@analogjs/router 3.0.0-alpha.5 → 3.0.0-alpha.51

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 (75) hide show
  1. package/content/package.json +4 -0
  2. package/fesm2022/analogjs-router-content.mjs +63 -0
  3. package/fesm2022/analogjs-router-content.mjs.map +1 -0
  4. package/fesm2022/analogjs-router-i18n.mjs +156 -0
  5. package/fesm2022/analogjs-router-i18n.mjs.map +1 -0
  6. package/fesm2022/analogjs-router-server-actions.mjs +309 -1
  7. package/fesm2022/analogjs-router-server-actions.mjs.map +1 -0
  8. package/fesm2022/analogjs-router-server.mjs +60 -3
  9. package/fesm2022/analogjs-router-server.mjs.map +1 -0
  10. package/fesm2022/analogjs-router-tanstack-query-server.mjs +22 -0
  11. package/fesm2022/analogjs-router-tanstack-query-server.mjs.map +1 -0
  12. package/fesm2022/analogjs-router-tanstack-query.mjs +39 -0
  13. package/fesm2022/analogjs-router-tanstack-query.mjs.map +1 -0
  14. package/fesm2022/analogjs-router-tokens.mjs +7 -2
  15. package/fesm2022/analogjs-router-tokens.mjs.map +1 -0
  16. package/fesm2022/analogjs-router.mjs +559 -61
  17. package/fesm2022/analogjs-router.mjs.map +1 -0
  18. package/fesm2022/debug.page.mjs +53 -31
  19. package/fesm2022/debug.page.mjs.map +1 -0
  20. package/fesm2022/provide-analog-query.mjs +23 -0
  21. package/fesm2022/provide-analog-query.mjs.map +1 -0
  22. package/fesm2022/route-files.mjs +361 -0
  23. package/fesm2022/route-files.mjs.map +1 -0
  24. package/fesm2022/routes.mjs +5 -278
  25. package/fesm2022/routes.mjs.map +1 -0
  26. package/i18n/package.json +4 -0
  27. package/package.json +76 -25
  28. package/tanstack-query/package.json +4 -0
  29. package/tanstack-query/server/package.json +4 -0
  30. package/types/content/src/index.d.ts +4 -0
  31. package/types/content/src/lib/debug/routes.d.ts +10 -0
  32. package/types/{src → content/src}/lib/markdown-helpers.d.ts +1 -1
  33. package/types/content/src/lib/routes.d.ts +8 -0
  34. package/types/content/src/lib/with-content-routes.d.ts +2 -0
  35. package/types/i18n/src/index.d.ts +1 -0
  36. package/types/i18n/src/provide-i18n.d.ts +92 -0
  37. package/types/server/actions/src/define-action.d.ts +54 -0
  38. package/types/server/actions/src/define-api-route.d.ts +57 -0
  39. package/types/server/actions/src/define-page-load.d.ts +55 -0
  40. package/types/server/actions/src/define-server-route.d.ts +68 -0
  41. package/types/server/actions/src/index.d.ts +9 -1
  42. package/types/server/actions/src/parse-request-data.d.ts +9 -0
  43. package/types/server/actions/src/validate.d.ts +8 -0
  44. package/types/server/src/provide-server-context.d.ts +15 -1
  45. package/types/server/src/render.d.ts +1 -1
  46. package/types/server/src/server-component-render.d.ts +1 -1
  47. package/types/src/index.d.ts +16 -5
  48. package/types/src/lib/cache-key.d.ts +1 -1
  49. package/types/src/lib/cookie-interceptor.d.ts +1 -1
  50. package/types/src/lib/debug/debug.page.d.ts +4 -2
  51. package/types/src/lib/define-route.d.ts +6 -1
  52. package/types/src/lib/endpoints.d.ts +1 -1
  53. package/types/src/lib/experimental.d.ts +140 -0
  54. package/types/src/lib/form-action.directive.d.ts +12 -5
  55. package/types/src/lib/inject-load.d.ts +5 -2
  56. package/types/src/lib/inject-navigate.d.ts +23 -0
  57. package/types/src/lib/inject-route-context.d.ts +32 -0
  58. package/types/src/lib/inject-typed-params.d.ts +63 -0
  59. package/types/src/lib/json-ld.d.ts +32 -0
  60. package/types/src/lib/meta-tags.d.ts +3 -1
  61. package/types/src/lib/models.d.ts +3 -0
  62. package/types/src/lib/provide-file-router-base.d.ts +4 -0
  63. package/types/src/lib/provide-file-router.d.ts +2 -8
  64. package/types/src/lib/route-builder.d.ts +5 -0
  65. package/types/src/lib/route-files.d.ts +18 -0
  66. package/types/src/lib/route-path.d.ts +124 -0
  67. package/types/src/lib/route-types.d.ts +2 -1
  68. package/types/src/lib/routes.d.ts +2 -10
  69. package/types/src/lib/validation-errors.d.ts +7 -0
  70. package/types/tanstack-query/server/src/index.d.ts +1 -0
  71. package/types/tanstack-query/src/index.d.ts +2 -0
  72. package/types/tanstack-query/src/provide-analog-query.d.ts +4 -0
  73. package/types/tanstack-query/src/provide-server-analog-query.d.ts +2 -0
  74. package/types/tanstack-query/src/server-query.d.ts +16 -0
  75. package/types/tokens/src/index.d.ts +2 -0
@@ -0,0 +1,361 @@
1
+ import { injectAPIPrefix, injectBaseURL, injectInternalServerFetch } from "./analogjs-router-tokens.mjs";
2
+ import { NavigationEnd, Router, UrlSegment } from "@angular/router";
3
+ import { DOCUMENT, InjectionToken, inject } from "@angular/core";
4
+ import { HttpClient } from "@angular/common/http";
5
+ import { firstValueFrom } from "rxjs";
6
+ import { filter } from "rxjs/operators";
7
+ import { Meta } from "@angular/platform-browser";
8
+ //#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
9
+ function isPlainObject(value) {
10
+ if (!value || typeof value !== "object") return false;
11
+ const proto = Object.getPrototypeOf(value);
12
+ if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
13
+ return Object.prototype.toString.call(value) === "[object Object]";
14
+ }
15
+ //#endregion
16
+ //#region packages/router/src/lib/json-ld.ts
17
+ function isJsonLdObject(value) {
18
+ return isPlainObject(value);
19
+ }
20
+ function normalizeJsonLd(value) {
21
+ if (Array.isArray(value)) return value.filter(isJsonLdObject);
22
+ return isJsonLdObject(value) ? [value] : [];
23
+ }
24
+ var ROUTE_JSON_LD_KEY = Symbol("@analogjs/router Route JSON-LD Key");
25
+ var JSON_LD_SCRIPT_SELECTOR = "script[data-analog-json-ld]";
26
+ function updateJsonLdOnRouteChange(router = inject(Router), document = inject(DOCUMENT, { optional: true })) {
27
+ if (!document) return;
28
+ router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(() => {
29
+ applyJsonLdToDocument(document, getJsonLdEntries(router.routerState.snapshot.root));
30
+ });
31
+ }
32
+ function serializeJsonLd(entry) {
33
+ try {
34
+ return JSON.stringify(entry).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+ function getJsonLdEntries(route) {
40
+ const entries = [];
41
+ let currentRoute = route;
42
+ while (currentRoute) {
43
+ entries.push(...normalizeJsonLd(currentRoute.data[ROUTE_JSON_LD_KEY]));
44
+ currentRoute = currentRoute.firstChild;
45
+ }
46
+ return entries;
47
+ }
48
+ function applyJsonLdToDocument(document, entries) {
49
+ document.querySelectorAll(JSON_LD_SCRIPT_SELECTOR).forEach((element) => {
50
+ element.remove();
51
+ });
52
+ if (entries.length === 0) return;
53
+ const head = document.head || document.getElementsByTagName("head")[0];
54
+ if (!head) return;
55
+ entries.forEach((entry, index) => {
56
+ const serialized = serializeJsonLd(entry);
57
+ if (!serialized) return;
58
+ const script = document.createElement("script");
59
+ script.type = "application/ld+json";
60
+ script.setAttribute("data-analog-json-ld", "true");
61
+ script.setAttribute("data-analog-json-ld-index", String(index));
62
+ script.textContent = serialized;
63
+ head.appendChild(script);
64
+ });
65
+ }
66
+ //#endregion
67
+ //#region packages/router/src/lib/meta-tags.ts
68
+ var ROUTE_META_TAGS_KEY = Symbol("@analogjs/router Route Meta Tags Key");
69
+ var CHARSET_KEY = "charset";
70
+ var HTTP_EQUIV_SELECTOR_KEY = "http-equiv";
71
+ var NAME_KEY = "name";
72
+ var PROPERTY_KEY = "property";
73
+ var ITEMPROP_KEY = "itemprop";
74
+ function updateMetaTagsOnRouteChange(router = inject(Router), metaService = inject(Meta)) {
75
+ router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(() => {
76
+ const metaTagMap = getMetaTagMap(router.routerState.snapshot.root);
77
+ for (const metaTagSelector in metaTagMap) {
78
+ const metaTag = metaTagMap[metaTagSelector];
79
+ metaService.updateTag(metaTag, metaTagSelector);
80
+ }
81
+ });
82
+ }
83
+ function getMetaTagMap(route) {
84
+ const metaTagMap = {};
85
+ let currentRoute = route;
86
+ while (currentRoute) {
87
+ const metaTags = currentRoute.data[ROUTE_META_TAGS_KEY] ?? [];
88
+ for (const metaTag of metaTags) metaTagMap[getMetaTagSelector(metaTag)] = metaTag;
89
+ currentRoute = currentRoute.firstChild;
90
+ }
91
+ return metaTagMap;
92
+ }
93
+ function getMetaTagSelector(metaTag) {
94
+ if (metaTag.name) return `${NAME_KEY}="${metaTag.name}"`;
95
+ if (metaTag.property) return `${PROPERTY_KEY}="${metaTag.property}"`;
96
+ if (metaTag.httpEquiv) return `${HTTP_EQUIV_SELECTOR_KEY}="${metaTag.httpEquiv}"`;
97
+ if (metaTag.itemprop) return `${ITEMPROP_KEY}="${metaTag.itemprop}"`;
98
+ return CHARSET_KEY;
99
+ }
100
+ //#endregion
101
+ //#region packages/router/src/lib/endpoints.ts
102
+ var ANALOG_META_KEY = Symbol("@analogjs/router Analog Route Metadata Key");
103
+ /**
104
+ * This variable reference is replaced with a glob of all route endpoints.
105
+ */
106
+ var ANALOG_PAGE_ENDPOINTS = {};
107
+ //#endregion
108
+ //#region packages/router/src/lib/inject-route-endpoint-url.ts
109
+ function injectRouteEndpointURL(route) {
110
+ const routeConfig = route.routeConfig;
111
+ const apiPrefix = injectAPIPrefix();
112
+ const baseUrl = injectBaseURL();
113
+ const { queryParams, fragment: hash, params, parent } = route;
114
+ const segment = parent?.url.map((segment) => segment.path).join("/") || "";
115
+ const url = new URL("", {
116
+ "BASE_URL": "/",
117
+ "DEV": false,
118
+ "MODE": "production",
119
+ "PROD": true,
120
+ "SSR": false
121
+ }["VITE_ANALOG_PUBLIC_BASE_URL"] || baseUrl || (typeof window !== "undefined" && window.location.origin ? window.location.origin : ""));
122
+ url.pathname = `${url.pathname.endsWith("/") ? url.pathname : url.pathname + "/"}${apiPrefix}/_analog${routeConfig[ANALOG_META_KEY].endpoint}`;
123
+ url.search = `${new URLSearchParams(queryParams).toString()}`;
124
+ url.hash = hash ?? "";
125
+ Object.keys(params).forEach((param) => {
126
+ url.pathname = url.pathname.replace(`[${param}]`, params[param]);
127
+ });
128
+ url.pathname = url.pathname.replace("**", segment);
129
+ return url;
130
+ }
131
+ //#endregion
132
+ //#region packages/router/src/lib/route-config.ts
133
+ function toRouteConfig(routeMeta) {
134
+ if (routeMeta && isRedirectRouteMeta$1(routeMeta)) return routeMeta;
135
+ const { meta, jsonLd, ...routeConfig } = routeMeta ?? {};
136
+ if (Array.isArray(meta)) routeConfig.data = {
137
+ ...routeConfig.data,
138
+ [ROUTE_META_TAGS_KEY]: meta
139
+ };
140
+ else if (typeof meta === "function") routeConfig.resolve = {
141
+ ...routeConfig.resolve,
142
+ [ROUTE_META_TAGS_KEY]: meta
143
+ };
144
+ if (Array.isArray(jsonLd) || isJsonLdObject(jsonLd)) routeConfig.data = {
145
+ ...routeConfig.data,
146
+ [ROUTE_JSON_LD_KEY]: jsonLd
147
+ };
148
+ else if (typeof jsonLd === "function") routeConfig.resolve = {
149
+ ...routeConfig.resolve,
150
+ [ROUTE_JSON_LD_KEY]: jsonLd
151
+ };
152
+ routeConfig.runGuardsAndResolvers = routeConfig.runGuardsAndResolvers ?? "paramsOrQueryParamsChange";
153
+ routeConfig.resolve = {
154
+ ...routeConfig.resolve,
155
+ load: async (route) => {
156
+ if (ANALOG_PAGE_ENDPOINTS[route.routeConfig[ANALOG_META_KEY]?.endpointKey]) {
157
+ const http = inject(HttpClient);
158
+ const url = injectRouteEndpointURL(route);
159
+ const internalFetch = injectInternalServerFetch();
160
+ if (internalFetch) return internalFetch(`${url.pathname}${url.search}`);
161
+ const globalFetch = globalThis.$fetch;
162
+ if (!!{
163
+ "BASE_URL": "/",
164
+ "DEV": false,
165
+ "MODE": "production",
166
+ "PROD": true,
167
+ "SSR": false
168
+ }["VITE_ANALOG_PUBLIC_BASE_URL"] && globalFetch) return globalFetch(`${url.pathname}${url.search}`);
169
+ return firstValueFrom(http.get(`${url.href}`));
170
+ }
171
+ return {};
172
+ }
173
+ };
174
+ return routeConfig;
175
+ }
176
+ function isRedirectRouteMeta$1(routeMeta) {
177
+ return !!routeMeta.redirectTo;
178
+ }
179
+ //#endregion
180
+ //#region packages/router/src/lib/constants.ts
181
+ var ENDPOINT_EXTENSION = ".server.ts";
182
+ //#endregion
183
+ //#region packages/router/src/lib/route-builder.ts
184
+ function createRoutes(files, resolveModule, debug = false) {
185
+ const filenames = Object.keys(files).sort((a, b) => {
186
+ return getCollisionPriority(a) - getCollisionPriority(b);
187
+ });
188
+ if (filenames.length === 0) return [];
189
+ const rawRoutesByLevelMap = filenames.reduce((acc, filename) => {
190
+ const rawPath = toRawPath(filename);
191
+ const rawSegments = rawPath.split("/");
192
+ const level = rawSegments.length - 1;
193
+ const rawSegment = rawSegments[level];
194
+ const ancestorRawSegments = rawSegments.slice(0, level);
195
+ const existing = acc[level]?.[rawPath];
196
+ if (existing?.filename && existing.filename !== filename) {
197
+ const shouldKeepExisting = getCollisionPriority(existing.filename) < getCollisionPriority(filename);
198
+ shouldKeepExisting && existing.filename;
199
+ if (shouldKeepExisting) return acc;
200
+ }
201
+ return {
202
+ ...acc,
203
+ [level]: {
204
+ ...acc[level],
205
+ [rawPath]: {
206
+ filename,
207
+ rawSegment,
208
+ ancestorRawSegments,
209
+ segment: toSegment(rawSegment),
210
+ level,
211
+ children: []
212
+ }
213
+ }
214
+ };
215
+ }, {});
216
+ const allLevels = Object.keys(rawRoutesByLevelMap).map(Number);
217
+ const maxLevel = Math.max(...allLevels);
218
+ for (let level = maxLevel; level > 0; level--) {
219
+ const rawRoutesMap = rawRoutesByLevelMap[level];
220
+ const rawPaths = Object.keys(rawRoutesMap);
221
+ for (const rawPath of rawPaths) {
222
+ const rawRoute = rawRoutesMap[rawPath];
223
+ const parentRawPath = rawRoute.ancestorRawSegments.join("/");
224
+ const parentRawSegmentIndex = rawRoute.ancestorRawSegments.length - 1;
225
+ const parentRawSegment = rawRoute.ancestorRawSegments[parentRawSegmentIndex];
226
+ rawRoutesByLevelMap[level - 1] ||= {};
227
+ rawRoutesByLevelMap[level - 1][parentRawPath] ||= {
228
+ filename: null,
229
+ rawSegment: parentRawSegment,
230
+ ancestorRawSegments: rawRoute.ancestorRawSegments.slice(0, parentRawSegmentIndex),
231
+ segment: toSegment(parentRawSegment),
232
+ level: level - 1,
233
+ children: []
234
+ };
235
+ rawRoutesByLevelMap[level - 1][parentRawPath].children.push(rawRoute);
236
+ }
237
+ }
238
+ const rootRawRoutesMap = rawRoutesByLevelMap[0];
239
+ const rawRoutes = Object.keys(rootRawRoutesMap).map((segment) => rootRawRoutesMap[segment]);
240
+ sortRawRoutes(rawRoutes);
241
+ return toRoutes(rawRoutes, files, resolveModule, debug);
242
+ }
243
+ function getCollisionPriority(filename) {
244
+ if (filename.includes("/src/app/pages/") || filename.includes("/src/app/routes/") || filename.includes("/app/pages/") || filename.includes("/app/routes/") || filename.includes("/src/content/")) return 0;
245
+ return 1;
246
+ }
247
+ /**
248
+ * Strips directory prefixes and file extensions from a route filename to
249
+ * produce the raw path used for route segment construction.
250
+ *
251
+ * The regex mirrors `filenameToRoutePath` in route-manifest.ts — changes
252
+ * here must be kept in sync with that function. The first alternation
253
+ * strips everything up to and including the first /routes/, /pages/, or
254
+ * /content/ segment, which handles both app-local and additional directory
255
+ * paths (e.g. `additionalPagesDirs`, `additionalContentDirs`).
256
+ */
257
+ function toRawPath(filename) {
258
+ return filename.replace(/^(?:[a-zA-Z]:[\\/])?(.*?)[\\/](?:routes|pages|content)[\\/]|(?:[\\/](?:app[\\/](?:routes|pages)|src[\\/]content)[\\/])|(\.page\.(js|ts|analog|ag)$)|(\.(ts|md|analog|ag)$)/g, "").replace(/\[\[\.\.\.([^\]]+)\]\]/g, "(opt-$1)").replace(/\[\.{3}.+\]/, "**").replace(/\[([^\]]+)\]/g, ":$1");
259
+ }
260
+ function toSegment(rawSegment) {
261
+ return rawSegment.replace(/\(.*?\)/g, "").replace(/(^|[./])index(?=[./]|$)/g, "$1").replace(/\.|\/+/g, "/").replace(/^\/+|\/+$/g, "");
262
+ }
263
+ function createOptionalCatchAllMatcher(paramName) {
264
+ return (segments) => {
265
+ if (segments.length === 0) return null;
266
+ const joined = segments.map((s) => s.path).join("/");
267
+ return {
268
+ consumed: segments,
269
+ posParams: { [paramName]: new UrlSegment(joined, {}) }
270
+ };
271
+ };
272
+ }
273
+ function toRoutes(rawRoutes, files, resolveModule, debug = false) {
274
+ const routes = [];
275
+ for (const rawRoute of rawRoutes) {
276
+ const children = rawRoute.children.length > 0 ? toRoutes(rawRoute.children, files, resolveModule, debug) : void 0;
277
+ let module;
278
+ let analogMeta;
279
+ if (rawRoute.filename) {
280
+ if (!debug) module = resolveModule(rawRoute.filename, files[rawRoute.filename]);
281
+ if (/\.page\.(ts|analog|ag)$/.test(rawRoute.filename)) {
282
+ const endpointKey = rawRoute.filename.replace(/\.page\.(ts|analog|ag)$/, ENDPOINT_EXTENSION);
283
+ analogMeta = {
284
+ endpoint: (rawRoute.filename.replace(/\.page\.(ts|analog|ag)$/, "").replace(/\[\[\.\.\..+\]\]/, "**").replace(/\[\.{3}.+\]/, "**").replace(/^(.*?)\/pages/, "/pages") || "").replace(/\./g, "/").replace(/\/\((.*?)\)$/, "/-$1-"),
285
+ endpointKey
286
+ };
287
+ }
288
+ }
289
+ const optCatchAllMatch = rawRoute.filename?.match(/\[\[\.\.\.([^\]]+)\]\]/);
290
+ const optCatchAllParam = optCatchAllMatch ? optCatchAllMatch[1] : null;
291
+ const route = module ? {
292
+ path: rawRoute.segment,
293
+ loadChildren: () => module().then((m) => {
294
+ const routeConfig = toRouteConfig(mergeRouteJsonLdIntoRouteMeta(m.routeMeta, m.routeJsonLd));
295
+ const hasRedirect = "redirectTo" in routeConfig;
296
+ return [{ ...hasRedirect ? {
297
+ path: "",
298
+ ...routeConfig
299
+ } : {
300
+ path: "",
301
+ component: m.default,
302
+ ...routeConfig,
303
+ children,
304
+ [ANALOG_META_KEY]: analogMeta
305
+ } }, ...optCatchAllParam ? [{
306
+ matcher: createOptionalCatchAllMatcher(optCatchAllParam),
307
+ ...hasRedirect ? routeConfig : {
308
+ component: m.default,
309
+ ...routeConfig,
310
+ [ANALOG_META_KEY]: analogMeta
311
+ }
312
+ }] : []];
313
+ })
314
+ } : {
315
+ path: rawRoute.segment,
316
+ ...debug ? {
317
+ filename: rawRoute.filename ? rawRoute.filename : void 0,
318
+ isLayout: children && children.length > 0 ? true : false
319
+ } : {},
320
+ children
321
+ };
322
+ routes.push(route);
323
+ }
324
+ return routes;
325
+ }
326
+ function mergeRouteJsonLdIntoRouteMeta(routeMeta, routeJsonLd) {
327
+ if (!routeJsonLd) return routeMeta;
328
+ if (!routeMeta) return { jsonLd: routeJsonLd };
329
+ if (isRedirectRouteMeta(routeMeta) || routeMeta.jsonLd) return routeMeta;
330
+ return {
331
+ ...routeMeta,
332
+ jsonLd: routeJsonLd
333
+ };
334
+ }
335
+ function isRedirectRouteMeta(routeMeta) {
336
+ return "redirectTo" in routeMeta && !!routeMeta.redirectTo;
337
+ }
338
+ function sortRawRoutes(rawRoutes) {
339
+ rawRoutes.sort((a, b) => {
340
+ let segmentA = deprioritizeSegment(a.segment);
341
+ let segmentB = deprioritizeSegment(b.segment);
342
+ if (a.children.length > b.children.length) segmentA = `~${segmentA}`;
343
+ else if (a.children.length < b.children.length) segmentB = `~${segmentB}`;
344
+ return segmentA > segmentB ? 1 : -1;
345
+ });
346
+ for (const rawRoute of rawRoutes) sortRawRoutes(rawRoute.children);
347
+ }
348
+ function deprioritizeSegment(segment) {
349
+ return segment.replaceAll(":", "~~").replaceAll("**", "~~~~");
350
+ }
351
+ //#endregion
352
+ //#region packages/router/src/lib/route-files.ts
353
+ /**
354
+ * This variable reference is replaced with a glob of all page routes.
355
+ */
356
+ var ANALOG_ROUTE_FILES = {};
357
+ var ANALOG_EXTRA_ROUTE_FILE_SOURCES = new InjectionToken("@analogjs/router extra route file sources");
358
+ //#endregion
359
+ export { updateMetaTagsOnRouteChange as a, injectRouteEndpointURL as i, ANALOG_ROUTE_FILES as n, updateJsonLdOnRouteChange as o, createRoutes as r, ANALOG_EXTRA_ROUTE_FILE_SOURCES as t };
360
+
361
+ //# sourceMappingURL=route-files.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-files.mjs","names":[],"sources":["../../../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs","../../src/lib/json-ld.ts","../../src/lib/meta-tags.ts","../../src/lib/endpoints.ts","../../src/lib/inject-route-endpoint-url.ts","../../src/lib/route-config.ts","../../src/lib/constants.ts","../../src/lib/route-builder.ts","../../src/lib/route-files.ts"],"sourcesContent":["function isPlainObject(value) {\n if (!value || typeof value !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n const hasObjectPrototype = proto === null ||\n proto === Object.prototype ||\n Object.getPrototypeOf(proto) === null;\n if (!hasObjectPrototype) {\n return false;\n }\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\nexport { isPlainObject };\n","import { DOCUMENT, inject } from '@angular/core';\nimport type { ActivatedRouteSnapshot } from '@angular/router';\nimport { NavigationEnd, Router } from '@angular/router';\nimport { isPlainObject } from 'es-toolkit';\nimport { filter } from 'rxjs/operators';\n\nimport type { Graph, Thing, WithContext } from 'schema-dts';\n\nexport type JsonLdObject = Record<string, unknown>;\n\nexport function isJsonLdObject(value: unknown): value is JsonLdObject {\n return isPlainObject(value);\n}\n\nexport function normalizeJsonLd(value: unknown): JsonLdObject[] {\n if (Array.isArray(value)) {\n return value.filter(isJsonLdObject);\n }\n\n return isJsonLdObject(value) ? [value] : [];\n}\n\nexport type JsonLd = JsonLdObject | JsonLdObject[];\n\n/**\n * Typed JSON-LD document based on `schema-dts`.\n *\n * Accepts single Schema.org nodes (`WithContext<Thing>`),\n * `@graph`-based documents (`Graph`), or arrays of nodes.\n *\n * This is the canonical JSON-LD type for route authoring surfaces\n * (`routeMeta.jsonLd`, `routeJsonLd`, generated manifest).\n *\n * @example\n * ```ts\n * import type { WebPage, WithContext } from 'schema-dts';\n *\n * export const routeMeta = {\n * jsonLd: {\n * '@context': 'https://schema.org',\n * '@type': 'WebPage',\n * name: 'Products',\n * } satisfies WithContext<WebPage>,\n * };\n * ```\n */\nexport type AnalogJsonLdDocument =\n | WithContext<Thing>\n | Graph\n | WithContext<Thing>[];\n\nexport const ROUTE_JSON_LD_KEY: unique symbol = Symbol(\n '@analogjs/router Route JSON-LD Key',\n);\nconst JSON_LD_SCRIPT_SELECTOR = 'script[data-analog-json-ld]';\n\nexport function updateJsonLdOnRouteChange(\n router: Router = inject(Router),\n document: Document | null = inject(DOCUMENT, { optional: true }),\n): void {\n if (!document) {\n return;\n }\n\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n const entries = getJsonLdEntries(router.routerState.snapshot.root);\n applyJsonLdToDocument(document, entries);\n });\n}\n\nexport function serializeJsonLd(entry: JsonLdObject): string | null {\n try {\n return JSON.stringify(entry)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n } catch {\n return null;\n }\n}\n\nfunction getJsonLdEntries(route: ActivatedRouteSnapshot): JsonLdObject[] {\n const entries: JsonLdObject[] = [];\n let currentRoute: ActivatedRouteSnapshot | null = route;\n\n while (currentRoute) {\n entries.push(...normalizeJsonLd(currentRoute.data[ROUTE_JSON_LD_KEY]));\n currentRoute = currentRoute.firstChild;\n }\n\n return entries;\n}\n\nfunction applyJsonLdToDocument(\n document: Document,\n entries: JsonLdObject[],\n): void {\n document.querySelectorAll(JSON_LD_SCRIPT_SELECTOR).forEach((element) => {\n element.remove();\n });\n\n if (entries.length === 0) {\n return;\n }\n\n const head = document.head || document.getElementsByTagName('head')[0];\n if (!head) {\n return;\n }\n\n entries.forEach((entry, index) => {\n const serialized = serializeJsonLd(entry);\n if (!serialized) {\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.setAttribute('data-analog-json-ld', 'true');\n script.setAttribute('data-analog-json-ld-index', String(index));\n script.textContent = serialized;\n head.appendChild(script);\n });\n}\n","import { inject } from '@angular/core';\nimport { Meta, MetaDefinition as NgMetaTag } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router';\nimport { filter } from 'rxjs/operators';\n\nexport const ROUTE_META_TAGS_KEY: unique symbol = Symbol(\n '@analogjs/router Route Meta Tags Key',\n);\n\nconst CHARSET_KEY = 'charset';\nconst HTTP_EQUIV_KEY = 'httpEquiv';\n// httpEquiv selector key needs to be in kebab case format\nconst HTTP_EQUIV_SELECTOR_KEY = 'http-equiv';\nconst NAME_KEY = 'name';\nconst PROPERTY_KEY = 'property';\nconst CONTENT_KEY = 'content';\nconst ITEMPROP_KEY = 'itemprop';\n\nexport type MetaTag =\n | (CharsetMetaTag & ExcludeRestMetaTagKeys<typeof CHARSET_KEY>)\n | (HttpEquivMetaTag & ExcludeRestMetaTagKeys<typeof HTTP_EQUIV_KEY>)\n | (NameMetaTag & ExcludeRestMetaTagKeys<typeof NAME_KEY>)\n | (PropertyMetaTag & ExcludeRestMetaTagKeys<typeof PROPERTY_KEY>)\n | (ItempropMetaTag & ExcludeRestMetaTagKeys<typeof ITEMPROP_KEY>);\n\ntype CharsetMetaTag = { [CHARSET_KEY]: string };\ntype HttpEquivMetaTag = { [HTTP_EQUIV_KEY]: string; [CONTENT_KEY]: string };\ntype NameMetaTag = { [NAME_KEY]: string; [CONTENT_KEY]: string };\ntype PropertyMetaTag = { [PROPERTY_KEY]: string; [CONTENT_KEY]: string };\ntype ItempropMetaTag = { [ITEMPROP_KEY]: string; [CONTENT_KEY]: string };\n\ntype MetaTagKey =\n | typeof CHARSET_KEY\n | typeof HTTP_EQUIV_KEY\n | typeof NAME_KEY\n | typeof PROPERTY_KEY\n | typeof ITEMPROP_KEY;\ntype ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {\n [K in Exclude<MetaTagKey, Key>]?: never;\n};\n\ntype MetaTagSelector =\n | typeof CHARSET_KEY\n | `${\n | typeof HTTP_EQUIV_SELECTOR_KEY\n | typeof NAME_KEY\n | typeof PROPERTY_KEY\n | typeof ITEMPROP_KEY}=\"${string}\"`;\ntype MetaTagMap = Record<MetaTagSelector, MetaTag>;\n\nexport function updateMetaTagsOnRouteChange(\n router: Router = inject(Router),\n metaService: Meta = inject(Meta),\n): void {\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n const metaTagMap = getMetaTagMap(router.routerState.snapshot.root);\n for (const metaTagSelector in metaTagMap) {\n const metaTag = metaTagMap[\n metaTagSelector as MetaTagSelector\n ] as NgMetaTag;\n metaService.updateTag(metaTag, metaTagSelector);\n }\n });\n}\n\nfunction getMetaTagMap(route: ActivatedRouteSnapshot): MetaTagMap {\n const metaTagMap = {} as MetaTagMap;\n let currentRoute: ActivatedRouteSnapshot | null = route;\n\n while (currentRoute) {\n const metaTags: MetaTag[] = currentRoute.data[ROUTE_META_TAGS_KEY] ?? [];\n for (const metaTag of metaTags) {\n metaTagMap[getMetaTagSelector(metaTag)] = metaTag;\n }\n\n currentRoute = currentRoute.firstChild;\n }\n\n return metaTagMap;\n}\n\nfunction getMetaTagSelector(metaTag: MetaTag): MetaTagSelector {\n if (metaTag.name) {\n return `${NAME_KEY}=\"${metaTag.name}\"`;\n }\n\n if (metaTag.property) {\n return `${PROPERTY_KEY}=\"${metaTag.property}\"`;\n }\n\n if (metaTag.httpEquiv) {\n return `${HTTP_EQUIV_SELECTOR_KEY}=\"${metaTag.httpEquiv}\"`;\n }\n\n if (metaTag.itemprop) {\n return `${ITEMPROP_KEY}=\"${metaTag.itemprop}\"`;\n }\n\n return CHARSET_KEY;\n}\n","export const ANALOG_META_KEY: unique symbol = Symbol(\n '@analogjs/router Analog Route Metadata Key',\n);\n\n/**\n * This variable reference is replaced with a glob of all route endpoints.\n */\nexport const ANALOG_PAGE_ENDPOINTS: Record<string, () => Promise<unknown>> = {};\n","import type { ActivatedRouteSnapshot, Route } from '@angular/router';\nimport { injectBaseURL, injectAPIPrefix } from '../../tokens/src/index.js';\n\nimport { ANALOG_META_KEY } from './endpoints';\n\nexport function injectRouteEndpointURL(route: ActivatedRouteSnapshot): URL {\n const routeConfig = route.routeConfig as Route & {\n [ANALOG_META_KEY]: { endpoint: string; endpointKey: string };\n };\n\n const apiPrefix = injectAPIPrefix();\n const baseUrl = injectBaseURL();\n const { queryParams, fragment: hash, params, parent } = route;\n const segment = parent?.url.map((segment) => segment.path).join('/') || '';\n const url = new URL(\n '',\n import.meta.env['VITE_ANALOG_PUBLIC_BASE_URL'] ||\n baseUrl ||\n (typeof window !== 'undefined' && window.location.origin\n ? window.location.origin\n : ''),\n );\n url.pathname = `${\n url.pathname.endsWith('/') ? url.pathname : url.pathname + '/'\n }${apiPrefix}/_analog${routeConfig[ANALOG_META_KEY].endpoint}`;\n url.search = `${new URLSearchParams(queryParams).toString()}`;\n url.hash = hash ?? '';\n\n Object.keys(params).forEach((param) => {\n url.pathname = url.pathname.replace(`[${param}]`, params[param]);\n });\n url.pathname = url.pathname.replace('**', segment);\n\n return url;\n}\n","import { inject } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport type { Route } from '@angular/router';\nimport { firstValueFrom } from 'rxjs';\nimport {\n injectInternalServerFetch,\n type ServerInternalFetch,\n} from '../../tokens/src/index.js';\n\nimport {\n DefaultRouteMeta,\n RedirectRouteMeta,\n RouteConfig,\n RouteMeta,\n} from './models';\nimport { ROUTE_JSON_LD_KEY, isJsonLdObject } from './json-ld';\nimport { ROUTE_META_TAGS_KEY } from './meta-tags';\nimport { ANALOG_PAGE_ENDPOINTS, ANALOG_META_KEY } from './endpoints';\nimport { injectRouteEndpointURL } from './inject-route-endpoint-url';\n\nexport function toRouteConfig(routeMeta: RouteMeta | undefined): RouteConfig {\n if (routeMeta && isRedirectRouteMeta(routeMeta)) {\n return routeMeta;\n }\n\n const defaultMeta: DefaultRouteMeta = (routeMeta ?? {}) as DefaultRouteMeta;\n const { meta, jsonLd, ...routeConfig } = defaultMeta;\n\n if (Array.isArray(meta)) {\n routeConfig.data = { ...routeConfig.data, [ROUTE_META_TAGS_KEY]: meta };\n } else if (typeof meta === 'function') {\n routeConfig.resolve = {\n ...routeConfig.resolve,\n [ROUTE_META_TAGS_KEY]: meta,\n };\n }\n\n if (Array.isArray(jsonLd) || isJsonLdObject(jsonLd)) {\n routeConfig.data = { ...routeConfig.data, [ROUTE_JSON_LD_KEY]: jsonLd };\n } else if (typeof jsonLd === 'function') {\n routeConfig.resolve = {\n ...routeConfig.resolve,\n [ROUTE_JSON_LD_KEY]: jsonLd,\n };\n }\n\n routeConfig.runGuardsAndResolvers =\n routeConfig.runGuardsAndResolvers ?? 'paramsOrQueryParamsChange';\n routeConfig.resolve = {\n ...routeConfig.resolve,\n load: async (route) => {\n const routeConfig = route.routeConfig as Route & {\n [ANALOG_META_KEY]: { endpoint: string; endpointKey: string };\n };\n\n // Content routes (from .md files in the pages directory) do not have\n // ANALOG_META_KEY — it is only set on page routes (.page.ts) in\n // route-builder.ts. The optional chain avoids a runtime crash when\n // the router resolves a content route during SSR / prerendering.\n if (ANALOG_PAGE_ENDPOINTS[routeConfig[ANALOG_META_KEY]?.endpointKey]) {\n const http = inject(HttpClient);\n const url = injectRouteEndpointURL(route);\n const internalFetch = injectInternalServerFetch();\n\n if (internalFetch) {\n return internalFetch(`${url.pathname}${url.search}`);\n }\n\n const globalFetch = (\n globalThis as unknown as { $fetch?: ServerInternalFetch }\n ).$fetch;\n if (!!import.meta.env['VITE_ANALOG_PUBLIC_BASE_URL'] && globalFetch) {\n return globalFetch(`${url.pathname}${url.search}`);\n }\n\n return firstValueFrom(http.get(`${url.href}`));\n }\n\n return {};\n },\n };\n\n return routeConfig;\n}\n\nfunction isRedirectRouteMeta(\n routeMeta: RouteMeta,\n): routeMeta is RedirectRouteMeta {\n return !!routeMeta.redirectTo;\n}\n","export const ENDPOINT_EXTENSION = '.server.ts';\nexport const APP_DIR = 'src/app';\n","import { UrlSegment } from '@angular/router';\nimport type { Route } from '@angular/router';\nimport type { UrlMatcher } from '@angular/router';\n\nimport type { DefaultRouteMeta, RouteExport, RouteMeta } from './models';\nimport { toRouteConfig } from './route-config';\nimport { ENDPOINT_EXTENSION } from './constants';\nimport { ANALOG_META_KEY } from './endpoints';\n\nexport type RouteModuleFactory = () => Promise<RouteExport>;\n\nexport type RouteModuleResolver<TFile> = (\n filename: string,\n fileLoader: () => Promise<TFile>,\n) => RouteModuleFactory;\n\ntype RawRoute = {\n filename: string | null;\n rawSegment: string;\n ancestorRawSegments: string[];\n segment: string;\n level: number;\n children: RawRoute[];\n};\n\ntype RawRouteMap = Record<string, RawRoute>;\ntype RawRouteByLevelMap = Record<number, RawRouteMap>;\n\nexport function createRoutes<TFile>(\n files: Record<string, () => Promise<TFile>>,\n resolveModule: RouteModuleResolver<TFile>,\n debug = false,\n): Route[] {\n const filenames = Object.keys(files).sort((a, b) => {\n const aPriority = getCollisionPriority(a);\n const bPriority = getCollisionPriority(b);\n\n return aPriority - bPriority;\n });\n\n if (filenames.length === 0) {\n return [];\n }\n\n const rawRoutesByLevelMap = filenames.reduce((acc, filename) => {\n const rawPath = toRawPath(filename);\n const rawSegments = rawPath.split('/');\n const level = rawSegments.length - 1;\n const rawSegment = rawSegments[level];\n const ancestorRawSegments = rawSegments.slice(0, level);\n\n const existing = acc[level]?.[rawPath];\n if (existing?.filename && existing.filename !== filename) {\n const existingPriority = getCollisionPriority(existing.filename);\n const nextPriority = getCollisionPriority(filename);\n const shouldKeepExisting = existingPriority < nextPriority;\n const chosenFilename = shouldKeepExisting ? existing.filename : filename;\n\n if (import.meta.env.DEV) {\n console.warn(\n `[Analog] Route files \"${existing.filename}\" and \"${filename}\" ` +\n `resolve to the same route path \"${rawPath}\". ` +\n `Only \"${chosenFilename}\" will be used.`,\n );\n }\n\n if (shouldKeepExisting) {\n return acc;\n }\n }\n\n return {\n ...acc,\n [level]: {\n ...acc[level],\n [rawPath]: {\n filename,\n rawSegment,\n ancestorRawSegments,\n segment: toSegment(rawSegment),\n level,\n children: [],\n },\n },\n };\n }, {} as RawRouteByLevelMap);\n\n const allLevels = Object.keys(rawRoutesByLevelMap).map(Number);\n const maxLevel = Math.max(...allLevels);\n\n for (let level = maxLevel; level > 0; level--) {\n const rawRoutesMap = rawRoutesByLevelMap[level];\n const rawPaths = Object.keys(rawRoutesMap);\n\n for (const rawPath of rawPaths) {\n const rawRoute = rawRoutesMap[rawPath];\n const parentRawPath = rawRoute.ancestorRawSegments.join('/');\n const parentRawSegmentIndex = rawRoute.ancestorRawSegments.length - 1;\n const parentRawSegment =\n rawRoute.ancestorRawSegments[parentRawSegmentIndex];\n\n rawRoutesByLevelMap[level - 1] ||= {};\n rawRoutesByLevelMap[level - 1][parentRawPath] ||= {\n filename: null,\n rawSegment: parentRawSegment,\n ancestorRawSegments: rawRoute.ancestorRawSegments.slice(\n 0,\n parentRawSegmentIndex,\n ),\n segment: toSegment(parentRawSegment),\n level: level - 1,\n children: [],\n };\n\n rawRoutesByLevelMap[level - 1][parentRawPath].children.push(rawRoute);\n }\n }\n\n const rootRawRoutesMap = rawRoutesByLevelMap[0];\n const rawRoutes = Object.keys(rootRawRoutesMap).map(\n (segment) => rootRawRoutesMap[segment],\n );\n sortRawRoutes(rawRoutes);\n\n return toRoutes(rawRoutes, files, resolveModule, debug);\n}\n\nfunction getCollisionPriority(filename: string): number {\n if (\n filename.includes('/src/app/pages/') ||\n filename.includes('/src/app/routes/') ||\n filename.includes('/app/pages/') ||\n filename.includes('/app/routes/') ||\n filename.includes('/src/content/')\n ) {\n return 0;\n }\n\n return 1;\n}\n\n/**\n * Strips directory prefixes and file extensions from a route filename to\n * produce the raw path used for route segment construction.\n *\n * The regex mirrors `filenameToRoutePath` in route-manifest.ts — changes\n * here must be kept in sync with that function. The first alternation\n * strips everything up to and including the first /routes/, /pages/, or\n * /content/ segment, which handles both app-local and additional directory\n * paths (e.g. `additionalPagesDirs`, `additionalContentDirs`).\n */\nfunction toRawPath(filename: string): string {\n return filename\n .replace(\n /^(?:[a-zA-Z]:[\\\\/])?(.*?)[\\\\/](?:routes|pages|content)[\\\\/]|(?:[\\\\/](?:app[\\\\/](?:routes|pages)|src[\\\\/]content)[\\\\/])|(\\.page\\.(js|ts|analog|ag)$)|(\\.(ts|md|analog|ag)$)/g,\n '',\n )\n .replace(/\\[\\[\\.\\.\\.([^\\]]+)\\]\\]/g, '(opt-$1)')\n .replace(/\\[\\.{3}.+\\]/, '**')\n .replace(/\\[([^\\]]+)\\]/g, ':$1');\n}\n\nfunction toSegment(rawSegment: string): string {\n return rawSegment\n .replace(/\\(.*?\\)/g, '')\n .replace(/(^|[./])index(?=[./]|$)/g, '$1')\n .replace(/\\.|\\/+/g, '/')\n .replace(/^\\/+|\\/+$/g, '');\n}\n\nfunction createOptionalCatchAllMatcher(paramName: string): UrlMatcher {\n return (segments) => {\n if (segments.length === 0) {\n return null;\n }\n const joined = segments.map((s) => s.path).join('/');\n return {\n consumed: segments,\n posParams: { [paramName]: new UrlSegment(joined, {}) },\n };\n };\n}\n\nfunction toRoutes<TFile>(\n rawRoutes: RawRoute[],\n files: Record<string, () => Promise<TFile>>,\n resolveModule: RouteModuleResolver<TFile>,\n debug = false,\n): Route[] {\n const routes: Route[] = [];\n\n for (const rawRoute of rawRoutes) {\n const children: Route[] | undefined =\n rawRoute.children.length > 0\n ? toRoutes(rawRoute.children, files, resolveModule, debug)\n : undefined;\n let module: RouteModuleFactory | undefined;\n let analogMeta: { endpoint: string; endpointKey: string } | undefined;\n\n if (rawRoute.filename) {\n if (!debug) {\n module = resolveModule(rawRoute.filename, files[rawRoute.filename]);\n }\n\n if (/\\.page\\.(ts|analog|ag)$/.test(rawRoute.filename)) {\n const endpointKey = rawRoute.filename.replace(\n /\\.page\\.(ts|analog|ag)$/,\n ENDPOINT_EXTENSION,\n );\n\n const rawEndpoint = rawRoute.filename\n .replace(/\\.page\\.(ts|analog|ag)$/, '')\n .replace(/\\[\\[\\.\\.\\..+\\]\\]/, '**')\n .replace(/\\[\\.{3}.+\\]/, '**')\n .replace(/^(.*?)\\/pages/, '/pages');\n\n const endpoint = (rawEndpoint || '')\n .replace(/\\./g, '/')\n .replace(/\\/\\((.*?)\\)$/, '/-$1-');\n\n analogMeta = {\n endpoint,\n endpointKey,\n };\n }\n }\n\n const optCatchAllMatch = rawRoute.filename?.match(/\\[\\[\\.\\.\\.([^\\]]+)\\]\\]/);\n const optCatchAllParam = optCatchAllMatch ? optCatchAllMatch[1] : null;\n\n type DebugRoute = Route & {\n filename?: string | null | undefined;\n isLayout?: boolean;\n };\n\n const route: Route & { meta?: typeof analogMeta } & DebugRoute = module\n ? {\n path: rawRoute.segment,\n loadChildren: () =>\n module!().then((m) => {\n if (import.meta.env.DEV) {\n const hasModuleDefault = !!m.default;\n const hasRedirect = !!m.routeMeta?.redirectTo;\n\n if (!hasModuleDefault && !hasRedirect) {\n console.warn(\n `[Analog] Missing default export at ${rawRoute.filename}`,\n );\n }\n }\n\n const routeMeta = mergeRouteJsonLdIntoRouteMeta(\n m.routeMeta as RouteMeta | undefined,\n m.routeJsonLd,\n );\n\n const routeConfig = toRouteConfig(routeMeta);\n const hasRedirect = 'redirectTo' in routeConfig;\n const baseChild = hasRedirect\n ? {\n path: '',\n ...routeConfig,\n }\n : {\n path: '',\n component: m.default,\n ...routeConfig,\n children,\n [ANALOG_META_KEY]: analogMeta,\n };\n\n return [\n {\n ...baseChild,\n },\n ...(optCatchAllParam\n ? [\n {\n matcher:\n createOptionalCatchAllMatcher(optCatchAllParam),\n ...(hasRedirect\n ? routeConfig\n : {\n component: m.default,\n ...routeConfig,\n [ANALOG_META_KEY]: analogMeta,\n }),\n },\n ]\n : []),\n ];\n }),\n }\n : {\n path: rawRoute.segment,\n ...(debug\n ? {\n filename: rawRoute.filename ? rawRoute.filename : undefined,\n isLayout: children && children.length > 0 ? true : false,\n }\n : {}),\n children,\n };\n\n routes.push(route);\n }\n\n return routes;\n}\n\nfunction mergeRouteJsonLdIntoRouteMeta(\n routeMeta: RouteMeta | undefined,\n routeJsonLd: RouteExport['routeJsonLd'],\n): RouteMeta | undefined {\n if (!routeJsonLd) {\n return routeMeta;\n }\n\n if (!routeMeta) {\n return { jsonLd: routeJsonLd };\n }\n\n if (isRedirectRouteMeta(routeMeta) || routeMeta.jsonLd) {\n return routeMeta;\n }\n\n return {\n ...routeMeta,\n jsonLd: routeJsonLd,\n };\n}\n\nfunction isRedirectRouteMeta(\n routeMeta: RouteMeta,\n): routeMeta is Exclude<RouteMeta, DefaultRouteMeta> {\n return 'redirectTo' in routeMeta && !!routeMeta.redirectTo;\n}\n\nfunction sortRawRoutes(rawRoutes: RawRoute[]): void {\n rawRoutes.sort((a, b) => {\n let segmentA = deprioritizeSegment(a.segment);\n let segmentB = deprioritizeSegment(b.segment);\n\n if (a.children.length > b.children.length) {\n segmentA = `~${segmentA}`;\n } else if (a.children.length < b.children.length) {\n segmentB = `~${segmentB}`;\n }\n\n return segmentA > segmentB ? 1 : -1;\n });\n\n for (const rawRoute of rawRoutes) {\n sortRawRoutes(rawRoute.children);\n }\n}\n\nfunction deprioritizeSegment(segment: string): string {\n return segment.replaceAll(':', '~~').replaceAll('**', '~~~~');\n}\n","import { InjectionToken } from '@angular/core';\nimport type { RouteExport } from './models';\n\nexport type Files = Record<string, () => Promise<RouteExport>>;\n\n/**\n * This variable reference is replaced with a glob of all page routes.\n */\nexport const ANALOG_ROUTE_FILES = {};\n\nexport interface ExtraRouteFileSource {\n files: Record<string, () => Promise<unknown>>;\n resolveModule: (\n filename: string,\n fileLoader: () => Promise<unknown>,\n ) => () => Promise<RouteExport>;\n}\n\nexport const ANALOG_EXTRA_ROUTE_FILE_SOURCES: InjectionToken<\n ExtraRouteFileSource[]\n> = new InjectionToken('@analogjs/router extra route file sources');\n\n/**\n * Replaced at build time by the Vite router plugin with the number of\n * discovered content route files. Used in dev mode to warn when content\n * files exist but `withContent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