playwright 1.58.0-alpha-2025-12-11 → 1.58.0-alpha-2025-12-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/mcp/browser/context.js +4 -4
- package/lib/mcp/browser/tools/evaluate.js +3 -13
- package/lib/mcp/browser/tools/form.js +2 -12
- package/lib/mcp/browser/tools/pdf.js +4 -14
- package/lib/mcp/browser/tools/screenshot.js +5 -5
- package/lib/mcp/browser/tools/snapshot.js +3 -3
- package/lib/mcp/browser/tools/verify.js +5 -15
- package/lib/worker/testInfo.js +1 -1
- package/package.json +2 -2
- package/lib/mcp/browser/codegen.js +0 -66
|
@@ -34,12 +34,12 @@ __export(context_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(context_exports);
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
37
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
37
38
|
var import_playwright_core = require("playwright-core");
|
|
38
39
|
var import_log = require("../log");
|
|
39
40
|
var import_tab = require("./tab");
|
|
40
41
|
var import_config = require("./config");
|
|
41
|
-
var
|
|
42
|
-
var import_utils = require("./tools/utils");
|
|
42
|
+
var import_utils2 = require("./tools/utils");
|
|
43
43
|
const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
|
|
44
44
|
class Context {
|
|
45
45
|
constructor(options) {
|
|
@@ -141,7 +141,7 @@ class Context {
|
|
|
141
141
|
const videos = this.config.saveVideo ? browserContext.pages().map((page) => page.video()).filter((video) => !!video) : [];
|
|
142
142
|
await close(async () => {
|
|
143
143
|
for (const video of videos) {
|
|
144
|
-
const name = await this.outputFile((0,
|
|
144
|
+
const name = await this.outputFile((0, import_utils2.dateAsFileName)("webm"), { origin: "code", reason: "Saving video" });
|
|
145
145
|
const p = await video.path();
|
|
146
146
|
if (import_fs.default.existsSync(p)) {
|
|
147
147
|
try {
|
|
@@ -215,7 +215,7 @@ class Context {
|
|
|
215
215
|
}
|
|
216
216
|
lookupSecret(secretName) {
|
|
217
217
|
if (!this.config.secrets?.[secretName])
|
|
218
|
-
return { value: secretName, code:
|
|
218
|
+
return { value: secretName, code: (0, import_utils.escapeWithQuotes)(secretName, "'") };
|
|
219
219
|
return {
|
|
220
220
|
value: this.config.secrets[secretName],
|
|
221
221
|
code: `process.env['${secretName}']`
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var evaluate_exports = {};
|
|
30
20
|
__export(evaluate_exports, {
|
|
@@ -32,8 +22,8 @@ __export(evaluate_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(evaluate_exports);
|
|
34
24
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
35
26
|
var import_tool = require("./tool");
|
|
36
|
-
var javascript = __toESM(require("../codegen"));
|
|
37
27
|
const evaluateSchema = import_mcpBundle.z.object({
|
|
38
28
|
function: import_mcpBundle.z.string().describe("() => { /* code */ } or (element) => { /* code */ } when element is provided"),
|
|
39
29
|
element: import_mcpBundle.z.string().optional().describe("Human-readable element description used to obtain permission to interact with the element"),
|
|
@@ -53,9 +43,9 @@ const evaluate = (0, import_tool.defineTabTool)({
|
|
|
53
43
|
let locator;
|
|
54
44
|
if (params.ref && params.element) {
|
|
55
45
|
locator = await tab.refLocator({ ref: params.ref, element: params.element });
|
|
56
|
-
response.addCode(`await page.${locator.resolved}.evaluate(${
|
|
46
|
+
response.addCode(`await page.${locator.resolved}.evaluate(${(0, import_utils.escapeWithQuotes)(params.function)});`);
|
|
57
47
|
} else {
|
|
58
|
-
response.addCode(`await page.evaluate(${
|
|
48
|
+
response.addCode(`await page.evaluate(${(0, import_utils.escapeWithQuotes)(params.function)});`);
|
|
59
49
|
}
|
|
60
50
|
await tab.waitForCompletion(async () => {
|
|
61
51
|
const receiver = locator?.locator ?? tab.page;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var form_exports = {};
|
|
30
20
|
__export(form_exports, {
|
|
@@ -32,8 +22,8 @@ __export(form_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(form_exports);
|
|
34
24
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
35
26
|
var import_tool = require("./tool");
|
|
36
|
-
var codegen = __toESM(require("../codegen"));
|
|
37
27
|
const fillForm = (0, import_tool.defineTabTool)({
|
|
38
28
|
capability: "core",
|
|
39
29
|
schema: {
|
|
@@ -63,7 +53,7 @@ const fillForm = (0, import_tool.defineTabTool)({
|
|
|
63
53
|
response.addCode(`${locatorSource}.setChecked(${field.value});`);
|
|
64
54
|
} else if (field.type === "combobox") {
|
|
65
55
|
await locator.selectOption({ label: field.value });
|
|
66
|
-
response.addCode(`${locatorSource}.selectOption(${
|
|
56
|
+
response.addCode(`${locatorSource}.selectOption(${(0, import_utils.escapeWithQuotes)(field.value)});`);
|
|
67
57
|
}
|
|
68
58
|
}
|
|
69
59
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var pdf_exports = {};
|
|
30
20
|
__export(pdf_exports, {
|
|
@@ -32,9 +22,9 @@ __export(pdf_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(pdf_exports);
|
|
34
24
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
35
26
|
var import_tool = require("./tool");
|
|
36
|
-
var
|
|
37
|
-
var import_utils = require("./utils");
|
|
27
|
+
var import_utils2 = require("./utils");
|
|
38
28
|
const pdfSchema = import_mcpBundle.z.object({
|
|
39
29
|
filename: import_mcpBundle.z.string().optional().describe("File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.")
|
|
40
30
|
});
|
|
@@ -48,8 +38,8 @@ const pdf = (0, import_tool.defineTabTool)({
|
|
|
48
38
|
type: "readOnly"
|
|
49
39
|
},
|
|
50
40
|
handle: async (tab, params, response) => {
|
|
51
|
-
const fileName = await response.addFile(params.filename ?? (0,
|
|
52
|
-
response.addCode(`await page.pdf(${
|
|
41
|
+
const fileName = await response.addFile(params.filename ?? (0, import_utils2.dateAsFileName)("pdf"), { origin: "llm", reason: "Page saved as PDF" });
|
|
42
|
+
response.addCode(`await page.pdf(${(0, import_utils.formatObject)({ path: fileName })});`);
|
|
53
43
|
await tab.page.pdf({ path: fileName });
|
|
54
44
|
}
|
|
55
45
|
});
|
|
@@ -35,10 +35,10 @@ module.exports = __toCommonJS(screenshot_exports);
|
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_utils = require("playwright-core/lib/utils");
|
|
37
37
|
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
|
38
|
+
var import_utils2 = require("playwright-core/lib/utils");
|
|
38
39
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
39
40
|
var import_tool = require("./tool");
|
|
40
|
-
var
|
|
41
|
-
var import_utils2 = require("./utils");
|
|
41
|
+
var import_utils3 = require("./utils");
|
|
42
42
|
const screenshotSchema = import_mcpBundle.z.object({
|
|
43
43
|
type: import_mcpBundle.z.enum(["png", "jpeg"]).default("png").describe("Image format for the screenshot. Default is png."),
|
|
44
44
|
filename: import_mcpBundle.z.string().optional().describe("File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory."),
|
|
@@ -69,13 +69,13 @@ const screenshot = (0, import_tool.defineTabTool)({
|
|
|
69
69
|
};
|
|
70
70
|
const isElementScreenshot = params.element && params.ref;
|
|
71
71
|
const screenshotTarget = isElementScreenshot ? params.element : params.fullPage ? "full page" : "viewport";
|
|
72
|
-
const fileName = await response.addFile(params.filename || (0,
|
|
72
|
+
const fileName = await response.addFile(params.filename || (0, import_utils3.dateAsFileName)(fileType), { origin: "llm", reason: `Screenshot of ${screenshotTarget}` });
|
|
73
73
|
response.addCode(`// Screenshot ${screenshotTarget} and save it as ${fileName}`);
|
|
74
74
|
const ref = params.ref ? await tab.refLocator({ element: params.element || "", ref: params.ref }) : null;
|
|
75
75
|
if (ref)
|
|
76
|
-
response.addCode(`await page.${ref.resolved}.screenshot(${
|
|
76
|
+
response.addCode(`await page.${ref.resolved}.screenshot(${(0, import_utils2.formatObject)(options)});`);
|
|
77
77
|
else
|
|
78
|
-
response.addCode(`await page.screenshot(${
|
|
78
|
+
response.addCode(`await page.screenshot(${(0, import_utils2.formatObject)(options)});`);
|
|
79
79
|
const buffer = ref ? await ref.locator.screenshot(options) : await tab.page.screenshot(options);
|
|
80
80
|
await (0, import_utils.mkdirIfNeeded)(fileName);
|
|
81
81
|
await import_fs.default.promises.writeFile(fileName, buffer);
|
|
@@ -34,8 +34,8 @@ __export(snapshot_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(snapshot_exports);
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
37
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
37
38
|
var import_tool = require("./tool");
|
|
38
|
-
var javascript = __toESM(require("../codegen"));
|
|
39
39
|
const snapshot = (0, import_tool.defineTool)({
|
|
40
40
|
capability: "core",
|
|
41
41
|
schema: {
|
|
@@ -83,7 +83,7 @@ const click = (0, import_tool.defineTabTool)({
|
|
|
83
83
|
button: params.button,
|
|
84
84
|
modifiers: params.modifiers
|
|
85
85
|
};
|
|
86
|
-
const formatted =
|
|
86
|
+
const formatted = (0, import_utils.formatObject)(options, " ", "oneline");
|
|
87
87
|
const optionsAttr = formatted !== "{}" ? formatted : "";
|
|
88
88
|
if (params.doubleClick)
|
|
89
89
|
response.addCode(`await page.${resolved}.dblclick(${optionsAttr});`);
|
|
@@ -156,7 +156,7 @@ const selectOption = (0, import_tool.defineTabTool)({
|
|
|
156
156
|
handle: async (tab, params, response) => {
|
|
157
157
|
response.setIncludeSnapshot();
|
|
158
158
|
const { locator, resolved } = await tab.refLocator(params);
|
|
159
|
-
response.addCode(`await page.${resolved}.selectOption(${
|
|
159
|
+
response.addCode(`await page.${resolved}.selectOption(${(0, import_utils.formatObject)(params.values)});`);
|
|
160
160
|
await tab.waitForCompletion(async () => {
|
|
161
161
|
await locator.selectOption(params.values);
|
|
162
162
|
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var verify_exports = {};
|
|
30
20
|
__export(verify_exports, {
|
|
@@ -32,8 +22,8 @@ __export(verify_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(verify_exports);
|
|
34
24
|
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
|
25
|
+
var import_utils = require("playwright-core/lib/utils");
|
|
35
26
|
var import_tool = require("./tool");
|
|
36
|
-
var javascript = __toESM(require("../codegen"));
|
|
37
27
|
const verifyElement = (0, import_tool.defineTabTool)({
|
|
38
28
|
capability: "testing",
|
|
39
29
|
schema: {
|
|
@@ -52,7 +42,7 @@ const verifyElement = (0, import_tool.defineTabTool)({
|
|
|
52
42
|
response.addError(`Element with role "${params.role}" and accessible name "${params.accessibleName}" not found`);
|
|
53
43
|
return;
|
|
54
44
|
}
|
|
55
|
-
response.addCode(`await expect(page.getByRole(${
|
|
45
|
+
response.addCode(`await expect(page.getByRole(${(0, import_utils.escapeWithQuotes)(params.role)}, { name: ${(0, import_utils.escapeWithQuotes)(params.accessibleName)} })).toBeVisible();`);
|
|
56
46
|
response.addResult("Done");
|
|
57
47
|
}
|
|
58
48
|
});
|
|
@@ -73,7 +63,7 @@ const verifyText = (0, import_tool.defineTabTool)({
|
|
|
73
63
|
response.addError("Text not found");
|
|
74
64
|
return;
|
|
75
65
|
}
|
|
76
|
-
response.addCode(`await expect(page.getByText(${
|
|
66
|
+
response.addCode(`await expect(page.getByText(${(0, import_utils.escapeWithQuotes)(params.text)})).toBeVisible();`);
|
|
77
67
|
response.addResult("Done");
|
|
78
68
|
}
|
|
79
69
|
});
|
|
@@ -103,7 +93,7 @@ const verifyList = (0, import_tool.defineTabTool)({
|
|
|
103
93
|
}
|
|
104
94
|
const ariaSnapshot = `\`
|
|
105
95
|
- list:
|
|
106
|
-
${itemTexts.map((t) => ` - listitem: ${
|
|
96
|
+
${itemTexts.map((t) => ` - listitem: ${(0, import_utils.escapeWithQuotes)(t, '"')}`).join("\n")}
|
|
107
97
|
\``;
|
|
108
98
|
response.addCode(`await expect(page.locator('body')).toMatchAriaSnapshot(${ariaSnapshot});`);
|
|
109
99
|
response.addResult("Done");
|
|
@@ -132,7 +122,7 @@ const verifyValue = (0, import_tool.defineTabTool)({
|
|
|
132
122
|
response.addError(`Expected value "${params.value}", but got "${value}"`);
|
|
133
123
|
return;
|
|
134
124
|
}
|
|
135
|
-
response.addCode(`await expect(${locatorSource}).toHaveValue(${
|
|
125
|
+
response.addCode(`await expect(${locatorSource}).toHaveValue(${(0, import_utils.escapeWithQuotes)(params.value)});`);
|
|
136
126
|
} else if (params.type === "checkbox" || params.type === "radio") {
|
|
137
127
|
const value = await locator.isChecked();
|
|
138
128
|
if (value !== (params.value === "true")) {
|
package/lib/worker/testInfo.js
CHANGED
|
@@ -342,13 +342,13 @@ ${(0, import_utils.stringifyStackFrames)(step.boxedStack).join("\n")}`;
|
|
|
342
342
|
this._callbacks.onTestPaused({ testId: this.testId, stepId: step.stepId, errors: this._isFailure() ? this.errors : [] }),
|
|
343
343
|
this._interruptedPromise.then(() => "interrupted")
|
|
344
344
|
]);
|
|
345
|
-
step.complete({});
|
|
346
345
|
if (result !== "interrupted") {
|
|
347
346
|
if (result.action === "abort")
|
|
348
347
|
this._interrupt();
|
|
349
348
|
if (result.action === void 0)
|
|
350
349
|
await this._interruptedPromise;
|
|
351
350
|
}
|
|
351
|
+
step.complete({});
|
|
352
352
|
}
|
|
353
353
|
await this._onDidFinishTestFunctionCallback?.();
|
|
354
354
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.58.0-alpha-2025-12-
|
|
3
|
+
"version": "1.58.0-alpha-2025-12-12",
|
|
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.58.0-alpha-2025-12-
|
|
67
|
+
"playwright-core": "1.58.0-alpha-2025-12-12"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|
|
@@ -1,66 +0,0 @@
|
|
|
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 codegen_exports = {};
|
|
20
|
-
__export(codegen_exports, {
|
|
21
|
-
escapeWithQuotes: () => escapeWithQuotes,
|
|
22
|
-
formatObject: () => formatObject,
|
|
23
|
-
quote: () => quote
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(codegen_exports);
|
|
26
|
-
function escapeWithQuotes(text, char = "'") {
|
|
27
|
-
const stringified = JSON.stringify(text);
|
|
28
|
-
const escapedText = stringified.substring(1, stringified.length - 1).replace(/\\"/g, '"');
|
|
29
|
-
if (char === "'")
|
|
30
|
-
return char + escapedText.replace(/[']/g, "\\'") + char;
|
|
31
|
-
if (char === '"')
|
|
32
|
-
return char + escapedText.replace(/["]/g, '\\"') + char;
|
|
33
|
-
if (char === "`")
|
|
34
|
-
return char + escapedText.replace(/[`]/g, "\\`") + char;
|
|
35
|
-
throw new Error("Invalid escape char");
|
|
36
|
-
}
|
|
37
|
-
function quote(text) {
|
|
38
|
-
return escapeWithQuotes(text, "'");
|
|
39
|
-
}
|
|
40
|
-
function formatObject(value, indent = " ", mode = "multiline") {
|
|
41
|
-
if (typeof value === "string")
|
|
42
|
-
return quote(value);
|
|
43
|
-
if (Array.isArray(value))
|
|
44
|
-
return `[${value.map((o) => formatObject(o)).join(", ")}]`;
|
|
45
|
-
if (typeof value === "object") {
|
|
46
|
-
const keys = Object.keys(value).filter((key) => value[key] !== void 0).sort();
|
|
47
|
-
if (!keys.length)
|
|
48
|
-
return "{}";
|
|
49
|
-
const tokens = [];
|
|
50
|
-
for (const key of keys)
|
|
51
|
-
tokens.push(`${key}: ${formatObject(value[key])}`);
|
|
52
|
-
if (mode === "multiline")
|
|
53
|
-
return `{
|
|
54
|
-
${tokens.join(`,
|
|
55
|
-
${indent}`)}
|
|
56
|
-
}`;
|
|
57
|
-
return `{ ${tokens.join(", ")} }`;
|
|
58
|
-
}
|
|
59
|
-
return String(value);
|
|
60
|
-
}
|
|
61
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
escapeWithQuotes,
|
|
64
|
-
formatObject,
|
|
65
|
-
quote
|
|
66
|
-
});
|