@stablyai/internal-playwright 0.1.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +168 -0
- package/ThirdPartyNotices.txt +6277 -0
- package/cli.js +19 -0
- package/index.d.ts +17 -0
- package/index.js +17 -0
- package/index.mjs +18 -0
- package/jsx-runtime.js +42 -0
- package/jsx-runtime.mjs +21 -0
- package/lib/agents/generateAgents.js +265 -0
- package/lib/agents/generator.md +102 -0
- package/lib/agents/healer.md +78 -0
- package/lib/agents/planner.md +135 -0
- package/lib/cli.js +274 -0
- package/lib/common/config.js +274 -0
- package/lib/common/config.js.map +7 -0
- package/lib/common/configLoader.js +377 -0
- package/lib/common/configLoader.js.map +7 -0
- package/lib/common/esmLoaderHost.js +102 -0
- package/lib/common/esmLoaderHost.js.map +7 -0
- package/lib/common/expectBundle.js +52 -0
- package/lib/common/expectBundle.js.map +7 -0
- package/lib/common/expectBundleImpl.js +389 -0
- package/lib/common/expectBundleImpl.js.map +7 -0
- package/lib/common/fixtures.js +302 -0
- package/lib/common/fixtures.js.map +7 -0
- package/lib/common/globals.js +58 -0
- package/lib/common/globals.js.map +7 -0
- package/lib/common/ipc.js +60 -0
- package/lib/common/ipc.js.map +7 -0
- package/lib/common/poolBuilder.js +85 -0
- package/lib/common/poolBuilder.js.map +7 -0
- package/lib/common/process.js +104 -0
- package/lib/common/process.js.map +7 -0
- package/lib/common/suiteUtils.js +140 -0
- package/lib/common/suiteUtils.js.map +7 -0
- package/lib/common/test.js +321 -0
- package/lib/common/test.js.map +7 -0
- package/lib/common/testLoader.js +100 -0
- package/lib/common/testLoader.js.map +7 -0
- package/lib/common/testType.js +310 -0
- package/lib/common/testType.js.map +7 -0
- package/lib/fsWatcher.js +67 -0
- package/lib/fsWatcher.js.map +7 -0
- package/lib/index.js +696 -0
- package/lib/index.js.map +7 -0
- package/lib/internalsForTest.js +42 -0
- package/lib/internalsForTest.js.map +7 -0
- package/lib/isomorphic/events.js +77 -0
- package/lib/isomorphic/events.js.map +7 -0
- package/lib/isomorphic/folders.js +30 -0
- package/lib/isomorphic/folders.js.map +7 -0
- package/lib/isomorphic/stringInternPool.js +69 -0
- package/lib/isomorphic/stringInternPool.js.map +7 -0
- package/lib/isomorphic/teleReceiver.js +507 -0
- package/lib/isomorphic/teleReceiver.js.map +7 -0
- package/lib/isomorphic/teleSuiteUpdater.js +137 -0
- package/lib/isomorphic/teleSuiteUpdater.js.map +7 -0
- package/lib/isomorphic/testServerConnection.js +211 -0
- package/lib/isomorphic/testServerConnection.js.map +7 -0
- package/lib/isomorphic/testServerInterface.js +16 -0
- package/lib/isomorphic/testServerInterface.js.map +7 -0
- package/lib/isomorphic/testTree.js +334 -0
- package/lib/isomorphic/testTree.js.map +7 -0
- package/lib/isomorphic/types.d.js +16 -0
- package/lib/isomorphic/types.d.js.map +7 -0
- package/lib/loader/loaderMain.js +59 -0
- package/lib/loader/loaderMain.js.map +7 -0
- package/lib/matchers/expect.js +325 -0
- package/lib/matchers/expect.js.map +7 -0
- package/lib/matchers/matcherHint.js +87 -0
- package/lib/matchers/matcherHint.js.map +7 -0
- package/lib/matchers/matchers.js +366 -0
- package/lib/matchers/matchers.js.map +7 -0
- package/lib/matchers/toBeTruthy.js +73 -0
- package/lib/matchers/toBeTruthy.js.map +7 -0
- package/lib/matchers/toEqual.js +99 -0
- package/lib/matchers/toEqual.js.map +7 -0
- package/lib/matchers/toHaveURL.js +102 -0
- package/lib/matchers/toHaveURL.js.map +7 -0
- package/lib/matchers/toMatchAriaSnapshot.js +159 -0
- package/lib/matchers/toMatchAriaSnapshot.js.map +7 -0
- package/lib/matchers/toMatchSnapshot.js +359 -0
- package/lib/matchers/toMatchSnapshot.js.map +7 -0
- package/lib/matchers/toMatchText.js +99 -0
- package/lib/matchers/toMatchText.js.map +7 -0
- package/lib/mcp/browser/actions.d.js +16 -0
- package/lib/mcp/browser/backend.js +93 -0
- package/lib/mcp/browser/backend.js.map +7 -0
- package/lib/mcp/browser/browserContextFactory.js +296 -0
- package/lib/mcp/browser/browserServerBackend.js +76 -0
- package/lib/mcp/browser/codegen.js +66 -0
- package/lib/mcp/browser/config.js +385 -0
- package/lib/mcp/browser/context.js +287 -0
- package/lib/mcp/browser/response.js +228 -0
- package/lib/mcp/browser/sessionLog.js +160 -0
- package/lib/mcp/browser/tab.js +277 -0
- package/lib/mcp/browser/tool.js +30 -0
- package/lib/mcp/browser/tool.js.map +7 -0
- package/lib/mcp/browser/tools/common.js +63 -0
- package/lib/mcp/browser/tools/console.js +44 -0
- package/lib/mcp/browser/tools/dialogs.js +60 -0
- package/lib/mcp/browser/tools/evaluate.js +70 -0
- package/lib/mcp/browser/tools/files.js +58 -0
- package/lib/mcp/browser/tools/form.js +74 -0
- package/lib/mcp/browser/tools/install.js +69 -0
- package/lib/mcp/browser/tools/keyboard.js +85 -0
- package/lib/mcp/browser/tools/mouse.js +107 -0
- package/lib/mcp/browser/tools/navigate.js +62 -0
- package/lib/mcp/browser/tools/network.js +54 -0
- package/lib/mcp/browser/tools/pdf.js +59 -0
- package/lib/mcp/browser/tools/screenshot.js +88 -0
- package/lib/mcp/browser/tools/snapshot.js +182 -0
- package/lib/mcp/browser/tools/tabs.js +67 -0
- package/lib/mcp/browser/tools/tool.js +49 -0
- package/lib/mcp/browser/tools/tracing.js +74 -0
- package/lib/mcp/browser/tools/utils.js +100 -0
- package/lib/mcp/browser/tools/verify.js +154 -0
- package/lib/mcp/browser/tools/wait.js +63 -0
- package/lib/mcp/browser/tools.js +80 -0
- package/lib/mcp/browser/tools.js.map +7 -0
- package/lib/mcp/browser/watchdog.js +44 -0
- package/lib/mcp/config.d.js +16 -0
- package/lib/mcp/extension/cdpRelay.js +351 -0
- package/lib/mcp/extension/extensionContextFactory.js +75 -0
- package/lib/mcp/extension/protocol.js +28 -0
- package/lib/mcp/index.js +61 -0
- package/lib/mcp/log.js +35 -0
- package/lib/mcp/program.js +96 -0
- package/lib/mcp/sdk/bundle.js +81 -0
- package/lib/mcp/sdk/bundle.js.map +7 -0
- package/lib/mcp/sdk/call.js +49 -0
- package/lib/mcp/sdk/call.js.map +7 -0
- package/lib/mcp/sdk/exports.js +32 -0
- package/lib/mcp/sdk/exports.js.map +7 -0
- package/lib/mcp/sdk/http.js +187 -0
- package/lib/mcp/sdk/http.js.map +7 -0
- package/lib/mcp/sdk/inProcessTransport.js +71 -0
- package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
- package/lib/mcp/sdk/mdb.js +206 -0
- package/lib/mcp/sdk/mdb.js.map +7 -0
- package/lib/mcp/sdk/proxyBackend.js +128 -0
- package/lib/mcp/sdk/proxyBackend.js.map +7 -0
- package/lib/mcp/sdk/server.js +189 -0
- package/lib/mcp/sdk/server.js.map +7 -0
- package/lib/mcp/sdk/tool.js +51 -0
- package/lib/mcp/sdk/tool.js.map +7 -0
- package/lib/mcp/test/backend.js +67 -0
- package/lib/mcp/test/backend.js.map +7 -0
- package/lib/mcp/test/browserBackend.js +98 -0
- package/lib/mcp/test/context.js +48 -0
- package/lib/mcp/test/context.js.map +7 -0
- package/lib/mcp/test/generatorTools.js +122 -0
- package/lib/mcp/test/plannerTools.js +46 -0
- package/lib/mcp/test/seed.js +72 -0
- package/lib/mcp/test/streams.js +39 -0
- package/lib/mcp/test/streams.js.map +7 -0
- package/lib/mcp/test/testBackend.js +97 -0
- package/lib/mcp/test/testContext.js +176 -0
- package/lib/mcp/test/testTool.js +30 -0
- package/lib/mcp/test/testTools.js +115 -0
- package/lib/mcp/test/tool.js +30 -0
- package/lib/mcp/test/tool.js.map +7 -0
- package/lib/mcp/test/tools.js +150 -0
- package/lib/mcp/test/tools.js.map +7 -0
- package/lib/mcp/vscode/host.js +187 -0
- package/lib/mcp/vscode/main.js +77 -0
- package/lib/mcpBundleImpl.js +41 -0
- package/lib/mcpBundleImpl.js.map +7 -0
- package/lib/plugins/gitCommitInfoPlugin.js +198 -0
- package/lib/plugins/gitCommitInfoPlugin.js.map +7 -0
- package/lib/plugins/index.js +28 -0
- package/lib/plugins/index.js.map +7 -0
- package/lib/plugins/webServerPlugin.js +209 -0
- package/lib/plugins/webServerPlugin.js.map +7 -0
- package/lib/program.js +412 -0
- package/lib/program.js.map +7 -0
- package/lib/reporters/base.js +609 -0
- package/lib/reporters/base.js.map +7 -0
- package/lib/reporters/blob.js +135 -0
- package/lib/reporters/blob.js.map +7 -0
- package/lib/reporters/dot.js +82 -0
- package/lib/reporters/dot.js.map +7 -0
- package/lib/reporters/empty.js +32 -0
- package/lib/reporters/empty.js.map +7 -0
- package/lib/reporters/github.js +128 -0
- package/lib/reporters/github.js.map +7 -0
- package/lib/reporters/html.js +644 -0
- package/lib/reporters/html.js.map +7 -0
- package/lib/reporters/internalReporter.js +130 -0
- package/lib/reporters/internalReporter.js.map +7 -0
- package/lib/reporters/json.js +254 -0
- package/lib/reporters/json.js.map +7 -0
- package/lib/reporters/junit.js +230 -0
- package/lib/reporters/junit.js.map +7 -0
- package/lib/reporters/line.js +113 -0
- package/lib/reporters/line.js.map +7 -0
- package/lib/reporters/list.js +235 -0
- package/lib/reporters/list.js.map +7 -0
- package/lib/reporters/listModeReporter.js +69 -0
- package/lib/reporters/listModeReporter.js.map +7 -0
- package/lib/reporters/markdown.js +144 -0
- package/lib/reporters/markdown.js.map +7 -0
- package/lib/reporters/merge.js +535 -0
- package/lib/reporters/merge.js.map +7 -0
- package/lib/reporters/multiplexer.js +104 -0
- package/lib/reporters/multiplexer.js.map +7 -0
- package/lib/reporters/reporterV2.js +102 -0
- package/lib/reporters/reporterV2.js.map +7 -0
- package/lib/reporters/teleEmitter.js +297 -0
- package/lib/reporters/teleEmitter.js.map +7 -0
- package/lib/reporters/versions/blobV1.js +16 -0
- package/lib/reporters/versions/blobV1.js.map +7 -0
- package/lib/runner/dispatcher.js +491 -0
- package/lib/runner/dispatcher.js.map +7 -0
- package/lib/runner/failureTracker.js +72 -0
- package/lib/runner/failureTracker.js.map +7 -0
- package/lib/runner/lastRun.js +77 -0
- package/lib/runner/lastRun.js.map +7 -0
- package/lib/runner/loadUtils.js +333 -0
- package/lib/runner/loadUtils.js.map +7 -0
- package/lib/runner/loaderHost.js +89 -0
- package/lib/runner/loaderHost.js.map +7 -0
- package/lib/runner/processHost.js +161 -0
- package/lib/runner/processHost.js.map +7 -0
- package/lib/runner/projectUtils.js +241 -0
- package/lib/runner/projectUtils.js.map +7 -0
- package/lib/runner/rebase.js +189 -0
- package/lib/runner/rebase.js.map +7 -0
- package/lib/runner/reporters.js +137 -0
- package/lib/runner/reporters.js.map +7 -0
- package/lib/runner/runner.js +173 -0
- package/lib/runner/sigIntWatcher.js +96 -0
- package/lib/runner/sigIntWatcher.js.map +7 -0
- package/lib/runner/taskRunner.js +127 -0
- package/lib/runner/taskRunner.js.map +7 -0
- package/lib/runner/tasks.js +410 -0
- package/lib/runner/tasks.js.map +7 -0
- package/lib/runner/testGroups.js +117 -0
- package/lib/runner/testGroups.js.map +7 -0
- package/lib/runner/testRunner.js +390 -0
- package/lib/runner/testRunner.js.map +7 -0
- package/lib/runner/testServer.js +264 -0
- package/lib/runner/testServer.js.map +7 -0
- package/lib/runner/uiMode.js +271 -0
- package/lib/runner/uiModeReporter.js +30 -0
- package/lib/runner/uiModeReporter.js.map +7 -0
- package/lib/runner/vcs.js +72 -0
- package/lib/runner/vcs.js.map +7 -0
- package/lib/runner/watchMode.js +395 -0
- package/lib/runner/watchMode.js.map +7 -0
- package/lib/runner/workerHost.js +95 -0
- package/lib/runner/workerHost.js.map +7 -0
- package/lib/store.js +98 -0
- package/lib/third_party/pirates.js +62 -0
- package/lib/third_party/pirates.js.map +7 -0
- package/lib/third_party/tsconfig-loader.js +103 -0
- package/lib/third_party/tsconfig-loader.js.map +7 -0
- package/lib/transform/babelBundle.js +43 -0
- package/lib/transform/babelBundle.js.map +7 -0
- package/lib/transform/babelBundleImpl.js +461 -0
- package/lib/transform/babelBundleImpl.js.map +7 -0
- package/lib/transform/compilationCache.js +272 -0
- package/lib/transform/compilationCache.js.map +7 -0
- package/lib/transform/esmLoader.js +104 -0
- package/lib/transform/esmLoader.js.map +7 -0
- package/lib/transform/esmUtils.js +32 -0
- package/lib/transform/portTransport.js +67 -0
- package/lib/transform/portTransport.js.map +7 -0
- package/lib/transform/transform.js +293 -0
- package/lib/transform/transform.js.map +7 -0
- package/lib/util.js +403 -0
- package/lib/util.js.map +7 -0
- package/lib/utilsBundle.js +43 -0
- package/lib/utilsBundle.js.map +7 -0
- package/lib/utilsBundleImpl.js +100 -0
- package/lib/utilsBundleImpl.js.map +7 -0
- package/lib/worker/fixtureRunner.js +258 -0
- package/lib/worker/fixtureRunner.js.map +7 -0
- package/lib/worker/stepContext.js +34 -0
- package/lib/worker/testInfo.js +508 -0
- package/lib/worker/testInfo.js.map +7 -0
- package/lib/worker/testTracing.js +344 -0
- package/lib/worker/testTracing.js.map +7 -0
- package/lib/worker/timeoutManager.js +174 -0
- package/lib/worker/timeoutManager.js.map +7 -0
- package/lib/worker/util.js +31 -0
- package/lib/worker/util.js.map +7 -0
- package/lib/worker/workerMain.js +520 -0
- package/lib/worker/workerMain.js.map +7 -0
- package/package.json +74 -0
- package/test.d.ts +18 -0
- package/test.js +24 -0
- package/test.mjs +33 -0
- package/types/test.d.ts +10217 -0
- package/types/testReporter.d.ts +816 -0
@@ -0,0 +1,377 @@
|
|
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 configLoader_exports = {};
|
30
|
+
__export(configLoader_exports, {
|
31
|
+
defineConfig: () => defineConfig,
|
32
|
+
defineStablyConfig: () => defineStablyConfig,
|
33
|
+
deserializeConfig: () => deserializeConfig,
|
34
|
+
loadConfig: () => loadConfig,
|
35
|
+
loadConfigFromFile: () => loadConfigFromFile,
|
36
|
+
loadEmptyConfigForMergeReports: () => loadEmptyConfigForMergeReports,
|
37
|
+
resolveConfigLocation: () => resolveConfigLocation
|
38
|
+
});
|
39
|
+
module.exports = __toCommonJS(configLoader_exports);
|
40
|
+
var import_fs = __toESM(require("fs"));
|
41
|
+
var import_path = __toESM(require("path"));
|
42
|
+
var import_utils = require("playwright-core/lib/utils");
|
43
|
+
var import_transform = require("../transform/transform");
|
44
|
+
var import_util = require("../util");
|
45
|
+
var import_config = require("./config");
|
46
|
+
var import_esmLoaderHost = require("./esmLoaderHost");
|
47
|
+
var import_compilationCache = require("../transform/compilationCache");
|
48
|
+
const kDefineConfigWasUsed = Symbol("defineConfigWasUsed");
|
49
|
+
const defineConfig = (...configs) => {
|
50
|
+
let result = configs[0];
|
51
|
+
for (let i = 1; i < configs.length; ++i) {
|
52
|
+
const config = configs[i];
|
53
|
+
const prevProjects = result.projects;
|
54
|
+
result = {
|
55
|
+
...result,
|
56
|
+
...config,
|
57
|
+
expect: {
|
58
|
+
...result.expect,
|
59
|
+
...config.expect
|
60
|
+
},
|
61
|
+
use: {
|
62
|
+
...result.use,
|
63
|
+
...config.use
|
64
|
+
},
|
65
|
+
build: {
|
66
|
+
...result.build,
|
67
|
+
...config.build
|
68
|
+
},
|
69
|
+
webServer: [
|
70
|
+
...Array.isArray(result.webServer) ? result.webServer : result.webServer ? [result.webServer] : [],
|
71
|
+
...Array.isArray(config.webServer) ? config.webServer : config.webServer ? [config.webServer] : []
|
72
|
+
]
|
73
|
+
};
|
74
|
+
if (!result.projects && !config.projects)
|
75
|
+
continue;
|
76
|
+
const projectOverrides = /* @__PURE__ */ new Map();
|
77
|
+
for (const project of config.projects || [])
|
78
|
+
projectOverrides.set(project.name, project);
|
79
|
+
const projects = [];
|
80
|
+
for (const project of prevProjects || []) {
|
81
|
+
const projectOverride = projectOverrides.get(project.name);
|
82
|
+
if (projectOverride) {
|
83
|
+
projects.push({
|
84
|
+
...project,
|
85
|
+
...projectOverride,
|
86
|
+
use: {
|
87
|
+
...project.use,
|
88
|
+
...projectOverride.use
|
89
|
+
}
|
90
|
+
});
|
91
|
+
projectOverrides.delete(project.name);
|
92
|
+
} else {
|
93
|
+
projects.push(project);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
projects.push(...projectOverrides.values());
|
97
|
+
result.projects = projects;
|
98
|
+
}
|
99
|
+
result[kDefineConfigWasUsed] = true;
|
100
|
+
return result;
|
101
|
+
};
|
102
|
+
const defineStablyConfig = (config) => {
|
103
|
+
if (!config || typeof config !== "object")
|
104
|
+
throw new Error("stably.config must export an object");
|
105
|
+
return config;
|
106
|
+
};
|
107
|
+
async function deserializeConfig(data) {
|
108
|
+
if (data.compilationCache)
|
109
|
+
(0, import_compilationCache.addToCompilationCache)(data.compilationCache);
|
110
|
+
return await loadConfig(data.location, data.configCLIOverrides, void 0, data.metadata ? JSON.parse(data.metadata) : void 0);
|
111
|
+
}
|
112
|
+
async function loadUserConfig(location) {
|
113
|
+
let object = location.resolvedConfigFile ? await (0, import_transform.requireOrImport)(location.resolvedConfigFile) : {};
|
114
|
+
if (object && typeof object === "object" && "default" in object)
|
115
|
+
object = object["default"];
|
116
|
+
const stablyConfig = await loadStablyConfig(location);
|
117
|
+
if (stablyConfig)
|
118
|
+
object = defineConfig(object, stablyConfig);
|
119
|
+
return object;
|
120
|
+
}
|
121
|
+
async function loadStablyConfig(location) {
|
122
|
+
const configDir = location.configDir;
|
123
|
+
const stablyConfigPaths = [
|
124
|
+
"stably.config.ts",
|
125
|
+
"stably.config.js",
|
126
|
+
"stably.config.mjs"
|
127
|
+
];
|
128
|
+
for (const configPath of stablyConfigPaths) {
|
129
|
+
const fullPath = import_path.default.resolve(configDir, configPath);
|
130
|
+
if (import_fs.default.existsSync(fullPath)) {
|
131
|
+
try {
|
132
|
+
let stablyConfig = await (0, import_transform.requireOrImport)(fullPath);
|
133
|
+
if (stablyConfig && typeof stablyConfig === "object" && "default" in stablyConfig)
|
134
|
+
stablyConfig = stablyConfig["default"];
|
135
|
+
if (stablyConfig && typeof stablyConfig === "object")
|
136
|
+
return stablyConfig;
|
137
|
+
} catch (error) {
|
138
|
+
console.warn(`Warning: Failed to load ${configPath}: ${error.message}`);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
return null;
|
143
|
+
}
|
144
|
+
async function loadConfig(location, overrides, ignoreProjectDependencies = false, metadata) {
|
145
|
+
if (!(0, import_esmLoaderHost.registerESMLoader)()) {
|
146
|
+
if (location.resolvedConfigFile && (0, import_util.fileIsModule)(location.resolvedConfigFile))
|
147
|
+
throw (0, import_util.errorWithFile)(location.resolvedConfigFile, `Playwright requires Node.js 18.19 or higher to load esm modules. Please update your version of Node.js.`);
|
148
|
+
}
|
149
|
+
(0, import_transform.setSingleTSConfig)(overrides?.tsconfig);
|
150
|
+
await (0, import_esmLoaderHost.configureESMLoader)();
|
151
|
+
const userConfig = await loadUserConfig(location);
|
152
|
+
validateConfig(location.resolvedConfigFile || "<default config>", userConfig);
|
153
|
+
const fullConfig = new import_config.FullConfigInternal(location, userConfig, overrides || {}, metadata);
|
154
|
+
fullConfig.defineConfigWasUsed = !!userConfig[kDefineConfigWasUsed];
|
155
|
+
if (ignoreProjectDependencies) {
|
156
|
+
for (const project of fullConfig.projects) {
|
157
|
+
project.deps = [];
|
158
|
+
project.teardown = void 0;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
const babelPlugins = userConfig["@playwright/test"]?.babelPlugins || [];
|
162
|
+
const external = userConfig.build?.external || [];
|
163
|
+
(0, import_transform.setTransformConfig)({ babelPlugins, external });
|
164
|
+
if (!overrides?.tsconfig)
|
165
|
+
(0, import_transform.setSingleTSConfig)(fullConfig?.singleTSConfigPath);
|
166
|
+
await (0, import_esmLoaderHost.configureESMLoaderTransformConfig)();
|
167
|
+
return fullConfig;
|
168
|
+
}
|
169
|
+
function validateConfig(file, config) {
|
170
|
+
if (typeof config !== "object" || !config)
|
171
|
+
throw (0, import_util.errorWithFile)(file, `Configuration file must export a single object`);
|
172
|
+
validateProject(file, config, "config");
|
173
|
+
if ("forbidOnly" in config && config.forbidOnly !== void 0) {
|
174
|
+
if (typeof config.forbidOnly !== "boolean")
|
175
|
+
throw (0, import_util.errorWithFile)(file, `config.forbidOnly must be a boolean`);
|
176
|
+
}
|
177
|
+
if ("globalSetup" in config && config.globalSetup !== void 0) {
|
178
|
+
if (Array.isArray(config.globalSetup)) {
|
179
|
+
config.globalSetup.forEach((item, index) => {
|
180
|
+
if (typeof item !== "string")
|
181
|
+
throw (0, import_util.errorWithFile)(file, `config.globalSetup[${index}] must be a string`);
|
182
|
+
});
|
183
|
+
} else if (typeof config.globalSetup !== "string") {
|
184
|
+
throw (0, import_util.errorWithFile)(file, `config.globalSetup must be a string`);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
if ("globalTeardown" in config && config.globalTeardown !== void 0) {
|
188
|
+
if (Array.isArray(config.globalTeardown)) {
|
189
|
+
config.globalTeardown.forEach((item, index) => {
|
190
|
+
if (typeof item !== "string")
|
191
|
+
throw (0, import_util.errorWithFile)(file, `config.globalTeardown[${index}] must be a string`);
|
192
|
+
});
|
193
|
+
} else if (typeof config.globalTeardown !== "string") {
|
194
|
+
throw (0, import_util.errorWithFile)(file, `config.globalTeardown must be a string`);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
if ("globalTimeout" in config && config.globalTimeout !== void 0) {
|
198
|
+
if (typeof config.globalTimeout !== "number" || config.globalTimeout < 0)
|
199
|
+
throw (0, import_util.errorWithFile)(file, `config.globalTimeout must be a non-negative number`);
|
200
|
+
}
|
201
|
+
if ("grep" in config && config.grep !== void 0) {
|
202
|
+
if (Array.isArray(config.grep)) {
|
203
|
+
config.grep.forEach((item, index) => {
|
204
|
+
if (!(0, import_utils.isRegExp)(item))
|
205
|
+
throw (0, import_util.errorWithFile)(file, `config.grep[${index}] must be a RegExp`);
|
206
|
+
});
|
207
|
+
} else if (!(0, import_utils.isRegExp)(config.grep)) {
|
208
|
+
throw (0, import_util.errorWithFile)(file, `config.grep must be a RegExp`);
|
209
|
+
}
|
210
|
+
}
|
211
|
+
if ("grepInvert" in config && config.grepInvert !== void 0) {
|
212
|
+
if (Array.isArray(config.grepInvert)) {
|
213
|
+
config.grepInvert.forEach((item, index) => {
|
214
|
+
if (!(0, import_utils.isRegExp)(item))
|
215
|
+
throw (0, import_util.errorWithFile)(file, `config.grepInvert[${index}] must be a RegExp`);
|
216
|
+
});
|
217
|
+
} else if (!(0, import_utils.isRegExp)(config.grepInvert)) {
|
218
|
+
throw (0, import_util.errorWithFile)(file, `config.grepInvert must be a RegExp`);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
if ("maxFailures" in config && config.maxFailures !== void 0) {
|
222
|
+
if (typeof config.maxFailures !== "number" || config.maxFailures < 0)
|
223
|
+
throw (0, import_util.errorWithFile)(file, `config.maxFailures must be a non-negative number`);
|
224
|
+
}
|
225
|
+
if ("preserveOutput" in config && config.preserveOutput !== void 0) {
|
226
|
+
if (typeof config.preserveOutput !== "string" || !["always", "never", "failures-only"].includes(config.preserveOutput))
|
227
|
+
throw (0, import_util.errorWithFile)(file, `config.preserveOutput must be one of "always", "never" or "failures-only"`);
|
228
|
+
}
|
229
|
+
if ("projects" in config && config.projects !== void 0) {
|
230
|
+
if (!Array.isArray(config.projects))
|
231
|
+
throw (0, import_util.errorWithFile)(file, `config.projects must be an array`);
|
232
|
+
config.projects.forEach((project, index) => {
|
233
|
+
validateProject(file, project, `config.projects[${index}]`);
|
234
|
+
});
|
235
|
+
}
|
236
|
+
if ("quiet" in config && config.quiet !== void 0) {
|
237
|
+
if (typeof config.quiet !== "boolean")
|
238
|
+
throw (0, import_util.errorWithFile)(file, `config.quiet must be a boolean`);
|
239
|
+
}
|
240
|
+
if ("reporter" in config && config.reporter !== void 0) {
|
241
|
+
if (Array.isArray(config.reporter)) {
|
242
|
+
config.reporter.forEach((item, index) => {
|
243
|
+
if (!Array.isArray(item) || item.length <= 0 || item.length > 2 || typeof item[0] !== "string")
|
244
|
+
throw (0, import_util.errorWithFile)(file, `config.reporter[${index}] must be a tuple [name, optionalArgument]`);
|
245
|
+
});
|
246
|
+
} else if (typeof config.reporter !== "string") {
|
247
|
+
throw (0, import_util.errorWithFile)(file, `config.reporter must be a string`);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
if ("reportSlowTests" in config && config.reportSlowTests !== void 0 && config.reportSlowTests !== null) {
|
251
|
+
if (!config.reportSlowTests || typeof config.reportSlowTests !== "object")
|
252
|
+
throw (0, import_util.errorWithFile)(file, `config.reportSlowTests must be an object`);
|
253
|
+
if (!("max" in config.reportSlowTests) || typeof config.reportSlowTests.max !== "number" || config.reportSlowTests.max < 0)
|
254
|
+
throw (0, import_util.errorWithFile)(file, `config.reportSlowTests.max must be a non-negative number`);
|
255
|
+
if (!("threshold" in config.reportSlowTests) || typeof config.reportSlowTests.threshold !== "number" || config.reportSlowTests.threshold < 0)
|
256
|
+
throw (0, import_util.errorWithFile)(file, `config.reportSlowTests.threshold must be a non-negative number`);
|
257
|
+
}
|
258
|
+
if ("shard" in config && config.shard !== void 0 && config.shard !== null) {
|
259
|
+
if (!config.shard || typeof config.shard !== "object")
|
260
|
+
throw (0, import_util.errorWithFile)(file, `config.shard must be an object`);
|
261
|
+
if (!("total" in config.shard) || typeof config.shard.total !== "number" || config.shard.total < 1)
|
262
|
+
throw (0, import_util.errorWithFile)(file, `config.shard.total must be a positive number`);
|
263
|
+
if (!("current" in config.shard) || typeof config.shard.current !== "number" || config.shard.current < 1 || config.shard.current > config.shard.total)
|
264
|
+
throw (0, import_util.errorWithFile)(file, `config.shard.current must be a positive number, not greater than config.shard.total`);
|
265
|
+
}
|
266
|
+
if ("updateSnapshots" in config && config.updateSnapshots !== void 0) {
|
267
|
+
if (typeof config.updateSnapshots !== "string" || !["all", "changed", "missing", "none"].includes(config.updateSnapshots))
|
268
|
+
throw (0, import_util.errorWithFile)(file, `config.updateSnapshots must be one of "all", "changed", "missing" or "none"`);
|
269
|
+
}
|
270
|
+
if ("tsconfig" in config && config.tsconfig !== void 0) {
|
271
|
+
if (typeof config.tsconfig !== "string")
|
272
|
+
throw (0, import_util.errorWithFile)(file, `config.tsconfig must be a string`);
|
273
|
+
if (!import_fs.default.existsSync(import_path.default.resolve(file, "..", config.tsconfig)))
|
274
|
+
throw (0, import_util.errorWithFile)(file, `config.tsconfig does not exist`);
|
275
|
+
}
|
276
|
+
}
|
277
|
+
function validateProject(file, project, title) {
|
278
|
+
if (typeof project !== "object" || !project)
|
279
|
+
throw (0, import_util.errorWithFile)(file, `${title} must be an object`);
|
280
|
+
if ("name" in project && project.name !== void 0) {
|
281
|
+
if (typeof project.name !== "string")
|
282
|
+
throw (0, import_util.errorWithFile)(file, `${title}.name must be a string`);
|
283
|
+
}
|
284
|
+
if ("outputDir" in project && project.outputDir !== void 0) {
|
285
|
+
if (typeof project.outputDir !== "string")
|
286
|
+
throw (0, import_util.errorWithFile)(file, `${title}.outputDir must be a string`);
|
287
|
+
}
|
288
|
+
if ("repeatEach" in project && project.repeatEach !== void 0) {
|
289
|
+
if (typeof project.repeatEach !== "number" || project.repeatEach < 0)
|
290
|
+
throw (0, import_util.errorWithFile)(file, `${title}.repeatEach must be a non-negative number`);
|
291
|
+
}
|
292
|
+
if ("retries" in project && project.retries !== void 0) {
|
293
|
+
if (typeof project.retries !== "number" || project.retries < 0)
|
294
|
+
throw (0, import_util.errorWithFile)(file, `${title}.retries must be a non-negative number`);
|
295
|
+
}
|
296
|
+
if ("testDir" in project && project.testDir !== void 0) {
|
297
|
+
if (typeof project.testDir !== "string")
|
298
|
+
throw (0, import_util.errorWithFile)(file, `${title}.testDir must be a string`);
|
299
|
+
}
|
300
|
+
for (const prop of ["testIgnore", "testMatch"]) {
|
301
|
+
if (prop in project && project[prop] !== void 0) {
|
302
|
+
const value = project[prop];
|
303
|
+
if (Array.isArray(value)) {
|
304
|
+
value.forEach((item, index) => {
|
305
|
+
if (typeof item !== "string" && !(0, import_utils.isRegExp)(item))
|
306
|
+
throw (0, import_util.errorWithFile)(file, `${title}.${prop}[${index}] must be a string or a RegExp`);
|
307
|
+
});
|
308
|
+
} else if (typeof value !== "string" && !(0, import_utils.isRegExp)(value)) {
|
309
|
+
throw (0, import_util.errorWithFile)(file, `${title}.${prop} must be a string or a RegExp`);
|
310
|
+
}
|
311
|
+
}
|
312
|
+
}
|
313
|
+
if ("timeout" in project && project.timeout !== void 0) {
|
314
|
+
if (typeof project.timeout !== "number" || project.timeout < 0)
|
315
|
+
throw (0, import_util.errorWithFile)(file, `${title}.timeout must be a non-negative number`);
|
316
|
+
}
|
317
|
+
if ("use" in project && project.use !== void 0) {
|
318
|
+
if (!project.use || typeof project.use !== "object")
|
319
|
+
throw (0, import_util.errorWithFile)(file, `${title}.use must be an object`);
|
320
|
+
}
|
321
|
+
if ("ignoreSnapshots" in project && project.ignoreSnapshots !== void 0) {
|
322
|
+
if (typeof project.ignoreSnapshots !== "boolean")
|
323
|
+
throw (0, import_util.errorWithFile)(file, `${title}.ignoreSnapshots must be a boolean`);
|
324
|
+
}
|
325
|
+
if ("workers" in project && project.workers !== void 0) {
|
326
|
+
if (typeof project.workers === "number" && project.workers <= 0)
|
327
|
+
throw (0, import_util.errorWithFile)(file, `${title}.workers must be a positive number`);
|
328
|
+
else if (typeof project.workers === "string" && !project.workers.endsWith("%"))
|
329
|
+
throw (0, import_util.errorWithFile)(file, `${title}.workers must be a number or percentage`);
|
330
|
+
}
|
331
|
+
}
|
332
|
+
function resolveConfigLocation(configFile) {
|
333
|
+
const configFileOrDirectory = configFile ? import_path.default.resolve(process.cwd(), configFile) : process.cwd();
|
334
|
+
const resolvedConfigFile = resolveConfigFile(configFileOrDirectory);
|
335
|
+
return {
|
336
|
+
resolvedConfigFile,
|
337
|
+
configDir: resolvedConfigFile ? import_path.default.dirname(resolvedConfigFile) : configFileOrDirectory
|
338
|
+
};
|
339
|
+
}
|
340
|
+
function resolveConfigFile(configFileOrDirectory) {
|
341
|
+
const resolveConfig = (configFile) => {
|
342
|
+
if (import_fs.default.existsSync(configFile))
|
343
|
+
return configFile;
|
344
|
+
};
|
345
|
+
const resolveConfigFileFromDirectory = (directory) => {
|
346
|
+
for (const ext of [".ts", ".js", ".mts", ".mjs", ".cts", ".cjs"]) {
|
347
|
+
const configFile = resolveConfig(import_path.default.resolve(directory, "playwright.config" + ext));
|
348
|
+
if (configFile)
|
349
|
+
return configFile;
|
350
|
+
}
|
351
|
+
};
|
352
|
+
if (!import_fs.default.existsSync(configFileOrDirectory))
|
353
|
+
throw new Error(`${configFileOrDirectory} does not exist`);
|
354
|
+
if (import_fs.default.statSync(configFileOrDirectory).isDirectory()) {
|
355
|
+
const configFile = resolveConfigFileFromDirectory(configFileOrDirectory);
|
356
|
+
if (configFile)
|
357
|
+
return configFile;
|
358
|
+
return void 0;
|
359
|
+
}
|
360
|
+
return configFileOrDirectory;
|
361
|
+
}
|
362
|
+
async function loadConfigFromFile(configFile, overrides, ignoreDeps) {
|
363
|
+
return await loadConfig(resolveConfigLocation(configFile), overrides, ignoreDeps);
|
364
|
+
}
|
365
|
+
async function loadEmptyConfigForMergeReports() {
|
366
|
+
return await loadConfig({ configDir: process.cwd() });
|
367
|
+
}
|
368
|
+
// Annotate the CommonJS export names for ESM import in node:
|
369
|
+
0 && (module.exports = {
|
370
|
+
defineConfig,
|
371
|
+
defineStablyConfig,
|
372
|
+
deserializeConfig,
|
373
|
+
loadConfig,
|
374
|
+
loadConfigFromFile,
|
375
|
+
loadEmptyConfigForMergeReports,
|
376
|
+
resolveConfigLocation
|
377
|
+
});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/common/configLoader.ts"],
|
4
|
+
"sourcesContent": ["/**\n * Copyright Microsoft Corporation. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs';\nimport path from 'path';\n\nimport { isRegExp } from 'playwright-core/lib/utils';\n\nimport { requireOrImport, setSingleTSConfig, setTransformConfig } from '../transform/transform';\nimport { errorWithFile, fileIsModule } from '../util';\nimport { FullConfigInternal } from './config';\nimport { configureESMLoader, configureESMLoaderTransformConfig, registerESMLoader } from './esmLoaderHost';\nimport { addToCompilationCache } from '../transform/compilationCache';\n\nimport type { ConfigLocation } from './config';\nimport type { ConfigCLIOverrides, SerializedConfig } from './ipc';\nimport type { Config, Project } from '../../types/test';\n\nconst kDefineConfigWasUsed = Symbol('defineConfigWasUsed');\nexport const defineConfig = (...configs: any[]) => {\n let result = configs[0];\n for (let i = 1; i < configs.length; ++i) {\n const config = configs[i];\n const prevProjects = result.projects;\n result = {\n ...result,\n ...config,\n expect: {\n ...result.expect,\n ...config.expect,\n },\n use: {\n ...result.use,\n ...config.use,\n },\n build: {\n ...result.build,\n ...config.build,\n },\n webServer: [\n ...(Array.isArray(result.webServer) ? result.webServer : (result.webServer ? [result.webServer] : [])),\n ...(Array.isArray(config.webServer) ? config.webServer : (config.webServer ? [config.webServer] : [])),\n ]\n };\n\n if (!result.projects && !config.projects)\n continue;\n\n const projectOverrides = new Map<string, any>();\n for (const project of config.projects || [])\n projectOverrides.set(project.name, project);\n\n const projects = [];\n for (const project of prevProjects || []) {\n const projectOverride = projectOverrides.get(project.name);\n if (projectOverride) {\n projects.push({\n ...project,\n ...projectOverride,\n use: {\n ...project.use,\n ...projectOverride.use,\n }\n });\n projectOverrides.delete(project.name);\n } else {\n projects.push(project);\n }\n }\n projects.push(...projectOverrides.values());\n result.projects = projects;\n }\n result[kDefineConfigWasUsed] = true;\n return result;\n};\n\nexport async function deserializeConfig(data: SerializedConfig): Promise<FullConfigInternal> {\n if (data.compilationCache)\n addToCompilationCache(data.compilationCache);\n return await loadConfig(data.location, data.configCLIOverrides, undefined, data.metadata ? JSON.parse(data.metadata) : undefined);\n}\n\nasync function loadUserConfig(location: ConfigLocation): Promise<Config> {\n let object = location.resolvedConfigFile ? await requireOrImport(location.resolvedConfigFile) : {};\n if (object && typeof object === 'object' && ('default' in object))\n object = object['default'];\n return object as Config;\n}\n\nexport async function loadConfig(location: ConfigLocation, overrides?: ConfigCLIOverrides, ignoreProjectDependencies = false, metadata?: Config['metadata']): Promise<FullConfigInternal> {\n // 0. Setup ESM loader if needed.\n if (!registerESMLoader()) {\n // In Node.js < 18, complain if the config file is ESM. Historically, we would restart\n // the process with --loader, but now we require newer Node.js.\n if (location.resolvedConfigFile && fileIsModule(location.resolvedConfigFile))\n throw errorWithFile(location.resolvedConfigFile, `Playwright requires Node.js 18.19 or higher to load esm modules. Please update your version of Node.js.`);\n }\n\n // 1. Setup tsconfig; configure ESM loader with tsconfig and compilation cache.\n setSingleTSConfig(overrides?.tsconfig);\n await configureESMLoader();\n\n // 2. Load and validate playwright config.\n const userConfig = await loadUserConfig(location);\n validateConfig(location.resolvedConfigFile || '<default config>', userConfig);\n const fullConfig = new FullConfigInternal(location, userConfig, overrides || {}, metadata);\n fullConfig.defineConfigWasUsed = !!(userConfig as any)[kDefineConfigWasUsed];\n if (ignoreProjectDependencies) {\n for (const project of fullConfig.projects) {\n project.deps = [];\n project.teardown = undefined;\n }\n }\n\n // 3. Load transform options from the playwright config.\n const babelPlugins = (userConfig as any)['@playwright/test']?.babelPlugins || [];\n const external = userConfig.build?.external || [];\n setTransformConfig({ babelPlugins, external });\n if (!overrides?.tsconfig)\n setSingleTSConfig(fullConfig?.singleTSConfigPath);\n\n // 4. Send transform options to ESM loader.\n await configureESMLoaderTransformConfig();\n\n return fullConfig;\n}\n\nfunction validateConfig(file: string, config: Config) {\n if (typeof config !== 'object' || !config)\n throw errorWithFile(file, `Configuration file must export a single object`);\n\n validateProject(file, config, 'config');\n\n if ('forbidOnly' in config && config.forbidOnly !== undefined) {\n if (typeof config.forbidOnly !== 'boolean')\n throw errorWithFile(file, `config.forbidOnly must be a boolean`);\n }\n\n if ('globalSetup' in config && config.globalSetup !== undefined) {\n if (Array.isArray(config.globalSetup)) {\n config.globalSetup.forEach((item, index) => {\n if (typeof item !== 'string')\n throw errorWithFile(file, `config.globalSetup[${index}] must be a string`);\n });\n } else if (typeof config.globalSetup !== 'string') {\n throw errorWithFile(file, `config.globalSetup must be a string`);\n }\n }\n\n if ('globalTeardown' in config && config.globalTeardown !== undefined) {\n if (Array.isArray(config.globalTeardown)) {\n config.globalTeardown.forEach((item, index) => {\n if (typeof item !== 'string')\n throw errorWithFile(file, `config.globalTeardown[${index}] must be a string`);\n });\n } else if (typeof config.globalTeardown !== 'string') {\n throw errorWithFile(file, `config.globalTeardown must be a string`);\n }\n }\n\n if ('globalTimeout' in config && config.globalTimeout !== undefined) {\n if (typeof config.globalTimeout !== 'number' || config.globalTimeout < 0)\n throw errorWithFile(file, `config.globalTimeout must be a non-negative number`);\n }\n\n if ('grep' in config && config.grep !== undefined) {\n if (Array.isArray(config.grep)) {\n config.grep.forEach((item, index) => {\n if (!isRegExp(item))\n throw errorWithFile(file, `config.grep[${index}] must be a RegExp`);\n });\n } else if (!isRegExp(config.grep)) {\n throw errorWithFile(file, `config.grep must be a RegExp`);\n }\n }\n\n if ('grepInvert' in config && config.grepInvert !== undefined) {\n if (Array.isArray(config.grepInvert)) {\n config.grepInvert.forEach((item, index) => {\n if (!isRegExp(item))\n throw errorWithFile(file, `config.grepInvert[${index}] must be a RegExp`);\n });\n } else if (!isRegExp(config.grepInvert)) {\n throw errorWithFile(file, `config.grepInvert must be a RegExp`);\n }\n }\n\n if ('maxFailures' in config && config.maxFailures !== undefined) {\n if (typeof config.maxFailures !== 'number' || config.maxFailures < 0)\n throw errorWithFile(file, `config.maxFailures must be a non-negative number`);\n }\n\n if ('preserveOutput' in config && config.preserveOutput !== undefined) {\n if (typeof config.preserveOutput !== 'string' || !['always', 'never', 'failures-only'].includes(config.preserveOutput))\n throw errorWithFile(file, `config.preserveOutput must be one of \"always\", \"never\" or \"failures-only\"`);\n }\n\n if ('projects' in config && config.projects !== undefined) {\n if (!Array.isArray(config.projects))\n throw errorWithFile(file, `config.projects must be an array`);\n config.projects.forEach((project, index) => {\n validateProject(file, project, `config.projects[${index}]`);\n });\n }\n\n if ('quiet' in config && config.quiet !== undefined) {\n if (typeof config.quiet !== 'boolean')\n throw errorWithFile(file, `config.quiet must be a boolean`);\n }\n\n if ('reporter' in config && config.reporter !== undefined) {\n if (Array.isArray(config.reporter)) {\n config.reporter.forEach((item, index) => {\n if (!Array.isArray(item) || item.length <= 0 || item.length > 2 || typeof item[0] !== 'string')\n throw errorWithFile(file, `config.reporter[${index}] must be a tuple [name, optionalArgument]`);\n });\n } else if (typeof config.reporter !== 'string') {\n throw errorWithFile(file, `config.reporter must be a string`);\n }\n }\n\n if ('reportSlowTests' in config && config.reportSlowTests !== undefined && config.reportSlowTests !== null) {\n if (!config.reportSlowTests || typeof config.reportSlowTests !== 'object')\n throw errorWithFile(file, `config.reportSlowTests must be an object`);\n if (!('max' in config.reportSlowTests) || typeof config.reportSlowTests.max !== 'number' || config.reportSlowTests.max < 0)\n throw errorWithFile(file, `config.reportSlowTests.max must be a non-negative number`);\n if (!('threshold' in config.reportSlowTests) || typeof config.reportSlowTests.threshold !== 'number' || config.reportSlowTests.threshold < 0)\n throw errorWithFile(file, `config.reportSlowTests.threshold must be a non-negative number`);\n }\n\n if ('shard' in config && config.shard !== undefined && config.shard !== null) {\n if (!config.shard || typeof config.shard !== 'object')\n throw errorWithFile(file, `config.shard must be an object`);\n if (!('total' in config.shard) || typeof config.shard.total !== 'number' || config.shard.total < 1)\n throw errorWithFile(file, `config.shard.total must be a positive number`);\n if (!('current' in config.shard) || typeof config.shard.current !== 'number' || config.shard.current < 1 || config.shard.current > config.shard.total)\n throw errorWithFile(file, `config.shard.current must be a positive number, not greater than config.shard.total`);\n }\n\n if ('updateSnapshots' in config && config.updateSnapshots !== undefined) {\n if (typeof config.updateSnapshots !== 'string' || !['all', 'changed', 'missing', 'none'].includes(config.updateSnapshots))\n throw errorWithFile(file, `config.updateSnapshots must be one of \"all\", \"changed\", \"missing\" or \"none\"`);\n }\n\n if ('tsconfig' in config && config.tsconfig !== undefined) {\n if (typeof config.tsconfig !== 'string')\n throw errorWithFile(file, `config.tsconfig must be a string`);\n if (!fs.existsSync(path.resolve(file, '..', config.tsconfig)))\n throw errorWithFile(file, `config.tsconfig does not exist`);\n }\n}\n\nfunction validateProject(file: string, project: Project, title: string) {\n if (typeof project !== 'object' || !project)\n throw errorWithFile(file, `${title} must be an object`);\n\n if ('name' in project && project.name !== undefined) {\n if (typeof project.name !== 'string')\n throw errorWithFile(file, `${title}.name must be a string`);\n }\n\n if ('outputDir' in project && project.outputDir !== undefined) {\n if (typeof project.outputDir !== 'string')\n throw errorWithFile(file, `${title}.outputDir must be a string`);\n }\n\n if ('repeatEach' in project && project.repeatEach !== undefined) {\n if (typeof project.repeatEach !== 'number' || project.repeatEach < 0)\n throw errorWithFile(file, `${title}.repeatEach must be a non-negative number`);\n }\n\n if ('retries' in project && project.retries !== undefined) {\n if (typeof project.retries !== 'number' || project.retries < 0)\n throw errorWithFile(file, `${title}.retries must be a non-negative number`);\n }\n\n if ('testDir' in project && project.testDir !== undefined) {\n if (typeof project.testDir !== 'string')\n throw errorWithFile(file, `${title}.testDir must be a string`);\n }\n\n for (const prop of ['testIgnore', 'testMatch'] as const) {\n if (prop in project && project[prop] !== undefined) {\n const value = project[prop];\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n if (typeof item !== 'string' && !isRegExp(item))\n throw errorWithFile(file, `${title}.${prop}[${index}] must be a string or a RegExp`);\n });\n } else if (typeof value !== 'string' && !isRegExp(value)) {\n throw errorWithFile(file, `${title}.${prop} must be a string or a RegExp`);\n }\n }\n }\n\n if ('timeout' in project && project.timeout !== undefined) {\n if (typeof project.timeout !== 'number' || project.timeout < 0)\n throw errorWithFile(file, `${title}.timeout must be a non-negative number`);\n }\n\n if ('use' in project && project.use !== undefined) {\n if (!project.use || typeof project.use !== 'object')\n throw errorWithFile(file, `${title}.use must be an object`);\n }\n\n if ('ignoreSnapshots' in project && project.ignoreSnapshots !== undefined) {\n if (typeof project.ignoreSnapshots !== 'boolean')\n throw errorWithFile(file, `${title}.ignoreSnapshots must be a boolean`);\n }\n\n if ('workers' in project && project.workers !== undefined) {\n if (typeof project.workers === 'number' && project.workers <= 0)\n throw errorWithFile(file, `${title}.workers must be a positive number`);\n else if (typeof project.workers === 'string' && !project.workers.endsWith('%'))\n throw errorWithFile(file, `${title}.workers must be a number or percentage`);\n }\n}\n\nexport function resolveConfigLocation(configFile: string | undefined): ConfigLocation {\n const configFileOrDirectory = configFile ? path.resolve(process.cwd(), configFile) : process.cwd();\n const resolvedConfigFile = resolveConfigFile(configFileOrDirectory);\n return {\n resolvedConfigFile,\n configDir: resolvedConfigFile ? path.dirname(resolvedConfigFile) : configFileOrDirectory,\n };\n}\n\nfunction resolveConfigFile(configFileOrDirectory: string): string | undefined {\n const resolveConfig = (configFile: string) => {\n if (fs.existsSync(configFile))\n return configFile;\n };\n\n const resolveConfigFileFromDirectory = (directory: string) => {\n for (const ext of ['.ts', '.js', '.mts', '.mjs', '.cts', '.cjs']) {\n const configFile = resolveConfig(path.resolve(directory, 'playwright.config' + ext));\n if (configFile)\n return configFile;\n }\n };\n\n if (!fs.existsSync(configFileOrDirectory))\n throw new Error(`${configFileOrDirectory} does not exist`);\n if (fs.statSync(configFileOrDirectory).isDirectory()) {\n // When passed a directory, look for a config file inside.\n const configFile = resolveConfigFileFromDirectory(configFileOrDirectory);\n if (configFile)\n return configFile;\n // If there is no config, assume this as a root testing directory.\n return undefined;\n }\n // When passed a file, it must be a config file.\n return configFileOrDirectory!;\n}\n\nexport async function loadConfigFromFile(configFile: string | undefined, overrides?: ConfigCLIOverrides, ignoreDeps?: boolean): Promise<FullConfigInternal> {\n return await loadConfig(resolveConfigLocation(configFile), overrides, ignoreDeps);\n}\n\nexport async function loadEmptyConfigForMergeReports() {\n // Merge reports is \"different\" for no good reason. It should not pick up local config from the cwd.\n return await loadConfig({ configDir: process.cwd() });\n}\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,gBAAe;AACf,kBAAiB;AAEjB,mBAAyB;AAEzB,uBAAuE;AACvE,kBAA4C;AAC5C,oBAAmC;AACnC,2BAAyF;AACzF,8BAAsC;AAMtC,MAAM,uBAAuB,OAAO,qBAAqB;AAClD,MAAM,eAAe,IAAI,YAAmB;A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__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 esmLoaderHost_exports = {};
|
30
|
+
__export(esmLoaderHost_exports, {
|
31
|
+
configureESMLoader: () => configureESMLoader,
|
32
|
+
configureESMLoaderTransformConfig: () => configureESMLoaderTransformConfig,
|
33
|
+
incorporateCompilationCache: () => incorporateCompilationCache,
|
34
|
+
registerESMLoader: () => registerESMLoader,
|
35
|
+
startCollectingFileDeps: () => startCollectingFileDeps,
|
36
|
+
stopCollectingFileDeps: () => stopCollectingFileDeps
|
37
|
+
});
|
38
|
+
module.exports = __toCommonJS(esmLoaderHost_exports);
|
39
|
+
var import_url = __toESM(require("url"));
|
40
|
+
var import_compilationCache = require("../transform/compilationCache");
|
41
|
+
var import_portTransport = require("../transform/portTransport");
|
42
|
+
var import_transform = require("../transform/transform");
|
43
|
+
let loaderChannel;
|
44
|
+
function registerESMLoader() {
|
45
|
+
if (process.env.PW_DISABLE_TS_ESM)
|
46
|
+
return true;
|
47
|
+
if (loaderChannel)
|
48
|
+
return true;
|
49
|
+
const register = require("node:module").register;
|
50
|
+
if (!register)
|
51
|
+
return false;
|
52
|
+
const { port1, port2 } = new MessageChannel();
|
53
|
+
register(import_url.default.pathToFileURL(require.resolve("../transform/esmLoader")), {
|
54
|
+
data: { port: port2 },
|
55
|
+
transferList: [port2]
|
56
|
+
});
|
57
|
+
loaderChannel = createPortTransport(port1);
|
58
|
+
return true;
|
59
|
+
}
|
60
|
+
function createPortTransport(port) {
|
61
|
+
return new import_portTransport.PortTransport(port, async (method, params) => {
|
62
|
+
if (method === "pushToCompilationCache")
|
63
|
+
(0, import_compilationCache.addToCompilationCache)(params.cache);
|
64
|
+
});
|
65
|
+
}
|
66
|
+
async function startCollectingFileDeps() {
|
67
|
+
if (!loaderChannel)
|
68
|
+
return;
|
69
|
+
await loaderChannel.send("startCollectingFileDeps", {});
|
70
|
+
}
|
71
|
+
async function stopCollectingFileDeps(file) {
|
72
|
+
if (!loaderChannel)
|
73
|
+
return;
|
74
|
+
await loaderChannel.send("stopCollectingFileDeps", { file });
|
75
|
+
}
|
76
|
+
async function incorporateCompilationCache() {
|
77
|
+
if (!loaderChannel)
|
78
|
+
return;
|
79
|
+
const result = await loaderChannel.send("getCompilationCache", {});
|
80
|
+
(0, import_compilationCache.addToCompilationCache)(result.cache);
|
81
|
+
}
|
82
|
+
async function configureESMLoader() {
|
83
|
+
if (!loaderChannel)
|
84
|
+
return;
|
85
|
+
await loaderChannel.send("setSingleTSConfig", { tsconfig: (0, import_transform.singleTSConfig)() });
|
86
|
+
await loaderChannel.send("addToCompilationCache", { cache: (0, import_compilationCache.serializeCompilationCache)() });
|
87
|
+
}
|
88
|
+
async function configureESMLoaderTransformConfig() {
|
89
|
+
if (!loaderChannel)
|
90
|
+
return;
|
91
|
+
await loaderChannel.send("setSingleTSConfig", { tsconfig: (0, import_transform.singleTSConfig)() });
|
92
|
+
await loaderChannel.send("setTransformConfig", { config: (0, import_transform.transformConfig)() });
|
93
|
+
}
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
95
|
+
0 && (module.exports = {
|
96
|
+
configureESMLoader,
|
97
|
+
configureESMLoaderTransformConfig,
|
98
|
+
incorporateCompilationCache,
|
99
|
+
registerESMLoader,
|
100
|
+
startCollectingFileDeps,
|
101
|
+
stopCollectingFileDeps
|
102
|
+
});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/common/esmLoaderHost.ts"],
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport url from 'url';\n\nimport { addToCompilationCache, serializeCompilationCache } from '../transform/compilationCache';\nimport { PortTransport } from '../transform/portTransport';\nimport { singleTSConfig, transformConfig } from '../transform/transform';\n\nlet loaderChannel: PortTransport | undefined;\n\nexport function registerESMLoader() {\n // Opt-out switch.\n if (process.env.PW_DISABLE_TS_ESM)\n return true;\n\n if (loaderChannel)\n return true;\n\n const register = require('node:module').register;\n if (!register)\n return false;\n\n const { port1, port2 } = new MessageChannel();\n // register will wait until the loader is initialized.\n register(url.pathToFileURL(require.resolve('../transform/esmLoader')), {\n data: { port: port2 },\n transferList: [port2],\n });\n loaderChannel = createPortTransport(port1);\n return true;\n}\n\nfunction createPortTransport(port: MessagePort) {\n return new PortTransport(port, async (method, params) => {\n if (method === 'pushToCompilationCache')\n addToCompilationCache(params.cache);\n });\n}\n\nexport async function startCollectingFileDeps() {\n if (!loaderChannel)\n return;\n await loaderChannel.send('startCollectingFileDeps', {});\n}\n\nexport async function stopCollectingFileDeps(file: string) {\n if (!loaderChannel)\n return;\n await loaderChannel.send('stopCollectingFileDeps', { file });\n}\n\nexport async function incorporateCompilationCache() {\n if (!loaderChannel)\n return;\n // This is needed to gather dependency information from the esm loader\n // that is populated from the resolve hook. We do not need to push\n // this information proactively during load, but gather it at the end.\n const result = await loaderChannel.send('getCompilationCache', {});\n addToCompilationCache(result.cache);\n}\n\nexport async function configureESMLoader() {\n if (!loaderChannel)\n return;\n await loaderChannel.send('setSingleTSConfig', { tsconfig: singleTSConfig() });\n await loaderChannel.send('addToCompilationCache', { cache: serializeCompilationCache() });\n}\n\nexport async function configureESMLoaderTransformConfig() {\n if (!loaderChannel)\n return;\n await loaderChannel.send('setSingleTSConfig', { tsconfig: singleTSConfig() });\n await loaderChannel.send('setTransformConfig', { config: transformConfig() });\n}\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,iBAAgB;AAEhB,8BAAiE;AACjE,2BAA8B;AAC9B,uBAAgD;AAEhD,IAAI;AAEG,SAAS,oBAAoB;AAElC,MAAI,QAAQ,IAAI;AACd,WAAO;AAET,MAAI;AACF,WAAO;AAET,QAAM,WAAW,QAAQ,aAAa,EAAE;AACxC,MAAI,CAAC;AACH,WAAO;AAET,QAAM,EAAE,OAAO,MAAM,IAAI,IAAI,eAAe;AAE5C,WAAS,WAAAA,QAAI,cAAc,gBAAgB,wBAAwB,CAAC,GAAG;AAAA,IACrE,MAAM,EAAE,MAAM,MAAM;AAAA,IACpB,cAAc,CAAC,KAAK;AAAA,EACtB,CAAC;AACD,kBAAgB,oBAAoB,KAAK;AACzC,SAAO;AACT;AAEA,SAAS,oBAAoB,MAAmB;AAC9C,SAAO,IAAI,mCAAc,MAAM,OAAO,QAAQ,WAAW;AACvD,QAAI,WAAW;AACb,yDAAsB,OAAO,KAAK;AAAA,EACtC,CAAC;AACH;AAEA,eAAsB,0BAA0B;AAC9C,MAAI,CAAC;AACH;AACF,QAAM,cAAc,KAAK,2BAA2B,CAAC,CAAC;AACxD;AAEA,eAAsB,uBAAuB,MAAc;AACzD,MAAI,CAAC;AACH;AACF,QAAM,cAAc,KAAK,0BAA0B,EAAE,KAAK,CAAC;AAC7D;AAEA,eAAsB,8BAA8B;AAClD,MAAI,CAAC;AACH;AAIF,QAAM,SAAS,MAAM,cAAc,KAAK,uBAAuB,CAAC,CAAC;AACjE,qDAAsB,OAAO,KAAK;AACpC;AAEA,eAAsB,qBAAqB;AACzC,MAAI,CAAC;AACH;AACF,QAAM,cAAc,KAAK,qBAAqB,EAAE,cAAU,iCAAe,EAAE,CAAC;AAC5E,QAAM,cAAc,KAAK,yBAAyB,EAAE,WAAO,mDAA0B,EAAE,CAAC;AAC1F;AAEA,eAAsB,oCAAoC;AACxD,MAAI,CAAC;AACH;AACF,QAAM,cAAc,KAAK,qBAAqB,EAAE,cAAU,iCAAe,EAAE,CAAC;AAC5E,QAAM,cAAc,KAAK,sBAAsB,EAAE,YAAQ,kCAAgB,EAAE,CAAC;AAC9E;",
|
6
|
+
"names": ["url"]
|
7
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var expectBundle_exports = {};
|
20
|
+
__export(expectBundle_exports, {
|
21
|
+
DIM_COLOR: () => DIM_COLOR,
|
22
|
+
EXPECTED_COLOR: () => EXPECTED_COLOR,
|
23
|
+
INVERTED_COLOR: () => INVERTED_COLOR,
|
24
|
+
RECEIVED_COLOR: () => RECEIVED_COLOR,
|
25
|
+
asymmetricMatchers: () => asymmetricMatchers,
|
26
|
+
expect: () => expect,
|
27
|
+
matcherUtils: () => matcherUtils,
|
28
|
+
mock: () => mock,
|
29
|
+
printReceived: () => printReceived
|
30
|
+
});
|
31
|
+
module.exports = __toCommonJS(expectBundle_exports);
|
32
|
+
const expect = require("./expectBundleImpl").expect;
|
33
|
+
const mock = require("./expectBundleImpl").mock;
|
34
|
+
const asymmetricMatchers = require("./expectBundleImpl").asymmetricMatchers;
|
35
|
+
const matcherUtils = require("./expectBundleImpl").matcherUtils;
|
36
|
+
const EXPECTED_COLOR = require("./expectBundleImpl").EXPECTED_COLOR;
|
37
|
+
const INVERTED_COLOR = require("./expectBundleImpl").INVERTED_COLOR;
|
38
|
+
const RECEIVED_COLOR = require("./expectBundleImpl").RECEIVED_COLOR;
|
39
|
+
const DIM_COLOR = require("./expectBundleImpl").DIM_COLOR;
|
40
|
+
const printReceived = require("./expectBundleImpl").printReceived;
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
42
|
+
0 && (module.exports = {
|
43
|
+
DIM_COLOR,
|
44
|
+
EXPECTED_COLOR,
|
45
|
+
INVERTED_COLOR,
|
46
|
+
RECEIVED_COLOR,
|
47
|
+
asymmetricMatchers,
|
48
|
+
expect,
|
49
|
+
matcherUtils,
|
50
|
+
mock,
|
51
|
+
printReceived
|
52
|
+
});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../src/common/expectBundle.ts"],
|
4
|
+
"sourcesContent": ["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const expect: typeof import('../../bundles/expect/third_party/index').expect = require('./expectBundleImpl').expect;\nexport const mock: typeof import('../../bundles/expect/node_modules/jest-mock') = require('./expectBundleImpl').mock;\nexport const asymmetricMatchers = require('./expectBundleImpl').asymmetricMatchers;\nexport const matcherUtils = require('./expectBundleImpl').matcherUtils;\nexport const EXPECTED_COLOR: typeof import('../../bundles/expect/node_modules/jest-matcher-utils/build').EXPECTED_COLOR = require('./expectBundleImpl').EXPECTED_COLOR;\nexport const INVERTED_COLOR: typeof import('../../bundles/expect/node_modules/jest-matcher-utils/build').INVERTED_COLOR = require('./expectBundleImpl').INVERTED_COLOR;\nexport const RECEIVED_COLOR: typeof import('../../bundles/expect/node_modules/jest-matcher-utils/build').RECEIVED_COLOR = require('./expectBundleImpl').RECEIVED_COLOR;\nexport const printReceived: typeof import('../../bundles/expect/node_modules/jest-matcher-utils/build').printReceived = require('./expectBundleImpl').printReceived;\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,MAAM,SAAyE,QAAQ,oBAAoB,EAAE;AAC7G,MAAM,OAAqE,QAAQ,oBAAoB,EAAE;AACzG,MAAM,qBAAqB,QAAQ,oBAAoB,EAAE;AACzD,MAAM,eAAe,QAAQ,oBAAoB,EAAE;AACnD,MAAM,iBAA6G,QAAQ,oBAAoB,EAAE;AACjJ,MAAM,iBAA6G,QAAQ,oBAAoB,EAAE;AACjJ,MAAM,iBAA6G,QAAQ,oBAAoB,EAAE;AACjJ,MAAM,gBAA2G,QAAQ,oBAAoB,EAAE;",
|
6
|
+
"names": []
|
7
|
+
}
|