ui5-lib-guard-router 1.6.2 → 1.7.0

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 +190 -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 +122 -121
  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 +882 -1020
  42. package/dist/resources/ui5/guard/router/Router-dbg.js.map +1 -1
  43. package/dist/resources/ui5/guard/router/Router.d.ts +360 -211
  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 +155 -128
  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 +1089 -1130
  65. package/src/manifest.json +5 -2
  66. package/src/types.ts +79 -22
  67. package/tsconfig.json +0 -11
@@ -0,0 +1,253 @@
1
+ sap.ui.define(["sap/base/Log", "./GuardPipeline", "./GuardConfig"], function (Log, ___GuardPipeline, ___GuardConfig) {
2
+ "use strict";
3
+
4
+ const isPromiseLike = ___GuardPipeline["isPromiseLike"];
5
+ const LOG_COMPONENT = ___GuardPipeline["LOG_COMPONENT"];
6
+ const nameGuard = ___GuardPipeline["nameGuard"];
7
+ const isRecord = ___GuardConfig["isRecord"];
8
+ /** A guard function from a module, with the name its log messages show. */
9
+ /** A guard as a module exports it: any function. Its result is checked when it runs. */
10
+ function isGuardFn(value) {
11
+ return typeof value === "function";
12
+ }
13
+
14
+ /** Log a warning about a guard module entry in the manifest. */
15
+ function guardWarning(modulePath, detail) {
16
+ Log.warning(`guardRouter.guards: "${modulePath}" ${detail}`, undefined, LOG_COMPONENT);
17
+ }
18
+
19
+ /** The last segment of a module path, by which the guards of the module are named. */
20
+ function moduleNameOf(modulePath) {
21
+ return modulePath.slice(modulePath.lastIndexOf("/") + 1);
22
+ }
23
+
24
+ /** The position an export key selects: a plain non-negative integer, otherwise `NaN`. */
25
+ function positionOf(exportKey) {
26
+ return /^\d+$/.test(exportKey) ? Number(exportKey) : NaN;
27
+ }
28
+
29
+ /**
30
+ * Detect the export shape of a loaded guard module and extract guard functions.
31
+ *
32
+ * Shapes and the names they get (`moduleName` is the last path segment):
33
+ * - function → single guard, named `moduleName` (or the export key when one is given);
34
+ * an export key that names a function among its own properties picks that one
35
+ * - Array → ordered guards, named `moduleName#index` (non-functions warned and skipped)
36
+ * - plain object → guards in key order, named by key (non-functions warned and skipped)
37
+ *
38
+ * The module is read as the value it returns to the UI5 loader, which has no ES module
39
+ * interop. The UI5 transpiler (babel-plugin-transform-modules-ui5) returns a default export
40
+ * as that value, with named exports beside it collapsed onto it as properties, and returns
41
+ * the exports of a module with only named exports as the object `{ __esModule: true, ... }`.
42
+ *
43
+ * When `exportKey` is set, only the matching export is returned.
44
+ * When `exportKey` is set on a function export that has no such function, the key is ignored with a debug log.
45
+ */
46
+ function resolveModuleExports(moduleExport, modulePath, exportKey) {
47
+ const moduleName = moduleNameOf(modulePath);
48
+ if (isGuardFn(moduleExport)) {
49
+ if (exportKey !== undefined) {
50
+ // A named export beside the default export, which the transpiler has collapsed onto it.
51
+ if (Object.hasOwn(moduleExport, exportKey)) {
52
+ const named = Reflect.get(moduleExport, exportKey);
53
+ if (isGuardFn(named)) return [{
54
+ name: exportKey,
55
+ fn: named
56
+ }];
57
+ }
58
+ Log.debug(`guardRouter.guards: "${modulePath}#${exportKey}" is a single function, ignoring export key`, undefined, LOG_COMPONENT);
59
+ }
60
+ return [{
61
+ name: exportKey ?? moduleName,
62
+ fn: moduleExport
63
+ }];
64
+ }
65
+ if (Array.isArray(moduleExport)) {
66
+ if (moduleExport.length === 0) {
67
+ guardWarning(modulePath, "exported an empty array, skipping");
68
+ return [];
69
+ }
70
+ if (exportKey !== undefined) {
71
+ const index = positionOf(exportKey);
72
+ if (Number.isNaN(index) || index >= moduleExport.length) {
73
+ guardWarning(modulePath, `#${exportKey} - index out of range, skipping`);
74
+ return [];
75
+ }
76
+ const entry = moduleExport[index];
77
+ if (!isGuardFn(entry)) {
78
+ guardWarning(modulePath, `#${exportKey} is not a function, skipping`);
79
+ return [];
80
+ }
81
+ return [{
82
+ name: `${moduleName}#${exportKey}`,
83
+ fn: entry
84
+ }];
85
+ }
86
+ const results = [];
87
+ for (let i = 0; i < moduleExport.length; i++) {
88
+ const entry = moduleExport[i];
89
+ if (!isGuardFn(entry)) {
90
+ guardWarning(modulePath, `[${i}] is not a function, skipping`);
91
+ continue;
92
+ }
93
+ results.push({
94
+ name: `${moduleName}#${i}`,
95
+ fn: entry
96
+ });
97
+ }
98
+ return results;
99
+ }
100
+ if (isRecord(moduleExport)) {
101
+ // The transpiler's object of a module with only named exports has `__esModule` as an enumerable first key.
102
+ const entries = Object.entries(moduleExport).filter(([key]) => key !== "__esModule");
103
+ if (entries.length === 0) {
104
+ guardWarning(modulePath, "exported an empty object, skipping");
105
+ return [];
106
+ }
107
+ if (exportKey !== undefined) {
108
+ // A key wins over a position. A position that is not a number or out of range finds no entry.
109
+ const entry = Object.hasOwn(moduleExport, exportKey) ? [exportKey, moduleExport[exportKey]] : entries[positionOf(exportKey)];
110
+ if (entry === undefined) {
111
+ guardWarning(modulePath, `#${exportKey} - key not found, skipping`);
112
+ return [];
113
+ }
114
+ const [name, value] = entry;
115
+ if (!isGuardFn(value)) {
116
+ guardWarning(modulePath, `#${exportKey} is not a function, skipping`);
117
+ return [];
118
+ }
119
+ return [{
120
+ name,
121
+ fn: value
122
+ }];
123
+ }
124
+ const results = [];
125
+ for (const [key, value] of entries) {
126
+ if (!isGuardFn(value)) {
127
+ guardWarning(modulePath, `.${key} is not a function, skipping`);
128
+ continue;
129
+ }
130
+ results.push({
131
+ name: key,
132
+ fn: value
133
+ });
134
+ }
135
+ return results;
136
+ }
137
+ guardWarning(modulePath, "did not export a function, array, or plain object, skipping");
138
+ return [];
139
+ }
140
+
141
+ /** Resolve a module's guards and name each one for log output. */
142
+ function resolveNamedGuards(moduleExport, modulePath, exportKey) {
143
+ return resolveModuleExports(moduleExport, modulePath, exportKey).map(({
144
+ name,
145
+ fn
146
+ }) => {
147
+ nameGuard(fn, name);
148
+ return fn;
149
+ });
150
+ }
151
+
152
+ /**
153
+ * Run guards in order, stopping at the first result that is not `true`.
154
+ * Stays synchronous until a guard returns a Promise, like the pipeline.
155
+ */
156
+ function runGuardsInOrder(guards, context) {
157
+ for (let i = 0; i < guards.length; i++) {
158
+ const result = guards[i](context);
159
+ if (isPromiseLike(result)) return finishGuardsAsync(result, guards.slice(i + 1), context);
160
+ if (result !== true) return result;
161
+ }
162
+ return true;
163
+ }
164
+
165
+ /** Await a pending guard result, then run the remaining guards unless the navigation was superseded. */
166
+ async function finishGuardsAsync(pending, remaining, context) {
167
+ const result = await pending;
168
+ if (result !== true) return result;
169
+ if (context.signal.aborted) return false;
170
+ return runGuardsInOrder(remaining, context);
171
+ }
172
+
173
+ /** Load a guard module asynchronously. Warns with `failure` and rejects when the load fails. */
174
+ function loadGuardModule(modulePath, failure) {
175
+ return new Promise((resolve, reject) => {
176
+ sap.ui.require([modulePath], resolve, err => {
177
+ Log.warning(`guardRouter.guards: ${failure}`, String(err), LOG_COMPONENT);
178
+ reject(err);
179
+ });
180
+ });
181
+ }
182
+
183
+ /**
184
+ * Load the modules of all descriptors (`guardLoading: "block"`) and resolve their guards.
185
+ *
186
+ * Each module is loaded in its own `sap.ui.require` call, so an invalid path
187
+ * only skips that descriptor (with a warning) instead of failing the batch.
188
+ * Results keep declaration order.
189
+ */
190
+ function loadGuardModules(descriptors) {
191
+ return Promise.all(descriptors.map(async descriptor => {
192
+ const {
193
+ modulePath,
194
+ exportKey
195
+ } = descriptor;
196
+ const guards = await loadGuardModule(modulePath, `failed to load module "${modulePath}", skipping`).then(moduleExport => resolveNamedGuards(moduleExport, modulePath, exportKey), () => []);
197
+ return {
198
+ descriptor,
199
+ guards
200
+ };
201
+ }));
202
+ }
203
+
204
+ /**
205
+ * Create the guards to register for one descriptor (`guardLoading: "lazy"`).
206
+ *
207
+ * - Cherry-pick (`module#export`): one wrapper that loads the module on first use
208
+ * and resolves the export once, so a missing export warns once.
209
+ * - Bare path, module already cached (preload finished): the module's guards themselves.
210
+ * - Bare path, cache miss: one wrapper that loads the module on first use and runs all
211
+ * of its guards in order. Registering them on first use would miss the current
212
+ * navigation, whose guard list the pipeline is already iterating. Later navigations
213
+ * run them synchronously.
214
+ *
215
+ * A wrapper is named after the module until it resolves to a single guard, then after that guard.
216
+ */
217
+ function createLazyGuards(descriptor) {
218
+ const {
219
+ modulePath,
220
+ exportKey
221
+ } = descriptor;
222
+ const moduleName = moduleNameOf(modulePath);
223
+ if (exportKey === undefined) {
224
+ const cached = sap.ui.require(modulePath);
225
+ if (cached !== undefined) return resolveNamedGuards(cached, modulePath);
226
+ }
227
+ let guards;
228
+ const run = (mod, context) => {
229
+ if (guards === undefined) {
230
+ const resolved = resolveModuleExports(mod, modulePath, exportKey);
231
+ if (resolved.length === 1) nameGuard(wrapper, resolved[0].name);
232
+ guards = resolved.map(guard => guard.fn);
233
+ }
234
+ return runGuardsInOrder(guards, context);
235
+ };
236
+ const wrapper = context => {
237
+ const mod = sap.ui.require(modulePath);
238
+ if (mod !== undefined) return run(mod, context);
239
+ return loadGuardModule(modulePath, `lazy load of "${modulePath}" failed`).then(loadedModule => context.signal.aborted ? false : run(loadedModule, context));
240
+ };
241
+ nameGuard(wrapper, exportKey === undefined ? moduleName : `${moduleName}#${exportKey}`);
242
+ return [wrapper];
243
+ }
244
+ var __exports = {
245
+ __esModule: true
246
+ };
247
+ __exports.resolveModuleExports = resolveModuleExports;
248
+ __exports.runGuardsInOrder = runGuardsInOrder;
249
+ __exports.loadGuardModules = loadGuardModules;
250
+ __exports.createLazyGuards = createLazyGuards;
251
+ return __exports;
252
+ });
253
+ //# sourceMappingURL=GuardModules-dbg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardModules-dbg.js","names":["isPromiseLike","___GuardPipeline","LOG_COMPONENT","nameGuard","isRecord","___GuardConfig","isGuardFn","value","guardWarning","modulePath","detail","Log","warning","undefined","moduleNameOf","slice","lastIndexOf","positionOf","exportKey","test","Number","NaN","resolveModuleExports","moduleExport","moduleName","Object","hasOwn","named","Reflect","get","name","fn","debug","Array","isArray","length","index","isNaN","entry","results","i","push","entries","filter","key","resolveNamedGuards","map","runGuardsInOrder","guards","context","result","finishGuardsAsync","pending","remaining","signal","aborted","loadGuardModule","failure","Promise","resolve","reject","sap","ui","require","err","String","loadGuardModules","descriptors","all","descriptor","then","createLazyGuards","cached","run","mod","resolved","wrapper","guard","loadedModule","__exports","__esModule"],"sourceRoot":"./","sources":["GuardModules.ts"],"sourcesContent":["/**\n * Guard modules: detect a loaded module's export shape, load modules for\n * manifest guards (blocking or lazy), and run a module's guards in order.\n */\nimport Log from \"sap/base/Log\";\nimport type { GuardContext, GuardFn, GuardResult } from \"./types\";\nimport { isPromiseLike, LOG_COMPONENT, nameGuard } from \"./GuardPipeline\";\nimport { type GuardDescriptor, isRecord } from \"./GuardConfig\";\n\n/** A guard function from a module, with the name its log messages show. */\ninterface NamedGuard {\n\treadonly name: string;\n\treadonly fn: GuardFn;\n}\n\n/** A guard as a module exports it: any function. Its result is checked when it runs. */\nfunction isGuardFn(value: unknown): value is GuardFn {\n\treturn typeof value === \"function\";\n}\n\n/** Log a warning about a guard module entry in the manifest. */\nfunction guardWarning(modulePath: string, detail: string): void {\n\tLog.warning(`guardRouter.guards: \"${modulePath}\" ${detail}`, undefined, LOG_COMPONENT);\n}\n\n/** The last segment of a module path, by which the guards of the module are named. */\nfunction moduleNameOf(modulePath: string): string {\n\treturn modulePath.slice(modulePath.lastIndexOf(\"/\") + 1);\n}\n\n/** The position an export key selects: a plain non-negative integer, otherwise `NaN`. */\nfunction positionOf(exportKey: string): number {\n\treturn /^\\d+$/.test(exportKey) ? Number(exportKey) : NaN;\n}\n\n/**\n * Detect the export shape of a loaded guard module and extract guard functions.\n *\n * Shapes and the names they get (`moduleName` is the last path segment):\n * - function → single guard, named `moduleName` (or the export key when one is given);\n * an export key that names a function among its own properties picks that one\n * - Array → ordered guards, named `moduleName#index` (non-functions warned and skipped)\n * - plain object → guards in key order, named by key (non-functions warned and skipped)\n *\n * The module is read as the value it returns to the UI5 loader, which has no ES module\n * interop. The UI5 transpiler (babel-plugin-transform-modules-ui5) returns a default export\n * as that value, with named exports beside it collapsed onto it as properties, and returns\n * the exports of a module with only named exports as the object `{ __esModule: true, ... }`.\n *\n * When `exportKey` is set, only the matching export is returned.\n * When `exportKey` is set on a function export that has no such function, the key is ignored with a debug log.\n */\nexport function resolveModuleExports(moduleExport: unknown, modulePath: string, exportKey?: string): NamedGuard[] {\n\tconst moduleName = moduleNameOf(modulePath);\n\n\tif (isGuardFn(moduleExport)) {\n\t\tif (exportKey !== undefined) {\n\t\t\t// A named export beside the default export, which the transpiler has collapsed onto it.\n\t\t\tif (Object.hasOwn(moduleExport, exportKey)) {\n\t\t\t\tconst named: unknown = Reflect.get(moduleExport, exportKey);\n\t\t\t\tif (isGuardFn(named)) return [{ name: exportKey, fn: named }];\n\t\t\t}\n\t\t\tLog.debug(\n\t\t\t\t`guardRouter.guards: \"${modulePath}#${exportKey}\" is a single function, ignoring export key`,\n\t\t\t\tundefined,\n\t\t\t\tLOG_COMPONENT,\n\t\t\t);\n\t\t}\n\t\treturn [{ name: exportKey ?? moduleName, fn: moduleExport }];\n\t}\n\n\tif (Array.isArray(moduleExport)) {\n\t\tif (moduleExport.length === 0) {\n\t\t\tguardWarning(modulePath, \"exported an empty array, skipping\");\n\t\t\treturn [];\n\t\t}\n\n\t\tif (exportKey !== undefined) {\n\t\t\tconst index = positionOf(exportKey);\n\t\t\tif (Number.isNaN(index) || index >= moduleExport.length) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} - index out of range, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst entry: unknown = moduleExport[index];\n\t\t\tif (!isGuardFn(entry)) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} is not a function, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn [{ name: `${moduleName}#${exportKey}`, fn: entry }];\n\t\t}\n\n\t\tconst results: NamedGuard[] = [];\n\t\tfor (let i = 0; i < moduleExport.length; i++) {\n\t\t\tconst entry: unknown = moduleExport[i];\n\t\t\tif (!isGuardFn(entry)) {\n\t\t\t\tguardWarning(modulePath, `[${i}] is not a function, skipping`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresults.push({ name: `${moduleName}#${i}`, fn: entry });\n\t\t}\n\t\treturn results;\n\t}\n\n\tif (isRecord(moduleExport)) {\n\t\t// The transpiler's object of a module with only named exports has `__esModule` as an enumerable first key.\n\t\tconst entries = Object.entries(moduleExport).filter(([key]) => key !== \"__esModule\");\n\t\tif (entries.length === 0) {\n\t\t\tguardWarning(modulePath, \"exported an empty object, skipping\");\n\t\t\treturn [];\n\t\t}\n\n\t\tif (exportKey !== undefined) {\n\t\t\t// A key wins over a position. A position that is not a number or out of range finds no entry.\n\t\t\tconst entry: [string, unknown] | undefined = Object.hasOwn(moduleExport, exportKey)\n\t\t\t\t? [exportKey, moduleExport[exportKey]]\n\t\t\t\t: entries[positionOf(exportKey)];\n\t\t\tif (entry === undefined) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} - key not found, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst [name, value] = entry;\n\t\t\tif (!isGuardFn(value)) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} is not a function, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn [{ name, fn: value }];\n\t\t}\n\n\t\tconst results: NamedGuard[] = [];\n\t\tfor (const [key, value] of entries) {\n\t\t\tif (!isGuardFn(value)) {\n\t\t\t\tguardWarning(modulePath, `.${key} is not a function, skipping`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresults.push({ name: key, fn: value });\n\t\t}\n\t\treturn results;\n\t}\n\n\tguardWarning(modulePath, \"did not export a function, array, or plain object, skipping\");\n\treturn [];\n}\n\n/** Resolve a module's guards and name each one for log output. */\nfunction resolveNamedGuards(moduleExport: unknown, modulePath: string, exportKey?: string): GuardFn[] {\n\treturn resolveModuleExports(moduleExport, modulePath, exportKey).map(({ name, fn }) => {\n\t\tnameGuard(fn, name);\n\t\treturn fn;\n\t});\n}\n\n/**\n * Run guards in order, stopping at the first result that is not `true`.\n * Stays synchronous until a guard returns a Promise, like the pipeline.\n */\nexport function runGuardsInOrder(guards: GuardFn[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\tfor (let i = 0; i < guards.length; i++) {\n\t\tconst result = guards[i](context);\n\t\tif (isPromiseLike(result)) return finishGuardsAsync(result, guards.slice(i + 1), context);\n\t\tif (result !== true) return result;\n\t}\n\treturn true;\n}\n\n/** Await a pending guard result, then run the remaining guards unless the navigation was superseded. */\nasync function finishGuardsAsync(\n\tpending: PromiseLike<GuardResult>,\n\tremaining: GuardFn[],\n\tcontext: GuardContext,\n): Promise<GuardResult> {\n\tconst result = await pending;\n\tif (result !== true) return result;\n\tif (context.signal.aborted) return false;\n\treturn runGuardsInOrder(remaining, context);\n}\n\n/** Load a guard module asynchronously. Warns with `failure` and rejects when the load fails. */\nfunction loadGuardModule(modulePath: string, failure: string): Promise<unknown> {\n\treturn new Promise((resolve, reject) => {\n\t\tsap.ui.require([modulePath], resolve, (err: Error) => {\n\t\t\tLog.warning(`guardRouter.guards: ${failure}`, String(err), LOG_COMPONENT);\n\t\t\treject(err);\n\t\t});\n\t});\n}\n\n/**\n * Load the modules of all descriptors (`guardLoading: \"block\"`) and resolve their guards.\n *\n * Each module is loaded in its own `sap.ui.require` call, so an invalid path\n * only skips that descriptor (with a warning) instead of failing the batch.\n * Results keep declaration order.\n */\nexport function loadGuardModules<T extends GuardDescriptor>(\n\tdescriptors: T[],\n): Promise<{ descriptor: T; guards: GuardFn[] }[]> {\n\treturn Promise.all(\n\t\tdescriptors.map(async (descriptor) => {\n\t\t\tconst { modulePath, exportKey } = descriptor;\n\t\t\tconst guards = await loadGuardModule(modulePath, `failed to load module \"${modulePath}\", skipping`).then(\n\t\t\t\t(moduleExport) => resolveNamedGuards(moduleExport, modulePath, exportKey),\n\t\t\t\t() => [],\n\t\t\t);\n\t\t\treturn { descriptor, guards };\n\t\t}),\n\t);\n}\n\n/**\n * Create the guards to register for one descriptor (`guardLoading: \"lazy\"`).\n *\n * - Cherry-pick (`module#export`): one wrapper that loads the module on first use\n * and resolves the export once, so a missing export warns once.\n * - Bare path, module already cached (preload finished): the module's guards themselves.\n * - Bare path, cache miss: one wrapper that loads the module on first use and runs all\n * of its guards in order. Registering them on first use would miss the current\n * navigation, whose guard list the pipeline is already iterating. Later navigations\n * run them synchronously.\n *\n * A wrapper is named after the module until it resolves to a single guard, then after that guard.\n */\nexport function createLazyGuards(descriptor: GuardDescriptor): GuardFn[] {\n\tconst { modulePath, exportKey } = descriptor;\n\tconst moduleName = moduleNameOf(modulePath);\n\n\tif (exportKey === undefined) {\n\t\tconst cached: unknown = sap.ui.require(modulePath);\n\t\tif (cached !== undefined) return resolveNamedGuards(cached, modulePath);\n\t}\n\n\tlet guards: GuardFn[] | undefined;\n\tconst run = (mod: unknown, context: GuardContext): GuardResult | Promise<GuardResult> => {\n\t\tif (guards === undefined) {\n\t\t\tconst resolved = resolveModuleExports(mod, modulePath, exportKey);\n\t\t\tif (resolved.length === 1) nameGuard(wrapper, resolved[0].name);\n\t\t\tguards = resolved.map((guard) => guard.fn);\n\t\t}\n\t\treturn runGuardsInOrder(guards, context);\n\t};\n\tconst wrapper = (context: GuardContext): GuardResult | PromiseLike<GuardResult> => {\n\t\tconst mod: unknown = sap.ui.require(modulePath);\n\t\tif (mod !== undefined) return run(mod, context);\n\t\treturn loadGuardModule(modulePath, `lazy load of \"${modulePath}\" failed`).then((loadedModule) =>\n\t\t\tcontext.signal.aborted ? false : run(loadedModule, context),\n\t\t);\n\t};\n\tnameGuard(wrapper, exportKey === undefined ? moduleName : `${moduleName}#${exportKey}`);\n\treturn [wrapper];\n}\n"],"mappings":";;;QAMSA,aAAa,GAAAC,gBAAA;EAAA,MAAEC,aAAa,GAAAD,gBAAA;EAAA,MAAEE,SAAS,GAAAF,gBAAA;EAAA,MACjBG,QAAQ,GAAAC,cAAA;EAEvC;EAMA;EACA,SAASC,SAASA,CAACC,KAAc,EAAoB;IACpD,OAAO,OAAOA,KAAK,KAAK,UAAU;EACnC;;EAEA;EACA,SAASC,YA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,gBAAA,GAAAA,gBAAA;EAAAa,SAAA,CAAAR,gBAAA,GAAAA,gBAAA;EAAA,OAAAQ,SAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ declare module "ui5/guard/router/GuardModules" {
2
+ import type { GuardContext, GuardFn, GuardResult } from "ui5/guard/router/types";
3
+ import { type GuardDescriptor } from "ui5/guard/router/GuardConfig";
4
+ /** A guard function from a module, with the name its log messages show. */
5
+ interface NamedGuard {
6
+ readonly name: string;
7
+ readonly fn: GuardFn;
8
+ }
9
+ /** A guard as a module exports it: any function. Its result is checked when it runs. */
10
+ function isGuardFn(value: unknown): value is GuardFn;
11
+ /** Log a warning about a guard module entry in the manifest. */
12
+ function guardWarning(modulePath: string, detail: string): void;
13
+ /** The last segment of a module path, by which the guards of the module are named. */
14
+ function moduleNameOf(modulePath: string): string;
15
+ /** The position an export key selects: a plain non-negative integer, otherwise `NaN`. */
16
+ function positionOf(exportKey: string): number;
17
+ /**
18
+ * Detect the export shape of a loaded guard module and extract guard functions.
19
+ *
20
+ * Shapes and the names they get (`moduleName` is the last path segment):
21
+ * - function → single guard, named `moduleName` (or the export key when one is given);
22
+ * an export key that names a function among its own properties picks that one
23
+ * - Array → ordered guards, named `moduleName#index` (non-functions warned and skipped)
24
+ * - plain object → guards in key order, named by key (non-functions warned and skipped)
25
+ *
26
+ * The module is read as the value it returns to the UI5 loader, which has no ES module
27
+ * interop. The UI5 transpiler (babel-plugin-transform-modules-ui5) returns a default export
28
+ * as that value, with named exports beside it collapsed onto it as properties, and returns
29
+ * the exports of a module with only named exports as the object `{ __esModule: true, ... }`.
30
+ *
31
+ * When `exportKey` is set, only the matching export is returned.
32
+ * When `exportKey` is set on a function export that has no such function, the key is ignored with a debug log.
33
+ */
34
+ export function resolveModuleExports(moduleExport: unknown, modulePath: string, exportKey?: string): NamedGuard[];
35
+ /** Resolve a module's guards and name each one for log output. */
36
+ function resolveNamedGuards(moduleExport: unknown, modulePath: string, exportKey?: string): GuardFn[];
37
+ /**
38
+ * Run guards in order, stopping at the first result that is not `true`.
39
+ * Stays synchronous until a guard returns a Promise, like the pipeline.
40
+ */
41
+ export function runGuardsInOrder(guards: GuardFn[], context: GuardContext): GuardResult | Promise<GuardResult>;
42
+ /** Await a pending guard result, then run the remaining guards unless the navigation was superseded. */
43
+ function finishGuardsAsync(pending: PromiseLike<GuardResult>, remaining: GuardFn[], context: GuardContext): Promise<GuardResult>;
44
+ /** Load a guard module asynchronously. Warns with `failure` and rejects when the load fails. */
45
+ function loadGuardModule(modulePath: string, failure: string): Promise<unknown>;
46
+ /**
47
+ * Load the modules of all descriptors (`guardLoading: "block"`) and resolve their guards.
48
+ *
49
+ * Each module is loaded in its own `sap.ui.require` call, so an invalid path
50
+ * only skips that descriptor (with a warning) instead of failing the batch.
51
+ * Results keep declaration order.
52
+ */
53
+ export function loadGuardModules<T extends GuardDescriptor>(descriptors: T[]): Promise<{
54
+ descriptor: T;
55
+ guards: GuardFn[];
56
+ }[]>;
57
+ /**
58
+ * Create the guards to register for one descriptor (`guardLoading: "lazy"`).
59
+ *
60
+ * - Cherry-pick (`module#export`): one wrapper that loads the module on first use
61
+ * and resolves the export once, so a missing export warns once.
62
+ * - Bare path, module already cached (preload finished): the module's guards themselves.
63
+ * - Bare path, cache miss: one wrapper that loads the module on first use and runs all
64
+ * of its guards in order. Registering them on first use would miss the current
65
+ * navigation, whose guard list the pipeline is already iterating. Later navigations
66
+ * run them synchronously.
67
+ *
68
+ * A wrapper is named after the module until it resolves to a single guard, then after that guard.
69
+ */
70
+ export function createLazyGuards(descriptor: GuardDescriptor): GuardFn[];
71
+ }
72
+ //# sourceMappingURL=GuardModules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardModules.d.ts","sourceRoot":"../../../../..","sources":["src/GuardModules.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,+BAA+B,CAAC;IAM/C,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAA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OAAO,CAAC,CAO9E;IAED;;;;;;OAMG;IACH,SAAgB,gBAAgB,CAAC,CAAC,SAAS,eAAe,EACzD,WAAW,EAAE,CAAC,EAAE,GACd,OAAO,CAAC;QAAE,UAAU,EAAE,CAAC,CAAC;QAAC,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,EAAE,CAAC,CAWjD;IAED;;;;;;;;;;;;OAYG;IACH,SAAgB,gBAAgB,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,EAAE,CA2BvE;CAEA"}
@@ -0,0 +1,2 @@
1
+ sap.ui.define(["sap/base/Log","./GuardPipeline","./GuardConfig"],function(n,e,t){"use strict";const r=e["isPromiseLike"];const i=e["LOG_COMPONENT"];const u=e["nameGuard"];const o=t["isRecord"];function s(n){return typeof n==="function"}function f(e,t){n.warning(`guardRouter.guards: "${e}" ${t}`,undefined,i)}function a(n){return n.slice(n.lastIndexOf("/")+1)}function d(n){return/^\d+$/.test(n)?Number(n):NaN}function c(e,t,r){const u=a(t);if(s(e)){if(r!==undefined){if(Object.hasOwn(e,r)){const n=Reflect.get(e,r);if(s(n))return[{name:r,fn:n}]}n.debug(`guardRouter.guards: "${t}#${r}" is a single function, ignoring export key`,undefined,i)}return[{name:r??u,fn:e}]}if(Array.isArray(e)){if(e.length===0){f(t,"exported an empty array, skipping");return[]}if(r!==undefined){const n=d(r);if(Number.isNaN(n)||n>=e.length){f(t,`#${r} - index out of range, skipping`);return[]}const i=e[n];if(!s(i)){f(t,`#${r} is not a function, skipping`);return[]}return[{name:`${u}#${r}`,fn:i}]}const n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!s(i)){f(t,`[${r}] is not a function, skipping`);continue}n.push({name:`${u}#${r}`,fn:i})}return n}if(o(e)){const n=Object.entries(e).filter(([n])=>n!=="__esModule");if(n.length===0){f(t,"exported an empty object, skipping");return[]}if(r!==undefined){const i=Object.hasOwn(e,r)?[r,e[r]]:n[d(r)];if(i===undefined){f(t,`#${r} - key not found, skipping`);return[]}const[u,o]=i;if(!s(o)){f(t,`#${r} is not a function, skipping`);return[]}return[{name:u,fn:o}]}const i=[];for(const[e,r]of n){if(!s(r)){f(t,`.${e} is not a function, skipping`);continue}i.push({name:e,fn:r})}return i}f(t,"did not export a function, array, or plain object, skipping");return[]}function p(n,e,t){return c(n,e,t).map(({name:n,fn:e})=>{u(e,n);return e})}function l(n,e){for(let t=0;t<n.length;t++){const i=n[t](e);if(r(i))return g(i,n.slice(t+1),e);if(i!==true)return i}return true}async function g(n,e,t){const r=await n;if(r!==true)return r;if(t.signal.aborted)return false;return l(e,t)}function m(e,t){return new Promise((r,u)=>{sap.ui.require([e],r,e=>{n.warning(`guardRouter.guards: ${t}`,String(e),i);u(e)})})}function $(n){return Promise.all(n.map(async n=>{const{modulePath:e,exportKey:t}=n;const r=await m(e,`failed to load module "${e}", skipping`).then(n=>p(n,e,t),()=>[]);return{descriptor:n,guards:r}}))}function y(n){const{modulePath:e,exportKey:t}=n;const r=a(e);if(t===undefined){const n=sap.ui.require(e);if(n!==undefined)return p(n,e)}let i;const o=(n,r)=>{if(i===undefined){const r=c(n,e,t);if(r.length===1)u(s,r[0].name);i=r.map(n=>n.fn)}return l(i,r)};const s=n=>{const t=sap.ui.require(e);if(t!==undefined)return o(t,n);return m(e,`lazy load of "${e}" failed`).then(e=>n.signal.aborted?false:o(e,n))};u(s,t===undefined?r:`${r}#${t}`);return[s]}var h={__esModule:true};h.resolveModuleExports=c;h.runGuardsInOrder=l;h.loadGuardModules=$;h.createLazyGuards=y;return h});
2
+ //# sourceMappingURL=GuardModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardModules.js","names":["isPromiseLike","___GuardPipeline","LOG_COMPONENT","nameGuard","isRecord","___GuardConfig","isGuardFn","value","guardWarning","modulePath","detail","Log","warning","undefined","moduleNameOf","slice","lastIndexOf","positionOf","exportKey","test","Number","NaN","resolveModuleExports","moduleExport","moduleName","Object","hasOwn","named","Reflect","get","name","fn","debug","Array","isArray","length","index","isNaN","entry","results","i","push","entries","filter","key","resolveNamedGuards","map","runGuardsInOrder","guards","context","result","finishGuardsAsync","async","pending","remaining","signal","aborted","loadGuardModule","failure","Promise","resolve","reject","sap","ui","require","err","String","loadGuardModules","descriptors","all","descriptor","then","createLazyGuards","cached","run","mod","resolved","wrapper","guard","loadedModule","__exports","__esModule"],"sources":["./GuardModules.ts"],"sourcesContent":["/**\n * Guard modules: detect a loaded module's export shape, load modules for\n * manifest guards (blocking or lazy), and run a module's guards in order.\n */\nimport Log from \"sap/base/Log\";\nimport type { GuardContext, GuardFn, GuardResult } from \"./types\";\nimport { isPromiseLike, LOG_COMPONENT, nameGuard } from \"./GuardPipeline\";\nimport { type GuardDescriptor, isRecord } from \"./GuardConfig\";\n\n/** A guard function from a module, with the name its log messages show. */\ninterface NamedGuard {\n\treadonly name: string;\n\treadonly fn: GuardFn;\n}\n\n/** A guard as a module exports it: any function. Its result is checked when it runs. */\nfunction isGuardFn(value: unknown): value is GuardFn {\n\treturn typeof value === \"function\";\n}\n\n/** Log a warning about a guard module entry in the manifest. */\nfunction guardWarning(modulePath: string, detail: string): void {\n\tLog.warning(`guardRouter.guards: \"${modulePath}\" ${detail}`, undefined, LOG_COMPONENT);\n}\n\n/** The last segment of a module path, by which the guards of the module are named. */\nfunction moduleNameOf(modulePath: string): string {\n\treturn modulePath.slice(modulePath.lastIndexOf(\"/\") + 1);\n}\n\n/** The position an export key selects: a plain non-negative integer, otherwise `NaN`. */\nfunction positionOf(exportKey: string): number {\n\treturn /^\\d+$/.test(exportKey) ? Number(exportKey) : NaN;\n}\n\n/**\n * Detect the export shape of a loaded guard module and extract guard functions.\n *\n * Shapes and the names they get (`moduleName` is the last path segment):\n * - function → single guard, named `moduleName` (or the export key when one is given);\n * an export key that names a function among its own properties picks that one\n * - Array → ordered guards, named `moduleName#index` (non-functions warned and skipped)\n * - plain object → guards in key order, named by key (non-functions warned and skipped)\n *\n * The module is read as the value it returns to the UI5 loader, which has no ES module\n * interop. The UI5 transpiler (babel-plugin-transform-modules-ui5) returns a default export\n * as that value, with named exports beside it collapsed onto it as properties, and returns\n * the exports of a module with only named exports as the object `{ __esModule: true, ... }`.\n *\n * When `exportKey` is set, only the matching export is returned.\n * When `exportKey` is set on a function export that has no such function, the key is ignored with a debug log.\n */\nexport function resolveModuleExports(moduleExport: unknown, modulePath: string, exportKey?: string): NamedGuard[] {\n\tconst moduleName = moduleNameOf(modulePath);\n\n\tif (isGuardFn(moduleExport)) {\n\t\tif (exportKey !== undefined) {\n\t\t\t// A named export beside the default export, which the transpiler has collapsed onto it.\n\t\t\tif (Object.hasOwn(moduleExport, exportKey)) {\n\t\t\t\tconst named: unknown = Reflect.get(moduleExport, exportKey);\n\t\t\t\tif (isGuardFn(named)) return [{ name: exportKey, fn: named }];\n\t\t\t}\n\t\t\tLog.debug(\n\t\t\t\t`guardRouter.guards: \"${modulePath}#${exportKey}\" is a single function, ignoring export key`,\n\t\t\t\tundefined,\n\t\t\t\tLOG_COMPONENT,\n\t\t\t);\n\t\t}\n\t\treturn [{ name: exportKey ?? moduleName, fn: moduleExport }];\n\t}\n\n\tif (Array.isArray(moduleExport)) {\n\t\tif (moduleExport.length === 0) {\n\t\t\tguardWarning(modulePath, \"exported an empty array, skipping\");\n\t\t\treturn [];\n\t\t}\n\n\t\tif (exportKey !== undefined) {\n\t\t\tconst index = positionOf(exportKey);\n\t\t\tif (Number.isNaN(index) || index >= moduleExport.length) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} - index out of range, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst entry: unknown = moduleExport[index];\n\t\t\tif (!isGuardFn(entry)) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} is not a function, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn [{ name: `${moduleName}#${exportKey}`, fn: entry }];\n\t\t}\n\n\t\tconst results: NamedGuard[] = [];\n\t\tfor (let i = 0; i < moduleExport.length; i++) {\n\t\t\tconst entry: unknown = moduleExport[i];\n\t\t\tif (!isGuardFn(entry)) {\n\t\t\t\tguardWarning(modulePath, `[${i}] is not a function, skipping`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresults.push({ name: `${moduleName}#${i}`, fn: entry });\n\t\t}\n\t\treturn results;\n\t}\n\n\tif (isRecord(moduleExport)) {\n\t\t// The transpiler's object of a module with only named exports has `__esModule` as an enumerable first key.\n\t\tconst entries = Object.entries(moduleExport).filter(([key]) => key !== \"__esModule\");\n\t\tif (entries.length === 0) {\n\t\t\tguardWarning(modulePath, \"exported an empty object, skipping\");\n\t\t\treturn [];\n\t\t}\n\n\t\tif (exportKey !== undefined) {\n\t\t\t// A key wins over a position. A position that is not a number or out of range finds no entry.\n\t\t\tconst entry: [string, unknown] | undefined = Object.hasOwn(moduleExport, exportKey)\n\t\t\t\t? [exportKey, moduleExport[exportKey]]\n\t\t\t\t: entries[positionOf(exportKey)];\n\t\t\tif (entry === undefined) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} - key not found, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst [name, value] = entry;\n\t\t\tif (!isGuardFn(value)) {\n\t\t\t\tguardWarning(modulePath, `#${exportKey} is not a function, skipping`);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn [{ name, fn: value }];\n\t\t}\n\n\t\tconst results: NamedGuard[] = [];\n\t\tfor (const [key, value] of entries) {\n\t\t\tif (!isGuardFn(value)) {\n\t\t\t\tguardWarning(modulePath, `.${key} is not a function, skipping`);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresults.push({ name: key, fn: value });\n\t\t}\n\t\treturn results;\n\t}\n\n\tguardWarning(modulePath, \"did not export a function, array, or plain object, skipping\");\n\treturn [];\n}\n\n/** Resolve a module's guards and name each one for log output. */\nfunction resolveNamedGuards(moduleExport: unknown, modulePath: string, exportKey?: string): GuardFn[] {\n\treturn resolveModuleExports(moduleExport, modulePath, exportKey).map(({ name, fn }) => {\n\t\tnameGuard(fn, name);\n\t\treturn fn;\n\t});\n}\n\n/**\n * Run guards in order, stopping at the first result that is not `true`.\n * Stays synchronous until a guard returns a Promise, like the pipeline.\n */\nexport function runGuardsInOrder(guards: GuardFn[], context: GuardContext): GuardResult | Promise<GuardResult> {\n\tfor (let i = 0; i < guards.length; i++) {\n\t\tconst result = guards[i](context);\n\t\tif (isPromiseLike(result)) return finishGuardsAsync(result, guards.slice(i + 1), context);\n\t\tif (result !== true) return result;\n\t}\n\treturn true;\n}\n\n/** Await a pending guard result, then run the remaining guards unless the navigation was superseded. */\nasync function finishGuardsAsync(\n\tpending: PromiseLike<GuardResult>,\n\tremaining: GuardFn[],\n\tcontext: GuardContext,\n): Promise<GuardResult> {\n\tconst result = await pending;\n\tif (result !== true) return result;\n\tif (context.signal.aborted) return false;\n\treturn runGuardsInOrder(remaining, context);\n}\n\n/** Load a guard module asynchronously. Warns with `failure` and rejects when the load fails. */\nfunction loadGuardModule(modulePath: string, failure: string): Promise<unknown> {\n\treturn new Promise((resolve, reject) => {\n\t\tsap.ui.require([modulePath], resolve, (err: Error) => {\n\t\t\tLog.warning(`guardRouter.guards: ${failure}`, String(err), LOG_COMPONENT);\n\t\t\treject(err);\n\t\t});\n\t});\n}\n\n/**\n * Load the modules of all descriptors (`guardLoading: \"block\"`) and resolve their guards.\n *\n * Each module is loaded in its own `sap.ui.require` call, so an invalid path\n * only skips that descriptor (with a warning) instead of failing the batch.\n * Results keep declaration order.\n */\nexport function loadGuardModules<T extends GuardDescriptor>(\n\tdescriptors: T[],\n): Promise<{ descriptor: T; guards: GuardFn[] }[]> {\n\treturn Promise.all(\n\t\tdescriptors.map(async (descriptor) => {\n\t\t\tconst { modulePath, exportKey } = descriptor;\n\t\t\tconst guards = await loadGuardModule(modulePath, `failed to load module \"${modulePath}\", skipping`).then(\n\t\t\t\t(moduleExport) => resolveNamedGuards(moduleExport, modulePath, exportKey),\n\t\t\t\t() => [],\n\t\t\t);\n\t\t\treturn { descriptor, guards };\n\t\t}),\n\t);\n}\n\n/**\n * Create the guards to register for one descriptor (`guardLoading: \"lazy\"`).\n *\n * - Cherry-pick (`module#export`): one wrapper that loads the module on first use\n * and resolves the export once, so a missing export warns once.\n * - Bare path, module already cached (preload finished): the module's guards themselves.\n * - Bare path, cache miss: one wrapper that loads the module on first use and runs all\n * of its guards in order. Registering them on first use would miss the current\n * navigation, whose guard list the pipeline is already iterating. Later navigations\n * run them synchronously.\n *\n * A wrapper is named after the module until it resolves to a single guard, then after that guard.\n */\nexport function createLazyGuards(descriptor: GuardDescriptor): GuardFn[] {\n\tconst { modulePath, exportKey } = descriptor;\n\tconst moduleName = moduleNameOf(modulePath);\n\n\tif (exportKey === undefined) {\n\t\tconst cached: unknown = sap.ui.require(modulePath);\n\t\tif (cached !== undefined) return resolveNamedGuards(cached, modulePath);\n\t}\n\n\tlet guards: GuardFn[] | undefined;\n\tconst run = (mod: unknown, context: GuardContext): GuardResult | Promise<GuardResult> => {\n\t\tif (guards === undefined) {\n\t\t\tconst resolved = resolveModuleExports(mod, modulePath, exportKey);\n\t\t\tif (resolved.length === 1) nameGuard(wrapper, resolved[0].name);\n\t\t\tguards = resolved.map((guard) => guard.fn);\n\t\t}\n\t\treturn runGuardsInOrder(guards, context);\n\t};\n\tconst wrapper = (context: GuardContext): GuardResult | PromiseLike<GuardResult> => {\n\t\tconst mod: unknown = sap.ui.require(modulePath);\n\t\tif (mod !== undefined) return run(mod, context);\n\t\treturn loadGuardModule(modulePath, `lazy load of \"${modulePath}\" failed`).then((loadedModule) =>\n\t\t\tcontext.signal.aborted ? false : run(loadedModule, context),\n\t\t);\n\t};\n\tnameGuard(wrapper, exportKey === undefined ? moduleName : `${moduleName}#${exportKey}`);\n\treturn [wrapper];\n}\n"],"mappings":"oGAMSA,EAAaC,EAAA,uBAAEC,EAAaD,EAAA,uBAAEE,EAASF,EAAA,mBACjBG,EAAQC,EAAA,YASvC,SAASC,EAAUC,GAClB,cAAcA,IAAU,UACzB,CAGA,SAASC,EA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