@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.
Files changed (60) hide show
  1. package/dist/builtin-ssr-directives.d.ts +8 -0
  2. package/dist/builtin-ssr-directives.d.ts.map +1 -0
  3. package/dist/client/hydrate-component.d.ts +32 -0
  4. package/dist/client/hydrate-component.d.ts.map +1 -0
  5. package/dist/client/hydrate-context.d.ts +54 -0
  6. package/dist/client/hydrate-context.d.ts.map +1 -0
  7. package/dist/client/hydrate-core.d.ts +33 -0
  8. package/dist/client/hydrate-core.d.ts.map +1 -0
  9. package/dist/client/index.d.ts +8 -4
  10. package/dist/client/index.d.ts.map +1 -1
  11. package/dist/client/index.js +2 -2
  12. package/dist/client-directives.d.ts +3 -36
  13. package/dist/client-directives.d.ts.map +1 -1
  14. package/dist/client-ggDL-Wx2.js +309 -0
  15. package/dist/client-ggDL-Wx2.js.map +1 -0
  16. package/dist/directive-ssr-types.d.ts +23 -0
  17. package/dist/directive-ssr-types.d.ts.map +1 -0
  18. package/dist/head.d.ts +97 -0
  19. package/dist/head.d.ts.map +1 -0
  20. package/dist/index.d.ts +22 -18
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +7 -3
  23. package/dist/index.js.map +1 -0
  24. package/dist/plugin.d.ts +124 -0
  25. package/dist/plugin.d.ts.map +1 -0
  26. package/dist/server/context.d.ts +52 -59
  27. package/dist/server/context.d.ts.map +1 -1
  28. package/dist/server/index.d.ts +9 -4
  29. package/dist/server/index.d.ts.map +1 -1
  30. package/dist/server/index.js +3 -2
  31. package/dist/server/render-api.d.ts +64 -0
  32. package/dist/server/render-api.d.ts.map +1 -0
  33. package/dist/server/render-core.d.ts +46 -0
  34. package/dist/server/render-core.d.ts.map +1 -0
  35. package/dist/server/streaming.d.ts +24 -0
  36. package/dist/server/streaming.d.ts.map +1 -0
  37. package/dist/server/types.d.ts +40 -0
  38. package/dist/server/types.d.ts.map +1 -0
  39. package/dist/server-UBcHtkm-.js +829 -0
  40. package/dist/server-UBcHtkm-.js.map +1 -0
  41. package/dist/ssr.d.ts +38 -0
  42. package/dist/ssr.d.ts.map +1 -0
  43. package/dist/types-B4Rf1Xot.js +6 -0
  44. package/dist/types-B4Rf1Xot.js.map +1 -0
  45. package/package.json +5 -10
  46. package/dist/client/hydrate.d.ts +0 -24
  47. package/dist/client/hydrate.d.ts.map +0 -1
  48. package/dist/client/registry.d.ts +0 -54
  49. package/dist/client/registry.d.ts.map +0 -1
  50. package/dist/client/types.d.ts +0 -23
  51. package/dist/client/types.d.ts.map +0 -1
  52. package/dist/client-DiLwBAD-.js +0 -541
  53. package/dist/client-DiLwBAD-.js.map +0 -1
  54. package/dist/server/stream.d.ts +0 -62
  55. package/dist/server/stream.d.ts.map +0 -1
  56. package/dist/server-BCOJt2Bi.js +0 -459
  57. package/dist/server-BCOJt2Bi.js.map +0 -1
  58. package/dist/shared/utils.d.ts +0 -9
  59. package/dist/shared/utils.d.ts.map +0 -1
  60. package/src/jsx.d.ts +0 -62
@@ -0,0 +1,23 @@
1
+ /**
2
+ * SSR directive type augmentation.
3
+ *
4
+ * When `@sigx/server-renderer` is imported, directives gain the `getSSRProps` hook.
5
+ * This keeps `@sigx/runtime-core` and `@sigx/runtime-dom` free of SSR knowledge —
6
+ * the SSR layer owns this extension.
7
+ *
8
+ * Uses TypeScript module augmentation on `DirectiveDefinitionExtensions` which
9
+ * is the designated extension point in `@sigx/runtime-core`.
10
+ */
11
+ import type { DirectiveBinding } from '@sigx/runtime-core';
12
+ declare module '@sigx/runtime-core' {
13
+ interface DirectiveDefinitionExtensions<T> {
14
+ /**
15
+ * Called during SSR to produce props that should be merged into the element's HTML.
16
+ * Return an object with keys like `style`, `class`, or any attribute.
17
+ *
18
+ * This hook is ONLY available when `@sigx/server-renderer` is in the project.
19
+ */
20
+ getSSRProps?(binding: DirectiveBinding<T>): Record<string, any> | void;
21
+ }
22
+ }
23
+ //# sourceMappingURL=directive-ssr-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive-ssr-types.d.ts","sourceRoot":"","sources":["../src/directive-ssr-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,QAAQ,oBAAoB,CAAC;IAChC,UAAU,6BAA6B,CAAC,CAAC;QACrC;;;;;WAKG;QACH,WAAW,CAAC,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;KAC1E;CACJ"}
package/dist/head.d.ts ADDED
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Head management composable for SSR and client-side.
3
+ *
4
+ * Provides `useHead()` for managing `<head>` elements (title, meta, link, script)
5
+ * from within components. Works during SSR (collects into SSRContext._head) and
6
+ * on the client (updates DOM directly).
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import { useHead } from '@sigx/server-renderer/head';
11
+ *
12
+ * function MyPage(ctx) {
13
+ * useHead({
14
+ * title: 'My Page',
15
+ * meta: [
16
+ * { name: 'description', content: 'A great page' },
17
+ * { property: 'og:title', content: 'My Page' }
18
+ * ],
19
+ * link: [
20
+ * { rel: 'canonical', href: 'https://example.com/my-page' }
21
+ * ]
22
+ * });
23
+ *
24
+ * return () => <div>Page content</div>;
25
+ * }
26
+ * ```
27
+ */
28
+ export interface HeadMeta {
29
+ name?: string;
30
+ property?: string;
31
+ 'http-equiv'?: string;
32
+ charset?: string;
33
+ content?: string;
34
+ [key: string]: string | undefined;
35
+ }
36
+ export interface HeadLink {
37
+ rel: string;
38
+ href?: string;
39
+ type?: string;
40
+ crossorigin?: string;
41
+ [key: string]: string | undefined;
42
+ }
43
+ export interface HeadScript {
44
+ src?: string;
45
+ type?: string;
46
+ async?: boolean;
47
+ defer?: boolean;
48
+ innerHTML?: string;
49
+ [key: string]: string | boolean | undefined;
50
+ }
51
+ export interface HeadConfig {
52
+ /** Page title */
53
+ title?: string;
54
+ /** Title template — use %s as placeholder for the title */
55
+ titleTemplate?: string;
56
+ /** Meta tags */
57
+ meta?: HeadMeta[];
58
+ /** Link tags */
59
+ link?: HeadLink[];
60
+ /** Script tags */
61
+ script?: HeadScript[];
62
+ /** HTML language attribute */
63
+ htmlAttrs?: {
64
+ lang?: string;
65
+ dir?: string;
66
+ [key: string]: string | undefined;
67
+ };
68
+ /** Body attributes */
69
+ bodyAttrs?: {
70
+ class?: string;
71
+ [key: string]: string | undefined;
72
+ };
73
+ }
74
+ /**
75
+ * Enable SSR mode for head management.
76
+ * Called by the SSR renderer before rendering starts.
77
+ */
78
+ export declare function enableSSRHead(): void;
79
+ /**
80
+ * Disable SSR mode and return collected configs.
81
+ */
82
+ export declare function collectSSRHead(): HeadConfig[];
83
+ /**
84
+ * Render collected head configs to an HTML string.
85
+ * Deduplicates meta tags by name/property and uses the last title.
86
+ */
87
+ export declare function renderHeadToString(configs: HeadConfig[]): string;
88
+ /**
89
+ * Manage `<head>` elements from within a component.
90
+ *
91
+ * During SSR, collects head configs for later rendering with `renderHeadToString()`.
92
+ * On the client, updates the DOM directly. Cleans up on component unmount.
93
+ *
94
+ * @param config - Head configuration (title, meta, link, script, etc.)
95
+ */
96
+ export declare function useHead(config: HeadConfig): void;
97
+ //# sourceMappingURL=head.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../src/head.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,MAAM,WAAW,QAAQ;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM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AED;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,EAAE,CAK7C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAmFhE;AA0FD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAehD"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * @sigx/server-renderer
3
3
  *
4
4
  * Server-side rendering and client-side hydration for SigX applications.
5
+ * Strategy-agnostic core — extend with plugins for islands, resumable SSR, etc.
5
6
  *
6
7
  * ## Server Usage
7
8
  * ```ts
@@ -14,6 +15,15 @@
14
15
  * const html = await renderToString(<App />);
15
16
  * ```
16
17
  *
18
+ * ## Plugin-driven rendering (recommended for islands, async, etc.)
19
+ * ```ts
20
+ * import { createSSR } from '@sigx/server-renderer';
21
+ * import { islandsPlugin } from '@sigx/ssr-islands';
22
+ *
23
+ * const ssr = createSSR().use(islandsPlugin());
24
+ * const html = await ssr.render(<App />);
25
+ * ```
26
+ *
17
27
  * ## Client Usage
18
28
  * ```ts
19
29
  * import { defineApp } from 'sigx';
@@ -24,25 +34,19 @@
24
34
  * .hydrate('#root');
25
35
  * ```
26
36
  *
27
- * ## Selective Hydration (Islands)
28
- * ```tsx
29
- * // Enable JSX types for client directives
30
- * import '@sigx/server-renderer/jsx';
31
- *
32
- * // Use directives on components
33
- * <Counter client:visible /> // Hydrate when visible
34
- * <Widget client:idle /> // Hydrate during idle time
35
- * <Modal client:load /> // Hydrate immediately
36
- * <Sidebar client:media="(min-width: 768px)" /> // Hydrate on media match
37
- * <Map client:only /> // Client-only, no SSR
38
- * ```
39
- *
40
37
  * @module
41
38
  */
42
- export { renderToStream, renderToString } from './server/index.js';
39
+ import './directive-ssr-types.js';
40
+ export { createSSR } from './ssr.js';
41
+ export type { SSRInstance } from './ssr.js';
42
+ export type { SSRPlugin } from './plugin.js';
43
+ export { renderToStream, renderToString, renderVNodeToString } from './server/index.js';
43
44
  export { createSSRContext } from './server/context.js';
44
- export type { SSRContext, SSRContextOptions, RenderOptions, IslandInfo, HydrationStrategy } from './server/context.js';
45
- export { ssrClientPlugin, hydrateIslands } from './client/index.js';
46
- export { registerComponent, registerComponents, HydrationRegistry } from './client/registry.js';
47
- export type { HydrationOptions } from './client/types.js';
45
+ export type { SSRContext, SSRContextOptions, RenderOptions, CorePendingAsync } from './server/context.js';
46
+ export { ssrClientPlugin } from './client/index.js';
47
+ export type { SSRHelper } from './client-directives.js';
48
+ export type { SSRSignalFn } from './server/types.js';
49
+ export { generateSignalKey } from './server/types.js';
50
+ export { useHead, renderHeadToString, enableSSRHead, collectSSRHead } from './head.js';
51
+ export type { HeadConfig, HeadMeta, HeadLink, HeadScript } from './head.js';
48
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGvH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAChG,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,0BAA0B,CAAC;AAOlC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG1G,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACvF,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
- import { i as createSSRContext, r as renderToString, t as renderToStream } from "./server-BCOJt2Bi.js";
2
- import { a as registerComponents, i as registerComponent, n as hydrateIslands, r as HydrationRegistry, t as ssrClientPlugin } from "./client-DiLwBAD-.js";
3
- export { HydrationRegistry, createSSRContext, hydrateIslands, registerComponent, registerComponents, renderToStream, renderToString, ssrClientPlugin };
1
+ import { a as collectSSRHead, c as useHead, f as renderVNodeToString, i as createSSR, m as initDirectivesForSSR, o as enableSSRHead, p as createSSRContext, r as renderToString, s as renderHeadToString, t as renderToStream } from "./server-UBcHtkm-.js";
2
+ import { t as generateSignalKey } from "./types-B4Rf1Xot.js";
3
+ import { t as ssrClientPlugin } from "./client-ggDL-Wx2.js";
4
+ initDirectivesForSSR();
5
+ export { collectSSRHead, createSSR, createSSRContext, enableSSRHead, generateSignalKey, renderHeadToString, renderToStream, renderToString, renderVNodeToString, ssrClientPlugin, useHead };
6
+
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\r\n * @sigx/server-renderer\r\n * \r\n * Server-side rendering and client-side hydration for SigX applications.\r\n * Strategy-agnostic core — extend with plugins for islands, resumable SSR, etc.\r\n * \r\n * ## Server Usage\r\n * ```ts\r\n * import { renderToStream, renderToString } from '@sigx/server-renderer/server';\r\n * \r\n * // Streaming (recommended)\r\n * const stream = renderToStream(<App />);\r\n * \r\n * // Or string\r\n * const html = await renderToString(<App />);\r\n * ```\r\n * \r\n * ## Plugin-driven rendering (recommended for islands, async, etc.)\r\n * ```ts\r\n * import { createSSR } from '@sigx/server-renderer';\r\n * import { islandsPlugin } from '@sigx/ssr-islands';\r\n * \r\n * const ssr = createSSR().use(islandsPlugin());\r\n * const html = await ssr.render(<App />);\r\n * ```\r\n * \r\n * ## Client Usage\r\n * ```ts\r\n * import { defineApp } from 'sigx';\r\n * import { ssrClientPlugin } from '@sigx/server-renderer/client';\r\n * \r\n * defineApp(<App />)\r\n * .use(ssrClientPlugin)\r\n * .hydrate('#root');\r\n * ```\r\n * \r\n * @module\r\n */\r\n\r\n// SSR directive type augmentation — adds getSSRProps to DirectiveDefinition\r\nimport './directive-ssr-types.js';\r\n\r\n// Patch getSSRProps onto built-in directives (show, etc.)\r\nimport { initDirectivesForSSR } from './builtin-ssr-directives.js';\r\ninitDirectivesForSSR();\r\n\r\n// Plugin system\r\nexport { createSSR } from './ssr.js';\r\nexport type { SSRInstance } from './ssr.js';\r\nexport type { SSRPlugin } from './plugin.js';\r\n\r\n// Re-export from server (convenience)\r\nexport { renderToStream, renderToString, renderVNodeToString } from './server/index.js';\r\nexport { createSSRContext } from './server/context.js';\r\nexport type { SSRContext, SSRContextOptions, RenderOptions, CorePendingAsync } from './server/context.js';\r\n\r\n// Re-export from client (convenience)\r\nexport { ssrClientPlugin } from './client/index.js';\r\n\r\n// SSR types (shared across server-renderer and plugins)\r\nexport type { SSRHelper } from './client-directives.js';\r\nexport type { SSRSignalFn } from './server/types.js';\r\nexport { generateSignalKey } from './server/types.js';\r\n\r\n// Head management\r\nexport { useHead, renderHeadToString, enableSSRHead, collectSSRHead } from './head.js';\r\nexport type { HeadConfig, HeadMeta, HeadLink, HeadScript } from './head.js';\r\n"],"mappings":";;;AA4CA,sBAAsB"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * SSR Plugin Interface
3
+ *
4
+ * Defines a generic, strategy-agnostic extension point for server-side rendering.
5
+ * Plugins can control component context creation, async behavior, HTML injection,
6
+ * and client-side hydration — enabling islands, resumable SSR, streaming Suspense,
7
+ * progressive enhancement, or any future strategy without core changes.
8
+ */
9
+ import type { VNode, ComponentSetupContext } from 'sigx';
10
+ import type { SSRContext } from './server/context';
11
+ /**
12
+ * SSR Plugin interface for extending server rendering and client hydration.
13
+ *
14
+ * ## Supported Strategies
15
+ *
16
+ * - **Islands** (`@sigx/ssr-islands`): selective hydration via `client:*` directives
17
+ * - **Resumable**: serialize all signals + event handlers; no hydration walk
18
+ * - **Streaming Suspense**: async boundaries with fallback UI, out-of-order streaming
19
+ * - **Progressive Enhancement**: server-rendered forms/links work without JS
20
+ */
21
+ export interface SSRPlugin {
22
+ /** Unique plugin name */
23
+ name: string;
24
+ /** Server-side hooks (run during renderToString / renderToStream) */
25
+ server?: {
26
+ /**
27
+ * Called once before rendering starts.
28
+ * Use to initialize plugin-specific data via `ctx.setPluginData()`.
29
+ */
30
+ setup?(ctx: SSRContext): void;
31
+ /**
32
+ * Called after ComponentSetupContext is constructed but BEFORE setup() runs.
33
+ * Plugin can mutate or replace the context — swap signal fn, modify ssr helper,
34
+ * filter/transform props, add metadata.
35
+ *
36
+ * Return a new context to replace the default, or void to accept as-is.
37
+ *
38
+ * @example Islands plugin swaps `ctx.signal` with a tracking variant
39
+ * @example Resumable plugin wraps ALL signals with serializing proxies
40
+ */
41
+ transformComponentContext?(ctx: SSRContext, vnode: VNode, componentCtx: ComponentSetupContext): ComponentSetupContext | void;
42
+ /**
43
+ * Called after a component renders. Receives the accumulated HTML string.
44
+ * Can transform it (e.g., wrap with markers, inject attributes).
45
+ * Return a string to replace, or void to pass through.
46
+ */
47
+ afterRenderComponent?(id: number, vnode: VNode, html: string, ctx: SSRContext): string | void;
48
+ /**
49
+ * Called when a component has pending `ssr.load()` calls.
50
+ * Plugin decides the async model:
51
+ * - `'block'`: wait inline (overrides streaming default)
52
+ * - `'stream'`: render placeholder now, stream replacement later (this is the default in streaming mode)
53
+ * - `'skip'`: don't render this component server-side
54
+ *
55
+ * Return void to accept the default behavior:
56
+ * - In streaming mode (`renderStream`/`renderStreamWithCallbacks`): defaults to `'stream'`
57
+ * - In string mode (`renderToString`/`render`): defaults to `'block'`
58
+ *
59
+ * When core handles streaming, it manages the deferred render and race loop.
60
+ * Plugins that need to augment the streamed result should use `onAsyncComponentResolved`.
61
+ *
62
+ * @example Suspense plugin returns `{ mode: 'stream', placeholder: '<Spinner/>' }`
63
+ * @example A plugin returns `{ mode: 'block' }` to force waiting
64
+ */
65
+ handleAsyncSetup?(id: number, ssrLoads: Promise<void>[], renderFn: () => any, ctx: SSRContext): {
66
+ mode: 'block' | 'stream' | 'skip';
67
+ placeholder?: string;
68
+ } | void;
69
+ /**
70
+ * Called after a core-managed async component resolves its deferred render.
71
+ * Allows plugins to capture state, inject extra data, or modify the replacement.
72
+ *
73
+ * Return an object with:
74
+ * - `html`: replacement HTML (modified or as-is)
75
+ * - `script`: extra script content to inject alongside the replacement
76
+ *
77
+ * Return void to accept the default (plain HTML replacement).
78
+ *
79
+ * @example Islands plugin captures signal state and injects island data update
80
+ */
81
+ onAsyncComponentResolved?(id: number, html: string, ctx: SSRContext): {
82
+ html?: string;
83
+ script?: string;
84
+ } | void;
85
+ /**
86
+ * Called after rendering finishes. Return HTML to append after the rendered content.
87
+ * Use for injecting scripts, JSON data, ready events, etc.
88
+ */
89
+ getInjectedHTML?(ctx: SSRContext): string | Promise<string>;
90
+ /**
91
+ * Called after all synchronous rendering for streaming mode.
92
+ * Returns an async generator of HTML chunks to append (e.g., streaming replacement scripts).
93
+ * Return void if no streaming chunks needed.
94
+ */
95
+ getStreamingChunks?(ctx: SSRContext): AsyncGenerator<string> | void;
96
+ };
97
+ /** Client-side hooks (run during hydration) */
98
+ client?: {
99
+ /**
100
+ * Called before the hydration DOM walk.
101
+ * Return `false` to prevent the default DOM walk entirely.
102
+ *
103
+ * @example Resumable plugin returns false (sets up event delegation instead)
104
+ * @example Islands plugin returns void (allows default walk)
105
+ */
106
+ beforeHydrate?(container: Element): boolean | void;
107
+ /**
108
+ * Called for each component encountered during the hydration walk.
109
+ * Return a `Node | null` to indicate the plugin handled this component
110
+ * (the returned value is the next DOM sibling to process).
111
+ * Return `undefined` (void) to let the next plugin or default hydration handle it.
112
+ *
113
+ * @example Islands plugin intercepts `client:*` components and schedules deferred hydration
114
+ */
115
+ hydrateComponent?(vnode: VNode, dom: Node | null, parent: Node): Node | null | undefined;
116
+ /**
117
+ * Called after the hydration walk completes.
118
+ *
119
+ * @example Islands plugin calls `hydrateLeftoverAsyncComponents()`
120
+ */
121
+ afterHydrate?(container: Element): void;
122
+ };
123
+ }
124
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,MAAM,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACtB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IAEb,qEAAqE;IACrE,MAAM,C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AAG,OAAO,GAAG,IAAI,CAAC;QAEnD;;;;;;;WAOG;QACH,gBAAgB,CAAC,CACb,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,IAAI,GAAG,IAAI,EAChB,MAAM,EAAE,IAAI,GACb,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;QAE3B;;;;WAIG;QACH,YAAY,CAAC,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;KAC3C,CAAC;CACL"}
@@ -1,11 +1,36 @@
1
1
  /**
2
- * SSR Context - tracks component boundaries and hydration markers during rendering
2
+ * SSR Context tracks component boundaries and rendering state.
3
+ *
4
+ * This is the core SSR context, free of any strategy-specific logic (islands, etc.).
5
+ * Plugins extend it via the generic `_pluginData` map.
3
6
  */
7
+ import type { SSRPlugin } from '../plugin';
8
+ /**
9
+ * Core-managed pending async component.
10
+ * Created by render-core when streaming mode is active and no plugin overrides.
11
+ */
12
+ export interface CorePendingAsync {
13
+ /** Component ID */
14
+ id: number;
15
+ /** Resolves to rendered HTML when ssr.load() completes */
16
+ promise: Promise<string>;
17
+ }
4
18
  export interface SSRContextOptions {
5
19
  /**
6
20
  * Enable streaming mode (default: true)
7
21
  */
8
22
  streaming?: boolean;
23
+ /**
24
+ * Called when a component's setup() throws during SSR.
25
+ *
26
+ * Return a fallback HTML string to render in place of the failed component,
27
+ * or `null` to use the default error placeholder.
28
+ *
29
+ * @param error - The error thrown during rendering
30
+ * @param componentName - The component's `__name` (or 'Anonymous')
31
+ * @param componentId - The numeric component ID assigned by the SSR context
32
+ */
33
+ onComponentError?: (error: Error, componentName: string, componentId: number) => string | null;
9
34
  }
10
35
  export interface RenderOptions {
11
36
  /**
@@ -22,18 +47,34 @@ export interface SSRContext {
22
47
  * Stack of component IDs for nested tracking
23
48
  */
24
49
  _componentStack: number[];
25
- /**
26
- * Registered islands and their hydration strategies
27
- */
28
- _islands: Map<number, IslandInfo>;
29
50
  /**
30
51
  * Collected head elements (scripts, styles, etc.)
31
52
  */
32
53
  _head: string[];
33
54
  /**
34
- * Pending async components for streaming
55
+ * Error callback for component rendering failures
35
56
  */
36
- _pendingAsync: PendingAsyncComponent[];
57
+ _onComponentError?: (error: Error, componentName: string, componentId: number) => string | null;
58
+ /**
59
+ * Registered SSR plugins
60
+ */
61
+ _plugins?: SSRPlugin[];
62
+ /**
63
+ * Plugin-specific data storage, keyed by plugin name.
64
+ * Plugins store their own state here via `getPluginData` / `setPluginData`.
65
+ */
66
+ _pluginData: Map<string, any>;
67
+ /**
68
+ * Whether streaming mode is active.
69
+ * When true, async components default to streaming (placeholder + deferred render)
70
+ * instead of blocking. Set by renderStream / renderStreamWithCallbacks.
71
+ */
72
+ _streaming: boolean;
73
+ /**
74
+ * Core-managed pending async components.
75
+ * Populated by render-core when async components are streamed without a plugin override.
76
+ */
77
+ _pendingAsync: CorePendingAsync[];
37
78
  /**
38
79
  * Generate next component ID
39
80
  */
@@ -46,14 +87,6 @@ export interface SSRContext {
46
87
  * Pop the current component from stack
47
88
  */
48
89
  popComponent(): number | undefined;
49
- /**
50
- * Register an island for selective hydration
51
- */
52
- registerIsland(id: number, info: IslandInfo): void;
53
- /**
54
- * Get all registered islands
55
- */
56
- getIslands(): Map<number, IslandInfo>;
57
90
  /**
58
91
  * Add a head element
59
92
  */
@@ -63,54 +96,14 @@ export interface SSRContext {
63
96
  */
64
97
  getHead(): string;
65
98
  /**
66
- * Register a pending async component for streaming
67
- */
68
- addPendingAsync(pending: PendingAsyncComponent): void;
69
- /**
70
- * Get all pending async components
71
- */
72
- getPendingAsync(): PendingAsyncComponent[];
73
- }
74
- export interface IslandInfo {
75
- /**
76
- * Hydration strategy: 'load' | 'idle' | 'visible' | 'media' | 'only'
77
- */
78
- strategy: HydrationStrategy;
79
- /**
80
- * Media query for 'media' strategy
81
- */
82
- media?: string;
83
- /**
84
- * Component props to serialize for client hydration
99
+ * Get plugin-specific data by plugin name.
85
100
  */
86
- props?: Record<string, any>;
101
+ getPluginData<T>(pluginName: string): T | undefined;
87
102
  /**
88
- * Component name/identifier for client
103
+ * Set plugin-specific data by plugin name.
89
104
  */
90
- componentId?: string;
91
- /**
92
- * Captured signal state from async setup for client hydration
93
- */
94
- state?: Record<string, any>;
95
- /**
96
- * Placeholder HTML for streaming async components
97
- */
98
- placeholder?: string;
99
- }
100
- /**
101
- * Pending async component that will be streamed later
102
- */
103
- export interface PendingAsyncComponent {
104
- /** Component ID */
105
- id: number;
106
- /** Promise that resolves to rendered HTML */
107
- promise: Promise<string>;
108
- /** Signal state captured during render */
109
- signalMap: Map<string, any>;
110
- /** Island info reference */
111
- islandInfo: IslandInfo;
105
+ setPluginData<T>(pluginName: string, data: T): void;
112
106
  }
113
- export type HydrationStrategy = 'load' | 'idle' | 'visible' | 'media' | 'only';
114
107
  /**
115
108
  * Create a new SSR context for rendering
116
109
  */
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/server/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAElC;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAEhB;;OAEG;IACH,aAAa,EAAE,qBAAqB,EAAE,CAAC;IAEvC;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC;IAEjB;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;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C;IAEhC;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;OAEG;IACH,OAAO,IAAI,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAEpD;;OAEG;IACH,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;CACvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CA2C5E"}
@@ -2,10 +2,15 @@
2
2
  * @sigx/server-renderer/server
3
3
  *
4
4
  * Server-side rendering with streaming support and hydration markers.
5
+ * Strategy-agnostic — plugins add islands, Suspense, etc.
5
6
  */
6
7
  import '../client-directives.js';
7
- export { renderToStream, renderToString, renderToStreamWithCallbacks } from './stream.js';
8
- export type { StreamCallbacks } from './stream.js';
9
- export { createSSRContext } from './context.js';
10
- export type { SSRContext, SSRContextOptions, RenderOptions } from './context.js';
8
+ import '../directive-ssr-types.js';
9
+ export { renderToStream, renderToString, renderToStreamWithCallbacks } from './render-api';
10
+ export { renderVNodeToString } from './render-core';
11
+ export { createSSRContext } from './context';
12
+ export type { SSRContext, SSRContextOptions, RenderOptions, CorePendingAsync } from './context';
13
+ export { generateStreamingScript, generateReplacementScript, escapeJsonForScript } from './streaming';
14
+ export type { SSRSignalFn, StreamCallbacks } from './types';
15
+ export { generateSignalKey } from './types';
11
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1F,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,2BAA2B,CAAC;AAMnC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACtG,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,2 +1,3 @@
1
- import { i as createSSRContext, n as renderToStreamWithCallbacks, r as renderToString, t as renderToStream } from "../server-BCOJt2Bi.js";
2
- export { createSSRContext, renderToStream, renderToStreamWithCallbacks, renderToString };
1
+ import { d as generateStreamingScript, f as renderVNodeToString, l as escapeJsonForScript, n as renderToStreamWithCallbacks, p as createSSRContext, r as renderToString, t as renderToStream, u as generateReplacementScript } from "../server-UBcHtkm-.js";
2
+ import { t as generateSignalKey } from "../types-B4Rf1Xot.js";
3
+ export { createSSRContext, escapeJsonForScript, generateReplacementScript, generateSignalKey, generateStreamingScript, renderToStream, renderToStreamWithCallbacks, renderToString, renderVNodeToString };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Public SSR rendering APIs — convenience wrappers
3
+ *
4
+ * These delegate to `createSSR()` internally so there is exactly one
5
+ * rendering pipeline. When no plugins are registered the plugin hooks
6
+ * are simply no-ops, making these equivalent to calling `createSSR()`
7
+ * directly — but with a simpler call signature for the common case.
8
+ *
9
+ * For plugin-driven rendering (islands, streaming async, etc.),
10
+ * use `createSSR().use(plugin).render()` from `@sigx/server-renderer`.
11
+ *
12
+ * Entry points:
13
+ * - `renderToString()` — full render to a single string
14
+ * - `renderToStream()` — ReadableStream
15
+ * - `renderToStreamWithCallbacks()` — callback-based streaming
16
+ */
17
+ import type { JSXElement } from 'sigx';
18
+ import type { App } from 'sigx';
19
+ import type { SSRContext } from './context';
20
+ import type { StreamCallbacks } from './types';
21
+ export type { StreamCallbacks } from './types';
22
+ /**
23
+ * Render JSX element or App to a ReadableStream.
24
+ *
25
+ * Internally delegates to `createSSR().renderStream()`.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * // Simple usage with JSX
30
+ * renderToStream(<App />)
31
+ *
32
+ * // With App instance for DI/plugins
33
+ * const app = defineApp(<App />).use(router);
34
+ * renderToStream(app)
35
+ * ```
36
+ */
37
+ export declare function renderToStream(input: JSXElement | App, context?: SSRContext): ReadableStream<string>;
38
+ /**
39
+ * Render with callbacks for fine-grained streaming control.
40
+ *
41
+ * Internally delegates to `createSSR().renderStreamWithCallbacks()`.
42
+ *
43
+ * @example
44
+ * ```tsx
45
+ * const app = defineApp(<App />).use(router);
46
+ * await renderToStreamWithCallbacks(app, callbacks)
47
+ * ```
48
+ */
49
+ export declare function renderToStreamWithCallbacks(input: JSXElement | App, callbacks: StreamCallbacks, context?: SSRContext): Promise<void>;
50
+ /**
51
+ * Render JSX element or App to string.
52
+ *
53
+ * Internally delegates to `createSSR().render()`.
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * const html = await renderToString(<App />);
58
+ *
59
+ * const app = defineApp(<App />).use(router);
60
+ * const html = await renderToString(app);
61
+ * ```
62
+ */
63
+ export declare function renderToString(input: JSXElement | App, context?: SSRContext): Promise<string>;
64
+ //# sourceMappingURL=render-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-api.d.ts","sourceRoot":"","sources":["../../src/server/render-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAqB,MAAM,WAAW,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,CAEpG;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,2BAA2B,CAC7C,KAAK,EAAE,UAAU,GAAG,GAAG,EACvB,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAEnG"}