UNPKG

6.19 kBTypeScriptView Raw
1// Generated by dts-bundle-generator v5.3.0
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 clientside
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 clientside. 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 serverside-rendered
72 * and will not be clientside 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 clientside 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 whitespce, 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 level: "error" | "warn" | "info" | "log" | "debug";
145 type: string;
146 header?: string;
147 language?: string;
148 messageText: string;
149 debugText?: string;
150 code?: string;
151 absFilePath?: string;
152 relFilePath?: string;
153 lineNumber?: number;
154 columnNumber?: number;
155 lines?: {
156 lineIndex: number;
157 lineNumber: number;
158 text?: string;
159 errorCharStart: number;
160 errorLength?: number;
161 }[];
162}
163export interface HydrateResults {
164 buildId: string;
165 diagnostics: Diagnostic[];
166 url: string;
167 host: string;
168 hostname: string;
169 href: string;
170 port: string;
171 pathname: string;
172 search: string;
173 hash: string;
174 html: string;
175 components: HydrateComponent[];
176 anchors: HydrateAnchorElement[];
177 imgs: HydrateImgElement[];
178 scripts: HydrateScriptElement[];
179 styles: HydrateStyleElement[];
180 staticData: HydrateStaticData[];
181 title: string;
182 hydratedCount: number;
183 httpStatus: number;
184}
185export interface HydrateComponent {
186 tag: string;
187 mode: string;
188 count: number;
189 depth: number;
190}
191export interface HydrateElement {
192 [attrName: string]: string | undefined;
193}
194export interface HydrateAnchorElement extends HydrateElement {
195 href?: string;
196 target?: string;
197}
198export interface HydrateImgElement extends HydrateElement {
199 src?: string;
200}
201export interface HydrateScriptElement extends HydrateElement {
202 src?: string;
203 type?: string;
204}
205export interface HydrateStyleElement extends HydrateElement {
206 href?: string;
207}
208export interface HydrateStaticData {
209 id: string;
210 type: string;
211 content: string;
212}
213export declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<HydrateResults>;
214export declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
215export declare function serializeDocumentToString(doc: any, opts: HydrateFactoryOptions): string;
216
217export {};