@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.
Files changed (127) hide show
  1. package/LICENSE +9 -2
  2. package/dist/index.esm.js +3760 -3762
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +3724 -3804
  5. package/dist/index.js.map +1 -1
  6. package/package.json +22 -48
  7. package/preact/README.md +5 -5
  8. package/preact/compat/client.d.ts +1 -3
  9. package/preact/compat/dist/compat.mjs +2 -2
  10. package/preact/compat/dist/compat.mjs.map +1 -0
  11. package/preact/compat/package.json +2 -41
  12. package/preact/compat/scheduler.d.ts +12 -0
  13. package/preact/compat/server.d.ts +17 -0
  14. package/preact/compat/src/Children.js +3 -3
  15. package/preact/compat/src/PureComponent.js +20 -12
  16. package/preact/compat/src/forwardRef.js +4 -17
  17. package/preact/compat/src/hooks.js +17 -51
  18. package/preact/compat/src/index.d.ts +249 -164
  19. package/preact/compat/src/index.js +52 -43
  20. package/preact/compat/src/internal.d.ts +1 -2
  21. package/preact/compat/src/memo.js +2 -2
  22. package/preact/compat/src/portals.js +2 -68
  23. package/preact/compat/src/render.js +182 -73
  24. package/preact/compat/src/suspense.d.ts +1 -3
  25. package/preact/compat/src/suspense.js +169 -179
  26. package/preact/compat/src/util.js +5 -22
  27. package/preact/debug/dist/debug.mjs +2 -2
  28. package/preact/debug/dist/debug.mjs.map +1 -0
  29. package/preact/debug/package.json +3 -14
  30. package/preact/debug/src/check-props.js +2 -6
  31. package/preact/debug/src/component-stack.js +67 -16
  32. package/preact/debug/src/debug.js +80 -35
  33. package/preact/debug/src/index.d.ts +11 -1
  34. package/preact/debug/src/index.js +3 -1
  35. package/preact/debug/src/util.js +1 -11
  36. package/preact/devtools/dist/devtools.mjs +2 -2
  37. package/preact/devtools/dist/devtools.mjs.map +1 -0
  38. package/preact/devtools/package.json +3 -15
  39. package/preact/devtools/src/devtools.js +1 -1
  40. package/preact/dist/preact.mjs +2 -2
  41. package/preact/dist/preact.mjs.map +1 -0
  42. package/preact/hooks/dist/hooks.mjs +2 -2
  43. package/preact/hooks/dist/hooks.mjs.map +1 -0
  44. package/preact/hooks/package.json +5 -24
  45. package/preact/hooks/src/index.d.ts +6 -13
  46. package/preact/hooks/src/index.js +95 -73
  47. package/preact/hooks/src/internal.d.ts +8 -3
  48. package/preact/jsx-runtime/dist/jsxRuntime.mjs +2 -2
  49. package/preact/jsx-runtime/dist/jsxRuntime.mjs.map +1 -0
  50. package/preact/jsx-runtime/package.json +4 -16
  51. package/preact/jsx-runtime/src/index.d.ts +11 -11
  52. package/preact/jsx-runtime/src/index.js +25 -40
  53. package/preact/jsx-runtime/src/utils.js +3 -3
  54. package/preact/package.json +59 -115
  55. package/preact/src/component.js +54 -47
  56. package/preact/src/constants.js +17 -2
  57. package/preact/src/create-context.js +4 -14
  58. package/preact/src/create-element.js +42 -17
  59. package/preact/src/create-portal.js +20 -0
  60. package/preact/src/diff/catch-error.js +26 -8
  61. package/preact/src/diff/children.js +158 -96
  62. package/preact/src/diff/index.js +265 -146
  63. package/preact/src/diff/props.js +39 -50
  64. package/preact/src/dom.d.ts +796 -147
  65. package/preact/src/index.d.ts +7 -18
  66. package/preact/src/index.js +2 -1
  67. package/preact/src/internal.d.ts +16 -24
  68. package/preact/src/jsx.d.ts +222 -2910
  69. package/preact/src/render.js +30 -34
  70. package/preact/src/util.js +5 -20
  71. package/preact/test-utils/dist/testUtils.mjs +1 -1
  72. package/preact/test-utils/dist/testUtils.mjs.map +1 -0
  73. package/preact/test-utils/package.json +5 -17
  74. package/README.md +0 -35
  75. package/preact/compat/dist/compat.js +0 -2
  76. package/preact/compat/dist/compat.js.map +0 -1
  77. package/preact/compat/dist/compat.module.js +0 -2
  78. package/preact/compat/dist/compat.module.js.map +0 -1
  79. package/preact/compat/dist/compat.umd.js +0 -2
  80. package/preact/compat/dist/compat.umd.js.map +0 -1
  81. package/preact/compat/src/suspense-list.d.ts +0 -16
  82. package/preact/compat/src/suspense-list.js +0 -127
  83. package/preact/debug/dist/debug.js +0 -2
  84. package/preact/debug/dist/debug.js.map +0 -1
  85. package/preact/debug/dist/debug.module.js +0 -2
  86. package/preact/debug/dist/debug.module.js.map +0 -1
  87. package/preact/debug/dist/debug.umd.js +0 -2
  88. package/preact/debug/dist/debug.umd.js.map +0 -1
  89. package/preact/devtools/dist/devtools.js +0 -2
  90. package/preact/devtools/dist/devtools.js.map +0 -1
  91. package/preact/devtools/dist/devtools.module.js +0 -2
  92. package/preact/devtools/dist/devtools.module.js.map +0 -1
  93. package/preact/devtools/dist/devtools.umd.js +0 -2
  94. package/preact/devtools/dist/devtools.umd.js.map +0 -1
  95. package/preact/dist/preact.js +0 -2
  96. package/preact/dist/preact.js.map +0 -1
  97. package/preact/dist/preact.min.js +0 -2
  98. package/preact/dist/preact.min.js.map +0 -1
  99. package/preact/dist/preact.min.module.js +0 -2
  100. package/preact/dist/preact.min.module.js.map +0 -1
  101. package/preact/dist/preact.min.umd.js +0 -2
  102. package/preact/dist/preact.min.umd.js.map +0 -1
  103. package/preact/dist/preact.module.js +0 -2
  104. package/preact/dist/preact.module.js.map +0 -1
  105. package/preact/dist/preact.umd.js +0 -2
  106. package/preact/dist/preact.umd.js.map +0 -1
  107. package/preact/hooks/dist/hooks.js +0 -2
  108. package/preact/hooks/dist/hooks.js.map +0 -1
  109. package/preact/hooks/dist/hooks.module.js +0 -2
  110. package/preact/hooks/dist/hooks.module.js.map +0 -1
  111. package/preact/hooks/dist/hooks.umd.js +0 -2
  112. package/preact/hooks/dist/hooks.umd.js.map +0 -1
  113. package/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
  114. package/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
  115. package/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
  116. package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
  117. package/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
  118. package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
  119. package/preact/src/cjs.js +0 -3
  120. package/preact/src/clone-element.js +0 -48
  121. package/preact/src/index-5.d.ts +0 -399
  122. package/preact/test-utils/dist/testUtils.js +0 -2
  123. package/preact/test-utils/dist/testUtils.js.map +0 -1
  124. package/preact/test-utils/dist/testUtils.module.js +0 -2
  125. package/preact/test-utils/dist/testUtils.module.js.map +0 -1
  126. package/preact/test-utils/dist/testUtils.umd.js +0 -2
  127. package/preact/test-utils/dist/testUtils.umd.js.map +0 -1
@@ -1,48 +1,49 @@
1
1
  import {
2
- createElement,
3
- render as preactRender,
4
- cloneElement as preactCloneElement,
5
- createRef,
6
2
  Component,
7
- createContext,
8
3
  Fragment,
9
- options
4
+ createContext,
5
+ createElement,
6
+ createRef,
7
+ options,
8
+ cloneElement as preactCloneElement,
9
+ render as preactRender
10
10
  } from '../..';
11
11
  import {
12
- useState,
13
- useId,
14
- useReducer,
12
+ useCallback,
13
+ useContext,
14
+ useDebugValue,
15
15
  useEffect,
16
- useLayoutEffect,
17
- useRef,
16
+ useId,
18
17
  useImperativeHandle,
18
+ useLayoutEffect,
19
19
  useMemo,
20
- useCallback,
21
- useContext,
22
- useDebugValue
20
+ useReducer,
21
+ useRef,
22
+ useState
23
23
  } from '../../hooks';
24
+ import { Children } from './Children';
25
+ import { PureComponent } from './PureComponent';
26
+ import { forwardRef } from './forwardRef';
24
27
  import {
25
- useInsertionEffect,
26
28
  startTransition,
27
29
  useDeferredValue,
28
- useSyncExternalStore,
30
+ useEffectEvent,
31
+ useInsertionEffect,
29
32
  useTransition
30
33
  } from './hooks';
31
- import { PureComponent } from './PureComponent';
32
34
  import { memo } from './memo';
33
- import { forwardRef } from './forwardRef';
34
- import { Children } from './Children';
35
- import { Suspense, lazy } from './suspense';
36
- import { SuspenseList } from './suspense-list';
37
35
  import { createPortal } from './portals';
38
36
  import {
37
+ REACT_ELEMENT_TYPE,
38
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
39
39
  hydrate,
40
40
  render,
41
- REACT_ELEMENT_TYPE,
42
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
41
+ use,
42
+ useSyncExternalStore
43
43
  } from './render';
44
+ import { Suspense, lazy } from './suspense';
44
45
 
45
- const version = '18.3.1'; // trick libraries to think we are react
46
+ const version = '19.0.0'; // trick libraries to think we are react
46
47
 
47
48
  /**
48
49
  * Legacy version of createElement.
@@ -67,7 +68,7 @@ function isValidElement(element) {
67
68
  * @returns {boolean}
68
69
  */
69
70
  function isFragment(element) {
70
- return isValidElement(element) && element.type === Fragment;
71
+ return isValidElement(element) && element.type == Fragment;
71
72
  }
72
73
 
73
74
  /**
@@ -116,21 +117,12 @@ function unmountComponentAtNode(container) {
116
117
  function findDOMNode(component) {
117
118
  return (
118
119
  (component &&
119
- (component.base || (component.nodeType === 1 && component))) ||
120
+ ((component._vnode && component._vnode._dom) ||
121
+ (component.nodeType == 1 && component))) ||
120
122
  null
121
123
  );
122
124
  }
123
125
 
124
- /**
125
- * Deprecated way to control batched rendering inside the reconciler, but we
126
- * already schedule in batches inside our rendering code
127
- * @template Arg
128
- * @param {(arg: Arg) => void} callback function that triggers the updated
129
- * @param {Arg} [arg] Optional argument that can be passed to the callback
130
- */
131
- // eslint-disable-next-line camelcase
132
- const unstable_batchedUpdates = (callback, arg) => callback(arg);
133
-
134
126
  /**
135
127
  * In React, `flushSync` flushes the entire tree and forces a rerender.
136
128
  * @template Arg
@@ -141,6 +133,10 @@ const unstable_batchedUpdates = (callback, arg) => callback(arg);
141
133
  */
142
134
  const flushSync = (callback, arg) => {
143
135
  const prevDebounce = options.debounceRendering;
136
+
137
+ // Capture the scheduled render callback so that all updates performed
138
+ // inside the user callback are batched into a single synchronous commit
139
+ // instead of every state setter rendering independently.
144
140
  let flush;
145
141
  options.debounceRendering = cb => {
146
142
  flush = cb;
@@ -154,8 +150,18 @@ const flushSync = (callback, arg) => {
154
150
  }
155
151
  };
156
152
 
157
- // compat to react-is
158
- export const isElement = isValidElement;
153
+ /**
154
+ * In React, `unstable_batchedUpdates` is a legacy feature that was made a no-op
155
+ * outside of legacy mode in React 18 and a no-op across the board in React 19.
156
+ * @template Arg
157
+ * @template Result
158
+ * @param {(arg: Arg) => Result} callback
159
+ * @param {Arg} [arg]
160
+ * @returns {Result}
161
+ */
162
+ function unstable_batchedUpdates(callback, arg) {
163
+ return callback(arg);
164
+ }
159
165
 
160
166
  export * from '../../hooks';
161
167
  export {
@@ -172,6 +178,8 @@ export {
172
178
  createRef,
173
179
  Fragment,
174
180
  isValidElement,
181
+ // compat to react-is
182
+ isValidElement as isElement,
175
183
  isFragment,
176
184
  isMemo,
177
185
  findDOMNode,
@@ -180,16 +188,16 @@ export {
180
188
  memo,
181
189
  forwardRef,
182
190
  flushSync,
191
+ unstable_batchedUpdates,
183
192
  useInsertionEffect,
184
193
  startTransition,
185
194
  useDeferredValue,
186
195
  useSyncExternalStore,
187
196
  useTransition,
188
- // eslint-disable-next-line camelcase
189
- unstable_batchedUpdates,
197
+ useEffectEvent,
198
+ use,
190
199
  Fragment as StrictMode,
191
200
  Suspense,
192
- SuspenseList,
193
201
  lazy,
194
202
  __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
195
203
  };
@@ -205,12 +213,14 @@ export default {
205
213
  useTransition,
206
214
  useDeferredValue,
207
215
  useSyncExternalStore,
216
+ useEffectEvent,
208
217
  startTransition,
209
218
  useRef,
210
219
  useImperativeHandle,
211
220
  useMemo,
212
221
  useCallback,
213
222
  useContext,
223
+ use,
214
224
  useDebugValue,
215
225
  version,
216
226
  Children,
@@ -225,7 +235,7 @@ export default {
225
235
  createRef,
226
236
  Fragment,
227
237
  isValidElement,
228
- isElement,
238
+ isElement: isValidElement,
229
239
  isFragment,
230
240
  isMemo,
231
241
  findDOMNode,
@@ -237,7 +247,6 @@ export default {
237
247
  unstable_batchedUpdates,
238
248
  StrictMode: Fragment,
239
249
  Suspense,
240
- SuspenseList,
241
250
  lazy,
242
251
  __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
243
252
  };
@@ -27,12 +27,11 @@ export interface Component<P = {}, S = {}> extends PreactComponent<P, S> {
27
27
 
28
28
  export interface FunctionComponent<P = {}> extends PreactFunctionComponent<P> {
29
29
  shouldComponentUpdate?(nextProps: Readonly<P>): boolean;
30
- _forwarded?: boolean;
31
30
  _patchedLifecycles?: true;
32
31
  }
33
32
 
34
33
  export interface VNode<T = any> extends PreactVNode<T> {
35
- $$typeof?: symbol | string;
34
+ $$typeof?: symbol;
36
35
  preactCompatNormalized?: boolean;
37
36
  }
38
37
 
@@ -10,7 +10,7 @@ import { shallowDiffers } from './util';
10
10
  */
11
11
  export function memo(c, comparer) {
12
12
  function shouldUpdate(nextProps) {
13
- let ref = this.props.ref;
13
+ const ref = this.props.ref;
14
14
  if (ref != nextProps.ref && ref) {
15
15
  typeof ref == 'function' ? ref(null) : (ref.current = null);
16
16
  }
@@ -25,7 +25,7 @@ export function memo(c, comparer) {
25
25
  return createElement(c, props);
26
26
  }
27
27
  Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
28
- Memoed._forwarded = Memoed.prototype.isReactComponent = true;
28
+ Memoed.prototype.isReactComponent = true;
29
29
  Memoed.type = c;
30
30
  return Memoed;
31
31
  }
@@ -1,70 +1,4 @@
1
- import { createElement, render } from '../..';
2
-
3
- /**
4
- * @param {import('../../src/index').RenderableProps<{ context: any }>} props
5
- */
6
- function ContextProvider(props) {
7
- this.getChildContext = () => props.context;
8
- return props.children;
9
- }
10
-
11
- /**
12
- * Portal component
13
- * @this {import('./internal').Component}
14
- * @param {object | null | undefined} props
15
- *
16
- * TODO: use createRoot() instead of fake root
17
- */
18
- function Portal(props) {
19
- const _this = this;
20
- let container = props._container;
21
-
22
- _this.componentWillUnmount = function () {
23
- render(null, _this._temp);
24
- _this._temp = null;
25
- _this._container = null;
26
- };
27
-
28
- // When we change container we should clear our old container and
29
- // indicate a new mount.
30
- if (_this._container && _this._container !== container) {
31
- _this.componentWillUnmount();
32
- }
33
-
34
- if (!_this._temp) {
35
- // Ensure the element has a mask for useId invocations
36
- let root = _this._vnode;
37
- while (root !== null && !root._mask && root._parent !== null) {
38
- root = root._parent;
39
- }
40
-
41
- _this._container = container;
42
-
43
- // Create a fake DOM parent node that manages a subset of `container`'s children:
44
- _this._temp = {
45
- nodeType: 1,
46
- parentNode: container,
47
- childNodes: [],
48
- _children: { _mask: root._mask },
49
- contains: () => true,
50
- namespaceURI: container.namespaceURI,
51
- insertBefore(child, before) {
52
- this.childNodes.push(child);
53
- _this._container.insertBefore(child, before);
54
- },
55
- removeChild(child) {
56
- this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
57
- _this._container.removeChild(child);
58
- }
59
- };
60
- }
61
-
62
- // Render our wrapping element into temp.
63
- render(
64
- createElement(ContextProvider, { context: _this.context }, props._vnode),
65
- _this._temp
66
- );
67
- }
1
+ import { createPortal as corePortal } from '../..';
68
2
 
69
3
  /**
70
4
  * Create a `Portal` to continue rendering the vnode tree at a different DOM node
@@ -72,7 +6,7 @@ function Portal(props) {
72
6
  * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
73
7
  */
74
8
  export function createPortal(vnode, container) {
75
- const el = createElement(Portal, { _vnode: vnode, _container: container });
9
+ const el = corePortal(vnode, container);
76
10
  el.containerInfo = container;
77
11
  return el;
78
12
  }
@@ -18,31 +18,75 @@ import {
18
18
  useRef,
19
19
  useState
20
20
  } from '../../hooks';
21
- import {
22
- useDeferredValue,
23
- useInsertionEffect,
24
- useSyncExternalStore,
25
- useTransition
26
- } from './index';
21
+ import { useDeferredValue, useInsertionEffect, useTransition } from './index';
22
+ import { assign, IS_NON_DIMENSIONAL } from './util';
23
+
24
+ export const REACT_ELEMENT_TYPE = Symbol.for('react.element');
27
25
 
28
- export const REACT_ELEMENT_TYPE =
29
- (typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
30
- 0xeac7;
26
+ const MODE_HYDRATE = 1 << 5;
27
+ let currentComponent, hydrationRoot, renderTrackingInitialized;
31
28
 
32
29
  const CAMEL_PROPS =
33
- /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
34
- const ON_ANI = /^on(Ani|Tra|Tou|BeforeInp|Compo)/;
30
+ /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(?!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
35
31
  const CAMEL_REPLACE = /[A-Z0-9]/g;
36
- const IS_DOM = typeof document !== 'undefined';
32
+ const IS_DOM = typeof document < 'u';
33
+
34
+ /**
35
+ * This is taken from https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L84
36
+ * on a high level this cuts out the warnings, ... and attempts a smaller implementation
37
+ * @typedef {{ _value: any; _getSnapshot: () => any }} Store
38
+ */
39
+ export const useSyncExternalStore = /* @__PURE__ */ initRenderTracking(
40
+ function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
41
+ const serverRendering = options._skipEffects || hydrationRoot;
42
+ const value = serverRendering
43
+ ? (getServerSnapshot || getSnapshot)()
44
+ : getSnapshot();
45
+
46
+ /**
47
+ * @typedef {{ _instance: Store }} StoreRef
48
+ * @type {[StoreRef, (store: StoreRef) => void]}
49
+ */
50
+ const [{ _instance }, forceUpdate] = useState({
51
+ _instance: { _value: value, _getSnapshot: getSnapshot }
52
+ });
53
+
54
+ useLayoutEffect(() => {
55
+ _instance._value = value;
56
+ _instance._getSnapshot = getSnapshot;
57
+
58
+ if (didSnapshotChange(_instance)) {
59
+ forceUpdate({ _instance });
60
+ }
61
+ }, [subscribe, value, getSnapshot]);
62
+
63
+ useEffect(() => {
64
+ if (didSnapshotChange(_instance)) {
65
+ forceUpdate({ _instance });
66
+ }
67
+
68
+ return subscribe(() => {
69
+ if (didSnapshotChange(_instance)) {
70
+ forceUpdate({ _instance });
71
+ }
72
+ });
73
+ }, [subscribe]);
74
+
75
+ return value;
76
+ }
77
+ );
78
+
79
+ /** @type {(inst: Store) => boolean} */
80
+ function didSnapshotChange(inst) {
81
+ try {
82
+ return !Object.is(inst._value, inst._getSnapshot());
83
+ } catch (error) {
84
+ return true;
85
+ }
86
+ }
37
87
 
38
88
  // Input types for which onchange should not be converted to oninput.
39
- // type="file|checkbox|radio", plus "range" in IE11.
40
- // (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
41
- const onChangeInputType = type =>
42
- (typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'
43
- ? /fil|che|rad/
44
- : /fil|che|ra/
45
- ).test(type);
89
+ const onChangeInputType = type => /fil|che|rad/.test(type);
46
90
 
47
91
  // Some libraries like `react-virtualized` explicitly check for this.
48
92
  Component.prototype.isReactComponent = true;
@@ -132,46 +176,63 @@ function handleDomVNode(vnode) {
132
176
  let value = props[i];
133
177
 
134
178
  if (
135
- (i === 'value' && 'defaultValue' in props && value == null) ||
179
+ (i == 'value' && 'defaultValue' in props && value == null) ||
136
180
  // Emulate React's behavior of not rendering the contents of noscript tags on the client.
137
- (IS_DOM && i === 'children' && type === 'noscript') ||
138
- i === 'class' ||
139
- i === 'className'
181
+ (IS_DOM && i == 'children' && type == 'noscript') ||
182
+ i == 'class' ||
183
+ i == 'className'
140
184
  ) {
141
185
  // Skip applying value if it is null/undefined and we already set
142
186
  // a default value
143
187
  continue;
144
188
  }
145
189
 
146
- let lowerCased = i.toLowerCase();
147
- if (i === 'defaultValue' && 'value' in props && props.value == null) {
190
+ if (i == 'style' && typeof value == 'object') {
191
+ let cloned;
192
+ for (let key in value) {
193
+ if (typeof value[key] == 'number' && !IS_NON_DIMENSIONAL.test(key)) {
194
+ if (!cloned) {
195
+ cloned = value = assign({}, value);
196
+ }
197
+ value[key] += 'px';
198
+ }
199
+ }
200
+ } else if (i == 'defaultValue' && 'value' in props && props.value == null) {
148
201
  // `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
149
202
  // `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
150
203
  i = 'value';
151
- } else if (i === 'download' && value === true) {
204
+ } else if (i == 'download' && value === true) {
152
205
  // Calling `setAttribute` with a truthy value will lead to it being
153
206
  // passed as a stringified value, e.g. `download="true"`. React
154
207
  // converts it to an empty string instead, otherwise the attribute
155
208
  // value will be used as the file name and the file will be called
156
209
  // "true" upon downloading it.
157
210
  value = '';
158
- } else if (lowerCased === 'translate' && value === 'no') {
211
+ } else if (i == 'translate' && value === 'no') {
159
212
  value = false;
160
- } else if (lowerCased[0] === 'o' && lowerCased[1] === 'n') {
161
- if (lowerCased === 'ondoubleclick') {
213
+ } else if (i[0] == 'o' && i[1] == 'n') {
214
+ let lowerCased = i.toLowerCase();
215
+ if (lowerCased == 'ondoubleclick') {
162
216
  i = 'ondblclick';
163
217
  } else if (
164
- lowerCased === 'onchange' &&
165
- (type === 'input' || type === 'textarea') &&
218
+ lowerCased == 'onchange' &&
219
+ (type == 'input' || type == 'textarea') &&
166
220
  !onChangeInputType(props.type)
167
221
  ) {
168
222
  lowerCased = i = 'oninput';
169
- } else if (lowerCased === 'onfocus') {
223
+ } else if (lowerCased == 'onfocus') {
170
224
  i = 'onfocusin';
171
- } else if (lowerCased === 'onblur') {
225
+ } else if (lowerCased == 'onblur') {
172
226
  i = 'onfocusout';
173
- } else if (ON_ANI.test(i)) {
227
+ }
228
+
229
+ // Add support for onInput and onChange, see #3561
230
+ // if we have an oninput prop already change it to oninputCapture
231
+ if (lowerCased == 'oninput') {
174
232
  i = lowerCased;
233
+ if (normalizedProps[i]) {
234
+ i = 'oninputCapture';
235
+ }
175
236
  }
176
237
  } else if (isNonDashedType && CAMEL_PROPS.test(i)) {
177
238
  i = i.replace(CAMEL_REPLACE, '-$&').toLowerCase();
@@ -179,15 +240,6 @@ function handleDomVNode(vnode) {
179
240
  value = undefined;
180
241
  }
181
242
 
182
- // Add support for onInput and onChange, see #3561
183
- // if we have an oninput prop already change it to oninputCapture
184
- if (lowerCased === 'oninput') {
185
- i = lowerCased;
186
- if (normalizedProps[i]) {
187
- i = 'oninputCapture';
188
- }
189
- }
190
-
191
243
  normalizedProps[i] = value;
192
244
  }
193
245
 
@@ -232,55 +284,112 @@ function handleDomVNode(vnode) {
232
284
  let oldVNodeHook = options.vnode;
233
285
  options.vnode = vnode => {
234
286
  // only normalize props on Element nodes
235
- if (typeof vnode.type === 'string') {
287
+ if (typeof vnode.type == 'string') {
236
288
  handleDomVNode(vnode);
289
+ } else if (typeof vnode.type == 'function') {
290
+ const shouldApplyRef =
291
+ 'prototype' in vnode.type && vnode.type.prototype.render;
292
+ if ('ref' in vnode.props && shouldApplyRef) {
293
+ vnode.ref = vnode.props.ref;
294
+ delete vnode.props.ref;
295
+ }
296
+
297
+ if (vnode.type.defaultProps) {
298
+ let normalizedProps = assign({}, vnode.props);
299
+ for (let i in vnode.type.defaultProps) {
300
+ if (normalizedProps[i] === undefined) {
301
+ normalizedProps[i] = vnode.type.defaultProps[i];
302
+ }
303
+ }
304
+ vnode.props = normalizedProps;
305
+ }
237
306
  }
238
307
 
308
+ // React 19 keeps `ref` in element.props for every element type, and that's
309
+ // where libraries detecting React 19 read it (e.g. MUI's getReactElementRef).
310
+ // DOM and class vnodes keep theirs on vnode.ref.
311
+ if (vnode.ref && !('ref' in vnode.props)) {
312
+ Object.defineProperty(vnode.props, 'ref', {
313
+ value: vnode.ref,
314
+ configurable: true,
315
+ writable: true
316
+ });
317
+ }
239
318
  vnode.$$typeof = REACT_ELEMENT_TYPE;
240
319
 
241
320
  if (oldVNodeHook) oldVNodeHook(vnode);
242
321
  };
243
322
 
244
- // Only needed for react-relay
245
- let currentComponent;
246
- const oldBeforeRender = options._render;
247
- options._render = function (vnode) {
248
- if (oldBeforeRender) {
249
- oldBeforeRender(vnode);
250
- }
251
- currentComponent = vnode._component;
252
- };
253
-
254
- const oldDiffed = options.diffed;
255
- /** @type {(vnode: import('./internal').VNode) => void} */
256
- options.diffed = function (vnode) {
257
- if (oldDiffed) {
258
- oldDiffed(vnode);
323
+ // Only needed for react-relay and useSyncExternalStore hydration.
324
+ function initRenderTracking(value) {
325
+ if (!renderTrackingInitialized) {
326
+ renderTrackingInitialized = true;
327
+
328
+ const oldBeforeRender = options._render;
329
+ options._render = vnode => {
330
+ if (oldBeforeRender) oldBeforeRender(vnode);
331
+ if (vnode._flags & MODE_HYDRATE) hydrationRoot = vnode;
332
+ currentComponent = vnode._component;
333
+ };
334
+
335
+ const oldDiffed = options.diffed;
336
+ options.diffed = vnode => {
337
+ if (oldDiffed) oldDiffed(vnode);
338
+ currentComponent = null;
339
+ if (hydrationRoot == vnode) hydrationRoot = null;
340
+ };
259
341
  }
260
342
 
261
- const props = vnode.props;
262
- const dom = vnode._dom;
343
+ return value;
344
+ }
263
345
 
264
- if (
265
- dom != null &&
266
- vnode.type === 'textarea' &&
267
- 'value' in props &&
268
- props.value !== dom.value
269
- ) {
270
- dom.value = props.value == null ? '' : props.value;
346
+ /**
347
+ * Read the value of a Promise (suspending while pending) or a Context.
348
+ * Unlike other hooks, `use` may be called conditionally.
349
+ * @template T
350
+ * @param {(Promise<T> & { status?: string, value?: T, reason?: any }) | import('../../src/internal').PreactContext} resource
351
+ * @returns {T}
352
+ */
353
+ export const use = /* @__PURE__ */ initRenderTracking(function use(resource) {
354
+ // A Context is a function without a `then`, a thenable has one.
355
+ if (resource.then) {
356
+ if (resource.status == 'fulfilled') return resource.value;
357
+ if (resource.status == 'rejected') throw resource.reason;
358
+ if (!resource.status) {
359
+ resource.status = 'pending';
360
+ resource.then(
361
+ value => {
362
+ resource.status = 'fulfilled';
363
+ resource.value = value;
364
+ },
365
+ reason => {
366
+ resource.status = 'rejected';
367
+ resource.reason = reason;
368
+ }
369
+ );
370
+ }
371
+ throw resource;
271
372
  }
272
373
 
273
- currentComponent = null;
274
- };
374
+ const id = resource._id;
375
+ const provider = currentComponent._globalContext[id];
376
+ if (!provider) return resource._defaultValue;
377
+ // `use` runs on every render without hook state, while `provider.sub`
378
+ // wraps `componentWillUnmount` on each call — mark the component so we
379
+ // only subscribe it once.
380
+ if (!currentComponent[id]) {
381
+ currentComponent[id] = true;
382
+ provider.sub(currentComponent);
383
+ }
384
+ return provider.props.value;
385
+ });
275
386
 
276
387
  // This is a very very private internal function for React it
277
388
  // is used to sort-of do runtime dependency injection.
278
389
  export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
279
390
  ReactCurrentDispatcher: {
280
391
  current: {
281
- readContext(context) {
282
- return currentComponent._globalContext[context._id].props.value;
283
- },
392
+ readContext: use,
284
393
  useCallback,
285
394
  useContext,
286
395
  useDebugValue,
@@ -1,6 +1,4 @@
1
- // Intentionally not using a relative path to take advantage of
2
- // the TS version resolution mechanism
3
- import { Component, ComponentChild, ComponentChildren } from 'preact';
1
+ import { Component, ComponentChild, ComponentChildren } from '../../src/index';
4
2
 
5
3
  //
6
4
  // Suspense/lazy