pudui 0.0.1 → 0.0.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.
@@ -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,7 @@ 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);
750
757
  const sharedLength = Math.min(node.c.length, normalizedChildren.length);
751
758
  for (let index = 0; index < sharedLength; index++) node.c[index] = patchRenderNode(node.c[index], normalizedChildren[index], context);
752
759
  const parent = node.e.parentNode;
@@ -770,9 +777,45 @@ function patchArrayRenderNode(node, nextChildren, context) {
770
777
  const firstRemovedChild = removedChildren[0];
771
778
  const lastRemovedChild = removedChildren.at(-1);
772
779
  if (firstRemovedChild && lastRemovedChild) removeNodeRange(renderNodeStart(firstRemovedChild), renderNodeEnd(lastRemovedChild));
780
+ node.h = void 0;
773
781
  return node;
774
782
  }
783
+ function reuseKeyedArrayChildren(node, nextChildren) {
784
+ const previousChildren = node.h;
785
+ const reusableChildren = previousChildren ? Array.from(nextChildren) : void 0;
786
+ const nextReusableChildren = /* @__PURE__ */ new Map();
787
+ for (let index = 0; index < nextChildren.length; index++) {
788
+ const child = nextChildren[index];
789
+ const key = readChildKey(child);
790
+ if (key === void 0) {
791
+ node.h = void 0;
792
+ return nextChildren;
793
+ }
794
+ const previousChild = previousChildren?.get(key);
795
+ const reusableChild = previousChild && canReuseKeyedChild(previousChild, child) ? previousChild : child;
796
+ if (reusableChildren) reusableChildren[index] = reusableChild;
797
+ nextReusableChildren.set(key, reusableChild);
798
+ }
799
+ node.h = nextReusableChildren;
800
+ return reusableChildren ?? nextChildren;
801
+ }
802
+ function canReuseKeyedChild(previousChild, nextChild) {
803
+ if (!isVNode(previousChild) || !isVNode(nextChild) || typeof previousChild.type !== "function" || previousChild.type !== nextChild.type || previousChild.key !== nextChild.key) return false;
804
+ return shallowEqualProps(previousChild.props, nextChild.props);
805
+ }
806
+ function shallowEqualProps(previousProps, nextProps) {
807
+ if (previousProps === nextProps) return true;
808
+ if (previousProps === void 0) return false;
809
+ const previousKeys = Object.keys(previousProps);
810
+ const nextKeys = Object.keys(nextProps);
811
+ if (previousKeys.length !== nextKeys.length) return false;
812
+ const previousRecord = previousProps;
813
+ const nextRecord = nextProps;
814
+ for (const key of previousKeys) if (previousRecord[key] !== nextRecord[key] || !Object.hasOwn(nextProps, key)) return false;
815
+ return true;
816
+ }
775
817
  function patchKeyedArrayRenderNode(node, normalizedChildren, context) {
818
+ if (patchSameLengthKeyedArrayRenderNode(node, normalizedChildren, context)) return node;
776
819
  const parent = node.e.parentNode;
777
820
  const oldEntries = /* @__PURE__ */ new Map();
778
821
  for (let index = 0; index < node.c.length; index++) oldEntries.set(readRenderNodeKey(node.c[index]), {
@@ -811,6 +854,58 @@ function patchKeyedArrayRenderNode(node, normalizedChildren, context) {
811
854
  node.c = nextNodes;
812
855
  return node;
813
856
  }
857
+ function patchSameLengthKeyedArrayRenderNode(node, normalizedChildren, context) {
858
+ const length = node.c.length;
859
+ if (length !== normalizedChildren.length) return false;
860
+ const changedIndexes = [];
861
+ const changedOldNodes = /* @__PURE__ */ new Map();
862
+ const nextNodes = node.c.slice();
863
+ for (let index = 0; index < length; index++) {
864
+ const oldNode = node.c[index];
865
+ const nextChild = normalizedChildren[index];
866
+ const oldKey = readRenderNodeKey(oldNode);
867
+ const nextKey = readChildKey(nextChild);
868
+ if (oldKey === void 0 || nextKey === void 0) return false;
869
+ if (oldKey === nextKey) nextNodes[index] = patchStableKeyedRenderNode(oldNode, nextChild, context);
870
+ else {
871
+ changedIndexes.push(index);
872
+ changedOldNodes.set(oldKey, oldNode);
873
+ }
874
+ }
875
+ if (changedIndexes.length === 0) {
876
+ node.c = nextNodes;
877
+ return true;
878
+ }
879
+ for (const index of changedIndexes) {
880
+ const nextChild = normalizedChildren[index];
881
+ const oldNode = changedOldNodes.get(readChildKey(nextChild));
882
+ if (oldNode === void 0) return false;
883
+ nextNodes[index] = patchStableKeyedRenderNode(oldNode, nextChild, context);
884
+ }
885
+ const parent = node.e.parentNode;
886
+ if (parent) for (let cursor = changedIndexes.length - 1; cursor >= 0; cursor--) {
887
+ const index = changedIndexes[cursor];
888
+ const child = nextNodes[index];
889
+ const anchor = index + 1 < nextNodes.length ? renderNodeStart(nextNodes[index + 1]) : node.e;
890
+ if (renderNodeEnd(child).nextSibling !== anchor) insertRenderNode(parent, child, anchor);
891
+ }
892
+ node.c = nextNodes;
893
+ return true;
894
+ }
895
+ function patchStableKeyedRenderNode(node, nextChild, context) {
896
+ if (canSkipStableKeyedRenderNodePatch(node, nextChild, context)) return node;
897
+ return patchRenderNode(node, nextChild, context);
898
+ }
899
+ function canSkipStableKeyedRenderNodePatch(node, nextChild, context) {
900
+ if (node.k === componentRenderNodeKind && node.o === nextChild) {
901
+ retainComponentSlot(nextChild, context.owner);
902
+ return true;
903
+ }
904
+ 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;
905
+ retainComponentSlot(nextChild, context.owner);
906
+ node.o = nextChild;
907
+ return true;
908
+ }
814
909
  function shouldPatchKeyedArray(oldNodes, nextChildren) {
815
910
  const firstOld = oldNodes[0];
816
911
  const firstNext = nextChildren[0];
@@ -852,7 +947,6 @@ function lis(values) {
852
947
  return t;
853
948
  }
854
949
  function patchComponentRenderNode(node, component, context) {
855
- if (!shouldRenderComponent(component)) return node;
856
950
  return renderComponentChild(component, context.effects, (renderedChild) => {
857
951
  node.c = patchRenderNode(node.c, renderedChild, renderContextWithOwner(context, component));
858
952
  return node;
@@ -904,10 +998,10 @@ function patchElementRenderNode(node, vnode, context) {
904
998
  if (refChanged) collectRefEffects(node.n, vnode.props.ref, context.effects, node.r);
905
999
  return node;
906
1000
  }
907
- function replaceRenderNode(node, nextChild, context, key) {
1001
+ function replaceRenderNode(node, nextChild, context, key, type) {
908
1002
  const parent = renderNodeStart(node).parentNode;
909
1003
  const nextSibling = renderNodeEnd(node).nextSibling;
910
- const replacement = isComponent(nextChild) ? componentToRenderNode(nextChild, context, key) : childToRenderNode(nextChild, context);
1004
+ const replacement = isComponent(nextChild) ? componentToRenderNode(nextChild, context, key, type) : childToRenderNode(nextChild, context);
911
1005
  cleanupRenderNode(node);
912
1006
  removeRenderNode(node);
913
1007
  if (parent) insertRenderNode(parent, replacement, nextSibling);
@@ -1208,14 +1302,22 @@ function textValue(value) {
1208
1302
  return isPrimitiveValue(value) ? String(value) : "";
1209
1303
  }
1210
1304
  function arrayToRenderNode(children, context) {
1211
- return {
1212
- c: normalizeChildren(children).map((child) => childToRenderNode(child, context)),
1305
+ const normalizedChildren = normalizeChildren(children);
1306
+ const node = {
1307
+ c: normalizedChildren.map((child) => childToRenderNode(child, context)),
1213
1308
  e: createMarker(context.document),
1214
1309
  k: arrayRenderNodeKind,
1215
1310
  s: createMarker(context.document)
1216
1311
  };
1312
+ if (isKeyedArrayChildren(normalizedChildren)) node.h = new Map(normalizedChildren.map((child) => [readChildKey(child), child]));
1313
+ return node;
1314
+ }
1315
+ function isKeyedArrayChildren(children) {
1316
+ if (children.length === 0) return false;
1317
+ for (const child of children) if (!isVNode(child) || child.key === void 0) return false;
1318
+ return true;
1217
1319
  }
1218
- function componentToRenderNode(component, context, key) {
1320
+ function componentToRenderNode(component, context, key, type, vnode) {
1219
1321
  const unsubscribe = subscribeComponent(component, context.scheduleUpdate);
1220
1322
  let child;
1221
1323
  try {
@@ -1234,7 +1336,9 @@ function componentToRenderNode(component, context, key) {
1234
1336
  return {
1235
1337
  c: child,
1236
1338
  k: componentRenderNodeKind,
1339
+ o: vnode,
1237
1340
  q: key,
1341
+ t: type,
1238
1342
  u: unsubscribe,
1239
1343
  v: component
1240
1344
  };
@@ -1540,4 +1644,4 @@ function isCommentData(node, isMarkerCommentData) {
1540
1644
  return node?.nodeType === Node.COMMENT_NODE && isMarkerCommentData(node.data);
1541
1645
  }
1542
1646
  //#endregion
1543
- export { Component, Fragment, Raw, createElement, event, hydrate, isComponent, isVNode, jsx, jsx as jsxs, jsxDEV, memo, render };
1647
+ 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.2",
4
4
  "description": "A tiny JSX UI runtime built from the ground up.",
5
5
  "license": "MIT",
6
6
  "files": [