@askrjs/askr 0.0.70 → 0.0.71

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 (64) hide show
  1. package/capabilities.json +66 -0
  2. package/dist/actions/index.d.ts +1 -1
  3. package/dist/actions/index.js +9 -2
  4. package/dist/activity-C2tPn9Fr.js +152 -0
  5. package/dist/activity-DZ-NCYr8.d.ts +10 -0
  6. package/dist/{authoring-uaJ556aG.js → authoring-CXmUcaCe.js} +2 -2
  7. package/dist/benchmark.d.ts +1 -1
  8. package/dist/benchmark.js +6 -6
  9. package/dist/boot/index.d.ts +2 -2
  10. package/dist/boot/index.js +1 -1
  11. package/dist/{boot-8gP6mB3c.js → boot-DIKbEA4Y.js} +11 -10
  12. package/dist/{cleanup-B4BiQHx-.js → cleanup-D8Ufd9Ix.js} +16 -2
  13. package/dist/components/index.d.ts +1 -0
  14. package/dist/components/index.js +1 -0
  15. package/dist/control/index.d.ts +1 -1
  16. package/dist/control/index.js +1 -1
  17. package/dist/{control-CA45Yvvu.js → control-DVRBkN2X.js} +7 -2
  18. package/dist/{csp-nonce-HGZ0vbqT.js → csp-nonce-CwSRP3Jl.js} +16 -1
  19. package/dist/css-BuPaTOfe.js +70 -0
  20. package/dist/data/index.js +3 -3
  21. package/dist/{data-DHt_zO1G.js → data-DFcSmGvN.js} +2 -2
  22. package/dist/{data-runtime-SJ1BSUvk.js → data-runtime-rpV6-3XW.js} +13 -2
  23. package/dist/{deferred-zHtUheIQ.js → deferred-Cr58yIQD.js} +3 -4
  24. package/dist/foundations/index.d.ts +1 -1
  25. package/dist/foundations/index.js +1 -1
  26. package/dist/foundations/structures/index.d.ts +1 -1
  27. package/dist/foundations/structures/index.js +1 -1
  28. package/dist/{index-BFnTM1a8.d.ts → index-BOBtoY_r.d.ts} +34 -2
  29. package/dist/{index-DSClfSoC.d.ts → index-DxYJPVC4.d.ts} +1 -1
  30. package/dist/{index-Dh6ZF9yW.d.ts → index-UmwPZ8ZN.d.ts} +5 -0
  31. package/dist/{index-DjusBb1I.d.ts → index-u3KYoHlM.d.ts} +1 -1
  32. package/dist/index.d.ts +4 -5
  33. package/dist/index.js +12 -7
  34. package/dist/jsx-dev-runtime.d.ts +1 -0
  35. package/dist/jsx-runtime-C6Fs8Mmc.d.ts +2 -0
  36. package/dist/{jsx-runtime-aYZ8zb4q.d.ts → jsx-runtime-CL2r2HHQ.d.ts} +1 -0
  37. package/dist/jsx-runtime.d.ts +1 -1
  38. package/dist/{lifecycle-operations-SlPEK68H.js → lifecycle-operations-Db-_MG-O.js} +9 -12
  39. package/dist/{navigate-CV-RDqYP.d.ts → navigate-Cbq6QHVl.d.ts} +1 -1
  40. package/dist/{navigate-BTPrVhqI.js → navigate-CuGQzS_Y.js} +8 -104
  41. package/dist/{portal-D7TC986A.js → portal-wY3j0vvp.js} +59 -1
  42. package/dist/{query-registry-CQIT4mXr.js → query-registry-Bu_cuMch.js} +1 -1
  43. package/dist/{renderer-DF0hyjEr.js → renderer-BJYY2Y8s.js} +91 -10
  44. package/dist/resources/index.d.ts +27 -8
  45. package/dist/resources/index.js +218 -4
  46. package/dist/{route-matching-DLBWDeXX.js → route-matching-M-f1VQRu.js} +276 -2
  47. package/dist/router/index.d.ts +7 -7
  48. package/dist/router/index.js +28 -17
  49. package/dist/{router-C0XQA62W.d.ts → router-C3vENhUh.d.ts} +1 -1
  50. package/dist/{selector-DueeR6Oz.js → selector-DEfqO1rA.js} +8 -0
  51. package/dist/ssg/index.d.ts +8 -1
  52. package/dist/ssg/index.js +53 -17
  53. package/dist/ssr/index.d.ts +15 -1
  54. package/dist/ssr/index.js +1 -1
  55. package/dist/{ssr-vE-KUgDV.js → ssr-BSUA9Y64.js} +72 -78
  56. package/dist/testing/index.d.ts +35 -2
  57. package/dist/testing/index.js +182 -3
  58. package/dist/{verify-hydration-ChyEiBAn.js → verify-hydration-CVSGv6Vs.js} +1 -1
  59. package/package.json +4 -2
  60. package/dist/attr-names-CjhzmHOn.js +0 -15
  61. package/dist/component-scope-CvPba6O6.d.ts +0 -12
  62. package/dist/invalidation-listeners-Des3AHYs.js +0 -13
  63. package/dist/jsx-runtime-X2SX2y8V.d.ts +0 -2
  64. package/dist/resource-operation-BJiLoLYZ.js +0 -276
@@ -1,4 +1,5 @@
1
- import { t as getSignal } from "../component-scope-CvPba6O6.js";
1
+ import { h as getSignal } from "../index-BOBtoY_r.js";
2
+ import { i as onRouteChange, n as RouteChangeOptions, t as RouteChangeCleanup } from "../activity-DZ-NCYr8.js";
2
3
  //#region src/runtime/resource-operation.d.ts
3
4
  interface ResourceResult<T> {
4
5
  value: T | null;
@@ -6,10 +7,31 @@ interface ResourceResult<T> {
6
7
  error: Error | null;
7
8
  refresh(): void;
8
9
  }
10
+ /** Creates a render-scoped async resource with cancellation and refresh; SSR has special data rules. */
9
11
  declare function resource<T, const TDeps extends readonly unknown[]>(fn: (opts: {
10
12
  signal: AbortSignal;
11
13
  }) => PromiseLike<T> | T, deps: TDeps): ResourceResult<T>;
12
14
  //#endregion
15
+ //#region src/runtime/stream-operation.d.ts
16
+ type StreamStatus = 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error';
17
+ interface StreamResult<T> {
18
+ value: T | null;
19
+ status: StreamStatus;
20
+ pending: boolean;
21
+ stale: boolean;
22
+ error: Error | null;
23
+ restart(): void;
24
+ close(): void;
25
+ }
26
+ interface StreamOptions<T> {
27
+ deps?: readonly unknown[];
28
+ initialValue?: T;
29
+ }
30
+ type StreamSource<T> = (context: {
31
+ signal: AbortSignal;
32
+ }) => AsyncIterable<T> | PromiseLike<AsyncIterable<T>>;
33
+ declare function stream<T>(source: StreamSource<T>, options?: StreamOptions<T>): StreamResult<T>;
34
+ //#endregion
13
35
  //#region src/runtime/lifecycle-operations.d.ts
14
36
  type ActivityPredicate = () => boolean;
15
37
  interface TimerOptions {
@@ -18,14 +40,11 @@ interface TimerOptions {
18
40
  declare function routeActive(pathOrPaths: string | readonly string[]): ActivityPredicate;
19
41
  declare function documentVisible(): ActivityPredicate;
20
42
  declare function windowFocused(): ActivityPredicate;
43
+ type ListenerTarget = EventTarget | (() => EventTarget | null | undefined);
21
44
  type ListenerOptions = boolean | AddEventListenerOptions | undefined;
22
- declare function on(target: EventTarget, event: string, handler: EventListener, options?: ListenerOptions): void;
45
+ declare function on(target: ListenerTarget, event: string, handler: EventListener, options?: ListenerOptions): void;
23
46
  declare function timer(intervalMs: number, fn: () => void, options?: TimerOptions): void;
24
- declare function stream<T>(_source: unknown, _options?: Record<string, unknown>): {
25
- value: T | null;
26
- pending: boolean;
27
- error: Error | null;
28
- };
47
+ /** Runs an owned task after commit. */
29
48
  declare function task(fn: () => void | (() => void) | PromiseLike<void | (() => void)>): void;
30
49
  /**
31
50
  * Capture the result of a synchronous expression at call time and return a
@@ -39,4 +58,4 @@ declare function task(fn: () => void | (() => void) | PromiseLike<void | (() =>
39
58
  */
40
59
  declare function capture<T>(fn: () => T): () => T;
41
60
  //#endregion
42
- export { type ActivityPredicate, type ResourceResult, type TimerOptions, capture, documentVisible, getSignal, on, resource, routeActive, stream, task, timer, windowFocused };
61
+ export { type ActivityPredicate, type ListenerTarget, type ResourceResult, type RouteChangeCleanup, type RouteChangeOptions, type StreamOptions, type StreamResult, type StreamStatus, type TimerOptions, capture, documentVisible, getSignal, on, onRouteChange, resource, routeActive, stream, task, timer, windowFocused };
@@ -1,4 +1,218 @@
1
- import { g as getSignal } from "../component-scope-CC3cojX9.js";
2
- import { t as resource } from "../resource-operation-BJiLoLYZ.js";
3
- import { a as stream, c as windowFocused, i as routeActive, n as documentVisible, o as task, r as on, s as timer, t as capture } from "../lifecycle-operations-SlPEK68H.js";
4
- export { capture, documentVisible, getSignal, on, resource, routeActive, stream, task, timer, windowFocused };
1
+ import { t as enqueueRuntimeLane } from "../access-ePqdQqkV.js";
2
+ import { a as registerCommitOperation } from "../component-internal-CPjM4n8M.js";
3
+ import { f as getCurrentComponentInstance, g as getSignal, i as claimHookIndex } from "../component-scope-CC3cojX9.js";
4
+ import { z as resource } from "../route-matching-M-f1VQRu.js";
5
+ import { a as task, i as routeActive, n as documentVisible, o as timer, r as on, s as windowFocused, t as capture } from "../lifecycle-operations-Db-_MG-O.js";
6
+ import { n as onRouteChange } from "../activity-C2tPn9Fr.js";
7
+ //#region src/runtime/stream-operation.ts
8
+ function toError(value) {
9
+ return value instanceof Error ? value : new Error(String(value));
10
+ }
11
+ function depsEqual(left, right) {
12
+ return left.length === right.length && left.every((value, index) => Object.is(value, right[index]));
13
+ }
14
+ function publish(slot) {
15
+ if (slot.disposed) return;
16
+ try {
17
+ slot.owner?.notifyUpdate?.();
18
+ } catch {}
19
+ }
20
+ function setStartingState(slot) {
21
+ const retained = slot.hasValue;
22
+ slot.snapshot.status = retained && slot.generation > 0 ? "reconnecting" : "connecting";
23
+ slot.snapshot.pending = !retained;
24
+ slot.snapshot.stale = retained;
25
+ slot.snapshot.error = null;
26
+ }
27
+ function returnIterator(generation) {
28
+ if (generation.returned || !generation.iterator) return;
29
+ generation.returned = true;
30
+ const returnMethod = generation.iterator.return;
31
+ if (typeof returnMethod !== "function") return;
32
+ try {
33
+ Promise.resolve(returnMethod.call(generation.iterator)).catch(() => {});
34
+ } catch {}
35
+ }
36
+ function stopGeneration(generation) {
37
+ if (!generation || generation.stopped) return;
38
+ generation.stopped = true;
39
+ generation.controller.abort();
40
+ returnIterator(generation);
41
+ }
42
+ function isCurrent(slot, generation) {
43
+ return !slot.disposed && !generation.stopped && slot.current === generation && slot.generation === generation.id;
44
+ }
45
+ async function consume(slot, generation, iterable) {
46
+ const iteratorFactory = iterable?.[Symbol.asyncIterator];
47
+ if (typeof iteratorFactory !== "function") throw new TypeError("stream() source must return an AsyncIterable.");
48
+ const iterator = iteratorFactory.call(iterable);
49
+ if (!iterator || typeof iterator.next !== "function") throw new TypeError("stream() source must return an AsyncIterable with an iterator.");
50
+ generation.iterator = iterator;
51
+ if (!isCurrent(slot, generation)) {
52
+ returnIterator(generation);
53
+ return;
54
+ }
55
+ while (isCurrent(slot, generation)) {
56
+ const step = await iterator.next();
57
+ if (!isCurrent(slot, generation)) return;
58
+ if (step.done) {
59
+ slot.current = null;
60
+ slot.snapshot.status = "closed";
61
+ slot.snapshot.pending = false;
62
+ slot.snapshot.stale = slot.hasValue;
63
+ slot.snapshot.error = null;
64
+ publish(slot);
65
+ return;
66
+ }
67
+ slot.snapshot.value = step.value;
68
+ slot.hasValue = true;
69
+ slot.snapshot.status = "connected";
70
+ slot.snapshot.pending = false;
71
+ slot.snapshot.stale = false;
72
+ slot.snapshot.error = null;
73
+ publish(slot);
74
+ }
75
+ }
76
+ function startSlot(slot) {
77
+ if (!slot.activated || slot.disposed) return;
78
+ stopGeneration(slot.current);
79
+ slot.explicitlyClosed = false;
80
+ setStartingState(slot);
81
+ publish(slot);
82
+ const generation = {
83
+ id: ++slot.generation,
84
+ controller: new AbortController(),
85
+ iterator: null,
86
+ returned: false,
87
+ stopped: false
88
+ };
89
+ slot.current = generation;
90
+ let result;
91
+ try {
92
+ result = slot.source({ signal: generation.controller.signal });
93
+ } catch (error) {
94
+ if (!isCurrent(slot, generation)) return;
95
+ slot.current = null;
96
+ slot.snapshot.status = "error";
97
+ slot.snapshot.pending = false;
98
+ slot.snapshot.stale = slot.hasValue;
99
+ slot.snapshot.error = toError(error);
100
+ publish(slot);
101
+ return;
102
+ }
103
+ Promise.resolve(result).then((iterable) => consume(slot, generation, iterable)).catch((error) => {
104
+ if (!isCurrent(slot, generation)) return;
105
+ slot.current = null;
106
+ slot.snapshot.status = "error";
107
+ slot.snapshot.pending = false;
108
+ slot.snapshot.stale = slot.hasValue;
109
+ slot.snapshot.error = toError(error);
110
+ publish(slot);
111
+ });
112
+ }
113
+ function queueStart(slot) {
114
+ if (slot.startQueued || slot.disposed || slot.explicitlyClosed) return;
115
+ slot.startQueued = true;
116
+ enqueueRuntimeLane("post", () => {
117
+ slot.startQueued = false;
118
+ if (!slot.owner?.notifyUpdate || slot.explicitlyClosed) return;
119
+ startSlot(slot);
120
+ });
121
+ }
122
+ function closeSlot(slot) {
123
+ if (slot.disposed) return;
124
+ slot.explicitlyClosed = true;
125
+ stopGeneration(slot.current);
126
+ slot.current = null;
127
+ slot.snapshot.status = "closed";
128
+ slot.snapshot.pending = false;
129
+ slot.snapshot.stale = slot.hasValue;
130
+ slot.snapshot.error = null;
131
+ publish(slot);
132
+ }
133
+ function createSnapshot(options) {
134
+ const hasInitialValue = Object.prototype.hasOwnProperty.call(options, "initialValue");
135
+ return {
136
+ value: hasInitialValue ? options.initialValue : null,
137
+ status: "connecting",
138
+ pending: !hasInitialValue,
139
+ stale: hasInitialValue,
140
+ error: null,
141
+ restart: () => {},
142
+ close: () => {}
143
+ };
144
+ }
145
+ function createSlot(source, options) {
146
+ const snapshot = createSnapshot(options);
147
+ const slot = {
148
+ kind: "stream",
149
+ source,
150
+ pendingSource: source,
151
+ deps: (options.deps ?? []).slice(),
152
+ pendingDeps: (options.deps ?? []).slice(),
153
+ snapshot,
154
+ generation: 0,
155
+ current: null,
156
+ activated: false,
157
+ disposed: false,
158
+ explicitlyClosed: false,
159
+ hasValue: Object.prototype.hasOwnProperty.call(options, "initialValue"),
160
+ cleanupRegistered: false,
161
+ startQueued: false,
162
+ owner: null
163
+ };
164
+ snapshot.restart = () => {
165
+ if (slot.disposed) return;
166
+ slot.explicitlyClosed = false;
167
+ if (slot.activated) {
168
+ if (!slot.startQueued) startSlot(slot);
169
+ }
170
+ };
171
+ snapshot.close = () => closeSlot(slot);
172
+ return slot;
173
+ }
174
+ function disposeSlot(slot) {
175
+ if (slot.disposed) return;
176
+ slot.disposed = true;
177
+ stopGeneration(slot.current);
178
+ slot.current = null;
179
+ slot.owner = null;
180
+ if (slot.activated && false);
181
+ slot.activated = false;
182
+ }
183
+ function commitSlot(instance, slot) {
184
+ const depsChanged = !depsEqual(slot.deps, slot.pendingDeps);
185
+ const firstCommit = !slot.activated;
186
+ const wasRunning = slot.current !== null;
187
+ slot.owner = instance;
188
+ slot.source = slot.pendingSource;
189
+ slot.deps = slot.pendingDeps;
190
+ if (firstCommit) slot.activated = true;
191
+ if (!slot.cleanupRegistered) {
192
+ slot.cleanupRegistered = true;
193
+ (instance.cleanupFns ??= []).push(() => disposeSlot(slot));
194
+ }
195
+ if (!slot.explicitlyClosed && (firstCommit || depsChanged && wasRunning)) queueStart(slot);
196
+ }
197
+ function getStreamSlot(instance, index, source, options) {
198
+ const slots = instance.lifecycleSlots ??= [];
199
+ const existing = slots[index];
200
+ if (existing) {
201
+ if (existing.kind !== "stream") throw new Error(`stream() lifecycle order violation: slot ${index} already belongs to ${existing.kind ?? "another primitive"}(). Keep lifecycle primitives in a stable top-level order.`);
202
+ return existing;
203
+ }
204
+ const slot = createSlot(source, options);
205
+ slots[index] = slot;
206
+ return slot;
207
+ }
208
+ function stream(source, options = {}) {
209
+ const instance = getCurrentComponentInstance();
210
+ if (!instance) return createSnapshot(options);
211
+ const slot = getStreamSlot(instance, claimHookIndex(instance, "stream"), source, options);
212
+ slot.pendingSource = source;
213
+ slot.pendingDeps = (options.deps ?? []).slice();
214
+ if (!instance.ssr) registerCommitOperation(() => commitSlot(instance, slot));
215
+ return slot.snapshot;
216
+ }
217
+ //#endregion
218
+ export { capture, documentVisible, getSignal, on, onRouteChange, resource, routeActive, stream, task, timer, windowFocused };
@@ -1,4 +1,278 @@
1
- import { n as getActiveRenderContext } from "./render-context-Clw3rFiO.js";
1
+ import { t as enqueueRuntimeLane, v as logger } from "./access-ePqdQqkV.js";
2
+ import { c as registerCommitOperationForInstance, d as getCurrentContextFrame, g as withAsyncResourceContext } from "./component-internal-CPjM4n8M.js";
3
+ import { f as getCurrentComponentInstance } from "./component-scope-CC3cojX9.js";
4
+ import { p as isPromiseLike } from "./lifecycle-batch-COgl8jMS.js";
5
+ import { t as brandSnapshotSource } from "./snapshot-source-BB42xgwb.js";
6
+ import { i as getNextRenderKey, l as throwSSRDataMissing, n as getActiveRenderContext, r as getCurrentRenderData, u as SSRDataMissingError } from "./render-context-Clw3rFiO.js";
7
+ import { t as state } from "./state-CVuQVjvK.js";
8
+ //#region src/runtime/resource-cell.ts
9
+ /**
10
+ * Pure, component-agnostic ResourceCell state machine.
11
+ * - Holds value/pending/error/generation/controller
12
+ * - Exposes a stable `snapshot` object: { value, pending, error, refresh }
13
+ * - Uses `withAsyncResourceContext` to bind the synchronous execution step
14
+ * to a captured frame. Continuations after await do not see the frame.
15
+ */
16
+ var ResourceCell = class {
17
+ constructor(fn, deps, resourceFrame) {
18
+ this.value = null;
19
+ this.pending = true;
20
+ this.error = null;
21
+ this.generation = 0;
22
+ this.controller = null;
23
+ this.deps = null;
24
+ this.resourceFrame = null;
25
+ this.subscribers = /* @__PURE__ */ new Set();
26
+ this.disposed = false;
27
+ this.fn = fn;
28
+ this.deps = deps ? deps.slice() : null;
29
+ this.resourceFrame = resourceFrame;
30
+ this.snapshot = brandSnapshotSource({
31
+ value: null,
32
+ pending: true,
33
+ error: null,
34
+ refresh: () => this.refresh()
35
+ });
36
+ }
37
+ setLoader(fn) {
38
+ this.fn = fn;
39
+ }
40
+ subscribe(cb) {
41
+ this.subscribers.add(cb);
42
+ return () => this.subscribers.delete(cb);
43
+ }
44
+ notifySubscribers() {
45
+ this.snapshot.value = this.value;
46
+ this.snapshot.pending = this.pending;
47
+ this.snapshot.error = this.error;
48
+ for (const cb of this.subscribers) cb();
49
+ }
50
+ start(ssr = false, notify = true) {
51
+ if (this.disposed) return;
52
+ const generation = this.generation;
53
+ this.controller?.abort();
54
+ const controller = new AbortController();
55
+ this.controller = controller;
56
+ this.pending = true;
57
+ this.error = null;
58
+ if (notify) this.notifySubscribers();
59
+ let result;
60
+ try {
61
+ result = withAsyncResourceContext(this.resourceFrame, () => this.fn({ signal: controller.signal }));
62
+ } catch (err) {
63
+ this.pending = false;
64
+ this.error = err instanceof Error ? err : new Error(String(err));
65
+ if (notify) this.notifySubscribers();
66
+ return;
67
+ }
68
+ if (!isPromiseLike(result)) {
69
+ this.value = result;
70
+ this.pending = false;
71
+ this.error = null;
72
+ if (notify) this.notifySubscribers();
73
+ return;
74
+ }
75
+ if (ssr) throwSSRDataMissing();
76
+ Promise.resolve(result).then((val) => {
77
+ if (this.generation !== generation) return;
78
+ if (this.controller !== controller) return;
79
+ if (controller.signal.aborted) return;
80
+ this.value = val;
81
+ this.pending = false;
82
+ this.error = null;
83
+ this.notifySubscribers();
84
+ }).catch((err) => {
85
+ if (this.generation !== generation) return;
86
+ if (this.controller !== controller) return;
87
+ if (controller.signal.aborted || err instanceof Error && err.name === "AbortError" || typeof DOMException !== "undefined" && err instanceof DOMException && err.name === "AbortError") return;
88
+ this.pending = false;
89
+ this.error = err instanceof Error ? err : new Error(String(err));
90
+ try {
91
+ if (this.ownerName) logger.error(`[Askr] Async resource error in ${this.ownerName}:`, err);
92
+ else logger.error("[Askr] Async resource error:", err);
93
+ } catch {}
94
+ this.notifySubscribers();
95
+ });
96
+ }
97
+ refresh() {
98
+ if (this.disposed) return;
99
+ this.generation++;
100
+ this.controller?.abort();
101
+ this.start();
102
+ }
103
+ abort() {
104
+ this.controller?.abort();
105
+ }
106
+ dispose() {
107
+ if (this.disposed) return;
108
+ this.disposed = true;
109
+ this.controller?.abort();
110
+ this.subscribers.clear();
111
+ }
112
+ };
113
+ //#endregion
114
+ //#region src/runtime/resource-operation.ts
115
+ /**
116
+ * Resource primitive — simple, deterministic async primitive
117
+ * Usage: resource(fn, deps)
118
+ * - fn receives { signal }
119
+ * - captures execution context once at creation (synchronous step only)
120
+ * - executes at most once per generation; stale async results are ignored
121
+ * - refresh() cancels in-flight execution, increments generation and re-runs
122
+ * - exposes { value, pending, error, refresh }
123
+ * - during SSR, async results are disallowed and will throw synchronously
124
+ */
125
+ function resource(fn, deps = []) {
126
+ const instance = getCurrentComponentInstance();
127
+ const inst = instance;
128
+ if (!instance) {
129
+ const renderData = getCurrentRenderData()?.resources;
130
+ if (renderData && (getActiveRenderContext()?.resourceDataProvided || Object.keys(renderData).some((key) => key.startsWith("r:")))) {
131
+ const key = getNextRenderKey();
132
+ if (!(key in renderData)) throwSSRDataMissing();
133
+ const val = renderData[key];
134
+ return brandSnapshotSource({
135
+ value: val,
136
+ pending: false,
137
+ error: null,
138
+ refresh: () => {}
139
+ });
140
+ }
141
+ if (getActiveRenderContext()) throwSSRDataMissing();
142
+ throw new Error("[Askr] resource() must be called during component render inside an app. Do not create resources at module scope or outside render.");
143
+ }
144
+ const renderData = getCurrentRenderData()?.resources;
145
+ if (renderData && (getActiveRenderContext()?.resourceDataProvided || Object.keys(renderData).some((key) => key.startsWith("r:")))) {
146
+ const key = getNextRenderKey();
147
+ if (!(key in renderData)) throwSSRDataMissing();
148
+ const val = renderData[key];
149
+ const h = state({
150
+ cell: void 0,
151
+ snapshot: brandSnapshotSource({
152
+ value: val,
153
+ pending: false,
154
+ error: null,
155
+ refresh: () => {}
156
+ })
157
+ })();
158
+ h.snapshot.value = val;
159
+ h.snapshot.pending = false;
160
+ h.snapshot.error = null;
161
+ return h.snapshot;
162
+ }
163
+ const holder = state({
164
+ cell: void 0,
165
+ snapshot: brandSnapshotSource({
166
+ value: null,
167
+ pending: true,
168
+ error: null,
169
+ refresh: () => {}
170
+ })
171
+ });
172
+ const h = holder();
173
+ if (!h.cell) {
174
+ const cell = new ResourceCell(fn, deps, getCurrentContextFrame());
175
+ cell.ownerName = inst.fn?.name || "<anonymous>";
176
+ h.cell = cell;
177
+ h.snapshot = cell.snapshot;
178
+ const unsubscribe = cell.subscribe(() => {
179
+ const cur = holder();
180
+ cur.snapshot.value = cell.snapshot.value;
181
+ cur.snapshot.pending = cell.snapshot.pending;
182
+ cur.snapshot.error = cell.snapshot.error;
183
+ holder.set(cur);
184
+ try {
185
+ inst.notifyUpdate?.();
186
+ } catch {}
187
+ });
188
+ (inst.cleanupFns ??= []).push(() => {
189
+ unsubscribe();
190
+ cell.dispose();
191
+ });
192
+ if (inst.ssr) {
193
+ cell.start(true, false);
194
+ if (!cell.pending) {
195
+ const cur = holder();
196
+ cur.snapshot.value = cell.value;
197
+ cur.snapshot.pending = cell.pending;
198
+ cur.snapshot.error = cell.error;
199
+ }
200
+ } else {
201
+ const scheduledGeneration = cell.generation;
202
+ registerCommitOperationForInstance(inst, () => {
203
+ enqueueRuntimeLane("post", () => {
204
+ if (!inst.notifyUpdate || cell.generation !== scheduledGeneration) return;
205
+ try {
206
+ cell.start(false, false);
207
+ } catch (err) {
208
+ const cur = holder();
209
+ cur.snapshot.value = cell.value;
210
+ cur.snapshot.pending = cell.pending;
211
+ cur.snapshot.error = err ?? null;
212
+ holder.set(cur);
213
+ inst.notifyUpdate?.();
214
+ return;
215
+ }
216
+ if (!cell.pending) {
217
+ const cur = holder();
218
+ cur.snapshot.value = cell.value;
219
+ cur.snapshot.pending = cell.pending;
220
+ cur.snapshot.error = cell.error;
221
+ holder.set(cur);
222
+ inst.notifyUpdate?.();
223
+ }
224
+ });
225
+ });
226
+ }
227
+ }
228
+ const cell = h.cell;
229
+ cell.setLoader(fn);
230
+ if (!cell.deps || cell.deps.length !== deps.length || cell.deps.some((d, i) => !Object.is(d, deps[i]))) {
231
+ cell.deps = deps.slice();
232
+ cell.generation++;
233
+ cell.pending = true;
234
+ cell.error = null;
235
+ h.snapshot.pending = true;
236
+ h.snapshot.error = null;
237
+ try {
238
+ if (inst.ssr) {
239
+ cell.start(true, false);
240
+ if (!cell.pending) {
241
+ const cur = holder();
242
+ cur.snapshot.value = cell.value;
243
+ cur.snapshot.pending = cell.pending;
244
+ cur.snapshot.error = cell.error;
245
+ }
246
+ } else {
247
+ const scheduledGeneration = cell.generation;
248
+ registerCommitOperationForInstance(inst, () => {
249
+ enqueueRuntimeLane("post", () => {
250
+ if (!inst.notifyUpdate || cell.generation !== scheduledGeneration) return;
251
+ cell.start(false, false);
252
+ if (!cell.pending) {
253
+ const cur = holder();
254
+ cur.snapshot.value = cell.value;
255
+ cur.snapshot.pending = cell.pending;
256
+ cur.snapshot.error = cell.error;
257
+ holder.set(cur);
258
+ inst.notifyUpdate?.();
259
+ }
260
+ });
261
+ });
262
+ }
263
+ } catch (err) {
264
+ if (err instanceof SSRDataMissingError) throw err;
265
+ cell.error = err;
266
+ cell.pending = false;
267
+ const cur = holder();
268
+ cur.snapshot.value = cell.value;
269
+ cur.snapshot.pending = cell.pending;
270
+ cur.snapshot.error = cell.error;
271
+ }
272
+ }
273
+ return h.snapshot;
274
+ }
275
+ //#endregion
2
276
  //#region src/router/match.ts
3
277
  function splitPathSegments(path) {
4
278
  const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
@@ -510,4 +784,4 @@ function _resolveRouteMatchFromRoutes(pathname, routeList) {
510
784
  return findBestResolvedRouteFromRoutes(pathname, routeList);
511
785
  }
512
786
  //#endregion
513
- export { insertRecordSorted as A, getCurrentPathPrefix as C, getRouteRecords as D, getRouteList as E, snapshotRouteState as F, computeRank as I, normalizeRouteSegmentName as L, pushRegistrationScope as M, restoreRouteState as N, hasActivePageScope as O, setDefaultRouteAuthOptions as P, parseSegments as R, getCurrentPageScope as S, getDefaultRouteAuthOptions as T, getCurrentInheritedAuthRequirements as _, resolveRouteFromRoutes as a, getCurrentLayoutChain as b, deepFreeze as c, _setActiveRouteAuthOptions as d, addRouteToStores as f, getActiveRoutes as g, getActiveRouteAuthOptions as h, getMatchingRouteRecord as i, lockRouteRegistration as j, hasRegisteredRoutes as k, makeQuery as l, clearRouteState as m, computeMatchesFromRoutes as n, buildRouteContext as o, assertRouteRegistrationUnlocked as p, computeRouteActivityMatches as r, buildRouteContextBase as s, _resolveRouteMatchFromRoutes as t, parseLocation as u, getCurrentInheritedMeta as v, getCurrentScopeKind as w, getCurrentPageChain as x, getCurrentInheritedPolicies as y };
787
+ export { insertRecordSorted as A, getCurrentPathPrefix as C, getRouteRecords as D, getRouteList as E, snapshotRouteState as F, computeRank as I, normalizeRouteSegmentName as L, pushRegistrationScope as M, restoreRouteState as N, hasActivePageScope as O, setDefaultRouteAuthOptions as P, parseSegments as R, getCurrentPageScope as S, getDefaultRouteAuthOptions as T, getCurrentInheritedAuthRequirements as _, resolveRouteFromRoutes as a, getCurrentLayoutChain as b, deepFreeze as c, _setActiveRouteAuthOptions as d, addRouteToStores as f, getActiveRoutes as g, getActiveRouteAuthOptions as h, getMatchingRouteRecord as i, lockRouteRegistration as j, hasRegisteredRoutes as k, makeQuery as l, clearRouteState as m, computeMatchesFromRoutes as n, buildRouteContext as o, assertRouteRegistrationUnlocked as p, computeRouteActivityMatches as r, buildRouteContextBase as s, _resolveRouteMatchFromRoutes as t, parseLocation as u, getCurrentInheritedMeta as v, getCurrentScopeKind as w, getCurrentPageChain as x, getCurrentInheritedPolicies as y, resource as z };
@@ -1,8 +1,9 @@
1
1
  import { c as RenderableChild } from "../control-DO-iBEtV.js";
2
2
  import { r as JSXElement, s as Props } from "../jsx-Dvr2SGRG.js";
3
3
  import "../types-DEhT-Nrv.js";
4
- import { A as RouteRecord, B as RouteSnapshot, C as RouteMetaSource, D as RoutePathParams, E as RouteParams, F as RouteRenderResult, I as RouteRequestOptions, L as RouteRequestResult, M as RouteRefSearch, N as RouteRegistry, O as RoutePolicy, P as RouteRegistryOptions, R as RouteSearch, S as RouteMeta, T as RouteOptions, _ as RouteDefinition, a as AccessRedirectDecision, b as RouteManifest, c as LayoutScopeRecord, d as ParsedSegment, f as Route, g as RouteContext, h as RouteComponent, i as AccessDenyStatus, j as RouteRef, k as RouteQuery, l as PageHelperOptions, m as RouteAuthResolver, n as AccessDecision, o as AccessRedirectStatus, p as RouteAuthOptions, r as AccessDenyDecision, s as GroupHelperOptions, t as AccessAllowDecision, u as PageScopeRecord, v as RouteDestination, w as RouteMode, x as RouteMatch, y as RouteHandler, z as RouteSearchValue } from "../router-C0XQA62W.js";
5
- import { a as ScrollRestorationOptions, i as NavigationScrollBehavior, n as NavigateOptions, r as HistoryScrollBehavior, t as navigate } from "../navigate-CV-RDqYP.js";
4
+ import { A as RouteRecord, B as RouteSnapshot, C as RouteMetaSource, D as RoutePathParams, E as RouteParams, F as RouteRenderResult, I as RouteRequestOptions, L as RouteRequestResult, M as RouteRefSearch, N as RouteRegistry, O as RoutePolicy, P as RouteRegistryOptions, R as RouteSearch, S as RouteMeta, T as RouteOptions, _ as RouteDefinition, a as AccessRedirectDecision, b as RouteManifest, c as LayoutScopeRecord, d as ParsedSegment, f as Route, g as RouteContext, h as RouteComponent, i as AccessDenyStatus, j as RouteRef, k as RouteQuery, l as PageHelperOptions, m as RouteAuthResolver, n as AccessDecision, o as AccessRedirectStatus, p as RouteAuthOptions, r as AccessDenyDecision, s as GroupHelperOptions, t as AccessAllowDecision, u as PageScopeRecord, v as RouteDestination, w as RouteMode, x as RouteMatch, y as RouteHandler, z as RouteSearchValue } from "../router-C3vENhUh.js";
5
+ import { a as ScrollRestorationOptions, i as NavigationScrollBehavior, n as NavigateOptions, r as HistoryScrollBehavior, t as navigate } from "../navigate-Cbq6QHVl.js";
6
+ import { i as onRouteChange, n as RouteChangeOptions, r as currentRoute, t as RouteChangeCleanup } from "../activity-DZ-NCYr8.js";
6
7
  import { AuthContext, AuthContext as AuthContext$1, AuthRequirement, AuthRequirement as AuthRequirement$1 } from "@askrjs/auth";
7
8
  import { ObjectSchema } from "@askrjs/schema";
8
9
  //#region src/router/route-query.d.ts
@@ -39,9 +40,6 @@ declare function fallback(Component: RouteComponent): void;
39
40
  declare function route<const TPath extends string, const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined>(path: TPath, Component: RouteComponent<RoutePathParams<TPath>>, options?: RouteOptions<RoutePathParams<TPath>, TSearchSchema>): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
40
41
  declare function route<const TPath extends string, TComponent extends AnyRouteComponent, const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined>(path: TPath, Component: CompatibleRouteComponent<TPath, TComponent>, options?: RouteOptionsForComponent<TPath, TComponent, TSearchSchema>): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
41
42
  //#endregion
42
- //#region src/router/activity.d.ts
43
- declare function currentRoute<TParams extends RouteParams = RouteParams>(): RouteSnapshot<TParams>;
44
- //#endregion
45
43
  //#region src/router/auth.d.ts
46
44
  /** Return the identity resolved for the route currently being rendered. */
47
45
  declare function currentAuth(): AuthContext$1;
@@ -128,6 +126,8 @@ type LinkBaseProps = Omit<Props, 'children' | 'href' | 'class' | 'rel' | 'target
128
126
  * Optional aria-label for accessibility when link text isn't descriptive enough.
129
127
  */
130
128
  'aria-label'?: string;
129
+ onPress?: (event: Event) => void;
130
+ onClick?: (event: MouseEvent) => void;
131
131
  };
132
132
  type LinkProps = LinkBaseProps & ({
133
133
  href: string;
@@ -163,6 +163,6 @@ type LinkProps = LinkBaseProps & ({
163
163
  * - Keyboard handling automatic
164
164
  * - Composable via mergeProps
165
165
  */
166
- declare function Link({ href: suppliedHref, to, class: className, children, rel, target, 'aria-current': ariaCurrent, 'aria-label': ariaLabel, ...rest }: LinkProps): JSXElement;
166
+ declare function Link({ href: suppliedHref, to, class: className, children, rel, target, 'aria-current': ariaCurrent, 'aria-label': ariaLabel, onPress, onClick, ...rest }: LinkProps): JSXElement;
167
167
  //#endregion
168
- export { type AccessDecision, type AccessDenyDecision, type AccessRedirectDecision, type AuthContext, type AuthRequirement, type Deferred, type DeferredState, type GroupHelperOptions, type HistoryScrollBehavior, type LayoutScopeRecord, type LazyRouteComponent, Link, type LinkProps, type NavigateOptions, type NavigationScrollBehavior, Outlet, type PageHelperOptions, type PageScopeRecord, type ParsedSegment, Resolve, type ResolveProps, type Route, type RouteAuthOptions, type RouteAuthResolver, type RouteComponent, type RouteContext, type RouteDefinition, type RouteDestination, type RouteHandler, type RouteManifest, type RouteMatch, type RouteMeta, type RouteMetaSource, type RouteMode, type RouteOptions, type RouteParams, type RoutePathParams, type RoutePolicy, type RouteQuery, type RouteQueryParamInput, type RouteQueryParamValue, type RouteQueryUpdater, type RouteQueryUpdates, type RouteRecord, type RouteRef, type RouteRegistry, type RouteRegistryOptions, type RouteRenderResult, type RouteRequestOptions, type RouteRequestResult, type RouteSearch, type RouteSearchValue, type RouteSnapshot, type ScrollRestorationOptions, type UpdateRouteQueryOptions, allow, createRouteRegistry, currentAuth, currentRoute, defer, deny, fallback, forbidden, group, index, isDeferred, lazy, navigate, notFound, page, reconcileRouteMeta, redirect, resolveDeferredValues, resolveRouteMeta, resolveRouteRequest, route, routeData, serializeRouteMeta, to$1 as to, unauthorized, updateRouteQuery };
168
+ export { type AccessDecision, type AccessDenyDecision, type AccessRedirectDecision, type AuthContext, type AuthRequirement, type Deferred, type DeferredState, type GroupHelperOptions, type HistoryScrollBehavior, type LayoutScopeRecord, type LazyRouteComponent, Link, type LinkProps, type NavigateOptions, type NavigationScrollBehavior, Outlet, type PageHelperOptions, type PageScopeRecord, type ParsedSegment, Resolve, type ResolveProps, type Route, type RouteAuthOptions, type RouteAuthResolver, type RouteChangeCleanup, type RouteChangeOptions, type RouteComponent, type RouteContext, type RouteDefinition, type RouteDestination, type RouteHandler, type RouteManifest, type RouteMatch, type RouteMeta, type RouteMetaSource, type RouteMode, type RouteOptions, type RouteParams, type RoutePathParams, type RoutePolicy, type RouteQuery, type RouteQueryParamInput, type RouteQueryParamValue, type RouteQueryUpdater, type RouteQueryUpdates, type RouteRecord, type RouteRef, type RouteRegistry, type RouteRegistryOptions, type RouteRenderResult, type RouteRequestOptions, type RouteRequestResult, type RouteSearch, type RouteSearchValue, type RouteSnapshot, type ScrollRestorationOptions, type UpdateRouteQueryOptions, allow, createRouteRegistry, currentAuth, currentRoute, defer, deny, fallback, forbidden, group, index, isDeferred, lazy, navigate, notFound, onRouteChange, page, reconcileRouteMeta, redirect, resolveDeferredValues, resolveRouteMeta, resolveRouteRequest, route, routeData, serializeRouteMeta, to$1 as to, unauthorized, updateRouteQuery };