runner.d.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. // Generated by dts-bundle-generator v9.5.1
  2. import { Readable } from 'node:stream';
  3. export declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
  4. export 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. }
  96. export 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. /**
  138. * If set to `false` Stencil will ignore the fact that a component has a `shadow: true`
  139. * flag and serializes it as a scoped component. If set to `true` the component will
  140. * be rendered within a Declarative Shadow DOM.
  141. * @default false
  142. */
  143. serializeShadowRoot?: boolean;
  144. /**
  145. * The `fullDocument` flag determines the format of the rendered output. Set it to true to
  146. * generate a complete HTML document, or false to render only the component.
  147. * @default true
  148. */
  149. fullDocument?: boolean;
  150. }
  151. export interface HydrateFactoryOptions extends SerializeDocumentOptions {
  152. serializeToHtml: boolean;
  153. destroyWindow: boolean;
  154. destroyDocument: boolean;
  155. }
  156. export interface Diagnostic {
  157. absFilePath?: string | undefined;
  158. code?: string;
  159. columnNumber?: number | undefined;
  160. debugText?: string;
  161. header?: string;
  162. language?: string;
  163. level: "error" | "warn" | "info" | "log" | "debug";
  164. lineNumber?: number | undefined;
  165. lines: PrintLine[];
  166. messageText: string;
  167. relFilePath?: string | undefined;
  168. type: string;
  169. }
  170. export interface PrintLine {
  171. lineIndex: number;
  172. lineNumber: number;
  173. text: string;
  174. errorCharStart: number;
  175. errorLength?: number;
  176. }
  177. export interface HydrateResults {
  178. buildId: string;
  179. diagnostics: Diagnostic[];
  180. url: string;
  181. host: string | null;
  182. hostname: string | null;
  183. href: string | null;
  184. port: string | null;
  185. pathname: string | null;
  186. search: string | null;
  187. hash: string | null;
  188. html: string | null;
  189. components: HydrateComponent[];
  190. anchors: HydrateAnchorElement[];
  191. imgs: HydrateImgElement[];
  192. scripts: HydrateScriptElement[];
  193. styles: HydrateStyleElement[];
  194. staticData: HydrateStaticData[];
  195. title: string | null;
  196. hydratedCount: number;
  197. httpStatus: number | null;
  198. }
  199. export interface HydrateComponent {
  200. tag: string;
  201. mode: string;
  202. count: number;
  203. depth: number;
  204. }
  205. export interface HydrateElement {
  206. [attrName: string]: string | undefined;
  207. }
  208. export interface HydrateAnchorElement extends HydrateElement {
  209. href?: string;
  210. target?: string;
  211. }
  212. export interface HydrateImgElement extends HydrateElement {
  213. src?: string;
  214. }
  215. export interface HydrateScriptElement extends HydrateElement {
  216. src?: string;
  217. type?: string;
  218. }
  219. export interface HydrateStyleElement extends HydrateElement {
  220. href?: string;
  221. }
  222. export interface HydrateStaticData {
  223. id: string;
  224. type: string;
  225. content: string;
  226. }
  227. export declare function streamToString(html: string | any, option?: SerializeDocumentOptions): Readable;
  228. export declare function renderToString(html: string | any, options?: SerializeDocumentOptions): Promise<HydrateResults>;
  229. export declare function renderToString(html: string | any, options: SerializeDocumentOptions | undefined, asStream: true): Readable;
  230. export declare function hydrateDocument(doc: any | string, options?: HydrateDocumentOptions): Promise<HydrateResults>;
  231. export declare function hydrateDocument(doc: any | string, options: HydrateDocumentOptions | undefined, asStream?: boolean): Readable;
  232. export declare function serializeDocumentToString(doc: Document, opts: HydrateFactoryOptions): string;
  233. export {};