solid-js 1.4.5 → 1.5.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 +113 -116
- package/dist/dev.js +113 -116
- package/dist/server.cjs +28 -23
- package/dist/server.js +28 -23
- package/dist/solid.cjs +113 -114
- package/dist/solid.js +113 -114
- package/h/jsx-runtime/types/jsx.d.ts +6 -1401
- package/html/dist/html.cjs +34 -59
- package/html/dist/html.js +34 -59
- package/package.json +2 -2
- package/store/dist/dev.cjs +41 -23
- package/store/dist/dev.js +41 -23
- package/store/dist/store.cjs +41 -23
- package/store/dist/store.js +41 -23
- package/store/types/store.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/jsx.d.ts +194 -1580
- package/types/reactive/observable.d.ts +7 -2
- package/types/reactive/signal.d.ts +42 -13
- package/types/render/component.d.ts +21 -6
- package/types/server/reactive.d.ts +1 -0
- package/types/server/rendering.d.ts +2 -2
- package/universal/types/universal.d.ts +3 -3
- package/web/dist/dev.cjs +6 -7
- package/web/dist/dev.js +6 -7
- package/web/dist/server.cjs +35 -69
- package/web/dist/server.js +35 -69
- package/web/dist/web.cjs +6 -7
- package/web/dist/web.js +6 -7
- package/web/types/index.d.ts +4 -5
- package/web/types/server-mock.d.ts +4 -2
package/html/dist/html.cjs
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var web = require('solid-js/web');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
lookup = {
|
|
5
|
+
const tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
|
|
6
|
+
const attrRE = /(?:\s(?<boolean>[^/\s><=]+?)(?=[\s/>]))|(?:(?<name>\S+?)(?:\s*=\s*(?:(['"])(?<quotedValue>[\s\S]*?)\3|(?<unquotedValue>[^\s>]+))))/g;
|
|
7
|
+
const lookup = {
|
|
9
8
|
area: true,
|
|
10
9
|
base: true,
|
|
11
10
|
br: true,
|
|
@@ -23,9 +22,9 @@ lookup = {
|
|
|
23
22
|
track: true,
|
|
24
23
|
wbr: true
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
res = {
|
|
25
|
+
function parseTag(
|
|
26
|
+
tag) {
|
|
27
|
+
const res = {
|
|
29
28
|
type: 'tag',
|
|
30
29
|
name: '',
|
|
31
30
|
voidElement: false,
|
|
@@ -47,64 +46,42 @@ parseTag = function (tag) {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
const reg = new RegExp(attrRE);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
result = reg.exec(tag);
|
|
53
|
-
if (result === null) {
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
if (!result[0].trim()) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (result[1]) {
|
|
60
|
-
const attr = result[1].trim();
|
|
61
|
-
let arr = [attr, ''];
|
|
62
|
-
if (attr.indexOf('=') > -1) {
|
|
63
|
-
arr = attr.split('=');
|
|
64
|
-
}
|
|
65
|
-
res.attrs[arr[0]] = arr[1];
|
|
66
|
-
reg.lastIndex--;
|
|
67
|
-
} else if (result[2]) {
|
|
68
|
-
res.attrs[result[2]] = result[3].trim().substring(1, result[3].length - 1);
|
|
69
|
-
}
|
|
49
|
+
for (const match of tag.matchAll(reg)) {
|
|
50
|
+
res.attrs[match[1] || match[2]] = match[4] || match[5] || '';
|
|
70
51
|
}
|
|
71
52
|
return res;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
content = html.slice(start, end === -1 ? void 0 : end);
|
|
53
|
+
}
|
|
54
|
+
function pushTextNode(list, html, start) {
|
|
55
|
+
const end = html.indexOf('<', start);
|
|
56
|
+
const content = html.slice(start, end === -1 ? void 0 : end);
|
|
77
57
|
if (!/^\s*$/.test(content)) {
|
|
78
58
|
list.push({
|
|
79
59
|
type: 'text',
|
|
80
60
|
content: content
|
|
81
61
|
});
|
|
82
62
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
content = tag.replace('<!--', '').replace('-->', '');
|
|
63
|
+
}
|
|
64
|
+
function pushCommentNode(list, tag) {
|
|
65
|
+
const content = tag.replace('<!--', '').replace('-->', '');
|
|
87
66
|
if (!/^\s*$/.test(content)) {
|
|
88
67
|
list.push({
|
|
89
68
|
type: 'comment',
|
|
90
69
|
content: content
|
|
91
70
|
});
|
|
92
71
|
}
|
|
93
|
-
}
|
|
72
|
+
}
|
|
94
73
|
function parse(html) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
nextChar = html.charAt(start);
|
|
107
|
-
parent = void 0;
|
|
74
|
+
const result = [];
|
|
75
|
+
let current = void 0;
|
|
76
|
+
let level = -1;
|
|
77
|
+
const arr = [];
|
|
78
|
+
const byTag = {};
|
|
79
|
+
html.replace(tagRE, (tag, index) => {
|
|
80
|
+
const isOpen = tag.charAt(1) !== '/';
|
|
81
|
+
const isComment = tag.slice(0, 4) === '<!--';
|
|
82
|
+
const start = index + tag.length;
|
|
83
|
+
const nextChar = html.charAt(start);
|
|
84
|
+
let parent = void 0;
|
|
108
85
|
if (isOpen && !isComment) {
|
|
109
86
|
level++;
|
|
110
87
|
current = parseTag(tag);
|
|
@@ -140,19 +117,17 @@ function parse(html) {
|
|
|
140
117
|
});
|
|
141
118
|
return result;
|
|
142
119
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
for (key in attrs) {
|
|
148
|
-
buff.push(key + '="' + attrs[key] + '"');
|
|
120
|
+
function attrString(attrs) {
|
|
121
|
+
const buff = [];
|
|
122
|
+
for (const key in attrs) {
|
|
123
|
+
buff.push(key + '="' + attrs[key].replace(/"/g, '"') + '"');
|
|
149
124
|
}
|
|
150
125
|
if (!buff.length) {
|
|
151
126
|
return '';
|
|
152
127
|
}
|
|
153
128
|
return ' ' + buff.join(' ');
|
|
154
|
-
}
|
|
155
|
-
|
|
129
|
+
}
|
|
130
|
+
function stringifier(buff, doc) {
|
|
156
131
|
switch (doc.type) {
|
|
157
132
|
case 'text':
|
|
158
133
|
return buff + doc.content;
|
|
@@ -165,7 +140,7 @@ stringifier = function (buff, doc) {
|
|
|
165
140
|
case 'comment':
|
|
166
141
|
return buff += '<!--' + doc.content + '-->';
|
|
167
142
|
}
|
|
168
|
-
}
|
|
143
|
+
}
|
|
169
144
|
function stringify(doc) {
|
|
170
145
|
return doc.reduce(function (token, rootEl) {
|
|
171
146
|
return token + stringifier('', rootEl);
|
package/html/dist/html.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { effect, style, insert, spread, createComponent, delegateEvents, classList, mergeProps, dynamicProperty, setAttribute, setAttributeNS, addEventListener, Aliases, PropAliases, Properties, ChildProperties, DelegatedEvents, SVGElements, SVGNamespace } from 'solid-js/web';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
lookup = {
|
|
3
|
+
const tagRE = /(?:<!--[\S\s]*?-->|<(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>)/g;
|
|
4
|
+
const attrRE = /(?:\s(?<boolean>[^/\s><=]+?)(?=[\s/>]))|(?:(?<name>\S+?)(?:\s*=\s*(?:(['"])(?<quotedValue>[\s\S]*?)\3|(?<unquotedValue>[^\s>]+))))/g;
|
|
5
|
+
const lookup = {
|
|
7
6
|
area: true,
|
|
8
7
|
base: true,
|
|
9
8
|
br: true,
|
|
@@ -21,9 +20,9 @@ lookup = {
|
|
|
21
20
|
track: true,
|
|
22
21
|
wbr: true
|
|
23
22
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
res = {
|
|
23
|
+
function parseTag(
|
|
24
|
+
tag) {
|
|
25
|
+
const res = {
|
|
27
26
|
type: 'tag',
|
|
28
27
|
name: '',
|
|
29
28
|
voidElement: false,
|
|
@@ -45,64 +44,42 @@ parseTag = function (tag) {
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
const reg = new RegExp(attrRE);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
result = reg.exec(tag);
|
|
51
|
-
if (result === null) {
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
if (!result[0].trim()) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (result[1]) {
|
|
58
|
-
const attr = result[1].trim();
|
|
59
|
-
let arr = [attr, ''];
|
|
60
|
-
if (attr.indexOf('=') > -1) {
|
|
61
|
-
arr = attr.split('=');
|
|
62
|
-
}
|
|
63
|
-
res.attrs[arr[0]] = arr[1];
|
|
64
|
-
reg.lastIndex--;
|
|
65
|
-
} else if (result[2]) {
|
|
66
|
-
res.attrs[result[2]] = result[3].trim().substring(1, result[3].length - 1);
|
|
67
|
-
}
|
|
47
|
+
for (const match of tag.matchAll(reg)) {
|
|
48
|
+
res.attrs[match[1] || match[2]] = match[4] || match[5] || '';
|
|
68
49
|
}
|
|
69
50
|
return res;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
content = html.slice(start, end === -1 ? void 0 : end);
|
|
51
|
+
}
|
|
52
|
+
function pushTextNode(list, html, start) {
|
|
53
|
+
const end = html.indexOf('<', start);
|
|
54
|
+
const content = html.slice(start, end === -1 ? void 0 : end);
|
|
75
55
|
if (!/^\s*$/.test(content)) {
|
|
76
56
|
list.push({
|
|
77
57
|
type: 'text',
|
|
78
58
|
content: content
|
|
79
59
|
});
|
|
80
60
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
content = tag.replace('<!--', '').replace('-->', '');
|
|
61
|
+
}
|
|
62
|
+
function pushCommentNode(list, tag) {
|
|
63
|
+
const content = tag.replace('<!--', '').replace('-->', '');
|
|
85
64
|
if (!/^\s*$/.test(content)) {
|
|
86
65
|
list.push({
|
|
87
66
|
type: 'comment',
|
|
88
67
|
content: content
|
|
89
68
|
});
|
|
90
69
|
}
|
|
91
|
-
}
|
|
70
|
+
}
|
|
92
71
|
function parse(html) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
nextChar = html.charAt(start);
|
|
105
|
-
parent = void 0;
|
|
72
|
+
const result = [];
|
|
73
|
+
let current = void 0;
|
|
74
|
+
let level = -1;
|
|
75
|
+
const arr = [];
|
|
76
|
+
const byTag = {};
|
|
77
|
+
html.replace(tagRE, (tag, index) => {
|
|
78
|
+
const isOpen = tag.charAt(1) !== '/';
|
|
79
|
+
const isComment = tag.slice(0, 4) === '<!--';
|
|
80
|
+
const start = index + tag.length;
|
|
81
|
+
const nextChar = html.charAt(start);
|
|
82
|
+
let parent = void 0;
|
|
106
83
|
if (isOpen && !isComment) {
|
|
107
84
|
level++;
|
|
108
85
|
current = parseTag(tag);
|
|
@@ -138,19 +115,17 @@ function parse(html) {
|
|
|
138
115
|
});
|
|
139
116
|
return result;
|
|
140
117
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
for (key in attrs) {
|
|
146
|
-
buff.push(key + '="' + attrs[key] + '"');
|
|
118
|
+
function attrString(attrs) {
|
|
119
|
+
const buff = [];
|
|
120
|
+
for (const key in attrs) {
|
|
121
|
+
buff.push(key + '="' + attrs[key].replace(/"/g, '"') + '"');
|
|
147
122
|
}
|
|
148
123
|
if (!buff.length) {
|
|
149
124
|
return '';
|
|
150
125
|
}
|
|
151
126
|
return ' ' + buff.join(' ');
|
|
152
|
-
}
|
|
153
|
-
|
|
127
|
+
}
|
|
128
|
+
function stringifier(buff, doc) {
|
|
154
129
|
switch (doc.type) {
|
|
155
130
|
case 'text':
|
|
156
131
|
return buff + doc.content;
|
|
@@ -163,7 +138,7 @@ stringifier = function (buff, doc) {
|
|
|
163
138
|
case 'comment':
|
|
164
139
|
return buff += '<!--' + doc.content + '-->';
|
|
165
140
|
}
|
|
166
|
-
}
|
|
141
|
+
}
|
|
167
142
|
function stringify(doc) {
|
|
168
143
|
return doc.reduce(function (token, rootEl) {
|
|
169
144
|
return token + stringifier('', rootEl);
|
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
|
+
"version": "1.5.0-beta.0",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -151,5 +151,5 @@
|
|
|
151
151
|
"compiler",
|
|
152
152
|
"performance"
|
|
153
153
|
],
|
|
154
|
-
"gitHead": "
|
|
154
|
+
"gitHead": "141a7b2c4f447d8894fa9382fca97e10b0626493"
|
|
155
155
|
}
|
package/store/dist/dev.cjs
CHANGED
|
@@ -13,15 +13,17 @@ function wrap$1(value, name) {
|
|
|
13
13
|
Object.defineProperty(value, solidJs.$PROXY, {
|
|
14
14
|
value: p = new Proxy(value, proxyTraps$1)
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
if (!Array.isArray(value)) {
|
|
17
|
+
const keys = Object.keys(value),
|
|
18
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
19
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
20
|
+
const prop = keys[i];
|
|
21
|
+
if (desc[prop].get) {
|
|
22
|
+
const get = desc[prop].get.bind(p);
|
|
23
|
+
Object.defineProperty(value, prop, {
|
|
24
|
+
get
|
|
25
|
+
});
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
if (name) Object.defineProperty(value, $NAME, {
|
|
@@ -65,7 +67,7 @@ function getDataNodes(target) {
|
|
|
65
67
|
return nodes;
|
|
66
68
|
}
|
|
67
69
|
function getDataNode(nodes, property, value) {
|
|
68
|
-
return nodes[property] || (nodes[property] = createDataNode(value
|
|
70
|
+
return nodes[property] || (nodes[property] = createDataNode(value));
|
|
69
71
|
}
|
|
70
72
|
function proxyDescriptor(target, property) {
|
|
71
73
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
@@ -85,10 +87,8 @@ function ownKeys(target) {
|
|
|
85
87
|
trackSelf(target);
|
|
86
88
|
return Reflect.ownKeys(target);
|
|
87
89
|
}
|
|
88
|
-
function createDataNode(value
|
|
89
|
-
const [s, set] = solidJs.createSignal(value,
|
|
90
|
-
internal: true
|
|
91
|
-
} : {
|
|
90
|
+
function createDataNode(value) {
|
|
91
|
+
const [s, set] = solidJs.createSignal(value, {
|
|
92
92
|
equals: false,
|
|
93
93
|
internal: true
|
|
94
94
|
});
|
|
@@ -99,9 +99,12 @@ const proxyTraps$1 = {
|
|
|
99
99
|
get(target, property, receiver) {
|
|
100
100
|
if (property === $RAW) return target;
|
|
101
101
|
if (property === solidJs.$PROXY) return receiver;
|
|
102
|
-
if (property === solidJs.$TRACK)
|
|
102
|
+
if (property === solidJs.$TRACK) {
|
|
103
|
+
trackSelf(target);
|
|
104
|
+
return receiver;
|
|
105
|
+
}
|
|
103
106
|
const nodes = getDataNodes(target);
|
|
104
|
-
const tracked = nodes
|
|
107
|
+
const tracked = nodes.hasOwnProperty(property);
|
|
105
108
|
let value = tracked ? nodes[property]() : target[property];
|
|
106
109
|
if (property === $NODE || property === "__proto__") return value;
|
|
107
110
|
if (!tracked) {
|
|
@@ -110,6 +113,12 @@ const proxyTraps$1 = {
|
|
|
110
113
|
}
|
|
111
114
|
return isWrappable(value) ? wrap$1(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
112
115
|
},
|
|
116
|
+
has(target, property) {
|
|
117
|
+
if (property === $RAW || property === solidJs.$PROXY || property === solidJs.$TRACK || property === $NODE || property === "__proto__") return true;
|
|
118
|
+
const tracked = getDataNodes(target)[property];
|
|
119
|
+
tracked && tracked();
|
|
120
|
+
return property in target;
|
|
121
|
+
},
|
|
113
122
|
set() {
|
|
114
123
|
console.warn("Cannot mutate a Store directly");
|
|
115
124
|
return true;
|
|
@@ -121,8 +130,8 @@ const proxyTraps$1 = {
|
|
|
121
130
|
ownKeys: ownKeys,
|
|
122
131
|
getOwnPropertyDescriptor: proxyDescriptor
|
|
123
132
|
};
|
|
124
|
-
function setProperty(state, property, value) {
|
|
125
|
-
if (state[property] === value) return;
|
|
133
|
+
function setProperty(state, property, value, deleting = false) {
|
|
134
|
+
if (!deleting && state[property] === value) return;
|
|
126
135
|
const prev = state[property];
|
|
127
136
|
const len = state.length;
|
|
128
137
|
if (value === undefined) {
|
|
@@ -223,9 +232,12 @@ const proxyTraps = {
|
|
|
223
232
|
get(target, property, receiver) {
|
|
224
233
|
if (property === $RAW) return target;
|
|
225
234
|
if (property === solidJs.$PROXY) return receiver;
|
|
226
|
-
if (property === solidJs.$TRACK)
|
|
235
|
+
if (property === solidJs.$TRACK) {
|
|
236
|
+
trackSelf(target);
|
|
237
|
+
return receiver;
|
|
238
|
+
}
|
|
227
239
|
const nodes = getDataNodes(target);
|
|
228
|
-
const tracked = nodes
|
|
240
|
+
const tracked = nodes.hasOwnProperty(property);
|
|
229
241
|
let value = tracked ? nodes[property]() : target[property];
|
|
230
242
|
if (property === $NODE || property === "__proto__") return value;
|
|
231
243
|
if (!tracked) {
|
|
@@ -237,12 +249,18 @@ const proxyTraps = {
|
|
|
237
249
|
}
|
|
238
250
|
return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
239
251
|
},
|
|
252
|
+
has(target, property) {
|
|
253
|
+
if (property === $RAW || property === solidJs.$PROXY || property === solidJs.$TRACK || property === $NODE || property === "__proto__") return true;
|
|
254
|
+
const tracked = getDataNodes(target)[property];
|
|
255
|
+
tracked && tracked();
|
|
256
|
+
return property in target;
|
|
257
|
+
},
|
|
240
258
|
set(target, property, value) {
|
|
241
|
-
setProperty(target, property, unwrap(value));
|
|
259
|
+
solidJs.batch(() => setProperty(target, property, unwrap(value)));
|
|
242
260
|
return true;
|
|
243
261
|
},
|
|
244
262
|
deleteProperty(target, property) {
|
|
245
|
-
setProperty(target, property, undefined);
|
|
263
|
+
solidJs.batch(() => setProperty(target, property, undefined, true));
|
|
246
264
|
return true;
|
|
247
265
|
},
|
|
248
266
|
ownKeys: ownKeys,
|
|
@@ -393,7 +411,7 @@ const setterTraps = {
|
|
|
393
411
|
return true;
|
|
394
412
|
},
|
|
395
413
|
deleteProperty(target, property) {
|
|
396
|
-
setProperty(target, property, undefined);
|
|
414
|
+
setProperty(target, property, undefined, true);
|
|
397
415
|
return true;
|
|
398
416
|
}
|
|
399
417
|
};
|
package/store/dist/dev.js
CHANGED
|
@@ -9,15 +9,17 @@ function wrap$1(value, name) {
|
|
|
9
9
|
Object.defineProperty(value, $PROXY, {
|
|
10
10
|
value: p = new Proxy(value, proxyTraps$1)
|
|
11
11
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
if (!Array.isArray(value)) {
|
|
13
|
+
const keys = Object.keys(value),
|
|
14
|
+
desc = Object.getOwnPropertyDescriptors(value);
|
|
15
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
16
|
+
const prop = keys[i];
|
|
17
|
+
if (desc[prop].get) {
|
|
18
|
+
const get = desc[prop].get.bind(p);
|
|
19
|
+
Object.defineProperty(value, prop, {
|
|
20
|
+
get
|
|
21
|
+
});
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
if (name) Object.defineProperty(value, $NAME, {
|
|
@@ -61,7 +63,7 @@ function getDataNodes(target) {
|
|
|
61
63
|
return nodes;
|
|
62
64
|
}
|
|
63
65
|
function getDataNode(nodes, property, value) {
|
|
64
|
-
return nodes[property] || (nodes[property] = createDataNode(value
|
|
66
|
+
return nodes[property] || (nodes[property] = createDataNode(value));
|
|
65
67
|
}
|
|
66
68
|
function proxyDescriptor(target, property) {
|
|
67
69
|
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
@@ -81,10 +83,8 @@ function ownKeys(target) {
|
|
|
81
83
|
trackSelf(target);
|
|
82
84
|
return Reflect.ownKeys(target);
|
|
83
85
|
}
|
|
84
|
-
function createDataNode(value
|
|
85
|
-
const [s, set] = createSignal(value,
|
|
86
|
-
internal: true
|
|
87
|
-
} : {
|
|
86
|
+
function createDataNode(value) {
|
|
87
|
+
const [s, set] = createSignal(value, {
|
|
88
88
|
equals: false,
|
|
89
89
|
internal: true
|
|
90
90
|
});
|
|
@@ -95,9 +95,12 @@ const proxyTraps$1 = {
|
|
|
95
95
|
get(target, property, receiver) {
|
|
96
96
|
if (property === $RAW) return target;
|
|
97
97
|
if (property === $PROXY) return receiver;
|
|
98
|
-
if (property === $TRACK)
|
|
98
|
+
if (property === $TRACK) {
|
|
99
|
+
trackSelf(target);
|
|
100
|
+
return receiver;
|
|
101
|
+
}
|
|
99
102
|
const nodes = getDataNodes(target);
|
|
100
|
-
const tracked = nodes
|
|
103
|
+
const tracked = nodes.hasOwnProperty(property);
|
|
101
104
|
let value = tracked ? nodes[property]() : target[property];
|
|
102
105
|
if (property === $NODE || property === "__proto__") return value;
|
|
103
106
|
if (!tracked) {
|
|
@@ -106,6 +109,12 @@ const proxyTraps$1 = {
|
|
|
106
109
|
}
|
|
107
110
|
return isWrappable(value) ? wrap$1(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
108
111
|
},
|
|
112
|
+
has(target, property) {
|
|
113
|
+
if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === "__proto__") return true;
|
|
114
|
+
const tracked = getDataNodes(target)[property];
|
|
115
|
+
tracked && tracked();
|
|
116
|
+
return property in target;
|
|
117
|
+
},
|
|
109
118
|
set() {
|
|
110
119
|
console.warn("Cannot mutate a Store directly");
|
|
111
120
|
return true;
|
|
@@ -117,8 +126,8 @@ const proxyTraps$1 = {
|
|
|
117
126
|
ownKeys: ownKeys,
|
|
118
127
|
getOwnPropertyDescriptor: proxyDescriptor
|
|
119
128
|
};
|
|
120
|
-
function setProperty(state, property, value) {
|
|
121
|
-
if (state[property] === value) return;
|
|
129
|
+
function setProperty(state, property, value, deleting = false) {
|
|
130
|
+
if (!deleting && state[property] === value) return;
|
|
122
131
|
const prev = state[property];
|
|
123
132
|
const len = state.length;
|
|
124
133
|
if (value === undefined) {
|
|
@@ -219,9 +228,12 @@ const proxyTraps = {
|
|
|
219
228
|
get(target, property, receiver) {
|
|
220
229
|
if (property === $RAW) return target;
|
|
221
230
|
if (property === $PROXY) return receiver;
|
|
222
|
-
if (property === $TRACK)
|
|
231
|
+
if (property === $TRACK) {
|
|
232
|
+
trackSelf(target);
|
|
233
|
+
return receiver;
|
|
234
|
+
}
|
|
223
235
|
const nodes = getDataNodes(target);
|
|
224
|
-
const tracked = nodes
|
|
236
|
+
const tracked = nodes.hasOwnProperty(property);
|
|
225
237
|
let value = tracked ? nodes[property]() : target[property];
|
|
226
238
|
if (property === $NODE || property === "__proto__") return value;
|
|
227
239
|
if (!tracked) {
|
|
@@ -233,12 +245,18 @@ const proxyTraps = {
|
|
|
233
245
|
}
|
|
234
246
|
return isWrappable(value) ? wrap(value, target[$NAME] && `${target[$NAME]}:${property.toString()}`) : value;
|
|
235
247
|
},
|
|
248
|
+
has(target, property) {
|
|
249
|
+
if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === "__proto__") return true;
|
|
250
|
+
const tracked = getDataNodes(target)[property];
|
|
251
|
+
tracked && tracked();
|
|
252
|
+
return property in target;
|
|
253
|
+
},
|
|
236
254
|
set(target, property, value) {
|
|
237
|
-
setProperty(target, property, unwrap(value));
|
|
255
|
+
batch(() => setProperty(target, property, unwrap(value)));
|
|
238
256
|
return true;
|
|
239
257
|
},
|
|
240
258
|
deleteProperty(target, property) {
|
|
241
|
-
setProperty(target, property, undefined);
|
|
259
|
+
batch(() => setProperty(target, property, undefined, true));
|
|
242
260
|
return true;
|
|
243
261
|
},
|
|
244
262
|
ownKeys: ownKeys,
|
|
@@ -389,7 +407,7 @@ const setterTraps = {
|
|
|
389
407
|
return true;
|
|
390
408
|
},
|
|
391
409
|
deleteProperty(target, property) {
|
|
392
|
-
setProperty(target, property, undefined);
|
|
410
|
+
setProperty(target, property, undefined, true);
|
|
393
411
|
return true;
|
|
394
412
|
}
|
|
395
413
|
};
|