-
-
Notifications
You must be signed in to change notification settings - Fork 883
/
server-mock.ts
80 lines (77 loc) · 2.15 KB
/
server-mock.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//@ts-nocheck
function throwInBrowser(func: Function) {
const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
console.error(err);
}
export function renderToString<T>(
fn: () => T,
options?: {
nonce?: string;
renderId?: string;
}
): string {
throwInBrowser(renderToString);
}
export function renderToStringAsync<T>(
fn: () => T,
options?: {
timeoutMs?: number;
nonce?: string;
renderId?: string;
}
): Promise<string> {
throwInBrowser(renderToStringAsync);
}
export function renderToStream<T>(
fn: () => T,
options?: {
nonce?: string;
renderId?: string;
onCompleteShell?: (info: { write: (v: string) => void }) => void;
onCompleteAll?: (info: { write: (v: string) => void }) => void;
}
): {
pipe: (writable: { write: (v: string) => void }) => void;
pipeTo: (writable: WritableStream) => void;
} {
throwInBrowser(renderToStream);
}
export function ssr(template: string[] | string, ...nodes: any[]): { t: string } {}
export function ssrElement(name: string, props: any, children: any, needsId: boolean): { t: string } {};
export function ssrClassList(value: { [k: string]: boolean }): string {}
export function ssrStyle(value: { [k: string]: string }): string {}
export function ssrAttribute(key: string, value: boolean): string {}
export function ssrHydrationKey(): string {}
export function resolveSSRNode(node: any): string {}
export function escape(html: string): string {}
/**
* @deprecated Replaced by ssrElement
*/
export function ssrSpread(props: any, isSVG: boolean, skipChildren: boolean): void {};
export type LegacyResults = {
startWriting: () => void;
};
/**
* @deprecated Replaced by renderToStream
*/
export function pipeToWritable<T>(
fn: () => T,
writable: WritableStream,
options?: {
nonce?: string;
onReady?: (res: LegacyResults) => void;
onCompleteAll?: () => void;
}
): void;
/**
* @deprecated Replaced by renderToStream
*/
export function pipeToNodeWritable<T>(
fn: () => T,
writable: { write: (v: string) => void },
options?: {
nonce?: string;
onReady?: (res: LegacyResults) => void;
onCompleteAll?: () => void;
}
): void;