flashwright 0.0.0-stage → 1.64.1-flashwright.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +17 -2
  4. package/ThirdPartyNotices.txt +14 -0
  5. package/cli.js +37 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/lib/agents/agentParser.js +89 -0
  10. package/lib/agents/copilot-setup-steps.yml +34 -0
  11. package/lib/agents/generateAgents.js +395 -0
  12. package/lib/agents/playwright-test-coverage.prompt.md +31 -0
  13. package/lib/agents/playwright-test-generate.prompt.md +8 -0
  14. package/lib/agents/playwright-test-generator.agent.md +88 -0
  15. package/lib/agents/playwright-test-heal.prompt.md +6 -0
  16. package/lib/agents/playwright-test-healer.agent.md +56 -0
  17. package/lib/agents/playwright-test-plan.prompt.md +9 -0
  18. package/lib/agents/playwright-test-planner.agent.md +74 -0
  19. package/lib/cli/reportActions.js +78 -0
  20. package/lib/cli/testActions.js +219 -0
  21. package/lib/codeCache.js +141 -0
  22. package/lib/codeCache.js.txt +8 -0
  23. package/lib/common/index.js +2974 -0
  24. package/lib/common/index.js.txt +33 -0
  25. package/lib/errorContext.js +129 -0
  26. package/lib/globals.js +58 -0
  27. package/lib/index.js +896 -0
  28. package/lib/isomorphic.js +260 -0
  29. package/lib/isomorphic.js.txt +9 -0
  30. package/lib/loader/loaderProcessEntry.js +34 -0
  31. package/lib/loader/loaderProcessEntry.js.txt +9 -0
  32. package/lib/matchers/expect.js +13496 -0
  33. package/lib/matchers/expect.js.LICENSE +640 -0
  34. package/lib/matchers/expect.js.txt +67 -0
  35. package/lib/mcp/test/browserBackend.js +135 -0
  36. package/lib/mcp/test/generatorTools.js +122 -0
  37. package/lib/mcp/test/plannerTools.js +150 -0
  38. package/lib/mcp/test/seed.js +82 -0
  39. package/lib/mcp/test/streams.js +44 -0
  40. package/lib/mcp/test/testBackend.js +99 -0
  41. package/lib/mcp/test/testContext.js +306 -0
  42. package/lib/mcp/test/testTool.js +30 -0
  43. package/lib/mcp/test/testTools.js +98 -0
  44. package/lib/package.js +47 -0
  45. package/lib/program.js +248 -0
  46. package/lib/runner/index.js +8819 -0
  47. package/lib/runner/index.js.txt +65 -0
  48. package/lib/runner/session.js +723 -0
  49. package/lib/runner/session.js.txt +8 -0
  50. package/lib/runner/workerStandby.js +206 -0
  51. package/lib/runner/workerStandby.js.txt +8 -0
  52. package/lib/speculativeBrowser.js +228 -0
  53. package/lib/transform/babelBundle.js +72490 -0
  54. package/lib/transform/babelBundle.js.LICENSE +2384 -0
  55. package/lib/transform/babelBundle.js.txt +328 -0
  56. package/lib/transform/esmLoader.js +8090 -0
  57. package/lib/transform/esmLoader.js.LICENSE +355 -0
  58. package/lib/transform/esmLoader.js.txt +60 -0
  59. package/lib/util.js +373 -0
  60. package/lib/worker/workerProcessEntry.js +2015 -0
  61. package/lib/worker/workerProcessEntry.js.txt +22 -0
  62. package/package.json +64 -4
  63. package/test.d.ts +18 -0
  64. package/test.js +40 -0
  65. package/test.mjs +35 -0
  66. package/types/test.d.ts +11316 -0
  67. package/types/testReporter.d.ts +950 -0
@@ -0,0 +1,78 @@
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 reportActions_exports = {};
30
+ __export(reportActions_exports, {
31
+ mergeReports: () => mergeReports,
32
+ showReport: () => showReport
33
+ });
34
+ module.exports = __toCommonJS(reportActions_exports);
35
+ var import_fs = __toESM(require("fs"));
36
+ var import_path = __toESM(require("path"));
37
+ var import_common = require("../common");
38
+ var import_runner = require("../runner");
39
+ const { gracefullyProcessExitDoNotHang } = require("playwright-core/lib/coreBundle").utils;
40
+ async function showReport(report, host, port) {
41
+ await import_runner.html.showHTMLReport(report, host, port);
42
+ }
43
+ async function mergeReports(reportDir, opts) {
44
+ const configFile = opts.config;
45
+ const config = configFile ? await import_common.configLoader.loadConfigFromFile(configFile) : await import_common.configLoader.loadEmptyConfigForMergeReports();
46
+ const dir = import_path.default.resolve(process.cwd(), reportDir || "");
47
+ const dirStat = await import_fs.default.promises.stat(dir).catch((e) => null);
48
+ if (!dirStat)
49
+ throw new Error("Directory does not exist: " + dir);
50
+ if (!dirStat.isDirectory())
51
+ throw new Error(`"${dir}" is not a directory`);
52
+ let reporterDescriptions = resolveReporterOption(opts.reporter);
53
+ if (!reporterDescriptions && configFile)
54
+ reporterDescriptions = config.config.reporter;
55
+ if (!reporterDescriptions)
56
+ reporterDescriptions = [[import_common.config.defaultReporter]];
57
+ const rootDirOverride = configFile ? config.config.rootDir : void 0;
58
+ const result = await import_runner.merge.createMergedReport(config, dir, reporterDescriptions, rootDirOverride);
59
+ gracefullyProcessExitDoNotHang(result === "failed" ? 1 : 0);
60
+ }
61
+ function resolveReporterOption(reporter) {
62
+ if (!reporter || !reporter.length)
63
+ return void 0;
64
+ return reporter.split(",").map((r) => [resolveReporter(r)]);
65
+ }
66
+ function resolveReporter(id) {
67
+ if (import_common.builtInReporters.includes(id))
68
+ return id;
69
+ const localPath = import_path.default.resolve(process.cwd(), id);
70
+ if (import_fs.default.existsSync(localPath))
71
+ return localPath;
72
+ return require.resolve(id, { paths: [process.cwd()] });
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ mergeReports,
77
+ showReport
78
+ });
@@ -0,0 +1,219 @@
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 testActions_exports = {};
30
+ __export(testActions_exports, {
31
+ clearCache: () => clearCache,
32
+ runTestServerAction: () => runTestServerAction,
33
+ runTests: () => runTests
34
+ });
35
+ module.exports = __toCommonJS(testActions_exports);
36
+ var import_fs = __toESM(require("fs"));
37
+ var import_path = __toESM(require("path"));
38
+ var import_common = require("../common");
39
+ var import_runner = require("../runner");
40
+ var import_session = require("../runner/session");
41
+ const { gracefullyProcessExitDoNotHang } = require("playwright-core/lib/coreBundle").utils;
42
+ async function runTests(args, opts) {
43
+ const cliOverrides = overridesFromOptions(opts);
44
+ cliOverrides.argv = process.argv;
45
+ const config = await import_common.configLoader.loadConfigFromFile(opts.config, cliOverrides, opts.deps === false);
46
+ const options = {
47
+ locations: args.length ? args : void 0,
48
+ grep: opts.grep,
49
+ grepInvert: opts.grepInvert,
50
+ onlyChanged: opts.onlyChanged === true ? "HEAD" : opts.onlyChanged,
51
+ listMode: !!opts.list,
52
+ projectFilter: opts.project || void 0,
53
+ passWithNoTests: !!opts.passWithNoTests,
54
+ lastFailed: !!opts.lastFailed,
55
+ lastFailedFile: opts.lastFailedFile,
56
+ testList: opts.testList ? import_path.default.resolve(process.cwd(), opts.testList) : void 0,
57
+ testListInvert: opts.testListInvert ? import_path.default.resolve(process.cwd(), opts.testListInvert) : void 0,
58
+ shardWeights: resolveShardWeightsOption()
59
+ };
60
+ import_runner.projectUtils.filterProjects(config.projects, options.projectFilter);
61
+ if (opts.ui || opts.uiHost || opts.uiPort) {
62
+ if (opts.onlyChanged)
63
+ throw new Error(`--only-changed is not supported in UI mode. If you'd like that to change, see https://github.com/microsoft/playwright/issues/15075 for more details.`);
64
+ const status2 = await import_runner.testServer.runUIMode(opts.config, cliOverrides, {
65
+ host: opts.uiHost,
66
+ port: opts.uiPort ? +opts.uiPort : void 0,
67
+ args,
68
+ grep: opts.grep,
69
+ grepInvert: opts.grepInvert,
70
+ project: opts.project || void 0,
71
+ reporter: Array.isArray(opts.reporter) ? opts.reporter : opts.reporter ? [opts.reporter] : void 0
72
+ });
73
+ const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
74
+ gracefullyProcessExitDoNotHang(exitCode2);
75
+ return;
76
+ }
77
+ if (process.env.PWTEST_WATCH) {
78
+ if (opts.onlyChanged)
79
+ throw new Error(`--only-changed is not supported in watch mode. If you'd like that to change, file an issue and let us know about your usecase for it.`);
80
+ const status2 = await import_runner.watchMode.runWatchModeLoop(
81
+ import_common.configLoader.resolveConfigLocation(opts.config),
82
+ {
83
+ projects: opts.project,
84
+ files: args,
85
+ grep: opts.grep
86
+ }
87
+ );
88
+ const exitCode2 = status2 === "interrupted" ? 130 : status2 === "passed" ? 0 : 1;
89
+ gracefullyProcessExitDoNotHang(exitCode2);
90
+ return;
91
+ }
92
+ const status = await import_runner.testRunner.runAllTestsWithConfig(config, options);
93
+ const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
94
+ gracefullyProcessExitDoNotHang(exitCode, () => (0, import_session.flushSessionBrowsers)(exitCode));
95
+ }
96
+ async function runTestServerAction(opts) {
97
+ const host = opts.host;
98
+ const port = opts.port ? +opts.port : void 0;
99
+ const status = await import_runner.testServer.runTestServer(opts.config, {}, { host, port });
100
+ const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
101
+ gracefullyProcessExitDoNotHang(exitCode);
102
+ }
103
+ async function clearCache(opts) {
104
+ const runner = new import_runner.testRunner.TestRunner(import_common.configLoader.resolveConfigLocation(opts.config), {});
105
+ const { status } = await runner.clearCache(import_runner.runnerReporters.createErrorCollectingReporter(import_runner.base.terminalScreen));
106
+ const exitCode = status === "interrupted" ? 130 : status === "passed" ? 0 : 1;
107
+ gracefullyProcessExitDoNotHang(exitCode);
108
+ }
109
+ function overridesFromOptions(options) {
110
+ if (options.ui) {
111
+ options.debug = void 0;
112
+ options.trace = void 0;
113
+ }
114
+ const overrides = {
115
+ debug: options.debug,
116
+ failOnFlakyTests: options.failOnFlakyTests ? true : void 0,
117
+ forbidOnly: options.forbidOnly ? true : void 0,
118
+ fullyParallel: options.fullyParallel ? true : void 0,
119
+ globalTimeout: options.globalTimeout ? parseInt(options.globalTimeout, 10) : void 0,
120
+ maxFailures: options.x ? 1 : options.maxFailures ? parseInt(options.maxFailures, 10) : void 0,
121
+ outputDir: options.output ? import_path.default.resolve(process.cwd(), options.output) : void 0,
122
+ pause: !!process.env.PWPAUSE,
123
+ quiet: options.quiet ? options.quiet : void 0,
124
+ repeatEach: options.repeatEach ? parseInt(options.repeatEach, 10) : void 0,
125
+ retries: options.retries ? parseInt(options.retries, 10) : void 0,
126
+ reporter: resolveReporterOption(options.reporter),
127
+ additionalReporters: resolveReporterOption(options.addReporter),
128
+ shard: resolveShardOption(options.shard),
129
+ shuffle: resolveShuffleOption(options.shuffle),
130
+ testOrder: options.testOrder,
131
+ timeout: options.timeout ? parseInt(options.timeout, 10) : void 0,
132
+ tsconfig: options.tsconfig ? import_path.default.resolve(process.cwd(), options.tsconfig) : void 0,
133
+ ignoreSnapshots: options.ignoreSnapshots ? !!options.ignoreSnapshots : void 0,
134
+ updateSnapshots: options.updateSnapshots,
135
+ updateSourceMethod: options.updateSourceMethod,
136
+ use: {
137
+ trace: options.trace
138
+ },
139
+ workers: options.workers
140
+ };
141
+ if (options.browser) {
142
+ const browserOpt = options.browser.toLowerCase();
143
+ if (!["all", "chromium", "firefox", "webkit"].includes(browserOpt))
144
+ throw new Error(`Unsupported browser "${options.browser}", must be one of "all", "chromium", "firefox" or "webkit"`);
145
+ const browserNames = browserOpt === "all" ? ["chromium", "firefox", "webkit"] : [browserOpt];
146
+ overrides.projects = browserNames.map((browserName) => {
147
+ return {
148
+ name: browserName,
149
+ use: { browserName }
150
+ };
151
+ });
152
+ }
153
+ if (options.headed)
154
+ overrides.use.headless = false;
155
+ if (options.debug === "inspector") {
156
+ overrides.use.headless = false;
157
+ process.env.PWDEBUG = "1";
158
+ }
159
+ if (overrides.tsconfig && !import_fs.default.existsSync(overrides.tsconfig))
160
+ throw new Error(`--tsconfig "${options.tsconfig}" does not exist`);
161
+ return overrides;
162
+ }
163
+ function resolveReporterOption(reporter) {
164
+ if (!reporter || !reporter.length)
165
+ return void 0;
166
+ return reporter.split(",").map((r) => [resolveReporter(r)]);
167
+ }
168
+ function resolveShuffleOption(shuffle) {
169
+ if (!shuffle)
170
+ return void 0;
171
+ if (shuffle === true)
172
+ return String(Math.floor(Math.random() * 1e9));
173
+ return shuffle;
174
+ }
175
+ function resolveShardOption(shard) {
176
+ if (!shard)
177
+ return void 0;
178
+ const shardPair = shard.split("/");
179
+ if (shardPair.length !== 2) {
180
+ throw new Error(
181
+ `--shard "${shard}", expected format is "current/all", 1-based, for example "3/5".`
182
+ );
183
+ }
184
+ const current = parseInt(shardPair[0], 10);
185
+ const total = parseInt(shardPair[1], 10);
186
+ if (isNaN(total) || total < 1)
187
+ throw new Error(`--shard "${shard}" total must be a positive number`);
188
+ if (isNaN(current) || current < 1 || current > total) {
189
+ throw new Error(
190
+ `--shard "${shard}" current must be a positive number, not greater than shard total`
191
+ );
192
+ }
193
+ return { current, total };
194
+ }
195
+ function resolveShardWeightsOption() {
196
+ const shardWeights = process.env.PWTEST_SHARD_WEIGHTS;
197
+ if (!shardWeights)
198
+ return void 0;
199
+ return shardWeights.split(":").map((w) => {
200
+ const weight = parseInt(w, 10);
201
+ if (isNaN(weight) || weight < 0)
202
+ throw new Error(`PWTEST_SHARD_WEIGHTS="${shardWeights}" weights must be non-negative numbers`);
203
+ return weight;
204
+ });
205
+ }
206
+ function resolveReporter(id) {
207
+ if (import_common.builtInReporters.includes(id))
208
+ return id;
209
+ const localPath = import_path.default.resolve(process.cwd(), id);
210
+ if (import_fs.default.existsSync(localPath))
211
+ return localPath;
212
+ return require.resolve(id, { paths: [process.cwd()] });
213
+ }
214
+ // Annotate the CommonJS export names for ESM import in node:
215
+ 0 && (module.exports = {
216
+ clearCache,
217
+ runTestServerAction,
218
+ runTests
219
+ });
@@ -0,0 +1,141 @@
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
+
30
+ // packages/playwright/src/codeCache.ts
31
+ var codeCache_exports = {};
32
+ __export(codeCache_exports, {
33
+ installCodeCache: () => installCodeCache
34
+ });
35
+ module.exports = __toCommonJS(codeCache_exports);
36
+ var import_crypto = __toESM(require("crypto"));
37
+ var import_fs = __toESM(require("fs"));
38
+ var import_module = __toESM(require("module"));
39
+ var import_os = __toESM(require("os"));
40
+ var import_path = __toESM(require("path"));
41
+ var import_vm = __toESM(require("vm"));
42
+ var minimumSize = 32 * 1024;
43
+ var pending = [];
44
+ var installed = false;
45
+ function installCodeCache(role) {
46
+ if (installed || process.env.NODE_DISABLE_COMPILE_CACHE || process.env.FLASHWRIGHT_DISABLE_CODE_CACHE || process.env.NODE_V8_COVERAGE)
47
+ return;
48
+ const importModuleDynamically = import_vm.default.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER;
49
+ const originalCompile = import_module.default.prototype._compile;
50
+ if (!importModuleDynamically || typeof originalCompile !== "function")
51
+ return;
52
+ installed = true;
53
+ silenceDefaultLoaderWarning(importModuleDynamically);
54
+ const roots = packageLibDirs();
55
+ const cacheDir = import_path.default.join(import_os.default.tmpdir(), "flashwright-code-cache", `${process.version}-${process.arch}`, role);
56
+ import_module.default.prototype._compile = function(content, filename, format) {
57
+ if (format === "module" || typeof content !== "string" || content.length < minimumSize || content.startsWith("#!") || !roots.some((root) => filename.startsWith(root)))
58
+ return originalCompile.apply(this, arguments);
59
+ let compiled;
60
+ try {
61
+ compiled = compileWithCache(content, filename, cacheDir, importModuleDynamically);
62
+ } catch {
63
+ return originalCompile.apply(this, arguments);
64
+ }
65
+ return compiled.call(this.exports, this.exports, makeRequireFunction(this), this, filename, import_path.default.dirname(filename));
66
+ };
67
+ process.once("exit", writeCodeCaches);
68
+ }
69
+ function silenceDefaultLoaderWarning(importModuleDynamically) {
70
+ const emitWarning = process.emitWarning;
71
+ process.emitWarning = function(warning, ...args) {
72
+ if (typeof warning === "string" && warning.startsWith("vm.USE_MAIN_CONTEXT_DEFAULT_LOADER"))
73
+ return;
74
+ return emitWarning.call(this, warning, ...args);
75
+ };
76
+ try {
77
+ new import_vm.default.Script('import("node:path").catch(() => {})', { importModuleDynamically }).runInThisContext();
78
+ } catch {
79
+ } finally {
80
+ process.emitWarning = emitWarning;
81
+ }
82
+ }
83
+ function packageLibDirs() {
84
+ const dirs = [import_path.default.join(import_path.default.dirname(__dirname), "lib") + import_path.default.sep];
85
+ try {
86
+ dirs.push(import_path.default.join(import_path.default.dirname(require.resolve("playwright-core/package.json")), "lib") + import_path.default.sep);
87
+ } catch {
88
+ }
89
+ return dirs;
90
+ }
91
+ function compileWithCache(content, filename, cacheDir, importModuleDynamically) {
92
+ const stat = import_fs.default.statSync(filename);
93
+ const fileKey = import_crypto.default.createHash("sha1").update(filename).digest("hex").slice(0, 16);
94
+ const versionKey = import_crypto.default.createHash("sha1").update(`${stat.size}:${stat.mtimeMs}:${content.length}`).digest("hex").slice(0, 16);
95
+ const cacheFile = import_path.default.join(cacheDir, `${fileKey}-${versionKey}`);
96
+ let cachedData;
97
+ try {
98
+ cachedData = import_fs.default.readFileSync(cacheFile);
99
+ } catch {
100
+ }
101
+ const script = new import_vm.default.Script(import_module.default.wrap(content), { filename, cachedData, importModuleDynamically });
102
+ if (!cachedData || script.cachedDataRejected)
103
+ pending.push({ script, cacheFile, staleFiles: staleCacheFiles(cacheDir, fileKey, cacheFile) });
104
+ return script.runInThisContext({ displayErrors: true });
105
+ }
106
+ function staleCacheFiles(cacheDir, fileKey, cacheFile) {
107
+ try {
108
+ return import_fs.default.readdirSync(cacheDir).filter((name) => name.startsWith(fileKey + "-")).map((name) => import_path.default.join(cacheDir, name)).filter((file) => file !== cacheFile);
109
+ } catch {
110
+ return [];
111
+ }
112
+ }
113
+ function makeRequireFunction(mod) {
114
+ const require2 = (id) => mod.require(id);
115
+ const resolve = (request, options) => import_module.default._resolveFilename(request, mod, false, options);
116
+ resolve.paths = (request) => import_module.default._resolveLookupPaths(request, mod);
117
+ require2.resolve = resolve;
118
+ require2.main = process.mainModule;
119
+ require2.extensions = import_module.default._extensions;
120
+ require2.cache = import_module.default._cache;
121
+ return require2;
122
+ }
123
+ function writeCodeCaches() {
124
+ for (const { script, cacheFile, staleFiles } of pending.splice(0)) {
125
+ try {
126
+ import_fs.default.mkdirSync(import_path.default.dirname(cacheFile), { recursive: true });
127
+ const temporary = `${cacheFile}.${process.pid}`;
128
+ import_fs.default.writeFileSync(temporary, script.createCachedData());
129
+ import_fs.default.renameSync(temporary, cacheFile);
130
+ for (const file of staleFiles)
131
+ import_fs.default.rmSync(file, { force: true });
132
+ } catch {
133
+ }
134
+ }
135
+ }
136
+ if (/workerProcessEntry\.js$/.test(process.argv[1] || ""))
137
+ installCodeCache("worker");
138
+ // Annotate the CommonJS export names for ESM import in node:
139
+ 0 && (module.exports = {
140
+ installCodeCache
141
+ });
@@ -0,0 +1,8 @@
1
+ # packages/playwright/lib/codeCache.js
2
+ # total: 6.4 KB
3
+
4
+ ## Inlined (1)
5
+ 4.9 KB packages/playwright/src/codeCache.ts
6
+
7
+ ## External (1)
8
+ playwright-core/package.json