solid-js 1.6.8 → 1.6.10
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 +144 -127
- package/dist/dev.js +144 -127
- package/dist/server.cjs +30 -25
- package/dist/server.js +30 -25
- package/dist/solid.cjs +130 -115
- package/dist/solid.js +130 -115
- package/h/dist/h.cjs +4 -4
- package/h/dist/h.js +4 -4
- package/h/types/hyperscript.d.ts +3 -3
- package/html/dist/html.cjs +34 -35
- package/html/dist/html.js +34 -35
- package/html/types/lit.d.ts +2 -2
- package/package.json +1 -1
- package/store/dist/dev.cjs +16 -16
- package/store/dist/dev.js +16 -16
- package/store/dist/server.cjs +3 -3
- package/store/dist/server.js +3 -3
- package/store/dist/store.cjs +16 -16
- package/store/dist/store.js +16 -16
- package/types/index.d.ts +1 -1
- package/types/reactive/observable.d.ts +8 -6
- package/types/reactive/signal.d.ts +12 -9
- package/types/render/Suspense.d.ts +2 -2
- package/types/render/flow.d.ts +6 -6
- package/universal/dist/dev.cjs +10 -10
- package/universal/dist/dev.js +10 -10
- package/universal/dist/universal.cjs +10 -10
- package/universal/dist/universal.js +10 -10
- package/web/dist/dev.cjs +29 -22
- package/web/dist/dev.js +29 -22
- package/web/dist/server.cjs +12 -20
- package/web/dist/server.js +12 -20
- package/web/dist/web.cjs +29 -22
- package/web/dist/web.js +29 -22
- package/web/types/index.d.ts +3 -3
package/html/dist/html.js
CHANGED
|
@@ -20,8 +20,7 @@ const lookup = {
|
|
|
20
20
|
track: true,
|
|
21
21
|
wbr: true
|
|
22
22
|
};
|
|
23
|
-
function parseTag(
|
|
24
|
-
tag) {
|
|
23
|
+
function parseTag( tag) {
|
|
25
24
|
const res = {
|
|
26
25
|
type: 'tag',
|
|
27
26
|
name: '',
|
|
@@ -181,14 +180,14 @@ function createHTML(r, {
|
|
|
181
180
|
};
|
|
182
181
|
function createTemplate(statics) {
|
|
183
182
|
let i = 0,
|
|
184
|
-
|
|
183
|
+
markup = "";
|
|
185
184
|
for (; i < statics.length - 1; i++) {
|
|
186
185
|
markup = markup + statics[i] + "<!--#-->";
|
|
187
186
|
}
|
|
188
187
|
markup = markup + statics[i];
|
|
189
188
|
markup = markup.replace(selfClosing, fullClosing).replace(/<(<!--#-->)/g, "<###").replace(/\.\.\.(<!--#-->)/g, "###").replace(attrSeeker, attrReplacer).replace(/>\n+\s*/g, ">").replace(/\n+\s*</g, "<").replace(/\s+</g, " <").replace(/>\s+/g, "> ");
|
|
190
189
|
const [html, code] = parseTemplate(parse(markup)),
|
|
191
|
-
|
|
190
|
+
templates = [];
|
|
192
191
|
for (let i = 0; i < html.length; i++) {
|
|
193
192
|
templates.push(document.createElement("template"));
|
|
194
193
|
templates[i].innerHTML = html[i];
|
|
@@ -211,8 +210,8 @@ function createHTML(r, {
|
|
|
211
210
|
}
|
|
212
211
|
function parseKeyValue(tag, name, value, isSVG, isCE, options) {
|
|
213
212
|
let expr = value === "###" ? `!doNotWrap ? exprs[${options.counter}]() : exprs[${options.counter++}]` : value.split("###").map((v, i) => i ? ` + (typeof exprs[${options.counter}] === "function" ? exprs[${options.counter}]() : exprs[${options.counter++}]) + "${v}"` : `"${v}"`).join(""),
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
parts,
|
|
214
|
+
namespace;
|
|
216
215
|
if ((parts = name.split(":")) && parts[1] && reservedNameSpaces.has(parts[0])) {
|
|
217
216
|
name = parts[1];
|
|
218
217
|
namespace = parts[0];
|
|
@@ -250,9 +249,9 @@ function createHTML(r, {
|
|
|
250
249
|
options.exprs.push(`exprs[${options.counter++}](${tag})`);
|
|
251
250
|
} else {
|
|
252
251
|
const childOptions = Object.assign({}, options, {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
252
|
+
exprs: []
|
|
253
|
+
}),
|
|
254
|
+
count = options.counter;
|
|
256
255
|
parseKeyValue(tag, name, value, isSVG, isCE, childOptions);
|
|
257
256
|
options.decl.push(`_fn${count} = (${value === "###" ? "doNotWrap" : ""}) => {\n${childOptions.exprs.join(";\n")};\n}`);
|
|
258
257
|
if (value === "###") {
|
|
@@ -318,11 +317,11 @@ function createHTML(r, {
|
|
|
318
317
|
function processComponent(node, options) {
|
|
319
318
|
let props = [];
|
|
320
319
|
const keys = Object.keys(node.attrs),
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
propGroups = [props],
|
|
321
|
+
componentIdentifier = options.counter++;
|
|
323
322
|
for (let i = 0; i < keys.length; i++) {
|
|
324
323
|
const name = keys[i],
|
|
325
|
-
|
|
324
|
+
value = node.attrs[name];
|
|
326
325
|
if (name === "###") {
|
|
327
326
|
propGroups.push(`exprs[${options.counter++}]`);
|
|
328
327
|
propGroups.push(props = []);
|
|
@@ -334,15 +333,15 @@ function createHTML(r, {
|
|
|
334
333
|
props.push(`children: () => exprs[${options.counter++}]`);
|
|
335
334
|
} else if (node.children.length) {
|
|
336
335
|
const children = {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
336
|
+
type: "fragment",
|
|
337
|
+
children: node.children
|
|
338
|
+
},
|
|
339
|
+
childOptions = Object.assign({}, options, {
|
|
340
|
+
first: true,
|
|
341
|
+
decl: [],
|
|
342
|
+
exprs: [],
|
|
343
|
+
parent: false
|
|
344
|
+
});
|
|
346
345
|
parseNode(children, childOptions);
|
|
347
346
|
props.push(`children: () => { ${childOptions.exprs.join(";\n")}}`);
|
|
348
347
|
options.templateId = childOptions.templateId;
|
|
@@ -408,7 +407,7 @@ function createHTML(r, {
|
|
|
408
407
|
let current = "";
|
|
409
408
|
for (let i = 0; i < keys.length; i++) {
|
|
410
409
|
const name = keys[i],
|
|
411
|
-
|
|
410
|
+
value = node.attrs[name];
|
|
412
411
|
if (value.includes("###")) {
|
|
413
412
|
let count = options.counter++;
|
|
414
413
|
current += `${name}: ${name !== "ref" ? `typeof exprs[${count}] === "function" ? exprs[${count}]() : ` : ""}exprs[${count}],`;
|
|
@@ -427,7 +426,7 @@ function createHTML(r, {
|
|
|
427
426
|
} else {
|
|
428
427
|
for (let i = 0; i < keys.length; i++) {
|
|
429
428
|
const name = keys[i],
|
|
430
|
-
|
|
429
|
+
value = node.attrs[name];
|
|
431
430
|
if (value.includes("###")) {
|
|
432
431
|
delete node.attrs[name];
|
|
433
432
|
parseAttribute(tag, name, value, isSVG, isCE, options);
|
|
@@ -459,18 +458,18 @@ function createHTML(r, {
|
|
|
459
458
|
}
|
|
460
459
|
function parseTemplate(nodes) {
|
|
461
460
|
const options = {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
461
|
+
path: "",
|
|
462
|
+
decl: [],
|
|
463
|
+
exprs: [],
|
|
464
|
+
delegatedEvents: new Set(),
|
|
465
|
+
counter: 0,
|
|
466
|
+
first: true,
|
|
467
|
+
multi: false,
|
|
468
|
+
templateId: 0,
|
|
469
|
+
templateNodes: []
|
|
470
|
+
},
|
|
471
|
+
id = uuid,
|
|
472
|
+
origNodes = nodes;
|
|
474
473
|
let toplevel;
|
|
475
474
|
if (nodes.length > 1) {
|
|
476
475
|
nodes = [{
|
package/html/types/lit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
2
|
interface Runtime {
|
|
3
3
|
effect<T>(fn: (prev?: T) => T, init?: T): any;
|
|
4
4
|
untrack<T>(fn: () => T): T;
|
|
@@ -29,7 +29,7 @@ interface Runtime {
|
|
|
29
29
|
SVGElements: Set<string>;
|
|
30
30
|
SVGNamespace: Record<string, string>;
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export type HTMLTag = {
|
|
33
33
|
(statics: TemplateStringsArray, ...args: unknown[]): Node | Node[];
|
|
34
34
|
};
|
|
35
35
|
export declare function createHTML(r: Runtime, { delegateEvents }?: {
|
package/package.json
CHANGED
package/store/dist/dev.cjs
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
|
|
5
5
|
const $RAW = Symbol("store-raw"),
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
$NODE = Symbol("store-node"),
|
|
7
|
+
$NAME = Symbol("store-name");
|
|
8
8
|
function wrap$1(value, name) {
|
|
9
9
|
let p = value[solidJs.$PROXY];
|
|
10
10
|
if (!p) {
|
|
@@ -13,7 +13,7 @@ function wrap$1(value, name) {
|
|
|
13
13
|
});
|
|
14
14
|
if (!Array.isArray(value)) {
|
|
15
15
|
const keys = Object.keys(value),
|
|
16
|
-
|
|
16
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
17
17
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
18
18
|
const prop = keys[i];
|
|
19
19
|
if (desc[prop].get) {
|
|
@@ -47,7 +47,7 @@ function unwrap(item, set = new Set()) {
|
|
|
47
47
|
} else {
|
|
48
48
|
if (Object.isFrozen(item)) item = Object.assign({}, item);else set.add(item);
|
|
49
49
|
const keys = Object.keys(item),
|
|
50
|
-
|
|
50
|
+
desc = Object.getOwnPropertyDescriptors(item);
|
|
51
51
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
52
52
|
prop = keys[i];
|
|
53
53
|
if (desc[prop].get) continue;
|
|
@@ -130,11 +130,11 @@ const proxyTraps$1 = {
|
|
|
130
130
|
function setProperty(state, property, value, deleting = false) {
|
|
131
131
|
if (!deleting && state[property] === value) return;
|
|
132
132
|
const prev = state[property],
|
|
133
|
-
|
|
133
|
+
len = state.length;
|
|
134
134
|
if (globalThis._$onStoreNodeUpdate) globalThis._$onStoreNodeUpdate(state, property, value, prev);
|
|
135
135
|
if (value === undefined) delete state[property];else state[property] = value;
|
|
136
136
|
let nodes = getDataNodes(state),
|
|
137
|
-
|
|
137
|
+
node;
|
|
138
138
|
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
139
139
|
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
140
140
|
(node = nodes._) && node.$();
|
|
@@ -152,7 +152,7 @@ function updateArray(current, next) {
|
|
|
152
152
|
if (Array.isArray(next)) {
|
|
153
153
|
if (current === next) return;
|
|
154
154
|
let i = 0,
|
|
155
|
-
|
|
155
|
+
len = next.length;
|
|
156
156
|
for (; i < len; i++) {
|
|
157
157
|
const value = next[i];
|
|
158
158
|
if (current[i] !== value) setProperty(current, i, value);
|
|
@@ -162,11 +162,11 @@ function updateArray(current, next) {
|
|
|
162
162
|
}
|
|
163
163
|
function updatePath(current, path, traversed = []) {
|
|
164
164
|
let part,
|
|
165
|
-
|
|
165
|
+
prev = current;
|
|
166
166
|
if (path.length > 1) {
|
|
167
167
|
part = path.shift();
|
|
168
168
|
const partType = typeof part,
|
|
169
|
-
|
|
169
|
+
isArray = Array.isArray(current);
|
|
170
170
|
if (Array.isArray(part)) {
|
|
171
171
|
for (let i = 0; i < part.length; i++) {
|
|
172
172
|
updatePath(current, [part[i]].concat(path), traversed);
|
|
@@ -277,7 +277,7 @@ function wrap(value, name) {
|
|
|
277
277
|
value: p = new Proxy(value, proxyTraps)
|
|
278
278
|
});
|
|
279
279
|
const keys = Object.keys(value),
|
|
280
|
-
|
|
280
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
281
281
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
282
282
|
const prop = keys[i];
|
|
283
283
|
if (desc[prop].get) {
|
|
@@ -288,7 +288,7 @@ function wrap(value, name) {
|
|
|
288
288
|
}
|
|
289
289
|
if (desc[prop].set) {
|
|
290
290
|
const og = desc[prop].set,
|
|
291
|
-
|
|
291
|
+
set = v => solidJs.batch(() => og.call(p, v));
|
|
292
292
|
Object.defineProperty(value, prop, {
|
|
293
293
|
set
|
|
294
294
|
});
|
|
@@ -334,7 +334,7 @@ function applyState(target, parent, property, merge, key) {
|
|
|
334
334
|
applyState(target[start], previous, start, merge, key);
|
|
335
335
|
}
|
|
336
336
|
const temp = new Array(target.length),
|
|
337
|
-
|
|
337
|
+
newIndices = new Map();
|
|
338
338
|
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
|
|
339
339
|
temp[newEnd] = previous[end];
|
|
340
340
|
}
|
|
@@ -390,10 +390,10 @@ function applyState(target, parent, property, merge, key) {
|
|
|
390
390
|
}
|
|
391
391
|
function reconcile(value, options = {}) {
|
|
392
392
|
const {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
merge,
|
|
394
|
+
key = "id"
|
|
395
|
+
} = options,
|
|
396
|
+
v = unwrap(value);
|
|
397
397
|
return state => {
|
|
398
398
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
399
399
|
const res = applyState(v, {
|
package/store/dist/dev.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { $PROXY, DEV as DEV$1, $TRACK, getListener, batch, createSignal } from 'solid-js';
|
|
2
2
|
|
|
3
3
|
const $RAW = Symbol("store-raw"),
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
$NODE = Symbol("store-node"),
|
|
5
|
+
$NAME = Symbol("store-name");
|
|
6
6
|
function wrap$1(value, name) {
|
|
7
7
|
let p = value[$PROXY];
|
|
8
8
|
if (!p) {
|
|
@@ -11,7 +11,7 @@ function wrap$1(value, name) {
|
|
|
11
11
|
});
|
|
12
12
|
if (!Array.isArray(value)) {
|
|
13
13
|
const keys = Object.keys(value),
|
|
14
|
-
|
|
14
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
15
15
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
16
16
|
const prop = keys[i];
|
|
17
17
|
if (desc[prop].get) {
|
|
@@ -45,7 +45,7 @@ function unwrap(item, set = new Set()) {
|
|
|
45
45
|
} else {
|
|
46
46
|
if (Object.isFrozen(item)) item = Object.assign({}, item);else set.add(item);
|
|
47
47
|
const keys = Object.keys(item),
|
|
48
|
-
|
|
48
|
+
desc = Object.getOwnPropertyDescriptors(item);
|
|
49
49
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
50
50
|
prop = keys[i];
|
|
51
51
|
if (desc[prop].get) continue;
|
|
@@ -128,11 +128,11 @@ const proxyTraps$1 = {
|
|
|
128
128
|
function setProperty(state, property, value, deleting = false) {
|
|
129
129
|
if (!deleting && state[property] === value) return;
|
|
130
130
|
const prev = state[property],
|
|
131
|
-
|
|
131
|
+
len = state.length;
|
|
132
132
|
if (globalThis._$onStoreNodeUpdate) globalThis._$onStoreNodeUpdate(state, property, value, prev);
|
|
133
133
|
if (value === undefined) delete state[property];else state[property] = value;
|
|
134
134
|
let nodes = getDataNodes(state),
|
|
135
|
-
|
|
135
|
+
node;
|
|
136
136
|
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
137
137
|
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
138
138
|
(node = nodes._) && node.$();
|
|
@@ -150,7 +150,7 @@ function updateArray(current, next) {
|
|
|
150
150
|
if (Array.isArray(next)) {
|
|
151
151
|
if (current === next) return;
|
|
152
152
|
let i = 0,
|
|
153
|
-
|
|
153
|
+
len = next.length;
|
|
154
154
|
for (; i < len; i++) {
|
|
155
155
|
const value = next[i];
|
|
156
156
|
if (current[i] !== value) setProperty(current, i, value);
|
|
@@ -160,11 +160,11 @@ function updateArray(current, next) {
|
|
|
160
160
|
}
|
|
161
161
|
function updatePath(current, path, traversed = []) {
|
|
162
162
|
let part,
|
|
163
|
-
|
|
163
|
+
prev = current;
|
|
164
164
|
if (path.length > 1) {
|
|
165
165
|
part = path.shift();
|
|
166
166
|
const partType = typeof part,
|
|
167
|
-
|
|
167
|
+
isArray = Array.isArray(current);
|
|
168
168
|
if (Array.isArray(part)) {
|
|
169
169
|
for (let i = 0; i < part.length; i++) {
|
|
170
170
|
updatePath(current, [part[i]].concat(path), traversed);
|
|
@@ -275,7 +275,7 @@ function wrap(value, name) {
|
|
|
275
275
|
value: p = new Proxy(value, proxyTraps)
|
|
276
276
|
});
|
|
277
277
|
const keys = Object.keys(value),
|
|
278
|
-
|
|
278
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
279
279
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
280
280
|
const prop = keys[i];
|
|
281
281
|
if (desc[prop].get) {
|
|
@@ -286,7 +286,7 @@ function wrap(value, name) {
|
|
|
286
286
|
}
|
|
287
287
|
if (desc[prop].set) {
|
|
288
288
|
const og = desc[prop].set,
|
|
289
|
-
|
|
289
|
+
set = v => batch(() => og.call(p, v));
|
|
290
290
|
Object.defineProperty(value, prop, {
|
|
291
291
|
set
|
|
292
292
|
});
|
|
@@ -332,7 +332,7 @@ function applyState(target, parent, property, merge, key) {
|
|
|
332
332
|
applyState(target[start], previous, start, merge, key);
|
|
333
333
|
}
|
|
334
334
|
const temp = new Array(target.length),
|
|
335
|
-
|
|
335
|
+
newIndices = new Map();
|
|
336
336
|
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
|
|
337
337
|
temp[newEnd] = previous[end];
|
|
338
338
|
}
|
|
@@ -388,10 +388,10 @@ function applyState(target, parent, property, merge, key) {
|
|
|
388
388
|
}
|
|
389
389
|
function reconcile(value, options = {}) {
|
|
390
390
|
const {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
391
|
+
merge,
|
|
392
|
+
key = "id"
|
|
393
|
+
} = options,
|
|
394
|
+
v = unwrap(value);
|
|
395
395
|
return state => {
|
|
396
396
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
397
397
|
const res = applyState(v, {
|
package/store/dist/server.cjs
CHANGED
|
@@ -25,7 +25,7 @@ function updateArray(current, next) {
|
|
|
25
25
|
if (Array.isArray(next)) {
|
|
26
26
|
if (current === next) return;
|
|
27
27
|
let i = 0,
|
|
28
|
-
|
|
28
|
+
len = next.length;
|
|
29
29
|
for (; i < len; i++) {
|
|
30
30
|
const value = next[i];
|
|
31
31
|
if (current[i] !== value) setProperty(current, i, value);
|
|
@@ -35,11 +35,11 @@ function updateArray(current, next) {
|
|
|
35
35
|
}
|
|
36
36
|
function updatePath(current, path, traversed = []) {
|
|
37
37
|
let part,
|
|
38
|
-
|
|
38
|
+
next = current;
|
|
39
39
|
if (path.length > 1) {
|
|
40
40
|
part = path.shift();
|
|
41
41
|
const partType = typeof part,
|
|
42
|
-
|
|
42
|
+
isArray = Array.isArray(current);
|
|
43
43
|
if (Array.isArray(part)) {
|
|
44
44
|
for (let i = 0; i < part.length; i++) {
|
|
45
45
|
updatePath(current, [part[i]].concat(path), traversed);
|
package/store/dist/server.js
CHANGED
|
@@ -23,7 +23,7 @@ function updateArray(current, next) {
|
|
|
23
23
|
if (Array.isArray(next)) {
|
|
24
24
|
if (current === next) return;
|
|
25
25
|
let i = 0,
|
|
26
|
-
|
|
26
|
+
len = next.length;
|
|
27
27
|
for (; i < len; i++) {
|
|
28
28
|
const value = next[i];
|
|
29
29
|
if (current[i] !== value) setProperty(current, i, value);
|
|
@@ -33,11 +33,11 @@ function updateArray(current, next) {
|
|
|
33
33
|
}
|
|
34
34
|
function updatePath(current, path, traversed = []) {
|
|
35
35
|
let part,
|
|
36
|
-
|
|
36
|
+
next = current;
|
|
37
37
|
if (path.length > 1) {
|
|
38
38
|
part = path.shift();
|
|
39
39
|
const partType = typeof part,
|
|
40
|
-
|
|
40
|
+
isArray = Array.isArray(current);
|
|
41
41
|
if (Array.isArray(part)) {
|
|
42
42
|
for (let i = 0; i < part.length; i++) {
|
|
43
43
|
updatePath(current, [part[i]].concat(path), traversed);
|
package/store/dist/store.cjs
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
|
|
5
5
|
const $RAW = Symbol("store-raw"),
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
$NODE = Symbol("store-node"),
|
|
7
|
+
$NAME = Symbol("store-name");
|
|
8
8
|
function wrap$1(value, name) {
|
|
9
9
|
let p = value[solidJs.$PROXY];
|
|
10
10
|
if (!p) {
|
|
@@ -13,7 +13,7 @@ function wrap$1(value, name) {
|
|
|
13
13
|
});
|
|
14
14
|
if (!Array.isArray(value)) {
|
|
15
15
|
const keys = Object.keys(value),
|
|
16
|
-
|
|
16
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
17
17
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
18
18
|
const prop = keys[i];
|
|
19
19
|
if (desc[prop].get) {
|
|
@@ -44,7 +44,7 @@ function unwrap(item, set = new Set()) {
|
|
|
44
44
|
} else {
|
|
45
45
|
if (Object.isFrozen(item)) item = Object.assign({}, item);else set.add(item);
|
|
46
46
|
const keys = Object.keys(item),
|
|
47
|
-
|
|
47
|
+
desc = Object.getOwnPropertyDescriptors(item);
|
|
48
48
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
49
49
|
prop = keys[i];
|
|
50
50
|
if (desc[prop].get) continue;
|
|
@@ -125,10 +125,10 @@ const proxyTraps$1 = {
|
|
|
125
125
|
function setProperty(state, property, value, deleting = false) {
|
|
126
126
|
if (!deleting && state[property] === value) return;
|
|
127
127
|
const prev = state[property],
|
|
128
|
-
|
|
128
|
+
len = state.length;
|
|
129
129
|
if (value === undefined) delete state[property];else state[property] = value;
|
|
130
130
|
let nodes = getDataNodes(state),
|
|
131
|
-
|
|
131
|
+
node;
|
|
132
132
|
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
133
133
|
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
134
134
|
(node = nodes._) && node.$();
|
|
@@ -146,7 +146,7 @@ function updateArray(current, next) {
|
|
|
146
146
|
if (Array.isArray(next)) {
|
|
147
147
|
if (current === next) return;
|
|
148
148
|
let i = 0,
|
|
149
|
-
|
|
149
|
+
len = next.length;
|
|
150
150
|
for (; i < len; i++) {
|
|
151
151
|
const value = next[i];
|
|
152
152
|
if (current[i] !== value) setProperty(current, i, value);
|
|
@@ -156,11 +156,11 @@ function updateArray(current, next) {
|
|
|
156
156
|
}
|
|
157
157
|
function updatePath(current, path, traversed = []) {
|
|
158
158
|
let part,
|
|
159
|
-
|
|
159
|
+
prev = current;
|
|
160
160
|
if (path.length > 1) {
|
|
161
161
|
part = path.shift();
|
|
162
162
|
const partType = typeof part,
|
|
163
|
-
|
|
163
|
+
isArray = Array.isArray(current);
|
|
164
164
|
if (Array.isArray(part)) {
|
|
165
165
|
for (let i = 0; i < part.length; i++) {
|
|
166
166
|
updatePath(current, [part[i]].concat(path), traversed);
|
|
@@ -264,7 +264,7 @@ function wrap(value, name) {
|
|
|
264
264
|
value: p = new Proxy(value, proxyTraps)
|
|
265
265
|
});
|
|
266
266
|
const keys = Object.keys(value),
|
|
267
|
-
|
|
267
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
268
268
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
269
269
|
const prop = keys[i];
|
|
270
270
|
if (desc[prop].get) {
|
|
@@ -275,7 +275,7 @@ function wrap(value, name) {
|
|
|
275
275
|
}
|
|
276
276
|
if (desc[prop].set) {
|
|
277
277
|
const og = desc[prop].set,
|
|
278
|
-
|
|
278
|
+
set = v => solidJs.batch(() => og.call(p, v));
|
|
279
279
|
Object.defineProperty(value, prop, {
|
|
280
280
|
set
|
|
281
281
|
});
|
|
@@ -311,7 +311,7 @@ function applyState(target, parent, property, merge, key) {
|
|
|
311
311
|
applyState(target[start], previous, start, merge, key);
|
|
312
312
|
}
|
|
313
313
|
const temp = new Array(target.length),
|
|
314
|
-
|
|
314
|
+
newIndices = new Map();
|
|
315
315
|
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
|
|
316
316
|
temp[newEnd] = previous[end];
|
|
317
317
|
}
|
|
@@ -367,10 +367,10 @@ function applyState(target, parent, property, merge, key) {
|
|
|
367
367
|
}
|
|
368
368
|
function reconcile(value, options = {}) {
|
|
369
369
|
const {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
370
|
+
merge,
|
|
371
|
+
key = "id"
|
|
372
|
+
} = options,
|
|
373
|
+
v = unwrap(value);
|
|
374
374
|
return state => {
|
|
375
375
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
376
376
|
const res = applyState(v, {
|
package/store/dist/store.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { $PROXY, $TRACK, getListener, batch, createSignal } from 'solid-js';
|
|
2
2
|
|
|
3
3
|
const $RAW = Symbol("store-raw"),
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
$NODE = Symbol("store-node"),
|
|
5
|
+
$NAME = Symbol("store-name");
|
|
6
6
|
function wrap$1(value, name) {
|
|
7
7
|
let p = value[$PROXY];
|
|
8
8
|
if (!p) {
|
|
@@ -11,7 +11,7 @@ function wrap$1(value, name) {
|
|
|
11
11
|
});
|
|
12
12
|
if (!Array.isArray(value)) {
|
|
13
13
|
const keys = Object.keys(value),
|
|
14
|
-
|
|
14
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
15
15
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
16
16
|
const prop = keys[i];
|
|
17
17
|
if (desc[prop].get) {
|
|
@@ -42,7 +42,7 @@ function unwrap(item, set = new Set()) {
|
|
|
42
42
|
} else {
|
|
43
43
|
if (Object.isFrozen(item)) item = Object.assign({}, item);else set.add(item);
|
|
44
44
|
const keys = Object.keys(item),
|
|
45
|
-
|
|
45
|
+
desc = Object.getOwnPropertyDescriptors(item);
|
|
46
46
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
47
47
|
prop = keys[i];
|
|
48
48
|
if (desc[prop].get) continue;
|
|
@@ -123,10 +123,10 @@ const proxyTraps$1 = {
|
|
|
123
123
|
function setProperty(state, property, value, deleting = false) {
|
|
124
124
|
if (!deleting && state[property] === value) return;
|
|
125
125
|
const prev = state[property],
|
|
126
|
-
|
|
126
|
+
len = state.length;
|
|
127
127
|
if (value === undefined) delete state[property];else state[property] = value;
|
|
128
128
|
let nodes = getDataNodes(state),
|
|
129
|
-
|
|
129
|
+
node;
|
|
130
130
|
if (node = getDataNode(nodes, property, prev)) node.$(() => value);
|
|
131
131
|
if (Array.isArray(state) && state.length !== len) (node = getDataNode(nodes, "length", len)) && node.$(state.length);
|
|
132
132
|
(node = nodes._) && node.$();
|
|
@@ -144,7 +144,7 @@ function updateArray(current, next) {
|
|
|
144
144
|
if (Array.isArray(next)) {
|
|
145
145
|
if (current === next) return;
|
|
146
146
|
let i = 0,
|
|
147
|
-
|
|
147
|
+
len = next.length;
|
|
148
148
|
for (; i < len; i++) {
|
|
149
149
|
const value = next[i];
|
|
150
150
|
if (current[i] !== value) setProperty(current, i, value);
|
|
@@ -154,11 +154,11 @@ function updateArray(current, next) {
|
|
|
154
154
|
}
|
|
155
155
|
function updatePath(current, path, traversed = []) {
|
|
156
156
|
let part,
|
|
157
|
-
|
|
157
|
+
prev = current;
|
|
158
158
|
if (path.length > 1) {
|
|
159
159
|
part = path.shift();
|
|
160
160
|
const partType = typeof part,
|
|
161
|
-
|
|
161
|
+
isArray = Array.isArray(current);
|
|
162
162
|
if (Array.isArray(part)) {
|
|
163
163
|
for (let i = 0; i < part.length; i++) {
|
|
164
164
|
updatePath(current, [part[i]].concat(path), traversed);
|
|
@@ -262,7 +262,7 @@ function wrap(value, name) {
|
|
|
262
262
|
value: p = new Proxy(value, proxyTraps)
|
|
263
263
|
});
|
|
264
264
|
const keys = Object.keys(value),
|
|
265
|
-
|
|
265
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
266
266
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
267
267
|
const prop = keys[i];
|
|
268
268
|
if (desc[prop].get) {
|
|
@@ -273,7 +273,7 @@ function wrap(value, name) {
|
|
|
273
273
|
}
|
|
274
274
|
if (desc[prop].set) {
|
|
275
275
|
const og = desc[prop].set,
|
|
276
|
-
|
|
276
|
+
set = v => batch(() => og.call(p, v));
|
|
277
277
|
Object.defineProperty(value, prop, {
|
|
278
278
|
set
|
|
279
279
|
});
|
|
@@ -309,7 +309,7 @@ function applyState(target, parent, property, merge, key) {
|
|
|
309
309
|
applyState(target[start], previous, start, merge, key);
|
|
310
310
|
}
|
|
311
311
|
const temp = new Array(target.length),
|
|
312
|
-
|
|
312
|
+
newIndices = new Map();
|
|
313
313
|
for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[start] && target[start] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {
|
|
314
314
|
temp[newEnd] = previous[end];
|
|
315
315
|
}
|
|
@@ -365,10 +365,10 @@ function applyState(target, parent, property, merge, key) {
|
|
|
365
365
|
}
|
|
366
366
|
function reconcile(value, options = {}) {
|
|
367
367
|
const {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
368
|
+
merge,
|
|
369
|
+
key = "id"
|
|
370
|
+
} = options,
|
|
371
|
+
v = unwrap(value);
|
|
372
372
|
return state => {
|
|
373
373
|
if (!isWrappable(state) || !isWrappable(v)) return v;
|
|
374
374
|
const res = applyState(v, {
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { $DEVCOMP, $PROXY, $TRACK, batch, children, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, enableExternalSource, enableScheduling, equalFn, getListener, getOwner, on, onCleanup, onError, onMount, runWithOwner, startTransition, untrack, useContext, useTransition } from "./reactive/signal.js";
|
|
2
|
-
export type { Accessor, AccessorArray, ChildrenReturn, Context, EffectFunction, InitializedResource, InitializedResourceOptions, InitializedResourceReturn, MemoOptions, NoInfer, OnEffectFunction, Owner, Resource, ResourceActions, ResourceFetcher, ResourceFetcherInfo, ResourceOptions, ResourceReturn, ResourceSource, ReturnTypes, Setter, Signal, SignalOptions } from "./reactive/signal.js";
|
|
2
|
+
export type { Accessor, AccessorArray, ChildrenReturn, Context, EffectFunction, EffectOptions, InitializedResource, InitializedResourceOptions, InitializedResourceReturn, MemoOptions, NoInfer, OnEffectFunction, OnOptions, Owner, Resource, ResourceActions, ResourceFetcher, ResourceFetcherInfo, ResourceOptions, ResourceReturn, ResourceSource, ReturnTypes, Setter, Signal, SignalOptions } from "./reactive/signal.js";
|
|
3
3
|
export * from "./reactive/observable.js";
|
|
4
4
|
export * from "./reactive/scheduler.js";
|
|
5
5
|
export * from "./reactive/array.js";
|
|
@@ -4,6 +4,12 @@ declare global {
|
|
|
4
4
|
readonly observable: symbol;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
+
interface Observable<T> {
|
|
8
|
+
subscribe(observer: ObservableObserver<T>): {
|
|
9
|
+
unsubscribe(): void;
|
|
10
|
+
};
|
|
11
|
+
[Symbol.observable](): Observable<T>;
|
|
12
|
+
}
|
|
7
13
|
export declare type ObservableObserver<T> = ((v: T) => void) | {
|
|
8
14
|
next?: (v: T) => void;
|
|
9
15
|
error?: (v: any) => void;
|
|
@@ -19,14 +25,10 @@ export declare type ObservableObserver<T> = ((v: T) => void) | {
|
|
|
19
25
|
* ```
|
|
20
26
|
* description https://www.solidjs.com/docs/latest/api#observable
|
|
21
27
|
*/
|
|
22
|
-
export declare function observable<T>(input: Accessor<T>):
|
|
23
|
-
subscribe(observer: ObservableObserver<T>): {
|
|
24
|
-
unsubscribe(): void;
|
|
25
|
-
};
|
|
26
|
-
[Symbol.observable](): any;
|
|
27
|
-
};
|
|
28
|
+
export declare function observable<T>(input: Accessor<T>): Observable<T>;
|
|
28
29
|
export declare function from<T>(producer: ((setter: Setter<T | undefined>) => () => void) | {
|
|
29
30
|
subscribe: (fn: (v: T) => void) => (() => void) | {
|
|
30
31
|
unsubscribe: () => void;
|
|
31
32
|
};
|
|
32
33
|
}): Accessor<T | undefined>;
|
|
34
|
+
export {};
|