stencil-private.d.ts 65 KB

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