solid-js 2.0.0-beta.1 → 2.0.0-beta.10
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/CHEATSHEET.md +640 -0
- package/README.md +42 -188
- package/dist/dev.cjs +431 -283
- package/dist/dev.js +411 -286
- package/dist/server.cjs +701 -281
- package/dist/server.js +684 -284
- package/dist/solid.cjs +423 -255
- package/dist/solid.js +403 -258
- package/package.json +67 -39
- package/types/client/component.d.ts +64 -19
- package/types/client/core.d.ts +110 -34
- package/types/client/flow.d.ts +176 -42
- package/types/client/hydration.d.ts +514 -36
- package/types/index.d.ts +9 -12
- package/types/server/component.d.ts +11 -11
- package/types/server/core.d.ts +19 -14
- package/types/server/flow.d.ts +76 -21
- package/types/server/hydration.d.ts +34 -9
- package/types/server/index.d.ts +5 -7
- package/types/server/shared.d.ts +5 -1
- package/types/server/signals.d.ts +44 -19
- package/types/types.d.ts +15 -0
- package/types-cjs/client/component.d.cts +120 -0
- package/types-cjs/client/core.d.cts +141 -0
- package/types-cjs/client/flow.d.cts +234 -0
- package/types-cjs/client/hydration.d.cts +570 -0
- package/types-cjs/index.d.cts +17 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server/component.d.cts +67 -0
- package/types-cjs/server/core.d.cts +49 -0
- package/types-cjs/server/flow.d.cts +115 -0
- package/types-cjs/server/hydration.d.cts +63 -0
- package/types-cjs/server/index.d.cts +10 -0
- package/types-cjs/server/shared.d.cts +50 -0
- package/types-cjs/server/signals.d.cts +87 -0
- package/types-cjs/types.d.cts +15 -0
- package/jsx-runtime.d.ts +0 -1
- package/types/jsx.d.ts +0 -4129
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getOwner, getContext, getNextChildId, createOwner, runWithOwner, onCleanup,
|
|
2
|
-
export { $PROXY, $TRACK, NotReadyError, createOwner, createRoot, flatten, getNextChildId, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, snapshot, storePath } from '@solidjs/signals';
|
|
1
|
+
import { getOwner, getContext, getNextChildId, createOwner, NotReadyError, runWithOwner, onCleanup, isWrappable, setContext, flatten, createRoot } from '@solidjs/signals';
|
|
2
|
+
export { $PROXY, $REFRESH, $TRACK, NotReadyError, createOwner, createRoot, enableExternalSource, enforceLoadingBoundary, flatten, getNextChildId, getOwner, isDisposed, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, snapshot, storePath } from '@solidjs/signals';
|
|
3
3
|
|
|
4
4
|
const NoHydrateContext = {
|
|
5
5
|
id: Symbol("NoHydrateContext"),
|
|
@@ -27,38 +27,82 @@ function runWithObserver(comp, fn) {
|
|
|
27
27
|
function getObserver() {
|
|
28
28
|
return Observer;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function createDeferredPromise() {
|
|
31
|
+
let settled = false;
|
|
32
|
+
let resolvePromise;
|
|
33
|
+
let rejectPromise;
|
|
34
|
+
const promise = new Promise((resolve, reject) => {
|
|
35
|
+
resolvePromise = resolve;
|
|
36
|
+
rejectPromise = reject;
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
promise,
|
|
40
|
+
resolve(value) {
|
|
41
|
+
if (settled) return;
|
|
42
|
+
settled = true;
|
|
43
|
+
promise.s = 1;
|
|
44
|
+
promise.v = value;
|
|
45
|
+
resolvePromise(value);
|
|
46
|
+
},
|
|
47
|
+
reject(error) {
|
|
48
|
+
if (settled) return;
|
|
49
|
+
settled = true;
|
|
50
|
+
promise.s = 2;
|
|
51
|
+
promise.v = error;
|
|
52
|
+
rejectPromise(error);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function subscribePendingRetry(error, retry) {
|
|
57
|
+
if (!(error instanceof NotReadyError)) return false;
|
|
58
|
+
error.source?.then(() => retry(), () => retry());
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function settleServerAsync(initial, rerun, deferred, onSuccess, onError, isDisposed) {
|
|
62
|
+
let first = true;
|
|
63
|
+
const attempt = () => {
|
|
64
|
+
if (isDisposed()) return;
|
|
65
|
+
let current;
|
|
66
|
+
try {
|
|
67
|
+
current = first ? initial : rerun();
|
|
68
|
+
first = false;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (subscribePendingRetry(error, attempt)) return;
|
|
71
|
+
onError(error);
|
|
72
|
+
deferred.reject(error);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
Promise.resolve(current).then(value => {
|
|
76
|
+
if (isDisposed()) return;
|
|
77
|
+
deferred.resolve(onSuccess(value));
|
|
78
|
+
}, error => {
|
|
79
|
+
if (isDisposed()) return;
|
|
80
|
+
if (subscribePendingRetry(error, attempt)) return;
|
|
81
|
+
onError(error);
|
|
82
|
+
deferred.reject(error);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
attempt();
|
|
86
|
+
}
|
|
87
|
+
function createSignal(first, second) {
|
|
31
88
|
if (typeof first === "function") {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
let value = second;
|
|
36
|
-
return [() => value, v => {
|
|
37
|
-
return value = typeof v === "function" ? v(value) : v;
|
|
38
|
-
}];
|
|
39
|
-
}
|
|
40
|
-
const memoOpts = third?.deferStream || ssrSource ? {
|
|
41
|
-
deferStream: third?.deferStream,
|
|
42
|
-
ssrSource
|
|
89
|
+
const opts = second?.deferStream || second?.ssrSource ? {
|
|
90
|
+
deferStream: second?.deferStream,
|
|
91
|
+
ssrSource: second?.ssrSource
|
|
43
92
|
} : undefined;
|
|
44
|
-
const memo = createMemo(
|
|
45
|
-
|
|
46
|
-
return [() => value, v => {
|
|
47
|
-
return value = typeof v === "function" ? v(value) : v;
|
|
48
|
-
}];
|
|
49
|
-
}, undefined, memoOpts);
|
|
50
|
-
return [() => memo()[0](), v => memo()[1](v)];
|
|
93
|
+
const memo = createMemo(prev => first(prev), opts);
|
|
94
|
+
return [memo, () => undefined];
|
|
51
95
|
}
|
|
52
96
|
return [() => first, v => {
|
|
53
97
|
return first = typeof v === "function" ? v(first) : v;
|
|
54
98
|
}];
|
|
55
99
|
}
|
|
56
|
-
function createMemo(compute,
|
|
100
|
+
function createMemo(compute, options) {
|
|
57
101
|
const ctx = sharedConfig.context;
|
|
58
102
|
const owner = createOwner();
|
|
59
103
|
const comp = {
|
|
60
104
|
owner,
|
|
61
|
-
value:
|
|
105
|
+
value: undefined,
|
|
62
106
|
compute: compute,
|
|
63
107
|
error: undefined,
|
|
64
108
|
computed: false,
|
|
@@ -69,21 +113,22 @@ function createMemo(compute, value, options) {
|
|
|
69
113
|
}));
|
|
70
114
|
function update() {
|
|
71
115
|
if (comp.disposed) return;
|
|
116
|
+
const run = () => runWithOwner(owner, () => runWithObserver(comp, () => comp.compute(comp.value)));
|
|
72
117
|
try {
|
|
73
118
|
comp.error = undefined;
|
|
74
|
-
const result =
|
|
119
|
+
const result = run();
|
|
75
120
|
comp.computed = true;
|
|
76
|
-
processResult(comp, result, owner, ctx, options?.deferStream, options?.ssrSource);
|
|
121
|
+
processResult(comp, result, owner, ctx, options?.deferStream, options?.ssrSource, run);
|
|
77
122
|
} catch (err) {
|
|
78
123
|
if (err instanceof NotReadyError) {
|
|
79
|
-
err
|
|
124
|
+
subscribePendingRetry(err, update);
|
|
80
125
|
}
|
|
81
126
|
comp.error = err;
|
|
82
127
|
comp.computed = true;
|
|
83
128
|
}
|
|
84
129
|
}
|
|
85
130
|
const ssrSource = options?.ssrSource;
|
|
86
|
-
if (ssrSource === "
|
|
131
|
+
if (ssrSource === "client") {
|
|
87
132
|
comp.computed = true;
|
|
88
133
|
} else if (!options?.lazy) {
|
|
89
134
|
update();
|
|
@@ -158,76 +203,128 @@ function createDeepProxy(target, patches, basePath = []) {
|
|
|
158
203
|
};
|
|
159
204
|
return new Proxy(target, handler);
|
|
160
205
|
}
|
|
161
|
-
function processResult(comp, result, owner, ctx, deferStream, ssrSource) {
|
|
206
|
+
function processResult(comp, result, owner, ctx, deferStream, ssrSource, rerun) {
|
|
162
207
|
if (comp.disposed) return;
|
|
163
208
|
const id = owner.id;
|
|
164
|
-
const uninitialized = comp.value === undefined;
|
|
165
209
|
const noHydrate = getContext(NoHydrateContext, owner);
|
|
166
210
|
if (result instanceof Promise) {
|
|
167
|
-
result.
|
|
168
|
-
|
|
169
|
-
result.v = v;
|
|
170
|
-
if (comp.disposed) return;
|
|
171
|
-
comp.value = v;
|
|
211
|
+
if (result.s === 1) {
|
|
212
|
+
comp.value = result.v;
|
|
172
213
|
comp.error = undefined;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
comp.error =
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (result.s === 2) {
|
|
217
|
+
comp.error = result.v;
|
|
218
|
+
return;
|
|
177
219
|
}
|
|
220
|
+
const deferred = createDeferredPromise();
|
|
221
|
+
if (ctx?.async && ctx.serialize && id && !noHydrate) ctx.serialize(id, deferred.promise, deferStream);
|
|
222
|
+
settleServerAsync(result, () => rerun ? rerun() : result, deferred, value => {
|
|
223
|
+
result.s = 1;
|
|
224
|
+
result.v = value;
|
|
225
|
+
comp.value = value;
|
|
226
|
+
comp.error = undefined;
|
|
227
|
+
return value;
|
|
228
|
+
}, error => {
|
|
229
|
+
result.s = 2;
|
|
230
|
+
result.v = error;
|
|
231
|
+
comp.error = error;
|
|
232
|
+
}, () => comp.disposed);
|
|
233
|
+
comp.error = new NotReadyError(deferred.promise);
|
|
178
234
|
return;
|
|
179
235
|
}
|
|
180
236
|
const iterator = result?.[Symbol.asyncIterator];
|
|
181
237
|
if (typeof iterator === "function") {
|
|
182
|
-
const iter = iterator.call(result);
|
|
183
238
|
if (ssrSource === "hybrid") {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
239
|
+
let currentResult = result;
|
|
240
|
+
let iter;
|
|
241
|
+
const deferred = createDeferredPromise();
|
|
242
|
+
const runFirst = () => {
|
|
243
|
+
const source = currentResult ?? (rerun ? rerun() : result);
|
|
244
|
+
currentResult = undefined;
|
|
245
|
+
const nextIterator = source?.[Symbol.asyncIterator];
|
|
246
|
+
if (typeof nextIterator !== "function") {
|
|
247
|
+
throw new Error("Expected async iterator while retrying server createMemo");
|
|
248
|
+
}
|
|
249
|
+
iter = nextIterator.call(source);
|
|
250
|
+
return iter.next().then(value => {
|
|
251
|
+
if (!value.done) closeAsyncIterator(iter);
|
|
252
|
+
return value.value;
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
settleServerAsync(runFirst(), runFirst, deferred, value => {
|
|
256
|
+
comp.value = value;
|
|
189
257
|
comp.error = undefined;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
258
|
+
return value;
|
|
259
|
+
}, error => {
|
|
260
|
+
comp.error = error;
|
|
261
|
+
}, () => comp.disposed);
|
|
262
|
+
if (ctx?.async && ctx.serialize && id && !noHydrate) ctx.serialize(id, deferred.promise, deferStream);
|
|
263
|
+
comp.error = new NotReadyError(deferred.promise);
|
|
195
264
|
} else {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
265
|
+
let currentResult = result;
|
|
266
|
+
let iter;
|
|
267
|
+
let firstResult;
|
|
268
|
+
const deferred = createDeferredPromise();
|
|
269
|
+
const runFirst = () => {
|
|
270
|
+
const source = currentResult ?? (rerun ? rerun() : result);
|
|
271
|
+
currentResult = undefined;
|
|
272
|
+
const nextIterator = source?.[Symbol.asyncIterator];
|
|
273
|
+
if (typeof nextIterator !== "function") {
|
|
274
|
+
throw new Error("Expected async iterator while retrying server createMemo");
|
|
202
275
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (!servedFirst) {
|
|
209
|
-
servedFirst = true;
|
|
210
|
-
return firstNext.then(r => {
|
|
211
|
-
if (!r.done && !comp.disposed) comp.value = r.value;
|
|
212
|
-
return r;
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
return iter.next().then(r => r);
|
|
216
|
-
}
|
|
217
|
-
})
|
|
276
|
+
iter = nextIterator.call(source);
|
|
277
|
+
return iter.next().then(value => {
|
|
278
|
+
firstResult = value;
|
|
279
|
+
return Promise.resolve();
|
|
280
|
+
});
|
|
218
281
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
282
|
+
settleServerAsync(runFirst(), runFirst, deferred, () => {
|
|
283
|
+
const resolved = firstResult;
|
|
284
|
+
if (resolved && !resolved.done) {
|
|
285
|
+
comp.value = resolved.value;
|
|
286
|
+
}
|
|
287
|
+
comp.error = undefined;
|
|
288
|
+
return undefined;
|
|
289
|
+
}, error => {
|
|
290
|
+
comp.error = error;
|
|
291
|
+
}, () => comp.disposed);
|
|
292
|
+
if (ctx?.async && ctx.serialize && id && !noHydrate) {
|
|
293
|
+
let tappedFirst = true;
|
|
294
|
+
const tapped = {
|
|
295
|
+
[Symbol.asyncIterator]: () => ({
|
|
296
|
+
next() {
|
|
297
|
+
if (tappedFirst) {
|
|
298
|
+
tappedFirst = false;
|
|
299
|
+
return deferred.promise.then(() => firstResult?.done ? {
|
|
300
|
+
done: true,
|
|
301
|
+
value: undefined
|
|
302
|
+
} : firstResult);
|
|
303
|
+
}
|
|
304
|
+
return iter.next().then(r => r);
|
|
305
|
+
},
|
|
306
|
+
return(value) {
|
|
307
|
+
return iter.return?.(value);
|
|
308
|
+
}
|
|
309
|
+
})
|
|
310
|
+
};
|
|
311
|
+
ctx.serialize(id, tapped, deferStream);
|
|
222
312
|
}
|
|
313
|
+
comp.error = new NotReadyError(deferred.promise);
|
|
223
314
|
}
|
|
224
315
|
return;
|
|
225
316
|
}
|
|
226
317
|
comp.value = result;
|
|
227
318
|
}
|
|
228
|
-
function
|
|
319
|
+
function closeAsyncIterator(iter, value) {
|
|
320
|
+
const returned = iter.return?.(value);
|
|
321
|
+
if (returned && typeof returned.then === "function") {
|
|
322
|
+
returned.then(undefined, () => {});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function serverEffect(compute, effectFn, options) {
|
|
229
326
|
const ssrSource = options?.ssrSource;
|
|
230
|
-
if (ssrSource === "client"
|
|
327
|
+
if (ssrSource === "client") {
|
|
231
328
|
createOwner();
|
|
232
329
|
return;
|
|
233
330
|
}
|
|
@@ -235,7 +332,7 @@ function serverEffect(compute, effectFn, value, options) {
|
|
|
235
332
|
const owner = createOwner();
|
|
236
333
|
const comp = {
|
|
237
334
|
owner,
|
|
238
|
-
value:
|
|
335
|
+
value: undefined,
|
|
239
336
|
compute: compute,
|
|
240
337
|
error: undefined,
|
|
241
338
|
computed: true,
|
|
@@ -247,19 +344,19 @@ function serverEffect(compute, effectFn, value, options) {
|
|
|
247
344
|
}));
|
|
248
345
|
}
|
|
249
346
|
try {
|
|
250
|
-
const result = runWithOwner(owner, () => runWithObserver(comp, () => compute(
|
|
347
|
+
const result = runWithOwner(owner, () => runWithObserver(comp, () => compute(undefined)));
|
|
251
348
|
if (ssrSource) {
|
|
252
349
|
processResult(comp, result, owner, ctx, options?.deferStream, ssrSource);
|
|
253
350
|
}
|
|
254
|
-
effectFn?.(ssrSource ? comp.value ?? result : result,
|
|
351
|
+
effectFn?.(ssrSource ? comp.value ?? result : result, undefined);
|
|
255
352
|
} catch (err) {
|
|
256
353
|
}
|
|
257
354
|
}
|
|
258
|
-
function createEffect(compute, effect,
|
|
259
|
-
serverEffect(compute, undefined,
|
|
355
|
+
function createEffect(compute, effect, options) {
|
|
356
|
+
serverEffect(compute, undefined, options);
|
|
260
357
|
}
|
|
261
|
-
function createRenderEffect(compute, effectFn,
|
|
262
|
-
serverEffect(compute, effectFn,
|
|
358
|
+
function createRenderEffect(compute, effectFn, options) {
|
|
359
|
+
serverEffect(compute, effectFn, options);
|
|
263
360
|
}
|
|
264
361
|
function createTrackedEffect(compute, options) {
|
|
265
362
|
const o = getOwner();
|
|
@@ -270,8 +367,8 @@ function createReaction(effectFn, options) {
|
|
|
270
367
|
tracking();
|
|
271
368
|
};
|
|
272
369
|
}
|
|
273
|
-
function createOptimistic(first, second
|
|
274
|
-
return createSignal(first, second
|
|
370
|
+
function createOptimistic(first, second) {
|
|
371
|
+
return createSignal(first, second);
|
|
275
372
|
}
|
|
276
373
|
function setProperty(state, property, value) {
|
|
277
374
|
if (state[property] === value) return;
|
|
@@ -281,7 +378,7 @@ function setProperty(state, property, value) {
|
|
|
281
378
|
}
|
|
282
379
|
function createStore(first, second) {
|
|
283
380
|
if (typeof first === "function") {
|
|
284
|
-
const store = createProjection(first, second
|
|
381
|
+
const store = createProjection(first, second);
|
|
285
382
|
return [store, fn => fn(store)];
|
|
286
383
|
}
|
|
287
384
|
const state = first;
|
|
@@ -304,11 +401,11 @@ function createPendingProxy(state, source) {
|
|
|
304
401
|
pending = false;
|
|
305
402
|
}];
|
|
306
403
|
}
|
|
307
|
-
function createProjection(fn, initialValue
|
|
404
|
+
function createProjection(fn, initialValue, options) {
|
|
308
405
|
const ctx = sharedConfig.context;
|
|
309
406
|
const owner = createOwner();
|
|
310
407
|
const [state] = createStore(initialValue);
|
|
311
|
-
if (options?.ssrSource === "
|
|
408
|
+
if (options?.ssrSource === "client") {
|
|
312
409
|
return state;
|
|
313
410
|
}
|
|
314
411
|
let disposed = false;
|
|
@@ -319,100 +416,131 @@ function createProjection(fn, initialValue = {}, options) {
|
|
|
319
416
|
const useProxy = ssrSource !== "hybrid";
|
|
320
417
|
const patches = [];
|
|
321
418
|
const draft = useProxy ? createDeepProxy(state, patches) : state;
|
|
322
|
-
const
|
|
419
|
+
const runProjection = () => runWithOwner(owner, () => fn(draft));
|
|
420
|
+
const result = runProjection();
|
|
323
421
|
const iteratorFn = result?.[Symbol.asyncIterator];
|
|
324
422
|
if (typeof iteratorFn === "function") {
|
|
325
|
-
const iter = iteratorFn.call(result);
|
|
326
423
|
if (ssrSource === "hybrid") {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
424
|
+
let currentResult = result;
|
|
425
|
+
let iter;
|
|
426
|
+
const deferred = createDeferredPromise();
|
|
427
|
+
const [pending, markReady] = createPendingProxy(state, deferred.promise);
|
|
428
|
+
const runFirst = () => {
|
|
429
|
+
const source = currentResult ?? runProjection();
|
|
430
|
+
currentResult = undefined;
|
|
431
|
+
const nextIterator = source?.[Symbol.asyncIterator];
|
|
432
|
+
if (typeof nextIterator !== "function") {
|
|
433
|
+
throw new Error("Expected async iterator while retrying server createProjection");
|
|
332
434
|
}
|
|
333
|
-
|
|
334
|
-
|
|
435
|
+
iter = nextIterator.call(source);
|
|
436
|
+
return iter.next().then(r => {
|
|
437
|
+
if (!r.done) closeAsyncIterator(iter);
|
|
438
|
+
return r.value;
|
|
439
|
+
});
|
|
440
|
+
};
|
|
441
|
+
settleServerAsync(runFirst(), runFirst, deferred, value => {
|
|
442
|
+
if (value !== undefined && value !== state) {
|
|
443
|
+
Object.assign(state, value);
|
|
335
444
|
}
|
|
336
|
-
promise.v = state;
|
|
337
445
|
markReady();
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
446
|
+
return state;
|
|
447
|
+
}, error => {
|
|
448
|
+
markReady();
|
|
449
|
+
}, () => disposed);
|
|
450
|
+
if (ctx?.async && !getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, deferred.promise, options?.deferStream);
|
|
341
451
|
return pending;
|
|
342
452
|
} else {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
453
|
+
let currentResult = result;
|
|
454
|
+
let iter;
|
|
455
|
+
let firstResult;
|
|
456
|
+
const deferred = createDeferredPromise();
|
|
457
|
+
const [pending, markReady] = createPendingProxy(state, deferred.promise);
|
|
458
|
+
const runFirst = () => {
|
|
459
|
+
const source = currentResult ?? runProjection();
|
|
460
|
+
currentResult = undefined;
|
|
461
|
+
const nextIterator = source?.[Symbol.asyncIterator];
|
|
462
|
+
if (typeof nextIterator !== "function") {
|
|
463
|
+
throw new Error("Expected async iterator while retrying server createProjection");
|
|
464
|
+
}
|
|
465
|
+
iter = nextIterator.call(source);
|
|
466
|
+
return iter.next().then(value => {
|
|
467
|
+
firstResult = value;
|
|
468
|
+
return Promise.resolve();
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
settleServerAsync(runFirst(), runFirst, deferred, () => {
|
|
346
472
|
patches.length = 0;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
473
|
+
const resolved = firstResult;
|
|
474
|
+
if (resolved && !resolved.done && resolved.value !== undefined && resolved.value !== draft) {
|
|
475
|
+
Object.assign(state, resolved.value);
|
|
351
476
|
}
|
|
352
477
|
markReady(JSON.parse(JSON.stringify(state)));
|
|
353
|
-
|
|
478
|
+
return undefined;
|
|
479
|
+
}, error => {
|
|
354
480
|
markReady();
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
done
|
|
365
|
-
|
|
481
|
+
}, () => disposed);
|
|
482
|
+
if (ctx?.async && !getContext(NoHydrateContext) && owner.id) {
|
|
483
|
+
let tappedFirst = true;
|
|
484
|
+
const tapped = {
|
|
485
|
+
[Symbol.asyncIterator]: () => ({
|
|
486
|
+
next() {
|
|
487
|
+
if (tappedFirst) {
|
|
488
|
+
tappedFirst = false;
|
|
489
|
+
return deferred.promise.then(() => {
|
|
490
|
+
if (firstResult?.done) return {
|
|
491
|
+
done: true,
|
|
492
|
+
value: undefined
|
|
493
|
+
};
|
|
494
|
+
return {
|
|
495
|
+
done: false,
|
|
496
|
+
value: JSON.parse(JSON.stringify(state))
|
|
497
|
+
};
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
return iter.next().then(r => {
|
|
501
|
+
if (disposed) return {
|
|
502
|
+
done: true,
|
|
503
|
+
value: undefined
|
|
366
504
|
};
|
|
505
|
+
const flushed = patches.splice(0);
|
|
506
|
+
if (!r.done) {
|
|
507
|
+
if (r.value !== undefined && r.value !== draft) {
|
|
508
|
+
Object.assign(state, r.value);
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
done: false,
|
|
512
|
+
value: flushed
|
|
513
|
+
};
|
|
514
|
+
}
|
|
367
515
|
return {
|
|
368
|
-
done:
|
|
516
|
+
done: true,
|
|
369
517
|
value: undefined
|
|
370
518
|
};
|
|
371
519
|
});
|
|
520
|
+
},
|
|
521
|
+
return(value) {
|
|
522
|
+
return iter.return?.(value);
|
|
372
523
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
};
|
|
378
|
-
const flushed = patches.splice(0);
|
|
379
|
-
if (!r.done) {
|
|
380
|
-
if (r.value !== undefined && r.value !== draft) {
|
|
381
|
-
Object.assign(state, r.value);
|
|
382
|
-
}
|
|
383
|
-
return {
|
|
384
|
-
done: false,
|
|
385
|
-
value: flushed
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
return {
|
|
389
|
-
done: true,
|
|
390
|
-
value: undefined
|
|
391
|
-
};
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
})
|
|
395
|
-
};
|
|
396
|
-
if (ctx?.async && !getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, tapped, options?.deferStream);
|
|
397
|
-
const [pending, markReady] = createPendingProxy(state, firstReady);
|
|
524
|
+
})
|
|
525
|
+
};
|
|
526
|
+
ctx.serialize(owner.id, tapped, options?.deferStream);
|
|
527
|
+
}
|
|
398
528
|
return pending;
|
|
399
529
|
}
|
|
400
530
|
}
|
|
401
531
|
if (result instanceof Promise) {
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
532
|
+
const deferred = createDeferredPromise();
|
|
533
|
+
const [pending, markReady] = createPendingProxy(state, deferred.promise);
|
|
534
|
+
settleServerAsync(result, () => runProjection(), deferred, value => {
|
|
535
|
+
if (value !== undefined && value !== state) {
|
|
536
|
+
Object.assign(state, value);
|
|
407
537
|
}
|
|
408
|
-
if (v !== undefined && v !== state) {
|
|
409
|
-
Object.assign(state, v);
|
|
410
|
-
}
|
|
411
|
-
promise.v = state;
|
|
412
538
|
markReady();
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
539
|
+
return state;
|
|
540
|
+
}, error => {
|
|
541
|
+
markReady();
|
|
542
|
+
}, () => disposed);
|
|
543
|
+
if (ctx?.async && !getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, deferred.promise, options?.deferStream);
|
|
416
544
|
return pending;
|
|
417
545
|
}
|
|
418
546
|
if (result !== undefined && result !== state && result !== draft) {
|
|
@@ -440,7 +568,7 @@ function deep(store) {
|
|
|
440
568
|
}
|
|
441
569
|
function mapArray(list, mapFn, options = {}) {
|
|
442
570
|
const parent = createOwner();
|
|
443
|
-
return () => {
|
|
571
|
+
return createMemo(() => {
|
|
444
572
|
const items = list();
|
|
445
573
|
let s = [];
|
|
446
574
|
if (items && items.length) {
|
|
@@ -457,54 +585,93 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
457
585
|
})];
|
|
458
586
|
}
|
|
459
587
|
return s;
|
|
460
|
-
};
|
|
588
|
+
});
|
|
461
589
|
}
|
|
462
590
|
function repeat(count, mapFn, options = {}) {
|
|
463
591
|
const owner = createOwner();
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
592
|
+
return createMemo(() => {
|
|
593
|
+
const len = count();
|
|
594
|
+
const offset = options.from?.() || 0;
|
|
595
|
+
if (!len) {
|
|
596
|
+
if (!options.fallback) return [];
|
|
597
|
+
return [runWithOwner(owner, () => {
|
|
598
|
+
const fallbackOwner = createOwner();
|
|
599
|
+
return runWithOwner(fallbackOwner, () => options.fallback());
|
|
600
|
+
})];
|
|
601
|
+
}
|
|
602
|
+
return runWithOwner(owner, () => Array.from({
|
|
603
|
+
length: len
|
|
604
|
+
}, (_, i) => {
|
|
605
|
+
const itemOwner = createOwner();
|
|
606
|
+
return runWithOwner(itemOwner, () => mapFn(i + offset));
|
|
607
|
+
}));
|
|
608
|
+
});
|
|
481
609
|
}
|
|
482
610
|
const ErrorContext = {
|
|
483
611
|
id: Symbol("ErrorContext"),
|
|
484
612
|
defaultValue: null
|
|
485
613
|
};
|
|
614
|
+
function runWithBoundaryErrorContext(owner, render, onError, context, boundaryId) {
|
|
615
|
+
const prevCtx = sharedConfig.context;
|
|
616
|
+
const prevBoundary = context?._currentBoundaryId;
|
|
617
|
+
if (context) {
|
|
618
|
+
sharedConfig.context = context;
|
|
619
|
+
if (boundaryId !== undefined) context._currentBoundaryId = boundaryId;
|
|
620
|
+
}
|
|
621
|
+
try {
|
|
622
|
+
return runWithOwner(owner, () => {
|
|
623
|
+
const parentHandler = getContext(ErrorContext);
|
|
624
|
+
setContext(ErrorContext, err => onError(err, parentHandler));
|
|
625
|
+
return render();
|
|
626
|
+
});
|
|
627
|
+
} finally {
|
|
628
|
+
if (context) {
|
|
629
|
+
if (boundaryId !== undefined) context._currentBoundaryId = prevBoundary;
|
|
630
|
+
sharedConfig.context = prevCtx;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
486
634
|
function createErrorBoundary(fn, fallback) {
|
|
487
635
|
const ctx = sharedConfig.context;
|
|
488
|
-
const owner = createOwner();
|
|
489
636
|
const parent = getOwner();
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
637
|
+
const owner = createOwner();
|
|
638
|
+
const resolve = () => {
|
|
639
|
+
const resolved = ctx.resolve(runWithOwner(createOwner(), fn));
|
|
640
|
+
if (resolved?.p?.length) throw new NotReadyError(Promise.all(resolved.p));
|
|
641
|
+
return resolved;
|
|
642
|
+
};
|
|
643
|
+
const renderFallback = err => ctx ? runWithOwner(parent, () => {
|
|
644
|
+
const fallbackOwner = createOwner();
|
|
645
|
+
return runWithOwner(fallbackOwner, () => fallback(err, () => {}));
|
|
646
|
+
}) : fallback(err, () => {});
|
|
647
|
+
const serializeError = err => {
|
|
648
|
+
if (ctx && owner.id && !runWithOwner(owner, () => getContext(NoHydrateContext))) {
|
|
649
|
+
ctx.serialize(owner.id, err);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
const handleError = err => {
|
|
653
|
+
serializeError(err);
|
|
654
|
+
return renderFallback(err);
|
|
655
|
+
};
|
|
656
|
+
return () => {
|
|
493
657
|
let result;
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
result = fallback(err, () => {});
|
|
497
|
-
});
|
|
658
|
+
let handled = false;
|
|
659
|
+
if (ctx) owner.dispose(false);
|
|
498
660
|
try {
|
|
499
|
-
result =
|
|
661
|
+
result = ctx ? runWithBoundaryErrorContext(owner, resolve, err => {
|
|
662
|
+
if (err instanceof NotReadyError) throw err;
|
|
663
|
+
handled = true;
|
|
664
|
+
result = handleError(err);
|
|
665
|
+
throw err;
|
|
666
|
+
}) : runWithOwner(owner, fn);
|
|
500
667
|
} catch (err) {
|
|
501
|
-
if (
|
|
502
|
-
result =
|
|
668
|
+
if (err instanceof NotReadyError) throw err;
|
|
669
|
+
result = handled ? result : handleError(err);
|
|
503
670
|
}
|
|
504
|
-
return
|
|
505
|
-
}
|
|
671
|
+
return result;
|
|
672
|
+
};
|
|
506
673
|
}
|
|
507
|
-
function
|
|
674
|
+
function createLoadingBoundary$1(fn, fallback, options) {
|
|
508
675
|
try {
|
|
509
676
|
const result = fn();
|
|
510
677
|
return () => result;
|
|
@@ -515,6 +682,10 @@ function createLoadBoundary(fn, fallback) {
|
|
|
515
682
|
throw err;
|
|
516
683
|
}
|
|
517
684
|
}
|
|
685
|
+
function createRevealOrder(fn, _options) {
|
|
686
|
+
const o = createOwner();
|
|
687
|
+
return runWithOwner(o, fn);
|
|
688
|
+
}
|
|
518
689
|
function untrack(fn) {
|
|
519
690
|
return fn();
|
|
520
691
|
}
|
|
@@ -567,10 +738,10 @@ function useContext(context) {
|
|
|
567
738
|
return getContext(context);
|
|
568
739
|
}
|
|
569
740
|
function children(fn) {
|
|
570
|
-
const c = createMemo(fn,
|
|
741
|
+
const c = createMemo(fn, {
|
|
571
742
|
lazy: true
|
|
572
743
|
});
|
|
573
|
-
const memo = createMemo(() => flatten(c()),
|
|
744
|
+
const memo = createMemo(() => flatten(c()), {
|
|
574
745
|
lazy: true
|
|
575
746
|
});
|
|
576
747
|
memo.toArray = () => {
|
|
@@ -580,7 +751,9 @@ function children(fn) {
|
|
|
580
751
|
return memo;
|
|
581
752
|
}
|
|
582
753
|
function ssrRunInScope(fn) {
|
|
583
|
-
|
|
754
|
+
const owner = getOwner();
|
|
755
|
+
if (!owner) return fn;
|
|
756
|
+
return Array.isArray(fn) ? fn.map(hole => () => runWithOwner(owner, hole)) : () => runWithOwner(owner, fn);
|
|
584
757
|
}
|
|
585
758
|
|
|
586
759
|
function enableHydration() {}
|
|
@@ -637,6 +810,159 @@ function createUniqueId() {
|
|
|
637
810
|
return getNextChildId(o);
|
|
638
811
|
}
|
|
639
812
|
|
|
813
|
+
const RevealGroupContext = {
|
|
814
|
+
id: Symbol("RevealGroupContext"),
|
|
815
|
+
defaultValue: null
|
|
816
|
+
};
|
|
817
|
+
function ssrHandleError(err) {
|
|
818
|
+
if (err instanceof NotReadyError) {
|
|
819
|
+
return err.source;
|
|
820
|
+
}
|
|
821
|
+
const handler = getContext(ErrorContext);
|
|
822
|
+
if (handler) {
|
|
823
|
+
handler(err);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
throw err;
|
|
827
|
+
}
|
|
828
|
+
function createLoadingBoundary(fn, fallback, options) {
|
|
829
|
+
const currentCtx = sharedConfig.context;
|
|
830
|
+
if (!currentCtx) {
|
|
831
|
+
return createLoadingBoundary$1(fn, fallback);
|
|
832
|
+
}
|
|
833
|
+
const ctx = currentCtx;
|
|
834
|
+
const parent = getOwner();
|
|
835
|
+
const parentHandler = parent && runWithOwner(parent, () => getContext(ErrorContext));
|
|
836
|
+
const revealGroup = parent && runWithOwner(parent, () => getContext(RevealGroupContext));
|
|
837
|
+
const o = createOwner();
|
|
838
|
+
const id = o.id;
|
|
839
|
+
o.id = id + "00";
|
|
840
|
+
let done;
|
|
841
|
+
let handledRenderError;
|
|
842
|
+
let retryPromise;
|
|
843
|
+
let serializeBuffer = [];
|
|
844
|
+
const bufferedCtx = Object.create(ctx);
|
|
845
|
+
bufferedCtx.serialize = (id, value, deferStream) => {
|
|
846
|
+
serializeBuffer.push([id, value, deferStream]);
|
|
847
|
+
};
|
|
848
|
+
bufferedCtx._currentBoundaryId = id;
|
|
849
|
+
function flushSerializeBuffer() {
|
|
850
|
+
for (const args of serializeBuffer) ctx.serialize(args[0], args[1], args[2]);
|
|
851
|
+
serializeBuffer = [];
|
|
852
|
+
}
|
|
853
|
+
function commitBoundaryState() {
|
|
854
|
+
flushSerializeBuffer();
|
|
855
|
+
const modules = ctx.getBoundaryModules?.(id);
|
|
856
|
+
if (modules) ctx.serialize(id + "_assets", modules);
|
|
857
|
+
}
|
|
858
|
+
function runLoadingPhase(render) {
|
|
859
|
+
handledRenderError = undefined;
|
|
860
|
+
return runWithBoundaryErrorContext(o, render, (err, parentHandler) => {
|
|
861
|
+
handledRenderError = err;
|
|
862
|
+
if (done?.(undefined, err)) throw err;
|
|
863
|
+
if (parentHandler) {
|
|
864
|
+
parentHandler(err);
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
throw err;
|
|
868
|
+
}, bufferedCtx, id);
|
|
869
|
+
}
|
|
870
|
+
function finalizeError(err) {
|
|
871
|
+
if (handledRenderError === err) {
|
|
872
|
+
handledRenderError = undefined;
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
if (done?.(undefined, err)) return;
|
|
876
|
+
if (!parentHandler) throw err;
|
|
877
|
+
try {
|
|
878
|
+
runWithOwner(parent, () => parentHandler(err));
|
|
879
|
+
} catch (caught) {
|
|
880
|
+
if (caught !== err) throw caught;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
function runDiscovery() {
|
|
884
|
+
o.dispose(false);
|
|
885
|
+
serializeBuffer = [];
|
|
886
|
+
retryPromise = undefined;
|
|
887
|
+
return runLoadingPhase(() => {
|
|
888
|
+
try {
|
|
889
|
+
return ctx.resolve(fn());
|
|
890
|
+
} catch (err) {
|
|
891
|
+
if (err instanceof NotReadyError) {
|
|
892
|
+
retryPromise = err.source;
|
|
893
|
+
return undefined;
|
|
894
|
+
}
|
|
895
|
+
throw err;
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
let ret = runDiscovery();
|
|
900
|
+
if (!retryPromise && !ret?.p?.length) {
|
|
901
|
+
commitBoundaryState();
|
|
902
|
+
return () => ret;
|
|
903
|
+
}
|
|
904
|
+
const regResult = revealGroup ? revealGroup.register(id) : null;
|
|
905
|
+
const collapseFallback = regResult?.collapseFallback ?? false;
|
|
906
|
+
if (collapseFallback && !ctx.async) {
|
|
907
|
+
commitBoundaryState();
|
|
908
|
+
ctx.serialize(id, "$$f");
|
|
909
|
+
return () => undefined;
|
|
910
|
+
}
|
|
911
|
+
const fallbackOwner = createOwner({
|
|
912
|
+
id
|
|
913
|
+
});
|
|
914
|
+
const fallbackResult = runWithOwner(fallbackOwner, () => {
|
|
915
|
+
if (!ctx.async) return fallback();
|
|
916
|
+
const tpl = collapseFallback ? [`<template id="pl-${id}">`, `</template><!--pl-${id}-->`] : [`<template id="pl-${id}"></template>`, `<!--pl-${id}-->`];
|
|
917
|
+
return ctx.ssr(tpl, ctx.escape(fallback()));
|
|
918
|
+
});
|
|
919
|
+
if (ctx.async) {
|
|
920
|
+
const regOpts = revealGroup ? {
|
|
921
|
+
revealGroup: revealGroup.id
|
|
922
|
+
} : undefined;
|
|
923
|
+
done = ctx.registerFragment(id, regOpts);
|
|
924
|
+
(async () => {
|
|
925
|
+
try {
|
|
926
|
+
while (retryPromise) {
|
|
927
|
+
await retryPromise.catch(() => {});
|
|
928
|
+
ret = runDiscovery();
|
|
929
|
+
}
|
|
930
|
+
commitBoundaryState();
|
|
931
|
+
while (ret.p.length) {
|
|
932
|
+
await Promise.all(ret.p).catch(() => {});
|
|
933
|
+
ret = runLoadingPhase(() => ctx.ssr(ret.t, ...ret.h));
|
|
934
|
+
}
|
|
935
|
+
flushSerializeBuffer();
|
|
936
|
+
done(ret.t[0]);
|
|
937
|
+
if (revealGroup) revealGroup.onResolved(id);
|
|
938
|
+
} catch (err) {
|
|
939
|
+
finalizeError(err);
|
|
940
|
+
}
|
|
941
|
+
})();
|
|
942
|
+
return () => fallbackResult;
|
|
943
|
+
}
|
|
944
|
+
commitBoundaryState();
|
|
945
|
+
ctx.serialize(id, "$$f");
|
|
946
|
+
return () => fallbackResult;
|
|
947
|
+
}
|
|
948
|
+
function NoHydration(props) {
|
|
949
|
+
const o = createOwner();
|
|
950
|
+
return runWithOwner(o, () => {
|
|
951
|
+
setContext(NoHydrateContext, true);
|
|
952
|
+
return props.children;
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
function Hydration(props) {
|
|
956
|
+
if (!getContext(NoHydrateContext)) return props.children;
|
|
957
|
+
const o = createOwner({
|
|
958
|
+
id: props.id ?? ""
|
|
959
|
+
});
|
|
960
|
+
return runWithOwner(o, () => {
|
|
961
|
+
setContext(NoHydrateContext, false);
|
|
962
|
+
return props.children;
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
|
|
640
966
|
function For(props) {
|
|
641
967
|
const options = "fallback" in props ? {
|
|
642
968
|
keyed: props.keyed,
|
|
@@ -644,7 +970,7 @@ function For(props) {
|
|
|
644
970
|
} : {
|
|
645
971
|
keyed: props.keyed
|
|
646
972
|
};
|
|
647
|
-
return
|
|
973
|
+
return mapArray(() => props.each, props.children, options);
|
|
648
974
|
}
|
|
649
975
|
function Repeat(props) {
|
|
650
976
|
const options = "fallback" in props ? {
|
|
@@ -697,108 +1023,182 @@ function Errored(props) {
|
|
|
697
1023
|
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
698
1024
|
});
|
|
699
1025
|
}
|
|
700
|
-
|
|
701
|
-
function ssrHandleError(err) {
|
|
702
|
-
if (err instanceof NotReadyError) {
|
|
703
|
-
return err.source;
|
|
704
|
-
}
|
|
705
|
-
const handler = getContext(ErrorContext);
|
|
706
|
-
if (handler) {
|
|
707
|
-
handler(err);
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
throw err;
|
|
711
|
-
}
|
|
712
1026
|
function Loading(props) {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
}
|
|
1027
|
+
return createLoadingBoundary(() => props.children, () => props.fallback);
|
|
1028
|
+
}
|
|
1029
|
+
function Reveal(props) {
|
|
717
1030
|
const o = createOwner();
|
|
718
1031
|
const id = o.id;
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
1032
|
+
const order = props.order ?? "sequential";
|
|
1033
|
+
const collapsed = order === "sequential" && !!props.collapsed;
|
|
1034
|
+
if (!sharedConfig.context?.async) {
|
|
1035
|
+
const parent = getOwner();
|
|
1036
|
+
const parentGroup = parent ? runWithOwner(parent, () => getContext(RevealGroupContext)) : null;
|
|
1037
|
+
let collapsedByParent = false;
|
|
1038
|
+
if (parentGroup) {
|
|
1039
|
+
const reg = parentGroup.register(id);
|
|
1040
|
+
collapsedByParent = reg.collapseFallback;
|
|
1041
|
+
if (order === "together" || collapsed) console.warn("Nested <Reveal> with collapsed/together won't coordinate correctly with renderToString. Use renderToStream for full support.");
|
|
1042
|
+
}
|
|
1043
|
+
let count = 0;
|
|
1044
|
+
return runWithOwner(o, () => {
|
|
1045
|
+
setContext(RevealGroupContext, {
|
|
1046
|
+
id,
|
|
1047
|
+
register(_key) {
|
|
1048
|
+
count++;
|
|
1049
|
+
const collapseFallback = collapsedByParent || order === "sequential" && collapsed && count > 1;
|
|
1050
|
+
return {
|
|
1051
|
+
collapseFallback,
|
|
1052
|
+
held: false
|
|
1053
|
+
};
|
|
1054
|
+
},
|
|
1055
|
+
onResolved() {}
|
|
1056
|
+
});
|
|
1057
|
+
return props.children;
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
const ctx = sharedConfig.context;
|
|
1061
|
+
const keys = [];
|
|
1062
|
+
const resolved = new Set();
|
|
1063
|
+
const minimallyResolved = new Set();
|
|
1064
|
+
const composites = new Map();
|
|
1065
|
+
const activated = new Set();
|
|
1066
|
+
const stash = [];
|
|
1067
|
+
const collapsedLeafKeys = [];
|
|
1068
|
+
let frontier = 0;
|
|
1069
|
+
let heldByParent = false;
|
|
1070
|
+
let collapsedByParent = false;
|
|
1071
|
+
let selfMinimallyResolved = false;
|
|
1072
|
+
let notifiedParentDone = false;
|
|
1073
|
+
const parent = getOwner();
|
|
1074
|
+
const parentGroup = parent ? runWithOwner(parent, () => getContext(RevealGroupContext)) : null;
|
|
1075
|
+
if (parentGroup) {
|
|
1076
|
+
const reg = parentGroup.register(id, {
|
|
1077
|
+
onActivate: () => {
|
|
1078
|
+
if (!heldByParent) return;
|
|
1079
|
+
heldByParent = false;
|
|
1080
|
+
if (collapsedByParent) {
|
|
1081
|
+
collapsedByParent = false;
|
|
1082
|
+
if (collapsedLeafKeys.length) {
|
|
1083
|
+
ctx.revealFallbacks?.([...collapsedLeafKeys]);
|
|
1084
|
+
collapsedLeafKeys.length = 0;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
if (order === "sequential") advanceFrontier();else if (order === "together") checkTogetherRelease();else naturalRelease();
|
|
736
1088
|
}
|
|
737
1089
|
});
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return result;
|
|
1090
|
+
collapsedByParent = reg.collapseFallback;
|
|
1091
|
+
heldByParent = reg.held;
|
|
741
1092
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
return ret;
|
|
1093
|
+
function notifyParentIfDone() {
|
|
1094
|
+
if (notifiedParentDone) return;
|
|
1095
|
+
if (parentGroup && resolved.size === keys.length) {
|
|
1096
|
+
notifiedParentDone = true;
|
|
1097
|
+
parentGroup.onResolved(id);
|
|
1098
|
+
}
|
|
749
1099
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
1100
|
+
function activateComposite(key) {
|
|
1101
|
+
if (activated.has(key)) return;
|
|
1102
|
+
activated.add(key);
|
|
1103
|
+
composites.get(key)();
|
|
1104
|
+
}
|
|
1105
|
+
function updateSelfMinimallyResolved() {
|
|
1106
|
+
if (selfMinimallyResolved) return;
|
|
1107
|
+
if (keys.length === 0) selfMinimallyResolved = true;else if (order === "together") selfMinimallyResolved = minimallyResolved.size === keys.length;else if (order === "sequential") selfMinimallyResolved = minimallyResolved.has(keys[0]);
|
|
1108
|
+
else selfMinimallyResolved = resolved.size > 0;
|
|
1109
|
+
if (selfMinimallyResolved) parentGroup?.onMinimallyResolved?.(id);
|
|
1110
|
+
}
|
|
1111
|
+
function advanceFrontier() {
|
|
1112
|
+
if (heldByParent) return;
|
|
1113
|
+
while (frontier < keys.length && resolved.has(keys[frontier])) {
|
|
1114
|
+
const k = keys[frontier];
|
|
1115
|
+
if (composites.has(k)) activateComposite(k);else ctx.revealFragments?.([k]);
|
|
1116
|
+
frontier++;
|
|
1117
|
+
}
|
|
1118
|
+
if (frontier < keys.length) {
|
|
1119
|
+
const k = keys[frontier];
|
|
1120
|
+
if (composites.has(k)) activateComposite(k);else if (order === "sequential" && collapsed) ctx.revealFallbacks?.([k]);
|
|
1121
|
+
}
|
|
1122
|
+
notifyParentIfDone();
|
|
1123
|
+
}
|
|
1124
|
+
function checkTogetherRelease() {
|
|
1125
|
+
if (order !== "together" || heldByParent) return;
|
|
1126
|
+
if (minimallyResolved.size < keys.length) return;
|
|
1127
|
+
if (stash.length) {
|
|
1128
|
+
ctx.revealFragments?.([...stash]);
|
|
1129
|
+
stash.length = 0;
|
|
1130
|
+
}
|
|
1131
|
+
composites.forEach((_, key) => activateComposite(key));
|
|
1132
|
+
notifyParentIfDone();
|
|
1133
|
+
}
|
|
1134
|
+
function naturalRelease() {
|
|
1135
|
+
if (stash.length) {
|
|
1136
|
+
ctx.revealFragments?.([...stash]);
|
|
1137
|
+
stash.length = 0;
|
|
1138
|
+
}
|
|
1139
|
+
composites.forEach((_, key) => activateComposite(key));
|
|
1140
|
+
notifyParentIfDone();
|
|
1141
|
+
}
|
|
1142
|
+
return runWithOwner(o, () => {
|
|
1143
|
+
setContext(RevealGroupContext, {
|
|
1144
|
+
id,
|
|
1145
|
+
register(key, options) {
|
|
1146
|
+
keys.push(key);
|
|
1147
|
+
const isComposite = !!options?.onActivate;
|
|
1148
|
+
if (isComposite) composites.set(key, options.onActivate);
|
|
1149
|
+
const selfCollapse = order === "sequential" && collapsed && keys.length > 1;
|
|
1150
|
+
const collapseFallback = collapsedByParent || selfCollapse;
|
|
1151
|
+
if (collapseFallback && !isComposite) collapsedLeafKeys.push(key);
|
|
1152
|
+
let held = heldByParent;
|
|
1153
|
+
if (!held) {
|
|
1154
|
+
if (order === "together") held = true;else if (order === "sequential" && keys.length > 1) held = true;
|
|
763
1155
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
1156
|
+
return {
|
|
1157
|
+
collapseFallback,
|
|
1158
|
+
held
|
|
1159
|
+
};
|
|
1160
|
+
},
|
|
1161
|
+
onResolved(key) {
|
|
1162
|
+
resolved.add(key);
|
|
1163
|
+
const isLeaf = !composites.has(key);
|
|
1164
|
+
if (isLeaf) {
|
|
1165
|
+
if (order === "together") {
|
|
1166
|
+
stash.push(key);
|
|
1167
|
+
} else if (order === "natural" && heldByParent) {
|
|
1168
|
+
stash.push(key);
|
|
1169
|
+
} else if (order === "natural") {
|
|
1170
|
+
ctx.revealFragments?.([key]);
|
|
1171
|
+
}
|
|
1172
|
+
markMinimallyResolved(key);
|
|
1173
|
+
if (order === "sequential" && !heldByParent) advanceFrontier();
|
|
1174
|
+
if (order === "natural") updateSelfMinimallyResolved();
|
|
1175
|
+
} else {
|
|
1176
|
+
if (!heldByParent) {
|
|
1177
|
+
if (order === "sequential") advanceFrontier();else if (order === "natural") activateComposite(key);
|
|
1178
|
+
}
|
|
1179
|
+
if (order === "together") checkTogetherRelease();
|
|
1180
|
+
if (order === "natural") updateSelfMinimallyResolved();
|
|
769
1181
|
}
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
|
|
1182
|
+
notifyParentIfDone();
|
|
1183
|
+
},
|
|
1184
|
+
onMinimallyResolved(key) {
|
|
1185
|
+
markMinimallyResolved(key);
|
|
773
1186
|
}
|
|
774
|
-
})
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
if (modules) ctx.serialize(id + "_assets", modules);
|
|
781
|
-
ctx.serialize(id, "$$f");
|
|
782
|
-
return runWithOwner(fallbackOwner, () => props.fallback);
|
|
783
|
-
}
|
|
784
|
-
function NoHydration(props) {
|
|
785
|
-
const o = createOwner();
|
|
786
|
-
return runWithOwner(o, () => {
|
|
787
|
-
setContext(NoHydrateContext, true);
|
|
788
|
-
return props.children;
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
function Hydration(props) {
|
|
792
|
-
if (!getContext(NoHydrateContext)) return props.children;
|
|
793
|
-
const o = createOwner({
|
|
794
|
-
id: props.id ?? ""
|
|
795
|
-
});
|
|
796
|
-
return runWithOwner(o, () => {
|
|
797
|
-
setContext(NoHydrateContext, false);
|
|
798
|
-
return props.children;
|
|
1187
|
+
});
|
|
1188
|
+
const result = props.children;
|
|
1189
|
+
if (parentGroup && keys.length === 0) {
|
|
1190
|
+
parentGroup.onResolved(id);
|
|
1191
|
+
}
|
|
1192
|
+
return result;
|
|
799
1193
|
});
|
|
1194
|
+
function markMinimallyResolved(key) {
|
|
1195
|
+
if (minimallyResolved.has(key)) return;
|
|
1196
|
+
minimallyResolved.add(key);
|
|
1197
|
+
updateSelfMinimallyResolved();
|
|
1198
|
+
if (order === "together") checkTogetherRelease();
|
|
1199
|
+
}
|
|
800
1200
|
}
|
|
801
1201
|
|
|
802
1202
|
const DEV = undefined;
|
|
803
1203
|
|
|
804
|
-
export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, latest, lazy, mapArray, onSettled, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext };
|
|
1204
|
+
export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRevealOrder, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, latest, lazy, mapArray, onSettled, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext };
|