solid-js 1.3.15 → 1.4.0-beta.0
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 +26 -25
- package/dist/dev.js +26 -25
- package/dist/server.cjs +9 -9
- package/dist/server.js +10 -9
- package/dist/solid.cjs +26 -25
- package/dist/solid.js +26 -25
- package/package.json +2 -2
- package/store/dist/dev.cjs +31 -28
- package/store/dist/dev.js +32 -29
- package/store/dist/store.cjs +31 -28
- package/store/dist/store.js +32 -29
- package/store/types/store.d.ts +1 -0
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +23 -6
- package/types/reactive/signal.d.ts +3 -4
- package/types/render/component.d.ts +6 -11
- package/types/server/index.d.ts +1 -1
- package/types/server/rendering.d.ts +3 -9
- package/web/dist/dev.cjs +8 -2
- package/web/dist/dev.js +7 -3
- package/web/dist/server.cjs +17 -8
- package/web/dist/server.js +17 -8
- package/web/dist/web.cjs +8 -2
- package/web/dist/web.js +7 -3
- package/web/types/client.d.ts +2 -0
package/dist/dev.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 $TRACK = Symbol("solid-track");
|
|
134
135
|
const $DEVCOMP = Symbol("solid-dev-component");
|
|
135
136
|
const signalOptions = {
|
|
136
137
|
equals: equalFn
|
|
@@ -208,7 +209,7 @@ function createEffect(fn, value, options) {
|
|
|
208
209
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
209
210
|
if (s) c.suspense = s;
|
|
210
211
|
c.user = true;
|
|
211
|
-
Effects ? Effects.push(c) :
|
|
212
|
+
Effects ? Effects.push(c) : updateComputation(c);
|
|
212
213
|
}
|
|
213
214
|
function createReaction(onInvalidate, options) {
|
|
214
215
|
let fn;
|
|
@@ -249,13 +250,8 @@ function createResource(source, fetcher, options) {
|
|
|
249
250
|
source = true;
|
|
250
251
|
}
|
|
251
252
|
options || (options = {});
|
|
252
|
-
if (options.globalRefetch !== false) {
|
|
253
|
-
Resources || (Resources = new Set());
|
|
254
|
-
Resources.add(load);
|
|
255
|
-
Owner && onCleanup(() => Resources.delete(load));
|
|
256
|
-
}
|
|
257
253
|
const contexts = new Set(),
|
|
258
|
-
[
|
|
254
|
+
[value, setValue] = createSignal(options.initialValue),
|
|
259
255
|
[track, trigger] = createSignal(undefined, {
|
|
260
256
|
equals: false
|
|
261
257
|
}),
|
|
@@ -267,7 +263,7 @@ function createResource(source, fetcher, options) {
|
|
|
267
263
|
id = null,
|
|
268
264
|
loadedUnderTransition = false,
|
|
269
265
|
scheduled = false,
|
|
270
|
-
dynamic = typeof source === "function";
|
|
266
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
271
267
|
if (sharedConfig.context) {
|
|
272
268
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
273
269
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
@@ -297,7 +293,7 @@ function createResource(source, fetcher, options) {
|
|
|
297
293
|
}
|
|
298
294
|
function completeLoad(v) {
|
|
299
295
|
batch(() => {
|
|
300
|
-
|
|
296
|
+
setValue(() => v);
|
|
301
297
|
setLoading(false);
|
|
302
298
|
for (const c of contexts.keys()) c.decrement();
|
|
303
299
|
contexts.clear();
|
|
@@ -305,7 +301,7 @@ function createResource(source, fetcher, options) {
|
|
|
305
301
|
}
|
|
306
302
|
function read() {
|
|
307
303
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
308
|
-
v =
|
|
304
|
+
v = value();
|
|
309
305
|
if (err) throw err;
|
|
310
306
|
if (Listener && !Listener.user && c) {
|
|
311
307
|
createComputed(() => {
|
|
@@ -324,15 +320,15 @@ function createResource(source, fetcher, options) {
|
|
|
324
320
|
if (refetching && scheduled) return;
|
|
325
321
|
scheduled = false;
|
|
326
322
|
setError(err = undefined);
|
|
327
|
-
const lookup = dynamic ?
|
|
323
|
+
const lookup = dynamic ? dynamic() : source;
|
|
328
324
|
loadedUnderTransition = Transition && Transition.running;
|
|
329
325
|
if (lookup == null || lookup === false) {
|
|
330
|
-
loadEnd(pr, untrack(
|
|
326
|
+
loadEnd(pr, untrack(value));
|
|
331
327
|
return;
|
|
332
328
|
}
|
|
333
329
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
334
330
|
const p = initP || untrack(() => fetcher(lookup, {
|
|
335
|
-
value:
|
|
331
|
+
value: value(),
|
|
336
332
|
refetching
|
|
337
333
|
}));
|
|
338
334
|
if (typeof p !== "object" || !("then" in p)) {
|
|
@@ -358,18 +354,20 @@ function createResource(source, fetcher, options) {
|
|
|
358
354
|
get() {
|
|
359
355
|
return error();
|
|
360
356
|
}
|
|
357
|
+
},
|
|
358
|
+
latest: {
|
|
359
|
+
get() {
|
|
360
|
+
if (err) throw err;
|
|
361
|
+
return value();
|
|
362
|
+
}
|
|
361
363
|
}
|
|
362
364
|
});
|
|
363
365
|
if (dynamic) createComputed(() => load(false));else load(false);
|
|
364
366
|
return [read, {
|
|
365
367
|
refetch: load,
|
|
366
|
-
mutate:
|
|
368
|
+
mutate: setValue
|
|
367
369
|
}];
|
|
368
370
|
}
|
|
369
|
-
let Resources;
|
|
370
|
-
function refetchResources(info) {
|
|
371
|
-
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
372
|
-
}
|
|
373
371
|
function createDeferred(source, options) {
|
|
374
372
|
let t,
|
|
375
373
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -388,7 +386,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
388
386
|
const subs = new Map();
|
|
389
387
|
const node = createComputation(p => {
|
|
390
388
|
const v = source();
|
|
391
|
-
for (const key of subs.keys()) if (fn(key, v) !==
|
|
389
|
+
for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
|
|
392
390
|
const l = subs.get(key);
|
|
393
391
|
for (const c of l.values()) {
|
|
394
392
|
c.state = STALE;
|
|
@@ -797,11 +795,14 @@ function runUpdates(fn, init) {
|
|
|
797
795
|
if (Effects) wait = true;else Effects = [];
|
|
798
796
|
ExecCount++;
|
|
799
797
|
try {
|
|
800
|
-
|
|
798
|
+
const res = fn();
|
|
799
|
+
completeUpdates(wait);
|
|
800
|
+
return res;
|
|
801
801
|
} catch (err) {
|
|
802
802
|
handleError(err);
|
|
803
803
|
} finally {
|
|
804
|
-
|
|
804
|
+
Updates = null;
|
|
805
|
+
if (!wait) Effects = null;
|
|
805
806
|
}
|
|
806
807
|
}
|
|
807
808
|
function completeUpdates(wait) {
|
|
@@ -1066,6 +1067,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1066
1067
|
let newItems = list() || [],
|
|
1067
1068
|
i,
|
|
1068
1069
|
j;
|
|
1070
|
+
newItems[$TRACK];
|
|
1069
1071
|
return untrack(() => {
|
|
1070
1072
|
let newLen = newItems.length,
|
|
1071
1073
|
newIndices,
|
|
@@ -1167,6 +1169,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1167
1169
|
onCleanup(() => dispose(disposers));
|
|
1168
1170
|
return () => {
|
|
1169
1171
|
const newItems = list() || [];
|
|
1172
|
+
newItems[$TRACK];
|
|
1170
1173
|
return untrack(() => {
|
|
1171
1174
|
if (newItems.length === 0) {
|
|
1172
1175
|
if (len !== 0) {
|
|
@@ -1330,9 +1333,7 @@ function lazy(fn) {
|
|
|
1330
1333
|
});
|
|
1331
1334
|
comp = s;
|
|
1332
1335
|
} else if (!comp) {
|
|
1333
|
-
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default)
|
|
1334
|
-
globalRefetch: false
|
|
1335
|
-
});
|
|
1336
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1336
1337
|
comp = s;
|
|
1337
1338
|
} else {
|
|
1338
1339
|
const c = comp();
|
|
@@ -1601,6 +1602,7 @@ if (globalThis) {
|
|
|
1601
1602
|
|
|
1602
1603
|
exports.$DEVCOMP = $DEVCOMP;
|
|
1603
1604
|
exports.$PROXY = $PROXY;
|
|
1605
|
+
exports.$TRACK = $TRACK;
|
|
1604
1606
|
exports.ErrorBoundary = ErrorBoundary;
|
|
1605
1607
|
exports.For = For;
|
|
1606
1608
|
exports.Index = Index;
|
|
@@ -1641,7 +1643,6 @@ exports.on = on;
|
|
|
1641
1643
|
exports.onCleanup = onCleanup;
|
|
1642
1644
|
exports.onError = onError;
|
|
1643
1645
|
exports.onMount = onMount;
|
|
1644
|
-
exports.refetchResources = refetchResources;
|
|
1645
1646
|
exports.requestCallback = requestCallback;
|
|
1646
1647
|
exports.resetErrorBoundaries = resetErrorBoundaries;
|
|
1647
1648
|
exports.runWithOwner = runWithOwner;
|
package/dist/dev.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 $TRACK = Symbol("solid-track");
|
|
130
131
|
const $DEVCOMP = Symbol("solid-dev-component");
|
|
131
132
|
const signalOptions = {
|
|
132
133
|
equals: equalFn
|
|
@@ -204,7 +205,7 @@ function createEffect(fn, value, options) {
|
|
|
204
205
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
205
206
|
if (s) c.suspense = s;
|
|
206
207
|
c.user = true;
|
|
207
|
-
Effects ? Effects.push(c) :
|
|
208
|
+
Effects ? Effects.push(c) : updateComputation(c);
|
|
208
209
|
}
|
|
209
210
|
function createReaction(onInvalidate, options) {
|
|
210
211
|
let fn;
|
|
@@ -245,13 +246,8 @@ function createResource(source, fetcher, options) {
|
|
|
245
246
|
source = true;
|
|
246
247
|
}
|
|
247
248
|
options || (options = {});
|
|
248
|
-
if (options.globalRefetch !== false) {
|
|
249
|
-
Resources || (Resources = new Set());
|
|
250
|
-
Resources.add(load);
|
|
251
|
-
Owner && onCleanup(() => Resources.delete(load));
|
|
252
|
-
}
|
|
253
249
|
const contexts = new Set(),
|
|
254
|
-
[
|
|
250
|
+
[value, setValue] = createSignal(options.initialValue),
|
|
255
251
|
[track, trigger] = createSignal(undefined, {
|
|
256
252
|
equals: false
|
|
257
253
|
}),
|
|
@@ -263,7 +259,7 @@ function createResource(source, fetcher, options) {
|
|
|
263
259
|
id = null,
|
|
264
260
|
loadedUnderTransition = false,
|
|
265
261
|
scheduled = false,
|
|
266
|
-
dynamic = typeof source === "function";
|
|
262
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
267
263
|
if (sharedConfig.context) {
|
|
268
264
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
269
265
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
@@ -293,7 +289,7 @@ function createResource(source, fetcher, options) {
|
|
|
293
289
|
}
|
|
294
290
|
function completeLoad(v) {
|
|
295
291
|
batch(() => {
|
|
296
|
-
|
|
292
|
+
setValue(() => v);
|
|
297
293
|
setLoading(false);
|
|
298
294
|
for (const c of contexts.keys()) c.decrement();
|
|
299
295
|
contexts.clear();
|
|
@@ -301,7 +297,7 @@ function createResource(source, fetcher, options) {
|
|
|
301
297
|
}
|
|
302
298
|
function read() {
|
|
303
299
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
304
|
-
v =
|
|
300
|
+
v = value();
|
|
305
301
|
if (err) throw err;
|
|
306
302
|
if (Listener && !Listener.user && c) {
|
|
307
303
|
createComputed(() => {
|
|
@@ -320,15 +316,15 @@ function createResource(source, fetcher, options) {
|
|
|
320
316
|
if (refetching && scheduled) return;
|
|
321
317
|
scheduled = false;
|
|
322
318
|
setError(err = undefined);
|
|
323
|
-
const lookup = dynamic ?
|
|
319
|
+
const lookup = dynamic ? dynamic() : source;
|
|
324
320
|
loadedUnderTransition = Transition && Transition.running;
|
|
325
321
|
if (lookup == null || lookup === false) {
|
|
326
|
-
loadEnd(pr, untrack(
|
|
322
|
+
loadEnd(pr, untrack(value));
|
|
327
323
|
return;
|
|
328
324
|
}
|
|
329
325
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
330
326
|
const p = initP || untrack(() => fetcher(lookup, {
|
|
331
|
-
value:
|
|
327
|
+
value: value(),
|
|
332
328
|
refetching
|
|
333
329
|
}));
|
|
334
330
|
if (typeof p !== "object" || !("then" in p)) {
|
|
@@ -354,18 +350,20 @@ function createResource(source, fetcher, options) {
|
|
|
354
350
|
get() {
|
|
355
351
|
return error();
|
|
356
352
|
}
|
|
353
|
+
},
|
|
354
|
+
latest: {
|
|
355
|
+
get() {
|
|
356
|
+
if (err) throw err;
|
|
357
|
+
return value();
|
|
358
|
+
}
|
|
357
359
|
}
|
|
358
360
|
});
|
|
359
361
|
if (dynamic) createComputed(() => load(false));else load(false);
|
|
360
362
|
return [read, {
|
|
361
363
|
refetch: load,
|
|
362
|
-
mutate:
|
|
364
|
+
mutate: setValue
|
|
363
365
|
}];
|
|
364
366
|
}
|
|
365
|
-
let Resources;
|
|
366
|
-
function refetchResources(info) {
|
|
367
|
-
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
368
|
-
}
|
|
369
367
|
function createDeferred(source, options) {
|
|
370
368
|
let t,
|
|
371
369
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -384,7 +382,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
384
382
|
const subs = new Map();
|
|
385
383
|
const node = createComputation(p => {
|
|
386
384
|
const v = source();
|
|
387
|
-
for (const key of subs.keys()) if (fn(key, v) !==
|
|
385
|
+
for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
|
|
388
386
|
const l = subs.get(key);
|
|
389
387
|
for (const c of l.values()) {
|
|
390
388
|
c.state = STALE;
|
|
@@ -793,11 +791,14 @@ function runUpdates(fn, init) {
|
|
|
793
791
|
if (Effects) wait = true;else Effects = [];
|
|
794
792
|
ExecCount++;
|
|
795
793
|
try {
|
|
796
|
-
|
|
794
|
+
const res = fn();
|
|
795
|
+
completeUpdates(wait);
|
|
796
|
+
return res;
|
|
797
797
|
} catch (err) {
|
|
798
798
|
handleError(err);
|
|
799
799
|
} finally {
|
|
800
|
-
|
|
800
|
+
Updates = null;
|
|
801
|
+
if (!wait) Effects = null;
|
|
801
802
|
}
|
|
802
803
|
}
|
|
803
804
|
function completeUpdates(wait) {
|
|
@@ -1062,6 +1063,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1062
1063
|
let newItems = list() || [],
|
|
1063
1064
|
i,
|
|
1064
1065
|
j;
|
|
1066
|
+
newItems[$TRACK];
|
|
1065
1067
|
return untrack(() => {
|
|
1066
1068
|
let newLen = newItems.length,
|
|
1067
1069
|
newIndices,
|
|
@@ -1163,6 +1165,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1163
1165
|
onCleanup(() => dispose(disposers));
|
|
1164
1166
|
return () => {
|
|
1165
1167
|
const newItems = list() || [];
|
|
1168
|
+
newItems[$TRACK];
|
|
1166
1169
|
return untrack(() => {
|
|
1167
1170
|
if (newItems.length === 0) {
|
|
1168
1171
|
if (len !== 0) {
|
|
@@ -1326,9 +1329,7 @@ function lazy(fn) {
|
|
|
1326
1329
|
});
|
|
1327
1330
|
comp = s;
|
|
1328
1331
|
} else if (!comp) {
|
|
1329
|
-
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default)
|
|
1330
|
-
globalRefetch: false
|
|
1331
|
-
});
|
|
1332
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1332
1333
|
comp = s;
|
|
1333
1334
|
} else {
|
|
1334
1335
|
const c = comp();
|
|
@@ -1595,4 +1596,4 @@ if (globalThis) {
|
|
|
1595
1596
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1596
1597
|
}
|
|
1597
1598
|
|
|
1598
|
-
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,
|
|
1599
|
+
export { $DEVCOMP, $PROXY, $TRACK, 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, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
package/dist/server.cjs
CHANGED
|
@@ -221,7 +221,11 @@ function resolveSSRNode(node) {
|
|
|
221
221
|
const t = typeof node;
|
|
222
222
|
if (t === "string") return node;
|
|
223
223
|
if (node == null || t === "boolean") return "";
|
|
224
|
-
if (Array.isArray(node))
|
|
224
|
+
if (Array.isArray(node)) {
|
|
225
|
+
let mapped = "";
|
|
226
|
+
for (let i = 0, len = node.length; i < len; i++) mapped += resolveSSRNode(node[i]);
|
|
227
|
+
return mapped;
|
|
228
|
+
}
|
|
225
229
|
if (t === "object") return resolveSSRNode(node.t);
|
|
226
230
|
if (t === "function") return resolveSSRNode(node());
|
|
227
231
|
return String(node);
|
|
@@ -279,13 +283,11 @@ function simpleMap(props, wrap) {
|
|
|
279
283
|
len = list.length,
|
|
280
284
|
fn = props.children;
|
|
281
285
|
if (len) {
|
|
282
|
-
let mapped =
|
|
283
|
-
for (let i = 0; i < len; i++) mapped
|
|
284
|
-
return
|
|
285
|
-
t: mapped
|
|
286
|
-
};
|
|
286
|
+
let mapped = Array(len);
|
|
287
|
+
for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
|
|
288
|
+
return mapped;
|
|
287
289
|
}
|
|
288
|
-
return props.fallback
|
|
290
|
+
return props.fallback;
|
|
289
291
|
}
|
|
290
292
|
function For(props) {
|
|
291
293
|
return simpleMap(props, (fn, item, i) => fn(item, () => i));
|
|
@@ -417,7 +419,6 @@ function createResource(source, fetcher, options = {}) {
|
|
|
417
419
|
mutate: v => value = v
|
|
418
420
|
}];
|
|
419
421
|
}
|
|
420
|
-
function refetchResources(info) {}
|
|
421
422
|
function lazy(fn) {
|
|
422
423
|
let resolved;
|
|
423
424
|
const p = fn();
|
|
@@ -565,7 +566,6 @@ exports.on = on;
|
|
|
565
566
|
exports.onCleanup = onCleanup;
|
|
566
567
|
exports.onError = onError;
|
|
567
568
|
exports.onMount = onMount;
|
|
568
|
-
exports.refetchResources = refetchResources;
|
|
569
569
|
exports.requestCallback = requestCallback;
|
|
570
570
|
exports.resetErrorBoundaries = resetErrorBoundaries;
|
|
571
571
|
exports.runWithOwner = runWithOwner;
|
package/dist/server.js
CHANGED
|
@@ -217,7 +217,11 @@ function resolveSSRNode(node) {
|
|
|
217
217
|
const t = typeof node;
|
|
218
218
|
if (t === "string") return node;
|
|
219
219
|
if (node == null || t === "boolean") return "";
|
|
220
|
-
if (Array.isArray(node))
|
|
220
|
+
if (Array.isArray(node)) {
|
|
221
|
+
let mapped = "";
|
|
222
|
+
for (let i = 0, len = node.length; i < len; i++) mapped += resolveSSRNode(node[i]);
|
|
223
|
+
return mapped;
|
|
224
|
+
}
|
|
221
225
|
if (t === "object") return resolveSSRNode(node.t);
|
|
222
226
|
if (t === "function") return resolveSSRNode(node());
|
|
223
227
|
return String(node);
|
|
@@ -275,13 +279,11 @@ function simpleMap(props, wrap) {
|
|
|
275
279
|
len = list.length,
|
|
276
280
|
fn = props.children;
|
|
277
281
|
if (len) {
|
|
278
|
-
let mapped =
|
|
279
|
-
for (let i = 0; i < len; i++) mapped
|
|
280
|
-
return
|
|
281
|
-
t: mapped
|
|
282
|
-
};
|
|
282
|
+
let mapped = Array(len);
|
|
283
|
+
for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
|
|
284
|
+
return mapped;
|
|
283
285
|
}
|
|
284
|
-
return props.fallback
|
|
286
|
+
return props.fallback;
|
|
285
287
|
}
|
|
286
288
|
function For(props) {
|
|
287
289
|
return simpleMap(props, (fn, item, i) => fn(item, () => i));
|
|
@@ -413,7 +415,6 @@ function createResource(source, fetcher, options = {}) {
|
|
|
413
415
|
mutate: v => value = v
|
|
414
416
|
}];
|
|
415
417
|
}
|
|
416
|
-
function refetchResources(info) {}
|
|
417
418
|
function lazy(fn) {
|
|
418
419
|
let resolved;
|
|
419
420
|
const p = fn();
|
|
@@ -520,4 +521,4 @@ function Suspense(props) {
|
|
|
520
521
|
return props.fallback;
|
|
521
522
|
}
|
|
522
523
|
|
|
523
|
-
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount,
|
|
524
|
+
export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|
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 $TRACK = Symbol("solid-track");
|
|
134
135
|
const $DEVCOMP = Symbol("solid-dev-component");
|
|
135
136
|
const signalOptions = {
|
|
136
137
|
equals: equalFn
|
|
@@ -205,7 +206,7 @@ function createEffect(fn, value, options) {
|
|
|
205
206
|
s = SuspenseContext && lookup(Owner, SuspenseContext.id);
|
|
206
207
|
if (s) c.suspense = s;
|
|
207
208
|
c.user = true;
|
|
208
|
-
Effects ? Effects.push(c) :
|
|
209
|
+
Effects ? Effects.push(c) : updateComputation(c);
|
|
209
210
|
}
|
|
210
211
|
function createReaction(onInvalidate, options) {
|
|
211
212
|
let fn;
|
|
@@ -246,13 +247,8 @@ function createResource(source, fetcher, options) {
|
|
|
246
247
|
source = true;
|
|
247
248
|
}
|
|
248
249
|
options || (options = {});
|
|
249
|
-
if (options.globalRefetch !== false) {
|
|
250
|
-
Resources || (Resources = new Set());
|
|
251
|
-
Resources.add(load);
|
|
252
|
-
Owner && onCleanup(() => Resources.delete(load));
|
|
253
|
-
}
|
|
254
250
|
const contexts = new Set(),
|
|
255
|
-
[
|
|
251
|
+
[value, setValue] = createSignal(options.initialValue),
|
|
256
252
|
[track, trigger] = createSignal(undefined, {
|
|
257
253
|
equals: false
|
|
258
254
|
}),
|
|
@@ -264,7 +260,7 @@ function createResource(source, fetcher, options) {
|
|
|
264
260
|
id = null,
|
|
265
261
|
loadedUnderTransition = false,
|
|
266
262
|
scheduled = false,
|
|
267
|
-
dynamic = typeof source === "function";
|
|
263
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
268
264
|
if (sharedConfig.context) {
|
|
269
265
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
270
266
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
@@ -294,7 +290,7 @@ function createResource(source, fetcher, options) {
|
|
|
294
290
|
}
|
|
295
291
|
function completeLoad(v) {
|
|
296
292
|
batch(() => {
|
|
297
|
-
|
|
293
|
+
setValue(() => v);
|
|
298
294
|
setLoading(false);
|
|
299
295
|
for (const c of contexts.keys()) c.decrement();
|
|
300
296
|
contexts.clear();
|
|
@@ -302,7 +298,7 @@ function createResource(source, fetcher, options) {
|
|
|
302
298
|
}
|
|
303
299
|
function read() {
|
|
304
300
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
305
|
-
v =
|
|
301
|
+
v = value();
|
|
306
302
|
if (err) throw err;
|
|
307
303
|
if (Listener && !Listener.user && c) {
|
|
308
304
|
createComputed(() => {
|
|
@@ -321,15 +317,15 @@ function createResource(source, fetcher, options) {
|
|
|
321
317
|
if (refetching && scheduled) return;
|
|
322
318
|
scheduled = false;
|
|
323
319
|
setError(err = undefined);
|
|
324
|
-
const lookup = dynamic ?
|
|
320
|
+
const lookup = dynamic ? dynamic() : source;
|
|
325
321
|
loadedUnderTransition = Transition && Transition.running;
|
|
326
322
|
if (lookup == null || lookup === false) {
|
|
327
|
-
loadEnd(pr, untrack(
|
|
323
|
+
loadEnd(pr, untrack(value));
|
|
328
324
|
return;
|
|
329
325
|
}
|
|
330
326
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
331
327
|
const p = initP || untrack(() => fetcher(lookup, {
|
|
332
|
-
value:
|
|
328
|
+
value: value(),
|
|
333
329
|
refetching
|
|
334
330
|
}));
|
|
335
331
|
if (typeof p !== "object" || !("then" in p)) {
|
|
@@ -355,18 +351,20 @@ function createResource(source, fetcher, options) {
|
|
|
355
351
|
get() {
|
|
356
352
|
return error();
|
|
357
353
|
}
|
|
354
|
+
},
|
|
355
|
+
latest: {
|
|
356
|
+
get() {
|
|
357
|
+
if (err) throw err;
|
|
358
|
+
return value();
|
|
359
|
+
}
|
|
358
360
|
}
|
|
359
361
|
});
|
|
360
362
|
if (dynamic) createComputed(() => load(false));else load(false);
|
|
361
363
|
return [read, {
|
|
362
364
|
refetch: load,
|
|
363
|
-
mutate:
|
|
365
|
+
mutate: setValue
|
|
364
366
|
}];
|
|
365
367
|
}
|
|
366
|
-
let Resources;
|
|
367
|
-
function refetchResources(info) {
|
|
368
|
-
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
369
|
-
}
|
|
370
368
|
function createDeferred(source, options) {
|
|
371
369
|
let t,
|
|
372
370
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -385,7 +383,7 @@ function createSelector(source, fn = equalFn, options) {
|
|
|
385
383
|
const subs = new Map();
|
|
386
384
|
const node = createComputation(p => {
|
|
387
385
|
const v = source();
|
|
388
|
-
for (const key of subs.keys()) if (fn(key, v) !==
|
|
386
|
+
for (const key of subs.keys()) if (fn(key, v) !== fn(key, p)) {
|
|
389
387
|
const l = subs.get(key);
|
|
390
388
|
for (const c of l.values()) {
|
|
391
389
|
c.state = STALE;
|
|
@@ -740,11 +738,14 @@ function runUpdates(fn, init) {
|
|
|
740
738
|
if (Effects) wait = true;else Effects = [];
|
|
741
739
|
ExecCount++;
|
|
742
740
|
try {
|
|
743
|
-
|
|
741
|
+
const res = fn();
|
|
742
|
+
completeUpdates(wait);
|
|
743
|
+
return res;
|
|
744
744
|
} catch (err) {
|
|
745
745
|
handleError(err);
|
|
746
746
|
} finally {
|
|
747
|
-
|
|
747
|
+
Updates = null;
|
|
748
|
+
if (!wait) Effects = null;
|
|
748
749
|
}
|
|
749
750
|
}
|
|
750
751
|
function completeUpdates(wait) {
|
|
@@ -985,6 +986,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
985
986
|
let newItems = list() || [],
|
|
986
987
|
i,
|
|
987
988
|
j;
|
|
989
|
+
newItems[$TRACK];
|
|
988
990
|
return untrack(() => {
|
|
989
991
|
let newLen = newItems.length,
|
|
990
992
|
newIndices,
|
|
@@ -1086,6 +1088,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1086
1088
|
onCleanup(() => dispose(disposers));
|
|
1087
1089
|
return () => {
|
|
1088
1090
|
const newItems = list() || [];
|
|
1091
|
+
newItems[$TRACK];
|
|
1089
1092
|
return untrack(() => {
|
|
1090
1093
|
if (newItems.length === 0) {
|
|
1091
1094
|
if (len !== 0) {
|
|
@@ -1249,9 +1252,7 @@ function lazy(fn) {
|
|
|
1249
1252
|
});
|
|
1250
1253
|
comp = s;
|
|
1251
1254
|
} else if (!comp) {
|
|
1252
|
-
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default)
|
|
1253
|
-
globalRefetch: false
|
|
1254
|
-
});
|
|
1255
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1255
1256
|
comp = s;
|
|
1256
1257
|
} else {
|
|
1257
1258
|
const c = comp();
|
|
@@ -1505,6 +1506,7 @@ let DEV;
|
|
|
1505
1506
|
|
|
1506
1507
|
exports.$DEVCOMP = $DEVCOMP;
|
|
1507
1508
|
exports.$PROXY = $PROXY;
|
|
1509
|
+
exports.$TRACK = $TRACK;
|
|
1508
1510
|
exports.DEV = DEV;
|
|
1509
1511
|
exports.ErrorBoundary = ErrorBoundary;
|
|
1510
1512
|
exports.For = For;
|
|
@@ -1546,7 +1548,6 @@ exports.on = on;
|
|
|
1546
1548
|
exports.onCleanup = onCleanup;
|
|
1547
1549
|
exports.onError = onError;
|
|
1548
1550
|
exports.onMount = onMount;
|
|
1549
|
-
exports.refetchResources = refetchResources;
|
|
1550
1551
|
exports.requestCallback = requestCallback;
|
|
1551
1552
|
exports.resetErrorBoundaries = resetErrorBoundaries;
|
|
1552
1553
|
exports.runWithOwner = runWithOwner;
|