diff --git a/README.md b/README.md
index fa816a0..5a8a499 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains an implementation of the RouteLoader interface for use with the router module. It also contains a custom element that allows the templating engine to display the current route.
-> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions look around our [Discourse forums](https://discourse.aurelia.io/), chat in our [community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/docs). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards.
+> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions look around our [Discourse forums](https://discourse.aurelia.io/), chat in our [community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/docs).
## Platform Support
diff --git a/bower.json b/bower.json
index 372cc5a..5fe4e43 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "aurelia-templating-router",
- "version": "1.5.0",
+ "version": "1.4.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.",
"keywords": [
"aurelia",
diff --git a/dist/amd/aurelia-templating-router.js b/dist/amd/aurelia-templating-router.js
index bfcafbf..bb02d8d 100644
--- a/dist/amd/aurelia-templating-router.js
+++ b/dist/amd/aurelia-templating-router.js
@@ -1,20 +1,433 @@
-define(['exports', 'aurelia-router', './route-loader', './router-view', './route-href'], function (exports, _aureliaRouter, _routeLoader, _routerView, _routeHref) {
- 'use strict';
+define('aurelia-templating-router', ['exports', 'aurelia-router', 'aurelia-metadata', 'aurelia-path', 'aurelia-templating', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-pal', 'aurelia-logging'], function (exports, aureliaRouter, aureliaMetadata, aureliaPath, aureliaTemplating, aureliaDependencyInjection, aureliaBinding, aureliaPal, LogManager) { 'use strict';
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.configure = exports.RouteHref = exports.RouterView = exports.TemplatingRouteLoader = undefined;
+ /*! *****************************************************************************
+ Copyright (c) Microsoft Corporation. All rights reserved.
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of the
+ License at http://www.apache.org/licenses/LICENSE-2.0
+
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+ MERCHANTABLITY OR NON-INFRINGEMENT.
+
+ See the Apache Version 2.0 License for specific language governing permissions
+ and limitations under the License.
+ ***************************************************************************** */
+ /* global Reflect, Promise */
+
+ var extendStatics = function(d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+ };
+
+ function __extends(d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+ }
+ var EmptyLayoutViewModel = /** @class */ (function () {
+ function EmptyLayoutViewModel() {
+ }
+ return EmptyLayoutViewModel;
+ }());
+ /**
+ * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views
+ */
+ var RouterView = /** @class */ (function () {
+ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
+ this.element = element;
+ this.container = container;
+ this.viewSlot = viewSlot;
+ this.router = router;
+ this.viewLocator = viewLocator;
+ this.compositionTransaction = compositionTransaction;
+ this.compositionEngine = compositionEngine;
+ // add this to router view ports lookup based on name attribute
+ // when this router is the root router-view
+ // also trigger AppRouter registerViewPort extra flow
+ this.router.registerViewPort(this, this.element.getAttribute('name'));
+ // Each process its instruction as a composition transaction
+ // there are differences between intial composition and subsequent compositions
+ // also there are differences between root composition and child composition
+ // mark the first composition transaction with a property initialComposition to distinguish it
+ // when the root gets new instruction for the first time
+ if (!('initialComposition' in compositionTransaction)) {
+ compositionTransaction.initialComposition = true;
+ this.compositionTransactionNotifier = compositionTransaction.enlist();
+ }
+ }
+ /**@internal */
+ RouterView.inject = function () {
+ return [aureliaPal.DOM.Element, aureliaDependencyInjection.Container, aureliaTemplating.ViewSlot, aureliaRouter.Router, aureliaTemplating.ViewLocator, aureliaTemplating.CompositionTransaction, aureliaTemplating.CompositionEngine];
+ };
+ RouterView.prototype.created = function (owningView) {
+ this.owningView = owningView;
+ };
+ RouterView.prototype.bind = function (bindingContext, overrideContext) {
+ // router needs to get access to view model of current route parent
+ // doing it in generic way via viewModel property on container
+ this.container.viewModel = bindingContext;
+ this.overrideContext = overrideContext;
+ };
+ /**
+ * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline
+ */
+ RouterView.prototype.process = function ($viewPortInstruction, waitToSwap) {
+ var _this = this;
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ var viewPortInstruction = $viewPortInstruction;
+ var component = viewPortInstruction.component;
+ var childContainer = component.childContainer;
+ var viewModel = component.viewModel;
+ var viewModelResource = component.viewModelResource;
+ var metadata = viewModelResource.metadata;
+ var config = component.router.currentInstruction.config;
+ var viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};
+ childContainer.get(RouterViewLocator)._notify(this);
+ // layoutInstruction is our layout viewModel
+ var layoutInstruction = {
+ viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
+ view: viewPortConfig.layoutView || config.layoutView || this.layoutView,
+ model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,
+ router: viewPortInstruction.component.router,
+ childContainer: childContainer,
+ viewSlot: this.viewSlot
+ };
+ // viewport will be a thin wrapper around composition engine
+ // to process instruction/configuration from users
+ // preparing all information related to a composition process
+ // first by getting view strategy of a ViewPortComponent View
+ var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
+ if (viewStrategy && component.view) {
+ viewStrategy.makeRelativeTo(aureliaMetadata.Origin.get(component.router.container.viewModel.constructor).moduleId);
+ }
+ // using metadata of a custom element view model to load appropriate view-factory instance
+ return metadata
+ .load(childContainer, viewModelResource.value, null, viewStrategy, true)
+ // for custom element, viewFactory typing is always ViewFactory
+ // for custom attribute, it will be HtmlBehaviorResource
+ .then(function (viewFactory) {
+ // if this is not the first time that this is composing its instruction
+ // try to capture ownership of the composition transaction
+ // child will not be able to capture, since root typically captures
+ // the ownership token
+ if (!_this.compositionTransactionNotifier) {
+ _this.compositionTransactionOwnershipToken = _this.compositionTransaction.tryCapture();
+ }
+ if (layoutInstruction.viewModel || layoutInstruction.view) {
+ viewPortInstruction.layoutInstruction = layoutInstruction;
+ }
+ var viewPortComponentBehaviorInstruction = aureliaTemplating.BehaviorInstruction.dynamic(_this.element, viewModel, viewFactory);
+ viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);
+ if (waitToSwap) {
+ return null;
+ }
+ _this.swap(viewPortInstruction);
+ });
+ };
+ RouterView.prototype.swap = function ($viewPortInstruction) {
+ var _this = this;
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ var viewPortInstruction = $viewPortInstruction;
+ var viewPortController = viewPortInstruction.controller;
+ var layoutInstruction = viewPortInstruction.layoutInstruction;
+ var previousView = this.view;
+ // Final step of swapping a ViewPortComponent
+ var work = function () {
+ var swapStrategy = aureliaTemplating.SwapStrategies[_this.swapOrder] || aureliaTemplating.SwapStrategies.after;
+ var viewSlot = _this.viewSlot;
+ swapStrategy(viewSlot, previousView, function () { return Promise.resolve(viewSlot.add(_this.view)); }).then(function () {
+ _this._notify();
+ });
+ };
+ // Ensure all users setups have been completed
+ var ready = function (owningView_or_layoutView) {
+ viewPortController.automate(_this.overrideContext, owningView_or_layoutView);
+ var transactionOwnerShipToken = _this.compositionTransactionOwnershipToken;
+ // if this router-view is the root of a normal startup via aurelia.setRoot
+ // attemp to take control of the transaction
+ // if ownership can be taken
+ // wait for transaction to complete before swapping
+ if (transactionOwnerShipToken) {
+ return transactionOwnerShipToken
+ .waitForCompositionComplete()
+ .then(function () {
+ _this.compositionTransactionOwnershipToken = null;
+ return work();
+ });
+ }
+ // otherwise, just swap
+ return work();
+ };
+ // If there is layout instruction, new to compose layout before processing ViewPortComponent
+ // layout controller/view/view-model is composed using composition engine APIs
+ if (layoutInstruction) {
+ if (!layoutInstruction.viewModel) {
+ // createController chokes if there's no viewmodel, so create a dummy one
+ // but avoid using a POJO as it creates unwanted metadata in Object constructor
+ layoutInstruction.viewModel = new EmptyLayoutViewModel();
+ }
+ // using composition engine to create compose layout
+ return this.compositionEngine
+ // first create controller from layoutInstruction
+ // and treat it as CompositionContext
+ // then emulate slot projection with ViewPortComponent view
+ .createController(layoutInstruction)
+ .then(function (layoutController) {
+ var layoutView = layoutController.view;
+ aureliaTemplating.ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);
+ // when there is a layout
+ // view hierarchy is: owner view -> layout view -> ViewPortComponent view
+ layoutController.automate(aureliaBinding.createOverrideContext(layoutInstruction.viewModel), _this.owningView);
+ layoutView.children.push(viewPortController.view);
+ return layoutView || layoutController;
+ })
+ .then(function (newView) {
+ _this.view = newView;
+ return ready(newView);
+ });
+ }
+ // if there is no layout, then get ViewPortComponent view ready as view property
+ // and process controller/swapping
+ // when there is no layout
+ // view hierarchy is: owner view -> ViewPortComponent view
+ this.view = viewPortController.view;
+ return ready(this.owningView);
+ };
+ /**
+ * Notify composition transaction that this router has finished processing
+ * Happens when this is the root router-view
+ * @internal
+ */
+ RouterView.prototype._notify = function () {
+ var notifier = this.compositionTransactionNotifier;
+ if (notifier) {
+ notifier.done();
+ this.compositionTransactionNotifier = null;
+ }
+ };
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ *
+ * There is no view to compose by default in a router view
+ * This custom element is responsible for composing its own view, based on current config
+ */
+ RouterView.$view = null;
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+ RouterView.$resource = {
+ name: 'router-view',
+ bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context']
+ };
+ return RouterView;
+ }());
+ /**
+ * Locator which finds the nearest RouterView, relative to the current dependency injection container.
+ */
+ var RouterViewLocator = /** @class */ (function () {
+ /**
+ * Creates an instance of the RouterViewLocator class.
+ */
+ function RouterViewLocator() {
+ var _this = this;
+ this.promise = new Promise(function (resolve) { return _this.resolve = resolve; });
+ }
+ /**
+ * Finds the nearest RouterView instance.
+ * @returns A promise that will be resolved with the located RouterView instance.
+ */
+ RouterViewLocator.prototype.findNearest = function () {
+ return this.promise;
+ };
+ /**@internal */
+ RouterViewLocator.prototype._notify = function (routerView) {
+ this.resolve(routerView);
+ };
+ return RouterViewLocator;
+ }());
- function configure(config) {
- config.singleton(_aureliaRouter.RouteLoader, _routeLoader.TemplatingRouteLoader).singleton(_aureliaRouter.Router, _aureliaRouter.AppRouter).globalResources(_routerView.RouterView, _routeHref.RouteHref);
+ /**@internal exported for unit testing */
+ var EmptyClass = /** @class */ (function () {
+ function EmptyClass() {
+ }
+ return EmptyClass;
+ }());
+ aureliaTemplating.inlineView('')(EmptyClass);
+ /**
+ * Default implementation of `RouteLoader` used for loading component based on a route config
+ */
+ var TemplatingRouteLoader = /** @class */ (function (_super) {
+ __extends(TemplatingRouteLoader, _super);
+ function TemplatingRouteLoader(compositionEngine) {
+ var _this = _super.call(this) || this;
+ _this.compositionEngine = compositionEngine;
+ return _this;
+ }
+ /**
+ * Resolve a view model from a RouteConfig
+ * Throws when there is neither "moduleId" nor "viewModel" property
+ * @internal
+ */
+ TemplatingRouteLoader.prototype.resolveViewModel = function (router, config) {
+ return new Promise(function (resolve, reject) {
+ var viewModel;
+ if ('moduleId' in config) {
+ var moduleId = config.moduleId;
+ if (moduleId === null) {
+ viewModel = EmptyClass;
+ }
+ else {
+ // this requires container of router has passes a certain point
+ // where a view model has been setup on the container
+ // it will fail in enhance scenario because no viewport has been registered
+ moduleId = aureliaPath.relativeToFile(moduleId, aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
+ if (/\.html/i.test(moduleId)) {
+ viewModel = createDynamicClass(moduleId);
+ }
+ else {
+ viewModel = moduleId;
+ }
+ }
+ return resolve(viewModel);
+ }
+ // todo: add if ('viewModel' in config) to support static view model resolution
+ reject(new Error('Invalid route config. No "moduleId" found.'));
+ });
+ };
+ /**
+ * Create child container based on a router container
+ * Also ensures that child router are properly constructed in the newly created child container
+ * @internal
+ */
+ TemplatingRouteLoader.prototype.createChildContainer = function (router) {
+ var childContainer = router.container.createChild();
+ childContainer.registerSingleton(RouterViewLocator);
+ childContainer.getChildRouter = function () {
+ var childRouter;
+ childContainer.registerHandler(aureliaRouter.Router, function () { return childRouter || (childRouter = router.createChild(childContainer)); });
+ return childContainer.get(aureliaRouter.Router);
+ };
+ return childContainer;
+ };
+ /**
+ * Load corresponding component of a route config of a navigation instruction
+ */
+ TemplatingRouteLoader.prototype.loadRoute = function (router, config, _navInstruction) {
+ var _this = this;
+ return this
+ .resolveViewModel(router, config)
+ .then(function (viewModel) { return _this.compositionEngine.ensureViewModel({
+ viewModel: viewModel,
+ childContainer: _this.createChildContainer(router),
+ view: config.view || config.viewStrategy,
+ router: router
+ }); });
+ };
+ /**@internal */
+ TemplatingRouteLoader.inject = [aureliaTemplating.CompositionEngine];
+ return TemplatingRouteLoader;
+ }(aureliaRouter.RouteLoader));
+ /**@internal exported for unit testing */
+ function createDynamicClass(moduleId) {
+ var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
+ var DynamicClass = /** @class */ (function () {
+ function DynamicClass() {
+ }
+ DynamicClass.prototype.bind = function (bindingContext) {
+ this.$parent = bindingContext;
+ };
+ return DynamicClass;
+ }());
+ aureliaTemplating.customElement(name)(DynamicClass);
+ aureliaTemplating.useView(moduleId)(DynamicClass);
+ return DynamicClass;
+ }
- config.container.registerAlias(_aureliaRouter.Router, _aureliaRouter.AppRouter);
- }
+ var logger = LogManager.getLogger('route-href');
+ /**
+ * Helper custom attribute to help associate an element with a route by name
+ */
+ var RouteHref = /** @class */ (function () {
+ function RouteHref(router, element) {
+ this.router = router;
+ this.element = element;
+ this.attribute = 'href';
+ }
+ /*@internal */
+ RouteHref.inject = function () {
+ return [aureliaRouter.Router, aureliaPal.DOM.Element];
+ };
+ RouteHref.prototype.bind = function () {
+ this.isActive = true;
+ this.processChange();
+ };
+ RouteHref.prototype.unbind = function () {
+ this.isActive = false;
+ };
+ RouteHref.prototype.attributeChanged = function (value, previous) {
+ if (previous) {
+ this.element.removeAttribute(previous);
+ }
+ return this.processChange();
+ };
+ RouteHref.prototype.processChange = function () {
+ var _this = this;
+ return this.router
+ .ensureConfigured()
+ .then(function () {
+ if (!_this.isActive) {
+ // returning null to avoid Bluebird warning
+ return null;
+ }
+ var element = _this.element;
+ var href = _this.router.generate(_this.route, _this.params);
+ if (element.au.controller) {
+ element.au.controller.viewModel[_this.attribute] = href;
+ }
+ else {
+ element.setAttribute(_this.attribute, href);
+ }
+ // returning null to avoid Bluebird warning
+ return null;
+ })
+ .catch(function (reason) {
+ logger.error(reason);
+ });
+ };
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+ RouteHref.$resource = {
+ type: 'attribute',
+ name: 'route-href',
+ bindables: [
+ { name: 'route', changeHandler: 'processChange', primaryProperty: true },
+ { name: 'params', changeHandler: 'processChange' },
+ 'attribute'
+ ] // type definition of Aurelia templating is wrong
+ };
+ return RouteHref;
+ }());
- exports.TemplatingRouteLoader = _routeLoader.TemplatingRouteLoader;
- exports.RouterView = _routerView.RouterView;
- exports.RouteHref = _routeHref.RouteHref;
- exports.configure = configure;
-});
\ No newline at end of file
+ function configure(config) {
+ config
+ .singleton(aureliaRouter.RouteLoader, TemplatingRouteLoader)
+ .singleton(aureliaRouter.Router, aureliaRouter.AppRouter)
+ .globalResources(RouterView, RouteHref);
+ config.container.registerAlias(aureliaRouter.Router, aureliaRouter.AppRouter);
+ }
+
+ exports.RouteHref = RouteHref;
+ exports.RouterView = RouterView;
+ exports.TemplatingRouteLoader = TemplatingRouteLoader;
+ exports.configure = configure;
+
+ Object.defineProperty(exports, '__esModule', { value: true });
+
+});
+//# sourceMappingURL=aurelia-templating-router.js.map
diff --git a/dist/amd/aurelia-templating-router.js.map b/dist/amd/aurelia-templating-router.js.map
new file mode 100644
index 0000000..b2be828
--- /dev/null
+++ b/dist/amd/aurelia-templating-router.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"aurelia-templating-router.js","sources":["../../src/router-view.ts","../../src/route-loader.ts","../../src/route-href.ts","../../src/aurelia-templating-router.ts"],"sourcesContent":["import { Container } from 'aurelia-dependency-injection';\nimport { createOverrideContext, OverrideContext } from 'aurelia-binding';\nimport {\n ViewSlot,\n ViewLocator,\n BehaviorInstruction,\n CompositionTransaction,\n CompositionEngine,\n ShadowDOM,\n SwapStrategies,\n ResourceDescription,\n HtmlBehaviorResource,\n CompositionTransactionNotifier,\n View,\n CompositionTransactionOwnershipToken,\n Controller,\n ViewFactory,\n CompositionContext,\n IStaticResourceConfig,\n IStaticViewConfig\n} from 'aurelia-templating';\nimport {\n Router\n} from 'aurelia-router';\nimport { Origin } from 'aurelia-metadata';\nimport { DOM } from 'aurelia-pal';\nimport { IRouterViewViewPortInstruction, Constructable } from './interfaces';\n\nclass EmptyLayoutViewModel {\n\n}\n\n/**\n * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views\n */\nexport class RouterView {\n\n /**@internal */\n static inject() {\n return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n *\n * There is no view to compose by default in a router view\n * This custom element is responsible for composing its own view, based on current config\n */\n static $view: IStaticViewConfig = null;\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n name: 'router-view',\n bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context'] as any\n };\n\n /**\n * Swapping order when going to a new route. By default, supports 3 value: before, after, with\n * - before = new in -> old out\n * - after = old out -> new in\n * - with = new in + old out\n *\n * These values are defined by swapStrategies export in aurelia-templating/ aurelia-framework\n * Can be extended there and used here\n */\n swapOrder?: string;\n\n /**\n * Layout view used for this router-view layout, if no layout-viewmodel specified\n */\n layoutView?: any;\n\n /**\n * Layout view model used as binding context for this router-view layout\n * Actual type would be {string | Constructable | object}\n */\n layoutViewModel?: any;\n\n /**\n * Layout model used to activate layout view model, if specified with `layoutViewModel`\n */\n layoutModel?: any;\n\n /**\n * Element associated with this custom element\n */\n readonly element: Element;\n\n /**\n * Current router associated with this \n */\n readonly router: Router;\n\n /**\n * Container at this level\n */\n container: Container;\n\n /**\n * @internal\n * the view slot for adding / removing Routing related views created dynamically\n */\n viewSlot: ViewSlot;\n\n /**\n * @internal\n * Used to mimic partially functionalities of CompositionEngine\n */\n viewLocator: ViewLocator;\n\n /**\n * @internal\n * View composed by the CompositionEngine, depends on layout / viewports/ moduleId / viewModel of routeconfig\n */\n view: View;\n\n /**\n * @internal\n * The view where this `` is placed in\n */\n owningView: View;\n\n /**\n * @internal\n * Composition Transaction of initial composition transaction, when this is created\n */\n compositionTransaction: CompositionTransaction;\n\n /**\n * @internal\n * CompositionEngine instance, responsible for composing view/view model during process changes phase of this \n */\n compositionEngine: CompositionEngine;\n\n /**\n * Composition transaction notifier instance. Created when this router-view composing its instruction\n * for the first time.\n * Null on 2nd time and after.\n * @internal\n */\n compositionTransactionNotifier: CompositionTransactionNotifier;\n\n /**\n * @internal\n */\n compositionTransactionOwnershipToken: CompositionTransactionOwnershipToken;\n\n /**\n * @internal\n */\n overrideContext: OverrideContext;\n\n constructor(\n element: Element,\n container: Container,\n viewSlot: ViewSlot,\n router: Router,\n viewLocator: ViewLocator,\n compositionTransaction: CompositionTransaction,\n compositionEngine: CompositionEngine\n ) {\n this.element = element;\n this.container = container;\n this.viewSlot = viewSlot;\n this.router = router;\n this.viewLocator = viewLocator;\n this.compositionTransaction = compositionTransaction;\n this.compositionEngine = compositionEngine;\n // add this to router view ports lookup based on name attribute\n // when this router is the root router-view\n // also trigger AppRouter registerViewPort extra flow\n this.router.registerViewPort(this, this.element.getAttribute('name'));\n\n // Each process its instruction as a composition transaction\n // there are differences between intial composition and subsequent compositions\n // also there are differences between root composition and child composition\n // mark the first composition transaction with a property initialComposition to distinguish it\n // when the root gets new instruction for the first time\n if (!('initialComposition' in compositionTransaction)) {\n compositionTransaction.initialComposition = true;\n this.compositionTransactionNotifier = compositionTransaction.enlist();\n }\n }\n\n created(owningView: View): void {\n this.owningView = owningView;\n }\n\n bind(bindingContext: any, overrideContext: OverrideContext): void {\n // router needs to get access to view model of current route parent\n // doing it in generic way via viewModel property on container\n this.container.viewModel = bindingContext;\n this.overrideContext = overrideContext;\n }\n\n /**\n * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline\n */\n process($viewPortInstruction: any, waitToSwap?: boolean): Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction = $viewPortInstruction as IRouterViewViewPortInstruction;\n const component = viewPortInstruction.component;\n const childContainer = component.childContainer;\n const viewModel = component.viewModel;\n const viewModelResource = component.viewModelResource as unknown as ResourceDescription;\n const metadata = viewModelResource.metadata;\n const config = component.router.currentInstruction.config;\n const viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};\n\n (childContainer.get(RouterViewLocator) as RouterViewLocator)._notify(this);\n\n // layoutInstruction is our layout viewModel\n const layoutInstruction = {\n viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,\n view: viewPortConfig.layoutView || config.layoutView || this.layoutView,\n model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,\n router: viewPortInstruction.component.router,\n childContainer: childContainer,\n viewSlot: this.viewSlot\n };\n\n // viewport will be a thin wrapper around composition engine\n // to process instruction/configuration from users\n // preparing all information related to a composition process\n // first by getting view strategy of a ViewPortComponent View\n const viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);\n if (viewStrategy && component.view) {\n viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);\n }\n\n // using metadata of a custom element view model to load appropriate view-factory instance\n return metadata\n .load(childContainer, viewModelResource.value, null, viewStrategy, true)\n // for custom element, viewFactory typing is always ViewFactory\n // for custom attribute, it will be HtmlBehaviorResource\n .then((viewFactory: ViewFactory | HtmlBehaviorResource) => {\n // if this is not the first time that this is composing its instruction\n // try to capture ownership of the composition transaction\n // child will not be able to capture, since root typically captures\n // the ownership token\n if (!this.compositionTransactionNotifier) {\n this.compositionTransactionOwnershipToken = this.compositionTransaction.tryCapture();\n }\n\n if (layoutInstruction.viewModel || layoutInstruction.view) {\n viewPortInstruction.layoutInstruction = layoutInstruction;\n }\n\n const viewPortComponentBehaviorInstruction = BehaviorInstruction.dynamic(\n this.element,\n viewModel,\n viewFactory as ViewFactory\n );\n viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);\n\n if (waitToSwap) {\n return null;\n }\n\n this.swap(viewPortInstruction);\n });\n }\n\n swap($viewPortInstruction: any): void | Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction: IRouterViewViewPortInstruction = $viewPortInstruction;\n const viewPortController = viewPortInstruction.controller;\n const layoutInstruction = viewPortInstruction.layoutInstruction;\n const previousView = this.view;\n\n // Final step of swapping a ViewPortComponent\n const work = () => {\n const swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;\n const viewSlot = this.viewSlot;\n\n swapStrategy(\n viewSlot,\n previousView,\n () => Promise.resolve(viewSlot.add(this.view))\n ).then(() => {\n this._notify();\n });\n };\n\n // Ensure all users setups have been completed\n const ready = (owningView_or_layoutView: View) => {\n viewPortController.automate(this.overrideContext, owningView_or_layoutView);\n const transactionOwnerShipToken = this.compositionTransactionOwnershipToken;\n // if this router-view is the root of a normal startup via aurelia.setRoot\n // attemp to take control of the transaction\n\n // if ownership can be taken\n // wait for transaction to complete before swapping\n if (transactionOwnerShipToken) {\n return transactionOwnerShipToken\n .waitForCompositionComplete()\n .then(() => {\n this.compositionTransactionOwnershipToken = null;\n return work();\n });\n }\n\n // otherwise, just swap\n return work();\n };\n\n // If there is layout instruction, new to compose layout before processing ViewPortComponent\n // layout controller/view/view-model is composed using composition engine APIs\n if (layoutInstruction) {\n if (!layoutInstruction.viewModel) {\n // createController chokes if there's no viewmodel, so create a dummy one\n // but avoid using a POJO as it creates unwanted metadata in Object constructor\n layoutInstruction.viewModel = new EmptyLayoutViewModel();\n }\n\n // using composition engine to create compose layout\n return this.compositionEngine\n // first create controller from layoutInstruction\n // and treat it as CompositionContext\n // then emulate slot projection with ViewPortComponent view\n .createController(layoutInstruction as CompositionContext)\n .then((layoutController: Controller) => {\n const layoutView = layoutController.view;\n ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);\n // when there is a layout\n // view hierarchy is: owner view -> layout view -> ViewPortComponent view\n layoutController.automate(createOverrideContext(layoutInstruction.viewModel), this.owningView);\n layoutView.children.push(viewPortController.view);\n return layoutView || layoutController;\n })\n .then((newView: View | Controller) => {\n this.view = newView as View;\n return ready(newView as View);\n });\n }\n\n // if there is no layout, then get ViewPortComponent view ready as view property\n // and process controller/swapping\n // when there is no layout\n // view hierarchy is: owner view -> ViewPortComponent view\n this.view = viewPortController.view;\n\n return ready(this.owningView);\n }\n\n /**\n * Notify composition transaction that this router has finished processing\n * Happens when this is the root router-view\n * @internal\n */\n _notify() {\n const notifier = this.compositionTransactionNotifier;\n if (notifier) {\n notifier.done();\n this.compositionTransactionNotifier = null;\n }\n }\n}\n\n/**\n* Locator which finds the nearest RouterView, relative to the current dependency injection container.\n*/\nexport class RouterViewLocator {\n\n /*@internal */\n promise: Promise;\n\n /*@internal */\n resolve: (val?: any) => void;\n\n /**\n * Creates an instance of the RouterViewLocator class.\n */\n constructor() {\n this.promise = new Promise((resolve) => this.resolve = resolve);\n }\n\n /**\n * Finds the nearest RouterView instance.\n * @returns A promise that will be resolved with the located RouterView instance.\n */\n findNearest(): Promise {\n return this.promise;\n }\n\n /**@internal */\n _notify(routerView: RouterView): void {\n this.resolve(routerView);\n }\n}\n","import { Origin } from 'aurelia-metadata';\nimport { relativeToFile } from 'aurelia-path';\nimport { NavigationInstruction, RouteConfig, RouteLoader, Router } from 'aurelia-router';\nimport { CompositionEngine, customElement, inlineView, useView, CompositionContext } from 'aurelia-templating';\nimport { RouterViewLocator } from './router-view';\nimport { Container } from 'aurelia-dependency-injection';\n\n/**@internal exported for unit testing */\nexport class EmptyClass { }\ninlineView('')(EmptyClass);\n\n/**\n * Default implementation of `RouteLoader` used for loading component based on a route config\n */\nexport class TemplatingRouteLoader extends RouteLoader {\n\n /**@internal */\n static inject = [CompositionEngine];\n\n /**@internal */\n compositionEngine: CompositionEngine;\n\n constructor(\n compositionEngine: CompositionEngine\n ) {\n super();\n this.compositionEngine = compositionEngine;\n }\n\n /**\n * Resolve a view model from a RouteConfig\n * Throws when there is neither \"moduleId\" nor \"viewModel\" property\n * @internal\n */\n resolveViewModel(router: Router, config: RouteConfig): Promise {\n return new Promise((resolve, reject) => {\n let viewModel: string | null | Function;\n if ('moduleId' in config) {\n let moduleId = config.moduleId;\n if (moduleId === null) {\n viewModel = EmptyClass;\n } else {\n // this requires container of router has passes a certain point\n // where a view model has been setup on the container\n // it will fail in enhance scenario because no viewport has been registered\n moduleId = relativeToFile(moduleId, Origin.get(router.container.viewModel.constructor).moduleId);\n if (/\\.html/i.test(moduleId)) {\n viewModel = createDynamicClass(moduleId);\n } else {\n viewModel = moduleId;\n }\n }\n return resolve(viewModel);\n }\n // todo: add if ('viewModel' in config) to support static view model resolution\n reject(new Error('Invalid route config. No \"moduleId\" found.'));\n });\n }\n\n /**\n * Create child container based on a router container\n * Also ensures that child router are properly constructed in the newly created child container\n * @internal\n */\n createChildContainer(router: Router): Container {\n const childContainer = router.container.createChild();\n\n childContainer.registerSingleton(RouterViewLocator);\n childContainer.getChildRouter = function() {\n let childRouter: Router;\n\n childContainer.registerHandler(\n Router,\n () => childRouter || (childRouter = router.createChild(childContainer))\n );\n\n return childContainer.get(Router);\n };\n return childContainer;\n }\n\n /**\n * Load corresponding component of a route config of a navigation instruction\n */\n loadRoute(router: Router, config: RouteConfig, _navInstruction: NavigationInstruction): Promise {\n return this\n .resolveViewModel(router, config)\n .then(viewModel => this.compositionEngine.ensureViewModel({\n viewModel: viewModel,\n childContainer: this.createChildContainer(router),\n view: config.view || config.viewStrategy,\n router: router\n } as CompositionContext));\n }\n}\n\n/**@internal exported for unit testing */\nexport function createDynamicClass(moduleId: string) {\n const name = /([^\\/^\\?]+)\\.html/i.exec(moduleId)[1];\n\n class DynamicClass {\n\n $parent: any;\n\n bind(bindingContext: any) {\n this.$parent = bindingContext;\n }\n }\n\n customElement(name)(DynamicClass);\n useView(moduleId)(DynamicClass);\n\n return DynamicClass;\n}\n","import { IStaticResourceConfig } from 'aurelia-templating';\nimport { Router } from 'aurelia-router';\nimport { DOM } from 'aurelia-pal';\nimport * as LogManager from 'aurelia-logging';\n\nconst logger = LogManager.getLogger('route-href');\n\n/**\n * Helper custom attribute to help associate an element with a route by name\n */\nexport class RouteHref {\n\n /*@internal */\n static inject() {\n return [Router, DOM.Element];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n type: 'attribute',\n name: 'route-href',\n bindables: [\n { name: 'route', changeHandler: 'processChange', primaryProperty: true },\n { name: 'params', changeHandler: 'processChange' },\n 'attribute'\n ] as any // type definition of Aurelia templating is wrong\n };\n\n /**\n * Current router of this attribute\n */\n readonly router: Router;\n\n /**\n * Element this attribute is associated with\n */\n readonly element: Element;\n\n /**@internal */\n isActive: boolean;\n\n /**\n * Name of the route this attribute refers to. This name should exist in the current router hierarchy\n */\n route: string;\n\n /**\n * Parameters of this attribute to generate URL.\n */\n params: Record;\n\n /**\n * Target property on a custom element if this attribute is put on a custom element\n * OR an attribute if this attribute is put on a normal element\n */\n attribute: string;\n\n constructor(\n router: Router,\n element: Element\n ) {\n this.router = router;\n this.element = element;\n this.attribute = 'href';\n }\n\n bind() {\n this.isActive = true;\n this.processChange();\n }\n\n unbind() {\n this.isActive = false;\n }\n\n attributeChanged(value: any, previous: any) {\n if (previous) {\n this.element.removeAttribute(previous);\n }\n\n return this.processChange();\n }\n\n processChange() {\n return this.router\n .ensureConfigured()\n .then((): null => {\n if (!this.isActive) {\n // returning null to avoid Bluebird warning\n return null;\n }\n const element = this.element as Element & { au: any };\n\n const href = this.router.generate(this.route, this.params);\n\n if (element.au.controller) {\n element.au.controller.viewModel[this.attribute] = href;\n } else {\n element.setAttribute(this.attribute, href);\n }\n\n // returning null to avoid Bluebird warning\n return null;\n })\n .catch((reason: any) => {\n logger.error(reason);\n });\n }\n}\n\n","import { Router, AppRouter, RouteLoader } from 'aurelia-router';\nimport { TemplatingRouteLoader } from './route-loader';\nimport { RouterView } from './router-view';\nimport { RouteHref } from './route-href';\nimport { IFrameworkConfiguration } from './interfaces';\n\nexport function configure(config: IFrameworkConfiguration) {\n config\n .singleton(RouteLoader, TemplatingRouteLoader)\n .singleton(Router, AppRouter)\n .globalResources(\n RouterView,\n RouteHref\n );\n\n config.container.registerAlias(Router, AppRouter);\n}\n\nexport {\n TemplatingRouteLoader,\n RouterView,\n RouteHref\n};\n"],"names":["DOM","Container","ViewSlot","Router","ViewLocator","CompositionTransaction","CompositionEngine","Origin","BehaviorInstruction","SwapStrategies","ShadowDOM","createOverrideContext","inlineView","tslib_1.__extends","relativeToFile","RouteLoader","customElement","useView","LogManager.getLogger","AppRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4BA;QAAA;SAEC;QAAD,2BAAC;IAAD,CAAC,IAAA;IAED;;;AAGA;QAsHE,oBACE,OAAgB,EAChB,SAAoB,EACpB,QAAkB,EAClB,MAAc,EACd,WAAwB,EACxB,sBAA8C,EAC9C,iBAAoC;YAEpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;YACrD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;;;;YAI3C,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;YAOtE,IAAI,EAAE,oBAAoB,IAAI,sBAAsB,CAAC,EAAE;gBACrD,sBAAsB,CAAC,kBAAkB,GAAG,IAAI,CAAC;gBACjD,IAAI,CAAC,8BAA8B,GAAG,sBAAsB,CAAC,MAAM,EAAE,CAAC;aACvE;SACF;;QAjJM,iBAAM,GAAb;YACE,OAAO,CAACA,cAAG,CAAC,OAAO,EAAEC,oCAAS,EAAEC,0BAAQ,EAAEC,oBAAM,EAAEC,6BAAW,EAAEC,wCAAsB,EAAEC,mCAAiB,CAAC,CAAC;SAC3G;QAiJD,4BAAO,GAAP,UAAQ,UAAgB;YACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;SAC9B;Q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G,IAAI,CAAC;iBACxD;qBAAM;oBACL,OAAO,CAAC,YAAY,CAAC,KAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;iBAC5C;;gBAGD,OAAO,IAAI,CAAC;aACb,CAAC;iBACD,KAAK,CAAC,UAAC,MAAW;gBACjB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;aACtB,CAAC,CAAC;SACN;;;;QAzFM,mBAAS,GAA0B;YACxC,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,YAAY;YAClB,SAAS,EAAE;gBACT,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE;gBACxE,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE;gBAClD,WAAW;aACL;SACT,CAAC;QAkFJ,gBAAC;KApGD;;aCJgB,SAAS,CAAC,MAA+B;QACvD,MAAM;aACH,SAAS,CAACe,yBAAW,EAAE,qBAAqB,CAAC;aAC7C,SAAS,CAACZ,oBAAM,EAAEgB,uBAAS,CAAC;aAC5B,eAAe,CACd,UAAU,EACV,SAAS,CACV,CAAC;QAEJ,MAAM,CAAC,SAAS,CAAC,aAAa,CAAChB,oBAAM,EAAEgB,uBAAS,CAAC,CAAC;IACpD,CAAC;;;;;;;;;;;;;;;"}
\ No newline at end of file
diff --git a/dist/amd/index.js b/dist/amd/index.js
deleted file mode 100644
index 6de0203..0000000
--- a/dist/amd/index.js
+++ /dev/null
@@ -1,16 +0,0 @@
-define(['exports', './aurelia-templating-router'], function (exports, _aureliaTemplatingRouter) {
- 'use strict';
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- Object.keys(_aureliaTemplatingRouter).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function () {
- return _aureliaTemplatingRouter[key];
- }
- });
- });
-});
\ No newline at end of file
diff --git a/dist/amd/route-href.js b/dist/amd/route-href.js
deleted file mode 100644
index 9329345..0000000
--- a/dist/amd/route-href.js
+++ /dev/null
@@ -1,87 +0,0 @@
-define(['exports', 'aurelia-templating', 'aurelia-router', 'aurelia-pal', 'aurelia-logging'], function (exports, _aureliaTemplating, _aureliaRouter, _aureliaPal, _aureliaLogging) {
- 'use strict';
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.RouteHref = undefined;
-
- var LogManager = _interopRequireWildcard(_aureliaLogging);
-
- function _interopRequireWildcard(obj) {
- if (obj && obj.__esModule) {
- return obj;
- } else {
- var newObj = {};
-
- if (obj != null) {
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
- }
- }
-
- newObj.default = obj;
- return newObj;
- }
- }
-
-
-
- var _dec, _dec2, _dec3, _dec4, _class;
-
- var logger = LogManager.getLogger('route-href');
-
- var RouteHref = exports.RouteHref = (_dec = (0, _aureliaTemplating.customAttribute)('route-href'), _dec2 = (0, _aureliaTemplating.bindable)({ name: 'route', changeHandler: 'processChange', primaryProperty: true }), _dec3 = (0, _aureliaTemplating.bindable)({ name: 'params', changeHandler: 'processChange' }), _dec4 = (0, _aureliaTemplating.bindable)({ name: 'attribute', defaultValue: 'href' }), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = function () {
- RouteHref.inject = function inject() {
- return [_aureliaRouter.Router, _aureliaPal.DOM.Element];
- };
-
- function RouteHref(router, element) {
-
-
- this.router = router;
- this.element = element;
- }
-
- RouteHref.prototype.bind = function bind() {
- this.isActive = true;
- this.processChange();
- };
-
- RouteHref.prototype.unbind = function unbind() {
- this.isActive = false;
- };
-
- RouteHref.prototype.attributeChanged = function attributeChanged(value, previous) {
- if (previous) {
- this.element.removeAttribute(previous);
- }
-
- this.processChange();
- };
-
- RouteHref.prototype.processChange = function processChange() {
- var _this = this;
-
- return this.router.ensureConfigured().then(function () {
- if (!_this.isActive) {
- return null;
- }
-
- var href = _this.router.generate(_this.route, _this.params);
-
- if (_this.element.au.controller) {
- _this.element.au.controller.viewModel[_this.attribute] = href;
- } else {
- _this.element.setAttribute(_this.attribute, href);
- }
-
- return null;
- }).catch(function (reason) {
- logger.error(reason);
- });
- };
-
- return RouteHref;
- }()) || _class) || _class) || _class) || _class);
-});
\ No newline at end of file
diff --git a/dist/amd/route-loader.js b/dist/amd/route-loader.js
deleted file mode 100644
index 771cdab..0000000
--- a/dist/amd/route-loader.js
+++ /dev/null
@@ -1,110 +0,0 @@
-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';
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.TemplatingRouteLoader = undefined;
-
- 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;
- }
-
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }
-
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
-
-
- var _dec, _class, _dec2, _class2;
-
- var EmptyClass = (_dec = (0, _aureliaTemplating.inlineView)(''), _dec(_class = function EmptyClass() {
-
- }) || _class);
- var TemplatingRouteLoader = exports.TemplatingRouteLoader = (_dec2 = (0, _aureliaDependencyInjection.inject)(_aureliaTemplating.CompositionEngine), _dec2(_class2 = function (_RouteLoader) {
- _inherits(TemplatingRouteLoader, _RouteLoader);
-
- function TemplatingRouteLoader(compositionEngine) {
-
-
- var _this = _possibleConstructorReturn(this, _RouteLoader.call(this));
-
- _this.compositionEngine = compositionEngine;
- return _this;
- }
-
- TemplatingRouteLoader.prototype.loadRoute = function loadRoute(router, config) {
- var childContainer = router.container.createChild();
-
- var viewModel = void 0;
- if (config.moduleId === null) {
- viewModel = EmptyClass;
- } else if (/\.html/i.test(config.moduleId)) {
- viewModel = createDynamicClass(config.moduleId);
- } else {
- viewModel = (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
- }
-
- var instruction = {
- viewModel: viewModel,
- childContainer: childContainer,
- view: config.view || config.viewStrategy,
- router: router
- };
-
- childContainer.registerSingleton(_routerView.RouterViewLocator);
-
- childContainer.getChildRouter = function () {
- var childRouter = void 0;
-
- childContainer.registerHandler(_aureliaRouter.Router, function (c) {
- return childRouter || (childRouter = router.createChild(childContainer));
- });
-
- return childContainer.get(_aureliaRouter.Router);
- };
-
- return this.compositionEngine.ensureViewModel(instruction);
- };
-
- return TemplatingRouteLoader;
- }(_aureliaRouter.RouteLoader)) || _class2);
-
-
- function createDynamicClass(moduleId) {
- var _dec3, _dec4, _class3;
-
- var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
-
- var DynamicClass = (_dec3 = (0, _aureliaTemplating.customElement)(name), _dec4 = (0, _aureliaTemplating.useView)(moduleId), _dec3(_class3 = _dec4(_class3 = function () {
- function DynamicClass() {
-
- }
-
- DynamicClass.prototype.bind = function bind(bindingContext) {
- this.$parent = bindingContext;
- };
-
- return DynamicClass;
- }()) || _class3) || _class3);
-
-
- return DynamicClass;
- }
-});
\ No newline at end of file
diff --git a/dist/amd/router-view.js b/dist/amd/router-view.js
deleted file mode 100644
index 1a21ad0..0000000
--- a/dist/amd/router-view.js
+++ /dev/null
@@ -1,235 +0,0 @@
-define(['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-templating', 'aurelia-router', 'aurelia-metadata', 'aurelia-pal'], function (exports, _aureliaDependencyInjection, _aureliaBinding, _aureliaTemplating, _aureliaRouter, _aureliaMetadata, _aureliaPal) {
- 'use strict';
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.RouterViewLocator = exports.RouterView = undefined;
-
- function _initDefineProp(target, property, descriptor, context) {
- if (!descriptor) return;
- Object.defineProperty(target, property, {
- enumerable: descriptor.enumerable,
- configurable: descriptor.configurable,
- writable: descriptor.writable,
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
- });
- }
-
-
-
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
- var desc = {};
- Object['ke' + 'ys'](descriptor).forEach(function (key) {
- desc[key] = descriptor[key];
- });
- desc.enumerable = !!desc.enumerable;
- desc.configurable = !!desc.configurable;
-
- if ('value' in desc || desc.initializer) {
- desc.writable = true;
- }
-
- desc = decorators.slice().reverse().reduce(function (desc, decorator) {
- return decorator(target, property, desc) || desc;
- }, desc);
-
- if (context && desc.initializer !== void 0) {
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
- desc.initializer = undefined;
- }
-
- if (desc.initializer === void 0) {
- Object['define' + 'Property'](target, property, desc);
- desc = null;
- }
-
- return desc;
- }
-
- function _initializerWarningHelper(descriptor, context) {
- throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
- }
-
- var _dec, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
-
- var RouterView = exports.RouterView = (_dec = (0, _aureliaTemplating.customElement)('router-view'), _dec(_class = (0, _aureliaTemplating.noView)(_class = (_class2 = function () {
- RouterView.inject = function inject() {
- return [_aureliaPal.DOM.Element, _aureliaDependencyInjection.Container, _aureliaTemplating.ViewSlot, _aureliaRouter.Router, _aureliaTemplating.ViewLocator, _aureliaTemplating.CompositionTransaction, _aureliaTemplating.CompositionEngine];
- };
-
- function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
-
-
- _initDefineProp(this, 'swapOrder', _descriptor, this);
-
- _initDefineProp(this, 'layoutView', _descriptor2, this);
-
- _initDefineProp(this, 'layoutViewModel', _descriptor3, this);
-
- _initDefineProp(this, 'layoutModel', _descriptor4, this);
-
- this.element = element;
- this.container = container;
- this.viewSlot = viewSlot;
- this.router = router;
- this.viewLocator = viewLocator;
- this.compositionTransaction = compositionTransaction;
- this.compositionEngine = compositionEngine;
- this.router.registerViewPort(this, this.element.getAttribute('name'));
-
- if (!('initialComposition' in compositionTransaction)) {
- compositionTransaction.initialComposition = true;
- this.compositionTransactionNotifier = compositionTransaction.enlist();
- }
- }
-
- RouterView.prototype.created = function created(owningView) {
- this.owningView = owningView;
- };
-
- RouterView.prototype.bind = function bind(bindingContext, overrideContext) {
- this.container.viewModel = bindingContext;
- this.overrideContext = overrideContext;
- };
-
- RouterView.prototype.process = function process(viewPortInstruction, waitToSwap) {
- var _this = this;
-
- var component = viewPortInstruction.component;
- var childContainer = component.childContainer;
- var viewModel = component.viewModel;
- var viewModelResource = component.viewModelResource;
- var metadata = viewModelResource.metadata;
- var config = component.router.currentInstruction.config;
- var viewPort = config.viewPorts ? config.viewPorts[viewPortInstruction.name] || {} : {};
-
- childContainer.get(RouterViewLocator)._notify(this);
-
- var layoutInstruction = {
- viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
- view: viewPort.layoutView || config.layoutView || this.layoutView,
- model: viewPort.layoutModel || config.layoutModel || this.layoutModel,
- router: viewPortInstruction.component.router,
- childContainer: childContainer,
- viewSlot: this.viewSlot
- };
-
- var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
- if (viewStrategy && component.view) {
- viewStrategy.makeRelativeTo(_aureliaMetadata.Origin.get(component.router.container.viewModel.constructor).moduleId);
- }
-
- return metadata.load(childContainer, viewModelResource.value, null, viewStrategy, true).then(function (viewFactory) {
- if (!_this.compositionTransactionNotifier) {
- _this.compositionTransactionOwnershipToken = _this.compositionTransaction.tryCapture();
- }
-
- if (layoutInstruction.viewModel || layoutInstruction.view) {
- viewPortInstruction.layoutInstruction = layoutInstruction;
- }
-
- viewPortInstruction.controller = metadata.create(childContainer, _aureliaTemplating.BehaviorInstruction.dynamic(_this.element, viewModel, viewFactory));
-
- if (waitToSwap) {
- return null;
- }
-
- _this.swap(viewPortInstruction);
- });
- };
-
- RouterView.prototype.swap = function swap(viewPortInstruction) {
- var _this2 = this;
-
- var layoutInstruction = viewPortInstruction.layoutInstruction;
- var previousView = this.view;
-
- var work = function work() {
- var swapStrategy = _aureliaTemplating.SwapStrategies[_this2.swapOrder] || _aureliaTemplating.SwapStrategies.after;
- var viewSlot = _this2.viewSlot;
-
- swapStrategy(viewSlot, previousView, function () {
- return Promise.resolve(viewSlot.add(_this2.view));
- }).then(function () {
- _this2._notify();
- });
- };
-
- var ready = function ready(owningView) {
- viewPortInstruction.controller.automate(_this2.overrideContext, owningView);
- if (_this2.compositionTransactionOwnershipToken) {
- return _this2.compositionTransactionOwnershipToken.waitForCompositionComplete().then(function () {
- _this2.compositionTransactionOwnershipToken = null;
- return work();
- });
- }
-
- return work();
- };
-
- if (layoutInstruction) {
- if (!layoutInstruction.viewModel) {
- layoutInstruction.viewModel = {};
- }
-
- return this.compositionEngine.createController(layoutInstruction).then(function (controller) {
- _aureliaTemplating.ShadowDOM.distributeView(viewPortInstruction.controller.view, controller.slots || controller.view.slots);
- controller.automate((0, _aureliaBinding.createOverrideContext)(layoutInstruction.viewModel), _this2.owningView);
- controller.view.children.push(viewPortInstruction.controller.view);
- return controller.view || controller;
- }).then(function (newView) {
- _this2.view = newView;
- return ready(newView);
- });
- }
-
- this.view = viewPortInstruction.controller.view;
-
- return ready(this.owningView);
- };
-
- RouterView.prototype._notify = function _notify() {
- if (this.compositionTransactionNotifier) {
- this.compositionTransactionNotifier.done();
- this.compositionTransactionNotifier = null;
- }
- };
-
- return RouterView;
- }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'swapOrder', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'layoutView', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'layoutViewModel', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'layoutModel', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
- })), _class2)) || _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;
- }();
-});
\ No newline at end of file
diff --git a/dist/aurelia-templating-router.d.ts b/dist/aurelia-templating-router.d.ts
index c516443..e05da8c 100644
--- a/dist/aurelia-templating-router.d.ts
+++ b/dist/aurelia-templating-router.d.ts
@@ -1,78 +1,100 @@
-import * as LogManager from 'aurelia-logging';
-import {
- customAttribute,
- bindable,
- ViewSlot,
- ViewLocator,
- customElement,
- noView,
- BehaviorInstruction,
- CompositionTransaction,
- CompositionEngine,
- ShadowDOM,
- SwapStrategies,
- useView,
- inlineView
-} from 'aurelia-templating';
-import {
- Router,
- RouteLoader
-} from 'aurelia-router';
-import {
- DOM
-} from 'aurelia-pal';
-import {
- Container,
- inject
-} from 'aurelia-dependency-injection';
-import {
- createOverrideContext
-} from 'aurelia-binding';
-import {
- Origin
-} from 'aurelia-metadata';
-import {
- relativeToFile
-} from 'aurelia-path';
-export declare class RouteHref {
- static inject(): any;
- constructor(router?: any, element?: any);
- bind(): any;
- unbind(): any;
- attributeChanged(value?: any, previous?: any): any;
- processChange(): any;
+import { OverrideContext } from 'aurelia-binding';
+import { Container } from 'aurelia-dependency-injection';
+import { NavigationInstruction, RouteConfig, RouteLoader, Router } from 'aurelia-router';
+import { CompositionEngine, CompositionTransaction, View, ViewLocator, ViewSlot } from 'aurelia-templating';
+
+/**
+ * Default implementation of `RouteLoader` used for loading component based on a route config
+ */
+export declare class TemplatingRouteLoader extends RouteLoader {
+ constructor(compositionEngine: CompositionEngine);
+ /**
+ * Load corresponding component of a route config of a navigation instruction
+ */
+ loadRoute(router: Router, config: RouteConfig, _navInstruction: NavigationInstruction): Promise;
}
+/**
+ * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views
+ */
export declare class RouterView {
- static inject(): any;
- swapOrder: any;
- layoutView: any;
- layoutViewModel: any;
- layoutModel: any;
- element: any;
- constructor(element?: any, container?: any, viewSlot?: any, router?: any, viewLocator?: any, compositionTransaction?: any, compositionEngine?: any);
- created(owningView?: any): any;
- bind(bindingContext?: any, overrideContext?: any): any;
- process(viewPortInstruction?: any, waitToSwap?: any): any;
- swap(viewPortInstruction?: any): any;
+ /**
+ * Swapping order when going to a new route. By default, supports 3 value: before, after, with
+ * - before = new in -> old out
+ * - after = old out -> new in
+ * - with = new in + old out
+ *
+ * These values are defined by swapStrategies export in aurelia-templating/ aurelia-framework
+ * Can be extended there and used here
+ */
+ swapOrder?: string;
+ /**
+ * Layout view used for this router-view layout, if no layout-viewmodel specified
+ */
+ layoutView?: any;
+ /**
+ * Layout view model used as binding context for this router-view layout
+ * Actual type would be {string | Constructable | object}
+ */
+ layoutViewModel?: any;
+ /**
+ * Layout model used to activate layout view model, if specified with `layoutViewModel`
+ */
+ layoutModel?: any;
+ /**
+ * Element associated with this custom element
+ */
+ readonly element: Element;
+ /**
+ * Current router associated with this
+ */
+ readonly router: Router;
+ /**
+ * Container at this level
+ */
+ container: Container;
+ constructor(element: Element, container: Container, viewSlot: ViewSlot, router: Router, viewLocator: ViewLocator, compositionTransaction: CompositionTransaction, compositionEngine: CompositionEngine);
+ created(owningView: View): void;
+ bind(bindingContext: any, overrideContext: OverrideContext): void;
+ /**
+ * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline
+ */
+ process($viewPortInstruction: any, waitToSwap?: boolean): Promise;
+ swap($viewPortInstruction: any): void | Promise;
}
-
/**
-* 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;
+ * Helper custom attribute to help associate an element with a route by name
+ */
+export declare class RouteHref {
+ /**
+ * Current router of this attribute
+ */
+ readonly router: Router;
+ /**
+ * Element this attribute is associated with
+ */
+ readonly element: Element;
+ /**
+ * Name of the route this attribute refers to. This name should exist in the current router hierarchy
+ */
+ route: string;
+ /**
+ * Parameters of this attribute to generate URL.
+ */
+ params: Record;
+ /**
+ * Target property on a custom element if this attribute is put on a custom element
+ * OR an attribute if this attribute is put on a normal element
+ */
+ attribute: string;
+ constructor(router: Router, element: Element);
+ bind(): void;
+ unbind(): void;
+ attributeChanged(value: any, previous: any): Promise;
+ processChange(): Promise;
}
-export declare class TemplatingRouteLoader extends RouteLoader {
- constructor(compositionEngine?: any);
- loadRoute(router?: any, config?: any): any;
-}
\ No newline at end of file
+export interface IFrameworkConfiguration {
+ container: Container;
+ singleton(...args: any[]): this;
+ globalResources(...args: any[]): this;
+}
+export declare function configure(config: IFrameworkConfiguration): void;
\ No newline at end of file
diff --git a/dist/aurelia-templating-router.js b/dist/aurelia-templating-router.js
deleted file mode 100644
index 44ac924..0000000
--- a/dist/aurelia-templating-router.js
+++ /dev/null
@@ -1,296 +0,0 @@
-import * as LogManager from 'aurelia-logging';
-import {customAttribute,bindable,ViewSlot,ViewLocator,customElement,noView,BehaviorInstruction,CompositionTransaction,CompositionEngine,ShadowDOM,SwapStrategies,useView,inlineView} from 'aurelia-templating';
-import {Router,RouteLoader} from 'aurelia-router';
-import {DOM} from 'aurelia-pal';
-import {Container,inject} from 'aurelia-dependency-injection';
-import {createOverrideContext} from 'aurelia-binding';
-import {Origin} from 'aurelia-metadata';
-import {relativeToFile} from 'aurelia-path';
-
-const logger = LogManager.getLogger('route-href');
-
-@customAttribute('route-href')
-@bindable({name: 'route', changeHandler: 'processChange', primaryProperty: true})
-@bindable({name: 'params', changeHandler: 'processChange'})
-@bindable({name: 'attribute', defaultValue: 'href'})
-export class RouteHref {
-
- static inject() {
- return [Router, DOM.Element];
- }
-
- constructor(router, element) {
- this.router = router;
- this.element = element;
- }
-
- bind() {
- this.isActive = true;
- this.processChange();
- }
-
- unbind() {
- this.isActive = false;
- }
-
- attributeChanged(value, previous) {
- if (previous) {
- this.element.removeAttribute(previous);
- }
-
- this.processChange();
- }
-
- processChange() {
- return this.router.ensureConfigured()
- .then(() => {
- if (!this.isActive) {
- return null;
- }
-
- let href = this.router.generate(this.route, this.params);
-
- if (this.element.au.controller) {
- this.element.au.controller.viewModel[this.attribute] = href;
- } else {
- this.element.setAttribute(this.attribute, href);
- }
-
- return null;
- }).catch(reason => {
- logger.error(reason);
- });
- }
-}
-
-@customElement('router-view')
-@noView
-export class RouterView {
-
- static inject() {
- return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];
- }
-
- @bindable swapOrder;
- @bindable layoutView;
- @bindable layoutViewModel;
- @bindable layoutModel;
- element;
-
- constructor(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
- this.element = element;
- this.container = container;
- this.viewSlot = viewSlot;
- this.router = router;
- this.viewLocator = viewLocator;
- this.compositionTransaction = compositionTransaction;
- this.compositionEngine = compositionEngine;
- this.router.registerViewPort(this, this.element.getAttribute('name'));
-
- if (!('initialComposition' in compositionTransaction)) {
- compositionTransaction.initialComposition = true;
- this.compositionTransactionNotifier = compositionTransaction.enlist();
- }
- }
-
- created(owningView) {
- this.owningView = owningView;
- }
-
- bind(bindingContext, overrideContext) {
- this.container.viewModel = bindingContext;
- this.overrideContext = overrideContext;
- }
-
- process(viewPortInstruction, waitToSwap) {
- let component = viewPortInstruction.component;
- let childContainer = component.childContainer;
- let viewModel = component.viewModel;
- let viewModelResource = component.viewModelResource;
- let metadata = viewModelResource.metadata;
- let config = component.router.currentInstruction.config;
- let viewPort = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};
-
- childContainer.get(RouterViewLocator)._notify(this);
-
- // layoutInstruction is our layout viewModel
- let layoutInstruction = {
- viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
- view: viewPort.layoutView || config.layoutView || this.layoutView,
- model: viewPort.layoutModel || config.layoutModel || this.layoutModel,
- router: viewPortInstruction.component.router,
- childContainer: childContainer,
- viewSlot: this.viewSlot
- };
-
- let viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
- if (viewStrategy && component.view) {
- viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);
- }
-
- return metadata.load(childContainer, viewModelResource.value, null, viewStrategy, true)
- .then(viewFactory => {
- if (!this.compositionTransactionNotifier) {
- this.compositionTransactionOwnershipToken = this.compositionTransaction.tryCapture();
- }
-
- if (layoutInstruction.viewModel || layoutInstruction.view) {
- viewPortInstruction.layoutInstruction = layoutInstruction;
- }
-
- viewPortInstruction.controller = metadata.create(childContainer,
- BehaviorInstruction.dynamic(
- this.element,
- viewModel,
- viewFactory
- )
- );
-
- if (waitToSwap) {
- return null;
- }
-
- this.swap(viewPortInstruction);
- });
- }
-
- swap(viewPortInstruction) {
- let layoutInstruction = viewPortInstruction.layoutInstruction;
- let previousView = this.view;
-
- let work = () => {
- let swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;
- let viewSlot = this.viewSlot;
-
- swapStrategy(viewSlot, previousView, () => {
- return Promise.resolve(viewSlot.add(this.view));
- }).then(() => {
- this._notify();
- });
- };
-
- let ready = owningView => {
- viewPortInstruction.controller.automate(this.overrideContext, owningView);
- if (this.compositionTransactionOwnershipToken) {
- return this.compositionTransactionOwnershipToken.waitForCompositionComplete().then(() => {
- this.compositionTransactionOwnershipToken = null;
- return work();
- });
- }
-
- return work();
- };
-
- if (layoutInstruction) {
- if (!layoutInstruction.viewModel) {
- // createController chokes if there's no viewmodel, so create a dummy one
- // should we use something else for the view model here?
- layoutInstruction.viewModel = {};
- }
-
- return this.compositionEngine.createController(layoutInstruction).then(controller => {
- ShadowDOM.distributeView(viewPortInstruction.controller.view, controller.slots || controller.view.slots);
- controller.automate(createOverrideContext(layoutInstruction.viewModel), this.owningView);
- controller.view.children.push(viewPortInstruction.controller.view);
- return controller.view || controller;
- }).then(newView => {
- this.view = newView;
- return ready(newView);
- });
- }
-
- this.view = viewPortInstruction.controller.view;
-
- return ready(this.owningView);
- }
-
- _notify() {
- if (this.compositionTransactionNotifier) {
- this.compositionTransactionNotifier.done();
- this.compositionTransactionNotifier = null;
- }
- }
-}
-
-/**
-* 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 {
- return this.promise;
- }
-
- _notify(routerView: RouterView): void {
- this.resolve(routerView);
- }
-}
-
-@inlineView('')
-class EmptyClass { }
-
-@inject(CompositionEngine)
-export class TemplatingRouteLoader extends RouteLoader {
- constructor(compositionEngine) {
- super();
- this.compositionEngine = compositionEngine;
- }
-
- loadRoute(router, config) {
- let childContainer = router.container.createChild();
-
- let viewModel;
- if (config.moduleId === null) {
- viewModel = EmptyClass;
- } else if (/\.html/i.test(config.moduleId)) {
- viewModel = createDynamicClass(config.moduleId);
- } else {
- viewModel = relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
- }
-
- let instruction = {
- viewModel: viewModel,
- childContainer: childContainer,
- view: config.view || config.viewStrategy,
- router: router
- };
-
- childContainer.registerSingleton(RouterViewLocator);
-
- childContainer.getChildRouter = function() {
- let childRouter;
-
- childContainer.registerHandler(Router, c => {
- return childRouter || (childRouter = router.createChild(childContainer));
- });
-
- return childContainer.get(Router);
- };
-
- return this.compositionEngine.ensureViewModel(instruction);
- }
-}
-
-function createDynamicClass(moduleId) {
- let name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
-
- @customElement(name)
- @useView(moduleId)
- class DynamicClass {
- bind(bindingContext) {
- this.$parent = bindingContext;
- }
- }
-
- return DynamicClass;
-}
diff --git a/dist/commonjs/aurelia-templating-router.js b/dist/commonjs/aurelia-templating-router.js
index 42e3d56..d7e0235 100644
--- a/dist/commonjs/aurelia-templating-router.js
+++ b/dist/commonjs/aurelia-templating-router.js
@@ -1,25 +1,440 @@
'use strict';
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.configure = exports.RouteHref = exports.RouterView = exports.TemplatingRouteLoader = undefined;
+Object.defineProperty(exports, '__esModule', { value: true });
-var _aureliaRouter = require('aurelia-router');
+var aureliaRouter = require('aurelia-router');
+var aureliaMetadata = require('aurelia-metadata');
+var aureliaPath = require('aurelia-path');
+var aureliaTemplating = require('aurelia-templating');
+var aureliaDependencyInjection = require('aurelia-dependency-injection');
+var aureliaBinding = require('aurelia-binding');
+var aureliaPal = require('aurelia-pal');
+var LogManager = require('aurelia-logging');
-var _routeLoader = require('./route-loader');
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+/* global Reflect, Promise */
+
+var extendStatics = function(d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+};
+
+function __extends(d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+}
-var _routerView = require('./router-view');
+var EmptyLayoutViewModel = /** @class */ (function () {
+ function EmptyLayoutViewModel() {
+ }
+ return EmptyLayoutViewModel;
+}());
+/**
+ * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views
+ */
+var RouterView = /** @class */ (function () {
+ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
+ this.element = element;
+ this.container = container;
+ this.viewSlot = viewSlot;
+ this.router = router;
+ this.viewLocator = viewLocator;
+ this.compositionTransaction = compositionTransaction;
+ this.compositionEngine = compositionEngine;
+ // add this to router view ports lookup based on name attribute
+ // when this router is the root router-view
+ // also trigger AppRouter registerViewPort extra flow
+ this.router.registerViewPort(this, this.element.getAttribute('name'));
+ // Each process its instruction as a composition transaction
+ // there are differences between intial composition and subsequent compositions
+ // also there are differences between root composition and child composition
+ // mark the first composition transaction with a property initialComposition to distinguish it
+ // when the root gets new instruction for the first time
+ if (!('initialComposition' in compositionTransaction)) {
+ compositionTransaction.initialComposition = true;
+ this.compositionTransactionNotifier = compositionTransaction.enlist();
+ }
+ }
+ /**@internal */
+ RouterView.inject = function () {
+ return [aureliaPal.DOM.Element, aureliaDependencyInjection.Container, aureliaTemplating.ViewSlot, aureliaRouter.Router, aureliaTemplating.ViewLocator, aureliaTemplating.CompositionTransaction, aureliaTemplating.CompositionEngine];
+ };
+ RouterView.prototype.created = function (owningView) {
+ this.owningView = owningView;
+ };
+ RouterView.prototype.bind = function (bindingContext, overrideContext) {
+ // router needs to get access to view model of current route parent
+ // doing it in generic way via viewModel property on container
+ this.container.viewModel = bindingContext;
+ this.overrideContext = overrideContext;
+ };
+ /**
+ * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline
+ */
+ RouterView.prototype.process = function ($viewPortInstruction, waitToSwap) {
+ var _this = this;
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ var viewPortInstruction = $viewPortInstruction;
+ var component = viewPortInstruction.component;
+ var childContainer = component.childContainer;
+ var viewModel = component.viewModel;
+ var viewModelResource = component.viewModelResource;
+ var metadata = viewModelResource.metadata;
+ var config = component.router.currentInstruction.config;
+ var viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};
+ childContainer.get(RouterViewLocator)._notify(this);
+ // layoutInstruction is our layout viewModel
+ var layoutInstruction = {
+ viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
+ view: viewPortConfig.layoutView || config.layoutView || this.layoutView,
+ model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,
+ router: viewPortInstruction.component.router,
+ childContainer: childContainer,
+ viewSlot: this.viewSlot
+ };
+ // viewport will be a thin wrapper around composition engine
+ // to process instruction/configuration from users
+ // preparing all information related to a composition process
+ // first by getting view strategy of a ViewPortComponent View
+ var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
+ if (viewStrategy && component.view) {
+ viewStrategy.makeRelativeTo(aureliaMetadata.Origin.get(component.router.container.viewModel.constructor).moduleId);
+ }
+ // using metadata of a custom element view model to load appropriate view-factory instance
+ return metadata
+ .load(childContainer, viewModelResource.value, null, viewStrategy, true)
+ // for custom element, viewFactory typing is always ViewFactory
+ // for custom attribute, it will be HtmlBehaviorResource
+ .then(function (viewFactory) {
+ // if this is not the first time that this is composing its instruction
+ // try to capture ownership of the composition transaction
+ // child will not be able to capture, since root typically captures
+ // the ownership token
+ if (!_this.compositionTransactionNotifier) {
+ _this.compositionTransactionOwnershipToken = _this.compositionTransaction.tryCapture();
+ }
+ if (layoutInstruction.viewModel || layoutInstruction.view) {
+ viewPortInstruction.layoutInstruction = layoutInstruction;
+ }
+ var viewPortComponentBehaviorInstruction = aureliaTemplating.BehaviorInstruction.dynamic(_this.element, viewModel, viewFactory);
+ viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);
+ if (waitToSwap) {
+ return null;
+ }
+ _this.swap(viewPortInstruction);
+ });
+ };
+ RouterView.prototype.swap = function ($viewPortInstruction) {
+ var _this = this;
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ var viewPortInstruction = $viewPortInstruction;
+ var viewPortController = viewPortInstruction.controller;
+ var layoutInstruction = viewPortInstruction.layoutInstruction;
+ var previousView = this.view;
+ // Final step of swapping a ViewPortComponent
+ var work = function () {
+ var swapStrategy = aureliaTemplating.SwapStrategies[_this.swapOrder] || aureliaTemplating.SwapStrategies.after;
+ var viewSlot = _this.viewSlot;
+ swapStrategy(viewSlot, previousView, function () { return Promise.resolve(viewSlot.add(_this.view)); }).then(function () {
+ _this._notify();
+ });
+ };
+ // Ensure all users setups have been completed
+ var ready = function (owningView_or_layoutView) {
+ viewPortController.automate(_this.overrideContext, owningView_or_layoutView);
+ var transactionOwnerShipToken = _this.compositionTransactionOwnershipToken;
+ // if this router-view is the root of a normal startup via aurelia.setRoot
+ // attemp to take control of the transaction
+ // if ownership can be taken
+ // wait for transaction to complete before swapping
+ if (transactionOwnerShipToken) {
+ return transactionOwnerShipToken
+ .waitForCompositionComplete()
+ .then(function () {
+ _this.compositionTransactionOwnershipToken = null;
+ return work();
+ });
+ }
+ // otherwise, just swap
+ return work();
+ };
+ // If there is layout instruction, new to compose layout before processing ViewPortComponent
+ // layout controller/view/view-model is composed using composition engine APIs
+ if (layoutInstruction) {
+ if (!layoutInstruction.viewModel) {
+ // createController chokes if there's no viewmodel, so create a dummy one
+ // but avoid using a POJO as it creates unwanted metadata in Object constructor
+ layoutInstruction.viewModel = new EmptyLayoutViewModel();
+ }
+ // using composition engine to create compose layout
+ return this.compositionEngine
+ // first create controller from layoutInstruction
+ // and treat it as CompositionContext
+ // then emulate slot projection with ViewPortComponent view
+ .createController(layoutInstruction)
+ .then(function (layoutController) {
+ var layoutView = layoutController.view;
+ aureliaTemplating.ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);
+ // when there is a layout
+ // view hierarchy is: owner view -> layout view -> ViewPortComponent view
+ layoutController.automate(aureliaBinding.createOverrideContext(layoutInstruction.viewModel), _this.owningView);
+ layoutView.children.push(viewPortController.view);
+ return layoutView || layoutController;
+ })
+ .then(function (newView) {
+ _this.view = newView;
+ return ready(newView);
+ });
+ }
+ // if there is no layout, then get ViewPortComponent view ready as view property
+ // and process controller/swapping
+ // when there is no layout
+ // view hierarchy is: owner view -> ViewPortComponent view
+ this.view = viewPortController.view;
+ return ready(this.owningView);
+ };
+ /**
+ * Notify composition transaction that this router has finished processing
+ * Happens when this is the root router-view
+ * @internal
+ */
+ RouterView.prototype._notify = function () {
+ var notifier = this.compositionTransactionNotifier;
+ if (notifier) {
+ notifier.done();
+ this.compositionTransactionNotifier = null;
+ }
+ };
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ *
+ * There is no view to compose by default in a router view
+ * This custom element is responsible for composing its own view, based on current config
+ */
+ RouterView.$view = null;
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+ RouterView.$resource = {
+ name: 'router-view',
+ bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context']
+ };
+ return RouterView;
+}());
+/**
+* Locator which finds the nearest RouterView, relative to the current dependency injection container.
+*/
+var RouterViewLocator = /** @class */ (function () {
+ /**
+ * Creates an instance of the RouterViewLocator class.
+ */
+ function RouterViewLocator() {
+ var _this = this;
+ this.promise = new Promise(function (resolve) { return _this.resolve = resolve; });
+ }
+ /**
+ * Finds the nearest RouterView instance.
+ * @returns A promise that will be resolved with the located RouterView instance.
+ */
+ RouterViewLocator.prototype.findNearest = function () {
+ return this.promise;
+ };
+ /**@internal */
+ RouterViewLocator.prototype._notify = function (routerView) {
+ this.resolve(routerView);
+ };
+ return RouterViewLocator;
+}());
-var _routeHref = require('./route-href');
+/**@internal exported for unit testing */
+var EmptyClass = /** @class */ (function () {
+ function EmptyClass() {
+ }
+ return EmptyClass;
+}());
+aureliaTemplating.inlineView('')(EmptyClass);
+/**
+ * Default implementation of `RouteLoader` used for loading component based on a route config
+ */
+var TemplatingRouteLoader = /** @class */ (function (_super) {
+ __extends(TemplatingRouteLoader, _super);
+ function TemplatingRouteLoader(compositionEngine) {
+ var _this = _super.call(this) || this;
+ _this.compositionEngine = compositionEngine;
+ return _this;
+ }
+ /**
+ * Resolve a view model from a RouteConfig
+ * Throws when there is neither "moduleId" nor "viewModel" property
+ * @internal
+ */
+ TemplatingRouteLoader.prototype.resolveViewModel = function (router, config) {
+ return new Promise(function (resolve, reject) {
+ var viewModel;
+ if ('moduleId' in config) {
+ var moduleId = config.moduleId;
+ if (moduleId === null) {
+ viewModel = EmptyClass;
+ }
+ else {
+ // this requires container of router has passes a certain point
+ // where a view model has been setup on the container
+ // it will fail in enhance scenario because no viewport has been registered
+ moduleId = aureliaPath.relativeToFile(moduleId, aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
+ if (/\.html/i.test(moduleId)) {
+ viewModel = createDynamicClass(moduleId);
+ }
+ else {
+ viewModel = moduleId;
+ }
+ }
+ return resolve(viewModel);
+ }
+ // todo: add if ('viewModel' in config) to support static view model resolution
+ reject(new Error('Invalid route config. No "moduleId" found.'));
+ });
+ };
+ /**
+ * Create child container based on a router container
+ * Also ensures that child router are properly constructed in the newly created child container
+ * @internal
+ */
+ TemplatingRouteLoader.prototype.createChildContainer = function (router) {
+ var childContainer = router.container.createChild();
+ childContainer.registerSingleton(RouterViewLocator);
+ childContainer.getChildRouter = function () {
+ var childRouter;
+ childContainer.registerHandler(aureliaRouter.Router, function () { return childRouter || (childRouter = router.createChild(childContainer)); });
+ return childContainer.get(aureliaRouter.Router);
+ };
+ return childContainer;
+ };
+ /**
+ * Load corresponding component of a route config of a navigation instruction
+ */
+ TemplatingRouteLoader.prototype.loadRoute = function (router, config, _navInstruction) {
+ var _this = this;
+ return this
+ .resolveViewModel(router, config)
+ .then(function (viewModel) { return _this.compositionEngine.ensureViewModel({
+ viewModel: viewModel,
+ childContainer: _this.createChildContainer(router),
+ view: config.view || config.viewStrategy,
+ router: router
+ }); });
+ };
+ /**@internal */
+ TemplatingRouteLoader.inject = [aureliaTemplating.CompositionEngine];
+ return TemplatingRouteLoader;
+}(aureliaRouter.RouteLoader));
+/**@internal exported for unit testing */
+function createDynamicClass(moduleId) {
+ var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
+ var DynamicClass = /** @class */ (function () {
+ function DynamicClass() {
+ }
+ DynamicClass.prototype.bind = function (bindingContext) {
+ this.$parent = bindingContext;
+ };
+ return DynamicClass;
+ }());
+ aureliaTemplating.customElement(name)(DynamicClass);
+ aureliaTemplating.useView(moduleId)(DynamicClass);
+ return DynamicClass;
+}
-function configure(config) {
- config.singleton(_aureliaRouter.RouteLoader, _routeLoader.TemplatingRouteLoader).singleton(_aureliaRouter.Router, _aureliaRouter.AppRouter).globalResources(_routerView.RouterView, _routeHref.RouteHref);
+var logger = LogManager.getLogger('route-href');
+/**
+ * Helper custom attribute to help associate an element with a route by name
+ */
+var RouteHref = /** @class */ (function () {
+ function RouteHref(router, element) {
+ this.router = router;
+ this.element = element;
+ this.attribute = 'href';
+ }
+ /*@internal */
+ RouteHref.inject = function () {
+ return [aureliaRouter.Router, aureliaPal.DOM.Element];
+ };
+ RouteHref.prototype.bind = function () {
+ this.isActive = true;
+ this.processChange();
+ };
+ RouteHref.prototype.unbind = function () {
+ this.isActive = false;
+ };
+ RouteHref.prototype.attributeChanged = function (value, previous) {
+ if (previous) {
+ this.element.removeAttribute(previous);
+ }
+ return this.processChange();
+ };
+ RouteHref.prototype.processChange = function () {
+ var _this = this;
+ return this.router
+ .ensureConfigured()
+ .then(function () {
+ if (!_this.isActive) {
+ // returning null to avoid Bluebird warning
+ return null;
+ }
+ var element = _this.element;
+ var href = _this.router.generate(_this.route, _this.params);
+ if (element.au.controller) {
+ element.au.controller.viewModel[_this.attribute] = href;
+ }
+ else {
+ element.setAttribute(_this.attribute, href);
+ }
+ // returning null to avoid Bluebird warning
+ return null;
+ })
+ .catch(function (reason) {
+ logger.error(reason);
+ });
+ };
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+ RouteHref.$resource = {
+ type: 'attribute',
+ name: 'route-href',
+ bindables: [
+ { name: 'route', changeHandler: 'processChange', primaryProperty: true },
+ { name: 'params', changeHandler: 'processChange' },
+ 'attribute'
+ ] // type definition of Aurelia templating is wrong
+ };
+ return RouteHref;
+}());
- config.container.registerAlias(_aureliaRouter.Router, _aureliaRouter.AppRouter);
+function configure(config) {
+ config
+ .singleton(aureliaRouter.RouteLoader, TemplatingRouteLoader)
+ .singleton(aureliaRouter.Router, aureliaRouter.AppRouter)
+ .globalResources(RouterView, RouteHref);
+ config.container.registerAlias(aureliaRouter.Router, aureliaRouter.AppRouter);
}
-exports.TemplatingRouteLoader = _routeLoader.TemplatingRouteLoader;
-exports.RouterView = _routerView.RouterView;
-exports.RouteHref = _routeHref.RouteHref;
-exports.configure = configure;
\ No newline at end of file
+exports.RouteHref = RouteHref;
+exports.RouterView = RouterView;
+exports.TemplatingRouteLoader = TemplatingRouteLoader;
+exports.configure = configure;
+//# sourceMappingURL=aurelia-templating-router.js.map
diff --git a/dist/commonjs/aurelia-templating-router.js.map b/dist/commonjs/aurelia-templating-router.js.map
new file mode 100644
index 0000000..c018b26
--- /dev/null
+++ b/dist/commonjs/aurelia-templating-router.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"aurelia-templating-router.js","sources":["../../src/router-view.ts","../../src/route-loader.ts","../../src/route-href.ts","../../src/aurelia-templating-router.ts"],"sourcesContent":["import { Container } from 'aurelia-dependency-injection';\nimport { createOverrideContext, OverrideContext } from 'aurelia-binding';\nimport {\n ViewSlot,\n ViewLocator,\n BehaviorInstruction,\n CompositionTransaction,\n CompositionEngine,\n ShadowDOM,\n SwapStrategies,\n ResourceDescription,\n HtmlBehaviorResource,\n CompositionTransactionNotifier,\n View,\n CompositionTransactionOwnershipToken,\n Controller,\n ViewFactory,\n CompositionContext,\n IStaticResourceConfig,\n IStaticViewConfig\n} from 'aurelia-templating';\nimport {\n Router\n} from 'aurelia-router';\nimport { Origin } from 'aurelia-metadata';\nimport { DOM } from 'aurelia-pal';\nimport { IRouterViewViewPortInstruction, Constructable } from './interfaces';\n\nclass EmptyLayoutViewModel {\n\n}\n\n/**\n * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views\n */\nexport class RouterView {\n\n /**@internal */\n static inject() {\n return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n *\n * There is no view to compose by default in a router view\n * This custom element is responsible for composing its own view, based on current config\n */\n static $view: IStaticViewConfig = null;\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n name: 'router-view',\n bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context'] as any\n };\n\n /**\n * Swapping order when going to a new route. By default, supports 3 value: before, after, with\n * - before = new in -> old out\n * - after = old out -> new in\n * - with = new in + old out\n *\n * These values are defined by swapStrategies export in aurelia-templating/ aurelia-framework\n * Can be extended there and used here\n */\n swapOrder?: string;\n\n /**\n * Layout view used for this router-view layout, if no layout-viewmodel specified\n */\n layoutView?: any;\n\n /**\n * Layout view model used as binding context for this router-view layout\n * Actual type would be {string | Constructable | object}\n */\n layoutViewModel?: any;\n\n /**\n * Layout model used to activate layout view model, if specified with `layoutViewModel`\n */\n layoutModel?: any;\n\n /**\n * Element associated with this custom element\n */\n readonly element: Element;\n\n /**\n * Current router associated with this \n */\n readonly router: Router;\n\n /**\n * Container at this level\n */\n container: Container;\n\n /**\n * @internal\n * the view slot for adding / removing Routing related views created dynamically\n */\n viewSlot: ViewSlot;\n\n /**\n * @internal\n * Used to mimic partially functionalities of CompositionEngine\n */\n viewLocator: ViewLocator;\n\n /**\n * @internal\n * View composed by the CompositionEngine, depends on layout / viewports/ moduleId / viewModel of routeconfig\n */\n view: View;\n\n /**\n * @internal\n * The view where this `` is placed in\n */\n owningView: View;\n\n /**\n * @internal\n * Composition Transaction of initial composition transaction, when this is created\n */\n compositionTransaction: CompositionTransaction;\n\n /**\n * @internal\n * CompositionEngine instance, responsible for composing view/view model during process changes phase of this \n */\n compositionEngine: CompositionEngine;\n\n /**\n * Composition transaction notifier instance. Created when this router-view composing its instruction\n * for the first time.\n * Null on 2nd time and after.\n * @internal\n */\n compositionTransactionNotifier: CompositionTransactionNotifier;\n\n /**\n * @internal\n */\n compositionTransactionOwnershipToken: CompositionTransactionOwnershipToken;\n\n /**\n * @internal\n */\n overrideContext: OverrideContext;\n\n constructor(\n element: Element,\n container: Container,\n viewSlot: ViewSlot,\n router: Router,\n viewLocator: ViewLocator,\n compositionTransaction: CompositionTransaction,\n compositionEngine: CompositionEngine\n ) {\n this.element = element;\n this.container = container;\n this.viewSlot = viewSlot;\n this.router = router;\n this.viewLocator = viewLocator;\n this.compositionTransaction = compositionTransaction;\n this.compositionEngine = compositionEngine;\n // add this to router view ports lookup based on name attribute\n // when this router is the root router-view\n // also trigger AppRouter registerViewPort extra flow\n this.router.registerViewPort(this, this.element.getAttribute('name'));\n\n // Each process its instruction as a composition transaction\n // there are differences between intial composition and subsequent compositions\n // also there are differences between root composition and child composition\n // mark the first composition transaction with a property initialComposition to distinguish it\n // when the root gets new instruction for the first time\n if (!('initialComposition' in compositionTransaction)) {\n compositionTransaction.initialComposition = true;\n this.compositionTransactionNotifier = compositionTransaction.enlist();\n }\n }\n\n created(owningView: View): void {\n this.owningView = owningView;\n }\n\n bind(bindingContext: any, overrideContext: OverrideContext): void {\n // router needs to get access to view model of current route parent\n // doing it in generic way via viewModel property on container\n this.container.viewModel = bindingContext;\n this.overrideContext = overrideContext;\n }\n\n /**\n * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline\n */\n process($viewPortInstruction: any, waitToSwap?: boolean): Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction = $viewPortInstruction as IRouterViewViewPortInstruction;\n const component = viewPortInstruction.component;\n const childContainer = component.childContainer;\n const viewModel = component.viewModel;\n const viewModelResource = component.viewModelResource as unknown as ResourceDescription;\n const metadata = viewModelResource.metadata;\n const config = component.router.currentInstruction.config;\n const viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};\n\n (childContainer.get(RouterViewLocator) as RouterViewLocator)._notify(this);\n\n // layoutInstruction is our layout viewModel\n const layoutInstruction = {\n viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,\n view: viewPortConfig.layoutView || config.layoutView || this.layoutView,\n model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,\n router: viewPortInstruction.component.router,\n childContainer: childContainer,\n viewSlot: this.viewSlot\n };\n\n // viewport will be a thin wrapper around composition engine\n // to process instruction/configuration from users\n // preparing all information related to a composition process\n // first by getting view strategy of a ViewPortComponent View\n const viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);\n if (viewStrategy && component.view) {\n viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);\n }\n\n // using metadata of a custom element view model to load appropriate view-factory instance\n return metadata\n .load(childContainer, viewModelResource.value, null, viewStrategy, true)\n // for custom element, viewFactory typing is always ViewFactory\n // for custom attribute, it will be HtmlBehaviorResource\n .then((viewFactory: ViewFactory | HtmlBehaviorResource) => {\n // if this is not the first time that this is composing its instruction\n // try to capture ownership of the composition transaction\n // child will not be able to capture, since root typically captures\n // the ownership token\n if (!this.compositionTransactionNotifier) {\n this.compositionTransactionOwnershipToken = this.compositionTransaction.tryCapture();\n }\n\n if (layoutInstruction.viewModel || layoutInstruction.view) {\n viewPortInstruction.layoutInstruction = layoutInstruction;\n }\n\n const viewPortComponentBehaviorInstruction = BehaviorInstruction.dynamic(\n this.element,\n viewModel,\n viewFactory as ViewFactory\n );\n viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);\n\n if (waitToSwap) {\n return null;\n }\n\n this.swap(viewPortInstruction);\n });\n }\n\n swap($viewPortInstruction: any): void | Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction: IRouterViewViewPortInstruction = $viewPortInstruction;\n const viewPortController = viewPortInstruction.controller;\n const layoutInstruction = viewPortInstruction.layoutInstruction;\n const previousView = this.view;\n\n // Final step of swapping a ViewPortComponent\n const work = () => {\n const swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;\n const viewSlot = this.viewSlot;\n\n swapStrategy(\n viewSlot,\n previousView,\n () => Promise.resolve(viewSlot.add(this.view))\n ).then(() => {\n this._notify();\n });\n };\n\n // Ensure all users setups have been completed\n const ready = (owningView_or_layoutView: View) => {\n viewPortController.automate(this.overrideContext, owningView_or_layoutView);\n const transactionOwnerShipToken = this.compositionTransactionOwnershipToken;\n // if this router-view is the root of a normal startup via aurelia.setRoot\n // attemp to take control of the transaction\n\n // if ownership can be taken\n // wait for transaction to complete before swapping\n if (transactionOwnerShipToken) {\n return transactionOwnerShipToken\n .waitForCompositionComplete()\n .then(() => {\n this.compositionTransactionOwnershipToken = null;\n return work();\n });\n }\n\n // otherwise, just swap\n return work();\n };\n\n // If there is layout instruction, new to compose layout before processing ViewPortComponent\n // layout controller/view/view-model is composed using composition engine APIs\n if (layoutInstruction) {\n if (!layoutInstruction.viewModel) {\n // createController chokes if there's no viewmodel, so create a dummy one\n // but avoid using a POJO as it creates unwanted metadata in Object constructor\n layoutInstruction.viewModel = new EmptyLayoutViewModel();\n }\n\n // using composition engine to create compose layout\n return this.compositionEngine\n // first create controller from layoutInstruction\n // and treat it as CompositionContext\n // then emulate slot projection with ViewPortComponent view\n .createController(layoutInstruction as CompositionContext)\n .then((layoutController: Controller) => {\n const layoutView = layoutController.view;\n ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);\n // when there is a layout\n // view hierarchy is: owner view -> layout view -> ViewPortComponent view\n layoutController.automate(createOverrideContext(layoutInstruction.viewModel), this.owningView);\n layoutView.children.push(viewPortController.view);\n return layoutView || layoutController;\n })\n .then((newView: View | Controller) => {\n this.view = newView as View;\n return ready(newView as View);\n });\n }\n\n // if there is no layout, then get ViewPortComponent view ready as view property\n // and process controller/swapping\n // when there is no layout\n // view hierarchy is: owner view -> ViewPortComponent view\n this.view = viewPortController.view;\n\n return ready(this.owningView);\n }\n\n /**\n * Notify composition transaction that this router has finished processing\n * Happens when this is the root router-view\n * @internal\n */\n _notify() {\n const notifier = this.compositionTransactionNotifier;\n if (notifier) {\n notifier.done();\n this.compositionTransactionNotifier = null;\n }\n }\n}\n\n/**\n* Locator which finds the nearest RouterView, relative to the current dependency injection container.\n*/\nexport class RouterViewLocator {\n\n /*@internal */\n promise: Promise;\n\n /*@internal */\n resolve: (val?: any) => void;\n\n /**\n * Creates an instance of the RouterViewLocator class.\n */\n constructor() {\n this.promise = new Promise((resolve) => this.resolve = resolve);\n }\n\n /**\n * Finds the nearest RouterView instance.\n * @returns A promise that will be resolved with the located RouterView instance.\n */\n findNearest(): Promise {\n return this.promise;\n }\n\n /**@internal */\n _notify(routerView: RouterView): void {\n this.resolve(routerView);\n }\n}\n","import { Origin } from 'aurelia-metadata';\nimport { relativeToFile } from 'aurelia-path';\nimport { NavigationInstruction, RouteConfig, RouteLoader, Router } from 'aurelia-router';\nimport { CompositionEngine, customElement, inlineView, useView, CompositionContext } from 'aurelia-templating';\nimport { RouterViewLocator } from './router-view';\nimport { Container } from 'aurelia-dependency-injection';\n\n/**@internal exported for unit testing */\nexport class EmptyClass { }\ninlineView('')(EmptyClass);\n\n/**\n * Default implementation of `RouteLoader` used for loading component based on a route config\n */\nexport class TemplatingRouteLoader extends RouteLoader {\n\n /**@internal */\n static inject = [CompositionEngine];\n\n /**@internal */\n compositionEngine: CompositionEngine;\n\n constructor(\n compositionEngine: CompositionEngine\n ) {\n super();\n this.compositionEngine = compositionEngine;\n }\n\n /**\n * Resolve a view model from a RouteConfig\n * Throws when there is neither \"moduleId\" nor \"viewModel\" property\n * @internal\n */\n resolveViewModel(router: Router, config: RouteConfig): Promise {\n return new Promise((resolve, reject) => {\n let viewModel: string | null | Function;\n if ('moduleId' in config) {\n let moduleId = config.moduleId;\n if (moduleId === null) {\n viewModel = EmptyClass;\n } else {\n // this requires container of router has passes a certain point\n // where a view model has been setup on the container\n // it will fail in enhance scenario because no viewport has been registered\n moduleId = relativeToFile(moduleId, Origin.get(router.container.viewModel.constructor).moduleId);\n if (/\\.html/i.test(moduleId)) {\n viewModel = createDynamicClass(moduleId);\n } else {\n viewModel = moduleId;\n }\n }\n return resolve(viewModel);\n }\n // todo: add if ('viewModel' in config) to support static view model resolution\n reject(new Error('Invalid route config. No \"moduleId\" found.'));\n });\n }\n\n /**\n * Create child container based on a router container\n * Also ensures that child router are properly constructed in the newly created child container\n * @internal\n */\n createChildContainer(router: Router): Container {\n const childContainer = router.container.createChild();\n\n childContainer.registerSingleton(RouterViewLocator);\n childContainer.getChildRouter = function() {\n let childRouter: Router;\n\n childContainer.registerHandler(\n Router,\n () => childRouter || (childRouter = router.createChild(childContainer))\n );\n\n return childContainer.get(Router);\n };\n return childContainer;\n }\n\n /**\n * Load corresponding component of a route config of a navigation instruction\n */\n loadRoute(router: Router, config: RouteConfig, _navInstruction: NavigationInstruction): Promise {\n return this\n .resolveViewModel(router, config)\n .then(viewModel => this.compositionEngine.ensureViewModel({\n viewModel: viewModel,\n childContainer: this.createChildContainer(router),\n view: config.view || config.viewStrategy,\n router: router\n } as CompositionContext));\n }\n}\n\n/**@internal exported for unit testing */\nexport function createDynamicClass(moduleId: string) {\n const name = /([^\\/^\\?]+)\\.html/i.exec(moduleId)[1];\n\n class DynamicClass {\n\n $parent: any;\n\n bind(bindingContext: any) {\n this.$parent = bindingContext;\n }\n }\n\n customElement(name)(DynamicClass);\n useView(moduleId)(DynamicClass);\n\n return DynamicClass;\n}\n","import { IStaticResourceConfig } from 'aurelia-templating';\nimport { Router } from 'aurelia-router';\nimport { DOM } from 'aurelia-pal';\nimport * as LogManager from 'aurelia-logging';\n\nconst logger = LogManager.getLogger('route-href');\n\n/**\n * Helper custom attribute to help associate an element with a route by name\n */\nexport class RouteHref {\n\n /*@internal */\n static inject() {\n return [Router, DOM.Element];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n type: 'attribute',\n name: 'route-href',\n bindables: [\n { name: 'route', changeHandler: 'processChange', primaryProperty: true },\n { name: 'params', changeHandler: 'processChange' },\n 'attribute'\n ] as any // type definition of Aurelia templating is wrong\n };\n\n /**\n * Current router of this attribute\n */\n readonly router: Router;\n\n /**\n * Element this attribute is associated with\n */\n readonly element: Element;\n\n /**@internal */\n isActive: boolean;\n\n /**\n * Name of the route this attribute refers to. This name should exist in the current router hierarchy\n */\n route: string;\n\n /**\n * Parameters of this attribute to generate URL.\n */\n params: Record;\n\n /**\n * Target property on a custom element if this attribute is put on a custom element\n * OR an attribute if this attribute is put on a normal element\n */\n attribute: string;\n\n constructor(\n router: Router,\n element: Element\n ) {\n this.router = router;\n this.element = element;\n this.attribute = 'href';\n }\n\n bind() {\n this.isActive = true;\n this.processChange();\n }\n\n unbind() {\n this.isActive = false;\n }\n\n attributeChanged(value: any, previous: any) {\n if (previous) {\n this.element.removeAttribute(previous);\n }\n\n return this.processChange();\n }\n\n processChange() {\n return this.router\n .ensureConfigured()\n .then((): null => {\n if (!this.isActive) {\n // returning null to avoid Bluebird warning\n return null;\n }\n const element = this.element as Element & { au: any };\n\n const href = this.router.generate(this.route, this.params);\n\n if (element.au.controller) {\n element.au.controller.viewModel[this.attribute] = href;\n } else {\n element.setAttribute(this.attribute, href);\n }\n\n // returning null to avoid Bluebird warning\n return null;\n })\n .catch((reason: any) => {\n logger.error(reason);\n });\n }\n}\n\n","import { Router, AppRouter, RouteLoader } from 'aurelia-router';\nimport { TemplatingRouteLoader } from './route-loader';\nimport { RouterView } from './router-view';\nimport { RouteHref } from './route-href';\nimport { IFrameworkConfiguration } from './interfaces';\n\nexport function configure(config: IFrameworkConfiguration) {\n config\n .singleton(RouteLoader, TemplatingRouteLoader)\n .singleton(Router, AppRouter)\n .globalResources(\n RouterView,\n RouteHref\n );\n\n config.container.registerAlias(Router, AppRouter);\n}\n\nexport {\n TemplatingRouteLoader,\n RouterView,\n RouteHref\n};\n"],"names":["DOM","Container","ViewSlot","Router","ViewLocator","CompositionTransaction","CompositionEngine","Origin","BehaviorInstruction","SwapStrategies","ShadowDOM","createOverrideContext","inlineView","tslib_1.__extends","relativeToFile","RouteLoader","customElement","useView","LogManager.getLogger","AppRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;IAAA;KAEC;IAAD,2BAAC;CAAA,IAAA;;;;AAKD;IAsHE,oBACE,OAAgB,EAChB,SAAoB,EACpB,QAAkB,EAClB,MAAc,EACd,WAAwB,EACxB,sBAA8C,EAC9C,iBAAoC;QAEpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;;;;QAI3C,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;QAOtE,IAAI,EAAE,oBAAoB,IAAI,sBAAsB,CAAC,EAAE;YACr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G,KAAI,CAAC,OAAgC,CAAC;YAEtD,IAAM,IAAI,GAAG,KAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,MAAM,CAAC,CAAC;YAE3D,IAAI,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE;gBACzB,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,KAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;aACxD;iBAAM;gBACL,OAAO,CAAC,YAAY,CAAC,KAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;aAC5C;;YAGD,OAAO,IAAI,CAAC;SACb,CAAC;aACD,KAAK,CAAC,UAAC,MAAW;YACjB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACtB,CAAC,CAAC;KACN;;;;IAzFM,mBAAS,GAA0B;QACxC,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,YAAY;QAClB,SAAS,EAAE;YACT,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE;YACxE,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE;YAClD,WAAW;SACL;KACT,CAAC;IAkFJ,gBAAC;CApGD;;SCJgB,SAAS,CAAC,MAA+B;IACvD,MAAM;SACH,SAAS,CAACe,yBAAW,EAAE,qBAAqB,CAAC;SAC7C,SAAS,CAACZ,oBAAM,EAAEgB,uBAAS,CAAC;SAC5B,eAAe,CACd,UAAU,EACV,SAAS,CACV,CAAC;IAEJ,MAAM,CAAC,SAAS,CAAC,aAAa,CAAChB,oBAAM,EAAEgB,uBAAS,CAAC,CAAC;CACnD;;;;;;;"}
\ No newline at end of file
diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js
deleted file mode 100644
index ccc8952..0000000
--- a/dist/commonjs/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-var _aureliaTemplatingRouter = require('./aurelia-templating-router');
-
-Object.keys(_aureliaTemplatingRouter).forEach(function (key) {
- if (key === "default" || key === "__esModule") return;
- Object.defineProperty(exports, key, {
- enumerable: true,
- get: function get() {
- return _aureliaTemplatingRouter[key];
- }
- });
-});
\ No newline at end of file
diff --git a/dist/commonjs/route-href.js b/dist/commonjs/route-href.js
deleted file mode 100644
index 26f4cc7..0000000
--- a/dist/commonjs/route-href.js
+++ /dev/null
@@ -1,78 +0,0 @@
-'use strict';
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.RouteHref = undefined;
-
-var _dec, _dec2, _dec3, _dec4, _class;
-
-var _aureliaTemplating = require('aurelia-templating');
-
-var _aureliaRouter = require('aurelia-router');
-
-var _aureliaPal = require('aurelia-pal');
-
-var _aureliaLogging = require('aurelia-logging');
-
-var LogManager = _interopRequireWildcard(_aureliaLogging);
-
-function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
-
-
-var logger = LogManager.getLogger('route-href');
-
-var RouteHref = exports.RouteHref = (_dec = (0, _aureliaTemplating.customAttribute)('route-href'), _dec2 = (0, _aureliaTemplating.bindable)({ name: 'route', changeHandler: 'processChange', primaryProperty: true }), _dec3 = (0, _aureliaTemplating.bindable)({ name: 'params', changeHandler: 'processChange' }), _dec4 = (0, _aureliaTemplating.bindable)({ name: 'attribute', defaultValue: 'href' }), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = function () {
- RouteHref.inject = function inject() {
- return [_aureliaRouter.Router, _aureliaPal.DOM.Element];
- };
-
- function RouteHref(router, element) {
-
-
- this.router = router;
- this.element = element;
- }
-
- RouteHref.prototype.bind = function bind() {
- this.isActive = true;
- this.processChange();
- };
-
- RouteHref.prototype.unbind = function unbind() {
- this.isActive = false;
- };
-
- RouteHref.prototype.attributeChanged = function attributeChanged(value, previous) {
- if (previous) {
- this.element.removeAttribute(previous);
- }
-
- this.processChange();
- };
-
- RouteHref.prototype.processChange = function processChange() {
- var _this = this;
-
- return this.router.ensureConfigured().then(function () {
- if (!_this.isActive) {
- return null;
- }
-
- var href = _this.router.generate(_this.route, _this.params);
-
- if (_this.element.au.controller) {
- _this.element.au.controller.viewModel[_this.attribute] = href;
- } else {
- _this.element.setAttribute(_this.attribute, href);
- }
-
- return null;
- }).catch(function (reason) {
- logger.error(reason);
- });
- };
-
- return RouteHref;
-}()) || _class) || _class) || _class) || _class);
\ No newline at end of file
diff --git a/dist/commonjs/route-loader.js b/dist/commonjs/route-loader.js
deleted file mode 100644
index 7d72694..0000000
--- a/dist/commonjs/route-loader.js
+++ /dev/null
@@ -1,100 +0,0 @@
-'use strict';
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.TemplatingRouteLoader = undefined;
-
-var _dec, _class, _dec2, _class2;
-
-var _aureliaDependencyInjection = require('aurelia-dependency-injection');
-
-var _aureliaTemplating = require('aurelia-templating');
-
-var _aureliaRouter = require('aurelia-router');
-
-var _aureliaPath = require('aurelia-path');
-
-var _aureliaMetadata = require('aurelia-metadata');
-
-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; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-var EmptyClass = (_dec = (0, _aureliaTemplating.inlineView)(''), _dec(_class = function EmptyClass() {
-
-}) || _class);
-var TemplatingRouteLoader = exports.TemplatingRouteLoader = (_dec2 = (0, _aureliaDependencyInjection.inject)(_aureliaTemplating.CompositionEngine), _dec2(_class2 = function (_RouteLoader) {
- _inherits(TemplatingRouteLoader, _RouteLoader);
-
- function TemplatingRouteLoader(compositionEngine) {
-
-
- var _this = _possibleConstructorReturn(this, _RouteLoader.call(this));
-
- _this.compositionEngine = compositionEngine;
- return _this;
- }
-
- TemplatingRouteLoader.prototype.loadRoute = function loadRoute(router, config) {
- var childContainer = router.container.createChild();
-
- var viewModel = void 0;
- if (config.moduleId === null) {
- viewModel = EmptyClass;
- } else if (/\.html/i.test(config.moduleId)) {
- viewModel = createDynamicClass(config.moduleId);
- } else {
- viewModel = (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
- }
-
- var instruction = {
- viewModel: viewModel,
- childContainer: childContainer,
- view: config.view || config.viewStrategy,
- router: router
- };
-
- childContainer.registerSingleton(_routerView.RouterViewLocator);
-
- childContainer.getChildRouter = function () {
- var childRouter = void 0;
-
- childContainer.registerHandler(_aureliaRouter.Router, function (c) {
- return childRouter || (childRouter = router.createChild(childContainer));
- });
-
- return childContainer.get(_aureliaRouter.Router);
- };
-
- return this.compositionEngine.ensureViewModel(instruction);
- };
-
- return TemplatingRouteLoader;
-}(_aureliaRouter.RouteLoader)) || _class2);
-
-
-function createDynamicClass(moduleId) {
- var _dec3, _dec4, _class3;
-
- var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
-
- var DynamicClass = (_dec3 = (0, _aureliaTemplating.customElement)(name), _dec4 = (0, _aureliaTemplating.useView)(moduleId), _dec3(_class3 = _dec4(_class3 = function () {
- function DynamicClass() {
-
- }
-
- DynamicClass.prototype.bind = function bind(bindingContext) {
- this.$parent = bindingContext;
- };
-
- return DynamicClass;
- }()) || _class3) || _class3);
-
-
- return DynamicClass;
-}
\ No newline at end of file
diff --git a/dist/commonjs/router-view.js b/dist/commonjs/router-view.js
deleted file mode 100644
index 3975863..0000000
--- a/dist/commonjs/router-view.js
+++ /dev/null
@@ -1,245 +0,0 @@
-'use strict';
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.RouterViewLocator = exports.RouterView = undefined;
-
-var _dec, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
-
-var _aureliaDependencyInjection = require('aurelia-dependency-injection');
-
-var _aureliaBinding = require('aurelia-binding');
-
-var _aureliaTemplating = require('aurelia-templating');
-
-var _aureliaRouter = require('aurelia-router');
-
-var _aureliaMetadata = require('aurelia-metadata');
-
-var _aureliaPal = require('aurelia-pal');
-
-function _initDefineProp(target, property, descriptor, context) {
- if (!descriptor) return;
- Object.defineProperty(target, property, {
- enumerable: descriptor.enumerable,
- configurable: descriptor.configurable,
- writable: descriptor.writable,
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
- });
-}
-
-
-
-function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
- var desc = {};
- Object['ke' + 'ys'](descriptor).forEach(function (key) {
- desc[key] = descriptor[key];
- });
- desc.enumerable = !!desc.enumerable;
- desc.configurable = !!desc.configurable;
-
- if ('value' in desc || desc.initializer) {
- desc.writable = true;
- }
-
- desc = decorators.slice().reverse().reduce(function (desc, decorator) {
- return decorator(target, property, desc) || desc;
- }, desc);
-
- if (context && desc.initializer !== void 0) {
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
- desc.initializer = undefined;
- }
-
- if (desc.initializer === void 0) {
- Object['define' + 'Property'](target, property, desc);
- desc = null;
- }
-
- return desc;
-}
-
-function _initializerWarningHelper(descriptor, context) {
- throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
-}
-
-var RouterView = exports.RouterView = (_dec = (0, _aureliaTemplating.customElement)('router-view'), _dec(_class = (0, _aureliaTemplating.noView)(_class = (_class2 = function () {
- RouterView.inject = function inject() {
- return [_aureliaPal.DOM.Element, _aureliaDependencyInjection.Container, _aureliaTemplating.ViewSlot, _aureliaRouter.Router, _aureliaTemplating.ViewLocator, _aureliaTemplating.CompositionTransaction, _aureliaTemplating.CompositionEngine];
- };
-
- function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
-
-
- _initDefineProp(this, 'swapOrder', _descriptor, this);
-
- _initDefineProp(this, 'layoutView', _descriptor2, this);
-
- _initDefineProp(this, 'layoutViewModel', _descriptor3, this);
-
- _initDefineProp(this, 'layoutModel', _descriptor4, this);
-
- this.element = element;
- this.container = container;
- this.viewSlot = viewSlot;
- this.router = router;
- this.viewLocator = viewLocator;
- this.compositionTransaction = compositionTransaction;
- this.compositionEngine = compositionEngine;
- this.router.registerViewPort(this, this.element.getAttribute('name'));
-
- if (!('initialComposition' in compositionTransaction)) {
- compositionTransaction.initialComposition = true;
- this.compositionTransactionNotifier = compositionTransaction.enlist();
- }
- }
-
- RouterView.prototype.created = function created(owningView) {
- this.owningView = owningView;
- };
-
- RouterView.prototype.bind = function bind(bindingContext, overrideContext) {
- this.container.viewModel = bindingContext;
- this.overrideContext = overrideContext;
- };
-
- RouterView.prototype.process = function process(viewPortInstruction, waitToSwap) {
- var _this = this;
-
- var component = viewPortInstruction.component;
- var childContainer = component.childContainer;
- var viewModel = component.viewModel;
- var viewModelResource = component.viewModelResource;
- var metadata = viewModelResource.metadata;
- var config = component.router.currentInstruction.config;
- var viewPort = config.viewPorts ? config.viewPorts[viewPortInstruction.name] || {} : {};
-
- childContainer.get(RouterViewLocator)._notify(this);
-
- var layoutInstruction = {
- viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
- view: viewPort.layoutView || config.layoutView || this.layoutView,
- model: viewPort.layoutModel || config.layoutModel || this.layoutModel,
- router: viewPortInstruction.component.router,
- childContainer: childContainer,
- viewSlot: this.viewSlot
- };
-
- var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
- if (viewStrategy && component.view) {
- viewStrategy.makeRelativeTo(_aureliaMetadata.Origin.get(component.router.container.viewModel.constructor).moduleId);
- }
-
- return metadata.load(childContainer, viewModelResource.value, null, viewStrategy, true).then(function (viewFactory) {
- if (!_this.compositionTransactionNotifier) {
- _this.compositionTransactionOwnershipToken = _this.compositionTransaction.tryCapture();
- }
-
- if (layoutInstruction.viewModel || layoutInstruction.view) {
- viewPortInstruction.layoutInstruction = layoutInstruction;
- }
-
- viewPortInstruction.controller = metadata.create(childContainer, _aureliaTemplating.BehaviorInstruction.dynamic(_this.element, viewModel, viewFactory));
-
- if (waitToSwap) {
- return null;
- }
-
- _this.swap(viewPortInstruction);
- });
- };
-
- RouterView.prototype.swap = function swap(viewPortInstruction) {
- var _this2 = this;
-
- var layoutInstruction = viewPortInstruction.layoutInstruction;
- var previousView = this.view;
-
- var work = function work() {
- var swapStrategy = _aureliaTemplating.SwapStrategies[_this2.swapOrder] || _aureliaTemplating.SwapStrategies.after;
- var viewSlot = _this2.viewSlot;
-
- swapStrategy(viewSlot, previousView, function () {
- return Promise.resolve(viewSlot.add(_this2.view));
- }).then(function () {
- _this2._notify();
- });
- };
-
- var ready = function ready(owningView) {
- viewPortInstruction.controller.automate(_this2.overrideContext, owningView);
- if (_this2.compositionTransactionOwnershipToken) {
- return _this2.compositionTransactionOwnershipToken.waitForCompositionComplete().then(function () {
- _this2.compositionTransactionOwnershipToken = null;
- return work();
- });
- }
-
- return work();
- };
-
- if (layoutInstruction) {
- if (!layoutInstruction.viewModel) {
- layoutInstruction.viewModel = {};
- }
-
- return this.compositionEngine.createController(layoutInstruction).then(function (controller) {
- _aureliaTemplating.ShadowDOM.distributeView(viewPortInstruction.controller.view, controller.slots || controller.view.slots);
- controller.automate((0, _aureliaBinding.createOverrideContext)(layoutInstruction.viewModel), _this2.owningView);
- controller.view.children.push(viewPortInstruction.controller.view);
- return controller.view || controller;
- }).then(function (newView) {
- _this2.view = newView;
- return ready(newView);
- });
- }
-
- this.view = viewPortInstruction.controller.view;
-
- return ready(this.owningView);
- };
-
- RouterView.prototype._notify = function _notify() {
- if (this.compositionTransactionNotifier) {
- this.compositionTransactionNotifier.done();
- this.compositionTransactionNotifier = null;
- }
- };
-
- return RouterView;
-}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'swapOrder', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'layoutView', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'layoutViewModel', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'layoutModel', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-})), _class2)) || _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;
-}();
\ No newline at end of file
diff --git a/dist/es2015/aurelia-templating-router.js b/dist/es2015/aurelia-templating-router.js
index 22444ed..c59d7be 100644
--- a/dist/es2015/aurelia-templating-router.js
+++ b/dist/es2015/aurelia-templating-router.js
@@ -1,12 +1,384 @@
-import { Router, AppRouter, RouteLoader } from 'aurelia-router';
-import { TemplatingRouteLoader } from './route-loader';
-import { RouterView } from './router-view';
-import { RouteHref } from './route-href';
+import { Router, RouteLoader, AppRouter } from 'aurelia-router';
+import { Origin } from 'aurelia-metadata';
+import { relativeToFile } from 'aurelia-path';
+import { ViewSlot, ViewLocator, CompositionTransaction, CompositionEngine, BehaviorInstruction, ShadowDOM, SwapStrategies, inlineView, customElement, useView } from 'aurelia-templating';
+import { Container } from 'aurelia-dependency-injection';
+import { createOverrideContext } from 'aurelia-binding';
+import { DOM } from 'aurelia-pal';
+import { getLogger } from 'aurelia-logging';
-function configure(config) {
- config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources(RouterView, RouteHref);
+class EmptyLayoutViewModel {
+}
+/**
+ * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views
+ */
+class RouterView {
+ constructor(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
+ this.element = element;
+ this.container = container;
+ this.viewSlot = viewSlot;
+ this.router = router;
+ this.viewLocator = viewLocator;
+ this.compositionTransaction = compositionTransaction;
+ this.compositionEngine = compositionEngine;
+ // add this to router view ports lookup based on name attribute
+ // when this router is the root router-view
+ // also trigger AppRouter registerViewPort extra flow
+ this.router.registerViewPort(this, this.element.getAttribute('name'));
+ // Each process its instruction as a composition transaction
+ // there are differences between intial composition and subsequent compositions
+ // also there are differences between root composition and child composition
+ // mark the first composition transaction with a property initialComposition to distinguish it
+ // when the root gets new instruction for the first time
+ if (!('initialComposition' in compositionTransaction)) {
+ compositionTransaction.initialComposition = true;
+ this.compositionTransactionNotifier = compositionTransaction.enlist();
+ }
+ }
+ /**@internal */
+ static inject() {
+ return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];
+ }
+ created(owningView) {
+ this.owningView = owningView;
+ }
+ bind(bindingContext, overrideContext) {
+ // router needs to get access to view model of current route parent
+ // doing it in generic way via viewModel property on container
+ this.container.viewModel = bindingContext;
+ this.overrideContext = overrideContext;
+ }
+ /**
+ * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline
+ */
+ process($viewPortInstruction, waitToSwap) {
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ const viewPortInstruction = $viewPortInstruction;
+ const component = viewPortInstruction.component;
+ const childContainer = component.childContainer;
+ const viewModel = component.viewModel;
+ const viewModelResource = component.viewModelResource;
+ const metadata = viewModelResource.metadata;
+ const config = component.router.currentInstruction.config;
+ const viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};
+ childContainer.get(RouterViewLocator)._notify(this);
+ // layoutInstruction is our layout viewModel
+ const layoutInstruction = {
+ viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
+ view: viewPortConfig.layoutView || config.layoutView || this.layoutView,
+ model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,
+ router: viewPortInstruction.component.router,
+ childContainer: childContainer,
+ viewSlot: this.viewSlot
+ };
+ // viewport will be a thin wrapper around composition engine
+ // to process instruction/configuration from users
+ // preparing all information related to a composition process
+ // first by getting view strategy of a ViewPortComponent View
+ const viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
+ if (viewStrategy && component.view) {
+ viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);
+ }
+ // using metadata of a custom element view model to load appropriate view-factory instance
+ return metadata
+ .load(childContainer, viewModelResource.value, null, viewStrategy, true)
+ // for custom element, viewFactory typing is always ViewFactory
+ // for custom attribute, it will be HtmlBehaviorResource
+ .then((viewFactory) => {
+ // if this is not the first time that this is composing its instruction
+ // try to capture ownership of the composition transaction
+ // child will not be able to capture, since root typically captures
+ // the ownership token
+ if (!this.compositionTransactionNotifier) {
+ this.compositionTransactionOwnershipToken = this.compositionTransaction.tryCapture();
+ }
+ if (layoutInstruction.viewModel || layoutInstruction.view) {
+ viewPortInstruction.layoutInstruction = layoutInstruction;
+ }
+ const viewPortComponentBehaviorInstruction = BehaviorInstruction.dynamic(this.element, viewModel, viewFactory);
+ viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);
+ if (waitToSwap) {
+ return null;
+ }
+ this.swap(viewPortInstruction);
+ });
+ }
+ swap($viewPortInstruction) {
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ const viewPortInstruction = $viewPortInstruction;
+ const viewPortController = viewPortInstruction.controller;
+ const layoutInstruction = viewPortInstruction.layoutInstruction;
+ const previousView = this.view;
+ // Final step of swapping a ViewPortComponent
+ const work = () => {
+ const swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;
+ const viewSlot = this.viewSlot;
+ swapStrategy(viewSlot, previousView, () => Promise.resolve(viewSlot.add(this.view))).then(() => {
+ this._notify();
+ });
+ };
+ // Ensure all users setups have been completed
+ const ready = (owningView_or_layoutView) => {
+ viewPortController.automate(this.overrideContext, owningView_or_layoutView);
+ const transactionOwnerShipToken = this.compositionTransactionOwnershipToken;
+ // if this router-view is the root of a normal startup via aurelia.setRoot
+ // attemp to take control of the transaction
+ // if ownership can be taken
+ // wait for transaction to complete before swapping
+ if (transactionOwnerShipToken) {
+ return transactionOwnerShipToken
+ .waitForCompositionComplete()
+ .then(() => {
+ this.compositionTransactionOwnershipToken = null;
+ return work();
+ });
+ }
+ // otherwise, just swap
+ return work();
+ };
+ // If there is layout instruction, new to compose layout before processing ViewPortComponent
+ // layout controller/view/view-model is composed using composition engine APIs
+ if (layoutInstruction) {
+ if (!layoutInstruction.viewModel) {
+ // createController chokes if there's no viewmodel, so create a dummy one
+ // but avoid using a POJO as it creates unwanted metadata in Object constructor
+ layoutInstruction.viewModel = new EmptyLayoutViewModel();
+ }
+ // using composition engine to create compose layout
+ return this.compositionEngine
+ // first create controller from layoutInstruction
+ // and treat it as CompositionContext
+ // then emulate slot projection with ViewPortComponent view
+ .createController(layoutInstruction)
+ .then((layoutController) => {
+ const layoutView = layoutController.view;
+ ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);
+ // when there is a layout
+ // view hierarchy is: owner view -> layout view -> ViewPortComponent view
+ layoutController.automate(createOverrideContext(layoutInstruction.viewModel), this.owningView);
+ layoutView.children.push(viewPortController.view);
+ return layoutView || layoutController;
+ })
+ .then((newView) => {
+ this.view = newView;
+ return ready(newView);
+ });
+ }
+ // if there is no layout, then get ViewPortComponent view ready as view property
+ // and process controller/swapping
+ // when there is no layout
+ // view hierarchy is: owner view -> ViewPortComponent view
+ this.view = viewPortController.view;
+ return ready(this.owningView);
+ }
+ /**
+ * Notify composition transaction that this router has finished processing
+ * Happens when this is the root router-view
+ * @internal
+ */
+ _notify() {
+ const notifier = this.compositionTransactionNotifier;
+ if (notifier) {
+ notifier.done();
+ this.compositionTransactionNotifier = null;
+ }
+ }
+}
+/**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ *
+ * There is no view to compose by default in a router view
+ * This custom element is responsible for composing its own view, based on current config
+ */
+RouterView.$view = null;
+/**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+RouterView.$resource = {
+ name: 'router-view',
+ bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context']
+};
+/**
+* Locator which finds the nearest RouterView, relative to the current dependency injection container.
+*/
+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() {
+ return this.promise;
+ }
+ /**@internal */
+ _notify(routerView) {
+ this.resolve(routerView);
+ }
+}
+
+/**@internal exported for unit testing */
+class EmptyClass {
+}
+inlineView('')(EmptyClass);
+/**
+ * Default implementation of `RouteLoader` used for loading component based on a route config
+ */
+class TemplatingRouteLoader extends RouteLoader {
+ constructor(compositionEngine) {
+ super();
+ this.compositionEngine = compositionEngine;
+ }
+ /**
+ * Resolve a view model from a RouteConfig
+ * Throws when there is neither "moduleId" nor "viewModel" property
+ * @internal
+ */
+ resolveViewModel(router, config) {
+ return new Promise((resolve, reject) => {
+ let viewModel;
+ if ('moduleId' in config) {
+ let moduleId = config.moduleId;
+ if (moduleId === null) {
+ viewModel = EmptyClass;
+ }
+ else {
+ // this requires container of router has passes a certain point
+ // where a view model has been setup on the container
+ // it will fail in enhance scenario because no viewport has been registered
+ moduleId = relativeToFile(moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
+ if (/\.html/i.test(moduleId)) {
+ viewModel = createDynamicClass(moduleId);
+ }
+ else {
+ viewModel = moduleId;
+ }
+ }
+ return resolve(viewModel);
+ }
+ // todo: add if ('viewModel' in config) to support static view model resolution
+ reject(new Error('Invalid route config. No "moduleId" found.'));
+ });
+ }
+ /**
+ * Create child container based on a router container
+ * Also ensures that child router are properly constructed in the newly created child container
+ * @internal
+ */
+ createChildContainer(router) {
+ const childContainer = router.container.createChild();
+ childContainer.registerSingleton(RouterViewLocator);
+ childContainer.getChildRouter = function () {
+ let childRouter;
+ childContainer.registerHandler(Router, () => childRouter || (childRouter = router.createChild(childContainer)));
+ return childContainer.get(Router);
+ };
+ return childContainer;
+ }
+ /**
+ * Load corresponding component of a route config of a navigation instruction
+ */
+ loadRoute(router, config, _navInstruction) {
+ return this
+ .resolveViewModel(router, config)
+ .then(viewModel => this.compositionEngine.ensureViewModel({
+ viewModel: viewModel,
+ childContainer: this.createChildContainer(router),
+ view: config.view || config.viewStrategy,
+ router: router
+ }));
+ }
+}
+/**@internal */
+TemplatingRouteLoader.inject = [CompositionEngine];
+/**@internal exported for unit testing */
+function createDynamicClass(moduleId) {
+ const name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
+ class DynamicClass {
+ bind(bindingContext) {
+ this.$parent = bindingContext;
+ }
+ }
+ customElement(name)(DynamicClass);
+ useView(moduleId)(DynamicClass);
+ return DynamicClass;
+}
+
+const logger = getLogger('route-href');
+/**
+ * Helper custom attribute to help associate an element with a route by name
+ */
+class RouteHref {
+ constructor(router, element) {
+ this.router = router;
+ this.element = element;
+ this.attribute = 'href';
+ }
+ /*@internal */
+ static inject() {
+ return [Router, DOM.Element];
+ }
+ bind() {
+ this.isActive = true;
+ this.processChange();
+ }
+ unbind() {
+ this.isActive = false;
+ }
+ attributeChanged(value, previous) {
+ if (previous) {
+ this.element.removeAttribute(previous);
+ }
+ return this.processChange();
+ }
+ processChange() {
+ return this.router
+ .ensureConfigured()
+ .then(() => {
+ if (!this.isActive) {
+ // returning null to avoid Bluebird warning
+ return null;
+ }
+ const element = this.element;
+ const href = this.router.generate(this.route, this.params);
+ if (element.au.controller) {
+ element.au.controller.viewModel[this.attribute] = href;
+ }
+ else {
+ element.setAttribute(this.attribute, href);
+ }
+ // returning null to avoid Bluebird warning
+ return null;
+ })
+ .catch((reason) => {
+ logger.error(reason);
+ });
+ }
+}
+/**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+RouteHref.$resource = {
+ type: 'attribute',
+ name: 'route-href',
+ bindables: [
+ { name: 'route', changeHandler: 'processChange', primaryProperty: true },
+ { name: 'params', changeHandler: 'processChange' },
+ 'attribute'
+ ] // type definition of Aurelia templating is wrong
+};
- config.container.registerAlias(Router, AppRouter);
+function configure(config) {
+ config
+ .singleton(RouteLoader, TemplatingRouteLoader)
+ .singleton(Router, AppRouter)
+ .globalResources(RouterView, RouteHref);
+ config.container.registerAlias(Router, AppRouter);
}
-export { TemplatingRouteLoader, RouterView, RouteHref, configure };
\ No newline at end of file
+export { RouteHref, RouterView, TemplatingRouteLoader, configure };
+//# sourceMappingURL=aurelia-templating-router.js.map
diff --git a/dist/es2015/aurelia-templating-router.js.map b/dist/es2015/aurelia-templating-router.js.map
new file mode 100644
index 0000000..da06252
--- /dev/null
+++ b/dist/es2015/aurelia-templating-router.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"aurelia-templating-router.js","sources":["../../src/router-view.ts","../../src/route-loader.ts","../../src/route-href.ts","../../src/aurelia-templating-router.ts"],"sourcesContent":["import { Container } from 'aurelia-dependency-injection';\nimport { createOverrideContext, OverrideContext } from 'aurelia-binding';\nimport {\n ViewSlot,\n ViewLocator,\n BehaviorInstruction,\n CompositionTransaction,\n CompositionEngine,\n ShadowDOM,\n SwapStrategies,\n ResourceDescription,\n HtmlBehaviorResource,\n CompositionTransactionNotifier,\n View,\n CompositionTransactionOwnershipToken,\n Controller,\n ViewFactory,\n CompositionContext,\n IStaticResourceConfig,\n IStaticViewConfig\n} from 'aurelia-templating';\nimport {\n Router\n} from 'aurelia-router';\nimport { Origin } from 'aurelia-metadata';\nimport { DOM } from 'aurelia-pal';\nimport { IRouterViewViewPortInstruction, Constructable } from './interfaces';\n\nclass EmptyLayoutViewModel {\n\n}\n\n/**\n * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views\n */\nexport class RouterView {\n\n /**@internal */\n static inject() {\n return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n *\n * There is no view to compose by default in a router view\n * This custom element is responsible for composing its own view, based on current config\n */\n static $view: IStaticViewConfig = null;\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n name: 'router-view',\n bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context'] as any\n };\n\n /**\n * Swapping order when going to a new route. By default, supports 3 value: before, after, with\n * - before = new in -> old out\n * - after = old out -> new in\n * - with = new in + old out\n *\n * These values are defined by swapStrategies export in aurelia-templating/ aurelia-framework\n * Can be extended there and used here\n */\n swapOrder?: string;\n\n /**\n * Layout view used for this router-view layout, if no layout-viewmodel specified\n */\n layoutView?: any;\n\n /**\n * Layout view model used as binding context for this router-view layout\n * Actual type would be {string | Constructable | object}\n */\n layoutViewModel?: any;\n\n /**\n * Layout model used to activate layout view model, if specified with `layoutViewModel`\n */\n layoutModel?: any;\n\n /**\n * Element associated with this custom element\n */\n readonly element: Element;\n\n /**\n * Current router associated with this \n */\n readonly router: Router;\n\n /**\n * Container at this level\n */\n container: Container;\n\n /**\n * @internal\n * the view slot for adding / removing Routing related views created dynamically\n */\n viewSlot: ViewSlot;\n\n /**\n * @internal\n * Used to mimic partially functionalities of CompositionEngine\n */\n viewLocator: ViewLocator;\n\n /**\n * @internal\n * View composed by the CompositionEngine, depends on layout / viewports/ moduleId / viewModel of routeconfig\n */\n view: View;\n\n /**\n * @internal\n * The view where this `` is placed in\n */\n owningView: View;\n\n /**\n * @internal\n * Composition Transaction of initial composition transaction, when this is created\n */\n compositionTransaction: CompositionTransaction;\n\n /**\n * @internal\n * CompositionEngine instance, responsible for composing view/view model during process changes phase of this \n */\n compositionEngine: CompositionEngine;\n\n /**\n * Composition transaction notifier instance. Created when this router-view composing its instruction\n * for the first time.\n * Null on 2nd time and after.\n * @internal\n */\n compositionTransactionNotifier: CompositionTransactionNotifier;\n\n /**\n * @internal\n */\n compositionTransactionOwnershipToken: CompositionTransactionOwnershipToken;\n\n /**\n * @internal\n */\n overrideContext: OverrideContext;\n\n constructor(\n element: Element,\n container: Container,\n viewSlot: ViewSlot,\n router: Router,\n viewLocator: ViewLocator,\n compositionTransaction: CompositionTransaction,\n compositionEngine: CompositionEngine\n ) {\n this.element = element;\n this.container = container;\n this.viewSlot = viewSlot;\n this.router = router;\n this.viewLocator = viewLocator;\n this.compositionTransaction = compositionTransaction;\n this.compositionEngine = compositionEngine;\n // add this to router view ports lookup based on name attribute\n // when this router is the root router-view\n // also trigger AppRouter registerViewPort extra flow\n this.router.registerViewPort(this, this.element.getAttribute('name'));\n\n // Each process its instruction as a composition transaction\n // there are differences between intial composition and subsequent compositions\n // also there are differences between root composition and child composition\n // mark the first composition transaction with a property initialComposition to distinguish it\n // when the root gets new instruction for the first time\n if (!('initialComposition' in compositionTransaction)) {\n compositionTransaction.initialComposition = true;\n this.compositionTransactionNotifier = compositionTransaction.enlist();\n }\n }\n\n created(owningView: View): void {\n this.owningView = owningView;\n }\n\n bind(bindingContext: any, overrideContext: OverrideContext): void {\n // router needs to get access to view model of current route parent\n // doing it in generic way via viewModel property on container\n this.container.viewModel = bindingContext;\n this.overrideContext = overrideContext;\n }\n\n /**\n * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline\n */\n process($viewPortInstruction: any, waitToSwap?: boolean): Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction = $viewPortInstruction as IRouterViewViewPortInstruction;\n const component = viewPortInstruction.component;\n const childContainer = component.childContainer;\n const viewModel = component.viewModel;\n const viewModelResource = component.viewModelResource as unknown as ResourceDescription;\n const metadata = viewModelResource.metadata;\n const config = component.router.currentInstruction.config;\n const viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};\n\n (childContainer.get(RouterViewLocator) as RouterViewLocator)._notify(this);\n\n // layoutInstruction is our layout viewModel\n const layoutInstruction = {\n viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,\n view: viewPortConfig.layoutView || config.layoutView || this.layoutView,\n model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,\n router: viewPortInstruction.component.router,\n childContainer: childContainer,\n viewSlot: this.viewSlot\n };\n\n // viewport will be a thin wrapper around composition engine\n // to process instruction/configuration from users\n // preparing all information related to a composition process\n // first by getting view strategy of a ViewPortComponent View\n const viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);\n if (viewStrategy && component.view) {\n viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);\n }\n\n // using metadata of a custom element view model to load appropriate view-factory instance\n return metadata\n .load(childContainer, viewModelResource.value, null, viewStrategy, true)\n // for custom element, viewFactory typing is always ViewFactory\n // for custom attribute, it will be HtmlBehaviorResource\n .then((viewFactory: ViewFactory | HtmlBehaviorResource) => {\n // if this is not the first time that this is composing its instruction\n // try to capture ownership of the composition transaction\n // child will not be able to capture, since root typically captures\n // the ownership token\n if (!this.compositionTransactionNotifier) {\n this.compositionTransactionOwnershipToken = this.compositionTransaction.tryCapture();\n }\n\n if (layoutInstruction.viewModel || layoutInstruction.view) {\n viewPortInstruction.layoutInstruction = layoutInstruction;\n }\n\n const viewPortComponentBehaviorInstruction = BehaviorInstruction.dynamic(\n this.element,\n viewModel,\n viewFactory as ViewFactory\n );\n viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);\n\n if (waitToSwap) {\n return null;\n }\n\n this.swap(viewPortInstruction);\n });\n }\n\n swap($viewPortInstruction: any): void | Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction: IRouterViewViewPortInstruction = $viewPortInstruction;\n const viewPortController = viewPortInstruction.controller;\n const layoutInstruction = viewPortInstruction.layoutInstruction;\n const previousView = this.view;\n\n // Final step of swapping a ViewPortComponent\n const work = () => {\n const swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;\n const viewSlot = this.viewSlot;\n\n swapStrategy(\n viewSlot,\n previousView,\n () => Promise.resolve(viewSlot.add(this.view))\n ).then(() => {\n this._notify();\n });\n };\n\n // Ensure all users setups have been completed\n const ready = (owningView_or_layoutView: View) => {\n viewPortController.automate(this.overrideContext, owningView_or_layoutView);\n const transactionOwnerShipToken = this.compositionTransactionOwnershipToken;\n // if this router-view is the root of a normal startup via aurelia.setRoot\n // attemp to take control of the transaction\n\n // if ownership can be taken\n // wait for transaction to complete before swapping\n if (transactionOwnerShipToken) {\n return transactionOwnerShipToken\n .waitForCompositionComplete()\n .then(() => {\n this.compositionTransactionOwnershipToken = null;\n return work();\n });\n }\n\n // otherwise, just swap\n return work();\n };\n\n // If there is layout instruction, new to compose layout before processing ViewPortComponent\n // layout controller/view/view-model is composed using composition engine APIs\n if (layoutInstruction) {\n if (!layoutInstruction.viewModel) {\n // createController chokes if there's no viewmodel, so create a dummy one\n // but avoid using a POJO as it creates unwanted metadata in Object constructor\n layoutInstruction.viewModel = new EmptyLayoutViewModel();\n }\n\n // using composition engine to create compose layout\n return this.compositionEngine\n // first create controller from layoutInstruction\n // and treat it as CompositionContext\n // then emulate slot projection with ViewPortComponent view\n .createController(layoutInstruction as CompositionContext)\n .then((layoutController: Controller) => {\n const layoutView = layoutController.view;\n ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);\n // when there is a layout\n // view hierarchy is: owner view -> layout view -> ViewPortComponent view\n layoutController.automate(createOverrideContext(layoutInstruction.viewModel), this.owningView);\n layoutView.children.push(viewPortController.view);\n return layoutView || layoutController;\n })\n .then((newView: View | Controller) => {\n this.view = newView as View;\n return ready(newView as View);\n });\n }\n\n // if there is no layout, then get ViewPortComponent view ready as view property\n // and process controller/swapping\n // when there is no layout\n // view hierarchy is: owner view -> ViewPortComponent view\n this.view = viewPortController.view;\n\n return ready(this.owningView);\n }\n\n /**\n * Notify composition transaction that this router has finished processing\n * Happens when this is the root router-view\n * @internal\n */\n _notify() {\n const notifier = this.compositionTransactionNotifier;\n if (notifier) {\n notifier.done();\n this.compositionTransactionNotifier = null;\n }\n }\n}\n\n/**\n* Locator which finds the nearest RouterView, relative to the current dependency injection container.\n*/\nexport class RouterViewLocator {\n\n /*@internal */\n promise: Promise;\n\n /*@internal */\n resolve: (val?: any) => void;\n\n /**\n * Creates an instance of the RouterViewLocator class.\n */\n constructor() {\n this.promise = new Promise((resolve) => this.resolve = resolve);\n }\n\n /**\n * Finds the nearest RouterView instance.\n * @returns A promise that will be resolved with the located RouterView instance.\n */\n findNearest(): Promise {\n return this.promise;\n }\n\n /**@internal */\n _notify(routerView: RouterView): void {\n this.resolve(routerView);\n }\n}\n","import { Origin } from 'aurelia-metadata';\nimport { relativeToFile } from 'aurelia-path';\nimport { NavigationInstruction, RouteConfig, RouteLoader, Router } from 'aurelia-router';\nimport { CompositionEngine, customElement, inlineView, useView, CompositionContext } from 'aurelia-templating';\nimport { RouterViewLocator } from './router-view';\nimport { Container } from 'aurelia-dependency-injection';\n\n/**@internal exported for unit testing */\nexport class EmptyClass { }\ninlineView('')(EmptyClass);\n\n/**\n * Default implementation of `RouteLoader` used for loading component based on a route config\n */\nexport class TemplatingRouteLoader extends RouteLoader {\n\n /**@internal */\n static inject = [CompositionEngine];\n\n /**@internal */\n compositionEngine: CompositionEngine;\n\n constructor(\n compositionEngine: CompositionEngine\n ) {\n super();\n this.compositionEngine = compositionEngine;\n }\n\n /**\n * Resolve a view model from a RouteConfig\n * Throws when there is neither \"moduleId\" nor \"viewModel\" property\n * @internal\n */\n resolveViewModel(router: Router, config: RouteConfig): Promise {\n return new Promise((resolve, reject) => {\n let viewModel: string | null | Function;\n if ('moduleId' in config) {\n let moduleId = config.moduleId;\n if (moduleId === null) {\n viewModel = EmptyClass;\n } else {\n // this requires container of router has passes a certain point\n // where a view model has been setup on the container\n // it will fail in enhance scenario because no viewport has been registered\n moduleId = relativeToFile(moduleId, Origin.get(router.container.viewModel.constructor).moduleId);\n if (/\\.html/i.test(moduleId)) {\n viewModel = createDynamicClass(moduleId);\n } else {\n viewModel = moduleId;\n }\n }\n return resolve(viewModel);\n }\n // todo: add if ('viewModel' in config) to support static view model resolution\n reject(new Error('Invalid route config. No \"moduleId\" found.'));\n });\n }\n\n /**\n * Create child container based on a router container\n * Also ensures that child router are properly constructed in the newly created child container\n * @internal\n */\n createChildContainer(router: Router): Container {\n const childContainer = router.container.createChild();\n\n childContainer.registerSingleton(RouterViewLocator);\n childContainer.getChildRouter = function() {\n let childRouter: Router;\n\n childContainer.registerHandler(\n Router,\n () => childRouter || (childRouter = router.createChild(childContainer))\n );\n\n return childContainer.get(Router);\n };\n return childContainer;\n }\n\n /**\n * Load corresponding component of a route config of a navigation instruction\n */\n loadRoute(router: Router, config: RouteConfig, _navInstruction: NavigationInstruction): Promise {\n return this\n .resolveViewModel(router, config)\n .then(viewModel => this.compositionEngine.ensureViewModel({\n viewModel: viewModel,\n childContainer: this.createChildContainer(router),\n view: config.view || config.viewStrategy,\n router: router\n } as CompositionContext));\n }\n}\n\n/**@internal exported for unit testing */\nexport function createDynamicClass(moduleId: string) {\n const name = /([^\\/^\\?]+)\\.html/i.exec(moduleId)[1];\n\n class DynamicClass {\n\n $parent: any;\n\n bind(bindingContext: any) {\n this.$parent = bindingContext;\n }\n }\n\n customElement(name)(DynamicClass);\n useView(moduleId)(DynamicClass);\n\n return DynamicClass;\n}\n","import { IStaticResourceConfig } from 'aurelia-templating';\nimport { Router } from 'aurelia-router';\nimport { DOM } from 'aurelia-pal';\nimport * as LogManager from 'aurelia-logging';\n\nconst logger = LogManager.getLogger('route-href');\n\n/**\n * Helper custom attribute to help associate an element with a route by name\n */\nexport class RouteHref {\n\n /*@internal */\n static inject() {\n return [Router, DOM.Element];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n type: 'attribute',\n name: 'route-href',\n bindables: [\n { name: 'route', changeHandler: 'processChange', primaryProperty: true },\n { name: 'params', changeHandler: 'processChange' },\n 'attribute'\n ] as any // type definition of Aurelia templating is wrong\n };\n\n /**\n * Current router of this attribute\n */\n readonly router: Router;\n\n /**\n * Element this attribute is associated with\n */\n readonly element: Element;\n\n /**@internal */\n isActive: boolean;\n\n /**\n * Name of the route this attribute refers to. This name should exist in the current router hierarchy\n */\n route: string;\n\n /**\n * Parameters of this attribute to generate URL.\n */\n params: Record;\n\n /**\n * Target property on a custom element if this attribute is put on a custom element\n * OR an attribute if this attribute is put on a normal element\n */\n attribute: string;\n\n constructor(\n router: Router,\n element: Element\n ) {\n this.router = router;\n this.element = element;\n this.attribute = 'href';\n }\n\n bind() {\n this.isActive = true;\n this.processChange();\n }\n\n unbind() {\n this.isActive = false;\n }\n\n attributeChanged(value: any, previous: any) {\n if (previous) {\n this.element.removeAttribute(previous);\n }\n\n return this.processChange();\n }\n\n processChange() {\n return this.router\n .ensureConfigured()\n .then((): null => {\n if (!this.isActive) {\n // returning null to avoid Bluebird warning\n return null;\n }\n const element = this.element as Element & { au: any };\n\n const href = this.router.generate(this.route, this.params);\n\n if (element.au.controller) {\n element.au.controller.viewModel[this.attribute] = href;\n } else {\n element.setAttribute(this.attribute, href);\n }\n\n // returning null to avoid Bluebird warning\n return null;\n })\n .catch((reason: any) => {\n logger.error(reason);\n });\n }\n}\n\n","import { Router, AppRouter, RouteLoader } from 'aurelia-router';\nimport { TemplatingRouteLoader } from './route-loader';\nimport { RouterView } from './router-view';\nimport { RouteHref } from './route-href';\nimport { IFrameworkConfiguration } from './interfaces';\n\nexport function configure(config: IFrameworkConfiguration) {\n config\n .singleton(RouteLoader, TemplatingRouteLoader)\n .singleton(Router, AppRouter)\n .globalResources(\n RouterView,\n RouteHref\n );\n\n config.container.registerAlias(Router, AppRouter);\n}\n\nexport {\n TemplatingRouteLoader,\n RouterView,\n RouteHref\n};\n"],"names":["LogManager.getLogger"],"mappings":";;;;;;;;;AA4BA,MAAM,oBAAoB;CAEzB;;;;AAKD,MAAa,UAAU;IAsHrB,YACE,OAAgB,EAChB,SAAoB,EACpB,QAAkB,EAClB,MAAc,EACd,WAAwB,EACxB,sBAA8C,EAC9C,iBAAoC;QAEpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;;;;QAI3C,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;QAOtE,IAAI,EAAE,oBAAoB,IAAI,sBAAsB,CAAC,EAAE;YACrD,sBAAsB,CAAC,kBAAkB,GAAG,IAAI,CAAC;YACjD,IAAI,CAAC,8BAA8B,GAAG,sBAAsB,CAAC,MAAM,EAAE,CAAC;SACvE;KACF;;IAjJD,OAAO,MAAM;QACX,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;KAC3G;IAiJD,OAAO,CAAC,UAAgB;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAC9B;IAED,IAAI,CAAC,cAAmB,EAAE,eAAgC;;;QAGxD,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC;QAC1C,IAA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,WAAW,EAAE,qBAAqB,CAAC;SAC7C,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;SAC5B,eAAe,CACd,UAAU,EACV,SAAS,CACV,CAAC;IAEJ,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnD;;;;"}
\ No newline at end of file
diff --git a/dist/es2015/index.js b/dist/es2015/index.js
deleted file mode 100644
index 64874f8..0000000
--- a/dist/es2015/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from './aurelia-templating-router';
\ No newline at end of file
diff --git a/dist/es2015/route-href.js b/dist/es2015/route-href.js
deleted file mode 100644
index 9f60873..0000000
--- a/dist/es2015/route-href.js
+++ /dev/null
@@ -1,57 +0,0 @@
-var _dec, _dec2, _dec3, _dec4, _class;
-
-import { customAttribute, bindable } from 'aurelia-templating';
-import { Router } from 'aurelia-router';
-import { DOM } from 'aurelia-pal';
-import * as LogManager from 'aurelia-logging';
-
-const logger = LogManager.getLogger('route-href');
-
-export let RouteHref = (_dec = customAttribute('route-href'), _dec2 = bindable({ name: 'route', changeHandler: 'processChange', primaryProperty: true }), _dec3 = bindable({ name: 'params', changeHandler: 'processChange' }), _dec4 = bindable({ name: 'attribute', defaultValue: 'href' }), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = class RouteHref {
-
- static inject() {
- return [Router, DOM.Element];
- }
-
- constructor(router, element) {
- this.router = router;
- this.element = element;
- }
-
- bind() {
- this.isActive = true;
- this.processChange();
- }
-
- unbind() {
- this.isActive = false;
- }
-
- attributeChanged(value, previous) {
- if (previous) {
- this.element.removeAttribute(previous);
- }
-
- this.processChange();
- }
-
- processChange() {
- return this.router.ensureConfigured().then(() => {
- if (!this.isActive) {
- return null;
- }
-
- let href = this.router.generate(this.route, this.params);
-
- if (this.element.au.controller) {
- this.element.au.controller.viewModel[this.attribute] = href;
- } else {
- this.element.setAttribute(this.attribute, href);
- }
-
- return null;
- }).catch(reason => {
- logger.error(reason);
- });
- }
-}) || _class) || _class) || _class) || _class);
\ No newline at end of file
diff --git a/dist/es2015/route-loader.js b/dist/es2015/route-loader.js
deleted file mode 100644
index bb163d1..0000000
--- a/dist/es2015/route-loader.js
+++ /dev/null
@@ -1,66 +0,0 @@
-var _dec, _class, _dec2, _class2;
-
-import { inject } from 'aurelia-dependency-injection';
-import { CompositionEngine, useView, inlineView, 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';
-
-let EmptyClass = (_dec = inlineView(''), _dec(_class = class EmptyClass {}) || _class);
-
-export let TemplatingRouteLoader = (_dec2 = inject(CompositionEngine), _dec2(_class2 = class TemplatingRouteLoader extends RouteLoader {
- constructor(compositionEngine) {
- super();
- this.compositionEngine = compositionEngine;
- }
-
- loadRoute(router, config) {
- let childContainer = router.container.createChild();
-
- let viewModel;
- if (config.moduleId === null) {
- viewModel = EmptyClass;
- } else if (/\.html/i.test(config.moduleId)) {
- viewModel = createDynamicClass(config.moduleId);
- } else {
- viewModel = relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
- }
-
- let instruction = {
- viewModel: viewModel,
- childContainer: childContainer,
- view: config.view || config.viewStrategy,
- router: router
- };
-
- childContainer.registerSingleton(RouterViewLocator);
-
- childContainer.getChildRouter = function () {
- let childRouter;
-
- childContainer.registerHandler(Router, c => {
- return childRouter || (childRouter = router.createChild(childContainer));
- });
-
- return childContainer.get(Router);
- };
-
- return this.compositionEngine.ensureViewModel(instruction);
- }
-}) || _class2);
-
-function createDynamicClass(moduleId) {
- var _dec3, _dec4, _class3;
-
- let name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
-
- let DynamicClass = (_dec3 = customElement(name), _dec4 = useView(moduleId), _dec3(_class3 = _dec4(_class3 = class DynamicClass {
- bind(bindingContext) {
- this.$parent = bindingContext;
- }
- }) || _class3) || _class3);
-
-
- return DynamicClass;
-}
\ No newline at end of file
diff --git a/dist/es2015/router-view.js b/dist/es2015/router-view.js
deleted file mode 100644
index e083321..0000000
--- a/dist/es2015/router-view.js
+++ /dev/null
@@ -1,216 +0,0 @@
-var _dec, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
-
-function _initDefineProp(target, property, descriptor, context) {
- if (!descriptor) return;
- Object.defineProperty(target, property, {
- enumerable: descriptor.enumerable,
- configurable: descriptor.configurable,
- writable: descriptor.writable,
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
- });
-}
-
-function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
- var desc = {};
- Object['ke' + 'ys'](descriptor).forEach(function (key) {
- desc[key] = descriptor[key];
- });
- desc.enumerable = !!desc.enumerable;
- desc.configurable = !!desc.configurable;
-
- if ('value' in desc || desc.initializer) {
- desc.writable = true;
- }
-
- desc = decorators.slice().reverse().reduce(function (desc, decorator) {
- return decorator(target, property, desc) || desc;
- }, desc);
-
- if (context && desc.initializer !== void 0) {
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
- desc.initializer = undefined;
- }
-
- if (desc.initializer === void 0) {
- Object['define' + 'Property'](target, property, desc);
- desc = null;
- }
-
- return desc;
-}
-
-function _initializerWarningHelper(descriptor, context) {
- throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
-}
-
-import { Container } from 'aurelia-dependency-injection';
-import { createOverrideContext } from 'aurelia-binding';
-import { ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, SwapStrategies } from 'aurelia-templating';
-import { Router } from 'aurelia-router';
-import { Origin } from 'aurelia-metadata';
-import { DOM } from 'aurelia-pal';
-
-export let RouterView = (_dec = customElement('router-view'), _dec(_class = noView(_class = (_class2 = class RouterView {
-
- static inject() {
- return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];
- }
-
- constructor(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
- _initDefineProp(this, 'swapOrder', _descriptor, this);
-
- _initDefineProp(this, 'layoutView', _descriptor2, this);
-
- _initDefineProp(this, 'layoutViewModel', _descriptor3, this);
-
- _initDefineProp(this, 'layoutModel', _descriptor4, this);
-
- this.element = element;
- this.container = container;
- this.viewSlot = viewSlot;
- this.router = router;
- this.viewLocator = viewLocator;
- this.compositionTransaction = compositionTransaction;
- this.compositionEngine = compositionEngine;
- this.router.registerViewPort(this, this.element.getAttribute('name'));
-
- if (!('initialComposition' in compositionTransaction)) {
- compositionTransaction.initialComposition = true;
- this.compositionTransactionNotifier = compositionTransaction.enlist();
- }
- }
-
- created(owningView) {
- this.owningView = owningView;
- }
-
- bind(bindingContext, overrideContext) {
- this.container.viewModel = bindingContext;
- this.overrideContext = overrideContext;
- }
-
- process(viewPortInstruction, waitToSwap) {
- let component = viewPortInstruction.component;
- let childContainer = component.childContainer;
- let viewModel = component.viewModel;
- let viewModelResource = component.viewModelResource;
- let metadata = viewModelResource.metadata;
- let config = component.router.currentInstruction.config;
- let viewPort = config.viewPorts ? config.viewPorts[viewPortInstruction.name] || {} : {};
-
- childContainer.get(RouterViewLocator)._notify(this);
-
- let layoutInstruction = {
- viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
- view: viewPort.layoutView || config.layoutView || this.layoutView,
- model: viewPort.layoutModel || config.layoutModel || this.layoutModel,
- router: viewPortInstruction.component.router,
- childContainer: childContainer,
- viewSlot: this.viewSlot
- };
-
- let viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
- if (viewStrategy && component.view) {
- viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);
- }
-
- return metadata.load(childContainer, viewModelResource.value, null, viewStrategy, true).then(viewFactory => {
- if (!this.compositionTransactionNotifier) {
- this.compositionTransactionOwnershipToken = this.compositionTransaction.tryCapture();
- }
-
- if (layoutInstruction.viewModel || layoutInstruction.view) {
- viewPortInstruction.layoutInstruction = layoutInstruction;
- }
-
- viewPortInstruction.controller = metadata.create(childContainer, BehaviorInstruction.dynamic(this.element, viewModel, viewFactory));
-
- if (waitToSwap) {
- return null;
- }
-
- this.swap(viewPortInstruction);
- });
- }
-
- swap(viewPortInstruction) {
- let layoutInstruction = viewPortInstruction.layoutInstruction;
- let previousView = this.view;
-
- let work = () => {
- let swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;
- let viewSlot = this.viewSlot;
-
- swapStrategy(viewSlot, previousView, () => {
- return Promise.resolve(viewSlot.add(this.view));
- }).then(() => {
- this._notify();
- });
- };
-
- let ready = owningView => {
- viewPortInstruction.controller.automate(this.overrideContext, owningView);
- if (this.compositionTransactionOwnershipToken) {
- return this.compositionTransactionOwnershipToken.waitForCompositionComplete().then(() => {
- this.compositionTransactionOwnershipToken = null;
- return work();
- });
- }
-
- return work();
- };
-
- if (layoutInstruction) {
- if (!layoutInstruction.viewModel) {
- layoutInstruction.viewModel = {};
- }
-
- return this.compositionEngine.createController(layoutInstruction).then(controller => {
- ShadowDOM.distributeView(viewPortInstruction.controller.view, controller.slots || controller.view.slots);
- controller.automate(createOverrideContext(layoutInstruction.viewModel), this.owningView);
- controller.view.children.push(viewPortInstruction.controller.view);
- return controller.view || controller;
- }).then(newView => {
- this.view = newView;
- return ready(newView);
- });
- }
-
- this.view = viewPortInstruction.controller.view;
-
- return ready(this.owningView);
- }
-
- _notify() {
- if (this.compositionTransactionNotifier) {
- this.compositionTransactionNotifier.done();
- this.compositionTransactionNotifier = null;
- }
- }
-}, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'swapOrder', [bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'layoutView', [bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'layoutViewModel', [bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'layoutModel', [bindable], {
- enumerable: true,
- initializer: null
-})), _class2)) || _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);
- }
-};
\ No newline at end of file
diff --git a/dist/native-modules/aurelia-templating-router.js b/dist/native-modules/aurelia-templating-router.js
index 22444ed..5287b95 100644
--- a/dist/native-modules/aurelia-templating-router.js
+++ b/dist/native-modules/aurelia-templating-router.js
@@ -1,12 +1,433 @@
-import { Router, AppRouter, RouteLoader } from 'aurelia-router';
-import { TemplatingRouteLoader } from './route-loader';
-import { RouterView } from './router-view';
-import { RouteHref } from './route-href';
+import { Router, RouteLoader, AppRouter } from 'aurelia-router';
+import { Origin } from 'aurelia-metadata';
+import { relativeToFile } from 'aurelia-path';
+import { BehaviorInstruction, ShadowDOM, ViewSlot, ViewLocator, CompositionTransaction, CompositionEngine, SwapStrategies, inlineView, customElement, useView } from 'aurelia-templating';
+import { Container } from 'aurelia-dependency-injection';
+import { createOverrideContext } from 'aurelia-binding';
+import { DOM } from 'aurelia-pal';
+import { getLogger } from 'aurelia-logging';
-function configure(config) {
- config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources(RouterView, RouteHref);
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+/* global Reflect, Promise */
+
+var extendStatics = function(d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+};
+
+function __extends(d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+}
+
+var EmptyLayoutViewModel = /** @class */ (function () {
+ function EmptyLayoutViewModel() {
+ }
+ return EmptyLayoutViewModel;
+}());
+/**
+ * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views
+ */
+var RouterView = /** @class */ (function () {
+ function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
+ this.element = element;
+ this.container = container;
+ this.viewSlot = viewSlot;
+ this.router = router;
+ this.viewLocator = viewLocator;
+ this.compositionTransaction = compositionTransaction;
+ this.compositionEngine = compositionEngine;
+ // add this to router view ports lookup based on name attribute
+ // when this router is the root router-view
+ // also trigger AppRouter registerViewPort extra flow
+ this.router.registerViewPort(this, this.element.getAttribute('name'));
+ // Each process its instruction as a composition transaction
+ // there are differences between intial composition and subsequent compositions
+ // also there are differences between root composition and child composition
+ // mark the first composition transaction with a property initialComposition to distinguish it
+ // when the root gets new instruction for the first time
+ if (!('initialComposition' in compositionTransaction)) {
+ compositionTransaction.initialComposition = true;
+ this.compositionTransactionNotifier = compositionTransaction.enlist();
+ }
+ }
+ /**@internal */
+ RouterView.inject = function () {
+ return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];
+ };
+ RouterView.prototype.created = function (owningView) {
+ this.owningView = owningView;
+ };
+ RouterView.prototype.bind = function (bindingContext, overrideContext) {
+ // router needs to get access to view model of current route parent
+ // doing it in generic way via viewModel property on container
+ this.container.viewModel = bindingContext;
+ this.overrideContext = overrideContext;
+ };
+ /**
+ * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline
+ */
+ RouterView.prototype.process = function ($viewPortInstruction, waitToSwap) {
+ var _this = this;
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ var viewPortInstruction = $viewPortInstruction;
+ var component = viewPortInstruction.component;
+ var childContainer = component.childContainer;
+ var viewModel = component.viewModel;
+ var viewModelResource = component.viewModelResource;
+ var metadata = viewModelResource.metadata;
+ var config = component.router.currentInstruction.config;
+ var viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};
+ childContainer.get(RouterViewLocator)._notify(this);
+ // layoutInstruction is our layout viewModel
+ var layoutInstruction = {
+ viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
+ view: viewPortConfig.layoutView || config.layoutView || this.layoutView,
+ model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,
+ router: viewPortInstruction.component.router,
+ childContainer: childContainer,
+ viewSlot: this.viewSlot
+ };
+ // viewport will be a thin wrapper around composition engine
+ // to process instruction/configuration from users
+ // preparing all information related to a composition process
+ // first by getting view strategy of a ViewPortComponent View
+ var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
+ if (viewStrategy && component.view) {
+ viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);
+ }
+ // using metadata of a custom element view model to load appropriate view-factory instance
+ return metadata
+ .load(childContainer, viewModelResource.value, null, viewStrategy, true)
+ // for custom element, viewFactory typing is always ViewFactory
+ // for custom attribute, it will be HtmlBehaviorResource
+ .then(function (viewFactory) {
+ // if this is not the first time that this is composing its instruction
+ // try to capture ownership of the composition transaction
+ // child will not be able to capture, since root typically captures
+ // the ownership token
+ if (!_this.compositionTransactionNotifier) {
+ _this.compositionTransactionOwnershipToken = _this.compositionTransaction.tryCapture();
+ }
+ if (layoutInstruction.viewModel || layoutInstruction.view) {
+ viewPortInstruction.layoutInstruction = layoutInstruction;
+ }
+ var viewPortComponentBehaviorInstruction = BehaviorInstruction.dynamic(_this.element, viewModel, viewFactory);
+ viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);
+ if (waitToSwap) {
+ return null;
+ }
+ _this.swap(viewPortInstruction);
+ });
+ };
+ RouterView.prototype.swap = function ($viewPortInstruction) {
+ var _this = this;
+ // have strong typings without exposing it in public typings, this is to ensure maximum backward compat
+ var viewPortInstruction = $viewPortInstruction;
+ var viewPortController = viewPortInstruction.controller;
+ var layoutInstruction = viewPortInstruction.layoutInstruction;
+ var previousView = this.view;
+ // Final step of swapping a ViewPortComponent
+ var work = function () {
+ var swapStrategy = SwapStrategies[_this.swapOrder] || SwapStrategies.after;
+ var viewSlot = _this.viewSlot;
+ swapStrategy(viewSlot, previousView, function () { return Promise.resolve(viewSlot.add(_this.view)); }).then(function () {
+ _this._notify();
+ });
+ };
+ // Ensure all users setups have been completed
+ var ready = function (owningView_or_layoutView) {
+ viewPortController.automate(_this.overrideContext, owningView_or_layoutView);
+ var transactionOwnerShipToken = _this.compositionTransactionOwnershipToken;
+ // if this router-view is the root of a normal startup via aurelia.setRoot
+ // attemp to take control of the transaction
+ // if ownership can be taken
+ // wait for transaction to complete before swapping
+ if (transactionOwnerShipToken) {
+ return transactionOwnerShipToken
+ .waitForCompositionComplete()
+ .then(function () {
+ _this.compositionTransactionOwnershipToken = null;
+ return work();
+ });
+ }
+ // otherwise, just swap
+ return work();
+ };
+ // If there is layout instruction, new to compose layout before processing ViewPortComponent
+ // layout controller/view/view-model is composed using composition engine APIs
+ if (layoutInstruction) {
+ if (!layoutInstruction.viewModel) {
+ // createController chokes if there's no viewmodel, so create a dummy one
+ // but avoid using a POJO as it creates unwanted metadata in Object constructor
+ layoutInstruction.viewModel = new EmptyLayoutViewModel();
+ }
+ // using composition engine to create compose layout
+ return this.compositionEngine
+ // first create controller from layoutInstruction
+ // and treat it as CompositionContext
+ // then emulate slot projection with ViewPortComponent view
+ .createController(layoutInstruction)
+ .then(function (layoutController) {
+ var layoutView = layoutController.view;
+ ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);
+ // when there is a layout
+ // view hierarchy is: owner view -> layout view -> ViewPortComponent view
+ layoutController.automate(createOverrideContext(layoutInstruction.viewModel), _this.owningView);
+ layoutView.children.push(viewPortController.view);
+ return layoutView || layoutController;
+ })
+ .then(function (newView) {
+ _this.view = newView;
+ return ready(newView);
+ });
+ }
+ // if there is no layout, then get ViewPortComponent view ready as view property
+ // and process controller/swapping
+ // when there is no layout
+ // view hierarchy is: owner view -> ViewPortComponent view
+ this.view = viewPortController.view;
+ return ready(this.owningView);
+ };
+ /**
+ * Notify composition transaction that this router has finished processing
+ * Happens when this is the root router-view
+ * @internal
+ */
+ RouterView.prototype._notify = function () {
+ var notifier = this.compositionTransactionNotifier;
+ if (notifier) {
+ notifier.done();
+ this.compositionTransactionNotifier = null;
+ }
+ };
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ *
+ * There is no view to compose by default in a router view
+ * This custom element is responsible for composing its own view, based on current config
+ */
+ RouterView.$view = null;
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+ RouterView.$resource = {
+ name: 'router-view',
+ bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context']
+ };
+ return RouterView;
+}());
+/**
+* Locator which finds the nearest RouterView, relative to the current dependency injection container.
+*/
+var RouterViewLocator = /** @class */ (function () {
+ /**
+ * Creates an instance of the RouterViewLocator class.
+ */
+ function RouterViewLocator() {
+ var _this = this;
+ this.promise = new Promise(function (resolve) { return _this.resolve = resolve; });
+ }
+ /**
+ * Finds the nearest RouterView instance.
+ * @returns A promise that will be resolved with the located RouterView instance.
+ */
+ RouterViewLocator.prototype.findNearest = function () {
+ return this.promise;
+ };
+ /**@internal */
+ RouterViewLocator.prototype._notify = function (routerView) {
+ this.resolve(routerView);
+ };
+ return RouterViewLocator;
+}());
+
+/**@internal exported for unit testing */
+var EmptyClass = /** @class */ (function () {
+ function EmptyClass() {
+ }
+ return EmptyClass;
+}());
+inlineView('')(EmptyClass);
+/**
+ * Default implementation of `RouteLoader` used for loading component based on a route config
+ */
+var TemplatingRouteLoader = /** @class */ (function (_super) {
+ __extends(TemplatingRouteLoader, _super);
+ function TemplatingRouteLoader(compositionEngine) {
+ var _this = _super.call(this) || this;
+ _this.compositionEngine = compositionEngine;
+ return _this;
+ }
+ /**
+ * Resolve a view model from a RouteConfig
+ * Throws when there is neither "moduleId" nor "viewModel" property
+ * @internal
+ */
+ TemplatingRouteLoader.prototype.resolveViewModel = function (router, config) {
+ return new Promise(function (resolve, reject) {
+ var viewModel;
+ if ('moduleId' in config) {
+ var moduleId = config.moduleId;
+ if (moduleId === null) {
+ viewModel = EmptyClass;
+ }
+ else {
+ // this requires container of router has passes a certain point
+ // where a view model has been setup on the container
+ // it will fail in enhance scenario because no viewport has been registered
+ moduleId = relativeToFile(moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
+ if (/\.html/i.test(moduleId)) {
+ viewModel = createDynamicClass(moduleId);
+ }
+ else {
+ viewModel = moduleId;
+ }
+ }
+ return resolve(viewModel);
+ }
+ // todo: add if ('viewModel' in config) to support static view model resolution
+ reject(new Error('Invalid route config. No "moduleId" found.'));
+ });
+ };
+ /**
+ * Create child container based on a router container
+ * Also ensures that child router are properly constructed in the newly created child container
+ * @internal
+ */
+ TemplatingRouteLoader.prototype.createChildContainer = function (router) {
+ var childContainer = router.container.createChild();
+ childContainer.registerSingleton(RouterViewLocator);
+ childContainer.getChildRouter = function () {
+ var childRouter;
+ childContainer.registerHandler(Router, function () { return childRouter || (childRouter = router.createChild(childContainer)); });
+ return childContainer.get(Router);
+ };
+ return childContainer;
+ };
+ /**
+ * Load corresponding component of a route config of a navigation instruction
+ */
+ TemplatingRouteLoader.prototype.loadRoute = function (router, config, _navInstruction) {
+ var _this = this;
+ return this
+ .resolveViewModel(router, config)
+ .then(function (viewModel) { return _this.compositionEngine.ensureViewModel({
+ viewModel: viewModel,
+ childContainer: _this.createChildContainer(router),
+ view: config.view || config.viewStrategy,
+ router: router
+ }); });
+ };
+ /**@internal */
+ TemplatingRouteLoader.inject = [CompositionEngine];
+ return TemplatingRouteLoader;
+}(RouteLoader));
+/**@internal exported for unit testing */
+function createDynamicClass(moduleId) {
+ var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
+ var DynamicClass = /** @class */ (function () {
+ function DynamicClass() {
+ }
+ DynamicClass.prototype.bind = function (bindingContext) {
+ this.$parent = bindingContext;
+ };
+ return DynamicClass;
+ }());
+ customElement(name)(DynamicClass);
+ useView(moduleId)(DynamicClass);
+ return DynamicClass;
+}
+
+var logger = getLogger('route-href');
+/**
+ * Helper custom attribute to help associate an element with a route by name
+ */
+var RouteHref = /** @class */ (function () {
+ function RouteHref(router, element) {
+ this.router = router;
+ this.element = element;
+ this.attribute = 'href';
+ }
+ /*@internal */
+ RouteHref.inject = function () {
+ return [Router, DOM.Element];
+ };
+ RouteHref.prototype.bind = function () {
+ this.isActive = true;
+ this.processChange();
+ };
+ RouteHref.prototype.unbind = function () {
+ this.isActive = false;
+ };
+ RouteHref.prototype.attributeChanged = function (value, previous) {
+ if (previous) {
+ this.element.removeAttribute(previous);
+ }
+ return this.processChange();
+ };
+ RouteHref.prototype.processChange = function () {
+ var _this = this;
+ return this.router
+ .ensureConfigured()
+ .then(function () {
+ if (!_this.isActive) {
+ // returning null to avoid Bluebird warning
+ return null;
+ }
+ var element = _this.element;
+ var href = _this.router.generate(_this.route, _this.params);
+ if (element.au.controller) {
+ element.au.controller.viewModel[_this.attribute] = href;
+ }
+ else {
+ element.setAttribute(_this.attribute, href);
+ }
+ // returning null to avoid Bluebird warning
+ return null;
+ })
+ .catch(function (reason) {
+ logger.error(reason);
+ });
+ };
+ /**
+ * @internal Actively avoid using decorator to reduce the amount of code generated
+ */
+ RouteHref.$resource = {
+ type: 'attribute',
+ name: 'route-href',
+ bindables: [
+ { name: 'route', changeHandler: 'processChange', primaryProperty: true },
+ { name: 'params', changeHandler: 'processChange' },
+ 'attribute'
+ ] // type definition of Aurelia templating is wrong
+ };
+ return RouteHref;
+}());
- config.container.registerAlias(Router, AppRouter);
+function configure(config) {
+ config
+ .singleton(RouteLoader, TemplatingRouteLoader)
+ .singleton(Router, AppRouter)
+ .globalResources(RouterView, RouteHref);
+ config.container.registerAlias(Router, AppRouter);
}
-export { TemplatingRouteLoader, RouterView, RouteHref, configure };
\ No newline at end of file
+export { RouteHref, RouterView, TemplatingRouteLoader, configure };
+//# sourceMappingURL=aurelia-templating-router.js.map
diff --git a/dist/native-modules/aurelia-templating-router.js.map b/dist/native-modules/aurelia-templating-router.js.map
new file mode 100644
index 0000000..22a14ca
--- /dev/null
+++ b/dist/native-modules/aurelia-templating-router.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"aurelia-templating-router.js","sources":["../../src/router-view.ts","../../src/route-loader.ts","../../src/route-href.ts","../../src/aurelia-templating-router.ts"],"sourcesContent":["import { Container } from 'aurelia-dependency-injection';\nimport { createOverrideContext, OverrideContext } from 'aurelia-binding';\nimport {\n ViewSlot,\n ViewLocator,\n BehaviorInstruction,\n CompositionTransaction,\n CompositionEngine,\n ShadowDOM,\n SwapStrategies,\n ResourceDescription,\n HtmlBehaviorResource,\n CompositionTransactionNotifier,\n View,\n CompositionTransactionOwnershipToken,\n Controller,\n ViewFactory,\n CompositionContext,\n IStaticResourceConfig,\n IStaticViewConfig\n} from 'aurelia-templating';\nimport {\n Router\n} from 'aurelia-router';\nimport { Origin } from 'aurelia-metadata';\nimport { DOM } from 'aurelia-pal';\nimport { IRouterViewViewPortInstruction, Constructable } from './interfaces';\n\nclass EmptyLayoutViewModel {\n\n}\n\n/**\n * Implementation of Aurelia Router ViewPort. Responsible for loading route, composing and swapping routes views\n */\nexport class RouterView {\n\n /**@internal */\n static inject() {\n return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n *\n * There is no view to compose by default in a router view\n * This custom element is responsible for composing its own view, based on current config\n */\n static $view: IStaticViewConfig = null;\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n name: 'router-view',\n bindables: ['swapOrder', 'layoutView', 'layoutViewModel', 'layoutModel', 'inherit-binding-context'] as any\n };\n\n /**\n * Swapping order when going to a new route. By default, supports 3 value: before, after, with\n * - before = new in -> old out\n * - after = old out -> new in\n * - with = new in + old out\n *\n * These values are defined by swapStrategies export in aurelia-templating/ aurelia-framework\n * Can be extended there and used here\n */\n swapOrder?: string;\n\n /**\n * Layout view used for this router-view layout, if no layout-viewmodel specified\n */\n layoutView?: any;\n\n /**\n * Layout view model used as binding context for this router-view layout\n * Actual type would be {string | Constructable | object}\n */\n layoutViewModel?: any;\n\n /**\n * Layout model used to activate layout view model, if specified with `layoutViewModel`\n */\n layoutModel?: any;\n\n /**\n * Element associated with this custom element\n */\n readonly element: Element;\n\n /**\n * Current router associated with this \n */\n readonly router: Router;\n\n /**\n * Container at this level\n */\n container: Container;\n\n /**\n * @internal\n * the view slot for adding / removing Routing related views created dynamically\n */\n viewSlot: ViewSlot;\n\n /**\n * @internal\n * Used to mimic partially functionalities of CompositionEngine\n */\n viewLocator: ViewLocator;\n\n /**\n * @internal\n * View composed by the CompositionEngine, depends on layout / viewports/ moduleId / viewModel of routeconfig\n */\n view: View;\n\n /**\n * @internal\n * The view where this `` is placed in\n */\n owningView: View;\n\n /**\n * @internal\n * Composition Transaction of initial composition transaction, when this is created\n */\n compositionTransaction: CompositionTransaction;\n\n /**\n * @internal\n * CompositionEngine instance, responsible for composing view/view model during process changes phase of this \n */\n compositionEngine: CompositionEngine;\n\n /**\n * Composition transaction notifier instance. Created when this router-view composing its instruction\n * for the first time.\n * Null on 2nd time and after.\n * @internal\n */\n compositionTransactionNotifier: CompositionTransactionNotifier;\n\n /**\n * @internal\n */\n compositionTransactionOwnershipToken: CompositionTransactionOwnershipToken;\n\n /**\n * @internal\n */\n overrideContext: OverrideContext;\n\n constructor(\n element: Element,\n container: Container,\n viewSlot: ViewSlot,\n router: Router,\n viewLocator: ViewLocator,\n compositionTransaction: CompositionTransaction,\n compositionEngine: CompositionEngine\n ) {\n this.element = element;\n this.container = container;\n this.viewSlot = viewSlot;\n this.router = router;\n this.viewLocator = viewLocator;\n this.compositionTransaction = compositionTransaction;\n this.compositionEngine = compositionEngine;\n // add this to router view ports lookup based on name attribute\n // when this router is the root router-view\n // also trigger AppRouter registerViewPort extra flow\n this.router.registerViewPort(this, this.element.getAttribute('name'));\n\n // Each process its instruction as a composition transaction\n // there are differences between intial composition and subsequent compositions\n // also there are differences between root composition and child composition\n // mark the first composition transaction with a property initialComposition to distinguish it\n // when the root gets new instruction for the first time\n if (!('initialComposition' in compositionTransaction)) {\n compositionTransaction.initialComposition = true;\n this.compositionTransactionNotifier = compositionTransaction.enlist();\n }\n }\n\n created(owningView: View): void {\n this.owningView = owningView;\n }\n\n bind(bindingContext: any, overrideContext: OverrideContext): void {\n // router needs to get access to view model of current route parent\n // doing it in generic way via viewModel property on container\n this.container.viewModel = bindingContext;\n this.overrideContext = overrideContext;\n }\n\n /**\n * Implementation of `aurelia-router` ViewPort interface, responsible for templating related part in routing Pipeline\n */\n process($viewPortInstruction: any, waitToSwap?: boolean): Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction = $viewPortInstruction as IRouterViewViewPortInstruction;\n const component = viewPortInstruction.component;\n const childContainer = component.childContainer;\n const viewModel = component.viewModel;\n const viewModelResource = component.viewModelResource as unknown as ResourceDescription;\n const metadata = viewModelResource.metadata;\n const config = component.router.currentInstruction.config;\n const viewPortConfig = config.viewPorts ? (config.viewPorts[viewPortInstruction.name] || {}) : {};\n\n (childContainer.get(RouterViewLocator) as RouterViewLocator)._notify(this);\n\n // layoutInstruction is our layout viewModel\n const layoutInstruction = {\n viewModel: viewPortConfig.layoutViewModel || config.layoutViewModel || this.layoutViewModel,\n view: viewPortConfig.layoutView || config.layoutView || this.layoutView,\n model: viewPortConfig.layoutModel || config.layoutModel || this.layoutModel,\n router: viewPortInstruction.component.router,\n childContainer: childContainer,\n viewSlot: this.viewSlot\n };\n\n // viewport will be a thin wrapper around composition engine\n // to process instruction/configuration from users\n // preparing all information related to a composition process\n // first by getting view strategy of a ViewPortComponent View\n const viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);\n if (viewStrategy && component.view) {\n viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);\n }\n\n // using metadata of a custom element view model to load appropriate view-factory instance\n return metadata\n .load(childContainer, viewModelResource.value, null, viewStrategy, true)\n // for custom element, viewFactory typing is always ViewFactory\n // for custom attribute, it will be HtmlBehaviorResource\n .then((viewFactory: ViewFactory | HtmlBehaviorResource) => {\n // if this is not the first time that this is composing its instruction\n // try to capture ownership of the composition transaction\n // child will not be able to capture, since root typically captures\n // the ownership token\n if (!this.compositionTransactionNotifier) {\n this.compositionTransactionOwnershipToken = this.compositionTransaction.tryCapture();\n }\n\n if (layoutInstruction.viewModel || layoutInstruction.view) {\n viewPortInstruction.layoutInstruction = layoutInstruction;\n }\n\n const viewPortComponentBehaviorInstruction = BehaviorInstruction.dynamic(\n this.element,\n viewModel,\n viewFactory as ViewFactory\n );\n viewPortInstruction.controller = metadata.create(childContainer, viewPortComponentBehaviorInstruction);\n\n if (waitToSwap) {\n return null;\n }\n\n this.swap(viewPortInstruction);\n });\n }\n\n swap($viewPortInstruction: any): void | Promise {\n // have strong typings without exposing it in public typings, this is to ensure maximum backward compat\n const viewPortInstruction: IRouterViewViewPortInstruction = $viewPortInstruction;\n const viewPortController = viewPortInstruction.controller;\n const layoutInstruction = viewPortInstruction.layoutInstruction;\n const previousView = this.view;\n\n // Final step of swapping a ViewPortComponent\n const work = () => {\n const swapStrategy = SwapStrategies[this.swapOrder] || SwapStrategies.after;\n const viewSlot = this.viewSlot;\n\n swapStrategy(\n viewSlot,\n previousView,\n () => Promise.resolve(viewSlot.add(this.view))\n ).then(() => {\n this._notify();\n });\n };\n\n // Ensure all users setups have been completed\n const ready = (owningView_or_layoutView: View) => {\n viewPortController.automate(this.overrideContext, owningView_or_layoutView);\n const transactionOwnerShipToken = this.compositionTransactionOwnershipToken;\n // if this router-view is the root of a normal startup via aurelia.setRoot\n // attemp to take control of the transaction\n\n // if ownership can be taken\n // wait for transaction to complete before swapping\n if (transactionOwnerShipToken) {\n return transactionOwnerShipToken\n .waitForCompositionComplete()\n .then(() => {\n this.compositionTransactionOwnershipToken = null;\n return work();\n });\n }\n\n // otherwise, just swap\n return work();\n };\n\n // If there is layout instruction, new to compose layout before processing ViewPortComponent\n // layout controller/view/view-model is composed using composition engine APIs\n if (layoutInstruction) {\n if (!layoutInstruction.viewModel) {\n // createController chokes if there's no viewmodel, so create a dummy one\n // but avoid using a POJO as it creates unwanted metadata in Object constructor\n layoutInstruction.viewModel = new EmptyLayoutViewModel();\n }\n\n // using composition engine to create compose layout\n return this.compositionEngine\n // first create controller from layoutInstruction\n // and treat it as CompositionContext\n // then emulate slot projection with ViewPortComponent view\n .createController(layoutInstruction as CompositionContext)\n .then((layoutController: Controller) => {\n const layoutView = layoutController.view;\n ShadowDOM.distributeView(viewPortController.view, layoutController.slots || layoutView.slots);\n // when there is a layout\n // view hierarchy is: owner view -> layout view -> ViewPortComponent view\n layoutController.automate(createOverrideContext(layoutInstruction.viewModel), this.owningView);\n layoutView.children.push(viewPortController.view);\n return layoutView || layoutController;\n })\n .then((newView: View | Controller) => {\n this.view = newView as View;\n return ready(newView as View);\n });\n }\n\n // if there is no layout, then get ViewPortComponent view ready as view property\n // and process controller/swapping\n // when there is no layout\n // view hierarchy is: owner view -> ViewPortComponent view\n this.view = viewPortController.view;\n\n return ready(this.owningView);\n }\n\n /**\n * Notify composition transaction that this router has finished processing\n * Happens when this is the root router-view\n * @internal\n */\n _notify() {\n const notifier = this.compositionTransactionNotifier;\n if (notifier) {\n notifier.done();\n this.compositionTransactionNotifier = null;\n }\n }\n}\n\n/**\n* Locator which finds the nearest RouterView, relative to the current dependency injection container.\n*/\nexport class RouterViewLocator {\n\n /*@internal */\n promise: Promise;\n\n /*@internal */\n resolve: (val?: any) => void;\n\n /**\n * Creates an instance of the RouterViewLocator class.\n */\n constructor() {\n this.promise = new Promise((resolve) => this.resolve = resolve);\n }\n\n /**\n * Finds the nearest RouterView instance.\n * @returns A promise that will be resolved with the located RouterView instance.\n */\n findNearest(): Promise {\n return this.promise;\n }\n\n /**@internal */\n _notify(routerView: RouterView): void {\n this.resolve(routerView);\n }\n}\n","import { Origin } from 'aurelia-metadata';\nimport { relativeToFile } from 'aurelia-path';\nimport { NavigationInstruction, RouteConfig, RouteLoader, Router } from 'aurelia-router';\nimport { CompositionEngine, customElement, inlineView, useView, CompositionContext } from 'aurelia-templating';\nimport { RouterViewLocator } from './router-view';\nimport { Container } from 'aurelia-dependency-injection';\n\n/**@internal exported for unit testing */\nexport class EmptyClass { }\ninlineView('')(EmptyClass);\n\n/**\n * Default implementation of `RouteLoader` used for loading component based on a route config\n */\nexport class TemplatingRouteLoader extends RouteLoader {\n\n /**@internal */\n static inject = [CompositionEngine];\n\n /**@internal */\n compositionEngine: CompositionEngine;\n\n constructor(\n compositionEngine: CompositionEngine\n ) {\n super();\n this.compositionEngine = compositionEngine;\n }\n\n /**\n * Resolve a view model from a RouteConfig\n * Throws when there is neither \"moduleId\" nor \"viewModel\" property\n * @internal\n */\n resolveViewModel(router: Router, config: RouteConfig): Promise {\n return new Promise((resolve, reject) => {\n let viewModel: string | null | Function;\n if ('moduleId' in config) {\n let moduleId = config.moduleId;\n if (moduleId === null) {\n viewModel = EmptyClass;\n } else {\n // this requires container of router has passes a certain point\n // where a view model has been setup on the container\n // it will fail in enhance scenario because no viewport has been registered\n moduleId = relativeToFile(moduleId, Origin.get(router.container.viewModel.constructor).moduleId);\n if (/\\.html/i.test(moduleId)) {\n viewModel = createDynamicClass(moduleId);\n } else {\n viewModel = moduleId;\n }\n }\n return resolve(viewModel);\n }\n // todo: add if ('viewModel' in config) to support static view model resolution\n reject(new Error('Invalid route config. No \"moduleId\" found.'));\n });\n }\n\n /**\n * Create child container based on a router container\n * Also ensures that child router are properly constructed in the newly created child container\n * @internal\n */\n createChildContainer(router: Router): Container {\n const childContainer = router.container.createChild();\n\n childContainer.registerSingleton(RouterViewLocator);\n childContainer.getChildRouter = function() {\n let childRouter: Router;\n\n childContainer.registerHandler(\n Router,\n () => childRouter || (childRouter = router.createChild(childContainer))\n );\n\n return childContainer.get(Router);\n };\n return childContainer;\n }\n\n /**\n * Load corresponding component of a route config of a navigation instruction\n */\n loadRoute(router: Router, config: RouteConfig, _navInstruction: NavigationInstruction): Promise {\n return this\n .resolveViewModel(router, config)\n .then(viewModel => this.compositionEngine.ensureViewModel({\n viewModel: viewModel,\n childContainer: this.createChildContainer(router),\n view: config.view || config.viewStrategy,\n router: router\n } as CompositionContext));\n }\n}\n\n/**@internal exported for unit testing */\nexport function createDynamicClass(moduleId: string) {\n const name = /([^\\/^\\?]+)\\.html/i.exec(moduleId)[1];\n\n class DynamicClass {\n\n $parent: any;\n\n bind(bindingContext: any) {\n this.$parent = bindingContext;\n }\n }\n\n customElement(name)(DynamicClass);\n useView(moduleId)(DynamicClass);\n\n return DynamicClass;\n}\n","import { IStaticResourceConfig } from 'aurelia-templating';\nimport { Router } from 'aurelia-router';\nimport { DOM } from 'aurelia-pal';\nimport * as LogManager from 'aurelia-logging';\n\nconst logger = LogManager.getLogger('route-href');\n\n/**\n * Helper custom attribute to help associate an element with a route by name\n */\nexport class RouteHref {\n\n /*@internal */\n static inject() {\n return [Router, DOM.Element];\n }\n\n /**\n * @internal Actively avoid using decorator to reduce the amount of code generated\n */\n static $resource: IStaticResourceConfig = {\n type: 'attribute',\n name: 'route-href',\n bindables: [\n { name: 'route', changeHandler: 'processChange', primaryProperty: true },\n { name: 'params', changeHandler: 'processChange' },\n 'attribute'\n ] as any // type definition of Aurelia templating is wrong\n };\n\n /**\n * Current router of this attribute\n */\n readonly router: Router;\n\n /**\n * Element this attribute is associated with\n */\n readonly element: Element;\n\n /**@internal */\n isActive: boolean;\n\n /**\n * Name of the route this attribute refers to. This name should exist in the current router hierarchy\n */\n route: string;\n\n /**\n * Parameters of this attribute to generate URL.\n */\n params: Record;\n\n /**\n * Target property on a custom element if this attribute is put on a custom element\n * OR an attribute if this attribute is put on a normal element\n */\n attribute: string;\n\n constructor(\n router: Router,\n element: Element\n ) {\n this.router = router;\n this.element = element;\n this.attribute = 'href';\n }\n\n bind() {\n this.isActive = true;\n this.processChange();\n }\n\n unbind() {\n this.isActive = false;\n }\n\n attributeChanged(value: any, previous: any) {\n if (previous) {\n this.element.removeAttribute(previous);\n }\n\n return this.processChange();\n }\n\n processChange() {\n return this.router\n .ensureConfigured()\n .then((): null => {\n if (!this.isActive) {\n // returning null to avoid Bluebird warning\n return null;\n }\n const element = this.element as Element & { au: any };\n\n const href = this.router.generate(this.route, this.params);\n\n if (element.au.controller) {\n element.au.controller.viewModel[this.attribute] = href;\n } else {\n element.setAttribute(this.attribute, href);\n }\n\n // returning null to avoid Bluebird warning\n return null;\n })\n .catch((reason: any) => {\n logger.error(reason);\n });\n }\n}\n\n","import { Router, AppRouter, RouteLoader } from 'aurelia-router';\nimport { TemplatingRouteLoader } from './route-loader';\nimport { RouterView } from './router-view';\nimport { RouteHref } from './route-href';\nimport { IFrameworkConfiguration } from './interfaces';\n\nexport function configure(config: IFrameworkConfiguration) {\n config\n .singleton(RouteLoader, TemplatingRouteLoader)\n .singleton(Router, AppRouter)\n .globalResources(\n RouterView,\n RouteHref\n );\n\n config.container.registerAlias(Router, AppRouter);\n}\n\nexport {\n TemplatingRouteLoader,\n RouterView,\n RouteHref\n};\n"],"names":["tslib_1.__extends","LogManager.getLogger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;IAAA;KAEC;IAAD,2BAAC;CAAA,IAAA;;;;AAKD;IAsHE,oBACE,OAAgB,EAChB,SAAoB,EACp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QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE;YAClD,WAAW;SACL;KACT,CAAC;IAkFJ,gBAAC;CApGD;;SCJgB,SAAS,CAAC,MAA+B;IACvD,MAAM;SACH,SAAS,CAAC,WAAW,EAAE,qBAAqB,CAAC;SAC7C,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;SAC5B,eAAe,CACd,UAAU,EACV,SAAS,CACV,CAAC;IAEJ,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnD;;;;"}
\ No newline at end of file
diff --git a/dist/native-modules/index.js b/dist/native-modules/index.js
deleted file mode 100644
index 64874f8..0000000
--- a/dist/native-modules/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from './aurelia-templating-router';
\ No newline at end of file
diff --git a/dist/native-modules/route-href.js b/dist/native-modules/route-href.js
deleted file mode 100644
index f19502a..0000000
--- a/dist/native-modules/route-href.js
+++ /dev/null
@@ -1,64 +0,0 @@
-var _dec, _dec2, _dec3, _dec4, _class;
-
-
-
-import { customAttribute, bindable } from 'aurelia-templating';
-import { Router } from 'aurelia-router';
-import { DOM } from 'aurelia-pal';
-import * as LogManager from 'aurelia-logging';
-
-var logger = LogManager.getLogger('route-href');
-
-export var RouteHref = (_dec = customAttribute('route-href'), _dec2 = bindable({ name: 'route', changeHandler: 'processChange', primaryProperty: true }), _dec3 = bindable({ name: 'params', changeHandler: 'processChange' }), _dec4 = bindable({ name: 'attribute', defaultValue: 'href' }), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = function () {
- RouteHref.inject = function inject() {
- return [Router, DOM.Element];
- };
-
- function RouteHref(router, element) {
-
-
- this.router = router;
- this.element = element;
- }
-
- RouteHref.prototype.bind = function bind() {
- this.isActive = true;
- this.processChange();
- };
-
- RouteHref.prototype.unbind = function unbind() {
- this.isActive = false;
- };
-
- RouteHref.prototype.attributeChanged = function attributeChanged(value, previous) {
- if (previous) {
- this.element.removeAttribute(previous);
- }
-
- this.processChange();
- };
-
- RouteHref.prototype.processChange = function processChange() {
- var _this = this;
-
- return this.router.ensureConfigured().then(function () {
- if (!_this.isActive) {
- return null;
- }
-
- var href = _this.router.generate(_this.route, _this.params);
-
- if (_this.element.au.controller) {
- _this.element.au.controller.viewModel[_this.attribute] = href;
- } else {
- _this.element.setAttribute(_this.attribute, href);
- }
-
- return null;
- }).catch(function (reason) {
- logger.error(reason);
- });
- };
-
- return RouteHref;
-}()) || _class) || _class) || _class) || _class);
\ No newline at end of file
diff --git a/dist/native-modules/route-loader.js b/dist/native-modules/route-loader.js
deleted file mode 100644
index b8150ea..0000000
--- a/dist/native-modules/route-loader.js
+++ /dev/null
@@ -1,88 +0,0 @@
-var _dec, _class, _dec2, _class2;
-
-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; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-
-
-import { inject } from 'aurelia-dependency-injection';
-import { CompositionEngine, useView, inlineView, 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';
-
-var EmptyClass = (_dec = inlineView(''), _dec(_class = function EmptyClass() {
-
-}) || _class);
-
-export var TemplatingRouteLoader = (_dec2 = inject(CompositionEngine), _dec2(_class2 = function (_RouteLoader) {
- _inherits(TemplatingRouteLoader, _RouteLoader);
-
- function TemplatingRouteLoader(compositionEngine) {
-
-
- var _this = _possibleConstructorReturn(this, _RouteLoader.call(this));
-
- _this.compositionEngine = compositionEngine;
- return _this;
- }
-
- TemplatingRouteLoader.prototype.loadRoute = function loadRoute(router, config) {
- var childContainer = router.container.createChild();
-
- var viewModel = void 0;
- if (config.moduleId === null) {
- viewModel = EmptyClass;
- } else if (/\.html/i.test(config.moduleId)) {
- viewModel = createDynamicClass(config.moduleId);
- } else {
- viewModel = relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
- }
-
- var instruction = {
- viewModel: viewModel,
- childContainer: childContainer,
- view: config.view || config.viewStrategy,
- router: router
- };
-
- childContainer.registerSingleton(RouterViewLocator);
-
- childContainer.getChildRouter = function () {
- var childRouter = void 0;
-
- childContainer.registerHandler(Router, function (c) {
- return childRouter || (childRouter = router.createChild(childContainer));
- });
-
- return childContainer.get(Router);
- };
-
- return this.compositionEngine.ensureViewModel(instruction);
- };
-
- return TemplatingRouteLoader;
-}(RouteLoader)) || _class2);
-
-function createDynamicClass(moduleId) {
- var _dec3, _dec4, _class3;
-
- var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
-
- var DynamicClass = (_dec3 = customElement(name), _dec4 = useView(moduleId), _dec3(_class3 = _dec4(_class3 = function () {
- function DynamicClass() {
-
- }
-
- DynamicClass.prototype.bind = function bind(bindingContext) {
- this.$parent = bindingContext;
- };
-
- return DynamicClass;
- }()) || _class3) || _class3);
-
-
- return DynamicClass;
-}
\ No newline at end of file
diff --git a/dist/native-modules/router-view.js b/dist/native-modules/router-view.js
deleted file mode 100644
index 5fc0395..0000000
--- a/dist/native-modules/router-view.js
+++ /dev/null
@@ -1,233 +0,0 @@
-var _dec, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
-
-function _initDefineProp(target, property, descriptor, context) {
- if (!descriptor) return;
- Object.defineProperty(target, property, {
- enumerable: descriptor.enumerable,
- configurable: descriptor.configurable,
- writable: descriptor.writable,
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
- });
-}
-
-
-
-function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
- var desc = {};
- Object['ke' + 'ys'](descriptor).forEach(function (key) {
- desc[key] = descriptor[key];
- });
- desc.enumerable = !!desc.enumerable;
- desc.configurable = !!desc.configurable;
-
- if ('value' in desc || desc.initializer) {
- desc.writable = true;
- }
-
- desc = decorators.slice().reverse().reduce(function (desc, decorator) {
- return decorator(target, property, desc) || desc;
- }, desc);
-
- if (context && desc.initializer !== void 0) {
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
- desc.initializer = undefined;
- }
-
- if (desc.initializer === void 0) {
- Object['define' + 'Property'](target, property, desc);
- desc = null;
- }
-
- return desc;
-}
-
-function _initializerWarningHelper(descriptor, context) {
- throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
-}
-
-import { Container } from 'aurelia-dependency-injection';
-import { createOverrideContext } from 'aurelia-binding';
-import { ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, SwapStrategies } from 'aurelia-templating';
-import { Router } from 'aurelia-router';
-import { Origin } from 'aurelia-metadata';
-import { DOM } from 'aurelia-pal';
-
-export var RouterView = (_dec = customElement('router-view'), _dec(_class = noView(_class = (_class2 = function () {
- RouterView.inject = function inject() {
- return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];
- };
-
- function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
-
-
- _initDefineProp(this, 'swapOrder', _descriptor, this);
-
- _initDefineProp(this, 'layoutView', _descriptor2, this);
-
- _initDefineProp(this, 'layoutViewModel', _descriptor3, this);
-
- _initDefineProp(this, 'layoutModel', _descriptor4, this);
-
- this.element = element;
- this.container = container;
- this.viewSlot = viewSlot;
- this.router = router;
- this.viewLocator = viewLocator;
- this.compositionTransaction = compositionTransaction;
- this.compositionEngine = compositionEngine;
- this.router.registerViewPort(this, this.element.getAttribute('name'));
-
- if (!('initialComposition' in compositionTransaction)) {
- compositionTransaction.initialComposition = true;
- this.compositionTransactionNotifier = compositionTransaction.enlist();
- }
- }
-
- RouterView.prototype.created = function created(owningView) {
- this.owningView = owningView;
- };
-
- RouterView.prototype.bind = function bind(bindingContext, overrideContext) {
- this.container.viewModel = bindingContext;
- this.overrideContext = overrideContext;
- };
-
- RouterView.prototype.process = function process(viewPortInstruction, waitToSwap) {
- var _this = this;
-
- var component = viewPortInstruction.component;
- var childContainer = component.childContainer;
- var viewModel = component.viewModel;
- var viewModelResource = component.viewModelResource;
- var metadata = viewModelResource.metadata;
- var config = component.router.currentInstruction.config;
- var viewPort = config.viewPorts ? config.viewPorts[viewPortInstruction.name] || {} : {};
-
- childContainer.get(RouterViewLocator)._notify(this);
-
- var layoutInstruction = {
- viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
- view: viewPort.layoutView || config.layoutView || this.layoutView,
- model: viewPort.layoutModel || config.layoutModel || this.layoutModel,
- router: viewPortInstruction.component.router,
- childContainer: childContainer,
- viewSlot: this.viewSlot
- };
-
- var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
- if (viewStrategy && component.view) {
- viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);
- }
-
- return metadata.load(childContainer, viewModelResource.value, null, viewStrategy, true).then(function (viewFactory) {
- if (!_this.compositionTransactionNotifier) {
- _this.compositionTransactionOwnershipToken = _this.compositionTransaction.tryCapture();
- }
-
- if (layoutInstruction.viewModel || layoutInstruction.view) {
- viewPortInstruction.layoutInstruction = layoutInstruction;
- }
-
- viewPortInstruction.controller = metadata.create(childContainer, BehaviorInstruction.dynamic(_this.element, viewModel, viewFactory));
-
- if (waitToSwap) {
- return null;
- }
-
- _this.swap(viewPortInstruction);
- });
- };
-
- RouterView.prototype.swap = function swap(viewPortInstruction) {
- var _this2 = this;
-
- var layoutInstruction = viewPortInstruction.layoutInstruction;
- var previousView = this.view;
-
- var work = function work() {
- var swapStrategy = SwapStrategies[_this2.swapOrder] || SwapStrategies.after;
- var viewSlot = _this2.viewSlot;
-
- swapStrategy(viewSlot, previousView, function () {
- return Promise.resolve(viewSlot.add(_this2.view));
- }).then(function () {
- _this2._notify();
- });
- };
-
- var ready = function ready(owningView) {
- viewPortInstruction.controller.automate(_this2.overrideContext, owningView);
- if (_this2.compositionTransactionOwnershipToken) {
- return _this2.compositionTransactionOwnershipToken.waitForCompositionComplete().then(function () {
- _this2.compositionTransactionOwnershipToken = null;
- return work();
- });
- }
-
- return work();
- };
-
- if (layoutInstruction) {
- if (!layoutInstruction.viewModel) {
- layoutInstruction.viewModel = {};
- }
-
- return this.compositionEngine.createController(layoutInstruction).then(function (controller) {
- ShadowDOM.distributeView(viewPortInstruction.controller.view, controller.slots || controller.view.slots);
- controller.automate(createOverrideContext(layoutInstruction.viewModel), _this2.owningView);
- controller.view.children.push(viewPortInstruction.controller.view);
- return controller.view || controller;
- }).then(function (newView) {
- _this2.view = newView;
- return ready(newView);
- });
- }
-
- this.view = viewPortInstruction.controller.view;
-
- return ready(this.owningView);
- };
-
- RouterView.prototype._notify = function _notify() {
- if (this.compositionTransactionNotifier) {
- this.compositionTransactionNotifier.done();
- this.compositionTransactionNotifier = null;
- }
- };
-
- return RouterView;
-}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'swapOrder', [bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'layoutView', [bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'layoutViewModel', [bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'layoutModel', [bindable], {
- enumerable: true,
- initializer: null
-})), _class2)) || _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;
-}();
\ No newline at end of file
diff --git a/dist/system/aurelia-templating-router.js b/dist/system/aurelia-templating-router.js
deleted file mode 100644
index 744a982..0000000
--- a/dist/system/aurelia-templating-router.js
+++ /dev/null
@@ -1,37 +0,0 @@
-'use strict';
-
-System.register(['aurelia-router', './route-loader', './router-view', './route-href'], function (_export, _context) {
- "use strict";
-
- var Router, AppRouter, RouteLoader, TemplatingRouteLoader, RouterView, RouteHref;
-
-
- function configure(config) {
- config.singleton(RouteLoader, TemplatingRouteLoader).singleton(Router, AppRouter).globalResources(RouterView, RouteHref);
-
- config.container.registerAlias(Router, AppRouter);
- }
-
- return {
- setters: [function (_aureliaRouter) {
- Router = _aureliaRouter.Router;
- AppRouter = _aureliaRouter.AppRouter;
- RouteLoader = _aureliaRouter.RouteLoader;
- }, function (_routeLoader) {
- TemplatingRouteLoader = _routeLoader.TemplatingRouteLoader;
- }, function (_routerView) {
- RouterView = _routerView.RouterView;
- }, function (_routeHref) {
- RouteHref = _routeHref.RouteHref;
- }],
- execute: function () {
- _export('TemplatingRouteLoader', TemplatingRouteLoader);
-
- _export('RouterView', RouterView);
-
- _export('RouteHref', RouteHref);
-
- _export('configure', configure);
- }
- };
-});
\ No newline at end of file
diff --git a/dist/system/index.js b/dist/system/index.js
deleted file mode 100644
index 1b4f62b..0000000
--- a/dist/system/index.js
+++ /dev/null
@@ -1,18 +0,0 @@
-'use strict';
-
-System.register(['./aurelia-templating-router'], function (_export, _context) {
- "use strict";
-
- return {
- setters: [function (_aureliaTemplatingRouter) {
- var _exportObj = {};
-
- for (var _key in _aureliaTemplatingRouter) {
- if (_key !== "default" && _key !== "__esModule") _exportObj[_key] = _aureliaTemplatingRouter[_key];
- }
-
- _export(_exportObj);
- }],
- execute: function () {}
- };
-});
\ No newline at end of file
diff --git a/dist/system/route-href.js b/dist/system/route-href.js
deleted file mode 100644
index 24becab..0000000
--- a/dist/system/route-href.js
+++ /dev/null
@@ -1,81 +0,0 @@
-'use strict';
-
-System.register(['aurelia-templating', 'aurelia-router', 'aurelia-pal', 'aurelia-logging'], function (_export, _context) {
- "use strict";
-
- var customAttribute, bindable, Router, DOM, LogManager, _dec, _dec2, _dec3, _dec4, _class, logger, RouteHref;
-
-
-
- return {
- setters: [function (_aureliaTemplating) {
- customAttribute = _aureliaTemplating.customAttribute;
- bindable = _aureliaTemplating.bindable;
- }, function (_aureliaRouter) {
- Router = _aureliaRouter.Router;
- }, function (_aureliaPal) {
- DOM = _aureliaPal.DOM;
- }, function (_aureliaLogging) {
- LogManager = _aureliaLogging;
- }],
- execute: function () {
- logger = LogManager.getLogger('route-href');
-
- _export('RouteHref', RouteHref = (_dec = customAttribute('route-href'), _dec2 = bindable({ name: 'route', changeHandler: 'processChange', primaryProperty: true }), _dec3 = bindable({ name: 'params', changeHandler: 'processChange' }), _dec4 = bindable({ name: 'attribute', defaultValue: 'href' }), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = function () {
- RouteHref.inject = function inject() {
- return [Router, DOM.Element];
- };
-
- function RouteHref(router, element) {
-
-
- this.router = router;
- this.element = element;
- }
-
- RouteHref.prototype.bind = function bind() {
- this.isActive = true;
- this.processChange();
- };
-
- RouteHref.prototype.unbind = function unbind() {
- this.isActive = false;
- };
-
- RouteHref.prototype.attributeChanged = function attributeChanged(value, previous) {
- if (previous) {
- this.element.removeAttribute(previous);
- }
-
- this.processChange();
- };
-
- RouteHref.prototype.processChange = function processChange() {
- var _this = this;
-
- return this.router.ensureConfigured().then(function () {
- if (!_this.isActive) {
- return null;
- }
-
- var href = _this.router.generate(_this.route, _this.params);
-
- if (_this.element.au.controller) {
- _this.element.au.controller.viewModel[_this.attribute] = href;
- } else {
- _this.element.setAttribute(_this.attribute, href);
- }
-
- return null;
- }).catch(function (reason) {
- logger.error(reason);
- });
- };
-
- return RouteHref;
- }()) || _class) || _class) || _class) || _class));
-
- _export('RouteHref', RouteHref);
- }
- };
-});
\ No newline at end of file
diff --git a/dist/system/route-loader.js b/dist/system/route-loader.js
deleted file mode 100644
index e934498..0000000
--- a/dist/system/route-loader.js
+++ /dev/null
@@ -1,129 +0,0 @@
-'use strict';
-
-System.register(['aurelia-dependency-injection', 'aurelia-templating', 'aurelia-router', 'aurelia-path', 'aurelia-metadata', './router-view'], function (_export, _context) {
- "use strict";
-
- var inject, CompositionEngine, useView, inlineView, customElement, RouteLoader, Router, relativeToFile, Origin, RouterViewLocator, _dec, _class, _dec2, _class2, EmptyClass, TemplatingRouteLoader;
-
- 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;
- }
-
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
- }
-
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
- }
-
-
-
- function createDynamicClass(moduleId) {
- var _dec3, _dec4, _class3;
-
- var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
-
- var DynamicClass = (_dec3 = customElement(name), _dec4 = useView(moduleId), _dec3(_class3 = _dec4(_class3 = function () {
- function DynamicClass() {
-
- }
-
- DynamicClass.prototype.bind = function bind(bindingContext) {
- this.$parent = bindingContext;
- };
-
- return DynamicClass;
- }()) || _class3) || _class3);
-
-
- return DynamicClass;
- }
- return {
- setters: [function (_aureliaDependencyInjection) {
- inject = _aureliaDependencyInjection.inject;
- }, function (_aureliaTemplating) {
- CompositionEngine = _aureliaTemplating.CompositionEngine;
- useView = _aureliaTemplating.useView;
- inlineView = _aureliaTemplating.inlineView;
- customElement = _aureliaTemplating.customElement;
- }, function (_aureliaRouter) {
- RouteLoader = _aureliaRouter.RouteLoader;
- Router = _aureliaRouter.Router;
- }, function (_aureliaPath) {
- relativeToFile = _aureliaPath.relativeToFile;
- }, function (_aureliaMetadata) {
- Origin = _aureliaMetadata.Origin;
- }, function (_routerView) {
- RouterViewLocator = _routerView.RouterViewLocator;
- }],
- execute: function () {
- EmptyClass = (_dec = inlineView(''), _dec(_class = function EmptyClass() {
-
- }) || _class);
-
- _export('TemplatingRouteLoader', TemplatingRouteLoader = (_dec2 = inject(CompositionEngine), _dec2(_class2 = function (_RouteLoader) {
- _inherits(TemplatingRouteLoader, _RouteLoader);
-
- function TemplatingRouteLoader(compositionEngine) {
-
-
- var _this = _possibleConstructorReturn(this, _RouteLoader.call(this));
-
- _this.compositionEngine = compositionEngine;
- return _this;
- }
-
- TemplatingRouteLoader.prototype.loadRoute = function loadRoute(router, config) {
- var childContainer = router.container.createChild();
-
- var viewModel = void 0;
- if (config.moduleId === null) {
- viewModel = EmptyClass;
- } else if (/\.html/i.test(config.moduleId)) {
- viewModel = createDynamicClass(config.moduleId);
- } else {
- viewModel = relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
- }
-
- var instruction = {
- viewModel: viewModel,
- childContainer: childContainer,
- view: config.view || config.viewStrategy,
- router: router
- };
-
- childContainer.registerSingleton(RouterViewLocator);
-
- childContainer.getChildRouter = function () {
- var childRouter = void 0;
-
- childContainer.registerHandler(Router, function (c) {
- return childRouter || (childRouter = router.createChild(childContainer));
- });
-
- return childContainer.get(Router);
- };
-
- return this.compositionEngine.ensureViewModel(instruction);
- };
-
- return TemplatingRouteLoader;
- }(RouteLoader)) || _class2));
-
- _export('TemplatingRouteLoader', TemplatingRouteLoader);
- }
- };
-});
\ No newline at end of file
diff --git a/dist/system/router-view.js b/dist/system/router-view.js
deleted file mode 100644
index cdfb47f..0000000
--- a/dist/system/router-view.js
+++ /dev/null
@@ -1,262 +0,0 @@
-'use strict';
-
-System.register(['aurelia-dependency-injection', 'aurelia-binding', 'aurelia-templating', 'aurelia-router', 'aurelia-metadata', 'aurelia-pal'], function (_export, _context) {
- "use strict";
-
- var Container, createOverrideContext, ViewSlot, ViewLocator, customElement, noView, BehaviorInstruction, bindable, CompositionTransaction, CompositionEngine, ShadowDOM, SwapStrategies, Router, Origin, DOM, _dec, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, RouterView, RouterViewLocator;
-
- function _initDefineProp(target, property, descriptor, context) {
- if (!descriptor) return;
- Object.defineProperty(target, property, {
- enumerable: descriptor.enumerable,
- configurable: descriptor.configurable,
- writable: descriptor.writable,
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
- });
- }
-
-
-
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
- var desc = {};
- Object['ke' + 'ys'](descriptor).forEach(function (key) {
- desc[key] = descriptor[key];
- });
- desc.enumerable = !!desc.enumerable;
- desc.configurable = !!desc.configurable;
-
- if ('value' in desc || desc.initializer) {
- desc.writable = true;
- }
-
- desc = decorators.slice().reverse().reduce(function (desc, decorator) {
- return decorator(target, property, desc) || desc;
- }, desc);
-
- if (context && desc.initializer !== void 0) {
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
- desc.initializer = undefined;
- }
-
- if (desc.initializer === void 0) {
- Object['define' + 'Property'](target, property, desc);
- desc = null;
- }
-
- return desc;
- }
-
- function _initializerWarningHelper(descriptor, context) {
- throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
- }
-
- return {
- setters: [function (_aureliaDependencyInjection) {
- Container = _aureliaDependencyInjection.Container;
- }, function (_aureliaBinding) {
- createOverrideContext = _aureliaBinding.createOverrideContext;
- }, function (_aureliaTemplating) {
- ViewSlot = _aureliaTemplating.ViewSlot;
- ViewLocator = _aureliaTemplating.ViewLocator;
- customElement = _aureliaTemplating.customElement;
- noView = _aureliaTemplating.noView;
- BehaviorInstruction = _aureliaTemplating.BehaviorInstruction;
- bindable = _aureliaTemplating.bindable;
- CompositionTransaction = _aureliaTemplating.CompositionTransaction;
- CompositionEngine = _aureliaTemplating.CompositionEngine;
- ShadowDOM = _aureliaTemplating.ShadowDOM;
- SwapStrategies = _aureliaTemplating.SwapStrategies;
- }, function (_aureliaRouter) {
- Router = _aureliaRouter.Router;
- }, function (_aureliaMetadata) {
- Origin = _aureliaMetadata.Origin;
- }, function (_aureliaPal) {
- DOM = _aureliaPal.DOM;
- }],
- execute: function () {
- _export('RouterView', RouterView = (_dec = customElement('router-view'), _dec(_class = noView(_class = (_class2 = function () {
- RouterView.inject = function inject() {
- return [DOM.Element, Container, ViewSlot, Router, ViewLocator, CompositionTransaction, CompositionEngine];
- };
-
- function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
-
-
- _initDefineProp(this, 'swapOrder', _descriptor, this);
-
- _initDefineProp(this, 'layoutView', _descriptor2, this);
-
- _initDefineProp(this, 'layoutViewModel', _descriptor3, this);
-
- _initDefineProp(this, 'layoutModel', _descriptor4, this);
-
- this.element = element;
- this.container = container;
- this.viewSlot = viewSlot;
- this.router = router;
- this.viewLocator = viewLocator;
- this.compositionTransaction = compositionTransaction;
- this.compositionEngine = compositionEngine;
- this.router.registerViewPort(this, this.element.getAttribute('name'));
-
- if (!('initialComposition' in compositionTransaction)) {
- compositionTransaction.initialComposition = true;
- this.compositionTransactionNotifier = compositionTransaction.enlist();
- }
- }
-
- RouterView.prototype.created = function created(owningView) {
- this.owningView = owningView;
- };
-
- RouterView.prototype.bind = function bind(bindingContext, overrideContext) {
- this.container.viewModel = bindingContext;
- this.overrideContext = overrideContext;
- };
-
- RouterView.prototype.process = function process(viewPortInstruction, waitToSwap) {
- var _this = this;
-
- var component = viewPortInstruction.component;
- var childContainer = component.childContainer;
- var viewModel = component.viewModel;
- var viewModelResource = component.viewModelResource;
- var metadata = viewModelResource.metadata;
- var config = component.router.currentInstruction.config;
- var viewPort = config.viewPorts ? config.viewPorts[viewPortInstruction.name] || {} : {};
-
- childContainer.get(RouterViewLocator)._notify(this);
-
- var layoutInstruction = {
- viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
- view: viewPort.layoutView || config.layoutView || this.layoutView,
- model: viewPort.layoutModel || config.layoutModel || this.layoutModel,
- router: viewPortInstruction.component.router,
- childContainer: childContainer,
- viewSlot: this.viewSlot
- };
-
- var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
- if (viewStrategy && component.view) {
- viewStrategy.makeRelativeTo(Origin.get(component.router.container.viewModel.constructor).moduleId);
- }
-
- return metadata.load(childContainer, viewModelResource.value, null, viewStrategy, true).then(function (viewFactory) {
- if (!_this.compositionTransactionNotifier) {
- _this.compositionTransactionOwnershipToken = _this.compositionTransaction.tryCapture();
- }
-
- if (layoutInstruction.viewModel || layoutInstruction.view) {
- viewPortInstruction.layoutInstruction = layoutInstruction;
- }
-
- viewPortInstruction.controller = metadata.create(childContainer, BehaviorInstruction.dynamic(_this.element, viewModel, viewFactory));
-
- if (waitToSwap) {
- return null;
- }
-
- _this.swap(viewPortInstruction);
- });
- };
-
- RouterView.prototype.swap = function swap(viewPortInstruction) {
- var _this2 = this;
-
- var layoutInstruction = viewPortInstruction.layoutInstruction;
- var previousView = this.view;
-
- var work = function work() {
- var swapStrategy = SwapStrategies[_this2.swapOrder] || SwapStrategies.after;
- var viewSlot = _this2.viewSlot;
-
- swapStrategy(viewSlot, previousView, function () {
- return Promise.resolve(viewSlot.add(_this2.view));
- }).then(function () {
- _this2._notify();
- });
- };
-
- var ready = function ready(owningView) {
- viewPortInstruction.controller.automate(_this2.overrideContext, owningView);
- if (_this2.compositionTransactionOwnershipToken) {
- return _this2.compositionTransactionOwnershipToken.waitForCompositionComplete().then(function () {
- _this2.compositionTransactionOwnershipToken = null;
- return work();
- });
- }
-
- return work();
- };
-
- if (layoutInstruction) {
- if (!layoutInstruction.viewModel) {
- layoutInstruction.viewModel = {};
- }
-
- return this.compositionEngine.createController(layoutInstruction).then(function (controller) {
- ShadowDOM.distributeView(viewPortInstruction.controller.view, controller.slots || controller.view.slots);
- controller.automate(createOverrideContext(layoutInstruction.viewModel), _this2.owningView);
- controller.view.children.push(viewPortInstruction.controller.view);
- return controller.view || controller;
- }).then(function (newView) {
- _this2.view = newView;
- return ready(newView);
- });
- }
-
- this.view = viewPortInstruction.controller.view;
-
- return ready(this.owningView);
- };
-
- RouterView.prototype._notify = function _notify() {
- if (this.compositionTransactionNotifier) {
- this.compositionTransactionNotifier.done();
- this.compositionTransactionNotifier = null;
- }
- };
-
- return RouterView;
- }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, 'swapOrder', [bindable], {
- enumerable: true,
- initializer: null
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, 'layoutView', [bindable], {
- enumerable: true,
- initializer: null
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, 'layoutViewModel', [bindable], {
- enumerable: true,
- initializer: null
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, 'layoutModel', [bindable], {
- enumerable: true,
- initializer: null
- })), _class2)) || _class) || _class));
-
- _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);
- }
- };
-});
\ No newline at end of file
diff --git a/dist/temp/aurelia-templating-router.js b/dist/temp/aurelia-templating-router.js
deleted file mode 100644
index d471896..0000000
--- a/dist/temp/aurelia-templating-router.js
+++ /dev/null
@@ -1,386 +0,0 @@
-'use strict';
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.TemplatingRouteLoader = exports.RouterViewLocator = exports.RouterView = exports.RouteHref = undefined;
-
-var _dec, _dec2, _dec3, _dec4, _class, _dec5, _class2, _desc, _value, _class3, _descriptor, _descriptor2, _descriptor3, _descriptor4, _dec6, _class5, _dec7, _class6;
-
-var _aureliaLogging = require('aurelia-logging');
-
-var LogManager = _interopRequireWildcard(_aureliaLogging);
-
-var _aureliaTemplating = require('aurelia-templating');
-
-var _aureliaRouter = require('aurelia-router');
-
-var _aureliaPal = require('aurelia-pal');
-
-var _aureliaDependencyInjection = require('aurelia-dependency-injection');
-
-var _aureliaBinding = require('aurelia-binding');
-
-var _aureliaMetadata = require('aurelia-metadata');
-
-var _aureliaPath = require('aurelia-path');
-
-function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
-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; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-function _initDefineProp(target, property, descriptor, context) {
- if (!descriptor) return;
- Object.defineProperty(target, property, {
- enumerable: descriptor.enumerable,
- configurable: descriptor.configurable,
- writable: descriptor.writable,
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
- });
-}
-
-function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
- var desc = {};
- Object['ke' + 'ys'](descriptor).forEach(function (key) {
- desc[key] = descriptor[key];
- });
- desc.enumerable = !!desc.enumerable;
- desc.configurable = !!desc.configurable;
-
- if ('value' in desc || desc.initializer) {
- desc.writable = true;
- }
-
- desc = decorators.slice().reverse().reduce(function (desc, decorator) {
- return decorator(target, property, desc) || desc;
- }, desc);
-
- if (context && desc.initializer !== void 0) {
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
- desc.initializer = undefined;
- }
-
- if (desc.initializer === void 0) {
- Object['define' + 'Property'](target, property, desc);
- desc = null;
- }
-
- return desc;
-}
-
-function _initializerWarningHelper(descriptor, context) {
- throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');
-}
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-var logger = LogManager.getLogger('route-href');
-
-var RouteHref = exports.RouteHref = (_dec = (0, _aureliaTemplating.customAttribute)('route-href'), _dec2 = (0, _aureliaTemplating.bindable)({ name: 'route', changeHandler: 'processChange', primaryProperty: true }), _dec3 = (0, _aureliaTemplating.bindable)({ name: 'params', changeHandler: 'processChange' }), _dec4 = (0, _aureliaTemplating.bindable)({ name: 'attribute', defaultValue: 'href' }), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = function () {
- RouteHref.inject = function inject() {
- return [_aureliaRouter.Router, _aureliaPal.DOM.Element];
- };
-
- function RouteHref(router, element) {
- _classCallCheck(this, RouteHref);
-
- this.router = router;
- this.element = element;
- }
-
- RouteHref.prototype.bind = function bind() {
- this.isActive = true;
- this.processChange();
- };
-
- RouteHref.prototype.unbind = function unbind() {
- this.isActive = false;
- };
-
- RouteHref.prototype.attributeChanged = function attributeChanged(value, previous) {
- if (previous) {
- this.element.removeAttribute(previous);
- }
-
- this.processChange();
- };
-
- RouteHref.prototype.processChange = function processChange() {
- var _this = this;
-
- return this.router.ensureConfigured().then(function () {
- if (!_this.isActive) {
- return null;
- }
-
- var href = _this.router.generate(_this.route, _this.params);
-
- if (_this.element.au.controller) {
- _this.element.au.controller.viewModel[_this.attribute] = href;
- } else {
- _this.element.setAttribute(_this.attribute, href);
- }
-
- return null;
- }).catch(function (reason) {
- logger.error(reason);
- });
- };
-
- return RouteHref;
-}()) || _class) || _class) || _class) || _class);
-var RouterView = exports.RouterView = (_dec5 = (0, _aureliaTemplating.customElement)('router-view'), _dec5(_class2 = (0, _aureliaTemplating.noView)(_class2 = (_class3 = function () {
- RouterView.inject = function inject() {
- return [_aureliaPal.DOM.Element, _aureliaDependencyInjection.Container, _aureliaTemplating.ViewSlot, _aureliaRouter.Router, _aureliaTemplating.ViewLocator, _aureliaTemplating.CompositionTransaction, _aureliaTemplating.CompositionEngine];
- };
-
- function RouterView(element, container, viewSlot, router, viewLocator, compositionTransaction, compositionEngine) {
- _classCallCheck(this, RouterView);
-
- _initDefineProp(this, 'swapOrder', _descriptor, this);
-
- _initDefineProp(this, 'layoutView', _descriptor2, this);
-
- _initDefineProp(this, 'layoutViewModel', _descriptor3, this);
-
- _initDefineProp(this, 'layoutModel', _descriptor4, this);
-
- this.element = element;
- this.container = container;
- this.viewSlot = viewSlot;
- this.router = router;
- this.viewLocator = viewLocator;
- this.compositionTransaction = compositionTransaction;
- this.compositionEngine = compositionEngine;
- this.router.registerViewPort(this, this.element.getAttribute('name'));
-
- if (!('initialComposition' in compositionTransaction)) {
- compositionTransaction.initialComposition = true;
- this.compositionTransactionNotifier = compositionTransaction.enlist();
- }
- }
-
- RouterView.prototype.created = function created(owningView) {
- this.owningView = owningView;
- };
-
- RouterView.prototype.bind = function bind(bindingContext, overrideContext) {
- this.container.viewModel = bindingContext;
- this.overrideContext = overrideContext;
- };
-
- RouterView.prototype.process = function process(viewPortInstruction, waitToSwap) {
- var _this2 = this;
-
- var component = viewPortInstruction.component;
- var childContainer = component.childContainer;
- var viewModel = component.viewModel;
- var viewModelResource = component.viewModelResource;
- var metadata = viewModelResource.metadata;
- var config = component.router.currentInstruction.config;
- var viewPort = config.viewPorts ? config.viewPorts[viewPortInstruction.name] || {} : {};
-
- childContainer.get(RouterViewLocator)._notify(this);
-
- var layoutInstruction = {
- viewModel: viewPort.layoutViewModel || config.layoutViewModel || this.layoutViewModel,
- view: viewPort.layoutView || config.layoutView || this.layoutView,
- model: viewPort.layoutModel || config.layoutModel || this.layoutModel,
- router: viewPortInstruction.component.router,
- childContainer: childContainer,
- viewSlot: this.viewSlot
- };
-
- var viewStrategy = this.viewLocator.getViewStrategy(component.view || viewModel);
- if (viewStrategy && component.view) {
- viewStrategy.makeRelativeTo(_aureliaMetadata.Origin.get(component.router.container.viewModel.constructor).moduleId);
- }
-
- return metadata.load(childContainer, viewModelResource.value, null, viewStrategy, true).then(function (viewFactory) {
- if (!_this2.compositionTransactionNotifier) {
- _this2.compositionTransactionOwnershipToken = _this2.compositionTransaction.tryCapture();
- }
-
- if (layoutInstruction.viewModel || layoutInstruction.view) {
- viewPortInstruction.layoutInstruction = layoutInstruction;
- }
-
- viewPortInstruction.controller = metadata.create(childContainer, _aureliaTemplating.BehaviorInstruction.dynamic(_this2.element, viewModel, viewFactory));
-
- if (waitToSwap) {
- return null;
- }
-
- _this2.swap(viewPortInstruction);
- });
- };
-
- RouterView.prototype.swap = function swap(viewPortInstruction) {
- var _this3 = this;
-
- var layoutInstruction = viewPortInstruction.layoutInstruction;
- var previousView = this.view;
-
- var work = function work() {
- var swapStrategy = _aureliaTemplating.SwapStrategies[_this3.swapOrder] || _aureliaTemplating.SwapStrategies.after;
- var viewSlot = _this3.viewSlot;
-
- swapStrategy(viewSlot, previousView, function () {
- return Promise.resolve(viewSlot.add(_this3.view));
- }).then(function () {
- _this3._notify();
- });
- };
-
- var ready = function ready(owningView) {
- viewPortInstruction.controller.automate(_this3.overrideContext, owningView);
- if (_this3.compositionTransactionOwnershipToken) {
- return _this3.compositionTransactionOwnershipToken.waitForCompositionComplete().then(function () {
- _this3.compositionTransactionOwnershipToken = null;
- return work();
- });
- }
-
- return work();
- };
-
- if (layoutInstruction) {
- if (!layoutInstruction.viewModel) {
- layoutInstruction.viewModel = {};
- }
-
- return this.compositionEngine.createController(layoutInstruction).then(function (controller) {
- _aureliaTemplating.ShadowDOM.distributeView(viewPortInstruction.controller.view, controller.slots || controller.view.slots);
- controller.automate((0, _aureliaBinding.createOverrideContext)(layoutInstruction.viewModel), _this3.owningView);
- controller.view.children.push(viewPortInstruction.controller.view);
- return controller.view || controller;
- }).then(function (newView) {
- _this3.view = newView;
- return ready(newView);
- });
- }
-
- this.view = viewPortInstruction.controller.view;
-
- return ready(this.owningView);
- };
-
- RouterView.prototype._notify = function _notify() {
- if (this.compositionTransactionNotifier) {
- this.compositionTransactionNotifier.done();
- this.compositionTransactionNotifier = null;
- }
- };
-
- return RouterView;
-}(), (_descriptor = _applyDecoratedDescriptor(_class3.prototype, 'swapOrder', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor2 = _applyDecoratedDescriptor(_class3.prototype, 'layoutView', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor3 = _applyDecoratedDescriptor(_class3.prototype, 'layoutViewModel', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-}), _descriptor4 = _applyDecoratedDescriptor(_class3.prototype, 'layoutModel', [_aureliaTemplating.bindable], {
- enumerable: true,
- initializer: null
-})), _class3)) || _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 EmptyClass = (_dec6 = (0, _aureliaTemplating.inlineView)(''), _dec6(_class5 = function EmptyClass() {
- _classCallCheck(this, EmptyClass);
-}) || _class5);
-var TemplatingRouteLoader = exports.TemplatingRouteLoader = (_dec7 = (0, _aureliaDependencyInjection.inject)(_aureliaTemplating.CompositionEngine), _dec7(_class6 = function (_RouteLoader) {
- _inherits(TemplatingRouteLoader, _RouteLoader);
-
- function TemplatingRouteLoader(compositionEngine) {
- _classCallCheck(this, TemplatingRouteLoader);
-
- var _this5 = _possibleConstructorReturn(this, _RouteLoader.call(this));
-
- _this5.compositionEngine = compositionEngine;
- return _this5;
- }
-
- TemplatingRouteLoader.prototype.loadRoute = function loadRoute(router, config) {
- var childContainer = router.container.createChild();
-
- var viewModel = void 0;
- if (config.moduleId === null) {
- viewModel = EmptyClass;
- } else if (/\.html/i.test(config.moduleId)) {
- viewModel = createDynamicClass(config.moduleId);
- } else {
- viewModel = (0, _aureliaPath.relativeToFile)(config.moduleId, _aureliaMetadata.Origin.get(router.container.viewModel.constructor).moduleId);
- }
-
- var instruction = {
- viewModel: viewModel,
- childContainer: childContainer,
- view: config.view || config.viewStrategy,
- router: router
- };
-
- childContainer.registerSingleton(RouterViewLocator);
-
- childContainer.getChildRouter = function () {
- var childRouter = void 0;
-
- childContainer.registerHandler(_aureliaRouter.Router, function (c) {
- return childRouter || (childRouter = router.createChild(childContainer));
- });
-
- return childContainer.get(_aureliaRouter.Router);
- };
-
- return this.compositionEngine.ensureViewModel(instruction);
- };
-
- return TemplatingRouteLoader;
-}(_aureliaRouter.RouteLoader)) || _class6);
-
-
-function createDynamicClass(moduleId) {
- var _dec8, _dec9, _class7;
-
- var name = /([^\/^\?]+)\.html/i.exec(moduleId)[1];
-
- var DynamicClass = (_dec8 = (0, _aureliaTemplating.customElement)(name), _dec9 = (0, _aureliaTemplating.useView)(moduleId), _dec8(_class7 = _dec9(_class7 = function () {
- function DynamicClass() {
- _classCallCheck(this, DynamicClass);
- }
-
- DynamicClass.prototype.bind = function bind(bindingContext) {
- this.$parent = bindingContext;
- };
-
- return DynamicClass;
- }()) || _class7) || _class7);
-
-
- return DynamicClass;
-}
\ No newline at end of file
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 7ca9c75..83a99f7 100644
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -2,7 +2,7 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
-# [1.5.0](https://github.com/aurelia/templating-router/compare/1.3.3...1.5.0) (2019-05-02)
+# [1.4.0](https://github.com/aurelia/templating-router/compare/1.3.3...1.5.0) (2019-05-02)
### Bug Fixes
diff --git a/package-lock.json b/package-lock.json
index cd7c84c..ab89c60 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "aurelia-templating-router",
- "version": "1.5.0",
+ "version": "1.4.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index a764c51..1186be3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "aurelia-templating-router",
- "version": "1.5.0",
+ "version": "1.4.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.",
"keywords": [
"aurelia",
@@ -27,7 +27,7 @@
"test:debugger": "karma start --browsers ChromeDebugging",
"lint": "tslint -c tslint.json '{src,test}/**/*.ts' --force",
"precut-release": "npm run test",
- "cut-release": "standard-version -t \"\" -i doc/CHANGELOG.md"
+ "cut-release": "standard-version -t \"\" -i doc/CHANGELOG.md && npm run build"
},
"typings": "dist/aurelia-templating-router.d.ts",
"repository": {