UNPKG

6.27 kBTypeScriptView Raw
1// Generated by dts-bundle-generator v8.0.1
2
3export declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
4export interface HydrateDocumentOptions {
5 /**
6 * Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
7 * a random ID will be generated
8 */
9 buildId?: string;
10 /**
11 * Sets the `href` attribute on the `<link rel="canonical">`
12 * tag within the `<head>`. If the value is not defined it will
13 * ensure a canonical link tag is no included in the `<head>`.
14 */
15 canonicalUrl?: string;
16 /**
17 * Include the HTML comments and attributes used by the client-side
18 * JavaScript to read the structure of the HTML and rebuild each
19 * component. Defaults to `true`.
20 */
21 clientHydrateAnnotations?: boolean;
22 /**
23 * Constrain `setTimeout()` to 1ms, but still async. Also
24 * only allows `setInterval()` to fire once, also constrained to 1ms.
25 * Defaults to `true`.
26 */
27 constrainTimeouts?: boolean;
28 /**
29 * Sets `document.cookie`
30 */
31 cookie?: string;
32 /**
33 * Sets the `dir` attribute on the top level `<html>`.
34 */
35 direction?: string;
36 /**
37 * Component tag names listed here will not be prerendered, nor will
38 * hydrated on the client-side. Components listed here will be ignored
39 * as custom elements and treated no differently than a `<div>`.
40 */
41 excludeComponents?: string[];
42 /**
43 * Sets the `lang` attribute on the top level `<html>`.
44 */
45 language?: string;
46 /**
47 * Maximum number of components to hydrate on one page. Defaults to `300`.
48 */
49 maxHydrateCount?: number;
50 /**
51 * Sets `document.referrer`
52 */
53 referrer?: string;
54 /**
55 * Removes every `<script>` element found in the `document`. Defaults to `false`.
56 */
57 removeScripts?: boolean;
58 /**
59 * Removes CSS not used by elements within the `document`. Defaults to `true`.
60 */
61 removeUnusedStyles?: boolean;
62 /**
63 * The url the runtime uses for the resources, such as the assets directory.
64 */
65 resourcesUrl?: string;
66 /**
67 * Prints out runtime console logs to the NodeJS process. Defaults to `false`.
68 */
69 runtimeLogging?: boolean;
70 /**
71 * Component tags listed here will only be prerendered or server-side-rendered
72 * and will not be client-side hydrated. This is useful for components that
73 * are not dynamic and do not need to be defined as a custom element within the
74 * browser. For example, a header or footer component would be a good example that
75 * may not require any client-side JavaScript.
76 */
77 staticComponents?: string[];
78 /**
79 * The amount of milliseconds to wait for a page to finish rendering until
80 * a timeout error is thrown. Defaults to `15000`.
81 */
82 timeout?: number;
83 /**
84 * Sets `document.title`.
85 */
86 title?: string;
87 /**
88 * Sets `location.href`
89 */
90 url?: string;
91 /**
92 * Sets `navigator.userAgent`
93 */
94 userAgent?: string;
95}
96export interface SerializeDocumentOptions extends HydrateDocumentOptions {
97 /**
98 * Runs after the `document` has been hydrated.
99 */
100 afterHydrate?(document: any): any | Promise<any>;
101 /**
102 * Sets an approximate line width the HTML should attempt to stay within.
103 * Note that this is "approximate", in that HTML may often not be able
104 * to be split at an exact line width. Additionally, new lines created
105 * is where HTML naturally already has whitespace, such as before an
106 * attribute or spaces between words. Defaults to `100`.
107 */
108 approximateLineWidth?: number;
109 /**
110 * Runs before the `document` has been hydrated.
111 */
112 beforeHydrate?(document: any): any | Promise<any>;
113 /**
114 * Format the HTML in a nicely indented format.
115 * Defaults to `false`.
116 */
117 prettyHtml?: boolean;
118 /**
119 * Remove quotes from attribute values when possible.
120 * Defaults to `true`.
121 */
122 removeAttributeQuotes?: boolean;
123 /**
124 * Remove the `=""` from standardized `boolean` attributes,
125 * such as `hidden` or `checked`. Defaults to `true`.
126 */
127 removeBooleanAttributeQuotes?: boolean;
128 /**
129 * Remove these standardized attributes when their value is empty:
130 * `class`, `dir`, `id`, `lang`, and `name`, `title`. Defaults to `true`.
131 */
132 removeEmptyAttributes?: boolean;
133 /**
134 * Remove HTML comments. Defaults to `true`.
135 */
136 removeHtmlComments?: boolean;
137}
138export interface HydrateFactoryOptions extends SerializeDocumentOptions {
139 serializeToHtml: boolean;
140 destroyWindow: boolean;
141 destroyDocument: boolean;
142}
143export interface Diagnostic {
144 absFilePath?: string | undefined;
145 code?: string;
146 columnNumber?: number | undefined;
147 debugText?: string;
148 header?: string;
149 language?: string;
150 level: "error" | "warn" | "info" | "log" | "debug";
151 lineNumber?: number | undefined;
152 lines: PrintLine[];
153 messageText: string;
154 relFilePath?: string | undefined;
155 type: string;
156}
157export interface PrintLine {
158 lineIndex: number;
159 lineNumber: number;
160 text?: string;
161 errorCharStart: number;
162 errorLength?: number;
163}
164export interface HydrateResults {
165 buildId: string;
166 diagnostics: Diagnostic[];
167 url: string;
168 host: string;
169 hostname: string;
170 href: string;
171 port: string;
172 pathname: string;
173 search: string;
174 hash: string;
175 html: string;
176 components: HydrateComponent[];
177 anchors: HydrateAnchorElement[];
178 imgs: HydrateImgElement[];
179 scripts: HydrateScriptElement[];
180 styles: HydrateStyleElement[];
181 staticData: HydrateStaticData[];
182 title: string;
183 hydratedCount: number;
184 httpStatus: number;
185}
186export interface HydrateComponent {
187 tag: string;
188 mode: string;
189 count: number;
190 depth: number;
191}
192export interface HydrateElement {
193 [attrName: string]: string | undefined;
194}
195export interface HydrateAnchorElement extends HydrateElement {
196 href?: string;
197 target?: string;
198}
199export interface HydrateImgElement extends HydrateElement {
200 src?: string;
201}
202export interface HydrateScriptElement extends HydrateElement {
203 src?: string;
204 type?: string;
205}
206export interface HydrateStyleElement extends HydrateElement {
207 href?: string;
208}
209export interface HydrateStaticData {
210 id: string;
211 type: string;
212 content: string;
213}
214export declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<HydrateResults>;
215export declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
216export declare function serializeDocumentToString(doc: any, opts: HydrateFactoryOptions): string;
217
218export {};