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