Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1cf9354

Browse filesBrowse files
committed
feat: Add types for renderStream & pipeableStream
1 parent 8ec4fa5 commit 1cf9354
Copy full SHA for 1cf9354

File tree

Expand file treeCollapse file tree

3 files changed

+36
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+36
-1
lines changed

‎src/stream-node.d.ts

Copy file name to clipboard
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { VNode } from 'preact';
2+
import { WritableStream } from 'node:stream';
3+
4+
interface RenderToPipeableStreamOptions {
5+
onShellReady?: () => void;
6+
onAllReady?: () => void;
7+
onError?: (error: any) => void;
8+
}
9+
10+
interface PipeableStream {
11+
abort: () => void;
12+
pipe: (writable: WritableStream) => void;
13+
}
14+
15+
export function renderToReadableStream(
16+
vnode: VNode,
17+
options: RenderToPipeableStreamOptions,
18+
context?: any
19+
): PipeableStream;

‎src/stream-node.js

Copy file name to clipboardExpand all lines: src/stream-node.js
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ import { renderToChunks } from './lib/chunked.js';
88
* @property {(error) => void} [onError]
99
*/
1010

11+
/**
12+
* @typedef {object} PipeableStream
13+
* @property {() => void} abort
14+
* @property {(writable: import('stream').Writable) => void} pipe
15+
*/
16+
1117
/**
1218
* @param {import('preact').VNode} vnode
1319
* @param {RenderToPipeableStreamOptions} options
1420
* @param {any} [context]
15-
* @returns {{}}
21+
* @returns {PipeableStream}
1622
*/
1723
export function renderToPipeableStream(vnode, options, context) {
1824
const encoder = new TextEncoder('utf-8');

‎src/stream.d.ts

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { VNode } from 'preact';
2+
3+
interface RenderStream extends ReadableStream<Uint8Array> {
4+
allReady: Promise<void>;
5+
}
6+
7+
export function renderToReadableStream(
8+
vnode: VNode,
9+
context?: any
10+
): RenderStream;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.