@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,5 +1,7 @@
1
1
  import { options as _options } from '../..';
2
2
 
3
+ const ObjectIs = Object.is;
4
+
3
5
  /** @type {number} */
4
6
  let currentIndex;
5
7
 
@@ -15,6 +17,15 @@ let currentHook = 0;
15
17
  /** @type {Array<import('./internal').Component>} */
16
18
  let afterPaintEffects = [];
17
19
 
20
+ /**
21
+ * Passive (useEffect) hook states of unmounted components whose cleanup is
22
+ * still pending. Deferred to the after-paint flush to match React, which runs
23
+ * passive destroys after the commit has painted. Each state's `_passive` holds
24
+ * the surviving component its errors should be routed to.
25
+ * @type {Array<import('./internal').EffectHookState>}
26
+ */
27
+ let unmountCleanups = [];
28
+
18
29
  // Cast to use internal Options type
19
30
  const options = /** @type {import('./internal').Options} */ (_options);
20
31
 
@@ -54,21 +65,23 @@ options._render = vnode => {
54
65
 
55
66
  const hooks = currentComponent.__hooks;
56
67
  if (hooks) {
57
- if (previousComponent === currentComponent) {
58
- hooks._pendingEffects = [];
68
+ if (previousComponent == currentComponent) {
59
69
  currentComponent._renderCallbacks = [];
60
- hooks._list.some(hookItem => {
61
- if (hookItem._nextValue) {
62
- hookItem._value = hookItem._nextValue;
63
- }
64
- hookItem._pendingArgs = hookItem._nextValue = undefined;
65
- });
66
70
  } else {
67
71
  hooks._pendingEffects.some(invokeCleanup);
68
72
  hooks._pendingEffects.some(invokeEffect);
69
- hooks._pendingEffects = [];
70
73
  currentIndex = 0;
71
74
  }
75
+ hooks._pendingEffects = [];
76
+
77
+ // Runs before every render, forced or not, so `shouldComponentUpdate`
78
+ // never has to apply these itself.
79
+ hooks._list.some(hookItem => {
80
+ if (hookItem._nextValue) {
81
+ hookItem._value = hookItem._nextValue;
82
+ }
83
+ hookItem._pendingArgs = hookItem._nextValue = undefined;
84
+ });
72
85
  }
73
86
  previousComponent = currentComponent;
74
87
  };
@@ -80,11 +93,10 @@ options.diffed = vnode => {
80
93
  const c = vnode._component;
81
94
  if (c && c.__hooks) {
82
95
  if (c.__hooks._pendingEffects.length) afterPaint(afterPaintEffects.push(c));
96
+ // `_pendingArgs` is cleared again by `options._render` before anything
97
+ // can read it, so committing it here is enough.
83
98
  c.__hooks._list.some(hookItem => {
84
- if (hookItem._pendingArgs) {
85
- hookItem._args = hookItem._pendingArgs;
86
- hookItem._pendingArgs = undefined;
87
- }
99
+ if (hookItem._pendingArgs) hookItem._args = hookItem._pendingArgs;
88
100
  });
89
101
  }
90
102
  previousComponent = currentComponent = null;
@@ -117,10 +129,29 @@ options.unmount = vnode => {
117
129
 
118
130
  const c = vnode._component;
119
131
  if (c && c.__hooks) {
120
- let hasErrored;
132
+ let hasErrored, errorParent;
121
133
  c.__hooks._list.some(s => {
122
134
  try {
123
- invokeCleanup(s);
135
+ // Layout cleanups have to run before the new DOM is in place, so
136
+ // they stay in the commit phase (see #1886). Passive cleanups run
137
+ // after paint, before any new passive effect (see #4299), with
138
+ // `_passive` repurposed to hold the error-routing component.
139
+ if (s._passive && s._cleanup) {
140
+ if (errorParent === undefined) {
141
+ errorParent = vnode._parent;
142
+ while (
143
+ errorParent &&
144
+ !(errorParent._component && errorParent._component._parentDom)
145
+ ) {
146
+ errorParent = errorParent._parent;
147
+ }
148
+ errorParent = errorParent && errorParent._component;
149
+ }
150
+ s._passive = errorParent;
151
+ afterPaint(unmountCleanups.push(s));
152
+ } else {
153
+ invokeCleanup(s);
154
+ }
124
155
  } catch (e) {
125
156
  hasErrored = e;
126
157
  }
@@ -133,7 +164,7 @@ options.unmount = vnode => {
133
164
  /**
134
165
  * Get a hook's state from the currentComponent
135
166
  * @param {number} index The index of the hook to get
136
- * @param {number} type The index of the hook to get
167
+ * @param {number} type The type of the hook to get
137
168
  * @returns {any}
138
169
  */
139
170
  function getHookState(index, type) {
@@ -193,7 +224,7 @@ export function useReducer(reducer, initialState, init) {
193
224
  : hookState._value[0];
194
225
  const nextValue = hookState._reducer(currentValue, action);
195
226
 
196
- if (currentValue !== nextValue) {
227
+ if (!ObjectIs(currentValue, nextValue)) {
197
228
  hookState._nextValue = [nextValue, hookState._value[1]];
198
229
  hookState._component.setState({});
199
230
  }
@@ -204,51 +235,28 @@ export function useReducer(reducer, initialState, init) {
204
235
 
205
236
  if (!currentComponent._hasScuFromHooks) {
206
237
  currentComponent._hasScuFromHooks = true;
207
- let prevScu = currentComponent.shouldComponentUpdate;
208
- const prevCWU = currentComponent.componentWillUpdate;
209
-
210
- // If we're dealing with a forced update `shouldComponentUpdate` will
211
- // not be called. But we use that to update the hook values, so we
212
- // need to call it.
213
- currentComponent.componentWillUpdate = function (p, s, c) {
214
- if (this._force) {
215
- let tmp = prevScu;
216
- // Clear to avoid other sCU hooks from being called
217
- prevScu = undefined;
218
- updateHookState(p, s, c);
219
- prevScu = tmp;
220
- }
221
-
222
- if (prevCWU) prevCWU.call(this, p, s, c);
223
- };
238
+ const prevScu = currentComponent.shouldComponentUpdate;
224
239
 
225
240
  // This SCU has the purpose of bailing out after repeated updates
226
- // to stateful hooks.
227
- // we store the next value in _nextValue[0] and keep doing that for all
228
- // state setters, if we have next states and
229
- // all next states within a component end up being equal to their original state
230
- // we are safe to bail out for this specific component.
231
- /**
232
- *
233
- * @type {import('./internal').Component["shouldComponentUpdate"]}
234
- */
235
- // @ts-ignore - We don't use TS to downtranspile
236
- // eslint-disable-next-line no-inner-declarations
237
- function updateHookState(p, s, c) {
238
- if (!hookState._component.__hooks) return true;
241
+ // to stateful hooks. We store the next value in `_nextValue[0]` and
242
+ // keep doing that for all state setters; if we have next states and
243
+ // all next states within a component end up being equal to their
244
+ // original state we are safe to bail out for this specific component.
245
+ currentComponent.shouldComponentUpdate = function (p, s, c) {
246
+ const hooks = this.__hooks;
247
+ if (!hooks) return true;
239
248
 
240
249
  // We check whether we have components with a nextValue set that
241
250
  // have values that aren't equal to one another this pushes
242
251
  // us to update further down the tree
243
252
  let updatedHook = false;
244
- let shouldUpdate = hookState._component.props !== p;
245
- hookState._component.__hooks._list.some(hookItem => {
253
+ let shouldUpdate = this.props != p;
254
+ hooks._list.some(hookItem => {
246
255
  if (hookItem._nextValue) {
247
256
  updatedHook = true;
248
- const currentValue = hookItem._value[0];
249
- hookItem._value = hookItem._nextValue;
250
- hookItem._nextValue = undefined;
251
- if (currentValue !== hookItem._value[0]) shouldUpdate = true;
257
+ if (!ObjectIs(hookItem._value[0], hookItem._nextValue[0])) {
258
+ shouldUpdate = true;
259
+ }
252
260
  }
253
261
  });
254
262
 
@@ -258,13 +266,11 @@ export function useReducer(reducer, initialState, init) {
258
266
  }
259
267
 
260
268
  return !updatedHook || shouldUpdate;
261
- }
262
-
263
- currentComponent.shouldComponentUpdate = updateHookState;
269
+ };
264
270
  }
265
271
  }
266
272
 
267
- return hookState._nextValue || hookState._value;
273
+ return hookState._value;
268
274
  }
269
275
 
270
276
  /**
@@ -276,6 +282,7 @@ export function useEffect(callback, args) {
276
282
  /** @type {import('./internal').EffectHookState} */
277
283
  const state = getHookState(currentIndex++, 3);
278
284
  if (!options._skipEffects && argsChanged(state._args, args)) {
285
+ state._passive = true;
279
286
  state._value = callback;
280
287
  state._pendingArgs = args;
281
288
 
@@ -292,6 +299,7 @@ export function useLayoutEffect(callback, args) {
292
299
  /** @type {import('./internal').EffectHookState} */
293
300
  const state = getHookState(currentIndex++, 4);
294
301
  if (!options._skipEffects && argsChanged(state._args, args)) {
302
+ state._passive = false;
295
303
  state._value = callback;
296
304
  state._pendingArgs = args;
297
305
 
@@ -342,7 +350,6 @@ export function useMemo(factory, args) {
342
350
  if (argsChanged(state._args, args)) {
343
351
  state._value = factory();
344
352
  state._args = args;
345
- state._factory = factory;
346
353
  }
347
354
 
348
355
  return state._value;
@@ -424,7 +431,7 @@ export function useId() {
424
431
  // Grab either the root node or the nearest async boundary node.
425
432
  /** @type {import('./internal').VNode} */
426
433
  let root = currentComponent._vnode;
427
- while (root !== null && !root._mask && root._parent !== null) {
434
+ while (!root._mask && root._parent) {
428
435
  root = root._parent;
429
436
  }
430
437
 
@@ -440,18 +447,33 @@ export function useId() {
440
447
  */
441
448
  function flushAfterPaintEffects() {
442
449
  let component;
443
- while ((component = afterPaintEffects.shift())) {
444
- const hooks = component.__hooks;
445
- if (!component._parentDom || !hooks) continue;
446
- try {
447
- hooks._pendingEffects.some(invokeCleanup);
448
- hooks._pendingEffects.some(invokeEffect);
449
- hooks._pendingEffects = [];
450
- } catch (e) {
451
- hooks._pendingEffects = [];
452
- options._catchError(e, component._vnode);
450
+ // The loop picks up components unmounted by an effect we just invoked, which
451
+ // don't necessarily schedule a flush of their own.
452
+ do {
453
+ // Unmounted components' passive cleanups run before any new passive
454
+ // effect, mirroring React running all destroys before any create.
455
+ while ((component = unmountCleanups.shift())) {
456
+ try {
457
+ invokeCleanup(component);
458
+ } catch (e) {
459
+ component = /** @type {any} */ (component._passive);
460
+ options._catchError(e, { _parent: component && component._vnode });
461
+ }
453
462
  }
454
- }
463
+
464
+ while ((component = afterPaintEffects.shift())) {
465
+ const hooks = component.__hooks;
466
+ if (!component._parentDom || !hooks) continue;
467
+ try {
468
+ hooks._pendingEffects.some(invokeCleanup);
469
+ hooks._pendingEffects.some(invokeEffect);
470
+ hooks._pendingEffects = [];
471
+ } catch (e) {
472
+ hooks._pendingEffects = [];
473
+ options._catchError(e, component._vnode);
474
+ }
475
+ }
476
+ } while (unmountCleanups.length);
455
477
  }
456
478
 
457
479
  let HAS_RAF = typeof requestAnimationFrame == 'function';
@@ -489,7 +511,7 @@ function afterNextFrame(callback) {
489
511
  * @returns {void}
490
512
  */
491
513
  function afterPaint(newQueueLength) {
492
- if (newQueueLength === 1 || prevRaf !== options.requestAnimationFrame) {
514
+ if (newQueueLength == 1 || prevRaf != options.requestAnimationFrame) {
493
515
  prevRaf = options.requestAnimationFrame;
494
516
  (prevRaf || afterNextFrame)(flushAfterPaintEffects);
495
517
  }
@@ -533,8 +555,8 @@ function invokeEffect(hook) {
533
555
  function argsChanged(oldArgs, newArgs) {
534
556
  return (
535
557
  !oldArgs ||
536
- oldArgs.length !== newArgs.length ||
537
- newArgs.some((arg, index) => arg !== oldArgs[index])
558
+ oldArgs.length != newArgs.length ||
559
+ newArgs.some((arg, index) => !ObjectIs(arg, oldArgs[index]))
538
560
  );
539
561
  }
540
562
 
@@ -13,12 +13,12 @@ export { PreactContext };
13
13
  export interface Options extends PreactOptions {
14
14
  /** Attach a hook that is invoked before a vnode is diffed. */
15
15
  _diff?(vnode: VNode): void;
16
- diffed?(vnode: VNode): void;
17
16
  /** Attach a hook that is invoked before a vnode has rendered. */
18
17
  _render?(vnode: VNode): void;
18
+ /** Attach a hook that is invoked after a vnode has rendered. */
19
+ diffed?(vnode: VNode): void;
19
20
  /** Attach a hook that is invoked after a tree was mounted or was updated. */
20
21
  _commit?(vnode: VNode, commitQueue: Component[]): void;
21
- _unmount?(vnode: VNode): void;
22
22
  /** Attach a hook that is invoked before a hook's state is queried. */
23
23
  _hook?(component: Component, index: number, type: HookType): void;
24
24
  }
@@ -73,6 +73,12 @@ export interface EffectHookState extends BaseHookState {
73
73
  _args?: unknown[];
74
74
  _pendingArgs?: unknown[];
75
75
  _cleanup?: Cleanup | void;
76
+ /**
77
+ * Whether this is a passive effect (useEffect), whose unmount cleanup runs
78
+ * after paint. Once unmounted it holds the surviving component that deferred
79
+ * cleanup errors are routed to instead.
80
+ */
81
+ _passive?: boolean | Component;
76
82
  }
77
83
 
78
84
  export interface MemoHookState<T = unknown> extends BaseHookState {
@@ -80,7 +86,6 @@ export interface MemoHookState<T = unknown> extends BaseHookState {
80
86
  _pendingValue?: T;
81
87
  _args?: unknown[];
82
88
  _pendingArgs?: unknown[];
83
- _factory?: () => T;
84
89
  }
85
90
 
86
91
  export interface ReducerHookState<
@@ -1,2 +1,2 @@
1
- import{options as r,Fragment as e}from"../..";export{Fragment}from"../..";var t=/["&<]/;function n(r){if(0===r.length||!1===t.test(r))return r;for(var e=0,n=0,o="",f="";n<r.length;n++){switch(r.charCodeAt(n)){case 34:f="&quot;";break;case 38:f="&amp;";break;case 60:f="&lt;";break;default:continue}n!==e&&(o+=r.slice(e,n)),o+=f,e=n+1}return n!==e&&(o+=r.slice(e,n)),o}var o=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,f=0,i=Array.isArray;function u(e,t,n,o,i,u){t||(t={});var a,c,p=t;if("ref"in p)for(c in p={},t)"ref"==c?a=t[c]:p[c]=t[c];var l={type:e,props:p,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--f,__i:-1,__u:0,__source:i,__self:u};if("function"==typeof e&&(a=e.defaultProps))for(c in a)void 0===p[c]&&(p[c]=a[c]);return r.vnode&&r.vnode(l),l}function a(r){var t=u(e,{tpl:r,exprs:[].slice.call(arguments,1)});return t.key=t.__v,t}var c={},p=/[A-Z]/g;function l(e,t){if(r.attr){var f=r.attr(e,t);if("string"==typeof f)return f}if(t=function(r){return null!==r&&"object"==typeof r&&"function"==typeof r.valueOf?r.valueOf():r}(t),"ref"===e||"key"===e)return"";if("style"===e&&"object"==typeof t){var i="";for(var u in t){var a=t[u];if(null!=a&&""!==a){var l="-"==u[0]?u:c[u]||(c[u]=u.replace(p,"-$&").toLowerCase()),s=";";"number"!=typeof a||l.startsWith("--")||o.test(l)||(s="px;"),i=i+l+":"+a+s}}return e+'="'+n(i)+'"'}return null==t||!1===t||"function"==typeof t||"object"==typeof t?"":!0===t?e:e+'="'+n(""+t)+'"'}function s(r){if(null==r||"boolean"==typeof r||"function"==typeof r)return null;if("object"==typeof r){if(void 0===r.constructor)return r;if(i(r)){for(var e=0;e<r.length;e++)r[e]=s(r[e]);return r}}return n(""+r)}export{u as jsx,l as jsxAttr,u as jsxDEV,s as jsxEscape,a as jsxTemplate,u as jsxs};
2
- //# sourceMappingURL=jsxRuntime.module.js.map
1
+ import{options as r,Fragment as t}from"../..";export{Fragment}from"../..";var e=/["&<]/;function n(r){if(!r.length||!e.test(r))return r;for(var t=0,n=0,o="",f="";n<r.length;n++){switch(r.charCodeAt(n)){case 34:f="&quot;";break;case 38:f="&amp;";break;case 60:f="&lt;";break;default:continue}n!=t&&(o+=r.slice(t,n)),o+=f,t=n+1}return n!=t&&(o+=r.slice(t,n)),o}var o=0,f=Array.isArray;function u(t,e,n,f,u,i){e||(e={});var a,c,l=e;if("ref"in l&&"function"!=typeof t)for(c in l={},e)"ref"==c?a=e[c]:l[c]=e[c];var p={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--o,__i:-1,__u:0};return(u||i)&&(p.__source=u,p.__self=i),r.vnode&&r.vnode(p),p}function i(r){var e=u(t,{tpl:r,exprs:[].slice.call(arguments,1)});return e.key=e.__v,e}var a={},c=/[A-Z]/g;function l(t,e){if(r.attr){var o=r.attr(t,e);if("string"==typeof o)return o}if(e=function(r){return null!=r&&"object"==typeof r&&"function"==typeof r.valueOf?r.valueOf():r}(e),"ref"==t||"key"==t)return"";if("style"==t&&"object"==typeof e){var f="";for(var u in e){var i=e[u];null!=i&&""!==i&&(f=f+("-"==u[0]?u:a[u]||(a[u]=u.replace(c,"-$&").toLowerCase()))+":"+i+";")}return t+'="'+n(f)+'"'}return null==e||!1===e||"function"==typeof e||"object"==typeof e?"":!0===e?t:t+'="'+n(""+e)+'"'}function p(r){if(null==r||"boolean"==typeof r||"function"==typeof r)return null;if("object"==typeof r){if(void 0===r.constructor)return r;if(f(r)){for(var t=0;t<r.length;t++)r[t]=p(r[t]);return r}}return n(""+r)}export{u as jsx,l as jsxAttr,u as jsxDEV,p as jsxEscape,i as jsxTemplate,u as jsxs};
2
+ //# sourceMappingURL=jsxRuntime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsxRuntime.mjs","sources":["../src/utils.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 || !ENCODED_ENTITIES.test(str)) 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 = '&quot;';\n\t\t\t\tbreak;\n\t\t\tcase 38:\n\t\t\t\tch = '&amp;';\n\t\t\t\tbreak;\n\t\t\tcase 60:\n\t\t\t\tch = '&lt;';\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","import { options, Fragment } from 'preact';\nimport { encodeEntities } from './utils';\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 {import('../../src/internal').VNode['type']} type\n * @param {import('preact').VNode['props']} props\n * @param {import('preact').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\tif (!props) props = {};\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 = props,\n\t\tref,\n\t\ti;\n\n\tif ('ref' in normalizedProps && typeof type != 'function') {\n\t\tnormalizedProps = {};\n\t\tfor (i in props) {\n\t\t\tif (i == 'ref') {\n\t\t\t\tref = props[i];\n\t\t\t} else {\n\t\t\t\tnormalizedProps[i] = props[i];\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @type {import('../../src/internal').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_component: null,\n\t\tconstructor: undefined,\n\t\t_original: --vnodeId,\n\t\t_index: -1,\n\t\t_flags: 0\n\t};\n\n\tif (__source || __self) {\n\t\tvnode.__source = __source;\n\t\tvnode.__self = __self;\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 | import('preact').VNode>} exprs\n * @returns {import('preact').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\t// @ts-ignore\n\tvnode.key = vnode._vnode;\n\treturn vnode;\n}\n\nconst JS_TO_CSS = {};\nconst CSS_REGEX = /[A-Z]/g;\n\n/**\n * Unwrap potential signals.\n * @param {*} value\n * @returns {*}\n */\nfunction normalizeAttrValue(value) {\n\treturn value != null &&\n\t\ttypeof value == 'object' &&\n\t\ttypeof value.valueOf == 'function'\n\t\t? value.valueOf()\n\t\t: value;\n}\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\tvalue = normalizeAttrValue(value);\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\t(JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$&').toLowerCase());\n\n\t\t\t\tstr = str + name + ':' + val + ';';\n\t\t\t}\n\t\t}\n\t\treturn name + '=\"' + encodeEntities(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 | import('preact').VNode | Array<string | null | import('preact').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","vnodeId","isArray","Array","createVNode","type","props","key","isStaticChildren","__source","__self","ref","normalizedProps","vnode","__k","__","__b","__e","__c","constructor","undefined","__v","__i","__u","options","jsxTemplate","templates","Fragment","tpl","exprs","call","arguments","JS_TO_CSS","CSS_REGEX","jsxAttr","name","value","attr","result","valueOf","normalizeAttrValue","prop","val","replace","toLowerCase","jsxEscape"],"mappings":"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"}
@@ -1,28 +1,16 @@
1
1
  {
2
2
  "name": "jsx-runtime",
3
- "amdName": "jsxRuntime",
4
- "version": "1.0.0",
5
3
  "private": true,
6
4
  "description": "Preact JSX runtime",
7
- "main": "dist/jsxRuntime.js",
8
- "module": "dist/jsxRuntime.module.js",
9
- "umd:main": "dist/jsxRuntime.umd.js",
5
+ "main": "dist/jsxRuntime.mjs",
6
+ "module": "dist/jsxRuntime.mjs",
10
7
  "source": "src/index.js",
11
8
  "types": "src/index.d.ts",
12
9
  "license": "MIT",
13
- "peerDependencies": {
14
- "preact": "^10.0.0"
15
- },
16
10
  "mangle": {
17
11
  "regex": "^_"
18
12
  },
19
- "exports": {
20
- ".": {
21
- "types": "./src/index.d.ts",
22
- "browser": "./dist/jsxRuntime.module.js",
23
- "umd": "./dist/jsxRuntime.umd.js",
24
- "import": "./dist/jsxRuntime.mjs",
25
- "require": "./dist/jsxRuntime.js"
26
- }
13
+ "peerDependencies": {
14
+ "preact": "^10.0.0"
27
15
  }
28
16
  }
@@ -1,19 +1,19 @@
1
- // Intentionally not using a relative path to take advantage of
2
- // the TS version resolution mechanism
3
- export { Fragment } from 'preact';
1
+ export { Fragment } from '../../src/index';
4
2
  import {
5
3
  ComponentType,
6
4
  ComponentChild,
7
5
  ComponentChildren,
8
6
  VNode,
9
- Attributes
10
- } from 'preact';
7
+ Attributes,
8
+ HTMLAttributes,
9
+ SVGAttributes
10
+ } from '../../src/index';
11
11
  import { JSXInternal } from '../../src/jsx';
12
12
 
13
13
  export function jsx(
14
14
  type: string,
15
- props: JSXInternal.HTMLAttributes &
16
- JSXInternal.SVGAttributes &
15
+ props: HTMLAttributes &
16
+ SVGAttributes &
17
17
  Record<string, any> & { children?: ComponentChild },
18
18
  key?: string
19
19
  ): VNode<any>;
@@ -25,8 +25,8 @@ export function jsx<P>(
25
25
 
26
26
  export function jsxs(
27
27
  type: string,
28
- props: JSXInternal.HTMLAttributes &
29
- JSXInternal.SVGAttributes &
28
+ props: HTMLAttributes &
29
+ SVGAttributes &
30
30
  Record<string, any> & { children?: ComponentChild[] },
31
31
  key?: string
32
32
  ): VNode<any>;
@@ -38,8 +38,8 @@ export function jsxs<P>(
38
38
 
39
39
  export function jsxDEV(
40
40
  type: string,
41
- props: JSXInternal.HTMLAttributes &
42
- JSXInternal.SVGAttributes &
41
+ props: HTMLAttributes &
42
+ SVGAttributes &
43
43
  Record<string, any> & { children?: ComponentChildren },
44
44
  key?: string
45
45
  ): VNode<any>;
@@ -1,6 +1,5 @@
1
1
  import { options, Fragment } from '../..';
2
2
  import { encodeEntities } from './utils';
3
- import { IS_NON_DIMENSIONAL } from '../../src/constants';
4
3
 
5
4
  let vnodeId = 0;
6
5
 
@@ -19,9 +18,9 @@ const isArray = Array.isArray;
19
18
 
20
19
  /**
21
20
  * JSX.Element factory used by Babel's {runtime:"automatic"} JSX transform
22
- * @param {VNode['type']} type
23
- * @param {VNode['props']} props
24
- * @param {VNode['key']} [key]
21
+ * @param {import('../../src/internal').VNode['type']} type
22
+ * @param {import('preact').VNode['props']} props
23
+ * @param {import('preact').VNode['key']} [key]
25
24
  * @param {unknown} [isStaticChildren]
26
25
  * @param {unknown} [__source]
27
26
  * @param {unknown} [__self]
@@ -35,7 +34,7 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
35
34
  ref,
36
35
  i;
37
36
 
38
- if ('ref' in normalizedProps) {
37
+ if ('ref' in normalizedProps && typeof type != 'function') {
39
38
  normalizedProps = {};
40
39
  for (i in props) {
41
40
  if (i == 'ref') {
@@ -46,7 +45,7 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
46
45
  }
47
46
  }
48
47
 
49
- /** @type {VNode & { __source: any; __self: any }} */
48
+ /** @type {import('../../src/internal').VNode & { __source?: any; __self?: any }} */
50
49
  const vnode = {
51
50
  type,
52
51
  props: normalizedProps,
@@ -60,18 +59,12 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
60
59
  constructor: undefined,
61
60
  _original: --vnodeId,
62
61
  _index: -1,
63
- _flags: 0,
64
- __source,
65
- __self
62
+ _flags: 0
66
63
  };
67
64
 
68
- // If a Component VNode, check for and apply defaultProps.
69
- // Note: `type` is often a String, and can be `undefined` in development.
70
- if (typeof type === 'function' && (ref = type.defaultProps)) {
71
- for (i in ref)
72
- if (normalizedProps[i] === undefined) {
73
- normalizedProps[i] = ref[i];
74
- }
65
+ if (__source || __self) {
66
+ vnode.__source = __source;
67
+ vnode.__self = __self;
75
68
  }
76
69
 
77
70
  if (options.vnode) options.vnode(vnode);
@@ -82,12 +75,13 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
82
75
  * Create a template vnode. This function is not expected to be
83
76
  * used directly, but rather through a precompile JSX transform
84
77
  * @param {string[]} templates
85
- * @param {Array<string | null | VNode>} exprs
86
- * @returns {VNode}
78
+ * @param {Array<string | null | import('preact').VNode>} exprs
79
+ * @returns {import('preact').VNode}
87
80
  */
88
81
  function jsxTemplate(templates, ...exprs) {
89
82
  const vnode = createVNode(Fragment, { tpl: templates, exprs });
90
83
  // Bypass render to string top level Fragment optimization
84
+ // @ts-ignore
91
85
  vnode.key = vnode._vnode;
92
86
  return vnode;
93
87
  }
@@ -101,9 +95,9 @@ const CSS_REGEX = /[A-Z]/g;
101
95
  * @returns {*}
102
96
  */
103
97
  function normalizeAttrValue(value) {
104
- return value !== null &&
105
- typeof value === 'object' &&
106
- typeof value.valueOf === 'function'
98
+ return value != null &&
99
+ typeof value == 'object' &&
100
+ typeof value.valueOf == 'function'
107
101
  ? value.valueOf()
108
102
  : value;
109
103
  }
@@ -119,13 +113,13 @@ function normalizeAttrValue(value) {
119
113
  function jsxAttr(name, value) {
120
114
  if (options.attr) {
121
115
  const result = options.attr(name, value);
122
- if (typeof result === 'string') return result;
116
+ if (typeof result == 'string') return result;
123
117
  }
124
118
 
125
119
  value = normalizeAttrValue(value);
126
120
 
127
- if (name === 'ref' || name === 'key') return '';
128
- if (name === 'style' && typeof value === 'object') {
121
+ if (name == 'ref' || name == 'key') return '';
122
+ if (name == 'style' && typeof value == 'object') {
129
123
  let str = '';
130
124
  for (let prop in value) {
131
125
  let val = value[prop];
@@ -136,16 +130,7 @@ function jsxAttr(name, value) {
136
130
  : JS_TO_CSS[prop] ||
137
131
  (JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$&').toLowerCase());
138
132
 
139
- let suffix = ';';
140
- if (
141
- typeof val === 'number' &&
142
- // Exclude custom-attributes
143
- !name.startsWith('--') &&
144
- !IS_NON_DIMENSIONAL.test(name)
145
- ) {
146
- suffix = 'px;';
147
- }
148
- str = str + name + ':' + val + suffix;
133
+ str = str + name + ':' + val + ';';
149
134
  }
150
135
  }
151
136
  return name + '="' + encodeEntities(str) + '"';
@@ -154,8 +139,8 @@ function jsxAttr(name, value) {
154
139
  if (
155
140
  value == null ||
156
141
  value === false ||
157
- typeof value === 'function' ||
158
- typeof value === 'object'
142
+ typeof value == 'function' ||
143
+ typeof value == 'object'
159
144
  ) {
160
145
  return '';
161
146
  } else if (value === true) return name;
@@ -168,18 +153,18 @@ function jsxAttr(name, value) {
168
153
  * is not expected to be used directly, but rather through a
169
154
  * precompile JSX transform
170
155
  * @param {*} value
171
- * @returns {string | null | VNode | Array<string | null | VNode>}
156
+ * @returns {string | null | import('preact').VNode | Array<string | null | import('preact').VNode>}
172
157
  */
173
158
  function jsxEscape(value) {
174
159
  if (
175
160
  value == null ||
176
- typeof value === 'boolean' ||
177
- typeof value === 'function'
161
+ typeof value == 'boolean' ||
162
+ typeof value == 'function'
178
163
  ) {
179
164
  return null;
180
165
  }
181
166
 
182
- if (typeof value === 'object') {
167
+ if (typeof value == 'object') {
183
168
  // Check for VNode
184
169
  if (value.constructor === undefined) return value;
185
170
 
@@ -3,7 +3,7 @@ const ENCODED_ENTITIES = /["&<]/;
3
3
  /** @param {string} str */
4
4
  export function encodeEntities(str) {
5
5
  // Skip all work for strings with no entities needing encoding:
6
- if (str.length === 0 || ENCODED_ENTITIES.test(str) === false) return str;
6
+ if (!str.length || !ENCODED_ENTITIES.test(str)) return str;
7
7
 
8
8
  let last = 0,
9
9
  i = 0,
@@ -26,11 +26,11 @@ export function encodeEntities(str) {
26
26
  continue;
27
27
  }
28
28
  // Append skipped/buffered characters and the encoded entity:
29
- if (i !== last) out += str.slice(last, i);
29
+ if (i != last) out += str.slice(last, i);
30
30
  out += ch;
31
31
  // Start the next seek/buffer after the entity's offset:
32
32
  last = i + 1;
33
33
  }
34
- if (i !== last) out += str.slice(last, i);
34
+ if (i != last) out += str.slice(last, i);
35
35
  return out;
36
36
  }