ui5-lib-guard-router 1.6.1 → 1.6.2

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Drop-in replacement for `sap.m.routing.Router` that intercepts navigation **before** route matching, target loading, or view creation, preventing flashes of unauthorized content and polluted browser history.
4
4
 
5
- > Born from [SAP/openui5#3411](https://github.com/SAP/openui5/issues/3411), an open request for native navigation guard support in UI5.
5
+ > Born from [UI5/openui5#3411](https://github.com/UI5/openui5/issues/3411), an open request for native navigation guard support in UI5.
6
6
  >
7
7
  > **Related resources**:
8
8
  >
@@ -177,7 +177,7 @@ export default class Component extends UIComponent {
177
177
 
178
178
  ## How it works
179
179
 
180
- The library extends [`sap.m.routing.Router`](https://sdk.openui5.org/api/sap.m.routing.Router) and intercepts navigation through two entry points:
180
+ The library extends [`sap.m.routing.Router`](https://sdk.openui5.org/#/api/sap.m.routing.Router) and intercepts navigation through two entry points:
181
181
 
182
182
  - **`navTo()` preflight**: For programmatic navigation (`router.navTo()`), guards run _before_ any hash change occurs. If a guard blocks or redirects, the hash never changes, so no history entry is created.
183
183
  - **`parse()` fallback**: For browser-initiated navigation (back/forward buttons, URL bar entry, direct hash changes), guards run inside the `parse()` override after the browser has already changed the hash. If a guard blocks or redirects, the router restores the previous hash via `replaceHash()`.
@@ -450,10 +450,10 @@ The full object form with `enter` and `leave` keys registers both enter and leav
450
450
 
451
451
  **Module paths** use dot notation and are resolved relative to `sap.app.id`. Given `sap.app.id = "com.example.app"`, the path `"guards.authGuard"` resolves to `"com/example/app/guards/authGuard"`.
452
452
 
453
- To use an absolute module path, prefix it with `"module:"`:
453
+ To use an absolute module path, prefix it with `"module:"`. Dot notation is used for consistency with relative paths; slash notation (`module:com/shared/guards/authGuard`) is also accepted:
454
454
 
455
455
  ```json
456
- "*": ["module:com/shared/guards/authGuard"]
456
+ "*": ["module:com.shared.guards.authGuard"]
457
457
  ```
458
458
 
459
459
  ### Complete example
@@ -1026,10 +1026,10 @@ Or set the global log level via URL parameter (per-component filtering is only a
1026
1026
 
1027
1027
  ### Running tests
1028
1028
 
1029
- The library ships three QUnit test suites that run in headless Chrome via WebdriverIO:
1029
+ The library ships nine QUnit test suites that run in headless Chrome via WebdriverIO:
1030
1030
 
1031
1031
  ```bash
1032
- # All three suites (Router, NativeRouterCompat, UpstreamParity)
1032
+ # All suites (Router, RouterGuards, RouterAsync, RouterNavigation, RouterSettlement, RouterOptions, GuardPipeline, NativeRouterCompat, UpstreamParity)
1033
1033
  npm run test:qunit
1034
1034
 
1035
1035
  # Full matrix including OpenUI5 1.120 compatibility lane and E2E
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "buildManifest": {
18
18
  "manifestVersion": "0.2",
19
- "timestamp": "2026-04-02T23:45:49.937Z",
19
+ "timestamp": "2026-05-15T15:28:23.027Z",
20
20
  "versions": {
21
21
  "builderVersion": "4.1.4",
22
22
  "projectVersion": "4.0.13",
@@ -31,7 +31,7 @@
31
31
  "includedTasks": [],
32
32
  "excludedTasks": []
33
33
  },
34
- "version": "1.6.1",
34
+ "version": "1.6.2",
35
35
  "namespace": "ui5/guard/router",
36
36
  "tags": {
37
37
  "/resources/ui5/guard/router/GuardPipeline-dbg.js": {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Generated with TypeScript 6.0.2 / OpenUI5 1.144.0 using:
2
2
  // - typescript@6.0.2
3
- /// <reference path="./resources/ui5/guard/router/Router.d.ts"/>
3
+ /// <reference path="./resources/ui5/guard/router/GuardPipeline.d.ts"/>
4
4
  /// <reference path="./resources/ui5/guard/router/library.d.ts"/>
5
+ /// <reference path="./resources/ui5/guard/router/Router.d.ts"/>
5
6
  /// <reference path="./resources/ui5/guard/router/types.d.ts"/>
6
- /// <reference path="./resources/ui5/guard/router/NavigationOutcome.d.ts"/>
7
- /// <reference path="./resources/ui5/guard/router/GuardPipeline.d.ts"/>
7
+ /// <reference path="./resources/ui5/guard/router/NavigationOutcome.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.6.1</version>
5
+ <version>1.6.2</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>
@@ -96,12 +96,18 @@ sap.ui.define(["sap/m/routing/Router", "sap/base/Log", "sap/ui/core/library", ".
96
96
  /** Parsed guard declaration from the manifest `guards` block. */
97
97
 
98
98
  /**
99
- * Resolve a dot-notation module path following UI5 routing conventions.
100
- * Mirrors `sap.ui.core.routing.Target._getEffectiveObjectName()`.
99
+ * Resolve a guard module path to a slash-separated AMD module path.
101
100
  *
102
- * - Paths prefixed with `"module:"` are treated as absolute (the prefix is
103
- * stripped and dots become slashes).
104
- * - All other paths are prefixed with the component namespace.
101
+ * Inspired by `sap.ui.core.routing.Target._getEffectiveObjectName()`,
102
+ * which skips namespace prepending for `"module:"`-prefixed paths. This
103
+ * function goes further: it also converts dots to slashes in a single
104
+ * step, so both dot notation (`module:some.lib.guard`) and slash
105
+ * notation (`module:some/lib/guard`) are accepted.
106
+ *
107
+ * - Paths prefixed with `"module:"` are treated as absolute (the prefix
108
+ * is stripped, dots become slashes).
109
+ * - All other paths are prefixed with the component namespace, then dots
110
+ * become slashes.
105
111
  */
106
112
  function resolveGuardModulePath(dotPath, componentNamespace) {
107
113
  if (dotPath.startsWith("module:")) {
@@ -1452,8 +1458,7 @@ sap.ui.define(["sap/m/routing/Router", "sap/base/Log", "sap/ui/core/library", ".
1452
1458
  // Sort by pattern depth (segment count) so ancestor guards run first.
1453
1459
  // Global ("*") descriptors return 0 here -- their relative position is irrelevant
1454
1460
  // because GuardPipeline evaluates globals separately from route-specific guards.
1455
- // oxlint-disable-next-line unicorn/no-array-sort -- expanded is a local array, mutation is intentional
1456
- return expanded.sort((a, b) => {
1461
+ return expanded.toSorted((a, b) => {
1457
1462
  if (a.route === "*" || b.route === "*") return 0;
1458
1463
  const pa = patternByName.get(a.route) ?? "";
1459
1464
  const pb = patternByName.get(b.route) ?? "";
@@ -1468,10 +1473,8 @@ sap.ui.define(["sap/m/routing/Router", "sap/base/Log", "sap/ui/core/library", ".
1468
1473
  const manifest = this._manifestMeta.get(routeName);
1469
1474
  const runtime = this._runtimeMeta.get(routeName);
1470
1475
  if (!manifest && !runtime) return Router._EMPTY_META;
1471
- if (!runtime) return manifest ?? Router._EMPTY_META;
1472
- if (!manifest) return Object.freeze({
1473
- ...runtime
1474
- });
1476
+ if (!runtime) return manifest;
1477
+ if (!manifest) return runtime;
1475
1478
  return Object.freeze({
1476
1479
  ...manifest,
1477
1480
  ...runtime