@askrjs/askr 0.0.85 → 0.0.86

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 (36) hide show
  1. package/dist/actions/index.js +2 -2
  2. package/dist/{activity-Jd9CgEa3.js → activity-BvgvaMZA.js} +2 -2
  3. package/dist/benchmark.js +4 -4
  4. package/dist/boot/index.js +1 -1
  5. package/dist/{boot-DWe880Et.js → boot-CViTpUiB.js} +13 -12
  6. package/dist/data/index.js +3 -3
  7. package/dist/{data-Dkqb8_QP.js → data-DGrD3-qA.js} +2 -2
  8. package/dist/{data-runtime-D68YOo9L.js → data-runtime-Ck3tJDDQ.js} +1 -1
  9. package/dist/default-portal-runtime-DvMvWJVp.js +20 -0
  10. package/dist/{authoring-DdQ3pHqt.js → deferred-nleQtdfY.js} +81 -4
  11. package/dist/foundations/index.d.ts +1 -1
  12. package/dist/foundations/index.js +1 -2
  13. package/dist/foundations/structures/index.d.ts +1 -1
  14. package/dist/foundations/structures/index.js +1 -2
  15. package/dist/{index-Bkh9S9-t.d.ts → index-DflhL1h8.d.ts} +15 -15
  16. package/dist/index.js +4 -4
  17. package/dist/manifest-D1P9uTlz.js +53 -0
  18. package/dist/{navigate-b4GGxO_l.js → navigate-BwAPbpCb.js} +6 -6
  19. package/dist/{query-registry-BL6rjGsO.js → query-registry-CPW_6nwF.js} +1 -1
  20. package/dist/render-context-D0Hoj9dW.js +161 -0
  21. package/dist/{deferred-vUOy-awa.js → resolution-YHwi4Bav.js} +59 -229
  22. package/dist/resource-operation-ys6eDoRJ.js +304 -0
  23. package/dist/resources/index.js +2 -2
  24. package/dist/{route-matching-DHduNiGk.js → route-matching-DqULzZtC.js} +2 -276
  25. package/dist/router/index.d.ts +5 -3
  26. package/dist/router/index.js +6 -5
  27. package/dist/ssg/index.js +5 -4
  28. package/dist/ssr/index.js +2 -2
  29. package/dist/{ssr-CpiBHMNv.js → ssr-B98593qJ.js} +28 -13
  30. package/dist/{portal-BVWjAhNQ.js → structures-DsOm-clq.js} +232 -3
  31. package/dist/testing/index.js +3 -3
  32. package/dist/{verify-hydration-C3QBBQqR.js → verify-hydration-ww1dgwea.js} +4 -3
  33. package/package.json +2 -2
  34. package/dist/render-context-D-DFk2WN.js +0 -73
  35. package/dist/structures-DSLF_iis.js +0 -223
  36. package/dist/{renderer-CZzNtoj2.js → renderer-D9DL9R2D.js} +1 -1
@@ -1,8 +1,8 @@
1
1
  import { d as getCurrentAppRenderRuntime } from "../component-scope-DzJEbYGE.js";
2
- import { r as getCurrentRenderData } from "../render-context-D-DFk2WN.js";
2
+ import { r as getCurrentRenderData } from "../render-context-D0Hoj9dW.js";
3
3
  import { t as state } from "../state-DCjONcHK.js";
4
4
  import { jsx, jsxs } from "../jsx-runtime.js";
5
- import { c as resolveDataRuntimeState, s as invalidateQueriesForRuntime } from "../data-runtime-D68YOo9L.js";
5
+ import { c as resolveDataRuntimeState, s as invalidateQueriesForRuntime } from "../data-runtime-Ck3tJDDQ.js";
6
6
  //#region src/actions/runtime.ts
7
7
  const emptyFramework = Object.freeze({});
8
8
  /** @internal Read Askr-owned state from the current application root. */
@@ -1,9 +1,9 @@
1
1
  import { d as getCurrentAppRenderRuntime, f as getCurrentComponentInstance, i as claimHookIndex } from "./component-scope-DzJEbYGE.js";
2
2
  import { a as registerCommitOperation } from "./component-internal-DcrLymUJ.js";
3
3
  import { l as notifyReadableReaders, o as markReactivePropsDirtySource, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-B5NtV7V0.js";
4
- import { n as getActiveRenderContext } from "./render-context-D-DFk2WN.js";
5
- import { b as getActiveRoutes, c as removeRouteBasePath, d as deepFreeze, f as makeQuery, n as computeMatchesFromRoutes, p as parseLocation, y as getActiveRouteBasePath } from "./route-matching-DHduNiGk.js";
4
+ import { n as getActiveRenderContext } from "./render-context-D0Hoj9dW.js";
6
5
  import { n as syncRouteActivitySnapshot } from "./route-activity-CNJfpwx-.js";
6
+ import { b as getActiveRoutes, c as removeRouteBasePath, d as deepFreeze, f as makeQuery, n as computeMatchesFromRoutes, p as parseLocation, y as getActiveRouteBasePath } from "./route-matching-DqULzZtC.js";
7
7
  //#region src/common/app-render-runtime.ts
8
8
  const stagedRouteLocations = /* @__PURE__ */ new WeakMap();
9
9
  function createAppRenderRuntime(input = {}) {
package/dist/benchmark.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { r as flushRuntimeScheduler } from "./access-Dpfoi4cA.js";
2
- import { t as installRendererBridge } from "./renderer-CZzNtoj2.js";
2
+ import { t as installRendererBridge } from "./renderer-D9DL9R2D.js";
3
3
  import { t as state } from "./state-DCjONcHK.js";
4
4
  import { t as selector } from "./selector-Ck_Pp9av.js";
5
5
  import { i as For } from "./control-oLADku43.js";
6
6
  import { jsx, jsxs } from "./jsx-runtime.js";
7
- import { t as createIsland } from "./boot-DWe880Et.js";
7
+ import { t as createIsland } from "./boot-CViTpUiB.js";
8
8
  //#region src/bench/components/benchmark-row.tsx
9
9
  function BenchmarkRow({ item, isSelected, onSelect, onRemove }) {
10
10
  return /* @__PURE__ */ jsxs("tr", {
@@ -63,8 +63,8 @@ function BenchmarkTable({ rows, isSelected, onSelect, onRemove }) {
63
63
  installRendererBridge();
64
64
  const benchmarkMetadata = {
65
65
  packageName: "@askrjs/askr",
66
- packageVersion: "0.0.85",
67
- buildLabel: "0.0.85-local"
66
+ packageVersion: "0.0.86",
67
+ buildLabel: "0.0.86-local"
68
68
  };
69
69
  function getBenchmarkMetadata() {
70
70
  return { ...benchmarkMetadata };
@@ -1,2 +1,2 @@
1
- import { a as cleanupApp, i as hydrateSPA, n as createIslands, o as hasApp, r as createSPA, t as createIsland } from "../boot-DWe880Et.js";
1
+ import { a as cleanupApp, i as hydrateSPA, n as createIslands, o as hasApp, r as createSPA, t as createIsland } from "../boot-CViTpUiB.js";
2
2
  export { cleanupApp, createIsland, createIslands, createSPA, hasApp, hydrateSPA };
@@ -3,17 +3,18 @@ import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-C3IECePB.js";
3
3
  import { n as createComponentInstance, r as executeComponent } from "./component-internal-DcrLymUJ.js";
4
4
  import { t as cleanupComponent } from "./component-cleanup-BUfUleGZ.js";
5
5
  import { p as isPromiseLike } from "./lifecycle-batch-Dfpid9-A.js";
6
- import { a as setStaticChildSlotsCacheEnabled, c as endHydrationDirectListenerMode, d as discardHydrationListenerTransaction, i as registerDeferredHydrationBoundary, l as beginHydrationListenerTransaction, n as activateHydrationBoundary$1, o as withIntrinsicHydrationAdoption, r as clearDeferredHydrationBoundaries, s as beginHydrationDirectListenerMode, t as installRendererBridge, u as commitHydrationListenerTransaction } from "./renderer-CZzNtoj2.js";
6
+ import { a as setStaticChildSlotsCacheEnabled, c as endHydrationDirectListenerMode, d as discardHydrationListenerTransaction, i as registerDeferredHydrationBoundary, l as beginHydrationListenerTransaction, n as activateHydrationBoundary$1, o as withIntrinsicHydrationAdoption, r as clearDeferredHydrationBoundaries, s as beginHydrationDirectListenerMode, t as installRendererBridge, u as commitHydrationListenerTransaction } from "./renderer-D9DL9R2D.js";
7
7
  import { _ as teardownNodeSubtree, d as removeAllListeners } from "./cleanup-c837KVij.js";
8
- import { S as pageRenderEnvelope, c as _applyManifest, d as getRouteRenderContext, f as getRouteRenderData, k as assertExecutionModel, m as resolveRouteRequest, o as reviveDeferredValue, p as hasRouteRenderData } from "./deferred-vUOy-awa.js";
9
- import { c as stopHydrationRenderPhase, o as startHydrationRenderPhase } from "./render-context-D-DFk2WN.js";
10
- import { I as lockRouteRegistration, P as hasRegisteredRoutes, _ as clearRouteState, m as _setActiveRouteAuthOptions } from "./route-matching-DHduNiGk.js";
11
- import { a as disposeDefaultPortalScope, t as DefaultPortal } from "./portal-BVWjAhNQ.js";
8
+ import { r as assertExecutionModel, t as _applyManifest } from "./manifest-D1P9uTlz.js";
9
+ import { d as stopHydrationRenderPhase, l as startHydrationRenderPhase, v as pageRenderEnvelope } from "./render-context-D0Hoj9dW.js";
12
10
  import { r as validateCspNonce, t as CspNonceScope } from "./csp-nonce-Bc52OIVc.js";
13
- import { i as getDefaultDataRuntime } from "./data-runtime-D68YOo9L.js";
14
- import { a as hydrateDataRuntime } from "./query-registry-BL6rjGsO.js";
15
- import { o as createAppRenderRuntime, r as setServerLocation } from "./activity-Jd9CgEa3.js";
16
- import { f as registerAppInstance, g as unregisterAppInstance, i as resolveRouteMeta, o as configureScrollRestoration, r as reconcileRouteMeta, t as initializeNavigation } from "./navigate-b4GGxO_l.js";
11
+ import { i as getDefaultDataRuntime } from "./data-runtime-Ck3tJDDQ.js";
12
+ import { a as hydrateDataRuntime } from "./query-registry-CPW_6nwF.js";
13
+ import { I as lockRouteRegistration, P as hasRegisteredRoutes, _ as clearRouteState, m as _setActiveRouteAuthOptions } from "./route-matching-DqULzZtC.js";
14
+ import { a as resolveRouteRequest, i as hasRouteRenderData, m as reviveDeferredValue, n as getRouteRenderContext, r as getRouteRenderData } from "./resolution-YHwi4Bav.js";
15
+ import { o as createAppRenderRuntime, r as setServerLocation } from "./activity-BvgvaMZA.js";
16
+ import { f as registerAppInstance, g as unregisterAppInstance, i as resolveRouteMeta, o as configureScrollRestoration, r as reconcileRouteMeta, t as initializeNavigation } from "./navigate-BwAPbpCb.js";
17
+ import { n as disposeRegisteredDefaultPortalScope, r as getDefaultPortalHost } from "./default-portal-runtime-DvMvWJVp.js";
17
18
  import "./ssr-DSHd_Q9K.js";
18
19
  //#region src/boot/hydration.ts
19
20
  const DEFERRED_PAYLOAD = "__askr_deferred__";
@@ -268,7 +269,7 @@ function mountOrUpdate(rootElement, componentFn, options) {
268
269
  if (isPromiseLike(out)) throw new Error("Async components are not supported. Components must return synchronously.");
269
270
  const portalVNode = {
270
271
  $$typeof: ELEMENT_TYPE,
271
- type: DefaultPortal,
272
+ type: getDefaultPortalHost(),
272
273
  props: { __askrAutoDefaultPortal: true },
273
274
  key: "__default_portal"
274
275
  };
@@ -337,7 +338,7 @@ function mountOrUpdate(rootElement, componentFn, options) {
337
338
  }
338
339
  attachCleanupForRoot(rootElement, instance);
339
340
  registerRootCleanupCallback(rootElement, () => {
340
- disposeDefaultPortalScope(instance.portalScope ?? instance);
341
+ disposeRegisteredDefaultPortalScope(instance.portalScope ?? instance);
341
342
  });
342
343
  executeComponent(instance);
343
344
  flushRuntimeScheduler();
@@ -586,7 +587,7 @@ async function hydrateSPA(config) {
586
587
  cspNonce: config.cspNonce
587
588
  }));
588
589
  if (shouldVerifyHydrationMarkup(config)) {
589
- const { verifyHydrationSyncForUrl } = await import("./verify-hydration-C3QBBQqR.js");
590
+ const { verifyHydrationSyncForUrl } = await import("./verify-hydration-ww1dgwea.js");
590
591
  if (!verifyHydrationSyncForUrl({
591
592
  root: rootElement,
592
593
  url: currentUrl,
@@ -1,4 +1,4 @@
1
- import { i as getDefaultDataRuntime, t as createDataRuntime } from "../data-runtime-D68YOo9L.js";
2
- import { a as queryScope, i as invalidateOnInterval, n as createMutation, r as invalidate, t as createQuery } from "../data-Dkqb8_QP.js";
3
- import { a as hydrateDataRuntime, i as dehydrateDataRuntime, n as defineQuery, o as prefetchQuery, r as defineServerQueries, s as serveQuery, t as createQueryPrefetchContext } from "../query-registry-BL6rjGsO.js";
1
+ import { i as getDefaultDataRuntime, t as createDataRuntime } from "../data-runtime-Ck3tJDDQ.js";
2
+ import { a as queryScope, i as invalidateOnInterval, n as createMutation, r as invalidate, t as createQuery } from "../data-DGrD3-qA.js";
3
+ import { a as hydrateDataRuntime, i as dehydrateDataRuntime, n as defineQuery, o as prefetchQuery, r as defineServerQueries, s as serveQuery, t as createQueryPrefetchContext } from "../query-registry-CPW_6nwF.js";
4
4
  export { createDataRuntime, createMutation, createQuery, createQueryPrefetchContext, defineQuery, defineServerQueries, dehydrateDataRuntime, getDefaultDataRuntime, hydrateDataRuntime, invalidate, invalidateOnInterval, prefetchQuery, queryScope, serveQuery };
@@ -1,9 +1,9 @@
1
1
  import { n as enqueueRuntimeTask, v as logger } from "./access-Dpfoi4cA.js";
2
2
  import { f as getCurrentComponentInstance, i as claimHookIndex } from "./component-scope-DzJEbYGE.js";
3
3
  import { l as notifyReadableReaders, o as markReactivePropsDirtySource, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-B5NtV7V0.js";
4
- import { n as getActiveRenderContext } from "./render-context-D-DFk2WN.js";
4
+ import { n as getActiveRenderContext } from "./render-context-D0Hoj9dW.js";
5
5
  import { i as routeActive, n as documentVisible, o as timer, s as windowFocused } from "./lifecycle-operations-BrYrBsXY.js";
6
- import { a as getMutationSlotStore, c as resolveDataRuntimeState, i as getDefaultDataRuntime, n as ensureMutationCleanup, o as getQuerySlotStore, r as ensureQueryCleanup, s as invalidateQueriesForRuntime } from "./data-runtime-D68YOo9L.js";
6
+ import { a as getMutationSlotStore, c as resolveDataRuntimeState, i as getDefaultDataRuntime, n as ensureMutationCleanup, o as getQuerySlotStore, r as ensureQueryCleanup, s as invalidateQueriesForRuntime } from "./data-runtime-Ck3tJDDQ.js";
7
7
  //#region src/data/query-key.ts
8
8
  function serializeQueryKeyNumber(part) {
9
9
  if (Number.isNaN(part)) return "NaN";
@@ -1,4 +1,4 @@
1
- import { n as getActiveRenderContext } from "./render-context-D-DFk2WN.js";
1
+ import { n as getActiveRenderContext } from "./render-context-D0Hoj9dW.js";
2
2
  //#region src/data/invalidation-listeners.ts
3
3
  const invalidationListeners = /* @__PURE__ */ new Set();
4
4
  function addInvalidationListener(listener) {
@@ -0,0 +1,20 @@
1
+ //#region src/common/default-portal-runtime.ts
2
+ let defaultPortalRuntime = null;
3
+ function InactiveDefaultPortalHost() {
4
+ return null;
5
+ }
6
+ /** Register the optional portal capability when its public module is loaded. */
7
+ function registerDefaultPortalRuntime(runtime) {
8
+ defaultPortalRuntime = runtime;
9
+ }
10
+ function getDefaultPortalHost() {
11
+ return defaultPortalRuntime?.host ?? InactiveDefaultPortalHost;
12
+ }
13
+ function clearRegisteredDefaultPortalForInstance(instance) {
14
+ defaultPortalRuntime?.clearForInstance(instance);
15
+ }
16
+ function disposeRegisteredDefaultPortalScope(scope) {
17
+ defaultPortalRuntime?.disposeScope(scope);
18
+ }
19
+ //#endregion
20
+ export { registerDefaultPortalRuntime as i, disposeRegisteredDefaultPortalScope as n, getDefaultPortalHost as r, clearRegisteredDefaultPortalForInstance as t };
@@ -1,6 +1,9 @@
1
- import { f as getCurrentComponentInstance } from "./component-scope-DzJEbYGE.js";
2
- import { A as getExecutionModel, T as createRouteHandler } from "./deferred-vUOy-awa.js";
3
- import { A as getDefaultRouteBasePath, C as getCurrentInheritedPolicies, D as getCurrentPathPrefix, E as getCurrentPageScope, F as insertRecordSorted, H as computeRank, L as pushRegistrationScope, N as hasActivePageScope, O as getCurrentScopeKind, S as getCurrentInheritedMeta, T as getCurrentPageChain, U as normalizeRouteSegmentName, W as parseSegments, g as assertRouteRegistrationUnlocked, h as addRouteToStores, w as getCurrentLayoutChain, x as getCurrentInheritedAuthRequirements } from "./route-matching-DHduNiGk.js";
1
+ import { d as getCurrentAppRenderRuntime, f as getCurrentComponentInstance } from "./component-scope-DzJEbYGE.js";
2
+ import { i as getExecutionModel } from "./manifest-D1P9uTlz.js";
3
+ import { n as getActiveRenderContext, r as getCurrentRenderData } from "./render-context-D0Hoj9dW.js";
4
+ import { t as resource } from "./resource-operation-ys6eDoRJ.js";
5
+ import { A as getDefaultRouteBasePath, C as getCurrentInheritedPolicies, D as getCurrentPathPrefix, E as getCurrentPageScope, F as insertRecordSorted, H as computeRank, L as pushRegistrationScope, N as hasActivePageScope, O as getCurrentScopeKind, S as getCurrentInheritedMeta, T as getCurrentPageChain, U as normalizeRouteSegmentName, W as parseSegments, g as assertRouteRegistrationUnlocked, h as addRouteToStores, w as getCurrentLayoutChain, x as getCurrentInheritedAuthRequirements } from "./route-matching-DqULzZtC.js";
6
+ import { _ as createRouteHandler, d as DEFERRED_BOUNDARY, p as isDeferred, s as guardHydratedRouteData } from "./resolution-YHwi4Bav.js";
4
7
  import { allOf } from "@askrjs/auth";
5
8
  //#region src/router/access.ts
6
9
  function compileNodePolicies(node) {
@@ -200,4 +203,78 @@ function route(path, Component, options) {
200
203
  });
201
204
  }
202
205
  //#endregion
203
- export { route as a, page as i, group as n, index as r, fallback as t };
206
+ //#region src/router/deferred.tsx
207
+ function abortError() {
208
+ const error = /* @__PURE__ */ new Error("Deferred route data was aborted.");
209
+ error.name = "AbortError";
210
+ return error;
211
+ }
212
+ function awaitWithSignal(promise, signal) {
213
+ if (!signal) return promise;
214
+ if (signal.aborted) return Promise.reject(abortError());
215
+ return new Promise((resolve, reject) => {
216
+ const abort = () => reject(abortError());
217
+ signal.addEventListener("abort", abort, { once: true });
218
+ promise.then((value) => {
219
+ signal.removeEventListener("abort", abort);
220
+ resolve(value);
221
+ }, (error) => {
222
+ signal.removeEventListener("abort", abort);
223
+ reject(error);
224
+ });
225
+ });
226
+ }
227
+ async function resolveDeferredValues(input, signal) {
228
+ const seen = /* @__PURE__ */ new Set();
229
+ const visit = async (value) => {
230
+ if (!value || typeof value !== "object") return;
231
+ if (isDeferred(value)) {
232
+ const resolved = await awaitWithSignal(value.promise, signal);
233
+ await visit(resolved);
234
+ return;
235
+ }
236
+ if (seen.has(value)) return;
237
+ seen.add(value);
238
+ const children = Array.isArray(value) ? value : Object.values(value);
239
+ await Promise.all(children.map(visit));
240
+ };
241
+ await visit(input);
242
+ return input;
243
+ }
244
+ function routeData() {
245
+ const envelope = getCurrentRenderData();
246
+ if (envelope) return guardHydratedRouteData(envelope.route, envelope.framework);
247
+ const runtime = getCurrentAppRenderRuntime();
248
+ if (!runtime?.hasRoute) throw new Error("routeData() can only be read while rendering a route with loader data.");
249
+ return guardHydratedRouteData(runtime.route, runtime.framework);
250
+ }
251
+ function rejectedChild(props, error) {
252
+ return typeof props.rejected === "function" ? props.rejected(error) : props.rejected ?? null;
253
+ }
254
+ function Resolve(props) {
255
+ if (props.value.state === "fulfilled") return props.children(props.value.value);
256
+ if (props.value.state === "rejected") return rejectedChild(props, props.value.error);
257
+ const renderContext = getActiveRenderContext();
258
+ if (renderContext) {
259
+ const id = `d:${renderContext.deferredBoundaries.length}`;
260
+ renderContext.deferredBoundaries.push({
261
+ id,
262
+ promise: props.value.promise,
263
+ fulfilled: (value) => props.children(value),
264
+ rejected: (error) => rejectedChild(props, error)
265
+ });
266
+ return {
267
+ type: DEFERRED_BOUNDARY,
268
+ props: {
269
+ id,
270
+ pending: props.pending ?? null
271
+ }
272
+ };
273
+ }
274
+ const result = resource(() => props.value.promise, [props.value]);
275
+ if (result.error) return rejectedChild(props, result.error);
276
+ if (result.pending || result.value === null) return props.pending ?? null;
277
+ return props.children(result.value);
278
+ }
279
+ //#endregion
280
+ export { group as a, route as c, fallback as i, resolveDeferredValues as n, index as o, routeData as r, page as s, Resolve as t };
@@ -1,3 +1,3 @@
1
1
  import { r as JSXElement } from "../jsx-Dvr2SGRG.js";
2
- import { _ as Portal, c as Presence, d as SlotProps, g as DefaultPortal, h as layout, l as PresenceProps, m as LayoutComponent, u as Slot, v as PortalProps, y as definePortal } from "../index-Bkh9S9-t.js";
2
+ import { c as DefaultPortal, d as definePortal, f as Presence, h as SlotProps, l as Portal, m as Slot, p as PresenceProps, u as PortalProps, v as LayoutComponent, y as layout } from "../index-DflhL1h8.js";
3
3
  export { DefaultPortal, type JSXElement, type LayoutComponent, Portal, type PortalProps, Presence, type PresenceProps, Slot, type SlotProps, definePortal, layout };
@@ -1,3 +1,2 @@
1
- import { a as layout, i as Slot, r as Presence } from "../structures-DSLF_iis.js";
2
- import { i as definePortal, n as Portal, t as DefaultPortal } from "../portal-BVWjAhNQ.js";
1
+ import { a as definePortal, c as layout, i as Portal, o as Presence, r as DefaultPortal, s as Slot } from "../structures-DsOm-clq.js";
3
2
  export { DefaultPortal, Portal, Presence, Slot, definePortal, layout };
@@ -1,3 +1,3 @@
1
1
  import { r as JSXElement } from "../../jsx-Dvr2SGRG.js";
2
- import { _ as Portal, a as Collection, c as Presence, d as SlotProps, f as cloneElement, g as DefaultPortal, h as layout, i as createLayer, l as PresenceProps, m as LayoutComponent, n as LayerManager, o as CollectionItem, p as isElement, r as LayerOptions, s as createCollection, t as Layer, u as Slot, v as PortalProps, y as definePortal } from "../../index-Bkh9S9-t.js";
2
+ import { _ as isElement, a as Collection, c as DefaultPortal, d as definePortal, f as Presence, g as cloneElement, h as SlotProps, i as createLayer, l as Portal, m as Slot, n as LayerManager, o as CollectionItem, p as PresenceProps, r as LayerOptions, s as createCollection, t as Layer, u as PortalProps, v as LayoutComponent, y as layout } from "../../index-DflhL1h8.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, cloneElement, createCollection, createLayer, definePortal, isElement, layout };
@@ -1,3 +1,2 @@
1
- import { a as layout, i as Slot, n as createCollection, o as cloneElement, r as Presence, s as isElement, t as createLayer } from "../../structures-DSLF_iis.js";
2
- import { i as definePortal, n as Portal, t as DefaultPortal } from "../../portal-BVWjAhNQ.js";
1
+ import { a as definePortal, c as layout, i as Portal, l as cloneElement, n as createCollection, o as Presence, r as DefaultPortal, s as Slot, t as createLayer, u as isElement } from "../../structures-DsOm-clq.js";
3
2
  export { DefaultPortal, Portal, Presence, Slot, cloneElement, createCollection, createLayer, definePortal, isElement, layout };
@@ -1,20 +1,6 @@
1
1
  import { u as RenderableChild } from "./control-DhUZU4_V.js";
2
2
  import { r as JSXElement } from "./jsx-Dvr2SGRG.js";
3
3
  import "./types-C9YcqVpk.js";
4
- //#region src/runtime/portal.d.ts
5
- interface Portal<T extends RenderableChild = RenderableChild> {
6
- (): T | JSXElement | null | undefined;
7
- render(props: {
8
- children?: T;
9
- }): unknown;
10
- }
11
- interface PortalProps {
12
- children?: RenderableChild;
13
- }
14
- declare function definePortal<T extends RenderableChild = RenderableChild>(): Portal<T>;
15
- declare const DefaultPortal: Portal<RenderableChild>;
16
- declare function Portal(props: PortalProps): JSXElement | null;
17
- //#endregion
18
4
  //#region src/foundations/structures/layout.d.ts
19
5
  /**
20
6
  * Layout helper.
@@ -109,6 +95,20 @@ interface PresenceProps {
109
95
  */
110
96
  declare function Presence({ present, children }: PresenceProps): JSXElement | null;
111
97
  //#endregion
98
+ //#region src/runtime/portal.d.ts
99
+ interface Portal<T extends RenderableChild = RenderableChild> {
100
+ (): T | JSXElement | null | undefined;
101
+ render(props: {
102
+ children?: T;
103
+ }): unknown;
104
+ }
105
+ interface PortalProps {
106
+ children?: RenderableChild;
107
+ }
108
+ declare function definePortal<T extends RenderableChild = RenderableChild>(): Portal<T>;
109
+ declare const DefaultPortal: Portal<RenderableChild>;
110
+ declare function Portal(props: PortalProps): JSXElement | null;
111
+ //#endregion
112
112
  //#region src/foundations/structures/collection.d.ts
113
113
  /**
114
114
  * createCollection
@@ -280,4 +280,4 @@ declare function createLayer(): LayerManager;
280
280
  * }
281
281
  */
282
282
  //#endregion
283
- export { Portal as _, Collection as a, Presence as c, SlotProps as d, cloneElement as f, DefaultPortal as g, layout as h, createLayer as i, PresenceProps as l, LayoutComponent as m, LayerManager as n, CollectionItem as o, isElement as p, LayerOptions as r, createCollection as s, Layer as t, Slot as u, PortalProps as v, definePortal as y };
283
+ export { isElement as _, Collection as a, DefaultPortal as c, definePortal as d, Presence as f, cloneElement as g, SlotProps as h, createLayer as i, Portal as l, Slot as m, LayerManager as n, CollectionItem as o, PresenceProps as p, LayerOptions as r, createCollection as s, Layer as t, PortalProps as u, LayoutComponent as v, layout as y };
package/dist/index.js CHANGED
@@ -4,15 +4,15 @@ import { n as Fragment } from "./jsx-C3IECePB.js";
4
4
  import { g as readScope, u as defineScope } from "./component-internal-DcrLymUJ.js";
5
5
  import { f as syncDerivedDependencySubscriptions, l as notifyReadableReaders, o as markReactivePropsDirtySource, p as withDerivedReadTracking, r as clearDerivedDependencySubscriptions, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-B5NtV7V0.js";
6
6
  import { n as isSnapshotSource } from "./snapshot-source-BB42xgwb.js";
7
- import { t as installRendererBridge } from "./renderer-CZzNtoj2.js";
8
- import { a as registerSSRStyle } from "./render-context-D-DFk2WN.js";
7
+ import { t as installRendererBridge } from "./renderer-D9DL9R2D.js";
8
+ import { c as registerSSRStyle } from "./render-context-D0Hoj9dW.js";
9
9
  import { t as state } from "./state-DCjONcHK.js";
10
10
  import { t as selector } from "./selector-Ck_Pp9av.js";
11
11
  import { n as cspNonce, t as CspNonceScope } from "./csp-nonce-Bc52OIVc.js";
12
12
  import { i as For, n as Match, r as Show, t as Case } from "./control-oLADku43.js";
13
13
  import { jsx, jsxs } from "./jsx-runtime.js";
14
- import { t as createQuery } from "./data-Dkqb8_QP.js";
15
- import { a as hydrateDataRuntime, i as dehydrateDataRuntime, n as defineQuery, o as prefetchQuery, r as defineServerQueries, s as serveQuery } from "./query-registry-BL6rjGsO.js";
14
+ import { t as createQuery } from "./data-DGrD3-qA.js";
15
+ import { a as hydrateDataRuntime, i as dehydrateDataRuntime, n as defineQuery, o as prefetchQuery, r as defineServerQueries, s as serveQuery } from "./query-registry-CPW_6nwF.js";
16
16
  //#region src/runtime/derive.ts
17
17
  const deriveCells = /* @__PURE__ */ new WeakMap();
18
18
  const dirtyDerivedCells = /* @__PURE__ */ new Set();
@@ -0,0 +1,53 @@
1
+ import { A as getDefaultRouteBasePath, B as setDefaultRouteBasePath, F as insertRecordSorted, M as getRouteRecords, R as restoreRouteState, V as snapshotRouteState, _ as clearRouteState, h as addRouteToStores, j as getRouteList, k as getDefaultRouteAuthOptions, s as normalizeRouteBasePath, z as setDefaultRouteAuthOptions } from "./route-matching-DqULzZtC.js";
2
+ //#region src/runtime/execution-model.ts
3
+ const EXECUTION_MODEL_KEY = Symbol.for("__ASKR_EXECUTION_MODEL__");
4
+ function getExecutionModel() {
5
+ return globalThis[EXECUTION_MODEL_KEY];
6
+ }
7
+ function assertExecutionModel(model) {
8
+ const g = globalThis;
9
+ const cur = g[EXECUTION_MODEL_KEY];
10
+ 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.`);
11
+ if (!cur) g[EXECUTION_MODEL_KEY] = model;
12
+ }
13
+ //#endregion
14
+ //#region src/router/manifest.ts
15
+ function createRouteManifest() {
16
+ const auth = getDefaultRouteAuthOptions();
17
+ return {
18
+ records: [...getRouteRecords()],
19
+ ...auth ? { auth } : {},
20
+ ...getDefaultRouteBasePath() ? { basePath: getDefaultRouteBasePath() } : {}
21
+ };
22
+ }
23
+ function _applyManifest(manifest) {
24
+ setDefaultRouteAuthOptions(manifest.auth);
25
+ setDefaultRouteBasePath(normalizeRouteBasePath(manifest.basePath));
26
+ for (const record of manifest.records) {
27
+ insertRecordSorted(record);
28
+ addRouteToStores({
29
+ path: record.path,
30
+ handler: record.handler,
31
+ namespace: record.options.namespace,
32
+ ..."fallbackPrefix" in record && typeof record.fallbackPrefix === "string" ? { fallbackPrefix: record.fallbackPrefix } : {}
33
+ });
34
+ }
35
+ }
36
+ function createRouteRegistry(definition, options = {}) {
37
+ const previous = snapshotRouteState();
38
+ clearRouteState();
39
+ try {
40
+ setDefaultRouteAuthOptions(options.auth);
41
+ setDefaultRouteBasePath(normalizeRouteBasePath(options.basePath));
42
+ definition();
43
+ const manifest = createRouteManifest();
44
+ return Object.freeze({
45
+ manifest,
46
+ routes: getRouteList()
47
+ });
48
+ } finally {
49
+ restoreRouteState(previous);
50
+ }
51
+ }
52
+ //#endregion
53
+ export { getExecutionModel as i, createRouteRegistry as n, assertExecutionModel as r, _applyManifest as t };
@@ -5,11 +5,11 @@ import { t as cleanupReadableSubscriptionSources } from "./readable-B5NtV7V0.js"
5
5
  import { n as cleanupComponentGeneration, t as cleanupComponent } from "./component-cleanup-BUfUleGZ.js";
6
6
  import { i as drainLifecycleCommitErrors, p as isPromiseLike, r as discardLifecycleCommitBatch, s as flushLifecycleCommitBatch, t as beginLifecycleCommitBatch } from "./lifecycle-batch-Dfpid9-A.js";
7
7
  import { _ as teardownNodeSubtree } from "./cleanup-c837KVij.js";
8
- import { d as getRouteRenderContext, f as getRouteRenderData, m as resolveRouteRequest, p as hasRouteRenderData, v as withoutRouteHydrationMetadata } from "./deferred-vUOy-awa.js";
9
- import { I as lockRouteRegistration, o as addRouteBasePath, r as computeRouteActivityMatches, y as getActiveRouteBasePath } from "./route-matching-DHduNiGk.js";
10
- import { r as clearDefaultPortalForInstance, t as DefaultPortal } from "./portal-BVWjAhNQ.js";
11
8
  import { t as CspNonceScope } from "./csp-nonce-Bc52OIVc.js";
12
- import { a as clearStagedAppRenderRouteLocation, i as syncCurrentRouteSnapshot, o as createAppRenderRuntime, s as stageAppRenderRouteLocation } from "./activity-Jd9CgEa3.js";
9
+ import { I as lockRouteRegistration, o as addRouteBasePath, r as computeRouteActivityMatches, y as getActiveRouteBasePath } from "./route-matching-DqULzZtC.js";
10
+ import { a as resolveRouteRequest, i as hasRouteRenderData, n as getRouteRenderContext, r as getRouteRenderData, u as withoutRouteHydrationMetadata } from "./resolution-YHwi4Bav.js";
11
+ import { a as clearStagedAppRenderRouteLocation, i as syncCurrentRouteSnapshot, o as createAppRenderRuntime, s as stageAppRenderRouteLocation } from "./activity-BvgvaMZA.js";
12
+ import { r as getDefaultPortalHost, t as clearRegisteredDefaultPortalForInstance } from "./default-portal-runtime-DvMvWJVp.js";
13
13
  //#region src/router/navigation-registry.ts
14
14
  let currentInstance = null;
15
15
  let currentPathname = "/";
@@ -423,7 +423,7 @@ function wrapRootRouteHandler(componentFn, cspNonce) {
423
423
  if (isPromiseLike(out)) throw new Error("Async components are not supported. Components must return synchronously.");
424
424
  const portalVNode = {
425
425
  $$typeof: ELEMENT_TYPE,
426
- type: DefaultPortal,
426
+ type: getDefaultPortalHost(),
427
427
  props: { __askrAutoDefaultPortal: true },
428
428
  key: "__default_portal"
429
429
  };
@@ -671,7 +671,7 @@ function cleanupDeferredRouteInstance(deferred) {
671
671
  }
672
672
  function remountResolvedRoute(instance, resolved, pathname, href, existingSnapshot) {
673
673
  const deferredCleanup = existingSnapshot ?? captureDeferredRouteCleanup(instance);
674
- clearDefaultPortalForInstance(instance);
674
+ clearRegisteredDefaultPortalForInstance(instance);
675
675
  instance.fn = wrapRootRouteHandler(bindResolvedRouteHandler(resolved), instance._cspNonce);
676
676
  instance.props = {};
677
677
  instance._ownershipGeneration = {};
@@ -1,4 +1,4 @@
1
- import { i as getDefaultDataRuntime, t as createDataRuntime } from "./data-runtime-D68YOo9L.js";
1
+ import { i as getDefaultDataRuntime, t as createDataRuntime } from "./data-runtime-Ck3tJDDQ.js";
2
2
  //#region src/common/telemetry.ts
3
3
  function withTelemetry(span, fields, work) {
4
4
  return span ? span(fields, work) : work();
@@ -0,0 +1,161 @@
1
+ //#region src/common/ssr-errors.ts
2
+ /**
3
+ * Common call contracts: SSR error types
4
+ */
5
+ var SSRDataMissingError = class SSRDataMissingError extends Error {
6
+ constructor(message = "Server-side rendering requires all data to be available synchronously. This component attempted to use async data during SSR.") {
7
+ super(message);
8
+ this.code = "SSR_DATA_MISSING";
9
+ this.name = "SSRDataMissingError";
10
+ Object.setPrototypeOf(this, SSRDataMissingError.prototype);
11
+ }
12
+ };
13
+ //#endregion
14
+ //#region src/common/page-render-envelope.ts
15
+ const PAGE_RENDER_ENVELOPE_VERSION = 1;
16
+ function ownedRecord(value) {
17
+ return Object.freeze({ ...value });
18
+ }
19
+ function createPageRenderEnvelope(input = {}) {
20
+ return Object.freeze({
21
+ version: PAGE_RENDER_ENVELOPE_VERSION,
22
+ resources: ownedRecord(input.resources),
23
+ route: input.route,
24
+ framework: ownedRecord(input.framework)
25
+ });
26
+ }
27
+ function isPageRenderEnvelope(value) {
28
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
29
+ const candidate = value;
30
+ return candidate.version === PAGE_RENDER_ENVELOPE_VERSION && Boolean(candidate.resources && typeof candidate.resources === "object" && !Array.isArray(candidate.resources)) && Boolean(candidate.framework && typeof candidate.framework === "object" && !Array.isArray(candidate.framework));
31
+ }
32
+ function pageRenderEnvelope(value, fallback = {}) {
33
+ if (isPageRenderEnvelope(value)) return value;
34
+ return createPageRenderEnvelope({
35
+ ...fallback,
36
+ route: value ?? fallback.route
37
+ });
38
+ }
39
+ function replacePageRoute(value, route) {
40
+ const current = pageRenderEnvelope(value);
41
+ return createPageRenderEnvelope({
42
+ resources: current.resources,
43
+ route,
44
+ framework: current.framework
45
+ });
46
+ }
47
+ function withPageFramework(value, framework) {
48
+ const current = pageRenderEnvelope(value);
49
+ return createPageRenderEnvelope({
50
+ resources: current.resources,
51
+ route: current.route,
52
+ framework
53
+ });
54
+ }
55
+ function isEmptyPageRenderEnvelope(value) {
56
+ return value.route === void 0 && Object.keys(value.resources).length === 0 && Object.keys(value.framework).length === 0;
57
+ }
58
+ //#endregion
59
+ //#region src/common/render-context.ts
60
+ let provider = { getRenderContext() {
61
+ return null;
62
+ } };
63
+ let hydrationRenderData = null;
64
+ let hydrationKeyCounter = 0;
65
+ let hydrationVerificationDepth = 0;
66
+ const RESOURCE_VERIFICATION_SNAPSHOTS = "rv";
67
+ function configureRenderContextProvider(nextProvider) {
68
+ provider = nextProvider;
69
+ }
70
+ function getActiveRenderContext() {
71
+ return provider.getRenderContext();
72
+ }
73
+ /** Register request-local CSS produced during SSR without importing the SSR renderer in clients. */
74
+ function registerSSRStyle(id, cssText) {
75
+ const context = getActiveRenderContext();
76
+ if (!context?.ssrStyles) return;
77
+ const safeCssText = cssText.replace(/<\/style/gi, "<\\/style");
78
+ const existing = context.ssrStyles.get(id);
79
+ if (existing && existing.cssText !== safeCssText) throw new RangeError(`SSR style registration collision for ${JSON.stringify(id)}.`);
80
+ context.ssrStyles.set(id, {
81
+ id,
82
+ cssText: safeCssText
83
+ });
84
+ }
85
+ function getCurrentRenderData() {
86
+ return getActiveRenderContext()?.renderData ?? hydrationRenderData;
87
+ }
88
+ function getNextRenderKey() {
89
+ const ctx = getActiveRenderContext();
90
+ if (ctx) return `r:${ctx.keyCounter++}`;
91
+ if (hydrationRenderData) return `r:${hydrationKeyCounter++}`;
92
+ return "r:0";
93
+ }
94
+ function startHydrationRenderPhase(data) {
95
+ hydrationRenderData = data;
96
+ hydrationKeyCounter = 0;
97
+ }
98
+ function stopHydrationRenderPhase() {
99
+ hydrationRenderData = null;
100
+ hydrationKeyCounter = 0;
101
+ }
102
+ /** @internal Run one synchronous client-side markup verification pass. */
103
+ function withHydrationVerificationRender(fn) {
104
+ hydrationVerificationDepth += 1;
105
+ try {
106
+ return fn();
107
+ } finally {
108
+ hydrationVerificationDepth -= 1;
109
+ }
110
+ }
111
+ /** @internal Whether resources should reflect their server pending snapshot. */
112
+ function isHydrationVerificationRender() {
113
+ return hydrationVerificationDepth > 0;
114
+ }
115
+ /** @internal Read a server-captured resource branch without invoking its loader. */
116
+ function getResourceVerificationSnapshot(key) {
117
+ const snapshots = getCurrentRenderData()?.framework[RESOURCE_VERIFICATION_SNAPSHOTS];
118
+ if (!snapshots || typeof snapshots !== "object" || Array.isArray(snapshots)) return null;
119
+ if (!Object.prototype.hasOwnProperty.call(snapshots, key)) return null;
120
+ const snapshot = snapshots[key];
121
+ if (!snapshot || typeof snapshot !== "object" || Array.isArray(snapshot)) return null;
122
+ const candidate = snapshot;
123
+ return typeof candidate.pending === "boolean" ? {
124
+ value: candidate.value,
125
+ pending: candidate.pending
126
+ } : null;
127
+ }
128
+ /** @internal Preserve a JSON-safe server branch solely for markup verification. */
129
+ function recordResourceVerificationSnapshot(key, snapshot) {
130
+ const ctx = getActiveRenderContext();
131
+ const envelope = ctx?.hydrationData;
132
+ if (!ctx || !envelope) return;
133
+ const current = envelope.framework[RESOURCE_VERIFICATION_SNAPSHOTS];
134
+ const snapshots = current && typeof current === "object" && !Array.isArray(current) ? current : {};
135
+ ctx.hydrationData = withPageFramework(envelope, {
136
+ ...envelope.framework,
137
+ [RESOURCE_VERIFICATION_SNAPSHOTS]: {
138
+ ...snapshots,
139
+ [key]: snapshot
140
+ }
141
+ });
142
+ }
143
+ function startRenderPhase(data) {
144
+ const ctx = getActiveRenderContext();
145
+ if (ctx) {
146
+ ctx.renderData = data ?? null;
147
+ ctx.keyCounter = 0;
148
+ }
149
+ }
150
+ function stopRenderPhase() {
151
+ const ctx = getActiveRenderContext();
152
+ if (ctx) {
153
+ ctx.renderData = null;
154
+ ctx.keyCounter = 0;
155
+ }
156
+ }
157
+ function throwSSRDataMissing() {
158
+ throw new SSRDataMissingError();
159
+ }
160
+ //#endregion
161
+ export { isPageRenderEnvelope as _, getResourceVerificationSnapshot as a, withPageFramework as b, registerSSRStyle as c, stopHydrationRenderPhase as d, stopRenderPhase as f, isEmptyPageRenderEnvelope as g, createPageRenderEnvelope as h, getNextRenderKey as i, startHydrationRenderPhase as l, withHydrationVerificationRender as m, getActiveRenderContext as n, isHydrationVerificationRender as o, throwSSRDataMissing as p, getCurrentRenderData as r, recordResourceVerificationSnapshot as s, configureRenderContextProvider as t, startRenderPhase as u, pageRenderEnvelope as v, SSRDataMissingError as x, replacePageRoute as y };