solid-js 1.4.6 → 1.5.0-beta.1
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 +112 -113
- package/dist/dev.js +112 -113
- package/dist/server.cjs +65 -31
- package/dist/server.js +65 -31
- package/dist/solid.cjs +112 -111
- package/dist/solid.js +112 -111
- package/h/jsx-runtime/types/jsx.d.ts +6 -1401
- package/h/types/hyperscript.d.ts +17 -0
- package/html/dist/html.cjs +34 -59
- package/html/dist/html.js +34 -59
- package/html/types/lit.d.ts +37 -0
- package/package.json +23 -21
- package/store/dist/dev.cjs +40 -22
- package/store/dist/dev.js +41 -23
- package/store/dist/store.cjs +40 -22
- package/store/dist/store.js +40 -22
- package/store/types/store.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 +6 -1
- package/types/server/rendering.d.ts +3 -2
- package/universal/types/universal.d.ts +3 -3
- package/web/dist/dev.cjs +3 -3
- package/web/dist/dev.js +3 -3
- package/web/dist/server.cjs +35 -69
- package/web/dist/server.js +35 -69
- package/web/dist/web.cjs +3 -3
- package/web/dist/web.js +3 -3
- package/web/types/core.d.ts +2 -2
- package/web/types/index.d.ts +5 -6
- package/web/types/server-mock.d.ts +4 -2
- package/web/types/server.d.ts +70 -0
- package/h/README.md +0 -99
- package/h/jsx-runtime/package.json +0 -8
- package/h/package.json +0 -8
- package/html/README.md +0 -84
- package/html/package.json +0 -8
- package/store/README.md +0 -23
- package/store/package.json +0 -35
- package/universal/README.md +0 -102
- package/universal/package.json +0 -18
- package/web/README.md +0 -7
- package/web/package.json +0 -35
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
|
+
interface Runtime {
|
|
3
|
+
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
4
|
+
spread(node: Element, accessor: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
5
|
+
assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
6
|
+
createComponent(Comp: (props: any) => any, props: any): any;
|
|
7
|
+
dynamicProperty(props: any, key: string): any;
|
|
8
|
+
SVGElements: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
declare type ExpandableNode = Node & {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export declare type HyperScript = {
|
|
14
|
+
(...args: any[]): () => ExpandableNode | ExpandableNode[];
|
|
15
|
+
};
|
|
16
|
+
export declare function createHyperScript(r: Runtime): HyperScript;
|
|
17
|
+
export {};
|
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);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
2
|
+
interface Runtime {
|
|
3
|
+
effect<T>(fn: (prev?: T) => T, init?: T): any;
|
|
4
|
+
insert(parent: MountableElement, accessor: any, marker?: Node | null, init?: any): any;
|
|
5
|
+
spread<T>(node: Element, accessor: (() => T) | T, isSVG?: Boolean, skipChildren?: Boolean): void;
|
|
6
|
+
createComponent(Comp: (props: any) => any, props: any): any;
|
|
7
|
+
addEventListener(node: Element, name: string, handler: () => void, delegate: boolean): void;
|
|
8
|
+
delegateEvents(eventNames: string[]): void;
|
|
9
|
+
classList(node: Element, value: {
|
|
10
|
+
[k: string]: boolean;
|
|
11
|
+
}, prev?: {
|
|
12
|
+
[k: string]: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
style(node: Element, value: {
|
|
15
|
+
[k: string]: string;
|
|
16
|
+
}, prev?: {
|
|
17
|
+
[k: string]: string;
|
|
18
|
+
}): void;
|
|
19
|
+
mergeProps(...sources: unknown[]): unknown;
|
|
20
|
+
dynamicProperty(props: any, key: string): any;
|
|
21
|
+
setAttribute(node: Element, name: string, value: any): void;
|
|
22
|
+
setAttributeNS(node: Element, namespace: string, name: string, value: any): void;
|
|
23
|
+
Aliases: Record<string, string>;
|
|
24
|
+
PropAliases: Record<string, string>;
|
|
25
|
+
Properties: Set<string>;
|
|
26
|
+
ChildProperties: Set<string>;
|
|
27
|
+
DelegatedEvents: Set<string>;
|
|
28
|
+
SVGElements: Set<string>;
|
|
29
|
+
SVGNamespace: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export declare type HTMLTag = {
|
|
32
|
+
(statics: TemplateStringsArray, ...args: unknown[]): Node | Node[];
|
|
33
|
+
};
|
|
34
|
+
export declare function createHTML(r: Runtime, { delegateEvents }?: {
|
|
35
|
+
delegateEvents?: boolean | undefined;
|
|
36
|
+
}): HTMLTag;
|
|
37
|
+
export {};
|
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.1",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -124,24 +124,6 @@
|
|
|
124
124
|
},
|
|
125
125
|
"./html/dist/*": "./html/dist/*"
|
|
126
126
|
},
|
|
127
|
-
"scripts": {
|
|
128
|
-
"prebuild": "npm run clean",
|
|
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
|
-
"build": "npm-run-all -cnl build:*",
|
|
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-h.d.ts ./h/jsx-runtime/src/jsx.d.ts && rollup -c",
|
|
133
|
-
"build:types": "tsc --project ./tsconfig.build.json",
|
|
134
|
-
"build:types-store": "tsc --project ./store/tsconfig.build.json && tsconfig-replace-paths --project ./store/tsconfig.types.json",
|
|
135
|
-
"build:types-web": "tsc --project ./web/tsconfig.build.json && tsconfig-replace-paths --project ./web/tsconfig.types.json",
|
|
136
|
-
"build:types-html": "tsc --project ./html/tsconfig.json",
|
|
137
|
-
"build:types-h": "tsc --project ./h/tsconfig.json",
|
|
138
|
-
"build:types-jsx": "tsc --project ./h/jsx-runtime/tsconfig.json",
|
|
139
|
-
"build:types-universal": "tsc --project ./universal/tsconfig.json",
|
|
140
|
-
"bench": "node --allow-natives-syntax bench/bench.cjs",
|
|
141
|
-
"test": "jest && npm run test:types",
|
|
142
|
-
"test:coverage": "jest --coverage && npm run test:types",
|
|
143
|
-
"test:types": "tsc --project tsconfig.test.json"
|
|
144
|
-
},
|
|
145
127
|
"keywords": [
|
|
146
128
|
"solid",
|
|
147
129
|
"solidjs",
|
|
@@ -151,5 +133,25 @@
|
|
|
151
133
|
"compiler",
|
|
152
134
|
"performance"
|
|
153
135
|
],
|
|
154
|
-
"
|
|
155
|
-
|
|
136
|
+
"scripts": {
|
|
137
|
+
"build": "npm-run-all -nl build:*",
|
|
138
|
+
"build:clean": "rimraf dist/ coverage/ store/dist/ web/dist/ h/dist/ h/jsx-runtime/dist html/dist/",
|
|
139
|
+
"build:js": "rollup -c",
|
|
140
|
+
"types": "npm-run-all -nl types:*",
|
|
141
|
+
"types:clean": "rimraf types/ store/types/ web/types/ h/types/ h/jsx-runtime/types html/types/",
|
|
142
|
+
"types:copy": "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",
|
|
143
|
+
"types:src": "tsc --project ./tsconfig.build.json && ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./types/jsx.d.ts",
|
|
144
|
+
"types:web": "tsc --project ./web/tsconfig.build.json",
|
|
145
|
+
"types:copy-web": "ncp ../../node_modules/dom-expressions/src/client.d.ts ./web/types/client.d.ts && ncp ../../node_modules/dom-expressions/src/server.d.ts ./web/types/server.d.ts",
|
|
146
|
+
"types:store": "tsc --project ./store/tsconfig.build.json",
|
|
147
|
+
"types:html": "tsc --project ./html/tsconfig.json && ncp ../../node_modules/lit-dom-expressions/types/index.d.ts ./html/types/lit.d.ts",
|
|
148
|
+
"types:h": "tsc --project ./h/tsconfig.json && ncp ../../node_modules/hyper-dom-expressions/types/index.d.ts ./h/types/hyperscript.d.ts",
|
|
149
|
+
"types:jsx": "rimraf ./h/jsx-runtime/types && tsc --project ./h/jsx-runtime/tsconfig.json && ncp ../../node_modules/dom-expressions/src/jsx-h.d.ts ./h/jsx-runtime/types/jsx.d.ts",
|
|
150
|
+
"types:universal": "tsc --project ./universal/tsconfig.json && ncp ../../node_modules/dom-expressions/src/universal.d.ts ./universal/types/universal.d.ts",
|
|
151
|
+
"bench": "node --allow-natives-syntax bench/bench.cjs",
|
|
152
|
+
"link": "symlink-dir . node_modules/solid-js",
|
|
153
|
+
"test": "jest",
|
|
154
|
+
"coverage": "jest --coverage",
|
|
155
|
+
"test-types": "tsc --project tsconfig.test.json"
|
|
156
|
+
}
|
|
157
|
+
}
|
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
259
|
solidJs.batch(() => setProperty(target, property, unwrap(value)));
|
|
242
260
|
return true;
|
|
243
261
|
},
|
|
244
262
|
deleteProperty(target, property) {
|
|
245
|
-
solidJs.batch(() => 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
|
};
|