@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.
- package/CHANGELOG.md +11 -0
- package/dist/access-CEA2pOry.js +1046 -0
- package/dist/actions/index.d.ts +16 -2
- package/dist/actions/index.js +5 -5
- package/dist/{activity-FirwPXA_.js → activity-oy2YFTFF.js} +10 -16
- package/dist/benchmark.js +8 -9
- package/dist/boot/index.d.ts +19 -9
- package/dist/boot/index.js +1 -1
- package/dist/{boot-tWyF6121.js → boot-BMBMWUGI.js} +680 -441
- package/dist/capabilities-Bbf0mlp9.js +42 -0
- package/dist/components/index.d.ts +11 -8
- package/dist/components/index.js +1 -1
- package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
- package/dist/control/index.d.ts +20 -2
- package/dist/control/index.js +1 -1
- package/dist/{control-C-wSaq9V.js → control-BR_mrX__.js} +4 -4
- package/dist/core.d.ts +163 -0
- package/dist/csp-nonce-BfFWcd0w.js +173 -0
- package/dist/data/index.d.ts +74 -2
- package/dist/data/index.js +3 -3
- package/dist/{data-ghKopAbp.js → data-2edW0jhF.js} +108 -122
- package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
- package/dist/{deferred-CxjWCkIn.js → deferred-CbgNhf67.js} +5 -5
- package/dist/dom-renderer.d.ts +77 -0
- package/dist/domains/actions.d.ts +70 -0
- package/dist/domains/component.d.ts +119 -0
- package/dist/domains/context.d.ts +73 -0
- package/dist/domains/control.d.ts +328 -0
- package/dist/domains/data.d.ts +461 -0
- package/dist/domains/diagnostics.d.ts +21 -0
- package/dist/domains/lifecycle.d.ts +112 -0
- package/dist/domains/refs.d.ts +18 -0
- package/dist/domains/renderer.d.ts +127 -0
- package/dist/domains/routing.d.ts +501 -0
- package/dist/domains/scheduler.d.ts +79 -0
- package/dist/domains/server.d.ts +112 -0
- package/dist/domains/state.d.ts +129 -0
- package/dist/domains/telemetry.d.ts +29 -0
- package/dist/eager-control.d.ts +8 -0
- package/dist/{effect-CNwstBBD.js → effect-C3Zsc1k6.js} +14 -41
- package/dist/{types-DWVrKn9N.d.ts → elements.d.ts} +79 -42
- package/dist/{for-internal-DyBHfKJA.js → for-state-BDykeOJL.js} +598 -494
- package/dist/foundations/icon/index.d.ts +67 -16
- package/dist/foundations/icon/index.js +1 -1
- package/dist/foundations/index.d.ts +26 -3
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/index.d.ts +73 -34
- package/dist/foundations/interactions/index.js +1 -1
- package/dist/foundations/state/index.d.ts +12 -5
- package/dist/foundations/state/index.js +1 -1
- package/dist/foundations/structures/index.d.ts +44 -3
- package/dist/foundations/structures/index.js +1 -1
- package/dist/foundations/utilities/index.d.ts +34 -3
- package/dist/foundations/utilities/index.js +1 -1
- package/dist/fx/index.d.ts +72 -25
- package/dist/fx/index.js +8 -8
- package/dist/index.d.ts +121 -4
- package/dist/index.js +316 -47
- package/dist/{component-internal-C4hKKQBF.js → instance-VAFYVJOa.js} +495 -283
- package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
- package/dist/jsx-dev-runtime.d.ts +51 -11
- package/dist/jsx-globals.d.ts +2 -0
- package/dist/jsx-runtime-CPJXAOBF.js +43 -0
- package/dist/jsx-runtime.d.ts +17 -3
- package/dist/jsx-runtime.js +2 -42
- package/dist/jsx.d.ts +108 -0
- package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
- package/dist/{navigate-ZZu1IV0B.js → navigate-prC5V8XV.js} +125 -472
- package/dist/{navigate-F4sHgWbw.d.ts → navigation.d.ts} +8 -8
- package/dist/{readable-Di1fzSwm.js → notify-DxxuDPeY.js} +96 -34
- package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
- package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
- package/dist/{ssr-Doog-AfJ.js → render-resolved-BC0W7_5b.js} +165 -558
- package/dist/{renderer-Cl23O0hV.js → renderer-CT0HeY58.js} +6825 -5692
- package/dist/{resolution-ClD-K7Lz.js → resolution-3DskUkjG.js} +189 -180
- package/dist/{resource-operation-Vz1S5h2k.js → resource-18-sFRl9.js} +98 -58
- package/dist/resources/index.d.ts +64 -12
- package/dist/resources/index.js +214 -8
- package/dist/route-activity.d.ts +21 -0
- package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
- package/dist/router/index.d.ts +378 -79
- package/dist/router/index.js +9 -9
- package/dist/router-internal-7nuNEHfG.js +36 -0
- package/dist/scope-Cq_iYbTR.js +403 -0
- package/dist/{selector-CsKuomw0.js → selector-BSPVkjKP.js} +26 -27
- package/dist/{shared-CYBH3F8I.js → shared-kU8yvryp.js} +3 -6
- package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
- package/dist/ssg/index.d.ts +51 -15
- package/dist/ssg/index.js +269 -209
- package/dist/ssr/index.d.ts +121 -68
- package/dist/ssr/index.js +2 -1
- package/dist/ssr-CiNm6Vzl.js +393 -0
- package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
- package/dist/{state-BGJgYSyQ.js → state-BXJfudq1.js} +10 -15
- package/dist/{structures-DFyK5AdQ.js → structures-CjEzfj4h.js} +37 -57
- package/dist/{index-CTpMmzgN.d.ts → structures.d.ts} +57 -36
- package/dist/testing/index.d.ts +123 -24
- package/dist/testing/index.js +24 -61
- package/dist/timer-C7uqnJVt.js +85 -0
- package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
- package/dist/{verify-hydration-BZPJ_kYa.js → verify-hydration-ikaxotf7.js} +8 -5
- package/package.json +12 -14
- package/dist/access-BucjYZcX.js +0 -509
- package/dist/activity-DooIuxQO.d.ts +0 -14
- package/dist/benchmark.d.ts +0 -26
- package/dist/cleanup-TXSsApEl.js +0 -535
- package/dist/component-cleanup-jdbgjkT1.js +0 -143
- package/dist/component-scope-4I3yEMkb.js +0 -195
- package/dist/control-Cxag1yqV.d.ts +0 -8
- package/dist/csp-nonce-9NFUb7hJ.js +0 -72
- package/dist/css-BuPaTOfe.js +0 -70
- package/dist/fastlane-BKZduiBQ.js +0 -166
- package/dist/index-Dgjbo2gU.d.ts +0 -1456
- package/dist/jsx-runtime-Cg7GqY1S.d.ts +0 -2
- package/dist/jsx-runtime-gVIaTPw0.d.ts +0 -38
- package/dist/lifecycle-batch-63aXFf2S.js +0 -253
- package/dist/lifecycle-operations-Q0k3EFnG.js +0 -287
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
//#region src/runtime/state.ts
|
|
1
|
+
import { T as isProductionEnvironment } from "./access-CEA2pOry.js";
|
|
2
|
+
import { f as getCurrentComponentInstance, i as claimHookIndex } from "./scope-Cq_iYbTR.js";
|
|
3
|
+
import { a as deferCommitNotification, t as notifyReadableSource, v as recordReadableRead } from "./notify-DxxuDPeY.js";
|
|
4
|
+
//#region src/runtime/reactivity/state.ts
|
|
6
5
|
/**
|
|
7
6
|
* State primitive for Askr components
|
|
8
7
|
* Optimized for minimal overhead and fast updates
|
|
@@ -42,7 +41,7 @@ import { l as notifyReadableReaders, o as markReactivePropsDirtySource, s as mar
|
|
|
42
41
|
* ```
|
|
43
42
|
*/
|
|
44
43
|
function state(initialValue) {
|
|
45
|
-
const instance =
|
|
44
|
+
const instance = getCurrentComponentInstance();
|
|
46
45
|
if (!instance) throw new Error("state() can only be called during component render execution. Move state() calls to the top level of your component function.");
|
|
47
46
|
const index = claimHookIndex(instance, "state");
|
|
48
47
|
const stateValues = instance.stateValues ??= [];
|
|
@@ -71,21 +70,17 @@ function createStateCell(initialValue, instance) {
|
|
|
71
70
|
read._unusedStateDiagnosticEligible = !isProductionEnvironment();
|
|
72
71
|
read._owner = instance;
|
|
73
72
|
read.set = (newValueOrUpdater) => {
|
|
74
|
-
if (
|
|
73
|
+
if (getCurrentComponentInstance() !== null) throw new Error("[Askr] state.set() cannot be called during component render. State mutations during render break the actor model and cause infinite loops. Move state updates to event handlers or use conditional rendering instead.");
|
|
75
74
|
let newValue;
|
|
76
75
|
if (typeof newValueOrUpdater === "function") newValue = newValueOrUpdater(value);
|
|
77
76
|
else newValue = newValueOrUpdater;
|
|
78
77
|
if (Object.is(value, newValue)) return;
|
|
79
|
-
if (isBulkCommitActive()) {
|
|
80
|
-
value = newValue;
|
|
81
|
-
deferBulkCommitReadableNotification(read);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
78
|
value = newValue;
|
|
85
|
-
|
|
86
|
-
markReactivePropsDirtySource(read);
|
|
87
|
-
notifyReadableReaders(read);
|
|
79
|
+
if (!deferCommitNotification(read, notify)) notify();
|
|
88
80
|
};
|
|
81
|
+
function notify() {
|
|
82
|
+
notifyReadableSource(read);
|
|
83
|
+
}
|
|
89
84
|
read[Symbol.iterator] = function* () {
|
|
90
85
|
yield read;
|
|
91
86
|
yield read.set;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as getCurrentComponentInstance,
|
|
1
|
+
import { i as getRuntimeCleanup } from "./access-CEA2pOry.js";
|
|
2
|
+
import { O as ownCleanup, f as getCurrentComponentInstance, p as getCurrentPortalScope } from "./scope-Cq_iYbTR.js";
|
|
3
|
+
import { c as registerCommitEffect, s as getCurrentCommitTransaction, t as notifyReadableSource, v as recordReadableRead } from "./notify-DxxuDPeY.js";
|
|
3
4
|
import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-DRS-qjiN.js";
|
|
4
|
-
import { l as notifyReadableReaders, o as markReactivePropsDirtySource, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-Di1fzSwm.js";
|
|
5
|
-
import { t as cleanupComponent } from "./component-cleanup-jdbgjkT1.js";
|
|
6
|
-
import { c as getCurrentLifecycleCommitBatch, u as registerLifecycleTransaction } from "./lifecycle-batch-63aXFf2S.js";
|
|
7
5
|
import { n as getActiveRenderContext } from "./render-context-B7ohlh6t.js";
|
|
8
6
|
import { i as createSSRPortalHostToken, n as SSR_PORTAL_HOST, r as createSSRPortalAnchorToken, t as SSR_PORTAL_ANCHOR } from "./portal-w3oQ6oQU.js";
|
|
9
7
|
import { i as registerDefaultPortalRuntime } from "./default-portal-runtime-DvMvWJVp.js";
|
|
@@ -108,18 +106,8 @@ function Presence({ present, children }) {
|
|
|
108
106
|
};
|
|
109
107
|
}
|
|
110
108
|
//#endregion
|
|
111
|
-
//#region src/runtime/portal.ts
|
|
109
|
+
//#region src/runtime/portal/ssr.ts
|
|
112
110
|
const DEFAULT_SSR_PORTAL_KEY = {};
|
|
113
|
-
function setPortalErrorParent(host, owner) {
|
|
114
|
-
if (!host) return;
|
|
115
|
-
if (owner && owner.instance._ownershipGeneration === owner.generation && owner.instance.notifyUpdate !== null) {
|
|
116
|
-
host._portalErrorParent = owner.instance;
|
|
117
|
-
host._portalErrorParentGeneration = owner.generation;
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
host._portalErrorParent = null;
|
|
121
|
-
host._portalErrorParentGeneration = void 0;
|
|
122
|
-
}
|
|
123
111
|
function getSSRPortalSlot(key) {
|
|
124
112
|
const context = getActiveRenderContext();
|
|
125
113
|
if (context?.mode !== "ssr") return null;
|
|
@@ -168,6 +156,18 @@ function createSSRPortalAnchor() {
|
|
|
168
156
|
props: { token }
|
|
169
157
|
};
|
|
170
158
|
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/runtime/portal/lifetime.ts
|
|
161
|
+
function setPortalErrorParent(host, owner) {
|
|
162
|
+
if (!host) return;
|
|
163
|
+
if (owner && owner.instance.owner.identity === owner.generation && owner.instance.notifyUpdate !== null) {
|
|
164
|
+
host._portalErrorParent = owner.instance;
|
|
165
|
+
host._portalErrorParentGeneration = owner.generation;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
host._portalErrorParent = null;
|
|
169
|
+
host._portalErrorParentGeneration = void 0;
|
|
170
|
+
}
|
|
171
171
|
function createPortalSlot() {
|
|
172
172
|
let currentValue;
|
|
173
173
|
let currentOwner = null;
|
|
@@ -184,15 +184,15 @@ function createPortalSlot() {
|
|
|
184
184
|
currentOwner = owner;
|
|
185
185
|
if (Object.is(currentValue, value) && !ownerChanged) return;
|
|
186
186
|
currentValue = value;
|
|
187
|
-
|
|
188
|
-
markReactivePropsDirtySource(source);
|
|
189
|
-
notifyReadableReaders(source);
|
|
187
|
+
notifyReadableSource(source);
|
|
190
188
|
},
|
|
191
189
|
getOwner() {
|
|
192
190
|
return currentOwner;
|
|
193
191
|
}
|
|
194
192
|
};
|
|
195
193
|
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/runtime/portal/explicit.ts
|
|
196
196
|
/** Create a new named {@link Portal} channel with its own host and content. */
|
|
197
197
|
function definePortal() {
|
|
198
198
|
const ssrPortalKey = {};
|
|
@@ -210,7 +210,7 @@ function definePortal() {
|
|
|
210
210
|
const owner = getCurrentComponentInstance();
|
|
211
211
|
slot.write(props.children, owner ? {
|
|
212
212
|
instance: owner,
|
|
213
|
-
generation: owner.
|
|
213
|
+
generation: owner.owner.identity
|
|
214
214
|
} : null);
|
|
215
215
|
return null;
|
|
216
216
|
};
|
|
@@ -229,6 +229,8 @@ function definePortal() {
|
|
|
229
229
|
};
|
|
230
230
|
return PortalHostFallback;
|
|
231
231
|
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/runtime/portal/portal.ts
|
|
232
234
|
let _defaultPortalStates = /* @__PURE__ */ new Map();
|
|
233
235
|
let _hasPendingDefaultPortalValue = false;
|
|
234
236
|
let _pendingDefaultPortalValue = void 0;
|
|
@@ -265,17 +267,13 @@ function readExplicitDefaultPortalHosts(state) {
|
|
|
265
267
|
return state.explicitHostSource();
|
|
266
268
|
}
|
|
267
269
|
function notifyExplicitDefaultPortalHostReaders(state) {
|
|
268
|
-
|
|
269
|
-
markReactivePropsDirtySource(state.explicitHostSource);
|
|
270
|
-
notifyReadableReaders(state.explicitHostSource);
|
|
270
|
+
notifyReadableSource(state.explicitHostSource);
|
|
271
271
|
}
|
|
272
272
|
function setDefaultPortalOwner(state, owner) {
|
|
273
273
|
if (state.owner?.instance === owner?.instance && state.owner?.generation === owner?.generation) return;
|
|
274
274
|
state.owner = owner;
|
|
275
275
|
state.ownerVersion += 1;
|
|
276
|
-
|
|
277
|
-
markReactivePropsDirtySource(state.ownerSource);
|
|
278
|
-
notifyReadableReaders(state.ownerSource);
|
|
276
|
+
notifyReadableSource(state.ownerSource);
|
|
279
277
|
}
|
|
280
278
|
function createDefaultPortalState() {
|
|
281
279
|
const state = {
|
|
@@ -306,25 +304,7 @@ function isEmptyPortalValue(value) {
|
|
|
306
304
|
return value === null || value === void 0 || value === false;
|
|
307
305
|
}
|
|
308
306
|
function detachDefaultPortalHostOutput(state) {
|
|
309
|
-
|
|
310
|
-
const target = host?.target;
|
|
311
|
-
const parent = target?.parentNode;
|
|
312
|
-
if (!host || !target || !parent) return;
|
|
313
|
-
const portalHost = target;
|
|
314
|
-
const hostedInstances = new Set(portalHost.__ASKR_INSTANCES ?? []);
|
|
315
|
-
if (portalHost.__ASKR_INSTANCE) hostedInstances.add(portalHost.__ASKR_INSTANCE);
|
|
316
|
-
for (const instance of hostedInstances) if (instance !== host) cleanupComponent(instance);
|
|
317
|
-
try {
|
|
318
|
-
delete portalHost.__ASKR_INSTANCE;
|
|
319
|
-
delete portalHost.__ASKR_INSTANCES;
|
|
320
|
-
delete portalHost.__ASKR_WRAPPER_HOST;
|
|
321
|
-
} catch {}
|
|
322
|
-
getRuntimeRenderer().teardownNodeSubtree(target);
|
|
323
|
-
const placeholder = document.createComment("");
|
|
324
|
-
placeholder.__ASKR_INSTANCE = host;
|
|
325
|
-
parent.replaceChild(placeholder, target);
|
|
326
|
-
host.target = null;
|
|
327
|
-
host._placeholder = placeholder;
|
|
307
|
+
if (state.host) getRuntimeCleanup().detachPortalHostOutput(state.host.instance);
|
|
328
308
|
}
|
|
329
309
|
function applyDefaultPortalWrite(state, children, owner) {
|
|
330
310
|
state.portal.render({ children });
|
|
@@ -333,8 +313,8 @@ function applyDefaultPortalWrite(state, children, owner) {
|
|
|
333
313
|
}
|
|
334
314
|
function isStaleDefaultPortalScope(scope) {
|
|
335
315
|
if (!isComponentPortalScope(scope)) return false;
|
|
336
|
-
if (
|
|
337
|
-
return scope.mounted === false;
|
|
316
|
+
if (getRuntimeCleanup().isComponentHostDetached(scope)) return true;
|
|
317
|
+
return scope.owner.mounted === false;
|
|
338
318
|
}
|
|
339
319
|
function pruneStaleDefaultPortalScopes() {
|
|
340
320
|
if (_defaultPortalStates.size === 0) return;
|
|
@@ -367,9 +347,9 @@ function writeDefaultPortal(props, owner) {
|
|
|
367
347
|
const state = getDefaultPortalState(scope);
|
|
368
348
|
const capturedOwner = owner ? {
|
|
369
349
|
instance: owner,
|
|
370
|
-
generation: owner.
|
|
350
|
+
generation: owner.owner.identity
|
|
371
351
|
} : null;
|
|
372
|
-
const batch =
|
|
352
|
+
const batch = getCurrentCommitTransaction();
|
|
373
353
|
if (batch) {
|
|
374
354
|
let writes = _batchPortalWrites.get(batch);
|
|
375
355
|
if (!writes) {
|
|
@@ -388,7 +368,7 @@ function writeDefaultPortal(props, owner) {
|
|
|
388
368
|
children: props.children,
|
|
389
369
|
batch
|
|
390
370
|
};
|
|
391
|
-
if (
|
|
371
|
+
if (registerCommitEffect(state, () => {
|
|
392
372
|
if (_batchPortalWrites.get(batch)?.get(state) !== transaction) return;
|
|
393
373
|
clearTrackedBatchPortalWrite(transaction);
|
|
394
374
|
applyDefaultPortalWrite(state, transaction.children, transaction.owner);
|
|
@@ -418,7 +398,7 @@ function writeDefaultPortal(props, owner) {
|
|
|
418
398
|
owner: capturedOwner,
|
|
419
399
|
children: props.children
|
|
420
400
|
};
|
|
421
|
-
if (
|
|
401
|
+
if (registerCommitEffect(transaction, () => {
|
|
422
402
|
if (_pendingDefaultPortalWrites.get(state) !== transaction) return;
|
|
423
403
|
_pendingDefaultPortalWrites.delete(state);
|
|
424
404
|
_hasPendingDefaultPortalValue = false;
|
|
@@ -443,7 +423,7 @@ function applyPendingDefaultPortalValue(scope) {
|
|
|
443
423
|
_pendingDefaultPortalValue = void 0;
|
|
444
424
|
}
|
|
445
425
|
function getPendingDefaultPortalWrite(state) {
|
|
446
|
-
let batch =
|
|
426
|
+
let batch = getCurrentCommitTransaction();
|
|
447
427
|
while (batch) {
|
|
448
428
|
const pending = _batchPortalWrites.get(batch)?.get(state);
|
|
449
429
|
if (pending) return pending;
|
|
@@ -459,10 +439,10 @@ function registerDefaultPortalOwner(owner) {
|
|
|
459
439
|
const scope = resolveDefaultPortalScope(owner);
|
|
460
440
|
if (!scope) return;
|
|
461
441
|
const state = getDefaultPortalState(scope);
|
|
462
|
-
const generation = owner.
|
|
442
|
+
const generation = owner.owner.identity;
|
|
463
443
|
if (state.cleanupOwners.has(generation)) return;
|
|
464
444
|
state.cleanupOwners.add(generation);
|
|
465
|
-
(owner.
|
|
445
|
+
ownCleanup(owner.owner, () => {
|
|
466
446
|
const currentState = _defaultPortalStates.get(scope);
|
|
467
447
|
if (!currentState) return;
|
|
468
448
|
if (currentState.owner?.instance === owner && currentState.owner.generation === generation && !hasPendingReplacementPortalOwner(currentState, owner, generation)) applyDefaultPortalWrite(currentState, void 0, null);
|
|
@@ -471,14 +451,14 @@ function registerDefaultPortalOwner(owner) {
|
|
|
471
451
|
}
|
|
472
452
|
function registerExplicitDefaultPortalHost(scope, state, owner) {
|
|
473
453
|
if (!owner) return;
|
|
474
|
-
const generation = owner.
|
|
454
|
+
const generation = owner.owner.identity;
|
|
475
455
|
if (!state.explicitHostOwners.has(generation)) {
|
|
476
456
|
state.explicitHostOwners.set(generation, owner);
|
|
477
457
|
notifyExplicitDefaultPortalHostReaders(state);
|
|
478
458
|
}
|
|
479
459
|
if (!state.explicitHostCleanupOwners.has(generation)) {
|
|
480
460
|
state.explicitHostCleanupOwners.add(generation);
|
|
481
|
-
(owner.
|
|
461
|
+
ownCleanup(owner.owner, () => {
|
|
482
462
|
if (_defaultPortalStates.get(scope) !== state) return;
|
|
483
463
|
state.explicitHostCleanupOwners.delete(generation);
|
|
484
464
|
if (state.explicitHostOwners.get(generation) === owner && state.explicitHostOwners.delete(generation)) notifyExplicitDefaultPortalHostReaders(state);
|
|
@@ -510,7 +490,7 @@ const DefaultPortal = (() => {
|
|
|
510
490
|
const state = getDefaultPortalState(scope);
|
|
511
491
|
state.host = owner ? {
|
|
512
492
|
instance: owner,
|
|
513
|
-
generation: owner.
|
|
493
|
+
generation: owner.owner.identity
|
|
514
494
|
} : null;
|
|
515
495
|
if (!(props?.__askrAutoDefaultPortal === true)) registerExplicitDefaultPortalHost(scope, state, owner);
|
|
516
496
|
else if (readExplicitDefaultPortalHosts(state) > 0) return null;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//#region src/foundations/structures/layout.d.ts
|
|
1
|
+
import { RenderableChild } from './core.js';
|
|
2
|
+
import { JSXElement } from './elements.js';
|
|
4
3
|
/**
|
|
5
4
|
* Layout helper.
|
|
6
5
|
*
|
|
@@ -25,31 +24,36 @@ import { r as JSXElement } from "./types-DWVrKn9N.js";
|
|
|
25
24
|
* and deterministic — no merging or composition.
|
|
26
25
|
*/
|
|
27
26
|
/** A component that receives its route children via `props.children`. */
|
|
28
|
-
type LayoutComponent<P = object> = (
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
type LayoutComponent<P = object> = (
|
|
28
|
+
props: P & {
|
|
29
|
+
children?: RenderableChild;
|
|
30
|
+
}
|
|
31
|
+
) => unknown;
|
|
31
32
|
/**
|
|
32
33
|
* Wrap a {@link LayoutComponent} so it can be invoked as `(children, props)`,
|
|
33
34
|
* matching route layout conventions.
|
|
34
35
|
*/
|
|
35
|
-
declare function layout<P = object>(
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
declare function layout<P = object>(
|
|
37
|
+
Layout: LayoutComponent<P>
|
|
38
|
+
): (children?: RenderableChild, props?: P) => unknown;
|
|
38
39
|
/** Check whether `value` is a JSX element vnode. */
|
|
39
40
|
declare function isElement(value: unknown): value is JSXElement;
|
|
40
41
|
/** Clone a JSX element, shallow-merging `props` over its existing props. */
|
|
41
|
-
declare function cloneElement(
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
declare function cloneElement(
|
|
43
|
+
element: JSXElement,
|
|
44
|
+
props: Record<string, unknown>
|
|
45
|
+
): JSXElement;
|
|
44
46
|
/** Props for {@link Slot}: `asChild` selects prop-merging vs. fragment mode. */
|
|
45
|
-
type SlotProps =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
type SlotProps =
|
|
48
|
+
| {
|
|
49
|
+
asChild: true;
|
|
50
|
+
children: JSXElement;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
| {
|
|
54
|
+
asChild?: false;
|
|
55
|
+
children?: RenderableChild;
|
|
56
|
+
};
|
|
53
57
|
/**
|
|
54
58
|
* Slot
|
|
55
59
|
*
|
|
@@ -71,8 +75,6 @@ type SlotProps = {
|
|
|
71
75
|
* Runtime validates with isElement() check.
|
|
72
76
|
*/
|
|
73
77
|
declare function Slot(props: SlotProps): JSXElement | null;
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/foundations/structures/presence.d.ts
|
|
76
78
|
/** Props for {@link Presence}. */
|
|
77
79
|
interface PresenceProps {
|
|
78
80
|
/** Whether the children should be mounted, or a function returning it. */
|
|
@@ -102,25 +104,26 @@ interface PresenceProps {
|
|
|
102
104
|
* children are removed immediately. Animation must be layered above
|
|
103
105
|
* this primitive.
|
|
104
106
|
*/
|
|
105
|
-
declare function Presence({
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
declare function Presence({
|
|
108
|
+
present,
|
|
109
|
+
children,
|
|
110
|
+
}: PresenceProps): JSXElement | null;
|
|
108
111
|
/**
|
|
109
112
|
* A named portal channel created by {@link definePortal}: call it as a
|
|
110
113
|
* component to render the host, and call `.render(props)` to write content.
|
|
111
114
|
*/
|
|
112
115
|
interface Portal<T extends RenderableChild = RenderableChild> {
|
|
113
116
|
(): T | JSXElement | null | undefined;
|
|
114
|
-
render(props: {
|
|
115
|
-
children?: T;
|
|
116
|
-
}): unknown;
|
|
117
|
+
render(props: { children?: T }): unknown;
|
|
117
118
|
}
|
|
118
119
|
/** Props for the {@link Portal} component. */
|
|
119
120
|
interface PortalProps {
|
|
120
121
|
children?: RenderableChild;
|
|
121
122
|
}
|
|
122
123
|
/** Create a new named {@link Portal} channel with its own host and content. */
|
|
123
|
-
declare function definePortal<
|
|
124
|
+
declare function definePortal<
|
|
125
|
+
T extends RenderableChild = RenderableChild,
|
|
126
|
+
>(): Portal<T>;
|
|
124
127
|
/**
|
|
125
128
|
* The implicit portal channel that {@link Portal} writes to and that any
|
|
126
129
|
* host rendered without an explicit portal falls back to.
|
|
@@ -128,8 +131,6 @@ declare function definePortal<T extends RenderableChild = RenderableChild>(): Po
|
|
|
128
131
|
declare const DefaultPortal: Portal<RenderableChild>;
|
|
129
132
|
/** Write children to the {@link DefaultPortal} host wherever it is rendered. */
|
|
130
133
|
declare function Portal(props: PortalProps): JSXElement | null;
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/foundations/structures/collection.d.ts
|
|
133
134
|
/**
|
|
134
135
|
* createCollection
|
|
135
136
|
*
|
|
@@ -180,7 +181,10 @@ interface Collection<TNode, TMetadata = unknown> {
|
|
|
180
181
|
size(): number;
|
|
181
182
|
}
|
|
182
183
|
/** Create an empty, insertion-ordered {@link Collection} registry. */
|
|
183
|
-
declare function createCollection<TNode, TMetadata = unknown>(): Collection<
|
|
184
|
+
declare function createCollection<TNode, TMetadata = unknown>(): Collection<
|
|
185
|
+
TNode,
|
|
186
|
+
TMetadata
|
|
187
|
+
>;
|
|
184
188
|
/**
|
|
185
189
|
* USAGE EXAMPLE:
|
|
186
190
|
*
|
|
@@ -199,8 +203,6 @@ declare function createCollection<TNode, TMetadata = unknown>(): Collection<TNod
|
|
|
199
203
|
* unregister1();
|
|
200
204
|
* unregister2();
|
|
201
205
|
*/
|
|
202
|
-
//#endregion
|
|
203
|
-
//#region src/foundations/structures/layer.d.ts
|
|
204
206
|
/**
|
|
205
207
|
* createLayer
|
|
206
208
|
*
|
|
@@ -306,5 +308,24 @@ declare function createLayer(): LayerManager;
|
|
|
306
308
|
* );
|
|
307
309
|
* }
|
|
308
310
|
*/
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
export {
|
|
312
|
+
isElement,
|
|
313
|
+
Collection,
|
|
314
|
+
DefaultPortal,
|
|
315
|
+
definePortal,
|
|
316
|
+
Presence,
|
|
317
|
+
cloneElement,
|
|
318
|
+
SlotProps,
|
|
319
|
+
createLayer,
|
|
320
|
+
Portal,
|
|
321
|
+
Slot,
|
|
322
|
+
LayerManager,
|
|
323
|
+
CollectionItem,
|
|
324
|
+
PresenceProps,
|
|
325
|
+
LayerOptions,
|
|
326
|
+
createCollection,
|
|
327
|
+
Layer,
|
|
328
|
+
PortalProps,
|
|
329
|
+
LayoutComponent,
|
|
330
|
+
layout,
|
|
331
|
+
};
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
RouteAuthOptions,
|
|
3
|
+
RouteRegistry,
|
|
4
|
+
RouteMatch,
|
|
5
|
+
ComponentFunction,
|
|
6
|
+
QueryStaleReason,
|
|
7
|
+
Mutation,
|
|
8
|
+
Query,
|
|
9
|
+
DataRuntime,
|
|
10
|
+
} from '../core.js';
|
|
3
11
|
/** Options for {@link render} and {@link mount}. */
|
|
4
12
|
interface RenderOptions {
|
|
5
13
|
/**
|
|
@@ -20,34 +28,62 @@ interface RouteRenderOptions extends RenderOptions {
|
|
|
20
28
|
auth?: RouteAuthOptions;
|
|
21
29
|
dataRuntime?: DataRuntime;
|
|
22
30
|
}
|
|
23
|
-
type DispatchEventInit =
|
|
31
|
+
type DispatchEventInit =
|
|
32
|
+
| EventInit
|
|
33
|
+
| UIEventInit
|
|
34
|
+
| FocusEventInit
|
|
35
|
+
| MouseEventInit
|
|
36
|
+
| WheelEventInit
|
|
37
|
+
| KeyboardEventInit
|
|
38
|
+
| InputEventInit
|
|
39
|
+
| CompositionEventInit
|
|
40
|
+
| PointerEventInit
|
|
41
|
+
| TouchEventInit
|
|
42
|
+
| DragEventInit;
|
|
24
43
|
/** Handle to a mounted test render, returned by {@link render}/{@link mount}/{@link renderRoute}. */
|
|
25
44
|
interface RenderResult {
|
|
26
45
|
readonly container: HTMLElement;
|
|
27
46
|
readonly root: HTMLElement;
|
|
28
47
|
flush(): void;
|
|
29
|
-
dispatch(
|
|
48
|
+
dispatch(
|
|
49
|
+
target: EventTarget,
|
|
50
|
+
event: Event | string,
|
|
51
|
+
init?: DispatchEventInit
|
|
52
|
+
): boolean;
|
|
30
53
|
unmount(): void;
|
|
31
54
|
cleanup(): void;
|
|
32
55
|
}
|
|
33
56
|
/** Synchronously flush the runtime's scheduled work (renders, effects). */
|
|
34
57
|
declare function flush(): void;
|
|
35
58
|
/** Dispatch an event (constructed from a type string, or given directly) on `target`. */
|
|
36
|
-
declare function dispatch(
|
|
59
|
+
declare function dispatch(
|
|
60
|
+
target: EventTarget,
|
|
61
|
+
event: Event | string,
|
|
62
|
+
init?: DispatchEventInit
|
|
63
|
+
): boolean;
|
|
37
64
|
/** Tear down a test render, given either its {@link RenderResult} or container element. */
|
|
38
65
|
declare function cleanup(target: RenderResult | HTMLElement): void;
|
|
39
66
|
/** Mount `component` as an island into a test container and flush pending work. */
|
|
40
|
-
declare function render(
|
|
67
|
+
declare function render(
|
|
68
|
+
component: ComponentFunction,
|
|
69
|
+
options?: RenderOptions
|
|
70
|
+
): RenderResult;
|
|
41
71
|
/** Alias for {@link render}. */
|
|
42
|
-
declare function mount(
|
|
72
|
+
declare function mount(
|
|
73
|
+
component: ComponentFunction,
|
|
74
|
+
options?: RenderOptions
|
|
75
|
+
): RenderResult;
|
|
43
76
|
/** Mount a routed app (via {@link createSPA}) into a test container for the given route registry. */
|
|
44
|
-
declare function renderRoute(
|
|
45
|
-
|
|
46
|
-
|
|
77
|
+
declare function renderRoute(
|
|
78
|
+
options: RouteRenderOptions
|
|
79
|
+
): Promise<RenderResult>;
|
|
47
80
|
/** Dispatch the browser click sequence expected by Askr's delegated events. */
|
|
48
81
|
declare function click(element: Element): boolean;
|
|
49
82
|
/** Set a text control's value and emit an input event for each character. */
|
|
50
|
-
declare function type(
|
|
83
|
+
declare function type(
|
|
84
|
+
element: HTMLInputElement | HTMLTextAreaElement,
|
|
85
|
+
text: string
|
|
86
|
+
): void;
|
|
51
87
|
/** Dispatch a cancelable bubbling submit event on a form. */
|
|
52
88
|
declare function submit(form: HTMLFormElement): boolean;
|
|
53
89
|
/** Keyed query fixture registry returned by {@link createQueryTestRegistry}. */
|
|
@@ -85,16 +121,26 @@ type MutationFixture<TInput, TResult> = Mutation<TInput, TResult> & {
|
|
|
85
121
|
/** Reject the current fixture execution and expose its error. */
|
|
86
122
|
fail(error: {}): void;
|
|
87
123
|
};
|
|
88
|
-
declare function createMutationFixture<TInput = unknown, TResult = unknown>(
|
|
124
|
+
declare function createMutationFixture<TInput = unknown, TResult = unknown>(
|
|
125
|
+
initial?: MutationFixtureInitial<TResult>
|
|
126
|
+
): MutationFixture<TInput, TResult>;
|
|
89
127
|
/**
|
|
90
128
|
* Build a {@link MutationFixture} for tests: call directly with initial
|
|
91
129
|
* state, or use `.idle()`/`.pending()`/`.success(result)`/`.error(error)`.
|
|
92
130
|
*/
|
|
93
131
|
declare const mutationState: typeof createMutationFixture & {
|
|
94
132
|
idle<TInput = unknown, TResult = unknown>(): MutationFixture<TInput, TResult>;
|
|
95
|
-
pending<TInput = unknown, TResult = unknown>(): MutationFixture<
|
|
96
|
-
|
|
97
|
-
|
|
133
|
+
pending<TInput = unknown, TResult = unknown>(): MutationFixture<
|
|
134
|
+
TInput,
|
|
135
|
+
TResult
|
|
136
|
+
>;
|
|
137
|
+
success<TInput = unknown, TResult = unknown>(
|
|
138
|
+
result: TResult
|
|
139
|
+
): MutationFixture<TInput, TResult>;
|
|
140
|
+
error<TInput = unknown, TResult = unknown>(error: {}): MutationFixture<
|
|
141
|
+
TInput,
|
|
142
|
+
TResult
|
|
143
|
+
>;
|
|
98
144
|
};
|
|
99
145
|
/** Refresh callback for a {@link mockQuery} fixture, invoked by the query's `refresh()`. */
|
|
100
146
|
type MockRefresh = () => void | Promise<void>;
|
|
@@ -127,32 +173,85 @@ interface RoutePatternWarning {
|
|
|
127
173
|
message: string;
|
|
128
174
|
}
|
|
129
175
|
type StaleValueReason = Exclude<QueryStaleReason, 'error'>;
|
|
130
|
-
declare function createFreshQuery<T extends {}>(
|
|
176
|
+
declare function createFreshQuery<T extends {}>(
|
|
177
|
+
data: T,
|
|
178
|
+
options?: MockQueryOptions
|
|
179
|
+
): Query<T>;
|
|
131
180
|
/**
|
|
132
181
|
* Build a fresh {@link Query} fixture for tests: call directly with data, or
|
|
133
182
|
* use `.loading()`/`.error()`/`.refreshing()`/`.stale()`/`.pendingWrite()`.
|
|
134
183
|
*/
|
|
135
184
|
declare const mockQuery: typeof createFreshQuery & {
|
|
136
185
|
loading<T extends {} = {}>(options?: MockQueryOptions): Query<T>;
|
|
137
|
-
error<T extends {} = {}>(
|
|
186
|
+
error<T extends {} = {}>(
|
|
187
|
+
error: {},
|
|
188
|
+
previousData?: T,
|
|
189
|
+
options?: MockQueryOptions
|
|
190
|
+
): Query<T>;
|
|
138
191
|
refreshing<T extends {}>(data: T, options?: MockQueryOptions): Query<T>;
|
|
139
|
-
stale<T extends {}>(
|
|
192
|
+
stale<T extends {}>(
|
|
193
|
+
data: T,
|
|
194
|
+
reason?: StaleValueReason,
|
|
195
|
+
options?: MockQueryOptions
|
|
196
|
+
): Query<T>;
|
|
140
197
|
pendingWrite<T extends {}>(data: T, options?: MockQueryOptions): Query<T>;
|
|
141
198
|
};
|
|
142
199
|
/** Alias table mirroring {@link mockQuery}'s state builders (`fresh`, `loading`, `error`, ...). */
|
|
143
200
|
declare const queryState: {
|
|
144
201
|
fresh: typeof createFreshQuery;
|
|
145
202
|
loading: <T extends {} = {}>(options?: MockQueryOptions) => Query<T>;
|
|
146
|
-
error: <T extends {} = {}>(
|
|
203
|
+
error: <T extends {} = {}>(
|
|
204
|
+
error: {},
|
|
205
|
+
previousData?: T,
|
|
206
|
+
options?: MockQueryOptions
|
|
207
|
+
) => Query<T>;
|
|
147
208
|
refreshing: <T extends {}>(data: T, options?: MockQueryOptions) => Query<T>;
|
|
148
|
-
stale: <T extends {}>(
|
|
209
|
+
stale: <T extends {}>(
|
|
210
|
+
data: T,
|
|
211
|
+
reason?: StaleValueReason,
|
|
212
|
+
options?: MockQueryOptions
|
|
213
|
+
) => Query<T>;
|
|
149
214
|
pendingWrite: <T extends {}>(data: T, options?: MockQueryOptions) => Query<T>;
|
|
150
215
|
};
|
|
151
216
|
/** Start recording {@link invalidate} calls for assertions; call `stop()` when done. */
|
|
152
217
|
declare function createInvalidationRecorder(): InvalidationRecorder;
|
|
153
218
|
/** Match `path` against a route registry for tests, without mounting the app. */
|
|
154
|
-
declare function matchRoute(
|
|
219
|
+
declare function matchRoute(
|
|
220
|
+
path: string,
|
|
221
|
+
options: MatchRouteOptions
|
|
222
|
+
): RouteMatch | null;
|
|
155
223
|
/** Find named-splat routes whose reserved segments collide with sibling static routes. */
|
|
156
|
-
declare function getRouteWarnings(
|
|
157
|
-
|
|
158
|
-
|
|
224
|
+
declare function getRouteWarnings(
|
|
225
|
+
options: MatchRouteOptions
|
|
226
|
+
): RoutePatternWarning[];
|
|
227
|
+
export {
|
|
228
|
+
InvalidationRecord,
|
|
229
|
+
InvalidationRecorder,
|
|
230
|
+
MockQueryOptions,
|
|
231
|
+
MockRefresh,
|
|
232
|
+
MutationFixture,
|
|
233
|
+
MutationFixtureInitial,
|
|
234
|
+
MutationTestRegistry,
|
|
235
|
+
QueryTestRegistry,
|
|
236
|
+
type RenderOptions,
|
|
237
|
+
type RenderResult,
|
|
238
|
+
RoutePatternWarning,
|
|
239
|
+
type RouteRenderOptions,
|
|
240
|
+
cleanup,
|
|
241
|
+
click,
|
|
242
|
+
createInvalidationRecorder,
|
|
243
|
+
createMutationTestRegistry,
|
|
244
|
+
createQueryTestRegistry,
|
|
245
|
+
dispatch,
|
|
246
|
+
flush,
|
|
247
|
+
getRouteWarnings,
|
|
248
|
+
matchRoute,
|
|
249
|
+
mockQuery,
|
|
250
|
+
mount,
|
|
251
|
+
mutationState,
|
|
252
|
+
queryState,
|
|
253
|
+
render,
|
|
254
|
+
renderRoute,
|
|
255
|
+
submit,
|
|
256
|
+
type,
|
|
257
|
+
};
|