diff --git a/dist/amd/aurelia-router.js.map b/dist/amd/aurelia-router.js.map index d062b0a2..cd8f6459 100644 --- a/dist/amd/aurelia-router.js.map +++ b/dist/amd/aurelia-router.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\nimport { Router } from './router';\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\n\n/**\n * Initialization options for a navigation instruction\n */\nexport interface NavigationInstructionInit {\n fragment: string;\n queryString?: string;\n params?: Record;\n queryParams?: Record;\n config: RouteConfig;\n parentInstruction?: NavigationInstruction;\n previousInstruction?: NavigationInstruction;\n router: Router;\n options?: Object;\n plan?: Record;\n}\n\nexport interface ViewPortInstructionInit {\n name: string;\n strategy: ActivationStrategyType;\n moduleId: string;\n component: ViewPortComponent;\n}\n\n/**\n * Class used to represent an instruction during a navigation.\n */\nexport class NavigationInstruction {\n /**\n * The URL fragment.\n */\n fragment: string;\n\n /**\n * The query string.\n */\n queryString: string;\n\n /**\n * Parameters extracted from the route pattern.\n */\n params: any;\n\n /**\n * Parameters extracted from the query string.\n */\n queryParams: any;\n\n /**\n * The route config for the route matching this instruction.\n */\n config: RouteConfig;\n\n /**\n * The parent instruction, if this instruction was created by a child router.\n */\n parentInstruction: NavigationInstruction;\n\n parentCatchHandler: any;\n\n /**\n * The instruction being replaced by this instruction in the current router.\n */\n previousInstruction: NavigationInstruction;\n\n /**\n * viewPort instructions to used activation.\n */\n viewPortInstructions: Record;\n\n /**\n * The router instance.\n */\n router: Router;\n\n /**\n * Current built viewport plan of this nav instruction\n */\n plan: Record = null;\n\n options: Record = {};\n\n /**@internal */\n lifecycleArgs: LifecycleArguments;\n /**@internal */\n resolve?: (val?: any) => void;\n\n constructor(init: NavigationInstructionInit) {\n Object.assign(this, init);\n\n this.params = this.params || {};\n this.viewPortInstructions = {};\n\n let ancestorParams = [];\n let current: NavigationInstruction = this;\n do {\n let currentParams = Object.assign({}, current.params);\n if (current.config && current.config.hasChildRouter) {\n // remove the param for the injected child route segment\n delete currentParams[current.getWildCardName()];\n }\n\n ancestorParams.unshift(currentParams);\n current = current.parentInstruction;\n } while (current);\n\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\n this.lifecycleArgs = [allParams, this.config, this];\n }\n\n /**\n * Gets an array containing this instruction and all child instructions for the current navigation.\n */\n getAllInstructions(): Array {\n let instructions: NavigationInstruction[] = [this];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let key in viewPortInstructions) {\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\n if (childInstruction) {\n instructions.push(...childInstruction.getAllInstructions());\n }\n }\n\n return instructions;\n }\n\n /**\n * Gets an array containing the instruction and all child instructions for the previous navigation.\n * Previous instructions are no longer available after navigation completes.\n */\n getAllPreviousInstructions(): Array {\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\n }\n\n /**\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\n */\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\n addViewPortInstruction(\n nameOrInitOptions: string | ViewPortInstructionInit,\n strategy?: ActivationStrategyType,\n moduleId?: string,\n component?: any\n ): /*ViewPortInstruction*/ any {\n\n let viewPortInstruction: ViewPortInstruction;\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\n const lifecycleArgs = this.lifecycleArgs;\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\n\n if (typeof nameOrInitOptions === 'string') {\n viewPortInstruction = {\n name: nameOrInitOptions,\n strategy: strategy,\n moduleId: moduleId,\n component: component,\n childRouter: component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n } else {\n viewPortInstruction = {\n name: viewPortName,\n strategy: nameOrInitOptions.strategy,\n component: nameOrInitOptions.component,\n moduleId: nameOrInitOptions.moduleId,\n childRouter: nameOrInitOptions.component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n }\n\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\n }\n\n /**\n * Gets the name of the route pattern's wildcard parameter, if applicable.\n */\n getWildCardName(): string {\n // todo: potential issue, or at least unsafe typings\n let configRoute = this.config.route as string;\n let wildcardIndex = configRoute.lastIndexOf('*');\n return configRoute.substr(wildcardIndex + 1);\n }\n\n /**\n * Gets the path and query string created by filling the route\n * pattern's wildcard parameter with the matching param.\n */\n getWildcardPath(): string {\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n let queryString = this.queryString;\n\n if (queryString) {\n path += '?' + queryString;\n }\n\n return path;\n }\n\n /**\n * Gets the instruction's base URL, accounting for wildcard route parameters.\n */\n getBaseUrl(): string {\n let $encodeURI = encodeURI;\n let fragment = decodeURI(this.fragment);\n\n if (fragment === '') {\n let nonEmptyRoute = this.router.routes.find(route => {\n return route.name === this.config.name &&\n route.route !== '';\n });\n if (nonEmptyRoute) {\n fragment = nonEmptyRoute.route as any;\n }\n }\n\n if (!this.params) {\n return $encodeURI(fragment);\n }\n\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n\n if (!path) {\n return $encodeURI(fragment);\n }\n\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\n }\n\n /**\n * Finalize a viewport instruction\n * @internal\n */\n _commitChanges(waitToSwap: boolean): Promise {\n let router = this.router;\n router.currentInstruction = this;\n\n const previousInstruction = this.previousInstruction;\n if (previousInstruction) {\n previousInstruction.config.navModel.isActive = false;\n }\n\n this.config.navModel.isActive = true;\n\n router.refreshNavigation();\n\n let loads: Promise[] = [];\n let delaySwaps: ISwapPlan[] = [];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let viewPort = router.viewPorts[viewPortName];\n\n if (!viewPort) {\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\n }\n\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n } else {\n if (waitToSwap) {\n delaySwaps.push({ viewPort, viewPortInstruction });\n }\n loads.push(\n viewPort\n .process(viewPortInstruction, waitToSwap)\n .then(() => childNavInstruction\n ? childNavInstruction._commitChanges(waitToSwap)\n : Promise.resolve()\n )\n );\n }\n } else {\n if (childNavInstruction) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n }\n }\n }\n\n return Promise\n .all(loads)\n .then(() => {\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\n return null;\n })\n .then(() => prune(this));\n }\n\n /**@internal */\n _updateTitle(): void {\n let router = this.router;\n let title = this._buildTitle(router.titleSeparator);\n if (title) {\n router.history.setTitle(title);\n }\n }\n\n /**@internal */\n _buildTitle(separator: string = ' | '): string {\n let title = '';\n let childTitles = [];\n let navModelTitle = this.config.navModel.title;\n let instructionRouter = this.router;\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n if (navModelTitle) {\n title = instructionRouter.transformTitle(navModelTitle);\n }\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\n\n if (child_nav_instruction) {\n let childTitle = child_nav_instruction._buildTitle(separator);\n if (childTitle) {\n childTitles.push(childTitle);\n }\n }\n }\n\n if (childTitles.length) {\n title = childTitles.join(separator) + (title ? separator : '') + title;\n }\n\n if (instructionRouter.title) {\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\n }\n\n return title;\n }\n}\n\nconst prune = (instruction: NavigationInstruction): void => {\n instruction.previousInstruction = null;\n instruction.plan = null;\n};\n\ninterface ISwapPlan {\n viewPort: ViewPort;\n viewPortInstruction: ViewPortInstruction;\n}\n","import { Router } from './router';\nimport { RouteConfig } from './interfaces';\n\n/**\n* Class for storing and interacting with a route's navigation settings.\n*/\nexport class NavModel {\n\n /**\n * True if this nav item is currently active.\n */\n isActive: boolean = false;\n\n /**\n * The title.\n */\n title: string = null;\n\n /**\n * This nav item's absolute href.\n */\n href: string = null;\n\n /**\n * This nav item's relative href.\n */\n relativeHref: string = null;\n\n /**\n * Data attached to the route at configuration time.\n */\n settings: any = {};\n\n /**\n * The route config.\n */\n config: RouteConfig = null;\n\n /**\n * The router associated with this navigation model.\n */\n router: Router;\n\n order: number | boolean;\n\n constructor(router: Router, relativeHref: string) {\n this.router = router;\n this.relativeHref = relativeHref;\n }\n\n /**\n * Sets the route's title and updates document.title.\n * If the a navigation is in progress, the change will be applied\n * to document.title when the navigation completes.\n *\n * @param title The new title.\n */\n setTitle(title: string): void {\n this.title = title;\n\n if (this.isActive) {\n this.router.updateTitle();\n }\n }\n}\n","import { RouteConfig } from './interfaces';\n\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\n if (!hasPushState && path[0] !== '#') {\n path = '#' + path;\n }\n\n if (hasPushState && absolute) {\n path = path.substring(1, path.length);\n }\n\n return path;\n}\n\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\n if (isAbsoluteUrl.test(fragment)) {\n return fragment;\n }\n\n let path = '';\n\n if (baseUrl.length && baseUrl[0] !== '/') {\n path += '/';\n }\n\n path += baseUrl;\n\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\n path += '/';\n }\n\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\n path = path.substring(0, path.length - 1);\n }\n\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\n}\n\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\n if (isRootedPath.test(fragment)) {\n return _normalizeAbsolutePath(fragment, hasPushState);\n }\n\n return _createRootedPath(fragment, baseUrl, hasPushState);\n}\n\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\n let routeConfigs = [];\n\n if (Array.isArray(config.route)) {\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\n let current = Object.assign({}, config);\n current.route = config.route[i];\n routeConfigs.push(current);\n }\n } else {\n routeConfigs.push(Object.assign({}, config));\n }\n\n return routeConfigs;\n}\n\nconst isRootedPath = /^#?\\//;\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\nimport { Router } from './router';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * Class used to configure a [[Router]] instance.\n *\n * @constructor\n */\nexport class RouterConfiguration {\n instructions: Array<(router: Router) => void> = [];\n options: {\n [key: string]: any;\n compareQueryParams?: boolean;\n root?: string;\n pushState?: boolean;\n hashChange?: boolean;\n silent?: boolean;\n } = {};\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\n title: string;\n titleSeparator: string;\n unknownRouteConfig: RouteConfigSpecifier;\n viewPortDefaults: Record;\n\n /**@internal */\n _fallbackRoute: string;\n\n /**\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\n *\n * @param name The name of the pipeline slot to insert the step into.\n * @param step The pipeline step.\n * @chainable\n */\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\n if (step === null || step === undefined) {\n throw new Error('Pipeline step cannot be null or undefined.');\n }\n this.pipelineSteps.push({ name, step });\n return this;\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\n }\n\n /**\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @chainable\n */\n fallbackRoute(fragment: string): RouterConfiguration {\n this._fallbackRoute = fragment;\n return this;\n }\n\n /**\n * Maps one or more routes to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\n * @chainable\n */\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\n if (Array.isArray(route)) {\n route.forEach(r => this.map(r));\n return this;\n }\n\n return this.mapRoute(route);\n }\n\n /**\n * Configures defaults to use for any view ports.\n *\n * @param viewPortConfig a view port configuration object to use as a\n * default, of the form { viewPortName: { moduleId } }.\n * @chainable\n */\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\n this.viewPortDefaults = viewPortConfig;\n return this;\n }\n\n /**\n * Maps a single route to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map.\n * @chainable\n */\n mapRoute(config: RouteConfig): RouterConfiguration {\n this.instructions.push(router => {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n\n let navModel;\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\n let routeConfig = routeConfigs[i];\n routeConfig.settings = routeConfig.settings || {};\n if (!navModel) {\n navModel = router.createNavModel(routeConfig);\n }\n\n router.addRoute(routeConfig, navModel);\n }\n });\n\n return this;\n }\n\n /**\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\n *\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\n * [[NavigationInstruction]] and selects a moduleId to load.\n * @chainable\n */\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\n this.unknownRouteConfig = config;\n return this;\n }\n\n /**\n * Applies the current configuration to the specified [[Router]].\n *\n * @param router The [[Router]] to apply the configuration to.\n */\n exportToRouter(router: Router): void {\n let instructions = this.instructions;\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\n instructions[i](router);\n }\n\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\n\n if (title) {\n router.title = title;\n }\n\n if (titleSeparator) {\n router.titleSeparator = titleSeparator;\n }\n\n if (unknownRouteConfig) {\n router.handleUnknownRoutes(unknownRouteConfig);\n }\n\n if (_fallbackRoute) {\n router.fallbackRoute = _fallbackRoute;\n }\n\n if (viewPortDefaults) {\n router.useViewPortDefaults(viewPortDefaults);\n }\n\n Object.assign(router.options, this.options);\n\n let pipelineSteps = this.pipelineSteps;\n let pipelineStepCount = pipelineSteps.length;\n if (pipelineStepCount) {\n if (!router.isRoot) {\n throw new Error('Pipeline steps can only be added to the root router');\n }\n\n let pipelineProvider = router.pipelineProvider;\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\n let { name, step } = pipelineSteps[i];\n pipelineProvider.addStep(name, step);\n }\n }\n }\n}\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): boolean {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): boolean {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\n\n/**@internal exported for unit testing */\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\n let index = -1;\n const next: Next = function() {\n index++;\n\n if (index < steps.length) {\n let currentStep = steps[index];\n\n try {\n return currentStep(instruction, next);\n } catch (e) {\n return next.reject(e);\n }\n } else {\n return next.complete();\n }\n } as Next;\n\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\n\n return next;\n};\n\n/**@internal exported for unit testing */\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\n return (output: any) => Promise\n .resolve({\n status,\n output,\n completed: status === PipelineStatus.Completed\n });\n};\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { createNextFn } from './next';\n\n/**\n * The class responsible for managing and processing the navigation pipeline.\n */\nexport class Pipeline {\n /**\n * The pipeline steps. And steps added via addStep will be converted to a function\n * The actualy running functions with correct step contexts of this pipeline\n */\n steps: StepRunnerFunction[] = [];\n\n /**\n * Adds a step to the pipeline.\n *\n * @param step The pipeline step.\n */\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\n let run;\n\n if (typeof step === 'function') {\n run = step;\n } else if (typeof step.getSteps === 'function') {\n // getSteps is to enable support open slots\n // where devs can add multiple steps into the same slot name\n let steps = step.getSteps();\n for (let i = 0, l = steps.length; i < l; i++) {\n this.addStep(steps[i]);\n }\n\n return this;\n } else {\n run = (step as PipelineStep).run.bind(step);\n }\n\n this.steps.push(run);\n\n return this;\n }\n\n /**\n * Runs the pipeline.\n *\n * @param instruction The navigation instruction to process.\n */\n run(instruction: NavigationInstruction): Promise {\n const nextFn = createNextFn(instruction, this.steps);\n return nextFn();\n }\n}\n","import { NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface NavigationOptions {\n useAppRouter?: boolean;\n }\n}\n\n/**\n* When a navigation command is encountered, the current navigation\n* will be cancelled and control will be passed to the navigation\n* command so it can determine the correct action.\n*/\nexport interface NavigationCommand {\n navigate: (router: Router) => void;\n /**@internal */\n shouldContinueProcessing?: boolean;\n /**@internal */\n setRouter?: (router: Router) => void;\n}\n\n/**\n* Determines if the provided object is a navigation command.\n* A navigation command is anything with a navigate method.\n*\n* @param obj The object to check.\n*/\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\n return obj && typeof obj.navigate === 'function';\n}\n\n/**\n* Used during the activation lifecycle to cause a redirect.\n*/\nexport class Redirect implements NavigationCommand {\n\n url: string;\n /**@internal */\n options: NavigationOptions;\n /**@internal */\n shouldContinueProcessing: boolean;\n\n private router: Router;\n\n /**\n * @param url The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n constructor(url: string, options: NavigationOptions = {}) {\n this.url = url;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigate(this.url, this.options);\n }\n}\n\n/**\n * Used during the activation lifecycle to cause a redirect to a named route.\n */\nexport class RedirectToRoute implements NavigationCommand {\n\n route: string;\n params: any;\n /**@internal */\n options: NavigationOptions;\n\n /**@internal */\n shouldContinueProcessing: boolean;\n\n /**@internal */\n router: Router;\n\n /**\n * @param route The name of the route.\n * @param params The parameters to be sent to the activation method.\n * @param options The options to use for navigation.\n */\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\n this.route = route;\n this.params = params;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\n }\n}\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\n\ntype ViewPortPlansRecord = Record;\n\n/**\n * @internal exported for unit testing\n */\nexport function _buildNavigationPlan(\n instruction: NavigationInstruction,\n forceLifecycleMinimum?: boolean\n): Promise {\n let config = instruction.config;\n\n if ('redirect' in config) {\n return buildRedirectPlan(instruction);\n }\n\n const prevInstruction = instruction.previousInstruction;\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\n\n if (prevInstruction) {\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\n }\n\n // first navigation, only need to prepare a few information for each viewport plan\n const viewPortPlans: ViewPortPlansRecord = {};\n let viewPortConfigs = config.viewPorts;\n for (let viewPortName in viewPortConfigs) {\n let viewPortConfig = viewPortConfigs[viewPortName];\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n viewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n viewPortPlans[viewPortName] = {\n name: viewPortName,\n strategy: InternalActivationStrategy.Replace,\n config: viewPortConfig\n };\n }\n\n return Promise.resolve(viewPortPlans);\n}\n\n/**\n * Build redirect plan based on config of a navigation instruction\n * @internal exported for unit testing\n */\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\n const config = instruction.config;\n const router = instruction.router;\n return router\n ._createNavigationInstruction(config.redirect)\n .then(redirectInstruction => {\n\n const params: Record = {};\n const originalInstructionParams = instruction.params;\n const redirectInstructionParams = redirectInstruction.params;\n\n for (let key in redirectInstructionParams) {\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\n let val = redirectInstructionParams[key];\n if (typeof val === 'string' && val[0] === ':') {\n val = val.slice(1);\n // And if that param is found on the original instruction then use it\n if (val in originalInstructionParams) {\n params[key] = originalInstructionParams[val];\n }\n } else {\n params[key] = redirectInstructionParams[key];\n }\n }\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\n\n // Special handling for child routes\n for (let key in originalInstructionParams) {\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\n }\n\n let queryString = instruction.queryString;\n if (queryString) {\n redirectLocation += '?' + queryString;\n }\n\n return Promise.resolve(new Redirect(redirectLocation));\n });\n};\n\n/**\n * @param viewPortPlans the Plan record that holds information about built plans\n * @internal exported for unit testing\n */\nexport const buildTransitionPlans = (\n currentInstruction: NavigationInstruction,\n previousInstruction: NavigationInstruction,\n defaultViewPortConfigs: Record,\n forceLifecycleMinimum?: boolean\n): Promise => {\n\n let viewPortPlans: ViewPortPlansRecord = {};\n let newInstructionConfig = currentInstruction.config;\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\n let pending: Promise[] = [];\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\n\n for (let viewPortName in previousViewPortInstructions) {\n\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\n const prevViewPortComponent = prevViewPortInstruction.component;\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\n\n // if this is invoked on a viewport without any changes, based on new url,\n // newViewPortConfig will be the existing viewport instruction\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\n ? newInstructionViewPortConfigs[viewPortName]\n : prevViewPortInstruction;\n\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n\n const viewPortActivationStrategy = determineActivationStrategy(\n currentInstruction,\n prevViewPortInstruction,\n nextViewPortConfig,\n hasNewParams,\n forceLifecycleMinimum\n );\n const viewPortPlan = viewPortPlans[viewPortName] = {\n name: viewPortName,\n // ViewPortInstruction can quack like a RouteConfig\n config: nextViewPortConfig as RouteConfig,\n prevComponent: prevViewPortComponent,\n prevModuleId: prevViewPortInstruction.moduleId,\n strategy: viewPortActivationStrategy\n } as ViewPortPlan;\n\n // recursively build nav plans for all existing child routers/viewports of this viewport\n // this is possible because existing child viewports and routers already have necessary information\n // to process the wildcard path from parent instruction\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\n const path = currentInstruction.getWildcardPath();\n const task: Promise = prevViewPortInstruction\n .childRouter\n ._createNavigationInstruction(path, currentInstruction)\n .then((childInstruction: NavigationInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(\n childInstruction,\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\n // if so, can just use local variable viewPortPlanStrategy\n // there could be user code modifying viewport plan during _createNavigationInstruction?\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\n )\n .then(childPlan => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n // for bluebird ?\n return null;\n });\n });\n\n pending.push(task);\n }\n }\n\n return Promise.all(pending).then(() => viewPortPlans);\n};\n\n/**\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\n * @internal exported for unit testing\n */\nexport const determineActivationStrategy = (\n currentNavInstruction: NavigationInstruction,\n prevViewPortInstruction: ViewPortInstruction,\n newViewPortConfig: RouteConfig | ViewPortInstruction,\n // indicates whether there is difference between old and new url params\n hasNewParams: boolean,\n forceLifecycleMinimum?: boolean\n): ActivationStrategyType => {\n\n let newInstructionConfig = currentNavInstruction.config;\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\n let viewPortPlanStrategy: ActivationStrategyType;\n\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\n } else if (newInstructionConfig.activationStrategy) {\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\n } else if (hasNewParams || forceLifecycleMinimum) {\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\n } else {\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\n }\n return viewPortPlanStrategy;\n};\n\n/**@internal exported for unit testing */\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\n let prevParams = prev.params;\n let nextParams = next.params;\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\n\n for (let key in nextParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n for (let key in prevParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n if (!next.options.compareQueryParams) {\n return false;\n }\n\n let prevQueryParams = prev.queryParams;\n let nextQueryParams = next.queryParams;\n for (let key in nextQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n for (let key in prevQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n return false;\n};\n","import { Next } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\n\n/**\n * Transform a navigation instruction into viewport plan record object,\n * or a redirect request if user viewmodel demands\n */\nexport class BuildNavigationPlanStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return _buildNavigationPlan(navigationInstruction)\n .then(plan => {\n if (plan instanceof Redirect) {\n return next.cancel(plan);\n }\n navigationInstruction.plan = plan;\n return next();\n })\n .catch(next.cancel);\n }\n}\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\nimport { InternalActivationStrategy } from './activation-strategy';\nimport { RouteLoader } from './route-loader';\n\n/**\n * Loading plan calculated based on a navigration-instruction and a viewport plan\n */\ninterface ILoadingPlan {\n viewPortPlan: ViewPortPlan;\n navigationInstruction: NavigationInstruction;\n}\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadNewRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction\n): Promise => {\n let loadingPlans = determineLoadingPlans(navigationInstruction);\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\n routeLoader,\n loadingPlan.navigationInstruction,\n loadingPlan.viewPortPlan\n ));\n\n return Promise.all(loadPromises);\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const determineLoadingPlans = (\n navigationInstruction: NavigationInstruction,\n loadingPlans: ILoadingPlan[] = []\n): ILoadingPlan[] => {\n let viewPortPlans: Record = navigationInstruction.plan;\n\n for (let viewPortName in viewPortPlans) {\n let viewPortPlan = viewPortPlans[viewPortName];\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\n\n if (childNavInstruction) {\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n } else {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortName,\n strategy: viewPortPlan.strategy,\n moduleId: viewPortPlan.prevModuleId,\n component: viewPortPlan.prevComponent\n }) as ViewPortInstruction;\n\n if (childNavInstruction) {\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n }\n }\n\n return loadingPlans;\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n viewPortPlan: ViewPortPlan\n): Promise => {\n let planConfig = viewPortPlan.config;\n let moduleId = planConfig ? planConfig.moduleId : null;\n\n return loadComponent(routeLoader, navigationInstruction, planConfig)\n .then((component) => {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortPlan.name,\n strategy: viewPortPlan.strategy,\n moduleId: moduleId,\n component: component\n }) as ViewPortInstruction;\n\n let childRouter = component.childRouter;\n if (childRouter) {\n let path = navigationInstruction.getWildcardPath();\n\n return childRouter\n ._createNavigationInstruction(path, navigationInstruction)\n .then((childInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(childInstruction)\n .then((childPlan) => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n viewPortInstruction.childNavigationInstruction = childInstruction;\n\n return loadNewRoute(routeLoader, childInstruction);\n });\n });\n }\n // ts complains without this, though they are same\n return void 0;\n });\n};\n\n/**\n * Load a routed-component based on navigation instruction and route config\n * @internal exported for unit testing only\n */\nexport const loadComponent = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n config: RouteConfig\n): Promise => {\n let router = navigationInstruction.router;\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\n\n return Promise.resolve()\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\n .then(\n /**\n * @param component an object carrying information about loaded route\n * typically contains information about view model, childContainer, view and router\n */\n (component: ViewPortComponent) => {\n let { viewModel, childContainer } = component;\n component.router = router;\n component.config = config;\n\n if ('configureRouter' in viewModel) {\n let childRouter = childContainer.getChildRouter();\n component.childRouter = childRouter;\n\n return childRouter\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\n .then(() => component);\n }\n\n return component;\n }\n );\n};\n","import { RouteConfig } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Router } from './router';\n\n/**\n * Abstract class that is responsible for loading view / view model from a route config\n * The default implementation can be found in `aurelia-templating-router`\n */\nexport class RouteLoader {\n /**\n * Load a route config based on its viewmodel / view configuration\n */\n // return typing: return typings used to be never\n // as it was a throw. Changing it to Promise should not cause any issues\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\n }\n}\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { loadNewRoute } from './utilities-route-loading';\nimport { RouteLoader } from './route-loader';\n/**\n * A pipeline step responsible for loading a route config of a navigation instruction\n */\nexport class LoadRouteStep {\n /**@internal */\n static inject() { return [RouteLoader]; }\n /**\n * Route loader isntance that will handle loading route config\n * @internal\n */\n routeLoader: RouteLoader;\n constructor(routeLoader: RouteLoader) {\n this.routeLoader = routeLoader;\n }\n /**\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\n */\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return loadNewRoute(this.routeLoader, navigationInstruction)\n .then(next, next.cancel);\n }\n}\n","import { NavigationInstruction } from './navigation-instruction';\n\n/**\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\n */\nexport class CommitChangesStep {\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\n return navigationInstruction\n ._commitChanges(/*wait to swap?*/ true)\n .then(() => {\n navigationInstruction._updateTitle();\n return next();\n });\n }\n}\n","/**\n * An optional interface describing the available activation strategies.\n * @internal Used internally.\n */\nexport const enum InternalActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n NoChange = 'no-change',\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n InvokeLifecycle = 'invoke-lifecycle',\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n Replace = 'replace'\n}\n\n/**\n * The strategy to use when activating modules during navigation.\n */\n// kept for compat reason\nexport const activationStrategy: ActivationStrategy = {\n noChange: InternalActivationStrategy.NoChange,\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\n replace: InternalActivationStrategy.Replace\n};\n\n/**\n * An optional interface describing the available activation strategies.\n */\nexport interface ActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n noChange: 'no-change';\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n invokeLifecycle: 'invoke-lifecycle';\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n replace: 'replace';\n}\n\n/**\n * Enum like type for activation strategy built-in values\n */\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\nimport { isNavigationCommand } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { activationStrategy } from './activation-strategy';\nimport { Router } from './router';\n\n/**\n * Recursively find list of deactivate-able view models\n * and invoke the either 'canDeactivate' or 'deactivate' on each\n * @internal exported for unit testing\n */\nexport const processDeactivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canDeactivate' | 'deactivate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let plan: Record = navigationInstruction.plan;\n let infos = findDeactivatable(plan, callbackName);\n let i = infos.length; // query from inside out\n\n function inspect(val: any): Promise {\n if (ignoreResult || shouldContinue(val)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n if (i--) {\n try {\n let viewModel = infos[i];\n let result = viewModel[callbackName](navigationInstruction);\n return processPotential(result, inspect, next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n navigationInstruction.router.couldDeactivate = true;\n\n return next();\n }\n\n return iterate();\n};\n\n/**\n * Recursively find and returns a list of deactivate-able view models\n * @internal exported for unit testing\n */\nexport const findDeactivatable = (\n plan: Record,\n callbackName: string,\n list: IActivatableInfo[] = []\n): any[] => {\n for (let viewPortName in plan) {\n let viewPortPlan = plan[viewPortName];\n let prevComponent = viewPortPlan.prevComponent;\n\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\n && prevComponent\n ) {\n let viewModel = prevComponent.viewModel;\n\n if (callbackName in viewModel) {\n list.push(viewModel);\n }\n }\n\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\n addPreviousDeactivatable(prevComponent, callbackName, list);\n } else if (viewPortPlan.childNavigationInstruction) {\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\n }\n }\n\n return list;\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const addPreviousDeactivatable = (\n component: ViewPortComponent,\n callbackName: string,\n list: IActivatableInfo[]\n): void => {\n let childRouter = component.childRouter;\n\n if (childRouter && childRouter.currentInstruction) {\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let prevComponent = viewPortInstruction.component;\n let prevViewModel = prevComponent.viewModel;\n\n if (callbackName in prevViewModel) {\n list.push(prevViewModel);\n }\n\n addPreviousDeactivatable(prevComponent, callbackName, list);\n }\n }\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const processActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let infos = findActivatable(navigationInstruction, callbackName);\n let length = infos.length;\n let i = -1; // query from top down\n\n function inspect(val: any, router: Router): Promise {\n if (ignoreResult || shouldContinue(val, router)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n i++;\n\n if (i < length) {\n try {\n let current = infos[i];\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n return next();\n }\n\n return iterate();\n};\n\ninterface IActivatableInfo {\n viewModel: any;\n lifecycleArgs: LifecycleArguments;\n router: Router;\n}\n\n/**\n * Find list of activatable view model and add to list (3rd parameter)\n * @internal exported for unit testing\n */\nexport const findActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n list: IActivatableInfo[] = [],\n router?: Router\n): IActivatableInfo[] => {\n let plan: Record = navigationInstruction.plan;\n\n Object\n .keys(plan)\n .forEach((viewPortName) => {\n let viewPortPlan = plan[viewPortName];\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\n let viewPortComponent = viewPortInstruction.component;\n let viewModel = viewPortComponent.viewModel;\n\n if (\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\n || viewPortPlan.strategy === activationStrategy.replace\n )\n && callbackName in viewModel\n ) {\n list.push({\n viewModel,\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\n router\n });\n }\n\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (childNavInstruction) {\n findActivatable(\n childNavInstruction,\n callbackName,\n list,\n viewPortComponent.childRouter || router\n );\n }\n });\n\n return list;\n};\n\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\n if (output instanceof Error) {\n return false;\n }\n\n if (isNavigationCommand(output)) {\n if (typeof output.setRouter === 'function') {\n output.setRouter(router);\n }\n\n return !!output.shouldContinueProcessing;\n }\n\n if (output === undefined) {\n return true;\n }\n\n return output;\n};\n\n/**\n * A basic interface for an Observable type\n */\nexport interface IObservable {\n subscribe(sub?: IObservableConfig): ISubscription;\n}\n\nexport interface IObservableConfig {\n next(): void;\n error(err?: any): void;\n complete(): void;\n}\n\n/**\n * A basic interface for a Subscription to an Observable\n */\ninterface ISubscription {\n unsubscribe(): void;\n}\n\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\n\n/**\n * wraps a subscription, allowing unsubscribe calls even if\n * the first value comes synchronously\n */\nclass SafeSubscription {\n\n private _subscribed: boolean;\n private _subscription: ISubscription;\n\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\n this._subscribed = true;\n this._subscription = subscriptionFunc(this);\n\n if (!this._subscribed) {\n this.unsubscribe();\n }\n }\n\n get subscribed(): boolean {\n return this._subscribed;\n }\n\n unsubscribe(): void {\n if (this._subscribed && this._subscription) {\n this._subscription.unsubscribe();\n }\n\n this._subscribed = false;\n }\n}\n\n/**\n * A function to process return value from `activate`/`canActivate` steps\n * Supports observable/promise\n *\n * For observable, resolve at first next() or on complete()\n */\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\n // if promise like\n if (obj && typeof obj.then === 'function') {\n return Promise.resolve(obj).then(resolve).catch(reject);\n }\n\n // if observable\n if (obj && typeof obj.subscribe === 'function') {\n let obs: IObservable = obj;\n return new SafeSubscription(sub => obs.subscribe({\n next() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n },\n error(error) {\n if (sub.subscribed) {\n sub.unsubscribe();\n reject(error);\n }\n },\n complete() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n }\n }));\n }\n\n // else just resolve\n try {\n return resolve(obj);\n } catch (error) {\n return reject(error);\n }\n};\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { processDeactivatable, processActivatable } from './utilities-activation';\n\n/**\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\n */\nexport class CanDeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\n */\nexport class CanActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'canActivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\n */\nexport class DeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\n */\nexport class ActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'activate', next, true);\n }\n}\n","import { Container } from 'aurelia-dependency-injection';\nimport { Pipeline } from './pipeline';\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\nimport { LoadRouteStep } from './step-load-route';\nimport { CommitChangesStep } from './step-commit-changes';\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\n */\nclass PipelineSlot implements IPipelineSlot {\n\n /**@internal */\n container: Container;\n /**@internal */\n slotName: string;\n /**@internal */\n slotAlias?: string;\n\n steps: (Function | PipelineStep)[] = [];\n\n constructor(container: Container, name: string, alias?: string) {\n this.container = container;\n this.slotName = name;\n this.slotAlias = alias;\n }\n\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\n return this.steps.map(x => this.container.get(x));\n }\n}\n\n/**\n * Class responsible for creating the navigation pipeline.\n */\nexport class PipelineProvider {\n\n /**@internal */\n static inject() { return [Container]; }\n /**@internal */\n container: Container;\n /**@internal */\n steps: (Function | PipelineSlot)[];\n\n constructor(container: Container) {\n this.container = container;\n this.steps = [\n BuildNavigationPlanStep,\n CanDeactivatePreviousStep, // optional\n LoadRouteStep,\n createPipelineSlot(container, PipelineSlotName.Authorize),\n CanActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\n // NOTE: app state changes start below - point of no return\n DeactivatePreviousStep, // optional\n ActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\n CommitChangesStep,\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\n ];\n }\n\n /**\n * Create the navigation pipeline.\n */\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\n let pipeline = new Pipeline();\n this.steps.forEach(step => {\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\n pipeline.addStep(this.container.get(step));\n }\n });\n return pipeline;\n }\n\n /**@internal */\n _findStep(name: string): PipelineSlot {\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\n }\n\n /**\n * Adds a step into the pipeline at a known slot location.\n */\n addStep(name: string, step: PipelineStep | Function): void {\n let found = this._findStep(name);\n if (found) {\n let slotSteps = found.steps;\n // prevent duplicates\n if (!slotSteps.includes(step)) {\n slotSteps.push(step);\n }\n } else {\n throw new Error(`Invalid pipeline slot name: ${name}.`);\n }\n }\n\n /**\n * Removes a step from a slot in the pipeline\n */\n removeStep(name: string, step: PipelineStep): void {\n let slot = this._findStep(name);\n if (slot) {\n let slotSteps = slot.steps;\n slotSteps.splice(slotSteps.indexOf(step), 1);\n }\n }\n\n /**\n * Clears all steps from a slot in the pipeline\n * @internal\n */\n _clearSteps(name: string = ''): void {\n let slot = this._findStep(name);\n if (slot) {\n slot.steps = [];\n }\n }\n\n /**\n * Resets all pipeline slots\n */\n reset(): void {\n this._clearSteps(PipelineSlotName.Authorize);\n this._clearSteps(PipelineSlotName.PreActivate);\n this._clearSteps(PipelineSlotName.PreRender);\n this._clearSteps(PipelineSlotName.PostRender);\n }\n}\n\n/**@internal */\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\n return new PipelineSlot(container, name, alias);\n};\n","import * as LogManager from 'aurelia-logging';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\nimport { PipelineProvider } from './pipeline-provider';\nimport { isNavigationCommand } from './navigation-commands';\nimport { EventAggregator } from 'aurelia-event-aggregator';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\nimport { RouterEvent } from './router-event';\nimport { RouterConfiguration } from './router-configuration';\n\n/**@internal */\ndeclare module 'aurelia-dependency-injection' {\n interface Container {\n viewModel?: any;\n }\n}\n\nconst logger = LogManager.getLogger('app-router');\n\n/**\n * The main application router.\n */\nexport class AppRouter extends Router {\n\n /**@internal */\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\n\n events: EventAggregator;\n /**@internal */\n maxInstructionCount: number;\n /**@internal */\n _queue: NavigationInstruction[];\n /**@internal */\n isActive: boolean;\n\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\n super(container, history); // Note the super will call reset internally.\n this.pipelineProvider = pipelineProvider;\n this.events = events;\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset(): void {\n super.reset();\n this.maxInstructionCount = 10;\n if (!this._queue) {\n this._queue = [];\n } else {\n this._queue.length = 0;\n }\n }\n\n /**\n * Loads the specified URL.\n *\n * @param url The URL fragment to load.\n */\n loadUrl(url: string): Promise {\n return this\n ._createNavigationInstruction(url)\n .then(instruction => this._queueInstruction(instruction))\n .catch(error => {\n logger.error(error);\n restorePreviousLocation(this);\n });\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\n // having strong typing without changing public API\n const $viewPort: ViewPort = viewPort;\n super.registerViewPort($viewPort, name);\n\n // beside adding viewport to the registry of this instance\n // AppRouter also configure routing/history to start routing functionality\n // There are situation where there are more than 1 element at root view\n // in that case, still only activate once via the following guard\n if (!this.isActive) {\n const viewModel = this._findViewModel($viewPort);\n if ('configureRouter' in viewModel) {\n // If there are more than one element at root view\n // use this flag to guard against configure method being invoked multiple times\n // this flag is set inside method configure\n if (!this.isConfigured) {\n // replace the real resolve with a noop to guarantee that any action in base class Router\n // won't resolve the configurePromise prematurely\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\n this._resolveConfiguredPromise = () => {/**/};\n return this\n .configure(config =>\n Promise\n .resolve(viewModel.configureRouter(config, this))\n // an issue with configure interface. Should be fixed there\n // todo: fix this via configure interface in router\n .then(() => config) as any\n )\n .then(() => {\n this.activate();\n resolveConfiguredPromise();\n });\n }\n } else {\n this.activate();\n }\n }\n // when a viewport is added dynamically to a root view that is already activated\n // just process the navigation instruction\n else {\n this._dequeueInstruction();\n }\n\n return Promise.resolve();\n }\n\n /**\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\n *\n * @params options The set of options to activate the router with.\n */\n activate(options?: NavigationOptions): void {\n if (this.isActive) {\n return;\n }\n\n this.isActive = true;\n // route handler property is responsible for handling url change\n // the interface of aurelia-history isn't clear on this perspective\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\n this.history.activate(this.options);\n this._dequeueInstruction();\n }\n\n /**\n * Deactivates the router.\n */\n deactivate(): void {\n this.isActive = false;\n this.history.deactivate();\n }\n\n /**@internal */\n _queueInstruction(instruction: NavigationInstruction): Promise {\n return new Promise((resolve) => {\n instruction.resolve = resolve;\n this._queue.unshift(instruction);\n this._dequeueInstruction();\n });\n }\n\n /**@internal */\n _dequeueInstruction(instructionCount: number = 0): Promise {\n return Promise.resolve().then(() => {\n if (this.isNavigating && !instructionCount) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n let instruction = this._queue.shift();\n this._queue.length = 0;\n\n if (!instruction) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n this.isNavigating = true;\n\n let navtracker: number = this.history.getState('NavigationTracker');\n let currentNavTracker = this.currentNavigationTracker;\n\n if (!navtracker && !currentNavTracker) {\n this.isNavigatingFirst = true;\n this.isNavigatingNew = true;\n } else if (!navtracker) {\n this.isNavigatingNew = true;\n } else if (!currentNavTracker) {\n this.isNavigatingRefresh = true;\n } else if (currentNavTracker < navtracker) {\n this.isNavigatingForward = true;\n } else if (currentNavTracker > navtracker) {\n this.isNavigatingBack = true;\n } if (!navtracker) {\n navtracker = Date.now();\n this.history.setState('NavigationTracker', navtracker);\n }\n this.currentNavigationTracker = navtracker;\n\n instruction.previousInstruction = this.currentInstruction;\n\n let maxInstructionCount = this.maxInstructionCount;\n\n if (!instructionCount) {\n this.events.publish(RouterEvent.Processing, { instruction });\n } else if (instructionCount === maxInstructionCount - 1) {\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\n restorePreviousLocation(this);\n return this._dequeueInstruction(instructionCount + 1);\n } else if (instructionCount > maxInstructionCount) {\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\n }\n\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\n\n return pipeline\n .run(instruction)\n .then(result => processResult(instruction, result, instructionCount, this))\n .catch(error => {\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\n })\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\n });\n }\n\n /**@internal */\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\n if (this.container.viewModel) {\n return this.container.viewModel;\n }\n\n if (viewPort.container) {\n let container = viewPort.container;\n\n while (container) {\n if (container.viewModel) {\n this.container.viewModel = container.viewModel;\n return container.viewModel;\n }\n\n container = container.parent;\n }\n }\n\n return undefined;\n }\n}\n\nconst processResult = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n instructionCount: number,\n router: AppRouter\n): Promise => {\n if (!(result && 'completed' in result && 'output' in result)) {\n result = result || {} as PipelineResult;\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\n }\n\n let finalResult: PipelineResult = null;\n let navigationCommandResult = null;\n if (isNavigationCommand(result.output)) {\n navigationCommandResult = result.output.navigate(router);\n } else {\n finalResult = result;\n\n if (!result.completed) {\n if (result.output instanceof Error) {\n logger.error(result.output.toString());\n }\n\n restorePreviousLocation(router);\n }\n }\n\n return Promise.resolve(navigationCommandResult)\n .then(_ => router._dequeueInstruction(instructionCount + 1))\n .then(innerResult => finalResult || innerResult || result);\n};\n\nconst resolveInstruction = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n isInnerInstruction: boolean,\n router: AppRouter\n): PipelineResult => {\n instruction.resolve(result);\n\n let eventAggregator = router.events;\n let eventArgs = { instruction, result };\n if (!isInnerInstruction) {\n router.isNavigating = false;\n router.isExplicitNavigation = false;\n router.isExplicitNavigationBack = false;\n router.isNavigatingFirst = false;\n router.isNavigatingNew = false;\n router.isNavigatingRefresh = false;\n router.isNavigatingForward = false;\n router.isNavigatingBack = false;\n router.couldDeactivate = false;\n\n let eventName: string;\n\n if (result.output instanceof Error) {\n eventName = RouterEvent.Error;\n } else if (!result.completed) {\n eventName = RouterEvent.Canceled;\n } else {\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\n router.history.previousLocation = instruction.fragment + queryString;\n eventName = RouterEvent.Success;\n }\n\n eventAggregator.publish(eventName, eventArgs);\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\n } else {\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\n }\n\n return result;\n};\n\nconst restorePreviousLocation = (router: AppRouter): void => {\n let previousLocation = router.history.previousLocation;\n if (previousLocation) {\n router.navigate(previousLocation, { trigger: false, replace: true });\n } else if (router.fallbackRoute) {\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\n } else {\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\n }\n};\n","/**\n* The status of a Pipeline.\n*/\nexport const enum PipelineStatus {\n Completed = 'completed',\n Canceled = 'canceled',\n Rejected = 'rejected',\n Running = 'running'\n}\n","/**\n * A list of known router events used by the Aurelia router\n * to signal the pipeline has come to a certain state\n */\n// const enum is preserved in tsconfig\nexport const enum RouterEvent {\n Processing = 'router:navigation:processing',\n Error = 'router:navigation:error',\n Canceled = 'router:navigation:canceled',\n Complete = 'router:navigation:complete',\n Success = 'router:navigation:success',\n ChildComplete = 'router:navigation:child:complete'\n}\n","/**\n * Available pipeline slot names to insert interceptor into router pipeline\n */\n// const enum is preserved in tsconfig\nexport const enum PipelineSlotName {\n /**\n * Authorization slot. Invoked early in the pipeline,\n * before `canActivate` hook of incoming route\n */\n Authorize = 'authorize',\n /**\n * Pre-activation slot. Invoked early in the pipeline,\n * Invoked timing:\n * - after Authorization slot\n * - after canActivate hook on new view model\n * - before deactivate hook on old view model\n * - before activate hook on new view model\n */\n PreActivate = 'preActivate',\n /**\n * Pre-render slot. Invoked later in the pipeline\n * Invokcation timing:\n * - after activate hook on new view model\n * - before commit step on new navigation instruction\n */\n PreRender = 'preRender',\n /**\n * Post-render slot. Invoked last in the pipeline\n */\n PostRender = 'postRender'\n}\n"],"names":["RouteRecognizer","Container","LogManager.getLogger","tslib_1.__extends","History","EventAggregator","PipelineStatus","RouterEvent","PipelineSlotName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BA;;;AAGA;QA4DE,+BAAY,IAA+B;;;;YAT3C,SAAI,GAAwC,IAAI,CAAC;YAEjD,YAAO,GAAwB,EAAE,CAAC;YAQhC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAE1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,oBAAoB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AA;IAC3B,CAAC,EA1BiBC,wBAAgB,KAAhBA,wBAAgB,QA0BjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\r\nimport { Router } from './router';\r\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\r\n\r\n/**\r\n * Initialization options for a navigation instruction\r\n */\r\nexport interface NavigationInstructionInit {\r\n fragment: string;\r\n queryString?: string;\r\n params?: Record;\r\n queryParams?: Record;\r\n config: RouteConfig;\r\n parentInstruction?: NavigationInstruction;\r\n previousInstruction?: NavigationInstruction;\r\n router: Router;\r\n options?: Object;\r\n plan?: Record;\r\n}\r\n\r\nexport interface ViewPortInstructionInit {\r\n name: string;\r\n strategy: ActivationStrategyType;\r\n moduleId: string;\r\n component: ViewPortComponent;\r\n}\r\n\r\n/**\r\n * Class used to represent an instruction during a navigation.\r\n */\r\nexport class NavigationInstruction {\r\n /**\r\n * The URL fragment.\r\n */\r\n fragment: string;\r\n\r\n /**\r\n * The query string.\r\n */\r\n queryString: string;\r\n\r\n /**\r\n * Parameters extracted from the route pattern.\r\n */\r\n params: any;\r\n\r\n /**\r\n * Parameters extracted from the query string.\r\n */\r\n queryParams: any;\r\n\r\n /**\r\n * The route config for the route matching this instruction.\r\n */\r\n config: RouteConfig;\r\n\r\n /**\r\n * The parent instruction, if this instruction was created by a child router.\r\n */\r\n parentInstruction: NavigationInstruction;\r\n\r\n parentCatchHandler: any;\r\n\r\n /**\r\n * The instruction being replaced by this instruction in the current router.\r\n */\r\n previousInstruction: NavigationInstruction;\r\n\r\n /**\r\n * viewPort instructions to used activation.\r\n */\r\n viewPortInstructions: Record;\r\n\r\n /**\r\n * The router instance.\r\n */\r\n router: Router;\r\n\r\n /**\r\n * Current built viewport plan of this nav instruction\r\n */\r\n plan: Record = null;\r\n\r\n options: Record = {};\r\n\r\n /**@internal */\r\n lifecycleArgs: LifecycleArguments;\r\n /**@internal */\r\n resolve?: (val?: any) => void;\r\n\r\n constructor(init: NavigationInstructionInit) {\r\n Object.assign(this, init);\r\n\r\n this.params = this.params || {};\r\n this.viewPortInstructions = {};\r\n\r\n let ancestorParams = [];\r\n let current: NavigationInstruction = this;\r\n do {\r\n let currentParams = Object.assign({}, current.params);\r\n if (current.config && current.config.hasChildRouter) {\r\n // remove the param for the injected child route segment\r\n delete currentParams[current.getWildCardName()];\r\n }\r\n\r\n ancestorParams.unshift(currentParams);\r\n current = current.parentInstruction;\r\n } while (current);\r\n\r\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\r\n this.lifecycleArgs = [allParams, this.config, this];\r\n }\r\n\r\n /**\r\n * Gets an array containing this instruction and all child instructions for the current navigation.\r\n */\r\n getAllInstructions(): Array {\r\n let instructions: NavigationInstruction[] = [this];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let key in viewPortInstructions) {\r\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\r\n if (childInstruction) {\r\n instructions.push(...childInstruction.getAllInstructions());\r\n }\r\n }\r\n\r\n return instructions;\r\n }\r\n\r\n /**\r\n * Gets an array containing the instruction and all child instructions for the previous navigation.\r\n * Previous instructions are no longer available after navigation completes.\r\n */\r\n getAllPreviousInstructions(): Array {\r\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\r\n }\r\n\r\n /**\r\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\r\n */\r\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(\r\n nameOrInitOptions: string | ViewPortInstructionInit,\r\n strategy?: ActivationStrategyType,\r\n moduleId?: string,\r\n component?: any\r\n ): /*ViewPortInstruction*/ any {\r\n\r\n let viewPortInstruction: ViewPortInstruction;\r\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\r\n const lifecycleArgs = this.lifecycleArgs;\r\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\r\n\r\n if (typeof nameOrInitOptions === 'string') {\r\n viewPortInstruction = {\r\n name: nameOrInitOptions,\r\n strategy: strategy,\r\n moduleId: moduleId,\r\n component: component,\r\n childRouter: component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n } else {\r\n viewPortInstruction = {\r\n name: viewPortName,\r\n strategy: nameOrInitOptions.strategy,\r\n component: nameOrInitOptions.component,\r\n moduleId: nameOrInitOptions.moduleId,\r\n childRouter: nameOrInitOptions.component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n }\r\n\r\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\r\n }\r\n\r\n /**\r\n * Gets the name of the route pattern's wildcard parameter, if applicable.\r\n */\r\n getWildCardName(): string {\r\n // todo: potential issue, or at least unsafe typings\r\n let configRoute = this.config.route as string;\r\n let wildcardIndex = configRoute.lastIndexOf('*');\r\n return configRoute.substr(wildcardIndex + 1);\r\n }\r\n\r\n /**\r\n * Gets the path and query string created by filling the route\r\n * pattern's wildcard parameter with the matching param.\r\n */\r\n getWildcardPath(): string {\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n let queryString = this.queryString;\r\n\r\n if (queryString) {\r\n path += '?' + queryString;\r\n }\r\n\r\n return path;\r\n }\r\n\r\n /**\r\n * Gets the instruction's base URL, accounting for wildcard route parameters.\r\n */\r\n getBaseUrl(): string {\r\n let $encodeURI = encodeURI;\r\n let fragment = decodeURI(this.fragment);\r\n\r\n if (fragment === '') {\r\n let nonEmptyRoute = this.router.routes.find(route => {\r\n return route.name === this.config.name &&\r\n route.route !== '';\r\n });\r\n if (nonEmptyRoute) {\r\n fragment = nonEmptyRoute.route as any;\r\n }\r\n }\r\n\r\n if (!this.params) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n\r\n if (!path) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\r\n }\r\n\r\n /**\r\n * Finalize a viewport instruction\r\n * @internal\r\n */\r\n _commitChanges(waitToSwap: boolean): Promise {\r\n let router = this.router;\r\n router.currentInstruction = this;\r\n\r\n const previousInstruction = this.previousInstruction;\r\n if (previousInstruction) {\r\n previousInstruction.config.navModel.isActive = false;\r\n }\r\n\r\n this.config.navModel.isActive = true;\r\n\r\n router.refreshNavigation();\r\n\r\n let loads: Promise[] = [];\r\n let delaySwaps: ISwapPlan[] = [];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let viewPort = router.viewPorts[viewPortName];\r\n\r\n if (!viewPort) {\r\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\r\n }\r\n\r\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\r\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\r\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n } else {\r\n if (waitToSwap) {\r\n delaySwaps.push({ viewPort, viewPortInstruction });\r\n }\r\n loads.push(\r\n viewPort\r\n .process(viewPortInstruction, waitToSwap)\r\n .then(() => childNavInstruction\r\n ? childNavInstruction._commitChanges(waitToSwap)\r\n : Promise.resolve()\r\n )\r\n );\r\n }\r\n } else {\r\n if (childNavInstruction) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n }\r\n }\r\n }\r\n\r\n return Promise\r\n .all(loads)\r\n .then(() => {\r\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\r\n return null;\r\n })\r\n .then(() => prune(this));\r\n }\r\n\r\n /**@internal */\r\n _updateTitle(): void {\r\n let router = this.router;\r\n let title = this._buildTitle(router.titleSeparator);\r\n if (title) {\r\n router.history.setTitle(title);\r\n }\r\n }\r\n\r\n /**@internal */\r\n _buildTitle(separator: string = ' | '): string {\r\n let title = '';\r\n let childTitles = [];\r\n let navModelTitle = this.config.navModel.title;\r\n let instructionRouter = this.router;\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n if (navModelTitle) {\r\n title = instructionRouter.transformTitle(navModelTitle);\r\n }\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\r\n\r\n if (child_nav_instruction) {\r\n let childTitle = child_nav_instruction._buildTitle(separator);\r\n if (childTitle) {\r\n childTitles.push(childTitle);\r\n }\r\n }\r\n }\r\n\r\n if (childTitles.length) {\r\n title = childTitles.join(separator) + (title ? separator : '') + title;\r\n }\r\n\r\n if (instructionRouter.title) {\r\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\r\n }\r\n\r\n return title;\r\n }\r\n}\r\n\r\nconst prune = (instruction: NavigationInstruction): void => {\r\n instruction.previousInstruction = null;\r\n instruction.plan = null;\r\n};\r\n\r\ninterface ISwapPlan {\r\n viewPort: ViewPort;\r\n viewPortInstruction: ViewPortInstruction;\r\n}\r\n","import { Router } from './router';\r\nimport { RouteConfig } from './interfaces';\r\n\r\n/**\r\n* Class for storing and interacting with a route's navigation settings.\r\n*/\r\nexport class NavModel {\r\n\r\n /**\r\n * True if this nav item is currently active.\r\n */\r\n isActive: boolean = false;\r\n\r\n /**\r\n * The title.\r\n */\r\n title: string = null;\r\n\r\n /**\r\n * This nav item's absolute href.\r\n */\r\n href: string = null;\r\n\r\n /**\r\n * This nav item's relative href.\r\n */\r\n relativeHref: string = null;\r\n\r\n /**\r\n * Data attached to the route at configuration time.\r\n */\r\n settings: any = {};\r\n\r\n /**\r\n * The route config.\r\n */\r\n config: RouteConfig = null;\r\n\r\n /**\r\n * The router associated with this navigation model.\r\n */\r\n router: Router;\r\n\r\n order: number | boolean;\r\n\r\n constructor(router: Router, relativeHref: string) {\r\n this.router = router;\r\n this.relativeHref = relativeHref;\r\n }\r\n\r\n /**\r\n * Sets the route's title and updates document.title.\r\n * If the a navigation is in progress, the change will be applied\r\n * to document.title when the navigation completes.\r\n *\r\n * @param title The new title.\r\n */\r\n setTitle(title: string): void {\r\n this.title = title;\r\n\r\n if (this.isActive) {\r\n this.router.updateTitle();\r\n }\r\n }\r\n}\r\n","import { RouteConfig } from './interfaces';\r\n\r\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\r\n if (!hasPushState && path[0] !== '#') {\r\n path = '#' + path;\r\n }\r\n\r\n if (hasPushState && absolute) {\r\n path = path.substring(1, path.length);\r\n }\r\n\r\n return path;\r\n}\r\n\r\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\r\n if (isAbsoluteUrl.test(fragment)) {\r\n return fragment;\r\n }\r\n\r\n let path = '';\r\n\r\n if (baseUrl.length && baseUrl[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n path += baseUrl;\r\n\r\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\r\n path = path.substring(0, path.length - 1);\r\n }\r\n\r\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\r\n}\r\n\r\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\r\n if (isRootedPath.test(fragment)) {\r\n return _normalizeAbsolutePath(fragment, hasPushState);\r\n }\r\n\r\n return _createRootedPath(fragment, baseUrl, hasPushState);\r\n}\r\n\r\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\r\n let routeConfigs = [];\r\n\r\n if (Array.isArray(config.route)) {\r\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\r\n let current = Object.assign({}, config);\r\n current.route = config.route[i];\r\n routeConfigs.push(current);\r\n }\r\n } else {\r\n routeConfigs.push(Object.assign({}, config));\r\n }\r\n\r\n return routeConfigs;\r\n}\r\n\r\nconst isRootedPath = /^#?\\//;\r\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\r\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\r\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\r\nimport { Router } from './router';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * Class used to configure a [[Router]] instance.\r\n *\r\n * @constructor\r\n */\r\nexport class RouterConfiguration {\r\n instructions: Array<(router: Router) => void> = [];\r\n options: {\r\n [key: string]: any;\r\n compareQueryParams?: boolean;\r\n root?: string;\r\n pushState?: boolean;\r\n hashChange?: boolean;\r\n silent?: boolean;\r\n } = {};\r\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\r\n title: string;\r\n titleSeparator: string;\r\n unknownRouteConfig: RouteConfigSpecifier;\r\n viewPortDefaults: Record;\r\n\r\n /**@internal */\r\n _fallbackRoute: string;\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\r\n *\r\n * @param name The name of the pipeline slot to insert the step into.\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\r\n if (step === null || step === undefined) {\r\n throw new Error('Pipeline step cannot be null or undefined.');\r\n }\r\n this.pipelineSteps.push({ name, step });\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\r\n }\r\n\r\n /**\r\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\r\n *\r\n * @param fragment The URL fragment to use as the navigation destination.\r\n * @chainable\r\n */\r\n fallbackRoute(fragment: string): RouterConfiguration {\r\n this._fallbackRoute = fragment;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps one or more routes to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\r\n if (Array.isArray(route)) {\r\n route.forEach(r => this.map(r));\r\n return this;\r\n }\r\n\r\n return this.mapRoute(route);\r\n }\r\n\r\n /**\r\n * Configures defaults to use for any view ports.\r\n *\r\n * @param viewPortConfig a view port configuration object to use as a\r\n * default, of the form { viewPortName: { moduleId } }.\r\n * @chainable\r\n */\r\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\r\n this.viewPortDefaults = viewPortConfig;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps a single route to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n mapRoute(config: RouteConfig): RouterConfiguration {\r\n this.instructions.push(router => {\r\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\r\n\r\n let navModel;\r\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\r\n let routeConfig = routeConfigs[i];\r\n routeConfig.settings = routeConfig.settings || {};\r\n if (!navModel) {\r\n navModel = router.createNavModel(routeConfig);\r\n }\r\n\r\n router.addRoute(routeConfig, navModel);\r\n }\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\r\n *\r\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\r\n * [[NavigationInstruction]] and selects a moduleId to load.\r\n * @chainable\r\n */\r\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\r\n this.unknownRouteConfig = config;\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current configuration to the specified [[Router]].\r\n *\r\n * @param router The [[Router]] to apply the configuration to.\r\n */\r\n exportToRouter(router: Router): void {\r\n let instructions = this.instructions;\r\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\r\n instructions[i](router);\r\n }\r\n\r\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\r\n\r\n if (title) {\r\n router.title = title;\r\n }\r\n\r\n if (titleSeparator) {\r\n router.titleSeparator = titleSeparator;\r\n }\r\n\r\n if (unknownRouteConfig) {\r\n router.handleUnknownRoutes(unknownRouteConfig);\r\n }\r\n\r\n if (_fallbackRoute) {\r\n router.fallbackRoute = _fallbackRoute;\r\n }\r\n\r\n if (viewPortDefaults) {\r\n router.useViewPortDefaults(viewPortDefaults);\r\n }\r\n\r\n Object.assign(router.options, this.options);\r\n\r\n let pipelineSteps = this.pipelineSteps;\r\n let pipelineStepCount = pipelineSteps.length;\r\n if (pipelineStepCount) {\r\n if (!router.isRoot) {\r\n throw new Error('Pipeline steps can only be added to the root router');\r\n }\r\n\r\n let pipelineProvider = router.pipelineProvider;\r\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\r\n let { name, step } = pipelineSteps[i];\r\n pipelineProvider.addStep(name, step);\r\n }\r\n }\r\n }\r\n}\r\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { NavigationResult, RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): NavigationResult {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): NavigationResult {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\r\n\r\n/**@internal exported for unit testing */\r\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\r\n let index = -1;\r\n const next: Next = function() {\r\n index++;\r\n\r\n if (index < steps.length) {\r\n let currentStep = steps[index];\r\n\r\n try {\r\n return currentStep(instruction, next);\r\n } catch (e) {\r\n return next.reject(e);\r\n }\r\n } else {\r\n return next.complete();\r\n }\r\n } as Next;\r\n\r\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\r\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\r\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\r\n\r\n return next;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\r\n return (output: any) => Promise\r\n .resolve({\r\n status,\r\n output,\r\n completed: status === PipelineStatus.Completed\r\n });\r\n};\r\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { createNextFn } from './next';\r\n\r\n/**\r\n * The class responsible for managing and processing the navigation pipeline.\r\n */\r\nexport class Pipeline {\r\n /**\r\n * The pipeline steps. And steps added via addStep will be converted to a function\r\n * The actualy running functions with correct step contexts of this pipeline\r\n */\r\n steps: StepRunnerFunction[] = [];\r\n\r\n /**\r\n * Adds a step to the pipeline.\r\n *\r\n * @param step The pipeline step.\r\n */\r\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\r\n let run;\r\n\r\n if (typeof step === 'function') {\r\n run = step;\r\n } else if (typeof step.getSteps === 'function') {\r\n // getSteps is to enable support open slots\r\n // where devs can add multiple steps into the same slot name\r\n let steps = step.getSteps();\r\n for (let i = 0, l = steps.length; i < l; i++) {\r\n this.addStep(steps[i]);\r\n }\r\n\r\n return this;\r\n } else {\r\n run = (step as PipelineStep).run.bind(step);\r\n }\r\n\r\n this.steps.push(run);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Runs the pipeline.\r\n *\r\n * @param instruction The navigation instruction to process.\r\n */\r\n run(instruction: NavigationInstruction): Promise {\r\n const nextFn = createNextFn(instruction, this.steps);\r\n return nextFn();\r\n }\r\n}\r\n","import { NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-history' {\r\n interface NavigationOptions {\r\n useAppRouter?: boolean;\r\n }\r\n}\r\n\r\n/**\r\n* When a navigation command is encountered, the current navigation\r\n* will be cancelled and control will be passed to the navigation\r\n* command so it can determine the correct action.\r\n*/\r\nexport interface NavigationCommand {\r\n navigate: (router: Router) => void;\r\n /**@internal */\r\n shouldContinueProcessing?: boolean;\r\n /**@internal */\r\n setRouter?: (router: Router) => void;\r\n}\r\n\r\n/**\r\n* Determines if the provided object is a navigation command.\r\n* A navigation command is anything with a navigate method.\r\n*\r\n* @param obj The object to check.\r\n*/\r\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\r\n return obj && typeof obj.navigate === 'function';\r\n}\r\n\r\n/**\r\n* Used during the activation lifecycle to cause a redirect.\r\n*/\r\nexport class Redirect implements NavigationCommand {\r\n\r\n url: string;\r\n /**@internal */\r\n options: NavigationOptions;\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n private router: Router;\r\n\r\n /**\r\n * @param url The URL fragment to use as the navigation destination.\r\n * @param options The navigation options.\r\n */\r\n constructor(url: string, options: NavigationOptions = {}) {\r\n this.url = url;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigate(this.url, this.options);\r\n }\r\n}\r\n\r\n/**\r\n * Used during the activation lifecycle to cause a redirect to a named route.\r\n */\r\nexport class RedirectToRoute implements NavigationCommand {\r\n\r\n route: string;\r\n params: any;\r\n /**@internal */\r\n options: NavigationOptions;\r\n\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n /**@internal */\r\n router: Router;\r\n\r\n /**\r\n * @param route The name of the route.\r\n * @param params The parameters to be sent to the activation method.\r\n * @param options The options to use for navigation.\r\n */\r\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\r\n this.route = route;\r\n this.params = params;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\r\n }\r\n}\r\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\r\n\r\ntype ViewPortPlansRecord = Record;\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport function _buildNavigationPlan(\r\n instruction: NavigationInstruction,\r\n forceLifecycleMinimum?: boolean\r\n): Promise {\r\n let config = instruction.config;\r\n\r\n if ('redirect' in config) {\r\n return buildRedirectPlan(instruction);\r\n }\r\n\r\n const prevInstruction = instruction.previousInstruction;\r\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\r\n\r\n if (prevInstruction) {\r\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\r\n }\r\n\r\n // first navigation, only need to prepare a few information for each viewport plan\r\n const viewPortPlans: ViewPortPlansRecord = {};\r\n let viewPortConfigs = config.viewPorts;\r\n for (let viewPortName in viewPortConfigs) {\r\n let viewPortConfig = viewPortConfigs[viewPortName];\r\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n viewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n strategy: InternalActivationStrategy.Replace,\r\n config: viewPortConfig\r\n };\r\n }\r\n\r\n return Promise.resolve(viewPortPlans);\r\n}\r\n\r\n/**\r\n * Build redirect plan based on config of a navigation instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\r\n const config = instruction.config;\r\n const router = instruction.router;\r\n return router\r\n ._createNavigationInstruction(config.redirect)\r\n .then(redirectInstruction => {\r\n\r\n const params: Record = {};\r\n const originalInstructionParams = instruction.params;\r\n const redirectInstructionParams = redirectInstruction.params;\r\n\r\n for (let key in redirectInstructionParams) {\r\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\r\n let val = redirectInstructionParams[key];\r\n if (typeof val === 'string' && val[0] === ':') {\r\n val = val.slice(1);\r\n // And if that param is found on the original instruction then use it\r\n if (val in originalInstructionParams) {\r\n params[key] = originalInstructionParams[val];\r\n }\r\n } else {\r\n params[key] = redirectInstructionParams[key];\r\n }\r\n }\r\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\r\n\r\n // Special handling for child routes\r\n for (let key in originalInstructionParams) {\r\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\r\n }\r\n\r\n let queryString = instruction.queryString;\r\n if (queryString) {\r\n redirectLocation += '?' + queryString;\r\n }\r\n\r\n return Promise.resolve(new Redirect(redirectLocation));\r\n });\r\n};\r\n\r\n/**\r\n * @param viewPortPlans the Plan record that holds information about built plans\r\n * @internal exported for unit testing\r\n */\r\nexport const buildTransitionPlans = (\r\n currentInstruction: NavigationInstruction,\r\n previousInstruction: NavigationInstruction,\r\n defaultViewPortConfigs: Record,\r\n forceLifecycleMinimum?: boolean\r\n): Promise => {\r\n\r\n let viewPortPlans: ViewPortPlansRecord = {};\r\n let newInstructionConfig = currentInstruction.config;\r\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\r\n let pending: Promise[] = [];\r\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\r\n\r\n for (let viewPortName in previousViewPortInstructions) {\r\n\r\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\r\n const prevViewPortComponent = prevViewPortInstruction.component;\r\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\r\n\r\n // if this is invoked on a viewport without any changes, based on new url,\r\n // newViewPortConfig will be the existing viewport instruction\r\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\r\n ? newInstructionViewPortConfigs[viewPortName]\r\n : prevViewPortInstruction;\r\n\r\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n\r\n const viewPortActivationStrategy = determineActivationStrategy(\r\n currentInstruction,\r\n prevViewPortInstruction,\r\n nextViewPortConfig,\r\n hasNewParams,\r\n forceLifecycleMinimum\r\n );\r\n const viewPortPlan = viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n // ViewPortInstruction can quack like a RouteConfig\r\n config: nextViewPortConfig as RouteConfig,\r\n prevComponent: prevViewPortComponent,\r\n prevModuleId: prevViewPortInstruction.moduleId,\r\n strategy: viewPortActivationStrategy\r\n } as ViewPortPlan;\r\n\r\n // recursively build nav plans for all existing child routers/viewports of this viewport\r\n // this is possible because existing child viewports and routers already have necessary information\r\n // to process the wildcard path from parent instruction\r\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\r\n const path = currentInstruction.getWildcardPath();\r\n const task: Promise = prevViewPortInstruction\r\n .childRouter\r\n ._createNavigationInstruction(path, currentInstruction)\r\n .then((childInstruction: NavigationInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(\r\n childInstruction,\r\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\r\n // if so, can just use local variable viewPortPlanStrategy\r\n // there could be user code modifying viewport plan during _createNavigationInstruction?\r\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\r\n )\r\n .then(childPlan => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n // for bluebird ?\r\n return null;\r\n });\r\n });\r\n\r\n pending.push(task);\r\n }\r\n }\r\n\r\n return Promise.all(pending).then(() => viewPortPlans);\r\n};\r\n\r\n/**\r\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const determineActivationStrategy = (\r\n currentNavInstruction: NavigationInstruction,\r\n prevViewPortInstruction: ViewPortInstruction,\r\n newViewPortConfig: RouteConfig | ViewPortInstruction,\r\n // indicates whether there is difference between old and new url params\r\n hasNewParams: boolean,\r\n forceLifecycleMinimum?: boolean\r\n): ActivationStrategyType => {\r\n\r\n let newInstructionConfig = currentNavInstruction.config;\r\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\r\n let viewPortPlanStrategy: ActivationStrategyType;\r\n\r\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\r\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\r\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\r\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\r\n } else if (newInstructionConfig.activationStrategy) {\r\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\r\n } else if (hasNewParams || forceLifecycleMinimum) {\r\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\r\n } else {\r\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\r\n }\r\n return viewPortPlanStrategy;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\r\n let prevParams = prev.params;\r\n let nextParams = next.params;\r\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\r\n\r\n for (let key in nextParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!next.options.compareQueryParams) {\r\n return false;\r\n }\r\n\r\n let prevQueryParams = prev.queryParams;\r\n let nextQueryParams = next.queryParams;\r\n for (let key in nextQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n};\r\n","import { Next } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\n\r\n/**\r\n * Transform a navigation instruction into viewport plan record object,\r\n * or a redirect request if user viewmodel demands\r\n */\r\nexport class BuildNavigationPlanStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return _buildNavigationPlan(navigationInstruction)\r\n .then(plan => {\r\n if (plan instanceof Redirect) {\r\n return next.cancel(plan);\r\n }\r\n navigationInstruction.plan = plan;\r\n return next();\r\n })\r\n .catch(next.cancel);\r\n }\r\n}\r\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\nimport { InternalActivationStrategy } from './activation-strategy';\r\nimport { RouteLoader } from './route-loader';\r\n\r\n/**\r\n * Loading plan calculated based on a navigration-instruction and a viewport plan\r\n */\r\ninterface ILoadingPlan {\r\n viewPortPlan: ViewPortPlan;\r\n navigationInstruction: NavigationInstruction;\r\n}\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadNewRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction\r\n): Promise => {\r\n let loadingPlans = determineLoadingPlans(navigationInstruction);\r\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\r\n routeLoader,\r\n loadingPlan.navigationInstruction,\r\n loadingPlan.viewPortPlan\r\n ));\r\n\r\n return Promise.all(loadPromises);\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const determineLoadingPlans = (\r\n navigationInstruction: NavigationInstruction,\r\n loadingPlans: ILoadingPlan[] = []\r\n): ILoadingPlan[] => {\r\n let viewPortPlans: Record = navigationInstruction.plan;\r\n\r\n for (let viewPortName in viewPortPlans) {\r\n let viewPortPlan = viewPortPlans[viewPortName];\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\r\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\r\n\r\n if (childNavInstruction) {\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n } else {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortName,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: viewPortPlan.prevModuleId,\r\n component: viewPortPlan.prevComponent\r\n }) as ViewPortInstruction;\r\n\r\n if (childNavInstruction) {\r\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n }\r\n }\r\n\r\n return loadingPlans;\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n viewPortPlan: ViewPortPlan\r\n): Promise => {\r\n let planConfig = viewPortPlan.config;\r\n let moduleId = planConfig ? planConfig.moduleId : null;\r\n\r\n return loadComponent(routeLoader, navigationInstruction, planConfig)\r\n .then((component) => {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortPlan.name,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: moduleId,\r\n component: component\r\n }) as ViewPortInstruction;\r\n\r\n let childRouter = component.childRouter;\r\n if (childRouter) {\r\n let path = navigationInstruction.getWildcardPath();\r\n\r\n return childRouter\r\n ._createNavigationInstruction(path, navigationInstruction)\r\n .then((childInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(childInstruction)\r\n .then((childPlan) => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n viewPortInstruction.childNavigationInstruction = childInstruction;\r\n\r\n return loadNewRoute(routeLoader, childInstruction);\r\n });\r\n });\r\n }\r\n // ts complains without this, though they are same\r\n return void 0;\r\n });\r\n};\r\n\r\n/**\r\n * Load a routed-component based on navigation instruction and route config\r\n * @internal exported for unit testing only\r\n */\r\nexport const loadComponent = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n config: RouteConfig\r\n): Promise => {\r\n let router = navigationInstruction.router;\r\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\r\n\r\n return Promise.resolve()\r\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\r\n .then(\r\n /**\r\n * @param component an object carrying information about loaded route\r\n * typically contains information about view model, childContainer, view and router\r\n */\r\n (component: ViewPortComponent) => {\r\n let { viewModel, childContainer } = component;\r\n component.router = router;\r\n component.config = config;\r\n\r\n if ('configureRouter' in viewModel) {\r\n let childRouter = childContainer.getChildRouter();\r\n component.childRouter = childRouter;\r\n\r\n return childRouter\r\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\r\n .then(() => component);\r\n }\r\n\r\n return component;\r\n }\r\n );\r\n};\r\n","import { RouteConfig } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Abstract class that is responsible for loading view / view model from a route config\r\n * The default implementation can be found in `aurelia-templating-router`\r\n */\r\nexport class RouteLoader {\r\n /**\r\n * Load a route config based on its viewmodel / view configuration\r\n */\r\n // return typing: return typings used to be never\r\n // as it was a throw. Changing it to Promise should not cause any issues\r\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\r\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\r\n }\r\n}\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { loadNewRoute } from './utilities-route-loading';\r\nimport { RouteLoader } from './route-loader';\r\n/**\r\n * A pipeline step responsible for loading a route config of a navigation instruction\r\n */\r\nexport class LoadRouteStep {\r\n /**@internal */\r\n static inject() { return [RouteLoader]; }\r\n /**\r\n * Route loader isntance that will handle loading route config\r\n * @internal\r\n */\r\n routeLoader: RouteLoader;\r\n constructor(routeLoader: RouteLoader) {\r\n this.routeLoader = routeLoader;\r\n }\r\n /**\r\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\r\n */\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return loadNewRoute(this.routeLoader, navigationInstruction)\r\n .then(next, next.cancel);\r\n }\r\n}\r\n","import { NavigationInstruction } from './navigation-instruction';\r\n\r\n/**\r\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\r\n */\r\nexport class CommitChangesStep {\r\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\r\n return navigationInstruction\r\n ._commitChanges(/*wait to swap?*/ true)\r\n .then(() => {\r\n navigationInstruction._updateTitle();\r\n return next();\r\n });\r\n }\r\n}\r\n","/**\r\n * An optional interface describing the available activation strategies.\r\n * @internal Used internally.\r\n */\r\nexport const enum InternalActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n NoChange = 'no-change',\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n InvokeLifecycle = 'invoke-lifecycle',\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n Replace = 'replace'\r\n}\r\n\r\n/**\r\n * The strategy to use when activating modules during navigation.\r\n */\r\n// kept for compat reason\r\nexport const activationStrategy: ActivationStrategy = {\r\n noChange: InternalActivationStrategy.NoChange,\r\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\r\n replace: InternalActivationStrategy.Replace\r\n};\r\n\r\n/**\r\n * An optional interface describing the available activation strategies.\r\n */\r\nexport interface ActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n noChange: 'no-change';\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n invokeLifecycle: 'invoke-lifecycle';\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n replace: 'replace';\r\n}\r\n\r\n/**\r\n * Enum like type for activation strategy built-in values\r\n */\r\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\r\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { activationStrategy } from './activation-strategy';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Recursively find list of deactivate-able view models\r\n * and invoke the either 'canDeactivate' or 'deactivate' on each\r\n * @internal exported for unit testing\r\n */\r\nexport const processDeactivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canDeactivate' | 'deactivate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let plan: Record = navigationInstruction.plan;\r\n let infos = findDeactivatable(plan, callbackName);\r\n let i = infos.length; // query from inside out\r\n\r\n function inspect(val: any): Promise {\r\n if (ignoreResult || shouldContinue(val)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n if (i--) {\r\n try {\r\n let viewModel = infos[i];\r\n let result = viewModel[callbackName](navigationInstruction);\r\n return processPotential(result, inspect, next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n navigationInstruction.router.couldDeactivate = true;\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\n/**\r\n * Recursively find and returns a list of deactivate-able view models\r\n * @internal exported for unit testing\r\n */\r\nexport const findDeactivatable = (\r\n plan: Record,\r\n callbackName: string,\r\n list: IActivatableInfo[] = []\r\n): any[] => {\r\n for (let viewPortName in plan) {\r\n let viewPortPlan = plan[viewPortName];\r\n let prevComponent = viewPortPlan.prevComponent;\r\n\r\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\r\n && prevComponent\r\n ) {\r\n let viewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in viewModel) {\r\n list.push(viewModel);\r\n }\r\n }\r\n\r\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n } else if (viewPortPlan.childNavigationInstruction) {\r\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\r\n }\r\n }\r\n\r\n return list;\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const addPreviousDeactivatable = (\r\n component: ViewPortComponent,\r\n callbackName: string,\r\n list: IActivatableInfo[]\r\n): void => {\r\n let childRouter = component.childRouter;\r\n\r\n if (childRouter && childRouter.currentInstruction) {\r\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let prevComponent = viewPortInstruction.component;\r\n let prevViewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in prevViewModel) {\r\n list.push(prevViewModel);\r\n }\r\n\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const processActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let infos = findActivatable(navigationInstruction, callbackName);\r\n let length = infos.length;\r\n let i = -1; // query from top down\r\n\r\n function inspect(val: any, router: Router): Promise {\r\n if (ignoreResult || shouldContinue(val, router)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n i++;\r\n\r\n if (i < length) {\r\n try {\r\n let current = infos[i];\r\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\r\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\ninterface IActivatableInfo {\r\n viewModel: any;\r\n lifecycleArgs: LifecycleArguments;\r\n router: Router;\r\n}\r\n\r\n/**\r\n * Find list of activatable view model and add to list (3rd parameter)\r\n * @internal exported for unit testing\r\n */\r\nexport const findActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n list: IActivatableInfo[] = [],\r\n router?: Router\r\n): IActivatableInfo[] => {\r\n let plan: Record = navigationInstruction.plan;\r\n\r\n Object\r\n .keys(plan)\r\n .forEach((viewPortName) => {\r\n let viewPortPlan = plan[viewPortName];\r\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\r\n let viewPortComponent = viewPortInstruction.component;\r\n let viewModel = viewPortComponent.viewModel;\r\n\r\n if (\r\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\r\n || viewPortPlan.strategy === activationStrategy.replace\r\n )\r\n && callbackName in viewModel\r\n ) {\r\n list.push({\r\n viewModel,\r\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\r\n router\r\n });\r\n }\r\n\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (childNavInstruction) {\r\n findActivatable(\r\n childNavInstruction,\r\n callbackName,\r\n list,\r\n viewPortComponent.childRouter || router\r\n );\r\n }\r\n });\r\n\r\n return list;\r\n};\r\n\r\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\r\n if (output instanceof Error) {\r\n return false;\r\n }\r\n\r\n if (isNavigationCommand(output)) {\r\n if (typeof output.setRouter === 'function') {\r\n output.setRouter(router);\r\n }\r\n\r\n return !!output.shouldContinueProcessing;\r\n }\r\n\r\n if (output === undefined) {\r\n return true;\r\n }\r\n\r\n return output;\r\n};\r\n\r\n/**\r\n * A basic interface for an Observable type\r\n */\r\nexport interface IObservable {\r\n subscribe(sub?: IObservableConfig): ISubscription;\r\n}\r\n\r\nexport interface IObservableConfig {\r\n next(): void;\r\n error(err?: any): void;\r\n complete(): void;\r\n}\r\n\r\n/**\r\n * A basic interface for a Subscription to an Observable\r\n */\r\ninterface ISubscription {\r\n unsubscribe(): void;\r\n}\r\n\r\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\r\n\r\n/**\r\n * wraps a subscription, allowing unsubscribe calls even if\r\n * the first value comes synchronously\r\n */\r\nclass SafeSubscription {\r\n\r\n private _subscribed: boolean;\r\n private _subscription: ISubscription;\r\n\r\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\r\n this._subscribed = true;\r\n this._subscription = subscriptionFunc(this);\r\n\r\n if (!this._subscribed) {\r\n this.unsubscribe();\r\n }\r\n }\r\n\r\n get subscribed(): boolean {\r\n return this._subscribed;\r\n }\r\n\r\n unsubscribe(): void {\r\n if (this._subscribed && this._subscription) {\r\n this._subscription.unsubscribe();\r\n }\r\n\r\n this._subscribed = false;\r\n }\r\n}\r\n\r\n/**\r\n * A function to process return value from `activate`/`canActivate` steps\r\n * Supports observable/promise\r\n *\r\n * For observable, resolve at first next() or on complete()\r\n */\r\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\r\n // if promise like\r\n if (obj && typeof obj.then === 'function') {\r\n return Promise.resolve(obj).then(resolve).catch(reject);\r\n }\r\n\r\n // if observable\r\n if (obj && typeof obj.subscribe === 'function') {\r\n let obs: IObservable = obj;\r\n return new SafeSubscription(sub => obs.subscribe({\r\n next() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n },\r\n error(error) {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n reject(error);\r\n }\r\n },\r\n complete() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n }\r\n }));\r\n }\r\n\r\n // else just resolve\r\n try {\r\n return resolve(obj);\r\n } catch (error) {\r\n return reject(error);\r\n }\r\n};\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { processDeactivatable, processActivatable } from './utilities-activation';\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\r\n */\r\nexport class CanDeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\r\n */\r\nexport class CanActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'canActivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\r\n */\r\nexport class DeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\r\n */\r\nexport class ActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'activate', next, true);\r\n }\r\n}\r\n","import { Container } from 'aurelia-dependency-injection';\r\nimport { Pipeline } from './pipeline';\r\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\r\nimport { LoadRouteStep } from './step-load-route';\r\nimport { CommitChangesStep } from './step-commit-changes';\r\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\r\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\r\n */\r\nclass PipelineSlot implements IPipelineSlot {\r\n\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n slotName: string;\r\n /**@internal */\r\n slotAlias?: string;\r\n\r\n steps: (Function | PipelineStep)[] = [];\r\n\r\n constructor(container: Container, name: string, alias?: string) {\r\n this.container = container;\r\n this.slotName = name;\r\n this.slotAlias = alias;\r\n }\r\n\r\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\r\n return this.steps.map(x => this.container.get(x));\r\n }\r\n}\r\n\r\n/**\r\n * Class responsible for creating the navigation pipeline.\r\n */\r\nexport class PipelineProvider {\r\n\r\n /**@internal */\r\n static inject() { return [Container]; }\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n steps: (Function | PipelineSlot)[];\r\n\r\n constructor(container: Container) {\r\n this.container = container;\r\n this.steps = [\r\n BuildNavigationPlanStep,\r\n CanDeactivatePreviousStep, // optional\r\n LoadRouteStep,\r\n createPipelineSlot(container, PipelineSlotName.Authorize),\r\n CanActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\r\n // NOTE: app state changes start below - point of no return\r\n DeactivatePreviousStep, // optional\r\n ActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\r\n CommitChangesStep,\r\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\r\n ];\r\n }\r\n\r\n /**\r\n * Create the navigation pipeline.\r\n */\r\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\r\n let pipeline = new Pipeline();\r\n this.steps.forEach(step => {\r\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\r\n pipeline.addStep(this.container.get(step));\r\n }\r\n });\r\n return pipeline;\r\n }\r\n\r\n /**@internal */\r\n _findStep(name: string): PipelineSlot {\r\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\r\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\r\n }\r\n\r\n /**\r\n * Adds a step into the pipeline at a known slot location.\r\n */\r\n addStep(name: string, step: PipelineStep | Function): void {\r\n let found = this._findStep(name);\r\n if (found) {\r\n let slotSteps = found.steps;\r\n // prevent duplicates\r\n if (!slotSteps.includes(step)) {\r\n slotSteps.push(step);\r\n }\r\n } else {\r\n throw new Error(`Invalid pipeline slot name: ${name}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Removes a step from a slot in the pipeline\r\n */\r\n removeStep(name: string, step: PipelineStep): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n let slotSteps = slot.steps;\r\n slotSteps.splice(slotSteps.indexOf(step), 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clears all steps from a slot in the pipeline\r\n * @internal\r\n */\r\n _clearSteps(name: string = ''): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n slot.steps = [];\r\n }\r\n }\r\n\r\n /**\r\n * Resets all pipeline slots\r\n */\r\n reset(): void {\r\n this._clearSteps(PipelineSlotName.Authorize);\r\n this._clearSteps(PipelineSlotName.PreActivate);\r\n this._clearSteps(PipelineSlotName.PreRender);\r\n this._clearSteps(PipelineSlotName.PostRender);\r\n }\r\n}\r\n\r\n/**@internal */\r\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\r\n return new PipelineSlot(container, name, alias);\r\n};\r\n","import * as LogManager from 'aurelia-logging';\r\nimport { Container } from 'aurelia-dependency-injection';\r\nimport { History, NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\nimport { PipelineProvider } from './pipeline-provider';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\r\nimport { RouterEvent } from './router-event';\r\nimport { RouterConfiguration } from './router-configuration';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-dependency-injection' {\r\n interface Container {\r\n viewModel?: any;\r\n }\r\n}\r\n\r\nconst logger = LogManager.getLogger('app-router');\r\n\r\n/**\r\n * The main application router.\r\n */\r\nexport class AppRouter extends Router {\r\n\r\n /**@internal */\r\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\r\n\r\n events: EventAggregator;\r\n /**@internal */\r\n maxInstructionCount: number;\r\n /**@internal */\r\n _queue: NavigationInstruction[];\r\n /**@internal */\r\n isActive: boolean;\r\n\r\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\r\n super(container, history); // Note the super will call reset internally.\r\n this.pipelineProvider = pipelineProvider;\r\n this.events = events;\r\n }\r\n\r\n /**\r\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\r\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\r\n */\r\n reset(): void {\r\n super.reset();\r\n this.maxInstructionCount = 10;\r\n if (!this._queue) {\r\n this._queue = [];\r\n } else {\r\n this._queue.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Loads the specified URL.\r\n *\r\n * @param url The URL fragment to load.\r\n */\r\n loadUrl(url: string): Promise {\r\n return this\r\n ._createNavigationInstruction(url)\r\n .then(instruction => this._queueInstruction(instruction))\r\n .catch(error => {\r\n logger.error(error);\r\n restorePreviousLocation(this);\r\n });\r\n }\r\n\r\n /**\r\n * Registers a viewPort to be used as a rendering target for activated routes.\r\n *\r\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\r\n * @param name The name of the viewPort. 'default' if unspecified.\r\n */\r\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\r\n // having strong typing without changing public API\r\n const $viewPort: ViewPort = viewPort;\r\n super.registerViewPort($viewPort, name);\r\n\r\n // beside adding viewport to the registry of this instance\r\n // AppRouter also configure routing/history to start routing functionality\r\n // There are situation where there are more than 1 element at root view\r\n // in that case, still only activate once via the following guard\r\n if (!this.isActive) {\r\n const viewModel = this._findViewModel($viewPort);\r\n if ('configureRouter' in viewModel) {\r\n // If there are more than one element at root view\r\n // use this flag to guard against configure method being invoked multiple times\r\n // this flag is set inside method configure\r\n if (!this.isConfigured) {\r\n // replace the real resolve with a noop to guarantee that any action in base class Router\r\n // won't resolve the configurePromise prematurely\r\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\r\n this._resolveConfiguredPromise = () => {/**/};\r\n return this\r\n .configure(config =>\r\n Promise\r\n .resolve(viewModel.configureRouter(config, this))\r\n // an issue with configure interface. Should be fixed there\r\n // todo: fix this via configure interface in router\r\n .then(() => config) as any\r\n )\r\n .then(() => {\r\n this.activate();\r\n resolveConfiguredPromise();\r\n });\r\n }\r\n } else {\r\n this.activate();\r\n }\r\n }\r\n // when a viewport is added dynamically to a root view that is already activated\r\n // just process the navigation instruction\r\n else {\r\n this._dequeueInstruction();\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\r\n *\r\n * @params options The set of options to activate the router with.\r\n */\r\n activate(options?: NavigationOptions): void {\r\n if (this.isActive) {\r\n return;\r\n }\r\n\r\n this.isActive = true;\r\n // route handler property is responsible for handling url change\r\n // the interface of aurelia-history isn't clear on this perspective\r\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\r\n this.history.activate(this.options);\r\n this._dequeueInstruction();\r\n }\r\n\r\n /**\r\n * Deactivates the router.\r\n */\r\n deactivate(): void {\r\n this.isActive = false;\r\n this.history.deactivate();\r\n }\r\n\r\n /**@internal */\r\n _queueInstruction(instruction: NavigationInstruction): Promise {\r\n return new Promise((resolve) => {\r\n instruction.resolve = resolve;\r\n this._queue.unshift(instruction);\r\n this._dequeueInstruction();\r\n });\r\n }\r\n\r\n /**@internal */\r\n _dequeueInstruction(instructionCount: number = 0): Promise {\r\n return Promise.resolve().then(() => {\r\n if (this.isNavigating && !instructionCount) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n let instruction = this._queue.shift();\r\n this._queue.length = 0;\r\n\r\n if (!instruction) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n this.isNavigating = true;\r\n\r\n let navtracker: number = this.history.getState('NavigationTracker');\r\n let currentNavTracker = this.currentNavigationTracker;\r\n\r\n if (!navtracker && !currentNavTracker) {\r\n this.isNavigatingFirst = true;\r\n this.isNavigatingNew = true;\r\n } else if (!navtracker) {\r\n this.isNavigatingNew = true;\r\n } else if (!currentNavTracker) {\r\n this.isNavigatingRefresh = true;\r\n } else if (currentNavTracker < navtracker) {\r\n this.isNavigatingForward = true;\r\n } else if (currentNavTracker > navtracker) {\r\n this.isNavigatingBack = true;\r\n } if (!navtracker) {\r\n navtracker = Date.now();\r\n this.history.setState('NavigationTracker', navtracker);\r\n }\r\n this.currentNavigationTracker = navtracker;\r\n\r\n instruction.previousInstruction = this.currentInstruction;\r\n\r\n let maxInstructionCount = this.maxInstructionCount;\r\n\r\n if (!instructionCount) {\r\n this.events.publish(RouterEvent.Processing, { instruction });\r\n } else if (instructionCount === maxInstructionCount - 1) {\r\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\r\n restorePreviousLocation(this);\r\n return this._dequeueInstruction(instructionCount + 1);\r\n } else if (instructionCount > maxInstructionCount) {\r\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\r\n }\r\n\r\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\r\n\r\n return pipeline\r\n .run(instruction)\r\n .then(result => processResult(instruction, result, instructionCount, this))\r\n .catch(error => {\r\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\r\n })\r\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\r\n });\r\n }\r\n\r\n /**@internal */\r\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\r\n if (this.container.viewModel) {\r\n return this.container.viewModel;\r\n }\r\n\r\n if (viewPort.container) {\r\n let container = viewPort.container;\r\n\r\n while (container) {\r\n if (container.viewModel) {\r\n this.container.viewModel = container.viewModel;\r\n return container.viewModel;\r\n }\r\n\r\n container = container.parent;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n\r\nconst processResult = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n instructionCount: number,\r\n router: AppRouter\r\n): Promise => {\r\n if (!(result && 'completed' in result && 'output' in result)) {\r\n result = result || {} as PipelineResult;\r\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\r\n }\r\n\r\n let finalResult: PipelineResult = null;\r\n let navigationCommandResult = null;\r\n if (isNavigationCommand(result.output)) {\r\n navigationCommandResult = result.output.navigate(router);\r\n } else {\r\n finalResult = result;\r\n\r\n if (!result.completed) {\r\n if (result.output instanceof Error) {\r\n logger.error(result.output.toString());\r\n }\r\n\r\n restorePreviousLocation(router);\r\n }\r\n }\r\n\r\n return Promise.resolve(navigationCommandResult)\r\n .then(_ => router._dequeueInstruction(instructionCount + 1))\r\n .then(innerResult => finalResult || innerResult || result);\r\n};\r\n\r\nconst resolveInstruction = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n isInnerInstruction: boolean,\r\n router: AppRouter\r\n): PipelineResult => {\r\n instruction.resolve(result);\r\n\r\n let eventAggregator = router.events;\r\n let eventArgs = { instruction, result };\r\n if (!isInnerInstruction) {\r\n router.isNavigating = false;\r\n router.isExplicitNavigation = false;\r\n router.isExplicitNavigationBack = false;\r\n router.isNavigatingFirst = false;\r\n router.isNavigatingNew = false;\r\n router.isNavigatingRefresh = false;\r\n router.isNavigatingForward = false;\r\n router.isNavigatingBack = false;\r\n router.couldDeactivate = false;\r\n\r\n let eventName: string;\r\n\r\n if (result.output instanceof Error) {\r\n eventName = RouterEvent.Error;\r\n } else if (!result.completed) {\r\n eventName = RouterEvent.Canceled;\r\n } else {\r\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\r\n router.history.previousLocation = instruction.fragment + queryString;\r\n eventName = RouterEvent.Success;\r\n }\r\n\r\n eventAggregator.publish(eventName, eventArgs);\r\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\r\n } else {\r\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst restorePreviousLocation = (router: AppRouter): void => {\r\n let previousLocation = router.history.previousLocation;\r\n if (previousLocation) {\r\n router.navigate(previousLocation, { trigger: false, replace: true });\r\n } else if (router.fallbackRoute) {\r\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\r\n } else {\r\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\r\n }\r\n};\r\n","/**\r\n* The status of a Pipeline.\r\n*/\r\nexport const enum PipelineStatus {\r\n Completed = 'completed',\r\n Canceled = 'canceled',\r\n Rejected = 'rejected',\r\n Running = 'running'\r\n}\r\n","/**\r\n * A list of known router events used by the Aurelia router\r\n * to signal the pipeline has come to a certain state\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum RouterEvent {\r\n Processing = 'router:navigation:processing',\r\n Error = 'router:navigation:error',\r\n Canceled = 'router:navigation:canceled',\r\n Complete = 'router:navigation:complete',\r\n Success = 'router:navigation:success',\r\n ChildComplete = 'router:navigation:child:complete'\r\n}\r\n","/**\r\n * Available pipeline slot names to insert interceptor into router pipeline\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum PipelineSlotName {\r\n /**\r\n * Authorization slot. Invoked early in the pipeline,\r\n * before `canActivate` hook of incoming route\r\n */\r\n Authorize = 'authorize',\r\n /**\r\n * Pre-activation slot. Invoked early in the pipeline,\r\n * Invoked timing:\r\n * - after Authorization slot\r\n * - after canActivate hook on new view model\r\n * - before deactivate hook on old view model\r\n * - before activate hook on new view model\r\n */\r\n PreActivate = 'preActivate',\r\n /**\r\n * Pre-render slot. Invoked later in the pipeline\r\n * Invokcation timing:\r\n * - after activate hook on new view model\r\n * - before commit step on new navigation instruction\r\n */\r\n PreRender = 'preRender',\r\n /**\r\n * Post-render slot. Invoked last in the pipeline\r\n */\r\n PostRender = 'postRender'\r\n}\r\n"],"names":["RouteRecognizer","Container","LogManager.getLogger","tslib_1.__extends","History","EventAggregator","PipelineStatus","RouterEvent","PipelineSlotName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BA;;;AAGA;QA4DE,+BAAY,IAA+B;;;;YAT3C,SAAI,GAAwC,IAAI,CAAC;YAEjD,YAAO,GAAwB,EAAE,CAAC;YAQhC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAE1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;YAE/B,IAAI,cAAc,GAAG,EAAE,CAAC;YACxB,IAAI,OAAO,GAA0B,IAAI,CAAC;YAC1C,GAAG;gBACD,IAAI,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;gBACtD,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE;;oBAEnD,OAAO,aAAa,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;iBACjD;gBAED,cAAc,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;gBACtC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;aACrC,QAAQ,OAAO,EAAE;YAElB,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,OAAb,MAAM,GAAQ,EAAE,EAAE,IAAI,CAAC,WAAW,SAAK,cAAc,EAAC,CAAC;YACvE,IAAI,CAAC,aAAa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AAE,IAAI,EAAE,CAAC,CAAC;SACzE;aAAM;YACL,MAAM,CAAC,KAAK,CAAC,wFAAwF,CAAC,CAAC;SACxG;IACH,CAAC,CAAC;;ICzUF;;;AAGA,IAAA,WAAkB,cAAc;QAC9B,yCAAuB,CAAA;QACvB,uCAAqB,CAAA;QACrB,uCAAqB,CAAA;QACrB,qCAAmB,CAAA;IACrB,CAAC,EALiBC,sBAAc,KAAdA,sBAAc,QAK/B;;ICRD;;;;AAIA,IACA,WAAkB,WAAW;QAC3B,0DAA2C,CAAA;QAC3C,gDAAiC,CAAA;QACjC,sDAAuC,CAAA;QACvC,sDAAuC,CAAA;QACvC,oDAAqC,CAAA;QACrC,iEAAkD,CAAA;IACpD,CAAC,EAPiBC,mBAAW,KAAXA,mBAAW,QAO5B;;ICZD;;;AAGA,IACA,WAAkB,gBAAgB;;;;;QAKhC,2CAAuB,CAAA;;;;;;;;;QASvB,+CAA2B,CAAA;;;;;;;QAO3B,2CAAuB,CAAA;;;;QAIvB,6CAAyB,CAAA;IAC3B,CAAC,EA1BiBC,wBAAgB,KAAhBA,wBAAgB,QA0BjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/aurelia-router.d.ts b/dist/aurelia-router.d.ts index 4b192ce4..4877808e 100644 --- a/dist/aurelia-router.d.ts +++ b/dist/aurelia-router.d.ts @@ -288,7 +288,7 @@ export declare class Router { * @param fragment The URL fragment to use as the navigation destination. * @param options The navigation options. */ - navigate(fragment: string, options?: NavigationOptions): boolean; + navigate(fragment: string, options?: NavigationOptions): NavigationResult; /** * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed * by [[Router.navigate]]. @@ -297,7 +297,7 @@ export declare class Router { * @param params The route parameters to be used when populating the route pattern. * @param options The navigation options. */ - navigateToRoute(route: string, params?: any, options?: NavigationOptions): boolean; + navigateToRoute(route: string, params?: any, options?: NavigationOptions): NavigationResult; /** * Navigates back to the most recent location in history. */ diff --git a/dist/commonjs/aurelia-router.js.map b/dist/commonjs/aurelia-router.js.map index 0bb19d9a..1f3adb7f 100644 --- a/dist/commonjs/aurelia-router.js.map +++ b/dist/commonjs/aurelia-router.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\nimport { Router } from './router';\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\n\n/**\n * Initialization options for a navigation instruction\n */\nexport interface NavigationInstructionInit {\n fragment: string;\n queryString?: string;\n params?: Record;\n queryParams?: Record;\n config: RouteConfig;\n parentInstruction?: NavigationInstruction;\n previousInstruction?: NavigationInstruction;\n router: Router;\n options?: Object;\n plan?: Record;\n}\n\nexport interface ViewPortInstructionInit {\n name: string;\n strategy: ActivationStrategyType;\n moduleId: string;\n component: ViewPortComponent;\n}\n\n/**\n * Class used to represent an instruction during a navigation.\n */\nexport class NavigationInstruction {\n /**\n * The URL fragment.\n */\n fragment: string;\n\n /**\n * The query string.\n */\n queryString: string;\n\n /**\n * Parameters extracted from the route pattern.\n */\n params: any;\n\n /**\n * Parameters extracted from the query string.\n */\n queryParams: any;\n\n /**\n * The route config for the route matching this instruction.\n */\n config: RouteConfig;\n\n /**\n * The parent instruction, if this instruction was created by a child router.\n */\n parentInstruction: NavigationInstruction;\n\n parentCatchHandler: any;\n\n /**\n * The instruction being replaced by this instruction in the current router.\n */\n previousInstruction: NavigationInstruction;\n\n /**\n * viewPort instructions to used activation.\n */\n viewPortInstructions: Record;\n\n /**\n * The router instance.\n */\n router: Router;\n\n /**\n * Current built viewport plan of this nav instruction\n */\n plan: Record = null;\n\n options: Record = {};\n\n /**@internal */\n lifecycleArgs: LifecycleArguments;\n /**@internal */\n resolve?: (val?: any) => void;\n\n constructor(init: NavigationInstructionInit) {\n Object.assign(this, init);\n\n this.params = this.params || {};\n this.viewPortInstructions = {};\n\n let ancestorParams = [];\n let current: NavigationInstruction = this;\n do {\n let currentParams = Object.assign({}, current.params);\n if (current.config && current.config.hasChildRouter) {\n // remove the param for the injected child route segment\n delete currentParams[current.getWildCardName()];\n }\n\n ancestorParams.unshift(currentParams);\n current = current.parentInstruction;\n } while (current);\n\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\n this.lifecycleArgs = [allParams, this.config, this];\n }\n\n /**\n * Gets an array containing this instruction and all child instructions for the current navigation.\n */\n getAllInstructions(): Array {\n let instructions: NavigationInstruction[] = [this];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let key in viewPortInstructions) {\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\n if (childInstruction) {\n instructions.push(...childInstruction.getAllInstructions());\n }\n }\n\n return instructions;\n }\n\n /**\n * Gets an array containing the instruction and all child instructions for the previous navigation.\n * Previous instructions are no longer available after navigation completes.\n */\n getAllPreviousInstructions(): Array {\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\n }\n\n /**\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\n */\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\n addViewPortInstruction(\n nameOrInitOptions: string | ViewPortInstructionInit,\n strategy?: ActivationStrategyType,\n moduleId?: string,\n component?: any\n ): /*ViewPortInstruction*/ any {\n\n let viewPortInstruction: ViewPortInstruction;\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\n const lifecycleArgs = this.lifecycleArgs;\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\n\n if (typeof nameOrInitOptions === 'string') {\n viewPortInstruction = {\n name: nameOrInitOptions,\n strategy: strategy,\n moduleId: moduleId,\n component: component,\n childRouter: component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n } else {\n viewPortInstruction = {\n name: viewPortName,\n strategy: nameOrInitOptions.strategy,\n component: nameOrInitOptions.component,\n moduleId: nameOrInitOptions.moduleId,\n childRouter: nameOrInitOptions.component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n }\n\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\n }\n\n /**\n * Gets the name of the route pattern's wildcard parameter, if applicable.\n */\n getWildCardName(): string {\n // todo: potential issue, or at least unsafe typings\n let configRoute = this.config.route as string;\n let wildcardIndex = configRoute.lastIndexOf('*');\n return configRoute.substr(wildcardIndex + 1);\n }\n\n /**\n * Gets the path and query string created by filling the route\n * pattern's wildcard parameter with the matching param.\n */\n getWildcardPath(): string {\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n let queryString = this.queryString;\n\n if (queryString) {\n path += '?' + queryString;\n }\n\n return path;\n }\n\n /**\n * Gets the instruction's base URL, accounting for wildcard route parameters.\n */\n getBaseUrl(): string {\n let $encodeURI = encodeURI;\n let fragment = decodeURI(this.fragment);\n\n if (fragment === '') {\n let nonEmptyRoute = this.router.routes.find(route => {\n return route.name === this.config.name &&\n route.route !== '';\n });\n if (nonEmptyRoute) {\n fragment = nonEmptyRoute.route as any;\n }\n }\n\n if (!this.params) {\n return $encodeURI(fragment);\n }\n\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n\n if (!path) {\n return $encodeURI(fragment);\n }\n\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\n }\n\n /**\n * Finalize a viewport instruction\n * @internal\n */\n _commitChanges(waitToSwap: boolean): Promise {\n let router = this.router;\n router.currentInstruction = this;\n\n const previousInstruction = this.previousInstruction;\n if (previousInstruction) {\n previousInstruction.config.navModel.isActive = false;\n }\n\n this.config.navModel.isActive = true;\n\n router.refreshNavigation();\n\n let loads: Promise[] = [];\n let delaySwaps: ISwapPlan[] = [];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let viewPort = router.viewPorts[viewPortName];\n\n if (!viewPort) {\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\n }\n\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n } else {\n if (waitToSwap) {\n delaySwaps.push({ viewPort, viewPortInstruction });\n }\n loads.push(\n viewPort\n .process(viewPortInstruction, waitToSwap)\n .then(() => childNavInstruction\n ? childNavInstruction._commitChanges(waitToSwap)\n : Promise.resolve()\n )\n );\n }\n } else {\n if (childNavInstruction) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n }\n }\n }\n\n return Promise\n .all(loads)\n .then(() => {\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\n return null;\n })\n .then(() => prune(this));\n }\n\n /**@internal */\n _updateTitle(): void {\n let router = this.router;\n let title = this._buildTitle(router.titleSeparator);\n if (title) {\n router.history.setTitle(title);\n }\n }\n\n /**@internal */\n _buildTitle(separator: string = ' | '): string {\n let title = '';\n let childTitles = [];\n let navModelTitle = this.config.navModel.title;\n let instructionRouter = this.router;\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n if (navModelTitle) {\n title = instructionRouter.transformTitle(navModelTitle);\n }\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\n\n if (child_nav_instruction) {\n let childTitle = child_nav_instruction._buildTitle(separator);\n if (childTitle) {\n childTitles.push(childTitle);\n }\n }\n }\n\n if (childTitles.length) {\n title = childTitles.join(separator) + (title ? separator : '') + title;\n }\n\n if (instructionRouter.title) {\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\n }\n\n return title;\n }\n}\n\nconst prune = (instruction: NavigationInstruction): void => {\n instruction.previousInstruction = null;\n instruction.plan = null;\n};\n\ninterface ISwapPlan {\n viewPort: ViewPort;\n viewPortInstruction: ViewPortInstruction;\n}\n","import { Router } from './router';\nimport { RouteConfig } from './interfaces';\n\n/**\n* Class for storing and interacting with a route's navigation settings.\n*/\nexport class NavModel {\n\n /**\n * True if this nav item is currently active.\n */\n isActive: boolean = false;\n\n /**\n * The title.\n */\n title: string = null;\n\n /**\n * This nav item's absolute href.\n */\n href: string = null;\n\n /**\n * This nav item's relative href.\n */\n relativeHref: string = null;\n\n /**\n * Data attached to the route at configuration time.\n */\n settings: any = {};\n\n /**\n * The route config.\n */\n config: RouteConfig = null;\n\n /**\n * The router associated with this navigation model.\n */\n router: Router;\n\n order: number | boolean;\n\n constructor(router: Router, relativeHref: string) {\n this.router = router;\n this.relativeHref = relativeHref;\n }\n\n /**\n * Sets the route's title and updates document.title.\n * If the a navigation is in progress, the change will be applied\n * to document.title when the navigation completes.\n *\n * @param title The new title.\n */\n setTitle(title: string): void {\n this.title = title;\n\n if (this.isActive) {\n this.router.updateTitle();\n }\n }\n}\n","import { RouteConfig } from './interfaces';\n\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\n if (!hasPushState && path[0] !== '#') {\n path = '#' + path;\n }\n\n if (hasPushState && absolute) {\n path = path.substring(1, path.length);\n }\n\n return path;\n}\n\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\n if (isAbsoluteUrl.test(fragment)) {\n return fragment;\n }\n\n let path = '';\n\n if (baseUrl.length && baseUrl[0] !== '/') {\n path += '/';\n }\n\n path += baseUrl;\n\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\n path += '/';\n }\n\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\n path = path.substring(0, path.length - 1);\n }\n\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\n}\n\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\n if (isRootedPath.test(fragment)) {\n return _normalizeAbsolutePath(fragment, hasPushState);\n }\n\n return _createRootedPath(fragment, baseUrl, hasPushState);\n}\n\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\n let routeConfigs = [];\n\n if (Array.isArray(config.route)) {\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\n let current = Object.assign({}, config);\n current.route = config.route[i];\n routeConfigs.push(current);\n }\n } else {\n routeConfigs.push(Object.assign({}, config));\n }\n\n return routeConfigs;\n}\n\nconst isRootedPath = /^#?\\//;\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\nimport { Router } from './router';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * Class used to configure a [[Router]] instance.\n *\n * @constructor\n */\nexport class RouterConfiguration {\n instructions: Array<(router: Router) => void> = [];\n options: {\n [key: string]: any;\n compareQueryParams?: boolean;\n root?: string;\n pushState?: boolean;\n hashChange?: boolean;\n silent?: boolean;\n } = {};\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\n title: string;\n titleSeparator: string;\n unknownRouteConfig: RouteConfigSpecifier;\n viewPortDefaults: Record;\n\n /**@internal */\n _fallbackRoute: string;\n\n /**\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\n *\n * @param name The name of the pipeline slot to insert the step into.\n * @param step The pipeline step.\n * @chainable\n */\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\n if (step === null || step === undefined) {\n throw new Error('Pipeline step cannot be null or undefined.');\n }\n this.pipelineSteps.push({ name, step });\n return this;\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\n }\n\n /**\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @chainable\n */\n fallbackRoute(fragment: string): RouterConfiguration {\n this._fallbackRoute = fragment;\n return this;\n }\n\n /**\n * Maps one or more routes to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\n * @chainable\n */\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\n if (Array.isArray(route)) {\n route.forEach(r => this.map(r));\n return this;\n }\n\n return this.mapRoute(route);\n }\n\n /**\n * Configures defaults to use for any view ports.\n *\n * @param viewPortConfig a view port configuration object to use as a\n * default, of the form { viewPortName: { moduleId } }.\n * @chainable\n */\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\n this.viewPortDefaults = viewPortConfig;\n return this;\n }\n\n /**\n * Maps a single route to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map.\n * @chainable\n */\n mapRoute(config: RouteConfig): RouterConfiguration {\n this.instructions.push(router => {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n\n let navModel;\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\n let routeConfig = routeConfigs[i];\n routeConfig.settings = routeConfig.settings || {};\n if (!navModel) {\n navModel = router.createNavModel(routeConfig);\n }\n\n router.addRoute(routeConfig, navModel);\n }\n });\n\n return this;\n }\n\n /**\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\n *\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\n * [[NavigationInstruction]] and selects a moduleId to load.\n * @chainable\n */\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\n this.unknownRouteConfig = config;\n return this;\n }\n\n /**\n * Applies the current configuration to the specified [[Router]].\n *\n * @param router The [[Router]] to apply the configuration to.\n */\n exportToRouter(router: Router): void {\n let instructions = this.instructions;\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\n instructions[i](router);\n }\n\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\n\n if (title) {\n router.title = title;\n }\n\n if (titleSeparator) {\n router.titleSeparator = titleSeparator;\n }\n\n if (unknownRouteConfig) {\n router.handleUnknownRoutes(unknownRouteConfig);\n }\n\n if (_fallbackRoute) {\n router.fallbackRoute = _fallbackRoute;\n }\n\n if (viewPortDefaults) {\n router.useViewPortDefaults(viewPortDefaults);\n }\n\n Object.assign(router.options, this.options);\n\n let pipelineSteps = this.pipelineSteps;\n let pipelineStepCount = pipelineSteps.length;\n if (pipelineStepCount) {\n if (!router.isRoot) {\n throw new Error('Pipeline steps can only be added to the root router');\n }\n\n let pipelineProvider = router.pipelineProvider;\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\n let { name, step } = pipelineSteps[i];\n pipelineProvider.addStep(name, step);\n }\n }\n }\n}\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): boolean {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): boolean {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\n\n/**@internal exported for unit testing */\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\n let index = -1;\n const next: Next = function() {\n index++;\n\n if (index < steps.length) {\n let currentStep = steps[index];\n\n try {\n return currentStep(instruction, next);\n } catch (e) {\n return next.reject(e);\n }\n } else {\n return next.complete();\n }\n } as Next;\n\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\n\n return next;\n};\n\n/**@internal exported for unit testing */\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\n return (output: any) => Promise\n .resolve({\n status,\n output,\n completed: status === PipelineStatus.Completed\n });\n};\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { createNextFn } from './next';\n\n/**\n * The class responsible for managing and processing the navigation pipeline.\n */\nexport class Pipeline {\n /**\n * The pipeline steps. And steps added via addStep will be converted to a function\n * The actualy running functions with correct step contexts of this pipeline\n */\n steps: StepRunnerFunction[] = [];\n\n /**\n * Adds a step to the pipeline.\n *\n * @param step The pipeline step.\n */\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\n let run;\n\n if (typeof step === 'function') {\n run = step;\n } else if (typeof step.getSteps === 'function') {\n // getSteps is to enable support open slots\n // where devs can add multiple steps into the same slot name\n let steps = step.getSteps();\n for (let i = 0, l = steps.length; i < l; i++) {\n this.addStep(steps[i]);\n }\n\n return this;\n } else {\n run = (step as PipelineStep).run.bind(step);\n }\n\n this.steps.push(run);\n\n return this;\n }\n\n /**\n * Runs the pipeline.\n *\n * @param instruction The navigation instruction to process.\n */\n run(instruction: NavigationInstruction): Promise {\n const nextFn = createNextFn(instruction, this.steps);\n return nextFn();\n }\n}\n","import { NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface NavigationOptions {\n useAppRouter?: boolean;\n }\n}\n\n/**\n* When a navigation command is encountered, the current navigation\n* will be cancelled and control will be passed to the navigation\n* command so it can determine the correct action.\n*/\nexport interface NavigationCommand {\n navigate: (router: Router) => void;\n /**@internal */\n shouldContinueProcessing?: boolean;\n /**@internal */\n setRouter?: (router: Router) => void;\n}\n\n/**\n* Determines if the provided object is a navigation command.\n* A navigation command is anything with a navigate method.\n*\n* @param obj The object to check.\n*/\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\n return obj && typeof obj.navigate === 'function';\n}\n\n/**\n* Used during the activation lifecycle to cause a redirect.\n*/\nexport class Redirect implements NavigationCommand {\n\n url: string;\n /**@internal */\n options: NavigationOptions;\n /**@internal */\n shouldContinueProcessing: boolean;\n\n private router: Router;\n\n /**\n * @param url The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n constructor(url: string, options: NavigationOptions = {}) {\n this.url = url;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigate(this.url, this.options);\n }\n}\n\n/**\n * Used during the activation lifecycle to cause a redirect to a named route.\n */\nexport class RedirectToRoute implements NavigationCommand {\n\n route: string;\n params: any;\n /**@internal */\n options: NavigationOptions;\n\n /**@internal */\n shouldContinueProcessing: boolean;\n\n /**@internal */\n router: Router;\n\n /**\n * @param route The name of the route.\n * @param params The parameters to be sent to the activation method.\n * @param options The options to use for navigation.\n */\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\n this.route = route;\n this.params = params;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\n }\n}\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\n\ntype ViewPortPlansRecord = Record;\n\n/**\n * @internal exported for unit testing\n */\nexport function _buildNavigationPlan(\n instruction: NavigationInstruction,\n forceLifecycleMinimum?: boolean\n): Promise {\n let config = instruction.config;\n\n if ('redirect' in config) {\n return buildRedirectPlan(instruction);\n }\n\n const prevInstruction = instruction.previousInstruction;\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\n\n if (prevInstruction) {\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\n }\n\n // first navigation, only need to prepare a few information for each viewport plan\n const viewPortPlans: ViewPortPlansRecord = {};\n let viewPortConfigs = config.viewPorts;\n for (let viewPortName in viewPortConfigs) {\n let viewPortConfig = viewPortConfigs[viewPortName];\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n viewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n viewPortPlans[viewPortName] = {\n name: viewPortName,\n strategy: InternalActivationStrategy.Replace,\n config: viewPortConfig\n };\n }\n\n return Promise.resolve(viewPortPlans);\n}\n\n/**\n * Build redirect plan based on config of a navigation instruction\n * @internal exported for unit testing\n */\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\n const config = instruction.config;\n const router = instruction.router;\n return router\n ._createNavigationInstruction(config.redirect)\n .then(redirectInstruction => {\n\n const params: Record = {};\n const originalInstructionParams = instruction.params;\n const redirectInstructionParams = redirectInstruction.params;\n\n for (let key in redirectInstructionParams) {\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\n let val = redirectInstructionParams[key];\n if (typeof val === 'string' && val[0] === ':') {\n val = val.slice(1);\n // And if that param is found on the original instruction then use it\n if (val in originalInstructionParams) {\n params[key] = originalInstructionParams[val];\n }\n } else {\n params[key] = redirectInstructionParams[key];\n }\n }\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\n\n // Special handling for child routes\n for (let key in originalInstructionParams) {\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\n }\n\n let queryString = instruction.queryString;\n if (queryString) {\n redirectLocation += '?' + queryString;\n }\n\n return Promise.resolve(new Redirect(redirectLocation));\n });\n};\n\n/**\n * @param viewPortPlans the Plan record that holds information about built plans\n * @internal exported for unit testing\n */\nexport const buildTransitionPlans = (\n currentInstruction: NavigationInstruction,\n previousInstruction: NavigationInstruction,\n defaultViewPortConfigs: Record,\n forceLifecycleMinimum?: boolean\n): Promise => {\n\n let viewPortPlans: ViewPortPlansRecord = {};\n let newInstructionConfig = currentInstruction.config;\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\n let pending: Promise[] = [];\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\n\n for (let viewPortName in previousViewPortInstructions) {\n\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\n const prevViewPortComponent = prevViewPortInstruction.component;\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\n\n // if this is invoked on a viewport without any changes, based on new url,\n // newViewPortConfig will be the existing viewport instruction\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\n ? newInstructionViewPortConfigs[viewPortName]\n : prevViewPortInstruction;\n\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n\n const viewPortActivationStrategy = determineActivationStrategy(\n currentInstruction,\n prevViewPortInstruction,\n nextViewPortConfig,\n hasNewParams,\n forceLifecycleMinimum\n );\n const viewPortPlan = viewPortPlans[viewPortName] = {\n name: viewPortName,\n // ViewPortInstruction can quack like a RouteConfig\n config: nextViewPortConfig as RouteConfig,\n prevComponent: prevViewPortComponent,\n prevModuleId: prevViewPortInstruction.moduleId,\n strategy: viewPortActivationStrategy\n } as ViewPortPlan;\n\n // recursively build nav plans for all existing child routers/viewports of this viewport\n // this is possible because existing child viewports and routers already have necessary information\n // to process the wildcard path from parent instruction\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\n const path = currentInstruction.getWildcardPath();\n const task: Promise = prevViewPortInstruction\n .childRouter\n ._createNavigationInstruction(path, currentInstruction)\n .then((childInstruction: NavigationInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(\n childInstruction,\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\n // if so, can just use local variable viewPortPlanStrategy\n // there could be user code modifying viewport plan during _createNavigationInstruction?\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\n )\n .then(childPlan => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n // for bluebird ?\n return null;\n });\n });\n\n pending.push(task);\n }\n }\n\n return Promise.all(pending).then(() => viewPortPlans);\n};\n\n/**\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\n * @internal exported for unit testing\n */\nexport const determineActivationStrategy = (\n currentNavInstruction: NavigationInstruction,\n prevViewPortInstruction: ViewPortInstruction,\n newViewPortConfig: RouteConfig | ViewPortInstruction,\n // indicates whether there is difference between old and new url params\n hasNewParams: boolean,\n forceLifecycleMinimum?: boolean\n): ActivationStrategyType => {\n\n let newInstructionConfig = currentNavInstruction.config;\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\n let viewPortPlanStrategy: ActivationStrategyType;\n\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\n } else if (newInstructionConfig.activationStrategy) {\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\n } else if (hasNewParams || forceLifecycleMinimum) {\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\n } else {\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\n }\n return viewPortPlanStrategy;\n};\n\n/**@internal exported for unit testing */\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\n let prevParams = prev.params;\n let nextParams = next.params;\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\n\n for (let key in nextParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n for (let key in prevParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n if (!next.options.compareQueryParams) {\n return false;\n }\n\n let prevQueryParams = prev.queryParams;\n let nextQueryParams = next.queryParams;\n for (let key in nextQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n for (let key in prevQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n return false;\n};\n","import { Next } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\n\n/**\n * Transform a navigation instruction into viewport plan record object,\n * or a redirect request if user viewmodel demands\n */\nexport class BuildNavigationPlanStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return _buildNavigationPlan(navigationInstruction)\n .then(plan => {\n if (plan instanceof Redirect) {\n return next.cancel(plan);\n }\n navigationInstruction.plan = plan;\n return next();\n })\n .catch(next.cancel);\n }\n}\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\nimport { InternalActivationStrategy } from './activation-strategy';\nimport { RouteLoader } from './route-loader';\n\n/**\n * Loading plan calculated based on a navigration-instruction and a viewport plan\n */\ninterface ILoadingPlan {\n viewPortPlan: ViewPortPlan;\n navigationInstruction: NavigationInstruction;\n}\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadNewRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction\n): Promise => {\n let loadingPlans = determineLoadingPlans(navigationInstruction);\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\n routeLoader,\n loadingPlan.navigationInstruction,\n loadingPlan.viewPortPlan\n ));\n\n return Promise.all(loadPromises);\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const determineLoadingPlans = (\n navigationInstruction: NavigationInstruction,\n loadingPlans: ILoadingPlan[] = []\n): ILoadingPlan[] => {\n let viewPortPlans: Record = navigationInstruction.plan;\n\n for (let viewPortName in viewPortPlans) {\n let viewPortPlan = viewPortPlans[viewPortName];\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\n\n if (childNavInstruction) {\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n } else {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortName,\n strategy: viewPortPlan.strategy,\n moduleId: viewPortPlan.prevModuleId,\n component: viewPortPlan.prevComponent\n }) as ViewPortInstruction;\n\n if (childNavInstruction) {\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n }\n }\n\n return loadingPlans;\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n viewPortPlan: ViewPortPlan\n): Promise => {\n let planConfig = viewPortPlan.config;\n let moduleId = planConfig ? planConfig.moduleId : null;\n\n return loadComponent(routeLoader, navigationInstruction, planConfig)\n .then((component) => {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortPlan.name,\n strategy: viewPortPlan.strategy,\n moduleId: moduleId,\n component: component\n }) as ViewPortInstruction;\n\n let childRouter = component.childRouter;\n if (childRouter) {\n let path = navigationInstruction.getWildcardPath();\n\n return childRouter\n ._createNavigationInstruction(path, navigationInstruction)\n .then((childInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(childInstruction)\n .then((childPlan) => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n viewPortInstruction.childNavigationInstruction = childInstruction;\n\n return loadNewRoute(routeLoader, childInstruction);\n });\n });\n }\n // ts complains without this, though they are same\n return void 0;\n });\n};\n\n/**\n * Load a routed-component based on navigation instruction and route config\n * @internal exported for unit testing only\n */\nexport const loadComponent = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n config: RouteConfig\n): Promise => {\n let router = navigationInstruction.router;\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\n\n return Promise.resolve()\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\n .then(\n /**\n * @param component an object carrying information about loaded route\n * typically contains information about view model, childContainer, view and router\n */\n (component: ViewPortComponent) => {\n let { viewModel, childContainer } = component;\n component.router = router;\n component.config = config;\n\n if ('configureRouter' in viewModel) {\n let childRouter = childContainer.getChildRouter();\n component.childRouter = childRouter;\n\n return childRouter\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\n .then(() => component);\n }\n\n return component;\n }\n );\n};\n","import { RouteConfig } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Router } from './router';\n\n/**\n * Abstract class that is responsible for loading view / view model from a route config\n * The default implementation can be found in `aurelia-templating-router`\n */\nexport class RouteLoader {\n /**\n * Load a route config based on its viewmodel / view configuration\n */\n // return typing: return typings used to be never\n // as it was a throw. Changing it to Promise should not cause any issues\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\n }\n}\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { loadNewRoute } from './utilities-route-loading';\nimport { RouteLoader } from './route-loader';\n/**\n * A pipeline step responsible for loading a route config of a navigation instruction\n */\nexport class LoadRouteStep {\n /**@internal */\n static inject() { return [RouteLoader]; }\n /**\n * Route loader isntance that will handle loading route config\n * @internal\n */\n routeLoader: RouteLoader;\n constructor(routeLoader: RouteLoader) {\n this.routeLoader = routeLoader;\n }\n /**\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\n */\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return loadNewRoute(this.routeLoader, navigationInstruction)\n .then(next, next.cancel);\n }\n}\n","import { NavigationInstruction } from './navigation-instruction';\n\n/**\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\n */\nexport class CommitChangesStep {\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\n return navigationInstruction\n ._commitChanges(/*wait to swap?*/ true)\n .then(() => {\n navigationInstruction._updateTitle();\n return next();\n });\n }\n}\n","/**\n * An optional interface describing the available activation strategies.\n * @internal Used internally.\n */\nexport const enum InternalActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n NoChange = 'no-change',\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n InvokeLifecycle = 'invoke-lifecycle',\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n Replace = 'replace'\n}\n\n/**\n * The strategy to use when activating modules during navigation.\n */\n// kept for compat reason\nexport const activationStrategy: ActivationStrategy = {\n noChange: InternalActivationStrategy.NoChange,\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\n replace: InternalActivationStrategy.Replace\n};\n\n/**\n * An optional interface describing the available activation strategies.\n */\nexport interface ActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n noChange: 'no-change';\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n invokeLifecycle: 'invoke-lifecycle';\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n replace: 'replace';\n}\n\n/**\n * Enum like type for activation strategy built-in values\n */\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\nimport { isNavigationCommand } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { activationStrategy } from './activation-strategy';\nimport { Router } from './router';\n\n/**\n * Recursively find list of deactivate-able view models\n * and invoke the either 'canDeactivate' or 'deactivate' on each\n * @internal exported for unit testing\n */\nexport const processDeactivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canDeactivate' | 'deactivate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let plan: Record = navigationInstruction.plan;\n let infos = findDeactivatable(plan, callbackName);\n let i = infos.length; // query from inside out\n\n function inspect(val: any): Promise {\n if (ignoreResult || shouldContinue(val)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n if (i--) {\n try {\n let viewModel = infos[i];\n let result = viewModel[callbackName](navigationInstruction);\n return processPotential(result, inspect, next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n navigationInstruction.router.couldDeactivate = true;\n\n return next();\n }\n\n return iterate();\n};\n\n/**\n * Recursively find and returns a list of deactivate-able view models\n * @internal exported for unit testing\n */\nexport const findDeactivatable = (\n plan: Record,\n callbackName: string,\n list: IActivatableInfo[] = []\n): any[] => {\n for (let viewPortName in plan) {\n let viewPortPlan = plan[viewPortName];\n let prevComponent = viewPortPlan.prevComponent;\n\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\n && prevComponent\n ) {\n let viewModel = prevComponent.viewModel;\n\n if (callbackName in viewModel) {\n list.push(viewModel);\n }\n }\n\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\n addPreviousDeactivatable(prevComponent, callbackName, list);\n } else if (viewPortPlan.childNavigationInstruction) {\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\n }\n }\n\n return list;\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const addPreviousDeactivatable = (\n component: ViewPortComponent,\n callbackName: string,\n list: IActivatableInfo[]\n): void => {\n let childRouter = component.childRouter;\n\n if (childRouter && childRouter.currentInstruction) {\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let prevComponent = viewPortInstruction.component;\n let prevViewModel = prevComponent.viewModel;\n\n if (callbackName in prevViewModel) {\n list.push(prevViewModel);\n }\n\n addPreviousDeactivatable(prevComponent, callbackName, list);\n }\n }\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const processActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let infos = findActivatable(navigationInstruction, callbackName);\n let length = infos.length;\n let i = -1; // query from top down\n\n function inspect(val: any, router: Router): Promise {\n if (ignoreResult || shouldContinue(val, router)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n i++;\n\n if (i < length) {\n try {\n let current = infos[i];\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n return next();\n }\n\n return iterate();\n};\n\ninterface IActivatableInfo {\n viewModel: any;\n lifecycleArgs: LifecycleArguments;\n router: Router;\n}\n\n/**\n * Find list of activatable view model and add to list (3rd parameter)\n * @internal exported for unit testing\n */\nexport const findActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n list: IActivatableInfo[] = [],\n router?: Router\n): IActivatableInfo[] => {\n let plan: Record = navigationInstruction.plan;\n\n Object\n .keys(plan)\n .forEach((viewPortName) => {\n let viewPortPlan = plan[viewPortName];\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\n let viewPortComponent = viewPortInstruction.component;\n let viewModel = viewPortComponent.viewModel;\n\n if (\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\n || viewPortPlan.strategy === activationStrategy.replace\n )\n && callbackName in viewModel\n ) {\n list.push({\n viewModel,\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\n router\n });\n }\n\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (childNavInstruction) {\n findActivatable(\n childNavInstruction,\n callbackName,\n list,\n viewPortComponent.childRouter || router\n );\n }\n });\n\n return list;\n};\n\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\n if (output instanceof Error) {\n return false;\n }\n\n if (isNavigationCommand(output)) {\n if (typeof output.setRouter === 'function') {\n output.setRouter(router);\n }\n\n return !!output.shouldContinueProcessing;\n }\n\n if (output === undefined) {\n return true;\n }\n\n return output;\n};\n\n/**\n * A basic interface for an Observable type\n */\nexport interface IObservable {\n subscribe(sub?: IObservableConfig): ISubscription;\n}\n\nexport interface IObservableConfig {\n next(): void;\n error(err?: any): void;\n complete(): void;\n}\n\n/**\n * A basic interface for a Subscription to an Observable\n */\ninterface ISubscription {\n unsubscribe(): void;\n}\n\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\n\n/**\n * wraps a subscription, allowing unsubscribe calls even if\n * the first value comes synchronously\n */\nclass SafeSubscription {\n\n private _subscribed: boolean;\n private _subscription: ISubscription;\n\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\n this._subscribed = true;\n this._subscription = subscriptionFunc(this);\n\n if (!this._subscribed) {\n this.unsubscribe();\n }\n }\n\n get subscribed(): boolean {\n return this._subscribed;\n }\n\n unsubscribe(): void {\n if (this._subscribed && this._subscription) {\n this._subscription.unsubscribe();\n }\n\n this._subscribed = false;\n }\n}\n\n/**\n * A function to process return value from `activate`/`canActivate` steps\n * Supports observable/promise\n *\n * For observable, resolve at first next() or on complete()\n */\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\n // if promise like\n if (obj && typeof obj.then === 'function') {\n return Promise.resolve(obj).then(resolve).catch(reject);\n }\n\n // if observable\n if (obj && typeof obj.subscribe === 'function') {\n let obs: IObservable = obj;\n return new SafeSubscription(sub => obs.subscribe({\n next() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n },\n error(error) {\n if (sub.subscribed) {\n sub.unsubscribe();\n reject(error);\n }\n },\n complete() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n }\n }));\n }\n\n // else just resolve\n try {\n return resolve(obj);\n } catch (error) {\n return reject(error);\n }\n};\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { processDeactivatable, processActivatable } from './utilities-activation';\n\n/**\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\n */\nexport class CanDeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\n */\nexport class CanActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'canActivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\n */\nexport class DeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\n */\nexport class ActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'activate', next, true);\n }\n}\n","import { Container } from 'aurelia-dependency-injection';\nimport { Pipeline } from './pipeline';\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\nimport { LoadRouteStep } from './step-load-route';\nimport { CommitChangesStep } from './step-commit-changes';\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\n */\nclass PipelineSlot implements IPipelineSlot {\n\n /**@internal */\n container: Container;\n /**@internal */\n slotName: string;\n /**@internal */\n slotAlias?: string;\n\n steps: (Function | PipelineStep)[] = [];\n\n constructor(container: Container, name: string, alias?: string) {\n this.container = container;\n this.slotName = name;\n this.slotAlias = alias;\n }\n\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\n return this.steps.map(x => this.container.get(x));\n }\n}\n\n/**\n * Class responsible for creating the navigation pipeline.\n */\nexport class PipelineProvider {\n\n /**@internal */\n static inject() { return [Container]; }\n /**@internal */\n container: Container;\n /**@internal */\n steps: (Function | PipelineSlot)[];\n\n constructor(container: Container) {\n this.container = container;\n this.steps = [\n BuildNavigationPlanStep,\n CanDeactivatePreviousStep, // optional\n LoadRouteStep,\n createPipelineSlot(container, PipelineSlotName.Authorize),\n CanActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\n // NOTE: app state changes start below - point of no return\n DeactivatePreviousStep, // optional\n ActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\n CommitChangesStep,\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\n ];\n }\n\n /**\n * Create the navigation pipeline.\n */\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\n let pipeline = new Pipeline();\n this.steps.forEach(step => {\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\n pipeline.addStep(this.container.get(step));\n }\n });\n return pipeline;\n }\n\n /**@internal */\n _findStep(name: string): PipelineSlot {\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\n }\n\n /**\n * Adds a step into the pipeline at a known slot location.\n */\n addStep(name: string, step: PipelineStep | Function): void {\n let found = this._findStep(name);\n if (found) {\n let slotSteps = found.steps;\n // prevent duplicates\n if (!slotSteps.includes(step)) {\n slotSteps.push(step);\n }\n } else {\n throw new Error(`Invalid pipeline slot name: ${name}.`);\n }\n }\n\n /**\n * Removes a step from a slot in the pipeline\n */\n removeStep(name: string, step: PipelineStep): void {\n let slot = this._findStep(name);\n if (slot) {\n let slotSteps = slot.steps;\n slotSteps.splice(slotSteps.indexOf(step), 1);\n }\n }\n\n /**\n * Clears all steps from a slot in the pipeline\n * @internal\n */\n _clearSteps(name: string = ''): void {\n let slot = this._findStep(name);\n if (slot) {\n slot.steps = [];\n }\n }\n\n /**\n * Resets all pipeline slots\n */\n reset(): void {\n this._clearSteps(PipelineSlotName.Authorize);\n this._clearSteps(PipelineSlotName.PreActivate);\n this._clearSteps(PipelineSlotName.PreRender);\n this._clearSteps(PipelineSlotName.PostRender);\n }\n}\n\n/**@internal */\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\n return new PipelineSlot(container, name, alias);\n};\n","import * as LogManager from 'aurelia-logging';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\nimport { PipelineProvider } from './pipeline-provider';\nimport { isNavigationCommand } from './navigation-commands';\nimport { EventAggregator } from 'aurelia-event-aggregator';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\nimport { RouterEvent } from './router-event';\nimport { RouterConfiguration } from './router-configuration';\n\n/**@internal */\ndeclare module 'aurelia-dependency-injection' {\n interface Container {\n viewModel?: any;\n }\n}\n\nconst logger = LogManager.getLogger('app-router');\n\n/**\n * The main application router.\n */\nexport class AppRouter extends Router {\n\n /**@internal */\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\n\n events: EventAggregator;\n /**@internal */\n maxInstructionCount: number;\n /**@internal */\n _queue: NavigationInstruction[];\n /**@internal */\n isActive: boolean;\n\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\n super(container, history); // Note the super will call reset internally.\n this.pipelineProvider = pipelineProvider;\n this.events = events;\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset(): void {\n super.reset();\n this.maxInstructionCount = 10;\n if (!this._queue) {\n this._queue = [];\n } else {\n this._queue.length = 0;\n }\n }\n\n /**\n * Loads the specified URL.\n *\n * @param url The URL fragment to load.\n */\n loadUrl(url: string): Promise {\n return this\n ._createNavigationInstruction(url)\n .then(instruction => this._queueInstruction(instruction))\n .catch(error => {\n logger.error(error);\n restorePreviousLocation(this);\n });\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\n // having strong typing without changing public API\n const $viewPort: ViewPort = viewPort;\n super.registerViewPort($viewPort, name);\n\n // beside adding viewport to the registry of this instance\n // AppRouter also configure routing/history to start routing functionality\n // There are situation where there are more than 1 element at root view\n // in that case, still only activate once via the following guard\n if (!this.isActive) {\n const viewModel = this._findViewModel($viewPort);\n if ('configureRouter' in viewModel) {\n // If there are more than one element at root view\n // use this flag to guard against configure method being invoked multiple times\n // this flag is set inside method configure\n if (!this.isConfigured) {\n // replace the real resolve with a noop to guarantee that any action in base class Router\n // won't resolve the configurePromise prematurely\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\n this._resolveConfiguredPromise = () => {/**/};\n return this\n .configure(config =>\n Promise\n .resolve(viewModel.configureRouter(config, this))\n // an issue with configure interface. Should be fixed there\n // todo: fix this via configure interface in router\n .then(() => config) as any\n )\n .then(() => {\n this.activate();\n resolveConfiguredPromise();\n });\n }\n } else {\n this.activate();\n }\n }\n // when a viewport is added dynamically to a root view that is already activated\n // just process the navigation instruction\n else {\n this._dequeueInstruction();\n }\n\n return Promise.resolve();\n }\n\n /**\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\n *\n * @params options The set of options to activate the router with.\n */\n activate(options?: NavigationOptions): void {\n if (this.isActive) {\n return;\n }\n\n this.isActive = true;\n // route handler property is responsible for handling url change\n // the interface of aurelia-history isn't clear on this perspective\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\n this.history.activate(this.options);\n this._dequeueInstruction();\n }\n\n /**\n * Deactivates the router.\n */\n deactivate(): void {\n this.isActive = false;\n this.history.deactivate();\n }\n\n /**@internal */\n _queueInstruction(instruction: NavigationInstruction): Promise {\n return new Promise((resolve) => {\n instruction.resolve = resolve;\n this._queue.unshift(instruction);\n this._dequeueInstruction();\n });\n }\n\n /**@internal */\n _dequeueInstruction(instructionCount: number = 0): Promise {\n return Promise.resolve().then(() => {\n if (this.isNavigating && !instructionCount) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n let instruction = this._queue.shift();\n this._queue.length = 0;\n\n if (!instruction) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n this.isNavigating = true;\n\n let navtracker: number = this.history.getState('NavigationTracker');\n let currentNavTracker = this.currentNavigationTracker;\n\n if (!navtracker && !currentNavTracker) {\n this.isNavigatingFirst = true;\n this.isNavigatingNew = true;\n } else if (!navtracker) {\n this.isNavigatingNew = true;\n } else if (!currentNavTracker) {\n this.isNavigatingRefresh = true;\n } else if (currentNavTracker < navtracker) {\n this.isNavigatingForward = true;\n } else if (currentNavTracker > navtracker) {\n this.isNavigatingBack = true;\n } if (!navtracker) {\n navtracker = Date.now();\n this.history.setState('NavigationTracker', navtracker);\n }\n this.currentNavigationTracker = navtracker;\n\n instruction.previousInstruction = this.currentInstruction;\n\n let maxInstructionCount = this.maxInstructionCount;\n\n if (!instructionCount) {\n this.events.publish(RouterEvent.Processing, { instruction });\n } else if (instructionCount === maxInstructionCount - 1) {\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\n restorePreviousLocation(this);\n return this._dequeueInstruction(instructionCount + 1);\n } else if (instructionCount > maxInstructionCount) {\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\n }\n\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\n\n return pipeline\n .run(instruction)\n .then(result => processResult(instruction, result, instructionCount, this))\n .catch(error => {\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\n })\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\n });\n }\n\n /**@internal */\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\n if (this.container.viewModel) {\n return this.container.viewModel;\n }\n\n if (viewPort.container) {\n let container = viewPort.container;\n\n while (container) {\n if (container.viewModel) {\n this.container.viewModel = container.viewModel;\n return container.viewModel;\n }\n\n container = container.parent;\n }\n }\n\n return undefined;\n }\n}\n\nconst processResult = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n instructionCount: number,\n router: AppRouter\n): Promise => {\n if (!(result && 'completed' in result && 'output' in result)) {\n result = result || {} as PipelineResult;\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\n }\n\n let finalResult: PipelineResult = null;\n let navigationCommandResult = null;\n if (isNavigationCommand(result.output)) {\n navigationCommandResult = result.output.navigate(router);\n } else {\n finalResult = result;\n\n if (!result.completed) {\n if (result.output instanceof Error) {\n logger.error(result.output.toString());\n }\n\n restorePreviousLocation(router);\n }\n }\n\n return Promise.resolve(navigationCommandResult)\n .then(_ => router._dequeueInstruction(instructionCount + 1))\n .then(innerResult => finalResult || innerResult || result);\n};\n\nconst resolveInstruction = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n isInnerInstruction: boolean,\n router: AppRouter\n): PipelineResult => {\n instruction.resolve(result);\n\n let eventAggregator = router.events;\n let eventArgs = { instruction, result };\n if (!isInnerInstruction) {\n router.isNavigating = false;\n router.isExplicitNavigation = false;\n router.isExplicitNavigationBack = false;\n router.isNavigatingFirst = false;\n router.isNavigatingNew = false;\n router.isNavigatingRefresh = false;\n router.isNavigatingForward = false;\n router.isNavigatingBack = false;\n router.couldDeactivate = false;\n\n let eventName: string;\n\n if (result.output instanceof Error) {\n eventName = RouterEvent.Error;\n } else if (!result.completed) {\n eventName = RouterEvent.Canceled;\n } else {\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\n router.history.previousLocation = instruction.fragment + queryString;\n eventName = RouterEvent.Success;\n }\n\n eventAggregator.publish(eventName, eventArgs);\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\n } else {\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\n }\n\n return result;\n};\n\nconst restorePreviousLocation = (router: AppRouter): void => {\n let previousLocation = router.history.previousLocation;\n if (previousLocation) {\n router.navigate(previousLocation, { trigger: false, replace: true });\n } else if (router.fallbackRoute) {\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\n } else {\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\n }\n};\n","/**\n* The status of a Pipeline.\n*/\nexport const enum PipelineStatus {\n Completed = 'completed',\n Canceled = 'canceled',\n Rejected = 'rejected',\n Running = 'running'\n}\n","/**\n * A list of known router events used by the Aurelia router\n * to signal the pipeline has come to a certain state\n */\n// const enum is preserved in tsconfig\nexport const enum RouterEvent {\n Processing = 'router:navigation:processing',\n Error = 'router:navigation:error',\n Canceled = 'router:navigation:canceled',\n Complete = 'router:navigation:complete',\n Success = 'router:navigation:success',\n ChildComplete = 'router:navigation:child:complete'\n}\n","/**\n * Available pipeline slot names to insert interceptor into router pipeline\n */\n// const enum is preserved in tsconfig\nexport const enum PipelineSlotName {\n /**\n * Authorization slot. Invoked early in the pipeline,\n * before `canActivate` hook of incoming route\n */\n Authorize = 'authorize',\n /**\n * Pre-activation slot. Invoked early in the pipeline,\n * Invoked timing:\n * - after Authorization slot\n * - after canActivate hook on new view model\n * - before deactivate hook on old view model\n * - before activate hook on new view model\n */\n PreActivate = 'preActivate',\n /**\n * Pre-render slot. Invoked later in the pipeline\n * Invokcation timing:\n * - after activate hook on new view model\n * - before commit step on new navigation instruction\n */\n PreRender = 'preRender',\n /**\n * Post-render slot. Invoked last in the pipeline\n */\n PostRender = 'postRender'\n}\n"],"names":["RouteRecognizer","Container","LogManager.getLogger","tslib_1.__extends","History","EventAggregator","PipelineStatus","RouterEvent","PipelineSlotName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA;;;AAGA;IA4DE,+BAAY,IAA+B;;;;QAT3C,SAAI,GAAwC,IAAI,CAAC;QAEjD,YAAO,GAAwB,EAAE,CAAC;QAQhC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChC,IAAI,C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AA;CACpB,EALiBC,sBAAc,KAAdA,sBAAc,QAK/B;;ACRD;;;;AAIA,AACA,WAAkB,WAAW;IAC3B,0DAA2C,CAAA;IAC3C,gDAAiC,CAAA;IACjC,sDAAuC,CAAA;IACvC,sDAAuC,CAAA;IACvC,oDAAqC,CAAA;IACrC,iEAAkD,CAAA;CACnD,EAPiBC,mBAAW,KAAXA,mBAAW,QAO5B;;ACZD;;;AAGA,AACA,WAAkB,gBAAgB;;;;;IAKhC,2CAAuB,CAAA;;;;;;;;;IASvB,+CAA2B,CAAA;;;;;;;IAO3B,2CAAuB,CAAA;;;;IAIvB,6CAAyB,CAAA;CAC1B,EA1BiBC,wBAAgB,KAAhBA,wBAAgB,QA0BjC;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\r\nimport { Router } from './router';\r\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\r\n\r\n/**\r\n * Initialization options for a navigation instruction\r\n */\r\nexport interface NavigationInstructionInit {\r\n fragment: string;\r\n queryString?: string;\r\n params?: Record;\r\n queryParams?: Record;\r\n config: RouteConfig;\r\n parentInstruction?: NavigationInstruction;\r\n previousInstruction?: NavigationInstruction;\r\n router: Router;\r\n options?: Object;\r\n plan?: Record;\r\n}\r\n\r\nexport interface ViewPortInstructionInit {\r\n name: string;\r\n strategy: ActivationStrategyType;\r\n moduleId: string;\r\n component: ViewPortComponent;\r\n}\r\n\r\n/**\r\n * Class used to represent an instruction during a navigation.\r\n */\r\nexport class NavigationInstruction {\r\n /**\r\n * The URL fragment.\r\n */\r\n fragment: string;\r\n\r\n /**\r\n * The query string.\r\n */\r\n queryString: string;\r\n\r\n /**\r\n * Parameters extracted from the route pattern.\r\n */\r\n params: any;\r\n\r\n /**\r\n * Parameters extracted from the query string.\r\n */\r\n queryParams: any;\r\n\r\n /**\r\n * The route config for the route matching this instruction.\r\n */\r\n config: RouteConfig;\r\n\r\n /**\r\n * The parent instruction, if this instruction was created by a child router.\r\n */\r\n parentInstruction: NavigationInstruction;\r\n\r\n parentCatchHandler: any;\r\n\r\n /**\r\n * The instruction being replaced by this instruction in the current router.\r\n */\r\n previousInstruction: NavigationInstruction;\r\n\r\n /**\r\n * viewPort instructions to used activation.\r\n */\r\n viewPortInstructions: Record;\r\n\r\n /**\r\n * The router instance.\r\n */\r\n router: Router;\r\n\r\n /**\r\n * Current built viewport plan of this nav instruction\r\n */\r\n plan: Record = null;\r\n\r\n options: Record = {};\r\n\r\n /**@internal */\r\n lifecycleArgs: LifecycleArguments;\r\n /**@internal */\r\n resolve?: (val?: any) => void;\r\n\r\n constructor(init: NavigationInstructionInit) {\r\n Object.assign(this, init);\r\n\r\n this.params = this.params || {};\r\n this.viewPortInstructions = {};\r\n\r\n let ancestorParams = [];\r\n let current: NavigationInstruction = this;\r\n do {\r\n let currentParams = Object.assign({}, current.params);\r\n if (current.config && current.config.hasChildRouter) {\r\n // remove the param for the injected child route segment\r\n delete currentParams[current.getWildCardName()];\r\n }\r\n\r\n ancestorParams.unshift(currentParams);\r\n current = current.parentInstruction;\r\n } while (current);\r\n\r\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\r\n this.lifecycleArgs = [allParams, this.config, this];\r\n }\r\n\r\n /**\r\n * Gets an array containing this instruction and all child instructions for the current navigation.\r\n */\r\n getAllInstructions(): Array {\r\n let instructions: NavigationInstruction[] = [this];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let key in viewPortInstructions) {\r\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\r\n if (childInstruction) {\r\n instructions.push(...childInstruction.getAllInstructions());\r\n }\r\n }\r\n\r\n return instructions;\r\n }\r\n\r\n /**\r\n * Gets an array containing the instruction and all child instructions for the previous navigation.\r\n * Previous instructions are no longer available after navigation completes.\r\n */\r\n getAllPreviousInstructions(): Array {\r\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\r\n }\r\n\r\n /**\r\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\r\n */\r\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(\r\n nameOrInitOptions: string | ViewPortInstructionInit,\r\n strategy?: ActivationStrategyType,\r\n moduleId?: string,\r\n component?: any\r\n ): /*ViewPortInstruction*/ any {\r\n\r\n let viewPortInstruction: ViewPortInstruction;\r\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\r\n const lifecycleArgs = this.lifecycleArgs;\r\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\r\n\r\n if (typeof nameOrInitOptions === 'string') {\r\n viewPortInstruction = {\r\n name: nameOrInitOptions,\r\n strategy: strategy,\r\n moduleId: moduleId,\r\n component: component,\r\n childRouter: component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n } else {\r\n viewPortInstruction = {\r\n name: viewPortName,\r\n strategy: nameOrInitOptions.strategy,\r\n component: nameOrInitOptions.component,\r\n moduleId: nameOrInitOptions.moduleId,\r\n childRouter: nameOrInitOptions.component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n }\r\n\r\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\r\n }\r\n\r\n /**\r\n * Gets the name of the route pattern's wildcard parameter, if applicable.\r\n */\r\n getWildCardName(): string {\r\n // todo: potential issue, or at least unsafe typings\r\n let configRoute = this.config.route as string;\r\n let wildcardIndex = configRoute.lastIndexOf('*');\r\n return configRoute.substr(wildcardIndex + 1);\r\n }\r\n\r\n /**\r\n * Gets the path and query string created by filling the route\r\n * pattern's wildcard parameter with the matching param.\r\n */\r\n getWildcardPath(): string {\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n let queryString = this.queryString;\r\n\r\n if (queryString) {\r\n path += '?' + queryString;\r\n }\r\n\r\n return path;\r\n }\r\n\r\n /**\r\n * Gets the instruction's base URL, accounting for wildcard route parameters.\r\n */\r\n getBaseUrl(): string {\r\n let $encodeURI = encodeURI;\r\n let fragment = decodeURI(this.fragment);\r\n\r\n if (fragment === '') {\r\n let nonEmptyRoute = this.router.routes.find(route => {\r\n return route.name === this.config.name &&\r\n route.route !== '';\r\n });\r\n if (nonEmptyRoute) {\r\n fragment = nonEmptyRoute.route as any;\r\n }\r\n }\r\n\r\n if (!this.params) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n\r\n if (!path) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\r\n }\r\n\r\n /**\r\n * Finalize a viewport instruction\r\n * @internal\r\n */\r\n _commitChanges(waitToSwap: boolean): Promise {\r\n let router = this.router;\r\n router.currentInstruction = this;\r\n\r\n const previousInstruction = this.previousInstruction;\r\n if (previousInstruction) {\r\n previousInstruction.config.navModel.isActive = false;\r\n }\r\n\r\n this.config.navModel.isActive = true;\r\n\r\n router.refreshNavigation();\r\n\r\n let loads: Promise[] = [];\r\n let delaySwaps: ISwapPlan[] = [];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let viewPort = router.viewPorts[viewPortName];\r\n\r\n if (!viewPort) {\r\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\r\n }\r\n\r\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\r\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\r\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n } else {\r\n if (waitToSwap) {\r\n delaySwaps.push({ viewPort, viewPortInstruction });\r\n }\r\n loads.push(\r\n viewPort\r\n .process(viewPortInstruction, waitToSwap)\r\n .then(() => childNavInstruction\r\n ? childNavInstruction._commitChanges(waitToSwap)\r\n : Promise.resolve()\r\n )\r\n );\r\n }\r\n } else {\r\n if (childNavInstruction) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n }\r\n }\r\n }\r\n\r\n return Promise\r\n .all(loads)\r\n .then(() => {\r\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\r\n return null;\r\n })\r\n .then(() => prune(this));\r\n }\r\n\r\n /**@internal */\r\n _updateTitle(): void {\r\n let router = this.router;\r\n let title = this._buildTitle(router.titleSeparator);\r\n if (title) {\r\n router.history.setTitle(title);\r\n }\r\n }\r\n\r\n /**@internal */\r\n _buildTitle(separator: string = ' | '): string {\r\n let title = '';\r\n let childTitles = [];\r\n let navModelTitle = this.config.navModel.title;\r\n let instructionRouter = this.router;\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n if (navModelTitle) {\r\n title = instructionRouter.transformTitle(navModelTitle);\r\n }\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\r\n\r\n if (child_nav_instruction) {\r\n let childTitle = child_nav_instruction._buildTitle(separator);\r\n if (childTitle) {\r\n childTitles.push(childTitle);\r\n }\r\n }\r\n }\r\n\r\n if (childTitles.length) {\r\n title = childTitles.join(separator) + (title ? separator : '') + title;\r\n }\r\n\r\n if (instructionRouter.title) {\r\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\r\n }\r\n\r\n return title;\r\n }\r\n}\r\n\r\nconst prune = (instruction: NavigationInstruction): void => {\r\n instruction.previousInstruction = null;\r\n instruction.plan = null;\r\n};\r\n\r\ninterface ISwapPlan {\r\n viewPort: ViewPort;\r\n viewPortInstruction: ViewPortInstruction;\r\n}\r\n","import { Router } from './router';\r\nimport { RouteConfig } from './interfaces';\r\n\r\n/**\r\n* Class for storing and interacting with a route's navigation settings.\r\n*/\r\nexport class NavModel {\r\n\r\n /**\r\n * True if this nav item is currently active.\r\n */\r\n isActive: boolean = false;\r\n\r\n /**\r\n * The title.\r\n */\r\n title: string = null;\r\n\r\n /**\r\n * This nav item's absolute href.\r\n */\r\n href: string = null;\r\n\r\n /**\r\n * This nav item's relative href.\r\n */\r\n relativeHref: string = null;\r\n\r\n /**\r\n * Data attached to the route at configuration time.\r\n */\r\n settings: any = {};\r\n\r\n /**\r\n * The route config.\r\n */\r\n config: RouteConfig = null;\r\n\r\n /**\r\n * The router associated with this navigation model.\r\n */\r\n router: Router;\r\n\r\n order: number | boolean;\r\n\r\n constructor(router: Router, relativeHref: string) {\r\n this.router = router;\r\n this.relativeHref = relativeHref;\r\n }\r\n\r\n /**\r\n * Sets the route's title and updates document.title.\r\n * If the a navigation is in progress, the change will be applied\r\n * to document.title when the navigation completes.\r\n *\r\n * @param title The new title.\r\n */\r\n setTitle(title: string): void {\r\n this.title = title;\r\n\r\n if (this.isActive) {\r\n this.router.updateTitle();\r\n }\r\n }\r\n}\r\n","import { RouteConfig } from './interfaces';\r\n\r\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\r\n if (!hasPushState && path[0] !== '#') {\r\n path = '#' + path;\r\n }\r\n\r\n if (hasPushState && absolute) {\r\n path = path.substring(1, path.length);\r\n }\r\n\r\n return path;\r\n}\r\n\r\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\r\n if (isAbsoluteUrl.test(fragment)) {\r\n return fragment;\r\n }\r\n\r\n let path = '';\r\n\r\n if (baseUrl.length && baseUrl[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n path += baseUrl;\r\n\r\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\r\n path = path.substring(0, path.length - 1);\r\n }\r\n\r\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\r\n}\r\n\r\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\r\n if (isRootedPath.test(fragment)) {\r\n return _normalizeAbsolutePath(fragment, hasPushState);\r\n }\r\n\r\n return _createRootedPath(fragment, baseUrl, hasPushState);\r\n}\r\n\r\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\r\n let routeConfigs = [];\r\n\r\n if (Array.isArray(config.route)) {\r\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\r\n let current = Object.assign({}, config);\r\n current.route = config.route[i];\r\n routeConfigs.push(current);\r\n }\r\n } else {\r\n routeConfigs.push(Object.assign({}, config));\r\n }\r\n\r\n return routeConfigs;\r\n}\r\n\r\nconst isRootedPath = /^#?\\//;\r\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\r\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\r\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\r\nimport { Router } from './router';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * Class used to configure a [[Router]] instance.\r\n *\r\n * @constructor\r\n */\r\nexport class RouterConfiguration {\r\n instructions: Array<(router: Router) => void> = [];\r\n options: {\r\n [key: string]: any;\r\n compareQueryParams?: boolean;\r\n root?: string;\r\n pushState?: boolean;\r\n hashChange?: boolean;\r\n silent?: boolean;\r\n } = {};\r\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\r\n title: string;\r\n titleSeparator: string;\r\n unknownRouteConfig: RouteConfigSpecifier;\r\n viewPortDefaults: Record;\r\n\r\n /**@internal */\r\n _fallbackRoute: string;\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\r\n *\r\n * @param name The name of the pipeline slot to insert the step into.\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\r\n if (step === null || step === undefined) {\r\n throw new Error('Pipeline step cannot be null or undefined.');\r\n }\r\n this.pipelineSteps.push({ name, step });\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\r\n }\r\n\r\n /**\r\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\r\n *\r\n * @param fragment The URL fragment to use as the navigation destination.\r\n * @chainable\r\n */\r\n fallbackRoute(fragment: string): RouterConfiguration {\r\n this._fallbackRoute = fragment;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps one or more routes to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\r\n if (Array.isArray(route)) {\r\n route.forEach(r => this.map(r));\r\n return this;\r\n }\r\n\r\n return this.mapRoute(route);\r\n }\r\n\r\n /**\r\n * Configures defaults to use for any view ports.\r\n *\r\n * @param viewPortConfig a view port configuration object to use as a\r\n * default, of the form { viewPortName: { moduleId } }.\r\n * @chainable\r\n */\r\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\r\n this.viewPortDefaults = viewPortConfig;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps a single route to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n mapRoute(config: RouteConfig): RouterConfiguration {\r\n this.instructions.push(router => {\r\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\r\n\r\n let navModel;\r\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\r\n let routeConfig = routeConfigs[i];\r\n routeConfig.settings = routeConfig.settings || {};\r\n if (!navModel) {\r\n navModel = router.createNavModel(routeConfig);\r\n }\r\n\r\n router.addRoute(routeConfig, navModel);\r\n }\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\r\n *\r\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\r\n * [[NavigationInstruction]] and selects a moduleId to load.\r\n * @chainable\r\n */\r\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\r\n this.unknownRouteConfig = config;\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current configuration to the specified [[Router]].\r\n *\r\n * @param router The [[Router]] to apply the configuration to.\r\n */\r\n exportToRouter(router: Router): void {\r\n let instructions = this.instructions;\r\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\r\n instructions[i](router);\r\n }\r\n\r\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\r\n\r\n if (title) {\r\n router.title = title;\r\n }\r\n\r\n if (titleSeparator) {\r\n router.titleSeparator = titleSeparator;\r\n }\r\n\r\n if (unknownRouteConfig) {\r\n router.handleUnknownRoutes(unknownRouteConfig);\r\n }\r\n\r\n if (_fallbackRoute) {\r\n router.fallbackRoute = _fallbackRoute;\r\n }\r\n\r\n if (viewPortDefaults) {\r\n router.useViewPortDefaults(viewPortDefaults);\r\n }\r\n\r\n Object.assign(router.options, this.options);\r\n\r\n let pipelineSteps = this.pipelineSteps;\r\n let pipelineStepCount = pipelineSteps.length;\r\n if (pipelineStepCount) {\r\n if (!router.isRoot) {\r\n throw new Error('Pipeline steps can only be added to the root router');\r\n }\r\n\r\n let pipelineProvider = router.pipelineProvider;\r\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\r\n let { name, step } = pipelineSteps[i];\r\n pipelineProvider.addStep(name, step);\r\n }\r\n }\r\n }\r\n}\r\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { NavigationResult, RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): NavigationResult {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): NavigationResult {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\r\n\r\n/**@internal exported for unit testing */\r\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\r\n let index = -1;\r\n const next: Next = function() {\r\n index++;\r\n\r\n if (index < steps.length) {\r\n let currentStep = steps[index];\r\n\r\n try {\r\n return currentStep(instruction, next);\r\n } catch (e) {\r\n return next.reject(e);\r\n }\r\n } else {\r\n return next.complete();\r\n }\r\n } as Next;\r\n\r\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\r\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\r\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\r\n\r\n return next;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\r\n return (output: any) => Promise\r\n .resolve({\r\n status,\r\n output,\r\n completed: status === PipelineStatus.Completed\r\n });\r\n};\r\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { createNextFn } from './next';\r\n\r\n/**\r\n * The class responsible for managing and processing the navigation pipeline.\r\n */\r\nexport class Pipeline {\r\n /**\r\n * The pipeline steps. And steps added via addStep will be converted to a function\r\n * The actualy running functions with correct step contexts of this pipeline\r\n */\r\n steps: StepRunnerFunction[] = [];\r\n\r\n /**\r\n * Adds a step to the pipeline.\r\n *\r\n * @param step The pipeline step.\r\n */\r\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\r\n let run;\r\n\r\n if (typeof step === 'function') {\r\n run = step;\r\n } else if (typeof step.getSteps === 'function') {\r\n // getSteps is to enable support open slots\r\n // where devs can add multiple steps into the same slot name\r\n let steps = step.getSteps();\r\n for (let i = 0, l = steps.length; i < l; i++) {\r\n this.addStep(steps[i]);\r\n }\r\n\r\n return this;\r\n } else {\r\n run = (step as PipelineStep).run.bind(step);\r\n }\r\n\r\n this.steps.push(run);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Runs the pipeline.\r\n *\r\n * @param instruction The navigation instruction to process.\r\n */\r\n run(instruction: NavigationInstruction): Promise {\r\n const nextFn = createNextFn(instruction, this.steps);\r\n return nextFn();\r\n }\r\n}\r\n","import { NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-history' {\r\n interface NavigationOptions {\r\n useAppRouter?: boolean;\r\n }\r\n}\r\n\r\n/**\r\n* When a navigation command is encountered, the current navigation\r\n* will be cancelled and control will be passed to the navigation\r\n* command so it can determine the correct action.\r\n*/\r\nexport interface NavigationCommand {\r\n navigate: (router: Router) => void;\r\n /**@internal */\r\n shouldContinueProcessing?: boolean;\r\n /**@internal */\r\n setRouter?: (router: Router) => void;\r\n}\r\n\r\n/**\r\n* Determines if the provided object is a navigation command.\r\n* A navigation command is anything with a navigate method.\r\n*\r\n* @param obj The object to check.\r\n*/\r\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\r\n return obj && typeof obj.navigate === 'function';\r\n}\r\n\r\n/**\r\n* Used during the activation lifecycle to cause a redirect.\r\n*/\r\nexport class Redirect implements NavigationCommand {\r\n\r\n url: string;\r\n /**@internal */\r\n options: NavigationOptions;\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n private router: Router;\r\n\r\n /**\r\n * @param url The URL fragment to use as the navigation destination.\r\n * @param options The navigation options.\r\n */\r\n constructor(url: string, options: NavigationOptions = {}) {\r\n this.url = url;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigate(this.url, this.options);\r\n }\r\n}\r\n\r\n/**\r\n * Used during the activation lifecycle to cause a redirect to a named route.\r\n */\r\nexport class RedirectToRoute implements NavigationCommand {\r\n\r\n route: string;\r\n params: any;\r\n /**@internal */\r\n options: NavigationOptions;\r\n\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n /**@internal */\r\n router: Router;\r\n\r\n /**\r\n * @param route The name of the route.\r\n * @param params The parameters to be sent to the activation method.\r\n * @param options The options to use for navigation.\r\n */\r\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\r\n this.route = route;\r\n this.params = params;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\r\n }\r\n}\r\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\r\n\r\ntype ViewPortPlansRecord = Record;\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport function _buildNavigationPlan(\r\n instruction: NavigationInstruction,\r\n forceLifecycleMinimum?: boolean\r\n): Promise {\r\n let config = instruction.config;\r\n\r\n if ('redirect' in config) {\r\n return buildRedirectPlan(instruction);\r\n }\r\n\r\n const prevInstruction = instruction.previousInstruction;\r\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\r\n\r\n if (prevInstruction) {\r\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\r\n }\r\n\r\n // first navigation, only need to prepare a few information for each viewport plan\r\n const viewPortPlans: ViewPortPlansRecord = {};\r\n let viewPortConfigs = config.viewPorts;\r\n for (let viewPortName in viewPortConfigs) {\r\n let viewPortConfig = viewPortConfigs[viewPortName];\r\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n viewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n strategy: InternalActivationStrategy.Replace,\r\n config: viewPortConfig\r\n };\r\n }\r\n\r\n return Promise.resolve(viewPortPlans);\r\n}\r\n\r\n/**\r\n * Build redirect plan based on config of a navigation instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\r\n const config = instruction.config;\r\n const router = instruction.router;\r\n return router\r\n ._createNavigationInstruction(config.redirect)\r\n .then(redirectInstruction => {\r\n\r\n const params: Record = {};\r\n const originalInstructionParams = instruction.params;\r\n const redirectInstructionParams = redirectInstruction.params;\r\n\r\n for (let key in redirectInstructionParams) {\r\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\r\n let val = redirectInstructionParams[key];\r\n if (typeof val === 'string' && val[0] === ':') {\r\n val = val.slice(1);\r\n // And if that param is found on the original instruction then use it\r\n if (val in originalInstructionParams) {\r\n params[key] = originalInstructionParams[val];\r\n }\r\n } else {\r\n params[key] = redirectInstructionParams[key];\r\n }\r\n }\r\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\r\n\r\n // Special handling for child routes\r\n for (let key in originalInstructionParams) {\r\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\r\n }\r\n\r\n let queryString = instruction.queryString;\r\n if (queryString) {\r\n redirectLocation += '?' + queryString;\r\n }\r\n\r\n return Promise.resolve(new Redirect(redirectLocation));\r\n });\r\n};\r\n\r\n/**\r\n * @param viewPortPlans the Plan record that holds information about built plans\r\n * @internal exported for unit testing\r\n */\r\nexport const buildTransitionPlans = (\r\n currentInstruction: NavigationInstruction,\r\n previousInstruction: NavigationInstruction,\r\n defaultViewPortConfigs: Record,\r\n forceLifecycleMinimum?: boolean\r\n): Promise => {\r\n\r\n let viewPortPlans: ViewPortPlansRecord = {};\r\n let newInstructionConfig = currentInstruction.config;\r\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\r\n let pending: Promise[] = [];\r\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\r\n\r\n for (let viewPortName in previousViewPortInstructions) {\r\n\r\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\r\n const prevViewPortComponent = prevViewPortInstruction.component;\r\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\r\n\r\n // if this is invoked on a viewport without any changes, based on new url,\r\n // newViewPortConfig will be the existing viewport instruction\r\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\r\n ? newInstructionViewPortConfigs[viewPortName]\r\n : prevViewPortInstruction;\r\n\r\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n\r\n const viewPortActivationStrategy = determineActivationStrategy(\r\n currentInstruction,\r\n prevViewPortInstruction,\r\n nextViewPortConfig,\r\n hasNewParams,\r\n forceLifecycleMinimum\r\n );\r\n const viewPortPlan = viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n // ViewPortInstruction can quack like a RouteConfig\r\n config: nextViewPortConfig as RouteConfig,\r\n prevComponent: prevViewPortComponent,\r\n prevModuleId: prevViewPortInstruction.moduleId,\r\n strategy: viewPortActivationStrategy\r\n } as ViewPortPlan;\r\n\r\n // recursively build nav plans for all existing child routers/viewports of this viewport\r\n // this is possible because existing child viewports and routers already have necessary information\r\n // to process the wildcard path from parent instruction\r\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\r\n const path = currentInstruction.getWildcardPath();\r\n const task: Promise = prevViewPortInstruction\r\n .childRouter\r\n ._createNavigationInstruction(path, currentInstruction)\r\n .then((childInstruction: NavigationInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(\r\n childInstruction,\r\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\r\n // if so, can just use local variable viewPortPlanStrategy\r\n // there could be user code modifying viewport plan during _createNavigationInstruction?\r\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\r\n )\r\n .then(childPlan => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n // for bluebird ?\r\n return null;\r\n });\r\n });\r\n\r\n pending.push(task);\r\n }\r\n }\r\n\r\n return Promise.all(pending).then(() => viewPortPlans);\r\n};\r\n\r\n/**\r\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const determineActivationStrategy = (\r\n currentNavInstruction: NavigationInstruction,\r\n prevViewPortInstruction: ViewPortInstruction,\r\n newViewPortConfig: RouteConfig | ViewPortInstruction,\r\n // indicates whether there is difference between old and new url params\r\n hasNewParams: boolean,\r\n forceLifecycleMinimum?: boolean\r\n): ActivationStrategyType => {\r\n\r\n let newInstructionConfig = currentNavInstruction.config;\r\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\r\n let viewPortPlanStrategy: ActivationStrategyType;\r\n\r\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\r\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\r\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\r\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\r\n } else if (newInstructionConfig.activationStrategy) {\r\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\r\n } else if (hasNewParams || forceLifecycleMinimum) {\r\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\r\n } else {\r\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\r\n }\r\n return viewPortPlanStrategy;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\r\n let prevParams = prev.params;\r\n let nextParams = next.params;\r\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\r\n\r\n for (let key in nextParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!next.options.compareQueryParams) {\r\n return false;\r\n }\r\n\r\n let prevQueryParams = prev.queryParams;\r\n let nextQueryParams = next.queryParams;\r\n for (let key in nextQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n};\r\n","import { Next } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\n\r\n/**\r\n * Transform a navigation instruction into viewport plan record object,\r\n * or a redirect request if user viewmodel demands\r\n */\r\nexport class BuildNavigationPlanStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return _buildNavigationPlan(navigationInstruction)\r\n .then(plan => {\r\n if (plan instanceof Redirect) {\r\n return next.cancel(plan);\r\n }\r\n navigationInstruction.plan = plan;\r\n return next();\r\n })\r\n .catch(next.cancel);\r\n }\r\n}\r\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\nimport { InternalActivationStrategy } from './activation-strategy';\r\nimport { RouteLoader } from './route-loader';\r\n\r\n/**\r\n * Loading plan calculated based on a navigration-instruction and a viewport plan\r\n */\r\ninterface ILoadingPlan {\r\n viewPortPlan: ViewPortPlan;\r\n navigationInstruction: NavigationInstruction;\r\n}\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadNewRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction\r\n): Promise => {\r\n let loadingPlans = determineLoadingPlans(navigationInstruction);\r\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\r\n routeLoader,\r\n loadingPlan.navigationInstruction,\r\n loadingPlan.viewPortPlan\r\n ));\r\n\r\n return Promise.all(loadPromises);\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const determineLoadingPlans = (\r\n navigationInstruction: NavigationInstruction,\r\n loadingPlans: ILoadingPlan[] = []\r\n): ILoadingPlan[] => {\r\n let viewPortPlans: Record = navigationInstruction.plan;\r\n\r\n for (let viewPortName in viewPortPlans) {\r\n let viewPortPlan = viewPortPlans[viewPortName];\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\r\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\r\n\r\n if (childNavInstruction) {\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n } else {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortName,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: viewPortPlan.prevModuleId,\r\n component: viewPortPlan.prevComponent\r\n }) as ViewPortInstruction;\r\n\r\n if (childNavInstruction) {\r\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n }\r\n }\r\n\r\n return loadingPlans;\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n viewPortPlan: ViewPortPlan\r\n): Promise => {\r\n let planConfig = viewPortPlan.config;\r\n let moduleId = planConfig ? planConfig.moduleId : null;\r\n\r\n return loadComponent(routeLoader, navigationInstruction, planConfig)\r\n .then((component) => {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortPlan.name,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: moduleId,\r\n component: component\r\n }) as ViewPortInstruction;\r\n\r\n let childRouter = component.childRouter;\r\n if (childRouter) {\r\n let path = navigationInstruction.getWildcardPath();\r\n\r\n return childRouter\r\n ._createNavigationInstruction(path, navigationInstruction)\r\n .then((childInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(childInstruction)\r\n .then((childPlan) => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n viewPortInstruction.childNavigationInstruction = childInstruction;\r\n\r\n return loadNewRoute(routeLoader, childInstruction);\r\n });\r\n });\r\n }\r\n // ts complains without this, though they are same\r\n return void 0;\r\n });\r\n};\r\n\r\n/**\r\n * Load a routed-component based on navigation instruction and route config\r\n * @internal exported for unit testing only\r\n */\r\nexport const loadComponent = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n config: RouteConfig\r\n): Promise => {\r\n let router = navigationInstruction.router;\r\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\r\n\r\n return Promise.resolve()\r\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\r\n .then(\r\n /**\r\n * @param component an object carrying information about loaded route\r\n * typically contains information about view model, childContainer, view and router\r\n */\r\n (component: ViewPortComponent) => {\r\n let { viewModel, childContainer } = component;\r\n component.router = router;\r\n component.config = config;\r\n\r\n if ('configureRouter' in viewModel) {\r\n let childRouter = childContainer.getChildRouter();\r\n component.childRouter = childRouter;\r\n\r\n return childRouter\r\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\r\n .then(() => component);\r\n }\r\n\r\n return component;\r\n }\r\n );\r\n};\r\n","import { RouteConfig } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Abstract class that is responsible for loading view / view model from a route config\r\n * The default implementation can be found in `aurelia-templating-router`\r\n */\r\nexport class RouteLoader {\r\n /**\r\n * Load a route config based on its viewmodel / view configuration\r\n */\r\n // return typing: return typings used to be never\r\n // as it was a throw. Changing it to Promise should not cause any issues\r\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\r\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\r\n }\r\n}\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { loadNewRoute } from './utilities-route-loading';\r\nimport { RouteLoader } from './route-loader';\r\n/**\r\n * A pipeline step responsible for loading a route config of a navigation instruction\r\n */\r\nexport class LoadRouteStep {\r\n /**@internal */\r\n static inject() { return [RouteLoader]; }\r\n /**\r\n * Route loader isntance that will handle loading route config\r\n * @internal\r\n */\r\n routeLoader: RouteLoader;\r\n constructor(routeLoader: RouteLoader) {\r\n this.routeLoader = routeLoader;\r\n }\r\n /**\r\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\r\n */\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return loadNewRoute(this.routeLoader, navigationInstruction)\r\n .then(next, next.cancel);\r\n }\r\n}\r\n","import { NavigationInstruction } from './navigation-instruction';\r\n\r\n/**\r\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\r\n */\r\nexport class CommitChangesStep {\r\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\r\n return navigationInstruction\r\n ._commitChanges(/*wait to swap?*/ true)\r\n .then(() => {\r\n navigationInstruction._updateTitle();\r\n return next();\r\n });\r\n }\r\n}\r\n","/**\r\n * An optional interface describing the available activation strategies.\r\n * @internal Used internally.\r\n */\r\nexport const enum InternalActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n NoChange = 'no-change',\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n InvokeLifecycle = 'invoke-lifecycle',\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n Replace = 'replace'\r\n}\r\n\r\n/**\r\n * The strategy to use when activating modules during navigation.\r\n */\r\n// kept for compat reason\r\nexport const activationStrategy: ActivationStrategy = {\r\n noChange: InternalActivationStrategy.NoChange,\r\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\r\n replace: InternalActivationStrategy.Replace\r\n};\r\n\r\n/**\r\n * An optional interface describing the available activation strategies.\r\n */\r\nexport interface ActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n noChange: 'no-change';\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n invokeLifecycle: 'invoke-lifecycle';\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n replace: 'replace';\r\n}\r\n\r\n/**\r\n * Enum like type for activation strategy built-in values\r\n */\r\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\r\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { activationStrategy } from './activation-strategy';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Recursively find list of deactivate-able view models\r\n * and invoke the either 'canDeactivate' or 'deactivate' on each\r\n * @internal exported for unit testing\r\n */\r\nexport const processDeactivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canDeactivate' | 'deactivate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let plan: Record = navigationInstruction.plan;\r\n let infos = findDeactivatable(plan, callbackName);\r\n let i = infos.length; // query from inside out\r\n\r\n function inspect(val: any): Promise {\r\n if (ignoreResult || shouldContinue(val)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n if (i--) {\r\n try {\r\n let viewModel = infos[i];\r\n let result = viewModel[callbackName](navigationInstruction);\r\n return processPotential(result, inspect, next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n navigationInstruction.router.couldDeactivate = true;\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\n/**\r\n * Recursively find and returns a list of deactivate-able view models\r\n * @internal exported for unit testing\r\n */\r\nexport const findDeactivatable = (\r\n plan: Record,\r\n callbackName: string,\r\n list: IActivatableInfo[] = []\r\n): any[] => {\r\n for (let viewPortName in plan) {\r\n let viewPortPlan = plan[viewPortName];\r\n let prevComponent = viewPortPlan.prevComponent;\r\n\r\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\r\n && prevComponent\r\n ) {\r\n let viewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in viewModel) {\r\n list.push(viewModel);\r\n }\r\n }\r\n\r\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n } else if (viewPortPlan.childNavigationInstruction) {\r\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\r\n }\r\n }\r\n\r\n return list;\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const addPreviousDeactivatable = (\r\n component: ViewPortComponent,\r\n callbackName: string,\r\n list: IActivatableInfo[]\r\n): void => {\r\n let childRouter = component.childRouter;\r\n\r\n if (childRouter && childRouter.currentInstruction) {\r\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let prevComponent = viewPortInstruction.component;\r\n let prevViewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in prevViewModel) {\r\n list.push(prevViewModel);\r\n }\r\n\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const processActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let infos = findActivatable(navigationInstruction, callbackName);\r\n let length = infos.length;\r\n let i = -1; // query from top down\r\n\r\n function inspect(val: any, router: Router): Promise {\r\n if (ignoreResult || shouldContinue(val, router)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n i++;\r\n\r\n if (i < length) {\r\n try {\r\n let current = infos[i];\r\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\r\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\ninterface IActivatableInfo {\r\n viewModel: any;\r\n lifecycleArgs: LifecycleArguments;\r\n router: Router;\r\n}\r\n\r\n/**\r\n * Find list of activatable view model and add to list (3rd parameter)\r\n * @internal exported for unit testing\r\n */\r\nexport const findActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n list: IActivatableInfo[] = [],\r\n router?: Router\r\n): IActivatableInfo[] => {\r\n let plan: Record = navigationInstruction.plan;\r\n\r\n Object\r\n .keys(plan)\r\n .forEach((viewPortName) => {\r\n let viewPortPlan = plan[viewPortName];\r\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\r\n let viewPortComponent = viewPortInstruction.component;\r\n let viewModel = viewPortComponent.viewModel;\r\n\r\n if (\r\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\r\n || viewPortPlan.strategy === activationStrategy.replace\r\n )\r\n && callbackName in viewModel\r\n ) {\r\n list.push({\r\n viewModel,\r\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\r\n router\r\n });\r\n }\r\n\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (childNavInstruction) {\r\n findActivatable(\r\n childNavInstruction,\r\n callbackName,\r\n list,\r\n viewPortComponent.childRouter || router\r\n );\r\n }\r\n });\r\n\r\n return list;\r\n};\r\n\r\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\r\n if (output instanceof Error) {\r\n return false;\r\n }\r\n\r\n if (isNavigationCommand(output)) {\r\n if (typeof output.setRouter === 'function') {\r\n output.setRouter(router);\r\n }\r\n\r\n return !!output.shouldContinueProcessing;\r\n }\r\n\r\n if (output === undefined) {\r\n return true;\r\n }\r\n\r\n return output;\r\n};\r\n\r\n/**\r\n * A basic interface for an Observable type\r\n */\r\nexport interface IObservable {\r\n subscribe(sub?: IObservableConfig): ISubscription;\r\n}\r\n\r\nexport interface IObservableConfig {\r\n next(): void;\r\n error(err?: any): void;\r\n complete(): void;\r\n}\r\n\r\n/**\r\n * A basic interface for a Subscription to an Observable\r\n */\r\ninterface ISubscription {\r\n unsubscribe(): void;\r\n}\r\n\r\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\r\n\r\n/**\r\n * wraps a subscription, allowing unsubscribe calls even if\r\n * the first value comes synchronously\r\n */\r\nclass SafeSubscription {\r\n\r\n private _subscribed: boolean;\r\n private _subscription: ISubscription;\r\n\r\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\r\n this._subscribed = true;\r\n this._subscription = subscriptionFunc(this);\r\n\r\n if (!this._subscribed) {\r\n this.unsubscribe();\r\n }\r\n }\r\n\r\n get subscribed(): boolean {\r\n return this._subscribed;\r\n }\r\n\r\n unsubscribe(): void {\r\n if (this._subscribed && this._subscription) {\r\n this._subscription.unsubscribe();\r\n }\r\n\r\n this._subscribed = false;\r\n }\r\n}\r\n\r\n/**\r\n * A function to process return value from `activate`/`canActivate` steps\r\n * Supports observable/promise\r\n *\r\n * For observable, resolve at first next() or on complete()\r\n */\r\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\r\n // if promise like\r\n if (obj && typeof obj.then === 'function') {\r\n return Promise.resolve(obj).then(resolve).catch(reject);\r\n }\r\n\r\n // if observable\r\n if (obj && typeof obj.subscribe === 'function') {\r\n let obs: IObservable = obj;\r\n return new SafeSubscription(sub => obs.subscribe({\r\n next() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n },\r\n error(error) {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n reject(error);\r\n }\r\n },\r\n complete() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n }\r\n }));\r\n }\r\n\r\n // else just resolve\r\n try {\r\n return resolve(obj);\r\n } catch (error) {\r\n return reject(error);\r\n }\r\n};\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { processDeactivatable, processActivatable } from './utilities-activation';\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\r\n */\r\nexport class CanDeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\r\n */\r\nexport class CanActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'canActivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\r\n */\r\nexport class DeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\r\n */\r\nexport class ActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'activate', next, true);\r\n }\r\n}\r\n","import { Container } from 'aurelia-dependency-injection';\r\nimport { Pipeline } from './pipeline';\r\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\r\nimport { LoadRouteStep } from './step-load-route';\r\nimport { CommitChangesStep } from './step-commit-changes';\r\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\r\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\r\n */\r\nclass PipelineSlot implements IPipelineSlot {\r\n\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n slotName: string;\r\n /**@internal */\r\n slotAlias?: string;\r\n\r\n steps: (Function | PipelineStep)[] = [];\r\n\r\n constructor(container: Container, name: string, alias?: string) {\r\n this.container = container;\r\n this.slotName = name;\r\n this.slotAlias = alias;\r\n }\r\n\r\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\r\n return this.steps.map(x => this.container.get(x));\r\n }\r\n}\r\n\r\n/**\r\n * Class responsible for creating the navigation pipeline.\r\n */\r\nexport class PipelineProvider {\r\n\r\n /**@internal */\r\n static inject() { return [Container]; }\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n steps: (Function | PipelineSlot)[];\r\n\r\n constructor(container: Container) {\r\n this.container = container;\r\n this.steps = [\r\n BuildNavigationPlanStep,\r\n CanDeactivatePreviousStep, // optional\r\n LoadRouteStep,\r\n createPipelineSlot(container, PipelineSlotName.Authorize),\r\n CanActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\r\n // NOTE: app state changes start below - point of no return\r\n DeactivatePreviousStep, // optional\r\n ActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\r\n CommitChangesStep,\r\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\r\n ];\r\n }\r\n\r\n /**\r\n * Create the navigation pipeline.\r\n */\r\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\r\n let pipeline = new Pipeline();\r\n this.steps.forEach(step => {\r\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\r\n pipeline.addStep(this.container.get(step));\r\n }\r\n });\r\n return pipeline;\r\n }\r\n\r\n /**@internal */\r\n _findStep(name: string): PipelineSlot {\r\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\r\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\r\n }\r\n\r\n /**\r\n * Adds a step into the pipeline at a known slot location.\r\n */\r\n addStep(name: string, step: PipelineStep | Function): void {\r\n let found = this._findStep(name);\r\n if (found) {\r\n let slotSteps = found.steps;\r\n // prevent duplicates\r\n if (!slotSteps.includes(step)) {\r\n slotSteps.push(step);\r\n }\r\n } else {\r\n throw new Error(`Invalid pipeline slot name: ${name}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Removes a step from a slot in the pipeline\r\n */\r\n removeStep(name: string, step: PipelineStep): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n let slotSteps = slot.steps;\r\n slotSteps.splice(slotSteps.indexOf(step), 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clears all steps from a slot in the pipeline\r\n * @internal\r\n */\r\n _clearSteps(name: string = ''): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n slot.steps = [];\r\n }\r\n }\r\n\r\n /**\r\n * Resets all pipeline slots\r\n */\r\n reset(): void {\r\n this._clearSteps(PipelineSlotName.Authorize);\r\n this._clearSteps(PipelineSlotName.PreActivate);\r\n this._clearSteps(PipelineSlotName.PreRender);\r\n this._clearSteps(PipelineSlotName.PostRender);\r\n }\r\n}\r\n\r\n/**@internal */\r\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\r\n return new PipelineSlot(container, name, alias);\r\n};\r\n","import * as LogManager from 'aurelia-logging';\r\nimport { Container } from 'aurelia-dependency-injection';\r\nimport { History, NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\nimport { PipelineProvider } from './pipeline-provider';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\r\nimport { RouterEvent } from './router-event';\r\nimport { RouterConfiguration } from './router-configuration';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-dependency-injection' {\r\n interface Container {\r\n viewModel?: any;\r\n }\r\n}\r\n\r\nconst logger = LogManager.getLogger('app-router');\r\n\r\n/**\r\n * The main application router.\r\n */\r\nexport class AppRouter extends Router {\r\n\r\n /**@internal */\r\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\r\n\r\n events: EventAggregator;\r\n /**@internal */\r\n maxInstructionCount: number;\r\n /**@internal */\r\n _queue: NavigationInstruction[];\r\n /**@internal */\r\n isActive: boolean;\r\n\r\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\r\n super(container, history); // Note the super will call reset internally.\r\n this.pipelineProvider = pipelineProvider;\r\n this.events = events;\r\n }\r\n\r\n /**\r\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\r\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\r\n */\r\n reset(): void {\r\n super.reset();\r\n this.maxInstructionCount = 10;\r\n if (!this._queue) {\r\n this._queue = [];\r\n } else {\r\n this._queue.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Loads the specified URL.\r\n *\r\n * @param url The URL fragment to load.\r\n */\r\n loadUrl(url: string): Promise {\r\n return this\r\n ._createNavigationInstruction(url)\r\n .then(instruction => this._queueInstruction(instruction))\r\n .catch(error => {\r\n logger.error(error);\r\n restorePreviousLocation(this);\r\n });\r\n }\r\n\r\n /**\r\n * Registers a viewPort to be used as a rendering target for activated routes.\r\n *\r\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\r\n * @param name The name of the viewPort. 'default' if unspecified.\r\n */\r\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\r\n // having strong typing without changing public API\r\n const $viewPort: ViewPort = viewPort;\r\n super.registerViewPort($viewPort, name);\r\n\r\n // beside adding viewport to the registry of this instance\r\n // AppRouter also configure routing/history to start routing functionality\r\n // There are situation where there are more than 1 element at root view\r\n // in that case, still only activate once via the following guard\r\n if (!this.isActive) {\r\n const viewModel = this._findViewModel($viewPort);\r\n if ('configureRouter' in viewModel) {\r\n // If there are more than one element at root view\r\n // use this flag to guard against configure method being invoked multiple times\r\n // this flag is set inside method configure\r\n if (!this.isConfigured) {\r\n // replace the real resolve with a noop to guarantee that any action in base class Router\r\n // won't resolve the configurePromise prematurely\r\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\r\n this._resolveConfiguredPromise = () => {/**/};\r\n return this\r\n .configure(config =>\r\n Promise\r\n .resolve(viewModel.configureRouter(config, this))\r\n // an issue with configure interface. Should be fixed there\r\n // todo: fix this via configure interface in router\r\n .then(() => config) as any\r\n )\r\n .then(() => {\r\n this.activate();\r\n resolveConfiguredPromise();\r\n });\r\n }\r\n } else {\r\n this.activate();\r\n }\r\n }\r\n // when a viewport is added dynamically to a root view that is already activated\r\n // just process the navigation instruction\r\n else {\r\n this._dequeueInstruction();\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\r\n *\r\n * @params options The set of options to activate the router with.\r\n */\r\n activate(options?: NavigationOptions): void {\r\n if (this.isActive) {\r\n return;\r\n }\r\n\r\n this.isActive = true;\r\n // route handler property is responsible for handling url change\r\n // the interface of aurelia-history isn't clear on this perspective\r\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\r\n this.history.activate(this.options);\r\n this._dequeueInstruction();\r\n }\r\n\r\n /**\r\n * Deactivates the router.\r\n */\r\n deactivate(): void {\r\n this.isActive = false;\r\n this.history.deactivate();\r\n }\r\n\r\n /**@internal */\r\n _queueInstruction(instruction: NavigationInstruction): Promise {\r\n return new Promise((resolve) => {\r\n instruction.resolve = resolve;\r\n this._queue.unshift(instruction);\r\n this._dequeueInstruction();\r\n });\r\n }\r\n\r\n /**@internal */\r\n _dequeueInstruction(instructionCount: number = 0): Promise {\r\n return Promise.resolve().then(() => {\r\n if (this.isNavigating && !instructionCount) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n let instruction = this._queue.shift();\r\n this._queue.length = 0;\r\n\r\n if (!instruction) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n this.isNavigating = true;\r\n\r\n let navtracker: number = this.history.getState('NavigationTracker');\r\n let currentNavTracker = this.currentNavigationTracker;\r\n\r\n if (!navtracker && !currentNavTracker) {\r\n this.isNavigatingFirst = true;\r\n this.isNavigatingNew = true;\r\n } else if (!navtracker) {\r\n this.isNavigatingNew = true;\r\n } else if (!currentNavTracker) {\r\n this.isNavigatingRefresh = true;\r\n } else if (currentNavTracker < navtracker) {\r\n this.isNavigatingForward = true;\r\n } else if (currentNavTracker > navtracker) {\r\n this.isNavigatingBack = true;\r\n } if (!navtracker) {\r\n navtracker = Date.now();\r\n this.history.setState('NavigationTracker', navtracker);\r\n }\r\n this.currentNavigationTracker = navtracker;\r\n\r\n instruction.previousInstruction = this.currentInstruction;\r\n\r\n let maxInstructionCount = this.maxInstructionCount;\r\n\r\n if (!instructionCount) {\r\n this.events.publish(RouterEvent.Processing, { instruction });\r\n } else if (instructionCount === maxInstructionCount - 1) {\r\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\r\n restorePreviousLocation(this);\r\n return this._dequeueInstruction(instructionCount + 1);\r\n } else if (instructionCount > maxInstructionCount) {\r\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\r\n }\r\n\r\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\r\n\r\n return pipeline\r\n .run(instruction)\r\n .then(result => processResult(instruction, result, instructionCount, this))\r\n .catch(error => {\r\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\r\n })\r\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\r\n });\r\n }\r\n\r\n /**@internal */\r\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\r\n if (this.container.viewModel) {\r\n return this.container.viewModel;\r\n }\r\n\r\n if (viewPort.container) {\r\n let container = viewPort.container;\r\n\r\n while (container) {\r\n if (container.viewModel) {\r\n this.container.viewModel = container.viewModel;\r\n return container.viewModel;\r\n }\r\n\r\n container = container.parent;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n\r\nconst processResult = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n instructionCount: number,\r\n router: AppRouter\r\n): Promise => {\r\n if (!(result && 'completed' in result && 'output' in result)) {\r\n result = result || {} as PipelineResult;\r\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\r\n }\r\n\r\n let finalResult: PipelineResult = null;\r\n let navigationCommandResult = null;\r\n if (isNavigationCommand(result.output)) {\r\n navigationCommandResult = result.output.navigate(router);\r\n } else {\r\n finalResult = result;\r\n\r\n if (!result.completed) {\r\n if (result.output instanceof Error) {\r\n logger.error(result.output.toString());\r\n }\r\n\r\n restorePreviousLocation(router);\r\n }\r\n }\r\n\r\n return Promise.resolve(navigationCommandResult)\r\n .then(_ => router._dequeueInstruction(instructionCount + 1))\r\n .then(innerResult => finalResult || innerResult || result);\r\n};\r\n\r\nconst resolveInstruction = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n isInnerInstruction: boolean,\r\n router: AppRouter\r\n): PipelineResult => {\r\n instruction.resolve(result);\r\n\r\n let eventAggregator = router.events;\r\n let eventArgs = { instruction, result };\r\n if (!isInnerInstruction) {\r\n router.isNavigating = false;\r\n router.isExplicitNavigation = false;\r\n router.isExplicitNavigationBack = false;\r\n router.isNavigatingFirst = false;\r\n router.isNavigatingNew = false;\r\n router.isNavigatingRefresh = false;\r\n router.isNavigatingForward = false;\r\n router.isNavigatingBack = false;\r\n router.couldDeactivate = false;\r\n\r\n let eventName: string;\r\n\r\n if (result.output instanceof Error) {\r\n eventName = RouterEvent.Error;\r\n } else if (!result.completed) {\r\n eventName = RouterEvent.Canceled;\r\n } else {\r\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\r\n router.history.previousLocation = instruction.fragment + queryString;\r\n eventName = RouterEvent.Success;\r\n }\r\n\r\n eventAggregator.publish(eventName, eventArgs);\r\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\r\n } else {\r\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst restorePreviousLocation = (router: AppRouter): void => {\r\n let previousLocation = router.history.previousLocation;\r\n if (previousLocation) {\r\n router.navigate(previousLocation, { trigger: false, replace: true });\r\n } else if (router.fallbackRoute) {\r\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\r\n } else {\r\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\r\n }\r\n};\r\n","/**\r\n* The status of a Pipeline.\r\n*/\r\nexport const enum PipelineStatus {\r\n Completed = 'completed',\r\n Canceled = 'canceled',\r\n Rejected = 'rejected',\r\n Running = 'running'\r\n}\r\n","/**\r\n * A list of known router events used by the Aurelia router\r\n * to signal the pipeline has come to a certain state\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum RouterEvent {\r\n Processing = 'router:navigation:processing',\r\n Error = 'router:navigation:error',\r\n Canceled = 'router:navigation:canceled',\r\n Complete = 'router:navigation:complete',\r\n Success = 'router:navigation:success',\r\n ChildComplete = 'router:navigation:child:complete'\r\n}\r\n","/**\r\n * Available pipeline slot names to insert interceptor into router pipeline\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum PipelineSlotName {\r\n /**\r\n * Authorization slot. Invoked early in the pipeline,\r\n * before `canActivate` hook of incoming route\r\n */\r\n Authorize = 'authorize',\r\n /**\r\n * Pre-activation slot. Invoked early in the pipeline,\r\n * Invoked timing:\r\n * - after Authorization slot\r\n * - after canActivate hook on new view model\r\n * - before deactivate hook on old view model\r\n * - before activate hook on new view model\r\n */\r\n PreActivate = 'preActivate',\r\n /**\r\n * Pre-render slot. Invoked later in the pipeline\r\n * Invokcation timing:\r\n * - after activate hook on new view model\r\n * - before commit step on new navigation instruction\r\n */\r\n PreRender = 'preRender',\r\n /**\r\n * Post-render slot. Invoked last in the pipeline\r\n */\r\n PostRender = 'postRender'\r\n}\r\n"],"names":["RouteRecognizer","Container","LogManager.getLogger","tslib_1.__extends","History","EventAggregator","PipelineStatus","RouterEvent","PipelineSlotName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA;;;AAGA;IA4DE,+BAAY,IAA+B;;;;QAT3C,SAAI,GAAwC,IAAI,CAAC;QAEjD,YAAO,GAAwB,EAAE,CAAC;QAQhC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;QAE/B,IAAI,cAAc,GAAG,EAAE,CAAC;QACxB,IAAI,OAAO,GAA0B,IAAI,CAAC;QAC1C,GAAG;YACD,IAAI,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACtD,IAAI,OAAO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W,KAAXA,mBAAW,QAO5B;;ACZD;;;AAGA,AACA,WAAkB,gBAAgB;;;;;IAKhC,2CAAuB,CAAA;;;;;;;;;IASvB,+CAA2B,CAAA;;;;;;;IAO3B,2CAAuB,CAAA;;;;IAIvB,6CAAyB,CAAA;CAC1B,EA1BiBC,wBAAgB,KAAhBA,wBAAgB,QA0BjC;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/es2015/aurelia-router.js.map b/dist/es2015/aurelia-router.js.map index 87ad2189..8bca893a 100644 --- a/dist/es2015/aurelia-router.js.map +++ b/dist/es2015/aurelia-router.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\nimport { Router } from './router';\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\n\n/**\n * Initialization options for a navigation instruction\n */\nexport interface NavigationInstructionInit {\n fragment: string;\n queryString?: string;\n params?: Record;\n queryParams?: Record;\n config: RouteConfig;\n parentInstruction?: NavigationInstruction;\n previousInstruction?: NavigationInstruction;\n router: Router;\n options?: Object;\n plan?: Record;\n}\n\nexport interface ViewPortInstructionInit {\n name: string;\n strategy: ActivationStrategyType;\n moduleId: string;\n component: ViewPortComponent;\n}\n\n/**\n * Class used to represent an instruction during a navigation.\n */\nexport class NavigationInstruction {\n /**\n * The URL fragment.\n */\n fragment: string;\n\n /**\n * The query string.\n */\n queryString: string;\n\n /**\n * Parameters extracted from the route pattern.\n */\n params: any;\n\n /**\n * Parameters extracted from the query string.\n */\n queryParams: any;\n\n /**\n * The route config for the route matching this instruction.\n */\n config: RouteConfig;\n\n /**\n * The parent instruction, if this instruction was created by a child router.\n */\n parentInstruction: NavigationInstruction;\n\n parentCatchHandler: any;\n\n /**\n * The instruction being replaced by this instruction in the current router.\n */\n previousInstruction: NavigationInstruction;\n\n /**\n * viewPort instructions to used activation.\n */\n viewPortInstructions: Record;\n\n /**\n * The router instance.\n */\n router: Router;\n\n /**\n * Current built viewport plan of this nav instruction\n */\n plan: Record = null;\n\n options: Record = {};\n\n /**@internal */\n lifecycleArgs: LifecycleArguments;\n /**@internal */\n resolve?: (val?: any) => void;\n\n constructor(init: NavigationInstructionInit) {\n Object.assign(this, init);\n\n this.params = this.params || {};\n this.viewPortInstructions = {};\n\n let ancestorParams = [];\n let current: NavigationInstruction = this;\n do {\n let currentParams = Object.assign({}, current.params);\n if (current.config && current.config.hasChildRouter) {\n // remove the param for the injected child route segment\n delete currentParams[current.getWildCardName()];\n }\n\n ancestorParams.unshift(currentParams);\n current = current.parentInstruction;\n } while (current);\n\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\n this.lifecycleArgs = [allParams, this.config, this];\n }\n\n /**\n * Gets an array containing this instruction and all child instructions for the current navigation.\n */\n getAllInstructions(): Array {\n let instructions: NavigationInstruction[] = [this];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let key in viewPortInstructions) {\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\n if (childInstruction) {\n instructions.push(...childInstruction.getAllInstructions());\n }\n }\n\n return instructions;\n }\n\n /**\n * Gets an array containing the instruction and all child instructions for the previous navigation.\n * Previous instructions are no longer available after navigation completes.\n */\n getAllPreviousInstructions(): Array {\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\n }\n\n /**\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\n */\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\n addViewPortInstruction(\n nameOrInitOptions: string | ViewPortInstructionInit,\n strategy?: ActivationStrategyType,\n moduleId?: string,\n component?: any\n ): /*ViewPortInstruction*/ any {\n\n let viewPortInstruction: ViewPortInstruction;\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\n const lifecycleArgs = this.lifecycleArgs;\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\n\n if (typeof nameOrInitOptions === 'string') {\n viewPortInstruction = {\n name: nameOrInitOptions,\n strategy: strategy,\n moduleId: moduleId,\n component: component,\n childRouter: component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n } else {\n viewPortInstruction = {\n name: viewPortName,\n strategy: nameOrInitOptions.strategy,\n component: nameOrInitOptions.component,\n moduleId: nameOrInitOptions.moduleId,\n childRouter: nameOrInitOptions.component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n }\n\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\n }\n\n /**\n * Gets the name of the route pattern's wildcard parameter, if applicable.\n */\n getWildCardName(): string {\n // todo: potential issue, or at least unsafe typings\n let configRoute = this.config.route as string;\n let wildcardIndex = configRoute.lastIndexOf('*');\n return configRoute.substr(wildcardIndex + 1);\n }\n\n /**\n * Gets the path and query string created by filling the route\n * pattern's wildcard parameter with the matching param.\n */\n getWildcardPath(): string {\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n let queryString = this.queryString;\n\n if (queryString) {\n path += '?' + queryString;\n }\n\n return path;\n }\n\n /**\n * Gets the instruction's base URL, accounting for wildcard route parameters.\n */\n getBaseUrl(): string {\n let $encodeURI = encodeURI;\n let fragment = decodeURI(this.fragment);\n\n if (fragment === '') {\n let nonEmptyRoute = this.router.routes.find(route => {\n return route.name === this.config.name &&\n route.route !== '';\n });\n if (nonEmptyRoute) {\n fragment = nonEmptyRoute.route as any;\n }\n }\n\n if (!this.params) {\n return $encodeURI(fragment);\n }\n\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n\n if (!path) {\n return $encodeURI(fragment);\n }\n\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\n }\n\n /**\n * Finalize a viewport instruction\n * @internal\n */\n _commitChanges(waitToSwap: boolean): Promise {\n let router = this.router;\n router.currentInstruction = this;\n\n const previousInstruction = this.previousInstruction;\n if (previousInstruction) {\n previousInstruction.config.navModel.isActive = false;\n }\n\n this.config.navModel.isActive = true;\n\n router.refreshNavigation();\n\n let loads: Promise[] = [];\n let delaySwaps: ISwapPlan[] = [];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let viewPort = router.viewPorts[viewPortName];\n\n if (!viewPort) {\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\n }\n\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n } else {\n if (waitToSwap) {\n delaySwaps.push({ viewPort, viewPortInstruction });\n }\n loads.push(\n viewPort\n .process(viewPortInstruction, waitToSwap)\n .then(() => childNavInstruction\n ? childNavInstruction._commitChanges(waitToSwap)\n : Promise.resolve()\n )\n );\n }\n } else {\n if (childNavInstruction) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n }\n }\n }\n\n return Promise\n .all(loads)\n .then(() => {\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\n return null;\n })\n .then(() => prune(this));\n }\n\n /**@internal */\n _updateTitle(): void {\n let router = this.router;\n let title = this._buildTitle(router.titleSeparator);\n if (title) {\n router.history.setTitle(title);\n }\n }\n\n /**@internal */\n _buildTitle(separator: string = ' | '): string {\n let title = '';\n let childTitles = [];\n let navModelTitle = this.config.navModel.title;\n let instructionRouter = this.router;\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n if (navModelTitle) {\n title = instructionRouter.transformTitle(navModelTitle);\n }\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\n\n if (child_nav_instruction) {\n let childTitle = child_nav_instruction._buildTitle(separator);\n if (childTitle) {\n childTitles.push(childTitle);\n }\n }\n }\n\n if (childTitles.length) {\n title = childTitles.join(separator) + (title ? separator : '') + title;\n }\n\n if (instructionRouter.title) {\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\n }\n\n return title;\n }\n}\n\nconst prune = (instruction: NavigationInstruction): void => {\n instruction.previousInstruction = null;\n instruction.plan = null;\n};\n\ninterface ISwapPlan {\n viewPort: ViewPort;\n viewPortInstruction: ViewPortInstruction;\n}\n","import { Router } from './router';\nimport { RouteConfig } from './interfaces';\n\n/**\n* Class for storing and interacting with a route's navigation settings.\n*/\nexport class NavModel {\n\n /**\n * True if this nav item is currently active.\n */\n isActive: boolean = false;\n\n /**\n * The title.\n */\n title: string = null;\n\n /**\n * This nav item's absolute href.\n */\n href: string = null;\n\n /**\n * This nav item's relative href.\n */\n relativeHref: string = null;\n\n /**\n * Data attached to the route at configuration time.\n */\n settings: any = {};\n\n /**\n * The route config.\n */\n config: RouteConfig = null;\n\n /**\n * The router associated with this navigation model.\n */\n router: Router;\n\n order: number | boolean;\n\n constructor(router: Router, relativeHref: string) {\n this.router = router;\n this.relativeHref = relativeHref;\n }\n\n /**\n * Sets the route's title and updates document.title.\n * If the a navigation is in progress, the change will be applied\n * to document.title when the navigation completes.\n *\n * @param title The new title.\n */\n setTitle(title: string): void {\n this.title = title;\n\n if (this.isActive) {\n this.router.updateTitle();\n }\n }\n}\n","import { RouteConfig } from './interfaces';\n\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\n if (!hasPushState && path[0] !== '#') {\n path = '#' + path;\n }\n\n if (hasPushState && absolute) {\n path = path.substring(1, path.length);\n }\n\n return path;\n}\n\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\n if (isAbsoluteUrl.test(fragment)) {\n return fragment;\n }\n\n let path = '';\n\n if (baseUrl.length && baseUrl[0] !== '/') {\n path += '/';\n }\n\n path += baseUrl;\n\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\n path += '/';\n }\n\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\n path = path.substring(0, path.length - 1);\n }\n\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\n}\n\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\n if (isRootedPath.test(fragment)) {\n return _normalizeAbsolutePath(fragment, hasPushState);\n }\n\n return _createRootedPath(fragment, baseUrl, hasPushState);\n}\n\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\n let routeConfigs = [];\n\n if (Array.isArray(config.route)) {\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\n let current = Object.assign({}, config);\n current.route = config.route[i];\n routeConfigs.push(current);\n }\n } else {\n routeConfigs.push(Object.assign({}, config));\n }\n\n return routeConfigs;\n}\n\nconst isRootedPath = /^#?\\//;\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\nimport { Router } from './router';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * Class used to configure a [[Router]] instance.\n *\n * @constructor\n */\nexport class RouterConfiguration {\n instructions: Array<(router: Router) => void> = [];\n options: {\n [key: string]: any;\n compareQueryParams?: boolean;\n root?: string;\n pushState?: boolean;\n hashChange?: boolean;\n silent?: boolean;\n } = {};\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\n title: string;\n titleSeparator: string;\n unknownRouteConfig: RouteConfigSpecifier;\n viewPortDefaults: Record;\n\n /**@internal */\n _fallbackRoute: string;\n\n /**\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\n *\n * @param name The name of the pipeline slot to insert the step into.\n * @param step The pipeline step.\n * @chainable\n */\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\n if (step === null || step === undefined) {\n throw new Error('Pipeline step cannot be null or undefined.');\n }\n this.pipelineSteps.push({ name, step });\n return this;\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\n }\n\n /**\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @chainable\n */\n fallbackRoute(fragment: string): RouterConfiguration {\n this._fallbackRoute = fragment;\n return this;\n }\n\n /**\n * Maps one or more routes to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\n * @chainable\n */\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\n if (Array.isArray(route)) {\n route.forEach(r => this.map(r));\n return this;\n }\n\n return this.mapRoute(route);\n }\n\n /**\n * Configures defaults to use for any view ports.\n *\n * @param viewPortConfig a view port configuration object to use as a\n * default, of the form { viewPortName: { moduleId } }.\n * @chainable\n */\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\n this.viewPortDefaults = viewPortConfig;\n return this;\n }\n\n /**\n * Maps a single route to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map.\n * @chainable\n */\n mapRoute(config: RouteConfig): RouterConfiguration {\n this.instructions.push(router => {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n\n let navModel;\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\n let routeConfig = routeConfigs[i];\n routeConfig.settings = routeConfig.settings || {};\n if (!navModel) {\n navModel = router.createNavModel(routeConfig);\n }\n\n router.addRoute(routeConfig, navModel);\n }\n });\n\n return this;\n }\n\n /**\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\n *\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\n * [[NavigationInstruction]] and selects a moduleId to load.\n * @chainable\n */\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\n this.unknownRouteConfig = config;\n return this;\n }\n\n /**\n * Applies the current configuration to the specified [[Router]].\n *\n * @param router The [[Router]] to apply the configuration to.\n */\n exportToRouter(router: Router): void {\n let instructions = this.instructions;\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\n instructions[i](router);\n }\n\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\n\n if (title) {\n router.title = title;\n }\n\n if (titleSeparator) {\n router.titleSeparator = titleSeparator;\n }\n\n if (unknownRouteConfig) {\n router.handleUnknownRoutes(unknownRouteConfig);\n }\n\n if (_fallbackRoute) {\n router.fallbackRoute = _fallbackRoute;\n }\n\n if (viewPortDefaults) {\n router.useViewPortDefaults(viewPortDefaults);\n }\n\n Object.assign(router.options, this.options);\n\n let pipelineSteps = this.pipelineSteps;\n let pipelineStepCount = pipelineSteps.length;\n if (pipelineStepCount) {\n if (!router.isRoot) {\n throw new Error('Pipeline steps can only be added to the root router');\n }\n\n let pipelineProvider = router.pipelineProvider;\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\n let { name, step } = pipelineSteps[i];\n pipelineProvider.addStep(name, step);\n }\n }\n }\n}\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): boolean {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): boolean {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\n\n/**@internal exported for unit testing */\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\n let index = -1;\n const next: Next = function() {\n index++;\n\n if (index < steps.length) {\n let currentStep = steps[index];\n\n try {\n return currentStep(instruction, next);\n } catch (e) {\n return next.reject(e);\n }\n } else {\n return next.complete();\n }\n } as Next;\n\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\n\n return next;\n};\n\n/**@internal exported for unit testing */\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\n return (output: any) => Promise\n .resolve({\n status,\n output,\n completed: status === PipelineStatus.Completed\n });\n};\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { createNextFn } from './next';\n\n/**\n * The class responsible for managing and processing the navigation pipeline.\n */\nexport class Pipeline {\n /**\n * The pipeline steps. And steps added via addStep will be converted to a function\n * The actualy running functions with correct step contexts of this pipeline\n */\n steps: StepRunnerFunction[] = [];\n\n /**\n * Adds a step to the pipeline.\n *\n * @param step The pipeline step.\n */\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\n let run;\n\n if (typeof step === 'function') {\n run = step;\n } else if (typeof step.getSteps === 'function') {\n // getSteps is to enable support open slots\n // where devs can add multiple steps into the same slot name\n let steps = step.getSteps();\n for (let i = 0, l = steps.length; i < l; i++) {\n this.addStep(steps[i]);\n }\n\n return this;\n } else {\n run = (step as PipelineStep).run.bind(step);\n }\n\n this.steps.push(run);\n\n return this;\n }\n\n /**\n * Runs the pipeline.\n *\n * @param instruction The navigation instruction to process.\n */\n run(instruction: NavigationInstruction): Promise {\n const nextFn = createNextFn(instruction, this.steps);\n return nextFn();\n }\n}\n","import { NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface NavigationOptions {\n useAppRouter?: boolean;\n }\n}\n\n/**\n* When a navigation command is encountered, the current navigation\n* will be cancelled and control will be passed to the navigation\n* command so it can determine the correct action.\n*/\nexport interface NavigationCommand {\n navigate: (router: Router) => void;\n /**@internal */\n shouldContinueProcessing?: boolean;\n /**@internal */\n setRouter?: (router: Router) => void;\n}\n\n/**\n* Determines if the provided object is a navigation command.\n* A navigation command is anything with a navigate method.\n*\n* @param obj The object to check.\n*/\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\n return obj && typeof obj.navigate === 'function';\n}\n\n/**\n* Used during the activation lifecycle to cause a redirect.\n*/\nexport class Redirect implements NavigationCommand {\n\n url: string;\n /**@internal */\n options: NavigationOptions;\n /**@internal */\n shouldContinueProcessing: boolean;\n\n private router: Router;\n\n /**\n * @param url The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n constructor(url: string, options: NavigationOptions = {}) {\n this.url = url;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigate(this.url, this.options);\n }\n}\n\n/**\n * Used during the activation lifecycle to cause a redirect to a named route.\n */\nexport class RedirectToRoute implements NavigationCommand {\n\n route: string;\n params: any;\n /**@internal */\n options: NavigationOptions;\n\n /**@internal */\n shouldContinueProcessing: boolean;\n\n /**@internal */\n router: Router;\n\n /**\n * @param route The name of the route.\n * @param params The parameters to be sent to the activation method.\n * @param options The options to use for navigation.\n */\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\n this.route = route;\n this.params = params;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\n }\n}\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\n\ntype ViewPortPlansRecord = Record;\n\n/**\n * @internal exported for unit testing\n */\nexport function _buildNavigationPlan(\n instruction: NavigationInstruction,\n forceLifecycleMinimum?: boolean\n): Promise {\n let config = instruction.config;\n\n if ('redirect' in config) {\n return buildRedirectPlan(instruction);\n }\n\n const prevInstruction = instruction.previousInstruction;\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\n\n if (prevInstruction) {\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\n }\n\n // first navigation, only need to prepare a few information for each viewport plan\n const viewPortPlans: ViewPortPlansRecord = {};\n let viewPortConfigs = config.viewPorts;\n for (let viewPortName in viewPortConfigs) {\n let viewPortConfig = viewPortConfigs[viewPortName];\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n viewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n viewPortPlans[viewPortName] = {\n name: viewPortName,\n strategy: InternalActivationStrategy.Replace,\n config: viewPortConfig\n };\n }\n\n return Promise.resolve(viewPortPlans);\n}\n\n/**\n * Build redirect plan based on config of a navigation instruction\n * @internal exported for unit testing\n */\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\n const config = instruction.config;\n const router = instruction.router;\n return router\n ._createNavigationInstruction(config.redirect)\n .then(redirectInstruction => {\n\n const params: Record = {};\n const originalInstructionParams = instruction.params;\n const redirectInstructionParams = redirectInstruction.params;\n\n for (let key in redirectInstructionParams) {\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\n let val = redirectInstructionParams[key];\n if (typeof val === 'string' && val[0] === ':') {\n val = val.slice(1);\n // And if that param is found on the original instruction then use it\n if (val in originalInstructionParams) {\n params[key] = originalInstructionParams[val];\n }\n } else {\n params[key] = redirectInstructionParams[key];\n }\n }\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\n\n // Special handling for child routes\n for (let key in originalInstructionParams) {\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\n }\n\n let queryString = instruction.queryString;\n if (queryString) {\n redirectLocation += '?' + queryString;\n }\n\n return Promise.resolve(new Redirect(redirectLocation));\n });\n};\n\n/**\n * @param viewPortPlans the Plan record that holds information about built plans\n * @internal exported for unit testing\n */\nexport const buildTransitionPlans = (\n currentInstruction: NavigationInstruction,\n previousInstruction: NavigationInstruction,\n defaultViewPortConfigs: Record,\n forceLifecycleMinimum?: boolean\n): Promise => {\n\n let viewPortPlans: ViewPortPlansRecord = {};\n let newInstructionConfig = currentInstruction.config;\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\n let pending: Promise[] = [];\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\n\n for (let viewPortName in previousViewPortInstructions) {\n\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\n const prevViewPortComponent = prevViewPortInstruction.component;\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\n\n // if this is invoked on a viewport without any changes, based on new url,\n // newViewPortConfig will be the existing viewport instruction\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\n ? newInstructionViewPortConfigs[viewPortName]\n : prevViewPortInstruction;\n\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n\n const viewPortActivationStrategy = determineActivationStrategy(\n currentInstruction,\n prevViewPortInstruction,\n nextViewPortConfig,\n hasNewParams,\n forceLifecycleMinimum\n );\n const viewPortPlan = viewPortPlans[viewPortName] = {\n name: viewPortName,\n // ViewPortInstruction can quack like a RouteConfig\n config: nextViewPortConfig as RouteConfig,\n prevComponent: prevViewPortComponent,\n prevModuleId: prevViewPortInstruction.moduleId,\n strategy: viewPortActivationStrategy\n } as ViewPortPlan;\n\n // recursively build nav plans for all existing child routers/viewports of this viewport\n // this is possible because existing child viewports and routers already have necessary information\n // to process the wildcard path from parent instruction\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\n const path = currentInstruction.getWildcardPath();\n const task: Promise = prevViewPortInstruction\n .childRouter\n ._createNavigationInstruction(path, currentInstruction)\n .then((childInstruction: NavigationInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(\n childInstruction,\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\n // if so, can just use local variable viewPortPlanStrategy\n // there could be user code modifying viewport plan during _createNavigationInstruction?\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\n )\n .then(childPlan => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n // for bluebird ?\n return null;\n });\n });\n\n pending.push(task);\n }\n }\n\n return Promise.all(pending).then(() => viewPortPlans);\n};\n\n/**\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\n * @internal exported for unit testing\n */\nexport const determineActivationStrategy = (\n currentNavInstruction: NavigationInstruction,\n prevViewPortInstruction: ViewPortInstruction,\n newViewPortConfig: RouteConfig | ViewPortInstruction,\n // indicates whether there is difference between old and new url params\n hasNewParams: boolean,\n forceLifecycleMinimum?: boolean\n): ActivationStrategyType => {\n\n let newInstructionConfig = currentNavInstruction.config;\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\n let viewPortPlanStrategy: ActivationStrategyType;\n\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\n } else if (newInstructionConfig.activationStrategy) {\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\n } else if (hasNewParams || forceLifecycleMinimum) {\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\n } else {\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\n }\n return viewPortPlanStrategy;\n};\n\n/**@internal exported for unit testing */\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\n let prevParams = prev.params;\n let nextParams = next.params;\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\n\n for (let key in nextParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n for (let key in prevParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n if (!next.options.compareQueryParams) {\n return false;\n }\n\n let prevQueryParams = prev.queryParams;\n let nextQueryParams = next.queryParams;\n for (let key in nextQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n for (let key in prevQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n return false;\n};\n","import { Next } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\n\n/**\n * Transform a navigation instruction into viewport plan record object,\n * or a redirect request if user viewmodel demands\n */\nexport class BuildNavigationPlanStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return _buildNavigationPlan(navigationInstruction)\n .then(plan => {\n if (plan instanceof Redirect) {\n return next.cancel(plan);\n }\n navigationInstruction.plan = plan;\n return next();\n })\n .catch(next.cancel);\n }\n}\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\nimport { InternalActivationStrategy } from './activation-strategy';\nimport { RouteLoader } from './route-loader';\n\n/**\n * Loading plan calculated based on a navigration-instruction and a viewport plan\n */\ninterface ILoadingPlan {\n viewPortPlan: ViewPortPlan;\n navigationInstruction: NavigationInstruction;\n}\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadNewRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction\n): Promise => {\n let loadingPlans = determineLoadingPlans(navigationInstruction);\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\n routeLoader,\n loadingPlan.navigationInstruction,\n loadingPlan.viewPortPlan\n ));\n\n return Promise.all(loadPromises);\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const determineLoadingPlans = (\n navigationInstruction: NavigationInstruction,\n loadingPlans: ILoadingPlan[] = []\n): ILoadingPlan[] => {\n let viewPortPlans: Record = navigationInstruction.plan;\n\n for (let viewPortName in viewPortPlans) {\n let viewPortPlan = viewPortPlans[viewPortName];\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\n\n if (childNavInstruction) {\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n } else {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortName,\n strategy: viewPortPlan.strategy,\n moduleId: viewPortPlan.prevModuleId,\n component: viewPortPlan.prevComponent\n }) as ViewPortInstruction;\n\n if (childNavInstruction) {\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n }\n }\n\n return loadingPlans;\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n viewPortPlan: ViewPortPlan\n): Promise => {\n let planConfig = viewPortPlan.config;\n let moduleId = planConfig ? planConfig.moduleId : null;\n\n return loadComponent(routeLoader, navigationInstruction, planConfig)\n .then((component) => {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortPlan.name,\n strategy: viewPortPlan.strategy,\n moduleId: moduleId,\n component: component\n }) as ViewPortInstruction;\n\n let childRouter = component.childRouter;\n if (childRouter) {\n let path = navigationInstruction.getWildcardPath();\n\n return childRouter\n ._createNavigationInstruction(path, navigationInstruction)\n .then((childInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(childInstruction)\n .then((childPlan) => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n viewPortInstruction.childNavigationInstruction = childInstruction;\n\n return loadNewRoute(routeLoader, childInstruction);\n });\n });\n }\n // ts complains without this, though they are same\n return void 0;\n });\n};\n\n/**\n * Load a routed-component based on navigation instruction and route config\n * @internal exported for unit testing only\n */\nexport const loadComponent = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n config: RouteConfig\n): Promise => {\n let router = navigationInstruction.router;\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\n\n return Promise.resolve()\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\n .then(\n /**\n * @param component an object carrying information about loaded route\n * typically contains information about view model, childContainer, view and router\n */\n (component: ViewPortComponent) => {\n let { viewModel, childContainer } = component;\n component.router = router;\n component.config = config;\n\n if ('configureRouter' in viewModel) {\n let childRouter = childContainer.getChildRouter();\n component.childRouter = childRouter;\n\n return childRouter\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\n .then(() => component);\n }\n\n return component;\n }\n );\n};\n","import { RouteConfig } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Router } from './router';\n\n/**\n * Abstract class that is responsible for loading view / view model from a route config\n * The default implementation can be found in `aurelia-templating-router`\n */\nexport class RouteLoader {\n /**\n * Load a route config based on its viewmodel / view configuration\n */\n // return typing: return typings used to be never\n // as it was a throw. Changing it to Promise should not cause any issues\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\n }\n}\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { loadNewRoute } from './utilities-route-loading';\nimport { RouteLoader } from './route-loader';\n/**\n * A pipeline step responsible for loading a route config of a navigation instruction\n */\nexport class LoadRouteStep {\n /**@internal */\n static inject() { return [RouteLoader]; }\n /**\n * Route loader isntance that will handle loading route config\n * @internal\n */\n routeLoader: RouteLoader;\n constructor(routeLoader: RouteLoader) {\n this.routeLoader = routeLoader;\n }\n /**\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\n */\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return loadNewRoute(this.routeLoader, navigationInstruction)\n .then(next, next.cancel);\n }\n}\n","import { NavigationInstruction } from './navigation-instruction';\n\n/**\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\n */\nexport class CommitChangesStep {\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\n return navigationInstruction\n ._commitChanges(/*wait to swap?*/ true)\n .then(() => {\n navigationInstruction._updateTitle();\n return next();\n });\n }\n}\n","/**\n * An optional interface describing the available activation strategies.\n * @internal Used internally.\n */\nexport const enum InternalActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n NoChange = 'no-change',\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n InvokeLifecycle = 'invoke-lifecycle',\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n Replace = 'replace'\n}\n\n/**\n * The strategy to use when activating modules during navigation.\n */\n// kept for compat reason\nexport const activationStrategy: ActivationStrategy = {\n noChange: InternalActivationStrategy.NoChange,\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\n replace: InternalActivationStrategy.Replace\n};\n\n/**\n * An optional interface describing the available activation strategies.\n */\nexport interface ActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n noChange: 'no-change';\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n invokeLifecycle: 'invoke-lifecycle';\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n replace: 'replace';\n}\n\n/**\n * Enum like type for activation strategy built-in values\n */\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\nimport { isNavigationCommand } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { activationStrategy } from './activation-strategy';\nimport { Router } from './router';\n\n/**\n * Recursively find list of deactivate-able view models\n * and invoke the either 'canDeactivate' or 'deactivate' on each\n * @internal exported for unit testing\n */\nexport const processDeactivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canDeactivate' | 'deactivate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let plan: Record = navigationInstruction.plan;\n let infos = findDeactivatable(plan, callbackName);\n let i = infos.length; // query from inside out\n\n function inspect(val: any): Promise {\n if (ignoreResult || shouldContinue(val)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n if (i--) {\n try {\n let viewModel = infos[i];\n let result = viewModel[callbackName](navigationInstruction);\n return processPotential(result, inspect, next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n navigationInstruction.router.couldDeactivate = true;\n\n return next();\n }\n\n return iterate();\n};\n\n/**\n * Recursively find and returns a list of deactivate-able view models\n * @internal exported for unit testing\n */\nexport const findDeactivatable = (\n plan: Record,\n callbackName: string,\n list: IActivatableInfo[] = []\n): any[] => {\n for (let viewPortName in plan) {\n let viewPortPlan = plan[viewPortName];\n let prevComponent = viewPortPlan.prevComponent;\n\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\n && prevComponent\n ) {\n let viewModel = prevComponent.viewModel;\n\n if (callbackName in viewModel) {\n list.push(viewModel);\n }\n }\n\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\n addPreviousDeactivatable(prevComponent, callbackName, list);\n } else if (viewPortPlan.childNavigationInstruction) {\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\n }\n }\n\n return list;\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const addPreviousDeactivatable = (\n component: ViewPortComponent,\n callbackName: string,\n list: IActivatableInfo[]\n): void => {\n let childRouter = component.childRouter;\n\n if (childRouter && childRouter.currentInstruction) {\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let prevComponent = viewPortInstruction.component;\n let prevViewModel = prevComponent.viewModel;\n\n if (callbackName in prevViewModel) {\n list.push(prevViewModel);\n }\n\n addPreviousDeactivatable(prevComponent, callbackName, list);\n }\n }\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const processActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let infos = findActivatable(navigationInstruction, callbackName);\n let length = infos.length;\n let i = -1; // query from top down\n\n function inspect(val: any, router: Router): Promise {\n if (ignoreResult || shouldContinue(val, router)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n i++;\n\n if (i < length) {\n try {\n let current = infos[i];\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n return next();\n }\n\n return iterate();\n};\n\ninterface IActivatableInfo {\n viewModel: any;\n lifecycleArgs: LifecycleArguments;\n router: Router;\n}\n\n/**\n * Find list of activatable view model and add to list (3rd parameter)\n * @internal exported for unit testing\n */\nexport const findActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n list: IActivatableInfo[] = [],\n router?: Router\n): IActivatableInfo[] => {\n let plan: Record = navigationInstruction.plan;\n\n Object\n .keys(plan)\n .forEach((viewPortName) => {\n let viewPortPlan = plan[viewPortName];\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\n let viewPortComponent = viewPortInstruction.component;\n let viewModel = viewPortComponent.viewModel;\n\n if (\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\n || viewPortPlan.strategy === activationStrategy.replace\n )\n && callbackName in viewModel\n ) {\n list.push({\n viewModel,\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\n router\n });\n }\n\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (childNavInstruction) {\n findActivatable(\n childNavInstruction,\n callbackName,\n list,\n viewPortComponent.childRouter || router\n );\n }\n });\n\n return list;\n};\n\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\n if (output instanceof Error) {\n return false;\n }\n\n if (isNavigationCommand(output)) {\n if (typeof output.setRouter === 'function') {\n output.setRouter(router);\n }\n\n return !!output.shouldContinueProcessing;\n }\n\n if (output === undefined) {\n return true;\n }\n\n return output;\n};\n\n/**\n * A basic interface for an Observable type\n */\nexport interface IObservable {\n subscribe(sub?: IObservableConfig): ISubscription;\n}\n\nexport interface IObservableConfig {\n next(): void;\n error(err?: any): void;\n complete(): void;\n}\n\n/**\n * A basic interface for a Subscription to an Observable\n */\ninterface ISubscription {\n unsubscribe(): void;\n}\n\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\n\n/**\n * wraps a subscription, allowing unsubscribe calls even if\n * the first value comes synchronously\n */\nclass SafeSubscription {\n\n private _subscribed: boolean;\n private _subscription: ISubscription;\n\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\n this._subscribed = true;\n this._subscription = subscriptionFunc(this);\n\n if (!this._subscribed) {\n this.unsubscribe();\n }\n }\n\n get subscribed(): boolean {\n return this._subscribed;\n }\n\n unsubscribe(): void {\n if (this._subscribed && this._subscription) {\n this._subscription.unsubscribe();\n }\n\n this._subscribed = false;\n }\n}\n\n/**\n * A function to process return value from `activate`/`canActivate` steps\n * Supports observable/promise\n *\n * For observable, resolve at first next() or on complete()\n */\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\n // if promise like\n if (obj && typeof obj.then === 'function') {\n return Promise.resolve(obj).then(resolve).catch(reject);\n }\n\n // if observable\n if (obj && typeof obj.subscribe === 'function') {\n let obs: IObservable = obj;\n return new SafeSubscription(sub => obs.subscribe({\n next() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n },\n error(error) {\n if (sub.subscribed) {\n sub.unsubscribe();\n reject(error);\n }\n },\n complete() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n }\n }));\n }\n\n // else just resolve\n try {\n return resolve(obj);\n } catch (error) {\n return reject(error);\n }\n};\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { processDeactivatable, processActivatable } from './utilities-activation';\n\n/**\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\n */\nexport class CanDeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\n */\nexport class CanActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'canActivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\n */\nexport class DeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\n */\nexport class ActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'activate', next, true);\n }\n}\n","import { Container } from 'aurelia-dependency-injection';\nimport { Pipeline } from './pipeline';\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\nimport { LoadRouteStep } from './step-load-route';\nimport { CommitChangesStep } from './step-commit-changes';\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\n */\nclass PipelineSlot implements IPipelineSlot {\n\n /**@internal */\n container: Container;\n /**@internal */\n slotName: string;\n /**@internal */\n slotAlias?: string;\n\n steps: (Function | PipelineStep)[] = [];\n\n constructor(container: Container, name: string, alias?: string) {\n this.container = container;\n this.slotName = name;\n this.slotAlias = alias;\n }\n\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\n return this.steps.map(x => this.container.get(x));\n }\n}\n\n/**\n * Class responsible for creating the navigation pipeline.\n */\nexport class PipelineProvider {\n\n /**@internal */\n static inject() { return [Container]; }\n /**@internal */\n container: Container;\n /**@internal */\n steps: (Function | PipelineSlot)[];\n\n constructor(container: Container) {\n this.container = container;\n this.steps = [\n BuildNavigationPlanStep,\n CanDeactivatePreviousStep, // optional\n LoadRouteStep,\n createPipelineSlot(container, PipelineSlotName.Authorize),\n CanActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\n // NOTE: app state changes start below - point of no return\n DeactivatePreviousStep, // optional\n ActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\n CommitChangesStep,\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\n ];\n }\n\n /**\n * Create the navigation pipeline.\n */\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\n let pipeline = new Pipeline();\n this.steps.forEach(step => {\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\n pipeline.addStep(this.container.get(step));\n }\n });\n return pipeline;\n }\n\n /**@internal */\n _findStep(name: string): PipelineSlot {\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\n }\n\n /**\n * Adds a step into the pipeline at a known slot location.\n */\n addStep(name: string, step: PipelineStep | Function): void {\n let found = this._findStep(name);\n if (found) {\n let slotSteps = found.steps;\n // prevent duplicates\n if (!slotSteps.includes(step)) {\n slotSteps.push(step);\n }\n } else {\n throw new Error(`Invalid pipeline slot name: ${name}.`);\n }\n }\n\n /**\n * Removes a step from a slot in the pipeline\n */\n removeStep(name: string, step: PipelineStep): void {\n let slot = this._findStep(name);\n if (slot) {\n let slotSteps = slot.steps;\n slotSteps.splice(slotSteps.indexOf(step), 1);\n }\n }\n\n /**\n * Clears all steps from a slot in the pipeline\n * @internal\n */\n _clearSteps(name: string = ''): void {\n let slot = this._findStep(name);\n if (slot) {\n slot.steps = [];\n }\n }\n\n /**\n * Resets all pipeline slots\n */\n reset(): void {\n this._clearSteps(PipelineSlotName.Authorize);\n this._clearSteps(PipelineSlotName.PreActivate);\n this._clearSteps(PipelineSlotName.PreRender);\n this._clearSteps(PipelineSlotName.PostRender);\n }\n}\n\n/**@internal */\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\n return new PipelineSlot(container, name, alias);\n};\n","import * as LogManager from 'aurelia-logging';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\nimport { PipelineProvider } from './pipeline-provider';\nimport { isNavigationCommand } from './navigation-commands';\nimport { EventAggregator } from 'aurelia-event-aggregator';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\nimport { RouterEvent } from './router-event';\nimport { RouterConfiguration } from './router-configuration';\n\n/**@internal */\ndeclare module 'aurelia-dependency-injection' {\n interface Container {\n viewModel?: any;\n }\n}\n\nconst logger = LogManager.getLogger('app-router');\n\n/**\n * The main application router.\n */\nexport class AppRouter extends Router {\n\n /**@internal */\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\n\n events: EventAggregator;\n /**@internal */\n maxInstructionCount: number;\n /**@internal */\n _queue: NavigationInstruction[];\n /**@internal */\n isActive: boolean;\n\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\n super(container, history); // Note the super will call reset internally.\n this.pipelineProvider = pipelineProvider;\n this.events = events;\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset(): void {\n super.reset();\n this.maxInstructionCount = 10;\n if (!this._queue) {\n this._queue = [];\n } else {\n this._queue.length = 0;\n }\n }\n\n /**\n * Loads the specified URL.\n *\n * @param url The URL fragment to load.\n */\n loadUrl(url: string): Promise {\n return this\n ._createNavigationInstruction(url)\n .then(instruction => this._queueInstruction(instruction))\n .catch(error => {\n logger.error(error);\n restorePreviousLocation(this);\n });\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\n // having strong typing without changing public API\n const $viewPort: ViewPort = viewPort;\n super.registerViewPort($viewPort, name);\n\n // beside adding viewport to the registry of this instance\n // AppRouter also configure routing/history to start routing functionality\n // There are situation where there are more than 1 element at root view\n // in that case, still only activate once via the following guard\n if (!this.isActive) {\n const viewModel = this._findViewModel($viewPort);\n if ('configureRouter' in viewModel) {\n // If there are more than one element at root view\n // use this flag to guard against configure method being invoked multiple times\n // this flag is set inside method configure\n if (!this.isConfigured) {\n // replace the real resolve with a noop to guarantee that any action in base class Router\n // won't resolve the configurePromise prematurely\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\n this._resolveConfiguredPromise = () => {/**/};\n return this\n .configure(config =>\n Promise\n .resolve(viewModel.configureRouter(config, this))\n // an issue with configure interface. Should be fixed there\n // todo: fix this via configure interface in router\n .then(() => config) as any\n )\n .then(() => {\n this.activate();\n resolveConfiguredPromise();\n });\n }\n } else {\n this.activate();\n }\n }\n // when a viewport is added dynamically to a root view that is already activated\n // just process the navigation instruction\n else {\n this._dequeueInstruction();\n }\n\n return Promise.resolve();\n }\n\n /**\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\n *\n * @params options The set of options to activate the router with.\n */\n activate(options?: NavigationOptions): void {\n if (this.isActive) {\n return;\n }\n\n this.isActive = true;\n // route handler property is responsible for handling url change\n // the interface of aurelia-history isn't clear on this perspective\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\n this.history.activate(this.options);\n this._dequeueInstruction();\n }\n\n /**\n * Deactivates the router.\n */\n deactivate(): void {\n this.isActive = false;\n this.history.deactivate();\n }\n\n /**@internal */\n _queueInstruction(instruction: NavigationInstruction): Promise {\n return new Promise((resolve) => {\n instruction.resolve = resolve;\n this._queue.unshift(instruction);\n this._dequeueInstruction();\n });\n }\n\n /**@internal */\n _dequeueInstruction(instructionCount: number = 0): Promise {\n return Promise.resolve().then(() => {\n if (this.isNavigating && !instructionCount) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n let instruction = this._queue.shift();\n this._queue.length = 0;\n\n if (!instruction) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n this.isNavigating = true;\n\n let navtracker: number = this.history.getState('NavigationTracker');\n let currentNavTracker = this.currentNavigationTracker;\n\n if (!navtracker && !currentNavTracker) {\n this.isNavigatingFirst = true;\n this.isNavigatingNew = true;\n } else if (!navtracker) {\n this.isNavigatingNew = true;\n } else if (!currentNavTracker) {\n this.isNavigatingRefresh = true;\n } else if (currentNavTracker < navtracker) {\n this.isNavigatingForward = true;\n } else if (currentNavTracker > navtracker) {\n this.isNavigatingBack = true;\n } if (!navtracker) {\n navtracker = Date.now();\n this.history.setState('NavigationTracker', navtracker);\n }\n this.currentNavigationTracker = navtracker;\n\n instruction.previousInstruction = this.currentInstruction;\n\n let maxInstructionCount = this.maxInstructionCount;\n\n if (!instructionCount) {\n this.events.publish(RouterEvent.Processing, { instruction });\n } else if (instructionCount === maxInstructionCount - 1) {\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\n restorePreviousLocation(this);\n return this._dequeueInstruction(instructionCount + 1);\n } else if (instructionCount > maxInstructionCount) {\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\n }\n\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\n\n return pipeline\n .run(instruction)\n .then(result => processResult(instruction, result, instructionCount, this))\n .catch(error => {\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\n })\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\n });\n }\n\n /**@internal */\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\n if (this.container.viewModel) {\n return this.container.viewModel;\n }\n\n if (viewPort.container) {\n let container = viewPort.container;\n\n while (container) {\n if (container.viewModel) {\n this.container.viewModel = container.viewModel;\n return container.viewModel;\n }\n\n container = container.parent;\n }\n }\n\n return undefined;\n }\n}\n\nconst processResult = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n instructionCount: number,\n router: AppRouter\n): Promise => {\n if (!(result && 'completed' in result && 'output' in result)) {\n result = result || {} as PipelineResult;\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\n }\n\n let finalResult: PipelineResult = null;\n let navigationCommandResult = null;\n if (isNavigationCommand(result.output)) {\n navigationCommandResult = result.output.navigate(router);\n } else {\n finalResult = result;\n\n if (!result.completed) {\n if (result.output instanceof Error) {\n logger.error(result.output.toString());\n }\n\n restorePreviousLocation(router);\n }\n }\n\n return Promise.resolve(navigationCommandResult)\n .then(_ => router._dequeueInstruction(instructionCount + 1))\n .then(innerResult => finalResult || innerResult || result);\n};\n\nconst resolveInstruction = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n isInnerInstruction: boolean,\n router: AppRouter\n): PipelineResult => {\n instruction.resolve(result);\n\n let eventAggregator = router.events;\n let eventArgs = { instruction, result };\n if (!isInnerInstruction) {\n router.isNavigating = false;\n router.isExplicitNavigation = false;\n router.isExplicitNavigationBack = false;\n router.isNavigatingFirst = false;\n router.isNavigatingNew = false;\n router.isNavigatingRefresh = false;\n router.isNavigatingForward = false;\n router.isNavigatingBack = false;\n router.couldDeactivate = false;\n\n let eventName: string;\n\n if (result.output instanceof Error) {\n eventName = RouterEvent.Error;\n } else if (!result.completed) {\n eventName = RouterEvent.Canceled;\n } else {\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\n router.history.previousLocation = instruction.fragment + queryString;\n eventName = RouterEvent.Success;\n }\n\n eventAggregator.publish(eventName, eventArgs);\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\n } else {\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\n }\n\n return result;\n};\n\nconst restorePreviousLocation = (router: AppRouter): void => {\n let previousLocation = router.history.previousLocation;\n if (previousLocation) {\n router.navigate(previousLocation, { trigger: false, replace: true });\n } else if (router.fallbackRoute) {\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\n } else {\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\n }\n};\n","/**\n* The status of a Pipeline.\n*/\nexport const enum PipelineStatus {\n Completed = 'completed',\n Canceled = 'canceled',\n Rejected = 'rejected',\n Running = 'running'\n}\n","/**\n * A list of known router events used by the Aurelia router\n * to signal the pipeline has come to a certain state\n */\n// const enum is preserved in tsconfig\nexport const enum RouterEvent {\n Processing = 'router:navigation:processing',\n Error = 'router:navigation:error',\n Canceled = 'router:navigation:canceled',\n Complete = 'router:navigation:complete',\n Success = 'router:navigation:success',\n ChildComplete = 'router:navigation:child:complete'\n}\n","/**\n * Available pipeline slot names to insert interceptor into router pipeline\n */\n// const enum is preserved in tsconfig\nexport const enum PipelineSlotName {\n /**\n * Authorization slot. Invoked early in the pipeline,\n * before `canActivate` hook of incoming route\n */\n Authorize = 'authorize',\n /**\n * Pre-activation slot. Invoked early in the pipeline,\n * Invoked timing:\n * - after Authorization slot\n * - after canActivate hook on new view model\n * - before deactivate hook on old view model\n * - before activate hook on new view model\n */\n PreActivate = 'preActivate',\n /**\n * Pre-render slot. Invoked later in the pipeline\n * Invokcation timing:\n * - after activate hook on new view model\n * - before commit step on new navigation instruction\n */\n PreRender = 'preRender',\n /**\n * Post-render slot. Invoked last in the pipeline\n */\n PostRender = 'postRender'\n}\n"],"names":["LogManager.getLogger"],"mappings":";;;;;;AA2BA;;;AAGA,MAAa,qBAAqB;IA4DhC,YAAY,IAA+B;;;;QAT3C,SAAI,GAAwC,IAAI,CAAC;QAEj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QA0BjC;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\r\nimport { Router } from './router';\r\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\r\n\r\n/**\r\n * Initialization options for a navigation instruction\r\n */\r\nexport interface NavigationInstructionInit {\r\n fragment: string;\r\n queryString?: string;\r\n params?: Record;\r\n queryParams?: Record;\r\n config: RouteConfig;\r\n parentInstruction?: NavigationInstruction;\r\n previousInstruction?: NavigationInstruction;\r\n router: Router;\r\n options?: Object;\r\n plan?: Record;\r\n}\r\n\r\nexport interface ViewPortInstructionInit {\r\n name: string;\r\n strategy: ActivationStrategyType;\r\n moduleId: string;\r\n component: ViewPortComponent;\r\n}\r\n\r\n/**\r\n * Class used to represent an instruction during a navigation.\r\n */\r\nexport class NavigationInstruction {\r\n /**\r\n * The URL fragment.\r\n */\r\n fragment: string;\r\n\r\n /**\r\n * The query string.\r\n */\r\n queryString: string;\r\n\r\n /**\r\n * Parameters extracted from the route pattern.\r\n */\r\n params: any;\r\n\r\n /**\r\n * Parameters extracted from the query string.\r\n */\r\n queryParams: any;\r\n\r\n /**\r\n * The route config for the route matching this instruction.\r\n */\r\n config: RouteConfig;\r\n\r\n /**\r\n * The parent instruction, if this instruction was created by a child router.\r\n */\r\n parentInstruction: NavigationInstruction;\r\n\r\n parentCatchHandler: any;\r\n\r\n /**\r\n * The instruction being replaced by this instruction in the current router.\r\n */\r\n previousInstruction: NavigationInstruction;\r\n\r\n /**\r\n * viewPort instructions to used activation.\r\n */\r\n viewPortInstructions: Record;\r\n\r\n /**\r\n * The router instance.\r\n */\r\n router: Router;\r\n\r\n /**\r\n * Current built viewport plan of this nav instruction\r\n */\r\n plan: Record = null;\r\n\r\n options: Record = {};\r\n\r\n /**@internal */\r\n lifecycleArgs: LifecycleArguments;\r\n /**@internal */\r\n resolve?: (val?: any) => void;\r\n\r\n constructor(init: NavigationInstructionInit) {\r\n Object.assign(this, init);\r\n\r\n this.params = this.params || {};\r\n this.viewPortInstructions = {};\r\n\r\n let ancestorParams = [];\r\n let current: NavigationInstruction = this;\r\n do {\r\n let currentParams = Object.assign({}, current.params);\r\n if (current.config && current.config.hasChildRouter) {\r\n // remove the param for the injected child route segment\r\n delete currentParams[current.getWildCardName()];\r\n }\r\n\r\n ancestorParams.unshift(currentParams);\r\n current = current.parentInstruction;\r\n } while (current);\r\n\r\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\r\n this.lifecycleArgs = [allParams, this.config, this];\r\n }\r\n\r\n /**\r\n * Gets an array containing this instruction and all child instructions for the current navigation.\r\n */\r\n getAllInstructions(): Array {\r\n let instructions: NavigationInstruction[] = [this];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let key in viewPortInstructions) {\r\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\r\n if (childInstruction) {\r\n instructions.push(...childInstruction.getAllInstructions());\r\n }\r\n }\r\n\r\n return instructions;\r\n }\r\n\r\n /**\r\n * Gets an array containing the instruction and all child instructions for the previous navigation.\r\n * Previous instructions are no longer available after navigation completes.\r\n */\r\n getAllPreviousInstructions(): Array {\r\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\r\n }\r\n\r\n /**\r\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\r\n */\r\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(\r\n nameOrInitOptions: string | ViewPortInstructionInit,\r\n strategy?: ActivationStrategyType,\r\n moduleId?: string,\r\n component?: any\r\n ): /*ViewPortInstruction*/ any {\r\n\r\n let viewPortInstruction: ViewPortInstruction;\r\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\r\n const lifecycleArgs = this.lifecycleArgs;\r\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\r\n\r\n if (typeof nameOrInitOptions === 'string') {\r\n viewPortInstruction = {\r\n name: nameOrInitOptions,\r\n strategy: strategy,\r\n moduleId: moduleId,\r\n component: component,\r\n childRouter: component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n } else {\r\n viewPortInstruction = {\r\n name: viewPortName,\r\n strategy: nameOrInitOptions.strategy,\r\n component: nameOrInitOptions.component,\r\n moduleId: nameOrInitOptions.moduleId,\r\n childRouter: nameOrInitOptions.component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n }\r\n\r\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\r\n }\r\n\r\n /**\r\n * Gets the name of the route pattern's wildcard parameter, if applicable.\r\n */\r\n getWildCardName(): string {\r\n // todo: potential issue, or at least unsafe typings\r\n let configRoute = this.config.route as string;\r\n let wildcardIndex = configRoute.lastIndexOf('*');\r\n return configRoute.substr(wildcardIndex + 1);\r\n }\r\n\r\n /**\r\n * Gets the path and query string created by filling the route\r\n * pattern's wildcard parameter with the matching param.\r\n */\r\n getWildcardPath(): string {\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n let queryString = this.queryString;\r\n\r\n if (queryString) {\r\n path += '?' + queryString;\r\n }\r\n\r\n return path;\r\n }\r\n\r\n /**\r\n * Gets the instruction's base URL, accounting for wildcard route parameters.\r\n */\r\n getBaseUrl(): string {\r\n let $encodeURI = encodeURI;\r\n let fragment = decodeURI(this.fragment);\r\n\r\n if (fragment === '') {\r\n let nonEmptyRoute = this.router.routes.find(route => {\r\n return route.name === this.config.name &&\r\n route.route !== '';\r\n });\r\n if (nonEmptyRoute) {\r\n fragment = nonEmptyRoute.route as any;\r\n }\r\n }\r\n\r\n if (!this.params) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n\r\n if (!path) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\r\n }\r\n\r\n /**\r\n * Finalize a viewport instruction\r\n * @internal\r\n */\r\n _commitChanges(waitToSwap: boolean): Promise {\r\n let router = this.router;\r\n router.currentInstruction = this;\r\n\r\n const previousInstruction = this.previousInstruction;\r\n if (previousInstruction) {\r\n previousInstruction.config.navModel.isActive = false;\r\n }\r\n\r\n this.config.navModel.isActive = true;\r\n\r\n router.refreshNavigation();\r\n\r\n let loads: Promise[] = [];\r\n let delaySwaps: ISwapPlan[] = [];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let viewPort = router.viewPorts[viewPortName];\r\n\r\n if (!viewPort) {\r\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\r\n }\r\n\r\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\r\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\r\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n } else {\r\n if (waitToSwap) {\r\n delaySwaps.push({ viewPort, viewPortInstruction });\r\n }\r\n loads.push(\r\n viewPort\r\n .process(viewPortInstruction, waitToSwap)\r\n .then(() => childNavInstruction\r\n ? childNavInstruction._commitChanges(waitToSwap)\r\n : Promise.resolve()\r\n )\r\n );\r\n }\r\n } else {\r\n if (childNavInstruction) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n }\r\n }\r\n }\r\n\r\n return Promise\r\n .all(loads)\r\n .then(() => {\r\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\r\n return null;\r\n })\r\n .then(() => prune(this));\r\n }\r\n\r\n /**@internal */\r\n _updateTitle(): void {\r\n let router = this.router;\r\n let title = this._buildTitle(router.titleSeparator);\r\n if (title) {\r\n router.history.setTitle(title);\r\n }\r\n }\r\n\r\n /**@internal */\r\n _buildTitle(separator: string = ' | '): string {\r\n let title = '';\r\n let childTitles = [];\r\n let navModelTitle = this.config.navModel.title;\r\n let instructionRouter = this.router;\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n if (navModelTitle) {\r\n title = instructionRouter.transformTitle(navModelTitle);\r\n }\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\r\n\r\n if (child_nav_instruction) {\r\n let childTitle = child_nav_instruction._buildTitle(separator);\r\n if (childTitle) {\r\n childTitles.push(childTitle);\r\n }\r\n }\r\n }\r\n\r\n if (childTitles.length) {\r\n title = childTitles.join(separator) + (title ? separator : '') + title;\r\n }\r\n\r\n if (instructionRouter.title) {\r\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\r\n }\r\n\r\n return title;\r\n }\r\n}\r\n\r\nconst prune = (instruction: NavigationInstruction): void => {\r\n instruction.previousInstruction = null;\r\n instruction.plan = null;\r\n};\r\n\r\ninterface ISwapPlan {\r\n viewPort: ViewPort;\r\n viewPortInstruction: ViewPortInstruction;\r\n}\r\n","import { Router } from './router';\r\nimport { RouteConfig } from './interfaces';\r\n\r\n/**\r\n* Class for storing and interacting with a route's navigation settings.\r\n*/\r\nexport class NavModel {\r\n\r\n /**\r\n * True if this nav item is currently active.\r\n */\r\n isActive: boolean = false;\r\n\r\n /**\r\n * The title.\r\n */\r\n title: string = null;\r\n\r\n /**\r\n * This nav item's absolute href.\r\n */\r\n href: string = null;\r\n\r\n /**\r\n * This nav item's relative href.\r\n */\r\n relativeHref: string = null;\r\n\r\n /**\r\n * Data attached to the route at configuration time.\r\n */\r\n settings: any = {};\r\n\r\n /**\r\n * The route config.\r\n */\r\n config: RouteConfig = null;\r\n\r\n /**\r\n * The router associated with this navigation model.\r\n */\r\n router: Router;\r\n\r\n order: number | boolean;\r\n\r\n constructor(router: Router, relativeHref: string) {\r\n this.router = router;\r\n this.relativeHref = relativeHref;\r\n }\r\n\r\n /**\r\n * Sets the route's title and updates document.title.\r\n * If the a navigation is in progress, the change will be applied\r\n * to document.title when the navigation completes.\r\n *\r\n * @param title The new title.\r\n */\r\n setTitle(title: string): void {\r\n this.title = title;\r\n\r\n if (this.isActive) {\r\n this.router.updateTitle();\r\n }\r\n }\r\n}\r\n","import { RouteConfig } from './interfaces';\r\n\r\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\r\n if (!hasPushState && path[0] !== '#') {\r\n path = '#' + path;\r\n }\r\n\r\n if (hasPushState && absolute) {\r\n path = path.substring(1, path.length);\r\n }\r\n\r\n return path;\r\n}\r\n\r\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\r\n if (isAbsoluteUrl.test(fragment)) {\r\n return fragment;\r\n }\r\n\r\n let path = '';\r\n\r\n if (baseUrl.length && baseUrl[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n path += baseUrl;\r\n\r\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\r\n path = path.substring(0, path.length - 1);\r\n }\r\n\r\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\r\n}\r\n\r\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\r\n if (isRootedPath.test(fragment)) {\r\n return _normalizeAbsolutePath(fragment, hasPushState);\r\n }\r\n\r\n return _createRootedPath(fragment, baseUrl, hasPushState);\r\n}\r\n\r\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\r\n let routeConfigs = [];\r\n\r\n if (Array.isArray(config.route)) {\r\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\r\n let current = Object.assign({}, config);\r\n current.route = config.route[i];\r\n routeConfigs.push(current);\r\n }\r\n } else {\r\n routeConfigs.push(Object.assign({}, config));\r\n }\r\n\r\n return routeConfigs;\r\n}\r\n\r\nconst isRootedPath = /^#?\\//;\r\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\r\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\r\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\r\nimport { Router } from './router';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * Class used to configure a [[Router]] instance.\r\n *\r\n * @constructor\r\n */\r\nexport class RouterConfiguration {\r\n instructions: Array<(router: Router) => void> = [];\r\n options: {\r\n [key: string]: any;\r\n compareQueryParams?: boolean;\r\n root?: string;\r\n pushState?: boolean;\r\n hashChange?: boolean;\r\n silent?: boolean;\r\n } = {};\r\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\r\n title: string;\r\n titleSeparator: string;\r\n unknownRouteConfig: RouteConfigSpecifier;\r\n viewPortDefaults: Record;\r\n\r\n /**@internal */\r\n _fallbackRoute: string;\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\r\n *\r\n * @param name The name of the pipeline slot to insert the step into.\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\r\n if (step === null || step === undefined) {\r\n throw new Error('Pipeline step cannot be null or undefined.');\r\n }\r\n this.pipelineSteps.push({ name, step });\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\r\n }\r\n\r\n /**\r\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\r\n *\r\n * @param fragment The URL fragment to use as the navigation destination.\r\n * @chainable\r\n */\r\n fallbackRoute(fragment: string): RouterConfiguration {\r\n this._fallbackRoute = fragment;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps one or more routes to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\r\n if (Array.isArray(route)) {\r\n route.forEach(r => this.map(r));\r\n return this;\r\n }\r\n\r\n return this.mapRoute(route);\r\n }\r\n\r\n /**\r\n * Configures defaults to use for any view ports.\r\n *\r\n * @param viewPortConfig a view port configuration object to use as a\r\n * default, of the form { viewPortName: { moduleId } }.\r\n * @chainable\r\n */\r\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\r\n this.viewPortDefaults = viewPortConfig;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps a single route to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n mapRoute(config: RouteConfig): RouterConfiguration {\r\n this.instructions.push(router => {\r\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\r\n\r\n let navModel;\r\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\r\n let routeConfig = routeConfigs[i];\r\n routeConfig.settings = routeConfig.settings || {};\r\n if (!navModel) {\r\n navModel = router.createNavModel(routeConfig);\r\n }\r\n\r\n router.addRoute(routeConfig, navModel);\r\n }\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\r\n *\r\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\r\n * [[NavigationInstruction]] and selects a moduleId to load.\r\n * @chainable\r\n */\r\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\r\n this.unknownRouteConfig = config;\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current configuration to the specified [[Router]].\r\n *\r\n * @param router The [[Router]] to apply the configuration to.\r\n */\r\n exportToRouter(router: Router): void {\r\n let instructions = this.instructions;\r\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\r\n instructions[i](router);\r\n }\r\n\r\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\r\n\r\n if (title) {\r\n router.title = title;\r\n }\r\n\r\n if (titleSeparator) {\r\n router.titleSeparator = titleSeparator;\r\n }\r\n\r\n if (unknownRouteConfig) {\r\n router.handleUnknownRoutes(unknownRouteConfig);\r\n }\r\n\r\n if (_fallbackRoute) {\r\n router.fallbackRoute = _fallbackRoute;\r\n }\r\n\r\n if (viewPortDefaults) {\r\n router.useViewPortDefaults(viewPortDefaults);\r\n }\r\n\r\n Object.assign(router.options, this.options);\r\n\r\n let pipelineSteps = this.pipelineSteps;\r\n let pipelineStepCount = pipelineSteps.length;\r\n if (pipelineStepCount) {\r\n if (!router.isRoot) {\r\n throw new Error('Pipeline steps can only be added to the root router');\r\n }\r\n\r\n let pipelineProvider = router.pipelineProvider;\r\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\r\n let { name, step } = pipelineSteps[i];\r\n pipelineProvider.addStep(name, step);\r\n }\r\n }\r\n }\r\n}\r\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { NavigationResult, RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): NavigationResult {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): NavigationResult {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\r\n\r\n/**@internal exported for unit testing */\r\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\r\n let index = -1;\r\n const next: Next = function() {\r\n index++;\r\n\r\n if (index < steps.length) {\r\n let currentStep = steps[index];\r\n\r\n try {\r\n return currentStep(instruction, next);\r\n } catch (e) {\r\n return next.reject(e);\r\n }\r\n } else {\r\n return next.complete();\r\n }\r\n } as Next;\r\n\r\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\r\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\r\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\r\n\r\n return next;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\r\n return (output: any) => Promise\r\n .resolve({\r\n status,\r\n output,\r\n completed: status === PipelineStatus.Completed\r\n });\r\n};\r\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { createNextFn } from './next';\r\n\r\n/**\r\n * The class responsible for managing and processing the navigation pipeline.\r\n */\r\nexport class Pipeline {\r\n /**\r\n * The pipeline steps. And steps added via addStep will be converted to a function\r\n * The actualy running functions with correct step contexts of this pipeline\r\n */\r\n steps: StepRunnerFunction[] = [];\r\n\r\n /**\r\n * Adds a step to the pipeline.\r\n *\r\n * @param step The pipeline step.\r\n */\r\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\r\n let run;\r\n\r\n if (typeof step === 'function') {\r\n run = step;\r\n } else if (typeof step.getSteps === 'function') {\r\n // getSteps is to enable support open slots\r\n // where devs can add multiple steps into the same slot name\r\n let steps = step.getSteps();\r\n for (let i = 0, l = steps.length; i < l; i++) {\r\n this.addStep(steps[i]);\r\n }\r\n\r\n return this;\r\n } else {\r\n run = (step as PipelineStep).run.bind(step);\r\n }\r\n\r\n this.steps.push(run);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Runs the pipeline.\r\n *\r\n * @param instruction The navigation instruction to process.\r\n */\r\n run(instruction: NavigationInstruction): Promise {\r\n const nextFn = createNextFn(instruction, this.steps);\r\n return nextFn();\r\n }\r\n}\r\n","import { NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-history' {\r\n interface NavigationOptions {\r\n useAppRouter?: boolean;\r\n }\r\n}\r\n\r\n/**\r\n* When a navigation command is encountered, the current navigation\r\n* will be cancelled and control will be passed to the navigation\r\n* command so it can determine the correct action.\r\n*/\r\nexport interface NavigationCommand {\r\n navigate: (router: Router) => void;\r\n /**@internal */\r\n shouldContinueProcessing?: boolean;\r\n /**@internal */\r\n setRouter?: (router: Router) => void;\r\n}\r\n\r\n/**\r\n* Determines if the provided object is a navigation command.\r\n* A navigation command is anything with a navigate method.\r\n*\r\n* @param obj The object to check.\r\n*/\r\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\r\n return obj && typeof obj.navigate === 'function';\r\n}\r\n\r\n/**\r\n* Used during the activation lifecycle to cause a redirect.\r\n*/\r\nexport class Redirect implements NavigationCommand {\r\n\r\n url: string;\r\n /**@internal */\r\n options: NavigationOptions;\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n private router: Router;\r\n\r\n /**\r\n * @param url The URL fragment to use as the navigation destination.\r\n * @param options The navigation options.\r\n */\r\n constructor(url: string, options: NavigationOptions = {}) {\r\n this.url = url;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigate(this.url, this.options);\r\n }\r\n}\r\n\r\n/**\r\n * Used during the activation lifecycle to cause a redirect to a named route.\r\n */\r\nexport class RedirectToRoute implements NavigationCommand {\r\n\r\n route: string;\r\n params: any;\r\n /**@internal */\r\n options: NavigationOptions;\r\n\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n /**@internal */\r\n router: Router;\r\n\r\n /**\r\n * @param route The name of the route.\r\n * @param params The parameters to be sent to the activation method.\r\n * @param options The options to use for navigation.\r\n */\r\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\r\n this.route = route;\r\n this.params = params;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\r\n }\r\n}\r\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\r\n\r\ntype ViewPortPlansRecord = Record;\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport function _buildNavigationPlan(\r\n instruction: NavigationInstruction,\r\n forceLifecycleMinimum?: boolean\r\n): Promise {\r\n let config = instruction.config;\r\n\r\n if ('redirect' in config) {\r\n return buildRedirectPlan(instruction);\r\n }\r\n\r\n const prevInstruction = instruction.previousInstruction;\r\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\r\n\r\n if (prevInstruction) {\r\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\r\n }\r\n\r\n // first navigation, only need to prepare a few information for each viewport plan\r\n const viewPortPlans: ViewPortPlansRecord = {};\r\n let viewPortConfigs = config.viewPorts;\r\n for (let viewPortName in viewPortConfigs) {\r\n let viewPortConfig = viewPortConfigs[viewPortName];\r\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n viewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n strategy: InternalActivationStrategy.Replace,\r\n config: viewPortConfig\r\n };\r\n }\r\n\r\n return Promise.resolve(viewPortPlans);\r\n}\r\n\r\n/**\r\n * Build redirect plan based on config of a navigation instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\r\n const config = instruction.config;\r\n const router = instruction.router;\r\n return router\r\n ._createNavigationInstruction(config.redirect)\r\n .then(redirectInstruction => {\r\n\r\n const params: Record = {};\r\n const originalInstructionParams = instruction.params;\r\n const redirectInstructionParams = redirectInstruction.params;\r\n\r\n for (let key in redirectInstructionParams) {\r\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\r\n let val = redirectInstructionParams[key];\r\n if (typeof val === 'string' && val[0] === ':') {\r\n val = val.slice(1);\r\n // And if that param is found on the original instruction then use it\r\n if (val in originalInstructionParams) {\r\n params[key] = originalInstructionParams[val];\r\n }\r\n } else {\r\n params[key] = redirectInstructionParams[key];\r\n }\r\n }\r\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\r\n\r\n // Special handling for child routes\r\n for (let key in originalInstructionParams) {\r\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\r\n }\r\n\r\n let queryString = instruction.queryString;\r\n if (queryString) {\r\n redirectLocation += '?' + queryString;\r\n }\r\n\r\n return Promise.resolve(new Redirect(redirectLocation));\r\n });\r\n};\r\n\r\n/**\r\n * @param viewPortPlans the Plan record that holds information about built plans\r\n * @internal exported for unit testing\r\n */\r\nexport const buildTransitionPlans = (\r\n currentInstruction: NavigationInstruction,\r\n previousInstruction: NavigationInstruction,\r\n defaultViewPortConfigs: Record,\r\n forceLifecycleMinimum?: boolean\r\n): Promise => {\r\n\r\n let viewPortPlans: ViewPortPlansRecord = {};\r\n let newInstructionConfig = currentInstruction.config;\r\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\r\n let pending: Promise[] = [];\r\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\r\n\r\n for (let viewPortName in previousViewPortInstructions) {\r\n\r\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\r\n const prevViewPortComponent = prevViewPortInstruction.component;\r\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\r\n\r\n // if this is invoked on a viewport without any changes, based on new url,\r\n // newViewPortConfig will be the existing viewport instruction\r\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\r\n ? newInstructionViewPortConfigs[viewPortName]\r\n : prevViewPortInstruction;\r\n\r\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n\r\n const viewPortActivationStrategy = determineActivationStrategy(\r\n currentInstruction,\r\n prevViewPortInstruction,\r\n nextViewPortConfig,\r\n hasNewParams,\r\n forceLifecycleMinimum\r\n );\r\n const viewPortPlan = viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n // ViewPortInstruction can quack like a RouteConfig\r\n config: nextViewPortConfig as RouteConfig,\r\n prevComponent: prevViewPortComponent,\r\n prevModuleId: prevViewPortInstruction.moduleId,\r\n strategy: viewPortActivationStrategy\r\n } as ViewPortPlan;\r\n\r\n // recursively build nav plans for all existing child routers/viewports of this viewport\r\n // this is possible because existing child viewports and routers already have necessary information\r\n // to process the wildcard path from parent instruction\r\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\r\n const path = currentInstruction.getWildcardPath();\r\n const task: Promise = prevViewPortInstruction\r\n .childRouter\r\n ._createNavigationInstruction(path, currentInstruction)\r\n .then((childInstruction: NavigationInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(\r\n childInstruction,\r\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\r\n // if so, can just use local variable viewPortPlanStrategy\r\n // there could be user code modifying viewport plan during _createNavigationInstruction?\r\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\r\n )\r\n .then(childPlan => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n // for bluebird ?\r\n return null;\r\n });\r\n });\r\n\r\n pending.push(task);\r\n }\r\n }\r\n\r\n return Promise.all(pending).then(() => viewPortPlans);\r\n};\r\n\r\n/**\r\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const determineActivationStrategy = (\r\n currentNavInstruction: NavigationInstruction,\r\n prevViewPortInstruction: ViewPortInstruction,\r\n newViewPortConfig: RouteConfig | ViewPortInstruction,\r\n // indicates whether there is difference between old and new url params\r\n hasNewParams: boolean,\r\n forceLifecycleMinimum?: boolean\r\n): ActivationStrategyType => {\r\n\r\n let newInstructionConfig = currentNavInstruction.config;\r\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\r\n let viewPortPlanStrategy: ActivationStrategyType;\r\n\r\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\r\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\r\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\r\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\r\n } else if (newInstructionConfig.activationStrategy) {\r\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\r\n } else if (hasNewParams || forceLifecycleMinimum) {\r\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\r\n } else {\r\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\r\n }\r\n return viewPortPlanStrategy;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\r\n let prevParams = prev.params;\r\n let nextParams = next.params;\r\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\r\n\r\n for (let key in nextParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!next.options.compareQueryParams) {\r\n return false;\r\n }\r\n\r\n let prevQueryParams = prev.queryParams;\r\n let nextQueryParams = next.queryParams;\r\n for (let key in nextQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n};\r\n","import { Next } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\n\r\n/**\r\n * Transform a navigation instruction into viewport plan record object,\r\n * or a redirect request if user viewmodel demands\r\n */\r\nexport class BuildNavigationPlanStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return _buildNavigationPlan(navigationInstruction)\r\n .then(plan => {\r\n if (plan instanceof Redirect) {\r\n return next.cancel(plan);\r\n }\r\n navigationInstruction.plan = plan;\r\n return next();\r\n })\r\n .catch(next.cancel);\r\n }\r\n}\r\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\nimport { InternalActivationStrategy } from './activation-strategy';\r\nimport { RouteLoader } from './route-loader';\r\n\r\n/**\r\n * Loading plan calculated based on a navigration-instruction and a viewport plan\r\n */\r\ninterface ILoadingPlan {\r\n viewPortPlan: ViewPortPlan;\r\n navigationInstruction: NavigationInstruction;\r\n}\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadNewRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction\r\n): Promise => {\r\n let loadingPlans = determineLoadingPlans(navigationInstruction);\r\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\r\n routeLoader,\r\n loadingPlan.navigationInstruction,\r\n loadingPlan.viewPortPlan\r\n ));\r\n\r\n return Promise.all(loadPromises);\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const determineLoadingPlans = (\r\n navigationInstruction: NavigationInstruction,\r\n loadingPlans: ILoadingPlan[] = []\r\n): ILoadingPlan[] => {\r\n let viewPortPlans: Record = navigationInstruction.plan;\r\n\r\n for (let viewPortName in viewPortPlans) {\r\n let viewPortPlan = viewPortPlans[viewPortName];\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\r\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\r\n\r\n if (childNavInstruction) {\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n } else {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortName,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: viewPortPlan.prevModuleId,\r\n component: viewPortPlan.prevComponent\r\n }) as ViewPortInstruction;\r\n\r\n if (childNavInstruction) {\r\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n }\r\n }\r\n\r\n return loadingPlans;\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n viewPortPlan: ViewPortPlan\r\n): Promise => {\r\n let planConfig = viewPortPlan.config;\r\n let moduleId = planConfig ? planConfig.moduleId : null;\r\n\r\n return loadComponent(routeLoader, navigationInstruction, planConfig)\r\n .then((component) => {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortPlan.name,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: moduleId,\r\n component: component\r\n }) as ViewPortInstruction;\r\n\r\n let childRouter = component.childRouter;\r\n if (childRouter) {\r\n let path = navigationInstruction.getWildcardPath();\r\n\r\n return childRouter\r\n ._createNavigationInstruction(path, navigationInstruction)\r\n .then((childInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(childInstruction)\r\n .then((childPlan) => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n viewPortInstruction.childNavigationInstruction = childInstruction;\r\n\r\n return loadNewRoute(routeLoader, childInstruction);\r\n });\r\n });\r\n }\r\n // ts complains without this, though they are same\r\n return void 0;\r\n });\r\n};\r\n\r\n/**\r\n * Load a routed-component based on navigation instruction and route config\r\n * @internal exported for unit testing only\r\n */\r\nexport const loadComponent = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n config: RouteConfig\r\n): Promise => {\r\n let router = navigationInstruction.router;\r\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\r\n\r\n return Promise.resolve()\r\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\r\n .then(\r\n /**\r\n * @param component an object carrying information about loaded route\r\n * typically contains information about view model, childContainer, view and router\r\n */\r\n (component: ViewPortComponent) => {\r\n let { viewModel, childContainer } = component;\r\n component.router = router;\r\n component.config = config;\r\n\r\n if ('configureRouter' in viewModel) {\r\n let childRouter = childContainer.getChildRouter();\r\n component.childRouter = childRouter;\r\n\r\n return childRouter\r\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\r\n .then(() => component);\r\n }\r\n\r\n return component;\r\n }\r\n );\r\n};\r\n","import { RouteConfig } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Abstract class that is responsible for loading view / view model from a route config\r\n * The default implementation can be found in `aurelia-templating-router`\r\n */\r\nexport class RouteLoader {\r\n /**\r\n * Load a route config based on its viewmodel / view configuration\r\n */\r\n // return typing: return typings used to be never\r\n // as it was a throw. Changing it to Promise should not cause any issues\r\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\r\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\r\n }\r\n}\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { loadNewRoute } from './utilities-route-loading';\r\nimport { RouteLoader } from './route-loader';\r\n/**\r\n * A pipeline step responsible for loading a route config of a navigation instruction\r\n */\r\nexport class LoadRouteStep {\r\n /**@internal */\r\n static inject() { return [RouteLoader]; }\r\n /**\r\n * Route loader isntance that will handle loading route config\r\n * @internal\r\n */\r\n routeLoader: RouteLoader;\r\n constructor(routeLoader: RouteLoader) {\r\n this.routeLoader = routeLoader;\r\n }\r\n /**\r\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\r\n */\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return loadNewRoute(this.routeLoader, navigationInstruction)\r\n .then(next, next.cancel);\r\n }\r\n}\r\n","import { NavigationInstruction } from './navigation-instruction';\r\n\r\n/**\r\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\r\n */\r\nexport class CommitChangesStep {\r\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\r\n return navigationInstruction\r\n ._commitChanges(/*wait to swap?*/ true)\r\n .then(() => {\r\n navigationInstruction._updateTitle();\r\n return next();\r\n });\r\n }\r\n}\r\n","/**\r\n * An optional interface describing the available activation strategies.\r\n * @internal Used internally.\r\n */\r\nexport const enum InternalActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n NoChange = 'no-change',\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n InvokeLifecycle = 'invoke-lifecycle',\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n Replace = 'replace'\r\n}\r\n\r\n/**\r\n * The strategy to use when activating modules during navigation.\r\n */\r\n// kept for compat reason\r\nexport const activationStrategy: ActivationStrategy = {\r\n noChange: InternalActivationStrategy.NoChange,\r\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\r\n replace: InternalActivationStrategy.Replace\r\n};\r\n\r\n/**\r\n * An optional interface describing the available activation strategies.\r\n */\r\nexport interface ActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n noChange: 'no-change';\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n invokeLifecycle: 'invoke-lifecycle';\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n replace: 'replace';\r\n}\r\n\r\n/**\r\n * Enum like type for activation strategy built-in values\r\n */\r\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\r\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { activationStrategy } from './activation-strategy';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Recursively find list of deactivate-able view models\r\n * and invoke the either 'canDeactivate' or 'deactivate' on each\r\n * @internal exported for unit testing\r\n */\r\nexport const processDeactivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canDeactivate' | 'deactivate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let plan: Record = navigationInstruction.plan;\r\n let infos = findDeactivatable(plan, callbackName);\r\n let i = infos.length; // query from inside out\r\n\r\n function inspect(val: any): Promise {\r\n if (ignoreResult || shouldContinue(val)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n if (i--) {\r\n try {\r\n let viewModel = infos[i];\r\n let result = viewModel[callbackName](navigationInstruction);\r\n return processPotential(result, inspect, next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n navigationInstruction.router.couldDeactivate = true;\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\n/**\r\n * Recursively find and returns a list of deactivate-able view models\r\n * @internal exported for unit testing\r\n */\r\nexport const findDeactivatable = (\r\n plan: Record,\r\n callbackName: string,\r\n list: IActivatableInfo[] = []\r\n): any[] => {\r\n for (let viewPortName in plan) {\r\n let viewPortPlan = plan[viewPortName];\r\n let prevComponent = viewPortPlan.prevComponent;\r\n\r\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\r\n && prevComponent\r\n ) {\r\n let viewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in viewModel) {\r\n list.push(viewModel);\r\n }\r\n }\r\n\r\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n } else if (viewPortPlan.childNavigationInstruction) {\r\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\r\n }\r\n }\r\n\r\n return list;\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const addPreviousDeactivatable = (\r\n component: ViewPortComponent,\r\n callbackName: string,\r\n list: IActivatableInfo[]\r\n): void => {\r\n let childRouter = component.childRouter;\r\n\r\n if (childRouter && childRouter.currentInstruction) {\r\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let prevComponent = viewPortInstruction.component;\r\n let prevViewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in prevViewModel) {\r\n list.push(prevViewModel);\r\n }\r\n\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const processActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let infos = findActivatable(navigationInstruction, callbackName);\r\n let length = infos.length;\r\n let i = -1; // query from top down\r\n\r\n function inspect(val: any, router: Router): Promise {\r\n if (ignoreResult || shouldContinue(val, router)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n i++;\r\n\r\n if (i < length) {\r\n try {\r\n let current = infos[i];\r\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\r\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\ninterface IActivatableInfo {\r\n viewModel: any;\r\n lifecycleArgs: LifecycleArguments;\r\n router: Router;\r\n}\r\n\r\n/**\r\n * Find list of activatable view model and add to list (3rd parameter)\r\n * @internal exported for unit testing\r\n */\r\nexport const findActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n list: IActivatableInfo[] = [],\r\n router?: Router\r\n): IActivatableInfo[] => {\r\n let plan: Record = navigationInstruction.plan;\r\n\r\n Object\r\n .keys(plan)\r\n .forEach((viewPortName) => {\r\n let viewPortPlan = plan[viewPortName];\r\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\r\n let viewPortComponent = viewPortInstruction.component;\r\n let viewModel = viewPortComponent.viewModel;\r\n\r\n if (\r\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\r\n || viewPortPlan.strategy === activationStrategy.replace\r\n )\r\n && callbackName in viewModel\r\n ) {\r\n list.push({\r\n viewModel,\r\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\r\n router\r\n });\r\n }\r\n\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (childNavInstruction) {\r\n findActivatable(\r\n childNavInstruction,\r\n callbackName,\r\n list,\r\n viewPortComponent.childRouter || router\r\n );\r\n }\r\n });\r\n\r\n return list;\r\n};\r\n\r\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\r\n if (output instanceof Error) {\r\n return false;\r\n }\r\n\r\n if (isNavigationCommand(output)) {\r\n if (typeof output.setRouter === 'function') {\r\n output.setRouter(router);\r\n }\r\n\r\n return !!output.shouldContinueProcessing;\r\n }\r\n\r\n if (output === undefined) {\r\n return true;\r\n }\r\n\r\n return output;\r\n};\r\n\r\n/**\r\n * A basic interface for an Observable type\r\n */\r\nexport interface IObservable {\r\n subscribe(sub?: IObservableConfig): ISubscription;\r\n}\r\n\r\nexport interface IObservableConfig {\r\n next(): void;\r\n error(err?: any): void;\r\n complete(): void;\r\n}\r\n\r\n/**\r\n * A basic interface for a Subscription to an Observable\r\n */\r\ninterface ISubscription {\r\n unsubscribe(): void;\r\n}\r\n\r\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\r\n\r\n/**\r\n * wraps a subscription, allowing unsubscribe calls even if\r\n * the first value comes synchronously\r\n */\r\nclass SafeSubscription {\r\n\r\n private _subscribed: boolean;\r\n private _subscription: ISubscription;\r\n\r\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\r\n this._subscribed = true;\r\n this._subscription = subscriptionFunc(this);\r\n\r\n if (!this._subscribed) {\r\n this.unsubscribe();\r\n }\r\n }\r\n\r\n get subscribed(): boolean {\r\n return this._subscribed;\r\n }\r\n\r\n unsubscribe(): void {\r\n if (this._subscribed && this._subscription) {\r\n this._subscription.unsubscribe();\r\n }\r\n\r\n this._subscribed = false;\r\n }\r\n}\r\n\r\n/**\r\n * A function to process return value from `activate`/`canActivate` steps\r\n * Supports observable/promise\r\n *\r\n * For observable, resolve at first next() or on complete()\r\n */\r\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\r\n // if promise like\r\n if (obj && typeof obj.then === 'function') {\r\n return Promise.resolve(obj).then(resolve).catch(reject);\r\n }\r\n\r\n // if observable\r\n if (obj && typeof obj.subscribe === 'function') {\r\n let obs: IObservable = obj;\r\n return new SafeSubscription(sub => obs.subscribe({\r\n next() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n },\r\n error(error) {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n reject(error);\r\n }\r\n },\r\n complete() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n }\r\n }));\r\n }\r\n\r\n // else just resolve\r\n try {\r\n return resolve(obj);\r\n } catch (error) {\r\n return reject(error);\r\n }\r\n};\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { processDeactivatable, processActivatable } from './utilities-activation';\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\r\n */\r\nexport class CanDeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\r\n */\r\nexport class CanActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'canActivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\r\n */\r\nexport class DeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\r\n */\r\nexport class ActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'activate', next, true);\r\n }\r\n}\r\n","import { Container } from 'aurelia-dependency-injection';\r\nimport { Pipeline } from './pipeline';\r\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\r\nimport { LoadRouteStep } from './step-load-route';\r\nimport { CommitChangesStep } from './step-commit-changes';\r\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\r\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\r\n */\r\nclass PipelineSlot implements IPipelineSlot {\r\n\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n slotName: string;\r\n /**@internal */\r\n slotAlias?: string;\r\n\r\n steps: (Function | PipelineStep)[] = [];\r\n\r\n constructor(container: Container, name: string, alias?: string) {\r\n this.container = container;\r\n this.slotName = name;\r\n this.slotAlias = alias;\r\n }\r\n\r\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\r\n return this.steps.map(x => this.container.get(x));\r\n }\r\n}\r\n\r\n/**\r\n * Class responsible for creating the navigation pipeline.\r\n */\r\nexport class PipelineProvider {\r\n\r\n /**@internal */\r\n static inject() { return [Container]; }\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n steps: (Function | PipelineSlot)[];\r\n\r\n constructor(container: Container) {\r\n this.container = container;\r\n this.steps = [\r\n BuildNavigationPlanStep,\r\n CanDeactivatePreviousStep, // optional\r\n LoadRouteStep,\r\n createPipelineSlot(container, PipelineSlotName.Authorize),\r\n CanActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\r\n // NOTE: app state changes start below - point of no return\r\n DeactivatePreviousStep, // optional\r\n ActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\r\n CommitChangesStep,\r\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\r\n ];\r\n }\r\n\r\n /**\r\n * Create the navigation pipeline.\r\n */\r\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\r\n let pipeline = new Pipeline();\r\n this.steps.forEach(step => {\r\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\r\n pipeline.addStep(this.container.get(step));\r\n }\r\n });\r\n return pipeline;\r\n }\r\n\r\n /**@internal */\r\n _findStep(name: string): PipelineSlot {\r\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\r\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\r\n }\r\n\r\n /**\r\n * Adds a step into the pipeline at a known slot location.\r\n */\r\n addStep(name: string, step: PipelineStep | Function): void {\r\n let found = this._findStep(name);\r\n if (found) {\r\n let slotSteps = found.steps;\r\n // prevent duplicates\r\n if (!slotSteps.includes(step)) {\r\n slotSteps.push(step);\r\n }\r\n } else {\r\n throw new Error(`Invalid pipeline slot name: ${name}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Removes a step from a slot in the pipeline\r\n */\r\n removeStep(name: string, step: PipelineStep): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n let slotSteps = slot.steps;\r\n slotSteps.splice(slotSteps.indexOf(step), 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clears all steps from a slot in the pipeline\r\n * @internal\r\n */\r\n _clearSteps(name: string = ''): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n slot.steps = [];\r\n }\r\n }\r\n\r\n /**\r\n * Resets all pipeline slots\r\n */\r\n reset(): void {\r\n this._clearSteps(PipelineSlotName.Authorize);\r\n this._clearSteps(PipelineSlotName.PreActivate);\r\n this._clearSteps(PipelineSlotName.PreRender);\r\n this._clearSteps(PipelineSlotName.PostRender);\r\n }\r\n}\r\n\r\n/**@internal */\r\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\r\n return new PipelineSlot(container, name, alias);\r\n};\r\n","import * as LogManager from 'aurelia-logging';\r\nimport { Container } from 'aurelia-dependency-injection';\r\nimport { History, NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\nimport { PipelineProvider } from './pipeline-provider';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\r\nimport { RouterEvent } from './router-event';\r\nimport { RouterConfiguration } from './router-configuration';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-dependency-injection' {\r\n interface Container {\r\n viewModel?: any;\r\n }\r\n}\r\n\r\nconst logger = LogManager.getLogger('app-router');\r\n\r\n/**\r\n * The main application router.\r\n */\r\nexport class AppRouter extends Router {\r\n\r\n /**@internal */\r\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\r\n\r\n events: EventAggregator;\r\n /**@internal */\r\n maxInstructionCount: number;\r\n /**@internal */\r\n _queue: NavigationInstruction[];\r\n /**@internal */\r\n isActive: boolean;\r\n\r\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\r\n super(container, history); // Note the super will call reset internally.\r\n this.pipelineProvider = pipelineProvider;\r\n this.events = events;\r\n }\r\n\r\n /**\r\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\r\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\r\n */\r\n reset(): void {\r\n super.reset();\r\n this.maxInstructionCount = 10;\r\n if (!this._queue) {\r\n this._queue = [];\r\n } else {\r\n this._queue.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Loads the specified URL.\r\n *\r\n * @param url The URL fragment to load.\r\n */\r\n loadUrl(url: string): Promise {\r\n return this\r\n ._createNavigationInstruction(url)\r\n .then(instruction => this._queueInstruction(instruction))\r\n .catch(error => {\r\n logger.error(error);\r\n restorePreviousLocation(this);\r\n });\r\n }\r\n\r\n /**\r\n * Registers a viewPort to be used as a rendering target for activated routes.\r\n *\r\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\r\n * @param name The name of the viewPort. 'default' if unspecified.\r\n */\r\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\r\n // having strong typing without changing public API\r\n const $viewPort: ViewPort = viewPort;\r\n super.registerViewPort($viewPort, name);\r\n\r\n // beside adding viewport to the registry of this instance\r\n // AppRouter also configure routing/history to start routing functionality\r\n // There are situation where there are more than 1 element at root view\r\n // in that case, still only activate once via the following guard\r\n if (!this.isActive) {\r\n const viewModel = this._findViewModel($viewPort);\r\n if ('configureRouter' in viewModel) {\r\n // If there are more than one element at root view\r\n // use this flag to guard against configure method being invoked multiple times\r\n // this flag is set inside method configure\r\n if (!this.isConfigured) {\r\n // replace the real resolve with a noop to guarantee that any action in base class Router\r\n // won't resolve the configurePromise prematurely\r\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\r\n this._resolveConfiguredPromise = () => {/**/};\r\n return this\r\n .configure(config =>\r\n Promise\r\n .resolve(viewModel.configureRouter(config, this))\r\n // an issue with configure interface. Should be fixed there\r\n // todo: fix this via configure interface in router\r\n .then(() => config) as any\r\n )\r\n .then(() => {\r\n this.activate();\r\n resolveConfiguredPromise();\r\n });\r\n }\r\n } else {\r\n this.activate();\r\n }\r\n }\r\n // when a viewport is added dynamically to a root view that is already activated\r\n // just process the navigation instruction\r\n else {\r\n this._dequeueInstruction();\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\r\n *\r\n * @params options The set of options to activate the router with.\r\n */\r\n activate(options?: NavigationOptions): void {\r\n if (this.isActive) {\r\n return;\r\n }\r\n\r\n this.isActive = true;\r\n // route handler property is responsible for handling url change\r\n // the interface of aurelia-history isn't clear on this perspective\r\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\r\n this.history.activate(this.options);\r\n this._dequeueInstruction();\r\n }\r\n\r\n /**\r\n * Deactivates the router.\r\n */\r\n deactivate(): void {\r\n this.isActive = false;\r\n this.history.deactivate();\r\n }\r\n\r\n /**@internal */\r\n _queueInstruction(instruction: NavigationInstruction): Promise {\r\n return new Promise((resolve) => {\r\n instruction.resolve = resolve;\r\n this._queue.unshift(instruction);\r\n this._dequeueInstruction();\r\n });\r\n }\r\n\r\n /**@internal */\r\n _dequeueInstruction(instructionCount: number = 0): Promise {\r\n return Promise.resolve().then(() => {\r\n if (this.isNavigating && !instructionCount) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n let instruction = this._queue.shift();\r\n this._queue.length = 0;\r\n\r\n if (!instruction) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n this.isNavigating = true;\r\n\r\n let navtracker: number = this.history.getState('NavigationTracker');\r\n let currentNavTracker = this.currentNavigationTracker;\r\n\r\n if (!navtracker && !currentNavTracker) {\r\n this.isNavigatingFirst = true;\r\n this.isNavigatingNew = true;\r\n } else if (!navtracker) {\r\n this.isNavigatingNew = true;\r\n } else if (!currentNavTracker) {\r\n this.isNavigatingRefresh = true;\r\n } else if (currentNavTracker < navtracker) {\r\n this.isNavigatingForward = true;\r\n } else if (currentNavTracker > navtracker) {\r\n this.isNavigatingBack = true;\r\n } if (!navtracker) {\r\n navtracker = Date.now();\r\n this.history.setState('NavigationTracker', navtracker);\r\n }\r\n this.currentNavigationTracker = navtracker;\r\n\r\n instruction.previousInstruction = this.currentInstruction;\r\n\r\n let maxInstructionCount = this.maxInstructionCount;\r\n\r\n if (!instructionCount) {\r\n this.events.publish(RouterEvent.Processing, { instruction });\r\n } else if (instructionCount === maxInstructionCount - 1) {\r\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\r\n restorePreviousLocation(this);\r\n return this._dequeueInstruction(instructionCount + 1);\r\n } else if (instructionCount > maxInstructionCount) {\r\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\r\n }\r\n\r\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\r\n\r\n return pipeline\r\n .run(instruction)\r\n .then(result => processResult(instruction, result, instructionCount, this))\r\n .catch(error => {\r\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\r\n })\r\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\r\n });\r\n }\r\n\r\n /**@internal */\r\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\r\n if (this.container.viewModel) {\r\n return this.container.viewModel;\r\n }\r\n\r\n if (viewPort.container) {\r\n let container = viewPort.container;\r\n\r\n while (container) {\r\n if (container.viewModel) {\r\n this.container.viewModel = container.viewModel;\r\n return container.viewModel;\r\n }\r\n\r\n container = container.parent;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n\r\nconst processResult = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n instructionCount: number,\r\n router: AppRouter\r\n): Promise => {\r\n if (!(result && 'completed' in result && 'output' in result)) {\r\n result = result || {} as PipelineResult;\r\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\r\n }\r\n\r\n let finalResult: PipelineResult = null;\r\n let navigationCommandResult = null;\r\n if (isNavigationCommand(result.output)) {\r\n navigationCommandResult = result.output.navigate(router);\r\n } else {\r\n finalResult = result;\r\n\r\n if (!result.completed) {\r\n if (result.output instanceof Error) {\r\n logger.error(result.output.toString());\r\n }\r\n\r\n restorePreviousLocation(router);\r\n }\r\n }\r\n\r\n return Promise.resolve(navigationCommandResult)\r\n .then(_ => router._dequeueInstruction(instructionCount + 1))\r\n .then(innerResult => finalResult || innerResult || result);\r\n};\r\n\r\nconst resolveInstruction = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n isInnerInstruction: boolean,\r\n router: AppRouter\r\n): PipelineResult => {\r\n instruction.resolve(result);\r\n\r\n let eventAggregator = router.events;\r\n let eventArgs = { instruction, result };\r\n if (!isInnerInstruction) {\r\n router.isNavigating = false;\r\n router.isExplicitNavigation = false;\r\n router.isExplicitNavigationBack = false;\r\n router.isNavigatingFirst = false;\r\n router.isNavigatingNew = false;\r\n router.isNavigatingRefresh = false;\r\n router.isNavigatingForward = false;\r\n router.isNavigatingBack = false;\r\n router.couldDeactivate = false;\r\n\r\n let eventName: string;\r\n\r\n if (result.output instanceof Error) {\r\n eventName = RouterEvent.Error;\r\n } else if (!result.completed) {\r\n eventName = RouterEvent.Canceled;\r\n } else {\r\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\r\n router.history.previousLocation = instruction.fragment + queryString;\r\n eventName = RouterEvent.Success;\r\n }\r\n\r\n eventAggregator.publish(eventName, eventArgs);\r\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\r\n } else {\r\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst restorePreviousLocation = (router: AppRouter): void => {\r\n let previousLocation = router.history.previousLocation;\r\n if (previousLocation) {\r\n router.navigate(previousLocation, { trigger: false, replace: true });\r\n } else if (router.fallbackRoute) {\r\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\r\n } else {\r\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\r\n }\r\n};\r\n","/**\r\n* The status of a Pipeline.\r\n*/\r\nexport const enum PipelineStatus {\r\n Completed = 'completed',\r\n Canceled = 'canceled',\r\n Rejected = 'rejected',\r\n Running = 'running'\r\n}\r\n","/**\r\n * A list of known router events used by the Aurelia router\r\n * to signal the pipeline has come to a certain state\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum RouterEvent {\r\n Processing = 'router:navigation:processing',\r\n Error = 'router:navigation:error',\r\n Canceled = 'router:navigation:canceled',\r\n Complete = 'router:navigation:complete',\r\n Success = 'router:navigation:success',\r\n ChildComplete = 'router:navigation:child:complete'\r\n}\r\n","/**\r\n * Available pipeline slot names to insert interceptor into router pipeline\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum PipelineSlotName {\r\n /**\r\n * Authorization slot. Invoked early in the pipeline,\r\n * before `canActivate` hook of incoming route\r\n */\r\n Authorize = 'authorize',\r\n /**\r\n * Pre-activation slot. Invoked early in the pipeline,\r\n * Invoked timing:\r\n * - after Authorization slot\r\n * - after canActivate hook on new view model\r\n * - before deactivate hook on old view model\r\n * - before activate hook on new view model\r\n */\r\n PreActivate = 'preActivate',\r\n /**\r\n * Pre-render slot. Invoked later in the pipeline\r\n * Invokcation timing:\r\n * - after activate hook on new view model\r\n * - before commit step on new navigation instruction\r\n */\r\n PreRender = 'preRender',\r\n /**\r\n * Post-render slot. Invoked last in the pipeline\r\n */\r\n PostRender = 'postRender'\r\n}\r\n"],"names":["LogManager.getLogger"],"mappings":";;;;;;AA2BA;;;AAGA,MAAa,qBAAqB;IA4DhC,YAAY,IAA+B;;;;QAT3C,SAAI,GAAwC,IAAI,CAAC;QAEjD,YAAO,GAAwB,EAAE,CAAC;QAQhC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;QAE/B,IAAI,cAAc,GAAG,EAAE,CAAC;QACxB,IAAI,OAAO,GAA0B,IAAI,CAAC;QAC1C,GAAG;YACD,IAAI,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACtD,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE;;gBAEnD,OAAO,aAAa,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;aACjD;YAED,cAAc,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YACtC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;SACrC,QAAQ,OAAO,EAAE;QAElB,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,cAAc,CAAC,CAAC;QACvE,IAAI,CAAC,aAAa,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;KACrD;;;;IAKD,kBAAkB;QAChB,IAAI,YAAY,GAA4B,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,oBAAoB,GAAwC,IAAI,CAA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IACvC,oDAAqC,CAAA;IACrC,iEAAkD,CAAA;CACnD,EAPiB,WAAW,KAAX,WAAW,QAO5B;;ACZD;;;;AAIA,IAAkB,gBA0BjB;AA1BD,WAAkB,gBAAgB;;;;;IAKhC,2CAAuB,CAAA;;;;;;;;;IASvB,+CAA2B,CAAA;;;;;;;IAO3B,2CAAuB,CAAA;;;;IAIvB,6CAAyB,CAAA;CAC1B,EA1BiB,gBAAgB,KAAhB,gBAAgB,QA0BjC;;;;"} \ No newline at end of file diff --git a/dist/native-modules/aurelia-router.js.map b/dist/native-modules/aurelia-router.js.map index 0854aca1..8bff95c5 100644 --- a/dist/native-modules/aurelia-router.js.map +++ b/dist/native-modules/aurelia-router.js.map @@ -1 +1 @@ -{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\nimport { Router } from './router';\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\n\n/**\n * Initialization options for a navigation instruction\n */\nexport interface NavigationInstructionInit {\n fragment: string;\n queryString?: string;\n params?: Record;\n queryParams?: Record;\n config: RouteConfig;\n parentInstruction?: NavigationInstruction;\n previousInstruction?: NavigationInstruction;\n router: Router;\n options?: Object;\n plan?: Record;\n}\n\nexport interface ViewPortInstructionInit {\n name: string;\n strategy: ActivationStrategyType;\n moduleId: string;\n component: ViewPortComponent;\n}\n\n/**\n * Class used to represent an instruction during a navigation.\n */\nexport class NavigationInstruction {\n /**\n * The URL fragment.\n */\n fragment: string;\n\n /**\n * The query string.\n */\n queryString: string;\n\n /**\n * Parameters extracted from the route pattern.\n */\n params: any;\n\n /**\n * Parameters extracted from the query string.\n */\n queryParams: any;\n\n /**\n * The route config for the route matching this instruction.\n */\n config: RouteConfig;\n\n /**\n * The parent instruction, if this instruction was created by a child router.\n */\n parentInstruction: NavigationInstruction;\n\n parentCatchHandler: any;\n\n /**\n * The instruction being replaced by this instruction in the current router.\n */\n previousInstruction: NavigationInstruction;\n\n /**\n * viewPort instructions to used activation.\n */\n viewPortInstructions: Record;\n\n /**\n * The router instance.\n */\n router: Router;\n\n /**\n * Current built viewport plan of this nav instruction\n */\n plan: Record = null;\n\n options: Record = {};\n\n /**@internal */\n lifecycleArgs: LifecycleArguments;\n /**@internal */\n resolve?: (val?: any) => void;\n\n constructor(init: NavigationInstructionInit) {\n Object.assign(this, init);\n\n this.params = this.params || {};\n this.viewPortInstructions = {};\n\n let ancestorParams = [];\n let current: NavigationInstruction = this;\n do {\n let currentParams = Object.assign({}, current.params);\n if (current.config && current.config.hasChildRouter) {\n // remove the param for the injected child route segment\n delete currentParams[current.getWildCardName()];\n }\n\n ancestorParams.unshift(currentParams);\n current = current.parentInstruction;\n } while (current);\n\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\n this.lifecycleArgs = [allParams, this.config, this];\n }\n\n /**\n * Gets an array containing this instruction and all child instructions for the current navigation.\n */\n getAllInstructions(): Array {\n let instructions: NavigationInstruction[] = [this];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let key in viewPortInstructions) {\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\n if (childInstruction) {\n instructions.push(...childInstruction.getAllInstructions());\n }\n }\n\n return instructions;\n }\n\n /**\n * Gets an array containing the instruction and all child instructions for the previous navigation.\n * Previous instructions are no longer available after navigation completes.\n */\n getAllPreviousInstructions(): Array {\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\n }\n\n /**\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\n */\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\n addViewPortInstruction(\n nameOrInitOptions: string | ViewPortInstructionInit,\n strategy?: ActivationStrategyType,\n moduleId?: string,\n component?: any\n ): /*ViewPortInstruction*/ any {\n\n let viewPortInstruction: ViewPortInstruction;\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\n const lifecycleArgs = this.lifecycleArgs;\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\n\n if (typeof nameOrInitOptions === 'string') {\n viewPortInstruction = {\n name: nameOrInitOptions,\n strategy: strategy,\n moduleId: moduleId,\n component: component,\n childRouter: component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n } else {\n viewPortInstruction = {\n name: viewPortName,\n strategy: nameOrInitOptions.strategy,\n component: nameOrInitOptions.component,\n moduleId: nameOrInitOptions.moduleId,\n childRouter: nameOrInitOptions.component.childRouter,\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\n };\n }\n\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\n }\n\n /**\n * Gets the name of the route pattern's wildcard parameter, if applicable.\n */\n getWildCardName(): string {\n // todo: potential issue, or at least unsafe typings\n let configRoute = this.config.route as string;\n let wildcardIndex = configRoute.lastIndexOf('*');\n return configRoute.substr(wildcardIndex + 1);\n }\n\n /**\n * Gets the path and query string created by filling the route\n * pattern's wildcard parameter with the matching param.\n */\n getWildcardPath(): string {\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n let queryString = this.queryString;\n\n if (queryString) {\n path += '?' + queryString;\n }\n\n return path;\n }\n\n /**\n * Gets the instruction's base URL, accounting for wildcard route parameters.\n */\n getBaseUrl(): string {\n let $encodeURI = encodeURI;\n let fragment = decodeURI(this.fragment);\n\n if (fragment === '') {\n let nonEmptyRoute = this.router.routes.find(route => {\n return route.name === this.config.name &&\n route.route !== '';\n });\n if (nonEmptyRoute) {\n fragment = nonEmptyRoute.route as any;\n }\n }\n\n if (!this.params) {\n return $encodeURI(fragment);\n }\n\n let wildcardName = this.getWildCardName();\n let path = this.params[wildcardName] || '';\n\n if (!path) {\n return $encodeURI(fragment);\n }\n\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\n }\n\n /**\n * Finalize a viewport instruction\n * @internal\n */\n _commitChanges(waitToSwap: boolean): Promise {\n let router = this.router;\n router.currentInstruction = this;\n\n const previousInstruction = this.previousInstruction;\n if (previousInstruction) {\n previousInstruction.config.navModel.isActive = false;\n }\n\n this.config.navModel.isActive = true;\n\n router.refreshNavigation();\n\n let loads: Promise[] = [];\n let delaySwaps: ISwapPlan[] = [];\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let viewPort = router.viewPorts[viewPortName];\n\n if (!viewPort) {\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\n }\n\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n } else {\n if (waitToSwap) {\n delaySwaps.push({ viewPort, viewPortInstruction });\n }\n loads.push(\n viewPort\n .process(viewPortInstruction, waitToSwap)\n .then(() => childNavInstruction\n ? childNavInstruction._commitChanges(waitToSwap)\n : Promise.resolve()\n )\n );\n }\n } else {\n if (childNavInstruction) {\n loads.push(childNavInstruction._commitChanges(waitToSwap));\n }\n }\n }\n\n return Promise\n .all(loads)\n .then(() => {\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\n return null;\n })\n .then(() => prune(this));\n }\n\n /**@internal */\n _updateTitle(): void {\n let router = this.router;\n let title = this._buildTitle(router.titleSeparator);\n if (title) {\n router.history.setTitle(title);\n }\n }\n\n /**@internal */\n _buildTitle(separator: string = ' | '): string {\n let title = '';\n let childTitles = [];\n let navModelTitle = this.config.navModel.title;\n let instructionRouter = this.router;\n let viewPortInstructions: Record = this.viewPortInstructions;\n\n if (navModelTitle) {\n title = instructionRouter.transformTitle(navModelTitle);\n }\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\n\n if (child_nav_instruction) {\n let childTitle = child_nav_instruction._buildTitle(separator);\n if (childTitle) {\n childTitles.push(childTitle);\n }\n }\n }\n\n if (childTitles.length) {\n title = childTitles.join(separator) + (title ? separator : '') + title;\n }\n\n if (instructionRouter.title) {\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\n }\n\n return title;\n }\n}\n\nconst prune = (instruction: NavigationInstruction): void => {\n instruction.previousInstruction = null;\n instruction.plan = null;\n};\n\ninterface ISwapPlan {\n viewPort: ViewPort;\n viewPortInstruction: ViewPortInstruction;\n}\n","import { Router } from './router';\nimport { RouteConfig } from './interfaces';\n\n/**\n* Class for storing and interacting with a route's navigation settings.\n*/\nexport class NavModel {\n\n /**\n * True if this nav item is currently active.\n */\n isActive: boolean = false;\n\n /**\n * The title.\n */\n title: string = null;\n\n /**\n * This nav item's absolute href.\n */\n href: string = null;\n\n /**\n * This nav item's relative href.\n */\n relativeHref: string = null;\n\n /**\n * Data attached to the route at configuration time.\n */\n settings: any = {};\n\n /**\n * The route config.\n */\n config: RouteConfig = null;\n\n /**\n * The router associated with this navigation model.\n */\n router: Router;\n\n order: number | boolean;\n\n constructor(router: Router, relativeHref: string) {\n this.router = router;\n this.relativeHref = relativeHref;\n }\n\n /**\n * Sets the route's title and updates document.title.\n * If the a navigation is in progress, the change will be applied\n * to document.title when the navigation completes.\n *\n * @param title The new title.\n */\n setTitle(title: string): void {\n this.title = title;\n\n if (this.isActive) {\n this.router.updateTitle();\n }\n }\n}\n","import { RouteConfig } from './interfaces';\n\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\n if (!hasPushState && path[0] !== '#') {\n path = '#' + path;\n }\n\n if (hasPushState && absolute) {\n path = path.substring(1, path.length);\n }\n\n return path;\n}\n\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\n if (isAbsoluteUrl.test(fragment)) {\n return fragment;\n }\n\n let path = '';\n\n if (baseUrl.length && baseUrl[0] !== '/') {\n path += '/';\n }\n\n path += baseUrl;\n\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\n path += '/';\n }\n\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\n path = path.substring(0, path.length - 1);\n }\n\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\n}\n\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\n if (isRootedPath.test(fragment)) {\n return _normalizeAbsolutePath(fragment, hasPushState);\n }\n\n return _createRootedPath(fragment, baseUrl, hasPushState);\n}\n\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\n let routeConfigs = [];\n\n if (Array.isArray(config.route)) {\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\n let current = Object.assign({}, config);\n current.route = config.route[i];\n routeConfigs.push(current);\n }\n } else {\n routeConfigs.push(Object.assign({}, config));\n }\n\n return routeConfigs;\n}\n\nconst isRootedPath = /^#?\\//;\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\nimport { Router } from './router';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * Class used to configure a [[Router]] instance.\n *\n * @constructor\n */\nexport class RouterConfiguration {\n instructions: Array<(router: Router) => void> = [];\n options: {\n [key: string]: any;\n compareQueryParams?: boolean;\n root?: string;\n pushState?: boolean;\n hashChange?: boolean;\n silent?: boolean;\n } = {};\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\n title: string;\n titleSeparator: string;\n unknownRouteConfig: RouteConfigSpecifier;\n viewPortDefaults: Record;\n\n /**@internal */\n _fallbackRoute: string;\n\n /**\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\n *\n * @param name The name of the pipeline slot to insert the step into.\n * @param step The pipeline step.\n * @chainable\n */\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\n if (step === null || step === undefined) {\n throw new Error('Pipeline step cannot be null or undefined.');\n }\n this.pipelineSteps.push({ name, step });\n return this;\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\n }\n\n /**\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\n *\n * @param step The pipeline step.\n * @chainable\n */\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\n }\n\n /**\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @chainable\n */\n fallbackRoute(fragment: string): RouterConfiguration {\n this._fallbackRoute = fragment;\n return this;\n }\n\n /**\n * Maps one or more routes to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\n * @chainable\n */\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\n if (Array.isArray(route)) {\n route.forEach(r => this.map(r));\n return this;\n }\n\n return this.mapRoute(route);\n }\n\n /**\n * Configures defaults to use for any view ports.\n *\n * @param viewPortConfig a view port configuration object to use as a\n * default, of the form { viewPortName: { moduleId } }.\n * @chainable\n */\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\n this.viewPortDefaults = viewPortConfig;\n return this;\n }\n\n /**\n * Maps a single route to be registered with the router.\n *\n * @param route The [[RouteConfig]] to map.\n * @chainable\n */\n mapRoute(config: RouteConfig): RouterConfiguration {\n this.instructions.push(router => {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n\n let navModel;\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\n let routeConfig = routeConfigs[i];\n routeConfig.settings = routeConfig.settings || {};\n if (!navModel) {\n navModel = router.createNavModel(routeConfig);\n }\n\n router.addRoute(routeConfig, navModel);\n }\n });\n\n return this;\n }\n\n /**\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\n *\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\n * [[NavigationInstruction]] and selects a moduleId to load.\n * @chainable\n */\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\n this.unknownRouteConfig = config;\n return this;\n }\n\n /**\n * Applies the current configuration to the specified [[Router]].\n *\n * @param router The [[Router]] to apply the configuration to.\n */\n exportToRouter(router: Router): void {\n let instructions = this.instructions;\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\n instructions[i](router);\n }\n\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\n\n if (title) {\n router.title = title;\n }\n\n if (titleSeparator) {\n router.titleSeparator = titleSeparator;\n }\n\n if (unknownRouteConfig) {\n router.handleUnknownRoutes(unknownRouteConfig);\n }\n\n if (_fallbackRoute) {\n router.fallbackRoute = _fallbackRoute;\n }\n\n if (viewPortDefaults) {\n router.useViewPortDefaults(viewPortDefaults);\n }\n\n Object.assign(router.options, this.options);\n\n let pipelineSteps = this.pipelineSteps;\n let pipelineStepCount = pipelineSteps.length;\n if (pipelineStepCount) {\n if (!router.isRoot) {\n throw new Error('Pipeline steps can only be added to the root router');\n }\n\n let pipelineProvider = router.pipelineProvider;\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\n let { name, step } = pipelineSteps[i];\n pipelineProvider.addStep(name, step);\n }\n }\n }\n}\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): boolean {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): boolean {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\n\n/**@internal exported for unit testing */\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\n let index = -1;\n const next: Next = function() {\n index++;\n\n if (index < steps.length) {\n let currentStep = steps[index];\n\n try {\n return currentStep(instruction, next);\n } catch (e) {\n return next.reject(e);\n }\n } else {\n return next.complete();\n }\n } as Next;\n\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\n\n return next;\n};\n\n/**@internal exported for unit testing */\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\n return (output: any) => Promise\n .resolve({\n status,\n output,\n completed: status === PipelineStatus.Completed\n });\n};\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { createNextFn } from './next';\n\n/**\n * The class responsible for managing and processing the navigation pipeline.\n */\nexport class Pipeline {\n /**\n * The pipeline steps. And steps added via addStep will be converted to a function\n * The actualy running functions with correct step contexts of this pipeline\n */\n steps: StepRunnerFunction[] = [];\n\n /**\n * Adds a step to the pipeline.\n *\n * @param step The pipeline step.\n */\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\n let run;\n\n if (typeof step === 'function') {\n run = step;\n } else if (typeof step.getSteps === 'function') {\n // getSteps is to enable support open slots\n // where devs can add multiple steps into the same slot name\n let steps = step.getSteps();\n for (let i = 0, l = steps.length; i < l; i++) {\n this.addStep(steps[i]);\n }\n\n return this;\n } else {\n run = (step as PipelineStep).run.bind(step);\n }\n\n this.steps.push(run);\n\n return this;\n }\n\n /**\n * Runs the pipeline.\n *\n * @param instruction The navigation instruction to process.\n */\n run(instruction: NavigationInstruction): Promise {\n const nextFn = createNextFn(instruction, this.steps);\n return nextFn();\n }\n}\n","import { NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface NavigationOptions {\n useAppRouter?: boolean;\n }\n}\n\n/**\n* When a navigation command is encountered, the current navigation\n* will be cancelled and control will be passed to the navigation\n* command so it can determine the correct action.\n*/\nexport interface NavigationCommand {\n navigate: (router: Router) => void;\n /**@internal */\n shouldContinueProcessing?: boolean;\n /**@internal */\n setRouter?: (router: Router) => void;\n}\n\n/**\n* Determines if the provided object is a navigation command.\n* A navigation command is anything with a navigate method.\n*\n* @param obj The object to check.\n*/\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\n return obj && typeof obj.navigate === 'function';\n}\n\n/**\n* Used during the activation lifecycle to cause a redirect.\n*/\nexport class Redirect implements NavigationCommand {\n\n url: string;\n /**@internal */\n options: NavigationOptions;\n /**@internal */\n shouldContinueProcessing: boolean;\n\n private router: Router;\n\n /**\n * @param url The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n constructor(url: string, options: NavigationOptions = {}) {\n this.url = url;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigate(this.url, this.options);\n }\n}\n\n/**\n * Used during the activation lifecycle to cause a redirect to a named route.\n */\nexport class RedirectToRoute implements NavigationCommand {\n\n route: string;\n params: any;\n /**@internal */\n options: NavigationOptions;\n\n /**@internal */\n shouldContinueProcessing: boolean;\n\n /**@internal */\n router: Router;\n\n /**\n * @param route The name of the route.\n * @param params The parameters to be sent to the activation method.\n * @param options The options to use for navigation.\n */\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\n this.route = route;\n this.params = params;\n this.options = Object.assign({ trigger: true, replace: true }, options);\n this.shouldContinueProcessing = false;\n }\n\n /**\n * Called by the activation system to set the child router.\n *\n * @param router The router.\n */\n setRouter(router: Router): void {\n this.router = router;\n }\n\n /**\n * Called by the navigation pipeline to navigate.\n *\n * @param appRouter The router to be redirected.\n */\n navigate(appRouter: Router): void {\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\n }\n}\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\n\ntype ViewPortPlansRecord = Record;\n\n/**\n * @internal exported for unit testing\n */\nexport function _buildNavigationPlan(\n instruction: NavigationInstruction,\n forceLifecycleMinimum?: boolean\n): Promise {\n let config = instruction.config;\n\n if ('redirect' in config) {\n return buildRedirectPlan(instruction);\n }\n\n const prevInstruction = instruction.previousInstruction;\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\n\n if (prevInstruction) {\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\n }\n\n // first navigation, only need to prepare a few information for each viewport plan\n const viewPortPlans: ViewPortPlansRecord = {};\n let viewPortConfigs = config.viewPorts;\n for (let viewPortName in viewPortConfigs) {\n let viewPortConfig = viewPortConfigs[viewPortName];\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n viewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n viewPortPlans[viewPortName] = {\n name: viewPortName,\n strategy: InternalActivationStrategy.Replace,\n config: viewPortConfig\n };\n }\n\n return Promise.resolve(viewPortPlans);\n}\n\n/**\n * Build redirect plan based on config of a navigation instruction\n * @internal exported for unit testing\n */\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\n const config = instruction.config;\n const router = instruction.router;\n return router\n ._createNavigationInstruction(config.redirect)\n .then(redirectInstruction => {\n\n const params: Record = {};\n const originalInstructionParams = instruction.params;\n const redirectInstructionParams = redirectInstruction.params;\n\n for (let key in redirectInstructionParams) {\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\n let val = redirectInstructionParams[key];\n if (typeof val === 'string' && val[0] === ':') {\n val = val.slice(1);\n // And if that param is found on the original instruction then use it\n if (val in originalInstructionParams) {\n params[key] = originalInstructionParams[val];\n }\n } else {\n params[key] = redirectInstructionParams[key];\n }\n }\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\n\n // Special handling for child routes\n for (let key in originalInstructionParams) {\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\n }\n\n let queryString = instruction.queryString;\n if (queryString) {\n redirectLocation += '?' + queryString;\n }\n\n return Promise.resolve(new Redirect(redirectLocation));\n });\n};\n\n/**\n * @param viewPortPlans the Plan record that holds information about built plans\n * @internal exported for unit testing\n */\nexport const buildTransitionPlans = (\n currentInstruction: NavigationInstruction,\n previousInstruction: NavigationInstruction,\n defaultViewPortConfigs: Record,\n forceLifecycleMinimum?: boolean\n): Promise => {\n\n let viewPortPlans: ViewPortPlansRecord = {};\n let newInstructionConfig = currentInstruction.config;\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\n let pending: Promise[] = [];\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\n\n for (let viewPortName in previousViewPortInstructions) {\n\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\n const prevViewPortComponent = prevViewPortInstruction.component;\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\n\n // if this is invoked on a viewport without any changes, based on new url,\n // newViewPortConfig will be the existing viewport instruction\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\n ? newInstructionViewPortConfigs[viewPortName]\n : prevViewPortInstruction;\n\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\n }\n\n const viewPortActivationStrategy = determineActivationStrategy(\n currentInstruction,\n prevViewPortInstruction,\n nextViewPortConfig,\n hasNewParams,\n forceLifecycleMinimum\n );\n const viewPortPlan = viewPortPlans[viewPortName] = {\n name: viewPortName,\n // ViewPortInstruction can quack like a RouteConfig\n config: nextViewPortConfig as RouteConfig,\n prevComponent: prevViewPortComponent,\n prevModuleId: prevViewPortInstruction.moduleId,\n strategy: viewPortActivationStrategy\n } as ViewPortPlan;\n\n // recursively build nav plans for all existing child routers/viewports of this viewport\n // this is possible because existing child viewports and routers already have necessary information\n // to process the wildcard path from parent instruction\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\n const path = currentInstruction.getWildcardPath();\n const task: Promise = prevViewPortInstruction\n .childRouter\n ._createNavigationInstruction(path, currentInstruction)\n .then((childInstruction: NavigationInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(\n childInstruction,\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\n // if so, can just use local variable viewPortPlanStrategy\n // there could be user code modifying viewport plan during _createNavigationInstruction?\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\n )\n .then(childPlan => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n // for bluebird ?\n return null;\n });\n });\n\n pending.push(task);\n }\n }\n\n return Promise.all(pending).then(() => viewPortPlans);\n};\n\n/**\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\n * @internal exported for unit testing\n */\nexport const determineActivationStrategy = (\n currentNavInstruction: NavigationInstruction,\n prevViewPortInstruction: ViewPortInstruction,\n newViewPortConfig: RouteConfig | ViewPortInstruction,\n // indicates whether there is difference between old and new url params\n hasNewParams: boolean,\n forceLifecycleMinimum?: boolean\n): ActivationStrategyType => {\n\n let newInstructionConfig = currentNavInstruction.config;\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\n let viewPortPlanStrategy: ActivationStrategyType;\n\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\n } else if (newInstructionConfig.activationStrategy) {\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\n } else if (hasNewParams || forceLifecycleMinimum) {\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\n } else {\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\n }\n return viewPortPlanStrategy;\n};\n\n/**@internal exported for unit testing */\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\n let prevParams = prev.params;\n let nextParams = next.params;\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\n\n for (let key in nextParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n for (let key in prevParams) {\n if (key === nextWildCardName) {\n continue;\n }\n\n if (prevParams[key] !== nextParams[key]) {\n return true;\n }\n }\n\n if (!next.options.compareQueryParams) {\n return false;\n }\n\n let prevQueryParams = prev.queryParams;\n let nextQueryParams = next.queryParams;\n for (let key in nextQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n for (let key in prevQueryParams) {\n if (prevQueryParams[key] !== nextQueryParams[key]) {\n return true;\n }\n }\n\n return false;\n};\n","import { Next } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\n\n/**\n * Transform a navigation instruction into viewport plan record object,\n * or a redirect request if user viewmodel demands\n */\nexport class BuildNavigationPlanStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return _buildNavigationPlan(navigationInstruction)\n .then(plan => {\n if (plan instanceof Redirect) {\n return next.cancel(plan);\n }\n navigationInstruction.plan = plan;\n return next();\n })\n .catch(next.cancel);\n }\n}\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\nimport { Redirect } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { _buildNavigationPlan } from './navigation-plan';\nimport { InternalActivationStrategy } from './activation-strategy';\nimport { RouteLoader } from './route-loader';\n\n/**\n * Loading plan calculated based on a navigration-instruction and a viewport plan\n */\ninterface ILoadingPlan {\n viewPortPlan: ViewPortPlan;\n navigationInstruction: NavigationInstruction;\n}\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadNewRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction\n): Promise => {\n let loadingPlans = determineLoadingPlans(navigationInstruction);\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\n routeLoader,\n loadingPlan.navigationInstruction,\n loadingPlan.viewPortPlan\n ));\n\n return Promise.all(loadPromises);\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const determineLoadingPlans = (\n navigationInstruction: NavigationInstruction,\n loadingPlans: ILoadingPlan[] = []\n): ILoadingPlan[] => {\n let viewPortPlans: Record = navigationInstruction.plan;\n\n for (let viewPortName in viewPortPlans) {\n let viewPortPlan = viewPortPlans[viewPortName];\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\n\n if (childNavInstruction) {\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n } else {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortName,\n strategy: viewPortPlan.strategy,\n moduleId: viewPortPlan.prevModuleId,\n component: viewPortPlan.prevComponent\n }) as ViewPortInstruction;\n\n if (childNavInstruction) {\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\n determineLoadingPlans(childNavInstruction, loadingPlans);\n }\n }\n }\n\n return loadingPlans;\n};\n\n/**\n * @internal Exported for unit testing\n */\nexport const loadRoute = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n viewPortPlan: ViewPortPlan\n): Promise => {\n let planConfig = viewPortPlan.config;\n let moduleId = planConfig ? planConfig.moduleId : null;\n\n return loadComponent(routeLoader, navigationInstruction, planConfig)\n .then((component) => {\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\n name: viewPortPlan.name,\n strategy: viewPortPlan.strategy,\n moduleId: moduleId,\n component: component\n }) as ViewPortInstruction;\n\n let childRouter = component.childRouter;\n if (childRouter) {\n let path = navigationInstruction.getWildcardPath();\n\n return childRouter\n ._createNavigationInstruction(path, navigationInstruction)\n .then((childInstruction) => {\n viewPortPlan.childNavigationInstruction = childInstruction;\n\n return _buildNavigationPlan(childInstruction)\n .then((childPlan) => {\n if (childPlan instanceof Redirect) {\n return Promise.reject(childPlan);\n }\n childInstruction.plan = childPlan;\n viewPortInstruction.childNavigationInstruction = childInstruction;\n\n return loadNewRoute(routeLoader, childInstruction);\n });\n });\n }\n // ts complains without this, though they are same\n return void 0;\n });\n};\n\n/**\n * Load a routed-component based on navigation instruction and route config\n * @internal exported for unit testing only\n */\nexport const loadComponent = (\n routeLoader: RouteLoader,\n navigationInstruction: NavigationInstruction,\n config: RouteConfig\n): Promise => {\n let router = navigationInstruction.router;\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\n\n return Promise.resolve()\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\n .then(\n /**\n * @param component an object carrying information about loaded route\n * typically contains information about view model, childContainer, view and router\n */\n (component: ViewPortComponent) => {\n let { viewModel, childContainer } = component;\n component.router = router;\n component.config = config;\n\n if ('configureRouter' in viewModel) {\n let childRouter = childContainer.getChildRouter();\n component.childRouter = childRouter;\n\n return childRouter\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\n .then(() => component);\n }\n\n return component;\n }\n );\n};\n","import { RouteConfig } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { Router } from './router';\n\n/**\n * Abstract class that is responsible for loading view / view model from a route config\n * The default implementation can be found in `aurelia-templating-router`\n */\nexport class RouteLoader {\n /**\n * Load a route config based on its viewmodel / view configuration\n */\n // return typing: return typings used to be never\n // as it was a throw. Changing it to Promise should not cause any issues\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\n }\n}\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { loadNewRoute } from './utilities-route-loading';\nimport { RouteLoader } from './route-loader';\n/**\n * A pipeline step responsible for loading a route config of a navigation instruction\n */\nexport class LoadRouteStep {\n /**@internal */\n static inject() { return [RouteLoader]; }\n /**\n * Route loader isntance that will handle loading route config\n * @internal\n */\n routeLoader: RouteLoader;\n constructor(routeLoader: RouteLoader) {\n this.routeLoader = routeLoader;\n }\n /**\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\n */\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return loadNewRoute(this.routeLoader, navigationInstruction)\n .then(next, next.cancel);\n }\n}\n","import { NavigationInstruction } from './navigation-instruction';\n\n/**\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\n */\nexport class CommitChangesStep {\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\n return navigationInstruction\n ._commitChanges(/*wait to swap?*/ true)\n .then(() => {\n navigationInstruction._updateTitle();\n return next();\n });\n }\n}\n","/**\n * An optional interface describing the available activation strategies.\n * @internal Used internally.\n */\nexport const enum InternalActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n NoChange = 'no-change',\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n InvokeLifecycle = 'invoke-lifecycle',\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n Replace = 'replace'\n}\n\n/**\n * The strategy to use when activating modules during navigation.\n */\n// kept for compat reason\nexport const activationStrategy: ActivationStrategy = {\n noChange: InternalActivationStrategy.NoChange,\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\n replace: InternalActivationStrategy.Replace\n};\n\n/**\n * An optional interface describing the available activation strategies.\n */\nexport interface ActivationStrategy {\n /**\n * Reuse the existing view model, without invoking Router lifecycle hooks.\n */\n noChange: 'no-change';\n /**\n * Reuse the existing view model, invoking Router lifecycle hooks.\n */\n invokeLifecycle: 'invoke-lifecycle';\n /**\n * Replace the existing view model, invoking Router lifecycle hooks.\n */\n replace: 'replace';\n}\n\n/**\n * Enum like type for activation strategy built-in values\n */\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\nimport { isNavigationCommand } from './navigation-commands';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { activationStrategy } from './activation-strategy';\nimport { Router } from './router';\n\n/**\n * Recursively find list of deactivate-able view models\n * and invoke the either 'canDeactivate' or 'deactivate' on each\n * @internal exported for unit testing\n */\nexport const processDeactivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canDeactivate' | 'deactivate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let plan: Record = navigationInstruction.plan;\n let infos = findDeactivatable(plan, callbackName);\n let i = infos.length; // query from inside out\n\n function inspect(val: any): Promise {\n if (ignoreResult || shouldContinue(val)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n if (i--) {\n try {\n let viewModel = infos[i];\n let result = viewModel[callbackName](navigationInstruction);\n return processPotential(result, inspect, next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n navigationInstruction.router.couldDeactivate = true;\n\n return next();\n }\n\n return iterate();\n};\n\n/**\n * Recursively find and returns a list of deactivate-able view models\n * @internal exported for unit testing\n */\nexport const findDeactivatable = (\n plan: Record,\n callbackName: string,\n list: IActivatableInfo[] = []\n): any[] => {\n for (let viewPortName in plan) {\n let viewPortPlan = plan[viewPortName];\n let prevComponent = viewPortPlan.prevComponent;\n\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\n && prevComponent\n ) {\n let viewModel = prevComponent.viewModel;\n\n if (callbackName in viewModel) {\n list.push(viewModel);\n }\n }\n\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\n addPreviousDeactivatable(prevComponent, callbackName, list);\n } else if (viewPortPlan.childNavigationInstruction) {\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\n }\n }\n\n return list;\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const addPreviousDeactivatable = (\n component: ViewPortComponent,\n callbackName: string,\n list: IActivatableInfo[]\n): void => {\n let childRouter = component.childRouter;\n\n if (childRouter && childRouter.currentInstruction) {\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\n\n for (let viewPortName in viewPortInstructions) {\n let viewPortInstruction = viewPortInstructions[viewPortName];\n let prevComponent = viewPortInstruction.component;\n let prevViewModel = prevComponent.viewModel;\n\n if (callbackName in prevViewModel) {\n list.push(prevViewModel);\n }\n\n addPreviousDeactivatable(prevComponent, callbackName, list);\n }\n }\n};\n\n/**\n * @internal exported for unit testing\n */\nexport const processActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n next: Next,\n ignoreResult?: boolean\n): Promise => {\n let infos = findActivatable(navigationInstruction, callbackName);\n let length = infos.length;\n let i = -1; // query from top down\n\n function inspect(val: any, router: Router): Promise {\n if (ignoreResult || shouldContinue(val, router)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise {\n i++;\n\n if (i < length) {\n try {\n let current = infos[i];\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\n } catch (error) {\n return next.cancel(error);\n }\n }\n\n return next();\n }\n\n return iterate();\n};\n\ninterface IActivatableInfo {\n viewModel: any;\n lifecycleArgs: LifecycleArguments;\n router: Router;\n}\n\n/**\n * Find list of activatable view model and add to list (3rd parameter)\n * @internal exported for unit testing\n */\nexport const findActivatable = (\n navigationInstruction: NavigationInstruction,\n callbackName: 'canActivate' | 'activate',\n list: IActivatableInfo[] = [],\n router?: Router\n): IActivatableInfo[] => {\n let plan: Record = navigationInstruction.plan;\n\n Object\n .keys(plan)\n .forEach((viewPortName) => {\n let viewPortPlan = plan[viewPortName];\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\n let viewPortComponent = viewPortInstruction.component;\n let viewModel = viewPortComponent.viewModel;\n\n if (\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\n || viewPortPlan.strategy === activationStrategy.replace\n )\n && callbackName in viewModel\n ) {\n list.push({\n viewModel,\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\n router\n });\n }\n\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\n\n if (childNavInstruction) {\n findActivatable(\n childNavInstruction,\n callbackName,\n list,\n viewPortComponent.childRouter || router\n );\n }\n });\n\n return list;\n};\n\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\n if (output instanceof Error) {\n return false;\n }\n\n if (isNavigationCommand(output)) {\n if (typeof output.setRouter === 'function') {\n output.setRouter(router);\n }\n\n return !!output.shouldContinueProcessing;\n }\n\n if (output === undefined) {\n return true;\n }\n\n return output;\n};\n\n/**\n * A basic interface for an Observable type\n */\nexport interface IObservable {\n subscribe(sub?: IObservableConfig): ISubscription;\n}\n\nexport interface IObservableConfig {\n next(): void;\n error(err?: any): void;\n complete(): void;\n}\n\n/**\n * A basic interface for a Subscription to an Observable\n */\ninterface ISubscription {\n unsubscribe(): void;\n}\n\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\n\n/**\n * wraps a subscription, allowing unsubscribe calls even if\n * the first value comes synchronously\n */\nclass SafeSubscription {\n\n private _subscribed: boolean;\n private _subscription: ISubscription;\n\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\n this._subscribed = true;\n this._subscription = subscriptionFunc(this);\n\n if (!this._subscribed) {\n this.unsubscribe();\n }\n }\n\n get subscribed(): boolean {\n return this._subscribed;\n }\n\n unsubscribe(): void {\n if (this._subscribed && this._subscription) {\n this._subscription.unsubscribe();\n }\n\n this._subscribed = false;\n }\n}\n\n/**\n * A function to process return value from `activate`/`canActivate` steps\n * Supports observable/promise\n *\n * For observable, resolve at first next() or on complete()\n */\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\n // if promise like\n if (obj && typeof obj.then === 'function') {\n return Promise.resolve(obj).then(resolve).catch(reject);\n }\n\n // if observable\n if (obj && typeof obj.subscribe === 'function') {\n let obs: IObservable = obj;\n return new SafeSubscription(sub => obs.subscribe({\n next() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n },\n error(error) {\n if (sub.subscribed) {\n sub.unsubscribe();\n reject(error);\n }\n },\n complete() {\n if (sub.subscribed) {\n sub.unsubscribe();\n resolve(obj);\n }\n }\n }));\n }\n\n // else just resolve\n try {\n return resolve(obj);\n } catch (error) {\n return reject(error);\n }\n};\n","import { Next } from './interfaces';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { processDeactivatable, processActivatable } from './utilities-activation';\n\n/**\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\n */\nexport class CanDeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\n */\nexport class CanActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'canActivate', next);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\n */\nexport class DeactivatePreviousStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\n }\n}\n\n/**\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\n */\nexport class ActivateNextStep {\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\n return processActivatable(navigationInstruction, 'activate', next, true);\n }\n}\n","import { Container } from 'aurelia-dependency-injection';\nimport { Pipeline } from './pipeline';\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\nimport { LoadRouteStep } from './step-load-route';\nimport { CommitChangesStep } from './step-commit-changes';\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\nimport { PipelineSlotName } from './pipeline-slot-name';\n\n/**\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\n */\nclass PipelineSlot implements IPipelineSlot {\n\n /**@internal */\n container: Container;\n /**@internal */\n slotName: string;\n /**@internal */\n slotAlias?: string;\n\n steps: (Function | PipelineStep)[] = [];\n\n constructor(container: Container, name: string, alias?: string) {\n this.container = container;\n this.slotName = name;\n this.slotAlias = alias;\n }\n\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\n return this.steps.map(x => this.container.get(x));\n }\n}\n\n/**\n * Class responsible for creating the navigation pipeline.\n */\nexport class PipelineProvider {\n\n /**@internal */\n static inject() { return [Container]; }\n /**@internal */\n container: Container;\n /**@internal */\n steps: (Function | PipelineSlot)[];\n\n constructor(container: Container) {\n this.container = container;\n this.steps = [\n BuildNavigationPlanStep,\n CanDeactivatePreviousStep, // optional\n LoadRouteStep,\n createPipelineSlot(container, PipelineSlotName.Authorize),\n CanActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\n // NOTE: app state changes start below - point of no return\n DeactivatePreviousStep, // optional\n ActivateNextStep, // optional\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\n CommitChangesStep,\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\n ];\n }\n\n /**\n * Create the navigation pipeline.\n */\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\n let pipeline = new Pipeline();\n this.steps.forEach(step => {\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\n pipeline.addStep(this.container.get(step));\n }\n });\n return pipeline;\n }\n\n /**@internal */\n _findStep(name: string): PipelineSlot {\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\n }\n\n /**\n * Adds a step into the pipeline at a known slot location.\n */\n addStep(name: string, step: PipelineStep | Function): void {\n let found = this._findStep(name);\n if (found) {\n let slotSteps = found.steps;\n // prevent duplicates\n if (!slotSteps.includes(step)) {\n slotSteps.push(step);\n }\n } else {\n throw new Error(`Invalid pipeline slot name: ${name}.`);\n }\n }\n\n /**\n * Removes a step from a slot in the pipeline\n */\n removeStep(name: string, step: PipelineStep): void {\n let slot = this._findStep(name);\n if (slot) {\n let slotSteps = slot.steps;\n slotSteps.splice(slotSteps.indexOf(step), 1);\n }\n }\n\n /**\n * Clears all steps from a slot in the pipeline\n * @internal\n */\n _clearSteps(name: string = ''): void {\n let slot = this._findStep(name);\n if (slot) {\n slot.steps = [];\n }\n }\n\n /**\n * Resets all pipeline slots\n */\n reset(): void {\n this._clearSteps(PipelineSlotName.Authorize);\n this._clearSteps(PipelineSlotName.PreActivate);\n this._clearSteps(PipelineSlotName.PreRender);\n this._clearSteps(PipelineSlotName.PostRender);\n }\n}\n\n/**@internal */\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\n return new PipelineSlot(container, name, alias);\n};\n","import * as LogManager from 'aurelia-logging';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { Router } from './router';\nimport { PipelineProvider } from './pipeline-provider';\nimport { isNavigationCommand } from './navigation-commands';\nimport { EventAggregator } from 'aurelia-event-aggregator';\nimport { NavigationInstruction } from './navigation-instruction';\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\nimport { RouterEvent } from './router-event';\nimport { RouterConfiguration } from './router-configuration';\n\n/**@internal */\ndeclare module 'aurelia-dependency-injection' {\n interface Container {\n viewModel?: any;\n }\n}\n\nconst logger = LogManager.getLogger('app-router');\n\n/**\n * The main application router.\n */\nexport class AppRouter extends Router {\n\n /**@internal */\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\n\n events: EventAggregator;\n /**@internal */\n maxInstructionCount: number;\n /**@internal */\n _queue: NavigationInstruction[];\n /**@internal */\n isActive: boolean;\n\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\n super(container, history); // Note the super will call reset internally.\n this.pipelineProvider = pipelineProvider;\n this.events = events;\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset(): void {\n super.reset();\n this.maxInstructionCount = 10;\n if (!this._queue) {\n this._queue = [];\n } else {\n this._queue.length = 0;\n }\n }\n\n /**\n * Loads the specified URL.\n *\n * @param url The URL fragment to load.\n */\n loadUrl(url: string): Promise {\n return this\n ._createNavigationInstruction(url)\n .then(instruction => this._queueInstruction(instruction))\n .catch(error => {\n logger.error(error);\n restorePreviousLocation(this);\n });\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\n // having strong typing without changing public API\n const $viewPort: ViewPort = viewPort;\n super.registerViewPort($viewPort, name);\n\n // beside adding viewport to the registry of this instance\n // AppRouter also configure routing/history to start routing functionality\n // There are situation where there are more than 1 element at root view\n // in that case, still only activate once via the following guard\n if (!this.isActive) {\n const viewModel = this._findViewModel($viewPort);\n if ('configureRouter' in viewModel) {\n // If there are more than one element at root view\n // use this flag to guard against configure method being invoked multiple times\n // this flag is set inside method configure\n if (!this.isConfigured) {\n // replace the real resolve with a noop to guarantee that any action in base class Router\n // won't resolve the configurePromise prematurely\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\n this._resolveConfiguredPromise = () => {/**/};\n return this\n .configure(config =>\n Promise\n .resolve(viewModel.configureRouter(config, this))\n // an issue with configure interface. Should be fixed there\n // todo: fix this via configure interface in router\n .then(() => config) as any\n )\n .then(() => {\n this.activate();\n resolveConfiguredPromise();\n });\n }\n } else {\n this.activate();\n }\n }\n // when a viewport is added dynamically to a root view that is already activated\n // just process the navigation instruction\n else {\n this._dequeueInstruction();\n }\n\n return Promise.resolve();\n }\n\n /**\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\n *\n * @params options The set of options to activate the router with.\n */\n activate(options?: NavigationOptions): void {\n if (this.isActive) {\n return;\n }\n\n this.isActive = true;\n // route handler property is responsible for handling url change\n // the interface of aurelia-history isn't clear on this perspective\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\n this.history.activate(this.options);\n this._dequeueInstruction();\n }\n\n /**\n * Deactivates the router.\n */\n deactivate(): void {\n this.isActive = false;\n this.history.deactivate();\n }\n\n /**@internal */\n _queueInstruction(instruction: NavigationInstruction): Promise {\n return new Promise((resolve) => {\n instruction.resolve = resolve;\n this._queue.unshift(instruction);\n this._dequeueInstruction();\n });\n }\n\n /**@internal */\n _dequeueInstruction(instructionCount: number = 0): Promise {\n return Promise.resolve().then(() => {\n if (this.isNavigating && !instructionCount) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n let instruction = this._queue.shift();\n this._queue.length = 0;\n\n if (!instruction) {\n // ts complains about inconsistent returns without void 0\n return void 0;\n }\n\n this.isNavigating = true;\n\n let navtracker: number = this.history.getState('NavigationTracker');\n let currentNavTracker = this.currentNavigationTracker;\n\n if (!navtracker && !currentNavTracker) {\n this.isNavigatingFirst = true;\n this.isNavigatingNew = true;\n } else if (!navtracker) {\n this.isNavigatingNew = true;\n } else if (!currentNavTracker) {\n this.isNavigatingRefresh = true;\n } else if (currentNavTracker < navtracker) {\n this.isNavigatingForward = true;\n } else if (currentNavTracker > navtracker) {\n this.isNavigatingBack = true;\n } if (!navtracker) {\n navtracker = Date.now();\n this.history.setState('NavigationTracker', navtracker);\n }\n this.currentNavigationTracker = navtracker;\n\n instruction.previousInstruction = this.currentInstruction;\n\n let maxInstructionCount = this.maxInstructionCount;\n\n if (!instructionCount) {\n this.events.publish(RouterEvent.Processing, { instruction });\n } else if (instructionCount === maxInstructionCount - 1) {\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\n restorePreviousLocation(this);\n return this._dequeueInstruction(instructionCount + 1);\n } else if (instructionCount > maxInstructionCount) {\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\n }\n\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\n\n return pipeline\n .run(instruction)\n .then(result => processResult(instruction, result, instructionCount, this))\n .catch(error => {\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\n })\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\n });\n }\n\n /**@internal */\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\n if (this.container.viewModel) {\n return this.container.viewModel;\n }\n\n if (viewPort.container) {\n let container = viewPort.container;\n\n while (container) {\n if (container.viewModel) {\n this.container.viewModel = container.viewModel;\n return container.viewModel;\n }\n\n container = container.parent;\n }\n }\n\n return undefined;\n }\n}\n\nconst processResult = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n instructionCount: number,\n router: AppRouter\n): Promise => {\n if (!(result && 'completed' in result && 'output' in result)) {\n result = result || {} as PipelineResult;\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\n }\n\n let finalResult: PipelineResult = null;\n let navigationCommandResult = null;\n if (isNavigationCommand(result.output)) {\n navigationCommandResult = result.output.navigate(router);\n } else {\n finalResult = result;\n\n if (!result.completed) {\n if (result.output instanceof Error) {\n logger.error(result.output.toString());\n }\n\n restorePreviousLocation(router);\n }\n }\n\n return Promise.resolve(navigationCommandResult)\n .then(_ => router._dequeueInstruction(instructionCount + 1))\n .then(innerResult => finalResult || innerResult || result);\n};\n\nconst resolveInstruction = (\n instruction: NavigationInstruction,\n result: PipelineResult,\n isInnerInstruction: boolean,\n router: AppRouter\n): PipelineResult => {\n instruction.resolve(result);\n\n let eventAggregator = router.events;\n let eventArgs = { instruction, result };\n if (!isInnerInstruction) {\n router.isNavigating = false;\n router.isExplicitNavigation = false;\n router.isExplicitNavigationBack = false;\n router.isNavigatingFirst = false;\n router.isNavigatingNew = false;\n router.isNavigatingRefresh = false;\n router.isNavigatingForward = false;\n router.isNavigatingBack = false;\n router.couldDeactivate = false;\n\n let eventName: string;\n\n if (result.output instanceof Error) {\n eventName = RouterEvent.Error;\n } else if (!result.completed) {\n eventName = RouterEvent.Canceled;\n } else {\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\n router.history.previousLocation = instruction.fragment + queryString;\n eventName = RouterEvent.Success;\n }\n\n eventAggregator.publish(eventName, eventArgs);\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\n } else {\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\n }\n\n return result;\n};\n\nconst restorePreviousLocation = (router: AppRouter): void => {\n let previousLocation = router.history.previousLocation;\n if (previousLocation) {\n router.navigate(previousLocation, { trigger: false, replace: true });\n } else if (router.fallbackRoute) {\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\n } else {\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\n }\n};\n","/**\n* The status of a Pipeline.\n*/\nexport const enum PipelineStatus {\n Completed = 'completed',\n Canceled = 'canceled',\n Rejected = 'rejected',\n Running = 'running'\n}\n","/**\n * A list of known router events used by the Aurelia router\n * to signal the pipeline has come to a certain state\n */\n// const enum is preserved in tsconfig\nexport const enum RouterEvent {\n Processing = 'router:navigation:processing',\n Error = 'router:navigation:error',\n Canceled = 'router:navigation:canceled',\n Complete = 'router:navigation:complete',\n Success = 'router:navigation:success',\n ChildComplete = 'router:navigation:child:complete'\n}\n","/**\n * Available pipeline slot names to insert interceptor into router pipeline\n */\n// const enum is preserved in tsconfig\nexport const enum PipelineSlotName {\n /**\n * Authorization slot. Invoked early in the pipeline,\n * before `canActivate` hook of incoming route\n */\n Authorize = 'authorize',\n /**\n * Pre-activation slot. Invoked early in the pipeline,\n * Invoked timing:\n * - after Authorization slot\n * - after canActivate hook on new view model\n * - before deactivate hook on old view model\n * - before activate hook on new view model\n */\n PreActivate = 'preActivate',\n /**\n * Pre-render slot. Invoked later in the pipeline\n * Invokcation timing:\n * - after activate hook on new view model\n * - before commit step on new navigation instruction\n */\n PreRender = 'preRender',\n /**\n * Post-render slot. Invoked last in the pipeline\n */\n PostRender = 'postRender'\n}\n"],"names":["LogManager.getLogger","tslib_1.__extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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AAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;KACzE;SAAM;QACL,MAAM,CAAC,KAAK,CAAC,wFAAwF,CAAC,CAAC;KACxG;CACF,CAAC;;ACzUF;;;AAGA,IAAkB,cAKjB;AALD,WAAkB,cAAc;IAC9B,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;CACpB,EALiB,cAAc,KAAd,cAAc,QAK/B;;ACRD;;;;;AAKA,IAAkB,WAOjB;AAPD,WAAkB,WAAW;IAC3B,0DAA2C,CAAA;IAC3C,gDAAiC,CAAA;IACjC,sDAAuC,CAAA;IACvC,sDAAuC,CAAA;IACvC,oDAAqC,CAAA;IACrC,iEAAkD,CAAA;CACnD,EAPiB,WAAW,KAAX,WAAW,QAO5B;;ACZD;;;;AAIA,IAAkB,gBA0BjB;AA1BD,WAAkB,gBAAgB;;;;;IAKhC,2CAAuB,CAAA;;;;;;;;;IASvB,+CAA2B,CAAA;;;;;;;IAO3B,2CAAuB,CAAA;;;;IAIvB,6CAAyB,CAAA;CAC1B,EA1BiB,gBAAgB,KAAhB,gBAAgB,QA0BjC;;;;"} \ No newline at end of file +{"version":3,"file":"aurelia-router.js","sources":["../../src/navigation-instruction.ts","../../src/nav-model.ts","../../src/util.ts","../../src/router-configuration.ts","../../src/router.ts","../../src/next.ts","../../src/pipeline.ts","../../src/navigation-commands.ts","../../src/navigation-plan.ts","../../src/step-build-navigation-plan.ts","../../src/utilities-route-loading.ts","../../src/route-loader.ts","../../src/step-load-route.ts","../../src/step-commit-changes.ts","../../src/activation-strategy.ts","../../src/utilities-activation.ts","../../src/step-activation.ts","../../src/pipeline-provider.ts","../../src/app-router.ts","../../src/pipeline-status.ts","../../src/router-event.ts","../../src/pipeline-slot-name.ts"],"sourcesContent":["import { ViewPortInstruction, RouteConfig, ViewPort, LifecycleArguments, ViewPortComponent } from './interfaces';\r\nimport { Router } from './router';\r\nimport { ActivationStrategyType, InternalActivationStrategy } from './activation-strategy';\r\n\r\n/**\r\n * Initialization options for a navigation instruction\r\n */\r\nexport interface NavigationInstructionInit {\r\n fragment: string;\r\n queryString?: string;\r\n params?: Record;\r\n queryParams?: Record;\r\n config: RouteConfig;\r\n parentInstruction?: NavigationInstruction;\r\n previousInstruction?: NavigationInstruction;\r\n router: Router;\r\n options?: Object;\r\n plan?: Record;\r\n}\r\n\r\nexport interface ViewPortInstructionInit {\r\n name: string;\r\n strategy: ActivationStrategyType;\r\n moduleId: string;\r\n component: ViewPortComponent;\r\n}\r\n\r\n/**\r\n * Class used to represent an instruction during a navigation.\r\n */\r\nexport class NavigationInstruction {\r\n /**\r\n * The URL fragment.\r\n */\r\n fragment: string;\r\n\r\n /**\r\n * The query string.\r\n */\r\n queryString: string;\r\n\r\n /**\r\n * Parameters extracted from the route pattern.\r\n */\r\n params: any;\r\n\r\n /**\r\n * Parameters extracted from the query string.\r\n */\r\n queryParams: any;\r\n\r\n /**\r\n * The route config for the route matching this instruction.\r\n */\r\n config: RouteConfig;\r\n\r\n /**\r\n * The parent instruction, if this instruction was created by a child router.\r\n */\r\n parentInstruction: NavigationInstruction;\r\n\r\n parentCatchHandler: any;\r\n\r\n /**\r\n * The instruction being replaced by this instruction in the current router.\r\n */\r\n previousInstruction: NavigationInstruction;\r\n\r\n /**\r\n * viewPort instructions to used activation.\r\n */\r\n viewPortInstructions: Record;\r\n\r\n /**\r\n * The router instance.\r\n */\r\n router: Router;\r\n\r\n /**\r\n * Current built viewport plan of this nav instruction\r\n */\r\n plan: Record = null;\r\n\r\n options: Record = {};\r\n\r\n /**@internal */\r\n lifecycleArgs: LifecycleArguments;\r\n /**@internal */\r\n resolve?: (val?: any) => void;\r\n\r\n constructor(init: NavigationInstructionInit) {\r\n Object.assign(this, init);\r\n\r\n this.params = this.params || {};\r\n this.viewPortInstructions = {};\r\n\r\n let ancestorParams = [];\r\n let current: NavigationInstruction = this;\r\n do {\r\n let currentParams = Object.assign({}, current.params);\r\n if (current.config && current.config.hasChildRouter) {\r\n // remove the param for the injected child route segment\r\n delete currentParams[current.getWildCardName()];\r\n }\r\n\r\n ancestorParams.unshift(currentParams);\r\n current = current.parentInstruction;\r\n } while (current);\r\n\r\n let allParams = Object.assign({}, this.queryParams, ...ancestorParams);\r\n this.lifecycleArgs = [allParams, this.config, this];\r\n }\r\n\r\n /**\r\n * Gets an array containing this instruction and all child instructions for the current navigation.\r\n */\r\n getAllInstructions(): Array {\r\n let instructions: NavigationInstruction[] = [this];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let key in viewPortInstructions) {\r\n let childInstruction = viewPortInstructions[key].childNavigationInstruction;\r\n if (childInstruction) {\r\n instructions.push(...childInstruction.getAllInstructions());\r\n }\r\n }\r\n\r\n return instructions;\r\n }\r\n\r\n /**\r\n * Gets an array containing the instruction and all child instructions for the previous navigation.\r\n * Previous instructions are no longer available after navigation completes.\r\n */\r\n getAllPreviousInstructions(): Array {\r\n return this.getAllInstructions().map(c => c.previousInstruction).filter(c => c);\r\n }\r\n\r\n /**\r\n * Adds a viewPort instruction. Returns the newly created instruction based on parameters\r\n */\r\n addViewPortInstruction(initOptions: ViewPortInstructionInit): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(viewPortName: string, strategy: ActivationStrategyType, moduleId: string, component: any): /*ViewPortInstruction*/ any;\r\n addViewPortInstruction(\r\n nameOrInitOptions: string | ViewPortInstructionInit,\r\n strategy?: ActivationStrategyType,\r\n moduleId?: string,\r\n component?: any\r\n ): /*ViewPortInstruction*/ any {\r\n\r\n let viewPortInstruction: ViewPortInstruction;\r\n let viewPortName = typeof nameOrInitOptions === 'string' ? nameOrInitOptions : nameOrInitOptions.name;\r\n const lifecycleArgs = this.lifecycleArgs;\r\n const config: RouteConfig = Object.assign({}, lifecycleArgs[1], { currentViewPort: viewPortName });\r\n\r\n if (typeof nameOrInitOptions === 'string') {\r\n viewPortInstruction = {\r\n name: nameOrInitOptions,\r\n strategy: strategy,\r\n moduleId: moduleId,\r\n component: component,\r\n childRouter: component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n } else {\r\n viewPortInstruction = {\r\n name: viewPortName,\r\n strategy: nameOrInitOptions.strategy,\r\n component: nameOrInitOptions.component,\r\n moduleId: nameOrInitOptions.moduleId,\r\n childRouter: nameOrInitOptions.component.childRouter,\r\n lifecycleArgs: [lifecycleArgs[0], config, lifecycleArgs[2]] as LifecycleArguments\r\n };\r\n }\r\n\r\n return this.viewPortInstructions[viewPortName] = viewPortInstruction;\r\n }\r\n\r\n /**\r\n * Gets the name of the route pattern's wildcard parameter, if applicable.\r\n */\r\n getWildCardName(): string {\r\n // todo: potential issue, or at least unsafe typings\r\n let configRoute = this.config.route as string;\r\n let wildcardIndex = configRoute.lastIndexOf('*');\r\n return configRoute.substr(wildcardIndex + 1);\r\n }\r\n\r\n /**\r\n * Gets the path and query string created by filling the route\r\n * pattern's wildcard parameter with the matching param.\r\n */\r\n getWildcardPath(): string {\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n let queryString = this.queryString;\r\n\r\n if (queryString) {\r\n path += '?' + queryString;\r\n }\r\n\r\n return path;\r\n }\r\n\r\n /**\r\n * Gets the instruction's base URL, accounting for wildcard route parameters.\r\n */\r\n getBaseUrl(): string {\r\n let $encodeURI = encodeURI;\r\n let fragment = decodeURI(this.fragment);\r\n\r\n if (fragment === '') {\r\n let nonEmptyRoute = this.router.routes.find(route => {\r\n return route.name === this.config.name &&\r\n route.route !== '';\r\n });\r\n if (nonEmptyRoute) {\r\n fragment = nonEmptyRoute.route as any;\r\n }\r\n }\r\n\r\n if (!this.params) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n let wildcardName = this.getWildCardName();\r\n let path = this.params[wildcardName] || '';\r\n\r\n if (!path) {\r\n return $encodeURI(fragment);\r\n }\r\n\r\n return $encodeURI(fragment.substr(0, fragment.lastIndexOf(path)));\r\n }\r\n\r\n /**\r\n * Finalize a viewport instruction\r\n * @internal\r\n */\r\n _commitChanges(waitToSwap: boolean): Promise {\r\n let router = this.router;\r\n router.currentInstruction = this;\r\n\r\n const previousInstruction = this.previousInstruction;\r\n if (previousInstruction) {\r\n previousInstruction.config.navModel.isActive = false;\r\n }\r\n\r\n this.config.navModel.isActive = true;\r\n\r\n router.refreshNavigation();\r\n\r\n let loads: Promise[] = [];\r\n let delaySwaps: ISwapPlan[] = [];\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let viewPort = router.viewPorts[viewPortName];\r\n\r\n if (!viewPort) {\r\n throw new Error(`There was no router-view found in the view for ${viewPortInstruction.moduleId}.`);\r\n }\r\n\r\n let childNavInstruction = viewPortInstruction.childNavigationInstruction;\r\n if (viewPortInstruction.strategy === InternalActivationStrategy.Replace) {\r\n if (childNavInstruction && childNavInstruction.parentCatchHandler) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n } else {\r\n if (waitToSwap) {\r\n delaySwaps.push({ viewPort, viewPortInstruction });\r\n }\r\n loads.push(\r\n viewPort\r\n .process(viewPortInstruction, waitToSwap)\r\n .then(() => childNavInstruction\r\n ? childNavInstruction._commitChanges(waitToSwap)\r\n : Promise.resolve()\r\n )\r\n );\r\n }\r\n } else {\r\n if (childNavInstruction) {\r\n loads.push(childNavInstruction._commitChanges(waitToSwap));\r\n }\r\n }\r\n }\r\n\r\n return Promise\r\n .all(loads)\r\n .then(() => {\r\n delaySwaps.forEach(x => x.viewPort.swap(x.viewPortInstruction));\r\n return null;\r\n })\r\n .then(() => prune(this));\r\n }\r\n\r\n /**@internal */\r\n _updateTitle(): void {\r\n let router = this.router;\r\n let title = this._buildTitle(router.titleSeparator);\r\n if (title) {\r\n router.history.setTitle(title);\r\n }\r\n }\r\n\r\n /**@internal */\r\n _buildTitle(separator: string = ' | '): string {\r\n let title = '';\r\n let childTitles = [];\r\n let navModelTitle = this.config.navModel.title;\r\n let instructionRouter = this.router;\r\n let viewPortInstructions: Record = this.viewPortInstructions;\r\n\r\n if (navModelTitle) {\r\n title = instructionRouter.transformTitle(navModelTitle);\r\n }\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let child_nav_instruction = viewPortInstruction.childNavigationInstruction;\r\n\r\n if (child_nav_instruction) {\r\n let childTitle = child_nav_instruction._buildTitle(separator);\r\n if (childTitle) {\r\n childTitles.push(childTitle);\r\n }\r\n }\r\n }\r\n\r\n if (childTitles.length) {\r\n title = childTitles.join(separator) + (title ? separator : '') + title;\r\n }\r\n\r\n if (instructionRouter.title) {\r\n title += (title ? separator : '') + instructionRouter.transformTitle(instructionRouter.title);\r\n }\r\n\r\n return title;\r\n }\r\n}\r\n\r\nconst prune = (instruction: NavigationInstruction): void => {\r\n instruction.previousInstruction = null;\r\n instruction.plan = null;\r\n};\r\n\r\ninterface ISwapPlan {\r\n viewPort: ViewPort;\r\n viewPortInstruction: ViewPortInstruction;\r\n}\r\n","import { Router } from './router';\r\nimport { RouteConfig } from './interfaces';\r\n\r\n/**\r\n* Class for storing and interacting with a route's navigation settings.\r\n*/\r\nexport class NavModel {\r\n\r\n /**\r\n * True if this nav item is currently active.\r\n */\r\n isActive: boolean = false;\r\n\r\n /**\r\n * The title.\r\n */\r\n title: string = null;\r\n\r\n /**\r\n * This nav item's absolute href.\r\n */\r\n href: string = null;\r\n\r\n /**\r\n * This nav item's relative href.\r\n */\r\n relativeHref: string = null;\r\n\r\n /**\r\n * Data attached to the route at configuration time.\r\n */\r\n settings: any = {};\r\n\r\n /**\r\n * The route config.\r\n */\r\n config: RouteConfig = null;\r\n\r\n /**\r\n * The router associated with this navigation model.\r\n */\r\n router: Router;\r\n\r\n order: number | boolean;\r\n\r\n constructor(router: Router, relativeHref: string) {\r\n this.router = router;\r\n this.relativeHref = relativeHref;\r\n }\r\n\r\n /**\r\n * Sets the route's title and updates document.title.\r\n * If the a navigation is in progress, the change will be applied\r\n * to document.title when the navigation completes.\r\n *\r\n * @param title The new title.\r\n */\r\n setTitle(title: string): void {\r\n this.title = title;\r\n\r\n if (this.isActive) {\r\n this.router.updateTitle();\r\n }\r\n }\r\n}\r\n","import { RouteConfig } from './interfaces';\r\n\r\nexport function _normalizeAbsolutePath(path: string, hasPushState: boolean, absolute: boolean = false) {\r\n if (!hasPushState && path[0] !== '#') {\r\n path = '#' + path;\r\n }\r\n\r\n if (hasPushState && absolute) {\r\n path = path.substring(1, path.length);\r\n }\r\n\r\n return path;\r\n}\r\n\r\nexport function _createRootedPath(fragment: string, baseUrl: string, hasPushState: boolean, absolute?: boolean) {\r\n if (isAbsoluteUrl.test(fragment)) {\r\n return fragment;\r\n }\r\n\r\n let path = '';\r\n\r\n if (baseUrl.length && baseUrl[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n path += baseUrl;\r\n\r\n if ((!path.length || path[path.length - 1] !== '/') && fragment[0] !== '/') {\r\n path += '/';\r\n }\r\n\r\n if (path.length && path[path.length - 1] === '/' && fragment[0] === '/') {\r\n path = path.substring(0, path.length - 1);\r\n }\r\n\r\n return _normalizeAbsolutePath(path + fragment, hasPushState, absolute);\r\n}\r\n\r\nexport function _resolveUrl(fragment: string, baseUrl: string, hasPushState?: boolean) {\r\n if (isRootedPath.test(fragment)) {\r\n return _normalizeAbsolutePath(fragment, hasPushState);\r\n }\r\n\r\n return _createRootedPath(fragment, baseUrl, hasPushState);\r\n}\r\n\r\nexport function _ensureArrayWithSingleRoutePerConfig(config: RouteConfig) {\r\n let routeConfigs = [];\r\n\r\n if (Array.isArray(config.route)) {\r\n for (let i = 0, ii = config.route.length; i < ii; ++i) {\r\n let current = Object.assign({}, config);\r\n current.route = config.route[i];\r\n routeConfigs.push(current);\r\n }\r\n } else {\r\n routeConfigs.push(Object.assign({}, config));\r\n }\r\n\r\n return routeConfigs;\r\n}\r\n\r\nconst isRootedPath = /^#?\\//;\r\nconst isAbsoluteUrl = /^([a-z][a-z0-9+\\-.]*:)?\\/\\//i;\r\n","import { RouteConfig, PipelineStep, RouteConfigSpecifier } from './interfaces';\r\nimport { _ensureArrayWithSingleRoutePerConfig } from './util';\r\nimport { Router } from './router';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * Class used to configure a [[Router]] instance.\r\n *\r\n * @constructor\r\n */\r\nexport class RouterConfiguration {\r\n instructions: Array<(router: Router) => void> = [];\r\n options: {\r\n [key: string]: any;\r\n compareQueryParams?: boolean;\r\n root?: string;\r\n pushState?: boolean;\r\n hashChange?: boolean;\r\n silent?: boolean;\r\n } = {};\r\n pipelineSteps: Array<{ name: string, step: Function | PipelineStep }> = [];\r\n title: string;\r\n titleSeparator: string;\r\n unknownRouteConfig: RouteConfigSpecifier;\r\n viewPortDefaults: Record;\r\n\r\n /**@internal */\r\n _fallbackRoute: string;\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s navigation pipeline.\r\n *\r\n * @param name The name of the pipeline slot to insert the step into.\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPipelineStep(name: string, step: Function | PipelineStep): RouterConfiguration {\r\n if (step === null || step === undefined) {\r\n throw new Error('Pipeline step cannot be null or undefined.');\r\n }\r\n this.pipelineSteps.push({ name, step });\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s authorize pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addAuthorizeStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.Authorize, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preActivate pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreActivateStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreActivate, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s preRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPreRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PreRender, step);\r\n }\r\n\r\n /**\r\n * Adds a step to be run during the [[Router]]'s postRender pipeline slot.\r\n *\r\n * @param step The pipeline step.\r\n * @chainable\r\n */\r\n addPostRenderStep(step: Function | PipelineStep): RouterConfiguration {\r\n return this.addPipelineStep(PipelineSlotName.PostRender, step);\r\n }\r\n\r\n /**\r\n * Configures a route that will be used if there is no previous location available on navigation cancellation.\r\n *\r\n * @param fragment The URL fragment to use as the navigation destination.\r\n * @chainable\r\n */\r\n fallbackRoute(fragment: string): RouterConfiguration {\r\n this._fallbackRoute = fragment;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps one or more routes to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map, or an array of [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n map(route: RouteConfig | RouteConfig[]): RouterConfiguration {\r\n if (Array.isArray(route)) {\r\n route.forEach(r => this.map(r));\r\n return this;\r\n }\r\n\r\n return this.mapRoute(route);\r\n }\r\n\r\n /**\r\n * Configures defaults to use for any view ports.\r\n *\r\n * @param viewPortConfig a view port configuration object to use as a\r\n * default, of the form { viewPortName: { moduleId } }.\r\n * @chainable\r\n */\r\n useViewPortDefaults(viewPortConfig: Record): RouterConfiguration {\r\n this.viewPortDefaults = viewPortConfig;\r\n return this;\r\n }\r\n\r\n /**\r\n * Maps a single route to be registered with the router.\r\n *\r\n * @param route The [[RouteConfig]] to map.\r\n * @chainable\r\n */\r\n mapRoute(config: RouteConfig): RouterConfiguration {\r\n this.instructions.push(router => {\r\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\r\n\r\n let navModel;\r\n for (let i = 0, ii = routeConfigs.length; i < ii; ++i) {\r\n let routeConfig = routeConfigs[i];\r\n routeConfig.settings = routeConfig.settings || {};\r\n if (!navModel) {\r\n navModel = router.createNavModel(routeConfig);\r\n }\r\n\r\n router.addRoute(routeConfig, navModel);\r\n }\r\n });\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Registers an unknown route handler to be run when the URL fragment doesn't match any registered routes.\r\n *\r\n * @param config A string containing a moduleId to load, or a [[RouteConfig]], or a function that takes the\r\n * [[NavigationInstruction]] and selects a moduleId to load.\r\n * @chainable\r\n */\r\n mapUnknownRoutes(config: RouteConfigSpecifier): RouterConfiguration {\r\n this.unknownRouteConfig = config;\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current configuration to the specified [[Router]].\r\n *\r\n * @param router The [[Router]] to apply the configuration to.\r\n */\r\n exportToRouter(router: Router): void {\r\n let instructions = this.instructions;\r\n for (let i = 0, ii = instructions.length; i < ii; ++i) {\r\n instructions[i](router);\r\n }\r\n\r\n let { title, titleSeparator, unknownRouteConfig, _fallbackRoute, viewPortDefaults } = this;\r\n\r\n if (title) {\r\n router.title = title;\r\n }\r\n\r\n if (titleSeparator) {\r\n router.titleSeparator = titleSeparator;\r\n }\r\n\r\n if (unknownRouteConfig) {\r\n router.handleUnknownRoutes(unknownRouteConfig);\r\n }\r\n\r\n if (_fallbackRoute) {\r\n router.fallbackRoute = _fallbackRoute;\r\n }\r\n\r\n if (viewPortDefaults) {\r\n router.useViewPortDefaults(viewPortDefaults);\r\n }\r\n\r\n Object.assign(router.options, this.options);\r\n\r\n let pipelineSteps = this.pipelineSteps;\r\n let pipelineStepCount = pipelineSteps.length;\r\n if (pipelineStepCount) {\r\n if (!router.isRoot) {\r\n throw new Error('Pipeline steps can only be added to the root router');\r\n }\r\n\r\n let pipelineProvider = router.pipelineProvider;\r\n for (let i = 0, ii = pipelineStepCount; i < ii; ++i) {\r\n let { name, step } = pipelineSteps[i];\r\n pipelineProvider.addStep(name, step);\r\n }\r\n }\r\n }\r\n}\r\n","import { RouteRecognizer, RouteHandler, ConfigurableRoute, State, RecognizedRoute } from 'aurelia-route-recognizer';\nimport { Container } from 'aurelia-dependency-injection';\nimport { History, NavigationOptions } from 'aurelia-history';\nimport { NavigationInstruction, NavigationInstructionInit } from './navigation-instruction';\nimport { NavModel } from './nav-model';\nimport { RouterConfiguration } from './router-configuration';\nimport {\n _ensureArrayWithSingleRoutePerConfig,\n _normalizeAbsolutePath,\n _createRootedPath,\n _resolveUrl\n} from './util';\nimport { NavigationResult, RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces';\nimport { PipelineProvider } from './pipeline-provider';\n\n/**@internal */\ndeclare module 'aurelia-history' {\n interface History {\n // This is wrong, as it's an implementation detail from aurelia-history-browser\n // but we are poking it in here so probably will need to make it official in `aurelia-history`\n /**\n * A private flag of Aurelia History implementation to indicate if push state should be used\n */\n _hasPushState: boolean;\n\n previousLocation: string;\n }\n}\n\n/**@internal */\ndeclare module 'aurelia-route-recognizer' {\n interface State {\n types: {\n dynamics: DynamicSegment;\n stars: StarSegment;\n };\n }\n\n interface RouteHandler {\n navigationStrategy?: (instruction: NavigationInstruction) => any;\n }\n\n interface RecognizedRoute {\n config?: RouteConfig;\n queryParams?: Record;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise);\n\n/**\n * The primary class responsible for handling routing and navigation.\n */\nexport class Router {\n\n /**\n * Container associated with this router. Also used to create child container for creating child router.\n */\n container: Container;\n\n /**\n * History instance of Aurelia abstract class for wrapping platform history global object\n */\n history: History;\n\n /**\n * A registry of registered viewport. Will be used to handle process navigation instruction route loading\n * and dom swapping\n */\n viewPorts: Record;\n\n /**\n * List of route configs registered with this router\n */\n routes: RouteConfig[];\n\n /**\n * The [[Router]]'s current base URL, typically based on the [[Router.currentInstruction]].\n */\n baseUrl: string;\n\n /**\n * If defined, used in generation of document title for [[Router]]'s routes.\n */\n title: string | undefined;\n\n /**\n * The separator used in the document title between [[Router]]'s routes.\n */\n titleSeparator: string | undefined;\n\n /**\n * True if the [[Router]] has been configured.\n */\n isConfigured: boolean;\n\n /**\n * True if the [[Router]] is currently processing a navigation.\n */\n isNavigating: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigate function(s).\n */\n isExplicitNavigation: boolean;\n\n /**\n * True if the [[Router]] is navigating due to explicit call to navigateBack function.\n */\n isExplicitNavigationBack: boolean;\n\n /**\n * True if the [[Router]] is navigating into the app for the first time in the browser session.\n */\n isNavigatingFirst: boolean;\n\n /**\n * True if the [[Router]] is navigating to a page instance not in the browser session history.\n */\n isNavigatingNew: boolean;\n\n /**\n * True if the [[Router]] is navigating forward in the browser session history.\n */\n isNavigatingForward: boolean;\n\n /**\n * True if the [[Router]] is navigating back in the browser session history.\n */\n isNavigatingBack: boolean;\n\n /**\n * True if the [[Router]] is navigating due to a browser refresh.\n */\n isNavigatingRefresh: boolean;\n\n /**\n * True if the previous instruction successfully completed the CanDeactivatePreviousStep in the current navigation.\n */\n couldDeactivate: boolean;\n\n /**\n * The currently active navigation tracker.\n */\n currentNavigationTracker: number;\n\n /**\n * The navigation models for routes that specified [[RouteConfig.nav]].\n */\n navigation: NavModel[];\n\n /**\n * The currently active navigation instruction.\n */\n currentInstruction: NavigationInstruction;\n\n /**\n * The parent router, or null if this instance is not a child router.\n */\n parent: Router = null;\n\n options: any = {};\n\n /**\n * The defaults used when a viewport lacks specified content\n */\n viewPortDefaults: Record = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise;\n /**@internal */\n fallbackRoute: string;\n /**@internal */\n pipelineProvider: PipelineProvider;\n /**@internal */\n _fallbackOrder: number;\n /**@internal */\n _recognizer: RouteRecognizer;\n /**@internal */\n _childRecognizer: RouteRecognizer;\n /**@internal */\n _configuredPromise: Promise;\n /**@internal */\n _resolveConfiguredPromise: (value?: any) => void;\n\n /**\n * Extension point to transform the document title before it is built and displayed.\n * By default, child routers delegate to the parent router, and the app router\n * returns the title unchanged.\n */\n transformTitle: (title: string) => string = (title: string) => {\n if (this.parent) {\n return this.parent.transformTitle(title);\n }\n return title;\n }\n\n /**\n * @param container The [[Container]] to use when child routers.\n * @param history The [[History]] implementation to delegate navigation requests to.\n */\n constructor(container: Container, history: History) {\n this.container = container;\n this.history = history;\n this.reset();\n }\n\n /**\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\n */\n reset() {\n this.viewPorts = {};\n this.routes = [];\n this.baseUrl = '';\n this.isConfigured = false;\n this.isNavigating = false;\n this.isExplicitNavigation = false;\n this.isExplicitNavigationBack = false;\n this.isNavigatingFirst = false;\n this.isNavigatingNew = false;\n this.isNavigatingRefresh = false;\n this.isNavigatingForward = false;\n this.isNavigatingBack = false;\n this.couldDeactivate = false;\n this.navigation = [];\n this.currentInstruction = null;\n this.viewPortDefaults = {};\n this._fallbackOrder = 100;\n this._recognizer = new RouteRecognizer();\n this._childRecognizer = new RouteRecognizer();\n this._configuredPromise = new Promise(resolve => {\n this._resolveConfiguredPromise = resolve;\n });\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] is the root in the router tree. I.e., it has no parent.\n */\n get isRoot(): boolean {\n return !this.parent;\n }\n\n /**\n * Registers a viewPort to be used as a rendering target for activated routes.\n *\n * @param viewPort The viewPort.\n * @param name The name of the viewPort. 'default' if unspecified.\n */\n registerViewPort(viewPort: /*ViewPort*/any, name?: string): void {\n name = name || 'default';\n this.viewPorts[name] = viewPort;\n }\n\n /**\n * Returns a Promise that resolves when the router is configured.\n */\n ensureConfigured(): Promise {\n return this._configuredPromise;\n }\n\n /**\n * Configures the router.\n *\n * @param callbackOrConfig The [[RouterConfiguration]] or a callback that takes a [[RouterConfiguration]].\n */\n configure(callbackOrConfig: RouterConfiguration | ((config: RouterConfiguration) => RouterConfiguration)): Promise {\n this.isConfigured = true;\n\n let result: RouterConfigurationResolution = callbackOrConfig as RouterConfiguration;\n let config: RouterConfiguration;\n if (typeof callbackOrConfig === 'function') {\n config = new RouterConfiguration();\n result = callbackOrConfig(config);\n }\n\n return Promise\n .resolve(result)\n .then((c) => {\n if (c && (c as RouterConfiguration).exportToRouter) {\n config = c;\n }\n\n config.exportToRouter(this);\n this.isConfigured = true;\n this._resolveConfiguredPromise();\n });\n }\n\n /**\n * Navigates to a new location.\n *\n * @param fragment The URL fragment to use as the navigation destination.\n * @param options The navigation options.\n */\n navigate(fragment: string, options?: NavigationOptions): NavigationResult {\n if (!this.isConfigured && this.parent) {\n return this.parent.navigate(fragment, options);\n }\n\n this.isExplicitNavigation = true;\n return this.history.navigate(_resolveUrl(fragment, this.baseUrl, this.history._hasPushState), options);\n }\n\n /**\n * Navigates to a new location corresponding to the route and params specified. Equivallent to [[Router.generate]] followed\n * by [[Router.navigate]].\n *\n * @param route The name of the route to use when generating the navigation location.\n * @param params The route parameters to be used when populating the route pattern.\n * @param options The navigation options.\n */\n navigateToRoute(route: string, params?: any, options?: NavigationOptions): NavigationResult {\n let path = this.generate(route, params);\n return this.navigate(path, options);\n }\n\n /**\n * Navigates back to the most recent location in history.\n */\n navigateBack(): void {\n this.isExplicitNavigationBack = true;\n this.history.navigateBack();\n }\n\n /**\n * Creates a child router of the current router.\n *\n * @param container The [[Container]] to provide to the child router. Uses the current [[Router]]'s [[Container]] if unspecified.\n * @returns {Router} The new child Router.\n */\n createChild(container?: Container): Router {\n let childRouter = new Router(container || this.container.createChild(), this.history);\n childRouter.parent = this;\n return childRouter;\n }\n\n /**\n * Generates a URL fragment matching the specified route pattern.\n *\n * @param name The name of the route whose pattern should be used to generate the fragment.\n * @param params The route params to be used to populate the route pattern.\n * @param options If options.absolute = true, then absolute url will be generated; otherwise, it will be relative url.\n * @returns {string} A string containing the generated URL fragment.\n */\n generate(nameOrRoute: string | RouteConfig, params: any = {}, options: any = {}): string {\n // A child recognizer generates routes for potential child routes. Any potential child route is added\n // to the childRoute property of params for the childRouter to recognize. When generating routes, we\n // use the childRecognizer when childRoute params are available to generate a child router enabled route.\n let recognizer = 'childRoute' in params ? this._childRecognizer : this._recognizer;\n let hasRoute = recognizer.hasRoute(nameOrRoute as string | RouteHandler);\n if (!hasRoute) {\n if (this.parent) {\n return this.parent.generate(nameOrRoute, params, options);\n }\n throw new Error(`A route with name '${nameOrRoute}' could not be found. Check that \\`name: '${nameOrRoute}'\\` was specified in the route's config.`);\n }\n let path = recognizer.generate(nameOrRoute as string | RouteHandler, params);\n let rootedPath = _createRootedPath(path, this.baseUrl, this.history._hasPushState, options.absolute);\n return options.absolute ? `${this.history.getAbsoluteRoot()}${rootedPath}` : rootedPath;\n }\n\n /**\n * Creates a [[NavModel]] for the specified route config.\n *\n * @param config The route config.\n */\n createNavModel(config: RouteConfig): NavModel {\n let navModel = new NavModel(\n this,\n 'href' in config\n ? config.href\n // potential error when config.route is a string[] ?\n : config.route as string);\n navModel.title = config.title;\n navModel.order = config.nav;\n navModel.href = config.href;\n navModel.settings = config.settings;\n navModel.config = config;\n\n return navModel;\n }\n\n /**\n * Registers a new route with the router.\n *\n * @param config The [[RouteConfig]].\n * @param navModel The [[NavModel]] to use for the route. May be omitted for single-pattern routes.\n */\n addRoute(config: RouteConfig, navModel?: NavModel): void {\n if (Array.isArray(config.route)) {\n let routeConfigs = _ensureArrayWithSingleRoutePerConfig(config);\n // the following is wrong. todo: fix this after TS refactoring release\n routeConfigs.forEach(this.addRoute.bind(this));\n return;\n }\n\n validateRouteConfig(config);\n\n if (!('viewPorts' in config) && !config.navigationStrategy) {\n config.viewPorts = {\n 'default': {\n moduleId: config.moduleId,\n view: config.view\n }\n };\n }\n\n if (!navModel) {\n navModel = this.createNavModel(config);\n }\n\n this.routes.push(config);\n\n let path = config.route;\n if (path.charAt(0) === '/') {\n path = path.substr(1);\n }\n let caseSensitive = config.caseSensitive === true;\n let state: State = this._recognizer.add({\n path: path,\n handler: config as RouteHandler,\n caseSensitive: caseSensitive\n } as ConfigurableRoute);\n\n if (path) {\n let settings = config.settings;\n delete config.settings;\n let withChild = JSON.parse(JSON.stringify(config));\n config.settings = settings;\n withChild.route = `${path}/*childRoute`;\n withChild.hasChildRouter = true;\n this._childRecognizer.add({\n path: withChild.route,\n handler: withChild,\n caseSensitive: caseSensitive\n });\n\n withChild.navModel = navModel;\n withChild.settings = config.settings;\n withChild.navigationStrategy = config.navigationStrategy;\n }\n\n config.navModel = navModel;\n\n let navigation = this.navigation;\n\n if ((navModel.order || navModel.order === 0) && navigation.indexOf(navModel) === -1) {\n if ((!navModel.href && navModel.href !== '') && (state.types.dynamics || state.types.stars)) {\n throw new Error('Invalid route config for \"' + config.route + '\" : dynamic routes must specify an \"href:\" to be included in the navigation model.');\n }\n\n if (typeof navModel.order !== 'number') {\n navModel.order = ++this._fallbackOrder;\n }\n\n navigation.push(navModel);\n // this is a potential error / inconsistency between browsers\n //\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n // If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other,\n // but sorted with respect to all different elements.\n // Note: the ECMAscript standard does not guarantee this behaviour,\n // and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.\n navigation.sort((a, b) => a.order - b.order);\n }\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] or one of its ancestors has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasRoute(name: string): boolean {\n return !!(this._recognizer.hasRoute(name) || this.parent && this.parent.hasRoute(name));\n }\n\n /**\n * Gets a value indicating whether or not this [[Router]] has a route registered with the specified name.\n *\n * @param name The name of the route to check.\n */\n hasOwnRoute(name: string): boolean {\n return this._recognizer.hasRoute(name);\n }\n\n /**\n * Register a handler to use when the incoming URL fragment doesn't match any registered routes.\n *\n * @param config The moduleId, or a function that selects the moduleId, or a [[RouteConfig]].\n */\n handleUnknownRoutes(config?: RouteConfigSpecifier): void {\n if (!config) {\n throw new Error('Invalid unknown route handler');\n }\n\n this.catchAllHandler = instruction => {\n return this\n ._createRouteConfig(config, instruction)\n .then(c => {\n instruction.config = c;\n return instruction;\n });\n };\n }\n\n /**\n * Updates the document title using the current navigation instruction.\n */\n updateTitle(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n return parentRouter.updateTitle();\n }\n\n let currentInstruction = this.currentInstruction;\n if (currentInstruction) {\n currentInstruction._updateTitle();\n }\n return undefined;\n }\n\n /**\n * Updates the navigation routes with hrefs relative to the current location.\n * Note: This method will likely move to a plugin in a future release.\n */\n refreshNavigation(): void {\n let nav = this.navigation;\n\n for (let i = 0, length = nav.length; i < length; i++) {\n let current = nav[i];\n if (!current.config.href) {\n current.href = _createRootedPath(current.relativeHref, this.baseUrl, this.history._hasPushState);\n } else {\n current.href = _normalizeAbsolutePath(current.config.href, this.history._hasPushState);\n }\n }\n }\n\n /**\n * Sets the default configuration for the view ports. This specifies how to\n * populate a view port for which no module is specified. The default is\n * an empty view/view-model pair.\n */\n useViewPortDefaults($viewPortDefaults: Record): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record = $viewPortDefaults;\n for (let viewPortName in viewPortDefaults) {\n let viewPortConfig = viewPortDefaults[viewPortName];\n this.viewPortDefaults[viewPortName] = {\n moduleId: viewPortConfig.moduleId\n };\n }\n }\n\n /**@internal */\n _refreshBaseUrl(): void {\n let parentRouter = this.parent;\n if (parentRouter) {\n this.baseUrl = generateBaseUrl(parentRouter, parentRouter.currentInstruction);\n }\n }\n\n /**@internal */\n _createNavigationInstruction(url: string = '', parentInstruction: NavigationInstruction = null): Promise {\n let fragment = url;\n let queryString = '';\n\n let queryIndex = url.indexOf('?');\n if (queryIndex !== -1) {\n fragment = url.substr(0, queryIndex);\n queryString = url.substr(queryIndex + 1);\n }\n\n let urlRecognizationResults = this._recognizer.recognize(url) as IRouteRecognizationResults;\n if (!urlRecognizationResults || !urlRecognizationResults.length) {\n urlRecognizationResults = this._childRecognizer.recognize(url) as IRouteRecognizationResults;\n }\n\n let instructionInit: NavigationInstructionInit = {\n fragment,\n queryString,\n config: null,\n parentInstruction,\n previousInstruction: this.currentInstruction,\n router: this,\n options: {\n compareQueryParams: this.options.compareQueryParams\n }\n };\n\n let result: Promise;\n\n if (urlRecognizationResults && urlRecognizationResults.length) {\n let first = urlRecognizationResults[0];\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: first.params,\n queryParams: first.queryParams || urlRecognizationResults.queryParams,\n config: first.config || first.handler\n }));\n\n if (typeof first.handler === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler, first);\n } else if (first.handler && typeof first.handler.navigationStrategy === 'function') {\n result = evaluateNavigationStrategy(instruction, first.handler.navigationStrategy, first.handler);\n } else {\n result = Promise.resolve(instruction);\n }\n } else if (this.catchAllHandler) {\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n config: null // config will be created by the catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, this.catchAllHandler);\n } else if (this.parent) {\n let router = this._parentCatchAllHandler(this.parent);\n\n if (router) {\n let newParentInstruction = this._findParentInstructionFromRouter(router, parentInstruction);\n\n let instruction = new NavigationInstruction(Object.assign({}, instructionInit, {\n params: { path: fragment },\n queryParams: urlRecognizationResults ? urlRecognizationResults.queryParams : {},\n router: router,\n parentInstruction: newParentInstruction,\n parentCatchHandler: true,\n config: null // config will be created by the chained parent catchAllHandler\n }));\n\n result = evaluateNavigationStrategy(instruction, router.catchAllHandler);\n }\n }\n\n if (result && parentInstruction) {\n this.baseUrl = generateBaseUrl(this.parent, parentInstruction);\n }\n\n return result || Promise.reject(new Error(`Route not found: ${url}`));\n }\n\n /**@internal */\n _findParentInstructionFromRouter(router: Router, instruction: NavigationInstruction): NavigationInstruction {\n if (instruction.router === router) {\n instruction.fragment = router.baseUrl; // need to change the fragment in case of a redirect instead of moduleId\n return instruction;\n } else if (instruction.parentInstruction) {\n return this._findParentInstructionFromRouter(router, instruction.parentInstruction);\n }\n return undefined;\n }\n\n /**@internal */\n _parentCatchAllHandler(router: Router): Router | false {\n if (router.catchAllHandler) {\n return router;\n } else if (router.parent) {\n return this._parentCatchAllHandler(router.parent);\n }\n return false;\n }\n\n /**\n * @internal\n */\n _createRouteConfig(config: RouteConfigSpecifier, instruction: NavigationInstruction): Promise {\n return Promise\n .resolve(config)\n .then((c: any) => {\n if (typeof c === 'string') {\n return { moduleId: c } as RouteConfig;\n } else if (typeof c === 'function') {\n return c(instruction);\n }\n\n return c;\n })\n // typing here could be either RouteConfig or RedirectConfig\n // but temporarily treat both as RouteConfig\n // todo: improve typings precision\n .then((c: string | RouteConfig) => typeof c === 'string' ? { moduleId: c } as RouteConfig : c)\n .then((c: RouteConfig) => {\n c.route = instruction.params.path;\n validateRouteConfig(c);\n\n if (!c.navModel) {\n c.navModel = this.createNavModel(c);\n }\n\n return c;\n });\n }\n}\n\n/* @internal exported for unit testing */\nexport const generateBaseUrl = (router: Router, instruction: NavigationInstruction): string => {\n return `${router.baseUrl || ''}${instruction.getBaseUrl() || ''}`;\n};\n\n/* @internal exported for unit testing */\nexport const validateRouteConfig = (config: RouteConfig): void => {\n if (typeof config !== 'object') {\n throw new Error('Invalid Route Config');\n }\n\n if (typeof config.route !== 'string') {\n let name = config.name || '(no name)';\n throw new Error('Invalid Route Config for \"' + name + '\": You must specify a \"route:\" pattern.');\n }\n\n if (!('redirect' in config || config.moduleId || config.navigationStrategy || config.viewPorts)) {\n throw new Error('Invalid Route Config for \"' + config.route + '\": You must specify a \"moduleId:\", \"redirect:\", \"navigationStrategy:\", or \"viewPorts:\".');\n }\n};\n\n/* @internal exported for unit testing */\nexport const evaluateNavigationStrategy = (\n instruction: NavigationInstruction,\n evaluator: Function,\n context?: any\n): Promise => {\n return Promise\n .resolve(evaluator.call(context, instruction))\n .then(() => {\n if (!('viewPorts' in instruction.config)) {\n instruction.config.viewPorts = {\n 'default': {\n moduleId: instruction.config.moduleId\n }\n };\n }\n\n return instruction;\n });\n};\n\ninterface IRouteRecognizationResults extends Array {\n queryParams: Record;\n}\n","import { PipelineStatus } from './pipeline-status';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Next, StepRunnerFunction, NextCompletionHandler } from './interfaces';\r\n\r\n/**@internal exported for unit testing */\r\nexport const createNextFn = (instruction: NavigationInstruction, steps: StepRunnerFunction[]): Next => {\r\n let index = -1;\r\n const next: Next = function() {\r\n index++;\r\n\r\n if (index < steps.length) {\r\n let currentStep = steps[index];\r\n\r\n try {\r\n return currentStep(instruction, next);\r\n } catch (e) {\r\n return next.reject(e);\r\n }\r\n } else {\r\n return next.complete();\r\n }\r\n } as Next;\r\n\r\n next.complete = createCompletionHandler(next, PipelineStatus.Completed);\r\n next.cancel = createCompletionHandler(next, PipelineStatus.Canceled);\r\n next.reject = createCompletionHandler(next, PipelineStatus.Rejected);\r\n\r\n return next;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const createCompletionHandler = (next: Next, status: PipelineStatus): NextCompletionHandler => {\r\n return (output: any) => Promise\r\n .resolve({\r\n status,\r\n output,\r\n completed: status === PipelineStatus.Completed\r\n });\r\n};\r\n","import { PipelineStep, PipelineResult, Next, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { createNextFn } from './next';\r\n\r\n/**\r\n * The class responsible for managing and processing the navigation pipeline.\r\n */\r\nexport class Pipeline {\r\n /**\r\n * The pipeline steps. And steps added via addStep will be converted to a function\r\n * The actualy running functions with correct step contexts of this pipeline\r\n */\r\n steps: StepRunnerFunction[] = [];\r\n\r\n /**\r\n * Adds a step to the pipeline.\r\n *\r\n * @param step The pipeline step.\r\n */\r\n addStep(step: StepRunnerFunction | PipelineStep | IPipelineSlot): Pipeline {\r\n let run;\r\n\r\n if (typeof step === 'function') {\r\n run = step;\r\n } else if (typeof step.getSteps === 'function') {\r\n // getSteps is to enable support open slots\r\n // where devs can add multiple steps into the same slot name\r\n let steps = step.getSteps();\r\n for (let i = 0, l = steps.length; i < l; i++) {\r\n this.addStep(steps[i]);\r\n }\r\n\r\n return this;\r\n } else {\r\n run = (step as PipelineStep).run.bind(step);\r\n }\r\n\r\n this.steps.push(run);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Runs the pipeline.\r\n *\r\n * @param instruction The navigation instruction to process.\r\n */\r\n run(instruction: NavigationInstruction): Promise {\r\n const nextFn = createNextFn(instruction, this.steps);\r\n return nextFn();\r\n }\r\n}\r\n","import { NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-history' {\r\n interface NavigationOptions {\r\n useAppRouter?: boolean;\r\n }\r\n}\r\n\r\n/**\r\n* When a navigation command is encountered, the current navigation\r\n* will be cancelled and control will be passed to the navigation\r\n* command so it can determine the correct action.\r\n*/\r\nexport interface NavigationCommand {\r\n navigate: (router: Router) => void;\r\n /**@internal */\r\n shouldContinueProcessing?: boolean;\r\n /**@internal */\r\n setRouter?: (router: Router) => void;\r\n}\r\n\r\n/**\r\n* Determines if the provided object is a navigation command.\r\n* A navigation command is anything with a navigate method.\r\n*\r\n* @param obj The object to check.\r\n*/\r\nexport function isNavigationCommand(obj: any): obj is NavigationCommand {\r\n return obj && typeof obj.navigate === 'function';\r\n}\r\n\r\n/**\r\n* Used during the activation lifecycle to cause a redirect.\r\n*/\r\nexport class Redirect implements NavigationCommand {\r\n\r\n url: string;\r\n /**@internal */\r\n options: NavigationOptions;\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n private router: Router;\r\n\r\n /**\r\n * @param url The URL fragment to use as the navigation destination.\r\n * @param options The navigation options.\r\n */\r\n constructor(url: string, options: NavigationOptions = {}) {\r\n this.url = url;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigate(this.url, this.options);\r\n }\r\n}\r\n\r\n/**\r\n * Used during the activation lifecycle to cause a redirect to a named route.\r\n */\r\nexport class RedirectToRoute implements NavigationCommand {\r\n\r\n route: string;\r\n params: any;\r\n /**@internal */\r\n options: NavigationOptions;\r\n\r\n /**@internal */\r\n shouldContinueProcessing: boolean;\r\n\r\n /**@internal */\r\n router: Router;\r\n\r\n /**\r\n * @param route The name of the route.\r\n * @param params The parameters to be sent to the activation method.\r\n * @param options The options to use for navigation.\r\n */\r\n constructor(route: string, params: any = {}, options: NavigationOptions = {}) {\r\n this.route = route;\r\n this.params = params;\r\n this.options = Object.assign({ trigger: true, replace: true }, options);\r\n this.shouldContinueProcessing = false;\r\n }\r\n\r\n /**\r\n * Called by the activation system to set the child router.\r\n *\r\n * @param router The router.\r\n */\r\n setRouter(router: Router): void {\r\n this.router = router;\r\n }\r\n\r\n /**\r\n * Called by the navigation pipeline to navigate.\r\n *\r\n * @param appRouter The router to be redirected.\r\n */\r\n navigate(appRouter: Router): void {\r\n let navigatingRouter = this.options.useAppRouter ? appRouter : (this.router || appRouter);\r\n navigatingRouter.navigateToRoute(this.route, this.params, this.options);\r\n }\r\n}\r\n","import { ViewPortPlan, ViewPortInstruction, RouteConfig, ViewPort } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { InternalActivationStrategy, ActivationStrategyType } from './activation-strategy';\r\n\r\ntype ViewPortPlansRecord = Record;\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport function _buildNavigationPlan(\r\n instruction: NavigationInstruction,\r\n forceLifecycleMinimum?: boolean\r\n): Promise {\r\n let config = instruction.config;\r\n\r\n if ('redirect' in config) {\r\n return buildRedirectPlan(instruction);\r\n }\r\n\r\n const prevInstruction = instruction.previousInstruction;\r\n const defaultViewPortConfigs = instruction.router.viewPortDefaults;\r\n\r\n if (prevInstruction) {\r\n return buildTransitionPlans(instruction, prevInstruction, defaultViewPortConfigs, forceLifecycleMinimum);\r\n }\r\n\r\n // first navigation, only need to prepare a few information for each viewport plan\r\n const viewPortPlans: ViewPortPlansRecord = {};\r\n let viewPortConfigs = config.viewPorts;\r\n for (let viewPortName in viewPortConfigs) {\r\n let viewPortConfig = viewPortConfigs[viewPortName];\r\n if (viewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n viewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n strategy: InternalActivationStrategy.Replace,\r\n config: viewPortConfig\r\n };\r\n }\r\n\r\n return Promise.resolve(viewPortPlans);\r\n}\r\n\r\n/**\r\n * Build redirect plan based on config of a navigation instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const buildRedirectPlan = (instruction: NavigationInstruction) => {\r\n const config = instruction.config;\r\n const router = instruction.router;\r\n return router\r\n ._createNavigationInstruction(config.redirect)\r\n .then(redirectInstruction => {\r\n\r\n const params: Record = {};\r\n const originalInstructionParams = instruction.params;\r\n const redirectInstructionParams = redirectInstruction.params;\r\n\r\n for (let key in redirectInstructionParams) {\r\n // If the param on the redirect points to another param, e.g. { route: first/:this, redirect: second/:this }\r\n let val = redirectInstructionParams[key];\r\n if (typeof val === 'string' && val[0] === ':') {\r\n val = val.slice(1);\r\n // And if that param is found on the original instruction then use it\r\n if (val in originalInstructionParams) {\r\n params[key] = originalInstructionParams[val];\r\n }\r\n } else {\r\n params[key] = redirectInstructionParams[key];\r\n }\r\n }\r\n let redirectLocation = router.generate(redirectInstruction.config, params, instruction.options);\r\n\r\n // Special handling for child routes\r\n for (let key in originalInstructionParams) {\r\n redirectLocation = redirectLocation.replace(`:${key}`, originalInstructionParams[key]);\r\n }\r\n\r\n let queryString = instruction.queryString;\r\n if (queryString) {\r\n redirectLocation += '?' + queryString;\r\n }\r\n\r\n return Promise.resolve(new Redirect(redirectLocation));\r\n });\r\n};\r\n\r\n/**\r\n * @param viewPortPlans the Plan record that holds information about built plans\r\n * @internal exported for unit testing\r\n */\r\nexport const buildTransitionPlans = (\r\n currentInstruction: NavigationInstruction,\r\n previousInstruction: NavigationInstruction,\r\n defaultViewPortConfigs: Record,\r\n forceLifecycleMinimum?: boolean\r\n): Promise => {\r\n\r\n let viewPortPlans: ViewPortPlansRecord = {};\r\n let newInstructionConfig = currentInstruction.config;\r\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\r\n let pending: Promise[] = [];\r\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record;\r\n\r\n for (let viewPortName in previousViewPortInstructions) {\r\n\r\n const prevViewPortInstruction = previousViewPortInstructions[viewPortName];\r\n const prevViewPortComponent = prevViewPortInstruction.component;\r\n const newInstructionViewPortConfigs = newInstructionConfig.viewPorts as Record;\r\n\r\n // if this is invoked on a viewport without any changes, based on new url,\r\n // newViewPortConfig will be the existing viewport instruction\r\n let nextViewPortConfig = viewPortName in newInstructionViewPortConfigs\r\n ? newInstructionViewPortConfigs[viewPortName]\r\n : prevViewPortInstruction;\r\n\r\n if (nextViewPortConfig.moduleId === null && viewPortName in defaultViewPortConfigs) {\r\n nextViewPortConfig = defaultViewPortConfigs[viewPortName];\r\n }\r\n\r\n const viewPortActivationStrategy = determineActivationStrategy(\r\n currentInstruction,\r\n prevViewPortInstruction,\r\n nextViewPortConfig,\r\n hasNewParams,\r\n forceLifecycleMinimum\r\n );\r\n const viewPortPlan = viewPortPlans[viewPortName] = {\r\n name: viewPortName,\r\n // ViewPortInstruction can quack like a RouteConfig\r\n config: nextViewPortConfig as RouteConfig,\r\n prevComponent: prevViewPortComponent,\r\n prevModuleId: prevViewPortInstruction.moduleId,\r\n strategy: viewPortActivationStrategy\r\n } as ViewPortPlan;\r\n\r\n // recursively build nav plans for all existing child routers/viewports of this viewport\r\n // this is possible because existing child viewports and routers already have necessary information\r\n // to process the wildcard path from parent instruction\r\n if (viewPortActivationStrategy !== InternalActivationStrategy.Replace && prevViewPortInstruction.childRouter) {\r\n const path = currentInstruction.getWildcardPath();\r\n const task: Promise = prevViewPortInstruction\r\n .childRouter\r\n ._createNavigationInstruction(path, currentInstruction)\r\n .then((childInstruction: NavigationInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(\r\n childInstruction,\r\n // is it safe to assume viewPortPlan has not been changed from previous assignment?\r\n // if so, can just use local variable viewPortPlanStrategy\r\n // there could be user code modifying viewport plan during _createNavigationInstruction?\r\n viewPortPlan.strategy === InternalActivationStrategy.InvokeLifecycle\r\n )\r\n .then(childPlan => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n // for bluebird ?\r\n return null;\r\n });\r\n });\r\n\r\n pending.push(task);\r\n }\r\n }\r\n\r\n return Promise.all(pending).then(() => viewPortPlans);\r\n};\r\n\r\n/**\r\n * @param newViewPortConfig if this is invoked on a viewport without any changes, based on new url, newViewPortConfig will be the existing viewport instruction\r\n * @internal exported for unit testing\r\n */\r\nexport const determineActivationStrategy = (\r\n currentNavInstruction: NavigationInstruction,\r\n prevViewPortInstruction: ViewPortInstruction,\r\n newViewPortConfig: RouteConfig | ViewPortInstruction,\r\n // indicates whether there is difference between old and new url params\r\n hasNewParams: boolean,\r\n forceLifecycleMinimum?: boolean\r\n): ActivationStrategyType => {\r\n\r\n let newInstructionConfig = currentNavInstruction.config;\r\n let prevViewPortViewModel = prevViewPortInstruction.component.viewModel;\r\n let viewPortPlanStrategy: ActivationStrategyType;\r\n\r\n if (prevViewPortInstruction.moduleId !== newViewPortConfig.moduleId) {\r\n viewPortPlanStrategy = InternalActivationStrategy.Replace;\r\n } else if ('determineActivationStrategy' in prevViewPortViewModel) {\r\n viewPortPlanStrategy = prevViewPortViewModel.determineActivationStrategy(...currentNavInstruction.lifecycleArgs);\r\n } else if (newInstructionConfig.activationStrategy) {\r\n viewPortPlanStrategy = newInstructionConfig.activationStrategy;\r\n } else if (hasNewParams || forceLifecycleMinimum) {\r\n viewPortPlanStrategy = InternalActivationStrategy.InvokeLifecycle;\r\n } else {\r\n viewPortPlanStrategy = InternalActivationStrategy.NoChange;\r\n }\r\n return viewPortPlanStrategy;\r\n};\r\n\r\n/**@internal exported for unit testing */\r\nexport const hasDifferentParameterValues = (prev: NavigationInstruction, next: NavigationInstruction): boolean => {\r\n let prevParams = prev.params;\r\n let nextParams = next.params;\r\n let nextWildCardName = next.config.hasChildRouter ? next.getWildCardName() : null;\r\n\r\n for (let key in nextParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevParams) {\r\n if (key === nextWildCardName) {\r\n continue;\r\n }\r\n\r\n if (prevParams[key] !== nextParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n if (!next.options.compareQueryParams) {\r\n return false;\r\n }\r\n\r\n let prevQueryParams = prev.queryParams;\r\n let nextQueryParams = next.queryParams;\r\n for (let key in nextQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n for (let key in prevQueryParams) {\r\n if (prevQueryParams[key] !== nextQueryParams[key]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n};\r\n","import { Next } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\n\r\n/**\r\n * Transform a navigation instruction into viewport plan record object,\r\n * or a redirect request if user viewmodel demands\r\n */\r\nexport class BuildNavigationPlanStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return _buildNavigationPlan(navigationInstruction)\r\n .then(plan => {\r\n if (plan instanceof Redirect) {\r\n return next.cancel(plan);\r\n }\r\n navigationInstruction.plan = plan;\r\n return next();\r\n })\r\n .catch(next.cancel);\r\n }\r\n}\r\n","import { RouteConfig, ViewPortComponent, ViewPortPlan, ViewPortInstruction } from './interfaces';\r\nimport { Redirect } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { _buildNavigationPlan } from './navigation-plan';\r\nimport { InternalActivationStrategy } from './activation-strategy';\r\nimport { RouteLoader } from './route-loader';\r\n\r\n/**\r\n * Loading plan calculated based on a navigration-instruction and a viewport plan\r\n */\r\ninterface ILoadingPlan {\r\n viewPortPlan: ViewPortPlan;\r\n navigationInstruction: NavigationInstruction;\r\n}\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadNewRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction\r\n): Promise => {\r\n let loadingPlans = determineLoadingPlans(navigationInstruction);\r\n let loadPromises = loadingPlans.map((loadingPlan: ILoadingPlan) => loadRoute(\r\n routeLoader,\r\n loadingPlan.navigationInstruction,\r\n loadingPlan.viewPortPlan\r\n ));\r\n\r\n return Promise.all(loadPromises);\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const determineLoadingPlans = (\r\n navigationInstruction: NavigationInstruction,\r\n loadingPlans: ILoadingPlan[] = []\r\n): ILoadingPlan[] => {\r\n let viewPortPlans: Record = navigationInstruction.plan;\r\n\r\n for (let viewPortName in viewPortPlans) {\r\n let viewPortPlan = viewPortPlans[viewPortName];\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (viewPortPlan.strategy === InternalActivationStrategy.Replace) {\r\n loadingPlans.push({ viewPortPlan, navigationInstruction } as ILoadingPlan);\r\n\r\n if (childNavInstruction) {\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n } else {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortName,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: viewPortPlan.prevModuleId,\r\n component: viewPortPlan.prevComponent\r\n }) as ViewPortInstruction;\r\n\r\n if (childNavInstruction) {\r\n viewPortInstruction.childNavigationInstruction = childNavInstruction;\r\n determineLoadingPlans(childNavInstruction, loadingPlans);\r\n }\r\n }\r\n }\r\n\r\n return loadingPlans;\r\n};\r\n\r\n/**\r\n * @internal Exported for unit testing\r\n */\r\nexport const loadRoute = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n viewPortPlan: ViewPortPlan\r\n): Promise => {\r\n let planConfig = viewPortPlan.config;\r\n let moduleId = planConfig ? planConfig.moduleId : null;\r\n\r\n return loadComponent(routeLoader, navigationInstruction, planConfig)\r\n .then((component) => {\r\n let viewPortInstruction = navigationInstruction.addViewPortInstruction({\r\n name: viewPortPlan.name,\r\n strategy: viewPortPlan.strategy,\r\n moduleId: moduleId,\r\n component: component\r\n }) as ViewPortInstruction;\r\n\r\n let childRouter = component.childRouter;\r\n if (childRouter) {\r\n let path = navigationInstruction.getWildcardPath();\r\n\r\n return childRouter\r\n ._createNavigationInstruction(path, navigationInstruction)\r\n .then((childInstruction) => {\r\n viewPortPlan.childNavigationInstruction = childInstruction;\r\n\r\n return _buildNavigationPlan(childInstruction)\r\n .then((childPlan) => {\r\n if (childPlan instanceof Redirect) {\r\n return Promise.reject(childPlan);\r\n }\r\n childInstruction.plan = childPlan;\r\n viewPortInstruction.childNavigationInstruction = childInstruction;\r\n\r\n return loadNewRoute(routeLoader, childInstruction);\r\n });\r\n });\r\n }\r\n // ts complains without this, though they are same\r\n return void 0;\r\n });\r\n};\r\n\r\n/**\r\n * Load a routed-component based on navigation instruction and route config\r\n * @internal exported for unit testing only\r\n */\r\nexport const loadComponent = (\r\n routeLoader: RouteLoader,\r\n navigationInstruction: NavigationInstruction,\r\n config: RouteConfig\r\n): Promise => {\r\n let router = navigationInstruction.router;\r\n let lifecycleArgs = navigationInstruction.lifecycleArgs;\r\n\r\n return Promise.resolve()\r\n .then(() => routeLoader.loadRoute(router, config, navigationInstruction))\r\n .then(\r\n /**\r\n * @param component an object carrying information about loaded route\r\n * typically contains information about view model, childContainer, view and router\r\n */\r\n (component: ViewPortComponent) => {\r\n let { viewModel, childContainer } = component;\r\n component.router = router;\r\n component.config = config;\r\n\r\n if ('configureRouter' in viewModel) {\r\n let childRouter = childContainer.getChildRouter();\r\n component.childRouter = childRouter;\r\n\r\n return childRouter\r\n .configure(c => viewModel.configureRouter(c, childRouter, lifecycleArgs[0], lifecycleArgs[1], lifecycleArgs[2]))\r\n .then(() => component);\r\n }\r\n\r\n return component;\r\n }\r\n );\r\n};\r\n","import { RouteConfig } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Abstract class that is responsible for loading view / view model from a route config\r\n * The default implementation can be found in `aurelia-templating-router`\r\n */\r\nexport class RouteLoader {\r\n /**\r\n * Load a route config based on its viewmodel / view configuration\r\n */\r\n // return typing: return typings used to be never\r\n // as it was a throw. Changing it to Promise should not cause any issues\r\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise {\r\n throw new Error('Route loaders must implement \"loadRoute(router, config, navigationInstruction)\".');\r\n }\r\n}\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { loadNewRoute } from './utilities-route-loading';\r\nimport { RouteLoader } from './route-loader';\r\n/**\r\n * A pipeline step responsible for loading a route config of a navigation instruction\r\n */\r\nexport class LoadRouteStep {\r\n /**@internal */\r\n static inject() { return [RouteLoader]; }\r\n /**\r\n * Route loader isntance that will handle loading route config\r\n * @internal\r\n */\r\n routeLoader: RouteLoader;\r\n constructor(routeLoader: RouteLoader) {\r\n this.routeLoader = routeLoader;\r\n }\r\n /**\r\n * Run the internal to load route config of a navigation instruction to prepare for next steps in the pipeline\r\n */\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return loadNewRoute(this.routeLoader, navigationInstruction)\r\n .then(next, next.cancel);\r\n }\r\n}\r\n","import { NavigationInstruction } from './navigation-instruction';\r\n\r\n/**\r\n * A pipeline step for instructing a piepline to commit changes on a navigation instruction\r\n */\r\nexport class CommitChangesStep {\r\n run(navigationInstruction: NavigationInstruction, next: Function): Promise {\r\n return navigationInstruction\r\n ._commitChanges(/*wait to swap?*/ true)\r\n .then(() => {\r\n navigationInstruction._updateTitle();\r\n return next();\r\n });\r\n }\r\n}\r\n","/**\r\n * An optional interface describing the available activation strategies.\r\n * @internal Used internally.\r\n */\r\nexport const enum InternalActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n NoChange = 'no-change',\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n InvokeLifecycle = 'invoke-lifecycle',\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n Replace = 'replace'\r\n}\r\n\r\n/**\r\n * The strategy to use when activating modules during navigation.\r\n */\r\n// kept for compat reason\r\nexport const activationStrategy: ActivationStrategy = {\r\n noChange: InternalActivationStrategy.NoChange,\r\n invokeLifecycle: InternalActivationStrategy.InvokeLifecycle,\r\n replace: InternalActivationStrategy.Replace\r\n};\r\n\r\n/**\r\n * An optional interface describing the available activation strategies.\r\n */\r\nexport interface ActivationStrategy {\r\n /**\r\n * Reuse the existing view model, without invoking Router lifecycle hooks.\r\n */\r\n noChange: 'no-change';\r\n /**\r\n * Reuse the existing view model, invoking Router lifecycle hooks.\r\n */\r\n invokeLifecycle: 'invoke-lifecycle';\r\n /**\r\n * Replace the existing view model, invoking Router lifecycle hooks.\r\n */\r\n replace: 'replace';\r\n}\r\n\r\n/**\r\n * Enum like type for activation strategy built-in values\r\n */\r\nexport type ActivationStrategyType = ActivationStrategy[keyof ActivationStrategy];\r\n","import { Next, ViewPortComponent, ViewPortPlan, ViewPortInstruction, LifecycleArguments } from './interfaces';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { activationStrategy } from './activation-strategy';\r\nimport { Router } from './router';\r\n\r\n/**\r\n * Recursively find list of deactivate-able view models\r\n * and invoke the either 'canDeactivate' or 'deactivate' on each\r\n * @internal exported for unit testing\r\n */\r\nexport const processDeactivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canDeactivate' | 'deactivate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let plan: Record = navigationInstruction.plan;\r\n let infos = findDeactivatable(plan, callbackName);\r\n let i = infos.length; // query from inside out\r\n\r\n function inspect(val: any): Promise {\r\n if (ignoreResult || shouldContinue(val)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n if (i--) {\r\n try {\r\n let viewModel = infos[i];\r\n let result = viewModel[callbackName](navigationInstruction);\r\n return processPotential(result, inspect, next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n navigationInstruction.router.couldDeactivate = true;\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\n/**\r\n * Recursively find and returns a list of deactivate-able view models\r\n * @internal exported for unit testing\r\n */\r\nexport const findDeactivatable = (\r\n plan: Record,\r\n callbackName: string,\r\n list: IActivatableInfo[] = []\r\n): any[] => {\r\n for (let viewPortName in plan) {\r\n let viewPortPlan = plan[viewPortName];\r\n let prevComponent = viewPortPlan.prevComponent;\r\n\r\n if ((viewPortPlan.strategy === activationStrategy.invokeLifecycle || viewPortPlan.strategy === activationStrategy.replace)\r\n && prevComponent\r\n ) {\r\n let viewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in viewModel) {\r\n list.push(viewModel);\r\n }\r\n }\r\n\r\n if (viewPortPlan.strategy === activationStrategy.replace && prevComponent) {\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n } else if (viewPortPlan.childNavigationInstruction) {\r\n findDeactivatable(viewPortPlan.childNavigationInstruction.plan, callbackName, list);\r\n }\r\n }\r\n\r\n return list;\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const addPreviousDeactivatable = (\r\n component: ViewPortComponent,\r\n callbackName: string,\r\n list: IActivatableInfo[]\r\n): void => {\r\n let childRouter = component.childRouter;\r\n\r\n if (childRouter && childRouter.currentInstruction) {\r\n let viewPortInstructions = childRouter.currentInstruction.viewPortInstructions;\r\n\r\n for (let viewPortName in viewPortInstructions) {\r\n let viewPortInstruction = viewPortInstructions[viewPortName];\r\n let prevComponent = viewPortInstruction.component;\r\n let prevViewModel = prevComponent.viewModel;\r\n\r\n if (callbackName in prevViewModel) {\r\n list.push(prevViewModel);\r\n }\r\n\r\n addPreviousDeactivatable(prevComponent, callbackName, list);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * @internal exported for unit testing\r\n */\r\nexport const processActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n next: Next,\r\n ignoreResult?: boolean\r\n): Promise => {\r\n let infos = findActivatable(navigationInstruction, callbackName);\r\n let length = infos.length;\r\n let i = -1; // query from top down\r\n\r\n function inspect(val: any, router: Router): Promise {\r\n if (ignoreResult || shouldContinue(val, router)) {\r\n return iterate();\r\n }\r\n\r\n return next.cancel(val);\r\n }\r\n\r\n function iterate(): Promise {\r\n i++;\r\n\r\n if (i < length) {\r\n try {\r\n let current = infos[i];\r\n let result = current.viewModel[callbackName](...current.lifecycleArgs);\r\n return processPotential(result, (val: any) => inspect(val, current.router), next.cancel);\r\n } catch (error) {\r\n return next.cancel(error);\r\n }\r\n }\r\n\r\n return next();\r\n }\r\n\r\n return iterate();\r\n};\r\n\r\ninterface IActivatableInfo {\r\n viewModel: any;\r\n lifecycleArgs: LifecycleArguments;\r\n router: Router;\r\n}\r\n\r\n/**\r\n * Find list of activatable view model and add to list (3rd parameter)\r\n * @internal exported for unit testing\r\n */\r\nexport const findActivatable = (\r\n navigationInstruction: NavigationInstruction,\r\n callbackName: 'canActivate' | 'activate',\r\n list: IActivatableInfo[] = [],\r\n router?: Router\r\n): IActivatableInfo[] => {\r\n let plan: Record = navigationInstruction.plan;\r\n\r\n Object\r\n .keys(plan)\r\n .forEach((viewPortName) => {\r\n let viewPortPlan = plan[viewPortName];\r\n let viewPortInstruction = navigationInstruction.viewPortInstructions[viewPortName] as ViewPortInstruction;\r\n let viewPortComponent = viewPortInstruction.component;\r\n let viewModel = viewPortComponent.viewModel;\r\n\r\n if (\r\n (viewPortPlan.strategy === activationStrategy.invokeLifecycle\r\n || viewPortPlan.strategy === activationStrategy.replace\r\n )\r\n && callbackName in viewModel\r\n ) {\r\n list.push({\r\n viewModel,\r\n lifecycleArgs: viewPortInstruction.lifecycleArgs,\r\n router\r\n });\r\n }\r\n\r\n let childNavInstruction = viewPortPlan.childNavigationInstruction;\r\n\r\n if (childNavInstruction) {\r\n findActivatable(\r\n childNavInstruction,\r\n callbackName,\r\n list,\r\n viewPortComponent.childRouter || router\r\n );\r\n }\r\n });\r\n\r\n return list;\r\n};\r\n\r\nconst shouldContinue = (output: T, router?: Router): boolean | T => {\r\n if (output instanceof Error) {\r\n return false;\r\n }\r\n\r\n if (isNavigationCommand(output)) {\r\n if (typeof output.setRouter === 'function') {\r\n output.setRouter(router);\r\n }\r\n\r\n return !!output.shouldContinueProcessing;\r\n }\r\n\r\n if (output === undefined) {\r\n return true;\r\n }\r\n\r\n return output;\r\n};\r\n\r\n/**\r\n * A basic interface for an Observable type\r\n */\r\nexport interface IObservable {\r\n subscribe(sub?: IObservableConfig): ISubscription;\r\n}\r\n\r\nexport interface IObservableConfig {\r\n next(): void;\r\n error(err?: any): void;\r\n complete(): void;\r\n}\r\n\r\n/**\r\n * A basic interface for a Subscription to an Observable\r\n */\r\ninterface ISubscription {\r\n unsubscribe(): void;\r\n}\r\n\r\ntype SafeSubscriptionFunc = (sub: SafeSubscription) => ISubscription;\r\n\r\n/**\r\n * wraps a subscription, allowing unsubscribe calls even if\r\n * the first value comes synchronously\r\n */\r\nclass SafeSubscription {\r\n\r\n private _subscribed: boolean;\r\n private _subscription: ISubscription;\r\n\r\n constructor(subscriptionFunc: SafeSubscriptionFunc) {\r\n this._subscribed = true;\r\n this._subscription = subscriptionFunc(this);\r\n\r\n if (!this._subscribed) {\r\n this.unsubscribe();\r\n }\r\n }\r\n\r\n get subscribed(): boolean {\r\n return this._subscribed;\r\n }\r\n\r\n unsubscribe(): void {\r\n if (this._subscribed && this._subscription) {\r\n this._subscription.unsubscribe();\r\n }\r\n\r\n this._subscribed = false;\r\n }\r\n}\r\n\r\n/**\r\n * A function to process return value from `activate`/`canActivate` steps\r\n * Supports observable/promise\r\n *\r\n * For observable, resolve at first next() or on complete()\r\n */\r\nconst processPotential = (obj: any, resolve: (val?: any) => any, reject: (err?: any) => any): any => {\r\n // if promise like\r\n if (obj && typeof obj.then === 'function') {\r\n return Promise.resolve(obj).then(resolve).catch(reject);\r\n }\r\n\r\n // if observable\r\n if (obj && typeof obj.subscribe === 'function') {\r\n let obs: IObservable = obj;\r\n return new SafeSubscription(sub => obs.subscribe({\r\n next() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n },\r\n error(error) {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n reject(error);\r\n }\r\n },\r\n complete() {\r\n if (sub.subscribed) {\r\n sub.unsubscribe();\r\n resolve(obj);\r\n }\r\n }\r\n }));\r\n }\r\n\r\n // else just resolve\r\n try {\r\n return resolve(obj);\r\n } catch (error) {\r\n return reject(error);\r\n }\r\n};\r\n","import { Next } from './interfaces';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { processDeactivatable, processActivatable } from './utilities-activation';\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canDeactivate` on a view model of a route\r\n */\r\nexport class CanDeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'canDeactivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `canActivate` on a view model of a route\r\n */\r\nexport class CanActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'canActivate', next);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `deactivate` on a view model of a route\r\n */\r\nexport class DeactivatePreviousStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processDeactivatable(navigationInstruction, 'deactivate', next, true);\r\n }\r\n}\r\n\r\n/**\r\n * A pipeline step responsible for finding and activating method `activate` on a view model of a route\r\n */\r\nexport class ActivateNextStep {\r\n run(navigationInstruction: NavigationInstruction, next: Next): Promise {\r\n return processActivatable(navigationInstruction, 'activate', next, true);\r\n }\r\n}\r\n","import { Container } from 'aurelia-dependency-injection';\r\nimport { Pipeline } from './pipeline';\r\nimport { BuildNavigationPlanStep } from './step-build-navigation-plan';\r\nimport { LoadRouteStep } from './step-load-route';\r\nimport { CommitChangesStep } from './step-commit-changes';\r\nimport { CanDeactivatePreviousStep, CanActivateNextStep, DeactivatePreviousStep, ActivateNextStep } from './step-activation';\r\nimport { PipelineStep, StepRunnerFunction, IPipelineSlot } from './interfaces';\r\nimport { PipelineSlotName } from './pipeline-slot-name';\r\n\r\n/**\r\n * A multi-slots Pipeline Placeholder Step for hooking into a pipeline execution\r\n */\r\nclass PipelineSlot implements IPipelineSlot {\r\n\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n slotName: string;\r\n /**@internal */\r\n slotAlias?: string;\r\n\r\n steps: (Function | PipelineStep)[] = [];\r\n\r\n constructor(container: Container, name: string, alias?: string) {\r\n this.container = container;\r\n this.slotName = name;\r\n this.slotAlias = alias;\r\n }\r\n\r\n getSteps(): (StepRunnerFunction | IPipelineSlot | PipelineStep)[] {\r\n return this.steps.map(x => this.container.get(x));\r\n }\r\n}\r\n\r\n/**\r\n * Class responsible for creating the navigation pipeline.\r\n */\r\nexport class PipelineProvider {\r\n\r\n /**@internal */\r\n static inject() { return [Container]; }\r\n /**@internal */\r\n container: Container;\r\n /**@internal */\r\n steps: (Function | PipelineSlot)[];\r\n\r\n constructor(container: Container) {\r\n this.container = container;\r\n this.steps = [\r\n BuildNavigationPlanStep,\r\n CanDeactivatePreviousStep, // optional\r\n LoadRouteStep,\r\n createPipelineSlot(container, PipelineSlotName.Authorize),\r\n CanActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreActivate, 'modelbind'),\r\n // NOTE: app state changes start below - point of no return\r\n DeactivatePreviousStep, // optional\r\n ActivateNextStep, // optional\r\n createPipelineSlot(container, PipelineSlotName.PreRender, 'precommit'),\r\n CommitChangesStep,\r\n createPipelineSlot(container, PipelineSlotName.PostRender, 'postcomplete')\r\n ];\r\n }\r\n\r\n /**\r\n * Create the navigation pipeline.\r\n */\r\n createPipeline(useCanDeactivateStep: boolean = true): Pipeline {\r\n let pipeline = new Pipeline();\r\n this.steps.forEach(step => {\r\n if (useCanDeactivateStep || step !== CanDeactivatePreviousStep) {\r\n pipeline.addStep(this.container.get(step));\r\n }\r\n });\r\n return pipeline;\r\n }\r\n\r\n /**@internal */\r\n _findStep(name: string): PipelineSlot {\r\n // Steps that are not PipelineSlots are constructor functions, and they will automatically fail. Probably.\r\n return this.steps.find(x => (x as PipelineSlot).slotName === name || (x as PipelineSlot).slotAlias === name) as PipelineSlot;\r\n }\r\n\r\n /**\r\n * Adds a step into the pipeline at a known slot location.\r\n */\r\n addStep(name: string, step: PipelineStep | Function): void {\r\n let found = this._findStep(name);\r\n if (found) {\r\n let slotSteps = found.steps;\r\n // prevent duplicates\r\n if (!slotSteps.includes(step)) {\r\n slotSteps.push(step);\r\n }\r\n } else {\r\n throw new Error(`Invalid pipeline slot name: ${name}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Removes a step from a slot in the pipeline\r\n */\r\n removeStep(name: string, step: PipelineStep): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n let slotSteps = slot.steps;\r\n slotSteps.splice(slotSteps.indexOf(step), 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clears all steps from a slot in the pipeline\r\n * @internal\r\n */\r\n _clearSteps(name: string = ''): void {\r\n let slot = this._findStep(name);\r\n if (slot) {\r\n slot.steps = [];\r\n }\r\n }\r\n\r\n /**\r\n * Resets all pipeline slots\r\n */\r\n reset(): void {\r\n this._clearSteps(PipelineSlotName.Authorize);\r\n this._clearSteps(PipelineSlotName.PreActivate);\r\n this._clearSteps(PipelineSlotName.PreRender);\r\n this._clearSteps(PipelineSlotName.PostRender);\r\n }\r\n}\r\n\r\n/**@internal */\r\nconst createPipelineSlot = (container: Container, name: PipelineSlotName, alias?: string): PipelineSlot => {\r\n return new PipelineSlot(container, name, alias);\r\n};\r\n","import * as LogManager from 'aurelia-logging';\r\nimport { Container } from 'aurelia-dependency-injection';\r\nimport { History, NavigationOptions } from 'aurelia-history';\r\nimport { Router } from './router';\r\nimport { PipelineProvider } from './pipeline-provider';\r\nimport { isNavigationCommand } from './navigation-commands';\r\nimport { EventAggregator } from 'aurelia-event-aggregator';\r\nimport { NavigationInstruction } from './navigation-instruction';\r\nimport { ViewPort, ConfiguresRouter, PipelineResult } from './interfaces';\r\nimport { RouterEvent } from './router-event';\r\nimport { RouterConfiguration } from './router-configuration';\r\n\r\n/**@internal */\r\ndeclare module 'aurelia-dependency-injection' {\r\n interface Container {\r\n viewModel?: any;\r\n }\r\n}\r\n\r\nconst logger = LogManager.getLogger('app-router');\r\n\r\n/**\r\n * The main application router.\r\n */\r\nexport class AppRouter extends Router {\r\n\r\n /**@internal */\r\n static inject() { return [Container, History, PipelineProvider, EventAggregator]; }\r\n\r\n events: EventAggregator;\r\n /**@internal */\r\n maxInstructionCount: number;\r\n /**@internal */\r\n _queue: NavigationInstruction[];\r\n /**@internal */\r\n isActive: boolean;\r\n\r\n constructor(container: Container, history: History, pipelineProvider: PipelineProvider, events: EventAggregator) {\r\n super(container, history); // Note the super will call reset internally.\r\n this.pipelineProvider = pipelineProvider;\r\n this.events = events;\r\n }\r\n\r\n /**\r\n * Fully resets the router's internal state. Primarily used internally by the framework when multiple calls to setRoot are made.\r\n * Use with caution (actually, avoid using this). Do not use this to simply change your navigation model.\r\n */\r\n reset(): void {\r\n super.reset();\r\n this.maxInstructionCount = 10;\r\n if (!this._queue) {\r\n this._queue = [];\r\n } else {\r\n this._queue.length = 0;\r\n }\r\n }\r\n\r\n /**\r\n * Loads the specified URL.\r\n *\r\n * @param url The URL fragment to load.\r\n */\r\n loadUrl(url: string): Promise {\r\n return this\r\n ._createNavigationInstruction(url)\r\n .then(instruction => this._queueInstruction(instruction))\r\n .catch(error => {\r\n logger.error(error);\r\n restorePreviousLocation(this);\r\n });\r\n }\r\n\r\n /**\r\n * Registers a viewPort to be used as a rendering target for activated routes.\r\n *\r\n * @param viewPort The viewPort. This is typically a element in Aurelia default impl\r\n * @param name The name of the viewPort. 'default' if unspecified.\r\n */\r\n registerViewPort(viewPort: /*ViewPort*/ any, name?: string): Promise {\r\n // having strong typing without changing public API\r\n const $viewPort: ViewPort = viewPort;\r\n super.registerViewPort($viewPort, name);\r\n\r\n // beside adding viewport to the registry of this instance\r\n // AppRouter also configure routing/history to start routing functionality\r\n // There are situation where there are more than 1 element at root view\r\n // in that case, still only activate once via the following guard\r\n if (!this.isActive) {\r\n const viewModel = this._findViewModel($viewPort);\r\n if ('configureRouter' in viewModel) {\r\n // If there are more than one element at root view\r\n // use this flag to guard against configure method being invoked multiple times\r\n // this flag is set inside method configure\r\n if (!this.isConfigured) {\r\n // replace the real resolve with a noop to guarantee that any action in base class Router\r\n // won't resolve the configurePromise prematurely\r\n const resolveConfiguredPromise = this._resolveConfiguredPromise;\r\n this._resolveConfiguredPromise = () => {/**/};\r\n return this\r\n .configure(config =>\r\n Promise\r\n .resolve(viewModel.configureRouter(config, this))\r\n // an issue with configure interface. Should be fixed there\r\n // todo: fix this via configure interface in router\r\n .then(() => config) as any\r\n )\r\n .then(() => {\r\n this.activate();\r\n resolveConfiguredPromise();\r\n });\r\n }\r\n } else {\r\n this.activate();\r\n }\r\n }\r\n // when a viewport is added dynamically to a root view that is already activated\r\n // just process the navigation instruction\r\n else {\r\n this._dequeueInstruction();\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n /**\r\n * Activates the router. This instructs the router to begin listening for history changes and processing instructions.\r\n *\r\n * @params options The set of options to activate the router with.\r\n */\r\n activate(options?: NavigationOptions): void {\r\n if (this.isActive) {\r\n return;\r\n }\r\n\r\n this.isActive = true;\r\n // route handler property is responsible for handling url change\r\n // the interface of aurelia-history isn't clear on this perspective\r\n this.options = Object.assign({ routeHandler: this.loadUrl.bind(this) }, this.options, options);\r\n this.history.activate(this.options);\r\n this._dequeueInstruction();\r\n }\r\n\r\n /**\r\n * Deactivates the router.\r\n */\r\n deactivate(): void {\r\n this.isActive = false;\r\n this.history.deactivate();\r\n }\r\n\r\n /**@internal */\r\n _queueInstruction(instruction: NavigationInstruction): Promise {\r\n return new Promise((resolve) => {\r\n instruction.resolve = resolve;\r\n this._queue.unshift(instruction);\r\n this._dequeueInstruction();\r\n });\r\n }\r\n\r\n /**@internal */\r\n _dequeueInstruction(instructionCount: number = 0): Promise {\r\n return Promise.resolve().then(() => {\r\n if (this.isNavigating && !instructionCount) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n let instruction = this._queue.shift();\r\n this._queue.length = 0;\r\n\r\n if (!instruction) {\r\n // ts complains about inconsistent returns without void 0\r\n return void 0;\r\n }\r\n\r\n this.isNavigating = true;\r\n\r\n let navtracker: number = this.history.getState('NavigationTracker');\r\n let currentNavTracker = this.currentNavigationTracker;\r\n\r\n if (!navtracker && !currentNavTracker) {\r\n this.isNavigatingFirst = true;\r\n this.isNavigatingNew = true;\r\n } else if (!navtracker) {\r\n this.isNavigatingNew = true;\r\n } else if (!currentNavTracker) {\r\n this.isNavigatingRefresh = true;\r\n } else if (currentNavTracker < navtracker) {\r\n this.isNavigatingForward = true;\r\n } else if (currentNavTracker > navtracker) {\r\n this.isNavigatingBack = true;\r\n } if (!navtracker) {\r\n navtracker = Date.now();\r\n this.history.setState('NavigationTracker', navtracker);\r\n }\r\n this.currentNavigationTracker = navtracker;\r\n\r\n instruction.previousInstruction = this.currentInstruction;\r\n\r\n let maxInstructionCount = this.maxInstructionCount;\r\n\r\n if (!instructionCount) {\r\n this.events.publish(RouterEvent.Processing, { instruction });\r\n } else if (instructionCount === maxInstructionCount - 1) {\r\n logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);\r\n restorePreviousLocation(this);\r\n return this._dequeueInstruction(instructionCount + 1);\r\n } else if (instructionCount > maxInstructionCount) {\r\n throw new Error('Maximum navigation attempts exceeded. Giving up.');\r\n }\r\n\r\n let pipeline = this.pipelineProvider.createPipeline(!this.couldDeactivate);\r\n\r\n return pipeline\r\n .run(instruction)\r\n .then(result => processResult(instruction, result, instructionCount, this))\r\n .catch(error => {\r\n return { output: error instanceof Error ? error : new Error(error) } as PipelineResult;\r\n })\r\n .then(result => resolveInstruction(instruction, result, !!instructionCount, this));\r\n });\r\n }\r\n\r\n /**@internal */\r\n _findViewModel(viewPort: ViewPort): ConfiguresRouter | undefined {\r\n if (this.container.viewModel) {\r\n return this.container.viewModel;\r\n }\r\n\r\n if (viewPort.container) {\r\n let container = viewPort.container;\r\n\r\n while (container) {\r\n if (container.viewModel) {\r\n this.container.viewModel = container.viewModel;\r\n return container.viewModel;\r\n }\r\n\r\n container = container.parent;\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n\r\nconst processResult = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n instructionCount: number,\r\n router: AppRouter\r\n): Promise => {\r\n if (!(result && 'completed' in result && 'output' in result)) {\r\n result = result || {} as PipelineResult;\r\n result.output = new Error(`Expected router pipeline to return a navigation result, but got [${JSON.stringify(result)}] instead.`);\r\n }\r\n\r\n let finalResult: PipelineResult = null;\r\n let navigationCommandResult = null;\r\n if (isNavigationCommand(result.output)) {\r\n navigationCommandResult = result.output.navigate(router);\r\n } else {\r\n finalResult = result;\r\n\r\n if (!result.completed) {\r\n if (result.output instanceof Error) {\r\n logger.error(result.output.toString());\r\n }\r\n\r\n restorePreviousLocation(router);\r\n }\r\n }\r\n\r\n return Promise.resolve(navigationCommandResult)\r\n .then(_ => router._dequeueInstruction(instructionCount + 1))\r\n .then(innerResult => finalResult || innerResult || result);\r\n};\r\n\r\nconst resolveInstruction = (\r\n instruction: NavigationInstruction,\r\n result: PipelineResult,\r\n isInnerInstruction: boolean,\r\n router: AppRouter\r\n): PipelineResult => {\r\n instruction.resolve(result);\r\n\r\n let eventAggregator = router.events;\r\n let eventArgs = { instruction, result };\r\n if (!isInnerInstruction) {\r\n router.isNavigating = false;\r\n router.isExplicitNavigation = false;\r\n router.isExplicitNavigationBack = false;\r\n router.isNavigatingFirst = false;\r\n router.isNavigatingNew = false;\r\n router.isNavigatingRefresh = false;\r\n router.isNavigatingForward = false;\r\n router.isNavigatingBack = false;\r\n router.couldDeactivate = false;\r\n\r\n let eventName: string;\r\n\r\n if (result.output instanceof Error) {\r\n eventName = RouterEvent.Error;\r\n } else if (!result.completed) {\r\n eventName = RouterEvent.Canceled;\r\n } else {\r\n let queryString = instruction.queryString ? ('?' + instruction.queryString) : '';\r\n router.history.previousLocation = instruction.fragment + queryString;\r\n eventName = RouterEvent.Success;\r\n }\r\n\r\n eventAggregator.publish(eventName, eventArgs);\r\n eventAggregator.publish(RouterEvent.Complete, eventArgs);\r\n } else {\r\n eventAggregator.publish(RouterEvent.ChildComplete, eventArgs);\r\n }\r\n\r\n return result;\r\n};\r\n\r\nconst restorePreviousLocation = (router: AppRouter): void => {\r\n let previousLocation = router.history.previousLocation;\r\n if (previousLocation) {\r\n router.navigate(previousLocation, { trigger: false, replace: true });\r\n } else if (router.fallbackRoute) {\r\n router.navigate(router.fallbackRoute, { trigger: true, replace: true });\r\n } else {\r\n logger.error('Router navigation failed, and no previous location or fallbackRoute could be restored.');\r\n }\r\n};\r\n","/**\r\n* The status of a Pipeline.\r\n*/\r\nexport const enum PipelineStatus {\r\n Completed = 'completed',\r\n Canceled = 'canceled',\r\n Rejected = 'rejected',\r\n Running = 'running'\r\n}\r\n","/**\r\n * A list of known router events used by the Aurelia router\r\n * to signal the pipeline has come to a certain state\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum RouterEvent {\r\n Processing = 'router:navigation:processing',\r\n Error = 'router:navigation:error',\r\n Canceled = 'router:navigation:canceled',\r\n Complete = 'router:navigation:complete',\r\n Success = 'router:navigation:success',\r\n ChildComplete = 'router:navigation:child:complete'\r\n}\r\n","/**\r\n * Available pipeline slot names to insert interceptor into router pipeline\r\n */\r\n// const enum is preserved in tsconfig\r\nexport const enum PipelineSlotName {\r\n /**\r\n * Authorization slot. Invoked early in the pipeline,\r\n * before `canActivate` hook of incoming route\r\n */\r\n Authorize = 'authorize',\r\n /**\r\n * Pre-activation slot. Invoked early in the pipeline,\r\n * Invoked timing:\r\n * - after Authorization slot\r\n * - after canActivate hook on new view model\r\n * - before deactivate hook on old view model\r\n * - before activate hook on new view model\r\n */\r\n PreActivate = 'preActivate',\r\n /**\r\n * Pre-render slot. Invoked later in the pipeline\r\n * Invokcation timing:\r\n * - after activate hook on new view model\r\n * - before commit step on new navigation instruction\r\n */\r\n PreRender = 'preRender',\r\n /**\r\n * Post-render slot. Invoked last in the pipeline\r\n */\r\n PostRender = 'postRender'\r\n}\r\n"],"names":["LogManager.getLogger","tslib_1.__extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA;;;AAGA;IA4DE,+BAAY,IAA+B;;;;QAT3C,SAAI,GAAwC,IAAI,CAAC;QAEjD,YAAO,GAAwB,EAAE,CAAC;QAQhC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,oBAAoB,GAAG,E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,KAAd,cAAc,QAK/B;;ACRD;;;;;AAKA,IAAkB,WAOjB;AAPD,WAAkB,WAAW;IAC3B,0DAA2C,CAAA;IAC3C,gDAAiC,CAAA;IACjC,sDAAuC,CAAA;IACvC,sDAAuC,CAAA;IACvC,oDAAqC,CAAA;IACrC,iEAAkD,CAAA;CACnD,EAPiB,WAAW,KAAX,WAAW,QAO5B;;ACZD;;;;AAIA,IAAkB,gBA0BjB;AA1BD,WAAkB,gBAAgB;;;;;IAKhC,2CAAuB,CAAA;;;;;;;;;IASvB,+CAA2B,CAAA;;;;;;;IAO3B,2CAAuB,CAAA;;;;IAIvB,6CAAyB,CAAA;CAC1B,EA1BiB,gBAAgB,KAAhB,gBAAgB,QA0BjC;;;;"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 53ef7605..c57ddcd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3154,7 +3154,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3175,12 +3176,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3195,17 +3198,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3322,7 +3328,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3334,6 +3341,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3348,6 +3356,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3355,12 +3364,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -3379,6 +3390,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3459,7 +3471,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3471,6 +3484,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3556,7 +3570,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3592,6 +3607,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3611,6 +3627,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3654,12 +3671,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/src/router.ts b/src/router.ts index 8a061c39..36959701 100644 --- a/src/router.ts +++ b/src/router.ts @@ -10,7 +10,7 @@ import { _createRootedPath, _resolveUrl } from './util'; -import { RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces'; +import { NavigationResult, RouteConfig, RouteConfigSpecifier, ViewPortInstruction } from './interfaces'; import { PipelineProvider } from './pipeline-provider'; /**@internal */ @@ -293,7 +293,7 @@ export class Router { * @param fragment The URL fragment to use as the navigation destination. * @param options The navigation options. */ - navigate(fragment: string, options?: NavigationOptions): boolean { + navigate(fragment: string, options?: NavigationOptions): NavigationResult { if (!this.isConfigured && this.parent) { return this.parent.navigate(fragment, options); } @@ -310,7 +310,7 @@ export class Router { * @param params The route parameters to be used when populating the route pattern. * @param options The navigation options. */ - navigateToRoute(route: string, params?: any, options?: NavigationOptions): boolean { + navigateToRoute(route: string, params?: any, options?: NavigationOptions): NavigationResult { let path = this.generate(route, params); return this.navigate(path, options); }