@analogjs/router 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (90) 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-server-actions.mjs +327 -31
  5. package/fesm2022/analogjs-router-server-actions.mjs.map +1 -1
  6. package/fesm2022/analogjs-router-server.mjs +151 -199
  7. package/fesm2022/analogjs-router-server.mjs.map +1 -1
  8. package/fesm2022/analogjs-router-tanstack-query-server.mjs +22 -0
  9. package/fesm2022/analogjs-router-tanstack-query-server.mjs.map +1 -0
  10. package/fesm2022/analogjs-router-tanstack-query.mjs +39 -0
  11. package/fesm2022/analogjs-router-tanstack-query.mjs.map +1 -0
  12. package/fesm2022/analogjs-router-tokens.mjs +15 -18
  13. package/fesm2022/analogjs-router-tokens.mjs.map +1 -1
  14. package/fesm2022/analogjs-router.mjs +960 -815
  15. package/fesm2022/analogjs-router.mjs.map +1 -1
  16. package/fesm2022/debug.page.mjs +135 -0
  17. package/fesm2022/debug.page.mjs.map +1 -0
  18. package/fesm2022/provide-analog-query.mjs +23 -0
  19. package/fesm2022/provide-analog-query.mjs.map +1 -0
  20. package/fesm2022/route-files.mjs +345 -0
  21. package/fesm2022/route-files.mjs.map +1 -0
  22. package/fesm2022/routes.mjs +28 -0
  23. package/fesm2022/routes.mjs.map +1 -0
  24. package/package.json +67 -27
  25. package/server/actions/package.json +4 -0
  26. package/server/package.json +4 -0
  27. package/tanstack-query/package.json +4 -0
  28. package/tanstack-query/server/package.json +4 -0
  29. package/tokens/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/content/src/lib/markdown-helpers.d.ts +2 -0
  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/server/actions/src/actions.d.ts +13 -0
  36. package/types/server/actions/src/define-action.d.ts +54 -0
  37. package/types/server/actions/src/define-api-route.d.ts +57 -0
  38. package/types/server/actions/src/define-page-load.d.ts +55 -0
  39. package/types/server/actions/src/define-server-route.d.ts +68 -0
  40. package/types/server/actions/src/index.d.ts +9 -0
  41. package/types/server/actions/src/parse-request-data.d.ts +9 -0
  42. package/types/server/actions/src/validate.d.ts +8 -0
  43. package/types/server/src/index.d.ts +4 -0
  44. package/types/server/src/provide-server-context.d.ts +11 -0
  45. package/types/server/src/render.d.ts +12 -0
  46. package/types/server/src/server-component-render.d.ts +4 -0
  47. package/types/server/src/tokens.d.ts +7 -0
  48. package/types/src/index.d.ts +27 -0
  49. package/types/src/lib/cache-key.d.ts +3 -0
  50. package/types/src/lib/constants.d.ts +2 -0
  51. package/types/src/lib/cookie-interceptor.d.ts +4 -0
  52. package/types/src/lib/debug/debug.page.d.ts +20 -0
  53. package/types/src/lib/debug/index.d.ts +10 -0
  54. package/types/src/lib/debug/routes.d.ts +10 -0
  55. package/types/src/lib/define-route.d.ts +51 -0
  56. package/types/src/lib/endpoints.d.ts +5 -0
  57. package/types/src/lib/experimental.d.ts +140 -0
  58. package/types/src/lib/form-action.directive.d.ts +25 -0
  59. package/types/src/lib/get-load-resolver.d.ts +8 -0
  60. package/types/src/lib/inject-load.d.ts +9 -0
  61. package/types/src/lib/inject-navigate.d.ts +23 -0
  62. package/types/src/lib/inject-route-context.d.ts +32 -0
  63. package/types/src/lib/inject-route-endpoint-url.d.ts +2 -0
  64. package/types/src/lib/inject-typed-params.d.ts +63 -0
  65. package/types/src/lib/json-ld.d.ts +31 -0
  66. package/types/src/lib/meta-tags.d.ts +33 -0
  67. package/types/src/lib/models.d.ts +32 -0
  68. package/types/src/lib/provide-file-router-base.d.ts +4 -0
  69. package/types/src/lib/provide-file-router.d.ts +12 -0
  70. package/types/src/lib/request-context.d.ts +13 -0
  71. package/types/src/lib/route-builder.d.ts +5 -0
  72. package/types/src/lib/route-config.d.ts +2 -0
  73. package/types/src/lib/route-files.d.ts +18 -0
  74. package/types/src/lib/route-path.d.ts +124 -0
  75. package/types/src/lib/route-types.d.ts +12 -0
  76. package/types/src/lib/routes.d.ts +11 -0
  77. package/types/src/lib/server.component.d.ts +33 -0
  78. package/types/src/lib/validation-errors.d.ts +7 -0
  79. package/types/tanstack-query/server/src/index.d.ts +1 -0
  80. package/types/tanstack-query/src/index.d.ts +2 -0
  81. package/types/tanstack-query/src/provide-analog-query.d.ts +4 -0
  82. package/types/tanstack-query/src/provide-server-analog-query.d.ts +2 -0
  83. package/types/tanstack-query/src/server-query.d.ts +16 -0
  84. package/types/tokens/src/index.d.ts +23 -0
  85. package/fesm2022/analogjs-router-debug.page-jzggTA45.mjs +0 -91
  86. package/fesm2022/analogjs-router-debug.page-jzggTA45.mjs.map +0 -1
  87. package/types/analogjs-router-server-actions.d.ts +0 -17
  88. package/types/analogjs-router-server.d.ts +0 -29
  89. package/types/analogjs-router-tokens.d.ts +0 -27
  90. package/types/analogjs-router.d.ts +0 -269
@@ -0,0 +1,345 @@
1
+ import { NavigationEnd, Router, UrlSegment } from "@angular/router";
2
+ import { InjectionToken, inject } from "@angular/core";
3
+ import { HttpClient } from "@angular/common/http";
4
+ import { firstValueFrom } from "rxjs";
5
+ import { injectAPIPrefix, injectBaseURL, injectInternalServerFetch } from "@analogjs/router/tokens";
6
+ import { DOCUMENT } from "@angular/common";
7
+ import { filter } from "rxjs/operators";
8
+ import { Meta } from "@angular/platform-browser";
9
+ //#region packages/router/src/lib/json-ld.ts
10
+ function isJsonLdObject(value) {
11
+ return typeof value === "object" && value !== null && !Array.isArray(value);
12
+ }
13
+ function normalizeJsonLd(value) {
14
+ if (Array.isArray(value)) return value.filter(isJsonLdObject);
15
+ return isJsonLdObject(value) ? [value] : [];
16
+ }
17
+ var ROUTE_JSON_LD_KEY = Symbol("@analogjs/router Route JSON-LD Key");
18
+ var JSON_LD_SCRIPT_SELECTOR = "script[data-analog-json-ld]";
19
+ function updateJsonLdOnRouteChange() {
20
+ const router = inject(Router);
21
+ const document = inject(DOCUMENT);
22
+ router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(() => {
23
+ applyJsonLdToDocument(document, getJsonLdEntries(router.routerState.snapshot.root));
24
+ });
25
+ }
26
+ function serializeJsonLd(entry) {
27
+ try {
28
+ return JSON.stringify(entry).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+ function getJsonLdEntries(route) {
34
+ const entries = [];
35
+ let currentRoute = route;
36
+ while (currentRoute) {
37
+ entries.push(...normalizeJsonLd(currentRoute.data[ROUTE_JSON_LD_KEY]));
38
+ currentRoute = currentRoute.firstChild;
39
+ }
40
+ return entries;
41
+ }
42
+ function applyJsonLdToDocument(document, entries) {
43
+ document.querySelectorAll(JSON_LD_SCRIPT_SELECTOR).forEach((element) => {
44
+ element.remove();
45
+ });
46
+ if (entries.length === 0) return;
47
+ const head = document.head || document.getElementsByTagName("head")[0];
48
+ if (!head) return;
49
+ entries.forEach((entry, index) => {
50
+ const serialized = serializeJsonLd(entry);
51
+ if (!serialized) return;
52
+ const script = document.createElement("script");
53
+ script.type = "application/ld+json";
54
+ script.setAttribute("data-analog-json-ld", "true");
55
+ script.setAttribute("data-analog-json-ld-index", String(index));
56
+ script.textContent = serialized;
57
+ head.appendChild(script);
58
+ });
59
+ }
60
+ //#endregion
61
+ //#region packages/router/src/lib/meta-tags.ts
62
+ var ROUTE_META_TAGS_KEY = Symbol("@analogjs/router Route Meta Tags Key");
63
+ var CHARSET_KEY = "charset";
64
+ var HTTP_EQUIV_SELECTOR_KEY = "http-equiv";
65
+ var NAME_KEY = "name";
66
+ var PROPERTY_KEY = "property";
67
+ var ITEMPROP_KEY = "itemprop";
68
+ function updateMetaTagsOnRouteChange() {
69
+ const router = inject(Router);
70
+ const metaService = inject(Meta);
71
+ router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(() => {
72
+ const metaTagMap = getMetaTagMap(router.routerState.snapshot.root);
73
+ for (const metaTagSelector in metaTagMap) {
74
+ const metaTag = metaTagMap[metaTagSelector];
75
+ metaService.updateTag(metaTag, metaTagSelector);
76
+ }
77
+ });
78
+ }
79
+ function getMetaTagMap(route) {
80
+ const metaTagMap = {};
81
+ let currentRoute = route;
82
+ while (currentRoute) {
83
+ const metaTags = currentRoute.data[ROUTE_META_TAGS_KEY] ?? [];
84
+ for (const metaTag of metaTags) metaTagMap[getMetaTagSelector(metaTag)] = metaTag;
85
+ currentRoute = currentRoute.firstChild;
86
+ }
87
+ return metaTagMap;
88
+ }
89
+ function getMetaTagSelector(metaTag) {
90
+ if (metaTag.name) return `${NAME_KEY}="${metaTag.name}"`;
91
+ if (metaTag.property) return `${PROPERTY_KEY}="${metaTag.property}"`;
92
+ if (metaTag.httpEquiv) return `${HTTP_EQUIV_SELECTOR_KEY}="${metaTag.httpEquiv}"`;
93
+ if (metaTag.itemprop) return `${ITEMPROP_KEY}="${metaTag.itemprop}"`;
94
+ return CHARSET_KEY;
95
+ }
96
+ //#endregion
97
+ //#region packages/router/src/lib/endpoints.ts
98
+ var ANALOG_META_KEY = Symbol("@analogjs/router Analog Route Metadata Key");
99
+ /**
100
+ * This variable reference is replaced with a glob of all route endpoints.
101
+ */
102
+ var ANALOG_PAGE_ENDPOINTS = {};
103
+ //#endregion
104
+ //#region packages/router/src/lib/inject-route-endpoint-url.ts
105
+ function injectRouteEndpointURL(route) {
106
+ const routeConfig = route.routeConfig;
107
+ const apiPrefix = injectAPIPrefix();
108
+ const baseUrl = injectBaseURL();
109
+ const { queryParams, fragment: hash, params, parent } = route;
110
+ const segment = parent?.url.map((segment) => segment.path).join("/") || "";
111
+ const url = new URL("", {
112
+ "BASE_URL": "/",
113
+ "DEV": false,
114
+ "MODE": "production",
115
+ "PROD": true,
116
+ "SSR": false
117
+ }["VITE_ANALOG_PUBLIC_BASE_URL"] || baseUrl || (typeof window !== "undefined" && window.location.origin ? window.location.origin : ""));
118
+ url.pathname = `${url.pathname.endsWith("/") ? url.pathname : url.pathname + "/"}${apiPrefix}/_analog${routeConfig[ANALOG_META_KEY].endpoint}`;
119
+ url.search = `${new URLSearchParams(queryParams).toString()}`;
120
+ url.hash = hash ?? "";
121
+ Object.keys(params).forEach((param) => {
122
+ url.pathname = url.pathname.replace(`[${param}]`, params[param]);
123
+ });
124
+ url.pathname = url.pathname.replace("**", segment);
125
+ return url;
126
+ }
127
+ //#endregion
128
+ //#region packages/router/src/lib/route-config.ts
129
+ function toRouteConfig(routeMeta) {
130
+ if (routeMeta && isRedirectRouteMeta$1(routeMeta)) return routeMeta;
131
+ const { meta, jsonLd, ...routeConfig } = routeMeta ?? {};
132
+ if (Array.isArray(meta)) routeConfig.data = {
133
+ ...routeConfig.data,
134
+ [ROUTE_META_TAGS_KEY]: meta
135
+ };
136
+ else if (typeof meta === "function") routeConfig.resolve = {
137
+ ...routeConfig.resolve,
138
+ [ROUTE_META_TAGS_KEY]: meta
139
+ };
140
+ if (Array.isArray(jsonLd) || isJsonLdObject(jsonLd)) routeConfig.data = {
141
+ ...routeConfig.data,
142
+ [ROUTE_JSON_LD_KEY]: jsonLd
143
+ };
144
+ else if (typeof jsonLd === "function") routeConfig.resolve = {
145
+ ...routeConfig.resolve,
146
+ [ROUTE_JSON_LD_KEY]: jsonLd
147
+ };
148
+ routeConfig.runGuardsAndResolvers = routeConfig.runGuardsAndResolvers ?? "paramsOrQueryParamsChange";
149
+ routeConfig.resolve = {
150
+ ...routeConfig.resolve,
151
+ load: async (route) => {
152
+ if (ANALOG_PAGE_ENDPOINTS[route.routeConfig[ANALOG_META_KEY]?.endpointKey]) {
153
+ const http = inject(HttpClient);
154
+ const url = injectRouteEndpointURL(route);
155
+ const internalFetch = injectInternalServerFetch();
156
+ if (internalFetch) return internalFetch(`${url.pathname}${url.search}`);
157
+ const globalFetch = globalThis.$fetch;
158
+ if (!!{
159
+ "BASE_URL": "/",
160
+ "DEV": false,
161
+ "MODE": "production",
162
+ "PROD": true,
163
+ "SSR": false
164
+ }["VITE_ANALOG_PUBLIC_BASE_URL"] && globalFetch) return globalFetch(`${url.pathname}${url.search}`);
165
+ return firstValueFrom(http.get(`${url.href}`));
166
+ }
167
+ return {};
168
+ }
169
+ };
170
+ return routeConfig;
171
+ }
172
+ function isRedirectRouteMeta$1(routeMeta) {
173
+ return !!routeMeta.redirectTo;
174
+ }
175
+ //#endregion
176
+ //#region packages/router/src/lib/constants.ts
177
+ var ENDPOINT_EXTENSION = ".server.ts";
178
+ //#endregion
179
+ //#region packages/router/src/lib/route-builder.ts
180
+ function createRoutes(files, resolveModule, debug = false) {
181
+ const filenames = Object.keys(files);
182
+ if (filenames.length === 0) return [];
183
+ const rawRoutesByLevelMap = filenames.reduce((acc, filename) => {
184
+ const rawPath = toRawPath(filename);
185
+ const rawSegments = rawPath.split("/");
186
+ const level = rawSegments.length - 1;
187
+ const rawSegment = rawSegments[level];
188
+ const ancestorRawSegments = rawSegments.slice(0, level);
189
+ return {
190
+ ...acc,
191
+ [level]: {
192
+ ...acc[level],
193
+ [rawPath]: {
194
+ filename,
195
+ rawSegment,
196
+ ancestorRawSegments,
197
+ segment: toSegment(rawSegment),
198
+ level,
199
+ children: []
200
+ }
201
+ }
202
+ };
203
+ }, {});
204
+ const allLevels = Object.keys(rawRoutesByLevelMap).map(Number);
205
+ const maxLevel = Math.max(...allLevels);
206
+ for (let level = maxLevel; level > 0; level--) {
207
+ const rawRoutesMap = rawRoutesByLevelMap[level];
208
+ const rawPaths = Object.keys(rawRoutesMap);
209
+ for (const rawPath of rawPaths) {
210
+ const rawRoute = rawRoutesMap[rawPath];
211
+ const parentRawPath = rawRoute.ancestorRawSegments.join("/");
212
+ const parentRawSegmentIndex = rawRoute.ancestorRawSegments.length - 1;
213
+ const parentRawSegment = rawRoute.ancestorRawSegments[parentRawSegmentIndex];
214
+ rawRoutesByLevelMap[level - 1] ||= {};
215
+ rawRoutesByLevelMap[level - 1][parentRawPath] ||= {
216
+ filename: null,
217
+ rawSegment: parentRawSegment,
218
+ ancestorRawSegments: rawRoute.ancestorRawSegments.slice(0, parentRawSegmentIndex),
219
+ segment: toSegment(parentRawSegment),
220
+ level: level - 1,
221
+ children: []
222
+ };
223
+ rawRoutesByLevelMap[level - 1][parentRawPath].children.push(rawRoute);
224
+ }
225
+ }
226
+ const rootRawRoutesMap = rawRoutesByLevelMap[0];
227
+ const rawRoutes = Object.keys(rootRawRoutesMap).map((segment) => rootRawRoutesMap[segment]);
228
+ sortRawRoutes(rawRoutes);
229
+ return toRoutes(rawRoutes, files, resolveModule, debug);
230
+ }
231
+ /**
232
+ * Strips directory prefixes and file extensions from a route filename to
233
+ * produce the raw path used for route segment construction.
234
+ *
235
+ * The regex mirrors `filenameToRoutePath` in route-manifest.ts — changes
236
+ * here must be kept in sync with that function. The first alternation
237
+ * strips everything up to and including the first /routes/, /pages/, or
238
+ * /content/ segment, which handles both app-local and additional directory
239
+ * paths (e.g. `additionalPagesDirs`, `additionalContentDirs`).
240
+ */
241
+ function toRawPath(filename) {
242
+ 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");
243
+ }
244
+ function toSegment(rawSegment) {
245
+ return rawSegment.replace(/\(.*?\)/g, "").replace(/(^|[./])index(?=[./]|$)/g, "$1").replace(/\.|\/+/g, "/").replace(/^\/+|\/+$/g, "");
246
+ }
247
+ function createOptionalCatchAllMatcher(paramName) {
248
+ return (segments) => {
249
+ if (segments.length === 0) return null;
250
+ const joined = segments.map((s) => s.path).join("/");
251
+ return {
252
+ consumed: segments,
253
+ posParams: { [paramName]: new UrlSegment(joined, {}) }
254
+ };
255
+ };
256
+ }
257
+ function toRoutes(rawRoutes, files, resolveModule, debug = false) {
258
+ const routes = [];
259
+ for (const rawRoute of rawRoutes) {
260
+ const children = rawRoute.children.length > 0 ? toRoutes(rawRoute.children, files, resolveModule, debug) : void 0;
261
+ let module;
262
+ let analogMeta;
263
+ if (rawRoute.filename) {
264
+ if (!debug) module = resolveModule(rawRoute.filename, files[rawRoute.filename]);
265
+ if (/\.page\.(ts|analog|ag)$/.test(rawRoute.filename)) {
266
+ const endpointKey = rawRoute.filename.replace(/\.page\.(ts|analog|ag)$/, ENDPOINT_EXTENSION);
267
+ analogMeta = {
268
+ endpoint: (rawRoute.filename.replace(/\.page\.(ts|analog|ag)$/, "").replace(/\[\[\.\.\..+\]\]/, "**").replace(/\[\.{3}.+\]/, "**").replace(/^(.*?)\/pages/, "/pages") || "").replace(/\./g, "/").replace(/\/\((.*?)\)$/, "/-$1-"),
269
+ endpointKey
270
+ };
271
+ }
272
+ }
273
+ const optCatchAllMatch = rawRoute.filename?.match(/\[\[\.\.\.([^\]]+)\]\]/);
274
+ const optCatchAllParam = optCatchAllMatch ? optCatchAllMatch[1] : null;
275
+ const route = module ? {
276
+ path: rawRoute.segment,
277
+ loadChildren: () => module().then((m) => {
278
+ const routeConfig = toRouteConfig(mergeRouteJsonLdIntoRouteMeta(m.routeMeta, m.routeJsonLd));
279
+ const hasRedirect = "redirectTo" in routeConfig;
280
+ return [{ ...hasRedirect ? {
281
+ path: "",
282
+ ...routeConfig
283
+ } : {
284
+ path: "",
285
+ component: m.default,
286
+ ...routeConfig,
287
+ children,
288
+ [ANALOG_META_KEY]: analogMeta
289
+ } }, ...optCatchAllParam ? [{
290
+ matcher: createOptionalCatchAllMatcher(optCatchAllParam),
291
+ ...hasRedirect ? routeConfig : {
292
+ component: m.default,
293
+ ...routeConfig,
294
+ [ANALOG_META_KEY]: analogMeta
295
+ }
296
+ }] : []];
297
+ })
298
+ } : {
299
+ path: rawRoute.segment,
300
+ ...debug ? {
301
+ filename: rawRoute.filename ? rawRoute.filename : void 0,
302
+ isLayout: children && children.length > 0 ? true : false
303
+ } : {},
304
+ children
305
+ };
306
+ routes.push(route);
307
+ }
308
+ return routes;
309
+ }
310
+ function mergeRouteJsonLdIntoRouteMeta(routeMeta, routeJsonLd) {
311
+ if (!routeJsonLd) return routeMeta;
312
+ if (!routeMeta) return { jsonLd: routeJsonLd };
313
+ if (isRedirectRouteMeta(routeMeta) || routeMeta.jsonLd) return routeMeta;
314
+ return {
315
+ ...routeMeta,
316
+ jsonLd: routeJsonLd
317
+ };
318
+ }
319
+ function isRedirectRouteMeta(routeMeta) {
320
+ return "redirectTo" in routeMeta && !!routeMeta.redirectTo;
321
+ }
322
+ function sortRawRoutes(rawRoutes) {
323
+ rawRoutes.sort((a, b) => {
324
+ let segmentA = deprioritizeSegment(a.segment);
325
+ let segmentB = deprioritizeSegment(b.segment);
326
+ if (a.children.length > b.children.length) segmentA = `~${segmentA}`;
327
+ else if (a.children.length < b.children.length) segmentB = `~${segmentB}`;
328
+ return segmentA > segmentB ? 1 : -1;
329
+ });
330
+ for (const rawRoute of rawRoutes) sortRawRoutes(rawRoute.children);
331
+ }
332
+ function deprioritizeSegment(segment) {
333
+ return segment.replaceAll(":", "~~").replaceAll("**", "~~~~");
334
+ }
335
+ //#endregion
336
+ //#region packages/router/src/lib/route-files.ts
337
+ /**
338
+ * This variable reference is replaced with a glob of all page routes.
339
+ */
340
+ var ANALOG_ROUTE_FILES = {};
341
+ var ANALOG_EXTRA_ROUTE_FILE_SOURCES = new InjectionToken("@analogjs/router extra route file sources");
342
+ //#endregion
343
+ 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 };
344
+
345
+ //# sourceMappingURL=route-files.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-files.mjs","names":[],"sources":["../../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":["import { DOCUMENT } from '@angular/common';\nimport { inject } from '@angular/core';\nimport { ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router';\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 typeof value === 'object' && value !== null && !Array.isArray(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 | Array<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(): void {\n const router = inject(Router);\n const document = inject(DOCUMENT);\n\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n applyJsonLdToDocument(\n document,\n getJsonLdEntries(router.routerState.snapshot.root),\n );\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(): void {\n const router = inject(Router);\n const metaService = inject(Meta);\n\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n const metaTagMap = getMetaTagMap(router.routerState.snapshot.root);\n\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 '@analogjs/router/tokens';\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 '@analogjs/router/tokens';\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);\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 if (import.meta.env.DEV) {\n const existing = acc[level]?.[rawPath];\n if (existing?.filename && existing.filename !== filename) {\n console.warn(\n `[Analog] Route files \"${existing.filename}\" and \"${filename}\" ` +\n `resolve to the same route path \"${rawPath}\". ` +\n `Only \"${filename}\" will be used.`,\n );\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\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 `withContentRoutes()` is not configured.\n */\nexport const ANALOG_CONTENT_FILE_COUNT = 0;\n"],"mappings":";;;;;;;;;AASA,SAAgB,eAAe,OAAuC;AACpE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAS,CAAA,MAAM,QAAQ,MAAM;;AAG7E,SAAgB,gBAAgB,OAAgC;AAC9D,KAAI,MAAM,QAAQ,MAAQ,CACxB,QAAa,MAAA,OAAO,eAAe;AAGrC,QAAO,eAAe,MAAS,GAAC,CAAA,MAAS,GAAE,EAAA;;AAgC7C,IAAa,oBAAmC,OAC9C,qCACD;AACD,IAAM,0BAA0B;AAEhC,SAAgB,4BAAkC;CAChD,MAAM,SAAS,OAAO,OAAO;CAC7B,MAAM,WAAW,OAAO,SAAS;AAEjC,QAAO,OAGH,KAAA,QAAA,UACE,iBACA,cAAwB,CAAA,CAE1B,gBAAA;;GAGN;;AAEI,SAAY,gBACT,OAAQ;;AAMX,SAAO,KAAA,UAAA,MAAA,CAAA,QAAA,MAAA,UAAA,CAAA,QAAA,MAAA,UAAA,CAIF,QAAA,MAAiB,UAA+C,CACjE,QAA4B,WAAA,UAAA,CAC9B,QAA8C,WAAA,UAAA;SAGxC;AACR,SAAA;;;;CAMJ,MAAS,UAAA,EAAA;CAIP,IAAA,eAAS;AACP,QAAQ,cAAQ;AAChB,UAAA,KAAA,GAAA,gBAAA,aAAA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GACC,oBAAkB,QAAA,CAAA,MAAA,MAAA;IAsBxB,MAAA,cAAA,cAAA,8BAAA,EAAA,WAAA,EAAA,YAAA,CAAA;;AAoBN,WAAA,CAIW,EACT,GAtBH,cACiB;KAEX,MAAA;KACqB,GAAA;KACT,GAEV;KACN,MAAA;KACD,WAAA,EAAA;KAEa,GAAA;;MAGb,kBAAA;SAWS,GAAA,mBACG,CAAA;KAGe,SAAI,8BAAkB,iBAAA;KAC/C,GAAA,cAAA,cAGF;MACF,WAAA,EAAA;MACK,GAAA;OACT,kBAAA;;KAID,CAEuB,GAAA,EAAA,CAGhB;KACS;GACV,GACA;GAEE,MAAS,SAAW;GACb,GAAI,QACJ;IACI,UAAA,SAAA,WAAA,SAAA,WAAA,KAAA;;IAGC,GAClB,EAAA;GAES;GACT;;;AAIJ,QAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjUT,IAAa,qBAAqB,EAAE;AAUpC,IAAa,kCAET,IAAI,eAAe,4CAA4C"}
@@ -0,0 +1,28 @@
1
+ import { n as ANALOG_ROUTE_FILES, r as createRoutes$1 } from "./route-files.mjs";
2
+ import { InjectionToken, inject } from "@angular/core";
3
+ //#region packages/router/src/lib/routes.ts
4
+ /**
5
+ * A function used to parse list of files and create configuration of routes.
6
+ *
7
+ * @param files
8
+ * @returns Array of routes
9
+ */
10
+ function createRoutes(files, debug = false) {
11
+ return createRoutes$1(files, (_filename, fileLoader) => fileLoader, debug);
12
+ }
13
+ var routes = createRoutes(ANALOG_ROUTE_FILES);
14
+ //#endregion
15
+ //#region packages/router/src/lib/debug/routes.ts
16
+ var DEBUG_ROUTES = new InjectionToken("@analogjs/router debug routes", {
17
+ providedIn: "root",
18
+ factory() {
19
+ return createRoutes(ANALOG_ROUTE_FILES, true);
20
+ }
21
+ });
22
+ function injectDebugRoutes() {
23
+ return inject(DEBUG_ROUTES);
24
+ }
25
+ //#endregion
26
+ export { createRoutes as n, routes as r, injectDebugRoutes as t };
27
+
28
+ //# sourceMappingURL=routes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.mjs","names":[],"sources":["../../src/lib/routes.ts","../../src/lib/debug/routes.ts"],"sourcesContent":["import type { Route } from '@angular/router';\n\nimport type { RouteExport } from './models';\nimport { createRoutes as createBaseRoutes } from './route-builder';\nimport { ANALOG_ROUTE_FILES, type Files } from './route-files';\n\n/**\n * A function used to parse list of files and create configuration of routes.\n *\n * @param files\n * @returns Array of routes\n */\nexport function createRoutes(files: Files, debug = false): Route[] {\n return createBaseRoutes(\n files,\n (_filename, fileLoader) => fileLoader as () => Promise<RouteExport>,\n debug,\n );\n}\n\nexport { ANALOG_ROUTE_FILES } from './route-files';\n\nexport const routes: Route[] = createRoutes(ANALOG_ROUTE_FILES);\n","import { inject, InjectionToken } from '@angular/core';\nimport { Route } from '@angular/router';\n\nimport { ANALOG_ROUTE_FILES, createRoutes } from '../routes';\n\nexport const DEBUG_ROUTES: InjectionToken<(Route & DebugRoute)[]> =\n new InjectionToken<(Route & DebugRoute)[]>('@analogjs/router debug routes', {\n providedIn: 'root',\n factory() {\n const debugRoutes = createRoutes(ANALOG_ROUTE_FILES, true);\n\n return debugRoutes as (Route & DebugRoute)[];\n },\n });\n\nexport type DebugRoute = {\n path: string;\n filename: string;\n isLayout: boolean;\n children?: DebugRoute[];\n};\n\nexport function injectDebugRoutes(): (Route & DebugRoute)[] {\n return inject(DEBUG_ROUTES);\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,aAAa,OAAc,QAAQ,OAAgB;AACjE,QAAO,eACL,QACC,WAAW,eAAe,YAC3B,MACD;;AAKH,IAAa,SAAkB,aAAa,mBAAmB;;;ACjB/D,IAAa,eACX,IAAI,eAAuC,iCAAiC;CAC1E,YAAY;CACZ,UAAU;AAGR,SAFoB,aAAa,oBAAyB,KAAA;;CAI7D,CAAC;AASJ,SAAgB,oBAA4C;AAC1D,QAAO,OAAO,aAAa"}
package/package.json CHANGED
@@ -1,9 +1,49 @@
1
1
  {
2
2
  "name": "@analogjs/router",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Filesystem-based routing for Angular",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
7
+ "exports": {
8
+ "./package.json": {
9
+ "default": "./package.json"
10
+ },
11
+ ".": {
12
+ "types": "./types/src/index.d.ts",
13
+ "import": "./fesm2022/analogjs-router.mjs",
14
+ "default": "./fesm2022/analogjs-router.mjs"
15
+ },
16
+ "./content": {
17
+ "types": "./types/content/src/index.d.ts",
18
+ "import": "./fesm2022/analogjs-router-content.mjs",
19
+ "default": "./fesm2022/analogjs-router-content.mjs"
20
+ },
21
+ "./server": {
22
+ "types": "./types/server/src/index.d.ts",
23
+ "import": "./fesm2022/analogjs-router-server.mjs",
24
+ "default": "./fesm2022/analogjs-router-server.mjs"
25
+ },
26
+ "./server/actions": {
27
+ "types": "./types/server/actions/src/index.d.ts",
28
+ "import": "./fesm2022/analogjs-router-server-actions.mjs",
29
+ "default": "./fesm2022/analogjs-router-server-actions.mjs"
30
+ },
31
+ "./tanstack-query": {
32
+ "types": "./types/tanstack-query/src/index.d.ts",
33
+ "import": "./fesm2022/analogjs-router-tanstack-query.mjs",
34
+ "default": "./fesm2022/analogjs-router-tanstack-query.mjs"
35
+ },
36
+ "./tanstack-query/server": {
37
+ "types": "./types/tanstack-query/server/src/index.d.ts",
38
+ "import": "./fesm2022/analogjs-router-tanstack-query-server.mjs",
39
+ "default": "./fesm2022/analogjs-router-tanstack-query-server.mjs"
40
+ },
41
+ "./tokens": {
42
+ "types": "./types/tokens/src/index.d.ts",
43
+ "import": "./fesm2022/analogjs-router-tokens.mjs",
44
+ "default": "./fesm2022/analogjs-router-tokens.mjs"
45
+ }
46
+ },
7
47
  "keywords": [
8
48
  "angular",
9
49
  "router",
@@ -24,12 +64,33 @@
24
64
  "url": "https://github.com/sponsors/brandonroberts"
25
65
  },
26
66
  "peerDependencies": {
27
- "@analogjs/content": "^3.0.0-alpha.2",
67
+ "@analogjs/content": "^3.0.0-alpha.21",
28
68
  "@angular/core": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
29
- "@angular/router": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0"
69
+ "@angular/platform-server": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
70
+ "@angular/router": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
71
+ "@tanstack/angular-query-experimental": ">=5.95.0",
72
+ "schema-dts": "^2.0.0"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "@analogjs/content": {
76
+ "optional": true
77
+ },
78
+ "@angular/platform-server": {
79
+ "optional": true
80
+ },
81
+ "@tanstack/angular-query-experimental": {
82
+ "optional": true
83
+ },
84
+ "schema-dts": {
85
+ "optional": true
86
+ }
30
87
  },
31
88
  "dependencies": {
32
- "tslib": "^2.0.0"
89
+ "@standard-schema/spec": "^1.1.0",
90
+ "tslib": "^2.3.0"
91
+ },
92
+ "devDependencies": {
93
+ "@analogjs/vite-plugin-angular": "^3.0.0-alpha.21"
33
94
  },
34
95
  "ng-update": {
35
96
  "packageGroup": [
@@ -48,27 +109,6 @@
48
109
  "provenance": true
49
110
  },
50
111
  "module": "fesm2022/analogjs-router.mjs",
51
- "typings": "types/analogjs-router.d.ts",
52
- "exports": {
53
- "./package.json": {
54
- "default": "./package.json"
55
- },
56
- ".": {
57
- "types": "./types/analogjs-router.d.ts",
58
- "default": "./fesm2022/analogjs-router.mjs"
59
- },
60
- "./server": {
61
- "types": "./types/analogjs-router-server.d.ts",
62
- "default": "./fesm2022/analogjs-router-server.mjs"
63
- },
64
- "./server/actions": {
65
- "types": "./types/analogjs-router-server-actions.d.ts",
66
- "default": "./fesm2022/analogjs-router-server-actions.mjs"
67
- },
68
- "./tokens": {
69
- "types": "./types/analogjs-router-tokens.d.ts",
70
- "default": "./fesm2022/analogjs-router-tokens.mjs"
71
- }
72
- },
112
+ "typings": "types/src/index.d.ts",
73
113
  "sideEffects": false
74
- }
114
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "../../fesm2022/analogjs-router-server-actions.mjs",
3
+ "typings": "../../types/server/actions/src/index.d.ts"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "../fesm2022/analogjs-router-server.mjs",
3
+ "typings": "../types/server/src/index.d.ts"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "../fesm2022/analogjs-router-tanstack-query.mjs",
3
+ "typings": "../types/tanstack-query/src/index.d.ts"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "../../fesm2022/analogjs-router-tanstack-query-server.mjs",
3
+ "typings": "../../types/tanstack-query/server/src/index.d.ts"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "../fesm2022/analogjs-router-tokens.mjs",
3
+ "typings": "../types/tokens/src/index.d.ts"
4
+ }
@@ -0,0 +1,4 @@
1
+ export { withContentRoutes } from './lib/with-content-routes';
2
+ export { ANALOG_CONTENT_ROUTE_FILES, createContentRoutes } from './lib/routes';
3
+ export type { Files } from './lib/routes';
4
+ export { injectDebugContentRoutes } from './lib/debug/routes';
@@ -0,0 +1,10 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { Route } from '@angular/router';
3
+ export declare const DEBUG_CONTENT_ROUTES: InjectionToken<(Route & DebugRoute)[]>;
4
+ export type DebugRoute = {
5
+ path: string;
6
+ filename: string;
7
+ isLayout: boolean;
8
+ children?: DebugRoute[];
9
+ };
10
+ export declare function injectDebugContentRoutes(): (Route & DebugRoute)[];
@@ -0,0 +1,2 @@
1
+ import type { RouteExport } from '../../../src/lib/models';
2
+ export declare function toMarkdownModule(markdownFileFactory: () => Promise<string>): () => Promise<RouteExport>;
@@ -0,0 +1,8 @@
1
+ import type { Route } from '@angular/router';
2
+ import type { RouteExport } from '../../../src/lib/models';
3
+ /**
4
+ * This variable reference is replaced with a glob of all content routes.
5
+ */
6
+ export declare const ANALOG_CONTENT_ROUTE_FILES: {};
7
+ export type Files = Record<string, () => Promise<RouteExport | string>>;
8
+ export declare function createContentRoutes(files: Files, debug?: boolean): Route[];
@@ -0,0 +1,2 @@
1
+ import { type RouterFeatures } from '@angular/router';
2
+ export declare function withContentRoutes(): RouterFeatures;
@@ -0,0 +1,13 @@
1
+ import type { H3Event, H3EventContext } from 'nitro/h3';
2
+ import type { $Fetch } from 'nitro/types';
3
+ import type { NodeContext } from '../../../src/lib/route-types.js';
4
+ export type PageServerAction = {
5
+ params: H3EventContext['params'];
6
+ req: NodeContext['req'];
7
+ res: NonNullable<NodeContext['res']>;
8
+ fetch: $Fetch;
9
+ event: H3Event;
10
+ };
11
+ export declare function fail<T = object>(status: number, errors: T): Response;
12
+ export declare function json<T = object>(data: T, config?: ResponseInit): Response;
13
+ export declare function redirect(url: string, config?: number | ResponseInit): Response;