@stencil/core 2.17.4 → 2.18.1

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 (88) hide show
  1. package/cli/index.cjs +285 -220
  2. package/cli/index.d.ts +1 -0
  3. package/cli/index.js +285 -220
  4. package/cli/package.json +1 -1
  5. package/compiler/lib.dom.d.ts +620 -89
  6. package/compiler/lib.dom.iterable.d.ts +27 -3
  7. package/compiler/lib.es2015.core.d.ts +3 -3
  8. package/compiler/lib.es2015.iterable.d.ts +2 -1
  9. package/compiler/lib.es2015.reflect.d.ts +1 -1
  10. package/compiler/lib.es2020.bigint.d.ts +7 -5
  11. package/compiler/lib.es2020.d.ts +2 -0
  12. package/compiler/lib.es2020.date.d.ts +44 -0
  13. package/compiler/lib.es2020.intl.d.ts +51 -11
  14. package/compiler/lib.es2020.number.d.ts +30 -0
  15. package/compiler/lib.es2021.intl.d.ts +106 -4
  16. package/compiler/lib.es2022.array.d.ts +123 -0
  17. package/compiler/lib.es2022.d.ts +26 -0
  18. package/compiler/lib.es2022.error.d.ts +75 -0
  19. package/compiler/lib.es2022.full.d.ts +25 -0
  20. package/compiler/lib.es2022.intl.d.ts +111 -0
  21. package/compiler/lib.es2022.object.d.ts +28 -0
  22. package/compiler/lib.es2022.string.d.ts +27 -0
  23. package/compiler/lib.es5.d.ts +25 -19
  24. package/compiler/lib.esnext.d.ts +1 -1
  25. package/compiler/lib.esnext.intl.d.ts +4 -1
  26. package/compiler/lib.webworker.d.ts +236 -40
  27. package/compiler/lib.webworker.iterable.d.ts +10 -3
  28. package/compiler/package.json +1 -1
  29. package/compiler/stencil.d.ts +2 -2
  30. package/compiler/stencil.js +47263 -45624
  31. package/compiler/stencil.min.js +2 -2
  32. package/compiler/sys/in-memory-fs.d.ts +218 -0
  33. package/dependencies.json +10 -1
  34. package/dev-server/client/index.d.ts +2 -2
  35. package/dev-server/client/index.js +241 -241
  36. package/dev-server/client/package.json +1 -1
  37. package/dev-server/connector.html +3 -3
  38. package/dev-server/index.d.ts +1 -1
  39. package/dev-server/index.js +2 -2
  40. package/dev-server/package.json +1 -1
  41. package/dev-server/server-process.js +1198 -1167
  42. package/internal/app-data/package.json +1 -1
  43. package/internal/client/css-shim.js +2 -2
  44. package/internal/client/dom.js +1 -1
  45. package/internal/client/index.js +1022 -824
  46. package/internal/client/package.json +1 -1
  47. package/internal/client/patch-browser.js +1 -1
  48. package/internal/client/patch-esm.js +1 -1
  49. package/internal/client/polyfills/css-shim.js +1 -1
  50. package/internal/client/shadow-css.js +1 -1
  51. package/internal/hydrate/index.js +119 -119
  52. package/internal/hydrate/package.json +1 -1
  53. package/internal/hydrate/runner.d.ts +1 -1
  54. package/internal/hydrate/runner.js +100 -100
  55. package/internal/package.json +1 -1
  56. package/internal/stencil-core/index.d.ts +8 -10
  57. package/internal/stencil-private.d.ts +77 -138
  58. package/internal/stencil-public-compiler.d.ts +44 -10
  59. package/internal/stencil-public-runtime.d.ts +15 -4
  60. package/internal/testing/index.js +148 -148
  61. package/internal/testing/package.json +1 -1
  62. package/mock-doc/index.cjs +534 -518
  63. package/mock-doc/index.d.ts +13 -12
  64. package/mock-doc/index.js +534 -518
  65. package/mock-doc/package.json +1 -1
  66. package/package.json +23 -32
  67. package/readme.md +27 -33
  68. package/screenshot/index.d.ts +1 -1
  69. package/screenshot/index.js +13 -13
  70. package/screenshot/package.json +1 -1
  71. package/screenshot/pixel-match.js +983 -849
  72. package/sys/node/glob.js +1 -1
  73. package/sys/node/index.d.ts +2 -0
  74. package/sys/node/index.js +374 -373
  75. package/sys/node/package.json +1 -1
  76. package/sys/node/worker.js +1 -1
  77. package/testing/index.d.ts +6 -6
  78. package/testing/index.js +427 -441
  79. package/testing/jest/jest-config.d.ts +1 -1
  80. package/testing/matchers/index.d.ts +3 -3
  81. package/testing/mock-fetch.d.ts +1 -1
  82. package/testing/mocks.d.ts +2 -2
  83. package/testing/package.json +1 -1
  84. package/testing/puppeteer/puppeteer-element.d.ts +2 -2
  85. package/testing/puppeteer/puppeteer-events.d.ts +1 -1
  86. package/testing/testing-logger.d.ts +1 -1
  87. package/testing/testing-utils.d.ts +5 -4
  88. package/testing/testing.d.ts +1 -1
package/cli/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil CLI (CommonJS) v2.17.4 | MIT Licensed | https://stenciljs.com
2
+ Stencil CLI (CommonJS) v2.18.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  'use strict';
5
5
 
@@ -25,29 +25,6 @@ function _interopNamespace(e) {
25
25
  return Object.freeze(n);
26
26
  }
27
27
 
28
- /**
29
- * This sets the log level hierarchy for our terminal logger, ranging from
30
- * most to least verbose.
31
- *
32
- * Ordering the levels like this lets us easily check whether we should log a
33
- * message at a given time. For instance, if the log level is set to `'warn'`,
34
- * then anything passed to the logger with level `'warn'` or `'error'` should
35
- * be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
36
- *
37
- * If we have a current log level `currentLevel` and a message with level
38
- * `msgLevel` is passed to the logger, we can determine whether or not we should
39
- * log it by checking if the log level on the message is further up or at the
40
- * same level in the hierarchy than `currentLevel`, like so:
41
- *
42
- * ```ts
43
- * LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
44
- * ```
45
- *
46
- * NOTE: for the reasons described above, do not change the order of the entries
47
- * in this array without good reason!
48
- */
49
- const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
50
-
51
28
  /**
52
29
  * Convert a string from PascalCase to dash-case
53
30
  *
@@ -223,18 +200,18 @@ const getEncodedRootLength = (path) => {
223
200
  return 0;
224
201
  const ch0 = path.charCodeAt(0);
225
202
  // POSIX or UNC
226
- if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
203
+ if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) {
227
204
  if (path.charCodeAt(1) !== ch0)
228
205
  return 1; // POSIX: "/" (or non-normalized "\")
229
- const p1 = path.indexOf(ch0 === 47 /* slash */ ? '/' : altDirectorySeparator, 2);
206
+ const p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? '/' : altDirectorySeparator, 2);
230
207
  if (p1 < 0)
231
208
  return path.length; // UNC: "//server" or "\\server"
232
209
  return p1 + 1; // UNC: "//server/" or "\\server\"
233
210
  }
234
211
  // DOS
235
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
212
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) {
236
213
  const ch2 = path.charCodeAt(2);
237
- if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
214
+ if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */)
238
215
  return 3; // DOS: "c:/" or "c:\"
239
216
  if (path.length === 2)
240
217
  return 2; // DOS: "c:" (but not "c:d")
@@ -256,7 +233,7 @@ const getEncodedRootLength = (path) => {
256
233
  isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
257
234
  const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
258
235
  if (volumeSeparatorEnd !== -1) {
259
- if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
236
+ if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) {
260
237
  // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
261
238
  return ~(volumeSeparatorEnd + 1);
262
239
  }
@@ -274,15 +251,15 @@ const getEncodedRootLength = (path) => {
274
251
  // relative
275
252
  return 0;
276
253
  };
277
- const isVolumeCharacter = (charCode) => (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
278
- (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
254
+ const isVolumeCharacter = (charCode) => (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) ||
255
+ (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */);
279
256
  const getFileUrlVolumeSeparatorEnd = (url, start) => {
280
257
  const ch0 = url.charCodeAt(start);
281
- if (ch0 === 58 /* colon */)
258
+ if (ch0 === 58 /* CharacterCodes.colon */)
282
259
  return start + 1;
283
- if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
260
+ if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) {
284
261
  const ch2 = url.charCodeAt(start + 2);
285
- if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
262
+ if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */)
286
263
  return start + 3;
287
264
  }
288
265
  return -1;
@@ -297,6 +274,22 @@ const pathComponents = (path, rootLength) => {
297
274
  return [root, ...rest];
298
275
  };
299
276
 
277
+ /**
278
+ * Check whether a string is a member of a ReadonlyArray<string>
279
+ *
280
+ * We need a little helper for this because unfortunately `includes` is typed
281
+ * on `ReadonlyArray<T>` as `(el: T): boolean` so a `string` cannot be passed
282
+ * to `includes` on a `ReadonlyArray` 😢 thus we have a little helper function
283
+ * where we do the type coercion just once.
284
+ *
285
+ * see microsoft/TypeScript#31018 for some discussion of this
286
+ *
287
+ * @param readOnlyArray the array we're checking
288
+ * @param maybeMember a value which is possibly a member of the array
289
+ * @returns whether the array contains the member or not
290
+ */
291
+ const readOnlyArrayHasStringMember = (readOnlyArray, maybeMember) => readOnlyArray.includes(maybeMember);
292
+
300
293
  /**
301
294
  * Validates that a component tag meets required naming conventions to be used for a web component
302
295
  * @param tag the tag to validate
@@ -341,6 +334,29 @@ const validateComponentTag = (tag) => {
341
334
  return undefined;
342
335
  };
343
336
 
337
+ /**
338
+ * This sets the log level hierarchy for our terminal logger, ranging from
339
+ * most to least verbose.
340
+ *
341
+ * Ordering the levels like this lets us easily check whether we should log a
342
+ * message at a given time. For instance, if the log level is set to `'warn'`,
343
+ * then anything passed to the logger with level `'warn'` or `'error'` should
344
+ * be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
345
+ *
346
+ * If we have a current log level `currentLevel` and a message with level
347
+ * `msgLevel` is passed to the logger, we can determine whether or not we should
348
+ * log it by checking if the log level on the message is further up or at the
349
+ * same level in the hierarchy than `currentLevel`, like so:
350
+ *
351
+ * ```ts
352
+ * LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
353
+ * ```
354
+ *
355
+ * NOTE: for the reasons described above, do not change the order of the entries
356
+ * in this array without good reason!
357
+ */
358
+ const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
359
+
344
360
  /**
345
361
  * All the Boolean options supported by the Stencil CLI
346
362
  */
@@ -818,18 +834,12 @@ const parseEqualsArg = (arg) => {
818
834
  * @param maybeLogLevel the string to check
819
835
  * @returns whether this is a `LogLevel`
820
836
  */
821
- const isLogLevel = (maybeLogLevel) =>
822
- // unfortunately `includes` is typed on `ReadonlyArray<T>` as `(el: T):
823
- // boolean` so a `string` cannot be passed to `includes` on a
824
- // `ReadonlyArray` 😢 thus we `as any`
825
- //
826
- // see microsoft/TypeScript#31018 for some discussion of this
827
- LOG_LEVELS.includes(maybeLogLevel);
837
+ const isLogLevel = (maybeLogLevel) => readOnlyArrayHasStringMember(LOG_LEVELS, maybeLogLevel);
828
838
 
829
839
  const dependencies = [
830
840
  {
831
841
  name: "@stencil/core",
832
- version: "2.17.4",
842
+ version: "2.18.1",
833
843
  main: "compiler/stencil.js",
834
844
  resources: [
835
845
  "package.json",
@@ -871,8 +881,10 @@ const dependencies = [
871
881
  "compiler/lib.es2019.symbol.d.ts",
872
882
  "compiler/lib.es2020.bigint.d.ts",
873
883
  "compiler/lib.es2020.d.ts",
884
+ "compiler/lib.es2020.date.d.ts",
874
885
  "compiler/lib.es2020.full.d.ts",
875
886
  "compiler/lib.es2020.intl.d.ts",
887
+ "compiler/lib.es2020.number.d.ts",
876
888
  "compiler/lib.es2020.promise.d.ts",
877
889
  "compiler/lib.es2020.sharedmemory.d.ts",
878
890
  "compiler/lib.es2020.string.d.ts",
@@ -883,6 +895,13 @@ const dependencies = [
883
895
  "compiler/lib.es2021.promise.d.ts",
884
896
  "compiler/lib.es2021.string.d.ts",
885
897
  "compiler/lib.es2021.weakref.d.ts",
898
+ "compiler/lib.es2022.array.d.ts",
899
+ "compiler/lib.es2022.d.ts",
900
+ "compiler/lib.es2022.error.d.ts",
901
+ "compiler/lib.es2022.full.d.ts",
902
+ "compiler/lib.es2022.intl.d.ts",
903
+ "compiler/lib.es2022.object.d.ts",
904
+ "compiler/lib.es2022.string.d.ts",
886
905
  "compiler/lib.es5.d.ts",
887
906
  "compiler/lib.es6.d.ts",
888
907
  "compiler/lib.esnext.d.ts",
@@ -932,11 +951,107 @@ const dependencies = [
932
951
  },
933
952
  {
934
953
  name: "typescript",
935
- version: "4.5.4",
954
+ version: "4.7.4",
936
955
  main: "lib/typescript.js"
937
956
  }
938
957
  ];
939
958
 
959
+ const IS_NODE_ENV = typeof global !== 'undefined' &&
960
+ typeof require === 'function' &&
961
+ !!global.process &&
962
+ typeof __filename === 'string' &&
963
+ (!global.origin || typeof global.origin !== 'string');
964
+ const IS_BROWSER_ENV = typeof location !== 'undefined' && typeof navigator !== 'undefined' && typeof XMLHttpRequest !== 'undefined';
965
+
966
+ /**
967
+ * Creates an instance of a logger
968
+ * @returns the new logger instance
969
+ */
970
+ const createLogger = () => {
971
+ let useColors = IS_BROWSER_ENV;
972
+ let level = 'info';
973
+ return {
974
+ enableColors: (uc) => (useColors = uc),
975
+ getLevel: () => level,
976
+ setLevel: (l) => (level = l),
977
+ emoji: (e) => e,
978
+ info: console.log.bind(console),
979
+ warn: console.warn.bind(console),
980
+ error: console.error.bind(console),
981
+ debug: console.debug.bind(console),
982
+ red: (msg) => msg,
983
+ green: (msg) => msg,
984
+ yellow: (msg) => msg,
985
+ blue: (msg) => msg,
986
+ magenta: (msg) => msg,
987
+ cyan: (msg) => msg,
988
+ gray: (msg) => msg,
989
+ bold: (msg) => msg,
990
+ dim: (msg) => msg,
991
+ bgRed: (msg) => msg,
992
+ createTimeSpan: (_startMsg, _debug = false) => ({
993
+ duration: () => 0,
994
+ finish: () => 0,
995
+ }),
996
+ printDiagnostics(diagnostics) {
997
+ diagnostics.forEach((diagnostic) => logDiagnostic(diagnostic, useColors));
998
+ },
999
+ };
1000
+ };
1001
+ const logDiagnostic = (diagnostic, useColors) => {
1002
+ let color = BLUE;
1003
+ let prefix = 'Build';
1004
+ let msg = '';
1005
+ if (diagnostic.level === 'error') {
1006
+ color = RED;
1007
+ prefix = 'Error';
1008
+ }
1009
+ else if (diagnostic.level === 'warn') {
1010
+ color = YELLOW;
1011
+ prefix = 'Warning';
1012
+ }
1013
+ if (diagnostic.header) {
1014
+ prefix = diagnostic.header;
1015
+ }
1016
+ const filePath = diagnostic.relFilePath || diagnostic.absFilePath;
1017
+ if (filePath) {
1018
+ msg += filePath;
1019
+ if (typeof diagnostic.lineNumber === 'number' && diagnostic.lineNumber > 0) {
1020
+ msg += ', line ' + diagnostic.lineNumber;
1021
+ if (typeof diagnostic.columnNumber === 'number' && diagnostic.columnNumber > 0) {
1022
+ msg += ', column ' + diagnostic.columnNumber;
1023
+ }
1024
+ }
1025
+ msg += '\n';
1026
+ }
1027
+ msg += diagnostic.messageText;
1028
+ if (diagnostic.lines && diagnostic.lines.length > 0) {
1029
+ diagnostic.lines.forEach((l) => {
1030
+ msg += '\n' + l.lineNumber + ': ' + l.text;
1031
+ });
1032
+ msg += '\n';
1033
+ }
1034
+ if (useColors) {
1035
+ const styledPrefix = [
1036
+ '%c' + prefix,
1037
+ `background: ${color}; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;`,
1038
+ ];
1039
+ console.log(...styledPrefix, msg);
1040
+ }
1041
+ else if (diagnostic.level === 'error') {
1042
+ console.error(msg);
1043
+ }
1044
+ else if (diagnostic.level === 'warn') {
1045
+ console.warn(msg);
1046
+ }
1047
+ else {
1048
+ console.log(msg);
1049
+ }
1050
+ };
1051
+ const YELLOW = `#f39c12`;
1052
+ const RED = `#c0392b`;
1053
+ const BLUE = `#3498db`;
1054
+
940
1055
  /**
941
1056
  * Attempt to find a Stencil configuration file on the file system
942
1057
  * @param opts the options needed to find the configuration file
@@ -945,11 +1060,7 @@ const dependencies = [
945
1060
  const findConfig = async (opts) => {
946
1061
  const sys = opts.sys;
947
1062
  const cwd = sys.getCurrentDirectory();
948
- const results = {
949
- configPath: null,
950
- rootDir: normalizePath(cwd),
951
- diagnostics: [],
952
- };
1063
+ const rootDir = normalizePath(cwd);
953
1064
  let configPath = opts.configPath;
954
1065
  if (isString(configPath)) {
955
1066
  if (!sys.platformPath.isAbsolute(configPath)) {
@@ -964,8 +1075,13 @@ const findConfig = async (opts) => {
964
1075
  }
965
1076
  else {
966
1077
  // nothing was passed in, use the current working directory
967
- configPath = results.rootDir;
1078
+ configPath = rootDir;
968
1079
  }
1080
+ const results = {
1081
+ configPath,
1082
+ rootDir: normalizePath(cwd),
1083
+ diagnostics: [],
1084
+ };
969
1085
  const stat = await sys.stat(configPath);
970
1086
  if (stat.error) {
971
1087
  const diagnostic = buildError(results.diagnostics);
@@ -998,12 +1114,33 @@ const loadCoreCompiler = async (sys) => {
998
1114
  return globalThis.stencil;
999
1115
  };
1000
1116
 
1117
+ /**
1118
+ * Log the name of this package (`@stencil/core`) to an output stream
1119
+ *
1120
+ * The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
1121
+ *
1122
+ * The name of the package may not be logged, by design, for certain `task` types and logging levels
1123
+ *
1124
+ * @param logger the logging entity to use to output the name of the package
1125
+ * @param task the current task
1126
+ */
1001
1127
  const startupLog = (logger, task) => {
1002
1128
  if (task === 'info' || task === 'serve' || task === 'version') {
1003
1129
  return;
1004
1130
  }
1005
1131
  logger.info(logger.cyan(`@stencil/core`));
1006
1132
  };
1133
+ /**
1134
+ * Log this package's version to an output stream
1135
+ *
1136
+ * The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
1137
+ *
1138
+ * The package version may not be logged, by design, for certain `task` types and logging levels
1139
+ *
1140
+ * @param logger the logging entity to use for output
1141
+ * @param task the current task
1142
+ * @param coreCompiler the compiler instance to derive version information from
1143
+ */
1007
1144
  const startupLogVersion = (logger, task, coreCompiler) => {
1008
1145
  if (task === 'info' || task === 'serve' || task === 'version') {
1009
1146
  return;
@@ -1019,11 +1156,25 @@ const startupLogVersion = (logger, task, coreCompiler) => {
1019
1156
  startupMsg += logger.emoji(' ' + coreCompiler.vermoji);
1020
1157
  logger.info(startupMsg);
1021
1158
  };
1159
+ /**
1160
+ * Log details from a {@link CompilerSystem} used by Stencil to an output stream
1161
+ *
1162
+ * The output stream is determined by the {@link Logger} instance that is provided as an argument to this function
1163
+ *
1164
+ * @param sys the `CompilerSystem` to report details on
1165
+ * @param logger the logging entity to use for output
1166
+ * @param flags user set flags for the current invocation of Stencil
1167
+ * @param coreCompiler the compiler instance being used for this invocation of Stencil
1168
+ */
1022
1169
  const loadedCompilerLog = (sys, logger, flags, coreCompiler) => {
1023
1170
  const sysDetails = sys.details;
1024
1171
  const runtimeInfo = `${sys.name} ${sys.version}`;
1025
- const platformInfo = `${sysDetails.platform}, ${sysDetails.cpuModel}`;
1026
- const statsInfo = `cpus: ${sys.hardwareConcurrency}, freemem: ${Math.round(sysDetails.freemem() / 1000000)}MB, totalmem: ${Math.round(sysDetails.totalmem / 1000000)}MB`;
1172
+ const platformInfo = sysDetails
1173
+ ? `${sysDetails.platform}, ${sysDetails.cpuModel}`
1174
+ : `Unknown Platform, Unknown CPU Model`;
1175
+ const statsInfo = sysDetails
1176
+ ? `cpus: ${sys.hardwareConcurrency}, freemem: ${Math.round(sysDetails.freemem() / 1000000)}MB, totalmem: ${Math.round(sysDetails.totalmem / 1000000)}MB`
1177
+ : 'Unknown CPU Core Count, Unknown Memory';
1027
1178
  if (logger.getLevel() === 'debug') {
1028
1179
  logger.debug(runtimeInfo);
1029
1180
  logger.debug(platformInfo);
@@ -1037,6 +1188,14 @@ const loadedCompilerLog = (sys, logger, flags, coreCompiler) => {
1037
1188
  logger.info(statsInfo);
1038
1189
  }
1039
1190
  };
1191
+ /**
1192
+ * Log various warnings to an output stream
1193
+ *
1194
+ * The output stream is determined by the {@link Logger} instance attached to the `config` argument to this function
1195
+ *
1196
+ * @param coreCompiler the compiler instance being used for this invocation of Stencil
1197
+ * @param config a validated configuration object to be used for this run of Stencil
1198
+ */
1040
1199
  const startupCompilerLog = (coreCompiler, config) => {
1041
1200
  if (config.suppressLogs === true) {
1042
1201
  return;
@@ -1058,6 +1217,21 @@ const startupCompilerLog = (coreCompiler, config) => {
1058
1217
  }
1059
1218
  };
1060
1219
 
1220
+ const startCheckVersion = async (config, currentVersion) => {
1221
+ if (config.devMode && !config.flags.ci && !currentVersion.includes('-dev.') && isFunction(config.sys.checkVersion)) {
1222
+ return config.sys.checkVersion(config.logger, currentVersion);
1223
+ }
1224
+ return null;
1225
+ };
1226
+ const printCheckVersionResults = async (versionChecker) => {
1227
+ if (versionChecker) {
1228
+ const checkVersionResults = await versionChecker;
1229
+ if (isFunction(checkVersionResults)) {
1230
+ checkVersionResults();
1231
+ }
1232
+ }
1233
+ };
1234
+
1061
1235
  const taskPrerender = async (coreCompiler, config) => {
1062
1236
  startupCompilerLog(coreCompiler, config);
1063
1237
  const hydrateAppFilePath = config.flags.unknownArgs[0];
@@ -1089,21 +1263,6 @@ const runPrerenderTask = async (coreCompiler, config, hydrateAppFilePath, compon
1089
1263
  return diagnostics;
1090
1264
  };
1091
1265
 
1092
- const startCheckVersion = async (config, currentVersion) => {
1093
- if (config.devMode && !config.flags.ci && !currentVersion.includes('-dev.') && isFunction(config.sys.checkVersion)) {
1094
- return config.sys.checkVersion(config.logger, currentVersion);
1095
- }
1096
- return null;
1097
- };
1098
- const printCheckVersionResults = async (versionChecker) => {
1099
- if (versionChecker) {
1100
- const checkVersionResults = await versionChecker;
1101
- if (isFunction(checkVersionResults)) {
1102
- checkVersionResults();
1103
- }
1104
- }
1105
- };
1106
-
1107
1266
  const taskWatch = async (coreCompiler, config) => {
1108
1267
  let devServer = null;
1109
1268
  let exitCode = 0;
@@ -1150,6 +1309,15 @@ const taskWatch = async (coreCompiler, config) => {
1150
1309
  }
1151
1310
  };
1152
1311
 
1312
+ const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
1313
+ const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
1314
+ const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
1315
+ const DOCS_CUSTOM = 'docs-custom';
1316
+ const DOCS_JSON = 'docs-json';
1317
+ const DOCS_README = 'docs-readme';
1318
+ const DOCS_VSCODE = 'docs-vscode';
1319
+ const WWW = 'www';
1320
+
1153
1321
  const tryFn = async (fn, ...args) => {
1154
1322
  try {
1155
1323
  return await fn(...args);
@@ -1163,7 +1331,7 @@ const isInteractive = (sys, flags, object) => {
1163
1331
  const terminalInfo = object ||
1164
1332
  Object.freeze({
1165
1333
  tty: sys.isTTY() ? true : false,
1166
- ci: ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN'].filter((v) => !!sys.getEnvironmentVar(v)).length > 0 || !!flags.ci,
1334
+ ci: ['CI', 'BUILD_ID', 'BUILD_NUMBER', 'BITBUCKET_COMMIT', 'CODEBUILD_BUILD_ARN'].filter((v) => { var _a; return !!((_a = sys.getEnvironmentVar) === null || _a === void 0 ? void 0 : _a.call(sys, v)); }).length > 0 || !!flags.ci,
1167
1335
  });
1168
1336
  return terminalInfo.tty && !terminalInfo.ci;
1169
1337
  };
@@ -1192,7 +1360,7 @@ async function readJson(sys, path) {
1192
1360
  * @returns true if --debug has been passed, otherwise false
1193
1361
  */
1194
1362
  function hasDebug(flags) {
1195
- return flags.debug;
1363
+ return !!flags.debug;
1196
1364
  }
1197
1365
  /**
1198
1366
  * Does the command have the verbose and debug flags?
@@ -1200,18 +1368,7 @@ function hasDebug(flags) {
1200
1368
  * @returns true if both --debug and --verbose have been passed, otherwise false
1201
1369
  */
1202
1370
  function hasVerbose(flags) {
1203
- return flags.verbose && hasDebug(flags);
1204
- }
1205
-
1206
- /**
1207
- * Used to determine if tracking should occur.
1208
- * @param config The config passed into the Stencil command
1209
- * @param sys The system where the command is invoked
1210
- * @param ci whether or not the process is running in a Continuous Integration (CI) environment
1211
- * @returns true if telemetry should be sent, false otherwise
1212
- */
1213
- async function shouldTrack(config, sys, ci) {
1214
- return !ci && isInteractive(sys, config.flags) && (await checkTelemetry(sys));
1371
+ return !!flags.verbose && hasDebug(flags);
1215
1372
  }
1216
1373
 
1217
1374
  const isTest$1 = () => process.env.JEST_WORKER_ID !== undefined;
@@ -1232,7 +1389,7 @@ async function readConfig(sys) {
1232
1389
  };
1233
1390
  await writeConfig(sys, config);
1234
1391
  }
1235
- else if (!UUID_REGEX.test(config['tokens.telemetry'])) {
1392
+ else if (!config['tokens.telemetry'] || !UUID_REGEX.test(config['tokens.telemetry'])) {
1236
1393
  const newUuid = uuidv4();
1237
1394
  await writeConfig(sys, { ...config, 'tokens.telemetry': newUuid });
1238
1395
  config['tokens.telemetry'] = newUuid;
@@ -1268,14 +1425,16 @@ async function updateConfig(sys, newOptions) {
1268
1425
  return await writeConfig(sys, Object.assign(config, newOptions));
1269
1426
  }
1270
1427
 
1271
- const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
1272
- const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE;
1273
- const DIST_HYDRATE_SCRIPT = 'dist-hydrate-script';
1274
- const DOCS_CUSTOM = 'docs-custom';
1275
- const DOCS_JSON = 'docs-json';
1276
- const DOCS_README = 'docs-readme';
1277
- const DOCS_VSCODE = 'docs-vscode';
1278
- const WWW = 'www';
1428
+ /**
1429
+ * Used to determine if tracking should occur.
1430
+ * @param config The config passed into the Stencil command
1431
+ * @param sys The system where the command is invoked
1432
+ * @param ci whether or not the process is running in a Continuous Integration (CI) environment
1433
+ * @returns true if telemetry should be sent, false otherwise
1434
+ */
1435
+ async function shouldTrack(config, sys, ci) {
1436
+ return !ci && isInteractive(sys, config.flags) && (await checkTelemetry(sys));
1437
+ }
1279
1438
 
1280
1439
  /**
1281
1440
  * Used to within taskBuild to provide the component_count property.
@@ -1286,11 +1445,11 @@ const WWW = 'www';
1286
1445
  * @param result The results of a compiler build.
1287
1446
  */
1288
1447
  async function telemetryBuildFinishedAction(sys, config, coreCompiler, result) {
1289
- const tracking = await shouldTrack(config, sys, config.flags.ci);
1448
+ const tracking = await shouldTrack(config, sys, !!config.flags.ci);
1290
1449
  if (!tracking) {
1291
1450
  return;
1292
1451
  }
1293
- const component_count = Object.keys(result.componentGraph).length;
1452
+ const component_count = result.componentGraph ? Object.keys(result.componentGraph).length : undefined;
1294
1453
  const data = await prepareData(coreCompiler, config, sys, result.duration, component_count);
1295
1454
  await sendMetric(sys, config, 'stencil_cli_command', data);
1296
1455
  config.logger.debug(`${config.logger.blue('Telemetry')}: ${config.logger.gray(JSON.stringify(data))}`);
@@ -1369,15 +1528,16 @@ function getActiveTargets(config) {
1369
1528
  * @returns a Promise wrapping data for the telemetry endpoint
1370
1529
  */
1371
1530
  const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
1531
+ var _a, _b, _c;
1372
1532
  const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
1373
1533
  const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
1374
1534
  const targets = getActiveTargets(config);
1375
1535
  const yarn = isUsingYarn(sys);
1376
1536
  const stencil = coreCompiler.version || 'unknown';
1377
1537
  const system = `${sys.name} ${sys.version}`;
1378
- const os_name = sys.details.platform;
1379
- const os_version = sys.details.release;
1380
- const cpu_model = sys.details.cpuModel;
1538
+ const os_name = (_a = sys.details) === null || _a === void 0 ? void 0 : _a.platform;
1539
+ const os_version = (_b = sys.details) === null || _b === void 0 ? void 0 : _b.release;
1540
+ const cpu_model = (_c = sys.details) === null || _c === void 0 ? void 0 : _c.cpuModel;
1381
1541
  const build = coreCompiler.buildId || 'unknown';
1382
1542
  const has_app_pwa_config = hasAppTarget(config);
1383
1543
  const anonymizedConfig = anonymizeConfigForTelemetry(config);
@@ -1707,13 +1867,6 @@ const taskDocs = async (coreCompiler, config) => {
1707
1867
  await compiler.destroy();
1708
1868
  };
1709
1869
 
1710
- const IS_NODE_ENV = typeof global !== 'undefined' &&
1711
- typeof require === 'function' &&
1712
- !!global.process &&
1713
- typeof __filename === 'string' &&
1714
- (!global.origin || typeof global.origin !== 'string');
1715
- const IS_BROWSER_ENV = typeof location !== 'undefined' && typeof navigator !== 'undefined' && typeof XMLHttpRequest !== 'undefined';
1716
-
1717
1870
  /**
1718
1871
  * Task to generate component boilerplate and write it to disk. This task can
1719
1872
  * cause the program to exit with an error under various circumstances, such as
@@ -1974,7 +2127,7 @@ const taskTelemetry = async (flags, sys, logger) => {
1974
2127
  const prompt = logger.dim(sys.details.platform === 'windows' ? '>' : '$');
1975
2128
  const isEnabling = flags.args.includes('on');
1976
2129
  const isDisabling = flags.args.includes('off');
1977
- const INFORMATION = `Opt in or our of telemetry. Information about the data we collect is available on our website: ${logger.bold('https://stenciljs.com/telemetry')}`;
2130
+ const INFORMATION = `Opt in or out of telemetry. Information about the data we collect is available on our website: ${logger.bold('https://stenciljs.com/telemetry')}`;
1978
2131
  const THANK_YOU = `Thank you for helping to make Stencil better! 💖`;
1979
2132
  const ENABLED_MESSAGE = `${logger.green('Enabled')}. ${THANK_YOU}\n\n`;
1980
2133
  const DISABLED_MESSAGE = `${logger.red('Disabled')}\n\n`;
@@ -2105,32 +2258,32 @@ const taskTest = async (config) => {
2105
2258
  config.logger.error(`"test" command is currently only implemented for a NodeJS environment`);
2106
2259
  return config.sys.exit(1);
2107
2260
  }
2108
- try {
2109
- config.buildDocs = false;
2110
- const testingRunOpts = {
2111
- e2e: !!config.flags.e2e,
2112
- screenshot: !!config.flags.screenshot,
2113
- spec: !!config.flags.spec,
2114
- updateScreenshot: !!config.flags.updateScreenshot,
2115
- };
2116
- // always ensure we have jest modules installed
2117
- const ensureModuleIds = ['@types/jest', 'jest', 'jest-cli'];
2118
- if (testingRunOpts.e2e) {
2119
- // if it's an e2e test, also make sure we're got
2120
- // puppeteer modules installed and if browserExecutablePath is provided don't download Chromium use only puppeteer-core instead
2121
- const puppeteer = config.testing.browserExecutablePath ? 'puppeteer-core' : 'puppeteer';
2122
- ensureModuleIds.push(puppeteer);
2123
- if (testingRunOpts.screenshot) {
2124
- // ensure we've got pixelmatch for screenshots
2125
- config.logger.warn(config.logger.yellow(`EXPERIMENTAL: screenshot visual diff testing is currently under heavy development and has not reached a stable status. However, any assistance testing would be appreciated.`));
2126
- }
2127
- }
2128
- // ensure we've got the required modules installed
2129
- const diagnostics = await config.sys.lazyRequire.ensure(config.rootDir, ensureModuleIds);
2130
- if (diagnostics.length > 0) {
2131
- config.logger.printDiagnostics(diagnostics);
2132
- return config.sys.exit(1);
2261
+ config.buildDocs = false;
2262
+ const testingRunOpts = {
2263
+ e2e: !!config.flags.e2e,
2264
+ screenshot: !!config.flags.screenshot,
2265
+ spec: !!config.flags.spec,
2266
+ updateScreenshot: !!config.flags.updateScreenshot,
2267
+ };
2268
+ // always ensure we have jest modules installed
2269
+ const ensureModuleIds = ['@types/jest', 'jest', 'jest-cli'];
2270
+ if (testingRunOpts.e2e) {
2271
+ // if it's an e2e test, also make sure we're got
2272
+ // puppeteer modules installed and if browserExecutablePath is provided don't download Chromium use only puppeteer-core instead
2273
+ const puppeteer = config.testing.browserExecutablePath ? 'puppeteer-core' : 'puppeteer';
2274
+ ensureModuleIds.push(puppeteer);
2275
+ if (testingRunOpts.screenshot) {
2276
+ // ensure we've got pixelmatch for screenshots
2277
+ config.logger.warn(config.logger.yellow(`EXPERIMENTAL: screenshot visual diff testing is currently under heavy development and has not reached a stable status. However, any assistance testing would be appreciated.`));
2133
2278
  }
2279
+ }
2280
+ // ensure we've got the required modules installed
2281
+ const diagnostics = await config.sys.lazyRequire.ensure(config.rootDir, ensureModuleIds);
2282
+ if (diagnostics.length > 0) {
2283
+ config.logger.printDiagnostics(diagnostics);
2284
+ return config.sys.exit(1);
2285
+ }
2286
+ try {
2134
2287
  // let's test!
2135
2288
  const { createTesting } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('../testing/index.js')); });
2136
2289
  const testing = await createTesting(config);
@@ -2146,95 +2299,6 @@ const taskTest = async (config) => {
2146
2299
  }
2147
2300
  };
2148
2301
 
2149
- /**
2150
- * Creates an instance of a logger
2151
- * @returns the new logger instance
2152
- */
2153
- const createLogger = () => {
2154
- let useColors = IS_BROWSER_ENV;
2155
- let level = 'info';
2156
- return {
2157
- enableColors: (uc) => (useColors = uc),
2158
- getLevel: () => level,
2159
- setLevel: (l) => (level = l),
2160
- emoji: (e) => e,
2161
- info: console.log.bind(console),
2162
- warn: console.warn.bind(console),
2163
- error: console.error.bind(console),
2164
- debug: console.debug.bind(console),
2165
- red: (msg) => msg,
2166
- green: (msg) => msg,
2167
- yellow: (msg) => msg,
2168
- blue: (msg) => msg,
2169
- magenta: (msg) => msg,
2170
- cyan: (msg) => msg,
2171
- gray: (msg) => msg,
2172
- bold: (msg) => msg,
2173
- dim: (msg) => msg,
2174
- bgRed: (msg) => msg,
2175
- createTimeSpan: (_startMsg, _debug = false) => ({
2176
- duration: () => 0,
2177
- finish: () => 0,
2178
- }),
2179
- printDiagnostics(diagnostics) {
2180
- diagnostics.forEach((diagnostic) => logDiagnostic(diagnostic, useColors));
2181
- },
2182
- };
2183
- };
2184
- const logDiagnostic = (diagnostic, useColors) => {
2185
- let color = BLUE;
2186
- let prefix = 'Build';
2187
- let msg = '';
2188
- if (diagnostic.level === 'error') {
2189
- color = RED;
2190
- prefix = 'Error';
2191
- }
2192
- else if (diagnostic.level === 'warn') {
2193
- color = YELLOW;
2194
- prefix = 'Warning';
2195
- }
2196
- if (diagnostic.header) {
2197
- prefix = diagnostic.header;
2198
- }
2199
- const filePath = diagnostic.relFilePath || diagnostic.absFilePath;
2200
- if (filePath) {
2201
- msg += filePath;
2202
- if (typeof diagnostic.lineNumber === 'number' && diagnostic.lineNumber > 0) {
2203
- msg += ', line ' + diagnostic.lineNumber;
2204
- if (typeof diagnostic.columnNumber === 'number' && diagnostic.columnNumber > 0) {
2205
- msg += ', column ' + diagnostic.columnNumber;
2206
- }
2207
- }
2208
- msg += '\n';
2209
- }
2210
- msg += diagnostic.messageText;
2211
- if (diagnostic.lines && diagnostic.lines.length > 0) {
2212
- diagnostic.lines.forEach((l) => {
2213
- msg += '\n' + l.lineNumber + ': ' + l.text;
2214
- });
2215
- msg += '\n';
2216
- }
2217
- if (useColors) {
2218
- const styledPrefix = [
2219
- '%c' + prefix,
2220
- `background: ${color}; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;`,
2221
- ];
2222
- console.log(...styledPrefix, msg);
2223
- }
2224
- else if (diagnostic.level === 'error') {
2225
- console.error(msg);
2226
- }
2227
- else if (diagnostic.level === 'warn') {
2228
- console.warn(msg);
2229
- }
2230
- else {
2231
- console.log(msg);
2232
- }
2233
- };
2234
- const YELLOW = `#f39c12`;
2235
- const RED = `#c0392b`;
2236
- const BLUE = `#3498db`;
2237
-
2238
2302
  const run = async (init) => {
2239
2303
  const { args, logger, sys } = init;
2240
2304
  try {
@@ -2249,7 +2313,7 @@ const run = async (init) => {
2249
2313
  if (isFunction(sys.applyGlobalPatch)) {
2250
2314
  sys.applyGlobalPatch(sys.getCurrentDirectory());
2251
2315
  }
2252
- if (task === 'help' || flags.help) {
2316
+ if (!task || task === 'help' || flags.help) {
2253
2317
  await taskHelp(createConfigFlags({ task: 'help', args }), logger, sys);
2254
2318
  return;
2255
2319
  }
@@ -2318,15 +2382,16 @@ const run = async (init) => {
2318
2382
  * @public
2319
2383
  */
2320
2384
  const runTask = async (coreCompiler, config, task, sys) => {
2321
- var _a, _b, _c, _d, _e;
2385
+ var _a, _b, _c, _d, _e, _f;
2322
2386
  const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
2323
2387
  const strictConfig = {
2324
2388
  ...config,
2325
2389
  flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
2326
2390
  logger,
2327
2391
  outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
2328
- sys: (_d = sys !== null && sys !== void 0 ? sys : config.sys) !== null && _d !== void 0 ? _d : coreCompiler.createSystem({ logger }),
2329
- testing: (_e = config.testing) !== null && _e !== void 0 ? _e : {},
2392
+ rootDir: (_d = config.rootDir) !== null && _d !== void 0 ? _d : '/',
2393
+ sys: (_e = sys !== null && sys !== void 0 ? sys : config.sys) !== null && _e !== void 0 ? _e : coreCompiler.createSystem({ logger }),
2394
+ testing: (_f = config.testing) !== null && _f !== void 0 ? _f : {},
2330
2395
  };
2331
2396
  switch (task) {
2332
2397
  case 'build':