@kunpeng-js/properties-panel 2026.0.0-alpha2 → 2026.10.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/LICENSE +9 -2
- package/dist/index.esm.js +3760 -3762
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3724 -3804
- package/dist/index.js.map +1 -1
- package/package.json +22 -48
- package/preact/README.md +5 -5
- package/preact/compat/client.d.ts +1 -3
- package/preact/compat/dist/compat.mjs +2 -2
- package/preact/compat/dist/compat.mjs.map +1 -0
- package/preact/compat/package.json +2 -41
- package/preact/compat/scheduler.d.ts +12 -0
- package/preact/compat/server.d.ts +17 -0
- package/preact/compat/src/Children.js +3 -3
- package/preact/compat/src/PureComponent.js +20 -12
- package/preact/compat/src/forwardRef.js +4 -17
- package/preact/compat/src/hooks.js +17 -51
- package/preact/compat/src/index.d.ts +249 -164
- package/preact/compat/src/index.js +52 -43
- package/preact/compat/src/internal.d.ts +1 -2
- package/preact/compat/src/memo.js +2 -2
- package/preact/compat/src/portals.js +2 -68
- package/preact/compat/src/render.js +182 -73
- package/preact/compat/src/suspense.d.ts +1 -3
- package/preact/compat/src/suspense.js +169 -179
- package/preact/compat/src/util.js +5 -22
- package/preact/debug/dist/debug.mjs +2 -2
- package/preact/debug/dist/debug.mjs.map +1 -0
- package/preact/debug/package.json +3 -14
- package/preact/debug/src/check-props.js +2 -6
- package/preact/debug/src/component-stack.js +67 -16
- package/preact/debug/src/debug.js +80 -35
- package/preact/debug/src/index.d.ts +11 -1
- package/preact/debug/src/index.js +3 -1
- package/preact/debug/src/util.js +1 -11
- package/preact/devtools/dist/devtools.mjs +2 -2
- package/preact/devtools/dist/devtools.mjs.map +1 -0
- package/preact/devtools/package.json +3 -15
- package/preact/devtools/src/devtools.js +1 -1
- package/preact/dist/preact.mjs +2 -2
- package/preact/dist/preact.mjs.map +1 -0
- package/preact/hooks/dist/hooks.mjs +2 -2
- package/preact/hooks/dist/hooks.mjs.map +1 -0
- package/preact/hooks/package.json +5 -24
- package/preact/hooks/src/index.d.ts +6 -13
- package/preact/hooks/src/index.js +95 -73
- package/preact/hooks/src/internal.d.ts +8 -3
- package/preact/jsx-runtime/dist/jsxRuntime.mjs +2 -2
- package/preact/jsx-runtime/dist/jsxRuntime.mjs.map +1 -0
- package/preact/jsx-runtime/package.json +4 -16
- package/preact/jsx-runtime/src/index.d.ts +11 -11
- package/preact/jsx-runtime/src/index.js +25 -40
- package/preact/jsx-runtime/src/utils.js +3 -3
- package/preact/package.json +59 -115
- package/preact/src/component.js +54 -47
- package/preact/src/constants.js +17 -2
- package/preact/src/create-context.js +4 -14
- package/preact/src/create-element.js +42 -17
- package/preact/src/create-portal.js +20 -0
- package/preact/src/diff/catch-error.js +26 -8
- package/preact/src/diff/children.js +158 -96
- package/preact/src/diff/index.js +265 -146
- package/preact/src/diff/props.js +39 -50
- package/preact/src/dom.d.ts +796 -147
- package/preact/src/index.d.ts +7 -18
- package/preact/src/index.js +2 -1
- package/preact/src/internal.d.ts +16 -24
- package/preact/src/jsx.d.ts +222 -2910
- package/preact/src/render.js +30 -34
- package/preact/src/util.js +5 -20
- package/preact/test-utils/dist/testUtils.mjs +1 -1
- package/preact/test-utils/dist/testUtils.mjs.map +1 -0
- package/preact/test-utils/package.json +5 -17
- package/README.md +0 -35
- package/preact/compat/dist/compat.js +0 -2
- package/preact/compat/dist/compat.js.map +0 -1
- package/preact/compat/dist/compat.module.js +0 -2
- package/preact/compat/dist/compat.module.js.map +0 -1
- package/preact/compat/dist/compat.umd.js +0 -2
- package/preact/compat/dist/compat.umd.js.map +0 -1
- package/preact/compat/src/suspense-list.d.ts +0 -16
- package/preact/compat/src/suspense-list.js +0 -127
- package/preact/debug/dist/debug.js +0 -2
- package/preact/debug/dist/debug.js.map +0 -1
- package/preact/debug/dist/debug.module.js +0 -2
- package/preact/debug/dist/debug.module.js.map +0 -1
- package/preact/debug/dist/debug.umd.js +0 -2
- package/preact/debug/dist/debug.umd.js.map +0 -1
- package/preact/devtools/dist/devtools.js +0 -2
- package/preact/devtools/dist/devtools.js.map +0 -1
- package/preact/devtools/dist/devtools.module.js +0 -2
- package/preact/devtools/dist/devtools.module.js.map +0 -1
- package/preact/devtools/dist/devtools.umd.js +0 -2
- package/preact/devtools/dist/devtools.umd.js.map +0 -1
- package/preact/dist/preact.js +0 -2
- package/preact/dist/preact.js.map +0 -1
- package/preact/dist/preact.min.js +0 -2
- package/preact/dist/preact.min.js.map +0 -1
- package/preact/dist/preact.min.module.js +0 -2
- package/preact/dist/preact.min.module.js.map +0 -1
- package/preact/dist/preact.min.umd.js +0 -2
- package/preact/dist/preact.min.umd.js.map +0 -1
- package/preact/dist/preact.module.js +0 -2
- package/preact/dist/preact.module.js.map +0 -1
- package/preact/dist/preact.umd.js +0 -2
- package/preact/dist/preact.umd.js.map +0 -1
- package/preact/hooks/dist/hooks.js +0 -2
- package/preact/hooks/dist/hooks.js.map +0 -1
- package/preact/hooks/dist/hooks.module.js +0 -2
- package/preact/hooks/dist/hooks.module.js.map +0 -1
- package/preact/hooks/dist/hooks.umd.js +0 -2
- package/preact/hooks/dist/hooks.umd.js.map +0 -1
- package/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
- package/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
- package/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
- package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
- package/preact/src/cjs.js +0 -3
- package/preact/src/clone-element.js +0 -48
- package/preact/src/index-5.d.ts +0 -399
- package/preact/test-utils/dist/testUtils.js +0 -2
- package/preact/test-utils/dist/testUtils.js.map +0 -1
- package/preact/test-utils/dist/testUtils.module.js +0 -2
- package/preact/test-utils/dist/testUtils.module.js.map +0 -1
- package/preact/test-utils/dist/testUtils.umd.js +0 -2
- package/preact/test-utils/dist/testUtils.umd.js.map +0 -1
package/preact/package.json
CHANGED
|
@@ -1,91 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preact",
|
|
3
3
|
"amdName": "preact",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "11.0.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
8
8
|
"provenance": true
|
|
9
9
|
},
|
|
10
|
-
"description": "Fast
|
|
11
|
-
"main": "dist/preact.
|
|
12
|
-
"module": "dist/preact.
|
|
13
|
-
"umd:main": "dist/preact.umd.js",
|
|
14
|
-
"unpkg": "dist/preact.min.js",
|
|
10
|
+
"description": "Fast 4kb React-compatible Virtual DOM library.",
|
|
11
|
+
"main": "dist/preact.mjs",
|
|
12
|
+
"module": "dist/preact.mjs",
|
|
15
13
|
"source": "src/index.js",
|
|
16
|
-
"typesVersions": {
|
|
17
|
-
"<=5.0": {
|
|
18
|
-
".": [
|
|
19
|
-
"./src/index-5.d.ts"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
14
|
"exports": {
|
|
24
15
|
".": {
|
|
25
|
-
"types@<=5.0": {
|
|
26
|
-
"types": "./src/index-5.d.ts"
|
|
27
|
-
},
|
|
28
16
|
"types": "./src/index.d.ts",
|
|
29
|
-
"
|
|
30
|
-
"umd": "./dist/preact.umd.js",
|
|
31
|
-
"import": "./dist/preact.mjs",
|
|
32
|
-
"require": "./dist/preact.js"
|
|
17
|
+
"default": "./dist/preact.mjs"
|
|
33
18
|
},
|
|
34
19
|
"./compat": {
|
|
35
20
|
"types": "./compat/src/index.d.ts",
|
|
36
|
-
"
|
|
37
|
-
"umd": "./compat/dist/compat.umd.js",
|
|
38
|
-
"import": "./compat/dist/compat.mjs",
|
|
39
|
-
"require": "./compat/dist/compat.js"
|
|
21
|
+
"default": "./compat/dist/compat.mjs"
|
|
40
22
|
},
|
|
41
23
|
"./debug": {
|
|
42
24
|
"types": "./debug/src/index.d.ts",
|
|
43
|
-
"
|
|
44
|
-
"umd": "./debug/dist/debug.umd.js",
|
|
45
|
-
"import": "./debug/dist/debug.mjs",
|
|
46
|
-
"require": "./debug/dist/debug.js"
|
|
25
|
+
"default": "./debug/dist/debug.mjs"
|
|
47
26
|
},
|
|
48
27
|
"./devtools": {
|
|
49
28
|
"types": "./devtools/src/index.d.ts",
|
|
50
|
-
"
|
|
51
|
-
"umd": "./devtools/dist/devtools.umd.js",
|
|
52
|
-
"import": "./devtools/dist/devtools.mjs",
|
|
53
|
-
"require": "./devtools/dist/devtools.js"
|
|
29
|
+
"default": "./devtools/dist/devtools.mjs"
|
|
54
30
|
},
|
|
55
31
|
"./hooks": {
|
|
56
32
|
"types": "./hooks/src/index.d.ts",
|
|
57
|
-
"
|
|
58
|
-
"umd": "./hooks/dist/hooks.umd.js",
|
|
59
|
-
"import": "./hooks/dist/hooks.mjs",
|
|
60
|
-
"require": "./hooks/dist/hooks.js"
|
|
33
|
+
"default": "./hooks/dist/hooks.mjs"
|
|
61
34
|
},
|
|
62
35
|
"./test-utils": {
|
|
63
36
|
"types": "./test-utils/src/index.d.ts",
|
|
64
|
-
"
|
|
65
|
-
"umd": "./test-utils/dist/testUtils.umd.js",
|
|
66
|
-
"import": "./test-utils/dist/testUtils.mjs",
|
|
67
|
-
"require": "./test-utils/dist/testUtils.js"
|
|
37
|
+
"default": "./test-utils/dist/testUtils.mjs"
|
|
68
38
|
},
|
|
69
39
|
"./compat/test-utils": {
|
|
70
40
|
"types": "./test-utils/src/index.d.ts",
|
|
71
|
-
"
|
|
72
|
-
"umd": "./test-utils/dist/testUtils.umd.js",
|
|
73
|
-
"import": "./test-utils/dist/testUtils.mjs",
|
|
74
|
-
"require": "./test-utils/dist/testUtils.js"
|
|
41
|
+
"default": "./test-utils/dist/testUtils.mjs"
|
|
75
42
|
},
|
|
76
43
|
"./jsx-runtime": {
|
|
77
44
|
"types": "./jsx-runtime/src/index.d.ts",
|
|
78
|
-
"
|
|
79
|
-
"umd": "./jsx-runtime/dist/jsxRuntime.umd.js",
|
|
80
|
-
"import": "./jsx-runtime/dist/jsxRuntime.mjs",
|
|
81
|
-
"require": "./jsx-runtime/dist/jsxRuntime.js"
|
|
45
|
+
"default": "./jsx-runtime/dist/jsxRuntime.mjs"
|
|
82
46
|
},
|
|
83
47
|
"./jsx-dev-runtime": {
|
|
84
48
|
"types": "./jsx-runtime/src/index.d.ts",
|
|
85
|
-
"
|
|
86
|
-
"umd": "./jsx-runtime/dist/jsxRuntime.umd.js",
|
|
87
|
-
"import": "./jsx-runtime/dist/jsxRuntime.mjs",
|
|
88
|
-
"require": "./jsx-runtime/dist/jsxRuntime.js"
|
|
49
|
+
"default": "./jsx-runtime/dist/jsxRuntime.mjs"
|
|
89
50
|
},
|
|
90
51
|
"./compat/client": {
|
|
91
52
|
"types": "./compat/client.d.ts",
|
|
@@ -93,6 +54,7 @@
|
|
|
93
54
|
"require": "./compat/client.js"
|
|
94
55
|
},
|
|
95
56
|
"./compat/server": {
|
|
57
|
+
"types": "./compat/server.d.ts",
|
|
96
58
|
"browser": "./compat/server.browser.js",
|
|
97
59
|
"import": "./compat/server.mjs",
|
|
98
60
|
"require": "./compat/server.js"
|
|
@@ -112,6 +74,7 @@
|
|
|
112
74
|
"require": "./compat/jsx-dev-runtime.js"
|
|
113
75
|
},
|
|
114
76
|
"./compat/scheduler": {
|
|
77
|
+
"types": "./compat/scheduler.d.ts",
|
|
115
78
|
"import": "./compat/scheduler.mjs",
|
|
116
79
|
"require": "./compat/scheduler.js"
|
|
117
80
|
},
|
|
@@ -129,38 +92,6 @@
|
|
|
129
92
|
"url": "https://opencollective.com/preact"
|
|
130
93
|
},
|
|
131
94
|
"types": "src/index.d.ts",
|
|
132
|
-
"scripts": {
|
|
133
|
-
"prepare": "husky && npm run test:install && run-s build",
|
|
134
|
-
"build": "npm-run-all --parallel 'build:*'",
|
|
135
|
-
"build:core": "microbundle build --raw --no-generateTypes -f cjs,esm,umd",
|
|
136
|
-
"build:core-min": "microbundle build --raw --no-generateTypes -f cjs,esm,umd,iife src/cjs.js -o dist/preact.min.js",
|
|
137
|
-
"build:debug": "microbundle build --raw --no-generateTypes -f cjs,esm,umd --cwd debug",
|
|
138
|
-
"build:devtools": "microbundle build --raw --no-generateTypes -f cjs,esm,umd --cwd devtools",
|
|
139
|
-
"build:hooks": "microbundle build --raw --no-generateTypes -f cjs,esm,umd --cwd hooks",
|
|
140
|
-
"build:test-utils": "microbundle build --raw --no-generateTypes -f cjs,esm,umd --cwd test-utils",
|
|
141
|
-
"build:compat": "microbundle build --raw --no-generateTypes -f cjs,esm,umd --cwd compat --globals 'preact/hooks=preactHooks'",
|
|
142
|
-
"build:jsx": "microbundle build --raw --no-generateTypes -f cjs,esm,umd --cwd jsx-runtime",
|
|
143
|
-
"postbuild": "node ./config/node-13-exports.js && node ./config/compat-entries.js",
|
|
144
|
-
"dev": "microbundle watch --raw --no-generateTypes --format cjs",
|
|
145
|
-
"dev:hooks": "microbundle watch --raw --no-generateTypes --format cjs --cwd hooks",
|
|
146
|
-
"dev:compat": "microbundle watch --raw --no-generateTypes --format cjs --cwd compat --globals 'preact/hooks=preactHooks'",
|
|
147
|
-
"test": "npm-run-all build lint test:unit",
|
|
148
|
-
"test:install": "playwright install chromium",
|
|
149
|
-
"test:unit": "run-p test:mocha test:vitest:min test:ts",
|
|
150
|
-
"test:vitest": "cross-env COVERAGE=true vitest run",
|
|
151
|
-
"test:vitest:min": "cross-env MINIFY=true vitest run",
|
|
152
|
-
"test:vitest:watch": "vitest",
|
|
153
|
-
"test:ts": "run-p 'test:ts:*'",
|
|
154
|
-
"test:ts:core": "tsc -p test/ts/ && mocha --require \"@babel/register\" test/ts/**/*-test.js",
|
|
155
|
-
"test:ts:compat": "tsc -p compat/test/ts/",
|
|
156
|
-
"test:mocha": "mocha --recursive --require \"@babel/register\" test/shared test/node",
|
|
157
|
-
"test:mocha:watch": "npm run test:mocha -- --watch",
|
|
158
|
-
"lint": "run-s oxlint tsc",
|
|
159
|
-
"tsc": "tsc -p jsconfig-lint.json",
|
|
160
|
-
"oxlint": "oxlint -c oxlint.json src test/browser test/node test/shared debug compat hooks test-utils",
|
|
161
|
-
"format": "oxfmt . --write",
|
|
162
|
-
"format:check": "oxfmt --check ."
|
|
163
|
-
},
|
|
164
95
|
"nano-staged": {
|
|
165
96
|
"**/*.{js,jsx,mjs,cjs,ts,tsx,yml,json,html,md,css,scss}": [
|
|
166
97
|
"oxfmt --write --no-error-on-unmatched-pattern"
|
|
@@ -174,9 +105,11 @@
|
|
|
174
105
|
"compat/client.d.ts",
|
|
175
106
|
"compat/client.js",
|
|
176
107
|
"compat/client.mjs",
|
|
108
|
+
"compat/server.d.ts",
|
|
177
109
|
"compat/server.browser.js",
|
|
178
110
|
"compat/server.js",
|
|
179
111
|
"compat/server.mjs",
|
|
112
|
+
"compat/scheduler.d.ts",
|
|
180
113
|
"compat/scheduler.js",
|
|
181
114
|
"compat/scheduler.mjs",
|
|
182
115
|
"compat/test-utils.js",
|
|
@@ -217,50 +150,40 @@
|
|
|
217
150
|
"authors": [
|
|
218
151
|
"The Preact Authors (https://github.com/preactjs/preact/contributors)"
|
|
219
152
|
],
|
|
220
|
-
"repository":
|
|
153
|
+
"repository": {
|
|
154
|
+
"type": "git",
|
|
155
|
+
"url": "git+https://github.com/preactjs/preact.git"
|
|
156
|
+
},
|
|
221
157
|
"bugs": "https://github.com/preactjs/preact/issues",
|
|
222
158
|
"homepage": "https://preactjs.com",
|
|
223
159
|
"devDependencies": {
|
|
224
|
-
"@
|
|
225
|
-
"@
|
|
226
|
-
"@babel
|
|
227
|
-
"@
|
|
228
|
-
"@
|
|
229
|
-
"@
|
|
230
|
-
"@
|
|
231
|
-
"@
|
|
232
|
-
"@types/mocha": "^10.0.0",
|
|
233
|
-
"@types/node": "^18.19.87",
|
|
234
|
-
"@types/sinon": "^17.0.3",
|
|
235
|
-
"@vitest/browser": "^3.2.1",
|
|
236
|
-
"@vitest/coverage-istanbul": "^3.2.1",
|
|
160
|
+
"@babel/core": "^7.28.0",
|
|
161
|
+
"@babel/preset-env": "^7.29.7",
|
|
162
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
163
|
+
"@types/chai": "^5.2.2",
|
|
164
|
+
"@types/node": "^22.20.1",
|
|
165
|
+
"@vitest/browser": "^5.0.0",
|
|
166
|
+
"@vitest/browser-playwright": "^5.0.0",
|
|
167
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
237
168
|
"babel-plugin-transform-rename-properties": "0.1.0",
|
|
238
|
-
"chai": "^
|
|
239
|
-
"coveralls": "^3.1.1",
|
|
169
|
+
"chai": "^6.2.2",
|
|
240
170
|
"cross-env": "^7.0.3",
|
|
241
|
-
"errorstacks": "^2.4.1",
|
|
242
|
-
"esbuild": "^0.24.0",
|
|
243
171
|
"husky": "^9.1.7",
|
|
244
172
|
"kolorist": "^1.8.0",
|
|
245
|
-
"
|
|
246
|
-
"mocha": "^11.0.0",
|
|
173
|
+
"nano-staged": "^1.0.2",
|
|
247
174
|
"npm-run-all2": "^7.0.0",
|
|
248
175
|
"oxfmt": "^0.32.0",
|
|
249
|
-
"oxlint": "^
|
|
176
|
+
"oxlint": "^1.8.0",
|
|
177
|
+
"playwright": "^1.54.1",
|
|
250
178
|
"preact-render-to-string": "^6.5.0",
|
|
251
179
|
"prop-types": "^15.8.1",
|
|
252
|
-
"
|
|
253
|
-
"sinon": "^19.0.2",
|
|
254
|
-
"sinon-chai": "^4.0.0",
|
|
180
|
+
"rollup": "^4.62.2",
|
|
255
181
|
"terser": "5.16.0",
|
|
256
182
|
"typescript": "5.1.6",
|
|
257
|
-
"
|
|
258
|
-
"vite": "^6.2.0",
|
|
259
|
-
"vitest": "^3.2.1",
|
|
260
|
-
"playwright": "^1.52.0"
|
|
183
|
+
"vitest": "^5.0.0"
|
|
261
184
|
},
|
|
262
185
|
"peerDependencies": {
|
|
263
|
-
"preact-render-to-string": ">=
|
|
186
|
+
"preact-render-to-string": ">=6.7.0"
|
|
264
187
|
},
|
|
265
188
|
"peerDependenciesMeta": {
|
|
266
189
|
"preact-render-to-string": {
|
|
@@ -268,6 +191,27 @@
|
|
|
268
191
|
}
|
|
269
192
|
},
|
|
270
193
|
"volta": {
|
|
271
|
-
"node": "
|
|
194
|
+
"node": "22.22.2"
|
|
195
|
+
},
|
|
196
|
+
"scripts": {
|
|
197
|
+
"build": "node ./scripts/build.mjs",
|
|
198
|
+
"postbuild": "node ./config/compat-entries.js",
|
|
199
|
+
"dev": "node ./scripts/build.mjs --watch",
|
|
200
|
+
"dev:hooks": "node ./scripts/build.mjs --watch hooks",
|
|
201
|
+
"dev:compat": "node ./scripts/build.mjs --watch compat",
|
|
202
|
+
"test": "npm-run-all build lint test:unit",
|
|
203
|
+
"test:install": "playwright install chromium",
|
|
204
|
+
"test:unit": "run-p test:vitest:min test:ts",
|
|
205
|
+
"test:vitest": "cross-env COVERAGE=true vitest run",
|
|
206
|
+
"test:vitest:min": "cross-env MINIFY=true vitest run",
|
|
207
|
+
"test:vitest:watch": "vitest",
|
|
208
|
+
"test:ts": "run-p 'test:ts:*'",
|
|
209
|
+
"test:ts:core": "tsc -p test/ts/",
|
|
210
|
+
"test:ts:compat": "tsc -p compat/test/ts/",
|
|
211
|
+
"lint": "run-s oxlint tsc",
|
|
212
|
+
"tsc": "tsc -p jsconfig-lint.json",
|
|
213
|
+
"oxlint": "oxlint src test/browser test/node test/shared debug compat hooks test-utils",
|
|
214
|
+
"format": "oxfmt . --write",
|
|
215
|
+
"format:check": "oxfmt --check ."
|
|
272
216
|
}
|
|
273
|
-
}
|
|
217
|
+
}
|
package/preact/src/component.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_DIRTY,
|
|
3
|
+
COMPONENT_FORCE,
|
|
4
|
+
MODE_HYDRATE,
|
|
5
|
+
NULL,
|
|
6
|
+
UNDEFINED
|
|
7
|
+
} from './constants';
|
|
4
8
|
import { Fragment } from './create-element';
|
|
5
|
-
import {
|
|
9
|
+
import { commitRoot, diff } from './diff/index';
|
|
10
|
+
import options from './options';
|
|
11
|
+
import { assign } from './util';
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* Base Component class. Provides `setState()` and `forceUpdate()`, which
|
|
@@ -14,6 +20,7 @@ import { MODE_HYDRATE, NULL } from './constants';
|
|
|
14
20
|
export function BaseComponent(props, context) {
|
|
15
21
|
this.props = props;
|
|
16
22
|
this.context = context;
|
|
23
|
+
this._bits = 0;
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
/**
|
|
@@ -27,10 +34,8 @@ export function BaseComponent(props, context) {
|
|
|
27
34
|
*/
|
|
28
35
|
BaseComponent.prototype.setState = function (update, callback) {
|
|
29
36
|
// only clone state when copying to nextState the first time.
|
|
30
|
-
let s;
|
|
31
|
-
if (
|
|
32
|
-
s = this._nextState;
|
|
33
|
-
} else {
|
|
37
|
+
let s = this._nextState;
|
|
38
|
+
if (!s || s == this.state) {
|
|
34
39
|
s = this._nextState = assign({}, this.state);
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -42,11 +47,10 @@ BaseComponent.prototype.setState = function (update, callback) {
|
|
|
42
47
|
|
|
43
48
|
if (update) {
|
|
44
49
|
assign(s, update);
|
|
50
|
+
} else {
|
|
51
|
+
return;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
// Skip update if updater function returned null
|
|
48
|
-
if (update == NULL) return;
|
|
49
|
-
|
|
50
54
|
if (this._vnode) {
|
|
51
55
|
if (callback) {
|
|
52
56
|
this._stateCallbacks.push(callback);
|
|
@@ -66,7 +70,7 @@ BaseComponent.prototype.forceUpdate = function (callback) {
|
|
|
66
70
|
// Set render mode so that we can differentiate where the render request
|
|
67
71
|
// is coming from. We need this because forceUpdate should never call
|
|
68
72
|
// shouldComponentUpdate
|
|
69
|
-
this.
|
|
73
|
+
this._bits |= COMPONENT_FORCE;
|
|
70
74
|
if (callback) this._renderCallbacks.push(callback);
|
|
71
75
|
enqueueRender(this);
|
|
72
76
|
}
|
|
@@ -100,7 +104,7 @@ export function getDomSibling(vnode, childIndex) {
|
|
|
100
104
|
for (; childIndex < vnode._children.length; childIndex++) {
|
|
101
105
|
sibling = vnode._children[childIndex];
|
|
102
106
|
|
|
103
|
-
if (sibling
|
|
107
|
+
if (sibling && sibling._dom) {
|
|
104
108
|
// Since updateParentDomPointers keeps _dom pointer correct,
|
|
105
109
|
// we can rely on _dom to tell us if this subtree contains a
|
|
106
110
|
// rendered DOM node, and what the first rendered DOM node is
|
|
@@ -112,8 +116,10 @@ export function getDomSibling(vnode, childIndex) {
|
|
|
112
116
|
// We must resume from this vnode's sibling (in it's parent _children array)
|
|
113
117
|
// Only climb up and search the parent if we aren't searching through a DOM
|
|
114
118
|
// VNode (meaning we reached the DOM parent of the original vnode that began
|
|
115
|
-
// the search)
|
|
116
|
-
return typeof vnode.type == 'function'
|
|
119
|
+
// the search). New roots (_parentDom) are a DOM boundary too.
|
|
120
|
+
return typeof vnode.type == 'function' && !vnode.props._parentDom
|
|
121
|
+
? getDomSibling(vnode)
|
|
122
|
+
: NULL;
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
/**
|
|
@@ -121,32 +127,34 @@ export function getDomSibling(vnode, childIndex) {
|
|
|
121
127
|
* @param {import('./internal').Component} component The component to rerender
|
|
122
128
|
*/
|
|
123
129
|
function renderComponent(component) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
const oldVNode = component._vnode,
|
|
131
|
+
oldDom = oldVNode._dom,
|
|
132
|
+
commitQueue = [],
|
|
133
|
+
refQueue = [];
|
|
134
|
+
|
|
135
|
+
const parentDom = component._parentDom;
|
|
136
|
+
if (parentDom) {
|
|
137
|
+
const newVNode = assign({ constructor: UNDEFINED }, oldVNode);
|
|
130
138
|
newVNode._original = oldVNode._original + 1;
|
|
131
139
|
if (options.vnode) options.vnode(newVNode);
|
|
132
140
|
|
|
133
141
|
diff(
|
|
134
|
-
|
|
142
|
+
parentDom,
|
|
135
143
|
newVNode,
|
|
136
144
|
oldVNode,
|
|
137
145
|
component._globalContext,
|
|
138
|
-
|
|
146
|
+
parentDom.namespaceURI,
|
|
139
147
|
oldVNode._flags & MODE_HYDRATE ? [oldDom] : NULL,
|
|
140
148
|
commitQueue,
|
|
141
|
-
oldDom
|
|
142
|
-
|
|
149
|
+
oldDom || getDomSibling(oldVNode),
|
|
150
|
+
oldVNode._flags & MODE_HYDRATE,
|
|
143
151
|
refQueue
|
|
144
152
|
);
|
|
145
153
|
|
|
146
154
|
newVNode._original = oldVNode._original;
|
|
147
155
|
newVNode._parent._children[newVNode._index] = newVNode;
|
|
148
156
|
commitRoot(commitQueue, newVNode, refQueue);
|
|
149
|
-
oldVNode.
|
|
157
|
+
oldVNode._parent = oldVNode._dom = NULL;
|
|
150
158
|
|
|
151
159
|
if (newVNode._dom != oldDom) {
|
|
152
160
|
updateParentDomPointers(newVNode);
|
|
@@ -158,13 +166,12 @@ function renderComponent(component) {
|
|
|
158
166
|
* @param {import('./internal').VNode} vnode
|
|
159
167
|
*/
|
|
160
168
|
function updateParentDomPointers(vnode) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
169
|
+
// Stop at root boundaries (_parentDom)
|
|
170
|
+
if ((vnode = vnode._parent) && vnode._component && !vnode.props._parentDom) {
|
|
171
|
+
// _dom starts nulled, so re-assigning a null child._dom is a no-op and
|
|
172
|
+
// the first truthy _dom stops the walk.
|
|
173
|
+
vnode._dom = NULL;
|
|
174
|
+
vnode._children.some(child => child && (vnode._dom = child._dom));
|
|
168
175
|
|
|
169
176
|
return updateParentDomPointers(vnode);
|
|
170
177
|
}
|
|
@@ -174,7 +181,7 @@ function updateParentDomPointers(vnode) {
|
|
|
174
181
|
* The render queue
|
|
175
182
|
* @type {Array<import('./internal').Component>}
|
|
176
183
|
*/
|
|
177
|
-
|
|
184
|
+
const rerenderQueue = [];
|
|
178
185
|
|
|
179
186
|
/*
|
|
180
187
|
* The value of `Component.debounce` must asynchronously invoke the passed in callback. It is
|
|
@@ -185,12 +192,12 @@ let rerenderQueue = [];
|
|
|
185
192
|
* * [Callbacks synchronous and asynchronous](https://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/)
|
|
186
193
|
*/
|
|
187
194
|
|
|
188
|
-
let prevDebounce
|
|
195
|
+
let prevDebounce,
|
|
196
|
+
rerenderCount = 0;
|
|
189
197
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
: setTimeout;
|
|
198
|
+
export function resetRenderCount() {
|
|
199
|
+
rerenderCount = 0;
|
|
200
|
+
}
|
|
194
201
|
|
|
195
202
|
/**
|
|
196
203
|
* Enqueue a rerender of a component
|
|
@@ -198,14 +205,14 @@ const defer =
|
|
|
198
205
|
*/
|
|
199
206
|
export function enqueueRender(c) {
|
|
200
207
|
if (
|
|
201
|
-
(!c.
|
|
202
|
-
(c.
|
|
208
|
+
(!(c._bits & COMPONENT_DIRTY) &&
|
|
209
|
+
(c._bits |= COMPONENT_DIRTY) &&
|
|
203
210
|
rerenderQueue.push(c) &&
|
|
204
|
-
!
|
|
211
|
+
!rerenderCount++) ||
|
|
205
212
|
prevDebounce != options.debounceRendering
|
|
206
213
|
) {
|
|
207
214
|
prevDebounce = options.debounceRendering;
|
|
208
|
-
(prevDebounce ||
|
|
215
|
+
(prevDebounce || queueMicrotask)(process);
|
|
209
216
|
}
|
|
210
217
|
}
|
|
211
218
|
|
|
@@ -237,11 +244,11 @@ function process() {
|
|
|
237
244
|
c = rerenderQueue.shift();
|
|
238
245
|
l = rerenderQueue.length;
|
|
239
246
|
|
|
240
|
-
|
|
247
|
+
if (c._bits & COMPONENT_DIRTY) {
|
|
248
|
+
renderComponent(c);
|
|
249
|
+
}
|
|
241
250
|
}
|
|
242
251
|
} finally {
|
|
243
|
-
rerenderQueue.length =
|
|
252
|
+
rerenderQueue.length = rerenderCount = 0;
|
|
244
253
|
}
|
|
245
254
|
}
|
|
246
|
-
|
|
247
|
-
process._rerenderCount = 0;
|
package/preact/src/constants.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Vnode._flags
|
|
1
2
|
/** Normal hydration that attaches to a DOM tree but does not diff it. */
|
|
2
3
|
export const MODE_HYDRATE = 1 << 5;
|
|
3
4
|
/** Signifies this VNode suspended on the previous render */
|
|
@@ -6,6 +7,20 @@ export const MODE_SUSPENDED = 1 << 7;
|
|
|
6
7
|
export const INSERT_VNODE = 1 << 2;
|
|
7
8
|
/** Indicates a VNode has been matched with another VNode in the diff */
|
|
8
9
|
export const MATCHED = 1 << 1;
|
|
10
|
+
/** Indicates that this vnode has been unmounted before indicating the loss of event listeners */
|
|
11
|
+
export const FORCE_PROPS_REVALIDATE = 1 << 0;
|
|
12
|
+
/** The vnode's ref was detached while its subtree was parked by Suspense */
|
|
13
|
+
export const REF_DETACHED = 1 << 3;
|
|
14
|
+
|
|
15
|
+
// component._bits
|
|
16
|
+
/** Component is processing an exception */
|
|
17
|
+
export const COMPONENT_PROCESSING_EXCEPTION = 1 << 0;
|
|
18
|
+
/** Component has a pending error */
|
|
19
|
+
export const COMPONENT_PENDING_ERROR = 1 << 1;
|
|
20
|
+
/** Component should force update (skip shouldComponentUpdate) */
|
|
21
|
+
export const COMPONENT_FORCE = 1 << 2;
|
|
22
|
+
/** Component is queued for update */
|
|
23
|
+
export const COMPONENT_DIRTY = 1 << 3;
|
|
9
24
|
|
|
10
25
|
/** Reset all mode flags */
|
|
11
26
|
export const RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);
|
|
@@ -18,5 +33,5 @@ export const NULL = null;
|
|
|
18
33
|
export const UNDEFINED = undefined;
|
|
19
34
|
export const EMPTY_OBJ = /** @type {any} */ ({});
|
|
20
35
|
export const EMPTY_ARR = [];
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
|
|
37
|
+
export const MATHML_TOKEN_ELEMENTS = /^m(i|n|o|s|text|space)$/;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { enqueueRender } from './component';
|
|
2
|
-
import {
|
|
2
|
+
import { COMPONENT_FORCE } from './constants';
|
|
3
3
|
|
|
4
4
|
export let i = 0;
|
|
5
5
|
|
|
@@ -13,15 +13,11 @@ export function createContext(defaultValue) {
|
|
|
13
13
|
|
|
14
14
|
this.getChildContext = () => ctx;
|
|
15
15
|
|
|
16
|
-
this.componentWillUnmount = () => {
|
|
17
|
-
subs = NULL;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
16
|
this.shouldComponentUpdate = function (_props) {
|
|
21
17
|
// @ts-expect-error even
|
|
22
18
|
if (this.props.value != _props.value) {
|
|
23
19
|
subs.forEach(c => {
|
|
24
|
-
c.
|
|
20
|
+
c._bits |= COMPONENT_FORCE;
|
|
25
21
|
enqueueRender(c);
|
|
26
22
|
});
|
|
27
23
|
}
|
|
@@ -31,9 +27,7 @@ export function createContext(defaultValue) {
|
|
|
31
27
|
subs.add(c);
|
|
32
28
|
let old = c.componentWillUnmount;
|
|
33
29
|
c.componentWillUnmount = () => {
|
|
34
|
-
|
|
35
|
-
subs.delete(c);
|
|
36
|
-
}
|
|
30
|
+
subs.delete(c);
|
|
37
31
|
if (old) old.call(c);
|
|
38
32
|
};
|
|
39
33
|
};
|
|
@@ -50,11 +44,7 @@ export function createContext(defaultValue) {
|
|
|
50
44
|
return props.children(contextValue);
|
|
51
45
|
};
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
Context.Provider =
|
|
55
|
-
Context._contextRef =
|
|
56
|
-
Context.Consumer.contextType =
|
|
57
|
-
Context;
|
|
47
|
+
Context.Provider = Context.Consumer.contextType = Context;
|
|
58
48
|
|
|
59
49
|
return Context;
|
|
60
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { slice } from './util';
|
|
1
|
+
import { assign, slice } from './util';
|
|
2
2
|
import options from './options';
|
|
3
3
|
import { NULL, UNDEFINED } from './constants';
|
|
4
4
|
|
|
@@ -17,29 +17,54 @@ export function createElement(type, props, children) {
|
|
|
17
17
|
let normalizedProps = {},
|
|
18
18
|
key,
|
|
19
19
|
ref,
|
|
20
|
-
i
|
|
20
|
+
i,
|
|
21
|
+
length = arguments.length;
|
|
21
22
|
for (i in props) {
|
|
22
23
|
if (i == 'key') key = props[i];
|
|
23
|
-
else if (i == 'ref') ref = props[i];
|
|
24
|
+
else if (i == 'ref' && typeof type != 'function') ref = props[i];
|
|
24
25
|
else normalizedProps[i] = props[i];
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
if (
|
|
28
|
-
normalizedProps.children =
|
|
29
|
-
arguments.length > 3 ? slice.call(arguments, 2) : children;
|
|
28
|
+
if (length > 2) {
|
|
29
|
+
normalizedProps.children = length > 3 ? slice.call(arguments, 2) : children;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
return createVNode(type, normalizedProps, key, ref, NULL);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Clones the given VNode, optionally adding attributes/props and replacing its
|
|
37
|
+
* children.
|
|
38
|
+
* @param {import('./internal').VNode} vnode The virtual DOM element to clone
|
|
39
|
+
* @param {object} props Attributes/props to add when cloning
|
|
40
|
+
* @param {Array<import('./internal').ComponentChildren>} children Any additional arguments will be used
|
|
41
|
+
* as replacement children.
|
|
42
|
+
* @returns {import('./internal').VNode}
|
|
43
|
+
*/
|
|
44
|
+
export function cloneElement(vnode, props, children) {
|
|
45
|
+
let normalizedProps = assign({}, vnode.props),
|
|
46
|
+
key,
|
|
47
|
+
ref,
|
|
48
|
+
i,
|
|
49
|
+
length = arguments.length;
|
|
50
|
+
|
|
51
|
+
for (i in props) {
|
|
52
|
+
if (i == 'key') key = props[i];
|
|
53
|
+
else if (i == 'ref' && typeof vnode.type != 'function') ref = props[i];
|
|
54
|
+
else normalizedProps[i] = props[i];
|
|
40
55
|
}
|
|
41
56
|
|
|
42
|
-
|
|
57
|
+
if (length > 2) {
|
|
58
|
+
normalizedProps.children = length > 3 ? slice.call(arguments, 2) : children;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return createVNode(
|
|
62
|
+
vnode.type,
|
|
63
|
+
normalizedProps,
|
|
64
|
+
key !== UNDEFINED ? key : vnode.key,
|
|
65
|
+
ref !== UNDEFINED ? ref : vnode.ref,
|
|
66
|
+
NULL
|
|
67
|
+
);
|
|
43
68
|
}
|
|
44
69
|
|
|
45
70
|
/**
|
|
@@ -69,13 +94,13 @@ export function createVNode(type, props, key, ref, original) {
|
|
|
69
94
|
_dom: NULL,
|
|
70
95
|
_component: NULL,
|
|
71
96
|
constructor: UNDEFINED,
|
|
72
|
-
_original: original
|
|
97
|
+
_original: original || ++vnodeId,
|
|
73
98
|
_index: -1,
|
|
74
99
|
_flags: 0
|
|
75
100
|
};
|
|
76
101
|
|
|
77
102
|
// Only invoke the vnode hook if this was *not* a direct copy:
|
|
78
|
-
if (original
|
|
103
|
+
if (!original && options.vnode) options.vnode(vnode);
|
|
79
104
|
|
|
80
105
|
return vnode;
|
|
81
106
|
}
|