@askrjs/askr 0.2.4 → 0.3.0

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 +11 -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-BMBMWUGI.js} +680 -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
@@ -1,51 +1,386 @@
1
+ import { T as isProductionEnvironment, a as getRuntimeEvaluation, i as getRuntimeCleanup, m as runRuntimeWithSyncProgress, n as enqueueRuntimeTask, v as logger, w as isDevelopmentEnvironment } from "./access-CEA2pOry.js";
2
+ import { C as disposeOwnership, D as ownChild, E as getOwnershipSignal, O as ownCleanup, _ as restoreInlineRenderTracking, a as clearCurrentComponentScope, b as attachOwnership, c as enterComponentExecutionScope, f as getCurrentComponentInstance, g as resetRenderState, n as captureInlineComponentScope, o as clearRenderTracking, p as getCurrentPortalScope, r as captureInlineRenderTracking, s as endComponentScope, t as beginRenderTracking, u as enterRenderScopedComponent, x as componentRecordPrototype, y as OwnershipRecord } from "./scope-Cq_iYbTR.js";
3
+ import { t as adoptComponentParent } from "./capabilities-Bbf0mlp9.js";
4
+ import { f as runCommitTransaction, g as finalizeReadableSubscriptionsFromSnapshot, i as commitTransaction, l as registerCommitParticipant, m as cleanupReadableSubscriptionSources, n as applyTransaction, o as discardTransaction, p as suspendTransaction, r as beginCommitTransaction, s as getCurrentCommitTransaction } from "./notify-DxxuDPeY.js";
1
5
  import { a as markTransparentComponentResult, i as markEagerControlPrimitive } from "./control-C-ApnFs1.js";
2
- import { S as isProductionEnvironment, n as enqueueRuntimeTask, o as getRuntimeRenderer, x as isDevelopmentEnvironment, y as logger } from "./access-BucjYZcX.js";
3
- import { i as tryRuntimeFastLaneSync, n as isBulkCommitActive } from "./fastlane-BKZduiBQ.js";
4
- import { C as restoreRenderScopedComponent, S as restoreInlineRenderTracking, _ as getSignalForInstance, b as restoreDomCommitScope, c as enterDomCommitScope, f as getCurrentComponentInstance, l as enterRenderScopedComponent, m as getCurrentPortalScope, n as captureInlineComponentScope, o as clearRenderTracking, p as getCurrentInstance, r as captureInlineRenderTracking, s as enterComponentExecutionScope, t as beginRenderTracking, u as exitComponentExecutionScope, v as resetRenderState, x as restoreInlineComponentScope } from "./component-scope-4I3yEMkb.js";
5
6
  import { r as STATIC_CHILDREN, t as ELEMENT_TYPE } from "./jsx-DRS-qjiN.js";
6
- import { i as finalizeReadableSubscriptions } from "./readable-Di1fzSwm.js";
7
- import { a as enqueueLifecycleCommitForInstance, d as discardCommitOperations, f as executeCommittedLifecycleOperations, n as captureInlineRenderSnapshot$1, o as finalizeInlineReadSubscriptions, p as isPromiseLike, r as discardLifecycleCommitBatch, s as flushLifecycleCommitBatch, t as beginLifecycleCommitBatch } from "./lifecycle-batch-63aXFf2S.js";
8
- //#region src/runtime/context.ts
9
- const TransparentContextScopeComponent = markTransparentComponentResult(ContextScopeComponent);
10
- let nextScopeIdentityKey = 0;
11
- /** @internal Compare immutable context snapshots by provider identity and value. */
12
- function haveEquivalentContextFrames(left, right) {
13
- let leftFrame = left;
14
- let rightFrame = right;
15
- while (true) {
16
- while (leftFrame && !leftFrame.values?.size) leftFrame = leftFrame.parent;
17
- while (rightFrame && !rightFrame.values?.size) rightFrame = rightFrame.parent;
18
- if (leftFrame === rightFrame) return true;
19
- if (!leftFrame || !rightFrame) return false;
20
- const leftValues = leftFrame.values;
21
- const rightValues = rightFrame.values;
22
- if (leftValues?.size !== rightValues?.size) return false;
23
- if (leftValues) {
24
- if (!rightValues) return false;
25
- for (const [key, value] of leftValues) if (!rightValues.has(key) || !Object.is(rightValues.get(key), value)) return false;
7
+ //#region src/runtime/diagnostics/dev-namespace.ts
8
+ /**
9
+ * Set a value in the dev namespace (no-op in production).
10
+ */
11
+ const setDevValue = () => {};
12
+ /**
13
+ * Increment a counter in the dev namespace (no-op in production).
14
+ * Safely handles non-number values by resetting to 1.
15
+ */
16
+ const incDevCounter = () => {};
17
+ //#endregion
18
+ //#region src/common/dom-range.ts
19
+ /** Native records expose one renderer-maintained range index. Extension
20
+ * objects remain opaque and use the renderer's external index instead. */
21
+ const DIRECT_RANGE_OWNER = Symbol("askr.directRangeOwner");
22
+ //#endregion
23
+ //#region src/runtime/component/state.ts
24
+ /** Capture generation state without rewinding the monotonic render revision. */
25
+ function captureGenerationExecution(instance) {
26
+ return {
27
+ owner: instance.owner,
28
+ fn: instance.fn,
29
+ props: instance.props,
30
+ expectedStateIndices: instance.expectedStateIndices,
31
+ firstRenderComplete: instance.firstRenderComplete,
32
+ stateIndexCheck: instance.stateIndexCheck,
33
+ errorBoundaryState: instance.errorBoundaryState,
34
+ target: instance.target,
35
+ stateValues: instance.stateValues,
36
+ mountOperations: instance.mountOperations,
37
+ commitOperations: instance.commitOperations,
38
+ lifecycleSlots: instance.lifecycleSlots,
39
+ lifecycleGeneration: instance.lifecycleGeneration,
40
+ evaluationGeneration: instance.evaluationGeneration,
41
+ hasPendingUpdate: instance.hasPendingUpdate,
42
+ notifyUpdate: instance.notifyUpdate,
43
+ _placeholder: instance._placeholder,
44
+ _currentRenderToken: instance._currentRenderToken,
45
+ lastRenderToken: instance.lastRenderToken,
46
+ _pendingReadSources: instance._pendingReadSources,
47
+ _pendingReadSourceVersions: instance._pendingReadSourceVersions,
48
+ _appRenderRuntime: instance._appRenderRuntime
49
+ };
50
+ }
51
+ /** Inline execution capture excludes monotonic revision and subscription identity. */
52
+ function captureInlineExecution(instance) {
53
+ return {
54
+ props: instance.props,
55
+ firstRenderComplete: instance.firstRenderComplete,
56
+ ownerFrame: instance.ownerFrame,
57
+ portalScope: instance.portalScope,
58
+ isRoot: instance.isRoot,
59
+ _vnodeParentGeneration: instance._vnodeParentGeneration,
60
+ _vnodeOwner: instance._vnodeOwner,
61
+ _vnodeParent: instance._vnodeParent,
62
+ _vnodeKey: instance._vnodeKey,
63
+ _vnodePosition: instance._vnodePosition,
64
+ _wrapperDepth: instance._wrapperDepth,
65
+ cleanupStrict: instance.cleanupStrict
66
+ };
67
+ }
68
+ function restoreInlineExecution(instance, execution, hasVNodeKey) {
69
+ Object.assign(instance, execution);
70
+ if (!hasVNodeKey) delete instance._vnodeKey;
71
+ }
72
+ //#endregion
73
+ //#region src/runtime/component/inline-snapshot.ts
74
+ function createInlineRenderSnapshot(instance) {
75
+ return {
76
+ instance,
77
+ mounted: instance.owner.mounted,
78
+ parentInstance: instance.parentInstance,
79
+ parentLifetime: instance.owner.parent,
80
+ hasVNodeKey: "_vnodeKey" in instance,
81
+ execution: captureInlineExecution(instance)
82
+ };
83
+ }
84
+ function restoreInlineRenderSnapshot(snapshot) {
85
+ restoreInlineExecution(snapshot.instance, snapshot.execution, snapshot.hasVNodeKey);
86
+ snapshot.instance.owner.mounted = snapshot.mounted;
87
+ adoptComponentParent(snapshot.instance, snapshot.parentInstance, snapshot.parentLifetime ?? null);
88
+ }
89
+ //#endregion
90
+ //#region src/common/promise.ts
91
+ function isPromiseLike(value) {
92
+ return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
93
+ }
94
+ /**
95
+ * Components must return synchronously; async work belongs in `resource()`.
96
+ *
97
+ * The rule was previously enforced by ten hand-written throws carrying three
98
+ * different messages. It is one rule, so it has one message and one guard.
99
+ */
100
+ const ASYNC_COMPONENT_MESSAGE = "Async components are not supported. Use resource() for async work.";
101
+ function assertSyncComponentResult(result) {
102
+ if (isPromiseLike(result)) throw new Error(ASYNC_COMPONENT_MESSAGE);
103
+ }
104
+ //#endregion
105
+ //#region src/runtime/lifecycle/settlement.ts
106
+ const LIFECYCLE_COMMIT = {};
107
+ var LifecycleCommit = class {
108
+ constructor(instance, firstMount) {
109
+ this.kind = LIFECYCLE_COMMIT;
110
+ this.prepared = false;
111
+ this.key = instance;
112
+ this.owner = instance.owner;
113
+ this.generation = instance.owner.identity;
114
+ this.firstMount = firstMount;
115
+ }
116
+ merge(parent) {
117
+ parent.update(this.owner, this.generation, this.firstMount);
118
+ }
119
+ update(owner, generation, firstMount) {
120
+ this.firstMount = this.generation === generation ? this.firstMount || firstMount : firstMount;
121
+ this.owner = owner;
122
+ this.generation = generation;
123
+ }
124
+ live() {
125
+ return this.key.owner === this.owner && this.owner.identity === this.generation && !this.owner.disposed;
126
+ }
127
+ publish() {
128
+ if (!this.live()) return;
129
+ if (this.firstMount) {
130
+ this.mounts = this.key.mountOperations;
131
+ this.key.mountOperations = void 0;
26
132
  }
27
- leftFrame = leftFrame.parent;
28
- rightFrame = rightFrame.parent;
133
+ this.commits = this.key.commitOperations;
134
+ this.key.commitOperations = void 0;
135
+ this.prepared = true;
136
+ }
137
+ activate() {
138
+ if (this.prepared && this.live()) executeOwnedLifecycleOperations(this.key.id, this.owner, this.mounts, this.commits);
139
+ }
140
+ rollback() {
141
+ if (!this.live()) return;
142
+ if (this.firstMount) this.key.mountOperations = void 0;
143
+ discardCommitOperations(this.key);
29
144
  }
30
- }
31
- const ROOT_EXECUTION_FRAME = {
32
- parent: null,
33
- values: null
34
145
  };
35
- const executionFramesByParent = /* @__PURE__ */ new WeakMap();
36
- /** @internal Reuse immutable empty wrappers for the same provider snapshot. */
37
- function getExecutionContextFrame(parent) {
38
- if (!parent) return ROOT_EXECUTION_FRAME;
39
- let frame = executionFramesByParent.get(parent);
40
- if (!frame) {
41
- frame = {
42
- parent,
43
- values: null
146
+ function enqueueLifecycleCommitForInstance(instance, firstMount) {
147
+ const transaction = getCurrentCommitTransaction();
148
+ if (!transaction) return false;
149
+ const previous = transaction.participant(instance, LIFECYCLE_COMMIT);
150
+ if (previous) previous.update(instance.owner, instance.owner.identity, firstMount);
151
+ else registerCommitParticipant(new LifecycleCommit(instance, firstMount));
152
+ return true;
153
+ }
154
+ function settleLifecycleOperationResult(owner, result) {
155
+ if (isPromiseLike(result)) Promise.resolve(result).then((cleanup) => {
156
+ if (typeof cleanup === "function") {
157
+ if (!owner.disposed && owner.mounted) {
158
+ ownCleanup(owner, cleanup);
159
+ return;
160
+ }
161
+ try {
162
+ cleanup();
163
+ } catch (err) {
164
+ logger.error("[Askr] async mount cleanup failed:", err);
165
+ }
166
+ }
167
+ }, (err) => {
168
+ logger.error("[Askr] async mount operation failed:", err);
169
+ });
170
+ else if (typeof result === "function") ownCleanup(owner, result);
171
+ }
172
+ function discardCommitOperations(instance) {
173
+ instance.commitOperations = void 0;
174
+ }
175
+ function executeOwnedLifecycleOperations(id, owner, mounts, commits) {
176
+ const errors = [];
177
+ for (const operations of [mounts, commits]) for (const operation of operations ?? []) try {
178
+ settleLifecycleOperationResult(owner, operation());
179
+ } catch (error) {
180
+ errors.push(error);
181
+ }
182
+ if (errors.length > 0) throw new AggregateError(errors, `Committed lifecycle operations failed for ${id}`);
183
+ }
184
+ //#endregion
185
+ //#region src/runtime/transactions/render.ts
186
+ const READ_COMMIT = {};
187
+ const INLINE_SNAPSHOT = {};
188
+ var ReadCommit = class {
189
+ constructor(instance, token, sources, versions) {
190
+ this.kind = READ_COMMIT;
191
+ this.key = instance;
192
+ this.update(token, sources, versions);
193
+ }
194
+ update(token, sources, versions) {
195
+ this.generation = this.key.owner.identity;
196
+ this.token = token;
197
+ this.sources = sources ? new Set(sources) : void 0;
198
+ this.versions = versions ? new Map(versions) : void 0;
199
+ }
200
+ merge(parent) {
201
+ const previous = parent;
202
+ previous.generation = this.generation;
203
+ previous.token = this.token;
204
+ previous.sources = this.sources;
205
+ previous.versions = this.versions;
206
+ }
207
+ publish() {
208
+ const instance = this.key;
209
+ if (instance.owner.disposed || instance.owner.identity !== this.generation) return;
210
+ const { readers, sources } = this.previous = {
211
+ sources: instance.owner.reads,
212
+ token: instance.lastRenderToken,
213
+ readers: /* @__PURE__ */ new Map()
44
214
  };
45
- executionFramesByParent.set(parent, frame);
215
+ for (const source of sources ?? []) readers.set(source, source._readers?.get(instance));
216
+ for (const source of this.sources ?? []) if (!readers.has(source)) readers.set(source, source._readers?.get(instance));
217
+ finalizeReadableSubscriptionsFromSnapshot(instance, this.token, this.sources, this.versions, this.generation);
46
218
  }
47
- return frame;
219
+ rollback() {
220
+ const instance = this.key;
221
+ if (!this.previous || instance.owner.disposed || instance.owner.identity !== this.generation) return;
222
+ instance.owner.reads = this.previous.sources;
223
+ instance.lastRenderToken = this.previous.token;
224
+ const errors = [];
225
+ for (const [source, entry] of this.previous.readers) try {
226
+ source._readers?.get(instance);
227
+ if (entry) (source._readers ??= /* @__PURE__ */ new Map()).set(instance, entry);
228
+ else if (source._readers?.delete(instance) && false);
229
+ } catch (error) {
230
+ errors.push(error);
231
+ }
232
+ if (errors.length) throw new AggregateError(errors, "Read subscription restoration failed");
233
+ }
234
+ };
235
+ var InlineSnapshot = class {
236
+ constructor(instance) {
237
+ this.kind = INLINE_SNAPSHOT;
238
+ this.key = instance;
239
+ this.generation = instance.owner.identity;
240
+ this.snapshot = createInlineRenderSnapshot(instance);
241
+ this.revision = instance.renderRevision;
242
+ }
243
+ merge(parent) {
244
+ parent.revision = this.revision;
245
+ }
246
+ rollback() {
247
+ if (!this.key.owner.disposed && this.key.owner.identity === this.generation && this.key.renderRevision === this.revision) restoreInlineRenderSnapshot(this.snapshot);
248
+ }
249
+ };
250
+ function sealInlineRenderSnapshot(instance) {
251
+ const snapshot = getCurrentCommitTransaction()?.participant(instance, INLINE_SNAPSHOT);
252
+ if (snapshot) snapshot.revision = instance.renderRevision;
253
+ }
254
+ function captureInlineRenderSnapshot$1(instance) {
255
+ const transaction = getCurrentCommitTransaction();
256
+ if (!transaction || transaction.participant(instance, INLINE_SNAPSHOT)) return;
257
+ registerCommitParticipant(new InlineSnapshot(instance));
258
+ }
259
+ function finalizeInlineReadSubscriptions(instance, token, sources, versions) {
260
+ if (!sources?.size && !instance.owner.reads?.size) return;
261
+ const transaction = getCurrentCommitTransaction();
262
+ if (!transaction) {
263
+ runCommitTransaction(() => registerCommitParticipant(new ReadCommit(instance, token, sources, versions)));
264
+ return;
265
+ }
266
+ const existing = transaction.participant(instance, READ_COMMIT);
267
+ if (existing) existing.update(token, sources, versions);
268
+ else registerCommitParticipant(new ReadCommit(instance, token, sources, versions));
48
269
  }
270
+ //#endregion
271
+ //#region src/runtime/diagnostics/state-diagnostics.ts
272
+ /**
273
+ * Report state cells that were never read during a component's completed
274
+ * lifetime. A branch that has not rendered yet is not evidence that its state
275
+ * is unused, so this diagnostic belongs at unmount rather than every commit.
276
+ */
277
+ function warnUnusedStateReads(instance) {
278
+ if (!instance.owner.mounted) return;
279
+ const stateValues = instance.stateValues;
280
+ if (!stateValues?.length || isProductionEnvironment()) return;
281
+ for (let i = 0; i < stateValues.length; i++) {
282
+ const state = stateValues[i];
283
+ const diagnosticEligible = state?._unusedStateDiagnosticEligible;
284
+ const hasCommittedUsage = (state?._readers?.size ?? 0) > 0 || (state?._derivedSubscribers?.size ?? 0) > 0;
285
+ if (state && diagnosticEligible !== false && !state._hasEverBeenRead && !hasCommittedUsage) {
286
+ const warnings = instance.devWarningsEmitted ??= /* @__PURE__ */ new Set();
287
+ const key = `unused-state:${i}`;
288
+ if (warnings.has(key)) continue;
289
+ warnings.add(key);
290
+ try {
291
+ const name = instance.fn?.name || "<anonymous>";
292
+ logger.warn(`[askr] Unused state variable detected in ${name} at index ${i}. State should be read during render or removed.`);
293
+ } catch {
294
+ logger.warn("[askr] Unused state variable detected. State should be read during render or removed.");
295
+ }
296
+ }
297
+ }
298
+ }
299
+ //#endregion
300
+ //#region src/runtime/component/reset.ts
301
+ /** Pending work belongs to one generation and cannot survive its retirement. */
302
+ function resetComponentWork(instance) {
303
+ instance.hasPendingUpdate = false;
304
+ instance.notifyUpdate = null;
305
+ instance.mountOperations = void 0;
306
+ instance.commitOperations = void 0;
307
+ instance.lifecycleSlots = void 0;
308
+ instance._pendingReadSources = void 0;
309
+ instance._pendingReadSourceVersions = void 0;
310
+ instance._placeholder = void 0;
311
+ }
312
+ //#endregion
313
+ //#region src/runtime/component/cleanup.ts
314
+ function componentDisposalPhases(owner) {
315
+ const instance = owner.subject;
316
+ const active = instance.owner === owner;
317
+ const hadRendererHost = Boolean(instance.target || instance._placeholder);
318
+ let savedScope;
319
+ const errors = instance.cleanupStrict ? [] : void 0;
320
+ const retiredScopes = active ? void 0 : owner.scopedIndex;
321
+ const detachReads = () => {
322
+ retiredScopes?.clear();
323
+ cleanupReadableSubscriptionSources(instance, owner.reads, owner.identity);
324
+ };
325
+ const recordError = (message, error) => {
326
+ if (errors) errors.push(error);
327
+ else if (isDevelopmentEnvironment()) logger.warn(message, error);
328
+ };
329
+ return {
330
+ begin() {
331
+ savedScope = clearCurrentComponentScope();
332
+ if (active) {
333
+ instance.lifecycleGeneration++;
334
+ instance.evaluationGeneration++;
335
+ instance.hasPendingUpdate = false;
336
+ instance.notifyUpdate = null;
337
+ warnUnusedStateReads(instance);
338
+ }
339
+ },
340
+ beforeCleanup: active ? void 0 : detachReads,
341
+ afterCleanup: active ? detachReads : void 0,
342
+ recordError,
343
+ finish() {
344
+ try {
345
+ if (active && instance.owner === owner) {
346
+ try {
347
+ if (hadRendererHost) getRuntimeCleanup().releaseComponentHost(instance);
348
+ } catch (error) {
349
+ recordError("[Askr] host release failed:", error);
350
+ }
351
+ resetComponentWork(instance);
352
+ instance._portalErrorParent = void 0;
353
+ instance._portalErrorParentGeneration = void 0;
354
+ }
355
+ if (errors?.length) throw new AggregateError(errors, `Cleanup failed for component ${instance.id}`);
356
+ } finally {
357
+ endComponentScope(savedScope);
358
+ }
359
+ }
360
+ };
361
+ }
362
+ function createComponentOwnership(instance) {
363
+ const owner = new OwnershipRecord();
364
+ owner.subject = instance;
365
+ owner.lifecycle = componentDisposalPhases;
366
+ return owner;
367
+ }
368
+ function bindComponentOwnership(instance) {
369
+ instance.owner.subject = instance;
370
+ instance.owner.lifecycle = componentDisposalPhases;
371
+ }
372
+ /** Retire the captured lifetime without swapping the execution record. */
373
+ function cleanupComponentGeneration(_instance, owner) {
374
+ disposeOwnership(owner);
375
+ }
376
+ function cleanupComponent(instance) {
377
+ disposeOwnership(instance.owner);
378
+ }
379
+ function registerOwnedChildScope(instance, scope) {
380
+ ownChild(instance.owner, scope);
381
+ }
382
+ //#endregion
383
+ //#region src/runtime/context/vnode.ts
49
384
  const CONTEXT_FRAME_SYMBOL = Symbol("__tempoContextFrame__");
50
385
  const vnodeContextFrames = /* @__PURE__ */ new WeakMap();
51
386
  function getVNodeContextFrame(node) {
@@ -161,6 +496,48 @@ function rebaseVNodeTreeWithContextFrame(node, ownerFrame, previousOwnerFrame =
161
496
  }
162
497
  return node;
163
498
  }
499
+ //#endregion
500
+ //#region src/runtime/context/context.ts
501
+ const TransparentContextScopeComponent = markTransparentComponentResult(ContextScopeComponent);
502
+ let nextScopeIdentityKey = 0;
503
+ /** @internal Compare immutable context snapshots by provider identity and value. */
504
+ function haveEquivalentContextFrames(left, right) {
505
+ let leftFrame = left;
506
+ let rightFrame = right;
507
+ while (true) {
508
+ while (leftFrame && !leftFrame.values?.size) leftFrame = leftFrame.parent;
509
+ while (rightFrame && !rightFrame.values?.size) rightFrame = rightFrame.parent;
510
+ if (leftFrame === rightFrame) return true;
511
+ if (!leftFrame || !rightFrame) return false;
512
+ const leftValues = leftFrame.values;
513
+ const rightValues = rightFrame.values;
514
+ if (leftValues?.size !== rightValues?.size) return false;
515
+ if (leftValues) {
516
+ if (!rightValues) return false;
517
+ for (const [key, value] of leftValues) if (!rightValues.has(key) || !Object.is(rightValues.get(key), value)) return false;
518
+ }
519
+ leftFrame = leftFrame.parent;
520
+ rightFrame = rightFrame.parent;
521
+ }
522
+ }
523
+ const ROOT_EXECUTION_FRAME = {
524
+ parent: null,
525
+ values: null
526
+ };
527
+ const executionFramesByParent = /* @__PURE__ */ new WeakMap();
528
+ /** @internal Reuse immutable empty wrappers for the same provider snapshot. */
529
+ function getExecutionContextFrame(parent) {
530
+ if (!parent) return ROOT_EXECUTION_FRAME;
531
+ let frame = executionFramesByParent.get(parent);
532
+ if (!frame) {
533
+ frame = {
534
+ parent,
535
+ values: null
536
+ };
537
+ executionFramesByParent.set(parent, frame);
538
+ }
539
+ return frame;
540
+ }
164
541
  let currentContextFrame = null;
165
542
  let currentAsyncResourceFrame = null;
166
543
  /**
@@ -318,7 +695,7 @@ function getCurrentContextFrame() {
318
695
  return currentContextFrame;
319
696
  }
320
697
  //#endregion
321
- //#region src/runtime/render-diagnostics.ts
698
+ //#region src/runtime/diagnostics/render-diagnostics.ts
322
699
  let renderDiagnostics = {
323
700
  slowRenderWarnings: true,
324
701
  slowRenderThresholdMs: 5
@@ -347,26 +724,20 @@ function shouldWarnSlowRender(renderTimeMs) {
347
724
  return renderDiagnostics.slowRenderWarnings && renderTimeMs > renderDiagnostics.slowRenderThresholdMs;
348
725
  }
349
726
  //#endregion
350
- //#region src/runtime/component-lifecycle.ts
727
+ //#region src/runtime/component/lifecycle.ts
351
728
  function registerCommitOperationForInstance(instance, operation) {
352
- if (instance) {
353
- if (isBulkCommitActive()) {
354
- if (isDevelopmentEnvironment()) throw new Error("registerCommitOperation called during bulk commit fast-lane");
355
- return;
356
- }
357
- (instance.commitOperations ??= []).push(operation);
358
- }
729
+ if (instance) (instance.commitOperations ??= []).push(operation);
359
730
  }
360
731
  function commitLifecycleForInstance(instance, wasFirstMount) {
361
732
  if ((instance.mountOperations?.length ?? 0) === 0 && (instance.commitOperations?.length ?? 0) === 0) return;
362
733
  if (enqueueLifecycleCommitForInstance(instance, wasFirstMount)) return;
363
- executeCommittedLifecycleOperations(instance, wasFirstMount);
734
+ runCommitTransaction(() => enqueueLifecycleCommitForInstance(instance, wasFirstMount));
364
735
  }
365
736
  function commitRenderedComponent$1(instance) {
366
- if (instance.mounted && (instance.commitOperations?.length ?? 0) > 0) commitLifecycleForInstance(instance, false);
737
+ if (instance.owner.mounted && (instance.commitOperations?.length ?? 0) > 0) commitLifecycleForInstance(instance, false);
367
738
  }
368
739
  //#endregion
369
- //#region src/runtime/error-boundary.ts
740
+ //#region src/runtime/component/error-boundary.ts
370
741
  function createBoundaryReset(instance) {
371
742
  return () => {
372
743
  const boundaryState = instance.errorBoundaryState;
@@ -394,7 +765,7 @@ function reportBoundaryError(instance, error, onError) {
394
765
  }
395
766
  function getLivePortalErrorParent(instance) {
396
767
  const parent = instance._portalErrorParent;
397
- if (!parent || parent._ownershipGeneration !== instance._portalErrorParentGeneration || parent.notifyUpdate === null) return null;
768
+ if (!parent || parent.owner.identity !== instance._portalErrorParentGeneration || parent.notifyUpdate === null) return null;
398
769
  return parent;
399
770
  }
400
771
  function findLiveErrorBoundary(failedInstance) {
@@ -417,189 +788,65 @@ function routeComponentErrorToBoundary(failedInstance, error) {
417
788
  return true;
418
789
  }
419
790
  //#endregion
420
- //#region src/runtime/component-commit.ts
421
- function runScheduledComponent(instance, host) {
422
- const ownershipGeneration = instance._ownershipGeneration;
791
+ //#region src/runtime/component/commit.ts
792
+ function runScheduledComponent(instance, execute) {
793
+ const owner = instance.owner;
794
+ const ownershipGeneration = owner.identity;
423
795
  const evaluationGeneration = instance.evaluationGeneration;
796
+ const transaction = beginCommitTransaction();
424
797
  instance.notifyUpdate = instance._enqueueRun;
798
+ captureInlineRenderSnapshot$1(instance);
425
799
  beginRenderTracking(instance);
800
+ const token = instance._currentRenderToken;
801
+ const renderRevision = instance.renderRevision;
426
802
  let result;
803
+ let fast = false;
427
804
  try {
428
- result = host.execute(instance);
429
- } catch (err) {
430
- discardCommitOperations(instance);
431
- if (routeComponentErrorToBoundary(instance, err)) return;
432
- throw err;
433
- }
434
- if (isPromiseLike(result)) {
435
- const error = /* @__PURE__ */ new Error("Async components are not supported. Components must be synchronous.");
436
- discardCommitOperations(instance);
437
- if (routeComponentErrorToBoundary(instance, error)) return;
438
- throw error;
439
- }
440
- try {
441
- if (tryRuntimeFastLaneSync(instance, result)) return;
442
- } catch (err) {
443
- if (routeComponentErrorToBoundary(instance, err)) return;
444
- if (isDevelopmentEnvironment()) throw err;
445
- }
446
- enqueueRuntimeTask(() => {
447
- try {
448
- if (instance._ownershipGeneration !== ownershipGeneration || instance.evaluationGeneration !== evaluationGeneration) return;
449
- if (!instance.target && instance._placeholder) {
450
- commitPlaceholderReplacement(instance, result, host);
451
- return;
452
- }
453
- if (instance.target) commitToTarget(instance, result, host);
454
- } catch (err) {
455
- if (!routeComponentErrorToBoundary(instance, err)) throw err;
456
- }
457
- });
458
- }
459
- function commitPlaceholderReplacement(instance, result, host) {
460
- if (result === null || result === void 0) {
461
- const placeholder = instance._placeholder;
462
- if (placeholder) {
463
- const replacement = getRuntimeRenderer().replaceComponentRange(instance, result, placeholder);
464
- if (replacement) {
465
- instance.target = replacement instanceof Element ? replacement : null;
466
- instance._placeholder = replacement instanceof Comment ? replacement : void 0;
467
- }
468
- }
469
- host.finalizeReadSubscriptions(instance);
470
- host.commitRenderedComponent(instance);
471
- return;
472
- }
473
- const placeholder = instance._placeholder;
474
- const parent = placeholder.parentNode;
475
- if (!parent) {
476
- logger.warn("[Askr] placeholder no longer in DOM, cannot render component");
805
+ result = execute(instance);
806
+ assertSyncComponentResult(result);
807
+ finalizeInlineReadSubscriptions(instance, token, instance._pendingReadSources, instance._pendingReadSourceVersions);
808
+ fast = getRuntimeEvaluation().classifyComponentUpdate(instance, result).useFastPath;
809
+ if (!fast) {}
810
+ } catch (error) {
811
+ discardTransaction(transaction);
812
+ if (!routeComponentErrorToBoundary(instance, error)) throw error;
477
813
  return;
478
- }
479
- const renderer = getRuntimeRenderer();
480
- const rangeReplacement = renderer.replaceComponentRange(instance, result, placeholder);
481
- if (rangeReplacement) {
482
- if (rangeReplacement instanceof Element) {
483
- instance.target = rangeReplacement;
484
- instance._placeholder = void 0;
485
- } else {
486
- instance.target = null;
487
- instance._placeholder = rangeReplacement;
488
- }
489
- host.finalizeReadSubscriptions(instance);
490
- host.commitRenderedComponent(instance);
491
- return;
492
- }
493
- const hostElement = document.createElement("div");
494
- const executionFrame = getExecutionContextFrame(instance.ownerFrame);
495
- const oldInstance = enterDomCommitScope(instance);
496
- const lifecycleBatch = beginLifecycleCommitBatch();
497
- try {
498
- try {
499
- withContext(executionFrame, () => {
500
- renderer.evaluate(result, hostElement);
501
- });
502
- const onlyChild = hostElement.childNodes.length === 1 ? hostElement.firstChild : null;
503
- const replacement = onlyChild instanceof Element || onlyChild instanceof Comment ? onlyChild : hostElement;
504
- if (replacement === hostElement) hostElement.__ASKR_WRAPPER_HOST = true;
505
- parent.replaceChild(replacement, placeholder);
506
- instance.target = replacement instanceof Element ? replacement : null;
507
- instance._placeholder = replacement instanceof Comment ? replacement : void 0;
508
- const instanceHost = replacement;
509
- const instances = instanceHost.__ASKR_INSTANCES ?? [];
510
- if (!instances.includes(instance)) instances.push(instance);
511
- instanceHost.__ASKR_INSTANCES = instances;
512
- instanceHost.__ASKR_INSTANCE = instances[0] ?? instance;
513
- } catch (err) {
514
- discardLifecycleCommitBatch(lifecycleBatch);
515
- throw err;
516
- }
517
- host.finalizeReadSubscriptions(instance);
518
- host.commitRenderedComponent(instance);
519
- flushLifecycleCommitBatch(lifecycleBatch);
520
814
  } finally {
521
- restoreDomCommitScope(oldInstance);
815
+ clearRenderTracking(instance);
816
+ suspendTransaction(transaction);
522
817
  }
523
- }
524
- function commitToTarget(instance, result, host) {
525
- const renderer = getRuntimeRenderer();
526
- const target = instance.target;
527
- let oldChildren = [];
528
- let restoredOldChildren = false;
529
- try {
530
- const wasFirstMount = !instance.mounted;
531
- const oldInstance = enterDomCommitScope(instance);
532
- const executionFrame = getExecutionContextFrame(instance.ownerFrame);
533
- oldChildren = Array.from(target.childNodes);
534
- const lifecycleBatch = beginLifecycleCommitBatch();
535
- try {
536
- try {
537
- withContext(executionFrame, () => {
538
- if (!renderer.replaceComponentRange(instance, result, target)) renderer.evaluate(result, target, void 0, instance);
539
- });
540
- } catch (err) {
541
- discardLifecycleCommitBatch(lifecycleBatch);
542
- throw err;
543
- }
544
- } catch (err) {
545
- cleanupFailedCommitChildren(renderer, target, oldChildren);
546
- try {
547
- (/* @__PURE__ */ new Error()).stack;
548
- } catch (devErr) {}
549
- target.replaceChildren(...oldChildren);
550
- restoredOldChildren = true;
551
- throw err;
552
- } finally {
553
- restoreDomCommitScope(oldInstance);
818
+ const apply = () => {
819
+ if (owner.disposed || instance.owner !== owner || owner.identity !== ownershipGeneration || instance.evaluationGeneration !== evaluationGeneration || instance.renderRevision !== renderRevision) {
820
+ discardTransaction(transaction);
821
+ return;
554
822
  }
555
- host.finalizeReadSubscriptions(instance);
556
- instance.mounted = true;
557
- commitLifecycleForInstance(instance, wasFirstMount);
558
- flushLifecycleCommitBatch(lifecycleBatch);
559
- } catch (renderError) {
560
- discardCommitOperations(instance);
561
- cleanupRollbackChildren(renderer, target, oldChildren, restoredOldChildren);
562
- const rollbackErrors = [];
563
823
  try {
564
- (/* @__PURE__ */ new Error()).stack;
565
- target.replaceChildren(...oldChildren);
566
- } catch (rollbackError) {
567
- rollbackErrors.push(rollbackError);
568
- }
569
- if (rollbackErrors.length > 0) logger.error("[Askr] component rollback failed after render error:", new AggregateError(rollbackErrors, "Component rollback failed"));
570
- throw renderError;
571
- }
572
- }
573
- function cleanupFailedCommitChildren(renderer, target, oldChildren) {
574
- try {
575
- const newChildren = Array.from(target.childNodes);
576
- const preservedChildren = new Set(oldChildren);
577
- for (const node of newChildren) {
578
- if (preservedChildren.has(node)) continue;
579
- try {
580
- renderer.cleanupInstancesUnder(node);
581
- } catch (err) {
582
- logger.warn("[Askr] error cleaning up failed commit children:", err);
583
- }
584
- }
585
- } catch (err) {}
586
- }
587
- function cleanupRollbackChildren(renderer, target, oldChildren, restoredOldChildren) {
588
- try {
589
- const currentChildren = Array.from(target.childNodes);
590
- const preservedChildren = restoredOldChildren ? new Set(oldChildren) : null;
591
- for (const node of currentChildren) {
592
- if (preservedChildren?.has(node)) continue;
593
- try {
594
- renderer.cleanupInstancesUnder(node);
595
- } catch (err) {
596
- logger.warn("[Askr] error cleaning up partial children during rollback:", err);
597
- }
824
+ transaction.setDeferredNotifications(fast);
825
+ if (applyTransaction(transaction, () => {
826
+ const wasFirstMount = !owner.mounted;
827
+ if (!getRuntimeEvaluation().applyComponentResult(instance, result, fast ? "keyed-reorder" : "ordinary")) return false;
828
+ owner.mounted = true;
829
+ commitLifecycleForInstance(instance, wasFirstMount);
830
+ return true;
831
+ })) commitTransaction(transaction);
832
+ else discardTransaction(transaction);
833
+ } catch (error) {
834
+ discardTransaction(transaction);
835
+ if (!routeComponentErrorToBoundary(instance, error)) throw error;
836
+ } finally {
837
+ suspendTransaction(transaction);
598
838
  }
599
- } catch (err) {}
839
+ };
840
+ if (fast) runRuntimeWithSyncProgress(apply);
841
+ else enqueueRuntimeTask(apply);
600
842
  }
601
843
  //#endregion
602
- //#region src/runtime/component-internal.ts
844
+ //#region src/runtime/component/instance.ts
845
+ /**
846
+ * Component instance lifecycle management
847
+ * Internal only — users never see this
848
+ */
849
+ Object.defineProperty(componentRecordPrototype, DIRECT_RANGE_OWNER, { value: true });
603
850
  const PRODUCTION_BUILD_ENABLED = isProductionEnvironment();
604
851
  function ensurePendingRunTask(instance) {
605
852
  const existing = instance._pendingRunTask;
@@ -608,42 +855,41 @@ function ensurePendingRunTask(instance) {
608
855
  if (!instance.hasPendingUpdate) return;
609
856
  instance.hasPendingUpdate = false;
610
857
  if (instance.notifyUpdate === null) return;
611
- runScheduledComponent(instance, {
612
- execute: executeComponentSync,
613
- finalizeReadSubscriptions,
614
- commitRenderedComponent
615
- });
858
+ runScheduledComponent(instance, executeComponentSync);
616
859
  };
617
860
  instance._pendingRunTask = task;
618
861
  if (!instance._pendingFlushTask) instance._pendingFlushTask = task;
619
862
  return task;
620
863
  }
621
864
  function enqueueComponentRun() {
622
- if (this.hasPendingUpdate) return;
865
+ if (this.owner.disposed || this.hasPendingUpdate) return;
623
866
  this.hasPendingUpdate = true;
624
867
  enqueueRuntimeTask(ensurePendingRunTask(this));
625
868
  }
626
869
  var ComponentExecutionContext = class {
627
- constructor(instance) {
628
- this.instance = instance;
870
+ constructor(owner) {
871
+ this.owner = owner;
629
872
  }
630
873
  get signal() {
631
- return getSignalForInstance(this.instance);
874
+ return getOwnershipSignal(this.owner);
632
875
  }
633
876
  };
634
- function createComponentInstance(id, fn, props, target) {
635
- const parentInstance = getCurrentInstance();
877
+ function createComponentInstance(id, fn, props, target, lifetimeParent) {
878
+ const parentInstance = getCurrentComponentInstance();
879
+ const portalScope = parentInstance?.portalScope ?? getCurrentPortalScope();
636
880
  const instance = {
881
+ __proto__: componentRecordPrototype,
637
882
  id,
638
883
  fn,
639
884
  props,
640
885
  target,
886
+ range: void 0,
641
887
  parentInstance,
642
- portalScope: parentInstance?.portalScope ?? getCurrentPortalScope() ?? null,
643
- mounted: false,
644
- abortController: null,
888
+ portalScope: portalScope ?? null,
889
+ owner: new OwnershipRecord(),
645
890
  stateValues: void 0,
646
891
  evaluationGeneration: 0,
892
+ renderRevision: 0,
647
893
  notifyUpdate: null,
648
894
  _pendingFlushTask: void 0,
649
895
  _pendingRunTask: void 0,
@@ -659,18 +905,18 @@ function createComponentInstance(id, fn, props, target) {
659
905
  ownerFrame: null,
660
906
  ssr: false,
661
907
  cleanupStrict: false,
662
- _ownershipGeneration: {},
663
908
  isRoot: false,
664
909
  _currentRenderToken: void 0,
665
910
  lastRenderToken: 0,
666
911
  _pendingReadSources: void 0,
667
912
  _pendingReadSourceVersions: void 0,
668
- _lastReadSources: void 0,
669
913
  devWarningsEmitted: void 0,
670
914
  _portalErrorParent: void 0,
671
915
  _portalErrorParentGeneration: void 0
672
916
  };
673
917
  instance._enqueueRun = enqueueComponentRun;
918
+ bindComponentOwnership(instance);
919
+ attachOwnership(instance.owner, lifetimeParent === null ? void 0 : lifetimeParent ?? parentInstance?.owner);
674
920
  return instance;
675
921
  }
676
922
  /**
@@ -687,34 +933,10 @@ function commitRenderedComponent(instance) {
687
933
  commitRenderedComponent$1(instance);
688
934
  }
689
935
  function mountInstanceInline(instance, target) {
690
- instance.target = target;
691
- try {
692
- if (typeof Element !== "undefined" && target instanceof Element) {
693
- const host = target;
694
- const instances = host.__ASKR_INSTANCES;
695
- if (!instances) {
696
- host.__ASKR_INSTANCES = [instance];
697
- host.__ASKR_INSTANCE = instance;
698
- } else if (instances[instances.length - 1] !== instance) {
699
- const nextInstances = instances.indexOf(instance) === -1 ? instances.slice() : instances.filter((entry) => entry !== instance);
700
- nextInstances.push(instance);
701
- host.__ASKR_INSTANCES = nextInstances;
702
- host.__ASKR_INSTANCE = nextInstances[0] ?? instance;
703
- }
704
- }
705
- } catch (err) {
706
- if (isDevelopmentEnvironment()) {
707
- const componentName = instance.fn.name || instance.id;
708
- let hostName = "unknown";
709
- try {
710
- hostName = target?.tagName?.toLowerCase() || hostName;
711
- } catch {}
712
- logger.warn(`[askr] Failed to record DOM ownership for ${componentName} on <${hostName}>.`, err);
713
- }
714
- }
936
+ getRuntimeEvaluation().recordInlineComponentHost(instance, target);
715
937
  instance.notifyUpdate = instance._enqueueRun;
716
- const wasFirstMount = !instance.mounted;
717
- instance.mounted = true;
938
+ const wasFirstMount = !instance.owner.mounted;
939
+ instance.owner.mounted = true;
718
940
  commitLifecycleForInstance(instance, wasFirstMount);
719
941
  }
720
942
  /**
@@ -735,8 +957,9 @@ function renderScopedComponent(instance, startStateIndex, render) {
735
957
  didComplete = true;
736
958
  return result;
737
959
  } finally {
960
+ sealInlineRenderSnapshot(instance);
738
961
  if (!didComplete) clearRenderTracking(instance);
739
- restoreRenderScopedComponent(savedScope);
962
+ endComponentScope(savedScope);
740
963
  }
741
964
  }
742
965
  /**
@@ -758,7 +981,7 @@ function renderComponentInline(instance) {
758
981
  return result;
759
982
  } finally {
760
983
  restoreInlineRenderTracking(instance, trackingSnapshot);
761
- restoreInlineComponentScope(scopeSnapshot);
984
+ endComponentScope(scopeSnapshot);
762
985
  }
763
986
  }
764
987
  function executeComponentSync(instance) {
@@ -768,7 +991,7 @@ function executeComponentSync(instance) {
768
991
  try {
769
992
  const trackRenderTime = !PRODUCTION_BUILD_ENABLED && isDevelopmentEnvironment();
770
993
  const renderStartTime = trackRenderTime ? Date.now() : 0;
771
- const context = new ComponentExecutionContext(instance);
994
+ const context = new ComponentExecutionContext(instance.owner);
772
995
  const result = callWithContext(getExecutionContextFrame(instance.ownerFrame), instance.fn, instance.props, context);
773
996
  if (trackRenderTime) {
774
997
  const renderTime = Date.now() - renderStartTime;
@@ -778,8 +1001,9 @@ function executeComponentSync(instance) {
778
1001
  didComplete = true;
779
1002
  return result;
780
1003
  } finally {
1004
+ sealInlineRenderSnapshot(instance);
781
1005
  if (!didComplete) discardCommitOperations(instance);
782
- exitComponentExecutionScope(savedPortalScope);
1006
+ endComponentScope(savedPortalScope);
783
1007
  }
784
1008
  }
785
1009
  /**
@@ -788,22 +1012,10 @@ function executeComponentSync(instance) {
788
1012
  * Single entry point to avoid lifecycle divergence.
789
1013
  */
790
1014
  function executeComponent(instance) {
791
- instance.abortController = null;
792
1015
  instance.notifyUpdate = instance._enqueueRun;
793
1016
  instance.hasPendingUpdate = true;
794
1017
  enqueueRuntimeTask(ensurePendingRunTask(instance));
795
1018
  }
796
- /**
797
- * Finalize read subscriptions for an instance after a successful commit.
798
- * - Update per-state readers map to point to this instance's last committed token
799
- * - Remove this instance from states it no longer reads
800
- * This is deterministic and runs synchronously with commit to ensure
801
- * subscribers are only notified when they actually read a state in their
802
- * last committed render.
803
- */
804
- function finalizeReadSubscriptions(instance) {
805
- finalizeReadableSubscriptions(instance);
806
- }
807
1019
  function warnInstanceOnce(instance, key, message) {
808
1020
  if (isProductionEnvironment()) return;
809
1021
  const warnings = instance.devWarningsEmitted ??= /* @__PURE__ */ new Set();
@@ -812,4 +1024,4 @@ function warnInstanceOnce(instance, key, message) {
812
1024
  logger.warn(message);
813
1025
  }
814
1026
  //#endregion
815
- export { withContext as C, withAsyncResourceContext as S, getVNodeContextFrame as _, registerCommitOperation as a, readScope as b, createBoundaryReset as c, registerCommitOperationForInstance as d, configureRenderDiagnostics as f, getExecutionContextFrame as g, getCurrentContextFrame as h, mountInstanceInline as i, reportBoundaryError as l, defineScope as m, createComponentInstance as n, renderComponentInline as o, callWithContext as p, executeComponent as r, renderScopedComponent as s, captureInlineRenderSnapshot as t, routeComponentErrorToBoundary as u, haveEquivalentContextFrames as v, rebaseVNodeTreeWithContextFrame as x, markVNodeTreeWithContextFrame as y };
1027
+ export { captureInlineRenderSnapshot$1 as A, rebaseVNodeTreeWithContextFrame as C, createComponentOwnership as D, cleanupComponentGeneration as E, captureGenerationExecution as F, DIRECT_RANGE_OWNER as I, incDevCounter as L, ASYNC_COMPONENT_MESSAGE as M, assertSyncComponentResult as N, registerOwnedChildScope as O, isPromiseLike as P, setDevValue as R, markVNodeTreeWithContextFrame as S, cleanupComponent as T, haveEquivalentContextFrames as _, registerCommitOperation as a, withContext as b, createBoundaryReset as c, registerCommitOperationForInstance as d, configureRenderDiagnostics as f, getExecutionContextFrame as g, getCurrentContextFrame as h, mountInstanceInline as i, finalizeInlineReadSubscriptions as j, resetComponentWork as k, reportBoundaryError as l, defineScope as m, createComponentInstance as n, renderComponentInline as o, callWithContext as p, executeComponent as r, renderScopedComponent as s, captureInlineRenderSnapshot as t, routeComponentErrorToBoundary as u, readScope as v, bindComponentOwnership as w, getVNodeContextFrame as x, withAsyncResourceContext as y };