solid-js 1.3.0-rc.0 → 1.3.0-rc.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 +78 -47
- package/dist/dev.js +77 -48
- package/dist/server.cjs +13 -3
- package/dist/server.js +11 -4
- package/dist/solid.cjs +72 -46
- package/dist/solid.js +71 -47
- package/package.json +2 -2
- package/types/index.d.ts +1 -1
- package/types/reactive/signal.d.ts +27 -7
- package/types/server/index.d.ts +2 -2
- package/types/server/reactive.d.ts +2 -0
- package/types/server/rendering.d.ts +1 -0
- package/web/dist/dev.cjs +13 -37
- package/web/dist/dev.js +1 -1
- package/web/dist/server.cjs +26 -38
- package/web/dist/server.js +16 -8
- package/web/dist/web.cjs +13 -37
- package/web/dist/web.js +1 -1
package/dist/solid.cjs
CHANGED
|
@@ -131,6 +131,7 @@ function nextHydrateContext() {
|
|
|
131
131
|
|
|
132
132
|
const equalFn = (a, b) => a === b;
|
|
133
133
|
const $PROXY = Symbol("solid-proxy");
|
|
134
|
+
const $DEVCOMP = Symbol('solid-dev-component');
|
|
134
135
|
const signalOptions = {
|
|
135
136
|
equals: equalFn
|
|
136
137
|
};
|
|
@@ -167,14 +168,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
167
168
|
};
|
|
168
169
|
Owner = root;
|
|
169
170
|
Listener = null;
|
|
170
|
-
let result;
|
|
171
171
|
try {
|
|
172
|
-
runUpdates(() =>
|
|
172
|
+
return runUpdates(() => fn(() => cleanNode(root)), true);
|
|
173
173
|
} finally {
|
|
174
174
|
Listener = listener;
|
|
175
175
|
Owner = owner;
|
|
176
176
|
}
|
|
177
|
-
return result;
|
|
178
177
|
}
|
|
179
178
|
function createSignal(value, options) {
|
|
180
179
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -207,7 +206,21 @@ function createEffect(fn, value, options) {
|
|
|
207
206
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
208
207
|
if (s) c.suspense = s;
|
|
209
208
|
c.user = true;
|
|
210
|
-
Effects
|
|
209
|
+
Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
|
|
210
|
+
}
|
|
211
|
+
function createReaction(onInvalidate, options) {
|
|
212
|
+
let fn;
|
|
213
|
+
const c = createComputation(() => {
|
|
214
|
+
fn ? fn() : untrack(onInvalidate);
|
|
215
|
+
fn = undefined;
|
|
216
|
+
}, undefined, false, 0),
|
|
217
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
218
|
+
if (s) c.suspense = s;
|
|
219
|
+
c.user = true;
|
|
220
|
+
return tracking => {
|
|
221
|
+
fn = tracking;
|
|
222
|
+
updateComputation(c);
|
|
223
|
+
};
|
|
211
224
|
}
|
|
212
225
|
function createMemo(fn, value, options) {
|
|
213
226
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -233,11 +246,14 @@ function createResource(source, fetcher, options) {
|
|
|
233
246
|
fetcher = source;
|
|
234
247
|
source = true;
|
|
235
248
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
249
|
+
options ||= {};
|
|
250
|
+
if (options.globalRefetch !== false) {
|
|
251
|
+
Resources || (Resources = new Set());
|
|
252
|
+
Resources.add(load);
|
|
253
|
+
Owner && onCleanup(() => Resources.delete(load));
|
|
254
|
+
}
|
|
239
255
|
const contexts = new Set(),
|
|
240
|
-
[s, set] = createSignal(
|
|
256
|
+
[s, set] = createSignal(options.initialValue),
|
|
241
257
|
[track, trigger] = createSignal(undefined, {
|
|
242
258
|
equals: false
|
|
243
259
|
}),
|
|
@@ -253,10 +269,14 @@ function createResource(source, fetcher, options) {
|
|
|
253
269
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
254
270
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
255
271
|
}
|
|
256
|
-
function loadEnd(p, v, e) {
|
|
272
|
+
function loadEnd(p, v, e, key) {
|
|
257
273
|
if (pr === p) {
|
|
258
|
-
setError(err = e);
|
|
259
274
|
pr = null;
|
|
275
|
+
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
276
|
+
value: v
|
|
277
|
+
});
|
|
278
|
+
initP = null;
|
|
279
|
+
setError(err = e);
|
|
260
280
|
if (Transition && p && loadedUnderTransition) {
|
|
261
281
|
Transition.promises.delete(p);
|
|
262
282
|
loadedUnderTransition = false;
|
|
@@ -310,17 +330,16 @@ function createResource(source, fetcher, options) {
|
|
|
310
330
|
value: s(),
|
|
311
331
|
refetching
|
|
312
332
|
}));
|
|
313
|
-
initP = null;
|
|
314
333
|
if (typeof p !== "object" || !("then" in p)) {
|
|
315
334
|
loadEnd(pr, p);
|
|
316
|
-
return;
|
|
335
|
+
return p;
|
|
317
336
|
}
|
|
318
337
|
pr = p;
|
|
319
338
|
batch(() => {
|
|
320
339
|
setLoading(true);
|
|
321
340
|
trigger();
|
|
322
341
|
});
|
|
323
|
-
p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
|
|
342
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
|
|
324
343
|
}
|
|
325
344
|
Object.defineProperties(read, {
|
|
326
345
|
loading: {
|
|
@@ -342,7 +361,7 @@ function createResource(source, fetcher, options) {
|
|
|
342
361
|
}
|
|
343
362
|
let Resources;
|
|
344
363
|
function refetchResources(info) {
|
|
345
|
-
Resources && Resources.
|
|
364
|
+
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
346
365
|
}
|
|
347
366
|
function createDeferred(source, options) {
|
|
348
367
|
let t,
|
|
@@ -456,7 +475,7 @@ function runWithOwner(o, fn) {
|
|
|
456
475
|
const prev = Owner;
|
|
457
476
|
Owner = o;
|
|
458
477
|
try {
|
|
459
|
-
return fn
|
|
478
|
+
return runUpdates(fn, true);
|
|
460
479
|
} finally {
|
|
461
480
|
Owner = prev;
|
|
462
481
|
}
|
|
@@ -464,28 +483,31 @@ function runWithOwner(o, fn) {
|
|
|
464
483
|
function enableScheduling(scheduler = requestCallback) {
|
|
465
484
|
Scheduler = scheduler;
|
|
466
485
|
}
|
|
467
|
-
function startTransition(fn
|
|
486
|
+
function startTransition(fn) {
|
|
468
487
|
if (Transition && Transition.running) {
|
|
469
488
|
fn();
|
|
470
|
-
|
|
471
|
-
return;
|
|
489
|
+
return Transition.done;
|
|
472
490
|
}
|
|
473
|
-
|
|
491
|
+
const l = Listener;
|
|
492
|
+
const o = Owner;
|
|
493
|
+
return Promise.resolve().then(() => {
|
|
494
|
+
Listener = l;
|
|
495
|
+
Owner = o;
|
|
496
|
+
let t;
|
|
474
497
|
if (Scheduler || SuspenseContext) {
|
|
475
|
-
Transition || (Transition = {
|
|
498
|
+
t = Transition || (Transition = {
|
|
476
499
|
sources: new Set(),
|
|
477
500
|
effects: [],
|
|
478
501
|
promises: new Set(),
|
|
479
502
|
disposed: new Set(),
|
|
480
503
|
queue: new Set(),
|
|
481
|
-
running: true
|
|
482
|
-
cb: []
|
|
504
|
+
running: true
|
|
483
505
|
});
|
|
484
|
-
|
|
485
|
-
|
|
506
|
+
t.done ||= new Promise(res => t.resolve = res);
|
|
507
|
+
t.running = true;
|
|
486
508
|
}
|
|
487
509
|
batch(fn);
|
|
488
|
-
|
|
510
|
+
return t ? t.done : undefined;
|
|
489
511
|
});
|
|
490
512
|
}
|
|
491
513
|
function useTransition() {
|
|
@@ -665,7 +687,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
665
687
|
});
|
|
666
688
|
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
667
689
|
onCleanup(() => ordinary.dispose());
|
|
668
|
-
const triggerInTransition = () => startTransition(trigger
|
|
690
|
+
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
669
691
|
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
670
692
|
c.fn = x => {
|
|
671
693
|
track();
|
|
@@ -710,7 +732,7 @@ function runUpdates(fn, init) {
|
|
|
710
732
|
if (Effects) wait = true;else Effects = [];
|
|
711
733
|
ExecCount++;
|
|
712
734
|
try {
|
|
713
|
-
fn();
|
|
735
|
+
return fn();
|
|
714
736
|
} catch (err) {
|
|
715
737
|
handleError(err);
|
|
716
738
|
} finally {
|
|
@@ -723,7 +745,7 @@ function completeUpdates(wait) {
|
|
|
723
745
|
Updates = null;
|
|
724
746
|
}
|
|
725
747
|
if (wait) return;
|
|
726
|
-
let
|
|
748
|
+
let res;
|
|
727
749
|
if (Transition && Transition.running) {
|
|
728
750
|
if (Transition.promises.size || Transition.queue.size) {
|
|
729
751
|
Transition.running = false;
|
|
@@ -733,7 +755,7 @@ function completeUpdates(wait) {
|
|
|
733
755
|
return;
|
|
734
756
|
}
|
|
735
757
|
const sources = Transition.sources;
|
|
736
|
-
|
|
758
|
+
res = Transition.resolve;
|
|
737
759
|
Effects.forEach(e => {
|
|
738
760
|
"tState" in e && (e.state = e.tState);
|
|
739
761
|
delete e.tState;
|
|
@@ -759,7 +781,7 @@ function completeUpdates(wait) {
|
|
|
759
781
|
});else {
|
|
760
782
|
Effects = null;
|
|
761
783
|
}
|
|
762
|
-
if (
|
|
784
|
+
if (res) res();
|
|
763
785
|
}
|
|
764
786
|
function runQueue(queue) {
|
|
765
787
|
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
|
|
@@ -1219,9 +1241,9 @@ function lazy(fn) {
|
|
|
1219
1241
|
});
|
|
1220
1242
|
comp = s;
|
|
1221
1243
|
} else if (!comp) {
|
|
1222
|
-
const [s] = createResource((
|
|
1223
|
-
|
|
1224
|
-
})
|
|
1244
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
|
|
1245
|
+
globalRefetch: false
|
|
1246
|
+
});
|
|
1225
1247
|
comp = s;
|
|
1226
1248
|
} else {
|
|
1227
1249
|
const c = comp();
|
|
@@ -1404,19 +1426,21 @@ function Suspense(props) {
|
|
|
1404
1426
|
if (sharedConfig.context) {
|
|
1405
1427
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1406
1428
|
p = sharedConfig.load(key);
|
|
1407
|
-
if (p
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1429
|
+
if (p) {
|
|
1430
|
+
if (typeof p !== "object" || !("then" in p)) error = p;else {
|
|
1431
|
+
const [s, set] = createSignal(undefined, {
|
|
1432
|
+
equals: false
|
|
1433
|
+
});
|
|
1434
|
+
flicker = s;
|
|
1435
|
+
p.then(err => {
|
|
1436
|
+
if (error = err) return set();
|
|
1437
|
+
sharedConfig.gather(key);
|
|
1438
|
+
setHydrateContext(ctx);
|
|
1439
|
+
set();
|
|
1440
|
+
setHydrateContext();
|
|
1441
|
+
p = undefined;
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1420
1444
|
}
|
|
1421
1445
|
}
|
|
1422
1446
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1465,6 +1489,7 @@ function Suspense(props) {
|
|
|
1465
1489
|
|
|
1466
1490
|
let DEV;
|
|
1467
1491
|
|
|
1492
|
+
exports.$DEVCOMP = $DEVCOMP;
|
|
1468
1493
|
exports.$PROXY = $PROXY;
|
|
1469
1494
|
exports.DEV = DEV;
|
|
1470
1495
|
exports.ErrorBoundary = ErrorBoundary;
|
|
@@ -1484,6 +1509,7 @@ exports.createContext = createContext;
|
|
|
1484
1509
|
exports.createDeferred = createDeferred;
|
|
1485
1510
|
exports.createEffect = createEffect;
|
|
1486
1511
|
exports.createMemo = createMemo;
|
|
1512
|
+
exports.createReaction = createReaction;
|
|
1487
1513
|
exports.createRenderEffect = createRenderEffect;
|
|
1488
1514
|
exports.createResource = createResource;
|
|
1489
1515
|
exports.createRoot = createRoot;
|
package/dist/solid.js
CHANGED
|
@@ -127,6 +127,7 @@ function nextHydrateContext() {
|
|
|
127
127
|
|
|
128
128
|
const equalFn = (a, b) => a === b;
|
|
129
129
|
const $PROXY = Symbol("solid-proxy");
|
|
130
|
+
const $DEVCOMP = Symbol('solid-dev-component');
|
|
130
131
|
const signalOptions = {
|
|
131
132
|
equals: equalFn
|
|
132
133
|
};
|
|
@@ -163,14 +164,12 @@ function createRoot(fn, detachedOwner) {
|
|
|
163
164
|
};
|
|
164
165
|
Owner = root;
|
|
165
166
|
Listener = null;
|
|
166
|
-
let result;
|
|
167
167
|
try {
|
|
168
|
-
runUpdates(() =>
|
|
168
|
+
return runUpdates(() => fn(() => cleanNode(root)), true);
|
|
169
169
|
} finally {
|
|
170
170
|
Listener = listener;
|
|
171
171
|
Owner = owner;
|
|
172
172
|
}
|
|
173
|
-
return result;
|
|
174
173
|
}
|
|
175
174
|
function createSignal(value, options) {
|
|
176
175
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -203,7 +202,21 @@ function createEffect(fn, value, options) {
|
|
|
203
202
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
204
203
|
if (s) c.suspense = s;
|
|
205
204
|
c.user = true;
|
|
206
|
-
Effects
|
|
205
|
+
Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
|
|
206
|
+
}
|
|
207
|
+
function createReaction(onInvalidate, options) {
|
|
208
|
+
let fn;
|
|
209
|
+
const c = createComputation(() => {
|
|
210
|
+
fn ? fn() : untrack(onInvalidate);
|
|
211
|
+
fn = undefined;
|
|
212
|
+
}, undefined, false, 0),
|
|
213
|
+
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
214
|
+
if (s) c.suspense = s;
|
|
215
|
+
c.user = true;
|
|
216
|
+
return tracking => {
|
|
217
|
+
fn = tracking;
|
|
218
|
+
updateComputation(c);
|
|
219
|
+
};
|
|
207
220
|
}
|
|
208
221
|
function createMemo(fn, value, options) {
|
|
209
222
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
@@ -229,11 +242,14 @@ function createResource(source, fetcher, options) {
|
|
|
229
242
|
fetcher = source;
|
|
230
243
|
source = true;
|
|
231
244
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
245
|
+
options ||= {};
|
|
246
|
+
if (options.globalRefetch !== false) {
|
|
247
|
+
Resources || (Resources = new Set());
|
|
248
|
+
Resources.add(load);
|
|
249
|
+
Owner && onCleanup(() => Resources.delete(load));
|
|
250
|
+
}
|
|
235
251
|
const contexts = new Set(),
|
|
236
|
-
[s, set] = createSignal(
|
|
252
|
+
[s, set] = createSignal(options.initialValue),
|
|
237
253
|
[track, trigger] = createSignal(undefined, {
|
|
238
254
|
equals: false
|
|
239
255
|
}),
|
|
@@ -249,10 +265,14 @@ function createResource(source, fetcher, options) {
|
|
|
249
265
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
250
266
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
251
267
|
}
|
|
252
|
-
function loadEnd(p, v, e) {
|
|
268
|
+
function loadEnd(p, v, e, key) {
|
|
253
269
|
if (pr === p) {
|
|
254
|
-
setError(err = e);
|
|
255
270
|
pr = null;
|
|
271
|
+
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
272
|
+
value: v
|
|
273
|
+
});
|
|
274
|
+
initP = null;
|
|
275
|
+
setError(err = e);
|
|
256
276
|
if (Transition && p && loadedUnderTransition) {
|
|
257
277
|
Transition.promises.delete(p);
|
|
258
278
|
loadedUnderTransition = false;
|
|
@@ -306,17 +326,16 @@ function createResource(source, fetcher, options) {
|
|
|
306
326
|
value: s(),
|
|
307
327
|
refetching
|
|
308
328
|
}));
|
|
309
|
-
initP = null;
|
|
310
329
|
if (typeof p !== "object" || !("then" in p)) {
|
|
311
330
|
loadEnd(pr, p);
|
|
312
|
-
return;
|
|
331
|
+
return p;
|
|
313
332
|
}
|
|
314
333
|
pr = p;
|
|
315
334
|
batch(() => {
|
|
316
335
|
setLoading(true);
|
|
317
336
|
trigger();
|
|
318
337
|
});
|
|
319
|
-
p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
|
|
338
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
|
|
320
339
|
}
|
|
321
340
|
Object.defineProperties(read, {
|
|
322
341
|
loading: {
|
|
@@ -338,7 +357,7 @@ function createResource(source, fetcher, options) {
|
|
|
338
357
|
}
|
|
339
358
|
let Resources;
|
|
340
359
|
function refetchResources(info) {
|
|
341
|
-
Resources && Resources.
|
|
360
|
+
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
342
361
|
}
|
|
343
362
|
function createDeferred(source, options) {
|
|
344
363
|
let t,
|
|
@@ -452,7 +471,7 @@ function runWithOwner(o, fn) {
|
|
|
452
471
|
const prev = Owner;
|
|
453
472
|
Owner = o;
|
|
454
473
|
try {
|
|
455
|
-
return fn
|
|
474
|
+
return runUpdates(fn, true);
|
|
456
475
|
} finally {
|
|
457
476
|
Owner = prev;
|
|
458
477
|
}
|
|
@@ -460,28 +479,31 @@ function runWithOwner(o, fn) {
|
|
|
460
479
|
function enableScheduling(scheduler = requestCallback) {
|
|
461
480
|
Scheduler = scheduler;
|
|
462
481
|
}
|
|
463
|
-
function startTransition(fn
|
|
482
|
+
function startTransition(fn) {
|
|
464
483
|
if (Transition && Transition.running) {
|
|
465
484
|
fn();
|
|
466
|
-
|
|
467
|
-
return;
|
|
485
|
+
return Transition.done;
|
|
468
486
|
}
|
|
469
|
-
|
|
487
|
+
const l = Listener;
|
|
488
|
+
const o = Owner;
|
|
489
|
+
return Promise.resolve().then(() => {
|
|
490
|
+
Listener = l;
|
|
491
|
+
Owner = o;
|
|
492
|
+
let t;
|
|
470
493
|
if (Scheduler || SuspenseContext) {
|
|
471
|
-
Transition || (Transition = {
|
|
494
|
+
t = Transition || (Transition = {
|
|
472
495
|
sources: new Set(),
|
|
473
496
|
effects: [],
|
|
474
497
|
promises: new Set(),
|
|
475
498
|
disposed: new Set(),
|
|
476
499
|
queue: new Set(),
|
|
477
|
-
running: true
|
|
478
|
-
cb: []
|
|
500
|
+
running: true
|
|
479
501
|
});
|
|
480
|
-
|
|
481
|
-
|
|
502
|
+
t.done ||= new Promise(res => t.resolve = res);
|
|
503
|
+
t.running = true;
|
|
482
504
|
}
|
|
483
505
|
batch(fn);
|
|
484
|
-
|
|
506
|
+
return t ? t.done : undefined;
|
|
485
507
|
});
|
|
486
508
|
}
|
|
487
509
|
function useTransition() {
|
|
@@ -661,7 +683,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
661
683
|
});
|
|
662
684
|
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
663
685
|
onCleanup(() => ordinary.dispose());
|
|
664
|
-
const triggerInTransition = () => startTransition(trigger
|
|
686
|
+
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
665
687
|
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
666
688
|
c.fn = x => {
|
|
667
689
|
track();
|
|
@@ -706,7 +728,7 @@ function runUpdates(fn, init) {
|
|
|
706
728
|
if (Effects) wait = true;else Effects = [];
|
|
707
729
|
ExecCount++;
|
|
708
730
|
try {
|
|
709
|
-
fn();
|
|
731
|
+
return fn();
|
|
710
732
|
} catch (err) {
|
|
711
733
|
handleError(err);
|
|
712
734
|
} finally {
|
|
@@ -719,7 +741,7 @@ function completeUpdates(wait) {
|
|
|
719
741
|
Updates = null;
|
|
720
742
|
}
|
|
721
743
|
if (wait) return;
|
|
722
|
-
let
|
|
744
|
+
let res;
|
|
723
745
|
if (Transition && Transition.running) {
|
|
724
746
|
if (Transition.promises.size || Transition.queue.size) {
|
|
725
747
|
Transition.running = false;
|
|
@@ -729,7 +751,7 @@ function completeUpdates(wait) {
|
|
|
729
751
|
return;
|
|
730
752
|
}
|
|
731
753
|
const sources = Transition.sources;
|
|
732
|
-
|
|
754
|
+
res = Transition.resolve;
|
|
733
755
|
Effects.forEach(e => {
|
|
734
756
|
"tState" in e && (e.state = e.tState);
|
|
735
757
|
delete e.tState;
|
|
@@ -755,7 +777,7 @@ function completeUpdates(wait) {
|
|
|
755
777
|
});else {
|
|
756
778
|
Effects = null;
|
|
757
779
|
}
|
|
758
|
-
if (
|
|
780
|
+
if (res) res();
|
|
759
781
|
}
|
|
760
782
|
function runQueue(queue) {
|
|
761
783
|
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
|
|
@@ -1215,9 +1237,9 @@ function lazy(fn) {
|
|
|
1215
1237
|
});
|
|
1216
1238
|
comp = s;
|
|
1217
1239
|
} else if (!comp) {
|
|
1218
|
-
const [s] = createResource((
|
|
1219
|
-
|
|
1220
|
-
})
|
|
1240
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
|
|
1241
|
+
globalRefetch: false
|
|
1242
|
+
});
|
|
1221
1243
|
comp = s;
|
|
1222
1244
|
} else {
|
|
1223
1245
|
const c = comp();
|
|
@@ -1400,19 +1422,21 @@ function Suspense(props) {
|
|
|
1400
1422
|
if (sharedConfig.context) {
|
|
1401
1423
|
const key = sharedConfig.context.id + sharedConfig.context.count;
|
|
1402
1424
|
p = sharedConfig.load(key);
|
|
1403
|
-
if (p
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1425
|
+
if (p) {
|
|
1426
|
+
if (typeof p !== "object" || !("then" in p)) error = p;else {
|
|
1427
|
+
const [s, set] = createSignal(undefined, {
|
|
1428
|
+
equals: false
|
|
1429
|
+
});
|
|
1430
|
+
flicker = s;
|
|
1431
|
+
p.then(err => {
|
|
1432
|
+
if (error = err) return set();
|
|
1433
|
+
sharedConfig.gather(key);
|
|
1434
|
+
setHydrateContext(ctx);
|
|
1435
|
+
set();
|
|
1436
|
+
setHydrateContext();
|
|
1437
|
+
p = undefined;
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1416
1440
|
}
|
|
1417
1441
|
}
|
|
1418
1442
|
const listContext = useContext(SuspenseListContext);
|
|
@@ -1461,4 +1485,4 @@ function Suspense(props) {
|
|
|
1461
1485
|
|
|
1462
1486
|
let DEV;
|
|
1463
1487
|
|
|
1464
|
-
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, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
|
1488
|
+
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, 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-rc.
|
|
4
|
+
"version": "1.3.0-rc.4",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"compiler",
|
|
145
145
|
"performance"
|
|
146
146
|
],
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "25d84f333fb0b2fd6f9e055148e66665c1a7d813"
|
|
148
148
|
}
|
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, enableExternalSource, startTransition, useTransition, refetchResources, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
|
|
1
|
+
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, refetchResources, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY } from "./reactive/signal";
|
|
2
2
|
export type { Accessor, Setter, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
|
|
3
3
|
export * from "./reactive/observable";
|
|
4
4
|
export * from "./reactive/scheduler";
|
|
@@ -2,6 +2,7 @@ import { requestCallback } from "./scheduler";
|
|
|
2
2
|
import type { JSX } from "../jsx";
|
|
3
3
|
export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
4
4
|
export declare const $PROXY: unique symbol;
|
|
5
|
+
export declare const $DEVCOMP: unique symbol;
|
|
5
6
|
export declare const NOTPENDING: {};
|
|
6
7
|
export declare var Owner: Owner | null;
|
|
7
8
|
export declare let Transition: TransitionState | null;
|
|
@@ -49,7 +50,8 @@ export interface TransitionState {
|
|
|
49
50
|
queue: Set<Computation<any>>;
|
|
50
51
|
scheduler?: (fn: () => void) => unknown;
|
|
51
52
|
running: boolean;
|
|
52
|
-
|
|
53
|
+
done?: Promise<void>;
|
|
54
|
+
resolve?: () => void;
|
|
53
55
|
}
|
|
54
56
|
declare type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(fn: EffectFunction<Prev, Next>, trigger: () => void) => ExternalSource;
|
|
55
57
|
export interface ExternalSource {
|
|
@@ -156,6 +158,20 @@ export declare function createRenderEffect<Next, Init = undefined>(..._: undefin
|
|
|
156
158
|
*/
|
|
157
159
|
export declare function createEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
158
160
|
export declare function createEffect<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
161
|
+
/**
|
|
162
|
+
* Creates a reactive computation that runs after the render phase with flexible tracking
|
|
163
|
+
* ```typescript
|
|
164
|
+
* export function createReaction(
|
|
165
|
+
* onInvalidate: () => void,
|
|
166
|
+
* options?: { name?: string }
|
|
167
|
+
* ): (fn: () => void) => void;
|
|
168
|
+
* ```
|
|
169
|
+
* @param invalidated a function that is called when tracked function is invalidated.
|
|
170
|
+
* @param options allows to set a name in dev mode for debugging purposes
|
|
171
|
+
*
|
|
172
|
+
* @description https://www.solidjs.com/docs/latest/api#createreaction
|
|
173
|
+
*/
|
|
174
|
+
export declare function createReaction(onInvalidate: () => void, options?: EffectOptions): (tracking: () => void) => void;
|
|
159
175
|
interface Memo<Prev, Next = Prev> extends SignalState<Next>, Computation<Next> {
|
|
160
176
|
tOwned?: Computation<Prev | Next, Next>[];
|
|
161
177
|
}
|
|
@@ -169,7 +185,7 @@ export interface MemoOptions<T> extends EffectOptions {
|
|
|
169
185
|
* fn: (v: T) => T,
|
|
170
186
|
* value?: T,
|
|
171
187
|
* options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
|
|
172
|
-
* ): T;
|
|
188
|
+
* ): () => T;
|
|
173
189
|
* ```
|
|
174
190
|
* @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
|
|
175
191
|
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
|
|
@@ -197,9 +213,13 @@ export declare type ResourceFetcherInfo<T> = {
|
|
|
197
213
|
export declare type ResourceOptions<T> = T extends undefined ? {
|
|
198
214
|
initialValue?: T;
|
|
199
215
|
name?: string;
|
|
216
|
+
globalRefetch?: boolean;
|
|
217
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
200
218
|
} : {
|
|
201
219
|
initialValue: T;
|
|
202
220
|
name?: string;
|
|
221
|
+
globalRefetch?: boolean;
|
|
222
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
203
223
|
};
|
|
204
224
|
/**
|
|
205
225
|
* Creates a resource that wraps a repeated promise in a reactive pattern:
|
|
@@ -230,7 +250,7 @@ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S,
|
|
|
230
250
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
231
251
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
232
252
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
233
|
-
export declare function refetchResources(info?: unknown):
|
|
253
|
+
export declare function refetchResources(info?: unknown): Promise<any[]>;
|
|
234
254
|
export interface DeferredOptions<T> {
|
|
235
255
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
236
256
|
name?: string;
|
|
@@ -351,16 +371,16 @@ export declare function onCleanup(fn: () => void): () => void;
|
|
|
351
371
|
export declare function onError(fn: (err: any) => void): void;
|
|
352
372
|
export declare function getListener(): Computation<any, any> | null;
|
|
353
373
|
export declare function getOwner(): Owner | null;
|
|
354
|
-
export declare function runWithOwner(o: Owner, fn: () =>
|
|
374
|
+
export declare function runWithOwner<T>(o: Owner, fn: () => T): T;
|
|
355
375
|
export declare function enableScheduling(scheduler?: typeof requestCallback): void;
|
|
356
376
|
/**
|
|
357
377
|
* ```typescript
|
|
358
|
-
* export function startTransition(fn: () => void
|
|
378
|
+
* export function startTransition(fn: () => void) => Promise<void>
|
|
359
379
|
*
|
|
360
380
|
* @description https://www.solidjs.com/docs/latest/api#usetransition
|
|
361
381
|
*/
|
|
362
|
-
export declare function startTransition(fn: () =>
|
|
363
|
-
export declare type Transition = [Accessor<boolean>, (fn: () => void
|
|
382
|
+
export declare function startTransition(fn: () => unknown): Promise<void>;
|
|
383
|
+
export declare type Transition = [Accessor<boolean>, (fn: () => void) => Promise<void>];
|
|
364
384
|
/**
|
|
365
385
|
* ```typescript
|
|
366
386
|
* export function useTransition(): [
|
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, enableExternalSource } from "./reactive";
|
|
2
|
-
export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, enableScheduling, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
|
|
1
|
+
export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createReaction, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, $DEVCOMP, DEV, enableExternalSource } from "./reactive";
|
|
2
|
+
export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, enableScheduling, enableHydration, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
|
|
3
3
|
export type { Component, Resource } from "./rendering";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Accessor, Setter } from "../reactive/signal";
|
|
2
2
|
export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
3
3
|
export declare const $PROXY: unique symbol;
|
|
4
|
+
export declare const $DEVCOMP: unique symbol;
|
|
4
5
|
export declare const DEV: {};
|
|
5
6
|
export declare let Owner: Owner | null;
|
|
6
7
|
interface Owner {
|
|
@@ -15,6 +16,7 @@ export declare function createSignal<T>(value: T, options?: {
|
|
|
15
16
|
export declare function createComputed<T>(fn: (v?: T) => T, value?: T): void;
|
|
16
17
|
export declare const createRenderEffect: typeof createComputed;
|
|
17
18
|
export declare function createEffect<T>(fn: (v?: T) => T, value?: T): void;
|
|
19
|
+
export declare function createReaction(fn: () => void): (fn: () => void) => void;
|
|
18
20
|
export declare function createMemo<T>(fn: (v?: T) => T, value?: T): () => T;
|
|
19
21
|
export declare function createDeferred<T>(source: () => T): () => T;
|
|
20
22
|
export declare function createSelector<T>(source: () => T, fn: (k: T, value: T) => boolean): (k: T) => boolean;
|
|
@@ -87,6 +87,7 @@ export declare function lazy(fn: () => Promise<{
|
|
|
87
87
|
default: any;
|
|
88
88
|
}>): (props: any) => string;
|
|
89
89
|
export declare function enableScheduling(): void;
|
|
90
|
+
export declare function enableHydration(): void;
|
|
90
91
|
export declare function startTransition(fn: () => any): void;
|
|
91
92
|
export declare function useTransition(): [() => boolean, (fn: () => any) => void];
|
|
92
93
|
declare type HydrationContext = {
|