playwright 1.62.1 → 1.65.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/README.md +4 -4
- package/lib/agents/playwright-test-generator.agent.md +1 -1
- package/lib/cli/testActions.js +9 -6
- package/lib/common/index.js +207 -148
- package/lib/common/index.js.txt +13 -14
- package/lib/index.js +51 -30
- package/lib/matchers/expect.js +117 -81
- package/lib/matchers/expect.js.LICENSE +3 -3
- package/lib/matchers/expect.js.txt +8 -8
- package/lib/mcp/test/browserBackend.js +12 -2
- package/lib/mcp/test/testContext.js +2 -8
- package/lib/program.js +4 -4
- package/lib/runner/index.js +1151 -572
- package/lib/runner/index.js.txt +32 -29
- package/lib/transform/babelBundle.js +1217 -982
- package/lib/transform/babelBundle.js.LICENSE +15 -15
- package/lib/transform/babelBundle.js.txt +14 -11
- package/lib/transform/esmLoader.js +375 -187
- package/lib/transform/esmLoader.js.LICENSE +3 -3
- package/lib/transform/esmLoader.js.txt +9 -8
- package/lib/worker/workerProcessEntry.js +43 -41
- package/lib/worker/workerProcessEntry.js.txt +4 -4
- package/package.json +2 -10
- package/types/test.d.ts +755 -88
- package/types/testReporter.d.ts +74 -3
- package/jsx-runtime.js +0 -42
- package/jsx-runtime.mjs +0 -21
|
@@ -154,34 +154,34 @@ var require_util = __commonJS({
|
|
|
154
154
|
}
|
|
155
155
|
exports2.urlParse = urlParse;
|
|
156
156
|
function urlGenerate(aParsedUrl) {
|
|
157
|
-
var
|
|
157
|
+
var url5 = "";
|
|
158
158
|
if (aParsedUrl.scheme) {
|
|
159
|
-
|
|
159
|
+
url5 += aParsedUrl.scheme + ":";
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
url5 += "//";
|
|
162
162
|
if (aParsedUrl.auth) {
|
|
163
|
-
|
|
163
|
+
url5 += aParsedUrl.auth + "@";
|
|
164
164
|
}
|
|
165
165
|
if (aParsedUrl.host) {
|
|
166
|
-
|
|
166
|
+
url5 += aParsedUrl.host;
|
|
167
167
|
}
|
|
168
168
|
if (aParsedUrl.port) {
|
|
169
|
-
|
|
169
|
+
url5 += ":" + aParsedUrl.port;
|
|
170
170
|
}
|
|
171
171
|
if (aParsedUrl.path) {
|
|
172
|
-
|
|
172
|
+
url5 += aParsedUrl.path;
|
|
173
173
|
}
|
|
174
|
-
return
|
|
174
|
+
return url5;
|
|
175
175
|
}
|
|
176
176
|
exports2.urlGenerate = urlGenerate;
|
|
177
177
|
function normalize(aPath) {
|
|
178
178
|
var path7 = aPath;
|
|
179
|
-
var
|
|
180
|
-
if (
|
|
181
|
-
if (!
|
|
179
|
+
var url5 = urlParse(aPath);
|
|
180
|
+
if (url5) {
|
|
181
|
+
if (!url5.path) {
|
|
182
182
|
return aPath;
|
|
183
183
|
}
|
|
184
|
-
path7 =
|
|
184
|
+
path7 = url5.path;
|
|
185
185
|
}
|
|
186
186
|
var isAbsolute = exports2.isAbsolute(path7);
|
|
187
187
|
var parts = path7.split(/\/+/);
|
|
@@ -205,9 +205,9 @@ var require_util = __commonJS({
|
|
|
205
205
|
if (path7 === "") {
|
|
206
206
|
path7 = isAbsolute ? "/" : ".";
|
|
207
207
|
}
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
return urlGenerate(
|
|
208
|
+
if (url5) {
|
|
209
|
+
url5.path = path7;
|
|
210
|
+
return urlGenerate(url5);
|
|
211
211
|
}
|
|
212
212
|
return path7;
|
|
213
213
|
}
|
|
@@ -1285,13 +1285,13 @@ var require_source_map_consumer = __commonJS({
|
|
|
1285
1285
|
if (this.sourceRoot != null) {
|
|
1286
1286
|
relativeSource = util.relative(this.sourceRoot, relativeSource);
|
|
1287
1287
|
}
|
|
1288
|
-
var
|
|
1289
|
-
if (this.sourceRoot != null && (
|
|
1288
|
+
var url5;
|
|
1289
|
+
if (this.sourceRoot != null && (url5 = util.urlParse(this.sourceRoot))) {
|
|
1290
1290
|
var fileUriAbsPath = relativeSource.replace(/^file:\/\//, "");
|
|
1291
|
-
if (
|
|
1291
|
+
if (url5.scheme == "file" && this._sources.has(fileUriAbsPath)) {
|
|
1292
1292
|
return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)];
|
|
1293
1293
|
}
|
|
1294
|
-
if ((!
|
|
1294
|
+
if ((!url5.path || url5.path == "/") && this._sources.has("/" + relativeSource)) {
|
|
1295
1295
|
return this.sourcesContent[this._sources.indexOf("/" + relativeSource)];
|
|
1296
1296
|
}
|
|
1297
1297
|
}
|
|
@@ -1924,17 +1924,17 @@ var require_source_map_support = __commonJS({
|
|
|
1924
1924
|
}
|
|
1925
1925
|
return fileContentsCache[path8] = contents;
|
|
1926
1926
|
});
|
|
1927
|
-
function supportRelativeURL(file2,
|
|
1928
|
-
if (!file2) return
|
|
1927
|
+
function supportRelativeURL(file2, url5) {
|
|
1928
|
+
if (!file2) return url5;
|
|
1929
1929
|
var dir = path7.dirname(file2);
|
|
1930
1930
|
var match2 = /^\w+:\/\/[^\/]*/.exec(dir);
|
|
1931
1931
|
var protocol = match2 ? match2[0] : "";
|
|
1932
1932
|
var startPath = dir.slice(protocol.length);
|
|
1933
1933
|
if (protocol && /^\/\w\:/.test(startPath)) {
|
|
1934
1934
|
protocol += "/";
|
|
1935
|
-
return protocol + path7.resolve(dir.slice(protocol.length),
|
|
1935
|
+
return protocol + path7.resolve(dir.slice(protocol.length), url5).replace(/\\/g, "/");
|
|
1936
1936
|
}
|
|
1937
|
-
return protocol + path7.resolve(dir.slice(protocol.length),
|
|
1937
|
+
return protocol + path7.resolve(dir.slice(protocol.length), url5);
|
|
1938
1938
|
}
|
|
1939
1939
|
function retrieveSourceMapURL(source) {
|
|
1940
1940
|
var fileData;
|
|
@@ -1992,8 +1992,8 @@ var require_source_map_support = __commonJS({
|
|
|
1992
1992
|
sourceMap.map.sources.forEach(function(source, i) {
|
|
1993
1993
|
var contents = sourceMap.map.sourcesContent[i];
|
|
1994
1994
|
if (contents) {
|
|
1995
|
-
var
|
|
1996
|
-
fileContentsCache[
|
|
1995
|
+
var url5 = supportRelativeURL(sourceMap.url, source);
|
|
1996
|
+
fileContentsCache[url5] = contents;
|
|
1997
1997
|
}
|
|
1998
1998
|
});
|
|
1999
1999
|
}
|
|
@@ -4172,14 +4172,70 @@ var require_src = __commonJS({
|
|
|
4172
4172
|
|
|
4173
4173
|
// packages/playwright/src/transform/esmLoader.ts
|
|
4174
4174
|
var import_fs6 = __toESM(require("fs"));
|
|
4175
|
-
var
|
|
4175
|
+
var import_url4 = __toESM(require("url"));
|
|
4176
4176
|
|
|
4177
4177
|
// packages/playwright/src/transform/compilationCache.ts
|
|
4178
4178
|
var import_fs = __toESM(require("fs"));
|
|
4179
4179
|
var import_os = __toESM(require("os"));
|
|
4180
4180
|
var import_path = __toESM(require("path"));
|
|
4181
|
+
var import_url = __toESM(require("url"));
|
|
4181
4182
|
var import_source_map_support = __toESM(require_source_map_support());
|
|
4182
4183
|
|
|
4184
|
+
// packages/isomorphic/multimap.ts
|
|
4185
|
+
var MultiMap = class {
|
|
4186
|
+
constructor() {
|
|
4187
|
+
this._map = /* @__PURE__ */ new Map();
|
|
4188
|
+
}
|
|
4189
|
+
set(key, value) {
|
|
4190
|
+
let values = this._map.get(key);
|
|
4191
|
+
if (!values) {
|
|
4192
|
+
values = [];
|
|
4193
|
+
this._map.set(key, values);
|
|
4194
|
+
}
|
|
4195
|
+
values.push(value);
|
|
4196
|
+
}
|
|
4197
|
+
get(key) {
|
|
4198
|
+
return this._map.get(key) || [];
|
|
4199
|
+
}
|
|
4200
|
+
has(key) {
|
|
4201
|
+
return this._map.has(key);
|
|
4202
|
+
}
|
|
4203
|
+
delete(key, value) {
|
|
4204
|
+
const values = this._map.get(key);
|
|
4205
|
+
if (!values)
|
|
4206
|
+
return;
|
|
4207
|
+
if (values.includes(value))
|
|
4208
|
+
this._map.set(key, values.filter((v) => value !== v));
|
|
4209
|
+
}
|
|
4210
|
+
deleteAll(key) {
|
|
4211
|
+
this._map.delete(key);
|
|
4212
|
+
}
|
|
4213
|
+
hasValue(key, value) {
|
|
4214
|
+
const values = this._map.get(key);
|
|
4215
|
+
if (!values)
|
|
4216
|
+
return false;
|
|
4217
|
+
return values.includes(value);
|
|
4218
|
+
}
|
|
4219
|
+
get size() {
|
|
4220
|
+
return this._map.size;
|
|
4221
|
+
}
|
|
4222
|
+
[Symbol.iterator]() {
|
|
4223
|
+
return this._map[Symbol.iterator]();
|
|
4224
|
+
}
|
|
4225
|
+
keys() {
|
|
4226
|
+
return this._map.keys();
|
|
4227
|
+
}
|
|
4228
|
+
values() {
|
|
4229
|
+
const result2 = [];
|
|
4230
|
+
for (const key of this.keys())
|
|
4231
|
+
result2.push(...this.get(key));
|
|
4232
|
+
return result2;
|
|
4233
|
+
}
|
|
4234
|
+
clear() {
|
|
4235
|
+
this._map.clear();
|
|
4236
|
+
}
|
|
4237
|
+
};
|
|
4238
|
+
|
|
4183
4239
|
// packages/utils/crypto.ts
|
|
4184
4240
|
var import_crypto = __toESM(require("crypto"));
|
|
4185
4241
|
function calculateSha1(buffer) {
|
|
@@ -4191,7 +4247,7 @@ function calculateSha1(buffer) {
|
|
|
4191
4247
|
// packages/playwright/src/transform/compilationCache.ts
|
|
4192
4248
|
var import_globals = require("../globals");
|
|
4193
4249
|
var import_package = require("../package");
|
|
4194
|
-
var cacheDir = process.env.PWTEST_CACHE_DIR || (() => {
|
|
4250
|
+
var cacheDir = process.env.PLAYWRIGHT_TRANSFORM_CACHE_DIR || process.env.PWTEST_CACHE_DIR || (() => {
|
|
4195
4251
|
if (process.platform === "win32")
|
|
4196
4252
|
return import_path.default.join(import_os.default.tmpdir(), `playwright-transform-cache`);
|
|
4197
4253
|
return import_path.default.join(import_os.default.tmpdir(), `playwright-transform-cache-` + process.geteuid?.());
|
|
@@ -4199,7 +4255,6 @@ var cacheDir = process.env.PWTEST_CACHE_DIR || (() => {
|
|
|
4199
4255
|
var sourceMaps = /* @__PURE__ */ new Map();
|
|
4200
4256
|
var memoryCache = /* @__PURE__ */ new Map();
|
|
4201
4257
|
var fileDependencies = /* @__PURE__ */ new Map();
|
|
4202
|
-
var externalDependencies = /* @__PURE__ */ new Map();
|
|
4203
4258
|
function installSourceMapSupport() {
|
|
4204
4259
|
Error.stackTraceLimit = 200;
|
|
4205
4260
|
import_source_map_support.default.install({
|
|
@@ -4262,25 +4317,22 @@ function getFromCompilationCache(filename, contentHash, moduleUrl) {
|
|
|
4262
4317
|
const cachePath = calculateCachePath(filename, cacheFolderName, hashPrefix);
|
|
4263
4318
|
const codePath = cachePath + ".js";
|
|
4264
4319
|
const sourceMapPath = cachePath + ".map";
|
|
4265
|
-
const dataPath = cachePath + ".data";
|
|
4266
4320
|
try {
|
|
4267
4321
|
const cachedCode = readCodeCache(codePath);
|
|
4268
|
-
const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath,
|
|
4322
|
+
const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, moduleUrl });
|
|
4269
4323
|
return { cachedCode, serializedCache };
|
|
4270
4324
|
} catch {
|
|
4271
4325
|
}
|
|
4272
4326
|
return {
|
|
4273
|
-
addToCache: (code, map
|
|
4327
|
+
addToCache: (code, map) => {
|
|
4274
4328
|
if ((0, import_globals.isWorkerProcess)())
|
|
4275
4329
|
return {};
|
|
4276
4330
|
clearOldCacheEntries(cacheFolderName, filePathHash);
|
|
4277
4331
|
import_fs.default.mkdirSync(import_path.default.dirname(cachePath), { recursive: true });
|
|
4278
4332
|
if (map)
|
|
4279
4333
|
import_fs.default.writeFileSync(sourceMapPath, JSON.stringify(map), "utf8");
|
|
4280
|
-
if (data.size)
|
|
4281
|
-
import_fs.default.writeFileSync(dataPath, JSON.stringify(Object.fromEntries(data.entries()), void 0, 2), "utf8");
|
|
4282
4334
|
writeCodeCache(codePath, code);
|
|
4283
|
-
const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath,
|
|
4335
|
+
const serializedCache = _innerAddToCompilationCacheAndSerialize(filename, { codePath, sourceMapPath, moduleUrl });
|
|
4284
4336
|
return { serializedCache };
|
|
4285
4337
|
}
|
|
4286
4338
|
};
|
|
@@ -4289,8 +4341,7 @@ function serializeCompilationCache() {
|
|
|
4289
4341
|
return {
|
|
4290
4342
|
sourceMaps: [...sourceMaps.entries()],
|
|
4291
4343
|
memoryCache: [...memoryCache.entries()],
|
|
4292
|
-
fileDependencies: [...fileDependencies.entries()].map(([filename, deps]) => [filename, [...deps]])
|
|
4293
|
-
externalDependencies: [...externalDependencies.entries()].map(([filename, deps]) => [filename, [...deps]])
|
|
4344
|
+
fileDependencies: [...fileDependencies.entries()].map(([filename, deps]) => [filename, [...deps]])
|
|
4294
4345
|
};
|
|
4295
4346
|
}
|
|
4296
4347
|
function addToCompilationCache(payload) {
|
|
@@ -4302,10 +4353,6 @@ function addToCompilationCache(payload) {
|
|
|
4302
4353
|
const existing = fileDependencies.get(entry[0]) || [];
|
|
4303
4354
|
fileDependencies.set(entry[0], /* @__PURE__ */ new Set([...entry[1], ...existing]));
|
|
4304
4355
|
}
|
|
4305
|
-
for (const entry of payload.externalDependencies) {
|
|
4306
|
-
const existing = externalDependencies.get(entry[0]) || [];
|
|
4307
|
-
externalDependencies.set(entry[0], /* @__PURE__ */ new Set([...entry[1], ...existing]));
|
|
4308
|
-
}
|
|
4309
4356
|
}
|
|
4310
4357
|
function calculateFilePathHash(filePath) {
|
|
4311
4358
|
return calculateSha1(filePath).substring(0, 10);
|
|
@@ -4324,12 +4371,30 @@ function clearOldCacheEntries(cacheFolderName, filePathHash) {
|
|
|
4324
4371
|
}
|
|
4325
4372
|
}
|
|
4326
4373
|
var depsCollector2;
|
|
4374
|
+
var importGraph = new MultiMap();
|
|
4375
|
+
function recordResolvedFile(resolvedUrl, parentUrl) {
|
|
4376
|
+
if ((0, import_globals.isWorkerProcess)() || !resolvedUrl?.startsWith("file://"))
|
|
4377
|
+
return;
|
|
4378
|
+
const child = import_url.default.fileURLToPath(resolvedUrl);
|
|
4379
|
+
depsCollector2?.add(child);
|
|
4380
|
+
if (!parentUrl?.startsWith("file://"))
|
|
4381
|
+
return;
|
|
4382
|
+
const parent = import_url.default.fileURLToPath(parentUrl);
|
|
4383
|
+
if (!belongsToNodeModules(parent) && !importGraph.hasValue(parent, child))
|
|
4384
|
+
importGraph.set(parent, child);
|
|
4385
|
+
}
|
|
4327
4386
|
function startCollectingFileDeps() {
|
|
4328
4387
|
depsCollector2 = /* @__PURE__ */ new Set();
|
|
4329
4388
|
}
|
|
4330
|
-
function stopCollectingFileDeps(filename) {
|
|
4389
|
+
function stopCollectingFileDeps(filename, additionalDeps = []) {
|
|
4331
4390
|
if (!depsCollector2)
|
|
4332
4391
|
return;
|
|
4392
|
+
for (const dep of additionalDeps)
|
|
4393
|
+
depsCollector2.add(dep);
|
|
4394
|
+
for (const dep of depsCollector2) {
|
|
4395
|
+
for (const child of importGraph.get(dep))
|
|
4396
|
+
depsCollector2.add(child);
|
|
4397
|
+
}
|
|
4333
4398
|
depsCollector2.delete(filename);
|
|
4334
4399
|
for (const dep of depsCollector2) {
|
|
4335
4400
|
if (belongsToNodeModules(dep))
|
|
@@ -4341,6 +4406,9 @@ function stopCollectingFileDeps(filename) {
|
|
|
4341
4406
|
function currentFileDepsCollector() {
|
|
4342
4407
|
return depsCollector2;
|
|
4343
4408
|
}
|
|
4409
|
+
function dependenciesForTestFile(filename) {
|
|
4410
|
+
return fileDependencies.get(filename) || /* @__PURE__ */ new Set();
|
|
4411
|
+
}
|
|
4344
4412
|
var kPlaywrightInternalPrefix = import_package.packageRoot;
|
|
4345
4413
|
function belongsToNodeModules(file2) {
|
|
4346
4414
|
if (file2.includes(`${import_path.default.sep}node_modules${import_path.default.sep}`))
|
|
@@ -4396,7 +4464,7 @@ var PortTransport = class {
|
|
|
4396
4464
|
var import_fs5 = __toESM(require("fs"));
|
|
4397
4465
|
var import_module2 = __toESM(require("module"));
|
|
4398
4466
|
var import_path5 = __toESM(require("path"));
|
|
4399
|
-
var
|
|
4467
|
+
var import_url3 = __toESM(require("url"));
|
|
4400
4468
|
var import_crypto5 = __toESM(require("crypto"));
|
|
4401
4469
|
var import_source_map_support2 = __toESM(require_source_map_support());
|
|
4402
4470
|
|
|
@@ -4404,6 +4472,7 @@ var import_source_map_support2 = __toESM(require_source_map_support());
|
|
|
4404
4472
|
var import_path2 = __toESM(require("path"));
|
|
4405
4473
|
var import_fs2 = __toESM(require("fs"));
|
|
4406
4474
|
var import_json5 = __toESM(require_lib());
|
|
4475
|
+
var jsxOptionNames = ["jsx", "jsxFactory", "jsxFragmentFactory", "jsxImportSource"];
|
|
4407
4476
|
function loadTsConfig(configPath) {
|
|
4408
4477
|
try {
|
|
4409
4478
|
const references = [];
|
|
@@ -4415,13 +4484,26 @@ ${e.message}`);
|
|
|
4415
4484
|
}
|
|
4416
4485
|
}
|
|
4417
4486
|
function resolveConfigFile(baseConfigFile, referencedConfigFile) {
|
|
4418
|
-
if (!referencedConfigFile.endsWith(".json"))
|
|
4419
|
-
referencedConfigFile += ".json";
|
|
4420
4487
|
const currentDir = import_path2.default.dirname(baseConfigFile);
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4488
|
+
const referencedFile = referencedConfigFile.endsWith(".json") ? referencedConfigFile : referencedConfigFile + ".json";
|
|
4489
|
+
const resolvedConfigFile = import_path2.default.resolve(currentDir, referencedFile);
|
|
4490
|
+
if (import_fs2.default.existsSync(resolvedConfigFile) || referencedConfigFile.startsWith(".") || import_path2.default.isAbsolute(referencedConfigFile))
|
|
4491
|
+
return resolvedConfigFile;
|
|
4492
|
+
const packageDir = import_path2.default.join(currentDir, "node_modules", referencedConfigFile);
|
|
4493
|
+
const candidates = [import_path2.default.join(currentDir, "node_modules", referencedFile)];
|
|
4494
|
+
const packageTsconfig = packageJsonTsconfigField(import_path2.default.join(packageDir, "package.json"));
|
|
4495
|
+
if (packageTsconfig)
|
|
4496
|
+
candidates.push(import_path2.default.resolve(packageDir, packageTsconfig));
|
|
4497
|
+
candidates.push(import_path2.default.join(packageDir, "tsconfig.json"));
|
|
4498
|
+
return candidates.find((candidate) => import_fs2.default.existsSync(candidate)) ?? resolvedConfigFile;
|
|
4499
|
+
}
|
|
4500
|
+
function packageJsonTsconfigField(packageJsonFile) {
|
|
4501
|
+
try {
|
|
4502
|
+
const tsconfig = JSON.parse(import_fs2.default.readFileSync(packageJsonFile, "utf8")).tsconfig;
|
|
4503
|
+
return typeof tsconfig === "string" ? tsconfig : void 0;
|
|
4504
|
+
} catch {
|
|
4505
|
+
return void 0;
|
|
4506
|
+
}
|
|
4425
4507
|
}
|
|
4426
4508
|
function innerLoadTsConfig(configFilePath, references, visited = /* @__PURE__ */ new Map()) {
|
|
4427
4509
|
if (visited.has(configFilePath))
|
|
@@ -4443,6 +4525,14 @@ function innerLoadTsConfig(configFilePath, references, visited = /* @__PURE__ */
|
|
|
4443
4525
|
}
|
|
4444
4526
|
if (parsedConfig.compilerOptions?.allowJs !== void 0)
|
|
4445
4527
|
result2.allowJs = parsedConfig.compilerOptions.allowJs;
|
|
4528
|
+
for (const name of jsxOptionNames) {
|
|
4529
|
+
if (parsedConfig.compilerOptions?.[name] !== void 0)
|
|
4530
|
+
result2[name] = parsedConfig.compilerOptions[name];
|
|
4531
|
+
}
|
|
4532
|
+
if (parsedConfig.compilerOptions?.target !== void 0)
|
|
4533
|
+
result2.target = parsedConfig.compilerOptions.target;
|
|
4534
|
+
if (parsedConfig.compilerOptions?.useDefineForClassFields !== void 0)
|
|
4535
|
+
result2.useDefineForClassFields = parsedConfig.compilerOptions.useDefineForClassFields;
|
|
4446
4536
|
if (parsedConfig.compilerOptions?.paths !== void 0) {
|
|
4447
4537
|
result2.paths = {
|
|
4448
4538
|
mapping: parsedConfig.compilerOptions.paths,
|
|
@@ -5726,6 +5816,9 @@ var closePattern = /\\}/g;
|
|
|
5726
5816
|
var commaPattern = /\\,/g;
|
|
5727
5817
|
var periodPattern = /\\\./g;
|
|
5728
5818
|
var EXPANSION_MAX = 1e5;
|
|
5819
|
+
var EXPANSION_MAX_LENGTH = 4e6;
|
|
5820
|
+
var EXPANSION_MAX_DEPTH = 1e3;
|
|
5821
|
+
var EXPANSION_MAX_REWRITES = 1e3;
|
|
5729
5822
|
function numeric(str) {
|
|
5730
5823
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
|
5731
5824
|
}
|
|
@@ -5735,36 +5828,44 @@ function escapeBraces(str) {
|
|
|
5735
5828
|
function unescapeBraces(str) {
|
|
5736
5829
|
return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
|
|
5737
5830
|
}
|
|
5738
|
-
function
|
|
5739
|
-
|
|
5740
|
-
|
|
5831
|
+
function pushAll(target, items) {
|
|
5832
|
+
for (let i = 0; i < items.length; i++) {
|
|
5833
|
+
target.push(items[i]);
|
|
5741
5834
|
}
|
|
5835
|
+
}
|
|
5836
|
+
function parseCommaParts(str) {
|
|
5742
5837
|
const parts = [];
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
;
|
|
5753
|
-
p
|
|
5754
|
-
p
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5838
|
+
let carry = "";
|
|
5839
|
+
for (; ; ) {
|
|
5840
|
+
const m = balanced("{", "}", str);
|
|
5841
|
+
if (!m) {
|
|
5842
|
+
const tail = str.split(",");
|
|
5843
|
+
tail[0] = carry + tail[0];
|
|
5844
|
+
pushAll(parts, tail);
|
|
5845
|
+
return parts;
|
|
5846
|
+
}
|
|
5847
|
+
const { pre, body, post } = m;
|
|
5848
|
+
const p = pre.split(",");
|
|
5849
|
+
p[0] = carry + p[0];
|
|
5850
|
+
p[p.length - 1] += "{" + body + "}";
|
|
5851
|
+
if (!post.length) {
|
|
5852
|
+
pushAll(parts, p);
|
|
5853
|
+
return parts;
|
|
5854
|
+
}
|
|
5855
|
+
carry = p.pop();
|
|
5856
|
+
pushAll(parts, p);
|
|
5857
|
+
str = post;
|
|
5858
|
+
}
|
|
5758
5859
|
}
|
|
5759
5860
|
function expand(str, options = {}) {
|
|
5760
5861
|
if (!str) {
|
|
5761
5862
|
return [];
|
|
5762
5863
|
}
|
|
5763
|
-
const { max = EXPANSION_MAX } = options;
|
|
5864
|
+
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
|
|
5764
5865
|
if (str.slice(0, 2) === "{}") {
|
|
5765
5866
|
str = "\\{\\}" + str.slice(2);
|
|
5766
5867
|
}
|
|
5767
|
-
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
5868
|
+
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
|
5768
5869
|
}
|
|
5769
5870
|
function embrace(str) {
|
|
5770
5871
|
return "{" + str + "}";
|
|
@@ -5778,99 +5879,152 @@ function lte(i, y) {
|
|
|
5778
5879
|
function gte(i, y) {
|
|
5779
5880
|
return i >= y;
|
|
5780
5881
|
}
|
|
5781
|
-
function
|
|
5782
|
-
const
|
|
5882
|
+
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
|
5883
|
+
const out = [];
|
|
5884
|
+
let length = 0;
|
|
5885
|
+
for (let a = 0; a < acc.length; a++) {
|
|
5886
|
+
for (let v = 0; v < values.length; v++) {
|
|
5887
|
+
if (out.length >= max)
|
|
5888
|
+
return out;
|
|
5889
|
+
const expansion = acc[a] + pre + values[v];
|
|
5890
|
+
if (dropEmpties && !expansion)
|
|
5891
|
+
continue;
|
|
5892
|
+
if (length + expansion.length > maxLength)
|
|
5893
|
+
return out;
|
|
5894
|
+
out.push(expansion);
|
|
5895
|
+
length += expansion.length;
|
|
5896
|
+
}
|
|
5897
|
+
}
|
|
5898
|
+
return out;
|
|
5899
|
+
}
|
|
5900
|
+
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|
5901
|
+
const n = body.split(/\.\./);
|
|
5902
|
+
const N = [];
|
|
5903
|
+
if (n[0] === void 0 || n[1] === void 0) {
|
|
5904
|
+
return N;
|
|
5905
|
+
}
|
|
5906
|
+
const x = numeric(n[0]);
|
|
5907
|
+
const y = numeric(n[1]);
|
|
5908
|
+
const width = Math.max(n[0].length, n[1].length);
|
|
5909
|
+
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
5910
|
+
let test = lte;
|
|
5911
|
+
const reverse = y < x;
|
|
5912
|
+
if (reverse) {
|
|
5913
|
+
incr *= -1;
|
|
5914
|
+
test = gte;
|
|
5915
|
+
}
|
|
5916
|
+
const pad = n.some(isPadded);
|
|
5917
|
+
let length = 0;
|
|
5918
|
+
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
|
5919
|
+
let c;
|
|
5920
|
+
if (isAlphaSequence) {
|
|
5921
|
+
c = String.fromCharCode(i);
|
|
5922
|
+
if (c === "\\") {
|
|
5923
|
+
c = "";
|
|
5924
|
+
}
|
|
5925
|
+
} else {
|
|
5926
|
+
c = String(i);
|
|
5927
|
+
if (pad) {
|
|
5928
|
+
const need = width - c.length;
|
|
5929
|
+
if (need > 0) {
|
|
5930
|
+
const z = new Array(need + 1).join("0");
|
|
5931
|
+
if (i < 0) {
|
|
5932
|
+
c = "-" + z + c.slice(1);
|
|
5933
|
+
} else {
|
|
5934
|
+
c = z + c;
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5938
|
+
}
|
|
5939
|
+
if (length + c.length > maxLength)
|
|
5940
|
+
break;
|
|
5941
|
+
N.push(c);
|
|
5942
|
+
length += c.length;
|
|
5943
|
+
}
|
|
5944
|
+
return N;
|
|
5945
|
+
}
|
|
5946
|
+
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
5947
|
+
if (depth > maxDepth) {
|
|
5948
|
+
return [str];
|
|
5949
|
+
}
|
|
5950
|
+
let acc = [""];
|
|
5951
|
+
let rewrites = 0;
|
|
5952
|
+
let dropEmpties = false;
|
|
5953
|
+
let firstGroup = true;
|
|
5783
5954
|
for (; ; ) {
|
|
5784
5955
|
const m = balanced("{", "}", str);
|
|
5785
|
-
if (!m)
|
|
5786
|
-
return [
|
|
5956
|
+
if (!m) {
|
|
5957
|
+
return combine(acc, str, [""], max, maxLength, dropEmpties);
|
|
5958
|
+
}
|
|
5787
5959
|
const pre = m.pre;
|
|
5788
|
-
if (/\$$/.test(
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5960
|
+
if (/\$$/.test(pre)) {
|
|
5961
|
+
acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
|
|
5962
|
+
firstGroup = false;
|
|
5963
|
+
if (!m.post.length)
|
|
5964
|
+
break;
|
|
5965
|
+
str = m.post;
|
|
5966
|
+
continue;
|
|
5795
5967
|
}
|
|
5796
5968
|
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
5797
5969
|
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
5798
5970
|
const isSequence = isNumericSequence || isAlphaSequence;
|
|
5799
5971
|
const isOptions = m.body.indexOf(",") >= 0;
|
|
5800
5972
|
if (!isSequence && !isOptions) {
|
|
5801
|
-
if (m.post.match(/,(?!,).*\}/)) {
|
|
5973
|
+
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
|
5974
|
+
rewrites++;
|
|
5802
5975
|
str = m.pre + "{" + m.body + escClose + m.post;
|
|
5803
5976
|
isTop = true;
|
|
5804
5977
|
continue;
|
|
5805
5978
|
}
|
|
5806
|
-
return [
|
|
5979
|
+
return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
|
|
5807
5980
|
}
|
|
5808
|
-
|
|
5809
|
-
|
|
5981
|
+
if (firstGroup) {
|
|
5982
|
+
dropEmpties = isTop && !isSequence;
|
|
5983
|
+
firstGroup = false;
|
|
5984
|
+
}
|
|
5985
|
+
let values;
|
|
5810
5986
|
if (isSequence) {
|
|
5811
|
-
|
|
5987
|
+
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
5812
5988
|
} else {
|
|
5813
|
-
n = parseCommaParts(m.body);
|
|
5989
|
+
let n = parseCommaParts(m.body);
|
|
5814
5990
|
if (n.length === 1 && n[0] !== void 0) {
|
|
5815
|
-
n = expand_(n[0], max, false).map(embrace);
|
|
5991
|
+
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
|
5816
5992
|
if (n.length === 1) {
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
|
|
5823
|
-
const x = numeric(n[0]);
|
|
5824
|
-
const y = numeric(n[1]);
|
|
5825
|
-
const width = Math.max(n[0].length, n[1].length);
|
|
5826
|
-
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
5827
|
-
let test = lte;
|
|
5828
|
-
const reverse = y < x;
|
|
5829
|
-
if (reverse) {
|
|
5830
|
-
incr *= -1;
|
|
5831
|
-
test = gte;
|
|
5832
|
-
}
|
|
5833
|
-
const pad = n.some(isPadded);
|
|
5834
|
-
N = [];
|
|
5835
|
-
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
|
5836
|
-
let c;
|
|
5837
|
-
if (isAlphaSequence) {
|
|
5838
|
-
c = String.fromCharCode(i);
|
|
5839
|
-
if (c === "\\") {
|
|
5840
|
-
c = "";
|
|
5841
|
-
}
|
|
5842
|
-
} else {
|
|
5843
|
-
c = String(i);
|
|
5844
|
-
if (pad) {
|
|
5845
|
-
const need = width - c.length;
|
|
5846
|
-
if (need > 0) {
|
|
5847
|
-
const z = new Array(need + 1).join("0");
|
|
5848
|
-
if (i < 0) {
|
|
5849
|
-
c = "-" + z + c.slice(1);
|
|
5850
|
-
} else {
|
|
5851
|
-
c = z + c;
|
|
5852
|
-
}
|
|
5853
|
-
}
|
|
5854
|
-
}
|
|
5993
|
+
acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
|
|
5994
|
+
if (!m.post.length)
|
|
5995
|
+
break;
|
|
5996
|
+
str = m.post;
|
|
5997
|
+
continue;
|
|
5855
5998
|
}
|
|
5856
|
-
N.push(c);
|
|
5857
5999
|
}
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
6000
|
+
let dropsEmpties = dropEmpties && !m.post.length && !pre;
|
|
6001
|
+
for (let d = 0; dropsEmpties && d < acc.length; d++) {
|
|
6002
|
+
if (acc[d]) {
|
|
6003
|
+
dropsEmpties = false;
|
|
6004
|
+
}
|
|
5862
6005
|
}
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
for (let
|
|
5866
|
-
const
|
|
5867
|
-
|
|
5868
|
-
|
|
6006
|
+
values = [];
|
|
6007
|
+
let valuesLength = 0;
|
|
6008
|
+
outer: for (let j = 0; j < n.length; j++) {
|
|
6009
|
+
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
|
6010
|
+
for (let k = 0; k < expanded.length; k++) {
|
|
6011
|
+
const v = expanded[k];
|
|
6012
|
+
if (dropsEmpties && !v)
|
|
6013
|
+
continue;
|
|
6014
|
+
if (values.length >= max || valuesLength + v.length > maxLength) {
|
|
6015
|
+
break outer;
|
|
6016
|
+
}
|
|
6017
|
+
values.push(v);
|
|
6018
|
+
valuesLength += v.length;
|
|
5869
6019
|
}
|
|
5870
6020
|
}
|
|
5871
6021
|
}
|
|
5872
|
-
|
|
6022
|
+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
|
6023
|
+
if (!m.post.length)
|
|
6024
|
+
break;
|
|
6025
|
+
str = m.post;
|
|
5873
6026
|
}
|
|
6027
|
+
return acc;
|
|
5874
6028
|
}
|
|
5875
6029
|
|
|
5876
6030
|
// node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
@@ -7633,18 +7787,17 @@ function dirExists(resolved) {
|
|
|
7633
7787
|
|
|
7634
7788
|
// packages/playwright/src/transform/esmLoaderSync.ts
|
|
7635
7789
|
var import_fs4 = __toESM(require("fs"));
|
|
7636
|
-
var
|
|
7790
|
+
var import_url2 = __toESM(require("url"));
|
|
7637
7791
|
function resolve(specifier, context, nextResolve) {
|
|
7638
7792
|
if (context.parentURL && context.parentURL.startsWith("file://")) {
|
|
7639
|
-
const filename =
|
|
7793
|
+
const filename = import_url2.default.fileURLToPath(context.parentURL);
|
|
7640
7794
|
const resolved = resolveHook(filename, specifier);
|
|
7641
7795
|
if (resolved !== void 0) {
|
|
7642
|
-
specifier = new Set(context.conditions).has("import") ?
|
|
7796
|
+
specifier = new Set(context.conditions).has("import") ? import_url2.default.pathToFileURL(resolved).toString() : resolved;
|
|
7643
7797
|
}
|
|
7644
7798
|
}
|
|
7645
7799
|
const result2 = nextResolve(specifier, context);
|
|
7646
|
-
|
|
7647
|
-
currentFileDepsCollector()?.add(import_url.default.fileURLToPath(result2.url));
|
|
7800
|
+
recordResolvedFile(result2?.url, context.parentURL);
|
|
7648
7801
|
return result2;
|
|
7649
7802
|
}
|
|
7650
7803
|
var kSupportedFormats = /* @__PURE__ */ new Map([
|
|
@@ -7661,8 +7814,10 @@ function load(moduleUrl, context, nextLoad) {
|
|
|
7661
7814
|
return nextLoad(moduleUrl, context);
|
|
7662
7815
|
if (!moduleUrl.startsWith("file://"))
|
|
7663
7816
|
return nextLoad(moduleUrl, context);
|
|
7664
|
-
const filename =
|
|
7665
|
-
if (
|
|
7817
|
+
const filename = import_url2.default.fileURLToPath(moduleUrl);
|
|
7818
|
+
if (isStyleFile(filename))
|
|
7819
|
+
return { format: "commonjs", source: "", shortCircuit: true };
|
|
7820
|
+
if (!shouldTransform(filename) || !hasTransformedExtension(filename))
|
|
7666
7821
|
return nextLoad(moduleUrl, context);
|
|
7667
7822
|
const isRequire = !new Set(context.conditions).has("import");
|
|
7668
7823
|
const format = isRequire ? "commonjs" : kSupportedFormats.get(context.format) || (fileIsModule(filename) ? "module" : "commonjs");
|
|
@@ -7706,7 +7861,6 @@ function addHook(transformHook2, shouldTransform2, extensions) {
|
|
|
7706
7861
|
var version = import_package2.packageJSON.version;
|
|
7707
7862
|
var cachedTSConfigs = /* @__PURE__ */ new Map();
|
|
7708
7863
|
var _transformConfig = {
|
|
7709
|
-
babelPlugins: [],
|
|
7710
7864
|
external: []
|
|
7711
7865
|
};
|
|
7712
7866
|
var _externalMatcher = () => false;
|
|
@@ -7729,9 +7883,21 @@ function validateTsConfig(tsconfig) {
|
|
|
7729
7883
|
return {
|
|
7730
7884
|
allowJs: !!tsconfig.allowJs,
|
|
7731
7885
|
pathsBase,
|
|
7732
|
-
paths: Object.entries(tsconfig.paths?.mapping || {}).map(([key, values]) => ({ key, values })).concat(pathsFallback)
|
|
7886
|
+
paths: Object.entries(tsconfig.paths?.mapping || {}).map(([key, values]) => ({ key, values })).concat(pathsFallback),
|
|
7887
|
+
jsx: tsconfig.jsx ? {
|
|
7888
|
+
jsx: tsconfig.jsx.toLowerCase(),
|
|
7889
|
+
jsxFactory: tsconfig.jsxFactory,
|
|
7890
|
+
jsxFragmentFactory: tsconfig.jsxFragmentFactory,
|
|
7891
|
+
jsxImportSource: tsconfig.jsxImportSource
|
|
7892
|
+
} : void 0,
|
|
7893
|
+
useDefineForClassFields: tsconfig.useDefineForClassFields ?? (tsconfig.target ? targetUsesDefineForClassFields(tsconfig.target) : void 0)
|
|
7733
7894
|
};
|
|
7734
7895
|
}
|
|
7896
|
+
function targetUsesDefineForClassFields(target) {
|
|
7897
|
+
const normalized = target.toLowerCase();
|
|
7898
|
+
const year = normalized.match(/^es(\d{4})$/)?.[1];
|
|
7899
|
+
return normalized === "esnext" || !!year && +year >= 2022;
|
|
7900
|
+
}
|
|
7735
7901
|
function loadAndValidateTsconfigsForFile(file2) {
|
|
7736
7902
|
if (_singleTSConfigPath && !_singleTSConfig)
|
|
7737
7903
|
_singleTSConfig = loadTsConfig(_singleTSConfigPath).map(validateTsConfig);
|
|
@@ -7826,47 +7992,48 @@ function resolveHook(filename, specifier) {
|
|
|
7826
7992
|
return resolveImportSpecifierAfterMapping(specifier, false);
|
|
7827
7993
|
}
|
|
7828
7994
|
}
|
|
7995
|
+
var kStyleExtensions = [".css", ".less", ".scss"];
|
|
7996
|
+
function isStyleFile(filename) {
|
|
7997
|
+
return kStyleExtensions.includes(import_path5.default.extname(filename));
|
|
7998
|
+
}
|
|
7829
7999
|
function shouldTransform(filename) {
|
|
7830
8000
|
if (_externalMatcher(filename))
|
|
7831
8001
|
return false;
|
|
7832
8002
|
return !belongsToNodeModules(filename);
|
|
7833
8003
|
}
|
|
7834
|
-
var
|
|
7835
|
-
function
|
|
7836
|
-
|
|
8004
|
+
var kTransformedExtensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".mts", ".cjs", ".cts"];
|
|
8005
|
+
function hasTransformedExtension(filename) {
|
|
8006
|
+
const extension = import_path5.default.extname(filename);
|
|
8007
|
+
return !extension || kTransformedExtensions.includes(extension);
|
|
7837
8008
|
}
|
|
7838
8009
|
function transformHook(originalCode, filename, moduleUrl) {
|
|
7839
8010
|
const hasPreprocessor = process.env.PW_TEST_SOURCE_TRANSFORM && process.env.PW_TEST_SOURCE_TRANSFORM_SCOPE && process.env.PW_TEST_SOURCE_TRANSFORM_SCOPE.split(pathSeparator).some((f) => filename.startsWith(f));
|
|
7840
|
-
const pluginsPrologue = _transformConfig.babelPlugins;
|
|
7841
8011
|
const pluginsEpilogue = hasPreprocessor ? [[process.env.PW_TEST_SOURCE_TRANSFORM]] : [];
|
|
7842
|
-
const
|
|
8012
|
+
const tsconfigs = loadAndValidateTsconfigsForFile(filename);
|
|
8013
|
+
const jsx = tsconfigs.find((tsconfig) => tsconfig.jsx)?.jsx;
|
|
8014
|
+
const useDefineForClassFields = tsconfigs.find((tsconfig) => tsconfig.useDefineForClassFields !== void 0)?.useDefineForClassFields ?? true;
|
|
8015
|
+
const hash = calculateHash(originalCode, filename, !!moduleUrl, pluginsEpilogue, useDefineForClassFields, jsx);
|
|
7843
8016
|
const { cachedCode, addToCache, serializedCache } = getFromCompilationCache(filename, hash, moduleUrl);
|
|
7844
8017
|
if (cachedCode !== void 0)
|
|
7845
8018
|
return { code: cachedCode, serializedCache };
|
|
7846
8019
|
process.env.BROWSERSLIST_IGNORE_OLD_DATA = "true";
|
|
7847
8020
|
const { babelTransform } = require((0, import_package2.libPath)("transform", "babelBundle"));
|
|
7848
|
-
|
|
7849
|
-
const setTransformDataForPlugin = (key, value) => transformData.set(key, value);
|
|
7850
|
-
const wrappedPrologue = pluginsPrologue.map(([name, opts]) => [
|
|
7851
|
-
name,
|
|
7852
|
-
{ ...opts || {}, setTransformData: setTransformDataForPlugin }
|
|
7853
|
-
]);
|
|
7854
|
-
const babelResult = babelTransform(originalCode, filename, !!moduleUrl, wrappedPrologue, pluginsEpilogue, _transformConfig.jsxImportSource);
|
|
8021
|
+
const babelResult = babelTransform(originalCode, filename, !!moduleUrl, pluginsEpilogue, useDefineForClassFields, jsx);
|
|
7855
8022
|
if (!babelResult?.code)
|
|
7856
8023
|
return { code: originalCode, serializedCache };
|
|
7857
8024
|
const { code, map } = babelResult;
|
|
7858
|
-
const added = addToCache(code, map
|
|
8025
|
+
const added = addToCache(code, map);
|
|
7859
8026
|
return { code, serializedCache: added.serializedCache };
|
|
7860
8027
|
}
|
|
7861
|
-
function calculateHash(content, filePath, isModule2,
|
|
7862
|
-
const hash = import_crypto5.default.createHash("sha1").update(isModule2 ? "esm" : "no_esm").update(content).update(filePath).update(version).update(
|
|
8028
|
+
function calculateHash(content, filePath, isModule2, pluginsEpilogue, useDefineForClassFields, jsx) {
|
|
8029
|
+
const hash = import_crypto5.default.createHash("sha1").update(isModule2 ? "esm" : "no_esm").update(content).update(filePath).update(version).update(pluginsEpilogue.map((p) => p[0]).join(",")).update(useDefineForClassFields ? "define" : "assign").update(jsx ? JSON.stringify(jsx) : "").digest("hex");
|
|
7863
8030
|
return hash;
|
|
7864
8031
|
}
|
|
7865
8032
|
async function requireOrImport(file) {
|
|
7866
8033
|
installTransformIfNeeded();
|
|
7867
8034
|
const isModule = fileIsModule(file);
|
|
7868
8035
|
if (isModule) {
|
|
7869
|
-
const fileName =
|
|
8036
|
+
const fileName = import_url3.default.pathToFileURL(file);
|
|
7870
8037
|
const esmImport = () => eval(`import(${JSON.stringify(fileName)})`);
|
|
7871
8038
|
if (loaderChannel) {
|
|
7872
8039
|
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);
|
|
@@ -7891,6 +8058,8 @@ function installTransformIfNeeded() {
|
|
|
7891
8058
|
if (transformInstalled)
|
|
7892
8059
|
return;
|
|
7893
8060
|
transformInstalled = true;
|
|
8061
|
+
if ("Bun" in globalThis)
|
|
8062
|
+
return;
|
|
7894
8063
|
registerESMLoader();
|
|
7895
8064
|
installSourceMapSupport();
|
|
7896
8065
|
if (loaderChannel) {
|
|
@@ -7914,7 +8083,11 @@ function installCJSHooks() {
|
|
|
7914
8083
|
import_module2.default._resolveFilename = resolveFilename;
|
|
7915
8084
|
addHook((code, filename) => {
|
|
7916
8085
|
return transformHook(code, filename).code;
|
|
7917
|
-
}, shouldTransform,
|
|
8086
|
+
}, shouldTransform, kTransformedExtensions);
|
|
8087
|
+
const extensions = import_module2.default._extensions;
|
|
8088
|
+
for (const ext2 of kStyleExtensions)
|
|
8089
|
+
extensions[ext2] = () => {
|
|
8090
|
+
};
|
|
7918
8091
|
}
|
|
7919
8092
|
var collectCJSDependencies = (module2, dependencies) => {
|
|
7920
8093
|
module2.children.forEach((child) => {
|
|
@@ -7927,26 +8100,40 @@ var collectCJSDependencies = (module2, dependencies) => {
|
|
|
7927
8100
|
function wrapFunctionWithLocation(func) {
|
|
7928
8101
|
return (...args) => {
|
|
7929
8102
|
const oldPrepareStackTrace = Error.prepareStackTrace;
|
|
7930
|
-
Error.prepareStackTrace = (error, stackFrames) => {
|
|
7931
|
-
const frame = import_source_map_support2.default.wrapCallSite(stackFrames[1]);
|
|
7932
|
-
const fileName2 = frame.getFileName();
|
|
7933
|
-
const file2 = fileName2 && fileName2.startsWith("file://") ? import_url2.default.fileURLToPath(fileName2) : fileName2;
|
|
7934
|
-
return {
|
|
7935
|
-
file: file2,
|
|
7936
|
-
line: frame.getLineNumber(),
|
|
7937
|
-
column: frame.getColumnNumber()
|
|
7938
|
-
};
|
|
7939
|
-
};
|
|
7940
8103
|
const oldStackTraceLimit = Error.stackTraceLimit;
|
|
8104
|
+
Error.prepareStackTrace = "Bun" in globalThis ? bunCallerLocation : nodeCallerLocation;
|
|
7941
8105
|
Error.stackTraceLimit = 2;
|
|
7942
8106
|
const obj = {};
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
8107
|
+
let location;
|
|
8108
|
+
try {
|
|
8109
|
+
Error.captureStackTrace(obj);
|
|
8110
|
+
location = obj.stack;
|
|
8111
|
+
} finally {
|
|
8112
|
+
Error.stackTraceLimit = oldStackTraceLimit;
|
|
8113
|
+
Error.prepareStackTrace = oldPrepareStackTrace;
|
|
8114
|
+
}
|
|
7947
8115
|
return func(location, ...args);
|
|
7948
8116
|
};
|
|
7949
8117
|
}
|
|
8118
|
+
function nodeCallerLocation(error, stackFrames) {
|
|
8119
|
+
const frame = import_source_map_support2.default.wrapCallSite(stackFrames[1]);
|
|
8120
|
+
const fileName2 = frame.getFileName();
|
|
8121
|
+
const file2 = fileName2 && fileName2.startsWith("file://") ? import_url3.default.fileURLToPath(fileName2) : fileName2;
|
|
8122
|
+
return {
|
|
8123
|
+
file: file2,
|
|
8124
|
+
line: frame.getLineNumber(),
|
|
8125
|
+
column: frame.getColumnNumber()
|
|
8126
|
+
};
|
|
8127
|
+
}
|
|
8128
|
+
function bunCallerLocation(error, stackFrames) {
|
|
8129
|
+
const frame = stackFrames[1];
|
|
8130
|
+
const position = import_source_map_support2.default.mapSourcePosition({ source: frame.getFileName(), line: frame.getLineNumber(), column: frame.getColumnNumber() });
|
|
8131
|
+
return {
|
|
8132
|
+
file: position.source,
|
|
8133
|
+
line: position.line,
|
|
8134
|
+
column: position.column + 1
|
|
8135
|
+
};
|
|
8136
|
+
}
|
|
7950
8137
|
function isRelativeSpecifier(specifier) {
|
|
7951
8138
|
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
|
|
7952
8139
|
}
|
|
@@ -7957,8 +8144,6 @@ var loaderChannel;
|
|
|
7957
8144
|
function registerESMLoader() {
|
|
7958
8145
|
if (process.env.PW_DISABLE_TS_ESM)
|
|
7959
8146
|
return;
|
|
7960
|
-
if ("Bun" in globalThis)
|
|
7961
|
-
return;
|
|
7962
8147
|
const nodeModule = require("node:module");
|
|
7963
8148
|
if (nodeModule.registerHooks && !process.env.PLAYWRIGHT_FORCE_ASYNC_LOADER) {
|
|
7964
8149
|
nodeModule.registerHooks({ resolve, load });
|
|
@@ -7967,7 +8152,7 @@ function registerESMLoader() {
|
|
|
7967
8152
|
if (!nodeModule.register)
|
|
7968
8153
|
return;
|
|
7969
8154
|
const { port1, port2 } = new MessageChannel();
|
|
7970
|
-
nodeModule.register(
|
|
8155
|
+
nodeModule.register(import_url3.default.pathToFileURL(require.resolve("../transform/esmLoader.js")), {
|
|
7971
8156
|
data: { port: port2 },
|
|
7972
8157
|
transferList: [port2]
|
|
7973
8158
|
});
|
|
@@ -7987,7 +8172,7 @@ async function startCollectingFileDeps2() {
|
|
|
7987
8172
|
async function stopCollectingFileDeps2(file2) {
|
|
7988
8173
|
stopCollectingFileDeps(file2);
|
|
7989
8174
|
if (loaderChannel)
|
|
7990
|
-
await loaderChannel.send("stopCollectingFileDeps", { file: file2 });
|
|
8175
|
+
await loaderChannel.send("stopCollectingFileDeps", { file: file2, dependencies: [...dependenciesForTestFile(file2)] });
|
|
7991
8176
|
}
|
|
7992
8177
|
async function incorporateCompilationCache() {
|
|
7993
8178
|
if (!loaderChannel)
|
|
@@ -8001,14 +8186,13 @@ var esmPreflightExtension = ".esm.preflight";
|
|
|
8001
8186
|
async function resolve2(originalSpecifier, context, defaultResolve) {
|
|
8002
8187
|
let specifier = originalSpecifier.replace(esmPreflightExtension, "");
|
|
8003
8188
|
if (context.parentURL && context.parentURL.startsWith("file://")) {
|
|
8004
|
-
const filename =
|
|
8189
|
+
const filename = import_url4.default.fileURLToPath(context.parentURL);
|
|
8005
8190
|
const resolved = resolveHook(filename, specifier);
|
|
8006
8191
|
if (resolved !== void 0)
|
|
8007
|
-
specifier =
|
|
8192
|
+
specifier = import_url4.default.pathToFileURL(resolved).toString();
|
|
8008
8193
|
}
|
|
8009
8194
|
const result2 = await defaultResolve(specifier, context, defaultResolve);
|
|
8010
|
-
|
|
8011
|
-
currentFileDepsCollector()?.add(import_url3.default.fileURLToPath(result2.url));
|
|
8195
|
+
recordResolvedFile(result2?.url, context.parentURL);
|
|
8012
8196
|
if (originalSpecifier.endsWith(esmPreflightExtension))
|
|
8013
8197
|
result2.url = result2.url + esmPreflightExtension;
|
|
8014
8198
|
return result2;
|
|
@@ -8026,12 +8210,16 @@ async function load2(moduleUrl, context, defaultLoad) {
|
|
|
8026
8210
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
8027
8211
|
if (!moduleUrl.startsWith("file://"))
|
|
8028
8212
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
8029
|
-
const filename =
|
|
8213
|
+
const filename = import_url4.default.fileURLToPath(moduleUrl);
|
|
8030
8214
|
const isPreflight = moduleUrl.endsWith(esmPreflightExtension);
|
|
8215
|
+
if (isStyleFile(filename))
|
|
8216
|
+
return { format: "commonjs", source: "", shortCircuit: true };
|
|
8031
8217
|
if (!shouldTransform(filename))
|
|
8032
8218
|
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
8033
8219
|
const originalModuleUrl = isPreflight ? moduleUrl.slice(0, -esmPreflightExtension.length) : moduleUrl;
|
|
8034
|
-
const originalFilename = isPreflight ?
|
|
8220
|
+
const originalFilename = isPreflight ? import_url4.default.fileURLToPath(originalModuleUrl) : filename;
|
|
8221
|
+
if (!hasTransformedExtension(originalFilename))
|
|
8222
|
+
return defaultLoad(moduleUrl, context, defaultLoad);
|
|
8035
8223
|
const code = import_fs6.default.readFileSync(originalFilename, "utf-8");
|
|
8036
8224
|
const transformed = transformHook(code, originalFilename, originalModuleUrl);
|
|
8037
8225
|
if (transformed.serializedCache)
|
|
@@ -8067,7 +8255,7 @@ function createTransport(port) {
|
|
|
8067
8255
|
return;
|
|
8068
8256
|
}
|
|
8069
8257
|
if (method === "stopCollectingFileDeps") {
|
|
8070
|
-
stopCollectingFileDeps(params.file);
|
|
8258
|
+
stopCollectingFileDeps(params.file, params.dependencies);
|
|
8071
8259
|
return;
|
|
8072
8260
|
}
|
|
8073
8261
|
});
|