UNPKG

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