@askrjs/askr 0.2.3 → 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-ZxJXI9hF.js → activity-oy2YFTFF.js} +22 -16
  6. package/dist/benchmark.js +8 -9
  7. package/dist/boot/index.d.ts +21 -9
  8. package/dist/boot/index.js +1 -1
  9. package/dist/{boot-D4GaLA0d.js → boot-BMBMWUGI.js} +680 -440
  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-57x3wa4J.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-B7XCDeC8.js → data-2edW0jhF.js} +133 -138
  22. package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
  23. package/dist/{deferred-BELyvMsC.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-4LwBwV58.js → effect-C3Zsc1k6.js} +14 -41
  41. package/dist/{types-DkVJhVs9.d.ts → elements.d.ts} +84 -42
  42. package/dist/{for-internal-DeoSg_AV.js → for-state-BDykeOJL.js} +623 -511
  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-Dl02WQKS.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-C46GtScG.js → navigate-prC5V8XV.js} +204 -476
  69. package/dist/{navigate-wel1e6cU.d.ts → navigation.d.ts} +10 -8
  70. package/dist/{readable-CEcteIDE.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-BaC5qHEw.js → render-resolved-BC0W7_5b.js} +165 -558
  74. package/dist/{renderer-BhXofszH.js → renderer-CT0HeY58.js} +6866 -5715
  75. package/dist/{resolution-t8J0yNaU.js → resolution-3DskUkjG.js} +189 -180
  76. package/dist/{resource-operation-B8q-QRUx.js → resource-18-sFRl9.js} +98 -58
  77. package/dist/resources/index.d.ts +64 -46
  78. package/dist/resources/index.js +215 -9
  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-C7rIpOnN.js → selector-BSPVkjKP.js} +41 -41
  86. package/dist/{shared-CGrx2AOL.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-BzhOW2TX.js → state-BXJfudq1.js} +10 -15
  95. package/dist/{structures-BwfeO4Iz.js → structures-CjEzfj4h.js} +37 -57
  96. package/dist/{index-r5THqzPN.d.ts → structures.d.ts} +57 -36
  97. package/dist/testing/index.d.ts +125 -24
  98. package/dist/testing/index.js +26 -62
  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-_Q6avFp0.js → verify-hydration-ikaxotf7.js} +8 -5
  102. package/package.json +13 -15
  103. package/dist/access-Rr7CMa06.js +0 -507
  104. package/dist/activity-CAJ5eho-.d.ts +0 -14
  105. package/dist/benchmark.d.ts +0 -26
  106. package/dist/cleanup-DsrbV-rr.js +0 -535
  107. package/dist/component-cleanup-DjpwO9WX.js +0 -143
  108. package/dist/component-scope-4I3yEMkb.js +0 -195
  109. package/dist/control-DdFw-Caz.d.ts +0 -8
  110. package/dist/csp-nonce-C9OuML0U.js +0 -72
  111. package/dist/css-BuPaTOfe.js +0 -70
  112. package/dist/fastlane-Buz1Rvlr.js +0 -166
  113. package/dist/index-DSqXWc77.d.ts +0 -1402
  114. package/dist/jsx-runtime-BTzDdBJ_.d.ts +0 -2
  115. package/dist/jsx-runtime-Cdd6Gkb0.d.ts +0 -38
  116. package/dist/lifecycle-batch-Be-CLDjV.js +0 -253
  117. package/dist/lifecycle-operations-C5m03NQc.js +0 -195
@@ -1,8 +1,7 @@
1
- import { S as isProductionEnvironment } from "./access-Rr7CMa06.js";
2
- import { n as isBulkCommitActive, t as deferBulkCommitReadableNotification } from "./fastlane-Buz1Rvlr.js";
3
- import { i as claimHookIndex, p as getCurrentInstance } from "./component-scope-4I3yEMkb.js";
4
- import { l as notifyReadableReaders, o as markReactivePropsDirtySource, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-CEcteIDE.js";
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 = getCurrentInstance();
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 (getCurrentInstance() !== 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.");
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
- markReadableDerivedSubscribersDirty(read);
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 { o as getRuntimeRenderer } from "./access-Rr7CMa06.js";
2
- import { f as getCurrentComponentInstance, m as getCurrentPortalScope } from "./component-scope-4I3yEMkb.js";
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-CEcteIDE.js";
5
- import { t as cleanupComponent } from "./component-cleanup-DjpwO9WX.js";
6
- import { c as getCurrentLifecycleCommitBatch, u as registerLifecycleTransaction } from "./lifecycle-batch-Be-CLDjV.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
- markReadableDerivedSubscribersDirty(source);
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._ownershipGeneration
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
- markReadableDerivedSubscribersDirty(state.explicitHostSource);
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
- markReadableDerivedSubscribersDirty(state.ownerSource);
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
- const host = state.host?.instance;
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 (scope.target && scope.target.isConnected === false) return true;
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._ownershipGeneration
350
+ generation: owner.owner.identity
371
351
  } : null;
372
- const batch = getCurrentLifecycleCommitBatch();
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 (registerLifecycleTransaction(state, () => {
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 (registerLifecycleTransaction(transaction, () => {
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 = getCurrentLifecycleCommitBatch();
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._ownershipGeneration;
442
+ const generation = owner.owner.identity;
463
443
  if (state.cleanupOwners.has(generation)) return;
464
444
  state.cleanupOwners.add(generation);
465
- (owner.cleanupFns ??= []).push(() => {
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._ownershipGeneration;
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.cleanupFns ??= []).push(() => {
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._ownershipGeneration
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 { cn as RenderableChild } from "./index-DSqXWc77.js";
2
- import { r as JSXElement } from "./types-DkVJhVs9.js";
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-DkVJhVs9.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> = (props: P & {
29
- children?: RenderableChild;
30
- }) => unknown;
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>(Layout: LayoutComponent<P>): (children?: RenderableChild, props?: P) => unknown;
36
- //#endregion
37
- //#region src/jsx/utils.d.ts
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(element: JSXElement, props: Record<string, unknown>): JSXElement;
42
- //#endregion
43
- //#region src/foundations/structures/slot.d.ts
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
- asChild: true;
47
- children: JSXElement;
48
- [key: string]: unknown;
49
- } | {
50
- asChild?: false;
51
- children?: RenderableChild;
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({ present, children }: PresenceProps): JSXElement | null;
106
- //#endregion
107
- //#region src/runtime/portal.d.ts
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<T extends RenderableChild = RenderableChild>(): Portal<T>;
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<TNode, TMetadata>;
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
- //#endregion
310
- export { isElement as _, Collection as a, DefaultPortal as c, definePortal as d, Presence as f, cloneElement as g, SlotProps as h, createLayer as i, Portal as l, Slot as m, LayerManager as n, CollectionItem as o, PresenceProps as p, LayerOptions as r, createCollection as s, Layer as t, PortalProps as u, LayoutComponent as v, layout as y };
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
+ };
@@ -1,5 +1,13 @@
1
- import { Bt as DataRuntime, Kt as Query, Wt as Mutation, dt as RouteAuthOptions, jt as RouteRegistry, nn as QueryStaleReason, sn as ComponentFunction, yt as RouteMatch } from "../index-DSqXWc77.js";
2
- //#region src/testing/render.d.ts
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
  /**
@@ -9,6 +17,8 @@ interface RenderOptions {
9
17
  container?: HTMLElement;
10
18
  /** Surface lifecycle cleanup errors during unmount. */
11
19
  cleanupStrict?: boolean;
20
+ /** Isolated data runtime owned by this component render. */
21
+ dataRuntime?: DataRuntime;
12
22
  }
13
23
  /** Options for {@link renderRoute}. */
14
24
  interface RouteRenderOptions extends RenderOptions {
@@ -18,34 +28,62 @@ interface RouteRenderOptions extends RenderOptions {
18
28
  auth?: RouteAuthOptions;
19
29
  dataRuntime?: DataRuntime;
20
30
  }
21
- type DispatchEventInit = EventInit | UIEventInit | FocusEventInit | MouseEventInit | WheelEventInit | KeyboardEventInit | InputEventInit | CompositionEventInit | PointerEventInit | TouchEventInit | DragEventInit;
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;
22
43
  /** Handle to a mounted test render, returned by {@link render}/{@link mount}/{@link renderRoute}. */
23
44
  interface RenderResult {
24
45
  readonly container: HTMLElement;
25
46
  readonly root: HTMLElement;
26
47
  flush(): void;
27
- dispatch(target: EventTarget, event: Event | string, init?: DispatchEventInit): boolean;
48
+ dispatch(
49
+ target: EventTarget,
50
+ event: Event | string,
51
+ init?: DispatchEventInit
52
+ ): boolean;
28
53
  unmount(): void;
29
54
  cleanup(): void;
30
55
  }
31
56
  /** Synchronously flush the runtime's scheduled work (renders, effects). */
32
57
  declare function flush(): void;
33
58
  /** Dispatch an event (constructed from a type string, or given directly) on `target`. */
34
- declare function dispatch(target: EventTarget, event: Event | string, init?: DispatchEventInit): boolean;
59
+ declare function dispatch(
60
+ target: EventTarget,
61
+ event: Event | string,
62
+ init?: DispatchEventInit
63
+ ): boolean;
35
64
  /** Tear down a test render, given either its {@link RenderResult} or container element. */
36
65
  declare function cleanup(target: RenderResult | HTMLElement): void;
37
66
  /** Mount `component` as an island into a test container and flush pending work. */
38
- declare function render(component: ComponentFunction, options?: RenderOptions): RenderResult;
67
+ declare function render(
68
+ component: ComponentFunction,
69
+ options?: RenderOptions
70
+ ): RenderResult;
39
71
  /** Alias for {@link render}. */
40
- declare function mount(component: ComponentFunction, options?: RenderOptions): RenderResult;
72
+ declare function mount(
73
+ component: ComponentFunction,
74
+ options?: RenderOptions
75
+ ): RenderResult;
41
76
  /** Mount a routed app (via {@link createSPA}) into a test container for the given route registry. */
42
- declare function renderRoute(options: RouteRenderOptions): Promise<RenderResult>;
43
- //#endregion
44
- //#region src/testing/index.d.ts
77
+ declare function renderRoute(
78
+ options: RouteRenderOptions
79
+ ): Promise<RenderResult>;
45
80
  /** Dispatch the browser click sequence expected by Askr's delegated events. */
46
81
  declare function click(element: Element): boolean;
47
82
  /** Set a text control's value and emit an input event for each character. */
48
- declare function type(element: HTMLInputElement | HTMLTextAreaElement, text: string): void;
83
+ declare function type(
84
+ element: HTMLInputElement | HTMLTextAreaElement,
85
+ text: string
86
+ ): void;
49
87
  /** Dispatch a cancelable bubbling submit event on a form. */
50
88
  declare function submit(form: HTMLFormElement): boolean;
51
89
  /** Keyed query fixture registry returned by {@link createQueryTestRegistry}. */
@@ -83,16 +121,26 @@ type MutationFixture<TInput, TResult> = Mutation<TInput, TResult> & {
83
121
  /** Reject the current fixture execution and expose its error. */
84
122
  fail(error: {}): void;
85
123
  };
86
- declare function createMutationFixture<TInput = unknown, TResult = unknown>(initial?: MutationFixtureInitial<TResult>): MutationFixture<TInput, TResult>;
124
+ declare function createMutationFixture<TInput = unknown, TResult = unknown>(
125
+ initial?: MutationFixtureInitial<TResult>
126
+ ): MutationFixture<TInput, TResult>;
87
127
  /**
88
128
  * Build a {@link MutationFixture} for tests: call directly with initial
89
129
  * state, or use `.idle()`/`.pending()`/`.success(result)`/`.error(error)`.
90
130
  */
91
131
  declare const mutationState: typeof createMutationFixture & {
92
132
  idle<TInput = unknown, TResult = unknown>(): MutationFixture<TInput, TResult>;
93
- pending<TInput = unknown, TResult = unknown>(): MutationFixture<TInput, TResult>;
94
- success<TInput = unknown, TResult = unknown>(result: TResult): MutationFixture<TInput, TResult>;
95
- error<TInput = unknown, TResult = unknown>(error: {}): MutationFixture<TInput, TResult>;
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
+ >;
96
144
  };
97
145
  /** Refresh callback for a {@link mockQuery} fixture, invoked by the query's `refresh()`. */
98
146
  type MockRefresh = () => void | Promise<void>;
@@ -125,32 +173,85 @@ interface RoutePatternWarning {
125
173
  message: string;
126
174
  }
127
175
  type StaleValueReason = Exclude<QueryStaleReason, 'error'>;
128
- declare function createFreshQuery<T extends {}>(data: T, options?: MockQueryOptions): Query<T>;
176
+ declare function createFreshQuery<T extends {}>(
177
+ data: T,
178
+ options?: MockQueryOptions
179
+ ): Query<T>;
129
180
  /**
130
181
  * Build a fresh {@link Query} fixture for tests: call directly with data, or
131
182
  * use `.loading()`/`.error()`/`.refreshing()`/`.stale()`/`.pendingWrite()`.
132
183
  */
133
184
  declare const mockQuery: typeof createFreshQuery & {
134
185
  loading<T extends {} = {}>(options?: MockQueryOptions): Query<T>;
135
- error<T extends {} = {}>(error: {}, previousData?: T, options?: MockQueryOptions): Query<T>;
186
+ error<T extends {} = {}>(
187
+ error: {},
188
+ previousData?: T,
189
+ options?: MockQueryOptions
190
+ ): Query<T>;
136
191
  refreshing<T extends {}>(data: T, options?: MockQueryOptions): Query<T>;
137
- stale<T extends {}>(data: T, reason?: StaleValueReason, options?: MockQueryOptions): Query<T>;
192
+ stale<T extends {}>(
193
+ data: T,
194
+ reason?: StaleValueReason,
195
+ options?: MockQueryOptions
196
+ ): Query<T>;
138
197
  pendingWrite<T extends {}>(data: T, options?: MockQueryOptions): Query<T>;
139
198
  };
140
199
  /** Alias table mirroring {@link mockQuery}'s state builders (`fresh`, `loading`, `error`, ...). */
141
200
  declare const queryState: {
142
201
  fresh: typeof createFreshQuery;
143
202
  loading: <T extends {} = {}>(options?: MockQueryOptions) => Query<T>;
144
- error: <T extends {} = {}>(error: {}, previousData?: T, options?: MockQueryOptions) => Query<T>;
203
+ error: <T extends {} = {}>(
204
+ error: {},
205
+ previousData?: T,
206
+ options?: MockQueryOptions
207
+ ) => Query<T>;
145
208
  refreshing: <T extends {}>(data: T, options?: MockQueryOptions) => Query<T>;
146
- stale: <T extends {}>(data: T, reason?: StaleValueReason, options?: MockQueryOptions) => Query<T>;
209
+ stale: <T extends {}>(
210
+ data: T,
211
+ reason?: StaleValueReason,
212
+ options?: MockQueryOptions
213
+ ) => Query<T>;
147
214
  pendingWrite: <T extends {}>(data: T, options?: MockQueryOptions) => Query<T>;
148
215
  };
149
216
  /** Start recording {@link invalidate} calls for assertions; call `stop()` when done. */
150
217
  declare function createInvalidationRecorder(): InvalidationRecorder;
151
218
  /** Match `path` against a route registry for tests, without mounting the app. */
152
- declare function matchRoute(path: string, options: MatchRouteOptions): RouteMatch | null;
219
+ declare function matchRoute(
220
+ path: string,
221
+ options: MatchRouteOptions
222
+ ): RouteMatch | null;
153
223
  /** Find named-splat routes whose reserved segments collide with sibling static routes. */
154
- declare function getRouteWarnings(options: MatchRouteOptions): RoutePatternWarning[];
155
- //#endregion
156
- export { InvalidationRecord, InvalidationRecorder, MockQueryOptions, MockRefresh, MutationFixture, MutationFixtureInitial, MutationTestRegistry, QueryTestRegistry, type RenderOptions, type RenderResult, RoutePatternWarning, type RouteRenderOptions, cleanup, click, createInvalidationRecorder, createMutationTestRegistry, createQueryTestRegistry, dispatch, flush, getRouteWarnings, matchRoute, mockQuery, mount, mutationState, queryState, render, renderRoute, submit, type };
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
+ };