@midscene/web 0.7.1 → 0.7.2-beta-20241024094141.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/dist/browser/playground.js +8438 -0
- package/dist/browser/types/playground.d.ts +313 -0
- package/dist/es/appium.js +680 -604
- package/dist/es/debug.js +95 -73
- package/dist/es/index.js +939 -797
- package/dist/es/midscene-playground.js +678 -609
- package/dist/es/playground.js +593 -1024
- package/dist/es/playwright-report.js +29 -11
- package/dist/es/playwright.js +705 -597
- package/dist/es/puppeteer.js +636 -552
- package/dist/lib/appium.js +688 -609
- package/dist/lib/debug.js +95 -73
- package/dist/lib/index.js +950 -804
- package/dist/lib/midscene-playground.js +687 -615
- package/dist/lib/playground.js +586 -1007
- package/dist/lib/playwright-report.js +30 -9
- package/dist/lib/playwright.js +713 -602
- package/dist/lib/puppeteer.js +644 -557
- package/dist/script/htmlElement.js +11 -10
- package/dist/script/htmlElementDebug.js +11 -10
- package/dist/types/appium.d.ts +2 -3
- package/dist/types/debug.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/{page-ad820b3c.d.ts → page-8117b0ad.d.ts} +8 -7
- package/dist/types/playground.d.ts +6 -21
- package/dist/types/playwright.d.ts +3 -4
- package/dist/types/puppeteer.d.ts +2 -3
- package/dist/types/{tasks-82c1054b.d.ts → tasks-cb6bf758.d.ts} +6 -6
- package/package.json +11 -5
- package/static/index.html +1 -1
package/dist/lib/debug.js
CHANGED
|
@@ -26,6 +26,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
29
49
|
|
|
30
50
|
// src/debug/index.ts
|
|
31
51
|
var debug_exports = {};
|
|
@@ -44,67 +64,67 @@ var import_constants = require("@midscene/shared/constants");
|
|
|
44
64
|
|
|
45
65
|
// src/debug/index.ts
|
|
46
66
|
var import_img = require("@midscene/shared/img");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"output_without_text.png"
|
|
61
|
-
);
|
|
62
|
-
const resizeOutputImgPath = import_node_path.default.join(targetDir, "resize-output.png");
|
|
63
|
-
const snapshotJsonPath = import_node_path.default.join(targetDir, "element-snapshot.json");
|
|
64
|
-
const {
|
|
65
|
-
compositeElementInfoImgBase64,
|
|
66
|
-
compositeElementInfoImgWithoutTextBase64
|
|
67
|
-
} = await (0, import_img.processImageElementInfo)({
|
|
68
|
-
elementsPositionInfo,
|
|
69
|
-
elementsPositionInfoWithoutText,
|
|
70
|
-
inputImgBase64
|
|
71
|
-
});
|
|
72
|
-
const resizeImgBase64 = await (0, import_img.resizeImg)(inputImgBase64);
|
|
73
|
-
const existingSnapshot = (0, import_node_fs.existsSync)(snapshotJsonPath) ? JSON.parse((0, import_node_fs.readFileSync)(snapshotJsonPath, "utf-8")) : null;
|
|
74
|
-
if (existingSnapshot && JSON.stringify(existingSnapshot) === JSON.stringify(captureElementSnapshot)) {
|
|
75
|
-
console.log("skip save snapshot for ", targetDir);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (!(saveImgType == null ? void 0 : saveImgType.disableSnapshot)) {
|
|
79
|
-
writeFileSyncWithDir(
|
|
80
|
-
snapshotJsonPath,
|
|
81
|
-
JSON.stringify(captureElementSnapshot, null, 2)
|
|
67
|
+
function generateExtractData(page, targetDir, saveImgType) {
|
|
68
|
+
return __async(this, null, function* () {
|
|
69
|
+
const inputImgBase64 = yield page.screenshotBase64();
|
|
70
|
+
const {
|
|
71
|
+
elementsPositionInfo,
|
|
72
|
+
captureElementSnapshot,
|
|
73
|
+
elementsPositionInfoWithoutText
|
|
74
|
+
} = yield getElementInfos(page);
|
|
75
|
+
const inputImagePath = import_node_path.default.join(targetDir, "input.png");
|
|
76
|
+
const outputImagePath = import_node_path.default.join(targetDir, "output.png");
|
|
77
|
+
const outputWithoutTextImgPath = import_node_path.default.join(
|
|
78
|
+
targetDir,
|
|
79
|
+
"output_without_text.png"
|
|
82
80
|
);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
base64Data: compositeElementInfoImgBase64,
|
|
93
|
-
outputPath: outputImagePath
|
|
81
|
+
const resizeOutputImgPath = import_node_path.default.join(targetDir, "resize-output.png");
|
|
82
|
+
const snapshotJsonPath = import_node_path.default.join(targetDir, "element-snapshot.json");
|
|
83
|
+
const {
|
|
84
|
+
compositeElementInfoImgBase64,
|
|
85
|
+
compositeElementInfoImgWithoutTextBase64
|
|
86
|
+
} = yield (0, import_img.processImageElementInfo)({
|
|
87
|
+
elementsPositionInfo,
|
|
88
|
+
elementsPositionInfoWithoutText,
|
|
89
|
+
inputImgBase64
|
|
94
90
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
91
|
+
const resizeImgBase64 = yield (0, import_img.resizeImg)(inputImgBase64);
|
|
92
|
+
const existingSnapshot = (0, import_node_fs.existsSync)(snapshotJsonPath) ? JSON.parse((0, import_node_fs.readFileSync)(snapshotJsonPath, "utf-8")) : null;
|
|
93
|
+
if (existingSnapshot && JSON.stringify(existingSnapshot) === JSON.stringify(captureElementSnapshot)) {
|
|
94
|
+
console.log("skip save snapshot for ", targetDir);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!(saveImgType == null ? void 0 : saveImgType.disableSnapshot)) {
|
|
98
|
+
writeFileSyncWithDir(
|
|
99
|
+
snapshotJsonPath,
|
|
100
|
+
JSON.stringify(captureElementSnapshot, null, 2)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (!(saveImgType == null ? void 0 : saveImgType.disableInputImage)) {
|
|
104
|
+
yield (0, import_img.saveBase64Image)({
|
|
105
|
+
base64Data: inputImgBase64,
|
|
106
|
+
outputPath: inputImagePath
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (!(saveImgType == null ? void 0 : saveImgType.disableOutputImage)) {
|
|
110
|
+
yield (0, import_img.saveBase64Image)({
|
|
111
|
+
base64Data: compositeElementInfoImgBase64,
|
|
112
|
+
outputPath: outputImagePath
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (!(saveImgType == null ? void 0 : saveImgType.disableOutputWithoutTextImg)) {
|
|
116
|
+
yield (0, import_img.saveBase64Image)({
|
|
117
|
+
base64Data: compositeElementInfoImgWithoutTextBase64,
|
|
118
|
+
outputPath: outputWithoutTextImgPath
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (!(saveImgType == null ? void 0 : saveImgType.disableResizeOutputImg)) {
|
|
122
|
+
yield (0, import_img.saveBase64Image)({
|
|
123
|
+
base64Data: resizeImgBase64,
|
|
124
|
+
outputPath: resizeOutputImgPath
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
108
128
|
}
|
|
109
129
|
function generateTestDataPath(testDataName) {
|
|
110
130
|
const modulePath = require.resolve("@midscene/core").replace("dist/lib/index.js", "");
|
|
@@ -126,21 +146,23 @@ function writeFileSyncWithDir(filePath, content, options = {}) {
|
|
|
126
146
|
ensureDirectoryExistence(filePath);
|
|
127
147
|
(0, import_node_fs.writeFileSync)(filePath, content, options);
|
|
128
148
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
function getElementInfos(page) {
|
|
150
|
+
return __async(this, null, function* () {
|
|
151
|
+
const captureElementSnapshot = yield page.getElementInfos();
|
|
152
|
+
const elementsPositionInfoWithoutText = captureElementSnapshot.filter(
|
|
153
|
+
(elementInfo) => {
|
|
154
|
+
if (elementInfo.attributes.nodeType === import_constants.NodeType.TEXT) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
135
158
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
};
|
|
159
|
+
);
|
|
160
|
+
return {
|
|
161
|
+
elementsPositionInfo: captureElementSnapshot,
|
|
162
|
+
captureElementSnapshot,
|
|
163
|
+
elementsPositionInfoWithoutText
|
|
164
|
+
};
|
|
165
|
+
});
|
|
144
166
|
}
|
|
145
167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
146
168
|
0 && (module.exports = {
|