@midscene/web 0.7.2 → 0.7.3-beta-20241104100519.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/es/appium.js +2297 -2019
- package/dist/es/chrome-extension.js +1627 -0
- package/dist/es/debug.js +146 -125
- package/dist/es/index.js +2718 -2391
- package/dist/es/midscene-playground.js +1843 -1666
- package/dist/es/playground.js +1368 -1666
- package/dist/es/playwright-report.js +482 -384
- package/dist/es/playwright.js +1616 -1384
- package/dist/es/puppeteer.js +1455 -1244
- package/dist/es/utils.js +599 -0
- package/dist/lib/appium.js +2296 -2003
- package/dist/lib/chrome-extension.js +1627 -0
- package/dist/lib/debug.js +145 -146
- package/dist/lib/index.js +2717 -2375
- package/dist/lib/midscene-playground.js +1843 -1645
- package/dist/lib/playground.js +1367 -1659
- package/dist/lib/playwright-report.js +482 -391
- package/dist/lib/playwright.js +1615 -1384
- package/dist/lib/puppeteer.js +1454 -1243
- package/dist/lib/utils.js +599 -0
- package/dist/script/htmlElement.js +11 -10
- package/dist/script/htmlElementDebug.js +11 -10
- package/dist/types/appium.d.ts +3 -3
- package/dist/types/chrome-extension.d.ts +16 -0
- package/dist/types/debug.d.ts +3 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/{page-ad820b3c.d.ts → page-84b18c7f.d.ts} +82 -14
- package/dist/types/playground.d.ts +7 -21
- package/dist/types/playwright.d.ts +3 -4
- package/dist/types/puppeteer.d.ts +3 -3
- package/dist/types/{tasks-82c1054b.d.ts → tasks-bf894fe9.d.ts} +19 -10
- package/dist/types/utils.d.ts +7 -0
- package/package.json +14 -5
- package/static/index.html +0 -245
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("assert"), require("fs"), require("path"), require("@midscene/shared/constants"), require("@midscene/shared/fs"), require("@midscene/shared/img"), require("@midscene/shared/utils"));
|
|
3
|
+
else if (typeof define === "function" && define.amd) define([
|
|
4
|
+
"exports",
|
|
5
|
+
"assert",
|
|
6
|
+
"fs",
|
|
7
|
+
"path",
|
|
8
|
+
"@midscene/shared/constants",
|
|
9
|
+
"@midscene/shared/fs",
|
|
10
|
+
"@midscene/shared/img",
|
|
11
|
+
"@midscene/shared/utils"
|
|
12
|
+
], factory);
|
|
13
|
+
else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.utils = {}, global.assert, global.fs, global.path, global.constants, global.fs, global.img, global.utils);
|
|
14
|
+
})(this, function(exports, _assert, _fs, _path, _constants, _fs1, _img, _utils) {
|
|
15
|
+
"use strict";
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
function _export(target, all) {
|
|
20
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: all[name]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
_export(exports, {
|
|
26
|
+
ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED: function() {
|
|
27
|
+
return ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED;
|
|
28
|
+
},
|
|
29
|
+
generateCacheId: function() {
|
|
30
|
+
return generateCacheId;
|
|
31
|
+
},
|
|
32
|
+
getCurrentExecutionFile: function() {
|
|
33
|
+
return getCurrentExecutionFile;
|
|
34
|
+
},
|
|
35
|
+
getExtraReturnLogic: function() {
|
|
36
|
+
return getExtraReturnLogic;
|
|
37
|
+
},
|
|
38
|
+
parseContextFromWebPage: function() {
|
|
39
|
+
return parseContextFromWebPage;
|
|
40
|
+
},
|
|
41
|
+
printReportMsg: function() {
|
|
42
|
+
return printReportMsg;
|
|
43
|
+
},
|
|
44
|
+
reportFileName: function() {
|
|
45
|
+
return reportFileName;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
_assert = /*#__PURE__*/ _interop_require_default(_assert);
|
|
49
|
+
_path = /*#__PURE__*/ _interop_require_default(_path);
|
|
50
|
+
function _interop_require_default(obj) {
|
|
51
|
+
return obj && obj.__esModule ? obj : {
|
|
52
|
+
default: obj
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var __create = Object.create;
|
|
56
|
+
var __defProp = Object.defineProperty;
|
|
57
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
58
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
59
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
60
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
61
|
+
var __commonJS = (cb, mod)=>function __require() {
|
|
62
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
63
|
+
exports: {}
|
|
64
|
+
}).exports, mod), mod.exports;
|
|
65
|
+
};
|
|
66
|
+
var __copyProps = (to, from, except, desc)=>{
|
|
67
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
68
|
+
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
69
|
+
get: ()=>from[key],
|
|
70
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return to;
|
|
74
|
+
};
|
|
75
|
+
var __toESM = (mod, isNodeMode, target)=>(target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
76
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
77
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
78
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
79
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
80
|
+
value: mod,
|
|
81
|
+
enumerable: true
|
|
82
|
+
}) : target, mod));
|
|
83
|
+
var __async = (__this, __arguments, generator)=>{
|
|
84
|
+
return new Promise((resolve, reject)=>{
|
|
85
|
+
var fulfilled = (value)=>{
|
|
86
|
+
try {
|
|
87
|
+
step(generator.next(value));
|
|
88
|
+
} catch (e) {
|
|
89
|
+
reject(e);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var rejected = (value)=>{
|
|
93
|
+
try {
|
|
94
|
+
step(generator.throw(value));
|
|
95
|
+
} catch (e) {
|
|
96
|
+
reject(e);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var step = (x)=>x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
100
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
// ../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js
|
|
104
|
+
var require_dayjs_min = __commonJS({
|
|
105
|
+
"../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js" (exports, module1) {
|
|
106
|
+
"use strict";
|
|
107
|
+
!function(t, e) {
|
|
108
|
+
"object" == typeof exports && "undefined" != typeof module1 ? module1.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
|
|
109
|
+
}(exports, function() {
|
|
110
|
+
"use strict";
|
|
111
|
+
var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = {
|
|
112
|
+
name: "en",
|
|
113
|
+
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
|
114
|
+
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
|
115
|
+
ordinal: function(t2) {
|
|
116
|
+
var e2 = [
|
|
117
|
+
"th",
|
|
118
|
+
"st",
|
|
119
|
+
"nd",
|
|
120
|
+
"rd"
|
|
121
|
+
], n2 = t2 % 100;
|
|
122
|
+
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
|
|
123
|
+
}
|
|
124
|
+
}, m = function(t2, e2, n2) {
|
|
125
|
+
var r2 = String(t2);
|
|
126
|
+
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
|
|
127
|
+
}, v = {
|
|
128
|
+
s: m,
|
|
129
|
+
z: function(t2) {
|
|
130
|
+
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
|
|
131
|
+
return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
|
|
132
|
+
},
|
|
133
|
+
m: function t2(e2, n2) {
|
|
134
|
+
if (e2.date() < n2.date()) return -t2(n2, e2);
|
|
135
|
+
var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
|
|
136
|
+
return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
|
|
137
|
+
},
|
|
138
|
+
a: function(t2) {
|
|
139
|
+
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
|
140
|
+
},
|
|
141
|
+
p: function(t2) {
|
|
142
|
+
return ({
|
|
143
|
+
M: c,
|
|
144
|
+
y: h,
|
|
145
|
+
w: o,
|
|
146
|
+
d: a,
|
|
147
|
+
D: d,
|
|
148
|
+
h: u,
|
|
149
|
+
m: s,
|
|
150
|
+
s: i,
|
|
151
|
+
ms: r,
|
|
152
|
+
Q: f
|
|
153
|
+
})[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
|
154
|
+
},
|
|
155
|
+
u: function(t2) {
|
|
156
|
+
return void 0 === t2;
|
|
157
|
+
}
|
|
158
|
+
}, g = "en", D = {};
|
|
159
|
+
D[g] = M;
|
|
160
|
+
var p = "$isDayjsObject", S = function(t2) {
|
|
161
|
+
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
162
|
+
}, w = function t2(e2, n2, r2) {
|
|
163
|
+
var i2;
|
|
164
|
+
if (!e2) return g;
|
|
165
|
+
if ("string" == typeof e2) {
|
|
166
|
+
var s2 = e2.toLowerCase();
|
|
167
|
+
D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
|
|
168
|
+
var u2 = e2.split("-");
|
|
169
|
+
if (!i2 && u2.length > 1) return t2(u2[0]);
|
|
170
|
+
} else {
|
|
171
|
+
var a2 = e2.name;
|
|
172
|
+
D[a2] = e2, i2 = a2;
|
|
173
|
+
}
|
|
174
|
+
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
175
|
+
}, O = function(t2, e2) {
|
|
176
|
+
if (S(t2)) return t2.clone();
|
|
177
|
+
var n2 = "object" == typeof e2 ? e2 : {};
|
|
178
|
+
return n2.date = t2, n2.args = arguments, new _(n2);
|
|
179
|
+
}, b = v;
|
|
180
|
+
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
181
|
+
return O(t2, {
|
|
182
|
+
locale: e2.$L,
|
|
183
|
+
utc: e2.$u,
|
|
184
|
+
x: e2.$x,
|
|
185
|
+
$offset: e2.$offset
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
var _ = function() {
|
|
189
|
+
function M2(t2) {
|
|
190
|
+
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
191
|
+
}
|
|
192
|
+
var m2 = M2.prototype;
|
|
193
|
+
return m2.parse = function(t2) {
|
|
194
|
+
this.$d = function(t3) {
|
|
195
|
+
var e2 = t3.date, n2 = t3.utc;
|
|
196
|
+
if (null === e2) return /* @__PURE__ */ new Date(NaN);
|
|
197
|
+
if (b.u(e2)) return /* @__PURE__ */ new Date();
|
|
198
|
+
if (e2 instanceof Date) return new Date(e2);
|
|
199
|
+
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
|
|
200
|
+
var r2 = e2.match($);
|
|
201
|
+
if (r2) {
|
|
202
|
+
var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
|
203
|
+
return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return new Date(e2);
|
|
207
|
+
}(t2), this.init();
|
|
208
|
+
}, m2.init = function() {
|
|
209
|
+
var t2 = this.$d;
|
|
210
|
+
this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
|
|
211
|
+
}, m2.$utils = function() {
|
|
212
|
+
return b;
|
|
213
|
+
}, m2.isValid = function() {
|
|
214
|
+
return !(this.$d.toString() === l);
|
|
215
|
+
}, m2.isSame = function(t2, e2) {
|
|
216
|
+
var n2 = O(t2);
|
|
217
|
+
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
|
|
218
|
+
}, m2.isAfter = function(t2, e2) {
|
|
219
|
+
return O(t2) < this.startOf(e2);
|
|
220
|
+
}, m2.isBefore = function(t2, e2) {
|
|
221
|
+
return this.endOf(e2) < O(t2);
|
|
222
|
+
}, m2.$g = function(t2, e2, n2) {
|
|
223
|
+
return b.u(t2) ? this[e2] : this.set(n2, t2);
|
|
224
|
+
}, m2.unix = function() {
|
|
225
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
226
|
+
}, m2.valueOf = function() {
|
|
227
|
+
return this.$d.getTime();
|
|
228
|
+
}, m2.startOf = function(t2, e2) {
|
|
229
|
+
var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
|
|
230
|
+
var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
|
|
231
|
+
return r2 ? i2 : i2.endOf(a);
|
|
232
|
+
}, $2 = function(t3, e3) {
|
|
233
|
+
return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [
|
|
234
|
+
0,
|
|
235
|
+
0,
|
|
236
|
+
0,
|
|
237
|
+
0
|
|
238
|
+
] : [
|
|
239
|
+
23,
|
|
240
|
+
59,
|
|
241
|
+
59,
|
|
242
|
+
999
|
|
243
|
+
]).slice(e3)), n2);
|
|
244
|
+
}, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
|
245
|
+
switch(f2){
|
|
246
|
+
case h:
|
|
247
|
+
return r2 ? l2(1, 0) : l2(31, 11);
|
|
248
|
+
case c:
|
|
249
|
+
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
250
|
+
case o:
|
|
251
|
+
var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
252
|
+
return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
|
253
|
+
case a:
|
|
254
|
+
case d:
|
|
255
|
+
return $2(v2 + "Hours", 0);
|
|
256
|
+
case u:
|
|
257
|
+
return $2(v2 + "Minutes", 1);
|
|
258
|
+
case s:
|
|
259
|
+
return $2(v2 + "Seconds", 2);
|
|
260
|
+
case i:
|
|
261
|
+
return $2(v2 + "Milliseconds", 3);
|
|
262
|
+
default:
|
|
263
|
+
return this.clone();
|
|
264
|
+
}
|
|
265
|
+
}, m2.endOf = function(t2) {
|
|
266
|
+
return this.startOf(t2, false);
|
|
267
|
+
}, m2.$set = function(t2, e2) {
|
|
268
|
+
var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
|
|
269
|
+
if (o2 === c || o2 === h) {
|
|
270
|
+
var y2 = this.clone().set(d, 1);
|
|
271
|
+
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
|
272
|
+
} else l2 && this.$d[l2]($2);
|
|
273
|
+
return this.init(), this;
|
|
274
|
+
}, m2.set = function(t2, e2) {
|
|
275
|
+
return this.clone().$set(t2, e2);
|
|
276
|
+
}, m2.get = function(t2) {
|
|
277
|
+
return this[b.p(t2)]();
|
|
278
|
+
}, m2.add = function(r2, f2) {
|
|
279
|
+
var d2, l2 = this;
|
|
280
|
+
r2 = Number(r2);
|
|
281
|
+
var $2 = b.p(f2), y2 = function(t2) {
|
|
282
|
+
var e2 = O(l2);
|
|
283
|
+
return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
|
|
284
|
+
};
|
|
285
|
+
if ($2 === c) return this.set(c, this.$M + r2);
|
|
286
|
+
if ($2 === h) return this.set(h, this.$y + r2);
|
|
287
|
+
if ($2 === a) return y2(1);
|
|
288
|
+
if ($2 === o) return y2(7);
|
|
289
|
+
var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
|
290
|
+
return b.w(m3, this);
|
|
291
|
+
}, m2.subtract = function(t2, e2) {
|
|
292
|
+
return this.add(-1 * t2, e2);
|
|
293
|
+
}, m2.format = function(t2) {
|
|
294
|
+
var e2 = this, n2 = this.$locale();
|
|
295
|
+
if (!this.isValid()) return n2.invalidDate || l;
|
|
296
|
+
var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
|
|
297
|
+
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
|
|
298
|
+
}, d2 = function(t3) {
|
|
299
|
+
return b.s(s2 % 12 || 12, t3, "0");
|
|
300
|
+
}, $2 = f2 || function(t3, e3, n3) {
|
|
301
|
+
var r3 = t3 < 12 ? "AM" : "PM";
|
|
302
|
+
return n3 ? r3.toLowerCase() : r3;
|
|
303
|
+
};
|
|
304
|
+
return r2.replace(y, function(t3, r3) {
|
|
305
|
+
return r3 || function(t4) {
|
|
306
|
+
switch(t4){
|
|
307
|
+
case "YY":
|
|
308
|
+
return String(e2.$y).slice(-2);
|
|
309
|
+
case "YYYY":
|
|
310
|
+
return b.s(e2.$y, 4, "0");
|
|
311
|
+
case "M":
|
|
312
|
+
return a2 + 1;
|
|
313
|
+
case "MM":
|
|
314
|
+
return b.s(a2 + 1, 2, "0");
|
|
315
|
+
case "MMM":
|
|
316
|
+
return h2(n2.monthsShort, a2, c2, 3);
|
|
317
|
+
case "MMMM":
|
|
318
|
+
return h2(c2, a2);
|
|
319
|
+
case "D":
|
|
320
|
+
return e2.$D;
|
|
321
|
+
case "DD":
|
|
322
|
+
return b.s(e2.$D, 2, "0");
|
|
323
|
+
case "d":
|
|
324
|
+
return String(e2.$W);
|
|
325
|
+
case "dd":
|
|
326
|
+
return h2(n2.weekdaysMin, e2.$W, o2, 2);
|
|
327
|
+
case "ddd":
|
|
328
|
+
return h2(n2.weekdaysShort, e2.$W, o2, 3);
|
|
329
|
+
case "dddd":
|
|
330
|
+
return o2[e2.$W];
|
|
331
|
+
case "H":
|
|
332
|
+
return String(s2);
|
|
333
|
+
case "HH":
|
|
334
|
+
return b.s(s2, 2, "0");
|
|
335
|
+
case "h":
|
|
336
|
+
return d2(1);
|
|
337
|
+
case "hh":
|
|
338
|
+
return d2(2);
|
|
339
|
+
case "a":
|
|
340
|
+
return $2(s2, u2, true);
|
|
341
|
+
case "A":
|
|
342
|
+
return $2(s2, u2, false);
|
|
343
|
+
case "m":
|
|
344
|
+
return String(u2);
|
|
345
|
+
case "mm":
|
|
346
|
+
return b.s(u2, 2, "0");
|
|
347
|
+
case "s":
|
|
348
|
+
return String(e2.$s);
|
|
349
|
+
case "ss":
|
|
350
|
+
return b.s(e2.$s, 2, "0");
|
|
351
|
+
case "SSS":
|
|
352
|
+
return b.s(e2.$ms, 3, "0");
|
|
353
|
+
case "Z":
|
|
354
|
+
return i2;
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}(t3) || i2.replace(":", "");
|
|
358
|
+
});
|
|
359
|
+
}, m2.utcOffset = function() {
|
|
360
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
361
|
+
}, m2.diff = function(r2, d2, l2) {
|
|
362
|
+
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
|
|
363
|
+
return b.m(y2, m3);
|
|
364
|
+
};
|
|
365
|
+
switch(M3){
|
|
366
|
+
case h:
|
|
367
|
+
$2 = D2() / 12;
|
|
368
|
+
break;
|
|
369
|
+
case c:
|
|
370
|
+
$2 = D2();
|
|
371
|
+
break;
|
|
372
|
+
case f:
|
|
373
|
+
$2 = D2() / 3;
|
|
374
|
+
break;
|
|
375
|
+
case o:
|
|
376
|
+
$2 = (g2 - v2) / 6048e5;
|
|
377
|
+
break;
|
|
378
|
+
case a:
|
|
379
|
+
$2 = (g2 - v2) / 864e5;
|
|
380
|
+
break;
|
|
381
|
+
case u:
|
|
382
|
+
$2 = g2 / n;
|
|
383
|
+
break;
|
|
384
|
+
case s:
|
|
385
|
+
$2 = g2 / e;
|
|
386
|
+
break;
|
|
387
|
+
case i:
|
|
388
|
+
$2 = g2 / t;
|
|
389
|
+
break;
|
|
390
|
+
default:
|
|
391
|
+
$2 = g2;
|
|
392
|
+
}
|
|
393
|
+
return l2 ? $2 : b.a($2);
|
|
394
|
+
}, m2.daysInMonth = function() {
|
|
395
|
+
return this.endOf(c).$D;
|
|
396
|
+
}, m2.$locale = function() {
|
|
397
|
+
return D[this.$L];
|
|
398
|
+
}, m2.locale = function(t2, e2) {
|
|
399
|
+
if (!t2) return this.$L;
|
|
400
|
+
var n2 = this.clone(), r2 = w(t2, e2, true);
|
|
401
|
+
return r2 && (n2.$L = r2), n2;
|
|
402
|
+
}, m2.clone = function() {
|
|
403
|
+
return b.w(this.$d, this);
|
|
404
|
+
}, m2.toDate = function() {
|
|
405
|
+
return new Date(this.valueOf());
|
|
406
|
+
}, m2.toJSON = function() {
|
|
407
|
+
return this.isValid() ? this.toISOString() : null;
|
|
408
|
+
}, m2.toISOString = function() {
|
|
409
|
+
return this.$d.toISOString();
|
|
410
|
+
}, m2.toString = function() {
|
|
411
|
+
return this.$d.toUTCString();
|
|
412
|
+
}, M2;
|
|
413
|
+
}(), k = _.prototype;
|
|
414
|
+
return O.prototype = k, [
|
|
415
|
+
[
|
|
416
|
+
"$ms",
|
|
417
|
+
r
|
|
418
|
+
],
|
|
419
|
+
[
|
|
420
|
+
"$s",
|
|
421
|
+
i
|
|
422
|
+
],
|
|
423
|
+
[
|
|
424
|
+
"$m",
|
|
425
|
+
s
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
"$H",
|
|
429
|
+
u
|
|
430
|
+
],
|
|
431
|
+
[
|
|
432
|
+
"$W",
|
|
433
|
+
a
|
|
434
|
+
],
|
|
435
|
+
[
|
|
436
|
+
"$M",
|
|
437
|
+
c
|
|
438
|
+
],
|
|
439
|
+
[
|
|
440
|
+
"$y",
|
|
441
|
+
h
|
|
442
|
+
],
|
|
443
|
+
[
|
|
444
|
+
"$D",
|
|
445
|
+
d
|
|
446
|
+
]
|
|
447
|
+
].forEach(function(t2) {
|
|
448
|
+
k[t2[1]] = function(e2) {
|
|
449
|
+
return this.$g(e2, t2[0], t2[1]);
|
|
450
|
+
};
|
|
451
|
+
}), O.extend = function(t2, e2) {
|
|
452
|
+
return t2.$i || (t2(e2, _, O), t2.$i = true), O;
|
|
453
|
+
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
454
|
+
return O(1e3 * t2);
|
|
455
|
+
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
// src/common/utils.ts
|
|
460
|
+
var import_dayjs = __toESM(require_dayjs_min());
|
|
461
|
+
// src/web-element.ts
|
|
462
|
+
var WebElementInfo = class {
|
|
463
|
+
constructor({ content, rect, page, locator, id, attributes, indexId }){
|
|
464
|
+
this.content = content;
|
|
465
|
+
this.rect = rect;
|
|
466
|
+
this.center = [
|
|
467
|
+
Math.floor(rect.left + rect.width / 2),
|
|
468
|
+
Math.floor(rect.top + rect.height / 2)
|
|
469
|
+
];
|
|
470
|
+
this.page = page;
|
|
471
|
+
this.locator = locator;
|
|
472
|
+
this.id = id;
|
|
473
|
+
this.attributes = attributes;
|
|
474
|
+
this.indexId = indexId;
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
// src/common/utils.ts
|
|
478
|
+
function parseContextFromWebPage(page, _opt) {
|
|
479
|
+
return __async(this, null, function*() {
|
|
480
|
+
(0, _assert.default)(page, "page is required");
|
|
481
|
+
if (page._forceUsePageContext) {
|
|
482
|
+
return yield page._forceUsePageContext();
|
|
483
|
+
}
|
|
484
|
+
const url = yield page.url();
|
|
485
|
+
let screenshotBase64;
|
|
486
|
+
let elementsInfo;
|
|
487
|
+
yield Promise.all([
|
|
488
|
+
page.screenshotBase64().then((base64)=>{
|
|
489
|
+
screenshotBase64 = base64;
|
|
490
|
+
}),
|
|
491
|
+
page.getElementInfos().then((snapshot)=>__async(this, null, function*() {
|
|
492
|
+
elementsInfo = yield alignElements(snapshot, page);
|
|
493
|
+
}))
|
|
494
|
+
]);
|
|
495
|
+
(0, _assert.default)(screenshotBase64, "screenshotBase64 is required");
|
|
496
|
+
const elementsPositionInfoWithoutText = elementsInfo.filter((elementInfo)=>{
|
|
497
|
+
if (elementInfo.attributes.nodeType === _constants.NodeType.TEXT) {
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
return true;
|
|
501
|
+
});
|
|
502
|
+
const size = yield page.size();
|
|
503
|
+
const width = size.width;
|
|
504
|
+
const height = size.height;
|
|
505
|
+
const screenshotBase64WithElementMarker = (_opt == null ? void 0 : _opt.ignoreMarker) ? void 0 : yield (0, _img.compositeElementInfoImg)({
|
|
506
|
+
inputImgBase64: screenshotBase64,
|
|
507
|
+
elementsPositionInfo: elementsPositionInfoWithoutText,
|
|
508
|
+
size: {
|
|
509
|
+
width,
|
|
510
|
+
height
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
return {
|
|
514
|
+
content: elementsInfo,
|
|
515
|
+
size: {
|
|
516
|
+
width,
|
|
517
|
+
height
|
|
518
|
+
},
|
|
519
|
+
screenshotBase64,
|
|
520
|
+
screenshotBase64WithElementMarker,
|
|
521
|
+
url
|
|
522
|
+
};
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function getExtraReturnLogic() {
|
|
526
|
+
return __async(this, null, function*() {
|
|
527
|
+
const pathDir = (0, _fs1.findNearestPackageJson)(__dirname);
|
|
528
|
+
(0, _assert.default)(pathDir, `can't find pathDir, with ${__dirname}`);
|
|
529
|
+
const scriptPath = _path.default.join(pathDir, "./dist/script/htmlElement.js");
|
|
530
|
+
const elementInfosScriptContent = (0, _fs.readFileSync)(scriptPath, "utf-8");
|
|
531
|
+
return `${elementInfosScriptContent}midscene_element_inspector.webExtractTextWithPosition()`;
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
var sizeThreshold = 3;
|
|
535
|
+
function alignElements(elements, page) {
|
|
536
|
+
return __async(this, null, function*() {
|
|
537
|
+
const validElements = elements.filter((item)=>{
|
|
538
|
+
return item.rect.height >= sizeThreshold && item.rect.width >= sizeThreshold;
|
|
539
|
+
});
|
|
540
|
+
const textsAligned = [];
|
|
541
|
+
for (const item of validElements){
|
|
542
|
+
const { rect, id, content, attributes, locator, indexId } = item;
|
|
543
|
+
textsAligned.push(new WebElementInfo({
|
|
544
|
+
rect,
|
|
545
|
+
locator,
|
|
546
|
+
id,
|
|
547
|
+
content,
|
|
548
|
+
attributes,
|
|
549
|
+
page,
|
|
550
|
+
indexId
|
|
551
|
+
}));
|
|
552
|
+
}
|
|
553
|
+
return textsAligned;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function reportFileName(tag = "web") {
|
|
557
|
+
const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
|
|
558
|
+
return `${tag}-${dateTimeInFileName}`;
|
|
559
|
+
}
|
|
560
|
+
function printReportMsg(filepath) {
|
|
561
|
+
console.log("Midscene - report file updated:", filepath);
|
|
562
|
+
}
|
|
563
|
+
function getCurrentExecutionFile(trace) {
|
|
564
|
+
const error = new Error();
|
|
565
|
+
const stackTrace = trace || error.stack;
|
|
566
|
+
const pkgDir = process.cwd() || "";
|
|
567
|
+
if (stackTrace) {
|
|
568
|
+
const stackLines = stackTrace.split("\n");
|
|
569
|
+
for (const line of stackLines){
|
|
570
|
+
if (line.includes(".spec.") || line.includes(".test.") || line.includes(".ts") || line.includes(".js")) {
|
|
571
|
+
const match = line.match(/(?:at\s+)?(.*?\.(?:spec|test)\.[jt]s)/);
|
|
572
|
+
if (match == null ? void 0 : match[1]) {
|
|
573
|
+
const targetFileName = match[1].replace(pkgDir, "").trim().replace("at ", "");
|
|
574
|
+
return targetFileName;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
var testFileIndex = /* @__PURE__ */ new Map();
|
|
582
|
+
function generateCacheId(fileName) {
|
|
583
|
+
let taskFile = fileName || getCurrentExecutionFile();
|
|
584
|
+
if (!taskFile) {
|
|
585
|
+
taskFile = (0, _utils.uuid)();
|
|
586
|
+
console.warn("Midscene - using random UUID for cache id. Cache may be invalid.");
|
|
587
|
+
}
|
|
588
|
+
if (testFileIndex.has(taskFile)) {
|
|
589
|
+
const currentIndex = testFileIndex.get(taskFile);
|
|
590
|
+
if (currentIndex !== void 0) {
|
|
591
|
+
testFileIndex.set(taskFile, currentIndex + 1);
|
|
592
|
+
}
|
|
593
|
+
} else {
|
|
594
|
+
testFileIndex.set(taskFile, 1);
|
|
595
|
+
}
|
|
596
|
+
return `${taskFile}-${testFileIndex.get(taskFile)}`;
|
|
597
|
+
}
|
|
598
|
+
var ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
|
|
599
|
+
});
|
|
@@ -23,14 +23,7 @@ var midscene_element_inspector = (() => {
|
|
|
23
23
|
return a;
|
|
24
24
|
};
|
|
25
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
-
var
|
|
27
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
28
|
-
}) : x)(function(x) {
|
|
29
|
-
if (typeof require !== "undefined")
|
|
30
|
-
return require.apply(this, arguments);
|
|
31
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
32
|
-
});
|
|
33
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
26
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
34
27
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
35
28
|
};
|
|
36
29
|
var __export = (target, all) => {
|
|
@@ -55,6 +48,14 @@ var midscene_element_inspector = (() => {
|
|
|
55
48
|
));
|
|
56
49
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
57
50
|
|
|
51
|
+
// resolve-false:/empty-stub
|
|
52
|
+
var require_empty_stub = __commonJS({
|
|
53
|
+
"resolve-false:/empty-stub"(exports, module) {
|
|
54
|
+
"use strict";
|
|
55
|
+
module.exports = {};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
58
59
|
// ../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js
|
|
59
60
|
var require_sha256 = __commonJS({
|
|
60
61
|
"../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js"(exports, module) {
|
|
@@ -181,8 +182,8 @@ var midscene_element_inspector = (() => {
|
|
|
181
182
|
return method;
|
|
182
183
|
};
|
|
183
184
|
var nodeWrap = function(method, is224) {
|
|
184
|
-
var crypto =
|
|
185
|
-
var Buffer2 =
|
|
185
|
+
var crypto = require_empty_stub();
|
|
186
|
+
var Buffer2 = require_empty_stub().Buffer;
|
|
186
187
|
var algorithm = is224 ? "sha224" : "sha256";
|
|
187
188
|
var bufferFrom;
|
|
188
189
|
if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|
|
@@ -23,14 +23,7 @@ var midscene_element_inspector = (() => {
|
|
|
23
23
|
return a;
|
|
24
24
|
};
|
|
25
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
-
var
|
|
27
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
28
|
-
}) : x)(function(x) {
|
|
29
|
-
if (typeof require !== "undefined")
|
|
30
|
-
return require.apply(this, arguments);
|
|
31
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
32
|
-
});
|
|
33
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
26
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
34
27
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
35
28
|
};
|
|
36
29
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -50,6 +43,14 @@ var midscene_element_inspector = (() => {
|
|
|
50
43
|
mod
|
|
51
44
|
));
|
|
52
45
|
|
|
46
|
+
// resolve-false:/empty-stub
|
|
47
|
+
var require_empty_stub = __commonJS({
|
|
48
|
+
"resolve-false:/empty-stub"(exports, module) {
|
|
49
|
+
"use strict";
|
|
50
|
+
module.exports = {};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
53
54
|
// ../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js
|
|
54
55
|
var require_sha256 = __commonJS({
|
|
55
56
|
"../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js"(exports, module) {
|
|
@@ -176,8 +177,8 @@ var midscene_element_inspector = (() => {
|
|
|
176
177
|
return method;
|
|
177
178
|
};
|
|
178
179
|
var nodeWrap = function(method, is224) {
|
|
179
|
-
var crypto =
|
|
180
|
-
var Buffer2 =
|
|
180
|
+
var crypto = require_empty_stub();
|
|
181
|
+
var Buffer2 = require_empty_stub().Buffer;
|
|
181
182
|
var algorithm = is224 ? "sha224" : "sha256";
|
|
182
183
|
var bufferFrom;
|
|
183
184
|
if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|