@askrjs/askr 0.3.0 → 0.4.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.
- package/CHANGELOG.md +874 -0
- package/README.md +61 -29
- package/capabilities.json +19 -9
- package/dist/actions/index.js +56 -12
- package/dist/benchmark.js +10 -15
- package/dist/boot/index.d.ts +3 -2
- package/dist/boot/index.js +1 -1
- package/dist/boot-DaoTYoCw.js +3989 -0
- package/dist/browser-activity-CB8e-V4f.js +220 -0
- package/dist/components/index.d.ts +8 -1
- package/dist/components/index.js +1 -43
- package/dist/{aria-hKjThHcp.js → compose-ref-DWzdbxsD.js} +41 -4
- package/dist/control/index.d.ts +2 -0
- package/dist/control/index.js +1 -1
- package/dist/control-nfpT2fbK.js +209 -0
- package/dist/core.d.ts +5 -9
- package/dist/csp-nonce-DwGw1A6Q.js +35 -0
- package/dist/data/index.js +3 -3
- package/dist/{data-2edW0jhF.js → data-BCwClJiF.js} +283 -94
- package/dist/data-runtime-C1bFAlba.js +242 -0
- package/dist/{deferred-CbgNhf67.js → deferred-bEEHHvic.js} +42 -20
- package/dist/domains/actions.d.ts +8 -3
- package/dist/domains/component.d.ts +1 -107
- package/dist/domains/context.d.ts +0 -15
- package/dist/domains/control.d.ts +36 -249
- package/dist/domains/data.d.ts +31 -13
- package/dist/domains/diagnostics.d.ts +1 -2
- package/dist/domains/lifecycle.d.ts +2 -5
- package/dist/domains/refs.d.ts +0 -2
- package/dist/domains/routing.d.ts +43 -8
- package/dist/domains/scheduler.d.ts +1 -76
- package/dist/domains/server.d.ts +5 -2
- package/dist/domains/state.d.ts +2 -5
- package/dist/domains/telemetry.d.ts +0 -2
- package/dist/elements.d.ts +214 -51
- package/dist/error-boundary-Bpwofwps.js +293 -0
- package/dist/foundations/icon/index.d.ts +0 -58
- package/dist/foundations/icon/index.js +2 -2
- package/dist/foundations/index.js +2 -1
- package/dist/foundations/interactions/index.js +1 -1
- package/dist/foundations/state/index.d.ts +3 -3
- package/dist/foundations/state/index.js +5 -3
- package/dist/foundations/structures/index.js +2 -1
- package/dist/foundations/utilities/index.d.ts +2 -0
- package/dist/foundations/utilities/index.js +1 -2
- package/dist/fx/index.d.ts +31 -58
- package/dist/fx/index.js +313 -195
- package/dist/hooks-BimKStr4.js +202 -0
- package/dist/index.d.ts +11 -74
- package/dist/index.js +8 -447
- package/dist/instance-BAnfmXOR.js +988 -0
- package/dist/{interactions-CTeACdT_.js → interactions-D2BoREb-.js} +3 -2
- package/dist/jsx-dev-runtime.d.ts +41 -18
- package/dist/jsx-dev-runtime.js +1 -6
- package/dist/{jsx-runtime-CPJXAOBF.js → jsx-runtime-C4idqHY0.js} +18 -7
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx.d.ts +61 -37
- package/dist/{manifest-D1P3UNWV.js → manifest-CW9gyNBY.js} +3 -3
- package/dist/{navigate-prC5V8XV.js → navigate-CP_0Zy5U.js} +454 -87
- package/dist/navigation.d.ts +12 -3
- package/dist/peer-types.d.ts +8 -0
- package/dist/portal-DuOKfnLa.js +349 -0
- package/dist/promise-Dz8iIHAm.js +16 -0
- package/dist/query-registry-WMCN0BJL.js +320 -0
- package/dist/readable-DFWOsTac.js +21 -0
- package/dist/{render-context-B7ohlh6t.js → render-context-DGHnEveC.js} +27 -11
- package/dist/render-sync-IC5lMFpq.js +1240 -0
- package/dist/resolution-Cx82-xjW.js +1244 -0
- package/dist/resource-CLjB7RBQ.js +377 -0
- package/dist/resources/index.d.ts +21 -11
- package/dist/resources/index.js +45 -244
- package/dist/router/index.d.ts +14 -5
- package/dist/router/index.js +22 -53
- package/dist/scope-CwpVSHVf.js +55 -0
- package/dist/{shared-kU8yvryp.js → shared-O2ZnmYAf.js} +1 -7
- package/dist/{snapshot-source-An4iKajG.js → snapshot-Cjx4N988.js} +6 -1
- package/dist/ssg/index.d.ts +1 -2
- package/dist/ssg/index.js +5 -13
- package/dist/ssr/index.d.ts +26 -28
- package/dist/ssr/index.js +4 -4
- package/dist/{ssr-CiNm6Vzl.js → ssr-BJ8ug7zH.js} +133 -122
- package/dist/ssr-DoV-vJ-5.js +229 -0
- package/dist/state-DWO1KzkX.js +232 -0
- package/dist/structures-D4dDMqHX.js +231 -0
- package/dist/testing/index.d.ts +8 -4
- package/dist/testing/index.js +29 -34
- package/dist/url-CnbfpX0K.js +185 -0
- package/dist/utilities.d.ts +48 -2
- package/dist/verify-hydration-DpVaDnqz.js +152 -0
- package/package.json +19 -9
- package/dist/access-CEA2pOry.js +0 -1046
- package/dist/activity-oy2YFTFF.js +0 -201
- package/dist/boot-BMBMWUGI.js +0 -1084
- package/dist/capabilities-Bbf0mlp9.js +0 -42
- package/dist/compose-ref-v0qGlHoN.js +0 -26
- package/dist/control-BR_mrX__.js +0 -173
- package/dist/control-C-ApnFs1.js +0 -20
- package/dist/csp-nonce-BfFWcd0w.js +0 -173
- package/dist/data-runtime-CxoY98lX.js +0 -149
- package/dist/default-portal-runtime-DvMvWJVp.js +0 -20
- package/dist/dom-renderer.d.ts +0 -77
- package/dist/domains/renderer.d.ts +0 -127
- package/dist/eager-control.d.ts +0 -8
- package/dist/effect-C3Zsc1k6.js +0 -292
- package/dist/for-state-BDykeOJL.js +0 -1753
- package/dist/instance-VAFYVJOa.js +0 -1027
- package/dist/notify-DxxuDPeY.js +0 -266
- package/dist/portal-w3oQ6oQU.js +0 -29
- package/dist/query-registry-LrYpQsDJ.js +0 -83
- package/dist/render-resolved-BC0W7_5b.js +0 -1123
- package/dist/renderer-CT0HeY58.js +0 -8623
- package/dist/resolution-3DskUkjG.js +0 -577
- package/dist/resource-18-sFRl9.js +0 -344
- package/dist/route-matching-CUzZ31gT.js +0 -551
- package/dist/router-internal-7nuNEHfG.js +0 -36
- package/dist/scope-Cq_iYbTR.js +0 -403
- package/dist/selector-BSPVkjKP.js +0 -311
- package/dist/ssr-EPjwJH5R.js +0 -29
- package/dist/state-BXJfudq1.js +0 -91
- package/dist/structures-CjEzfj4h.js +0 -654
- package/dist/timer-C7uqnJVt.js +0 -85
- package/dist/verify-hydration-ikaxotf7.js +0 -27
- package/dist/vnode-D24p6IW2.js +0 -7
package/dist/scope-Cq_iYbTR.js
DELETED
|
@@ -1,403 +0,0 @@
|
|
|
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 };
|