@askrjs/askr 0.2.4 → 0.3.1

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 (117) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/access-CEA2pOry.js +1046 -0
  3. package/dist/actions/index.d.ts +16 -2
  4. package/dist/actions/index.js +5 -5
  5. package/dist/{activity-FirwPXA_.js → activity-oy2YFTFF.js} +10 -16
  6. package/dist/benchmark.js +8 -9
  7. package/dist/boot/index.d.ts +19 -9
  8. package/dist/boot/index.js +1 -1
  9. package/dist/{boot-tWyF6121.js → boot-DLplW9h4.js} +700 -441
  10. package/dist/capabilities-Bbf0mlp9.js +42 -0
  11. package/dist/components/index.d.ts +11 -8
  12. package/dist/components/index.js +1 -1
  13. package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
  14. package/dist/control/index.d.ts +20 -2
  15. package/dist/control/index.js +1 -1
  16. package/dist/{control-C-wSaq9V.js → control-BR_mrX__.js} +4 -4
  17. package/dist/core.d.ts +163 -0
  18. package/dist/csp-nonce-BfFWcd0w.js +173 -0
  19. package/dist/data/index.d.ts +74 -2
  20. package/dist/data/index.js +3 -3
  21. package/dist/{data-ghKopAbp.js → data-2edW0jhF.js} +108 -122
  22. package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
  23. package/dist/{deferred-CxjWCkIn.js → deferred-CbgNhf67.js} +5 -5
  24. package/dist/dom-renderer.d.ts +77 -0
  25. package/dist/domains/actions.d.ts +70 -0
  26. package/dist/domains/component.d.ts +119 -0
  27. package/dist/domains/context.d.ts +73 -0
  28. package/dist/domains/control.d.ts +328 -0
  29. package/dist/domains/data.d.ts +461 -0
  30. package/dist/domains/diagnostics.d.ts +21 -0
  31. package/dist/domains/lifecycle.d.ts +112 -0
  32. package/dist/domains/refs.d.ts +18 -0
  33. package/dist/domains/renderer.d.ts +127 -0
  34. package/dist/domains/routing.d.ts +501 -0
  35. package/dist/domains/scheduler.d.ts +79 -0
  36. package/dist/domains/server.d.ts +112 -0
  37. package/dist/domains/state.d.ts +129 -0
  38. package/dist/domains/telemetry.d.ts +29 -0
  39. package/dist/eager-control.d.ts +8 -0
  40. package/dist/{effect-CNwstBBD.js → effect-C3Zsc1k6.js} +14 -41
  41. package/dist/{types-DWVrKn9N.d.ts → elements.d.ts} +79 -42
  42. package/dist/{for-internal-DyBHfKJA.js → for-state-BDykeOJL.js} +598 -494
  43. package/dist/foundations/icon/index.d.ts +67 -16
  44. package/dist/foundations/icon/index.js +1 -1
  45. package/dist/foundations/index.d.ts +26 -3
  46. package/dist/foundations/index.js +1 -1
  47. package/dist/foundations/interactions/index.d.ts +73 -34
  48. package/dist/foundations/interactions/index.js +1 -1
  49. package/dist/foundations/state/index.d.ts +12 -5
  50. package/dist/foundations/state/index.js +1 -1
  51. package/dist/foundations/structures/index.d.ts +44 -3
  52. package/dist/foundations/structures/index.js +1 -1
  53. package/dist/foundations/utilities/index.d.ts +34 -3
  54. package/dist/foundations/utilities/index.js +1 -1
  55. package/dist/fx/index.d.ts +72 -25
  56. package/dist/fx/index.js +8 -8
  57. package/dist/index.d.ts +121 -4
  58. package/dist/index.js +316 -47
  59. package/dist/{component-internal-C4hKKQBF.js → instance-VAFYVJOa.js} +495 -283
  60. package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
  61. package/dist/jsx-dev-runtime.d.ts +51 -11
  62. package/dist/jsx-globals.d.ts +2 -0
  63. package/dist/jsx-runtime-CPJXAOBF.js +43 -0
  64. package/dist/jsx-runtime.d.ts +17 -3
  65. package/dist/jsx-runtime.js +2 -42
  66. package/dist/jsx.d.ts +108 -0
  67. package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
  68. package/dist/{navigate-ZZu1IV0B.js → navigate-prC5V8XV.js} +125 -472
  69. package/dist/{navigate-F4sHgWbw.d.ts → navigation.d.ts} +8 -8
  70. package/dist/{readable-Di1fzSwm.js → notify-DxxuDPeY.js} +96 -34
  71. package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
  72. package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
  73. package/dist/{ssr-Doog-AfJ.js → render-resolved-BC0W7_5b.js} +165 -558
  74. package/dist/{renderer-Cl23O0hV.js → renderer-CT0HeY58.js} +6825 -5692
  75. package/dist/{resolution-ClD-K7Lz.js → resolution-3DskUkjG.js} +189 -180
  76. package/dist/{resource-operation-Vz1S5h2k.js → resource-18-sFRl9.js} +98 -58
  77. package/dist/resources/index.d.ts +64 -12
  78. package/dist/resources/index.js +214 -8
  79. package/dist/route-activity.d.ts +21 -0
  80. package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
  81. package/dist/router/index.d.ts +378 -79
  82. package/dist/router/index.js +9 -9
  83. package/dist/router-internal-7nuNEHfG.js +36 -0
  84. package/dist/scope-Cq_iYbTR.js +403 -0
  85. package/dist/{selector-CsKuomw0.js → selector-BSPVkjKP.js} +26 -27
  86. package/dist/{shared-CYBH3F8I.js → shared-kU8yvryp.js} +3 -6
  87. package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
  88. package/dist/ssg/index.d.ts +51 -15
  89. package/dist/ssg/index.js +269 -209
  90. package/dist/ssr/index.d.ts +121 -68
  91. package/dist/ssr/index.js +2 -1
  92. package/dist/ssr-CiNm6Vzl.js +393 -0
  93. package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
  94. package/dist/{state-BGJgYSyQ.js → state-BXJfudq1.js} +10 -15
  95. package/dist/{structures-DFyK5AdQ.js → structures-CjEzfj4h.js} +37 -57
  96. package/dist/{index-CTpMmzgN.d.ts → structures.d.ts} +57 -36
  97. package/dist/testing/index.d.ts +123 -24
  98. package/dist/testing/index.js +24 -61
  99. package/dist/timer-C7uqnJVt.js +85 -0
  100. package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
  101. package/dist/{verify-hydration-BZPJ_kYa.js → verify-hydration-ikaxotf7.js} +8 -5
  102. package/package.json +12 -14
  103. package/dist/access-BucjYZcX.js +0 -509
  104. package/dist/activity-DooIuxQO.d.ts +0 -14
  105. package/dist/benchmark.d.ts +0 -26
  106. package/dist/cleanup-TXSsApEl.js +0 -535
  107. package/dist/component-cleanup-jdbgjkT1.js +0 -143
  108. package/dist/component-scope-4I3yEMkb.js +0 -195
  109. package/dist/control-Cxag1yqV.d.ts +0 -8
  110. package/dist/csp-nonce-9NFUb7hJ.js +0 -72
  111. package/dist/css-BuPaTOfe.js +0 -70
  112. package/dist/fastlane-BKZduiBQ.js +0 -166
  113. package/dist/index-Dgjbo2gU.d.ts +0 -1456
  114. package/dist/jsx-runtime-Cg7GqY1S.d.ts +0 -2
  115. package/dist/jsx-runtime-gVIaTPw0.d.ts +0 -38
  116. package/dist/lifecycle-batch-63aXFf2S.js +0 -253
  117. package/dist/lifecycle-operations-Q0k3EFnG.js +0 -287
@@ -0,0 +1,403 @@
1
+ //#region src/runtime/ownership/record.ts
2
+ /** One record per lifetime. Render and request revisions belong to execution
3
+ * and requests respectively; neither replaces this identity on a rerender. */
4
+ var OwnershipRecord = class {
5
+ constructor() {
6
+ this.identity = this;
7
+ this.disposed = false;
8
+ this.mounted = false;
9
+ this.controller = null;
10
+ this.hadScopedChildren = false;
11
+ }
12
+ };
13
+ /** A shared view surface populated only by the public compatibility adapter. */
14
+ const componentRecordPrototype = {};
15
+ const disposedSignal = (() => {
16
+ const controller = new AbortController();
17
+ controller.abort();
18
+ return controller.signal;
19
+ })();
20
+ function getOwnershipSignal(owner) {
21
+ if (owner.signal) return owner.signal;
22
+ if (owner.disposed) return disposedSignal;
23
+ owner.controller ??= new AbortController();
24
+ return owner.signal = owner.controller.signal;
25
+ }
26
+ function ownCleanup(owner, cleanup) {
27
+ if (owner.disposed) cleanup();
28
+ else (owner.cleanups ??= []).push(cleanup);
29
+ }
30
+ const scopedOwners = /* @__PURE__ */ new WeakMap();
31
+ /** Index an existing native lifetime; scopes never receive another owner. */
32
+ function registerScopedOwnership(scope, owner) {
33
+ owner.scope = scope;
34
+ scopedOwners.set(scope, owner);
35
+ if (owner.parent) {
36
+ owner.parent.hadScopedChildren = true;
37
+ owner.parent.scopedIndex?.add(scope);
38
+ }
39
+ }
40
+ function scopedOwnership(child) {
41
+ let lifetime = scopedOwners.get(child);
42
+ if (!lifetime) {
43
+ lifetime = new OwnershipRecord();
44
+ lifetime.cleanups = [() => child.dispose()];
45
+ registerScopedOwnership(child, lifetime);
46
+ }
47
+ return lifetime;
48
+ }
49
+ function ownChild(owner, child) {
50
+ attachOwnership(scopedOwnership(child), owner);
51
+ }
52
+ function releaseOwnedChild(owner, child) {
53
+ const lifetime = scopedOwners.get(child);
54
+ if (lifetime?.parent === owner) detachOwnership(lifetime);
55
+ }
56
+ function synchronizeScopedIndex(owner) {
57
+ const index = owner.scopedIndex;
58
+ for (let child = owner.head; child;) {
59
+ const next = child.next;
60
+ if (child.scope && !index?.has(child.scope)) detachOwnership(child);
61
+ child = next;
62
+ }
63
+ if (index) for (const scope of Set.prototype.values.call(index)) ownChild(owner, scope);
64
+ }
65
+ /** Compatibility collections are maintained indexes of the lifetime graph. */
66
+ function getOwnedChildScopes(owner) {
67
+ if (!owner.hadScopedChildren) return void 0;
68
+ if (!owner.scopedIndex) {
69
+ owner.scopedIndex = /* @__PURE__ */ new Set();
70
+ if (owner.disposed) return owner.scopedIndex;
71
+ for (let child = owner.head; child; child = child.next) if (child.scope) owner.scopedIndex.add(child.scope);
72
+ }
73
+ return owner.scopedIndex;
74
+ }
75
+ function setOwnedChildScopes(owner, scopes) {
76
+ owner.scopedIndex = scopes;
77
+ owner.hadScopedChildren = scopes !== void 0;
78
+ synchronizeScopedIndex(owner);
79
+ }
80
+ function detachOwnedChildren(owner) {
81
+ while (owner.head) detachOwnership(owner.head);
82
+ }
83
+ /** Drain attachments within a composite cleanup before surfacing its failures. */
84
+ function drainOwnedCleanup(items, cleanup) {
85
+ const errors = [];
86
+ for (const item of items) try {
87
+ cleanup(item);
88
+ } catch (error) {
89
+ errors.push(error);
90
+ }
91
+ if (errors.length) throw new AggregateError(errors, "Owned cleanup failed");
92
+ }
93
+ /** Detach the exact lifetime, independently of its execution record. */
94
+ function detachOwnership(owner) {
95
+ const parent = owner.parent;
96
+ if (!parent) return;
97
+ if (owner.previous) owner.previous.next = owner.next;
98
+ else parent.head = owner.next;
99
+ if (owner.next) owner.next.previous = owner.previous;
100
+ else parent.tail = owner.previous;
101
+ if (owner.scope) parent.scopedIndex?.delete(owner.scope);
102
+ owner.parent = void 0;
103
+ owner.previous = void 0;
104
+ owner.next = void 0;
105
+ }
106
+ function attachOwnership(owner, parent) {
107
+ if (owner.parent === parent || owner.disposed) return;
108
+ if (parent === owner) throw new Error("[Askr] A lifetime cannot own itself.");
109
+ if (owner.head) {
110
+ for (let ancestor = parent; ancestor; ancestor = ancestor.parent) if (ancestor === owner) throw new Error("[Askr] Lifetime ownership cannot contain a cycle.");
111
+ }
112
+ detachOwnership(owner);
113
+ if (!parent) return;
114
+ if (parent.disposed) {
115
+ disposeOwnership(owner);
116
+ return;
117
+ }
118
+ linkOwnership(owner, parent);
119
+ }
120
+ function linkOwnership(owner, parent) {
121
+ owner.parent = parent;
122
+ owner.previous = parent.tail;
123
+ if (parent.tail) parent.tail.next = owner;
124
+ else parent.head = owner;
125
+ parent.tail = owner;
126
+ if (owner.scope) {
127
+ parent.hadScopedChildren = true;
128
+ parent.scopedIndex?.add(owner.scope);
129
+ }
130
+ }
131
+ function defaultDisposalPhases() {
132
+ const errors = [];
133
+ return {
134
+ recordError(_message, error) {
135
+ errors.push(error);
136
+ },
137
+ finish() {
138
+ if (errors.length) throw new AggregateError(errors, "Owned cleanup failed");
139
+ }
140
+ };
141
+ }
142
+ function attemptDisposal(frame, message, run) {
143
+ try {
144
+ run?.();
145
+ } catch (error) {
146
+ try {
147
+ frame.phases.recordError(message, error);
148
+ } catch (reportError) {
149
+ frame.unreported.push(reportError);
150
+ }
151
+ }
152
+ }
153
+ function prepareDisposal(owner, phases) {
154
+ const errors = [];
155
+ let scopes;
156
+ try {
157
+ if (owner.scopedIndex) synchronizeScopedIndex(owner);
158
+ if (owner.scopedIndex?.size) scopes = Set.prototype.values.call(owner.scopedIndex);
159
+ } catch (error) {
160
+ errors.push(error);
161
+ owner.scopedIndex = void 0;
162
+ }
163
+ owner.disposed = true;
164
+ detachOwnership(owner);
165
+ try {
166
+ phases ??= owner.lifecycle?.(owner);
167
+ } catch (error) {
168
+ errors.push(error);
169
+ }
170
+ const frame = {
171
+ owner,
172
+ phases: phases ?? defaultDisposalPhases(),
173
+ scopes,
174
+ unreported: errors
175
+ };
176
+ if (scopes) owner.scopedIndex = void 0;
177
+ attemptDisposal(frame, "[Askr] owner preparation threw:", frame.phases.begin);
178
+ return frame;
179
+ }
180
+ /** One iterative postorder drain for every lifetime, including deep chains. */
181
+ function disposeOwnership(owner, phases) {
182
+ if (owner.disposed) return;
183
+ const stack = [prepareDisposal(owner, phases)];
184
+ while (stack.length) {
185
+ const frame = stack[stack.length - 1];
186
+ const current = frame.owner;
187
+ if (frame.scopes) {
188
+ const next = frame.scopes.next();
189
+ if (!next.done) {
190
+ const child = scopedOwnership(next.value);
191
+ if (!child.disposed && (!child.parent || child.parent === current)) {
192
+ if (!child.parent) linkOwnership(child, current);
193
+ stack.push(prepareDisposal(child));
194
+ }
195
+ continue;
196
+ }
197
+ }
198
+ if (current.head) {
199
+ const child = current.head;
200
+ if (frame.scopes && child.scope) {
201
+ detachOwnership(child);
202
+ continue;
203
+ }
204
+ stack.push(prepareDisposal(child));
205
+ continue;
206
+ }
207
+ const attempt = (message, run) => attemptDisposal(frame, message, run);
208
+ attempt("[Askr] readable subscription cleanup threw:", frame.phases.beforeCleanup);
209
+ const cleanups = current.cleanups;
210
+ current.cleanups = void 0;
211
+ if (cleanups) for (const cleanup of cleanups) attempt("[Askr] cleanup function threw:", cleanup);
212
+ attempt("[Askr] readable subscription cleanup threw:", frame.phases.afterCleanup);
213
+ attempt("[Askr] abort controller cleanup threw:", () => {
214
+ if (current.controller && !current.controller.signal.aborted) current.controller.abort(disposedSignal.reason);
215
+ });
216
+ current.controller = null;
217
+ current.reads = void 0;
218
+ current.mounted = false;
219
+ const finalizer = current.finalizer;
220
+ current.finalizer = void 0;
221
+ if (finalizer) attempt("[Askr] owner finalization threw:", () => finalizer.release());
222
+ try {
223
+ frame.phases.finish?.();
224
+ } catch (error) {
225
+ frame.unreported.push(error);
226
+ }
227
+ current.scope = void 0;
228
+ current.subject = void 0;
229
+ current.lifecycle = void 0;
230
+ stack.pop();
231
+ if (frame.unreported.length) {
232
+ const error = frame.unreported.length === 1 ? frame.unreported[0] : new AggregateError(frame.unreported, "Owned cleanup failed");
233
+ const parent = stack[stack.length - 1];
234
+ if (parent) attemptDisposal(parent, "[Askr] child ownership cleanup threw:", () => {
235
+ throw error;
236
+ });
237
+ else throw error;
238
+ }
239
+ }
240
+ }
241
+ //#endregion
242
+ //#region src/runtime/component/scope.ts
243
+ let currentInstance = null;
244
+ let currentPortalScope = null;
245
+ let scopedAppRenderRuntime;
246
+ let stateIndex = 0;
247
+ let globalRenderCounter = 0;
248
+ function nextRenderToken() {
249
+ return ++globalRenderCounter;
250
+ }
251
+ function captureScope() {
252
+ return {
253
+ instance: currentInstance,
254
+ portalScope: currentPortalScope,
255
+ stateIndex
256
+ };
257
+ }
258
+ function restoreScope(snapshot) {
259
+ currentInstance = snapshot.instance;
260
+ currentPortalScope = snapshot.portalScope;
261
+ stateIndex = snapshot.stateIndex;
262
+ }
263
+ /**
264
+ * Enter a component scope, returning the snapshot that restores it.
265
+ *
266
+ * The entry describes only what changes; the snapshot always carries all three
267
+ * ambient fields, and `endComponentScope` always restores all three. Callers
268
+ * therefore cannot introduce a variant that saves a subset and leaves the rest
269
+ * pointing at the previous component, which is what the older enter/exit pairs
270
+ * each did differently.
271
+ *
272
+ * Prefer `withComponentScope`. Use this pair directly only where the scope
273
+ * genuinely cannot be expressed as a closure, such as a span across two
274
+ * separately invoked lifecycle phases.
275
+ */
276
+ function beginComponentScope(entry) {
277
+ const snapshot = captureScope();
278
+ if ("instance" in entry) {
279
+ const instance = entry.instance ?? null;
280
+ currentInstance = instance;
281
+ currentPortalScope = instance?.portalScope ?? snapshot.portalScope;
282
+ }
283
+ if ("portalScope" in entry) currentPortalScope = entry.portalScope ?? null;
284
+ if (entry.stateIndex !== void 0) stateIndex = entry.stateIndex;
285
+ return snapshot;
286
+ }
287
+ /** Restore every ambient scope field captured by `beginComponentScope`. */
288
+ function endComponentScope(snapshot) {
289
+ restoreScope(snapshot);
290
+ }
291
+ function getCurrentComponentInstance() {
292
+ return currentInstance;
293
+ }
294
+ function getCurrentAppRenderRuntime() {
295
+ let instance = currentInstance;
296
+ while (instance) {
297
+ if (instance._appRenderRuntime) return instance._appRenderRuntime;
298
+ instance = instance.parentInstance;
299
+ }
300
+ return scopedAppRenderRuntime;
301
+ }
302
+ /** @internal Preserve root ownership without exposing component hook scope. */
303
+ function withAppRenderRuntime(runtime, fn) {
304
+ const previous = scopedAppRenderRuntime;
305
+ scopedAppRenderRuntime = runtime;
306
+ try {
307
+ return fn();
308
+ } finally {
309
+ scopedAppRenderRuntime = previous;
310
+ }
311
+ }
312
+ function getCurrentPortalScope() {
313
+ return currentInstance?.portalScope ?? currentPortalScope;
314
+ }
315
+ function getSignalForInstance(instance) {
316
+ return getOwnershipSignal(instance.owner);
317
+ }
318
+ /**
319
+ * Get the abort signal for the current component.
320
+ *
321
+ * The signal is guaranteed to be aborted when:
322
+ * - Component unmounts
323
+ * - Navigation occurs (different route)
324
+ * - Parent is destroyed
325
+ */
326
+ function getSignal() {
327
+ if (!currentInstance) throw new Error("getSignal() can only be called during component render execution. Ensure you are calling this from inside your component function.");
328
+ return getSignalForInstance(currentInstance);
329
+ }
330
+ function resetRenderState(instance) {
331
+ instance.stateIndexCheck = -1;
332
+ for (const state of instance.stateValues ?? []) if (state) state._hasBeenRead = false;
333
+ instance._pendingReadSources = void 0;
334
+ instance._pendingReadSourceVersions = void 0;
335
+ }
336
+ function beginRenderTracking(instance) {
337
+ instance.renderRevision = (instance.renderRevision ?? 0) + 1;
338
+ instance._currentRenderToken = nextRenderToken();
339
+ instance._pendingReadSources = void 0;
340
+ instance._pendingReadSourceVersions = void 0;
341
+ }
342
+ function clearRenderTracking(instance) {
343
+ instance._pendingReadSources = void 0;
344
+ instance._pendingReadSourceVersions = void 0;
345
+ instance._currentRenderToken = void 0;
346
+ }
347
+ function captureInlineRenderTracking(instance) {
348
+ return {
349
+ currentRenderToken: instance._currentRenderToken,
350
+ pendingReadSources: instance._pendingReadSources,
351
+ pendingReadSourceVersions: instance._pendingReadSourceVersions
352
+ };
353
+ }
354
+ function restoreInlineRenderTracking(instance, snapshot) {
355
+ instance._currentRenderToken = snapshot.currentRenderToken;
356
+ instance._pendingReadSources = snapshot.pendingReadSources;
357
+ instance._pendingReadSourceVersions = snapshot.pendingReadSourceVersions;
358
+ }
359
+ function enterRenderScopedComponent(instance, startStateIndex) {
360
+ return beginComponentScope({
361
+ instance,
362
+ stateIndex: startStateIndex
363
+ });
364
+ }
365
+ function captureInlineComponentScope() {
366
+ return beginComponentScope({});
367
+ }
368
+ function enterComponentExecutionScope(instance) {
369
+ return beginComponentScope({
370
+ instance,
371
+ stateIndex: 0
372
+ });
373
+ }
374
+ function enterDomCommitScope(instance) {
375
+ return beginComponentScope({ instance });
376
+ }
377
+ function clearCurrentComponentScope() {
378
+ return beginComponentScope({
379
+ instance: null,
380
+ portalScope: null
381
+ });
382
+ }
383
+ function getNextStateIndex() {
384
+ return stateIndex++;
385
+ }
386
+ function hookOrderGuidance(hookName) {
387
+ return `The render-scoped hook sequence changed between renders. This can happen when ${hookName}() is called conditionally, or when a conditional subtree skips an outer control boundary through a plain if, ternary, && branch, or loop. Keep render-scoped hooks and their outer control boundaries unconditional. Use <Show> or <Case> with <Match> children for conditional branches, and <For> for changing collections.`;
388
+ }
389
+ function claimHookIndex(instance, hookName) {
390
+ const index = getNextStateIndex();
391
+ if (index < instance.stateIndexCheck) throw new Error(`Hook index violation: ${hookName}() call at index ${index}, but previously saw index ${instance.stateIndexCheck}. ` + hookOrderGuidance(hookName));
392
+ instance.stateIndexCheck = index;
393
+ const expectedStateIndices = instance.expectedStateIndices ??= [];
394
+ if (instance.firstRenderComplete) {
395
+ if (expectedStateIndices[index] !== index) throw new Error(`Hook order violation: ${hookName}() called at index ${index}, but this index was not in the first render's sequence [${expectedStateIndices.join(", ")}]. ` + hookOrderGuidance(hookName));
396
+ } else expectedStateIndices.push(index);
397
+ return index;
398
+ }
399
+ function getCurrentStateIndex() {
400
+ return stateIndex;
401
+ }
402
+ //#endregion
403
+ export { releaseOwnedChild as A, disposeOwnership as C, ownChild as D, getOwnershipSignal as E, ownCleanup as O, detachOwnedChildren as S, getOwnedChildScopes as T, restoreInlineRenderTracking as _, clearCurrentComponentScope as a, attachOwnership as b, enterComponentExecutionScope as c, getCurrentAppRenderRuntime as d, getCurrentComponentInstance as f, resetRenderState as g, getSignal as h, claimHookIndex as i, setOwnedChildScopes as j, registerScopedOwnership as k, enterDomCommitScope as l, getCurrentStateIndex as m, captureInlineComponentScope as n, clearRenderTracking as o, getCurrentPortalScope as p, captureInlineRenderTracking as r, endComponentScope as s, beginRenderTracking as t, enterRenderScopedComponent as u, withAppRenderRuntime as v, drainOwnedCleanup as w, componentRecordPrototype as x, OwnershipRecord as y };
@@ -1,31 +1,29 @@
1
- import { t as enqueueRuntimeLane } from "./access-BucjYZcX.js";
2
- import { i as claimHookIndex, p as getCurrentInstance } from "./component-scope-4I3yEMkb.js";
3
- import { c as markReadableUsage, f as syncDerivedDependencySubscriptions, l as notifyReadableReaders, o as markReactivePropsDirtySource, p as withDerivedReadTracking, r as clearDerivedDependencySubscriptions, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-Di1fzSwm.js";
4
- //#region src/runtime/selector-store.ts
1
+ import { b as ScheduledWork, f as requestRuntimeWork } from "./access-CEA2pOry.js";
2
+ import { O as ownCleanup, f as getCurrentComponentInstance, i as claimHookIndex } from "./scope-Cq_iYbTR.js";
3
+ import { _ as markReadableUsage, b as syncDerivedDependencySubscriptions, h as clearDerivedDependencySubscriptions, t as notifyReadableSource, v as recordReadableRead, x as withDerivedReadTracking } from "./notify-DxxuDPeY.js";
4
+ //#region src/runtime/reactivity/selector-store.ts
5
5
  const dirtySelectorRecords = /* @__PURE__ */ new Set();
6
- let hasPendingSelectorFlush = false;
6
+ let selectorWork;
7
7
  function markDirtySelectorRecord(record, flush) {
8
8
  record._dirty = true;
9
- if (record._scheduled) return;
10
- record._scheduled = true;
11
- dirtySelectorRecords.add(record);
12
- if (hasPendingSelectorFlush) return;
13
- hasPendingSelectorFlush = true;
14
- enqueueRuntimeLane("derived", flush);
9
+ if (!record._pending) {
10
+ record._pending = true;
11
+ dirtySelectorRecords.add(record);
12
+ }
13
+ requestRuntimeWork("derived", selectorWork ??= new ScheduledWork(flush));
15
14
  }
16
15
  function takeDirtySelectorRecords() {
17
- hasPendingSelectorFlush = false;
18
16
  if (dirtySelectorRecords.size === 0) return [];
19
17
  const pending = Array.from(dirtySelectorRecords);
20
18
  dirtySelectorRecords.clear();
21
19
  return pending;
22
20
  }
23
21
  //#endregion
24
- //#region src/runtime/selector.ts
22
+ //#region src/runtime/reactivity/selector.ts
25
23
  const selectorCells = /* @__PURE__ */ new WeakMap();
26
24
  const selectorRecords = /* @__PURE__ */ new WeakMap();
27
25
  function getSelectorStore(instance) {
28
- const generation = instance._ownershipGeneration;
26
+ const generation = instance.owner.identity;
29
27
  let store = selectorCells.get(generation);
30
28
  if (!store) {
31
29
  store = /* @__PURE__ */ new Map();
@@ -39,7 +37,7 @@ function markSelectorRecordDirty(record) {
39
37
  function flushDirtySelectorRecords() {
40
38
  let failures = null;
41
39
  for (const record of takeDirtySelectorRecords()) {
42
- record._scheduled = false;
40
+ record._pending = false;
43
41
  if (!record._dirty) continue;
44
42
  try {
45
43
  recomputeSelectorSourceRecord(record, true);
@@ -93,7 +91,7 @@ function createSelectorSourceRecord(source) {
93
91
  _value: void 0,
94
92
  _hasValue: false,
95
93
  _dirty: true,
96
- _scheduled: false,
94
+ _pending: false,
97
95
  _evaluating: false,
98
96
  _sources: /* @__PURE__ */ new Set(),
99
97
  _lanes: /* @__PURE__ */ new Map(),
@@ -101,7 +99,7 @@ function createSelectorSourceRecord(source) {
101
99
  markSelectorRecordDirty(record);
102
100
  },
103
101
  _cleanup: () => {
104
- record._scheduled = false;
102
+ record._pending = false;
105
103
  record._dirty = false;
106
104
  record._hasValue = false;
107
105
  record._evaluating = false;
@@ -147,9 +145,7 @@ function createSelectorLane(record, equals) {
147
145
  return lane;
148
146
  }
149
147
  function notifySelectorSource(source) {
150
- markReadableDerivedSubscribersDirty(source, true);
151
- markReactivePropsDirtySource(source);
152
- notifyReadableReaders(source);
148
+ notifyReadableSource(source, { skipCurrentDerivedSubscriber: true });
153
149
  }
154
150
  function notifyAllSelectorSources(lane) {
155
151
  for (const source of lane._primitiveCandidates.values()) notifySelectorSource(source);
@@ -237,7 +233,7 @@ function createSelectorHook(instance, generation, store, hookIndex, source, equa
237
233
  const sourceRef = getCandidateSource(lane, candidate);
238
234
  recordReadableRead(sourceRef);
239
235
  if (record._evaluating) throw new Error("selector() cannot read itself recursively");
240
- const current = record._dirty || !record._hasValue ? recomputeSelectorSourceRecord(record, record._scheduled) : record._value;
236
+ const current = record._dirty || !record._hasValue ? recomputeSelectorSourceRecord(record, record._pending) : record._value;
241
237
  return lane._equals(current, candidate);
242
238
  };
243
239
  hook._owner = instance;
@@ -259,10 +255,13 @@ function createSelectorHook(instance, generation, store, hookIndex, source, equa
259
255
  detachSelectorHookBinding(hook);
260
256
  };
261
257
  attachSelectorHookBinding(hook, source, equals);
262
- (instance.cleanupFns ??= []).push(() => {
263
- hook._cleanup();
264
- store.delete(hookIndex);
265
- if (store.size === 0 && selectorCells.get(generation) === store) selectorCells.delete(generation);
258
+ ownCleanup(instance.owner, () => {
259
+ try {
260
+ hook._cleanup();
261
+ } finally {
262
+ store.delete(hookIndex);
263
+ if (store.size === 0 && selectorCells.get(generation) === store) selectorCells.delete(generation);
264
+ }
266
265
  });
267
266
  return hook;
268
267
  }
@@ -287,7 +286,7 @@ function getOrCreateSelectorHook(instance, hookIndex, source, equals) {
287
286
  } else ensureSelectorHookBinding(existing);
288
287
  return existing;
289
288
  }
290
- const created = createSelectorHook(instance, instance._ownershipGeneration, store, hookIndex, source, equals);
289
+ const created = createSelectorHook(instance, instance.owner.identity, store, hookIndex, source, equals);
291
290
  store.set(hookIndex, created);
292
291
  return created;
293
292
  }
@@ -301,7 +300,7 @@ function getOrCreateSelectorHook(instance, hookIndex, source, equals) {
301
300
  */
302
301
  function selector(source, equals = Object.is) {
303
302
  markReadableUsage(source);
304
- const instance = getCurrentInstance();
303
+ const instance = getCurrentComponentInstance();
305
304
  if (!instance) throw new Error("selector() can only be called during component render execution. Move selector() calls to the top level of your component function.");
306
305
  const hook = getOrCreateSelectorHook(instance, claimHookIndex(instance, "selector"), source, equals);
307
306
  if (!hook._record) throw new Error("selector() record binding was not established.");
@@ -1,13 +1,10 @@
1
- import { l as notifyReadableReaders, o as markReactivePropsDirtySource, s as markReadableDerivedSubscribersDirty } from "./readable-Di1fzSwm.js";
1
+ import { t as notifyReadableSource } from "./notify-DxxuDPeY.js";
2
2
  //#region src/data/shared.ts
3
3
  function createReadableSource() {
4
4
  return (() => void 0);
5
5
  }
6
- function notifySource(source) {
7
- markReadableDerivedSubscribersDirty(source);
8
- markReactivePropsDirtySource(source);
9
- notifyReadableReaders(source);
10
- }
6
+ /** Re-exported so data cells keep their existing name for the shared fan-out. */
7
+ const notifySource = notifyReadableSource;
11
8
  function isAbortError(error, signal) {
12
9
  return signal.aborted || error instanceof Error && error.name === "AbortError" || typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError";
13
10
  }
@@ -1,4 +1,4 @@
1
- //#region src/runtime/snapshot-source.ts
1
+ //#region src/runtime/reactivity/snapshot-source.ts
2
2
  const SNAPSHOT_SOURCE_BRAND = Symbol.for("__ASKR_SNAPSHOT_SOURCE__");
3
3
  function brandSnapshotSource(value) {
4
4
  Object.defineProperty(value, SNAPSHOT_SOURCE_BRAND, {
@@ -1,14 +1,33 @@
1
- import { An as SSRStyleRegistrationValidation, Bt as RoutePathParams, Dn as DocumentRenderer, En as DocumentRenderContext, Kt as RouteRegistry, Mt as RouteHandler, Rt as RouteOptions, Tn as DocumentRenderArgs, Vt as RoutePolicy } from "../index-Dgjbo2gU.js";
2
- import { AuthRequirement } from "@askrjs/auth";
3
- import "node:fs/promises";
4
- //#region src/ssg/types.d.ts
1
+ import {
2
+ SSRStyleRegistrationValidation,
3
+ RoutePathParams,
4
+ DocumentRenderer,
5
+ DocumentRenderContext,
6
+ RouteRegistry,
7
+ RouteHandler,
8
+ RouteOptions,
9
+ DocumentRenderArgs,
10
+ RoutePolicy,
11
+ } from '../core.js';
12
+ import { AuthRequirement } from '@askrjs/auth';
13
+ import 'node:fs/promises';
5
14
  /** Whether an SSG run rebuilds every route (`full`) or only changed ones (`incremental`). */
6
15
  type SSGMode = 'full' | 'incremental';
7
16
  /** Outcome of generating a single route's static HTML. */
8
17
  type RouteRenderStatus = 'success' | 'error' | 'skipped' | 'removed';
9
18
  /** Why a route was rendered, skipped, or removed during generation. */
10
- type RouteRenderReason = 'full' | 'changed-key' | 'changed-route' | 'new-route' | 'no-keys' | 'unchanged' | 'deleted' | 'runtime-only';
11
- type RouteConfigParams<Path extends string> = string extends Path ? Record<string, string> : RoutePathParams<Path>;
19
+ type RouteRenderReason =
20
+ | 'full'
21
+ | 'changed-key'
22
+ | 'changed-route'
23
+ | 'new-route'
24
+ | 'no-keys'
25
+ | 'unchanged'
26
+ | 'deleted'
27
+ | 'runtime-only';
28
+ type RouteConfigParams<Path extends string> = string extends Path
29
+ ? Record<string, string>
30
+ : RoutePathParams<Path>;
12
31
  /**
13
32
  * Route config accepted by SSG.
14
33
  *
@@ -49,7 +68,9 @@ interface RouteConfig<Path extends string = string> {
49
68
  * });
50
69
  * ```
51
70
  */
52
- entries?: () => Array<RouteConfigParams<Path>> | Promise<Array<RouteConfigParams<Path>>>;
71
+ entries?: () =>
72
+ | Array<RouteConfigParams<Path>>
73
+ | Promise<Array<RouteConfigParams<Path>>>;
53
74
  }
54
75
  interface SSGBaseOptions {
55
76
  /** Output directory for generated HTML files */
@@ -77,10 +98,11 @@ interface SSGAssetSource {
77
98
  to?: string;
78
99
  }
79
100
  /** Options for createStaticGen */
80
- type SSGOptions<_TRoutes extends readonly RouteConfig[] = RouteConfig[]> = SSGBaseOptions & {
81
- /** Explicit route registry captured with `createRouteRegistry()`. */
82
- registry: RouteRegistry;
83
- };
101
+ type SSGOptions<_TRoutes extends readonly RouteConfig[] = RouteConfig[]> =
102
+ SSGBaseOptions & {
103
+ /** Explicit route registry captured with `createRouteRegistry()`. */
104
+ registry: RouteRegistry;
105
+ };
84
106
  /** Options for a single generation run */
85
107
  interface SSGGenerateOptions {
86
108
  /** Generation mode */
@@ -206,8 +228,6 @@ interface DiscoveredResources {
206
228
  dependencies: string[];
207
229
  };
208
230
  }
209
- //#endregion
210
- //#region src/ssg/create-static-gen.d.ts
211
231
  /**
212
232
  * Create a Static Site Generator
213
233
  *
@@ -250,5 +270,21 @@ declare function createStaticGen(options: SSGOptions): {
250
270
  */
251
271
  getResult(): SSGResult | null;
252
272
  };
253
- //#endregion
254
- export { type DiscoveredResources, type DocumentRenderArgs, type DocumentRenderContext, type DocumentRenderer, type RouteConfig, type RouteRenderReason, type RouteRenderResult, type RouteRenderStatus, type SSGAssetSource, type SSGGenerateOptions, type SSGMetadata, type SSGMode, type SSGOptions, type SSGResult, type SSRStyleRegistrationValidation, createStaticGen };
273
+ export {
274
+ type DiscoveredResources,
275
+ type DocumentRenderArgs,
276
+ type DocumentRenderContext,
277
+ type DocumentRenderer,
278
+ type RouteConfig,
279
+ type RouteRenderReason,
280
+ type RouteRenderResult,
281
+ type RouteRenderStatus,
282
+ type SSGAssetSource,
283
+ type SSGGenerateOptions,
284
+ type SSGMetadata,
285
+ type SSGMode,
286
+ type SSGOptions,
287
+ type SSGResult,
288
+ type SSRStyleRegistrationValidation,
289
+ createStaticGen,
290
+ };