@askrjs/askr 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +874 -0
  2. package/README.md +61 -29
  3. package/capabilities.json +19 -9
  4. package/dist/actions/index.js +56 -12
  5. package/dist/benchmark.js +10 -15
  6. package/dist/boot/index.d.ts +3 -2
  7. package/dist/boot/index.js +1 -1
  8. package/dist/boot-DaoTYoCw.js +3989 -0
  9. package/dist/browser-activity-CB8e-V4f.js +220 -0
  10. package/dist/components/index.d.ts +8 -1
  11. package/dist/components/index.js +1 -43
  12. package/dist/{aria-hKjThHcp.js → compose-ref-DWzdbxsD.js} +41 -4
  13. package/dist/control/index.d.ts +2 -0
  14. package/dist/control/index.js +1 -1
  15. package/dist/control-nfpT2fbK.js +209 -0
  16. package/dist/core.d.ts +5 -9
  17. package/dist/csp-nonce-DwGw1A6Q.js +35 -0
  18. package/dist/data/index.js +3 -3
  19. package/dist/{data-2edW0jhF.js → data-BCwClJiF.js} +283 -94
  20. package/dist/data-runtime-C1bFAlba.js +242 -0
  21. package/dist/{deferred-CbgNhf67.js → deferred-bEEHHvic.js} +42 -20
  22. package/dist/domains/actions.d.ts +8 -3
  23. package/dist/domains/component.d.ts +1 -107
  24. package/dist/domains/context.d.ts +0 -15
  25. package/dist/domains/control.d.ts +36 -249
  26. package/dist/domains/data.d.ts +31 -13
  27. package/dist/domains/diagnostics.d.ts +1 -2
  28. package/dist/domains/lifecycle.d.ts +2 -5
  29. package/dist/domains/refs.d.ts +0 -2
  30. package/dist/domains/routing.d.ts +43 -8
  31. package/dist/domains/scheduler.d.ts +1 -76
  32. package/dist/domains/server.d.ts +5 -2
  33. package/dist/domains/state.d.ts +2 -5
  34. package/dist/domains/telemetry.d.ts +0 -2
  35. package/dist/elements.d.ts +214 -51
  36. package/dist/error-boundary-Bpwofwps.js +293 -0
  37. package/dist/foundations/icon/index.d.ts +0 -58
  38. package/dist/foundations/icon/index.js +2 -2
  39. package/dist/foundations/index.js +2 -1
  40. package/dist/foundations/interactions/index.js +1 -1
  41. package/dist/foundations/state/index.d.ts +3 -3
  42. package/dist/foundations/state/index.js +5 -3
  43. package/dist/foundations/structures/index.js +2 -1
  44. package/dist/foundations/utilities/index.d.ts +2 -0
  45. package/dist/foundations/utilities/index.js +1 -2
  46. package/dist/fx/index.d.ts +31 -58
  47. package/dist/fx/index.js +313 -195
  48. package/dist/hooks-BimKStr4.js +202 -0
  49. package/dist/index.d.ts +11 -74
  50. package/dist/index.js +8 -447
  51. package/dist/instance-BAnfmXOR.js +988 -0
  52. package/dist/{interactions-CTeACdT_.js → interactions-D2BoREb-.js} +3 -2
  53. package/dist/jsx-dev-runtime.d.ts +41 -18
  54. package/dist/jsx-dev-runtime.js +1 -6
  55. package/dist/{jsx-runtime-CPJXAOBF.js → jsx-runtime-C4idqHY0.js} +18 -7
  56. package/dist/jsx-runtime.js +1 -1
  57. package/dist/jsx.d.ts +61 -37
  58. package/dist/{manifest-D1P3UNWV.js → manifest-CW9gyNBY.js} +3 -3
  59. package/dist/{navigate-prC5V8XV.js → navigate-CP_0Zy5U.js} +454 -87
  60. package/dist/navigation.d.ts +12 -3
  61. package/dist/peer-types.d.ts +8 -0
  62. package/dist/portal-DuOKfnLa.js +349 -0
  63. package/dist/promise-Dz8iIHAm.js +16 -0
  64. package/dist/query-registry-WMCN0BJL.js +320 -0
  65. package/dist/readable-DFWOsTac.js +21 -0
  66. package/dist/{render-context-B7ohlh6t.js → render-context-DGHnEveC.js} +27 -11
  67. package/dist/render-sync-IC5lMFpq.js +1240 -0
  68. package/dist/resolution-Cx82-xjW.js +1244 -0
  69. package/dist/resource-CLjB7RBQ.js +377 -0
  70. package/dist/resources/index.d.ts +21 -11
  71. package/dist/resources/index.js +45 -244
  72. package/dist/router/index.d.ts +14 -5
  73. package/dist/router/index.js +22 -53
  74. package/dist/scope-CwpVSHVf.js +55 -0
  75. package/dist/{shared-kU8yvryp.js → shared-O2ZnmYAf.js} +1 -7
  76. package/dist/{snapshot-source-An4iKajG.js → snapshot-Cjx4N988.js} +6 -1
  77. package/dist/ssg/index.d.ts +1 -2
  78. package/dist/ssg/index.js +5 -13
  79. package/dist/ssr/index.d.ts +26 -28
  80. package/dist/ssr/index.js +4 -4
  81. package/dist/{ssr-CiNm6Vzl.js → ssr-BJ8ug7zH.js} +133 -122
  82. package/dist/ssr-DoV-vJ-5.js +229 -0
  83. package/dist/state-DWO1KzkX.js +232 -0
  84. package/dist/structures-D4dDMqHX.js +231 -0
  85. package/dist/testing/index.d.ts +8 -4
  86. package/dist/testing/index.js +29 -34
  87. package/dist/url-CnbfpX0K.js +185 -0
  88. package/dist/utilities.d.ts +48 -2
  89. package/dist/verify-hydration-DpVaDnqz.js +152 -0
  90. package/package.json +19 -9
  91. package/dist/access-CEA2pOry.js +0 -1046
  92. package/dist/activity-oy2YFTFF.js +0 -201
  93. package/dist/boot-BMBMWUGI.js +0 -1084
  94. package/dist/capabilities-Bbf0mlp9.js +0 -42
  95. package/dist/compose-ref-v0qGlHoN.js +0 -26
  96. package/dist/control-BR_mrX__.js +0 -173
  97. package/dist/control-C-ApnFs1.js +0 -20
  98. package/dist/csp-nonce-BfFWcd0w.js +0 -173
  99. package/dist/data-runtime-CxoY98lX.js +0 -149
  100. package/dist/default-portal-runtime-DvMvWJVp.js +0 -20
  101. package/dist/dom-renderer.d.ts +0 -77
  102. package/dist/domains/renderer.d.ts +0 -127
  103. package/dist/eager-control.d.ts +0 -8
  104. package/dist/effect-C3Zsc1k6.js +0 -292
  105. package/dist/for-state-BDykeOJL.js +0 -1753
  106. package/dist/instance-VAFYVJOa.js +0 -1027
  107. package/dist/notify-DxxuDPeY.js +0 -266
  108. package/dist/portal-w3oQ6oQU.js +0 -29
  109. package/dist/query-registry-LrYpQsDJ.js +0 -83
  110. package/dist/render-resolved-BC0W7_5b.js +0 -1123
  111. package/dist/renderer-CT0HeY58.js +0 -8623
  112. package/dist/resolution-3DskUkjG.js +0 -577
  113. package/dist/resource-18-sFRl9.js +0 -344
  114. package/dist/route-matching-CUzZ31gT.js +0 -551
  115. package/dist/router-internal-7nuNEHfG.js +0 -36
  116. package/dist/scope-Cq_iYbTR.js +0 -403
  117. package/dist/selector-BSPVkjKP.js +0 -311
  118. package/dist/ssr-EPjwJH5R.js +0 -29
  119. package/dist/state-BXJfudq1.js +0 -91
  120. package/dist/structures-CjEzfj4h.js +0 -654
  121. package/dist/timer-C7uqnJVt.js +0 -85
  122. package/dist/verify-hydration-ikaxotf7.js +0 -27
  123. package/dist/vnode-D24p6IW2.js +0 -7
@@ -1,266 +0,0 @@
1
- import { _ as defaultRuntimeState, d as markRuntimeReactivePropsDirtySource, n as enqueueRuntimeTask, u as isRuntimeSchedulerExecuting } from "./access-CEA2pOry.js";
2
- import { f as getCurrentComponentInstance } from "./scope-Cq_iYbTR.js";
3
- //#region src/runtime/reactivity/readable.ts
4
- const DEVELOPMENT_BUILD_ENABLED = false;
5
- function markReadableUsage(source) {
6
- if (source && typeof source === "function" && ("_hasBeenRead" in source || "_readers" in source)) {
7
- const readable = source;
8
- readable._hasBeenRead = true;
9
- if (readable._unusedStateDiagnosticEligible === true) readable._hasEverBeenRead = true;
10
- }
11
- }
12
- let currentDerivedSubscriber = null;
13
- let suppressComponentReadTrackingDepth = 0;
14
- let currentFineGrainedReadCollector = null;
15
- function scheduleReadableInstanceUpdate(instance) {
16
- if (instance.owner.disposed || instance.hasPendingUpdate) return;
17
- instance.hasPendingUpdate = true;
18
- const task = instance._pendingFlushTask;
19
- if (task) {
20
- enqueueRuntimeTask(task);
21
- return;
22
- }
23
- enqueueRuntimeTask(() => {
24
- instance.hasPendingUpdate = false;
25
- instance.notifyUpdate?.();
26
- });
27
- }
28
- function recordReadableRead(source) {
29
- if (source._unusedStateDiagnosticEligible === true) source._hasEverBeenRead = true;
30
- if (currentFineGrainedReadCollector) {
31
- const first = currentFineGrainedReadCollector._pendingFineGrainedReadSource;
32
- if (!first) currentFineGrainedReadCollector._pendingFineGrainedReadSource = source;
33
- else if (first !== source) {
34
- let sources = currentFineGrainedReadCollector._pendingFineGrainedReadSources;
35
- if (!sources) currentFineGrainedReadCollector._pendingFineGrainedReadSources = source;
36
- else if (Array.isArray(sources)) {
37
- if (!sources.includes(source)) sources.push(source);
38
- } else if (sources instanceof Set) sources.add(source);
39
- else if (sources !== source) currentFineGrainedReadCollector._pendingFineGrainedReadSources = [
40
- first,
41
- sources,
42
- source
43
- ];
44
- }
45
- return;
46
- }
47
- if (currentDerivedSubscriber) {
48
- if (!currentDerivedSubscriber._pendingDependencySources) currentDerivedSubscriber._pendingDependencySources = /* @__PURE__ */ new Set();
49
- currentDerivedSubscriber._pendingDependencySources.add(source);
50
- }
51
- if (suppressComponentReadTrackingDepth > 0) return;
52
- const inst = getCurrentComponentInstance();
53
- if (!inst || inst._currentRenderToken === void 0) return;
54
- if (!inst._pendingReadSources) inst._pendingReadSources = /* @__PURE__ */ new Set();
55
- inst._pendingReadSources.add(source);
56
- const sourceVersion = source._version ?? 0;
57
- let pendingVersions = inst._pendingReadSourceVersions;
58
- if (!pendingVersions) {
59
- pendingVersions = /* @__PURE__ */ new Map();
60
- inst._pendingReadSourceVersions = pendingVersions;
61
- }
62
- pendingVersions.set(source, sourceVersion);
63
- }
64
- function withFineGrainedReadTracking(collector, fn) {
65
- const previousCollector = currentFineGrainedReadCollector;
66
- currentFineGrainedReadCollector = collector;
67
- try {
68
- return fn.call(collector);
69
- } finally {
70
- currentFineGrainedReadCollector = previousCollector;
71
- }
72
- }
73
- /** @internal Whether the active grouped effect coalesces item-property reads. */
74
- function shouldCoalesceFineGrainedItemReads() {
75
- return (currentFineGrainedReadCollector?._owner)?._coalesceForItemReads === true;
76
- }
77
- function finalizeReadableSubscriptionsFromSnapshot(instance, token, newSet, pendingReadSourceVersions = instance._pendingReadSourceVersions, ownershipGeneration = instance.owner.identity) {
78
- if (instance.owner.disposed || token === void 0 || instance.owner.identity !== ownershipGeneration || !instance.owner.mounted && instance.notifyUpdate === null) return;
79
- const oldSet = instance.owner.reads;
80
- const pendingVersions = pendingReadSourceVersions;
81
- let needsFollowUpUpdate = false;
82
- if (oldSet) {
83
- for (const source of oldSet) if (!newSet?.has(source)) {
84
- if ((source._readers?.get(instance))?.generation === instance.owner.identity) {
85
- if (source._readers?.delete(instance) && DEVELOPMENT_BUILD_ENABLED);
86
- }
87
- }
88
- }
89
- instance.lastRenderToken = token;
90
- if (newSet) for (const source of newSet) {
91
- if (pendingVersions) {
92
- const sourceVersion = source._version ?? 0;
93
- const readVersion = pendingVersions.get(source);
94
- if (readVersion !== void 0 && sourceVersion !== readVersion && (!oldSet || oldSet.has(source) || isRuntimeSchedulerExecuting())) needsFollowUpUpdate = true;
95
- }
96
- let readers = source._readers;
97
- if (!readers) {
98
- readers = /* @__PURE__ */ new Map();
99
- source._readers = readers;
100
- }
101
- readers.has(instance);
102
- readers.set(instance, {
103
- token: instance.lastRenderToken ?? 0,
104
- generation: instance.owner.identity
105
- });
106
- }
107
- instance.owner.reads = newSet?.size ? newSet : void 0;
108
- if (needsFollowUpUpdate) scheduleReadableInstanceUpdate(instance);
109
- }
110
- /** @internal Detach an exact committed read set without mutating another live generation. */
111
- function cleanupReadableSubscriptionSources(instance, sources, generation) {
112
- if (!sources) return;
113
- for (const source of sources) if ((source._readers?.get(instance))?.generation === generation) {
114
- if (source._readers?.delete(instance) && DEVELOPMENT_BUILD_ENABLED);
115
- }
116
- }
117
- function withDerivedReadTracking(subscriber, fn) {
118
- const prevDerivedSubscriber = currentDerivedSubscriber;
119
- currentDerivedSubscriber = subscriber;
120
- suppressComponentReadTrackingDepth += 1;
121
- try {
122
- return fn();
123
- } finally {
124
- suppressComponentReadTrackingDepth -= 1;
125
- currentDerivedSubscriber = prevDerivedSubscriber;
126
- }
127
- }
128
- function syncDerivedDependencySubscriptions(subscriber, prevSources, nextSources) {
129
- for (const source of prevSources) if (!nextSources.has(source)) source._derivedSubscribers?.delete(subscriber);
130
- for (const source of nextSources) {
131
- let subscribers = source._derivedSubscribers;
132
- if (!subscribers) {
133
- subscribers = /* @__PURE__ */ new Set();
134
- source._derivedSubscribers = subscribers;
135
- }
136
- subscribers.add(subscriber);
137
- }
138
- }
139
- function clearDerivedDependencySubscriptions(subscriber, sources) {
140
- for (const source of sources) source._derivedSubscribers?.delete(subscriber);
141
- sources.clear();
142
- }
143
- function markReadableDerivedSubscribersDirty(source, skipCurrentSubscriber = false) {
144
- const subscribers = source._derivedSubscribers;
145
- if (!subscribers || subscribers.size === 0) return;
146
- for (const subscriber of subscribers) {
147
- if (skipCurrentSubscriber && subscriber === currentDerivedSubscriber) continue;
148
- subscriber._markDirty();
149
- }
150
- }
151
- function markReactivePropsDirtySource(source) {
152
- try {
153
- markRuntimeReactivePropsDirtySource(source);
154
- } catch {}
155
- }
156
- function notifyReadableReaders(source, skipInstance, skipOwnedBy) {
157
- source._version = (source._version ?? 0) + 1;
158
- const readers = source._readers;
159
- let didScheduleUpdate = false;
160
- if (!readers || readers.size === 0) return false;
161
- for (const [instance, reader] of readers) {
162
- if (skipInstance && instance === skipInstance) continue;
163
- if (skipOwnedBy) {
164
- let owner = instance;
165
- let isOwned = false;
166
- while (owner) {
167
- if (owner === skipOwnedBy) {
168
- isOwned = true;
169
- break;
170
- }
171
- owner = owner.parentInstance;
172
- }
173
- if (isOwned) continue;
174
- }
175
- if (instance.owner.identity !== reader.generation || instance.lastRenderToken !== reader.token) continue;
176
- if (instance.hasPendingUpdate) continue;
177
- scheduleReadableInstanceUpdate(instance);
178
- didScheduleUpdate = true;
179
- }
180
- return didScheduleUpdate;
181
- }
182
- //#endregion
183
- //#region src/runtime/transactions/access.ts
184
- /**
185
- * Resolved per call rather than captured at import time.
186
- *
187
- * Binding the coordinator once when this module is first evaluated meant these
188
- * helpers could never follow a runtime whose state was replaced afterwards —
189
- * the import order of an unrelated module decided which coordinator they used.
190
- */
191
- function commitCoordinator() {
192
- return defaultRuntimeState.commits;
193
- }
194
- function beginCommitTransaction() {
195
- return commitCoordinator().begin();
196
- }
197
- function getCurrentCommitTransaction() {
198
- const transaction = commitCoordinator().current;
199
- return transaction?.active ? transaction : null;
200
- }
201
- function deferCommitNotification(key, notify) {
202
- return commitCoordinator().deferCompletion(key, notify);
203
- }
204
- function commitTransaction(transaction) {
205
- commitCoordinator().commit(transaction);
206
- }
207
- function discardTransaction(transaction) {
208
- commitCoordinator().discard(transaction);
209
- }
210
- function suspendTransaction(transaction) {
211
- commitCoordinator().suspend(transaction);
212
- }
213
- function applyTransaction(transaction, operation) {
214
- return commitCoordinator().apply(transaction, operation);
215
- }
216
- function registerCommitParticipant(participant) {
217
- return commitCoordinator().register(participant);
218
- }
219
- function registerCommitEffect(key, settle, rollback, merge) {
220
- return registerCommitParticipant({
221
- key,
222
- settle,
223
- rollback,
224
- merge
225
- });
226
- }
227
- function registerCommitRollback(rollback) {
228
- return registerCommitParticipant({ rollback });
229
- }
230
- function runCommitTransaction(operation) {
231
- const transaction = beginCommitTransaction();
232
- try {
233
- const result = applyTransaction(transaction, operation);
234
- commitTransaction(transaction);
235
- return result;
236
- } catch (error) {
237
- discardTransaction(transaction);
238
- throw error;
239
- } finally {
240
- suspendTransaction(transaction);
241
- }
242
- }
243
- /** Operation boundaries reuse their enclosing transaction, or own its lifetime. */
244
- function runCommitOperation(operation) {
245
- return getCurrentCommitTransaction() ? operation() : runCommitTransaction(operation);
246
- }
247
- //#endregion
248
- //#region src/runtime/reactivity/notify.ts
249
- /**
250
- * Publish a change to everything subscribed to `source`.
251
- *
252
- * A readable source has four kinds of subscriber — derived values, reactive
253
- * props (and, through them, fine-grained effects), and component readers — and
254
- * every one of them has to be told, in this order. That sequence was written
255
- * out by hand at nine call sites across the reactivity core, portals, control
256
- * flow, the router and the data layer, and had already drifted into four
257
- * variants; the only named copy lived in `data/`, which the runtime cannot
258
- * import. It belongs here, beside the three primitives it drives.
259
- */
260
- function notifyReadableSource(source, options) {
261
- markReadableDerivedSubscribersDirty(source, options?.skipCurrentDerivedSubscriber);
262
- markReactivePropsDirtySource(source);
263
- notifyReadableReaders(source, options?.skipInstance, options?.skipOwnedBy);
264
- }
265
- //#endregion
266
- export { withFineGrainedReadTracking as S, markReadableUsage as _, deferCommitNotification as a, syncDerivedDependencySubscriptions as b, registerCommitEffect as c, runCommitOperation as d, runCommitTransaction as f, finalizeReadableSubscriptionsFromSnapshot as g, clearDerivedDependencySubscriptions as h, commitTransaction as i, registerCommitParticipant as l, cleanupReadableSubscriptionSources as m, applyTransaction as n, discardTransaction as o, suspendTransaction as p, beginCommitTransaction as r, getCurrentCommitTransaction as s, notifyReadableSource as t, registerCommitRollback as u, recordReadableRead as v, withDerivedReadTracking as x, shouldCoalesceFineGrainedItemReads as y };
@@ -1,29 +0,0 @@
1
- //#region src/common/portal.ts
2
- /**
3
- * Internal marker used to defer server portal host output until all writes in
4
- * the current render root are known.
5
- *
6
- * @internal
7
- */
8
- const SSR_PORTAL_HOST = Symbol.for("askr.ssr-portal-host");
9
- const SSR_PORTAL_ANCHOR = Symbol.for("askr.ssr-portal-anchor");
10
- const SSR_PORTAL_HOST_PREFIX = "askr-portal:";
11
- const SSR_PORTAL_ANCHOR_PREFIX = "askr-portal-anchor:";
12
- function createSSRPortalHostToken(id) {
13
- return `<!--${SSR_PORTAL_HOST_PREFIX}${id}-->`;
14
- }
15
- function createSSRPortalAnchorToken(id) {
16
- return `<!--${SSR_PORTAL_ANCHOR_PREFIX}${id}-->`;
17
- }
18
- function isSSRPortalMarkerData(data, prefix) {
19
- if (!data.startsWith(prefix)) return false;
20
- const id = data.slice(prefix.length);
21
- return id.length > 0 && Array.from(id).every((char) => char >= "0" && char <= "9");
22
- }
23
- function isSSRPortalHydrationAnchor(node) {
24
- if (typeof node !== "object" || node === null || node.nodeType !== 8) return false;
25
- const data = node.data;
26
- return typeof data === "string" && (isSSRPortalMarkerData(data, SSR_PORTAL_HOST_PREFIX) || isSSRPortalMarkerData(data, SSR_PORTAL_ANCHOR_PREFIX));
27
- }
28
- //#endregion
29
- export { isSSRPortalHydrationAnchor as a, createSSRPortalHostToken as i, SSR_PORTAL_HOST as n, createSSRPortalAnchorToken as r, SSR_PORTAL_ANCHOR as t };
@@ -1,83 +0,0 @@
1
- import { i as getDefaultDataRuntime, t as createDataRuntime } from "./data-runtime-CxoY98lX.js";
2
- //#region src/common/telemetry.ts
3
- function withTelemetry(span, fields, work) {
4
- return span ? span(fields, work) : work();
5
- }
6
- //#endregion
7
- //#region src/data/query-registry.ts
8
- /** Pair a {@link QueryDefinition} with the server-side handler that resolves it. */
9
- function serveQuery(query, handler) {
10
- return Object.freeze({
11
- query,
12
- handler
13
- });
14
- }
15
- /** Build a {@link ServerQueryRegistry} from one or more {@link serveQuery} entries. */
16
- function defineServerQueries(...entries) {
17
- const frozenEntries = Object.freeze([...entries]);
18
- const handlers = new Map(entries.map((entry) => [entry.query, entry.handler]));
19
- return Object.freeze({
20
- entries: frozenEntries,
21
- get(query) {
22
- return handlers.get(query);
23
- }
24
- });
25
- }
26
- /** Freeze and return a reusable {@link QueryDefinition}. */
27
- function defineQuery(definition) {
28
- return Object.freeze({ ...definition });
29
- }
30
- /**
31
- * Create a {@link QueryPrefetchContext} for prefetching query data ahead of
32
- * render, e.g. during SSR route resolution.
33
- */
34
- function createQueryPrefetchContext(options = {}) {
35
- const runtime = options.runtime ?? (options.mode === "spa" ? getDefaultDataRuntime() : createDataRuntime());
36
- const signal = options.signal ?? new AbortController().signal;
37
- return {
38
- runtime,
39
- request: options.request,
40
- signal,
41
- mode: options.mode ?? "spa",
42
- async prefetch(query, input) {
43
- return withTelemetry(options.telemetry?.queryPrefetch, {}, async () => {
44
- const key = query.key(input);
45
- if (runtime.queryData.has(key)) return true;
46
- let value;
47
- const handler = options.mode === "ssr" ? options.registry?.get(query) : void 0;
48
- if (options.mode === "ssr" && !handler) return false;
49
- value = handler ? await handler({
50
- input,
51
- request: options.request,
52
- signal
53
- }) : await query.fetch({
54
- ...input,
55
- signal
56
- });
57
- if (signal.aborted) return false;
58
- runtime.queryData.set(key, value);
59
- return true;
60
- });
61
- }
62
- };
63
- }
64
- /** Prefetch `query` with `input` into a {@link QueryPrefetchContext}'s runtime. */
65
- async function prefetchQuery(context, query, input) {
66
- return context.prefetch(query, input);
67
- }
68
- /** Extract a runtime's cached query data into a JSON-serializable snapshot, dropping non-serializable values. */
69
- function dehydrateDataRuntime(runtime) {
70
- const result = {};
71
- for (const [key, value] of runtime.queryData) try {
72
- JSON.stringify(value);
73
- result[key] = value;
74
- } catch {}
75
- return result;
76
- }
77
- /** Load a {@link dehydrateDataRuntime} snapshot back into a runtime's query cache. */
78
- function hydrateDataRuntime(runtime, data) {
79
- if (!data || typeof data !== "object" || Array.isArray(data)) return;
80
- for (const [key, value] of Object.entries(data)) runtime.queryData.set(key, value);
81
- }
82
- //#endregion
83
- export { hydrateDataRuntime as a, withTelemetry as c, dehydrateDataRuntime as i, defineQuery as n, prefetchQuery as o, defineServerQueries as r, serveQuery as s, createQueryPrefetchContext as t };