solid-js 1.3.0-rc.1 → 1.3.0-rc.2
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 +31 -26
- package/dist/dev.js +31 -26
- package/dist/server.cjs +4 -2
- package/dist/server.js +4 -3
- package/dist/solid.cjs +31 -26
- package/dist/solid.js +31 -26
- package/package.json +2 -2
- package/types/reactive/signal.d.ts +9 -4
- package/types/server/index.d.ts +1 -1
- package/types/server/rendering.d.ts +1 -0
package/dist/dev.cjs
CHANGED
|
@@ -236,11 +236,14 @@ function createResource(source, fetcher, options) {
|
|
|
236
236
|
fetcher = source;
|
|
237
237
|
source = true;
|
|
238
238
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
options ||= {};
|
|
240
|
+
if (options.globalRefetch !== false) {
|
|
241
|
+
Resources || (Resources = new Set());
|
|
242
|
+
Resources.add(load);
|
|
243
|
+
onCleanup(() => Resources.delete(load));
|
|
244
|
+
}
|
|
242
245
|
const contexts = new Set(),
|
|
243
|
-
[s, set] = createSignal(
|
|
246
|
+
[s, set] = createSignal(options.initialValue),
|
|
244
247
|
[track, trigger] = createSignal(undefined, {
|
|
245
248
|
equals: false
|
|
246
249
|
}),
|
|
@@ -256,10 +259,14 @@ function createResource(source, fetcher, options) {
|
|
|
256
259
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
257
260
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
258
261
|
}
|
|
259
|
-
function loadEnd(p, v, e) {
|
|
262
|
+
function loadEnd(p, v, e, key) {
|
|
260
263
|
if (pr === p) {
|
|
261
|
-
setError(err = e);
|
|
262
264
|
pr = null;
|
|
265
|
+
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
266
|
+
value: v
|
|
267
|
+
});
|
|
268
|
+
initP = null;
|
|
269
|
+
setError(err = e);
|
|
263
270
|
if (Transition && p && loadedUnderTransition) {
|
|
264
271
|
Transition.promises.delete(p);
|
|
265
272
|
loadedUnderTransition = false;
|
|
@@ -313,17 +320,16 @@ function createResource(source, fetcher, options) {
|
|
|
313
320
|
value: s(),
|
|
314
321
|
refetching
|
|
315
322
|
}));
|
|
316
|
-
initP = null;
|
|
317
323
|
if (typeof p !== "object" || !("then" in p)) {
|
|
318
324
|
loadEnd(pr, p);
|
|
319
|
-
return;
|
|
325
|
+
return p;
|
|
320
326
|
}
|
|
321
327
|
pr = p;
|
|
322
328
|
batch(() => {
|
|
323
329
|
setLoading(true);
|
|
324
330
|
trigger();
|
|
325
331
|
});
|
|
326
|
-
p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
|
|
332
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
|
|
327
333
|
}
|
|
328
334
|
Object.defineProperties(read, {
|
|
329
335
|
loading: {
|
|
@@ -467,28 +473,27 @@ function runWithOwner(o, fn) {
|
|
|
467
473
|
function enableScheduling(scheduler = requestCallback) {
|
|
468
474
|
Scheduler = scheduler;
|
|
469
475
|
}
|
|
470
|
-
function startTransition(fn
|
|
476
|
+
function startTransition(fn) {
|
|
471
477
|
if (Transition && Transition.running) {
|
|
472
478
|
fn();
|
|
473
|
-
|
|
474
|
-
return;
|
|
479
|
+
return Transition.done;
|
|
475
480
|
}
|
|
476
|
-
|
|
481
|
+
return Promise.resolve().then(() => {
|
|
482
|
+
let t;
|
|
477
483
|
if (Scheduler || SuspenseContext) {
|
|
478
|
-
Transition || (Transition = {
|
|
484
|
+
t = Transition || (Transition = {
|
|
479
485
|
sources: new Set(),
|
|
480
486
|
effects: [],
|
|
481
487
|
promises: new Set(),
|
|
482
488
|
disposed: new Set(),
|
|
483
489
|
queue: new Set(),
|
|
484
|
-
running: true
|
|
485
|
-
cb: []
|
|
490
|
+
running: true
|
|
486
491
|
});
|
|
487
|
-
|
|
488
|
-
|
|
492
|
+
t.done ||= new Promise(res => t.resolve = res);
|
|
493
|
+
t.running = true;
|
|
489
494
|
}
|
|
490
495
|
batch(fn);
|
|
491
|
-
|
|
496
|
+
return t ? t.done : undefined;
|
|
492
497
|
});
|
|
493
498
|
}
|
|
494
499
|
function useTransition() {
|
|
@@ -717,7 +722,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
717
722
|
});
|
|
718
723
|
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
719
724
|
onCleanup(() => ordinary.dispose());
|
|
720
|
-
const triggerInTransition = () => startTransition(trigger
|
|
725
|
+
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
721
726
|
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
722
727
|
c.fn = x => {
|
|
723
728
|
track();
|
|
@@ -775,7 +780,7 @@ function completeUpdates(wait) {
|
|
|
775
780
|
Updates = null;
|
|
776
781
|
}
|
|
777
782
|
if (wait) return;
|
|
778
|
-
let
|
|
783
|
+
let res;
|
|
779
784
|
if (Transition && Transition.running) {
|
|
780
785
|
if (Transition.promises.size || Transition.queue.size) {
|
|
781
786
|
Transition.running = false;
|
|
@@ -785,7 +790,7 @@ function completeUpdates(wait) {
|
|
|
785
790
|
return;
|
|
786
791
|
}
|
|
787
792
|
const sources = Transition.sources;
|
|
788
|
-
|
|
793
|
+
res = Transition.resolve;
|
|
789
794
|
Effects.forEach(e => {
|
|
790
795
|
"tState" in e && (e.state = e.tState);
|
|
791
796
|
delete e.tState;
|
|
@@ -812,7 +817,7 @@ function completeUpdates(wait) {
|
|
|
812
817
|
Effects = null;
|
|
813
818
|
globalThis._$afterUpdate && globalThis._$afterUpdate();
|
|
814
819
|
}
|
|
815
|
-
if (
|
|
820
|
+
if (res) res();
|
|
816
821
|
}
|
|
817
822
|
function runQueue(queue) {
|
|
818
823
|
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
|
|
@@ -1295,9 +1300,9 @@ function lazy(fn) {
|
|
|
1295
1300
|
});
|
|
1296
1301
|
comp = s;
|
|
1297
1302
|
} else if (!comp) {
|
|
1298
|
-
const [s] = createResource((
|
|
1299
|
-
|
|
1300
|
-
})
|
|
1303
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
|
|
1304
|
+
globalRefetch: false
|
|
1305
|
+
});
|
|
1301
1306
|
comp = s;
|
|
1302
1307
|
} else {
|
|
1303
1308
|
const c = comp();
|
package/dist/dev.js
CHANGED
|
@@ -232,11 +232,14 @@ function createResource(source, fetcher, options) {
|
|
|
232
232
|
fetcher = source;
|
|
233
233
|
source = true;
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
options ||= {};
|
|
236
|
+
if (options.globalRefetch !== false) {
|
|
237
|
+
Resources || (Resources = new Set());
|
|
238
|
+
Resources.add(load);
|
|
239
|
+
onCleanup(() => Resources.delete(load));
|
|
240
|
+
}
|
|
238
241
|
const contexts = new Set(),
|
|
239
|
-
[s, set] = createSignal(
|
|
242
|
+
[s, set] = createSignal(options.initialValue),
|
|
240
243
|
[track, trigger] = createSignal(undefined, {
|
|
241
244
|
equals: false
|
|
242
245
|
}),
|
|
@@ -252,10 +255,14 @@ function createResource(source, fetcher, options) {
|
|
|
252
255
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
253
256
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
254
257
|
}
|
|
255
|
-
function loadEnd(p, v, e) {
|
|
258
|
+
function loadEnd(p, v, e, key) {
|
|
256
259
|
if (pr === p) {
|
|
257
|
-
setError(err = e);
|
|
258
260
|
pr = null;
|
|
261
|
+
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
262
|
+
value: v
|
|
263
|
+
});
|
|
264
|
+
initP = null;
|
|
265
|
+
setError(err = e);
|
|
259
266
|
if (Transition && p && loadedUnderTransition) {
|
|
260
267
|
Transition.promises.delete(p);
|
|
261
268
|
loadedUnderTransition = false;
|
|
@@ -309,17 +316,16 @@ function createResource(source, fetcher, options) {
|
|
|
309
316
|
value: s(),
|
|
310
317
|
refetching
|
|
311
318
|
}));
|
|
312
|
-
initP = null;
|
|
313
319
|
if (typeof p !== "object" || !("then" in p)) {
|
|
314
320
|
loadEnd(pr, p);
|
|
315
|
-
return;
|
|
321
|
+
return p;
|
|
316
322
|
}
|
|
317
323
|
pr = p;
|
|
318
324
|
batch(() => {
|
|
319
325
|
setLoading(true);
|
|
320
326
|
trigger();
|
|
321
327
|
});
|
|
322
|
-
p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
|
|
328
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
|
|
323
329
|
}
|
|
324
330
|
Object.defineProperties(read, {
|
|
325
331
|
loading: {
|
|
@@ -463,28 +469,27 @@ function runWithOwner(o, fn) {
|
|
|
463
469
|
function enableScheduling(scheduler = requestCallback) {
|
|
464
470
|
Scheduler = scheduler;
|
|
465
471
|
}
|
|
466
|
-
function startTransition(fn
|
|
472
|
+
function startTransition(fn) {
|
|
467
473
|
if (Transition && Transition.running) {
|
|
468
474
|
fn();
|
|
469
|
-
|
|
470
|
-
return;
|
|
475
|
+
return Transition.done;
|
|
471
476
|
}
|
|
472
|
-
|
|
477
|
+
return Promise.resolve().then(() => {
|
|
478
|
+
let t;
|
|
473
479
|
if (Scheduler || SuspenseContext) {
|
|
474
|
-
Transition || (Transition = {
|
|
480
|
+
t = Transition || (Transition = {
|
|
475
481
|
sources: new Set(),
|
|
476
482
|
effects: [],
|
|
477
483
|
promises: new Set(),
|
|
478
484
|
disposed: new Set(),
|
|
479
485
|
queue: new Set(),
|
|
480
|
-
running: true
|
|
481
|
-
cb: []
|
|
486
|
+
running: true
|
|
482
487
|
});
|
|
483
|
-
|
|
484
|
-
|
|
488
|
+
t.done ||= new Promise(res => t.resolve = res);
|
|
489
|
+
t.running = true;
|
|
485
490
|
}
|
|
486
491
|
batch(fn);
|
|
487
|
-
|
|
492
|
+
return t ? t.done : undefined;
|
|
488
493
|
});
|
|
489
494
|
}
|
|
490
495
|
function useTransition() {
|
|
@@ -713,7 +718,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
713
718
|
});
|
|
714
719
|
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
715
720
|
onCleanup(() => ordinary.dispose());
|
|
716
|
-
const triggerInTransition = () => startTransition(trigger
|
|
721
|
+
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
717
722
|
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
718
723
|
c.fn = x => {
|
|
719
724
|
track();
|
|
@@ -771,7 +776,7 @@ function completeUpdates(wait) {
|
|
|
771
776
|
Updates = null;
|
|
772
777
|
}
|
|
773
778
|
if (wait) return;
|
|
774
|
-
let
|
|
779
|
+
let res;
|
|
775
780
|
if (Transition && Transition.running) {
|
|
776
781
|
if (Transition.promises.size || Transition.queue.size) {
|
|
777
782
|
Transition.running = false;
|
|
@@ -781,7 +786,7 @@ function completeUpdates(wait) {
|
|
|
781
786
|
return;
|
|
782
787
|
}
|
|
783
788
|
const sources = Transition.sources;
|
|
784
|
-
|
|
789
|
+
res = Transition.resolve;
|
|
785
790
|
Effects.forEach(e => {
|
|
786
791
|
"tState" in e && (e.state = e.tState);
|
|
787
792
|
delete e.tState;
|
|
@@ -808,7 +813,7 @@ function completeUpdates(wait) {
|
|
|
808
813
|
Effects = null;
|
|
809
814
|
globalThis._$afterUpdate && globalThis._$afterUpdate();
|
|
810
815
|
}
|
|
811
|
-
if (
|
|
816
|
+
if (res) res();
|
|
812
817
|
}
|
|
813
818
|
function runQueue(queue) {
|
|
814
819
|
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
|
|
@@ -1291,9 +1296,9 @@ function lazy(fn) {
|
|
|
1291
1296
|
});
|
|
1292
1297
|
comp = s;
|
|
1293
1298
|
} else if (!comp) {
|
|
1294
|
-
const [s] = createResource((
|
|
1295
|
-
|
|
1296
|
-
})
|
|
1299
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
|
|
1300
|
+
globalRefetch: false
|
|
1301
|
+
});
|
|
1297
1302
|
comp = s;
|
|
1298
1303
|
} else {
|
|
1299
1304
|
const c = comp();
|
package/dist/server.cjs
CHANGED
|
@@ -381,7 +381,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
381
381
|
read.loading = true;
|
|
382
382
|
if ("then" in p) {
|
|
383
383
|
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
384
|
-
p.then(res => {
|
|
384
|
+
return p.then(res => {
|
|
385
385
|
read.loading = false;
|
|
386
386
|
ctx.resources[id].data = res;
|
|
387
387
|
p = null;
|
|
@@ -393,10 +393,10 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
393
393
|
p = null;
|
|
394
394
|
notifySuspense(contexts);
|
|
395
395
|
});
|
|
396
|
-
return;
|
|
397
396
|
}
|
|
398
397
|
ctx.resources[id].data = p;
|
|
399
398
|
p = null;
|
|
399
|
+
return ctx.resources[id].data;
|
|
400
400
|
}
|
|
401
401
|
load();
|
|
402
402
|
return resource.ref = [read, {
|
|
@@ -442,6 +442,7 @@ function notifySuspense(contexts) {
|
|
|
442
442
|
contexts.clear();
|
|
443
443
|
}
|
|
444
444
|
function enableScheduling() {}
|
|
445
|
+
function enableHydration() {}
|
|
445
446
|
function startTransition(fn) {
|
|
446
447
|
fn();
|
|
447
448
|
}
|
|
@@ -533,6 +534,7 @@ exports.createSelector = createSelector;
|
|
|
533
534
|
exports.createSignal = createSignal;
|
|
534
535
|
exports.createUniqueId = createUniqueId;
|
|
535
536
|
exports.enableExternalSource = enableExternalSource;
|
|
537
|
+
exports.enableHydration = enableHydration;
|
|
536
538
|
exports.enableScheduling = enableScheduling;
|
|
537
539
|
exports.equalFn = equalFn;
|
|
538
540
|
exports.from = from;
|
package/dist/server.js
CHANGED
|
@@ -377,7 +377,7 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
377
377
|
read.loading = true;
|
|
378
378
|
if ("then" in p) {
|
|
379
379
|
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
380
|
-
p.then(res => {
|
|
380
|
+
return p.then(res => {
|
|
381
381
|
read.loading = false;
|
|
382
382
|
ctx.resources[id].data = res;
|
|
383
383
|
p = null;
|
|
@@ -389,10 +389,10 @@ function createResource(fn, fetcher, options = {}) {
|
|
|
389
389
|
p = null;
|
|
390
390
|
notifySuspense(contexts);
|
|
391
391
|
});
|
|
392
|
-
return;
|
|
393
392
|
}
|
|
394
393
|
ctx.resources[id].data = p;
|
|
395
394
|
p = null;
|
|
395
|
+
return ctx.resources[id].data;
|
|
396
396
|
}
|
|
397
397
|
load();
|
|
398
398
|
return resource.ref = [read, {
|
|
@@ -438,6 +438,7 @@ function notifySuspense(contexts) {
|
|
|
438
438
|
contexts.clear();
|
|
439
439
|
}
|
|
440
440
|
function enableScheduling() {}
|
|
441
|
+
function enableHydration() {}
|
|
441
442
|
function startTransition(fn) {
|
|
442
443
|
fn();
|
|
443
444
|
}
|
|
@@ -504,4 +505,4 @@ function Suspense(props) {
|
|
|
504
505
|
return props.fallback;
|
|
505
506
|
}
|
|
506
507
|
|
|
507
|
-
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 };
|
|
508
|
+
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, enableHydration, 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
|
@@ -233,11 +233,14 @@ function createResource(source, fetcher, options) {
|
|
|
233
233
|
fetcher = source;
|
|
234
234
|
source = true;
|
|
235
235
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
options ||= {};
|
|
237
|
+
if (options.globalRefetch !== false) {
|
|
238
|
+
Resources || (Resources = new Set());
|
|
239
|
+
Resources.add(load);
|
|
240
|
+
onCleanup(() => Resources.delete(load));
|
|
241
|
+
}
|
|
239
242
|
const contexts = new Set(),
|
|
240
|
-
[s, set] = createSignal(
|
|
243
|
+
[s, set] = createSignal(options.initialValue),
|
|
241
244
|
[track, trigger] = createSignal(undefined, {
|
|
242
245
|
equals: false
|
|
243
246
|
}),
|
|
@@ -253,10 +256,14 @@ function createResource(source, fetcher, options) {
|
|
|
253
256
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
254
257
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
255
258
|
}
|
|
256
|
-
function loadEnd(p, v, e) {
|
|
259
|
+
function loadEnd(p, v, e, key) {
|
|
257
260
|
if (pr === p) {
|
|
258
|
-
setError(err = e);
|
|
259
261
|
pr = null;
|
|
262
|
+
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
263
|
+
value: v
|
|
264
|
+
});
|
|
265
|
+
initP = null;
|
|
266
|
+
setError(err = e);
|
|
260
267
|
if (Transition && p && loadedUnderTransition) {
|
|
261
268
|
Transition.promises.delete(p);
|
|
262
269
|
loadedUnderTransition = false;
|
|
@@ -310,17 +317,16 @@ function createResource(source, fetcher, options) {
|
|
|
310
317
|
value: s(),
|
|
311
318
|
refetching
|
|
312
319
|
}));
|
|
313
|
-
initP = null;
|
|
314
320
|
if (typeof p !== "object" || !("then" in p)) {
|
|
315
321
|
loadEnd(pr, p);
|
|
316
|
-
return;
|
|
322
|
+
return p;
|
|
317
323
|
}
|
|
318
324
|
pr = p;
|
|
319
325
|
batch(() => {
|
|
320
326
|
setLoading(true);
|
|
321
327
|
trigger();
|
|
322
328
|
});
|
|
323
|
-
p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
|
|
329
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
|
|
324
330
|
}
|
|
325
331
|
Object.defineProperties(read, {
|
|
326
332
|
loading: {
|
|
@@ -464,28 +470,27 @@ function runWithOwner(o, fn) {
|
|
|
464
470
|
function enableScheduling(scheduler = requestCallback) {
|
|
465
471
|
Scheduler = scheduler;
|
|
466
472
|
}
|
|
467
|
-
function startTransition(fn
|
|
473
|
+
function startTransition(fn) {
|
|
468
474
|
if (Transition && Transition.running) {
|
|
469
475
|
fn();
|
|
470
|
-
|
|
471
|
-
return;
|
|
476
|
+
return Transition.done;
|
|
472
477
|
}
|
|
473
|
-
|
|
478
|
+
return Promise.resolve().then(() => {
|
|
479
|
+
let t;
|
|
474
480
|
if (Scheduler || SuspenseContext) {
|
|
475
|
-
Transition || (Transition = {
|
|
481
|
+
t = Transition || (Transition = {
|
|
476
482
|
sources: new Set(),
|
|
477
483
|
effects: [],
|
|
478
484
|
promises: new Set(),
|
|
479
485
|
disposed: new Set(),
|
|
480
486
|
queue: new Set(),
|
|
481
|
-
running: true
|
|
482
|
-
cb: []
|
|
487
|
+
running: true
|
|
483
488
|
});
|
|
484
|
-
|
|
485
|
-
|
|
489
|
+
t.done ||= new Promise(res => t.resolve = res);
|
|
490
|
+
t.running = true;
|
|
486
491
|
}
|
|
487
492
|
batch(fn);
|
|
488
|
-
|
|
493
|
+
return t ? t.done : undefined;
|
|
489
494
|
});
|
|
490
495
|
}
|
|
491
496
|
function useTransition() {
|
|
@@ -665,7 +670,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
665
670
|
});
|
|
666
671
|
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
667
672
|
onCleanup(() => ordinary.dispose());
|
|
668
|
-
const triggerInTransition = () => startTransition(trigger
|
|
673
|
+
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
669
674
|
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
670
675
|
c.fn = x => {
|
|
671
676
|
track();
|
|
@@ -723,7 +728,7 @@ function completeUpdates(wait) {
|
|
|
723
728
|
Updates = null;
|
|
724
729
|
}
|
|
725
730
|
if (wait) return;
|
|
726
|
-
let
|
|
731
|
+
let res;
|
|
727
732
|
if (Transition && Transition.running) {
|
|
728
733
|
if (Transition.promises.size || Transition.queue.size) {
|
|
729
734
|
Transition.running = false;
|
|
@@ -733,7 +738,7 @@ function completeUpdates(wait) {
|
|
|
733
738
|
return;
|
|
734
739
|
}
|
|
735
740
|
const sources = Transition.sources;
|
|
736
|
-
|
|
741
|
+
res = Transition.resolve;
|
|
737
742
|
Effects.forEach(e => {
|
|
738
743
|
"tState" in e && (e.state = e.tState);
|
|
739
744
|
delete e.tState;
|
|
@@ -759,7 +764,7 @@ function completeUpdates(wait) {
|
|
|
759
764
|
});else {
|
|
760
765
|
Effects = null;
|
|
761
766
|
}
|
|
762
|
-
if (
|
|
767
|
+
if (res) res();
|
|
763
768
|
}
|
|
764
769
|
function runQueue(queue) {
|
|
765
770
|
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
|
|
@@ -1219,9 +1224,9 @@ function lazy(fn) {
|
|
|
1219
1224
|
});
|
|
1220
1225
|
comp = s;
|
|
1221
1226
|
} else if (!comp) {
|
|
1222
|
-
const [s] = createResource((
|
|
1223
|
-
|
|
1224
|
-
})
|
|
1227
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
|
|
1228
|
+
globalRefetch: false
|
|
1229
|
+
});
|
|
1225
1230
|
comp = s;
|
|
1226
1231
|
} else {
|
|
1227
1232
|
const c = comp();
|
package/dist/solid.js
CHANGED
|
@@ -229,11 +229,14 @@ function createResource(source, fetcher, options) {
|
|
|
229
229
|
fetcher = source;
|
|
230
230
|
source = true;
|
|
231
231
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
options ||= {};
|
|
233
|
+
if (options.globalRefetch !== false) {
|
|
234
|
+
Resources || (Resources = new Set());
|
|
235
|
+
Resources.add(load);
|
|
236
|
+
onCleanup(() => Resources.delete(load));
|
|
237
|
+
}
|
|
235
238
|
const contexts = new Set(),
|
|
236
|
-
[s, set] = createSignal(
|
|
239
|
+
[s, set] = createSignal(options.initialValue),
|
|
237
240
|
[track, trigger] = createSignal(undefined, {
|
|
238
241
|
equals: false
|
|
239
242
|
}),
|
|
@@ -249,10 +252,14 @@ function createResource(source, fetcher, options) {
|
|
|
249
252
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
250
253
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
251
254
|
}
|
|
252
|
-
function loadEnd(p, v, e) {
|
|
255
|
+
function loadEnd(p, v, e, key) {
|
|
253
256
|
if (pr === p) {
|
|
254
|
-
setError(err = e);
|
|
255
257
|
pr = null;
|
|
258
|
+
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
259
|
+
value: v
|
|
260
|
+
});
|
|
261
|
+
initP = null;
|
|
262
|
+
setError(err = e);
|
|
256
263
|
if (Transition && p && loadedUnderTransition) {
|
|
257
264
|
Transition.promises.delete(p);
|
|
258
265
|
loadedUnderTransition = false;
|
|
@@ -306,17 +313,16 @@ function createResource(source, fetcher, options) {
|
|
|
306
313
|
value: s(),
|
|
307
314
|
refetching
|
|
308
315
|
}));
|
|
309
|
-
initP = null;
|
|
310
316
|
if (typeof p !== "object" || !("then" in p)) {
|
|
311
317
|
loadEnd(pr, p);
|
|
312
|
-
return;
|
|
318
|
+
return p;
|
|
313
319
|
}
|
|
314
320
|
pr = p;
|
|
315
321
|
batch(() => {
|
|
316
322
|
setLoading(true);
|
|
317
323
|
trigger();
|
|
318
324
|
});
|
|
319
|
-
p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
|
|
325
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
|
|
320
326
|
}
|
|
321
327
|
Object.defineProperties(read, {
|
|
322
328
|
loading: {
|
|
@@ -460,28 +466,27 @@ function runWithOwner(o, fn) {
|
|
|
460
466
|
function enableScheduling(scheduler = requestCallback) {
|
|
461
467
|
Scheduler = scheduler;
|
|
462
468
|
}
|
|
463
|
-
function startTransition(fn
|
|
469
|
+
function startTransition(fn) {
|
|
464
470
|
if (Transition && Transition.running) {
|
|
465
471
|
fn();
|
|
466
|
-
|
|
467
|
-
return;
|
|
472
|
+
return Transition.done;
|
|
468
473
|
}
|
|
469
|
-
|
|
474
|
+
return Promise.resolve().then(() => {
|
|
475
|
+
let t;
|
|
470
476
|
if (Scheduler || SuspenseContext) {
|
|
471
|
-
Transition || (Transition = {
|
|
477
|
+
t = Transition || (Transition = {
|
|
472
478
|
sources: new Set(),
|
|
473
479
|
effects: [],
|
|
474
480
|
promises: new Set(),
|
|
475
481
|
disposed: new Set(),
|
|
476
482
|
queue: new Set(),
|
|
477
|
-
running: true
|
|
478
|
-
cb: []
|
|
483
|
+
running: true
|
|
479
484
|
});
|
|
480
|
-
|
|
481
|
-
|
|
485
|
+
t.done ||= new Promise(res => t.resolve = res);
|
|
486
|
+
t.running = true;
|
|
482
487
|
}
|
|
483
488
|
batch(fn);
|
|
484
|
-
|
|
489
|
+
return t ? t.done : undefined;
|
|
485
490
|
});
|
|
486
491
|
}
|
|
487
492
|
function useTransition() {
|
|
@@ -661,7 +666,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
661
666
|
});
|
|
662
667
|
const ordinary = ExternalSourceFactory(c.fn, trigger);
|
|
663
668
|
onCleanup(() => ordinary.dispose());
|
|
664
|
-
const triggerInTransition = () => startTransition(trigger
|
|
669
|
+
const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
|
|
665
670
|
const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
|
|
666
671
|
c.fn = x => {
|
|
667
672
|
track();
|
|
@@ -719,7 +724,7 @@ function completeUpdates(wait) {
|
|
|
719
724
|
Updates = null;
|
|
720
725
|
}
|
|
721
726
|
if (wait) return;
|
|
722
|
-
let
|
|
727
|
+
let res;
|
|
723
728
|
if (Transition && Transition.running) {
|
|
724
729
|
if (Transition.promises.size || Transition.queue.size) {
|
|
725
730
|
Transition.running = false;
|
|
@@ -729,7 +734,7 @@ function completeUpdates(wait) {
|
|
|
729
734
|
return;
|
|
730
735
|
}
|
|
731
736
|
const sources = Transition.sources;
|
|
732
|
-
|
|
737
|
+
res = Transition.resolve;
|
|
733
738
|
Effects.forEach(e => {
|
|
734
739
|
"tState" in e && (e.state = e.tState);
|
|
735
740
|
delete e.tState;
|
|
@@ -755,7 +760,7 @@ function completeUpdates(wait) {
|
|
|
755
760
|
});else {
|
|
756
761
|
Effects = null;
|
|
757
762
|
}
|
|
758
|
-
if (
|
|
763
|
+
if (res) res();
|
|
759
764
|
}
|
|
760
765
|
function runQueue(queue) {
|
|
761
766
|
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
|
|
@@ -1215,9 +1220,9 @@ function lazy(fn) {
|
|
|
1215
1220
|
});
|
|
1216
1221
|
comp = s;
|
|
1217
1222
|
} else if (!comp) {
|
|
1218
|
-
const [s] = createResource((
|
|
1219
|
-
|
|
1220
|
-
})
|
|
1223
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
|
|
1224
|
+
globalRefetch: false
|
|
1225
|
+
});
|
|
1221
1226
|
comp = s;
|
|
1222
1227
|
} else {
|
|
1223
1228
|
const c = comp();
|
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.2",
|
|
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": "755131b48e080980ee093f087ecd91945aeb3d31"
|
|
148
148
|
}
|
|
@@ -49,7 +49,8 @@ export interface TransitionState {
|
|
|
49
49
|
queue: Set<Computation<any>>;
|
|
50
50
|
scheduler?: (fn: () => void) => unknown;
|
|
51
51
|
running: boolean;
|
|
52
|
-
|
|
52
|
+
done?: Promise<void>;
|
|
53
|
+
resolve?: () => void;
|
|
53
54
|
}
|
|
54
55
|
declare type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(fn: EffectFunction<Prev, Next>, trigger: () => void) => ExternalSource;
|
|
55
56
|
export interface ExternalSource {
|
|
@@ -197,9 +198,13 @@ export declare type ResourceFetcherInfo<T> = {
|
|
|
197
198
|
export declare type ResourceOptions<T> = T extends undefined ? {
|
|
198
199
|
initialValue?: T;
|
|
199
200
|
name?: string;
|
|
201
|
+
globalRefetch?: boolean;
|
|
202
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
200
203
|
} : {
|
|
201
204
|
initialValue: T;
|
|
202
205
|
name?: string;
|
|
206
|
+
globalRefetch?: boolean;
|
|
207
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
203
208
|
};
|
|
204
209
|
/**
|
|
205
210
|
* Creates a resource that wraps a repeated promise in a reactive pattern:
|
|
@@ -355,12 +360,12 @@ export declare function runWithOwner(o: Owner, fn: () => any): any;
|
|
|
355
360
|
export declare function enableScheduling(scheduler?: typeof requestCallback): void;
|
|
356
361
|
/**
|
|
357
362
|
* ```typescript
|
|
358
|
-
* export function startTransition(fn: () => void
|
|
363
|
+
* export function startTransition(fn: () => void) => Promise<void>
|
|
359
364
|
*
|
|
360
365
|
* @description https://www.solidjs.com/docs/latest/api#usetransition
|
|
361
366
|
*/
|
|
362
|
-
export declare function startTransition(fn: () =>
|
|
363
|
-
export declare type Transition = [Accessor<boolean>, (fn: () => void
|
|
367
|
+
export declare function startTransition(fn: () => unknown): Promise<void>;
|
|
368
|
+
export declare type Transition = [Accessor<boolean>, (fn: () => void) => Promise<void>];
|
|
364
369
|
/**
|
|
365
370
|
* ```typescript
|
|
366
371
|
* export function useTransition(): [
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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";
|
|
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";
|
|
@@ -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 = {
|