solid-js 1.8.19 → 1.8.21
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 +6 -6
- package/dist/dev.js +562 -321
- package/dist/server.js +168 -74
- package/dist/solid.cjs +6 -6
- package/dist/solid.js +489 -279
- package/h/dist/h.js +38 -9
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -33
- package/package.json +1 -1
- package/store/dist/dev.js +122 -43
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +113 -40
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +913 -862
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +233 -142
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +64 -33
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +15 -15
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +169 -98
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +34 -18
- package/web/dist/dev.js +655 -97
- package/web/dist/server.cjs +1 -1
- package/web/dist/server.js +210 -96
- package/web/dist/web.cjs +32 -16
- package/web/dist/web.js +646 -95
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
package/store/dist/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEV as DEV$1, $PROXY, $TRACK, getListener, batch, createSignal } from
|
|
1
|
+
import { DEV as DEV$1, $PROXY, $TRACK, getListener, batch, createSignal } from "solid-js";
|
|
2
2
|
|
|
3
3
|
const $RAW = Symbol("store-raw"),
|
|
4
4
|
$NODE = Symbol("store-node"),
|
|
@@ -11,7 +11,7 @@ function wrap$1(value) {
|
|
|
11
11
|
let p = value[$PROXY];
|
|
12
12
|
if (!p) {
|
|
13
13
|
Object.defineProperty(value, $PROXY, {
|
|
14
|
-
value: p = new Proxy(value, proxyTraps$1)
|
|
14
|
+
value: (p = new Proxy(value, proxyTraps$1))
|
|
15
15
|
});
|
|
16
16
|
if (!Array.isArray(value)) {
|
|
17
17
|
const keys = Object.keys(value),
|
|
@@ -31,20 +31,29 @@ function wrap$1(value) {
|
|
|
31
31
|
}
|
|
32
32
|
function isWrappable(obj) {
|
|
33
33
|
let proto;
|
|
34
|
-
return
|
|
34
|
+
return (
|
|
35
|
+
obj != null &&
|
|
36
|
+
typeof obj === "object" &&
|
|
37
|
+
(obj[$PROXY] ||
|
|
38
|
+
!(proto = Object.getPrototypeOf(obj)) ||
|
|
39
|
+
proto === Object.prototype ||
|
|
40
|
+
Array.isArray(obj))
|
|
41
|
+
);
|
|
35
42
|
}
|
|
36
43
|
function unwrap(item, set = new Set()) {
|
|
37
44
|
let result, unwrapped, v, prop;
|
|
38
|
-
if (result = item != null && item[$RAW]) return result;
|
|
45
|
+
if ((result = item != null && item[$RAW])) return result;
|
|
39
46
|
if (!isWrappable(item) || set.has(item)) return item;
|
|
40
47
|
if (Array.isArray(item)) {
|
|
41
|
-
if (Object.isFrozen(item)) item = item.slice(0);
|
|
48
|
+
if (Object.isFrozen(item)) item = item.slice(0);
|
|
49
|
+
else set.add(item);
|
|
42
50
|
for (let i = 0, l = item.length; i < l; i++) {
|
|
43
51
|
v = item[i];
|
|
44
52
|
if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
|
|
45
53
|
}
|
|
46
54
|
} else {
|
|
47
|
-
if (Object.isFrozen(item)) item = Object.assign({}, item);
|
|
55
|
+
if (Object.isFrozen(item)) item = Object.assign({}, item);
|
|
56
|
+
else set.add(item);
|
|
48
57
|
const keys = Object.keys(item),
|
|
49
58
|
desc = Object.getOwnPropertyDescriptors(item);
|
|
50
59
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
@@ -58,9 +67,10 @@ function unwrap(item, set = new Set()) {
|
|
|
58
67
|
}
|
|
59
68
|
function getNodes(target, symbol) {
|
|
60
69
|
let nodes = target[symbol];
|
|
61
|
-
if (!nodes)
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
if (!nodes)
|
|
71
|
+
Object.defineProperty(target, symbol, {
|
|
72
|
+
value: (nodes = Object.create(null))
|
|
73
|
+
});
|
|
64
74
|
return nodes;
|
|
65
75
|
}
|
|
66
76
|
function getNode(nodes, property, value) {
|
|
@@ -70,11 +80,12 @@ function getNode(nodes, property, value) {
|
|
|
70
80
|
internal: true
|
|
71
81
|
});
|
|
72
82
|
s.$ = set;
|
|
73
|
-
return nodes[property] = s;
|
|
83
|
+
return (nodes[property] = s);
|
|
74
84
|
}
|
|
75
85
|
function proxyDescriptor$1(target, property) {
|
|
76
86
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
77
|
-
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
|
|
87
|
+
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
|
|
88
|
+
return desc;
|
|
78
89
|
delete desc.value;
|
|
79
90
|
delete desc.writable;
|
|
80
91
|
desc.get = () => target[$PROXY][property];
|
|
@@ -101,12 +112,25 @@ const proxyTraps$1 = {
|
|
|
101
112
|
if (property === $NODE || property === $HAS || property === "__proto__") return value;
|
|
102
113
|
if (!tracked) {
|
|
103
114
|
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
104
|
-
if (
|
|
115
|
+
if (
|
|
116
|
+
getListener() &&
|
|
117
|
+
(typeof value !== "function" || target.hasOwnProperty(property)) &&
|
|
118
|
+
!(desc && desc.get)
|
|
119
|
+
)
|
|
120
|
+
value = getNode(nodes, property, value)();
|
|
105
121
|
}
|
|
106
122
|
return isWrappable(value) ? wrap$1(value) : value;
|
|
107
123
|
},
|
|
108
124
|
has(target, property) {
|
|
109
|
-
if (
|
|
125
|
+
if (
|
|
126
|
+
property === $RAW ||
|
|
127
|
+
property === $PROXY ||
|
|
128
|
+
property === $TRACK ||
|
|
129
|
+
property === $NODE ||
|
|
130
|
+
property === $HAS ||
|
|
131
|
+
property === "__proto__"
|
|
132
|
+
)
|
|
133
|
+
return true;
|
|
110
134
|
getListener() && getNode(getNodes(target, $HAS), property)();
|
|
111
135
|
return property in target;
|
|
112
136
|
},
|
|
@@ -135,7 +159,7 @@ function setProperty(state, property, value, deleting = false) {
|
|
|
135
159
|
}
|
|
136
160
|
let nodes = getNodes(state, $NODE),
|
|
137
161
|
node;
|
|
138
|
-
if (node = getNode(nodes, property, prev)) node.$(() => value);
|
|
162
|
+
if ((node = getNode(nodes, property, prev))) node.$(() => value);
|
|
139
163
|
if (Array.isArray(state) && state.length !== len) {
|
|
140
164
|
for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
|
|
141
165
|
(node = getNode(nodes, "length", len)) && node.$(state.length);
|
|
@@ -181,11 +205,7 @@ function updatePath(current, path, traversed = []) {
|
|
|
181
205
|
}
|
|
182
206
|
return;
|
|
183
207
|
} else if (isArray && partType === "object") {
|
|
184
|
-
const {
|
|
185
|
-
from = 0,
|
|
186
|
-
to = current.length - 1,
|
|
187
|
-
by = 1
|
|
188
|
-
} = part;
|
|
208
|
+
const { from = 0, to = current.length - 1, by = 1 } = part;
|
|
189
209
|
for (let i = from; i <= to; i += by) {
|
|
190
210
|
updatePath(current, [i].concat(path), traversed);
|
|
191
211
|
}
|
|
@@ -204,14 +224,17 @@ function updatePath(current, path, traversed = []) {
|
|
|
204
224
|
}
|
|
205
225
|
if (part === undefined && value == undefined) return;
|
|
206
226
|
value = unwrap(value);
|
|
207
|
-
if (part === undefined || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
|
|
227
|
+
if (part === undefined || (isWrappable(prev) && isWrappable(value) && !Array.isArray(value))) {
|
|
208
228
|
mergeStoreNode(prev, value);
|
|
209
229
|
} else setProperty(current, part, value);
|
|
210
230
|
}
|
|
211
231
|
function createStore(...[store, options]) {
|
|
212
232
|
const unwrappedStore = unwrap(store || {});
|
|
213
233
|
const isArray = Array.isArray(unwrappedStore);
|
|
214
|
-
if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function")
|
|
234
|
+
if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function")
|
|
235
|
+
throw new Error(
|
|
236
|
+
`Unexpected type ${typeof unwrappedStore} received when initializing 'createStore'. Expected an object.`
|
|
237
|
+
);
|
|
215
238
|
const wrappedStore = wrap$1(unwrappedStore);
|
|
216
239
|
DEV$1.registerGraph({
|
|
217
240
|
value: unwrappedStore,
|
|
@@ -219,7 +242,9 @@ function createStore(...[store, options]) {
|
|
|
219
242
|
});
|
|
220
243
|
function setStore(...args) {
|
|
221
244
|
batch(() => {
|
|
222
|
-
isArray && args.length === 1
|
|
245
|
+
isArray && args.length === 1
|
|
246
|
+
? updateArray(unwrappedStore, args[0])
|
|
247
|
+
: updatePath(unwrappedStore, args);
|
|
223
248
|
});
|
|
224
249
|
}
|
|
225
250
|
return [wrappedStore, setStore];
|
|
@@ -227,11 +252,19 @@ function createStore(...[store, options]) {
|
|
|
227
252
|
|
|
228
253
|
function proxyDescriptor(target, property) {
|
|
229
254
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
230
|
-
if (
|
|
255
|
+
if (
|
|
256
|
+
!desc ||
|
|
257
|
+
desc.get ||
|
|
258
|
+
desc.set ||
|
|
259
|
+
!desc.configurable ||
|
|
260
|
+
property === $PROXY ||
|
|
261
|
+
property === $NODE
|
|
262
|
+
)
|
|
263
|
+
return desc;
|
|
231
264
|
delete desc.value;
|
|
232
265
|
delete desc.writable;
|
|
233
266
|
desc.get = () => target[$PROXY][property];
|
|
234
|
-
desc.set = v => target[$PROXY][property] = v;
|
|
267
|
+
desc.set = v => (target[$PROXY][property] = v);
|
|
235
268
|
return desc;
|
|
236
269
|
}
|
|
237
270
|
const proxyTraps = {
|
|
@@ -249,14 +282,24 @@ const proxyTraps = {
|
|
|
249
282
|
if (!tracked) {
|
|
250
283
|
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
251
284
|
const isFunction = typeof value === "function";
|
|
252
|
-
if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get))
|
|
285
|
+
if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get))
|
|
286
|
+
value = getNode(nodes, property, value)();
|
|
287
|
+
else if (value != null && isFunction && value === Array.prototype[property]) {
|
|
253
288
|
return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
|
|
254
289
|
}
|
|
255
290
|
}
|
|
256
291
|
return isWrappable(value) ? wrap(value) : value;
|
|
257
292
|
},
|
|
258
293
|
has(target, property) {
|
|
259
|
-
if (
|
|
294
|
+
if (
|
|
295
|
+
property === $RAW ||
|
|
296
|
+
property === $PROXY ||
|
|
297
|
+
property === $TRACK ||
|
|
298
|
+
property === $NODE ||
|
|
299
|
+
property === $HAS ||
|
|
300
|
+
property === "__proto__"
|
|
301
|
+
)
|
|
302
|
+
return true;
|
|
260
303
|
getListener() && getNode(getNodes(target, $HAS), property)();
|
|
261
304
|
return property in target;
|
|
262
305
|
},
|
|
@@ -275,12 +318,16 @@ function wrap(value) {
|
|
|
275
318
|
let p = value[$PROXY];
|
|
276
319
|
if (!p) {
|
|
277
320
|
Object.defineProperty(value, $PROXY, {
|
|
278
|
-
value: p = new Proxy(value, proxyTraps)
|
|
321
|
+
value: (p = new Proxy(value, proxyTraps))
|
|
279
322
|
});
|
|
280
323
|
const keys = Object.keys(value),
|
|
281
324
|
desc = Object.getOwnPropertyDescriptors(value);
|
|
282
325
|
const proto = Object.getPrototypeOf(value);
|
|
283
|
-
const isClass =
|
|
326
|
+
const isClass =
|
|
327
|
+
value !== null &&
|
|
328
|
+
typeof value === "object" &&
|
|
329
|
+
!Array.isArray(value) &&
|
|
330
|
+
proto !== Object.prototype;
|
|
284
331
|
if (isClass) {
|
|
285
332
|
const descriptors = Object.getOwnPropertyDescriptors(proto);
|
|
286
333
|
keys.push(...Object.keys(descriptors));
|
|
@@ -310,7 +357,10 @@ function wrap(value) {
|
|
|
310
357
|
}
|
|
311
358
|
function createMutable(state, options) {
|
|
312
359
|
const unwrappedStore = unwrap(state || {});
|
|
313
|
-
if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function")
|
|
360
|
+
if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function")
|
|
361
|
+
throw new Error(
|
|
362
|
+
`Unexpected type ${typeof unwrappedStore} received when initializing 'createMutable'. Expected an object.`
|
|
363
|
+
);
|
|
314
364
|
const wrappedStore = wrap(unwrappedStore);
|
|
315
365
|
DEV$1.registerGraph({
|
|
316
366
|
value: unwrappedStore,
|
|
@@ -327,19 +377,42 @@ function applyState(target, parent, property, merge, key) {
|
|
|
327
377
|
const previous = parent[property];
|
|
328
378
|
if (target === previous) return;
|
|
329
379
|
const isArray = Array.isArray(target);
|
|
330
|
-
if (
|
|
380
|
+
if (
|
|
381
|
+
property !== $ROOT &&
|
|
382
|
+
(!isWrappable(target) ||
|
|
383
|
+
!isWrappable(previous) ||
|
|
384
|
+
isArray !== Array.isArray(previous) ||
|
|
385
|
+
(key && target[key] !== previous[key]))
|
|
386
|
+
) {
|
|
331
387
|
setProperty(parent, property, target);
|
|
332
388
|
return;
|
|
333
389
|
}
|
|
334
390
|
if (isArray) {
|
|
335
|
-
if (
|
|
391
|
+
if (
|
|
392
|
+
target.length &&
|
|
393
|
+
previous.length &&
|
|
394
|
+
(!merge || (key && target[0] && target[0][key] != null))
|
|
395
|
+
) {
|
|
336
396
|
let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
|
|
337
|
-
for (
|
|
397
|
+
for (
|
|
398
|
+
start = 0, end = Math.min(previous.length, target.length);
|
|
399
|
+
start < end &&
|
|
400
|
+
(previous[start] === target[start] ||
|
|
401
|
+
(key && previous[start] && target[start] && previous[start][key] === target[start][key]));
|
|
402
|
+
start++
|
|
403
|
+
) {
|
|
338
404
|
applyState(target[start], previous, start, merge, key);
|
|
339
405
|
}
|
|
340
406
|
const temp = new Array(target.length),
|
|
341
407
|
newIndices = new Map();
|
|
342
|
-
for (
|
|
408
|
+
for (
|
|
409
|
+
end = previous.length - 1, newEnd = target.length - 1;
|
|
410
|
+
end >= start &&
|
|
411
|
+
newEnd >= start &&
|
|
412
|
+
(previous[end] === target[newEnd] ||
|
|
413
|
+
(key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]));
|
|
414
|
+
end--, newEnd--
|
|
415
|
+
) {
|
|
343
416
|
temp[newEnd] = previous[end];
|
|
344
417
|
}
|
|
345
418
|
if (start > newEnd || start > end) {
|
|
@@ -393,16 +466,19 @@ function applyState(target, parent, property, merge, key) {
|
|
|
393
466
|
}
|
|
394
467
|
}
|
|
395
468
|
function reconcile(value, options = {}) {
|
|
396
|
-
const {
|
|
397
|
-
merge,
|
|
398
|
-
key = "id"
|
|
399
|
-
} = options,
|
|
469
|
+
const { merge, key = "id" } = options,
|
|
400
470
|
v = unwrap(value);
|
|
401
471
|
return state => {
|
|
402
472
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
403
|
-
const res = applyState(
|
|
404
|
-
|
|
405
|
-
|
|
473
|
+
const res = applyState(
|
|
474
|
+
v,
|
|
475
|
+
{
|
|
476
|
+
[$ROOT]: state
|
|
477
|
+
},
|
|
478
|
+
$ROOT,
|
|
479
|
+
merge,
|
|
480
|
+
key
|
|
481
|
+
);
|
|
406
482
|
return res === undefined ? state : res;
|
|
407
483
|
};
|
|
408
484
|
}
|
|
@@ -412,7 +488,10 @@ const setterTraps = {
|
|
|
412
488
|
if (property === $RAW) return target;
|
|
413
489
|
const value = target[property];
|
|
414
490
|
let proxy;
|
|
415
|
-
return isWrappable(value)
|
|
491
|
+
return isWrappable(value)
|
|
492
|
+
? producers.get(value) ||
|
|
493
|
+
(producers.set(value, (proxy = new Proxy(value, setterTraps))), proxy)
|
|
494
|
+
: value;
|
|
416
495
|
},
|
|
417
496
|
set(target, property, value) {
|
|
418
497
|
setProperty(target, property, unwrap(value));
|
|
@@ -428,7 +507,7 @@ function produce(fn) {
|
|
|
428
507
|
if (isWrappable(state)) {
|
|
429
508
|
let proxy;
|
|
430
509
|
if (!(proxy = producers.get(state))) {
|
|
431
|
-
producers.set(state, proxy = new Proxy(state, setterTraps));
|
|
510
|
+
producers.set(state, (proxy = new Proxy(state, setterTraps)));
|
|
432
511
|
}
|
|
433
512
|
fn(proxy);
|
|
434
513
|
}
|
|
@@ -440,6 +519,6 @@ const DEV = {
|
|
|
440
519
|
$NODE,
|
|
441
520
|
isWrappable,
|
|
442
521
|
hooks: DevHooks
|
|
443
|
-
}
|
|
522
|
+
};
|
|
444
523
|
|
|
445
524
|
export { $RAW, DEV, createMutable, createStore, modifyMutable, produce, reconcile, unwrap };
|
package/store/dist/server.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const $RAW = Symbol("state-raw");
|
|
2
2
|
function isWrappable(obj) {
|
|
3
|
-
return
|
|
3
|
+
return (
|
|
4
|
+
obj != null &&
|
|
5
|
+
typeof obj === "object" &&
|
|
6
|
+
(Object.getPrototypeOf(obj) === Object.prototype || Array.isArray(obj))
|
|
7
|
+
);
|
|
4
8
|
}
|
|
5
9
|
function unwrap(item) {
|
|
6
10
|
return item;
|
|
@@ -49,11 +53,7 @@ function updatePath(current, path, traversed = []) {
|
|
|
49
53
|
}
|
|
50
54
|
return;
|
|
51
55
|
} else if (isArray && partType === "object") {
|
|
52
|
-
const {
|
|
53
|
-
from = 0,
|
|
54
|
-
to = current.length - 1,
|
|
55
|
-
by = 1
|
|
56
|
-
} = part;
|
|
56
|
+
const { from = 0, to = current.length - 1, by = 1 } = part;
|
|
57
57
|
for (let i = from; i <= to; i += by) {
|
|
58
58
|
updatePath(current, [i].concat(path), traversed);
|
|
59
59
|
}
|
|
@@ -71,7 +71,7 @@ function updatePath(current, path, traversed = []) {
|
|
|
71
71
|
if (value === next) return;
|
|
72
72
|
}
|
|
73
73
|
if (part === undefined && value == undefined) return;
|
|
74
|
-
if (part === undefined || isWrappable(next) && isWrappable(value) && !Array.isArray(value)) {
|
|
74
|
+
if (part === undefined || (isWrappable(next) && isWrappable(value) && !Array.isArray(value))) {
|
|
75
75
|
mergeStoreNode(next, value);
|
|
76
76
|
} else setProperty(current, part, value);
|
|
77
77
|
}
|
|
@@ -108,4 +108,15 @@ function produce(fn) {
|
|
|
108
108
|
}
|
|
109
109
|
const DEV = undefined;
|
|
110
110
|
|
|
111
|
-
export {
|
|
111
|
+
export {
|
|
112
|
+
$RAW,
|
|
113
|
+
DEV,
|
|
114
|
+
createMutable,
|
|
115
|
+
createStore,
|
|
116
|
+
isWrappable,
|
|
117
|
+
produce,
|
|
118
|
+
reconcile,
|
|
119
|
+
setProperty,
|
|
120
|
+
unwrap,
|
|
121
|
+
updatePath
|
|
122
|
+
};
|