UNPKG

93.4 kBTypeScriptView Raw
1import type { ConfigFlags } from '../cli/config-flags';
2import type { PrerenderUrlResults, PrintLine } from '../internal';
3import type { JsonDocs } from './stencil-public-docs';
4export * from './stencil-public-docs';
5/**
6 * https://stenciljs.com/docs/config/
7 */
8export interface StencilConfig {
9 /**
10 * By default, Stencil will attempt to optimize small scripts by inlining them in HTML. Setting
11 * this flag to `false` will prevent this optimization and keep all scripts separate from HTML.
12 */
13 allowInlineScripts?: boolean;
14 /**
15 * By setting `autoprefixCss` to `true`, Stencil will use the appropriate config to automatically
16 * prefix css. For example, developers can write modern and standard css properties, such as
17 * "transform", and Stencil will automatically add in the prefixed version, such as "-webkit-transform".
18 * As of Stencil v2, autoprefixing CSS is no longer the default.
19 * Defaults to `false`
20 */
21 autoprefixCss?: boolean | any;
22 /**
23 * By default, Stencil will statically analyze the application and generate a component graph of
24 * how all the components are interconnected.
25 *
26 * From the component graph it is able to best decide how components should be grouped
27 * depending on their usage with one another within the app.
28 * By doing so it's able to bundle components together in order to reduce network requests.
29 * However, bundles can be manually generated using the bundles config.
30 *
31 * The bundles config is an array of objects that represent how components are grouped together
32 * in lazy-loaded bundles.
33 * This config is rarely needed as Stencil handles this automatically behind the scenes.
34 */
35 bundles?: ConfigBundle[];
36 /**
37 * Stencil will cache build results in order to speed up rebuilds.
38 * To disable this feature, set enableCache to false.
39 */
40 enableCache?: boolean;
41 /**
42 * The directory where sub-directories will be created for caching when `enableCache` is set
43 * `true` or if using Stencil's Screenshot Connector.
44 *
45 * @default '.stencil'
46 *
47 * @example
48 *
49 * A Stencil config like the following:
50 * ```ts
51 * export const config = {
52 * ...,
53 * enableCache: true,
54 * cacheDir: '.cache',
55 * testing: {
56 * screenshotConnector: 'connector.js'
57 * }
58 * }
59 * ```
60 *
61 * Will result in the following file structure:
62 * ```tree
63 * stencil-project-root
64 * └── .cache
65 * ├── .build <-- Where build related file caching is written
66 * |
67 * └── screenshot-cache.json <-- Where screenshot caching is written
68 * ```
69 */
70 cacheDir?: string;
71 /**
72 * Stencil is traditionally used to compile many components into an app,
73 * and each component comes with its own compartmentalized styles.
74 * However, it's still common to have styles which should be "global" across all components and the website.
75 * A global CSS file is often useful to set CSS Variables.
76 *
77 * Additionally, the globalStyle config can be used to precompile styles with Sass, PostCSS, etc.
78 * Below is an example folder structure containing a webapp's global sass file, named app.css.
79 */
80 globalStyle?: string;
81 /**
82 * When the hashFileNames config is set to true, and it is a production build,
83 * the hashedFileNameLength config is used to determine how many characters the file name's hash should be.
84 */
85 hashedFileNameLength?: number;
86 /**
87 * During production builds, the content of each generated file is hashed to represent the content,
88 * and the hashed value is used as the filename. If the content isn't updated between builds,
89 * then it receives the same filename. When the content is updated, then the filename is different.
90 *
91 * By doing this, deployed apps can "forever-cache" the build directory and take full advantage of
92 * content delivery networks (CDNs) and heavily caching files for faster apps.
93 */
94 hashFileNames?: boolean;
95 /**
96 * The namespace config is a string representing a namespace for the app.
97 * For apps that are not meant to be a library of reusable components,
98 * the default of App is just fine. However, if the app is meant to be consumed
99 * as a third-party library, such as Ionic, a unique namespace is required.
100 */
101 namespace?: string;
102 /**
103 * Stencil is able to take an app's source and compile it to numerous targets,
104 * such as an app to be deployed on an http server, or as a third-party library
105 * to be distributed on npm. By default, Stencil apps have an output target type of www.
106 *
107 * The outputTargets config is an array of objects, with types of www and dist.
108 */
109 outputTargets?: OutputTarget[];
110 /**
111 * The plugins config can be used to add your own rollup plugins.
112 * By default, Stencil does not come with Sass or PostCSS support.
113 * However, either can be added using the plugin array.
114 */
115 plugins?: any[];
116 /**
117 * Generate js source map files for all bundles
118 */
119 sourceMap?: boolean;
120 /**
121 * The srcDir config specifies the directory which should contain the source typescript files
122 * for each component. The standard for Stencil apps is to use src, which is the default.
123 */
124 srcDir?: string;
125 /**
126 * Sets whether or not Stencil should transform path aliases set in a project's
127 * `tsconfig.json` from the assigned module aliases to resolved relative paths.
128 *
129 * This behavior defaults to `true`, but may be opted-out of by setting this flag to `false`.
130 */
131 transformAliasedImportPaths?: boolean;
132 /**
133 * When `true`, we will validate a project's `package.json` based on the output target the user has designated
134 * as `isPrimaryPackageOutputTarget: true` in their Stencil config.
135 */
136 validatePrimaryPackageOutputTarget?: boolean;
137 /**
138 * Passes custom configuration down to the "@rollup/plugin-commonjs" that Stencil uses under the hood.
139 * For further information: https://stenciljs.com/docs/module-bundling
140 */
141 commonjs?: BundlingConfig;
142 /**
143 * Passes custom configuration down to the "@rollup/plugin-node-resolve" that Stencil uses under the hood.
144 * For further information: https://stenciljs.com/docs/module-bundling
145 */
146 nodeResolve?: NodeResolveConfig;
147 /**
148 * Passes custom configuration down to rollup itself, not all rollup options can be overridden.
149 */
150 rollupConfig?: RollupConfig;
151 /**
152 * Sets if the ES5 build should be generated or not. Stencil generates a modern build without ES5,
153 * whereas this setting to `true` will also create es5 builds for both dev and prod modes. Setting
154 * `buildEs5` to `prod` will only build ES5 in prod mode. Basically if the app does not need to run
155 * on legacy browsers (IE11 and Edge 18 and below), it's safe to not build ES5, which will also speed
156 * up build times. Defaults to `false`.
157 */
158 buildEs5?: boolean | 'prod';
159 /**
160 * Sets if the JS browser files are minified or not. Stencil uses `terser` under the hood.
161 * Defaults to `false` in dev mode and `true` in production mode.
162 */
163 minifyJs?: boolean;
164 /**
165 * Sets if the CSS is minified or not.
166 * Defaults to `false` in dev mode and `true` in production mode.
167 */
168 minifyCss?: boolean;
169 /**
170 * Forces Stencil to run in `dev` mode if the value is `true` and `production` mode
171 * if it's `false`.
172 *
173 * Defaults to `false` (ie. production) unless the `--dev` flag is used in the CLI.
174 */
175 devMode?: boolean;
176 /**
177 * Object to provide a custom logger. By default a `logger` is already provided for the
178 * platform the compiler is running on, such as NodeJS or a browser.
179 */
180 logger?: Logger;
181 /**
182 * Config to add extra runtime for DOM features that require more polyfills. Note
183 * that not all DOM APIs are fully polyfilled when using the slot polyfill. These
184 * are opt-in since not all users will require the additional runtime.
185 */
186 extras?: ConfigExtras;
187 /**
188 * The hydrated flag identifies if a component and all of its child components
189 * have finished hydrating. This helps prevent any flash of unstyled content (FOUC)
190 * as various components are asynchronously downloaded and rendered. By default it
191 * will add the `hydrated` CSS class to the element. The `hydratedFlag` config can be used
192 * to change the name of the CSS class, change it to an attribute, or change which
193 * type of CSS properties and values are assigned before and after hydrating. This config
194 * can also be used to not include the hydrated flag at all by setting it to `null`.
195 */
196 hydratedFlag?: HydratedFlag | null;
197 /**
198 * Ionic prefers to hide all components prior to hydration with a style tag appended
199 * to the head of the document containing some `visibility: hidden;` css rules.
200 *
201 * Disabling this will remove the style tag that sets `visibility: hidden;` on all
202 * un-hydrated web components. This more closely follows the HTML spec, and allows
203 * you to set your own fallback content.
204 *
205 */
206 invisiblePrehydration?: boolean;
207 /**
208 * Sets the task queue used by stencil's runtime. The task queue schedules DOM read and writes
209 * across the frames to efficiently render and reduce layout thrashing. By default,
210 * `async` is used. It's recommended to also try each setting to decide which works
211 * best for your use-case. In all cases, if your app has many CPU intensive tasks causing the
212 * main thread to periodically lock-up, it's always recommended to try
213 * [Web Workers](https://stenciljs.com/docs/web-workers) for those tasks.
214 *
215 * - `async`: DOM read and writes are scheduled in the next frame to prevent layout thrashing.
216 * During intensive CPU tasks it will not reschedule rendering to happen in the next frame.
217 * `async` is ideal for most apps, and if the app has many intensive tasks causing the main
218 * thread to lock-up, it's recommended to try [Web Workers](https://stenciljs.com/docs/web-workers)
219 * rather than the congestion async queue.
220 *
221 * - `congestionAsync`: DOM reads and writes are scheduled in the next frame to prevent layout
222 * thrashing. When the app is heavily tasked and the queue becomes congested it will then
223 * split the work across multiple frames to prevent blocking the main thread. However, it can
224 * also introduce unnecessary reflows in some cases, especially during startup. `congestionAsync`
225 * is ideal for apps running animations while also simultaneously executing intensive tasks
226 * which may lock-up the main thread.
227 *
228 * - `immediate`: Makes writeTask() and readTask() callbacks to be executed synchronously. Tasks
229 * are not scheduled to run in the next frame, but do note there is at least one microtask.
230 * The `immediate` setting is ideal for apps that do not provide long running and smooth
231 * animations. Like the async setting, if the app has intensive tasks causing the main thread
232 * to lock-up, it's recommended to try [Web Workers](https://stenciljs.com/docs/web-workers).
233 */
234 taskQueue?: 'async' | 'immediate' | 'congestionAsync';
235 /**
236 * Provide a object of key/values accessible within the app, using the `Env` object.
237 */
238 env?: {
239 [prop: string]: string | undefined;
240 };
241 globalScript?: string;
242 srcIndexHtml?: string;
243 watch?: boolean;
244 testing?: TestingConfig;
245 maxConcurrentWorkers?: number;
246 preamble?: string;
247 rollupPlugins?: {
248 before?: any[];
249 after?: any[];
250 };
251 entryComponentsHint?: string[];
252 buildDist?: boolean;
253 buildLogFilePath?: string;
254 devInspector?: boolean;
255 devServer?: StencilDevServerConfig;
256 sys?: CompilerSystem;
257 tsconfig?: string;
258 validateTypes?: boolean;
259 /**
260 * An array of RegExp patterns that are matched against all source files before adding
261 * to the watch list in watch mode. If the file path matches any of the patterns, when it
262 * is updated, it will not trigger a re-run of tests.
263 */
264 watchIgnoredRegex?: RegExp | RegExp[];
265 /**
266 * Set whether unused dependencies should be excluded from the built output.
267 */
268 excludeUnusedDependencies?: boolean;
269 stencilCoreResolvedId?: string;
270}
271interface ConfigExtrasBase {
272 /**
273 * Experimental flag. Projects that use a Stencil library built using the `dist` output target may have trouble lazily
274 * loading components when using a bundler such as Vite or Parcel. Setting this flag to `true` will change how Stencil
275 * lazily loads components in a way that works with additional bundlers. Setting this flag to `true` will increase
276 * the size of the compiled output. Defaults to `false`.
277 * @deprecated This flag has been deprecated in favor of `enableImportInjection`, which provides the same
278 * functionality. `experimentalImportInjection` will be removed in a future major version of Stencil.
279 */
280 experimentalImportInjection?: boolean;
281 /**
282 * Projects that use a Stencil library built using the `dist` output target may have trouble lazily
283 * loading components when using a bundler such as Vite or Parcel. Setting this flag to `true` will change how Stencil
284 * lazily loads components in a way that works with additional bundlers. Setting this flag to `true` will increase
285 * the size of the compiled output. Defaults to `false`.
286 */
287 enableImportInjection?: boolean;
288 /**
289 * Dispatches component lifecycle events. Mainly used for testing. Defaults to `false`.
290 */
291 lifecycleDOMEvents?: boolean;
292 /**
293 * It is possible to assign data to the actual `<script>` element's `data-opts` property,
294 * which then gets passed to Stencil's initial bootstrap. This feature is only required
295 * for very special cases and rarely needed. Defaults to `false`.
296 */
297 scriptDataOpts?: boolean;
298 /**
299 * When a component is first attached to the DOM, this setting will wait a single tick before
300 * rendering. This works around an Angular issue, where Angular attaches the elements before
301 * settings their initial state, leading to double renders and unnecessary event dispatches.
302 * Defaults to `false`.
303 */
304 initializeNextTick?: boolean;
305 /**
306 * Enables the tagNameTransform option of `defineCustomElements()`, so the component tagName
307 * can be customized at runtime. Defaults to `false`.
308 */
309 tagNameTransform?: boolean;
310}
311type ConfigExtrasSlotFixes<ExperimentalFixesEnabled extends boolean, IndividualFlags extends boolean> = {
312 /**
313 * By default, the slot polyfill does not update `appendChild()` so that it appends
314 * new child nodes into the correct child slot like how shadow dom works. This is an opt-in
315 * polyfill for those who need it when using `element.appendChild(node)` and expecting the
316 * child to be appended in the same location shadow dom would. This is not required for
317 * IE11 or Edge 18, but can be enabled if the app is using `appendChild()`. Defaults to `false`.
318 */
319 appendChildSlotFix?: IndividualFlags;
320 /**
321 * By default, the runtime does not polyfill `cloneNode()` when cloning a component
322 * that uses the slot polyfill. This is an opt-in polyfill for those who need it.
323 * This is not required for IE11 or Edge 18, but can be enabled if the app is using
324 * `cloneNode()` and unexpected node are being cloned due to the slot polyfill
325 * simulating shadow dom. Defaults to `false`.
326 */
327 cloneNodeFix?: IndividualFlags;
328 /**
329 * Experimental flag to align the behavior of invoking `textContent` on a scoped component to act more like a
330 * component that uses the shadow DOM. Defaults to `false`
331 */
332 scopedSlotTextContentFix?: IndividualFlags;
333 /**
334 * For browsers that do not support shadow dom (IE11 and Edge 18 and below), slot is polyfilled
335 * to simulate the same behavior. However, the host element's `childNodes` and `children`
336 * getters are not patched to only show the child nodes and elements of the default slot.
337 * Defaults to `false`.
338 */
339 slotChildNodesFix?: IndividualFlags;
340 /**
341 * Enables all slot-related fixes such as {@link slotChildNodesFix}, and
342 * {@link scopedSlotTextContentFix}.
343 */
344 experimentalSlotFixes?: ExperimentalFixesEnabled;
345};
346export type ConfigExtras = ConfigExtrasBase & (ConfigExtrasSlotFixes<true, true> | ConfigExtrasSlotFixes<false, boolean>);
347export interface Config extends StencilConfig {
348 buildAppCore?: boolean;
349 buildDocs?: boolean;
350 configPath?: string;
351 writeLog?: boolean;
352 devServer?: DevServerConfig;
353 flags?: ConfigFlags;
354 fsNamespace?: string;
355 logLevel?: LogLevel;
356 rootDir?: string;
357 packageJsonFilePath?: string;
358 suppressLogs?: boolean;
359 profile?: boolean;
360 tsCompilerOptions?: any;
361 _isValidated?: boolean;
362 _isTesting?: boolean;
363}
364/**
365 * A 'loose' type useful for wrapping an incomplete / possible malformed
366 * object as we work on getting it comply with a particular Interface T.
367 *
368 * Example:
369 *
370 * ```ts
371 * interface Foo {
372 * bar: string
373 * }
374 *
375 * function validateFoo(foo: Loose<Foo>): Foo {
376 * let validatedFoo = {
377 * ...foo,
378 * bar: foo.bar || DEFAULT_BAR
379 * }
380 *
381 * return validatedFoo
382 * }
383 * ```
384 *
385 * Use this when you need to take user input or something from some other part
386 * of the world that we don't control and transform it into something
387 * conforming to a given interface. For best results, pair with a validation
388 * function as shown in the example.
389 */
390type Loose<T extends Object> = Record<string, any> & Partial<T>;
391/**
392 * A Loose version of the Config interface. This is intended to let us load a partial config
393 * and have type information carry though as we construct an object which is a valid `Config`.
394 */
395export type UnvalidatedConfig = Loose<Config>;
396/**
397 * Helper type to strip optional markers from keys in a type, while preserving other type information for the key.
398 * This type takes a union of keys, K, in type T to allow for the type T to be gradually updated.
399 *
400 * ```typescript
401 * type Foo { bar?: number, baz?: string }
402 * type ReqFieldFoo = RequireFields<Foo, 'bar'>; // { bar: number, baz?: string }
403 * ```
404 */
405type RequireFields<T, K extends keyof T> = T & {
406 [P in K]-?: T[P];
407};
408/**
409 * Fields in {@link Config} to make required for {@link ValidatedConfig}
410 */
411type StrictConfigFields = 'cacheDir' | 'devServer' | 'extras' | 'flags' | 'hydratedFlag' | 'logger' | 'outputTargets' | 'packageJsonFilePath' | 'rollupConfig' | 'rootDir' | 'srcDir' | 'srcIndexHtml' | 'sys' | 'testing' | 'transformAliasedImportPaths' | 'validatePrimaryPackageOutputTarget';
412/**
413 * A version of {@link Config} that makes certain fields required. This type represents a valid configuration entity.
414 * When a configuration is received by the user, it is a bag of unverified data. In order to make stricter guarantees
415 * about the data from a type-safety perspective, this type is intended to be used throughout the codebase once
416 * validations have occurred at runtime.
417 */
418export type ValidatedConfig = RequireFields<Config, StrictConfigFields>;
419export interface HydratedFlag {
420 /**
421 * Defaults to `hydrated`.
422 */
423 name?: string;
424 /**
425 * Can be either `class` or `attribute`. Defaults to `class`.
426 */
427 selector?: 'class' | 'attribute';
428 /**
429 * The CSS property used to show and hide components. Defaults to use the CSS `visibility`
430 * property. Other commonly used CSS properties would be `display` with the `initialValue`
431 * setting as `none`, or `opacity` with the `initialValue` as `0`. Defaults to `visibility`
432 * and the default `initialValue` is `hidden`.
433 */
434 property?: string;
435 /**
436 * This is the CSS value to give all components before it has been hydrated.
437 * Defaults to `hidden`.
438 */
439 initialValue?: string;
440 /**
441 * This is the CSS value to assign once a component has finished hydrating.
442 * This is the CSS value that'll allow the component to show. Defaults to `inherit`.
443 */
444 hydratedValue?: string;
445}
446export interface StencilDevServerConfig {
447 /**
448 * IP address used by the dev server. The default is `0.0.0.0`, which points to all IPv4 addresses
449 * on the local machine, such as `localhost`.
450 */
451 address?: string;
452 /**
453 * Base path to be used by the server. Defaults to the root pathname.
454 */
455 basePath?: string;
456 /**
457 * EXPERIMENTAL!
458 * During development, node modules can be independently requested and bundled, making for
459 * faster build times. This is only available using the Stencil Dev Server throughout
460 * development. Production builds and builds with the `es5` flag will override
461 * this setting to `false`. Default is `false`.
462 */
463 experimentalDevModules?: boolean;
464 /**
465 * If the dev server should respond with gzip compressed content. Defaults to `true`.
466 */
467 gzip?: boolean;
468 /**
469 * When set, the dev server will run via https using the SSL certificate and key you provide
470 * (use `fs` if you want to read them from files).
471 */
472 https?: Credentials;
473 /**
474 * The URL the dev server should first open to. Defaults to `/`.
475 */
476 initialLoadUrl?: string;
477 /**
478 * When `true`, every request to the server will be logged within the terminal.
479 * Defaults to `false`.
480 */
481 logRequests?: boolean;
482 /**
483 * By default, when dev server is started the local dev URL is opened in your default browser.
484 * However, to prevent this URL to be opened change this value to `false`. Defaults to `true`.
485 */
486 openBrowser?: boolean;
487 /**
488 * Sets the server's port. Defaults to `3333`.
489 */
490 port?: number;
491 /**
492 * When files are watched and updated, by default the dev server will use `hmr` (Hot Module Replacement)
493 * to update the page without a full page refresh. To have the page do a full refresh use `pageReload`.
494 * To disable any reloading, use `null`. Defaults to `hmr`.
495 */
496 reloadStrategy?: PageReloadStrategy;
497 /**
498 * Local path to a NodeJs file with a dev server request listener as the default export.
499 * The user's request listener is given the first chance to handle every request the dev server
500 * receives, and can choose to handle it or instead pass it on to the default dev server
501 * by calling `next()`.
502 *
503 * Below is an example of a NodeJs file the `requestListenerPath` config is using.
504 * The request and response arguments are the same as Node's `http` module and `RequestListener`
505 * callback. https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener
506 *
507 * ```js
508 * module.exports = function (req, res, next) {
509 * if (req.url === '/ping') {
510 * // custom response overriding the dev server
511 * res.setHeader('Content-Type', 'text/plain');
512 * res.writeHead(200);
513 * res.end('pong');
514 * } else {
515 * // pass request on to the default dev server
516 * next();
517 * }
518 * };
519 * ```
520 */
521 requestListenerPath?: string;
522 /**
523 * The root directory to serve the files from.
524 */
525 root?: string;
526 /**
527 * If the dev server should Server-Side Render (SSR) each page, meaning it'll dynamically generate
528 * server-side rendered html on each page load. The `--ssr` flag will most commonly be used with
529 * the`--dev --watch --serve` flags during development. Note that this is for development purposes
530 * only, and the built-in dev server should not be used for production. Defaults to `false`.
531 */
532 ssr?: boolean;
533 /**
534 * If the dev server fails to start up within the given timeout (in milliseconds), the startup will
535 * be canceled. Set to zero to disable the timeout. Defaults to `15000`.
536 */
537 startupTimeout?: number;
538 /**
539 * Whether to use the dev server's websocket client or not. Defaults to `true`.
540 */
541 websocket?: boolean;
542 /**
543 * If the dev server should fork a worker for the server process or not. A singled-threaded dev server
544 * is slower, however it is useful for debugging http requests and responses. Defaults to `true`.
545 */
546 worker?: boolean;
547}
548export interface DevServerConfig extends StencilDevServerConfig {
549 browserUrl?: string;
550 devServerDir?: string;
551 /**
552 * A list of glob patterns like `subdir/*.js` to exclude from hot-module
553 * reloading updates.
554 */
555 excludeHmr?: string[];
556 historyApiFallback?: HistoryApiFallback;
557 openBrowser?: boolean;
558 prerenderConfig?: string;
559 protocol?: 'http' | 'https';
560 srcIndexHtml?: string;
561}
562export interface HistoryApiFallback {
563 index?: string;
564 disableDotRule?: boolean;
565}
566export interface DevServerEditor {
567 id: string;
568 name?: string;
569 supported?: boolean;
570 priority?: number;
571}
572export type TaskCommand = 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'prerender' | 'serve' | 'telemetry' | 'test' | 'version';
573export type PageReloadStrategy = 'hmr' | 'pageReload' | null;
574/**
575 * The prerender config is used when prerendering a `www` output target.
576 * Within `stencil.config.ts`, set the path to the prerendering
577 * config file path using the `prerenderConfig` property, such as:
578 *
579 * ```tsx
580 * import { Config } from '@stencil/core';
581 * export const config: Config = {
582 * outputTargets: [
583 * {
584 * type: 'www',
585 * baseUrl: 'https://stenciljs.com/',
586 * prerenderConfig: './prerender.config.ts',
587 * }
588 * ]
589 * };
590 * ```
591 *
592 * The `prerender.config.ts` should export a `config` object using
593 * the `PrerenderConfig` interface.
594 *
595 * ```tsx
596 * import { PrerenderConfig } from '@stencil/core';
597 * export const config: PrerenderConfig = {
598 * ...
599 * };
600 * ```
601 *
602 * For more info: https://stenciljs.com/docs/static-site-generation
603 */
604export interface PrerenderConfig {
605 /**
606 * Run after each `document` is hydrated, but before it is serialized
607 * into an HTML string. Hook is passed the `document` and its `URL`.
608 */
609 afterHydrate?(document: Document, url: URL, results: PrerenderUrlResults): any | Promise<any>;
610 /**
611 * Run before each `document` is hydrated. Hook is passed the `document` it's `URL`.
612 */
613 beforeHydrate?(document: Document, url: URL): any | Promise<any>;
614 /**
615 * Runs after the template Document object has serialize into an
616 * HTML formatted string. Returns an HTML string to be used as the
617 * base template for all prerendered pages.
618 */
619 afterSerializeTemplate?(html: string): string | Promise<string>;
620 /**
621 * Runs before the template Document object is serialize into an
622 * HTML formatted string. Returns the Document to be serialized which
623 * will become the base template html for all prerendered pages.
624 */
625 beforeSerializeTemplate?(document: Document): Document | Promise<Document>;
626 /**
627 * A hook to be used to generate the canonical `<link>` tag
628 * which goes in the `<head>` of every prerendered page. Returning `null`
629 * will not add a canonical url tag to the page.
630 */
631 canonicalUrl?(url: URL): string | null;
632 /**
633 * While prerendering, crawl same-origin URLs found within `<a href>` elements.
634 * Defaults to `true`.
635 */
636 crawlUrls?: boolean;
637 /**
638 * URLs to start the prerendering from. By default the root URL of `/` is used.
639 */
640 entryUrls?: string[];
641 /**
642 * Return `true` the given `<a>` element should be crawled or not.
643 */
644 filterAnchor?(attrs: {
645 [attrName: string]: string;
646 }, base?: URL): boolean;
647 /**
648 * Return `true` if the given URL should be prerendered or not.
649 */
650 filterUrl?(url: URL, base: URL): boolean;
651 /**
652 * Returns the file path which the prerendered HTML content
653 * should be written to.
654 */
655 filePath?(url: URL, filePath: string): string;
656 /**
657 * Returns the hydrate options to use for each individual prerendered page.
658 */
659 hydrateOptions?(url: URL): PrerenderHydrateOptions;
660 /**
661 * Returns the template file's content. The template is the base
662 * HTML used for all prerendered pages.
663 */
664 loadTemplate?(filePath: string): string | Promise<string>;
665 /**
666 * Used to normalize the page's URL from a given a string and the current
667 * page's base URL. Largely used when reading an anchor's `href` attribute
668 * value and normalizing it into a `URL`.
669 */
670 normalizeUrl?(href: string, base: URL): URL;
671 robotsTxt?(opts: RobotsTxtOpts): string | RobotsTxtResults;
672 sitemapXml?(opts: SitemapXmpOpts): string | SitemapXmpResults;
673 /**
674 * Static Site Generated (SSG). Does not include Stencil's client-side
675 * JavaScript, custom elements or preload modules.
676 */
677 staticSite?: boolean;
678 /**
679 * If the prerendered URLs should have a trailing "/"" or not. Defaults to `false`.
680 */
681 trailingSlash?: boolean;
682}
683export interface HydrateDocumentOptions {
684 /**
685 * Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
686 * a random ID will be generated
687 */
688 buildId?: string;
689 /**
690 * Sets the `href` attribute on the `<link rel="canonical">`
691 * tag within the `<head>`. If the value is not defined it will
692 * ensure a canonical link tag is no included in the `<head>`.
693 */
694 canonicalUrl?: string;
695 /**
696 * Include the HTML comments and attributes used by the client-side
697 * JavaScript to read the structure of the HTML and rebuild each
698 * component. Defaults to `true`.
699 */
700 clientHydrateAnnotations?: boolean;
701 /**
702 * Constrain `setTimeout()` to 1ms, but still async. Also
703 * only allows `setInterval()` to fire once, also constrained to 1ms.
704 * Defaults to `true`.
705 */
706 constrainTimeouts?: boolean;
707 /**
708 * Sets `document.cookie`
709 */
710 cookie?: string;
711 /**
712 * Sets the `dir` attribute on the top level `<html>`.
713 */
714 direction?: string;
715 /**
716 * Component tag names listed here will not be prerendered, nor will
717 * hydrated on the client-side. Components listed here will be ignored
718 * as custom elements and treated no differently than a `<div>`.
719 */
720 excludeComponents?: string[];
721 /**
722 * Sets the `lang` attribute on the top level `<html>`.
723 */
724 language?: string;
725 /**
726 * Maximum number of components to hydrate on one page. Defaults to `300`.
727 */
728 maxHydrateCount?: number;
729 /**
730 * Sets `document.referrer`
731 */
732 referrer?: string;
733 /**
734 * Removes every `<script>` element found in the `document`. Defaults to `false`.
735 */
736 removeScripts?: boolean;
737 /**
738 * Removes CSS not used by elements within the `document`. Defaults to `true`.
739 */
740 removeUnusedStyles?: boolean;
741 /**
742 * The url the runtime uses for the resources, such as the assets directory.
743 */
744 resourcesUrl?: string;
745 /**
746 * Prints out runtime console logs to the NodeJS process. Defaults to `false`.
747 */
748 runtimeLogging?: boolean;
749 /**
750 * Component tags listed here will only be prerendered or server-side-rendered
751 * and will not be client-side hydrated. This is useful for components that
752 * are not dynamic and do not need to be defined as a custom element within the
753 * browser. For example, a header or footer component would be a good example that
754 * may not require any client-side JavaScript.
755 */
756 staticComponents?: string[];
757 /**
758 * The amount of milliseconds to wait for a page to finish rendering until
759 * a timeout error is thrown. Defaults to `15000`.
760 */
761 timeout?: number;
762 /**
763 * Sets `document.title`.
764 */
765 title?: string;
766 /**
767 * Sets `location.href`
768 */
769 url?: string;
770 /**
771 * Sets `navigator.userAgent`
772 */
773 userAgent?: string;
774}
775export interface SerializeDocumentOptions extends HydrateDocumentOptions {
776 /**
777 * Runs after the `document` has been hydrated.
778 */
779 afterHydrate?(document: any): any | Promise<any>;
780 /**
781 * Sets an approximate line width the HTML should attempt to stay within.
782 * Note that this is "approximate", in that HTML may often not be able
783 * to be split at an exact line width. Additionally, new lines created
784 * is where HTML naturally already has whitespace, such as before an
785 * attribute or spaces between words. Defaults to `100`.
786 */
787 approximateLineWidth?: number;
788 /**
789 * Runs before the `document` has been hydrated.
790 */
791 beforeHydrate?(document: any): any | Promise<any>;
792 /**
793 * Format the HTML in a nicely indented format.
794 * Defaults to `false`.
795 */
796 prettyHtml?: boolean;
797 /**
798 * Remove quotes from attribute values when possible.
799 * Defaults to `true`.
800 */
801 removeAttributeQuotes?: boolean;
802 /**
803 * Remove the `=""` from standardized `boolean` attributes,
804 * such as `hidden` or `checked`. Defaults to `true`.
805 */
806 removeBooleanAttributeQuotes?: boolean;
807 /**
808 * Remove these standardized attributes when their value is empty:
809 * `class`, `dir`, `id`, `lang`, and `name`, `title`. Defaults to `true`.
810 */
811 removeEmptyAttributes?: boolean;
812 /**
813 * Remove HTML comments. Defaults to `true`.
814 */
815 removeHtmlComments?: boolean;
816}
817export interface HydrateFactoryOptions extends SerializeDocumentOptions {
818 serializeToHtml: boolean;
819 destroyWindow: boolean;
820 destroyDocument: boolean;
821}
822export interface PrerenderHydrateOptions extends SerializeDocumentOptions {
823 /**
824 * Adds `<link rel="modulepreload">` for modules that will eventually be requested.
825 * Defaults to `true`.
826 */
827 addModulePreloads?: boolean;
828 /**
829 * Hash the content of assets, such as images, fonts and css files,
830 * and add the hashed value as `v` querystring. For example,
831 * `/assets/image.png?v=abcd1234`. This allows for assets to be
832 * heavily cached by setting the server's response header with
833 * `Cache-Control: max-age=31536000, immutable`.
834 */
835 hashAssets?: 'querystring';
836 /**
837 * External stylesheets from `<link rel="stylesheet">` are instead inlined
838 * into `<style>` elements. Defaults to `false`.
839 */
840 inlineExternalStyleSheets?: boolean;
841 /**
842 * Minify CSS content within `<style>` elements. Defaults to `true`.
843 */
844 minifyStyleElements?: boolean;
845 /**
846 * Minify JavaScript content within `<script>` elements. Defaults to `true`.
847 */
848 minifyScriptElements?: boolean;
849 /**
850 * Entire `document` should be static. This is useful for specific pages that
851 * should be static, rather than the entire site. If the whole site should be static,
852 * use the `staticSite` property on the prerender config instead. If only certain
853 * components should be static then use `staticComponents` instead.
854 */
855 staticDocument?: boolean;
856}
857export interface RobotsTxtOpts {
858 urls: string[];
859 sitemapUrl: string;
860 baseUrl: string;
861 dir: string;
862}
863export interface RobotsTxtResults {
864 content: string;
865 filePath: string;
866 url: string;
867}
868export interface SitemapXmpOpts {
869 urls: string[];
870 baseUrl: string;
871 dir: string;
872}
873export interface SitemapXmpResults {
874 content: string;
875 filePath: string;
876 url: string;
877}
878/**
879 * Common system used by the compiler. All file reads, writes, access, etc. will all use
880 * this system. Additionally, throughout each build, the compiler will use an internal
881 * in-memory file system as to prevent unnecessary fs reads and writes. At the end of each
882 * build all actions the in-memory fs performed will be written to disk using this system.
883 * A NodeJS based system will use APIs such as `fs` and `crypto`, and a web-based system
884 * will use in-memory Maps and browser APIs. Either way, the compiler itself is unaware
885 * of the actual platform it's being ran on top of.
886 */
887export interface CompilerSystem {
888 name: 'node' | 'in-memory';
889 version: string;
890 events?: BuildEvents;
891 details?: SystemDetails;
892 /**
893 * Add a callback which will be ran when destroy() is called.
894 */
895 addDestroy(cb: () => void): void;
896 /**
897 * Always returns a boolean, does not throw.
898 */
899 access(p: string): Promise<boolean>;
900 /**
901 * SYNC! Always returns a boolean, does not throw.
902 */
903 accessSync(p: string): boolean;
904 applyGlobalPatch?(fromDir: string): Promise<void>;
905 applyPrerenderGlobalPatch?(opts: {
906 devServerHostUrl: string;
907 window: any;
908 }): void;
909 cacheStorage?: CacheStorage;
910 checkVersion?: (logger: Logger, currentVersion: string) => Promise<() => void>;
911 copy?(copyTasks: Required<CopyTask>[], srcDir: string): Promise<CopyResults>;
912 /**
913 * Always returns a boolean if the files were copied or not. Does not throw.
914 */
915 copyFile(src: string, dst: string): Promise<boolean>;
916 /**
917 * Used to destroy any listeners, file watchers or child processes.
918 */
919 destroy(): Promise<void>;
920 /**
921 * Does not throw.
922 */
923 createDir(p: string, opts?: CompilerSystemCreateDirectoryOptions): Promise<CompilerSystemCreateDirectoryResults>;
924 /**
925 * SYNC! Does not throw.
926 */
927 createDirSync(p: string, opts?: CompilerSystemCreateDirectoryOptions): CompilerSystemCreateDirectoryResults;
928 homeDir(): string;
929 /**
930 * Used to determine if the current context of the terminal is TTY.
931 */
932 isTTY(): boolean;
933 /**
934 * Each platform as a different way to dynamically import modules.
935 */
936 dynamicImport?(p: string): Promise<any>;
937 /**
938 * Creates the worker controller for the current system.
939 */
940 createWorkerController?(maxConcurrentWorkers: number): WorkerMainController;
941 encodeToBase64(str: string): string;
942 /**
943 * @deprecated
944 */
945 ensureDependencies?(opts: {
946 rootDir: string;
947 logger: Logger;
948 dependencies: CompilerDependency[];
949 }): Promise<{
950 stencilPath: string;
951 diagnostics: Diagnostic[];
952 }>;
953 /**
954 * @deprecated
955 */
956 ensureResources?(opts: {
957 rootDir: string;
958 logger: Logger;
959 dependencies: CompilerDependency[];
960 }): Promise<void>;
961 /**
962 * process.exit()
963 */
964 exit(exitCode: number): Promise<void>;
965 /**
966 * Optionally provide a fetch() function rather than using the built-in fetch().
967 * First arg is a url string or Request object (RequestInfo).
968 * Second arg is the RequestInit. Returns the Response object
969 */
970 fetch?(input: string | any, init?: any): Promise<any>;
971 /**
972 * Generates a sha1 digest encoded as HEX
973 */
974 generateContentHash?(content: string | any, length?: number): Promise<string>;
975 /**
976 * Generates a sha1 digest encoded as HEX from a file path
977 */
978 generateFileHash?(filePath: string | any, length?: number): Promise<string>;
979 /**
980 * Get the current directory.
981 */
982 getCurrentDirectory(): string;
983 /**
984 * The compiler's executing path.
985 */
986 getCompilerExecutingPath(): string;
987 /**
988 * The dev server's executing path.
989 */
990 getDevServerExecutingPath?(): string;
991 getEnvironmentVar?(key: string): string;
992 /**
993 * Gets the absolute file path when for a dependency module.
994 */
995 getLocalModulePath(opts: {
996 rootDir: string;
997 moduleId: string;
998 path: string;
999 }): string;
1000 /**
1001 * Gets the full url when requesting a dependency module to fetch from a CDN.
1002 */
1003 getRemoteModuleUrl(opts: {
1004 moduleId: string;
1005 path?: string;
1006 version?: string;
1007 }): string;
1008 /**
1009 * Async glob task. Only available in NodeJS compiler system.
1010 */
1011 glob?(pattern: string, options: {
1012 cwd?: string;
1013 nodir?: boolean;
1014 [key: string]: any;
1015 }): Promise<string[]>;
1016 /**
1017 * The number of logical processors available to run threads on the user's computer (cpus).
1018 */
1019 hardwareConcurrency: number;
1020 /**
1021 * Tests if the path is a symbolic link or not. Always resolves a boolean. Does not throw.
1022 */
1023 isSymbolicLink(p: string): Promise<boolean>;
1024 lazyRequire?: LazyRequire;
1025 nextTick(cb: () => void): void;
1026 /**
1027 * Normalize file system path.
1028 */
1029 normalizePath(p: string): string;
1030 onProcessInterrupt?(cb: () => void): void;
1031 parseYarnLockFile?: (content: string) => {
1032 type: 'success' | 'merge' | 'conflict';
1033 object: any;
1034 };
1035 platformPath: PlatformPath;
1036 /**
1037 * All return paths are full normalized paths, not just the basenames. Always returns an array, does not throw.
1038 */
1039 readDir(p: string): Promise<string[]>;
1040 /**
1041 * SYNC! All return paths are full normalized paths, not just the basenames. Always returns an array, does not throw.
1042 */
1043 readDirSync(p: string): string[];
1044 /**
1045 * Returns undefined if file is not found. Does not throw.
1046 */
1047 readFile(p: string): Promise<string>;
1048 readFile(p: string, encoding: 'utf8'): Promise<string>;
1049 readFile(p: string, encoding: 'binary'): Promise<any>;
1050 /**
1051 * SYNC! Returns undefined if file is not found. Does not throw.
1052 */
1053 readFileSync(p: string, encoding?: string): string;
1054 /**
1055 * Does not throw.
1056 */
1057 realpath(p: string): Promise<CompilerSystemRealpathResults>;
1058 /**
1059 * SYNC! Does not throw.
1060 */
1061 realpathSync(p: string): CompilerSystemRealpathResults;
1062 /**
1063 * Remove a callback which will be ran when destroy() is called.
1064 */
1065 removeDestroy(cb: () => void): void;
1066 /**
1067 * Rename old path to new path. Does not throw.
1068 */
1069 rename(oldPath: string, newPath: string): Promise<CompilerSystemRenameResults>;
1070 resolveModuleId?(opts: ResolveModuleIdOptions): Promise<ResolveModuleIdResults>;
1071 resolvePath(p: string): string;
1072 /**
1073 * Does not throw.
1074 */
1075 removeDir(p: string, opts?: CompilerSystemRemoveDirectoryOptions): Promise<CompilerSystemRemoveDirectoryResults>;
1076 /**
1077 * SYNC! Does not throw.
1078 */
1079 removeDirSync(p: string, opts?: CompilerSystemRemoveDirectoryOptions): CompilerSystemRemoveDirectoryResults;
1080 /**
1081 * Does not throw.
1082 */
1083 removeFile(p: string): Promise<CompilerSystemRemoveFileResults>;
1084 /**
1085 * SYNC! Does not throw.
1086 */
1087 removeFileSync(p: string): CompilerSystemRemoveFileResults;
1088 setupCompiler?: (c: {
1089 ts: any;
1090 }) => void;
1091 /**
1092 * Always returns an object. Does not throw. Check for "error" property if there's an error.
1093 */
1094 stat(p: string): Promise<CompilerFsStats>;
1095 /**
1096 * SYNC! Always returns an object. Does not throw. Check for "error" property if there's an error.
1097 */
1098 statSync(p: string): CompilerFsStats;
1099 tmpDirSync(): string;
1100 watchDirectory?(p: string, callback: CompilerFileWatcherCallback, recursive?: boolean): CompilerFileWatcher;
1101 /**
1102 * A `watchFile` implementation in order to hook into the rest of the {@link CompilerSystem} implementation that is
1103 * used when running Stencil's compiler in "watch mode".
1104 *
1105 * It is analogous to TypeScript's `watchFile` implementation.
1106 *
1107 * Note, this function may be called for full builds of Stencil projects by the TypeScript compiler. It should not
1108 * assume that it will only be called in watch mode.
1109 *
1110 * This function should not perform any file watcher registration itself. Each `path` provided to it when called
1111 * should already have been registered as a file to watch.
1112 *
1113 * @param path the path to the file that is being watched
1114 * @param callback a callback to invoke when a file that is being watched has changed in some way
1115 * @returns an object with a method for unhooking the file watcher from the system
1116 */
1117 watchFile?(path: string, callback: CompilerFileWatcherCallback): CompilerFileWatcher;
1118 /**
1119 * How many milliseconds to wait after a change before calling watch callbacks.
1120 */
1121 watchTimeout?: number;
1122 /**
1123 * Does not throw.
1124 */
1125 writeFile(p: string, content: string): Promise<CompilerSystemWriteFileResults>;
1126 /**
1127 * SYNC! Does not throw.
1128 */
1129 writeFileSync(p: string, content: string): CompilerSystemWriteFileResults;
1130}
1131export interface TranspileOnlyResults {
1132 diagnostics: Diagnostic[];
1133 output: string;
1134 sourceMap: any;
1135}
1136export interface ParsedPath {
1137 root: string;
1138 dir: string;
1139 base: string;
1140 ext: string;
1141 name: string;
1142}
1143export interface PlatformPath {
1144 normalize(p: string): string;
1145 join(...paths: string[]): string;
1146 resolve(...pathSegments: string[]): string;
1147 isAbsolute(p: string): boolean;
1148 relative(from: string, to: string): string;
1149 dirname(p: string): string;
1150 basename(p: string, ext?: string): string;
1151 extname(p: string): string;
1152 parse(p: string): ParsedPath;
1153 sep: string;
1154 delimiter: string;
1155 posix: any;
1156 win32: any;
1157}
1158export interface CompilerDependency {
1159 name: string;
1160 version: string;
1161 main: string;
1162 resources?: string[];
1163}
1164export interface ResolveModuleIdOptions {
1165 moduleId: string;
1166 containingFile?: string;
1167 exts?: string[];
1168 packageFilter?: (pkg: any) => void;
1169}
1170export interface ResolveModuleIdResults {
1171 moduleId: string;
1172 resolveId: string;
1173 pkgData: {
1174 name: string;
1175 version: string;
1176 [key: string]: any;
1177 };
1178 pkgDirPath: string;
1179}
1180export interface WorkerMainController {
1181 send(...args: any[]): Promise<any>;
1182 handler(name: string): (...args: any[]) => Promise<any>;
1183 destroy(): void;
1184 maxWorkers: number;
1185}
1186export interface CopyResults {
1187 diagnostics: Diagnostic[];
1188 filePaths: string[];
1189 dirPaths: string[];
1190}
1191export interface SystemDetails {
1192 cpuModel: string;
1193 freemem(): number;
1194 platform: 'darwin' | 'windows' | 'linux' | '';
1195 release: string;
1196 totalmem: number;
1197}
1198export interface BuildOnEvents {
1199 on(cb: (eventName: CompilerEventName, data: any) => void): BuildOnEventRemove;
1200 on(eventName: CompilerEventFileAdd, cb: (path: string) => void): BuildOnEventRemove;
1201 on(eventName: CompilerEventFileDelete, cb: (path: string) => void): BuildOnEventRemove;
1202 on(eventName: CompilerEventFileUpdate, cb: (path: string) => void): BuildOnEventRemove;
1203 on(eventName: CompilerEventDirAdd, cb: (path: string) => void): BuildOnEventRemove;
1204 on(eventName: CompilerEventDirDelete, cb: (path: string) => void): BuildOnEventRemove;
1205 on(eventName: CompilerEventBuildStart, cb: (buildStart: CompilerBuildStart) => void): BuildOnEventRemove;
1206 on(eventName: CompilerEventBuildFinish, cb: (buildResults: CompilerBuildResults) => void): BuildOnEventRemove;
1207 on(eventName: CompilerEventBuildLog, cb: (buildLog: BuildLog) => void): BuildOnEventRemove;
1208 on(eventName: CompilerEventBuildNoChange, cb: () => void): BuildOnEventRemove;
1209}
1210export interface BuildEmitEvents {
1211 emit(eventName: CompilerEventName, path: string): void;
1212 emit(eventName: CompilerEventFileAdd, path: string): void;
1213 emit(eventName: CompilerEventFileDelete, path: string): void;
1214 emit(eventName: CompilerEventFileUpdate, path: string): void;
1215 emit(eventName: CompilerEventDirAdd, path: string): void;
1216 emit(eventName: CompilerEventDirDelete, path: string): void;
1217 emit(eventName: CompilerEventBuildStart, buildStart: CompilerBuildStart): void;
1218 emit(eventName: CompilerEventBuildFinish, buildResults: CompilerBuildResults): void;
1219 emit(eventName: CompilerEventBuildNoChange, buildNoChange: BuildNoChangeResults): void;
1220 emit(eventName: CompilerEventBuildLog, buildLog: BuildLog): void;
1221 emit(eventName: CompilerEventFsChange, fsWatchResults: FsWatchResults): void;
1222}
1223export interface FsWatchResults {
1224 dirsAdded: string[];
1225 dirsDeleted: string[];
1226 filesUpdated: string[];
1227 filesAdded: string[];
1228 filesDeleted: string[];
1229}
1230export interface BuildLog {
1231 buildId: number;
1232 messages: string[];
1233 progress: number;
1234}
1235export interface BuildNoChangeResults {
1236 buildId: number;
1237 noChange: boolean;
1238}
1239export interface CompilerBuildResults {
1240 buildId: number;
1241 componentGraph?: BuildResultsComponentGraph;
1242 diagnostics: Diagnostic[];
1243 dirsAdded: string[];
1244 dirsDeleted: string[];
1245 duration: number;
1246 filesAdded: string[];
1247 filesChanged: string[];
1248 filesDeleted: string[];
1249 filesUpdated: string[];
1250 hasError: boolean;
1251 hasSuccessfulBuild: boolean;
1252 hmr?: HotModuleReplacement;
1253 hydrateAppFilePath?: string;
1254 isRebuild: boolean;
1255 namespace: string;
1256 outputs: BuildOutput[];
1257 rootDir: string;
1258 srcDir: string;
1259 timestamp: string;
1260}
1261export interface BuildResultsComponentGraph {
1262 [scopeId: string]: string[];
1263}
1264export interface BuildOutput {
1265 type: string;
1266 files: string[];
1267}
1268export interface HotModuleReplacement {
1269 componentsUpdated?: string[];
1270 excludeHmr?: string[];
1271 externalStylesUpdated?: string[];
1272 imagesUpdated?: string[];
1273 indexHtmlUpdated?: boolean;
1274 inlineStylesUpdated?: HmrStyleUpdate[];
1275 reloadStrategy: PageReloadStrategy;
1276 scriptsAdded?: string[];
1277 scriptsDeleted?: string[];
1278 serviceWorkerUpdated?: boolean;
1279 versionId?: string;
1280}
1281export interface HmrStyleUpdate {
1282 styleId: string;
1283 styleTag: string;
1284 styleText: string;
1285}
1286export type BuildOnEventRemove = () => boolean;
1287export interface BuildEvents extends BuildOnEvents, BuildEmitEvents {
1288 unsubscribeAll(): void;
1289}
1290export interface CompilerBuildStart {
1291 buildId: number;
1292 timestamp: string;
1293}
1294/**
1295 * A type describing a function to call when an event is emitted by a file watcher
1296 * @param fileName the path of the file tied to event
1297 * @param eventKind a variant describing the type of event that was emitter (added, edited, etc.)
1298 */
1299export type CompilerFileWatcherCallback = (fileName: string, eventKind: CompilerFileWatcherEvent) => void;
1300/**
1301 * A type describing the different types of events that Stencil expects may happen when a file being watched is altered
1302 * in some way
1303 */
1304export type CompilerFileWatcherEvent = CompilerEventFileAdd | CompilerEventFileDelete | CompilerEventFileUpdate | CompilerEventDirAdd | CompilerEventDirDelete;
1305export type CompilerEventName = CompilerEventFsChange | CompilerEventFileUpdate | CompilerEventFileAdd | CompilerEventFileDelete | CompilerEventDirAdd | CompilerEventDirDelete | CompilerEventBuildStart | CompilerEventBuildFinish | CompilerEventBuildNoChange | CompilerEventBuildLog;
1306export type CompilerEventFsChange = 'fsChange';
1307export type CompilerEventFileUpdate = 'fileUpdate';
1308export type CompilerEventFileAdd = 'fileAdd';
1309export type CompilerEventFileDelete = 'fileDelete';
1310export type CompilerEventDirAdd = 'dirAdd';
1311export type CompilerEventDirDelete = 'dirDelete';
1312export type CompilerEventBuildStart = 'buildStart';
1313export type CompilerEventBuildFinish = 'buildFinish';
1314export type CompilerEventBuildLog = 'buildLog';
1315export type CompilerEventBuildNoChange = 'buildNoChange';
1316export interface CompilerFileWatcher {
1317 close(): void | Promise<void>;
1318}
1319export interface CompilerFsStats {
1320 /**
1321 * If it's a directory. `false` if there was an error.
1322 */
1323 isDirectory: boolean;
1324 /**
1325 * If it's a file. `false` if there was an error.
1326 */
1327 isFile: boolean;
1328 /**
1329 * If it's a symlink. `false` if there was an error.
1330 */
1331 isSymbolicLink: boolean;
1332 /**
1333 * The size of the file in bytes. `0` for directories or if there was an error.
1334 */
1335 size: number;
1336 /**
1337 * The timestamp indicating the last time this file was modified expressed in milliseconds since the POSIX Epoch.
1338 */
1339 mtimeMs?: number;
1340 /**
1341 * Error if there was one, otherwise `null`. `stat` and `statSync` do not throw errors but always returns this interface.
1342 */
1343 error: any;
1344}
1345export interface CompilerSystemCreateDirectoryOptions {
1346 /**
1347 * Indicates whether parent directories should be created.
1348 * @default false
1349 */
1350 recursive?: boolean;
1351 /**
1352 * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
1353 * @default 0o777.
1354 */
1355 mode?: number;
1356}
1357export interface CompilerSystemCreateDirectoryResults {
1358 basename: string;
1359 dirname: string;
1360 path: string;
1361 newDirs: string[];
1362 error: any;
1363}
1364export interface CompilerSystemRemoveDirectoryOptions {
1365 /**
1366 * Indicates whether child files and subdirectories should be removed.
1367 * @default false
1368 */
1369 recursive?: boolean;
1370}
1371export interface CompilerSystemRemoveDirectoryResults {
1372 basename: string;
1373 dirname: string;
1374 path: string;
1375 removedDirs: string[];
1376 removedFiles: string[];
1377 error: any;
1378}
1379export interface CompilerSystemRenameResults extends CompilerSystemRenamedPath {
1380 renamed: CompilerSystemRenamedPath[];
1381 oldDirs: string[];
1382 oldFiles: string[];
1383 newDirs: string[];
1384 newFiles: string[];
1385 error: any;
1386}
1387export interface CompilerSystemRenamedPath {
1388 oldPath: string;
1389 newPath: string;
1390 isFile: boolean;
1391 isDirectory: boolean;
1392}
1393export interface CompilerSystemRealpathResults {
1394 path: string;
1395 error: any;
1396}
1397export interface CompilerSystemRemoveFileResults {
1398 basename: string;
1399 dirname: string;
1400 path: string;
1401 error: any;
1402}
1403export interface CompilerSystemWriteFileResults {
1404 path: string;
1405 error: any;
1406}
1407export interface Credentials {
1408 key: string;
1409 cert: string;
1410}
1411export interface ConfigBundle {
1412 components: string[];
1413}
1414export interface CopyTask {
1415 src: string;
1416 dest?: string;
1417 warn?: boolean;
1418 keepDirStructure?: boolean;
1419}
1420export interface BundlingConfig {
1421 /**
1422 * @deprecated the `namedExports` field is no longer honored by `@rollup/plugin-commonjs` and is not used by Stencil.
1423 * This field can be safely removed from your Stencil configuration file.
1424 */
1425 namedExports?: {
1426 [key: string]: string[];
1427 };
1428}
1429export interface NodeResolveConfig {
1430 module?: boolean;
1431 jsnext?: boolean;
1432 main?: boolean;
1433 browser?: boolean;
1434 extensions?: string[];
1435 preferBuiltins?: boolean;
1436 jail?: string;
1437 only?: Array<string | RegExp>;
1438 modulesOnly?: boolean;
1439 /**
1440 * @see https://github.com/browserify/resolve#resolveid-opts-cb
1441 */
1442 customResolveOptions?: {
1443 basedir?: string;
1444 package?: string;
1445 extensions?: string[];
1446 readFile?: Function;
1447 isFile?: Function;
1448 isDirectory?: Function;
1449 packageFilter?: Function;
1450 pathFilter?: Function;
1451 paths?: Function | string[];
1452 moduleDirectory?: string | string[];
1453 preserveSymlinks?: boolean;
1454 };
1455}
1456export interface RollupConfig {
1457 inputOptions?: RollupInputOptions;
1458 outputOptions?: RollupOutputOptions;
1459}
1460export interface RollupInputOptions {
1461 context?: string;
1462 moduleContext?: ((id: string) => string) | {
1463 [id: string]: string;
1464 };
1465 treeshake?: boolean;
1466}
1467export interface RollupOutputOptions {
1468 globals?: {
1469 [name: string]: string;
1470 } | ((name: string) => string);
1471}
1472export interface Testing {
1473 run(opts: TestingRunOptions): Promise<boolean>;
1474 destroy(): Promise<void>;
1475}
1476/**
1477 * Options for initiating a run of Stencil tests (spec and/or end-to-end)
1478 */
1479export interface TestingRunOptions {
1480 /**
1481 * If true, run end-to-end tests
1482 */
1483 e2e?: boolean;
1484 /**
1485 * If true, run screenshot tests
1486 */
1487 screenshot?: boolean;
1488 /**
1489 * If true, run spec tests
1490 */
1491 spec?: boolean;
1492 /**
1493 * If true, update 'golden' screenshots. Otherwise, compare against priori.
1494 */
1495 updateScreenshot?: boolean;
1496}
1497export interface JestConfig {
1498 /**
1499 * This option tells Jest that all imported modules in your tests should be mocked automatically.
1500 * All modules used in your tests will have a replacement implementation, keeping the API surface. Default: false
1501 */
1502 automock?: boolean;
1503 /**
1504 * By default, Jest runs all tests and produces all errors into the console upon completion.
1505 * The bail config option can be used here to have Jest stop running tests after the first failure. Default: false
1506 */
1507 bail?: boolean;
1508 /**
1509 * The directory where Jest should store its cached dependency information. Jest attempts to scan your dependency tree once (up-front)
1510 * and cache it in order to ease some of the filesystem raking that needs to happen while running tests. This config option lets you
1511 * customize where Jest stores that cache data on disk. Default: "/tmp/<path>"
1512 */
1513 cacheDirectory?: string;
1514 /**
1515 * Automatically clear mock calls and instances between every test. Equivalent to calling jest.clearAllMocks()
1516 * between each test. This does not remove any mock implementation that may have been provided. Default: false
1517 */
1518 clearMocks?: boolean;
1519 /**
1520 * Indicates whether the coverage information should be collected while executing the test. Because this retrofits all
1521 * executed files with coverage collection statements, it may significantly slow down your tests. Default: false
1522 */
1523 collectCoverage?: boolean;
1524 /**
1525 * An array of glob patterns indicating a set of files for which coverage information should be collected.
1526 * If a file matches the specified glob pattern, coverage information will be collected for it even if no tests exist
1527 * for this file and it's never required in the test suite. Default: undefined
1528 */
1529 collectCoverageFrom?: any[];
1530 /**
1531 * The directory where Jest should output its coverage files. Default: undefined
1532 */
1533 coverageDirectory?: string;
1534 /**
1535 * An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path matches
1536 * any of the patterns, coverage information will be skipped. These pattern strings match against the full path.
1537 * Use the <rootDir> string token to include the path to your project's root directory to prevent it from accidentally
1538 * ignoring all of your files in different environments that may have different root directories.
1539 * Example: ["<rootDir>/build/", "<rootDir>/node_modules/"]. Default: ["/node_modules/"]
1540 */
1541 coveragePathIgnorePatterns?: any[];
1542 /**
1543 * A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
1544 * Default: `["json", "lcov", "text"]`
1545 */
1546 coverageReporters?: any[];
1547 /**
1548 * This will be used to configure minimum threshold enforcement for coverage results. Thresholds can be specified as global,
1549 * as a glob, and as a directory or file path. If thresholds aren't met, jest will fail. Thresholds specified as a positive
1550 * number are taken to be the minimum percentage required. Thresholds specified as a negative number represent the maximum
1551 * number of uncovered entities allowed. Default: undefined
1552 */
1553 coverageThreshold?: any;
1554 errorOnDeprecated?: boolean;
1555 forceCoverageMatch?: any[];
1556 globals?: any;
1557 globalSetup?: string;
1558 globalTeardown?: string;
1559 /**
1560 * An array of directory names to be searched recursively up from the requiring module's location. Setting this option will
1561 * override the default, if you wish to still search node_modules for packages include it along with any other
1562 * options: ["node_modules", "bower_components"]. Default: ["node_modules"]
1563 */
1564 moduleDirectories?: string[];
1565 /**
1566 * An array of file extensions your modules use. If you require modules without specifying a file extension,
1567 * these are the extensions Jest will look for. Default: ['ts', 'tsx', 'js', 'json']
1568 */
1569 moduleFileExtensions?: string[];
1570 moduleNameMapper?: any;
1571 modulePaths?: any[];
1572 modulePathIgnorePatterns?: any[];
1573 notify?: boolean;
1574 notifyMode?: string;
1575 preset?: string;
1576 prettierPath?: string;
1577 projects?: any;
1578 reporters?: any;
1579 resetMocks?: boolean;
1580 resetModules?: boolean;
1581 resolver?: string;
1582 restoreMocks?: string;
1583 rootDir?: string;
1584 roots?: any[];
1585 runner?: string;
1586 /**
1587 * The paths to modules that run some code to configure or set up the testing environment before each test.
1588 * Since every test runs in its own environment, these scripts will be executed in the testing environment
1589 * immediately before executing the test code itself. Default: []
1590 */
1591 setupFiles?: string[];
1592 setupFilesAfterEnv?: string[];
1593 snapshotSerializers?: any[];
1594 testEnvironment?: string;
1595 testEnvironmentOptions?: any;
1596 testMatch?: string[];
1597 testPathIgnorePatterns?: string[];
1598 testPreset?: string;
1599 testRegex?: string;
1600 testResultsProcessor?: string;
1601 testRunner?: string;
1602 testURL?: string;
1603 timers?: string;
1604 transform?: {
1605 [key: string]: string;
1606 };
1607 transformIgnorePatterns?: any[];
1608 unmockedModulePathPatterns?: any[];
1609 verbose?: boolean;
1610 watchPathIgnorePatterns?: any[];
1611}
1612export interface TestingConfig extends JestConfig {
1613 /**
1614 * The `allowableMismatchedPixels` value is used to determine an acceptable
1615 * number of pixels that can be mismatched before the image is considered
1616 * to have changes. Realistically, two screenshots representing the same
1617 * content may have a small number of pixels that are not identical due to
1618 * anti-aliasing, which is perfectly normal. If the `allowableMismatchedRatio`
1619 * is provided it will take precedence, otherwise `allowableMismatchedPixels`
1620 * will be used.
1621 */
1622 allowableMismatchedPixels?: number;
1623 /**
1624 * The `allowableMismatchedRatio` ranges from `0` to `1` and is used to
1625 * determine an acceptable ratio of pixels that can be mismatched before
1626 * the image is considered to have changes. Realistically, two screenshots
1627 * representing the same content may have a small number of pixels that
1628 * are not identical due to anti-aliasing, which is perfectly normal. The
1629 * `allowableMismatchedRatio` is the number of pixels that were mismatched,
1630 * divided by the total number of pixels in the screenshot. For example,
1631 * a ratio value of `0.06` means 6% of the pixels can be mismatched before
1632 * the image is considered to have changes. If the `allowableMismatchedRatio`
1633 * is provided it will take precedence, otherwise `allowableMismatchedPixels`
1634 * will be used.
1635 */
1636 allowableMismatchedRatio?: number;
1637 /**
1638 * Matching threshold while comparing two screenshots. Value ranges from `0` to `1`.
1639 * Smaller values make the comparison more sensitive. The `pixelmatchThreshold`
1640 * value helps to ignore anti-aliasing. Default: `0.1`
1641 */
1642 pixelmatchThreshold?: number;
1643 /**
1644 * Additional arguments to pass to the browser instance.
1645 */
1646 browserArgs?: string[];
1647 /**
1648 * Path to a Chromium or Chrome executable to run instead of the bundled Chromium.
1649 */
1650 browserExecutablePath?: string;
1651 /**
1652 * Url of remote Chrome instance to use instead of local Chrome.
1653 */
1654 browserWSEndpoint?: string;
1655 /**
1656 * Whether to run browser e2e tests in headless mode.
1657 *
1658 * Starting with Chrome v112, a new headless mode was introduced.
1659 * The new headless mode unifies the "headful" and "headless" code paths in the Chrome distributable.
1660 *
1661 * To enable the "new" headless mode, a string value of "new" must be provided.
1662 * To use the "old" headless mode, a boolean value of `true` must be provided.
1663 * To use "headful" mode, a boolean value of `false` must be provided.
1664 *
1665 * Defaults to true.
1666 */
1667 browserHeadless?: boolean | 'new';
1668 /**
1669 * Slows down e2e browser operations by the specified amount of milliseconds.
1670 * Useful so that you can see what is going on.
1671 */
1672 browserSlowMo?: number;
1673 /**
1674 * By default, all E2E pages wait until the "load" event, this global setting can be used
1675 * to change the default `waitUntil` behavior.
1676 */
1677 browserWaitUntil?: 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
1678 /**
1679 * Whether to auto-open a DevTools panel for each tab.
1680 * If this option is true, the headless option will be set false
1681 */
1682 browserDevtools?: boolean;
1683 /**
1684 * Array of browser emulations to be used during _screenshot_ tests. A full screenshot
1685 * test is ran for each emulation.
1686 *
1687 * To emulate a device display for your e2e tests, use the `setViewport` method on a test's E2E page.
1688 * An example can be found in [the Stencil docs](https://stenciljs.com/docs/end-to-end-testing#emulate-a-display).
1689 */
1690 emulate?: EmulateConfig[];
1691 /**
1692 * Path to the Screenshot Connector module.
1693 */
1694 screenshotConnector?: string;
1695 /**
1696 * Amount of time in milliseconds to wait before a screenshot is taken.
1697 */
1698 waitBeforeScreenshot?: number;
1699}
1700export interface EmulateConfig {
1701 /**
1702 * Predefined device descriptor name, such as "iPhone X" or "Nexus 10".
1703 * For a complete list please see: https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts
1704 */
1705 device?: string;
1706 /**
1707 * User-Agent to be used. Defaults to the user-agent of the installed Puppeteer version.
1708 */
1709 userAgent?: string;
1710 viewport?: EmulateViewport;
1711}
1712export interface EmulateViewport {
1713 /**
1714 * Page width in pixels.
1715 */
1716 width: number;
1717 /**
1718 * page height in pixels.
1719 */
1720 height: number;
1721 /**
1722 * Specify device scale factor (can be thought of as dpr). Defaults to 1.
1723 */
1724 deviceScaleFactor?: number;
1725 /**
1726 * Whether the meta viewport tag is taken into account. Defaults to false.
1727 */
1728 isMobile?: boolean;
1729 /**
1730 * Specifies if viewport supports touch events. Defaults to false
1731 */
1732 hasTouch?: boolean;
1733 /**
1734 * Specifies if viewport is in landscape mode. Defaults to false.
1735 */
1736 isLandscape?: boolean;
1737}
1738/**
1739 * This sets the log level hierarchy for our terminal logger, ranging from
1740 * most to least verbose.
1741 *
1742 * Ordering the levels like this lets us easily check whether we should log a
1743 * message at a given time. For instance, if the log level is set to `'warn'`,
1744 * then anything passed to the logger with level `'warn'` or `'error'` should
1745 * be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
1746 *
1747 * If we have a current log level `currentLevel` and a message with level
1748 * `msgLevel` is passed to the logger, we can determine whether or not we should
1749 * log it by checking if the log level on the message is further up or at the
1750 * same level in the hierarchy than `currentLevel`, like so:
1751 *
1752 * ```ts
1753 * LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
1754 * ```
1755 *
1756 * NOTE: for the reasons described above, do not change the order of the entries
1757 * in this array without good reason!
1758 */
1759export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
1760export type LogLevel = (typeof LOG_LEVELS)[number];
1761/**
1762 * Common logger to be used by the compiler, dev-server and CLI. The CLI will use a
1763 * NodeJS based console logging and colors, and the web will use browser based
1764 * logs and colors.
1765 */
1766export interface Logger {
1767 enableColors: (useColors: boolean) => void;
1768 setLevel: (level: LogLevel) => void;
1769 getLevel: () => LogLevel;
1770 debug: (...msg: any[]) => void;
1771 info: (...msg: any[]) => void;
1772 warn: (...msg: any[]) => void;
1773 error: (...msg: any[]) => void;
1774 createTimeSpan: (startMsg: string, debug?: boolean, appendTo?: string[]) => LoggerTimeSpan;
1775 printDiagnostics: (diagnostics: Diagnostic[], cwd?: string) => void;
1776 red: (msg: string) => string;
1777 green: (msg: string) => string;
1778 yellow: (msg: string) => string;
1779 blue: (msg: string) => string;
1780 magenta: (msg: string) => string;
1781 cyan: (msg: string) => string;
1782 gray: (msg: string) => string;
1783 bold: (msg: string) => string;
1784 dim: (msg: string) => string;
1785 bgRed: (msg: string) => string;
1786 emoji: (e: string) => string;
1787 setLogFilePath?: (p: string) => void;
1788 writeLogs?: (append: boolean) => void;
1789 createLineUpdater?: () => Promise<LoggerLineUpdater>;
1790}
1791export interface LoggerLineUpdater {
1792 update(text: string): Promise<void>;
1793 stop(): Promise<void>;
1794}
1795export interface LoggerTimeSpan {
1796 duration(): number;
1797 finish(finishedMsg: string, color?: string, bold?: boolean, newLineSuffix?: boolean): number;
1798}
1799export interface OutputTargetDist extends OutputTargetValidationConfig {
1800 type: 'dist';
1801 buildDir?: string;
1802 collectionDir?: string | null;
1803 /**
1804 * When `true` this flag will transform aliased import paths defined in
1805 * a project's `tsconfig.json` to relative import paths in the compiled output's
1806 * `dist-collection` bundle if it is generated (i.e. `collectionDir` is set).
1807 *
1808 * Paths will be left in aliased format if `false`.
1809 *
1810 * @example
1811 * // tsconfig.json
1812 * {
1813 * paths: {
1814 * "@utils/*": ['/src/utils/*']
1815 * }
1816 * }
1817 *
1818 * // Source file
1819 * import * as dateUtils from '@utils/date-utils';
1820 * // Output file
1821 * import * as dateUtils from '../utils/date-utils';
1822 */
1823 transformAliasedImportPathsInCollection?: boolean | null;
1824 typesDir?: string;
1825 esmLoaderPath?: string;
1826 copy?: CopyTask[];
1827 polyfills?: boolean;
1828 empty?: boolean;
1829}
1830export interface OutputTargetDistCollection extends OutputTargetValidationConfig {
1831 type: 'dist-collection';
1832 empty?: boolean;
1833 dir: string;
1834 collectionDir: string;
1835 /**
1836 * When `true` this flag will transform aliased import paths defined in
1837 * a project's `tsconfig.json` to relative import paths in the compiled output.
1838 *
1839 * Paths will be left in aliased format if `false` or `undefined`.
1840 *
1841 * @example
1842 * // tsconfig.json
1843 * {
1844 * paths: {
1845 * "@utils/*": ['/src/utils/*']
1846 * }
1847 * }
1848 *
1849 * // Source file
1850 * import * as dateUtils from '@utils/date-utils';
1851 * // Output file
1852 * import * as dateUtils from '../utils/date-utils';
1853 */
1854 transformAliasedImportPaths?: boolean | null;
1855}
1856export interface OutputTargetDistTypes extends OutputTargetValidationConfig {
1857 type: 'dist-types';
1858 dir: string;
1859 typesDir: string;
1860}
1861export interface OutputTargetDistLazy extends OutputTargetBase {
1862 type: 'dist-lazy';
1863 dir?: string;
1864 esmDir?: string;
1865 esmEs5Dir?: string;
1866 systemDir?: string;
1867 cjsDir?: string;
1868 polyfills?: boolean;
1869 isBrowserBuild?: boolean;
1870 esmIndexFile?: string;
1871 cjsIndexFile?: string;
1872 systemLoaderFile?: string;
1873 legacyLoaderFile?: string;
1874 empty?: boolean;
1875}
1876export interface OutputTargetDistGlobalStyles extends OutputTargetBase {
1877 type: 'dist-global-styles';
1878 file: string;
1879}
1880export interface OutputTargetDistLazyLoader extends OutputTargetBase {
1881 type: 'dist-lazy-loader';
1882 dir: string;
1883 esmDir: string;
1884 esmEs5Dir?: string;
1885 cjsDir: string;
1886 componentDts: string;
1887 empty: boolean;
1888}
1889export interface OutputTargetHydrate extends OutputTargetBase {
1890 type: 'dist-hydrate-script';
1891 dir?: string;
1892 /**
1893 * Module IDs that should not be bundled into the script.
1894 * By default, all node builtin's, such as `fs` or `path`
1895 * will be considered "external" and not bundled.
1896 */
1897 external?: string[];
1898 empty?: boolean;
1899}
1900export interface OutputTargetCustom extends OutputTargetBase {
1901 type: 'custom';
1902 name: string;
1903 validate?: (config: Config, diagnostics: Diagnostic[]) => void;
1904 generator: (config: Config, compilerCtx: any, buildCtx: any, docs: any) => Promise<void>;
1905 copy?: CopyTask[];
1906}
1907/**
1908 * Output target for generating [custom data](https://github.com/microsoft/vscode-custom-data) for VS Code as a JSON
1909 * file.
1910 */
1911export interface OutputTargetDocsVscode extends OutputTargetBase {
1912 /**
1913 * Designates this output target to be used for generating VS Code custom data.
1914 * @see OutputTargetBase#type
1915 */
1916 type: 'docs-vscode';
1917 /**
1918 * The location on disk to write the JSON file.
1919 */
1920 file: string;
1921 /**
1922 * A base URL to find the source code of the component(s) described in the JSON file.
1923 */
1924 sourceCodeBaseUrl?: string;
1925}
1926export interface OutputTargetDocsReadme extends OutputTargetBase {
1927 type: 'docs-readme';
1928 dir?: string;
1929 dependencies?: boolean;
1930 footer?: string;
1931 strict?: boolean;
1932}
1933export interface OutputTargetDocsJson extends OutputTargetBase {
1934 type: 'docs-json';
1935 file: string;
1936 /**
1937 * Set an optional file path where Stencil should write a `d.ts` file to disk
1938 * at build-time containing type declarations for {@link JsonDocs} and related
1939 * interfaces. If this is omitted or set to `null` Stencil will not write such
1940 * a file.
1941 */
1942 typesFile?: string | null;
1943 strict?: boolean;
1944 /**
1945 * An optional file path pointing to a public type library which should be
1946 * included and documented in the same way as other types which are included
1947 * in this output target.
1948 *
1949 * This could be useful if, for instance, there are some important interfaces
1950 * used in a few places in a Stencil project which don't form part of the
1951 * public API for any of the project's components. Such interfaces will not
1952 * be included in the `docs-json` output by default, but if they're declared
1953 * and exported from a 'supplemental' file designated with this property then
1954 * they'll be included in the output, facilitating their documentation.
1955 */
1956 supplementalPublicTypes?: string;
1957}
1958export interface OutputTargetDocsCustom extends OutputTargetBase {
1959 type: 'docs-custom';
1960 generator: (docs: JsonDocs, config: Config) => void | Promise<void>;
1961 strict?: boolean;
1962}
1963export interface OutputTargetStats extends OutputTargetBase {
1964 type: 'stats';
1965 file?: string;
1966}
1967export interface OutputTargetBaseNext {
1968 type: string;
1969 dir?: string;
1970}
1971/**
1972 * The collection of valid export behaviors.
1973 * Used to generate a type for typed configs as well as output target validation
1974 * for the `dist-custom-elements` output target.
1975 *
1976 * Adding a value to this const array will automatically add it as a valid option on the
1977 * output target configuration for `customElementsExportBehavior`.
1978 *
1979 * - `default`: No additional export or definition behavior will happen.
1980 * - `auto-define-custom-elements`: Enables the auto-definition of a component and its children (recursively) in the custom elements registry. This
1981 * functionality allows consumers to bypass the explicit call to define a component, its children, its children's
1982 * children, etc. Users of this flag should be aware that enabling this functionality may increase bundle size.
1983 * - `bundle`: A `defineCustomElements` function will be exported from the distribution directory. This behavior was added to allow easy migration
1984 * from `dist-custom-elements-bundle` to `dist-custom-elements`.
1985 * - `single-export-module`: All components will be re-exported from the specified directory's root `index.js` file.
1986 */
1987export declare const CustomElementsExportBehaviorOptions: readonly ["default", "auto-define-custom-elements", "bundle", "single-export-module"];
1988/**
1989 * This type is auto-generated based on the values in `CustomElementsExportBehaviorOptions` array.
1990 * This is used on the output target config for intellisense in typed configs.
1991 */
1992export type CustomElementsExportBehavior = (typeof CustomElementsExportBehaviorOptions)[number];
1993export interface OutputTargetDistCustomElements extends OutputTargetValidationConfig {
1994 type: 'dist-custom-elements';
1995 empty?: boolean;
1996 /**
1997 * Triggers the following behaviors when enabled:
1998 * 1. All `@stencil/core/*` module references are treated as external during bundling.
1999 * 2. File names are not hashed.
2000 * 3. File minification will follow the behavior defined at the root of the Stencil config.
2001 */
2002 externalRuntime?: boolean;
2003 copy?: CopyTask[];
2004 includeGlobalScripts?: boolean;
2005 minify?: boolean;
2006 /**
2007 * Enables the generation of type definition files for the output target.
2008 */
2009 generateTypeDeclarations?: boolean;
2010 /**
2011 * Define the export/definition behavior for the output target's generated output.
2012 * This controls if/how custom elements will be defined or where components will be exported from.
2013 * If omitted, no auto-definition behavior or re-exporting will happen.
2014 */
2015 customElementsExportBehavior?: CustomElementsExportBehavior;
2016}
2017/**
2018 * The base type for output targets. All output targets should extend this base type.
2019 */
2020export interface OutputTargetBase {
2021 /**
2022 * A unique string to differentiate one output target from another
2023 */
2024 type: string;
2025}
2026/**
2027 * Output targets that can have validation for common `package.json` field values
2028 * (module, types, etc.). This allows them to be marked for validation in a project's Stencil config.
2029 */
2030interface OutputTargetValidationConfig extends OutputTargetBaseNext {
2031 isPrimaryPackageOutputTarget?: boolean;
2032}
2033export type EligiblePrimaryPackageOutputTarget = OutputTargetDist | OutputTargetDistCustomElements | OutputTargetDistCollection | OutputTargetDistTypes;
2034export type OutputTargetBuild = OutputTargetDistCollection | OutputTargetDistLazy;
2035export interface OutputTargetCopy extends OutputTargetBase {
2036 type: 'copy';
2037 dir: string;
2038 copy?: CopyTask[];
2039 copyAssets?: 'collection' | 'dist';
2040}
2041export interface OutputTargetWww extends OutputTargetBase {
2042 /**
2043 * Webapp output target.
2044 */
2045 type: 'www';
2046 /**
2047 * The directory to write the app's JavaScript and CSS build
2048 * files to. The default is to place this directory as a child
2049 * to the `dir` config. Default: `build`
2050 */
2051 buildDir?: string;
2052 /**
2053 * The directory to write the entire application to.
2054 * Note, the `buildDir` is where the app's JavaScript and CSS build
2055 * files are written. Default: `www`
2056 */
2057 dir?: string;
2058 /**
2059 * Empty the build directory of all files and directories on first build.
2060 * Default: `true`
2061 */
2062 empty?: boolean;
2063 /**
2064 * The default index html file of the app, commonly found at the
2065 * root of the `src` directory.
2066 * Default: `index.html`
2067 */
2068 indexHtml?: string;
2069 /**
2070 * The copy config is an array of objects that defines any files or folders that should
2071 * be copied over to the build directory.
2072 *
2073 * Each object in the array must include a src property which can be either an absolute path,
2074 * a relative path or a glob pattern. The config can also provide an optional dest property
2075 * which can be either an absolute path or a path relative to the build directory.
2076 * Also note that any files within src/assets are automatically copied to www/assets for convenience.
2077 *
2078 * In the copy config below, it will copy the entire directory from src/docs-content over to www/docs-content.
2079 */
2080 copy?: CopyTask[];
2081 /**
2082 * The base url of the app, it's required during prerendering to be the absolute path
2083 * of your app, such as: `https://my.app.com/app`.
2084 *
2085 * Default: `/`
2086 */
2087 baseUrl?: string;
2088 /**
2089 * By default, stencil will include all the polyfills required by legacy browsers in the ES5 build.
2090 * If it's `false`, stencil will not emit this polyfills anymore and it's your responsibility to provide them before
2091 * stencil initializes.
2092 */
2093 polyfills?: boolean;
2094 /**
2095 * Path to an external node module which has exports of the prerender config object.
2096 * ```
2097 * module.exports = {
2098 * afterHydrate(document, url) {
2099 * document.title = `URL: ${url.href}`;
2100 * }
2101 * }
2102 * ```
2103 */
2104 prerenderConfig?: string;
2105 /**
2106 * Service worker config for production builds. During development builds
2107 * service worker script will be injected to automatically deregister existing
2108 * service workers. When set to `false` neither a service worker registration
2109 * or deregistration will be added to the index.html.
2110 */
2111 serviceWorker?: ServiceWorkerConfig | null | false;
2112 appDir?: string;
2113}
2114export type OutputTarget = OutputTargetCopy | OutputTargetCustom | OutputTargetDist | OutputTargetDistCollection | OutputTargetDistCustomElements | OutputTargetDistLazy | OutputTargetDistGlobalStyles | OutputTargetDistLazyLoader | OutputTargetDocsJson | OutputTargetDocsCustom | OutputTargetDocsReadme | OutputTargetDocsVscode | OutputTargetWww | OutputTargetHydrate | OutputTargetStats | OutputTargetDistTypes;
2115/**
2116 * Our custom configuration interface for generated caching Service Workers
2117 * using the Workbox library (see https://developer.chrome.com/docs/workbox/).
2118 *
2119 * Although we are using Workbox we are unfortunately unable to depend on the
2120 * published types for the library because they must be compiled using the
2121 * `webworker` lib for TypeScript, which cannot be used at the same time as
2122 * the `dom` lib. So as a workaround we maintain our own interface here. See
2123 * here to refer to the published version:
2124 * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/c7b4dadae5b320ad1311a8f82242b8f2f41b7b8c/types/workbox-build/generate-sw.d.ts#L3
2125 */
2126export interface ServiceWorkerConfig {
2127 unregister?: boolean;
2128 swDest?: string;
2129 swSrc?: string;
2130 globPatterns?: string[];
2131 globDirectory?: string | string[];
2132 globIgnores?: string | string[];
2133 templatedUrls?: any;
2134 maximumFileSizeToCacheInBytes?: number;
2135 manifestTransforms?: any;
2136 modifyUrlPrefix?: any;
2137 dontCacheBustURLsMatching?: RegExp;
2138 navigateFallback?: string;
2139 navigateFallbackWhitelist?: RegExp[];
2140 navigateFallbackBlacklist?: RegExp[];
2141 cacheId?: string;
2142 skipWaiting?: boolean;
2143 clientsClaim?: boolean;
2144 directoryIndex?: string;
2145 runtimeCaching?: any[];
2146 ignoreUrlParametersMatching?: any[];
2147 handleFetch?: boolean;
2148}
2149export interface LoadConfigInit {
2150 /**
2151 * User config object to merge into default config and
2152 * config loaded from a file path.
2153 */
2154 config?: UnvalidatedConfig;
2155 /**
2156 * Absolute path to a Stencil config file. This path cannot be
2157 * relative and it does not resolve config files within a directory.
2158 */
2159 configPath?: string;
2160 logger?: Logger;
2161 sys?: CompilerSystem;
2162 /**
2163 * When set to true, if the "tsconfig.json" file is not found
2164 * it'll automatically generate and save a default tsconfig
2165 * within the root directory.
2166 */
2167 initTsConfig?: boolean;
2168}
2169/**
2170 * Results from an attempt to load a config. The values on this interface
2171 * have not yet been validated and are not ready to be used for arbitrary
2172 * operations around the codebase.
2173 */
2174export interface LoadConfigResults {
2175 config: ValidatedConfig;
2176 diagnostics: Diagnostic[];
2177 tsconfig: {
2178 path: string;
2179 compilerOptions: any;
2180 files: string[];
2181 include: string[];
2182 exclude: string[];
2183 extends: string;
2184 };
2185}
2186export interface Diagnostic {
2187 absFilePath?: string | undefined;
2188 code?: string;
2189 columnNumber?: number | undefined;
2190 debugText?: string;
2191 header?: string;
2192 language?: string;
2193 level: 'error' | 'warn' | 'info' | 'log' | 'debug';
2194 lineNumber?: number | undefined;
2195 lines: PrintLine[];
2196 messageText: string;
2197 relFilePath?: string | undefined;
2198 type: string;
2199}
2200export interface CacheStorage {
2201 get(key: string): Promise<any>;
2202 set(key: string, value: any): Promise<void>;
2203}
2204export interface WorkerOptions {
2205 maxConcurrentWorkers?: number;
2206 maxConcurrentTasksPerWorker?: number;
2207 logger?: Logger;
2208}
2209export interface RollupInterface {
2210 rollup: {
2211 (config: any): Promise<any>;
2212 };
2213 plugins: {
2214 nodeResolve(opts: any): any;
2215 replace(opts: any): any;
2216 commonjs(opts: any): any;
2217 json(): any;
2218 };
2219}
2220export interface ResolveModuleOptions {
2221 manuallyResolve?: boolean;
2222 packageJson?: boolean;
2223}
2224export interface PrerenderStartOptions {
2225 buildId?: string;
2226 hydrateAppFilePath: string;
2227 componentGraph: BuildResultsComponentGraph;
2228 srcIndexHtmlPath: string;
2229}
2230export interface PrerenderResults {
2231 buildId: string;
2232 diagnostics: Diagnostic[];
2233 urls: number;
2234 duration: number;
2235 average: number;
2236}
2237/**
2238 * Input for CSS optimization functions, including the input CSS
2239 * string and a few boolean options which turn on or off various
2240 * optimizations.
2241 */
2242export interface OptimizeCssInput {
2243 input: string;
2244 filePath?: string;
2245 autoprefixer?: boolean | null | AutoprefixerOptions;
2246 minify?: boolean;
2247 sourceMap?: boolean;
2248 resolveUrl?: (url: string) => Promise<string> | string;
2249}
2250/**
2251 * This is not a real interface describing the options which can
2252 * be passed to autoprefixer, for that see the docs, here:
2253 * https://github.com/postcss/autoprefixer#options
2254 *
2255 * Instead, this basically just serves as a label type to track
2256 * that arguments are being passed consistently.
2257 */
2258export type AutoprefixerOptions = Object;
2259/**
2260 * Output from CSS optimization functions, wrapping up optimized
2261 * CSS and any diagnostics produced during optimization.
2262 */
2263export interface OptimizeCssOutput {
2264 output: string;
2265 diagnostics: Diagnostic[];
2266}
2267export interface OptimizeJsInput {
2268 input: string;
2269 filePath?: string;
2270 target?: 'es5' | 'latest';
2271 pretty?: boolean;
2272 sourceMap?: boolean;
2273}
2274export interface OptimizeJsOutput {
2275 output: string;
2276 sourceMap: any;
2277 diagnostics: Diagnostic[];
2278}
2279export interface LazyRequire {
2280 ensure(fromDir: string, moduleIds: string[]): Promise<Diagnostic[]>;
2281 require(fromDir: string, moduleId: string): any;
2282 getModulePath(fromDir: string, moduleId: string): string;
2283}
2284/**
2285 * @deprecated This interface is no longer used by Stencil
2286 * TODO(STENCIL-743): Remove this interface
2287 */
2288export interface FsWatcherItem {
2289 close(): void;
2290}
2291/**
2292 * @deprecated This interface is no longer used by Stencil
2293 * TODO(STENCIL-743): Remove this interface
2294 */
2295export interface MakeDirectoryOptions {
2296 /**
2297 * Indicates whether parent folders should be created.
2298 * @default false
2299 */
2300 recursive?: boolean;
2301 /**
2302 * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
2303 * @default 0o777.
2304 */
2305 mode?: number;
2306}
2307/**
2308 * @deprecated This interface is no longer used by Stencil
2309 * TODO(STENCIL-743): Remove this interface
2310 */
2311export interface FsStats {
2312 isFile(): boolean;
2313 isDirectory(): boolean;
2314 isBlockDevice(): boolean;
2315 isCharacterDevice(): boolean;
2316 isSymbolicLink(): boolean;
2317 isFIFO(): boolean;
2318 isSocket(): boolean;
2319 dev: number;
2320 ino: number;
2321 mode: number;
2322 nlink: number;
2323 uid: number;
2324 gid: number;
2325 rdev: number;
2326 size: number;
2327 blksize: number;
2328 blocks: number;
2329 atime: Date;
2330 mtime: Date;
2331 ctime: Date;
2332 birthtime: Date;
2333}
2334export interface Compiler {
2335 build(): Promise<CompilerBuildResults>;
2336 createWatcher(): Promise<CompilerWatcher>;
2337 destroy(): Promise<void>;
2338 sys: CompilerSystem;
2339}
2340export interface CompilerWatcher extends BuildOnEvents {
2341 start: () => Promise<WatcherCloseResults>;
2342 close: () => Promise<WatcherCloseResults>;
2343 request: (data: CompilerRequest) => Promise<CompilerRequestResponse>;
2344}
2345export interface CompilerRequest {
2346 path?: string;
2347}
2348export interface WatcherCloseResults {
2349 exitCode: number;
2350}
2351export interface CompilerRequestResponse {
2352 path: string;
2353 nodeModuleId: string;
2354 nodeModuleVersion: string;
2355 nodeResolvedPath: string;
2356 cachePath: string;
2357 cacheHit: boolean;
2358 content: string;
2359 status: number;
2360}
2361/**
2362 * Options for Stencil's string-to-string transpiler
2363 */
2364export interface TranspileOptions {
2365 /**
2366 * A component can be defined as a custom element by using `customelement`, or the
2367 * component class can be exported by using `module`. Default is `customelement`.
2368 */
2369 componentExport?: 'customelement' | 'module' | string | undefined;
2370 /**
2371 * Sets how and if component metadata should be assigned on the compiled
2372 * component output. The `compilerstatic` value will set the metadata to
2373 * a static `COMPILER_META` getter on the component class. This option
2374 * is useful for unit testing preprocessors. Default is `null`.
2375 */
2376 componentMetadata?: 'runtimestatic' | 'compilerstatic' | string | undefined;
2377 /**
2378 * The actual internal import path for any `@stencil/core` imports.
2379 * Default is `@stencil/core/internal/client`.
2380 */
2381 coreImportPath?: string;
2382 /**
2383 * The current working directory. Default is `/`.
2384 */
2385 currentDirectory?: string;
2386 /**
2387 * The filename of the code being compiled. Default is `module.tsx`.
2388 */
2389 file?: string;
2390 /**
2391 * Module format to use for the compiled code output, which can be either `esm` or `cjs`.
2392 * Default is `esm`.
2393 */
2394 module?: 'cjs' | 'esm' | string;
2395 /**
2396 * Sets how and if any properties, methods and events are proxied on the
2397 * component class. The `defineproperty` value sets the getters and setters
2398 * using Object.defineProperty. Default is `defineproperty`.
2399 */
2400 proxy?: 'defineproperty' | string | undefined;
2401 /**
2402 * How component styles should be associated to the component. The `static`
2403 * setting will assign the styles as a static getter on the component class.
2404 */
2405 style?: 'static' | string | undefined;
2406 /**
2407 * How style data should be added for imports. For example, the `queryparams` value
2408 * adds the component's tagname and encapsulation info as querystring parameter
2409 * to the style's import, such as `style.css?tag=my-tag&encapsulation=shadow`. This
2410 * style data can be used by bundlers to further optimize each component's css.
2411 * Set to `null` to not include the querystring parameters. Default is `queryparams`.
2412 */
2413 styleImportData?: 'queryparams' | string | undefined;
2414 /**
2415 * The JavaScript source target TypeScript should to transpile to. Values can be
2416 * `latest`, `esnext`, `es2017`, `es2015`, or `es5`. Defaults to `latest`.
2417 */
2418 target?: CompileTarget;
2419 /**
2420 * Create a source map. Using `inline` will inline the source map into the
2421 * code, otherwise the source map will be in the returned `map` property.
2422 * Default is `true`.
2423 */
2424 sourceMap?: boolean | 'inline';
2425 /**
2426 * Base directory to resolve non-relative module names. Same as the `baseUrl`
2427 * TypeScript compiler option: https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
2428 */
2429 baseUrl?: string;
2430 /**
2431 * List of path mapping entries for module names to locations relative to the `baseUrl`.
2432 * Same as the `paths` TypeScript compiler option:
2433 * https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
2434 */
2435 paths?: {
2436 [key: string]: string[];
2437 };
2438 /**
2439 * Passed in Stencil Compiler System, otherwise falls back to the internal in-memory only system.
2440 */
2441 sys?: CompilerSystem;
2442 /**
2443 * This option enables the same behavior as {@link Config.transformAliasedImportPaths}, transforming paths aliased in
2444 * `tsconfig.json` to relative paths.
2445 */
2446 transformAliasedImportPaths?: boolean;
2447}
2448export type CompileTarget = 'latest' | 'esnext' | 'es2020' | 'es2019' | 'es2018' | 'es2017' | 'es2015' | 'es5' | string | undefined;
2449export interface TranspileResults {
2450 code: string;
2451 data?: any[];
2452 diagnostics: Diagnostic[];
2453 imports?: {
2454 path: string;
2455 }[];
2456 inputFileExtension: string;
2457 inputFilePath: string;
2458 map: any;
2459 outputFilePath: string;
2460}
2461export interface TransformOptions {
2462 coreImportPath: string;
2463 componentExport: 'lazy' | 'module' | 'customelement' | null;
2464 componentMetadata: 'runtimestatic' | 'compilerstatic' | null;
2465 currentDirectory: string;
2466 file?: string;
2467 isolatedModules?: boolean;
2468 module?: 'cjs' | 'esm';
2469 proxy: 'defineproperty' | null;
2470 style: 'static' | null;
2471 styleImportData: 'queryparams' | null;
2472 target?: string;
2473}
2474export interface CompileScriptMinifyOptions {
2475 target?: CompileTarget;
2476 pretty?: boolean;
2477}
2478export interface DevServer extends BuildEmitEvents {
2479 address: string;
2480 basePath: string;
2481 browserUrl: string;
2482 protocol: string;
2483 port: number;
2484 root: string;
2485 close(): Promise<void>;
2486}
2487export interface CliInitOptions {
2488 args: string[];
2489 logger: Logger;
2490 sys: CompilerSystem;
2491}
2492
\No newline at end of file