@stencil/core 2.18.0 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/cli/index.cjs +275 -218
  2. package/cli/index.d.ts +3 -0
  3. package/cli/index.js +275 -218
  4. package/cli/package.json +1 -1
  5. package/compiler/package.json +1 -1
  6. package/compiler/stencil.d.ts +2 -2
  7. package/compiler/stencil.js +49510 -47947
  8. package/compiler/stencil.min.js +2 -2
  9. package/dependencies.json +1 -1
  10. package/dev-server/client/index.d.ts +2 -2
  11. package/dev-server/client/index.js +241 -241
  12. package/dev-server/client/package.json +1 -1
  13. package/dev-server/connector.html +3 -3
  14. package/dev-server/index.d.ts +1 -1
  15. package/dev-server/index.js +2 -2
  16. package/dev-server/package.json +1 -1
  17. package/dev-server/server-process.js +1230 -1199
  18. package/internal/app-data/package.json +1 -1
  19. package/internal/client/css-shim.js +2 -2
  20. package/internal/client/dom.js +1 -1
  21. package/internal/client/index.js +619 -601
  22. package/internal/client/package.json +1 -1
  23. package/internal/client/patch-browser.js +1 -1
  24. package/internal/client/patch-esm.js +1 -1
  25. package/internal/client/polyfills/css-shim.js +1 -1
  26. package/internal/client/shadow-css.js +1 -1
  27. package/internal/hydrate/index.js +119 -119
  28. package/internal/hydrate/package.json +1 -1
  29. package/internal/hydrate/runner.d.ts +1 -1
  30. package/internal/hydrate/runner.js +100 -100
  31. package/internal/package.json +1 -1
  32. package/internal/stencil-core/index.d.ts +8 -10
  33. package/internal/stencil-private.d.ts +104 -42
  34. package/internal/stencil-public-compiler.d.ts +12 -2
  35. package/internal/stencil-public-docs.d.ts +20 -0
  36. package/internal/stencil-public-runtime.d.ts +20 -4
  37. package/internal/testing/index.js +148 -148
  38. package/internal/testing/package.json +1 -1
  39. package/mock-doc/index.cjs +655 -645
  40. package/mock-doc/index.js +655 -645
  41. package/mock-doc/package.json +1 -1
  42. package/package.json +29 -37
  43. package/readme.md +27 -33
  44. package/screenshot/index.d.ts +1 -1
  45. package/screenshot/index.js +3 -3
  46. package/screenshot/package.json +1 -1
  47. package/screenshot/pixel-match.js +983 -849
  48. package/sys/node/autoprefixer.js +5 -5
  49. package/sys/node/glob.js +1 -1
  50. package/sys/node/graceful-fs.js +1 -1
  51. package/sys/node/index.d.ts +4 -0
  52. package/sys/node/index.js +373 -374
  53. package/sys/node/package.json +1 -1
  54. package/sys/node/prompts.js +1 -1
  55. package/sys/node/worker.js +1 -1
  56. package/testing/index.d.ts +6 -6
  57. package/testing/index.js +468 -467
  58. package/testing/jest/jest-config.d.ts +1 -1
  59. package/testing/matchers/index.d.ts +3 -3
  60. package/testing/mock-fetch.d.ts +1 -1
  61. package/testing/mocks.d.ts +2 -2
  62. package/testing/package.json +1 -1
  63. package/testing/puppeteer/puppeteer-element.d.ts +2 -2
  64. package/testing/puppeteer/puppeteer-events.d.ts +1 -1
  65. package/testing/testing-logger.d.ts +1 -1
  66. package/testing/testing.d.ts +1 -1
@@ -1,9 +1,10 @@
1
+ export type { StencilConfig as Config, PrerenderConfig } from '../stencil-public-compiler';
1
2
  export type {
2
3
  ChildNode,
3
- ComponentOptions,
4
4
  ComponentDidLoad,
5
5
  ComponentDidUpdate,
6
6
  ComponentInterface,
7
+ ComponentOptions,
7
8
  ComponentWillLoad,
8
9
  ComponentWillUpdate,
9
10
  EventEmitter,
@@ -11,42 +12,39 @@ export type {
11
12
  FunctionalComponent,
12
13
  FunctionalUtilities,
13
14
  JSX,
14
- MethodOptions,
15
- ModeStyles,
16
15
  ListenOptions,
17
16
  ListenTargetOptions,
17
+ MethodOptions,
18
+ ModeStyles,
18
19
  PropOptions,
19
20
  QueueApi,
20
21
  RafCallback,
21
22
  VNode,
22
23
  VNodeData,
23
24
  } from '../stencil-public-runtime';
24
-
25
25
  export {
26
26
  Build,
27
27
  Component,
28
28
  Element,
29
+ Env,
29
30
  Event,
31
+ forceUpdate,
32
+ Fragment,
30
33
  getAssetPath,
31
34
  getElement,
32
35
  getMode,
33
36
  getRenderingRef,
34
- Fragment,
35
- forceUpdate,
36
37
  h,
37
38
  Host,
38
- Env,
39
39
  Listen,
40
40
  Method,
41
41
  Prop,
42
42
  readTask,
43
43
  setAssetPath,
44
+ setErrorHandler,
44
45
  setMode,
45
46
  setPlatformHelpers,
46
47
  State,
47
48
  Watch,
48
49
  writeTask,
49
- setErrorHandler,
50
50
  } from '../stencil-public-runtime';
51
-
52
- export type { StencilConfig as Config, PrerenderConfig } from '../stencil-public-compiler';
@@ -1,7 +1,6 @@
1
- import { BuildResultsComponentGraph } from '.';
2
- import type { BuildEvents, BuildLog, CompilerBuildResults, CompilerBuildStart, CompilerFsStats, CompilerRequestResponse, CompilerSystem, Config, CopyResults, DevServerConfig, DevServerEditor, Diagnostic, Logger, LoggerTimeSpan, OptimizeCssInput, OptimizeCssOutput, OutputTargetWww, PageReloadStrategy, PrerenderConfig, StyleDoc, LoggerLineUpdater, TaskCommand } from './stencil-public-compiler';
3
- import type { ComponentInterface, ListenOptions, ListenTargetOptions, VNode, VNodeData } from './stencil-public-runtime';
4
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';
5
4
  export interface SourceMap {
6
5
  file: string;
7
6
  mappings: string;
@@ -785,12 +784,30 @@ export interface ComponentCompilerMethod extends ComponentCompilerStaticMethod {
785
784
  export interface ComponentCompilerState {
786
785
  name: string;
787
786
  }
787
+ /**
788
+ * Representation of JSDoc that is pulled off a node in the AST
789
+ */
788
790
  export interface CompilerJsDoc {
791
+ /**
792
+ * The text associated with the JSDoc
793
+ */
789
794
  text: string;
795
+ /**
796
+ * Tags included in the JSDoc
797
+ */
790
798
  tags: CompilerJsDocTagInfo[];
791
799
  }
800
+ /**
801
+ * Representation of a tag that exists in a JSDoc
802
+ */
792
803
  export interface CompilerJsDocTagInfo {
804
+ /**
805
+ * The name of the tag - e.g. `@deprecated`
806
+ */
793
807
  name: string;
808
+ /**
809
+ * Additional text that is associated with the tag - e.g. `@deprecated use v2 of this API`
810
+ */
794
811
  text?: string;
795
812
  }
796
813
  export interface CompilerStyleDoc {
@@ -824,6 +841,10 @@ export interface ComponentConstructor {
824
841
  isProxied?: boolean;
825
842
  isStyleRegistered?: boolean;
826
843
  }
844
+ /**
845
+ * A mapping from class member names to a list of methods which are watching
846
+ * them.
847
+ */
827
848
  export interface ComponentConstructorWatchers {
828
849
  [propName: string]: string[];
829
850
  }
@@ -833,9 +854,9 @@ export interface ComponentTestingConstructor extends ComponentConstructor {
833
854
  componentWillLoad?: Function;
834
855
  componentWillUpdate?: Function;
835
856
  componentWillRender?: Function;
836
- __componentWillLoad?: Function;
837
- __componentWillUpdate?: Function;
838
- __componentWillRender?: Function;
857
+ __componentWillLoad?: Function | null;
858
+ __componentWillUpdate?: Function | null;
859
+ __componentWillRender?: Function | null;
839
860
  };
840
861
  }
841
862
  export interface ComponentNativeConstructor extends ComponentConstructor {
@@ -1320,42 +1341,82 @@ export declare type ComponentRuntimeMetaCompact = [
1320
1341
  /** listeners */
1321
1342
  ComponentRuntimeHostListener[]?
1322
1343
  ];
1344
+ /**
1345
+ * Runtime metadata for a Stencil component
1346
+ */
1323
1347
  export interface ComponentRuntimeMeta {
1348
+ /**
1349
+ * This number is used to hold a series of bitflags for various features we
1350
+ * support on components. The flags which this value is intended to store are
1351
+ * documented in the {@link CMP_FLAGS} enum.
1352
+ */
1324
1353
  $flags$: number;
1354
+ /**
1355
+ * Just what it says on the tin - the tag name for the component, as set in
1356
+ * the `@Component` decorator.
1357
+ */
1325
1358
  $tagName$: string;
1326
- $members$?: ComponentRuntimeMembers;
1327
- $listeners$?: ComponentRuntimeHostListener[];
1328
- $attrsToReflect$?: [string, string][];
1329
- $watchers$?: ComponentConstructorWatchers;
1330
- $lazyBundleId$?: string;
1331
- }
1332
- export interface ComponentRuntimeMembers {
1333
- [memberName: string]: ComponentRuntimeMember;
1334
- }
1335
- export declare type ComponentRuntimeMember = [
1336
1359
  /**
1337
- * flags data
1360
+ * A map of the component's members, which could include fields decorated
1361
+ * with `@Prop`, `@State`, etc as well as methods.
1338
1362
  */
1339
- number,
1363
+ $members$?: ComponentRuntimeMembers;
1340
1364
  /**
1341
- * attribute name to observe
1365
+ * Information about listeners on the component.
1342
1366
  */
1343
- string?
1344
- ];
1345
- export declare type ComponentRuntimeHostListener = [
1367
+ $listeners$?: ComponentRuntimeHostListener[];
1346
1368
  /**
1347
- * event flags
1369
+ * Tuples containing information about `@Prop` fields on the component which
1370
+ * are set to be reflected (i.e. kept in sync) as HTML attributes when
1371
+ * updated.
1348
1372
  */
1349
- number,
1373
+ $attrsToReflect$?: ComponentRuntimeReflectingAttr[];
1350
1374
  /**
1351
- * event name,
1375
+ * Information about which class members have watchers attached on the component.
1352
1376
  */
1353
- string,
1377
+ $watchers$?: ComponentConstructorWatchers;
1354
1378
  /**
1355
- * event method,
1379
+ * A bundle ID used for lazy loading.
1356
1380
  */
1357
- string
1358
- ];
1381
+ $lazyBundleId$?: string;
1382
+ }
1383
+ /**
1384
+ * A mapping of the names of members on the component to some runtime-specific
1385
+ * information about them.
1386
+ */
1387
+ export interface ComponentRuntimeMembers {
1388
+ [memberName: string]: ComponentRuntimeMember;
1389
+ }
1390
+ /**
1391
+ * A tuple with information about a class member that's relevant at runtime.
1392
+ * The fields are:
1393
+ *
1394
+ * 1. A number used to hold bitflags for component members. The bit flags which
1395
+ * this is intended to store are documented in the {@link MEMBER_FLAGS} enum.
1396
+ * 2. The attribute name to observe.
1397
+ */
1398
+ export declare type ComponentRuntimeMember = [number, string?];
1399
+ /**
1400
+ * A tuple holding information about a host listener which is relevant at
1401
+ * runtime. The field are:
1402
+ *
1403
+ * 1. A number used to hold bitflags for listeners. The bit flags which this is
1404
+ * intended to store are documented in the {@link LISTENER_FLAGS} enum.
1405
+ * 2. The event name.
1406
+ * 3. The method name.
1407
+ */
1408
+ export declare type ComponentRuntimeHostListener = [number, string, string];
1409
+ /**
1410
+ * A tuple containing information about props which are "reflected" at runtime,
1411
+ * meaning that HTML attributes on the component instance are kept in sync with
1412
+ * the prop value.
1413
+ *
1414
+ * The fields are:
1415
+ *
1416
+ * 1. the prop name
1417
+ * 2. the prop attribute.
1418
+ */
1419
+ export declare type ComponentRuntimeReflectingAttr = [string, string | undefined];
1359
1420
  export declare type ModeBundleId = ModeBundleIds | string;
1360
1421
  export interface ModeBundleIds {
1361
1422
  [modeName: string]: string;
@@ -2163,25 +2224,26 @@ export declare type TelemetryCallback = (...args: any[]) => void | Promise<void>
2163
2224
  * The model for the data that's tracked.
2164
2225
  */
2165
2226
  export interface TrackableData {
2166
- yarn: boolean;
2167
- component_count?: number;
2168
2227
  arguments: string[];
2169
- targets: string[];
2170
- task: TaskCommand;
2171
- duration_ms: number;
2228
+ build: string;
2229
+ component_count?: number;
2230
+ config: Config;
2231
+ cpu_model: string | undefined;
2232
+ duration_ms: number | undefined;
2233
+ has_app_pwa_config: boolean;
2234
+ is_browser_env: boolean;
2235
+ os_name: string | undefined;
2236
+ os_version: string | undefined;
2172
2237
  packages: string[];
2173
2238
  packages_no_versions?: string[];
2174
- os_name: string;
2175
- os_version: string;
2176
- cpu_model: string;
2177
- typescript: string;
2178
2239
  rollup: string;
2240
+ stencil: string;
2179
2241
  system: string;
2180
2242
  system_major?: string;
2181
- build: string;
2182
- stencil: string;
2183
- has_app_pwa_config: boolean;
2184
- config: Config;
2243
+ targets: string[];
2244
+ task: TaskCommand | null;
2245
+ typescript: string;
2246
+ yarn: boolean;
2185
2247
  }
2186
2248
  /**
2187
2249
  * Used as the object sent to the server. Value is the data tracked.
@@ -1,6 +1,6 @@
1
- import type { JsonDocs } from './stencil-public-docs';
2
- import type { PrerenderUrlResults } from '../internal';
3
1
  import type { ConfigFlags } from '../cli/config-flags';
2
+ import type { PrerenderUrlResults } from '../internal';
3
+ import type { JsonDocs } from './stencil-public-docs';
4
4
  export * from './stencil-public-docs';
5
5
  /**
6
6
  * https://stenciljs.com/docs/config/
@@ -512,6 +512,10 @@ export interface StencilDevServerConfig {
512
512
  export interface DevServerConfig extends StencilDevServerConfig {
513
513
  browserUrl?: string;
514
514
  devServerDir?: string;
515
+ /**
516
+ * A list of glob patterns like `subdir/*.js` to exclude from hot-module
517
+ * reloading updates.
518
+ */
515
519
  excludeHmr?: string[];
516
520
  historyApiFallback?: HistoryApiFallback;
517
521
  openBrowser?: boolean;
@@ -1850,6 +1854,12 @@ export interface OutputTargetBaseNext {
1850
1854
  export interface OutputTargetDistCustomElements extends OutputTargetBaseNext {
1851
1855
  type: 'dist-custom-elements';
1852
1856
  empty?: boolean;
1857
+ /**
1858
+ * Triggers the following behaviors when enabled:
1859
+ * 1. All `@stencil/core/*` module references are treated as external during bundling.
1860
+ * 2. File names are not hashed.
1861
+ * 3. File minification will follow the behavior defined at the root of the Stencil config.
1862
+ */
1853
1863
  externalRuntime?: boolean;
1854
1864
  copy?: CopyTask[];
1855
1865
  inlineDynamicImports?: boolean;
@@ -42,6 +42,26 @@ export interface JsonDocsValue {
42
42
  value?: string;
43
43
  type: string;
44
44
  }
45
+ /**
46
+ * A mapping of file names to their contents.
47
+ *
48
+ * This type is meant to be used when reading one or more usage markdown files associated with a component. For the
49
+ * given directory structure:
50
+ * ```
51
+ * src/components/my-component
52
+ * ├── my-component.tsx
53
+ * └── usage
54
+ * ├── bar.md
55
+ * └── foo.md
56
+ * ```
57
+ * an instance of this type would include the name of the markdown file, mapped to its contents:
58
+ * ```ts
59
+ * {
60
+ * 'bar': STRING_CONTENTS_OF_BAR.MD
61
+ * 'foo': STRING_CONTENTS_OF_FOO.MD
62
+ * }
63
+ * ```
64
+ */
45
65
  export interface JsonDocsUsage {
46
66
  [key: string]: string;
47
67
  }
@@ -221,7 +221,9 @@ export declare type ErrorHandler = (err: any, element?: HTMLElement) => void;
221
221
  */
222
222
  export declare const setMode: (handler: ResolutionHandler) => void;
223
223
  /**
224
- * getMode
224
+ * `getMode()` is used for libraries which provide multiple "modes" for styles.
225
+ * @param ref a reference to the node to get styles for
226
+ * @returns the current mode or undefined, if not found
225
227
  */
226
228
  export declare function getMode<T = string | undefined>(ref: any): T;
227
229
  export declare function setPlatformHelpers(helpers: {
@@ -234,6 +236,9 @@ export declare function setPlatformHelpers(helpers: {
234
236
  /**
235
237
  * Get the base path to where the assets can be found. Use `setAssetPath(path)`
236
238
  * if the path needs to be customized.
239
+ * @param path the path to use in calculating the asset path. this value will be
240
+ * used in conjunction with the base asset path
241
+ * @returns the base path
237
242
  */
238
243
  export declare function getAssetPath(path: string): string;
239
244
  /**
@@ -246,22 +251,29 @@ export declare function getAssetPath(path: string): string;
246
251
  * `setAssetPath(document.currentScript.src)`, or using a bundler's replace plugin to
247
252
  * dynamically set the path at build time, such as `setAssetPath(process.env.ASSET_PATH)`.
248
253
  * But do note that this configuration depends on how your script is bundled, or lack of
249
- * bunding, and where your assets can be loaded from. Additionally custom bundling
254
+ * bundling, and where your assets can be loaded from. Additionally custom bundling
250
255
  * will have to ensure the static assets are copied to its build directory.
256
+ * @param path the asset path to set
257
+ * @returns the set path
251
258
  */
252
259
  export declare function setAssetPath(path: string): string;
253
260
  /**
254
- * getElement
261
+ * Retrieve a Stencil element for a given reference
262
+ * @param ref the ref to get the Stencil element for
263
+ * @returns a reference to the element
255
264
  */
256
265
  export declare function getElement(ref: any): HTMLStencilElement;
257
266
  /**
258
267
  * Schedules a new render of the given instance or element even if no state changed.
259
268
  *
260
- * Notice `forceUpdate()` is not syncronous and might perform the DOM render in the next frame.
269
+ * Notice `forceUpdate()` is not synchronous and might perform the DOM render in the next frame.
270
+ *
271
+ * @param ref the node/element to force the re-render of
261
272
  */
262
273
  export declare function forceUpdate(ref: any): void;
263
274
  /**
264
275
  * getRenderingRef
276
+ * @returns the rendering ref
265
277
  */
266
278
  export declare function getRenderingRef(): any;
267
279
  export interface HTMLStencilElement extends HTMLElement {
@@ -272,6 +284,8 @@ export interface HTMLStencilElement extends HTMLElement {
272
284
  * in the best moment to perform DOM mutation without causing layout thrashing.
273
285
  *
274
286
  * For further information: https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing
287
+ *
288
+ * @param task the DOM-write to schedule
275
289
  */
276
290
  export declare function writeTask(task: RafCallback): void;
277
291
  /**
@@ -279,6 +293,8 @@ export declare function writeTask(task: RafCallback): void;
279
293
  * in the best moment to perform DOM reads without causing layout thrashing.
280
294
  *
281
295
  * For further information: https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing
296
+ *
297
+ * @param task the DOM-read to schedule
282
298
  */
283
299
  export declare function readTask(task: RafCallback): void;
284
300
  /**