@analogjs/router 3.0.0-beta.3 → 3.0.0-beta.30

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.
@@ -1 +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`, 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 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 { injectInternalServerFetch } 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 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 { RouteExport } 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('/app/pages/') ||\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[\\\\/]pages|src[\\\\/]content)[\\\\/])|(\\.page\\.(js|ts)$)|(\\.(ts|md)$)/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$/.test(rawRoute.filename)) {\n const endpointKey = rawRoute.filename.replace(\n /\\.page\\.ts$/,\n ENDPOINT_EXTENSION,\n );\n\n const rawEndpoint = rawRoute.filename\n .replace(/\\.page\\.ts$/, '')\n .replace(/\\[\\[\\.\\.\\..+\\]\\]/, '**')\n .replace(/\\[\\.{3}.+\\]/, '**')\n .replace(/^(.*?)\\/pages/, '/pages');\n\n // Strip the route group syntax from every segment, matching how the\n // page handlers are mounted. Anchoring this to the last segment left\n // the parens in place for a route like `(auth)/sign-up`, so the\n // request went to a path no handler answered and the load resolved\n // to an empty object.\n const endpoint = (rawEndpoint || '')\n .replace(/\\./g, '/')\n .replace(/\\/\\(([^/]+)\\)/g, '/-$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 routeConfig = toRouteConfig(m.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 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"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAAA,SAAS,cAAc,OAAO;CAC1B,IAAI,CAAC,SAAS,OAAO,UAAU,UAC3B,OAAO;CAEX,MAAM,QAAQ,OAAO,eAAe,KAAK;CAIzC,IAAI,EAHuB,UAAU,QACjC,UAAU,OAAO,aACjB,OAAO,eAAe,KAAK,MAAM,OAEjC,OAAO;CAEX,OAAO,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AACrD;;;ACFA,SAAgB,eAAe,OAAc;CAC3C,OAAO,cAAc,KAAK;AAC5B;AAEA,SAAgB,gBAAgB,OAAc;CAC5C,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,OAAO,cAAc;CAGpC,OAAO,eAAe,KAAK,IAAI,CAAC,KAAK,IAAI,CAAA;AAC3C;AA+BA,IAAa,oBAAmC,OAC9C,oCAAoC;AAEtC,IAAM,0BAA0B;AAEhC,SAAgB,0BACd,SAAiB,OAAO,MAAM,GAC9B,WAA4B,OAAO,UAAU,EAAE,UAAU,KAAI,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AChD,GAAI,cACA,cACA;MACE,WAAW,EAAE;MACb,GAAG;OACF,kBAAkB;KACpB;IACN,CACF,IACD,CAAA,CACL;GACH,CAAC;EACJ,IACD;GACE,MAAM,SAAS;GACf,GAAI,QACA;IACE,UAAU,SAAS,WAAW,SAAS,WAAW,KAAA;IAClD,UAAU,YAAY,SAAS,SAAS,IAAI,OAAO;GACpD,IACD,CAAA;GACJ;EACD;EAEL,OAAO,KAAK,KAAK;CACnB;CAEA,OAAO;AACT;AAEA,SAAS,cAAc,WAAqB;CAC1C,UAAU,MAAM,GAAG,MAAK;EACtB,IAAI,WAAW,oBAAoB,EAAE,OAAO;EAC5C,IAAI,WAAW,oBAAoB,EAAE,OAAO;EAE5C,IAAI,EAAE,SAAS,SAAS,EAAE,SAAS,QACjC,WAAW,IAAI;OACV,IAAI,EAAE,SAAS,SAAS,EAAE,SAAS,QACxC,WAAW,IAAI;EAGjB,OAAO,WAAW,WAAW,IAAI;CACnC,CAAC;CAED,KAAK,MAAM,YAAY,WACrB,cAAc,SAAS,QAAQ;AAEnC;AAEA,SAAS,oBAAoB,SAAe;CAC1C,OAAO,QAAQ,WAAW,KAAK,IAAI,CAAC,CAAC,WAAW,MAAM,MAAM;AAC9D;;;;;;ACjUA,IAAa,qBAAqB,CAAA;AAUlC,IAAa,kCAET,IAAI,eAAe,2CAA2C"}
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`, 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 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';\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(\n routeMeta: RouteMeta<never> | undefined,\n): 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\n // On the server, requestContextInterceptor sends this through the\n // internal fetch when one is provided and records the response in\n // TransferState, so the client reuses it after hydration.\n return firstValueFrom(http.get(`${url.href}`));\n }\n\n return {};\n },\n };\n\n return routeConfig as RouteConfig;\n}\n\nfunction isRedirectRouteMeta(\n routeMeta: RouteMeta<never>,\n): routeMeta is RedirectRouteMeta {\n return routeMeta.redirectTo != null;\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 { RouteExport } 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('/app/pages/') ||\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[\\\\/]pages|src[\\\\/]content)[\\\\/])|(\\.page\\.(js|ts)$)|(\\.(ts|md)$)/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$/.test(rawRoute.filename)) {\n const endpointKey = rawRoute.filename.replace(\n /\\.page\\.ts$/,\n ENDPOINT_EXTENSION,\n );\n\n const rawEndpoint = rawRoute.filename\n .replace(/\\.page\\.ts$/, '')\n .replace(/\\[\\[\\.\\.\\..+\\]\\]/, '**')\n .replace(/\\[\\.{3}.+\\]/, '**')\n .replace(/^(.*?)\\/pages/, '/pages');\n\n // Strip the route group syntax from every segment, matching how the\n // page handlers are mounted. Anchoring this to the last segment left\n // the parens in place for a route like `(auth)/sign-up`, so the\n // request went to a path no handler answered and the load resolved\n // to an empty object.\n const endpoint = (rawEndpoint || '')\n .replace(/\\./g, '/')\n .replace(/\\/\\(([^/]+)\\)/g, '/-$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 != null;\n\n if (!hasModuleDefault && !hasRedirect) {\n console.warn(\n `[Analog] Missing default export at ${rawRoute.filename}`,\n );\n }\n }\n\n const routeConfig = toRouteConfig(m.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 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.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,QAAQ;AAEnC;AAEA,SAAS,oBAAoB,SAAe;CAC1C,OAAO,QAAQ,WAAW,KAAK,IAAI,CAAC,CAAC,WAAW,MAAM,MAAM;AAC9D;;;;;;ACjUA,IAAa,qBAAqB,CAAA;AAUlC,IAAa,kCAET,IAAI,eAAe,2CAA2C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/router",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.30",
4
4
  "description": "Filesystem-based routing for Angular",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -69,7 +69,7 @@
69
69
  "url": "https://github.com/sponsors/brandonroberts"
70
70
  },
71
71
  "peerDependencies": {
72
- "@analogjs/content": "3.0.0-beta.3",
72
+ "@analogjs/content": "3.0.0-beta.30",
73
73
  "@angular/core": "^20.0.0 || ^21.0.0 || ^22.0.0",
74
74
  "@angular/platform-server": "^20.0.0 || ^21.0.0 || ^22.0.0",
75
75
  "@angular/router": "^20.0.0 || ^21.0.0 || ^22.0.0",
@@ -102,11 +102,12 @@
102
102
  "@standard-schema/spec": "^1.1.0",
103
103
  "es-toolkit": "^1.45.1",
104
104
  "ofetch": "2.0.0-alpha.3",
105
+ "radix3": "^1.1.2",
105
106
  "tslib": "^2.3.0"
106
107
  },
107
108
  "devDependencies": {
108
- "@analogjs/vite-plugin-angular": "3.0.0-beta.3",
109
- "@analogjs/vitest-angular": "3.0.0-beta.3"
109
+ "@analogjs/vite-plugin-angular": "3.0.0-beta.30",
110
+ "@analogjs/vitest-angular": "3.0.0-beta.30"
110
111
  },
111
112
  "ng-update": {
112
113
  "packageGroup": [
@@ -1,2 +1,3 @@
1
+ import { type ContentFileLoader } from '@analogjs/content';
1
2
  import type { RouteExport } from '../../../src/lib/models';
2
- export declare function toMarkdownModule(markdownFileFactory: () => Promise<string>): () => Promise<RouteExport>;
3
+ export declare function toMarkdownModule(markdownFileFactory: ContentFileLoader): () => Promise<RouteExport>;
@@ -1,8 +1,9 @@
1
1
  import type { Route } from '@angular/router';
2
+ import type { ContentFileModule } from '@analogjs/content';
2
3
  import type { RouteExport } from '../../../src/lib/models';
3
4
  /**
4
5
  * This variable reference is replaced with a glob of all content routes.
5
6
  */
6
7
  export declare const ANALOG_CONTENT_ROUTE_FILES: {};
7
- export type Files = Record<string, () => Promise<RouteExport | string>>;
8
+ export type Files = Record<string, () => Promise<RouteExport | string | ContentFileModule>>;
8
9
  export declare function createContentRoutes(files: Files, debug?: boolean): Route[];
@@ -1,6 +1,8 @@
1
1
  export { provideServerContext } from './provide-server-context';
2
2
  export { render } from './render';
3
3
  export { renderStream } from './render-stream';
4
+ export { createAnalogRequestHandler, type AnalogRequestContext, type AnalogRequestHandler, type AnalogRequestOptions, } from './request-handler';
5
+ export { createAnalogHandler, type AnalogNodeHandler } from './node-handler';
4
6
  export { serverFn } from './server-fn/server-fn';
5
7
  export { createServerFnAppInjector } from './server-fn/app-injector';
6
8
  export { createServerFnEventHandler, handleServerFnRequest, } from './server-fn/event-handler';
@@ -0,0 +1,8 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { type AnalogRequestOptions } from './request-handler';
3
+ export type AnalogNodeHandler = (req: IncomingMessage, res: ServerResponse, next: (error?: unknown) => void) => void;
4
+ /**
5
+ * The Node adapter for `createAnalogRequestHandler()`: converts the request,
6
+ * writes Analog's `Response`, and calls `next` when Analog returns `null`.
7
+ */
8
+ export declare function createAnalogHandler(options?: AnalogRequestOptions): AnalogNodeHandler;
@@ -0,0 +1,30 @@
1
+ import { IncomingMessage, ServerResponse } from 'node:http';
2
+ /**
3
+ * The Node request and response behind a `Request`, when the host has them.
4
+ * They become Analog's `REQUEST`/`RESPONSE` and the page endpoint `req`/`res`.
5
+ */
6
+ export type AnalogRequestContext = {
7
+ req: IncomingMessage;
8
+ res: ServerResponse;
9
+ };
10
+ /**
11
+ * A `Response` for Analog's requests, or `null` for anything else. Without a
12
+ * context (fetch-native hosts), a Node request/response pair is created from
13
+ * the `Request`, and what the app sets on that response is folded into the
14
+ * returned `Response`.
15
+ */
16
+ export type AnalogRequestHandler = (request: Request, context?: AnalogRequestContext) => Promise<Response | null>;
17
+ export type AnalogRequestOptions = {
18
+ /**
19
+ * Serves server-side fetches that Analog doesn't handle, such as the host's
20
+ * own routes. Fetch-native hosts can pass their app's `fetch`.
21
+ */
22
+ fetch?: (request: Request) => Promise<Response>;
23
+ };
24
+ /**
25
+ * Handles Analog's requests: server functions and page endpoints, then SSR
26
+ * for GET requests outside the API prefix. Static client files are the
27
+ * host's job; serve them first, without an index fallback, or SSR answers
28
+ * asset URLs.
29
+ */
30
+ export declare function createAnalogRequestHandler(options?: AnalogRequestOptions): AnalogRequestHandler;
@@ -1,4 +1,4 @@
1
- import type { ServerFn, ServerFnConfig, ServerFnHandler, StandardSchemaV1 } from '@analogjs/router';
1
+ import type { ServerFn, ServerFnConfig, ServerFnHandler, ServerFnResult, StandardSchemaV1 } from '@analogjs/router';
2
2
  /**
3
3
  * Define a server function. Authored in a `*.server.ts` module.
4
4
  *
@@ -16,6 +16,6 @@ import type { ServerFn, ServerFnConfig, ServerFnHandler, StandardSchemaV1 } from
16
16
  * proxy that calls `/_analog/fn/<id>`; the reference still carries
17
17
  * `id`/`url`/`method` so `injectServerFn`/`ServerFnClient` can dispatch.
18
18
  */
19
- export declare function serverFn<Out>(handler: ServerFnHandler<void, Out>): ServerFn<void, Out>;
20
- export declare function serverFn<In, Out>(input: StandardSchemaV1<In>, handler: ServerFnHandler<In, Out>): ServerFn<In, Out>;
21
- export declare function serverFn<In, Out>(config: ServerFnConfig<In>, handler: ServerFnHandler<In, Out>): ServerFn<In, Out>;
19
+ export declare function serverFn<Out>(handler: ServerFnHandler<void, Out>): ServerFn<void, ServerFnResult<Out>>;
20
+ export declare function serverFn<In, Out>(input: StandardSchemaV1<In>, handler: ServerFnHandler<In, Out>): ServerFn<In, ServerFnResult<Out>>;
21
+ export declare function serverFn<In, Out>(config: ServerFnConfig<In>, handler: ServerFnHandler<In, Out>): ServerFn<In, ServerFnResult<Out>>;
@@ -0,0 +1,26 @@
1
+ import type { ApplicationConfig } from '@angular/core';
2
+ import type { ServerContext } from '@analogjs/router/tokens';
3
+ export type PageEndpointModule = {
4
+ load?: (ctx: unknown) => unknown;
5
+ action?: (ctx: unknown) => unknown;
6
+ };
7
+ export type ServerRender = (url: string, document: string, context: ServerContext) => Promise<string | ReadableStream<Uint8Array>>;
8
+ /** Everything the request handler needs from the app, as lazy imports. */
9
+ export type AnalogServerManifest = {
10
+ apiPrefix: string;
11
+ /** The HTML document to render around the app, for a request URL. */
12
+ template: (url: string) => Promise<string>;
13
+ /** The app's SSR entry (`main.server.ts` default export). */
14
+ render: () => Promise<ServerRender>;
15
+ /** The app's server config (`app.config.server.ts`). */
16
+ config: () => Promise<ApplicationConfig>;
17
+ /** Every `*.server.ts`, imported so server functions register. */
18
+ serverFnModules: (() => Promise<unknown>)[];
19
+ /** Page endpoint route → `*.server.ts` module. */
20
+ pageEndpoints: Record<string, () => Promise<PageEndpointModule>>;
21
+ };
22
+ /**
23
+ * Filled in at build time by the platform's server build, the same way the
24
+ * router plugin fills in `ANALOG_ROUTE_FILES`. Empty without it.
25
+ */
26
+ export declare const ANALOG_SERVER_MANIFEST: Partial<AnalogServerManifest>;
@@ -17,7 +17,7 @@ export type { AnalogJsonLdDocument } from './lib/json-ld';
17
17
  export { injectServerFn, injectServerFnMutation, provideServerFnClient, ServerFnClient, } from './lib/server-fn/inject-server-fn';
18
18
  export { createServerFnRef, type ServerFnRefConfig, } from './lib/server-fn/server-fn-ref';
19
19
  export { SERVER_FN_DISPATCHER, type ServerFnDispatcher, } from './lib/server-fn/dispatcher';
20
- export type { ServerFn, ServerFnConfig, ServerFnContext, ServerFnDef, ServerFnHandler, ServerFnMethod, StandardSchemaV1, } from './lib/server-fn/types';
20
+ export type { ServerFn, ServerFnConfig, ServerFnContext, ServerFnDef, ServerFnHandler, ServerFnMethod, ServerFnResult, StandardSchemaV1, } from './lib/server-fn/types';
21
21
  export { toRoute } from './lib/to-route';
22
22
  export { LinkTo, type LinkToInput } from './lib/link-to.directive';
23
23
  export type { AnalogRouteTable, AnalogRoutePath, RouteDataOutput, RouteLoadOutput, RoutePathOptions, RouteResourcesOutput, } from './lib/to-route';
@@ -1,30 +1,35 @@
1
1
  import { Type } from '@angular/core';
2
- import { CanActivateChildFn, CanActivateFn, CanDeactivateFn, CanMatchFn, DeprecatedGuard, ResolveFn, Route } from '@angular/router';
2
+ import { ActivatedRouteSnapshot, CanActivateChildFn, CanActivateFn, CanDeactivateFn, CanMatchFn, DeprecatedGuard, MaybeAsync, RedirectCommand, Route, RouterStateSnapshot } from '@angular/router';
3
3
  import { AnalogJsonLdDocument } from './json-ld';
4
4
  import { MetaTag } from './meta-tags';
5
+ import type { AnalogRoutePath, RouteActivatedRouteSnapshot, RouteResourceContext, RouteResourceResult } from './to-route';
5
6
  type OmittedRouteProps = 'path' | 'matcher' | 'component' | 'loadComponent' | 'children' | 'loadChildren' | 'canLoad' | 'outlet';
6
7
  export type RouteConfig = Omit<Route, OmittedRouteProps>;
7
- export interface DefaultRouteMeta extends Omit<Route, OmittedRouteProps | keyof RedirectRouteMeta> {
8
+ type RouteContextFor<P> = [P] extends [never] ? never : [P] extends [AnalogRoutePath] ? RouteResourceContext<P> : RouteResourceContext;
9
+ type RouteSnapshotFor<P> = [P] extends [never] ? never : [P] extends [AnalogRoutePath] ? RouteActivatedRouteSnapshot<P> : ActivatedRouteSnapshot;
10
+ type RouteResolveFn<T, P extends AnalogRoutePath | undefined = undefined> = (route: RouteSnapshotFor<P>, state: RouterStateSnapshot) => MaybeAsync<T | RedirectCommand>;
11
+ export interface DefaultRouteMeta<P extends AnalogRoutePath | undefined = undefined> extends Omit<Route, OmittedRouteProps | keyof RedirectRouteMeta | 'resolve' | 'resources' | 'title'> {
8
12
  canActivate?: CanActivateFn[] | DeprecatedGuard[];
9
13
  canActivateChild?: CanActivateChildFn[];
10
14
  canDeactivate?: CanDeactivateFn<unknown>[];
11
15
  canMatch?: CanMatchFn[];
12
16
  resolve?: {
13
- [key: string | symbol]: ResolveFn<unknown>;
17
+ [key: string | symbol]: RouteResolveFn<unknown, P>;
14
18
  };
15
- title?: string | ResolveFn<string>;
16
- meta?: MetaTag[] | ResolveFn<MetaTag[]>;
17
- jsonLd?: AnalogJsonLdDocument | ResolveFn<AnalogJsonLdDocument | undefined>;
19
+ resources?: (ctx: RouteContextFor<P>) => RouteResourceResult | Promise<RouteResourceResult>;
20
+ title?: string | RouteResolveFn<string, P>;
21
+ meta?: MetaTag[] | RouteResolveFn<MetaTag[], P>;
22
+ jsonLd?: AnalogJsonLdDocument | RouteResolveFn<AnalogJsonLdDocument | undefined, P>;
18
23
  }
19
24
  export interface RedirectRouteMeta {
20
- redirectTo: string;
25
+ redirectTo: NonNullable<Route['redirectTo']>;
21
26
  pathMatch?: Route['pathMatch'];
22
27
  }
23
- export type RouteMeta = (DefaultRouteMeta & {
28
+ export type RouteMeta<P extends AnalogRoutePath | undefined = undefined> = (DefaultRouteMeta<P> & {
24
29
  redirectTo?: never;
25
30
  }) | RedirectRouteMeta;
26
31
  export type RouteExport = {
27
32
  default: Type<unknown>;
28
- routeMeta?: RouteMeta;
33
+ routeMeta?: RouteMeta<never>;
29
34
  };
30
35
  export {};
@@ -1,2 +1,2 @@
1
1
  import { RouteConfig, RouteMeta } from './models';
2
- export declare function toRouteConfig(routeMeta: RouteMeta | undefined): RouteConfig;
2
+ export declare function toRouteConfig(routeMeta: RouteMeta<never> | undefined): RouteConfig;
@@ -46,6 +46,7 @@ export type ServerFn<In, Out> = ((input: In) => Promise<Out>) & {
46
46
  readonly url: string;
47
47
  readonly method: ServerFnMethod;
48
48
  };
49
+ export type ServerFnResult<Out> = Exclude<Out, Response>;
49
50
  export type ServerFnHandler<In, Out> = (input: In, context: ServerFnContext) => Promise<Out> | Out;
50
51
  export interface ServerFnDef {
51
52
  id: string;
@@ -1,4 +1,5 @@
1
- import { type ActivatedRoute, type ResolveFn } from '@angular/router';
1
+ import type { Resource, Signal, WritableResource } from '@angular/core';
2
+ import { type ActivatedRoute, type ActivatedRouteSnapshot, type Data as RouterData, type MaybeAsync, type Params, type RedirectCommand, type Route } from '@angular/router';
2
3
  /**
3
4
  * Typed route path utilities for Analog.
4
5
  *
@@ -94,22 +95,29 @@ type RouteResolvers<Meta> = Meta extends {
94
95
  resolve?: infer Resolvers;
95
96
  } ? MetaObject<Resolvers> : EmptyObject;
96
97
  type ResolvedRouteData<Meta> = {
97
- [K in keyof RouteResolvers<Meta>]: RouteResolvers<Meta>[K] extends ResolveFn<infer T> ? T : unknown;
98
+ [K in keyof RouteResolvers<Meta>]: RouteResolvers<Meta>[K] extends (...args: never[]) => MaybeAsync<infer T> ? Exclude<T, RedirectCommand> : unknown;
98
99
  };
99
100
  type RouteMetaData<Meta> = Merge<StaticRouteData<Meta>, ResolvedRouteData<Meta>>;
100
101
  type InheritedRouteData<Metas, Data = EmptyObject> = Metas extends [
101
102
  infer Meta,
102
103
  ...infer Rest
103
104
  ] ? InheritedRouteData<Rest, Merge<Data, RouteMetaData<Exclude<Meta, {
104
- redirectTo: string;
105
+ redirectTo: NonNullable<Route['redirectTo']>;
105
106
  }>>>> : Data;
106
107
  type RouteResourceMap<Meta> = Meta extends {
107
108
  resources?: (ctx: never) => infer R;
108
109
  } ? Awaited<R> extends Record<PropertyKey, unknown> ? Awaited<R> : EmptyObject : EmptyObject;
110
+ type InheritedRouteResources<Metas, Resources = EmptyObject> = Metas extends [
111
+ infer Meta,
112
+ ...infer Rest
113
+ ] ? InheritedRouteResources<Rest, Merge<Resources, RouteResourceMap<Exclude<Meta, {
114
+ redirectTo: NonNullable<Route['redirectTo']>;
115
+ }>>>> : Resources;
116
+ type LayoutRouteMetas<P extends keyof AnalogRouteTable> = AnalogRouteTable[P] extends {
117
+ layoutRouteMeta: infer Metas extends unknown[];
118
+ } ? Metas : [];
109
119
  type PageRouteMetas<P extends keyof AnalogRouteTable> = [
110
- ...(AnalogRouteTable[P] extends {
111
- layoutRouteMeta: infer Metas extends unknown[];
112
- } ? Metas : []),
120
+ ...LayoutRouteMetas<P>,
113
121
  ...(AnalogRouteTable[P] extends {
114
122
  routeMeta: infer Meta;
115
123
  } ? [Meta] : [])
@@ -134,16 +142,47 @@ export type RouteLoadOutput<P extends string> = P extends keyof AnalogRouteTable
134
142
  * results from its layouts and the page, and the page's server `load` result.
135
143
  */
136
144
  export type RouteDataOutput<P extends string> = P extends keyof AnalogRouteTable ? Simplify<Omit<InheritedRouteData<PageRouteMetas<P>>, 'load'> & PageLoadData<P>> : Record<string, unknown>;
145
+ type FallbackResourceResult = Record<string, Resource<unknown> & Pick<WritableResource<unknown>, 'reload'>>;
146
+ type PropOr<T, K extends PropertyKey, Fallback> = K extends keyof T ? NonNullable<T[K]> : Fallback;
147
+ /**
148
+ * Expected return type of `routeMeta.resources`, matching `@angular/router`'s
149
+ * `ResourceResult` across Angular versions with and without router resources.
150
+ */
151
+ export type RouteResourceResult = PropOr<ActivatedRoute, 'resources', FallbackResourceResult>;
152
+ interface FallbackResourceContext {
153
+ params: Signal<Params>;
154
+ queryParams: Signal<Params>;
155
+ fragment: Signal<string | null>;
156
+ data: Signal<RouterData>;
157
+ resources: Signal<RouteResourceResult>;
158
+ }
159
+ type ExtractResourceContext<T> = 'resources' extends keyof T ? PropOr<T, 'resources', never> extends (ctx: infer Ctx) => unknown ? Ctx : FallbackResourceContext : FallbackResourceContext;
160
+ type BaseResourceContext = ExtractResourceContext<Route>;
137
161
  /**
138
- * Resources for a page route: `routeMeta.resources` results defined on the page.
162
+ * Resources for a page route: `routeMeta.resources` results from its ancestor
163
+ * layouts and the page, with nearer keys overriding outer keys.
139
164
  */
140
- export type RouteResourcesOutput<P extends string> = P extends keyof AnalogRouteTable ? AnalogRouteTable[P] extends {
141
- routeMeta: infer Meta;
142
- } ? Simplify<RouteResourceMap<Exclude<Meta, {
143
- redirectTo: string;
144
- }>>> : EmptyObject : ActivatedRoute extends {
145
- resources: infer Resources;
146
- } ? Resources : EmptyObject;
165
+ export type RouteResourcesOutput<P extends string> = P extends keyof AnalogRouteTable ? Simplify<InheritedRouteResources<PageRouteMetas<P>>> : RouteResourceResult;
166
+ /**
167
+ * `ResourceContext` narrowed with typed `params`, `queryParams`, `data`
168
+ * (ancestor layout data/resolvers plus the page's server `load`), and
169
+ * `resources` (inherited ancestor layout resources) from the route table.
170
+ */
171
+ export type RouteResourceContext<P extends string = string> = Omit<BaseResourceContext, 'params' | 'queryParams' | 'data' | 'resources'> & {
172
+ params: Signal<P extends keyof AnalogRouteTable ? RouteParamsOutput<P> : Params>;
173
+ queryParams: Signal<P extends keyof AnalogRouteTable ? RouteQueryOutput<P> : Params>;
174
+ data: Signal<P extends keyof AnalogRouteTable ? Simplify<Omit<InheritedRouteData<LayoutRouteMetas<P>>, 'load'> & PageLoadData<P>> : RouterData>;
175
+ resources: Signal<P extends keyof AnalogRouteTable ? Simplify<InheritedRouteResources<LayoutRouteMetas<P>>> : RouteResourceResult>;
176
+ };
177
+ /**
178
+ * `ActivatedRouteSnapshot` narrowed with typed `params`, `queryParams`, and
179
+ * inherited ancestor layout `data` for resolvers on `RouteMeta<P>`.
180
+ */
181
+ export type RouteActivatedRouteSnapshot<P extends string = string> = Omit<ActivatedRouteSnapshot, 'params' | 'queryParams' | 'data'> & {
182
+ params: P extends keyof AnalogRouteTable ? RouteParamsOutput<P> : Params;
183
+ queryParams: P extends keyof AnalogRouteTable ? RouteQueryOutput<P> : Params;
184
+ data: P extends keyof AnalogRouteTable ? Simplify<Omit<InheritedRouteData<LayoutRouteMetas<P>>, 'load'>> : RouterData;
185
+ };
147
186
  type SplitPath<S extends string> = S extends '' ? [] : S extends `${infer Head}/${infer Tail}` ? [Head, ...SplitPath<Tail>] : [S];
148
187
  type Segments<P extends string> = P extends `/${infer Rest}` ? SplitPath<Rest> : SplitPath<P>;
149
188
  type JoinPath<S extends string[]> = S extends [