Skip to content

Commit

Permalink
chore(all): prepare release 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Dec 3, 2016
1 parent 2f076a8 commit 993ada4
Show file tree
Hide file tree
Showing 11 changed files with 391 additions and 213 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.0.7",
"version": "1.1.0",
"description": "A powerful client-side router.",
"keywords": [
"aurelia",
Expand Down
126 changes: 75 additions & 51 deletions dist/amd/aurelia-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,13 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
NavigationInstruction.prototype._buildTitle = function _buildTitle() {
var separator = arguments.length <= 0 || arguments[0] === undefined ? ' | ' : arguments[0];

var title = this.config.navModel.title || '';
var title = '';
var childTitles = [];

if (this.config.navModel.title) {
title = this.router.transformTitle(this.config.navModel.title);
}

for (var viewPortName in this.viewPortInstructions) {
var _viewPortInstruction = this.viewPortInstructions[viewPortName];

Expand All @@ -396,7 +400,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}

if (this.router.title) {
title += (title ? separator : '') + this.router.title;
title += (title ? separator : '') + this.router.transformTitle(this.router.title);
}

return title;
Expand Down Expand Up @@ -518,6 +522,11 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
return this.addPipelineStep('postRender', step);
};

RouterConfiguration.prototype.fallbackRoute = function fallbackRoute(fragment) {
this._fallbackRoute = fragment;
return this;
};

RouterConfiguration.prototype.map = function map(route) {
if (Array.isArray(route)) {
route.forEach(this.map.bind(this));
Expand Down Expand Up @@ -575,6 +584,10 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
router.handleUnknownRoutes(this.unknownRouteConfig);
}

if (this._fallbackRoute) {
router.fallbackRoute = this._fallbackRoute;
}

router.options = this.options;

var pipelineSteps = this.pipelineSteps;
Expand Down Expand Up @@ -758,18 +771,27 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen

var Router = exports.Router = function () {
function Router(container, history) {
var _this2 = this;



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

this.transformTitle = function (title) {
if (_this2.parent) {
return _this2.parent.transformTitle(title);
}
return title;
};

this.container = container;
this.history = history;
this.reset();
}

Router.prototype.reset = function reset() {
var _this2 = this;
var _this3 = this;

this.viewPorts = {};
this.routes = [];
Expand All @@ -782,7 +804,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
this._recognizer = new _aureliaRouteRecognizer.RouteRecognizer();
this._childRecognizer = new _aureliaRouteRecognizer.RouteRecognizer();
this._configuredPromise = new Promise(function (resolve) {
_this2._resolveConfiguredPromise = resolve;
_this3._resolveConfiguredPromise = resolve;
});
};

Expand All @@ -796,7 +818,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
};

Router.prototype.configure = function configure(callbackOrConfig) {
var _this3 = this;
var _this4 = this;

this.isConfigured = true;

Expand All @@ -812,9 +834,9 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
config = c;
}

config.exportToRouter(_this3);
_this3.isConfigured = true;
_this3._resolveConfiguredPromise();
config.exportToRouter(_this4);
_this4.isConfigured = true;
_this4._resolveConfiguredPromise();
});
};

Expand Down Expand Up @@ -939,14 +961,14 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
};

Router.prototype.handleUnknownRoutes = function handleUnknownRoutes(config) {
var _this4 = this;
var _this5 = this;

if (!config) {
throw new Error('Invalid unknown route handler');
}

this.catchAllHandler = function (instruction) {
return _this4._createRouteConfig(config, instruction).then(function (c) {
return _this5._createRouteConfig(config, instruction).then(function (c) {
instruction.config = c;
return instruction;
});
Expand Down Expand Up @@ -1040,7 +1062,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
};

Router.prototype._createRouteConfig = function _createRouteConfig(config, instruction) {
var _this5 = this;
var _this6 = this;

return Promise.resolve(config).then(function (c) {
if (typeof c === 'string') {
Expand All @@ -1054,10 +1076,10 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
return typeof c === 'string' ? { moduleId: c } : c;
}).then(function (c) {
c.route = instruction.params.path;
validateRouteConfig(c, _this5.routes);
validateRouteConfig(c, _this6.routes);

if (!c.navModel) {
c.navModel = _this5.createNavModel(c);
c.navModel = _this6.createNavModel(c);
}

return c;
Expand Down Expand Up @@ -1520,10 +1542,10 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}

PipelineSlot.prototype.getSteps = function getSteps() {
var _this6 = this;
var _this7 = this;

return this.steps.map(function (x) {
return _this6.container.get(x);
return _this7.container.get(x);
});
};

Expand All @@ -1543,11 +1565,11 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
}

PipelineProvider.prototype.createPipeline = function createPipeline() {
var _this7 = this;
var _this8 = this;

var pipeline = new Pipeline();
this.steps.forEach(function (step) {
return pipeline.addStep(_this7.container.get(step));
return pipeline.addStep(_this8.container.get(step));
});
return pipeline;
};
Expand Down Expand Up @@ -1611,11 +1633,11 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
function AppRouter(container, history, pipelineProvider, events) {


var _this8 = _possibleConstructorReturn(this, _Router.call(this, container, history));
var _this9 = _possibleConstructorReturn(this, _Router.call(this, container, history));

_this8.pipelineProvider = pipelineProvider;
_this8.events = events;
return _this8;
_this9.pipelineProvider = pipelineProvider;
_this9.events = events;
return _this9;
}

AppRouter.prototype.reset = function reset() {
Expand All @@ -1629,35 +1651,35 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
};

AppRouter.prototype.loadUrl = function loadUrl(url) {
var _this9 = this;
var _this10 = this;

return this._createNavigationInstruction(url).then(function (instruction) {
return _this9._queueInstruction(instruction);
return _this10._queueInstruction(instruction);
}).catch(function (error) {
logger.error(error);
restorePreviousLocation(_this9);
restorePreviousLocation(_this10);
});
};

AppRouter.prototype.registerViewPort = function registerViewPort(viewPort, name) {
var _this10 = this;
var _this11 = this;

_Router.prototype.registerViewPort.call(this, viewPort, name);

if (!this.isActive) {
var _ret6 = function () {
var viewModel = _this10._findViewModel(viewPort);
var viewModel = _this11._findViewModel(viewPort);
if ('configureRouter' in viewModel) {
if (!_this10.isConfigured) {
if (!_this11.isConfigured) {
var _ret7 = function () {
var resolveConfiguredPromise = _this10._resolveConfiguredPromise;
_this10._resolveConfiguredPromise = function () {};
var resolveConfiguredPromise = _this11._resolveConfiguredPromise;
_this11._resolveConfiguredPromise = function () {};
return {
v: {
v: _this10.configure(function (config) {
return viewModel.configureRouter(config, _this10);
v: _this11.configure(function (config) {
return viewModel.configureRouter(config, _this11);
}).then(function () {
_this10.activate();
_this11.activate();
resolveConfiguredPromise();
})
}
Expand All @@ -1667,7 +1689,7 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
if ((typeof _ret7 === 'undefined' ? 'undefined' : _typeof(_ret7)) === "object") return _ret7.v;
}
} else {
_this10.activate();
_this11.activate();
}
}();

Expand Down Expand Up @@ -1696,53 +1718,53 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
};

AppRouter.prototype._queueInstruction = function _queueInstruction(instruction) {
var _this11 = this;
var _this12 = this;

return new Promise(function (resolve) {
instruction.resolve = resolve;
_this11._queue.unshift(instruction);
_this11._dequeueInstruction();
_this12._queue.unshift(instruction);
_this12._dequeueInstruction();
});
};

AppRouter.prototype._dequeueInstruction = function _dequeueInstruction() {
var _this12 = this;
var _this13 = this;

var instructionCount = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];

return Promise.resolve().then(function () {
if (_this12.isNavigating && !instructionCount) {
if (_this13.isNavigating && !instructionCount) {
return undefined;
}

var instruction = _this12._queue.shift();
_this12._queue.length = 0;
var instruction = _this13._queue.shift();
_this13._queue.length = 0;

if (!instruction) {
return undefined;
}

_this12.isNavigating = true;
instruction.previousInstruction = _this12.currentInstruction;
_this13.isNavigating = true;
instruction.previousInstruction = _this13.currentInstruction;

if (!instructionCount) {
_this12.events.publish('router:navigation:processing', { instruction: instruction });
} else if (instructionCount === _this12.maxInstructionCount - 1) {
_this13.events.publish('router:navigation:processing', { instruction: instruction });
} else if (instructionCount === _this13.maxInstructionCount - 1) {
logger.error(instructionCount + 1 + ' navigation instructions have been attempted without success. Restoring last known good location.');
restorePreviousLocation(_this12);
return _this12._dequeueInstruction(instructionCount + 1);
} else if (instructionCount > _this12.maxInstructionCount) {
restorePreviousLocation(_this13);
return _this13._dequeueInstruction(instructionCount + 1);
} else if (instructionCount > _this13.maxInstructionCount) {
throw new Error('Maximum navigation attempts exceeded. Giving up.');
}

var pipeline = _this12.pipelineProvider.createPipeline();
var pipeline = _this13.pipelineProvider.createPipeline();

return pipeline.run(instruction).then(function (result) {
return processResult(instruction, result, instructionCount, _this12);
return processResult(instruction, result, instructionCount, _this13);
}).catch(function (error) {
return { output: error instanceof Error ? error : new Error(error) };
}).then(function (result) {
return resolveInstruction(instruction, result, !!instructionCount, _this12);
return resolveInstruction(instruction, result, !!instructionCount, _this13);
});
});
};
Expand Down Expand Up @@ -1826,8 +1848,10 @@ define(['exports', 'aurelia-logging', 'aurelia-route-recognizer', 'aurelia-depen
var previousLocation = router.history.previousLocation;
if (previousLocation) {
router.navigate(router.history.previousLocation, { trigger: false, replace: true });
} else if (router.fallbackRoute) {
router.navigate(router.fallbackRoute, { trigger: true, replace: true });
} else {
logger.error('Router navigation failed, and no previous location could be restored.');
logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');
}
}
});
15 changes: 15 additions & 0 deletions dist/aurelia-router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,14 @@ export declare class RouterConfiguration {
*/
addPostRenderStep(step: Function | PipelineStep): RouterConfiguration;

/**
* Configures a route that will be used if there is no previous location available on navigation cancellation.
*
* @param fragment The URL fragment to use as the navigation destination.
* @chainable
*/
fallbackRoute(fragment: string): RouterConfiguration;

/**
* Maps one or more routes to be registered with the router.
*
Expand Down Expand Up @@ -662,6 +670,13 @@ export declare class Router {
parent: Router;
options: 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
* returns the title unchanged.
*/
transformTitle: ((title: string) => string);

/**
* @param container The [[Container]] to use when child routers.
* @param history The [[History]] implementation to delegate navigation requests to.
Expand Down
Loading

0 comments on commit 993ada4

Please sign in to comment.