stencil-private.d.ts 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253
  1. import { BuildResultsComponentGraph } from '.';
  2. import type { BuildEvents, BuildLog, BuildOutput, CompilerBuildResults, CompilerBuildStart, CompilerFsStats, CompilerRequestResponse, CompilerSystem, Config, CopyResults, DevServerConfig, DevServerEditor, Diagnostic, FsWriteOptions, Logger, LoggerTimeSpan, OptimizeCssInput, OptimizeCssOutput, OutputTargetWww, PageReloadStrategy, PrerenderConfig, StyleDoc, LoggerLineUpdater, 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. export interface ComponentCompilerStaticProperty {
  686. mutable: boolean;
  687. optional: boolean;
  688. required: boolean;
  689. type: ComponentCompilerPropertyType;
  690. complexType: ComponentCompilerPropertyComplexType;
  691. attribute?: string;
  692. reflect?: boolean;
  693. docs: CompilerJsDoc;
  694. defaultValue?: string;
  695. }
  696. export interface ComponentCompilerProperty extends ComponentCompilerStaticProperty {
  697. name: string;
  698. internal: boolean;
  699. }
  700. export interface ComponentCompilerVirtualProperty {
  701. name: string;
  702. type: string;
  703. docs: string;
  704. }
  705. export declare type ComponentCompilerPropertyType = 'any' | 'string' | 'boolean' | 'number' | 'unknown';
  706. export interface ComponentCompilerPropertyComplexType {
  707. original: string;
  708. resolved: string;
  709. references: ComponentCompilerTypeReferences;
  710. }
  711. export interface ComponentCompilerTypeReferences {
  712. [key: string]: ComponentCompilerTypeReference;
  713. }
  714. export interface ComponentCompilerTypeReference {
  715. location: 'local' | 'global' | 'import';
  716. path?: string;
  717. }
  718. export interface ComponentCompilerStaticEvent {
  719. name: string;
  720. method: string;
  721. bubbles: boolean;
  722. cancelable: boolean;
  723. composed: boolean;
  724. docs: CompilerJsDoc;
  725. complexType: ComponentCompilerEventComplexType;
  726. }
  727. export interface ComponentCompilerEvent extends ComponentCompilerStaticEvent {
  728. internal: boolean;
  729. }
  730. export interface ComponentCompilerEventComplexType {
  731. original: string;
  732. resolved: string;
  733. references: ComponentCompilerTypeReferences;
  734. }
  735. export interface ComponentCompilerListener {
  736. name: string;
  737. method: string;
  738. capture: boolean;
  739. passive: boolean;
  740. target: ListenTargetOptions | undefined;
  741. }
  742. export interface ComponentCompilerStaticMethod {
  743. docs: CompilerJsDoc;
  744. complexType: ComponentCompilerMethodComplexType;
  745. }
  746. export interface ComponentCompilerMethodComplexType {
  747. signature: string;
  748. parameters: CompilerJsDoc[];
  749. references: ComponentCompilerTypeReferences;
  750. return: string;
  751. }
  752. export interface ComponentCompilerWatch {
  753. propName: string;
  754. methodName: string;
  755. }
  756. export interface ComponentCompilerMethod extends ComponentCompilerStaticMethod {
  757. name: string;
  758. internal: boolean;
  759. }
  760. export interface ComponentCompilerState {
  761. name: string;
  762. }
  763. export interface CompilerJsDoc {
  764. text: string;
  765. tags: CompilerJsDocTagInfo[];
  766. }
  767. export interface CompilerJsDocTagInfo {
  768. name: string;
  769. text?: string;
  770. }
  771. export interface CompilerStyleDoc {
  772. name: string;
  773. docs: string;
  774. annotation: 'prop';
  775. }
  776. export interface CompilerAssetDir {
  777. absolutePath?: string;
  778. cmpRelativePath?: string;
  779. originalComponentPath?: string;
  780. }
  781. export interface ComponentCompilerData {
  782. exportLine: string;
  783. filePath: string;
  784. cmp: ComponentCompilerMeta;
  785. uniqueComponentClassName?: string;
  786. importLine?: string;
  787. }
  788. export interface ComponentConstructor {
  789. is?: string;
  790. properties?: ComponentConstructorProperties;
  791. watchers?: ComponentConstructorWatchers;
  792. events?: ComponentConstructorEvent[];
  793. listeners?: ComponentConstructorListener[];
  794. style?: string;
  795. styleId?: string;
  796. encapsulation?: ComponentConstructorEncapsulation;
  797. observedAttributes?: string[];
  798. cmpMeta?: ComponentRuntimeMeta;
  799. isProxied?: boolean;
  800. isStyleRegistered?: boolean;
  801. }
  802. export interface ComponentConstructorWatchers {
  803. [propName: string]: string[];
  804. }
  805. export interface ComponentTestingConstructor extends ComponentConstructor {
  806. COMPILER_META: ComponentCompilerMeta;
  807. prototype?: {
  808. componentWillLoad?: Function;
  809. componentWillUpdate?: Function;
  810. componentWillRender?: Function;
  811. __componentWillLoad?: Function;
  812. __componentWillUpdate?: Function;
  813. __componentWillRender?: Function;
  814. };
  815. }
  816. export interface ComponentNativeConstructor extends ComponentConstructor {
  817. cmpMeta: ComponentRuntimeMeta;
  818. }
  819. export declare type ComponentConstructorEncapsulation = 'shadow' | 'scoped' | 'none';
  820. export interface ComponentConstructorProperties {
  821. [propName: string]: ComponentConstructorProperty;
  822. }
  823. export interface ComponentConstructorProperty {
  824. attribute?: string;
  825. elementRef?: boolean;
  826. method?: boolean;
  827. mutable?: boolean;
  828. reflect?: boolean;
  829. state?: boolean;
  830. type?: ComponentConstructorPropertyType;
  831. watchCallbacks?: string[];
  832. }
  833. export declare type ComponentConstructorPropertyType = StringConstructor | BooleanConstructor | NumberConstructor | 'string' | 'boolean' | 'number';
  834. export interface ComponentConstructorEvent {
  835. name: string;
  836. method: string;
  837. bubbles: boolean;
  838. cancelable: boolean;
  839. composed: boolean;
  840. }
  841. export interface ComponentConstructorListener {
  842. name: string;
  843. method: string;
  844. capture?: boolean;
  845. passive?: boolean;
  846. }
  847. export interface HostConfig {
  848. hosting?: {
  849. rules?: HostRule[];
  850. };
  851. }
  852. export interface HostRule {
  853. include: string;
  854. headers: HostRuleHeader[];
  855. }
  856. export interface HostRuleHeader {
  857. name?: string;
  858. value?: string;
  859. }
  860. export interface CssVarShim {
  861. i(): Promise<any>;
  862. addLink(linkEl: HTMLLinkElement): Promise<any>;
  863. addGlobalStyle(styleEl: HTMLStyleElement): void;
  864. createHostStyle(hostEl: HTMLElement, templateName: string, cssText: string, isScoped: boolean): HTMLStyleElement;
  865. removeHost(hostEl: HTMLElement): void;
  866. updateHost(hostEl: HTMLElement): void;
  867. updateGlobal(): void;
  868. }
  869. export interface DevClientWindow extends Window {
  870. ['s-dev-server']: boolean;
  871. ['s-initial-load']: boolean;
  872. ['s-build-id']: number;
  873. WebSocket: new (socketUrl: string, protos: string[]) => WebSocket;
  874. devServerConfig?: DevClientConfig;
  875. }
  876. export interface DevClientConfig {
  877. basePath: string;
  878. editors: DevServerEditor[];
  879. reloadStrategy: PageReloadStrategy;
  880. socketUrl?: string;
  881. }
  882. export interface HttpRequest {
  883. method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS';
  884. acceptHeader: string;
  885. url: URL;
  886. searchParams: URLSearchParams;
  887. pathname?: string;
  888. filePath?: string;
  889. stats?: CompilerFsStats;
  890. headers?: {
  891. [name: string]: string;
  892. };
  893. host?: string;
  894. }
  895. export interface DevServerMessage {
  896. startServer?: DevServerConfig;
  897. closeServer?: boolean;
  898. serverStarted?: DevServerConfig;
  899. serverClosed?: boolean;
  900. buildStart?: boolean;
  901. buildLog?: BuildLog;
  902. buildResults?: CompilerBuildResults;
  903. requestBuildResults?: boolean;
  904. error?: {
  905. message?: string;
  906. type?: string;
  907. stack?: any;
  908. };
  909. isActivelyBuilding?: boolean;
  910. compilerRequestPath?: string;
  911. compilerRequestResults?: CompilerRequestResponse;
  912. requestLog?: {
  913. method: string;
  914. url: string;
  915. status: number;
  916. };
  917. }
  918. export declare type DevServerSendMessage = (msg: DevServerMessage) => void;
  919. export interface DevServerContext {
  920. connectorHtml: string;
  921. dirTemplate: string;
  922. getBuildResults: () => Promise<CompilerBuildResults>;
  923. getCompilerRequest: (path: string) => Promise<CompilerRequestResponse>;
  924. isServerListening: boolean;
  925. logRequest: (req: {
  926. method: string;
  927. pathname?: string;
  928. }, status: number) => void;
  929. prerenderConfig: PrerenderConfig;
  930. serve302: (req: any, res: any, pathname?: string) => void;
  931. serve404: (req: any, res: any, xSource: string, content?: string) => void;
  932. serve500: (req: any, res: any, error: any, xSource: string) => void;
  933. sys: CompilerSystem;
  934. }
  935. export declare type InitServerProcess = (sendMsg: (msg: DevServerMessage) => void) => (msg: DevServerMessage) => void;
  936. export interface DevResponseHeaders {
  937. 'cache-control'?: string;
  938. expires?: string;
  939. 'content-type'?: string;
  940. 'content-length'?: number;
  941. date?: string;
  942. 'access-control-allow-origin'?: string;
  943. 'access-control-expose-headers'?: string;
  944. 'content-encoding'?: 'gzip';
  945. vary?: 'Accept-Encoding';
  946. server?: string;
  947. 'x-directory-index'?: string;
  948. 'x-source'?: string;
  949. }
  950. export interface OpenInEditorData {
  951. file?: string;
  952. line?: number;
  953. column?: number;
  954. open?: string;
  955. editor?: string;
  956. exists?: boolean;
  957. error?: string;
  958. }
  959. export interface EntryModule {
  960. entryKey: string;
  961. cmps: ComponentCompilerMeta[];
  962. }
  963. export interface EntryBundle {
  964. fileName: string;
  965. text: string;
  966. outputs: string[];
  967. modeName: string;
  968. isScopedStyles: boolean;
  969. sourceTarget: string;
  970. }
  971. export interface EntryComponent {
  972. tag: string;
  973. dependencyOf?: string[];
  974. }
  975. export interface ComponentRef {
  976. tag: string;
  977. filePath: string;
  978. }
  979. export interface ModuleGraph {
  980. filePath: string;
  981. importPaths: string[];
  982. }
  983. export interface AddEventListener {
  984. (elm: Element | Document | Window, eventName: string, cb: EventListenerCallback, opts?: ListenOptions): Function;
  985. }
  986. export interface EventListenerCallback {
  987. (ev?: any): void;
  988. }
  989. export interface EventEmitterData<T = any> {
  990. detail?: T;
  991. bubbles?: boolean;
  992. cancelable?: boolean;
  993. composed?: boolean;
  994. }
  995. export interface FsReadOptions {
  996. useCache?: boolean;
  997. setHash?: boolean;
  998. }
  999. export interface FsReaddirOptions {
  1000. inMemoryOnly?: boolean;
  1001. recursive?: boolean;
  1002. /**
  1003. * Directory names to exclude. Just the basename,
  1004. * not the entire path. Basically for "node_moduels".
  1005. */
  1006. excludeDirNames?: string[];
  1007. /**
  1008. * Extensions we know we can avoid. Each extension
  1009. * should include the `.` so that we can test for both
  1010. * `.d.ts.` and `.ts`. If `excludeExtensions` isn't provided it
  1011. * doesn't try to exclude anything. This only checks against
  1012. * the filename, not directory names when recursive.
  1013. */
  1014. excludeExtensions?: string[];
  1015. }
  1016. export interface FsReaddirItem {
  1017. absPath: string;
  1018. relPath: string;
  1019. isDirectory: boolean;
  1020. isFile: boolean;
  1021. }
  1022. export interface FsWriteResults {
  1023. changedContent: boolean;
  1024. queuedWrite: boolean;
  1025. ignored: boolean;
  1026. }
  1027. export declare type FsItems = Map<string, FsItem>;
  1028. export interface FsItem {
  1029. fileText: string;
  1030. isFile: boolean;
  1031. isDirectory: boolean;
  1032. size: number;
  1033. mtimeMs: number;
  1034. exists: boolean;
  1035. queueCopyFileToDest: string;
  1036. queueWriteToDisk: boolean;
  1037. queueDeleteFromDisk?: boolean;
  1038. useCache: boolean;
  1039. }
  1040. export interface HostElement extends HTMLElement {
  1041. connectedCallback?: () => void;
  1042. attributeChangedCallback?: (attribName: string, oldVal: string, newVal: string, namespace: string) => void;
  1043. disconnectedCallback?: () => void;
  1044. host?: Element;
  1045. forceUpdate?: () => void;
  1046. /**
  1047. * Unique stencil id for this element
  1048. */
  1049. ['s-id']?: string;
  1050. /**
  1051. * Content Reference:
  1052. * Reference to the HTML Comment that's placed inside of the
  1053. * host element's original content. This comment is used to
  1054. * always represent where host element's light dom is.
  1055. */
  1056. ['s-cr']?: RenderNode;
  1057. /**
  1058. * Lifecycle ready
  1059. */
  1060. ['s-lr']?: boolean;
  1061. /**
  1062. * On Render Callbacks:
  1063. * Array of callbacks to fire off after it has rendered.
  1064. */
  1065. ['s-rc']?: (() => void)[];
  1066. /**
  1067. * Scope Id
  1068. * The scope id of this component when using scoped css encapsulation
  1069. * or using shadow dom but the browser doesn't support it
  1070. */
  1071. ['s-sc']?: string;
  1072. /**
  1073. * Hot Module Replacement, dev mode only
  1074. */
  1075. ['s-hmr']?: (versionId: string) => void;
  1076. /**
  1077. * Callback method for when HMR finishes
  1078. */
  1079. ['s-hmr-load']?: () => void;
  1080. ['s-p']?: Promise<void>[];
  1081. componentOnReady?: () => Promise<this>;
  1082. }
  1083. export interface InMemoryFileSystem {
  1084. sys?: CompilerSystem;
  1085. accessData(filePath: string): Promise<{
  1086. exists: boolean;
  1087. isDirectory: boolean;
  1088. isFile: boolean;
  1089. }>;
  1090. access(filePath: string): Promise<boolean>;
  1091. /**
  1092. * Synchronous!!! Do not use!!!
  1093. * (Only typescript transpiling is allowed to use)
  1094. * @param filePath
  1095. */
  1096. accessSync(filePath: string): boolean;
  1097. copyFile(srcFile: string, dest: string): Promise<void>;
  1098. emptyDirs(dirPaths: string[]): Promise<void>;
  1099. readdir(dirPath: string, opts?: FsReaddirOptions): Promise<FsReaddirItem[]>;
  1100. readFile(filePath: string, opts?: FsReadOptions): Promise<string>;
  1101. /**
  1102. * Synchronous!!! Do not use!!!
  1103. * (Only typescript transpiling is allowed to use)
  1104. * @param filePath
  1105. */
  1106. readFileSync(filePath: string, opts?: FsReadOptions): string;
  1107. remove(itemPath: string): Promise<void>;
  1108. stat(itemPath: string): Promise<{
  1109. isFile: boolean;
  1110. isDirectory: boolean;
  1111. }>;
  1112. /**
  1113. * Synchronous!!! Do not use!!!
  1114. * (Only typescript transpiling is allowed to use)
  1115. * @param itemPath
  1116. */
  1117. statSync(itemPath: string): {
  1118. exists: boolean;
  1119. isFile: boolean;
  1120. isDirectory: boolean;
  1121. };
  1122. writeFile(filePath: string, content: string, opts?: FsWriteOptions): Promise<FsWriteResults>;
  1123. writeFiles(files: {
  1124. [filePath: string]: string;
  1125. } | Map<string, String>, opts?: FsWriteOptions): Promise<FsWriteResults[]>;
  1126. commit(): Promise<{
  1127. filesWritten: string[];
  1128. filesDeleted: string[];
  1129. filesCopied: string[][];
  1130. dirsDeleted: string[];
  1131. dirsAdded: string[];
  1132. }>;
  1133. cancelDeleteFilesFromDisk(filePaths: string[]): void;
  1134. cancelDeleteDirectoriesFromDisk(filePaths: string[]): void;
  1135. clearDirCache(dirPath: string): void;
  1136. clearFileCache(filePath: string): void;
  1137. getItem(itemPath: string): FsItem;
  1138. getBuildOutputs(): BuildOutput[];
  1139. clearCache(): void;
  1140. keys(): string[];
  1141. getMemoryStats(): string;
  1142. }
  1143. export interface HydrateResults {
  1144. buildId: string;
  1145. diagnostics: Diagnostic[];
  1146. url: string;
  1147. host: string;
  1148. hostname: string;
  1149. href: string;
  1150. port: string;
  1151. pathname: string;
  1152. search: string;
  1153. hash: string;
  1154. html: string;
  1155. components: HydrateComponent[];
  1156. anchors: HydrateAnchorElement[];
  1157. imgs: HydrateImgElement[];
  1158. scripts: HydrateScriptElement[];
  1159. styles: HydrateStyleElement[];
  1160. staticData: HydrateStaticData[];
  1161. title: string;
  1162. hydratedCount: number;
  1163. httpStatus: number;
  1164. }
  1165. export interface HydrateComponent {
  1166. tag: string;
  1167. mode: string;
  1168. count: number;
  1169. depth: number;
  1170. }
  1171. export interface HydrateElement {
  1172. [attrName: string]: string | undefined;
  1173. }
  1174. export interface HydrateAnchorElement extends HydrateElement {
  1175. href?: string;
  1176. target?: string;
  1177. }
  1178. export interface HydrateImgElement extends HydrateElement {
  1179. src?: string;
  1180. }
  1181. export interface HydrateScriptElement extends HydrateElement {
  1182. src?: string;
  1183. type?: string;
  1184. }
  1185. export interface HydrateStyleElement extends HydrateElement {
  1186. href?: string;
  1187. }
  1188. export interface HydrateStaticData {
  1189. id: string;
  1190. type: string;
  1191. content: string;
  1192. }
  1193. export interface JsDoc {
  1194. name: string;
  1195. documentation: string;
  1196. type: string;
  1197. tags: JSDocTagInfo[];
  1198. default?: string;
  1199. parameters?: JsDoc[];
  1200. returns?: {
  1201. type: string;
  1202. documentation: string;
  1203. };
  1204. }
  1205. export interface JSDocTagInfo {
  1206. name: string;
  1207. text?: string;
  1208. }
  1209. export interface MinifyJsResult {
  1210. code: string;
  1211. sourceMap: any;
  1212. error: {
  1213. message: string;
  1214. filename: string;
  1215. line: number;
  1216. col: number;
  1217. pos: number;
  1218. };
  1219. }
  1220. export declare type ModuleMap = Map<string, Module>;
  1221. /**
  1222. * Module gets serialized/parsed as JSON
  1223. * cannot use Map or Set
  1224. */
  1225. export interface Module {
  1226. cmps: ComponentCompilerMeta[];
  1227. coreRuntimeApis: string[];
  1228. collectionName: string;
  1229. dtsFilePath: string;
  1230. excludeFromCollection: boolean;
  1231. externalImports: string[];
  1232. htmlAttrNames: string[];
  1233. htmlTagNames: string[];
  1234. htmlParts: string[];
  1235. isCollectionDependency: boolean;
  1236. isLegacy: boolean;
  1237. jsFilePath: string;
  1238. localImports: string[];
  1239. originalImports: string[];
  1240. originalCollectionComponentPath: string;
  1241. potentialCmpRefs: string[];
  1242. sourceFilePath: string;
  1243. staticSourceFile: any;
  1244. staticSourceFileText: string;
  1245. sourceMapPath: string;
  1246. sourceMapFileText: string;
  1247. hasVdomAttribute: boolean;
  1248. hasVdomClass: boolean;
  1249. hasVdomFunctional: boolean;
  1250. hasVdomKey: boolean;
  1251. hasVdomListener: boolean;
  1252. hasVdomPropOrAttr: boolean;
  1253. hasVdomRef: boolean;
  1254. hasVdomRender: boolean;
  1255. hasVdomStyle: boolean;
  1256. hasVdomText: boolean;
  1257. hasVdomXlink: boolean;
  1258. }
  1259. export interface Plugin {
  1260. name?: string;
  1261. pluginType?: string;
  1262. load?: (id: string, context: PluginCtx) => Promise<string> | string;
  1263. resolveId?: (importee: string, importer: string, context: PluginCtx) => Promise<string> | string;
  1264. transform?: (sourceText: string, id: string, context: PluginCtx) => Promise<PluginTransformResults> | PluginTransformResults | string;
  1265. }
  1266. export interface PluginTransformResults {
  1267. code?: string;
  1268. map?: string;
  1269. id?: string;
  1270. diagnostics?: Diagnostic[];
  1271. dependencies?: string[];
  1272. }
  1273. export interface PluginCtx {
  1274. config: Config;
  1275. sys: CompilerSystem;
  1276. fs: InMemoryFileSystem;
  1277. cache: Cache;
  1278. diagnostics: Diagnostic[];
  1279. }
  1280. export interface PrerenderUrlResults {
  1281. anchorUrls: string[];
  1282. diagnostics: Diagnostic[];
  1283. filePath: string;
  1284. }
  1285. export interface PrerenderUrlRequest {
  1286. appDir: string;
  1287. buildId: string;
  1288. baseUrl: string;
  1289. componentGraphPath: string;
  1290. devServerHostUrl: string;
  1291. hydrateAppFilePath: string;
  1292. isDebug: boolean;
  1293. prerenderConfigPath: string;
  1294. staticSite: boolean;
  1295. templateId: string;
  1296. url: string;
  1297. writeToFilePath: string;
  1298. }
  1299. export interface PrerenderManager {
  1300. config: Config;
  1301. prerenderUrlWorker: (prerenderRequest: PrerenderUrlRequest) => Promise<PrerenderUrlResults>;
  1302. devServerHostUrl: string;
  1303. diagnostics: Diagnostic[];
  1304. hydrateAppFilePath: string;
  1305. isDebug: boolean;
  1306. logCount: number;
  1307. outputTarget: OutputTargetWww;
  1308. prerenderConfig: PrerenderConfig;
  1309. prerenderConfigPath: string;
  1310. progressLogger?: LoggerLineUpdater;
  1311. resolve: Function;
  1312. staticSite: boolean;
  1313. templateId: string;
  1314. componentGraphPath: string;
  1315. urlsProcessing: Set<string>;
  1316. urlsPending: Set<string>;
  1317. urlsCompleted: Set<string>;
  1318. maxConcurrency: number;
  1319. }
  1320. /**
  1321. * Generic node that represents all of the
  1322. * different types of nodes we'd see when rendering
  1323. */
  1324. export interface RenderNode extends HostElement {
  1325. /**
  1326. * Shadow root's host
  1327. */
  1328. host?: Element;
  1329. /**
  1330. * Is Content Reference Node:
  1331. * This node is a content reference node.
  1332. */
  1333. ['s-cn']?: boolean;
  1334. /**
  1335. * Is a slot reference node:
  1336. * This is a node that represents where a slot
  1337. * was originally located.
  1338. */
  1339. ['s-sr']?: boolean;
  1340. /**
  1341. * Slot name
  1342. */
  1343. ['s-sn']?: string;
  1344. /**
  1345. * Host element tag name:
  1346. * The tag name of the host element that this
  1347. * node was created in.
  1348. */
  1349. ['s-hn']?: string;
  1350. /**
  1351. * Original Location Reference:
  1352. * A reference pointing to the comment
  1353. * which represents the original location
  1354. * before it was moved to its slot.
  1355. */
  1356. ['s-ol']?: RenderNode;
  1357. /**
  1358. * Node reference:
  1359. * This is a reference for a original location node
  1360. * back to the node that's been moved around.
  1361. */
  1362. ['s-nr']?: RenderNode;
  1363. /**
  1364. * Scope Id
  1365. */
  1366. ['s-si']?: string;
  1367. /**
  1368. * Host Id (hydrate only)
  1369. */
  1370. ['s-host-id']?: number;
  1371. /**
  1372. * Node Id (hydrate only)
  1373. */
  1374. ['s-node-id']?: number;
  1375. /**
  1376. * Used to know the components encapsulation.
  1377. * empty "" for shadow, "c" from scoped
  1378. */
  1379. ['s-en']?: '' | /*shadow*/ 'c';
  1380. }
  1381. export declare type LazyBundlesRuntimeData = LazyBundleRuntimeData[];
  1382. export declare type LazyBundleRuntimeData = [
  1383. /** bundleIds */
  1384. string,
  1385. ComponentRuntimeMetaCompact[]
  1386. ];
  1387. export declare type ComponentRuntimeMetaCompact = [
  1388. /** flags */
  1389. number,
  1390. /** tagname */
  1391. string,
  1392. /** members */
  1393. {
  1394. [memberName: string]: ComponentRuntimeMember;
  1395. }?,
  1396. /** listeners */
  1397. ComponentRuntimeHostListener[]?
  1398. ];
  1399. export interface ComponentRuntimeMeta {
  1400. $flags$: number;
  1401. $tagName$: string;
  1402. $members$?: ComponentRuntimeMembers;
  1403. $listeners$?: ComponentRuntimeHostListener[];
  1404. $attrsToReflect$?: [string, string][];
  1405. $watchers$?: ComponentConstructorWatchers;
  1406. $lazyBundleId$?: string;
  1407. }
  1408. export interface ComponentRuntimeMembers {
  1409. [memberName: string]: ComponentRuntimeMember;
  1410. }
  1411. export declare type ComponentRuntimeMember = [
  1412. /**
  1413. * flags data
  1414. */
  1415. number,
  1416. /**
  1417. * attribute name to observe
  1418. */
  1419. string?
  1420. ];
  1421. export declare type ComponentRuntimeHostListener = [
  1422. /**
  1423. * event flags
  1424. */
  1425. number,
  1426. /**
  1427. * event name,
  1428. */
  1429. string,
  1430. /**
  1431. * event method,
  1432. */
  1433. string
  1434. ];
  1435. export declare type ModeBundleId = ModeBundleIds | string;
  1436. export interface ModeBundleIds {
  1437. [modeName: string]: string;
  1438. }
  1439. export declare type RuntimeRef = HostElement | {};
  1440. /**
  1441. * Interface used to track an Element, it's virtual Node (`VNode`), and other data
  1442. */
  1443. export interface HostRef {
  1444. $ancestorComponent$?: HostElement;
  1445. $flags$: number;
  1446. $cmpMeta$: ComponentRuntimeMeta;
  1447. $hostElement$?: HostElement;
  1448. $instanceValues$?: Map<string, any>;
  1449. $lazyInstance$?: ComponentInterface;
  1450. $onReadyPromise$?: Promise<any>;
  1451. $onReadyResolve$?: (elm: any) => void;
  1452. $onInstancePromise$?: Promise<any>;
  1453. $onInstanceResolve$?: (elm: any) => void;
  1454. $onRenderResolve$?: () => void;
  1455. $vnode$?: VNode;
  1456. $queuedListeners$?: [string, any][];
  1457. $rmListeners$?: (() => void)[];
  1458. $modeName$?: string;
  1459. $renderCount$?: number;
  1460. }
  1461. export interface PlatformRuntime {
  1462. $cssShim$?: CssVarShim;
  1463. $flags$: number;
  1464. $orgLocNodes$?: Map<string, RenderNode>;
  1465. $resourcesUrl$: string;
  1466. jmp: (c: Function) => any;
  1467. raf: (c: FrameRequestCallback) => number;
  1468. ael: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
  1469. rel: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
  1470. ce: (eventName: string, opts?: any) => CustomEvent;
  1471. }
  1472. export declare type RefMap = WeakMap<any, HostRef>;
  1473. export declare type StyleMap = Map<string, CSSStyleSheet | string>;
  1474. export declare type RootAppliedStyleMap = WeakMap<Element, Set<string>>;
  1475. export declare type AppliedStyleMap = Set<string>;
  1476. export declare type ActivelyProcessingCmpMap = Set<Element>;
  1477. export interface ScreenshotConnector {
  1478. initBuild(opts: ScreenshotConnectorOptions): Promise<void>;
  1479. completeBuild(masterBuild: ScreenshotBuild): Promise<ScreenshotBuildResults>;
  1480. getMasterBuild(): Promise<ScreenshotBuild>;
  1481. pullMasterBuild(): Promise<void>;
  1482. publishBuild(buildResults: ScreenshotBuildResults): Promise<ScreenshotBuildResults>;
  1483. getScreenshotCache(): Promise<ScreenshotCache>;
  1484. updateScreenshotCache(screenshotCache: ScreenshotCache, buildResults: ScreenshotBuildResults): Promise<ScreenshotCache>;
  1485. generateJsonpDataUris(build: ScreenshotBuild): Promise<void>;
  1486. sortScreenshots(screenshots: Screenshot[]): Screenshot[];
  1487. toJson(masterBuild: ScreenshotBuild, screenshotCache: ScreenshotCache): string;
  1488. }
  1489. export interface ScreenshotBuildResults {
  1490. appNamespace: string;
  1491. masterBuild: ScreenshotBuild;
  1492. currentBuild: ScreenshotBuild;
  1493. compare: ScreenshotCompareResults;
  1494. }
  1495. export interface ScreenshotCompareResults {
  1496. id: string;
  1497. a: {
  1498. id: string;
  1499. message: string;
  1500. author: string;
  1501. url: string;
  1502. previewUrl: string;
  1503. };
  1504. b: {
  1505. id: string;
  1506. message: string;
  1507. author: string;
  1508. url: string;
  1509. previewUrl: string;
  1510. };
  1511. timestamp: number;
  1512. url: string;
  1513. appNamespace: string;
  1514. diffs: ScreenshotDiff[];
  1515. }
  1516. export interface ScreenshotConnectorOptions {
  1517. buildId: string;
  1518. buildMessage: string;
  1519. buildAuthor?: string;
  1520. buildUrl?: string;
  1521. previewUrl?: string;
  1522. appNamespace: string;
  1523. buildTimestamp: number;
  1524. logger: Logger;
  1525. rootDir: string;
  1526. cacheDir: string;
  1527. packageDir: string;
  1528. screenshotDirName?: string;
  1529. imagesDirName?: string;
  1530. buildsDirName?: string;
  1531. currentBuildDir?: string;
  1532. updateMaster?: boolean;
  1533. allowableMismatchedPixels?: number;
  1534. allowableMismatchedRatio?: number;
  1535. pixelmatchThreshold?: number;
  1536. waitBeforeScreenshot?: number;
  1537. pixelmatchModulePath?: string;
  1538. }
  1539. export interface ScreenshotBuildData {
  1540. buildId: string;
  1541. rootDir: string;
  1542. screenshotDir: string;
  1543. imagesDir: string;
  1544. buildsDir: string;
  1545. currentBuildDir: string;
  1546. updateMaster: boolean;
  1547. allowableMismatchedPixels: number;
  1548. allowableMismatchedRatio: number;
  1549. pixelmatchThreshold: number;
  1550. masterScreenshots: {
  1551. [screenshotId: string]: string;
  1552. };
  1553. cache: {
  1554. [cacheKey: string]: number;
  1555. };
  1556. timeoutBeforeScreenshot: number;
  1557. pixelmatchModulePath: string;
  1558. }
  1559. export interface PixelMatchInput {
  1560. imageAPath: string;
  1561. imageBPath: string;
  1562. width: number;
  1563. height: number;
  1564. pixelmatchThreshold: number;
  1565. }
  1566. export interface ScreenshotBuild {
  1567. id: string;
  1568. message: string;
  1569. author?: string;
  1570. url?: string;
  1571. previewUrl?: string;
  1572. appNamespace: string;
  1573. timestamp: number;
  1574. screenshots: Screenshot[];
  1575. }
  1576. export interface ScreenshotCache {
  1577. timestamp?: number;
  1578. lastBuildId?: string;
  1579. size?: number;
  1580. items?: {
  1581. /**
  1582. * Cache key
  1583. */
  1584. key: string;
  1585. /**
  1586. * Timestamp used to remove the oldest data
  1587. */
  1588. ts: number;
  1589. /**
  1590. * Mismatched pixels
  1591. */
  1592. mp: number;
  1593. }[];
  1594. }
  1595. export interface Screenshot {
  1596. id: string;
  1597. desc?: string;
  1598. image: string;
  1599. device?: string;
  1600. userAgent?: string;
  1601. width?: number;
  1602. height?: number;
  1603. deviceScaleFactor?: number;
  1604. hasTouch?: boolean;
  1605. isLandscape?: boolean;
  1606. isMobile?: boolean;
  1607. testPath?: string;
  1608. diff?: ScreenshotDiff;
  1609. }
  1610. export interface ScreenshotDiff {
  1611. mismatchedPixels: number;
  1612. id?: string;
  1613. desc?: string;
  1614. imageA?: string;
  1615. imageB?: string;
  1616. device?: string;
  1617. userAgent?: string;
  1618. width?: number;
  1619. height?: number;
  1620. deviceScaleFactor?: number;
  1621. hasTouch?: boolean;
  1622. isLandscape?: boolean;
  1623. isMobile?: boolean;
  1624. allowableMismatchedPixels: number;
  1625. allowableMismatchedRatio: number;
  1626. testPath?: string;
  1627. cacheKey?: string;
  1628. }
  1629. export interface ScreenshotOptions {
  1630. /**
  1631. * When true, takes a screenshot of the full scrollable page.
  1632. * Default: `false`
  1633. */
  1634. fullPage?: boolean;
  1635. /**
  1636. * An object which specifies clipping region of the page.
  1637. */
  1638. clip?: ScreenshotBoundingBox;
  1639. /**
  1640. * Hides default white background and allows capturing screenshots with transparency.
  1641. * Default: `false`
  1642. */
  1643. omitBackground?: boolean;
  1644. /**
  1645. * Matching threshold, ranges from `0` to 1. Smaller values make the comparison
  1646. * more sensitive. Defaults to the testing config `pixelmatchThreshold` value;
  1647. */
  1648. pixelmatchThreshold?: number;
  1649. }
  1650. export interface ScreenshotBoundingBox {
  1651. /**
  1652. * The x-coordinate of top-left corner.
  1653. */
  1654. x: number;
  1655. /**
  1656. * The y-coordinate of top-left corner.
  1657. */
  1658. y: number;
  1659. /**
  1660. * The width in pixels.
  1661. */
  1662. width: number;
  1663. /**
  1664. * The height in pixels.
  1665. */
  1666. height: number;
  1667. }
  1668. export interface ServerConfigInput {
  1669. app: ExpressApp;
  1670. configPath?: string;
  1671. }
  1672. export interface ServerConfigOutput {
  1673. config: Config;
  1674. logger: Logger;
  1675. wwwDir: string;
  1676. destroy?: () => void;
  1677. }
  1678. export interface ExpressApp {
  1679. use?: Function;
  1680. }
  1681. export interface MiddlewareConfig {
  1682. config: string | Config;
  1683. destroy?: () => void;
  1684. }
  1685. export interface StyleCompiler {
  1686. modeName: string;
  1687. styleId: string;
  1688. styleStr: string;
  1689. styleIdentifier: string;
  1690. externalStyles: ExternalStyleCompiler[];
  1691. }
  1692. export interface ExternalStyleCompiler {
  1693. absolutePath: string;
  1694. relativePath: string;
  1695. originalComponentPath: string;
  1696. }
  1697. export interface CompilerModeStyles {
  1698. [modeName: string]: string[];
  1699. }
  1700. export interface CssImportData {
  1701. srcImport: string;
  1702. updatedImport?: string;
  1703. url: string;
  1704. filePath?: string;
  1705. altFilePath?: string;
  1706. styleText?: string;
  1707. }
  1708. export interface CssToEsmImportData {
  1709. srcImportText: string;
  1710. varName: string;
  1711. url: string;
  1712. filePath: string;
  1713. }
  1714. export interface TransformCssToEsmInput {
  1715. input: string;
  1716. module?: 'cjs' | 'esm' | string;
  1717. file?: string;
  1718. tag?: string;
  1719. encapsulation?: string;
  1720. mode?: string;
  1721. commentOriginalSelector?: boolean;
  1722. sourceMap?: boolean;
  1723. minify?: boolean;
  1724. docs?: boolean;
  1725. autoprefixer?: any;
  1726. styleImportData?: string;
  1727. }
  1728. export interface TransformCssToEsmOutput {
  1729. styleText: string;
  1730. output: string;
  1731. map: any;
  1732. diagnostics: Diagnostic[];
  1733. defaultVarName: string;
  1734. styleDocs: StyleDoc[];
  1735. imports: {
  1736. varName: string;
  1737. importPath: string;
  1738. }[];
  1739. }
  1740. export interface PackageJsonData {
  1741. name?: string;
  1742. version?: string;
  1743. main?: string;
  1744. description?: string;
  1745. bin?: {
  1746. [key: string]: string;
  1747. };
  1748. browser?: string;
  1749. module?: string;
  1750. 'jsnext:main'?: string;
  1751. 'collection:main'?: string;
  1752. unpkg?: string;
  1753. collection?: string;
  1754. types?: string;
  1755. files?: string[];
  1756. ['dist-tags']?: {
  1757. latest: string;
  1758. };
  1759. dependencies?: {
  1760. [moduleId: string]: string;
  1761. };
  1762. devDependencies?: {
  1763. [moduleId: string]: string;
  1764. };
  1765. repository?: {
  1766. type?: string;
  1767. url?: string;
  1768. };
  1769. private?: boolean;
  1770. scripts?: {
  1771. [runName: string]: string;
  1772. };
  1773. license?: string;
  1774. keywords?: string[];
  1775. }
  1776. export interface Workbox {
  1777. generateSW(swConfig: any): Promise<any>;
  1778. generateFileManifest(): Promise<any>;
  1779. getFileManifestEntries(): Promise<any>;
  1780. injectManifest(swConfig: any): Promise<any>;
  1781. copyWorkboxLibraries(wwwDir: string): Promise<any>;
  1782. }
  1783. export interface Url {
  1784. href?: string;
  1785. protocol?: string;
  1786. auth?: string;
  1787. hostname?: string;
  1788. host?: string;
  1789. port?: string;
  1790. pathname?: string;
  1791. path?: string;
  1792. search?: string;
  1793. query?: string | any;
  1794. hash?: string;
  1795. }
  1796. declare global {
  1797. namespace jest {
  1798. interface Matchers<R, T> {
  1799. /**
  1800. * Compares HTML, but first normalizes the HTML so all
  1801. * whitespace, attribute order and css class order are
  1802. * the same. When given an element, it will compare
  1803. * the element's `outerHTML`. When given a Document Fragment,
  1804. * such as a Shadow Root, it'll compare its `innerHTML`.
  1805. * Otherwise it'll compare two strings representing HTML.
  1806. */
  1807. toEqualHtml(expectHtml: string): void;
  1808. /**
  1809. * Compares HTML light DOKM only, but first normalizes the HTML so all
  1810. * whitespace, attribute order and css class order are
  1811. * the same. When given an element, it will compare
  1812. * the element's `outerHTML`. When given a Document Fragment,
  1813. * such as a Shadow Root, it'll compare its `innerHTML`.
  1814. * Otherwise it'll compare two strings representing HTML.
  1815. */
  1816. toEqualLightHtml(expectLightHtml: string): void;
  1817. /**
  1818. * When given an element, it'll compare the element's
  1819. * `textContent`. Otherwise it'll compare two strings. This
  1820. * matcher will also `trim()` each string before comparing.
  1821. */
  1822. toEqualText(expectTextContent: string): void;
  1823. /**
  1824. * Checks if an element simply has the attribute. It does
  1825. * not check any values of the attribute
  1826. */
  1827. toHaveAttribute(expectAttrName: string): void;
  1828. /**
  1829. * Checks if an element's attribute value equals the expect value.
  1830. */
  1831. toEqualAttribute(expectAttrName: string, expectAttrValue: any): void;
  1832. /**
  1833. * Checks if an element's has each of the expected attribute
  1834. * names and values.
  1835. */
  1836. toEqualAttributes(expectAttrs: {
  1837. [attrName: string]: any;
  1838. }): void;
  1839. /**
  1840. * Checks if an element has the expected css class.
  1841. */
  1842. toHaveClass(expectClassName: string): void;
  1843. /**
  1844. * Checks if an element has each of the expected css classes
  1845. * in the array.
  1846. */
  1847. toHaveClasses(expectClassNames: string[]): void;
  1848. /**
  1849. * Checks if an element has the exact same css classes
  1850. * as the expected array of css classes.
  1851. */
  1852. toMatchClasses(expectClassNames: string[]): void;
  1853. /**
  1854. * When given an EventSpy, checks if the event has been
  1855. * received or not.
  1856. */
  1857. toHaveReceivedEvent(): void;
  1858. /**
  1859. * When given an EventSpy, checks how many times the
  1860. * event has been received.
  1861. */
  1862. toHaveReceivedEventTimes(count: number): void;
  1863. /**
  1864. * When given an EventSpy, checks the event has
  1865. * received the correct custom event `detail` data.
  1866. */
  1867. toHaveReceivedEventDetail(eventDetail: any): void;
  1868. /**
  1869. * When given an EventSpy, checks the first event has
  1870. * received the correct custom event `detail` data.
  1871. */
  1872. toHaveFirstReceivedEventDetail(eventDetail: any): void;
  1873. /**
  1874. * When given an EventSpy, checks the event at an index
  1875. * has received the correct custom event `detail` data.
  1876. */
  1877. toHaveNthReceivedEventDetail(index: number, eventDetail: any): void;
  1878. /**
  1879. * Used to evaluate the results of `compareScreenshot()`, such as
  1880. * `expect(compare).toMatchScreenshot()`. The `allowableMismatchedRatio`
  1881. * value from the testing config is used by default if
  1882. * `MatchScreenshotOptions` were not provided.
  1883. */
  1884. toMatchScreenshot(opts?: MatchScreenshotOptions): void;
  1885. }
  1886. }
  1887. }
  1888. export interface MatchScreenshotOptions {
  1889. /**
  1890. * The `allowableMismatchedPixels` value is the total number of pixels
  1891. * that can be mismatched until the test fails. For example, if the value
  1892. * is `100`, and if there were `101` pixels that were mismatched then the
  1893. * test would fail. If the `allowableMismatchedRatio` is provided it will
  1894. * take precedence, otherwise `allowableMismatchedPixels` will be used.
  1895. */
  1896. allowableMismatchedPixels?: number;
  1897. /**
  1898. * The `allowableMismatchedRatio` ranges from `0` to `1` and is used to
  1899. * determine an acceptable ratio of pixels that can be mismatched before
  1900. * the image is considered to have changes. Realistically, two screenshots
  1901. * representing the same content may have a small number of pixels that
  1902. * are not identical due to anti-aliasing, which is perfectly normal. The
  1903. * `allowableMismatchedRatio` is the number of pixels that were mismatched,
  1904. * divided by the total number of pixels in the screenshot. For example,
  1905. * a ratio value of `0.06` means 6% of the pixels can be mismatched before
  1906. * the image is considered to have changes. If the `allowableMismatchedRatio`
  1907. * is provided it will take precedence, otherwise `allowableMismatchedPixels`
  1908. * will be used.
  1909. */
  1910. allowableMismatchedRatio?: number;
  1911. }
  1912. export interface EventSpy {
  1913. events: SerializedEvent[];
  1914. eventName: string;
  1915. firstEvent: SerializedEvent;
  1916. lastEvent: SerializedEvent;
  1917. length: number;
  1918. next(): Promise<{
  1919. done: boolean;
  1920. value: SerializedEvent;
  1921. }>;
  1922. }
  1923. export interface SerializedEvent {
  1924. bubbles: boolean;
  1925. cancelBubble: boolean;
  1926. cancelable: boolean;
  1927. composed: boolean;
  1928. currentTarget: any;
  1929. defaultPrevented: boolean;
  1930. detail: any;
  1931. eventPhase: any;
  1932. isTrusted: boolean;
  1933. returnValue: any;
  1934. srcElement: any;
  1935. target: any;
  1936. timeStamp: number;
  1937. type: string;
  1938. isSerializedEvent: boolean;
  1939. }
  1940. export interface EventInitDict {
  1941. bubbles?: boolean;
  1942. cancelable?: boolean;
  1943. composed?: boolean;
  1944. detail?: any;
  1945. }
  1946. export interface JestEnvironmentGlobal {
  1947. __NEW_TEST_PAGE__: () => Promise<any>;
  1948. __CLOSE_OPEN_PAGES__: () => Promise<any>;
  1949. Context: any;
  1950. loadTestWindow: (testWindow: any) => Promise<void>;
  1951. h: any;
  1952. resourcesUrl: string;
  1953. currentSpec?: {
  1954. id: string;
  1955. description: string;
  1956. fullName: string;
  1957. testPath: string;
  1958. };
  1959. env: {
  1960. [prop: string]: string;
  1961. };
  1962. screenshotDescriptions: Set<string>;
  1963. }
  1964. export interface E2EProcessEnv {
  1965. STENCIL_COMMIT_ID?: string;
  1966. STENCIL_COMMIT_MESSAGE?: string;
  1967. STENCIL_REPO_URL?: string;
  1968. STENCIL_SCREENSHOT_CONNECTOR?: string;
  1969. STENCIL_SCREENSHOT_SERVER?: string;
  1970. __STENCIL_EMULATE_CONFIGS__?: string;
  1971. __STENCIL_ENV__?: string;
  1972. __STENCIL_EMULATE__?: string;
  1973. __STENCIL_BROWSER_URL__?: string;
  1974. __STENCIL_APP_SCRIPT_URL__?: string;
  1975. __STENCIL_APP_STYLE_URL__?: string;
  1976. __STENCIL_BROWSER_WS_ENDPOINT__?: string;
  1977. __STENCIL_BROWSER_WAIT_UNTIL?: string;
  1978. __STENCIL_SCREENSHOT__?: 'true';
  1979. __STENCIL_SCREENSHOT_BUILD__?: string;
  1980. __STENCIL_E2E_TESTS__?: 'true';
  1981. __STENCIL_E2E_DEVTOOLS__?: 'true';
  1982. __STENCIL_SPEC_TESTS__?: 'true';
  1983. __STENCIL_PUPPETEER_MODULE__?: string;
  1984. __STENCIL_DEFAULT_TIMEOUT__?: string;
  1985. }
  1986. export interface AnyHTMLElement extends HTMLElement {
  1987. [key: string]: any;
  1988. }
  1989. export interface SpecPage {
  1990. /**
  1991. * Mocked testing `document.body`.
  1992. */
  1993. body: HTMLBodyElement;
  1994. /**
  1995. * Mocked testing `document`.
  1996. */
  1997. doc: HTMLDocument;
  1998. /**
  1999. * The first component found within the mocked `document.body`. If a component isn't found, then it'll return `document.body.firstElementChild`.
  2000. */
  2001. root?: AnyHTMLElement;
  2002. /**
  2003. * Similar to `root`, except returns the component instance. If a root component was not found it'll return `null`.
  2004. */
  2005. rootInstance?: any;
  2006. /**
  2007. * Convenience function to set `document.body.innerHTML` and `waitForChanges()`. Function argument should be an html string.
  2008. */
  2009. setContent: (html: string) => Promise<any>;
  2010. /**
  2011. * 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()`.
  2012. */
  2013. waitForChanges: () => Promise<any>;
  2014. /**
  2015. * Mocked testing `window`.
  2016. */
  2017. win: Window;
  2018. build: BuildConditionals;
  2019. flushLoadModule: (bundleId?: string) => Promise<any>;
  2020. flushQueue: () => Promise<any>;
  2021. styles: Map<string, string>;
  2022. }
  2023. export interface NewSpecPageOptions {
  2024. /**
  2025. * 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.
  2026. */
  2027. components: any[];
  2028. /**
  2029. * Sets the mocked `document.cookie`.
  2030. */
  2031. cookie?: string;
  2032. /**
  2033. * Sets the mocked `dir` attribute on `<html>`.
  2034. */
  2035. direction?: string;
  2036. flushQueue?: boolean;
  2037. /**
  2038. * 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`.
  2039. */
  2040. html?: string;
  2041. /**
  2042. * The initial JSX used to generate the test.
  2043. * Use `template` when you want to initialize a component using their properties, instead of their HTML attributes.
  2044. * It will render the specified template (JSX) into `document.body`.
  2045. */
  2046. template?: () => any;
  2047. /**
  2048. * Sets the mocked `lang` attribute on `<html>`.
  2049. */
  2050. language?: string;
  2051. /**
  2052. * Useful for debugging hydrating components client-side. Sets that the `html` option already includes annotated prerender attributes and comments.
  2053. */
  2054. hydrateClientSide?: boolean;
  2055. /**
  2056. * Useful for debugging hydrating components server-side. The output HTML will also include prerender annotations.
  2057. */
  2058. hydrateServerSide?: boolean;
  2059. /**
  2060. * Sets the mocked `document.referrer`.
  2061. */
  2062. referrer?: string;
  2063. /**
  2064. * Manually set if the mocked document supports Shadow DOM or not. Default is `true`.
  2065. */
  2066. supportsShadowDom?: boolean;
  2067. /**
  2068. * 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`.
  2069. */
  2070. includeAnnotations?: boolean;
  2071. /**
  2072. * Sets the mocked browser's `location.href`.
  2073. */
  2074. url?: string;
  2075. /**
  2076. * Sets the mocked browser's `navigator.userAgent`.
  2077. */
  2078. userAgent?: string;
  2079. /**
  2080. * 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`.
  2081. */
  2082. autoApplyChanges?: boolean;
  2083. /**
  2084. * By default, styles are not attached to the DOM and they are not reflected in the serialized HTML.
  2085. * Setting this option to `true` will include the component's styles in the serializable output.
  2086. */
  2087. attachStyles?: boolean;
  2088. strictBuild?: boolean;
  2089. }
  2090. export interface TypesImportData {
  2091. [key: string]: TypesMemberNameData[];
  2092. }
  2093. export interface TypesMemberNameData {
  2094. localName: string;
  2095. importName?: string;
  2096. }
  2097. export interface TypesModule {
  2098. isDep: boolean;
  2099. tagName: string;
  2100. tagNameAsPascal: string;
  2101. htmlElementName: string;
  2102. component: string;
  2103. jsx: string;
  2104. element: string;
  2105. }
  2106. export declare type TypeInfo = {
  2107. name: string;
  2108. type: string;
  2109. optional: boolean;
  2110. required: boolean;
  2111. internal: boolean;
  2112. jsdoc?: string;
  2113. }[];
  2114. export interface Hyperscript {
  2115. (sel: any): VNode;
  2116. (sel: Node, data: VNodeData): VNode;
  2117. (sel: any, data: VNodeData): VNode;
  2118. (sel: any, text: string): VNode;
  2119. (sel: any, children: Array<VNode | undefined | null>): VNode;
  2120. (sel: any, data: VNodeData, text: string): VNode;
  2121. (sel: any, data: VNodeData, children: Array<VNode | undefined | null>): VNode;
  2122. (sel: any, data: VNodeData, children: VNode): VNode;
  2123. }
  2124. export declare type ChildType = VNode | number | string;
  2125. export declare type PropsType = VNodeProdData | number | string | null;
  2126. export interface VNodeProdData {
  2127. key?: string | number;
  2128. class?: {
  2129. [className: string]: boolean;
  2130. } | string;
  2131. className?: {
  2132. [className: string]: boolean;
  2133. } | string;
  2134. style?: any;
  2135. [key: string]: any;
  2136. }
  2137. export interface CompilerWorkerContext {
  2138. optimizeCss(inputOpts: OptimizeCssInput): Promise<OptimizeCssOutput>;
  2139. prepareModule(input: string, minifyOpts: any, transpile: boolean, inlineHelpers: boolean): Promise<{
  2140. output: string;
  2141. diagnostics: Diagnostic[];
  2142. sourceMap?: SourceMap;
  2143. }>;
  2144. prerenderWorker(prerenderRequest: PrerenderUrlRequest): Promise<PrerenderUrlResults>;
  2145. transformCssToEsm(input: TransformCssToEsmInput): Promise<TransformCssToEsmOutput>;
  2146. }
  2147. export interface MsgToWorker {
  2148. stencilId: number;
  2149. args: any[];
  2150. }
  2151. export interface MsgFromWorker {
  2152. stencilId?: number;
  2153. stencilRtnValue: any;
  2154. stencilRtnError: string;
  2155. }
  2156. export interface CompilerWorkerTask {
  2157. stencilId?: number;
  2158. inputArgs?: any[];
  2159. resolve: (val: any) => any;
  2160. reject: (msg: string) => any;
  2161. retries?: number;
  2162. }
  2163. export declare type WorkerMsgHandler = (msgToWorker: MsgToWorker) => Promise<any>;
  2164. export interface WorkerTask {
  2165. taskId: number;
  2166. method: string;
  2167. args: any[];
  2168. resolve: (val: any) => any;
  2169. reject: (msg: string) => any;
  2170. retries: number;
  2171. isLongRunningTask: boolean;
  2172. workerKey: string;
  2173. }
  2174. export interface WorkerMessage {
  2175. taskId?: number;
  2176. method?: string;
  2177. args?: any[];
  2178. value?: any;
  2179. error?: string;
  2180. exit?: boolean;
  2181. }
  2182. export declare type WorkerRunner = (methodName: string, args: any[]) => Promise<any>;
  2183. export interface WorkerRunnerOptions {
  2184. isLongRunningTask?: boolean;
  2185. workerKey?: string;
  2186. }
  2187. export interface WorkerContext {
  2188. tsHost?: any;
  2189. tsProgram?: any;
  2190. }
  2191. export interface TranspileModuleResults {
  2192. sourceFilePath: string;
  2193. code: string;
  2194. map: any;
  2195. diagnostics: Diagnostic[];
  2196. moduleFile: Module;
  2197. }
  2198. export interface ValidateTypesResults {
  2199. diagnostics: Diagnostic[];
  2200. dirPaths: string[];
  2201. filePaths: string[];
  2202. }
  2203. export interface TerminalInfo {
  2204. /**
  2205. * Whether this is in CI or not.
  2206. */
  2207. readonly ci: boolean;
  2208. /**
  2209. * Whether the terminal is an interactive TTY or not.
  2210. */
  2211. readonly tty: boolean;
  2212. }
  2213. /**
  2214. * The task to run in order to collect the duration data point.
  2215. */
  2216. export declare type TelemetryCallback = (...args: any[]) => void | Promise<void>;
  2217. /**
  2218. * The model for the data that's tracked.
  2219. */
  2220. export interface TrackableData {
  2221. yarn: boolean;
  2222. component_count?: number;
  2223. arguments: string[];
  2224. targets: string[];
  2225. task: TaskCommand;
  2226. duration_ms: number;
  2227. packages: string[];
  2228. packages_no_versions?: string[];
  2229. os_name: string;
  2230. os_version: string;
  2231. cpu_model: string;
  2232. typescript: string;
  2233. rollup: string;
  2234. system: string;
  2235. system_major?: string;
  2236. build: string;
  2237. stencil: string;
  2238. has_app_pwa_config: boolean;
  2239. }
  2240. /**
  2241. * Used as the object sent to the server. Value is the data tracked.
  2242. */
  2243. export interface Metric {
  2244. name: string;
  2245. timestamp: string;
  2246. source: 'stencil_cli';
  2247. value: TrackableData;
  2248. session_id: string;
  2249. }
  2250. export interface TelemetryConfig {
  2251. 'telemetry.stencil'?: boolean;
  2252. 'tokens.telemetry'?: string;
  2253. }