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/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $PROXY, $TRACK, getListener, batch, createSignal } from
|
|
1
|
+
import { $PROXY, $TRACK, getListener, batch, createSignal } from "solid-js";
|
|
2
2
|
|
|
3
3
|
const $RAW = Symbol("store-raw"),
|
|
4
4
|
$NODE = Symbol("store-node"),
|
|
@@ -8,7 +8,7 @@ function wrap$1(value) {
|
|
|
8
8
|
let p = value[$PROXY];
|
|
9
9
|
if (!p) {
|
|
10
10
|
Object.defineProperty(value, $PROXY, {
|
|
11
|
-
value: p = new Proxy(value, proxyTraps$1)
|
|
11
|
+
value: (p = new Proxy(value, proxyTraps$1))
|
|
12
12
|
});
|
|
13
13
|
if (!Array.isArray(value)) {
|
|
14
14
|
const keys = Object.keys(value),
|
|
@@ -28,20 +28,29 @@ function wrap$1(value) {
|
|
|
28
28
|
}
|
|
29
29
|
function isWrappable(obj) {
|
|
30
30
|
let proto;
|
|
31
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
obj != null &&
|
|
33
|
+
typeof obj === "object" &&
|
|
34
|
+
(obj[$PROXY] ||
|
|
35
|
+
!(proto = Object.getPrototypeOf(obj)) ||
|
|
36
|
+
proto === Object.prototype ||
|
|
37
|
+
Array.isArray(obj))
|
|
38
|
+
);
|
|
32
39
|
}
|
|
33
40
|
function unwrap(item, set = new Set()) {
|
|
34
41
|
let result, unwrapped, v, prop;
|
|
35
|
-
if (result = item != null && item[$RAW]) return result;
|
|
42
|
+
if ((result = item != null && item[$RAW])) return result;
|
|
36
43
|
if (!isWrappable(item) || set.has(item)) return item;
|
|
37
44
|
if (Array.isArray(item)) {
|
|
38
|
-
if (Object.isFrozen(item)) item = item.slice(0);
|
|
45
|
+
if (Object.isFrozen(item)) item = item.slice(0);
|
|
46
|
+
else set.add(item);
|
|
39
47
|
for (let i = 0, l = item.length; i < l; i++) {
|
|
40
48
|
v = item[i];
|
|
41
49
|
if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
|
|
42
50
|
}
|
|
43
51
|
} else {
|
|
44
|
-
if (Object.isFrozen(item)) item = Object.assign({}, item);
|
|
52
|
+
if (Object.isFrozen(item)) item = Object.assign({}, item);
|
|
53
|
+
else set.add(item);
|
|
45
54
|
const keys = Object.keys(item),
|
|
46
55
|
desc = Object.getOwnPropertyDescriptors(item);
|
|
47
56
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
@@ -55,9 +64,10 @@ function unwrap(item, set = new Set()) {
|
|
|
55
64
|
}
|
|
56
65
|
function getNodes(target, symbol) {
|
|
57
66
|
let nodes = target[symbol];
|
|
58
|
-
if (!nodes)
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
if (!nodes)
|
|
68
|
+
Object.defineProperty(target, symbol, {
|
|
69
|
+
value: (nodes = Object.create(null))
|
|
70
|
+
});
|
|
61
71
|
return nodes;
|
|
62
72
|
}
|
|
63
73
|
function getNode(nodes, property, value) {
|
|
@@ -67,11 +77,12 @@ function getNode(nodes, property, value) {
|
|
|
67
77
|
internal: true
|
|
68
78
|
});
|
|
69
79
|
s.$ = set;
|
|
70
|
-
return nodes[property] = s;
|
|
80
|
+
return (nodes[property] = s);
|
|
71
81
|
}
|
|
72
82
|
function proxyDescriptor$1(target, property) {
|
|
73
83
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
74
|
-
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
|
|
84
|
+
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
|
|
85
|
+
return desc;
|
|
75
86
|
delete desc.value;
|
|
76
87
|
delete desc.writable;
|
|
77
88
|
desc.get = () => target[$PROXY][property];
|
|
@@ -98,12 +109,25 @@ const proxyTraps$1 = {
|
|
|
98
109
|
if (property === $NODE || property === $HAS || property === "__proto__") return value;
|
|
99
110
|
if (!tracked) {
|
|
100
111
|
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
101
|
-
if (
|
|
112
|
+
if (
|
|
113
|
+
getListener() &&
|
|
114
|
+
(typeof value !== "function" || target.hasOwnProperty(property)) &&
|
|
115
|
+
!(desc && desc.get)
|
|
116
|
+
)
|
|
117
|
+
value = getNode(nodes, property, value)();
|
|
102
118
|
}
|
|
103
119
|
return isWrappable(value) ? wrap$1(value) : value;
|
|
104
120
|
},
|
|
105
121
|
has(target, property) {
|
|
106
|
-
if (
|
|
122
|
+
if (
|
|
123
|
+
property === $RAW ||
|
|
124
|
+
property === $PROXY ||
|
|
125
|
+
property === $TRACK ||
|
|
126
|
+
property === $NODE ||
|
|
127
|
+
property === $HAS ||
|
|
128
|
+
property === "__proto__"
|
|
129
|
+
)
|
|
130
|
+
return true;
|
|
107
131
|
getListener() && getNode(getNodes(target, $HAS), property)();
|
|
108
132
|
return property in target;
|
|
109
133
|
},
|
|
@@ -129,7 +153,7 @@ function setProperty(state, property, value, deleting = false) {
|
|
|
129
153
|
}
|
|
130
154
|
let nodes = getNodes(state, $NODE),
|
|
131
155
|
node;
|
|
132
|
-
if (node = getNode(nodes, property, prev)) node.$(() => value);
|
|
156
|
+
if ((node = getNode(nodes, property, prev))) node.$(() => value);
|
|
133
157
|
if (Array.isArray(state) && state.length !== len) {
|
|
134
158
|
for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
|
|
135
159
|
(node = getNode(nodes, "length", len)) && node.$(state.length);
|
|
@@ -175,11 +199,7 @@ function updatePath(current, path, traversed = []) {
|
|
|
175
199
|
}
|
|
176
200
|
return;
|
|
177
201
|
} else if (isArray && partType === "object") {
|
|
178
|
-
const {
|
|
179
|
-
from = 0,
|
|
180
|
-
to = current.length - 1,
|
|
181
|
-
by = 1
|
|
182
|
-
} = part;
|
|
202
|
+
const { from = 0, to = current.length - 1, by = 1 } = part;
|
|
183
203
|
for (let i = from; i <= to; i += by) {
|
|
184
204
|
updatePath(current, [i].concat(path), traversed);
|
|
185
205
|
}
|
|
@@ -198,7 +218,7 @@ function updatePath(current, path, traversed = []) {
|
|
|
198
218
|
}
|
|
199
219
|
if (part === undefined && value == undefined) return;
|
|
200
220
|
value = unwrap(value);
|
|
201
|
-
if (part === undefined || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
|
|
221
|
+
if (part === undefined || (isWrappable(prev) && isWrappable(value) && !Array.isArray(value))) {
|
|
202
222
|
mergeStoreNode(prev, value);
|
|
203
223
|
} else setProperty(current, part, value);
|
|
204
224
|
}
|
|
@@ -208,7 +228,9 @@ function createStore(...[store, options]) {
|
|
|
208
228
|
const wrappedStore = wrap$1(unwrappedStore);
|
|
209
229
|
function setStore(...args) {
|
|
210
230
|
batch(() => {
|
|
211
|
-
isArray && args.length === 1
|
|
231
|
+
isArray && args.length === 1
|
|
232
|
+
? updateArray(unwrappedStore, args[0])
|
|
233
|
+
: updatePath(unwrappedStore, args);
|
|
212
234
|
});
|
|
213
235
|
}
|
|
214
236
|
return [wrappedStore, setStore];
|
|
@@ -216,11 +238,19 @@ function createStore(...[store, options]) {
|
|
|
216
238
|
|
|
217
239
|
function proxyDescriptor(target, property) {
|
|
218
240
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
219
|
-
if (
|
|
241
|
+
if (
|
|
242
|
+
!desc ||
|
|
243
|
+
desc.get ||
|
|
244
|
+
desc.set ||
|
|
245
|
+
!desc.configurable ||
|
|
246
|
+
property === $PROXY ||
|
|
247
|
+
property === $NODE
|
|
248
|
+
)
|
|
249
|
+
return desc;
|
|
220
250
|
delete desc.value;
|
|
221
251
|
delete desc.writable;
|
|
222
252
|
desc.get = () => target[$PROXY][property];
|
|
223
|
-
desc.set = v => target[$PROXY][property] = v;
|
|
253
|
+
desc.set = v => (target[$PROXY][property] = v);
|
|
224
254
|
return desc;
|
|
225
255
|
}
|
|
226
256
|
const proxyTraps = {
|
|
@@ -238,14 +268,24 @@ const proxyTraps = {
|
|
|
238
268
|
if (!tracked) {
|
|
239
269
|
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
240
270
|
const isFunction = typeof value === "function";
|
|
241
|
-
if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get))
|
|
271
|
+
if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get))
|
|
272
|
+
value = getNode(nodes, property, value)();
|
|
273
|
+
else if (value != null && isFunction && value === Array.prototype[property]) {
|
|
242
274
|
return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
|
|
243
275
|
}
|
|
244
276
|
}
|
|
245
277
|
return isWrappable(value) ? wrap(value) : value;
|
|
246
278
|
},
|
|
247
279
|
has(target, property) {
|
|
248
|
-
if (
|
|
280
|
+
if (
|
|
281
|
+
property === $RAW ||
|
|
282
|
+
property === $PROXY ||
|
|
283
|
+
property === $TRACK ||
|
|
284
|
+
property === $NODE ||
|
|
285
|
+
property === $HAS ||
|
|
286
|
+
property === "__proto__"
|
|
287
|
+
)
|
|
288
|
+
return true;
|
|
249
289
|
getListener() && getNode(getNodes(target, $HAS), property)();
|
|
250
290
|
return property in target;
|
|
251
291
|
},
|
|
@@ -264,12 +304,16 @@ function wrap(value) {
|
|
|
264
304
|
let p = value[$PROXY];
|
|
265
305
|
if (!p) {
|
|
266
306
|
Object.defineProperty(value, $PROXY, {
|
|
267
|
-
value: p = new Proxy(value, proxyTraps)
|
|
307
|
+
value: (p = new Proxy(value, proxyTraps))
|
|
268
308
|
});
|
|
269
309
|
const keys = Object.keys(value),
|
|
270
310
|
desc = Object.getOwnPropertyDescriptors(value);
|
|
271
311
|
const proto = Object.getPrototypeOf(value);
|
|
272
|
-
const isClass =
|
|
312
|
+
const isClass =
|
|
313
|
+
value !== null &&
|
|
314
|
+
typeof value === "object" &&
|
|
315
|
+
!Array.isArray(value) &&
|
|
316
|
+
proto !== Object.prototype;
|
|
273
317
|
if (isClass) {
|
|
274
318
|
const descriptors = Object.getOwnPropertyDescriptors(proto);
|
|
275
319
|
keys.push(...Object.keys(descriptors));
|
|
@@ -311,19 +355,42 @@ function applyState(target, parent, property, merge, key) {
|
|
|
311
355
|
const previous = parent[property];
|
|
312
356
|
if (target === previous) return;
|
|
313
357
|
const isArray = Array.isArray(target);
|
|
314
|
-
if (
|
|
358
|
+
if (
|
|
359
|
+
property !== $ROOT &&
|
|
360
|
+
(!isWrappable(target) ||
|
|
361
|
+
!isWrappable(previous) ||
|
|
362
|
+
isArray !== Array.isArray(previous) ||
|
|
363
|
+
(key && target[key] !== previous[key]))
|
|
364
|
+
) {
|
|
315
365
|
setProperty(parent, property, target);
|
|
316
366
|
return;
|
|
317
367
|
}
|
|
318
368
|
if (isArray) {
|
|
319
|
-
if (
|
|
369
|
+
if (
|
|
370
|
+
target.length &&
|
|
371
|
+
previous.length &&
|
|
372
|
+
(!merge || (key && target[0] && target[0][key] != null))
|
|
373
|
+
) {
|
|
320
374
|
let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
|
|
321
|
-
for (
|
|
375
|
+
for (
|
|
376
|
+
start = 0, end = Math.min(previous.length, target.length);
|
|
377
|
+
start < end &&
|
|
378
|
+
(previous[start] === target[start] ||
|
|
379
|
+
(key && previous[start] && target[start] && previous[start][key] === target[start][key]));
|
|
380
|
+
start++
|
|
381
|
+
) {
|
|
322
382
|
applyState(target[start], previous, start, merge, key);
|
|
323
383
|
}
|
|
324
384
|
const temp = new Array(target.length),
|
|
325
385
|
newIndices = new Map();
|
|
326
|
-
for (
|
|
386
|
+
for (
|
|
387
|
+
end = previous.length - 1, newEnd = target.length - 1;
|
|
388
|
+
end >= start &&
|
|
389
|
+
newEnd >= start &&
|
|
390
|
+
(previous[end] === target[newEnd] ||
|
|
391
|
+
(key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]));
|
|
392
|
+
end--, newEnd--
|
|
393
|
+
) {
|
|
327
394
|
temp[newEnd] = previous[end];
|
|
328
395
|
}
|
|
329
396
|
if (start > newEnd || start > end) {
|
|
@@ -377,16 +444,19 @@ function applyState(target, parent, property, merge, key) {
|
|
|
377
444
|
}
|
|
378
445
|
}
|
|
379
446
|
function reconcile(value, options = {}) {
|
|
380
|
-
const {
|
|
381
|
-
merge,
|
|
382
|
-
key = "id"
|
|
383
|
-
} = options,
|
|
447
|
+
const { merge, key = "id" } = options,
|
|
384
448
|
v = unwrap(value);
|
|
385
449
|
return state => {
|
|
386
450
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
387
|
-
const res = applyState(
|
|
388
|
-
|
|
389
|
-
|
|
451
|
+
const res = applyState(
|
|
452
|
+
v,
|
|
453
|
+
{
|
|
454
|
+
[$ROOT]: state
|
|
455
|
+
},
|
|
456
|
+
$ROOT,
|
|
457
|
+
merge,
|
|
458
|
+
key
|
|
459
|
+
);
|
|
390
460
|
return res === undefined ? state : res;
|
|
391
461
|
};
|
|
392
462
|
}
|
|
@@ -396,7 +466,10 @@ const setterTraps = {
|
|
|
396
466
|
if (property === $RAW) return target;
|
|
397
467
|
const value = target[property];
|
|
398
468
|
let proxy;
|
|
399
|
-
return isWrappable(value)
|
|
469
|
+
return isWrappable(value)
|
|
470
|
+
? producers.get(value) ||
|
|
471
|
+
(producers.set(value, (proxy = new Proxy(value, setterTraps))), proxy)
|
|
472
|
+
: value;
|
|
400
473
|
},
|
|
401
474
|
set(target, property, value) {
|
|
402
475
|
setProperty(target, property, unwrap(value));
|
|
@@ -412,7 +485,7 @@ function produce(fn) {
|
|
|
412
485
|
if (isWrappable(state)) {
|
|
413
486
|
let proxy;
|
|
414
487
|
if (!(proxy = producers.get(state))) {
|
|
415
|
-
producers.set(state, proxy = new Proxy(state, setterTraps));
|
|
488
|
+
producers.set(state, (proxy = new Proxy(state, setterTraps)));
|
|
416
489
|
}
|
|
417
490
|
fn(proxy);
|
|
418
491
|
}
|
package/store/types/index.d.ts
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
export { $RAW, createStore, unwrap } from "./store.js";
|
|
2
|
-
export type {
|
|
2
|
+
export type {
|
|
3
|
+
ArrayFilterFn,
|
|
4
|
+
DeepMutable,
|
|
5
|
+
DeepReadonly,
|
|
6
|
+
NotWrappable,
|
|
7
|
+
Part,
|
|
8
|
+
SetStoreFunction,
|
|
9
|
+
SolidStore,
|
|
10
|
+
Store,
|
|
11
|
+
StoreNode,
|
|
12
|
+
StorePathRange,
|
|
13
|
+
StoreSetter
|
|
14
|
+
} from "./store.js";
|
|
3
15
|
export * from "./mutable.js";
|
|
4
16
|
export * from "./modifiers.js";
|
|
5
17
|
import { $NODE, isWrappable } from "./store.js";
|
|
6
|
-
export declare const DEV:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
export declare const DEV:
|
|
19
|
+
| {
|
|
20
|
+
readonly $NODE: typeof $NODE;
|
|
21
|
+
readonly isWrappable: typeof isWrappable;
|
|
22
|
+
readonly hooks: {
|
|
10
23
|
onStoreNodeUpdate: import("./store.js").OnStoreNodeUpdate | null;
|
|
11
|
-
|
|
12
|
-
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
| undefined;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export type ReconcileOptions = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
key?: string | null;
|
|
3
|
+
merge?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare function reconcile<T extends U, U>(
|
|
5
|
+
export declare function reconcile<T extends U, U>(
|
|
6
|
+
value: T,
|
|
7
|
+
options?: ReconcileOptions
|
|
8
|
+
): (state: U) => T;
|
|
6
9
|
export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
|
package/store/types/mutable.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { StoreNode } from "./store.js";
|
|
2
|
-
export declare function createMutable<T extends StoreNode>(
|
|
2
|
+
export declare function createMutable<T extends StoreNode>(
|
|
3
|
+
state: T,
|
|
4
|
+
options?: {
|
|
3
5
|
name?: string;
|
|
4
|
-
}
|
|
6
|
+
}
|
|
7
|
+
): T;
|
|
5
8
|
export declare function modifyMutable<T>(state: T, modifier: (state: T) => T): void;
|
package/store/types/server.d.ts
CHANGED
|
@@ -2,15 +2,23 @@ import type { SetStoreFunction, Store } from "./store.js";
|
|
|
2
2
|
export declare const $RAW: unique symbol;
|
|
3
3
|
export declare function isWrappable(obj: any): boolean;
|
|
4
4
|
export declare function unwrap<T>(item: T): T;
|
|
5
|
-
export declare function setProperty(
|
|
5
|
+
export declare function setProperty(
|
|
6
|
+
state: any,
|
|
7
|
+
property: PropertyKey,
|
|
8
|
+
value: any,
|
|
9
|
+
force?: boolean
|
|
10
|
+
): void;
|
|
6
11
|
export declare function updatePath(current: any, path: any[], traversed?: PropertyKey[]): void;
|
|
7
12
|
export declare function createStore<T>(state: T | Store<T>): [Store<T>, SetStoreFunction<T>];
|
|
8
13
|
export declare function createMutable<T>(state: T | Store<T>): T;
|
|
9
14
|
type ReconcileOptions = {
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
key?: string | null;
|
|
16
|
+
merge?: boolean;
|
|
12
17
|
};
|
|
13
|
-
export declare function reconcile<T extends U, U extends object>(
|
|
18
|
+
export declare function reconcile<T extends U, U extends object>(
|
|
19
|
+
value: T,
|
|
20
|
+
options?: ReconcileOptions
|
|
21
|
+
): (state: U) => T;
|
|
14
22
|
export declare function produce<T>(fn: (state: T) => void): (state: T) => T;
|
|
15
23
|
export declare const DEV: undefined;
|
|
16
24
|
export {};
|