@bpmn-io/properties-panel 3.13.0 → 3.14.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/assets/properties-panel.css +0 -4
- package/dist/index.esm.js +31 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +66 -63
- package/dist/index.js.map +1 -1
- package/package.json +27 -30
- package/preact/README.md +2 -2
- package/preact/compat/LICENSE +21 -0
- package/preact/compat/dist/compat.js +1 -1
- package/preact/compat/dist/compat.js.map +1 -1
- package/preact/compat/dist/compat.mjs +1 -1
- package/preact/compat/dist/compat.module.js +1 -1
- package/preact/compat/dist/compat.module.js.map +1 -1
- package/preact/compat/dist/compat.umd.js +1 -1
- package/preact/compat/dist/compat.umd.js.map +1 -1
- package/preact/compat/server.browser.js +7 -0
- package/preact/compat/server.mjs +7 -0
- package/preact/compat/src/index.d.ts +22 -8
- package/preact/compat/src/index.js +35 -3
- package/preact/compat/src/portals.js +26 -35
- package/preact/compat/src/suspense.js +9 -6
- package/preact/compat/src/util.js +0 -5
- package/preact/debug/LICENSE +21 -0
- package/preact/debug/dist/debug.js +1 -1
- package/preact/debug/dist/debug.js.map +1 -1
- package/preact/debug/dist/debug.mjs +1 -1
- package/preact/debug/dist/debug.module.js +1 -1
- package/preact/debug/dist/debug.module.js.map +1 -1
- package/preact/debug/dist/debug.umd.js +1 -1
- package/preact/debug/dist/debug.umd.js.map +1 -1
- package/preact/debug/src/debug.js +124 -42
- package/preact/devtools/LICENSE +21 -0
- package/preact/devtools/dist/devtools.js +1 -1
- package/preact/devtools/dist/devtools.js.map +1 -1
- package/preact/devtools/dist/devtools.mjs +1 -1
- package/preact/devtools/dist/devtools.module.js +1 -1
- package/preact/devtools/dist/devtools.module.js.map +1 -1
- package/preact/devtools/dist/devtools.umd.js +1 -1
- package/preact/devtools/dist/devtools.umd.js.map +1 -1
- package/preact/devtools/src/devtools.js +1 -1
- package/preact/dist/preact.js +1 -1
- package/preact/dist/preact.js.map +1 -1
- package/preact/dist/preact.min.js +1 -1
- package/preact/dist/preact.min.js.map +1 -1
- package/preact/dist/preact.min.module.js +1 -1
- package/preact/dist/preact.min.module.js.map +1 -1
- package/preact/dist/preact.min.umd.js +1 -1
- package/preact/dist/preact.min.umd.js.map +1 -1
- package/preact/dist/preact.mjs +1 -1
- package/preact/dist/preact.module.js +1 -1
- package/preact/dist/preact.module.js.map +1 -1
- package/preact/dist/preact.umd.js +1 -1
- package/preact/dist/preact.umd.js.map +1 -1
- package/preact/hooks/LICENSE +21 -0
- package/preact/jsx-runtime/LICENSE +21 -0
- package/preact/jsx-runtime/dist/jsxRuntime.js +1 -1
- package/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -1
- package/preact/jsx-runtime/dist/jsxRuntime.mjs +1 -1
- package/preact/jsx-runtime/dist/jsxRuntime.module.js +1 -1
- package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -1
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js +1 -1
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
- package/preact/jsx-runtime/src/index.d.ts +10 -0
- package/preact/jsx-runtime/src/index.js +113 -4
- package/preact/jsx-runtime/src/utils.js +36 -0
- package/preact/package.json +4 -3
- package/preact/src/clone-element.js +6 -4
- package/preact/src/component.js +34 -28
- package/preact/src/constants.js +13 -1
- package/preact/src/create-context.js +3 -3
- package/preact/src/create-element.js +14 -11
- package/preact/src/diff/catch-error.js +11 -7
- package/preact/src/diff/children.js +321 -218
- package/preact/src/diff/index.js +188 -142
- package/preact/src/diff/props.js +31 -38
- package/preact/src/index.d.ts +38 -19
- package/preact/src/index.js +1 -1
- package/preact/src/internal.d.ts +183 -153
- package/preact/src/jsx.d.ts +883 -19
- package/preact/src/options.js +1 -1
- package/preact/src/render.js +11 -11
- package/preact/src/util.js +2 -2
- package/preact/test-utils/dist/testUtils.js +1 -1
- package/preact/test-utils/dist/testUtils.js.map +1 -1
- package/preact/test-utils/dist/testUtils.mjs +1 -1
- package/preact/test-utils/dist/testUtils.module.js +1 -1
- package/preact/test-utils/dist/testUtils.module.js.map +1 -1
- package/preact/test-utils/dist/testUtils.umd.js +1 -1
- package/preact/test-utils/dist/testUtils.umd.js.map +1 -1
- package/preact/test-utils/src/index.js +13 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsxRuntime.umd.js","sources":["../src/index.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"jsxRuntime.umd.js","sources":["../src/utils.js","../../src/constants.js","../src/index.js"],"sourcesContent":["const ENCODED_ENTITIES = /[\"&<]/;\n\n/** @param {string} str */\nexport function encodeEntities(str) {\n\t// Skip all work for strings with no entities needing encoding:\n\tif (str.length === 0 || ENCODED_ENTITIES.test(str) === false) return str;\n\n\tlet last = 0,\n\t\ti = 0,\n\t\tout = '',\n\t\tch = '';\n\n\t// Seek forward in str until the next entity char:\n\tfor (; i < str.length; i++) {\n\t\tswitch (str.charCodeAt(i)) {\n\t\t\tcase 34:\n\t\t\t\tch = '"';\n\t\t\t\tbreak;\n\t\t\tcase 38:\n\t\t\t\tch = '&';\n\t\t\t\tbreak;\n\t\t\tcase 60:\n\t\t\t\tch = '<';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tcontinue;\n\t\t}\n\t\t// Append skipped/buffered characters and the encoded entity:\n\t\tif (i !== last) out += str.slice(last, i);\n\t\tout += ch;\n\t\t// Start the next seek/buffer after the entity's offset:\n\t\tlast = i + 1;\n\t}\n\tif (i !== last) out += str.slice(last, i);\n\treturn out;\n}\n","/** Normal hydration that attaches to a DOM tree but does not diff it. */\nexport const MODE_HYDRATE = 1 << 5;\n/** Signifies this VNode suspended on the previous render */\nexport const MODE_SUSPENDED = 1 << 7;\n/** Indicates that this node needs to be inserted while patching children */\nexport const INSERT_VNODE = 1 << 16;\n/** Indicates a VNode has been matched with another VNode in the diff */\nexport const MATCHED = 1 << 17;\n\n/** Reset all mode flags */\nexport const RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);\n\nexport const EMPTY_OBJ = /** @type {any} */ ({});\nexport const EMPTY_ARR = [];\nexport const IS_NON_DIMENSIONAL =\n\t/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;\n","import { options, Fragment } from '../..';\nimport { encodeEntities } from './utils';\nimport { IS_NON_DIMENSIONAL } from '../../src/constants';\n\nlet vnodeId = 0;\n\nconst isArray = Array.isArray;\n\n/**\n * @fileoverview\n * This file exports various methods that implement Babel's \"automatic\" JSX runtime API:\n * - jsx(type, props, key)\n * - jsxs(type, props, key)\n * - jsxDEV(type, props, key, __source, __self)\n *\n * The implementation of createVNode here is optimized for performance.\n * Benchmarks: https://esbench.com/bench/5f6b54a0b4632100a7dcd2b3\n */\n\n/**\n * JSX.Element factory used by Babel's {runtime:\"automatic\"} JSX transform\n * @param {VNode['type']} type\n * @param {VNode['props']} props\n * @param {VNode['key']} [key]\n * @param {unknown} [isStaticChildren]\n * @param {unknown} [__source]\n * @param {unknown} [__self]\n */\nfunction createVNode(type, props, key, isStaticChildren, __source, __self) {\n\t// We'll want to preserve `ref` in props to get rid of the need for\n\t// forwardRef components in the future, but that should happen via\n\t// a separate PR.\n\tlet normalizedProps = {},\n\t\tref,\n\t\ti;\n\tfor (i in props) {\n\t\tif (i == 'ref') {\n\t\t\tref = props[i];\n\t\t} else {\n\t\t\tnormalizedProps[i] = props[i];\n\t\t}\n\t}\n\n\t/** @type {VNode & { __source: any; __self: any }} */\n\tconst vnode = {\n\t\ttype,\n\t\tprops: normalizedProps,\n\t\tkey,\n\t\tref,\n\t\t_children: null,\n\t\t_parent: null,\n\t\t_depth: 0,\n\t\t_dom: null,\n\t\t_nextDom: undefined,\n\t\t_component: null,\n\t\tconstructor: undefined,\n\t\t_original: --vnodeId,\n\t\t_index: -1,\n\t\t_flags: 0,\n\t\t__source,\n\t\t__self\n\t};\n\n\t// If a Component VNode, check for and apply defaultProps.\n\t// Note: `type` is often a String, and can be `undefined` in development.\n\tif (typeof type === 'function' && (ref = type.defaultProps)) {\n\t\tfor (i in ref)\n\t\t\tif (typeof normalizedProps[i] === 'undefined') {\n\t\t\t\tnormalizedProps[i] = ref[i];\n\t\t\t}\n\t}\n\n\tif (options.vnode) options.vnode(vnode);\n\treturn vnode;\n}\n\n/**\n * Create a template vnode. This function is not expected to be\n * used directly, but rather through a precompile JSX transform\n * @param {string[]} templates\n * @param {Array<string | null | VNode>} exprs\n * @returns {VNode}\n */\nfunction jsxTemplate(templates, ...exprs) {\n\tconst vnode = createVNode(Fragment, { tpl: templates, exprs });\n\t// Bypass render to string top level Fragment optimization\n\tvnode.key = vnode._vnode;\n\treturn vnode;\n}\n\nconst JS_TO_CSS = {};\nconst CSS_REGEX = /[A-Z]/g;\n\n/**\n * Serialize an HTML attribute to a string. This function is not\n * expected to be used directly, but rather through a precompile\n * JSX transform\n * @param {string} name The attribute name\n * @param {*} value The attribute value\n * @returns {string}\n */\nfunction jsxAttr(name, value) {\n\tif (options.attr) {\n\t\tconst result = options.attr(name, value);\n\t\tif (typeof result === 'string') return result;\n\t}\n\n\tif (name === 'ref' || name === 'key') return '';\n\tif (name === 'style' && typeof value === 'object') {\n\t\tlet str = '';\n\t\tfor (let prop in value) {\n\t\t\tlet val = value[prop];\n\t\t\tif (val != null && val !== '') {\n\t\t\t\tconst name =\n\t\t\t\t\tprop[0] == '-'\n\t\t\t\t\t\t? prop\n\t\t\t\t\t\t: JS_TO_CSS[prop] ||\n\t\t\t\t\t\t (JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$&').toLowerCase());\n\n\t\t\t\tlet suffix = ';';\n\t\t\t\tif (\n\t\t\t\t\ttypeof val === 'number' &&\n\t\t\t\t\t// Exclude custom-attributes\n\t\t\t\t\t!name.startsWith('--') &&\n\t\t\t\t\t!IS_NON_DIMENSIONAL.test(name)\n\t\t\t\t) {\n\t\t\t\t\tsuffix = 'px;';\n\t\t\t\t}\n\t\t\t\tstr = str + name + ':' + val + suffix;\n\t\t\t}\n\t\t}\n\t\treturn name + '=\"' + str + '\"';\n\t}\n\n\tif (\n\t\tvalue == null ||\n\t\tvalue === false ||\n\t\ttypeof value === 'function' ||\n\t\ttypeof value === 'object'\n\t) {\n\t\treturn '';\n\t} else if (value === true) return name;\n\n\treturn name + '=\"' + encodeEntities(value) + '\"';\n}\n\n/**\n * Escape a dynamic child passed to `jsxTemplate`. This function\n * is not expected to be used directly, but rather through a\n * precompile JSX transform\n * @param {*} value\n * @returns {string | null | VNode | Array<string | null | VNode>}\n */\nfunction jsxEscape(value) {\n\tif (\n\t\tvalue == null ||\n\t\ttypeof value === 'boolean' ||\n\t\ttypeof value === 'function'\n\t) {\n\t\treturn null;\n\t}\n\n\tif (typeof value === 'object') {\n\t\t// Check for VNode\n\t\tif (value.constructor === undefined) return value;\n\n\t\tif (isArray(value)) {\n\t\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\t\tvalue[i] = jsxEscape(value[i]);\n\t\t\t}\n\t\t\treturn value;\n\t\t}\n\t}\n\n\treturn encodeEntities('' + value);\n}\n\nexport {\n\tcreateVNode as jsx,\n\tcreateVNode as jsxs,\n\tcreateVNode as jsxDEV,\n\tFragment,\n\t// precompiled JSX transform\n\tjsxTemplate,\n\tjsxAttr,\n\tjsxEscape\n};\n"],"names":["ENCODED_ENTITIES","encodeEntities","str","length","test","last","i","out","ch","charCodeAt","slice","IS_NON_DIMENSIONAL","vnodeId","isArray","Array","createVNode","type","props","key","isStaticChildren","__source","__self","ref","normalizedProps","vnode","__k","__","__b","__e","__d","undefined","__c","constructor","__v","__i","__u","defaultProps","options","JS_TO_CSS","CSS_REGEX","name","value","attr","result","prop","val","replace","toLowerCase","suffix","startsWith","jsxEscape","templates","Fragment","tpl","exprs","call","arguments"],"mappings":"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"}
|
|
@@ -47,4 +47,14 @@ export function jsxDEV<P>(
|
|
|
47
47
|
key?: string
|
|
48
48
|
): VNode<any>;
|
|
49
49
|
|
|
50
|
+
// These are not expected to be used manually, but by a JSX transform
|
|
51
|
+
export function jsxTemplate(
|
|
52
|
+
template: string[],
|
|
53
|
+
...expressions: any[]
|
|
54
|
+
): VNode<any>;
|
|
55
|
+
export function jsxAttr(name: string, value: any): string | null;
|
|
56
|
+
export function jsxEscape<T>(
|
|
57
|
+
value: T
|
|
58
|
+
): string | null | VNode<any> | Array<string | null | VNode>;
|
|
59
|
+
|
|
50
60
|
export { JSXInternal as JSX };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { options, Fragment } from '../..';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { encodeEntities } from './utils';
|
|
3
|
+
import { IS_NON_DIMENSIONAL } from '../../src/constants';
|
|
4
4
|
|
|
5
5
|
let vnodeId = 0;
|
|
6
6
|
|
|
7
|
+
const isArray = Array.isArray;
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* @fileoverview
|
|
9
11
|
* This file exports various methods that implement Babel's "automatic" JSX runtime API:
|
|
@@ -39,6 +41,7 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
/** @type {VNode & { __source: any; __self: any }} */
|
|
42
45
|
const vnode = {
|
|
43
46
|
type,
|
|
44
47
|
props: normalizedProps,
|
|
@@ -50,9 +53,10 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
|
|
|
50
53
|
_dom: null,
|
|
51
54
|
_nextDom: undefined,
|
|
52
55
|
_component: null,
|
|
53
|
-
_hydrating: null,
|
|
54
56
|
constructor: undefined,
|
|
55
57
|
_original: --vnodeId,
|
|
58
|
+
_index: -1,
|
|
59
|
+
_flags: 0,
|
|
56
60
|
__source,
|
|
57
61
|
__self
|
|
58
62
|
};
|
|
@@ -70,9 +74,114 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
|
|
|
70
74
|
return vnode;
|
|
71
75
|
}
|
|
72
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Create a template vnode. This function is not expected to be
|
|
79
|
+
* used directly, but rather through a precompile JSX transform
|
|
80
|
+
* @param {string[]} templates
|
|
81
|
+
* @param {Array<string | null | VNode>} exprs
|
|
82
|
+
* @returns {VNode}
|
|
83
|
+
*/
|
|
84
|
+
function jsxTemplate(templates, ...exprs) {
|
|
85
|
+
const vnode = createVNode(Fragment, { tpl: templates, exprs });
|
|
86
|
+
// Bypass render to string top level Fragment optimization
|
|
87
|
+
vnode.key = vnode._vnode;
|
|
88
|
+
return vnode;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const JS_TO_CSS = {};
|
|
92
|
+
const CSS_REGEX = /[A-Z]/g;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Serialize an HTML attribute to a string. This function is not
|
|
96
|
+
* expected to be used directly, but rather through a precompile
|
|
97
|
+
* JSX transform
|
|
98
|
+
* @param {string} name The attribute name
|
|
99
|
+
* @param {*} value The attribute value
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
102
|
+
function jsxAttr(name, value) {
|
|
103
|
+
if (options.attr) {
|
|
104
|
+
const result = options.attr(name, value);
|
|
105
|
+
if (typeof result === 'string') return result;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (name === 'ref' || name === 'key') return '';
|
|
109
|
+
if (name === 'style' && typeof value === 'object') {
|
|
110
|
+
let str = '';
|
|
111
|
+
for (let prop in value) {
|
|
112
|
+
let val = value[prop];
|
|
113
|
+
if (val != null && val !== '') {
|
|
114
|
+
const name =
|
|
115
|
+
prop[0] == '-'
|
|
116
|
+
? prop
|
|
117
|
+
: JS_TO_CSS[prop] ||
|
|
118
|
+
(JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$&').toLowerCase());
|
|
119
|
+
|
|
120
|
+
let suffix = ';';
|
|
121
|
+
if (
|
|
122
|
+
typeof val === 'number' &&
|
|
123
|
+
// Exclude custom-attributes
|
|
124
|
+
!name.startsWith('--') &&
|
|
125
|
+
!IS_NON_DIMENSIONAL.test(name)
|
|
126
|
+
) {
|
|
127
|
+
suffix = 'px;';
|
|
128
|
+
}
|
|
129
|
+
str = str + name + ':' + val + suffix;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return name + '="' + str + '"';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (
|
|
136
|
+
value == null ||
|
|
137
|
+
value === false ||
|
|
138
|
+
typeof value === 'function' ||
|
|
139
|
+
typeof value === 'object'
|
|
140
|
+
) {
|
|
141
|
+
return '';
|
|
142
|
+
} else if (value === true) return name;
|
|
143
|
+
|
|
144
|
+
return name + '="' + encodeEntities(value) + '"';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Escape a dynamic child passed to `jsxTemplate`. This function
|
|
149
|
+
* is not expected to be used directly, but rather through a
|
|
150
|
+
* precompile JSX transform
|
|
151
|
+
* @param {*} value
|
|
152
|
+
* @returns {string | null | VNode | Array<string | null | VNode>}
|
|
153
|
+
*/
|
|
154
|
+
function jsxEscape(value) {
|
|
155
|
+
if (
|
|
156
|
+
value == null ||
|
|
157
|
+
typeof value === 'boolean' ||
|
|
158
|
+
typeof value === 'function'
|
|
159
|
+
) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (typeof value === 'object') {
|
|
164
|
+
// Check for VNode
|
|
165
|
+
if (value.constructor === undefined) return value;
|
|
166
|
+
|
|
167
|
+
if (isArray(value)) {
|
|
168
|
+
for (let i = 0; i < value.length; i++) {
|
|
169
|
+
value[i] = jsxEscape(value[i]);
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return encodeEntities('' + value);
|
|
176
|
+
}
|
|
177
|
+
|
|
73
178
|
export {
|
|
74
179
|
createVNode as jsx,
|
|
75
180
|
createVNode as jsxs,
|
|
76
181
|
createVNode as jsxDEV,
|
|
77
|
-
Fragment
|
|
182
|
+
Fragment,
|
|
183
|
+
// precompiled JSX transform
|
|
184
|
+
jsxTemplate,
|
|
185
|
+
jsxAttr,
|
|
186
|
+
jsxEscape
|
|
78
187
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const ENCODED_ENTITIES = /["&<]/;
|
|
2
|
+
|
|
3
|
+
/** @param {string} str */
|
|
4
|
+
export function encodeEntities(str) {
|
|
5
|
+
// Skip all work for strings with no entities needing encoding:
|
|
6
|
+
if (str.length === 0 || ENCODED_ENTITIES.test(str) === false) return str;
|
|
7
|
+
|
|
8
|
+
let last = 0,
|
|
9
|
+
i = 0,
|
|
10
|
+
out = '',
|
|
11
|
+
ch = '';
|
|
12
|
+
|
|
13
|
+
// Seek forward in str until the next entity char:
|
|
14
|
+
for (; i < str.length; i++) {
|
|
15
|
+
switch (str.charCodeAt(i)) {
|
|
16
|
+
case 34:
|
|
17
|
+
ch = '"';
|
|
18
|
+
break;
|
|
19
|
+
case 38:
|
|
20
|
+
ch = '&';
|
|
21
|
+
break;
|
|
22
|
+
case 60:
|
|
23
|
+
ch = '<';
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// Append skipped/buffered characters and the encoded entity:
|
|
29
|
+
if (i !== last) out += str.slice(last, i);
|
|
30
|
+
out += ch;
|
|
31
|
+
// Start the next seek/buffer after the entity's offset:
|
|
32
|
+
last = i + 1;
|
|
33
|
+
}
|
|
34
|
+
if (i !== last) out += str.slice(last, i);
|
|
35
|
+
return out;
|
|
36
|
+
}
|
package/preact/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preact",
|
|
3
3
|
"amdName": "preact",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.19.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Fast 3kb React-compatible Virtual DOM library.",
|
|
7
7
|
"main": "dist/preact.js",
|
|
@@ -132,7 +132,8 @@
|
|
|
132
132
|
"test:karma:test-utils": "cross-env PERFORMANCE=false COVERAGE=false BABEL_NO_MODULES=true karma start karma.conf.js --grep=test-utils/test/shared/**.js --no-single-run",
|
|
133
133
|
"test:karma:bench": "cross-env PERFORMANCE=true COVERAGE=false BABEL_NO_MODULES=true karma start karma.conf.js --grep=test/benchmarks/**.js --single-run",
|
|
134
134
|
"benchmark": "npm run test:karma:bench -- no-single-run",
|
|
135
|
-
"lint": "run-s eslint",
|
|
135
|
+
"lint": "run-s eslint tsc",
|
|
136
|
+
"tsc": "tsc -p jsconfig-lint.json",
|
|
136
137
|
"eslint": "eslint src test debug compat hooks test-utils",
|
|
137
138
|
"format": "prettier --write \"**/*.{js,jsx,mjs,cjs,ts,tsx,yml,json,html,md,css,scss}\"",
|
|
138
139
|
"format:check": "prettier --check '**/*.{js,jsx,mjs,cjs,ts,tsx,yml,json,html,md,css,scss}'"
|
|
@@ -312,6 +313,6 @@
|
|
|
312
313
|
"webdriverio": "7.30.2"
|
|
313
314
|
},
|
|
314
315
|
"volta": {
|
|
315
|
-
"node": "
|
|
316
|
+
"node": "20.9.0"
|
|
316
317
|
}
|
|
317
318
|
}
|
|
@@ -2,11 +2,13 @@ import { assign, slice } from './util';
|
|
|
2
2
|
import { createVNode } from './create-element';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Clones the given VNode, optionally adding attributes/props and replacing its
|
|
6
|
-
*
|
|
5
|
+
* Clones the given VNode, optionally adding attributes/props and replacing its
|
|
6
|
+
* children.
|
|
7
|
+
* @param {VNode} vnode The virtual DOM element to clone
|
|
7
8
|
* @param {object} props Attributes/props to add when cloning
|
|
8
|
-
* @param {Array<
|
|
9
|
-
*
|
|
9
|
+
* @param {Array<ComponentChildren>} rest Any additional arguments will be used
|
|
10
|
+
* as replacement children.
|
|
11
|
+
* @returns {VNode}
|
|
10
12
|
*/
|
|
11
13
|
export function cloneElement(vnode, props, children) {
|
|
12
14
|
let normalizedProps = assign({}, vnode.props),
|
package/preact/src/component.js
CHANGED
|
@@ -2,6 +2,7 @@ import { assign } from './util';
|
|
|
2
2
|
import { diff, commitRoot } from './diff/index';
|
|
3
3
|
import options from './options';
|
|
4
4
|
import { Fragment } from './create-element';
|
|
5
|
+
import { MODE_HYDRATE } from './constants';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Base Component class. Provides `setState()` and `forceUpdate()`, which
|
|
@@ -10,21 +11,21 @@ import { Fragment } from './create-element';
|
|
|
10
11
|
* @param {object} context The initial context from parent components'
|
|
11
12
|
* getChildContext
|
|
12
13
|
*/
|
|
13
|
-
export function
|
|
14
|
+
export function BaseComponent(props, context) {
|
|
14
15
|
this.props = props;
|
|
15
16
|
this.context = context;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Update component state and schedule a re-render.
|
|
20
|
-
* @this {
|
|
21
|
+
* @this {Component}
|
|
21
22
|
* @param {object | ((s: object, p: object) => object)} update A hash of state
|
|
22
23
|
* properties to update with new values or a function that given the current
|
|
23
24
|
* state and props returns a new partial state
|
|
24
25
|
* @param {() => void} [callback] A function to be called once component state is
|
|
25
26
|
* updated
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
BaseComponent.prototype.setState = function (update, callback) {
|
|
28
29
|
// only clone state when copying to nextState the first time.
|
|
29
30
|
let s;
|
|
30
31
|
if (this._nextState != null && this._nextState !== this.state) {
|
|
@@ -56,11 +57,11 @@ Component.prototype.setState = function (update, callback) {
|
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
59
|
* Immediately perform a synchronous re-render of the component
|
|
59
|
-
* @this {
|
|
60
|
+
* @this {Component}
|
|
60
61
|
* @param {() => void} [callback] A function to be called after component is
|
|
61
62
|
* re-rendered
|
|
62
63
|
*/
|
|
63
|
-
|
|
64
|
+
BaseComponent.prototype.forceUpdate = function (callback) {
|
|
64
65
|
if (this._vnode) {
|
|
65
66
|
// Set render mode so that we can differentiate where the render request
|
|
66
67
|
// is coming from. We need this because forceUpdate should never call
|
|
@@ -79,19 +80,19 @@ Component.prototype.forceUpdate = function (callback) {
|
|
|
79
80
|
* @param {object} state The component's current state
|
|
80
81
|
* @param {object} context Context object, as returned by the nearest
|
|
81
82
|
* ancestor's `getChildContext()`
|
|
82
|
-
* @returns {
|
|
83
|
+
* @returns {ComponentChildren | void}
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
+
BaseComponent.prototype.render = Fragment;
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
|
-
* @param {
|
|
88
|
+
* @param {VNode} vnode
|
|
88
89
|
* @param {number | null} [childIndex]
|
|
89
90
|
*/
|
|
90
91
|
export function getDomSibling(vnode, childIndex) {
|
|
91
92
|
if (childIndex == null) {
|
|
92
93
|
// Use childIndex==null as a signal to resume the search from the vnode's sibling
|
|
93
94
|
return vnode._parent
|
|
94
|
-
? getDomSibling(vnode._parent, vnode.
|
|
95
|
+
? getDomSibling(vnode._parent, vnode._index + 1)
|
|
95
96
|
: null;
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -117,39 +118,44 @@ export function getDomSibling(vnode, childIndex) {
|
|
|
117
118
|
|
|
118
119
|
/**
|
|
119
120
|
* Trigger in-place re-rendering of a component.
|
|
120
|
-
* @param {
|
|
121
|
+
* @param {Component} component The component to rerender
|
|
121
122
|
*/
|
|
122
123
|
function renderComponent(component) {
|
|
123
|
-
let
|
|
124
|
-
oldDom =
|
|
125
|
-
parentDom = component._parentDom
|
|
124
|
+
let oldVNode = component._vnode,
|
|
125
|
+
oldDom = oldVNode._dom,
|
|
126
|
+
parentDom = component._parentDom,
|
|
127
|
+
commitQueue = [],
|
|
128
|
+
refQueue = [];
|
|
126
129
|
|
|
127
130
|
if (parentDom) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
const newVNode = assign({}, oldVNode);
|
|
132
|
+
newVNode._original = oldVNode._original + 1;
|
|
133
|
+
if (options.vnode) options.vnode(newVNode);
|
|
131
134
|
|
|
132
135
|
diff(
|
|
133
136
|
parentDom,
|
|
134
|
-
|
|
137
|
+
newVNode,
|
|
135
138
|
oldVNode,
|
|
136
139
|
component._globalContext,
|
|
137
140
|
parentDom.ownerSVGElement !== undefined,
|
|
138
|
-
|
|
141
|
+
oldVNode._flags & MODE_HYDRATE ? [oldDom] : null,
|
|
139
142
|
commitQueue,
|
|
140
|
-
oldDom == null ? getDomSibling(
|
|
141
|
-
|
|
143
|
+
oldDom == null ? getDomSibling(oldVNode) : oldDom,
|
|
144
|
+
!!(oldVNode._flags & MODE_HYDRATE),
|
|
145
|
+
refQueue
|
|
142
146
|
);
|
|
143
|
-
commitRoot(commitQueue, vnode);
|
|
144
147
|
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
newVNode._parent._children[newVNode._index] = newVNode;
|
|
149
|
+
commitRoot(commitQueue, newVNode, refQueue);
|
|
150
|
+
|
|
151
|
+
if (newVNode._dom != oldDom) {
|
|
152
|
+
updateParentDomPointers(newVNode);
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
/**
|
|
152
|
-
* @param {
|
|
158
|
+
* @param {VNode} vnode
|
|
153
159
|
*/
|
|
154
160
|
function updateParentDomPointers(vnode) {
|
|
155
161
|
if ((vnode = vnode._parent) != null && vnode._component != null) {
|
|
@@ -168,7 +174,7 @@ function updateParentDomPointers(vnode) {
|
|
|
168
174
|
|
|
169
175
|
/**
|
|
170
176
|
* The render queue
|
|
171
|
-
* @type {Array<
|
|
177
|
+
* @type {Array<Component>}
|
|
172
178
|
*/
|
|
173
179
|
let rerenderQueue = [];
|
|
174
180
|
|
|
@@ -190,7 +196,7 @@ const defer =
|
|
|
190
196
|
|
|
191
197
|
/**
|
|
192
198
|
* Enqueue a rerender of a component
|
|
193
|
-
* @param {
|
|
199
|
+
* @param {Component} c The component to rerender
|
|
194
200
|
*/
|
|
195
201
|
export function enqueueRender(c) {
|
|
196
202
|
if (
|
|
@@ -206,8 +212,8 @@ export function enqueueRender(c) {
|
|
|
206
212
|
}
|
|
207
213
|
|
|
208
214
|
/**
|
|
209
|
-
* @param {
|
|
210
|
-
* @param {
|
|
215
|
+
* @param {Component} a
|
|
216
|
+
* @param {Component} b
|
|
211
217
|
*/
|
|
212
218
|
const depthSort = (a, b) => a._vnode._depth - b._vnode._depth;
|
|
213
219
|
|
package/preact/src/constants.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/** Normal hydration that attaches to a DOM tree but does not diff it. */
|
|
2
|
+
export const MODE_HYDRATE = 1 << 5;
|
|
3
|
+
/** Signifies this VNode suspended on the previous render */
|
|
4
|
+
export const MODE_SUSPENDED = 1 << 7;
|
|
5
|
+
/** Indicates that this node needs to be inserted while patching children */
|
|
6
|
+
export const INSERT_VNODE = 1 << 16;
|
|
7
|
+
/** Indicates a VNode has been matched with another VNode in the diff */
|
|
8
|
+
export const MATCHED = 1 << 17;
|
|
9
|
+
|
|
10
|
+
/** Reset all mode flags */
|
|
11
|
+
export const RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);
|
|
12
|
+
|
|
13
|
+
export const EMPTY_OBJ = /** @type {any} */ ({});
|
|
2
14
|
export const EMPTY_ARR = [];
|
|
3
15
|
export const IS_NON_DIMENSIONAL =
|
|
4
16
|
/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
|
@@ -8,17 +8,17 @@ export function createContext(defaultValue, contextId) {
|
|
|
8
8
|
const context = {
|
|
9
9
|
_id: contextId,
|
|
10
10
|
_defaultValue: defaultValue,
|
|
11
|
-
/** @type {
|
|
11
|
+
/** @type {FunctionComponent} */
|
|
12
12
|
Consumer(props, contextValue) {
|
|
13
13
|
// return props.children(
|
|
14
14
|
// context[contextId] ? context[contextId].props.value : defaultValue
|
|
15
15
|
// );
|
|
16
16
|
return props.children(contextValue);
|
|
17
17
|
},
|
|
18
|
-
/** @type {
|
|
18
|
+
/** @type {FunctionComponent} */
|
|
19
19
|
Provider(props) {
|
|
20
20
|
if (!this.getChildContext) {
|
|
21
|
-
/** @type {
|
|
21
|
+
/** @type {Component[]} */
|
|
22
22
|
let subs = [];
|
|
23
23
|
let ctx = {};
|
|
24
24
|
ctx[contextId] = this;
|
|
@@ -5,11 +5,12 @@ let vnodeId = 0;
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create an virtual node (used for JSX)
|
|
8
|
-
* @param {
|
|
9
|
-
*
|
|
8
|
+
* @param {VNode["type"]} type The node name or Component constructor for this
|
|
9
|
+
* virtual node
|
|
10
10
|
* @param {object | null | undefined} [props] The properties of the virtual node
|
|
11
|
-
* @param {Array<import('.').ComponentChildren>} [children] The children of the
|
|
12
|
-
*
|
|
11
|
+
* @param {Array<import('.').ComponentChildren>} [children] The children of the
|
|
12
|
+
* virtual node
|
|
13
|
+
* @returns {VNode}
|
|
13
14
|
*/
|
|
14
15
|
export function createElement(type, props, children) {
|
|
15
16
|
let normalizedProps = {},
|
|
@@ -42,19 +43,20 @@ export function createElement(type, props, children) {
|
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* Create a VNode (used internally by Preact)
|
|
45
|
-
* @param {
|
|
46
|
+
* @param {VNode["type"]} type The node name or Component
|
|
46
47
|
* Constructor for this virtual node
|
|
47
48
|
* @param {object | string | number | null} props The properties of this virtual node.
|
|
48
49
|
* If this virtual node represents a text node, this is the text of the node (string or number).
|
|
49
50
|
* @param {string | number | null} key The key for this virtual node, used when
|
|
50
51
|
* diffing it against its children
|
|
51
|
-
* @param {
|
|
52
|
+
* @param {VNode["ref"]} ref The ref property that will
|
|
52
53
|
* receive a reference to its created child
|
|
53
|
-
* @returns {
|
|
54
|
+
* @returns {VNode}
|
|
54
55
|
*/
|
|
55
56
|
export function createVNode(type, props, key, ref, original) {
|
|
56
57
|
// V8 seems to be better at detecting type shapes if the object is allocated from the same call site
|
|
57
58
|
// Do not inline into createElement and coerceToVNode!
|
|
59
|
+
/** @type {VNode} */
|
|
58
60
|
const vnode = {
|
|
59
61
|
type,
|
|
60
62
|
props,
|
|
@@ -70,9 +72,10 @@ export function createVNode(type, props, key, ref, original) {
|
|
|
70
72
|
// a _nextDom that has been set to `null`
|
|
71
73
|
_nextDom: undefined,
|
|
72
74
|
_component: null,
|
|
73
|
-
_hydrating: null,
|
|
74
75
|
constructor: undefined,
|
|
75
|
-
_original: original == null ? ++vnodeId : original
|
|
76
|
+
_original: original == null ? ++vnodeId : original,
|
|
77
|
+
_index: -1,
|
|
78
|
+
_flags: 0
|
|
76
79
|
};
|
|
77
80
|
|
|
78
81
|
// Only invoke the vnode hook if this was *not* a direct copy:
|
|
@@ -92,7 +95,7 @@ export function Fragment(props) {
|
|
|
92
95
|
/**
|
|
93
96
|
* Check if a the argument is a valid Preact VNode.
|
|
94
97
|
* @param {*} vnode
|
|
95
|
-
* @returns {vnode is
|
|
98
|
+
* @returns {vnode is VNode}
|
|
96
99
|
*/
|
|
97
100
|
export const isValidElement = vnode =>
|
|
98
|
-
vnode != null && vnode.constructor
|
|
101
|
+
vnode != null && vnode.constructor == undefined;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Find the closest error boundary to a thrown error and call it
|
|
3
3
|
* @param {object} error The thrown value
|
|
4
|
-
* @param {
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
4
|
+
* @param {VNode} vnode The vnode that threw the error that was caught (except
|
|
5
|
+
* for unmounting when this parameter is the highest parent that was being
|
|
6
|
+
* unmounted)
|
|
7
|
+
* @param {VNode} [oldVNode]
|
|
8
|
+
* @param {ErrorInfo} [errorInfo]
|
|
9
9
|
*/
|
|
10
10
|
export function _catchError(error, vnode, oldVNode, errorInfo) {
|
|
11
|
-
/** @type {
|
|
12
|
-
let component,
|
|
11
|
+
/** @type {Component} */
|
|
12
|
+
let component,
|
|
13
|
+
/** @type {ComponentType} */
|
|
14
|
+
ctor,
|
|
15
|
+
/** @type {boolean} */
|
|
16
|
+
handled;
|
|
13
17
|
|
|
14
18
|
for (; (vnode = vnode._parent); ) {
|
|
15
19
|
if ((component = vnode._component) && !component._processingException) {
|