1 | import Vue, { VNode, VNodeDirective } from 'vue'
|
2 | import { Readable } from 'stream'
|
3 |
|
4 | export declare function createRenderer(options?: RendererOptions): Renderer
|
5 |
|
6 | export declare function createBundleRenderer(
|
7 | bundle: string | object,
|
8 | options?: BundleRendererOptions
|
9 | ): BundleRenderer
|
10 |
|
11 | type RenderCallback = (err: Error | null, html: string) => void
|
12 |
|
13 | interface Renderer {
|
14 | renderToString(vm: Vue, callback: RenderCallback): void
|
15 | renderToString(vm: Vue, context: object, callback: RenderCallback): void
|
16 | renderToString(vm: Vue): Promise<string>
|
17 | renderToString(vm: Vue, context: object): Promise<string>
|
18 |
|
19 | renderToStream(vm: Vue, context?: object): Readable
|
20 | }
|
21 |
|
22 | interface BundleRenderer {
|
23 | renderToString(callback: RenderCallback): void
|
24 | renderToString(context: object, callback: RenderCallback): void
|
25 | renderToString(): Promise<string>
|
26 | renderToString(context: object): Promise<string>
|
27 |
|
28 | renderToStream(context?: object): Readable
|
29 | }
|
30 |
|
31 | interface RendererOptions {
|
32 | template?: string
|
33 | inject?: boolean
|
34 | shouldPreload?: (file: string, type: string) => boolean
|
35 | shouldPrefetch?: (file: string, type: string) => boolean
|
36 | cache?: RenderCache
|
37 | directives?: {
|
38 | [key: string]: (vnode: VNode, dir: VNodeDirective) => void
|
39 | }
|
40 | }
|
41 |
|
42 | interface BundleRendererOptions extends RendererOptions {
|
43 | clientManifest?: object
|
44 | serializer?: (state: object) => string
|
45 | runInNewContext?: boolean | 'once'
|
46 | basedir?: string
|
47 | }
|
48 |
|
49 | interface RenderCache {
|
50 | get: (key: string, cb?: (res: string) => void) => string | void
|
51 | set: (key: string, val: string) => void
|
52 | has?: (key: string, cb?: (hit: boolean) => void) => boolean | void
|
53 | }
|