Socket
Socket
Sign inDemoInstall

@aurelia/router-lite

Package Overview
Dependencies
Maintainers
1
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurelia/router-lite - npm Package Compare versions

Comparing version 2.0.0-beta.2 to 2.0.0-beta.3

6

dist/types/component-agent.d.ts

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

import type { LifecycleFlags, ICustomElementController, IHydratedController, ICustomElementViewModel, ILifecycleHooks } from '@aurelia/runtime-html';
import type { ICustomElementController, IHydratedController, ICustomElementViewModel, ILifecycleHooks } from '@aurelia/runtime-html';
import type { RouteDefinition } from './route-definition';

@@ -34,4 +34,4 @@ import type { RouteNode } from './route-tree';

constructor(instance: T, controller: ICustomElementController<T>, definition: RouteDefinition, routeNode: RouteNode, ctx: IRouteContext, routerOptions: RouterOptions);
activate(initiator: IHydratedController | null, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void>;
deactivate(initiator: IHydratedController | null, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void>;
activate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void>;
deactivate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void>;
dispose(): void;

@@ -38,0 +38,0 @@ canUnload(tr: Transition, next: RouteNode | null, b: Batch): void;

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

export { type IViewport, } from './resources/viewport';
export { type IViewport, FallbackFunction, } from './resources/viewport';
export { RouterConfiguration, RouterRegistration, DefaultComponents, DefaultResources, ViewportCustomElement, ViewportCustomElementRegistration, LoadCustomAttribute, LoadCustomAttributeRegistration, HrefCustomAttribute, HrefCustomAttributeRegistration, IRouterConfigurationOptions, } from './configuration';
export { type IRouteViewModel, ComponentAgent, } from './component-agent';
export { type RouteableComponent, type NavigationInstruction, IViewportInstruction, type Params, } from './instructions';
export { type RouteableComponent, type NavigationInstruction, IViewportInstruction, type Params, type ViewportInstruction, ITypedNavigationInstruction, ITypedNavigationInstruction_string, ITypedNavigationInstruction_ViewportInstruction, ITypedNavigationInstruction_CustomElementDefinition, ITypedNavigationInstruction_Promise, ITypedNavigationInstruction_IRouteViewModel, } from './instructions';
export { ILocationManager, } from './location-manager';

@@ -6,0 +6,0 @@ export { type Routeable, type IRouteConfig, type IChildRouteConfig, RouteConfig, Route, type RouteType, route, } from './route';

import { ILogger } from '@aurelia/kernel';
import { type LifecycleFlags, ICustomElementViewModel, IHydratedController, ICompiledCustomElementController } from '@aurelia/runtime-html';
import { ICustomElementViewModel, IHydratedController, ICompiledCustomElementController } from '@aurelia/runtime-html';
import { IRouteContext } from '../route-context';
import { type ViewportInstruction } from '../instructions';
import { type RouteNode } from '../route-tree';
export type FallbackFunction = (viewportInstruction: ViewportInstruction, routeNode: RouteNode, context: IRouteContext) => string | null;
export interface IViewport {

@@ -8,3 +11,3 @@ readonly name: string;

readonly default: string;
readonly fallback: string;
readonly fallback: string | FallbackFunction;
}

@@ -17,3 +20,3 @@ export declare class ViewportCustomElement implements ICustomElementViewModel, IViewport {

default: string;
fallback: string;
fallback: string | FallbackFunction;
private agent;

@@ -23,4 +26,4 @@ private controller;

hydrated(controller: ICompiledCustomElementController): void;
attaching(initiator: IHydratedController, _parent: IHydratedController, flags: LifecycleFlags): void | Promise<void>;
detaching(initiator: IHydratedController, _parent: IHydratedController, flags: LifecycleFlags): void | Promise<void>;
attaching(initiator: IHydratedController, _parent: IHydratedController): void | Promise<void>;
detaching(initiator: IHydratedController, _parent: IHydratedController): void | Promise<void>;
dispose(): void;

@@ -27,0 +30,0 @@ toString(): string;

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

import type { RouteNode } from './route-tree';
import { FallbackFunction } from './resources/viewport';
export declare class RouteDefinition {

@@ -17,3 +18,3 @@ readonly config: RouteConfig;

readonly data: Record<string, unknown>;
readonly fallback: string | null;
readonly fallback: string | FallbackFunction | null;
constructor(config: RouteConfig, component: CustomElementDefinition | null, parentDefinition: RouteDefinition | null);

@@ -20,0 +21,0 @@ static resolve(routeable: Promise<IModule>, parentDefinition: RouteDefinition | null, routeNode: RouteNode | null, context: IRouteContext): RouteDefinition | Promise<RouteDefinition>;

import { Constructable, ResourceType } from '@aurelia/kernel';
import { RouteableComponent } from './instructions';
import type { RouteNode } from './route-tree';
import { FallbackFunction } from './resources/viewport';
/**

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

*/
readonly fallback?: string | null;
readonly fallback?: string | FallbackFunction | null;
/**

@@ -93,6 +94,6 @@ * When set to `false`, the routes won't be included in the navigation model.

readonly routes: readonly Routeable[];
readonly fallback: string | null;
readonly fallback: string | FallbackFunction | null;
readonly component: 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 | null, component: Routeable, 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);
/**

@@ -99,0 +100,0 @@ * Creates a new route config applying the child route config.

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

import { LifecycleFlags, type IHydratedController, type ICustomElementController } from '@aurelia/runtime-html';
import { type IHydratedController, type ICustomElementController } from '@aurelia/runtime-html';
import type { IViewport } from './resources/viewport';

@@ -34,4 +34,4 @@ import { type RouteNode } from './route-tree';

static for(viewport: IViewport, ctx: IRouteContext): ViewportAgent;
activateFromViewport(initiator: IHydratedController, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void>;
deactivateFromViewport(initiator: IHydratedController, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void>;
activateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void>;
deactivateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void>;
handles(req: ViewportRequest): boolean;

@@ -38,0 +38,0 @@ isAvailable(): boolean;

{
"name": "@aurelia/router-lite",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"main": "dist/cjs/index.cjs",

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

"dependencies": {
"@aurelia/kernel": "2.0.0-beta.2",
"@aurelia/metadata": "2.0.0-beta.2",
"@aurelia/platform": "2.0.0-beta.2",
"@aurelia/platform-browser": "2.0.0-beta.2",
"@aurelia/route-recognizer": "2.0.0-beta.2",
"@aurelia/runtime": "2.0.0-beta.2",
"@aurelia/runtime-html": "2.0.0-beta.2"
"@aurelia/kernel": "2.0.0-beta.3",
"@aurelia/metadata": "2.0.0-beta.3",
"@aurelia/platform": "2.0.0-beta.3",
"@aurelia/platform-browser": "2.0.0-beta.3",
"@aurelia/route-recognizer": "2.0.0-beta.3",
"@aurelia/runtime": "2.0.0-beta.3",
"@aurelia/runtime-html": "2.0.0-beta.3"
},

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

import { ILogger } from '@aurelia/kernel';
import type { LifecycleFlags, ICustomElementController, IHydratedController, ICustomElementViewModel, ILifecycleHooks, LifecycleHooksLookup } from '@aurelia/runtime-html';
import type { ICustomElementController, IHydratedController, ICustomElementViewModel, ILifecycleHooks, LifecycleHooksLookup } from '@aurelia/runtime-html';

@@ -67,6 +67,6 @@ import type { RouteDefinition } from './route-definition';

public activate(initiator: IHydratedController | null, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void> {
public activate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void> {
if (initiator === null) {
this._logger.trace(`activate() - initial`);
return this.controller.activate(this.controller, parent, flags);
return this.controller.activate(this.controller, parent);
}

@@ -76,9 +76,9 @@

// Promise return values from user VM hooks are awaited by the initiator
void this.controller.activate(initiator, parent, flags);
void this.controller.activate(initiator, parent);
}
public deactivate(initiator: IHydratedController | null, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void> {
public deactivate(initiator: IHydratedController | null, parent: IHydratedController): void | Promise<void> {
if (initiator === null) {
this._logger.trace(`deactivate() - initial`);
return this.controller.deactivate(this.controller, parent, flags);
return this.controller.deactivate(this.controller, parent);
}

@@ -88,3 +88,3 @@

// Promise return values from user VM hooks are awaited by the initiator
void this.controller.deactivate(initiator, parent, flags);
void this.controller.deactivate(initiator, parent);
}

@@ -91,0 +91,0 @@

export {
type IViewport,
FallbackFunction,
} from './resources/viewport';

@@ -29,2 +30,9 @@

type Params,
type ViewportInstruction,
ITypedNavigationInstruction,
ITypedNavigationInstruction_string,
ITypedNavigationInstruction_ViewportInstruction,
ITypedNavigationInstruction_CustomElementDefinition,
ITypedNavigationInstruction_Promise,
ITypedNavigationInstruction_IRouteViewModel,
} from './instructions';

@@ -31,0 +39,0 @@

import { ILogger } from '@aurelia/kernel';
import {
type LifecycleFlags,
bindable,

@@ -14,4 +13,7 @@ customElement,

import { IRouteContext } from '../route-context';
import { defaultViewportName } from '../instructions';
import { defaultViewportName, type ViewportInstruction } from '../instructions';
import { type RouteNode } from '../route-tree';
export type FallbackFunction = (viewportInstruction: ViewportInstruction, routeNode: RouteNode, context: IRouteContext) => string | null;
export interface IViewport {

@@ -21,3 +23,5 @@ readonly name: string;

readonly default: string;
readonly fallback: string;
readonly fallback: string | FallbackFunction;
/** @internal */
_getFallback(viewportInstruction: ViewportInstruction, routeNode: RouteNode, context: IRouteContext): string | null;
}

@@ -30,3 +34,3 @@

@bindable public default: string = '';
@bindable public fallback: string = '';
@bindable public fallback: string | FallbackFunction = '';

@@ -45,2 +49,10 @@ private agent: ViewportAgent = (void 0)!;

/** @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 hydrated(controller: ICompiledCustomElementController): void {

@@ -53,12 +65,12 @@ this.logger.trace('hydrated()');

public attaching(initiator: IHydratedController, _parent: IHydratedController, flags: LifecycleFlags): void | Promise<void> {
public attaching(initiator: IHydratedController, _parent: IHydratedController): void | Promise<void> {
this.logger.trace('attaching()');
return this.agent.activateFromViewport(initiator, this.controller, flags);
return this.agent.activateFromViewport(initiator, this.controller);
}
public detaching(initiator: IHydratedController, _parent: IHydratedController, flags: LifecycleFlags): void | Promise<void> {
public detaching(initiator: IHydratedController, _parent: IHydratedController): void | Promise<void> {
this.logger.trace('detaching()');
return this.agent.deactivateFromViewport(initiator, this.controller, flags);
return this.agent.deactivateFromViewport(initiator, this.controller);
}

@@ -65,0 +77,0 @@

@@ -20,2 +20,3 @@ import { Metadata } from '@aurelia/metadata';

defaultViewportName,
type ViewportInstruction,
} from './instructions';

@@ -43,2 +44,3 @@ import {

import type { RouteNode } from './route-tree';
import { FallbackFunction } from './resources/viewport';

@@ -53,3 +55,3 @@ export class RouteDefinition {

public readonly data: Record<string, unknown>;
public readonly fallback: string | null;
public readonly fallback: string | FallbackFunction | null;

@@ -71,2 +73,10 @@ public constructor(

/** @internal */
public _getFallback(viewportInstruction: ViewportInstruction, routeNode: RouteNode, context: IRouteContext): string | null {
const fallback = this.fallback;
return typeof fallback === 'function'
? fallback(viewportInstruction, routeNode, context)
: fallback;
}
// Note on component instance: it is non-null for the root, and when the component agent is created via the route context (if the child routes are not yet configured).

@@ -73,0 +83,0 @@ public static resolve(routeable: Promise<IModule>, parentDefinition: RouteDefinition | null, routeNode: RouteNode | null, context: IRouteContext): RouteDefinition | Promise<RouteDefinition>;

@@ -437,3 +437,5 @@ import {

const vpa = ctx.getFallbackViewportAgent(vp);
const fallback = vpa !== null ? vpa.viewport.fallback : ctx.definition.fallback;
const fallback = vpa !== null
? vpa.viewport._getFallback(vi, node, ctx)
: ctx.definition._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}'?`);

@@ -440,0 +442,0 @@

@@ -7,2 +7,3 @@ import { Metadata } from '@aurelia/metadata';

import type { RouteNode } from './route-tree';
import { FallbackFunction } from './resources/viewport';

@@ -73,3 +74,3 @@ const noRoutes = emptyArray as RouteConfig['routes'];

*/
readonly fallback?: string | null;
readonly fallback?: string | FallbackFunction | null;
/**

@@ -112,3 +113,3 @@ * When set to `false`, the routes won't be included in the navigation model.

public readonly routes: readonly Routeable[],
public readonly fallback: string | null,
public readonly fallback: string | FallbackFunction | null,
public readonly component: Routeable,

@@ -115,0 +116,0 @@ public readonly nav: boolean,

@@ -187,5 +187,2 @@ import { isObject } from '@aurelia/metadata';

/** @internal */
private _cannotBeUnloaded: boolean = false;
public constructor(

@@ -518,26 +515,16 @@ @IContainer private readonly container: IContainer,

/**
* Future optimization scope:
* Can we devise a plan to ignore a transition?
* The idea is to deterministically identify that the given transition is already active.
* In that case, we only choose to execute the transition if the transitionPlan is set to replace. (this check is currently done in the viewport agent).
*
* Solution idea:
* The root RouteNode needs to be consistently updated, even when children nodes are lazily added.
* When done, the instruction can be compared starting with the root node.
*/
this._isNavigating = true;
let navigationContext = this.resolveContext(tr.options.context);
const trChildren = tr.instructions.children;
const nodeChildren = navigationContext.node.children;
const useHash = this.options.useUrlFragmentHash;
const shouldProcess = !this.navigated
|| this._cannotBeUnloaded
|| tr.trigger === (useHash ? 'hashchange' : 'popstate')
|| trChildren.length !== nodeChildren.length
|| trChildren.some((x, i) => !(nodeChildren[i]?.originalInstruction!.equals(x) ?? false))
|| this.ctx.definition.config.getTransitionPlan(tr.previousRouteTree.root, tr.routeTree.root) === 'replace';
if (!shouldProcess) {
this.logger.trace(`run(tr:%s) - NOT processing route`, tr);
this.navigated = true;
this._isNavigating = false;
tr.resolve!(false);
this.runNextTransition();
return;
}
this._cannotBeUnloaded = false;
this.logger.trace(`run(tr:%s) - processing route`, tr);

@@ -613,6 +600,2 @@

b.push(); // prevent the next step in the batch from running
// Note that another alternative solution can be to clear the the children of the root of the current tree
// and restore the children of the previous routeTree's root.
// However, this should be cheaper solution.
this._cannotBeUnloaded = tr.guardsResult === false;
this.cancelNavigation(tr);

@@ -657,3 +640,3 @@ }

// apply history state
const newUrl = tr.finalInstructions.toUrl(useHash);
const newUrl = tr.finalInstructions.toUrl(this.options.useUrlFragmentHash);
switch (tr.options._getHistoryStrategy(this.instructions)) {

@@ -660,0 +643,0 @@ case 'none':

@@ -80,3 +80,2 @@ import type { IIndexable } from '@aurelia/kernel';

case 'redirectTo':
case 'fallback':
if (typeof value !== 'string') {

@@ -148,2 +147,11 @@ expectType('string', path, value);

break;
case 'fallback':
switch(typeof value) {
case 'string':
case 'function':
break;
default:
expectType('string or function', path, value);
}
break;
default:

@@ -150,0 +158,0 @@ // We don't *have* to throw here, but let's be as strict as possible until someone gives a valid reason for not doing so.

// No-fallthrough disabled due to large numbers of false positives
/* eslint-disable no-fallthrough */
import { ILogger, onResolve, resolveAll } from '@aurelia/kernel';
import { LifecycleFlags, type IHydratedController, type ICustomElementController, Controller } from '@aurelia/runtime-html';
import { type IHydratedController, type ICustomElementController, Controller } from '@aurelia/runtime-html';

@@ -75,3 +75,3 @@ import type { IViewport } from './resources/viewport';

public activateFromViewport(initiator: IHydratedController, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void> {
public activateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void> {
const tr = this.currTransition;

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

this.logger.trace(`activateFromViewport() - activating existing componentAgent at %s`, this);
return this.curCA!.activate(initiator, parent, flags);
return this.curCA!.activate(initiator, parent);
default:

@@ -108,3 +108,3 @@ this.unexpectedState('activateFromViewport 1');

public deactivateFromViewport(initiator: IHydratedController, parent: IHydratedController, flags: LifecycleFlags): void | Promise<void> {
public deactivateFromViewport(initiator: IHydratedController, parent: IHydratedController): void | Promise<void> {
const tr = this.currTransition;

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

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

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

tr.run(() => {
return this.curCA!.deactivate(initiator, controller, LifecycleFlags.dispose);
return this.curCA!.deactivate(initiator, controller);
}, () => {

@@ -505,6 +505,5 @@ b.pop();

const controller = this.hostController;
const activateFlags = LifecycleFlags.none;
tr.run(() => {
b1.push();
return this.nextCA!.activate(initiator, controller, activateFlags);
return this.nextCA!.activate(initiator, controller);
}, () => {

@@ -574,3 +573,3 @@ b1.pop();

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

@@ -582,3 +581,3 @@ b1.pop();

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

@@ -731,3 +730,3 @@ b1.pop();

case State.nextActivate: {
this._cancellationPromise = onResolve(this.nextCA?.deactivate(null, this.hostController, LifecycleFlags.none), () => {
this._cancellationPromise = onResolve(this.nextCA?.deactivate(null, this.hostController), () => {
this.nextCA?.dispose();

@@ -734,0 +733,0 @@ this.$plan = 'replace';

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc