@sigx/runtime-core 0.1.4 → 0.1.5
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/dist/component.d.ts +22 -3
- package/dist/component.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +221 -115
- package/dist/index.js.map +1 -1
- package/dist/plugins.d.ts +25 -1
- package/dist/plugins.d.ts.map +1 -1
- package/dist/renderer.d.ts +22 -19
- package/dist/renderer.d.ts.map +1 -1
- package/dist/utils/component-helpers.d.ts +38 -0
- package/dist/utils/component-helpers.d.ts.map +1 -0
- package/dist/utils/normalize.d.ts +31 -0
- package/dist/utils/normalize.d.ts.map +1 -0
- package/dist/utils/props-accessor.d.ts +23 -0
- package/dist/utils/props-accessor.d.ts.map +1 -0
- package/dist/utils/slots.d.ts +46 -0
- package/dist/utils/slots.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/component.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { JSXElement } from "./jsx-runtime.js";
|
|
2
2
|
import { signal } from "@sigx/reactivity";
|
|
3
|
+
/**
|
|
4
|
+
* Extension point for additional component attributes.
|
|
5
|
+
* Use module augmentation to add attributes to all components:
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // In @sigx/server-renderer
|
|
10
|
+
* declare module '@sigx/runtime-core' {
|
|
11
|
+
* interface ComponentAttributeExtensions {
|
|
12
|
+
* 'client:load'?: boolean;
|
|
13
|
+
* 'client:visible'?: boolean;
|
|
14
|
+
* 'client:idle'?: boolean;
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface ComponentAttributeExtensions {
|
|
20
|
+
}
|
|
3
21
|
/**
|
|
4
22
|
* Define a single prop with type, required/optional status
|
|
5
23
|
*/
|
|
@@ -169,8 +187,9 @@ export type ViewFn = () => JSXElement | JSXElement[] | undefined;
|
|
|
169
187
|
/**
|
|
170
188
|
* Type for component setup functions.
|
|
171
189
|
* Includes Props, Events, Ref and Slots generics to preserve type information.
|
|
190
|
+
* Can be sync or async - async setup is awaited on server, runs sync on client hydration.
|
|
172
191
|
*/
|
|
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
|
|
192
|
+
export type SetupFn<TProps extends Record<string, any> = {}, TEvents extends Record<string, any> = {}, TRef = any, TSlots = {}> = (ctx: ComponentSetupContext<PlatformElement, TProps, TEvents, TRef, TSlots>) => ViewFn | Promise<ViewFn>;
|
|
174
193
|
/**
|
|
175
194
|
* Get component metadata (for DevTools)
|
|
176
195
|
*/
|
|
@@ -235,7 +254,7 @@ export interface ComponentOptions {
|
|
|
235
254
|
type SlotProps<TSlots> = TSlots extends Record<string, any> ? {
|
|
236
255
|
slots?: Partial<TSlots>;
|
|
237
256
|
} : {};
|
|
238
|
-
export type ComponentFactory<TCombined extends Record<string, any>, TRef, TSlots> = ((props: StripInternalMarkers<Omit<TCombined, EventNames<TCombined>>> & EventHandlers<TCombined> & SlotProps<TSlots> & JSX.IntrinsicAttributes & {
|
|
257
|
+
export type ComponentFactory<TCombined extends Record<string, any>, TRef, TSlots> = ((props: StripInternalMarkers<Omit<TCombined, EventNames<TCombined>>> & EventHandlers<TCombined> & SlotProps<TSlots> & JSX.IntrinsicAttributes & ComponentAttributeExtensions & {
|
|
239
258
|
ref?: Ref<TRef>;
|
|
240
259
|
children?: any;
|
|
241
260
|
}) => JSXElement) & {
|
|
@@ -275,6 +294,6 @@ export type ComponentFactory<TCombined extends Record<string, any>, TRef, TSlots
|
|
|
275
294
|
* });
|
|
276
295
|
* ```
|
|
277
296
|
*/
|
|
278
|
-
export declare function defineComponent<TCombined extends Record<string, any> = {}, TRef = ExtractExposed<TCombined>, TSlots = ExtractSlots<TCombined>>(setup: (ctx: ComponentSetupContext<PlatformElement, StripInternalMarkers<TCombined>, TCombined, TRef, TSlots>) => ViewFn
|
|
297
|
+
export declare function defineComponent<TCombined extends Record<string, any> = {}, TRef = ExtractExposed<TCombined>, TSlots = ExtractSlots<TCombined>>(setup: (ctx: ComponentSetupContext<PlatformElement, StripInternalMarkers<TCombined>, TCombined, TRef, TSlots>) => ViewFn | Promise<ViewFn>, options?: ComponentOptions): ComponentFactory<TCombined, TRef, TSlots>;
|
|
279
298
|
export {};
|
|
280
299
|
//# sourceMappingURL=component.d.ts.map
|
package/dist/component.d.ts.map
CHANGED
|
@@ -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,QAAQ,SAAS,OAAO,GAAG,KAAK,IAAI,QAAQ,SAAS,KAAK,GACxG;KAAG,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,KAAK;CAAE,GACxB;KAAG,CAAC,IAAI,KAAK,GAAG,KAAK;CAAE,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI,IAAI,KAAK,SAAS,IAAI,GAChE,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,WAAW,CAAC,cAAc,EAAE,WAAW,CAAC,GAC3E,WAAW,SAAS,MAAM,GAC1B,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,WAAW,CAAC,UAAU,WAAW,EAAE,EAAE,KAAK,CAAC,GAC5E,KAAK,CAAC;AAEZ,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAAE,aAAa,EAAE,CAA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;IAChB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,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,GAAG,OAAO,CAAC,MAAM,CAAC,EAC1I,OAAO,CAAC,EAAE,gBAAgB,GAC3B,gBAAgB,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CA4B3C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export * from './component.js';
|
|
|
5
5
|
export * from './jsx-runtime.js';
|
|
6
6
|
export * from './lazy.js';
|
|
7
7
|
export { Utils } from './utils/index.js';
|
|
8
|
+
export { createPropsAccessor } from './utils/props-accessor.js';
|
|
9
|
+
export { createSlots } from './utils/slots.js';
|
|
10
|
+
export type { InternalSlotsObject } from './utils/slots.js';
|
|
11
|
+
export { normalizeSubTree } from './utils/normalize.js';
|
|
8
12
|
export * from './models/index.js';
|
|
9
13
|
export * from './messaging/index.js';
|
|
10
14
|
export * from './di/injectable.js';
|
|
@@ -13,5 +17,4 @@ export * from './stores/store.js';
|
|
|
13
17
|
import './jsx-types.d.ts';
|
|
14
18
|
export { signal } from '@sigx/reactivity';
|
|
15
19
|
export * from './renderer.js';
|
|
16
|
-
export type { CustomElementRegistry, ComponentProps, RegisteredElements } from './register.d.ts';
|
|
17
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,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
|
|
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,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,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"}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,29 @@ function registerComponentPlugin(plugin) {
|
|
|
28
28
|
function getComponentPlugins() {
|
|
29
29
|
return plugins;
|
|
30
30
|
}
|
|
31
|
+
const contextExtensions = [];
|
|
32
|
+
/**
|
|
33
|
+
* Register a function that will be called to extend every component context.
|
|
34
|
+
* Extensions are called in order of registration.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // In @sigx/server-renderer/client
|
|
39
|
+
* registerContextExtension((ctx) => {
|
|
40
|
+
* ctx.ssr = { load: () => {} };
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function registerContextExtension(extension) {
|
|
45
|
+
contextExtensions.push(extension);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Apply all registered context extensions to a context object.
|
|
49
|
+
* Called internally by the renderer when creating component contexts.
|
|
50
|
+
*/
|
|
51
|
+
function applyContextExtensions(ctx) {
|
|
52
|
+
for (const extension of contextExtensions) extension(ctx);
|
|
53
|
+
}
|
|
31
54
|
|
|
32
55
|
//#endregion
|
|
33
56
|
//#region src/app.ts
|
|
@@ -603,6 +626,195 @@ function guid$1() {
|
|
|
603
626
|
});
|
|
604
627
|
}
|
|
605
628
|
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/utils/props-accessor.ts
|
|
631
|
+
/**
|
|
632
|
+
* Creates a props accessor that can be called with defaults or accessed directly.
|
|
633
|
+
* After calling with defaults, direct property access uses those defaults.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```ts
|
|
637
|
+
* // In component setup:
|
|
638
|
+
* const props = createPropsAccessor(reactiveProps);
|
|
639
|
+
*
|
|
640
|
+
* // Set defaults
|
|
641
|
+
* props({ count: 0, label: 'Default' });
|
|
642
|
+
*
|
|
643
|
+
* // Access props (falls back to defaults if not provided)
|
|
644
|
+
* const count = props.count;
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
function createPropsAccessor(reactiveProps) {
|
|
648
|
+
let defaults = {};
|
|
649
|
+
const proxy = new Proxy(function propsAccessor() {}, {
|
|
650
|
+
get(_, key) {
|
|
651
|
+
if (typeof key === "symbol") return void 0;
|
|
652
|
+
const value = reactiveProps[key];
|
|
653
|
+
return value != null ? value : defaults[key];
|
|
654
|
+
},
|
|
655
|
+
apply(_, __, args) {
|
|
656
|
+
if (args[0] && typeof args[0] === "object") defaults = {
|
|
657
|
+
...defaults,
|
|
658
|
+
...args[0]
|
|
659
|
+
};
|
|
660
|
+
return proxy;
|
|
661
|
+
},
|
|
662
|
+
has(_, key) {
|
|
663
|
+
if (typeof key === "symbol") return false;
|
|
664
|
+
return key in reactiveProps || key in defaults;
|
|
665
|
+
},
|
|
666
|
+
ownKeys() {
|
|
667
|
+
return [...new Set([...Object.keys(reactiveProps), ...Object.keys(defaults)])];
|
|
668
|
+
},
|
|
669
|
+
getOwnPropertyDescriptor(_, key) {
|
|
670
|
+
if (typeof key === "symbol") return void 0;
|
|
671
|
+
if (key in reactiveProps || key in defaults) return {
|
|
672
|
+
enumerable: true,
|
|
673
|
+
configurable: true,
|
|
674
|
+
writable: false
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
return proxy;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/utils/slots.ts
|
|
683
|
+
/**
|
|
684
|
+
* Slots system for component children.
|
|
685
|
+
* Supports default and named slots with reactivity.
|
|
686
|
+
*/
|
|
687
|
+
/**
|
|
688
|
+
* Create slots object from children and slots prop.
|
|
689
|
+
* Uses a version signal to trigger re-renders when children change.
|
|
690
|
+
*
|
|
691
|
+
* Supports named slots via:
|
|
692
|
+
* - `slots` prop object (e.g., `slots={{ header: () => <div>...</div> }}`)
|
|
693
|
+
* - `slot` prop on children (e.g., `<div slot="header">...</div>`)
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* ```tsx
|
|
697
|
+
* // Parent component
|
|
698
|
+
* <Card slots={{ header: () => <h1>Title</h1> }}>
|
|
699
|
+
* <p>Default content</p>
|
|
700
|
+
* <span slot="footer">Footer text</span>
|
|
701
|
+
* </Card>
|
|
702
|
+
*
|
|
703
|
+
* // Card component setup
|
|
704
|
+
* const slots = createSlots(children, slotsFromProps);
|
|
705
|
+
* return () => (
|
|
706
|
+
* <div>
|
|
707
|
+
* {slots.header()}
|
|
708
|
+
* {slots.default()}
|
|
709
|
+
* {slots.footer()}
|
|
710
|
+
* </div>
|
|
711
|
+
* );
|
|
712
|
+
* ```
|
|
713
|
+
*/
|
|
714
|
+
function createSlots(children, slotsFromProps) {
|
|
715
|
+
const versionSignal = signal$1({ v: 0 });
|
|
716
|
+
function extractNamedSlotsFromChildren(c) {
|
|
717
|
+
const defaultChildren = [];
|
|
718
|
+
const namedSlots = {};
|
|
719
|
+
if (c == null) return {
|
|
720
|
+
defaultChildren,
|
|
721
|
+
namedSlots
|
|
722
|
+
};
|
|
723
|
+
const items = Array.isArray(c) ? c : [c];
|
|
724
|
+
for (const child of items) if (child && typeof child === "object" && child.props && child.props.slot) {
|
|
725
|
+
const slotName = child.props.slot;
|
|
726
|
+
if (!namedSlots[slotName]) namedSlots[slotName] = [];
|
|
727
|
+
namedSlots[slotName].push(child);
|
|
728
|
+
} else defaultChildren.push(child);
|
|
729
|
+
return {
|
|
730
|
+
defaultChildren,
|
|
731
|
+
namedSlots
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
const slotsObj = {
|
|
735
|
+
_children: children,
|
|
736
|
+
_slotsFromProps: slotsFromProps || {},
|
|
737
|
+
_version: versionSignal,
|
|
738
|
+
_isPatching: false,
|
|
739
|
+
default: function() {
|
|
740
|
+
this._version.v;
|
|
741
|
+
const c = this._children;
|
|
742
|
+
const { defaultChildren } = extractNamedSlotsFromChildren(c);
|
|
743
|
+
return defaultChildren.filter((child) => child != null && child !== false && child !== true);
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
return new Proxy(slotsObj, { get(target, prop) {
|
|
747
|
+
if (prop in target) return target[prop];
|
|
748
|
+
if (typeof prop === "string") return function(scopedProps) {
|
|
749
|
+
target._version.v;
|
|
750
|
+
if (target._slotsFromProps && typeof target._slotsFromProps[prop] === "function") {
|
|
751
|
+
const result = target._slotsFromProps[prop](scopedProps);
|
|
752
|
+
if (result == null) return [];
|
|
753
|
+
return Array.isArray(result) ? result : [result];
|
|
754
|
+
}
|
|
755
|
+
const { namedSlots } = extractNamedSlotsFromChildren(target._children);
|
|
756
|
+
return namedSlots[prop] || [];
|
|
757
|
+
};
|
|
758
|
+
} });
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/utils/normalize.ts
|
|
763
|
+
/**
|
|
764
|
+
* VNode normalization utilities.
|
|
765
|
+
* Converts render results into proper VNode structures.
|
|
766
|
+
*/
|
|
767
|
+
/**
|
|
768
|
+
* Normalize render result to a VNode (wrapping arrays in Fragment).
|
|
769
|
+
* Handles null, undefined, false, true by returning an empty Text node.
|
|
770
|
+
*
|
|
771
|
+
* This is used to normalize the return value of component render functions
|
|
772
|
+
* into a consistent VNode structure for the renderer to process.
|
|
773
|
+
*
|
|
774
|
+
* @example
|
|
775
|
+
* ```ts
|
|
776
|
+
* // Conditional rendering returns null/false
|
|
777
|
+
* normalizeSubTree(null) // → empty Text node
|
|
778
|
+
* normalizeSubTree(false) // → empty Text node
|
|
779
|
+
*
|
|
780
|
+
* // Arrays become Fragments
|
|
781
|
+
* normalizeSubTree([<A/>, <B/>]) // → Fragment with children
|
|
782
|
+
*
|
|
783
|
+
* // Primitives become Text nodes
|
|
784
|
+
* normalizeSubTree("hello") // → Text node
|
|
785
|
+
* normalizeSubTree(42) // → Text node
|
|
786
|
+
*
|
|
787
|
+
* // VNodes pass through
|
|
788
|
+
* normalizeSubTree(<div/>) // → same VNode
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
function normalizeSubTree(result) {
|
|
792
|
+
if (result == null || result === false || result === true) return {
|
|
793
|
+
type: Text,
|
|
794
|
+
props: {},
|
|
795
|
+
key: null,
|
|
796
|
+
children: [],
|
|
797
|
+
dom: null,
|
|
798
|
+
text: ""
|
|
799
|
+
};
|
|
800
|
+
if (Array.isArray(result)) return {
|
|
801
|
+
type: Fragment,
|
|
802
|
+
props: {},
|
|
803
|
+
key: null,
|
|
804
|
+
children: result,
|
|
805
|
+
dom: null
|
|
806
|
+
};
|
|
807
|
+
if (typeof result === "string" || typeof result === "number") return {
|
|
808
|
+
type: Text,
|
|
809
|
+
props: {},
|
|
810
|
+
key: null,
|
|
811
|
+
children: [],
|
|
812
|
+
dom: null,
|
|
813
|
+
text: result
|
|
814
|
+
};
|
|
815
|
+
return result;
|
|
816
|
+
}
|
|
817
|
+
|
|
606
818
|
//#endregion
|
|
607
819
|
//#region src/models/index.ts
|
|
608
820
|
const guid = guid$1;
|
|
@@ -1136,43 +1348,6 @@ function createRenderer(options) {
|
|
|
1136
1348
|
for (let i = beginIdx; i <= endIdx; i++) if (children[i] && isSameVNode(children[i], newChild)) return i;
|
|
1137
1349
|
return null;
|
|
1138
1350
|
}
|
|
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
|
-
}
|
|
1176
1351
|
function mountComponent(vnode, container, before, setup) {
|
|
1177
1352
|
const anchor = hostCreateComment("");
|
|
1178
1353
|
vnode.dom = anchor;
|
|
@@ -1213,6 +1388,7 @@ function createRenderer(options) {
|
|
|
1213
1388
|
renderFn: null,
|
|
1214
1389
|
update: () => {}
|
|
1215
1390
|
};
|
|
1391
|
+
applyContextExtensions(ctx);
|
|
1216
1392
|
ctx.__name = componentName;
|
|
1217
1393
|
if (currentAppContext) ctx._appContext = currentAppContext;
|
|
1218
1394
|
const componentInstance = {
|
|
@@ -1223,7 +1399,9 @@ function createRenderer(options) {
|
|
|
1223
1399
|
const prev = setCurrentInstance(ctx);
|
|
1224
1400
|
let renderFn;
|
|
1225
1401
|
try {
|
|
1226
|
-
|
|
1402
|
+
const setupResult = setup(ctx);
|
|
1403
|
+
if (setupResult && typeof setupResult.then === "function") throw new Error(`Async setup in component "${componentName}" is only supported during SSR. On the client, use pre-loaded data from hydration or fetch in onMount.`);
|
|
1404
|
+
renderFn = setupResult;
|
|
1227
1405
|
notifyComponentCreated(currentAppContext, componentInstance);
|
|
1228
1406
|
} catch (err) {
|
|
1229
1407
|
if (!handleComponentError(currentAppContext, err, componentInstance, "setup")) throw err;
|
|
@@ -1268,84 +1446,12 @@ function createRenderer(options) {
|
|
|
1268
1446
|
cleanupHooks.forEach((hook) => hook(mountCtx));
|
|
1269
1447
|
};
|
|
1270
1448
|
}
|
|
1271
|
-
/**
|
|
1272
|
-
* Create slots object from children and slots prop.
|
|
1273
|
-
* Uses a version signal to trigger re-renders when children change.
|
|
1274
|
-
* Supports named slots via:
|
|
1275
|
-
* - `slots` prop object (e.g., slots={{ header: () => <div>...</div> }})
|
|
1276
|
-
* - `slot` prop on children (e.g., <div slot="header">...</div>)
|
|
1277
|
-
*/
|
|
1278
|
-
function createSlots(children, slotsFromProps) {
|
|
1279
|
-
const versionSignal = signal$1({ v: 0 });
|
|
1280
|
-
function extractNamedSlotsFromChildren(c) {
|
|
1281
|
-
const defaultChildren = [];
|
|
1282
|
-
const namedSlots = {};
|
|
1283
|
-
if (c == null) return {
|
|
1284
|
-
defaultChildren,
|
|
1285
|
-
namedSlots
|
|
1286
|
-
};
|
|
1287
|
-
const items = Array.isArray(c) ? c : [c];
|
|
1288
|
-
for (const child of items) if (child && typeof child === "object" && child.props && child.props.slot) {
|
|
1289
|
-
const slotName = child.props.slot;
|
|
1290
|
-
if (!namedSlots[slotName]) namedSlots[slotName] = [];
|
|
1291
|
-
namedSlots[slotName].push(child);
|
|
1292
|
-
} else defaultChildren.push(child);
|
|
1293
|
-
return {
|
|
1294
|
-
defaultChildren,
|
|
1295
|
-
namedSlots
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
|
-
const slotsObj = {
|
|
1299
|
-
_children: children,
|
|
1300
|
-
_slotsFromProps: slotsFromProps || {},
|
|
1301
|
-
_version: versionSignal,
|
|
1302
|
-
_isPatching: false,
|
|
1303
|
-
default: function() {
|
|
1304
|
-
this._version.v;
|
|
1305
|
-
const c = this._children;
|
|
1306
|
-
const { defaultChildren } = extractNamedSlotsFromChildren(c);
|
|
1307
|
-
return defaultChildren.filter((child) => child != null && child !== false && child !== true);
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
return new Proxy(slotsObj, { get(target, prop) {
|
|
1311
|
-
if (prop in target) return target[prop];
|
|
1312
|
-
if (typeof prop === "string") return function(scopedProps) {
|
|
1313
|
-
target._version.v;
|
|
1314
|
-
if (target._slotsFromProps && typeof target._slotsFromProps[prop] === "function") {
|
|
1315
|
-
const result = target._slotsFromProps[prop](scopedProps);
|
|
1316
|
-
if (result == null) return [];
|
|
1317
|
-
return Array.isArray(result) ? result : [result];
|
|
1318
|
-
}
|
|
1319
|
-
const { namedSlots } = extractNamedSlotsFromChildren(target._children);
|
|
1320
|
-
return namedSlots[prop] || [];
|
|
1321
|
-
};
|
|
1322
|
-
} });
|
|
1323
|
-
}
|
|
1324
|
-
/**
|
|
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.
|
|
1328
|
-
*/
|
|
1329
|
-
function normalizeSubTree(result) {
|
|
1330
|
-
if (Array.isArray(result)) return {
|
|
1331
|
-
type: Fragment,
|
|
1332
|
-
props: {},
|
|
1333
|
-
key: null,
|
|
1334
|
-
children: result,
|
|
1335
|
-
dom: null
|
|
1336
|
-
};
|
|
1337
|
-
if (typeof result === "string" || typeof result === "number") return {
|
|
1338
|
-
type: Text,
|
|
1339
|
-
props: {},
|
|
1340
|
-
key: null,
|
|
1341
|
-
children: [],
|
|
1342
|
-
dom: null,
|
|
1343
|
-
text: result
|
|
1344
|
-
};
|
|
1345
|
-
return result;
|
|
1346
|
-
}
|
|
1347
1449
|
return {
|
|
1348
1450
|
render,
|
|
1451
|
+
patch,
|
|
1452
|
+
mount,
|
|
1453
|
+
unmount,
|
|
1454
|
+
mountComponent,
|
|
1349
1455
|
createApp: (rootComponent) => {
|
|
1350
1456
|
return { mount(selectorOrContainer) {
|
|
1351
1457
|
let container = null;
|
|
@@ -1363,5 +1469,5 @@ function createRenderer(options) {
|
|
|
1363
1469
|
}
|
|
1364
1470
|
|
|
1365
1471
|
//#endregion
|
|
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 };
|
|
1472
|
+
export { AppContextKey, Fragment, InstanceLifetimes, SubscriptionHandler, Suspense, Text, Utils, applyContextExtensions, createPropsAccessor, createPropsProxy, createRenderer, createSlots, createTopic, defineApp, defineComponent, defineFactory, defineInjectable, defineProvide, defineStore, getComponentMeta, getComponentPlugins, getCurrentInstance, getDefaultMount, getPlatformSyncProcessor, guid, handleComponentError, inject, injectApp, isLazyComponent, jsx, jsxDEV, jsxs, lazy, normalizeSubTree, notifyComponentCreated, notifyComponentMounted, notifyComponentUnmounted, notifyComponentUpdated, onCleanup, onMount, provide, registerComponentPlugin, registerContextExtension, registerPendingPromise, setCurrentInstance, setDefaultMount, setPlatformSyncProcessor, signal, toSubscriber, valueOf };
|
|
1367
1473
|
//# sourceMappingURL=index.js.map
|