Skip to content

Commit

Permalink
chore(all): prepare release 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jan 15, 2018
1 parent 26500b0 commit c1720c4
Show file tree
Hide file tree
Showing 11 changed files with 520 additions and 77 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-router",
"version": "1.4.0",
"version": "1.5.0",
"description": "A powerful client-side router.",
"keywords": [
"aurelia",
Expand Down
76 changes: 65 additions & 11 deletions dist/amd/aurelia-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,15 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen

if (viewPortInstruction.strategy === activationStrategy.replace) {
if (viewPortInstruction.childNavigationInstruction && viewPortInstruction.childNavigationInstruction.parentCatchHandler) {
loads.push(viewPortInstruction.childNavigationInstruction._commitChanges());
loads.push(viewPortInstruction.childNavigationInstruction._commitChanges(waitToSwap));
} else {
if (waitToSwap) {
delaySwaps.push({ viewPort: viewPort, viewPortInstruction: viewPortInstruction });
}
loads.push(viewPort.process(viewPortInstruction, waitToSwap).then(function (x) {
if (viewPortInstruction.childNavigationInstruction) {
return viewPortInstruction.childNavigationInstruction._commitChanges();
return viewPortInstruction.childNavigationInstruction._commitChanges(waitToSwap);
}

return undefined;
}));
}
} else {
Expand Down Expand Up @@ -552,6 +550,11 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
return this.mapRoute(route);
};

RouterConfiguration.prototype.useViewPortDefaults = function useViewPortDefaults(viewPortConfig) {
this.viewPortDefaults = viewPortConfig;
return this;
};

RouterConfiguration.prototype.mapRoute = function mapRoute(config) {
this.instructions.push(function (router) {
var routeConfigs = [];
Expand Down Expand Up @@ -604,6 +607,10 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
router.fallbackRoute = this._fallbackRoute;
}

if (this.viewPortDefaults) {
router.useViewPortDefaults(this.viewPortDefaults);
}

router.options = this.options;

var pipelineSteps = this.pipelineSteps;
Expand Down Expand Up @@ -648,9 +655,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}();

function _buildNavigationPlan(instruction, forceLifecycleMinimum) {
var prev = instruction.previousInstruction;
var config = instruction.config;
var plan = {};

if ('redirect' in config) {
var redirectLocation = _resolveUrl(config.redirect, getInstructionBaseUrl(instruction));
Expand All @@ -661,15 +666,20 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
return Promise.reject(new Redirect(redirectLocation));
}

var prev = instruction.previousInstruction;
var plan = {};
var defaults = instruction.router.viewPortDefaults;

if (prev) {
var newParams = hasDifferentParameterValues(prev, instruction);
var pending = [];

var _loop2 = function _loop2(viewPortName) {
var prevViewPortInstruction = prev.viewPortInstructions[viewPortName];
var nextViewPortConfig = config.viewPorts[viewPortName];

if (!nextViewPortConfig) throw new Error('Invalid Route Config: Configuration for viewPort "' + viewPortName + '" was not found for route: "' + instruction.config.route + '."');
var nextViewPortConfig = viewPortName in config.viewPorts ? config.viewPorts[viewPortName] : prevViewPortInstruction;
if (nextViewPortConfig.moduleId === null && viewPortName in instruction.router.viewPortDefaults) {
nextViewPortConfig = defaults[viewPortName];
}

var viewPortPlan = plan[viewPortName] = {
name: viewPortName,
Expand Down Expand Up @@ -716,10 +726,14 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}

for (var viewPortName in config.viewPorts) {
var viewPortConfig = config.viewPorts[viewPortName];
if (viewPortConfig.moduleId === null && viewPortName in instruction.router.viewPortDefaults) {
viewPortConfig = defaults[viewPortName];
}
plan[viewPortName] = {
name: viewPortName,
strategy: activationStrategy.replace,
config: instruction.config.viewPorts[viewPortName]
config: viewPortConfig
};
}

Expand Down Expand Up @@ -793,6 +807,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen

this.parent = null;
this.options = {};
this.viewPortDefaults = {};

this.transformTitle = function (title) {
if (_this3.parent) {
Expand All @@ -816,8 +831,14 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
this.isNavigating = false;
this.isExplicitNavigation = false;
this.isExplicitNavigationBack = false;
this.isNavigatingFirst = false;
this.isNavigatingNew = false;
this.isNavigatingRefresh = false;
this.isNavigatingForward = false;
this.isNavigatingBack = false;
this.navigation = [];
this.currentInstruction = null;
this.viewPortDefaults = {};
this._fallbackOrder = 100;
this._recognizer = new _aureliaRouteRecognizer.RouteRecognizer();
this._childRecognizer = new _aureliaRouteRecognizer.RouteRecognizer();
Expand Down Expand Up @@ -1019,6 +1040,15 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}
};

Router.prototype.useViewPortDefaults = function useViewPortDefaults(viewPortDefaults) {
for (var viewPortName in viewPortDefaults) {
var viewPortConfig = viewPortDefaults[viewPortName];
this.viewPortDefaults[viewPortName] = {
moduleId: viewPortConfig.moduleId
};
}
};

Router.prototype._refreshBaseUrl = function _refreshBaseUrl() {
if (this.parent) {
var baseUrl = this.parent.currentInstruction.getBaseUrl();
Expand Down Expand Up @@ -1519,7 +1549,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}

function loadRoute(routeLoader, navigationInstruction, viewPortPlan) {
var moduleId = viewPortPlan.config.moduleId;
var moduleId = viewPortPlan.config ? viewPortPlan.config.moduleId : null;

return loadComponent(routeLoader, navigationInstruction, viewPortPlan.config).then(function (component) {
var viewPortInstruction = navigationInstruction.addViewPortInstruction(viewPortPlan.name, viewPortPlan.strategy, moduleId, component);
Expand Down Expand Up @@ -1773,6 +1803,25 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}

_this14.isNavigating = true;

var navtracker = _this14.history.getState('NavigationTracker');
if (!navtracker && !_this14.currentNavigationTracker) {
_this14.isNavigatingFirst = true;
_this14.isNavigatingNew = true;
} else if (!navtracker) {
_this14.isNavigatingNew = true;
} else if (!_this14.currentNavigationTracker) {
_this14.isNavigatingRefresh = true;
} else if (_this14.currentNavigationTracker < navtracker) {
_this14.isNavigatingForward = true;
} else if (_this14.currentNavigationTracker > navtracker) {
_this14.isNavigatingBack = true;
}if (!navtracker) {
navtracker = Date.now();
_this14.history.setState('NavigationTracker', navtracker);
}
_this14.currentNavigationTracker = navtracker;

instruction.previousInstruction = _this14.currentInstruction;

if (!instructionCount) {
Expand Down Expand Up @@ -1855,6 +1904,11 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
router.isNavigating = false;
router.isExplicitNavigation = false;
router.isExplicitNavigationBack = false;
router.isNavigatingFirst = false;
router.isNavigatingNew = false;
router.isNavigatingRefresh = false;
router.isNavigatingForward = false;
router.isNavigatingBack = false;

var eventName = void 0;

Expand Down
61 changes: 57 additions & 4 deletions dist/aurelia-router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export declare interface RouteConfig {
/**
* specifies the model parameter to pass to the layout view model's `activate` function.
*/
layoutModel?: string;
layoutModel?: any;
[x: string]: any;
}

Expand Down Expand Up @@ -491,7 +491,7 @@ export declare class NavModel {
config: RouteConfig;

/**
* The router associated with this navitation model.
* The router associated with this navigation model.
*/
router: Router;
constructor(router: Router, relativeHref: string);
Expand Down Expand Up @@ -584,6 +584,7 @@ export declare class RouterConfiguration {
pipelineSteps: Array<Function | PipelineStep>;
title: string;
unknownRouteConfig: any;
viewPortDefaults: any;

/**
* Adds a step to be run during the [[Router]]'s navigation pipeline.
Expand Down Expand Up @@ -642,6 +643,15 @@ export declare class RouterConfiguration {
*/
map(route: RouteConfig | RouteConfig[]): RouterConfiguration;

/**
* Configures defaults to use for any view ports.
*
* @param viewPortConfig a view port configuration object to use as a
* default, of the form { viewPortName: { moduleId } }.
* @chainable
*/
useViewPortDefaults(viewPortConfig: any): any;

/**
* Maps a single route to be registered with the router.
*
Expand Down Expand Up @@ -712,6 +722,36 @@ export declare class Router {
*/
isExplicitNavigationBack: boolean;

/**
* True if the [[Router]] is navigating into the app for the first time in the browser session.
*/
isNavigatingFirst: boolean;

/**
* True if the [[Router]] is navigating to a page instance not in the browser session history.
*/
isNavigatingNew: boolean;

/**
* True if the [[Router]] is navigating forward in the browser session history.
*/
isNavigatingForward: boolean;

/**
* True if the [[Router]] is navigating back in the browser session history.
*/
isNavigatingBack: boolean;

/**
* True if the [[Router]] is navigating due to a browser refresh.
*/
isNavigatingRefresh: boolean;

/**
* The currently active navigation tracker.
*/
currentNavigationTracker: number;

/**
* The navigation models for routes that specified [[RouteConfig.nav]].
*/
Expand All @@ -728,6 +768,11 @@ export declare class Router {
parent: Router;
options: any;

/**
* The defaults used when a viewport lacks specified content
*/
viewPortDefaults: any;

/**
* Extension point to transform the document title before it is built and displayed.
* By default, child routers delegate to the parent router, and the app router
Expand Down Expand Up @@ -776,7 +821,7 @@ export declare class Router {
* Navigates to a new location.
*
* @param fragment The URL fragment to use as the navigation destination.
* @param options The navigation options.
* @param options The navigation options. See [[History.NavigationOptions]] for all available options.
*/
navigate(fragment: string, options?: any): boolean;

Expand All @@ -786,7 +831,7 @@ export declare class Router {
*
* @param route The name of the route to use when generating the navigation location.
* @param params The route parameters to be used when populating the route pattern.
* @param options The navigation options.
* @param options The navigation options. See [[History.NavigationOptions]] for all available options.
*/
navigateToRoute(route: string, params?: any, options?: any): boolean;

Expand All @@ -808,6 +853,7 @@ export declare class Router {
*
* @param name The name of the route whose pattern should be used to generate the fragment.
* @param params The route params to be used to populate the route pattern.
* @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.
* @returns {string} A string containing the generated URL fragment.
*/
generate(name: string, params?: any, options?: any): string;
Expand Down Expand Up @@ -858,6 +904,13 @@ export declare class Router {
* Note: This method will likely move to a plugin in a future release.
*/
refreshNavigation(): void;

/**
* Sets the default configuration for the view ports. This specifies how to
* populate a view port for which no module is specified. The default is
* an empty view/view-model pair.
*/
useViewPortDefaults(viewPortDefaults: any): any;
}
export declare class CanDeactivatePreviousStep {
run(navigationInstruction: NavigationInstruction, next: Function): any;
Expand Down
Loading

0 comments on commit c1720c4

Please sign in to comment.