@askrjs/askr 0.0.69 → 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.
- package/capabilities.json +66 -0
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.js +9 -2
- package/dist/activity-C2tPn9Fr.js +152 -0
- package/dist/activity-DZ-NCYr8.d.ts +10 -0
- package/dist/{authoring-uaJ556aG.js → authoring-CXmUcaCe.js} +2 -2
- package/dist/benchmark.d.ts +1 -1
- package/dist/benchmark.js +6 -6
- package/dist/boot/index.d.ts +2 -2
- package/dist/boot/index.js +1 -1
- package/dist/{boot-aTei9rjA.js → boot-DIKbEA4Y.js} +11 -10
- package/dist/{cleanup-UyStxIHG.js → cleanup-D8Ufd9Ix.js} +29 -8
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/control/index.d.ts +1 -1
- package/dist/control/index.js +1 -1
- package/dist/{control-CA45Yvvu.js → control-DVRBkN2X.js} +7 -2
- package/dist/{csp-nonce-HGZ0vbqT.js → csp-nonce-CwSRP3Jl.js} +16 -1
- package/dist/css-BuPaTOfe.js +70 -0
- package/dist/data/index.js +3 -3
- package/dist/{data-DHt_zO1G.js → data-DFcSmGvN.js} +2 -2
- package/dist/{data-runtime-SJ1BSUvk.js → data-runtime-rpV6-3XW.js} +13 -2
- package/dist/{deferred-zHtUheIQ.js → deferred-Cr58yIQD.js} +3 -4
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/structures/index.d.ts +1 -1
- package/dist/foundations/structures/index.js +1 -1
- package/dist/{index-BFnTM1a8.d.ts → index-BOBtoY_r.d.ts} +34 -2
- package/dist/{index-DSClfSoC.d.ts → index-DxYJPVC4.d.ts} +1 -1
- package/dist/{index-Dh6ZF9yW.d.ts → index-UmwPZ8ZN.d.ts} +5 -0
- package/dist/{index-DjusBb1I.d.ts → index-u3KYoHlM.d.ts} +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +12 -7
- package/dist/jsx-dev-runtime.d.ts +1 -0
- package/dist/jsx-runtime-C6Fs8Mmc.d.ts +2 -0
- package/dist/{jsx-runtime-aYZ8zb4q.d.ts → jsx-runtime-CL2r2HHQ.d.ts} +1 -0
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/{lifecycle-operations-SlPEK68H.js → lifecycle-operations-Db-_MG-O.js} +9 -12
- package/dist/{navigate-CV-RDqYP.d.ts → navigate-Cbq6QHVl.d.ts} +1 -1
- package/dist/{navigate-DpR-cML9.js → navigate-CuGQzS_Y.js} +8 -104
- package/dist/{portal-D7TC986A.js → portal-wY3j0vvp.js} +59 -1
- package/dist/{query-registry-CQIT4mXr.js → query-registry-Bu_cuMch.js} +1 -1
- package/dist/{renderer-CBBbYZUO.js → renderer-BJYY2Y8s.js} +91 -10
- package/dist/resources/index.d.ts +27 -8
- package/dist/resources/index.js +218 -4
- package/dist/{route-matching-DLBWDeXX.js → route-matching-M-f1VQRu.js} +276 -2
- package/dist/router/index.d.ts +7 -7
- package/dist/router/index.js +28 -17
- package/dist/{router-C0XQA62W.d.ts → router-C3vENhUh.d.ts} +1 -1
- package/dist/{selector-DueeR6Oz.js → selector-DEfqO1rA.js} +8 -0
- package/dist/ssg/index.d.ts +8 -1
- package/dist/ssg/index.js +53 -17
- package/dist/ssr/index.d.ts +15 -1
- package/dist/ssr/index.js +1 -1
- package/dist/{ssr-vE-KUgDV.js → ssr-BSUA9Y64.js} +72 -78
- package/dist/testing/index.d.ts +35 -2
- package/dist/testing/index.js +182 -3
- package/dist/{verify-hydration-ChyEiBAn.js → verify-hydration-CVSGv6Vs.js} +1 -1
- package/package.json +4 -2
- package/dist/attr-names-CjhzmHOn.js +0 -15
- package/dist/component-scope-CvPba6O6.d.ts +0 -12
- package/dist/invalidation-listeners-Des3AHYs.js +0 -13
- package/dist/jsx-runtime-X2SX2y8V.d.ts +0 -2
- package/dist/resource-operation-BJiLoLYZ.js +0 -276
|
@@ -1,276 +0,0 @@
|
|
|
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
|
|
276
|
-
export { resource as t };
|