solid-js 1.3.16 → 1.4.0-beta.1
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 +30 -25
- package/dist/dev.js +30 -25
- package/dist/server.cjs +15 -9
- package/dist/server.js +16 -9
- package/dist/solid.cjs +30 -25
- package/dist/solid.js +30 -25
- package/package.json +2 -2
- package/store/dist/dev.cjs +63 -28
- package/store/dist/dev.js +63 -30
- package/store/dist/store.cjs +63 -28
- package/store/dist/store.js +63 -30
- package/store/types/modifiers.d.ts +1 -0
- package/store/types/mutable.d.ts +1 -0
- package/store/types/store.d.ts +1 -0
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +19 -6
- package/types/reactive/signal.d.ts +12 -13
- package/types/render/component.d.ts +62 -14
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -1
- package/types/server/rendering.d.ts +26 -18
- package/web/dist/dev.cjs +5 -1
- package/web/dist/dev.js +5 -2
- package/web/dist/server.cjs +11 -6
- package/web/dist/server.js +11 -6
- package/web/dist/web.cjs +5 -1
- package/web/dist/web.js +5 -2
- package/web/types/client.d.ts +1 -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,8 @@ function createResource(source, fetcher, options) {
|
|
|
267
263
|
id = null,
|
|
268
264
|
loadedUnderTransition = false,
|
|
269
265
|
scheduled = false,
|
|
270
|
-
|
|
266
|
+
resolved = ("initialValue" in options),
|
|
267
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
271
268
|
if (sharedConfig.context) {
|
|
272
269
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
273
270
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
@@ -275,6 +272,7 @@ function createResource(source, fetcher, options) {
|
|
|
275
272
|
function loadEnd(p, v, e, key) {
|
|
276
273
|
if (pr === p) {
|
|
277
274
|
pr = null;
|
|
275
|
+
resolved = true;
|
|
278
276
|
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
279
277
|
value: v
|
|
280
278
|
});
|
|
@@ -297,7 +295,7 @@ function createResource(source, fetcher, options) {
|
|
|
297
295
|
}
|
|
298
296
|
function completeLoad(v) {
|
|
299
297
|
batch(() => {
|
|
300
|
-
|
|
298
|
+
setValue(() => v);
|
|
301
299
|
setLoading(false);
|
|
302
300
|
for (const c of contexts.keys()) c.decrement();
|
|
303
301
|
contexts.clear();
|
|
@@ -305,7 +303,7 @@ function createResource(source, fetcher, options) {
|
|
|
305
303
|
}
|
|
306
304
|
function read() {
|
|
307
305
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
308
|
-
v =
|
|
306
|
+
v = value();
|
|
309
307
|
if (err) throw err;
|
|
310
308
|
if (Listener && !Listener.user && c) {
|
|
311
309
|
createComputed(() => {
|
|
@@ -324,15 +322,15 @@ function createResource(source, fetcher, options) {
|
|
|
324
322
|
if (refetching && scheduled) return;
|
|
325
323
|
scheduled = false;
|
|
326
324
|
setError(err = undefined);
|
|
327
|
-
const lookup = dynamic ?
|
|
325
|
+
const lookup = dynamic ? dynamic() : source;
|
|
328
326
|
loadedUnderTransition = Transition && Transition.running;
|
|
329
327
|
if (lookup == null || lookup === false) {
|
|
330
|
-
loadEnd(pr, untrack(
|
|
328
|
+
loadEnd(pr, untrack(value));
|
|
331
329
|
return;
|
|
332
330
|
}
|
|
333
331
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
334
332
|
const p = initP || untrack(() => fetcher(lookup, {
|
|
335
|
-
value:
|
|
333
|
+
value: value(),
|
|
336
334
|
refetching
|
|
337
335
|
}));
|
|
338
336
|
if (typeof p !== "object" || !("then" in p)) {
|
|
@@ -358,18 +356,21 @@ function createResource(source, fetcher, options) {
|
|
|
358
356
|
get() {
|
|
359
357
|
return error();
|
|
360
358
|
}
|
|
359
|
+
},
|
|
360
|
+
latest: {
|
|
361
|
+
get() {
|
|
362
|
+
if (!resolved) return read();
|
|
363
|
+
if (err) throw err;
|
|
364
|
+
return value();
|
|
365
|
+
}
|
|
361
366
|
}
|
|
362
367
|
});
|
|
363
368
|
if (dynamic) createComputed(() => load(false));else load(false);
|
|
364
369
|
return [read, {
|
|
365
370
|
refetch: load,
|
|
366
|
-
mutate:
|
|
371
|
+
mutate: setValue
|
|
367
372
|
}];
|
|
368
373
|
}
|
|
369
|
-
let Resources;
|
|
370
|
-
function refetchResources(info) {
|
|
371
|
-
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
372
|
-
}
|
|
373
374
|
function createDeferred(source, options) {
|
|
374
375
|
let t,
|
|
375
376
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -797,11 +798,14 @@ function runUpdates(fn, init) {
|
|
|
797
798
|
if (Effects) wait = true;else Effects = [];
|
|
798
799
|
ExecCount++;
|
|
799
800
|
try {
|
|
800
|
-
|
|
801
|
+
const res = fn();
|
|
802
|
+
completeUpdates(wait);
|
|
803
|
+
return res;
|
|
801
804
|
} catch (err) {
|
|
802
805
|
handleError(err);
|
|
803
806
|
} finally {
|
|
804
|
-
|
|
807
|
+
Updates = null;
|
|
808
|
+
if (!wait) Effects = null;
|
|
805
809
|
}
|
|
806
810
|
}
|
|
807
811
|
function completeUpdates(wait) {
|
|
@@ -1066,6 +1070,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1066
1070
|
let newItems = list() || [],
|
|
1067
1071
|
i,
|
|
1068
1072
|
j;
|
|
1073
|
+
newItems[$TRACK];
|
|
1069
1074
|
return untrack(() => {
|
|
1070
1075
|
let newLen = newItems.length,
|
|
1071
1076
|
newIndices,
|
|
@@ -1167,6 +1172,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1167
1172
|
onCleanup(() => dispose(disposers));
|
|
1168
1173
|
return () => {
|
|
1169
1174
|
const newItems = list() || [];
|
|
1175
|
+
newItems[$TRACK];
|
|
1170
1176
|
return untrack(() => {
|
|
1171
1177
|
if (newItems.length === 0) {
|
|
1172
1178
|
if (len !== 0) {
|
|
@@ -1222,6 +1228,7 @@ function enableHydration() {
|
|
|
1222
1228
|
hydrationEnabled = true;
|
|
1223
1229
|
}
|
|
1224
1230
|
function createComponent(Comp, props) {
|
|
1231
|
+
if (props == null || typeof props !== "object") props = {};
|
|
1225
1232
|
if (hydrationEnabled) {
|
|
1226
1233
|
if (sharedConfig.context) {
|
|
1227
1234
|
const c = sharedConfig.context;
|
|
@@ -1262,7 +1269,7 @@ const propTraps = {
|
|
|
1262
1269
|
}
|
|
1263
1270
|
};
|
|
1264
1271
|
function resolveSource(s) {
|
|
1265
|
-
return typeof s === "function" ? s() : s;
|
|
1272
|
+
return (s = typeof s === "function" ? s() : s) == null || typeof s !== "object" ? {} : s;
|
|
1266
1273
|
}
|
|
1267
1274
|
function mergeProps(...sources) {
|
|
1268
1275
|
return new Proxy({
|
|
@@ -1330,9 +1337,7 @@ function lazy(fn) {
|
|
|
1330
1337
|
});
|
|
1331
1338
|
comp = s;
|
|
1332
1339
|
} else if (!comp) {
|
|
1333
|
-
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default)
|
|
1334
|
-
globalRefetch: false
|
|
1335
|
-
});
|
|
1340
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1336
1341
|
comp = s;
|
|
1337
1342
|
} else {
|
|
1338
1343
|
const c = comp();
|
|
@@ -1601,6 +1606,7 @@ if (globalThis) {
|
|
|
1601
1606
|
|
|
1602
1607
|
exports.$DEVCOMP = $DEVCOMP;
|
|
1603
1608
|
exports.$PROXY = $PROXY;
|
|
1609
|
+
exports.$TRACK = $TRACK;
|
|
1604
1610
|
exports.ErrorBoundary = ErrorBoundary;
|
|
1605
1611
|
exports.For = For;
|
|
1606
1612
|
exports.Index = Index;
|
|
@@ -1641,7 +1647,6 @@ exports.on = on;
|
|
|
1641
1647
|
exports.onCleanup = onCleanup;
|
|
1642
1648
|
exports.onError = onError;
|
|
1643
1649
|
exports.onMount = onMount;
|
|
1644
|
-
exports.refetchResources = refetchResources;
|
|
1645
1650
|
exports.requestCallback = requestCallback;
|
|
1646
1651
|
exports.resetErrorBoundaries = resetErrorBoundaries;
|
|
1647
1652
|
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,8 @@ function createResource(source, fetcher, options) {
|
|
|
263
259
|
id = null,
|
|
264
260
|
loadedUnderTransition = false,
|
|
265
261
|
scheduled = false,
|
|
266
|
-
|
|
262
|
+
resolved = ("initialValue" in options),
|
|
263
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
267
264
|
if (sharedConfig.context) {
|
|
268
265
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
269
266
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
@@ -271,6 +268,7 @@ function createResource(source, fetcher, options) {
|
|
|
271
268
|
function loadEnd(p, v, e, key) {
|
|
272
269
|
if (pr === p) {
|
|
273
270
|
pr = null;
|
|
271
|
+
resolved = true;
|
|
274
272
|
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
275
273
|
value: v
|
|
276
274
|
});
|
|
@@ -293,7 +291,7 @@ function createResource(source, fetcher, options) {
|
|
|
293
291
|
}
|
|
294
292
|
function completeLoad(v) {
|
|
295
293
|
batch(() => {
|
|
296
|
-
|
|
294
|
+
setValue(() => v);
|
|
297
295
|
setLoading(false);
|
|
298
296
|
for (const c of contexts.keys()) c.decrement();
|
|
299
297
|
contexts.clear();
|
|
@@ -301,7 +299,7 @@ function createResource(source, fetcher, options) {
|
|
|
301
299
|
}
|
|
302
300
|
function read() {
|
|
303
301
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
304
|
-
v =
|
|
302
|
+
v = value();
|
|
305
303
|
if (err) throw err;
|
|
306
304
|
if (Listener && !Listener.user && c) {
|
|
307
305
|
createComputed(() => {
|
|
@@ -320,15 +318,15 @@ function createResource(source, fetcher, options) {
|
|
|
320
318
|
if (refetching && scheduled) return;
|
|
321
319
|
scheduled = false;
|
|
322
320
|
setError(err = undefined);
|
|
323
|
-
const lookup = dynamic ?
|
|
321
|
+
const lookup = dynamic ? dynamic() : source;
|
|
324
322
|
loadedUnderTransition = Transition && Transition.running;
|
|
325
323
|
if (lookup == null || lookup === false) {
|
|
326
|
-
loadEnd(pr, untrack(
|
|
324
|
+
loadEnd(pr, untrack(value));
|
|
327
325
|
return;
|
|
328
326
|
}
|
|
329
327
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
330
328
|
const p = initP || untrack(() => fetcher(lookup, {
|
|
331
|
-
value:
|
|
329
|
+
value: value(),
|
|
332
330
|
refetching
|
|
333
331
|
}));
|
|
334
332
|
if (typeof p !== "object" || !("then" in p)) {
|
|
@@ -354,18 +352,21 @@ function createResource(source, fetcher, options) {
|
|
|
354
352
|
get() {
|
|
355
353
|
return error();
|
|
356
354
|
}
|
|
355
|
+
},
|
|
356
|
+
latest: {
|
|
357
|
+
get() {
|
|
358
|
+
if (!resolved) return read();
|
|
359
|
+
if (err) throw err;
|
|
360
|
+
return value();
|
|
361
|
+
}
|
|
357
362
|
}
|
|
358
363
|
});
|
|
359
364
|
if (dynamic) createComputed(() => load(false));else load(false);
|
|
360
365
|
return [read, {
|
|
361
366
|
refetch: load,
|
|
362
|
-
mutate:
|
|
367
|
+
mutate: setValue
|
|
363
368
|
}];
|
|
364
369
|
}
|
|
365
|
-
let Resources;
|
|
366
|
-
function refetchResources(info) {
|
|
367
|
-
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
368
|
-
}
|
|
369
370
|
function createDeferred(source, options) {
|
|
370
371
|
let t,
|
|
371
372
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -793,11 +794,14 @@ function runUpdates(fn, init) {
|
|
|
793
794
|
if (Effects) wait = true;else Effects = [];
|
|
794
795
|
ExecCount++;
|
|
795
796
|
try {
|
|
796
|
-
|
|
797
|
+
const res = fn();
|
|
798
|
+
completeUpdates(wait);
|
|
799
|
+
return res;
|
|
797
800
|
} catch (err) {
|
|
798
801
|
handleError(err);
|
|
799
802
|
} finally {
|
|
800
|
-
|
|
803
|
+
Updates = null;
|
|
804
|
+
if (!wait) Effects = null;
|
|
801
805
|
}
|
|
802
806
|
}
|
|
803
807
|
function completeUpdates(wait) {
|
|
@@ -1062,6 +1066,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1062
1066
|
let newItems = list() || [],
|
|
1063
1067
|
i,
|
|
1064
1068
|
j;
|
|
1069
|
+
newItems[$TRACK];
|
|
1065
1070
|
return untrack(() => {
|
|
1066
1071
|
let newLen = newItems.length,
|
|
1067
1072
|
newIndices,
|
|
@@ -1163,6 +1168,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1163
1168
|
onCleanup(() => dispose(disposers));
|
|
1164
1169
|
return () => {
|
|
1165
1170
|
const newItems = list() || [];
|
|
1171
|
+
newItems[$TRACK];
|
|
1166
1172
|
return untrack(() => {
|
|
1167
1173
|
if (newItems.length === 0) {
|
|
1168
1174
|
if (len !== 0) {
|
|
@@ -1218,6 +1224,7 @@ function enableHydration() {
|
|
|
1218
1224
|
hydrationEnabled = true;
|
|
1219
1225
|
}
|
|
1220
1226
|
function createComponent(Comp, props) {
|
|
1227
|
+
if (props == null || typeof props !== "object") props = {};
|
|
1221
1228
|
if (hydrationEnabled) {
|
|
1222
1229
|
if (sharedConfig.context) {
|
|
1223
1230
|
const c = sharedConfig.context;
|
|
@@ -1258,7 +1265,7 @@ const propTraps = {
|
|
|
1258
1265
|
}
|
|
1259
1266
|
};
|
|
1260
1267
|
function resolveSource(s) {
|
|
1261
|
-
return typeof s === "function" ? s() : s;
|
|
1268
|
+
return (s = typeof s === "function" ? s() : s) == null || typeof s !== "object" ? {} : s;
|
|
1262
1269
|
}
|
|
1263
1270
|
function mergeProps(...sources) {
|
|
1264
1271
|
return new Proxy({
|
|
@@ -1326,9 +1333,7 @@ function lazy(fn) {
|
|
|
1326
1333
|
});
|
|
1327
1334
|
comp = s;
|
|
1328
1335
|
} else if (!comp) {
|
|
1329
|
-
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default)
|
|
1330
|
-
globalRefetch: false
|
|
1331
|
-
});
|
|
1336
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1332
1337
|
comp = s;
|
|
1333
1338
|
} else {
|
|
1334
1339
|
const c = comp();
|
|
@@ -1595,4 +1600,4 @@ if (globalThis) {
|
|
|
1595
1600
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1596
1601
|
}
|
|
1597
1602
|
|
|
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,
|
|
1603
|
+
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);
|
|
@@ -242,6 +246,7 @@ function createUniqueId() {
|
|
|
242
246
|
return `${ctx.id}${ctx.count++}`;
|
|
243
247
|
}
|
|
244
248
|
function createComponent(Comp, props) {
|
|
249
|
+
if (props == null || typeof props !== "object") props = {};
|
|
245
250
|
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
246
251
|
const c = sharedConfig.context;
|
|
247
252
|
setHydrateContext(nextHydrateContext());
|
|
@@ -279,13 +284,11 @@ function simpleMap(props, wrap) {
|
|
|
279
284
|
len = list.length,
|
|
280
285
|
fn = props.children;
|
|
281
286
|
if (len) {
|
|
282
|
-
let mapped =
|
|
283
|
-
for (let i = 0; i < len; i++) mapped
|
|
284
|
-
return
|
|
285
|
-
t: mapped
|
|
286
|
-
};
|
|
287
|
+
let mapped = Array(len);
|
|
288
|
+
for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
|
|
289
|
+
return mapped;
|
|
287
290
|
}
|
|
288
|
-
return props.fallback
|
|
291
|
+
return props.fallback;
|
|
289
292
|
}
|
|
290
293
|
function For(props) {
|
|
291
294
|
return simpleMap(props, (fn, item, i) => fn(item, () => i));
|
|
@@ -370,6 +373,11 @@ function createResource(source, fetcher, options = {}) {
|
|
|
370
373
|
};
|
|
371
374
|
read.loading = false;
|
|
372
375
|
read.error = undefined;
|
|
376
|
+
Object.defineProperty(read, "latest", {
|
|
377
|
+
get() {
|
|
378
|
+
return read();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
373
381
|
function load() {
|
|
374
382
|
const ctx = sharedConfig.context;
|
|
375
383
|
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
@@ -417,7 +425,6 @@ function createResource(source, fetcher, options = {}) {
|
|
|
417
425
|
mutate: v => value = v
|
|
418
426
|
}];
|
|
419
427
|
}
|
|
420
|
-
function refetchResources(info) {}
|
|
421
428
|
function lazy(fn) {
|
|
422
429
|
let resolved;
|
|
423
430
|
const p = fn();
|
|
@@ -565,7 +572,6 @@ exports.on = on;
|
|
|
565
572
|
exports.onCleanup = onCleanup;
|
|
566
573
|
exports.onError = onError;
|
|
567
574
|
exports.onMount = onMount;
|
|
568
|
-
exports.refetchResources = refetchResources;
|
|
569
575
|
exports.requestCallback = requestCallback;
|
|
570
576
|
exports.resetErrorBoundaries = resetErrorBoundaries;
|
|
571
577
|
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);
|
|
@@ -238,6 +242,7 @@ function createUniqueId() {
|
|
|
238
242
|
return `${ctx.id}${ctx.count++}`;
|
|
239
243
|
}
|
|
240
244
|
function createComponent(Comp, props) {
|
|
245
|
+
if (props == null || typeof props !== "object") props = {};
|
|
241
246
|
if (sharedConfig.context && !sharedConfig.context.noHydrate) {
|
|
242
247
|
const c = sharedConfig.context;
|
|
243
248
|
setHydrateContext(nextHydrateContext());
|
|
@@ -275,13 +280,11 @@ function simpleMap(props, wrap) {
|
|
|
275
280
|
len = list.length,
|
|
276
281
|
fn = props.children;
|
|
277
282
|
if (len) {
|
|
278
|
-
let mapped =
|
|
279
|
-
for (let i = 0; i < len; i++) mapped
|
|
280
|
-
return
|
|
281
|
-
t: mapped
|
|
282
|
-
};
|
|
283
|
+
let mapped = Array(len);
|
|
284
|
+
for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
|
|
285
|
+
return mapped;
|
|
283
286
|
}
|
|
284
|
-
return props.fallback
|
|
287
|
+
return props.fallback;
|
|
285
288
|
}
|
|
286
289
|
function For(props) {
|
|
287
290
|
return simpleMap(props, (fn, item, i) => fn(item, () => i));
|
|
@@ -366,6 +369,11 @@ function createResource(source, fetcher, options = {}) {
|
|
|
366
369
|
};
|
|
367
370
|
read.loading = false;
|
|
368
371
|
read.error = undefined;
|
|
372
|
+
Object.defineProperty(read, "latest", {
|
|
373
|
+
get() {
|
|
374
|
+
return read();
|
|
375
|
+
}
|
|
376
|
+
});
|
|
369
377
|
function load() {
|
|
370
378
|
const ctx = sharedConfig.context;
|
|
371
379
|
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
@@ -413,7 +421,6 @@ function createResource(source, fetcher, options = {}) {
|
|
|
413
421
|
mutate: v => value = v
|
|
414
422
|
}];
|
|
415
423
|
}
|
|
416
|
-
function refetchResources(info) {}
|
|
417
424
|
function lazy(fn) {
|
|
418
425
|
let resolved;
|
|
419
426
|
const p = fn();
|
|
@@ -520,4 +527,4 @@ function Suspense(props) {
|
|
|
520
527
|
return props.fallback;
|
|
521
528
|
}
|
|
522
529
|
|
|
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,
|
|
530
|
+
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,8 @@ function createResource(source, fetcher, options) {
|
|
|
264
260
|
id = null,
|
|
265
261
|
loadedUnderTransition = false,
|
|
266
262
|
scheduled = false,
|
|
267
|
-
|
|
263
|
+
resolved = ("initialValue" in options),
|
|
264
|
+
dynamic = typeof source === "function" && createMemo(source);
|
|
268
265
|
if (sharedConfig.context) {
|
|
269
266
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
270
267
|
if (sharedConfig.load) initP = sharedConfig.load(id);
|
|
@@ -272,6 +269,7 @@ function createResource(source, fetcher, options) {
|
|
|
272
269
|
function loadEnd(p, v, e, key) {
|
|
273
270
|
if (pr === p) {
|
|
274
271
|
pr = null;
|
|
272
|
+
resolved = true;
|
|
275
273
|
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
|
|
276
274
|
value: v
|
|
277
275
|
});
|
|
@@ -294,7 +292,7 @@ function createResource(source, fetcher, options) {
|
|
|
294
292
|
}
|
|
295
293
|
function completeLoad(v) {
|
|
296
294
|
batch(() => {
|
|
297
|
-
|
|
295
|
+
setValue(() => v);
|
|
298
296
|
setLoading(false);
|
|
299
297
|
for (const c of contexts.keys()) c.decrement();
|
|
300
298
|
contexts.clear();
|
|
@@ -302,7 +300,7 @@ function createResource(source, fetcher, options) {
|
|
|
302
300
|
}
|
|
303
301
|
function read() {
|
|
304
302
|
const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
|
|
305
|
-
v =
|
|
303
|
+
v = value();
|
|
306
304
|
if (err) throw err;
|
|
307
305
|
if (Listener && !Listener.user && c) {
|
|
308
306
|
createComputed(() => {
|
|
@@ -321,15 +319,15 @@ function createResource(source, fetcher, options) {
|
|
|
321
319
|
if (refetching && scheduled) return;
|
|
322
320
|
scheduled = false;
|
|
323
321
|
setError(err = undefined);
|
|
324
|
-
const lookup = dynamic ?
|
|
322
|
+
const lookup = dynamic ? dynamic() : source;
|
|
325
323
|
loadedUnderTransition = Transition && Transition.running;
|
|
326
324
|
if (lookup == null || lookup === false) {
|
|
327
|
-
loadEnd(pr, untrack(
|
|
325
|
+
loadEnd(pr, untrack(value));
|
|
328
326
|
return;
|
|
329
327
|
}
|
|
330
328
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
331
329
|
const p = initP || untrack(() => fetcher(lookup, {
|
|
332
|
-
value:
|
|
330
|
+
value: value(),
|
|
333
331
|
refetching
|
|
334
332
|
}));
|
|
335
333
|
if (typeof p !== "object" || !("then" in p)) {
|
|
@@ -355,18 +353,21 @@ function createResource(source, fetcher, options) {
|
|
|
355
353
|
get() {
|
|
356
354
|
return error();
|
|
357
355
|
}
|
|
356
|
+
},
|
|
357
|
+
latest: {
|
|
358
|
+
get() {
|
|
359
|
+
if (!resolved) return read();
|
|
360
|
+
if (err) throw err;
|
|
361
|
+
return value();
|
|
362
|
+
}
|
|
358
363
|
}
|
|
359
364
|
});
|
|
360
365
|
if (dynamic) createComputed(() => load(false));else load(false);
|
|
361
366
|
return [read, {
|
|
362
367
|
refetch: load,
|
|
363
|
-
mutate:
|
|
368
|
+
mutate: setValue
|
|
364
369
|
}];
|
|
365
370
|
}
|
|
366
|
-
let Resources;
|
|
367
|
-
function refetchResources(info) {
|
|
368
|
-
return Resources && Promise.all([...Resources].map(fn => fn(info)));
|
|
369
|
-
}
|
|
370
371
|
function createDeferred(source, options) {
|
|
371
372
|
let t,
|
|
372
373
|
timeout = options ? options.timeoutMs : undefined;
|
|
@@ -740,11 +741,14 @@ function runUpdates(fn, init) {
|
|
|
740
741
|
if (Effects) wait = true;else Effects = [];
|
|
741
742
|
ExecCount++;
|
|
742
743
|
try {
|
|
743
|
-
|
|
744
|
+
const res = fn();
|
|
745
|
+
completeUpdates(wait);
|
|
746
|
+
return res;
|
|
744
747
|
} catch (err) {
|
|
745
748
|
handleError(err);
|
|
746
749
|
} finally {
|
|
747
|
-
|
|
750
|
+
Updates = null;
|
|
751
|
+
if (!wait) Effects = null;
|
|
748
752
|
}
|
|
749
753
|
}
|
|
750
754
|
function completeUpdates(wait) {
|
|
@@ -985,6 +989,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
985
989
|
let newItems = list() || [],
|
|
986
990
|
i,
|
|
987
991
|
j;
|
|
992
|
+
newItems[$TRACK];
|
|
988
993
|
return untrack(() => {
|
|
989
994
|
let newLen = newItems.length,
|
|
990
995
|
newIndices,
|
|
@@ -1086,6 +1091,7 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1086
1091
|
onCleanup(() => dispose(disposers));
|
|
1087
1092
|
return () => {
|
|
1088
1093
|
const newItems = list() || [];
|
|
1094
|
+
newItems[$TRACK];
|
|
1089
1095
|
return untrack(() => {
|
|
1090
1096
|
if (newItems.length === 0) {
|
|
1091
1097
|
if (len !== 0) {
|
|
@@ -1141,6 +1147,7 @@ function enableHydration() {
|
|
|
1141
1147
|
hydrationEnabled = true;
|
|
1142
1148
|
}
|
|
1143
1149
|
function createComponent(Comp, props) {
|
|
1150
|
+
if (props == null || typeof props !== "object") props = {};
|
|
1144
1151
|
if (hydrationEnabled) {
|
|
1145
1152
|
if (sharedConfig.context) {
|
|
1146
1153
|
const c = sharedConfig.context;
|
|
@@ -1181,7 +1188,7 @@ const propTraps = {
|
|
|
1181
1188
|
}
|
|
1182
1189
|
};
|
|
1183
1190
|
function resolveSource(s) {
|
|
1184
|
-
return typeof s === "function" ? s() : s;
|
|
1191
|
+
return (s = typeof s === "function" ? s() : s) == null || typeof s !== "object" ? {} : s;
|
|
1185
1192
|
}
|
|
1186
1193
|
function mergeProps(...sources) {
|
|
1187
1194
|
return new Proxy({
|
|
@@ -1249,9 +1256,7 @@ function lazy(fn) {
|
|
|
1249
1256
|
});
|
|
1250
1257
|
comp = s;
|
|
1251
1258
|
} else if (!comp) {
|
|
1252
|
-
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default)
|
|
1253
|
-
globalRefetch: false
|
|
1254
|
-
});
|
|
1259
|
+
const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
|
|
1255
1260
|
comp = s;
|
|
1256
1261
|
} else {
|
|
1257
1262
|
const c = comp();
|
|
@@ -1505,6 +1510,7 @@ let DEV;
|
|
|
1505
1510
|
|
|
1506
1511
|
exports.$DEVCOMP = $DEVCOMP;
|
|
1507
1512
|
exports.$PROXY = $PROXY;
|
|
1513
|
+
exports.$TRACK = $TRACK;
|
|
1508
1514
|
exports.DEV = DEV;
|
|
1509
1515
|
exports.ErrorBoundary = ErrorBoundary;
|
|
1510
1516
|
exports.For = For;
|
|
@@ -1546,7 +1552,6 @@ exports.on = on;
|
|
|
1546
1552
|
exports.onCleanup = onCleanup;
|
|
1547
1553
|
exports.onError = onError;
|
|
1548
1554
|
exports.onMount = onMount;
|
|
1549
|
-
exports.refetchResources = refetchResources;
|
|
1550
1555
|
exports.requestCallback = requestCallback;
|
|
1551
1556
|
exports.resetErrorBoundaries = resetErrorBoundaries;
|
|
1552
1557
|
exports.runWithOwner = runWithOwner;
|