solid-js 1.3.0-beta.3 → 1.3.0-beta.4
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 +50 -9
- package/dist/dev.js +49 -10
- package/dist/server.cjs +3 -1
- package/dist/server.js +3 -2
- package/dist/solid.cjs +50 -9
- package/dist/solid.js +49 -10
- package/package.json +2 -2
- package/types/index.d.ts +1 -1
- package/types/reactive/signal.d.ts +7 -0
- package/types/render/component.d.ts +4 -1
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -0
- package/web/dist/dev.cjs +10 -8
- package/web/dist/dev.js +11 -8
- package/web/dist/server.cjs +46 -110
- package/web/dist/server.js +46 -110
- package/web/dist/web.cjs +10 -8
- package/web/dist/web.js +11 -8
- package/web/types/client.d.ts +11 -2
- package/web/types/index.d.ts +2 -0
- package/web/types/server-mock.d.ts +36 -20
package/dist/dev.cjs
CHANGED
|
@@ -149,6 +149,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
|
149
149
|
var Owner = null;
|
|
150
150
|
let Transition = null;
|
|
151
151
|
let Scheduler = null;
|
|
152
|
+
let ExternalSourceFactory = null;
|
|
152
153
|
let Listener = null;
|
|
153
154
|
let Pending = null;
|
|
154
155
|
let Updates = null;
|
|
@@ -554,6 +555,24 @@ let SuspenseContext;
|
|
|
554
555
|
function getSuspenseContext() {
|
|
555
556
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
556
557
|
}
|
|
558
|
+
function enableExternalSource(factory) {
|
|
559
|
+
if (ExternalSourceFactory) {
|
|
560
|
+
const oldFactory = ExternalSourceFactory;
|
|
561
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
562
|
+
const oldSource = oldFactory(fn, trigger);
|
|
563
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
564
|
+
return {
|
|
565
|
+
track: x => source.track(x),
|
|
566
|
+
dispose() {
|
|
567
|
+
source.dispose();
|
|
568
|
+
oldSource.dispose();
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
} else {
|
|
573
|
+
ExternalSourceFactory = factory;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
557
576
|
function readSignal() {
|
|
558
577
|
const runningTransition = Transition && Transition.running;
|
|
559
578
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -682,6 +701,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
682
701
|
}
|
|
683
702
|
c.name = options && options.name || `${Owner.name || "c"}-${(Owner.owned || Owner.tOwned).length}`;
|
|
684
703
|
}
|
|
704
|
+
if (ExternalSourceFactory) {
|
|
705
|
+
const [track, trigger] = createSignal(undefined, {
|
|
706
|
+
equals: false
|
|
707
|
+
});
|
|
708
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
709
|
+
onCleanup(() => ordinary.dispose());
|
|
710
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
711
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
712
|
+
c.fn = x => {
|
|
713
|
+
track();
|
|
714
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
715
|
+
};
|
|
716
|
+
}
|
|
685
717
|
return c;
|
|
686
718
|
}
|
|
687
719
|
function runTop(node) {
|
|
@@ -1139,13 +1171,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1139
1171
|
};
|
|
1140
1172
|
}
|
|
1141
1173
|
|
|
1174
|
+
let hydrationEnabled = false;
|
|
1175
|
+
function enableHydration() {
|
|
1176
|
+
hydrationEnabled = true;
|
|
1177
|
+
}
|
|
1142
1178
|
function createComponent(Comp, props) {
|
|
1143
|
-
if (
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1179
|
+
if (hydrationEnabled) {
|
|
1180
|
+
if (sharedConfig.context) {
|
|
1181
|
+
const c = sharedConfig.context;
|
|
1182
|
+
setHydrateContext(nextHydrateContext());
|
|
1183
|
+
const r = devComponent(Comp, props) ;
|
|
1184
|
+
setHydrateContext(c);
|
|
1185
|
+
return r;
|
|
1186
|
+
}
|
|
1149
1187
|
}
|
|
1150
1188
|
return devComponent(Comp, props);
|
|
1151
1189
|
}
|
|
@@ -1234,19 +1272,20 @@ function splitProps(props, ...keys) {
|
|
|
1234
1272
|
}
|
|
1235
1273
|
function lazy(fn) {
|
|
1236
1274
|
let comp;
|
|
1275
|
+
let p;
|
|
1237
1276
|
const wrap = props => {
|
|
1238
1277
|
const ctx = sharedConfig.context;
|
|
1239
1278
|
if (ctx) {
|
|
1240
1279
|
ctx.count++;
|
|
1241
1280
|
const [s, set] = createSignal();
|
|
1242
|
-
fn().then(mod => {
|
|
1281
|
+
(p || (p = fn())).then(mod => {
|
|
1243
1282
|
setHydrateContext(ctx);
|
|
1244
1283
|
set(() => mod.default);
|
|
1245
1284
|
setHydrateContext(undefined);
|
|
1246
1285
|
});
|
|
1247
1286
|
comp = s;
|
|
1248
1287
|
} else if (!comp) {
|
|
1249
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1288
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1250
1289
|
comp = s;
|
|
1251
1290
|
} else {
|
|
1252
1291
|
const c = comp();
|
|
@@ -1262,7 +1301,7 @@ function lazy(fn) {
|
|
|
1262
1301
|
return r;
|
|
1263
1302
|
}));
|
|
1264
1303
|
};
|
|
1265
|
-
wrap.preload = () =>
|
|
1304
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1266
1305
|
return wrap;
|
|
1267
1306
|
}
|
|
1268
1307
|
let counter = 0;
|
|
@@ -1519,6 +1558,8 @@ exports.createRoot = createRoot;
|
|
|
1519
1558
|
exports.createSelector = createSelector;
|
|
1520
1559
|
exports.createSignal = createSignal;
|
|
1521
1560
|
exports.createUniqueId = createUniqueId;
|
|
1561
|
+
exports.enableExternalSource = enableExternalSource;
|
|
1562
|
+
exports.enableHydration = enableHydration;
|
|
1522
1563
|
exports.enableScheduling = enableScheduling;
|
|
1523
1564
|
exports.equalFn = equalFn;
|
|
1524
1565
|
exports.from = from;
|
package/dist/dev.js
CHANGED
|
@@ -145,6 +145,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
|
145
145
|
var Owner = null;
|
|
146
146
|
let Transition = null;
|
|
147
147
|
let Scheduler = null;
|
|
148
|
+
let ExternalSourceFactory = null;
|
|
148
149
|
let Listener = null;
|
|
149
150
|
let Pending = null;
|
|
150
151
|
let Updates = null;
|
|
@@ -550,6 +551,24 @@ let SuspenseContext;
|
|
|
550
551
|
function getSuspenseContext() {
|
|
551
552
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
552
553
|
}
|
|
554
|
+
function enableExternalSource(factory) {
|
|
555
|
+
if (ExternalSourceFactory) {
|
|
556
|
+
const oldFactory = ExternalSourceFactory;
|
|
557
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
558
|
+
const oldSource = oldFactory(fn, trigger);
|
|
559
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
560
|
+
return {
|
|
561
|
+
track: x => source.track(x),
|
|
562
|
+
dispose() {
|
|
563
|
+
source.dispose();
|
|
564
|
+
oldSource.dispose();
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
};
|
|
568
|
+
} else {
|
|
569
|
+
ExternalSourceFactory = factory;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
553
572
|
function readSignal() {
|
|
554
573
|
const runningTransition = Transition && Transition.running;
|
|
555
574
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -678,6 +697,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
678
697
|
}
|
|
679
698
|
c.name = options && options.name || `${Owner.name || "c"}-${(Owner.owned || Owner.tOwned).length}`;
|
|
680
699
|
}
|
|
700
|
+
if (ExternalSourceFactory) {
|
|
701
|
+
const [track, trigger] = createSignal(undefined, {
|
|
702
|
+
equals: false
|
|
703
|
+
});
|
|
704
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
705
|
+
onCleanup(() => ordinary.dispose());
|
|
706
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
707
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
708
|
+
c.fn = x => {
|
|
709
|
+
track();
|
|
710
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
711
|
+
};
|
|
712
|
+
}
|
|
681
713
|
return c;
|
|
682
714
|
}
|
|
683
715
|
function runTop(node) {
|
|
@@ -1135,13 +1167,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1135
1167
|
};
|
|
1136
1168
|
}
|
|
1137
1169
|
|
|
1170
|
+
let hydrationEnabled = false;
|
|
1171
|
+
function enableHydration() {
|
|
1172
|
+
hydrationEnabled = true;
|
|
1173
|
+
}
|
|
1138
1174
|
function createComponent(Comp, props) {
|
|
1139
|
-
if (
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1175
|
+
if (hydrationEnabled) {
|
|
1176
|
+
if (sharedConfig.context) {
|
|
1177
|
+
const c = sharedConfig.context;
|
|
1178
|
+
setHydrateContext(nextHydrateContext());
|
|
1179
|
+
const r = devComponent(Comp, props) ;
|
|
1180
|
+
setHydrateContext(c);
|
|
1181
|
+
return r;
|
|
1182
|
+
}
|
|
1145
1183
|
}
|
|
1146
1184
|
return devComponent(Comp, props);
|
|
1147
1185
|
}
|
|
@@ -1230,19 +1268,20 @@ function splitProps(props, ...keys) {
|
|
|
1230
1268
|
}
|
|
1231
1269
|
function lazy(fn) {
|
|
1232
1270
|
let comp;
|
|
1271
|
+
let p;
|
|
1233
1272
|
const wrap = props => {
|
|
1234
1273
|
const ctx = sharedConfig.context;
|
|
1235
1274
|
if (ctx) {
|
|
1236
1275
|
ctx.count++;
|
|
1237
1276
|
const [s, set] = createSignal();
|
|
1238
|
-
fn().then(mod => {
|
|
1277
|
+
(p || (p = fn())).then(mod => {
|
|
1239
1278
|
setHydrateContext(ctx);
|
|
1240
1279
|
set(() => mod.default);
|
|
1241
1280
|
setHydrateContext(undefined);
|
|
1242
1281
|
});
|
|
1243
1282
|
comp = s;
|
|
1244
1283
|
} else if (!comp) {
|
|
1245
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1284
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1246
1285
|
comp = s;
|
|
1247
1286
|
} else {
|
|
1248
1287
|
const c = comp();
|
|
@@ -1258,7 +1297,7 @@ function lazy(fn) {
|
|
|
1258
1297
|
return r;
|
|
1259
1298
|
}));
|
|
1260
1299
|
};
|
|
1261
|
-
wrap.preload = () =>
|
|
1300
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1262
1301
|
return wrap;
|
|
1263
1302
|
}
|
|
1264
1303
|
let counter = 0;
|
|
@@ -1491,4 +1530,4 @@ if (globalThis) {
|
|
|
1491
1530
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1492
1531
|
}
|
|
1493
1532
|
|
|
1494
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1533
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/server.cjs
CHANGED
|
@@ -208,6 +208,7 @@ function from(producer) {
|
|
|
208
208
|
}
|
|
209
209
|
return s;
|
|
210
210
|
}
|
|
211
|
+
function enableExternalSource(factory) {}
|
|
211
212
|
|
|
212
213
|
function resolveSSRNode(node) {
|
|
213
214
|
const t = typeof node;
|
|
@@ -425,7 +426,7 @@ function lazy(fn) {
|
|
|
425
426
|
});
|
|
426
427
|
return "";
|
|
427
428
|
};
|
|
428
|
-
wrap.preload = () =>
|
|
429
|
+
wrap.preload = () => p;
|
|
429
430
|
return wrap;
|
|
430
431
|
}
|
|
431
432
|
function suspenseComplete(c) {
|
|
@@ -530,6 +531,7 @@ exports.createRoot = createRoot;
|
|
|
530
531
|
exports.createSelector = createSelector;
|
|
531
532
|
exports.createSignal = createSignal;
|
|
532
533
|
exports.createUniqueId = createUniqueId;
|
|
534
|
+
exports.enableExternalSource = enableExternalSource;
|
|
533
535
|
exports.enableScheduling = enableScheduling;
|
|
534
536
|
exports.equalFn = equalFn;
|
|
535
537
|
exports.from = from;
|
package/dist/server.js
CHANGED
|
@@ -204,6 +204,7 @@ function from(producer) {
|
|
|
204
204
|
}
|
|
205
205
|
return s;
|
|
206
206
|
}
|
|
207
|
+
function enableExternalSource(factory) {}
|
|
207
208
|
|
|
208
209
|
function resolveSSRNode(node) {
|
|
209
210
|
const t = typeof node;
|
|
@@ -421,7 +422,7 @@ function lazy(fn) {
|
|
|
421
422
|
});
|
|
422
423
|
return "";
|
|
423
424
|
};
|
|
424
|
-
wrap.preload = () =>
|
|
425
|
+
wrap.preload = () => p;
|
|
425
426
|
return wrap;
|
|
426
427
|
}
|
|
427
428
|
function suspenseComplete(c) {
|
|
@@ -502,4 +503,4 @@ function Suspense(props) {
|
|
|
502
503
|
return createComponent(() => props.fallback, {});
|
|
503
504
|
}
|
|
504
505
|
|
|
505
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
506
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/solid.cjs
CHANGED
|
@@ -149,6 +149,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
|
149
149
|
var Owner = null;
|
|
150
150
|
let Transition = null;
|
|
151
151
|
let Scheduler = null;
|
|
152
|
+
let ExternalSourceFactory = null;
|
|
152
153
|
let Listener = null;
|
|
153
154
|
let Pending = null;
|
|
154
155
|
let Updates = null;
|
|
@@ -503,6 +504,24 @@ let SuspenseContext;
|
|
|
503
504
|
function getSuspenseContext() {
|
|
504
505
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
505
506
|
}
|
|
507
|
+
function enableExternalSource(factory) {
|
|
508
|
+
if (ExternalSourceFactory) {
|
|
509
|
+
const oldFactory = ExternalSourceFactory;
|
|
510
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
511
|
+
const oldSource = oldFactory(fn, trigger);
|
|
512
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
513
|
+
return {
|
|
514
|
+
track: x => source.track(x),
|
|
515
|
+
dispose() {
|
|
516
|
+
source.dispose();
|
|
517
|
+
oldSource.dispose();
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
} else {
|
|
522
|
+
ExternalSourceFactory = factory;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
506
525
|
function readSignal() {
|
|
507
526
|
const runningTransition = Transition && Transition.running;
|
|
508
527
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -630,6 +649,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
630
649
|
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
631
650
|
}
|
|
632
651
|
}
|
|
652
|
+
if (ExternalSourceFactory) {
|
|
653
|
+
const [track, trigger] = createSignal(undefined, {
|
|
654
|
+
equals: false
|
|
655
|
+
});
|
|
656
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
657
|
+
onCleanup(() => ordinary.dispose());
|
|
658
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
659
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
660
|
+
c.fn = x => {
|
|
661
|
+
track();
|
|
662
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
663
|
+
};
|
|
664
|
+
}
|
|
633
665
|
return c;
|
|
634
666
|
}
|
|
635
667
|
function runTop(node) {
|
|
@@ -1063,13 +1095,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1063
1095
|
};
|
|
1064
1096
|
}
|
|
1065
1097
|
|
|
1098
|
+
let hydrationEnabled = false;
|
|
1099
|
+
function enableHydration() {
|
|
1100
|
+
hydrationEnabled = true;
|
|
1101
|
+
}
|
|
1066
1102
|
function createComponent(Comp, props) {
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1103
|
+
if (hydrationEnabled) {
|
|
1104
|
+
if (sharedConfig.context) {
|
|
1105
|
+
const c = sharedConfig.context;
|
|
1106
|
+
setHydrateContext(nextHydrateContext());
|
|
1107
|
+
const r = untrack(() => Comp(props));
|
|
1108
|
+
setHydrateContext(c);
|
|
1109
|
+
return r;
|
|
1110
|
+
}
|
|
1073
1111
|
}
|
|
1074
1112
|
return untrack(() => Comp(props));
|
|
1075
1113
|
}
|
|
@@ -1158,19 +1196,20 @@ function splitProps(props, ...keys) {
|
|
|
1158
1196
|
}
|
|
1159
1197
|
function lazy(fn) {
|
|
1160
1198
|
let comp;
|
|
1199
|
+
let p;
|
|
1161
1200
|
const wrap = props => {
|
|
1162
1201
|
const ctx = sharedConfig.context;
|
|
1163
1202
|
if (ctx) {
|
|
1164
1203
|
ctx.count++;
|
|
1165
1204
|
const [s, set] = createSignal();
|
|
1166
|
-
fn().then(mod => {
|
|
1205
|
+
(p || (p = fn())).then(mod => {
|
|
1167
1206
|
setHydrateContext(ctx);
|
|
1168
1207
|
set(() => mod.default);
|
|
1169
1208
|
setHydrateContext(undefined);
|
|
1170
1209
|
});
|
|
1171
1210
|
comp = s;
|
|
1172
1211
|
} else if (!comp) {
|
|
1173
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1212
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1174
1213
|
comp = s;
|
|
1175
1214
|
} else {
|
|
1176
1215
|
const c = comp();
|
|
@@ -1186,7 +1225,7 @@ function lazy(fn) {
|
|
|
1186
1225
|
return r;
|
|
1187
1226
|
}));
|
|
1188
1227
|
};
|
|
1189
|
-
wrap.preload = () =>
|
|
1228
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1190
1229
|
return wrap;
|
|
1191
1230
|
}
|
|
1192
1231
|
let counter = 0;
|
|
@@ -1433,6 +1472,8 @@ exports.createRoot = createRoot;
|
|
|
1433
1472
|
exports.createSelector = createSelector;
|
|
1434
1473
|
exports.createSignal = createSignal;
|
|
1435
1474
|
exports.createUniqueId = createUniqueId;
|
|
1475
|
+
exports.enableExternalSource = enableExternalSource;
|
|
1476
|
+
exports.enableHydration = enableHydration;
|
|
1436
1477
|
exports.enableScheduling = enableScheduling;
|
|
1437
1478
|
exports.equalFn = equalFn;
|
|
1438
1479
|
exports.from = from;
|
package/dist/solid.js
CHANGED
|
@@ -145,6 +145,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
|
145
145
|
var Owner = null;
|
|
146
146
|
let Transition = null;
|
|
147
147
|
let Scheduler = null;
|
|
148
|
+
let ExternalSourceFactory = null;
|
|
148
149
|
let Listener = null;
|
|
149
150
|
let Pending = null;
|
|
150
151
|
let Updates = null;
|
|
@@ -499,6 +500,24 @@ let SuspenseContext;
|
|
|
499
500
|
function getSuspenseContext() {
|
|
500
501
|
return SuspenseContext || (SuspenseContext = createContext({}));
|
|
501
502
|
}
|
|
503
|
+
function enableExternalSource(factory) {
|
|
504
|
+
if (ExternalSourceFactory) {
|
|
505
|
+
const oldFactory = ExternalSourceFactory;
|
|
506
|
+
ExternalSourceFactory = (fn, trigger) => {
|
|
507
|
+
const oldSource = oldFactory(fn, trigger);
|
|
508
|
+
const source = factory(x => oldSource.track(x), trigger);
|
|
509
|
+
return {
|
|
510
|
+
track: x => source.track(x),
|
|
511
|
+
dispose() {
|
|
512
|
+
source.dispose();
|
|
513
|
+
oldSource.dispose();
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
} else {
|
|
518
|
+
ExternalSourceFactory = factory;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
502
521
|
function readSignal() {
|
|
503
522
|
const runningTransition = Transition && Transition.running;
|
|
504
523
|
if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
|
|
@@ -626,6 +645,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
626
645
|
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
627
646
|
}
|
|
628
647
|
}
|
|
648
|
+
if (ExternalSourceFactory) {
|
|
649
|
+
const [track, trigger] = createSignal(undefined, {
|
|
650
|
+
equals: false
|
|
651
|
+
});
|
|
652
|
+
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
653
|
+
onCleanup(() => ordinary.dispose());
|
|
654
|
+
const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
|
|
655
|
+
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
656
|
+
c.fn = x => {
|
|
657
|
+
track();
|
|
658
|
+
return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
|
|
659
|
+
};
|
|
660
|
+
}
|
|
629
661
|
return c;
|
|
630
662
|
}
|
|
631
663
|
function runTop(node) {
|
|
@@ -1059,13 +1091,19 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1059
1091
|
};
|
|
1060
1092
|
}
|
|
1061
1093
|
|
|
1094
|
+
let hydrationEnabled = false;
|
|
1095
|
+
function enableHydration() {
|
|
1096
|
+
hydrationEnabled = true;
|
|
1097
|
+
}
|
|
1062
1098
|
function createComponent(Comp, props) {
|
|
1063
|
-
if (
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1099
|
+
if (hydrationEnabled) {
|
|
1100
|
+
if (sharedConfig.context) {
|
|
1101
|
+
const c = sharedConfig.context;
|
|
1102
|
+
setHydrateContext(nextHydrateContext());
|
|
1103
|
+
const r = untrack(() => Comp(props));
|
|
1104
|
+
setHydrateContext(c);
|
|
1105
|
+
return r;
|
|
1106
|
+
}
|
|
1069
1107
|
}
|
|
1070
1108
|
return untrack(() => Comp(props));
|
|
1071
1109
|
}
|
|
@@ -1154,19 +1192,20 @@ function splitProps(props, ...keys) {
|
|
|
1154
1192
|
}
|
|
1155
1193
|
function lazy(fn) {
|
|
1156
1194
|
let comp;
|
|
1195
|
+
let p;
|
|
1157
1196
|
const wrap = props => {
|
|
1158
1197
|
const ctx = sharedConfig.context;
|
|
1159
1198
|
if (ctx) {
|
|
1160
1199
|
ctx.count++;
|
|
1161
1200
|
const [s, set] = createSignal();
|
|
1162
|
-
fn().then(mod => {
|
|
1201
|
+
(p || (p = fn())).then(mod => {
|
|
1163
1202
|
setHydrateContext(ctx);
|
|
1164
1203
|
set(() => mod.default);
|
|
1165
1204
|
setHydrateContext(undefined);
|
|
1166
1205
|
});
|
|
1167
1206
|
comp = s;
|
|
1168
1207
|
} else if (!comp) {
|
|
1169
|
-
const [s] = createResource(() => fn().then(mod => mod.default));
|
|
1208
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1170
1209
|
comp = s;
|
|
1171
1210
|
} else {
|
|
1172
1211
|
const c = comp();
|
|
@@ -1182,7 +1221,7 @@ function lazy(fn) {
|
|
|
1182
1221
|
return r;
|
|
1183
1222
|
}));
|
|
1184
1223
|
};
|
|
1185
|
-
wrap.preload = () =>
|
|
1224
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1186
1225
|
return wrap;
|
|
1187
1226
|
}
|
|
1188
1227
|
let counter = 0;
|
|
@@ -1404,4 +1443,4 @@ function Suspense(props) {
|
|
|
1404
1443
|
|
|
1405
1444
|
let DEV;
|
|
1406
1445
|
|
|
1407
|
-
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1446
|
+
export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.3.0-beta.
|
|
4
|
+
"version": "1.3.0-beta.4",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"compiler",
|
|
133
133
|
"performance"
|
|
134
134
|
],
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "c9307f020f33ff584f2d896c219e530d8ee97a9c"
|
|
136
136
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
|
|
1
|
+
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
|
|
2
2
|
export type { Accessor, Setter, Resource, ResourceReturn, Context, ReturnTypes } from "./reactive/signal";
|
|
3
3
|
export * from "./reactive/observable";
|
|
4
4
|
export * from "./reactive/scheduler";
|
|
@@ -5,6 +5,7 @@ export declare const $PROXY: unique symbol;
|
|
|
5
5
|
export declare const NOTPENDING: {};
|
|
6
6
|
export declare var Owner: Owner | null;
|
|
7
7
|
export declare let Transition: TransitionState | null;
|
|
8
|
+
declare let ExternalSourceFactory: ExternalSourceFactory | null;
|
|
8
9
|
declare global {
|
|
9
10
|
var _$afterUpdate: () => void;
|
|
10
11
|
}
|
|
@@ -50,6 +51,11 @@ export interface TransitionState {
|
|
|
50
51
|
running: boolean;
|
|
51
52
|
cb: (() => void)[];
|
|
52
53
|
}
|
|
54
|
+
declare type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(fn: EffectFunction<Prev, Next>, trigger: () => void) => ExternalSource;
|
|
55
|
+
export interface ExternalSource {
|
|
56
|
+
track: EffectFunction<any, any>;
|
|
57
|
+
dispose: () => void;
|
|
58
|
+
}
|
|
53
59
|
export declare type RootFunction<T> = (dispose: () => void) => T;
|
|
54
60
|
/**
|
|
55
61
|
* Creates a new non-tracked reactive context that doesn't auto-dispose
|
|
@@ -423,6 +429,7 @@ declare type SuspenseContext = Context<SuspenseContextType> & {
|
|
|
423
429
|
};
|
|
424
430
|
declare let SuspenseContext: SuspenseContext;
|
|
425
431
|
export declare function getSuspenseContext(): SuspenseContext;
|
|
432
|
+
export declare function enableExternalSource(factory: ExternalSourceFactory): void;
|
|
426
433
|
export declare function readSignal(this: SignalState<any> | Memo<any>): any;
|
|
427
434
|
export declare function writeSignal(node: SignalState<any> | Memo<any>, value: any, isComp?: boolean): any;
|
|
428
435
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JSX } from "../jsx";
|
|
2
|
+
export declare function enableHydration(): void;
|
|
2
3
|
export declare type PropsWithChildren<P = {}> = P & {
|
|
3
4
|
children?: JSX.Element;
|
|
4
5
|
};
|
|
@@ -36,7 +37,9 @@ export declare function splitProps<T extends object, K1 extends keyof T, K2 exte
|
|
|
36
37
|
export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
37
38
|
default: T;
|
|
38
39
|
}>): T & {
|
|
39
|
-
preload: () =>
|
|
40
|
+
preload: () => Promise<{
|
|
41
|
+
default: T;
|
|
42
|
+
}>;
|
|
40
43
|
};
|
|
41
44
|
export declare function createUniqueId(): string;
|
|
42
45
|
export {};
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, DEV } from "./reactive";
|
|
1
|
+
export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, DEV, enableExternalSource } from "./reactive";
|
|
2
2
|
export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, enableScheduling, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
|
|
3
3
|
export type { Component, Resource } from "./rendering";
|
package/web/dist/dev.cjs
CHANGED
|
@@ -98,7 +98,7 @@ function render(code, element, init) {
|
|
|
98
98
|
let disposer;
|
|
99
99
|
solidJs.createRoot(dispose => {
|
|
100
100
|
disposer = dispose;
|
|
101
|
-
insert(element, code(), element.firstChild ? null : undefined, init);
|
|
101
|
+
element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
|
|
102
102
|
});
|
|
103
103
|
return () => {
|
|
104
104
|
disposer();
|
|
@@ -218,17 +218,17 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
|
218
218
|
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
function hydrate(code, element) {
|
|
221
|
+
function hydrate$1(code, element, options = {}) {
|
|
222
222
|
solidJs.sharedConfig.completed = globalThis._$HY.completed;
|
|
223
223
|
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
224
224
|
solidJs.sharedConfig.load = globalThis._$HY.load;
|
|
225
225
|
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
226
226
|
solidJs.sharedConfig.registry = new Map();
|
|
227
227
|
solidJs.sharedConfig.context = {
|
|
228
|
-
id: "",
|
|
228
|
+
id: options.renderId || "",
|
|
229
229
|
count: 0
|
|
230
230
|
};
|
|
231
|
-
gatherHydratable(element);
|
|
231
|
+
gatherHydratable(element, options.renderId);
|
|
232
232
|
const dispose = render(code, element, [...element.childNodes]);
|
|
233
233
|
solidJs.sharedConfig.context = null;
|
|
234
234
|
return dispose;
|
|
@@ -475,8 +475,7 @@ function NoHydration(props) {
|
|
|
475
475
|
|
|
476
476
|
function renderToString(fn, options) {}
|
|
477
477
|
function renderToStringAsync(fn, options) {}
|
|
478
|
-
function
|
|
479
|
-
function pipeToWritable(fn, writable, options) {}
|
|
478
|
+
function renderToStream(fn, options) {}
|
|
480
479
|
function ssr(template, ...nodes) {}
|
|
481
480
|
function resolveSSRNode(node) {}
|
|
482
481
|
function ssrClassList(value) {}
|
|
@@ -492,6 +491,10 @@ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
|
492
491
|
function createElement(tagName, isSVG = false) {
|
|
493
492
|
return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
|
|
494
493
|
}
|
|
494
|
+
const hydrate = (...args) => {
|
|
495
|
+
solidJs.enableHydration();
|
|
496
|
+
return hydrate$1(...args);
|
|
497
|
+
};
|
|
495
498
|
function Portal(props) {
|
|
496
499
|
const {
|
|
497
500
|
useShadow
|
|
@@ -645,9 +648,8 @@ exports.hydrate = hydrate;
|
|
|
645
648
|
exports.insert = insert;
|
|
646
649
|
exports.isServer = isServer;
|
|
647
650
|
exports.memo = memo;
|
|
648
|
-
exports.pipeToNodeWritable = pipeToNodeWritable;
|
|
649
|
-
exports.pipeToWritable = pipeToWritable;
|
|
650
651
|
exports.render = render;
|
|
652
|
+
exports.renderToStream = renderToStream;
|
|
651
653
|
exports.renderToString = renderToString;
|
|
652
654
|
exports.renderToStringAsync = renderToStringAsync;
|
|
653
655
|
exports.resolveSSRNode = resolveSSRNode;
|