@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
@@ -70,6 +70,7 @@ interface DocumentRenderContext {
70
70
  data?: SSRData;
71
71
  seed: number;
72
72
  route: DocumentRenderRoute;
73
+ cspNonce?: string;
73
74
  }
74
75
  interface DocumentRenderArgs {
75
76
  appHtml: string;
@@ -170,6 +171,8 @@ interface ComponentInstance {
170
171
  _rootComponentFn?: ComponentFunction;
171
172
  /** @internal Browser-owned hydration and route state for this app root. */
172
173
  _appRenderRuntime?: AppRenderRuntime;
174
+ /** @internal CSP nonce retained across browser route navigation. */
175
+ _cspNonce?: string;
173
176
  _vnodeOwner?: object;
174
177
  _vnodeParent?: ComponentInstance | null;
175
178
  _vnodeParentGeneration?: object;
@@ -0,0 +1,33 @@
1
+ import { l as defineScope, m as readScope } from "./component-internal-CbALfPGD.js";
2
+ //#region src/common/router-internal.ts
3
+ const ROUTE_ROOT_COMPONENT = Symbol.for("askr.route-root-component");
4
+ //#endregion
5
+ //#region src/csp-nonce.ts
6
+ const CspNonceScope = defineScope(void 0);
7
+ function cspNonce() {
8
+ try {
9
+ return readScope(CspNonceScope);
10
+ } catch (error) {
11
+ if (error instanceof Error && error.message.startsWith("readScope() can only be called during component render")) return;
12
+ throw error;
13
+ }
14
+ }
15
+ function validateCspNonce(value) {
16
+ if (value === void 0) return void 0;
17
+ const invalid = () => {
18
+ throw new TypeError("CSP nonce must be valid base64 or base64url encoding at least 16 bytes.");
19
+ };
20
+ if (value.length === 0 || !/^[A-Za-z0-9+/_-]+={0,2}$/.test(value) || value.length % 4 === 1 || /=/.test(value.slice(0, -2))) invalid();
21
+ const unpadded = value.replace(/-/g, "+").replace(/_/g, "/").replace(/=+$/, "");
22
+ const padded = unpadded.padEnd(Math.ceil(unpadded.length / 4) * 4, "=");
23
+ let decoded = "";
24
+ try {
25
+ decoded = atob(padded);
26
+ } catch {
27
+ invalid();
28
+ }
29
+ if (decoded.length < 16) invalid();
30
+ return value;
31
+ }
32
+ //#endregion
33
+ export { ROUTE_ROOT_COMPONENT as i, cspNonce as n, validateCspNonce as r, CspNonceScope as t };
@@ -4,9 +4,21 @@ import { d as getCurrentAppRenderRuntime } from "./component-scope-CC3cojX9.js";
4
4
  import { m as isPromiseLike } from "./component-lifecycle-DEMPihoZ.js";
5
5
  import { n as getActiveRenderContext, r as getCurrentRenderData } from "./render-context-Clw3rFiO.js";
6
6
  import { t as resource } from "./resource-operation-Dz2Nxi1q.js";
7
- import { t as ROUTE_ROOT_COMPONENT } from "./router-internal-BC0w1_xk.js";
7
+ import { i as ROUTE_ROOT_COMPONENT } from "./csp-nonce-C-8E85El.js";
8
8
  import { c as withTelemetry, t as createQueryPrefetchContext } from "./query-registry-CQIT4mXr.js";
9
- import { E as getRouteRecords, h as getActiveRouteAuthOptions, i as getMatchingRouteRecord, o as buildRouteContext, s as buildRouteContextBase } from "./route-matching-vJpvLVbX.js";
9
+ import { A as insertRecordSorted, D as getRouteRecords, E as getRouteList, F as snapshotRouteState, N as restoreRouteState, P as setDefaultRouteAuthOptions, T as getDefaultRouteAuthOptions, f as addRouteToStores, h as getActiveRouteAuthOptions, i as getMatchingRouteRecord, m as clearRouteState, o as buildRouteContext, s as buildRouteContextBase } from "./route-matching-C93To416.js";
10
+ //#region src/runtime/execution-model.ts
11
+ const EXECUTION_MODEL_KEY = Symbol.for("__ASKR_EXECUTION_MODEL__");
12
+ function getExecutionModel() {
13
+ return globalThis[EXECUTION_MODEL_KEY];
14
+ }
15
+ function assertExecutionModel(model) {
16
+ const g = globalThis;
17
+ const cur = g[EXECUTION_MODEL_KEY];
18
+ 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.`);
19
+ if (!cur) g[EXECUTION_MODEL_KEY] = model;
20
+ }
21
+ //#endregion
10
22
  //#region src/router/lazy.ts
11
23
  const pendingLazy = /* @__PURE__ */ new Set();
12
24
  const lazyStates = /* @__PURE__ */ new WeakMap();
@@ -55,13 +67,6 @@ function _preloadRouteRecord(record) {
55
67
  function _associateLazyHandler(handler, components) {
56
68
  handlerLazyComponents.set(handler, components);
57
69
  }
58
- function _preloadRouteHandler(handler) {
59
- const imports = (handlerLazyComponents.get(handler) ?? []).flatMap((component) => {
60
- const state = lazyStates.get(component);
61
- return state ? [startLazyLoad(state)] : [];
62
- });
63
- return imports.length > 0 ? Promise.all(imports).then(() => void 0) : null;
64
- }
65
70
  //#endregion
66
71
  //#region src/router/rendering.ts
67
72
  const outletScope = defineScope(null);
@@ -321,6 +326,42 @@ function resolveRouteRequest(target, options = {}) {
321
326
  });
322
327
  }
323
328
  //#endregion
329
+ //#region src/router/manifest.ts
330
+ function createRouteManifest() {
331
+ const auth = getDefaultRouteAuthOptions();
332
+ return {
333
+ records: [...getRouteRecords()],
334
+ ...auth ? { auth } : {}
335
+ };
336
+ }
337
+ function _applyManifest(manifest) {
338
+ setDefaultRouteAuthOptions(manifest.auth);
339
+ for (const record of manifest.records) {
340
+ insertRecordSorted(record);
341
+ addRouteToStores({
342
+ path: record.path,
343
+ handler: record.handler,
344
+ namespace: record.options.namespace,
345
+ ..."fallbackPrefix" in record && typeof record.fallbackPrefix === "string" ? { fallbackPrefix: record.fallbackPrefix } : {}
346
+ });
347
+ }
348
+ }
349
+ function createRouteRegistry(definition, options = {}) {
350
+ const previous = snapshotRouteState();
351
+ clearRouteState();
352
+ try {
353
+ setDefaultRouteAuthOptions(options.auth);
354
+ definition();
355
+ const manifest = createRouteManifest();
356
+ return Object.freeze({
357
+ manifest,
358
+ routes: getRouteList()
359
+ });
360
+ } finally {
361
+ restoreRouteState(previous);
362
+ }
363
+ }
364
+ //#endregion
324
365
  //#region src/router/deferred.tsx
325
366
  const DEFERRED_VALUE = Symbol.for("@askrjs/askr/deferred-value");
326
367
  const DEFERRED_BOUNDARY = Symbol.for("@askrjs/askr/deferred-boundary");
@@ -450,4 +491,4 @@ function Resolve(props) {
450
491
  return props.children(result.value);
451
492
  }
452
493
  //#endregion
453
- export { lazy as S, pageRenderEnvelope as _, resolveDeferredValues as a, getRenderHandler as b, bindResolvedRouteData as c, hasRouteRenderData as d, resolveRouteRequest as f, isPageRenderEnvelope as g, isEmptyPageRenderEnvelope as h, isDeferred as i, getRouteRenderContext as l, createPageRenderEnvelope as m, Resolve as n, reviveDeferredValue as o, currentAuth as p, defer as r, routeData as s, DEFERRED_BOUNDARY as t, getRouteRenderData as u, Outlet as v, _preloadRouteHandler as x, createRouteHandler as y };
494
+ export { lazy as C, getRenderHandler as S, getExecutionModel as T, isEmptyPageRenderEnvelope as _, resolveDeferredValues as a, Outlet as b, _applyManifest as c, getRouteRenderContext as d, getRouteRenderData as f, createPageRenderEnvelope as g, currentAuth as h, isDeferred as i, createRouteRegistry as l, resolveRouteRequest as m, Resolve as n, reviveDeferredValue as o, hasRouteRenderData as p, defer as r, routeData as s, DEFERRED_BOUNDARY as t, bindResolvedRouteData as u, isPageRenderEnvelope as v, assertExecutionModel as w, createRouteHandler as x, pageRenderEnvelope as y };
@@ -1,3 +1,3 @@
1
1
  import { r as JSXElement } from "../jsx-Dvr2SGRG.js";
2
- import { _ as definePortal, c as Presence, d as SlotProps, f as LayoutComponent, g as PortalProps, h as Portal, l as PresenceProps, m as DefaultPortal, p as layout, u as Slot } from "../index-Bce-RQg-.js";
2
+ import { _ as definePortal, c as Presence, d as SlotProps, f as LayoutComponent, g as PortalProps, h as Portal, l as PresenceProps, m as DefaultPortal, p as layout, u as Slot } from "../index-PgRn5wmg.js";
3
3
  export { DefaultPortal, type JSXElement, type LayoutComponent, Portal, type PortalProps, Presence, type PresenceProps, Slot, type SlotProps, definePortal, layout };
@@ -1,4 +1,4 @@
1
- import { m as State } from "../../control-CFIrGbD7.js";
1
+ import { m as State } from "../../control-CMzFPMjr.js";
2
2
 
3
3
  //#region src/foundations/state/controllable.d.ts
4
4
  declare function isControlled<T>(value: T | undefined): value is T;
@@ -1,3 +1,3 @@
1
1
  import { r as JSXElement } from "../../jsx-Dvr2SGRG.js";
2
- import { _ as definePortal, a as Collection, c as Presence, d as SlotProps, f as LayoutComponent, g as PortalProps, h as Portal, i as createLayer, l as PresenceProps, m as DefaultPortal, n as LayerManager, o as CollectionItem, p as layout, r as LayerOptions, s as createCollection, t as Layer, u as Slot } from "../../index-Bce-RQg-.js";
2
+ import { _ as definePortal, a as Collection, c as Presence, d as SlotProps, f as LayoutComponent, g as PortalProps, h as Portal, i as createLayer, l as PresenceProps, m as DefaultPortal, n as LayerManager, o as CollectionItem, p as layout, r as LayerOptions, s as createCollection, t as Layer, u as Slot } from "../../index-PgRn5wmg.js";
3
3
  export { type Collection, type CollectionItem, DefaultPortal, type JSXElement, type Layer, type LayerManager, type LayerOptions, type LayoutComponent, Portal, type PortalProps, Presence, type PresenceProps, Slot, type SlotProps, createCollection, createLayer, definePortal, layout };
@@ -1,4 +1,4 @@
1
- import { c as RenderableChild, g as StateTuple } from "./control-CFIrGbD7.js";
1
+ import { c as RenderableChild, g as StateTuple } from "./control-CMzFPMjr.js";
2
2
  import { r as JSXElement } from "./jsx-Dvr2SGRG.js";
3
3
  import { ObjectSchema } from "@askrjs/schema";
4
4
 
@@ -1,4 +1,4 @@
1
- import { c as RenderableChild, l as VNode, t as ForEachSource } from "./control-CFIrGbD7.js";
1
+ import { c as RenderableChild, l as VNode, t as ForEachSource } from "./control-CMzFPMjr.js";
2
2
  import { r as JSXElement } from "./jsx-Dvr2SGRG.js";
3
3
 
4
4
  //#region src/control/shared.d.ts
@@ -1,4 +1,4 @@
1
- import { n as ReadableSource, r as ComponentInstance } from "./control-CFIrGbD7.js";
1
+ import { i as Scope, n as ReadableSource, r as ComponentInstance } from "./control-CMzFPMjr.js";
2
2
  import { t as Scheduler } from "./scheduler-CmLO4Dfm.js";
3
3
  //#region src/runtime/runtime.d.ts
4
4
  interface RuntimeKeyedReorderDecision {
@@ -62,4 +62,8 @@ type SelectorEquals<T> = {
62
62
  }['bivarianceHack'];
63
63
  declare function selector<T>(source: () => T, equals?: SelectorEquals<T>): Selector<T>;
64
64
  //#endregion
65
- export { AskrRuntime as a, RuntimeRendererHost as c, derive as i, createRuntime as l, selector as n, AskrRuntimeOptions as o, Derived as r, RuntimeKeyedReorderDecision as s, Selector as t, getDefaultRuntime as u };
65
+ //#region src/csp-nonce.d.ts
66
+ declare const CspNonceScope: Scope<string | undefined>;
67
+ declare function cspNonce(): string | undefined;
68
+ //#endregion
69
+ export { Derived as a, AskrRuntimeOptions as c, createRuntime as d, getDefaultRuntime as f, selector as i, RuntimeKeyedReorderDecision as l, cspNonce as n, derive as o, Selector as r, AskrRuntime as s, CspNonceScope as t, RuntimeRendererHost as u };
@@ -1,4 +1,4 @@
1
- import { c as RenderableChild } from "./control-CFIrGbD7.js";
1
+ import { c as RenderableChild } from "./control-CMzFPMjr.js";
2
2
  import { r as JSXElement } from "./jsx-Dvr2SGRG.js";
3
3
  //#region src/runtime/portal.d.ts
4
4
  interface Portal<T extends RenderableChild = RenderableChild> {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { _ as state, a as defineScope, g as StateTuple, h as StateSetter, i as Scope, m as State, o as readScope } from "./control-CFIrGbD7.js";
1
+ import { _ as state, a as defineScope, g as StateTuple, h as StateSetter, i as Scope, m as State, o as readScope } from "./control-CMzFPMjr.js";
2
2
  import { s as Props, t as Fragment } from "./jsx-Dvr2SGRG.js";
3
3
  import { t as getSignal } from "./component-scope-CvPba6O6.js";
4
- import { a as AskrRuntime, c as RuntimeRendererHost, i as derive, l as createRuntime, n as selector, o as AskrRuntimeOptions, r as Derived, s as RuntimeKeyedReorderDecision, t as Selector, u as getDefaultRuntime } from "./index-CRck4XVe.js";
5
- import { a as Show, c as ForProps, i as MatchProps, n as CaseProps, o as ShowProps, r as Match, s as For, t as Case } from "./index-DlvpxdSz.js";
4
+ import { a as Derived, c as AskrRuntimeOptions, d as createRuntime, f as getDefaultRuntime, i as selector, l as RuntimeKeyedReorderDecision, n as cspNonce, o as derive, r as Selector, s as AskrRuntime, t as CspNonceScope, u as RuntimeRendererHost } from "./index-NKPpdRh9.js";
5
+ import { a as Show, c as ForProps, i as MatchProps, n as CaseProps, o as ShowProps, r as Match, s as For, t as Case } from "./index-Byqjltu2.js";
6
6
  import { i as jsxs, n as jsx } from "./jsx-runtime-iTU73uwP.js";
7
7
  import { A as ServerQueryHandler, D as QueryPrefetchContext, T as QueryDefinition, a as defineServerQueries, c as prefetchQuery, g as createQuery, i as defineQuery, l as serveQuery, o as dehydrateDataRuntime, s as hydrateDataRuntime, v as DataRuntime } from "./index-Bki2rqcr.js";
8
- export { AskrRuntime, type AskrRuntimeOptions, Case, type CaseProps, type DataRuntime, type Derived, For, type ForProps, Fragment, Match, type MatchProps, type Props, type QueryDefinition, type QueryPrefetchContext, type RuntimeKeyedReorderDecision, type RuntimeRendererHost, type Scope, type Selector, type ServerQueryHandler, Show, type ShowProps, type State, type StateSetter, type StateTuple, createQuery, createRuntime, defineQuery, defineScope, defineServerQueries, dehydrateDataRuntime, derive, getDefaultRuntime, getSignal, hydrateDataRuntime, jsx, jsxs, prefetchQuery, readScope, selector, serveQuery, state };
8
+ export { AskrRuntime, type AskrRuntimeOptions, Case, type CaseProps, CspNonceScope, type DataRuntime, type Derived, For, type ForProps, Fragment, Match, type MatchProps, type Props, type QueryDefinition, type QueryPrefetchContext, type RuntimeKeyedReorderDecision, type RuntimeRendererHost, type Scope, type Selector, type ServerQueryHandler, Show, type ShowProps, type State, type StateSetter, type StateTuple, createQuery, createRuntime, cspNonce, defineQuery, defineScope, defineServerQueries, dehydrateDataRuntime, derive, getDefaultRuntime, getSignal, hydrateDataRuntime, jsx, jsxs, prefetchQuery, readScope, selector, serveQuery, state };
package/dist/index.js CHANGED
@@ -4,10 +4,11 @@ import { n as Fragment } from "./jsx-CUpRxrLH.js";
4
4
  import { l as defineScope, m as readScope } from "./component-internal-CbALfPGD.js";
5
5
  import { g as getSignal, i as claimHookIndex, p as getCurrentInstance } from "./component-scope-CC3cojX9.js";
6
6
  import { n as isSnapshotSource } from "./snapshot-source-BB42xgwb.js";
7
- import { t as installRendererBridge } from "./renderer-CVr_nktj.js";
7
+ import { t as installRendererBridge } from "./renderer-aUD-acDe.js";
8
8
  import { t as state } from "./state-Cc5HumQ0.js";
9
9
  import { t as selector } from "./selector-pApF_lGd.js";
10
10
  import { jsx, jsxs } from "./jsx-runtime.js";
11
+ import { n as cspNonce, t as CspNonceScope } from "./csp-nonce-C-8E85El.js";
11
12
  import { i as For, n as Match, r as Show, t as Case } from "./control-KVP6LMEQ.js";
12
13
  import { t as createQuery } from "./data-DvYo_dHd.js";
13
14
  import { a as hydrateDataRuntime, i as dehydrateDataRuntime, n as defineQuery, o as prefetchQuery, r as defineServerQueries, s as serveQuery } from "./query-registry-CQIT4mXr.js";
@@ -156,4 +157,4 @@ function derive(source, map) {
156
157
  */
157
158
  installRendererBridge();
158
159
  //#endregion
159
- export { AskrRuntime, Case, For, Fragment, Match, Show, createQuery, createRuntime, defineQuery, defineScope, defineServerQueries, dehydrateDataRuntime, derive, getDefaultRuntime, getSignal, hydrateDataRuntime, jsx, jsxs, prefetchQuery, readScope, selector, serveQuery, state };
160
+ export { AskrRuntime, Case, CspNonceScope, For, Fragment, Match, Show, createQuery, createRuntime, cspNonce, defineQuery, defineScope, defineServerQueries, dehydrateDataRuntime, derive, getDefaultRuntime, getSignal, hydrateDataRuntime, jsx, jsxs, prefetchQuery, readScope, selector, serveQuery, state };