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.1-dev.202306161507 to 2.0.1-dev.202306180925

4

dist/types/instructions.d.ts

@@ -73,3 +73,3 @@ import { IModule } from '@aurelia/kernel';

readonly viewport: string | null;
readonly params: Params | null;
readonly params: Readonly<Params> | null;
readonly children: ViewportInstruction[];

@@ -90,3 +90,3 @@ private constructor();

constructor(options: NavigationOptions, isAbsolute: boolean, children: ViewportInstruction[], queryParams: Readonly<URLSearchParams>, fragment: string | null);
static create(instructionOrInstructions: NavigationInstruction | NavigationInstruction[], routerOptions: RouterOptions, options?: INavigationOptions, rootCtx?: IRouteContext | null): ViewportInstructionTree;
static create(instructionOrInstructions: NavigationInstruction | NavigationInstruction[], routerOptions: RouterOptions, options?: INavigationOptions | NavigationOptions, rootCtx?: IRouteContext | null): ViewportInstructionTree;
equals(other: ViewportInstructionTree): boolean;

@@ -93,0 +93,0 @@ toUrl(isFinalInstruction: boolean, useUrlFragmentHash: boolean): string;

{
"name": "@aurelia/router-lite",
"version": "2.0.1-dev.202306161507",
"version": "2.0.1-dev.202306180925",
"main": "dist/cjs/index.cjs",

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

"dependencies": {
"@aurelia/kernel": "2.0.1-dev.202306161507",
"@aurelia/metadata": "2.0.1-dev.202306161507",
"@aurelia/platform": "2.0.1-dev.202306161507",
"@aurelia/platform-browser": "2.0.1-dev.202306161507",
"@aurelia/route-recognizer": "2.0.1-dev.202306161507",
"@aurelia/runtime": "2.0.1-dev.202306161507",
"@aurelia/runtime-html": "2.0.1-dev.202306161507"
"@aurelia/kernel": "2.0.1-dev.202306180925",
"@aurelia/metadata": "2.0.1-dev.202306180925",
"@aurelia/platform": "2.0.1-dev.202306180925",
"@aurelia/platform-browser": "2.0.1-dev.202306180925",
"@aurelia/route-recognizer": "2.0.1-dev.202306180925",
"@aurelia/runtime": "2.0.1-dev.202306180925",
"@aurelia/runtime-html": "2.0.1-dev.202306180925"
},

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

@@ -24,4 +24,2 @@ import { ILogger } from '@aurelia/kernel';

// type IHooksFn<T, Fn extends (...args: any[]) => unknown> = (vm: T, ...args: Parameters<Fn>) => ReturnType<Fn>;
/**

@@ -28,0 +26,0 @@ * A component agent handles an instance of a routed view-model (a component).

@@ -96,3 +96,3 @@ import { isObject } from '@aurelia/metadata';

public readonly viewport: string | null,
public readonly params: Params | null,
public readonly params: Readonly<Params> | null,
public readonly children: ViewportInstruction[],

@@ -114,3 +114,3 @@ ) { }

instruction.viewport ?? null,
instruction.params ?? null,
Object.freeze(instruction.params ?? null),
children,

@@ -178,3 +178,3 @@ );

this.viewport,
this.params === null ? null : { ...this.params },
this.params,
[...this.children],

@@ -186,31 +186,11 @@ ) as this;

const component = this.component.toUrlComponent();
/**
* Note on the parenthesized parameters:
* We will land on this branch if and only if the component cannot be eagerly recognized (in the RouteContext#generateViewportInstruction) AND the parameters are also provided.
* When the routes are eagerly recognized, then there is no parameters left at this point and everything is already packed in the generated path as well as in the recognized route.
* Thus, in normal scenarios the users will never land here.
*
* Whenever, they are using a hand composed (string) path, then in that case there is no question of having parameters at this point, rather the given path is recognized in the createAndAppendNodes.
* It might be a rare edge case where users provide half the parameters in the string path and half as form of parameters; example: `load="route: r1/id1; params.bind: {id2}"`.
* We might not want to officially support such cases.
*
* However, as the route recognition is inherently lazy (think about child routes, whose routing configuration are not resolved till a child routing context is created, or
* the usage of instance level getRouteConfig), the component cannot be recognized fully eagerly. Thus, it is difficult at this point to correctly handle parameters as defined by the path templates defined for the component.
* This artifact is kept here for the purpose of fallback.
*
* We can think about a stricter mode where we throw error if any params remains unconsumed at this point.
* Or simply ignore the params while creating the URL. However, that does not feel right at all.
*/
const params = this.params === null || Object.keys(this.params).length === 0 ? '' : `(${stringifyParams(this.params)})`;
const vp = this.viewport;
const viewport = component.length === 0 || vp === null || vp.length === 0 || vp === defaultViewportName ? '' : `@${vp}`;
const thisPart = `${'('.repeat(this.open)}${component}${params}${viewport}${')'.repeat(this.close)}`;
const thisPart = `${'('.repeat(this.open)}${component}${stringifyParams(this.params)}${viewport}${')'.repeat(this.close)}`;
const childPart = recursive ? this.children.map(x => x.toUrlComponent()).join('+') : '';
if (thisPart.length > 0) {
if (childPart.length > 0) {
return [thisPart, childPart].join('/');
}
return thisPart;
}
return childPart;
return thisPart.length > 0
? childPart.length > 0
? `${thisPart}/${childPart}`
: thisPart
: childPart;
}

@@ -228,5 +208,25 @@

function stringifyParams(params: Params): string {
/**
* Note on the parenthesized parameters:
* We will land on this branch if and only if the component cannot be eagerly recognized (in the RouteContext#generateViewportInstruction) AND the parameters are also provided.
* When the routes are eagerly recognized, then there is no parameters left at this point and everything is already packed in the generated path as well as in the recognized route.
* Thus, in normal scenarios the users will never land here.
*
* Whenever, they are using a hand composed (string) path, then in that case there is no question of having parameters at this point, rather the given path is recognized in the createAndAppendNodes.
* It might be a rare edge case where users provide half the parameters in the string path and half as form of parameters; example: `load="route: r1/id1; params.bind: {id2}"`.
* We might not want to officially support such cases.
*
* However, as the route recognition is inherently lazy (think about child routes, whose routing configuration are not resolved till a child routing context is created, or
* the usage of instance level getRouteConfig), the component cannot be recognized fully eagerly. Thus, it is difficult at this point to correctly handle parameters as defined by the path templates defined for the component.
* This artifact is kept here for the purpose of fallback.
*
* We can think about a stricter mode where we throw error if any params remains unconsumed at this point.
* Or simply ignore the params while creating the URL. However, that does not feel right at all.
*/
function stringifyParams(params: Readonly<Params> | null): string {
if (params === null) return '';
const keys = Object.keys(params);
const values = Array<string>(keys.length);
const numKeys = keys.length;
if (numKeys === 0) return '';
const values = Array<string>(numKeys);
const indexKeys: number[] = [];

@@ -242,3 +242,3 @@ const namedKeys: string[] = [];

for (let i = 0; i < keys.length; ++i) {
for (let i = 0; i < numKeys; ++i) {
const indexKeyIdx = indexKeys.indexOf(i);

@@ -253,3 +253,3 @@ if (indexKeyIdx > -1) {

}
return values.join(',');
return `(${values.join(',')})`;
}

@@ -264,3 +264,5 @@

public readonly fragment: string | null,
) { }
) {
Object.freeze(queryParams);
}

@@ -270,10 +272,10 @@ public static create(

routerOptions: RouterOptions,
options?: INavigationOptions,
options?: INavigationOptions | NavigationOptions,
rootCtx?: IRouteContext | null,
): ViewportInstructionTree {
const $options = NavigationOptions.create(routerOptions, { ...options });
options = options instanceof NavigationOptions ? options : NavigationOptions.create(routerOptions, options ?? emptyObject);
let context = $options.context as RouteContext;
let context = options.context as RouteContext;
if (!(context instanceof RouteContext) && rootCtx != null) {
context = ($options as Writable<NavigationOptions>).context = RouteContext.resolve(rootCtx, context);
context = (options as Writable<NavigationOptions>).context = RouteContext.resolve(rootCtx, context);
}

@@ -285,3 +287,3 @@ const hasContext = context != null;

const children = new Array(len);
const query = new URLSearchParams($options.queryParams ?? emptyObject);
const query = new URLSearchParams(options.queryParams ?? emptyObject);
for (let i = 0; i < len; i++) {

@@ -297,3 +299,3 @@ const instruction = instructionOrInstructions[i];

}
return new ViewportInstructionTree($options, false, children, query, $options.fragment);
return new ViewportInstructionTree(options as NavigationOptions, false, children, query, (options as NavigationOptions).fragment);
}

@@ -303,3 +305,3 @@

const expr = RouteExpression.parse(instructionOrInstructions, routerOptions.useUrlFragmentHash);
return expr.toInstructionTree($options);
return expr.toInstructionTree(options as NavigationOptions);
}

@@ -313,17 +315,17 @@

: null;
const query = new URLSearchParams($options.queryParams ?? emptyObject);
const query = new URLSearchParams(options.queryParams ?? emptyObject);
return eagerVi !== null
? new ViewportInstructionTree(
$options,
options as NavigationOptions,
false,
[eagerVi.vi],
mergeURLSearchParams(query, eagerVi.query, false),
$options.fragment,
(options as NavigationOptions).fragment,
)
: new ViewportInstructionTree(
$options,
options as NavigationOptions,
false,
[ViewportInstruction.create(instructionOrInstructions)],
query,
$options.fragment,
(options as NavigationOptions).fragment,
);

@@ -330,0 +332,0 @@ }

@@ -260,6 +260,6 @@ import {

this.instruction,
{ ...this.params },
new URLSearchParams(this.queryParams),
this.params, // as this is frozen, it's safe to share
this.queryParams, // as this is frozen, it's safe to share
this.fragment,
{ ...this.data },
this.data, // as this is frozen, it's safe to share
this._viewport,

@@ -325,3 +325,3 @@ this.title,

this.options._clone(),
new URLSearchParams(this.queryParams),
this.queryParams, // as this is frozen, it's safe to share
this.fragment,

@@ -345,2 +345,7 @@ this.root._clone(),

/** @internal */
public _mergeQuery(other: Params): void {
(this as Writable<RouteTree>).queryParams = Object.freeze(mergeURLSearchParams(this.queryParams, other, true));
}
public toString(): string {

@@ -384,3 +389,3 @@ return this.root.toString();

if (result !== null) {
(node._tree as Writable<RouteTree>).queryParams = mergeURLSearchParams(node._tree.queryParams, result.query, true);
node._tree._mergeQuery(result.query);
const newVi = result.vi;

@@ -430,6 +435,6 @@ (newVi.children as NavigationInstruction[]).push(...vi.children);

viewport: vi.viewport,
children: vi.children.slice(),
children: vi.children,
});
if (eagerResult !== null) {
(node._tree as Writable<RouteTree>).queryParams = mergeURLSearchParams(node._tree.queryParams, eagerResult.query, true);
node._tree._mergeQuery(eagerResult.query);
return appendNode(log, node, createConfiguredNode(

@@ -511,5 +516,5 @@ log,

viewport: vi.viewport,
children: vi.children.slice(),
children: vi.children,
})!;
(node._tree as Writable<RouteTree>).queryParams = mergeURLSearchParams(node._tree.queryParams, query, true);
node._tree._mergeQuery(query);
return appendNode(log, node, createConfiguredNode(

@@ -568,5 +573,3 @@ log,

originalInstruction: originalVi,
params: {
...rr.route.params,
},
params: rr.route.params,
queryParams: rt.queryParams,

@@ -573,0 +576,0 @@ fragment: rt.fragment,

@@ -149,23 +149,19 @@ import { isObject } from '@aurelia/metadata';

public get currentTr(): Transition {
let currentTr = this._currentTr;
if (currentTr === null) {
currentTr = this._currentTr = Transition._create({
id: 0,
prevInstructions: this._instructions,
instructions: this._instructions,
finalInstructions: this._instructions,
instructionsChanged: true,
trigger: 'api',
options: NavigationOptions.create(this.options, {}),
managedState: null,
previousRouteTree: this.routeTree._clone(),
routeTree: this.routeTree,
resolve: null,
reject: null,
promise: null,
guardsResult: true,
error: void 0,
});
}
return currentTr;
return this._currentTr ??= Transition._create({
id: 0,
prevInstructions: this._instructions,
instructions: this._instructions,
finalInstructions: this._instructions,
instructionsChanged: true,
trigger: 'api',
options: NavigationOptions.create(this.options, {}),
managedState: null,
previousRouteTree: this.routeTree._clone(),
routeTree: this.routeTree,
resolve: null,
reject: null,
promise: null,
guardsResult: true,
error: void 0,
});
}

@@ -172,0 +168,0 @@ /** @internal */

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