@sigx/runtime-core 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Andreas Ekdahl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -93,16 +93,73 @@ export interface MountContext<TElement = PlatformElement> {
93
93
  */
94
94
  export interface SetupContext {
95
95
  }
96
+ /**
97
+ * Type for defaults object - REQUIRES all optional keys to be provided.
98
+ * Required props (where undefined is not assignable) get type 'never' to prevent setting them.
99
+ * This ensures you don't forget to add a default when adding a new optional prop.
100
+ */
101
+ type DefaultsFor<TProps> = {
102
+ [K in keyof TProps as undefined extends TProps[K] ? K : never]-?: NonNullable<TProps[K]>;
103
+ };
104
+ /**
105
+ * Props type after defaults are applied - all props become required (non-undefined)
106
+ */
107
+ export type PropsWithDefaults<TProps, D> = {
108
+ readonly [K in keyof TProps]-?: K extends keyof D ? NonNullable<TProps[K]> : TProps[K];
109
+ };
110
+ /**
111
+ * Props accessor - can be called with defaults to set them,
112
+ * then accessed directly with defaults applied.
113
+ *
114
+ * When calling props(), you MUST provide defaults for ALL optional props.
115
+ * This ensures you don't forget to add a default when adding a new optional prop.
116
+ * Required props cannot be in the defaults object.
117
+ *
118
+ * @example
119
+ * ```tsx
120
+ * // Must provide defaults for ALL optional props
121
+ * const p = props({ variant: "primary", size: "md" });
122
+ * return () => <button class={p.variant}>...</button>
123
+ * ```
124
+ */
125
+ export type PropsAccessor<TProps> = {
126
+ readonly [K in keyof TProps]: TProps[K];
127
+ } & {
128
+ (defaults: DefaultsFor<TProps>): PropsWithDefaults<TProps, DefaultsFor<TProps>> & PropsAccessor<TProps>;
129
+ };
96
130
  export interface ComponentSetupContext<TElement = PlatformElement, TProps extends Record<string, any> = {}, TEvents extends Record<string, any> = {}, TRef = any, TSlots = {}> extends SetupContext {
97
131
  el: TElement;
98
132
  signal: typeof signal;
99
- props: TProps;
133
+ /**
134
+ * Component props - can be called with defaults or accessed directly.
135
+ * After calling with defaults, direct property access uses those defaults.
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * // Set defaults once
140
+ * props({ variant: "primary", size: "md" });
141
+ *
142
+ * // Then use props directly with defaults applied
143
+ * return () => <button class={props.variant}>...</button>
144
+ * ```
145
+ */
146
+ props: PropsAccessor<TProps>;
100
147
  slots: SlotsObject<TSlots>;
101
148
  emit: EmitFn<TEvents>;
102
149
  parent: any | null;
103
150
  onMount(fn: (ctx: MountContext<TElement>) => void): void;
104
151
  onCleanup(fn: (ctx: MountContext<TElement>) => void): void;
105
152
  expose(exposed: TRef): void;
153
+ /**
154
+ * The current render function. Can be replaced directly for HMR.
155
+ * @internal Used by HMR - set this, then call update()
156
+ */
157
+ renderFn: ViewFn | null;
158
+ /**
159
+ * Force the component to re-render using the current renderFn.
160
+ * For HMR: first set ctx.renderFn to the new render function, then call update().
161
+ */
162
+ update(): void;
106
163
  }
107
164
  export declare function getCurrentInstance(): ComponentSetupContext<any, any, any, any, {}> | null;
108
165
  export declare function setCurrentInstance(ctx: ComponentSetupContext<any, any, any> | null): ComponentSetupContext<any, any, any, any, {}> | null;
@@ -111,14 +168,15 @@ export declare function onCleanup(fn: (ctx: MountContext) => void): void;
111
168
  export type ViewFn = () => JSXElement | JSXElement[] | undefined;
112
169
  /**
113
170
  * Type for component setup functions.
171
+ * Includes Props, Events, Ref and Slots generics to preserve type information.
114
172
  */
115
- export type SetupFn<TSlots = {}> = (ctx: ComponentSetupContext<any, any, any, any, TSlots>) => ViewFn;
173
+ export type SetupFn<TProps extends Record<string, any> = {}, TEvents extends Record<string, any> = {}, TRef = any, TSlots = {}> = (ctx: ComponentSetupContext<PlatformElement, TProps, TEvents, TRef, TSlots>) => ViewFn;
116
174
  /**
117
175
  * Get component metadata (for DevTools)
118
176
  */
119
177
  export declare function getComponentMeta(factory: Function): {
120
178
  name?: string;
121
- setup: SetupFn<any>;
179
+ setup: SetupFn<any, any, any, any>;
122
180
  } | undefined;
123
181
  /**
124
182
  * Helper to create a proxy that tracks property access
@@ -182,7 +240,7 @@ export type ComponentFactory<TCombined extends Record<string, any>, TRef, TSlots
182
240
  children?: any;
183
241
  }) => JSXElement) & {
184
242
  /** @internal Setup function for the renderer */
185
- __setup: SetupFn<TSlots>;
243
+ __setup: SetupFn<StripInternalMarkers<TCombined>, TCombined, TRef, TSlots>;
186
244
  /** @internal Component name for debugging */
187
245
  __name?: string;
188
246
  /** @internal Type brand for props */
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,EAAE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I,EAAE,MAAM,CAAC,CAAC;IAC3E,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACzC,sCAAsC;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,mCAAmC;IACnC,KAAK,EAAE,IAAI,CAAC;IACZ,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAC3B,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EAC1C,IAAI,GAAG,cAAc,CAAC,SAAS,CAAC,EAChC,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,EAEhC,KAAK,EAAE,CAAC,GAAG,EAAE,qBAAqB,CAAC,eAAe,EAAE,oBAAoB,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,EACxH,OAAO,CAAC,EAAE,gBAAgB,GAC3B,gBAAgB,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CA4B3C"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './plugins.js';
3
3
  export * from './app.js';
4
4
  export * from './component.js';
5
5
  export * from './jsx-runtime.js';
6
+ export * from './lazy.js';
6
7
  export { Utils } from './utils/index.js';
7
8
  export * from './models/index.js';
8
9
  export * from './messaging/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -405,6 +405,190 @@ function jsxs(type, props, key) {
405
405
  }
406
406
  const jsxDEV = jsx;
407
407
 
408
+ //#endregion
409
+ //#region src/lazy.tsx
410
+ /**
411
+ * Lazy loading utilities for sigx components.
412
+ *
413
+ * Provides runtime-only lazy loading with no build dependencies.
414
+ * Works with any bundler that supports dynamic import().
415
+ */
416
+ let currentSuspenseBoundary = null;
417
+ /**
418
+ * Register a promise with the current Suspense boundary
419
+ * @internal
420
+ */
421
+ function registerPendingPromise(promise) {
422
+ const boundary = currentSuspenseBoundary;
423
+ if (boundary) {
424
+ boundary.pending.add(promise);
425
+ promise.finally(() => {
426
+ boundary.pending.delete(promise);
427
+ if (boundary.pending.size === 0) boundary.onResolve();
428
+ });
429
+ return true;
430
+ }
431
+ return false;
432
+ }
433
+ /**
434
+ * Create a lazy-loaded component wrapper.
435
+ *
436
+ * The component will be loaded on first render. Use with `<Suspense>` to show
437
+ * a fallback while loading.
438
+ *
439
+ * @param loader - Function that returns a Promise resolving to the component
440
+ * @returns A component factory that loads the real component on demand
441
+ *
442
+ * @example
443
+ * ```tsx
444
+ * import { lazy, Suspense } from 'sigx';
445
+ *
446
+ * // Component will be in a separate chunk
447
+ * const HeavyChart = lazy(() => import('./components/HeavyChart'));
448
+ *
449
+ * // Usage
450
+ * <Suspense fallback={<Spinner />}>
451
+ * <HeavyChart data={chartData} />
452
+ * </Suspense>
453
+ *
454
+ * // Preload on hover
455
+ * <button onMouseEnter={() => HeavyChart.preload()}>
456
+ * Show Chart
457
+ * </button>
458
+ * ```
459
+ */
460
+ function lazy(loader) {
461
+ let Component = null;
462
+ let promise = null;
463
+ let error = null;
464
+ let state = "pending";
465
+ const LazyWrapper = defineComponent((ctx) => {
466
+ const loadState = ctx.signal({
467
+ state,
468
+ tick: 0
469
+ });
470
+ if (!promise) promise = loader().then((mod) => {
471
+ Component = "default" in mod ? mod.default : mod;
472
+ state = "resolved";
473
+ loadState.state = "resolved";
474
+ loadState.tick++;
475
+ return Component;
476
+ }).catch((err) => {
477
+ error = err instanceof Error ? err : new Error(String(err));
478
+ state = "rejected";
479
+ loadState.state = "rejected";
480
+ loadState.tick++;
481
+ throw error;
482
+ });
483
+ if (state === "resolved" && Component) return () => {
484
+ return jsx(Component, {});
485
+ };
486
+ if (state === "rejected" && error) throw error;
487
+ if (!registerPendingPromise(promise)) promise.catch(() => {});
488
+ return () => {
489
+ const currentState = loadState.state;
490
+ loadState.tick;
491
+ if (currentState === "resolved" && Component) return jsx(Component, {});
492
+ if (currentState === "rejected" && error) throw error;
493
+ return null;
494
+ };
495
+ }, { name: "LazyComponent" });
496
+ LazyWrapper.__lazy = true;
497
+ LazyWrapper.preload = () => {
498
+ if (!promise) promise = loader().then((mod) => {
499
+ Component = "default" in mod ? mod.default : mod;
500
+ state = "resolved";
501
+ return Component;
502
+ }).catch((err) => {
503
+ error = err instanceof Error ? err : new Error(String(err));
504
+ state = "rejected";
505
+ throw error;
506
+ });
507
+ return promise;
508
+ };
509
+ LazyWrapper.isLoaded = () => {
510
+ return state === "resolved";
511
+ };
512
+ return LazyWrapper;
513
+ }
514
+ /**
515
+ * Suspense boundary component for handling async loading states.
516
+ *
517
+ * Wraps lazy-loaded components and shows a fallback while they load.
518
+ *
519
+ * @example
520
+ * ```tsx
521
+ * import { lazy, Suspense } from 'sigx';
522
+ *
523
+ * const LazyDashboard = lazy(() => import('./Dashboard'));
524
+ *
525
+ * // Basic usage
526
+ * <Suspense fallback={<div>Loading...</div>}>
527
+ * <LazyDashboard />
528
+ * </Suspense>
529
+ *
530
+ * // With spinner component
531
+ * <Suspense fallback={<Spinner size="large" />}>
532
+ * <LazyDashboard />
533
+ * <LazyCharts />
534
+ * </Suspense>
535
+ * ```
536
+ */
537
+ const Suspense = defineComponent((ctx) => {
538
+ const { props, slots } = ctx;
539
+ const state = ctx.signal({
540
+ isReady: false,
541
+ pendingCount: 0
542
+ });
543
+ const boundary = {
544
+ pending: /* @__PURE__ */ new Set(),
545
+ onResolve: () => {
546
+ state.pendingCount = boundary.pending.size;
547
+ if (boundary.pending.size === 0) state.isReady = true;
548
+ }
549
+ };
550
+ ctx.onMount(() => {
551
+ if (boundary.pending.size === 0) state.isReady = true;
552
+ });
553
+ return () => {
554
+ state.isReady;
555
+ state.pendingCount;
556
+ const prevBoundary = currentSuspenseBoundary;
557
+ currentSuspenseBoundary = boundary;
558
+ try {
559
+ const children = slots.default();
560
+ if (boundary.pending.size > 0) {
561
+ const fallback = props.fallback;
562
+ if (typeof fallback === "function") return fallback();
563
+ return fallback ?? null;
564
+ }
565
+ if (Array.isArray(children)) {
566
+ const filtered = children.filter((c) => c != null && c !== false && c !== true);
567
+ if (filtered.length === 0) return null;
568
+ if (filtered.length === 1) return filtered[0];
569
+ return filtered;
570
+ }
571
+ return children;
572
+ } catch (err) {
573
+ if (err instanceof Promise) {
574
+ registerPendingPromise(err);
575
+ const fallback = props.fallback;
576
+ if (typeof fallback === "function") return fallback();
577
+ return fallback ?? null;
578
+ }
579
+ throw err;
580
+ } finally {
581
+ currentSuspenseBoundary = prevBoundary;
582
+ }
583
+ };
584
+ }, { name: "Suspense" });
585
+ /**
586
+ * Check if a component is a lazy-loaded component
587
+ */
588
+ function isLazyComponent(component) {
589
+ return component && component.__lazy === true;
590
+ }
591
+
408
592
  //#endregion
409
593
  //#region src/utils/index.ts
410
594
  var Utils = class {
@@ -715,7 +899,6 @@ function isComponent(type) {
715
899
  }
716
900
  function createRenderer(options) {
717
901
  const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
718
- let isPatching = false;
719
902
  let currentAppContext = null;
720
903
  function render(element, container, appContext) {
721
904
  if (appContext) currentAppContext = appContext;
@@ -729,6 +912,13 @@ function createRenderer(options) {
729
912
  dom: null,
730
913
  text: element
731
914
  };
915
+ else if (isComponent(element)) vnode = {
916
+ type: element,
917
+ props: {},
918
+ key: null,
919
+ children: [],
920
+ dom: null
921
+ };
732
922
  else vnode = element;
733
923
  if (vnode) {
734
924
  if (oldVNode) patch(oldVNode, vnode, container);
@@ -740,6 +930,7 @@ function createRenderer(options) {
740
930
  }
741
931
  }
742
932
  function mount(vnode, container, before = null) {
933
+ if (vnode == null || vnode === false || vnode === true) return;
743
934
  if (vnode.type === Text) {
744
935
  const node = hostCreateText(String(vnode.text));
745
936
  vnode.dom = node;
@@ -751,7 +942,7 @@ function createRenderer(options) {
751
942
  const anchor = hostCreateComment("");
752
943
  vnode.dom = anchor;
753
944
  hostInsert(anchor, container, before);
754
- vnode.children.forEach((child) => mount(child, container, anchor));
945
+ if (vnode.children) vnode.children.forEach((child) => mount(child, container, anchor));
755
946
  return;
756
947
  }
757
948
  if (isComponent(vnode.type)) {
@@ -768,17 +959,18 @@ function createRenderer(options) {
768
959
  else if (typeof vnode.props.ref === "object") vnode.props.ref.current = element;
769
960
  }
770
961
  }
771
- vnode.children.forEach((child) => {
962
+ if (vnode.children) vnode.children.forEach((child) => {
772
963
  child.parent = vnode;
773
964
  mount(child, element);
774
965
  });
775
966
  hostInsert(element, container, before);
776
967
  }
777
968
  function unmount(vnode, container) {
778
- if (vnode._effect) vnode._effect();
969
+ const internalVNode = vnode;
970
+ if (internalVNode._effect) internalVNode._effect.stop();
779
971
  if (vnode.cleanup) vnode.cleanup();
780
972
  if (isComponent(vnode.type)) {
781
- const subTree = vnode._subTree;
973
+ const subTree = internalVNode._subTree;
782
974
  if (subTree) unmount(subTree, container);
783
975
  if (vnode.dom) hostRemove(vnode.dom);
784
976
  if (vnode.props?.ref) {
@@ -788,7 +980,7 @@ function createRenderer(options) {
788
980
  return;
789
981
  }
790
982
  if (vnode.type === Fragment) {
791
- vnode.children.forEach((child) => unmount(child, container));
983
+ if (vnode.children) vnode.children.forEach((child) => unmount(child, container));
792
984
  if (vnode.dom) hostRemove(vnode.dom);
793
985
  return;
794
986
  }
@@ -808,13 +1000,15 @@ function createRenderer(options) {
808
1000
  mount(newVNode, parent, nextSibling);
809
1001
  return;
810
1002
  }
811
- if (oldVNode._effect) {
1003
+ const oldInternal = oldVNode;
1004
+ const newInternal = newVNode;
1005
+ if (oldInternal._effect) {
812
1006
  newVNode.dom = oldVNode.dom;
813
- newVNode._effect = oldVNode._effect;
814
- newVNode._subTree = oldVNode._subTree;
815
- newVNode._slots = oldVNode._slots;
816
- const props = oldVNode._componentProps;
817
- newVNode._componentProps = props;
1007
+ newInternal._effect = oldInternal._effect;
1008
+ newInternal._subTree = oldInternal._subTree;
1009
+ newInternal._slots = oldInternal._slots;
1010
+ const props = oldInternal._componentProps;
1011
+ newInternal._componentProps = props;
818
1012
  if (props) {
819
1013
  const newProps$1 = newVNode.props || {};
820
1014
  untrack(() => {
@@ -824,20 +1018,20 @@ function createRenderer(options) {
824
1018
  for (const key in props) if (!(key in newProps$1) && key !== "children" && key !== "key" && key !== "ref") delete props[key];
825
1019
  });
826
1020
  }
827
- const slotsRef = oldVNode._slots;
1021
+ const slotsRef = oldInternal._slots;
828
1022
  const newChildren = newVNode.props?.children;
829
1023
  const newSlotsFromProps = newVNode.props?.slots;
830
1024
  if (slotsRef) {
831
1025
  if (newChildren !== void 0) slotsRef._children = newChildren;
832
1026
  if (newSlotsFromProps !== void 0) slotsRef._slotsFromProps = newSlotsFromProps;
833
- if (!isPatching) {
834
- isPatching = true;
1027
+ if (!slotsRef._isPatching) {
1028
+ slotsRef._isPatching = true;
835
1029
  try {
836
1030
  untrack(() => {
837
1031
  slotsRef._version.v++;
838
1032
  });
839
1033
  } finally {
840
- isPatching = false;
1034
+ slotsRef._isPatching = false;
841
1035
  }
842
1036
  }
843
1037
  }
@@ -942,6 +1136,43 @@ function createRenderer(options) {
942
1136
  for (let i = beginIdx; i <= endIdx; i++) if (children[i] && isSameVNode(children[i], newChild)) return i;
943
1137
  return null;
944
1138
  }
1139
+ /**
1140
+ * Creates a props accessor that can be called with defaults or accessed directly.
1141
+ * After calling with defaults, direct property access uses those defaults.
1142
+ */
1143
+ function createPropsAccessor(reactiveProps) {
1144
+ let defaults = {};
1145
+ const proxy = new Proxy(function propsAccessor() {}, {
1146
+ get(_, key) {
1147
+ if (typeof key === "symbol") return void 0;
1148
+ const value = reactiveProps[key];
1149
+ return value != null ? value : defaults[key];
1150
+ },
1151
+ apply(_, __, args) {
1152
+ if (args[0] && typeof args[0] === "object") defaults = {
1153
+ ...defaults,
1154
+ ...args[0]
1155
+ };
1156
+ return proxy;
1157
+ },
1158
+ has(_, key) {
1159
+ if (typeof key === "symbol") return false;
1160
+ return key in reactiveProps || key in defaults;
1161
+ },
1162
+ ownKeys() {
1163
+ return [...new Set([...Object.keys(reactiveProps), ...Object.keys(defaults)])];
1164
+ },
1165
+ getOwnPropertyDescriptor(_, key) {
1166
+ if (typeof key === "symbol") return void 0;
1167
+ if (key in reactiveProps || key in defaults) return {
1168
+ enumerable: true,
1169
+ configurable: true,
1170
+ writable: false
1171
+ };
1172
+ }
1173
+ });
1174
+ return proxy;
1175
+ }
945
1176
  function mountComponent(vnode, container, before, setup) {
946
1177
  const anchor = hostCreateComment("");
947
1178
  vnode.dom = anchor;
@@ -951,9 +1182,10 @@ function createRenderer(options) {
951
1182
  let exposeCalled = false;
952
1183
  const { children, slots: slotsFromProps, ...propsData } = vnode.props || {};
953
1184
  const reactiveProps = signal$1(propsData);
954
- vnode._componentProps = reactiveProps;
1185
+ const internalVNode = vnode;
1186
+ internalVNode._componentProps = reactiveProps;
955
1187
  const slots = createSlots(children, slotsFromProps);
956
- vnode._slots = slots;
1188
+ internalVNode._slots = slots;
957
1189
  const mountHooks = [];
958
1190
  const cleanupHooks = [];
959
1191
  const parentInstance = getCurrentInstance();
@@ -961,7 +1193,7 @@ function createRenderer(options) {
961
1193
  const ctx = {
962
1194
  el: container,
963
1195
  signal: signal$1,
964
- props: reactiveProps,
1196
+ props: createPropsAccessor(reactiveProps),
965
1197
  slots,
966
1198
  emit: (event, ...args) => {
967
1199
  const handler = reactiveProps[`on${event[0].toUpperCase() + event.slice(1)}`];
@@ -977,7 +1209,9 @@ function createRenderer(options) {
977
1209
  expose: (exposedValue) => {
978
1210
  exposed = exposedValue;
979
1211
  exposeCalled = true;
980
- }
1212
+ },
1213
+ renderFn: null,
1214
+ update: () => {}
981
1215
  };
982
1216
  ctx.__name = componentName;
983
1217
  if (currentAppContext) ctx._appContext = currentAppContext;
@@ -1001,24 +1235,31 @@ function createRenderer(options) {
1001
1235
  if (typeof vnode.props.ref === "function") vnode.props.ref(refValue);
1002
1236
  else if (vnode.props.ref && typeof vnode.props.ref === "object") vnode.props.ref.current = refValue;
1003
1237
  }
1004
- if (renderFn) vnode._effect = effect(() => {
1005
- const prevInstance = setCurrentInstance(ctx);
1006
- try {
1007
- const subTreeResult = renderFn();
1008
- if (subTreeResult == null) return;
1009
- const subTree = normalizeSubTree(subTreeResult);
1010
- const prevSubTree = vnode._subTree;
1011
- if (prevSubTree) {
1012
- patch(prevSubTree, subTree, container);
1013
- notifyComponentUpdated(currentAppContext, componentInstance);
1014
- } else mount(subTree, container, anchor);
1015
- vnode._subTree = subTree;
1016
- } catch (err) {
1017
- if (!handleComponentError(currentAppContext, err, componentInstance, "render")) throw err;
1018
- } finally {
1019
- setCurrentInstance(prevInstance);
1020
- }
1021
- });
1238
+ if (renderFn) {
1239
+ ctx.renderFn = renderFn;
1240
+ const componentEffect = effect(() => {
1241
+ const prevInstance = setCurrentInstance(ctx);
1242
+ try {
1243
+ const subTreeResult = ctx.renderFn();
1244
+ if (subTreeResult == null) return;
1245
+ const subTree = normalizeSubTree(subTreeResult);
1246
+ const prevSubTree = internalVNode._subTree;
1247
+ if (prevSubTree) {
1248
+ patch(prevSubTree, subTree, container);
1249
+ notifyComponentUpdated(currentAppContext, componentInstance);
1250
+ } else mount(subTree, container, anchor);
1251
+ internalVNode._subTree = subTree;
1252
+ } catch (err) {
1253
+ if (!handleComponentError(currentAppContext, err, componentInstance, "render")) throw err;
1254
+ } finally {
1255
+ setCurrentInstance(prevInstance);
1256
+ }
1257
+ });
1258
+ internalVNode._effect = componentEffect;
1259
+ ctx.update = () => {
1260
+ componentEffect();
1261
+ };
1262
+ }
1022
1263
  const mountCtx = { el: container };
1023
1264
  mountHooks.forEach((hook) => hook(mountCtx));
1024
1265
  notifyComponentMounted(currentAppContext, componentInstance);
@@ -1058,11 +1299,12 @@ function createRenderer(options) {
1058
1299
  _children: children,
1059
1300
  _slotsFromProps: slotsFromProps || {},
1060
1301
  _version: versionSignal,
1302
+ _isPatching: false,
1061
1303
  default: function() {
1062
1304
  this._version.v;
1063
1305
  const c = this._children;
1064
1306
  const { defaultChildren } = extractNamedSlotsFromChildren(c);
1065
- return defaultChildren;
1307
+ return defaultChildren.filter((child) => child != null && child !== false && child !== true);
1066
1308
  }
1067
1309
  };
1068
1310
  return new Proxy(slotsObj, { get(target, prop) {
@@ -1081,6 +1323,8 @@ function createRenderer(options) {
1081
1323
  }
1082
1324
  /**
1083
1325
  * Normalize render result to a VNode (wrapping arrays in Fragment)
1326
+ * Note: Falsy values (null, undefined, false, true) from conditional rendering
1327
+ * are handled by mount() which guards against them, so no filtering needed here.
1084
1328
  */
1085
1329
  function normalizeSubTree(result) {
1086
1330
  if (Array.isArray(result)) return {
@@ -1119,5 +1363,5 @@ function createRenderer(options) {
1119
1363
  }
1120
1364
 
1121
1365
  //#endregion
1122
- export { AppContextKey, Fragment, InstanceLifetimes, SubscriptionHandler, Text, Utils, createPropsProxy, createRenderer, createTopic, defineApp, defineComponent, defineFactory, defineInjectable, defineProvide, defineStore, getComponentMeta, getComponentPlugins, getCurrentInstance, getDefaultMount, getPlatformSyncProcessor, guid, handleComponentError, inject, injectApp, jsx, jsxDEV, jsxs, notifyComponentCreated, notifyComponentMounted, notifyComponentUnmounted, notifyComponentUpdated, onCleanup, onMount, provide, registerComponentPlugin, setCurrentInstance, setDefaultMount, setPlatformSyncProcessor, signal, toSubscriber, valueOf };
1366
+ export { AppContextKey, Fragment, InstanceLifetimes, SubscriptionHandler, Suspense, Text, Utils, createPropsProxy, createRenderer, createTopic, defineApp, defineComponent, defineFactory, defineInjectable, defineProvide, defineStore, getComponentMeta, getComponentPlugins, getCurrentInstance, getDefaultMount, getPlatformSyncProcessor, guid, handleComponentError, inject, injectApp, isLazyComponent, jsx, jsxDEV, jsxs, lazy, notifyComponentCreated, notifyComponentMounted, notifyComponentUnmounted, notifyComponentUpdated, onCleanup, onMount, provide, registerComponentPlugin, registerPendingPromise, setCurrentInstance, setDefaultMount, setPlatformSyncProcessor, signal, toSubscriber, valueOf };
1123
1367
  //# sourceMappingURL=index.js.map