@sigx/runtime-core 0.1.3 → 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 +83 -6
- package/dist/component.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +463 -113
- package/dist/index.js.map +1 -1
- package/dist/lazy.d.ts +99 -0
- package/dist/lazy.d.ts.map +1 -0
- package/dist/plugins.d.ts +25 -1
- package/dist/plugins.d.ts.map +1 -1
- package/dist/renderer.d.ts +39 -6
- 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/lazy.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy loading utilities for sigx components.
|
|
3
|
+
*
|
|
4
|
+
* Provides runtime-only lazy loading with no build dependencies.
|
|
5
|
+
* Works with any bundler that supports dynamic import().
|
|
6
|
+
*/
|
|
7
|
+
import { type ComponentFactory } from './component.js';
|
|
8
|
+
import { type JSXElement } from './jsx-runtime.js';
|
|
9
|
+
/**
|
|
10
|
+
* Module with default export
|
|
11
|
+
*/
|
|
12
|
+
type ModuleWithDefault<T> = {
|
|
13
|
+
default: T;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Loader function that returns a component or module with default export
|
|
17
|
+
*/
|
|
18
|
+
type ComponentLoader<T> = () => Promise<T | ModuleWithDefault<T>>;
|
|
19
|
+
/**
|
|
20
|
+
* Extended component factory with lazy loading methods
|
|
21
|
+
*/
|
|
22
|
+
export type LazyComponentFactory<T extends ComponentFactory<any, any, any>> = T & {
|
|
23
|
+
/** Preload the component without rendering */
|
|
24
|
+
preload: () => Promise<T>;
|
|
25
|
+
/** Check if the component is loaded */
|
|
26
|
+
isLoaded: () => boolean;
|
|
27
|
+
/** @internal Marker for lazy components */
|
|
28
|
+
__lazy: true;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Props for the Suspense component
|
|
32
|
+
*/
|
|
33
|
+
export type SuspenseProps = {
|
|
34
|
+
/** Fallback content to show while loading */
|
|
35
|
+
fallback?: JSXElement | (() => JSXElement);
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Register a promise with the current Suspense boundary
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function registerPendingPromise(promise: Promise<any>): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Create a lazy-loaded component wrapper.
|
|
44
|
+
*
|
|
45
|
+
* The component will be loaded on first render. Use with `<Suspense>` to show
|
|
46
|
+
* a fallback while loading.
|
|
47
|
+
*
|
|
48
|
+
* @param loader - Function that returns a Promise resolving to the component
|
|
49
|
+
* @returns A component factory that loads the real component on demand
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* import { lazy, Suspense } from 'sigx';
|
|
54
|
+
*
|
|
55
|
+
* // Component will be in a separate chunk
|
|
56
|
+
* const HeavyChart = lazy(() => import('./components/HeavyChart'));
|
|
57
|
+
*
|
|
58
|
+
* // Usage
|
|
59
|
+
* <Suspense fallback={<Spinner />}>
|
|
60
|
+
* <HeavyChart data={chartData} />
|
|
61
|
+
* </Suspense>
|
|
62
|
+
*
|
|
63
|
+
* // Preload on hover
|
|
64
|
+
* <button onMouseEnter={() => HeavyChart.preload()}>
|
|
65
|
+
* Show Chart
|
|
66
|
+
* </button>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function lazy<T extends ComponentFactory<any, any, any>>(loader: ComponentLoader<T>): LazyComponentFactory<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Suspense boundary component for handling async loading states.
|
|
72
|
+
*
|
|
73
|
+
* Wraps lazy-loaded components and shows a fallback while they load.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* import { lazy, Suspense } from 'sigx';
|
|
78
|
+
*
|
|
79
|
+
* const LazyDashboard = lazy(() => import('./Dashboard'));
|
|
80
|
+
*
|
|
81
|
+
* // Basic usage
|
|
82
|
+
* <Suspense fallback={<div>Loading...</div>}>
|
|
83
|
+
* <LazyDashboard />
|
|
84
|
+
* </Suspense>
|
|
85
|
+
*
|
|
86
|
+
* // With spinner component
|
|
87
|
+
* <Suspense fallback={<Spinner size="large" />}>
|
|
88
|
+
* <LazyDashboard />
|
|
89
|
+
* <LazyCharts />
|
|
90
|
+
* </Suspense>
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare const Suspense: ComponentFactory<SuspenseProps, void, {}>;
|
|
94
|
+
/**
|
|
95
|
+
* Check if a component is a lazy-loaded component
|
|
96
|
+
*/
|
|
97
|
+
export declare function isLazyComponent(component: any): component is LazyComponentFactory<any>;
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../src/lazy.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAWxD;;GAEG;AACH,KAAK,iBAAiB,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAE3C;;GAEG;AACH,KAAK,eAAe,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG;IAC9E,8CAA8C;IAC9C,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,uCAAuC;IACvC,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,2CAA2C;IAC3C,MAAM,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,CAAC;CAC9C,CAAC;AAgBF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAcrE;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC1D,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,GAC3B,oBAAoB,CAAC,CAAC,CAAC,CAkGzB;AAMD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,QAAQ,2CA4EpB,CAAC;AAMF;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAEtF"}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* issues with ES module initialization.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
* Plugin system for components (used by HMR, DevTools, etc.)
|
|
9
|
+
* Plugin system for components (used by HMR, DevTools, SSR, etc.)
|
|
10
10
|
* Note: SetupFn type is duplicated here to avoid circular imports
|
|
11
11
|
*/
|
|
12
12
|
export type ComponentPlugin = {
|
|
@@ -17,4 +17,28 @@ export declare function registerComponentPlugin(plugin: ComponentPlugin): void;
|
|
|
17
17
|
* Get all registered plugins (internal use)
|
|
18
18
|
*/
|
|
19
19
|
export declare function getComponentPlugins(): readonly ComponentPlugin[];
|
|
20
|
+
/**
|
|
21
|
+
* Context extension system for adding properties to ComponentSetupContext
|
|
22
|
+
* Used by SSR, DevTools, and other packages that need to extend the context
|
|
23
|
+
*/
|
|
24
|
+
type ContextExtension = (ctx: any) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Register a function that will be called to extend every component context.
|
|
27
|
+
* Extensions are called in order of registration.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // In @sigx/server-renderer/client
|
|
32
|
+
* registerContextExtension((ctx) => {
|
|
33
|
+
* ctx.ssr = { load: () => {} };
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerContextExtension(extension: ContextExtension): void;
|
|
38
|
+
/**
|
|
39
|
+
* Apply all registered context extensions to a context object.
|
|
40
|
+
* Called internally by the renderer when creating component contexts.
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyContextExtensions(ctx: any): void;
|
|
43
|
+
export {};
|
|
20
44
|
//# sourceMappingURL=plugins.d.ts.map
|
package/dist/plugins.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CAChF,CAAC;AAIF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,eAAe,EAAE,CAEhE"}
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CAChF,CAAC;AAIF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAErE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,eAAe,EAAE,CAEhE;AAED;;;GAGG;AACH,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;AAG3C;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAE1E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAIrD"}
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import { JSXElement } from './jsx-runtime.js';
|
|
1
|
+
import { VNode, JSXElement } from './jsx-runtime.js';
|
|
2
|
+
import { EffectRunner } from '@sigx/reactivity';
|
|
3
|
+
import { SetupFn } from './component.js';
|
|
4
|
+
import { InternalSlotsObject } from './utils/slots.js';
|
|
2
5
|
import { AppContext } from './app.js';
|
|
6
|
+
/**
|
|
7
|
+
* Internal VNode with renderer-specific properties.
|
|
8
|
+
* These properties are used by the renderer to track component state
|
|
9
|
+
* but are not part of the public VNode API.
|
|
10
|
+
*/
|
|
11
|
+
export interface InternalVNode extends VNode {
|
|
12
|
+
/** The reactive effect that re-renders the component */
|
|
13
|
+
_effect?: EffectRunner;
|
|
14
|
+
/** The rendered sub-tree VNode of a component */
|
|
15
|
+
_subTree?: VNode;
|
|
16
|
+
/** The slots object for component children */
|
|
17
|
+
_slots?: InternalSlotsObject;
|
|
18
|
+
/** Reactive props signal for the component */
|
|
19
|
+
_componentProps?: Record<string, any>;
|
|
20
|
+
}
|
|
3
21
|
export interface RendererOptions<HostNode = any, HostElement = any> {
|
|
4
22
|
patchProp(el: HostElement, key: string, prevValue: any, nextValue: any, isSVG?: boolean): void;
|
|
5
23
|
insert(child: HostNode, parent: HostElement, anchor?: HostNode | null): void;
|
|
@@ -16,11 +34,26 @@ export interface RendererOptions<HostNode = any, HostElement = any> {
|
|
|
16
34
|
cloneNode?(node: HostNode): HostNode;
|
|
17
35
|
insertStaticContent?(content: string, parent: HostElement, anchor: HostNode | null, isSVG: boolean): [HostNode, HostNode];
|
|
18
36
|
}
|
|
19
|
-
export type RootRenderFunction<HostNode = any, HostElement = any> = (vnode: JSXElement, container: HostElement,
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
export type RootRenderFunction<HostNode = any, HostElement = any> = (vnode: JSXElement, container: HostElement, appContext?: AppContext) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Function types for renderer operations exposed for plugins/hydration
|
|
40
|
+
*/
|
|
41
|
+
export type RendererMountFn<HostNode = any, HostElement = any> = (vnode: VNode, container: HostElement, before?: HostNode | null) => void;
|
|
42
|
+
export type RendererUnmountFn<HostNode = any, HostElement = any> = (vnode: VNode, container: HostElement) => void;
|
|
43
|
+
export type RendererPatchFn<HostNode = any, HostElement = any> = (n1: VNode, n2: VNode, container: HostElement) => void;
|
|
44
|
+
export type RendererMountComponentFn<HostNode = any, HostElement = any> = (vnode: VNode, container: HostElement, before: HostNode | null, setup: SetupFn<any, any, any, any>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Renderer instance returned by createRenderer
|
|
47
|
+
*/
|
|
48
|
+
export interface Renderer<HostNode = any, HostElement = any> {
|
|
49
|
+
render: RootRenderFunction<HostNode, HostElement>;
|
|
50
|
+
patch: RendererPatchFn<HostNode, HostElement>;
|
|
51
|
+
mount: RendererMountFn<HostNode, HostElement>;
|
|
52
|
+
unmount: RendererUnmountFn<HostNode, HostElement>;
|
|
53
|
+
mountComponent: RendererMountComponentFn<HostNode, HostElement>;
|
|
22
54
|
createApp: (rootComponent: any) => {
|
|
23
|
-
mount(selectorOrContainer: string | HostElement)
|
|
55
|
+
mount: (selectorOrContainer: string | HostElement) => void;
|
|
24
56
|
};
|
|
25
|
-
}
|
|
57
|
+
}
|
|
58
|
+
export declare function createRenderer<HostNode = any, HostElement = any>(options: RendererOptions<HostNode, HostElement>): Renderer<HostNode, HostElement>;
|
|
26
59
|
//# sourceMappingURL=renderer.d.ts.map
|
package/dist/renderer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,UAAU,EAAQ,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAA2B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAoG,OAAO,EAAiB,MAAM,gBAAgB,CAAC;AAE1J,OAAO,EAAe,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EACH,UAAU,EAOb,MAAM,UAAU,CAAC;AAElB;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,KAAK;IACxC,wDAAwD;IACxD,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzC;AAyCD,MAAM,WAAW,eAAe,CAAC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,WAAW,CAAC,CAAC;IAC9C,KAAK,EAAE,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC9C,OAAO,EAAE,iBAAiB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAClD,cAAc,EAAE,wBAAwB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAChE,SAAS,EAAE,CAAC,aAAa,EAAE,GAAG,KAAK;QAAE,KAAK,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,WAAW,KAAK,IAAI,CAAA;KAAE,CAAC;CACrG;AAED,wBAAgB,cAAc,CAAC,QAAQ,GAAG,GAAG,EAAE,WAAW,GAAG,GAAG,EAC5D,OAAO,EAAE,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,GAChD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAynBjC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared component helpers used by both runtime-core renderer and server-renderer hydration.
|
|
3
|
+
* These are the canonical implementations - avoid duplication.
|
|
4
|
+
*/
|
|
5
|
+
import { VNode, JSXElement } from '../jsx-runtime.js';
|
|
6
|
+
import { PropsAccessor } from '../component.js';
|
|
7
|
+
/**
|
|
8
|
+
* Internal slots object with tracking properties
|
|
9
|
+
*/
|
|
10
|
+
export interface InternalSlotsObject {
|
|
11
|
+
default: () => any[];
|
|
12
|
+
_children: any;
|
|
13
|
+
_version: {
|
|
14
|
+
v: number;
|
|
15
|
+
};
|
|
16
|
+
_slotsFromProps: Record<string, any>;
|
|
17
|
+
_isPatching?: boolean;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a props accessor that can be called with defaults or accessed directly.
|
|
22
|
+
* After calling with defaults, direct property access uses those defaults.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createPropsAccessor<TProps extends Record<string, any>>(reactiveProps: TProps): PropsAccessor<TProps>;
|
|
25
|
+
/**
|
|
26
|
+
* Create slots object from children and slots prop.
|
|
27
|
+
* Uses a version signal to trigger re-renders when children change.
|
|
28
|
+
* Supports named slots via:
|
|
29
|
+
* - `slots` prop object (e.g., slots={{ header: () => <div>...</div> }})
|
|
30
|
+
* - `slot` prop on children (e.g., <div slot="header">...</div>)
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSlots(children: any, slotsFromProps?: Record<string, any>): InternalSlotsObject;
|
|
33
|
+
/**
|
|
34
|
+
* Normalize render result to a VNode (wrapping arrays in Fragment)
|
|
35
|
+
* Handles null, undefined, false, true by returning an empty Text node.
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeSubTree(result: JSXElement | JSXElement[] | null | undefined | boolean): VNode;
|
|
38
|
+
//# sourceMappingURL=component-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/component-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EAAe,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC;IACf,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAClE,aAAa,EAAE,MAAM,GACtB,aAAa,CAAC,MAAM,CAAC,CAmDvB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,mBAAmB,CAwEpG;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,CAmCtG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VNode normalization utilities.
|
|
3
|
+
* Converts render results into proper VNode structures.
|
|
4
|
+
*/
|
|
5
|
+
import { VNode, JSXElement } from '../jsx-runtime.js';
|
|
6
|
+
/**
|
|
7
|
+
* Normalize render result to a VNode (wrapping arrays in Fragment).
|
|
8
|
+
* Handles null, undefined, false, true by returning an empty Text node.
|
|
9
|
+
*
|
|
10
|
+
* This is used to normalize the return value of component render functions
|
|
11
|
+
* into a consistent VNode structure for the renderer to process.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Conditional rendering returns null/false
|
|
16
|
+
* normalizeSubTree(null) // → empty Text node
|
|
17
|
+
* normalizeSubTree(false) // → empty Text node
|
|
18
|
+
*
|
|
19
|
+
* // Arrays become Fragments
|
|
20
|
+
* normalizeSubTree([<A/>, <B/>]) // → Fragment with children
|
|
21
|
+
*
|
|
22
|
+
* // Primitives become Text nodes
|
|
23
|
+
* normalizeSubTree("hello") // → Text node
|
|
24
|
+
* normalizeSubTree(42) // → Text node
|
|
25
|
+
*
|
|
26
|
+
* // VNodes pass through
|
|
27
|
+
* normalizeSubTree(<div/>) // → same VNode
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeSubTree(result: JSXElement | JSXElement[] | null | undefined | boolean): VNode;
|
|
31
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAkB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,CAmCtG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props accessor for component setup functions.
|
|
3
|
+
* Provides a callable proxy that supports defaults and reactive property access.
|
|
4
|
+
*/
|
|
5
|
+
import { PropsAccessor } from '../component.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a props accessor that can be called with defaults or accessed directly.
|
|
8
|
+
* After calling with defaults, direct property access uses those defaults.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // In component setup:
|
|
13
|
+
* const props = createPropsAccessor(reactiveProps);
|
|
14
|
+
*
|
|
15
|
+
* // Set defaults
|
|
16
|
+
* props({ count: 0, label: 'Default' });
|
|
17
|
+
*
|
|
18
|
+
* // Access props (falls back to defaults if not provided)
|
|
19
|
+
* const count = props.count;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function createPropsAccessor<TProps extends Record<string, any>>(reactiveProps: TProps): PropsAccessor<TProps>;
|
|
23
|
+
//# sourceMappingURL=props-accessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props-accessor.d.ts","sourceRoot":"","sources":["../../src/utils/props-accessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAClE,aAAa,EAAE,MAAM,GACtB,aAAa,CAAC,MAAM,CAAC,CAmDvB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slots system for component children.
|
|
3
|
+
* Supports default and named slots with reactivity.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Internal slots object with tracking properties
|
|
7
|
+
*/
|
|
8
|
+
export interface InternalSlotsObject {
|
|
9
|
+
default: () => any[];
|
|
10
|
+
_children: any;
|
|
11
|
+
_version: {
|
|
12
|
+
v: number;
|
|
13
|
+
};
|
|
14
|
+
_slotsFromProps: Record<string, any>;
|
|
15
|
+
_isPatching?: boolean;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create slots object from children and slots prop.
|
|
20
|
+
* Uses a version signal to trigger re-renders when children change.
|
|
21
|
+
*
|
|
22
|
+
* Supports named slots via:
|
|
23
|
+
* - `slots` prop object (e.g., `slots={{ header: () => <div>...</div> }}`)
|
|
24
|
+
* - `slot` prop on children (e.g., `<div slot="header">...</div>`)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // Parent component
|
|
29
|
+
* <Card slots={{ header: () => <h1>Title</h1> }}>
|
|
30
|
+
* <p>Default content</p>
|
|
31
|
+
* <span slot="footer">Footer text</span>
|
|
32
|
+
* </Card>
|
|
33
|
+
*
|
|
34
|
+
* // Card component setup
|
|
35
|
+
* const slots = createSlots(children, slotsFromProps);
|
|
36
|
+
* return () => (
|
|
37
|
+
* <div>
|
|
38
|
+
* {slots.header()}
|
|
39
|
+
* {slots.default()}
|
|
40
|
+
* {slots.footer()}
|
|
41
|
+
* </div>
|
|
42
|
+
* );
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function createSlots(children: any, slotsFromProps?: Record<string, any>): InternalSlotsObject;
|
|
46
|
+
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../src/utils/slots.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC;IACf,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,mBAAmB,CAwEpG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/runtime-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Runtime core for SignalX",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"url": "https://github.com/signalxjs/core/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@sigx/reactivity": "^0.1.
|
|
40
|
+
"@sigx/reactivity": "^0.1.5"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^20.0.0",
|