pudui 0.0.1 → 0.0.3

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.
@@ -20,6 +20,7 @@ function fail(message) {
20
20
  //#endregion
21
21
  //#region src/core/component.ts
22
22
  const componentInternals = /* @__PURE__ */ new WeakMap();
23
+ const componentInternalsKey = Symbol();
23
24
  let updateFrameScheduled = false;
24
25
  let scheduledUpdates = /* @__PURE__ */ new Map();
25
26
  /**
@@ -52,21 +53,21 @@ var Component = class {
52
53
  * @param options Render, error, and hydration options for this component.
53
54
  */
54
55
  constructor(options) {
55
- componentInternals.set(this, {
56
+ const internals = {
56
57
  i: 0,
57
58
  c: /* @__PURE__ */ new Map(),
58
59
  d: false,
59
60
  e: options.error,
60
- a: options.memo,
61
61
  h: options.hydrate,
62
62
  f: /* @__PURE__ */ new Map(),
63
- l: void 0,
64
63
  m: false,
65
64
  o: [],
66
65
  p: void 0,
67
66
  r: options.render,
68
67
  u: /* @__PURE__ */ new Set()
69
- });
68
+ };
69
+ componentInternals.set(this, internals);
70
+ Object.defineProperty(this, componentInternalsKey, { value: internals });
70
71
  }
71
72
  /**
72
73
  * Queues a callback to run after the component's first browser mount.
@@ -103,7 +104,7 @@ function isComponent(value) {
103
104
  return value instanceof Component;
104
105
  }
105
106
  function getComponentInternals(component) {
106
- const internals = componentInternals.get(component);
107
+ const internals = component[componentInternalsKey] ?? componentInternals.get(component);
107
108
  invariant(internals, "component");
108
109
  return internals;
109
110
  }
@@ -144,25 +145,12 @@ function renderComponentOutput(component) {
144
145
  return getComponentInternals(component).r(readComponentProps(component));
145
146
  }
146
147
  /**
147
- * Checks whether a component should render for the current props.
148
- *
149
- * @param component Component to inspect.
150
- * @returns `true` when rendering should continue.
151
- */
152
- function shouldRenderComponent(component) {
153
- const internals = getComponentInternals(component);
154
- if (internals.d || internals.l === void 0 || internals.a === void 0) return true;
155
- return !internals.a(internals.l, readComponentProps(component));
156
- }
157
- /**
158
148
  * Marks the current props as rendered.
159
149
  *
160
150
  * @param component Component that completed a render pass.
161
151
  */
162
152
  function markComponentRendered(component) {
163
- const internals = getComponentInternals(component);
164
- internals.d = false;
165
- internals.l = readComponentProps(component);
153
+ getComponentInternals(component).d = false;
166
154
  }
167
155
  /**
168
156
  * Runs a component's error callback for a failed render.
@@ -205,7 +193,7 @@ function finishComponentRender(component) {
205
193
  function resolveComponent(vnode, owner) {
206
194
  if (!owner) return createComponent(vnode.type, vnode.props);
207
195
  const internals = getComponentInternals(owner);
208
- const slot = vnode.key === void 0 ? "." + internals.i++ : typeof vnode.key === "number" ? vnode.key : "#" + vnode.key;
196
+ const slot = componentSlot(vnode, internals);
209
197
  const existing = internals.c.get(slot);
210
198
  internals.u.add(slot);
211
199
  if (existing?.t === vnode.type) {
@@ -220,6 +208,20 @@ function resolveComponent(vnode, owner) {
220
208
  return component;
221
209
  }
222
210
  /**
211
+ * Marks a component virtual node slot as used without resolving the instance.
212
+ *
213
+ * @param vnode Component virtual node.
214
+ * @param owner Parent component that owns child instance slots.
215
+ */
216
+ function retainComponentSlot(vnode, owner) {
217
+ if (!owner) return;
218
+ const internals = getComponentInternals(owner);
219
+ internals.u.add(componentSlot(vnode, internals));
220
+ }
221
+ function componentSlot(vnode, internals) {
222
+ return vnode.key === void 0 ? "." + internals.i++ : typeof vnode.key === "number" ? vnode.key : "#" + vnode.key;
223
+ }
224
+ /**
223
225
  * Creates a component instance from a component factory.
224
226
  *
225
227
  * @param factory Component factory to invoke.
@@ -233,28 +235,6 @@ function createComponent(factory, props) {
233
235
  return component;
234
236
  }
235
237
  /**
236
- * Creates a component factory that skips parent-driven rerenders when props are equal.
237
- *
238
- * @param factory Component factory to memoize.
239
- * @param compare Optional prop equality check. Defaults to shallow equality.
240
- * @returns Memoized component factory.
241
- */
242
- function memo(factory, compare = shallowEqualProps) {
243
- return (props) => {
244
- const component = createComponent(factory, props);
245
- getComponentInternals(component).a = compare;
246
- return component;
247
- };
248
- }
249
- function shallowEqualProps(previousProps, nextProps) {
250
- if (previousProps === nextProps) return true;
251
- const previousKeys = Object.keys(previousProps);
252
- const nextKeys = Object.keys(nextProps);
253
- if (previousKeys.length !== nextKeys.length) return false;
254
- for (const key of previousKeys) if (previousProps[key] !== nextProps[key] || !Object.hasOwn(nextProps, key)) return false;
255
- return true;
256
- }
257
- /**
258
238
  * Subscribes a renderer to component updates.
259
239
  *
260
240
  * @param component Component to observe.
@@ -320,4 +300,4 @@ function isPromiseLike(value) {
320
300
  return typeof value?.then === "function";
321
301
  }
322
302
  //#endregion
323
- export { fail as _, isComponent as a, queueComponentMount as c, renderComponentErrorOutput as d, renderComponentOutput as f, subscribeComponent as g, shouldRenderComponent as h, finishComponentRender as i, readComponentHydrateMeta as l, setComponentProps as m, beginComponentRender as n, markComponentRendered as o, resolveComponent as p, createComponent as r, memo as s, Component as t, readComponentProps as u, invariant as v };
303
+ export { invariant as _, isComponent as a, readComponentHydrateMeta as c, renderComponentOutput as d, resolveComponent as f, fail as g, subscribeComponent as h, finishComponentRender as i, readComponentProps as l, setComponentProps as m, beginComponentRender as n, markComponentRendered as o, retainComponentSlot as p, createComponent as r, queueComponentMount as s, Component as t, renderComponentErrorOutput as u };
@@ -130,14 +130,6 @@ declare class Component<Props extends AnyProps = AnyProps> {
130
130
  * @returns `true` when the value is a {@link Component}.
131
131
  */
132
132
  declare function isComponent(value: unknown): value is Component;
133
- /**
134
- * Creates a component factory that skips parent-driven rerenders when props are equal.
135
- *
136
- * @param factory Component factory to memoize.
137
- * @param compare Optional prop equality check. Defaults to shallow equality.
138
- * @returns Memoized component factory.
139
- */
140
- declare function memo<Props extends AnyProps>(factory: ComponentFactory<Props>, compare?: ComponentMemoCompare<Props>): ComponentFactoryWithProps<Props>;
141
133
  //#endregion
142
134
  //#region src/core.d.ts
143
135
  /**
@@ -243,10 +235,6 @@ type ComponentFactoryWithoutProps<Props extends AnyProps = AnyProps> = () => Com
243
235
  * A function component constructor used as a JSX tag.
244
236
  */
245
237
  type ComponentFactory<Props extends AnyProps = AnyProps> = ComponentFactoryWithProps<Props> | ComponentFactoryWithoutProps<Props>;
246
- /**
247
- * Returns `true` when two prop objects are equivalent for a memoized component.
248
- */
249
- type ComponentMemoCompare<Props extends AnyProps = AnyProps> = (previousProps: Readonly<Props>, nextProps: Readonly<Props>) => boolean;
250
238
  /**
251
239
  * A JSX tag target: either an intrinsic element name or a component factory.
252
240
  */
@@ -399,12 +387,6 @@ type ComponentOptions<Props extends AnyProps> = {
399
387
  * Metadata consumed by the hydration macros and Vite runtime.
400
388
  */
401
389
  hydrate?: unknown;
402
- /**
403
- * Skips parent-driven rerenders while previous and next props are equivalent.
404
- *
405
- * Internal component updates still render even when props are unchanged.
406
- */
407
- memo?: ComponentMemoCompare<Props>;
408
390
  /**
409
391
  * Renders the component's current child tree.
410
392
  *
@@ -449,4 +431,4 @@ declare global {
449
431
  * Internal marker range and props for a server-rendered hydration boundary.
450
432
  */
451
433
  //#endregion
452
- export { isComponent as A, RefCleanup as C, UpdateCallback as D, StyleValue as E, isVNode as F, jsx as I, jsxDEV as L, Fragment as M, Raw as N, VNode as O, createElement as P, RefCallback as S, RenderableType as T, PreloadMetadata as _, ComponentFactoryWithoutProps as a, RawChild as b, ComponentOptions as c, ElementType as d, EmptyChild as f, MountCallback as g, Key as h, ComponentFactoryWithProps as i, memo as j, Component as k, ComponentPropsFor as l, IntrinsicElementsByTagName as m, Child as n, ComponentInstance as o, IntrinsicElementProps as p, ComponentFactory as r, ComponentMemoCompare as s, AnyProps as t, DangerouslySetInnerHTML as u, PreloadResolver as v, RefValue as w, RawProps as x, PrimitiveChild as y };
434
+ export { Fragment as A, RefValue as C, VNode as D, UpdateCallback as E, jsxDEV as F, createElement as M, isVNode as N, Component as O, jsx as P, RefCleanup as S, StyleValue as T, PreloadResolver as _, ComponentFactoryWithoutProps as a, RawProps as b, ComponentPropsFor as c, EmptyChild as d, IntrinsicElementProps as f, PreloadMetadata as g, MountCallback as h, ComponentFactoryWithProps as i, Raw as j, isComponent as k, DangerouslySetInnerHTML as l, Key as m, Child as n, ComponentInstance as o, IntrinsicElementsByTagName as p, ComponentFactory as r, ComponentOptions as s, AnyProps as t, ElementType as u, PrimitiveChild as v, RenderableType as w, RefCallback as x, RawChild as y };
@@ -1,4 +1,4 @@
1
- import { c as ComponentOptions, i as ComponentFactoryWithProps, k as Component, t as AnyProps } from "./core-C_ayj9MV.mjs";
1
+ import { O as Component, i as ComponentFactoryWithProps, s as ComponentOptions, t as AnyProps } from "./core-Cypb6mR9.mjs";
2
2
 
3
3
  //#region src/hmr-runtime.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as Component } from "./component-CHY49Hb1.mjs";
1
+ import { t as Component } from "./component-2mAsZGIS.mjs";
2
2
  //#region src/hmr-runtime.ts
3
3
  const globalRegistryKey = "__puduiHmrRegistry";
4
4
  const moduleDataKey = "__puduiHmr";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as isComponent, C as RefCleanup, D as UpdateCallback, E as StyleValue, F as isVNode, I as jsx, L as jsxDEV, M as Fragment, N as Raw, O as VNode, P as createElement, S as RefCallback, T as RenderableType, _ as PreloadMetadata, a as ComponentFactoryWithoutProps, b as RawChild, c as ComponentOptions, d as ElementType, f as EmptyChild, g as MountCallback, h as Key, i as ComponentFactoryWithProps, j as memo, k as Component, l as ComponentPropsFor, m as IntrinsicElementsByTagName, n as Child, o as ComponentInstance, p as IntrinsicElementProps, r as ComponentFactory, s as ComponentMemoCompare, t as AnyProps, u as DangerouslySetInnerHTML, v as PreloadResolver, w as RefValue, x as RawProps, y as PrimitiveChild } from "./core-C_ayj9MV.mjs";
1
+ import { A as Fragment, C as RefValue, D as VNode, E as UpdateCallback, F as jsxDEV, M as createElement, N as isVNode, O as Component, P as jsx, S as RefCleanup, T as StyleValue, _ as PreloadResolver, a as ComponentFactoryWithoutProps, b as RawProps, c as ComponentPropsFor, d as EmptyChild, f as IntrinsicElementProps, g as PreloadMetadata, h as MountCallback, i as ComponentFactoryWithProps, j as Raw, k as isComponent, l as DangerouslySetInnerHTML, m as Key, n as Child, o as ComponentInstance, p as IntrinsicElementsByTagName, r as ComponentFactory, s as ComponentOptions, t as AnyProps, u as ElementType, v as PrimitiveChild, w as RenderableType, x as RefCallback, y as RawChild } from "./core-Cypb6mR9.mjs";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  /**
@@ -106,4 +106,4 @@ declare function render(child: Child, container: Element | DocumentFragment): Hy
106
106
  */
107
107
  declare function hydrate(root: Document | DocumentFragment | Element, options: HydrateOptions): HydrationRoot;
108
108
  //#endregion
109
- export { type AnyProps, type Child, Component, type ComponentFactory, type ComponentFactoryWithProps, type ComponentFactoryWithoutProps, type ComponentInstance, type ComponentMemoCompare, type ComponentOptions, type ComponentPropsFor, type DangerouslySetInnerHTML, type ElementType, type EmptyChild, type EventForName, type EventHandler, Fragment, type HydrateLoad, type HydrateOptions, type HydrationRoot, type IntrinsicElementProps, type IntrinsicElementsByTagName, type Key, type MountCallback, type PreloadMetadata, type PreloadResolver, type PrimitiveChild, Raw, type RawChild, type RawProps, type RefCallback, type RefCleanup, type RefValue, type RenderableType, type StyleValue, type UpdateCallback, type VNode, createElement, event, hydrate, isComponent, isVNode, jsx, jsx as jsxs, jsxDEV, memo, render };
109
+ export { type AnyProps, type Child, Component, type ComponentFactory, type ComponentFactoryWithProps, type ComponentFactoryWithoutProps, type ComponentInstance, type ComponentOptions, type ComponentPropsFor, type DangerouslySetInnerHTML, type ElementType, type EmptyChild, type EventForName, type EventHandler, Fragment, type HydrateLoad, type HydrateOptions, type HydrationRoot, type IntrinsicElementProps, type IntrinsicElementsByTagName, type Key, type MountCallback, type PreloadMetadata, type PreloadResolver, type PrimitiveChild, Raw, type RawChild, type RawProps, type RefCallback, type RefCleanup, type RefValue, type RenderableType, type StyleValue, type UpdateCallback, type VNode, createElement, event, hydrate, isComponent, isVNode, jsx, jsx as jsxs, jsxDEV, render };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { c as jsxDEV, d as normalizeChildren, f as readRawChildHtml, l as isEmptyChild, n as Raw, o as isVNode, r as createElement, s as jsx, t as Fragment, u as isRawChild } from "./vnode-B7qKjJZs.mjs";
2
2
  import { a as isRawStartCommentData, g as readDangerouslySetInnerHTML, h as isPrimitiveValue, i as isRawEndCommentData, m as isChildlessElement, n as isHydrateMetaCommentData, o as parseHydrateMetaCommentData, p as attributeName, r as isHydrateStartCommentData, s as parseHydrateStartCommentData, t as isHydrateEndCommentData, v as toKebabCase } from "./hydration-markers-DdjOvH6g.mjs";
3
- import { _ as fail, a as isComponent, c as queueComponentMount, d as renderComponentErrorOutput, f as renderComponentOutput, g as subscribeComponent, h as shouldRenderComponent, i as finishComponentRender, l as readComponentHydrateMeta, m as setComponentProps, n as beginComponentRender, o as markComponentRendered, p as resolveComponent, r as createComponent, s as memo, t as Component, v as invariant } from "./component-CHY49Hb1.mjs";
3
+ import { _ as invariant, a as isComponent, c as readComponentHydrateMeta, d as renderComponentOutput, f as resolveComponent, g as fail, h as subscribeComponent, i as finishComponentRender, m as setComponentProps, n as beginComponentRender, o as markComponentRendered, p as retainComponentSlot, r as createComponent, s as queueComponentMount, t as Component, u as renderComponentErrorOutput } from "./component-2mAsZGIS.mjs";
4
4
  //#region src/core/hydration.ts
5
5
  /**
6
6
  * Checks whether a value is a hydrated child boundary wrapper.
@@ -519,7 +519,10 @@ function childToRenderNode(child, context) {
519
519
  if (Array.isArray(child)) return arrayToRenderNode(child, context);
520
520
  if (isComponent(child)) return componentToRenderNode(child, context);
521
521
  if (isVNode(child)) {
522
- if (typeof child.type === "function") return componentToRenderNode(resolveComponent(child, context.owner), context, child.key);
522
+ if (typeof child.type === "function") {
523
+ const vnode = child;
524
+ return componentToRenderNode(resolveComponent(vnode, context.owner), context, vnode.key, vnode.type, vnode);
525
+ }
523
526
  return elementToRenderNode(child, context);
524
527
  }
525
528
  return textToRenderNode(null, context.document);
@@ -610,8 +613,10 @@ function hydrateComponentToDom(component, context, currentNode, rootComponent, p
610
613
  c: result.r,
611
614
  e: componentEnd,
612
615
  k: componentRenderNodeKind,
616
+ o: void 0,
613
617
  q: key,
614
618
  s: componentStart,
619
+ t: void 0,
615
620
  u: unsubscribe,
616
621
  v: component
617
622
  }
@@ -734,9 +739,11 @@ function patchRenderNode(node, nextChild, context) {
734
739
  const component = resolveComponent(nextChild, context.owner);
735
740
  if (node.k === componentRenderNodeKind && node.v === component) {
736
741
  node.q = nextChild.key;
742
+ node.t = nextChild.type;
743
+ node.o = nextChild;
737
744
  return patchComponentRenderNode(node, component, context);
738
745
  }
739
- return replaceRenderNode(node, component, context, nextChild.key);
746
+ return replaceRenderNode(node, component, context, nextChild.key, nextChild.type);
740
747
  }
741
748
  const vnode = nextChild;
742
749
  if (node.k === elementRenderNodeKind && node.v.type === vnode.type && node.v.key === vnode.key) return patchElementRenderNode(node, vnode, context);
@@ -746,7 +753,8 @@ function patchRenderNode(node, nextChild, context) {
746
753
  }
747
754
  function patchArrayRenderNode(node, nextChildren, context) {
748
755
  const normalizedChildren = normalizeChildren(nextChildren);
749
- if (shouldPatchKeyedArray(node.c, normalizedChildren)) return patchKeyedArrayRenderNode(node, normalizedChildren, context);
756
+ if (shouldPatchKeyedArray(node.c, normalizedChildren)) return patchKeyedArrayRenderNode(node, reuseKeyedArrayChildren(node, normalizedChildren), context);
757
+ if (patchSameLengthKeyedArrayRenderNode(node, normalizedChildren, context)) return node;
750
758
  const sharedLength = Math.min(node.c.length, normalizedChildren.length);
751
759
  for (let index = 0; index < sharedLength; index++) node.c[index] = patchRenderNode(node.c[index], normalizedChildren[index], context);
752
760
  const parent = node.e.parentNode;
@@ -770,9 +778,49 @@ function patchArrayRenderNode(node, nextChildren, context) {
770
778
  const firstRemovedChild = removedChildren[0];
771
779
  const lastRemovedChild = removedChildren.at(-1);
772
780
  if (firstRemovedChild && lastRemovedChild) removeNodeRange(renderNodeStart(firstRemovedChild), renderNodeEnd(lastRemovedChild));
781
+ node.h = void 0;
773
782
  return node;
774
783
  }
784
+ function reuseKeyedArrayChildren(node, nextChildren) {
785
+ const previousChildren = node.h;
786
+ const reusableChildren = previousChildren ? Array.from(nextChildren) : void 0;
787
+ const nextReusableChildren = /* @__PURE__ */ new Map();
788
+ for (let index = 0; index < nextChildren.length; index++) {
789
+ const child = nextChildren[index];
790
+ const key = readChildKey(child);
791
+ if (key === void 0) {
792
+ node.h = void 0;
793
+ return nextChildren;
794
+ }
795
+ const previousChild = previousChildren?.get(key);
796
+ const reusableChild = previousChild && canReuseKeyedChild(previousChild, child) ? previousChild : child;
797
+ if (reusableChildren) reusableChildren[index] = reusableChild;
798
+ nextReusableChildren.set(key, reusableChild);
799
+ }
800
+ node.h = nextReusableChildren;
801
+ return reusableChildren ?? nextChildren;
802
+ }
803
+ function canReuseKeyedChild(previousChild, nextChild) {
804
+ if (!isVNode(previousChild) || !isVNode(nextChild) || typeof previousChild.type !== "function" || previousChild.type !== nextChild.type || previousChild.key !== nextChild.key) return false;
805
+ return shallowEqualProps(previousChild.props, nextChild.props);
806
+ }
807
+ function shallowEqualProps(previousProps, nextProps) {
808
+ if (previousProps === nextProps) return true;
809
+ if (previousProps === void 0) return false;
810
+ const previousRecord = previousProps;
811
+ const nextRecord = nextProps;
812
+ let previousKeyCount = 0;
813
+ for (const key in previousRecord) {
814
+ if (!Object.hasOwn(previousRecord, key)) continue;
815
+ previousKeyCount++;
816
+ if (previousRecord[key] !== nextRecord[key] || !Object.hasOwn(nextProps, key)) return false;
817
+ }
818
+ let nextKeyCount = 0;
819
+ for (const key in nextRecord) if (Object.hasOwn(nextRecord, key)) nextKeyCount++;
820
+ return previousKeyCount === nextKeyCount;
821
+ }
775
822
  function patchKeyedArrayRenderNode(node, normalizedChildren, context) {
823
+ if (patchSameLengthKeyedArrayRenderNode(node, normalizedChildren, context)) return node;
776
824
  const parent = node.e.parentNode;
777
825
  const oldEntries = /* @__PURE__ */ new Map();
778
826
  for (let index = 0; index < node.c.length; index++) oldEntries.set(readRenderNodeKey(node.c[index]), {
@@ -811,6 +859,58 @@ function patchKeyedArrayRenderNode(node, normalizedChildren, context) {
811
859
  node.c = nextNodes;
812
860
  return node;
813
861
  }
862
+ function patchSameLengthKeyedArrayRenderNode(node, normalizedChildren, context) {
863
+ const length = node.c.length;
864
+ if (length !== normalizedChildren.length) return false;
865
+ const changedIndexes = [];
866
+ const changedOldNodes = /* @__PURE__ */ new Map();
867
+ const nextNodes = node.c.slice();
868
+ for (let index = 0; index < length; index++) {
869
+ const oldNode = node.c[index];
870
+ const nextChild = normalizedChildren[index];
871
+ const oldKey = readRenderNodeKey(oldNode);
872
+ const nextKey = readChildKey(nextChild);
873
+ if (oldKey === void 0 || nextKey === void 0) return false;
874
+ if (oldKey === nextKey) nextNodes[index] = patchStableKeyedRenderNode(oldNode, nextChild, context);
875
+ else {
876
+ changedIndexes.push(index);
877
+ changedOldNodes.set(oldKey, oldNode);
878
+ }
879
+ }
880
+ if (changedIndexes.length === 0) {
881
+ node.c = nextNodes;
882
+ return true;
883
+ }
884
+ for (const index of changedIndexes) {
885
+ const nextChild = normalizedChildren[index];
886
+ const oldNode = changedOldNodes.get(readChildKey(nextChild));
887
+ if (oldNode === void 0) return false;
888
+ nextNodes[index] = patchStableKeyedRenderNode(oldNode, nextChild, context);
889
+ }
890
+ const parent = node.e.parentNode;
891
+ if (parent) for (let cursor = changedIndexes.length - 1; cursor >= 0; cursor--) {
892
+ const index = changedIndexes[cursor];
893
+ const child = nextNodes[index];
894
+ const anchor = index + 1 < nextNodes.length ? renderNodeStart(nextNodes[index + 1]) : node.e;
895
+ if (renderNodeEnd(child).nextSibling !== anchor) insertRenderNode(parent, child, anchor);
896
+ }
897
+ node.c = nextNodes;
898
+ return true;
899
+ }
900
+ function patchStableKeyedRenderNode(node, nextChild, context) {
901
+ if (canSkipStableKeyedRenderNodePatch(node, nextChild, context)) return node;
902
+ return patchRenderNode(node, nextChild, context);
903
+ }
904
+ function canSkipStableKeyedRenderNodePatch(node, nextChild, context) {
905
+ if (node.k === componentRenderNodeKind && node.o === nextChild) {
906
+ retainComponentSlot(nextChild, context.owner);
907
+ return true;
908
+ }
909
+ if (node.k !== componentRenderNodeKind || !isVNode(nextChild) || typeof nextChild.type !== "function" || node.t !== nextChild.type || node.q !== nextChild.key || !shallowEqualProps(node.o?.props, nextChild.props)) return false;
910
+ retainComponentSlot(nextChild, context.owner);
911
+ node.o = nextChild;
912
+ return true;
913
+ }
814
914
  function shouldPatchKeyedArray(oldNodes, nextChildren) {
815
915
  const firstOld = oldNodes[0];
816
916
  const firstNext = nextChildren[0];
@@ -852,7 +952,6 @@ function lis(values) {
852
952
  return t;
853
953
  }
854
954
  function patchComponentRenderNode(node, component, context) {
855
- if (!shouldRenderComponent(component)) return node;
856
955
  return renderComponentChild(component, context.effects, (renderedChild) => {
857
956
  node.c = patchRenderNode(node.c, renderedChild, renderContextWithOwner(context, component));
858
957
  return node;
@@ -904,10 +1003,10 @@ function patchElementRenderNode(node, vnode, context) {
904
1003
  if (refChanged) collectRefEffects(node.n, vnode.props.ref, context.effects, node.r);
905
1004
  return node;
906
1005
  }
907
- function replaceRenderNode(node, nextChild, context, key) {
1006
+ function replaceRenderNode(node, nextChild, context, key, type) {
908
1007
  const parent = renderNodeStart(node).parentNode;
909
1008
  const nextSibling = renderNodeEnd(node).nextSibling;
910
- const replacement = isComponent(nextChild) ? componentToRenderNode(nextChild, context, key) : childToRenderNode(nextChild, context);
1009
+ const replacement = isComponent(nextChild) ? componentToRenderNode(nextChild, context, key, type) : childToRenderNode(nextChild, context);
911
1010
  cleanupRenderNode(node);
912
1011
  removeRenderNode(node);
913
1012
  if (parent) insertRenderNode(parent, replacement, nextSibling);
@@ -1208,14 +1307,22 @@ function textValue(value) {
1208
1307
  return isPrimitiveValue(value) ? String(value) : "";
1209
1308
  }
1210
1309
  function arrayToRenderNode(children, context) {
1211
- return {
1212
- c: normalizeChildren(children).map((child) => childToRenderNode(child, context)),
1310
+ const normalizedChildren = normalizeChildren(children);
1311
+ const node = {
1312
+ c: normalizedChildren.map((child) => childToRenderNode(child, context)),
1213
1313
  e: createMarker(context.document),
1214
1314
  k: arrayRenderNodeKind,
1215
1315
  s: createMarker(context.document)
1216
1316
  };
1317
+ if (isKeyedArrayChildren(normalizedChildren)) node.h = new Map(normalizedChildren.map((child) => [readChildKey(child), child]));
1318
+ return node;
1319
+ }
1320
+ function isKeyedArrayChildren(children) {
1321
+ if (children.length === 0) return false;
1322
+ for (const child of children) if (!isVNode(child) || child.key === void 0) return false;
1323
+ return true;
1217
1324
  }
1218
- function componentToRenderNode(component, context, key) {
1325
+ function componentToRenderNode(component, context, key, type, vnode) {
1219
1326
  const unsubscribe = subscribeComponent(component, context.scheduleUpdate);
1220
1327
  let child;
1221
1328
  try {
@@ -1234,7 +1341,9 @@ function componentToRenderNode(component, context, key) {
1234
1341
  return {
1235
1342
  c: child,
1236
1343
  k: componentRenderNodeKind,
1344
+ o: vnode,
1237
1345
  q: key,
1346
+ t: type,
1238
1347
  u: unsubscribe,
1239
1348
  v: component
1240
1349
  };
@@ -1540,4 +1649,4 @@ function isCommentData(node, isMarkerCommentData) {
1540
1649
  return node?.nodeType === Node.COMMENT_NODE && isMarkerCommentData(node.data);
1541
1650
  }
1542
1651
  //#endregion
1543
- export { Component, Fragment, Raw, createElement, event, hydrate, isComponent, isVNode, jsx, jsx as jsxs, jsxDEV, memo, render };
1652
+ export { Component, Fragment, Raw, createElement, event, hydrate, isComponent, isVNode, jsx, jsx as jsxs, jsxDEV, render };
@@ -1,4 +1,4 @@
1
- import { L as jsxDEV, M as Fragment, l as ComponentPropsFor, m as IntrinsicElementsByTagName, n as Child, p as IntrinsicElementProps } from "./core-C_ayj9MV.mjs";
1
+ import { A as Fragment, F as jsxDEV, c as ComponentPropsFor, f as IntrinsicElementProps, n as Child, p as IntrinsicElementsByTagName } from "./core-Cypb6mR9.mjs";
2
2
 
3
3
  //#region src/jsx-dev-runtime.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { I as jsx, M as Fragment, l as ComponentPropsFor, m as IntrinsicElementsByTagName, n as Child, p as IntrinsicElementProps } from "./core-C_ayj9MV.mjs";
1
+ import { A as Fragment, P as jsx, c as ComponentPropsFor, f as IntrinsicElementProps, n as Child, p as IntrinsicElementsByTagName } from "./core-Cypb6mR9.mjs";
2
2
 
3
3
  //#region src/jsx-runtime.d.ts
4
4
  /**
package/dist/server.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as isComponent, C as RefCleanup, D as UpdateCallback, E as StyleValue, F as isVNode, I as jsx, L as jsxDEV, M as Fragment, N as Raw, O as VNode, P as createElement, S as RefCallback, T as RenderableType, a as ComponentFactoryWithoutProps, b as RawChild, c as ComponentOptions, d as ElementType, f as EmptyChild, g as MountCallback, h as Key, i as ComponentFactoryWithProps, k as Component, l as ComponentPropsFor, m as IntrinsicElementsByTagName, n as Child, o as ComponentInstance, p as IntrinsicElementProps, r as ComponentFactory, t as AnyProps, u as DangerouslySetInnerHTML, v as PreloadResolver, w as RefValue, x as RawProps, y as PrimitiveChild } from "./core-C_ayj9MV.mjs";
1
+ import { A as Fragment, C as RefValue, D as VNode, E as UpdateCallback, F as jsxDEV, M as createElement, N as isVNode, O as Component, P as jsx, S as RefCleanup, T as StyleValue, _ as PreloadResolver, a as ComponentFactoryWithoutProps, b as RawProps, c as ComponentPropsFor, d as EmptyChild, f as IntrinsicElementProps, h as MountCallback, i as ComponentFactoryWithProps, j as Raw, k as isComponent, l as DangerouslySetInnerHTML, m as Key, n as Child, o as ComponentInstance, p as IntrinsicElementsByTagName, r as ComponentFactory, s as ComponentOptions, t as AnyProps, u as ElementType, v as PrimitiveChild, w as RenderableType, x as RefCallback, y as RawChild } from "./core-Cypb6mR9.mjs";
2
2
 
3
3
  //#region src/server.d.ts
4
4
  /**
package/dist/server.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as isHostVNode, c as jsxDEV, d as normalizeChildren, f as readRawChildHtml, i as isComponentVNode, n as Raw, o as isVNode, r as createElement, s as jsx, t as Fragment, u as isRawChild } from "./vnode-B7qKjJZs.mjs";
2
2
  import { _ as serializeAttributeValue, b as validateStyleName, c as serializeHydrateEndComment, d as serializeRawEndComment, f as serializeRawStartComment, g as readDangerouslySetInnerHTML, l as serializeHydrateMetaComment, m as isChildlessElement, p as attributeName, u as serializeHydrateStartComment, v as toKebabCase, x as validateStyleValue, y as validateMarkupName } from "./hydration-markers-DdjOvH6g.mjs";
3
- import { a as isComponent, d as renderComponentErrorOutput, f as renderComponentOutput, i as finishComponentRender, l as readComponentHydrateMeta, m as setComponentProps, n as beginComponentRender, p as resolveComponent, t as Component, u as readComponentProps } from "./component-CHY49Hb1.mjs";
3
+ import { a as isComponent, c as readComponentHydrateMeta, d as renderComponentOutput, f as resolveComponent, i as finishComponentRender, l as readComponentProps, m as setComponentProps, n as beginComponentRender, t as Component, u as renderComponentErrorOutput } from "./component-2mAsZGIS.mjs";
4
4
  //#region src/server.ts
5
5
  /**
6
6
  * Renders a Pudui child tree to an HTML string.
@@ -1,4 +1,4 @@
1
- import { _ as PreloadMetadata } from "./core-C_ayj9MV.mjs";
1
+ import { g as PreloadMetadata } from "./core-Cypb6mR9.mjs";
2
2
 
3
3
  //#region src/vite-runtime.d.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pudui",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "A tiny JSX UI runtime built from the ground up.",
5
5
  "license": "MIT",
6
6
  "files": [