UNPKG

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