@stencil/core 2.11.0 → 2.12.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.
package/sys/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Node System v2.11.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Node System v2.12.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  function _interopDefaultLegacy(e) {
5
5
  return e && "object" == typeof e && "default" in e ? e : {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/sys/node",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
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.11.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Node System Worker v2.12.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  function _interopNamespace(e) {
5
5
  if (e && e.__esModule) return e;
package/testing/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Testing v2.11.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Testing v2.12.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  function _lazyRequire(e) {
5
5
  return new Proxy({}, {
@@ -205,6 +205,64 @@ function formatDiagnostic(e) {
205
205
  t;
206
206
  }
207
207
 
208
+ function getCompilerOptions(e) {
209
+ if (_tsCompilerOptions) return _tsCompilerOptions;
210
+ if ("string" != typeof e) return null;
211
+ e = normalizePath(e);
212
+ const t = stencil_js.ts.findConfigFile(e, stencil_js.ts.sys.fileExists);
213
+ if (!t) return null;
214
+ const r = stencil_js.ts.readConfigFile(t, stencil_js.ts.sys.readFile);
215
+ if (r.error) throw new Error(formatDiagnostic((e => {
216
+ const t = {
217
+ level: "warn",
218
+ type: "typescript",
219
+ language: "typescript",
220
+ header: "TypeScript",
221
+ code: e.code.toString(),
222
+ messageText: flattenDiagnosticMessageText(e, e.messageText),
223
+ relFilePath: null,
224
+ absFilePath: null,
225
+ lines: []
226
+ };
227
+ if (1 === e.category && (t.level = "error"), e.file) {
228
+ t.absFilePath = e.file.fileName;
229
+ const s = "string" != typeof (r = e.file.text) ? [] : (r = r.replace(/\\r/g, "\n")).split("\n"), n = e.file.getLineAndCharacterOfPosition(e.start), i = {
230
+ lineIndex: n.line,
231
+ lineNumber: n.line + 1,
232
+ text: s[n.line],
233
+ errorCharStart: n.character,
234
+ errorLength: Math.max(e.length, 1)
235
+ };
236
+ if (t.lineNumber = i.lineNumber, t.columnNumber = i.errorCharStart + 1, t.lines.push(i),
237
+ 0 === i.errorLength && i.errorCharStart > 0 && (i.errorLength = 1, i.errorCharStart--),
238
+ i.lineIndex > 0) {
239
+ const e = {
240
+ lineIndex: i.lineIndex - 1,
241
+ lineNumber: i.lineNumber - 1,
242
+ text: s[i.lineIndex - 1],
243
+ errorCharStart: -1,
244
+ errorLength: -1
245
+ };
246
+ t.lines.unshift(e);
247
+ }
248
+ if (i.lineIndex + 1 < s.length) {
249
+ const e = {
250
+ lineIndex: i.lineIndex + 1,
251
+ lineNumber: i.lineNumber + 1,
252
+ text: s[i.lineIndex + 1],
253
+ errorCharStart: -1,
254
+ errorLength: -1
255
+ };
256
+ t.lines.push(e);
257
+ }
258
+ }
259
+ var r;
260
+ return t;
261
+ })(r.error)));
262
+ const s = stencil_js.ts.parseJsonConfigFileContent(r.config, stencil_js.ts.sys, e, void 0, t);
263
+ return _tsCompilerOptions = s.options, _tsCompilerOptions;
264
+ }
265
+
208
266
  function compareHtml(e, t, r) {
209
267
  if (null == e) throw new Error(`expect toEqualHtml() value is "${e}"`);
210
268
  if ("function" == typeof e.then) throw new Error("element must be a resolved value, not a promise, before it can be tested");
@@ -1235,9 +1293,13 @@ const path$2 = require("path"), index_js = _lazyRequire("../dev-server/index.js"
1235
1293
  if (!r.includes(t.code) && (n = t.messageText, isIterable(t.next))) for (const r of t.next) n += flattenDiagnosticMessageText(e, r);
1236
1294
  return s && (n = n.replace("type 'StencilConfig'", "Stencil Config"), n = n.replace("Object literal may only specify known properties, but ", ""),
1237
1295
  n = n.replace("Object literal may only specify known properties, and ", "")), n.trim();
1238
- }, isOutputTargetDistLazy = e => e.type === DIST_LAZY, isOutputTargetWww = e => e.type === WWW, DIST_LAZY = "dist-lazy", WWW = "www", jestPreprocessor = {
1239
- process(e, t, r) {
1240
- if (function s(e, t) {
1296
+ }, isOutputTargetDistLazy = e => e.type === DIST_LAZY, isOutputTargetWww = e => e.type === WWW, DIST_LAZY = "dist-lazy", WWW = "www", isJest27TransformOptions = e => "object" == typeof e && e.hasOwnProperty("config");
1297
+
1298
+ let _tsCompilerOptions = null, _tsCompilerOptionsKey = null;
1299
+
1300
+ const jestPreprocessor = {
1301
+ process(e, t, r, s) {
1302
+ if (isJest27TransformOptions(r) && (s = r.config), function n(e, t) {
1241
1303
  const r = e.split(".").pop().toLowerCase().split("?")[0];
1242
1304
  if ("ts" === r || "tsx" === r || "jsx" === r) return !0;
1243
1305
  if ("mjs" === r) return !0;
@@ -1247,12 +1309,12 @@ const path$2 = require("path"), index_js = _lazyRequire("../dev-server/index.js"
1247
1309
  }
1248
1310
  return "css" === r;
1249
1311
  }(t, e)) {
1250
- const s = {
1312
+ const r = {
1251
1313
  file: t,
1252
- currentDirectory: r.rootDir
1253
- }, n = this.getCompilerOptions(r.rootDir);
1254
- n && (n.baseUrl && (s.baseUrl = n.baseUrl), n.paths && (s.paths = n.paths));
1255
- const i = transpile(e, s), o = i.diagnostics.some((e => "error" === e.level));
1314
+ currentDirectory: s.rootDir
1315
+ }, n = getCompilerOptions(s.rootDir);
1316
+ n && (n.baseUrl && (r.baseUrl = n.baseUrl), n.paths && (r.paths = n.paths));
1317
+ const i = transpile(e, r), o = i.diagnostics.some((e => "error" === e.level));
1256
1318
  if (i.diagnostics && o) {
1257
1319
  const e = i.diagnostics.map(formatDiagnostic).join("\n\n");
1258
1320
  throw new Error(e);
@@ -1261,69 +1323,12 @@ const path$2 = require("path"), index_js = _lazyRequire("../dev-server/index.js"
1261
1323
  }
1262
1324
  return e;
1263
1325
  },
1264
- getCompilerOptions(e) {
1265
- return this._tsCompilerOptions || (this._tsCompilerOptions = function t(e) {
1266
- if ("string" != typeof e) return null;
1267
- e = normalizePath(e);
1268
- const t = stencil_js.ts.findConfigFile(e, stencil_js.ts.sys.fileExists);
1269
- if (!t) return null;
1270
- const r = stencil_js.ts.readConfigFile(t, stencil_js.ts.sys.readFile);
1271
- if (r.error) throw new Error(formatDiagnostic((e => {
1272
- const t = {
1273
- level: "warn",
1274
- type: "typescript",
1275
- language: "typescript",
1276
- header: "TypeScript",
1277
- code: e.code.toString(),
1278
- messageText: flattenDiagnosticMessageText(e, e.messageText),
1279
- relFilePath: null,
1280
- absFilePath: null,
1281
- lines: []
1282
- };
1283
- if (1 === e.category && (t.level = "error"), e.file) {
1284
- t.absFilePath = e.file.fileName;
1285
- const s = "string" != typeof (r = e.file.text) ? [] : (r = r.replace(/\\r/g, "\n")).split("\n"), n = e.file.getLineAndCharacterOfPosition(e.start), i = {
1286
- lineIndex: n.line,
1287
- lineNumber: n.line + 1,
1288
- text: s[n.line],
1289
- errorCharStart: n.character,
1290
- errorLength: Math.max(e.length, 1)
1291
- };
1292
- if (t.lineNumber = i.lineNumber, t.columnNumber = i.errorCharStart + 1, t.lines.push(i),
1293
- 0 === i.errorLength && i.errorCharStart > 0 && (i.errorLength = 1, i.errorCharStart--),
1294
- i.lineIndex > 0) {
1295
- const e = {
1296
- lineIndex: i.lineIndex - 1,
1297
- lineNumber: i.lineNumber - 1,
1298
- text: s[i.lineIndex - 1],
1299
- errorCharStart: -1,
1300
- errorLength: -1
1301
- };
1302
- t.lines.unshift(e);
1303
- }
1304
- if (i.lineIndex + 1 < s.length) {
1305
- const e = {
1306
- lineIndex: i.lineIndex + 1,
1307
- lineNumber: i.lineNumber + 1,
1308
- text: s[i.lineIndex + 1],
1309
- errorCharStart: -1,
1310
- errorLength: -1
1311
- };
1312
- t.lines.push(e);
1313
- }
1314
- }
1315
- var r;
1316
- return t;
1317
- })(r.error)));
1318
- return stencil_js.ts.parseJsonConfigFileContent(r.config, stencil_js.ts.sys, e, void 0, t).options;
1319
- }(e)), this._tsCompilerOptions;
1320
- },
1321
1326
  getCacheKey(e, t, r, s) {
1322
- if (!this._tsCompilerOptionsKey) {
1323
- const e = this.getCompilerOptions(s.rootDir);
1324
- this._tsCompilerOptionsKey = JSON.stringify(e);
1327
+ if (isJest27TransformOptions(r) && (s = r.config), !_tsCompilerOptionsKey) {
1328
+ const e = getCompilerOptions(s.rootDir);
1329
+ _tsCompilerOptionsKey = JSON.stringify(e);
1325
1330
  }
1326
- return [ process.version, this._tsCompilerOptionsKey, e, t, r, !!s.instrument, 6 ].join(":");
1331
+ return [ process.version, _tsCompilerOptionsKey, e, t, r, !!s.instrument, 7 ].join(":");
1327
1332
  }
1328
1333
  }, deepEqual = function e(t, r) {
1329
1334
  var s, n, i, o, a, l, c, u, d, h;
@@ -2858,7 +2863,7 @@ const createSystem = e => {
2858
2863
  u("/");
2859
2864
  const S = {
2860
2865
  name: "in-memory",
2861
- version: "2.11.0",
2866
+ version: "2.12.0",
2862
2867
  events: o,
2863
2868
  access: async e => c(e),
2864
2869
  accessSync: c,
@@ -3592,6 +3597,9 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
3592
3597
  } catch (e) {}
3593
3598
  }(this.browser), this.browser = null;
3594
3599
  }
3600
+ getVmContext() {
3601
+ return super.getVmContext();
3602
+ }
3595
3603
  };
3596
3604
  }, exports.createTestRunner = function createTestRunner() {
3597
3605
  const e = require("jest-runner");
@@ -9,6 +9,7 @@ export declare function createJestPuppeteerEnvironment(): {
9
9
  newPuppeteerPage(): Promise<import("puppeteer").Page>;
10
10
  closeOpenPages(): Promise<void>;
11
11
  teardown(): Promise<void>;
12
+ getVmContext(): any;
12
13
  };
13
14
  [x: string]: any;
14
15
  };
@@ -1,11 +1,59 @@
1
+ declare type Jest26CacheKeyOptions = {
2
+ instrument: boolean;
3
+ rootDir: string;
4
+ };
5
+ declare type Jest26Config = {
6
+ instrument: boolean;
7
+ rootDir: string;
8
+ };
9
+ declare type Jest27TransformOptions = {
10
+ config: Jest26Config;
11
+ };
1
12
  export declare const jestPreprocessor: {
2
- process(sourceText: string, filePath: string, jestConfig: {
3
- rootDir: string;
4
- }): string;
5
- getCompilerOptions(rootDir: string): any;
6
- getCacheKey(code: string, filePath: string, jestConfigStr: string, transformOptions: {
7
- instrument: boolean;
8
- rootDir: string;
9
- }): string;
13
+ /**
14
+ * Transforms a file to CommonJS to be used by Jest. The API for `process` is described in the
15
+ * ["Writing custom transformers"](https://jestjs.io/docs/code-transformation#writing-custom-transformers)
16
+ * documentation on the jest site. Unfortunately, the URL is not versioned at the time of this writing. For
17
+ * reference, the v27.2 docs were referenced (the most recent available).
18
+ *
19
+ * This function attempts to support several versions of Jest (v23 through v27). Support for earlier versions of Jest
20
+ * will be removed in a future major version of Stencil.
21
+ *
22
+ * @param sourceText the contents of the source file
23
+ * @param sourcePath the path to the source file
24
+ * @param jestConfig the jest configuration when called by Jest 26 and lower. This parameter is folded into
25
+ * `transformOptions` when called by Jest 27+ as a top level `config` property. Calls to this function from Jest 27+
26
+ * will have a `Jest27TransformOptions` shape
27
+ * @param transformOptions an object containing the various transformation options. In Jest 27+ this parameter occurs
28
+ * third in this function signature (and no fourth parameter is formally accepted)
29
+ * @returns the transformed file contents if the file should be transformed. returns the original source otherwise
30
+ */
31
+ process(sourceText: string, sourcePath: string, jestConfig: Jest26Config | Jest27TransformOptions, transformOptions?: Jest26Config): string;
32
+ /**
33
+ * Generates a key used to cache the results of transforming a file. This helps avoid re-processing a file via the
34
+ * `transform` function unnecessarily (when no changes have occurred). The API for `getCacheKey` is described in the
35
+ * ["Writing custom transformers"](https://jestjs.io/docs/code-transformation#writing-custom-transformers)
36
+ * documentation on the jest site. Unfortunately, the URL is not versioned at the time of this writing. For
37
+ * reference, the v27.2 docs were referenced (the most recent available).
38
+ *
39
+ * This function attempts to support several versions of Jest (v23 through v27). Support for earlier versions of Jest
40
+ * will be removed in a future major version of Stencil.
41
+ *
42
+ * @param sourceText the contents of the source file
43
+ * @param sourcePath the path to the source file
44
+ * @param jestConfigStr a stringified version of the jest configuration when called by Jest 26 and lower. This
45
+ * parameter takes the shape of `transformOptions` when called by Jest 27+.
46
+ * @param transformOptions an object containing the various transformation options. In Jest 27+ this parameter occurs
47
+ * third in this function signature (and no fourth parameter is formally accepted)
48
+ * @returns the key to cache a file with
49
+ */
50
+ getCacheKey(sourceText: string, sourcePath: string, jestConfigStr: string | Jest27TransformOptions, transformOptions?: Jest26CacheKeyOptions): string;
10
51
  };
52
+ /**
53
+ * Determines if a file should be transformed prior to being consumed by Jest, based on the file name and its contents
54
+ * @param filePath the path of the file
55
+ * @param sourceText the contents of the file
56
+ * @returns `true` if the file should be transformed, `false` otherwise
57
+ */
11
58
  export declare function shouldTransform(filePath: string, sourceText: string): boolean;
59
+ export {};
@@ -1,3 +1,8 @@
1
+ /**
2
+ * The path's declared below are relative. Specifically, they are relative to the location of this file after
3
+ * compilation of the Stencil compiler has completed. See `scripts/bundles/testing` for the location of this file
4
+ * following compilation.
5
+ */
1
6
  const path = require('path');
2
7
  const testingDir = __dirname;
3
8
  const rootDir = path.join(testingDir, '..');
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/testing",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Stencil testing suite.",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",