@smoothdeploy/playwright 1.60.1 → 1.61.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/lib/agents/generateAgents.js +48 -0
- package/lib/cli/testActions.js +2 -0
- package/lib/common/index.js +168 -135
- package/lib/common/index.js.txt +8 -8
- package/lib/index.js +18 -13
- package/lib/loader/loaderProcessEntry.js +1 -1
- package/lib/matchers/expect.js +18 -16
- package/lib/matchers/expect.js.txt +3 -3
- package/lib/mcp/test/testContext.js +5 -1
- package/lib/program.js +9 -3
- package/lib/runner/index.js +138 -88
- package/lib/runner/index.js.txt +8 -8
- package/lib/transform/esmLoader.js +149 -42
- package/lib/transform/esmLoader.js.txt +7 -5
- package/lib/util.js +12 -15
- package/lib/worker/workerProcessEntry.js +46 -1429
- package/lib/worker/workerProcessEntry.js.txt +4 -8
- package/package.json +2 -2
- package/types/test.d.ts +67 -17
package/lib/runner/index.js.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# packages/playwright/lib/runner/index.js
|
|
2
|
-
# total:
|
|
2
|
+
# total: 302.0 KB
|
|
3
3
|
|
|
4
4
|
## Inlined (46)
|
|
5
5
|
1.3 KB packages/playwright/src/isomorphic/events.ts
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
3.9 KB packages/playwright/src/isomorphic/teleSuiteUpdater.ts
|
|
10
10
|
4.8 KB packages/playwright/src/isomorphic/testServerConnection.ts
|
|
11
11
|
0.0 KB packages/playwright/src/isomorphic/testTree.ts
|
|
12
|
-
5.
|
|
12
|
+
5.1 KB packages/playwright/src/plugins/gitCommitInfoPlugin.ts
|
|
13
13
|
8.6 KB packages/playwright/src/plugins/webServerPlugin.ts
|
|
14
|
-
|
|
14
|
+
21.2 KB packages/playwright/src/reporters/base.ts
|
|
15
15
|
4.0 KB packages/playwright/src/reporters/blob.ts
|
|
16
16
|
2.3 KB packages/playwright/src/reporters/dot.ts
|
|
17
17
|
0.1 KB packages/playwright/src/reporters/empty.ts
|
|
@@ -21,17 +21,17 @@
|
|
|
21
21
|
7.1 KB packages/playwright/src/reporters/json.ts
|
|
22
22
|
10.3 KB packages/playwright/src/reporters/junit.ts
|
|
23
23
|
3.8 KB packages/playwright/src/reporters/line.ts
|
|
24
|
-
|
|
24
|
+
9.2 KB packages/playwright/src/reporters/list.ts
|
|
25
25
|
1.4 KB packages/playwright/src/reporters/listModeReporter.ts
|
|
26
26
|
18.5 KB packages/playwright/src/reporters/merge.ts
|
|
27
27
|
2.5 KB packages/playwright/src/reporters/multiplexer.ts
|
|
28
28
|
2.0 KB packages/playwright/src/reporters/reporterV2.ts
|
|
29
29
|
11.0 KB packages/playwright/src/reporters/smoothdeploy.ts
|
|
30
|
-
8.
|
|
30
|
+
8.8 KB packages/playwright/src/reporters/teleEmitter.ts
|
|
31
31
|
19.0 KB packages/playwright/src/runner/dispatcher.ts
|
|
32
32
|
1.5 KB packages/playwright/src/runner/fsWatcher.ts
|
|
33
33
|
0.5 KB packages/playwright/src/runner/index.ts
|
|
34
|
-
1.
|
|
34
|
+
1.4 KB packages/playwright/src/runner/lastRun.ts
|
|
35
35
|
1.6 KB packages/playwright/src/runner/loaderHost.ts
|
|
36
36
|
12.5 KB packages/playwright/src/runner/loadUtils.ts
|
|
37
37
|
5.8 KB packages/playwright/src/runner/processHost.ts
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
3.5 KB packages/playwright/src/runner/taskRunner.ts
|
|
43
43
|
14.4 KB packages/playwright/src/runner/tasks.ts
|
|
44
44
|
3.6 KB packages/playwright/src/runner/testGroups.ts
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
14.1 KB packages/playwright/src/runner/testRunner.ts
|
|
46
|
+
9.3 KB packages/playwright/src/runner/testServer.ts
|
|
47
47
|
0.2 KB packages/playwright/src/runner/uiModeReporter.ts
|
|
48
48
|
1.7 KB packages/playwright/src/runner/vcs.ts
|
|
49
49
|
13.1 KB packages/playwright/src/runner/watchMode.ts
|
|
@@ -1826,11 +1826,11 @@ var require_source_map_support = __commonJS({
|
|
|
1826
1826
|
"node_modules/source-map-support/source-map-support.js"(exports2, module2) {
|
|
1827
1827
|
var SourceMapConsumer = require_source_map().SourceMapConsumer;
|
|
1828
1828
|
var path6 = require("path");
|
|
1829
|
-
var
|
|
1829
|
+
var fs7;
|
|
1830
1830
|
try {
|
|
1831
|
-
|
|
1832
|
-
if (!
|
|
1833
|
-
|
|
1831
|
+
fs7 = require("fs");
|
|
1832
|
+
if (!fs7.existsSync || !fs7.readFileSync) {
|
|
1833
|
+
fs7 = null;
|
|
1834
1834
|
}
|
|
1835
1835
|
} catch (err) {
|
|
1836
1836
|
}
|
|
@@ -1901,7 +1901,7 @@ var require_source_map_support = __commonJS({
|
|
|
1901
1901
|
}
|
|
1902
1902
|
var contents = "";
|
|
1903
1903
|
try {
|
|
1904
|
-
if (!
|
|
1904
|
+
if (!fs7) {
|
|
1905
1905
|
var xhr = new XMLHttpRequest();
|
|
1906
1906
|
xhr.open(
|
|
1907
1907
|
"GET",
|
|
@@ -1913,8 +1913,8 @@ var require_source_map_support = __commonJS({
|
|
|
1913
1913
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
1914
1914
|
contents = xhr.responseText;
|
|
1915
1915
|
}
|
|
1916
|
-
} else if (
|
|
1917
|
-
contents =
|
|
1916
|
+
} else if (fs7.existsSync(path7)) {
|
|
1917
|
+
contents = fs7.readFileSync(path7, "utf8");
|
|
1918
1918
|
}
|
|
1919
1919
|
} catch (er) {
|
|
1920
1920
|
}
|
|
@@ -2178,9 +2178,9 @@ var require_source_map_support = __commonJS({
|
|
|
2178
2178
|
var line = +match[2];
|
|
2179
2179
|
var column = +match[3];
|
|
2180
2180
|
var contents = fileContentsCache[source];
|
|
2181
|
-
if (!contents &&
|
|
2181
|
+
if (!contents && fs7 && fs7.existsSync(source)) {
|
|
2182
2182
|
try {
|
|
2183
|
-
contents =
|
|
2183
|
+
contents = fs7.readFileSync(source, "utf8");
|
|
2184
2184
|
} catch (er) {
|
|
2185
2185
|
contents = "";
|
|
2186
2186
|
}
|
|
@@ -3701,7 +3701,7 @@ var require_browser = __commonJS({
|
|
|
3701
3701
|
"node_modules/debug/src/browser.js"(exports2, module2) {
|
|
3702
3702
|
exports2.formatArgs = formatArgs;
|
|
3703
3703
|
exports2.save = save;
|
|
3704
|
-
exports2.load =
|
|
3704
|
+
exports2.load = load3;
|
|
3705
3705
|
exports2.useColors = useColors;
|
|
3706
3706
|
exports2.storage = localstorage();
|
|
3707
3707
|
exports2.destroy = /* @__PURE__ */ (() => {
|
|
@@ -3837,7 +3837,7 @@ var require_browser = __commonJS({
|
|
|
3837
3837
|
} catch (error) {
|
|
3838
3838
|
}
|
|
3839
3839
|
}
|
|
3840
|
-
function
|
|
3840
|
+
function load3() {
|
|
3841
3841
|
let r;
|
|
3842
3842
|
try {
|
|
3843
3843
|
r = exports2.storage.getItem("debug") || exports2.storage.getItem("DEBUG");
|
|
@@ -4002,7 +4002,7 @@ var require_node = __commonJS({
|
|
|
4002
4002
|
exports2.log = log;
|
|
4003
4003
|
exports2.formatArgs = formatArgs;
|
|
4004
4004
|
exports2.save = save;
|
|
4005
|
-
exports2.load =
|
|
4005
|
+
exports2.load = load3;
|
|
4006
4006
|
exports2.useColors = useColors;
|
|
4007
4007
|
exports2.destroy = util.deprecate(
|
|
4008
4008
|
() => {
|
|
@@ -4144,7 +4144,7 @@ var require_node = __commonJS({
|
|
|
4144
4144
|
delete process.env.DEBUG;
|
|
4145
4145
|
}
|
|
4146
4146
|
}
|
|
4147
|
-
function
|
|
4147
|
+
function load3() {
|
|
4148
4148
|
return process.env.DEBUG;
|
|
4149
4149
|
}
|
|
4150
4150
|
function init(debug2) {
|
|
@@ -5148,7 +5148,7 @@ var require_minimatch = __commonJS({
|
|
|
5148
5148
|
});
|
|
5149
5149
|
|
|
5150
5150
|
// packages/playwright/src/transform/esmLoader.ts
|
|
5151
|
-
var
|
|
5151
|
+
var import_fs6 = __toESM(require("fs"));
|
|
5152
5152
|
var import_url3 = __toESM(require("url"));
|
|
5153
5153
|
|
|
5154
5154
|
// packages/playwright/src/transform/compilationCache.ts
|
|
@@ -5386,7 +5386,7 @@ var PortTransport = class {
|
|
|
5386
5386
|
};
|
|
5387
5387
|
|
|
5388
5388
|
// packages/playwright/src/transform/transform.ts
|
|
5389
|
-
var
|
|
5389
|
+
var import_fs5 = __toESM(require("fs"));
|
|
5390
5390
|
var import_module2 = __toESM(require("module"));
|
|
5391
5391
|
var import_path5 = __toESM(require("path"));
|
|
5392
5392
|
var import_url2 = __toESM(require("url"));
|
|
@@ -5467,13 +5467,12 @@ var import_package2 = require("../package");
|
|
|
5467
5467
|
// packages/playwright/src/util.ts
|
|
5468
5468
|
var import_fs3 = __toESM(require("fs"));
|
|
5469
5469
|
var import_path3 = __toESM(require("path"));
|
|
5470
|
-
var import_url = __toESM(require("url"));
|
|
5471
5470
|
var import_debug2 = __toESM(require_src());
|
|
5472
5471
|
var import_mime = __toESM(require_mime());
|
|
5473
5472
|
var import_minimatch = __toESM(require_minimatch());
|
|
5474
5473
|
|
|
5475
5474
|
// packages/isomorphic/stringUtils.ts
|
|
5476
|
-
var ansiRegex = new RegExp("([\\u001B\\u009B][[\\]()
|
|
5475
|
+
var ansiRegex = new RegExp("([\\u001B\\u009B][[\\]()#?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{0,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))", "g");
|
|
5477
5476
|
|
|
5478
5477
|
// packages/isomorphic/rtti.ts
|
|
5479
5478
|
function isRegExp(obj) {
|
|
@@ -5508,10 +5507,10 @@ function createFileMatcher(patterns) {
|
|
|
5508
5507
|
return true;
|
|
5509
5508
|
}
|
|
5510
5509
|
if (import_path3.default.sep === "\\") {
|
|
5511
|
-
const
|
|
5510
|
+
const unixPath = filePath.split(import_path3.default.sep).join("/");
|
|
5512
5511
|
for (const re2 of reList) {
|
|
5513
5512
|
re2.lastIndex = 0;
|
|
5514
|
-
if (re2.test(
|
|
5513
|
+
if (re2.test(unixPath))
|
|
5515
5514
|
return true;
|
|
5516
5515
|
}
|
|
5517
5516
|
}
|
|
@@ -5550,11 +5549,20 @@ function fileIsModule(file2) {
|
|
|
5550
5549
|
const folder = import_path3.default.dirname(file2);
|
|
5551
5550
|
return folderIsModule(folder);
|
|
5552
5551
|
}
|
|
5552
|
+
var packageJsonIsModuleCache = /* @__PURE__ */ new Map();
|
|
5553
5553
|
function folderIsModule(folder) {
|
|
5554
5554
|
const packageJsonPath = getPackageJsonPath(folder);
|
|
5555
5555
|
if (!packageJsonPath)
|
|
5556
5556
|
return false;
|
|
5557
|
-
|
|
5557
|
+
if (!packageJsonIsModuleCache.has(packageJsonPath)) {
|
|
5558
|
+
let isModule2 = false;
|
|
5559
|
+
try {
|
|
5560
|
+
isModule2 = JSON.parse(import_fs3.default.readFileSync(packageJsonPath, "utf8")).type === "module";
|
|
5561
|
+
} catch {
|
|
5562
|
+
}
|
|
5563
|
+
packageJsonIsModuleCache.set(packageJsonPath, isModule2);
|
|
5564
|
+
}
|
|
5565
|
+
return packageJsonIsModuleCache.get(packageJsonPath);
|
|
5558
5566
|
}
|
|
5559
5567
|
var packageJsonMainFieldCache = /* @__PURE__ */ new Map();
|
|
5560
5568
|
function getMainFieldFromPackageJson(packageJsonPath) {
|
|
@@ -5613,6 +5621,49 @@ function dirExists(resolved) {
|
|
|
5613
5621
|
return import_fs3.default.statSync(resolved, { throwIfNoEntry: false })?.isDirectory();
|
|
5614
5622
|
}
|
|
5615
5623
|
|
|
5624
|
+
// packages/playwright/src/transform/esmLoaderSync.ts
|
|
5625
|
+
var import_fs4 = __toESM(require("fs"));
|
|
5626
|
+
var import_url = __toESM(require("url"));
|
|
5627
|
+
function resolve(specifier, context, nextResolve) {
|
|
5628
|
+
if (context.parentURL && context.parentURL.startsWith("file://")) {
|
|
5629
|
+
const filename = import_url.default.fileURLToPath(context.parentURL);
|
|
5630
|
+
const resolved = resolveHook(filename, specifier);
|
|
5631
|
+
if (resolved !== void 0) {
|
|
5632
|
+
specifier = context.conditions?.includes("import") ? import_url.default.pathToFileURL(resolved).toString() : resolved;
|
|
5633
|
+
}
|
|
5634
|
+
}
|
|
5635
|
+
const result2 = nextResolve(specifier, context);
|
|
5636
|
+
if (result2?.url && result2.url.startsWith("file://"))
|
|
5637
|
+
currentFileDepsCollector()?.add(import_url.default.fileURLToPath(result2.url));
|
|
5638
|
+
return result2;
|
|
5639
|
+
}
|
|
5640
|
+
var kSupportedFormats = /* @__PURE__ */ new Map([
|
|
5641
|
+
["commonjs", "commonjs"],
|
|
5642
|
+
["module", "module"],
|
|
5643
|
+
["commonjs-typescript", "commonjs"],
|
|
5644
|
+
["module-typescript", "module"],
|
|
5645
|
+
["typescript", null],
|
|
5646
|
+
[null, null],
|
|
5647
|
+
[void 0, void 0]
|
|
5648
|
+
]);
|
|
5649
|
+
function load(moduleUrl, context, nextLoad) {
|
|
5650
|
+
if (!kSupportedFormats.has(context.format))
|
|
5651
|
+
return nextLoad(moduleUrl, context);
|
|
5652
|
+
if (!moduleUrl.startsWith("file://"))
|
|
5653
|
+
return nextLoad(moduleUrl, context);
|
|
5654
|
+
const filename = import_url.default.fileURLToPath(moduleUrl);
|
|
5655
|
+
if (!shouldTransform(filename))
|
|
5656
|
+
return nextLoad(moduleUrl, context);
|
|
5657
|
+
const format = kSupportedFormats.get(context.format) || (fileIsModule(filename) ? "module" : "commonjs");
|
|
5658
|
+
const code = import_fs4.default.readFileSync(filename, "utf-8");
|
|
5659
|
+
const transformed = transformHook(code, filename, format === "module" ? moduleUrl : void 0);
|
|
5660
|
+
return {
|
|
5661
|
+
format,
|
|
5662
|
+
source: transformed.code,
|
|
5663
|
+
shortCircuit: true
|
|
5664
|
+
};
|
|
5665
|
+
}
|
|
5666
|
+
|
|
5616
5667
|
// packages/playwright/src/transform/pirates.ts
|
|
5617
5668
|
var import_module = __toESM(require("module"));
|
|
5618
5669
|
var import_path4 = __toESM(require("path"));
|
|
@@ -5648,20 +5699,18 @@ var _transformConfig = {
|
|
|
5648
5699
|
external: []
|
|
5649
5700
|
};
|
|
5650
5701
|
var _externalMatcher = () => false;
|
|
5651
|
-
function setTransformConfig(config) {
|
|
5702
|
+
async function setTransformConfig(config) {
|
|
5652
5703
|
_transformConfig = config;
|
|
5653
5704
|
_externalMatcher = createFileMatcher(_transformConfig.external);
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
return _transformConfig;
|
|
5705
|
+
if (loaderChannel)
|
|
5706
|
+
await loaderChannel.send("setTransformConfig", { config });
|
|
5657
5707
|
}
|
|
5658
5708
|
var _singleTSConfigPath;
|
|
5659
5709
|
var _singleTSConfig;
|
|
5660
|
-
function setSingleTSConfig(value) {
|
|
5710
|
+
async function setSingleTSConfig(value) {
|
|
5661
5711
|
_singleTSConfigPath = value;
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
return _singleTSConfigPath;
|
|
5712
|
+
if (loaderChannel)
|
|
5713
|
+
await loaderChannel.send("setSingleTSConfig", { tsconfig: value });
|
|
5665
5714
|
}
|
|
5666
5715
|
function validateTsConfig(tsconfig) {
|
|
5667
5716
|
const pathsBase = tsconfig.absoluteBaseUrl ?? tsconfig.paths?.pathsBasePath;
|
|
@@ -5692,7 +5741,7 @@ function loadAndValidateTsconfigsForFolder(folder) {
|
|
|
5692
5741
|
foldersWithConfig.push(currentFolder);
|
|
5693
5742
|
for (const name of ["tsconfig.json", "jsconfig.json"]) {
|
|
5694
5743
|
const configPath = import_path5.default.join(currentFolder, name);
|
|
5695
|
-
if (
|
|
5744
|
+
if (import_fs5.default.existsSync(configPath)) {
|
|
5696
5745
|
const loaded = loadTsConfig(configPath);
|
|
5697
5746
|
result2 = loaded.map(validateTsConfig);
|
|
5698
5747
|
break;
|
|
@@ -5808,15 +5857,21 @@ async function requireOrImport(file) {
|
|
|
5808
5857
|
if (isModule) {
|
|
5809
5858
|
const fileName = import_url2.default.pathToFileURL(file);
|
|
5810
5859
|
const esmImport = () => eval(`import(${JSON.stringify(fileName)})`);
|
|
5811
|
-
|
|
5860
|
+
if (loaderChannel) {
|
|
5861
|
+
await eval(`import(${JSON.stringify(fileName + ".esm.preflight")})`).catch((error) => debugTest("Failed to load preflight for " + file + ", source maps may be missing for errors thrown during loading.", error)).finally(nextTask);
|
|
5862
|
+
}
|
|
5812
5863
|
return await esmImport().finally(nextTask);
|
|
5813
5864
|
}
|
|
5814
5865
|
const result = require(file);
|
|
5815
5866
|
const depsCollector = currentFileDepsCollector();
|
|
5816
5867
|
if (depsCollector) {
|
|
5817
5868
|
const module2 = require.cache[file];
|
|
5818
|
-
if (module2)
|
|
5819
|
-
|
|
5869
|
+
if (module2) {
|
|
5870
|
+
const cjsDeps = /* @__PURE__ */ new Set();
|
|
5871
|
+
collectCJSDependencies(module2, cjsDeps);
|
|
5872
|
+
for (const dep of cjsDeps)
|
|
5873
|
+
depsCollector.add(dep);
|
|
5874
|
+
}
|
|
5820
5875
|
}
|
|
5821
5876
|
return result;
|
|
5822
5877
|
}
|
|
@@ -5825,7 +5880,17 @@ function installTransformIfNeeded() {
|
|
|
5825
5880
|
if (transformInstalled)
|
|
5826
5881
|
return;
|
|
5827
5882
|
transformInstalled = true;
|
|
5883
|
+
registerESMLoader();
|
|
5828
5884
|
installSourceMapSupport();
|
|
5885
|
+
if (loaderChannel) {
|
|
5886
|
+
installCJSHooks();
|
|
5887
|
+
return;
|
|
5888
|
+
}
|
|
5889
|
+
const extensions = import_module2.default._extensions;
|
|
5890
|
+
for (const ext of [".ts", ".cts", ".tsx", ".jsx"])
|
|
5891
|
+
extensions[ext] = extensions[".js"];
|
|
5892
|
+
}
|
|
5893
|
+
function installCJSHooks() {
|
|
5829
5894
|
const originalResolveFilename = import_module2.default._resolveFilename;
|
|
5830
5895
|
function resolveFilename(specifier, parent, ...rest) {
|
|
5831
5896
|
if (parent) {
|
|
@@ -5875,12 +5940,54 @@ function isRelativeSpecifier(specifier) {
|
|
|
5875
5940
|
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
|
|
5876
5941
|
}
|
|
5877
5942
|
async function nextTask() {
|
|
5878
|
-
return new Promise((
|
|
5943
|
+
return new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
5944
|
+
}
|
|
5945
|
+
var loaderChannel;
|
|
5946
|
+
function registerESMLoader() {
|
|
5947
|
+
if (process.env.PW_DISABLE_TS_ESM)
|
|
5948
|
+
return;
|
|
5949
|
+
if ("Bun" in globalThis)
|
|
5950
|
+
return;
|
|
5951
|
+
const nodeModule = require("node:module");
|
|
5952
|
+
if (nodeModule.registerHooks && !process.env.PLAYWRIGHT_FORCE_ASYNC_LOADER) {
|
|
5953
|
+
nodeModule.registerHooks({ resolve, load });
|
|
5954
|
+
return;
|
|
5955
|
+
}
|
|
5956
|
+
if (!nodeModule.register)
|
|
5957
|
+
return;
|
|
5958
|
+
const { port1, port2 } = new MessageChannel();
|
|
5959
|
+
nodeModule.register(import_url2.default.pathToFileURL(require.resolve("../transform/esmLoader.js")), {
|
|
5960
|
+
data: { port: port2 },
|
|
5961
|
+
transferList: [port2]
|
|
5962
|
+
});
|
|
5963
|
+
loaderChannel = new PortTransport(port1, async (method, params) => {
|
|
5964
|
+
if (method === "pushToCompilationCache")
|
|
5965
|
+
addToCompilationCache(params.cache);
|
|
5966
|
+
});
|
|
5967
|
+
void loaderChannel.send("setSingleTSConfig", { tsconfig: _singleTSConfigPath });
|
|
5968
|
+
void loaderChannel.send("setTransformConfig", { config: _transformConfig });
|
|
5969
|
+
void loaderChannel.send("addToCompilationCache", { cache: serializeCompilationCache() });
|
|
5970
|
+
}
|
|
5971
|
+
async function startCollectingFileDeps2() {
|
|
5972
|
+
startCollectingFileDeps();
|
|
5973
|
+
if (loaderChannel)
|
|
5974
|
+
await loaderChannel.send("startCollectingFileDeps", {});
|
|
5975
|
+
}
|
|
5976
|
+
async function stopCollectingFileDeps2(file2) {
|
|
5977
|
+
stopCollectingFileDeps(file2);
|
|
5978
|
+
if (loaderChannel)
|
|
5979
|
+
await loaderChannel.send("stopCollectingFileDeps", { file: file2 });
|
|
5980
|
+
}
|
|
5981
|
+
async function incorporateCompilationCache() {
|
|
5982
|
+
if (!loaderChannel)
|
|
5983
|
+
return;
|
|
5984
|
+
const result2 = await loaderChannel.send("getCompilationCache", {});
|
|
5985
|
+
addToCompilationCache(result2.cache);
|
|
5879
5986
|
}
|
|
5880
5987
|
|
|
5881
5988
|
// packages/playwright/src/transform/esmLoader.ts
|
|
5882
5989
|
var esmPreflightExtension = ".esm.preflight";
|
|
5883
|
-
async function
|
|
5990
|
+
async function resolve2(originalSpecifier, context, defaultResolve) {
|
|
5884
5991
|
let specifier = originalSpecifier.replace(esmPreflightExtension, "");
|
|
5885
5992
|
if (context.parentURL && context.parentURL.startsWith("file://")) {
|
|
5886
5993
|
const filename = import_url3.default.fileURLToPath(context.parentURL);
|
|
@@ -5895,7 +6002,7 @@ async function resolve(originalSpecifier, context, defaultResolve) {
|
|
|
5895
6002
|
result2.url = result2.url + esmPreflightExtension;
|
|
5896
6003
|
return result2;
|
|
5897
6004
|
}
|
|
5898
|
-
var
|
|
6005
|
+
var kSupportedFormats2 = /* @__PURE__ */ new Map([
|
|
5899
6006
|
["commonjs", "commonjs"],
|
|
5900
6007
|
["module", "module"],
|
|
5901
6008
|
["commonjs-typescript", "commonjs"],
|
|
@@ -5903,8 +6010,8 @@ var kSupportedFormats = /* @__PURE__ */ new Map([
|
|
|
5903
6010
|
[null, null],
|
|
5904
6011
|
[void 0, void 0]
|
|
5905
6012
|
]);
|
|
5906
|
-
async function
|
|
5907
|
-
if (!
|
|
6013
|
+
async function load2(moduleUrl, context, defaultLoad) {
|
|
6014
|
+
if (!kSupportedFormats2.has(context.format))
|
|
5908
6015
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
5909
6016
|
if (!moduleUrl.startsWith("file://"))
|
|
5910
6017
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
@@ -5914,12 +6021,12 @@ async function load(moduleUrl, context, defaultLoad) {
|
|
|
5914
6021
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
5915
6022
|
const originalModuleUrl = isPreflight ? moduleUrl.slice(0, -esmPreflightExtension.length) : moduleUrl;
|
|
5916
6023
|
const originalFilename = isPreflight ? import_url3.default.fileURLToPath(originalModuleUrl) : filename;
|
|
5917
|
-
const code =
|
|
6024
|
+
const code = import_fs6.default.readFileSync(originalFilename, "utf-8");
|
|
5918
6025
|
const transformed = transformHook(code, originalFilename, originalModuleUrl);
|
|
5919
6026
|
if (transformed.serializedCache)
|
|
5920
6027
|
transport?.post("pushToCompilationCache", { cache: transformed.serializedCache });
|
|
5921
6028
|
return {
|
|
5922
|
-
format:
|
|
6029
|
+
format: kSupportedFormats2.get(context.format) || (fileIsModule(originalFilename) ? "module" : "commonjs"),
|
|
5923
6030
|
source: isPreflight ? `void 0;` : transformed.code,
|
|
5924
6031
|
shortCircuit: true
|
|
5925
6032
|
};
|
|
@@ -5931,11 +6038,11 @@ function initialize(data) {
|
|
|
5931
6038
|
function createTransport(port) {
|
|
5932
6039
|
return new PortTransport(port, async (method, params) => {
|
|
5933
6040
|
if (method === "setSingleTSConfig") {
|
|
5934
|
-
setSingleTSConfig(params.tsconfig);
|
|
6041
|
+
await setSingleTSConfig(params.tsconfig);
|
|
5935
6042
|
return;
|
|
5936
6043
|
}
|
|
5937
6044
|
if (method === "setTransformConfig") {
|
|
5938
|
-
setTransformConfig(params.config);
|
|
6045
|
+
await setTransformConfig(params.config);
|
|
5939
6046
|
return;
|
|
5940
6047
|
}
|
|
5941
6048
|
if (method === "addToCompilationCache") {
|
|
@@ -5954,4 +6061,4 @@ function createTransport(port) {
|
|
|
5954
6061
|
}
|
|
5955
6062
|
});
|
|
5956
6063
|
}
|
|
5957
|
-
module.exports = { initialize, load, resolve };
|
|
6064
|
+
module.exports = { initialize, load: load2, resolve: resolve2 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# packages/playwright/lib/transform/esmLoader.js
|
|
2
|
-
# total:
|
|
2
|
+
# total: 249.0 KB
|
|
3
3
|
|
|
4
|
-
## Inlined (
|
|
4
|
+
## Inlined (47)
|
|
5
5
|
1.5 KB node_modules/balanced-match/index.js
|
|
6
6
|
4.4 KB node_modules/brace-expansion/index.js
|
|
7
7
|
1.8 KB node_modules/buffer-from/index.js
|
|
@@ -40,16 +40,18 @@
|
|
|
40
40
|
0.2 KB packages/isomorphic/stringUtils.ts
|
|
41
41
|
6.3 KB packages/playwright/src/transform/compilationCache.ts
|
|
42
42
|
3.1 KB packages/playwright/src/transform/esmLoader.ts
|
|
43
|
+
1.6 KB packages/playwright/src/transform/esmLoaderSync.ts
|
|
43
44
|
1.1 KB packages/playwright/src/transform/pirates.ts
|
|
44
45
|
1.1 KB packages/playwright/src/transform/portTransport.ts
|
|
45
|
-
|
|
46
|
+
11.7 KB packages/playwright/src/transform/transform.ts
|
|
46
47
|
2.9 KB packages/playwright/src/transform/tsconfig-loader.ts
|
|
47
|
-
4.
|
|
48
|
+
4.9 KB packages/playwright/src/util.ts
|
|
48
49
|
0.2 KB packages/utils/crypto.ts
|
|
49
50
|
0.2 KB packages/utils/debug.ts
|
|
50
51
|
0.5 KB packages/utils/env.ts
|
|
51
52
|
|
|
52
|
-
## External (
|
|
53
|
+
## External (4)
|
|
53
54
|
../globals
|
|
54
55
|
../package
|
|
56
|
+
../transform/esmLoader.js
|
|
55
57
|
playwright-core/package.json
|
package/lib/util.js
CHANGED
|
@@ -55,13 +55,11 @@ __export(util_exports, {
|
|
|
55
55
|
serializeError: () => serializeError,
|
|
56
56
|
stripAnsiEscapes: () => stripAnsiEscapes,
|
|
57
57
|
takeFirst: () => takeFirst,
|
|
58
|
-
trimLongString: () => trimLongString,
|
|
59
58
|
windowsFilesystemFriendlyLength: () => windowsFilesystemFriendlyLength
|
|
60
59
|
});
|
|
61
60
|
module.exports = __toCommonJS(util_exports);
|
|
62
61
|
var import_fs = __toESM(require("fs"));
|
|
63
62
|
var import_path = __toESM(require("path"));
|
|
64
|
-
var import_url = __toESM(require("url"));
|
|
65
63
|
var import_util = __toESM(require("util"));
|
|
66
64
|
const debug = require("playwright-core/lib/utilsBundle").debug;
|
|
67
65
|
const mime = require("playwright-core/lib/utilsBundle").mime;
|
|
@@ -141,10 +139,10 @@ function createFileMatcher(patterns) {
|
|
|
141
139
|
return true;
|
|
142
140
|
}
|
|
143
141
|
if (import_path.default.sep === "\\") {
|
|
144
|
-
const
|
|
142
|
+
const unixPath = filePath.split(import_path.default.sep).join("/");
|
|
145
143
|
for (const re of reList) {
|
|
146
144
|
re.lastIndex = 0;
|
|
147
|
-
if (re.test(
|
|
145
|
+
if (re.test(unixPath))
|
|
148
146
|
return true;
|
|
149
147
|
}
|
|
150
148
|
}
|
|
@@ -203,15 +201,6 @@ function expectTypes(receiver, types, matcherName) {
|
|
|
203
201
|
}
|
|
204
202
|
}
|
|
205
203
|
const windowsFilesystemFriendlyLength = 60;
|
|
206
|
-
function trimLongString(s, length = 100) {
|
|
207
|
-
if (s.length <= length)
|
|
208
|
-
return s;
|
|
209
|
-
const hash = calculateSha1(s);
|
|
210
|
-
const middle = `-${hash.substring(0, 5)}-`;
|
|
211
|
-
const start = Math.floor((length - middle.length) / 2);
|
|
212
|
-
const end = length - middle.length - start;
|
|
213
|
-
return s.substring(0, start) + middle + s.slice(-end);
|
|
214
|
-
}
|
|
215
204
|
function addSuffixToFilePath(filePath, suffix) {
|
|
216
205
|
const ext = import_path.default.extname(filePath);
|
|
217
206
|
const base = filePath.substring(0, filePath.length - ext.length);
|
|
@@ -283,11 +272,20 @@ function fileIsModule(file) {
|
|
|
283
272
|
const folder = import_path.default.dirname(file);
|
|
284
273
|
return folderIsModule(folder);
|
|
285
274
|
}
|
|
275
|
+
const packageJsonIsModuleCache = /* @__PURE__ */ new Map();
|
|
286
276
|
function folderIsModule(folder) {
|
|
287
277
|
const packageJsonPath = getPackageJsonPath(folder);
|
|
288
278
|
if (!packageJsonPath)
|
|
289
279
|
return false;
|
|
290
|
-
|
|
280
|
+
if (!packageJsonIsModuleCache.has(packageJsonPath)) {
|
|
281
|
+
let isModule = false;
|
|
282
|
+
try {
|
|
283
|
+
isModule = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf8")).type === "module";
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
packageJsonIsModuleCache.set(packageJsonPath, isModule);
|
|
287
|
+
}
|
|
288
|
+
return packageJsonIsModuleCache.get(packageJsonPath);
|
|
291
289
|
}
|
|
292
290
|
const packageJsonMainFieldCache = /* @__PURE__ */ new Map();
|
|
293
291
|
function getMainFieldFromPackageJson(packageJsonPath) {
|
|
@@ -398,6 +396,5 @@ function takeFirst(...args) {
|
|
|
398
396
|
serializeError,
|
|
399
397
|
stripAnsiEscapes,
|
|
400
398
|
takeFirst,
|
|
401
|
-
trimLongString,
|
|
402
399
|
windowsFilesystemFriendlyLength
|
|
403
400
|
});
|