@loozo/angular-router 0.0.3 → 0.0.4
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.
- package/README.md +243 -121
- package/fesm2022/loozo-angular-router-_core.mjs +19 -41
- package/fesm2022/loozo-angular-router-_core.mjs.map +1 -1
- package/fesm2022/loozo-angular-router-_generated.mjs +148 -315
- package/fesm2022/loozo-angular-router-_generated.mjs.map +1 -1
- package/fesm2022/loozo-angular-router.mjs +2 -2
- package/node/src/builders/application.js +12 -3
- package/node/src/builders/options.js +9 -3
- package/node/src/builders/serve.js +21 -14
- package/node/src/generation/emit.js +26 -8
- package/node/src/generation/filesystem.js +261 -69
- package/node/src/generation/generate.d.ts +1 -1
- package/node/src/generation/generate.js +6 -1
- package/node/src/generation/sources.js +7 -2
- package/node/src/generation/validate.js +15 -24
- package/package.json +1 -1
- package/schemas/application.json +29 -20
- package/schemas/serve.json +142 -7
- package/snippets/angular.json +29 -0
- package/snippets/generated/destinations.generated.ts +126 -0
- package/snippets/generated/routes.generated.ts +35 -0
- package/snippets/src/catalog.ts +20 -0
- package/snippets/src/docs-url.ts +8 -0
- package/snippets/src/index.html +11 -0
- package/snippets/src/main.ts +6 -0
- package/snippets/src/product-url.ts +8 -0
- package/snippets/src/routes/products/$productId/page.ts +20 -0
- package/snippets/src/routes/products/$productId/route.generated.ts +24 -0
- package/snippets/src/routes/products/$productId/route.ts +7 -0
- package/snippets/src/routes/reports/$reportId/page.ts +9 -0
- package/snippets/src/routes/reports/$reportId/route.generated.ts +24 -0
- package/snippets/src/routes/reports/$reportId/route.ts +6 -0
- package/snippets/src/routes/teams/$teamId/items/$id/inputs.ts +15 -0
- package/snippets/src/routes/teams/$teamId/items/$id/links.ts +13 -0
- package/snippets/src/routes/teams/$teamId/items/$id/page.ts +9 -0
- package/snippets/src/routes/teams/$teamId/items/$id/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/items/$id/route.ts +18 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/page.ts +9 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/members/$memberId/route.ts +7 -0
- package/snippets/src/routes/teams/$teamId/old-items/$id/route.ts +13 -0
- package/snippets/src/routes/teams/$teamId/route.generated.ts +24 -0
- package/snippets/src/routes/teams/$teamId/route.ts +6 -0
- package/snippets/src/shell.ts +9 -0
- package/snippets/src/slug.ts +14 -0
- package/snippets/tsconfig.app.json +14 -0
- package/snippets/tsconfig.routes.json +5 -0
- package/types/loozo-angular-router-_core.d.ts +141 -99
- package/types/loozo-angular-router-_generated.d.ts +48 -31
- package/types/loozo-angular-router.d.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loozo-angular-router-_generated.mjs","names":[],"sources":["../../_generated/src/inputs.ts","../../_generated/src/callbacks.ts","../../_generated/src/handle.ts","../../_generated/src/index.ts"],"sourcesContent":["import type { ActivatedRouteSnapshot, PartialMatchRouteSnapshot } from \"@angular/router\";\nimport { codecPresence, routeMetadata, type AnyRoute } from \"@loozo/angular-router/_core\";\n\nexport interface RecordBinding {\n readonly definition: () => AnyRoute;\n readonly owners: readonly string[];\n}\nexport interface RouteSet {\n readonly records: Readonly<Record<string, RecordBinding>>;\n readonly destinations: Readonly<Record<string, () => AnyRoute>>;\n readonly absolute: Readonly<Record<string, string>>;\n readonly relative: Readonly<Record<string, Readonly<Record<string, string>>>>;\n}\nexport interface Parsed {\n readonly params: Readonly<Record<string, unknown>>;\n readonly search: Readonly<Record<string, unknown>>;\n}\nexport interface Job {\n readonly source: \"path\" | \"search\";\n readonly key: string;\n readonly raws: readonly string[];\n readonly array: boolean;\n readonly codec: { parse(raw: string): unknown };\n}\nexport interface Operation {\n readonly promise: Promise<Parsed>;\n outcome: { value: Parsed } | { error: Error } | undefined;\n}\n\nexport function hasIdentity(\n snapshot: Pick<ActivatedRouteSnapshot, \"routeConfig\">,\n id: string,\n): boolean {\n const data = snapshot.routeConfig?.data;\n\n return (\n !!data &&\n Object.hasOwn(data, \"__loozoAngularRouterRouteId\") &&\n data.__loozoAngularRouterRouteId === id\n );\n}\n\nexport function assertIdentity(\n snapshot: Pick<ActivatedRouteSnapshot, \"routeConfig\">,\n id: string,\n): void {\n if (!hasIdentity(snapshot, id)) {\n throw new Error(`Generated route wiring identity mismatch: ${id}`);\n }\n}\n\nexport function inputError(\n source: \"path\" | \"search\",\n key: string,\n reason: \"missing\" | \"repeated\" | \"invalid\",\n cause?: unknown,\n): Error {\n return Object.assign(new Error(`Invalid ${source} input ${key}: ${reason}`, { cause }), {\n source,\n key,\n reason,\n });\n}\n\nexport function validateRaw(\n source: \"path\" | \"search\",\n key: string,\n raws: readonly unknown[],\n array: boolean,\n): asserts raws is readonly string[] {\n if (!array && raws.length === 0) {\n throw inputError(source, key, \"missing\");\n }\n\n if (!array && raws.length > 1) {\n throw inputError(source, key, \"repeated\");\n }\n\n if (raws.some((raw) => typeof raw !== \"string\")) {\n throw inputError(source, key, \"invalid\", new TypeError(\"Raw input must be a decoded string\"));\n }\n}\n\nexport function pathJobs(definition: AnyRoute, url: readonly { path: string }[]): Job[] {\n const metadata = routeMetadata(definition);\n const local = new Map<string, Job>();\n\n for (let index = 0; index < metadata.localSegments.length; index += 1) {\n const segment = metadata.localSegments[index];\n\n if (segment.kind === \"static\") {\n continue;\n }\n\n let raws: unknown[] = [];\n const array = segment.kind === \"catchall\";\n\n if (array) {\n raws = url.slice(index).map((value) => value.path);\n } else if (index < url.length) {\n raws = [url[index].path];\n }\n\n validateRaw(\"path\", segment.name, raws, array);\n // Repeated local scalars intentionally use Angular's last positional occurrence.\n local.set(segment.name, {\n source: \"path\",\n key: segment.name,\n raws,\n array,\n codec: metadata.localParams[segment.name],\n });\n }\n\n return [...local.values()];\n}\n\nexport function searchJobs(\n definition: AnyRoute,\n snapshot: Pick<ActivatedRouteSnapshot, \"queryParamMap\">,\n): Job[] {\n const metadata = routeMetadata(definition);\n const jobs: Job[] = [];\n\n for (const key of Object.keys(metadata.search)) {\n const codec = metadata.search[key];\n const raws = snapshot.queryParamMap.getAll(key);\n\n if (raws.length === 0 && codecPresence(codec) === \"optional\") {\n continue;\n }\n\n validateRaw(\"search\", key, raws, false);\n jobs.push({ source: \"search\", key, raws, array: false, codec });\n }\n\n return jobs;\n}\n\nexport async function runJobs(jobs: readonly Job[]): Promise<Parsed> {\n const params: Record<string, unknown> = Object.create(null);\n const search: Record<string, unknown> = Object.create(null);\n const pending: Promise<void>[] = [];\n\n for (const job of jobs) {\n // Async boundaries convert every synchronous throw into an observed rejection.\n pending.push(\n (async () => {\n try {\n const elements: Promise<unknown>[] = [];\n\n for (const raw of job.raws) {\n elements.push((async () => job.codec.parse(raw))());\n }\n\n const values = await Promise.all(elements);\n let value = values[0];\n\n if (job.array) {\n value = Object.freeze(values);\n }\n\n if (job.source === \"path\") {\n params[job.key] = value;\n } else {\n search[job.key] = value;\n }\n } catch (cause) {\n throw inputError(job.source, job.key, \"invalid\", cause);\n }\n })(),\n );\n }\n\n await Promise.all(pending);\n\n return Object.freeze({ params: Object.freeze(params), search: Object.freeze(search) });\n}\n\nconst full = new WeakMap<object, WeakMap<object, Operation>>();\nconst matching = new WeakMap<object, WeakMap<object, Operation>>();\n\nfunction operation(\n cache: typeof full,\n definition: AnyRoute,\n snapshot: object,\n collect: () => Job[],\n): Operation {\n let snapshots = cache.get(definition);\n\n if (!snapshots) {\n snapshots = new WeakMap();\n cache.set(definition, snapshots);\n }\n\n const existing = snapshots.get(snapshot);\n\n if (existing) {\n return existing;\n }\n\n // Insert before application code can run; even synchronous reentry joins the same operation.\n const result: Operation = {\n promise: Promise.resolve().then(() => runJobs(collect())),\n outcome: undefined,\n };\n\n snapshots.set(snapshot, result);\n result.promise.then(\n (value) => {\n result.outcome = { value };\n },\n (cause) => {\n let error = cause;\n\n if (!(error instanceof Error)) {\n error = new Error(\"Route input failure\", { cause });\n }\n\n result.outcome = { error };\n },\n );\n\n return result;\n}\n\nexport function fullOperation(\n set: RouteSet,\n id: string,\n snapshot: ActivatedRouteSnapshot,\n): Operation {\n assertIdentity(snapshot, id);\n\n const binding = set.records[id];\n\n return operation(full, binding.definition(), snapshot, () => {\n const jobs: Job[] = [];\n\n for (const ownerId of binding.owners) {\n const definition = set.records[ownerId].definition();\n\n // Pathless/static owners contribute no positional input. Effective search belongs\n // to this complete future record; inherited data is never positional authority.\n if (!routeMetadata(definition).localSegments.some((segment) => segment.kind !== \"static\")) {\n continue;\n }\n\n const owner = [...snapshot.pathFromRoot]\n .reverse()\n .find((record) => hasIdentity(record, ownerId));\n\n if (!owner) {\n throw new Error(`Generated route ancestor missing: ${ownerId}`);\n }\n\n assertIdentity(owner, ownerId);\n jobs.push(...pathJobs(definition, owner.url));\n }\n\n jobs.push(...searchJobs(binding.definition(), snapshot));\n\n return jobs;\n });\n}\n\nexport function parseInputs(\n set: RouteSet,\n id: string,\n snapshot: ActivatedRouteSnapshot,\n): Promise<Parsed> {\n return fullOperation(set, id, snapshot).promise;\n}\n\nexport function matchingInputs(\n set: RouteSet,\n id: string,\n snapshot: PartialMatchRouteSnapshot,\n): Promise<Parsed> {\n assertIdentity(snapshot, id);\n\n const definition = set.records[id].definition();\n\n return operation(matching, definition, snapshot, () => [\n ...pathJobs(definition, snapshot.url),\n ...searchJobs(definition, snapshot),\n ]).promise;\n}\n","import { Injector, inject, runInInjectionContext } from \"@angular/core\";\nimport {\n Router,\n type Route,\n type ActivatedRouteSnapshot,\n type RouterStateSnapshot,\n type GuardResult,\n type CanActivateFn,\n type CanActivateChildFn,\n type CanMatchFn,\n type ResolveFn,\n type RedirectFunction,\n} from \"@angular/router\";\nimport { Observable, from, isObservable, type ObservableInput } from \"rxjs\";\nimport { routeMetadata, codecPresence, type AnyRoute } from \"@loozo/angular-router/_core\";\nimport {\n assertIdentity,\n hasIdentity,\n parseInputs,\n matchingInputs,\n runJobs,\n validateRaw,\n type Job,\n type RouteSet,\n} from \"./inputs.js\";\n\nfunction isPromiseResult<T>(value: unknown): value is Promise<T> {\n return !!value && typeof (value as Promise<T>).then === \"function\";\n}\n\nfunction bridge<T>(\n inputs: () => Promise<unknown>,\n callback: (inputs: any) => T | ObservableInput<T>,\n): Observable<T> {\n const injector = inject(Injector);\n\n return new Observable((subscriber) => {\n let subscription: { unsubscribe(): void } | undefined;\n\n inputs().then(\n (value) => {\n if (subscriber.closed) {\n return;\n }\n\n try {\n const result = runInInjectionContext(injector, () => callback(value));\n\n if (isObservable(result)) {\n subscription = result.subscribe(subscriber);\n } else if (isPromiseResult<T>(result)) {\n subscription = from(Promise.resolve(result)).subscribe(subscriber);\n } else {\n subscriber.next(result as T);\n subscriber.complete();\n }\n } catch (error) {\n subscriber.error(error);\n }\n },\n (error) => subscriber.error(error),\n );\n\n return () => subscription?.unsubscribe();\n });\n}\n\nexport function callbacks(\n set: RouteSet,\n id: string,\n): Pick<Route, \"canActivate\" | \"canActivateChild\" | \"canMatch\" | \"resolve\"> {\n const config = routeMetadata(set.records[id].definition()).config;\n const result: Pick<Route, \"canActivate\" | \"canActivateChild\" | \"canMatch\" | \"resolve\"> = {};\n const activate = config.canActivate as readonly ((...args: any[]) => any)[] | undefined;\n\n if (activate) {\n result.canActivate = activate.map(\n (callback): CanActivateFn =>\n (snapshot, state) => {\n assertIdentity(snapshot, id);\n\n return bridge<GuardResult>(\n () => parseInputs(set, id, snapshot),\n (inputs) => callback(inputs, snapshot, state),\n );\n },\n );\n }\n\n const children = config.canActivateChild as readonly ((...args: any[]) => any)[] | undefined;\n\n if (children) {\n result.canActivateChild = children.map(\n (callback): CanActivateChildFn =>\n (child, state) => {\n let parent: ActivatedRouteSnapshot | undefined;\n\n // The native ancestry includes child itself; only proper ancestors can declare this guard.\n for (let index = child.pathFromRoot.length - 2; index >= 0; index -= 1) {\n const ancestor = child.pathFromRoot[index];\n\n if (hasIdentity(ancestor, id)) {\n parent = ancestor;\n\n break;\n }\n }\n\n if (!parent) {\n throw new Error(`Generated guard ancestor missing: ${id}`);\n }\n\n assertIdentity(parent, id);\n\n return bridge<GuardResult>(\n () => parseInputs(set, id, parent),\n (inputs) => callback(inputs, child, state),\n );\n },\n );\n }\n\n const matching = config.canMatch as readonly ((...args: any[]) => any)[] | undefined;\n\n if (matching) {\n result.canMatch = matching.map(\n (callback): CanMatchFn =>\n (route, segments, snapshot) => {\n assertIdentity(snapshot, id);\n\n return bridge<GuardResult>(\n () => matchingInputs(set, id, snapshot),\n (inputs) => callback(inputs, route, segments, snapshot),\n );\n },\n );\n }\n\n const resolvers = config.resolve as\n | Record<\n PropertyKey,\n (inputs: unknown, snapshot: ActivatedRouteSnapshot, state: RouterStateSnapshot) => any\n >\n | undefined;\n\n if (resolvers) {\n const resolve: Record<PropertyKey, ResolveFn<unknown>> = Object.create(null);\n\n for (const key of Reflect.ownKeys(resolvers)) {\n resolve[key] = (snapshot, state) => {\n assertIdentity(snapshot, id);\n\n return bridge(\n () => parseInputs(set, id, snapshot),\n (inputs) => resolvers[key](inputs, snapshot, state),\n );\n };\n }\n\n result.resolve = resolve;\n }\n\n return result;\n}\n\nexport function redirect(definition: () => AnyRoute): RedirectFunction {\n return async (snapshot) => {\n const router = inject(Router);\n const source = routeMetadata(definition());\n const config = source.config.redirect as {\n to: AnyRoute;\n params: Record<string, string>;\n search: { mode: string; values?: Record<string, unknown> };\n fragment: { mode: string; value?: string };\n };\n const target = routeMetadata(config.to);\n const raw = new Map<string, { values: string[]; array: boolean }>();\n\n for (let index = 0; index < source.segments.length; index += 1) {\n const segment = source.segments[index];\n\n if (segment.kind === \"scalar\") {\n raw.set(segment.name, {\n values: snapshot.url.slice(index, index + 1).map((value) => value.path),\n array: false,\n });\n } else if (segment.kind === \"catchall\") {\n raw.set(segment.name, {\n values: snapshot.url.slice(index).map((value) => value.path),\n array: true,\n });\n }\n }\n\n const jobs: Job[] = [];\n\n for (const key of new Set(Object.values(config.params))) {\n const input = raw.get(key);\n const raws = input?.values ?? [];\n const array = input?.array ?? false;\n\n validateRaw(\"path\", key, raws, array);\n jobs.push({ source: \"path\", key, raws, array, codec: source.params[key] });\n }\n\n if (config.search.mode === \"preserve\") {\n for (const key of Object.keys(target.search)) {\n const codec = target.search[key];\n const raws = snapshot.queryParamMap.getAll(key);\n\n if (raws.length === 0 && codecPresence(codec) === \"optional\") {\n continue;\n }\n\n validateRaw(\"search\", key, raws, false);\n jobs.push({ source: \"search\", key, raws, array: false, codec });\n }\n }\n\n // Every demand is prechecked. Async wrappers observe even synchronous preserved-search\n // throws after earlier source jobs launch, without detaching those later rejections.\n const logical = await runJobs(jobs);\n const params: Record<string, unknown> = Object.create(null);\n\n for (const [key, sourceKey] of Object.entries(config.params)) {\n params[key] = logical.params[sourceKey];\n }\n\n const path = createUrlForPath(config.to, params);\n const replacement: Record<string, string> = Object.create(null);\n\n if (config.search.mode === \"replace\") {\n const values = config.search.values!;\n\n for (const key of Object.keys(target.search).sort()) {\n const codec = target.search[key];\n\n if (\n codecPresence(codec) === \"optional\" &&\n (!Object.hasOwn(values, key) || values[key] === undefined)\n ) {\n continue;\n }\n\n const raw = codec.stringify(values[key]);\n\n if (typeof raw !== \"string\") {\n throw new TypeError(`Redirect search codec must stringify to a string: ${key}`);\n }\n\n replacement[key] = raw;\n }\n }\n\n // No native conversion before demanded codecs and destination stringification succeed.\n const tree = router.parseUrl(path);\n\n if (config.search.mode === \"preserve\") {\n tree.queryParams = { ...snapshot.queryParams };\n } else if (config.search.mode === \"replace\") {\n tree.queryParams = replacement;\n }\n\n if (config.fragment.mode === \"preserve\") {\n tree.fragment = snapshot.fragment;\n } else if (config.fragment.mode === \"replace\") {\n tree.fragment = config.fragment.value!;\n }\n\n return tree;\n };\n}\n\nfunction createUrlForPath(definition: AnyRoute, params: Record<string, unknown>): string {\n const metadata = routeMetadata(definition);\n const parts: string[] = [];\n\n function encode(raw: string): string {\n if (raw === \"\" || raw === \".\" || raw === \"..\") {\n throw new TypeError(\"Invalid redirect path value\");\n }\n\n return encodeURIComponent(raw).replace(/\\(/g, \"%28\").replace(/\\)/g, \"%29\");\n }\n\n for (const segment of metadata.segments) {\n if (segment.kind === \"static\") {\n parts.push(encode(segment.text));\n } else if (segment.kind === \"scalar\") {\n const raw = metadata.params[segment.name].stringify(params[segment.name]);\n\n if (typeof raw !== \"string\") {\n throw new TypeError(\"Redirect codec must stringify to a string\");\n }\n\n parts.push(encode(raw));\n } else {\n const values = params[segment.name];\n\n if (!Array.isArray(values)) {\n throw new TypeError(\"Redirect catchall requires an array\");\n }\n\n for (const value of values) {\n const raw = metadata.params[segment.name].stringify(value);\n\n if (typeof raw !== \"string\") {\n throw new TypeError(\"Redirect codec must stringify to a string\");\n }\n\n parts.push(encode(raw));\n }\n }\n }\n\n return `/${parts.join(\"/\")}`;\n}\n","import {\n DestroyRef,\n PendingTasks,\n inject,\n resourceFromSnapshots,\n signal,\n type ResourceSnapshot,\n} from \"@angular/core\";\nimport {\n ActivatedRoute,\n Router,\n NavigationStart,\n NavigationEnd,\n NavigationCancel,\n NavigationSkipped,\n NavigationError,\n NavigationCancellationCode,\n type ActivatedRouteSnapshot,\n} from \"@angular/router\";\nimport { routeMetadata } from \"@loozo/angular-router/_core\";\nimport {\n assertIdentity,\n fullOperation,\n type Operation,\n type Parsed,\n type RouteSet,\n} from \"./inputs.js\";\n\n// Shared parsing has no view/task lifetime. Each handle owns its visibility and relevance.\nexport function observeRoute(set: RouteSet, id: string) {\n const activated = inject(ActivatedRoute);\n const router = inject(Router);\n const destroy = inject(DestroyRef);\n const tasks = inject(PendingTasks);\n\n assertIdentity(activated.snapshot, id);\n\n const paired = signal<ResourceSnapshot<Parsed | undefined>>({\n status: \"loading\",\n value: undefined,\n });\n const data = signal<ResourceSnapshot<Readonly<Record<PropertyKey, unknown>> | undefined>>({\n status: \"loading\",\n value: undefined,\n });\n let survivor: ActivatedRouteSnapshot | undefined;\n let work: Operation | undefined;\n let commitment = -1;\n let pending: number | undefined;\n let visible = false;\n let destroyed = false;\n let release: (() => void) | undefined;\n let acquiring = false;\n\n function track(): void {\n if (release || destroyed || acquiring) {\n return;\n }\n\n // Native add synchronously notifies stability observers before returning ownership.\n acquiring = true;\n\n const cleanup = tasks.add();\n\n acquiring = false;\n\n if (destroyed) {\n cleanup();\n\n return;\n }\n\n release = cleanup;\n }\n\n function untrack(): void {\n const cleanup = release;\n\n release = undefined;\n cleanup?.();\n }\n\n function publish(): void {\n if (!visible || destroyed || !work) {\n return;\n }\n\n if (!work.outcome) {\n paired.set({ status: \"loading\", value: undefined });\n track();\n\n return;\n }\n\n if (\"value\" in work.outcome) {\n paired.set({ status: \"resolved\", value: work.outcome.value });\n } else {\n paired.set({ status: \"error\", error: work.outcome.error });\n }\n\n // A synchronous paired write always precedes package task removal.\n untrack();\n }\n\n function adopt(snapshot: ActivatedRouteSnapshot): void {\n assertIdentity(snapshot, id);\n\n if (snapshot === survivor) {\n return;\n }\n\n survivor = snapshot;\n\n const joined = fullOperation(set, id, snapshot);\n\n work = joined;\n\n if (!joined.outcome) {\n track();\n }\n\n joined.promise.then(\n () => {\n if (work === joined) {\n publish();\n }\n },\n () => {\n if (work === joined) {\n publish();\n }\n },\n );\n }\n\n function reconcile(): void {\n const successful = router.lastSuccessfulNavigation();\n\n if (successful && successful.id > commitment) {\n commitment = successful.id;\n adopt(activated.snapshot);\n }\n }\n\n function restore(): void {\n if (destroyed) {\n return;\n }\n\n reconcile();\n\n if (!survivor) {\n adopt(activated.snapshot);\n }\n\n const local: Record<PropertyKey, unknown> = Object.create(null);\n const resolvers = routeMetadata(set.records[id].definition()).config.resolve ?? {};\n\n for (const key of Reflect.ownKeys(resolvers)) {\n if (Object.hasOwn(survivor!.data, key)) {\n local[key] = survivor!.data[key];\n }\n }\n\n data.set({ status: \"resolved\", value: Object.freeze(local) });\n visible = true;\n publish();\n }\n\n function idleHandoff(): void {\n queueMicrotask(() => {\n if (destroyed || visible) {\n return;\n }\n\n const current = router.currentNavigation();\n const successful = router.lastSuccessfulNavigation();\n\n if (!current || current.id === successful?.id) {\n pending = undefined;\n restore();\n }\n });\n }\n\n function eligible(id: number): boolean {\n const current = router.currentNavigation();\n const successful = router.lastSuccessfulNavigation();\n\n if (current && current.id > id && current.id !== successful?.id) {\n return false;\n }\n\n return pending === undefined || pending === id;\n }\n\n // Subscribe before reading native phase: constructors can run inside event delivery.\n const subscription = router.events.subscribe((event) => {\n if (destroyed) {\n return;\n }\n\n if (event instanceof NavigationStart) {\n pending = event.id;\n visible = false;\n reconcile();\n paired.set({ status: \"loading\", value: undefined });\n data.set({ status: \"loading\", value: undefined });\n } else if (event instanceof NavigationEnd) {\n // Even an old End may expose a newer true survivor; it cannot settle a newer Start.\n reconcile();\n\n if (eligible(event.id)) {\n pending = undefined;\n restore();\n }\n } else if (event instanceof NavigationCancel) {\n reconcile();\n\n if (\n event.code === NavigationCancellationCode.Redirect ||\n event.code === NavigationCancellationCode.SupersededByNewNavigation\n ) {\n return;\n }\n\n if (eligible(event.id)) {\n pending = undefined;\n restore();\n }\n } else if (event instanceof NavigationSkipped) {\n reconcile();\n\n if (eligible(event.id)) {\n pending = undefined;\n restore();\n }\n } else if (event instanceof NavigationError && eligible(event.id)) {\n reconcile();\n pending = undefined;\n visible = false;\n\n let error = event.error;\n\n if (!(error instanceof Error)) {\n error = new Error(\"Navigation failure\", { cause: event.error });\n }\n\n paired.set({ status: \"error\", error });\n data.set({ status: \"error\", error });\n untrack();\n }\n });\n\n destroy.onDestroy(() => {\n destroyed = true;\n visible = false;\n subscription.unsubscribe();\n untrack();\n });\n\n // Synchronous task handoff prevents whenStable resolving before a missed-terminal microtask.\n track();\n\n if (!destroyed) {\n const current = router.currentNavigation();\n const successful = router.lastSuccessfulNavigation();\n\n if (!current || current.id === successful?.id) {\n restore();\n } else {\n pending = current.id;\n idleHandoff();\n }\n }\n\n function project(key: \"params\" | \"search\"): ResourceSnapshot<any> {\n const state = paired();\n\n if (state.status === \"error\") {\n return state;\n }\n\n return { status: state.status, value: state.value?.[key] };\n }\n\n return {\n params: resourceFromSnapshots(() => project(\"params\")),\n search: resourceFromSnapshots(() => project(\"search\")),\n data: resourceFromSnapshots(() => data()),\n };\n}\n","export { callbacks, redirect } from \"./callbacks.js\";\nexport { assertIdentity, parseInputs } from \"./inputs.js\";\nexport type { RecordBinding, RouteSet } from \"./inputs.js\";\n\nimport { inject, type Resource } from \"@angular/core\";\nimport { Router, type UrlTree } from \"@angular/router\";\nimport {\n createUrl,\n routeMetadata,\n type AnyRoute,\n type ParamsOf,\n type SearchOf,\n type UrlValues,\n} from \"@loozo/angular-router/_core\";\nimport { observeRoute } from \"./handle.js\";\nimport type { RouteSet } from \"./inputs.js\";\n\ndeclare const destinationBrand: unique symbol;\n\n/**\n * An inert nominal reference exported as `destination` by a route-local facade.\n *\n * @remarks\n * Use the exported object with a handle's link/navigate methods; no injection\n * context or target activation is needed. It selects its exact declaration,\n * not a canonical pathless winner. Only references from the caller's generated\n * set are accepted. Copies, spreads, fakes and authored routes are not references.\n * Do not construct this type or pass it to the root createUrl function.\n *\n * @typeParam Target - The referenced route's input and fragment schema.\n * @typeParam Set - The generator's nominal route-set identity.\n * @typeParam Id - The exact generated declaration identity.\n */\nexport declare class Destination<\n Target extends AnyRoute,\n Set = unknown,\n Id extends string = string,\n> {\n // Type-only identity, intentionally not read; object spreads must lose this member.\n // oxlint-disable-next-line no-unused-private-class-members\n readonly #nominal: void;\n readonly [destinationBrand]: { readonly target: Target; readonly set: Set; readonly id: Id };\n}\n\nconst destinations = new WeakMap<object, { getSet: () => RouteSet; id: string }>();\n\nexport function createDestination<Target extends AnyRoute, Set, Id extends string>(\n getSet: () => RouteSet,\n id: Id,\n): Destination<Target, Set, Id> {\n const destination = Object.freeze({});\n\n destinations.set(destination, { getSet, id });\n\n return destination as Destination<Target, Set, Id>;\n}\n\ntype DataOf<Target> = Target extends { readonly __data?: infer Data } ? Readonly<Data> : never;\ntype IsUnion<Value, Whole = Value> = Value extends unknown\n ? [Whole] extends [Value]\n ? false\n : true\n : never;\n\n/**\n * The noncallable typed handle returned by a colocated `injectRoute()` facade.\n *\n * @remarks\n * Obtain it in an Angular injection context for the exact generated activated\n * record. Params/search parse together; data contains only local resolver results,\n * not static/ancestor data or title. Resources are native readonly Angular\n * Resources: use hasValue before value access; error-state value reads throw.\n *\n * Navigation hides old values. Cancellation/same-URL skip restores the survivor\n * without reparsing; obsolete work cannot publish. Relevant parsing participates\n * in Angular stability until publication, error, replacement or destruction.\n * Codecs are not abortable and there is no package timeout or resolved-data cache.\n *\n * Selectors are single known authored literals, not concrete URLs or string\n * unions. `.` is exact-current; other absolute/relative selections use generated\n * canonical targets. Relative climbs count URL-template segments, not parent\n * edges. Catchall origins permit exact-current, absolute and reference targets,\n * not depth-dependent relative traversal. Every call supplies all target values;\n * there is no current-value reuse, extras argument or implicit query merge.\n *\n * @typeParam Target - The bound declaration's schema.\n * @typeParam Selected - Statically admitted literal selectors and target schemas.\n * @typeParam Set - The generator's nominal route-set identity.\n * @typeParam References - Exact declarations addressable by same-set references.\n *\n * @example\n * ```ts\n * import { injectRoute } from \"./route.generated.js\";\n * import { destination as report } from \"../report/route.generated.js\";\n *\n * const route = injectRoute(); // Inside an Angular injection context.\n * const link = route.link(report, { params: { reportId: 42 } });\n * // Bind link to Angular RouterLink, or call route.navigate with the same values.\n * ```\n */\nexport interface Handle<\n Target extends AnyRoute,\n Selected extends Record<string, AnyRoute> = {},\n Set = unknown,\n References extends Record<string, AnyRoute> = {},\n> {\n /** Effective positional params; undefined while pending or without a value. */\n readonly params: Resource<Readonly<ParamsOf<Target>> | undefined>;\n /** Effective declared search; paired with params from the same parse operation. */\n readonly search: Resource<Readonly<SearchOf<Target>> | undefined>;\n /** Own native resolver results only; settles independently of paired inputs. */\n readonly data: Resource<DataOf<Target> | undefined>;\n /**\n * Creates a native UrlTree for this exact declaration without navigating.\n *\n * @param values - Explicit effective params/search and optional own fragment.\n * @returns Router.parseUrl's result, suitable for Angular RouterLink.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n link<Keys extends keyof SearchOf<Target> = never>(values: UrlValues<Target, Keys>): UrlTree;\n /**\n * Creates a UrlTree for the exact bound declaration, not its pathless winner.\n *\n * @param selector - The exact-current literal `.`.\n * @param values - Explicit values for this declaration, with no current-input reuse.\n * @returns Router.parseUrl's result without navigating.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n link<Keys extends keyof SearchOf<Target> = never>(\n selector: \".\",\n values: UrlValues<Target, Keys>,\n ): UrlTree;\n /**\n * Creates a UrlTree for a statically admitted absolute/relative authored selector.\n *\n * @param selector - A single known template literal, never a concrete URL.\n * @param values - The selected target's complete explicit values.\n * @returns Router.parseUrl's result without navigating.\n * @throws Synchronously for unknown selectors or invalid URL values.\n */\n link<\n const Selector extends keyof Selected & string,\n Keys extends keyof SearchOf<NoInfer<Selected[Selector]>> = never,\n >(\n selector: Selector & (IsUnion<Selector> extends true ? never : unknown),\n values: UrlValues<NoInfer<Selected[Selector]>, Keys>,\n ): UrlTree;\n /**\n * Creates a UrlTree for a generated reference's own exact declaration.\n *\n * @param selector - A genuine destination exported by a facade in this route set.\n * @param values - The referenced declaration's complete explicit values.\n * @returns Router.parseUrl's result without navigating.\n * @throws Synchronously for foreign/fake references or invalid URL values.\n */\n link<\n const Id extends keyof References & string,\n Keys extends keyof SearchOf<NoInfer<References[Id]>> = never,\n >(\n selector: Destination<NoInfer<References[Id]>, Set, Id> &\n (IsUnion<Id> extends true ? never : unknown),\n values: UrlValues<NoInfer<References[Id]>, Keys>,\n ): UrlTree;\n /**\n * Navigates to this exact declaration via Router.navigateByUrl.\n *\n * @param values - Explicit effective params/search and optional own fragment.\n * @returns Angular's identical Promise; Angular owns skips, redirects and failures.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n navigate<Keys extends keyof SearchOf<Target> = never>(\n values: UrlValues<Target, Keys>,\n ): Promise<boolean>;\n /**\n * Navigates to the exact bound declaration, not its pathless winner.\n *\n * @param selector - The exact-current literal `.`.\n * @param values - Explicit values for this declaration, with no current-input reuse.\n * @returns Angular's identical Router.navigateByUrl Promise.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n navigate<Keys extends keyof SearchOf<Target> = never>(\n selector: \".\",\n values: UrlValues<Target, Keys>,\n ): Promise<boolean>;\n /**\n * Navigates to a statically admitted absolute/relative authored selector.\n *\n * @param selector - A single known template literal, never a concrete URL.\n * @param values - The selected target's complete explicit values.\n * @returns Angular's identical Router.navigateByUrl Promise.\n * @throws Synchronously for unknown selectors or invalid URL values.\n */\n navigate<\n const Selector extends keyof Selected & string,\n Keys extends keyof SearchOf<NoInfer<Selected[Selector]>> = never,\n >(\n selector: Selector & (IsUnion<Selector> extends true ? never : unknown),\n values: UrlValues<NoInfer<Selected[Selector]>, Keys>,\n ): Promise<boolean>;\n /**\n * Navigates to a generated reference's own exact declaration.\n *\n * @param selector - A genuine destination exported by a facade in this route set.\n * @param values - The referenced declaration's complete explicit values.\n * @returns Angular's identical Router.navigateByUrl Promise.\n * @throws Synchronously for foreign/fake references or invalid URL values.\n */\n navigate<\n const Id extends keyof References & string,\n Keys extends keyof SearchOf<NoInfer<References[Id]>> = never,\n >(\n selector: Destination<NoInfer<References[Id]>, Set, Id> &\n (IsUnion<Id> extends true ? never : unknown),\n values: UrlValues<NoInfer<References[Id]>, Keys>,\n ): Promise<boolean>;\n}\n\nexport function nativeOptions(definition: AnyRoute): Record<string, unknown> {\n const config = routeMetadata(definition).config;\n const options: Record<string, unknown> = {};\n\n for (const key of [\"providers\", \"title\", \"data\", \"canDeactivate\", \"runGuardsAndResolvers\"]) {\n if (Object.hasOwn(config, key)) {\n options[key] = config[key];\n }\n }\n\n return options;\n}\n\nexport function injectGeneratedRoute<\n Target extends AnyRoute,\n Selected extends Record<string, AnyRoute>,\n Set,\n References extends Record<string, AnyRoute>,\n>(set: RouteSet, id: string): Handle<Target, Selected, Set, References> {\n const router = inject(Router);\n const view = observeRoute(set, id);\n\n function url(args: readonly unknown[]): string {\n if (args.length !== 1 && args.length !== 2) {\n throw new TypeError(\"Expected values or a selected destination and values\");\n }\n\n let target = id;\n let values = args[0];\n\n if (args.length === 2) {\n const selector = args[0];\n\n values = args[1];\n\n if (typeof selector === \"string\") {\n if (selector !== \".\") {\n if (Object.hasOwn(set.absolute, selector)) {\n target = set.absolute[selector];\n } else if (Object.hasOwn(set.relative[id], selector)) {\n target = set.relative[id][selector];\n } else {\n throw new TypeError(`Unknown generated selector: ${selector}`);\n }\n }\n } else {\n if (typeof selector !== \"object\" || selector === null) {\n throw new TypeError(\"Expected a literal selector or genuine generated destination\");\n }\n\n const destination = destinations.get(selector);\n\n if (\n !destination ||\n destination.getSet() !== set ||\n !Object.hasOwn(set.records, destination.id)\n ) {\n throw new TypeError(\"Expected a destination from the same generated set\");\n }\n\n target = destination.id;\n }\n }\n\n return createUrl(set.destinations[target](), values as UrlValues<AnyRoute>);\n }\n\n return {\n params: view.params,\n search: view.search,\n data: view.data as Resource<DataOf<Target> | undefined>,\n link: ((...args: unknown[]) => router.parseUrl(url(args))) as Handle<\n Target,\n Selected,\n Set,\n References\n >[\"link\"],\n navigate: ((...args: unknown[]) => router.navigateByUrl(url(args))) as Handle<\n Target,\n Selected,\n Set,\n References\n >[\"navigate\"],\n };\n}\n"],"mappings":";;;;AA6BA,SAAgB,YACd,UACA,IAAU;CAEV,MAAM,OAAO,SAAS,aAAa;CAEnC,OACE,CAAC,CAAC,QACF,OAAO,OAAO,MAAM,6BAA6B,KACjD,KAAK,gCAAgC;AAEzC;AAEA,SAAgB,eACd,UACA,IAAU;CAEV,IAAI,CAAC,YAAY,UAAU,EAAE,GAC3B,MAAM,IAAI,MAAM,6CAA6C,IAAI;AAErE;AAEA,SAAgB,WACd,QACA,KACA,QACA,OAAe;CAEf,OAAO,OAAO,OAAO,IAAI,MAAM,WAAW,OAAM,SAAU,IAAG,IAAK,UAAU,EAAE,MAAK,CAAE,GAAG;EACtF;EACA;EACA;CACD,CAAA;AACH;AAEA,SAAgB,YACd,QACA,KACA,MACA,OAAc;CAEd,IA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AAS,KAAK;EAElB,IAAI,KAAK,WAAW,GAAG;GACrB,MAAM,WAAW,KAAK;GAEtB,SAAS,KAAK;GAEd,IAAI,OAAO,aAAa,UACtB;QAAI,aAAa,KAAK;KACpB,IAAI,OAAO,OAAO,IAAI,UAAU,QAAQ,GACtC,SAAS,IAAI,SAAS;UACjB,IAAI,OAAO,OAAO,IAAI,SAAS,KAAK,QAAQ,GACjD,SAAS,IAAI,SAAS,GAAG,CAAC;UAE1B,MAAM,IAAI,UAAU,+BAA+B,UAAU;IAEjE;UACK;IACL,IAAI,OAAO,aAAa,YAAY,aAAa,MAC/C,MAAM,IAAI,UAAU,8DAA8D;IAGpF,MAAM,cAAc,aAAa,IAAI,QAAQ;IAE7C,IACE,CAAC,eACD,YAAY,OAAM,MAAO,OACzB,CAAC,OAAO,OAAO,IAAI,SAAS,YAAY,EAAE,GAE1C,MAAM,IAAI,UAAU,oDAAoD;IAG1E,SAAS,YAAY;GACvB;EACF;EAEA,OAAO,UAAU,IAAI,aAAa,OAAO,CAAA,GAAI,MAA6B;CAC5E;CAEA,OAAO;EACL,QAAQ,KAAK;EACb,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,GAAG,SAAoB,OAAO,SAAS,IAAI,IAAI,CAAC;EAMxD,YAAY,GAAG,SAAoB,OAAO,cAAc,IAAI,IAAI,CAAC;CAMlE;AACH"}
|
|
1
|
+
{"version":3,"file":"loozo-angular-router-_generated.mjs","names":[],"sources":["../../_generated/src/inputs.ts","../../_generated/src/callbacks.ts","../../_generated/src/handle.ts","../../_generated/src/index.ts"],"sourcesContent":["import type { ActivatedRouteSnapshot, PartialMatchRouteSnapshot } from \"@angular/router\";\nimport { codecFallback, routeMetadata, type AnyRoute } from \"@loozo/angular-router/_core\";\n\nexport interface RecordBinding {\n readonly definition: () => AnyRoute;\n readonly owners: readonly string[];\n}\nexport interface RouteSet {\n readonly records: Readonly<Record<string, RecordBinding>>;\n readonly destinations: Readonly<Record<string, () => AnyRoute>>;\n readonly absolute: Readonly<Record<string, string>>;\n readonly relative: Readonly<Record<string, Readonly<Record<string, string>>>>;\n}\nexport interface Parsed {\n readonly params: Readonly<Record<string, unknown>>;\n readonly search: Readonly<Record<string, unknown>>;\n}\nexport interface Job {\n readonly key: string;\n readonly raws: readonly string[];\n readonly array: boolean;\n readonly codec: { parse(raw: string): unknown };\n}\n\nexport function hasIdentity(\n snapshot: Pick<ActivatedRouteSnapshot, \"routeConfig\">,\n id: string,\n): boolean {\n const data = snapshot.routeConfig?.data;\n\n return (\n !!data &&\n Object.hasOwn(data, \"__loozoAngularRouterRouteId\") &&\n data.__loozoAngularRouterRouteId === id\n );\n}\n\nexport function assertIdentity(\n snapshot: Pick<ActivatedRouteSnapshot, \"routeConfig\">,\n id: string,\n): void {\n if (!hasIdentity(snapshot, id)) {\n throw new Error(`Generated route wiring identity mismatch: ${id}`);\n }\n}\n\n// Private: input errors are Errors with source/key/reason, not an exported class.\nclass InputError extends Error {\n readonly source = \"path\";\n\n constructor(\n readonly key: string,\n readonly reason: \"missing\" | \"repeated\" | \"invalid\",\n cause?: unknown,\n ) {\n super(`Invalid path input ${key}: ${reason}`, { cause });\n }\n}\n\nexport function validateRaw(\n key: string,\n raws: readonly unknown[],\n array: boolean,\n): asserts raws is readonly string[] {\n if (!array && raws.length === 0) {\n throw new InputError(key, \"missing\");\n }\n\n if (!array && raws.length > 1) {\n throw new InputError(key, \"repeated\");\n }\n\n if (raws.some((raw) => typeof raw !== \"string\")) {\n throw new InputError(key, \"invalid\", new TypeError(\"Raw input must be a decoded string\"));\n }\n}\n\n/**\n * Runs one parser. A throw is invalid input; a thenable is a programming error,\n * thrown as a TypeError so it fails the navigation instead of reading as invalid.\n */\nfunction parse(codec: Job[\"codec\"], raw: string): { value: unknown } | { cause: unknown } {\n let value: unknown;\n\n try {\n value = codec.parse(raw);\n } catch (cause) {\n return { cause };\n }\n\n if (\n value !== null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n typeof (value as PromiseLike<unknown>).then === \"function\"\n ) {\n // Observe the stray result so its rejection can't surface as unhandled.\n Promise.resolve(value).catch(() => undefined);\n\n throw new TypeError(\"ParamCodec.parse must return its value synchronously, not a Promise\");\n }\n\n return { value };\n}\n\nexport function pathJobs(definition: AnyRoute, url: readonly { path: string }[]): Job[] {\n const metadata = routeMetadata(definition);\n const local = new Map<string, Job>();\n\n for (let index = 0; index < metadata.localSegments.length; index += 1) {\n const segment = metadata.localSegments[index];\n\n if (segment.kind === \"static\") {\n continue;\n }\n\n let raws: unknown[] = [];\n const array = segment.kind === \"catchall\";\n\n if (array) {\n raws = url.slice(index).map((value) => value.path);\n } else if (index < url.length) {\n raws = [url[index].path];\n }\n\n validateRaw(segment.name, raws, array);\n // Repeated local scalars intentionally use Angular's last positional occurrence.\n local.set(segment.name, {\n key: segment.name,\n raws,\n array,\n codec: metadata.localParams[segment.name],\n });\n }\n\n return [...local.values()];\n}\n\n/** Parses prechecked path jobs; the first codec failure is an input error. */\nexport function runPathJobs(jobs: readonly Job[]): Readonly<Record<string, unknown>> {\n const params: Record<string, unknown> = Object.create(null);\n\n for (const job of jobs) {\n const values: unknown[] = [];\n\n for (const raw of job.raws) {\n const result = parse(job.codec, raw);\n\n if (\"cause\" in result) {\n throw new InputError(job.key, \"invalid\", result.cause);\n }\n\n values.push(result.value);\n }\n\n if (job.array) {\n params[job.key] = Object.freeze(values);\n } else {\n params[job.key] = values[0];\n }\n }\n\n return Object.freeze(params);\n}\n\n/**\n * Parses a declaration's effective search. It never fails on input: a missing,\n * repeated or invalid value reads as the key's fallback, or leaves it absent.\n */\nexport function parseSearch(\n definition: AnyRoute,\n snapshot: Pick<ActivatedRouteSnapshot, \"queryParamMap\">,\n): Readonly<Record<string, unknown>> {\n const metadata = routeMetadata(definition);\n const search: Record<string, unknown> = Object.create(null);\n\n for (const key of Object.keys(metadata.search)) {\n const codec = metadata.search[key];\n const raws: unknown[] = snapshot.queryParamMap.getAll(key);\n\n if (raws.length === 1 && typeof raws[0] === \"string\") {\n const result = parse(codec, raws[0]);\n\n if (\"value\" in result) {\n search[key] = result.value;\n\n continue;\n }\n }\n\n const fallback = codecFallback(codec);\n\n if (fallback) {\n search[key] = fallback.value;\n }\n }\n\n return Object.freeze(search);\n}\n\ntype Outcome<Value> = { readonly value: Value } | { readonly error: unknown };\ntype Cache<Value> = WeakMap<object, WeakMap<object, Outcome<Value>>>;\n\nconst full: Cache<Parsed> = new WeakMap();\nconst paths: Cache<Readonly<Record<string, unknown>>> = new WeakMap();\nconst matching: Cache<Parsed | undefined> = new WeakMap();\n\n// One result or failure per exact declaration and snapshot, shared by every reader.\nfunction memo<Value>(\n cache: Cache<Value>,\n definition: AnyRoute,\n snapshot: object,\n run: () => Value,\n): Value {\n let snapshots = cache.get(definition);\n\n if (!snapshots) {\n snapshots = new WeakMap();\n cache.set(definition, snapshots);\n }\n\n let outcome = snapshots.get(snapshot);\n\n if (!outcome) {\n try {\n outcome = { value: run() };\n } catch (error) {\n outcome = { error };\n }\n\n snapshots.set(snapshot, outcome);\n }\n\n if (\"error\" in outcome) {\n throw outcome.error;\n }\n\n return outcome.value;\n}\n\n/** The effective inputs of a complete snapshot, shared by guards, resolvers and handles. */\nexport function parseInputs(set: RouteSet, id: string, snapshot: ActivatedRouteSnapshot): Parsed {\n assertIdentity(snapshot, id);\n\n const binding = set.records[id];\n\n return memo(full, binding.definition(), snapshot, () => {\n const jobs: Job[] = [];\n\n for (const ownerId of binding.owners) {\n const definition = set.records[ownerId].definition();\n\n // Pathless/static owners contribute no positional input. Effective search belongs\n // to this complete future record; inherited data is never positional authority.\n if (!routeMetadata(definition).localSegments.some((segment) => segment.kind !== \"static\")) {\n continue;\n }\n\n const owner = [...snapshot.pathFromRoot]\n .reverse()\n .find((record) => hasIdentity(record, ownerId));\n\n if (!owner) {\n throw new Error(`Generated route ancestor missing: ${ownerId}`);\n }\n\n assertIdentity(owner, ownerId);\n jobs.push(...pathJobs(definition, owner.url));\n }\n\n const params = runPathJobs(jobs);\n\n return Object.freeze({ params, search: parseSearch(binding.definition(), snapshot) });\n });\n}\n\n/**\n * Parses a matching candidate's own path params only. Angular passes one partial\n * snapshot to all of a candidate's canMatch guards, so they share this result.\n *\n * @returns An input error when a param is invalid; throws only programming errors.\n */\nexport function pathInputs(\n set: RouteSet,\n id: string,\n snapshot: PartialMatchRouteSnapshot,\n): { params: Readonly<Record<string, unknown>> } | { error: Error } {\n assertIdentity(snapshot, id);\n\n const definition = set.records[id].definition();\n\n try {\n return {\n params: memo(paths, definition, snapshot, () =>\n runPathJobs(pathJobs(definition, snapshot.url)),\n ),\n };\n } catch (error) {\n if (error instanceof InputError) {\n return { error };\n }\n\n throw error;\n }\n}\n\n/**\n * Local path params plus effective search for a candidate's canMatch guards, the\n * generated one included, or undefined when the path params fail: the generated\n * guard owns that outcome.\n */\nexport function matchingInputs(\n set: RouteSet,\n id: string,\n snapshot: PartialMatchRouteSnapshot,\n): Parsed | undefined {\n const definition = set.records[id].definition();\n\n return memo(matching, definition, snapshot, () => {\n const path = pathInputs(set, id, snapshot);\n\n // Search parses only once the path matches: a candidate the path rules out runs no\n // search codecs.\n if (\"error\" in path) {\n return undefined;\n }\n\n return Object.freeze({ params: path.params, search: parseSearch(definition, snapshot) });\n });\n}\n","import { inject } from \"@angular/core\";\nimport {\n Router,\n RedirectCommand,\n UrlTree,\n type Route,\n type ActivatedRouteSnapshot,\n type RouterStateSnapshot,\n type GuardResult,\n type CanActivateFn,\n type CanActivateChildFn,\n type CanMatchFn,\n type ResolveFn,\n type RedirectFunction,\n} from \"@angular/router\";\nimport { from, isObservable, map, type ObservableInput } from \"rxjs\";\nimport { routeMetadata, type AnyRoute } from \"@loozo/angular-router/_core\";\nimport {\n hasIdentity,\n parseInputs,\n matchingInputs,\n pathInputs,\n runPathJobs,\n validateRaw,\n type Job,\n type RouteSet,\n} from \"./inputs.js\";\n\n// Parsing is synchronous, so every adapter calls its callback in the same call Angular\n// made: Angular's injection context is still active and inject() works at entry.\nexport function callbacks(\n set: RouteSet,\n id: string,\n): Pick<Route, \"canActivate\" | \"canActivateChild\" | \"canMatch\" | \"resolve\" | \"title\"> {\n const metadata = routeMetadata(set.records[id].definition());\n const config = metadata.config;\n const result: Pick<Route, \"canActivate\" | \"canActivateChild\" | \"canMatch\" | \"resolve\" | \"title\"> =\n {};\n const activate = config.canActivate as readonly ((...args: any[]) => any)[] | undefined;\n\n if (activate) {\n result.canActivate = activate.map(\n (callback): CanActivateFn =>\n (snapshot, state) =>\n callback(parseInputs(set, id, snapshot), snapshot, state),\n );\n }\n\n const children = config.canActivateChild as readonly ((...args: any[]) => any)[] | undefined;\n\n if (children) {\n result.canActivateChild = children.map(\n (callback): CanActivateChildFn =>\n (child, state) => {\n let parent: ActivatedRouteSnapshot | undefined;\n\n // The native ancestry includes child itself; only proper ancestors can declare this guard.\n for (let index = child.pathFromRoot.length - 2; index >= 0; index -= 1) {\n const ancestor = child.pathFromRoot[index];\n\n if (hasIdentity(ancestor, id)) {\n parent = ancestor;\n\n break;\n }\n }\n\n if (!parent) {\n throw new Error(`Generated guard ancestor missing: ${id}`);\n }\n\n return callback(parseInputs(set, id, parent), child, state);\n },\n );\n }\n\n const matching = config.canMatch as readonly ((...args: any[]) => any)[] | undefined;\n const canMatch: CanMatchFn[] = [];\n\n // Local path params decide whether this record matches. Angular runs every canMatch\n // guard concurrently and prefers the first non-true result in array order.\n if (\n metadata.localSegments.some((segment) => segment.kind !== \"static\") ||\n Object.keys(metadata.search).length > 0\n ) {\n const handler = config.onInvalidParams as ((...args: any[]) => unknown) | undefined;\n\n canMatch.push((route, segments, snapshot) => {\n const path = pathInputs(set, id, snapshot);\n\n if (!(\"error\" in path)) {\n // Search never decides the match, but Angular runs this guard on every navigation,\n // query-only ones included, so a thenable search parse fails it here.\n matchingInputs(set, id, snapshot);\n\n return true;\n }\n\n if (!handler) {\n return false;\n }\n\n const decision = handler(path.error, route, segments, snapshot);\n\n if (isObservable(decision) || isPromiseResult(decision)) {\n return from(decision as ObservableInput<unknown>).pipe(map(invalidParamsResult));\n }\n\n return invalidParamsResult(decision);\n });\n }\n\n if (matching) {\n for (const callback of matching) {\n canMatch.push((route, segments, snapshot) => {\n const inputs = matchingInputs(set, id, snapshot);\n\n // Invalid path params: the generated guard ahead of this one decides.\n if (inputs === undefined) {\n return false;\n }\n\n return callback(inputs, route, segments, snapshot);\n });\n }\n }\n\n if (canMatch.length > 0) {\n result.canMatch = canMatch;\n }\n\n const resolvers = config.resolve as\n | Record<\n PropertyKey,\n (inputs: unknown, snapshot: ActivatedRouteSnapshot, state: RouterStateSnapshot) => any\n >\n | undefined;\n\n if (resolvers) {\n const resolve: Record<PropertyKey, ResolveFn<unknown>> = Object.create(null);\n\n for (const key of Reflect.ownKeys(resolvers)) {\n resolve[key] = (snapshot, state) =>\n resolvers[key](parseInputs(set, id, snapshot), snapshot, state);\n }\n\n result.resolve = resolve;\n }\n\n const title = config.title as\n | string\n | ((inputs: unknown, snapshot: ActivatedRouteSnapshot, state: RouterStateSnapshot) => any)\n | undefined;\n\n // Angular runs a title callback as a resolver, so it's adapted like one.\n if (typeof title === \"function\") {\n result.title = (snapshot, state) => title(parseInputs(set, id, snapshot), snapshot, state);\n } else if (title !== undefined) {\n result.title = title;\n }\n\n return result;\n}\n\nfunction isPromiseResult(value: unknown): value is PromiseLike<unknown> {\n return !!value && typeof (value as PromiseLike<unknown>).then === \"function\";\n}\n\n// Invalid params can't match, so a handler may only refuse or redirect.\nfunction invalidParamsResult(decision: unknown): GuardResult {\n if (decision === false || decision instanceof UrlTree || decision instanceof RedirectCommand) {\n return decision;\n }\n\n throw new TypeError(\"onInvalidParams must return false, a UrlTree or a RedirectCommand\");\n}\n\nexport function redirect(definition: () => AnyRoute): RedirectFunction {\n return (snapshot) => {\n const router = inject(Router);\n const source = routeMetadata(definition());\n const config = source.config.redirect as {\n to: AnyRoute;\n params: Record<string, string>;\n search: { mode: string; values?: Record<string, unknown> };\n fragment: { mode: string; value?: string };\n };\n const target = routeMetadata(config.to);\n const raw = new Map<string, { values: string[]; array: boolean }>();\n\n for (let index = 0; index < source.segments.length; index += 1) {\n const segment = source.segments[index];\n\n if (segment.kind === \"scalar\") {\n raw.set(segment.name, {\n values: snapshot.url.slice(index, index + 1).map((value) => value.path),\n array: false,\n });\n } else if (segment.kind === \"catchall\") {\n raw.set(segment.name, {\n values: snapshot.url.slice(index).map((value) => value.path),\n array: true,\n });\n }\n }\n\n const jobs: Job[] = [];\n\n // Only mapped source params are parsed, each cardinality checked before any parser runs.\n for (const key of new Set(Object.values(config.params))) {\n const input = raw.get(key);\n const raws = input?.values ?? [];\n const array = input?.array ?? false;\n\n validateRaw(key, raws, array);\n jobs.push({ key, raws, array, codec: source.params[key] });\n }\n\n // A failure fails the navigation: a redirect record has no matching guard to fall through.\n const logical = runPathJobs(jobs);\n const params: Record<string, unknown> = Object.create(null);\n\n for (const [key, sourceKey] of Object.entries(config.params)) {\n params[key] = logical[sourceKey];\n }\n\n const path = createUrlForPath(config.to, params);\n const replacement: Record<string, string> = Object.create(null);\n\n if (config.search.mode === \"replace\") {\n const values = config.search.values!;\n\n for (const key of Object.keys(target.search).sort()) {\n if (!Object.hasOwn(values, key) || values[key] === undefined) {\n continue;\n }\n\n const raw = target.search[key].stringify(values[key]);\n\n if (typeof raw !== \"string\") {\n throw new TypeError(`Redirect search codec must stringify to a string: ${key}`);\n }\n\n replacement[key] = raw;\n }\n }\n\n // No native conversion before source codecs and destination stringification succeed.\n const tree = router.parseUrl(path);\n\n if (config.search.mode === \"preserve\") {\n tree.queryParams = { ...snapshot.queryParams };\n } else if (config.search.mode === \"replace\") {\n tree.queryParams = replacement;\n }\n\n if (config.fragment.mode === \"preserve\") {\n tree.fragment = snapshot.fragment;\n } else if (config.fragment.mode === \"replace\") {\n tree.fragment = config.fragment.value!;\n }\n\n return tree;\n };\n}\n\nfunction createUrlForPath(definition: AnyRoute, params: Record<string, unknown>): string {\n const metadata = routeMetadata(definition);\n const parts: string[] = [];\n\n function encode(raw: string): string {\n if (raw === \"\" || raw === \".\" || raw === \"..\") {\n throw new TypeError(\"Invalid redirect path value\");\n }\n\n return encodeURIComponent(raw).replace(/\\(/g, \"%28\").replace(/\\)/g, \"%29\");\n }\n\n for (const segment of metadata.segments) {\n if (segment.kind === \"static\") {\n parts.push(encode(segment.text));\n } else if (segment.kind === \"scalar\") {\n const raw = metadata.params[segment.name].stringify(params[segment.name]);\n\n if (typeof raw !== \"string\") {\n throw new TypeError(\"Redirect codec must stringify to a string\");\n }\n\n parts.push(encode(raw));\n } else {\n const values = params[segment.name];\n\n if (!Array.isArray(values)) {\n throw new TypeError(\"Redirect catchall requires an array\");\n }\n\n for (const value of values) {\n const raw = metadata.params[segment.name].stringify(value);\n\n if (typeof raw !== \"string\") {\n throw new TypeError(\"Redirect codec must stringify to a string\");\n }\n\n parts.push(encode(raw));\n }\n }\n }\n\n return `/${parts.join(\"/\")}`;\n}\n","import { DestroyRef, computed, inject, signal, type Signal } from \"@angular/core\";\nimport { ActivatedRoute, Router, type ActivatedRouteSnapshot } from \"@angular/router\";\nimport { routeMetadata } from \"@loozo/angular-router/_core\";\nimport { merge } from \"rxjs\";\nimport { assertIdentity, parseInputs, type RouteSet } from \"./inputs.js\";\n\n/**\n * Signals of the route's committed snapshot. Angular replaces ActivatedRoute.snapshot\n * only when a navigation activates, so a pending, cancelled or failed navigation\n * leaves the values alone; params, search and data change together, from one snapshot.\n */\nexport function observeRoute(\n set: RouteSet,\n id: string,\n): {\n params: Signal<Readonly<Record<string, unknown>>>;\n search: Signal<Readonly<Record<string, unknown>>>;\n data: Signal<Readonly<Record<PropertyKey, unknown>>>;\n} {\n const activated = inject(ActivatedRoute);\n const router = inject(Router);\n\n assertIdentity(activated.snapshot, id);\n\n const snapshot = signal<ActivatedRouteSnapshot>(activated.snapshot);\n // Activation replaces the snapshot, then emits the route's changed observables, then\n // ActivationEnd. Following both keeps reads current inside subscribers registered after\n // the handle; router events cover a new snapshot whose values are all equal.\n const subscription = merge(\n activated.queryParams,\n activated.fragment,\n activated.params,\n activated.url,\n activated.data,\n router.events,\n ).subscribe(() => {\n snapshot.set(activated.snapshot);\n });\n\n inject(DestroyRef).onDestroy(() => subscription.unsubscribe());\n\n // Shares the parse of guards and resolvers for the same snapshot. An error here\n // means a codec rejected a value it accepted while matching, and reading rethrows it.\n const inputs = computed(() => parseInputs(set, id, snapshot()));\n const resolvers = routeMetadata(set.records[id].definition()).config.resolve ?? {};\n\n return {\n params: computed(() => inputs().params),\n search: computed(() => inputs().search),\n data: computed(() => {\n const data = snapshot().data;\n const own: Record<PropertyKey, unknown> = Object.create(null);\n\n for (const key of Reflect.ownKeys(resolvers)) {\n if (Object.hasOwn(data, key)) {\n own[key] = data[key];\n }\n }\n\n return Object.freeze(own);\n }),\n };\n}\n","export { callbacks, redirect } from \"./callbacks.js\";\nexport { assertIdentity, parseInputs } from \"./inputs.js\";\nexport type { RecordBinding, RouteSet } from \"./inputs.js\";\n\nimport { inject, type Signal } from \"@angular/core\";\nimport { Router, type UrlTree } from \"@angular/router\";\nimport {\n createUrl,\n routeMetadata,\n type AnyRoute,\n type ParamsOf,\n type SearchOf,\n type UrlValues,\n} from \"@loozo/angular-router/_core\";\nimport { observeRoute } from \"./handle.js\";\nimport type { RouteSet } from \"./inputs.js\";\n\ndeclare const destinationBrand: unique symbol;\n\n/**\n * An inert nominal reference exported as `destination` by a route-local facade.\n *\n * @remarks\n * Use the exported object with a handle's link/navigate methods; no injection\n * context or target activation is needed. It selects its exact declaration,\n * not a canonical pathless winner. Only references from the caller's generated\n * set are accepted. Copies, spreads, fakes and authored routes are not references.\n * Do not construct this type or pass it to the root createUrl function.\n *\n * @typeParam Target - The referenced route's input and fragment schema.\n * @typeParam Set - The generator's nominal route-set identity.\n * @typeParam Id - The exact generated declaration identity.\n */\nexport declare class Destination<\n Target extends AnyRoute,\n Set = unknown,\n Id extends string = string,\n> {\n // Type-only identity, intentionally not read; object spreads must lose this member.\n // oxlint-disable-next-line no-unused-private-class-members\n readonly #nominal: void;\n /** Type-only nominal brand carrying the reference's identity; not populated at runtime. */\n readonly [destinationBrand]: {\n /** Type-only: the referenced route's input and fragment schema. */\n readonly target: Target;\n /** Type-only: the generator's nominal route-set identity. */\n readonly set: Set;\n /** Type-only: the exact generated declaration identity. */\n readonly id: Id;\n };\n}\n\nconst destinations = new WeakMap<object, { getSet: () => RouteSet; id: string }>();\n\nexport function createDestination<Target extends AnyRoute, Set, Id extends string>(\n getSet: () => RouteSet,\n id: Id,\n): Destination<Target, Set, Id> {\n const destination = Object.freeze({});\n\n destinations.set(destination, { getSet, id });\n\n return destination as Destination<Target, Set, Id>;\n}\n\ntype DataOf<Target> = Target extends { readonly __data?: infer Data } ? Readonly<Data> : never;\ntype IsUnion<Value, Whole = Value> = Value extends unknown\n ? [Whole] extends [Value]\n ? false\n : true\n : never;\n\n/**\n * The noncallable typed handle returned by a colocated `injectRoute()` facade.\n *\n * @remarks\n * Obtain it in an Angular injection context for the exact generated activated\n * record. Params, search and data are readonly Angular Signals of the route's\n * committed snapshot, with values from the first read. Data contains only local\n * resolver results, not static/ancestor data or title.\n *\n * While a navigation is pending, the signals keep the current snapshot's values;\n * when a navigation commits a new snapshot for this route, all three change\n * together. Cancellation, failure or a same-URL skip leaves them unchanged. For\n * pending-navigation UI, read Angular's `Router.currentNavigation()`. There is no\n * resolved-data cache. Reading params or search throws only when a path codec\n * rejects a value it accepted while matching, a programming error.\n *\n * Selectors are single known authored literals, not concrete URLs or string\n * unions. `.` is exact-current; other absolute/relative selections use generated\n * canonical targets. Relative climbs count URL-template segments, not parent\n * edges. Catchall origins permit exact-current, absolute and reference targets,\n * not depth-dependent relative traversal. Every call supplies all target values;\n * there is no current-value reuse, extras argument or implicit query merge.\n *\n * @typeParam Target - The bound declaration's schema.\n * @typeParam Selected - Statically admitted literal selectors and target schemas.\n * @typeParam Set - The generator's nominal route-set identity.\n * @typeParam References - Exact declarations addressable by same-set references.\n *\n * @example\n * ```ts\n * import { injectRoute } from \"./route.generated.js\";\n * import { destination as report } from \"../report/route.generated.js\";\n *\n * const route = injectRoute(); // Inside an Angular injection context.\n * const link = route.link(report, { params: { reportId: 42 } });\n * // Bind link to Angular RouterLink, or call route.navigate with the same values.\n * ```\n */\nexport interface Handle<\n Target extends AnyRoute,\n Selected extends Record<string, AnyRoute> = {},\n Set = unknown,\n References extends Record<string, AnyRoute> = {},\n> {\n /** Effective positional params of the committed snapshot; kept while a navigation is pending. */\n readonly params: Signal<Readonly<ParamsOf<Target>>>;\n /** Effective declared search, from the same snapshot as params; absent keys have no value or fallback. */\n readonly search: Signal<Readonly<SearchOf<Target>>>;\n /** Own native resolver results only, from the same snapshot as params. */\n readonly data: Signal<DataOf<Target>>;\n /**\n * Creates a native UrlTree for this exact declaration without navigating.\n *\n * @param values - Explicit effective params/search and optional own fragment.\n * @returns Router.parseUrl's result, suitable for Angular RouterLink.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n link<Keys extends keyof SearchOf<Target> = never>(values: UrlValues<Target, Keys>): UrlTree;\n /**\n * Creates a UrlTree for the exact bound declaration, not its pathless winner.\n *\n * @param selector - The exact-current literal `.`.\n * @param values - Explicit values for this declaration, with no current-input reuse.\n * @returns Router.parseUrl's result without navigating.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n link<Keys extends keyof SearchOf<Target> = never>(\n selector: \".\",\n values: UrlValues<Target, Keys>,\n ): UrlTree;\n /**\n * Creates a UrlTree for a statically admitted absolute/relative authored selector.\n *\n * @param selector - A single known template literal, never a concrete URL.\n * @param values - The selected target's complete explicit values.\n * @returns Router.parseUrl's result without navigating.\n * @throws Synchronously for unknown selectors or invalid URL values.\n */\n link<\n const Selector extends keyof Selected & string,\n Keys extends keyof SearchOf<NoInfer<Selected[Selector]>> = never,\n >(\n selector: Selector & (IsUnion<Selector> extends true ? never : unknown),\n values: UrlValues<NoInfer<Selected[Selector]>, Keys>,\n ): UrlTree;\n /**\n * Creates a UrlTree for a generated reference's own exact declaration.\n *\n * @param selector - A genuine destination exported by a facade in this route set.\n * @param values - The referenced declaration's complete explicit values.\n * @returns Router.parseUrl's result without navigating.\n * @throws Synchronously for foreign/fake references or invalid URL values.\n */\n link<\n const Id extends keyof References & string,\n Keys extends keyof SearchOf<NoInfer<References[Id]>> = never,\n >(\n selector: Destination<NoInfer<References[Id]>, Set, Id> &\n (IsUnion<Id> extends true ? never : unknown),\n values: UrlValues<NoInfer<References[Id]>, Keys>,\n ): UrlTree;\n /**\n * Navigates to this exact declaration via Router.navigateByUrl.\n *\n * @param values - Explicit effective params/search and optional own fragment.\n * @returns Angular's identical Promise; Angular owns skips, redirects and failures.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n navigate<Keys extends keyof SearchOf<Target> = never>(\n values: UrlValues<Target, Keys>,\n ): Promise<boolean>;\n /**\n * Navigates to the exact bound declaration, not its pathless winner.\n *\n * @param selector - The exact-current literal `.`.\n * @param values - Explicit values for this declaration, with no current-input reuse.\n * @returns Angular's identical Router.navigateByUrl Promise.\n * @throws Synchronous URL validation, encoding or stringifier failures before Angular.\n */\n navigate<Keys extends keyof SearchOf<Target> = never>(\n selector: \".\",\n values: UrlValues<Target, Keys>,\n ): Promise<boolean>;\n /**\n * Navigates to a statically admitted absolute/relative authored selector.\n *\n * @param selector - A single known template literal, never a concrete URL.\n * @param values - The selected target's complete explicit values.\n * @returns Angular's identical Router.navigateByUrl Promise.\n * @throws Synchronously for unknown selectors or invalid URL values.\n */\n navigate<\n const Selector extends keyof Selected & string,\n Keys extends keyof SearchOf<NoInfer<Selected[Selector]>> = never,\n >(\n selector: Selector & (IsUnion<Selector> extends true ? never : unknown),\n values: UrlValues<NoInfer<Selected[Selector]>, Keys>,\n ): Promise<boolean>;\n /**\n * Navigates to a generated reference's own exact declaration.\n *\n * @param selector - A genuine destination exported by a facade in this route set.\n * @param values - The referenced declaration's complete explicit values.\n * @returns Angular's identical Router.navigateByUrl Promise.\n * @throws Synchronously for foreign/fake references or invalid URL values.\n */\n navigate<\n const Id extends keyof References & string,\n Keys extends keyof SearchOf<NoInfer<References[Id]>> = never,\n >(\n selector: Destination<NoInfer<References[Id]>, Set, Id> &\n (IsUnion<Id> extends true ? never : unknown),\n values: UrlValues<NoInfer<References[Id]>, Keys>,\n ): Promise<boolean>;\n}\n\nexport function nativeOptions(definition: AnyRoute): Record<string, unknown> {\n const config = routeMetadata(definition).config;\n const options: Record<string, unknown> = {};\n\n for (const key of [\"providers\", \"data\", \"canDeactivate\", \"runGuardsAndResolvers\"]) {\n if (Object.hasOwn(config, key)) {\n options[key] = config[key];\n }\n }\n\n return options;\n}\n\nexport function injectGeneratedRoute<\n Target extends AnyRoute,\n Selected extends Record<string, AnyRoute>,\n Set,\n References extends Record<string, AnyRoute>,\n>(set: RouteSet, id: string): Handle<Target, Selected, Set, References> {\n const router = inject(Router);\n const view = observeRoute(set, id);\n\n function url(args: readonly unknown[]): string {\n if (args.length !== 1 && args.length !== 2) {\n throw new TypeError(\"Expected values or a selected destination and values\");\n }\n\n let target = id;\n let values = args[0];\n\n if (args.length === 2) {\n const selector = args[0];\n\n values = args[1];\n\n if (typeof selector === \"string\") {\n if (selector !== \".\") {\n if (Object.hasOwn(set.absolute, selector)) {\n target = set.absolute[selector];\n } else if (Object.hasOwn(set.relative[id], selector)) {\n target = set.relative[id][selector];\n } else {\n throw new TypeError(`Unknown generated selector: ${selector}`);\n }\n }\n } else {\n if (typeof selector !== \"object\" || selector === null) {\n throw new TypeError(\"Expected a literal selector or genuine generated destination\");\n }\n\n const destination = destinations.get(selector);\n\n if (\n !destination ||\n destination.getSet() !== set ||\n !Object.hasOwn(set.records, destination.id)\n ) {\n throw new TypeError(\"Expected a destination from the same generated set\");\n }\n\n target = destination.id;\n }\n }\n\n return createUrl(set.destinations[target](), values as UrlValues<AnyRoute>);\n }\n\n return {\n params: view.params as Signal<Readonly<ParamsOf<Target>>>,\n search: view.search as Signal<Readonly<SearchOf<Target>>>,\n data: view.data as Signal<DataOf<Target>>,\n link: ((...args: unknown[]) => router.parseUrl(url(args))) as Handle<\n Target,\n Selected,\n Set,\n References\n >[\"link\"],\n navigate: ((...args: unknown[]) => router.navigateByUrl(url(args))) as Handle<\n Target,\n Selected,\n Set,\n References\n >[\"navigate\"],\n };\n}\n"],"mappings":";;;;AAwBA,SAAgB,YACd,UACA,IAAU;CAEV,MAAM,OAAO,SAAS,aAAa;CAEnC,OACE,CAAC,CAAC,QACF,OAAO,OAAO,MAAM,6BAA6B,KACjD,KAAK,gCAAgC;AAEzC;AAEA,SAAgB,eACd,UACA,IAAU;CAEV,IAAI,CAAC,YAAY,UAAU,EAAE,GAC3B,MAAM,IAAI,MAAM,6CAA6C,IAAI;AAErE;AAGA,IAAM,aAAN,cAAyB,MAAK;CAIjB;CACA;CAJF,SAAS;CAElB,YACW,KACA,QACT,OAAe;EAEf,MAAM,sBAAsB,IAAG,IAAK,UAAU,EAAE,MAAK,CAAE;EAJ9C,KAAA,MAAA;EACA,KAAA,SAAA;CAIX;AACD;AAED,SAAgB,YACd,KACA,MACA,OAAc;CAEd,IAAI,CAAC,SAAS,KAAK,WAAW,GAC5B,MAAM,IAAI,WAAW,KAAK,SAAS;CAGrC,IAAI,CAAC,SAAS,KAAK,SAAS,GAC1B,MAAM,IAAI,WAAW,KAAK,UAAU;CAGtC,IAAI,KAAK,MAAM,QAAQ,OAAO,QAAQ,QAAQ,GAC5C,MAAM,IAAI,WAAW,KAAK,2BAAW,IAAI,UAAU,oCAAoC,CAAC;AAE5F;AAMA,SAAS,MAAM,OAAqB,KAAW;CAC7C,IAAI;CAEJ,IAAI;EACF,QAAQ,MAAM,MAAM,GAAG;CACzB,SAAS,OAAO;EACd,OAAO,EAAE,MAAK;CAChB;CAEA,IACE,UAAU,SACT,OAAO,UAAU,YAAY,OAAO,UAAU,eAC/C,OAAQ,MAA+B,SAAS,YAChD;EAEA,QAAQ,QAAQ,KAAK,CAAC,CAAC,YAAY,MAAS;EAE5C,MAAM,IAAI,UAAU,qEAAqE;CAC3F;CAEA,OAA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ACzB,MAAM,SAAS,OAAO,MAAM;CAC5B,MAAM,OAAO,aAAa,KAAK,EAAE;CAEjC,SAAS,IAAI,MAAwB;EACnC,IAAI,KAAK,WAAW,KAAK,KAAK,WAAW,GACvC,MAAM,IAAI,UAAU,sDAAsD;EAG5E,IAAI,SAAS;EACb,IAAI,SAAS,KAAK;EAElB,IAAI,KAAK,WAAW,GAAG;GACrB,MAAM,WAAW,KAAK;GAEtB,SAAS,KAAK;GAEd,IAAI,OAAO,aAAa,UACtB;QAAI,aAAa,KAAK;KACpB,IAAI,OAAO,OAAO,IAAI,UAAU,QAAQ,GACtC,SAAS,IAAI,SAAS;UACjB,IAAI,OAAO,OAAO,IAAI,SAAS,KAAK,QAAQ,GACjD,SAAS,IAAI,SAAS,GAAG,CAAC;UAE1B,MAAM,IAAI,UAAU,+BAA+B,UAAU;IAEjE;UACK;IACL,IAAI,OAAO,aAAa,YAAY,aAAa,MAC/C,MAAM,IAAI,UAAU,8DAA8D;IAGpF,MAAM,cAAc,aAAa,IAAI,QAAQ;IAE7C,IACE,CAAC,eACD,YAAY,OAAM,MAAO,OACzB,CAAC,OAAO,OAAO,IAAI,SAAS,YAAY,EAAE,GAE1C,MAAM,IAAI,UAAU,oDAAoD;IAG1E,SAAS,YAAY;GACvB;EACF;EAEA,OAAO,UAAU,IAAI,aAAa,OAAO,CAAA,GAAI,MAA6B;CAC5E;CAEA,OAAO;EACL,QAAQ,KAAK;EACb,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,GAAG,SAAoB,OAAO,SAAS,IAAI,IAAI,CAAC;EAMxD,YAAY,GAAG,SAAoB,OAAO,cAAc,IAAI,IAAI,CAAC;CAMlE;AACH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { booleanParam, createUrl, defineRoute, enumParam,
|
|
2
|
-
export { booleanParam, createUrl, defineRoute, enumParam,
|
|
1
|
+
import { booleanParam, createUrl, defineRoute, enumParam, numberParam, stringParam, withFallback } from "@loozo/angular-router/_core";
|
|
2
|
+
export { booleanParam, createUrl, defineRoute, enumParam, numberParam, stringParam, withFallback };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBuilder } from "@angular-devkit/architect";
|
|
2
2
|
import { generate } from "../generation/generate.js";
|
|
3
|
-
import { split } from "./options.js";
|
|
3
|
+
import { message, split } from "./options.js";
|
|
4
4
|
const officialApplicationBuilder = "@angular/build:application";
|
|
5
5
|
export default createBuilder(async (options, context) => {
|
|
6
6
|
let stopped = false;
|
|
@@ -11,7 +11,9 @@ export default createBuilder(async (options, context) => {
|
|
|
11
11
|
stopped = true;
|
|
12
12
|
if (!cleanup) {
|
|
13
13
|
const delegateStop = acquisition?.then((run) => run.stop());
|
|
14
|
-
|
|
14
|
+
// The builder reports a failed generation itself; stopping only waits for it to settle.
|
|
15
|
+
const drain = generation?.catch(() => undefined);
|
|
16
|
+
cleanup = Promise.all([delegateStop, drain]).then(() => undefined);
|
|
15
17
|
}
|
|
16
18
|
return cleanup;
|
|
17
19
|
}
|
|
@@ -22,7 +24,14 @@ export default createBuilder(async (options, context) => {
|
|
|
22
24
|
throw new Error("The application builder runs once; it does not support watch: true");
|
|
23
25
|
}
|
|
24
26
|
generation = generate(context.workspaceRoot, router, () => stopped);
|
|
25
|
-
|
|
27
|
+
try {
|
|
28
|
+
await generation;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
// Diagnostics, synchronization conflicts and check-mode drift are build failures, not crashes.
|
|
32
|
+
context.logger.error(message(error));
|
|
33
|
+
return { success: false };
|
|
34
|
+
}
|
|
26
35
|
if (stopped) {
|
|
27
36
|
return { success: false };
|
|
28
37
|
}
|
|
@@ -16,10 +16,10 @@ function validateRouterOptions(value) {
|
|
|
16
16
|
scanDirectories.some((scan) => typeof scan !== "string" || scan.trim() === "")) {
|
|
17
17
|
throw new Error("scanDirectories must contain exactly one nonempty string");
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const auto = value.autoDefineRoutes;
|
|
20
|
+
if (auto !== undefined && auto !== false) {
|
|
21
21
|
if (!auto || typeof auto !== "object" || Array.isArray(auto)) {
|
|
22
|
-
throw new Error("autoDefineRoutes must be an object");
|
|
22
|
+
throw new Error("autoDefineRoutes must be false or an object");
|
|
23
23
|
}
|
|
24
24
|
for (const key of Object.keys(auto)) {
|
|
25
25
|
if (key !== "filename") {
|
|
@@ -40,6 +40,12 @@ function validateRouterOptions(value) {
|
|
|
40
40
|
throw new Error("check must be a boolean");
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
export function message(error) {
|
|
44
|
+
if (error instanceof Error) {
|
|
45
|
+
return error.message;
|
|
46
|
+
}
|
|
47
|
+
return String(error);
|
|
48
|
+
}
|
|
43
49
|
// Router options drive generation; everything else belongs to Angular's application builder.
|
|
44
50
|
export function split(options) {
|
|
45
51
|
validateRouterOptions(options);
|
|
@@ -7,7 +7,7 @@ import { generate } from "../generation/generate.js";
|
|
|
7
7
|
import { workspacePaths, markers } from "../generation/files.js";
|
|
8
8
|
import { CompilerState } from "../generation/compiler.js";
|
|
9
9
|
import { AnchorState } from "../generation/anchor.js";
|
|
10
|
-
import { buildTargetOptions } from "./options.js";
|
|
10
|
+
import { buildTargetOptions, message } from "./options.js";
|
|
11
11
|
// Polling catches what Angular 22.2's native watcher (@parcel/watcher) misses: edits to files
|
|
12
12
|
// inside a renamed directory, which otherwise leave the dev server serving stale output.
|
|
13
13
|
const defaultPoll = 1000;
|
|
@@ -74,11 +74,7 @@ export default createBuilder((options, context) => new Observable((subscriber) =
|
|
|
74
74
|
await regenerate();
|
|
75
75
|
}
|
|
76
76
|
catch (error) {
|
|
77
|
-
|
|
78
|
-
if (error instanceof Error) {
|
|
79
|
-
message = error.message;
|
|
80
|
-
}
|
|
81
|
-
context.logger.error(message);
|
|
77
|
+
context.logger.error(message(error));
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
80
|
})();
|
|
@@ -96,11 +92,10 @@ export default createBuilder((options, context) => new Observable((subscriber) =
|
|
|
96
92
|
if (poll !== false) {
|
|
97
93
|
devServer.poll = poll;
|
|
98
94
|
}
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
]);
|
|
95
|
+
// Architect already validated the dev-server options against schemas/serve.json, Angular's
|
|
96
|
+
// dev-server schema with this poll. The build target is validated before the watcher and
|
|
97
|
+
// generation too, so invalid options never write.
|
|
98
|
+
router = await buildTargetOptions(context, options.buildTarget);
|
|
104
99
|
if (stopped) {
|
|
105
100
|
return;
|
|
106
101
|
}
|
|
@@ -159,9 +154,21 @@ export default createBuilder((options, context) => new Observable((subscriber) =
|
|
|
159
154
|
dirty = false;
|
|
160
155
|
const generation = regenerate();
|
|
161
156
|
active = generation;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
try {
|
|
158
|
+
await generation;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
// The dev server never starts on a failed initial generation; report it as a build failure.
|
|
162
|
+
context.logger.error(message(error));
|
|
163
|
+
await stop();
|
|
164
|
+
subscriber.next({ success: false });
|
|
165
|
+
subscriber.complete();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
if (active === generation) {
|
|
170
|
+
active = undefined;
|
|
171
|
+
}
|
|
165
172
|
}
|
|
166
173
|
if (stopped) {
|
|
167
174
|
return;
|
|
@@ -51,11 +51,31 @@ export function emit(sources, selected) {
|
|
|
51
51
|
let needsNative = false;
|
|
52
52
|
let needsCallbacks = false;
|
|
53
53
|
let needsRedirect = false;
|
|
54
|
+
// Options Angular takes as they are, read from the definition itself.
|
|
55
|
+
function usesNative(declaration) {
|
|
56
|
+
return ["providers", "data", "canDeactivate", "runGuardsAndResolvers"].some((key) => declaration.config.has(key));
|
|
57
|
+
}
|
|
58
|
+
// Parsed-input callbacks, adapted through the route set; a redirect record never activates.
|
|
59
|
+
// Local path params and effective search always get the generated canMatch that parses them.
|
|
60
|
+
function usesCallbacks(declaration) {
|
|
61
|
+
if (declaration.target) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (declaration.segments.some((segment) => segment.kind !== "static")) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
for (let owner = declaration; owner; owner = owner.parent) {
|
|
68
|
+
if (owner.config.has("search")) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return ["canActivate", "canActivateChild", "canMatch", "resolve", "title"].some((key) => declaration.config.has(key));
|
|
73
|
+
}
|
|
54
74
|
for (const declaration of declarations) {
|
|
55
|
-
if (
|
|
75
|
+
if (usesNative(declaration)) {
|
|
56
76
|
needsNative = true;
|
|
57
77
|
}
|
|
58
|
-
if (
|
|
78
|
+
if (usesCallbacks(declaration)) {
|
|
59
79
|
needsCallbacks = true;
|
|
60
80
|
}
|
|
61
81
|
if (declaration.target) {
|
|
@@ -77,8 +97,7 @@ export function emit(sources, selected) {
|
|
|
77
97
|
routes.push(`import { ${helpers.join(", ")} } from '@loozo/angular-router/_generated';`);
|
|
78
98
|
}
|
|
79
99
|
for (const declaration of declarations) {
|
|
80
|
-
if (declaration
|
|
81
|
-
[...declaration.config.keys()].some((key) => !["parent", "params", "search", "fragments"].includes(key))) {
|
|
100
|
+
if (usesNative(declaration) || declaration.target) {
|
|
82
101
|
routes.push(`import ${names.get(declaration)} from ${JSON.stringify(specifier(routesFile, declaration.file))};`);
|
|
83
102
|
}
|
|
84
103
|
}
|
|
@@ -104,8 +123,7 @@ export function emit(sources, selected) {
|
|
|
104
123
|
function record(declaration) {
|
|
105
124
|
const parts = [];
|
|
106
125
|
const name = names.get(declaration);
|
|
107
|
-
|
|
108
|
-
if (native) {
|
|
126
|
+
if (usesNative(declaration)) {
|
|
109
127
|
parts.push(`...nativeOptions(${name})`);
|
|
110
128
|
}
|
|
111
129
|
parts.push(`path: ${JSON.stringify(nativePath(declaration, !!declaration.target))}`);
|
|
@@ -121,7 +139,7 @@ export function emit(sources, selected) {
|
|
|
121
139
|
parts.push(`redirectTo: redirect(() => ${name})`);
|
|
122
140
|
}
|
|
123
141
|
else {
|
|
124
|
-
if (
|
|
142
|
+
if (usesCallbacks(declaration)) {
|
|
125
143
|
parts.push(`...callbacks(getRouteSet(), ${JSON.stringify(declaration.id)})`);
|
|
126
144
|
}
|
|
127
145
|
if (declaration.page) {
|
|
@@ -253,7 +271,7 @@ const routeSet: RouteSet = { records: {`);
|
|
|
253
271
|
*
|
|
254
272
|
* @remarks
|
|
255
273
|
* Call in an Angular injection context. The handle exposes readonly native
|
|
256
|
-
* params/search/data
|
|
274
|
+
* params/search/data Signals and destination-typed link/navigate methods.
|
|
257
275
|
* Data includes local resolver results only, not static or inherited data.
|
|
258
276
|
* All navigation values are explicit; current inputs are never reused implicitly.
|
|
259
277
|
*
|