@sigx/server-renderer 0.1.6 → 0.1.7
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/builtin-ssr-directives.d.ts +8 -0
- package/dist/builtin-ssr-directives.d.ts.map +1 -0
- package/dist/client/hydrate-component.d.ts +32 -0
- package/dist/client/hydrate-component.d.ts.map +1 -0
- package/dist/client/hydrate-context.d.ts +54 -0
- package/dist/client/hydrate-context.d.ts.map +1 -0
- package/dist/client/hydrate-core.d.ts +33 -0
- package/dist/client/hydrate-core.d.ts.map +1 -0
- package/dist/client/index.d.ts +8 -4
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client-directives.d.ts +3 -36
- package/dist/client-directives.d.ts.map +1 -1
- package/dist/client-ggDL-Wx2.js +309 -0
- package/dist/client-ggDL-Wx2.js.map +1 -0
- package/dist/directive-ssr-types.d.ts +23 -0
- package/dist/directive-ssr-types.d.ts.map +1 -0
- package/dist/head.d.ts +97 -0
- package/dist/head.d.ts.map +1 -0
- package/dist/index.d.ts +22 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +124 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/server/context.d.ts +52 -59
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/index.d.ts +9 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -2
- package/dist/server/render-api.d.ts +64 -0
- package/dist/server/render-api.d.ts.map +1 -0
- package/dist/server/render-core.d.ts +46 -0
- package/dist/server/render-core.d.ts.map +1 -0
- package/dist/server/streaming.d.ts +24 -0
- package/dist/server/streaming.d.ts.map +1 -0
- package/dist/server/types.d.ts +40 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server-UBcHtkm-.js +829 -0
- package/dist/server-UBcHtkm-.js.map +1 -0
- package/dist/ssr.d.ts +38 -0
- package/dist/ssr.d.ts.map +1 -0
- package/dist/types-B4Rf1Xot.js +6 -0
- package/dist/types-B4Rf1Xot.js.map +1 -0
- package/package.json +5 -10
- package/dist/client/hydrate.d.ts +0 -24
- package/dist/client/hydrate.d.ts.map +0 -1
- package/dist/client/registry.d.ts +0 -54
- package/dist/client/registry.d.ts.map +0 -1
- package/dist/client/types.d.ts +0 -23
- package/dist/client/types.d.ts.map +0 -1
- package/dist/client-DiLwBAD-.js +0 -541
- package/dist/client-DiLwBAD-.js.map +0 -1
- package/dist/server/stream.d.ts +0 -62
- package/dist/server/stream.d.ts.map +0 -1
- package/dist/server-BCOJt2Bi.js +0 -459
- package/dist/server-BCOJt2Bi.js.map +0 -1
- package/dist/shared/utils.d.ts +0 -9
- package/dist/shared/utils.d.ts.map +0 -1
- package/src/jsx.d.ts +0 -62
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core rendering logic for SSR
|
|
3
|
+
*
|
|
4
|
+
* The async generator `renderToChunks` walks a VNode tree and yields HTML strings.
|
|
5
|
+
* Handles text, fragments, host elements, and delegates components to the
|
|
6
|
+
* component renderer.
|
|
7
|
+
*
|
|
8
|
+
* This module is strategy-agnostic. Island-specific logic (signal tracking,
|
|
9
|
+
* hydration directives, async streaming) lives in @sigx/ssr-islands and is
|
|
10
|
+
* injected through the SSRPlugin hooks.
|
|
11
|
+
*/
|
|
12
|
+
import { JSXElement, ComponentSetupContext } from 'sigx';
|
|
13
|
+
import type { AppContext } from 'sigx';
|
|
14
|
+
import type { SSRContext } from './context';
|
|
15
|
+
export declare function escapeHtml(s: string): string;
|
|
16
|
+
export declare function camelToKebab(str: string): string;
|
|
17
|
+
export declare function parseStringStyle(cssText: string): Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Serialize a style object to a CSS string.
|
|
20
|
+
*
|
|
21
|
+
* Uses for...in + string concat (avoids Object.entries/map/join allocations)
|
|
22
|
+
* and cached kebab-case conversion.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stringifyStyle(style: Record<string, any>): string;
|
|
25
|
+
/**
|
|
26
|
+
* Render element to string chunks (generator for streaming)
|
|
27
|
+
* @param element - The JSX element to render
|
|
28
|
+
* @param ctx - The SSR context for tracking state
|
|
29
|
+
* @param parentCtx - The parent component context for provide/inject
|
|
30
|
+
* @param appContext - The app context for app-level provides (from defineApp)
|
|
31
|
+
*/
|
|
32
|
+
export declare function renderToChunks(element: JSXElement, ctx: SSRContext, parentCtx?: ComponentSetupContext | null, appContext?: AppContext | null): AsyncGenerator<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Helper to render a VNode to string (for deferred async content)
|
|
35
|
+
*/
|
|
36
|
+
export declare function renderVNodeToString(element: JSXElement, ctx: SSRContext, appContext?: AppContext | null): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Synchronous render-to-string that avoids async generator overhead.
|
|
39
|
+
* Returns null if any async operation is encountered (caller should fall back
|
|
40
|
+
* to the async generator path).
|
|
41
|
+
*
|
|
42
|
+
* For purely synchronous component trees this eliminates thousands of
|
|
43
|
+
* microtask/Promise allocations from the AsyncGenerator protocol.
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderToStringSync(element: JSXElement, ctx: SSRContext, parentCtx: ComponentSetupContext | null, appContext: AppContext | null, buf: string[]): boolean;
|
|
46
|
+
//# sourceMappingURL=render-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-core.d.ts","sourceRoot":"","sources":["../../src/server/render-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGH,UAAU,EACV,qBAAqB,EASxB,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAY5C,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAQD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAiBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcxE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CASjE;AA4BD;;;;;;GAMG;AACH,wBAAuB,cAAc,CACjC,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,UAAU,EACf,SAAS,GAAE,qBAAqB,GAAG,IAAW,EAC9C,UAAU,GAAE,UAAU,GAAG,IAAW,GACrC,cAAc,CAAC,MAAM,CAAC,CAiWxB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,GAAE,UAAU,GAAG,IAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAMrI;AAID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,qBAAqB,GAAG,IAAI,EACvC,UAAU,EAAE,UAAU,GAAG,IAAI,EAC7B,GAAG,EAAE,MAAM,EAAE,GACd,OAAO,CAmQT"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core streaming utilities for async SSR
|
|
3
|
+
*
|
|
4
|
+
* Provides the client-side `$SIGX_REPLACE` function and replacement script
|
|
5
|
+
* generation used by core async streaming. These are strategy-agnostic —
|
|
6
|
+
* any async component with `ssr.load()` gets streamed without needing a plugin.
|
|
7
|
+
*
|
|
8
|
+
* Plugins (e.g., islands) can augment replacements via `onAsyncComponentResolved`.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Escape a JSON string for safe embedding inside <script> tags.
|
|
12
|
+
* Prevents XSS by replacing characters that could break out of the script context.
|
|
13
|
+
*/
|
|
14
|
+
export declare function escapeJsonForScript(json: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Generate the streaming bootstrap script (injected once before any replacements).
|
|
17
|
+
* Defines `window.$SIGX_REPLACE` which swaps async placeholders with rendered HTML.
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateStreamingScript(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Generate a replacement script for a resolved async component.
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateReplacementScript(id: number, html: string, extraScript?: string): string;
|
|
24
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/server/streaming.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAgBhD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAQhG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for server rendering APIs.
|
|
3
|
+
*
|
|
4
|
+
* Kept separate to avoid circular imports between ssr.ts and render-api.ts.
|
|
5
|
+
*/
|
|
6
|
+
import type { Signal, PrimitiveSignal, Primitive } from 'sigx';
|
|
7
|
+
/**
|
|
8
|
+
* SSR-enhanced signal function type.
|
|
9
|
+
* Extends the base signal() with an optional `name` parameter used as the
|
|
10
|
+
* serialization key for hydration state transfer.
|
|
11
|
+
*
|
|
12
|
+
* Both `createTrackingSignal` (server/islands) and `createRestoringSignal` (client/hydration)
|
|
13
|
+
* use this type and share the same key-generation contract via `generateSignalKey`.
|
|
14
|
+
*/
|
|
15
|
+
export type SSRSignalFn = {
|
|
16
|
+
<T extends Primitive>(initial: T, name?: string): PrimitiveSignal<T>;
|
|
17
|
+
<T extends object>(initial: T, name?: string): Signal<T>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Generate a stable key for a signal during SSR state tracking/restoration.
|
|
21
|
+
*
|
|
22
|
+
* Named signals use the provided name; unnamed signals use a positional key (`$0`, `$1`, ...).
|
|
23
|
+
* Both server-side tracking (`createTrackingSignal`) and client-side restoration
|
|
24
|
+
* (`createRestoringSignal`) MUST use this function to guarantee key parity.
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateSignalKey(name: string | undefined, index: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* Streaming callbacks interface
|
|
29
|
+
*/
|
|
30
|
+
export interface StreamCallbacks {
|
|
31
|
+
/** Called when the initial shell (synchronous content) is ready */
|
|
32
|
+
onShellReady: (html: string) => void;
|
|
33
|
+
/** Called for each async chunk (replacement scripts, hydration data) */
|
|
34
|
+
onAsyncChunk: (chunk: string) => void;
|
|
35
|
+
/** Called when all streaming is complete */
|
|
36
|
+
onComplete: () => void;
|
|
37
|
+
/** Called on error */
|
|
38
|
+
onError: (error: Error) => void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,mEAAmE;IACnE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,wEAAwE;IACxE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,4CAA4C;IAC5C,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,sBAAsB;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnC"}
|