@askrjs/askr 0.0.62 → 0.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +5 -5
  2. package/dist/actions/index.d.ts +1 -1
  3. package/dist/authoring-CXMPffwN.js +200 -0
  4. package/dist/benchmark.js +4 -4
  5. package/dist/boot/index.d.ts +12 -32
  6. package/dist/boot/index.js +1 -1
  7. package/dist/{boot-B0mMBddb.js → boot-OnYuVVfg.js} +64 -75
  8. package/dist/components/index.d.ts +1 -1
  9. package/dist/control/index.d.ts +1 -1
  10. package/dist/{control-CFIrGbD7.d.ts → control-CMzFPMjr.d.ts} +3 -0
  11. package/dist/csp-nonce-C-8E85El.js +33 -0
  12. package/dist/{deferred-BeNnjR4r.js → deferred-B71c2eio.js} +51 -10
  13. package/dist/foundations/index.d.ts +1 -1
  14. package/dist/foundations/state/index.d.ts +1 -1
  15. package/dist/foundations/structures/index.d.ts +1 -1
  16. package/dist/{index-DaWuMuIc.d.ts → index-Bjm0__Rr.d.ts} +1 -1
  17. package/dist/{index-DlvpxdSz.d.ts → index-Byqjltu2.d.ts} +1 -1
  18. package/dist/{index-CRck4XVe.d.ts → index-NKPpdRh9.d.ts} +6 -2
  19. package/dist/{index-Bce-RQg-.d.ts → index-PgRn5wmg.d.ts} +1 -1
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +3 -2
  22. package/dist/{navigate-DLi79IZr.js → navigate-DTZ2SM8_.js} +68 -279
  23. package/dist/{renderer-CVr_nktj.js → renderer-aUD-acDe.js} +1 -1
  24. package/dist/{route-matching-vJpvLVbX.js → route-matching-C93To416.js} +2 -2
  25. package/dist/router/index.d.ts +4 -10
  26. package/dist/router/index.js +4 -4
  27. package/dist/{router-lmH-Tmwh.d.ts → router-eRoaj11J.d.ts} +9 -6
  28. package/dist/ssg/index.d.ts +8 -33
  29. package/dist/ssg/index.js +34 -36
  30. package/dist/ssr/index.d.ts +10 -45
  31. package/dist/ssr/index.js +1 -1
  32. package/dist/{ssr-5HlhmLhU.js → ssr-C0hzqhY8.js} +65 -43
  33. package/dist/testing/index.d.ts +4 -5
  34. package/dist/testing/index.js +7 -10
  35. package/dist/{verify-hydration-13f0FOPd.js → verify-hydration-BdKE9Hi8.js} +3 -3
  36. package/package.json +1 -1
  37. package/dist/router-internal-BC0w1_xk.js +0 -4
@@ -5,223 +5,12 @@ import { r as executeComponent } from "./component-internal-CbALfPGD.js";
5
5
  import { d as getCurrentAppRenderRuntime, f as getCurrentComponentInstance } from "./component-scope-CC3cojX9.js";
6
6
  import { g as cleanupComponentGeneration, h as cleanupComponent, i as beginLifecycleCommitBatch, l as flushLifecycleCommitBatch, m as isPromiseLike, o as discardLifecycleCommitBatch, s as drainLifecycleCommitErrors } from "./component-lifecycle-DEMPihoZ.js";
7
7
  import { _ as teardownNodeSubtree } from "./cleanup-B6KovDZZ.js";
8
+ import { d as getRouteRenderContext, f as getRouteRenderData, m as resolveRouteRequest, p as hasRouteRenderData } from "./deferred-B71c2eio.js";
8
9
  import { n as getActiveRenderContext } from "./render-context-Clw3rFiO.js";
9
10
  import { n as syncRouteActivitySnapshot } from "./route-activity-CNJfpwx-.js";
10
11
  import { r as clearDefaultPortalForInstance, t as DefaultPortal } from "./portal-D2tPWNrC.js";
11
- import { A as insertRecordSorted, C as getCurrentPathPrefix, D as getRoutes, E as getRouteRecords, F as snapshotRouteState, I as computeRank, L as normalizeRouteSegmentName, M as pushRegistrationScope, N as restoreRouteState, O as hasActivePageScope, P as setDefaultRouteAuthOptions, R as parseSegments, S as getCurrentPageScope, T as getDefaultRouteAuthOptions, _ as getCurrentInheritedAuthRequirements, a as resolveRouteFromRoutes, b as getCurrentLayoutChain, c as deepFreeze, f as addRouteToStores, g as getActiveRoutes, j as lockRouteRegistration, l as makeQuery, m as clearRouteState, n as computeMatchesFromRoutes, p as assertRouteRegistrationUnlocked, r as computeRouteActivityMatches, u as parseLocation, v as getCurrentInheritedMeta, w as getCurrentScopeKind, x as getCurrentPageChain, y as getCurrentInheritedPolicies } from "./route-matching-vJpvLVbX.js";
12
- import { d as hasRouteRenderData, f as resolveRouteRequest, l as getRouteRenderContext, u as getRouteRenderData, x as _preloadRouteHandler, y as createRouteHandler } from "./deferred-BeNnjR4r.js";
13
- import { allOf } from "@askrjs/auth";
14
- //#region src/runtime/execution-model.ts
15
- const EXECUTION_MODEL_KEY = Symbol.for("__ASKR_EXECUTION_MODEL__");
16
- function getExecutionModel() {
17
- return globalThis[EXECUTION_MODEL_KEY];
18
- }
19
- function assertExecutionModel(model) {
20
- const g = globalThis;
21
- const cur = g[EXECUTION_MODEL_KEY];
22
- if (cur && cur !== model) throw new Error(`[Askr] mixing execution models is not allowed (current: ${cur}, attempted: ${model}). Choose exactly one: createSPA, createSSR, or createIslands.`);
23
- if (!cur) g[EXECUTION_MODEL_KEY] = model;
24
- }
25
- //#endregion
26
- //#region src/router/access.ts
27
- function compileNodePolicies(node) {
28
- return node.policies ? [...node.policies] : [];
29
- }
30
- //#endregion
31
- //#region src/router/authoring.ts
32
- function validateRoutePath(path) {
33
- if (!path.startsWith("/")) throw new Error(`Route path must begin with "/". Got: "${path}"`);
34
- if (/\/{2,}/.test(path)) throw new Error("Route path cannot contain consecutive slashes.");
35
- if (/:([^/{}]+)/.test(path)) {
36
- const suggested = path.replace(/:([^/{}]+)/g, "{$1}");
37
- throw new Error(`Route parameter syntax uses {name} interpolation, not :name. Use "${suggested}" instead of "${path}".`);
38
- }
39
- const segments = path.split("/").filter(Boolean);
40
- const seenParamNames = /* @__PURE__ */ new Set();
41
- for (let index = 0; index < segments.length; index++) {
42
- const segment = segments[index];
43
- if (segment === "*") continue;
44
- const hasOpenBrace = segment.includes("{");
45
- const hasCloseBrace = segment.includes("}");
46
- if (!hasOpenBrace && !hasCloseBrace) continue;
47
- if (!(segment.startsWith("{") && segment.endsWith("}"))) throw new Error("Route parameter segments must use complete {name} interpolation.");
48
- const rawParamName = normalizeRouteSegmentName(segment.slice(1, -1));
49
- const isSplat = rawParamName.startsWith("*");
50
- const paramName = isSplat ? normalizeRouteSegmentName(rawParamName.slice(1)) : rawParamName;
51
- if (!paramName) throw new Error(isSplat ? "Route splat parameter name cannot be empty." : "Route parameter name cannot be empty.");
52
- if (isSplat && paramName === "*") throw new Error("Route named splat parameter name cannot be \"*\".");
53
- if (isSplat && index !== segments.length - 1) throw new Error("Route named splat parameters must be the final segment.");
54
- if (seenParamNames.has(paramName)) throw new Error(`Route path cannot reuse duplicate parameter name "${paramName}".`);
55
- seenParamNames.add(paramName);
56
- }
57
- }
58
- function normalizeAbsoluteRoutePath(path) {
59
- if (!path || path === "/") return "/";
60
- return (path.endsWith("/") ? path.slice(0, -1) : path) || "/";
61
- }
62
- function joinRoutePaths(prefix, path) {
63
- const normalizedPrefix = normalizeAbsoluteRoutePath(prefix || "/");
64
- const normalizedPath = path.replace(/^\/+|\/+$/g, "");
65
- if (!normalizedPath) return normalizedPrefix;
66
- return normalizedPrefix === "/" ? `/${normalizedPath}` : `${normalizedPrefix}/${normalizedPath}`;
67
- }
68
- function resolvePageScopePath(path) {
69
- if (!path) throw new Error("page(path, Component, fn) requires a non-empty path.");
70
- if (path.startsWith("/")) {
71
- validateRoutePath(path);
72
- return normalizeAbsoluteRoutePath(path);
73
- }
74
- return joinRoutePaths(getCurrentPathPrefix(), path);
75
- }
76
- function resolveIndexPath() {
77
- return normalizeAbsoluteRoutePath(getCurrentPathPrefix() || "/");
78
- }
79
- function resolveRouteRegistrationPath(path) {
80
- if (path.startsWith("/")) {
81
- if (hasActivePageScope()) throw new Error(`Child route paths inside page() must be relative. Use "${path.slice(1)}" instead of "${path}".`);
82
- validateRoutePath(path);
83
- return normalizeAbsoluteRoutePath(path);
84
- }
85
- const prefix = getCurrentPathPrefix();
86
- if (!prefix) throw new Error(`Route path must begin with "/". Got: "${path}"`);
87
- return joinRoutePaths(prefix, path);
88
- }
89
- function pushGroupScope(options, fn) {
90
- const policies = compileNodePolicies(options);
91
- pushRegistrationScope({
92
- kind: "group",
93
- pathPrefix: getCurrentPathPrefix(),
94
- layout: options.layout,
95
- auth: options.auth,
96
- policies,
97
- meta: options.meta
98
- }, fn);
99
- }
100
- function pushPageScope(path, Component, options, fn) {
101
- if (hasActivePageScope()) throw new Error("page() cannot be nested inside another page(). Use route() for child leaves or group() for inherited behavior inside the existing page scope.");
102
- const policies = compileNodePolicies(options);
103
- pushRegistrationScope({
104
- kind: "page",
105
- pathPrefix: resolvePageScopePath(path),
106
- page: Component,
107
- hasIndex: false,
108
- auth: options.auth,
109
- policies,
110
- meta: options.meta
111
- }, fn);
112
- }
113
- function normalizeRouteOptions(options) {
114
- if (!options) return;
115
- const loader = options.loader;
116
- const preload = options.preload;
117
- const policies = compileNodePolicies(options);
118
- if (!loader && !preload && !options.entries && policies.length === 0 && !options.title && !options.namespace && !options.search && !options.meta && !options.actions && options.auth === void 0) return;
119
- return {
120
- ...loader ? { loader } : {},
121
- ...preload ? { preload } : {},
122
- ...options.entries ? { entries: options.entries } : {},
123
- ...options.auth !== void 0 ? { auth: options.auth } : {},
124
- ...policies.length > 0 ? { policies } : {},
125
- ...options.title ? { title: options.title } : {},
126
- ...options.namespace ? { namespace: options.namespace } : {},
127
- ...options.search ? { search: options.search } : {},
128
- ...options.meta ? { meta: options.meta } : {},
129
- ...options.actions ? { actions: options.actions } : {}
130
- };
131
- }
132
- function registerRouteAtResolvedPath(path, Component, options, metadata) {
133
- validateRoutePath(path);
134
- const chain = getCurrentLayoutChain();
135
- const pageChain = getCurrentPageChain();
136
- const segments = parseSegments(path);
137
- const rank = computeRank(segments);
138
- const isFallback = metadata?.isFallback ?? path === "/*";
139
- const comp = Component;
140
- const normalizedOptions = normalizeRouteOptions(options);
141
- const policies = [...getCurrentInheritedPolicies(), ...normalizedOptions?.policies ?? []];
142
- const authRequirements = [...getCurrentInheritedAuthRequirements(), ...normalizedOptions?.auth ? [normalizedOptions.auth] : []];
143
- const auth = authRequirements.length === 0 ? void 0 : authRequirements.length === 1 ? authRequirements[0] : allOf(...authRequirements);
144
- const metaChain = [...getCurrentInheritedMeta(), ...normalizedOptions?.meta ? [normalizedOptions.meta] : []];
145
- const handler = createRouteHandler(comp, pageChain, chain);
146
- const renderHandler = createRouteHandler(comp, pageChain, chain, true);
147
- insertRecordSorted({
148
- path,
149
- component: comp,
150
- segments,
151
- rank,
152
- layoutChain: chain,
153
- pageChain,
154
- options: normalizedOptions ? {
155
- ...normalizedOptions,
156
- ...auth ? { auth } : {},
157
- ...policies.length > 0 ? { policies } : {}
158
- } : policies.length > 0 ? {
159
- policies,
160
- ...auth ? { auth } : {}
161
- } : auth ? { auth } : {},
162
- ...metaChain.length > 0 ? { metaChain } : {},
163
- isFallback,
164
- handler,
165
- renderHandler,
166
- ...metadata?.fallbackPrefix ? { fallbackPrefix: metadata.fallbackPrefix } : {}
167
- });
168
- addRouteToStores({
169
- path,
170
- handler,
171
- namespace: normalizedOptions?.namespace ?? options?.namespace,
172
- ...metadata?.fallbackPrefix ? { fallbackPrefix: metadata.fallbackPrefix } : {}
173
- });
174
- }
175
- function group(options, fn) {
176
- pushGroupScope(options, fn);
177
- }
178
- function page(path, Component, optionsOrFn, maybeFn) {
179
- const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
180
- const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
181
- if (typeof Component !== "function") throw new Error("page(path, Component, fn) requires a component function as the second argument.");
182
- if (typeof fn !== "function") throw new Error("page(path, Component, fn) requires a route definition callback as the final argument.");
183
- pushPageScope(path, Component, options, fn);
184
- }
185
- function index(Component, options) {
186
- const pageScope = getCurrentPageScope();
187
- if (pageScope?.hasIndex) throw new Error("page() cannot declare multiple index routes.");
188
- if (pageScope) pageScope.hasIndex = true;
189
- registerRouteAtResolvedPath(resolveIndexPath(), Component, options);
190
- }
191
- function fallback(Component) {
192
- if (hasActivePageScope()) {
193
- if (getCurrentScopeKind() !== "page") throw new Error("fallback() inside page() must be declared directly in the page scope, not inside nested group().");
194
- registerRouteAtResolvedPath(`${getCurrentPathPrefix()}/*`, Component, void 0, {
195
- isFallback: true,
196
- fallbackPrefix: getCurrentPathPrefix()
197
- });
198
- return;
199
- }
200
- if (!(getCurrentInheritedPolicies().length === 0 && getCurrentInheritedAuthRequirements().length === 0)) throw new Error("fallback() can only be registered at the root scope. Use route(\"/*\", Component) if you need compatibility behavior.");
201
- registerRouteAtResolvedPath("/*", Component, void 0, {
202
- isFallback: true,
203
- fallbackPrefix: "/"
204
- });
205
- }
206
- function registerRoutes(definition, options = {}) {
207
- setDefaultRouteAuthOptions(options.auth);
208
- definition();
209
- }
210
- function route(path, Component, options) {
211
- if (typeof path === "undefined") throw new Error("route() is only for route registration. Use currentRoute() inside components.");
212
- if (getExecutionModel() === "islands") throw new Error("Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.");
213
- const currentInst = getCurrentComponentInstance();
214
- if (currentInst && currentInst.ssr) throw new Error("route() cannot be called during SSR rendering. Register routes at module load time instead.");
215
- assertRouteRegistrationUnlocked();
216
- if (typeof Component !== "function") throw new Error("route(path, Component) requires a component function as the second argument. Passing JSX elements or VNodes directly is not supported.");
217
- if (options?.search && options.search.kind !== "object") throw new Error("route search must be an object schema.");
218
- registerRouteAtResolvedPath(resolveRouteRegistrationPath(path), Component, options);
219
- return Object.freeze({
220
- path: resolveRouteRegistrationPath(path),
221
- ...options?.search ? { searchSchema: options.search } : {}
222
- });
223
- }
224
- //#endregion
12
+ import { t as CspNonceScope } from "./csp-nonce-C-8E85El.js";
13
+ import { c as deepFreeze, g as getActiveRoutes, j as lockRouteRegistration, l as makeQuery, n as computeMatchesFromRoutes, r as computeRouteActivityMatches, u as parseLocation } from "./route-matching-C93To416.js";
225
14
  //#region src/common/app-render-runtime.ts
226
15
  const stagedRouteLocations = /* @__PURE__ */ new WeakMap();
227
16
  function createAppRenderRuntime(input = {}) {
@@ -316,44 +105,6 @@ function syncCurrentRouteSnapshot(pathname, search, hash, activityMatches) {
316
105
  setCurrentRouteSnapshot(pathname, search, hash, activityMatches);
317
106
  }
318
107
  //#endregion
319
- //#region src/router/manifest.ts
320
- function getManifest() {
321
- const auth = getDefaultRouteAuthOptions();
322
- return {
323
- records: [...getRouteRecords()],
324
- ...auth ? { auth } : {}
325
- };
326
- }
327
- function _applyManifest(manifest) {
328
- setDefaultRouteAuthOptions(manifest.auth);
329
- for (const record of manifest.records) {
330
- insertRecordSorted(record);
331
- addRouteToStores({
332
- path: record.path,
333
- handler: record.handler,
334
- namespace: record.options.namespace,
335
- ..."fallbackPrefix" in record && typeof record.fallbackPrefix === "string" ? { fallbackPrefix: record.fallbackPrefix } : {}
336
- });
337
- }
338
- }
339
- function clearRoutes() {
340
- clearRouteState();
341
- }
342
- function createRouteRegistry(definition, options = {}) {
343
- const previous = snapshotRouteState();
344
- clearRoutes();
345
- try {
346
- registerRoutes(definition, options);
347
- const manifest = getManifest();
348
- return Object.freeze({
349
- manifest,
350
- routes: getRoutes()
351
- });
352
- } finally {
353
- restoreRouteState(previous);
354
- }
355
- }
356
- //#endregion
357
108
  //#region src/router/navigation-registry.ts
358
109
  let currentInstance = null;
359
110
  let currentPathname = "/";
@@ -400,8 +151,8 @@ function collectRouteActivityMatches(pathname, apps = registeredApps) {
400
151
  const seenPaths = /* @__PURE__ */ new Set();
401
152
  for (const app of apps) {
402
153
  const appMatches = computeRouteActivityMatches(pathname, {
403
- manifest: app.manifest,
404
- routes: app.routes
154
+ manifest: app.registry.manifest,
155
+ routes: app.registry.routes
405
156
  });
406
157
  for (const match of appMatches) {
407
158
  if (seenPaths.has(match.path)) continue;
@@ -416,7 +167,7 @@ function syncRegisteredRouteSnapshot() {
416
167
  const pathname = window.location.pathname || "/";
417
168
  syncCurrentRouteSnapshot(pathname, window.location.search || "", window.location.hash || "", collectRouteActivityMatches(pathname));
418
169
  }
419
- function registerAppInstance(instance, path, source = {}) {
170
+ function registerAppInstance(instance, path, source) {
420
171
  const existingIndex = registeredApps.findIndex((app) => app.instance === instance);
421
172
  const registration = {
422
173
  instance,
@@ -589,12 +340,61 @@ async function resolveRouteMeta(record, context) {
589
340
  /** Replace only Askr-owned head nodes after a successful client navigation. */
590
341
  function reconcileRouteMeta(meta, target = document) {
591
342
  for (const node of Array.from(target.head.querySelectorAll("[data-askr-head]"))) node.remove();
592
- const template = target.createElement("template");
593
- template.innerHTML = serializeRouteMeta(meta);
594
- target.head.append(template.content);
343
+ const own = (element) => {
344
+ element.setAttribute("data-askr-head", "");
345
+ return element;
346
+ };
347
+ const appendMeta = (attribute, name, content) => {
348
+ const element = own(target.createElement("meta"));
349
+ element.setAttribute(attribute, name);
350
+ element.setAttribute("content", content);
351
+ target.head.append(element);
352
+ };
353
+ if (meta.title !== void 0) {
354
+ const element = own(target.createElement("title"));
355
+ element.textContent = meta.title;
356
+ target.head.append(element);
357
+ }
358
+ if (meta.description !== void 0) appendMeta("name", "description", meta.description);
359
+ if (meta.canonical !== void 0) {
360
+ const element = own(target.createElement("link"));
361
+ element.setAttribute("rel", "canonical");
362
+ element.setAttribute("href", meta.canonical);
363
+ target.head.append(element);
364
+ }
365
+ if (meta.robots !== void 0) appendMeta("name", "robots", meta.robots);
366
+ for (const [property, content] of Object.entries(meta.openGraph ?? {})) appendMeta("property", property.startsWith("og:") ? property : `og:${property}`, content);
367
+ for (const link of meta.links ?? []) {
368
+ const element = own(target.createElement("link"));
369
+ for (const [name, value] of Object.entries(link)) if (LINK_ATTRIBUTES.has(name.toLowerCase())) element.setAttribute(name.toLowerCase(), value);
370
+ target.head.append(element);
371
+ }
372
+ if (meta.jsonLd !== void 0) {
373
+ const values = Array.isArray(meta.jsonLd) ? meta.jsonLd : [meta.jsonLd];
374
+ for (const value of values) {
375
+ const element = own(target.createElement("script"));
376
+ element.setAttribute("type", "application/ld+json");
377
+ element.textContent = JSON.stringify(value);
378
+ target.head.append(element);
379
+ }
380
+ }
595
381
  if (meta.html?.lang) target.documentElement.setAttribute("lang", meta.html.lang);
596
382
  if (meta.html?.dir) target.documentElement.setAttribute("dir", meta.html.dir);
597
383
  }
384
+ const LINK_ATTRIBUTES = /* @__PURE__ */ new Set([
385
+ "rel",
386
+ "href",
387
+ "as",
388
+ "crossorigin",
389
+ "fetchpriority",
390
+ "hreflang",
391
+ "imagesizes",
392
+ "imagesrcset",
393
+ "media",
394
+ "referrerpolicy",
395
+ "sizes",
396
+ "type"
397
+ ]);
598
398
  function escapeAttribute(value) {
599
399
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
600
400
  }
@@ -605,7 +405,7 @@ function ownedAttribute() {
605
405
  return " data-askr-head=\"\"";
606
406
  }
607
407
  function serializeLink(link) {
608
- const entries = Object.entries(link).filter(([name]) => /^[a-zA-Z][a-zA-Z0-9:_-]*$/.test(name)).sort(([left], [right]) => {
408
+ const entries = Object.entries(link).map(([name, value]) => [name.toLowerCase(), value]).filter(([name]) => LINK_ATTRIBUTES.has(name)).sort(([left], [right]) => {
609
409
  const order = (name) => name === "rel" ? 0 : name === "href" ? 1 : 2;
610
410
  return order(left) - order(right) || left.localeCompare(right);
611
411
  });
@@ -706,7 +506,7 @@ function createDeniedResolvedRoute(status) {
706
506
  function bindResolvedRouteHandler(resolved) {
707
507
  return () => resolved.handler(resolved.params);
708
508
  }
709
- function wrapRootRouteHandler(componentFn) {
509
+ function wrapRootRouteHandler(componentFn, cspNonce) {
710
510
  const wrappedFn = (props, ctx) => {
711
511
  const out = componentFn(props, ctx);
712
512
  if (isPromiseLike(out)) throw new Error("Async components are not supported. Components must return synchronously.");
@@ -716,11 +516,15 @@ function wrapRootRouteHandler(componentFn) {
716
516
  props: { __askrAutoDefaultPortal: true },
717
517
  key: "__default_portal"
718
518
  };
719
- return {
519
+ const root = {
720
520
  $$typeof: ELEMENT_TYPE,
721
521
  type: Fragment,
722
522
  props: { children: out === void 0 || out === null ? [portalVNode] : [out, portalVNode] }
723
523
  };
524
+ return cspNonce === void 0 ? root : CspNonceScope({
525
+ value: cspNonce,
526
+ children: root
527
+ });
724
528
  };
725
529
  Object.defineProperty(wrappedFn, "name", { value: componentFn.name || "Component" });
726
530
  return wrappedFn;
@@ -957,7 +761,7 @@ function cleanupDeferredRouteInstance(deferred) {
957
761
  function remountResolvedRoute(instance, resolved, pathname, href, existingSnapshot) {
958
762
  const deferredCleanup = existingSnapshot ?? captureDeferredRouteCleanup(instance);
959
763
  clearDefaultPortalForInstance(instance);
960
- instance.fn = wrapRootRouteHandler(bindResolvedRouteHandler(resolved));
764
+ instance.fn = wrapRootRouteHandler(bindResolvedRouteHandler(resolved), instance._cspNonce);
961
765
  instance.props = {};
962
766
  instance._ownershipGeneration = {};
963
767
  instance.stateValues = [];
@@ -989,23 +793,8 @@ function rerenderResolvedRoute(instance, pathname, href) {
989
793
  return true;
990
794
  }
991
795
  function resolveAppRouteRequest(app, pathname, href, signal) {
992
- if (app.manifest) return resolveRouteRequest(href, {
993
- manifest: app.manifest,
994
- auth: app.auth,
995
- signal
996
- });
997
- if (app.routes) {
998
- const resolved = resolveRouteFromRoutes(pathname, app.routes);
999
- if (!resolved) return null;
1000
- const result = {
1001
- kind: "render",
1002
- handler: resolved.handler,
1003
- params: resolved.params
1004
- };
1005
- const lazyImport = _preloadRouteHandler(resolved.handler);
1006
- return lazyImport ? lazyImport.then(() => result) : result;
1007
- }
1008
796
  return resolveRouteRequest(href, {
797
+ manifest: app.registry.manifest,
1009
798
  auth: app.auth,
1010
799
  signal
1011
800
  });
@@ -1394,4 +1183,4 @@ function initializeNavigation() {
1394
1183
  window.addEventListener("popstate", handlePopState);
1395
1184
  }
1396
1185
  //#endregion
1397
- export { assertExecutionModel as C, route as S, fallback as _, resolveRouteMeta as a, page as b, registerAppInstance as c, clearRoutes as d, createRouteRegistry as f, createAppRenderRuntime as g, setServerLocation as h, reconcileRouteMeta as i, unregisterAppInstance as l, currentRoute as m, navigate as n, serializeRouteMeta as o, getManifest as p, updateRouteQuery as r, configureScrollRestoration as s, initializeNavigation as t, _applyManifest as u, group as v, registerRoutes as x, index as y };
1186
+ export { resolveRouteMeta as a, registerAppInstance as c, setServerLocation as d, createAppRenderRuntime as f, reconcileRouteMeta as i, unregisterAppInstance as l, navigate as n, serializeRouteMeta as o, updateRouteQuery as r, configureScrollRestoration as s, initializeNavigation as t, currentRoute as u };
@@ -10,7 +10,7 @@ import { _ as createChildScope, a as registerForStateTransaction, c as captureFo
10
10
  import { n as createOwnedFineGrainedEffect, r as markFineGrainedEffectsDirtySource, t as createFineGrainedEffect } from "./effect-D_4zf_wy.js";
11
11
  import { C as getDelegatedHandlersForElement, D as updateDelegatedListener, E as removeDelegatedListener, S as getDelegatedHandlerForElement, T as isEventDelegationEnabled, _ as teardownNodeSubtree, a as elementReactivePropsCleanup, b as addFreshDelegatedListener, c as forEachElementReactivePropCleanup, d as removeAllListeners, f as removeElementReactiveProps, g as setFreshElementReactivePropCleanup, h as setDirectElementReactivePropCleanup, i as elementListeners, l as getElementReactivePropCleanupSize, m as replaceElementRefBookkeeping, n as cleanupInstanceIfPresent, o as elementRefs, p as removeElementRef, r as cleanupInstancesUnder, s as forEachDescendantNode, t as REACTIVE_CHILDREN_KEY, u as getElementReactivePropsCleanupMap, v as updateElementRef, w as isDelegatedEvent, x as clearDelegatedHandlersForElement, y as addDelegatedListener } from "./cleanup-B6KovDZZ.js";
12
12
  import { t as getPublicAttributeName } from "./attr-names-CjhzmHOn.js";
13
- import { t as ROUTE_ROOT_COMPONENT } from "./router-internal-BC0w1_xk.js";
13
+ import { i as ROUTE_ROOT_COMPONENT } from "./csp-nonce-C-8E85El.js";
14
14
  //#region src/runtime/error-boundary.ts
15
15
  function createBoundaryReset(instance) {
16
16
  return () => {
@@ -225,7 +225,7 @@ function lockRouteRegistration() {
225
225
  function assertRouteRegistrationUnlocked() {
226
226
  if (registrationLocked) throw new Error("Route registration is locked after app startup. Register routes at module load time before calling createSPA or createSSR.");
227
227
  }
228
- function getRoutes() {
228
+ function getRouteList() {
229
229
  return [...routes];
230
230
  }
231
231
  function hasRegisteredRoutes() {
@@ -512,4 +512,4 @@ function _resolveRouteMatchFromRoutes(pathname, routeList) {
512
512
  return findBestResolvedRouteFromRoutes(pathname, routeList);
513
513
  }
514
514
  //#endregion
515
- export { insertRecordSorted as A, getCurrentPathPrefix as C, getRoutes as D, getRouteRecords as E, snapshotRouteState as F, computeRank as I, normalizeRouteSegmentName as L, pushRegistrationScope as M, restoreRouteState as N, hasActivePageScope as O, setDefaultRouteAuthOptions as P, parseSegments as R, getCurrentPageScope as S, getDefaultRouteAuthOptions as T, getCurrentInheritedAuthRequirements as _, resolveRouteFromRoutes as a, getCurrentLayoutChain as b, deepFreeze as c, _setActiveRouteAuthOptions as d, addRouteToStores as f, getActiveRoutes as g, getActiveRouteAuthOptions as h, getMatchingRouteRecord as i, lockRouteRegistration as j, hasRegisteredRoutes as k, makeQuery as l, clearRouteState as m, computeMatchesFromRoutes as n, buildRouteContext as o, assertRouteRegistrationUnlocked as p, computeRouteActivityMatches as r, buildRouteContextBase as s, _resolveRouteMatchFromRoutes as t, parseLocation as u, getCurrentInheritedMeta as v, getCurrentScopeKind as w, getCurrentPageChain as x, getCurrentInheritedPolicies as y };
515
+ export { insertRecordSorted as A, getCurrentPathPrefix as C, getRouteRecords as D, getRouteList as E, snapshotRouteState as F, computeRank as I, normalizeRouteSegmentName as L, pushRegistrationScope as M, restoreRouteState as N, hasActivePageScope as O, setDefaultRouteAuthOptions as P, parseSegments as R, getCurrentPageScope as S, getDefaultRouteAuthOptions as T, getCurrentInheritedAuthRequirements as _, resolveRouteFromRoutes as a, getCurrentLayoutChain as b, deepFreeze as c, _setActiveRouteAuthOptions as d, addRouteToStores as f, getActiveRoutes as g, getActiveRouteAuthOptions as h, getMatchingRouteRecord as i, lockRouteRegistration as j, hasRegisteredRoutes as k, makeQuery as l, clearRouteState as m, computeMatchesFromRoutes as n, buildRouteContext as o, assertRouteRegistrationUnlocked as p, computeRouteActivityMatches as r, buildRouteContextBase as s, _resolveRouteMatchFromRoutes as t, parseLocation as u, getCurrentInheritedMeta as v, getCurrentScopeKind as w, getCurrentPageChain as x, getCurrentInheritedPolicies as y };
@@ -1,6 +1,6 @@
1
- import { c as RenderableChild } from "../control-CFIrGbD7.js";
1
+ import { c as RenderableChild } from "../control-CMzFPMjr.js";
2
2
  import { r as JSXElement, s as Props } from "../jsx-Dvr2SGRG.js";
3
- import { A as RouteQuery, B as RouteSnapshot, C as RouteMeta, D as RouteParams, E as RouteOptions, F as RouteRenderResult, I as RouteRequestOptions, L as RouteRequestResult, M as RouteRef, N as RouteRefSearch, O as RoutePathParams, P as RouteRegistry, R as RouteSearch, S as RouteMatch, T as RouteMode, _ as RouteContext, a as AccessRedirectDecision, b as RouteHandler, c as LayoutScopeRecord, d as ParsedSegment, f as RegisterRoutesOptions, g as RouteComponent, h as RouteAuthResolver, i as AccessDenyStatus, j as RouteRecord, k as RoutePolicy, l as PageHelperOptions, m as RouteAuthOptions, n as AccessDecision, o as AccessRedirectStatus, p as Route, r as AccessDenyDecision, s as GroupHelperOptions, t as AccessAllowDecision, u as PageScopeRecord, v as RouteDefinition, w as RouteMetaSource, x as RouteManifest, y as RouteDestination, z as RouteSearchValue } from "../router-lmH-Tmwh.js";
3
+ import { A as RouteRecord, B as RouteSnapshot, C as RouteMetaSource, D as RoutePathParams, E as RouteParams, F as RouteRenderResult, I as RouteRequestOptions, L as RouteRequestResult, M as RouteRefSearch, N as RouteRegistry, O as RoutePolicy, P as RouteRegistryOptions, R as RouteSearch, S as RouteMeta, T as RouteOptions, _ as RouteDefinition, a as AccessRedirectDecision, b as RouteManifest, c as LayoutScopeRecord, d as ParsedSegment, f as Route, g as RouteContext, h as RouteComponent, i as AccessDenyStatus, j as RouteRef, k as RouteQuery, l as PageHelperOptions, m as RouteAuthResolver, n as AccessDecision, o as AccessRedirectStatus, p as RouteAuthOptions, r as AccessDenyDecision, s as GroupHelperOptions, t as AccessAllowDecision, u as PageScopeRecord, v as RouteDestination, w as RouteMode, x as RouteMatch, y as RouteHandler, z as RouteSearchValue } from "../router-eRoaj11J.js";
4
4
  import { a as RouteQueryUpdates, c as NavigateOptions, d as ScrollRestorationOptions, i as RouteQueryUpdater, l as HistoryScrollBehavior, n as RouteQueryParamInput, o as UpdateRouteQueryOptions, r as RouteQueryParamValue, s as updateRouteQuery, t as navigate, u as NavigationScrollBehavior } from "../navigate-BVDCzOuB.js";
5
5
  import { AuthContext, AuthContext as AuthContext$1, AuthRequirement, AuthRequirement as AuthRequirement$1 } from "@askrjs/auth";
6
6
  import { ObjectSchema } from "@askrjs/schema";
@@ -21,7 +21,6 @@ declare function page<const TPath extends string>(path: TPath, Component: RouteC
21
21
  declare function page<const TPath extends string, TComponent extends AnyRouteComponent>(path: TPath, Component: CompatibleRouteComponent<TPath, TComponent>, options: PageHelperOptions, fn: RouteDefinition): void;
22
22
  declare function index(Component: RouteComponent, options?: RouteOptions): void;
23
23
  declare function fallback(Component: RouteComponent): void;
24
- declare function registerRoutes(definition: RouteDefinition, options?: RegisterRoutesOptions): void;
25
24
  declare function route<const TPath extends string, const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined>(path: TPath, Component: RouteComponent<RoutePathParams<TPath>>, options?: RouteOptions<RoutePathParams<TPath>, TSearchSchema>): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
26
25
  declare function route<const TPath extends string, TComponent extends AnyRouteComponent, const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined>(path: TPath, Component: CompatibleRouteComponent<TPath, TComponent>, options?: RouteOptionsForComponent<TPath, TComponent, TSearchSchema>): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
27
26
  //#endregion
@@ -36,12 +35,7 @@ declare function currentAuth(): AuthContext$1;
36
35
  declare function resolveRouteRequest(target: string, options?: RouteRequestOptions): RouteRequestResult | Promise<RouteRequestResult>;
37
36
  //#endregion
38
37
  //#region src/router/manifest.d.ts
39
- declare function getManifest(): RouteManifest;
40
- declare function clearRoutes(): void;
41
- declare function createRouteRegistry(definition: RouteDefinition, options?: RegisterRoutesOptions): RouteRegistry;
42
- //#endregion
43
- //#region src/router/store.d.ts
44
- declare function getRoutes(): Route[];
38
+ declare function createRouteRegistry(definition: RouteDefinition, options?: RouteRegistryOptions): RouteRegistry;
45
39
  //#endregion
46
40
  //#region src/router/lazy.d.ts
47
41
  type LazyRouteComponent<TComponent extends AnyRouteComponent> = TComponent & {
@@ -166,4 +160,4 @@ declare function Link({
166
160
  ...rest
167
161
  }: LinkProps): JSXElement;
168
162
  //#endregion
169
- export { type AccessDecision, type AccessDenyDecision, type AccessRedirectDecision, type AuthContext, type AuthRequirement, type Deferred, type DeferredState, type GroupHelperOptions, type HistoryScrollBehavior, type LayoutScopeRecord, type LazyRouteComponent, Link, type LinkProps, type NavigateOptions, type NavigationScrollBehavior, Outlet, type PageHelperOptions, type PageScopeRecord, type ParsedSegment, type RegisterRoutesOptions, Resolve, type ResolveProps, type Route, type RouteAuthOptions, type RouteAuthResolver, type RouteComponent, type RouteContext, type RouteDefinition, type RouteDestination, type RouteHandler, type RouteManifest, type RouteMatch, type RouteMeta, type RouteMetaSource, type RouteMode, type RouteOptions, type RouteParams, type RoutePathParams, type RoutePolicy, type RouteQuery, type RouteQueryParamInput, type RouteQueryParamValue, type RouteQueryUpdater, type RouteQueryUpdates, type RouteRecord, type RouteRef, type RouteRegistry, type RouteRenderResult, type RouteRequestOptions, type RouteRequestResult, type RouteSearch, type RouteSearchValue, type RouteSnapshot, type ScrollRestorationOptions, type UpdateRouteQueryOptions, allow, clearRoutes, createRouteRegistry, currentAuth, currentRoute, defer, deny, fallback, forbidden, getManifest, getRoutes, group, index, isDeferred, lazy, navigate, notFound, page, reconcileRouteMeta, redirect, registerRoutes, resolveDeferredValues, resolveRouteMeta, resolveRouteRequest, route, routeData, serializeRouteMeta, to$1 as to, unauthorized, updateRouteQuery };
163
+ export { type AccessDecision, type AccessDenyDecision, type AccessRedirectDecision, type AuthContext, type AuthRequirement, type Deferred, type DeferredState, type GroupHelperOptions, type HistoryScrollBehavior, type LayoutScopeRecord, type LazyRouteComponent, Link, type LinkProps, type NavigateOptions, type NavigationScrollBehavior, Outlet, type PageHelperOptions, type PageScopeRecord, type ParsedSegment, Resolve, type ResolveProps, type Route, type RouteAuthOptions, type RouteAuthResolver, type RouteComponent, type RouteContext, type RouteDefinition, type RouteDestination, type RouteHandler, type RouteManifest, type RouteMatch, type RouteMeta, type RouteMetaSource, type RouteMode, type RouteOptions, type RouteParams, type RoutePathParams, type RoutePolicy, type RouteQuery, type RouteQueryParamInput, type RouteQueryParamValue, type RouteQueryUpdater, type RouteQueryUpdates, type RouteRecord, type RouteRef, type RouteRegistry, type RouteRegistryOptions, type RouteRenderResult, type RouteRequestOptions, type RouteRequestResult, type RouteSearch, type RouteSearchValue, type RouteSnapshot, type ScrollRestorationOptions, type UpdateRouteQueryOptions, allow, createRouteRegistry, currentAuth, currentRoute, defer, deny, fallback, forbidden, group, index, isDeferred, lazy, navigate, notFound, page, reconcileRouteMeta, redirect, resolveDeferredValues, resolveRouteMeta, resolveRouteRequest, route, routeData, serializeRouteMeta, to$1 as to, unauthorized, updateRouteQuery };
@@ -1,7 +1,7 @@
1
- import { S as route, _ as fallback, a as resolveRouteMeta, b as page, d as clearRoutes, f as createRouteRegistry, i as reconcileRouteMeta, m as currentRoute, n as navigate, o as serializeRouteMeta, p as getManifest, r as updateRouteQuery, v as group, x as registerRoutes, y as index } from "../navigate-DLi79IZr.js";
1
+ import { C as lazy, a as resolveDeferredValues, b as Outlet, h as currentAuth, i as isDeferred, l as createRouteRegistry, m as resolveRouteRequest, n as Resolve, r as defer, s as routeData } from "../deferred-B71c2eio.js";
2
2
  import { jsx } from "../jsx-runtime.js";
3
- import { D as getRoutes } from "../route-matching-vJpvLVbX.js";
4
- import { S as lazy, a as resolveDeferredValues, f as resolveRouteRequest, i as isDeferred, n as Resolve, p as currentAuth, r as defer, s as routeData, v as Outlet } from "../deferred-BeNnjR4r.js";
3
+ import { a as route, i as page, n as group, r as index, t as fallback } from "../authoring-CXMPffwN.js";
4
+ import { a as resolveRouteMeta, i as reconcileRouteMeta, n as navigate, o as serializeRouteMeta, r as updateRouteQuery, u as currentRoute } from "../navigate-DTZ2SM8_.js";
5
5
  import { o as mergeProps } from "../compose-ref-Cc_YkUpM.js";
6
6
  import { t as applyInteractionPolicy } from "../interactions-w7gQN4ha.js";
7
7
  //#region src/router/policy.ts
@@ -147,4 +147,4 @@ function Link({ href: suppliedHref, to, class: className, children, rel, target,
147
147
  });
148
148
  }
149
149
  //#endregion
150
- export { Link, Outlet, Resolve, allow, clearRoutes, createRouteRegistry, currentAuth, currentRoute, defer, deny, fallback, forbidden, getManifest, getRoutes, group, index, isDeferred, lazy, navigate, notFound, page, reconcileRouteMeta, redirect, registerRoutes, resolveDeferredValues, resolveRouteMeta, resolveRouteRequest, route, routeData, serializeRouteMeta, to, unauthorized, updateRouteQuery };
150
+ export { Link, Outlet, Resolve, allow, createRouteRegistry, currentAuth, currentRoute, defer, deny, fallback, forbidden, group, index, isDeferred, lazy, navigate, notFound, page, reconcileRouteMeta, redirect, resolveDeferredValues, resolveRouteMeta, resolveRouteRequest, route, routeData, serializeRouteMeta, to, unauthorized, updateRouteQuery };
@@ -1,6 +1,6 @@
1
- import { c as RenderableChild } from "./control-CFIrGbD7.js";
1
+ import { c as RenderableChild } from "./control-CMzFPMjr.js";
2
2
  import { D as QueryPrefetchContext, u as CoreTelemetry } from "./index-Bki2rqcr.js";
3
- import { t as ActionDescriptor } from "./index-DaWuMuIc.js";
3
+ import { t as ActionDescriptor } from "./index-Bjm0__Rr.js";
4
4
  import { AuthContext, AuthRequirement } from "@askrjs/auth";
5
5
  import { InferSchema, ObjectSchema } from "@askrjs/schema";
6
6
 
@@ -79,6 +79,8 @@ interface RouteOptions<TParams extends RouteParams = RouteParams, TSearchSchema
79
79
  data: QueryPrefetchContext;
80
80
  }) => unknown;
81
81
  entries?: () => Array<TParams> | Promise<Array<TParams>>;
82
+ /** Optional invalidation keys used by incremental SSG generation. */
83
+ invalidationKeys?: readonly string[];
82
84
  title?: string;
83
85
  namespace?: string;
84
86
  search?: TSearchSchema;
@@ -147,7 +149,7 @@ interface LayoutScopeRecord {
147
149
  interface PageScopeRecord {
148
150
  component: RouteComponent;
149
151
  }
150
- interface RegisterRoutesOptions {
152
+ interface RouteRegistryOptions {
151
153
  auth?: RouteAuthOptions;
152
154
  }
153
155
  type RouteDefinition = () => void;
@@ -215,8 +217,9 @@ interface RouteRecord {
215
217
  * instead of assembling plain `Route[]` arrays.
216
218
  *
217
219
  * ```ts
218
- * import { getManifest } from '@askrjs/askr/router';
219
- * await createSPA({ root: '#app', manifest: getManifest() });
220
+ * import { createRouteRegistry } from '@askrjs/askr/router';
221
+ * const registry = createRouteRegistry(() => { ... });
222
+ * await createSPA({ root: '#app', registry });
220
223
  * ```
221
224
  */
222
225
  interface RouteManifest {
@@ -259,4 +262,4 @@ interface RouteSnapshot<TParams extends RouteParams = RouteParams> {
259
262
  matches: readonly RouteMatch<TParams>[];
260
263
  }
261
264
  //#endregion
262
- export { RouteQuery as A, RouteSnapshot as B, RouteMeta as C, RouteParams as D, RouteOptions as E, RouteRenderResult as F, RouteRequestOptions as I, RouteRequestResult as L, RouteRef as M, RouteRefSearch as N, RoutePathParams as O, RouteRegistry as P, RouteSearch as R, RouteMatch as S, RouteMode as T, RouteContext as _, AccessRedirectDecision as a, RouteHandler as b, LayoutScopeRecord as c, ParsedSegment as d, RegisterRoutesOptions as f, RouteComponent as g, RouteAuthResolver as h, AccessDenyStatus as i, RouteRecord as j, RoutePolicy as k, PageHelperOptions as l, RouteAuthOptions as m, AccessDecision as n, AccessRedirectStatus as o, Route as p, AccessDenyDecision as r, GroupHelperOptions as s, AccessAllowDecision as t, PageScopeRecord as u, RouteDefinition as v, RouteMetaSource as w, RouteManifest as x, RouteDestination as y, RouteSearchValue as z };
265
+ export { RouteRecord as A, RouteSnapshot as B, RouteMetaSource as C, RoutePathParams as D, RouteParams as E, RouteRenderResult as F, RouteRequestOptions as I, RouteRequestResult as L, RouteRefSearch as M, RouteRegistry as N, RoutePolicy as O, RouteRegistryOptions as P, RouteSearch as R, RouteMeta as S, RouteOptions as T, RouteDefinition as _, AccessRedirectDecision as a, RouteManifest as b, LayoutScopeRecord as c, ParsedSegment as d, Route as f, RouteContext as g, RouteComponent as h, AccessDenyStatus as i, RouteRef as j, RouteQuery as k, PageHelperOptions as l, RouteAuthResolver as m, AccessDecision as n, AccessRedirectStatus as o, RouteAuthOptions as p, AccessDenyDecision as r, GroupHelperOptions as s, AccessAllowDecision as t, PageScopeRecord as u, RouteDestination as v, RouteMode as w, RouteMatch as x, RouteHandler as y, RouteSearchValue as z };