ui5-lib-guard-router 1.6.2 → 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.
Files changed (67) hide show
  1. package/{dist/.ui5 → .ui5}/build-manifest.json +56 -8
  2. package/CHANGELOG.md +197 -0
  3. package/README.md +695 -327
  4. package/dist/index.d.ts +9 -5
  5. package/dist/resources/ui5/guard/router/.library +1 -1
  6. package/dist/resources/ui5/guard/router/GuardConfig-dbg.js +222 -0
  7. package/dist/resources/ui5/guard/router/GuardConfig-dbg.js.map +1 -0
  8. package/dist/resources/ui5/guard/router/GuardConfig.d.ts +89 -0
  9. package/dist/resources/ui5/guard/router/GuardConfig.d.ts.map +1 -0
  10. package/dist/resources/ui5/guard/router/GuardConfig.js +2 -0
  11. package/dist/resources/ui5/guard/router/GuardConfig.js.map +1 -0
  12. package/dist/resources/ui5/guard/router/GuardModules-dbg.js +253 -0
  13. package/dist/resources/ui5/guard/router/GuardModules-dbg.js.map +1 -0
  14. package/dist/resources/ui5/guard/router/GuardModules.d.ts +72 -0
  15. package/dist/resources/ui5/guard/router/GuardModules.d.ts.map +1 -0
  16. package/dist/resources/ui5/guard/router/GuardModules.js +2 -0
  17. package/dist/resources/ui5/guard/router/GuardModules.js.map +1 -0
  18. package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js +125 -122
  19. package/dist/resources/ui5/guard/router/GuardPipeline-dbg.js.map +1 -1
  20. package/dist/resources/ui5/guard/router/GuardPipeline.d.ts +45 -26
  21. package/dist/resources/ui5/guard/router/GuardPipeline.d.ts.map +1 -1
  22. package/dist/resources/ui5/guard/router/GuardPipeline.js +1 -1
  23. package/dist/resources/ui5/guard/router/GuardPipeline.js.map +1 -1
  24. package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js +3 -3
  25. package/dist/resources/ui5/guard/router/NavigationOutcome-dbg.js.map +1 -1
  26. package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts +3 -3
  27. package/dist/resources/ui5/guard/router/NavigationOutcome.d.ts.map +1 -1
  28. package/dist/resources/ui5/guard/router/NavigationOutcome.js.map +1 -1
  29. package/dist/resources/ui5/guard/router/PatternTree-dbg.js +156 -0
  30. package/dist/resources/ui5/guard/router/PatternTree-dbg.js.map +1 -0
  31. package/dist/resources/ui5/guard/router/PatternTree.d.ts +71 -0
  32. package/dist/resources/ui5/guard/router/PatternTree.d.ts.map +1 -0
  33. package/dist/resources/ui5/guard/router/PatternTree.js +2 -0
  34. package/dist/resources/ui5/guard/router/PatternTree.js.map +1 -0
  35. package/dist/resources/ui5/guard/router/RouteMeta-dbg.js +84 -0
  36. package/dist/resources/ui5/guard/router/RouteMeta-dbg.js.map +1 -0
  37. package/dist/resources/ui5/guard/router/RouteMeta.d.ts +33 -0
  38. package/dist/resources/ui5/guard/router/RouteMeta.d.ts.map +1 -0
  39. package/dist/resources/ui5/guard/router/RouteMeta.js +2 -0
  40. package/dist/resources/ui5/guard/router/RouteMeta.js.map +1 -0
  41. package/dist/resources/ui5/guard/router/Router-dbg.js +900 -1033
  42. package/dist/resources/ui5/guard/router/Router-dbg.js.map +1 -1
  43. package/dist/resources/ui5/guard/router/Router.d.ts +362 -212
  44. package/dist/resources/ui5/guard/router/Router.d.ts.map +1 -1
  45. package/dist/resources/ui5/guard/router/Router.js +1 -1
  46. package/dist/resources/ui5/guard/router/Router.js.map +1 -1
  47. package/dist/resources/ui5/guard/router/library-dbg.js +1 -1
  48. package/dist/resources/ui5/guard/router/library-dbg.js.map +1 -1
  49. package/dist/resources/ui5/guard/router/library-preload.js +8 -4
  50. package/dist/resources/ui5/guard/router/library-preload.js.map +1 -1
  51. package/dist/resources/ui5/guard/router/library.js +1 -1
  52. package/dist/resources/ui5/guard/router/library.js.map +1 -1
  53. package/dist/resources/ui5/guard/router/manifest.json +5 -2
  54. package/dist/resources/ui5/guard/router/types-dbg.js.map +1 -1
  55. package/dist/resources/ui5/guard/router/types.d.ts +94 -39
  56. package/dist/resources/ui5/guard/router/types.d.ts.map +1 -1
  57. package/package.json +10 -6
  58. package/src/GuardConfig.ts +272 -0
  59. package/src/GuardModules.ts +249 -0
  60. package/src/GuardPipeline.ts +158 -129
  61. package/src/NavigationOutcome.ts +3 -3
  62. package/src/PatternTree.ts +145 -0
  63. package/src/RouteMeta.ts +82 -0
  64. package/src/Router.ts +1110 -1150
  65. package/src/manifest.json +5 -2
  66. package/src/types.ts +79 -22
  67. package/tsconfig.json +0 -11
@@ -0,0 +1,2 @@
1
+ sap.ui.define([],function(){"use strict";const t=/^:[^:]*:$/;function e(t){const e=t.indexOf("{?");if(e!==-1)return t.slice(0,e);const n=t.indexOf(":?");if(n!==-1)return t.slice(0,n);return t}function n(n){return n.split("/").map(e).filter(e=>e!==""&&!t.test(e))}function r(t,e){if(t==="")return true;const r=n(t);if(r.length===0)return false;const o=n(e);if(o.length<=r.length)return false;return r.every((t,e)=>{const n=o[e];if(t===n)return true;return t.startsWith("{")&&n.startsWith("{")})}function o(t,e){return n(e.get(t)??"").length}function u(t,e){return t.toSorted((t,n)=>o(t.route,e)-o(n.route,e))}function i(t,e){if(e.length===0)return t;const n=new Map(e.map(t=>[t.name,t.pattern]));const o=[];for(const i of u(t,n)){o.push(i);if(i.route==="*")continue;const t=n.get(i.route);if(t===undefined)continue;for(const{name:n,pattern:u}of e){if(n!==i.route&&r(t,u)){o.push({...i,route:n})}}}return o}function s(t,e,n){const o=new Map(n.map(t=>[t.name,t.pattern]));const i=o.get(e);if(i===undefined)return[];const s=[];for(const f of u(t,o)){if(f.route==="*")continue;if(f.route===e){for(const{name:t,pattern:o}of n){if(t!==e&&r(i,o)){s.push({...f,route:t})}}}else{const t=o.get(f.route);if(t!==undefined&&r(t,i)){s.push({...f,route:e})}}}return s}var f={__esModule:true};f.patternSegments=n;f.isPatternAncestor=r;f.byRouteDepth=u;f.expandToDescendants=i;f.expandForNewRoute=s;return f});
2
+ //# sourceMappingURL=PatternTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatternTree.js","names":["OPTIONAL_OR_REST_SEGMENT","stripInlineQuery","seg","mqIdx","indexOf","slice","oqIdx","patternSegments","pattern","split","map","filter","test","isPatternAncestor","ancestorPattern","candidatePattern","ancestorSegments","length","candidateSegments","every","i","candidateSeg","startsWith","depthOf","route","patternByName","get","byRouteDepth","entries","toSorted","a","b","expandToDescendants","routes","Map","r","name","expanded","entry","push","undefined","expandForNewRoute","newName","newPattern","result","__exports","__esModule"],"sources":["./PatternTree.ts"],"sourcesContent":["/**\n * Pattern-tree helpers: compare UI5 route patterns by their mandatory path segments.\n */\n\n/** Matches a standalone optional (`:param:`) or rest (`:param*:`) segment. */\nconst OPTIONAL_OR_REST_SEGMENT = /^:[^:]*:$/;\n\n/**\n * Strips inline query and optional-query suffixes from a segment.\n *\n * UI5 (crossroads.js) allows query parameters to attach directly to a\n * path segment without a `/` separator:\n * - `product{?query}` → mandatory query on `product`\n * - `product:?query:` → optional query on `product`\n * - `{id}{?query}` → mandatory param + mandatory query\n *\n * For pattern-tree ancestry we only care about the path portion,\n * so these suffixes are stripped.\n */\nfunction stripInlineQuery(seg: string): string {\n\tconst mqIdx = seg.indexOf(\"{?\");\n\tif (mqIdx !== -1) return seg.slice(0, mqIdx);\n\tconst oqIdx = seg.indexOf(\":?\");\n\tif (oqIdx !== -1) return seg.slice(0, oqIdx);\n\treturn seg;\n}\n\n/**\n * Extract mandatory path segments from a UI5 route pattern.\n *\n * Splits on `/`, strips inline query suffixes, then drops empty segments,\n * standalone optional (`:param:`), and rest (`:param*:`) segments.\n */\nexport function patternSegments(pattern: string): string[] {\n\treturn pattern\n\t\t.split(\"/\")\n\t\t.map(stripInlineQuery)\n\t\t.filter((seg) => seg !== \"\" && !OPTIONAL_OR_REST_SEGMENT.test(seg));\n}\n\n/**\n * Check if `ancestorPattern` is a URL-tree ancestor of `candidatePattern`.\n *\n * Both patterns are reduced to their mandatory path segments and compared\n * positionally. Mandatory parameter segments (`{paramA}`, `{paramB}`) are\n * treated as equivalent regardless of name, so `employees/{empId}` is\n * recognized as an ancestor of `employees/{id}/resume`.\n */\nexport function isPatternAncestor(ancestorPattern: string, candidatePattern: string): boolean {\n\tif (ancestorPattern === \"\") return true;\n\tconst ancestorSegments = patternSegments(ancestorPattern);\n\tif (ancestorSegments.length === 0) return false;\n\tconst candidateSegments = patternSegments(candidatePattern);\n\tif (candidateSegments.length <= ancestorSegments.length) return false;\n\treturn ancestorSegments.every((seg, i) => {\n\t\tconst candidateSeg = candidateSegments[i];\n\t\tif (seg === candidateSeg) return true;\n\t\treturn seg.startsWith(\"{\") && candidateSeg.startsWith(\"{\");\n\t});\n}\n\n/** A route name with its pattern. */\nexport interface RoutePattern {\n\treadonly name: string;\n\treadonly pattern: string;\n}\n\n/** Number of mandatory segments in the pattern of `route` (0 when unknown). */\nfunction depthOf(route: string, patternByName: ReadonlyMap<string, string>): number {\n\treturn patternSegments(patternByName.get(route) ?? \"\").length;\n}\n\n/**\n * Entries ordered by the pattern depth of their own route, declaration order within one depth.\n * Expanding them in this order puts an ancestor's entries before a descendant's on every route.\n */\nexport function byRouteDepth<T extends { readonly route: string }>(\n\tentries: T[],\n\tpatternByName: ReadonlyMap<string, string>,\n): T[] {\n\treturn entries.toSorted((a, b) => depthOf(a.route, patternByName) - depthOf(b.route, patternByName));\n}\n\n/**\n * Copy each route-specific entry to every descendant route (`inheritance: \"pattern-tree\"`).\n * Global (`\"*\"`) entries and entries for routes without a known pattern are kept as-is.\n * Ordered by the pattern depth of the route an entry was declared for, so on every route\n * ancestor guards run before descendant guards, whatever the declaration order. Where global\n * entries end up does not matter: the pipeline runs global guards separately.\n * A route named `\"*\"` does not pass its entries on, because a `\"*\"` entry is a global one.\n */\nexport function expandToDescendants<T extends { readonly route: string }>(entries: T[], routes: RoutePattern[]): T[] {\n\tif (routes.length === 0) return entries;\n\tconst patternByName = new Map(routes.map((r) => [r.name, r.pattern]));\n\n\tconst expanded: T[] = [];\n\tfor (const entry of byRouteDepth(entries, patternByName)) {\n\t\texpanded.push(entry);\n\t\tif (entry.route === \"*\") continue;\n\t\tconst ancestorPattern = patternByName.get(entry.route);\n\t\tif (ancestorPattern === undefined) continue;\n\t\tfor (const { name, pattern } of routes) {\n\t\t\tif (name !== entry.route && isPatternAncestor(ancestorPattern, pattern)) {\n\t\t\t\texpanded.push({ ...entry, route: name });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn expanded;\n}\n\n/**\n * Entries a newly added route inherits (`inheritance: \"pattern-tree\"`): copies of its\n * ancestors' entries for the new route, and copies of its own entries for its existing\n * descendants. `routes` must include the new route. Ordered like {@link expandToDescendants};\n * where the entries go among those a route has already is up to the caller.\n */\nexport function expandForNewRoute<T extends { readonly route: string }>(\n\tentries: T[],\n\tnewName: string,\n\troutes: RoutePattern[],\n): T[] {\n\tconst patternByName = new Map(routes.map((r) => [r.name, r.pattern]));\n\tconst newPattern = patternByName.get(newName);\n\tif (newPattern === undefined) return [];\n\n\tconst result: T[] = [];\n\tfor (const entry of byRouteDepth(entries, patternByName)) {\n\t\tif (entry.route === \"*\") continue;\n\t\tif (entry.route === newName) {\n\t\t\tfor (const { name, pattern } of routes) {\n\t\t\t\tif (name !== newName && isPatternAncestor(newPattern, pattern)) {\n\t\t\t\t\tresult.push({ ...entry, route: name });\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst ancestorPattern = patternByName.get(entry.route);\n\t\t\tif (ancestorPattern !== undefined && isPatternAncestor(ancestorPattern, newPattern)) {\n\t\t\t\tresult.push({ ...entry, route: newName });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n"],"mappings":"yCAKA,MAAMA,EAA2B,YAcjC,SAASC,EAAiBC,GACzB,MAAMC,EAAQD,EAAIE,QAAQ,MAC1B,GAAID,KAAW,EAAG,OAAOD,EAAIG,MAAM,EAAGF,GACtC,MAAMG,EAAQJ,EAAIE,QAAQ,MAC1B,GAAIE,KAAW,EAAG,OAAOJ,EAAIG,MAAM,EAAGC,GACtC,OAAOJ,CACR,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OAAOC,CACR,CAQO,SAASI,EACfb,EACAc,EACAT,GAEA,MAAMR,EAAgB,IAAIS,IAAID,EAAOvB,IAAKyB,GAAM,CAACA,EAAEC,KAAMD,EAAE3B,WAC3D,MAAMmC,EAAalB,EAAcC,IAAIgB,GACrC,GAAIC,IAAeH,UAAW,MAAO,GAErC,MAAMI,EAAc,GACpB,IAAK,MAAMN,KAASX,EAAaC,EAASH,GAAgB,CACzD,GAAIa,EAAMd,QAAU,IAAK,SACzB,GAAIc,EAAMd,QAAUkB,EAAS,CAC5B,IAAK,MAAMN,KAAEA,EAAI5B,QAAEA,KAAayB,EAAQ,CACvC,GAAIG,IAASM,GAAW7B,EAAkB8B,EAAYnC,GAAU,CAC/DoC,EAAOL,KAAK,IAAKD,EAAOd,MAAOY,GAChC,CACD,CACD,KAAO,CACN,MAAMtB,EAAkBW,EAAcC,IAAIY,EAAMd,OAChD,GAAIV,IAAoB0B,WAAa3B,EAAkBC,EAAiB6B,GAAa,CACpFC,EAAOL,KAAK,IAAKD,EAAOd,MAAOkB,GAChC,CACD,CACD,CAEA,OAAOE,CACR,CAAC,IAAAC,EAAA,CAAAC,WAAA,MAAAD,EAAAtC,kBAAAsC,EAAAhC,oBAAAgC,EAAAlB,eAAAkB,EAAAb,sBAAAa,EAAAJ,oBAAA,OAAAI,CAAA","ignoreList":[]}
@@ -0,0 +1,84 @@
1
+ sap.ui.define(["./PatternTree"], function (___PatternTree) {
2
+ "use strict";
3
+
4
+ /**
5
+ * Route metadata: manifest and runtime values per route, resolved with
6
+ * optional pattern-tree inheritance and cached until something changes.
7
+ */
8
+ const isPatternAncestor = ___PatternTree["isPatternAncestor"];
9
+ const patternSegments = ___PatternTree["patternSegments"];
10
+ const EMPTY_META = Object.freeze({});
11
+ class RouteMetaStore {
12
+ _runtime = new Map();
13
+ _resolved = new Map();
14
+ /**
15
+ * @param manifest - Frozen metadata per route from the manifest `routeMeta` block.
16
+ * @param routes - Route patterns for pattern-tree inheritance, or `null` for none.
17
+ */
18
+ constructor(manifest, routes) {
19
+ this._manifest = manifest;
20
+ this._routes = routes;
21
+ }
22
+
23
+ /** Resolved metadata for a route: frozen, and the same object until something changes. */
24
+ get(routeName) {
25
+ let result = this._resolved.get(routeName);
26
+ if (result === undefined) {
27
+ result = this._routes ? this._resolveInherited(routeName, this._routes()) : this._resolveOwn(routeName);
28
+ if (Object.keys(result).length === 0) result = EMPTY_META;
29
+ this._resolved.set(routeName, result);
30
+ }
31
+ return result;
32
+ }
33
+
34
+ /** Set runtime metadata for a route, merged over its manifest metadata. */
35
+ set(routeName, meta) {
36
+ this._runtime.set(routeName, Object.freeze({
37
+ ...meta
38
+ }));
39
+ this._resolved.clear();
40
+ }
41
+
42
+ /** Drop resolved values, e.g. after a route was added that changes inheritance. */
43
+ invalidate() {
44
+ this._resolved.clear();
45
+ }
46
+
47
+ /** Drop all metadata, manifest and runtime. */
48
+ clear() {
49
+ this._manifest.clear();
50
+ this._runtime.clear();
51
+ this._resolved.clear();
52
+ }
53
+
54
+ /** Manifest metadata with runtime metadata on top, without inheritance. */
55
+ _resolveOwn(routeName) {
56
+ const manifest = this._manifest.get(routeName);
57
+ const runtime = this._runtime.get(routeName);
58
+ if (!runtime) return manifest ?? EMPTY_META;
59
+ if (!manifest) return runtime;
60
+ return Object.freeze({
61
+ ...manifest,
62
+ ...runtime
63
+ });
64
+ }
65
+
66
+ /** Ancestors' metadata shallowest-first, then the route's own; each level manifest then runtime. */
67
+ _resolveInherited(routeName, routes) {
68
+ const own = routes.find(r => r.name === routeName);
69
+ if (!own) return this._resolveOwn(routeName);
70
+ const levels = routes
71
+ // Only the empty pattern counts as its own ancestor; merging a level twice changes nothing.
72
+ .filter(r => isPatternAncestor(r.pattern, own.pattern)).toSorted((a, b) => patternSegments(a.pattern).length - patternSegments(b.pattern).length).map(r => r.name);
73
+ levels.push(routeName);
74
+ const merged = {};
75
+ for (const name of levels) {
76
+ Object.assign(merged, this._manifest.get(name), this._runtime.get(name));
77
+ }
78
+ return Object.freeze(merged);
79
+ }
80
+ }
81
+ RouteMetaStore.EMPTY_META = EMPTY_META;
82
+ return RouteMetaStore;
83
+ });
84
+ //# sourceMappingURL=RouteMeta-dbg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteMeta-dbg.js","names":["isPatternAncestor","___PatternTree","patternSegments","EMPTY_META","Object","freeze","RouteMetaStore","_runtime","Map","_resolved","constructor","manifest","routes","_manifest","_routes","get","routeName","result","undefined","_resolveInherited","_resolveOwn","keys","length","set","meta","clear","invalidate","runtime","own","find","r","name","levels","filter","pattern","toSorted","a","b","map","push","merged","assign"],"sourceRoot":"./","sources":["RouteMeta.ts"],"sourcesContent":["/**\n * Route metadata: manifest and runtime values per route, resolved with\n * optional pattern-tree inheritance and cached until something changes.\n */\nimport { isPatternAncestor, patternSegments, type RoutePattern } from \"./PatternTree\";\n\ntype Meta = Readonly<Record<string, unknown>>;\n\nexport const EMPTY_META: Meta = Object.freeze({});\n\nexport default class RouteMetaStore {\n\tprivate readonly _manifest: Map<string, Meta>;\n\tprivate readonly _runtime = new Map<string, Meta>();\n\tprivate readonly _resolved = new Map<string, Meta>();\n\tprivate readonly _routes: (() => RoutePattern[]) | null;\n\n\t/**\n\t * @param manifest - Frozen metadata per route from the manifest `routeMeta` block.\n\t * @param routes - Route patterns for pattern-tree inheritance, or `null` for none.\n\t */\n\tconstructor(manifest: Map<string, Meta>, routes: (() => RoutePattern[]) | null) {\n\t\tthis._manifest = manifest;\n\t\tthis._routes = routes;\n\t}\n\n\t/** Resolved metadata for a route: frozen, and the same object until something changes. */\n\tget(routeName: string): Meta {\n\t\tlet result = this._resolved.get(routeName);\n\t\tif (result === undefined) {\n\t\t\tresult = this._routes ? this._resolveInherited(routeName, this._routes()) : this._resolveOwn(routeName);\n\t\t\tif (Object.keys(result).length === 0) result = EMPTY_META;\n\t\t\tthis._resolved.set(routeName, result);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Set runtime metadata for a route, merged over its manifest metadata. */\n\tset(routeName: string, meta: Record<string, unknown>): void {\n\t\tthis._runtime.set(routeName, Object.freeze({ ...meta }));\n\t\tthis._resolved.clear();\n\t}\n\n\t/** Drop resolved values, e.g. after a route was added that changes inheritance. */\n\tinvalidate(): void {\n\t\tthis._resolved.clear();\n\t}\n\n\t/** Drop all metadata, manifest and runtime. */\n\tclear(): void {\n\t\tthis._manifest.clear();\n\t\tthis._runtime.clear();\n\t\tthis._resolved.clear();\n\t}\n\n\t/** Manifest metadata with runtime metadata on top, without inheritance. */\n\tprivate _resolveOwn(routeName: string): Meta {\n\t\tconst manifest = this._manifest.get(routeName);\n\t\tconst runtime = this._runtime.get(routeName);\n\t\tif (!runtime) return manifest ?? EMPTY_META;\n\t\tif (!manifest) return runtime;\n\t\treturn Object.freeze({ ...manifest, ...runtime });\n\t}\n\n\t/** Ancestors' metadata shallowest-first, then the route's own; each level manifest then runtime. */\n\tprivate _resolveInherited(routeName: string, routes: RoutePattern[]): Meta {\n\t\tconst own = routes.find((r) => r.name === routeName);\n\t\tif (!own) return this._resolveOwn(routeName);\n\n\t\tconst levels = routes\n\t\t\t// Only the empty pattern counts as its own ancestor; merging a level twice changes nothing.\n\t\t\t.filter((r) => isPatternAncestor(r.pattern, own.pattern))\n\t\t\t.toSorted((a, b) => patternSegments(a.pattern).length - patternSegments(b.pattern).length)\n\t\t\t.map((r) => r.name);\n\t\tlevels.push(routeName);\n\n\t\tconst merged: Record<string, unknown> = {};\n\t\tfor (const name of levels) {\n\t\t\tObject.assign(merged, this._manifest.get(name), this._runtime.get(name));\n\t\t}\n\t\treturn Object.freeze(merged);\n\t}\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;EAHA,MAISA,iBAAiB,GAAAC,cAAA;EAAA,MAAEC,eAAe,GAAAD,cAAA;EAIpC,MAAME,UAAgB,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;EAElC,MAAMC,cAAc,CAAC;IAElBC,QAAQ,GAAG,IAAIC,GAAG,CAA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ACgB,IAAI,CAAC,EAAE,IAAI,CAACxB,QAAQ,CAACQ,GAAG,CAACgB,IAAI,CAAC,CAAC;MACzE;MACA,OAAO3B,MAAM,CAACC,MAAM,CAACmC,MAAM,CAAC;IAC7B;EACD;EAAClC,cAAA,CAAAH,UAAA,GAAAA,UAAA;EAAA,OAAAG,cAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ declare module "ui5/guard/router/RouteMeta" {
2
+ /**
3
+ * Route metadata: manifest and runtime values per route, resolved with
4
+ * optional pattern-tree inheritance and cached until something changes.
5
+ */
6
+ import { type RoutePattern } from "ui5/guard/router/PatternTree";
7
+ type Meta = Readonly<Record<string, unknown>>;
8
+ export const EMPTY_META: Meta;
9
+ export default class RouteMetaStore {
10
+ private readonly _manifest;
11
+ private readonly _runtime;
12
+ private readonly _resolved;
13
+ private readonly _routes;
14
+ /**
15
+ * @param manifest - Frozen metadata per route from the manifest `routeMeta` block.
16
+ * @param routes - Route patterns for pattern-tree inheritance, or `null` for none.
17
+ */
18
+ constructor(manifest: Map<string, Meta>, routes: (() => RoutePattern[]) | null);
19
+ /** Resolved metadata for a route: frozen, and the same object until something changes. */
20
+ get(routeName: string): Meta;
21
+ /** Set runtime metadata for a route, merged over its manifest metadata. */
22
+ set(routeName: string, meta: Record<string, unknown>): void;
23
+ /** Drop resolved values, e.g. after a route was added that changes inheritance. */
24
+ invalidate(): void;
25
+ /** Drop all metadata, manifest and runtime. */
26
+ clear(): void;
27
+ /** Manifest metadata with runtime metadata on top, without inheritance. */
28
+ private _resolveOwn;
29
+ /** Ancestors' metadata shallowest-first, then the route's own; each level manifest then runtime. */
30
+ private _resolveInherited;
31
+ }
32
+ }
33
+ //# sourceMappingURL=RouteMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteMeta.d.ts","sourceRoot":"../../../../..","sources":["src/RouteMeta.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,4BAA4B,CAAC;IAC5C;;;OAGG;IACH,OAAO,EAAsC,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;IAErG,KAAK,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvC,MAAM,UAAU,EAAE,IAAwB,CAAC;IAElD,MAAM,CAAC,OAAO,OAAO,cAAc;QAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;QAC9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;QACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;QACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;QAExD;;;WAGG;oBACS,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,YAAY,EAAE,CAAC,GAAG,IAAI;QAK9E,0FAA0F;QAC1F,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;QAU5B,2EAA2E;QAC3E,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;QAK3D,mFAAmF;QACnF,UAAU,IAAI,IAAI;QAIlB,+CAA+C;QAC/C,KAAK,IAAI,IAAI;QAMb,2EAA2E;QAC3E,OAAO,CAAC,WAAW;QAQnB,oGAAoG;QACpG,OAAO,CAAC,iBAAiB;KAiBzB;CAEA"}
@@ -0,0 +1,2 @@
1
+ sap.ui.define(["./PatternTree"],function(e){"use strict";const t=e["isPatternAncestor"];const s=e["patternSegments"];const r=Object.freeze({});class n{_runtime=new Map;_resolved=new Map;constructor(e,t){this._manifest=e;this._routes=t}get(e){let t=this._resolved.get(e);if(t===undefined){t=this._routes?this._resolveInherited(e,this._routes()):this._resolveOwn(e);if(Object.keys(t).length===0)t=r;this._resolved.set(e,t)}return t}set(e,t){this._runtime.set(e,Object.freeze({...t}));this._resolved.clear()}invalidate(){this._resolved.clear()}clear(){this._manifest.clear();this._runtime.clear();this._resolved.clear()}_resolveOwn(e){const t=this._manifest.get(e);const s=this._runtime.get(e);if(!s)return t??r;if(!t)return s;return Object.freeze({...t,...s})}_resolveInherited(e,r){const n=r.find(t=>t.name===e);if(!n)return this._resolveOwn(e);const i=r.filter(e=>t(e.pattern,n.pattern)).toSorted((e,t)=>s(e.pattern).length-s(t.pattern).length).map(e=>e.name);i.push(e);const o={};for(const e of i){Object.assign(o,this._manifest.get(e),this._runtime.get(e))}return Object.freeze(o)}}n.EMPTY_META=r;return n});
2
+ //# sourceMappingURL=RouteMeta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteMeta.js","names":["isPatternAncestor","___PatternTree","patternSegments","EMPTY_META","Object","freeze","RouteMetaStore","_runtime","Map","_resolved","constructor","manifest","routes","this","_manifest","_routes","get","routeName","result","undefined","_resolveInherited","_resolveOwn","keys","length","set","meta","clear","invalidate","runtime","own","find","r","name","levels","filter","pattern","toSorted","a","b","map","push","merged","assign"],"sources":["./RouteMeta.ts"],"sourcesContent":["/**\n * Route metadata: manifest and runtime values per route, resolved with\n * optional pattern-tree inheritance and cached until something changes.\n */\nimport { isPatternAncestor, patternSegments, type RoutePattern } from \"./PatternTree\";\n\ntype Meta = Readonly<Record<string, unknown>>;\n\nexport const EMPTY_META: Meta = Object.freeze({});\n\nexport default class RouteMetaStore {\n\tprivate readonly _manifest: Map<string, Meta>;\n\tprivate readonly _runtime = new Map<string, Meta>();\n\tprivate readonly _resolved = new Map<string, Meta>();\n\tprivate readonly _routes: (() => RoutePattern[]) | null;\n\n\t/**\n\t * @param manifest - Frozen metadata per route from the manifest `routeMeta` block.\n\t * @param routes - Route patterns for pattern-tree inheritance, or `null` for none.\n\t */\n\tconstructor(manifest: Map<string, Meta>, routes: (() => RoutePattern[]) | null) {\n\t\tthis._manifest = manifest;\n\t\tthis._routes = routes;\n\t}\n\n\t/** Resolved metadata for a route: frozen, and the same object until something changes. */\n\tget(routeName: string): Meta {\n\t\tlet result = this._resolved.get(routeName);\n\t\tif (result === undefined) {\n\t\t\tresult = this._routes ? this._resolveInherited(routeName, this._routes()) : this._resolveOwn(routeName);\n\t\t\tif (Object.keys(result).length === 0) result = EMPTY_META;\n\t\t\tthis._resolved.set(routeName, result);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Set runtime metadata for a route, merged over its manifest metadata. */\n\tset(routeName: string, meta: Record<string, unknown>): void {\n\t\tthis._runtime.set(routeName, Object.freeze({ ...meta }));\n\t\tthis._resolved.clear();\n\t}\n\n\t/** Drop resolved values, e.g. after a route was added that changes inheritance. */\n\tinvalidate(): void {\n\t\tthis._resolved.clear();\n\t}\n\n\t/** Drop all metadata, manifest and runtime. */\n\tclear(): void {\n\t\tthis._manifest.clear();\n\t\tthis._runtime.clear();\n\t\tthis._resolved.clear();\n\t}\n\n\t/** Manifest metadata with runtime metadata on top, without inheritance. */\n\tprivate _resolveOwn(routeName: string): Meta {\n\t\tconst manifest = this._manifest.get(routeName);\n\t\tconst runtime = this._runtime.get(routeName);\n\t\tif (!runtime) return manifest ?? EMPTY_META;\n\t\tif (!manifest) return runtime;\n\t\treturn Object.freeze({ ...manifest, ...runtime });\n\t}\n\n\t/** Ancestors' metadata shallowest-first, then the route's own; each level manifest then runtime. */\n\tprivate _resolveInherited(routeName: string, routes: RoutePattern[]): Meta {\n\t\tconst own = routes.find((r) => r.name === routeName);\n\t\tif (!own) return this._resolveOwn(routeName);\n\n\t\tconst levels = routes\n\t\t\t// Only the empty pattern counts as its own ancestor; merging a level twice changes nothing.\n\t\t\t.filter((r) => isPatternAncestor(r.pattern, own.pattern))\n\t\t\t.toSorted((a, b) => patternSegments(a.pattern).length - patternSegments(b.pattern).length)\n\t\t\t.map((r) => r.name);\n\t\tlevels.push(routeName);\n\n\t\tconst merged: Record<string, unknown> = {};\n\t\tfor (const name of levels) {\n\t\t\tObject.assign(merged, this._manifest.get(name), this._runtime.get(name));\n\t\t}\n\t\treturn Object.freeze(merged);\n\t}\n}\n"],"mapp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