@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,278 +1,4 @@
1
- import { t as enqueueRuntimeLane, v as logger } from "./access-Dpfoi4cA.js";
2
- import { f as getCurrentComponentInstance } from "./component-scope-DzJEbYGE.js";
3
- import { c as registerCommitOperationForInstance, d as getCurrentContextFrame, v as withAsyncResourceContext } from "./component-internal-DcrLymUJ.js";
4
- import { p as isPromiseLike } from "./lifecycle-batch-Dfpid9-A.js";
5
- import { t as brandSnapshotSource } from "./snapshot-source-BB42xgwb.js";
6
- import { d as SSRDataMissingError, i as getNextRenderKey, n as getActiveRenderContext, r as getCurrentRenderData, u as throwSSRDataMissing } from "./render-context-D-DFk2WN.js";
7
- import { t as state } from "./state-DCjONcHK.js";
8
- //#region src/runtime/resource-cell.ts
9
- /**
10
- * Pure, component-agnostic ResourceCell state machine.
11
- * - Holds value/pending/error/generation/controller
12
- * - Exposes a stable `snapshot` object: { value, pending, error, refresh }
13
- * - Uses `withAsyncResourceContext` to bind the synchronous execution step
14
- * to a captured frame. Continuations after await do not see the frame.
15
- */
16
- var ResourceCell = class {
17
- constructor(fn, deps, resourceFrame) {
18
- this.value = null;
19
- this.pending = true;
20
- this.error = null;
21
- this.generation = 0;
22
- this.controller = null;
23
- this.deps = null;
24
- this.resourceFrame = null;
25
- this.subscribers = /* @__PURE__ */ new Set();
26
- this.disposed = false;
27
- this.fn = fn;
28
- this.deps = deps ? deps.slice() : null;
29
- this.resourceFrame = resourceFrame;
30
- this.snapshot = brandSnapshotSource({
31
- value: null,
32
- pending: true,
33
- error: null,
34
- refresh: () => this.refresh()
35
- });
36
- }
37
- setLoader(fn) {
38
- this.fn = fn;
39
- }
40
- subscribe(cb) {
41
- this.subscribers.add(cb);
42
- return () => this.subscribers.delete(cb);
43
- }
44
- notifySubscribers() {
45
- this.snapshot.value = this.value;
46
- this.snapshot.pending = this.pending;
47
- this.snapshot.error = this.error;
48
- for (const cb of this.subscribers) cb();
49
- }
50
- start(ssr = false, notify = true) {
51
- if (this.disposed) return;
52
- const generation = this.generation;
53
- this.controller?.abort();
54
- const controller = new AbortController();
55
- this.controller = controller;
56
- this.pending = true;
57
- this.error = null;
58
- if (notify) this.notifySubscribers();
59
- let result;
60
- try {
61
- result = withAsyncResourceContext(this.resourceFrame, () => this.fn({ signal: controller.signal }));
62
- } catch (err) {
63
- this.pending = false;
64
- this.error = err instanceof Error ? err : new Error(String(err));
65
- if (notify) this.notifySubscribers();
66
- return;
67
- }
68
- if (!isPromiseLike(result)) {
69
- this.value = result;
70
- this.pending = false;
71
- this.error = null;
72
- if (notify) this.notifySubscribers();
73
- return;
74
- }
75
- if (ssr) throwSSRDataMissing();
76
- Promise.resolve(result).then((val) => {
77
- if (this.generation !== generation) return;
78
- if (this.controller !== controller) return;
79
- if (controller.signal.aborted) return;
80
- this.value = val;
81
- this.pending = false;
82
- this.error = null;
83
- this.notifySubscribers();
84
- }).catch((err) => {
85
- if (this.generation !== generation) return;
86
- if (this.controller !== controller) return;
87
- if (controller.signal.aborted || err instanceof Error && err.name === "AbortError" || typeof DOMException !== "undefined" && err instanceof DOMException && err.name === "AbortError") return;
88
- this.pending = false;
89
- this.error = err instanceof Error ? err : new Error(String(err));
90
- try {
91
- if (this.ownerName) logger.error(`[Askr] Async resource error in ${this.ownerName}:`, err);
92
- else logger.error("[Askr] Async resource error:", err);
93
- } catch {}
94
- this.notifySubscribers();
95
- });
96
- }
97
- refresh() {
98
- if (this.disposed) return;
99
- this.generation++;
100
- this.controller?.abort();
101
- this.start();
102
- }
103
- abort() {
104
- this.controller?.abort();
105
- }
106
- dispose() {
107
- if (this.disposed) return;
108
- this.disposed = true;
109
- this.controller?.abort();
110
- this.subscribers.clear();
111
- }
112
- };
113
- //#endregion
114
- //#region src/runtime/resource-operation.ts
115
- /**
116
- * Resource primitive — simple, deterministic async primitive
117
- * Usage: resource(fn, deps)
118
- * - fn receives { signal }
119
- * - captures execution context once at creation (synchronous step only)
120
- * - executes at most once per generation; stale async results are ignored
121
- * - refresh() cancels in-flight execution, increments generation and re-runs
122
- * - exposes { value, pending, error, refresh }
123
- * - during SSR, async results are disallowed and will throw synchronously
124
- */
125
- function resource(fn, deps = []) {
126
- const instance = getCurrentComponentInstance();
127
- const inst = instance;
128
- if (!instance) {
129
- const renderData = getCurrentRenderData()?.resources;
130
- if (renderData && (getActiveRenderContext()?.resourceDataProvided || Object.keys(renderData).some((key) => key.startsWith("r:")))) {
131
- const key = getNextRenderKey();
132
- if (!(key in renderData)) throwSSRDataMissing();
133
- const val = renderData[key];
134
- return brandSnapshotSource({
135
- value: val,
136
- pending: false,
137
- error: null,
138
- refresh: () => {}
139
- });
140
- }
141
- if (getActiveRenderContext()) throwSSRDataMissing();
142
- throw new Error("[Askr] resource() must be called during component render inside an app. Do not create resources at module scope or outside render.");
143
- }
144
- const renderData = getCurrentRenderData()?.resources;
145
- if (renderData && (getActiveRenderContext()?.resourceDataProvided || Object.keys(renderData).some((key) => key.startsWith("r:")))) {
146
- const key = getNextRenderKey();
147
- if (!(key in renderData)) throwSSRDataMissing();
148
- const val = renderData[key];
149
- const h = state({
150
- cell: void 0,
151
- snapshot: brandSnapshotSource({
152
- value: val,
153
- pending: false,
154
- error: null,
155
- refresh: () => {}
156
- })
157
- })();
158
- h.snapshot.value = val;
159
- h.snapshot.pending = false;
160
- h.snapshot.error = null;
161
- return h.snapshot;
162
- }
163
- const holder = state({
164
- cell: void 0,
165
- snapshot: brandSnapshotSource({
166
- value: null,
167
- pending: true,
168
- error: null,
169
- refresh: () => {}
170
- })
171
- });
172
- const h = holder();
173
- if (!h.cell) {
174
- const cell = new ResourceCell(fn, deps, getCurrentContextFrame());
175
- cell.ownerName = inst.fn?.name || "<anonymous>";
176
- h.cell = cell;
177
- h.snapshot = cell.snapshot;
178
- const unsubscribe = cell.subscribe(() => {
179
- const cur = holder();
180
- cur.snapshot.value = cell.snapshot.value;
181
- cur.snapshot.pending = cell.snapshot.pending;
182
- cur.snapshot.error = cell.snapshot.error;
183
- holder.set(cur);
184
- try {
185
- inst.notifyUpdate?.();
186
- } catch {}
187
- });
188
- (inst.cleanupFns ??= []).push(() => {
189
- unsubscribe();
190
- cell.dispose();
191
- });
192
- if (inst.ssr) {
193
- cell.start(true, false);
194
- if (!cell.pending) {
195
- const cur = holder();
196
- cur.snapshot.value = cell.value;
197
- cur.snapshot.pending = cell.pending;
198
- cur.snapshot.error = cell.error;
199
- }
200
- } else {
201
- const scheduledGeneration = cell.generation;
202
- registerCommitOperationForInstance(inst, () => {
203
- enqueueRuntimeLane("post", () => {
204
- if (!inst.notifyUpdate || cell.generation !== scheduledGeneration) return;
205
- try {
206
- cell.start(false, false);
207
- } catch (err) {
208
- const cur = holder();
209
- cur.snapshot.value = cell.value;
210
- cur.snapshot.pending = cell.pending;
211
- cur.snapshot.error = err ?? null;
212
- holder.set(cur);
213
- inst.notifyUpdate?.();
214
- return;
215
- }
216
- if (!cell.pending) {
217
- const cur = holder();
218
- cur.snapshot.value = cell.value;
219
- cur.snapshot.pending = cell.pending;
220
- cur.snapshot.error = cell.error;
221
- holder.set(cur);
222
- inst.notifyUpdate?.();
223
- }
224
- });
225
- });
226
- }
227
- }
228
- const cell = h.cell;
229
- cell.setLoader(fn);
230
- if (!cell.deps || cell.deps.length !== deps.length || cell.deps.some((d, i) => !Object.is(d, deps[i]))) {
231
- cell.deps = deps.slice();
232
- cell.generation++;
233
- cell.pending = true;
234
- cell.error = null;
235
- h.snapshot.pending = true;
236
- h.snapshot.error = null;
237
- try {
238
- if (inst.ssr) {
239
- cell.start(true, false);
240
- if (!cell.pending) {
241
- const cur = holder();
242
- cur.snapshot.value = cell.value;
243
- cur.snapshot.pending = cell.pending;
244
- cur.snapshot.error = cell.error;
245
- }
246
- } else {
247
- const scheduledGeneration = cell.generation;
248
- registerCommitOperationForInstance(inst, () => {
249
- enqueueRuntimeLane("post", () => {
250
- if (!inst.notifyUpdate || cell.generation !== scheduledGeneration) return;
251
- cell.start(false, false);
252
- if (!cell.pending) {
253
- const cur = holder();
254
- cur.snapshot.value = cell.value;
255
- cur.snapshot.pending = cell.pending;
256
- cur.snapshot.error = cell.error;
257
- holder.set(cur);
258
- inst.notifyUpdate?.();
259
- }
260
- });
261
- });
262
- }
263
- } catch (err) {
264
- if (err instanceof SSRDataMissingError) throw err;
265
- cell.error = err;
266
- cell.pending = false;
267
- const cur = holder();
268
- cur.snapshot.value = cell.value;
269
- cur.snapshot.pending = cell.pending;
270
- cur.snapshot.error = cell.error;
271
- }
272
- }
273
- return h.snapshot;
274
- }
275
- //#endregion
1
+ import { n as getActiveRenderContext } from "./render-context-D0Hoj9dW.js";
276
2
  //#region src/router/match.ts
277
3
  function splitPathSegments(path) {
278
4
  const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
@@ -827,4 +553,4 @@ function _resolveRouteMatchFromRoutes(pathname, routeList) {
827
553
  return findBestResolvedRouteFromRoutes(pathname, routeList);
828
554
  }
829
555
  //#endregion
830
- export { getDefaultRouteBasePath as A, setDefaultRouteBasePath as B, getCurrentInheritedPolicies as C, getCurrentPathPrefix as D, getCurrentPageScope as E, insertRecordSorted as F, resource as G, computeRank as H, lockRouteRegistration as I, pushRegistrationScope as L, getRouteRecords as M, hasActivePageScope as N, getCurrentScopeKind as O, hasRegisteredRoutes as P, restoreRouteState as R, getCurrentInheritedMeta as S, getCurrentPageChain as T, normalizeRouteSegmentName as U, snapshotRouteState as V, parseSegments as W, clearRouteState as _, resolveRouteFromRoutes as a, getActiveRoutes as b, removeRouteBasePath as c, deepFreeze as d, makeQuery as f, assertRouteRegistrationUnlocked as g, addRouteToStores as h, getMatchingRouteRecord as i, getRouteList as j, getDefaultRouteAuthOptions as k, buildRouteContext as l, _setActiveRouteAuthOptions as m, computeMatchesFromRoutes as n, addRouteBasePath as o, parseLocation as p, computeRouteActivityMatches as r, normalizeRouteBasePath as s, _resolveRouteMatchFromRoutes as t, buildRouteContextBase as u, getActiveRouteAuthOptions as v, getCurrentLayoutChain as w, getCurrentInheritedAuthRequirements as x, getActiveRouteBasePath as y, setDefaultRouteAuthOptions as z };
556
+ export { getDefaultRouteBasePath as A, setDefaultRouteBasePath as B, getCurrentInheritedPolicies as C, getCurrentPathPrefix as D, getCurrentPageScope as E, insertRecordSorted as F, computeRank as H, lockRouteRegistration as I, pushRegistrationScope as L, getRouteRecords as M, hasActivePageScope as N, getCurrentScopeKind as O, hasRegisteredRoutes as P, restoreRouteState as R, getCurrentInheritedMeta as S, getCurrentPageChain as T, normalizeRouteSegmentName as U, snapshotRouteState as V, parseSegments as W, clearRouteState as _, resolveRouteFromRoutes as a, getActiveRoutes as b, removeRouteBasePath as c, deepFreeze as d, makeQuery as f, assertRouteRegistrationUnlocked as g, addRouteToStores as h, getMatchingRouteRecord as i, getRouteList as j, getDefaultRouteAuthOptions as k, buildRouteContext as l, _setActiveRouteAuthOptions as m, computeMatchesFromRoutes as n, addRouteBasePath as o, parseLocation as p, computeRouteActivityMatches as r, normalizeRouteBasePath as s, _resolveRouteMatchFromRoutes as t, buildRouteContextBase as u, getActiveRouteAuthOptions as v, getCurrentLayoutChain as w, getCurrentInheritedAuthRequirements as x, getActiveRouteBasePath as y, setDefaultRouteAuthOptions as z };
@@ -81,7 +81,7 @@ declare function resolveRouteMeta(record: RouteRecord, context: RouteContext): P
81
81
  declare function reconcileRouteMeta(meta: Readonly<RouteMeta>, target?: Document): void;
82
82
  declare function serializeRouteMeta(meta: RouteMeta): string;
83
83
  //#endregion
84
- //#region src/router/deferred.d.ts
84
+ //#region src/common/deferred-value.d.ts
85
85
  declare const DEFERRED_VALUE: unique symbol;
86
86
  type DeferredState = 'pending' | 'fulfilled' | 'rejected';
87
87
  interface Deferred<T> {
@@ -91,14 +91,16 @@ interface Deferred<T> {
91
91
  readonly promise: Promise<T>;
92
92
  readonly [DEFERRED_VALUE]: true;
93
93
  }
94
+ declare function defer<T>(promise: PromiseLike<T>): Deferred<T>;
95
+ declare function isDeferred<T = unknown>(value: unknown): value is Deferred<T>;
96
+ //#endregion
97
+ //#region src/router/deferred.d.ts
94
98
  interface ResolveProps<T> {
95
99
  value: Deferred<T>;
96
100
  pending?: RenderableChild;
97
101
  rejected?: RenderableChild | ((error: unknown) => RenderableChild);
98
102
  children: (value: T) => RenderableChild;
99
103
  }
100
- declare function defer<T>(promise: PromiseLike<T>): Deferred<T>;
101
- declare function isDeferred<T = unknown>(value: unknown): value is Deferred<T>;
102
104
  declare function resolveDeferredValues<T>(input: T, signal?: AbortSignal): Promise<T>;
103
105
  declare function routeData<T>(): T;
104
106
  declare function Resolve<T>(props: ResolveProps<T>): JSXElement;
@@ -1,10 +1,11 @@
1
- import { C as currentAuth, O as lazy, a as resolveDeferredValues, i as isDeferred, l as createRouteRegistry, m as resolveRouteRequest, n as Resolve, r as defer, s as routeData, w as Outlet } from "../deferred-vUOy-awa.js";
2
- import { o as addRouteBasePath, y as getActiveRouteBasePath } from "../route-matching-DHduNiGk.js";
1
+ import { n as createRouteRegistry } from "../manifest-D1P9uTlz.js";
3
2
  import { a as isSafeHref } from "../csp-nonce-Bc52OIVc.js";
4
3
  import { jsx } from "../jsx-runtime.js";
5
- import { a as route, i as page, n as group, r as index, t as fallback } from "../authoring-DdQ3pHqt.js";
6
- import { n as onRouteChange, t as currentRoute } from "../activity-Jd9CgEa3.js";
7
- import { a as serializeRouteMeta, c as getCurrentHref, d as parseTargetUrl, h as syncRegisteredRouteSnapshot, i as resolveRouteMeta, l as getRegisteredAppsSnapshot, m as syncAppRegistrationLocation, n as navigate, p as setCurrentRouteLocation, r as reconcileRouteMeta, s as saveScrollPosition, u as getWindowHref } from "../navigate-b4GGxO_l.js";
4
+ import { o as addRouteBasePath, y as getActiveRouteBasePath } from "../route-matching-DqULzZtC.js";
5
+ import { a as group, c as route, i as fallback, n as resolveDeferredValues, o as index, r as routeData, s as page, t as Resolve } from "../deferred-nleQtdfY.js";
6
+ import { a as resolveRouteRequest, b as lazy, f as defer, g as Outlet, h as currentAuth, p as isDeferred } from "../resolution-YHwi4Bav.js";
7
+ import { n as onRouteChange, t as currentRoute } from "../activity-BvgvaMZA.js";
8
+ import { a as serializeRouteMeta, c as getCurrentHref, d as parseTargetUrl, h as syncRegisteredRouteSnapshot, i as resolveRouteMeta, l as getRegisteredAppsSnapshot, m as syncAppRegistrationLocation, n as navigate, p as setCurrentRouteLocation, r as reconcileRouteMeta, s as saveScrollPosition, u as getWindowHref } from "../navigate-BwAPbpCb.js";
8
9
  import { o as mergeProps } from "../compose-ref-Cc_YkUpM.js";
9
10
  import { t as applyInteractionPolicy } from "../interactions-DgGQyUQv.js";
10
11
  //#region src/router/route-query.ts
package/dist/ssg/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import "../access-Dpfoi4cA.js";
2
- import { D as _preloadRouteHandler, E as getRenderHandler, a as resolveDeferredValues, g as prepareRouteHydrationData, l as createRouteRegistry, u as bindResolvedRouteData } from "../deferred-vUOy-awa.js";
3
- import { o as addRouteBasePath } from "../route-matching-DHduNiGk.js";
4
- import { a as route } from "../authoring-DdQ3pHqt.js";
2
+ import { n as createRouteRegistry } from "../manifest-D1P9uTlz.js";
3
+ import { o as addRouteBasePath } from "../route-matching-DqULzZtC.js";
4
+ import { c as route, n as resolveDeferredValues } from "../deferred-nleQtdfY.js";
5
+ import { c as prepareRouteHydrationData, t as bindResolvedRouteData, v as getRenderHandler, y as _preloadRouteHandler } from "../resolution-YHwi4Bav.js";
5
6
  import { n as renderDocument } from "../ssr-DSHd_Q9K.js";
6
- import { n as renderToString } from "../ssr-CpiBHMNv.js";
7
+ import { n as renderToString } from "../ssr-B98593qJ.js";
7
8
  import * as fs from "node:fs/promises";
8
9
  import * as pathModule from "node:path";
9
10
  import * as os from "node:os";
package/dist/ssr/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { d as SSRDataMissingError } from "../render-context-D-DFk2WN.js";
2
- import { a as renderResolvedToStringSync, c as createRenderContext, d as withRenderContextAsync, i as renderRouteRequestToString, l as getRenderContext, n as renderToString, o as renderToStringSync, r as renderRouteRequest, s as resolveRequest, t as renderToStream, u as withRenderContext } from "../ssr-CpiBHMNv.js";
1
+ import { x as SSRDataMissingError } from "../render-context-D0Hoj9dW.js";
2
+ import { a as renderResolvedToStringSync, c as createRenderContext, d as withRenderContextAsync, i as renderRouteRequestToString, l as getRenderContext, n as renderToString, o as renderToStringSync, r as renderRouteRequest, s as resolveRequest, t as renderToStream, u as withRenderContext } from "../ssr-B98593qJ.js";
3
3
  export { SSRDataMissingError, createRenderContext, getRenderContext, renderResolvedToStringSync, renderRouteRequest, renderRouteRequestToString, renderToStream, renderToString, renderToStringSync, resolveRequest, withRenderContext, withRenderContextAsync };
@@ -7,16 +7,15 @@ import { f as getExecutionContextFrame, h as markVNodeTreeWithContextFrame, l as
7
7
  import { t as cleanupComponent } from "./component-cleanup-BUfUleGZ.js";
8
8
  import { p as isPromiseLike } from "./lifecycle-batch-Dfpid9-A.js";
9
9
  import { _ as setControlBoundaryContextFrame, g as evaluateShowState, h as evaluateCaseState, i as evaluateForState, o as rollbackForStateTransaction, r as commitForStateTransaction } from "./for-internal-B_mnQhan.js";
10
- import { _ as validateRouteHydrationData, b as isEmptyPageRenderEnvelope, h as getRouteHydrationMetadata, i as isDeferred, l as createRouteRegistry, m as resolveRouteRequest, t as DEFERRED_BOUNDARY, x as isPageRenderEnvelope, y as createPageRenderEnvelope } from "./deferred-vUOy-awa.js";
11
- import { d as SSRDataMissingError, l as stopRenderPhase$1, s as startRenderPhase$1, t as configureRenderContextProvider } from "./render-context-D-DFk2WN.js";
12
- import { a as resolveRouteFromRoutes, c as removeRouteBasePath, s as normalizeRouteBasePath, t as _resolveRouteMatchFromRoutes } from "./route-matching-DHduNiGk.js";
13
- import { n as SSR_PORTAL_HOST, t as SSR_PORTAL_ANCHOR } from "./portal-w3oQ6oQU.js";
14
- import { a as disposeDefaultPortalScope, t as DefaultPortal } from "./portal-BVWjAhNQ.js";
10
+ import { _ as isPageRenderEnvelope, f as stopRenderPhase$1, g as isEmptyPageRenderEnvelope, h as createPageRenderEnvelope, t as configureRenderContextProvider, u as startRenderPhase$1, x as SSRDataMissingError } from "./render-context-D0Hoj9dW.js";
15
11
  import { n as getPublicAttributeName, t as sanitizeCssValue } from "./css-BuPaTOfe.js";
16
12
  import { o as isUnsafeUrlAttribute, r as validateCspNonce, t as CspNonceScope } from "./csp-nonce-Bc52OIVc.js";
17
- import { t as createDataRuntime } from "./data-runtime-D68YOo9L.js";
18
- import { c as withTelemetry, i as dehydrateDataRuntime, t as createQueryPrefetchContext } from "./query-registry-BL6rjGsO.js";
19
- import { a as route } from "./authoring-DdQ3pHqt.js";
13
+ import { n as SSR_PORTAL_HOST, t as SSR_PORTAL_ANCHOR } from "./portal-w3oQ6oQU.js";
14
+ import { t as createDataRuntime } from "./data-runtime-Ck3tJDDQ.js";
15
+ import { c as withTelemetry, i as dehydrateDataRuntime, t as createQueryPrefetchContext } from "./query-registry-CPW_6nwF.js";
16
+ import { a as resolveRouteFromRoutes, c as removeRouteBasePath, s as normalizeRouteBasePath, t as _resolveRouteMatchFromRoutes } from "./route-matching-DqULzZtC.js";
17
+ import { a as resolveRouteRequest, d as DEFERRED_BOUNDARY, l as validateRouteHydrationData, o as getRouteHydrationMetadata, p as isDeferred } from "./resolution-YHwi4Bav.js";
18
+ import { n as disposeRegisteredDefaultPortalScope, r as getDefaultPortalHost } from "./default-portal-runtime-DvMvWJVp.js";
20
19
  import { n as renderDocument, t as SSR_RENDER_DATA_ATTR } from "./ssr-DSHd_Q9K.js";
21
20
  //#region src/ssr/escape.ts
22
21
  /**
@@ -556,7 +555,7 @@ function executeComponentSync(component, props, ctx, ownerFrame = null) {
556
555
  cleanupError = error;
557
556
  }
558
557
  try {
559
- disposeDefaultPortalScope(temp);
558
+ disposeRegisteredDefaultPortalScope(temp);
560
559
  } catch (error) {
561
560
  if (cleanupError) throw new AggregateError([cleanupError, error], "SSR temporary owner cleanup failed");
562
561
  throw error;
@@ -597,7 +596,7 @@ function wrapWithDefaultPortal(out) {
597
596
  if (isPromiseLike(out)) throwSSRDataMissing();
598
597
  const portalVNode = {
599
598
  $$typeof: ELEMENT_TYPE,
600
- type: DefaultPortal,
599
+ type: getDefaultPortalHost(),
601
600
  props: { __askrAutoDefaultPortal: true },
602
601
  key: "__default_portal"
603
602
  };
@@ -1258,11 +1257,27 @@ function renderResolvedToStringSync(opts) {
1258
1257
  ...route,
1259
1258
  handler
1260
1259
  } : route);
1260
+ const matchedRoute = routes[matchedIndex];
1261
1261
  return renderToString({
1262
1262
  url,
1263
- registry: createRouteRegistry(() => {
1264
- for (const route$1 of effectiveRoutes) route(route$1.path, route$1.handler, { namespace: route$1.namespace });
1265
- }),
1263
+ registry: {
1264
+ manifest: {
1265
+ records: registry.manifest.records.map((record) => {
1266
+ const effectiveHandler = record.path === matchedRoute.path && record.handler === matchedRoute.handler && record.options.namespace === matchedRoute.namespace ? handler : record.handler;
1267
+ return {
1268
+ ...record,
1269
+ component: effectiveHandler,
1270
+ handler: effectiveHandler,
1271
+ layoutChain: [],
1272
+ pageChain: [],
1273
+ options: record.options.namespace ? { namespace: record.options.namespace } : {},
1274
+ metaChain: void 0
1275
+ };
1276
+ }),
1277
+ ...registry.manifest.basePath ? { basePath: registry.manifest.basePath } : {}
1278
+ },
1279
+ routes: effectiveRoutes
1280
+ },
1266
1281
  seed: options?.seed,
1267
1282
  data: options?.data,
1268
1283
  dataRuntime: options?.dataRuntime,
@@ -1,11 +1,107 @@
1
1
  import { o as getRuntimeRenderer } from "./access-Dpfoi4cA.js";
2
2
  import { f as getCurrentComponentInstance, m as getCurrentPortalScope } from "./component-scope-DzJEbYGE.js";
3
- import { t as ELEMENT_TYPE } from "./jsx-C3IECePB.js";
3
+ import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-C3IECePB.js";
4
4
  import { l as notifyReadableReaders, o as markReactivePropsDirtySource, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-B5NtV7V0.js";
5
5
  import { t as cleanupComponent } from "./component-cleanup-BUfUleGZ.js";
6
6
  import { c as getCurrentLifecycleCommitBatch, u as registerLifecycleTransaction } from "./lifecycle-batch-Dfpid9-A.js";
7
- import { n as getActiveRenderContext } from "./render-context-D-DFk2WN.js";
7
+ import { n as getActiveRenderContext } from "./render-context-D0Hoj9dW.js";
8
8
  import { i as createSSRPortalHostToken, n as SSR_PORTAL_HOST, r as createSSRPortalAnchorToken, t as SSR_PORTAL_ANCHOR } from "./portal-w3oQ6oQU.js";
9
+ import { i as registerDefaultPortalRuntime } from "./default-portal-runtime-DvMvWJVp.js";
10
+ //#region src/jsx/utils.ts
11
+ function isElement(value) {
12
+ return typeof value === "object" && value !== null && value.$$typeof === ELEMENT_TYPE;
13
+ }
14
+ function cloneElement(element, props) {
15
+ return {
16
+ $$typeof: element.$$typeof,
17
+ type: element.type,
18
+ key: element.key,
19
+ props: {
20
+ ...element.props,
21
+ ...props
22
+ }
23
+ };
24
+ }
25
+ //#endregion
26
+ //#region src/foundations/structures/layout.tsx
27
+ function layout(Layout) {
28
+ return (children, props) => {
29
+ return Layout({
30
+ ...props,
31
+ children
32
+ });
33
+ };
34
+ }
35
+ //#endregion
36
+ //#region src/foundations/structures/slot.tsx
37
+ /**
38
+ * Slot
39
+ *
40
+ * Structural primitive for prop forwarding patterns.
41
+ *
42
+ * POLICY DECISIONS (LOCKED):
43
+ *
44
+ * 1. asChild Pattern
45
+ * When asChild=true, merges props into the single child element.
46
+ * Child must be a valid JSXElement; non-element children return null.
47
+ * **Slot props override child props** (injection pattern).
48
+ *
49
+ * 2. Fallback Behavior
50
+ * When asChild=false, returns a Fragment (structural no-op).
51
+ * No DOM element is introduced.
52
+ *
53
+ * 3. Type Safety
54
+ * asChild=true requires exactly one JSXElement child (enforced by type).
55
+ * Runtime validates with isElement() check.
56
+ */
57
+ function Slot(props) {
58
+ if (props.asChild) {
59
+ const { children, asChild: _asChild, ...rest } = props;
60
+ if (isElement(children)) return cloneElement(children, rest);
61
+ return null;
62
+ }
63
+ return {
64
+ $$typeof: ELEMENT_TYPE,
65
+ type: Fragment,
66
+ props: { children: props.children },
67
+ key: null
68
+ };
69
+ }
70
+ //#endregion
71
+ //#region src/foundations/structures/presence.ts
72
+ /**
73
+ * Presence
74
+ *
75
+ * Structural policy primitive for conditional mount/unmount.
76
+ * - No timers
77
+ * - No animation coupling
78
+ * - No DOM side-effects
79
+ *
80
+ * POLICY DECISIONS (LOCKED):
81
+ *
82
+ * 1. Present as Function
83
+ * Accepts boolean OR function to support lazy evaluation patterns.
84
+ * Function is called once per render. Use boolean form for static values.
85
+ *
86
+ * 2. Children Type
87
+ * Presence forwards normal renderable child content only.
88
+ * Imperative DOM nodes are not part of the public contract.
89
+ *
90
+ * 3. Immediate Mount/Unmount
91
+ * No exit animations or transitions. When `present` becomes false,
92
+ * children are removed immediately. Animation must be layered above
93
+ * this primitive.
94
+ */
95
+ function Presence({ present, children }) {
96
+ if (!(typeof present === "function" ? present() : Boolean(present))) return null;
97
+ return {
98
+ $$typeof: ELEMENT_TYPE,
99
+ type: Fragment,
100
+ props: { children },
101
+ key: null
102
+ };
103
+ }
104
+ //#endregion
9
105
  //#region src/runtime/portal.ts
10
106
  const DEFAULT_SSR_PORTAL_KEY = {};
11
107
  function getSSRPortalSlot(key) {
@@ -391,5 +487,138 @@ function Portal(props) {
391
487
  writeDefaultPortal(props, owner);
392
488
  return null;
393
489
  }
490
+ registerDefaultPortalRuntime({
491
+ host: DefaultPortal,
492
+ clearForInstance(instance) {
493
+ clearDefaultPortalForInstance(instance);
494
+ },
495
+ disposeScope: disposeDefaultPortalScope
496
+ });
497
+ //#endregion
498
+ //#region src/foundations/structures/collection.ts
499
+ function createCollection() {
500
+ const registry = /* @__PURE__ */ new Map();
501
+ function register(node, metadata) {
502
+ const item = {
503
+ node,
504
+ metadata
505
+ };
506
+ registry.set(node, item);
507
+ return () => {
508
+ registry.delete(node);
509
+ };
510
+ }
511
+ function items() {
512
+ return Array.from(registry.values());
513
+ }
514
+ function clear() {
515
+ registry.clear();
516
+ }
517
+ function size() {
518
+ return registry.size;
519
+ }
520
+ return {
521
+ register,
522
+ items,
523
+ clear,
524
+ size
525
+ };
526
+ }
527
+ /**
528
+ * USAGE EXAMPLE:
529
+ *
530
+ * // Create a collection for menu items
531
+ * const menuItems = createCollection<HTMLElement, { disabled: boolean }>();
532
+ *
533
+ * // Register items
534
+ * const unregister1 = menuItems.register(element1, { disabled: false });
535
+ * const unregister2 = menuItems.register(element2, { disabled: true });
536
+ *
537
+ * // Query items
538
+ * const allItems = menuItems.items();
539
+ * const enabledItems = allItems.filter(item => !item.metadata.disabled);
540
+ *
541
+ * // Cleanup
542
+ * unregister1();
543
+ * unregister2();
544
+ */
545
+ //#endregion
546
+ //#region src/foundations/structures/layer.ts
547
+ function createLayer() {
548
+ const stack = [];
549
+ let nextId = 1;
550
+ function register(options) {
551
+ const id = nextId++;
552
+ const entry = {
553
+ id,
554
+ options
555
+ };
556
+ stack.push(entry);
557
+ function isTop() {
558
+ return stack[stack.length - 1]?.id === id;
559
+ }
560
+ function unregister() {
561
+ const index = stack.findIndex((e) => e.id === id);
562
+ if (index !== -1) stack.splice(index, 1);
563
+ }
564
+ return {
565
+ id,
566
+ isTop,
567
+ unregister
568
+ };
569
+ }
570
+ function layers() {
571
+ return stack.map((entry) => ({
572
+ id: entry.id,
573
+ isTop: () => stack[stack.length - 1]?.id === entry.id,
574
+ unregister: () => {
575
+ const index = stack.findIndex((e) => e.id === entry.id);
576
+ if (index !== -1) stack.splice(index, 1);
577
+ }
578
+ }));
579
+ }
580
+ function handleEscape() {
581
+ const top = stack[stack.length - 1];
582
+ if (top) top.options.onEscape?.();
583
+ }
584
+ function handleOutsidePointer(e) {
585
+ const top = stack[stack.length - 1];
586
+ if (!top) return;
587
+ const node = top.options.node;
588
+ if (node && e.target instanceof Node) {
589
+ if (!node.contains(e.target)) top.options.onOutsidePointer?.(e);
590
+ } else top.options.onOutsidePointer?.(e);
591
+ }
592
+ return {
593
+ register,
594
+ layers,
595
+ handleEscape,
596
+ handleOutsidePointer
597
+ };
598
+ }
599
+ /**
600
+ * USAGE EXAMPLE:
601
+ *
602
+ * const layerManager = createLayer();
603
+ *
604
+ * function Modal({ onClose }) {
605
+ * const modalRef = ref<HTMLDivElement>();
606
+ *
607
+ * const layer = layerManager.register({
608
+ * node: modalRef.current,
609
+ * onEscape: onClose,
610
+ * onOutsidePointer: onClose,
611
+ * });
612
+ *
613
+ * onUnmount(() => layer.unregister());
614
+ *
615
+ * return (
616
+ * <div ref={modalRef}>
617
+ * <h1>Modal</h1>
618
+ * {layer.isTop() && <p>I am on top!</p>}
619
+ * </div>
620
+ * );
621
+ * }
622
+ */
394
623
  //#endregion
395
- export { disposeDefaultPortalScope as a, definePortal as i, Portal as n, clearDefaultPortalForInstance as r, DefaultPortal as t };
624
+ export { definePortal as a, layout as c, Portal as i, cloneElement as l, createCollection as n, Presence as o, DefaultPortal as r, Slot as s, createLayer as t, isElement as u };