solid-js 2.0.0-beta.4 → 2.0.0-beta.6
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/dist/dev.cjs +136 -113
- package/dist/dev.js +128 -108
- package/dist/server.cjs +350 -131
- package/dist/server.js +347 -134
- package/dist/solid.cjs +130 -99
- package/dist/solid.js +122 -94
- package/package.json +2 -2
- package/types/client/core.d.ts +1 -8
- package/types/client/flow.d.ts +47 -5
- package/types/client/hydration.d.ts +9 -13
- package/types/index.d.ts +4 -7
- package/types/jsx.d.ts +160 -115
- package/types/server/flow.d.ts +27 -5
- package/types/server/hydration.d.ts +11 -4
- package/types/server/index.d.ts +2 -2
- package/types/server/shared.d.ts +5 -1
- package/types/server/signals.d.ts +7 -2
package/dist/server.cjs
CHANGED
|
@@ -64,7 +64,7 @@ function createMemo(compute, value, options) {
|
|
|
64
64
|
processResult(comp, result, owner, ctx, options?.deferStream, options?.ssrSource);
|
|
65
65
|
} catch (err) {
|
|
66
66
|
if (err instanceof signals.NotReadyError) {
|
|
67
|
-
err.source?.then(() => update());
|
|
67
|
+
err.source?.then(() => update(), () => update());
|
|
68
68
|
}
|
|
69
69
|
comp.error = err;
|
|
70
70
|
comp.computed = true;
|
|
@@ -149,20 +149,31 @@ function createDeepProxy(target, patches, basePath = []) {
|
|
|
149
149
|
function processResult(comp, result, owner, ctx, deferStream, ssrSource) {
|
|
150
150
|
if (comp.disposed) return;
|
|
151
151
|
const id = owner.id;
|
|
152
|
-
const uninitialized = comp.value === undefined;
|
|
153
152
|
const noHydrate = signals.getContext(NoHydrateContext, owner);
|
|
154
153
|
if (result instanceof Promise) {
|
|
154
|
+
if (result.s === 1) {
|
|
155
|
+
comp.value = result.v;
|
|
156
|
+
comp.error = undefined;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (result.s === 2) {
|
|
160
|
+
comp.error = result.v;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
155
163
|
result.then(v => {
|
|
156
164
|
result.s = 1;
|
|
157
165
|
result.v = v;
|
|
158
166
|
if (comp.disposed) return;
|
|
159
167
|
comp.value = v;
|
|
160
168
|
comp.error = undefined;
|
|
161
|
-
},
|
|
169
|
+
}, err => {
|
|
170
|
+
result.s = 2;
|
|
171
|
+
result.v = err;
|
|
172
|
+
if (comp.disposed) return;
|
|
173
|
+
comp.error = err;
|
|
174
|
+
});
|
|
162
175
|
if (ctx?.async && ctx.serialize && id && !noHydrate) ctx.serialize(id, result, deferStream);
|
|
163
|
-
|
|
164
|
-
comp.error = new signals.NotReadyError(result);
|
|
165
|
-
}
|
|
176
|
+
comp.error = new signals.NotReadyError(result);
|
|
166
177
|
return;
|
|
167
178
|
}
|
|
168
179
|
const iterator = result?.[Symbol.asyncIterator];
|
|
@@ -172,6 +183,7 @@ function processResult(comp, result, owner, ctx, deferStream, ssrSource) {
|
|
|
172
183
|
const promise = iter.next().then(v => {
|
|
173
184
|
promise.s = 1;
|
|
174
185
|
promise.v = v.value;
|
|
186
|
+
if (!v.done) closeAsyncIterator(iter);
|
|
175
187
|
if (comp.disposed) return v.value;
|
|
176
188
|
comp.value = v.value;
|
|
177
189
|
comp.error = undefined;
|
|
@@ -199,6 +211,9 @@ function processResult(comp, result, owner, ctx, deferStream, ssrSource) {
|
|
|
199
211
|
return firstNext.then(r => r);
|
|
200
212
|
}
|
|
201
213
|
return iter.next().then(r => r);
|
|
214
|
+
},
|
|
215
|
+
return(value) {
|
|
216
|
+
return iter.return?.(value);
|
|
202
217
|
}
|
|
203
218
|
})
|
|
204
219
|
};
|
|
@@ -210,6 +225,12 @@ function processResult(comp, result, owner, ctx, deferStream, ssrSource) {
|
|
|
210
225
|
}
|
|
211
226
|
comp.value = result;
|
|
212
227
|
}
|
|
228
|
+
function closeAsyncIterator(iter, value) {
|
|
229
|
+
const returned = iter.return?.(value);
|
|
230
|
+
if (returned && typeof returned.then === "function") {
|
|
231
|
+
returned.then(undefined, () => {});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
213
234
|
function serverEffect(compute, effectFn, value, options) {
|
|
214
235
|
const ssrSource = options?.ssrSource;
|
|
215
236
|
if (ssrSource === "client" || ssrSource === "initial") {
|
|
@@ -311,6 +332,7 @@ function createProjection(fn, initialValue = {}, options) {
|
|
|
311
332
|
if (ssrSource === "hybrid") {
|
|
312
333
|
const promise = iter.next().then(r => {
|
|
313
334
|
promise.s = 1;
|
|
335
|
+
if (!r.done) closeAsyncIterator(iter);
|
|
314
336
|
if (disposed) {
|
|
315
337
|
promise.v = state;
|
|
316
338
|
return state;
|
|
@@ -378,6 +400,9 @@ function createProjection(fn, initialValue = {}, options) {
|
|
|
378
400
|
value: undefined
|
|
379
401
|
};
|
|
380
402
|
});
|
|
403
|
+
},
|
|
404
|
+
return(value) {
|
|
405
|
+
return iter.return?.(value);
|
|
381
406
|
}
|
|
382
407
|
})
|
|
383
408
|
};
|
|
@@ -392,13 +417,14 @@ function createProjection(fn, initialValue = {}, options) {
|
|
|
392
417
|
promise.s = 1;
|
|
393
418
|
if (disposed) {
|
|
394
419
|
promise.v = state;
|
|
395
|
-
return;
|
|
420
|
+
return state;
|
|
396
421
|
}
|
|
397
422
|
if (v !== undefined && v !== state) {
|
|
398
423
|
Object.assign(state, v);
|
|
399
424
|
}
|
|
400
425
|
promise.v = state;
|
|
401
426
|
markReady();
|
|
427
|
+
return state;
|
|
402
428
|
}, () => {});
|
|
403
429
|
if (ctx?.async && !signals.getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, promise, options?.deferStream);
|
|
404
430
|
const [pending, markReady] = createPendingProxy(state, promise);
|
|
@@ -429,7 +455,7 @@ function deep(store) {
|
|
|
429
455
|
}
|
|
430
456
|
function mapArray(list, mapFn, options = {}) {
|
|
431
457
|
const parent = signals.createOwner();
|
|
432
|
-
return () => {
|
|
458
|
+
return createMemo(() => {
|
|
433
459
|
const items = list();
|
|
434
460
|
let s = [];
|
|
435
461
|
if (items && items.length) {
|
|
@@ -446,54 +472,93 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
446
472
|
})];
|
|
447
473
|
}
|
|
448
474
|
return s;
|
|
449
|
-
};
|
|
475
|
+
});
|
|
450
476
|
}
|
|
451
477
|
function repeat(count, mapFn, options = {}) {
|
|
452
478
|
const owner = signals.createOwner();
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
479
|
+
return createMemo(() => {
|
|
480
|
+
const len = count();
|
|
481
|
+
const offset = options.from?.() || 0;
|
|
482
|
+
if (!len) {
|
|
483
|
+
if (!options.fallback) return [];
|
|
484
|
+
return [signals.runWithOwner(owner, () => {
|
|
485
|
+
const fallbackOwner = signals.createOwner();
|
|
486
|
+
return signals.runWithOwner(fallbackOwner, () => options.fallback());
|
|
487
|
+
})];
|
|
488
|
+
}
|
|
489
|
+
return signals.runWithOwner(owner, () => Array.from({
|
|
490
|
+
length: len
|
|
491
|
+
}, (_, i) => {
|
|
492
|
+
const itemOwner = signals.createOwner();
|
|
493
|
+
return signals.runWithOwner(itemOwner, () => mapFn(i + offset));
|
|
494
|
+
}));
|
|
495
|
+
});
|
|
470
496
|
}
|
|
471
497
|
const ErrorContext = {
|
|
472
498
|
id: Symbol("ErrorContext"),
|
|
473
499
|
defaultValue: null
|
|
474
500
|
};
|
|
501
|
+
function runWithBoundaryErrorContext(owner, render, onError, context, boundaryId) {
|
|
502
|
+
const prevCtx = sharedConfig.context;
|
|
503
|
+
const prevBoundary = context?._currentBoundaryId;
|
|
504
|
+
if (context) {
|
|
505
|
+
sharedConfig.context = context;
|
|
506
|
+
if (boundaryId !== undefined) context._currentBoundaryId = boundaryId;
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
return signals.runWithOwner(owner, () => {
|
|
510
|
+
const parentHandler = signals.getContext(ErrorContext);
|
|
511
|
+
signals.setContext(ErrorContext, err => onError(err, parentHandler));
|
|
512
|
+
return render();
|
|
513
|
+
});
|
|
514
|
+
} finally {
|
|
515
|
+
if (context) {
|
|
516
|
+
if (boundaryId !== undefined) context._currentBoundaryId = prevBoundary;
|
|
517
|
+
sharedConfig.context = prevCtx;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
475
521
|
function createErrorBoundary(fn, fallback) {
|
|
476
522
|
const ctx = sharedConfig.context;
|
|
477
|
-
const owner = signals.createOwner();
|
|
478
523
|
const parent = signals.getOwner();
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
524
|
+
const owner = signals.createOwner();
|
|
525
|
+
const resolve = () => {
|
|
526
|
+
const resolved = ctx.resolve(signals.runWithOwner(signals.createOwner(), fn));
|
|
527
|
+
if (resolved?.p?.length) throw new signals.NotReadyError(Promise.all(resolved.p));
|
|
528
|
+
return resolved;
|
|
529
|
+
};
|
|
530
|
+
const renderFallback = err => ctx ? signals.runWithOwner(parent, () => {
|
|
531
|
+
const fallbackOwner = signals.createOwner();
|
|
532
|
+
return signals.runWithOwner(fallbackOwner, () => fallback(err, () => {}));
|
|
533
|
+
}) : fallback(err, () => {});
|
|
534
|
+
const serializeError = err => {
|
|
535
|
+
if (ctx && owner.id && !signals.runWithOwner(owner, () => signals.getContext(NoHydrateContext))) {
|
|
536
|
+
ctx.serialize(owner.id, err);
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
const handleError = err => {
|
|
540
|
+
serializeError(err);
|
|
541
|
+
return renderFallback(err);
|
|
542
|
+
};
|
|
543
|
+
return () => {
|
|
482
544
|
let result;
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
result = fallback(err, () => {});
|
|
486
|
-
});
|
|
545
|
+
let handled = false;
|
|
546
|
+
if (ctx) owner.dispose(false);
|
|
487
547
|
try {
|
|
488
|
-
result =
|
|
548
|
+
result = ctx ? runWithBoundaryErrorContext(owner, resolve, err => {
|
|
549
|
+
if (err instanceof signals.NotReadyError) throw err;
|
|
550
|
+
handled = true;
|
|
551
|
+
result = handleError(err);
|
|
552
|
+
throw err;
|
|
553
|
+
}) : signals.runWithOwner(owner, fn);
|
|
489
554
|
} catch (err) {
|
|
490
|
-
if (
|
|
491
|
-
result =
|
|
555
|
+
if (err instanceof signals.NotReadyError) throw err;
|
|
556
|
+
result = handled ? result : handleError(err);
|
|
492
557
|
}
|
|
493
|
-
return
|
|
494
|
-
}
|
|
558
|
+
return result;
|
|
559
|
+
};
|
|
495
560
|
}
|
|
496
|
-
function createLoadingBoundary(fn, fallback, options) {
|
|
561
|
+
function createLoadingBoundary$1(fn, fallback, options) {
|
|
497
562
|
try {
|
|
498
563
|
const result = fn();
|
|
499
564
|
return () => result;
|
|
@@ -504,6 +569,10 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
504
569
|
throw err;
|
|
505
570
|
}
|
|
506
571
|
}
|
|
572
|
+
function createRevealOrder(fn, _options) {
|
|
573
|
+
const o = signals.createOwner();
|
|
574
|
+
return signals.runWithOwner(o, fn);
|
|
575
|
+
}
|
|
507
576
|
function untrack(fn) {
|
|
508
577
|
return fn();
|
|
509
578
|
}
|
|
@@ -569,7 +638,9 @@ function children(fn) {
|
|
|
569
638
|
return memo;
|
|
570
639
|
}
|
|
571
640
|
function ssrRunInScope(fn) {
|
|
572
|
-
|
|
641
|
+
const owner = signals.getOwner();
|
|
642
|
+
if (!owner) return fn;
|
|
643
|
+
return Array.isArray(fn) ? fn.map(hole => () => signals.runWithOwner(owner, hole)) : () => signals.runWithOwner(owner, fn);
|
|
573
644
|
}
|
|
574
645
|
|
|
575
646
|
function enableHydration() {}
|
|
@@ -626,6 +697,155 @@ function createUniqueId() {
|
|
|
626
697
|
return signals.getNextChildId(o);
|
|
627
698
|
}
|
|
628
699
|
|
|
700
|
+
const RevealGroupContext = {
|
|
701
|
+
id: Symbol("RevealGroupContext"),
|
|
702
|
+
defaultValue: null
|
|
703
|
+
};
|
|
704
|
+
function ssrHandleError(err) {
|
|
705
|
+
if (err instanceof signals.NotReadyError) {
|
|
706
|
+
return err.source;
|
|
707
|
+
}
|
|
708
|
+
const handler = signals.getContext(ErrorContext);
|
|
709
|
+
if (handler) {
|
|
710
|
+
handler(err);
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
throw err;
|
|
714
|
+
}
|
|
715
|
+
class InvalidTopLevelAsyncReadError extends Error {
|
|
716
|
+
constructor() {
|
|
717
|
+
super("Async values must be read within a tracking scope (JSX, a memo, or an effect's compute function).");
|
|
718
|
+
this.name = "InvalidTopLevelAsyncReadError";
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
function createLoadingBoundary(fn, fallback, options) {
|
|
722
|
+
const currentCtx = sharedConfig.context;
|
|
723
|
+
if (!currentCtx) {
|
|
724
|
+
return createLoadingBoundary$1(fn, fallback);
|
|
725
|
+
}
|
|
726
|
+
const ctx = currentCtx;
|
|
727
|
+
const parent = signals.getOwner();
|
|
728
|
+
const parentHandler = parent && signals.runWithOwner(parent, () => signals.getContext(ErrorContext));
|
|
729
|
+
const revealGroup = parent && signals.runWithOwner(parent, () => signals.getContext(RevealGroupContext));
|
|
730
|
+
const o = signals.createOwner();
|
|
731
|
+
const id = o.id;
|
|
732
|
+
o.id = id + "00";
|
|
733
|
+
let done;
|
|
734
|
+
let handledRenderError;
|
|
735
|
+
let serializeBuffer = [];
|
|
736
|
+
const bufferedCtx = Object.create(ctx);
|
|
737
|
+
bufferedCtx.serialize = (id, value, deferStream) => {
|
|
738
|
+
serializeBuffer.push([id, value, deferStream]);
|
|
739
|
+
};
|
|
740
|
+
bufferedCtx._currentBoundaryId = id;
|
|
741
|
+
function flushSerializeBuffer() {
|
|
742
|
+
for (const args of serializeBuffer) ctx.serialize(args[0], args[1], args[2]);
|
|
743
|
+
serializeBuffer = [];
|
|
744
|
+
}
|
|
745
|
+
function commitBoundaryState() {
|
|
746
|
+
flushSerializeBuffer();
|
|
747
|
+
const modules = ctx.getBoundaryModules?.(id);
|
|
748
|
+
if (modules) ctx.serialize(id + "_assets", modules);
|
|
749
|
+
}
|
|
750
|
+
function runLoadingPhase(render) {
|
|
751
|
+
handledRenderError = undefined;
|
|
752
|
+
return runWithBoundaryErrorContext(o, render, (err, parentHandler) => {
|
|
753
|
+
handledRenderError = err;
|
|
754
|
+
if (done?.(undefined, err)) throw err;
|
|
755
|
+
if (parentHandler) {
|
|
756
|
+
parentHandler(err);
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
throw err;
|
|
760
|
+
}, bufferedCtx, id);
|
|
761
|
+
}
|
|
762
|
+
function finalizeError(err) {
|
|
763
|
+
if (handledRenderError === err) {
|
|
764
|
+
handledRenderError = undefined;
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
if (done?.(undefined, err)) return;
|
|
768
|
+
if (!parentHandler) throw err;
|
|
769
|
+
try {
|
|
770
|
+
signals.runWithOwner(parent, () => parentHandler(err));
|
|
771
|
+
} catch (caught) {
|
|
772
|
+
if (caught !== err) throw caught;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function runDiscovery() {
|
|
776
|
+
o.dispose(false);
|
|
777
|
+
serializeBuffer = [];
|
|
778
|
+
return runLoadingPhase(() => {
|
|
779
|
+
try {
|
|
780
|
+
return ctx.resolve(fn());
|
|
781
|
+
} catch (err) {
|
|
782
|
+
if (err instanceof signals.NotReadyError) throw new InvalidTopLevelAsyncReadError();
|
|
783
|
+
throw err;
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
let ret = runDiscovery();
|
|
788
|
+
if (!ret?.p?.length) {
|
|
789
|
+
commitBoundaryState();
|
|
790
|
+
return () => ret;
|
|
791
|
+
}
|
|
792
|
+
const collapseFallback = revealGroup ? revealGroup.register(id) : false;
|
|
793
|
+
if (collapseFallback && !ctx.async) {
|
|
794
|
+
commitBoundaryState();
|
|
795
|
+
ctx.serialize(id, "$$f");
|
|
796
|
+
return () => undefined;
|
|
797
|
+
}
|
|
798
|
+
const fallbackOwner = signals.createOwner({
|
|
799
|
+
id
|
|
800
|
+
});
|
|
801
|
+
const fallbackResult = signals.runWithOwner(fallbackOwner, () => {
|
|
802
|
+
if (!ctx.async) return fallback();
|
|
803
|
+
const tpl = collapseFallback ? [`<template id="pl-${id}">`, `</template><!--pl-${id}-->`] : [`<template id="pl-${id}"></template>`, `<!--pl-${id}-->`];
|
|
804
|
+
return ctx.ssr(tpl, ctx.escape(fallback()));
|
|
805
|
+
});
|
|
806
|
+
if (ctx.async) {
|
|
807
|
+
const regOpts = revealGroup ? {
|
|
808
|
+
revealGroup: revealGroup.id
|
|
809
|
+
} : undefined;
|
|
810
|
+
done = ctx.registerFragment(id, regOpts);
|
|
811
|
+
(async () => {
|
|
812
|
+
try {
|
|
813
|
+
commitBoundaryState();
|
|
814
|
+
while (ret.p.length) {
|
|
815
|
+
await Promise.all(ret.p).catch(() => {});
|
|
816
|
+
ret = runLoadingPhase(() => ctx.ssr(ret.t, ...ret.h));
|
|
817
|
+
}
|
|
818
|
+
flushSerializeBuffer();
|
|
819
|
+
done(ret.t[0]);
|
|
820
|
+
if (revealGroup) revealGroup.onResolved(id);
|
|
821
|
+
} catch (err) {
|
|
822
|
+
finalizeError(err);
|
|
823
|
+
}
|
|
824
|
+
})();
|
|
825
|
+
return () => fallbackResult;
|
|
826
|
+
}
|
|
827
|
+
commitBoundaryState();
|
|
828
|
+
ctx.serialize(id, "$$f");
|
|
829
|
+
return () => fallbackResult;
|
|
830
|
+
}
|
|
831
|
+
function NoHydration(props) {
|
|
832
|
+
const o = signals.createOwner();
|
|
833
|
+
return signals.runWithOwner(o, () => {
|
|
834
|
+
signals.setContext(NoHydrateContext, true);
|
|
835
|
+
return props.children;
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
function Hydration(props) {
|
|
839
|
+
if (!signals.getContext(NoHydrateContext)) return props.children;
|
|
840
|
+
const o = signals.createOwner({
|
|
841
|
+
id: props.id ?? ""
|
|
842
|
+
});
|
|
843
|
+
return signals.runWithOwner(o, () => {
|
|
844
|
+
signals.setContext(NoHydrateContext, false);
|
|
845
|
+
return props.children;
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
|
|
629
849
|
function For(props) {
|
|
630
850
|
const options = "fallback" in props ? {
|
|
631
851
|
keyed: props.keyed,
|
|
@@ -633,7 +853,7 @@ function For(props) {
|
|
|
633
853
|
} : {
|
|
634
854
|
keyed: props.keyed
|
|
635
855
|
};
|
|
636
|
-
return
|
|
856
|
+
return mapArray(() => props.each, props.children, options);
|
|
637
857
|
}
|
|
638
858
|
function Repeat(props) {
|
|
639
859
|
const options = "fallback" in props ? {
|
|
@@ -686,105 +906,98 @@ function Errored(props) {
|
|
|
686
906
|
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
687
907
|
});
|
|
688
908
|
}
|
|
689
|
-
|
|
690
|
-
function ssrHandleError(err) {
|
|
691
|
-
if (err instanceof signals.NotReadyError) {
|
|
692
|
-
return err.source;
|
|
693
|
-
}
|
|
694
|
-
const handler = signals.getContext(ErrorContext);
|
|
695
|
-
if (handler) {
|
|
696
|
-
handler(err);
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
throw err;
|
|
700
|
-
}
|
|
701
909
|
function Loading(props) {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
910
|
+
return createLoadingBoundary(() => props.children, () => props.fallback);
|
|
911
|
+
}
|
|
912
|
+
function Reveal(props) {
|
|
706
913
|
const o = signals.createOwner();
|
|
707
914
|
const id = o.id;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
915
|
+
const together = !!props.together;
|
|
916
|
+
const collapsed = !!props.collapsed;
|
|
917
|
+
if (!sharedConfig.context?.async) {
|
|
918
|
+
const parent = signals.getOwner();
|
|
919
|
+
const parentGroup = parent ? signals.runWithOwner(parent, () => signals.getContext(RevealGroupContext)) : null;
|
|
920
|
+
let collapsedByParent = false;
|
|
921
|
+
if (parentGroup) {
|
|
922
|
+
collapsedByParent = parentGroup.register(id);
|
|
923
|
+
if (collapsed || together) console.warn("Nested <Reveal> with collapsed/together won't coordinate correctly with renderToString. Use renderToStream for full support.");
|
|
924
|
+
}
|
|
925
|
+
let count = 0;
|
|
926
|
+
return signals.runWithOwner(o, () => {
|
|
927
|
+
signals.setContext(RevealGroupContext, {
|
|
928
|
+
id,
|
|
929
|
+
register(_key) {
|
|
930
|
+
count++;
|
|
931
|
+
if (collapsedByParent) return true;
|
|
932
|
+
return !together && collapsed && count > 1;
|
|
933
|
+
},
|
|
934
|
+
onResolved() {}
|
|
935
|
+
});
|
|
936
|
+
return props.children;
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
const ctx = sharedConfig.context;
|
|
940
|
+
const keys = [];
|
|
941
|
+
const resolved = new Set();
|
|
942
|
+
const composites = new Map();
|
|
943
|
+
let frontier = 0;
|
|
944
|
+
const parent = signals.getOwner();
|
|
945
|
+
const parentGroup = parent ? signals.runWithOwner(parent, () => signals.getContext(RevealGroupContext)) : null;
|
|
946
|
+
let collapsedByParent = false;
|
|
947
|
+
if (parentGroup) {
|
|
948
|
+
collapsedByParent = parentGroup.register(id, {
|
|
949
|
+
onActivate: () => {
|
|
950
|
+
collapsedByParent = false;
|
|
951
|
+
advanceFrontier();
|
|
725
952
|
}
|
|
726
953
|
});
|
|
727
|
-
ctx._currentBoundaryId = prevBoundary;
|
|
728
|
-
ctx.serialize = origSerialize;
|
|
729
|
-
return result;
|
|
730
954
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
const modules = ctx.getBoundaryModules?.(id);
|
|
736
|
-
if (modules) ctx.serialize(id + "_assets", modules);
|
|
737
|
-
return ret;
|
|
955
|
+
function notifyParentIfDone() {
|
|
956
|
+
if (parentGroup && resolved.size === keys.length) {
|
|
957
|
+
parentGroup.onResolved(id);
|
|
958
|
+
}
|
|
738
959
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
960
|
+
function advanceFrontier() {
|
|
961
|
+
while (frontier < keys.length && resolved.has(keys[frontier])) {
|
|
962
|
+
if (!composites.has(keys[frontier])) ctx.revealFragments?.([keys[frontier]]);
|
|
963
|
+
frontier++;
|
|
964
|
+
}
|
|
965
|
+
if (frontier < keys.length) {
|
|
966
|
+
const activate = composites.get(keys[frontier]);
|
|
967
|
+
if (activate) activate();else if (!together && collapsed) ctx.revealFallbacks?.(keys.slice(frontier));
|
|
968
|
+
}
|
|
969
|
+
notifyParentIfDone();
|
|
970
|
+
}
|
|
971
|
+
return signals.runWithOwner(o, () => {
|
|
972
|
+
signals.setContext(RevealGroupContext, {
|
|
973
|
+
id,
|
|
974
|
+
register(key, options) {
|
|
975
|
+
keys.push(key);
|
|
976
|
+
if (options?.onActivate) composites.set(key, options.onActivate);
|
|
977
|
+
if (collapsedByParent) return true;
|
|
978
|
+
return !together && collapsed && keys.length > 1;
|
|
979
|
+
},
|
|
980
|
+
onResolved(key) {
|
|
981
|
+
resolved.add(key);
|
|
982
|
+
if (collapsedByParent) {
|
|
983
|
+
notifyParentIfDone();
|
|
984
|
+
return;
|
|
752
985
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
986
|
+
if (together) {
|
|
987
|
+
if (resolved.size === keys.length) {
|
|
988
|
+
ctx.revealFragments?.(id);
|
|
989
|
+
notifyParentIfDone();
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
advanceFrontier();
|
|
758
993
|
}
|
|
759
|
-
done(ret.t[0]);
|
|
760
|
-
} catch (err) {
|
|
761
|
-
done(undefined, err);
|
|
762
994
|
}
|
|
763
|
-
})
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (modules) ctx.serialize(id + "_assets", modules);
|
|
770
|
-
ctx.serialize(id, "$$f");
|
|
771
|
-
return signals.runWithOwner(fallbackOwner, () => props.fallback);
|
|
772
|
-
}
|
|
773
|
-
function NoHydration(props) {
|
|
774
|
-
const o = signals.createOwner();
|
|
775
|
-
return signals.runWithOwner(o, () => {
|
|
776
|
-
signals.setContext(NoHydrateContext, true);
|
|
777
|
-
return props.children;
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
function Hydration(props) {
|
|
781
|
-
if (!signals.getContext(NoHydrateContext)) return props.children;
|
|
782
|
-
const o = signals.createOwner({
|
|
783
|
-
id: props.id ?? ""
|
|
784
|
-
});
|
|
785
|
-
return signals.runWithOwner(o, () => {
|
|
786
|
-
signals.setContext(NoHydrateContext, false);
|
|
787
|
-
return props.children;
|
|
995
|
+
});
|
|
996
|
+
const result = props.children;
|
|
997
|
+
if (parentGroup && keys.length === 0) {
|
|
998
|
+
parentGroup.onResolved(id);
|
|
999
|
+
}
|
|
1000
|
+
return result;
|
|
788
1001
|
});
|
|
789
1002
|
}
|
|
790
1003
|
|
|
@@ -834,6 +1047,10 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
834
1047
|
enumerable: true,
|
|
835
1048
|
get: function () { return signals.getOwner; }
|
|
836
1049
|
});
|
|
1050
|
+
Object.defineProperty(exports, "isDisposed", {
|
|
1051
|
+
enumerable: true,
|
|
1052
|
+
get: function () { return signals.isDisposed; }
|
|
1053
|
+
});
|
|
837
1054
|
Object.defineProperty(exports, "isEqual", {
|
|
838
1055
|
enumerable: true,
|
|
839
1056
|
get: function () { return signals.isEqual; }
|
|
@@ -876,6 +1093,7 @@ exports.Match = Match;
|
|
|
876
1093
|
exports.NoHydrateContext = NoHydrateContext;
|
|
877
1094
|
exports.NoHydration = NoHydration;
|
|
878
1095
|
exports.Repeat = Repeat;
|
|
1096
|
+
exports.Reveal = Reveal;
|
|
879
1097
|
exports.Show = Show;
|
|
880
1098
|
exports.Switch = Switch;
|
|
881
1099
|
exports.action = action;
|
|
@@ -892,6 +1110,7 @@ exports.createOptimisticStore = createOptimisticStore;
|
|
|
892
1110
|
exports.createProjection = createProjection;
|
|
893
1111
|
exports.createReaction = createReaction;
|
|
894
1112
|
exports.createRenderEffect = createRenderEffect;
|
|
1113
|
+
exports.createRevealOrder = createRevealOrder;
|
|
895
1114
|
exports.createSignal = createSignal;
|
|
896
1115
|
exports.createStore = createStore;
|
|
897
1116
|
exports.createTrackedEffect = createTrackedEffect;
|