solid-js 1.4.0-beta.4 → 1.4.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 +2 -2
- package/dist/dev.js +2 -2
- package/dist/server.cjs +2 -1
- package/dist/server.js +2 -1
- package/dist/solid.cjs +2 -2
- package/dist/solid.js +2 -2
- package/h/dist/h.cjs +10 -1
- package/h/dist/h.js +10 -1
- package/package.json +3 -3
- package/store/dist/dev.cjs +27 -17
- package/store/dist/dev.js +27 -17
- package/store/dist/store.cjs +27 -17
- package/store/dist/store.js +27 -17
- package/store/types/store.d.ts +1 -4
- package/types/reactive/signal.d.ts +19 -10
- package/types/render/component.d.ts +16 -10
package/dist/dev.cjs
CHANGED
|
@@ -441,8 +441,7 @@ function untrack(fn) {
|
|
|
441
441
|
Listener = listener;
|
|
442
442
|
return result;
|
|
443
443
|
}
|
|
444
|
-
function on(deps, fn,
|
|
445
|
-
options) {
|
|
444
|
+
function on(deps, fn, options) {
|
|
446
445
|
const isArray = Array.isArray(deps);
|
|
447
446
|
let prevInput;
|
|
448
447
|
let defer = options && options.defer;
|
|
@@ -516,6 +515,7 @@ function startTransition(fn) {
|
|
|
516
515
|
t.running = true;
|
|
517
516
|
}
|
|
518
517
|
batch(fn);
|
|
518
|
+
Listener = Owner = null;
|
|
519
519
|
return t ? t.done : undefined;
|
|
520
520
|
});
|
|
521
521
|
}
|
package/dist/dev.js
CHANGED
|
@@ -437,8 +437,7 @@ function untrack(fn) {
|
|
|
437
437
|
Listener = listener;
|
|
438
438
|
return result;
|
|
439
439
|
}
|
|
440
|
-
function on(deps, fn,
|
|
441
|
-
options) {
|
|
440
|
+
function on(deps, fn, options) {
|
|
442
441
|
const isArray = Array.isArray(deps);
|
|
443
442
|
let prevInput;
|
|
444
443
|
let defer = options && options.defer;
|
|
@@ -512,6 +511,7 @@ function startTransition(fn) {
|
|
|
512
511
|
t.running = true;
|
|
513
512
|
}
|
|
514
513
|
batch(fn);
|
|
514
|
+
Listener = Owner = null;
|
|
515
515
|
return t ? t.done : undefined;
|
|
516
516
|
});
|
|
517
517
|
}
|
package/dist/server.cjs
CHANGED
|
@@ -398,7 +398,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
398
398
|
value
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
|
-
if (p && "then" in p) {
|
|
401
|
+
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
402
402
|
read.loading = true;
|
|
403
403
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
404
404
|
return p.then(res => {
|
|
@@ -415,6 +415,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
417
|
ctx.resources[id].data = p;
|
|
418
|
+
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
418
419
|
p = null;
|
|
419
420
|
return ctx.resources[id].data;
|
|
420
421
|
}
|
package/dist/server.js
CHANGED
|
@@ -394,7 +394,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
394
394
|
value
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
|
-
if (p && "then" in p) {
|
|
397
|
+
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
398
398
|
read.loading = true;
|
|
399
399
|
if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
|
|
400
400
|
return p.then(res => {
|
|
@@ -411,6 +411,7 @@ function createResource(source, fetcher, options = {}) {
|
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
ctx.resources[id].data = p;
|
|
414
|
+
if (ctx.writeResource) ctx.writeResource(id, p);
|
|
414
415
|
p = null;
|
|
415
416
|
return ctx.resources[id].data;
|
|
416
417
|
}
|
package/dist/solid.cjs
CHANGED
|
@@ -438,8 +438,7 @@ function untrack(fn) {
|
|
|
438
438
|
Listener = listener;
|
|
439
439
|
return result;
|
|
440
440
|
}
|
|
441
|
-
function on(deps, fn,
|
|
442
|
-
options) {
|
|
441
|
+
function on(deps, fn, options) {
|
|
443
442
|
const isArray = Array.isArray(deps);
|
|
444
443
|
let prevInput;
|
|
445
444
|
let defer = options && options.defer;
|
|
@@ -513,6 +512,7 @@ function startTransition(fn) {
|
|
|
513
512
|
t.running = true;
|
|
514
513
|
}
|
|
515
514
|
batch(fn);
|
|
515
|
+
Listener = Owner = null;
|
|
516
516
|
return t ? t.done : undefined;
|
|
517
517
|
});
|
|
518
518
|
}
|
package/dist/solid.js
CHANGED
|
@@ -434,8 +434,7 @@ function untrack(fn) {
|
|
|
434
434
|
Listener = listener;
|
|
435
435
|
return result;
|
|
436
436
|
}
|
|
437
|
-
function on(deps, fn,
|
|
438
|
-
options) {
|
|
437
|
+
function on(deps, fn, options) {
|
|
439
438
|
const isArray = Array.isArray(deps);
|
|
440
439
|
let prevInput;
|
|
441
440
|
let defer = options && options.defer;
|
|
@@ -509,6 +508,7 @@ function startTransition(fn) {
|
|
|
509
508
|
t.running = true;
|
|
510
509
|
}
|
|
511
510
|
batch(fn);
|
|
511
|
+
Listener = Owner = null;
|
|
512
512
|
return t ? t.done : undefined;
|
|
513
513
|
});
|
|
514
514
|
}
|
package/h/dist/h.cjs
CHANGED
|
@@ -46,7 +46,16 @@ function createHyperScript(r) {
|
|
|
46
46
|
}
|
|
47
47
|
const d = Object.getOwnPropertyDescriptors(props);
|
|
48
48
|
for (const k in d) {
|
|
49
|
-
if (
|
|
49
|
+
if (Array.isArray(d[k].value)) {
|
|
50
|
+
const list = d[k].value;
|
|
51
|
+
props[k] = () => {
|
|
52
|
+
for (let i = 0; i < list.length; i++) {
|
|
53
|
+
while (list[i][$ELEMENT]) list[i] = list[i]();
|
|
54
|
+
}
|
|
55
|
+
return list;
|
|
56
|
+
};
|
|
57
|
+
r.dynamicProperty(props, k);
|
|
58
|
+
} else if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
|
|
50
59
|
}
|
|
51
60
|
e = r.createComponent(l, props);
|
|
52
61
|
args = [];
|
package/h/dist/h.js
CHANGED
|
@@ -44,7 +44,16 @@ function createHyperScript(r) {
|
|
|
44
44
|
}
|
|
45
45
|
const d = Object.getOwnPropertyDescriptors(props);
|
|
46
46
|
for (const k in d) {
|
|
47
|
-
if (
|
|
47
|
+
if (Array.isArray(d[k].value)) {
|
|
48
|
+
const list = d[k].value;
|
|
49
|
+
props[k] = () => {
|
|
50
|
+
for (let i = 0; i < list.length; i++) {
|
|
51
|
+
while (list[i][$ELEMENT]) list[i] = list[i]();
|
|
52
|
+
}
|
|
53
|
+
return list;
|
|
54
|
+
};
|
|
55
|
+
r.dynamicProperty(props, k);
|
|
56
|
+
} else if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
|
|
48
57
|
}
|
|
49
58
|
e = r.createComponent(l, props);
|
|
50
59
|
args = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.4.0
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"clean": "rimraf dist/ types/ coverage/ store/dist/ store/types/ web/dist/ web/types/ h/dist/ h/types/ h/jsx-runtime/dist h/jsx-runtime/types html/dist/ html/types/",
|
|
130
130
|
"build": "npm-run-all -cnl build:*",
|
|
131
131
|
"build:link": "symlink-dir . node_modules/solid-js",
|
|
132
|
-
"build:js": "ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./src/jsx.d.ts && ncp ../../node_modules/dom-expressions/src/jsx-
|
|
132
|
+
"build:js": "ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./src/jsx.d.ts && ncp ../../node_modules/dom-expressions/src/jsx-h.d.ts ./h/jsx-runtime/src/jsx.d.ts && rollup -c",
|
|
133
133
|
"build:types": "tsc --project ./tsconfig.build.json",
|
|
134
134
|
"build:types-store": "tsc --project ./store/tsconfig.build.json && tsconfig-replace-paths --project ./store/tsconfig.types.json",
|
|
135
135
|
"build:types-web": "tsc --project ./web/tsconfig.build.json && tsconfig-replace-paths --project ./web/tsconfig.types.json",
|
|
@@ -151,5 +151,5 @@
|
|
|
151
151
|
"compiler",
|
|
152
152
|
"performance"
|
|
153
153
|
],
|
|
154
|
-
"gitHead": "
|
|
154
|
+
"gitHead": "6c9e976c002d3ae327ff509213a091ce79f7582a"
|
|
155
155
|
}
|
package/store/dist/dev.cjs
CHANGED
|
@@ -63,6 +63,9 @@ function getDataNodes(target) {
|
|
|
63
63
|
});
|
|
64
64
|
return nodes;
|
|
65
65
|
}
|
|
66
|
+
function getDataNode(nodes, property, value) {
|
|
67
|
+
return nodes[property] || (nodes[property] = createDataNode(value, true));
|
|
68
|
+
}
|
|
66
69
|
function proxyDescriptor(target, property) {
|
|
67
70
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
68
71
|
if (!desc || desc.get || !desc.configurable || property === solidJs.$PROXY || property === $NODE || property === $NAME) return desc;
|
|
@@ -81,8 +84,10 @@ function ownKeys(target) {
|
|
|
81
84
|
trackSelf(target);
|
|
82
85
|
return Reflect.ownKeys(target);
|
|
83
86
|
}
|
|
84
|
-
function createDataNode() {
|
|
85
|
-
const [s, set] = solidJs.createSignal(
|
|
87
|
+
function createDataNode(value, equals) {
|
|
88
|
+
const [s, set] = solidJs.createSignal(value, equals ? {
|
|
89
|
+
internal: true
|
|
90
|
+
} : {
|
|
86
91
|
equals: false,
|
|
87
92
|
internal: true
|
|
88
93
|
});
|
|
@@ -93,12 +98,14 @@ const proxyTraps$1 = {
|
|
|
93
98
|
get(target, property, receiver) {
|
|
94
99
|
if (property === $RAW) return target;
|
|
95
100
|
if (property === solidJs.$PROXY) return receiver;
|
|
96
|
-
const value = target[property];
|
|
97
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
98
101
|
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
const nodes = getDataNodes(target);
|
|
103
|
+
const tracked = nodes[property];
|
|
104
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
105
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
106
|
+
if (!tracked) {
|
|
107
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
108
|
+
if (solidJs.getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();
|
|
102
109
|
}
|
|
103
110
|
return isWrappable(value) ? wrap$1(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
104
111
|
},
|
|
@@ -115,15 +122,15 @@ const proxyTraps$1 = {
|
|
|
115
122
|
};
|
|
116
123
|
function setProperty(state, property, value) {
|
|
117
124
|
if (state[property] === value) return;
|
|
118
|
-
const
|
|
125
|
+
const prev = state[property];
|
|
119
126
|
const len = state.length;
|
|
120
127
|
if (value === undefined) {
|
|
121
128
|
delete state[property];
|
|
122
129
|
} else state[property] = value;
|
|
123
130
|
let nodes = getDataNodes(state),
|
|
124
131
|
node;
|
|
125
|
-
(node = nodes
|
|
126
|
-
if (
|
|
132
|
+
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
133
|
+
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
127
134
|
(node = nodes._) && node.$();
|
|
128
135
|
}
|
|
129
136
|
function mergeStoreNode(state, value) {
|
|
@@ -213,14 +220,17 @@ const proxyTraps = {
|
|
|
213
220
|
get(target, property, receiver) {
|
|
214
221
|
if (property === $RAW) return target;
|
|
215
222
|
if (property === solidJs.$PROXY) return receiver;
|
|
216
|
-
const value = target[property];
|
|
217
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
218
223
|
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
+
const nodes = getDataNodes(target);
|
|
225
|
+
const tracked = nodes[property];
|
|
226
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
227
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
228
|
+
if (!tracked) {
|
|
229
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
230
|
+
const isFunction = typeof value !== "function";
|
|
231
|
+
if (solidJs.getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
|
|
232
|
+
return (...args) => solidJs.batch(() => Array.prototype[property].apply(receiver, args));
|
|
233
|
+
}
|
|
224
234
|
}
|
|
225
235
|
return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
226
236
|
},
|
package/store/dist/dev.js
CHANGED
|
@@ -59,6 +59,9 @@ function getDataNodes(target) {
|
|
|
59
59
|
});
|
|
60
60
|
return nodes;
|
|
61
61
|
}
|
|
62
|
+
function getDataNode(nodes, property, value) {
|
|
63
|
+
return nodes[property] || (nodes[property] = createDataNode(value, true));
|
|
64
|
+
}
|
|
62
65
|
function proxyDescriptor(target, property) {
|
|
63
66
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
64
67
|
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE || property === $NAME) return desc;
|
|
@@ -77,8 +80,10 @@ function ownKeys(target) {
|
|
|
77
80
|
trackSelf(target);
|
|
78
81
|
return Reflect.ownKeys(target);
|
|
79
82
|
}
|
|
80
|
-
function createDataNode() {
|
|
81
|
-
const [s, set] = createSignal(
|
|
83
|
+
function createDataNode(value, equals) {
|
|
84
|
+
const [s, set] = createSignal(value, equals ? {
|
|
85
|
+
internal: true
|
|
86
|
+
} : {
|
|
82
87
|
equals: false,
|
|
83
88
|
internal: true
|
|
84
89
|
});
|
|
@@ -89,12 +94,14 @@ const proxyTraps$1 = {
|
|
|
89
94
|
get(target, property, receiver) {
|
|
90
95
|
if (property === $RAW) return target;
|
|
91
96
|
if (property === $PROXY) return receiver;
|
|
92
|
-
const value = target[property];
|
|
93
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
94
97
|
if (property === $TRACK) return trackSelf(target);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
const nodes = getDataNodes(target);
|
|
99
|
+
const tracked = nodes[property];
|
|
100
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
101
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
102
|
+
if (!tracked) {
|
|
103
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
104
|
+
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();
|
|
98
105
|
}
|
|
99
106
|
return isWrappable(value) ? wrap$1(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
100
107
|
},
|
|
@@ -111,15 +118,15 @@ const proxyTraps$1 = {
|
|
|
111
118
|
};
|
|
112
119
|
function setProperty(state, property, value) {
|
|
113
120
|
if (state[property] === value) return;
|
|
114
|
-
const
|
|
121
|
+
const prev = state[property];
|
|
115
122
|
const len = state.length;
|
|
116
123
|
if (value === undefined) {
|
|
117
124
|
delete state[property];
|
|
118
125
|
} else state[property] = value;
|
|
119
126
|
let nodes = getDataNodes(state),
|
|
120
127
|
node;
|
|
121
|
-
(node = nodes
|
|
122
|
-
if (
|
|
128
|
+
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
129
|
+
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
123
130
|
(node = nodes._) && node.$();
|
|
124
131
|
}
|
|
125
132
|
function mergeStoreNode(state, value) {
|
|
@@ -209,14 +216,17 @@ const proxyTraps = {
|
|
|
209
216
|
get(target, property, receiver) {
|
|
210
217
|
if (property === $RAW) return target;
|
|
211
218
|
if (property === $PROXY) return receiver;
|
|
212
|
-
const value = target[property];
|
|
213
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
214
219
|
if (property === $TRACK) return trackSelf(target);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
const nodes = getDataNodes(target);
|
|
221
|
+
const tracked = nodes[property];
|
|
222
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
223
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
224
|
+
if (!tracked) {
|
|
225
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
226
|
+
const isFunction = typeof value !== "function";
|
|
227
|
+
if (getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
|
|
228
|
+
return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
|
|
229
|
+
}
|
|
220
230
|
}
|
|
221
231
|
return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
222
232
|
},
|
package/store/dist/store.cjs
CHANGED
|
@@ -60,6 +60,9 @@ function getDataNodes(target) {
|
|
|
60
60
|
});
|
|
61
61
|
return nodes;
|
|
62
62
|
}
|
|
63
|
+
function getDataNode(nodes, property, value) {
|
|
64
|
+
return nodes[property] || (nodes[property] = createDataNode(value, true));
|
|
65
|
+
}
|
|
63
66
|
function proxyDescriptor(target, property) {
|
|
64
67
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
65
68
|
if (!desc || desc.get || !desc.configurable || property === solidJs.$PROXY || property === $NODE || property === $NAME) return desc;
|
|
@@ -78,8 +81,10 @@ function ownKeys(target) {
|
|
|
78
81
|
trackSelf(target);
|
|
79
82
|
return Reflect.ownKeys(target);
|
|
80
83
|
}
|
|
81
|
-
function createDataNode() {
|
|
82
|
-
const [s, set] = solidJs.createSignal(
|
|
84
|
+
function createDataNode(value, equals) {
|
|
85
|
+
const [s, set] = solidJs.createSignal(value, equals ? {
|
|
86
|
+
internal: true
|
|
87
|
+
} : {
|
|
83
88
|
equals: false,
|
|
84
89
|
internal: true
|
|
85
90
|
});
|
|
@@ -90,12 +95,14 @@ const proxyTraps$1 = {
|
|
|
90
95
|
get(target, property, receiver) {
|
|
91
96
|
if (property === $RAW) return target;
|
|
92
97
|
if (property === solidJs.$PROXY) return receiver;
|
|
93
|
-
const value = target[property];
|
|
94
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
95
98
|
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
const nodes = getDataNodes(target);
|
|
100
|
+
const tracked = nodes[property];
|
|
101
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
102
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
103
|
+
if (!tracked) {
|
|
104
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
105
|
+
if (solidJs.getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();
|
|
99
106
|
}
|
|
100
107
|
return isWrappable(value) ? wrap$1(value) : value;
|
|
101
108
|
},
|
|
@@ -110,15 +117,15 @@ const proxyTraps$1 = {
|
|
|
110
117
|
};
|
|
111
118
|
function setProperty(state, property, value) {
|
|
112
119
|
if (state[property] === value) return;
|
|
113
|
-
const
|
|
120
|
+
const prev = state[property];
|
|
114
121
|
const len = state.length;
|
|
115
122
|
if (value === undefined) {
|
|
116
123
|
delete state[property];
|
|
117
124
|
} else state[property] = value;
|
|
118
125
|
let nodes = getDataNodes(state),
|
|
119
126
|
node;
|
|
120
|
-
(node = nodes
|
|
121
|
-
if (
|
|
127
|
+
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
128
|
+
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
122
129
|
(node = nodes._) && node.$();
|
|
123
130
|
}
|
|
124
131
|
function mergeStoreNode(state, value) {
|
|
@@ -201,14 +208,17 @@ const proxyTraps = {
|
|
|
201
208
|
get(target, property, receiver) {
|
|
202
209
|
if (property === $RAW) return target;
|
|
203
210
|
if (property === solidJs.$PROXY) return receiver;
|
|
204
|
-
const value = target[property];
|
|
205
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
206
211
|
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
const nodes = getDataNodes(target);
|
|
213
|
+
const tracked = nodes[property];
|
|
214
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
215
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
216
|
+
if (!tracked) {
|
|
217
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
218
|
+
const isFunction = typeof value !== "function";
|
|
219
|
+
if (solidJs.getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
|
|
220
|
+
return (...args) => solidJs.batch(() => Array.prototype[property].apply(receiver, args));
|
|
221
|
+
}
|
|
212
222
|
}
|
|
213
223
|
return isWrappable(value) ? wrap(value) : value;
|
|
214
224
|
},
|
package/store/dist/store.js
CHANGED
|
@@ -56,6 +56,9 @@ function getDataNodes(target) {
|
|
|
56
56
|
});
|
|
57
57
|
return nodes;
|
|
58
58
|
}
|
|
59
|
+
function getDataNode(nodes, property, value) {
|
|
60
|
+
return nodes[property] || (nodes[property] = createDataNode(value, true));
|
|
61
|
+
}
|
|
59
62
|
function proxyDescriptor(target, property) {
|
|
60
63
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
61
64
|
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE || property === $NAME) return desc;
|
|
@@ -74,8 +77,10 @@ function ownKeys(target) {
|
|
|
74
77
|
trackSelf(target);
|
|
75
78
|
return Reflect.ownKeys(target);
|
|
76
79
|
}
|
|
77
|
-
function createDataNode() {
|
|
78
|
-
const [s, set] = createSignal(
|
|
80
|
+
function createDataNode(value, equals) {
|
|
81
|
+
const [s, set] = createSignal(value, equals ? {
|
|
82
|
+
internal: true
|
|
83
|
+
} : {
|
|
79
84
|
equals: false,
|
|
80
85
|
internal: true
|
|
81
86
|
});
|
|
@@ -86,12 +91,14 @@ const proxyTraps$1 = {
|
|
|
86
91
|
get(target, property, receiver) {
|
|
87
92
|
if (property === $RAW) return target;
|
|
88
93
|
if (property === $PROXY) return receiver;
|
|
89
|
-
const value = target[property];
|
|
90
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
91
94
|
if (property === $TRACK) return trackSelf(target);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
const nodes = getDataNodes(target);
|
|
96
|
+
const tracked = nodes[property];
|
|
97
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
98
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
99
|
+
if (!tracked) {
|
|
100
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
101
|
+
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();
|
|
95
102
|
}
|
|
96
103
|
return isWrappable(value) ? wrap$1(value) : value;
|
|
97
104
|
},
|
|
@@ -106,15 +113,15 @@ const proxyTraps$1 = {
|
|
|
106
113
|
};
|
|
107
114
|
function setProperty(state, property, value) {
|
|
108
115
|
if (state[property] === value) return;
|
|
109
|
-
const
|
|
116
|
+
const prev = state[property];
|
|
110
117
|
const len = state.length;
|
|
111
118
|
if (value === undefined) {
|
|
112
119
|
delete state[property];
|
|
113
120
|
} else state[property] = value;
|
|
114
121
|
let nodes = getDataNodes(state),
|
|
115
122
|
node;
|
|
116
|
-
(node = nodes
|
|
117
|
-
if (
|
|
123
|
+
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
124
|
+
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
118
125
|
(node = nodes._) && node.$();
|
|
119
126
|
}
|
|
120
127
|
function mergeStoreNode(state, value) {
|
|
@@ -197,14 +204,17 @@ const proxyTraps = {
|
|
|
197
204
|
get(target, property, receiver) {
|
|
198
205
|
if (property === $RAW) return target;
|
|
199
206
|
if (property === $PROXY) return receiver;
|
|
200
|
-
const value = target[property];
|
|
201
|
-
if (property === $NODE || property === "__proto__") return value;
|
|
202
207
|
if (property === $TRACK) return trackSelf(target);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
const nodes = getDataNodes(target);
|
|
209
|
+
const tracked = nodes[property];
|
|
210
|
+
let value = tracked ? nodes[property]() : target[property];
|
|
211
|
+
if (property === $NODE || property === "__proto__") return value;
|
|
212
|
+
if (!tracked) {
|
|
213
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
214
|
+
const isFunction = typeof value !== "function";
|
|
215
|
+
if (getListener() && (isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getDataNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {
|
|
216
|
+
return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
|
|
217
|
+
}
|
|
208
218
|
}
|
|
209
219
|
return isWrappable(value) ? wrap(value) : value;
|
|
210
220
|
},
|
package/store/types/store.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Accessor } from "../..";
|
|
2
1
|
export declare const $RAW: unique symbol, $NODE: unique symbol, $NAME: unique symbol;
|
|
3
2
|
export declare type StoreNode = Record<PropertyKey, any>;
|
|
4
3
|
export declare namespace SolidStore {
|
|
@@ -10,12 +9,10 @@ export declare type Store<T> = DeepReadonly<T>;
|
|
|
10
9
|
export declare function isWrappable(obj: any): any;
|
|
11
10
|
export declare function unwrap<T extends StoreNode>(item: any, set?: Set<unknown>): T;
|
|
12
11
|
export declare function getDataNodes(target: StoreNode): any;
|
|
12
|
+
export declare function getDataNode(nodes: Record<string, any>, property: string | symbol, value: any): any;
|
|
13
13
|
export declare function proxyDescriptor(target: StoreNode, property: PropertyKey): PropertyDescriptor | undefined;
|
|
14
14
|
export declare function trackSelf(target: StoreNode): void;
|
|
15
15
|
export declare function ownKeys(target: StoreNode): (string | symbol)[];
|
|
16
|
-
export declare function createDataNode(): Accessor<void> & {
|
|
17
|
-
$: () => void;
|
|
18
|
-
};
|
|
19
16
|
export declare function setProperty(state: StoreNode, property: PropertyKey, value: any): void;
|
|
20
17
|
export declare function updatePath(current: StoreNode, path: any[], traversed?: PropertyKey[]): void;
|
|
21
18
|
export declare type DeepReadonly<T> = 0 extends 1 & T ? T : T extends NotWrappable ? T : {
|
|
@@ -72,7 +72,7 @@ export declare type RootFunction<T> = (dispose: () => void) => T;
|
|
|
72
72
|
*/
|
|
73
73
|
export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: Owner): T;
|
|
74
74
|
export declare type Accessor<T> = () => T;
|
|
75
|
-
export declare type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
|
|
75
|
+
export declare type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: (prev: T) => U) => U) & (<U extends T>(value: Exclude<U, Function>) => U) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
|
|
76
76
|
export declare type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
77
77
|
export interface SignalOptions<T> extends MemoOptions<T> {
|
|
78
78
|
internal?: boolean;
|
|
@@ -314,21 +314,25 @@ export declare function batch<T>(fn: Accessor<T>): T;
|
|
|
314
314
|
* @description https://www.solidjs.com/docs/latest/api#untrack
|
|
315
315
|
*/
|
|
316
316
|
export declare function untrack<T>(fn: Accessor<T>): T;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
/** @deprecated */
|
|
318
|
+
export declare type ReturnTypes<T> = T extends readonly Accessor<unknown>[] ? {
|
|
319
|
+
[K in keyof T]: T[K] extends Accessor<infer I> ? I : never;
|
|
320
|
+
} : T extends Accessor<infer I> ? I : never;
|
|
321
|
+
export declare type AccessorArray<T> = [...Extract<{
|
|
322
|
+
[K in keyof T]: Accessor<T[K]>;
|
|
323
|
+
}, readonly unknown[]>];
|
|
324
|
+
export declare type OnEffectFunction<S, Prev, Next extends Prev = Prev> = (input: S, prevInput: S | undefined, prev: Prev) => Next;
|
|
321
325
|
export interface OnOptions {
|
|
322
326
|
defer?: boolean;
|
|
323
327
|
}
|
|
324
328
|
/**
|
|
325
329
|
* on - make dependencies of a computation explicit
|
|
326
330
|
* ```typescript
|
|
327
|
-
* export function on<
|
|
328
|
-
* deps:
|
|
329
|
-
* fn: (input:
|
|
331
|
+
* export function on<S, U>(
|
|
332
|
+
* deps: Accessor<S> | AccessorArray<S>,
|
|
333
|
+
* fn: (input: S, prevInput: S | undefined, prevValue: U | undefined) => U,
|
|
330
334
|
* options?: { defer?: boolean } = {}
|
|
331
|
-
* ): (prevValue
|
|
335
|
+
* ): (prevValue: U | undefined) => U;
|
|
332
336
|
* ```
|
|
333
337
|
* @param deps list of reactive dependencies or a single reactive dependency
|
|
334
338
|
* @param fn computation on input; the current previous content(s) of input and the previous value are given as arguments and it returns a new value
|
|
@@ -347,7 +351,12 @@ export interface OnOptions {
|
|
|
347
351
|
*
|
|
348
352
|
* @description https://www.solidjs.com/docs/latest/api#on
|
|
349
353
|
*/
|
|
350
|
-
export declare function on<S extends
|
|
354
|
+
export declare function on<S, Next extends Prev, Prev = Next>(deps: AccessorArray<S> | Accessor<S>, fn: OnEffectFunction<S, undefined | NoInfer<Prev>, Next>, options?: OnOptions & {
|
|
355
|
+
defer?: false;
|
|
356
|
+
}): EffectFunction<undefined | NoInfer<Next>, NoInfer<Next>>;
|
|
357
|
+
export declare function on<S, Next extends Prev, Prev = Next>(deps: AccessorArray<S> | Accessor<S>, fn: OnEffectFunction<S, undefined | NoInfer<Prev>, Next>, options: OnOptions & {
|
|
358
|
+
defer: true;
|
|
359
|
+
}): EffectFunction<undefined | NoInfer<Next>>;
|
|
351
360
|
/**
|
|
352
361
|
* onMount - run an effect only after initial render on mount
|
|
353
362
|
* @param fn an effect that should run only once on mount
|
|
@@ -66,17 +66,23 @@ export declare type ComponentProps<T extends keyof JSX.IntrinsicElements | Compo
|
|
|
66
66
|
*/
|
|
67
67
|
export declare type Ref<T> = T | ((val: T) => void);
|
|
68
68
|
export declare function createComponent<T>(Comp: Component<T>, props: T): JSX.Element;
|
|
69
|
+
declare type Simplify<T> = T extends object ? {
|
|
70
|
+
[K in keyof T]: T[K];
|
|
71
|
+
} : T;
|
|
69
72
|
declare type UnboxLazy<T> = T extends () => infer U ? U : T;
|
|
70
|
-
declare type
|
|
71
|
-
[
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
declare type RequiredKeys<T> = keyof {
|
|
74
|
+
[K in keyof T as T extends {
|
|
75
|
+
[_ in K]: unknown;
|
|
76
|
+
} ? K : never]: 0;
|
|
77
|
+
};
|
|
78
|
+
declare type Override<T, U> = {
|
|
79
|
+
[K in keyof Omit<T, RequiredKeys<U>>]: T[K] | Exclude<U[K & keyof U], undefined>;
|
|
80
|
+
} & {
|
|
81
|
+
[K in keyof Omit<U, Exclude<keyof T, RequiredKeys<U>>>]: Exclude<U[K], undefined> | (undefined extends U[K] ? (K extends keyof T ? T[K] : undefined) : never);
|
|
82
|
+
};
|
|
83
|
+
export declare type MergeProps<T extends unknown[], Curr = {}> = T extends [infer Next, ...infer Rest] ? MergeProps<Rest, Next extends object ? (Next extends Function ? Curr : Override<Curr, UnboxLazy<Next>>) : Curr> : Simplify<Curr>;
|
|
84
|
+
export declare function mergeProps<T extends [unknown, ...unknown[]]>(...sources: T): MergeProps<T>;
|
|
85
|
+
export declare type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
|
|
80
86
|
...{
|
|
81
87
|
[P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : K[P];
|
|
82
88
|
},
|