ui5-lib-guard-router 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ui5/build-manifest.json +2 -2
- package/CHANGELOG.md +7 -0
- package/README.md +8 -8
- package/dist/index.d.ts +3 -3
- package/dist/resources/ui5/guard/router/.library +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js +3 -1
- package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline.d.ts.map +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline.js +1 -1
- package/dist/resources/ui5/guard/router/GuardPipeline.js.map +1 -1
- package/dist/resources/ui5/guard/router/Router-dbg.js +20 -15
- package/dist/resources/ui5/guard/router/Router-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/Router.d.ts +2 -1
- package/dist/resources/ui5/guard/router/Router.d.ts.map +1 -1
- package/dist/resources/ui5/guard/router/Router.js +1 -1
- package/dist/resources/ui5/guard/router/Router.js.map +1 -1
- package/dist/resources/ui5/guard/router/library-dbg.js +1 -1
- package/dist/resources/ui5/guard/router/library-dbg.js.map +1 -1
- package/dist/resources/ui5/guard/router/library-preload.js +4 -4
- package/dist/resources/ui5/guard/router/library-preload.js.map +1 -1
- package/dist/resources/ui5/guard/router/library.js +1 -1
- package/dist/resources/ui5/guard/router/library.js.map +1 -1
- package/dist/resources/ui5/guard/router/manifest.json +1 -1
- package/package.json +1 -1
- package/src/GuardPipeline.ts +3 -1
- package/src/Router.ts +19 -18
- package/src/manifest.json +1 -1
package/.ui5/build-manifest.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"buildManifest": {
|
|
18
18
|
"manifestVersion": "0.2",
|
|
19
|
-
"timestamp": "2026-11-
|
|
19
|
+
"timestamp": "2026-11-22T18:04:09.294Z",
|
|
20
20
|
"versions": {
|
|
21
21
|
"builderVersion": "4.3.8",
|
|
22
22
|
"projectVersion": "4.0.19",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"includedTasks": [],
|
|
32
32
|
"excludedTasks": []
|
|
33
33
|
},
|
|
34
|
-
"version": "1.7.
|
|
34
|
+
"version": "1.7.1",
|
|
35
35
|
"namespace": "ui5/guard/router",
|
|
36
36
|
"tags": {
|
|
37
37
|
"/resources/ui5/guard/router/GuardConfig-dbg.js": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.7.1](https://github.com/wridgeu/ui5-lib-guard-router/compare/v1.7.0...v1.7.1) (2026-11-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **router:** destroy() fires no navigationSettled event and ignores a later navTo() ([#77](https://github.com/wridgeu/ui5-lib-guard-router/issues/77)) ([e7a89d0](https://github.com/wridgeu/ui5-lib-guard-router/commit/e7a89d0e2564ed1d5036949792f1cf93cd9a6801))
|
|
9
|
+
|
|
3
10
|
## [1.7.0](https://github.com/wridgeu/ui5-lib-guard-router/compare/v1.6.2...v1.7.0) (2026-11-21)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -304,7 +304,7 @@ flowchart TD
|
|
|
304
304
|
|
|
305
305
|
A commit lets a `navTo()` write its hash and hands the hash to the native `parse()`. A block or an error undoes a hash that the browser changed. A redirect runs the enter guards of its target, without leave guards, for at most 10 hops. The guards of the manifest are the modules under `guards` in the `guardRouter` block.
|
|
306
306
|
|
|
307
|
-
A navigation that another one supersedes, or that `stop()` or `destroy()` ends, settles as `Cancelled`.
|
|
307
|
+
A navigation that another one supersedes, or that `stop()` or `destroy()` ends, settles as `Cancelled`. For `destroy()` only the `navigationSettled()` promise resolves: no `navigationSettled` handler runs while the router is torn down.
|
|
308
308
|
|
|
309
309
|
The two entry points run the same guards:
|
|
310
310
|
|
|
@@ -403,12 +403,12 @@ Leave guards cannot redirect. Redirect from an enter guard of the target route.
|
|
|
403
403
|
|
|
404
404
|
### Lifecycle
|
|
405
405
|
|
|
406
|
-
| Method | Behavior
|
|
407
|
-
| ------------------ |
|
|
408
|
-
| `initialize()` | Starts the router and parses the current hash through the guards, as the native router does
|
|
409
|
-
| `initialize(true)` | Starts the router without parsing the hash. After `stop()`, it resumes the route that was current, so its leave guards keep working
|
|
410
|
-
| `stop()` | Cancels a pending navigation (settles as `Cancelled`, aborts the `AbortSignal`) and resets the current route, hash and last settlement; guards are kept
|
|
411
|
-
| `destroy()` | Clears all guards, cancels a pending navigation
|
|
406
|
+
| Method | Behavior |
|
|
407
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
408
|
+
| `initialize()` | Starts the router and parses the current hash through the guards, as the native router does |
|
|
409
|
+
| `initialize(true)` | Starts the router without parsing the hash. After `stop()`, it resumes the route that was current, so its leave guards keep working |
|
|
410
|
+
| `stop()` | Cancels a pending navigation (settles as `Cancelled`, aborts the `AbortSignal`) and resets the current route, hash and last settlement; guards are kept |
|
|
411
|
+
| `destroy()` | Clears all guards, cancels a pending navigation without firing `navigationSettled`, then calls `super.destroy()`. A `navTo()` afterwards only logs a warning. A second call does nothing |
|
|
412
412
|
|
|
413
413
|
Before `initialize()`, while `guardLoading: "block"` modules load, and after `stop()`, the router does not listen to hash changes. `navTo()` then behaves like the native router: it only sets the hash, or does nothing on a stopped router. No guard runs and nothing settles; the guards run when the router starts and parses the hash.
|
|
414
414
|
|
|
@@ -497,7 +497,7 @@ assert.strictEqual(result.route, "home", "User stays on home");
|
|
|
497
497
|
|
|
498
498
|
**Event-based: observe every navigation outcome**
|
|
499
499
|
|
|
500
|
-
The `navigationSettled` event fires synchronously after every settlement:
|
|
500
|
+
The `navigationSettled` event fires synchronously after every settlement, except for the navigation that `destroy()` cancels:
|
|
501
501
|
|
|
502
502
|
```typescript
|
|
503
503
|
router.attachNavigationSettled((event) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Generated with TypeScript 6.0.3 / OpenUI5 1.144.0 using:
|
|
2
2
|
// - typescript@6.0.3
|
|
3
|
-
/// <reference path="./resources/ui5/guard/router/
|
|
3
|
+
/// <reference path="./resources/ui5/guard/router/RouteMeta.d.ts"/>
|
|
4
4
|
/// <reference path="./resources/ui5/guard/router/library.d.ts"/>
|
|
5
5
|
/// <reference path="./resources/ui5/guard/router/Router.d.ts"/>
|
|
6
|
-
/// <reference path="./resources/ui5/guard/router/
|
|
6
|
+
/// <reference path="./resources/ui5/guard/router/GuardConfig.d.ts"/>
|
|
7
7
|
/// <reference path="./resources/ui5/guard/router/PatternTree.d.ts"/>
|
|
8
8
|
/// <reference path="./resources/ui5/guard/router/NavigationOutcome.d.ts"/>
|
|
9
9
|
/// <reference path="./resources/ui5/guard/router/GuardPipeline.d.ts"/>
|
|
10
10
|
/// <reference path="./resources/ui5/guard/router/GuardModules.d.ts"/>
|
|
11
|
-
/// <reference path="./resources/ui5/guard/router/
|
|
11
|
+
/// <reference path="./resources/ui5/guard/router/types.d.ts"/>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<library xmlns="http://www.sap.com/sap.ui.library.xsd">
|
|
3
3
|
<name>ui5.guard.router</name>
|
|
4
4
|
<vendor>Marco</vendor>
|
|
5
|
-
<version>1.7.
|
|
5
|
+
<version>1.7.1</version>
|
|
6
6
|
<copyright></copyright>
|
|
7
7
|
<title>UI5 Router extension with async navigation guards</title>
|
|
8
8
|
<documentation>Extends sap.m.routing.Router with async navigation guards, running before route matching begins.</documentation>
|
|
@@ -297,12 +297,14 @@ sap.ui.define(["sap/base/Log"], function (Log) {
|
|
|
297
297
|
async _continueGuardsAsync(pendingResult, guards, currentIndex, context, onBlock, label, route) {
|
|
298
298
|
let guardIndex = currentIndex;
|
|
299
299
|
try {
|
|
300
|
+
// An aborted navigation discards the result: it is neither validated nor followed by the next guard.
|
|
300
301
|
const result = await pendingResult;
|
|
302
|
+
if (context.signal.aborted) return false;
|
|
301
303
|
if (result !== true) return onBlock(result);
|
|
302
304
|
for (let i = currentIndex + 1; i < guards.length; i++) {
|
|
303
|
-
if (context.signal.aborted) return false;
|
|
304
305
|
guardIndex = i;
|
|
305
306
|
const nextResult = await guards[i](context);
|
|
307
|
+
if (context.signal.aborted) return false;
|
|
306
308
|
if (nextResult !== true) return onBlock(nextResult);
|
|
307
309
|
}
|
|
308
310
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardPipeline-dbg.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","resolverSource","Promise","resolve","Function","prototype","toString","call","isPromiseResolver","name","guardNames","WeakMap","nameGuard","guard","set","describeGuard","label","index","get","undefined","toDecision","result","action","target","toErrorDecision","error","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","push","removeGlobalGuard","indexOf","splice","addEnterGuard","before","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","leaving","skipLeaveGuards","fromRoute","alsoLeaving","entering","toRoute","alsoEntering","runEnterPhase","enterResult","_runEnterGuards","catch","leaveResult","_runForEach","_runGuards","_validateLeaveGuardResult","allowed","signal","aborted","map","key","guards","delete","routes","run","start","i","settled","runRouteGuards","_runRouteGuards","globalResult","_validateGuardResult","onBlock","slice","_continueGuardsAsync","Log","Error","String","pendingResult","currentIndex","guardIndex","nextResult","warning"],"sourceRoot":"./","sources":["GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect } from \"./types\";\n\n/** The component under which the library logs. */\nexport const LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"route\" in value && typeof value.route === \"string\" && value.route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nexport function isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"then\" in value && typeof value.then === \"function\";\n}\n\n/** How this engine prints the resolve function of a Promise: `function () { [native code] }` in V8. */\nlet resolverSource!: string;\nvoid new Promise((resolve) => {\n\tresolverSource = Function.prototype.toString.call(resolve);\n});\n\n/**\n * Whether `value` looks exactly like the resolve function of a native Promise: a function with\n * the name `\"\"`, the length `1` and the source text that this engine prints for such a function.\n * `Router#attachRouteMatched` needs this to recognize a UI5 component target that waits for the\n * router. A function written in JavaScript never matches; other anonymous built-ins with one\n * parameter do, above all the reject function of a Promise.\n */\nexport function isPromiseResolver(value: unknown): value is () => void {\n\treturn (\n\t\ttypeof value === \"function\" &&\n\t\tvalue.name === \"\" &&\n\t\tvalue.length === 1 &&\n\t\tFunction.prototype.toString.call(value) === resolverSource\n\t);\n}\n\n/** Names of manifest guards, derived from their module, for log output. */\nconst guardNames = new WeakMap<GuardFn, string>();\n\n/** Give a guard a name that its log messages show. */\nexport function nameGuard(guard: GuardFn, name: string): void {\n\tguardNames.set(guard, name);\n}\n\n/** Describe a guard for log output: `Enter guard [0]`, or `Enter guard [0] \"checks#0\"` when it has a name. */\nfunction describeGuard(label: string, index: number, guard: GuardFn): string {\n\tconst name = guardNames.get(guard);\n\treturn name === undefined ? `${label} [${index}]` : `${label} [${index}] \"${name}\"`;\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\nfunction toDecision(result: GuardResult): GuardDecision {\n\tif (result === true) return { action: \"allow\" };\n\tif (result === false) return { action: \"block\" };\n\treturn { action: \"redirect\", target: result };\n}\n\nfunction toErrorDecision(error: unknown): GuardDecision {\n\treturn { action: \"error\", error };\n}\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. It reads no Router\n * state: evaluate() receives the context and the greedy routes left\n * and entered with it.\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, GuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t * @param before - A guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * Accepts `GuardFn` to support manifest-declared guards loaded from\n\t * untyped modules. Non-boolean return values are caught at runtime\n\t * by {@link _validateLeaveGuardResult}.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register as a leave guard.\n\t * @param before - A leave guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddLeaveGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t */\n\tremoveLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @param options.alsoLeaving - Greedy routes that are left as well: their leave guards run\n\t * after those of `context.fromRoute`, with the same context.\n\t * @param options.alsoEntering - Greedy routes that match as well: their enter guards run\n\t * after those of `context.toRoute`, with the same context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(\n\t\tcontext: GuardContext,\n\t\toptions?: { skipLeaveGuards?: boolean; alsoLeaving?: string[]; alsoEntering?: string[] },\n\t): GuardDecision | Promise<GuardDecision> {\n\t\t// No route is left on the first navigation, or after a hash that matched none.\n\t\tconst leaving =\n\t\t\toptions?.skipLeaveGuards || context.fromRoute === \"\"\n\t\t\t\t? []\n\t\t\t\t: [context.fromRoute, ...(options?.alsoLeaving ?? [])];\n\t\tconst entering = [context.toRoute, ...(options?.alsoEntering ?? [])];\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(entering, context);\n\t\t\treturn isPromiseLike(enterResult)\n\t\t\t\t? enterResult.then(toDecision).catch(toErrorDecision)\n\t\t\t\t: toDecision(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tconst leaveResult = this._runForEach(leaving, context, (route) =>\n\t\t\t\tthis._runGuards(\n\t\t\t\t\tthis._leaveGuards.get(route) ?? [],\n\t\t\t\t\tcontext,\n\t\t\t\t\troute,\n\t\t\t\t\t(result) => this._validateLeaveGuardResult(result),\n\t\t\t\t\t\"Leave guard\",\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\treturn leaveResult\n\t\t\t\t\t.then((allowed: GuardResult): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t})\n\t\t\t\t\t.catch(toErrorDecision);\n\t\t\t}\n\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn toErrorDecision(error);\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T, before?: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tconst index = before === undefined ? -1 : guards.indexOf(before);\n\t\tif (index === -1) guards.push(guard);\n\t\telse guards.splice(index, 0, guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run `run` for each route in order until one does not return `true`. Stays sync as long\n\t * as the runs do; after an async run the next one starts unless the navigation was aborted.\n\t */\n\tprivate _runForEach(\n\t\troutes: string[],\n\t\tcontext: GuardContext,\n\t\trun: (route: string) => GuardResult | Promise<GuardResult>,\n\t\tstart = 0,\n\t): GuardResult | Promise<GuardResult> {\n\t\tfor (let i = start; i < routes.length; i++) {\n\t\t\tconst result = run(routes[i]);\n\t\t\tif (isPromiseLike(result)) {\n\t\t\t\treturn result.then((settled: GuardResult) => {\n\t\t\t\t\tif (settled !== true) return settled;\n\t\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\t\treturn this._runForEach(routes, context, run, i + 1);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (result !== true) return result;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then the route-specific guards of each route in `entering`. Stays sync when possible. */\n\tprivate _runEnterGuards(entering: string[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst runRouteGuards = (): GuardResult | Promise<GuardResult> =>\n\t\t\tthis._runForEach(entering, context, (route) => this._runRouteGuards(route, context));\n\t\tconst globalResult = this._runGuards(\n\t\t\tthis._globalGuards,\n\t\t\tcontext,\n\t\t\tcontext.toRoute,\n\t\t\t(result) => this._validateGuardResult(result),\n\t\t\t\"Enter guard\",\n\t\t);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn runRouteGuards();\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn runRouteGuards();\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst guards = toRoute ? this._enterGuards.get(toRoute) : undefined;\n\t\tif (!guards) return true;\n\t\treturn this._runGuards(guards, context, toRoute, (result) => this._validateGuardResult(result), \"Enter guard\");\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned. A result that is not\n\t * `true` ends the run with what `onBlock` makes of it.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate _runGuards<R extends GuardResult>(\n\t\tguards: GuardFn[],\n\t\tcontext: GuardContext,\n\t\troute: string,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t): R | boolean | Promise<R | boolean> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(result, guards, i, context, onBlock, label, route);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return onBlock(result);\n\t\t\t} catch (error) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, i, guards[i])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate async _continueGuardsAsync<R extends GuardResult>(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t\troute: string,\n\t): Promise<R | boolean> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\tconst result = await pendingResult;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, guardIndex, guards[guardIndex])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;EAGA;EACO,MAAMA,aAAa,GAAG,yBAAyB;EAEtD,SAASC,eAAeA,CAACC,KAAc,EAA0B;IAChE,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;MAChD,OAAO,KAAK;IACb;IAEA,OAAO,OAAO,IAAIA,KAAK,IAAI,OAAOA,KAAK,CAACC,KAAK,KAAK,QAAQ,IAAID,KAAK,CAACC,KAAK,CAACC,MAAM,GAAG,CAAC;EACrF;;EAEA;AACA;AACA;AACA;AACA;AACA;EACO,SAASC,aAAaA,CAAIH,KAAc,EAA2B;IACzE,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAI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,EAAW;MAC3D,IAAI,OAAOA,MAAM,KAAK,SAAS,EAAE,OAAOA,MAAM;MAC9C4D,GAAG,CAACO,OAAO,CAAC,2DAA2D,EAAEL,MAAM,CAAC9D,MAAM,CAAC,EAAE3B,aAAa,CAAC;MACvG,OAAO,KAAK;IACb;EACD;EAACgC,aAAA,CAAAhC,aAAA,GAAAA,aAAA;EAAAgC,aAAA,CAAA3B,aAAA,GAAAA,aAAA;EAAA2B,aAAA,CAAAlB,iBAAA,GAAAA,iBAAA;EAAAkB,aAAA,CAAAd,SAAA,GAAAA,SAAA;EAAA,OAAAc,aAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"GuardPipeline-dbg.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","resolverSource","Promise","resolve","Function","prototype","toString","call","isPromiseResolver","name","guardNames","WeakMap","nameGuard","guard","set","describeGuard","label","index","get","undefined","toDecision","result","action","target","toErrorDecision","error","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","push","removeGlobalGuard","indexOf","splice","addEnterGuard","before","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","leaving","skipLeaveGuards","fromRoute","alsoLeaving","entering","toRoute","alsoEntering","runEnterPhase","enterResult","_runEnterGuards","catch","leaveResult","_runForEach","_runGuards","_validateLeaveGuardResult","allowed","signal","aborted","map","key","guards","delete","routes","run","start","i","settled","runRouteGuards","_runRouteGuards","globalResult","_validateGuardResult","onBlock","slice","_continueGuardsAsync","Log","Error","String","pendingResult","currentIndex","guardIndex","nextResult","warning"],"sourceRoot":"./","sources":["GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect } from \"./types\";\n\n/** The component under which the library logs. */\nexport const LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"route\" in value && typeof value.route === \"string\" && value.route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nexport function isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"then\" in value && typeof value.then === \"function\";\n}\n\n/** How this engine prints the resolve function of a Promise: `function () { [native code] }` in V8. */\nlet resolverSource!: string;\nvoid new Promise((resolve) => {\n\tresolverSource = Function.prototype.toString.call(resolve);\n});\n\n/**\n * Whether `value` looks exactly like the resolve function of a native Promise: a function with\n * the name `\"\"`, the length `1` and the source text that this engine prints for such a function.\n * `Router#attachRouteMatched` needs this to recognize a UI5 component target that waits for the\n * router. A function written in JavaScript never matches; other anonymous built-ins with one\n * parameter do, above all the reject function of a Promise.\n */\nexport function isPromiseResolver(value: unknown): value is () => void {\n\treturn (\n\t\ttypeof value === \"function\" &&\n\t\tvalue.name === \"\" &&\n\t\tvalue.length === 1 &&\n\t\tFunction.prototype.toString.call(value) === resolverSource\n\t);\n}\n\n/** Names of manifest guards, derived from their module, for log output. */\nconst guardNames = new WeakMap<GuardFn, string>();\n\n/** Give a guard a name that its log messages show. */\nexport function nameGuard(guard: GuardFn, name: string): void {\n\tguardNames.set(guard, name);\n}\n\n/** Describe a guard for log output: `Enter guard [0]`, or `Enter guard [0] \"checks#0\"` when it has a name. */\nfunction describeGuard(label: string, index: number, guard: GuardFn): string {\n\tconst name = guardNames.get(guard);\n\treturn name === undefined ? `${label} [${index}]` : `${label} [${index}] \"${name}\"`;\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\nfunction toDecision(result: GuardResult): GuardDecision {\n\tif (result === true) return { action: \"allow\" };\n\tif (result === false) return { action: \"block\" };\n\treturn { action: \"redirect\", target: result };\n}\n\nfunction toErrorDecision(error: unknown): GuardDecision {\n\treturn { action: \"error\", error };\n}\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. It reads no Router\n * state: evaluate() receives the context and the greedy routes left\n * and entered with it.\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, GuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t * @param before - A guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * Accepts `GuardFn` to support manifest-declared guards loaded from\n\t * untyped modules. Non-boolean return values are caught at runtime\n\t * by {@link _validateLeaveGuardResult}.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register as a leave guard.\n\t * @param before - A leave guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddLeaveGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t */\n\tremoveLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @param options.alsoLeaving - Greedy routes that are left as well: their leave guards run\n\t * after those of `context.fromRoute`, with the same context.\n\t * @param options.alsoEntering - Greedy routes that match as well: their enter guards run\n\t * after those of `context.toRoute`, with the same context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(\n\t\tcontext: GuardContext,\n\t\toptions?: { skipLeaveGuards?: boolean; alsoLeaving?: string[]; alsoEntering?: string[] },\n\t): GuardDecision | Promise<GuardDecision> {\n\t\t// No route is left on the first navigation, or after a hash that matched none.\n\t\tconst leaving =\n\t\t\toptions?.skipLeaveGuards || context.fromRoute === \"\"\n\t\t\t\t? []\n\t\t\t\t: [context.fromRoute, ...(options?.alsoLeaving ?? [])];\n\t\tconst entering = [context.toRoute, ...(options?.alsoEntering ?? [])];\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(entering, context);\n\t\t\treturn isPromiseLike(enterResult)\n\t\t\t\t? enterResult.then(toDecision).catch(toErrorDecision)\n\t\t\t\t: toDecision(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tconst leaveResult = this._runForEach(leaving, context, (route) =>\n\t\t\t\tthis._runGuards(\n\t\t\t\t\tthis._leaveGuards.get(route) ?? [],\n\t\t\t\t\tcontext,\n\t\t\t\t\troute,\n\t\t\t\t\t(result) => this._validateLeaveGuardResult(result),\n\t\t\t\t\t\"Leave guard\",\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\treturn leaveResult\n\t\t\t\t\t.then((allowed: GuardResult): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t})\n\t\t\t\t\t.catch(toErrorDecision);\n\t\t\t}\n\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn toErrorDecision(error);\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T, before?: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tconst index = before === undefined ? -1 : guards.indexOf(before);\n\t\tif (index === -1) guards.push(guard);\n\t\telse guards.splice(index, 0, guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run `run` for each route in order until one does not return `true`. Stays sync as long\n\t * as the runs do; after an async run the next one starts unless the navigation was aborted.\n\t */\n\tprivate _runForEach(\n\t\troutes: string[],\n\t\tcontext: GuardContext,\n\t\trun: (route: string) => GuardResult | Promise<GuardResult>,\n\t\tstart = 0,\n\t): GuardResult | Promise<GuardResult> {\n\t\tfor (let i = start; i < routes.length; i++) {\n\t\t\tconst result = run(routes[i]);\n\t\t\tif (isPromiseLike(result)) {\n\t\t\t\treturn result.then((settled: GuardResult) => {\n\t\t\t\t\tif (settled !== true) return settled;\n\t\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\t\treturn this._runForEach(routes, context, run, i + 1);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (result !== true) return result;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then the route-specific guards of each route in `entering`. Stays sync when possible. */\n\tprivate _runEnterGuards(entering: string[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst runRouteGuards = (): GuardResult | Promise<GuardResult> =>\n\t\t\tthis._runForEach(entering, context, (route) => this._runRouteGuards(route, context));\n\t\tconst globalResult = this._runGuards(\n\t\t\tthis._globalGuards,\n\t\t\tcontext,\n\t\t\tcontext.toRoute,\n\t\t\t(result) => this._validateGuardResult(result),\n\t\t\t\"Enter guard\",\n\t\t);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn runRouteGuards();\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn runRouteGuards();\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst guards = toRoute ? this._enterGuards.get(toRoute) : undefined;\n\t\tif (!guards) return true;\n\t\treturn this._runGuards(guards, context, toRoute, (result) => this._validateGuardResult(result), \"Enter guard\");\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned. A result that is not\n\t * `true` ends the run with what `onBlock` makes of it.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate _runGuards<R extends GuardResult>(\n\t\tguards: GuardFn[],\n\t\tcontext: GuardContext,\n\t\troute: string,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t): R | boolean | Promise<R | boolean> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(result, guards, i, context, onBlock, label, route);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return onBlock(result);\n\t\t\t} catch (error) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, i, guards[i])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate async _continueGuardsAsync<R extends GuardResult>(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t\troute: string,\n\t): Promise<R | boolean> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\t// An aborted navigation discards the result: it is neither validated nor followed by the next guard.\n\t\t\tconst result = await pendingResult;\n\t\t\tif (context.signal.aborted) return false;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, guardIndex, guards[guardIndex])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;EAGA;EACO,MAAMA,aAAa,GAAG,yBAAyB;EAEtD,SAASC,eAAeA,CAACC,KAAc,EAA0B;IAChE,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;MAChD,OAAO,KAAK;IACb;IAEA,OAAO,OAAO,IAAIA,KAAK,IAAI,OAAOA,KAAK,CAACC,KAAK,KAAK,QAAQ,IAAID,KAAK,CAACC,KAAK,CAACC,M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;;;;;;;;;WAUG;QACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;QAIpE;;WAEG;QACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;QAIrD;;WAEG;QACH,KAAK,IAAI,IAAI;QAMb;;;;;;;;;;;;;;;;;WAiBG;QACH,QAAQ,CACP,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE;YAAE,eAAe,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,GACtF,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QA2CzC,OAAO,CAAC,cAAc;QAWtB,OAAO,CAAC,mBAAmB;QAQ3B;;;WAGG;QACH,OAAO,CAAC,WAAW;QAoBnB,+GAA+G;QAC/G,OAAO,CAAC,eAAe;QAsBvB,uDAAuD;QACvD,OAAO,CAAC,eAAe;QAMvB;;;;;;;;;WASG;QACH,OAAO,CAAC,UAAU;QA4BlB;;;;;;;;WAQG;gBACW,oBAAoB;QAoClC,qEAAqE;QACrE,OAAO,CAAC,oBAAoB;QAQ5B,iFAAiF;QACjF,OAAO,CAAC,yBAAyB;KAKjC;CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sap.ui.define(["sap/base/Log"],function(r){"use strict";const e="ui5.guard.router.Router";function t(r){if(typeof r!=="object"||r===null){return false}return"route"in r&&typeof r.route==="string"&&r.route.length>0}function n(r){if(typeof r!=="object"&&typeof r!=="function"||r===null){return false}return"then"in r&&typeof r.then==="function"}let a;void new Promise(r=>{a=Function.prototype.toString.call(r)});function u(r){return typeof r==="function"&&r.name===""&&r.length===1&&Function.prototype.toString.call(r)===a}const i=new WeakMap;function o(r,e){i.set(r,e)}function s(r,e,t){const n=i.get(t);return n===undefined?`${r} [${e}]`:`${r} [${e}] "${n}"`}function l(r){if(r===true)return{action:"allow"};if(r===false)return{action:"block"};return{action:"redirect",target:r}}function d(r){return{action:"error",error:r}}class
|
|
1
|
+
sap.ui.define(["sap/base/Log"],function(r){"use strict";const e="ui5.guard.router.Router";function t(r){if(typeof r!=="object"||r===null){return false}return"route"in r&&typeof r.route==="string"&&r.route.length>0}function n(r){if(typeof r!=="object"&&typeof r!=="function"||r===null){return false}return"then"in r&&typeof r.then==="function"}let a;void new Promise(r=>{a=Function.prototype.toString.call(r)});function u(r){return typeof r==="function"&&r.name===""&&r.length===1&&Function.prototype.toString.call(r)===a}const i=new WeakMap;function o(r,e){i.set(r,e)}function s(r,e,t){const n=i.get(t);return n===undefined?`${r} [${e}]`:`${r} [${e}] "${n}"`}function l(r){if(r===true)return{action:"allow"};if(r===false)return{action:"block"};return{action:"redirect",target:r}}function d(r){return{action:"error",error:r}}class f{_globalGuards=[];_enterGuards=new Map;_leaveGuards=new Map;addGlobalGuard(r){this._globalGuards.push(r)}removeGlobalGuard(r){const e=this._globalGuards.indexOf(r);if(e!==-1){this._globalGuards.splice(e,1)}}addEnterGuard(r,e,t){this._addToGuardMap(this._enterGuards,r,e,t)}removeEnterGuard(r,e){this._removeFromGuardMap(this._enterGuards,r,e)}addLeaveGuard(r,e,t){this._addToGuardMap(this._leaveGuards,r,e,t)}removeLeaveGuard(r,e){this._removeFromGuardMap(this._leaveGuards,r,e)}clear(){this._globalGuards=[];this._enterGuards.clear();this._leaveGuards.clear()}evaluate(r,e){const t=e?.skipLeaveGuards||r.fromRoute===""?[]:[r.fromRoute,...e?.alsoLeaving??[]];const a=[r.toRoute,...e?.alsoEntering??[]];const u=()=>{const e=this._runEnterGuards(a,r);return n(e)?e.then(l).catch(d):l(e)};try{const e=this._runForEach(t,r,e=>this._runGuards(this._leaveGuards.get(e)??[],r,e,r=>this._validateLeaveGuardResult(r),"Leave guard"));if(n(e)){return e.then(e=>{if(e!==true)return{action:"block"};if(r.signal.aborted)return{action:"block"};return u()}).catch(d)}if(e!==true)return{action:"block"};return u()}catch(r){return d(r)}}_addToGuardMap(r,e,t,n){let a=r.get(e);if(!a){a=[];r.set(e,a)}const u=n===undefined?-1:a.indexOf(n);if(u===-1)a.push(t);else a.splice(u,0,t)}_removeFromGuardMap(r,e,t){const n=r.get(e);if(!n)return;const a=n.indexOf(t);if(a!==-1)n.splice(a,1);if(n.length===0)r.delete(e)}_runForEach(r,e,t,a=0){for(let u=a;u<r.length;u++){const a=t(r[u]);if(n(a)){return a.then(n=>{if(n!==true)return n;if(e.signal.aborted)return false;return this._runForEach(r,e,t,u+1)})}if(a!==true)return a}return true}_runEnterGuards(r,e){const t=()=>this._runForEach(r,e,r=>this._runRouteGuards(r,e));const a=this._runGuards(this._globalGuards,e,e.toRoute,r=>this._validateGuardResult(r),"Enter guard");if(n(a)){return a.then(r=>{if(r!==true)return r;if(e.signal.aborted)return false;return t()})}if(a!==true)return a;return t()}_runRouteGuards(r,e){const t=r?this._enterGuards.get(r):undefined;if(!t)return true;return this._runGuards(t,e,r,r=>this._validateGuardResult(r),"Enter guard")}_runGuards(t,a,u,i,o){t=t.slice();for(let l=0;l<t.length;l++){try{const r=t[l](a);if(n(r)){return this._continueGuardsAsync(r,t,l,a,i,o,u)}if(r!==true)return i(r)}catch(n){if(a.signal.aborted)return false;r.error(`${s(o,l,t[l])} on route "${u}" threw, navigation failed`,n instanceof Error?n:String(n),e);throw n}}return true}async _continueGuardsAsync(t,n,a,u,i,o,l){let d=a;try{const r=await t;if(u.signal.aborted)return false;if(r!==true)return i(r);for(let r=a+1;r<n.length;r++){d=r;const e=await n[r](u);if(u.signal.aborted)return false;if(e!==true)return i(e)}return true}catch(t){if(!u.signal.aborted){r.error(`${s(o,d,n[d])} on route "${l}" threw, navigation failed`,t instanceof Error?t:String(t),e);throw t}return false}}_validateGuardResult(n){if(typeof n==="boolean")return n;if(typeof n==="string"&&n.length>0)return n;if(t(n))return n;r.warning("Guard returned invalid value, treating as block",String(n),e);return false}_validateLeaveGuardResult(t){if(typeof t==="boolean")return t;r.warning("Leave guard returned non-boolean value, treating as block",String(t),e);return false}}f.LOG_COMPONENT=e;f.isPromiseLike=n;f.isPromiseResolver=u;f.nameGuard=o;return f});
|
|
2
2
|
//# sourceMappingURL=GuardPipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuardPipeline.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","resolverSource","Promise","resolve","Function","prototype","toString","call","isPromiseResolver","name","guardNames","WeakMap","nameGuard","guard","set","describeGuard","label","index","get","undefined","toDecision","result","action","target","toErrorDecision","error","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","this","push","removeGlobalGuard","indexOf","splice","addEnterGuard","before","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","leaving","skipLeaveGuards","fromRoute","alsoLeaving","entering","toRoute","alsoEntering","runEnterPhase","enterResult","_runEnterGuards","catch","leaveResult","_runForEach","_runGuards","_validateLeaveGuardResult","allowed","signal","aborted","map","key","guards","delete","routes","run","start","i","settled","runRouteGuards","_runRouteGuards","globalResult","_validateGuardResult","onBlock","slice","_continueGuardsAsync","Log","Error","String","pendingResult","currentIndex","guardIndex","nextResult","warning"],"sources":["./GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect } from \"./types\";\n\n/** The component under which the library logs. */\nexport const LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"route\" in value && typeof value.route === \"string\" && value.route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nexport function isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"then\" in value && typeof value.then === \"function\";\n}\n\n/** How this engine prints the resolve function of a Promise: `function () { [native code] }` in V8. */\nlet resolverSource!: string;\nvoid new Promise((resolve) => {\n\tresolverSource = Function.prototype.toString.call(resolve);\n});\n\n/**\n * Whether `value` looks exactly like the resolve function of a native Promise: a function with\n * the name `\"\"`, the length `1` and the source text that this engine prints for such a function.\n * `Router#attachRouteMatched` needs this to recognize a UI5 component target that waits for the\n * router. A function written in JavaScript never matches; other anonymous built-ins with one\n * parameter do, above all the reject function of a Promise.\n */\nexport function isPromiseResolver(value: unknown): value is () => void {\n\treturn (\n\t\ttypeof value === \"function\" &&\n\t\tvalue.name === \"\" &&\n\t\tvalue.length === 1 &&\n\t\tFunction.prototype.toString.call(value) === resolverSource\n\t);\n}\n\n/** Names of manifest guards, derived from their module, for log output. */\nconst guardNames = new WeakMap<GuardFn, string>();\n\n/** Give a guard a name that its log messages show. */\nexport function nameGuard(guard: GuardFn, name: string): void {\n\tguardNames.set(guard, name);\n}\n\n/** Describe a guard for log output: `Enter guard [0]`, or `Enter guard [0] \"checks#0\"` when it has a name. */\nfunction describeGuard(label: string, index: number, guard: GuardFn): string {\n\tconst name = guardNames.get(guard);\n\treturn name === undefined ? `${label} [${index}]` : `${label} [${index}] \"${name}\"`;\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\nfunction toDecision(result: GuardResult): GuardDecision {\n\tif (result === true) return { action: \"allow\" };\n\tif (result === false) return { action: \"block\" };\n\treturn { action: \"redirect\", target: result };\n}\n\nfunction toErrorDecision(error: unknown): GuardDecision {\n\treturn { action: \"error\", error };\n}\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. It reads no Router\n * state: evaluate() receives the context and the greedy routes left\n * and entered with it.\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, GuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t * @param before - A guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * Accepts `GuardFn` to support manifest-declared guards loaded from\n\t * untyped modules. Non-boolean return values are caught at runtime\n\t * by {@link _validateLeaveGuardResult}.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register as a leave guard.\n\t * @param before - A leave guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddLeaveGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t */\n\tremoveLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @param options.alsoLeaving - Greedy routes that are left as well: their leave guards run\n\t * after those of `context.fromRoute`, with the same context.\n\t * @param options.alsoEntering - Greedy routes that match as well: their enter guards run\n\t * after those of `context.toRoute`, with the same context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(\n\t\tcontext: GuardContext,\n\t\toptions?: { skipLeaveGuards?: boolean; alsoLeaving?: string[]; alsoEntering?: string[] },\n\t): GuardDecision | Promise<GuardDecision> {\n\t\t// No route is left on the first navigation, or after a hash that matched none.\n\t\tconst leaving =\n\t\t\toptions?.skipLeaveGuards || context.fromRoute === \"\"\n\t\t\t\t? []\n\t\t\t\t: [context.fromRoute, ...(options?.alsoLeaving ?? [])];\n\t\tconst entering = [context.toRoute, ...(options?.alsoEntering ?? [])];\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(entering, context);\n\t\t\treturn isPromiseLike(enterResult)\n\t\t\t\t? enterResult.then(toDecision).catch(toErrorDecision)\n\t\t\t\t: toDecision(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tconst leaveResult = this._runForEach(leaving, context, (route) =>\n\t\t\t\tthis._runGuards(\n\t\t\t\t\tthis._leaveGuards.get(route) ?? [],\n\t\t\t\t\tcontext,\n\t\t\t\t\troute,\n\t\t\t\t\t(result) => this._validateLeaveGuardResult(result),\n\t\t\t\t\t\"Leave guard\",\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\treturn leaveResult\n\t\t\t\t\t.then((allowed: GuardResult): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t})\n\t\t\t\t\t.catch(toErrorDecision);\n\t\t\t}\n\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn toErrorDecision(error);\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T, before?: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tconst index = before === undefined ? -1 : guards.indexOf(before);\n\t\tif (index === -1) guards.push(guard);\n\t\telse guards.splice(index, 0, guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run `run` for each route in order until one does not return `true`. Stays sync as long\n\t * as the runs do; after an async run the next one starts unless the navigation was aborted.\n\t */\n\tprivate _runForEach(\n\t\troutes: string[],\n\t\tcontext: GuardContext,\n\t\trun: (route: string) => GuardResult | Promise<GuardResult>,\n\t\tstart = 0,\n\t): GuardResult | Promise<GuardResult> {\n\t\tfor (let i = start; i < routes.length; i++) {\n\t\t\tconst result = run(routes[i]);\n\t\t\tif (isPromiseLike(result)) {\n\t\t\t\treturn result.then((settled: GuardResult) => {\n\t\t\t\t\tif (settled !== true) return settled;\n\t\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\t\treturn this._runForEach(routes, context, run, i + 1);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (result !== true) return result;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then the route-specific guards of each route in `entering`. Stays sync when possible. */\n\tprivate _runEnterGuards(entering: string[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst runRouteGuards = (): GuardResult | Promise<GuardResult> =>\n\t\t\tthis._runForEach(entering, context, (route) => this._runRouteGuards(route, context));\n\t\tconst globalResult = this._runGuards(\n\t\t\tthis._globalGuards,\n\t\t\tcontext,\n\t\t\tcontext.toRoute,\n\t\t\t(result) => this._validateGuardResult(result),\n\t\t\t\"Enter guard\",\n\t\t);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn runRouteGuards();\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn runRouteGuards();\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst guards = toRoute ? this._enterGuards.get(toRoute) : undefined;\n\t\tif (!guards) return true;\n\t\treturn this._runGuards(guards, context, toRoute, (result) => this._validateGuardResult(result), \"Enter guard\");\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned. A result that is not\n\t * `true` ends the run with what `onBlock` makes of it.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate _runGuards<R extends GuardResult>(\n\t\tguards: GuardFn[],\n\t\tcontext: GuardContext,\n\t\troute: string,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t): R | boolean | Promise<R | boolean> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(result, guards, i, context, onBlock, label, route);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return onBlock(result);\n\t\t\t} catch (error) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, i, guards[i])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate async _continueGuardsAsync<R extends GuardResult>(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t\troute: string,\n\t): Promise<R | boolean> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\tconst result = await pendingResult;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, guardIndex, guards[guardIndex])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":"wDAIO,MAAMA,EAAgB,0BAE7B,SAASC,EAAgBC,GACxB,UAAWA,IAAU,UAAYA,IAAU,KAAM,CAChD,OAAO,KACR,CAEA,MAAO,UAAWA,UAAgBA,EAAMC,QAAU,UAAYD,EAAMC,MAAMC,OAAS,CACpF,CAQO,SAASC,EAAiBH,GAChC,UAAYA,IAAU,iBAAmBA,IAAU,YAAeA,IAAU,KAAM,CACjF,OAAO,KACR,CAEA,MAAO,SAAUA,UAAgBA,EAAMI,OAAS,UACjD,CAGA,IAAIC,OACC,IAAIC,QAASC,IACjBF,EAAiBG,SAASC,UAAUC,SAASC,KAAKJ,KAU5C,SAASK,EAAkBZ,GACjC,cACQA,IAAU,YACjBA,EAAMa,OAAS,IACfb,EAAME,SAAW,GACjBM,SAASC,UAAUC,SAASC,KAAKX,KAAWK,CAE9C,CAGA,MAAMS,EAAa,IAAIC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6D,EAAIO,QAAQ,4DAA6DL,OAAO/D,GAAS3B,GACzF,OAAO,KACR,EACAgC,EAAAhC,gBAAAgC,EAAA3B,gBAAA2B,EAAAlB,oBAAAkB,EAAAd,YAAA,OAAAc,CAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"GuardPipeline.js","names":["LOG_COMPONENT","isGuardRedirect","value","route","length","isPromiseLike","then","resolverSource","Promise","resolve","Function","prototype","toString","call","isPromiseResolver","name","guardNames","WeakMap","nameGuard","guard","set","describeGuard","label","index","get","undefined","toDecision","result","action","target","toErrorDecision","error","GuardPipeline","_globalGuards","_enterGuards","Map","_leaveGuards","addGlobalGuard","this","push","removeGlobalGuard","indexOf","splice","addEnterGuard","before","_addToGuardMap","removeEnterGuard","_removeFromGuardMap","addLeaveGuard","removeLeaveGuard","clear","evaluate","context","options","leaving","skipLeaveGuards","fromRoute","alsoLeaving","entering","toRoute","alsoEntering","runEnterPhase","enterResult","_runEnterGuards","catch","leaveResult","_runForEach","_runGuards","_validateLeaveGuardResult","allowed","signal","aborted","map","key","guards","delete","routes","run","start","i","settled","runRouteGuards","_runRouteGuards","globalResult","_validateGuardResult","onBlock","slice","_continueGuardsAsync","Log","Error","String","pendingResult","currentIndex","guardIndex","nextResult","warning"],"sources":["./GuardPipeline.ts"],"sourcesContent":["import Log from \"sap/base/Log\";\nimport type { GuardFn, GuardContext, GuardResult, GuardRedirect } from \"./types\";\n\n/** The component under which the library logs. */\nexport const LOG_COMPONENT = \"ui5.guard.router.Router\";\n\nfunction isGuardRedirect(value: unknown): value is GuardRedirect {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"route\" in value && typeof value.route === \"string\" && value.route.length > 0;\n}\n\n/**\n * Promises/A+ thenable detection via duck typing.\n *\n * We intentionally do not use `instanceof Promise` because that misses\n * cross-realm Promises and PromiseLike/thenable objects.\n */\nexport function isPromiseLike<T>(value: unknown): value is PromiseLike<T> {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\treturn false;\n\t}\n\n\treturn \"then\" in value && typeof value.then === \"function\";\n}\n\n/** How this engine prints the resolve function of a Promise: `function () { [native code] }` in V8. */\nlet resolverSource!: string;\nvoid new Promise((resolve) => {\n\tresolverSource = Function.prototype.toString.call(resolve);\n});\n\n/**\n * Whether `value` looks exactly like the resolve function of a native Promise: a function with\n * the name `\"\"`, the length `1` and the source text that this engine prints for such a function.\n * `Router#attachRouteMatched` needs this to recognize a UI5 component target that waits for the\n * router. A function written in JavaScript never matches; other anonymous built-ins with one\n * parameter do, above all the reject function of a Promise.\n */\nexport function isPromiseResolver(value: unknown): value is () => void {\n\treturn (\n\t\ttypeof value === \"function\" &&\n\t\tvalue.name === \"\" &&\n\t\tvalue.length === 1 &&\n\t\tFunction.prototype.toString.call(value) === resolverSource\n\t);\n}\n\n/** Names of manifest guards, derived from their module, for log output. */\nconst guardNames = new WeakMap<GuardFn, string>();\n\n/** Give a guard a name that its log messages show. */\nexport function nameGuard(guard: GuardFn, name: string): void {\n\tguardNames.set(guard, name);\n}\n\n/** Describe a guard for log output: `Enter guard [0]`, or `Enter guard [0] \"checks#0\"` when it has a name. */\nfunction describeGuard(label: string, index: number, guard: GuardFn): string {\n\tconst name = guardNames.get(guard);\n\treturn name === undefined ? `${label} [${index}]` : `${label} [${index}] \"${name}\"`;\n}\n\n/**\n * Normalized result of the guard decision pipeline.\n */\nexport type GuardDecision =\n\t| { action: \"allow\" }\n\t| { action: \"block\" }\n\t| { action: \"redirect\"; target: string | GuardRedirect }\n\t| { action: \"error\"; error: unknown };\n\nfunction toDecision(result: GuardResult): GuardDecision {\n\tif (result === true) return { action: \"allow\" };\n\tif (result === false) return { action: \"block\" };\n\treturn { action: \"redirect\", target: result };\n}\n\nfunction toErrorDecision(error: unknown): GuardDecision {\n\treturn { action: \"error\", error };\n}\n\n/**\n * Standalone guard evaluation pipeline.\n *\n * Owns guard storage (global, enter, leave) and runs the full\n * leave -> global-enter -> route-enter pipeline. It reads no Router\n * state: evaluate() receives the context and the greedy routes left\n * and entered with it.\n */\nexport default class GuardPipeline {\n\tprivate _globalGuards: GuardFn[] = [];\n\tprivate _enterGuards = new Map<string, GuardFn[]>();\n\tprivate _leaveGuards = new Map<string, GuardFn[]>();\n\n\t/** Register a guard that runs for every navigation. */\n\taddGlobalGuard(guard: GuardFn): void {\n\t\tthis._globalGuards.push(guard);\n\t}\n\n\t/** Remove a previously registered global guard by reference. */\n\tremoveGlobalGuard(guard: GuardFn): void {\n\t\tconst index = this._globalGuards.indexOf(guard);\n\t\tif (index !== -1) {\n\t\t\tthis._globalGuards.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * Register an enter guard for a specific route.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register.\n\t * @param before - A guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddEnterGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._enterGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered enter guard by reference.\n\t */\n\tremoveEnterGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._enterGuards, route, guard);\n\t}\n\n\t/**\n\t * Register a leave guard for a specific route.\n\t *\n\t * Accepts `GuardFn` to support manifest-declared guards loaded from\n\t * untyped modules. Non-boolean return values are caught at runtime\n\t * by {@link _validateLeaveGuardResult}.\n\t *\n\t * @param route - Route name as defined in `manifest.json`.\n\t * @param guard - Guard function to register as a leave guard.\n\t * @param before - A leave guard of the route to register `guard` in front of; at the end without it.\n\t */\n\taddLeaveGuard(route: string, guard: GuardFn, before?: GuardFn): void {\n\t\tthis._addToGuardMap(this._leaveGuards, route, guard, before);\n\t}\n\n\t/**\n\t * Remove a previously registered leave guard by reference.\n\t */\n\tremoveLeaveGuard(route: string, guard: GuardFn): void {\n\t\tthis._removeFromGuardMap(this._leaveGuards, route, guard);\n\t}\n\n\t/**\n\t * Remove all registered guards.\n\t */\n\tclear(): void {\n\t\tthis._globalGuards = [];\n\t\tthis._enterGuards.clear();\n\t\tthis._leaveGuards.clear();\n\t}\n\n\t/**\n\t * Run the full guard pipeline (leave -> global enter -> route enter) and\n\t * return a normalized decision. Stays synchronous when all guards return\n\t * plain values; returns a Promise only when an async guard is encountered.\n\t *\n\t * @param context - Complete guard context including AbortSignal.\n\t * `context.fromRoute` controls leave-guard lookup: empty string skips leave guards.\n\t * @param options - Optional evaluation options.\n\t * @param options.skipLeaveGuards - When true, leave guards are skipped even if\n\t * `context.fromRoute` is set. Used by redirect chain hops to avoid re-running\n\t * leave guards while still preserving `fromRoute` in the context.\n\t * @param options.alsoLeaving - Greedy routes that are left as well: their leave guards run\n\t * after those of `context.fromRoute`, with the same context.\n\t * @param options.alsoEntering - Greedy routes that match as well: their enter guards run\n\t * after those of `context.toRoute`, with the same context.\n\t * @returns A synchronous {@link GuardDecision} when all guards return plain values,\n\t * or a `Promise<GuardDecision>` when at least one guard returns a thenable.\n\t */\n\tevaluate(\n\t\tcontext: GuardContext,\n\t\toptions?: { skipLeaveGuards?: boolean; alsoLeaving?: string[]; alsoEntering?: string[] },\n\t): GuardDecision | Promise<GuardDecision> {\n\t\t// No route is left on the first navigation, or after a hash that matched none.\n\t\tconst leaving =\n\t\t\toptions?.skipLeaveGuards || context.fromRoute === \"\"\n\t\t\t\t? []\n\t\t\t\t: [context.fromRoute, ...(options?.alsoLeaving ?? [])];\n\t\tconst entering = [context.toRoute, ...(options?.alsoEntering ?? [])];\n\n\t\tconst runEnterPhase = (): GuardDecision | Promise<GuardDecision> => {\n\t\t\tconst enterResult = this._runEnterGuards(entering, context);\n\t\t\treturn isPromiseLike(enterResult)\n\t\t\t\t? enterResult.then(toDecision).catch(toErrorDecision)\n\t\t\t\t: toDecision(enterResult);\n\t\t};\n\n\t\ttry {\n\t\t\tconst leaveResult = this._runForEach(leaving, context, (route) =>\n\t\t\t\tthis._runGuards(\n\t\t\t\t\tthis._leaveGuards.get(route) ?? [],\n\t\t\t\t\tcontext,\n\t\t\t\t\troute,\n\t\t\t\t\t(result) => this._validateLeaveGuardResult(result),\n\t\t\t\t\t\"Leave guard\",\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (isPromiseLike(leaveResult)) {\n\t\t\t\treturn leaveResult\n\t\t\t\t\t.then((allowed: GuardResult): GuardDecision | Promise<GuardDecision> => {\n\t\t\t\t\t\tif (allowed !== true) return { action: \"block\" };\n\t\t\t\t\t\tif (context.signal.aborted) return { action: \"block\" };\n\t\t\t\t\t\treturn runEnterPhase();\n\t\t\t\t\t})\n\t\t\t\t\t.catch(toErrorDecision);\n\t\t\t}\n\t\t\tif (leaveResult !== true) return { action: \"block\" };\n\n\t\t\treturn runEnterPhase();\n\t\t} catch (error) {\n\t\t\treturn toErrorDecision(error);\n\t\t}\n\t}\n\n\tprivate _addToGuardMap<T>(map: Map<string, T[]>, key: string, guard: T, before?: T): void {\n\t\tlet guards = map.get(key);\n\t\tif (!guards) {\n\t\t\tguards = [];\n\t\t\tmap.set(key, guards);\n\t\t}\n\t\tconst index = before === undefined ? -1 : guards.indexOf(before);\n\t\tif (index === -1) guards.push(guard);\n\t\telse guards.splice(index, 0, guard);\n\t}\n\n\tprivate _removeFromGuardMap<T>(map: Map<string, T[]>, key: string, guard: T): void {\n\t\tconst guards = map.get(key);\n\t\tif (!guards) return;\n\t\tconst index = guards.indexOf(guard);\n\t\tif (index !== -1) guards.splice(index, 1);\n\t\tif (guards.length === 0) map.delete(key);\n\t}\n\n\t/**\n\t * Run `run` for each route in order until one does not return `true`. Stays sync as long\n\t * as the runs do; after an async run the next one starts unless the navigation was aborted.\n\t */\n\tprivate _runForEach(\n\t\troutes: string[],\n\t\tcontext: GuardContext,\n\t\trun: (route: string) => GuardResult | Promise<GuardResult>,\n\t\tstart = 0,\n\t): GuardResult | Promise<GuardResult> {\n\t\tfor (let i = start; i < routes.length; i++) {\n\t\t\tconst result = run(routes[i]);\n\t\t\tif (isPromiseLike(result)) {\n\t\t\t\treturn result.then((settled: GuardResult) => {\n\t\t\t\t\tif (settled !== true) return settled;\n\t\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\t\treturn this._runForEach(routes, context, run, i + 1);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (result !== true) return result;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run global guards, then the route-specific guards of each route in `entering`. Stays sync when possible. */\n\tprivate _runEnterGuards(entering: string[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst runRouteGuards = (): GuardResult | Promise<GuardResult> =>\n\t\t\tthis._runForEach(entering, context, (route) => this._runRouteGuards(route, context));\n\t\tconst globalResult = this._runGuards(\n\t\t\tthis._globalGuards,\n\t\t\tcontext,\n\t\t\tcontext.toRoute,\n\t\t\t(result) => this._validateGuardResult(result),\n\t\t\t\"Enter guard\",\n\t\t);\n\n\t\tif (isPromiseLike(globalResult)) {\n\t\t\treturn globalResult.then((result: GuardResult) => {\n\t\t\t\tif (result !== true) return result;\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\treturn runRouteGuards();\n\t\t\t});\n\t\t}\n\t\tif (globalResult !== true) return globalResult;\n\t\treturn runRouteGuards();\n\t}\n\n\t/** Run route-specific guards if any are registered. */\n\tprivate _runRouteGuards(toRoute: string, context: GuardContext): GuardResult | Promise<GuardResult> {\n\t\tconst guards = toRoute ? this._enterGuards.get(toRoute) : undefined;\n\t\tif (!guards) return true;\n\t\treturn this._runGuards(guards, context, toRoute, (result) => this._validateGuardResult(result), \"Enter guard\");\n\t}\n\n\t/**\n\t * Run guards sync; switch to async path if a Promise is returned. A result that is not\n\t * `true` ends the run with what `onBlock` makes of it.\n\t *\n\t * The guard array is snapshot-copied before iteration so that guards\n\t * may safely add/remove themselves (e.g. one-shot guards) without\n\t * affecting the current pipeline run.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate _runGuards<R extends GuardResult>(\n\t\tguards: GuardFn[],\n\t\tcontext: GuardContext,\n\t\troute: string,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t): R | boolean | Promise<R | boolean> {\n\t\tguards = guards.slice();\n\t\tfor (let i = 0; i < guards.length; i++) {\n\t\t\ttry {\n\t\t\t\tconst result = guards[i](context);\n\t\t\t\tif (isPromiseLike(result)) {\n\t\t\t\t\treturn this._continueGuardsAsync(result, guards, i, context, onBlock, label, route);\n\t\t\t\t}\n\t\t\t\tif (result !== true) return onBlock(result);\n\t\t\t} catch (error) {\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, i, guards[i])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Continue guard array async from the first Promise onward.\n\t *\n\t * Shared by both enter and leave guard pipelines. The `onBlock` callback\n\t * determines what to return for non-true results: leave guards always\n\t * return `false`, enter guards validate and may return redirects.\n\t *\n\t * @param route - The route the guards are registered for, named in error logs.\n\t */\n\tprivate async _continueGuardsAsync<R extends GuardResult>(\n\t\tpendingResult: PromiseLike<GuardResult>,\n\t\tguards: GuardFn[],\n\t\tcurrentIndex: number,\n\t\tcontext: GuardContext,\n\t\tonBlock: (result: unknown) => R,\n\t\tlabel: string,\n\t\troute: string,\n\t): Promise<R | boolean> {\n\t\tlet guardIndex = currentIndex;\n\t\ttry {\n\t\t\t// An aborted navigation discards the result: it is neither validated nor followed by the next guard.\n\t\t\tconst result = await pendingResult;\n\t\t\tif (context.signal.aborted) return false;\n\t\t\tif (result !== true) return onBlock(result);\n\n\t\t\tfor (let i = currentIndex + 1; i < guards.length; i++) {\n\t\t\t\tguardIndex = i;\n\t\t\t\tconst nextResult = await guards[i](context);\n\t\t\t\tif (context.signal.aborted) return false;\n\t\t\t\tif (nextResult !== true) return onBlock(nextResult);\n\t\t\t}\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (!context.signal.aborted) {\n\t\t\t\tLog.error(\n\t\t\t\t\t`${describeGuard(label, guardIndex, guards[guardIndex])} on route \"${route}\" threw, navigation failed`,\n\t\t\t\t\terror instanceof Error ? error : String(error),\n\t\t\t\t\tLOG_COMPONENT,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Validate a non-true guard result; invalid values become false. */\n\tprivate _validateGuardResult(result: unknown): GuardResult {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tif (typeof result === \"string\" && result.length > 0) return result;\n\t\tif (isGuardRedirect(result)) return result;\n\t\tLog.warning(\"Guard returned invalid value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n\n\t/** Validate a leave guard result; non-boolean values log a warning and block. */\n\tprivate _validateLeaveGuardResult(result: unknown): boolean {\n\t\tif (typeof result === \"boolean\") return result;\n\t\tLog.warning(\"Leave guard returned non-boolean value, treating as block\", String(result), LOG_COMPONENT);\n\t\treturn false;\n\t}\n}\n"],"mappings":"wDAIO,MAAMA,EAAgB,0BAE7B,SAASC,EAAgBC,GACxB,UAAWA,IAAU,UAAYA,IAAU,KAAM,CAChD,OAAO,KACR,CAEA,MAAO,UAAWA,UAAgBA,EAAMC,QAAU,UAAYD,EAAMC,MAAMC,OAAS,CACpF,CAQO,SAASC,EAAiBH,GAChC,UAAYA,IAAU,iBAAmBA,IAAU,YAAeA,IAAU,KAAM,CACjF,OAAO,KACR,CAEA,MAAO,SAAUA,UAAgBA,EAAMI,OAAS,UACjD,CAGA,IAAIC,OACC,IAAIC,QAASC,IACjBF,EAAiBG,SAASC,UAAUC,SAASC,KAAKJ,KAU5C,SAASK,EAAkBZ,GACjC,cACQA,IAAU,YACjBA,EAAMa,OAAS,IACfb,EAAME,SAAW,GACjBM,SAASC,UAAUC,SAASC,KAAKX,KAAWK,CAE9C,CAGA,MAAMS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GQoE,0BAA0BzC,GACjC,UAAWA,IAAW,UAAW,OAAOA,EACxC6D,EAAIO,QAAQ,4DAA6DL,OAAO/D,GAAS3B,GACzF,OAAO,KACR,EACAgC,EAAAhC,gBAAAgC,EAAA3B,gBAAA2B,EAAAlB,oBAAAkB,EAAAd,YAAA,OAAAc,CAAA","ignoreList":[]}
|
|
@@ -439,23 +439,21 @@ sap.ui.define(["sap/m/routing/Router", "sap/base/Log", "sap/ui/core/library", "s
|
|
|
439
439
|
*/
|
|
440
440
|
addRouteGuard: function _addRouteGuard(routeName, guard) {
|
|
441
441
|
if (isRouteGuardConfig(guard)) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
this._pipeline.addEnterGuard(routeName, guard.beforeEnter);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
if (guard.beforeLeave !== undefined) {
|
|
451
|
-
hasHandler = true;
|
|
452
|
-
if (this._isFn(guard.beforeLeave, "addRouteGuard", routeName)) {
|
|
453
|
-
this._pipeline.addLeaveGuard(routeName, guard.beforeLeave);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
if (!hasHandler) {
|
|
442
|
+
const {
|
|
443
|
+
beforeEnter,
|
|
444
|
+
beforeLeave
|
|
445
|
+
} = guard;
|
|
446
|
+
if (beforeEnter === undefined && beforeLeave === undefined) {
|
|
457
447
|
Log.info("addRouteGuard: config has no beforeEnter or beforeLeave", routeName, LOG_COMPONENT);
|
|
448
|
+
return this;
|
|
458
449
|
}
|
|
450
|
+
// As for a guard function: the route is checked only when something is registered.
|
|
451
|
+
const enter = beforeEnter !== undefined && this._isFn(beforeEnter, "addRouteGuard", routeName);
|
|
452
|
+
const leave = beforeLeave !== undefined && this._isFn(beforeLeave, "addRouteGuard", routeName);
|
|
453
|
+
if (!enter && !leave) return this;
|
|
454
|
+
this._handleUnknownRouteRegistration(routeName, "addRouteGuard");
|
|
455
|
+
if (enter) this._pipeline.addEnterGuard(routeName, beforeEnter);
|
|
456
|
+
if (leave) this._pipeline.addLeaveGuard(routeName, beforeLeave);
|
|
459
457
|
return this;
|
|
460
458
|
}
|
|
461
459
|
if (!this._isFn(guard, "addRouteGuard", routeName)) return this;
|
|
@@ -663,6 +661,8 @@ sap.ui.define(["sap/m/routing/Router", "sap/base/Log", "sap/ui/core/library", "s
|
|
|
663
661
|
for (const resolve of resolvers) {
|
|
664
662
|
resolve(result);
|
|
665
663
|
}
|
|
664
|
+
// No handler runs while destroy() tears the router down; the native destroy() fires no event either.
|
|
665
|
+
if (this._destroyed) return;
|
|
666
666
|
try {
|
|
667
667
|
this.fireEvent("navigationSettled", result);
|
|
668
668
|
} catch (error) {
|
|
@@ -671,6 +671,11 @@ sap.ui.define(["sap/m/routing/Router", "sap/base/Log", "sap/ui/core/library", "s
|
|
|
671
671
|
}
|
|
672
672
|
},
|
|
673
673
|
navTo: function _navTo(routeName, parameters, componentTargetInfoOrReplace, replaceOrOptions, options) {
|
|
674
|
+
// The guards are gone: code that awaited navigationSettled() may still call navTo().
|
|
675
|
+
if (this._destroyed) {
|
|
676
|
+
Log.warning("navTo: router is destroyed, ignoring", routeName, LOG_COMPONENT);
|
|
677
|
+
return this;
|
|
678
|
+
}
|
|
674
679
|
const {
|
|
675
680
|
componentTargetInfo,
|
|
676
681
|
replace,
|