@stencil/core 2.17.0 → 2.17.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 (49) hide show
  1. package/cli/config-flags.d.ts +102 -0
  2. package/cli/index.cjs +603 -220
  3. package/cli/index.d.ts +2 -1
  4. package/cli/index.js +603 -220
  5. package/cli/package.json +1 -1
  6. package/compiler/package.json +1 -1
  7. package/compiler/stencil.js +337 -174
  8. package/compiler/stencil.min.js +2 -2
  9. package/dependencies.json +1 -1
  10. package/dev-server/client/index.js +1 -1
  11. package/dev-server/client/package.json +1 -1
  12. package/dev-server/connector.html +2 -2
  13. package/dev-server/index.js +1 -1
  14. package/dev-server/package.json +1 -1
  15. package/dev-server/server-process.js +2 -2
  16. package/internal/app-data/package.json +1 -1
  17. package/internal/client/css-shim.js +1 -1
  18. package/internal/client/dom.js +1 -1
  19. package/internal/client/index.js +11 -6
  20. package/internal/client/package.json +1 -1
  21. package/internal/client/patch-browser.js +1 -1
  22. package/internal/client/patch-esm.js +1 -1
  23. package/internal/client/shadow-css.js +1 -1
  24. package/internal/hydrate/index.js +2 -2
  25. package/internal/hydrate/package.json +1 -1
  26. package/internal/package.json +1 -1
  27. package/internal/stencil-private.d.ts +2 -2
  28. package/internal/stencil-public-compiler.d.ts +67 -48
  29. package/internal/testing/index.js +1 -1
  30. package/internal/testing/package.json +1 -1
  31. package/mock-doc/index.cjs +1 -1
  32. package/mock-doc/index.js +1 -1
  33. package/mock-doc/package.json +1 -1
  34. package/package.json +2 -1
  35. package/screenshot/package.json +1 -1
  36. package/sys/node/index.js +4 -4
  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 +40 -24
  41. package/testing/jest/jest-config.d.ts +1 -1
  42. package/testing/jest/jest-runner.d.ts +3 -2
  43. package/testing/jest/jest-screenshot.d.ts +1 -1
  44. package/testing/mocks.d.ts +27 -2
  45. package/testing/package.json +1 -1
  46. package/testing/puppeteer/puppeteer-browser.d.ts +2 -2
  47. package/testing/test/testing-utils.spec.d.ts +1 -0
  48. package/testing/testing-utils.d.ts +74 -2
  49. package/testing/testing.d.ts +2 -2
@@ -1,5 +1,6 @@
1
1
  import type { JsonDocs } from './stencil-public-docs';
2
2
  import type { PrerenderUrlResults } from '../internal';
3
+ import type { ConfigFlags } from '../cli/config-flags';
3
4
  export * from './stencil-public-docs';
4
5
  /**
5
6
  * https://stenciljs.com/docs/config/
@@ -356,6 +357,29 @@ declare type Loose<T extends Object> = Record<string, any> & Partial<T>;
356
357
  * and have type information carry though as we construct an object which is a valid `Config`.
357
358
  */
358
359
  export declare type UnvalidatedConfig = Loose<Config>;
360
+ /**
361
+ * Helper type to strip optional markers from keys in a type, while preserving other type information for the key.
362
+ * This type takes a union of keys, K, in type T to allow for the type T to be gradually updated.
363
+ *
364
+ * ```typescript
365
+ * type Foo { bar?: number, baz?: string }
366
+ * type ReqFieldFoo = RequireFields<Foo, 'bar'>; // { bar: number, baz?: string }
367
+ * ```
368
+ */
369
+ declare type RequireFields<T, K extends keyof T> = T & {
370
+ [P in K]-?: T[P];
371
+ };
372
+ /**
373
+ * Fields in {@link Config} to make required for {@link ValidatedConfig}
374
+ */
375
+ declare type StrictConfigFields = 'flags' | 'logger';
376
+ /**
377
+ * A version of {@link Config} that makes certain fields required. This type represents a valid configuration entity.
378
+ * When a configuration is received by the user, it is a bag of unverified data. In order to make stricter guarantees
379
+ * about the data from a type-safety perspective, this type is intended to be used throughout the codebase once
380
+ * validations have occurred at runtime.
381
+ */
382
+ export declare type ValidatedConfig = RequireFields<Config, StrictConfigFields>;
359
383
  export interface HydratedFlag {
360
384
  /**
361
385
  * Defaults to `hydrated`.
@@ -505,51 +529,6 @@ export interface DevServerEditor {
505
529
  supported?: boolean;
506
530
  priority?: number;
507
531
  }
508
- export interface ConfigFlags {
509
- task?: TaskCommand;
510
- args?: string[];
511
- knownArgs?: string[];
512
- unknownArgs?: string[];
513
- address?: string;
514
- build?: boolean;
515
- cache?: boolean;
516
- checkVersion?: boolean;
517
- ci?: boolean;
518
- compare?: boolean;
519
- config?: string;
520
- debug?: boolean;
521
- dev?: boolean;
522
- docs?: boolean;
523
- docsApi?: string;
524
- docsJson?: string;
525
- e2e?: boolean;
526
- emulate?: string;
527
- es5?: boolean;
528
- esm?: boolean;
529
- headless?: boolean;
530
- help?: boolean;
531
- log?: boolean;
532
- logLevel?: LogLevel;
533
- verbose?: boolean;
534
- maxWorkers?: number;
535
- open?: boolean;
536
- port?: number;
537
- prerender?: boolean;
538
- prod?: boolean;
539
- profile?: boolean;
540
- root?: string;
541
- screenshot?: boolean;
542
- screenshotConnector?: string;
543
- serve?: boolean;
544
- serviceWorker?: boolean;
545
- spec?: boolean;
546
- ssr?: boolean;
547
- stats?: boolean;
548
- updateScreenshot?: boolean;
549
- version?: boolean;
550
- watch?: boolean;
551
- devtools?: boolean;
552
- }
553
532
  export declare type TaskCommand = 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'prerender' | 'serve' | 'telemetry' | 'test' | 'version';
554
533
  export declare type PageReloadStrategy = 'hmr' | 'pageReload' | null;
555
534
  /**
@@ -1653,7 +1632,29 @@ export interface EmulateViewport {
1653
1632
  */
1654
1633
  isLandscape?: boolean;
1655
1634
  }
1656
- export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
1635
+ /**
1636
+ * This sets the log level hierarchy for our terminal logger, ranging from
1637
+ * most to least verbose.
1638
+ *
1639
+ * Ordering the levels like this lets us easily check whether we should log a
1640
+ * message at a given time. For instance, if the log level is set to `'warn'`,
1641
+ * then anything passed to the logger with level `'warn'` or `'error'` should
1642
+ * be logged, but we should _not_ log anything with level `'info'` or `'debug'`.
1643
+ *
1644
+ * If we have a current log level `currentLevel` and a message with level
1645
+ * `msgLevel` is passed to the logger, we can determine whether or not we should
1646
+ * log it by checking if the log level on the message is further up or at the
1647
+ * same level in the hierarchy than `currentLevel`, like so:
1648
+ *
1649
+ * ```ts
1650
+ * LOG_LEVELS.indexOf(msgLevel) >= LOG_LEVELS.indexOf(currentLevel)
1651
+ * ```
1652
+ *
1653
+ * NOTE: for the reasons described above, do not change the order of the entries
1654
+ * in this array without good reason!
1655
+ */
1656
+ export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
1657
+ export declare type LogLevel = typeof LOG_LEVELS[number];
1657
1658
  /**
1658
1659
  * Common logger to be used by the compiler, dev-server and CLI. The CLI will use a
1659
1660
  * NodeJS based console logging and colors, and the web will use browser based
@@ -1980,7 +1981,7 @@ export interface LoadConfigInit {
1980
1981
  * operations around the codebase.
1981
1982
  */
1982
1983
  export interface LoadConfigResults {
1983
- config: UnvalidatedConfig;
1984
+ config: ValidatedConfig;
1984
1985
  diagnostics: Diagnostic[];
1985
1986
  tsconfig: {
1986
1987
  path: string;
@@ -2048,14 +2049,32 @@ export interface PrerenderResults {
2048
2049
  duration: number;
2049
2050
  average: number;
2050
2051
  }
2052
+ /**
2053
+ * Input for CSS optimization functions, including the input CSS
2054
+ * string and a few boolean options which turn on or off various
2055
+ * optimizations.
2056
+ */
2051
2057
  export interface OptimizeCssInput {
2052
2058
  input: string;
2053
2059
  filePath?: string;
2054
- autoprefixer?: any;
2060
+ autoprefixer?: boolean | null | AutoprefixerOptions;
2055
2061
  minify?: boolean;
2056
2062
  sourceMap?: boolean;
2057
2063
  resolveUrl?: (url: string) => Promise<string> | string;
2058
2064
  }
2065
+ /**
2066
+ * This is not a real interface describing the options which can
2067
+ * be passed to autoprefixer, for that see the docs, here:
2068
+ * https://github.com/postcss/autoprefixer#options
2069
+ *
2070
+ * Instead, this basically just serves as a label type to track
2071
+ * that arguments are being passed consistently.
2072
+ */
2073
+ export declare type AutoprefixerOptions = Object;
2074
+ /**
2075
+ * Output from CSS optimization functions, wrapping up optimized
2076
+ * CSS and any diagnostics produced during optimization.
2077
+ */
2059
2078
  export interface OptimizeCssOutput {
2060
2079
  output: string;
2061
2080
  diagnostics: Diagnostic[];
@@ -1089,5 +1089,5 @@ exports.setMode = e => modeResolutionChain.push(e), exports.setPlatformHelpers =
1089
1089
  }), 100));
1090
1090
  }));
1091
1091
  }, exports.stopAutoApplyChanges = stopAutoApplyChanges, exports.styles = styles,
1092
- exports.supportsConstructibleStylesheets = !1, exports.supportsListenerOptions = !0,
1092
+ exports.supportsConstructableStylesheets = !1, exports.supportsListenerOptions = !0,
1093
1093
  exports.win = win, exports.writeTask = writeTask;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/internal/testing",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "Stencil internal testing platform to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
5
5
  "main": "./index.js",
6
6
  "private": true
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Mock Doc (CommonJS) v2.17.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Mock Doc (CommonJS) v2.17.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  var mockDoc = (function(exports) {
5
5
  'use strict';
package/mock-doc/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Mock Doc v2.17.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Mock Doc v2.17.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  const CONTENT_REF_ID = 'r';
5
5
  const ORG_LOCATION_ID = 'o';
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/mock-doc",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "Mock window, document and DOM outside of a browser environment.",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "license": "MIT",
5
5
  "main": "./internal/stencil-core/index.cjs",
6
6
  "module": "./internal/stencil-core/index.js",
@@ -98,6 +98,7 @@
98
98
  "dts-bundle-generator": "~5.3.0",
99
99
  "eslint": "^8.13.0",
100
100
  "eslint-config-prettier": "^8.5.0",
101
+ "eslint-plugin-jest": "^26.5.3",
101
102
  "eslint-plugin-jsdoc": "^39.3.1",
102
103
  "execa": "4.1.0",
103
104
  "exit": "^0.1.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/screenshot",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "Stencil Screenshot.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
package/sys/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Node System v2.17.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Node System v2.17.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  function _interopDefaultLegacy(e) {
5
5
  return e && "object" == typeof e && "default" in e ? e : {
@@ -274,7 +274,7 @@ Object.defineProperty(exports, "__esModule", {
274
274
  value: !0
275
275
  });
276
276
 
277
- const fs = require("./graceful-fs.js"), path = require("path"), require$$1 = require("util"), glob = require("./glob.js"), require$$6 = require("os"), require$$3 = require("crypto"), require$$2 = require("fs"), require$$4 = require("stream"), require$$5 = require("assert"), require$$7 = require("events"), require$$8 = require("buffer"), require$$9 = require("tty"), cp = require("child_process"), fs__default = _interopDefaultLegacy(fs), path__default = _interopDefaultLegacy(path), require$$1__default = _interopDefaultLegacy(require$$1), glob__default = _interopDefaultLegacy(glob), require$$6__default = _interopDefaultLegacy(require$$6), require$$6__namespace = _interopNamespace(require$$6), require$$3__default = _interopDefaultLegacy(require$$3), require$$2__default = _interopDefaultLegacy(require$$2), require$$4__default = _interopDefaultLegacy(require$$4), require$$5__default = _interopDefaultLegacy(require$$5), require$$7__default = _interopDefaultLegacy(require$$7), require$$8__default = _interopDefaultLegacy(require$$8), require$$9__default = _interopDefaultLegacy(require$$9), cp__namespace = _interopNamespace(cp);
277
+ const fs = require("./graceful-fs.js"), path = require("path"), require$$1 = require("util"), glob = require("./glob.js"), require$$6 = require("os"), require$$3 = require("crypto"), require$$2 = require("fs"), require$$4 = require("stream"), require$$5 = require("assert"), require$$7 = require("events"), require$$8 = require("buffer"), require$$9 = require("tty"), cp = require("child_process"), fs__default = _interopDefaultLegacy(fs), path__default = _interopDefaultLegacy(path), require$$1__default = _interopDefaultLegacy(require$$1), glob__default = _interopDefaultLegacy(glob), require$$6__default = _interopDefaultLegacy(require$$6), require$$6__namespace = _interopNamespace(require$$6), require$$3__default = _interopDefaultLegacy(require$$3), require$$2__default = _interopDefaultLegacy(require$$2), require$$4__default = _interopDefaultLegacy(require$$4), require$$5__default = _interopDefaultLegacy(require$$5), require$$7__default = _interopDefaultLegacy(require$$7), require$$8__default = _interopDefaultLegacy(require$$8), require$$9__default = _interopDefaultLegacy(require$$9), cp__namespace = _interopNamespace(cp), LOG_LEVELS = [ "debug", "info", "warn", "error" ];
278
278
 
279
279
  symbols = createCommonjsModule((function(e) {
280
280
  const t = "Hyper" === process.env.TERM_PROGRAM, r = "win32" === process.platform, n = "linux" === process.platform, i = {
@@ -607,7 +607,7 @@ const createTerminalLogger = e => {
607
607
  red: ansiColors.red,
608
608
  yellow: ansiColors.yellow
609
609
  };
610
- }, LOG_LEVELS = [ "debug", "info", "warn", "error" ], shouldLog = (e, t) => LOG_LEVELS.indexOf(t) >= LOG_LEVELS.indexOf(e), formatPrefixTimestamp = () => {
610
+ }, shouldLog = (e, t) => LOG_LEVELS.indexOf(t) >= LOG_LEVELS.indexOf(e), formatPrefixTimestamp = () => {
611
611
  const e = new Date;
612
612
  return `[${clampTwoDigits(e.getMinutes())}:${clampTwoDigits(e.getSeconds())}.${Math.floor(e.getMilliseconds() / 1e3 * 10)}]`;
613
613
  }, clampTwoDigits = e => ("0" + e.toString()).slice(-2), wordWrap = (e, t) => {
@@ -5632,7 +5632,7 @@ exports.createNodeLogger = e => {
5632
5632
  getColumns: () => {
5633
5633
  var t, r;
5634
5634
  const n = null !== (r = null === (t = null == e ? void 0 : e.stdout) || void 0 === t ? void 0 : t.columns) && void 0 !== r ? r : 80;
5635
- return Math.max(Math.min(120, n), 60);
5635
+ return Math.max(Math.min(n, 120), 60);
5636
5636
  },
5637
5637
  memoryUsage: () => e.memoryUsage().rss,
5638
5638
  relativePath: (e, t) => path__default.default.relative(e, t),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/sys/node",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "Stencil Node System.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Node System Worker v2.17.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Node System Worker v2.17.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  function _interopNamespace(e) {
5
5
  if (e && e.__esModule) return e;
@@ -3,7 +3,7 @@ export { createTesting } from './testing';
3
3
  export { createTestRunner } from './jest/jest-runner';
4
4
  export { jestPreprocessor } from './jest/jest-preprocessor';
5
5
  export { jestSetupTestFramework } from './jest/jest-setup-test-framework';
6
- export { mockBuildCtx, mockConfig, mockCompilerCtx, mockDocument, mockLogger, mockCompilerSystem, mockWindow, mockModule, } from './mocks';
6
+ export { mockBuildCtx, mockConfig, mockCompilerCtx, mockDocument, mockLoadConfigInit, mockValidatedConfig, mockLogger, mockCompilerSystem, mockWindow, mockModule, } from './mocks';
7
7
  export { MockHeaders, MockRequest, MockRequestInit, MockRequestInfo, MockResponse, MockResponseInit, mockFetch, } from './mock-fetch';
8
8
  export { newSpecPage } from './spec-page';
9
9
  export { shuffleArray } from './testing-utils';
package/testing/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Testing v2.17.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Testing v2.17.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  function _lazyRequire(e) {
5
5
  return new Proxy({}, {
@@ -817,6 +817,10 @@ function mockCompilerCtx(e) {
817
817
  }), t;
818
818
  }
819
819
 
820
+ function mockLogger() {
821
+ return new TestingLogger;
822
+ }
823
+
820
824
  function findRootComponent(e, t) {
821
825
  if (null != t) {
822
826
  const r = t.children, s = r.length;
@@ -2162,15 +2166,14 @@ const YELLOW = "#f39c12", RED = "#c0392b", BLUE = "#3498db", COMMON_DIR_MODULE_E
2162
2166
  let o = s.shift();
2163
2167
  o.startsWith("@") && (o += "/" + s.shift());
2164
2168
  const i = s.join("/");
2165
- if ("@stencil/core" === o) {
2166
- return ((e, t) => {
2167
- let r = (t = normalizePath(t)).split("/");
2168
- const s = r.lastIndexOf("node_modules");
2169
- return s > -1 && s < r.length - 1 && (r = r.slice(s + 1), r = r[0].startsWith("@") ? r.slice(2) : r.slice(1),
2170
- t = r.join("/")), new URL("./" + t, (e => new URL("../", e).href)(e)).href;
2171
- })(e.getCompilerExecutingPath(), i);
2172
- }
2173
- return e.getRemoteModuleUrl({
2169
+ return "@stencil/core" === o ? ((e, t) => {
2170
+ let r = (t = normalizePath(t)).split("/");
2171
+ const s = r.lastIndexOf("node_modules");
2172
+ s > -1 && s < r.length - 1 && (r = r.slice(s + 1), r = r[0].startsWith("@") ? r.slice(2) : r.slice(1),
2173
+ t = r.join("/"));
2174
+ const n = new URL("../", e).href;
2175
+ return new URL("./" + t, n).href;
2176
+ })(e.getCompilerExecutingPath(), i) : e.getRemoteModuleUrl({
2174
2177
  moduleId: o,
2175
2178
  version: t.get(o),
2176
2179
  path: i
@@ -2182,7 +2185,7 @@ const YELLOW = "#f39c12", RED = "#c0392b", BLUE = "#3498db", COMMON_DIR_MODULE_E
2182
2185
  const r = e.split("/"), s = r[r.length - 2], n = r[r.length - 1];
2183
2186
  return !("node_modules" !== s || !isCommonDirModuleFile(n));
2184
2187
  })(n) || known404Urls.has(s) || (e => knownUrlSkips.some((t => e.endsWith(t))))(s))) try {
2185
- const o = await ((e, t, r) => (console.trace(t), e && isFunction(e.fetch) ? e.fetch(t, r) : fetch(t, r)))(e, s);
2188
+ const o = await ((e, t, r) => e && isFunction(e.fetch) ? e.fetch(t, r) : fetch(t, r))(e, s);
2186
2189
  if (o) {
2187
2190
  if (o.ok) {
2188
2191
  const i = await o.clone().text();
@@ -2890,7 +2893,7 @@ const createSystem = e => {
2890
2893
  u("/");
2891
2894
  const S = {
2892
2895
  name: "in-memory",
2893
- version: "2.17.0",
2896
+ version: "2.17.1",
2894
2897
  events: i,
2895
2898
  access: async e => c(e),
2896
2899
  accessSync: c,
@@ -3647,8 +3650,8 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
3647
3650
  }, exports.createTesting = async e => {
3648
3651
  e = function t(e) {
3649
3652
  return e.buildEs5 = !1, e.devMode = !0, e.minifyCss = !1, e.minifyJs = !1, e.hashFileNames = !1,
3650
- e.validateTypes = !1, e._isTesting = !0, e.buildDist = !0, e.flags = e.flags || {},
3651
- e.flags.serve = !1, e.flags.open = !1, e.outputTargets.forEach((e => {
3653
+ e.validateTypes = !1, e._isTesting = !0, e.buildDist = !0, e.flags.serve = !1, e.flags.open = !1,
3654
+ e.outputTargets.forEach((e => {
3652
3655
  "www" === e.type && (e.serviceWorker = null);
3653
3656
  })), e.flags.args.includes("--watchAll") && (e.watch = !0), e;
3654
3657
  }(e);
@@ -3786,9 +3789,14 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
3786
3789
  return createTestingSystem();
3787
3790
  }, exports.mockConfig = mockConfig, exports.mockDocument = function mockDocument(e = null) {
3788
3791
  return new index_cjs.MockWindow(e).document;
3789
- }, exports.mockFetch = mockFetch, exports.mockLogger = function mockLogger() {
3790
- return new TestingLogger;
3791
- }, exports.mockModule = (e = {}) => ({
3792
+ }, exports.mockFetch = mockFetch, exports.mockLoadConfigInit = e => ({
3793
+ config: {},
3794
+ configPath: void 0,
3795
+ initTsConfig: !0,
3796
+ logger: void 0,
3797
+ sys: void 0,
3798
+ ...e
3799
+ }), exports.mockLogger = mockLogger, exports.mockModule = (e = {}) => ({
3792
3800
  cmps: [],
3793
3801
  coreRuntimeApis: [],
3794
3802
  collectionName: "",
@@ -3822,7 +3830,13 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
3822
3830
  hasVdomText: !1,
3823
3831
  hasVdomXlink: !1,
3824
3832
  ...e
3825
- }), exports.mockWindow = function mockWindow(e = null) {
3833
+ }), exports.mockValidatedConfig = function mockValidatedConfig(e) {
3834
+ return {
3835
+ ...mockConfig(e),
3836
+ flags: {},
3837
+ logger: mockLogger()
3838
+ };
3839
+ }, exports.mockWindow = function mockWindow(e = null) {
3826
3840
  return new index_cjs.MockWindow(e);
3827
3841
  }, exports.newE2EPage = async function newE2EPage(e = {}) {
3828
3842
  if (!global.__NEW_TEST_PAGE__) throw new Error("newE2EPage() is only available from E2E tests, and ran with the --e2e cmd line flag.");
@@ -3925,26 +3939,28 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
3925
3939
  };
3926
3940
  const o = !0 === e.failOnConsoleError, i = !0 === e.failOnNetworkError;
3927
3941
  t.on("console", (e => {
3928
- "error" === e.type() && (r.push({
3942
+ if ("error" === e.type() && (r.push({
3929
3943
  type: "error",
3930
3944
  message: e.text(),
3931
3945
  location: e.location().url
3932
- }), o && fail(new Error(serializeConsoleMessage(e)))), function t(e) {
3946
+ }), o)) throw new Error(serializeConsoleMessage(e));
3947
+ !function t(e) {
3933
3948
  const t = serializeConsoleMessage(e), r = e.type(), s = "warning" === r ? "warn" : r;
3934
3949
  "debug" !== s && ("function" == typeof console[s] ? console[s](t) : console.log(r, t));
3935
3950
  }(e);
3936
3951
  })), t.on("pageerror", (e => {
3937
- r.push({
3952
+ throw r.push({
3938
3953
  type: "pageerror",
3939
3954
  message: e.message,
3940
3955
  location: e.stack
3941
- }), fail(e);
3956
+ }), e;
3942
3957
  })), t.on("requestfailed", (e => {
3943
- r.push({
3958
+ if (r.push({
3944
3959
  type: "requestfailed",
3945
3960
  message: e.failure().errorText,
3946
3961
  location: e.url()
3947
- }), i ? fail(new Error(e.failure().errorText)) : console.error("requestfailed", e.url());
3962
+ }), i) throw new Error(e.failure().errorText);
3963
+ console.error("requestfailed", e.url());
3948
3964
  })), "string" == typeof e.html ? await e2eSetContent(t, e.html, {
3949
3965
  waitUntil: e.waitUntil
3950
3966
  }) : "string" == typeof e.url ? await e2eGoTo(t, e.url, {
@@ -5,7 +5,7 @@ import type { Config } from '@jest/types';
5
5
  * @param config the Stencil config to use while generating Jest CLI arguments
6
6
  * @returns the arguments to pass to the Jest CLI, wrapped in an object
7
7
  */
8
- export declare function buildJestArgv(config: d.Config): Config.Argv;
8
+ export declare function buildJestArgv(config: d.ValidatedConfig): Config.Argv;
9
9
  /**
10
10
  * Generate a Jest run configuration to be used as a part of the `argv` passed to the Jest CLI when it is invoked
11
11
  * programmatically
@@ -1,9 +1,10 @@
1
1
  import type * as d from '@stencil/core/internal';
2
- export declare function runJest(config: d.Config, env: d.E2EProcessEnv): Promise<boolean>;
2
+ import type { ConfigFlags } from '../../cli/config-flags';
3
+ export declare function runJest(config: d.ValidatedConfig, env: d.E2EProcessEnv): Promise<boolean>;
3
4
  /**
4
5
  * Creates a Stencil test runner
5
6
  * @returns the test runner
6
7
  */
7
8
  export declare function createTestRunner(): any;
8
9
  export declare function includeTestFile(testPath: string, env: d.E2EProcessEnv): boolean;
9
- export declare function getEmulateConfigs(testing: d.TestingConfig, flags: d.ConfigFlags): d.EmulateConfig[];
10
+ export declare function getEmulateConfigs(testing: d.TestingConfig, flags: ConfigFlags): d.EmulateConfig[];
@@ -1,2 +1,2 @@
1
1
  import type * as d from '@stencil/core/internal';
2
- export declare function runJestScreenshot(config: d.Config, env: d.E2EProcessEnv): Promise<boolean>;
2
+ export declare function runJestScreenshot(config: d.ValidatedConfig, env: d.E2EProcessEnv): Promise<boolean>;
@@ -1,7 +1,32 @@
1
- import type { BuildCtx, Cache, CompilerCtx, CompilerSystem, Config, Module } from '@stencil/core/internal';
1
+ import type { BuildCtx, Cache, CompilerCtx, CompilerSystem, Config, LoadConfigInit, ValidatedConfig, Module, UnvalidatedConfig } from '@stencil/core/internal';
2
2
  import { TestingSystem } from './testing-sys';
3
3
  import { TestingLogger } from './testing-logger';
4
- export declare function mockConfig(sys?: CompilerSystem): Config;
4
+ /**
5
+ * Creates a mock instance of an internal, validated Stencil configuration object
6
+ * @param sys an optional compiler system to associate with the config. If one is not provided, one will be created for
7
+ * the caller
8
+ * @returns the mock Stencil configuration
9
+ */
10
+ export declare function mockValidatedConfig(sys?: CompilerSystem): ValidatedConfig;
11
+ /**
12
+ * Creates a mock instance of a Stencil configuration entity. The mocked configuration has no guarantees around the
13
+ * types/validity of its data.
14
+ * @param sys an optional compiler system to associate with the config. If one is not provided, one will be created for
15
+ * the caller
16
+ * @returns the mock Stencil configuration
17
+ */
18
+ export declare function mockConfig(sys?: CompilerSystem): UnvalidatedConfig;
19
+ /**
20
+ * Creates a configuration object used to bootstrap a Stencil task invocation
21
+ *
22
+ * Several fields are intentionally undefined for this entity. While it would be trivial to stub them out, this mock
23
+ * generation function operates under the assumption that entities like loggers and compiler system abstractions will
24
+ * be shared by multiple entities in a test suite, who should provide those entities to this function
25
+ *
26
+ * @param overrides the properties on the default entity to manually override
27
+ * @returns the default configuration initialization object, with any overrides applied
28
+ */
29
+ export declare const mockLoadConfigInit: (overrides?: Partial<LoadConfigInit>) => LoadConfigInit;
5
30
  export declare function mockCompilerCtx(config?: Config): CompilerCtx;
6
31
  export declare function mockBuildCtx(config?: Config, compilerCtx?: CompilerCtx): BuildCtx;
7
32
  export declare function mockCache(config?: Config, compilerCtx?: CompilerCtx): Cache;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/testing",
3
- "version": "2.17.0",
3
+ "version": "2.17.1",
4
4
  "description": "Stencil testing suite.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -1,6 +1,6 @@
1
- import type { Config } from '@stencil/core/internal';
1
+ import type { ValidatedConfig } from '@stencil/core/internal';
2
2
  import type * as puppeteer from 'puppeteer';
3
- export declare function startPuppeteerBrowser(config: Config): Promise<puppeteer.Browser>;
3
+ export declare function startPuppeteerBrowser(config: ValidatedConfig): Promise<puppeteer.Browser>;
4
4
  export declare function connectBrowser(): Promise<any>;
5
5
  export declare function disconnectBrowser(browser: puppeteer.Browser): Promise<void>;
6
6
  export declare function newBrowserPage(browser: puppeteer.Browser): Promise<puppeteer.Page>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,78 @@
1
+ /// <reference types="jest" />
1
2
  import type * as d from '@stencil/core/internal';
2
3
  export declare function shuffleArray(array: any[]): any[];
3
- export declare function expectFiles(fs: d.InMemoryFileSystem, filePaths: string[]): void;
4
- export declare function doNotExpectFiles(fs: d.InMemoryFileSystem, filePaths: string[]): void;
4
+ /**
5
+ * Testing utility to validate the existence of some provided file paths using a specific file system
6
+ *
7
+ * @param fs the file system to use to validate the existence of some files
8
+ * @param filePaths the paths to validate
9
+ * @throws when one or more of the provided file paths cannot be found
10
+ */
11
+ export declare function expectFilesExist(fs: d.InMemoryFileSystem, filePaths: string[]): void;
12
+ /**
13
+ * Testing utility to validate the non-existence of some provided file paths using a specific file system
14
+ *
15
+ * @param fs the file system to use to validate the non-existence of some files
16
+ * @param filePaths the paths to validate
17
+ * @throws when one or more of the provided file paths is found
18
+ */
19
+ export declare function expectFilesDoNotExist(fs: d.InMemoryFileSystem, filePaths: string[]): void;
5
20
  export declare function getAppScriptUrl(config: d.Config, browserUrl: string): string;
6
21
  export declare function getAppStyleUrl(config: d.Config, browserUrl: string): string;
22
+ /**
23
+ * Utility for silencing `console` functions in tests.
24
+ *
25
+ * When this function is first called it grabs a reference to the `log`,
26
+ * `error`, and `warn` functions on `console` and then returns a per-test setup
27
+ * function which sets up a fresh set of mocks (via `jest.fn()`) and then
28
+ * assigns them to each of these functions. This setup function will return a
29
+ * reference to each of the three mock functions so tests can make assertions
30
+ * about their calls and so on.
31
+ *
32
+ * Because references to the original `.log`, `.error`, and `.warn` functions
33
+ * exist in closure within the function, it can use an `afterAll` call to clean
34
+ * up after itself and ensure that the original implementations are restored
35
+ * after the test suite finishes.
36
+ *
37
+ * An example of using this to silence log statements in a single test could look
38
+ * like this:
39
+ *
40
+ * ```ts
41
+ * describe("my-test-suite", () => {
42
+ * const setupConsoleMocks = setupConsoleMocker()
43
+ *
44
+ * it("should log a message", () => {
45
+ * const { logMock } = setupConsoleMocks();
46
+ * myFunctionWhichLogs(foo, bar);
47
+ * expect(logMock).toBeCalledWith('my log message');
48
+ * })
49
+ * })
50
+ * ```
51
+ *
52
+ * @returns a per-test mock setup function
53
+ */
54
+ export declare function setupConsoleMocker(): ConsoleMocker;
55
+ interface ConsoleMocker {
56
+ (): {
57
+ logMock: jest.Mock<typeof console.log>;
58
+ warnMock: jest.Mock<typeof console.warn>;
59
+ errorMock: jest.Mock<typeof console.error>;
60
+ };
61
+ }
62
+ /**
63
+ * the callback that `withSilentWarn` expects to receive. Basically receives a mock
64
+ * as its argument and returns a `Promise`, the value of which is returns by `withSilentWarn`
65
+ * as well.
66
+ */
67
+ declare type SilentWarnFunc<T> = (mock: jest.Mock<typeof console.warn>) => Promise<T>;
68
+ /**
69
+ * Wrap a single callback with a silent `console.warn`. The callback passed in
70
+ * receives the mocking function as an argument, so you can easily make assertions
71
+ * that it is called if necessary.
72
+ *
73
+ * @param cb a callback which `withSilentWarn` will call after replacing `console.warn`
74
+ * with a mock.
75
+ * @returns a Promise wrapping the return value of the callback
76
+ */
77
+ export declare function withSilentWarn<T>(cb: SilentWarnFunc<T>): Promise<T>;
78
+ export {};
@@ -1,2 +1,2 @@
1
- import type { Config, Testing } from '@stencil/core/internal';
2
- export declare const createTesting: (config: Config) => Promise<Testing>;
1
+ import type { ValidatedConfig, Testing } from '@stencil/core/internal';
2
+ export declare const createTesting: (config: ValidatedConfig) => Promise<Testing>;