solid-js 2.0.0-beta.10 → 2.0.0-beta.11
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 +15 -8
- package/dist/dev.js +16 -8
- package/dist/server.cjs +310 -134
- package/dist/server.js +237 -39
- package/dist/solid.cjs +17 -8
- package/dist/solid.js +18 -8
- package/package.json +2 -2
- package/types/client/hydration.d.ts +14 -16
- package/types/index.d.ts +1 -3
- package/types/server/core.d.ts +0 -7
- package/types/server/index.d.ts +1 -1
- package/types/server/shared.d.ts +5 -1
- package/types/server/signals.d.ts +41 -5
- package/types-cjs/client/hydration.d.cts +14 -16
- package/types-cjs/index.d.cts +1 -3
- package/types-cjs/server/core.d.cts +0 -7
- package/types-cjs/server/index.d.cts +1 -1
- package/types-cjs/server/shared.d.cts +5 -1
- package/types-cjs/server/signals.d.cts +41 -5
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { $PROXY, $REFRESH, $TRACK, NotReadyError,
|
|
1
|
+
import { NotReadyError, $REFRESH, isWrappable, NoOwnerError, ContextNotFoundError, flatten } from '@solidjs/signals';
|
|
2
|
+
export { $PROXY, $REFRESH, $TRACK, NotReadyError, enableExternalSource, enforceLoadingBoundary, flatten, isEqual, isWrappable, merge, omit, snapshot, storePath } from '@solidjs/signals';
|
|
3
3
|
|
|
4
4
|
const NoHydrateContext = {
|
|
5
5
|
id: Symbol("NoHydrateContext"),
|
|
@@ -14,6 +14,142 @@ const sharedConfig = {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
const defaultSSRContext = {};
|
|
18
|
+
let currentOwner = null;
|
|
19
|
+
const OWNER_POOL_MAX = 4096;
|
|
20
|
+
const ownerPool = [];
|
|
21
|
+
function formatChildId(prefix, id) {
|
|
22
|
+
const num = id.toString(36);
|
|
23
|
+
const len = num.length - 1;
|
|
24
|
+
return prefix + (len ? String.fromCharCode(64 + len) : "") + num;
|
|
25
|
+
}
|
|
26
|
+
function nextChildIdFor(owner, consume) {
|
|
27
|
+
let counter = owner;
|
|
28
|
+
while (counter._transparent && counter._parent) counter = counter._parent;
|
|
29
|
+
if (counter.id != null) {
|
|
30
|
+
return formatChildId(counter.id, counter._childCount++ );
|
|
31
|
+
}
|
|
32
|
+
throw new Error("Cannot get child id from owner without an id");
|
|
33
|
+
}
|
|
34
|
+
function getNextChildId(owner) {
|
|
35
|
+
return nextChildIdFor(owner);
|
|
36
|
+
}
|
|
37
|
+
function createOwner(options) {
|
|
38
|
+
const parent = currentOwner;
|
|
39
|
+
const transparent = options?.transparent ?? false;
|
|
40
|
+
const id = options?.id ?? (transparent ? parent?.id : parent?.id != null ? nextChildIdFor(parent) : undefined);
|
|
41
|
+
const ctx = parent?._context ?? defaultSSRContext;
|
|
42
|
+
let owner;
|
|
43
|
+
if (ownerPool.length) {
|
|
44
|
+
owner = ownerPool.pop();
|
|
45
|
+
owner.id = id;
|
|
46
|
+
owner._transparent = transparent;
|
|
47
|
+
owner._disposal = null;
|
|
48
|
+
owner._parent = parent;
|
|
49
|
+
owner._context = ctx;
|
|
50
|
+
owner._childCount = 0;
|
|
51
|
+
owner._firstChild = null;
|
|
52
|
+
owner._nextSibling = null;
|
|
53
|
+
owner._disposed = false;
|
|
54
|
+
} else {
|
|
55
|
+
owner = {
|
|
56
|
+
id,
|
|
57
|
+
_transparent: transparent,
|
|
58
|
+
_disposal: null,
|
|
59
|
+
_parent: parent,
|
|
60
|
+
_context: ctx,
|
|
61
|
+
_childCount: 0,
|
|
62
|
+
_firstChild: null,
|
|
63
|
+
_nextSibling: null,
|
|
64
|
+
_disposed: false
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (parent) {
|
|
68
|
+
const lastChild = parent._firstChild;
|
|
69
|
+
if (lastChild) owner._nextSibling = lastChild;
|
|
70
|
+
parent._firstChild = owner;
|
|
71
|
+
}
|
|
72
|
+
return owner;
|
|
73
|
+
}
|
|
74
|
+
function runWithOwner(owner, fn) {
|
|
75
|
+
const prev = currentOwner;
|
|
76
|
+
currentOwner = owner;
|
|
77
|
+
try {
|
|
78
|
+
return fn();
|
|
79
|
+
} finally {
|
|
80
|
+
currentOwner = prev;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function getOwner() {
|
|
84
|
+
return currentOwner;
|
|
85
|
+
}
|
|
86
|
+
function isDisposed(owner) {
|
|
87
|
+
return owner._disposed;
|
|
88
|
+
}
|
|
89
|
+
function onCleanup(fn) {
|
|
90
|
+
const o = currentOwner;
|
|
91
|
+
if (!o) return fn;
|
|
92
|
+
if (!o._disposal) o._disposal = fn;else if (Array.isArray(o._disposal)) o._disposal.push(fn);else o._disposal = [o._disposal, fn];
|
|
93
|
+
return fn;
|
|
94
|
+
}
|
|
95
|
+
function getContext(context, owner = currentOwner) {
|
|
96
|
+
if (!owner) throw new NoOwnerError();
|
|
97
|
+
const map = owner._context;
|
|
98
|
+
const stored = map[context.id];
|
|
99
|
+
const value = stored !== undefined ? stored : context.defaultValue;
|
|
100
|
+
if (value === undefined) throw new ContextNotFoundError();
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
function setContext(context, value, owner = currentOwner) {
|
|
104
|
+
if (!owner) throw new NoOwnerError();
|
|
105
|
+
const o = owner;
|
|
106
|
+
o._context = {
|
|
107
|
+
...o._context,
|
|
108
|
+
[context.id]: value === undefined ? context.defaultValue : value
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function disposeOwner(owner, self = true) {
|
|
112
|
+
const node = owner;
|
|
113
|
+
if (node._disposed) return;
|
|
114
|
+
if (!node._firstChild && !node._disposal) {
|
|
115
|
+
if (self) {
|
|
116
|
+
node._disposed = true;
|
|
117
|
+
if (ownerPool.length < OWNER_POOL_MAX) {
|
|
118
|
+
node._parent = null;
|
|
119
|
+
node._nextSibling = null;
|
|
120
|
+
ownerPool.push(node);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (self) node._disposed = true;
|
|
126
|
+
let child = node._firstChild;
|
|
127
|
+
while (child) {
|
|
128
|
+
const next = child._nextSibling;
|
|
129
|
+
disposeOwner(child, true);
|
|
130
|
+
child = next;
|
|
131
|
+
}
|
|
132
|
+
node._firstChild = null;
|
|
133
|
+
node._childCount = 0;
|
|
134
|
+
const d = node._disposal;
|
|
135
|
+
if (d) {
|
|
136
|
+
if (Array.isArray(d)) {
|
|
137
|
+
for (let i = 0, len = d.length; i < len; i++) d[i]();
|
|
138
|
+
} else {
|
|
139
|
+
d();
|
|
140
|
+
}
|
|
141
|
+
node._disposal = null;
|
|
142
|
+
}
|
|
143
|
+
if (self && ownerPool.length < OWNER_POOL_MAX) {
|
|
144
|
+
node._parent = null;
|
|
145
|
+
node._nextSibling = null;
|
|
146
|
+
ownerPool.push(node);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function createRoot(init, options) {
|
|
150
|
+
const owner = createOwner(options);
|
|
151
|
+
return runWithOwner(owner, () => init(() => disposeOwner(owner)));
|
|
152
|
+
}
|
|
17
153
|
let Observer = null;
|
|
18
154
|
function runWithObserver(comp, fn) {
|
|
19
155
|
const prev = Observer;
|
|
@@ -98,6 +234,9 @@ function createSignal(first, second) {
|
|
|
98
234
|
}];
|
|
99
235
|
}
|
|
100
236
|
function createMemo(compute, options) {
|
|
237
|
+
if (options?.sync) {
|
|
238
|
+
return createSyncMemo(compute, options);
|
|
239
|
+
}
|
|
101
240
|
const ctx = sharedConfig.context;
|
|
102
241
|
const owner = createOwner();
|
|
103
242
|
const comp = {
|
|
@@ -133,7 +272,7 @@ function createMemo(compute, options) {
|
|
|
133
272
|
} else if (!options?.lazy) {
|
|
134
273
|
update();
|
|
135
274
|
}
|
|
136
|
-
|
|
275
|
+
const read = () => {
|
|
137
276
|
if (!comp.computed) {
|
|
138
277
|
update();
|
|
139
278
|
}
|
|
@@ -142,6 +281,44 @@ function createMemo(compute, options) {
|
|
|
142
281
|
}
|
|
143
282
|
return comp.value;
|
|
144
283
|
};
|
|
284
|
+
read[$REFRESH] = comp;
|
|
285
|
+
return read;
|
|
286
|
+
}
|
|
287
|
+
function createSyncMemo(compute, options) {
|
|
288
|
+
const owner = createOwner();
|
|
289
|
+
let value;
|
|
290
|
+
let error;
|
|
291
|
+
let cached = false;
|
|
292
|
+
function pull() {
|
|
293
|
+
const prev = currentOwner;
|
|
294
|
+
currentOwner = owner;
|
|
295
|
+
try {
|
|
296
|
+
value = compute(value);
|
|
297
|
+
error = undefined;
|
|
298
|
+
cached = true;
|
|
299
|
+
return value;
|
|
300
|
+
} catch (err) {
|
|
301
|
+
if (err instanceof NotReadyError) throw err;
|
|
302
|
+
error = err;
|
|
303
|
+
cached = true;
|
|
304
|
+
throw err;
|
|
305
|
+
} finally {
|
|
306
|
+
currentOwner = prev;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (!options?.lazy) {
|
|
310
|
+
try {
|
|
311
|
+
pull();
|
|
312
|
+
} catch {
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return () => {
|
|
316
|
+
if (cached) {
|
|
317
|
+
if (error !== undefined) throw error;
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
320
|
+
return pull();
|
|
321
|
+
};
|
|
145
322
|
}
|
|
146
323
|
function createDeepProxy(target, patches, basePath = []) {
|
|
147
324
|
const childProxies = new Map();
|
|
@@ -567,44 +744,62 @@ function deep(store) {
|
|
|
567
744
|
return store;
|
|
568
745
|
}
|
|
569
746
|
function mapArray(list, mapFn, options = {}) {
|
|
570
|
-
const parent = createOwner();
|
|
571
747
|
return createMemo(() => {
|
|
572
748
|
const items = list();
|
|
573
|
-
|
|
749
|
+
const s = [];
|
|
574
750
|
if (items && items.length) {
|
|
575
|
-
|
|
751
|
+
const parent = currentOwner;
|
|
752
|
+
const origId = parent.id;
|
|
753
|
+
const origChildCount = parent._childCount;
|
|
754
|
+
try {
|
|
576
755
|
for (let i = 0, len = items.length; i < len; i++) {
|
|
577
|
-
|
|
578
|
-
|
|
756
|
+
if (origId !== undefined) {
|
|
757
|
+
parent.id = formatChildId(origId, origChildCount + i);
|
|
758
|
+
}
|
|
759
|
+
parent._childCount = 0;
|
|
760
|
+
s.push(mapFn(() => items[i], () => i));
|
|
579
761
|
}
|
|
580
|
-
}
|
|
762
|
+
} finally {
|
|
763
|
+
parent.id = origId;
|
|
764
|
+
parent._childCount = origChildCount + items.length;
|
|
765
|
+
}
|
|
581
766
|
} else if (options.fallback) {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return runWithOwner(fo, () => options.fallback());
|
|
585
|
-
})];
|
|
767
|
+
const fo = createOwner();
|
|
768
|
+
s.push(runWithOwner(fo, () => options.fallback()));
|
|
586
769
|
}
|
|
587
770
|
return s;
|
|
771
|
+
}, {
|
|
772
|
+
sync: true
|
|
588
773
|
});
|
|
589
774
|
}
|
|
590
775
|
function repeat(count, mapFn, options = {}) {
|
|
591
|
-
const owner = createOwner();
|
|
592
776
|
return createMemo(() => {
|
|
593
777
|
const len = count();
|
|
594
778
|
const offset = options.from?.() || 0;
|
|
595
779
|
if (!len) {
|
|
596
780
|
if (!options.fallback) return [];
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return runWithOwner(fallbackOwner, () => options.fallback());
|
|
600
|
-
})];
|
|
781
|
+
const fo = createOwner();
|
|
782
|
+
return [runWithOwner(fo, () => options.fallback())];
|
|
601
783
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
784
|
+
const out = new Array(len);
|
|
785
|
+
const parent = currentOwner;
|
|
786
|
+
const origId = parent.id;
|
|
787
|
+
const origChildCount = parent._childCount;
|
|
788
|
+
try {
|
|
789
|
+
for (let i = 0; i < len; i++) {
|
|
790
|
+
if (origId !== undefined) {
|
|
791
|
+
parent.id = formatChildId(origId, origChildCount + i);
|
|
792
|
+
}
|
|
793
|
+
parent._childCount = 0;
|
|
794
|
+
out[i] = mapFn(i + offset);
|
|
795
|
+
}
|
|
796
|
+
} finally {
|
|
797
|
+
parent.id = origId;
|
|
798
|
+
parent._childCount = origChildCount + len;
|
|
799
|
+
}
|
|
800
|
+
return out;
|
|
801
|
+
}, {
|
|
802
|
+
sync: true
|
|
608
803
|
});
|
|
609
804
|
}
|
|
610
805
|
const ErrorContext = {
|
|
@@ -656,7 +851,7 @@ function createErrorBoundary(fn, fallback) {
|
|
|
656
851
|
return () => {
|
|
657
852
|
let result;
|
|
658
853
|
let handled = false;
|
|
659
|
-
if (ctx) owner
|
|
854
|
+
if (ctx) disposeOwner(owner, false);
|
|
660
855
|
try {
|
|
661
856
|
result = ctx ? runWithBoundaryErrorContext(owner, resolve, err => {
|
|
662
857
|
if (err instanceof NotReadyError) throw err;
|
|
@@ -710,8 +905,8 @@ function latest(fn) {
|
|
|
710
905
|
function isRefreshing() {
|
|
711
906
|
return false;
|
|
712
907
|
}
|
|
713
|
-
function refresh(
|
|
714
|
-
return
|
|
908
|
+
function refresh(_target) {
|
|
909
|
+
return undefined;
|
|
715
910
|
}
|
|
716
911
|
function action(fn) {
|
|
717
912
|
return fn;
|
|
@@ -742,7 +937,8 @@ function children(fn) {
|
|
|
742
937
|
lazy: true
|
|
743
938
|
});
|
|
744
939
|
const memo = createMemo(() => flatten(c()), {
|
|
745
|
-
lazy: true
|
|
940
|
+
lazy: true,
|
|
941
|
+
sync: true
|
|
746
942
|
});
|
|
747
943
|
memo.toArray = () => {
|
|
748
944
|
const v = memo();
|
|
@@ -750,11 +946,6 @@ function children(fn) {
|
|
|
750
946
|
};
|
|
751
947
|
return memo;
|
|
752
948
|
}
|
|
753
|
-
function ssrRunInScope(fn) {
|
|
754
|
-
const owner = getOwner();
|
|
755
|
-
if (!owner) return fn;
|
|
756
|
-
return Array.isArray(fn) ? fn.map(hole => () => runWithOwner(owner, hole)) : () => runWithOwner(owner, fn);
|
|
757
|
-
}
|
|
758
949
|
|
|
759
950
|
function enableHydration() {}
|
|
760
951
|
function createComponent(Comp, props) {
|
|
@@ -798,6 +989,8 @@ function lazy(fn, moduleUrl) {
|
|
|
798
989
|
return createMemo(() => {
|
|
799
990
|
if (!p.v) throw new NotReadyError(p);
|
|
800
991
|
return p.v(props);
|
|
992
|
+
}, {
|
|
993
|
+
sync: true
|
|
801
994
|
});
|
|
802
995
|
};
|
|
803
996
|
wrap.preload = load;
|
|
@@ -881,7 +1074,7 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
881
1074
|
}
|
|
882
1075
|
}
|
|
883
1076
|
function runDiscovery() {
|
|
884
|
-
o
|
|
1077
|
+
disposeOwner(o, false);
|
|
885
1078
|
serializeBuffer = [];
|
|
886
1079
|
retryPromise = undefined;
|
|
887
1080
|
return runLoadingPhase(() => {
|
|
@@ -928,12 +1121,13 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
928
1121
|
ret = runDiscovery();
|
|
929
1122
|
}
|
|
930
1123
|
commitBoundaryState();
|
|
931
|
-
while (ret.p.length) {
|
|
932
|
-
|
|
933
|
-
|
|
1124
|
+
while (ret && ret.p && ret.p.length) {
|
|
1125
|
+
const pending = ret;
|
|
1126
|
+
await Promise.all(pending.p).catch(() => {});
|
|
1127
|
+
ret = runLoadingPhase(() => ctx.ssr(pending.t, ...pending.h));
|
|
934
1128
|
}
|
|
935
1129
|
flushSerializeBuffer();
|
|
936
|
-
done(ret.t[0]);
|
|
1130
|
+
done(ret && Array.isArray(ret.t) ? ret.t[0] : ret && ret.t);
|
|
937
1131
|
if (revealGroup) revealGroup.onResolved(id);
|
|
938
1132
|
} catch (err) {
|
|
939
1133
|
finalizeError(err);
|
|
@@ -995,6 +1189,8 @@ function Show(props) {
|
|
|
995
1189
|
return child;
|
|
996
1190
|
}
|
|
997
1191
|
return props.fallback;
|
|
1192
|
+
}, {
|
|
1193
|
+
sync: true
|
|
998
1194
|
});
|
|
999
1195
|
}
|
|
1000
1196
|
function Switch(props) {
|
|
@@ -1012,6 +1208,8 @@ function Switch(props) {
|
|
|
1012
1208
|
}
|
|
1013
1209
|
}
|
|
1014
1210
|
return props.fallback;
|
|
1211
|
+
}, {
|
|
1212
|
+
sync: true
|
|
1015
1213
|
});
|
|
1016
1214
|
}
|
|
1017
1215
|
function Match(props) {
|
|
@@ -1201,4 +1399,4 @@ function Reveal(props) {
|
|
|
1201
1399
|
|
|
1202
1400
|
const DEV = undefined;
|
|
1203
1401
|
|
|
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,
|
|
1402
|
+
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, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getNextChildId, getObserver, getOwner, isDisposed, isPending, isRefreshing, latest, lazy, mapArray, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, sharedConfig, ssrHandleError, untrack, useContext };
|
package/dist/solid.cjs
CHANGED
|
@@ -24,7 +24,8 @@ function children(fn) {
|
|
|
24
24
|
lazy: true
|
|
25
25
|
});
|
|
26
26
|
const memo = signals.createMemo(() => signals.flatten(c()), {
|
|
27
|
-
lazy: true
|
|
27
|
+
lazy: true,
|
|
28
|
+
sync: true
|
|
28
29
|
});
|
|
29
30
|
memo.toArray = () => {
|
|
30
31
|
const v = memo();
|
|
@@ -741,7 +742,9 @@ function lazy(fn, moduleUrl) {
|
|
|
741
742
|
let Comp;
|
|
742
743
|
return signals.createMemo(() => (Comp = comp()) ? signals.untrack(() => {
|
|
743
744
|
return Comp(props);
|
|
744
|
-
}) : ""
|
|
745
|
+
}) : "", {
|
|
746
|
+
sync: true
|
|
747
|
+
});
|
|
745
748
|
};
|
|
746
749
|
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
747
750
|
wrap.moduleUrl = moduleUrl;
|
|
@@ -773,7 +776,8 @@ function Show(props) {
|
|
|
773
776
|
const keyed = props.keyed;
|
|
774
777
|
const conditionValue = signals.createMemo(() => props.when, undefined);
|
|
775
778
|
const condition = keyed ? conditionValue : signals.createMemo(conditionValue, {
|
|
776
|
-
equals: (a, b) => !a === !b
|
|
779
|
+
equals: (a, b) => !a === !b,
|
|
780
|
+
sync: true
|
|
777
781
|
});
|
|
778
782
|
return signals.createMemo(() => {
|
|
779
783
|
const c = condition();
|
|
@@ -786,7 +790,9 @@ function Show(props) {
|
|
|
786
790
|
}), IS_DEV) : child;
|
|
787
791
|
}
|
|
788
792
|
return props.fallback;
|
|
789
|
-
},
|
|
793
|
+
}, {
|
|
794
|
+
sync: true
|
|
795
|
+
});
|
|
790
796
|
}
|
|
791
797
|
function Switch(props) {
|
|
792
798
|
const chs = children(() => props.children);
|
|
@@ -799,11 +805,14 @@ function Switch(props) {
|
|
|
799
805
|
const prevFunc = func;
|
|
800
806
|
const conditionValue = signals.createMemo(() => prevFunc() ? undefined : mp.when, undefined);
|
|
801
807
|
const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue, {
|
|
802
|
-
equals: (a, b) => !a === !b
|
|
808
|
+
equals: (a, b) => !a === !b,
|
|
809
|
+
sync: true
|
|
803
810
|
});
|
|
804
811
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
805
812
|
}
|
|
806
813
|
return func;
|
|
814
|
+
}, {
|
|
815
|
+
sync: true
|
|
807
816
|
});
|
|
808
817
|
return signals.createMemo(() => {
|
|
809
818
|
const sel = switchFunc()();
|
|
@@ -815,7 +824,9 @@ function Switch(props) {
|
|
|
815
824
|
if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
816
825
|
return conditionValue();
|
|
817
826
|
}), IS_DEV) : child;
|
|
818
|
-
},
|
|
827
|
+
}, {
|
|
828
|
+
sync: true
|
|
829
|
+
});
|
|
819
830
|
}
|
|
820
831
|
function Match(props) {
|
|
821
832
|
return props;
|
|
@@ -840,7 +851,6 @@ function Reveal(props) {
|
|
|
840
851
|
}
|
|
841
852
|
|
|
842
853
|
function ssrHandleError() {}
|
|
843
|
-
function ssrRunInScope() {}
|
|
844
854
|
const DEV = undefined;
|
|
845
855
|
|
|
846
856
|
Object.defineProperty(exports, "$PROXY", {
|
|
@@ -1022,5 +1032,4 @@ exports.enableHydration = enableHydration;
|
|
|
1022
1032
|
exports.lazy = lazy;
|
|
1023
1033
|
exports.sharedConfig = sharedConfig;
|
|
1024
1034
|
exports.ssrHandleError = ssrHandleError;
|
|
1025
|
-
exports.ssrRunInScope = ssrRunInScope;
|
|
1026
1035
|
exports.useContext = useContext;
|
package/dist/solid.js
CHANGED
|
@@ -23,7 +23,8 @@ function children(fn) {
|
|
|
23
23
|
lazy: true
|
|
24
24
|
});
|
|
25
25
|
const memo = createMemo$1(() => flatten(c()), {
|
|
26
|
-
lazy: true
|
|
26
|
+
lazy: true,
|
|
27
|
+
sync: true
|
|
27
28
|
});
|
|
28
29
|
memo.toArray = () => {
|
|
29
30
|
const v = memo();
|
|
@@ -740,7 +741,9 @@ function lazy(fn, moduleUrl) {
|
|
|
740
741
|
let Comp;
|
|
741
742
|
return createMemo$1(() => (Comp = comp()) ? untrack(() => {
|
|
742
743
|
return Comp(props);
|
|
743
|
-
}) : ""
|
|
744
|
+
}) : "", {
|
|
745
|
+
sync: true
|
|
746
|
+
});
|
|
744
747
|
};
|
|
745
748
|
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
746
749
|
wrap.moduleUrl = moduleUrl;
|
|
@@ -772,7 +775,8 @@ function Show(props) {
|
|
|
772
775
|
const keyed = props.keyed;
|
|
773
776
|
const conditionValue = createMemo$1(() => props.when, undefined);
|
|
774
777
|
const condition = keyed ? conditionValue : createMemo$1(conditionValue, {
|
|
775
|
-
equals: (a, b) => !a === !b
|
|
778
|
+
equals: (a, b) => !a === !b,
|
|
779
|
+
sync: true
|
|
776
780
|
});
|
|
777
781
|
return createMemo$1(() => {
|
|
778
782
|
const c = condition();
|
|
@@ -785,7 +789,9 @@ function Show(props) {
|
|
|
785
789
|
}), IS_DEV) : child;
|
|
786
790
|
}
|
|
787
791
|
return props.fallback;
|
|
788
|
-
},
|
|
792
|
+
}, {
|
|
793
|
+
sync: true
|
|
794
|
+
});
|
|
789
795
|
}
|
|
790
796
|
function Switch(props) {
|
|
791
797
|
const chs = children(() => props.children);
|
|
@@ -798,11 +804,14 @@ function Switch(props) {
|
|
|
798
804
|
const prevFunc = func;
|
|
799
805
|
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined);
|
|
800
806
|
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, {
|
|
801
|
-
equals: (a, b) => !a === !b
|
|
807
|
+
equals: (a, b) => !a === !b,
|
|
808
|
+
sync: true
|
|
802
809
|
});
|
|
803
810
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
804
811
|
}
|
|
805
812
|
return func;
|
|
813
|
+
}, {
|
|
814
|
+
sync: true
|
|
806
815
|
});
|
|
807
816
|
return createMemo$1(() => {
|
|
808
817
|
const sel = switchFunc()();
|
|
@@ -814,7 +823,9 @@ function Switch(props) {
|
|
|
814
823
|
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
815
824
|
return conditionValue();
|
|
816
825
|
}), IS_DEV) : child;
|
|
817
|
-
},
|
|
826
|
+
}, {
|
|
827
|
+
sync: true
|
|
828
|
+
});
|
|
818
829
|
}
|
|
819
830
|
function Match(props) {
|
|
820
831
|
return props;
|
|
@@ -839,7 +850,6 @@ function Reveal(props) {
|
|
|
839
850
|
}
|
|
840
851
|
|
|
841
852
|
function ssrHandleError() {}
|
|
842
|
-
function ssrRunInScope() {}
|
|
843
853
|
const DEV = undefined;
|
|
844
854
|
|
|
845
|
-
export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError,
|
|
855
|
+
export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, useContext };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "Reactive JavaScript library for building user interfaces. Compiles JSX to real DOM with fine-grained signal-based updates — no virtual DOM.",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.11",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"performance"
|
|
108
108
|
],
|
|
109
109
|
"dependencies": {
|
|
110
|
-
"@solidjs/signals": "^2.0.0-beta.
|
|
110
|
+
"@solidjs/signals": "^2.0.0-beta.11",
|
|
111
111
|
"csstype": "^3.1.0",
|
|
112
112
|
"seroval": "~1.5.0",
|
|
113
113
|
"seroval-plugins": "~1.5.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createErrorBoundary as coreErrorBoundary, createRenderEffect as coreRenderEffect, createEffect as coreEffect, type
|
|
1
|
+
import { createErrorBoundary as coreErrorBoundary, createRenderEffect as coreRenderEffect, createEffect as coreEffect, type ComputeFunction, type MemoOptions, type NoInfer, type ProjectionOptions, type Refreshable, type Signal, type SignalOptions, type SourceAccessor, type Store, type StoreSetter, type Context } from "@solidjs/signals";
|
|
2
2
|
import type { Element as SolidElement } from "../types.js";
|
|
3
3
|
type HydrationSsrFields = {
|
|
4
4
|
/**
|
|
@@ -34,11 +34,12 @@ declare module "@solidjs/signals" {
|
|
|
34
34
|
}
|
|
35
35
|
interface EffectOptions extends HydrationSsrFields {
|
|
36
36
|
}
|
|
37
|
+
interface ProjectionOptions extends HydrationSsrFields {
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* Options for `createProjection`, `createStore(fn, ...)`, and
|
|
40
|
-
* `createOptimisticStore(fn, ...)
|
|
41
|
-
* hydration-aware `ssrSource` field.
|
|
42
|
+
* `createOptimisticStore(fn, ...)`.
|
|
42
43
|
*
|
|
43
44
|
* `ssrSource` controls what initial value the client uses and whether
|
|
44
45
|
* the projection's compute re-runs:
|
|
@@ -52,9 +53,6 @@ declare module "@solidjs/signals" {
|
|
|
52
53
|
*
|
|
53
54
|
* See {@link HydrationSsrFields} for the fuller explanation.
|
|
54
55
|
*/
|
|
55
|
-
export type HydrationProjectionOptions = ProjectionOptions & {
|
|
56
|
-
ssrSource?: "server" | "hybrid" | "client";
|
|
57
|
-
};
|
|
58
56
|
type HydrationClientMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
|
|
59
57
|
ssrSource: "client";
|
|
60
58
|
};
|
|
@@ -157,8 +155,8 @@ export declare function enableHydration(): void;
|
|
|
157
155
|
* @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
|
|
158
156
|
*/
|
|
159
157
|
export declare const createMemo: {
|
|
160
|
-
<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: HydrationClientMemoOptions<T>):
|
|
161
|
-
<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: HydrationMemoOptions<T>):
|
|
158
|
+
<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: HydrationClientMemoOptions<T>): SourceAccessor<T | undefined>;
|
|
159
|
+
<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: HydrationMemoOptions<T>): SourceAccessor<T>;
|
|
162
160
|
};
|
|
163
161
|
/**
|
|
164
162
|
* Creates a simple reactive state with a getter and setter.
|
|
@@ -302,11 +300,11 @@ export declare const createOptimistic: {
|
|
|
302
300
|
* );
|
|
303
301
|
* ```
|
|
304
302
|
*
|
|
305
|
-
* **Hydration:**
|
|
303
|
+
* **Hydration:** `ProjectionOptions` accepts an `ssrSource` field
|
|
306
304
|
* (`"server"` | `"hybrid"` | `"client"`) for the same client-vs-server
|
|
307
305
|
* tradeoffs as the other primitives. See {@link HydrationSsrFields}.
|
|
308
306
|
*/
|
|
309
|
-
export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: T, options?:
|
|
307
|
+
export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: T, options?: ProjectionOptions) => Refreshable<Store<T>>;
|
|
310
308
|
type NoFn<T> = T extends Function ? never : T;
|
|
311
309
|
/**
|
|
312
310
|
* Creates a deeply-reactive store backed by a Proxy. Reads track each
|
|
@@ -362,15 +360,15 @@ type NoFn<T> = T extends Function ? never : T;
|
|
|
362
360
|
* );
|
|
363
361
|
* ```
|
|
364
362
|
*
|
|
365
|
-
* **Hydration:** the derived form accepts
|
|
366
|
-
*
|
|
363
|
+
* **Hydration:** the derived form accepts `ProjectionOptions`, including
|
|
364
|
+
* an `ssrSource` field
|
|
367
365
|
* (`"server"` | `"hybrid"` | `"client"`). See {@link HydrationSsrFields}.
|
|
368
366
|
*
|
|
369
367
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
370
368
|
*/
|
|
371
369
|
export declare const createStore: {
|
|
372
370
|
<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
373
|
-
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?:
|
|
371
|
+
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
374
372
|
};
|
|
375
373
|
/**
|
|
376
374
|
* The store equivalent of `createOptimistic`. Writes inside an
|
|
@@ -412,15 +410,15 @@ export declare const createStore: {
|
|
|
412
410
|
* });
|
|
413
411
|
* ```
|
|
414
412
|
*
|
|
415
|
-
* **Hydration:** the derived form accepts
|
|
416
|
-
*
|
|
413
|
+
* **Hydration:** the derived form accepts `ProjectionOptions`, including
|
|
414
|
+
* an `ssrSource` field
|
|
417
415
|
* (`"server"` | `"hybrid"` | `"client"`). See {@link HydrationSsrFields}.
|
|
418
416
|
*
|
|
419
417
|
* @returns `[store: Store<T>, setStore: StoreSetter<T>]`
|
|
420
418
|
*/
|
|
421
419
|
export declare const createOptimisticStore: {
|
|
422
420
|
<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
423
|
-
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?:
|
|
421
|
+
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
|
|
424
422
|
};
|
|
425
423
|
/**
|
|
426
424
|
* Creates a reactive computation that runs during the render phase as
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { $PROXY, $REFRESH, $TRACK, action, createOwner, createReaction, createRevealOrder, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
|
|
2
|
-
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Refreshable, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
2
|
+
export type { Accessor, ComputeFunction, EffectBundle, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, MemoOptions, NoInfer, NotWrappable, Omit, Owner, ProjectionOptions, Refreshable, Signal, SignalOptions, SourceAccessor, Setter, Store, StoreOptions, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
3
3
|
export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedElement } from "./client/core.js";
|
|
5
5
|
export * from "./client/component.js";
|
|
@@ -8,8 +8,6 @@ export type { ArrayElement, Element } from "./types.js";
|
|
|
8
8
|
export { sharedConfig, enableHydration, createErrorBoundary, createLoadingBoundary, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect, NoHydration, Hydration, NoHydrateContext } from "./client/hydration.js";
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare function ssrHandleError(): void;
|
|
11
|
-
/** @internal */
|
|
12
|
-
export declare function ssrRunInScope(): void;
|
|
13
11
|
import { type Dev } from "@solidjs/signals";
|
|
14
12
|
export declare const DEV: Dev | undefined;
|
|
15
13
|
declare global {
|