solid-js 1.3.17 → 1.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.cjs +25 -24
- package/dist/dev.js +25 -24
- package/dist/server.cjs +0 -2
- package/dist/server.js +1 -2
- package/dist/solid.cjs +25 -24
- package/dist/solid.js +25 -24
- package/package.json +2 -2
- package/store/dist/dev.cjs +31 -28
- package/store/dist/dev.js +32 -29
- package/store/dist/store.cjs +31 -28
- package/store/dist/store.js +32 -29
- package/store/types/store.d.ts +1 -0
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +19 -5
- package/types/reactive/signal.d.ts +3 -4
- package/types/render/component.d.ts +6 -11
- package/types/server/index.d.ts +1 -1
- package/types/server/rendering.d.ts +1 -3
- package/web/dist/dev.cjs +5 -1
- package/web/dist/dev.js +5 -2
- package/web/dist/server.cjs +6 -5
- package/web/dist/server.js +6 -5
- package/web/dist/web.cjs +5 -1
- package/web/dist/web.js +5 -2
- package/web/types/client.d.ts +1 -0
package/store/dist/dev.cjs
CHANGED
|
@@ -71,11 +71,14 @@ function proxyDescriptor(target, property) {
|
|
|
71
71
|
desc.get = () => target[solidJs.$PROXY][property];
|
|
72
72
|
return desc;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function trackSelf(target) {
|
|
75
75
|
if (solidJs.getListener()) {
|
|
76
76
|
const nodes = getDataNodes(target);
|
|
77
77
|
(nodes._ || (nodes._ = createDataNode()))();
|
|
78
78
|
}
|
|
79
|
+
}
|
|
80
|
+
function ownKeys(target) {
|
|
81
|
+
trackSelf(target);
|
|
79
82
|
return Reflect.ownKeys(target);
|
|
80
83
|
}
|
|
81
84
|
function createDataNode() {
|
|
@@ -92,18 +95,12 @@ const proxyTraps$1 = {
|
|
|
92
95
|
if (property === solidJs.$PROXY) return receiver;
|
|
93
96
|
const value = target[property];
|
|
94
97
|
if (property === $NODE || property === "__proto__") return value;
|
|
95
|
-
|
|
98
|
+
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
96
99
|
if (solidJs.getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
node = nodes._ || (nodes._ = createDataNode());
|
|
100
|
-
node();
|
|
101
|
-
}
|
|
102
|
-
nodes = getDataNodes(target);
|
|
103
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
104
|
-
node();
|
|
100
|
+
const nodes = getDataNodes(target);
|
|
101
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
105
102
|
}
|
|
106
|
-
return
|
|
103
|
+
return isWrappable(value) ? wrap$1(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
107
104
|
},
|
|
108
105
|
set() {
|
|
109
106
|
console.warn("Cannot mutate a Store directly");
|
|
@@ -120,16 +117,14 @@ function setProperty(state, property, value) {
|
|
|
120
117
|
if (state[property] === value) return;
|
|
121
118
|
const array = Array.isArray(state);
|
|
122
119
|
const len = state.length;
|
|
123
|
-
|
|
124
|
-
const notify = array || isUndefined === property in state;
|
|
125
|
-
if (isUndefined) {
|
|
120
|
+
if (value === undefined) {
|
|
126
121
|
delete state[property];
|
|
127
122
|
} else state[property] = value;
|
|
128
123
|
let nodes = getDataNodes(state),
|
|
129
124
|
node;
|
|
130
125
|
(node = nodes[property]) && node.$();
|
|
131
126
|
if (array && state.length !== len) (node = nodes.length) && node.$();
|
|
132
|
-
|
|
127
|
+
(node = nodes._) && node.$();
|
|
133
128
|
}
|
|
134
129
|
function mergeStoreNode(state, value) {
|
|
135
130
|
const keys = Object.keys(value);
|
|
@@ -138,6 +133,15 @@ function mergeStoreNode(state, value) {
|
|
|
138
133
|
setProperty(state, key, value[key]);
|
|
139
134
|
}
|
|
140
135
|
}
|
|
136
|
+
function updateArray(current, next) {
|
|
137
|
+
let i = 0,
|
|
138
|
+
len = next.length;
|
|
139
|
+
for (; i < len; i++) {
|
|
140
|
+
const value = next[i];
|
|
141
|
+
if (current[i] !== value) setProperty(current, i, value);
|
|
142
|
+
}
|
|
143
|
+
setProperty(current, "length", len);
|
|
144
|
+
}
|
|
141
145
|
function updatePath(current, path, traversed = []) {
|
|
142
146
|
let part,
|
|
143
147
|
prev = current;
|
|
@@ -185,6 +189,7 @@ function updatePath(current, path, traversed = []) {
|
|
|
185
189
|
}
|
|
186
190
|
function createStore(store, options) {
|
|
187
191
|
const unwrappedStore = unwrap(store || {});
|
|
192
|
+
const isArray = Array.isArray(unwrappedStore);
|
|
188
193
|
if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function") throw new Error(`Unexpected type ${typeof unwrappedStore} received when initializing 'createStore'. Expected an object.`);
|
|
189
194
|
const wrappedStore = wrap$1(unwrappedStore, (options && options.name || solidJs.DEV.hashValue(unwrappedStore)));
|
|
190
195
|
{
|
|
@@ -194,7 +199,9 @@ function createStore(store, options) {
|
|
|
194
199
|
});
|
|
195
200
|
}
|
|
196
201
|
function setStore(...args) {
|
|
197
|
-
solidJs.batch(() =>
|
|
202
|
+
solidJs.batch(() => {
|
|
203
|
+
isArray && args.length === 1 ? updateArray(unwrappedStore, unwrap(args[0])) : updatePath(unwrappedStore, args);
|
|
204
|
+
});
|
|
198
205
|
}
|
|
199
206
|
return [wrappedStore, setStore];
|
|
200
207
|
}
|
|
@@ -205,18 +212,14 @@ const proxyTraps = {
|
|
|
205
212
|
if (property === solidJs.$PROXY) return receiver;
|
|
206
213
|
const value = target[property];
|
|
207
214
|
if (property === $NODE || property === "__proto__") return value;
|
|
208
|
-
|
|
215
|
+
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
209
216
|
if (solidJs.getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
nodes = getDataNodes(target);
|
|
216
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
217
|
-
node();
|
|
217
|
+
const nodes = getDataNodes(target);
|
|
218
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
219
|
+
} else if (value != null && value === Array.prototype[property]) {
|
|
220
|
+
return (...args) => solidJs.batch(() => Array.prototype[property].apply(target, args));
|
|
218
221
|
}
|
|
219
|
-
return
|
|
222
|
+
return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
220
223
|
},
|
|
221
224
|
set(target, property, value) {
|
|
222
225
|
setProperty(target, property, unwrap(value));
|
|
@@ -348,9 +351,9 @@ function reconcile(value, options = {}) {
|
|
|
348
351
|
v = unwrap(value);
|
|
349
352
|
return state => {
|
|
350
353
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
351
|
-
applyState(v, {
|
|
354
|
+
solidJs.batch(() => applyState(v, {
|
|
352
355
|
state
|
|
353
|
-
}, "state", merge, key);
|
|
356
|
+
}, "state", merge, key));
|
|
354
357
|
return state;
|
|
355
358
|
};
|
|
356
359
|
}
|
package/store/dist/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $PROXY, DEV, getListener, batch, createSignal } from 'solid-js';
|
|
1
|
+
import { $PROXY, DEV, $TRACK, getListener, batch, createSignal } from 'solid-js';
|
|
2
2
|
|
|
3
3
|
const $RAW = Symbol("store-raw"),
|
|
4
4
|
$NODE = Symbol("store-node"),
|
|
@@ -67,11 +67,14 @@ function proxyDescriptor(target, property) {
|
|
|
67
67
|
desc.get = () => target[$PROXY][property];
|
|
68
68
|
return desc;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function trackSelf(target) {
|
|
71
71
|
if (getListener()) {
|
|
72
72
|
const nodes = getDataNodes(target);
|
|
73
73
|
(nodes._ || (nodes._ = createDataNode()))();
|
|
74
74
|
}
|
|
75
|
+
}
|
|
76
|
+
function ownKeys(target) {
|
|
77
|
+
trackSelf(target);
|
|
75
78
|
return Reflect.ownKeys(target);
|
|
76
79
|
}
|
|
77
80
|
function createDataNode() {
|
|
@@ -88,18 +91,12 @@ const proxyTraps$1 = {
|
|
|
88
91
|
if (property === $PROXY) return receiver;
|
|
89
92
|
const value = target[property];
|
|
90
93
|
if (property === $NODE || property === "__proto__") return value;
|
|
91
|
-
|
|
94
|
+
if (property === $TRACK) return trackSelf(target);
|
|
92
95
|
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
node = nodes._ || (nodes._ = createDataNode());
|
|
96
|
-
node();
|
|
97
|
-
}
|
|
98
|
-
nodes = getDataNodes(target);
|
|
99
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
100
|
-
node();
|
|
96
|
+
const nodes = getDataNodes(target);
|
|
97
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
101
98
|
}
|
|
102
|
-
return
|
|
99
|
+
return isWrappable(value) ? wrap$1(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
103
100
|
},
|
|
104
101
|
set() {
|
|
105
102
|
console.warn("Cannot mutate a Store directly");
|
|
@@ -116,16 +113,14 @@ function setProperty(state, property, value) {
|
|
|
116
113
|
if (state[property] === value) return;
|
|
117
114
|
const array = Array.isArray(state);
|
|
118
115
|
const len = state.length;
|
|
119
|
-
|
|
120
|
-
const notify = array || isUndefined === property in state;
|
|
121
|
-
if (isUndefined) {
|
|
116
|
+
if (value === undefined) {
|
|
122
117
|
delete state[property];
|
|
123
118
|
} else state[property] = value;
|
|
124
119
|
let nodes = getDataNodes(state),
|
|
125
120
|
node;
|
|
126
121
|
(node = nodes[property]) && node.$();
|
|
127
122
|
if (array && state.length !== len) (node = nodes.length) && node.$();
|
|
128
|
-
|
|
123
|
+
(node = nodes._) && node.$();
|
|
129
124
|
}
|
|
130
125
|
function mergeStoreNode(state, value) {
|
|
131
126
|
const keys = Object.keys(value);
|
|
@@ -134,6 +129,15 @@ function mergeStoreNode(state, value) {
|
|
|
134
129
|
setProperty(state, key, value[key]);
|
|
135
130
|
}
|
|
136
131
|
}
|
|
132
|
+
function updateArray(current, next) {
|
|
133
|
+
let i = 0,
|
|
134
|
+
len = next.length;
|
|
135
|
+
for (; i < len; i++) {
|
|
136
|
+
const value = next[i];
|
|
137
|
+
if (current[i] !== value) setProperty(current, i, value);
|
|
138
|
+
}
|
|
139
|
+
setProperty(current, "length", len);
|
|
140
|
+
}
|
|
137
141
|
function updatePath(current, path, traversed = []) {
|
|
138
142
|
let part,
|
|
139
143
|
prev = current;
|
|
@@ -181,6 +185,7 @@ function updatePath(current, path, traversed = []) {
|
|
|
181
185
|
}
|
|
182
186
|
function createStore(store, options) {
|
|
183
187
|
const unwrappedStore = unwrap(store || {});
|
|
188
|
+
const isArray = Array.isArray(unwrappedStore);
|
|
184
189
|
if (typeof unwrappedStore !== "object" && typeof unwrappedStore !== "function") throw new Error(`Unexpected type ${typeof unwrappedStore} received when initializing 'createStore'. Expected an object.`);
|
|
185
190
|
const wrappedStore = wrap$1(unwrappedStore, (options && options.name || DEV.hashValue(unwrappedStore)));
|
|
186
191
|
{
|
|
@@ -190,7 +195,9 @@ function createStore(store, options) {
|
|
|
190
195
|
});
|
|
191
196
|
}
|
|
192
197
|
function setStore(...args) {
|
|
193
|
-
batch(() =>
|
|
198
|
+
batch(() => {
|
|
199
|
+
isArray && args.length === 1 ? updateArray(unwrappedStore, unwrap(args[0])) : updatePath(unwrappedStore, args);
|
|
200
|
+
});
|
|
194
201
|
}
|
|
195
202
|
return [wrappedStore, setStore];
|
|
196
203
|
}
|
|
@@ -201,18 +208,14 @@ const proxyTraps = {
|
|
|
201
208
|
if (property === $PROXY) return receiver;
|
|
202
209
|
const value = target[property];
|
|
203
210
|
if (property === $NODE || property === "__proto__") return value;
|
|
204
|
-
|
|
211
|
+
if (property === $TRACK) return trackSelf(target);
|
|
205
212
|
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
nodes = getDataNodes(target);
|
|
212
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
213
|
-
node();
|
|
213
|
+
const nodes = getDataNodes(target);
|
|
214
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
215
|
+
} else if (value != null && value === Array.prototype[property]) {
|
|
216
|
+
return (...args) => batch(() => Array.prototype[property].apply(target, args));
|
|
214
217
|
}
|
|
215
|
-
return
|
|
218
|
+
return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
216
219
|
},
|
|
217
220
|
set(target, property, value) {
|
|
218
221
|
setProperty(target, property, unwrap(value));
|
|
@@ -344,9 +347,9 @@ function reconcile(value, options = {}) {
|
|
|
344
347
|
v = unwrap(value);
|
|
345
348
|
return state => {
|
|
346
349
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
347
|
-
applyState(v, {
|
|
350
|
+
batch(() => applyState(v, {
|
|
348
351
|
state
|
|
349
|
-
}, "state", merge, key);
|
|
352
|
+
}, "state", merge, key));
|
|
350
353
|
return state;
|
|
351
354
|
};
|
|
352
355
|
}
|
package/store/dist/store.cjs
CHANGED
|
@@ -68,11 +68,14 @@ function proxyDescriptor(target, property) {
|
|
|
68
68
|
desc.get = () => target[solidJs.$PROXY][property];
|
|
69
69
|
return desc;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function trackSelf(target) {
|
|
72
72
|
if (solidJs.getListener()) {
|
|
73
73
|
const nodes = getDataNodes(target);
|
|
74
74
|
(nodes._ || (nodes._ = createDataNode()))();
|
|
75
75
|
}
|
|
76
|
+
}
|
|
77
|
+
function ownKeys(target) {
|
|
78
|
+
trackSelf(target);
|
|
76
79
|
return Reflect.ownKeys(target);
|
|
77
80
|
}
|
|
78
81
|
function createDataNode() {
|
|
@@ -89,18 +92,12 @@ const proxyTraps$1 = {
|
|
|
89
92
|
if (property === solidJs.$PROXY) return receiver;
|
|
90
93
|
const value = target[property];
|
|
91
94
|
if (property === $NODE || property === "__proto__") return value;
|
|
92
|
-
|
|
95
|
+
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
93
96
|
if (solidJs.getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
node = nodes._ || (nodes._ = createDataNode());
|
|
97
|
-
node();
|
|
98
|
-
}
|
|
99
|
-
nodes = getDataNodes(target);
|
|
100
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
101
|
-
node();
|
|
97
|
+
const nodes = getDataNodes(target);
|
|
98
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
102
99
|
}
|
|
103
|
-
return
|
|
100
|
+
return isWrappable(value) ? wrap$1(value) : value;
|
|
104
101
|
},
|
|
105
102
|
set() {
|
|
106
103
|
return true;
|
|
@@ -115,16 +112,14 @@ function setProperty(state, property, value) {
|
|
|
115
112
|
if (state[property] === value) return;
|
|
116
113
|
const array = Array.isArray(state);
|
|
117
114
|
const len = state.length;
|
|
118
|
-
|
|
119
|
-
const notify = array || isUndefined === property in state;
|
|
120
|
-
if (isUndefined) {
|
|
115
|
+
if (value === undefined) {
|
|
121
116
|
delete state[property];
|
|
122
117
|
} else state[property] = value;
|
|
123
118
|
let nodes = getDataNodes(state),
|
|
124
119
|
node;
|
|
125
120
|
(node = nodes[property]) && node.$();
|
|
126
121
|
if (array && state.length !== len) (node = nodes.length) && node.$();
|
|
127
|
-
|
|
122
|
+
(node = nodes._) && node.$();
|
|
128
123
|
}
|
|
129
124
|
function mergeStoreNode(state, value) {
|
|
130
125
|
const keys = Object.keys(value);
|
|
@@ -133,6 +128,15 @@ function mergeStoreNode(state, value) {
|
|
|
133
128
|
setProperty(state, key, value[key]);
|
|
134
129
|
}
|
|
135
130
|
}
|
|
131
|
+
function updateArray(current, next) {
|
|
132
|
+
let i = 0,
|
|
133
|
+
len = next.length;
|
|
134
|
+
for (; i < len; i++) {
|
|
135
|
+
const value = next[i];
|
|
136
|
+
if (current[i] !== value) setProperty(current, i, value);
|
|
137
|
+
}
|
|
138
|
+
setProperty(current, "length", len);
|
|
139
|
+
}
|
|
136
140
|
function updatePath(current, path, traversed = []) {
|
|
137
141
|
let part,
|
|
138
142
|
prev = current;
|
|
@@ -180,9 +184,12 @@ function updatePath(current, path, traversed = []) {
|
|
|
180
184
|
}
|
|
181
185
|
function createStore(store, options) {
|
|
182
186
|
const unwrappedStore = unwrap(store || {});
|
|
187
|
+
const isArray = Array.isArray(unwrappedStore);
|
|
183
188
|
const wrappedStore = wrap$1(unwrappedStore);
|
|
184
189
|
function setStore(...args) {
|
|
185
|
-
solidJs.batch(() =>
|
|
190
|
+
solidJs.batch(() => {
|
|
191
|
+
isArray && args.length === 1 ? updateArray(unwrappedStore, unwrap(args[0])) : updatePath(unwrappedStore, args);
|
|
192
|
+
});
|
|
186
193
|
}
|
|
187
194
|
return [wrappedStore, setStore];
|
|
188
195
|
}
|
|
@@ -193,18 +200,14 @@ const proxyTraps = {
|
|
|
193
200
|
if (property === solidJs.$PROXY) return receiver;
|
|
194
201
|
const value = target[property];
|
|
195
202
|
if (property === $NODE || property === "__proto__") return value;
|
|
196
|
-
|
|
203
|
+
if (property === solidJs.$TRACK) return trackSelf(target);
|
|
197
204
|
if (solidJs.getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
nodes = getDataNodes(target);
|
|
204
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
205
|
-
node();
|
|
205
|
+
const nodes = getDataNodes(target);
|
|
206
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
207
|
+
} else if (value != null && value === Array.prototype[property]) {
|
|
208
|
+
return (...args) => solidJs.batch(() => Array.prototype[property].apply(target, args));
|
|
206
209
|
}
|
|
207
|
-
return
|
|
210
|
+
return isWrappable(value) ? wrap(value) : value;
|
|
208
211
|
},
|
|
209
212
|
set(target, property, value) {
|
|
210
213
|
setProperty(target, property, unwrap(value));
|
|
@@ -326,9 +329,9 @@ function reconcile(value, options = {}) {
|
|
|
326
329
|
v = unwrap(value);
|
|
327
330
|
return state => {
|
|
328
331
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
329
|
-
applyState(v, {
|
|
332
|
+
solidJs.batch(() => applyState(v, {
|
|
330
333
|
state
|
|
331
|
-
}, "state", merge, key);
|
|
334
|
+
}, "state", merge, key));
|
|
332
335
|
return state;
|
|
333
336
|
};
|
|
334
337
|
}
|
package/store/dist/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $PROXY, getListener, batch, createSignal } from 'solid-js';
|
|
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"),
|
|
@@ -64,11 +64,14 @@ function proxyDescriptor(target, property) {
|
|
|
64
64
|
desc.get = () => target[$PROXY][property];
|
|
65
65
|
return desc;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function trackSelf(target) {
|
|
68
68
|
if (getListener()) {
|
|
69
69
|
const nodes = getDataNodes(target);
|
|
70
70
|
(nodes._ || (nodes._ = createDataNode()))();
|
|
71
71
|
}
|
|
72
|
+
}
|
|
73
|
+
function ownKeys(target) {
|
|
74
|
+
trackSelf(target);
|
|
72
75
|
return Reflect.ownKeys(target);
|
|
73
76
|
}
|
|
74
77
|
function createDataNode() {
|
|
@@ -85,18 +88,12 @@ const proxyTraps$1 = {
|
|
|
85
88
|
if (property === $PROXY) return receiver;
|
|
86
89
|
const value = target[property];
|
|
87
90
|
if (property === $NODE || property === "__proto__") return value;
|
|
88
|
-
|
|
91
|
+
if (property === $TRACK) return trackSelf(target);
|
|
89
92
|
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
node = nodes._ || (nodes._ = createDataNode());
|
|
93
|
-
node();
|
|
94
|
-
}
|
|
95
|
-
nodes = getDataNodes(target);
|
|
96
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
97
|
-
node();
|
|
93
|
+
const nodes = getDataNodes(target);
|
|
94
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
98
95
|
}
|
|
99
|
-
return
|
|
96
|
+
return isWrappable(value) ? wrap$1(value) : value;
|
|
100
97
|
},
|
|
101
98
|
set() {
|
|
102
99
|
return true;
|
|
@@ -111,16 +108,14 @@ function setProperty(state, property, value) {
|
|
|
111
108
|
if (state[property] === value) return;
|
|
112
109
|
const array = Array.isArray(state);
|
|
113
110
|
const len = state.length;
|
|
114
|
-
|
|
115
|
-
const notify = array || isUndefined === property in state;
|
|
116
|
-
if (isUndefined) {
|
|
111
|
+
if (value === undefined) {
|
|
117
112
|
delete state[property];
|
|
118
113
|
} else state[property] = value;
|
|
119
114
|
let nodes = getDataNodes(state),
|
|
120
115
|
node;
|
|
121
116
|
(node = nodes[property]) && node.$();
|
|
122
117
|
if (array && state.length !== len) (node = nodes.length) && node.$();
|
|
123
|
-
|
|
118
|
+
(node = nodes._) && node.$();
|
|
124
119
|
}
|
|
125
120
|
function mergeStoreNode(state, value) {
|
|
126
121
|
const keys = Object.keys(value);
|
|
@@ -129,6 +124,15 @@ function mergeStoreNode(state, value) {
|
|
|
129
124
|
setProperty(state, key, value[key]);
|
|
130
125
|
}
|
|
131
126
|
}
|
|
127
|
+
function updateArray(current, next) {
|
|
128
|
+
let i = 0,
|
|
129
|
+
len = next.length;
|
|
130
|
+
for (; i < len; i++) {
|
|
131
|
+
const value = next[i];
|
|
132
|
+
if (current[i] !== value) setProperty(current, i, value);
|
|
133
|
+
}
|
|
134
|
+
setProperty(current, "length", len);
|
|
135
|
+
}
|
|
132
136
|
function updatePath(current, path, traversed = []) {
|
|
133
137
|
let part,
|
|
134
138
|
prev = current;
|
|
@@ -176,9 +180,12 @@ function updatePath(current, path, traversed = []) {
|
|
|
176
180
|
}
|
|
177
181
|
function createStore(store, options) {
|
|
178
182
|
const unwrappedStore = unwrap(store || {});
|
|
183
|
+
const isArray = Array.isArray(unwrappedStore);
|
|
179
184
|
const wrappedStore = wrap$1(unwrappedStore);
|
|
180
185
|
function setStore(...args) {
|
|
181
|
-
batch(() =>
|
|
186
|
+
batch(() => {
|
|
187
|
+
isArray && args.length === 1 ? updateArray(unwrappedStore, unwrap(args[0])) : updatePath(unwrappedStore, args);
|
|
188
|
+
});
|
|
182
189
|
}
|
|
183
190
|
return [wrappedStore, setStore];
|
|
184
191
|
}
|
|
@@ -189,18 +196,14 @@ const proxyTraps = {
|
|
|
189
196
|
if (property === $PROXY) return receiver;
|
|
190
197
|
const value = target[property];
|
|
191
198
|
if (property === $NODE || property === "__proto__") return value;
|
|
192
|
-
|
|
199
|
+
if (property === $TRACK) return trackSelf(target);
|
|
193
200
|
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
nodes = getDataNodes(target);
|
|
200
|
-
node = nodes[property] || (nodes[property] = createDataNode());
|
|
201
|
-
node();
|
|
201
|
+
const nodes = getDataNodes(target);
|
|
202
|
+
(nodes[property] || (nodes[property] = createDataNode()))();
|
|
203
|
+
} else if (value != null && value === Array.prototype[property]) {
|
|
204
|
+
return (...args) => batch(() => Array.prototype[property].apply(target, args));
|
|
202
205
|
}
|
|
203
|
-
return
|
|
206
|
+
return isWrappable(value) ? wrap(value) : value;
|
|
204
207
|
},
|
|
205
208
|
set(target, property, value) {
|
|
206
209
|
setProperty(target, property, unwrap(value));
|
|
@@ -322,9 +325,9 @@ function reconcile(value, options = {}) {
|
|
|
322
325
|
v = unwrap(value);
|
|
323
326
|
return state => {
|
|
324
327
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
325
|
-
applyState(v, {
|
|
328
|
+
batch(() => applyState(v, {
|
|
326
329
|
state
|
|
327
|
-
}, "state", merge, key);
|
|
330
|
+
}, "state", merge, key));
|
|
328
331
|
return state;
|
|
329
332
|
};
|
|
330
333
|
}
|
package/store/types/store.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function isWrappable(obj: any): any;
|
|
|
11
11
|
export declare function unwrap<T extends StoreNode>(item: any, set?: Set<unknown>): T;
|
|
12
12
|
export declare function getDataNodes(target: StoreNode): any;
|
|
13
13
|
export declare function proxyDescriptor(target: StoreNode, property: PropertyKey): PropertyDescriptor | undefined;
|
|
14
|
+
export declare function trackSelf(target: StoreNode): void;
|
|
14
15
|
export declare function ownKeys(target: StoreNode): (string | symbol)[];
|
|
15
16
|
export declare function createDataNode(): Accessor<void> & {
|
|
16
17
|
$: () => void;
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition,
|
|
1
|
+
export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY, $TRACK } from "./reactive/signal";
|
|
2
2
|
export type { Accessor, Setter, Signal, Resource, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, Context, ReturnTypes } from "./reactive/signal";
|
|
3
3
|
export * from "./reactive/observable";
|
|
4
4
|
export * from "./reactive/scheduler";
|
package/types/jsx.d.ts
CHANGED
|
@@ -58,7 +58,11 @@ export namespace JSX {
|
|
|
58
58
|
};
|
|
59
59
|
$ServerOnly?: boolean;
|
|
60
60
|
}
|
|
61
|
+
type Accessor<T> = () => T
|
|
61
62
|
interface Directives {}
|
|
63
|
+
interface DirectiveFunctions {
|
|
64
|
+
[x: string]: (el: Element, accessor: Accessor<any>) => void;
|
|
65
|
+
}
|
|
62
66
|
interface ExplicitProperties {}
|
|
63
67
|
interface ExplicitAttributes {}
|
|
64
68
|
interface CustomEvents {}
|
|
@@ -66,6 +70,20 @@ export namespace JSX {
|
|
|
66
70
|
type DirectiveAttributes = {
|
|
67
71
|
[Key in keyof Directives as `use:${Key}`]?: Directives[Key];
|
|
68
72
|
};
|
|
73
|
+
type DirectiveFunctionAttributes<T> = {
|
|
74
|
+
[K in keyof DirectiveFunctions as string extends K ? never : `use:${K}`]?: DirectiveFunctions[K] extends (
|
|
75
|
+
el: infer E, // will be unknown if not provided
|
|
76
|
+
...rest: infer R // use rest so that we can check whether it's provided or not
|
|
77
|
+
) => void
|
|
78
|
+
? T extends E // everything extends unknown if E is unknown
|
|
79
|
+
? R extends [infer A] // check if has accessor provided
|
|
80
|
+
? A extends Accessor<infer V>
|
|
81
|
+
? V // it's an accessor
|
|
82
|
+
: never // it isn't, type error
|
|
83
|
+
: true // no accessor provided
|
|
84
|
+
: never // T is the wrong element
|
|
85
|
+
: never; // it isn't a function
|
|
86
|
+
};
|
|
69
87
|
type PropAttributes = {
|
|
70
88
|
[Key in keyof ExplicitProperties as `prop:${Key}`]?: ExplicitProperties[Key];
|
|
71
89
|
};
|
|
@@ -78,7 +96,7 @@ export namespace JSX {
|
|
|
78
96
|
type OnCaptureAttributes<T> = {
|
|
79
97
|
[Key in keyof CustomCaptureEvents as `oncapture:${Key}`]?: EventHandler<T, CustomCaptureEvents[Key]>;
|
|
80
98
|
}
|
|
81
|
-
interface DOMAttributes<T> extends CustomAttributes<T>, DirectiveAttributes, PropAttributes, AttrAttributes, OnAttributes<T>, OnCaptureAttributes<T> {
|
|
99
|
+
interface DOMAttributes<T> extends CustomAttributes<T>, DirectiveAttributes, DirectiveFunctionAttributes<T>, PropAttributes, AttrAttributes, OnAttributes<T>, OnCaptureAttributes<T> {
|
|
82
100
|
children?: Element;
|
|
83
101
|
innerHTML?: string;
|
|
84
102
|
innerText?: string | number;
|
|
@@ -1905,7 +1923,6 @@ export namespace JSX {
|
|
|
1905
1923
|
|
|
1906
1924
|
interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
|
|
1907
1925
|
accessKey?: string;
|
|
1908
|
-
className?: string;
|
|
1909
1926
|
class?: string;
|
|
1910
1927
|
contenteditable?: boolean | "inherit";
|
|
1911
1928
|
contextmenu?: string;
|
|
@@ -2206,7 +2223,6 @@ export namespace JSX {
|
|
|
2206
2223
|
name?: string;
|
|
2207
2224
|
}
|
|
2208
2225
|
interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
2209
|
-
htmlFor?: string;
|
|
2210
2226
|
for?: string;
|
|
2211
2227
|
form?: string;
|
|
2212
2228
|
}
|
|
@@ -2293,7 +2309,6 @@ export namespace JSX {
|
|
|
2293
2309
|
}
|
|
2294
2310
|
interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
2295
2311
|
form?: string;
|
|
2296
|
-
htmlFor?: string;
|
|
2297
2312
|
for?: string;
|
|
2298
2313
|
name?: string;
|
|
2299
2314
|
}
|
|
@@ -2467,7 +2482,6 @@ export namespace JSX {
|
|
|
2467
2482
|
}
|
|
2468
2483
|
interface StylableSVGAttributes {
|
|
2469
2484
|
class?: string;
|
|
2470
|
-
className?: string;
|
|
2471
2485
|
style?: CSSProperties | string;
|
|
2472
2486
|
}
|
|
2473
2487
|
interface TransformableSVGAttributes {
|
|
@@ -2,6 +2,7 @@ import { requestCallback } from "./scheduler";
|
|
|
2
2
|
import type { JSX } from "../jsx";
|
|
3
3
|
export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
4
4
|
export declare const $PROXY: unique symbol;
|
|
5
|
+
export declare const $TRACK: unique symbol;
|
|
5
6
|
export declare const $DEVCOMP: unique symbol;
|
|
6
7
|
export declare const NOTPENDING: {};
|
|
7
8
|
export declare var Owner: Owner | null;
|
|
@@ -70,7 +71,7 @@ export declare type RootFunction<T> = (dispose: () => void) => T;
|
|
|
70
71
|
*/
|
|
71
72
|
export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: Owner): T;
|
|
72
73
|
export declare type Accessor<T> = () => T;
|
|
73
|
-
export declare type Setter<T> = (undefined extends T ? (
|
|
74
|
+
export declare type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
|
|
74
75
|
export declare type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
75
76
|
export interface SignalOptions<T> extends MemoOptions<T> {
|
|
76
77
|
internal?: boolean;
|
|
@@ -198,6 +199,7 @@ export declare function createMemo<Next extends _Next, Init = undefined, _Next =
|
|
|
198
199
|
export interface Resource<T> extends Accessor<T> {
|
|
199
200
|
loading: boolean;
|
|
200
201
|
error: any;
|
|
202
|
+
latest: T | undefined;
|
|
201
203
|
}
|
|
202
204
|
export declare type ResourceActions<T> = {
|
|
203
205
|
mutate: Setter<T>;
|
|
@@ -213,12 +215,10 @@ export declare type ResourceFetcherInfo<T> = {
|
|
|
213
215
|
export declare type ResourceOptions<T> = undefined extends T ? {
|
|
214
216
|
initialValue?: T;
|
|
215
217
|
name?: string;
|
|
216
|
-
globalRefetch?: boolean;
|
|
217
218
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
218
219
|
} : {
|
|
219
220
|
initialValue: T;
|
|
220
221
|
name?: string;
|
|
221
|
-
globalRefetch?: boolean;
|
|
222
222
|
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
223
223
|
};
|
|
224
224
|
/**
|
|
@@ -250,7 +250,6 @@ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S,
|
|
|
250
250
|
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
251
251
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
252
252
|
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
253
|
-
export declare function refetchResources(info?: unknown): Promise<any[]>;
|
|
254
253
|
export interface DeferredOptions<T> {
|
|
255
254
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
256
255
|
name?: string;
|