Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aurelia-templating-router

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aurelia-templating-router - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

test/module-view-only.html

6

bower.json
{
"name": "aurelia-templating-router",
"version": "1.0.1",
"version": "1.1.0",
"description": "An implementation of the RouteLoader interface for use with the router module. Also contains a custom element that allows the templating engine to display the current route.",

@@ -25,7 +25,7 @@ "keywords": [

"aurelia-metadata": "^1.0.0",
"aurelia-pal": "^1.0.0",
"aurelia-pal": "^1.3.0",
"aurelia-path": "^1.0.0",
"aurelia-router": "^1.0.1",
"aurelia-templating": "^1.0.0"
"aurelia-templating": "^1.3.0"
}
}
System.config({
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"runtime",
"optimisation.modules.system"
]
},
paths: {

@@ -17,5 +10,5 @@ "github:*": "jspm_packages/github/*",

map: {
"aurelia-binding": "npm:aurelia-binding@1.0.9",
"aurelia-binding": "npm:aurelia-binding@1.2.0",
"aurelia-bootstrapper": "npm:aurelia-bootstrapper@1.0.0-rc.1.0.1",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.3.0",
"aurelia-event-aggregator": "npm:aurelia-event-aggregator@1.0.0",

@@ -26,11 +19,11 @@ "aurelia-framework": "npm:aurelia-framework@1.0.0-rc.1.0.13",

"aurelia-loader-default": "npm:aurelia-loader-default@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-logging-console": "npm:aurelia-logging-console@1.0.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-pal-browser": "npm:aurelia-pal-browser@1.0.0",
"aurelia-path": "npm:aurelia-path@1.0.0",
"aurelia-path": "npm:aurelia-path@1.1.1",
"aurelia-polyfills": "npm:aurelia-polyfills@1.0.0",
"aurelia-router": "npm:aurelia-router@1.0.1",
"aurelia-templating": "npm:aurelia-templating@1.0.0",
"aurelia-templating": "npm:aurelia-templating@1.3.0",
"aurelia-templating-binding": "npm:aurelia-templating-binding@1.0.0-rc.1.0.1",

@@ -67,14 +60,8 @@ "aurelia-templating-resources": "npm:aurelia-templating-resources@1.0.0-rc.1.0.2",

},
"npm:aurelia-binding@1.0.0": {
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-task-queue": "npm:aurelia-task-queue@1.0.0"
"npm:aurelia-binding@1.2.0": {
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-task-queue": "npm:aurelia-task-queue@1.2.0"
},
"npm:aurelia-binding@1.0.9": {
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-task-queue": "npm:aurelia-task-queue@1.1.0"
},
"npm:aurelia-bootstrapper@1.0.0-rc.1.0.1": {

@@ -87,7 +74,7 @@ "aurelia-event-aggregator": "npm:aurelia-event-aggregator@1.0.0",

"aurelia-logging-console": "npm:aurelia-logging-console@1.0.0",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-pal-browser": "npm:aurelia-pal-browser@1.0.0",
"aurelia-polyfills": "npm:aurelia-polyfills@1.0.0",
"aurelia-router": "npm:aurelia-router@1.0.1",
"aurelia-templating": "npm:aurelia-templating@1.0.0",
"aurelia-templating": "npm:aurelia-templating@1.3.0",
"aurelia-templating-binding": "npm:aurelia-templating-binding@1.0.0-rc.1.0.1",

@@ -97,103 +84,100 @@ "aurelia-templating-resources": "npm:aurelia-templating-resources@1.0.0-rc.1.0.2",

},
"npm:aurelia-dependency-injection@1.0.0": {
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0"
"npm:aurelia-dependency-injection@1.3.0": {
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0"
},
"npm:aurelia-event-aggregator@1.0.0": {
"aurelia-logging": "npm:aurelia-logging@1.2.0"
"aurelia-logging": "npm:aurelia-logging@1.3.0"
},
"npm:aurelia-framework@1.0.0-rc.1.0.13": {
"aurelia-binding": "npm:aurelia-binding@1.0.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0",
"aurelia-binding": "npm:aurelia-binding@1.2.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.3.0",
"aurelia-loader": "npm:aurelia-loader@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-path": "npm:aurelia-path@1.0.0",
"aurelia-task-queue": "npm:aurelia-task-queue@1.0.0",
"aurelia-templating": "npm:aurelia-templating@1.0.0"
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-path": "npm:aurelia-path@1.1.1",
"aurelia-task-queue": "npm:aurelia-task-queue@1.2.0",
"aurelia-templating": "npm:aurelia-templating@1.3.0"
},
"npm:aurelia-history-browser@1.0.0": {
"aurelia-history": "npm:aurelia-history@1.0.0",
"aurelia-pal": "npm:aurelia-pal@1.0.0"
"aurelia-pal": "npm:aurelia-pal@1.3.0"
},
"npm:aurelia-loader-default@1.0.0": {
"aurelia-loader": "npm:aurelia-loader@1.0.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0"
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0"
},
"npm:aurelia-loader@1.0.0": {
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-path": "npm:aurelia-path@1.0.0"
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-path": "npm:aurelia-path@1.1.1"
},
"npm:aurelia-logging-console@1.0.0": {
"aurelia-logging": "npm:aurelia-logging@1.2.0"
"aurelia-logging": "npm:aurelia-logging@1.3.0"
},
"npm:aurelia-metadata@1.0.2": {
"aurelia-pal": "npm:aurelia-pal@1.0.0"
"npm:aurelia-metadata@1.0.3": {
"aurelia-pal": "npm:aurelia-pal@1.3.0"
},
"npm:aurelia-pal-browser@1.0.0": {
"aurelia-pal": "npm:aurelia-pal@1.0.0"
"aurelia-pal": "npm:aurelia-pal@1.3.0"
},
"npm:aurelia-polyfills@1.0.0": {
"aurelia-pal": "npm:aurelia-pal@1.0.0"
"aurelia-pal": "npm:aurelia-pal@1.3.0"
},
"npm:aurelia-route-recognizer@1.0.0": {
"aurelia-path": "npm:aurelia-path@1.0.0"
"aurelia-path": "npm:aurelia-path@1.1.1"
},
"npm:aurelia-router@1.0.1": {
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.3.0",
"aurelia-event-aggregator": "npm:aurelia-event-aggregator@1.0.0",
"aurelia-history": "npm:aurelia-history@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-path": "npm:aurelia-path@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-path": "npm:aurelia-path@1.1.1",
"aurelia-route-recognizer": "npm:aurelia-route-recognizer@1.0.0"
},
"npm:aurelia-task-queue@1.0.0": {
"aurelia-pal": "npm:aurelia-pal@1.0.0"
"npm:aurelia-task-queue@1.2.0": {
"aurelia-pal": "npm:aurelia-pal@1.3.0"
},
"npm:aurelia-task-queue@1.1.0": {
"aurelia-pal": "npm:aurelia-pal@1.0.0"
},
"npm:aurelia-templating-binding@1.0.0-rc.1.0.1": {
"aurelia-binding": "npm:aurelia-binding@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-templating": "npm:aurelia-templating@1.0.0"
"aurelia-binding": "npm:aurelia-binding@1.2.0",
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-templating": "npm:aurelia-templating@1.3.0"
},
"npm:aurelia-templating-resources@1.0.0-rc.1.0.2": {
"aurelia-binding": "npm:aurelia-binding@1.0.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0",
"aurelia-binding": "npm:aurelia-binding@1.2.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.3.0",
"aurelia-loader": "npm:aurelia-loader@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-path": "npm:aurelia-path@1.0.0",
"aurelia-task-queue": "npm:aurelia-task-queue@1.0.0",
"aurelia-templating": "npm:aurelia-templating@1.0.0"
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-path": "npm:aurelia-path@1.1.1",
"aurelia-task-queue": "npm:aurelia-task-queue@1.2.0",
"aurelia-templating": "npm:aurelia-templating@1.3.0"
},
"npm:aurelia-templating-router@1.0.0-rc.1.0.1": {
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-path": "npm:aurelia-path@1.0.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.3.0",
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-path": "npm:aurelia-path@1.1.1",
"aurelia-router": "npm:aurelia-router@1.0.1",
"aurelia-templating": "npm:aurelia-templating@1.0.0"
"aurelia-templating": "npm:aurelia-templating@1.3.0"
},
"npm:aurelia-templating@1.0.0": {
"aurelia-binding": "npm:aurelia-binding@1.0.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0",
"npm:aurelia-templating@1.3.0": {
"aurelia-binding": "npm:aurelia-binding@1.2.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.3.0",
"aurelia-loader": "npm:aurelia-loader@1.0.0",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.2",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-path": "npm:aurelia-path@1.0.0",
"aurelia-task-queue": "npm:aurelia-task-queue@1.0.0"
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-metadata": "npm:aurelia-metadata@1.0.3",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-path": "npm:aurelia-path@1.1.1",
"aurelia-task-queue": "npm:aurelia-task-queue@1.2.0"
},
"npm:aurelia-testing@0.5.0": {
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0",
"aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.3.0",
"aurelia-framework": "npm:aurelia-framework@1.0.0-rc.1.0.13",
"aurelia-logging": "npm:aurelia-logging@1.2.0",
"aurelia-pal": "npm:aurelia-pal@1.0.0",
"aurelia-templating": "npm:aurelia-templating@1.0.0"
"aurelia-logging": "npm:aurelia-logging@1.3.0",
"aurelia-pal": "npm:aurelia-pal@1.3.0",
"aurelia-templating": "npm:aurelia-templating@1.3.0"
},

@@ -200,0 +184,0 @@ "npm:babel-runtime@5.8.38": {

@@ -1,2 +0,2 @@

define(['exports', 'aurelia-router', './route-loader', './router-view', './route-href'], function (exports, _aureliaRouter, _routeLoader, _routerView, _routeHref) {
define(['exports', 'aurelia-pal', 'aurelia-router', './route-loader', './router-view', './route-href'], function (exports, _aureliaPal, _aureliaRouter, _routeLoader, _routerView, _routeHref) {
'use strict';

@@ -11,3 +11,3 @@

function configure(config) {
config.singleton(_aureliaRouter.RouteLoader, _routeLoader.TemplatingRouteLoader).singleton(_aureliaRouter.Router, _aureliaRouter.AppRouter).globalResources('./router-view', './route-href');
config.singleton(_aureliaRouter.RouteLoader, _routeLoader.TemplatingRouteLoader).singleton(_aureliaRouter.Router, _aureliaRouter.AppRouter).globalResources(_aureliaPal.PLATFORM.moduleName('./router-view'), _aureliaPal.PLATFORM.moduleName('./route-href'));

@@ -14,0 +14,0 @@ config.container.registerAlias(_aureliaRouter.Router, _aureliaRouter.AppRouter);

@@ -1,2 +0,2 @@

define(['exports', 'aurelia-dependency-injection', 'aurelia-templating', 'aurelia-router', 'aurelia-path', 'aurelia-metadata'], function (exports, _aureliaDependencyInjection, _aureliaTemplating, _aureliaRouter, _aureliaPath, _aureliaMetadata) {
define(['exports', 'aurelia-dependency-injection', 'aurelia-templating', 'aurelia-router', 'aurelia-path', 'aurelia-metadata', './router-view'], function (exports, _aureliaDependencyInjection, _aureliaTemplating, _aureliaRouter, _aureliaPath, _aureliaMetadata, _routerView) {
'use strict';

@@ -51,4 +51,7 @@

var childContainer = router.container.createChild();
var viewModel = /\.html/.test(config.moduleId) ? createDynamicClass(config.moduleId) : (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
var instruction = {
viewModel: (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -59,2 +62,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(_routerView.RouterViewLocator);
childContainer.getChildRouter = function () {

@@ -75,2 +80,24 @@ var childRouter = void 0;

}(_aureliaRouter.RouteLoader)) || _class);
function createDynamicClass(moduleId) {
var _dec2, _dec3, _class2;
var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
var DynamicClass = (_dec2 = (0, _aureliaTemplating.customElement)(name), _dec3 = (0, _aureliaTemplating.useView)(moduleId), _dec2(_class2 = _dec3(_class2 = function () {
function DynamicClass() {
}
DynamicClass.prototype.bind = function bind(bindingContext) {
this.$parent = bindingContext;
};
return DynamicClass;
}()) || _class2) || _class2);
return DynamicClass;
}
});

@@ -7,3 +7,3 @@ define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-templating', 'aurelia-router', 'aurelia-metadata', 'aurelia-pal'], function (exports, _aureliaDependencyInjection, _aureliaBinding, _aureliaTemplating, _aureliaRouter, _aureliaMetadata, _aureliaPal) {

});
exports.RouterView = undefined;
exports.RouterViewLocator = exports.RouterView = undefined;

@@ -20,2 +20,4 @@ function _initDefineProp(target, property, descriptor, context) {

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {

@@ -56,40 +58,2 @@ var desc = {};

var SwapStrategies = function () {
function SwapStrategies() {
}
SwapStrategies.prototype.before = function before(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(function () {
return viewSlot.remove(previousView, true);
});
}
return promise;
};
SwapStrategies.prototype.with = function _with(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
};
SwapStrategies.prototype.after = function after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
};
return SwapStrategies;
}();
var swapStrategies = new SwapStrategies();
var RouterView = exports.RouterView = (_dec = (0, _aureliaTemplating.customElement)('router-view'), _dec2 = (0, _aureliaDependencyInjection.inject)(_aureliaPal.DOM.Element, _aureliaDependencyInjection.Container, _aureliaTemplating.ViewSlot, _aureliaRouter.Router, _aureliaTemplating.ViewLocator, _aureliaTemplating.CompositionTransaction, _aureliaTemplating.CompositionEngine), _dec(_class = (0, _aureliaTemplating.noView)(_class = _dec2(_class = (_class2 = function () {

@@ -142,2 +106,4 @@ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {

childContainer.get(RouterViewLocator)._notify(this);
var layoutInstruction = {

@@ -180,16 +146,12 @@ viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,

var layoutInstruction = viewPortInstruction.layoutInstruction;
var previousView = this.view;
var work = function work() {
var previousView = _this2.view;
var swapStrategy = void 0;
var swapStrategy = _aureliaTemplating.SwapStrategies[_this2.swapOrder] || _aureliaTemplating.SwapStrategies.after;
var viewSlot = _this2.viewSlot;
swapStrategy = _this2.swapOrder in swapStrategies ? swapStrategies[_this2.swapOrder] : swapStrategies.after;
swapStrategy(viewSlot, previousView, function () {
return Promise.resolve().then(function () {
return viewSlot.add(_this2.view);
}).then(function () {
_this2._notify();
});
return Promise.resolve(viewSlot.add(_this2.view));
}).then(function () {
_this2._notify();
});

@@ -252,2 +214,24 @@ };

})), _class2)) || _class) || _class) || _class);
var RouterViewLocator = exports.RouterViewLocator = function () {
function RouterViewLocator() {
var _this3 = this;
this.promise = new Promise(function (resolve) {
return _this3.resolve = resolve;
});
}
RouterViewLocator.prototype.findNearest = function findNearest() {
return this.promise;
};
RouterViewLocator.prototype._notify = function _notify(routerView) {
this.resolve(routerView);
};
return RouterViewLocator;
}();
});

@@ -12,3 +12,5 @@ import * as LogManager from 'aurelia-logging';

CompositionEngine,
ShadowDOM
ShadowDOM,
SwapStrategies,
useView
} from 'aurelia-templating';

@@ -47,2 +49,3 @@ import {

layoutModel: any;
element: any;
constructor(element?: any, container?: any, viewSlot?: any, router?: any, viewLocator?: any, compositionTransaction?: any, compositionEngine?: any);

@@ -54,2 +57,19 @@ created(owningView?: any): any;

}
/**
* Locator which finds the nearest RouterView, relative to the current dependency injection container.
*/
export declare class RouterViewLocator {
/**
* Creates an instance of the RouterViewLocator class.
*/
constructor();
/**
* Finds the nearest RouterView instance.
* @returns A promise that will be resolved with the located RouterView instance.
*/
findNearest(): Promise<RouterView>;
}
export declare class TemplatingRouteLoader extends RouteLoader {

@@ -56,0 +76,0 @@ constructor(compositionEngine?: any);

import * as LogManager from 'aurelia-logging';
import {customAttribute,bindable,ViewSlot,ViewLocator,customElement,noView,BehaviorInstruction,CompositionTransaction,CompositionEngine,ShadowDOM} from 'aurelia-templating';
import {customAttribute,bindable,ViewSlot,ViewLocator,customElement,noView,BehaviorInstruction,CompositionTransaction,CompositionEngine,ShadowDOM,SwapStrategies,useView} from 'aurelia-templating';
import {inject,Container} from 'aurelia-dependency-injection';

@@ -62,33 +62,2 @@ import {Router,RouteLoader} from 'aurelia-router';

class SwapStrategies {
// animate the next view in before removing the current view;
before(viewSlot, previousView, callback) {
let promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(() => viewSlot.remove(previousView, true));
}
return promise;
}
// animate the next view at the same time the current view is removed
with(viewSlot, previousView, callback) {
let promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
}
// animate the next view in after the current view has been removed
after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
}
}
const swapStrategies = new SwapStrategies();
@customElement('router-view')

@@ -102,2 +71,3 @@ @noView

@bindable layoutModel;
element;

@@ -138,2 +108,4 @@ constructor(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {

childContainer.get(RouterViewLocator)._notify(this);
// layoutInstruction is our layout viewModel

@@ -182,18 +154,12 @@ let layoutInstruction = {

let layoutInstruction = viewPortInstruction.layoutInstruction;
let previousView = this.view;
let work = () => {
let previousView = this.view;
let swapStrategy;
let swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;
let viewSlot = this.viewSlot;
swapStrategy = this.swapOrder in swapStrategies
? swapStrategies[this.swapOrder]
: swapStrategies.after;
swapStrategy(viewSlot, previousView, () => {
return Promise.resolve().then(() => {
return viewSlot.add(this.view);
}).then(() => {
this._notify();
});
return Promise.resolve(viewSlot.add(this.view));
}).then(() => {
this._notify();
});

@@ -245,2 +211,26 @@ };

/**
* Locator which finds the nearest RouterView, relative to the current dependency injection container.
*/
export class RouterViewLocator {
/**
* Creates an instance of the RouterViewLocator class.
*/
constructor() {
this.promise = new Promise((resolve) => this.resolve = resolve);
}
/**
* Finds the nearest RouterView instance.
* @returns A promise that will be resolved with the located RouterView instance.
*/
findNearest(): Promise<RouterView> {
return this.promise;
}
_notify(routerView: RouterView): void {
this.resolve(routerView);
}
}
@inject(CompositionEngine)

@@ -255,4 +245,9 @@ export class TemplatingRouteLoader extends RouteLoader {

let childContainer = router.container.createChild();
let viewModel = /\.html/.test(config.moduleId)
? createDynamicClass(config.moduleId)
: relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
let instruction = {
viewModel: relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -263,2 +258,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function() {

@@ -277,1 +274,15 @@ let childRouter;

}
function createDynamicClass(moduleId) {
let name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
@customElement(name)
@useView(moduleId)
class DynamicClass {
bind(bindingContext) {
this.$parent = bindingContext;
}
}
return DynamicClass;
}

@@ -8,2 +8,4 @@ 'use strict';

var _aureliaPal = require('aurelia-pal');
var _aureliaRouter = require('aurelia-router');

@@ -18,3 +20,3 @@

function configure(config) {
config.singleton(_aureliaRouter.RouteLoader, _routeLoader.TemplatingRouteLoader).singleton(_aureliaRouter.Router, _aureliaRouter.AppRouter).globalResources('./router-view', './route-href');
config.singleton(_aureliaRouter.RouteLoader, _routeLoader.TemplatingRouteLoader).singleton(_aureliaRouter.Router, _aureliaRouter.AppRouter).globalResources(_aureliaPal.PLATFORM.moduleName('./router-view'), _aureliaPal.PLATFORM.moduleName('./route-href'));

@@ -21,0 +23,0 @@ config.container.registerAlias(_aureliaRouter.Router, _aureliaRouter.AppRouter);

@@ -20,4 +20,6 @@ 'use strict';

var _routerView = require('./router-view');
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

@@ -41,4 +43,7 @@

var childContainer = router.container.createChild();
var viewModel = /\.html/.test(config.moduleId) ? createDynamicClass(config.moduleId) : (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
var instruction = {
viewModel: (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -49,2 +54,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(_routerView.RouterViewLocator);
childContainer.getChildRouter = function () {

@@ -64,2 +71,24 @@ var childRouter = void 0;

return TemplatingRouteLoader;
}(_aureliaRouter.RouteLoader)) || _class);
}(_aureliaRouter.RouteLoader)) || _class);
function createDynamicClass(moduleId) {
var _dec2, _dec3, _class2;
var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
var DynamicClass = (_dec2 = (0, _aureliaTemplating.customElement)(name), _dec3 = (0, _aureliaTemplating.useView)(moduleId), _dec2(_class2 = _dec3(_class2 = function () {
function DynamicClass() {
}
DynamicClass.prototype.bind = function bind(bindingContext) {
this.$parent = bindingContext;
};
return DynamicClass;
}()) || _class2) || _class2);
return DynamicClass;
}

@@ -6,3 +6,3 @@ 'use strict';

});
exports.RouterView = undefined;
exports.RouterViewLocator = exports.RouterView = undefined;

@@ -33,2 +33,4 @@ var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {

@@ -67,40 +69,2 @@ var desc = {};

var SwapStrategies = function () {
function SwapStrategies() {
}
SwapStrategies.prototype.before = function before(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(function () {
return viewSlot.remove(previousView, true);
});
}
return promise;
};
SwapStrategies.prototype.with = function _with(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
};
SwapStrategies.prototype.after = function after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
};
return SwapStrategies;
}();
var swapStrategies = new SwapStrategies();
var RouterView = exports.RouterView = (_dec = (0, _aureliaTemplating.customElement)('router-view'), _dec2 = (0, _aureliaDependencyInjection.inject)(_aureliaPal.DOM.Element, _aureliaDependencyInjection.Container, _aureliaTemplating.ViewSlot, _aureliaRouter.Router, _aureliaTemplating.ViewLocator, _aureliaTemplating.CompositionTransaction, _aureliaTemplating.CompositionEngine), _dec(_class = (0, _aureliaTemplating.noView)(_class = _dec2(_class = (_class2 = function () {

@@ -153,2 +117,4 @@ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {

childContainer.get(RouterViewLocator)._notify(this);
var layoutInstruction = {

@@ -191,16 +157,12 @@ viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,

var layoutInstruction = viewPortInstruction.layoutInstruction;
var previousView = this.view;
var work = function work() {
var previousView = _this2.view;
var swapStrategy = void 0;
var swapStrategy = _aureliaTemplating.SwapStrategies[_this2.swapOrder] || _aureliaTemplating.SwapStrategies.after;
var viewSlot = _this2.viewSlot;
swapStrategy = _this2.swapOrder in swapStrategies ? swapStrategies[_this2.swapOrder] : swapStrategies.after;
swapStrategy(viewSlot, previousView, function () {
return Promise.resolve().then(function () {
return viewSlot.add(_this2.view);
}).then(function () {
_this2._notify();
});
return Promise.resolve(viewSlot.add(_this2.view));
}).then(function () {
_this2._notify();
});

@@ -262,2 +224,24 @@ };

initializer: null
})), _class2)) || _class) || _class) || _class);
})), _class2)) || _class) || _class) || _class);
var RouterViewLocator = exports.RouterViewLocator = function () {
function RouterViewLocator() {
var _this3 = this;
this.promise = new Promise(function (resolve) {
return _this3.resolve = resolve;
});
}
RouterViewLocator.prototype.findNearest = function findNearest() {
return this.promise;
};
RouterViewLocator.prototype._notify = function _notify(routerView) {
this.resolve(routerView);
};
return RouterViewLocator;
}();

@@ -0,1 +1,2 @@

import { PLATFORM } from 'aurelia-pal';
import { Router, AppRouter, RouteLoader } from 'aurelia-router';

@@ -7,3 +8,3 @@ import { TemplatingRouteLoader } from './route-loader';

function configure(config) {
config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources('./router-view', './route-href');
config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources(PLATFORM.moduleName('./router-view'), PLATFORM.moduleName('./route-href'));

@@ -10,0 +11,0 @@ config.container.registerAlias(Router, AppRouter);

var _dec, _class;
import { inject } from 'aurelia-dependency-injection';
import { CompositionEngine } from 'aurelia-templating';
import { CompositionEngine, useView, customElement } from 'aurelia-templating';
import { RouteLoader, Router } from 'aurelia-router';
import { relativeToFile } from 'aurelia-path';
import { Origin } from 'aurelia-metadata';
import { RouterViewLocator } from './router-view';

@@ -17,4 +18,7 @@ export let TemplatingRouteLoader = (_dec = inject(CompositionEngine), _dec(_class = class TemplatingRouteLoader extends RouteLoader {

let childContainer = router.container.createChild();
let viewModel = /\.html/.test(config.moduleId) ? createDynamicClass(config.moduleId) : relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
let instruction = {
viewModel: relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -25,2 +29,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function () {

@@ -38,2 +44,17 @@ let childRouter;

}
}) || _class);
}) || _class);
function createDynamicClass(moduleId) {
var _dec2, _dec3, _class2;
let name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
let DynamicClass = (_dec2 = customElement(name), _dec3 = useView(moduleId), _dec2(_class2 = _dec3(_class2 = class DynamicClass {
bind(bindingContext) {
this.$parent = bindingContext;
}
}) || _class2) || _class2);
return DynamicClass;
}

@@ -48,3 +48,3 @@ var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;

import { createOverrideContext } from 'aurelia-binding';
import { ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM } from 'aurelia-templating';
import { ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, SwapStrategies } from 'aurelia-templating';
import { Router } from 'aurelia-router';

@@ -54,31 +54,2 @@ import { Origin } from 'aurelia-metadata';

let SwapStrategies = class SwapStrategies {
before(viewSlot, previousView, callback) {
let promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(() => viewSlot.remove(previousView, true));
}
return promise;
}
with(viewSlot, previousView, callback) {
let promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
}
after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
}
};
const swapStrategies = new SwapStrategies();
export let RouterView = (_dec = customElement('router-view'), _dec2 = inject(DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine), _dec(_class = noView(_class = _dec2(_class = (_class2 = class RouterView {

@@ -128,2 +99,4 @@

childContainer.get(RouterViewLocator)._notify(this);
let layoutInstruction = {

@@ -164,16 +137,12 @@ viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,

let layoutInstruction = viewPortInstruction.layoutInstruction;
let previousView = this.view;
let work = () => {
let previousView = this.view;
let swapStrategy;
let swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;
let viewSlot = this.viewSlot;
swapStrategy = this.swapOrder in swapStrategies ? swapStrategies[this.swapOrder] : swapStrategies.after;
swapStrategy(viewSlot, previousView, () => {
return Promise.resolve().then(() => {
return viewSlot.add(this.view);
}).then(() => {
this._notify();
});
return Promise.resolve(viewSlot.add(this.view));
}).then(() => {
this._notify();
});

@@ -233,2 +202,16 @@ };

initializer: null
})), _class2)) || _class) || _class) || _class);
})), _class2)) || _class) || _class) || _class);
export let RouterViewLocator = class RouterViewLocator {
constructor() {
this.promise = new Promise(resolve => this.resolve = resolve);
}
findNearest() {
return this.promise;
}
_notify(routerView) {
this.resolve(routerView);
}
};

@@ -0,1 +1,2 @@

import { PLATFORM } from 'aurelia-pal';
import { Router, AppRouter, RouteLoader } from 'aurelia-router';

@@ -7,3 +8,3 @@ import { TemplatingRouteLoader } from './route-loader';

function configure(config) {
config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources('./router-view', './route-href');
config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources(PLATFORM.moduleName('./router-view'), PLATFORM.moduleName('./route-href'));

@@ -10,0 +11,0 @@ config.container.registerAlias(Router, AppRouter);

@@ -10,6 +10,7 @@ var _dec, _class;

import { inject } from 'aurelia-dependency-injection';
import { CompositionEngine } from 'aurelia-templating';
import { CompositionEngine, useView, customElement } from 'aurelia-templating';
import { RouteLoader, Router } from 'aurelia-router';
import { relativeToFile } from 'aurelia-path';
import { Origin } from 'aurelia-metadata';
import { RouterViewLocator } from './router-view';

@@ -30,4 +31,7 @@ export var TemplatingRouteLoader = (_dec = inject(CompositionEngine), _dec(_class = function (_RouteLoader) {

var childContainer = router.container.createChild();
var viewModel = /\.html/.test(config.moduleId) ? createDynamicClass(config.moduleId) : relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
var instruction = {
viewModel: relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -38,2 +42,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function () {

@@ -53,2 +59,23 @@ var childRouter = void 0;

return TemplatingRouteLoader;
}(RouteLoader)) || _class);
}(RouteLoader)) || _class);
function createDynamicClass(moduleId) {
var _dec2, _dec3, _class2;
var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
var DynamicClass = (_dec2 = customElement(name), _dec3 = useView(moduleId), _dec2(_class2 = _dec3(_class2 = function () {
function DynamicClass() {
}
DynamicClass.prototype.bind = function bind(bindingContext) {
this.$parent = bindingContext;
};
return DynamicClass;
}()) || _class2) || _class2);
return DynamicClass;
}

@@ -13,2 +13,4 @@ var _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {

@@ -47,7 +49,5 @@ var desc = {};

import { Container, inject } from 'aurelia-dependency-injection';
import { createOverrideContext } from 'aurelia-binding';
import { ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM } from 'aurelia-templating';
import { ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, SwapStrategies } from 'aurelia-templating';
import { Router } from 'aurelia-router';

@@ -57,38 +57,2 @@ import { Origin } from 'aurelia-metadata';

var SwapStrategies = function () {
function SwapStrategies() {
}
SwapStrategies.prototype.before = function before(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(function () {
return viewSlot.remove(previousView, true);
});
}
return promise;
};
SwapStrategies.prototype.with = function _with(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
};
SwapStrategies.prototype.after = function after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
};
return SwapStrategies;
}();
var swapStrategies = new SwapStrategies();
export var RouterView = (_dec = customElement('router-view'), _dec2 = inject(DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine), _dec(_class = noView(_class = _dec2(_class = (_class2 = function () {

@@ -141,2 +105,4 @@ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {

childContainer.get(RouterViewLocator)._notify(this);
var layoutInstruction = {

@@ -179,16 +145,12 @@ viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,

var layoutInstruction = viewPortInstruction.layoutInstruction;
var previousView = this.view;
var work = function work() {
var previousView = _this2.view;
var swapStrategy = void 0;
var swapStrategy = SwapStrategies[_this2.swapOrder] || SwapStrategies.after;
var viewSlot = _this2.viewSlot;
swapStrategy = _this2.swapOrder in swapStrategies ? swapStrategies[_this2.swapOrder] : swapStrategies.after;
swapStrategy(viewSlot, previousView, function () {
return Promise.resolve().then(function () {
return viewSlot.add(_this2.view);
}).then(function () {
_this2._notify();
});
return Promise.resolve(viewSlot.add(_this2.view));
}).then(function () {
_this2._notify();
});

@@ -250,2 +212,24 @@ };

initializer: null
})), _class2)) || _class) || _class) || _class);
})), _class2)) || _class) || _class) || _class);
export var RouterViewLocator = function () {
function RouterViewLocator() {
var _this3 = this;
this.promise = new Promise(function (resolve) {
return _this3.resolve = resolve;
});
}
RouterViewLocator.prototype.findNearest = function findNearest() {
return this.promise;
};
RouterViewLocator.prototype._notify = function _notify(routerView) {
this.resolve(routerView);
};
return RouterViewLocator;
}();
'use strict';
System.register(['aurelia-router', './route-loader', './router-view', './route-href'], function (_export, _context) {
System.register(['aurelia-pal', 'aurelia-router', './route-loader', './router-view', './route-href'], function (_export, _context) {
"use strict";
var Router, AppRouter, RouteLoader, TemplatingRouteLoader, RouterView, RouteHref;
var PLATFORM, Router, AppRouter, RouteLoader, TemplatingRouteLoader, RouterView, RouteHref;
function configure(config) {
config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources('./router-view', './route-href');
config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources(PLATFORM.moduleName('./router-view'), PLATFORM.moduleName('./route-href'));

@@ -16,3 +16,5 @@ config.container.registerAlias(Router, AppRouter);

return {
setters: [function (_aureliaRouter) {
setters: [function (_aureliaPal) {
PLATFORM = _aureliaPal.PLATFORM;
}, function (_aureliaRouter) {
Router = _aureliaRouter.Router;

@@ -19,0 +21,0 @@ AppRouter = _aureliaRouter.AppRouter;

@@ -11,3 +11,3 @@ 'use strict';

for (var _key in _aureliaTemplatingRouter) {
if (_key !== "default" && key !== "__esModule") _exportObj[_key] = _aureliaTemplatingRouter[_key];
if (_key !== "default" && _key !== "__esModule") _exportObj[_key] = _aureliaTemplatingRouter[_key];
}

@@ -14,0 +14,0 @@

'use strict';
System.register(['aurelia-dependency-injection', 'aurelia-templating', 'aurelia-router', 'aurelia-path', 'aurelia-metadata'], function (_export, _context) {
System.register(['aurelia-dependency-injection', 'aurelia-templating', 'aurelia-router', 'aurelia-path', 'aurelia-metadata', './router-view'], function (_export, _context) {
"use strict";
var inject, CompositionEngine, RouteLoader, Router, relativeToFile, Origin, _dec, _class, TemplatingRouteLoader;
var inject, CompositionEngine, useView, customElement, RouteLoader, Router, relativeToFile, Origin, RouterViewLocator, _dec, _class, TemplatingRouteLoader;

@@ -34,2 +34,22 @@

function createDynamicClass(moduleId) {
var _dec2, _dec3, _class2;
var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
var DynamicClass = (_dec2 = customElement(name), _dec3 = useView(moduleId), _dec2(_class2 = _dec3(_class2 = function () {
function DynamicClass() {
}
DynamicClass.prototype.bind = function bind(bindingContext) {
this.$parent = bindingContext;
};
return DynamicClass;
}()) || _class2) || _class2);
return DynamicClass;
}
return {

@@ -40,2 +60,4 @@ setters: [function (_aureliaDependencyInjection) {

CompositionEngine = _aureliaTemplating.CompositionEngine;
useView = _aureliaTemplating.useView;
customElement = _aureliaTemplating.customElement;
}, function (_aureliaRouter) {

@@ -48,2 +70,4 @@ RouteLoader = _aureliaRouter.RouteLoader;

Origin = _aureliaMetadata.Origin;
}, function (_routerView) {
RouterViewLocator = _routerView.RouterViewLocator;
}],

@@ -65,4 +89,7 @@ execute: function () {

var childContainer = router.container.createChild();
var viewModel = /\.html/.test(config.moduleId) ? createDynamicClass(config.moduleId) : relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
var instruction = {
viewModel: relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -73,2 +100,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function () {

@@ -75,0 +104,0 @@ var childRouter = void 0;

@@ -6,3 +6,3 @@ 'use strict';

var Container, inject, createOverrideContext, ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, Router, Origin, DOM, _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, SwapStrategies, swapStrategies, RouterView;
var Container, inject, createOverrideContext, ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, SwapStrategies, Router, Origin, DOM, _dec, _dec2, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, RouterView, RouterViewLocator;

@@ -19,2 +19,4 @@ function _initDefineProp(target, property, descriptor, context) {

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {

@@ -53,4 +55,2 @@ var desc = {};

return {

@@ -72,2 +72,3 @@ setters: [function (_aureliaDependencyInjection) {

ShadowDOM = _aureliaTemplating.ShadowDOM;
SwapStrategies = _aureliaTemplating.SwapStrategies;
}, function (_aureliaRouter) {

@@ -81,38 +82,2 @@ Router = _aureliaRouter.Router;

execute: function () {
SwapStrategies = function () {
function SwapStrategies() {
}
SwapStrategies.prototype.before = function before(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(function () {
return viewSlot.remove(previousView, true);
});
}
return promise;
};
SwapStrategies.prototype.with = function _with(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
};
SwapStrategies.prototype.after = function after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
};
return SwapStrategies;
}();
swapStrategies = new SwapStrategies();
_export('RouterView', RouterView = (_dec = customElement('router-view'), _dec2 = inject(DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine), _dec(_class = noView(_class = _dec2(_class = (_class2 = function () {

@@ -165,2 +130,4 @@ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {

childContainer.get(RouterViewLocator)._notify(this);
var layoutInstruction = {

@@ -203,16 +170,12 @@ viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,

var layoutInstruction = viewPortInstruction.layoutInstruction;
var previousView = this.view;
var work = function work() {
var previousView = _this2.view;
var swapStrategy = void 0;
var swapStrategy = SwapStrategies[_this2.swapOrder] || SwapStrategies.after;
var viewSlot = _this2.viewSlot;
swapStrategy = _this2.swapOrder in swapStrategies ? swapStrategies[_this2.swapOrder] : swapStrategies.after;
swapStrategy(viewSlot, previousView, function () {
return Promise.resolve().then(function () {
return viewSlot.add(_this2.view);
}).then(function () {
_this2._notify();
});
return Promise.resolve(viewSlot.add(_this2.view));
}).then(function () {
_this2._notify();
});

@@ -277,4 +240,28 @@ };

_export('RouterView', RouterView);
_export('RouterViewLocator', RouterViewLocator = function () {
function RouterViewLocator() {
var _this3 = this;
this.promise = new Promise(function (resolve) {
return _this3.resolve = resolve;
});
}
RouterViewLocator.prototype.findNearest = function findNearest() {
return this.promise;
};
RouterViewLocator.prototype._notify = function _notify(routerView) {
this.resolve(routerView);
};
return RouterViewLocator;
}());
_export('RouterViewLocator', RouterViewLocator);
}
};
});

@@ -6,3 +6,3 @@ 'use strict';

});
exports.TemplatingRouteLoader = exports.RouterView = exports.RouteHref = undefined;
exports.TemplatingRouteLoader = exports.RouterViewLocator = exports.RouterView = exports.RouteHref = undefined;

@@ -131,39 +131,2 @@ var _dec, _dec2, _dec3, _dec4, _dec5, _class, _dec6, _dec7, _class2, _desc, _value, _class3, _descriptor, _descriptor2, _descriptor3, _descriptor4, _dec8, _class5;

}()) || _class) || _class) || _class) || _class) || _class);
var SwapStrategies = function () {
function SwapStrategies() {
_classCallCheck(this, SwapStrategies);
}
SwapStrategies.prototype.before = function before(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(function () {
return viewSlot.remove(previousView, true);
});
}
return promise;
};
SwapStrategies.prototype.with = function _with(viewSlot, previousView, callback) {
var promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
};
SwapStrategies.prototype.after = function after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
};
return SwapStrategies;
}();
var swapStrategies = new SwapStrategies();
var RouterView = exports.RouterView = (_dec6 = (0, _aureliaTemplating.customElement)('router-view'), _dec7 = (0, _aureliaDependencyInjection.inject)(_aureliaPal.DOM.Element, _aureliaDependencyInjection.Container, _aureliaTemplating.ViewSlot, _aureliaRouter.Router, _aureliaTemplating.ViewLocator, _aureliaTemplating.CompositionTransaction, _aureliaTemplating.CompositionEngine), _dec6(_class2 = (0, _aureliaTemplating.noView)(_class2 = _dec7(_class2 = (_class3 = function () {

@@ -216,2 +179,4 @@ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {

childContainer.get(RouterViewLocator)._notify(this);
var layoutInstruction = {

@@ -254,16 +219,12 @@ viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,

var layoutInstruction = viewPortInstruction.layoutInstruction;
var previousView = this.view;
var work = function work() {
var previousView = _this3.view;
var swapStrategy = void 0;
var swapStrategy = _aureliaTemplating.SwapStrategies[_this3.swapOrder] || _aureliaTemplating.SwapStrategies.after;
var viewSlot = _this3.viewSlot;
swapStrategy = _this3.swapOrder in swapStrategies ? swapStrategies[_this3.swapOrder] : swapStrategies.after;
swapStrategy(viewSlot, previousView, function () {
return Promise.resolve().then(function () {
return viewSlot.add(_this3.view);
}).then(function () {
_this3._notify();
});
return Promise.resolve(viewSlot.add(_this3.view));
}).then(function () {
_this3._notify();
});

@@ -326,2 +287,25 @@ };

})), _class3)) || _class2) || _class2) || _class2);
var RouterViewLocator = exports.RouterViewLocator = function () {
function RouterViewLocator() {
var _this4 = this;
_classCallCheck(this, RouterViewLocator);
this.promise = new Promise(function (resolve) {
return _this4.resolve = resolve;
});
}
RouterViewLocator.prototype.findNearest = function findNearest() {
return this.promise;
};
RouterViewLocator.prototype._notify = function _notify(routerView) {
this.resolve(routerView);
};
return RouterViewLocator;
}();
var TemplatingRouteLoader = exports.TemplatingRouteLoader = (_dec8 = (0, _aureliaDependencyInjection.inject)(_aureliaTemplating.CompositionEngine), _dec8(_class5 = function (_RouteLoader) {

@@ -333,6 +317,6 @@ _inherits(TemplatingRouteLoader, _RouteLoader);

var _this4 = _possibleConstructorReturn(this, _RouteLoader.call(this));
var _this5 = _possibleConstructorReturn(this, _RouteLoader.call(this));
_this4.compositionEngine = compositionEngine;
return _this4;
_this5.compositionEngine = compositionEngine;
return _this5;
}

@@ -342,4 +326,7 @@

var childContainer = router.container.createChild();
var viewModel = /\.html/.test(config.moduleId) ? createDynamicClass(config.moduleId) : (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
var instruction = {
viewModel: (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -350,2 +337,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function () {

@@ -365,2 +354,24 @@ var childRouter = void 0;

return TemplatingRouteLoader;
}(_aureliaRouter.RouteLoader)) || _class5);
}(_aureliaRouter.RouteLoader)) || _class5);
function createDynamicClass(moduleId) {
var _dec9, _dec10, _class6;
var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
var DynamicClass = (_dec9 = (0, _aureliaTemplating.customElement)(name), _dec10 = (0, _aureliaTemplating.useView)(moduleId), _dec9(_class6 = _dec10(_class6 = function () {
function DynamicClass() {
_classCallCheck(this, DynamicClass);
}
DynamicClass.prototype.bind = function bind(bindingContext) {
this.$parent = bindingContext;
};
return DynamicClass;
}()) || _class6) || _class6);
return DynamicClass;
}

@@ -1,1 +0,1 @@

{"name":"aurelia-templating-router","children":[{"id":2,"name":"RouteHref","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":3,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":4,"name":"new RouteHref","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":5,"name":"router","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":6,"name":"element","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"RouteHref","id":2}}]},{"id":11,"name":"attributeChanged","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":12,"name":"attributeChanged","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":13,"name":"value","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":14,"name":"previous","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":7,"name":"bind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":8,"name":"bind","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}]},{"id":15,"name":"processChange","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":16,"name":"processChange","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}]},{"id":9,"name":"unbind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":10,"name":"unbind","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[3]},{"title":"Methods","kind":2048,"children":[11,7,15,9]}]},{"id":17,"name":"RouterView","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":22,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":23,"name":"new RouterView","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":24,"name":"element","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":25,"name":"container","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":26,"name":"viewSlot","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":27,"name":"router","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":28,"name":"viewLocator","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":29,"name":"compositionTransaction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":30,"name":"compositionEngine","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"RouterView","id":17}}]},{"id":21,"name":"layoutModel","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":19,"name":"layoutView","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":20,"name":"layoutViewModel","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":18,"name":"swapOrder","kind":1024,"kindString":"Property","flags":{"isExported":true},"type":{"type":"instrinct","name":"any"}},{"id":34,"name":"bind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":35,"name":"bind","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":36,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":37,"name":"overrideContext","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":31,"name":"created","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":32,"name":"created","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":33,"name":"owningView","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":38,"name":"process","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":39,"name":"process","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":40,"name":"viewPortInstruction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":41,"name":"waitToSwap","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]},{"id":42,"name":"swap","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":43,"name":"swap","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":44,"name":"viewPortInstruction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[22]},{"title":"Properties","kind":1024,"children":[21,19,20,18]},{"title":"Methods","kind":2048,"children":[34,31,38,42]}]},{"id":45,"name":"TemplatingRouteLoader","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":46,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":47,"name":"new TemplatingRouteLoader","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":48,"name":"compositionEngine","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"TemplatingRouteLoader","id":45}}]},{"id":49,"name":"loadRoute","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":50,"name":"loadRoute","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":51,"name":"router","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":52,"name":"config","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"},"overwrites":{"type":"reference","name":"RouteLoader.loadRoute"}}],"overwrites":{"type":"reference","name":"RouteLoader.loadRoute"}}],"groups":[{"title":"Constructors","kind":512,"children":[46]},{"title":"Methods","kind":2048,"children":[49]}],"extendedTypes":[{"type":"reference","name":"RouteLoader"}]}],"groups":[{"title":"Classes","kind":128,"children":[2,17,45]}]}
{"name":"aurelia-templating-router","children":[{"id":2,"name":"RouteHref","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":3,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":4,"name":"new RouteHref","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":5,"name":"router","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":6,"name":"element","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"RouteHref","id":2}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":36,"character":32}]},{"id":11,"name":"attributeChanged","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":12,"name":"attributeChanged","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":13,"name":"value","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":14,"name":"previous","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":40,"character":18}]},{"id":7,"name":"bind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":8,"name":"bind","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":38,"character":6}]},{"id":15,"name":"processChange","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":16,"name":"processChange","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":41,"character":15}]},{"id":9,"name":"unbind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":10,"name":"unbind","kind":4096,"kindString":"Call signature","flags":{},"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":39,"character":8}]}],"groups":[{"title":"Constructors","kind":512,"children":[3]},{"title":"Methods","kind":2048,"children":[11,7,15,9]}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":36,"character":30}]},{"id":17,"name":"RouterView","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":23,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":24,"name":"new RouterView","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":25,"name":"element","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":26,"name":"container","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":27,"name":"viewSlot","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":28,"name":"router","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":29,"name":"viewLocator","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":30,"name":"compositionTransaction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":31,"name":"compositionEngine","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"RouterView","id":17}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":48,"character":15}]},{"id":22,"name":"element","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-templating-router.d.ts","line":48,"character":9}],"type":{"type":"instrinct","name":"any"}},{"id":21,"name":"layoutModel","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-templating-router.d.ts","line":47,"character":13}],"type":{"type":"instrinct","name":"any"}},{"id":19,"name":"layoutView","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-templating-router.d.ts","line":45,"character":12}],"type":{"type":"instrinct","name":"any"}},{"id":20,"name":"layoutViewModel","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-templating-router.d.ts","line":46,"character":17}],"type":{"type":"instrinct","name":"any"}},{"id":18,"name":"swapOrder","kind":1024,"kindString":"Property","flags":{"isExported":true},"sources":[{"fileName":"aurelia-templating-router.d.ts","line":44,"character":11}],"type":{"type":"instrinct","name":"any"}},{"id":35,"name":"bind","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":36,"name":"bind","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":37,"name":"bindingContext","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":38,"name":"overrideContext","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":51,"character":6}]},{"id":32,"name":"created","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":33,"name":"created","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":34,"name":"owningView","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":50,"character":9}]},{"id":39,"name":"process","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":40,"name":"process","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":41,"name":"viewPortInstruction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":42,"name":"waitToSwap","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":52,"character":9}]},{"id":43,"name":"swap","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":44,"name":"swap","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":45,"name":"viewPortInstruction","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":53,"character":6}]}],"groups":[{"title":"Constructors","kind":512,"children":[23]},{"title":"Properties","kind":1024,"children":[22,21,19,20,18]},{"title":"Methods","kind":2048,"children":[35,32,39,43]}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":43,"character":31}]},{"id":46,"name":"RouterViewLocator","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"Locator which finds the nearest RouterView, relative to the current dependency injection container."},"children":[{"id":47,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"Creates an instance of the RouterViewLocator class."},"signatures":[{"id":48,"name":"new RouterViewLocator","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"Creates an instance of the RouterViewLocator class."},"type":{"type":"reference","name":"RouterViewLocator","id":46}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":59,"character":40}]},{"id":49,"name":"findNearest","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":50,"name":"findNearest","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Finds the nearest RouterView instance.","returns":"A promise that will be resolved with the located RouterView instance.\n"},"type":{"type":"reference","name":"Promise","typeArguments":[{"type":"reference","name":"RouterView","id":17}]}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":70,"character":13}]}],"groups":[{"title":"Constructors","kind":512,"children":[47]},{"title":"Methods","kind":2048,"children":[49]}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":59,"character":38}]},{"id":51,"name":"TemplatingRouteLoader","kind":128,"kindString":"Class","flags":{"isExported":true},"children":[{"id":52,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"signatures":[{"id":53,"name":"new TemplatingRouteLoader","kind":16384,"kindString":"Constructor signature","flags":{},"parameters":[{"id":54,"name":"compositionEngine","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"reference","name":"TemplatingRouteLoader","id":51}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":72,"character":64}]},{"id":55,"name":"loadRoute","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":56,"name":"loadRoute","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":57,"name":"router","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}},{"id":58,"name":"config","kind":32768,"kindString":"Parameter","flags":{"isOptional":true},"type":{"type":"instrinct","name":"any"}}],"type":{"type":"instrinct","name":"any"},"overwrites":{"type":"reference","name":"RouteLoader.loadRoute"}}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":74,"character":11}],"overwrites":{"type":"reference","name":"RouteLoader.loadRoute"}}],"groups":[{"title":"Constructors","kind":512,"children":[52]},{"title":"Methods","kind":2048,"children":[55]}],"sources":[{"fileName":"aurelia-templating-router.d.ts","line":72,"character":42}],"extendedTypes":[{"type":"reference","name":"RouteLoader"}]}],"groups":[{"title":"Classes","kind":128,"children":[2,17,46,51]}]}

@@ -0,1 +1,11 @@

<a name="1.1.0"></a>
# [1.1.0](https://github.com/aurelia/templating-router/compare/1.0.1...v1.1.0) (2017-02-26)
### Features
* **route:** load html only component ([112dd29](https://github.com/aurelia/templating-router/commit/112dd29))
* Update to use shared SwapStrategies from templating.
<a name="1.0.1"></a>

@@ -2,0 +12,0 @@ ## [1.0.1](https://github.com/aurelia/templating-router/compare/1.0.0...v1.0.1) (2016-12-03)

{
"name": "aurelia-templating-router",
"version": "1.0.1",
"version": "1.1.0",
"description": "An implementation of the RouteLoader interface for use with the router module. Also contains a custom element that allows the templating engine to display the current route.",

@@ -34,6 +34,6 @@ "keywords": [

"aurelia-metadata": "^1.0.0",
"aurelia-pal": "^1.0.0",
"aurelia-pal": "^1.3.0",
"aurelia-path": "^1.0.0",
"aurelia-router": "^1.0.1",
"aurelia-templating": "^1.0.0",
"aurelia-templating": "^1.3.0",
"aurelia-binding": "^1.0.9"

@@ -45,6 +45,6 @@ },

"aurelia-metadata": "^1.0.0",
"aurelia-pal": "^1.0.0",
"aurelia-pal": "^1.3.0",
"aurelia-path": "^1.0.0",
"aurelia-router": "^1.0.1",
"aurelia-templating": "^1.0.0",
"aurelia-templating": "^1.3.0",
"aurelia-binding": "^1.0.9"

@@ -66,6 +66,6 @@ },

"aurelia-metadata": "^1.0.0",
"aurelia-pal": "^1.0.0",
"aurelia-pal": "^1.3.0",
"aurelia-path": "^1.0.0",
"aurelia-router": "^1.0.1",
"aurelia-templating": "^1.0.0",
"aurelia-templating": "^1.3.0",
"aurelia-binding": "^1.0.9"

@@ -72,0 +72,0 @@ },

@@ -0,1 +1,2 @@

import {PLATFORM} from 'aurelia-pal';
import {Router, AppRouter, RouteLoader} from 'aurelia-router';

@@ -10,3 +11,6 @@ import {TemplatingRouteLoader} from './route-loader';

.singleton(Router, AppRouter)
.globalResources('./router-view', './route-href');
.globalResources(
PLATFORM.moduleName('./router-view'),
PLATFORM.moduleName('./route-href')
);

@@ -13,0 +17,0 @@ config.container.registerAlias(Router, AppRouter);

import {inject} from 'aurelia-dependency-injection';
import {CompositionEngine} from 'aurelia-templating';
import {CompositionEngine, useView, customElement} from 'aurelia-templating';
import {RouteLoader, Router} from 'aurelia-router';
import {relativeToFile} from 'aurelia-path';
import {Origin} from 'aurelia-metadata';
import {RouterViewLocator} from './router-view';

@@ -16,4 +17,9 @@ @inject(CompositionEngine)

let childContainer = router.container.createChild();
let viewModel = /\.html/.test(config.moduleId)
? createDynamicClass(config.moduleId)
: relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
let instruction = {
viewModel: relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId),
viewModel: viewModel,
childContainer: childContainer,

@@ -24,2 +30,4 @@ view: config.view || config.viewStrategy,

childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function() {

@@ -38,1 +46,15 @@ let childRouter;

}
function createDynamicClass(moduleId) {
let name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
@customElement(name)
@useView(moduleId)
class DynamicClass {
bind(bindingContext) {
this.$parent = bindingContext;
}
}
return DynamicClass;
}
import {Container, inject} from 'aurelia-dependency-injection';
import {createOverrideContext} from 'aurelia-binding';
import {ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM} from 'aurelia-templating';
import {ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, SwapStrategies} from 'aurelia-templating';
import {Router} from 'aurelia-router';

@@ -8,33 +8,2 @@ import {Origin} from 'aurelia-metadata';

class SwapStrategies {
// animate the next view in before removing the current view;
before(viewSlot, previousView, callback) {
let promise = Promise.resolve(callback());
if (previousView !== undefined) {
return promise.then(() => viewSlot.remove(previousView, true));
}
return promise;
}
// animate the next view at the same time the current view is removed
with(viewSlot, previousView, callback) {
let promise = Promise.resolve(callback());
if (previousView !== undefined) {
return Promise.all([viewSlot.remove(previousView, true), promise]);
}
return promise;
}
// animate the next view in after the current view has been removed
after(viewSlot, previousView, callback) {
return Promise.resolve(viewSlot.removeAll(true)).then(callback);
}
}
const swapStrategies = new SwapStrategies();
@customElement('router-view')

@@ -48,2 +17,3 @@ @noView

@bindable layoutModel;
element;

@@ -84,2 +54,4 @@ constructor(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {

childContainer.get(RouterViewLocator)._notify(this);
// layoutInstruction is our layout viewModel

@@ -128,18 +100,12 @@ let layoutInstruction = {

let layoutInstruction = viewPortInstruction.layoutInstruction;
let previousView = this.view;
let work = () => {
let previousView = this.view;
let swapStrategy;
let swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;
let viewSlot = this.viewSlot;
swapStrategy = this.swapOrder in swapStrategies
? swapStrategies[this.swapOrder]
: swapStrategies.after;
swapStrategy(viewSlot, previousView, () => {
return Promise.resolve().then(() => {
return viewSlot.add(this.view);
}).then(() => {
this._notify();
});
return Promise.resolve(viewSlot.add(this.view));
}).then(() => {
this._notify();
});

@@ -190,1 +156,25 @@ };

}
/**
* Locator which finds the nearest RouterView, relative to the current dependency injection container.
*/
export class RouterViewLocator {
/**
* Creates an instance of the RouterViewLocator class.
*/
constructor() {
this.promise = new Promise((resolve) => this.resolve = resolve);
}
/**
* Finds the nearest RouterView instance.
* @returns A promise that will be resolved with the located RouterView instance.
*/
findNearest(): Promise<RouterView> {
return this.promise;
}
_notify(routerView: RouterView): void {
this.resolve(routerView);
}
}

@@ -0,9 +1,21 @@

import {inject} from 'aurelia-dependency-injection';
import {testConstants} from '../test/test-constants';
import {RouterViewLocator, RouterView} from 'src/router-view';
@inject(RouterViewLocator)
export class LayoutDefaultSlot {
constants = testConstants;
constructor(routerViewLocator) {
routerViewLocator.findNearest().then(routerView => {
if (!this.activated && routerView instanceof RouterView) {
this.routerViewLocated = true;
}
});
}
activate(value) {
this.activated = true;
this.value = value;
}
}

@@ -23,7 +23,8 @@ import {StageComponent} from 'aurelia-testing';

component = withDefaultViewport({ moduleId: 'test/module-default-slot' });
component.create(bootstrap)
.then(() => {
expect(component.viewModel.router).not.toBe(undefined);
})
.then(done);
.then(() => {
expect(component.viewModel.router).not.toBe(undefined);
})
.then(done);
});

@@ -33,10 +34,11 @@

component = withDefaultViewport({ moduleId: 'test/module-default-slot' });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
})
.then(done);
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
})
.then(done);
});

@@ -46,25 +48,40 @@

component = withDefaultViewport({ moduleId: 'test/module-default-slot', layoutView: 'test/layout-default-slot.html' });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.defaultLayout);
})
.then(done);
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.defaultLayout);
})
.then(done);
});
it('loads a view-only module', done =>{
component = withDefaultViewport({ moduleId: 'test/module-view-only.html' });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain('view-only content');
})
.then(done);
});
it('loads a module based layout', done => {
component = withDefaultViewport({ moduleId: 'test/module-default-slot', layoutViewModel: 'test/layout-default-slot' });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.defaultLayout);
expect(component.viewModel.viewSlot.children[0].controller.viewModel).not.toBe(undefined);
})
.then(done);
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.defaultLayout);
expect(component.viewModel.viewSlot.children[0].controller.viewModel).not.toBe(undefined);
})
.then(done);
});

@@ -74,12 +91,13 @@

component = withDefaultViewport({ moduleId: 'test/module-default-slot', layoutView: 'test/layout-default-slot-alt.html', layoutViewModel: 'test/layout-default-slot' });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.altLayout);
expect(component.viewModel.viewSlot.children[0].controller.viewModel).not.toBe(undefined);
})
.then(done);
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.altLayout);
expect(component.viewModel.viewSlot.children[0].controller.viewModel).not.toBe(undefined);
})
.then(done);
});

@@ -89,11 +107,12 @@

component = withDefaultViewport({ moduleId: 'test/module-named-slots', layoutView: 'test/layout-named-slots.html' });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content + '\n' + testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.namedSlotsLayout);
})
.then(done);
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content + '\n' + testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.namedSlotsLayout);
})
.then(done);
});

@@ -107,11 +126,12 @@

});
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.defaultLayout);
})
.then(done);
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.element.innerText).toContain(testConstants.content);
expect(component.viewModel.element.innerText).toContain(testConstants.defaultLayout);
})
.then(done);
});

@@ -121,19 +141,29 @@

component = withDefaultViewport({ moduleId: 'test/module-default-slot', layoutViewModel: 'test/layout-default-slot', layoutModel: 1 });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.viewSlot.children[0].controller.viewModel.value).toBe(1);
})
.then(done);
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.viewSlot.children[0].controller.viewModel.value).toBe(1);
})
.then(done);
});
it('locates the view port before activating', done => {
component = withDefaultViewport({ moduleId: 'test/module-default-slot', layoutViewModel: 'test/layout-default-slot' });
component.create(bootstrap)
.then(() => {
return component.viewModel.router.navigate('route').then(wait);
})
.then(() => {
expect(component.viewModel.viewSlot.children[0].controller.viewModel.routerViewLocated).toBe(true);
})
.then(done);
});
});
function wait() {
return new Promise((res) => {
setTimeout(() => {
res();
}, 250);
});
return new Promise(res => setTimeout(() => res(), 250));
}

@@ -145,3 +175,9 @@

.inView('<router-view></router-view>');
configure(component, { route: ['', 'default'], moduleId: 'test/module-default-slot', activationStrategy: 'replace'}, routeConfig);
configure(component, {
route: ['', 'default'],
moduleId: 'test/module-default-slot',
activationStrategy: 'replace'
}, routeConfig);
return component;

@@ -154,11 +190,11 @@ }

.inView('<router-view name="viewport1"></router-view>');
configure(component,
{
route: ['', 'default'],
viewPorts: {
viewport1: { moduleId: 'test/module-default-slot' }
},
activationStrategy: 'replace'
configure(component, {
route: ['', 'default'],
viewPorts: {
viewport1: { moduleId: 'test/module-default-slot' }
},
routeConfig);
activationStrategy: 'replace'
}, routeConfig);
return component;

@@ -169,10 +205,11 @@ }

component.bootstrap(aurelia => {
aurelia.use.defaultBindingLanguage()
.defaultResources()
.history();
// .developmentLogging();
aurelia.use
.defaultBindingLanguage()
.defaultResources()
.history();
aurelia.use.singleton(RouteLoader, TemplatingRouteLoader)
.singleton(Router, AppRouter)
.globalResources('src/router-view', 'src/route-href');
aurelia.use
.singleton(RouteLoader, TemplatingRouteLoader)
.singleton(Router, AppRouter)
.globalResources('src/router-view', 'src/route-href');

@@ -179,0 +216,0 @@ if (routeConfig) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc