@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 +21 -0
- package/dist/component.d.ts +62 -4
- package/dist/component.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +284 -40
- package/dist/index.js.map +1 -1
- package/dist/lazy.d.ts +99 -0
- package/dist/lazy.d.ts.map +1 -0
- package/dist/renderer.d.ts +31 -1
- package/dist/renderer.d.ts.map +1 -1
- package/package.json +51 -52
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/renderer.d.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
import { JSXElement } from './jsx-runtime.js';
|
|
1
|
+
import { VNode, JSXElement } from './jsx-runtime.js';
|
|
2
|
+
import { EffectRunner } from '@sigx/reactivity';
|
|
2
3
|
import { AppContext } from './app.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internal VNode with renderer-specific properties.
|
|
6
|
+
* These properties are used by the renderer to track component state
|
|
7
|
+
* but are not part of the public VNode API.
|
|
8
|
+
*/
|
|
9
|
+
export interface InternalVNode extends VNode {
|
|
10
|
+
/** The reactive effect that re-renders the component */
|
|
11
|
+
_effect?: EffectRunner;
|
|
12
|
+
/** The rendered sub-tree VNode of a component */
|
|
13
|
+
_subTree?: VNode;
|
|
14
|
+
/** The slots object for component children */
|
|
15
|
+
_slots?: InternalSlotsObject;
|
|
16
|
+
/** Reactive props signal for the component */
|
|
17
|
+
_componentProps?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Internal slots object with tracking properties
|
|
21
|
+
*/
|
|
22
|
+
interface InternalSlotsObject {
|
|
23
|
+
default: () => any[];
|
|
24
|
+
_children: any;
|
|
25
|
+
_version: {
|
|
26
|
+
v: number;
|
|
27
|
+
};
|
|
28
|
+
_slotsFromProps: Record<string, any>;
|
|
29
|
+
_isPatching?: boolean;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
3
32
|
export interface RendererOptions<HostNode = any, HostElement = any> {
|
|
4
33
|
patchProp(el: HostElement, key: string, prevValue: any, nextValue: any, isSVG?: boolean): void;
|
|
5
34
|
insert(child: HostNode, parent: HostElement, anchor?: HostNode | null): void;
|
|
@@ -23,4 +52,5 @@ export declare function createRenderer<HostNode = any, HostElement = any>(option
|
|
|
23
52
|
mount(selectorOrContainer: string | HostElement): void;
|
|
24
53
|
};
|
|
25
54
|
};
|
|
55
|
+
export {};
|
|
26
56
|
//# 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;AAEzE,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,M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
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@sigx/runtime-core",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Runtime core for SignalX",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./jsx-runtime": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"sigx",
|
|
23
|
+
"runtime",
|
|
24
|
+
"core",
|
|
25
|
+
"components",
|
|
26
|
+
"framework"
|
|
27
|
+
],
|
|
28
|
+
"author": "Andreas Ekdahl",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/signalxjs/core.git",
|
|
33
|
+
"directory": "packages/runtime-core"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/signalxjs",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/signalxjs/core/issues"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@sigx/reactivity": "^0.1.4"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
|
+
"rolldown": "^1.0.0-beta.52",
|
|
45
|
+
"typescript": "^5.9.3"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "rolldown -c && tsc --emitDeclarationOnly",
|
|
49
|
+
"dev": "rolldown -c -w"
|
|
50
|
+
}
|
|
51
|
+
}
|