Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@aurelia/router-lite

Package Overview
Dependencies
7
Maintainers
1
Versions
253
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0-dev.202303150804 to 2.1.0-dev.202303312216

22

dist/types/component-agent.d.ts

@@ -1,12 +0,9 @@

import type { ICustomElementController, IHydratedController, ICustomElementViewModel, ILifecycleHooks } from '@aurelia/runtime-html';
import type { RouteDefinition } from './route-definition';
import type { ICustomElementController, ICustomElementViewModel } from '@aurelia/runtime-html';
import type { RouteNode } from './route-tree';
import { IRouteContext } from './route-context';
import { Params, NavigationInstruction } from './instructions';
import type { Transition } from './router';
import { Batch } from './util';
import { IRouteConfig } from './route';
import type { RouterOptions } from './options';
export interface IRouteViewModel extends ICustomElementViewModel {
getRouteConfig?(parentDefinition: RouteDefinition | null, routeNode: RouteNode | null): IRouteConfig | Promise<IRouteConfig>;
getRouteConfig?(parentConfig: IRouteConfig | null, routeNode: RouteNode | null): IRouteConfig | Promise<IRouteConfig>;
canLoad?(params: Params, next: RouteNode, current: RouteNode | null): boolean | NavigationInstruction | NavigationInstruction[] | Promise<boolean | NavigationInstruction | NavigationInstruction[]>;

@@ -25,20 +22,7 @@ loading?(params: Params, next: RouteNode, current: RouteNode | null): void | Promise<void>;

readonly controller: ICustomElementController<T>;
readonly definition: RouteDefinition;
readonly routeNode: RouteNode;
readonly ctx: IRouteContext;
private readonly routerOptions;
readonly canLoadHooks: readonly ILifecycleHooks<IRouteViewModel, 'canLoad'>[];
readonly loadHooks: readonly ILifecycleHooks<IRouteViewModel, 'loading'>[];
readonly canUnloadHooks: readonly ILifecycleHooks<IRouteViewModel, 'canUnload'>[];
readonly unloadHooks: readonly ILifecycleHooks<IRouteViewModel, 'unloading'>[];
constructor(instance: T, controller: ICustomElementController<T>, definition: RouteDefinition, routeNode: RouteNode, ctx: IRouteContext, routerOptions: RouterOptions);
activate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void>;
deactivate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void>;
dispose(): void;
canUnload(tr: Transition, next: RouteNode | null, b: Batch): void;
canLoad(tr: Transition, next: RouteNode, b: Batch): void;
unloading(tr: Transition, next: RouteNode | null, b: Batch): void;
loading(tr: Transition, next: RouteNode, b: Batch): void;
toString(): string;
constructor(instance: T, controller: ICustomElementController<T>, routeNode: RouteNode, ctx: IRouteContext, routerOptions: RouterOptions);
}
//# sourceMappingURL=component-agent.d.ts.map

@@ -8,3 +8,2 @@ export { type IViewport, FallbackFunction, } from './resources/viewport';

export { IRouteContext, RouteContext, type INavigationModel, type INavigationRoute, } from './route-context';
export { RouteDefinition, } from './route-definition';
export { AST, RouteExpression, CompositeSegmentExpression, ScopedSegmentExpression, SegmentGroupExpression, SegmentExpression, ComponentExpression, ActionExpression, ViewportExpression, ParameterListExpression, ParameterExpression, ExpressionKind, } from './route-expression';

@@ -11,0 +10,0 @@ export { RouteNode, RouteTree, } from './route-tree';

@@ -41,4 +41,2 @@ import { IModule } from '@aurelia/kernel';

*
* For a string component route-recognizer of the 'resolved' `RoutingContext` will be employed.
* Whereas for non-sting components, a `RouteDefinition` will be resolved, and a (new) `ViewportInstruction` will be created out of that.
*/

@@ -45,0 +43,0 @@ readonly component: string | RouteableComponent;

2

dist/types/options.d.ts
import type { Params, RouteContextLike, ViewportInstructionTree } from './instructions';
import { TransitionPlan } from './route';
import type { RouteNode } from './route-tree';

@@ -91,2 +92,3 @@ import type { Transition } from './router';

readonly state: Params | null;
readonly transitionPlan: TransitionPlan | null;
private constructor();

@@ -93,0 +95,0 @@ static create(routerOptions: RouterOptions, input: INavigationOptions): NavigationOptions;

@@ -7,4 +7,3 @@ import { type IContainer, IModule } from '@aurelia/kernel';

import { IViewport } from './resources/viewport';
import { IChildRouteConfig, RouteType } from './route';
import { RouteDefinition } from './route-definition';
import { IChildRouteConfig, RouteConfig, RouteType } from './route';
import type { RouteNode } from './route-tree';

@@ -21,3 +20,3 @@ import { IRouter } from './router';

export type EagerInstruction = {
component: string | RouteDefinition | PartialCustomElementDefinition | IRouteViewModel | IChildRouteConfig | RouteType;
component: string | RouteConfig | PartialCustomElementDefinition | IRouteViewModel | IChildRouteConfig | RouteType;
params: Params;

@@ -29,6 +28,6 @@ };

*
* The `RouteContext` is cached using a 3-part composite key consisting of the CustomElementDefinition, the RouteDefinition and the RenderContext.
* The `RouteContext` is cached using a 3-part composite key consisting of the CustomElementDefinition, the RouteConfig and the RenderContext.
*
* This means there can be more than one `RouteContext` per component type if either:
* - The `RouteDefinition` for a type is overridden manually via `Route.define`
* - The `RouteConfig` for a type is overridden manually via `Route.configure`
* - Different components (with different `RenderContext`s) reference the same component via a child route config

@@ -39,4 +38,3 @@ */

readonly component: CustomElementDefinition;
readonly definition: RouteDefinition;
readonly parentContainer: IContainer;
readonly config: RouteConfig;
private readonly _router;

@@ -58,5 +56,5 @@ private readonly childViewportAgents;

/**
* The (fully resolved) configured child routes of this context's `RouteDefinition`
* The (fully resolved) configured child routes of this context's `RouteConfig`
*/
readonly childRoutes: (RouteDefinition | Promise<RouteDefinition>)[];
readonly childRoutes: (RouteConfig | Promise<RouteConfig>)[];
get resolved(): Promise<void> | null;

@@ -79,4 +77,4 @@ get allResolved(): Promise<void> | null;

get navigationModel(): INavigationModel | null;
constructor(viewportAgent: ViewportAgent | null, parent: IRouteContext | null, component: CustomElementDefinition, definition: RouteDefinition, parentContainer: IContainer, _router: IRouter);
private processDefinition;
constructor(viewportAgent: ViewportAgent | null, parent: IRouteContext | null, component: CustomElementDefinition, config: RouteConfig, parentContainer: IContainer, _router: IRouter);
private _processConfig;
/**

@@ -117,5 +115,5 @@ * Create a new `RouteContext` and register it in the provided container.

export declare class $RecognizedRoute {
readonly route: RecognizedRoute<RouteDefinition | Promise<RouteDefinition>>;
readonly route: RecognizedRoute<RouteConfig | Promise<RouteConfig>>;
readonly residue: string | null;
constructor(route: RecognizedRoute<RouteDefinition | Promise<RouteDefinition>>, residue: string | null);
constructor(route: RecognizedRoute<RouteConfig | Promise<RouteConfig>>, residue: string | null);
toString(): string;

@@ -135,3 +133,3 @@ }

export interface INavigationRoute {
readonly id: string;
readonly id: string | null;
readonly path: string[];

@@ -138,0 +136,0 @@ readonly title: string | ((node: RouteNode) => string | null) | null;

import { type ILogger } from '@aurelia/kernel';
import type { CustomElementDefinition } from '@aurelia/runtime-html';
import { CustomElementDefinition } from '@aurelia/runtime-html';
import { ITypedNavigationInstruction_ResolvedComponent, Params, ViewportInstruction, ViewportInstructionTree } from './instructions';

@@ -4,0 +4,0 @@ import { type IRouteContext } from './route-context';

@@ -1,5 +0,6 @@

import { Constructable, ResourceType } from '@aurelia/kernel';
import { Constructable, ResourceType, IContainer } from '@aurelia/kernel';
import { RouteableComponent } from './instructions';
import type { RouteNode } from './route-tree';
import { FallbackFunction } from './resources/viewport';
export declare const noRoutes: readonly Routeable[];
/**

@@ -84,4 +85,3 @@ * Either a `RouteableComponent` or a name/config that can be resolved to a one:

export declare class RouteConfig implements IRouteConfig, IChildRouteConfig {
readonly id: string | null;
readonly path: string | string[] | null;
readonly id: string;
readonly title: string | ((node: RouteNode) => string | null) | null;

@@ -91,3 +91,3 @@ readonly redirectTo: string | null;

readonly transitionPlan: TransitionPlanOrFunc | null;
readonly viewport: string | null;
readonly viewport: string;
readonly data: Record<string, unknown>;

@@ -98,9 +98,6 @@ readonly routes: readonly Routeable[];

readonly nav: boolean;
protected constructor(id: string | null, path: string | string[] | null, title: string | ((node: RouteNode) => string | null) | null, redirectTo: string | null, caseSensitive: boolean, transitionPlan: TransitionPlanOrFunc | null, viewport: string | null, data: Record<string, unknown>, routes: readonly Routeable[], fallback: string | FallbackFunction | null, component: Routeable, nav: boolean);
/**
* Creates a new route config applying the child route config.
* Note that the current rote config is not mutated.
*/
applyChildRouteConfig(config: IChildRouteConfig, parentConfig: RouteConfig | null): RouteConfig;
get path(): string[];
private constructor();
getTransitionPlan(cur: RouteNode, next: RouteNode): TransitionPlan;
register(container: IContainer): void;
}

@@ -107,0 +104,0 @@ export declare const Route: {

import { IContainer, ILogger } from '@aurelia/kernel';
import { type CustomElementDefinition, IPlatform } from '@aurelia/runtime-html';
import { CustomElementDefinition, IPlatform } from '@aurelia/runtime-html';
import { IRouteContext } from './route-context';
import { IRouterEvents, ManagedState, RoutingTrigger } from './router-events';
import { ILocationManager } from './location-manager';
import { RouteType } from './route';
import { RouteConfig, RouteType } from './route';
import { IRouteViewModel } from './component-agent';

@@ -11,3 +11,2 @@ import { RouteTree } from './route-tree';

import { UnwrapPromise } from './util';
import { RouteDefinition } from './route-definition';
import { type ViewportAgent } from './viewport-agent';

@@ -162,3 +161,3 @@ import { INavigationOptions, NavigationOptions, type RouterOptions } from './options';

*/
getRouteContext(viewportAgent: ViewportAgent | null, componentDefinition: CustomElementDefinition, componentInstance: IRouteViewModel | null, container: IContainer, parentDefinition: RouteDefinition | null): IRouteContext | Promise<IRouteContext>;
getRouteContext(viewportAgent: ViewportAgent | null, componentDefinition: CustomElementDefinition, componentInstance: IRouteViewModel | null, container: IContainer, parentRouteConfig: RouteConfig | null, parentContext: IRouteContext | null, $rdConfig: RouteConfig | null): IRouteContext | Promise<IRouteContext>;
createViewportInstructions(instructionOrInstructions: NavigationInstruction | readonly NavigationInstruction[], options?: INavigationOptions): ViewportInstructionTree;

@@ -165,0 +164,0 @@ /**

@@ -1,8 +0,4 @@

import { type IHydratedController, type ICustomElementController } from '@aurelia/runtime-html';
import { type ICustomElementController } from '@aurelia/runtime-html';
import type { IViewport } from './resources/viewport';
import { type RouteNode } from './route-tree';
import type { IRouteContext } from './route-context';
import type { NavigationOptions } from './options';
import type { Transition } from './router';
import { Batch } from './util';
export declare class ViewportRequest {

@@ -34,21 +30,4 @@ readonly viewportName: string;

static for(viewport: IViewport, ctx: IRouteContext): ViewportAgent;
activateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void>;
deactivateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void>;
handles(req: ViewportRequest): boolean;
isAvailable(): boolean;
canUnload(tr: Transition, b: Batch): void;
canLoad(tr: Transition, b: Batch): void;
unloading(tr: Transition, b: Batch): void;
loading(tr: Transition, b: Batch): void;
deactivate(initiator: IHydratedController | null, tr: Transition, b: Batch): void;
activate(initiator: IHydratedController | null, tr: Transition, b: Batch): void;
swap(tr: Transition, b: Batch): void;
private processDynamicChildren;
scheduleUpdate(options: NavigationOptions, next: RouteNode): void;
cancelUpdate(): void;
endTransition(): void;
toString(): string;
dispose(): void;
private unexpectedState;
}
//# sourceMappingURL=viewport-agent.d.ts.map
{
"name": "@aurelia/router-lite",
"version": "2.1.0-dev.202303150804",
"version": "2.1.0-dev.202303312216",
"main": "dist/cjs/index.cjs",

@@ -52,9 +52,9 @@ "module": "dist/esm/index.mjs",

"dependencies": {
"@aurelia/kernel": "2.1.0-dev.202303150804",
"@aurelia/metadata": "2.1.0-dev.202303150804",
"@aurelia/platform": "2.1.0-dev.202303150804",
"@aurelia/platform-browser": "2.1.0-dev.202303150804",
"@aurelia/route-recognizer": "2.1.0-dev.202303150804",
"@aurelia/runtime": "2.1.0-dev.202303150804",
"@aurelia/runtime-html": "2.1.0-dev.202303150804"
"@aurelia/kernel": "2.1.0-dev.202303312216",
"@aurelia/metadata": "2.1.0-dev.202303312216",
"@aurelia/platform": "2.1.0-dev.202303312216",
"@aurelia/platform-browser": "2.1.0-dev.202303312216",
"@aurelia/route-recognizer": "2.1.0-dev.202303312216",
"@aurelia/runtime": "2.1.0-dev.202303312216",
"@aurelia/runtime-html": "2.1.0-dev.202303312216"
},

@@ -61,0 +61,0 @@ "devDependencies": {

import { ILogger } from '@aurelia/kernel';
import type { ICustomElementController, IHydratedController, ICustomElementViewModel, ILifecycleHooks, LifecycleHooksLookup } from '@aurelia/runtime-html';
import type { RouteDefinition } from './route-definition';
import type { RouteNode } from './route-tree';

@@ -18,3 +17,3 @@ import { IRouteContext } from './route-context';

export interface IRouteViewModel extends ICustomElementViewModel {
getRouteConfig?(parentDefinition: RouteDefinition | null, routeNode: RouteNode | null): IRouteConfig | Promise<IRouteConfig>;
getRouteConfig?(parentConfig: IRouteConfig | null, routeNode: RouteNode | null): IRouteConfig | Promise<IRouteConfig>;
canLoad?(params: Params, next: RouteNode, current: RouteNode | null): boolean | NavigationInstruction | NavigationInstruction[] | Promise<boolean | NavigationInstruction | NavigationInstruction[]>;

@@ -40,6 +39,6 @@ loading?(params: Params, next: RouteNode, current: RouteNode | null): void | Promise<void>;

public readonly canLoadHooks: readonly ILifecycleHooks<IRouteViewModel, 'canLoad'>[];
public readonly loadHooks: readonly ILifecycleHooks<IRouteViewModel, 'loading'>[];
public readonly canUnloadHooks: readonly ILifecycleHooks<IRouteViewModel, 'canUnload'>[];
public readonly unloadHooks: readonly ILifecycleHooks<IRouteViewModel, 'unloading'>[];
/** @internal */ private readonly _canLoadHooks: readonly ILifecycleHooks<IRouteViewModel, 'canLoad'>[];
/** @internal */ private readonly _loadHooks: readonly ILifecycleHooks<IRouteViewModel, 'loading'>[];
/** @internal */ private readonly _canUnloadHooks: readonly ILifecycleHooks<IRouteViewModel, 'canUnload'>[];
/** @internal */ private readonly _unloadHooks: readonly ILifecycleHooks<IRouteViewModel, 'unloading'>[];

@@ -49,3 +48,2 @@ public constructor(

public readonly controller: ICustomElementController<T>,
public readonly definition: RouteDefinition,
public readonly routeNode: RouteNode,

@@ -60,6 +58,6 @@ public readonly ctx: IRouteContext,

const lifecycleHooks = controller.lifecycleHooks as LifecycleHooksLookup<IRouteViewModel>;
this.canLoadHooks = (lifecycleHooks.canLoad ?? []).map(x => x.instance);
this.loadHooks = (lifecycleHooks.loading ?? []).map(x => x.instance);
this.canUnloadHooks = (lifecycleHooks.canUnload ?? []).map(x => x.instance);
this.unloadHooks = (lifecycleHooks.unloading ?? []).map(x => x.instance);
this._canLoadHooks = (lifecycleHooks.canLoad ?? []).map(x => x.instance);
this._loadHooks = (lifecycleHooks.loading ?? []).map(x => x.instance);
this._canUnloadHooks = (lifecycleHooks.canUnload ?? []).map(x => x.instance);
this._unloadHooks = (lifecycleHooks.unloading ?? []).map(x => x.instance);
this._hasCanLoad = 'canLoad' in instance;

@@ -71,3 +69,4 @@ this._hasLoad = 'loading' in instance;

public activate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void> {
/** @internal */
public _activate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void> {
if (initiator === null) {

@@ -83,3 +82,4 @@ this._logger.trace(`activate() - initial`);

public deactivate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void> {
/** @internal */
public _deactivate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void> {
if (initiator === null) {

@@ -95,3 +95,4 @@ this._logger.trace(`deactivate() - initial`);

public dispose(): void {
/** @internal */
public _dispose(): void {
this._logger.trace(`dispose()`);

@@ -102,7 +103,8 @@

public canUnload(tr: Transition, next: RouteNode | null, b: Batch): void {
this._logger.trace(`canUnload(next:%s) - invoking ${this.canUnloadHooks.length} hooks`, next);
/** @internal */
public _canUnload(tr: Transition, next: RouteNode | null, b: Batch): void {
this._logger.trace(`canUnload(next:%s) - invoking ${this._canUnloadHooks.length} hooks`, next);
b.push();
let promise: Promise<void> = Promise.resolve();
for (const hook of this.canUnloadHooks) {
for (const hook of this._canUnloadHooks) {
b.push();

@@ -147,8 +149,9 @@ promise = promise.then(() => new Promise((res) => {

public canLoad(tr: Transition, next: RouteNode, b: Batch): void {
this._logger.trace(`canLoad(next:%s) - invoking ${this.canLoadHooks.length} hooks`, next);
/** @internal */
public _canLoad(tr: Transition, next: RouteNode, b: Batch): void {
this._logger.trace(`canLoad(next:%s) - invoking ${this._canLoadHooks.length} hooks`, next);
const rootCtx = this.ctx.root;
b.push();
let promise: Promise<void> = Promise.resolve();
for (const hook of this.canLoadHooks) {
for (const hook of this._canLoadHooks) {
b.push();

@@ -193,6 +196,7 @@ promise = promise.then(() => new Promise((res) => {

public unloading(tr: Transition, next: RouteNode | null, b: Batch): void {
this._logger.trace(`unloading(next:%s) - invoking ${this.unloadHooks.length} hooks`, next);
/** @internal */
public _unloading(tr: Transition, next: RouteNode | null, b: Batch): void {
this._logger.trace(`unloading(next:%s) - invoking ${this._unloadHooks.length} hooks`, next);
b.push();
for (const hook of this.unloadHooks) {
for (const hook of this._unloadHooks) {
tr.run(() => {

@@ -216,6 +220,7 @@ b.push();

public loading(tr: Transition, next: RouteNode, b: Batch): void {
this._logger.trace(`loading(next:%s) - invoking ${this.loadHooks.length} hooks`, next);
/** @internal */
public _loading(tr: Transition, next: RouteNode, b: Batch): void {
this._logger.trace(`loading(next:%s) - invoking ${this._loadHooks.length} hooks`, next);
b.push();
for (const hook of this.loadHooks) {
for (const hook of this._loadHooks) {
tr.run(() => {

@@ -238,6 +243,2 @@ b.push();

}
public toString(): string {
return `CA(ctx:'${this.ctx.friendlyPath}',c:'${this.definition.component!.name}')`;
}
}

@@ -61,6 +61,2 @@ export {

export {
RouteDefinition,
} from './route-definition';
export {
AST,

@@ -67,0 +63,0 @@ RouteExpression,

@@ -61,4 +61,2 @@ import { isObject } from '@aurelia/metadata';

*
* For a string component route-recognizer of the 'resolved' `RoutingContext` will be employed.
* Whereas for non-sting components, a `RouteDefinition` will be resolved, and a (new) `ViewportInstruction` will be created out of that.
*/

@@ -65,0 +63,0 @@ readonly component: string | RouteableComponent;

import { DI } from '@aurelia/kernel';
import type { Params, RouteContextLike, ViewportInstructionTree } from './instructions';
import { TransitionPlan } from './route';
import type { RouteNode } from './route-tree';

@@ -101,2 +102,3 @@ import type { Transition } from './router';

public readonly state: Params | null,
public readonly transitionPlan: TransitionPlan | null,
) { }

@@ -113,2 +115,3 @@

input.state ?? null,
input.transitionPlan ?? null,
);

@@ -126,2 +129,3 @@ }

this.state === null ? null : { ...this.state },
this.transitionPlan,
);

@@ -128,0 +132,0 @@ }

@@ -64,3 +64,3 @@ import { ILogger } from '@aurelia/kernel';

return this.agent.activateFromViewport(initiator, this.controller);
return this.agent._activateFromViewport(initiator, this.controller);
}

@@ -71,3 +71,3 @@

return this.agent.deactivateFromViewport(initiator, this.controller);
return this.agent._deactivateFromViewport(initiator, this.controller);
}

@@ -79,3 +79,3 @@

this.ctx.unregisterViewport(this);
this.agent.dispose();
this.agent._dispose();
this.agent = (void 0)!;

@@ -82,0 +82,0 @@ }

@@ -15,2 +15,3 @@ import {

emptyObject,
emptyArray,
} from '@aurelia/kernel';

@@ -33,2 +34,3 @@ import { type Endpoint, RecognizedRoute, RESIDUE, RouteRecognizer } from '@aurelia/route-recognizer';

import {
ITypedNavigationInstruction_Component,
ITypedNavigationInstruction_string,

@@ -46,4 +48,3 @@ IViewportInstruction,

import { IViewport } from './resources/viewport';
import { IChildRouteConfig, Routeable, RouteType } from './route';
import { RouteDefinition } from './route-definition';
import { IChildRouteConfig, noRoutes, resolveCustomElementDefinition, resolveRouteConfiguration, Routeable, RouteConfig, RouteType } from './route';
import type { RouteNode } from './route-tree';

@@ -65,3 +66,3 @@ import {

export type EagerInstruction = {
component: string | RouteDefinition | PartialCustomElementDefinition | IRouteViewModel | IChildRouteConfig | RouteType;
component: string | RouteConfig | PartialCustomElementDefinition | IRouteViewModel | IChildRouteConfig | RouteType;
params: Params;

@@ -87,6 +88,6 @@ };

*
* The `RouteContext` is cached using a 3-part composite key consisting of the CustomElementDefinition, the RouteDefinition and the RenderContext.
* The `RouteContext` is cached using a 3-part composite key consisting of the CustomElementDefinition, the RouteConfig and the RenderContext.
*
* This means there can be more than one `RouteContext` per component type if either:
* - The `RouteDefinition` for a type is overridden manually via `Route.define`
* - The `RouteConfig` for a type is overridden manually via `Route.configure`
* - Different components (with different `RenderContext`s) reference the same component via a child route config

@@ -116,5 +117,5 @@ */

/**
* The (fully resolved) configured child routes of this context's `RouteDefinition`
* The (fully resolved) configured child routes of this context's `RouteConfig`
*/
public readonly childRoutes: (RouteDefinition | Promise<RouteDefinition>)[] = [];
public readonly childRoutes: (RouteConfig | Promise<RouteConfig>)[] = [];

@@ -170,3 +171,3 @@ /** @internal */

/** @internal */
public readonly _recognizer: RouteRecognizer<RouteDefinition | Promise<RouteDefinition>>;
public readonly _recognizer: RouteRecognizer<RouteConfig | Promise<RouteConfig>>;
private _childRoutesConfigured: boolean = false;

@@ -183,4 +184,4 @@

public readonly component: CustomElementDefinition,
public readonly definition: RouteDefinition,
public readonly parentContainer: IContainer,
public readonly config: RouteConfig,
parentContainer: IContainer,
private readonly _router: IRouter,

@@ -216,7 +217,7 @@ ) {

container.register(definition);
container.register(config);
this._recognizer = new RouteRecognizer();
if(_router.options.useNavigationModel) {
if (_router.options.useNavigationModel) {
const navModel = this._navigationModel = new NavigationModel([]);

@@ -232,12 +233,12 @@ // Note that routing-contexts have the same lifetime as the app itself; therefore, an attempt to dispose the subscription is kind of useless.

}
this.processDefinition(definition);
this._processConfig(config);
}
private processDefinition(definition: RouteDefinition): void {
private _processConfig(config: RouteConfig): void {
const promises: Promise<void>[] = [];
const allPromises: Promise<void>[] = [];
const children = definition.config.routes;
const len = children.length;
const childrenRoutes = config.routes ?? noRoutes;
const len = childrenRoutes.length;
if (len === 0) {
const getRouteConfig = (definition.component?.Type.prototype as IRouteViewModel)?.getRouteConfig;
const getRouteConfig = ((config.component as RouteType).prototype as IRouteViewModel)?.getRouteConfig;
this._childRoutesConfigured = getRouteConfig == null ? true : typeof getRouteConfig !== 'function';

@@ -250,20 +251,20 @@ return;

for (; i < len; i++) {
const child = children[i];
if (child instanceof Promise) {
const p = this.addRoute(child);
const childRoute = childrenRoutes[i];
if (childRoute instanceof Promise) {
const p = this.addRoute(childRoute);
promises.push(p);
allPromises.push(p);
} else {
const routeDef = RouteDefinition.resolve(child, definition, null, this);
if (routeDef instanceof Promise) {
if (!isPartialChildRouteConfig(child) || child.path == null) throw new Error(`Invalid route config. When the component property is a lazy import, the path must be specified.`);
for (const path of ensureArrayOfStrings(child.path)) {
this.$addRoute(path, child.caseSensitive ?? false, routeDef);
const rdResolution = resolveRouteConfiguration(childRoute, true, config, null, this);
if (rdResolution instanceof Promise) {
if (!isPartialChildRouteConfig(childRoute) || childRoute.path == null) throw new Error(`Invalid route config. When the component property is a lazy import, the path must be specified.`);
for (const path of ensureArrayOfStrings(childRoute.path)) {
this.$addRoute(path, childRoute.caseSensitive ?? false, rdResolution);
}
const idx = this.childRoutes.length;
const p = routeDef.then(resolvedRouteDef => {
return this.childRoutes[idx] = resolvedRouteDef;
const p = rdResolution.then((rdConfig) => {
return this.childRoutes[idx] = rdConfig;
});
this.childRoutes.push(p);
if(hasNavModel) {
if (hasNavModel) {
navModel.addRoute(p);

@@ -273,8 +274,8 @@ }

} else {
for (const path of routeDef.path) {
this.$addRoute(path, routeDef.caseSensitive, routeDef);
for (const path of rdResolution.path ?? emptyArray) {
this.$addRoute(path, rdResolution.caseSensitive, rdResolution);
}
this.childRoutes.push(routeDef);
if(hasNavModel) {
navModel.addRoute(routeDef);
this.childRoutes.push(rdResolution);
if (hasNavModel) {
navModel.addRoute(rdResolution);
}

@@ -323,3 +324,11 @@ }

return onResolve(
router.getRouteContext(null, controller.definition, controller.viewModel, controller.container, null),
router.getRouteContext(
null,
controller.definition,
controller.viewModel,
controller.container,
null,
null,
null,
),
routeContext => {

@@ -384,3 +393,3 @@ container.register(Registration.instance(IRouteContext, routeContext));

const agent = this.childViewportAgents.find(x => { return x.handles(req); });
const agent = this.childViewportAgents.find(x => { return x._handles(req); });

@@ -395,7 +404,7 @@ if (agent === void 0) {

public getAvailableViewportAgents(): readonly ViewportAgent[] {
return this.childViewportAgents.filter(x => x.isAvailable());
return this.childViewportAgents.filter(x => x._isAvailable());
}
public getFallbackViewportAgent(name: string): ViewportAgent | null {
return this.childViewportAgents.find(x => x.isAvailable() && x.viewport.name === name && x.viewport.fallback.length > 0) ?? null;
return this.childViewportAgents.find(x => x._isAvailable() && x.viewport.name === name && x.viewport.fallback.length > 0) ?? null;
}

@@ -415,3 +424,2 @@

const componentInstance = container.get<IRouteViewModel>(routeNode.component.key);
const parentDefinition = this.definition;
// this is the point where we can load the delayed (non-static) child route configuration by calling the getRouteConfig

@@ -421,9 +429,8 @@ const task: Promise<void> | void = this._childRoutesConfigured

: onResolve(
RouteDefinition.resolve(componentInstance, parentDefinition, routeNode),
routeDef => this.processDefinition(routeDef)
resolveRouteConfiguration(componentInstance, false, this.config, routeNode, null),
config => this._processConfig(config)
);
return onResolve(task, () => {
const definition = RouteDefinition.resolve(componentInstance.constructor as Constructable, parentDefinition, null) as RouteDefinition;
const controller = Controller.$el(container, componentInstance, hostController.host, null);
const componentAgent = new ComponentAgent(componentInstance, controller, definition, routeNode, this, this._router.options);
const componentAgent = new ComponentAgent(componentInstance, controller, routeNode, this, this._router.options);

@@ -463,3 +470,3 @@ this.hostControllerProvider.dispose();

let _continue = true;
let result: RecognizedRoute<RouteDefinition | Promise<RouteDefinition>> | null = null;
let result: RecognizedRoute<RouteConfig | Promise<RouteConfig>> | null = null;
while (_continue) {

@@ -475,12 +482,8 @@ result = _current._recognizer.recognize(path);

let residue: string | null;
if (Reflect.has(result!.params, RESIDUE)) {
residue = result!.params[RESIDUE] ?? null;
// TODO(sayan): Fred did this to fix some issue in lazy-loading. Inspect if this is really needed.
// Reflect.deleteProperty(result.params, RESIDUE);
} else {
residue = null;
}
return new $RecognizedRoute(result!, residue);
return new $RecognizedRoute(
result!,
Reflect.has(result!.params, RESIDUE)
? (result!.params[RESIDUE] ?? null)
: null
);
}

@@ -492,12 +495,14 @@

this.logger.trace(`addRoute(routeable:'${routeable}')`);
return onResolve(RouteDefinition.resolve(routeable, this.definition, null, this), routeDef => {
for (const path of routeDef.path) {
this.$addRoute(path, routeDef.caseSensitive, routeDef);
}
this._navigationModel?.addRoute(routeDef);
this.childRoutes.push(routeDef);
});
return onResolve(
resolveRouteConfiguration(routeable, true, this.config, null, this),
rdConfig => {
for (const path of rdConfig.path ?? emptyArray) {
this.$addRoute(path, rdConfig.caseSensitive, rdConfig);
}
this._navigationModel?.addRoute(rdConfig);
this.childRoutes.push(rdConfig);
});
}
private $addRoute(path: string, caseSensitive: boolean, handler: RouteDefinition | Promise<RouteDefinition>): void {
private $addRoute(path: string, caseSensitive: boolean, handler: RouteConfig | Promise<RouteConfig>): void {
this._recognizer.add({

@@ -546,3 +551,3 @@ path,

/** @internal */
public generateViewportInstruction(instruction: { component: RouteDefinition; params: Params }): PathGenerationResult;
public generateViewportInstruction(instruction: { component: RouteConfig; params: Params }): PathGenerationResult;
public generateViewportInstruction(instruction: { component: string; params: Params }): PathGenerationResult | null;

@@ -553,20 +558,30 @@ public generateViewportInstruction(instruction: NavigationInstruction | EagerInstruction): PathGenerationResult | null;

const component = instruction.component;
let def: RouteDefinition | undefined;
let paths: string[] | undefined;
let throwError: boolean = false;
if (component instanceof RouteDefinition) {
def = component;
if (component instanceof RouteConfig) {
paths = component.path;
throwError = true;
} else if (typeof component === 'string') {
def = (this.childRoutes as RouteDefinition[]).find(x => x.id === component);
const $rdConfig = (this.childRoutes as RouteConfig[]).find(x => x.id === component);
if ($rdConfig === void 0) return null;
paths = $rdConfig.path;
} else if ((component as ITypedNavigationInstruction_string).type === NavigationInstructionType.string) {
def = (this.childRoutes as RouteDefinition[]).find(x => x.id === (component as ITypedNavigationInstruction_string).value);
const $rdConfig = (this.childRoutes as RouteConfig[]).find(x => x.id === (component as ITypedNavigationInstruction_string).value);
if ($rdConfig === void 0) return null;
paths = $rdConfig.path;
} else {
// as the component is ensured not to be a promise in here, the resolution should also be synchronous
def = RouteDefinition.resolve(component, null, null, this) as RouteDefinition;
const ced = (resolveCustomElementDefinition(component, this) as [ITypedNavigationInstruction_Component, CustomElementDefinition])[1];
paths = this.childRoutes.reduce((acc, x) => {
if ((x as RouteConfig).component === ced.Type) {
acc.push(...(x as RouteConfig).path);
}
return acc;
}, [] as string[]);
throwError = true;
}
if (def === void 0) return null;
if (paths === void 0) return null;
const params = instruction.params;
const recognizer = this._recognizer;
const paths = def.path;
const numPaths = paths.length;

@@ -628,3 +643,3 @@ const errors: string[] = [];

path: string;
endpoint: Endpoint<RouteDefinition | Promise<RouteDefinition>>;
endpoint: Endpoint<RouteConfig | Promise<RouteConfig>>;
consumed: Params;

@@ -698,3 +713,3 @@ query: Params;

public constructor(
public readonly route: RecognizedRoute<RouteDefinition | Promise<RouteDefinition>>,
public readonly route: RecognizedRoute<RouteConfig | Promise<RouteConfig>>,
public readonly residue: string | null,

@@ -742,7 +757,7 @@ ) { }

/** @internal */
public addRoute(routeDef: RouteDefinition | Promise<RouteDefinition>): void {
public addRoute(route: RouteConfig | Promise<RouteConfig>): void {
const routes = this.routes;
if (!(routeDef instanceof Promise)) {
if (routeDef.config.nav) {
routes.push(NavigationRoute.create(routeDef));
if (!(route instanceof Promise)) {
if (route.nav ?? false) {
routes.push(NavigationRoute.create(route));
}

@@ -755,5 +770,5 @@ return;

promise = this._promise = onResolve(this._promise, () =>
onResolve(routeDef, $routeDef => {
if ($routeDef.config.nav) {
routes[index] = NavigationRoute.create($routeDef);
onResolve(route, rdConfig => {
if (rdConfig.nav) {
routes[index] = NavigationRoute.create(rdConfig);
} else {

@@ -771,3 +786,3 @@ routes.splice(index, 1);

export interface INavigationRoute {
readonly id: string;
readonly id: string | null;
readonly path: string[];

@@ -783,3 +798,3 @@ readonly title: string | ((node: RouteNode) => string | null) | null;

private constructor(
public readonly id: string,
public readonly id: string | null,
public readonly path: string[],

@@ -792,9 +807,9 @@ public readonly redirectTo: string | null,

/** @internal */
public static create(routeDef: RouteDefinition) {
public static create(rdConfig: RouteConfig) {
return new NavigationRoute(
routeDef.id,
routeDef.path,
routeDef.redirectTo,
routeDef.config.title,
routeDef.data,
rdConfig.id,
ensureArrayOfStrings(rdConfig.path ?? emptyArray),
rdConfig.redirectTo,
rdConfig.title,
rdConfig.data,
);

@@ -801,0 +816,0 @@ }

@@ -14,3 +14,3 @@ import {

} from '@aurelia/route-recognizer';
import type {
import {
CustomElementDefinition,

@@ -33,5 +33,2 @@ } from '@aurelia/runtime-html';

import {
RouteDefinition,
} from './route-definition';
import {
ExpressionKind,

@@ -54,2 +51,3 @@ RouteExpression,

} from './viewport-agent';
import { resolveCustomElementDefinition, resolveRouteConfiguration, RouteConfig, RouteType } from './route';

@@ -196,3 +194,3 @@ export interface IRouteNode {

c.clearChildren();
c.context.vpa.cancelUpdate();
c.context.vpa._cancelUpdate();
}

@@ -280,3 +278,3 @@ this.children.length = 0;

const component = this.context?.definition.component?.name ?? '';
const component = (this.context?.config.component as RouteType)?.name ?? '';
if (component.length > 0) {

@@ -286,3 +284,3 @@ props.push(`c:'${component}'`);

const path = this.context?.definition.config.path ?? '';
const path = this.context?.config.path ?? '';
if (path.length > 0) {

@@ -445,18 +443,21 @@ props.push(`path:'${path}'`);

? vpa.viewport._getFallback(vi, node, ctx)
: ctx.definition._getFallback(vi, node, ctx);
: ctx.config._getFallback(vi, node, ctx);
if (fallback === null) throw new UnknownRouteError(`Neither the route '${name}' matched any configured route at '${ctx.friendlyPath}' nor a fallback is configured for the viewport '${vp}' - did you forget to add '${name}' to the routes list of the route decorator of '${ctx.component.name}'?`);
// fallback: id -> route -> CEDefn (Route definition)
// fallback: id -> route -> CEDefn (Route configuration)
// look for a route first
log.trace(`Fallback is set to '${fallback}'. Looking for a recognized route.`);
const rd = (ctx.childRoutes as RouteDefinition[]).find(x => x.id === fallback);
const rd = (ctx.childRoutes as RouteConfig[]).find(x => x.id === fallback);
if (rd !== void 0) return appendNode(log, node, createFallbackNode(log, rd, node, vi as ViewportInstruction<ITypedNavigationInstruction_string>));
log.trace(`No route definition for the fallback '${fallback}' is found; trying to recognize the route.`);
log.trace(`No route configuration for the fallback '${fallback}' is found; trying to recognize the route.`);
const rr = ctx.recognize(fallback, true);
if (rr !== null && rr.residue !== fallback) return appendNode(log, node, createConfiguredNode(log, node, vi as ViewportInstruction<ITypedNavigationInstruction_ResolvedComponent>, rr, null));
// fallback is not recognized as a configured route; treat as CE and look for a route definition.
// fallback is not recognized as a configured route; treat as CE and look for a route configuration.
log.trace(`The fallback '${fallback}' is not recognized as a route; treating as custom element name.`);
return appendNode(log, node, createFallbackNode(log, RouteDefinition.resolve(fallback, ctx.definition, null, ctx), node, vi as ViewportInstruction<ITypedNavigationInstruction_string>));
return appendNode(log, node, createFallbackNode(log,
resolveRouteConfiguration(fallback, false, ctx.config, null, ctx) as RouteConfig, // TODO: fix the typing by adding overloads.
node,
vi as ViewportInstruction<ITypedNavigationInstruction_string>));
}

@@ -486,6 +487,6 @@

return onResolve(
RouteDefinition.resolve(vi.component.value, rc.definition, null, rc),
rd => {
resolveCustomElementDefinition(vi.component.value, rc)[1],
ced => {
const { vi: newVi, query } = rc.generateViewportInstruction({
component: rd,
component: ced,
params: vi.params ?? emptyObject,

@@ -515,3 +516,3 @@ open: vi.open,

originalVi: ViewportInstruction<ITypedNavigationInstruction_ResolvedComponent> | null,
route: ConfigurableRoute<RouteDefinition | Promise<RouteDefinition>> = rr.route.endpoint.route,
route: ConfigurableRoute<RouteConfig | Promise<RouteConfig>> = rr.route.endpoint.route,
): RouteNode | Promise<RouteNode> {

@@ -523,47 +524,51 @@ const ctx = node.context;

log.trace(`creatingConfiguredNode(rd:%s, vi:%s)`, $handler, vi);
log.trace(`creatingConfiguredNode(rdc:%s, vi:%s)`, $handler, vi);
if ($handler.redirectTo === null) {
const vpName: string = ((vi.viewport?.length ?? 0) > 0 ? vi.viewport : $handler.viewport)!;
const ced = $handler.component!;
return onResolve(
resolveCustomElementDefinition($handler.component, ctx)[1],
ced => {
const vpa = ctx.resolveViewportAgent(new ViewportRequest(
vpName,
ced.name,
));
const vpa = ctx.resolveViewportAgent(new ViewportRequest(
vpName,
ced.name,
));
const router = ctx.container.get(IRouter);
return onResolve(
router.getRouteContext(vpa, ced, null, vpa.hostController.container, ctx.definition),
childCtx => {
const router = ctx.container.get(IRouter);
return onResolve(
router.getRouteContext(vpa, ced, null, vpa.hostController.container, ctx.config, ctx, $handler),
childCtx => {
log.trace('createConfiguredNode setting the context node');
const $node = childCtx.node = RouteNode.create({
path: rr.route.endpoint.route.path,
finalPath: route.path,
context: childCtx,
instruction: vi,
originalInstruction: originalVi,
params: {
...rr.route.params,
},
queryParams: rt.queryParams,
fragment: rt.fragment,
data: $handler.data,
viewport: vpName,
component: ced,
title: $handler.config.title,
residue: [
// TODO(sayan): this can be removed; need to inspect more.
...(rr.residue === null ? [] : [ViewportInstruction.create(rr.residue)]),
...vi.children,
],
});
$node.setTree(node.tree);
log.trace('createConfiguredNode setting the context node');
const $node = childCtx.node = RouteNode.create({
path: rr.route.endpoint.route.path,
finalPath: route.path,
context: childCtx,
instruction: vi,
originalInstruction: originalVi,
params: {
...rr.route.params,
},
queryParams: rt.queryParams,
fragment: rt.fragment,
data: $handler.data,
viewport: vpName,
component: ced,
title: $handler.title,
residue: [
// TODO(sayan): this can be removed; need to inspect more.
...(rr.residue === null ? [] : [ViewportInstruction.create(rr.residue)]),
...vi.children,
],
});
$node.setTree(node.tree);
log.trace(`createConfiguredNode(vi:%s) -> %s`, vi, $node);
log.trace(`createConfiguredNode(vi:%s) -> %s`, vi, $node);
return $node;
}
);
return $node;
}
);
});
}

@@ -675,3 +680,3 @@

node.appendChild($childNode);
return $childNode.context.vpa.scheduleUpdate(node.tree.options, $childNode);
return $childNode.context.vpa._scheduleUpdate(node.tree.options, $childNode);
});

@@ -681,7 +686,7 @@ }

/**
* Creates route node from the given RouteDefinition `rd` for a unknown path (non-configured route).
* Creates route node from the given RouteConfig `rc` for a unknown path (non-configured route).
*/
function createFallbackNode(
log: ILogger,
rd: RouteDefinition,
rc: RouteConfig,
node: RouteNode,

@@ -694,3 +699,3 @@ vi: ViewportInstruction<ITypedNavigationInstruction_string>,

new Endpoint(
new ConfigurableRoute(rd.path[0], rd.caseSensitive, rd),
new ConfigurableRoute(rc.path[0], rc.caseSensitive, rc),
[]

@@ -697,0 +702,0 @@ ),

import { Metadata } from '@aurelia/metadata';
import { Constructable, emptyArray, Protocol, ResourceType } from '@aurelia/kernel';
import { Constructable, emptyArray, onResolve, Protocol, ResourceType, Writable, IContainer } from '@aurelia/kernel';
import { validateRouteConfig, expectType, shallowEquals } from './validation';
import { RouteableComponent } from './instructions';
import { validateRouteConfig, expectType, shallowEquals, isPartialRedirectRouteConfig, isPartialChildRouteConfig } from './validation';
import { defaultViewportName, ITypedNavigationInstruction_Component, NavigationInstructionType, RouteableComponent, TypedNavigationInstruction, ViewportInstruction } from './instructions';
import type { RouteNode } from './route-tree';
import { FallbackFunction } from './resources/viewport';
import type { IRouteContext } from './route-context';
import { CustomElement, CustomElementDefinition } from '@aurelia/runtime-html';
import { IRouteViewModel } from './component-agent';
import { ensureArrayOfStrings, ensureString } from './util';
const noRoutes = emptyArray as RouteConfig['routes'];
export const noRoutes = emptyArray as RouteConfig['routes'];

@@ -24,58 +28,58 @@ /**

export interface IRouteConfig {
/**
* The id for this route, which can be used in the view for generating hrefs.
*/
readonly id?: string | null;
/**
* The path to match against the url.
*
* If left blank, the path will be derived from the component's static `path` property (if it exists).
*/
readonly path?: string | string[] | null;
/**
* The title to use for this route when matched.
*
* If left blank, this route will not contribute to the generated title.
*/
readonly title?: string | ((node: RouteNode) => string | null) | null;
/**
* The path to which to redirect when the url matches the path in this config.
*/
readonly redirectTo?: string | null;
/**
* Whether the `path` should be case sensitive.
*/
readonly caseSensitive?: boolean;
/**
* How to behave when this component scheduled to be loaded again in the same viewport:
*
* - `replace`: completely removes the current component and creates a new one, behaving as if the component changed (default if only the parameters have changed).
* - `invoke-lifecycles`: calls `canUnload`, `canLoad`, `unloading` and `loading`.
* - `none`: does nothing (default if nothing has changed for the viewport).
*/
readonly transitionPlan?: TransitionPlanOrFunc | null;
/**
* The name of the viewport this component should be loaded into.
*/
readonly viewport?: string | null;
/**
* Any custom data that should be accessible to matched components or hooks.
*/
readonly data?: Record<string, unknown>;
/**
* The child routes that can be navigated to from this route. See `Routeable` for more information.
*/
readonly routes?: readonly Routeable[];
/**
* The id for this route, which can be used in the view for generating hrefs.
*/
readonly id?: string | null;
/**
* The path to match against the url.
*
* If left blank, the path will be derived from the component's static `path` property (if it exists).
*/
readonly path?: string | string[] | null;
/**
* The title to use for this route when matched.
*
* If left blank, this route will not contribute to the generated title.
*/
readonly title?: string | ((node: RouteNode) => string | null) | null;
/**
* The path to which to redirect when the url matches the path in this config.
*/
readonly redirectTo?: string | null;
/**
* Whether the `path` should be case sensitive.
*/
readonly caseSensitive?: boolean;
/**
* How to behave when this component scheduled to be loaded again in the same viewport:
*
* - `replace`: completely removes the current component and creates a new one, behaving as if the component changed (default if only the parameters have changed).
* - `invoke-lifecycles`: calls `canUnload`, `canLoad`, `unloading` and `loading`.
* - `none`: does nothing (default if nothing has changed for the viewport).
*/
readonly transitionPlan?: TransitionPlanOrFunc | null;
/**
* The name of the viewport this component should be loaded into.
*/
readonly viewport?: string | null;
/**
* Any custom data that should be accessible to matched components or hooks.
*/
readonly data?: Record<string, unknown>;
/**
* The child routes that can be navigated to from this route. See `Routeable` for more information.
*/
readonly routes?: readonly Routeable[];
/**
* When set, will be used to redirect unknown/unconfigured routes to this route.
* Can be a route-id, route-path (route), or a custom element name; this is also the resolution/fallback order.
*/
readonly fallback?: string | FallbackFunction | null;
/**
* When set to `false`, the routes won't be included in the navigation model.
*
* @default true
*/
readonly nav?: boolean;
/**
* When set, will be used to redirect unknown/unconfigured routes to this route.
* Can be a route-id, route-path (route), or a custom element name; this is also the resolution/fallback order.
*/
readonly fallback?: string | FallbackFunction | null;
/**
* When set to `false`, the routes won't be included in the navigation model.
*
* @default true
*/
readonly nav?: boolean;
}

@@ -102,5 +106,13 @@ export interface IChildRouteConfig extends IRouteConfig {

export class RouteConfig implements IRouteConfig, IChildRouteConfig {
protected constructor(
public readonly id: string | null,
public readonly path: string | string[] | null,
/** @internal */
public _configurationFromHookApplied: boolean = false;
public get path(): string[] {
const path = this._path;
if (path.length > 0) return path;
return this._path = [CustomElement.getDefinition(this.component as RouteType).name];
}
private constructor(
public readonly id: string,
/** @internal */
public _path: string[],
public readonly title: string | ((node: RouteNode) => string | null) | null,

@@ -110,3 +122,3 @@ public readonly redirectTo: string | null,

public readonly transitionPlan: TransitionPlanOrFunc | null,
public readonly viewport: string | null,
public readonly viewport: string,
public readonly data: Record<string, unknown>,

@@ -120,12 +132,15 @@ public readonly routes: readonly Routeable[],

/** @internal */
public static _create(configOrPath: IRouteConfig | IChildRouteConfig | string | string[], Type: RouteType | null, parentConfig: RouteConfig | null): RouteConfig {
public static _create(
configOrPath: IRouteConfig | IChildRouteConfig | string | string[],
Type: RouteType | null,
): RouteConfig {
if (typeof configOrPath === 'string' || configOrPath instanceof Array) {
const path = configOrPath;
const path = ensureArrayOfStrings(configOrPath);
const redirectTo = Type?.redirectTo ?? null;
const caseSensitive = Type?.caseSensitive ?? false;
const id = Type?.id ?? (path instanceof Array ? path[0] : path);
const id = ensureString(Type?.id ?? (path instanceof Array ? path[0] : path));
const title = Type?.title ?? null;
const reentryBehavior = Type?.transitionPlan ?? parentConfig?.transitionPlan ?? null;
const viewport = Type?.viewport ?? null;
const reentryBehavior = Type?.transitionPlan ?? null;
const viewport = Type?.viewport ?? defaultViewportName;
const data = Type?.data ?? {};

@@ -145,3 +160,3 @@ const children = Type?.routes ?? noRoutes;

Type?.fallback ?? null,
null!, // TODO(sayan): find a TS-wise clearer way to deal with this.
Type as Routeable,
Type?.nav ?? true,

@@ -153,3 +168,3 @@ );

const path = config.path ?? Type?.path ?? null;
const path = ensureArrayOfStrings(config.path ?? Type?.path ?? emptyArray);
const title = config.title ?? Type?.title ?? null;

@@ -159,4 +174,4 @@ const redirectTo = config.redirectTo ?? Type?.redirectTo ?? null;

const id = config.id ?? Type?.id ?? (path instanceof Array ? path[0] : path);
const reentryBehavior = config.transitionPlan ?? Type?.transitionPlan ?? parentConfig?.transitionPlan ?? null;
const viewport = config.viewport ?? Type?.viewport ?? null;
const reentryBehavior = config.transitionPlan ?? Type?.transitionPlan ?? /* parentConfig?.transitionPlan ?? */ null;
const viewport = config.viewport ?? Type?.viewport ?? defaultViewportName;
const data = {

@@ -181,3 +196,3 @@ ...Type?.data,

config.fallback ?? Type?.fallback ?? null,
(config as IChildRouteConfig).component ?? null,
(config as IChildRouteConfig).component ?? Type ?? null,
config.nav ?? true,

@@ -191,14 +206,14 @@ );

/**
* Invoked when this component is used as a child under another parent.
* Creates a new route config applying the child route config.
* Note that the current rote config is not mutated.
*
* @internal
*/
public applyChildRouteConfig(config: IChildRouteConfig, parentConfig: RouteConfig | null): RouteConfig {
let parentPath = this.path ?? '';
if (typeof parentPath !== 'string') {
parentPath = parentPath[0];
}
validateRouteConfig(config, parentPath);
validateRouteConfig(config, this.path[0] ?? '');
const path = ensureArrayOfStrings(config.path ?? this.path);
return new RouteConfig(
config.id ?? this.id,
config.path ?? this.path,
ensureString(config.id ?? this.id ?? path),
path,
config.title ?? this.title,

@@ -211,4 +226,4 @@ config.redirectTo ?? this.redirectTo,

config.routes ?? this.routes,
config.fallback ?? this.fallback,
config.component ?? this.component,
config.fallback ?? this.fallback ?? parentConfig?.fallback ?? null,
this.component, // The RouteConfig is created using a definitive Type as component; do not overwrite it.
config.nav ?? this.nav,

@@ -222,2 +237,70 @@ );

}
/** @internal */
public _applyFromConfigurationHook(instance: IRouteViewModel, parent: IRouteConfig | null, routeNode: RouteNode | null): void | Promise<void> {
// start strict
if (this._configurationFromHookApplied) throw new Error('Invalid operation, the configuration from the get hook is already applied.');
if (typeof instance.getRouteConfig !== 'function') return;
return onResolve(
instance.getRouteConfig(parent, routeNode),
value => {
this._configurationFromHookApplied = true;
if (value == null) return;
let parentPath = parent?.path ?? '';
if (typeof parentPath !== 'string') {
parentPath = parentPath[0];
}
validateRouteConfig(value, parentPath);
// the value from the hook takes precedence
(this as Writable<RouteConfig>).id = value.id ?? this.id;
(this as Writable<RouteConfig>)._path = ensureArrayOfStrings(value.path ?? this.path);
(this as Writable<RouteConfig>).title = value.title ?? this.title;
(this as Writable<RouteConfig>).redirectTo = value.redirectTo ?? this.redirectTo;
(this as Writable<RouteConfig>).caseSensitive = value.caseSensitive ?? this.caseSensitive;
(this as Writable<RouteConfig>).transitionPlan = value.transitionPlan ?? this.transitionPlan;
(this as Writable<RouteConfig>).viewport = value.viewport ?? this.viewport;
(this as Writable<RouteConfig>).data = value.data ?? this.data;
(this as Writable<RouteConfig>).routes = value.routes ?? this.routes;
(this as Writable<RouteConfig>).fallback = value.fallback ?? this.fallback;
(this as Writable<RouteConfig>).nav = value.nav ?? this.nav;
});
}
/** @internal */
public _clone(): RouteConfig {
return new RouteConfig(
this.id,
this.path,
this.title,
this.redirectTo,
this.caseSensitive,
this.transitionPlan,
this.viewport,
this.data,
this.routes,
this.fallback,
this.component,
this.nav,
);
}
/** @internal */
public _getFallback(viewportInstruction: ViewportInstruction, routeNode: RouteNode, context: IRouteContext): string | null {
const fallback = this.fallback;
return typeof fallback === 'function'
? fallback(viewportInstruction, routeNode, context)
: fallback;
}
public register(container: IContainer): void {
/**
* When an instance of the RouteConfig is created, via the static `_create` and `resolveRouteConfiguration`, the component is always resolved to a custom element.
* This makes the process to registering to registering the custom element to the DI.
* The component can only be null for redirection configurations and that is ignored here.
*/
const component= this.component;
if(component == null) return;
container.register(component);
}
}

@@ -236,4 +319,7 @@

*/
configure<T extends RouteType>(configOrPath: IRouteConfig | IChildRouteConfig | string | string[], Type: T): T {
const config = RouteConfig._create(configOrPath, Type, null);
configure<T extends RouteType>(
configOrPath: IRouteConfig | IChildRouteConfig | string | string[],
Type: T,
): T {
const config = RouteConfig._create(configOrPath, Type /* , isDefinedByType , null */);
Metadata.define(Route.name, config, Type);

@@ -250,3 +336,3 @@

// However there might still be static properties, and this API provides a unified way of accessing those.
Route.configure({}, Type);
Route.configure({}, Type/* , false */);
}

@@ -287,4 +373,68 @@

return function (target) {
return Route.configure(configOrPath, target);
return Route.configure(configOrPath, target/* , true */);
};
}
/** @internal */
export function resolveRouteConfiguration(routeable: Routeable, isChild: boolean, parent: RouteConfig | null, routeNode: RouteNode | null, context: IRouteContext | null): RouteConfig | Promise<RouteConfig> {
if (isPartialRedirectRouteConfig(routeable)) return RouteConfig._create(routeable, null/* , false */);
const [instruction, ceDef] = resolveCustomElementDefinition(routeable, context);
return onResolve(ceDef, $ceDef => {
const type = $ceDef.Type;
const routeConfig = Route.getConfig(type);
// If the component is used as a child, then apply the child configuration (comping from parent) and return a new RouteConfig with the configuration applied.
if (isPartialChildRouteConfig(routeable)) return routeConfig.applyChildRouteConfig(routeable, parent);
// If the component is used as a child, then return a clone.
// Rationale: as this component can be used multiple times as child (either under same parent or different parents), we don't want to mutate the original route config for the type.
if (isChild) return routeConfig._clone();
if (
!routeConfig._configurationFromHookApplied
&& instruction.type === NavigationInstructionType.IRouteViewModel
&& typeof (routeable as IRouteViewModel).getRouteConfig === 'function'
) {
return onResolve(routeConfig._applyFromConfigurationHook(routeable, parent, routeNode), () => routeConfig);
}
return routeConfig;
});
}
/** @internal */
export function resolveCustomElementDefinition(routeable: Routeable, context: IRouteContext | null | undefined): [instruction: ITypedNavigationInstruction_Component, ceDef: CustomElementDefinition | Promise<CustomElementDefinition>] {
const instruction = createNavigationInstruction(routeable);
let ceDef: CustomElementDefinition | Promise<CustomElementDefinition>;
switch (instruction.type) {
case NavigationInstructionType.string: {
if (context == null) throw new Error(`When retrieving the RouteConfig for a component name, a RouteContext (that can resolve it) must be provided`);
const component = context.container.find(CustomElement, instruction.value);
if (component === null) throw new Error(`Could not find a CustomElement named '${instruction.value}' in the current container scope of ${context}. This means the component is neither registered at Aurelia startup nor via the 'dependencies' decorator or static property.`);
ceDef = component;
break;
}
case NavigationInstructionType.CustomElementDefinition:
ceDef = instruction.value;
break;
case NavigationInstructionType.IRouteViewModel:
// Get the class from the constructor property. There might be static properties on it.
ceDef = CustomElement.getDefinition(instruction.value.constructor as RouteType);
break;
case NavigationInstructionType.Promise:
if (context == null)
throw new Error(`RouteContext must be provided when resolving an imported module`);
ceDef = context.resolveLazy(instruction.value);
break;
}
return [instruction, ceDef];
}
function createNavigationInstruction(routeable: Exclude<Routeable, IRedirectRouteConfig>): ITypedNavigationInstruction_Component {
return isPartialChildRouteConfig(routeable)
? createNavigationInstruction(routeable.component)
: TypedNavigationInstruction.create(routeable);
}
import { isObject } from '@aurelia/metadata';
import { IContainer, ILogger, DI, IDisposable, onResolve, Writable, resolveAll } from '@aurelia/kernel';
import { type CustomElementDefinition, IPlatform } from '@aurelia/runtime-html';
import { CustomElement, CustomElementDefinition, IPlatform } from '@aurelia/runtime-html';

@@ -8,3 +8,3 @@ import { IRouteContext, RouteContext } from './route-context';

import { ILocationManager } from './location-manager';
import { RouteType } from './route';
import { resolveRouteConfiguration, RouteConfig, RouteType } from './route';
import { IRouteViewModel } from './component-agent';

@@ -14,3 +14,2 @@ import { RouteTree, RouteNode, createAndAppendNodes } from './route-tree';

import { Batch, mergeDistinct, UnwrapPromise } from './util';
import { RouteDefinition } from './route-definition';
import { type ViewportAgent } from './viewport-agent';

@@ -103,4 +102,4 @@ import { INavigationOptions, NavigationOptions, type RouterOptions, IRouterOptions } from './options';

type RouteDefinitionLookup = WeakMap<RouteDefinition, IRouteContext>;
type ViewportAgentLookup = Map<ViewportAgent | null, RouteDefinitionLookup>;
type RouteConfigLookup = WeakMap<RouteConfig, IRouteContext>;
type ViewportAgentLookup = Map<ViewportAgent | null, RouteConfigLookup>;

@@ -138,4 +137,4 @@ export interface IRouter extends Router { }

instruction: null,
component: ctx.definition.component!,
title: ctx.definition.config.title,
component: CustomElement.getDefinition(ctx.config.component as RouteType),
title: ctx.config.title,
}),

@@ -359,3 +358,5 @@ );

container: IContainer,
parentDefinition: RouteDefinition | null,
parentRouteConfig: RouteConfig | null,
parentContext: IRouteContext | null,
$rdConfig: RouteConfig | null,
): IRouteContext | Promise<IRouteContext> {

@@ -366,20 +367,28 @@ const logger = container.get(ILogger).scopeTo('RouteContext');

return onResolve(
RouteDefinition.resolve(typeof componentInstance?.getRouteConfig === 'function' ? componentInstance : componentDefinition.Type, parentDefinition, null),
routeDefinition => {
let routeDefinitionLookup = this.vpaLookup.get(viewportAgent);
if (routeDefinitionLookup === void 0) {
this.vpaLookup.set(viewportAgent, routeDefinitionLookup = new WeakMap());
$rdConfig instanceof RouteConfig
? $rdConfig
: resolveRouteConfiguration(
typeof componentInstance?.getRouteConfig === 'function' ? componentInstance : componentDefinition.Type,
false,
parentRouteConfig,
null,
parentContext
),
rdConfig => {
let routeConfigLookup = this.vpaLookup.get(viewportAgent);
if (routeConfigLookup === void 0) {
this.vpaLookup.set(viewportAgent, routeConfigLookup = new WeakMap());
}
let routeContext = routeDefinitionLookup.get(routeDefinition);
let routeContext = routeConfigLookup.get(rdConfig);
if (routeContext !== void 0) {
logger.trace(`returning existing RouteContext for %s`, routeDefinition);
logger.trace(`returning existing RouteContext for %s`, rdConfig);
return routeContext;
}
logger.trace(`creating new RouteContext for %s`, routeDefinition);
logger.trace(`creating new RouteContext for %s`, rdConfig);
const parent = container.has(IRouteContext, true) ? container.get(IRouteContext) : null;
routeDefinitionLookup.set(
routeDefinition,
routeConfigLookup.set(
rdConfig,
routeContext = new RouteContext(

@@ -389,3 +398,3 @@ viewportAgent,

componentDefinition,
routeDefinition,
rdConfig,
container,

@@ -600,3 +609,3 @@ this,

for (const node of prev) {
node.context.vpa.canUnload(tr, b);
node.context.vpa._canUnload(tr, b);
}

@@ -611,3 +620,3 @@ }).continueWith(b => {

for (const node of next) {
node.context.vpa.canLoad(tr, b);
node.context.vpa._canLoad(tr, b);
}

@@ -622,3 +631,3 @@ }).continueWith(b => {

for (const node of prev) {
node.context.vpa.unloading(tr, b);
node.context.vpa._unloading(tr, b);
}

@@ -628,3 +637,3 @@ }).continueWith(b => {

for (const node of next) {
node.context.vpa.loading(tr, b);
node.context.vpa._loading(tr, b);
}

@@ -634,3 +643,3 @@ }).continueWith(b => {

for (const node of all) {
node.context.vpa.swap(tr, b);
node.context.vpa._swap(tr, b);
}

@@ -641,3 +650,3 @@ }).continueWith(() => {

all.forEach(function (node) {
node.context.vpa.endTransition();
node.context.vpa._endTransition();
});

@@ -703,3 +712,3 @@ this.navigated = true;

all.forEach(function (node) {
node.context.vpa.cancelUpdate();
node.context.vpa._cancelUpdate();
});

@@ -757,3 +766,3 @@

if (!node.context.isRoot) {
node.context.vpa.scheduleUpdate(node.tree.options, node);
node.context.vpa._scheduleUpdate(node.tree.options, node);
}

@@ -760,0 +769,0 @@ if (node.context === ctx) {

@@ -75,3 +75,4 @@ // No-fallthrough disabled due to large numbers of false positives

public activateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void> {
/** @internal */
public _activateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void> {
const tr = this.currTransition;

@@ -89,5 +90,5 @@ if (tr !== null) { ensureTransitionHasNotErrored(tr); }

this.logger.trace(`activateFromViewport() - activating existing componentAgent at %s`, this);
return this.curCA!.activate(initiator, parent);
return this.curCA!._activate(initiator, parent);
default:
this.unexpectedState('activateFromViewport 1');
this._unexpectedState('activateFromViewport 1');
}

@@ -99,3 +100,3 @@ case State.nextLoadDone: {

this.logger.trace(`activateFromViewport() - running ordinary activate at %s`, this);
const b = Batch.start(b1 => { this.activate(initiator, this.currTransition!, b1); });
const b = Batch.start(b1 => { this._activate(initiator, this.currTransition!, b1); });
const p = new Promise<void>(resolve => { b.continueWith(() => { resolve(); }); });

@@ -105,7 +106,8 @@ return b.start().done ? void 0 : p;

default:
this.unexpectedState('activateFromViewport 2');
this._unexpectedState('activateFromViewport 2');
}
}
public deactivateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void> {
/** @internal */
public _deactivateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void> {
const tr = this.currTransition;

@@ -121,3 +123,3 @@ if (tr !== null) { ensureTransitionHasNotErrored(tr); }

this.logger.trace(`deactivateFromViewport() - deactivating existing componentAgent at %s`, this);
return this.curCA!.deactivate(initiator, parent);
return this.curCA!._deactivate(initiator, parent);
case State.currDeactivate:

@@ -134,3 +136,3 @@ // This will happen with bottom-up deactivation because the child is already deactivated, the parent

this.logger.trace(`deactivateFromViewport() - running ordinary deactivate at %s`, this);
const b = Batch.start(b1 => { this.deactivate(initiator, this.currTransition!, b1); });
const b = Batch.start(b1 => { this._deactivate(initiator, this.currTransition!, b1); });
const p = new Promise<void>(resolve => { b.continueWith(() => { resolve(); }); });

@@ -142,4 +144,5 @@ return b.start().done ? void 0 : p;

public handles(req: ViewportRequest): boolean {
if (!this.isAvailable()) {
/** @internal */
public _handles(req: ViewportRequest): boolean {
if (!this._isAvailable()) {
return false;

@@ -185,3 +188,4 @@ }

public isAvailable(): boolean {
/** @internal */
public _isAvailable(): boolean {
if (!this.isActive) {

@@ -200,3 +204,4 @@ this.logger.trace(`isAvailable -> false (viewport is not active)`);

public canUnload(tr: Transition, b: Batch): void {
/** @internal */
public _canUnload(tr: Transition, b: Batch): void {
if (this.currTransition === null) { this.currTransition = tr; }

@@ -213,3 +218,3 @@ ensureTransitionHasNotErrored(tr);

for (const node of this.currNode!.children) {
node.context.vpa.canUnload(tr, b1);
node.context.vpa._canUnload(tr, b1);
}

@@ -230,3 +235,3 @@ }).continueWith(b1 => {

this.logger.trace(`canUnload() - finished invoking on children, now invoking on own component at %s`, this);
this.curCA!.canUnload(tr, this.nextNode, b2);
this.curCA!._canUnload(tr, this.nextNode, b2);
}).continueWith(() => {

@@ -251,3 +256,4 @@ this.logger.trace(`canUnload() - finished at %s`, this);

public canLoad(tr: Transition, b: Batch): void {
/** @internal */
public _canLoad(tr: Transition, b: Batch): void {
if (this.currTransition === null) { this.currTransition = tr; }

@@ -269,3 +275,3 @@ ensureTransitionHasNotErrored(tr);

case 'invoke-lifecycles':
return this.curCA!.canLoad(tr, this.nextNode!, b1);
return this.curCA!._canLoad(tr, this.nextNode!, b1);
case 'replace':

@@ -276,3 +282,3 @@ b1.push();

ca => {
(this.nextCA = ca).canLoad(tr, this.nextNode!, b1);
(this.nextCA = ca)._canLoad(tr, this.nextNode!, b1);
b1.pop();

@@ -286,3 +292,3 @@ }

default:
this.unexpectedState('canLoad');
this._unexpectedState('canLoad');
}

@@ -335,3 +341,3 @@ }).continueWith(b1 => {

for (const node of this.nextNode!.children) {
node.context.vpa.canLoad(tr, b1);
node.context.vpa._canLoad(tr, b1);
}

@@ -342,3 +348,3 @@ return;

default:
this.unexpectedState('canLoad');
this._unexpectedState('canLoad');
}

@@ -351,3 +357,4 @@ }).continueWith(() => {

public unloading(tr: Transition, b: Batch): void {
/** @internal */
public _unloading(tr: Transition, b: Batch): void {
ensureTransitionHasNotErrored(tr);

@@ -362,3 +369,3 @@ ensureGuardsResultIsTrue(this, tr);

for (const node of this.currNode!.children) {
node.context.vpa.unloading(tr, b1);
node.context.vpa._unloading(tr, b1);
}

@@ -379,3 +386,3 @@ }).continueWith(b1 => {

this.logger.trace(`unloading() - finished invoking on children, now invoking on own component at %s`, this);
this.curCA!.unloading(tr, this.nextNode, b2);
this.curCA!._unloading(tr, this.nextNode, b2);
}).continueWith(() => {

@@ -391,7 +398,7 @@ this.logger.trace(`unloading() - finished at %s`, this);

for (const node of this.currNode!.children) {
node.context.vpa.unloading(tr, b);
node.context.vpa._unloading(tr, b);
}
return;
default:
this.unexpectedState('unloading');
this._unexpectedState('unloading');
}

@@ -403,3 +410,4 @@ }).continueWith(() => {

public loading(tr: Transition, b: Batch): void {
/** @internal */
public _loading(tr: Transition, b: Batch): void {
ensureTransitionHasNotErrored(tr);

@@ -420,5 +428,5 @@ ensureGuardsResultIsTrue(this, tr);

case 'invoke-lifecycles':
return this.curCA!.loading(tr, this.nextNode!, b1);
return this.curCA!._loading(tr, this.nextNode!, b1);
case 'replace':
return this.nextCA!.loading(tr, this.nextNode!, b1);
return this.nextCA!._loading(tr, this.nextNode!, b1);
}

@@ -430,3 +438,3 @@ }

default:
this.unexpectedState('loading');
this._unexpectedState('loading');
}

@@ -439,3 +447,3 @@ }).continueWith(b1 => {

for (const node of this.nextNode!.children) {
node.context.vpa.loading(tr, b1);
node.context.vpa._loading(tr, b1);
}

@@ -446,3 +454,3 @@ return;

default:
this.unexpectedState('loading');
this._unexpectedState('loading');
}

@@ -455,3 +463,4 @@ }).continueWith(() => {

public deactivate(initiator: IHydratedController | null, tr: Transition, b: Batch): void {
/** @internal */
private _deactivate(initiator: IHydratedController | null, tr: Transition, b: Batch): void {
ensureTransitionHasNotErrored(tr);

@@ -473,4 +482,10 @@ ensureGuardsResultIsTrue(this, tr);

const controller = this.hostController;
const curCa = this.curCA!;
tr.run(() => {
return this.curCA!.deactivate(initiator, controller);
return onResolve(curCa._deactivate(initiator, controller), () => {
// Call dispose if initiator is null. If there is an initiator present, then the curCa will be disposed when the initiator is disposed.
if (initiator === null) {
curCa._dispose();
}
});
}, () => {

@@ -491,7 +506,8 @@ b.pop();

default:
this.unexpectedState('deactivate');
this._unexpectedState('deactivate');
}
}
public activate(initiator: IHydratedController | null, tr: Transition, b: Batch): void {
/** @internal */
private _activate(initiator: IHydratedController | null, tr: Transition, b: Batch): void {
ensureTransitionHasNotErrored(tr);

@@ -506,7 +522,7 @@ ensureGuardsResultIsTrue(this, tr);

Batch.start(b1 => {
this.canLoad(tr, b1);
this._canLoad(tr, b1);
}).continueWith(b1 => {
this.loading(tr, b1);
this._loading(tr, b1);
}).continueWith(b1 => {
this.activate(initiator, tr, b1);
this._activate(initiator, tr, b1);
}).continueWith(() => {

@@ -532,3 +548,3 @@ b.pop();

b1.push();
return this.nextCA!.activate(initiator, controller);
return this.nextCA!._activate(initiator, controller);
}, () => {

@@ -540,3 +556,3 @@ b1.pop();

}).continueWith(b1 => {
this.processDynamicChildren(tr, b1);
this._processDynamicChildren(tr, b1);
}).continueWith(() => {

@@ -551,10 +567,11 @@ b.pop();

default:
this.unexpectedState('activate');
this._unexpectedState('activate');
}
}
public swap(tr: Transition, b: Batch): void {
/** @internal */
public _swap(tr: Transition, b: Batch): void {
if (this.currState === State.currIsEmpty) {
this.logger.trace(`swap() - running activate on next instead, because there is nothing to deactivate at %s`, this);
this.activate(null, tr, b);
this._activate(null, tr, b);
return;

@@ -564,3 +581,3 @@ }

this.logger.trace(`swap() - running deactivate on current instead, because there is nothing to activate at %s`, this);
this.deactivate(null, tr, b);
this._deactivate(null, tr, b);
return;

@@ -576,3 +593,3 @@ }

)) {
this.unexpectedState('swap');
this._unexpectedState('swap');
}

@@ -589,3 +606,3 @@

for (const node of nodes) {
node.context.vpa.swap(tr, b);
node.context.vpa._swap(tr, b);
}

@@ -603,3 +620,3 @@ return;

b1.push();
return onResolve(curCA.deactivate(null, controller), () => curCA.dispose());
return onResolve(curCA._deactivate(null, controller), () => curCA._dispose());
}, () => {

@@ -611,3 +628,3 @@ b1.pop();

b1.push();
return nextCA.activate(null, controller);
return nextCA._activate(null, controller);
}, () => {

@@ -617,3 +634,3 @@ b1.pop();

}).continueWith(b1 => {
this.processDynamicChildren(tr, b1);
this._processDynamicChildren(tr, b1);
}).continueWith(() => {

@@ -627,3 +644,4 @@ b.pop();

private processDynamicChildren(tr: Transition, b: Batch): void {
/** @internal */
private _processDynamicChildren(tr: Transition, b: Batch): void {
this.logger.trace(`processDynamicChildren() - %s`, this);

@@ -662,3 +680,3 @@ const next = this.nextNode!;

b1.push();
return node.context.vpa.canLoad(tr, b1);
return node.context.vpa._canLoad(tr, b1);
}, () => {

@@ -672,3 +690,3 @@ b1.pop();

b1.push();
return node.context.vpa.loading(tr, b1);
return node.context.vpa._loading(tr, b1);
}, () => {

@@ -682,3 +700,3 @@ b1.pop();

b1.push();
return node.context.vpa.activate(null, tr, b1);
return node.context.vpa._activate(null, tr, b1);
}, () => {

@@ -694,3 +712,4 @@ b1.pop();

public scheduleUpdate(options: NavigationOptions, next: RouteNode): void {
/** @internal */
public _scheduleUpdate(options: NavigationOptions, next: RouteNode): void {
switch (this.nextState) {

@@ -702,3 +721,3 @@ case State.nextIsEmpty:

default:
this.unexpectedState('scheduleUpdate 1');
this._unexpectedState('scheduleUpdate 1');
}

@@ -712,3 +731,3 @@

default:
this.unexpectedState('scheduleUpdate 2');
this._unexpectedState('scheduleUpdate 2');
}

@@ -722,3 +741,3 @@

// Component is the same, so determine plan based on config and/or convention
this.$plan = next.context.definition.config.getTransitionPlan(cur, next);
this.$plan = options.transitionPlan ?? next.context.config.getTransitionPlan(cur, next);
}

@@ -729,6 +748,7 @@

public cancelUpdate(): void {
/** @internal */
public _cancelUpdate(): void {
if (this.currNode !== null) {
this.currNode.children.forEach(function (node) {
node.context.vpa.cancelUpdate();
node.context.vpa._cancelUpdate();
});

@@ -738,3 +758,3 @@ }

this.nextNode.children.forEach(function (node) {
node.context.vpa.cancelUpdate();
node.context.vpa._cancelUpdate();
});

@@ -771,4 +791,4 @@ }

case State.nextActivate: {
this._cancellationPromise = onResolve(this.nextCA?.deactivate(null, this.hostController), () => {
this.nextCA?.dispose();
this._cancellationPromise = onResolve(this.nextCA?._deactivate(null, this.hostController), () => {
this.nextCA?._dispose();
this.$plan = 'replace';

@@ -786,6 +806,7 @@ this.nextState = State.nextIsEmpty;

public endTransition(): void {
/** @internal */
public _endTransition(): void {
if (this.currNode !== null) {
this.currNode.children.forEach(function (node) {
node.context.vpa.endTransition();
node.context.vpa._endTransition();
});

@@ -795,3 +816,3 @@ }

this.nextNode.children.forEach(function (node) {
node.context.vpa.endTransition();
node.context.vpa._endTransition();
});

@@ -813,3 +834,3 @@ }

default:
this.unexpectedState('endTransition 1');
this._unexpectedState('endTransition 1');
}

@@ -838,7 +859,7 @@ break;

default:
this.unexpectedState('endTransition 2');
this._unexpectedState('endTransition 2');
}
break;
default:
this.unexpectedState('endTransition 3');
this._unexpectedState('endTransition 3');
}

@@ -858,8 +879,10 @@

public dispose(): void {
/** @internal */
public _dispose(): void {
this.logger.trace(`dispose() - disposing %s`, this);
this.curCA?.dispose();
this.curCA?._dispose();
}
private unexpectedState(label: string): never {
/** @internal */
private _unexpectedState(label: string): never {
throw new Error(`Unexpected state at ${label} of ${this}`);

@@ -866,0 +889,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc