solid-js 1.4.8 → 1.5.0-beta.2
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 +119 -134
- package/dist/dev.js +119 -134
- package/dist/server.cjs +98 -49
- package/dist/server.js +98 -49
- package/dist/solid.cjs +119 -132
- package/dist/solid.js +119 -132
- package/h/jsx-runtime/types/jsx.d.ts +8 -1401
- package/h/types/hyperscript.d.ts +17 -0
- package/html/types/lit.d.ts +37 -0
- package/package.json +103 -41
- 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/index.d.ts +4 -4
- package/store/types/mutable.d.ts +1 -1
- package/store/types/server.d.ts +1 -1
- package/store/types/store.d.ts +1 -1
- package/types/index.d.ts +8 -8
- package/types/jsx.d.ts +196 -1580
- package/types/reactive/array.d.ts +1 -1
- package/types/reactive/observable.d.ts +1 -1
- package/types/reactive/signal.d.ts +69 -34
- package/types/render/Suspense.d.ts +1 -1
- package/types/render/component.d.ts +22 -7
- package/types/render/flow.d.ts +2 -2
- package/types/render/index.d.ts +4 -4
- package/types/server/index.d.ts +3 -3
- package/types/server/reactive.d.ts +8 -3
- package/types/server/rendering.d.ts +11 -6
- package/universal/dist/dev.cjs +0 -0
- package/universal/dist/dev.js +0 -0
- package/universal/dist/universal.cjs +0 -0
- package/universal/dist/universal.js +0 -0
- package/universal/types/index.d.ts +1 -1
- package/web/dist/dev.cjs +3 -3
- package/web/dist/dev.js +3 -3
- package/web/dist/server.cjs +66 -90
- package/web/dist/server.js +66 -90
- package/web/dist/web.cjs +3 -3
- package/web/dist/web.js +3 -3
- package/web/types/client.d.ts +1 -1
- package/web/types/core.d.ts +3 -3
- package/web/types/index.d.ts +8 -9
- package/web/types/jsx.d.ts +1 -1
- 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 {};
|
|
@@ -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.2",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -40,108 +40,150 @@
|
|
|
40
40
|
".": {
|
|
41
41
|
"browser": {
|
|
42
42
|
"development": {
|
|
43
|
-
"import":
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./types/index.d.ts",
|
|
45
|
+
"default": "./dist/dev.js"
|
|
46
|
+
},
|
|
44
47
|
"require": "./dist/dev.cjs"
|
|
45
48
|
},
|
|
46
|
-
"import":
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./types/index.d.ts",
|
|
51
|
+
"default": "./dist/solid.js"
|
|
52
|
+
},
|
|
47
53
|
"require": "./dist/solid.cjs"
|
|
48
54
|
},
|
|
49
55
|
"node": {
|
|
50
|
-
"import":
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./types/index.d.ts",
|
|
58
|
+
"default": "./dist/server.js"
|
|
59
|
+
},
|
|
51
60
|
"require": "./dist/server.cjs"
|
|
52
61
|
},
|
|
53
62
|
"development": {
|
|
54
|
-
"import":
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./types/index.d.ts",
|
|
65
|
+
"default": "./dist/dev.js"
|
|
66
|
+
},
|
|
55
67
|
"require": "./dist/dev.cjs"
|
|
56
68
|
},
|
|
57
|
-
"import":
|
|
69
|
+
"import": {
|
|
70
|
+
"types": "./types/index.d.ts",
|
|
71
|
+
"default": "./dist/solid.js"
|
|
72
|
+
},
|
|
58
73
|
"require": "./dist/solid.cjs"
|
|
59
74
|
},
|
|
60
75
|
"./dist/*": "./dist/*",
|
|
61
76
|
"./store": {
|
|
62
77
|
"browser": {
|
|
63
78
|
"development": {
|
|
64
|
-
"import":
|
|
79
|
+
"import": {
|
|
80
|
+
"types": "./store/types/index.d.ts",
|
|
81
|
+
"default": "./store/dist/dev.js"
|
|
82
|
+
},
|
|
65
83
|
"require": "./store/dist/dev.cjs"
|
|
66
84
|
},
|
|
67
|
-
"import":
|
|
85
|
+
"import": {
|
|
86
|
+
"types": "./store/types/index.d.ts",
|
|
87
|
+
"default": "./store/dist/store.js"
|
|
88
|
+
},
|
|
68
89
|
"require": "./store/dist/store.cjs"
|
|
69
90
|
},
|
|
70
91
|
"node": {
|
|
71
|
-
"import":
|
|
92
|
+
"import": {
|
|
93
|
+
"types": "./store/types/index.d.ts",
|
|
94
|
+
"default": "./store/dist/server.js"
|
|
95
|
+
},
|
|
72
96
|
"require": "./store/dist/server.cjs"
|
|
73
97
|
},
|
|
74
98
|
"development": {
|
|
75
|
-
"import":
|
|
99
|
+
"import": {
|
|
100
|
+
"types": "./store/types/index.d.ts",
|
|
101
|
+
"default": "./store/dist/dev.js"
|
|
102
|
+
},
|
|
76
103
|
"require": "./store/dist/dev.cjs"
|
|
77
104
|
},
|
|
78
|
-
"import":
|
|
105
|
+
"import": {
|
|
106
|
+
"types": "./store/types/index.d.ts",
|
|
107
|
+
"default": "./store/dist/store.js"
|
|
108
|
+
},
|
|
79
109
|
"require": "./store/dist/store.cjs"
|
|
80
110
|
},
|
|
81
111
|
"./store/dist/*": "./store/dist/*",
|
|
82
112
|
"./web": {
|
|
83
113
|
"browser": {
|
|
84
114
|
"development": {
|
|
85
|
-
"import":
|
|
115
|
+
"import": {
|
|
116
|
+
"types": "./web/types/index.d.ts",
|
|
117
|
+
"default": "./web/dist/dev.js"
|
|
118
|
+
},
|
|
86
119
|
"require": "./web/dist/dev.cjs"
|
|
87
120
|
},
|
|
88
|
-
"import":
|
|
121
|
+
"import": {
|
|
122
|
+
"types": "./web/types/index.d.ts",
|
|
123
|
+
"default": "./web/dist/web.js"
|
|
124
|
+
},
|
|
89
125
|
"require": "./web/dist/web.cjs"
|
|
90
126
|
},
|
|
91
127
|
"node": {
|
|
92
|
-
"import":
|
|
128
|
+
"import": {
|
|
129
|
+
"types": "./web/types/index.d.ts",
|
|
130
|
+
"default": "./web/dist/server.js"
|
|
131
|
+
},
|
|
93
132
|
"require": "./web/dist/server.cjs"
|
|
94
133
|
},
|
|
95
134
|
"development": {
|
|
96
|
-
"import":
|
|
135
|
+
"import": {
|
|
136
|
+
"types": "./web/types/index.d.ts",
|
|
137
|
+
"default": "./web/dist/dev.js"
|
|
138
|
+
},
|
|
97
139
|
"require": "./web/dist/dev.cjs"
|
|
98
140
|
},
|
|
99
|
-
"import":
|
|
141
|
+
"import": {
|
|
142
|
+
"types": "./web/types/index.d.ts",
|
|
143
|
+
"default": "./web/dist/web.js"
|
|
144
|
+
},
|
|
100
145
|
"require": "./web/dist/web.cjs"
|
|
101
146
|
},
|
|
102
147
|
"./web/dist/*": "./web/dist/*",
|
|
103
148
|
"./universal": {
|
|
104
149
|
"development": {
|
|
105
|
-
"import":
|
|
150
|
+
"import": {
|
|
151
|
+
"types": "./universal/types/index.d.ts",
|
|
152
|
+
"default": "./universal/dist/dev.js"
|
|
153
|
+
},
|
|
106
154
|
"require": "./universal/dist/dev.cjs"
|
|
107
155
|
},
|
|
108
|
-
"import":
|
|
156
|
+
"import": {
|
|
157
|
+
"types": "./universal/types/index.d.ts",
|
|
158
|
+
"default": "./universal/dist/universal.js"
|
|
159
|
+
},
|
|
109
160
|
"require": "./universal/dist/universal.cjs"
|
|
110
161
|
},
|
|
111
162
|
"./universal/dist/*": "./universal/dist/*",
|
|
112
163
|
"./h": {
|
|
113
|
-
"import":
|
|
164
|
+
"import": {
|
|
165
|
+
"types": "./h/types/index.d.ts",
|
|
166
|
+
"default": "./h/dist/h.js"
|
|
167
|
+
},
|
|
114
168
|
"require": "./h/dist/h.cjs"
|
|
115
169
|
},
|
|
116
170
|
"./h/jsx-runtime": {
|
|
117
|
-
"import":
|
|
171
|
+
"import": {
|
|
172
|
+
"types": "./h/jsx-runtime/types/index.d.ts",
|
|
173
|
+
"default": "./h/jsx-runtime/dist/jsx.js"
|
|
174
|
+
},
|
|
118
175
|
"require": "./h/jsx-runtime/dist/jsx.cjs"
|
|
119
176
|
},
|
|
120
177
|
"./h/dist/*": "./h/dist/*",
|
|
121
178
|
"./html": {
|
|
122
|
-
"import":
|
|
179
|
+
"import": {
|
|
180
|
+
"types": "./html/types/index.d.ts",
|
|
181
|
+
"default": "./html/dist/html.js"
|
|
182
|
+
},
|
|
123
183
|
"require": "./html/dist/html.cjs"
|
|
124
184
|
},
|
|
125
185
|
"./html/dist/*": "./html/dist/*"
|
|
126
186
|
},
|
|
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
187
|
"keywords": [
|
|
146
188
|
"solid",
|
|
147
189
|
"solidjs",
|
|
@@ -151,5 +193,25 @@
|
|
|
151
193
|
"compiler",
|
|
152
194
|
"performance"
|
|
153
195
|
],
|
|
154
|
-
"
|
|
155
|
-
|
|
196
|
+
"scripts": {
|
|
197
|
+
"build": "npm-run-all -nl build:*",
|
|
198
|
+
"build:clean": "rimraf dist/ coverage/ store/dist/ web/dist/ h/dist/ h/jsx-runtime/dist html/dist/",
|
|
199
|
+
"build:js": "rollup -c",
|
|
200
|
+
"types": "npm-run-all -nl types:*",
|
|
201
|
+
"types:clean": "rimraf types/ store/types/ web/types/ h/types/ h/jsx-runtime/types html/types/",
|
|
202
|
+
"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",
|
|
203
|
+
"types:src": "tsc --project ./tsconfig.build.json && ncp ../../node_modules/dom-expressions/src/jsx.d.ts ./types/jsx.d.ts",
|
|
204
|
+
"types:web": "tsc --project ./web/tsconfig.build.json",
|
|
205
|
+
"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",
|
|
206
|
+
"types:store": "tsc --project ./store/tsconfig.build.json",
|
|
207
|
+
"types:html": "tsc --project ./html/tsconfig.json && ncp ../../node_modules/lit-dom-expressions/types/index.d.ts ./html/types/lit.d.ts",
|
|
208
|
+
"types:h": "tsc --project ./h/tsconfig.json && ncp ../../node_modules/hyper-dom-expressions/types/index.d.ts ./h/types/hyperscript.d.ts",
|
|
209
|
+
"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",
|
|
210
|
+
"types:universal": "tsc --project ./universal/tsconfig.json && ncp ../../node_modules/dom-expressions/src/universal.d.ts ./universal/types/universal.d.ts",
|
|
211
|
+
"bench": "node --allow-natives-syntax bench/bench.cjs",
|
|
212
|
+
"link": "symlink-dir . node_modules/solid-js",
|
|
213
|
+
"test": "jest",
|
|
214
|
+
"coverage": "jest --coverage",
|
|
215
|
+
"test-types": "tsc --project tsconfig.test.json"
|
|
216
|
+
}
|
|
217
|
+
}
|
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
|
};
|
package/store/dist/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $PROXY,
|
|
1
|
+
import { DEV, $PROXY, $TRACK, getListener, batch, createSignal } from 'solid-js';
|
|
2
2
|
|
|
3
3
|
const $RAW = Symbol("store-raw"),
|
|
4
4
|
$NODE = Symbol("store-node"),
|
|
@@ -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
255
|
batch(() => setProperty(target, property, unwrap(value)));
|
|
238
256
|
return true;
|
|
239
257
|
},
|
|
240
258
|
deleteProperty(target, property) {
|
|
241
|
-
batch(() => 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
|
};
|