@analogjs/router 3.0.0-alpha.95 → 3.0.0-alpha.97

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`, `routeJsonLd`, generated manifest).\n *\n * @example\n * ```ts\n * import type { WebPage, WithContext } from 'schema-dts';\n *\n * export const routeMeta = {\n * jsonLd: {\n * '@context': 'https://schema.org',\n * '@type': 'WebPage',\n * name: 'Products',\n * } satisfies WithContext<WebPage>,\n * };\n * ```\n */\nexport type AnalogJsonLdDocument =\n | WithContext<Thing>\n | Graph\n | WithContext<Thing>[];\n\nexport const ROUTE_JSON_LD_KEY: unique symbol = Symbol(\n '@analogjs/router Route JSON-LD Key',\n);\nconst JSON_LD_SCRIPT_SELECTOR = 'script[data-analog-json-ld]';\n\nexport function updateJsonLdOnRouteChange(\n router: Router = inject(Router),\n document: Document | null = inject(DOCUMENT, { optional: true }),\n): void {\n if (!document) {\n return;\n }\n\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n const entries = getJsonLdEntries(router.routerState.snapshot.root);\n applyJsonLdToDocument(document, entries);\n });\n}\n\nexport function serializeJsonLd(entry: JsonLdObject): string | null {\n try {\n return JSON.stringify(entry)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n } catch {\n return null;\n }\n}\n\nfunction getJsonLdEntries(route: ActivatedRouteSnapshot): JsonLdObject[] {\n const entries: JsonLdObject[] = [];\n let currentRoute: ActivatedRouteSnapshot | null = route;\n\n while (currentRoute) {\n entries.push(...normalizeJsonLd(currentRoute.data[ROUTE_JSON_LD_KEY]));\n currentRoute = currentRoute.firstChild;\n }\n\n return entries;\n}\n\nfunction applyJsonLdToDocument(\n document: Document,\n entries: JsonLdObject[],\n): void {\n document.querySelectorAll(JSON_LD_SCRIPT_SELECTOR).forEach((element) => {\n element.remove();\n });\n\n if (entries.length === 0) {\n return;\n }\n\n const head = document.head || document.getElementsByTagName('head')[0];\n if (!head) {\n return;\n }\n\n entries.forEach((entry, index) => {\n const serialized = serializeJsonLd(entry);\n if (!serialized) {\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.setAttribute('data-analog-json-ld', 'true');\n script.setAttribute('data-analog-json-ld-index', String(index));\n script.textContent = serialized;\n head.appendChild(script);\n });\n}\n","import { inject } from '@angular/core';\nimport { Meta, MetaDefinition as NgMetaTag } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router';\nimport { filter } from 'rxjs/operators';\n\nexport const ROUTE_META_TAGS_KEY: unique symbol = Symbol(\n '@analogjs/router Route Meta Tags Key',\n);\n\nconst CHARSET_KEY = 'charset';\nconst HTTP_EQUIV_KEY = 'httpEquiv';\n// httpEquiv selector key needs to be in kebab case format\nconst HTTP_EQUIV_SELECTOR_KEY = 'http-equiv';\nconst NAME_KEY = 'name';\nconst PROPERTY_KEY = 'property';\nconst CONTENT_KEY = 'content';\nconst ITEMPROP_KEY = 'itemprop';\n\nexport type MetaTag =\n | (CharsetMetaTag & ExcludeRestMetaTagKeys<typeof CHARSET_KEY>)\n | (HttpEquivMetaTag & ExcludeRestMetaTagKeys<typeof HTTP_EQUIV_KEY>)\n | (NameMetaTag & ExcludeRestMetaTagKeys<typeof NAME_KEY>)\n | (PropertyMetaTag & ExcludeRestMetaTagKeys<typeof PROPERTY_KEY>)\n | (ItempropMetaTag & ExcludeRestMetaTagKeys<typeof ITEMPROP_KEY>);\n\ntype CharsetMetaTag = { [CHARSET_KEY]: string };\ntype HttpEquivMetaTag = { [HTTP_EQUIV_KEY]: string; [CONTENT_KEY]: string };\ntype NameMetaTag = { [NAME_KEY]: string; [CONTENT_KEY]: string };\ntype PropertyMetaTag = { [PROPERTY_KEY]: string; [CONTENT_KEY]: string };\ntype ItempropMetaTag = { [ITEMPROP_KEY]: string; [CONTENT_KEY]: string };\n\ntype MetaTagKey =\n | typeof CHARSET_KEY\n | typeof HTTP_EQUIV_KEY\n | typeof NAME_KEY\n | typeof PROPERTY_KEY\n | typeof ITEMPROP_KEY;\ntype ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {\n [K in Exclude<MetaTagKey, Key>]?: never;\n};\n\ntype MetaTagSelector =\n | typeof CHARSET_KEY\n | `${\n | typeof HTTP_EQUIV_SELECTOR_KEY\n | typeof NAME_KEY\n | typeof PROPERTY_KEY\n | typeof ITEMPROP_KEY}=\"${string}\"`;\ntype MetaTagMap = Record<MetaTagSelector, MetaTag>;\n\nexport function updateMetaTagsOnRouteChange(\n router: Router = inject(Router),\n metaService: Meta = inject(Meta),\n): void {\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n const metaTagMap = getMetaTagMap(router.routerState.snapshot.root);\n for (const metaTagSelector in metaTagMap) {\n const metaTag = metaTagMap[\n metaTagSelector as MetaTagSelector\n ] as NgMetaTag;\n metaService.updateTag(metaTag, metaTagSelector);\n }\n });\n}\n\nfunction getMetaTagMap(route: ActivatedRouteSnapshot): MetaTagMap {\n const metaTagMap = {} as MetaTagMap;\n let currentRoute: ActivatedRouteSnapshot | null = route;\n\n while (currentRoute) {\n const metaTags: MetaTag[] = currentRoute.data[ROUTE_META_TAGS_KEY] ?? [];\n for (const metaTag of metaTags) {\n metaTagMap[getMetaTagSelector(metaTag)] = metaTag;\n }\n\n currentRoute = currentRoute.firstChild;\n }\n\n return metaTagMap;\n}\n\nfunction getMetaTagSelector(metaTag: MetaTag): MetaTagSelector {\n if (metaTag.name) {\n return `${NAME_KEY}=\"${metaTag.name}\"`;\n }\n\n if (metaTag.property) {\n return `${PROPERTY_KEY}=\"${metaTag.property}\"`;\n }\n\n if (metaTag.httpEquiv) {\n return `${HTTP_EQUIV_SELECTOR_KEY}=\"${metaTag.httpEquiv}\"`;\n }\n\n if (metaTag.itemprop) {\n return `${ITEMPROP_KEY}=\"${metaTag.itemprop}\"`;\n }\n\n return CHARSET_KEY;\n}\n","export const ANALOG_META_KEY: unique symbol = Symbol(\n '@analogjs/router Analog Route Metadata Key',\n);\n\n/**\n * This variable reference is replaced with a glob of all route endpoints.\n */\nexport const ANALOG_PAGE_ENDPOINTS: Record<string, () => Promise<unknown>> = {};\n","import type { ActivatedRouteSnapshot, Route } from '@angular/router';\nimport { injectBaseURL, injectAPIPrefix } from '../../tokens/src/index.js';\n\nimport { ANALOG_META_KEY } from './endpoints';\n\nexport function injectRouteEndpointURL(route: ActivatedRouteSnapshot): URL {\n const routeConfig = route.routeConfig as Route & {\n [ANALOG_META_KEY]: { endpoint: string; endpointKey: string };\n };\n\n const apiPrefix = injectAPIPrefix();\n const baseUrl = injectBaseURL();\n const { queryParams, fragment: hash, params, parent } = route;\n const segment = parent?.url.map((segment) => segment.path).join('/') || '';\n const url = new URL(\n '',\n import.meta.env['VITE_ANALOG_PUBLIC_BASE_URL'] ||\n baseUrl ||\n (typeof window !== 'undefined' && window.location.origin\n ? window.location.origin\n : ''),\n );\n url.pathname = `${\n url.pathname.endsWith('/') ? url.pathname : url.pathname + '/'\n }${apiPrefix}/_analog${routeConfig[ANALOG_META_KEY].endpoint}`;\n url.search = `${new URLSearchParams(queryParams).toString()}`;\n url.hash = hash ?? '';\n\n Object.keys(params).forEach((param) => {\n url.pathname = url.pathname.replace(`[${param}]`, params[param]);\n });\n url.pathname = url.pathname.replace('**', segment);\n\n return url;\n}\n","import { inject } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport type { Route } from '@angular/router';\nimport { firstValueFrom } from 'rxjs';\nimport {\n injectInternalServerFetch,\n type ServerInternalFetch,\n} from '../../tokens/src/index.js';\n\nimport {\n DefaultRouteMeta,\n RedirectRouteMeta,\n RouteConfig,\n RouteMeta,\n} from './models';\nimport { ROUTE_JSON_LD_KEY, isJsonLdObject } from './json-ld';\nimport { ROUTE_META_TAGS_KEY } from './meta-tags';\nimport { ANALOG_PAGE_ENDPOINTS, ANALOG_META_KEY } from './endpoints';\nimport { injectRouteEndpointURL } from './inject-route-endpoint-url';\n\nexport function toRouteConfig(routeMeta: RouteMeta | undefined): RouteConfig {\n if (routeMeta && isRedirectRouteMeta(routeMeta)) {\n return routeMeta;\n }\n\n const defaultMeta: DefaultRouteMeta = (routeMeta ?? {}) as DefaultRouteMeta;\n const { meta, jsonLd, ...routeConfig } = defaultMeta;\n\n if (Array.isArray(meta)) {\n routeConfig.data = { ...routeConfig.data, [ROUTE_META_TAGS_KEY]: meta };\n } else if (typeof meta === 'function') {\n routeConfig.resolve = {\n ...routeConfig.resolve,\n [ROUTE_META_TAGS_KEY]: meta,\n };\n }\n\n if (Array.isArray(jsonLd) || isJsonLdObject(jsonLd)) {\n routeConfig.data = { ...routeConfig.data, [ROUTE_JSON_LD_KEY]: jsonLd };\n } else if (typeof jsonLd === 'function') {\n routeConfig.resolve = {\n ...routeConfig.resolve,\n [ROUTE_JSON_LD_KEY]: jsonLd,\n };\n }\n\n routeConfig.runGuardsAndResolvers =\n routeConfig.runGuardsAndResolvers ?? 'paramsOrQueryParamsChange';\n routeConfig.resolve = {\n ...routeConfig.resolve,\n load: async (route) => {\n const routeConfig = route.routeConfig as Route & {\n [ANALOG_META_KEY]: { endpoint: string; endpointKey: string };\n };\n\n // Content routes (from .md files in the pages directory) do not have\n // ANALOG_META_KEY — it is only set on page routes (.page.ts) in\n // route-builder.ts. The optional chain avoids a runtime crash when\n // the router resolves a content route during SSR / prerendering.\n if (ANALOG_PAGE_ENDPOINTS[routeConfig[ANALOG_META_KEY]?.endpointKey]) {\n const http = inject(HttpClient);\n const url = injectRouteEndpointURL(route);\n const internalFetch = injectInternalServerFetch();\n\n if (internalFetch) {\n return internalFetch(`${url.pathname}${url.search}`);\n }\n\n const globalFetch = (\n globalThis as unknown as { $fetch?: ServerInternalFetch }\n ).$fetch;\n if (!!import.meta.env['VITE_ANALOG_PUBLIC_BASE_URL'] && globalFetch) {\n return globalFetch(`${url.pathname}${url.search}`);\n }\n\n return firstValueFrom(http.get(`${url.href}`));\n }\n\n return {};\n },\n };\n\n return routeConfig;\n}\n\nfunction isRedirectRouteMeta(\n routeMeta: RouteMeta,\n): routeMeta is RedirectRouteMeta {\n return !!routeMeta.redirectTo;\n}\n","export const ENDPOINT_EXTENSION = '.server.ts';\nexport const APP_DIR = 'src/app';\n","import { UrlSegment } from '@angular/router';\nimport type { Route } from '@angular/router';\nimport type { UrlMatcher } from '@angular/router';\n\nimport type { DefaultRouteMeta, RouteExport, RouteMeta } from './models';\nimport { toRouteConfig } from './route-config';\nimport { ENDPOINT_EXTENSION } from './constants';\nimport { ANALOG_META_KEY } from './endpoints';\n\nexport type RouteModuleFactory = () => Promise<RouteExport>;\n\nexport type RouteModuleResolver<TFile> = (\n filename: string,\n fileLoader: () => Promise<TFile>,\n) => RouteModuleFactory;\n\ntype RawRoute = {\n filename: string | null;\n rawSegment: string;\n ancestorRawSegments: string[];\n segment: string;\n level: number;\n children: RawRoute[];\n};\n\ntype RawRouteMap = Record<string, RawRoute>;\ntype RawRouteByLevelMap = Record<number, RawRouteMap>;\n\nexport function createRoutes<TFile>(\n files: Record<string, () => Promise<TFile>>,\n resolveModule: RouteModuleResolver<TFile>,\n debug = false,\n): Route[] {\n const filenames = Object.keys(files).sort((a, b) => {\n const aPriority = getCollisionPriority(a);\n const bPriority = getCollisionPriority(b);\n\n return aPriority - bPriority;\n });\n\n if (filenames.length === 0) {\n return [];\n }\n\n const rawRoutesByLevelMap = filenames.reduce((acc, filename) => {\n const rawPath = toRawPath(filename);\n const rawSegments = rawPath.split('/');\n const level = rawSegments.length - 1;\n const rawSegment = rawSegments[level];\n const ancestorRawSegments = rawSegments.slice(0, level);\n\n const existing = acc[level]?.[rawPath];\n if (existing?.filename && existing.filename !== filename) {\n const existingPriority = getCollisionPriority(existing.filename);\n const nextPriority = getCollisionPriority(filename);\n const shouldKeepExisting = existingPriority < nextPriority;\n const chosenFilename = shouldKeepExisting ? existing.filename : filename;\n\n if (import.meta.env.DEV) {\n console.warn(\n `[Analog] Route files \"${existing.filename}\" and \"${filename}\" ` +\n `resolve to the same route path \"${rawPath}\". ` +\n `Only \"${chosenFilename}\" will be used.`,\n );\n }\n\n if (shouldKeepExisting) {\n return acc;\n }\n }\n\n return {\n ...acc,\n [level]: {\n ...acc[level],\n [rawPath]: {\n filename,\n rawSegment,\n ancestorRawSegments,\n segment: toSegment(rawSegment),\n level,\n children: [],\n },\n },\n };\n }, {} as RawRouteByLevelMap);\n\n const allLevels = Object.keys(rawRoutesByLevelMap).map(Number);\n const maxLevel = Math.max(...allLevels);\n\n for (let level = maxLevel; level > 0; level--) {\n const rawRoutesMap = rawRoutesByLevelMap[level];\n const rawPaths = Object.keys(rawRoutesMap);\n\n for (const rawPath of rawPaths) {\n const rawRoute = rawRoutesMap[rawPath];\n const parentRawPath = rawRoute.ancestorRawSegments.join('/');\n const parentRawSegmentIndex = rawRoute.ancestorRawSegments.length - 1;\n const parentRawSegment =\n rawRoute.ancestorRawSegments[parentRawSegmentIndex];\n\n rawRoutesByLevelMap[level - 1] ||= {};\n rawRoutesByLevelMap[level - 1][parentRawPath] ||= {\n filename: null,\n rawSegment: parentRawSegment,\n ancestorRawSegments: rawRoute.ancestorRawSegments.slice(\n 0,\n parentRawSegmentIndex,\n ),\n segment: toSegment(parentRawSegment),\n level: level - 1,\n children: [],\n };\n\n rawRoutesByLevelMap[level - 1][parentRawPath].children.push(rawRoute);\n }\n }\n\n const rootRawRoutesMap = rawRoutesByLevelMap[0];\n const rawRoutes = Object.keys(rootRawRoutesMap).map(\n (segment) => rootRawRoutesMap[segment],\n );\n sortRawRoutes(rawRoutes);\n\n return toRoutes(rawRoutes, files, resolveModule, debug);\n}\n\nfunction getCollisionPriority(filename: string): number {\n if (\n filename.includes('/src/app/pages/') ||\n filename.includes('/src/app/routes/') ||\n filename.includes('/app/pages/') ||\n filename.includes('/app/routes/') ||\n filename.includes('/src/content/')\n ) {\n return 0;\n }\n\n return 1;\n}\n\n/**\n * Strips directory prefixes and file extensions from a route filename to\n * produce the raw path used for route segment construction.\n *\n * The regex mirrors `filenameToRoutePath` in route-manifest.ts — changes\n * here must be kept in sync with that function. The first alternation\n * strips everything up to and including the first /routes/, /pages/, or\n * /content/ segment, which handles both app-local and additional directory\n * paths (e.g. `additionalPagesDirs`, `additionalContentDirs`).\n */\nfunction toRawPath(filename: string): string {\n return filename\n .replace(\n /^(?:[a-zA-Z]:[\\\\/])?(.*?)[\\\\/](?:routes|pages|content)[\\\\/]|(?:[\\\\/](?:app[\\\\/](?:routes|pages)|src[\\\\/]content)[\\\\/])|(\\.page\\.(js|ts|analog|ag)$)|(\\.(ts|md|analog|ag)$)/g,\n '',\n )\n .replace(/\\[\\[\\.\\.\\.([^\\]]+)\\]\\]/g, '(opt-$1)')\n .replace(/\\[\\.{3}.+\\]/, '**')\n .replace(/\\[([^\\]]+)\\]/g, ':$1');\n}\n\nfunction toSegment(rawSegment: string): string {\n return rawSegment\n .replace(/\\(.*?\\)/g, '')\n .replace(/(^|[./])index(?=[./]|$)/g, '$1')\n .replace(/\\.|\\/+/g, '/')\n .replace(/^\\/+|\\/+$/g, '');\n}\n\nfunction createOptionalCatchAllMatcher(paramName: string): UrlMatcher {\n return (segments) => {\n if (segments.length === 0) {\n return null;\n }\n const joined = segments.map((s) => s.path).join('/');\n return {\n consumed: segments,\n posParams: { [paramName]: new UrlSegment(joined, {}) },\n };\n };\n}\n\nfunction toRoutes<TFile>(\n rawRoutes: RawRoute[],\n files: Record<string, () => Promise<TFile>>,\n resolveModule: RouteModuleResolver<TFile>,\n debug = false,\n): Route[] {\n const routes: Route[] = [];\n\n for (const rawRoute of rawRoutes) {\n const children: Route[] | undefined =\n rawRoute.children.length > 0\n ? toRoutes(rawRoute.children, files, resolveModule, debug)\n : undefined;\n let module: RouteModuleFactory | undefined;\n let analogMeta: { endpoint: string; endpointKey: string } | undefined;\n\n if (rawRoute.filename) {\n if (!debug) {\n module = resolveModule(rawRoute.filename, files[rawRoute.filename]);\n }\n\n if (/\\.page\\.(ts|analog|ag)$/.test(rawRoute.filename)) {\n const endpointKey = rawRoute.filename.replace(\n /\\.page\\.(ts|analog|ag)$/,\n ENDPOINT_EXTENSION,\n );\n\n const rawEndpoint = rawRoute.filename\n .replace(/\\.page\\.(ts|analog|ag)$/, '')\n .replace(/\\[\\[\\.\\.\\..+\\]\\]/, '**')\n .replace(/\\[\\.{3}.+\\]/, '**')\n .replace(/^(.*?)\\/pages/, '/pages');\n\n // 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 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"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAAA,SAAS,cAAc,OAAO;AAC1B,KAAI,CAAC,SAAS,OAAO,UAAU,SAC3B,QAAO;CAEX,MAAM,QAAQ,OAAO,eAAe,MAAM;AAI1C,KAAI,EAHuB,UAAU,QACjC,UAAU,OAAO,aACjB,OAAO,eAAe,MAAM,KAAK,MAEjC,QAAO;AAEX,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK;;;;ACDrD,SAAgB,eAAe,OAAc;AAC3C,QAAO,cAAc,MAAM;;AAG7B,SAAgB,gBAAgB,OAAc;AAC5C,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,OAAO,eAAe;AAGrC,QAAO,eAAe,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE;;AAgC7C,IAAa,oBAAmC,OAC9C,qCACD;AACD,IAAM,0BAA0B;AAEhC,SAAgB,0BACd,SAAiB,OAAO,OAAO,EAC/B,WAA4B,OAAO,UAAU,EAAE,UAAU,MAAM,CAAC,EAAA;AAEhE,KAAI,CAAC,SACH;AAGF,QAAO,OACJ,KAAK,QAAQ,UAAU,iBAAiB,cAAc,CAAC,CACvD,gBAAe;AAEd,wBAAsB,UADN,iBAAiB,OAAO,YAAY,SAAS,KAAK,CAC1B;GACxC;;AAGN,SAAgB,gBAAgB,OAAmB;AACjD,KAAI;AACF,SAAO,KAAK,UAAU,MAAM,CACzB,QAAQ,MAAM,UAAU,CACxB,QAAQ,MAAM,UAAU,CACxB,QAAQ,MAAM,UAAU,CACxB,QAAQ,WAAW,UAAU,CAC7B,QAAQ,WAAW,UAAU;SAC1B;AACN,SAAO;;;AAIX,SAAS,iBAAiB,OAA6B;CACrD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cAAc,WAAqB;AAC1C,WAAU,MAAM,GAAG,MAAK;EACtB,IAAI,WAAW,oBAAoB,EAAE,QAAQ;EAC7C,IAAI,WAAW,oBAAoB,EAAE,QAAQ;AAE7C,MAAI,EAAE,SAAS,SAAS,EAAE,SAAS,OACjC,YAAW,IAAI;WACN,EAAE,SAAS,SAAS,EAAE,SAAS,OACxC,YAAW,IAAI;AAGjB,SAAO,WAAW,WAAW,IAAI;GACjC;AAEF,MAAK,MAAM,YAAY,UACrB,eAAc,SAAS,SAAS;;AAIpC,SAAS,oBAAoB,SAAe;AAC1C,QAAO,QAAQ,WAAW,KAAK,KAAK,CAAC,WAAW,MAAM,OAAO;;;;;;;ACnW/D,IAAa,qBAAqB,EAAE;AAUpC,IAAa,kCAET,IAAI,eAAe,4CAA4C"}
1
+ {"version":3,"file":"route-files.mjs","names":[],"sources":["../../../../node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs","../../src/lib/json-ld.ts","../../src/lib/meta-tags.ts","../../src/lib/endpoints.ts","../../src/lib/inject-route-endpoint-url.ts","../../src/lib/route-config.ts","../../src/lib/constants.ts","../../src/lib/route-builder.ts","../../src/lib/route-files.ts"],"sourcesContent":["function isPlainObject(value) {\n if (!value || typeof value !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n const hasObjectPrototype = proto === null ||\n proto === Object.prototype ||\n Object.getPrototypeOf(proto) === null;\n if (!hasObjectPrototype) {\n return false;\n }\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\nexport { isPlainObject };\n","import { DOCUMENT, inject } from '@angular/core';\nimport type { ActivatedRouteSnapshot } from '@angular/router';\nimport { NavigationEnd, Router } from '@angular/router';\nimport { isPlainObject } from 'es-toolkit';\nimport { filter } from 'rxjs/operators';\n\nimport type { Graph, Thing, WithContext } from 'schema-dts';\n\nexport type JsonLdObject = Record<string, unknown>;\n\nexport function isJsonLdObject(value: unknown): value is JsonLdObject {\n return isPlainObject(value);\n}\n\nexport function normalizeJsonLd(value: unknown): JsonLdObject[] {\n if (Array.isArray(value)) {\n return value.filter(isJsonLdObject);\n }\n\n return isJsonLdObject(value) ? [value] : [];\n}\n\nexport type JsonLd = JsonLdObject | JsonLdObject[];\n\n/**\n * Typed JSON-LD document based on `schema-dts`.\n *\n * Accepts single Schema.org nodes (`WithContext<Thing>`),\n * `@graph`-based documents (`Graph`), or arrays of nodes.\n *\n * This is the canonical JSON-LD type for route authoring surfaces\n * (`routeMeta.jsonLd`, `routeJsonLd`, generated manifest).\n *\n * @example\n * ```ts\n * import type { WebPage, WithContext } from 'schema-dts';\n *\n * export const routeMeta = {\n * jsonLd: {\n * '@context': 'https://schema.org',\n * '@type': 'WebPage',\n * name: 'Products',\n * } satisfies WithContext<WebPage>,\n * };\n * ```\n */\nexport type AnalogJsonLdDocument =\n | WithContext<Thing>\n | Graph\n | WithContext<Thing>[];\n\nexport const ROUTE_JSON_LD_KEY: unique symbol = Symbol(\n '@analogjs/router Route JSON-LD Key',\n);\nconst JSON_LD_SCRIPT_SELECTOR = 'script[data-analog-json-ld]';\n\nexport function updateJsonLdOnRouteChange(\n router: Router = inject(Router),\n document: Document | null = inject(DOCUMENT, { optional: true }),\n): void {\n if (!document) {\n return;\n }\n\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n const entries = getJsonLdEntries(router.routerState.snapshot.root);\n applyJsonLdToDocument(document, entries);\n });\n}\n\nexport function serializeJsonLd(entry: JsonLdObject): string | null {\n try {\n return JSON.stringify(entry)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/&/g, '\\\\u0026')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n } catch {\n return null;\n }\n}\n\nfunction getJsonLdEntries(route: ActivatedRouteSnapshot): JsonLdObject[] {\n const entries: JsonLdObject[] = [];\n let currentRoute: ActivatedRouteSnapshot | null = route;\n\n while (currentRoute) {\n entries.push(...normalizeJsonLd(currentRoute.data[ROUTE_JSON_LD_KEY]));\n currentRoute = currentRoute.firstChild;\n }\n\n return entries;\n}\n\nfunction applyJsonLdToDocument(\n document: Document,\n entries: JsonLdObject[],\n): void {\n document.querySelectorAll(JSON_LD_SCRIPT_SELECTOR).forEach((element) => {\n element.remove();\n });\n\n if (entries.length === 0) {\n return;\n }\n\n const head = document.head || document.getElementsByTagName('head')[0];\n if (!head) {\n return;\n }\n\n entries.forEach((entry, index) => {\n const serialized = serializeJsonLd(entry);\n if (!serialized) {\n return;\n }\n\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.setAttribute('data-analog-json-ld', 'true');\n script.setAttribute('data-analog-json-ld-index', String(index));\n script.textContent = serialized;\n head.appendChild(script);\n });\n}\n","import { inject } from '@angular/core';\nimport { Meta, MetaDefinition as NgMetaTag } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, NavigationEnd, Router } from '@angular/router';\nimport { filter } from 'rxjs/operators';\n\nexport const ROUTE_META_TAGS_KEY: unique symbol = Symbol(\n '@analogjs/router Route Meta Tags Key',\n);\n\nconst CHARSET_KEY = 'charset';\nconst HTTP_EQUIV_KEY = 'httpEquiv';\n// httpEquiv selector key needs to be in kebab case format\nconst HTTP_EQUIV_SELECTOR_KEY = 'http-equiv';\nconst NAME_KEY = 'name';\nconst PROPERTY_KEY = 'property';\nconst CONTENT_KEY = 'content';\nconst ITEMPROP_KEY = 'itemprop';\n\nexport type MetaTag =\n | (CharsetMetaTag & ExcludeRestMetaTagKeys<typeof CHARSET_KEY>)\n | (HttpEquivMetaTag & ExcludeRestMetaTagKeys<typeof HTTP_EQUIV_KEY>)\n | (NameMetaTag & ExcludeRestMetaTagKeys<typeof NAME_KEY>)\n | (PropertyMetaTag & ExcludeRestMetaTagKeys<typeof PROPERTY_KEY>)\n | (ItempropMetaTag & ExcludeRestMetaTagKeys<typeof ITEMPROP_KEY>);\n\ntype CharsetMetaTag = { [CHARSET_KEY]: string };\ntype HttpEquivMetaTag = { [HTTP_EQUIV_KEY]: string; [CONTENT_KEY]: string };\ntype NameMetaTag = { [NAME_KEY]: string; [CONTENT_KEY]: string };\ntype PropertyMetaTag = { [PROPERTY_KEY]: string; [CONTENT_KEY]: string };\ntype ItempropMetaTag = { [ITEMPROP_KEY]: string; [CONTENT_KEY]: string };\n\ntype MetaTagKey =\n | typeof CHARSET_KEY\n | typeof HTTP_EQUIV_KEY\n | typeof NAME_KEY\n | typeof PROPERTY_KEY\n | typeof ITEMPROP_KEY;\ntype ExcludeRestMetaTagKeys<Key extends MetaTagKey> = {\n [K in Exclude<MetaTagKey, Key>]?: never;\n};\n\ntype MetaTagSelector =\n | typeof CHARSET_KEY\n | `${\n | typeof HTTP_EQUIV_SELECTOR_KEY\n | typeof NAME_KEY\n | typeof PROPERTY_KEY\n | typeof ITEMPROP_KEY}=\"${string}\"`;\ntype MetaTagMap = Record<MetaTagSelector, MetaTag>;\n\nexport function updateMetaTagsOnRouteChange(\n router: Router = inject(Router),\n metaService: Meta = inject(Meta),\n): void {\n router.events\n .pipe(filter((event) => event instanceof NavigationEnd))\n .subscribe(() => {\n const metaTagMap = getMetaTagMap(router.routerState.snapshot.root);\n for (const metaTagSelector in metaTagMap) {\n const metaTag = metaTagMap[\n metaTagSelector as MetaTagSelector\n ] as NgMetaTag;\n metaService.updateTag(metaTag, metaTagSelector);\n }\n });\n}\n\nfunction getMetaTagMap(route: ActivatedRouteSnapshot): MetaTagMap {\n const metaTagMap = {} as MetaTagMap;\n let currentRoute: ActivatedRouteSnapshot | null = route;\n\n while (currentRoute) {\n const metaTags: MetaTag[] = currentRoute.data[ROUTE_META_TAGS_KEY] ?? [];\n for (const metaTag of metaTags) {\n metaTagMap[getMetaTagSelector(metaTag)] = metaTag;\n }\n\n currentRoute = currentRoute.firstChild;\n }\n\n return metaTagMap;\n}\n\nfunction getMetaTagSelector(metaTag: MetaTag): MetaTagSelector {\n if (metaTag.name) {\n return `${NAME_KEY}=\"${metaTag.name}\"`;\n }\n\n if (metaTag.property) {\n return `${PROPERTY_KEY}=\"${metaTag.property}\"`;\n }\n\n if (metaTag.httpEquiv) {\n return `${HTTP_EQUIV_SELECTOR_KEY}=\"${metaTag.httpEquiv}\"`;\n }\n\n if (metaTag.itemprop) {\n return `${ITEMPROP_KEY}=\"${metaTag.itemprop}\"`;\n }\n\n return CHARSET_KEY;\n}\n","export const ANALOG_META_KEY: unique symbol = Symbol(\n '@analogjs/router Analog Route Metadata Key',\n);\n\n/**\n * This variable reference is replaced with a glob of all route endpoints.\n */\nexport const ANALOG_PAGE_ENDPOINTS: Record<string, () => Promise<unknown>> = {};\n","import type { ActivatedRouteSnapshot, Route } from '@angular/router';\nimport { injectBaseURL, injectAPIPrefix } from '../../tokens/src/index.js';\n\nimport { ANALOG_META_KEY } from './endpoints';\n\nexport function injectRouteEndpointURL(route: ActivatedRouteSnapshot): URL {\n const routeConfig = route.routeConfig as Route & {\n [ANALOG_META_KEY]: { endpoint: string; endpointKey: string };\n };\n\n const apiPrefix = injectAPIPrefix();\n const baseUrl = injectBaseURL();\n const { queryParams, fragment: hash, params, parent } = route;\n const segment = parent?.url.map((segment) => segment.path).join('/') || '';\n const url = new URL(\n '',\n 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 { DefaultRouteMeta, RouteExport, RouteMeta } from './models';\nimport { toRouteConfig } from './route-config';\nimport { ENDPOINT_EXTENSION } from './constants';\nimport { ANALOG_META_KEY } from './endpoints';\n\nexport type RouteModuleFactory = () => Promise<RouteExport>;\n\nexport type RouteModuleResolver<TFile> = (\n filename: string,\n fileLoader: () => Promise<TFile>,\n) => RouteModuleFactory;\n\ntype RawRoute = {\n filename: string | null;\n rawSegment: string;\n ancestorRawSegments: string[];\n segment: string;\n level: number;\n children: RawRoute[];\n};\n\ntype RawRouteMap = Record<string, RawRoute>;\ntype RawRouteByLevelMap = Record<number, RawRouteMap>;\n\nexport function createRoutes<TFile>(\n files: Record<string, () => Promise<TFile>>,\n resolveModule: RouteModuleResolver<TFile>,\n debug = false,\n): Route[] {\n const filenames = Object.keys(files).sort((a, b) => {\n const aPriority = getCollisionPriority(a);\n const bPriority = getCollisionPriority(b);\n\n return aPriority - bPriority;\n });\n\n if (filenames.length === 0) {\n return [];\n }\n\n const rawRoutesByLevelMap = filenames.reduce((acc, filename) => {\n const rawPath = toRawPath(filename);\n const rawSegments = rawPath.split('/');\n const level = rawSegments.length - 1;\n const rawSegment = rawSegments[level];\n const ancestorRawSegments = rawSegments.slice(0, level);\n\n const existing = acc[level]?.[rawPath];\n if (existing?.filename && existing.filename !== filename) {\n const existingPriority = getCollisionPriority(existing.filename);\n const nextPriority = getCollisionPriority(filename);\n const shouldKeepExisting = existingPriority < nextPriority;\n const chosenFilename = shouldKeepExisting ? existing.filename : filename;\n\n if (import.meta.env.DEV) {\n console.warn(\n `[Analog] Route files \"${existing.filename}\" and \"${filename}\" ` +\n `resolve to the same route path \"${rawPath}\". ` +\n `Only \"${chosenFilename}\" will be used.`,\n );\n }\n\n if (shouldKeepExisting) {\n return acc;\n }\n }\n\n return {\n ...acc,\n [level]: {\n ...acc[level],\n [rawPath]: {\n filename,\n rawSegment,\n ancestorRawSegments,\n segment: toSegment(rawSegment),\n level,\n children: [],\n },\n },\n };\n }, {} as RawRouteByLevelMap);\n\n const allLevels = Object.keys(rawRoutesByLevelMap).map(Number);\n const maxLevel = Math.max(...allLevels);\n\n for (let level = maxLevel; level > 0; level--) {\n const rawRoutesMap = rawRoutesByLevelMap[level];\n const rawPaths = Object.keys(rawRoutesMap);\n\n for (const rawPath of rawPaths) {\n const rawRoute = rawRoutesMap[rawPath];\n const parentRawPath = rawRoute.ancestorRawSegments.join('/');\n const parentRawSegmentIndex = rawRoute.ancestorRawSegments.length - 1;\n const parentRawSegment =\n rawRoute.ancestorRawSegments[parentRawSegmentIndex];\n\n rawRoutesByLevelMap[level - 1] ||= {};\n rawRoutesByLevelMap[level - 1][parentRawPath] ||= {\n filename: null,\n rawSegment: parentRawSegment,\n ancestorRawSegments: rawRoute.ancestorRawSegments.slice(\n 0,\n parentRawSegmentIndex,\n ),\n segment: toSegment(parentRawSegment),\n level: level - 1,\n children: [],\n };\n\n rawRoutesByLevelMap[level - 1][parentRawPath].children.push(rawRoute);\n }\n }\n\n const rootRawRoutesMap = rawRoutesByLevelMap[0];\n const rawRoutes = Object.keys(rootRawRoutesMap).map(\n (segment) => rootRawRoutesMap[segment],\n );\n sortRawRoutes(rawRoutes);\n\n return toRoutes(rawRoutes, files, resolveModule, debug);\n}\n\nfunction getCollisionPriority(filename: string): number {\n if (\n filename.includes('/src/app/pages/') ||\n filename.includes('/src/app/routes/') ||\n filename.includes('/app/pages/') ||\n filename.includes('/app/routes/') ||\n filename.includes('/src/content/')\n ) {\n return 0;\n }\n\n return 1;\n}\n\n/**\n * Strips directory prefixes and file extensions from a route filename to\n * produce the raw path used for route segment construction.\n *\n * The regex mirrors `filenameToRoutePath` in route-manifest.ts — changes\n * here must be kept in sync with that function. The first alternation\n * strips everything up to and including the first /routes/, /pages/, or\n * /content/ segment, which handles both app-local and additional directory\n * paths (e.g. `additionalPagesDirs`, `additionalContentDirs`).\n */\nfunction toRawPath(filename: string): string {\n return filename\n .replace(\n /^(?:[a-zA-Z]:[\\\\/])?(.*?)[\\\\/](?:routes|pages|content)[\\\\/]|(?:[\\\\/](?:app[\\\\/](?:routes|pages)|src[\\\\/]content)[\\\\/])|(\\.page\\.(js|ts)$)|(\\.(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 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"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAAA,SAAS,cAAc,OAAO;AAC1B,KAAI,CAAC,SAAS,OAAO,UAAU,SAC3B,QAAO;CAEX,MAAM,QAAQ,OAAO,eAAe,MAAM;AAI1C,KAAI,EAHuB,UAAU,QACjC,UAAU,OAAO,aACjB,OAAO,eAAe,MAAM,KAAK,MAEjC,QAAO;AAEX,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK;;;;ACDrD,SAAgB,eAAe,OAAc;AAC3C,QAAO,cAAc,MAAM;;AAG7B,SAAgB,gBAAgB,OAAc;AAC5C,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,OAAO,eAAe;AAGrC,QAAO,eAAe,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE;;AAgC7C,IAAa,oBAAmC,OAC9C,qCACD;AACD,IAAM,0BAA0B;AAEhC,SAAgB,0BACd,SAAiB,OAAO,OAAO,EAC/B,WAA4B,OAAO,UAAU,EAAE,UAAU,MAAM,CAAC,EAAA;AAEhE,KAAI,CAAC,SACH;AAGF,QAAO,OACJ,KAAK,QAAQ,UAAU,iBAAiB,cAAc,CAAC,CACvD,gBAAe;AAEd,wBAAsB,UADN,iBAAiB,OAAO,YAAY,SAAS,KAAK,CAC1B;GACxC;;AAGN,SAAgB,gBAAgB,OAAmB;AACjD,KAAI;AACF,SAAO,KAAK,UAAU,MAAM,CACzB,QAAQ,MAAM,UAAU,CACxB,QAAQ,MAAM,UAAU,CACxB,QAAQ,MAAM,UAAU,CAC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MAAK;EACtB,IAAI,WAAW,oBAAoB,EAAE,QAAQ;EAC7C,IAAI,WAAW,oBAAoB,EAAE,QAAQ;AAE7C,MAAI,EAAE,SAAS,SAAS,EAAE,SAAS,OACjC,YAAW,IAAI;WACN,EAAE,SAAS,SAAS,EAAE,SAAS,OACxC,YAAW,IAAI;AAGjB,SAAO,WAAW,WAAW,IAAI;GACjC;AAEF,MAAK,MAAM,YAAY,UACrB,eAAc,SAAS,SAAS;;AAIpC,SAAS,oBAAoB,SAAe;AAC1C,QAAO,QAAQ,WAAW,KAAK,KAAK,CAAC,WAAW,MAAM,OAAO;;;;;;;ACnW/D,IAAa,qBAAqB,EAAE;AAUpC,IAAa,kCAET,IAAI,eAAe,4CAA4C"}
@@ -1,4 +1,10 @@
1
1
  {
2
2
  "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
- "schematics": {}
3
+ "schematics": {
4
+ "remove-request-context-interceptor": {
5
+ "version": "3.0.0",
6
+ "description": "Remove requestContextInterceptor from withInterceptors() now that provideFileRouter() registers it automatically",
7
+ "factory": "./remove-request-context-interceptor/remove-request-context-interceptor"
8
+ }
9
+ }
4
10
  }
@@ -0,0 +1,122 @@
1
+ import * as ts from "typescript";
2
+ //#region packages/router/migrations/remove-request-context-interceptor/remove-request-context-interceptor.ts
3
+ var INTERCEPTOR = "requestContextInterceptor";
4
+ function getNamedImports(sourceFile) {
5
+ return sourceFile.statements.flatMap((declaration) => {
6
+ const bindings = ts.isImportDeclaration(declaration) ? declaration.importClause?.namedBindings : void 0;
7
+ return bindings && ts.isNamedImports(bindings) ? [{
8
+ declaration,
9
+ bindings
10
+ }] : [];
11
+ });
12
+ }
13
+ /** Local names imported for `exportName` from `moduleName`. */
14
+ function getImportNames(imports, moduleName, exportName) {
15
+ const names = /* @__PURE__ */ new Set();
16
+ for (const { declaration, bindings } of imports) {
17
+ if (!ts.isStringLiteral(declaration.moduleSpecifier) || declaration.moduleSpecifier.text !== moduleName) continue;
18
+ for (const element of bindings.elements) if ((element.propertyName ?? element.name).text === exportName) names.add(element.name.text);
19
+ }
20
+ return names;
21
+ }
22
+ function isCallTo(node, names) {
23
+ return ts.isCallExpression(node) && ts.isIdentifier(node.expression) && names.has(node.expression.text);
24
+ }
25
+ /** Removes one element of a comma-separated list along with its separator. */
26
+ function removeListElement(elements, index, listEnd, sourceFile) {
27
+ if (elements.length === 1) return {
28
+ start: elements.pos,
29
+ end: listEnd
30
+ };
31
+ if (index < elements.length - 1) return {
32
+ start: elements[index].getStart(sourceFile),
33
+ end: elements[index + 1].getStart(sourceFile)
34
+ };
35
+ return {
36
+ start: elements[index - 1].getEnd(),
37
+ end: elements[index].getEnd()
38
+ };
39
+ }
40
+ function countReferences(sourceFile, name) {
41
+ let count = 0;
42
+ function visit(node) {
43
+ if (ts.isImportDeclaration(node)) return;
44
+ if (ts.isIdentifier(node) && node.text === name) count++;
45
+ ts.forEachChild(node, visit);
46
+ }
47
+ visit(sourceFile);
48
+ return count;
49
+ }
50
+ /** Removes the import specifier for `name`, or the whole import if it is the only one. */
51
+ function removeImport(imports, name, sourceFile) {
52
+ for (const { declaration, bindings } of imports) {
53
+ const index = bindings.elements.findIndex((el) => el.name.text === name);
54
+ if (index === -1) continue;
55
+ if (bindings.elements.length === 1 && !declaration.importClause?.name) {
56
+ const end = declaration.getEnd();
57
+ return {
58
+ start: declaration.getStart(sourceFile),
59
+ end: sourceFile.text[end] === "\n" ? end + 1 : end
60
+ };
61
+ }
62
+ return removeListElement(bindings.elements, index, bindings.getEnd() - 1, sourceFile);
63
+ }
64
+ }
65
+ function removeFromSource(filePath, source) {
66
+ const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);
67
+ const imports = getNamedImports(sourceFile);
68
+ const interceptorNames = getImportNames(imports, "@analogjs/router", INTERCEPTOR);
69
+ if (!interceptorNames.size) return source;
70
+ const provideHttpClientNames = getImportNames(imports, "@angular/common/http", "provideHttpClient");
71
+ const withInterceptorsNames = getImportNames(imports, "@angular/common/http", "withInterceptors");
72
+ const edits = [];
73
+ const removed = /* @__PURE__ */ new Map();
74
+ const markRemoved = (name) => removed.set(name, (removed.get(name) ?? 0) + 1);
75
+ function visit(node) {
76
+ if (isCallTo(node, provideHttpClientNames)) node.arguments.forEach((arg, argIndex) => {
77
+ if (!isCallTo(arg, withInterceptorsNames)) return;
78
+ const [interceptors] = arg.arguments;
79
+ if (!interceptors || !ts.isArrayLiteralExpression(interceptors)) return;
80
+ const index = interceptors.elements.findIndex((el) => ts.isIdentifier(el) && interceptorNames.has(el.text));
81
+ if (index === -1) return;
82
+ markRemoved(interceptors.elements[index].text);
83
+ if (interceptors.elements.length === 1) {
84
+ markRemoved(arg.expression.text);
85
+ edits.push(removeListElement(node.arguments, argIndex, node.getEnd() - 1, sourceFile));
86
+ } else edits.push(removeListElement(interceptors.elements, index, interceptors.getEnd() - 1, sourceFile));
87
+ });
88
+ ts.forEachChild(node, visit);
89
+ }
90
+ visit(sourceFile);
91
+ for (const [name, count] of removed) if (countReferences(sourceFile, name) === count) {
92
+ const edit = removeImport(imports, name, sourceFile);
93
+ if (edit) edits.push(edit);
94
+ }
95
+ let result = source;
96
+ for (const edit of edits.sort((a, b) => b.start - a.start)) result = result.slice(0, edit.start) + result.slice(edit.end);
97
+ return result;
98
+ }
99
+ function removeRequestContextInterceptor() {
100
+ return (tree, context) => {
101
+ const updatedFiles = [];
102
+ const remainingFiles = [];
103
+ tree.visit((filePath) => {
104
+ if (filePath.includes("/node_modules/") || !filePath.endsWith(".ts")) return;
105
+ const source = tree.read(filePath)?.toString("utf-8");
106
+ if (!source?.includes(INTERCEPTOR)) return;
107
+ const result = removeFromSource(filePath, source);
108
+ if (result !== source) {
109
+ tree.overwrite(filePath, result);
110
+ updatedFiles.push(filePath);
111
+ }
112
+ if (result.includes(INTERCEPTOR)) remainingFiles.push(filePath);
113
+ });
114
+ if (updatedFiles.length) context.logger.info(`Removed requestContextInterceptor, now registered by provideFileRouter(), from: ${updatedFiles.join(", ")}`);
115
+ if (remainingFiles.length) context.logger.warn(`requestContextInterceptor is still referenced in: ${remainingFiles.join(", ")}. provideFileRouter() now registers it automatically, so remove any manual registration.`);
116
+ return tree;
117
+ };
118
+ }
119
+ //#endregion
120
+ export { removeRequestContextInterceptor as default };
121
+
122
+ //# sourceMappingURL=remove-request-context-interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-request-context-interceptor.js","names":[],"sources":["../../../migrations/remove-request-context-interceptor/remove-request-context-interceptor.ts"],"sourcesContent":["import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport * as ts from 'typescript';\n\nconst INTERCEPTOR = 'requestContextInterceptor';\n\ninterface Edit {\n start: number;\n end: number;\n}\n\ninterface NamedImport {\n declaration: ts.ImportDeclaration;\n bindings: ts.NamedImports;\n}\n\nfunction getNamedImports(sourceFile: ts.SourceFile): NamedImport[] {\n return sourceFile.statements.flatMap((declaration) => {\n const bindings = ts.isImportDeclaration(declaration)\n ? declaration.importClause?.namedBindings\n : undefined;\n return bindings && ts.isNamedImports(bindings)\n ? [{ declaration: declaration as ts.ImportDeclaration, bindings }]\n : [];\n });\n}\n\n/** Local names imported for `exportName` from `moduleName`. */\nfunction getImportNames(\n imports: NamedImport[],\n moduleName: string,\n exportName: string,\n): Set<string> {\n const names = new Set<string>();\n for (const { declaration, bindings } of imports) {\n if (\n !ts.isStringLiteral(declaration.moduleSpecifier) ||\n declaration.moduleSpecifier.text !== moduleName\n ) {\n continue;\n }\n for (const element of bindings.elements) {\n if ((element.propertyName ?? element.name).text === exportName) {\n names.add(element.name.text);\n }\n }\n }\n return names;\n}\n\nfunction isCallTo(\n node: ts.Node,\n names: Set<string>,\n): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n names.has(node.expression.text)\n );\n}\n\n/** Removes one element of a comma-separated list along with its separator. */\nfunction removeListElement(\n elements: ts.NodeArray<ts.Node>,\n index: number,\n listEnd: number,\n sourceFile: ts.SourceFile,\n): Edit {\n if (elements.length === 1) {\n return { start: elements.pos, end: listEnd };\n }\n if (index < elements.length - 1) {\n return {\n start: elements[index].getStart(sourceFile),\n end: elements[index + 1].getStart(sourceFile),\n };\n }\n return { start: elements[index - 1].getEnd(), end: elements[index].getEnd() };\n}\n\nfunction countReferences(sourceFile: ts.SourceFile, name: string): number {\n let count = 0;\n function visit(node: ts.Node): void {\n if (ts.isImportDeclaration(node)) return;\n if (ts.isIdentifier(node) && node.text === name) count++;\n ts.forEachChild(node, visit);\n }\n visit(sourceFile);\n return count;\n}\n\n/** Removes the import specifier for `name`, or the whole import if it is the only one. */\nfunction removeImport(\n imports: NamedImport[],\n name: string,\n sourceFile: ts.SourceFile,\n): Edit | undefined {\n for (const { declaration, bindings } of imports) {\n const index = bindings.elements.findIndex((el) => el.name.text === name);\n if (index === -1) continue;\n\n if (bindings.elements.length === 1 && !declaration.importClause?.name) {\n const end = declaration.getEnd();\n return {\n start: declaration.getStart(sourceFile),\n end: sourceFile.text[end] === '\\n' ? end + 1 : end,\n };\n }\n return removeListElement(\n bindings.elements,\n index,\n bindings.getEnd() - 1,\n sourceFile,\n );\n }\n return undefined;\n}\n\nfunction removeFromSource(filePath: string, source: string): string {\n const sourceFile = ts.createSourceFile(\n filePath,\n source,\n ts.ScriptTarget.Latest,\n true,\n );\n const imports = getNamedImports(sourceFile);\n const interceptorNames = getImportNames(\n imports,\n '@analogjs/router',\n INTERCEPTOR,\n );\n if (!interceptorNames.size) return source;\n\n const provideHttpClientNames = getImportNames(\n imports,\n '@angular/common/http',\n 'provideHttpClient',\n );\n const withInterceptorsNames = getImportNames(\n imports,\n '@angular/common/http',\n 'withInterceptors',\n );\n\n const edits: Edit[] = [];\n const removed = new Map<string, number>();\n const markRemoved = (name: string) =>\n removed.set(name, (removed.get(name) ?? 0) + 1);\n\n function visit(node: ts.Node): void {\n if (isCallTo(node, provideHttpClientNames)) {\n node.arguments.forEach((arg, argIndex) => {\n if (!isCallTo(arg, withInterceptorsNames)) return;\n const [interceptors] = arg.arguments;\n if (!interceptors || !ts.isArrayLiteralExpression(interceptors)) return;\n\n const index = interceptors.elements.findIndex(\n (el) => ts.isIdentifier(el) && interceptorNames.has(el.text),\n );\n if (index === -1) return;\n\n markRemoved((interceptors.elements[index] as ts.Identifier).text);\n if (interceptors.elements.length === 1) {\n markRemoved((arg.expression as ts.Identifier).text);\n edits.push(\n removeListElement(\n node.arguments,\n argIndex,\n node.getEnd() - 1,\n sourceFile,\n ),\n );\n } else {\n edits.push(\n removeListElement(\n interceptors.elements,\n index,\n interceptors.getEnd() - 1,\n sourceFile,\n ),\n );\n }\n });\n }\n ts.forEachChild(node, visit);\n }\n visit(sourceFile);\n\n for (const [name, count] of removed) {\n if (countReferences(sourceFile, name) === count) {\n const edit = removeImport(imports, name, sourceFile);\n if (edit) edits.push(edit);\n }\n }\n\n let result = source;\n for (const edit of edits.sort((a, b) => b.start - a.start)) {\n result = result.slice(0, edit.start) + result.slice(edit.end);\n }\n return result;\n}\n\nexport default function removeRequestContextInterceptor(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const updatedFiles: string[] = [];\n const remainingFiles: string[] = [];\n\n tree.visit((filePath) => {\n if (filePath.includes('/node_modules/') || !filePath.endsWith('.ts')) {\n return;\n }\n const source = tree.read(filePath)?.toString('utf-8');\n if (!source?.includes(INTERCEPTOR)) return;\n\n const result = removeFromSource(filePath, source);\n if (result !== source) {\n tree.overwrite(filePath, result);\n updatedFiles.push(filePath);\n }\n if (result.includes(INTERCEPTOR)) {\n remainingFiles.push(filePath);\n }\n });\n\n if (updatedFiles.length) {\n context.logger.info(\n `Removed requestContextInterceptor, now registered by provideFileRouter(), from: ${updatedFiles.join(', ')}`,\n );\n }\n if (remainingFiles.length) {\n context.logger.warn(\n `requestContextInterceptor is still referenced in: ${remainingFiles.join(', ')}. ` +\n 'provideFileRouter() now registers it automatically, so remove any manual registration.',\n );\n }\n\n return tree;\n };\n}\n"],"mappings":";;AAGA,IAAM,cAA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eAAe,OACjB,SAAQ,OAAO,KACb,qDAAqD,eAAe,KAAK,KAAK,CAAA,0FAE/E;AAGH,SAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/router",
3
- "version": "3.0.0-alpha.95",
3
+ "version": "3.0.0-alpha.97",
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-alpha.95",
72
+ "@analogjs/content": "3.0.0-alpha.97",
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",
@@ -105,8 +105,8 @@
105
105
  "tslib": "^2.3.0"
106
106
  },
107
107
  "devDependencies": {
108
- "@analogjs/vite-plugin-angular": "3.0.0-alpha.95",
109
- "@analogjs/vitest-angular": "3.0.0-alpha.95"
108
+ "@analogjs/vite-plugin-angular": "3.0.0-alpha.97",
109
+ "@analogjs/vitest-angular": "3.0.0-alpha.97"
110
110
  },
111
111
  "ng-update": {
112
112
  "packageGroup": [
@@ -0,0 +1,2 @@
1
+ import type { Rule } from '@angular-devkit/schematics';
2
+ export default function removeRequestContextInterceptor(): Rule;
@@ -1,6 +1,17 @@
1
1
  import type { StandardSchemaV1 } from './standard-schema';
2
2
  import type { H3Event } from 'h3';
3
3
  export type DefineApiRouteResult = Response | unknown;
4
+ export interface ApiRouteHandler<TQuery = unknown, TBody = unknown, TResult = unknown> {
5
+ (event: H3Event): Promise<Response>;
6
+ readonly _types: {
7
+ readonly query: TQuery;
8
+ readonly body: TBody;
9
+ readonly result: TResult;
10
+ };
11
+ }
12
+ export type InferRouteQuery<T> = T extends ApiRouteHandler<infer Q, any, any> ? Q : never;
13
+ export type InferRouteBody<T> = T extends ApiRouteHandler<any, infer B, any> ? B : never;
14
+ export type InferRouteResult<T> = T extends ApiRouteHandler<any, any, infer R> ? Exclude<R, Response> : never;
4
15
  type OptionalSchema = StandardSchemaV1 | undefined;
5
16
  type InferSchema<TSchema extends OptionalSchema, TFallback = unknown> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
6
17
  type ResolveDataSchema<TInput extends OptionalSchema, TQuery extends OptionalSchema, TBody extends OptionalSchema> = TInput extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TInput> : TQuery extends StandardSchemaV1 ? TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TQuery> | StandardSchemaV1.InferOutput<TBody> : StandardSchemaV1.InferOutput<TQuery> : TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TBody> : unknown;
@@ -52,5 +63,5 @@ export interface DefineApiRouteOptions<TInput extends StandardSchemaV1 | undefin
52
63
  * });
53
64
  * ```
54
65
  */
55
- export declare function defineApiRoute<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineApiRouteResult = DefineApiRouteResult>(options: DefineApiRouteOptions<TInput, TOutput, TQuery, TBody, TParams, TResult>): (event: H3Event) => Promise<Response>;
66
+ export declare function defineApiRoute<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineApiRouteResult = DefineApiRouteResult>(options: DefineApiRouteOptions<TInput, TOutput, TQuery, TBody, TParams, TResult>): ApiRouteHandler<InferSchema<TQuery, undefined>, InferSchema<TBody, undefined>, TResult>;
56
67
  export {};
@@ -20,7 +20,7 @@ export interface DefinePageLoadOptions<TParamsSchema extends OptionalSchema = un
20
20
  * Creates a typed page server load function with optional
21
21
  * Standard Schema validation for route params and query.
22
22
  *
23
- * Follows the same validation pattern as `defineServerRoute`:
23
+ * Follows the same validation pattern as `defineApiRoute`:
24
24
  * validates before invoking the handler and returns
25
25
  * `fail(422, issues)` on validation failure.
26
26
  *
@@ -1,10 +1,8 @@
1
1
  export type { PageServerAction } from './actions';
2
2
  export { json, redirect, fail } from './actions';
3
- export { defineServerRoute } from './define-server-route';
4
- export type { DefineServerRouteContext, DefineServerRouteOptions, DefineServerRouteResult, ServerRouteHandler, InferRouteQuery, InferRouteBody, InferRouteResult, } from './define-server-route';
5
3
  export { definePageLoad } from './define-page-load';
6
4
  export type { PageLoadContext, DefinePageLoadOptions, } from './define-page-load';
7
5
  export { validateWithSchema } from './validate';
8
6
  export type { StandardSchemaV1 } from './standard-schema';
9
7
  export { defineAction, type DefineActionContext, type DefineActionOptions, } from './define-action';
10
- export { defineApiRoute, type DefineApiRouteContext, type DefineApiRouteOptions, type DefineApiRouteResult, } from './define-api-route';
8
+ export { defineApiRoute, type DefineApiRouteContext, type DefineApiRouteOptions, type DefineApiRouteResult, type ApiRouteHandler, type InferRouteQuery, type InferRouteBody, type InferRouteResult, } from './define-api-route';
@@ -11,6 +11,7 @@ export declare class FormAction {
11
11
  private injector;
12
12
  private router;
13
13
  private route;
14
+ private apiPrefix;
14
15
  private path;
15
16
  constructor();
16
17
  submitted($event: any): void;
@@ -1,12 +1,12 @@
1
1
  import type { HttpClient } from '@angular/common/http';
2
2
  import type { CreateQueryOptions, CreateMutationOptions, CreateInfiniteQueryOptions, DefaultError, InfiniteData, QueryKey } from '@tanstack/angular-query-experimental';
3
- import type { ServerRouteHandler, InferRouteQuery, InferRouteBody, InferRouteResult } from '@analogjs/router/server/actions';
4
- export declare function serverQueryOptions<TRoute extends ServerRouteHandler<any, any, any>, TError = DefaultError, TData = InferRouteResult<TRoute>, TQueryKey extends QueryKey = QueryKey>(http: HttpClient, url: string, options: {
3
+ import type { ApiRouteHandler, InferRouteQuery, InferRouteBody, InferRouteResult } from '@analogjs/router/server/actions';
4
+ export declare function serverQueryOptions<TRoute extends ApiRouteHandler<any, any, any>, TError = DefaultError, TData = InferRouteResult<TRoute>, TQueryKey extends QueryKey = QueryKey>(http: HttpClient, url: string, options: {
5
5
  queryKey: TQueryKey;
6
6
  query?: InferRouteQuery<TRoute>;
7
7
  } & Omit<CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>, 'queryKey' | 'queryFn'>): CreateQueryOptions<InferRouteResult<TRoute>, TError, TData, TQueryKey>;
8
- export declare function serverMutationOptions<TRoute extends ServerRouteHandler<any, any, any>, TError = DefaultError, TOnMutateResult = unknown>(http: HttpClient, url: string, options?: Omit<CreateMutationOptions<InferRouteResult<TRoute>, TError, InferRouteBody<TRoute>, TOnMutateResult>, 'mutationFn'>): CreateMutationOptions<InferRouteResult<TRoute>, TError, InferRouteBody<TRoute>, TOnMutateResult>;
9
- export declare function serverInfiniteQueryOptions<TRoute extends ServerRouteHandler<any, any, any>, TError = DefaultError, TData = InfiniteData<InferRouteResult<TRoute>>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(http: HttpClient, url: string, options: {
8
+ export declare function serverMutationOptions<TRoute extends ApiRouteHandler<any, any, any>, TError = DefaultError, TOnMutateResult = unknown>(http: HttpClient, url: string, options?: Omit<CreateMutationOptions<InferRouteResult<TRoute>, TError, InferRouteBody<TRoute>, TOnMutateResult>, 'mutationFn'>): CreateMutationOptions<InferRouteResult<TRoute>, TError, InferRouteBody<TRoute>, TOnMutateResult>;
9
+ export declare function serverInfiniteQueryOptions<TRoute extends ApiRouteHandler<any, any, any>, TError = DefaultError, TData = InfiniteData<InferRouteResult<TRoute>>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(http: HttpClient, url: string, options: {
10
10
  queryKey: TQueryKey;
11
11
  query: (context: {
12
12
  pageParam: TPageParam;
@@ -1,68 +0,0 @@
1
- import type { StandardSchemaV1 } from './standard-schema';
2
- import type { H3Event } from 'h3';
3
- export type DefineServerRouteResult = Response | unknown;
4
- export interface ServerRouteHandler<TQuery = unknown, TBody = unknown, TResult = unknown> {
5
- (event: H3Event): Promise<Response>;
6
- readonly _types: {
7
- readonly query: TQuery;
8
- readonly body: TBody;
9
- readonly result: TResult;
10
- };
11
- }
12
- export type InferRouteQuery<T> = T extends ServerRouteHandler<infer Q, any, any> ? Q : never;
13
- export type InferRouteBody<T> = T extends ServerRouteHandler<any, infer B, any> ? B : never;
14
- export type InferRouteResult<T> = T extends ServerRouteHandler<any, any, infer R> ? Exclude<R, Response> : never;
15
- type OptionalSchema = StandardSchemaV1 | undefined;
16
- type InferSchema<TSchema extends OptionalSchema, TFallback = unknown> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
17
- type ResolveDataSchema<TInput extends OptionalSchema, TQuery extends OptionalSchema, TBody extends OptionalSchema> = TInput extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TInput> : TQuery extends StandardSchemaV1 ? TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TQuery> | StandardSchemaV1.InferOutput<TBody> : StandardSchemaV1.InferOutput<TQuery> : TBody extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TBody> : unknown;
18
- export interface DefineServerRouteContext<TInput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined> {
19
- data: ResolveDataSchema<TInput, TQuery, TBody>;
20
- query: InferSchema<TQuery, undefined>;
21
- body: InferSchema<TBody, undefined>;
22
- params: InferSchema<TParams, H3Event['context']['params']>;
23
- event: H3Event;
24
- }
25
- export interface DefineServerRouteOptions<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineServerRouteResult = DefineServerRouteResult> {
26
- input?: TInput;
27
- query?: TQuery;
28
- body?: TBody;
29
- params?: TParams;
30
- output?: TOutput;
31
- handler: (context: DefineServerRouteContext<TInput, TQuery, TBody, TParams>) => Promise<TResult> | TResult;
32
- }
33
- /**
34
- * Creates an h3-compatible event handler with Standard Schema validation.
35
- *
36
- * - `input` schema validates the request body (POST/PUT/PATCH) or query
37
- * params (GET). Returns 422 with `StandardSchemaV1.Issue[]` on failure.
38
- * - `output` schema validates the response in development only (stripped
39
- * in production for zero overhead). Logs a warning on mismatch.
40
- * - Plain return values are serialized with `json(...)`; raw `Response`
41
- * objects are returned unchanged.
42
- *
43
- * @example
44
- * ```typescript
45
- * import { defineServerRoute } from '@analogjs/router/server/actions';
46
- * import * as v from 'valibot';
47
- *
48
- * const Input = v.object({
49
- * name: v.pipe(v.string(), v.minLength(1)),
50
- * email: v.pipe(v.string(), v.email()),
51
- * });
52
- * const Output = v.object({
53
- * id: v.string(),
54
- * name: v.string(),
55
- * });
56
- *
57
- * export default defineServerRoute({
58
- * input: Input,
59
- * output: Output,
60
- * handler: async ({ data }) => {
61
- * const user = await db.users.create(data);
62
- * return user;
63
- * },
64
- * });
65
- * ```
66
- */
67
- export declare function defineServerRoute<TInput extends StandardSchemaV1 | undefined = undefined, TOutput extends StandardSchemaV1 | undefined = undefined, TQuery extends StandardSchemaV1 | undefined = undefined, TBody extends StandardSchemaV1 | undefined = undefined, TParams extends StandardSchemaV1 | undefined = undefined, TResult extends DefineServerRouteResult = DefineServerRouteResult>(options: DefineServerRouteOptions<TInput, TOutput, TQuery, TBody, TParams, TResult>): ServerRouteHandler<InferSchema<TQuery, undefined>, InferSchema<TBody, undefined>, TResult>;
68
- export {};