Skip to content

Commit

Permalink
chore(all): prepare release 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jan 7, 2015
1 parent 9116d50 commit b0bd4cb
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 305 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": "0.3.0",
"version": "0.4.0",
"description": "A powerful client-side router.",
"keywords": [
"aurelia",
Expand Down
21 changes: 8 additions & 13 deletions dist/amd/app-router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(["exports", "aurelia-history", "./router", "./pipeline-provider", "./navigation-commands"], function (exports, _aureliaHistory, _router, _pipelineProvider, _navigationCommands) {
define(["exports", "aurelia-dependency-injection", "aurelia-history", "./router", "./pipeline-provider", "./navigation-commands"], function (exports, _aureliaDependencyInjection, _aureliaHistory, _router, _pipelineProvider, _navigationCommands) {
"use strict";

var _inherits = function (child, parent) {
Expand All @@ -16,22 +16,23 @@ define(["exports", "aurelia-history", "./router", "./pipeline-provider", "./navi
if (parent) child.__proto__ = parent;
};

var Container = _aureliaDependencyInjection.Container;
var History = _aureliaHistory.History;
var Router = _router.Router;
var PipelineProvider = _pipelineProvider.PipelineProvider;
var isNavigationCommand = _navigationCommands.isNavigationCommand;
var AppRouter = (function () {
var _Router = Router;
var AppRouter = function AppRouter(history, pipelineProvider) {
_Router.call(this, history);
var AppRouter = function AppRouter(container, history, pipelineProvider) {
_Router.call(this, container, history);
this.pipelineProvider = pipelineProvider;
document.addEventListener("click", handleLinkClick.bind(this), true);
};

_inherits(AppRouter, _Router);

AppRouter.inject = function () {
return [History, PipelineProvider];
return [Container, History, PipelineProvider];
};

AppRouter.prototype.loadUrl = function (url) {
Expand Down Expand Up @@ -97,18 +98,12 @@ define(["exports", "aurelia-history", "./router", "./pipeline-provider", "./navi
};

AppRouter.prototype.registerViewPort = function (viewPort, name) {
var _this4 = this;
name = name || "default";
this.viewPorts[name] = viewPort;
_Router.prototype.registerViewPort.call(this, viewPort, name);

if (!this.isActive) {
this.configureRouterForViewPort(viewPort, function () {
return _this4.activate();
});
this.activate();
} else {
this.configureRouterForViewPort(viewPort, function () {
return _this4.dequeueInstruction();
});
this.dequeueInstruction();
}
};

Expand Down
28 changes: 21 additions & 7 deletions dist/amd/navigation-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ define(["exports", "./navigation-plan"], function (exports, _navigationPlan) {
this.prevInstruction = router.currentInstruction;
};

NavigationContext.prototype.commitChanges = function () {
var next = this.nextInstruction, prev = this.prevInstruction, viewPortInstructions = next.viewPortInstructions, router = this.router;
NavigationContext.prototype.commitChanges = function (waitToSwap) {
var next = this.nextInstruction, prev = this.prevInstruction, viewPortInstructions = next.viewPortInstructions, router = this.router, loads = [], delaySwaps = [];

router.currentInstruction = next;

Expand All @@ -28,13 +28,27 @@ define(["exports", "./navigation-plan"], function (exports, _navigationPlan) {
var viewPort = router.viewPorts[viewPortName];

if (viewPortInstruction.strategy === REPLACE) {
viewPort.process(viewPortInstruction);
}
if (waitToSwap) {
delaySwaps.push({ viewPort: viewPort, viewPortInstruction: viewPortInstruction });
}

if ("childNavigationContext" in viewPortInstruction) {
viewPortInstruction.childNavigationContext.commitChanges();
loads.push(viewPort.process(viewPortInstruction, waitToSwap).then(function (x) {
if ("childNavigationContext" in viewPortInstruction) {
return viewPortInstruction.childNavigationContext.commitChanges();
}
}));
} else {
if ("childNavigationContext" in viewPortInstruction) {
loads.push(viewPortInstruction.childNavigationContext.commitChanges(waitToSwap));
}
}
}

return Promise.all(loads).then(function () {
delaySwaps.forEach(function (x) {
return x.viewPort.swap(x.viewPortInstruction);
});
});
};

NavigationContext.prototype.buildTitle = function () {
Expand Down Expand Up @@ -67,7 +81,7 @@ define(["exports", "./navigation-plan"], function (exports, _navigationPlan) {
var CommitChangesStep = function CommitChangesStep() {};

CommitChangesStep.prototype.run = function (navigationContext, next) {
navigationContext.commitChanges();
navigationContext.commitChanges(true);

var title = navigationContext.buildTitle();
if (title) {
Expand Down
35 changes: 14 additions & 21 deletions dist/amd/route-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ define(["exports", "./navigation-plan"], function (exports, _navigationPlan) {
var buildNavigationPlan = _navigationPlan.buildNavigationPlan;
var RouteLoader = function RouteLoader() {};

RouteLoader.prototype.loadRoute = function (config) {
throw Error("Route loaders must implment \"loadRoute(config)\".");
RouteLoader.prototype.loadRoute = function (router, config) {
throw Error("Route loaders must implment \"loadRoute(router, config)\".");
};

exports.RouteLoader = RouteLoader;
Expand Down Expand Up @@ -68,7 +68,7 @@ define(["exports", "./navigation-plan"], function (exports, _navigationPlan) {
var moduleId = viewPortPlan.config.moduleId;
var next = navigationContext.nextInstruction;

return resolveComponent(routeLoader, navigationContext.router, viewPortPlan).then(function (component) {
return loadComponent(routeLoader, navigationContext.router, viewPortPlan.config).then(function (component) {
var viewPortInstruction = next.addViewPortInstruction(viewPortPlan.name, viewPortPlan.strategy, moduleId, component);

var controller = component.executionContext;
Expand All @@ -90,25 +90,18 @@ define(["exports", "./navigation-plan"], function (exports, _navigationPlan) {
});
}

function resolveComponent(routeLoader, router, viewPortPlan) {
var possibleRouterViewPort = router.viewPorts[viewPortPlan.name];

return routeLoader.loadRoute(viewPortPlan.config).then(function (type) {
return new Promise(function (resolve, reject) {
function createChildRouter() {
return router.createChild();
}

function getComponent(routerViewPort) {
routerViewPort.getComponent(type, createChildRouter, viewPortPlan.config).then(resolve)["catch"](reject);
}
function loadComponent(routeLoader, router, config) {
return routeLoader.loadRoute(router, config).then(function (component) {
if ("configureRouter" in component.executionContext) {
var result = component.executionContext.configureRouter() || Promise.resolve();
return result.then(function () {
return component;
});
}

if (possibleRouterViewPort) {
getComponent(possibleRouterViewPort);
} else {
router.viewPorts[viewPortPlan.name] = getComponent;
}
});
component.router = router;
component.config = config;
return component;
});
}
});
46 changes: 11 additions & 35 deletions dist/amd/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,17 @@ define(["exports", "aurelia-route-recognizer", "aurelia-path", "./navigation-con
var NavigationInstruction = _navigationInstruction.NavigationInstruction;
var RouterConfiguration = _routerConfiguration.RouterConfiguration;
var processPotential = _util.processPotential;
var Router = function Router(history) {
var Router = function Router(container, history) {
this.container = container;
this.history = history;
this.viewPorts = {};
this.reset();
this.baseUrl = "";
};

Router.prototype.registerViewPort = function (viewPort, name) {
var _this = this;
name = name || "default";

if (typeof this.viewPorts[name] == "function") {
var callback = this.viewPorts[name];
this.viewPorts[name] = viewPort;
this.configureRouterForViewPort(viewPort, callback);
} else {
this.configureRouterForViewPort(viewPort, function () {
if (typeof _this.viewPorts[name] == "function") {
var callback = _this.viewPorts[name];
_this.viewPorts[name] = viewPort;
callback(viewPort);
} else {
_this.viewPorts[name] = viewPort;
}
});
}
};

Router.prototype.configureRouterForViewPort = function (viewPort, callback) {
if ("configureRouter" in viewPort.executionContext) {
var result = viewPort.executionContext.configureRouter() || Promise.resolve();
result.then(function () {
return callback(viewPort);
});
} else {
callback(viewPort);
}
this.viewPorts[name] = viewPort;
};

Router.prototype.refreshBaseUrl = function () {
Expand All @@ -59,10 +33,12 @@ define(["exports", "aurelia-route-recognizer", "aurelia-path", "./navigation-con
for (var i = 0, length = nav.length; i < length; i++) {
var current = nav[i];

if (this.baseUrl[0] == "/") {
current.href = "#" + this.baseUrl;
} else {
current.href = "#/" + this.baseUrl;
if (!this.history._hasPushState) {
if (this.baseUrl[0] == "/") {
current.href = "#" + this.baseUrl;
} else {
current.href = "#/" + this.baseUrl;
}
}

if (current.href[current.href.length - 1] != "/") {
Expand Down Expand Up @@ -94,8 +70,8 @@ define(["exports", "aurelia-route-recognizer", "aurelia-path", "./navigation-con
this.history.navigateBack();
};

Router.prototype.createChild = function () {
var childRouter = new Router(this.history);
Router.prototype.createChild = function (container) {
var childRouter = new Router(container || this.container.createChild(), this.history);
childRouter.parent = this;
return childRouter;
};
Expand Down
19 changes: 7 additions & 12 deletions dist/commonjs/app-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ var _inherits = function (child, parent) {
if (parent) child.__proto__ = parent;
};

var Container = require("aurelia-dependency-injection").Container;
var History = require("aurelia-history").History;
var Router = require("./router").Router;
var PipelineProvider = require("./pipeline-provider").PipelineProvider;
var isNavigationCommand = require("./navigation-commands").isNavigationCommand;
var AppRouter = (function () {
var _Router = Router;
var AppRouter = function AppRouter(history, pipelineProvider) {
_Router.call(this, history);
var AppRouter = function AppRouter(container, history, pipelineProvider) {
_Router.call(this, container, history);
this.pipelineProvider = pipelineProvider;
document.addEventListener("click", handleLinkClick.bind(this), true);
};

_inherits(AppRouter, _Router);

AppRouter.inject = function () {
return [History, PipelineProvider];
return [Container, History, PipelineProvider];
};

AppRouter.prototype.loadUrl = function (url) {
Expand Down Expand Up @@ -96,18 +97,12 @@ var AppRouter = (function () {
};

AppRouter.prototype.registerViewPort = function (viewPort, name) {
var _this4 = this;
name = name || "default";
this.viewPorts[name] = viewPort;
_Router.prototype.registerViewPort.call(this, viewPort, name);

if (!this.isActive) {
this.configureRouterForViewPort(viewPort, function () {
return _this4.activate();
});
this.activate();
} else {
this.configureRouterForViewPort(viewPort, function () {
return _this4.dequeueInstruction();
});
this.dequeueInstruction();
}
};

Expand Down
28 changes: 21 additions & 7 deletions dist/commonjs/navigation-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ var NavigationContext = function NavigationContext(router, nextInstruction) {
this.prevInstruction = router.currentInstruction;
};

NavigationContext.prototype.commitChanges = function () {
var next = this.nextInstruction, prev = this.prevInstruction, viewPortInstructions = next.viewPortInstructions, router = this.router;
NavigationContext.prototype.commitChanges = function (waitToSwap) {
var next = this.nextInstruction, prev = this.prevInstruction, viewPortInstructions = next.viewPortInstructions, router = this.router, loads = [], delaySwaps = [];

router.currentInstruction = next;

Expand All @@ -27,13 +27,27 @@ NavigationContext.prototype.commitChanges = function () {
var viewPort = router.viewPorts[viewPortName];

if (viewPortInstruction.strategy === REPLACE) {
viewPort.process(viewPortInstruction);
}
if (waitToSwap) {
delaySwaps.push({ viewPort: viewPort, viewPortInstruction: viewPortInstruction });
}

if ("childNavigationContext" in viewPortInstruction) {
viewPortInstruction.childNavigationContext.commitChanges();
loads.push(viewPort.process(viewPortInstruction, waitToSwap).then(function (x) {
if ("childNavigationContext" in viewPortInstruction) {
return viewPortInstruction.childNavigationContext.commitChanges();
}
}));
} else {
if ("childNavigationContext" in viewPortInstruction) {
loads.push(viewPortInstruction.childNavigationContext.commitChanges(waitToSwap));
}
}
}

return Promise.all(loads).then(function () {
delaySwaps.forEach(function (x) {
return x.viewPort.swap(x.viewPortInstruction);
});
});
};

NavigationContext.prototype.buildTitle = function () {
Expand Down Expand Up @@ -66,7 +80,7 @@ exports.NavigationContext = NavigationContext;
var CommitChangesStep = function CommitChangesStep() {};

CommitChangesStep.prototype.run = function (navigationContext, next) {
navigationContext.commitChanges();
navigationContext.commitChanges(true);

var title = navigationContext.buildTitle();
if (title) {
Expand Down
Loading

0 comments on commit b0bd4cb

Please sign in to comment.