@sigx/server-renderer 0.1.4 → 0.1.6
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/client/hydrate.d.ts +24 -0
- package/dist/client/hydrate.d.ts.map +1 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +2 -0
- package/dist/client/plugin.d.ts +52 -0
- package/dist/client/plugin.d.ts.map +1 -0
- package/dist/client/registry.d.ts +54 -0
- package/dist/client/registry.d.ts.map +1 -0
- package/dist/client/types.d.ts +23 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client-DiLwBAD-.js +541 -0
- package/dist/client-DiLwBAD-.js.map +1 -0
- package/dist/client-directives.d.ts +96 -0
- package/dist/client-directives.d.ts.map +1 -0
- package/dist/index.d.ts +47 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -133
- package/dist/server/context.d.ts +118 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/stream.d.ts +62 -0
- package/dist/server/stream.d.ts.map +1 -0
- package/dist/server-BCOJt2Bi.js +459 -0
- package/dist/server-BCOJt2Bi.js.map +1 -0
- package/dist/shared/utils.d.ts +9 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/package.json +24 -10
- package/src/jsx.d.ts +62 -0
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side hydration for SSR'd content
|
|
3
|
+
*
|
|
4
|
+
* Hydration attaches the app to existing server-rendered DOM,
|
|
5
|
+
* then delegates all updates to the runtime-dom renderer.
|
|
6
|
+
*/
|
|
7
|
+
import { AppContext } from 'sigx';
|
|
8
|
+
export type { HydrationOptions } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Hydrate a server-rendered app.
|
|
11
|
+
*
|
|
12
|
+
* This walks the existing DOM to attach event handlers, runs component
|
|
13
|
+
* setup functions to establish reactivity, then uses runtime-dom for updates.
|
|
14
|
+
*
|
|
15
|
+
* @param element - The root element/VNode to hydrate
|
|
16
|
+
* @param container - The DOM container with SSR content
|
|
17
|
+
* @param appContext - The app context for DI (provides, etc.)
|
|
18
|
+
*/
|
|
19
|
+
export declare function hydrate(element: any, container: Element, appContext?: AppContext): void;
|
|
20
|
+
/**
|
|
21
|
+
* Hydrate islands based on their strategies (selective hydration)
|
|
22
|
+
*/
|
|
23
|
+
export declare function hydrateIslands(): void;
|
|
24
|
+
//# sourceMappingURL=hydrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../../src/client/hydrate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAuBH,UAAU,EAEb,MAAM,MAAM,CAAC;AAKd,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA0FnD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAYvF;AA+gBD;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAkBrC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sigx/server-renderer/client
|
|
3
|
+
*
|
|
4
|
+
* Client-side hydration with selective/islands hydration support.
|
|
5
|
+
*/
|
|
6
|
+
import '../client-directives.js';
|
|
7
|
+
export { ssrClientPlugin, type HydrateFn } from './plugin.js';
|
|
8
|
+
export { hydrateIslands } from './hydrate.js';
|
|
9
|
+
export { HydrationRegistry, registerComponent } from './registry.js';
|
|
10
|
+
export type { HydrationOptions } from './types.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGrE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR Client Plugin
|
|
3
|
+
*
|
|
4
|
+
* Provides app.hydrate() method for client-side hydration of server-rendered HTML.
|
|
5
|
+
* This plugin follows the same pattern as the router plugin.
|
|
6
|
+
*/
|
|
7
|
+
import type { Plugin, AppContext } from '@sigx/runtime-core';
|
|
8
|
+
/**
|
|
9
|
+
* Hydrate function signature - matches MountFn pattern
|
|
10
|
+
*/
|
|
11
|
+
export type HydrateFn<TContainer = any> = (element: any, container: TContainer, appContext: AppContext) => (() => void) | void;
|
|
12
|
+
declare module '@sigx/runtime-core' {
|
|
13
|
+
interface App<TContainer = any> {
|
|
14
|
+
/**
|
|
15
|
+
* Hydrate the app from server-rendered HTML.
|
|
16
|
+
*
|
|
17
|
+
* Unlike mount() which creates new DOM, hydrate() attaches to existing
|
|
18
|
+
* server-rendered DOM, adding event handlers and establishing reactivity.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { defineApp } from 'sigx';
|
|
23
|
+
* import { ssrClientPlugin } from '@sigx/server-renderer/client';
|
|
24
|
+
*
|
|
25
|
+
* const app = defineApp(<App />);
|
|
26
|
+
* app.use(router)
|
|
27
|
+
* .use(ssrClientPlugin)
|
|
28
|
+
* .hydrate(document.getElementById('app')!);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
hydrate(container: TContainer): App<TContainer>;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* SSR Client Plugin
|
|
36
|
+
*
|
|
37
|
+
* Adds the hydrate() method to the app instance for client-side hydration.
|
|
38
|
+
* Also registers the SSR context extension for all components.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { defineApp } from 'sigx';
|
|
43
|
+
* import { ssrClientPlugin } from '@sigx/server-renderer/client';
|
|
44
|
+
*
|
|
45
|
+
* const app = defineApp(<App />);
|
|
46
|
+
* app.use(ssrClientPlugin)
|
|
47
|
+
* .use(router)
|
|
48
|
+
* .hydrate('#app');
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const ssrClientPlugin: Plugin;
|
|
52
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/client/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAO,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQlE;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,UAAU,GAAG,GAAG,IAAI,CACtC,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,UAAU,KACrB,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;AAEzB,OAAO,QAAQ,oBAAoB,CAAC;IAChC,UAAU,GAAG,CAAC,UAAU,GAAG,GAAG;QAC1B;;;;;;;;;;;;;;;;WAgBG;QACH,OAAO,CAAC,SAAS,EAAE,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;KACnD;CACJ;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,EAAE,MAmD7B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Registry for Island Hydration
|
|
3
|
+
*
|
|
4
|
+
* Components must be registered before they can be hydrated as islands.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Minimal type for component factories used in hydration registry.
|
|
8
|
+
* Compatible with ComponentFactory from runtime-core.
|
|
9
|
+
*/
|
|
10
|
+
export interface ComponentFactory {
|
|
11
|
+
__setup: Function;
|
|
12
|
+
__name?: string;
|
|
13
|
+
__async?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Register a component for island hydration.
|
|
17
|
+
* Components must be registered before hydrateIslands() is called.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { registerComponent } from '@sigx/server-renderer/client';
|
|
22
|
+
* import { Counter } from './components/Counter';
|
|
23
|
+
*
|
|
24
|
+
* registerComponent('Counter', Counter);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerComponent(name: string, component: ComponentFactory): void;
|
|
28
|
+
/**
|
|
29
|
+
* Register multiple components at once
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { registerComponents } from '@sigx/server-renderer/client';
|
|
34
|
+
* import * as Components from './components';
|
|
35
|
+
*
|
|
36
|
+
* registerComponents(Components);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function registerComponents(components: Record<string, ComponentFactory>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get a registered component by name
|
|
42
|
+
*/
|
|
43
|
+
export declare function getComponent(name: string): ComponentFactory | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Hydration Registry class for more advanced use cases
|
|
46
|
+
*/
|
|
47
|
+
export declare class HydrationRegistry {
|
|
48
|
+
private components;
|
|
49
|
+
register(name: string, component: ComponentFactory): this;
|
|
50
|
+
registerAll(components: Record<string, ComponentFactory>): this;
|
|
51
|
+
get(name: string): ComponentFactory | undefined;
|
|
52
|
+
has(name: string): boolean;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/client/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAOD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAEjF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,IAAI,CAMrF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAEvE;AAID;;GAEG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,UAAU,CAAuC;IAEzD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAKzD,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,IAAI;IAS/D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI/C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAG7B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for client-side hydration
|
|
3
|
+
*/
|
|
4
|
+
export type { VNode } from 'sigx';
|
|
5
|
+
/**
|
|
6
|
+
* Hydration options
|
|
7
|
+
*/
|
|
8
|
+
export interface HydrationOptions {
|
|
9
|
+
recover?: boolean;
|
|
10
|
+
onMismatch?: (message: string, node: Node | null, vnode: any) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Island information serialized from server
|
|
14
|
+
*/
|
|
15
|
+
export interface IslandInfo {
|
|
16
|
+
strategy: 'load' | 'idle' | 'visible' | 'media' | 'only';
|
|
17
|
+
media?: string;
|
|
18
|
+
props?: Record<string, any>;
|
|
19
|
+
componentId?: string;
|
|
20
|
+
/** Captured signal state from async setup for client hydration */
|
|
21
|
+
state?: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACzE;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B"}
|