@cloudwerk/ui 0.15.17 → 0.15.18
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/{chunk-2HWK7DSZ.js → chunk-GSJRCKW5.js} +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -146
- package/dist/index.js +1 -1
- package/dist/renderers/react.d.ts +67 -0
- package/dist/types-Co7WR79C.d.ts +146 -0
- package/package.json +5 -1
- /package/dist/{react-XOX7IAFN.js → renderers/react.js} +0 -0
|
@@ -164,7 +164,7 @@ async function initReactRenderer() {
|
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
try {
|
|
167
|
-
const { reactRenderer } = await import("./react
|
|
167
|
+
const { reactRenderer } = await import("./renderers/react.js");
|
|
168
168
|
renderers["react"] = reactRenderer;
|
|
169
169
|
} catch (error) {
|
|
170
170
|
throw new Error(
|
package/dist/client.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,151 +1,8 @@
|
|
|
1
|
+
import { a as Renderer, S as StreamRenderOptions, R as RenderToStreamOptions, H as HtmlOptions, b as RenderOptions } from './types-Co7WR79C.js';
|
|
2
|
+
export { P as PropsWithChildren } from './types-Co7WR79C.js';
|
|
1
3
|
import { HydrationManifest } from '@cloudwerk/core/build';
|
|
2
4
|
export { ClientComponentMeta, ClientComponentWrapper, createClientComponentWrapper } from './client.js';
|
|
3
5
|
|
|
4
|
-
/**
|
|
5
|
-
* @cloudwerk/ui - Type Definitions
|
|
6
|
-
*
|
|
7
|
-
* Core types for the renderer abstraction layer.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Renderer implementation interface.
|
|
11
|
-
*
|
|
12
|
-
* Each renderer (hono-jsx, react, preact) implements this interface.
|
|
13
|
-
* The renderer is responsible for converting JSX elements to HTML responses.
|
|
14
|
-
*/
|
|
15
|
-
interface Renderer {
|
|
16
|
-
/**
|
|
17
|
-
* Render a JSX element to an HTML Response.
|
|
18
|
-
*
|
|
19
|
-
* @param element - JSX element to render (type is unknown to support any JSX implementation)
|
|
20
|
-
* @param options - Render options
|
|
21
|
-
* @returns Response object (may be a Promise for async rendering)
|
|
22
|
-
*/
|
|
23
|
-
render(element: unknown, options?: RenderOptions): Response | Promise<Response>;
|
|
24
|
-
/**
|
|
25
|
-
* Create an HTML Response from a raw string.
|
|
26
|
-
*
|
|
27
|
-
* Useful for static HTML, templates, or pre-rendered content.
|
|
28
|
-
*
|
|
29
|
-
* @param content - Raw HTML string
|
|
30
|
-
* @param options - HTML response options
|
|
31
|
-
* @returns Response object
|
|
32
|
-
*/
|
|
33
|
-
html(content: string, options?: HtmlOptions): Response;
|
|
34
|
-
/**
|
|
35
|
-
* Hydrate a JSX element on the client.
|
|
36
|
-
*
|
|
37
|
-
* Only used for Client Components marked with 'use client'.
|
|
38
|
-
* This attaches event handlers to server-rendered HTML.
|
|
39
|
-
*
|
|
40
|
-
* @param element - JSX element to hydrate
|
|
41
|
-
* @param root - DOM element to hydrate into
|
|
42
|
-
*/
|
|
43
|
-
hydrate(element: unknown, root: Element): void;
|
|
44
|
-
/**
|
|
45
|
-
* Create a JSX element using the renderer's element factory.
|
|
46
|
-
*
|
|
47
|
-
* This is used by the client component wrapper to create hydration wrapper
|
|
48
|
-
* elements at runtime without baking in a specific JSX runtime at compile time.
|
|
49
|
-
*
|
|
50
|
-
* @param type - Element type (e.g., 'div', 'span')
|
|
51
|
-
* @param props - Element properties
|
|
52
|
-
* @param children - Child elements
|
|
53
|
-
* @returns A JSX element compatible with this renderer
|
|
54
|
-
*/
|
|
55
|
-
createElement(type: string, props: Record<string, unknown>, ...children: unknown[]): unknown;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Options for rendering JSX elements.
|
|
59
|
-
*/
|
|
60
|
-
interface RenderOptions {
|
|
61
|
-
/**
|
|
62
|
-
* HTTP status code for the response.
|
|
63
|
-
* @default 200
|
|
64
|
-
*/
|
|
65
|
-
status?: number;
|
|
66
|
-
/**
|
|
67
|
-
* Additional response headers.
|
|
68
|
-
* These are merged with the default Content-Type header.
|
|
69
|
-
*/
|
|
70
|
-
headers?: Record<string, string>;
|
|
71
|
-
/**
|
|
72
|
-
* Whether to include the <!DOCTYPE html> declaration.
|
|
73
|
-
* @default true
|
|
74
|
-
*/
|
|
75
|
-
doctype?: boolean;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Options for creating HTML responses from raw strings.
|
|
79
|
-
*/
|
|
80
|
-
interface HtmlOptions {
|
|
81
|
-
/**
|
|
82
|
-
* HTTP status code for the response.
|
|
83
|
-
* @default 200
|
|
84
|
-
*/
|
|
85
|
-
status?: number;
|
|
86
|
-
/**
|
|
87
|
-
* Additional response headers.
|
|
88
|
-
* These are merged with the default Content-Type header.
|
|
89
|
-
*/
|
|
90
|
-
headers?: Record<string, string>;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Options for streaming render (loading-swap pattern).
|
|
94
|
-
*/
|
|
95
|
-
interface StreamRenderOptions {
|
|
96
|
-
/**
|
|
97
|
-
* HTTP status code for the response.
|
|
98
|
-
* @default 200
|
|
99
|
-
*/
|
|
100
|
-
status?: number;
|
|
101
|
-
/**
|
|
102
|
-
* Additional response headers.
|
|
103
|
-
* These are merged with the default Content-Type and Transfer-Encoding headers.
|
|
104
|
-
*/
|
|
105
|
-
headers?: Record<string, string>;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Options for native progressive streaming render with Suspense boundaries.
|
|
109
|
-
*
|
|
110
|
-
* This is used by renderToStream() which uses Hono's renderToReadableStream
|
|
111
|
-
* for native progressive streaming with Suspense support.
|
|
112
|
-
*/
|
|
113
|
-
interface RenderToStreamOptions {
|
|
114
|
-
/**
|
|
115
|
-
* HTTP status code for the response.
|
|
116
|
-
* @default 200
|
|
117
|
-
*/
|
|
118
|
-
status?: number;
|
|
119
|
-
/**
|
|
120
|
-
* Additional response headers.
|
|
121
|
-
* These are merged with the default Content-Type header.
|
|
122
|
-
*/
|
|
123
|
-
headers?: Record<string, string>;
|
|
124
|
-
/**
|
|
125
|
-
* Whether to include the <!DOCTYPE html> declaration.
|
|
126
|
-
* @default true
|
|
127
|
-
*/
|
|
128
|
-
doctype?: boolean;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Props for components that receive children.
|
|
132
|
-
*
|
|
133
|
-
* Works with any JSX implementation (Hono JSX, React, Preact).
|
|
134
|
-
* The children type is `unknown` to allow any JSX element type.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* function Layout({ children }: PropsWithChildren) {
|
|
138
|
-
* return (
|
|
139
|
-
* <html>
|
|
140
|
-
* <body>{children}</body>
|
|
141
|
-
* </html>
|
|
142
|
-
* )
|
|
143
|
-
* }
|
|
144
|
-
*/
|
|
145
|
-
interface PropsWithChildren<_P = unknown> {
|
|
146
|
-
children?: unknown;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
6
|
/**
|
|
150
7
|
* @cloudwerk/ui - Hydration Utilities
|
|
151
8
|
*
|
|
@@ -546,4 +403,4 @@ declare function html(content: string, options?: HtmlOptions): Response;
|
|
|
546
403
|
*/
|
|
547
404
|
declare function hydrate(element: unknown, root: Element): void;
|
|
548
405
|
|
|
549
|
-
export {
|
|
406
|
+
export { HtmlOptions, type HydrationScriptOptions, RenderOptions, RenderToStreamOptions, Renderer, StreamRenderOptions, type WrapForHydrationOptions, _resetRenderers, generateHydrationRuntime, generateHydrationScript, generatePreloadHints, generateReactHydrationRuntime, generateReactHydrationScript, getActiveRenderer, getActiveRendererName, getAvailableRenderers, honoJsxRenderer, html, hydrate, initReactRenderer, registerRenderer, render, renderStream, renderToStream, setActiveRenderer, wrapForHydration };
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { R as RenderToStreamOptions, a as Renderer } from '../types-Co7WR79C.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @cloudwerk/ui - React Renderer
|
|
5
|
+
*
|
|
6
|
+
* React SSR renderer implementation using react-dom/server.
|
|
7
|
+
* This provides an alternative to the Hono JSX renderer for projects
|
|
8
|
+
* that prefer React's rendering pipeline.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* React renderer implementation.
|
|
13
|
+
*
|
|
14
|
+
* Uses react-dom/server for server-side rendering. This renderer enables
|
|
15
|
+
* Cloudwerk applications to use React instead of Hono JSX.
|
|
16
|
+
*
|
|
17
|
+
* Features:
|
|
18
|
+
* - Synchronous rendering via renderToString()
|
|
19
|
+
* - Automatic doctype handling
|
|
20
|
+
* - Proper Content-Type headers
|
|
21
|
+
*
|
|
22
|
+
* Native progressive streaming is available via reactRenderToStream() using React's
|
|
23
|
+
* renderToReadableStream for Suspense boundary support.
|
|
24
|
+
*/
|
|
25
|
+
declare const reactRenderer: Renderer;
|
|
26
|
+
/**
|
|
27
|
+
* Render a React element to a streaming Response using native progressive streaming.
|
|
28
|
+
*
|
|
29
|
+
* This uses React 19's renderToReadableStream for native support of React-style
|
|
30
|
+
* Suspense boundaries. Content inside Suspense components will be progressively
|
|
31
|
+
* streamed as their async content resolves.
|
|
32
|
+
*
|
|
33
|
+
* Unlike synchronous render() which blocks until the full HTML is ready, this function
|
|
34
|
+
* provides true progressive streaming where:
|
|
35
|
+
* - The initial shell is sent immediately
|
|
36
|
+
* - Suspense fallbacks are shown while async content loads
|
|
37
|
+
* - Async content is streamed in-place as it resolves
|
|
38
|
+
* - No JavaScript is required for the initial render
|
|
39
|
+
*
|
|
40
|
+
* @param element - React element to render (may contain Suspense boundaries)
|
|
41
|
+
* @param options - Render options
|
|
42
|
+
* @returns Promise resolving to Response with streaming HTML content
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // In a route handler
|
|
46
|
+
* import { Suspense } from 'react'
|
|
47
|
+
*
|
|
48
|
+
* function Page() {
|
|
49
|
+
* return (
|
|
50
|
+
* <html>
|
|
51
|
+
* <body>
|
|
52
|
+
* <h1>Dashboard</h1>
|
|
53
|
+
* <Suspense fallback={<p>Loading stats...</p>}>
|
|
54
|
+
* <AsyncStats />
|
|
55
|
+
* </Suspense>
|
|
56
|
+
* </body>
|
|
57
|
+
* </html>
|
|
58
|
+
* )
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* export function GET() {
|
|
62
|
+
* return reactRenderToStream(<Page />)
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
65
|
+
declare function reactRenderToStream(element: unknown, options?: RenderToStreamOptions): Promise<Response>;
|
|
66
|
+
|
|
67
|
+
export { reactRenderToStream, reactRenderer };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cloudwerk/ui - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types for the renderer abstraction layer.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Renderer implementation interface.
|
|
8
|
+
*
|
|
9
|
+
* Each renderer (hono-jsx, react, preact) implements this interface.
|
|
10
|
+
* The renderer is responsible for converting JSX elements to HTML responses.
|
|
11
|
+
*/
|
|
12
|
+
interface Renderer {
|
|
13
|
+
/**
|
|
14
|
+
* Render a JSX element to an HTML Response.
|
|
15
|
+
*
|
|
16
|
+
* @param element - JSX element to render (type is unknown to support any JSX implementation)
|
|
17
|
+
* @param options - Render options
|
|
18
|
+
* @returns Response object (may be a Promise for async rendering)
|
|
19
|
+
*/
|
|
20
|
+
render(element: unknown, options?: RenderOptions): Response | Promise<Response>;
|
|
21
|
+
/**
|
|
22
|
+
* Create an HTML Response from a raw string.
|
|
23
|
+
*
|
|
24
|
+
* Useful for static HTML, templates, or pre-rendered content.
|
|
25
|
+
*
|
|
26
|
+
* @param content - Raw HTML string
|
|
27
|
+
* @param options - HTML response options
|
|
28
|
+
* @returns Response object
|
|
29
|
+
*/
|
|
30
|
+
html(content: string, options?: HtmlOptions): Response;
|
|
31
|
+
/**
|
|
32
|
+
* Hydrate a JSX element on the client.
|
|
33
|
+
*
|
|
34
|
+
* Only used for Client Components marked with 'use client'.
|
|
35
|
+
* This attaches event handlers to server-rendered HTML.
|
|
36
|
+
*
|
|
37
|
+
* @param element - JSX element to hydrate
|
|
38
|
+
* @param root - DOM element to hydrate into
|
|
39
|
+
*/
|
|
40
|
+
hydrate(element: unknown, root: Element): void;
|
|
41
|
+
/**
|
|
42
|
+
* Create a JSX element using the renderer's element factory.
|
|
43
|
+
*
|
|
44
|
+
* This is used by the client component wrapper to create hydration wrapper
|
|
45
|
+
* elements at runtime without baking in a specific JSX runtime at compile time.
|
|
46
|
+
*
|
|
47
|
+
* @param type - Element type (e.g., 'div', 'span')
|
|
48
|
+
* @param props - Element properties
|
|
49
|
+
* @param children - Child elements
|
|
50
|
+
* @returns A JSX element compatible with this renderer
|
|
51
|
+
*/
|
|
52
|
+
createElement(type: string, props: Record<string, unknown>, ...children: unknown[]): unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for rendering JSX elements.
|
|
56
|
+
*/
|
|
57
|
+
interface RenderOptions {
|
|
58
|
+
/**
|
|
59
|
+
* HTTP status code for the response.
|
|
60
|
+
* @default 200
|
|
61
|
+
*/
|
|
62
|
+
status?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Additional response headers.
|
|
65
|
+
* These are merged with the default Content-Type header.
|
|
66
|
+
*/
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to include the <!DOCTYPE html> declaration.
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
doctype?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Options for creating HTML responses from raw strings.
|
|
76
|
+
*/
|
|
77
|
+
interface HtmlOptions {
|
|
78
|
+
/**
|
|
79
|
+
* HTTP status code for the response.
|
|
80
|
+
* @default 200
|
|
81
|
+
*/
|
|
82
|
+
status?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Additional response headers.
|
|
85
|
+
* These are merged with the default Content-Type header.
|
|
86
|
+
*/
|
|
87
|
+
headers?: Record<string, string>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Options for streaming render (loading-swap pattern).
|
|
91
|
+
*/
|
|
92
|
+
interface StreamRenderOptions {
|
|
93
|
+
/**
|
|
94
|
+
* HTTP status code for the response.
|
|
95
|
+
* @default 200
|
|
96
|
+
*/
|
|
97
|
+
status?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Additional response headers.
|
|
100
|
+
* These are merged with the default Content-Type and Transfer-Encoding headers.
|
|
101
|
+
*/
|
|
102
|
+
headers?: Record<string, string>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Options for native progressive streaming render with Suspense boundaries.
|
|
106
|
+
*
|
|
107
|
+
* This is used by renderToStream() which uses Hono's renderToReadableStream
|
|
108
|
+
* for native progressive streaming with Suspense support.
|
|
109
|
+
*/
|
|
110
|
+
interface RenderToStreamOptions {
|
|
111
|
+
/**
|
|
112
|
+
* HTTP status code for the response.
|
|
113
|
+
* @default 200
|
|
114
|
+
*/
|
|
115
|
+
status?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Additional response headers.
|
|
118
|
+
* These are merged with the default Content-Type header.
|
|
119
|
+
*/
|
|
120
|
+
headers?: Record<string, string>;
|
|
121
|
+
/**
|
|
122
|
+
* Whether to include the <!DOCTYPE html> declaration.
|
|
123
|
+
* @default true
|
|
124
|
+
*/
|
|
125
|
+
doctype?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Props for components that receive children.
|
|
129
|
+
*
|
|
130
|
+
* Works with any JSX implementation (Hono JSX, React, Preact).
|
|
131
|
+
* The children type is `unknown` to allow any JSX element type.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* function Layout({ children }: PropsWithChildren) {
|
|
135
|
+
* return (
|
|
136
|
+
* <html>
|
|
137
|
+
* <body>{children}</body>
|
|
138
|
+
* </html>
|
|
139
|
+
* )
|
|
140
|
+
* }
|
|
141
|
+
*/
|
|
142
|
+
interface PropsWithChildren<_P = unknown> {
|
|
143
|
+
children?: unknown;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type { HtmlOptions as H, PropsWithChildren as P, RenderToStreamOptions as R, StreamRenderOptions as S, Renderer as a, RenderOptions as b };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudwerk/ui",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.18",
|
|
4
4
|
"description": "UI rendering abstraction for Cloudwerk",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"./client": {
|
|
17
17
|
"types": "./dist/client.d.ts",
|
|
18
18
|
"import": "./dist/client.js"
|
|
19
|
+
},
|
|
20
|
+
"./renderers/react": {
|
|
21
|
+
"types": "./dist/renderers/react.d.ts",
|
|
22
|
+
"import": "./dist/renderers/react.js"
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
"files": [
|
|
File without changes
|