UNPKG

72.7 kBTypeScriptView Raw
1import { result } from './utils';
2import type { InMemoryFileSystem } from '../compiler/sys/in-memory-fs';
3import type { CPSerializable } from './child_process';
4import type { BuildEvents, BuildLog, BuildResultsComponentGraph, CompilerBuildResults, CompilerFsStats, CompilerRequestResponse, CompilerSystem, Config, CopyResults, DevServerConfig, DevServerEditor, Diagnostic, Logger, LoggerLineUpdater, LoggerTimeSpan, OptimizeCssInput, OptimizeCssOutput, OutputTarget, OutputTargetWww, PageReloadStrategy, PrerenderConfig, StyleDoc, TaskCommand, ValidatedConfig } from './stencil-public-compiler';
5import type { JsonDocMethodParameter } from './stencil-public-docs';
6import type { ComponentInterface, ListenTargetOptions, VNode } from './stencil-public-runtime';
7export interface DocData {
8 hostIds: number;
9 rootLevelIds: number;
10 staticComponents: Set<string>;
11}
12export type StencilDocument = Document & {
13 _stencilDocData: DocData;
14};
15export interface SourceMap {
16 file: string;
17 mappings: string;
18 names: string[];
19 sourceRoot?: string;
20 sources: string[];
21 sourcesContent?: string[];
22 version: number;
23}
24export interface PrintLine {
25 lineIndex: number;
26 lineNumber: number;
27 text: string;
28 errorCharStart: number;
29 errorLength?: number;
30}
31export interface AssetsMeta {
32 absolutePath: string;
33 cmpRelativePath: string;
34 originalComponentPath: string;
35}
36export interface ParsedImport {
37 importPath: string;
38 basename: string;
39 ext: string;
40 data: ImportData;
41}
42export interface ImportData {
43 tag?: string;
44 encapsulation?: string;
45 mode?: string;
46}
47export interface SerializeImportData extends ImportData {
48 importeePath: string;
49 importerPath?: string;
50}
51export interface BuildFeatures {
52 style: boolean;
53 mode: boolean;
54 formAssociated: boolean;
55 shadowDom: boolean;
56 shadowDelegatesFocus: boolean;
57 scoped: boolean;
58 /**
59 * Every component has a render function
60 */
61 allRenderFn: boolean;
62 /**
63 * At least one component has a render function
64 */
65 hasRenderFn: boolean;
66 vdomRender: boolean;
67 vdomAttribute: boolean;
68 vdomClass: boolean;
69 vdomFunctional: boolean;
70 vdomKey: boolean;
71 vdomListener: boolean;
72 vdomPropOrAttr: boolean;
73 vdomRef: boolean;
74 vdomStyle: boolean;
75 vdomText: boolean;
76 vdomXlink: boolean;
77 slotRelocation: boolean;
78 slot: boolean;
79 svg: boolean;
80 element: boolean;
81 event: boolean;
82 hostListener: boolean;
83 hostListenerTargetWindow: boolean;
84 hostListenerTargetDocument: boolean;
85 hostListenerTargetBody: boolean;
86 /**
87 * @deprecated Prevented from new apps, but left in for older collections
88 */
89 hostListenerTargetParent: boolean;
90 hostListenerTarget: boolean;
91 method: boolean;
92 prop: boolean;
93 propMutable: boolean;
94 state: boolean;
95 watchCallback: boolean;
96 member: boolean;
97 updatable: boolean;
98 propBoolean: boolean;
99 propNumber: boolean;
100 propString: boolean;
101 lifecycle: boolean;
102 cmpDidLoad: boolean;
103 cmpShouldUpdate: boolean;
104 cmpWillLoad: boolean;
105 cmpDidUpdate: boolean;
106 cmpWillUpdate: boolean;
107 cmpWillRender: boolean;
108 cmpDidRender: boolean;
109 cmpDidUnload: boolean;
110 connectedCallback: boolean;
111 disconnectedCallback: boolean;
112 asyncLoading: boolean;
113 observeAttribute: boolean;
114 reflect: boolean;
115 taskQueue: boolean;
116}
117export interface BuildConditionals extends Partial<BuildFeatures> {
118 hotModuleReplacement?: boolean;
119 isDebug?: boolean;
120 isTesting?: boolean;
121 isDev?: boolean;
122 devTools?: boolean;
123 invisiblePrehydration?: boolean;
124 hydrateServerSide?: boolean;
125 hydrateClientSide?: boolean;
126 lifecycleDOMEvents?: boolean;
127 cssAnnotations?: boolean;
128 lazyLoad?: boolean;
129 profile?: boolean;
130 constructableCSS?: boolean;
131 appendChildSlotFix?: boolean;
132 slotChildNodesFix?: boolean;
133 scopedSlotTextContentFix?: boolean;
134 cloneNodeFix?: boolean;
135 hydratedAttribute?: boolean;
136 hydratedClass?: boolean;
137 hydratedSelectorName?: string;
138 initializeNextTick?: boolean;
139 scriptDataOpts?: boolean;
140 shadowDomShim?: boolean;
141 asyncQueue?: boolean;
142 transformTagName?: boolean;
143 attachStyles?: boolean;
144 experimentalSlotFixes?: boolean;
145 experimentalScopedSlotChanges?: boolean;
146}
147export type ModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd' | 'commonjs' | 'esm' | 'module' | 'systemjs';
148export interface RollupResultModule {
149 id: string;
150}
151export interface RollupResults {
152 modules: RollupResultModule[];
153}
154export interface UpdatedLazyBuildCtx {
155 name: 'esm-browser' | 'esm' | 'cjs' | 'system';
156 buildCtx: BuildCtx;
157}
158export interface BuildCtx {
159 buildId: number;
160 buildResults: CompilerBuildResults;
161 buildStats?: result.Result<CompilerBuildStats, {
162 diagnostics: Diagnostic[];
163 }>;
164 buildMessages: string[];
165 bundleBuildCount: number;
166 collections: CollectionCompilerMeta[];
167 compilerCtx: CompilerCtx;
168 esmBrowserComponentBundle: ReadonlyArray<BundleModule>;
169 esmComponentBundle: ReadonlyArray<BundleModule>;
170 es5ComponentBundle: ReadonlyArray<BundleModule>;
171 systemComponentBundle: ReadonlyArray<BundleModule>;
172 commonJsComponentBundle: ReadonlyArray<BundleModule>;
173 components: ComponentCompilerMeta[];
174 componentGraph: Map<string, string[]>;
175 config: ValidatedConfig;
176 createTimeSpan(msg: string, debug?: boolean): LoggerTimeSpan;
177 data: any;
178 debug: (msg: string) => void;
179 diagnostics: Diagnostic[];
180 dirsAdded: string[];
181 dirsDeleted: string[];
182 entryModules: EntryModule[];
183 filesAdded: string[];
184 filesChanged: string[];
185 filesDeleted: string[];
186 filesUpdated: string[];
187 filesWritten: string[];
188 globalStyle: string | undefined;
189 hasConfigChanges: boolean;
190 hasError: boolean;
191 hasFinished: boolean;
192 hasHtmlChanges: boolean;
193 hasPrintedResults: boolean;
194 hasServiceWorkerChanges: boolean;
195 hasScriptChanges: boolean;
196 hasStyleChanges: boolean;
197 hasWarning: boolean;
198 hydrateAppFilePath: string;
199 indexBuildCount: number;
200 indexDoc: Document;
201 isRebuild: boolean;
202 /**
203 * A collection of Stencil's intermediate representation of components, tied to the current build
204 */
205 moduleFiles: Module[];
206 packageJson: PackageJsonData;
207 pendingCopyTasks: Promise<CopyResults>[];
208 progress(task: BuildTask): void;
209 requiresFullBuild: boolean;
210 rollupResults?: RollupResults;
211 scriptsAdded: string[];
212 scriptsDeleted: string[];
213 startTime: number;
214 styleBuildCount: number;
215 stylesPromise: Promise<void>;
216 stylesUpdated: BuildStyleUpdate[];
217 timeSpan: LoggerTimeSpan;
218 timestamp: string;
219 transpileBuildCount: number;
220 validateTypesBuild?(): Promise<void>;
221 validateTypesHandler?: (results: any) => Promise<void>;
222 validateTypesPromise?: Promise<any>;
223}
224export interface BuildStyleUpdate {
225 styleTag: string;
226 styleText: string;
227 styleMode: string;
228}
229export type BuildTask = any;
230export interface CompilerBuildStats {
231 timestamp: string;
232 compiler: {
233 name: string;
234 version: string;
235 };
236 app: {
237 namespace: string;
238 fsNamespace: string;
239 components: number;
240 entries: number;
241 bundles: number;
242 outputs: any;
243 };
244 options: {
245 minifyJs: boolean;
246 minifyCss: boolean;
247 hashFileNames: boolean;
248 hashedFileNameLength: number;
249 buildEs5: boolean | 'prod';
250 };
251 formats: {
252 esmBrowser: ReadonlyArray<CompilerBuildStatBundle>;
253 esm: ReadonlyArray<CompilerBuildStatBundle>;
254 es5: ReadonlyArray<CompilerBuildStatBundle>;
255 system: ReadonlyArray<CompilerBuildStatBundle>;
256 commonjs: ReadonlyArray<CompilerBuildStatBundle>;
257 };
258 components: BuildComponent[];
259 entries: EntryModule[];
260 rollupResults: RollupResults;
261 sourceGraph?: BuildSourceGraph;
262 componentGraph: BuildResultsComponentGraph;
263 collections: CompilerBuildStatCollection[];
264}
265export interface CompilerBuildStatCollection {
266 name: string;
267 source: string;
268 tags: string[][];
269}
270export interface CompilerBuildStatBundle {
271 key: string;
272 components: string[];
273 bundleId: string;
274 fileName: string;
275 imports: string[];
276 originalByteSize: number;
277}
278export interface BuildSourceGraph {
279 [filePath: string]: string[];
280}
281export interface BuildComponent {
282 tag: string;
283 dependencyOf?: string[];
284 dependencies?: string[];
285}
286export type SourceTarget = 'es5' | 'es2017' | 'latest';
287/**
288 * A note regarding Rollup types:
289 * As of this writing, there is no great way to import external types for packages that are directly embedded in the
290 * Stencil source. As a result, some types are duplicated here for Rollup that will be used within the codebase.
291 * Updates to rollup may require these typings to be updated.
292 */
293export type RollupResult = RollupChunkResult | RollupAssetResult;
294export interface RollupAssetResult {
295 type: 'asset';
296 fileName: string;
297 content: string;
298}
299export interface RollupChunkResult {
300 type: 'chunk';
301 entryKey: string;
302 fileName: string;
303 code: string;
304 isEntry: boolean;
305 isComponent: boolean;
306 isCore: boolean;
307 isIndex: boolean;
308 isBrowserLoader: boolean;
309 imports: string[];
310 moduleFormat: ModuleFormat;
311 map?: RollupSourceMap;
312}
313export interface RollupSourceMap {
314 file: string;
315 mappings: string;
316 names: string[];
317 sources: string[];
318 sourcesContent: string[];
319 version: number;
320 toString(): string;
321 toUrl(): string;
322}
323/**
324 * Result of Stencil compressing, mangling, and otherwise 'minifying' JavaScript
325 */
326export type OptimizeJsResult = {
327 output: string;
328 diagnostics: Diagnostic[];
329 sourceMap?: SourceMap;
330};
331export interface BundleModule {
332 entryKey: string;
333 rollupResult: RollupChunkResult;
334 cmps: ComponentCompilerMeta[];
335 output: BundleModuleOutput;
336}
337export interface BundleModuleOutput {
338 bundleId: string;
339 fileName: string;
340 code: string;
341}
342export interface Cache {
343 get(key: string): Promise<string | null>;
344 put(key: string, value: string): Promise<boolean>;
345 has(key: string): Promise<boolean>;
346 createKey(domain: string, ...args: any[]): Promise<string>;
347 commit(): Promise<void>;
348 clear(): void;
349 clearDiskCache(): Promise<void>;
350 getMemoryStats(): string;
351 initCacheDir(): Promise<void>;
352}
353export interface CollectionCompilerMeta {
354 collectionName: string;
355 moduleId?: string;
356 moduleDir: string;
357 moduleFiles: Module[];
358 global?: Module;
359 compiler?: CollectionCompilerVersion;
360 isInitialized?: boolean;
361 hasExports?: boolean;
362 dependencies?: string[];
363 bundles?: {
364 components: string[];
365 }[];
366}
367export interface CollectionCompilerVersion {
368 name: string;
369 version: string;
370 typescriptVersion?: string;
371}
372export interface CollectionManifest {
373 entries?: CollectionComponentEntryPath[];
374 collections?: CollectionDependencyManifest[];
375 global?: string;
376 compiler?: CollectionCompilerVersion;
377 bundles?: CollectionBundleManifest[];
378}
379export type CollectionComponentEntryPath = string;
380export interface CollectionBundleManifest {
381 components: string[];
382}
383export interface CollectionDependencyManifest {
384 name: string;
385 tags: string[];
386}
387export interface CollectionCompiler {
388 name: string;
389 version: string;
390 typescriptVersion?: string;
391}
392export interface CollectionDependencyData {
393 name: string;
394 tags: string[];
395}
396export interface CompilerCtx {
397 version: number;
398 activeBuildId: number;
399 activeDirsAdded: string[];
400 activeDirsDeleted: string[];
401 activeFilesAdded: string[];
402 activeFilesDeleted: string[];
403 activeFilesUpdated: string[];
404 addWatchDir: (path: string, recursive: boolean) => void;
405 addWatchFile: (path: string) => void;
406 cache: Cache;
407 cssModuleImports: Map<string, string[]>;
408 cachedGlobalStyle: string;
409 collections: CollectionCompilerMeta[];
410 compilerOptions: any;
411 events: BuildEvents;
412 fs: InMemoryFileSystem;
413 hasSuccessfulBuild: boolean;
414 isActivelyBuilding: boolean;
415 lastBuildResults: CompilerBuildResults;
416 /**
417 * A mapping of a file path to a Stencil {@link Module}
418 */
419 moduleMap: ModuleMap;
420 nodeMap: NodeMap;
421 resolvedCollections: Set<string>;
422 rollupCacheHydrate: any;
423 rollupCacheLazy: any;
424 rollupCacheNative: any;
425 styleModeNames: Set<string>;
426 changedModules: Set<string>;
427 changedFiles: Set<string>;
428 worker?: CompilerWorkerContext;
429 rollupCache: Map<string, any>;
430 reset(): void;
431}
432export type NodeMap = WeakMap<any, ComponentCompilerMeta>;
433/**
434 * Record, for a specific component, whether or not it has various features
435 * which need to be handled correctly in the compilation pipeline.
436 *
437 * Note: this must be serializable to JSON.
438 */
439export interface ComponentCompilerFeatures {
440 hasAttribute: boolean;
441 hasAttributeChangedCallbackFn: boolean;
442 hasComponentWillLoadFn: boolean;
443 hasComponentDidLoadFn: boolean;
444 hasComponentShouldUpdateFn: boolean;
445 hasComponentWillUpdateFn: boolean;
446 hasComponentDidUpdateFn: boolean;
447 hasComponentWillRenderFn: boolean;
448 hasComponentDidRenderFn: boolean;
449 hasComponentDidUnloadFn: boolean;
450 hasConnectedCallbackFn: boolean;
451 hasDisconnectedCallbackFn: boolean;
452 hasElement: boolean;
453 hasEvent: boolean;
454 hasLifecycle: boolean;
455 hasListener: boolean;
456 hasListenerTarget: boolean;
457 hasListenerTargetWindow: boolean;
458 hasListenerTargetDocument: boolean;
459 hasListenerTargetBody: boolean;
460 /**
461 * @deprecated Prevented from new apps, but left in for older collections
462 */
463 hasListenerTargetParent: boolean;
464 hasMember: boolean;
465 hasMethod: boolean;
466 hasMode: boolean;
467 hasProp: boolean;
468 hasPropBoolean: boolean;
469 hasPropNumber: boolean;
470 hasPropString: boolean;
471 hasPropMutable: boolean;
472 hasReflect: boolean;
473 hasRenderFn: boolean;
474 hasState: boolean;
475 hasStyle: boolean;
476 hasVdomAttribute: boolean;
477 hasVdomClass: boolean;
478 hasVdomFunctional: boolean;
479 hasVdomKey: boolean;
480 hasVdomListener: boolean;
481 hasVdomPropOrAttr: boolean;
482 hasVdomRef: boolean;
483 hasVdomRender: boolean;
484 hasVdomStyle: boolean;
485 hasVdomText: boolean;
486 hasVdomXlink: boolean;
487 hasWatchCallback: boolean;
488 htmlAttrNames: string[];
489 htmlTagNames: string[];
490 htmlParts: string[];
491 isUpdateable: boolean;
492 /**
493 * A plain component is one that doesn't have:
494 * - any members decorated with `@Prop()`, `@State()`, `@Element()`, `@Method()`
495 * - any methods decorated with `@Listen()`
496 * - any styles
497 * - any lifecycle methods, including `render()`
498 */
499 isPlain: boolean;
500 /**
501 * A collection of tag names of web components that a component references in its JSX/h() function
502 */
503 potentialCmpRefs: string[];
504}
505/**
506 * Metadata about a given component
507 *
508 * Note: must be serializable to JSON!
509 */
510export interface ComponentCompilerMeta extends ComponentCompilerFeatures {
511 assetsDirs: CompilerAssetDir[];
512 /**
513 * The name to which an `ElementInternals` object (the return value of
514 * `HTMLElement.attachInternals`) should be attached at runtime. If this is
515 * `null` then `attachInternals` should not be called.
516 */
517 attachInternalsMemberName: string | null;
518 componentClassName: string;
519 /**
520 * A list of web component tag names that are either:
521 * - directly referenced in a Stencil component's JSX/h() function
522 * - are referenced by a web component that is directly referenced in a Stencil component's JSX/h() function
523 */
524 dependencies: string[];
525 /**
526 * A list of web component tag names that either:
527 * - directly reference the current component directly in their JSX/h() function
528 * - indirectly/transitively reference the current component directly in their JSX/h() function
529 */
530 dependents: string[];
531 /**
532 * A list of web component tag names that are directly referenced in a Stencil component's JSX/h() function
533 */
534 directDependencies: string[];
535 /**
536 * A list of web component tag names that the current component directly in their JSX/h() function
537 */
538 directDependents: string[];
539 docs: CompilerJsDoc;
540 elementRef: string;
541 encapsulation: Encapsulation;
542 events: ComponentCompilerEvent[];
543 excludeFromCollection: boolean;
544 /**
545 * Whether or not the component is form-associated
546 */
547 formAssociated: boolean;
548 internal: boolean;
549 isCollectionDependency: boolean;
550 jsFilePath: string;
551 listeners: ComponentCompilerListener[];
552 methods: ComponentCompilerMethod[];
553 properties: ComponentCompilerProperty[];
554 shadowDelegatesFocus: boolean;
555 sourceFilePath: string;
556 sourceMapPath: string;
557 states: ComponentCompilerState[];
558 styleDocs: CompilerStyleDoc[];
559 styles: StyleCompiler[];
560 tagName: string;
561 virtualProperties: ComponentCompilerVirtualProperty[];
562 watchers: ComponentCompilerWatch[];
563}
564/**
565 * The supported style encapsulation modes on a Stencil component:
566 * 1. 'shadow' - native Shadow DOM
567 * 2. 'scoped' - encapsulated styles and polyfilled slots
568 * 3. 'none' - a basic HTML element
569 */
570export type Encapsulation = 'shadow' | 'scoped' | 'none';
571/**
572 * Intermediate Representation (IR) of a static property on a Stencil component
573 */
574export interface ComponentCompilerStaticProperty {
575 mutable: boolean;
576 optional: boolean;
577 required: boolean;
578 type: ComponentCompilerPropertyType;
579 complexType: ComponentCompilerPropertyComplexType;
580 attribute?: string;
581 reflect?: boolean;
582 docs: CompilerJsDoc;
583 defaultValue?: string;
584}
585/**
586 * Intermediate Representation (IR) of a property on a Stencil component
587 */
588export interface ComponentCompilerProperty extends ComponentCompilerStaticProperty {
589 name: string;
590 internal: boolean;
591}
592export interface ComponentCompilerVirtualProperty {
593 name: string;
594 type: string;
595 docs: string;
596}
597export type ComponentCompilerPropertyType = 'any' | 'string' | 'boolean' | 'number' | 'unknown';
598/**
599 * Information about a type used in a Stencil component or exported
600 * from a Stencil project.
601 */
602export interface ComponentCompilerPropertyComplexType {
603 /**
604 * The string of the original type annotation in the Stencil source code
605 */
606 original: string;
607 /**
608 * A 'resolved' type, where e.g. imported types have been resolved and inlined
609 *
610 * For instance, an annotation like `(foo: Foo) => string;` will be
611 * converted to `(foo: { foo: string }) => string;`.
612 */
613 resolved: string;
614 /**
615 * A record of the types which were referenced in the assorted type
616 * annotation in the original source file.
617 */
618 references: ComponentCompilerTypeReferences;
619}
620/**
621 * A record of `ComponentCompilerTypeReference` entities.
622 *
623 * Each key in this record is intended to be the names of the types used by a component. However, this is not enforced
624 * by the type system (I.E. any string can be used as a key).
625 *
626 * Note any key can be a user defined type or a TypeScript standard type.
627 */
628export type ComponentCompilerTypeReferences = Record<string, ComponentCompilerTypeReference>;
629/**
630 * Describes a reference to a type used by a component.
631 */
632export interface ComponentCompilerTypeReference {
633 /**
634 * A type may be defined:
635 * - locally (in the same file as the component that uses it)
636 * - globally
637 * - by importing it into a file (and is defined elsewhere)
638 */
639 location: 'local' | 'global' | 'import';
640 /**
641 * The path to the type reference, if applicable (global types should not need a path associated with them)
642 */
643 path?: string;
644 /**
645 * An ID for this type which is unique within a Stencil project.
646 */
647 id: string;
648}
649/**
650 * Information about a type which is referenced by another type on a Stencil
651 * component, for instance a {@link ComponentCompilerPropertyComplexType} or a
652 * {@link ComponentCompilerEventComplexType}.
653 */
654export interface ComponentCompilerReferencedType {
655 /**
656 * The path to the module where the type is declared.
657 */
658 path: string;
659 /**
660 * The string of the original type annotation in the Stencil source code
661 */
662 declaration: string;
663 /**
664 * An extracted docstring
665 */
666 docstring: string;
667}
668export interface ComponentCompilerStaticEvent {
669 name: string;
670 method: string;
671 bubbles: boolean;
672 cancelable: boolean;
673 composed: boolean;
674 docs: CompilerJsDoc;
675 complexType: ComponentCompilerEventComplexType;
676}
677export interface ComponentCompilerEvent extends ComponentCompilerStaticEvent {
678 internal: boolean;
679}
680export interface ComponentCompilerEventComplexType {
681 original: string;
682 resolved: string;
683 references: ComponentCompilerTypeReferences;
684}
685export interface ComponentCompilerListener {
686 name: string;
687 method: string;
688 capture: boolean;
689 passive: boolean;
690 target: ListenTargetOptions | undefined;
691}
692export interface ComponentCompilerStaticMethod {
693 docs: CompilerJsDoc;
694 complexType: ComponentCompilerMethodComplexType;
695}
696export interface ComponentCompilerMethodComplexType {
697 signature: string;
698 parameters: JsonDocMethodParameter[];
699 references: ComponentCompilerTypeReferences;
700 return: string;
701}
702export interface ComponentCompilerWatch {
703 propName: string;
704 methodName: string;
705}
706export interface ComponentCompilerMethod extends ComponentCompilerStaticMethod {
707 name: string;
708 internal: boolean;
709}
710export interface ComponentCompilerState {
711 name: string;
712}
713/**
714 * Representation of JSDoc that is pulled off a node in the AST
715 */
716export interface CompilerJsDoc {
717 /**
718 * The text associated with the JSDoc
719 */
720 text: string;
721 /**
722 * Tags included in the JSDoc
723 */
724 tags: CompilerJsDocTagInfo[];
725}
726/**
727 * Representation of a tag that exists in a JSDoc
728 */
729export interface CompilerJsDocTagInfo {
730 /**
731 * The name of the tag - e.g. `@deprecated`
732 */
733 name: string;
734 /**
735 * Additional text that is associated with the tag - e.g. `@deprecated use v2 of this API`
736 */
737 text?: string;
738}
739/**
740 * The (internal) representation of a CSS block comment in a CSS, Sass, etc. file. This data structure is used during
741 * the initial compilation phases of Stencil, as a piece of {@link ComponentCompilerMeta}.
742 */
743export interface CompilerStyleDoc {
744 /**
745 * The name of the CSS property
746 */
747 name: string;
748 /**
749 * The user-defined description of the CSS property
750 */
751 docs: string;
752 /**
753 * The JSDoc-style annotation (e.g. `@prop`) that was used in the block comment to detect the comment.
754 * Used to inform Stencil where the start of a new property's description starts (and where the previous description
755 * ends).
756 */
757 annotation: 'prop';
758 /**
759 * The Stencil style-mode that is associated with this property.
760 */
761 mode: string;
762}
763export interface CompilerAssetDir {
764 absolutePath?: string;
765 cmpRelativePath?: string;
766 originalComponentPath?: string;
767}
768export interface ComponentCompilerData {
769 exportLine: string;
770 filePath: string;
771 cmp: ComponentCompilerMeta;
772 uniqueComponentClassName?: string;
773 importLine?: string;
774}
775export interface ComponentConstructor {
776 is?: string;
777 properties?: ComponentConstructorProperties;
778 watchers?: ComponentConstructorWatchers;
779 events?: ComponentConstructorEvent[];
780 listeners?: ComponentConstructorListener[];
781 style?: string;
782 styleId?: string;
783 encapsulation?: ComponentConstructorEncapsulation;
784 observedAttributes?: string[];
785 cmpMeta?: ComponentRuntimeMeta;
786 isProxied?: boolean;
787 isStyleRegistered?: boolean;
788}
789/**
790 * A mapping from class member names to a list of methods which are watching
791 * them.
792 */
793export interface ComponentConstructorWatchers {
794 [propName: string]: string[];
795}
796export interface ComponentTestingConstructor extends ComponentConstructor {
797 COMPILER_META: ComponentCompilerMeta;
798 prototype?: {
799 componentWillLoad?: Function;
800 componentWillUpdate?: Function;
801 componentWillRender?: Function;
802 __componentWillLoad?: Function | null;
803 __componentWillUpdate?: Function | null;
804 __componentWillRender?: Function | null;
805 };
806}
807export interface ComponentNativeConstructor extends ComponentConstructor {
808 cmpMeta: ComponentRuntimeMeta;
809}
810export type ComponentConstructorEncapsulation = 'shadow' | 'scoped' | 'none';
811export interface ComponentConstructorProperties {
812 [propName: string]: ComponentConstructorProperty;
813}
814export interface ComponentConstructorProperty {
815 attribute?: string;
816 elementRef?: boolean;
817 method?: boolean;
818 mutable?: boolean;
819 reflect?: boolean;
820 state?: boolean;
821 type?: ComponentConstructorPropertyType;
822 watchCallbacks?: string[];
823}
824export type ComponentConstructorPropertyType = StringConstructor | BooleanConstructor | NumberConstructor | 'string' | 'boolean' | 'number';
825export interface ComponentConstructorEvent {
826 name: string;
827 method: string;
828 bubbles: boolean;
829 cancelable: boolean;
830 composed: boolean;
831}
832export interface ComponentConstructorListener {
833 name: string;
834 method: string;
835 capture?: boolean;
836 passive?: boolean;
837}
838export interface DevClientWindow extends Window {
839 ['s-dev-server']: boolean;
840 ['s-initial-load']: boolean;
841 ['s-build-id']: number;
842 WebSocket: new (socketUrl: string, protos: string[]) => WebSocket;
843 devServerConfig?: DevClientConfig;
844}
845export interface DevClientConfig {
846 basePath: string;
847 editors: DevServerEditor[];
848 reloadStrategy: PageReloadStrategy;
849 socketUrl?: string;
850}
851export interface HttpRequest {
852 method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS';
853 acceptHeader: string;
854 url: URL;
855 searchParams: URLSearchParams;
856 pathname?: string;
857 filePath?: string;
858 stats?: CompilerFsStats;
859 headers?: {
860 [name: string]: string;
861 };
862 host?: string;
863}
864export interface DevServerMessage {
865 startServer?: DevServerConfig;
866 closeServer?: boolean;
867 serverStarted?: DevServerConfig;
868 serverClosed?: boolean;
869 buildStart?: boolean;
870 buildLog?: BuildLog;
871 buildResults?: CompilerBuildResults;
872 requestBuildResults?: boolean;
873 error?: {
874 message?: string;
875 type?: string;
876 stack?: any;
877 };
878 isActivelyBuilding?: boolean;
879 compilerRequestPath?: string;
880 compilerRequestResults?: CompilerRequestResponse;
881 requestLog?: {
882 method: string;
883 url: string;
884 status: number;
885 };
886}
887export type DevServerSendMessage = (msg: DevServerMessage) => void;
888export interface DevServerContext {
889 connectorHtml: string;
890 dirTemplate: string;
891 getBuildResults: () => Promise<CompilerBuildResults>;
892 getCompilerRequest: (path: string) => Promise<CompilerRequestResponse>;
893 isServerListening: boolean;
894 logRequest: (req: HttpRequest, status: number) => void;
895 prerenderConfig: PrerenderConfig;
896 serve302: (req: any, res: any, pathname?: string) => void;
897 serve404: (req: any, res: any, xSource: string, content?: string) => void;
898 serve500: (req: any, res: any, error: any, xSource: string) => void;
899 sys: CompilerSystem;
900}
901export type InitServerProcess = (sendMsg: (msg: DevServerMessage) => void) => (msg: DevServerMessage) => void;
902export interface DevResponseHeaders {
903 'cache-control'?: string;
904 expires?: string;
905 'content-type'?: string;
906 'content-length'?: number;
907 date?: string;
908 'access-control-allow-origin'?: string;
909 'access-control-expose-headers'?: string;
910 'content-encoding'?: 'gzip';
911 vary?: 'Accept-Encoding';
912 server?: string;
913 'x-directory-index'?: string;
914 'x-source'?: string;
915}
916export interface OpenInEditorData {
917 file?: string;
918 line?: number;
919 column?: number;
920 open?: string;
921 editor?: string;
922 exists?: boolean;
923 error?: string;
924}
925export interface EntryModule {
926 entryKey: string;
927 cmps: ComponentCompilerMeta[];
928}
929/**
930 * An interface extending `HTMLElement` which describes the fields added onto
931 * host HTML elements by the Stencil runtime.
932 */
933export interface HostElement extends HTMLElement {
934 connectedCallback?: () => void;
935 attributeChangedCallback?: (attribName: string, oldVal: string, newVal: string, namespace: string) => void;
936 disconnectedCallback?: () => void;
937 host?: Element;
938 forceUpdate?: () => void;
939 /**
940 * Unique stencil id for this element
941 */
942 ['s-id']?: string;
943 /**
944 * Content Reference:
945 * Reference to the HTML Comment that's placed inside of the
946 * host element's original content. This comment is used to
947 * always represent where host element's light dom is.
948 */
949 ['s-cr']?: RenderNode;
950 /**
951 * Lifecycle ready
952 */
953 ['s-lr']?: boolean;
954 /**
955 * A reference to the `ElementInternals` object for the current host
956 *
957 * This is used for maintaining a reference to the object between HMR
958 * refreshes in the lazy build.
959 *
960 * "stencil-element-internals"
961 */
962 ['s-ei']?: ElementInternals;
963 /**
964 * On Render Callbacks:
965 * Array of callbacks to fire off after it has rendered.
966 */
967 ['s-rc']?: (() => void)[];
968 /**
969 * Scope Id
970 * The scope id of this component when using scoped css encapsulation
971 * or using shadow dom but the browser doesn't support it
972 */
973 ['s-sc']?: string;
974 /**
975 * Scope Ids
976 * All the possible scope ids of this component when using scoped css encapsulation
977 * or using shadow dom but the browser doesn't support it
978 */
979 ['s-scs']?: string[];
980 /**
981 * Hot Module Replacement, dev mode only
982 *
983 * This function should be defined by the HMR-supporting runtime and should
984 * do the work of actually updating the component in-place.
985 */
986 ['s-hmr']?: (versionId: string) => void;
987 ['s-p']?: Promise<void>[];
988 componentOnReady?: () => Promise<this>;
989}
990export interface HydrateResults {
991 buildId: string;
992 diagnostics: Diagnostic[];
993 url: string;
994 host: string | null;
995 hostname: string | null;
996 href: string | null;
997 port: string | null;
998 pathname: string | null;
999 search: string | null;
1000 hash: string | null;
1001 html: string | null;
1002 components: HydrateComponent[];
1003 anchors: HydrateAnchorElement[];
1004 imgs: HydrateImgElement[];
1005 scripts: HydrateScriptElement[];
1006 styles: HydrateStyleElement[];
1007 staticData: HydrateStaticData[];
1008 title: string | null;
1009 hydratedCount: number;
1010 httpStatus: number | null;
1011}
1012export interface HydrateComponent {
1013 tag: string;
1014 mode: string;
1015 count: number;
1016 depth: number;
1017}
1018export interface HydrateElement {
1019 [attrName: string]: string | undefined;
1020}
1021export interface HydrateAnchorElement extends HydrateElement {
1022 href?: string;
1023 target?: string;
1024}
1025export interface HydrateImgElement extends HydrateElement {
1026 src?: string;
1027}
1028export interface HydrateScriptElement extends HydrateElement {
1029 src?: string;
1030 type?: string;
1031}
1032export interface HydrateStyleElement extends HydrateElement {
1033 href?: string;
1034}
1035export interface HydrateStaticData {
1036 id: string;
1037 type: string;
1038 content: string;
1039}
1040export interface JsDoc {
1041 name: string;
1042 documentation: string;
1043 type: string;
1044 tags: JSDocTagInfo[];
1045 default?: string;
1046 parameters?: JsDoc[];
1047 returns?: {
1048 type: string;
1049 documentation: string;
1050 };
1051}
1052export interface JSDocTagInfo {
1053 name: string;
1054 text?: string;
1055}
1056/**
1057 * A mapping from a TypeScript or JavaScript source file path on disk, to a Stencil {@link Module}.
1058 *
1059 * It is advised that the key (path) be normalized before storing/retrieving the `Module` to avoid unnecessary lookup
1060 * failures.
1061 */
1062export type ModuleMap = Map<string, Module>;
1063/**
1064 * Stencil's Intermediate Representation (IR) of a module, bundling together
1065 * various pieces of information like the classes declared within it, the path
1066 * to the original source file, HTML tag names defined in the file, and so on.
1067 *
1068 * Note that this gets serialized/parsed as JSON and therefore cannot contain a
1069 * `Map` or a `Set`.
1070 */
1071export interface Module {
1072 cmps: ComponentCompilerMeta[];
1073 /**
1074 * A collection of modules that a component will need. The modules in this list must have import statements generated
1075 * in order for the component to function.
1076 */
1077 coreRuntimeApis: string[];
1078 /**
1079 * A collection of modules that a component will need for a specific output target. The modules in this list must
1080 * have import statements generated in order for the component to function, but only for a specific output target.
1081 */
1082 outputTargetCoreRuntimeApis: Partial<Record<OutputTarget['type'], string[]>>;
1083 collectionName: string;
1084 dtsFilePath: string;
1085 excludeFromCollection: boolean;
1086 externalImports: string[];
1087 htmlAttrNames: string[];
1088 htmlTagNames: string[];
1089 htmlParts: string[];
1090 isCollectionDependency: boolean;
1091 isLegacy: boolean;
1092 jsFilePath: string;
1093 localImports: string[];
1094 originalImports: string[];
1095 originalCollectionComponentPath: string;
1096 potentialCmpRefs: string[];
1097 sourceFilePath: string;
1098 staticSourceFile: any;
1099 staticSourceFileText: string;
1100 sourceMapPath: string;
1101 sourceMapFileText: string;
1102 hasVdomAttribute: boolean;
1103 hasVdomClass: boolean;
1104 hasVdomFunctional: boolean;
1105 hasVdomKey: boolean;
1106 hasVdomListener: boolean;
1107 hasVdomPropOrAttr: boolean;
1108 hasVdomRef: boolean;
1109 hasVdomRender: boolean;
1110 hasVdomStyle: boolean;
1111 hasVdomText: boolean;
1112 hasVdomXlink: boolean;
1113}
1114export interface Plugin {
1115 name?: string;
1116 pluginType?: string;
1117 load?: (id: string, context: PluginCtx) => Promise<string> | string;
1118 resolveId?: (importee: string, importer: string, context: PluginCtx) => Promise<string> | string;
1119 transform?: (sourceText: string, id: string, context: PluginCtx) => Promise<PluginTransformResults> | PluginTransformResults | string;
1120}
1121export interface PluginTransformResults {
1122 code?: string;
1123 map?: string;
1124 id?: string;
1125 diagnostics?: Diagnostic[];
1126 dependencies?: string[];
1127}
1128export interface PluginCtx {
1129 config: Config;
1130 sys: CompilerSystem;
1131 fs: InMemoryFileSystem;
1132 cache: Cache;
1133 diagnostics: Diagnostic[];
1134}
1135export interface PrerenderUrlResults {
1136 anchorUrls: string[];
1137 diagnostics: Diagnostic[];
1138 filePath: string;
1139}
1140export interface PrerenderUrlRequest {
1141 appDir: string;
1142 buildId: string;
1143 baseUrl: string;
1144 componentGraphPath: string;
1145 devServerHostUrl: string;
1146 hydrateAppFilePath: string;
1147 isDebug: boolean;
1148 prerenderConfigPath: string;
1149 staticSite: boolean;
1150 templateId: string;
1151 url: string;
1152 writeToFilePath: string;
1153}
1154export interface PrerenderManager {
1155 config: Config;
1156 prerenderUrlWorker: (prerenderRequest: PrerenderUrlRequest) => Promise<PrerenderUrlResults>;
1157 devServerHostUrl: string;
1158 diagnostics: Diagnostic[];
1159 hydrateAppFilePath: string;
1160 isDebug: boolean;
1161 logCount: number;
1162 outputTarget: OutputTargetWww;
1163 prerenderConfig: PrerenderConfig;
1164 prerenderConfigPath: string;
1165 progressLogger?: LoggerLineUpdater;
1166 resolve: Function;
1167 staticSite: boolean;
1168 templateId: string;
1169 componentGraphPath: string;
1170 urlsProcessing: Set<string>;
1171 urlsPending: Set<string>;
1172 urlsCompleted: Set<string>;
1173 maxConcurrency: number;
1174}
1175/**
1176 * Generic node that represents all of the
1177 * different types of nodes we'd see when rendering
1178 */
1179export interface RenderNode extends HostElement {
1180 /**
1181 * Shadow root's host
1182 */
1183 host?: Element;
1184 /**
1185 * On Ref Function:
1186 * Callback function to be called when the slotted node ref is ready.
1187 */
1188 ['s-rf']?: (elm: Element) => unknown;
1189 /**
1190 * Is initially hidden
1191 * Whether this node was originally rendered with the `hidden` attribute.
1192 *
1193 * Used to reset the `hidden` state of a node during slot relocation.
1194 */
1195 ['s-ih']?: boolean;
1196 /**
1197 * Is Content Reference Node:
1198 * This node is a content reference node.
1199 */
1200 ['s-cn']?: boolean;
1201 /**
1202 * Is a slot reference node:
1203 * This is a node that represents where a slot
1204 * was originally located.
1205 */
1206 ['s-sr']?: boolean;
1207 /**
1208 * Slot name
1209 */
1210 ['s-sn']?: string;
1211 /**
1212 * Host element tag name:
1213 * The tag name of the host element that this
1214 * node was created in.
1215 */
1216 ['s-hn']?: string;
1217 /**
1218 * Slot host tag name:
1219 * This is the tag name of the element where this node
1220 * has been moved to during slot relocation.
1221 *
1222 * This allows us to check if the node has been moved and prevent
1223 * us from thinking a node _should_ be moved when it may already be in
1224 * its final destination.
1225 *
1226 * This value is set to `undefined` whenever the node is put back into its original location.
1227 */
1228 ['s-sh']?: string;
1229 /**
1230 * Original Location Reference:
1231 * A reference pointing to the comment
1232 * which represents the original location
1233 * before it was moved to its slot.
1234 */
1235 ['s-ol']?: RenderNode;
1236 /**
1237 * Node reference:
1238 * This is a reference for a original location node
1239 * back to the node that's been moved around.
1240 */
1241 ['s-nr']?: RenderNode;
1242 /**
1243 * Scope Id
1244 */
1245 ['s-si']?: string;
1246 /**
1247 * Host Id (hydrate only)
1248 */
1249 ['s-host-id']?: number;
1250 /**
1251 * Node Id (hydrate only)
1252 */
1253 ['s-node-id']?: number;
1254 /**
1255 * Used to know the components encapsulation.
1256 * empty "" for shadow, "c" from scoped
1257 */
1258 ['s-en']?: '' | /*shadow*/ 'c';
1259}
1260export type LazyBundlesRuntimeData = LazyBundleRuntimeData[];
1261export type LazyBundleRuntimeData = [
1262 /** bundleIds */
1263 string,
1264 ComponentRuntimeMetaCompact[]
1265];
1266export type ComponentRuntimeMetaCompact = [
1267 /** flags */
1268 number,
1269 /** tagname */
1270 string,
1271 /** members */
1272 {
1273 [memberName: string]: ComponentRuntimeMember;
1274 }?,
1275 /** listeners */
1276 ComponentRuntimeHostListener[]?,
1277 /** watchers */
1278 ComponentConstructorWatchers?
1279];
1280/**
1281 * Runtime metadata for a Stencil component
1282 */
1283export interface ComponentRuntimeMeta {
1284 /**
1285 * This number is used to hold a series of bitflags for various features we
1286 * support on components. The flags which this value is intended to store are
1287 * documented in the `CMP_FLAGS` enum.
1288 */
1289 $flags$: number;
1290 /**
1291 * Just what it says on the tin - the tag name for the component, as set in
1292 * the `@Component` decorator.
1293 */
1294 $tagName$: string;
1295 /**
1296 * A map of the component's members, which could include fields decorated
1297 * with `@Prop`, `@State`, etc as well as methods.
1298 */
1299 $members$?: ComponentRuntimeMembers;
1300 /**
1301 * Information about listeners on the component.
1302 */
1303 $listeners$?: ComponentRuntimeHostListener[];
1304 /**
1305 * Tuples containing information about `@Prop` fields on the component which
1306 * are set to be reflected (i.e. kept in sync) as HTML attributes when
1307 * updated.
1308 */
1309 $attrsToReflect$?: ComponentRuntimeReflectingAttr[];
1310 /**
1311 * Information about which class members have watchers attached on the component.
1312 */
1313 $watchers$?: ComponentConstructorWatchers;
1314 /**
1315 * A bundle ID used for lazy loading.
1316 */
1317 $lazyBundleId$?: string;
1318}
1319/**
1320 * A mapping of the names of members on the component to some runtime-specific
1321 * information about them.
1322 */
1323export interface ComponentRuntimeMembers {
1324 [memberName: string]: ComponentRuntimeMember;
1325}
1326/**
1327 * A tuple with information about a class member that's relevant at runtime.
1328 * The fields are:
1329 *
1330 * 1. A number used to hold bitflags for component members. The bit flags which
1331 * this is intended to store are documented in the `MEMBER_FLAGS` enum.
1332 * 2. The attribute name to observe.
1333 */
1334export type ComponentRuntimeMember = [number, string?];
1335/**
1336 * A tuple holding information about a host listener which is relevant at
1337 * runtime. The field are:
1338 *
1339 * 1. A number used to hold bitflags for listeners. The bit flags which this is
1340 * intended to store are documented in the `LISTENER_FLAGS` enum.
1341 * 2. The event name.
1342 * 3. The method name.
1343 */
1344export type ComponentRuntimeHostListener = [number, string, string];
1345/**
1346 * A tuple containing information about props which are "reflected" at runtime,
1347 * meaning that HTML attributes on the component instance are kept in sync with
1348 * the prop value.
1349 *
1350 * The fields are:
1351 *
1352 * 1. the prop name
1353 * 2. the prop attribute.
1354 */
1355export type ComponentRuntimeReflectingAttr = [string, string | undefined];
1356/**
1357 * A runtime component reference, consistent of either a host element _or_ an
1358 * empty object. This is used in particular in a few different places as the
1359 * keys in a `WeakMap` which maps {@link HostElement} instances to their
1360 * associated {@link HostRef} instance.
1361 */
1362export type RuntimeRef = HostElement | {};
1363/**
1364 * Interface used to track an Element, it's virtual Node (`VNode`), and other data
1365 */
1366export interface HostRef {
1367 $ancestorComponent$?: HostElement;
1368 $flags$: number;
1369 $cmpMeta$: ComponentRuntimeMeta;
1370 $hostElement$: HostElement;
1371 $instanceValues$?: Map<string, any>;
1372 $lazyInstance$?: ComponentInterface;
1373 /**
1374 * A promise that gets resolved if `BUILD.asyncLoading` is enabled and after the `componentDidLoad`
1375 * and before the `componentDidUpdate` lifecycle events are triggered.
1376 */
1377 $onReadyPromise$?: Promise<HostElement>;
1378 /**
1379 * A callback which resolves {@link HostRef.$onReadyPromise$}
1380 * @param elm host element
1381 */
1382 $onReadyResolve$?: (elm: HostElement) => void;
1383 /**
1384 * A promise which resolves with the host component once it has finished rendering
1385 * for the first time. This is primarily used to wait for the first `update` to be
1386 * called on a component.
1387 */
1388 $onInstancePromise$?: Promise<HostElement>;
1389 /**
1390 * A callback which resolves {@link HostRef.$onInstancePromise$}
1391 * @param elm host element
1392 */
1393 $onInstanceResolve$?: (elm: HostElement) => void;
1394 /**
1395 * A promise which resolves when the component has finished rendering for the first time.
1396 * It is called after {@link HostRef.$onInstancePromise$} resolves.
1397 */
1398 $onRenderResolve$?: () => void;
1399 $vnode$?: VNode;
1400 $queuedListeners$?: [string, any][];
1401 $rmListeners$?: (() => void)[];
1402 $modeName$?: string;
1403 $renderCount$?: number;
1404}
1405export interface PlatformRuntime {
1406 /**
1407 * This number is used to hold a series of bitflags for various features we
1408 * support within the runtime. The flags which this value is intended to store are
1409 * documented in the {@link PLATFORM_FLAGS} enum.
1410 */
1411 $flags$: number;
1412 /**
1413 * Holds a map of nodes to be hydrated.
1414 */
1415 $orgLocNodes$?: Map<string, RenderNode>;
1416 /**
1417 * Holds the resource url for given platform environment.
1418 */
1419 $resourcesUrl$: string;
1420 /**
1421 * The nonce value to be applied to all script/style tags at runtime.
1422 * If `null`, the nonce attribute will not be applied.
1423 */
1424 $nonce$?: string | null;
1425 /**
1426 * A utility function that executes a given function and returns the result.
1427 * @param c The callback function to execute
1428 */
1429 jmp: (c: Function) => any;
1430 /**
1431 * A wrapper for {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame `requestAnimationFrame`}
1432 */
1433 raf: (c: FrameRequestCallback) => number;
1434 /**
1435 * A wrapper for {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener `addEventListener`}
1436 */
1437 ael: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
1438 /**
1439 * A wrapper for {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener `removeEventListener`}
1440 */
1441 rel: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
1442 /**
1443 * A wrapper for creating a {@link https://developer.mozilla.org/docs/Web/API/CustomEvent `CustomEvent`}
1444 */
1445 ce: (eventName: string, opts?: any) => CustomEvent;
1446}
1447export type StyleMap = Map<string, CSSStyleSheet | string>;
1448export type RootAppliedStyleMap = WeakMap<Element, Set<string>>;
1449export interface ScreenshotConnector {
1450 initBuild(opts: ScreenshotConnectorOptions): Promise<void>;
1451 completeBuild(masterBuild: ScreenshotBuild): Promise<ScreenshotBuildResults>;
1452 getMasterBuild(): Promise<ScreenshotBuild>;
1453 pullMasterBuild(): Promise<void>;
1454 publishBuild(buildResults: ScreenshotBuildResults): Promise<ScreenshotBuildResults>;
1455 getScreenshotCache(): Promise<ScreenshotCache>;
1456 updateScreenshotCache(screenshotCache: ScreenshotCache, buildResults: ScreenshotBuildResults): Promise<ScreenshotCache>;
1457 generateJsonpDataUris(build: ScreenshotBuild): Promise<void>;
1458 sortScreenshots(screenshots: Screenshot[]): Screenshot[];
1459 toJson(masterBuild: ScreenshotBuild, screenshotCache: ScreenshotCache): string;
1460}
1461export interface ScreenshotBuildResults {
1462 appNamespace: string;
1463 masterBuild: ScreenshotBuild;
1464 currentBuild: ScreenshotBuild;
1465 compare: ScreenshotCompareResults;
1466}
1467export interface ScreenshotCompareResults {
1468 id: string;
1469 a: {
1470 id: string;
1471 message: string;
1472 author: string;
1473 url: string;
1474 previewUrl: string;
1475 };
1476 b: {
1477 id: string;
1478 message: string;
1479 author: string;
1480 url: string;
1481 previewUrl: string;
1482 };
1483 timestamp: number;
1484 url: string;
1485 appNamespace: string;
1486 diffs: ScreenshotDiff[];
1487}
1488export interface ScreenshotConnectorOptions {
1489 buildId: string;
1490 buildMessage: string;
1491 buildAuthor?: string;
1492 buildUrl?: string;
1493 previewUrl?: string;
1494 appNamespace: string;
1495 buildTimestamp: number;
1496 logger: Logger;
1497 rootDir: string;
1498 cacheDir: string;
1499 packageDir: string;
1500 screenshotDirName?: string;
1501 imagesDirName?: string;
1502 buildsDirName?: string;
1503 currentBuildDir?: string;
1504 updateMaster?: boolean;
1505 allowableMismatchedPixels?: number;
1506 allowableMismatchedRatio?: number;
1507 pixelmatchThreshold?: number;
1508 waitBeforeScreenshot?: number;
1509 pixelmatchModulePath?: string;
1510}
1511export interface ScreenshotBuildData {
1512 buildId: string;
1513 rootDir: string;
1514 screenshotDir: string;
1515 imagesDir: string;
1516 buildsDir: string;
1517 currentBuildDir: string;
1518 updateMaster: boolean;
1519 allowableMismatchedPixels: number;
1520 allowableMismatchedRatio: number;
1521 pixelmatchThreshold: number;
1522 masterScreenshots: {
1523 [screenshotId: string]: string;
1524 };
1525 cache: {
1526 [cacheKey: string]: number;
1527 };
1528 timeoutBeforeScreenshot: number;
1529 pixelmatchModulePath: string;
1530}
1531export interface PixelMatchInput {
1532 imageAPath: string;
1533 imageBPath: string;
1534 width: number;
1535 height: number;
1536 pixelmatchThreshold: number;
1537}
1538export interface ScreenshotBuild {
1539 id: string;
1540 message: string;
1541 author?: string;
1542 url?: string;
1543 previewUrl?: string;
1544 appNamespace: string;
1545 timestamp: number;
1546 screenshots: Screenshot[];
1547}
1548export interface ScreenshotCache {
1549 timestamp?: number;
1550 lastBuildId?: string;
1551 size?: number;
1552 items?: {
1553 /**
1554 * Cache key
1555 */
1556 key: string;
1557 /**
1558 * Timestamp used to remove the oldest data
1559 */
1560 ts: number;
1561 /**
1562 * Mismatched pixels
1563 */
1564 mp: number;
1565 }[];
1566}
1567export interface Screenshot {
1568 id: string;
1569 desc?: string;
1570 image: string;
1571 device?: string;
1572 userAgent?: string;
1573 width: number;
1574 height: number;
1575 deviceScaleFactor?: number;
1576 hasTouch?: boolean;
1577 isLandscape?: boolean;
1578 isMobile?: boolean;
1579 testPath?: string;
1580 diff?: ScreenshotDiff;
1581}
1582export interface ScreenshotDiff {
1583 mismatchedPixels: number;
1584 id: string;
1585 desc?: string;
1586 imageA?: string;
1587 imageB?: string;
1588 device?: string;
1589 userAgent?: string;
1590 width: number;
1591 height: number;
1592 deviceScaleFactor?: number;
1593 hasTouch?: boolean;
1594 isLandscape?: boolean;
1595 isMobile?: boolean;
1596 allowableMismatchedPixels: number;
1597 allowableMismatchedRatio: number;
1598 testPath?: string;
1599 cacheKey?: string;
1600}
1601export interface ScreenshotOptions {
1602 /**
1603 * When true, takes a screenshot of the full scrollable page.
1604 * Default: `false`
1605 */
1606 fullPage?: boolean;
1607 /**
1608 * An object which specifies clipping region of the page.
1609 */
1610 clip?: ScreenshotBoundingBox;
1611 /**
1612 * Hides default white background and allows capturing screenshots with transparency.
1613 * Default: `false`
1614 */
1615 omitBackground?: boolean;
1616 /**
1617 * Matching threshold, ranges from `0` to 1. Smaller values make the comparison
1618 * more sensitive. Defaults to the testing config `pixelmatchThreshold` value;
1619 */
1620 pixelmatchThreshold?: number;
1621 /**
1622 * Capture the screenshot beyond the viewport.
1623 *
1624 * @defaultValue `false` if there is no `clip`. `true` otherwise.
1625 */
1626 captureBeyondViewport?: boolean;
1627}
1628export interface ScreenshotBoundingBox {
1629 /**
1630 * The x-coordinate of top-left corner.
1631 */
1632 x: number;
1633 /**
1634 * The y-coordinate of top-left corner.
1635 */
1636 y: number;
1637 /**
1638 * The width in pixels.
1639 */
1640 width: number;
1641 /**
1642 * The height in pixels.
1643 */
1644 height: number;
1645}
1646export interface StyleCompiler {
1647 modeName: string;
1648 styleId: string;
1649 styleStr: string;
1650 styleIdentifier: string;
1651 externalStyles: ExternalStyleCompiler[];
1652}
1653export interface ExternalStyleCompiler {
1654 absolutePath: string;
1655 relativePath: string;
1656 originalComponentPath: string;
1657}
1658export interface CompilerModeStyles {
1659 [modeName: string]: string[];
1660}
1661export interface CssImportData {
1662 srcImport: string;
1663 updatedImport?: string;
1664 url: string;
1665 filePath: string;
1666 altFilePath?: string;
1667 styleText?: string | null;
1668}
1669export interface CssToEsmImportData {
1670 srcImportText: string;
1671 varName: string;
1672 url: string;
1673 filePath: string;
1674}
1675/**
1676 * Input CSS to be transformed into ESM
1677 */
1678export interface TransformCssToEsmInput {
1679 input: string;
1680 module?: 'cjs' | 'esm' | string;
1681 file?: string;
1682 tag?: string;
1683 encapsulation?: string;
1684 /**
1685 * The mode under which the CSS will be applied.
1686 *
1687 * Corresponds to a key used when `@Component`'s `styleUrls` field is an object:
1688 * ```ts
1689 * @Component({
1690 * tag: 'todo-list',
1691 * styleUrls: {
1692 * ios: 'todo-list.ios.scss',
1693 * md: 'todo-list.md.scss',
1694 * }
1695 * })
1696 * ```
1697 * In the example above, two `TransformCssToEsmInput`s should be created, one for 'ios' and one for 'md' (this field
1698 * is not shared by multiple fields, nor is it a composite of multiple modes).
1699 */
1700 mode?: string;
1701 sourceMap?: boolean;
1702 minify?: boolean;
1703 docs?: boolean;
1704 autoprefixer?: any;
1705 styleImportData?: string;
1706}
1707export interface TransformCssToEsmOutput {
1708 styleText: string;
1709 output: string;
1710 map: any;
1711 diagnostics: Diagnostic[];
1712 defaultVarName: string;
1713 styleDocs: StyleDoc[];
1714 imports: {
1715 varName: string;
1716 importPath: string;
1717 }[];
1718}
1719export interface PackageJsonData {
1720 name?: string;
1721 version?: string;
1722 main?: string;
1723 exports?: {
1724 [key: string]: string | {
1725 [key: string]: string;
1726 };
1727 };
1728 description?: string;
1729 bin?: {
1730 [key: string]: string;
1731 };
1732 browser?: string;
1733 module?: string;
1734 'jsnext:main'?: string;
1735 'collection:main'?: string;
1736 unpkg?: string;
1737 collection?: string;
1738 types?: string;
1739 files?: string[];
1740 ['dist-tags']?: {
1741 latest: string;
1742 };
1743 dependencies?: {
1744 [moduleId: string]: string;
1745 };
1746 devDependencies?: {
1747 [moduleId: string]: string;
1748 };
1749 repository?: {
1750 type?: string;
1751 url?: string;
1752 };
1753 private?: boolean;
1754 scripts?: {
1755 [runName: string]: string;
1756 };
1757 license?: string;
1758 keywords?: string[];
1759}
1760export interface Workbox {
1761 generateSW(swConfig: any): Promise<any>;
1762 generateFileManifest(): Promise<any>;
1763 getFileManifestEntries(): Promise<any>;
1764 injectManifest(swConfig: any): Promise<any>;
1765 copyWorkboxLibraries(wwwDir: string): Promise<any>;
1766}
1767declare global {
1768 namespace jest {
1769 interface Matchers<R, T> {
1770 /**
1771 * Compares HTML, but first normalizes the HTML so all
1772 * whitespace, attribute order and css class order are
1773 * the same. When given an element, it will compare
1774 * the element's `outerHTML`. When given a Document Fragment,
1775 * such as a Shadow Root, it'll compare its `innerHTML`.
1776 * Otherwise it'll compare two strings representing HTML.
1777 */
1778 toEqualHtml(expectHtml: string): void;
1779 /**
1780 * Compares HTML light DOM only, but first normalizes the HTML so all
1781 * whitespace, attribute order and css class order are
1782 * the same. When given an element, it will compare
1783 * the element's `outerHTML`. When given a Document Fragment,
1784 * such as a Shadow Root, it'll compare its `innerHTML`.
1785 * Otherwise it'll compare two strings representing HTML.
1786 */
1787 toEqualLightHtml(expectLightHtml: string): void;
1788 /**
1789 * When given an element, it'll compare the element's
1790 * `textContent`. Otherwise it'll compare two strings. This
1791 * matcher will also `trim()` each string before comparing.
1792 */
1793 toEqualText(expectTextContent: string): void;
1794 /**
1795 * Checks if an element simply has the attribute. It does
1796 * not check any values of the attribute
1797 */
1798 toHaveAttribute(expectAttrName: string): void;
1799 /**
1800 * Checks if an element's attribute value equals the expect value.
1801 */
1802 toEqualAttribute(expectAttrName: string, expectAttrValue: any): void;
1803 /**
1804 * Checks if an element's has each of the expected attribute
1805 * names and values.
1806 */
1807 toEqualAttributes(expectAttrs: {
1808 [attrName: string]: any;
1809 }): void;
1810 /**
1811 * Checks if an element has the expected css class.
1812 */
1813 toHaveClass(expectClassName: string): void;
1814 /**
1815 * Checks if an element has each of the expected css classes
1816 * in the array.
1817 */
1818 toHaveClasses(expectClassNames: string[]): void;
1819 /**
1820 * Checks if an element has the exact same css classes
1821 * as the expected array of css classes.
1822 */
1823 toMatchClasses(expectClassNames: string[]): void;
1824 /**
1825 * When given an EventSpy, checks if the event has been
1826 * received or not.
1827 */
1828 toHaveReceivedEvent(): void;
1829 /**
1830 * When given an EventSpy, checks how many times the
1831 * event has been received.
1832 */
1833 toHaveReceivedEventTimes(count: number): void;
1834 /**
1835 * When given an EventSpy, checks the event has
1836 * received the correct custom event `detail` data.
1837 */
1838 toHaveReceivedEventDetail(eventDetail: any): void;
1839 /**
1840 * When given an EventSpy, checks the first event has
1841 * received the correct custom event `detail` data.
1842 */
1843 toHaveFirstReceivedEventDetail(eventDetail: any): void;
1844 /**
1845 * When given an EventSpy, checks the last event has
1846 * received the correct custom event `detail` data.
1847 */
1848 toHaveLastReceivedEventDetail(eventDetail: any): void;
1849 /**
1850 * When given an EventSpy, checks the event at an index
1851 * has received the correct custom event `detail` data.
1852 */
1853 toHaveNthReceivedEventDetail(index: number, eventDetail: any): void;
1854 /**
1855 * Used to evaluate the results of `compareScreenshot()`, such as
1856 * `expect(compare).toMatchScreenshot()`. The `allowableMismatchedRatio`
1857 * value from the testing config is used by default if
1858 * `MatchScreenshotOptions` were not provided.
1859 */
1860 toMatchScreenshot(opts?: MatchScreenshotOptions): void;
1861 }
1862 }
1863}
1864export interface MatchScreenshotOptions {
1865 /**
1866 * The `allowableMismatchedPixels` value is the total number of pixels
1867 * that can be mismatched until the test fails. For example, if the value
1868 * is `100`, and if there were `101` pixels that were mismatched then the
1869 * test would fail. If the `allowableMismatchedRatio` is provided it will
1870 * take precedence, otherwise `allowableMismatchedPixels` will be used.
1871 */
1872 allowableMismatchedPixels?: number;
1873 /**
1874 * The `allowableMismatchedRatio` ranges from `0` to `1` and is used to
1875 * determine an acceptable ratio of pixels that can be mismatched before
1876 * the image is considered to have changes. Realistically, two screenshots
1877 * representing the same content may have a small number of pixels that
1878 * are not identical due to anti-aliasing, which is perfectly normal. The
1879 * `allowableMismatchedRatio` is the number of pixels that were mismatched,
1880 * divided by the total number of pixels in the screenshot. For example,
1881 * a ratio value of `0.06` means 6% of the pixels can be mismatched before
1882 * the image is considered to have changes. If the `allowableMismatchedRatio`
1883 * is provided it will take precedence, otherwise `allowableMismatchedPixels`
1884 * will be used.
1885 */
1886 allowableMismatchedRatio?: number;
1887}
1888export interface EventSpy {
1889 events: SerializedEvent[];
1890 eventName: string;
1891 firstEvent: SerializedEvent;
1892 lastEvent: SerializedEvent;
1893 length: number;
1894 next(): Promise<{
1895 done: boolean;
1896 value: SerializedEvent;
1897 }>;
1898}
1899export interface SerializedEvent {
1900 bubbles: boolean;
1901 cancelBubble: boolean;
1902 cancelable: boolean;
1903 composed: boolean;
1904 currentTarget: any;
1905 defaultPrevented: boolean;
1906 detail: any;
1907 eventPhase: any;
1908 isTrusted: boolean;
1909 returnValue: any;
1910 srcElement: any;
1911 target: any;
1912 timeStamp: number;
1913 type: string;
1914 isSerializedEvent: boolean;
1915}
1916export interface EventInitDict {
1917 bubbles?: boolean;
1918 cancelable?: boolean;
1919 composed?: boolean;
1920 detail?: any;
1921}
1922export interface JestEnvironmentGlobal {
1923 __NEW_TEST_PAGE__: () => Promise<any>;
1924 __CLOSE_OPEN_PAGES__: () => Promise<any>;
1925 loadTestWindow: (testWindow: any) => Promise<void>;
1926 h: any;
1927 resourcesUrl: string;
1928 currentSpec?: {
1929 id?: string;
1930 description: string;
1931 fullName: string;
1932 testPath: string | null;
1933 };
1934 env: {
1935 [prop: string]: string;
1936 };
1937 screenshotDescriptions: Set<string>;
1938}
1939export interface E2EProcessEnv {
1940 STENCIL_COMMIT_ID?: string;
1941 STENCIL_COMMIT_MESSAGE?: string;
1942 STENCIL_REPO_URL?: string;
1943 STENCIL_SCREENSHOT_CONNECTOR?: string;
1944 STENCIL_SCREENSHOT_SERVER?: string;
1945 __STENCIL_EMULATE_CONFIGS__?: string;
1946 __STENCIL_ENV__?: string;
1947 __STENCIL_EMULATE__?: string;
1948 __STENCIL_BROWSER_URL__?: string;
1949 __STENCIL_APP_SCRIPT_URL__?: string;
1950 __STENCIL_APP_STYLE_URL__?: string;
1951 __STENCIL_BROWSER_WS_ENDPOINT__?: string;
1952 __STENCIL_BROWSER_WAIT_UNTIL?: string;
1953 __STENCIL_SCREENSHOT__?: 'true';
1954 __STENCIL_SCREENSHOT_BUILD__?: string;
1955 __STENCIL_SCREENSHOT_TIMEOUT_MS__?: string;
1956 __STENCIL_E2E_TESTS__?: 'true';
1957 __STENCIL_E2E_DEVTOOLS__?: 'true';
1958 __STENCIL_SPEC_TESTS__?: 'true';
1959 __STENCIL_PUPPETEER_MODULE__?: string;
1960 __STENCIL_PUPPETEER_VERSION__?: number;
1961 __STENCIL_DEFAULT_TIMEOUT__?: string;
1962 /**
1963 * Property for injecting transformAliasedImportPaths into the Jest context
1964 */
1965 __STENCIL_TRANSPILE_PATHS__?: 'true' | 'false';
1966}
1967export interface AnyHTMLElement extends HTMLElement {
1968 [key: string]: any;
1969}
1970export interface SpecPage {
1971 /**
1972 * Mocked testing `document.body`.
1973 */
1974 body: HTMLBodyElement;
1975 /**
1976 * Mocked testing `document`.
1977 */
1978 doc: HTMLDocument;
1979 /**
1980 * The first component found within the mocked `document.body`. If a component isn't found, then it'll return `document.body.firstElementChild`.
1981 */
1982 root?: AnyHTMLElement;
1983 /**
1984 * Similar to `root`, except returns the component instance. If a root component was not found it'll return `null`.
1985 */
1986 rootInstance?: any;
1987 /**
1988 * Convenience function to set `document.body.innerHTML` and `waitForChanges()`. Function argument should be a HTML string.
1989 */
1990 setContent: (html: string) => Promise<any>;
1991 /**
1992 * After changes have been made to a component, such as a update to a property or attribute, the test page does not automatically apply the changes. In order to wait for, and apply the update, call `await page.waitForChanges()`.
1993 */
1994 waitForChanges: () => Promise<any>;
1995 /**
1996 * Mocked testing `window`.
1997 */
1998 win: Window;
1999 build: BuildConditionals;
2000 flushLoadModule: (bundleId?: string) => Promise<any>;
2001 flushQueue: () => Promise<any>;
2002 styles: Map<string, string>;
2003}
2004/**
2005 * Options pertaining to the creation and functionality of a {@link SpecPage}
2006 */
2007export interface NewSpecPageOptions {
2008 /**
2009 * An array of components to test. Component classes can be imported into the spec file, then their reference should be added to the `component` array in order to be used throughout the test.
2010 */
2011 components: any[];
2012 /**
2013 * Sets the mocked `document.cookie`.
2014 */
2015 cookie?: string;
2016 /**
2017 * Sets the mocked `dir` attribute on `<html>`.
2018 */
2019 direction?: string;
2020 /**
2021 * If `false`, do not flush the render queue on initial test setup.
2022 */
2023 flushQueue?: boolean;
2024 /**
2025 * The initial HTML used to generate the test. This can be useful to construct a collection of components working together, and assign HTML attributes. This value sets the mocked `document.body.innerHTML`.
2026 */
2027 html?: string;
2028 /**
2029 * The initial JSX used to generate the test.
2030 * Use `template` when you want to initialize a component using their properties, instead of their HTML attributes.
2031 * It will render the specified template (JSX) into `document.body`.
2032 */
2033 template?: () => any;
2034 /**
2035 * Sets the mocked `lang` attribute on `<html>`.
2036 */
2037 language?: string;
2038 /**
2039 * Useful for debugging hydrating components client-side. Sets that the `html` option already includes annotated prerender attributes and comments.
2040 */
2041 hydrateClientSide?: boolean;
2042 /**
2043 * Useful for debugging hydrating components server-side. The output HTML will also include prerender annotations.
2044 */
2045 hydrateServerSide?: boolean;
2046 /**
2047 * Sets the mocked `document.referrer`.
2048 */
2049 referrer?: string;
2050 /**
2051 * Manually set if the mocked document supports Shadow DOM or not. Default is `true`.
2052 */
2053 supportsShadowDom?: boolean;
2054 /**
2055 * When a component is pre-rendered it includes HTML annotations, such as `s-id` attributes and `<!-t.0->` comments. This information is used by client-side hydrating. Default is `false`.
2056 */
2057 includeAnnotations?: boolean;
2058 /**
2059 * Sets the mocked browser's `location.href`.
2060 */
2061 url?: string;
2062 /**
2063 * Sets the mocked browser's `navigator.userAgent`.
2064 */
2065 userAgent?: string;
2066 /**
2067 * By default, any changes to component properties and attributes must `page.waitForChanges()` in order to test the updates. As an option, `autoApplyChanges` continuously flushes the queue on the background. Default is `false`.
2068 */
2069 autoApplyChanges?: boolean;
2070 /**
2071 * By default, styles are not attached to the DOM and they are not reflected in the serialized HTML.
2072 * Setting this option to `true` will include the component's styles in the serializable output.
2073 */
2074 attachStyles?: boolean;
2075 /**
2076 * Set {@link BuildConditionals} for testing based off the metadata of the component under test.
2077 * When `true` all `BuildConditionals` will be assigned to the global testing `BUILD` object, regardless of their
2078 * value. When `false`, only `BuildConditionals` with a value of `true` will be assigned to the `BUILD` object.
2079 */
2080 strictBuild?: boolean;
2081 /**
2082 * Default values to be set on the platform runtime object {@see PlatformRuntime} when creating
2083 * the spec page.
2084 */
2085 platform?: Partial<PlatformRuntime>;
2086}
2087/**
2088 * A record of `TypesMemberNameData` entities.
2089 *
2090 * Each key in this record is intended to be the path to a file that declares one or more types used by a component.
2091 * However, this is not enforced by the type system - users of this interface should not make any assumptions regarding
2092 * the format of the path used as a key (relative vs. absolute)
2093 */
2094export interface TypesImportData {
2095 [key: string]: TypesMemberNameData[];
2096}
2097/**
2098 * A type describing how Stencil may alias an imported type to avoid naming collisions when performing operations such
2099 * as generating `components.d.ts` files.
2100 */
2101export interface TypesMemberNameData {
2102 /**
2103 * The original name of the import before any aliasing was applied.
2104 *
2105 * i.e. if a component imports a type as follows:
2106 * `import { MyType as MyCoolType } from './my-type';`
2107 *
2108 * the `originalName` would be 'MyType'. If the import is not aliased, then `originalName` and `localName` will be the same.
2109 */
2110 originalName: string;
2111 /**
2112 * The name of the type as it's used within a file.
2113 */
2114 localName: string;
2115 /**
2116 * An alias that Stencil may apply to the `localName` to avoid naming collisions. This name does not appear in the
2117 * file that is using `localName`.
2118 */
2119 importName?: string;
2120}
2121export interface TypesModule {
2122 isDep: boolean;
2123 tagName: string;
2124 tagNameAsPascal: string;
2125 htmlElementName: string;
2126 component: string;
2127 jsx: string;
2128 element: string;
2129}
2130export type TypeInfo = {
2131 name: string;
2132 type: string;
2133 optional: boolean;
2134 required: boolean;
2135 internal: boolean;
2136 jsdoc?: string;
2137}[];
2138export type ChildType = VNode | number | string;
2139export type PropsType = VNodeProdData | number | string | null;
2140export interface VNodeProdData {
2141 key?: string | number;
2142 class?: {
2143 [className: string]: boolean;
2144 } | string;
2145 className?: {
2146 [className: string]: boolean;
2147 } | string;
2148 style?: any;
2149 [key: string]: any;
2150}
2151/**
2152 * An abstraction to bundle up four methods which _may_ be handled by
2153 * dispatching work to workers running in other OS threads or may be called
2154 * synchronously. Environment and `CompilerSystem` related setup code will
2155 * determine which one, but in either case the call sites for these methods can
2156 * dispatch to this shared interface.
2157 */
2158export interface CompilerWorkerContext {
2159 optimizeCss(inputOpts: OptimizeCssInput): Promise<OptimizeCssOutput>;
2160 prepareModule(input: string, minifyOpts: any, transpile: boolean, inlineHelpers: boolean): Promise<{
2161 output: string;
2162 diagnostics: Diagnostic[];
2163 sourceMap?: SourceMap;
2164 }>;
2165 prerenderWorker(prerenderRequest: PrerenderUrlRequest): Promise<PrerenderUrlResults>;
2166 transformCssToEsm(input: TransformCssToEsmInput): Promise<TransformCssToEsmOutput>;
2167}
2168/**
2169 * The methods that are supported on a {@link CompilerWorkerContext}
2170 */
2171export type WorkerContextMethod = keyof CompilerWorkerContext;
2172/**
2173 * A little type guard which will cause a type error if the parameter `T` does
2174 * not satisfy {@link CPSerializable} (i.e. if it's not possible to cleanly
2175 * serialize it for message passing via an IPC channel).
2176 */
2177type IPCSerializable<T extends CPSerializable> = T;
2178/**
2179 * A manifest for a job that a worker thread should carry out, as determined by
2180 * and dispatched from the main thread. This includes the name of the task to do
2181 * and any arguments necessary to carry it out properly.
2182 *
2183 * This message must satisfy {@link CPSerializable} so it can be sent from the
2184 * main thread to a worker thread via an IPC channel
2185 */
2186export type MsgToWorker<T extends WorkerContextMethod> = IPCSerializable<{
2187 stencilId: number;
2188 method: T;
2189 args: Parameters<CompilerWorkerContext[T]>;
2190}>;
2191/**
2192 * A manifest for a job that a worker thread should carry out, as determined by
2193 * and dispatched from the main thread. This includes the name of the task to do
2194 * and any arguments necessary to carry it out properly.
2195 *
2196 * This message must satisfy {@link CPSerializable} so it can be sent from the
2197 * main thread to a worker thread via an IPC channel
2198 */
2199export type MsgFromWorker<T extends WorkerContextMethod> = IPCSerializable<{
2200 stencilId?: number;
2201 stencilRtnValue: ReturnType<CompilerWorkerContext[T]>;
2202 stencilRtnError: string | null;
2203}>;
2204/**
2205 * A description of a task which should be passed to a worker in another
2206 * thread. This interface differs from {@link MsgToWorker} in that it doesn't
2207 * have to be serializable for transmission through an IPC channel, so we can
2208 * hold things like a `resolve` and `reject` callback to use when the task
2209 * completes.
2210 */
2211export interface CompilerWorkerTask {
2212 stencilId: number;
2213 inputArgs: any[];
2214 resolve: (val: any) => any;
2215 reject: (msg: string) => any;
2216 retries: number;
2217}
2218/**
2219 * A handler for IPC messages from the main thread to a worker thread. This
2220 * involves dispatching an action specified by a {@link MsgToWorker} object to a
2221 * {@link CompilerWorkerContext}.
2222 *
2223 * @param msgToWorker the message to handle
2224 * @returns the return value of the specified function
2225 */
2226export type WorkerMsgHandler = <T extends WorkerContextMethod>(msgToWorker: MsgToWorker<T>) => ReturnType<CompilerWorkerContext[T]>;
2227export interface TranspileModuleResults {
2228 sourceFilePath: string;
2229 code: string;
2230 map: any;
2231 diagnostics: Diagnostic[];
2232 moduleFile: Module;
2233}
2234export interface ValidateTypesResults {
2235 diagnostics: Diagnostic[];
2236 dirPaths: string[];
2237 filePaths: string[];
2238}
2239export interface TerminalInfo {
2240 /**
2241 * Whether this is in CI or not.
2242 */
2243 readonly ci: boolean;
2244 /**
2245 * Whether the terminal is an interactive TTY or not.
2246 */
2247 readonly tty: boolean;
2248}
2249/**
2250 * The task to run in order to collect the duration data point.
2251 */
2252export type TelemetryCallback = (...args: any[]) => void | Promise<void>;
2253/**
2254 * The model for the data that's tracked.
2255 */
2256export interface TrackableData {
2257 arguments: string[];
2258 build: string;
2259 component_count?: number;
2260 config: Config;
2261 cpu_model: string | undefined;
2262 duration_ms: number | undefined;
2263 has_app_pwa_config: boolean;
2264 os_name: string | undefined;
2265 os_version: string | undefined;
2266 packages: string[];
2267 packages_no_versions?: string[];
2268 rollup: string;
2269 stencil: string;
2270 system: string;
2271 system_major?: string;
2272 targets: string[];
2273 task: TaskCommand | null;
2274 typescript: string;
2275 yarn: boolean;
2276}
2277/**
2278 * Used as the object sent to the server. Value is the data tracked.
2279 */
2280export interface Metric {
2281 name: string;
2282 timestamp: string;
2283 source: 'stencil_cli';
2284 value: TrackableData;
2285 session_id: string;
2286}
2287export interface TelemetryConfig {
2288 'telemetry.stencil'?: boolean;
2289 'tokens.telemetry'?: string;
2290}
2291export {};
2292
\No newline at end of file