@askrjs/askr 0.2.4 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/access-CEA2pOry.js +1046 -0
  3. package/dist/actions/index.d.ts +16 -2
  4. package/dist/actions/index.js +5 -5
  5. package/dist/{activity-FirwPXA_.js → activity-oy2YFTFF.js} +10 -16
  6. package/dist/benchmark.js +8 -9
  7. package/dist/boot/index.d.ts +19 -9
  8. package/dist/boot/index.js +1 -1
  9. package/dist/{boot-tWyF6121.js → boot-DLplW9h4.js} +700 -441
  10. package/dist/capabilities-Bbf0mlp9.js +42 -0
  11. package/dist/components/index.d.ts +11 -8
  12. package/dist/components/index.js +1 -1
  13. package/dist/{compose-ref-Bfaf4kUC.js → compose-ref-v0qGlHoN.js} +7 -1
  14. package/dist/control/index.d.ts +20 -2
  15. package/dist/control/index.js +1 -1
  16. package/dist/{control-C-wSaq9V.js → control-BR_mrX__.js} +4 -4
  17. package/dist/core.d.ts +163 -0
  18. package/dist/csp-nonce-BfFWcd0w.js +173 -0
  19. package/dist/data/index.d.ts +74 -2
  20. package/dist/data/index.js +3 -3
  21. package/dist/{data-ghKopAbp.js → data-2edW0jhF.js} +108 -122
  22. package/dist/{data-runtime-7t_Y0iv3.js → data-runtime-CxoY98lX.js} +22 -15
  23. package/dist/{deferred-CxjWCkIn.js → deferred-CbgNhf67.js} +5 -5
  24. package/dist/dom-renderer.d.ts +77 -0
  25. package/dist/domains/actions.d.ts +70 -0
  26. package/dist/domains/component.d.ts +119 -0
  27. package/dist/domains/context.d.ts +73 -0
  28. package/dist/domains/control.d.ts +328 -0
  29. package/dist/domains/data.d.ts +461 -0
  30. package/dist/domains/diagnostics.d.ts +21 -0
  31. package/dist/domains/lifecycle.d.ts +112 -0
  32. package/dist/domains/refs.d.ts +18 -0
  33. package/dist/domains/renderer.d.ts +127 -0
  34. package/dist/domains/routing.d.ts +501 -0
  35. package/dist/domains/scheduler.d.ts +79 -0
  36. package/dist/domains/server.d.ts +112 -0
  37. package/dist/domains/state.d.ts +129 -0
  38. package/dist/domains/telemetry.d.ts +29 -0
  39. package/dist/eager-control.d.ts +8 -0
  40. package/dist/{effect-CNwstBBD.js → effect-C3Zsc1k6.js} +14 -41
  41. package/dist/{types-DWVrKn9N.d.ts → elements.d.ts} +79 -42
  42. package/dist/{for-internal-DyBHfKJA.js → for-state-BDykeOJL.js} +598 -494
  43. package/dist/foundations/icon/index.d.ts +67 -16
  44. package/dist/foundations/icon/index.js +1 -1
  45. package/dist/foundations/index.d.ts +26 -3
  46. package/dist/foundations/index.js +1 -1
  47. package/dist/foundations/interactions/index.d.ts +73 -34
  48. package/dist/foundations/interactions/index.js +1 -1
  49. package/dist/foundations/state/index.d.ts +12 -5
  50. package/dist/foundations/state/index.js +1 -1
  51. package/dist/foundations/structures/index.d.ts +44 -3
  52. package/dist/foundations/structures/index.js +1 -1
  53. package/dist/foundations/utilities/index.d.ts +34 -3
  54. package/dist/foundations/utilities/index.js +1 -1
  55. package/dist/fx/index.d.ts +72 -25
  56. package/dist/fx/index.js +8 -8
  57. package/dist/index.d.ts +121 -4
  58. package/dist/index.js +316 -47
  59. package/dist/{component-internal-C4hKKQBF.js → instance-VAFYVJOa.js} +495 -283
  60. package/dist/{interactions-D102JxBR.js → interactions-CTeACdT_.js} +1 -1
  61. package/dist/jsx-dev-runtime.d.ts +51 -11
  62. package/dist/jsx-globals.d.ts +2 -0
  63. package/dist/jsx-runtime-CPJXAOBF.js +43 -0
  64. package/dist/jsx-runtime.d.ts +17 -3
  65. package/dist/jsx-runtime.js +2 -42
  66. package/dist/jsx.d.ts +108 -0
  67. package/dist/{manifest-D6rfj_jC.js → manifest-D1P3UNWV.js} +4 -9
  68. package/dist/{navigate-ZZu1IV0B.js → navigate-prC5V8XV.js} +125 -472
  69. package/dist/{navigate-F4sHgWbw.d.ts → navigation.d.ts} +8 -8
  70. package/dist/{readable-Di1fzSwm.js → notify-DxxuDPeY.js} +96 -34
  71. package/dist/{query-registry-Bua3cDyb.js → query-registry-LrYpQsDJ.js} +1 -1
  72. package/dist/{compose-ref-DOJHoW5X.d.ts → refs.d.ts} +11 -7
  73. package/dist/{ssr-Doog-AfJ.js → render-resolved-BC0W7_5b.js} +165 -558
  74. package/dist/{renderer-Cl23O0hV.js → renderer-CT0HeY58.js} +6825 -5692
  75. package/dist/{resolution-ClD-K7Lz.js → resolution-3DskUkjG.js} +189 -180
  76. package/dist/{resource-operation-Vz1S5h2k.js → resource-18-sFRl9.js} +98 -58
  77. package/dist/resources/index.d.ts +64 -12
  78. package/dist/resources/index.js +214 -8
  79. package/dist/route-activity.d.ts +21 -0
  80. package/dist/{route-matching-Bo6UqG-5.js → route-matching-CUzZ31gT.js} +68 -82
  81. package/dist/router/index.d.ts +378 -79
  82. package/dist/router/index.js +9 -9
  83. package/dist/router-internal-7nuNEHfG.js +36 -0
  84. package/dist/scope-Cq_iYbTR.js +403 -0
  85. package/dist/{selector-CsKuomw0.js → selector-BSPVkjKP.js} +26 -27
  86. package/dist/{shared-CYBH3F8I.js → shared-kU8yvryp.js} +3 -6
  87. package/dist/{snapshot-source-BB42xgwb.js → snapshot-source-An4iKajG.js} +1 -1
  88. package/dist/ssg/index.d.ts +51 -15
  89. package/dist/ssg/index.js +269 -209
  90. package/dist/ssr/index.d.ts +121 -68
  91. package/dist/ssr/index.js +2 -1
  92. package/dist/ssr-CiNm6Vzl.js +393 -0
  93. package/dist/{ssr-DSHd_Q9K.js → ssr-EPjwJH5R.js} +5 -1
  94. package/dist/{state-BGJgYSyQ.js → state-BXJfudq1.js} +10 -15
  95. package/dist/{structures-DFyK5AdQ.js → structures-CjEzfj4h.js} +37 -57
  96. package/dist/{index-CTpMmzgN.d.ts → structures.d.ts} +57 -36
  97. package/dist/testing/index.d.ts +123 -24
  98. package/dist/testing/index.js +24 -61
  99. package/dist/timer-C7uqnJVt.js +85 -0
  100. package/dist/{index-B1gu0_m0.d.ts → utilities.d.ts} +24 -13
  101. package/dist/{verify-hydration-BZPJ_kYa.js → verify-hydration-ikaxotf7.js} +8 -5
  102. package/package.json +12 -14
  103. package/dist/access-BucjYZcX.js +0 -509
  104. package/dist/activity-DooIuxQO.d.ts +0 -14
  105. package/dist/benchmark.d.ts +0 -26
  106. package/dist/cleanup-TXSsApEl.js +0 -535
  107. package/dist/component-cleanup-jdbgjkT1.js +0 -143
  108. package/dist/component-scope-4I3yEMkb.js +0 -195
  109. package/dist/control-Cxag1yqV.d.ts +0 -8
  110. package/dist/csp-nonce-9NFUb7hJ.js +0 -72
  111. package/dist/css-BuPaTOfe.js +0 -70
  112. package/dist/fastlane-BKZduiBQ.js +0 -166
  113. package/dist/index-Dgjbo2gU.d.ts +0 -1456
  114. package/dist/jsx-runtime-Cg7GqY1S.d.ts +0 -2
  115. package/dist/jsx-runtime-gVIaTPw0.d.ts +0 -38
  116. package/dist/lifecycle-batch-63aXFf2S.js +0 -253
  117. package/dist/lifecycle-operations-Q0k3EFnG.js +0 -287
@@ -1,6 +1,26 @@
1
- import { $ as routeActive, G as TimerOptions, J as WatchSource, K as WatchCallback, Q as on, U as ActivityPredicate, W as ListenerTarget, X as capture, Y as WatchValues, Z as documentVisible, et as task, nt as watch, pt as getSignal, q as WatchContext, rt as windowFocused, tt as timer } from "../index-Dgjbo2gU.js";
2
- import { i as onRouteChange, n as RouteChangeOptions, t as RouteChangeCleanup } from "../activity-DooIuxQO.js";
3
- //#region src/runtime/resource-operation.d.ts
1
+ import {
2
+ routeActive,
3
+ TimerOptions,
4
+ WatchSource,
5
+ WatchCallback,
6
+ on,
7
+ ActivityPredicate,
8
+ ListenerTarget,
9
+ capture,
10
+ WatchValues,
11
+ documentVisible,
12
+ task,
13
+ watch,
14
+ getSignal,
15
+ WatchContext,
16
+ windowFocused,
17
+ timer,
18
+ } from '../core.js';
19
+ import {
20
+ onRouteChange,
21
+ RouteChangeOptions,
22
+ RouteChangeCleanup,
23
+ } from '../route-activity.js';
4
24
  /** Reactive result of a {@link resource}: current value, loading state, and controls. */
5
25
  interface ResourceResult<T> {
6
26
  value: T | null;
@@ -9,13 +29,17 @@ interface ResourceResult<T> {
9
29
  refresh(): void;
10
30
  }
11
31
  /** Creates a render-scoped async resource with cancellation and refresh; SSR has special data rules. */
12
- declare function resource<T, const TDeps extends readonly unknown[]>(fn: (opts: {
13
- signal: AbortSignal;
14
- }) => PromiseLike<T> | T, deps: TDeps): ResourceResult<T>;
15
- //#endregion
16
- //#region src/runtime/stream-operation.d.ts
32
+ declare function resource<T, const TDeps extends readonly unknown[]>(
33
+ fn: (opts: { signal: AbortSignal }) => PromiseLike<T> | T,
34
+ deps: TDeps
35
+ ): ResourceResult<T>;
17
36
  /** Connection status of a {@link stream}. */
18
- type StreamStatus = 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error';
37
+ type StreamStatus =
38
+ | 'connecting'
39
+ | 'connected'
40
+ | 'reconnecting'
41
+ | 'closed'
42
+ | 'error';
19
43
  /** Reactive result of a {@link stream}: current value, connection status, and controls. */
20
44
  interface StreamResult<T> {
21
45
  value: T | null;
@@ -35,6 +59,34 @@ type StreamSource<T> = (context: {
35
59
  signal: AbortSignal;
36
60
  }) => AsyncIterable<T> | PromiseLike<AsyncIterable<T>>;
37
61
  /** Subscribe to a streaming data source for the current component's lifetime, with auto reconnect/cleanup. */
38
- declare function stream<T>(source: StreamSource<T>, options?: StreamOptions<T>): StreamResult<T>;
39
- //#endregion
40
- export { type ActivityPredicate, type ListenerTarget, type ResourceResult, type RouteChangeCleanup, type RouteChangeOptions, type StreamOptions, type StreamResult, type StreamStatus, type TimerOptions, type WatchCallback, type WatchContext, type WatchSource, type WatchValues, capture, documentVisible, getSignal, on, onRouteChange, resource, routeActive, stream, task, timer, watch, windowFocused };
62
+ declare function stream<T>(
63
+ source: StreamSource<T>,
64
+ options?: StreamOptions<T>
65
+ ): StreamResult<T>;
66
+ export {
67
+ type ActivityPredicate,
68
+ type ListenerTarget,
69
+ type ResourceResult,
70
+ type RouteChangeCleanup,
71
+ type RouteChangeOptions,
72
+ type StreamOptions,
73
+ type StreamResult,
74
+ type StreamStatus,
75
+ type TimerOptions,
76
+ type WatchCallback,
77
+ type WatchContext,
78
+ type WatchSource,
79
+ type WatchValues,
80
+ capture,
81
+ documentVisible,
82
+ getSignal,
83
+ on,
84
+ onRouteChange,
85
+ resource,
86
+ routeActive,
87
+ stream,
88
+ task,
89
+ timer,
90
+ watch,
91
+ windowFocused,
92
+ };
@@ -1,10 +1,12 @@
1
- import { t as enqueueRuntimeLane } from "../access-BucjYZcX.js";
2
- import { f as getCurrentComponentInstance, g as getSignal, i as claimHookIndex } from "../component-scope-4I3yEMkb.js";
3
- import { a as registerCommitOperation } from "../component-internal-C4hKKQBF.js";
4
- import { t as resource } from "../resource-operation-Vz1S5h2k.js";
5
- import { a as task, c as windowFocused, i as routeActive, n as documentVisible, o as timer, r as on, s as watch, t as capture } from "../lifecycle-operations-Q0k3EFnG.js";
6
- import { n as onRouteChange } from "../activity-FirwPXA_.js";
7
- //#region src/runtime/stream-operation.ts
1
+ import { t as enqueueRuntimeLane } from "../access-CEA2pOry.js";
2
+ import { a as registerCommitOperation, u as routeComponentErrorToBoundary } from "../instance-VAFYVJOa.js";
3
+ import { O as ownCleanup, f as getCurrentComponentInstance, h as getSignal, i as claimHookIndex } from "../scope-Cq_iYbTR.js";
4
+ import { n as getComponentLifecycleSlot } from "../capabilities-Bbf0mlp9.js";
5
+ import { t as createFineGrainedEffect } from "../effect-C3Zsc1k6.js";
6
+ import { t as resource } from "../resource-18-sFRl9.js";
7
+ import { a as routeActive, i as windowFocused, n as documentVisible, r as resolveListenerTarget, t as timer } from "../timer-C7uqnJVt.js";
8
+ import { n as onRouteChange } from "../activity-oy2YFTFF.js";
9
+ //#region src/runtime/lifecycle/stream.ts
8
10
  function toError(value) {
9
11
  return value instanceof Error ? value : new Error(String(value));
10
12
  }
@@ -190,7 +192,7 @@ function commitSlot(instance, slot) {
190
192
  if (firstCommit) slot.activated = true;
191
193
  if (!slot.cleanupRegistered) {
192
194
  slot.cleanupRegistered = true;
193
- (instance.cleanupFns ??= []).push(() => disposeSlot(slot));
195
+ ownCleanup(instance.owner, () => disposeSlot(slot));
194
196
  }
195
197
  if (!slot.explicitlyClosed && (firstCommit || depsChanged && wasRunning)) queueStart(slot);
196
198
  }
@@ -216,4 +218,208 @@ function stream(source, options = {}) {
216
218
  return slot.snapshot;
217
219
  }
218
220
  //#endregion
221
+ //#region src/runtime/lifecycle/listener.ts
222
+ function normalizeListenerOptions(options) {
223
+ if (options === void 0 || typeof options === "boolean") return options;
224
+ return {
225
+ ...options.capture !== void 0 ? { capture: options.capture } : {},
226
+ ...options.once !== void 0 ? { once: options.once } : {},
227
+ ...options.passive !== void 0 ? { passive: options.passive } : {},
228
+ ...options.signal !== void 0 ? { signal: options.signal } : {}
229
+ };
230
+ }
231
+ function listenerOptionsEqual(a, b) {
232
+ if (a === b) return true;
233
+ if (typeof a === "boolean" || typeof b === "boolean") return a === b;
234
+ if (!a || !b) return a === b;
235
+ return a.capture === b.capture && a.once === b.once && a.passive === b.passive && a.signal === b.signal;
236
+ }
237
+ function detachListenerSlot(slot) {
238
+ if (!slot.attached || !slot.target) return;
239
+ slot.target.removeEventListener(slot.event, slot.listener, slot.options);
240
+ slot.attached = false;
241
+ }
242
+ function commitListenerSlot(instance, slot) {
243
+ slot.handler = slot.pendingHandler;
244
+ const resolvedTarget = resolveListenerTarget(slot.pendingTarget);
245
+ if (!slot.attached || slot.target !== resolvedTarget || slot.event !== slot.pendingEvent || !listenerOptionsEqual(slot.options, slot.pendingOptions)) {
246
+ detachListenerSlot(slot);
247
+ slot.target = resolvedTarget;
248
+ slot.event = slot.pendingEvent;
249
+ slot.options = slot.pendingOptions;
250
+ if (slot.target) {
251
+ slot.target.addEventListener(slot.event, slot.listener, slot.options);
252
+ slot.attached = true;
253
+ }
254
+ }
255
+ if (!slot.cleanupRegistered) {
256
+ slot.cleanupRegistered = true;
257
+ ownCleanup(instance.owner, () => {
258
+ detachListenerSlot(slot);
259
+ slot.cleanupRegistered = false;
260
+ });
261
+ }
262
+ }
263
+ /** Attach an owned event listener to `target` for the current component's lifetime. */
264
+ function on(target, event, handler, options) {
265
+ const instance = getCurrentComponentInstance();
266
+ if (!instance) return;
267
+ const index = claimHookIndex(instance, "on");
268
+ const normalizedOptions = normalizeListenerOptions(options);
269
+ const slot = getComponentLifecycleSlot(instance, index, "listener", () => {
270
+ const createdSlot = {
271
+ kind: "listener",
272
+ target: null,
273
+ event,
274
+ handler,
275
+ listener: ((evt) => {
276
+ createdSlot.handler.call(createdSlot.target, evt);
277
+ }),
278
+ options: void 0,
279
+ pendingTarget: target,
280
+ pendingEvent: event,
281
+ pendingHandler: handler,
282
+ pendingOptions: normalizedOptions,
283
+ attached: false,
284
+ cleanupRegistered: false
285
+ };
286
+ return createdSlot;
287
+ });
288
+ slot.pendingTarget = target;
289
+ slot.pendingEvent = event;
290
+ slot.pendingHandler = handler;
291
+ slot.pendingOptions = normalizedOptions;
292
+ registerCommitOperation(() => {
293
+ commitListenerSlot(instance, slot);
294
+ });
295
+ }
296
+ //#endregion
297
+ //#region src/runtime/lifecycle/task.ts
298
+ /** Runs an owned task after commit. */
299
+ function task(fn) {
300
+ const instance = getCurrentComponentInstance();
301
+ if (!instance) return;
302
+ const index = claimHookIndex(instance, "task");
303
+ const slot = getComponentLifecycleSlot(instance, index, "task", () => ({
304
+ kind: "task",
305
+ started: false,
306
+ task: fn
307
+ }));
308
+ if (!slot.started) {
309
+ slot.task = fn;
310
+ registerCommitOperation(async () => {
311
+ if (slot.started) return;
312
+ slot.started = true;
313
+ return await slot.task();
314
+ });
315
+ }
316
+ }
317
+ /**
318
+ * Capture the result of a synchronous expression at call time and return a
319
+ * thunk that returns the captured value later. This is a low-level helper for
320
+ * cases where async continuations need to observe a snapshot of values at the
321
+ * moment scheduling occurred.
322
+ *
323
+ * Usage (public API):
324
+ * const snapshot = capture(() => someState());
325
+ * Promise.resolve().then(() => { use(snapshot()); });
326
+ */
327
+ function capture(fn) {
328
+ const value = fn();
329
+ return () => value;
330
+ }
331
+ //#endregion
332
+ //#region src/runtime/lifecycle/watch.ts
333
+ function watchValuesEqual(previous, next) {
334
+ if (previous.length !== next.length) return false;
335
+ for (let index = 0; index < previous.length; index += 1) if (!Object.is(previous[index], next[index])) return false;
336
+ return true;
337
+ }
338
+ function stopWatchGeneration(slot) {
339
+ const controller = slot.controller;
340
+ slot.controller = null;
341
+ if (controller && !controller.signal.aborted) controller.abort();
342
+ const cleanup = slot.cleanup;
343
+ slot.cleanup = null;
344
+ cleanup?.();
345
+ }
346
+ function stopWatchSlot(slot) {
347
+ stopWatchGeneration(slot);
348
+ slot.effect?.cleanup();
349
+ slot.effect = null;
350
+ }
351
+ function reportWatchError(instance, error) {
352
+ if (!routeComponentErrorToBoundary(instance, error)) throw error;
353
+ }
354
+ function commitWatchSlot(instance, slot) {
355
+ slot.callback = slot.pendingCallback;
356
+ slot.sources = slot.pendingSources;
357
+ const compute = () => {
358
+ const values = slot.sources.map((source) => source());
359
+ return values.length === 1 ? values[0] : values;
360
+ };
361
+ const observe = (value, previous) => {
362
+ stopWatchGeneration(slot);
363
+ const controller = new AbortController();
364
+ slot.controller = controller;
365
+ const initial = !slot.hasObserved;
366
+ slot.hasObserved = true;
367
+ let result;
368
+ try {
369
+ result = slot.callback(value, {
370
+ initial,
371
+ previous,
372
+ signal: controller.signal
373
+ });
374
+ } catch (error) {
375
+ reportWatchError(instance, error);
376
+ return;
377
+ }
378
+ if (typeof result === "function") {
379
+ slot.cleanup = result;
380
+ return;
381
+ }
382
+ if (result && typeof result.then === "function") Promise.resolve(result).catch((error) => {
383
+ if (!controller.signal.aborted) reportWatchError(instance, error);
384
+ });
385
+ };
386
+ if (!slot.effect) slot.effect = createFineGrainedEffect({
387
+ lane: "post",
388
+ compute,
389
+ commit: observe,
390
+ equals: (previous, next) => Array.isArray(previous) && Array.isArray(next) ? watchValuesEqual(previous, next) : Object.is(previous, next),
391
+ onError: (error) => reportWatchError(instance, error)
392
+ });
393
+ else slot.effect.updateCompute(compute);
394
+ if (!slot.cleanupRegistered) {
395
+ slot.cleanupRegistered = true;
396
+ ownCleanup(instance.owner, () => {
397
+ stopWatchSlot(slot);
398
+ slot.cleanupRegistered = false;
399
+ });
400
+ }
401
+ }
402
+ function watch(sourceOrSources, callback) {
403
+ const instance = getCurrentComponentInstance();
404
+ if (!instance) return;
405
+ const index = claimHookIndex(instance, "watch");
406
+ const sources = Array.isArray(sourceOrSources) ? sourceOrSources : [sourceOrSources];
407
+ const slot = getComponentLifecycleSlot(instance, index, "watch", () => ({
408
+ kind: "watch",
409
+ sources,
410
+ pendingSources: sources,
411
+ callback,
412
+ pendingCallback: callback,
413
+ effect: null,
414
+ controller: null,
415
+ cleanup: null,
416
+ cleanupRegistered: false,
417
+ hasObserved: false
418
+ }));
419
+ slot.pendingSources = sources;
420
+ slot.pendingCallback = callback;
421
+ if (instance.ssr) return;
422
+ registerCommitOperation(() => commitWatchSlot(instance, slot));
423
+ }
424
+ //#endregion
219
425
  export { capture, documentVisible, getSignal, on, onRouteChange, resource, routeActive, stream, task, timer, watch, windowFocused };
@@ -0,0 +1,21 @@
1
+ import { RouteSnapshot, RouteParams } from './core.js';
2
+ /** Options for {@link onRouteChange}. */
3
+ interface RouteChangeOptions {
4
+ immediate?: boolean;
5
+ }
6
+ /** Optional cleanup returned by an {@link onRouteChange} callback, run before the next change. */
7
+ type RouteChangeCleanup = void | (() => void);
8
+ /** Register a callback to run whenever the active route changes, with optional cleanup. */
9
+ declare function onRouteChange(
10
+ fn: (
11
+ current: RouteSnapshot,
12
+ previous: RouteSnapshot | null
13
+ ) => RouteChangeCleanup,
14
+ options?: RouteChangeOptions
15
+ ): void;
16
+ /** Read the currently active route's {@link RouteSnapshot}; reactive during component render. */
17
+ declare function currentRoute<
18
+ TParams extends RouteParams = RouteParams,
19
+ TState = unknown,
20
+ >(): RouteSnapshot<TParams, TState>;
21
+ export { onRouteChange, RouteChangeOptions, currentRoute, RouteChangeCleanup };
@@ -1,4 +1,4 @@
1
- import { d as getCurrentAppRenderRuntime } from "./component-scope-4I3yEMkb.js";
1
+ import { d as getCurrentAppRenderRuntime } from "./scope-Cq_iYbTR.js";
2
2
  import { n as getActiveRenderContext } from "./render-context-B7ohlh6t.js";
3
3
  //#region src/router/match.ts
4
4
  function splitPathSegments(path) {
@@ -120,48 +120,63 @@ function matchSegments(urlParts, segments) {
120
120
  }
121
121
  //#endregion
122
122
  //#region src/router/store.ts
123
- const routes = [];
124
- const records = [];
125
- const namespaces = /* @__PURE__ */ new Set();
126
- const routesByDepth = /* @__PURE__ */ new Map();
127
- const registrationScopeStack = [];
128
- let registrationLocked = false;
129
- let defaultRouteAuthOptions;
130
- let activeClientRouteAuthOptions;
131
- let defaultRouteBasePath = "";
123
+ function createRouteTable() {
124
+ return {
125
+ routes: [],
126
+ records: [],
127
+ namespaces: /* @__PURE__ */ new Set(),
128
+ routesByDepth: /* @__PURE__ */ new Map(),
129
+ registrationScopeStack: [],
130
+ registrationLocked: false,
131
+ defaultRouteAuthOptions: void 0,
132
+ activeClientRouteAuthOptions: void 0,
133
+ defaultRouteBasePath: ""
134
+ };
135
+ }
136
+ let activeTable = createRouteTable();
137
+ /** Run `fn` with `table` as the registration target, then restore the previous one. */
138
+ function withRouteTable(table, fn) {
139
+ const previous = activeTable;
140
+ activeTable = table;
141
+ try {
142
+ return fn();
143
+ } finally {
144
+ activeTable = previous;
145
+ }
146
+ }
132
147
  function getDepth(path) {
133
148
  const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
134
149
  return normalized === "/" ? 0 : normalized.split("/").filter(Boolean).length;
135
150
  }
136
151
  function getRouteRecords() {
137
- return records;
152
+ return activeTable.records;
138
153
  }
139
154
  function isRouteStoreRoutes(routeList) {
140
- return routeList === routes;
155
+ return routeList === activeTable.routes;
141
156
  }
142
157
  function insertRecordSorted(record) {
143
158
  let lo = 0;
144
- let hi = records.length;
159
+ let hi = activeTable.records.length;
145
160
  while (lo < hi) {
146
161
  const mid = lo + hi >>> 1;
147
- if (records[mid].rank >= record.rank) lo = mid + 1;
162
+ if (activeTable.records[mid].rank >= record.rank) lo = mid + 1;
148
163
  else hi = mid;
149
164
  }
150
- records.splice(lo, 0, record);
165
+ activeTable.records.splice(lo, 0, record);
151
166
  }
152
167
  function addRouteToStores(routeObj) {
153
- routes.push(routeObj);
168
+ activeTable.routes.push(routeObj);
154
169
  const depth = getDepth(routeObj.path);
155
- let depthRoutes = routesByDepth.get(depth);
170
+ let depthRoutes = activeTable.routesByDepth.get(depth);
156
171
  if (!depthRoutes) {
157
172
  depthRoutes = [];
158
- routesByDepth.set(depth, depthRoutes);
173
+ activeTable.routesByDepth.set(depth, depthRoutes);
159
174
  }
160
175
  depthRoutes.push(routeObj);
161
- if (routeObj.namespace) namespaces.add(routeObj.namespace);
176
+ if (routeObj.namespace) activeTable.namespaces.add(routeObj.namespace);
162
177
  }
163
178
  function getActiveRoutes() {
164
- return getActiveRenderContext()?.routes ?? getCurrentAppRenderRuntime()?.routeRegistry?.routes ?? routes;
179
+ return getActiveRenderContext()?.routes ?? getCurrentAppRenderRuntime()?.routeRegistry?.routes ?? activeTable.routes;
165
180
  }
166
181
  function getActiveRouteAuthOptions(override) {
167
182
  if (override !== void 0) return override;
@@ -169,126 +184,97 @@ function getActiveRouteAuthOptions(override) {
169
184
  if (renderContext) return renderContext.routeAuth;
170
185
  const appRuntime = getCurrentAppRenderRuntime();
171
186
  if (appRuntime) return appRuntime.routeAuth;
172
- return activeClientRouteAuthOptions ?? defaultRouteAuthOptions;
187
+ return activeTable.activeClientRouteAuthOptions ?? activeTable.defaultRouteAuthOptions;
173
188
  }
174
189
  function _setActiveRouteAuthOptions(auth) {
175
- activeClientRouteAuthOptions = auth;
190
+ activeTable.activeClientRouteAuthOptions = auth;
176
191
  }
177
192
  function getDefaultRouteAuthOptions() {
178
- return defaultRouteAuthOptions;
193
+ return activeTable.defaultRouteAuthOptions;
179
194
  }
180
195
  function setDefaultRouteAuthOptions(auth) {
181
- defaultRouteAuthOptions = auth;
196
+ activeTable.defaultRouteAuthOptions = auth;
182
197
  }
183
198
  function getDefaultRouteBasePath() {
184
- return defaultRouteBasePath;
199
+ return activeTable.defaultRouteBasePath;
185
200
  }
186
201
  function setDefaultRouteBasePath(basePath) {
187
- defaultRouteBasePath = basePath;
202
+ activeTable.defaultRouteBasePath = basePath;
188
203
  }
189
204
  function getActiveRouteBasePath() {
190
205
  const renderContext = getActiveRenderContext();
191
206
  if (renderContext?.basePath !== void 0) return renderContext.basePath;
192
207
  const appRegistry = getCurrentAppRenderRuntime()?.routeRegistry;
193
208
  if (appRegistry) return appRegistry.manifest.basePath ?? "";
194
- return defaultRouteBasePath;
209
+ return activeTable.defaultRouteBasePath;
195
210
  }
196
211
  function getCurrentLayoutChain() {
197
212
  const layoutChain = [];
198
- for (const scope of registrationScopeStack) if (scope.layout) layoutChain.push({ component: scope.layout });
213
+ for (const scope of activeTable.registrationScopeStack) if (scope.layout) layoutChain.push({ component: scope.layout });
199
214
  return layoutChain;
200
215
  }
201
216
  function getCurrentPageChain() {
202
217
  const pageChain = [];
203
- for (const scope of registrationScopeStack) if (scope.page) pageChain.push({ component: scope.page });
218
+ for (const scope of activeTable.registrationScopeStack) if (scope.page) pageChain.push({ component: scope.page });
204
219
  return pageChain;
205
220
  }
206
221
  function hasActivePageScope() {
207
- return registrationScopeStack.some((scope) => !!scope.page);
222
+ return activeTable.registrationScopeStack.some((scope) => !!scope.page);
208
223
  }
209
224
  function getCurrentPageScope() {
210
- for (let index = registrationScopeStack.length - 1; index >= 0; index -= 1) {
211
- const scope = registrationScopeStack[index];
225
+ for (let index = activeTable.registrationScopeStack.length - 1; index >= 0; index -= 1) {
226
+ const scope = activeTable.registrationScopeStack[index];
212
227
  if (scope.kind === "page") return scope;
213
228
  }
214
229
  return null;
215
230
  }
216
231
  function getCurrentScopeKind() {
217
- return registrationScopeStack[registrationScopeStack.length - 1]?.kind ?? null;
232
+ return activeTable.registrationScopeStack[activeTable.registrationScopeStack.length - 1]?.kind ?? null;
218
233
  }
219
234
  function getCurrentPathPrefix() {
220
- return registrationScopeStack[registrationScopeStack.length - 1]?.pathPrefix ?? "";
235
+ return activeTable.registrationScopeStack[activeTable.registrationScopeStack.length - 1]?.pathPrefix ?? "";
221
236
  }
222
237
  function getCurrentInheritedPolicies() {
223
238
  const policies = [];
224
- for (const scope of registrationScopeStack) if (scope.policies.length > 0) policies.push(...scope.policies);
239
+ for (const scope of activeTable.registrationScopeStack) if (scope.policies.length > 0) policies.push(...scope.policies);
225
240
  return policies;
226
241
  }
227
242
  function getCurrentInheritedAuthRequirements() {
228
- return registrationScopeStack.flatMap((scope) => scope.auth ? [scope.auth] : []);
243
+ return activeTable.registrationScopeStack.flatMap((scope) => scope.auth ? [scope.auth] : []);
229
244
  }
230
245
  function getCurrentInheritedMeta() {
231
- return registrationScopeStack.flatMap((scope) => scope.meta ? [scope.meta] : []);
246
+ return activeTable.registrationScopeStack.flatMap((scope) => scope.meta ? [scope.meta] : []);
232
247
  }
233
248
  function pushRegistrationScope(scope, fn) {
234
- registrationScopeStack.push(scope);
249
+ activeTable.registrationScopeStack.push(scope);
235
250
  try {
236
251
  fn();
237
252
  } finally {
238
- registrationScopeStack.pop();
253
+ activeTable.registrationScopeStack.pop();
239
254
  }
240
255
  }
241
256
  function lockRouteRegistration() {
242
- registrationLocked = true;
257
+ activeTable.registrationLocked = true;
243
258
  }
244
259
  function assertRouteRegistrationUnlocked() {
245
- if (registrationLocked) throw new Error("Route registration is locked after app startup. Register routes at module load time before calling createSPA or createSSR.");
260
+ if (activeTable.registrationLocked) throw new Error("Route registration is locked after app startup. Register routes at module load time before calling createSPA or createSSR.");
246
261
  }
247
262
  function getRouteList() {
248
- return [...routes];
263
+ return [...activeTable.routes];
249
264
  }
250
265
  function hasRegisteredRoutes() {
251
- return routes.length > 0 || records.length > 0;
266
+ return activeTable.routes.length > 0 || activeTable.records.length > 0;
252
267
  }
253
268
  function clearRouteState() {
254
- routes.length = 0;
255
- records.length = 0;
256
- namespaces.clear();
257
- routesByDepth.clear();
258
- registrationScopeStack.length = 0;
259
- registrationLocked = false;
260
- defaultRouteAuthOptions = void 0;
261
- activeClientRouteAuthOptions = void 0;
262
- defaultRouteBasePath = "";
263
- }
264
- function snapshotRouteState() {
265
- return {
266
- routes: [...routes],
267
- records: [...records],
268
- namespaces: [...namespaces],
269
- registrationLocked,
270
- defaultRouteAuthOptions,
271
- activeClientRouteAuthOptions,
272
- defaultRouteBasePath,
273
- routesByDepth: [...routesByDepth.entries()].map(([depth, depthRoutes]) => [depth, [...depthRoutes]]),
274
- registrationScopeStack: [...registrationScopeStack]
275
- };
276
- }
277
- function restoreRouteState(snapshot) {
278
- routes.length = 0;
279
- routes.push(...snapshot.routes);
280
- records.length = 0;
281
- records.push(...snapshot.records);
282
- namespaces.clear();
283
- for (const namespace of snapshot.namespaces) namespaces.add(namespace);
284
- routesByDepth.clear();
285
- for (const [depth, depthRoutes] of snapshot.routesByDepth) routesByDepth.set(depth, [...depthRoutes]);
286
- registrationScopeStack.length = 0;
287
- registrationScopeStack.push(...snapshot.registrationScopeStack);
288
- registrationLocked = snapshot.registrationLocked;
289
- defaultRouteAuthOptions = snapshot.defaultRouteAuthOptions;
290
- activeClientRouteAuthOptions = snapshot.activeClientRouteAuthOptions;
291
- defaultRouteBasePath = snapshot.defaultRouteBasePath;
269
+ activeTable.routes.length = 0;
270
+ activeTable.records.length = 0;
271
+ activeTable.namespaces.clear();
272
+ activeTable.routesByDepth.clear();
273
+ activeTable.registrationScopeStack.length = 0;
274
+ activeTable.registrationLocked = false;
275
+ activeTable.defaultRouteAuthOptions = void 0;
276
+ activeTable.activeClientRouteAuthOptions = void 0;
277
+ activeTable.defaultRouteBasePath = "";
292
278
  }
293
279
  //#endregion
294
280
  //#region src/router/route-context.ts
@@ -562,4 +548,4 @@ function _resolveRouteMatchFromRoutes(pathname, routeList) {
562
548
  return findBestResolvedRouteFromRoutes(pathname, routeList);
563
549
  }
564
550
  //#endregion
565
- export { getDefaultRouteBasePath as A, setDefaultRouteBasePath as B, getCurrentInheritedPolicies as C, getCurrentPathPrefix as D, getCurrentPageScope as E, insertRecordSorted as F, computeRank as H, lockRouteRegistration as I, pushRegistrationScope as L, getRouteRecords as M, hasActivePageScope as N, getCurrentScopeKind as O, hasRegisteredRoutes as P, restoreRouteState as R, getCurrentInheritedMeta as S, getCurrentPageChain as T, normalizeRouteSegmentName as U, snapshotRouteState as V, parseSegments as W, clearRouteState as _, resolveRouteFromRoutes as a, getActiveRoutes as b, removeRouteBasePath as c, deepFreeze as d, makeQuery as f, assertRouteRegistrationUnlocked as g, addRouteToStores as h, getMatchingRouteRecord as i, getRouteList as j, getDefaultRouteAuthOptions as k, buildRouteContext as l, _setActiveRouteAuthOptions as m, computeMatchesFromRoutes as n, addRouteBasePath as o, parseLocation as p, computeRouteActivityMatches as r, normalizeRouteBasePath as s, _resolveRouteMatchFromRoutes as t, buildRouteContextBase as u, getActiveRouteAuthOptions as v, getCurrentLayoutChain as w, getCurrentInheritedAuthRequirements as x, getActiveRouteBasePath as y, setDefaultRouteAuthOptions as z };
551
+ export { getDefaultRouteAuthOptions as A, setDefaultRouteBasePath as B, getCurrentInheritedMeta as C, getCurrentPageScope as D, getCurrentPageChain as E, hasRegisteredRoutes as F, computeRank as H, insertRecordSorted as I, lockRouteRegistration as L, getRouteList as M, getRouteRecords as N, getCurrentPathPrefix as O, hasActivePageScope as P, pushRegistrationScope as R, getCurrentInheritedAuthRequirements as S, getCurrentLayoutChain as T, normalizeRouteSegmentName as U, withRouteTable as V, parseSegments as W, clearRouteState as _, resolveRouteFromRoutes as a, getActiveRouteBasePath as b, removeRouteBasePath as c, deepFreeze as d, makeQuery as f, assertRouteRegistrationUnlocked as g, addRouteToStores as h, getMatchingRouteRecord as i, getDefaultRouteBasePath as j, getCurrentScopeKind as k, buildRouteContext as l, _setActiveRouteAuthOptions as m, computeMatchesFromRoutes as n, addRouteBasePath as o, parseLocation as p, computeRouteActivityMatches as r, normalizeRouteBasePath as s, _resolveRouteMatchFromRoutes as t, buildRouteContextBase as u, createRouteTable as v, getCurrentInheritedPolicies as w, getActiveRoutes as x, getActiveRouteAuthOptions as y, setDefaultRouteAuthOptions as z };