@sigx/server-renderer 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.
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Streaming SSR renderer with hydration markers
3
+ */
4
+ import { JSXElement } from '@sigx/runtime-core';
5
+ import { SSRContext } from './context.js';
6
+ /**
7
+ * Render JSX element to a ReadableStream with streaming async support
8
+ */
9
+ export declare function renderToStream(element: JSXElement, context?: SSRContext): ReadableStream<string>;
10
+ /**
11
+ * Streaming callbacks interface
12
+ */
13
+ export interface StreamCallbacks {
14
+ /** Called when the initial shell (synchronous content) is ready */
15
+ onShellReady: (html: string) => void;
16
+ /** Called for each async chunk (replacement scripts, hydration data) */
17
+ onAsyncChunk: (chunk: string) => void;
18
+ /** Called when all streaming is complete */
19
+ onComplete: () => void;
20
+ /** Called on error */
21
+ onError: (error: Error) => void;
22
+ }
23
+ /**
24
+ * Render with callbacks for fine-grained streaming control.
25
+ * This allows the server to inject scripts between shell and async content.
26
+ */
27
+ export declare function renderToStreamWithCallbacks(element: JSXElement, callbacks: StreamCallbacks, context?: SSRContext): Promise<void>;
28
+ /**
29
+ * Render JSX element to string (convenience wrapper around stream)
30
+ * For renderToString, we wait for all async components to complete,
31
+ * then include the replacement scripts inline so the final HTML is complete.
32
+ */
33
+ export declare function renderToString(element: JSXElement, context?: SSRContext): Promise<string>;
34
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/server/stream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGH,UAAU,EAOb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAA0E,MAAM,cAAc,CAAC;AA8clH;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,CA8DhG;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;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC7C,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CA4Ef;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA+C/F"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sigx/server-renderer",
3
- "version": "0.1.3",
4
- "description": "Server-side renderer for SignalX",
3
+ "version": "0.1.5",
4
+ "description": "Server-side rendering and client hydration for SigX",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -9,17 +9,31 @@
9
9
  ".": {
10
10
  "import": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts"
12
+ },
13
+ "./server": {
14
+ "import": "./dist/server/index.js",
15
+ "types": "./dist/server/index.d.ts"
16
+ },
17
+ "./client": {
18
+ "import": "./dist/client/index.js",
19
+ "types": "./dist/client/index.d.ts"
20
+ },
21
+ "./jsx": {
22
+ "types": "./src/jsx.d.ts"
12
23
  }
13
24
  },
14
25
  "files": [
15
- "dist"
26
+ "dist",
27
+ "src/jsx.d.ts"
16
28
  ],
17
29
  "keywords": [
18
30
  "sigx",
19
31
  "ssr",
20
32
  "server-side-rendering",
21
33
  "server",
22
- "renderer"
34
+ "renderer",
35
+ "hydration",
36
+ "islands"
23
37
  ],
24
38
  "author": "Andreas Ekdahl",
25
39
  "license": "MIT",
@@ -33,8 +47,9 @@
33
47
  "url": "https://github.com/signalxjs/core/issues"
34
48
  },
35
49
  "dependencies": {
36
- "@sigx/runtime-core": "^0.1.3",
37
- "@sigx/reactivity": "^0.1.3"
50
+ "@sigx/runtime-core": "^0.1.5",
51
+ "@sigx/reactivity": "^0.1.5",
52
+ "@sigx/runtime-dom": "^0.1.5"
38
53
  },
39
54
  "devDependencies": {
40
55
  "rolldown": "^1.0.0-beta.52",
package/src/jsx.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * JSX type augmentation for SSR client directives.
3
+ *
4
+ * Import this module to enable client:* directive types in your JSX.
5
+ * These directives control selective hydration behavior.
6
+ *
7
+ * Usage:
8
+ * ```tsx
9
+ * import '@sigx/server-renderer/jsx';
10
+ *
11
+ * <Counter client:visible />
12
+ * <HeavyWidget client:idle />
13
+ * <Modal client:load />
14
+ * <Sidebar client:media="(min-width: 768px)" />
15
+ * <ClientOnlyMap client:only />
16
+ * ```
17
+ */
18
+
19
+ /**
20
+ * Client hydration directive props
21
+ */
22
+ export interface ClientDirectives {
23
+ /**
24
+ * Hydrate this component immediately when the page loads.
25
+ * Use for critical interactive components above the fold.
26
+ */
27
+ 'client:load'?: boolean;
28
+
29
+ /**
30
+ * Hydrate this component during browser idle time (requestIdleCallback).
31
+ * Use for non-critical components that don't need immediate interactivity.
32
+ */
33
+ 'client:idle'?: boolean;
34
+
35
+ /**
36
+ * Hydrate this component when it enters the viewport (IntersectionObserver).
37
+ * Use for below-the-fold components to improve initial load performance.
38
+ */
39
+ 'client:visible'?: boolean;
40
+
41
+ /**
42
+ * Hydrate this component when the media query matches.
43
+ * Pass the media query string as the value.
44
+ * @example <Sidebar client:media="(min-width: 768px)" />
45
+ */
46
+ 'client:media'?: string;
47
+
48
+ /**
49
+ * Skip server rendering entirely; only render on client.
50
+ * Use for components that cannot run on the server (e.g., use browser APIs).
51
+ * A placeholder will be rendered on the server.
52
+ */
53
+ 'client:only'?: boolean;
54
+ }
55
+
56
+ // Augment the component attribute extensions in runtime-core
57
+ // This adds client directives to all components using the pluggable type system
58
+ declare module '@sigx/runtime-core' {
59
+ interface ComponentAttributeExtensions extends ClientDirectives { }
60
+ }
61
+
62
+ export { };