UNPKG

150 kBSource Map (JSON)View Raw
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<string, any>;\n queryParams?: Record<string, any>;\n config: RouteConfig;\n parentInstruction?: NavigationInstruction;\n previousInstruction?: NavigationInstruction;\n router: Router;\n options?: Object;\n plan?: Record<string, /*ViewPortInstruction*/any>;\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<string, /*ViewPortInstruction*/any>;\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<string, /*ViewPortPlan*/any> = null;\n\n options: Record<string, any> = {};\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<NavigationInstruction> {\n let instructions: NavigationInstruction[] = [this];\n let viewPortInstructions: Record<string, ViewPortInstruction> = 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<NavigationInstruction> {\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<void> {\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<void>[] = [];\n let delaySwaps: ISwapPlan[] = [];\n let viewPortInstructions: Record<string, ViewPortInstruction> = 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<string, ViewPortInstruction> = 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<string, any>;\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<string, { [key: string]: any; moduleId: string }>): 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<string, any>;\n }\n}\n\ntype RouterConfigurationResolution = RouterConfiguration | ((cfg: RouterConfiguration) => void | RouterConfiguration | Promise<RouterConfiguration>);\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<string, any>;\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<string, any> = {};\n\n /**@internal */\n catchAllHandler: (instruction: NavigationInstruction) => NavigationInstruction | Promise<NavigationInstruction>;\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<any>;\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<void> {\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<void> {\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) => <any>a.order - <any>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<string, any>): void {\n // a workaround to have strong typings while not requiring to expose interface ViewPortInstruction\n let viewPortDefaults: Record<string, ViewPortInstruction> = $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<NavigationInstruction> {\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<NavigationInstruction>;\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<RouteConfig> {\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<NavigationInstruction> => {\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<RecognizedRoute> {\n queryParams: Record<string, any>;\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<PipelineResult> {\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<string, ViewPortPlan>;\n\n/**\n * @internal exported for unit testing\n */\nexport function _buildNavigationPlan(\n instruction: NavigationInstruction,\n forceLifecycleMinimum?: boolean\n): Promise<ViewPortPlansRecord | Redirect> {\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<string, any> = {};\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<string, ViewPortInstruction>,\n forceLifecycleMinimum?: boolean\n): Promise<ViewPortPlansRecord> => {\n\n let viewPortPlans: ViewPortPlansRecord = {};\n let newInstructionConfig = currentInstruction.config;\n let hasNewParams = hasDifferentParameterValues(previousInstruction, currentInstruction);\n let pending: Promise<void>[] = [];\n let previousViewPortInstructions = previousInstruction.viewPortInstructions as Record<string, ViewPortInstruction>;\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<string, RouteConfig>;\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<void> = 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<any> {\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<any[] | void> => {\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<string, ViewPortPlan> = 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<any> => {\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<ViewPortComponent> => {\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<any> should not cause any issues\n loadRoute(router: Router, config: RouteConfig, navigationInstruction: NavigationInstruction): Promise</*ViewPortInstruction*/any> {\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<any> {\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<any> {\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<any> => {\n let plan: Record<string, ViewPortPlan> = navigationInstruction.plan;\n let infos = findDeactivatable(plan, callbackName);\n let i = infos.length; // query from inside out\n\n function inspect(val: any): Promise<any> {\n if (ignoreResult || shouldContinue(val)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise<any> {\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<string, ViewPortPlan>,\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<any> => {\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<any> {\n if (ignoreResult || shouldContinue(val, router)) {\n return iterate();\n }\n\n return next.cancel(val);\n }\n\n function iterate(): Promise<any> {\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<string, ViewPortPlan> = 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 = <T = any>(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<any> {\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<any> {\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<any> {\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<any> {\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<NavigationInstruction> {\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 <router-view/> 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<any> {\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 <router-view/> 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 <router-view/> 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<any> {\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<PipelineResult | void> {\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<PipelineResult> => {\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;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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