runner.d.ts 6.0 KB

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