@stencil/core 2.16.0 → 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 (42) hide show
  1. package/cli/index.cjs +124 -16
  2. package/cli/index.js +124 -16
  3. package/cli/package.json +1 -1
  4. package/compiler/package.json +1 -1
  5. package/compiler/stencil.js +728 -263
  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 +3 -3
  11. package/dev-server/index.js +1 -1
  12. package/dev-server/package.json +1 -1
  13. package/dev-server/server-process.js +4 -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/index.js +3 -3
  23. package/internal/hydrate/package.json +1 -1
  24. package/internal/package.json +1 -1
  25. package/internal/stencil-private.d.ts +4 -0
  26. package/internal/stencil-public-compiler.d.ts +3 -2
  27. package/internal/testing/index.js +1 -1
  28. package/internal/testing/package.json +1 -1
  29. package/mock-doc/index.cjs +142 -5
  30. package/mock-doc/index.d.ts +77 -1
  31. package/mock-doc/index.js +142 -5
  32. package/mock-doc/package.json +1 -1
  33. package/package.json +2 -1
  34. package/screenshot/index.js +2 -0
  35. package/screenshot/package.json +1 -1
  36. package/sys/node/index.js +325 -314
  37. package/sys/node/package.json +1 -1
  38. package/sys/node/worker.js +1 -1
  39. package/testing/index.d.ts +1 -1
  40. package/testing/index.js +105 -62
  41. package/testing/mocks.d.ts +22 -2
  42. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Compiler v2.16.0 | 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';
@@ -717,7 +717,7 @@ const computeListenerFlags = (listener) => {
717
717
  };
718
718
  const trimFalsy = (data) => {
719
719
  const arr = data;
720
- for (var i = arr.length - 1; i >= 0; i--) {
720
+ for (let i = arr.length - 1; i >= 0; i--) {
721
721
  if (arr[i]) {
722
722
  break;
723
723
  }
@@ -826,136 +826,15 @@ const isGlob = (str) => {
826
826
  };
827
827
 
828
828
  /**
829
- * Checks if the path is the OS root path, such as "/" or "C:\"
829
+ * Checks if the path is the Operating System (OS) root path, such as "/" or "C:\". This function does not take the OS
830
+ * the code is running on into account when performing this evaluation.
831
+ * @param p the path to check
832
+ * @returns `true` if the path is an OS root path, `false` otherwise
830
833
  */
831
834
  const isRootPath = (p) => p === '/' || windowsPathRegex.test(p);
832
835
  // https://github.com/nodejs/node/blob/5883a59b21a97e8b7339f435c977155a2c29ba8d/lib/path.js#L43
833
836
  const windowsPathRegex = /^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)?[\\/]$/;
834
837
 
835
- /**
836
- * Iterate through a series of diagnostics to provide minor fix-ups for various edge cases, deduplicate messages, etc.
837
- * @param compilerCtx the current compiler context
838
- * @param diagnostics the diagnostics to normalize
839
- * @returns the normalize documents
840
- */
841
- const normalizeDiagnostics = (compilerCtx, diagnostics) => {
842
- const normalizedErrors = [];
843
- const normalizedOthers = [];
844
- const dups = new Set();
845
- for (let i = 0; i < diagnostics.length; i++) {
846
- const d = normalizeDiagnostic(compilerCtx, diagnostics[i]);
847
- const key = d.absFilePath + d.code + d.messageText + d.type;
848
- if (dups.has(key)) {
849
- continue;
850
- }
851
- dups.add(key);
852
- const total = normalizedErrors.length + normalizedOthers.length;
853
- if (d.level === 'error') {
854
- normalizedErrors.push(d);
855
- }
856
- else if (total < MAX_ERRORS) {
857
- normalizedOthers.push(d);
858
- }
859
- }
860
- return [...normalizedErrors, ...normalizedOthers];
861
- };
862
- /**
863
- * Perform post-processing on a `Diagnostic` to handle a few message edge cases, massaging error message text and
864
- * updating build failure contexts
865
- * @param compilerCtx the current compiler
866
- * @param diagnostic the diagnostic to normalize
867
- * @returns the altered diagnostic
868
- */
869
- const normalizeDiagnostic = (compilerCtx, diagnostic) => {
870
- if (diagnostic.messageText) {
871
- if (typeof diagnostic.messageText.message === 'string') {
872
- diagnostic.messageText = diagnostic.messageText.message;
873
- }
874
- else if (typeof diagnostic.messageText === 'string' && diagnostic.messageText.indexOf('Error: ') === 0) {
875
- diagnostic.messageText = diagnostic.messageText.slice(7);
876
- }
877
- }
878
- if (diagnostic.messageText) {
879
- if (diagnostic.messageText.includes(`Cannot find name 'h'`)) {
880
- diagnostic.header = `Missing "h" import for JSX types`;
881
- diagnostic.messageText = `In order to load accurate JSX types for components, the "h" function must be imported from "@stencil/core" by each component using JSX. For example: import { Component, h } from '@stencil/core';`;
882
- try {
883
- const sourceText = compilerCtx.fs.readFileSync(diagnostic.absFilePath);
884
- const srcLines = splitLineBreaks(sourceText);
885
- for (let i = 0; i < srcLines.length; i++) {
886
- const srcLine = srcLines[i];
887
- if (srcLine.includes('@stencil/core')) {
888
- const msgLines = [];
889
- const beforeLineIndex = i - 1;
890
- if (beforeLineIndex > -1) {
891
- const beforeLine = {
892
- lineIndex: beforeLineIndex,
893
- lineNumber: beforeLineIndex + 1,
894
- text: srcLines[beforeLineIndex],
895
- errorCharStart: -1,
896
- errorLength: -1,
897
- };
898
- msgLines.push(beforeLine);
899
- }
900
- const errorLine = {
901
- lineIndex: i,
902
- lineNumber: i + 1,
903
- text: srcLine,
904
- errorCharStart: 0,
905
- errorLength: -1,
906
- };
907
- msgLines.push(errorLine);
908
- diagnostic.lineNumber = errorLine.lineNumber;
909
- diagnostic.columnNumber = srcLine.indexOf('}');
910
- const afterLineIndex = i + 1;
911
- if (afterLineIndex < srcLines.length) {
912
- const afterLine = {
913
- lineIndex: afterLineIndex,
914
- lineNumber: afterLineIndex + 1,
915
- text: srcLines[afterLineIndex],
916
- errorCharStart: -1,
917
- errorLength: -1,
918
- };
919
- msgLines.push(afterLine);
920
- }
921
- diagnostic.lines = msgLines;
922
- break;
923
- }
924
- }
925
- }
926
- catch (e) { }
927
- }
928
- }
929
- return diagnostic;
930
- };
931
- /**
932
- * Split a corpus by newlines. Carriage returns are treated a newlines.
933
- * @param sourceText the corpus to split
934
- * @returns the split text
935
- */
936
- const splitLineBreaks = (sourceText) => {
937
- if (typeof sourceText !== 'string')
938
- return [];
939
- sourceText = sourceText.replace(/\\r/g, '\n');
940
- return sourceText.split('\n');
941
- };
942
- const escapeHtml = (unsafe) => {
943
- if (unsafe === undefined)
944
- return 'undefined';
945
- if (unsafe === null)
946
- return 'null';
947
- if (typeof unsafe !== 'string') {
948
- unsafe = unsafe.toString();
949
- }
950
- return unsafe
951
- .replace(/&/g, '&amp;')
952
- .replace(/</g, '&lt;')
953
- .replace(/>/g, '&gt;')
954
- .replace(/"/g, '&quot;')
955
- .replace(/'/g, '&#039;');
956
- };
957
- const MAX_ERRORS = 25;
958
-
959
838
  /**
960
839
  * Builds a template `Diagnostic` entity for a build error. The created `Diagnostic` is returned, and have little
961
840
  * detail attached to it regarding the specifics of the error - it is the responsibility of the caller of this method
@@ -1120,6 +999,130 @@ const shouldIgnoreError = (msg) => {
1120
999
  };
1121
1000
  const TASK_CANCELED_MSG = `task canceled`;
1122
1001
 
1002
+ /**
1003
+ * Iterate through a series of diagnostics to provide minor fix-ups for various edge cases, deduplicate messages, etc.
1004
+ * @param compilerCtx the current compiler context
1005
+ * @param diagnostics the diagnostics to normalize
1006
+ * @returns the normalize documents
1007
+ */
1008
+ const normalizeDiagnostics = (compilerCtx, diagnostics) => {
1009
+ const maxErrorsToNormalize = 25;
1010
+ const normalizedErrors = [];
1011
+ const normalizedOthers = [];
1012
+ const dups = new Set();
1013
+ for (let i = 0; i < diagnostics.length; i++) {
1014
+ const d = normalizeDiagnostic(compilerCtx, diagnostics[i]);
1015
+ const key = d.absFilePath + d.code + d.messageText + d.type;
1016
+ if (dups.has(key)) {
1017
+ continue;
1018
+ }
1019
+ dups.add(key);
1020
+ const total = normalizedErrors.length + normalizedOthers.length;
1021
+ if (d.level === 'error') {
1022
+ normalizedErrors.push(d);
1023
+ }
1024
+ else if (total < maxErrorsToNormalize) {
1025
+ normalizedOthers.push(d);
1026
+ }
1027
+ }
1028
+ return [...normalizedErrors, ...normalizedOthers];
1029
+ };
1030
+ /**
1031
+ * Perform post-processing on a `Diagnostic` to handle a few message edge cases, massaging error message text and
1032
+ * updating build failure contexts
1033
+ * @param compilerCtx the current compiler
1034
+ * @param diagnostic the diagnostic to normalize
1035
+ * @returns the altered diagnostic
1036
+ */
1037
+ const normalizeDiagnostic = (compilerCtx, diagnostic) => {
1038
+ if (diagnostic.messageText) {
1039
+ if (typeof diagnostic.messageText.message === 'string') {
1040
+ diagnostic.messageText = diagnostic.messageText.message;
1041
+ }
1042
+ else if (typeof diagnostic.messageText === 'string' && diagnostic.messageText.indexOf('Error: ') === 0) {
1043
+ diagnostic.messageText = diagnostic.messageText.slice(7);
1044
+ }
1045
+ }
1046
+ if (diagnostic.messageText) {
1047
+ if (diagnostic.messageText.includes(`Cannot find name 'h'`)) {
1048
+ diagnostic.header = `Missing "h" import for JSX types`;
1049
+ diagnostic.messageText = `In order to load accurate JSX types for components, the "h" function must be imported from "@stencil/core" by each component using JSX. For example: import { Component, h } from '@stencil/core';`;
1050
+ try {
1051
+ const sourceText = compilerCtx.fs.readFileSync(diagnostic.absFilePath);
1052
+ const srcLines = splitLineBreaks(sourceText);
1053
+ for (let i = 0; i < srcLines.length; i++) {
1054
+ const srcLine = srcLines[i];
1055
+ if (srcLine.includes('@stencil/core')) {
1056
+ const msgLines = [];
1057
+ const beforeLineIndex = i - 1;
1058
+ if (beforeLineIndex > -1) {
1059
+ const beforeLine = {
1060
+ lineIndex: beforeLineIndex,
1061
+ lineNumber: beforeLineIndex + 1,
1062
+ text: srcLines[beforeLineIndex],
1063
+ errorCharStart: -1,
1064
+ errorLength: -1,
1065
+ };
1066
+ msgLines.push(beforeLine);
1067
+ }
1068
+ const errorLine = {
1069
+ lineIndex: i,
1070
+ lineNumber: i + 1,
1071
+ text: srcLine,
1072
+ errorCharStart: 0,
1073
+ errorLength: -1,
1074
+ };
1075
+ msgLines.push(errorLine);
1076
+ diagnostic.lineNumber = errorLine.lineNumber;
1077
+ diagnostic.columnNumber = srcLine.indexOf('}');
1078
+ const afterLineIndex = i + 1;
1079
+ if (afterLineIndex < srcLines.length) {
1080
+ const afterLine = {
1081
+ lineIndex: afterLineIndex,
1082
+ lineNumber: afterLineIndex + 1,
1083
+ text: srcLines[afterLineIndex],
1084
+ errorCharStart: -1,
1085
+ errorLength: -1,
1086
+ };
1087
+ msgLines.push(afterLine);
1088
+ }
1089
+ diagnostic.lines = msgLines;
1090
+ break;
1091
+ }
1092
+ }
1093
+ }
1094
+ catch (e) { }
1095
+ }
1096
+ }
1097
+ return diagnostic;
1098
+ };
1099
+ /**
1100
+ * Split a corpus by newlines. Carriage returns are treated a newlines.
1101
+ * @param sourceText the corpus to split
1102
+ * @returns the split text
1103
+ */
1104
+ const splitLineBreaks = (sourceText) => {
1105
+ if (typeof sourceText !== 'string')
1106
+ return [];
1107
+ sourceText = sourceText.replace(/\\r/g, '\n');
1108
+ return sourceText.split('\n');
1109
+ };
1110
+ const escapeHtml = (unsafe) => {
1111
+ if (unsafe === undefined)
1112
+ return 'undefined';
1113
+ if (unsafe === null)
1114
+ return 'null';
1115
+ if (typeof unsafe !== 'string') {
1116
+ unsafe = unsafe.toString();
1117
+ }
1118
+ return unsafe
1119
+ .replace(/&/g, '&amp;')
1120
+ .replace(/</g, '&lt;')
1121
+ .replace(/>/g, '&gt;')
1122
+ .replace(/"/g, '&quot;')
1123
+ .replace(/'/g, '&#039;');
1124
+ };
1125
+
1123
1126
  const loadRollupDiagnostics = (config, compilerCtx, buildCtx, rollupError) => {
1124
1127
  const formattedCode = formatErrorCode(rollupError.code);
1125
1128
  const diagnostic = {
@@ -1258,6 +1261,8 @@ const formatErrorCode = (errorCode) => {
1258
1261
  * Forward-slash paths can be used in Windows as long as they're not
1259
1262
  * extended-length paths and don't contain any non-ascii characters.
1260
1263
  * This was created since the path methods in Node.js outputs \\ paths on Windows.
1264
+ * @param path the Windows-based path to convert
1265
+ * @returns the converted path
1261
1266
  */
1262
1267
  const normalizePath$1 = (path) => {
1263
1268
  if (typeof path !== 'string') {
@@ -1393,8 +1398,10 @@ const pathComponents = (path, rootLength) => {
1393
1398
  return [root, ...rest];
1394
1399
  };
1395
1400
  /**
1396
- * Same as normalizePath(), expect it'll also strip any querystrings
1401
+ * Same as normalizePath(), expect it'll also strip any query strings
1397
1402
  * from the path name. So /dir/file.css?tag=cmp-a becomes /dir/file.css
1403
+ * @param p the path to normalize
1404
+ * @returns the normalized path, sans any query strings
1398
1405
  */
1399
1406
  const normalizeFsPath = (p) => normalizePath$1(p.split('?')[0].replace(/\0/g, ''));
1400
1407
  const normalizeFsPathQuery = (importPath) => {
@@ -1570,6 +1577,15 @@ const flattenDiagnosticMessageText = (tsDiagnostic, diag) => {
1570
1577
  return result.trim();
1571
1578
  };
1572
1579
 
1580
+ /**
1581
+ * Determines whether a string should be considered a remote url or not.
1582
+ *
1583
+ * This helper only checks the provided string to evaluate is one of a few pre-defined schemes, and should not be
1584
+ * considered all-encompassing
1585
+ *
1586
+ * @param p the string to evaluate
1587
+ * @returns `true` if the provided string is a remote url, `false` otherwise
1588
+ */
1573
1589
  const isRemoteUrl = (p) => {
1574
1590
  if (isString$1(p)) {
1575
1591
  p = p.toLowerCase();
@@ -1639,12 +1655,23 @@ ${docs.tags
1639
1655
  .map((tag) => `@${tag.name} ${(tag.text || '').replace(lineBreakRegex, ' ')}`)
1640
1656
  .join('\n')}`.trim();
1641
1657
  }
1658
+ /**
1659
+ * Retrieve a project's dependencies from the current build context
1660
+ * @param buildCtx the current build context to query for a specific package
1661
+ * @returns a list of package names the project is dependent on
1662
+ */
1642
1663
  const getDependencies = (buildCtx) => {
1643
1664
  if (buildCtx.packageJson != null && buildCtx.packageJson.dependencies != null) {
1644
1665
  return Object.keys(buildCtx.packageJson.dependencies).filter((pkgName) => !SKIP_DEPS.includes(pkgName));
1645
1666
  }
1646
1667
  return [];
1647
1668
  };
1669
+ /**
1670
+ * Utility to determine whether a project has a dependency on a package
1671
+ * @param buildCtx the current build context to query for a specific package
1672
+ * @param depName the name of the dependency/package
1673
+ * @returns `true` if the project has a dependency a packaged with the provided name, `false` otherwise
1674
+ */
1648
1675
  const hasDependency = (buildCtx, depName) => {
1649
1676
  return getDependencies(buildCtx).includes(depName);
1650
1677
  };
@@ -1670,38 +1697,30 @@ const readPackageJson = async (config, compilerCtx, buildCtx) => {
1670
1697
  }
1671
1698
  }
1672
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
+ */
1673
1706
  const parsePackageJson = (pkgJsonStr, pkgJsonFilePath) => {
1674
- if (isString$1(pkgJsonFilePath)) {
1675
- return parseJson(pkgJsonStr, pkgJsonFilePath);
1676
- }
1677
- return null;
1678
- };
1679
- const parseJson = (jsonStr, filePath) => {
1680
- const rtn = {
1707
+ const parseResult = {
1681
1708
  diagnostic: null,
1682
1709
  data: null,
1683
- filePath,
1710
+ filePath: pkgJsonFilePath,
1684
1711
  };
1685
- if (isString$1(jsonStr)) {
1686
- try {
1687
- rtn.data = JSON.parse(jsonStr);
1688
- }
1689
- catch (e) {
1690
- rtn.diagnostic = buildError();
1691
- rtn.diagnostic.absFilePath = filePath;
1692
- rtn.diagnostic.header = `Error Parsing JSON`;
1693
- if (e instanceof Error) {
1694
- rtn.diagnostic.messageText = e.message;
1695
- }
1696
- }
1712
+ try {
1713
+ parseResult.data = JSON.parse(pkgJsonStr);
1697
1714
  }
1698
- else {
1699
- rtn.diagnostic = buildError();
1700
- rtn.diagnostic.absFilePath = filePath;
1701
- rtn.diagnostic.header = `Error Parsing JSON`;
1702
- 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
+ }
1703
1722
  }
1704
- return rtn;
1723
+ return parseResult;
1705
1724
  };
1706
1725
  const SKIP_DEPS = ['@stencil/core'];
1707
1726
 
@@ -4000,7 +4019,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
4000
4019
  };
4001
4020
  };
4002
4021
 
4003
- const buildId = '20220531163847';
4022
+ const buildId = '20220621172432';
4004
4023
  const minfyJsId = 'terser5.6.1_7';
4005
4024
  const optimizeCssId = 'autoprefixer10.2.5_postcss8.2.13_7';
4006
4025
  const parse5Version = '6.0.1';
@@ -4008,8 +4027,8 @@ const rollupVersion = '2.42.3';
4008
4027
  const sizzleVersion = '2.42.3';
4009
4028
  const terserVersion = '5.6.1';
4010
4029
  const typescriptVersion = '4.5.4';
4011
- const vermoji = '🎉';
4012
- const version$3 = '2.16.0';
4030
+ const vermoji = '🚂';
4031
+ const version$3 = '2.17.0';
4013
4032
  const versions = {
4014
4033
  stencil: version$3,
4015
4034
  parse5: parse5Version,
@@ -10959,6 +10978,16 @@ MagicString$2.prototype.trimStart = function trimStart (charType) {
10959
10978
  return this;
10960
10979
  };
10961
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
+ */
10962
10991
  function parseStyleDocs(styleDocs, styleText) {
10963
10992
  if (typeof styleText !== 'string') {
10964
10993
  return;
@@ -10975,10 +11004,18 @@ function parseStyleDocs(styleDocs, styleText) {
10975
11004
  styleText = styleText.substring(endIndex + CSS_DOC_END.length);
10976
11005
  }
10977
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
+ */
10978
11014
  function parseCssComment(styleDocs, comment) {
10979
11015
  /**
10980
11016
  * @prop --max-width: Max width of the alert
10981
11017
  */
11018
+ // (the above is an example of what these comments might look like)
10982
11019
  const lines = comment.split(/\r?\n/).map((line) => {
10983
11020
  line = line.trim();
10984
11021
  while (line.startsWith('*')) {
@@ -11006,11 +11043,19 @@ function parseCssComment(styleDocs, comment) {
11006
11043
  styleDocs.push(cssDoc);
11007
11044
  }
11008
11045
  });
11009
- return styleDocs;
11010
11046
  }
11011
- const CSS_DOC_START = `/**`;
11012
- const CSS_DOC_END = `*/`;
11013
- 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';
11014
11059
 
11015
11060
  /**
11016
11061
  * @license
@@ -11499,6 +11544,53 @@ const stripCssComments = (input) => {
11499
11544
  return returnValue;
11500
11545
  };
11501
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
+ */
11502
11594
  const transformCssToEsm = async (input) => {
11503
11595
  const results = transformCssToEsmModule(input);
11504
11596
  const optimizeResults = await optimizeCss$1({
@@ -11515,10 +11607,22 @@ const transformCssToEsm = async (input) => {
11515
11607
  results.styleText = optimizeResults.output;
11516
11608
  return generateTransformCssToEsm(input, results);
11517
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
+ */
11518
11616
  const transformCssToEsmSync = (input) => {
11519
11617
  const results = transformCssToEsmModule(input);
11520
11618
  return generateTransformCssToEsm(input, results);
11521
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
+ */
11522
11626
  const transformCssToEsmModule = (input) => {
11523
11627
  const results = {
11524
11628
  styleText: input.input,
@@ -11563,6 +11667,14 @@ const transformCssToEsmModule = (input) => {
11563
11667
  }
11564
11668
  return results;
11565
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
+ */
11566
11678
  const generateTransformCssToEsm = (input, results) => {
11567
11679
  const s = new MagicString$2('');
11568
11680
  if (input.module === 'cjs') {
@@ -11592,6 +11704,15 @@ const generateTransformCssToEsm = (input, results) => {
11592
11704
  results.output = s.toString();
11593
11705
  return results;
11594
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
+ */
11595
11716
  const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
11596
11717
  const cssImports = [];
11597
11718
  if (!cssText.includes('@import')) {
@@ -11633,10 +11754,22 @@ const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
11633
11754
  }
11634
11755
  return cssImports;
11635
11756
  };
11636
- 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
+ */
11637
11763
  const isCssNodeModule$1 = (url) => {
11638
11764
  return url.startsWith('~');
11639
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
+ */
11640
11773
  const isLocalCssImport$1 = (srcImport) => {
11641
11774
  srcImport = srcImport.toLowerCase();
11642
11775
  if (srcImport.includes('url(')) {
@@ -11649,6 +11782,13 @@ const isLocalCssImport$1 = (srcImport) => {
11649
11782
  }
11650
11783
  return true;
11651
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
+ */
11652
11792
  const createCssVarName = (filePath, modeName) => {
11653
11793
  let varName = path$5.basename(filePath);
11654
11794
  if (modeName && modeName !== DEFAULT_STYLE_MODE && !varName.includes(modeName)) {
@@ -11670,7 +11810,7 @@ const createWorkerMessageHandler = (sys) => {
11670
11810
  const fnArgs = msgToWorker.args.slice(1);
11671
11811
  const fn = workerCtx[fnName];
11672
11812
  if (typeof fn === 'function') {
11673
- return fn.apply(null, fnArgs);
11813
+ return fn(...fnArgs);
11674
11814
  }
11675
11815
  };
11676
11816
  };
@@ -13785,8 +13925,8 @@ function generateBuildStats(config, buildCtx) {
13785
13925
  /**
13786
13926
  * Writes the files from the stats config to the file system
13787
13927
  * @param config the project build configuration
13788
- * @param buildCtx An instance of the build which holds the details about the build
13789
- * @returns
13928
+ * @param data the information to write out to disk (as specified by each stats output target specified in the provided
13929
+ * config)
13790
13930
  */
13791
13931
  async function writeBuildStats(config, data) {
13792
13932
  const statsTargets = config.outputTargets.filter(isOutputTargetStats);
@@ -15636,6 +15776,9 @@ class MockElement extends MockNode {
15636
15776
  this.shadowRoot = shadowRoot;
15637
15777
  return shadowRoot;
15638
15778
  }
15779
+ blur() {
15780
+ /**/
15781
+ }
15639
15782
  get shadowRoot() {
15640
15783
  return this.__shadowRoot || null;
15641
15784
  }
@@ -15704,6 +15847,7 @@ class MockElement extends MockNode {
15704
15847
  get firstElementChild() {
15705
15848
  return this.children[0] || null;
15706
15849
  }
15850
+ focus(_options) { }
15707
15851
  getAttribute(attrName) {
15708
15852
  if (attrName === 'style') {
15709
15853
  if (this.__style != null && this.__style.length > 0) {
@@ -16607,7 +16751,28 @@ function createElementNS(ownerDocument, namespaceURI, tagName) {
16607
16751
  return createElement(ownerDocument, tagName);
16608
16752
  }
16609
16753
  else if (namespaceURI === 'http://www.w3.org/2000/svg') {
16610
- 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
+ }
16611
16776
  }
16612
16777
  else {
16613
16778
  return new MockElement(ownerDocument, tagName);
@@ -16754,6 +16919,98 @@ class MockScriptElement extends MockHTMLElement {
16754
16919
  patchPropAttributes(MockScriptElement.prototype, {
16755
16920
  type: String,
16756
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
+ }
16757
17014
  class MockStyleElement extends MockHTMLElement {
16758
17015
  constructor(ownerDocument) {
16759
17016
  super(ownerDocument, 'style');
@@ -16786,9 +17043,6 @@ class MockSVGElement extends MockElement {
16786
17043
  get viewportElement() {
16787
17044
  return null;
16788
17045
  }
16789
- focus() {
16790
- /**/
16791
- }
16792
17046
  onunload() {
16793
17047
  /**/
16794
17048
  }
@@ -16806,6 +17060,27 @@ class MockSVGElement extends MockElement {
16806
17060
  return 0;
16807
17061
  }
16808
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
+ }
16809
17084
  class MockBaseElement extends MockHTMLElement {
16810
17085
  constructor(ownerDocument) {
16811
17086
  super(ownerDocument, 'base');
@@ -41026,6 +41301,7 @@ const createComponentExport = (cmp) => {
41026
41301
  * using the `dist-custom-elements` output target may have a single 'entry point' for each file containing a component.
41027
41302
  * Each of those files will be independently resolved and loaded by this plugin for further processing by Rollup later
41028
41303
  * in the bundling process.
41304
+ *
41029
41305
  * @param entries the Stencil project files to process. It should be noted that the keys in this object may not
41030
41306
  * necessarily be an absolute or relative path to a file, but may be a Rollup Virtual Module (which begin with \0).
41031
41307
  * @returns the rollup plugin that loads and process a Stencil project's entry points
@@ -41194,9 +41470,9 @@ const fetchUrlSync = (url) => {
41194
41470
  return undefined;
41195
41471
  };
41196
41472
 
41197
- const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41473
+ const patchTsSystemFileSystem = (config, compilerSys, inMemoryFs, tsSys) => {
41198
41474
  const realpath = (path) => {
41199
- const rp = stencilSys.realpathSync(path);
41475
+ const rp = compilerSys.realpathSync(path);
41200
41476
  if (isString$1(rp)) {
41201
41477
  return rp;
41202
41478
  }
@@ -41204,7 +41480,7 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41204
41480
  };
41205
41481
  const getAccessibleFileSystemEntries = (path) => {
41206
41482
  try {
41207
- const entries = stencilSys.readDirSync(path || '.').sort();
41483
+ const entries = compilerSys.readDirSync(path || '.').sort();
41208
41484
  const files = [];
41209
41485
  const directories = [];
41210
41486
  for (const absPath of entries) {
@@ -41229,13 +41505,13 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41229
41505
  }
41230
41506
  };
41231
41507
  tsSys.createDirectory = (p) => {
41232
- stencilSys.createDirSync(p, { recursive: true });
41508
+ compilerSys.createDirSync(p, { recursive: true });
41233
41509
  };
41234
41510
  tsSys.directoryExists = (p) => {
41235
41511
  const s = inMemoryFs.statSync(p);
41236
41512
  return s.isDirectory;
41237
41513
  };
41238
- tsSys.exit = stencilSys.exit;
41514
+ tsSys.exit = compilerSys.exit;
41239
41515
  tsSys.fileExists = (p) => {
41240
41516
  let filePath = p;
41241
41517
  if (isRemoteUrl(p)) {
@@ -41244,17 +41520,17 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41244
41520
  const s = inMemoryFs.statSync(filePath);
41245
41521
  return !!(s && s.isFile);
41246
41522
  };
41247
- tsSys.getCurrentDirectory = stencilSys.getCurrentDirectory;
41248
- tsSys.getExecutingFilePath = stencilSys.getCompilerExecutingPath;
41523
+ tsSys.getCurrentDirectory = compilerSys.getCurrentDirectory;
41524
+ tsSys.getExecutingFilePath = compilerSys.getCompilerExecutingPath;
41249
41525
  tsSys.getDirectories = (p) => {
41250
- const items = stencilSys.readDirSync(p);
41526
+ const items = compilerSys.readDirSync(p);
41251
41527
  return items.filter((itemPath) => {
41252
41528
  const s = inMemoryFs.statSync(itemPath);
41253
41529
  return !!(s && s.exists && s.isDirectory);
41254
41530
  });
41255
41531
  };
41256
41532
  tsSys.readDirectory = (path, extensions, exclude, include, depth) => {
41257
- const cwd = stencilSys.getCurrentDirectory();
41533
+ const cwd = compilerSys.getCurrentDirectory();
41258
41534
  // TODO(STENCIL-344): Replace `matchFiles` with a function that is publicly exposed
41259
41535
  return t.matchFiles(path, extensions, exclude, include, IS_CASE_SENSITIVE_FILE_NAMES, cwd, depth, getAccessibleFileSystemEntries, realpath);
41260
41536
  };
@@ -41281,9 +41557,9 @@ const patchTsSystemFileSystem = (config, stencilSys, inMemoryFs, tsSys) => {
41281
41557
  tsSys.writeFile = (p, data) => inMemoryFs.writeFile(p, data);
41282
41558
  return tsSys;
41283
41559
  };
41284
- const patchTsSystemWatch = (stencilSys, tsSys) => {
41560
+ const patchTsSystemWatch = (compilerSystem, tsSys) => {
41285
41561
  tsSys.watchDirectory = (p, cb, recursive) => {
41286
- const watcher = stencilSys.watchDirectory(p, (filePath) => {
41562
+ const watcher = compilerSystem.watchDirectory(p, (filePath) => {
41287
41563
  cb(filePath);
41288
41564
  }, recursive);
41289
41565
  return {
@@ -41293,7 +41569,7 @@ const patchTsSystemWatch = (stencilSys, tsSys) => {
41293
41569
  };
41294
41570
  };
41295
41571
  tsSys.watchFile = (p, cb) => {
41296
- const watcher = stencilSys.watchFile(p, (filePath, eventKind) => {
41572
+ const watcher = compilerSystem.watchFile(p, (filePath, eventKind) => {
41297
41573
  if (eventKind === 'fileAdd') {
41298
41574
  cb(filePath, t.FileWatcherEventKind.Created);
41299
41575
  }
@@ -55436,6 +55712,7 @@ const addDefineCustomElementFunction = (tagNames, newStatements, caseStatements)
55436
55712
  * ```typescript
55437
55713
  * defineCustomElement(MyPrincipalComponent);
55438
55714
  * ```
55715
+ * @param componentName the component's class name to use as the first argument to `defineCustomElement`
55439
55716
  * @returns the expression statement described above
55440
55717
  */
55441
55718
  function createAutoDefinitionExpression(componentName) {
@@ -55545,6 +55822,9 @@ const updateStencilCoreImports = (updatedCoreImportPath) => {
55545
55822
  };
55546
55823
  };
55547
55824
  };
55825
+ /**
55826
+ * A set of imports which we don't want to remove from an output file
55827
+ */
55548
55828
  const KEEP_IMPORTS = new Set([
55549
55829
  'h',
55550
55830
  'setMode',
@@ -55564,37 +55844,75 @@ const KEEP_IMPORTS = new Set([
55564
55844
  'setErrorHandler',
55565
55845
  ]);
55566
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
+ */
55567
55858
  const outputCustomElements = async (config, compilerCtx, buildCtx) => {
55859
+ var _a;
55568
55860
  if (!config.buildDist) {
55569
55861
  return;
55570
55862
  }
55571
- const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
55863
+ const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
55572
55864
  if (outputTargets.length === 0) {
55573
55865
  return;
55574
55866
  }
55575
55867
  const bundlingEventMessage = 'generate custom elements';
55576
55868
  const timespan = buildCtx.createTimeSpan(`${bundlingEventMessage} started`);
55577
- 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)));
55578
55870
  timespan.finish(`${bundlingEventMessage} finished`);
55579
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
+ */
55580
55913
  const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarget) => {
55581
55914
  try {
55582
- const bundleOpts = {
55583
- id: 'customElements',
55584
- platform: 'client',
55585
- conditionals: getCustomElementsBuildConditionals(config, buildCtx.components),
55586
- customTransformers: getCustomElementCustomTransformer(config, compilerCtx, buildCtx.components, outputTarget),
55587
- externalRuntime: !!outputTarget.externalRuntime,
55588
- inlineWorkers: true,
55589
- inputs: {
55590
- index: '\0core',
55591
- },
55592
- loader: {
55593
- '\0core': generateEntryPoint$1(outputTarget),
55594
- },
55595
- inlineDynamicImports: outputTarget.inlineDynamicImports,
55596
- preserveEntrySignatures: 'allow-extension',
55597
- };
55915
+ const bundleOpts = getBundleOptions(config, buildCtx, compilerCtx, outputTarget);
55598
55916
  addCustomElementInputs(buildCtx, bundleOpts);
55599
55917
  const build = await bundleOutput(config, compilerCtx, buildCtx, bundleOpts);
55600
55918
  if (build) {
@@ -55607,6 +55925,18 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
55607
55925
  hoistTransitiveImports: false,
55608
55926
  preferConst: true,
55609
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
+ }
55610
55940
  const minify = outputTarget.externalRuntime || outputTarget.minify !== true ? false : config.minifyJs;
55611
55941
  const files = rollupOutput.output.map(async (bundle) => {
55612
55942
  if (bundle.type === 'chunk') {
@@ -55621,15 +55951,15 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
55621
55951
  buildCtx.diagnostics.push(...optimizeResults.diagnostics);
55622
55952
  if (!hasError(optimizeResults.diagnostics) && typeof optimizeResults.output === 'string') {
55623
55953
  code = optimizeResults.output;
55624
- sourceMap = optimizeResults.sourceMap;
55625
55954
  }
55626
- if (sourceMap) {
55955
+ if (optimizeResults.sourceMap) {
55956
+ sourceMap = optimizeResults.sourceMap;
55627
55957
  code = code + getSourceMappingUrlForEndOfFile(bundle.fileName);
55628
- 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), {
55629
55959
  outputTargetType: outputTarget.type,
55630
55960
  });
55631
55961
  }
55632
- await compilerCtx.fs.writeFile(join(outputTarget.dir, bundle.fileName), code, {
55962
+ await compilerCtx.fs.writeFile(join(outputTargetDir, bundle.fileName), code, {
55633
55963
  outputTargetType: outputTarget.type,
55634
55964
  });
55635
55965
  }
@@ -55648,6 +55978,8 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
55648
55978
  */
55649
55979
  const addCustomElementInputs = (buildCtx, bundleOpts) => {
55650
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 = [];
55651
55983
  components.forEach((cmp) => {
55652
55984
  const exp = [];
55653
55985
  const exportName = dashToPascalCase$1(cmp.tagName);
@@ -55656,16 +55988,25 @@ const addCustomElementInputs = (buildCtx, bundleOpts) => {
55656
55988
  const coreKey = `\0${exportName}`;
55657
55989
  if (cmp.isPlain) {
55658
55990
  exp.push(`export { ${importName} as ${exportName} } from '${cmp.sourceFilePath}';`);
55991
+ indexImports.push(`export { {${exportName} } from '${coreKey}';`);
55659
55992
  }
55660
55993
  else {
55661
55994
  // the `importName` may collide with the `exportName`, alias it just in case it does with `importAs`
55662
55995
  exp.push(`import { ${importName} as ${importAs}, defineCustomElement as cmpDefCustomEle } from '${cmp.sourceFilePath}';`);
55663
55996
  exp.push(`export const ${exportName} = ${importAs};`);
55664
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}';`);
55665
56005
  }
55666
56006
  bundleOpts.inputs[cmp.tagName] = coreKey;
55667
56007
  bundleOpts.loader[coreKey] = exp.join('\n');
55668
56008
  });
56009
+ bundleOpts.loader['\0core'] += indexImports.join('\n');
55669
56010
  };
55670
56011
  /**
55671
56012
  * Generate the entrypoint (`index.ts` file) contents for the `dist-custom-elements` output target
@@ -55683,6 +56024,7 @@ const generateEntryPoint$1 = (outputTarget) => {
55683
56024
  /**
55684
56025
  * Get the series of custom transformers that will be applied to a Stencil project's source code during the TypeScript
55685
56026
  * transpilation process
56027
+ *
55686
56028
  * @param config the configuration for the Stencil project
55687
56029
  * @param compilerCtx the current compiler context
55688
56030
  * @param components the components that will be compiled as a part of the current build
@@ -56811,9 +57153,15 @@ const addLazyElementGetter = (classMembers, moduleFile, cmp) => {
56811
57153
 
56812
57154
  /**
56813
57155
  * Adds static "style" getter within the class
57156
+ * ```typescript
56814
57157
  * const MyComponent = class {
56815
57158
  * static get style() { return "styles"; }
56816
57159
  * }
57160
+ * ```
57161
+ * @param classMembers a class to existing members of a class. **this parameter will be mutated** rather than returning
57162
+ * a cloned version
57163
+ * @param cmp the metadata associated with the component being evaluated
57164
+ * @param commentOriginalSelector if `true`, add a comment with the original CSS selector to the style.
56817
57165
  */
56818
57166
  const addStaticStyleGetterWithinClass = (classMembers, cmp, commentOriginalSelector) => {
56819
57167
  const styleLiteral = getStyleLiteral(cmp, commentOriginalSelector);
@@ -56823,11 +57171,15 @@ const addStaticStyleGetterWithinClass = (classMembers, cmp, commentOriginalSelec
56823
57171
  };
56824
57172
  /**
56825
57173
  * Adds static "style" property to the class variable.
57174
+ * ```typescript
56826
57175
  * const MyComponent = class {}
56827
57176
  * MyComponent.style = "styles";
57177
+ * ```
57178
+ * @param styleStatements a list of statements containing style assignments to a class
57179
+ * @param cmp the metadata associated with the component being evaluated
56828
57180
  */
56829
- const addStaticStylePropertyToClass = (styleStatements, cmp, commentOriginalSelector) => {
56830
- const styleLiteral = getStyleLiteral(cmp, commentOriginalSelector);
57181
+ const addStaticStylePropertyToClass = (styleStatements, cmp) => {
57182
+ const styleLiteral = getStyleLiteral(cmp, false);
56831
57183
  if (styleLiteral) {
56832
57184
  const statement = t.createStatement(t.createAssignment(t.createPropertyAccess(t.createIdentifier(cmp.componentClassName), 'style'), styleLiteral));
56833
57185
  styleStatements.push(statement);
@@ -57429,7 +57781,7 @@ const updateLazyComponentMembers = (transformOpts, styleStatements, classNode, m
57429
57781
  addWatchers(classMembers, cmp);
57430
57782
  transformHostData(classMembers, moduleFile);
57431
57783
  if (transformOpts.style === 'static') {
57432
- addStaticStylePropertyToClass(styleStatements, cmp, false);
57784
+ addStaticStylePropertyToClass(styleStatements, cmp);
57433
57785
  }
57434
57786
  return classMembers;
57435
57787
  };
@@ -59664,29 +60016,38 @@ const relDts$1 = (fromPath, dtsPath) => {
59664
60016
  * @param config the Stencil configuration associated with the project being compiled
59665
60017
  * @param compilerCtx the current compiler context
59666
60018
  * @param buildCtx the context associated with the current build
59667
- * @param distDtsFilePath the path to a type declaration file (.d.ts) that is being generated for the output target.
59668
- * 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
59669
60020
  */
59670
- const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, distDtsFilePath) => {
59671
- const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
59672
- 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)));
59673
60025
  };
59674
60026
  /**
59675
60027
  * Generates types for a single `dist-custom-elements` output target definition in a Stencil project's configuration
60028
+ *
59676
60029
  * @param config the Stencil configuration associated with the project being compiled
59677
60030
  * @param compilerCtx the current compiler context
59678
60031
  * @param buildCtx the context associated with the current build
59679
- * @param distDtsFilePath the path to a type declaration file (.d.ts) that is being generated for the output target.
59680
- * 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
59681
60033
  * @param outputTarget the output target for which types are being currently generated
59682
60034
  */
59683
- 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
59684
60037
  const customElementsDtsPath = join(outputTarget.dir, 'index.d.ts');
59685
- 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);
59686
60041
  const code = [
59687
60042
  `/* ${config.namespace} custom elements */`,
59688
- ``,
59689
- `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
+ }),
59690
60051
  ``,
59691
60052
  `/**`,
59692
60053
  ` * Used to manually set the base path where assets can be found.`,
@@ -59706,10 +60067,8 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
59706
60067
  ` rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;`,
59707
60068
  `}`,
59708
60069
  `export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;`,
59709
- ``,
59710
- `export type { Components, JSX };`,
59711
- ``,
59712
60070
  ];
60071
+ const componentsDtsRelPath = relDts(outputTarget.dir, join(typesDir, 'components.d.ts'));
59713
60072
  const usersIndexJsPath = join(config.srcDir, 'index.ts');
59714
60073
  const hasUserIndex = await compilerCtx.fs.access(usersIndexJsPath);
59715
60074
  if (hasUserIndex) {
@@ -59722,7 +60081,6 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
59722
60081
  await compilerCtx.fs.writeFile(customElementsDtsPath, code.join('\n') + `\n`, {
59723
60082
  outputTargetType: outputTarget.type,
59724
60083
  });
59725
- const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
59726
60084
  await Promise.all(components.map(async (cmp) => {
59727
60085
  const dtsCode = generateCustomElementType(componentsDtsRelPath, cmp);
59728
60086
  const fileName = `${cmp.tagName}.d.ts`;
@@ -59796,20 +60154,21 @@ const generateTypesOutput = async (config, compilerCtx, buildCtx, outputTarget)
59796
60154
  const srcDtsFiles = srcDirItems.filter((srcItem) => srcItem.isFile && isDtsFile$1(srcItem.absPath));
59797
60155
  // Copy .d.ts files from src to dist
59798
60156
  // In addition, all references to @stencil/core are replaced
59799
- let distDtsFilePath;
59800
- await Promise.all(srcDtsFiles.map(async (srcDtsFile) => {
60157
+ const copiedDTSFilePaths = await Promise.all(srcDtsFiles.map(async (srcDtsFile) => {
59801
60158
  const relPath = relative$1(config.srcDir, srcDtsFile.absPath);
59802
60159
  const distPath = join(outputTarget.typesDir, relPath);
59803
60160
  const originalDtsContent = await compilerCtx.fs.readFile(srcDtsFile.absPath);
59804
60161
  const distDtsContent = updateStencilTypesImports(outputTarget.typesDir, distPath, originalDtsContent);
59805
60162
  await compilerCtx.fs.writeFile(distPath, distDtsContent);
59806
- distDtsFilePath = distPath;
60163
+ return distPath;
59807
60164
  }));
60165
+ const distDtsFilePath = copiedDTSFilePaths.slice(-1)[0];
59808
60166
  const distPath = outputTarget.typesDir;
59809
60167
  await generateAppTypes(config, compilerCtx, buildCtx, distPath);
60168
+ const { typesDir } = outputTarget;
59810
60169
  if (distDtsFilePath) {
59811
- await generateCustomElementsTypes(config, compilerCtx, buildCtx, distDtsFilePath);
59812
60170
  await generateCustomElementsBundleTypes(config, compilerCtx, buildCtx, distDtsFilePath);
60171
+ await generateCustomElementsTypes(config, compilerCtx, buildCtx, typesDir);
59813
60172
  }
59814
60173
  };
59815
60174
 
@@ -62280,7 +62639,7 @@ const getRelativeDts = (config, srcPath, emitDtsPath) => {
62280
62639
  emitDtsPath = join(emitDtsPath, '..');
62281
62640
  srcPath = normalizePath$1(join(srcPath, '..'));
62282
62641
  }
62283
- return join.apply(null, parts.reverse());
62642
+ return join(...parts.reverse());
62284
62643
  };
62285
62644
 
62286
62645
  const outputServiceWorkers = async (config, buildCtx) => {
@@ -62758,9 +63117,16 @@ const createInMemoryFs = (sys) => {
62758
63117
  return data.exists;
62759
63118
  };
62760
63119
  /**
62761
- * Synchronous!!! Do not use!!!
63120
+ * **Synchronous!!! Do not use!!!**
62762
63121
  * (Only typescript transpiling is allowed to use)
62763
- * @param filePath
63122
+ *
63123
+ * Synchronously get information about a file from a provided path. This function will attempt to use an in-memory
63124
+ * cache before performing a blocking read.
63125
+ *
63126
+ * In the event of a cache hit, the content from the cache will be returned and skip the read.
63127
+ *
63128
+ * @param filePath the path to the file to read
63129
+ * @returns `true` if the file exists, `false` otherwise
62764
63130
  */
62765
63131
  const accessSync = (filePath) => {
62766
63132
  const item = getItem(filePath);
@@ -62932,9 +63298,19 @@ const createInMemoryFs = (sys) => {
62932
63298
  return fileText;
62933
63299
  };
62934
63300
  /**
62935
- * Synchronous!!! Do not use!!!
63301
+ * **Synchronous!!! Do not use!!!**
62936
63302
  * (Only typescript transpiling is allowed to use)
62937
- * @param filePath
63303
+ *
63304
+ * Synchronously read a file from a provided path. This function will attempt to use an in-memory cache before
63305
+ * performing a blocking read in the following circumstances:
63306
+ * - no `opts` are provided
63307
+ * - the `useCache` member on `opts` is set to `true`, or is not set
63308
+ *
63309
+ * In the event of a cache hit, the content from the cache will be returned and skip the read.
63310
+ *
63311
+ * @param filePath the path to the file to read
63312
+ * @param opts a configuration to use when reading a file
63313
+ * @returns the contents of the file (read from either disk or the cache).
62938
63314
  */
62939
63315
  const readFileSync = (filePath, opts) => {
62940
63316
  if (opts == null || opts.useCache === true || opts.useCache === undefined) {
@@ -63027,10 +63403,13 @@ const createInMemoryFs = (sys) => {
63027
63403
  };
63028
63404
  };
63029
63405
  /**
63030
- * Synchronous!!! Do not use!!!
63031
- * Always returns an object, does not throw errors.
63406
+ * **Synchronous!!! Do not use!!!**
63032
63407
  * (Only typescript transpiling is allowed to use)
63033
- * @param itemPath
63408
+ *
63409
+ * Searches an in-memory cache for an item at the provided path. Always returns an object, **does not throw errors**.
63410
+ *
63411
+ * @param itemPath the path to the file to read
63412
+ * @returns an object describing the item found at the provided `itemPath`
63034
63413
  */
63035
63414
  const statSync = (itemPath) => {
63036
63415
  const item = getItem(itemPath);
@@ -63584,37 +63963,76 @@ const filesChanged = (buildCtx) => {
63584
63963
  // files changed include updated, added and deleted
63585
63964
  return unique([...buildCtx.filesUpdated, ...buildCtx.filesAdded, ...buildCtx.filesDeleted]).sort();
63586
63965
  };
63587
- const scriptsAdded = (buildCtx) => {
63588
- // collect all the scripts that were added
63589
- return buildCtx.filesAdded
63590
- .filter((f) => {
63591
- return SCRIPT_EXT.some((ext) => f.endsWith(ext.toLowerCase()));
63592
- })
63593
- .map((f) => basename(f));
63594
- };
63595
- const scriptsDeleted = (buildCtx) => {
63596
- // collect all the scripts that were deleted
63597
- return buildCtx.filesDeleted
63598
- .filter((f) => {
63599
- return SCRIPT_EXT.some((ext) => f.endsWith(ext.toLowerCase()));
63600
- })
63601
- .map((f) => basename(f));
63602
- };
63603
- const hasScriptChanges = (buildCtx) => {
63604
- return buildCtx.filesChanged.some((f) => {
63605
- const ext = getExt(f);
63606
- return SCRIPT_EXT.includes(ext);
63607
- });
63608
- };
63609
- const hasStyleChanges = (buildCtx) => {
63610
- return buildCtx.filesChanged.some((f) => {
63611
- const ext = getExt(f);
63612
- return STYLE_EXT.includes(ext);
63613
- });
63614
- };
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
+ */
63615
63981
  const getExt = (filePath) => filePath.split('.').pop().toLowerCase();
63982
+ /**
63983
+ * Script extensions which we want to be able to recognize
63984
+ */
63616
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));
63617
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
+ */
63618
64036
  const hasHtmlChanges = (config, buildCtx) => {
63619
64037
  const anyHtmlChanged = buildCtx.filesChanged.some((f) => f.toLowerCase().endsWith('.html'));
63620
64038
  if (anyHtmlChanged) {
@@ -64541,7 +64959,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
64541
64959
  const dependencies = [
64542
64960
  {
64543
64961
  name: "@stencil/core",
64544
- version: "2.16.0",
64962
+ version: "2.17.0",
64545
64963
  main: "compiler/stencil.js",
64546
64964
  resources: [
64547
64965
  "package.json",
@@ -65919,7 +66337,7 @@ const validateConfig = (userConfig = {}) => {
65919
66337
  setBooleanConfig(config, 'sourceMap', null, typeof config.sourceMap === 'undefined' ? false : config.sourceMap);
65920
66338
  setBooleanConfig(config, 'watch', 'watch', false);
65921
66339
  setBooleanConfig(config, 'buildDocs', 'docs', !config.devMode);
65922
- setBooleanConfig(config, 'buildDist', null, !config.devMode || config.buildEs5);
66340
+ setBooleanConfig(config, 'buildDist', 'esm', !config.devMode || config.buildEs5);
65923
66341
  setBooleanConfig(config, 'profile', 'profile', config.devMode);
65924
66342
  setBooleanConfig(config, 'writeLog', 'log', false);
65925
66343
  setBooleanConfig(config, 'buildAppCore', null, true);
@@ -66139,6 +66557,21 @@ const createDefaultTsConfig = (config) => JSON.stringify({
66139
66557
  const hasSrcDirectoryInclude = (includeProp, src) => Array.isArray(includeProp) && includeProp.includes(src);
66140
66558
  const hasStencilConfigInclude = (includeProp) => Array.isArray(includeProp) && includeProp.includes('stencil.config.ts');
66141
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
+ */
66142
66575
  const loadConfig = async (init = {}) => {
66143
66576
  const results = {
66144
66577
  config: null,
@@ -66210,6 +66643,15 @@ const loadConfig = async (init = {}) => {
66210
66643
  }
66211
66644
  return results;
66212
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
+ */
66213
66655
  const loadConfigFile = async (sys, diagnostics, configPath) => {
66214
66656
  let config = null;
66215
66657
  if (isString$1(configPath)) {
@@ -66229,6 +66671,15 @@ const loadConfigFile = async (sys, diagnostics, configPath) => {
66229
66671
  }
66230
66672
  return config;
66231
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
+ */
66232
66683
  const evaluateConfigFile = async (sys, diagnostics, configFilePath) => {
66233
66684
  let configFileData = null;
66234
66685
  try {
@@ -66253,6 +66704,16 @@ const evaluateConfigFile = async (sys, diagnostics, configFilePath) => {
66253
66704
  }
66254
66705
  return configFileData;
66255
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
+ */
66256
66717
  const transpileTypedConfig = (diagnostics, sourceText, filePath) => {
66257
66718
  // let's transpile an awesome stencil.config.ts file into
66258
66719
  // a boring stencil.config.js file
@@ -66454,6 +66915,10 @@ const convertStaticToMeta = (config, compilerCtx, buildCtx, typeChecker, collect
66454
66915
 
66455
66916
  /**
66456
66917
  * Stand-alone compiling of a single string
66918
+ * @param config the Stencil configuration to use in the compilation process
66919
+ * @param input the string to compile
66920
+ * @param transformOpts a configuration object for how the string is compiled
66921
+ * @returns the results of compiling the provided input string
66457
66922
  */
66458
66923
  const transpileModule = (config, input, transformOpts) => {
66459
66924
  if (!config.logger) {