playwright 1.56.0-alpha-2025-09-17 → 1.56.0-alpha-1758292576000

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.
@@ -49,6 +49,7 @@ module.exports = __toCommonJS(compilationCache_exports);
49
49
  var import_fs = __toESM(require("fs"));
50
50
  var import_os = __toESM(require("os"));
51
51
  var import_path = __toESM(require("path"));
52
+ var import_utils = require("playwright-core/lib/utils");
52
53
  var import_globals = require("../common/globals");
53
54
  var import_utilsBundle = require("../utilsBundle");
54
55
  const cacheDir = process.env.PWTEST_CACHE_DIR || (() => {
@@ -90,7 +91,7 @@ function _innerAddToCompilationCacheAndSerialize(filename, entry) {
90
91
  externalDependencies: []
91
92
  };
92
93
  }
93
- function getFromCompilationCache(filename, hash, moduleUrl) {
94
+ function getFromCompilationCache(filename, contentHash, moduleUrl) {
94
95
  const cache = memoryCache.get(filename);
95
96
  if (cache?.codePath) {
96
97
  try {
@@ -98,7 +99,10 @@ function getFromCompilationCache(filename, hash, moduleUrl) {
98
99
  } catch {
99
100
  }
100
101
  }
101
- const cachePath = calculateCachePath(filename, hash);
102
+ const filePathHash = calculateFilePathHash(filename);
103
+ const hashPrefix = filePathHash + "_" + contentHash.substring(0, 7);
104
+ const cacheFolderName = filePathHash.substring(0, 2);
105
+ const cachePath = calculateCachePath(filename, cacheFolderName, hashPrefix);
102
106
  const codePath = cachePath + ".js";
103
107
  const sourceMapPath = cachePath + ".map";
104
108
  const dataPath = cachePath + ".data";
@@ -112,6 +116,7 @@ function getFromCompilationCache(filename, hash, moduleUrl) {
112
116
  addToCache: (code, map, data) => {
113
117
  if ((0, import_globals.isWorkerProcess)())
114
118
  return {};
119
+ clearOldCacheEntries(cacheFolderName, filePathHash);
115
120
  import_fs.default.mkdirSync(import_path.default.dirname(cachePath), { recursive: true });
116
121
  if (map)
117
122
  import_fs.default.writeFileSync(sourceMapPath, JSON.stringify(map), "utf8");
@@ -145,9 +150,21 @@ function addToCompilationCache(payload) {
145
150
  externalDependencies.set(entry[0], /* @__PURE__ */ new Set([...entry[1], ...existing]));
146
151
  }
147
152
  }
148
- function calculateCachePath(filePath, hash) {
149
- const fileName = import_path.default.basename(filePath, import_path.default.extname(filePath)).replace(/\W/g, "") + "_" + hash;
150
- return import_path.default.join(cacheDir, hash[0] + hash[1], fileName);
153
+ function calculateFilePathHash(filePath) {
154
+ return (0, import_utils.calculateSha1)(filePath).substring(0, 10);
155
+ }
156
+ function calculateCachePath(filePath, cacheFolderName, hashPrefix) {
157
+ const fileName = hashPrefix + "_" + import_path.default.basename(filePath, import_path.default.extname(filePath)).replace(/\W/g, "");
158
+ return import_path.default.join(cacheDir, cacheFolderName, fileName);
159
+ }
160
+ function clearOldCacheEntries(cacheFolderName, filePathHash) {
161
+ const cachePath = import_path.default.join(cacheDir, cacheFolderName);
162
+ try {
163
+ const cachedRelevantFiles = import_fs.default.readdirSync(cachePath).filter((file) => file.startsWith(filePathHash));
164
+ for (const file of cachedRelevantFiles)
165
+ import_fs.default.rmSync(import_path.default.join(cachePath, file), { force: true });
166
+ } catch {
167
+ }
151
168
  }
152
169
  let depsCollector;
153
170
  function startCollectingFileDeps() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright",
3
- "version": "1.56.0-alpha-2025-09-17",
3
+ "version": "1.56.0-alpha-1758292576000",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "license": "Apache-2.0",
66
66
  "dependencies": {
67
- "playwright-core": "1.56.0-alpha-2025-09-17"
67
+ "playwright-core": "1.56.0-alpha-1758292576000"
68
68
  },
69
69
  "optionalDependencies": {
70
70
  "fsevents": "2.3.2"
package/types/test.d.ts CHANGED
@@ -22,7 +22,17 @@ export type BlobReporterOptions = { outputDir?: string, fileName?: string };
22
22
  export type ListReporterOptions = { printSteps?: boolean };
23
23
  export type JUnitReporterOptions = { outputFile?: string, stripANSIControlSequences?: boolean, includeProjectInTestName?: boolean };
24
24
  export type JsonReporterOptions = { outputFile?: string };
25
- export type HtmlReporterOptions = { outputFolder?: string, open?: 'always' | 'never' | 'on-failure', host?: string, port?: number, attachmentsBaseURL?: string, title?: string, noSnippets?: boolean };
25
+ export type HtmlReporterOptions = {
26
+ outputFolder?: string;
27
+ open?: 'always' | 'never' | 'on-failure';
28
+ host?: string;
29
+ port?: number;
30
+ attachmentsBaseURL?: string;
31
+ title?: string;
32
+ noSnippets?: boolean;
33
+ noCopyPrompt?: boolean;
34
+ noFiles?: boolean;
35
+ };
26
36
 
27
37
  export type ReporterDescription = Readonly<
28
38
  ['blob'] | ['blob', BlobReporterOptions] |
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var processUtils_exports = {};
30
- __export(processUtils_exports, {
31
- findBrowserProcess: () => findBrowserProcess,
32
- getBrowserExecPath: () => getBrowserExecPath
33
- });
34
- module.exports = __toCommonJS(processUtils_exports);
35
- var import_child_process = __toESM(require("child_process"));
36
- var import_fs = __toESM(require("fs"));
37
- var import_registry = require("playwright-core/lib/server/registry/index");
38
- function getBrowserExecPath(channelOrName) {
39
- return import_registry.registry.findExecutable(channelOrName)?.executablePath("javascript");
40
- }
41
- function findBrowserProcess(execPath, arg) {
42
- const predicate = (line) => line.includes(execPath) && line.includes(arg) && !line.includes("--type");
43
- try {
44
- switch (process.platform) {
45
- case "darwin":
46
- return findProcessMacos(predicate);
47
- case "linux":
48
- return findProcessLinux(predicate);
49
- case "win32":
50
- return findProcessWindows(execPath, arg, predicate);
51
- default:
52
- return void 0;
53
- }
54
- } catch {
55
- return void 0;
56
- }
57
- }
58
- function findProcessLinux(predicate) {
59
- const procDirs = import_fs.default.readdirSync("/proc").filter((name) => /^\d+$/.test(name));
60
- for (const pid of procDirs) {
61
- try {
62
- const cmdlineBuffer = import_fs.default.readFileSync(`/proc/${pid}/cmdline`);
63
- const cmdline = cmdlineBuffer.toString().replace(/\0/g, " ").trim();
64
- if (predicate(cmdline))
65
- return `${pid} ${cmdline}`;
66
- } catch {
67
- continue;
68
- }
69
- }
70
- return void 0;
71
- }
72
- function findProcessMacos(predicate) {
73
- const result = import_child_process.default.spawnSync("/bin/ps", ["-axo", "pid=,command="]);
74
- if (result.status !== 0 || !result.stdout)
75
- return void 0;
76
- return findMatchingLine(result.stdout.toString(), predicate);
77
- }
78
- function findProcessWindows(execPath, arg, predicate) {
79
- const psEscape = (path) => `'${path.replaceAll("'", "''")}'`;
80
- const filter = `$_.ExecutablePath -eq ${psEscape(execPath)} -and $_.CommandLine.Contains(${psEscape(arg)}) -and $_.CommandLine -notmatch '--type'`;
81
- const ps = import_child_process.default.spawnSync(
82
- "powershell.exe",
83
- [
84
- "-NoProfile",
85
- "-Command",
86
- `Get-CimInstance Win32_Process | Where-Object { ${filter} } | Select-Object -Property ProcessId,CommandLine | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }`
87
- ],
88
- { encoding: "utf8" }
89
- );
90
- if (ps.status !== 0 || !ps.stdout)
91
- return void 0;
92
- return findMatchingLine(ps.stdout.toString(), predicate);
93
- }
94
- function findMatchingLine(psOutput, predicate) {
95
- const lines = psOutput.split("\n").map((l) => l.trim()).filter(Boolean);
96
- return lines.find(predicate);
97
- }
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {
100
- findBrowserProcess,
101
- getBrowserExecPath
102
- });