@stencil/core 2.16.1 → 2.17.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 (39) hide show
  1. package/cli/index.cjs +96 -6
  2. package/cli/index.js +96 -6
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +524 -121
  6. package/compiler/stencil.min.js +2 -2
  7. package/dependencies.json +1 -1
  8. package/dev-server/client/index.js +1 -1
  9. package/dev-server/client/package.json +1 -1
  10. package/dev-server/connector.html +2 -2
  11. package/dev-server/index.js +1 -1
  12. package/dev-server/package.json +1 -1
  13. package/dev-server/server-process.js +2 -2
  14. package/internal/app-data/package.json +1 -1
  15. package/internal/client/css-shim.js +1 -1
  16. package/internal/client/dom.js +1 -1
  17. package/internal/client/index.js +1 -1
  18. package/internal/client/package.json +1 -1
  19. package/internal/client/patch-browser.js +1 -1
  20. package/internal/client/patch-esm.js +1 -1
  21. package/internal/client/shadow-css.js +1 -1
  22. package/internal/hydrate/package.json +1 -1
  23. package/internal/package.json +1 -1
  24. package/internal/stencil-private.d.ts +4 -0
  25. package/internal/stencil-public-compiler.d.ts +2 -2
  26. package/internal/testing/package.json +1 -1
  27. package/mock-doc/index.cjs +140 -5
  28. package/mock-doc/index.d.ts +76 -1
  29. package/mock-doc/index.js +140 -5
  30. package/mock-doc/package.json +1 -1
  31. package/package.json +1 -1
  32. package/screenshot/package.json +1 -1
  33. package/sys/node/index.js +325 -314
  34. package/sys/node/package.json +1 -1
  35. package/sys/node/worker.js +1 -1
  36. package/testing/index.d.ts +1 -1
  37. package/testing/index.js +406 -367
  38. package/testing/mocks.d.ts +22 -2
  39. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Compiler v2.16.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Compiler v2.17.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  (function(exports) {
5
5
  'use strict';
@@ -1697,38 +1697,30 @@ const readPackageJson = async (config, compilerCtx, buildCtx) => {
1697
1697
  }
1698
1698
  }
1699
1699
  };
1700
+ /**
1701
+ * Parse a string read from a `package.json` file
1702
+ * @param pkgJsonStr the string read from a `package.json` file
1703
+ * @param pkgJsonFilePath the path to the already read `package.json` file
1704
+ * @returns the results of parsing the provided contents of the `package.json` file
1705
+ */
1700
1706
  const parsePackageJson = (pkgJsonStr, pkgJsonFilePath) => {
1701
- if (isString$1(pkgJsonFilePath)) {
1702
- return parseJson(pkgJsonStr, pkgJsonFilePath);
1703
- }
1704
- return null;
1705
- };
1706
- const parseJson = (jsonStr, filePath) => {
1707
- const rtn = {
1707
+ const parseResult = {
1708
1708
  diagnostic: null,
1709
1709
  data: null,
1710
- filePath,
1710
+ filePath: pkgJsonFilePath,
1711
1711
  };
1712
- if (isString$1(jsonStr)) {
1713
- try {
1714
- rtn.data = JSON.parse(jsonStr);
1715
- }
1716
- catch (e) {
1717
- rtn.diagnostic = buildError();
1718
- rtn.diagnostic.absFilePath = filePath;
1719
- rtn.diagnostic.header = `Error Parsing JSON`;
1720
- if (e instanceof Error) {
1721
- rtn.diagnostic.messageText = e.message;
1722
- }
1723
- }
1712
+ try {
1713
+ parseResult.data = JSON.parse(pkgJsonStr);
1724
1714
  }
1725
- else {
1726
- rtn.diagnostic = buildError();
1727
- rtn.diagnostic.absFilePath = filePath;
1728
- rtn.diagnostic.header = `Error Parsing JSON`;
1729
- rtn.diagnostic.messageText = `Invalid JSON input to parse`;
1715
+ catch (e) {
1716
+ parseResult.diagnostic = buildError();
1717
+ parseResult.diagnostic.absFilePath = isString$1(pkgJsonFilePath) ? pkgJsonFilePath : undefined;
1718
+ parseResult.diagnostic.header = `Error Parsing JSON`;
1719
+ if (e instanceof Error) {
1720
+ parseResult.diagnostic.messageText = e.message;
1721
+ }
1730
1722
  }
1731
- return rtn;
1723
+ return parseResult;
1732
1724
  };
1733
1725
  const SKIP_DEPS = ['@stencil/core'];
1734
1726
 
@@ -4027,7 +4019,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
4027
4019
  };
4028
4020
  };
4029
4021
 
4030
- const buildId = '20220603123838';
4022
+ const buildId = '20220621172432';
4031
4023
  const minfyJsId = 'terser5.6.1_7';
4032
4024
  const optimizeCssId = 'autoprefixer10.2.5_postcss8.2.13_7';
4033
4025
  const parse5Version = '6.0.1';
@@ -4035,8 +4027,8 @@ const rollupVersion = '2.42.3';
4035
4027
  const sizzleVersion = '2.42.3';
4036
4028
  const terserVersion = '5.6.1';
4037
4029
  const typescriptVersion = '4.5.4';
4038
- const vermoji = '🎻';
4039
- const version$3 = '2.16.1';
4030
+ const vermoji = '🚂';
4031
+ const version$3 = '2.17.0';
4040
4032
  const versions = {
4041
4033
  stencil: version$3,
4042
4034
  parse5: parse5Version,
@@ -10986,6 +10978,16 @@ MagicString$2.prototype.trimStart = function trimStart (charType) {
10986
10978
  return this;
10987
10979
  };
10988
10980
 
10981
+ /**
10982
+ * Parse CSS docstrings that Stencil supports, as documented here:
10983
+ * https://stenciljs.com/docs/docs-json#css-variables
10984
+ *
10985
+ * Docstrings found in the supplied style text will be added to the
10986
+ * `styleDocs` param
10987
+ *
10988
+ * @param styleDocs the array to hold formatted CSS docstrings
10989
+ * @param styleText the CSS text we're working with
10990
+ */
10989
10991
  function parseStyleDocs(styleDocs, styleText) {
10990
10992
  if (typeof styleText !== 'string') {
10991
10993
  return;
@@ -11002,10 +11004,18 @@ function parseStyleDocs(styleDocs, styleText) {
11002
11004
  styleText = styleText.substring(endIndex + CSS_DOC_END.length);
11003
11005
  }
11004
11006
  }
11007
+ /**
11008
+ * Parse a CSS comment string and insert it into the provided array of
11009
+ * style docstrings.
11010
+ *
11011
+ * @param styleDocs an array which will be modified with the docstring
11012
+ * @param comment the comment string
11013
+ */
11005
11014
  function parseCssComment(styleDocs, comment) {
11006
11015
  /**
11007
11016
  * @prop --max-width: Max width of the alert
11008
11017
  */
11018
+ // (the above is an example of what these comments might look like)
11009
11019
  const lines = comment.split(/\r?\n/).map((line) => {
11010
11020
  line = line.trim();
11011
11021
  while (line.startsWith('*')) {
@@ -11033,11 +11043,19 @@ function parseCssComment(styleDocs, comment) {
11033
11043
  styleDocs.push(cssDoc);
11034
11044
  }
11035
11045
  });
11036
- return styleDocs;
11037
11046
  }
11038
- const CSS_DOC_START = `/**`;
11039
- const CSS_DOC_END = `*/`;
11040
- const CSS_PROP_ANNOTATION = `@prop`;
11047
+ /**
11048
+ * Opening syntax for a CSS docstring
11049
+ */
11050
+ const CSS_DOC_START = '/**';
11051
+ /**
11052
+ * Closing syntax for a CSS docstring
11053
+ */
11054
+ const CSS_DOC_END = '*/';
11055
+ /**
11056
+ * The `@prop` annotation we support within CSS docstrings
11057
+ */
11058
+ const CSS_PROP_ANNOTATION = '@prop';
11041
11059
 
11042
11060
  /**
11043
11061
  * @license
@@ -11526,6 +11544,53 @@ const stripCssComments = (input) => {
11526
11544
  return returnValue;
11527
11545
  };
11528
11546
 
11547
+ /**
11548
+ * A regular expression for matching CSS import statements
11549
+ *
11550
+ * According to https://developer.mozilla.org/en-US/docs/Web/CSS/@import
11551
+ * the formal grammar for CSS import statements is:
11552
+ *
11553
+ * ```
11554
+ * @import [ <url> | <string> ]
11555
+ * [ supports( [ <supports-condition> | <declaration> ] ) ]?
11556
+ * <media-query-list>? ;
11557
+ * ```
11558
+ *
11559
+ * Thus the string literal `"@import"` will be followed by a `<url>` or a
11560
+ * `<string>`, where a `<url>` may be a relative or absolute URL _or_ a `url()`
11561
+ * function.
11562
+ *
11563
+ * Thus the regular expression needs to match:
11564
+ *
11565
+ * - the string `"@import
11566
+ * - any amount of whitespace
11567
+ * - a URL, comprised of:
11568
+ * - an optional `url(` function opener
11569
+ * - a non-greedy match on any characters (to match the argument to the URL
11570
+ * function)
11571
+ * - an optional `)` closing paren on the `url()` function
11572
+ * - trailing characters after the URL, given by anything which doesn't match
11573
+ * the line-terminator `;`
11574
+ * - this can match media queries, support conditions, and so on
11575
+ * - a line-terminating semicolon
11576
+ *
11577
+ * The regex has 4 capture groups:
11578
+ *
11579
+ * 1. `@import`
11580
+ * 2. `url(`
11581
+ * 3. characters after `url(`
11582
+ * 4. all characters other than `;`, greedily matching
11583
+ *
11584
+ * We typically only care about group 4 here.
11585
+ */
11586
+ const CSS_IMPORT_RE = /(@import)\s+(url\()?\s?(.*?)\s?\)?([^;]*);?/gi;
11587
+ /**
11588
+ * Our main entry point to this module. This performs an async transformation
11589
+ * of CSS input to ESM.
11590
+ *
11591
+ * @param input CSS input to be transformed to ESM
11592
+ * @returns a promise wrapping transformed ESM output
11593
+ */
11529
11594
  const transformCssToEsm = async (input) => {
11530
11595
  const results = transformCssToEsmModule(input);
11531
11596
  const optimizeResults = await optimizeCss$1({
@@ -11542,10 +11607,22 @@ const transformCssToEsm = async (input) => {
11542
11607
  results.styleText = optimizeResults.output;
11543
11608
  return generateTransformCssToEsm(input, results);
11544
11609
  };
11610
+ /**
11611
+ * A sync function for transforming input CSS to ESM
11612
+ *
11613
+ * @param input the input CSS we're going to transform
11614
+ * @returns transformed ESM output
11615
+ */
11545
11616
  const transformCssToEsmSync = (input) => {
11546
11617
  const results = transformCssToEsmModule(input);
11547
11618
  return generateTransformCssToEsm(input, results);
11548
11619
  };
11620
+ /**
11621
+ * Performs the actual transformation from CSS to ESM
11622
+ *
11623
+ * @param input input CSS to be transformed
11624
+ * @returns ESM output
11625
+ */
11549
11626
  const transformCssToEsmModule = (input) => {
11550
11627
  const results = {
11551
11628
  styleText: input.input,
@@ -11590,6 +11667,14 @@ const transformCssToEsmModule = (input) => {
11590
11667
  }
11591
11668
  return results;
11592
11669
  };
11670
+ /**
11671
+ * Updated the `output` property on `results` with appropriate import statements for
11672
+ * the CSS import tree and the module type.
11673
+ *
11674
+ * @param input the CSS to ESM transform input
11675
+ * @param results the corresponding output
11676
+ * @returns the modified ESM output
11677
+ */
11593
11678
  const generateTransformCssToEsm = (input, results) => {
11594
11679
  const s = new MagicString$2('');
11595
11680
  if (input.module === 'cjs') {
@@ -11619,6 +11704,15 @@ const generateTransformCssToEsm = (input, results) => {
11619
11704
  results.output = s.toString();
11620
11705
  return results;
11621
11706
  };
11707
+ /**
11708
+ * Get all of the CSS imports in a file
11709
+ *
11710
+ * @param varNames a set into which new names will be added
11711
+ * @param cssText the CSS text in question
11712
+ * @param filePath the file path to the file in question
11713
+ * @param modeName the current mode name
11714
+ * @returns an array of import objects
11715
+ */
11622
11716
  const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
11623
11717
  const cssImports = [];
11624
11718
  if (!cssText.includes('@import')) {
@@ -11660,10 +11754,22 @@ const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
11660
11754
  }
11661
11755
  return cssImports;
11662
11756
  };
11663
- const CSS_IMPORT_RE = /(@import)\s+(url\()?\s?(.*?)\s?\)?([^;]*);?/gi;
11757
+ /**
11758
+ * Check if a module URL is a css node module
11759
+ *
11760
+ * @param url to check
11761
+ * @returns whether or not it's a Css node module
11762
+ */
11664
11763
  const isCssNodeModule$1 = (url) => {
11665
11764
  return url.startsWith('~');
11666
11765
  };
11766
+ /**
11767
+ * Check if a given import is a local import or not (i.e. check that it
11768
+ * is not importing from some other domain)
11769
+ *
11770
+ * @param srcImport the import to check
11771
+ * @returns whether it's local or not
11772
+ */
11667
11773
  const isLocalCssImport$1 = (srcImport) => {
11668
11774
  srcImport = srcImport.toLowerCase();
11669
11775
  if (srcImport.includes('url(')) {
@@ -11676,6 +11782,13 @@ const isLocalCssImport$1 = (srcImport) => {
11676
11782
  }
11677
11783
  return true;
11678
11784
  };
11785
+ /**
11786
+ * Given a file path and a mode name, create an appropriate variable name
11787
+ *
11788
+ * @param filePath the path we want to use
11789
+ * @param modeName the name for the current style mode (i.e. `md` or `ios` on Ionic)
11790
+ * @returns an appropriate Css var name
11791
+ */
11679
11792
  const createCssVarName = (filePath, modeName) => {
11680
11793
  let varName = path$5.basename(filePath);
11681
11794
  if (modeName && modeName !== DEFAULT_STYLE_MODE && !varName.includes(modeName)) {
@@ -15663,6 +15776,9 @@ class MockElement extends MockNode {
15663
15776
  this.shadowRoot = shadowRoot;
15664
15777
  return shadowRoot;
15665
15778
  }
15779
+ blur() {
15780
+ /**/
15781
+ }
15666
15782
  get shadowRoot() {
15667
15783
  return this.__shadowRoot || null;
15668
15784
  }
@@ -15731,6 +15847,7 @@ class MockElement extends MockNode {
15731
15847
  get firstElementChild() {
15732
15848
  return this.children[0] || null;
15733
15849
  }
15850
+ focus(_options) { }
15734
15851
  getAttribute(attrName) {
15735
15852
  if (attrName === 'style') {
15736
15853
  if (this.__style != null && this.__style.length > 0) {
@@ -16634,7 +16751,28 @@ function createElementNS(ownerDocument, namespaceURI, tagName) {
16634
16751
  return createElement(ownerDocument, tagName);
16635
16752
  }
16636
16753
  else if (namespaceURI === 'http://www.w3.org/2000/svg') {
16637
- return new MockSVGElement(ownerDocument, tagName);
16754
+ switch (tagName.toLowerCase()) {
16755
+ case 'text':
16756
+ case 'tspan':
16757
+ case 'tref':
16758
+ case 'altglyph':
16759
+ case 'textpath':
16760
+ return new MockSVGTextContentElement(ownerDocument, tagName);
16761
+ case 'circle':
16762
+ case 'ellipse':
16763
+ case 'image':
16764
+ case 'line':
16765
+ case 'path':
16766
+ case 'polygon':
16767
+ case 'polyline':
16768
+ case 'rect':
16769
+ case 'use':
16770
+ return new MockSVGGraphicsElement(ownerDocument, tagName);
16771
+ case 'svg':
16772
+ return new MockSVGSVGElement(ownerDocument, tagName);
16773
+ default:
16774
+ return new MockSVGElement(ownerDocument, tagName);
16775
+ }
16638
16776
  }
16639
16777
  else {
16640
16778
  return new MockElement(ownerDocument, tagName);
@@ -16781,6 +16919,98 @@ class MockScriptElement extends MockHTMLElement {
16781
16919
  patchPropAttributes(MockScriptElement.prototype, {
16782
16920
  type: String,
16783
16921
  });
16922
+ class MockDOMMatrix {
16923
+ constructor() {
16924
+ this.a = 1;
16925
+ this.b = 0;
16926
+ this.c = 0;
16927
+ this.d = 1;
16928
+ this.e = 0;
16929
+ this.f = 0;
16930
+ this.m11 = 1;
16931
+ this.m12 = 0;
16932
+ this.m13 = 0;
16933
+ this.m14 = 0;
16934
+ this.m21 = 0;
16935
+ this.m22 = 1;
16936
+ this.m23 = 0;
16937
+ this.m24 = 0;
16938
+ this.m31 = 0;
16939
+ this.m32 = 0;
16940
+ this.m33 = 1;
16941
+ this.m34 = 0;
16942
+ this.m41 = 0;
16943
+ this.m42 = 0;
16944
+ this.m43 = 0;
16945
+ this.m44 = 1;
16946
+ this.is2D = true;
16947
+ this.isIdentity = true;
16948
+ }
16949
+ static fromMatrix() {
16950
+ return new MockDOMMatrix();
16951
+ }
16952
+ inverse() {
16953
+ return new MockDOMMatrix();
16954
+ }
16955
+ flipX() {
16956
+ return new MockDOMMatrix();
16957
+ }
16958
+ flipY() {
16959
+ return new MockDOMMatrix();
16960
+ }
16961
+ multiply() {
16962
+ return new MockDOMMatrix();
16963
+ }
16964
+ rotate() {
16965
+ return new MockDOMMatrix();
16966
+ }
16967
+ rotateAxisAngle() {
16968
+ return new MockDOMMatrix();
16969
+ }
16970
+ rotateFromVector() {
16971
+ return new MockDOMMatrix();
16972
+ }
16973
+ scale() {
16974
+ return new MockDOMMatrix();
16975
+ }
16976
+ scaleNonUniform() {
16977
+ return new MockDOMMatrix();
16978
+ }
16979
+ skewX() {
16980
+ return new MockDOMMatrix();
16981
+ }
16982
+ skewY() {
16983
+ return new MockDOMMatrix();
16984
+ }
16985
+ toJSON() { }
16986
+ toString() { }
16987
+ transformPoint() {
16988
+ return new MockDOMPoint();
16989
+ }
16990
+ translate() {
16991
+ return new MockDOMMatrix();
16992
+ }
16993
+ }
16994
+ class MockDOMPoint {
16995
+ constructor() {
16996
+ this.w = 1;
16997
+ this.x = 0;
16998
+ this.y = 0;
16999
+ this.z = 0;
17000
+ }
17001
+ toJSON() { }
17002
+ matrixTransform() {
17003
+ return new MockDOMMatrix();
17004
+ }
17005
+ }
17006
+ class MockSVGRect {
17007
+ constructor() {
17008
+ this.height = 10;
17009
+ this.width = 10;
17010
+ this.x = 0;
17011
+ this.y = 0;
17012
+ }
17013
+ }
16784
17014
  class MockStyleElement extends MockHTMLElement {
16785
17015
  constructor(ownerDocument) {
16786
17016
  super(ownerDocument, 'style');
@@ -16813,9 +17043,6 @@ class MockSVGElement extends MockElement {
16813
17043
  get viewportElement() {
16814
17044
  return null;
16815
17045
  }
16816
- focus() {
16817
- /**/
16818
- }
16819
17046
  onunload() {
16820
17047
  /**/
16821
17048
  }
@@ -16833,6 +17060,27 @@ class MockSVGElement extends MockElement {
16833
17060
  return 0;
16834
17061
  }
16835
17062
  }
17063
+ class MockSVGGraphicsElement extends MockSVGElement {
17064
+ getBBox(_options) {
17065
+ return new MockSVGRect();
17066
+ }
17067
+ getCTM() {
17068
+ return new MockDOMMatrix();
17069
+ }
17070
+ getScreenCTM() {
17071
+ return new MockDOMMatrix();
17072
+ }
17073
+ }
17074
+ class MockSVGSVGElement extends MockSVGGraphicsElement {
17075
+ createSVGPoint() {
17076
+ return new MockDOMPoint();
17077
+ }
17078
+ }
17079
+ class MockSVGTextContentElement extends MockSVGGraphicsElement {
17080
+ getComputedTextLength() {
17081
+ return 0;
17082
+ }
17083
+ }
16836
17084
  class MockBaseElement extends MockHTMLElement {
16837
17085
  constructor(ownerDocument) {
16838
17086
  super(ownerDocument, 'base');
@@ -41053,6 +41301,7 @@ const createComponentExport = (cmp) => {
41053
41301
  * using the `dist-custom-elements` output target may have a single 'entry point' for each file containing a component.
41054
41302
  * Each of those files will be independently resolved and loaded by this plugin for further processing by Rollup later
41055
41303
  * in the bundling process.
41304
+ *
41056
41305
  * @param entries the Stencil project files to process. It should be noted that the keys in this object may not
41057
41306
  * necessarily be an absolute or relative path to a file, but may be a Rollup Virtual Module (which begin with \0).
41058
41307
  * @returns the rollup plugin that loads and process a Stencil project's entry points
@@ -41221,9 +41470,9 @@ const fetchUrlSync = (url) => {
41221
41470
  return undefined;
41222
41471
  };
41223
41472
 
41224
- const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41473
+ const patchTsSystemFileSystem = (config, compilerSys, inMemoryFs, tsSys) => {
41225
41474
  const realpath = (path) => {
41226
- const rp = stencilSys.realpathSync(path);
41475
+ const rp = compilerSys.realpathSync(path);
41227
41476
  if (isString$1(rp)) {
41228
41477
  return rp;
41229
41478
  }
@@ -41231,7 +41480,7 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41231
41480
  };
41232
41481
  const getAccessibleFileSystemEntries = (path) => {
41233
41482
  try {
41234
- const entries = stencilSys.readDirSync(path || '.').sort();
41483
+ const entries = compilerSys.readDirSync(path || '.').sort();
41235
41484
  const files = [];
41236
41485
  const directories = [];
41237
41486
  for (const absPath of entries) {
@@ -41256,13 +41505,13 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41256
41505
  }
41257
41506
  };
41258
41507
  tsSys.createDirectory = (p) => {
41259
- stencilSys.createDirSync(p, { recursive: true });
41508
+ compilerSys.createDirSync(p, { recursive: true });
41260
41509
  };
41261
41510
  tsSys.directoryExists = (p) => {
41262
41511
  const s = inMemoryFs.statSync(p);
41263
41512
  return s.isDirectory;
41264
41513
  };
41265
- tsSys.exit = stencilSys.exit;
41514
+ tsSys.exit = compilerSys.exit;
41266
41515
  tsSys.fileExists = (p) => {
41267
41516
  let filePath = p;
41268
41517
  if (isRemoteUrl(p)) {
@@ -41271,17 +41520,17 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41271
41520
  const s = inMemoryFs.statSync(filePath);
41272
41521
  return !!(s && s.isFile);
41273
41522
  };
41274
- tsSys.getCurrentDirectory = stencilSys.getCurrentDirectory;
41275
- tsSys.getExecutingFilePath = stencilSys.getCompilerExecutingPath;
41523
+ tsSys.getCurrentDirectory = compilerSys.getCurrentDirectory;
41524
+ tsSys.getExecutingFilePath = compilerSys.getCompilerExecutingPath;
41276
41525
  tsSys.getDirectories = (p) => {
41277
- const items = stencilSys.readDirSync(p);
41526
+ const items = compilerSys.readDirSync(p);
41278
41527
  return items.filter((itemPath) => {
41279
41528
  const s = inMemoryFs.statSync(itemPath);
41280
41529
  return !!(s && s.exists && s.isDirectory);
41281
41530
  });
41282
41531
  };
41283
41532
  tsSys.readDirectory = (path, extensions, exclude, include, depth) => {
41284
- const cwd = stencilSys.getCurrentDirectory();
41533
+ const cwd = compilerSys.getCurrentDirectory();
41285
41534
  // TODO(STENCIL-344): Replace `matchFiles` with a function that is publicly exposed
41286
41535
  return t.matchFiles(path, extensions, exclude, include, IS_CASE_SENSITIVE_FILE_NAMES, cwd, depth, getAccessibleFileSystemEntries, realpath);
41287
41536
  };
@@ -41308,9 +41557,9 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41308
41557
  tsSys.writeFile = (p, data) => inMemoryFs.writeFile(p, data);
41309
41558
  return tsSys;
41310
41559
  };
41311
- const patchTsSystemWatch = (stencilSys, tsSys) => {
41560
+ const patchTsSystemWatch = (compilerSystem, tsSys) => {
41312
41561
  tsSys.watchDirectory = (p, cb, recursive) => {
41313
- const watcher = stencilSys.watchDirectory(p, (filePath) => {
41562
+ const watcher = compilerSystem.watchDirectory(p, (filePath) => {
41314
41563
  cb(filePath);
41315
41564
  }, recursive);
41316
41565
  return {
@@ -41320,7 +41569,7 @@ const patchTsSystemWatch = (stencilSys, tsSys) => {
41320
41569
  };
41321
41570
  };
41322
41571
  tsSys.watchFile = (p, cb) => {
41323
- const watcher = stencilSys.watchFile(p, (filePath, eventKind) => {
41572
+ const watcher = compilerSystem.watchFile(p, (filePath, eventKind) => {
41324
41573
  if (eventKind === 'fileAdd') {
41325
41574
  cb(filePath, t.FileWatcherEventKind.Created);
41326
41575
  }
@@ -55573,6 +55822,9 @@ const updateStencilCoreImports = (updatedCoreImportPath) => {
55573
55822
  };
55574
55823
  };
55575
55824
  };
55825
+ /**
55826
+ * A set of imports which we don't want to remove from an output file
55827
+ */
55576
55828
  const KEEP_IMPORTS = new Set([
55577
55829
  'h',
55578
55830
  'setMode',
@@ -55592,37 +55844,75 @@ const KEEP_IMPORTS = new Set([
55592
55844
  'setErrorHandler',
55593
55845
  ]);
55594
55846
 
55847
+ /**
55848
+ * Main output target function for `dist-custom-elements`. This function just
55849
+ * does some organizational work to call the other functions in this module,
55850
+ * which do actual work of generating the rollup configuration, creating an
55851
+ * entry chunk, running, the build, etc.
55852
+ *
55853
+ * @param config the user-supplied compiler configuration we're using
55854
+ * @param compilerCtx the current compiler context
55855
+ * @param buildCtx the current build context
55856
+ * @returns an empty Promise which won't resolve until the work is done!
55857
+ */
55595
55858
  const outputCustomElements = async (config, compilerCtx, buildCtx) => {
55859
+ var _a;
55596
55860
  if (!config.buildDist) {
55597
55861
  return;
55598
55862
  }
55599
- const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
55863
+ const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
55600
55864
  if (outputTargets.length === 0) {
55601
55865
  return;
55602
55866
  }
55603
55867
  const bundlingEventMessage = 'generate custom elements';
55604
55868
  const timespan = buildCtx.createTimeSpan(`${bundlingEventMessage} started`);
55605
- await Promise.all(outputTargets.map((o) => bundleCustomElements$1(config, compilerCtx, buildCtx, o)));
55869
+ await Promise.all(outputTargets.map((target) => bundleCustomElements$1(config, compilerCtx, buildCtx, target)));
55606
55870
  timespan.finish(`${bundlingEventMessage} finished`);
55607
55871
  };
55872
+ /**
55873
+ * Get bundle options for our current build and compiler context which we'll use
55874
+ * to generate a Rollup build and so on.
55875
+ *
55876
+ * @param config user-supplied Stencil configuration
55877
+ * @param buildCtx the current build context
55878
+ * @param compilerCtx the current compiler context
55879
+ * @param outputTarget the outputTarget we're currently dealing with
55880
+ * @returns bundle options suitable for generating a rollup configuration
55881
+ */
55882
+ const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => ({
55883
+ id: 'customElements',
55884
+ platform: 'client',
55885
+ conditionals: getCustomElementsBuildConditionals(config, buildCtx.components),
55886
+ customTransformers: getCustomElementCustomTransformer(config, compilerCtx, buildCtx.components, outputTarget),
55887
+ externalRuntime: !!outputTarget.externalRuntime,
55888
+ inlineWorkers: true,
55889
+ inputs: {
55890
+ // Here we prefix our index chunk with '\0' to tell Rollup that we're
55891
+ // going to be using virtual modules with this module. A leading '\0'
55892
+ // prevents other plugins from messing with the module. We generate a
55893
+ // string for the index chunk below in the `loader` property.
55894
+ //
55895
+ // @see {@link https://rollupjs.org/guide/en/#conventions} for more info.
55896
+ index: '\0core',
55897
+ },
55898
+ loader: {
55899
+ '\0core': generateEntryPoint$1(outputTarget),
55900
+ },
55901
+ inlineDynamicImports: outputTarget.inlineDynamicImports,
55902
+ preserveEntrySignatures: 'allow-extension',
55903
+ });
55904
+ /**
55905
+ * Get bundle options for rollup, run the rollup build, optionally minify the
55906
+ * output, and write files to disk.
55907
+ * @param config user-supplied Stencil configuration
55908
+ * @param buildCtx the current build context
55909
+ * @param compilerCtx the current compiler context
55910
+ * @param outputTarget the outputTarget we're currently dealing with
55911
+ * @returns an empty promise
55912
+ */
55608
55913
  const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarget) => {
55609
55914
  try {
55610
- const bundleOpts = {
55611
- id: 'customElements',
55612
- platform: 'client',
55613
- conditionals: getCustomElementsBuildConditionals(config, buildCtx.components),
55614
- customTransformers: getCustomElementCustomTransformer(config, compilerCtx, buildCtx.components, outputTarget),
55615
- externalRuntime: !!outputTarget.externalRuntime,
55616
- inlineWorkers: true,
55617
- inputs: {
55618
- index: '\0core',
55619
- },
55620
- loader: {
55621
- '\0core': generateEntryPoint$1(outputTarget),
55622
- },
55623
- inlineDynamicImports: outputTarget.inlineDynamicImports,
55624
- preserveEntrySignatures: 'allow-extension',
55625
- };
55915
+ const bundleOpts = getBundleOptions(config, buildCtx, compilerCtx, outputTarget);
55626
55916
  addCustomElementInputs(buildCtx, bundleOpts);
55627
55917
  const build = await bundleOutput(config, compilerCtx, buildCtx, bundleOpts);
55628
55918
  if (build) {
@@ -55635,6 +55925,18 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
55635
55925
  hoistTransitiveImports: false,
55636
55926
  preferConst: true,
55637
55927
  });
55928
+ // the output target should have been validated at this point - as a result, we expect this field
55929
+ // to have been backfilled if it wasn't provided
55930
+ const outputTargetDir = outputTarget.dir;
55931
+ // besides, if it isn't here we do a diagnostic and an early return
55932
+ if (!isString$1(outputTargetDir)) {
55933
+ buildCtx.diagnostics.push({
55934
+ level: 'error',
55935
+ type: 'build',
55936
+ messageText: 'dist-custom-elements output target provided with no output target directory!',
55937
+ });
55938
+ return;
55939
+ }
55638
55940
  const minify = outputTarget.externalRuntime || outputTarget.minify !== true ? false : config.minifyJs;
55639
55941
  const files = rollupOutput.output.map(async (bundle) => {
55640
55942
  if (bundle.type === 'chunk') {
@@ -55649,15 +55951,15 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
55649
55951
  buildCtx.diagnostics.push(...optimizeResults.diagnostics);
55650
55952
  if (!hasError(optimizeResults.diagnostics) && typeof optimizeResults.output === 'string') {
55651
55953
  code = optimizeResults.output;
55652
- sourceMap = optimizeResults.sourceMap;
55653
55954
  }
55654
- if (sourceMap) {
55955
+ if (optimizeResults.sourceMap) {
55956
+ sourceMap = optimizeResults.sourceMap;
55655
55957
  code = code + getSourceMappingUrlForEndOfFile(bundle.fileName);
55656
- await compilerCtx.fs.writeFile(join(outputTarget.dir, bundle.fileName + '.map'), JSON.stringify(sourceMap), {
55958
+ await compilerCtx.fs.writeFile(join(outputTargetDir, bundle.fileName + '.map'), JSON.stringify(sourceMap), {
55657
55959
  outputTargetType: outputTarget.type,
55658
55960
  });
55659
55961
  }
55660
- await compilerCtx.fs.writeFile(join(outputTarget.dir, bundle.fileName), code, {
55962
+ await compilerCtx.fs.writeFile(join(outputTargetDir, bundle.fileName), code, {
55661
55963
  outputTargetType: outputTarget.type,
55662
55964
  });
55663
55965
  }
@@ -55676,6 +55978,8 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
55676
55978
  */
55677
55979
  const addCustomElementInputs = (buildCtx, bundleOpts) => {
55678
55980
  const components = buildCtx.components;
55981
+ // an array to store the imports of these modules that we're going to add to our entry chunk
55982
+ const indexImports = [];
55679
55983
  components.forEach((cmp) => {
55680
55984
  const exp = [];
55681
55985
  const exportName = dashToPascalCase$1(cmp.tagName);
@@ -55684,16 +55988,25 @@ const addCustomElementInputs = (buildCtx, bundleOpts) => {
55684
55988
  const coreKey = `\0${exportName}`;
55685
55989
  if (cmp.isPlain) {
55686
55990
  exp.push(`export { ${importName} as ${exportName} } from '${cmp.sourceFilePath}';`);
55991
+ indexImports.push(`export { {${exportName} } from '${coreKey}';`);
55687
55992
  }
55688
55993
  else {
55689
55994
  // the `importName` may collide with the `exportName`, alias it just in case it does with `importAs`
55690
55995
  exp.push(`import { ${importName} as ${importAs}, defineCustomElement as cmpDefCustomEle } from '${cmp.sourceFilePath}';`);
55691
55996
  exp.push(`export const ${exportName} = ${importAs};`);
55692
55997
  exp.push(`export const defineCustomElement = cmpDefCustomEle;`);
55998
+ // Here we push an export (with a rename for `defineCustomElement` for
55999
+ // this component onto our array which references the `coreKey` (prefixed
56000
+ // with `\0`). We have to do this so that our import is referencing the
56001
+ // correct virtual module, if we instead referenced, for instance,
56002
+ // `cmp.sourceFilePath`, we would end up with duplicated modules in our
56003
+ // output.
56004
+ indexImports.push(`export { ${exportName}, defineCustomElement as defineCustomElement${exportName} } from '${coreKey}';`);
55693
56005
  }
55694
56006
  bundleOpts.inputs[cmp.tagName] = coreKey;
55695
56007
  bundleOpts.loader[coreKey] = exp.join('\n');
55696
56008
  });
56009
+ bundleOpts.loader['\0core'] += indexImports.join('\n');
55697
56010
  };
55698
56011
  /**
55699
56012
  * Generate the entrypoint (`index.ts` file) contents for the `dist-custom-elements` output target
@@ -55711,6 +56024,7 @@ const generateEntryPoint$1 = (outputTarget) => {
55711
56024
  /**
55712
56025
  * Get the series of custom transformers that will be applied to a Stencil project's source code during the TypeScript
55713
56026
  * transpilation process
56027
+ *
55714
56028
  * @param config the configuration for the Stencil project
55715
56029
  * @param compilerCtx the current compiler context
55716
56030
  * @param components the components that will be compiled as a part of the current build
@@ -59702,29 +60016,38 @@ const relDts$1 = (fromPath, dtsPath) => {
59702
60016
  * @param config the Stencil configuration associated with the project being compiled
59703
60017
  * @param compilerCtx the current compiler context
59704
60018
  * @param buildCtx the context associated with the current build
59705
- * @param distDtsFilePath the path to a type declaration file (.d.ts) that is being generated for the output target.
59706
- * This path is not necessarily the `components.d.ts` file that is found in the root of a project's `src` directory.
60019
+ * @param typesDir the path to the directory where type declarations are saved
59707
60020
  */
59708
- const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, distDtsFilePath) => {
59709
- const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
59710
- await Promise.all(outputTargets.map((outputTarget) => generateCustomElementsTypesOutput(config, compilerCtx, buildCtx, distDtsFilePath, outputTarget)));
60021
+ const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, typesDir) => {
60022
+ var _a;
60023
+ const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
60024
+ await Promise.all(outputTargets.map((outputTarget) => generateCustomElementsTypesOutput(config, compilerCtx, buildCtx, typesDir, outputTarget)));
59711
60025
  };
59712
60026
  /**
59713
60027
  * Generates types for a single `dist-custom-elements` output target definition in a Stencil project's configuration
60028
+ *
59714
60029
  * @param config the Stencil configuration associated with the project being compiled
59715
60030
  * @param compilerCtx the current compiler context
59716
60031
  * @param buildCtx the context associated with the current build
59717
- * @param distDtsFilePath the path to a type declaration file (.d.ts) that is being generated for the output target.
59718
- * This path is not necessarily the `components.d.ts` file that is found in the root of a project's `src` directory.
60032
+ * @param typesDir path to the directory where type declarations are saved
59719
60033
  * @param outputTarget the output target for which types are being currently generated
59720
60034
  */
59721
- const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx, distDtsFilePath, outputTarget) => {
60035
+ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx, typesDir, outputTarget) => {
60036
+ // the path where we're going to write the typedef for the whole dist-custom-elements output
59722
60037
  const customElementsDtsPath = join(outputTarget.dir, 'index.d.ts');
59723
- const componentsDtsRelPath = relDts(outputTarget.dir, distDtsFilePath);
60038
+ // the directory where types for the individual components are written
60039
+ const componentsTypeDirectoryPath = relative$1(outputTarget.dir, join(typesDir, 'components'));
60040
+ const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
59724
60041
  const code = [
59725
60042
  `/* ${config.namespace} custom elements */`,
59726
- ``,
59727
- `import type { Components, JSX } from "${componentsDtsRelPath}";`,
60043
+ ...components.map((component) => {
60044
+ const exportName = dashToPascalCase$1(component.tagName);
60045
+ const importName = component.componentClassName;
60046
+ // typedefs for individual components can be found under paths like
60047
+ // $TYPES_DIR/components/my-component/my-component.d.ts
60048
+ const componentDTSPath = join(componentsTypeDirectoryPath, component.tagName, component.tagName);
60049
+ return `export { ${importName} as ${exportName} } from '${componentDTSPath}';`;
60050
+ }),
59728
60051
  ``,
59729
60052
  `/**`,
59730
60053
  ` * Used to manually set the base path where assets can be found.`,
@@ -59744,10 +60067,8 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
59744
60067
  ` rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;`,
59745
60068
  `}`,
59746
60069
  `export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;`,
59747
- ``,
59748
- `export type { Components, JSX };`,
59749
- ``,
59750
60070
  ];
60071
+ const componentsDtsRelPath = relDts(outputTarget.dir, join(typesDir, 'components.d.ts'));
59751
60072
  const usersIndexJsPath = join(config.srcDir, 'index.ts');
59752
60073
  const hasUserIndex = await compilerCtx.fs.access(usersIndexJsPath);
59753
60074
  if (hasUserIndex) {
@@ -59760,7 +60081,6 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
59760
60081
  await compilerCtx.fs.writeFile(customElementsDtsPath, code.join('\n') + `\n`, {
59761
60082
  outputTargetType: outputTarget.type,
59762
60083
  });
59763
- const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
59764
60084
  await Promise.all(components.map(async (cmp) => {
59765
60085
  const dtsCode = generateCustomElementType(componentsDtsRelPath, cmp);
59766
60086
  const fileName = `${cmp.tagName}.d.ts`;
@@ -59834,20 +60154,21 @@ const generateTypesOutput = async (config, compilerCtx, buildCtx, outputTarget)
59834
60154
  const srcDtsFiles = srcDirItems.filter((srcItem) => srcItem.isFile && isDtsFile$1(srcItem.absPath));
59835
60155
  // Copy .d.ts files from src to dist
59836
60156
  // In addition, all references to @stencil/core are replaced
59837
- let distDtsFilePath;
59838
- await Promise.all(srcDtsFiles.map(async (srcDtsFile) => {
60157
+ const copiedDTSFilePaths = await Promise.all(srcDtsFiles.map(async (srcDtsFile) => {
59839
60158
  const relPath = relative$1(config.srcDir, srcDtsFile.absPath);
59840
60159
  const distPath = join(outputTarget.typesDir, relPath);
59841
60160
  const originalDtsContent = await compilerCtx.fs.readFile(srcDtsFile.absPath);
59842
60161
  const distDtsContent = updateStencilTypesImports(outputTarget.typesDir, distPath, originalDtsContent);
59843
60162
  await compilerCtx.fs.writeFile(distPath, distDtsContent);
59844
- distDtsFilePath = distPath;
60163
+ return distPath;
59845
60164
  }));
60165
+ const distDtsFilePath = copiedDTSFilePaths.slice(-1)[0];
59846
60166
  const distPath = outputTarget.typesDir;
59847
60167
  await generateAppTypes(config, compilerCtx, buildCtx, distPath);
60168
+ const { typesDir } = outputTarget;
59848
60169
  if (distDtsFilePath) {
59849
- await generateCustomElementsTypes(config, compilerCtx, buildCtx, distDtsFilePath);
59850
60170
  await generateCustomElementsBundleTypes(config, compilerCtx, buildCtx, distDtsFilePath);
60171
+ await generateCustomElementsTypes(config, compilerCtx, buildCtx, typesDir);
59851
60172
  }
59852
60173
  };
59853
60174
 
@@ -63642,37 +63963,76 @@ const filesChanged = (buildCtx) => {
63642
63963
  // files changed include updated, added and deleted
63643
63964
  return unique([...buildCtx.filesUpdated, ...buildCtx.filesAdded, ...buildCtx.filesDeleted]).sort();
63644
63965
  };
63645
- const scriptsAdded = (buildCtx) => {
63646
- // collect all the scripts that were added
63647
- return buildCtx.filesAdded
63648
- .filter((f) => {
63649
- return SCRIPT_EXT.some((ext) => f.endsWith(ext.toLowerCase()));
63650
- })
63651
- .map((f) => basename(f));
63652
- };
63653
- const scriptsDeleted = (buildCtx) => {
63654
- // collect all the scripts that were deleted
63655
- return buildCtx.filesDeleted
63656
- .filter((f) => {
63657
- return SCRIPT_EXT.some((ext) => f.endsWith(ext.toLowerCase()));
63658
- })
63659
- .map((f) => basename(f));
63660
- };
63661
- const hasScriptChanges = (buildCtx) => {
63662
- return buildCtx.filesChanged.some((f) => {
63663
- const ext = getExt(f);
63664
- return SCRIPT_EXT.includes(ext);
63665
- });
63666
- };
63667
- const hasStyleChanges = (buildCtx) => {
63668
- return buildCtx.filesChanged.some((f) => {
63669
- const ext = getExt(f);
63670
- return STYLE_EXT.includes(ext);
63671
- });
63672
- };
63966
+ /**
63967
+ * Unary helper function mapping string to string and wrapping `basename`,
63968
+ * which normally takes two string arguments. This means it cannot be passed
63969
+ * to `Array.prototype.map`, but this little helper can!
63970
+ *
63971
+ * @param filePath a filepath to check out
63972
+ * @returns the basename for that filepath
63973
+ */
63974
+ const unaryBasename = (filePath) => basename(filePath);
63975
+ /**
63976
+ * Get the file extension for a path
63977
+ *
63978
+ * @param filePath a path
63979
+ * @returns the file extension (well, characters after the last `'.'`)
63980
+ */
63673
63981
  const getExt = (filePath) => filePath.split('.').pop().toLowerCase();
63982
+ /**
63983
+ * Script extensions which we want to be able to recognize
63984
+ */
63674
63985
  const SCRIPT_EXT = ['ts', 'tsx', 'js', 'jsx'];
63986
+ /**
63987
+ * Helper to check if a filepath has a script extension
63988
+ *
63989
+ * @param filePath a file extension
63990
+ * @returns whether the filepath has a script extension or not
63991
+ */
63992
+ const hasScriptExt = (filePath) => SCRIPT_EXT.includes(getExt(filePath));
63675
63993
  const STYLE_EXT = ['css', 'scss', 'sass', 'pcss', 'styl', 'stylus', 'less'];
63994
+ /**
63995
+ * Helper to check if a filepath has a style extension
63996
+ *
63997
+ * @param filePath a file extension to check
63998
+ * @returns whether the filepath has a style extension or not
63999
+ */
64000
+ const hasStyleExt = (filePath) => STYLE_EXT.includes(getExt(filePath));
64001
+ /**
64002
+ * Get all scripts from a build context that were added
64003
+ *
64004
+ * @param buildCtx the build context
64005
+ * @returns an array of filepaths that were added
64006
+ */
64007
+ const scriptsAdded = (buildCtx) => buildCtx.filesAdded.filter(hasScriptExt).map(unaryBasename);
64008
+ /**
64009
+ * Get all scripts from a build context that were deleted
64010
+ *
64011
+ * @param buildCtx the build context
64012
+ * @returns an array of deleted filepaths
64013
+ */
64014
+ const scriptsDeleted = (buildCtx) => buildCtx.filesDeleted.filter(hasScriptExt).map(unaryBasename);
64015
+ /**
64016
+ * Check whether a build has script changes
64017
+ *
64018
+ * @param buildCtx the build context
64019
+ * @returns whether or not there are script changes
64020
+ */
64021
+ const hasScriptChanges = (buildCtx) => buildCtx.filesChanged.some(hasScriptExt);
64022
+ /**
64023
+ * Check whether a build has style changes
64024
+ *
64025
+ * @param buildCtx the build context
64026
+ * @returns whether or not there are style changes
64027
+ */
64028
+ const hasStyleChanges = (buildCtx) => buildCtx.filesChanged.some(hasStyleExt);
64029
+ /**
64030
+ * Check whether a build has html changes
64031
+ *
64032
+ * @param config the current config
64033
+ * @param buildCtx the build context
64034
+ * @returns whether or not HTML files were changed
64035
+ */
63676
64036
  const hasHtmlChanges = (config, buildCtx) => {
63677
64037
  const anyHtmlChanged = buildCtx.filesChanged.some((f) => f.toLowerCase().endsWith('.html'));
63678
64038
  if (anyHtmlChanged) {
@@ -64599,7 +64959,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
64599
64959
  const dependencies = [
64600
64960
  {
64601
64961
  name: "@stencil/core",
64602
- version: "2.16.1",
64962
+ version: "2.17.0",
64603
64963
  main: "compiler/stencil.js",
64604
64964
  resources: [
64605
64965
  "package.json",
@@ -66197,6 +66557,21 @@ const createDefaultTsConfig = (config) => JSON.stringify({
66197
66557
  const hasSrcDirectoryInclude = (includeProp, src) => Array.isArray(includeProp) && includeProp.includes(src);
66198
66558
  const hasStencilConfigInclude = (includeProp) => Array.isArray(includeProp) && includeProp.includes('stencil.config.ts');
66199
66559
 
66560
+ /**
66561
+ * Load and validate a configuration to use throughout the lifetime of any Stencil task (build, test, etc.).
66562
+ *
66563
+ * Users can provide configurations multiple ways simultaneously:
66564
+ * - as an object of the `init` argument to this function
66565
+ * - through a path to a configuration file that exists on disk
66566
+ *
66567
+ * In the case of both being present, the two configurations will be merged. The fields of the former will take precedence
66568
+ * over the fields of the latter.
66569
+ *
66570
+ * @param init the initial configuration provided by the user (or generated by Stencil) used to bootstrap configuration
66571
+ * loading and validation
66572
+ * @returns the results of loading a configuration
66573
+ * @public
66574
+ */
66200
66575
  const loadConfig = async (init = {}) => {
66201
66576
  const results = {
66202
66577
  config: null,
@@ -66268,6 +66643,15 @@ const loadConfig = async (init = {}) => {
66268
66643
  }
66269
66644
  return results;
66270
66645
  };
66646
+ /**
66647
+ * Load a Stencil configuration file from disk
66648
+ * @param sys the underlying System entity to use to interact with the operating system
66649
+ * @param diagnostics a series of diagnostics used to track errors & warnings throughout the loading process. Entries
66650
+ * may be added to this list in the event of an error.
66651
+ * @param configPath the path to the configuration file to load
66652
+ * @returns an unvalidated configuration. In the event of an error, additional diagnostics may be pushed to the
66653
+ * provided `diagnostics` argument and `null` will be returned.
66654
+ */
66271
66655
  const loadConfigFile = async (sys, diagnostics, configPath) => {
66272
66656
  let config = null;
66273
66657
  if (isString$1(configPath)) {
@@ -66287,6 +66671,15 @@ const loadConfigFile = async (sys, diagnostics, configPath) => {
66287
66671
  }
66288
66672
  return config;
66289
66673
  };
66674
+ /**
66675
+ * Load the configuration file, based on the environment that Stencil is being run in
66676
+ * @param sys the underlying System entity to use to interact with the operating system
66677
+ * @param diagnostics a series of diagnostics used to track errors & warnings throughout the loading process. Entries
66678
+ * may be added to this list in the event of an error.
66679
+ * @param configFilePath the path to the configuration file to load
66680
+ * @returns an unvalidated configuration. In the event of an error, additional diagnostics may be pushed to the
66681
+ * provided `diagnostics` argument and `null` will be returned.
66682
+ */
66290
66683
  const evaluateConfigFile = async (sys, diagnostics, configFilePath) => {
66291
66684
  let configFileData = null;
66292
66685
  try {
@@ -66311,6 +66704,16 @@ const evaluateConfigFile = async (sys, diagnostics, configFilePath) => {
66311
66704
  }
66312
66705
  return configFileData;
66313
66706
  };
66707
+ /**
66708
+ * Transpiles the provided TypeScript source text into JavaScript.
66709
+ *
66710
+ * This function is intended to be used on a `stencil.config.ts` file
66711
+ *
66712
+ * @param diagnostics a collection of compiler diagnostics to check as a part of the compilation process
66713
+ * @param sourceText the text to transpile
66714
+ * @param filePath the name of the file to transpile
66715
+ * @returns the transpiled text. If there are any diagnostics in the provided collection, the provided source is returned
66716
+ */
66314
66717
  const transpileTypedConfig = (diagnostics, sourceText, filePath) => {
66315
66718
  // let's transpile an awesome stencil.config.ts file into
66316
66719
  // a boring stencil.config.js file