@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
package/dist/lib/appium.js
CHANGED
|
@@ -1,2046 +1,2339 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
26
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
27
|
-
};
|
|
28
|
-
var __export = (target, all) => {
|
|
29
|
-
for (var name in all)
|
|
30
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
31
|
-
};
|
|
32
|
-
var __copyProps = (to, from, except, desc) => {
|
|
33
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
34
|
-
for (let key of __getOwnPropNames(from))
|
|
35
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
36
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
37
|
-
}
|
|
38
|
-
return to;
|
|
39
|
-
};
|
|
40
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
41
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
42
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
43
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
44
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
45
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
46
|
-
mod
|
|
47
|
-
));
|
|
48
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
49
|
-
|
|
50
|
-
// ../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js
|
|
51
|
-
var require_dayjs_min = __commonJS({
|
|
52
|
-
"../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js"(exports, module2) {
|
|
1
|
+
(function(global1, factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@midscene/core"), require("@midscene/shared/constants"), require("@midscene/core/utils"), require("assert"), require("fs"), require("path"), require("@midscene/shared/fs"), require("@midscene/shared/utils"), require("@midscene/shared/img"), require("@xmldom/xmldom"));
|
|
3
|
+
else if (typeof define === "function" && define.amd) define([
|
|
4
|
+
"exports",
|
|
5
|
+
"@midscene/core",
|
|
6
|
+
"@midscene/shared/constants",
|
|
7
|
+
"@midscene/core/utils",
|
|
8
|
+
"assert",
|
|
9
|
+
"fs",
|
|
10
|
+
"path",
|
|
11
|
+
"@midscene/shared/fs",
|
|
12
|
+
"@midscene/shared/utils",
|
|
13
|
+
"@midscene/shared/img",
|
|
14
|
+
"@xmldom/xmldom"
|
|
15
|
+
], factory);
|
|
16
|
+
else if (global1 = typeof globalThis !== "undefined" ? globalThis : global1 || self) factory(global1.appium = {}, global1.core, global1.constants, global1.utils, global1.assert, global1.fs, global1.path, global1.fs, global1.utils, global1.img, global1.xmldom);
|
|
17
|
+
})(this, function(exports, _core, _constants, _utils, _assert, _fs, _path, _fs1, _utils1, _img, _xmldom) {
|
|
53
18
|
"use strict";
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}(exports, function() {
|
|
57
|
-
"use strict";
|
|
58
|
-
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 = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
|
|
59
|
-
var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
|
|
60
|
-
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
|
|
61
|
-
} }, m = function(t2, e2, n2) {
|
|
62
|
-
var r2 = String(t2);
|
|
63
|
-
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
|
|
64
|
-
}, v = { s: m, z: function(t2) {
|
|
65
|
-
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
|
|
66
|
-
return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
|
|
67
|
-
}, m: function t2(e2, n2) {
|
|
68
|
-
if (e2.date() < n2.date())
|
|
69
|
-
return -t2(n2, e2);
|
|
70
|
-
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);
|
|
71
|
-
return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
|
|
72
|
-
}, a: function(t2) {
|
|
73
|
-
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
|
74
|
-
}, p: function(t2) {
|
|
75
|
-
return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
|
76
|
-
}, u: function(t2) {
|
|
77
|
-
return void 0 === t2;
|
|
78
|
-
} }, g = "en", D = {};
|
|
79
|
-
D[g] = M;
|
|
80
|
-
var p = "$isDayjsObject", S = function(t2) {
|
|
81
|
-
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
82
|
-
}, w = function t2(e2, n2, r2) {
|
|
83
|
-
var i2;
|
|
84
|
-
if (!e2)
|
|
85
|
-
return g;
|
|
86
|
-
if ("string" == typeof e2) {
|
|
87
|
-
var s2 = e2.toLowerCase();
|
|
88
|
-
D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
|
|
89
|
-
var u2 = e2.split("-");
|
|
90
|
-
if (!i2 && u2.length > 1)
|
|
91
|
-
return t2(u2[0]);
|
|
92
|
-
} else {
|
|
93
|
-
var a2 = e2.name;
|
|
94
|
-
D[a2] = e2, i2 = a2;
|
|
95
|
-
}
|
|
96
|
-
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
97
|
-
}, O = function(t2, e2) {
|
|
98
|
-
if (S(t2))
|
|
99
|
-
return t2.clone();
|
|
100
|
-
var n2 = "object" == typeof e2 ? e2 : {};
|
|
101
|
-
return n2.date = t2, n2.args = arguments, new _(n2);
|
|
102
|
-
}, b = v;
|
|
103
|
-
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
104
|
-
return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
|
|
105
|
-
};
|
|
106
|
-
var _ = function() {
|
|
107
|
-
function M2(t2) {
|
|
108
|
-
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
109
|
-
}
|
|
110
|
-
var m2 = M2.prototype;
|
|
111
|
-
return m2.parse = function(t2) {
|
|
112
|
-
this.$d = function(t3) {
|
|
113
|
-
var e2 = t3.date, n2 = t3.utc;
|
|
114
|
-
if (null === e2)
|
|
115
|
-
return /* @__PURE__ */ new Date(NaN);
|
|
116
|
-
if (b.u(e2))
|
|
117
|
-
return /* @__PURE__ */ new Date();
|
|
118
|
-
if (e2 instanceof Date)
|
|
119
|
-
return new Date(e2);
|
|
120
|
-
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
|
|
121
|
-
var r2 = e2.match($);
|
|
122
|
-
if (r2) {
|
|
123
|
-
var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
|
124
|
-
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);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return new Date(e2);
|
|
128
|
-
}(t2), this.init();
|
|
129
|
-
}, m2.init = function() {
|
|
130
|
-
var t2 = this.$d;
|
|
131
|
-
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();
|
|
132
|
-
}, m2.$utils = function() {
|
|
133
|
-
return b;
|
|
134
|
-
}, m2.isValid = function() {
|
|
135
|
-
return !(this.$d.toString() === l);
|
|
136
|
-
}, m2.isSame = function(t2, e2) {
|
|
137
|
-
var n2 = O(t2);
|
|
138
|
-
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
|
|
139
|
-
}, m2.isAfter = function(t2, e2) {
|
|
140
|
-
return O(t2) < this.startOf(e2);
|
|
141
|
-
}, m2.isBefore = function(t2, e2) {
|
|
142
|
-
return this.endOf(e2) < O(t2);
|
|
143
|
-
}, m2.$g = function(t2, e2, n2) {
|
|
144
|
-
return b.u(t2) ? this[e2] : this.set(n2, t2);
|
|
145
|
-
}, m2.unix = function() {
|
|
146
|
-
return Math.floor(this.valueOf() / 1e3);
|
|
147
|
-
}, m2.valueOf = function() {
|
|
148
|
-
return this.$d.getTime();
|
|
149
|
-
}, m2.startOf = function(t2, e2) {
|
|
150
|
-
var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
|
|
151
|
-
var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
|
|
152
|
-
return r2 ? i2 : i2.endOf(a);
|
|
153
|
-
}, $2 = function(t3, e3) {
|
|
154
|
-
return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
|
|
155
|
-
}, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
|
156
|
-
switch (f2) {
|
|
157
|
-
case h:
|
|
158
|
-
return r2 ? l2(1, 0) : l2(31, 11);
|
|
159
|
-
case c:
|
|
160
|
-
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
161
|
-
case o:
|
|
162
|
-
var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
163
|
-
return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
|
164
|
-
case a:
|
|
165
|
-
case d:
|
|
166
|
-
return $2(v2 + "Hours", 0);
|
|
167
|
-
case u:
|
|
168
|
-
return $2(v2 + "Minutes", 1);
|
|
169
|
-
case s:
|
|
170
|
-
return $2(v2 + "Seconds", 2);
|
|
171
|
-
case i:
|
|
172
|
-
return $2(v2 + "Milliseconds", 3);
|
|
173
|
-
default:
|
|
174
|
-
return this.clone();
|
|
175
|
-
}
|
|
176
|
-
}, m2.endOf = function(t2) {
|
|
177
|
-
return this.startOf(t2, false);
|
|
178
|
-
}, m2.$set = function(t2, e2) {
|
|
179
|
-
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;
|
|
180
|
-
if (o2 === c || o2 === h) {
|
|
181
|
-
var y2 = this.clone().set(d, 1);
|
|
182
|
-
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
|
183
|
-
} else
|
|
184
|
-
l2 && this.$d[l2]($2);
|
|
185
|
-
return this.init(), this;
|
|
186
|
-
}, m2.set = function(t2, e2) {
|
|
187
|
-
return this.clone().$set(t2, e2);
|
|
188
|
-
}, m2.get = function(t2) {
|
|
189
|
-
return this[b.p(t2)]();
|
|
190
|
-
}, m2.add = function(r2, f2) {
|
|
191
|
-
var d2, l2 = this;
|
|
192
|
-
r2 = Number(r2);
|
|
193
|
-
var $2 = b.p(f2), y2 = function(t2) {
|
|
194
|
-
var e2 = O(l2);
|
|
195
|
-
return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
|
|
196
|
-
};
|
|
197
|
-
if ($2 === c)
|
|
198
|
-
return this.set(c, this.$M + r2);
|
|
199
|
-
if ($2 === h)
|
|
200
|
-
return this.set(h, this.$y + r2);
|
|
201
|
-
if ($2 === a)
|
|
202
|
-
return y2(1);
|
|
203
|
-
if ($2 === o)
|
|
204
|
-
return y2(7);
|
|
205
|
-
var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
|
206
|
-
return b.w(m3, this);
|
|
207
|
-
}, m2.subtract = function(t2, e2) {
|
|
208
|
-
return this.add(-1 * t2, e2);
|
|
209
|
-
}, m2.format = function(t2) {
|
|
210
|
-
var e2 = this, n2 = this.$locale();
|
|
211
|
-
if (!this.isValid())
|
|
212
|
-
return n2.invalidDate || l;
|
|
213
|
-
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) {
|
|
214
|
-
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
|
|
215
|
-
}, d2 = function(t3) {
|
|
216
|
-
return b.s(s2 % 12 || 12, t3, "0");
|
|
217
|
-
}, $2 = f2 || function(t3, e3, n3) {
|
|
218
|
-
var r3 = t3 < 12 ? "AM" : "PM";
|
|
219
|
-
return n3 ? r3.toLowerCase() : r3;
|
|
220
|
-
};
|
|
221
|
-
return r2.replace(y, function(t3, r3) {
|
|
222
|
-
return r3 || function(t4) {
|
|
223
|
-
switch (t4) {
|
|
224
|
-
case "YY":
|
|
225
|
-
return String(e2.$y).slice(-2);
|
|
226
|
-
case "YYYY":
|
|
227
|
-
return b.s(e2.$y, 4, "0");
|
|
228
|
-
case "M":
|
|
229
|
-
return a2 + 1;
|
|
230
|
-
case "MM":
|
|
231
|
-
return b.s(a2 + 1, 2, "0");
|
|
232
|
-
case "MMM":
|
|
233
|
-
return h2(n2.monthsShort, a2, c2, 3);
|
|
234
|
-
case "MMMM":
|
|
235
|
-
return h2(c2, a2);
|
|
236
|
-
case "D":
|
|
237
|
-
return e2.$D;
|
|
238
|
-
case "DD":
|
|
239
|
-
return b.s(e2.$D, 2, "0");
|
|
240
|
-
case "d":
|
|
241
|
-
return String(e2.$W);
|
|
242
|
-
case "dd":
|
|
243
|
-
return h2(n2.weekdaysMin, e2.$W, o2, 2);
|
|
244
|
-
case "ddd":
|
|
245
|
-
return h2(n2.weekdaysShort, e2.$W, o2, 3);
|
|
246
|
-
case "dddd":
|
|
247
|
-
return o2[e2.$W];
|
|
248
|
-
case "H":
|
|
249
|
-
return String(s2);
|
|
250
|
-
case "HH":
|
|
251
|
-
return b.s(s2, 2, "0");
|
|
252
|
-
case "h":
|
|
253
|
-
return d2(1);
|
|
254
|
-
case "hh":
|
|
255
|
-
return d2(2);
|
|
256
|
-
case "a":
|
|
257
|
-
return $2(s2, u2, true);
|
|
258
|
-
case "A":
|
|
259
|
-
return $2(s2, u2, false);
|
|
260
|
-
case "m":
|
|
261
|
-
return String(u2);
|
|
262
|
-
case "mm":
|
|
263
|
-
return b.s(u2, 2, "0");
|
|
264
|
-
case "s":
|
|
265
|
-
return String(e2.$s);
|
|
266
|
-
case "ss":
|
|
267
|
-
return b.s(e2.$s, 2, "0");
|
|
268
|
-
case "SSS":
|
|
269
|
-
return b.s(e2.$ms, 3, "0");
|
|
270
|
-
case "Z":
|
|
271
|
-
return i2;
|
|
272
|
-
}
|
|
273
|
-
return null;
|
|
274
|
-
}(t3) || i2.replace(":", "");
|
|
275
|
-
});
|
|
276
|
-
}, m2.utcOffset = function() {
|
|
277
|
-
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
278
|
-
}, m2.diff = function(r2, d2, l2) {
|
|
279
|
-
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
|
|
280
|
-
return b.m(y2, m3);
|
|
281
|
-
};
|
|
282
|
-
switch (M3) {
|
|
283
|
-
case h:
|
|
284
|
-
$2 = D2() / 12;
|
|
285
|
-
break;
|
|
286
|
-
case c:
|
|
287
|
-
$2 = D2();
|
|
288
|
-
break;
|
|
289
|
-
case f:
|
|
290
|
-
$2 = D2() / 3;
|
|
291
|
-
break;
|
|
292
|
-
case o:
|
|
293
|
-
$2 = (g2 - v2) / 6048e5;
|
|
294
|
-
break;
|
|
295
|
-
case a:
|
|
296
|
-
$2 = (g2 - v2) / 864e5;
|
|
297
|
-
break;
|
|
298
|
-
case u:
|
|
299
|
-
$2 = g2 / n;
|
|
300
|
-
break;
|
|
301
|
-
case s:
|
|
302
|
-
$2 = g2 / e;
|
|
303
|
-
break;
|
|
304
|
-
case i:
|
|
305
|
-
$2 = g2 / t;
|
|
306
|
-
break;
|
|
307
|
-
default:
|
|
308
|
-
$2 = g2;
|
|
309
|
-
}
|
|
310
|
-
return l2 ? $2 : b.a($2);
|
|
311
|
-
}, m2.daysInMonth = function() {
|
|
312
|
-
return this.endOf(c).$D;
|
|
313
|
-
}, m2.$locale = function() {
|
|
314
|
-
return D[this.$L];
|
|
315
|
-
}, m2.locale = function(t2, e2) {
|
|
316
|
-
if (!t2)
|
|
317
|
-
return this.$L;
|
|
318
|
-
var n2 = this.clone(), r2 = w(t2, e2, true);
|
|
319
|
-
return r2 && (n2.$L = r2), n2;
|
|
320
|
-
}, m2.clone = function() {
|
|
321
|
-
return b.w(this.$d, this);
|
|
322
|
-
}, m2.toDate = function() {
|
|
323
|
-
return new Date(this.valueOf());
|
|
324
|
-
}, m2.toJSON = function() {
|
|
325
|
-
return this.isValid() ? this.toISOString() : null;
|
|
326
|
-
}, m2.toISOString = function() {
|
|
327
|
-
return this.$d.toISOString();
|
|
328
|
-
}, m2.toString = function() {
|
|
329
|
-
return this.$d.toUTCString();
|
|
330
|
-
}, M2;
|
|
331
|
-
}(), k = _.prototype;
|
|
332
|
-
return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
|
|
333
|
-
k[t2[1]] = function(e2) {
|
|
334
|
-
return this.$g(e2, t2[0], t2[1]);
|
|
335
|
-
};
|
|
336
|
-
}), O.extend = function(t2, e2) {
|
|
337
|
-
return t2.$i || (t2(e2, _, O), t2.$i = true), O;
|
|
338
|
-
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
339
|
-
return O(1e3 * t2);
|
|
340
|
-
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
19
|
+
Object.defineProperty(exports, "__esModule", {
|
|
20
|
+
value: true
|
|
341
21
|
});
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
root = self;
|
|
363
|
-
}
|
|
364
|
-
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module2 === "object" && module2.exports;
|
|
365
|
-
var AMD = typeof define === "function" && define.amd;
|
|
366
|
-
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
|
|
367
|
-
var HEX_CHARS = "0123456789abcdef".split("");
|
|
368
|
-
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
369
|
-
var SHIFT = [24, 16, 8, 0];
|
|
370
|
-
var K = [
|
|
371
|
-
1116352408,
|
|
372
|
-
1899447441,
|
|
373
|
-
3049323471,
|
|
374
|
-
3921009573,
|
|
375
|
-
961987163,
|
|
376
|
-
1508970993,
|
|
377
|
-
2453635748,
|
|
378
|
-
2870763221,
|
|
379
|
-
3624381080,
|
|
380
|
-
310598401,
|
|
381
|
-
607225278,
|
|
382
|
-
1426881987,
|
|
383
|
-
1925078388,
|
|
384
|
-
2162078206,
|
|
385
|
-
2614888103,
|
|
386
|
-
3248222580,
|
|
387
|
-
3835390401,
|
|
388
|
-
4022224774,
|
|
389
|
-
264347078,
|
|
390
|
-
604807628,
|
|
391
|
-
770255983,
|
|
392
|
-
1249150122,
|
|
393
|
-
1555081692,
|
|
394
|
-
1996064986,
|
|
395
|
-
2554220882,
|
|
396
|
-
2821834349,
|
|
397
|
-
2952996808,
|
|
398
|
-
3210313671,
|
|
399
|
-
3336571891,
|
|
400
|
-
3584528711,
|
|
401
|
-
113926993,
|
|
402
|
-
338241895,
|
|
403
|
-
666307205,
|
|
404
|
-
773529912,
|
|
405
|
-
1294757372,
|
|
406
|
-
1396182291,
|
|
407
|
-
1695183700,
|
|
408
|
-
1986661051,
|
|
409
|
-
2177026350,
|
|
410
|
-
2456956037,
|
|
411
|
-
2730485921,
|
|
412
|
-
2820302411,
|
|
413
|
-
3259730800,
|
|
414
|
-
3345764771,
|
|
415
|
-
3516065817,
|
|
416
|
-
3600352804,
|
|
417
|
-
4094571909,
|
|
418
|
-
275423344,
|
|
419
|
-
430227734,
|
|
420
|
-
506948616,
|
|
421
|
-
659060556,
|
|
422
|
-
883997877,
|
|
423
|
-
958139571,
|
|
424
|
-
1322822218,
|
|
425
|
-
1537002063,
|
|
426
|
-
1747873779,
|
|
427
|
-
1955562222,
|
|
428
|
-
2024104815,
|
|
429
|
-
2227730452,
|
|
430
|
-
2361852424,
|
|
431
|
-
2428436474,
|
|
432
|
-
2756734187,
|
|
433
|
-
3204031479,
|
|
434
|
-
3329325298
|
|
435
|
-
];
|
|
436
|
-
var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
|
|
437
|
-
var blocks = [];
|
|
438
|
-
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
|
|
439
|
-
Array.isArray = function(obj) {
|
|
440
|
-
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
|
444
|
-
ArrayBuffer.isView = function(obj) {
|
|
445
|
-
return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
var createOutputMethod = function(outputType, is224) {
|
|
449
|
-
return function(message) {
|
|
450
|
-
return new Sha256(is224, true).update(message)[outputType]();
|
|
451
|
-
};
|
|
452
|
-
};
|
|
453
|
-
var createMethod = function(is224) {
|
|
454
|
-
var method = createOutputMethod("hex", is224);
|
|
455
|
-
if (NODE_JS) {
|
|
456
|
-
method = nodeWrap(method, is224);
|
|
457
|
-
}
|
|
458
|
-
method.create = function() {
|
|
459
|
-
return new Sha256(is224);
|
|
22
|
+
function _export(target, all) {
|
|
23
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: all[name]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
_export(exports, {
|
|
29
|
+
AppiumAgent: function() {
|
|
30
|
+
return PageAgent;
|
|
31
|
+
},
|
|
32
|
+
AppiumPage: function() {
|
|
33
|
+
return Page;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
_assert = /*#__PURE__*/ _interop_require_default(_assert);
|
|
37
|
+
_fs = /*#__PURE__*/ _interop_require_wildcard(_fs);
|
|
38
|
+
_path = /*#__PURE__*/ _interop_require_wildcard(_path);
|
|
39
|
+
function _interop_require_default(obj) {
|
|
40
|
+
return obj && obj.__esModule ? obj : {
|
|
41
|
+
default: obj
|
|
460
42
|
};
|
|
461
|
-
|
|
462
|
-
|
|
43
|
+
}
|
|
44
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
45
|
+
if (typeof WeakMap !== "function") return null;
|
|
46
|
+
var cacheBabelInterop = new WeakMap();
|
|
47
|
+
var cacheNodeInterop = new WeakMap();
|
|
48
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
49
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
50
|
+
})(nodeInterop);
|
|
51
|
+
}
|
|
52
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
53
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
56
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
57
|
+
return {
|
|
58
|
+
default: obj
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
62
|
+
if (cache && cache.has(obj)) {
|
|
63
|
+
return cache.get(obj);
|
|
64
|
+
}
|
|
65
|
+
var newObj = {
|
|
66
|
+
__proto__: null
|
|
463
67
|
};
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
var algorithm = is224 ? "sha224" : "sha256";
|
|
474
|
-
var bufferFrom;
|
|
475
|
-
if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|
|
476
|
-
bufferFrom = Buffer2.from;
|
|
477
|
-
} else {
|
|
478
|
-
bufferFrom = function(message) {
|
|
479
|
-
return new Buffer2(message);
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
var nodeMethod = function(message) {
|
|
483
|
-
if (typeof message === "string") {
|
|
484
|
-
return crypto.createHash(algorithm).update(message, "utf8").digest("hex");
|
|
485
|
-
} else {
|
|
486
|
-
if (message === null || message === void 0) {
|
|
487
|
-
throw new Error(ERROR);
|
|
488
|
-
} else if (message.constructor === ArrayBuffer) {
|
|
489
|
-
message = new Uint8Array(message);
|
|
68
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
69
|
+
for(var key in obj){
|
|
70
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
71
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
72
|
+
if (desc && (desc.get || desc.set)) {
|
|
73
|
+
Object.defineProperty(newObj, key, desc);
|
|
74
|
+
} else {
|
|
75
|
+
newObj[key] = obj[key];
|
|
76
|
+
}
|
|
490
77
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
78
|
+
}
|
|
79
|
+
newObj.default = obj;
|
|
80
|
+
if (cache) {
|
|
81
|
+
cache.set(obj, newObj);
|
|
82
|
+
}
|
|
83
|
+
return newObj;
|
|
84
|
+
}
|
|
85
|
+
var __create = Object.create;
|
|
86
|
+
var __defProp = Object.defineProperty;
|
|
87
|
+
var __defProps = Object.defineProperties;
|
|
88
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
89
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
90
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
91
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
92
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
93
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
94
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
95
|
+
var __defNormalProp = (obj, key, value)=>key in obj ? __defProp(obj, key, {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
configurable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
value
|
|
100
|
+
}) : obj[key] = value;
|
|
101
|
+
var __spreadValues = (a, b)=>{
|
|
102
|
+
for(var prop in b || (b = {}))if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
103
|
+
if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)){
|
|
104
|
+
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
105
|
+
}
|
|
106
|
+
return a;
|
|
107
|
+
};
|
|
108
|
+
var __spreadProps = (a, b)=>__defProps(a, __getOwnPropDescs(b));
|
|
109
|
+
var __require = /* @__PURE__ */ ((x)=>typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
110
|
+
get: (a, b)=>(typeof require !== "undefined" ? require : a)[b]
|
|
111
|
+
}) : x)(function(x) {
|
|
112
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
113
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
114
|
+
});
|
|
115
|
+
var __commonJS = (cb, mod)=>function __require2() {
|
|
116
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
117
|
+
exports: {}
|
|
118
|
+
}).exports, mod), mod.exports;
|
|
512
119
|
};
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
120
|
+
var __copyProps = (to, from, except, desc)=>{
|
|
121
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
122
|
+
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
123
|
+
get: ()=>from[key],
|
|
124
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return to;
|
|
128
|
+
};
|
|
129
|
+
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
|
|
130
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
131
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
132
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
133
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
134
|
+
value: mod,
|
|
135
|
+
enumerable: true
|
|
136
|
+
}) : target, mod));
|
|
137
|
+
var __async = (__this, __arguments, generator)=>{
|
|
138
|
+
return new Promise((resolve, reject)=>{
|
|
139
|
+
var fulfilled = (value)=>{
|
|
140
|
+
try {
|
|
141
|
+
step(generator.next(value));
|
|
142
|
+
} catch (e) {
|
|
143
|
+
reject(e);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var rejected = (value)=>{
|
|
147
|
+
try {
|
|
148
|
+
step(generator.throw(value));
|
|
149
|
+
} catch (e) {
|
|
150
|
+
reject(e);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var step = (x)=>x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
154
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
// ../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js
|
|
158
|
+
var require_dayjs_min = __commonJS({
|
|
159
|
+
"../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js" (exports, module1) {
|
|
160
|
+
"use strict";
|
|
161
|
+
!function(t, e) {
|
|
162
|
+
"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();
|
|
163
|
+
}(exports, function() {
|
|
164
|
+
"use strict";
|
|
165
|
+
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 = {
|
|
166
|
+
name: "en",
|
|
167
|
+
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
|
168
|
+
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
|
169
|
+
ordinal: function(t2) {
|
|
170
|
+
var e2 = [
|
|
171
|
+
"th",
|
|
172
|
+
"st",
|
|
173
|
+
"nd",
|
|
174
|
+
"rd"
|
|
175
|
+
], n2 = t2 % 100;
|
|
176
|
+
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
|
|
177
|
+
}
|
|
178
|
+
}, m = function(t2, e2, n2) {
|
|
179
|
+
var r2 = String(t2);
|
|
180
|
+
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
|
|
181
|
+
}, v = {
|
|
182
|
+
s: m,
|
|
183
|
+
z: function(t2) {
|
|
184
|
+
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
|
|
185
|
+
return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
|
|
186
|
+
},
|
|
187
|
+
m: function t2(e2, n2) {
|
|
188
|
+
if (e2.date() < n2.date()) return -t2(n2, e2);
|
|
189
|
+
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);
|
|
190
|
+
return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
|
|
191
|
+
},
|
|
192
|
+
a: function(t2) {
|
|
193
|
+
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
|
194
|
+
},
|
|
195
|
+
p: function(t2) {
|
|
196
|
+
return ({
|
|
197
|
+
M: c,
|
|
198
|
+
y: h,
|
|
199
|
+
w: o,
|
|
200
|
+
d: a,
|
|
201
|
+
D: d,
|
|
202
|
+
h: u,
|
|
203
|
+
m: s,
|
|
204
|
+
s: i,
|
|
205
|
+
ms: r,
|
|
206
|
+
Q: f
|
|
207
|
+
})[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
|
208
|
+
},
|
|
209
|
+
u: function(t2) {
|
|
210
|
+
return void 0 === t2;
|
|
211
|
+
}
|
|
212
|
+
}, g = "en", D = {};
|
|
213
|
+
D[g] = M;
|
|
214
|
+
var p = "$isDayjsObject", S = function(t2) {
|
|
215
|
+
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
216
|
+
}, w = function t2(e2, n2, r2) {
|
|
217
|
+
var i2;
|
|
218
|
+
if (!e2) return g;
|
|
219
|
+
if ("string" == typeof e2) {
|
|
220
|
+
var s2 = e2.toLowerCase();
|
|
221
|
+
D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
|
|
222
|
+
var u2 = e2.split("-");
|
|
223
|
+
if (!i2 && u2.length > 1) return t2(u2[0]);
|
|
224
|
+
} else {
|
|
225
|
+
var a2 = e2.name;
|
|
226
|
+
D[a2] = e2, i2 = a2;
|
|
227
|
+
}
|
|
228
|
+
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
229
|
+
}, O = function(t2, e2) {
|
|
230
|
+
if (S(t2)) return t2.clone();
|
|
231
|
+
var n2 = "object" == typeof e2 ? e2 : {};
|
|
232
|
+
return n2.date = t2, n2.args = arguments, new _(n2);
|
|
233
|
+
}, b = v;
|
|
234
|
+
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
235
|
+
return O(t2, {
|
|
236
|
+
locale: e2.$L,
|
|
237
|
+
utc: e2.$u,
|
|
238
|
+
x: e2.$x,
|
|
239
|
+
$offset: e2.$offset
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
var _ = function() {
|
|
243
|
+
function M2(t2) {
|
|
244
|
+
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
245
|
+
}
|
|
246
|
+
var m2 = M2.prototype;
|
|
247
|
+
return m2.parse = function(t2) {
|
|
248
|
+
this.$d = function(t3) {
|
|
249
|
+
var e2 = t3.date, n2 = t3.utc;
|
|
250
|
+
if (null === e2) return /* @__PURE__ */ new Date(NaN);
|
|
251
|
+
if (b.u(e2)) return /* @__PURE__ */ new Date();
|
|
252
|
+
if (e2 instanceof Date) return new Date(e2);
|
|
253
|
+
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
|
|
254
|
+
var r2 = e2.match($);
|
|
255
|
+
if (r2) {
|
|
256
|
+
var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
|
257
|
+
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);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return new Date(e2);
|
|
261
|
+
}(t2), this.init();
|
|
262
|
+
}, m2.init = function() {
|
|
263
|
+
var t2 = this.$d;
|
|
264
|
+
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();
|
|
265
|
+
}, m2.$utils = function() {
|
|
266
|
+
return b;
|
|
267
|
+
}, m2.isValid = function() {
|
|
268
|
+
return !(this.$d.toString() === l);
|
|
269
|
+
}, m2.isSame = function(t2, e2) {
|
|
270
|
+
var n2 = O(t2);
|
|
271
|
+
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
|
|
272
|
+
}, m2.isAfter = function(t2, e2) {
|
|
273
|
+
return O(t2) < this.startOf(e2);
|
|
274
|
+
}, m2.isBefore = function(t2, e2) {
|
|
275
|
+
return this.endOf(e2) < O(t2);
|
|
276
|
+
}, m2.$g = function(t2, e2, n2) {
|
|
277
|
+
return b.u(t2) ? this[e2] : this.set(n2, t2);
|
|
278
|
+
}, m2.unix = function() {
|
|
279
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
280
|
+
}, m2.valueOf = function() {
|
|
281
|
+
return this.$d.getTime();
|
|
282
|
+
}, m2.startOf = function(t2, e2) {
|
|
283
|
+
var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
|
|
284
|
+
var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
|
|
285
|
+
return r2 ? i2 : i2.endOf(a);
|
|
286
|
+
}, $2 = function(t3, e3) {
|
|
287
|
+
return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [
|
|
288
|
+
0,
|
|
289
|
+
0,
|
|
290
|
+
0,
|
|
291
|
+
0
|
|
292
|
+
] : [
|
|
293
|
+
23,
|
|
294
|
+
59,
|
|
295
|
+
59,
|
|
296
|
+
999
|
|
297
|
+
]).slice(e3)), n2);
|
|
298
|
+
}, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
|
299
|
+
switch(f2){
|
|
300
|
+
case h:
|
|
301
|
+
return r2 ? l2(1, 0) : l2(31, 11);
|
|
302
|
+
case c:
|
|
303
|
+
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
304
|
+
case o:
|
|
305
|
+
var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
306
|
+
return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
|
307
|
+
case a:
|
|
308
|
+
case d:
|
|
309
|
+
return $2(v2 + "Hours", 0);
|
|
310
|
+
case u:
|
|
311
|
+
return $2(v2 + "Minutes", 1);
|
|
312
|
+
case s:
|
|
313
|
+
return $2(v2 + "Seconds", 2);
|
|
314
|
+
case i:
|
|
315
|
+
return $2(v2 + "Milliseconds", 3);
|
|
316
|
+
default:
|
|
317
|
+
return this.clone();
|
|
318
|
+
}
|
|
319
|
+
}, m2.endOf = function(t2) {
|
|
320
|
+
return this.startOf(t2, false);
|
|
321
|
+
}, m2.$set = function(t2, e2) {
|
|
322
|
+
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;
|
|
323
|
+
if (o2 === c || o2 === h) {
|
|
324
|
+
var y2 = this.clone().set(d, 1);
|
|
325
|
+
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
|
326
|
+
} else l2 && this.$d[l2]($2);
|
|
327
|
+
return this.init(), this;
|
|
328
|
+
}, m2.set = function(t2, e2) {
|
|
329
|
+
return this.clone().$set(t2, e2);
|
|
330
|
+
}, m2.get = function(t2) {
|
|
331
|
+
return this[b.p(t2)]();
|
|
332
|
+
}, m2.add = function(r2, f2) {
|
|
333
|
+
var d2, l2 = this;
|
|
334
|
+
r2 = Number(r2);
|
|
335
|
+
var $2 = b.p(f2), y2 = function(t2) {
|
|
336
|
+
var e2 = O(l2);
|
|
337
|
+
return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
|
|
338
|
+
};
|
|
339
|
+
if ($2 === c) return this.set(c, this.$M + r2);
|
|
340
|
+
if ($2 === h) return this.set(h, this.$y + r2);
|
|
341
|
+
if ($2 === a) return y2(1);
|
|
342
|
+
if ($2 === o) return y2(7);
|
|
343
|
+
var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
|
344
|
+
return b.w(m3, this);
|
|
345
|
+
}, m2.subtract = function(t2, e2) {
|
|
346
|
+
return this.add(-1 * t2, e2);
|
|
347
|
+
}, m2.format = function(t2) {
|
|
348
|
+
var e2 = this, n2 = this.$locale();
|
|
349
|
+
if (!this.isValid()) return n2.invalidDate || l;
|
|
350
|
+
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) {
|
|
351
|
+
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
|
|
352
|
+
}, d2 = function(t3) {
|
|
353
|
+
return b.s(s2 % 12 || 12, t3, "0");
|
|
354
|
+
}, $2 = f2 || function(t3, e3, n3) {
|
|
355
|
+
var r3 = t3 < 12 ? "AM" : "PM";
|
|
356
|
+
return n3 ? r3.toLowerCase() : r3;
|
|
357
|
+
};
|
|
358
|
+
return r2.replace(y, function(t3, r3) {
|
|
359
|
+
return r3 || function(t4) {
|
|
360
|
+
switch(t4){
|
|
361
|
+
case "YY":
|
|
362
|
+
return String(e2.$y).slice(-2);
|
|
363
|
+
case "YYYY":
|
|
364
|
+
return b.s(e2.$y, 4, "0");
|
|
365
|
+
case "M":
|
|
366
|
+
return a2 + 1;
|
|
367
|
+
case "MM":
|
|
368
|
+
return b.s(a2 + 1, 2, "0");
|
|
369
|
+
case "MMM":
|
|
370
|
+
return h2(n2.monthsShort, a2, c2, 3);
|
|
371
|
+
case "MMMM":
|
|
372
|
+
return h2(c2, a2);
|
|
373
|
+
case "D":
|
|
374
|
+
return e2.$D;
|
|
375
|
+
case "DD":
|
|
376
|
+
return b.s(e2.$D, 2, "0");
|
|
377
|
+
case "d":
|
|
378
|
+
return String(e2.$W);
|
|
379
|
+
case "dd":
|
|
380
|
+
return h2(n2.weekdaysMin, e2.$W, o2, 2);
|
|
381
|
+
case "ddd":
|
|
382
|
+
return h2(n2.weekdaysShort, e2.$W, o2, 3);
|
|
383
|
+
case "dddd":
|
|
384
|
+
return o2[e2.$W];
|
|
385
|
+
case "H":
|
|
386
|
+
return String(s2);
|
|
387
|
+
case "HH":
|
|
388
|
+
return b.s(s2, 2, "0");
|
|
389
|
+
case "h":
|
|
390
|
+
return d2(1);
|
|
391
|
+
case "hh":
|
|
392
|
+
return d2(2);
|
|
393
|
+
case "a":
|
|
394
|
+
return $2(s2, u2, true);
|
|
395
|
+
case "A":
|
|
396
|
+
return $2(s2, u2, false);
|
|
397
|
+
case "m":
|
|
398
|
+
return String(u2);
|
|
399
|
+
case "mm":
|
|
400
|
+
return b.s(u2, 2, "0");
|
|
401
|
+
case "s":
|
|
402
|
+
return String(e2.$s);
|
|
403
|
+
case "ss":
|
|
404
|
+
return b.s(e2.$s, 2, "0");
|
|
405
|
+
case "SSS":
|
|
406
|
+
return b.s(e2.$ms, 3, "0");
|
|
407
|
+
case "Z":
|
|
408
|
+
return i2;
|
|
409
|
+
}
|
|
410
|
+
return null;
|
|
411
|
+
}(t3) || i2.replace(":", "");
|
|
412
|
+
});
|
|
413
|
+
}, m2.utcOffset = function() {
|
|
414
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
415
|
+
}, m2.diff = function(r2, d2, l2) {
|
|
416
|
+
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
|
|
417
|
+
return b.m(y2, m3);
|
|
418
|
+
};
|
|
419
|
+
switch(M3){
|
|
420
|
+
case h:
|
|
421
|
+
$2 = D2() / 12;
|
|
422
|
+
break;
|
|
423
|
+
case c:
|
|
424
|
+
$2 = D2();
|
|
425
|
+
break;
|
|
426
|
+
case f:
|
|
427
|
+
$2 = D2() / 3;
|
|
428
|
+
break;
|
|
429
|
+
case o:
|
|
430
|
+
$2 = (g2 - v2) / 6048e5;
|
|
431
|
+
break;
|
|
432
|
+
case a:
|
|
433
|
+
$2 = (g2 - v2) / 864e5;
|
|
434
|
+
break;
|
|
435
|
+
case u:
|
|
436
|
+
$2 = g2 / n;
|
|
437
|
+
break;
|
|
438
|
+
case s:
|
|
439
|
+
$2 = g2 / e;
|
|
440
|
+
break;
|
|
441
|
+
case i:
|
|
442
|
+
$2 = g2 / t;
|
|
443
|
+
break;
|
|
444
|
+
default:
|
|
445
|
+
$2 = g2;
|
|
446
|
+
}
|
|
447
|
+
return l2 ? $2 : b.a($2);
|
|
448
|
+
}, m2.daysInMonth = function() {
|
|
449
|
+
return this.endOf(c).$D;
|
|
450
|
+
}, m2.$locale = function() {
|
|
451
|
+
return D[this.$L];
|
|
452
|
+
}, m2.locale = function(t2, e2) {
|
|
453
|
+
if (!t2) return this.$L;
|
|
454
|
+
var n2 = this.clone(), r2 = w(t2, e2, true);
|
|
455
|
+
return r2 && (n2.$L = r2), n2;
|
|
456
|
+
}, m2.clone = function() {
|
|
457
|
+
return b.w(this.$d, this);
|
|
458
|
+
}, m2.toDate = function() {
|
|
459
|
+
return new Date(this.valueOf());
|
|
460
|
+
}, m2.toJSON = function() {
|
|
461
|
+
return this.isValid() ? this.toISOString() : null;
|
|
462
|
+
}, m2.toISOString = function() {
|
|
463
|
+
return this.$d.toISOString();
|
|
464
|
+
}, m2.toString = function() {
|
|
465
|
+
return this.$d.toUTCString();
|
|
466
|
+
}, M2;
|
|
467
|
+
}(), k = _.prototype;
|
|
468
|
+
return O.prototype = k, [
|
|
469
|
+
[
|
|
470
|
+
"$ms",
|
|
471
|
+
r
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
"$s",
|
|
475
|
+
i
|
|
476
|
+
],
|
|
477
|
+
[
|
|
478
|
+
"$m",
|
|
479
|
+
s
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
"$H",
|
|
483
|
+
u
|
|
484
|
+
],
|
|
485
|
+
[
|
|
486
|
+
"$W",
|
|
487
|
+
a
|
|
488
|
+
],
|
|
489
|
+
[
|
|
490
|
+
"$M",
|
|
491
|
+
c
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
"$y",
|
|
495
|
+
h
|
|
496
|
+
],
|
|
497
|
+
[
|
|
498
|
+
"$D",
|
|
499
|
+
d
|
|
500
|
+
]
|
|
501
|
+
].forEach(function(t2) {
|
|
502
|
+
k[t2[1]] = function(e2) {
|
|
503
|
+
return this.$g(e2, t2[0], t2[1]);
|
|
504
|
+
};
|
|
505
|
+
}), O.extend = function(t2, e2) {
|
|
506
|
+
return t2.$i || (t2(e2, _, O), t2.$i = true), O;
|
|
507
|
+
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
508
|
+
return O(1e3 * t2);
|
|
509
|
+
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
// ../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js
|
|
514
|
+
var require_sha256 = __commonJS({
|
|
515
|
+
"../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js" (exports, module1) {
|
|
516
|
+
"use strict";
|
|
517
|
+
(function() {
|
|
518
|
+
"use strict";
|
|
519
|
+
var ERROR = "input is invalid type";
|
|
520
|
+
var WINDOW = typeof window === "object";
|
|
521
|
+
var root = WINDOW ? window : {};
|
|
522
|
+
if (root.JS_SHA256_NO_WINDOW) {
|
|
523
|
+
WINDOW = false;
|
|
524
|
+
}
|
|
525
|
+
var WEB_WORKER = !WINDOW && typeof self === "object";
|
|
526
|
+
var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node;
|
|
527
|
+
if (NODE_JS) {
|
|
528
|
+
root = global;
|
|
529
|
+
} else if (WEB_WORKER) {
|
|
530
|
+
root = self;
|
|
531
|
+
}
|
|
532
|
+
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module1 === "object" && module1.exports;
|
|
533
|
+
var AMD = typeof define === "function" && define.amd;
|
|
534
|
+
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
|
|
535
|
+
var HEX_CHARS = "0123456789abcdef".split("");
|
|
536
|
+
var EXTRA = [
|
|
537
|
+
-2147483648,
|
|
538
|
+
8388608,
|
|
539
|
+
32768,
|
|
540
|
+
128
|
|
541
|
+
];
|
|
542
|
+
var SHIFT = [
|
|
543
|
+
24,
|
|
544
|
+
16,
|
|
545
|
+
8,
|
|
546
|
+
0
|
|
547
|
+
];
|
|
548
|
+
var K = [
|
|
549
|
+
1116352408,
|
|
550
|
+
1899447441,
|
|
551
|
+
3049323471,
|
|
552
|
+
3921009573,
|
|
553
|
+
961987163,
|
|
554
|
+
1508970993,
|
|
555
|
+
2453635748,
|
|
556
|
+
2870763221,
|
|
557
|
+
3624381080,
|
|
558
|
+
310598401,
|
|
559
|
+
607225278,
|
|
560
|
+
1426881987,
|
|
561
|
+
1925078388,
|
|
562
|
+
2162078206,
|
|
563
|
+
2614888103,
|
|
564
|
+
3248222580,
|
|
565
|
+
3835390401,
|
|
566
|
+
4022224774,
|
|
567
|
+
264347078,
|
|
568
|
+
604807628,
|
|
569
|
+
770255983,
|
|
570
|
+
1249150122,
|
|
571
|
+
1555081692,
|
|
572
|
+
1996064986,
|
|
573
|
+
2554220882,
|
|
574
|
+
2821834349,
|
|
575
|
+
2952996808,
|
|
576
|
+
3210313671,
|
|
577
|
+
3336571891,
|
|
578
|
+
3584528711,
|
|
579
|
+
113926993,
|
|
580
|
+
338241895,
|
|
581
|
+
666307205,
|
|
582
|
+
773529912,
|
|
583
|
+
1294757372,
|
|
584
|
+
1396182291,
|
|
585
|
+
1695183700,
|
|
586
|
+
1986661051,
|
|
587
|
+
2177026350,
|
|
588
|
+
2456956037,
|
|
589
|
+
2730485921,
|
|
590
|
+
2820302411,
|
|
591
|
+
3259730800,
|
|
592
|
+
3345764771,
|
|
593
|
+
3516065817,
|
|
594
|
+
3600352804,
|
|
595
|
+
4094571909,
|
|
596
|
+
275423344,
|
|
597
|
+
430227734,
|
|
598
|
+
506948616,
|
|
599
|
+
659060556,
|
|
600
|
+
883997877,
|
|
601
|
+
958139571,
|
|
602
|
+
1322822218,
|
|
603
|
+
1537002063,
|
|
604
|
+
1747873779,
|
|
605
|
+
1955562222,
|
|
606
|
+
2024104815,
|
|
607
|
+
2227730452,
|
|
608
|
+
2361852424,
|
|
609
|
+
2428436474,
|
|
610
|
+
2756734187,
|
|
611
|
+
3204031479,
|
|
612
|
+
3329325298
|
|
613
|
+
];
|
|
614
|
+
var OUTPUT_TYPES = [
|
|
615
|
+
"hex",
|
|
616
|
+
"array",
|
|
617
|
+
"digest",
|
|
618
|
+
"arrayBuffer"
|
|
619
|
+
];
|
|
620
|
+
var blocks = [];
|
|
621
|
+
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
|
|
622
|
+
Array.isArray = function(obj) {
|
|
623
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
|
627
|
+
ArrayBuffer.isView = function(obj) {
|
|
628
|
+
return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
var createOutputMethod = function(outputType, is224) {
|
|
632
|
+
return function(message) {
|
|
633
|
+
return new Sha256(is224, true).update(message)[outputType]();
|
|
634
|
+
};
|
|
635
|
+
};
|
|
636
|
+
var createMethod = function(is224) {
|
|
637
|
+
var method = createOutputMethod("hex", is224);
|
|
638
|
+
if (NODE_JS) {
|
|
639
|
+
method = nodeWrap(method, is224);
|
|
640
|
+
}
|
|
641
|
+
method.create = function() {
|
|
642
|
+
return new Sha256(is224);
|
|
643
|
+
};
|
|
644
|
+
method.update = function(message) {
|
|
645
|
+
return method.create().update(message);
|
|
646
|
+
};
|
|
647
|
+
for(var i = 0; i < OUTPUT_TYPES.length; ++i){
|
|
648
|
+
var type = OUTPUT_TYPES[i];
|
|
649
|
+
method[type] = createOutputMethod(type, is224);
|
|
650
|
+
}
|
|
651
|
+
return method;
|
|
652
|
+
};
|
|
653
|
+
var nodeWrap = function(method, is224) {
|
|
654
|
+
var crypto = __require("crypto");
|
|
655
|
+
var Buffer2 = __require("buffer").Buffer;
|
|
656
|
+
var algorithm = is224 ? "sha224" : "sha256";
|
|
657
|
+
var bufferFrom;
|
|
658
|
+
if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|
|
659
|
+
bufferFrom = Buffer2.from;
|
|
660
|
+
} else {
|
|
661
|
+
bufferFrom = function(message) {
|
|
662
|
+
return new Buffer2(message);
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
var nodeMethod = function(message) {
|
|
666
|
+
if (typeof message === "string") {
|
|
667
|
+
return crypto.createHash(algorithm).update(message, "utf8").digest("hex");
|
|
668
|
+
} else {
|
|
669
|
+
if (message === null || message === void 0) {
|
|
670
|
+
throw new Error(ERROR);
|
|
671
|
+
} else if (message.constructor === ArrayBuffer) {
|
|
672
|
+
message = new Uint8Array(message);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
if (Array.isArray(message) || ArrayBuffer.isView(message) || message.constructor === Buffer2) {
|
|
676
|
+
return crypto.createHash(algorithm).update(bufferFrom(message)).digest("hex");
|
|
677
|
+
} else {
|
|
678
|
+
return method(message);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
return nodeMethod;
|
|
682
|
+
};
|
|
683
|
+
var createHmacOutputMethod = function(outputType, is224) {
|
|
684
|
+
return function(key, message) {
|
|
685
|
+
return new HmacSha256(key, is224, true).update(message)[outputType]();
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
var createHmacMethod = function(is224) {
|
|
689
|
+
var method = createHmacOutputMethod("hex", is224);
|
|
690
|
+
method.create = function(key) {
|
|
691
|
+
return new HmacSha256(key, is224);
|
|
692
|
+
};
|
|
693
|
+
method.update = function(key, message) {
|
|
694
|
+
return method.create(key).update(message);
|
|
695
|
+
};
|
|
696
|
+
for(var i = 0; i < OUTPUT_TYPES.length; ++i){
|
|
697
|
+
var type = OUTPUT_TYPES[i];
|
|
698
|
+
method[type] = createHmacOutputMethod(type, is224);
|
|
699
|
+
}
|
|
700
|
+
return method;
|
|
701
|
+
};
|
|
702
|
+
function Sha256(is224, sharedMemory) {
|
|
703
|
+
if (sharedMemory) {
|
|
704
|
+
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
705
|
+
this.blocks = blocks;
|
|
706
|
+
} else {
|
|
707
|
+
this.blocks = [
|
|
708
|
+
0,
|
|
709
|
+
0,
|
|
710
|
+
0,
|
|
711
|
+
0,
|
|
712
|
+
0,
|
|
713
|
+
0,
|
|
714
|
+
0,
|
|
715
|
+
0,
|
|
716
|
+
0,
|
|
717
|
+
0,
|
|
718
|
+
0,
|
|
719
|
+
0,
|
|
720
|
+
0,
|
|
721
|
+
0,
|
|
722
|
+
0,
|
|
723
|
+
0,
|
|
724
|
+
0
|
|
725
|
+
];
|
|
726
|
+
}
|
|
727
|
+
if (is224) {
|
|
728
|
+
this.h0 = 3238371032;
|
|
729
|
+
this.h1 = 914150663;
|
|
730
|
+
this.h2 = 812702999;
|
|
731
|
+
this.h3 = 4144912697;
|
|
732
|
+
this.h4 = 4290775857;
|
|
733
|
+
this.h5 = 1750603025;
|
|
734
|
+
this.h6 = 1694076839;
|
|
735
|
+
this.h7 = 3204075428;
|
|
736
|
+
} else {
|
|
737
|
+
this.h0 = 1779033703;
|
|
738
|
+
this.h1 = 3144134277;
|
|
739
|
+
this.h2 = 1013904242;
|
|
740
|
+
this.h3 = 2773480762;
|
|
741
|
+
this.h4 = 1359893119;
|
|
742
|
+
this.h5 = 2600822924;
|
|
743
|
+
this.h6 = 528734635;
|
|
744
|
+
this.h7 = 1541459225;
|
|
745
|
+
}
|
|
746
|
+
this.block = this.start = this.bytes = this.hBytes = 0;
|
|
747
|
+
this.finalized = this.hashed = false;
|
|
748
|
+
this.first = true;
|
|
749
|
+
this.is224 = is224;
|
|
750
|
+
}
|
|
751
|
+
Sha256.prototype.update = function(message) {
|
|
752
|
+
if (this.finalized) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
var notString, type = typeof message;
|
|
756
|
+
if (type !== "string") {
|
|
757
|
+
if (type === "object") {
|
|
758
|
+
if (message === null) {
|
|
759
|
+
throw new Error(ERROR);
|
|
760
|
+
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
|
761
|
+
message = new Uint8Array(message);
|
|
762
|
+
} else if (!Array.isArray(message)) {
|
|
763
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
|
764
|
+
throw new Error(ERROR);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
} else {
|
|
768
|
+
throw new Error(ERROR);
|
|
769
|
+
}
|
|
770
|
+
notString = true;
|
|
771
|
+
}
|
|
772
|
+
var code, index = 0, i, length = message.length, blocks2 = this.blocks;
|
|
773
|
+
while(index < length){
|
|
774
|
+
if (this.hashed) {
|
|
775
|
+
this.hashed = false;
|
|
776
|
+
blocks2[0] = this.block;
|
|
777
|
+
this.block = blocks2[16] = blocks2[1] = blocks2[2] = blocks2[3] = blocks2[4] = blocks2[5] = blocks2[6] = blocks2[7] = blocks2[8] = blocks2[9] = blocks2[10] = blocks2[11] = blocks2[12] = blocks2[13] = blocks2[14] = blocks2[15] = 0;
|
|
778
|
+
}
|
|
779
|
+
if (notString) {
|
|
780
|
+
for(i = this.start; index < length && i < 64; ++index){
|
|
781
|
+
blocks2[i >>> 2] |= message[index] << SHIFT[i++ & 3];
|
|
782
|
+
}
|
|
783
|
+
} else {
|
|
784
|
+
for(i = this.start; index < length && i < 64; ++index){
|
|
785
|
+
code = message.charCodeAt(index);
|
|
786
|
+
if (code < 128) {
|
|
787
|
+
blocks2[i >>> 2] |= code << SHIFT[i++ & 3];
|
|
788
|
+
} else if (code < 2048) {
|
|
789
|
+
blocks2[i >>> 2] |= (192 | code >>> 6) << SHIFT[i++ & 3];
|
|
790
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
791
|
+
} else if (code < 55296 || code >= 57344) {
|
|
792
|
+
blocks2[i >>> 2] |= (224 | code >>> 12) << SHIFT[i++ & 3];
|
|
793
|
+
blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
|
|
794
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
795
|
+
} else {
|
|
796
|
+
code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023);
|
|
797
|
+
blocks2[i >>> 2] |= (240 | code >>> 18) << SHIFT[i++ & 3];
|
|
798
|
+
blocks2[i >>> 2] |= (128 | code >>> 12 & 63) << SHIFT[i++ & 3];
|
|
799
|
+
blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
|
|
800
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
this.lastByteIndex = i;
|
|
805
|
+
this.bytes += i - this.start;
|
|
806
|
+
if (i >= 64) {
|
|
807
|
+
this.block = blocks2[16];
|
|
808
|
+
this.start = i - 64;
|
|
809
|
+
this.hash();
|
|
810
|
+
this.hashed = true;
|
|
811
|
+
} else {
|
|
812
|
+
this.start = i;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
if (this.bytes > 4294967295) {
|
|
816
|
+
this.hBytes += this.bytes / 4294967296 << 0;
|
|
817
|
+
this.bytes = this.bytes % 4294967296;
|
|
818
|
+
}
|
|
819
|
+
return this;
|
|
820
|
+
};
|
|
821
|
+
Sha256.prototype.finalize = function() {
|
|
822
|
+
if (this.finalized) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
this.finalized = true;
|
|
826
|
+
var blocks2 = this.blocks, i = this.lastByteIndex;
|
|
827
|
+
blocks2[16] = this.block;
|
|
828
|
+
blocks2[i >>> 2] |= EXTRA[i & 3];
|
|
829
|
+
this.block = blocks2[16];
|
|
830
|
+
if (i >= 56) {
|
|
831
|
+
if (!this.hashed) {
|
|
832
|
+
this.hash();
|
|
833
|
+
}
|
|
834
|
+
blocks2[0] = this.block;
|
|
835
|
+
blocks2[16] = blocks2[1] = blocks2[2] = blocks2[3] = blocks2[4] = blocks2[5] = blocks2[6] = blocks2[7] = blocks2[8] = blocks2[9] = blocks2[10] = blocks2[11] = blocks2[12] = blocks2[13] = blocks2[14] = blocks2[15] = 0;
|
|
836
|
+
}
|
|
837
|
+
blocks2[14] = this.hBytes << 3 | this.bytes >>> 29;
|
|
838
|
+
blocks2[15] = this.bytes << 3;
|
|
839
|
+
this.hash();
|
|
840
|
+
};
|
|
841
|
+
Sha256.prototype.hash = function() {
|
|
842
|
+
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, h = this.h7, blocks2 = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
|
|
843
|
+
for(j = 16; j < 64; ++j){
|
|
844
|
+
t1 = blocks2[j - 15];
|
|
845
|
+
s0 = (t1 >>> 7 | t1 << 25) ^ (t1 >>> 18 | t1 << 14) ^ t1 >>> 3;
|
|
846
|
+
t1 = blocks2[j - 2];
|
|
847
|
+
s1 = (t1 >>> 17 | t1 << 15) ^ (t1 >>> 19 | t1 << 13) ^ t1 >>> 10;
|
|
848
|
+
blocks2[j] = blocks2[j - 16] + s0 + blocks2[j - 7] + s1 << 0;
|
|
849
|
+
}
|
|
850
|
+
bc = b & c;
|
|
851
|
+
for(j = 0; j < 64; j += 4){
|
|
852
|
+
if (this.first) {
|
|
853
|
+
if (this.is224) {
|
|
854
|
+
ab = 300032;
|
|
855
|
+
t1 = blocks2[0] - 1413257819;
|
|
856
|
+
h = t1 - 150054599 << 0;
|
|
857
|
+
d = t1 + 24177077 << 0;
|
|
858
|
+
} else {
|
|
859
|
+
ab = 704751109;
|
|
860
|
+
t1 = blocks2[0] - 210244248;
|
|
861
|
+
h = t1 - 1521486534 << 0;
|
|
862
|
+
d = t1 + 143694565 << 0;
|
|
863
|
+
}
|
|
864
|
+
this.first = false;
|
|
865
|
+
} else {
|
|
866
|
+
s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
|
|
867
|
+
s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
|
|
868
|
+
ab = a & b;
|
|
869
|
+
maj = ab ^ a & c ^ bc;
|
|
870
|
+
ch = e & f ^ ~e & g;
|
|
871
|
+
t1 = h + s1 + ch + K[j] + blocks2[j];
|
|
872
|
+
t2 = s0 + maj;
|
|
873
|
+
h = d + t1 << 0;
|
|
874
|
+
d = t1 + t2 << 0;
|
|
875
|
+
}
|
|
876
|
+
s0 = (d >>> 2 | d << 30) ^ (d >>> 13 | d << 19) ^ (d >>> 22 | d << 10);
|
|
877
|
+
s1 = (h >>> 6 | h << 26) ^ (h >>> 11 | h << 21) ^ (h >>> 25 | h << 7);
|
|
878
|
+
da = d & a;
|
|
879
|
+
maj = da ^ d & b ^ ab;
|
|
880
|
+
ch = h & e ^ ~h & f;
|
|
881
|
+
t1 = g + s1 + ch + K[j + 1] + blocks2[j + 1];
|
|
882
|
+
t2 = s0 + maj;
|
|
883
|
+
g = c + t1 << 0;
|
|
884
|
+
c = t1 + t2 << 0;
|
|
885
|
+
s0 = (c >>> 2 | c << 30) ^ (c >>> 13 | c << 19) ^ (c >>> 22 | c << 10);
|
|
886
|
+
s1 = (g >>> 6 | g << 26) ^ (g >>> 11 | g << 21) ^ (g >>> 25 | g << 7);
|
|
887
|
+
cd = c & d;
|
|
888
|
+
maj = cd ^ c & a ^ da;
|
|
889
|
+
ch = g & h ^ ~g & e;
|
|
890
|
+
t1 = f + s1 + ch + K[j + 2] + blocks2[j + 2];
|
|
891
|
+
t2 = s0 + maj;
|
|
892
|
+
f = b + t1 << 0;
|
|
893
|
+
b = t1 + t2 << 0;
|
|
894
|
+
s0 = (b >>> 2 | b << 30) ^ (b >>> 13 | b << 19) ^ (b >>> 22 | b << 10);
|
|
895
|
+
s1 = (f >>> 6 | f << 26) ^ (f >>> 11 | f << 21) ^ (f >>> 25 | f << 7);
|
|
896
|
+
bc = b & c;
|
|
897
|
+
maj = bc ^ b & d ^ cd;
|
|
898
|
+
ch = f & g ^ ~f & h;
|
|
899
|
+
t1 = e + s1 + ch + K[j + 3] + blocks2[j + 3];
|
|
900
|
+
t2 = s0 + maj;
|
|
901
|
+
e = a + t1 << 0;
|
|
902
|
+
a = t1 + t2 << 0;
|
|
903
|
+
this.chromeBugWorkAround = true;
|
|
904
|
+
}
|
|
905
|
+
this.h0 = this.h0 + a << 0;
|
|
906
|
+
this.h1 = this.h1 + b << 0;
|
|
907
|
+
this.h2 = this.h2 + c << 0;
|
|
908
|
+
this.h3 = this.h3 + d << 0;
|
|
909
|
+
this.h4 = this.h4 + e << 0;
|
|
910
|
+
this.h5 = this.h5 + f << 0;
|
|
911
|
+
this.h6 = this.h6 + g << 0;
|
|
912
|
+
this.h7 = this.h7 + h << 0;
|
|
913
|
+
};
|
|
914
|
+
Sha256.prototype.hex = function() {
|
|
915
|
+
this.finalize();
|
|
916
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7;
|
|
917
|
+
var hex = HEX_CHARS[h0 >>> 28 & 15] + HEX_CHARS[h0 >>> 24 & 15] + HEX_CHARS[h0 >>> 20 & 15] + HEX_CHARS[h0 >>> 16 & 15] + HEX_CHARS[h0 >>> 12 & 15] + HEX_CHARS[h0 >>> 8 & 15] + HEX_CHARS[h0 >>> 4 & 15] + HEX_CHARS[h0 & 15] + HEX_CHARS[h1 >>> 28 & 15] + HEX_CHARS[h1 >>> 24 & 15] + HEX_CHARS[h1 >>> 20 & 15] + HEX_CHARS[h1 >>> 16 & 15] + HEX_CHARS[h1 >>> 12 & 15] + HEX_CHARS[h1 >>> 8 & 15] + HEX_CHARS[h1 >>> 4 & 15] + HEX_CHARS[h1 & 15] + HEX_CHARS[h2 >>> 28 & 15] + HEX_CHARS[h2 >>> 24 & 15] + HEX_CHARS[h2 >>> 20 & 15] + HEX_CHARS[h2 >>> 16 & 15] + HEX_CHARS[h2 >>> 12 & 15] + HEX_CHARS[h2 >>> 8 & 15] + HEX_CHARS[h2 >>> 4 & 15] + HEX_CHARS[h2 & 15] + HEX_CHARS[h3 >>> 28 & 15] + HEX_CHARS[h3 >>> 24 & 15] + HEX_CHARS[h3 >>> 20 & 15] + HEX_CHARS[h3 >>> 16 & 15] + HEX_CHARS[h3 >>> 12 & 15] + HEX_CHARS[h3 >>> 8 & 15] + HEX_CHARS[h3 >>> 4 & 15] + HEX_CHARS[h3 & 15] + HEX_CHARS[h4 >>> 28 & 15] + HEX_CHARS[h4 >>> 24 & 15] + HEX_CHARS[h4 >>> 20 & 15] + HEX_CHARS[h4 >>> 16 & 15] + HEX_CHARS[h4 >>> 12 & 15] + HEX_CHARS[h4 >>> 8 & 15] + HEX_CHARS[h4 >>> 4 & 15] + HEX_CHARS[h4 & 15] + HEX_CHARS[h5 >>> 28 & 15] + HEX_CHARS[h5 >>> 24 & 15] + HEX_CHARS[h5 >>> 20 & 15] + HEX_CHARS[h5 >>> 16 & 15] + HEX_CHARS[h5 >>> 12 & 15] + HEX_CHARS[h5 >>> 8 & 15] + HEX_CHARS[h5 >>> 4 & 15] + HEX_CHARS[h5 & 15] + HEX_CHARS[h6 >>> 28 & 15] + HEX_CHARS[h6 >>> 24 & 15] + HEX_CHARS[h6 >>> 20 & 15] + HEX_CHARS[h6 >>> 16 & 15] + HEX_CHARS[h6 >>> 12 & 15] + HEX_CHARS[h6 >>> 8 & 15] + HEX_CHARS[h6 >>> 4 & 15] + HEX_CHARS[h6 & 15];
|
|
918
|
+
if (!this.is224) {
|
|
919
|
+
hex += HEX_CHARS[h7 >>> 28 & 15] + HEX_CHARS[h7 >>> 24 & 15] + HEX_CHARS[h7 >>> 20 & 15] + HEX_CHARS[h7 >>> 16 & 15] + HEX_CHARS[h7 >>> 12 & 15] + HEX_CHARS[h7 >>> 8 & 15] + HEX_CHARS[h7 >>> 4 & 15] + HEX_CHARS[h7 & 15];
|
|
920
|
+
}
|
|
921
|
+
return hex;
|
|
922
|
+
};
|
|
923
|
+
Sha256.prototype.toString = Sha256.prototype.hex;
|
|
924
|
+
Sha256.prototype.digest = function() {
|
|
925
|
+
this.finalize();
|
|
926
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7;
|
|
927
|
+
var arr = [
|
|
928
|
+
h0 >>> 24 & 255,
|
|
929
|
+
h0 >>> 16 & 255,
|
|
930
|
+
h0 >>> 8 & 255,
|
|
931
|
+
h0 & 255,
|
|
932
|
+
h1 >>> 24 & 255,
|
|
933
|
+
h1 >>> 16 & 255,
|
|
934
|
+
h1 >>> 8 & 255,
|
|
935
|
+
h1 & 255,
|
|
936
|
+
h2 >>> 24 & 255,
|
|
937
|
+
h2 >>> 16 & 255,
|
|
938
|
+
h2 >>> 8 & 255,
|
|
939
|
+
h2 & 255,
|
|
940
|
+
h3 >>> 24 & 255,
|
|
941
|
+
h3 >>> 16 & 255,
|
|
942
|
+
h3 >>> 8 & 255,
|
|
943
|
+
h3 & 255,
|
|
944
|
+
h4 >>> 24 & 255,
|
|
945
|
+
h4 >>> 16 & 255,
|
|
946
|
+
h4 >>> 8 & 255,
|
|
947
|
+
h4 & 255,
|
|
948
|
+
h5 >>> 24 & 255,
|
|
949
|
+
h5 >>> 16 & 255,
|
|
950
|
+
h5 >>> 8 & 255,
|
|
951
|
+
h5 & 255,
|
|
952
|
+
h6 >>> 24 & 255,
|
|
953
|
+
h6 >>> 16 & 255,
|
|
954
|
+
h6 >>> 8 & 255,
|
|
955
|
+
h6 & 255
|
|
956
|
+
];
|
|
957
|
+
if (!this.is224) {
|
|
958
|
+
arr.push(h7 >>> 24 & 255, h7 >>> 16 & 255, h7 >>> 8 & 255, h7 & 255);
|
|
959
|
+
}
|
|
960
|
+
return arr;
|
|
961
|
+
};
|
|
962
|
+
Sha256.prototype.array = Sha256.prototype.digest;
|
|
963
|
+
Sha256.prototype.arrayBuffer = function() {
|
|
964
|
+
this.finalize();
|
|
965
|
+
var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
|
|
966
|
+
var dataView = new DataView(buffer);
|
|
967
|
+
dataView.setUint32(0, this.h0);
|
|
968
|
+
dataView.setUint32(4, this.h1);
|
|
969
|
+
dataView.setUint32(8, this.h2);
|
|
970
|
+
dataView.setUint32(12, this.h3);
|
|
971
|
+
dataView.setUint32(16, this.h4);
|
|
972
|
+
dataView.setUint32(20, this.h5);
|
|
973
|
+
dataView.setUint32(24, this.h6);
|
|
974
|
+
if (!this.is224) {
|
|
975
|
+
dataView.setUint32(28, this.h7);
|
|
976
|
+
}
|
|
977
|
+
return buffer;
|
|
978
|
+
};
|
|
979
|
+
function HmacSha256(key, is224, sharedMemory) {
|
|
980
|
+
var i, type = typeof key;
|
|
981
|
+
if (type === "string") {
|
|
982
|
+
var bytes = [], length = key.length, index = 0, code;
|
|
983
|
+
for(i = 0; i < length; ++i){
|
|
984
|
+
code = key.charCodeAt(i);
|
|
985
|
+
if (code < 128) {
|
|
986
|
+
bytes[index++] = code;
|
|
987
|
+
} else if (code < 2048) {
|
|
988
|
+
bytes[index++] = 192 | code >>> 6;
|
|
989
|
+
bytes[index++] = 128 | code & 63;
|
|
990
|
+
} else if (code < 55296 || code >= 57344) {
|
|
991
|
+
bytes[index++] = 224 | code >>> 12;
|
|
992
|
+
bytes[index++] = 128 | code >>> 6 & 63;
|
|
993
|
+
bytes[index++] = 128 | code & 63;
|
|
994
|
+
} else {
|
|
995
|
+
code = 65536 + ((code & 1023) << 10 | key.charCodeAt(++i) & 1023);
|
|
996
|
+
bytes[index++] = 240 | code >>> 18;
|
|
997
|
+
bytes[index++] = 128 | code >>> 12 & 63;
|
|
998
|
+
bytes[index++] = 128 | code >>> 6 & 63;
|
|
999
|
+
bytes[index++] = 128 | code & 63;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
key = bytes;
|
|
1003
|
+
} else {
|
|
1004
|
+
if (type === "object") {
|
|
1005
|
+
if (key === null) {
|
|
1006
|
+
throw new Error(ERROR);
|
|
1007
|
+
} else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
|
|
1008
|
+
key = new Uint8Array(key);
|
|
1009
|
+
} else if (!Array.isArray(key)) {
|
|
1010
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
|
|
1011
|
+
throw new Error(ERROR);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
} else {
|
|
1015
|
+
throw new Error(ERROR);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
if (key.length > 64) {
|
|
1019
|
+
key = new Sha256(is224, true).update(key).array();
|
|
1020
|
+
}
|
|
1021
|
+
var oKeyPad = [], iKeyPad = [];
|
|
1022
|
+
for(i = 0; i < 64; ++i){
|
|
1023
|
+
var b = key[i] || 0;
|
|
1024
|
+
oKeyPad[i] = 92 ^ b;
|
|
1025
|
+
iKeyPad[i] = 54 ^ b;
|
|
1026
|
+
}
|
|
1027
|
+
Sha256.call(this, is224, sharedMemory);
|
|
1028
|
+
this.update(iKeyPad);
|
|
1029
|
+
this.oKeyPad = oKeyPad;
|
|
1030
|
+
this.inner = true;
|
|
1031
|
+
this.sharedMemory = sharedMemory;
|
|
1032
|
+
}
|
|
1033
|
+
HmacSha256.prototype = new Sha256();
|
|
1034
|
+
HmacSha256.prototype.finalize = function() {
|
|
1035
|
+
Sha256.prototype.finalize.call(this);
|
|
1036
|
+
if (this.inner) {
|
|
1037
|
+
this.inner = false;
|
|
1038
|
+
var innerHash = this.array();
|
|
1039
|
+
Sha256.call(this, this.is224, this.sharedMemory);
|
|
1040
|
+
this.update(this.oKeyPad);
|
|
1041
|
+
this.update(innerHash);
|
|
1042
|
+
Sha256.prototype.finalize.call(this);
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
var exports2 = createMethod();
|
|
1046
|
+
exports2.sha256 = exports2;
|
|
1047
|
+
exports2.sha224 = createMethod(true);
|
|
1048
|
+
exports2.sha256.hmac = createHmacMethod();
|
|
1049
|
+
exports2.sha224.hmac = createHmacMethod(true);
|
|
1050
|
+
if (COMMON_JS) {
|
|
1051
|
+
module1.exports = exports2;
|
|
1052
|
+
} else {
|
|
1053
|
+
root.sha256 = exports2.sha256;
|
|
1054
|
+
root.sha224 = exports2.sha224;
|
|
1055
|
+
if (AMD) {
|
|
1056
|
+
define(function() {
|
|
1057
|
+
return exports2;
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
})();
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
// src/common/utils.ts
|
|
1065
|
+
var import_dayjs = __toESM(require_dayjs_min());
|
|
1066
|
+
// src/web-element.ts
|
|
1067
|
+
var WebElementInfo = class {
|
|
1068
|
+
constructor({ content, rect, page, locator, id, attributes, indexId }){
|
|
1069
|
+
this.content = content;
|
|
1070
|
+
this.rect = rect;
|
|
1071
|
+
this.center = [
|
|
1072
|
+
Math.floor(rect.left + rect.width / 2),
|
|
1073
|
+
Math.floor(rect.top + rect.height / 2)
|
|
1074
|
+
];
|
|
1075
|
+
this.page = page;
|
|
1076
|
+
this.locator = locator;
|
|
1077
|
+
this.id = id;
|
|
1078
|
+
this.attributes = attributes;
|
|
1079
|
+
this.indexId = indexId;
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
// src/common/utils.ts
|
|
1083
|
+
function parseContextFromWebPage(page, _opt) {
|
|
1084
|
+
return __async(this, null, function*() {
|
|
1085
|
+
(0, _assert.default)(page, "page is required");
|
|
1086
|
+
if (page._forceUsePageContext) {
|
|
1087
|
+
return yield page._forceUsePageContext();
|
|
799
1088
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
1089
|
+
const url = yield page.url();
|
|
1090
|
+
let screenshotBase64;
|
|
1091
|
+
let elementsInfo;
|
|
1092
|
+
yield Promise.all([
|
|
1093
|
+
page.screenshotBase64().then((base64)=>{
|
|
1094
|
+
screenshotBase64 = base64;
|
|
1095
|
+
}),
|
|
1096
|
+
page.getElementInfos().then((snapshot)=>__async(this, null, function*() {
|
|
1097
|
+
elementsInfo = yield alignElements(snapshot, page);
|
|
1098
|
+
}))
|
|
1099
|
+
]);
|
|
1100
|
+
(0, _assert.default)(screenshotBase64, "screenshotBase64 is required");
|
|
1101
|
+
const elementsPositionInfoWithoutText = elementsInfo.filter((elementInfo)=>{
|
|
1102
|
+
if (elementInfo.attributes.nodeType === _constants.NodeType.TEXT) {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
return true;
|
|
1106
|
+
});
|
|
1107
|
+
const size = yield page.size();
|
|
1108
|
+
const width = size.width;
|
|
1109
|
+
const height = size.height;
|
|
1110
|
+
const screenshotBase64WithElementMarker = (_opt == null ? void 0 : _opt.ignoreMarker) ? void 0 : yield (0, _img.compositeElementInfoImg)({
|
|
1111
|
+
inputImgBase64: screenshotBase64,
|
|
1112
|
+
elementsPositionInfo: elementsPositionInfoWithoutText,
|
|
1113
|
+
size: {
|
|
1114
|
+
width,
|
|
1115
|
+
height
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
return {
|
|
1119
|
+
content: elementsInfo,
|
|
1120
|
+
size: {
|
|
1121
|
+
width,
|
|
1122
|
+
height
|
|
1123
|
+
},
|
|
1124
|
+
screenshotBase64,
|
|
1125
|
+
screenshotBase64WithElementMarker,
|
|
1126
|
+
url
|
|
1127
|
+
};
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
var sizeThreshold = 3;
|
|
1131
|
+
function alignElements(elements, page) {
|
|
1132
|
+
return __async(this, null, function*() {
|
|
1133
|
+
const validElements = elements.filter((item)=>{
|
|
1134
|
+
return item.rect.height >= sizeThreshold && item.rect.width >= sizeThreshold;
|
|
1135
|
+
});
|
|
1136
|
+
const textsAligned = [];
|
|
1137
|
+
for (const item of validElements){
|
|
1138
|
+
const { rect, id, content, attributes, locator, indexId } = item;
|
|
1139
|
+
textsAligned.push(new WebElementInfo({
|
|
1140
|
+
rect,
|
|
1141
|
+
locator,
|
|
1142
|
+
id,
|
|
1143
|
+
content,
|
|
1144
|
+
attributes,
|
|
1145
|
+
page,
|
|
1146
|
+
indexId
|
|
1147
|
+
}));
|
|
812
1148
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
if (key.length > 64) {
|
|
818
|
-
key = new Sha256(is224, true).update(key).array();
|
|
819
|
-
}
|
|
820
|
-
var oKeyPad = [], iKeyPad = [];
|
|
821
|
-
for (i = 0; i < 64; ++i) {
|
|
822
|
-
var b = key[i] || 0;
|
|
823
|
-
oKeyPad[i] = 92 ^ b;
|
|
824
|
-
iKeyPad[i] = 54 ^ b;
|
|
825
|
-
}
|
|
826
|
-
Sha256.call(this, is224, sharedMemory);
|
|
827
|
-
this.update(iKeyPad);
|
|
828
|
-
this.oKeyPad = oKeyPad;
|
|
829
|
-
this.inner = true;
|
|
830
|
-
this.sharedMemory = sharedMemory;
|
|
831
|
-
}
|
|
832
|
-
HmacSha256.prototype = new Sha256();
|
|
833
|
-
HmacSha256.prototype.finalize = function() {
|
|
834
|
-
Sha256.prototype.finalize.call(this);
|
|
835
|
-
if (this.inner) {
|
|
836
|
-
this.inner = false;
|
|
837
|
-
var innerHash = this.array();
|
|
838
|
-
Sha256.call(this, this.is224, this.sharedMemory);
|
|
839
|
-
this.update(this.oKeyPad);
|
|
840
|
-
this.update(innerHash);
|
|
841
|
-
Sha256.prototype.finalize.call(this);
|
|
842
|
-
}
|
|
843
|
-
};
|
|
844
|
-
var exports2 = createMethod();
|
|
845
|
-
exports2.sha256 = exports2;
|
|
846
|
-
exports2.sha224 = createMethod(true);
|
|
847
|
-
exports2.sha256.hmac = createHmacMethod();
|
|
848
|
-
exports2.sha224.hmac = createHmacMethod(true);
|
|
849
|
-
if (COMMON_JS) {
|
|
850
|
-
module2.exports = exports2;
|
|
851
|
-
} else {
|
|
852
|
-
root.sha256 = exports2.sha256;
|
|
853
|
-
root.sha224 = exports2.sha224;
|
|
854
|
-
if (AMD) {
|
|
855
|
-
define(function() {
|
|
856
|
-
return exports2;
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
})();
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
// src/appium/index.ts
|
|
865
|
-
var appium_exports = {};
|
|
866
|
-
__export(appium_exports, {
|
|
867
|
-
AppiumAgent: () => PageAgent,
|
|
868
|
-
AppiumPage: () => Page
|
|
869
|
-
});
|
|
870
|
-
module.exports = __toCommonJS(appium_exports);
|
|
871
|
-
|
|
872
|
-
// src/common/agent.ts
|
|
873
|
-
var import_utils5 = require("@midscene/core/utils");
|
|
874
|
-
|
|
875
|
-
// src/common/tasks.ts
|
|
876
|
-
var import_node_assert2 = __toESM(require("assert"));
|
|
877
|
-
var import_core = require("@midscene/core");
|
|
878
|
-
var import_utils3 = require("@midscene/core/utils");
|
|
879
|
-
var import_img3 = require("@midscene/shared/img");
|
|
880
|
-
|
|
881
|
-
// src/common/task-cache.ts
|
|
882
|
-
var import_node_fs2 = require("fs");
|
|
883
|
-
var import_node_path2 = require("path");
|
|
884
|
-
var import_utils = require("@midscene/core/utils");
|
|
885
|
-
var import_fs2 = require("@midscene/shared/fs");
|
|
886
|
-
|
|
887
|
-
// src/common/utils.ts
|
|
888
|
-
var import_node_assert = __toESM(require("assert"));
|
|
889
|
-
var import_node_crypto = require("crypto");
|
|
890
|
-
var import_node_fs = require("fs");
|
|
891
|
-
var import_node_path = __toESM(require("path"));
|
|
892
|
-
var import_constants = require("@midscene/shared/constants");
|
|
893
|
-
var import_fs = require("@midscene/shared/fs");
|
|
894
|
-
var import_img = require("@midscene/shared/img");
|
|
895
|
-
var import_img2 = require("@midscene/shared/img");
|
|
896
|
-
var import_dayjs = __toESM(require_dayjs_min());
|
|
897
|
-
|
|
898
|
-
// src/web-element.ts
|
|
899
|
-
var WebElementInfo = class {
|
|
900
|
-
constructor({
|
|
901
|
-
content,
|
|
902
|
-
rect,
|
|
903
|
-
page,
|
|
904
|
-
locator,
|
|
905
|
-
id,
|
|
906
|
-
attributes,
|
|
907
|
-
indexId
|
|
908
|
-
}) {
|
|
909
|
-
this.content = content;
|
|
910
|
-
this.rect = rect;
|
|
911
|
-
this.center = [
|
|
912
|
-
Math.floor(rect.left + rect.width / 2),
|
|
913
|
-
Math.floor(rect.top + rect.height / 2)
|
|
914
|
-
];
|
|
915
|
-
this.page = page;
|
|
916
|
-
this.locator = locator;
|
|
917
|
-
this.id = id;
|
|
918
|
-
this.attributes = attributes;
|
|
919
|
-
this.indexId = indexId;
|
|
920
|
-
}
|
|
921
|
-
};
|
|
922
|
-
|
|
923
|
-
// src/common/utils.ts
|
|
924
|
-
async function parseContextFromWebPage(page, _opt) {
|
|
925
|
-
(0, import_node_assert.default)(page, "page is required");
|
|
926
|
-
if (page._forceUsePageContext) {
|
|
927
|
-
return await page._forceUsePageContext();
|
|
928
|
-
}
|
|
929
|
-
const url = page.url();
|
|
930
|
-
const file = await page.screenshot();
|
|
931
|
-
const screenshotBase64 = (0, import_img.base64Encoded)(file);
|
|
932
|
-
const captureElementSnapshot = await page.getElementInfos();
|
|
933
|
-
const elementsInfo = await alignElements(captureElementSnapshot, page);
|
|
934
|
-
const elementsPositionInfoWithoutText = elementsInfo.filter((elementInfo) => {
|
|
935
|
-
if (elementInfo.attributes.nodeType === import_constants.NodeType.TEXT) {
|
|
936
|
-
return false;
|
|
1149
|
+
return textsAligned;
|
|
1150
|
+
});
|
|
937
1151
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
const screenshotBase64WithElementMarker = await (0, import_img2.compositeElementInfoImg)({
|
|
942
|
-
inputImgBase64: screenshotBase64.split(";base64,").pop(),
|
|
943
|
-
elementsPositionInfo: elementsPositionInfoWithoutText
|
|
944
|
-
});
|
|
945
|
-
return {
|
|
946
|
-
content: elementsInfo,
|
|
947
|
-
size,
|
|
948
|
-
screenshotBase64,
|
|
949
|
-
screenshotBase64WithElementMarker: `data:image/png;base64,${screenshotBase64WithElementMarker}`,
|
|
950
|
-
url
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
var sizeThreshold = 3;
|
|
954
|
-
async function alignElements(elements, page) {
|
|
955
|
-
const validElements = elements.filter((item) => {
|
|
956
|
-
return item.rect.height >= sizeThreshold && item.rect.width >= sizeThreshold;
|
|
957
|
-
});
|
|
958
|
-
const textsAligned = [];
|
|
959
|
-
for (const item of validElements) {
|
|
960
|
-
const { rect, id, content, attributes, locator, indexId } = item;
|
|
961
|
-
textsAligned.push(
|
|
962
|
-
new WebElementInfo({
|
|
963
|
-
rect,
|
|
964
|
-
locator,
|
|
965
|
-
id,
|
|
966
|
-
content,
|
|
967
|
-
attributes,
|
|
968
|
-
page,
|
|
969
|
-
indexId
|
|
970
|
-
})
|
|
971
|
-
);
|
|
972
|
-
}
|
|
973
|
-
return textsAligned;
|
|
974
|
-
}
|
|
975
|
-
function reportFileName(tag = "web") {
|
|
976
|
-
const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
|
|
977
|
-
return `${tag}-${dateTimeInFileName}`;
|
|
978
|
-
}
|
|
979
|
-
function printReportMsg(filepath) {
|
|
980
|
-
console.log("Midscene - report file updated:", filepath);
|
|
981
|
-
}
|
|
982
|
-
function getCurrentExecutionFile(trace) {
|
|
983
|
-
const error = new Error();
|
|
984
|
-
const stackTrace = trace || error.stack;
|
|
985
|
-
const pkgDir = process.cwd() || "";
|
|
986
|
-
if (stackTrace) {
|
|
987
|
-
const stackLines = stackTrace.split("\n");
|
|
988
|
-
for (const line of stackLines) {
|
|
989
|
-
if (line.includes(".spec.") || line.includes(".test.") || line.includes(".ts") || line.includes(".js")) {
|
|
990
|
-
const match = line.match(/(?:at\s+)?(.*?\.(?:spec|test)\.[jt]s)/);
|
|
991
|
-
if (match == null ? void 0 : match[1]) {
|
|
992
|
-
const targetFileName = match[1].replace(pkgDir, "").trim().replace("at ", "");
|
|
993
|
-
return targetFileName;
|
|
994
|
-
}
|
|
995
|
-
}
|
|
1152
|
+
function reportFileName(tag = "web") {
|
|
1153
|
+
const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
|
|
1154
|
+
return `${tag}-${dateTimeInFileName}`;
|
|
996
1155
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
}
|
|
1000
|
-
var testFileIndex = /* @__PURE__ */ new Map();
|
|
1001
|
-
function generateCacheId(fileName) {
|
|
1002
|
-
let taskFile = fileName || getCurrentExecutionFile();
|
|
1003
|
-
if (!taskFile) {
|
|
1004
|
-
taskFile = (0, import_node_crypto.randomUUID)();
|
|
1005
|
-
console.warn(
|
|
1006
|
-
"Midscene - using random UUID for cache id. Cache may be invalid."
|
|
1007
|
-
);
|
|
1008
|
-
}
|
|
1009
|
-
if (testFileIndex.has(taskFile)) {
|
|
1010
|
-
const currentIndex = testFileIndex.get(taskFile);
|
|
1011
|
-
if (currentIndex !== void 0) {
|
|
1012
|
-
testFileIndex.set(taskFile, currentIndex + 1);
|
|
1156
|
+
function printReportMsg(filepath) {
|
|
1157
|
+
console.log("Midscene - report file updated:", filepath);
|
|
1013
1158
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
getCacheGroupByPrompt(aiActionPrompt) {
|
|
1033
|
-
const { aiTasks = [] } = this.cache || { aiTasks: [] };
|
|
1034
|
-
const index = aiTasks.findIndex((item) => item.prompt === aiActionPrompt);
|
|
1035
|
-
const newCacheGroup = [];
|
|
1036
|
-
this.newCache.aiTasks.push({
|
|
1037
|
-
prompt: aiActionPrompt,
|
|
1038
|
-
tasks: newCacheGroup
|
|
1039
|
-
});
|
|
1040
|
-
return {
|
|
1041
|
-
readCache: (pageContext, type, actionPrompt) => {
|
|
1042
|
-
if (index === -1) {
|
|
1043
|
-
return false;
|
|
1044
|
-
}
|
|
1045
|
-
if (type === "plan") {
|
|
1046
|
-
return this.readCache(
|
|
1047
|
-
pageContext,
|
|
1048
|
-
type,
|
|
1049
|
-
actionPrompt,
|
|
1050
|
-
aiTasks[index].tasks
|
|
1051
|
-
);
|
|
1052
|
-
}
|
|
1053
|
-
return this.readCache(
|
|
1054
|
-
pageContext,
|
|
1055
|
-
type,
|
|
1056
|
-
actionPrompt,
|
|
1057
|
-
aiTasks[index].tasks
|
|
1058
|
-
);
|
|
1059
|
-
},
|
|
1060
|
-
saveCache: (cache) => {
|
|
1061
|
-
newCacheGroup.push(cache);
|
|
1062
|
-
this.writeCacheToFile();
|
|
1063
|
-
}
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
readCache(pageContext, type, userPrompt, cacheGroup) {
|
|
1067
|
-
var _a;
|
|
1068
|
-
if (cacheGroup.length > 0) {
|
|
1069
|
-
const index = cacheGroup.findIndex((item) => item.prompt === userPrompt);
|
|
1070
|
-
if (index === -1) {
|
|
1071
|
-
return false;
|
|
1072
|
-
}
|
|
1073
|
-
const taskRes = cacheGroup.splice(index, 1)[0];
|
|
1074
|
-
if ((taskRes == null ? void 0 : taskRes.type) === "locate" && !((_a = taskRes.response) == null ? void 0 : _a.elements.every((element) => {
|
|
1075
|
-
const findIndex = pageContext.content.findIndex(
|
|
1076
|
-
(contentElement) => contentElement.id === element.id
|
|
1077
|
-
);
|
|
1078
|
-
if (findIndex === -1) {
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1081
|
-
return true;
|
|
1082
|
-
}))) {
|
|
1159
|
+
function getCurrentExecutionFile(trace) {
|
|
1160
|
+
const error = new Error();
|
|
1161
|
+
const stackTrace = trace || error.stack;
|
|
1162
|
+
const pkgDir = process.cwd() || "";
|
|
1163
|
+
if (stackTrace) {
|
|
1164
|
+
const stackLines = stackTrace.split("\n");
|
|
1165
|
+
for (const line of stackLines){
|
|
1166
|
+
if (line.includes(".spec.") || line.includes(".test.") || line.includes(".ts") || line.includes(".js")) {
|
|
1167
|
+
const match = line.match(/(?:at\s+)?(.*?\.(?:spec|test)\.[jt]s)/);
|
|
1168
|
+
if (match == null ? void 0 : match[1]) {
|
|
1169
|
+
const targetFileName = match[1].replace(pkgDir, "").trim().replace("at ", "");
|
|
1170
|
+
return targetFileName;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1083
1175
|
return false;
|
|
1084
|
-
}
|
|
1085
|
-
if (taskRes && taskRes.type === type && taskRes.prompt === userPrompt && this.pageContextEqual(taskRes.pageContext, pageContext)) {
|
|
1086
|
-
return taskRes.response;
|
|
1087
|
-
}
|
|
1088
1176
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1177
|
+
var testFileIndex = /* @__PURE__ */ new Map();
|
|
1178
|
+
function generateCacheId(fileName) {
|
|
1179
|
+
let taskFile = fileName || getCurrentExecutionFile();
|
|
1180
|
+
if (!taskFile) {
|
|
1181
|
+
taskFile = (0, _utils1.uuid)();
|
|
1182
|
+
console.warn("Midscene - using random UUID for cache id. Cache may be invalid.");
|
|
1183
|
+
}
|
|
1184
|
+
if (testFileIndex.has(taskFile)) {
|
|
1185
|
+
const currentIndex = testFileIndex.get(taskFile);
|
|
1186
|
+
if (currentIndex !== void 0) {
|
|
1187
|
+
testFileIndex.set(taskFile, currentIndex + 1);
|
|
1188
|
+
}
|
|
1189
|
+
} else {
|
|
1190
|
+
testFileIndex.set(taskFile, 1);
|
|
1191
|
+
}
|
|
1192
|
+
return `${taskFile}-${testFileIndex.get(taskFile)}`;
|
|
1193
|
+
}
|
|
1194
|
+
// src/common/task-cache.ts
|
|
1195
|
+
var TaskCache = class {
|
|
1196
|
+
getCacheGroupByPrompt(aiActionPrompt) {
|
|
1197
|
+
const { aiTasks = [] } = this.cache || {
|
|
1198
|
+
aiTasks: []
|
|
1199
|
+
};
|
|
1200
|
+
const index = aiTasks.findIndex((item)=>item.prompt === aiActionPrompt);
|
|
1201
|
+
const newCacheGroup = [];
|
|
1202
|
+
this.newCache.aiTasks.push({
|
|
1203
|
+
prompt: aiActionPrompt,
|
|
1204
|
+
tasks: newCacheGroup
|
|
1205
|
+
});
|
|
1206
|
+
return {
|
|
1207
|
+
readCache: (pageContext, type, actionPrompt)=>{
|
|
1208
|
+
if (index === -1) {
|
|
1209
|
+
return false;
|
|
1210
|
+
}
|
|
1211
|
+
if (type === "plan") {
|
|
1212
|
+
return this.readCache(pageContext, type, actionPrompt, aiTasks[index].tasks);
|
|
1213
|
+
}
|
|
1214
|
+
return this.readCache(pageContext, type, actionPrompt, aiTasks[index].tasks);
|
|
1215
|
+
},
|
|
1216
|
+
saveCache: (cache)=>{
|
|
1217
|
+
newCacheGroup.push(cache);
|
|
1218
|
+
this.writeCacheToFile();
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
readCache(pageContext, type, userPrompt, cacheGroup) {
|
|
1223
|
+
var _a;
|
|
1224
|
+
if (cacheGroup.length > 0) {
|
|
1225
|
+
const index = cacheGroup.findIndex((item)=>item.prompt === userPrompt);
|
|
1226
|
+
if (index === -1) {
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
const taskRes = cacheGroup.splice(index, 1)[0];
|
|
1230
|
+
if ((taskRes == null ? void 0 : taskRes.type) === "locate" && !((_a = taskRes.response) == null ? void 0 : _a.elements.every((element)=>{
|
|
1231
|
+
const findIndex = pageContext.content.findIndex((contentElement)=>contentElement.id === element.id);
|
|
1232
|
+
if (findIndex === -1) {
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
return true;
|
|
1236
|
+
}))) {
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
if (taskRes && taskRes.type === type && taskRes.prompt === userPrompt && this.pageContextEqual(taskRes.pageContext, pageContext)) {
|
|
1240
|
+
return taskRes.response;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
return false;
|
|
1244
|
+
}
|
|
1245
|
+
pageContextEqual(taskPageContext, pageContext) {
|
|
1246
|
+
return taskPageContext.size.width === pageContext.size.width && taskPageContext.size.height === pageContext.size.height;
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1095
1249
|
* Generate task cache data.
|
|
1096
1250
|
* This method is mainly used to create or obtain some cached data for tasks, and it returns a new cache object.
|
|
1097
1251
|
* In the cache object, it may contain task-related information, states, or other necessary data.
|
|
1098
1252
|
* It is assumed that the `newCache` property already exists in the current class or object and is a data structure used to store task cache.
|
|
1099
1253
|
* @returns {Object} Returns a new cache object, which may include task cache data.
|
|
1100
|
-
*/
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
const midscenePkgInfo = (0, import_fs2.getMidscenePkgInfo)(__dirname);
|
|
1122
|
-
(0, import_utils.writeLogFile)({
|
|
1123
|
-
fileName: `${this.cacheId}`,
|
|
1124
|
-
fileExt: "json",
|
|
1125
|
-
fileContent: (0, import_utils.stringifyDumpData)(
|
|
1126
|
-
__spreadValues({
|
|
1127
|
-
pkgName: midscenePkgInfo.name,
|
|
1128
|
-
pkgVersion: midscenePkgInfo.version,
|
|
1129
|
-
cacheId: this.cacheId
|
|
1130
|
-
}, this.newCache),
|
|
1131
|
-
2
|
|
1132
|
-
),
|
|
1133
|
-
type: "cache"
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
1137
|
-
|
|
1138
|
-
// src/common/tasks.ts
|
|
1139
|
-
var PageTaskExecutor = class {
|
|
1140
|
-
constructor(page, opts) {
|
|
1141
|
-
this.page = page;
|
|
1142
|
-
this.insight = new import_core.Insight(async () => {
|
|
1143
|
-
return await parseContextFromWebPage(page);
|
|
1144
|
-
});
|
|
1145
|
-
this.taskCache = new TaskCache({
|
|
1146
|
-
fileName: opts == null ? void 0 : opts.cacheId
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
async recordScreenshot(timing) {
|
|
1150
|
-
const file = await this.page.screenshot();
|
|
1151
|
-
const item = {
|
|
1152
|
-
type: "screenshot",
|
|
1153
|
-
ts: Date.now(),
|
|
1154
|
-
screenshot: (0, import_img3.base64Encoded)(file),
|
|
1155
|
-
timing
|
|
1156
|
-
};
|
|
1157
|
-
return item;
|
|
1158
|
-
}
|
|
1159
|
-
wrapExecutorWithScreenshot(taskApply) {
|
|
1160
|
-
const taskWithScreenshot = __spreadProps(__spreadValues({}, taskApply), {
|
|
1161
|
-
executor: async (param, context, ...args) => {
|
|
1162
|
-
const recorder = [];
|
|
1163
|
-
const { task } = context;
|
|
1164
|
-
task.recorder = recorder;
|
|
1165
|
-
const shot = await this.recordScreenshot(`before ${task.type}`);
|
|
1166
|
-
recorder.push(shot);
|
|
1167
|
-
const result = await taskApply.executor(param, context, ...args);
|
|
1168
|
-
if (taskApply.type === "Action") {
|
|
1169
|
-
await (0, import_utils3.sleep)(1e3);
|
|
1170
|
-
const shot2 = await this.recordScreenshot("after Action");
|
|
1171
|
-
recorder.push(shot2);
|
|
1172
|
-
}
|
|
1173
|
-
return result;
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
return taskWithScreenshot;
|
|
1177
|
-
}
|
|
1178
|
-
async convertPlanToExecutable(plans, cacheGroup) {
|
|
1179
|
-
const tasks = plans.map((plan2) => {
|
|
1180
|
-
if (plan2.type === "Locate") {
|
|
1181
|
-
const taskFind = {
|
|
1182
|
-
type: "Insight",
|
|
1183
|
-
subType: "Locate",
|
|
1184
|
-
param: plan2.param,
|
|
1185
|
-
executor: async (param, taskContext) => {
|
|
1186
|
-
const { task } = taskContext;
|
|
1187
|
-
let insightDump;
|
|
1188
|
-
const dumpCollector = (dump) => {
|
|
1189
|
-
insightDump = dump;
|
|
1190
|
-
};
|
|
1191
|
-
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1192
|
-
const pageContext = await this.insight.contextRetrieverFn();
|
|
1193
|
-
const locateCache = cacheGroup == null ? void 0 : cacheGroup.readCache(
|
|
1194
|
-
pageContext,
|
|
1195
|
-
"locate",
|
|
1196
|
-
param.prompt
|
|
1197
|
-
);
|
|
1198
|
-
let locateResult;
|
|
1199
|
-
const callAI = this.insight.aiVendorFn;
|
|
1200
|
-
const element = await this.insight.locate(param.prompt, {
|
|
1201
|
-
quickAnswer: plan2.quickAnswer,
|
|
1202
|
-
callAI: async (...message) => {
|
|
1203
|
-
if (locateCache) {
|
|
1204
|
-
locateResult = locateCache;
|
|
1205
|
-
return Promise.resolve(locateCache);
|
|
1254
|
+
*/ generateTaskCache() {
|
|
1255
|
+
return this.newCache;
|
|
1256
|
+
}
|
|
1257
|
+
readCacheFromFile() {
|
|
1258
|
+
if (_utils1.ifInBrowser) {
|
|
1259
|
+
return void 0;
|
|
1260
|
+
}
|
|
1261
|
+
const cacheFile = (0, _path.join)((0, _utils.getLogDirByType)("cache"), `${this.cacheId}.json`);
|
|
1262
|
+
if (process.env.MIDSCENE_CACHE === "true" && (0, _fs.existsSync)(cacheFile)) {
|
|
1263
|
+
try {
|
|
1264
|
+
const data = (0, _fs.readFileSync)(cacheFile, "utf8");
|
|
1265
|
+
const jsonData = JSON.parse(data);
|
|
1266
|
+
if (!this.midscenePkgInfo) {
|
|
1267
|
+
return void 0;
|
|
1268
|
+
}
|
|
1269
|
+
if (jsonData.pkgName !== this.midscenePkgInfo.name || jsonData.pkgVersion !== this.midscenePkgInfo.version) {
|
|
1270
|
+
return void 0;
|
|
1271
|
+
}
|
|
1272
|
+
return jsonData;
|
|
1273
|
+
} catch (err) {
|
|
1274
|
+
return void 0;
|
|
1206
1275
|
}
|
|
1207
|
-
locateResult = await callAI(...message);
|
|
1208
|
-
(0, import_node_assert2.default)(locateResult);
|
|
1209
|
-
return locateResult;
|
|
1210
|
-
}
|
|
1211
|
-
});
|
|
1212
|
-
if (locateResult) {
|
|
1213
|
-
cacheGroup == null ? void 0 : cacheGroup.saveCache({
|
|
1214
|
-
type: "locate",
|
|
1215
|
-
pageContext: {
|
|
1216
|
-
url: pageContext.url,
|
|
1217
|
-
size: pageContext.size
|
|
1218
|
-
},
|
|
1219
|
-
prompt: param.prompt,
|
|
1220
|
-
response: locateResult
|
|
1221
|
-
});
|
|
1222
1276
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1277
|
+
return void 0;
|
|
1278
|
+
}
|
|
1279
|
+
writeCacheToFile() {
|
|
1280
|
+
const midscenePkgInfo = (0, _fs1.getRunningPkgInfo)();
|
|
1281
|
+
if (!midscenePkgInfo) {
|
|
1282
|
+
return;
|
|
1228
1283
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1284
|
+
if (!_utils1.ifInBrowser) {
|
|
1285
|
+
(0, _utils.writeLogFile)({
|
|
1286
|
+
fileName: `${this.cacheId}`,
|
|
1287
|
+
fileExt: "json",
|
|
1288
|
+
fileContent: (0, _utils.stringifyDumpData)(__spreadValues({
|
|
1289
|
+
pkgName: midscenePkgInfo.name,
|
|
1290
|
+
pkgVersion: midscenePkgInfo.version,
|
|
1291
|
+
cacheId: this.cacheId
|
|
1292
|
+
}, this.newCache), 2),
|
|
1293
|
+
type: "cache"
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
constructor(opts){
|
|
1298
|
+
this.midscenePkgInfo = (0, _fs1.getRunningPkgInfo)();
|
|
1299
|
+
this.cacheId = generateCacheId(opts == null ? void 0 : opts.fileName);
|
|
1300
|
+
this.cache = this.readCacheFromFile() || {
|
|
1301
|
+
aiTasks: []
|
|
1239
1302
|
};
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
return taskFind;
|
|
1243
|
-
}
|
|
1244
|
-
if (plan2.type === "Assert" || plan2.type === "AssertWithoutThrow") {
|
|
1245
|
-
const assertPlan = plan2;
|
|
1246
|
-
const taskAssert = {
|
|
1247
|
-
type: "Insight",
|
|
1248
|
-
subType: "Assert",
|
|
1249
|
-
param: assertPlan.param,
|
|
1250
|
-
executor: async (param, taskContext) => {
|
|
1251
|
-
const { task } = taskContext;
|
|
1252
|
-
let insightDump;
|
|
1253
|
-
const dumpCollector = (dump) => {
|
|
1254
|
-
insightDump = dump;
|
|
1303
|
+
this.newCache = {
|
|
1304
|
+
aiTasks: []
|
|
1255
1305
|
};
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
// src/common/tasks.ts
|
|
1309
|
+
var PageTaskExecutor = class {
|
|
1310
|
+
recordScreenshot(timing) {
|
|
1311
|
+
return __async(this, null, function*() {
|
|
1312
|
+
const base64 = yield this.page.screenshotBase64();
|
|
1313
|
+
const item = {
|
|
1314
|
+
type: "screenshot",
|
|
1315
|
+
ts: Date.now(),
|
|
1316
|
+
screenshot: base64,
|
|
1317
|
+
timing
|
|
1265
1318
|
};
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1319
|
+
return item;
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
wrapExecutorWithScreenshot(taskApply) {
|
|
1323
|
+
const taskWithScreenshot = __spreadProps(__spreadValues({}, taskApply), {
|
|
1324
|
+
executor: (param, context, ...args)=>__async(this, null, function*() {
|
|
1325
|
+
const recorder = [];
|
|
1326
|
+
const { task } = context;
|
|
1327
|
+
task.recorder = recorder;
|
|
1328
|
+
const shot = yield this.recordScreenshot(`before ${task.type}`);
|
|
1329
|
+
recorder.push(shot);
|
|
1330
|
+
const result = yield taskApply.executor(param, context, ...args);
|
|
1331
|
+
if (taskApply.type === "Action") {
|
|
1332
|
+
yield (0, _utils.sleep)(1e3);
|
|
1333
|
+
const shot2 = yield this.recordScreenshot("after Action");
|
|
1334
|
+
recorder.push(shot2);
|
|
1335
|
+
}
|
|
1336
|
+
return result;
|
|
1337
|
+
})
|
|
1338
|
+
});
|
|
1339
|
+
return taskWithScreenshot;
|
|
1340
|
+
}
|
|
1341
|
+
convertPlanToExecutable(plans, cacheGroup) {
|
|
1342
|
+
return __async(this, null, function*() {
|
|
1343
|
+
const tasks = plans.map((plan2)=>{
|
|
1344
|
+
if (plan2.type === "Locate") {
|
|
1345
|
+
const taskFind = {
|
|
1346
|
+
type: "Insight",
|
|
1347
|
+
subType: "Locate",
|
|
1348
|
+
param: plan2.param,
|
|
1349
|
+
quickAnswer: plan2.quickAnswer,
|
|
1350
|
+
executor: (param, taskContext)=>__async(this, null, function*() {
|
|
1351
|
+
const { task } = taskContext;
|
|
1352
|
+
let insightDump;
|
|
1353
|
+
const dumpCollector = (dump)=>{
|
|
1354
|
+
insightDump = dump;
|
|
1355
|
+
};
|
|
1356
|
+
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1357
|
+
const pageContext = yield this.insight.contextRetrieverFn();
|
|
1358
|
+
const locateCache = cacheGroup == null ? void 0 : cacheGroup.readCache(pageContext, "locate", param.prompt);
|
|
1359
|
+
let locateResult;
|
|
1360
|
+
const callAI = this.insight.aiVendorFn;
|
|
1361
|
+
const element = yield this.insight.locate(param.prompt, {
|
|
1362
|
+
quickAnswer: task.quickAnswer,
|
|
1363
|
+
callAI: (...message)=>__async(this, null, function*() {
|
|
1364
|
+
if (locateCache) {
|
|
1365
|
+
locateResult = locateCache;
|
|
1366
|
+
return Promise.resolve(locateCache);
|
|
1367
|
+
}
|
|
1368
|
+
const aiResult = yield callAI(...message);
|
|
1369
|
+
locateResult = (0, _core.transformElementPositionToId)(aiResult, pageContext.content);
|
|
1370
|
+
(0, _assert.default)(locateResult);
|
|
1371
|
+
return locateResult;
|
|
1372
|
+
})
|
|
1373
|
+
});
|
|
1374
|
+
if (locateResult) {
|
|
1375
|
+
cacheGroup == null ? void 0 : cacheGroup.saveCache({
|
|
1376
|
+
type: "locate",
|
|
1377
|
+
pageContext: {
|
|
1378
|
+
url: pageContext.url,
|
|
1379
|
+
size: pageContext.size
|
|
1380
|
+
},
|
|
1381
|
+
prompt: param.prompt,
|
|
1382
|
+
response: locateResult
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
if (!element) {
|
|
1386
|
+
task.log = {
|
|
1387
|
+
dump: insightDump
|
|
1388
|
+
};
|
|
1389
|
+
throw new Error(`Element not found: ${param.prompt}`);
|
|
1390
|
+
}
|
|
1391
|
+
return {
|
|
1392
|
+
output: {
|
|
1393
|
+
element
|
|
1394
|
+
},
|
|
1395
|
+
log: {
|
|
1396
|
+
dump: insightDump
|
|
1397
|
+
},
|
|
1398
|
+
cache: {
|
|
1399
|
+
hit: Boolean(locateCache)
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
})
|
|
1403
|
+
};
|
|
1404
|
+
return taskFind;
|
|
1405
|
+
}
|
|
1406
|
+
if (plan2.type === "Assert" || plan2.type === "AssertWithoutThrow") {
|
|
1407
|
+
const assertPlan = plan2;
|
|
1408
|
+
const taskAssert = {
|
|
1409
|
+
type: "Insight",
|
|
1410
|
+
subType: "Assert",
|
|
1411
|
+
param: assertPlan.param,
|
|
1412
|
+
executor: (param, taskContext)=>__async(this, null, function*() {
|
|
1413
|
+
const { task } = taskContext;
|
|
1414
|
+
let insightDump;
|
|
1415
|
+
const dumpCollector = (dump)=>{
|
|
1416
|
+
insightDump = dump;
|
|
1417
|
+
};
|
|
1418
|
+
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1419
|
+
const assertion = yield this.insight.assert(assertPlan.param.assertion);
|
|
1420
|
+
if (!assertion.pass) {
|
|
1421
|
+
if (plan2.type === "Assert") {
|
|
1422
|
+
task.output = assertion;
|
|
1423
|
+
task.log = {
|
|
1424
|
+
dump: insightDump
|
|
1425
|
+
};
|
|
1426
|
+
throw new Error(assertion.thought || "Assertion failed without reason");
|
|
1427
|
+
}
|
|
1428
|
+
task.error = assertion.thought;
|
|
1429
|
+
}
|
|
1430
|
+
return {
|
|
1431
|
+
output: assertion,
|
|
1432
|
+
log: {
|
|
1433
|
+
dump: insightDump
|
|
1434
|
+
}
|
|
1435
|
+
};
|
|
1436
|
+
})
|
|
1437
|
+
};
|
|
1438
|
+
return taskAssert;
|
|
1439
|
+
}
|
|
1440
|
+
if (plan2.type === "Input") {
|
|
1441
|
+
const taskActionInput = {
|
|
1442
|
+
type: "Action",
|
|
1443
|
+
subType: "Input",
|
|
1444
|
+
param: plan2.param,
|
|
1445
|
+
executor: (_0, _1)=>__async(this, [
|
|
1446
|
+
_0,
|
|
1447
|
+
_1
|
|
1448
|
+
], function*(taskParam, { element }) {
|
|
1449
|
+
if (element) {
|
|
1450
|
+
yield this.page.clearInput(element);
|
|
1451
|
+
if (taskParam.value === "") {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
yield this.page.keyboard.type(taskParam.value);
|
|
1455
|
+
}
|
|
1456
|
+
})
|
|
1457
|
+
};
|
|
1458
|
+
return taskActionInput;
|
|
1459
|
+
}
|
|
1460
|
+
if (plan2.type === "KeyboardPress") {
|
|
1461
|
+
const taskActionKeyboardPress = {
|
|
1462
|
+
type: "Action",
|
|
1463
|
+
subType: "KeyboardPress",
|
|
1464
|
+
param: plan2.param,
|
|
1465
|
+
executor: (taskParam)=>__async(this, null, function*() {
|
|
1466
|
+
(0, _assert.default)(taskParam.value, "No key to press");
|
|
1467
|
+
yield this.page.keyboard.press(taskParam.value);
|
|
1468
|
+
})
|
|
1469
|
+
};
|
|
1470
|
+
return taskActionKeyboardPress;
|
|
1471
|
+
}
|
|
1472
|
+
if (plan2.type === "Tap") {
|
|
1473
|
+
const taskActionTap = {
|
|
1474
|
+
type: "Action",
|
|
1475
|
+
subType: "Tap",
|
|
1476
|
+
executor: (_0, _1)=>__async(this, [
|
|
1477
|
+
_0,
|
|
1478
|
+
_1
|
|
1479
|
+
], function*(param, { element }) {
|
|
1480
|
+
(0, _assert.default)(element, "Element not found, cannot tap");
|
|
1481
|
+
yield this.page.mouse.click(element.center[0], element.center[1]);
|
|
1482
|
+
})
|
|
1483
|
+
};
|
|
1484
|
+
return taskActionTap;
|
|
1485
|
+
}
|
|
1486
|
+
if (plan2.type === "Hover") {
|
|
1487
|
+
const taskActionHover = {
|
|
1488
|
+
type: "Action",
|
|
1489
|
+
subType: "Hover",
|
|
1490
|
+
executor: (_0, _1)=>__async(this, [
|
|
1491
|
+
_0,
|
|
1492
|
+
_1
|
|
1493
|
+
], function*(param, { element }) {
|
|
1494
|
+
(0, _assert.default)(element, "Element not found, cannot hover");
|
|
1495
|
+
yield this.page.mouse.move(element.center[0], element.center[1]);
|
|
1496
|
+
})
|
|
1497
|
+
};
|
|
1498
|
+
return taskActionHover;
|
|
1499
|
+
}
|
|
1500
|
+
if (plan2.type === "Scroll") {
|
|
1501
|
+
const taskActionScroll = {
|
|
1502
|
+
type: "Action",
|
|
1503
|
+
subType: "Scroll",
|
|
1504
|
+
param: plan2.param,
|
|
1505
|
+
executor: (taskParam)=>__async(this, null, function*() {
|
|
1506
|
+
const scrollToEventName = taskParam.scrollType;
|
|
1507
|
+
switch(scrollToEventName){
|
|
1508
|
+
case "scrollUntilTop":
|
|
1509
|
+
yield this.page.scrollUntilTop();
|
|
1510
|
+
break;
|
|
1511
|
+
case "scrollUntilBottom":
|
|
1512
|
+
yield this.page.scrollUntilBottom();
|
|
1513
|
+
break;
|
|
1514
|
+
case "scrollUpOneScreen":
|
|
1515
|
+
yield this.page.scrollUpOneScreen();
|
|
1516
|
+
break;
|
|
1517
|
+
case "scrollDownOneScreen":
|
|
1518
|
+
yield this.page.scrollDownOneScreen();
|
|
1519
|
+
break;
|
|
1520
|
+
default:
|
|
1521
|
+
console.error("Unknown scroll event type:", scrollToEventName);
|
|
1522
|
+
}
|
|
1523
|
+
})
|
|
1524
|
+
};
|
|
1525
|
+
return taskActionScroll;
|
|
1526
|
+
}
|
|
1527
|
+
if (plan2.type === "Sleep") {
|
|
1528
|
+
const taskActionSleep = {
|
|
1529
|
+
type: "Action",
|
|
1530
|
+
subType: "Sleep",
|
|
1531
|
+
param: plan2.param,
|
|
1532
|
+
executor: (taskParam)=>__async(this, null, function*() {
|
|
1533
|
+
yield (0, _utils.sleep)(taskParam.timeMs || 3e3);
|
|
1534
|
+
})
|
|
1535
|
+
};
|
|
1536
|
+
return taskActionSleep;
|
|
1537
|
+
}
|
|
1538
|
+
if (plan2.type === "Error") {
|
|
1539
|
+
const taskActionError = {
|
|
1540
|
+
type: "Action",
|
|
1541
|
+
subType: "Error",
|
|
1542
|
+
param: plan2.param,
|
|
1543
|
+
executor: (taskParam)=>__async(this, null, function*() {
|
|
1544
|
+
(0, _assert.default)(taskParam.thought, "An error occurred, but no thought provided");
|
|
1545
|
+
throw new Error(taskParam.thought);
|
|
1546
|
+
})
|
|
1547
|
+
};
|
|
1548
|
+
return taskActionError;
|
|
1549
|
+
}
|
|
1550
|
+
throw new Error(`Unknown or Unsupported task type: ${plan2.type}`);
|
|
1551
|
+
}).map((task)=>{
|
|
1552
|
+
return this.wrapExecutorWithScreenshot(task);
|
|
1553
|
+
});
|
|
1554
|
+
return tasks;
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
action(userPrompt) {
|
|
1558
|
+
return __async(this, null, function*() {
|
|
1559
|
+
const taskExecutor = new _core.Executor(userPrompt);
|
|
1560
|
+
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
1561
|
+
let plans = [];
|
|
1562
|
+
const planningTask = {
|
|
1563
|
+
type: "Planning",
|
|
1564
|
+
param: {
|
|
1565
|
+
userPrompt
|
|
1566
|
+
},
|
|
1567
|
+
executor: (param)=>__async(this, null, function*() {
|
|
1568
|
+
const pageContext = yield this.insight.contextRetrieverFn();
|
|
1569
|
+
let planResult;
|
|
1570
|
+
const planCache = cacheGroup.readCache(pageContext, "plan", userPrompt);
|
|
1571
|
+
if (planCache) {
|
|
1572
|
+
planResult = planCache;
|
|
1573
|
+
} else {
|
|
1574
|
+
planResult = yield (0, _core.plan)(param.userPrompt, {
|
|
1575
|
+
context: pageContext
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
(0, _assert.default)(planResult.plans.length > 0, "No plans found");
|
|
1579
|
+
plans = planResult.plans;
|
|
1580
|
+
cacheGroup.saveCache({
|
|
1581
|
+
type: "plan",
|
|
1582
|
+
pageContext: {
|
|
1583
|
+
url: pageContext.url,
|
|
1584
|
+
size: pageContext.size
|
|
1585
|
+
},
|
|
1586
|
+
prompt: userPrompt,
|
|
1587
|
+
response: planResult
|
|
1588
|
+
});
|
|
1589
|
+
return {
|
|
1590
|
+
output: planResult,
|
|
1591
|
+
pageContext,
|
|
1592
|
+
cache: {
|
|
1593
|
+
hit: Boolean(planCache)
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
})
|
|
1597
|
+
};
|
|
1598
|
+
yield taskExecutor.append(this.wrapExecutorWithScreenshot(planningTask));
|
|
1599
|
+
let output = yield taskExecutor.flush();
|
|
1600
|
+
if (taskExecutor.isInErrorState()) {
|
|
1601
|
+
return {
|
|
1602
|
+
output,
|
|
1603
|
+
executor: taskExecutor
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
const executables = yield this.convertPlanToExecutable(plans, cacheGroup);
|
|
1607
|
+
yield taskExecutor.append(executables);
|
|
1608
|
+
output = yield taskExecutor.flush();
|
|
1609
|
+
return {
|
|
1610
|
+
output,
|
|
1611
|
+
executor: taskExecutor
|
|
1612
|
+
};
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
query(demand) {
|
|
1616
|
+
return __async(this, null, function*() {
|
|
1617
|
+
const description = typeof demand === "string" ? demand : JSON.stringify(demand);
|
|
1618
|
+
const taskExecutor = new _core.Executor(description);
|
|
1619
|
+
const queryTask = {
|
|
1620
|
+
type: "Insight",
|
|
1621
|
+
subType: "Query",
|
|
1622
|
+
param: {
|
|
1623
|
+
dataDemand: demand
|
|
1624
|
+
},
|
|
1625
|
+
executor: (param)=>__async(this, null, function*() {
|
|
1626
|
+
let insightDump;
|
|
1627
|
+
const dumpCollector = (dump)=>{
|
|
1628
|
+
insightDump = dump;
|
|
1629
|
+
};
|
|
1630
|
+
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1631
|
+
const data = yield this.insight.extract(param.dataDemand);
|
|
1632
|
+
return {
|
|
1633
|
+
output: data,
|
|
1634
|
+
log: {
|
|
1635
|
+
dump: insightDump
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
})
|
|
1639
|
+
};
|
|
1640
|
+
yield taskExecutor.append(this.wrapExecutorWithScreenshot(queryTask));
|
|
1641
|
+
const output = yield taskExecutor.flush();
|
|
1642
|
+
return {
|
|
1643
|
+
output,
|
|
1644
|
+
executor: taskExecutor
|
|
1645
|
+
};
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
assert(assertion) {
|
|
1649
|
+
return __async(this, null, function*() {
|
|
1650
|
+
const description = `assert: ${assertion}`;
|
|
1651
|
+
const taskExecutor = new _core.Executor(description);
|
|
1652
|
+
const assertionPlan = {
|
|
1653
|
+
type: "Assert",
|
|
1654
|
+
param: {
|
|
1655
|
+
assertion
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
const assertTask = yield this.convertPlanToExecutable([
|
|
1659
|
+
assertionPlan
|
|
1660
|
+
]);
|
|
1661
|
+
yield taskExecutor.append(this.wrapExecutorWithScreenshot(assertTask[0]));
|
|
1662
|
+
const output = yield taskExecutor.flush();
|
|
1663
|
+
return {
|
|
1664
|
+
output,
|
|
1665
|
+
executor: taskExecutor
|
|
1666
|
+
};
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
waitFor(assertion, opt) {
|
|
1670
|
+
return __async(this, null, function*() {
|
|
1671
|
+
const description = `waitFor: ${assertion}`;
|
|
1672
|
+
const taskExecutor = new _core.Executor(description);
|
|
1673
|
+
const { timeoutMs, checkIntervalMs } = opt;
|
|
1674
|
+
(0, _assert.default)(assertion, "No assertion for waitFor");
|
|
1675
|
+
(0, _assert.default)(timeoutMs, "No timeoutMs for waitFor");
|
|
1676
|
+
(0, _assert.default)(checkIntervalMs, "No checkIntervalMs for waitFor");
|
|
1677
|
+
const overallStartTime = Date.now();
|
|
1678
|
+
let startTime = Date.now();
|
|
1679
|
+
let errorThought = "";
|
|
1680
|
+
while(Date.now() - overallStartTime < timeoutMs){
|
|
1681
|
+
startTime = Date.now();
|
|
1682
|
+
const assertPlan = {
|
|
1683
|
+
type: "AssertWithoutThrow",
|
|
1684
|
+
param: {
|
|
1685
|
+
assertion
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
const assertTask = yield this.convertPlanToExecutable([
|
|
1689
|
+
assertPlan
|
|
1690
|
+
]);
|
|
1691
|
+
yield taskExecutor.append(this.wrapExecutorWithScreenshot(assertTask[0]));
|
|
1692
|
+
const output = yield taskExecutor.flush();
|
|
1693
|
+
if (output == null ? void 0 : output.pass) {
|
|
1694
|
+
return {
|
|
1695
|
+
output: void 0,
|
|
1696
|
+
executor: taskExecutor
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
errorThought = (output == null ? void 0 : output.thought) || "unknown error";
|
|
1700
|
+
const now = Date.now();
|
|
1701
|
+
if (now - startTime < checkIntervalMs) {
|
|
1702
|
+
const timeRemaining = checkIntervalMs - (now - startTime);
|
|
1703
|
+
const sleepPlan = {
|
|
1704
|
+
type: "Sleep",
|
|
1705
|
+
param: {
|
|
1706
|
+
timeMs: timeRemaining
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
const sleepTask = yield this.convertPlanToExecutable([
|
|
1710
|
+
sleepPlan
|
|
1711
|
+
]);
|
|
1712
|
+
yield taskExecutor.append(this.wrapExecutorWithScreenshot(sleepTask[0]));
|
|
1713
|
+
yield taskExecutor.flush();
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
const errorPlan = {
|
|
1717
|
+
type: "Error",
|
|
1718
|
+
param: {
|
|
1719
|
+
thought: `waitFor timeout: ${errorThought}`
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
const errorTask = yield this.convertPlanToExecutable([
|
|
1723
|
+
errorPlan
|
|
1724
|
+
]);
|
|
1725
|
+
yield taskExecutor.append(errorTask[0]);
|
|
1726
|
+
yield taskExecutor.flush();
|
|
1727
|
+
return {
|
|
1728
|
+
output: void 0,
|
|
1729
|
+
executor: taskExecutor
|
|
1730
|
+
};
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
constructor(page, insight, opts){
|
|
1734
|
+
this.page = page;
|
|
1735
|
+
this.insight = insight;
|
|
1736
|
+
this.taskCache = new TaskCache({
|
|
1737
|
+
fileName: opts == null ? void 0 : opts.cacheId
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
// src/common/agent.ts
|
|
1742
|
+
var PageAgent = class {
|
|
1743
|
+
getUIContext() {
|
|
1744
|
+
return __async(this, null, function*() {
|
|
1745
|
+
return yield parseContextFromWebPage(this.page);
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
resetDump() {
|
|
1749
|
+
this.dump = {
|
|
1750
|
+
groupName: this.opts.groupName,
|
|
1751
|
+
groupDescription: this.opts.groupDescription,
|
|
1752
|
+
executions: []
|
|
1277
1753
|
};
|
|
1278
|
-
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
param: plan2.param,
|
|
1304
|
-
executor: async (taskParam) => {
|
|
1305
|
-
(0, import_node_assert2.default)(taskParam.value, "No key to press");
|
|
1306
|
-
await this.page.keyboard.press(taskParam.value);
|
|
1307
|
-
}
|
|
1308
|
-
};
|
|
1309
|
-
return taskActionKeyboardPress;
|
|
1310
|
-
}
|
|
1311
|
-
if (plan2.type === "Tap") {
|
|
1312
|
-
const taskActionTap = {
|
|
1313
|
-
type: "Action",
|
|
1314
|
-
subType: "Tap",
|
|
1315
|
-
executor: async (param, { element }) => {
|
|
1316
|
-
(0, import_node_assert2.default)(element, "Element not found, cannot tap");
|
|
1317
|
-
await this.page.mouse.click(
|
|
1318
|
-
element.center[0],
|
|
1319
|
-
element.center[1]
|
|
1320
|
-
);
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
1323
|
-
return taskActionTap;
|
|
1324
|
-
}
|
|
1325
|
-
if (plan2.type === "Hover") {
|
|
1326
|
-
const taskActionHover = {
|
|
1327
|
-
type: "Action",
|
|
1328
|
-
subType: "Hover",
|
|
1329
|
-
executor: async (param, { element }) => {
|
|
1330
|
-
(0, import_node_assert2.default)(element, "Element not found, cannot hover");
|
|
1331
|
-
await this.page.mouse.move(
|
|
1332
|
-
element.center[0],
|
|
1333
|
-
element.center[1]
|
|
1334
|
-
);
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
1337
|
-
return taskActionHover;
|
|
1338
|
-
}
|
|
1339
|
-
if (plan2.type === "Scroll") {
|
|
1340
|
-
const taskActionScroll = {
|
|
1341
|
-
type: "Action",
|
|
1342
|
-
subType: "Scroll",
|
|
1343
|
-
param: plan2.param,
|
|
1344
|
-
executor: async (taskParam) => {
|
|
1345
|
-
const scrollToEventName = taskParam.scrollType;
|
|
1346
|
-
switch (scrollToEventName) {
|
|
1347
|
-
case "scrollUntilTop":
|
|
1348
|
-
await this.page.scrollUntilTop();
|
|
1349
|
-
break;
|
|
1350
|
-
case "scrollUntilBottom":
|
|
1351
|
-
await this.page.scrollUntilBottom();
|
|
1352
|
-
break;
|
|
1353
|
-
case "scrollUpOneScreen":
|
|
1354
|
-
await this.page.scrollUpOneScreen();
|
|
1355
|
-
break;
|
|
1356
|
-
case "scrollDownOneScreen":
|
|
1357
|
-
await this.page.scrollDownOneScreen();
|
|
1358
|
-
break;
|
|
1359
|
-
default:
|
|
1360
|
-
console.error(
|
|
1361
|
-
"Unknown scroll event type:",
|
|
1362
|
-
scrollToEventName
|
|
1363
|
-
);
|
|
1754
|
+
return this.dump;
|
|
1755
|
+
}
|
|
1756
|
+
appendExecutionDump(execution) {
|
|
1757
|
+
const currentDump = this.dump;
|
|
1758
|
+
currentDump.executions.push(execution);
|
|
1759
|
+
}
|
|
1760
|
+
dumpDataString() {
|
|
1761
|
+
this.dump.groupName = this.opts.groupName;
|
|
1762
|
+
this.dump.groupDescription = this.opts.groupDescription;
|
|
1763
|
+
return (0, _utils.stringifyDumpData)(this.dump);
|
|
1764
|
+
}
|
|
1765
|
+
reportHTMLString() {
|
|
1766
|
+
return (0, _utils.reportHTMLContent)(this.dumpDataString());
|
|
1767
|
+
}
|
|
1768
|
+
writeOutActionDumps() {
|
|
1769
|
+
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1770
|
+
this.reportFile = (0, _utils.writeLogFile)({
|
|
1771
|
+
fileName: this.reportFileName,
|
|
1772
|
+
fileExt: _utils.groupedActionDumpFileExt,
|
|
1773
|
+
fileContent: this.dumpDataString(),
|
|
1774
|
+
type: "dump",
|
|
1775
|
+
generateReport
|
|
1776
|
+
});
|
|
1777
|
+
if (generateReport && autoPrintReportMsg && this.reportFile) {
|
|
1778
|
+
printReportMsg(this.reportFile);
|
|
1364
1779
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
executor: async (taskParam) => {
|
|
1375
|
-
await (0, import_utils3.sleep)(taskParam.timeMs || 3e3);
|
|
1376
|
-
}
|
|
1377
|
-
};
|
|
1378
|
-
return taskActionSleep;
|
|
1379
|
-
}
|
|
1380
|
-
if (plan2.type === "Error") {
|
|
1381
|
-
const taskActionError = {
|
|
1382
|
-
type: "Action",
|
|
1383
|
-
subType: "Error",
|
|
1384
|
-
param: plan2.param,
|
|
1385
|
-
executor: async (taskParam) => {
|
|
1386
|
-
(0, import_node_assert2.default)(
|
|
1387
|
-
taskParam.thought,
|
|
1388
|
-
"An error occurred, but no thought provided"
|
|
1389
|
-
);
|
|
1390
|
-
throw new Error(taskParam.thought);
|
|
1391
|
-
}
|
|
1392
|
-
};
|
|
1393
|
-
return taskActionError;
|
|
1394
|
-
}
|
|
1395
|
-
throw new Error(`Unknown or Unsupported task type: ${plan2.type}`);
|
|
1396
|
-
}).map((task) => {
|
|
1397
|
-
return this.wrapExecutorWithScreenshot(task);
|
|
1398
|
-
});
|
|
1399
|
-
return tasks;
|
|
1400
|
-
}
|
|
1401
|
-
async action(userPrompt) {
|
|
1402
|
-
const taskExecutor = new import_core.Executor(userPrompt);
|
|
1403
|
-
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
1404
|
-
let plans = [];
|
|
1405
|
-
const planningTask = {
|
|
1406
|
-
type: "Planning",
|
|
1407
|
-
param: {
|
|
1408
|
-
userPrompt
|
|
1409
|
-
},
|
|
1410
|
-
executor: async (param) => {
|
|
1411
|
-
const pageContext = await this.insight.contextRetrieverFn();
|
|
1412
|
-
let planResult;
|
|
1413
|
-
const planCache = cacheGroup.readCache(pageContext, "plan", userPrompt);
|
|
1414
|
-
if (planCache) {
|
|
1415
|
-
planResult = planCache;
|
|
1416
|
-
} else {
|
|
1417
|
-
planResult = await (0, import_core.plan)(param.userPrompt, {
|
|
1418
|
-
context: pageContext
|
|
1419
|
-
});
|
|
1420
|
-
}
|
|
1421
|
-
(0, import_node_assert2.default)(planResult.plans.length > 0, "No plans found");
|
|
1422
|
-
plans = planResult.plans;
|
|
1423
|
-
cacheGroup.saveCache({
|
|
1424
|
-
type: "plan",
|
|
1425
|
-
pageContext: {
|
|
1426
|
-
url: pageContext.url,
|
|
1427
|
-
size: pageContext.size
|
|
1428
|
-
},
|
|
1429
|
-
prompt: userPrompt,
|
|
1430
|
-
response: planResult
|
|
1431
|
-
});
|
|
1432
|
-
return {
|
|
1433
|
-
output: planResult,
|
|
1434
|
-
cache: {
|
|
1435
|
-
hit: Boolean(planCache)
|
|
1436
|
-
}
|
|
1437
|
-
};
|
|
1438
|
-
}
|
|
1439
|
-
};
|
|
1440
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(planningTask));
|
|
1441
|
-
let output = await taskExecutor.flush();
|
|
1442
|
-
if (taskExecutor.isInErrorState()) {
|
|
1443
|
-
return {
|
|
1444
|
-
output,
|
|
1445
|
-
executor: taskExecutor
|
|
1446
|
-
};
|
|
1447
|
-
}
|
|
1448
|
-
const executables = await this.convertPlanToExecutable(plans, cacheGroup);
|
|
1449
|
-
await taskExecutor.append(executables);
|
|
1450
|
-
output = await taskExecutor.flush();
|
|
1451
|
-
return {
|
|
1452
|
-
output,
|
|
1453
|
-
executor: taskExecutor
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
async query(demand) {
|
|
1457
|
-
const description = typeof demand === "string" ? demand : JSON.stringify(demand);
|
|
1458
|
-
const taskExecutor = new import_core.Executor(description);
|
|
1459
|
-
const queryTask = {
|
|
1460
|
-
type: "Insight",
|
|
1461
|
-
subType: "Query",
|
|
1462
|
-
param: {
|
|
1463
|
-
dataDemand: demand
|
|
1464
|
-
},
|
|
1465
|
-
executor: async (param) => {
|
|
1466
|
-
let insightDump;
|
|
1467
|
-
const dumpCollector = (dump) => {
|
|
1468
|
-
insightDump = dump;
|
|
1469
|
-
};
|
|
1470
|
-
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1471
|
-
const data = await this.insight.extract(param.dataDemand);
|
|
1472
|
-
return {
|
|
1473
|
-
output: data,
|
|
1474
|
-
log: { dump: insightDump }
|
|
1475
|
-
};
|
|
1476
|
-
}
|
|
1477
|
-
};
|
|
1478
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(queryTask));
|
|
1479
|
-
const output = await taskExecutor.flush();
|
|
1480
|
-
return {
|
|
1481
|
-
output,
|
|
1482
|
-
executor: taskExecutor
|
|
1483
|
-
};
|
|
1484
|
-
}
|
|
1485
|
-
async assert(assertion) {
|
|
1486
|
-
const description = `assert: ${assertion}`;
|
|
1487
|
-
const taskExecutor = new import_core.Executor(description);
|
|
1488
|
-
const assertionPlan = {
|
|
1489
|
-
type: "Assert",
|
|
1490
|
-
param: {
|
|
1491
|
-
assertion
|
|
1492
|
-
}
|
|
1493
|
-
};
|
|
1494
|
-
const assertTask = await this.convertPlanToExecutable([assertionPlan]);
|
|
1495
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(assertTask[0]));
|
|
1496
|
-
const output = await taskExecutor.flush();
|
|
1497
|
-
return {
|
|
1498
|
-
output,
|
|
1499
|
-
executor: taskExecutor
|
|
1500
|
-
};
|
|
1501
|
-
}
|
|
1502
|
-
async waitFor(assertion, opt) {
|
|
1503
|
-
const description = `waitFor: ${assertion}`;
|
|
1504
|
-
const taskExecutor = new import_core.Executor(description);
|
|
1505
|
-
const { timeoutMs, checkIntervalMs } = opt;
|
|
1506
|
-
(0, import_node_assert2.default)(assertion, "No assertion for waitFor");
|
|
1507
|
-
(0, import_node_assert2.default)(timeoutMs, "No timeoutMs for waitFor");
|
|
1508
|
-
(0, import_node_assert2.default)(checkIntervalMs, "No checkIntervalMs for waitFor");
|
|
1509
|
-
const overallStartTime = Date.now();
|
|
1510
|
-
let startTime = Date.now();
|
|
1511
|
-
let errorThought = "";
|
|
1512
|
-
while (Date.now() - overallStartTime < timeoutMs) {
|
|
1513
|
-
startTime = Date.now();
|
|
1514
|
-
const assertPlan = {
|
|
1515
|
-
type: "AssertWithoutThrow",
|
|
1516
|
-
param: {
|
|
1517
|
-
assertion
|
|
1518
|
-
}
|
|
1519
|
-
};
|
|
1520
|
-
const assertTask = await this.convertPlanToExecutable([assertPlan]);
|
|
1521
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(assertTask[0]));
|
|
1522
|
-
const output = await taskExecutor.flush();
|
|
1523
|
-
if (output == null ? void 0 : output.pass) {
|
|
1524
|
-
return {
|
|
1525
|
-
output: void 0,
|
|
1526
|
-
executor: taskExecutor
|
|
1527
|
-
};
|
|
1528
|
-
}
|
|
1529
|
-
errorThought = (output == null ? void 0 : output.thought) || "unknown error";
|
|
1530
|
-
const now = Date.now();
|
|
1531
|
-
if (now - startTime < checkIntervalMs) {
|
|
1532
|
-
const timeRemaining = checkIntervalMs - (now - startTime);
|
|
1533
|
-
const sleepPlan = {
|
|
1534
|
-
type: "Sleep",
|
|
1535
|
-
param: {
|
|
1536
|
-
timeMs: timeRemaining
|
|
1537
|
-
}
|
|
1538
|
-
};
|
|
1539
|
-
const sleepTask = await this.convertPlanToExecutable([sleepPlan]);
|
|
1540
|
-
await taskExecutor.append(
|
|
1541
|
-
this.wrapExecutorWithScreenshot(sleepTask[0])
|
|
1542
|
-
);
|
|
1543
|
-
await taskExecutor.flush();
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
const errorPlan = {
|
|
1547
|
-
type: "Error",
|
|
1548
|
-
param: {
|
|
1549
|
-
thought: `waitFor timeout: ${errorThought}`
|
|
1550
|
-
}
|
|
1551
|
-
};
|
|
1552
|
-
const errorTask = await this.convertPlanToExecutable([errorPlan]);
|
|
1553
|
-
await taskExecutor.append(errorTask[0]);
|
|
1554
|
-
await taskExecutor.flush();
|
|
1555
|
-
return {
|
|
1556
|
-
output: void 0,
|
|
1557
|
-
executor: taskExecutor
|
|
1558
|
-
};
|
|
1559
|
-
}
|
|
1560
|
-
};
|
|
1561
|
-
|
|
1562
|
-
// src/common/agent.ts
|
|
1563
|
-
var PageAgent = class {
|
|
1564
|
-
constructor(page, opts) {
|
|
1565
|
-
this.page = page;
|
|
1566
|
-
this.opts = Object.assign(
|
|
1567
|
-
{
|
|
1568
|
-
generateReport: true,
|
|
1569
|
-
autoPrintReportMsg: true,
|
|
1570
|
-
groupName: "Midscene Report",
|
|
1571
|
-
groupDescription: ""
|
|
1572
|
-
},
|
|
1573
|
-
opts || {}
|
|
1574
|
-
);
|
|
1575
|
-
this.dump = {
|
|
1576
|
-
groupName: this.opts.groupName,
|
|
1577
|
-
groupDescription: this.opts.groupDescription,
|
|
1578
|
-
executions: []
|
|
1579
|
-
};
|
|
1580
|
-
this.taskExecutor = new PageTaskExecutor(this.page, {
|
|
1581
|
-
cacheId: opts == null ? void 0 : opts.cacheId
|
|
1582
|
-
});
|
|
1583
|
-
this.reportFileName = reportFileName((opts == null ? void 0 : opts.testId) || "web");
|
|
1584
|
-
}
|
|
1585
|
-
appendExecutionDump(execution) {
|
|
1586
|
-
const currentDump = this.dump;
|
|
1587
|
-
currentDump.executions.push(execution);
|
|
1588
|
-
}
|
|
1589
|
-
dumpDataString() {
|
|
1590
|
-
this.dump.groupName = this.opts.groupName;
|
|
1591
|
-
this.dump.groupDescription = this.opts.groupDescription;
|
|
1592
|
-
return (0, import_utils5.stringifyDumpData)(this.dump);
|
|
1593
|
-
}
|
|
1594
|
-
writeOutActionDumps() {
|
|
1595
|
-
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1596
|
-
this.reportFile = (0, import_utils5.writeLogFile)({
|
|
1597
|
-
fileName: this.reportFileName,
|
|
1598
|
-
fileExt: import_utils5.groupedActionDumpFileExt,
|
|
1599
|
-
fileContent: this.dumpDataString(),
|
|
1600
|
-
type: "dump",
|
|
1601
|
-
generateReport
|
|
1602
|
-
});
|
|
1603
|
-
if (generateReport && autoPrintReportMsg) {
|
|
1604
|
-
printReportMsg(this.reportFile);
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
async aiAction(taskPrompt) {
|
|
1608
|
-
const { executor } = await this.taskExecutor.action(taskPrompt);
|
|
1609
|
-
this.appendExecutionDump(executor.dump());
|
|
1610
|
-
this.writeOutActionDumps();
|
|
1611
|
-
if (executor.isInErrorState()) {
|
|
1612
|
-
const errorTask = executor.latestErrorTask();
|
|
1613
|
-
throw new Error(`${errorTask == null ? void 0 : errorTask.error}
|
|
1780
|
+
}
|
|
1781
|
+
aiAction(taskPrompt) {
|
|
1782
|
+
return __async(this, null, function*() {
|
|
1783
|
+
const { executor } = yield this.taskExecutor.action(taskPrompt);
|
|
1784
|
+
this.appendExecutionDump(executor.dump());
|
|
1785
|
+
this.writeOutActionDumps();
|
|
1786
|
+
if (executor.isInErrorState()) {
|
|
1787
|
+
const errorTask = executor.latestErrorTask();
|
|
1788
|
+
throw new Error(`${errorTask == null ? void 0 : errorTask.error}
|
|
1614
1789
|
${errorTask == null ? void 0 : errorTask.errorStack}`);
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
aiQuery(demand) {
|
|
1794
|
+
return __async(this, null, function*() {
|
|
1795
|
+
const { output, executor } = yield this.taskExecutor.query(demand);
|
|
1796
|
+
this.appendExecutionDump(executor.dump());
|
|
1797
|
+
this.writeOutActionDumps();
|
|
1798
|
+
if (executor.isInErrorState()) {
|
|
1799
|
+
const errorTask = executor.latestErrorTask();
|
|
1800
|
+
throw new Error(`${errorTask == null ? void 0 : errorTask.error}
|
|
1624
1801
|
${errorTask == null ? void 0 : errorTask.errorStack}`);
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1802
|
+
}
|
|
1803
|
+
return output;
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
aiAssert(assertion, msg, opt) {
|
|
1807
|
+
return __async(this, null, function*() {
|
|
1808
|
+
var _a;
|
|
1809
|
+
const { output, executor } = yield this.taskExecutor.assert(assertion);
|
|
1810
|
+
this.appendExecutionDump(executor.dump());
|
|
1811
|
+
this.writeOutActionDumps();
|
|
1812
|
+
if (output && (opt == null ? void 0 : opt.keepRawResponse)) {
|
|
1813
|
+
return output;
|
|
1814
|
+
}
|
|
1815
|
+
if (!(output == null ? void 0 : output.pass)) {
|
|
1816
|
+
const errMsg = msg || `Assertion failed: ${assertion}`;
|
|
1817
|
+
const reasonMsg = `Reason: ${(output == null ? void 0 : output.thought) || ((_a = executor.latestErrorTask()) == null ? void 0 : _a.error) || "(no_reason)"}`;
|
|
1818
|
+
throw new Error(`${errMsg}
|
|
1639
1819
|
${reasonMsg}`);
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
aiWaitFor(assertion, opt) {
|
|
1824
|
+
return __async(this, null, function*() {
|
|
1825
|
+
const { executor } = yield this.taskExecutor.waitFor(assertion, {
|
|
1826
|
+
timeoutMs: (opt == null ? void 0 : opt.timeoutMs) || 15 * 1e3,
|
|
1827
|
+
checkIntervalMs: (opt == null ? void 0 : opt.checkIntervalMs) || 3 * 1e3,
|
|
1828
|
+
assertion
|
|
1829
|
+
});
|
|
1830
|
+
this.appendExecutionDump(executor.dump());
|
|
1831
|
+
this.writeOutActionDumps();
|
|
1832
|
+
if (executor.isInErrorState()) {
|
|
1833
|
+
const errorTask = executor.latestErrorTask();
|
|
1834
|
+
throw new Error(`${errorTask == null ? void 0 : errorTask.error}
|
|
1653
1835
|
${errorTask == null ? void 0 : errorTask.errorStack}`);
|
|
1836
|
+
}
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
ai(taskPrompt, type = "action") {
|
|
1840
|
+
return __async(this, null, function*() {
|
|
1841
|
+
if (type === "action") {
|
|
1842
|
+
return this.aiAction(taskPrompt);
|
|
1843
|
+
}
|
|
1844
|
+
if (type === "query") {
|
|
1845
|
+
return this.aiQuery(taskPrompt);
|
|
1846
|
+
}
|
|
1847
|
+
if (type === "assert") {
|
|
1848
|
+
return this.aiAssert(taskPrompt);
|
|
1849
|
+
}
|
|
1850
|
+
throw new Error(`Unknown type: ${type}, only support 'action', 'query', 'assert'`);
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
destroy() {
|
|
1854
|
+
return __async(this, null, function*() {
|
|
1855
|
+
yield this.page.destroy();
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
constructor(page, opts){
|
|
1859
|
+
/**
|
|
1860
|
+
* If true, the agent will not perform any actions
|
|
1861
|
+
*/ this.dryMode = false;
|
|
1862
|
+
this.page = page;
|
|
1863
|
+
this.opts = Object.assign({
|
|
1864
|
+
generateReport: true,
|
|
1865
|
+
autoPrintReportMsg: true,
|
|
1866
|
+
groupName: "Midscene Report",
|
|
1867
|
+
groupDescription: ""
|
|
1868
|
+
}, opts || {});
|
|
1869
|
+
this.insight = new _core.Insight(()=>__async(this, null, function*() {
|
|
1870
|
+
return this.getUIContext();
|
|
1871
|
+
}), {
|
|
1872
|
+
generateElement: ({ content, rect })=>new WebElementInfo({
|
|
1873
|
+
content: content || "",
|
|
1874
|
+
rect,
|
|
1875
|
+
page,
|
|
1876
|
+
id: "",
|
|
1877
|
+
attributes: {
|
|
1878
|
+
nodeType: _constants.NodeType.CONTAINER
|
|
1879
|
+
},
|
|
1880
|
+
indexId: 0
|
|
1881
|
+
})
|
|
1882
|
+
});
|
|
1883
|
+
this.taskExecutor = new PageTaskExecutor(this.page, this.insight, {
|
|
1884
|
+
cacheId: opts == null ? void 0 : opts.cacheId
|
|
1885
|
+
});
|
|
1886
|
+
this.dump = this.resetDump();
|
|
1887
|
+
this.reportFileName = reportFileName((opts == null ? void 0 : opts.testId) || "web");
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
// src/extractor/util.ts
|
|
1891
|
+
var import_js_sha256 = __toESM(require_sha256());
|
|
1892
|
+
var frameId = 0;
|
|
1893
|
+
function getFrameId() {
|
|
1894
|
+
return frameId;
|
|
1654
1895
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
if (type === "assert") {
|
|
1664
|
-
return this.aiAssert(taskPrompt);
|
|
1665
|
-
}
|
|
1666
|
-
throw new Error(
|
|
1667
|
-
`Unknown type: ${type}, only support 'action', 'query', 'assert'`
|
|
1668
|
-
);
|
|
1669
|
-
}
|
|
1670
|
-
};
|
|
1671
|
-
|
|
1672
|
-
// src/appium/page.ts
|
|
1673
|
-
var import_node_fs3 = __toESM(require("fs"));
|
|
1674
|
-
var import_utils7 = require("@midscene/core/utils");
|
|
1675
|
-
var import_img4 = require("@midscene/shared/img");
|
|
1676
|
-
var import_xmldom = require("@xmldom/xmldom");
|
|
1677
|
-
|
|
1678
|
-
// src/extractor/web-extractor.ts
|
|
1679
|
-
var import_constants2 = require("@midscene/shared/constants");
|
|
1680
|
-
|
|
1681
|
-
// src/extractor/util.ts
|
|
1682
|
-
var import_js_sha256 = __toESM(require_sha256());
|
|
1683
|
-
var frameId = 0;
|
|
1684
|
-
function getFrameId() {
|
|
1685
|
-
return frameId;
|
|
1686
|
-
}
|
|
1687
|
-
function midsceneGenerateHash(content, rect) {
|
|
1688
|
-
const combined = JSON.stringify({
|
|
1689
|
-
content,
|
|
1690
|
-
rect,
|
|
1691
|
-
_midscene_frame_id: getFrameId()
|
|
1692
|
-
});
|
|
1693
|
-
const hashHex = (0, import_js_sha256.default)(combined);
|
|
1694
|
-
return hashHex.slice(0, 10);
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
// src/extractor/constants.ts
|
|
1698
|
-
var import_constants3 = require("@midscene/shared/constants");
|
|
1699
|
-
|
|
1700
|
-
// src/extractor/client-extractor.ts
|
|
1701
|
-
function getNodeAttributes2(node) {
|
|
1702
|
-
var _a;
|
|
1703
|
-
const attrs = {};
|
|
1704
|
-
if (node && node.nodeType === 1) {
|
|
1705
|
-
const element = node;
|
|
1706
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
1707
|
-
const attr = element.attributes[i];
|
|
1708
|
-
attrs[attr.nodeName] = (_a = attr.nodeValue) != null ? _a : "";
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
return attrs;
|
|
1712
|
-
}
|
|
1713
|
-
function getRect2(attributes) {
|
|
1714
|
-
var _a, _b, _c, _d;
|
|
1715
|
-
const x = Math.round(Number.parseFloat((_a = attributes.x) != null ? _a : "0"));
|
|
1716
|
-
const y = Math.round(Number.parseFloat((_b = attributes.y) != null ? _b : "0"));
|
|
1717
|
-
const width = Math.round(Number.parseFloat((_c = attributes.width) != null ? _c : "0"));
|
|
1718
|
-
const height = Math.round(Number.parseFloat((_d = attributes.height) != null ? _d : "0"));
|
|
1719
|
-
return {
|
|
1720
|
-
left: Math.max(0, Math.floor(x)),
|
|
1721
|
-
top: Math.max(0, Math.floor(y)),
|
|
1722
|
-
width: Math.max(0, width),
|
|
1723
|
-
height: Math.max(0, height)
|
|
1724
|
-
};
|
|
1725
|
-
}
|
|
1726
|
-
function validTextNodeContent(node) {
|
|
1727
|
-
var _a;
|
|
1728
|
-
if (node.nodeType === 3) {
|
|
1729
|
-
return ((_a = node.nodeValue) == null ? void 0 : _a.trim()) || "";
|
|
1730
|
-
}
|
|
1731
|
-
return "";
|
|
1732
|
-
}
|
|
1733
|
-
function getXPathForElement(element) {
|
|
1734
|
-
if (element.nodeType !== 1) {
|
|
1735
|
-
return "";
|
|
1736
|
-
}
|
|
1737
|
-
const getIndex = (sib, name) => {
|
|
1738
|
-
let count = 1;
|
|
1739
|
-
for (let cur = sib.previousSibling; cur; cur = cur.previousSibling) {
|
|
1740
|
-
if (cur.nodeType === 1 && cur.nodeName === name) {
|
|
1741
|
-
count++;
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
return count;
|
|
1745
|
-
};
|
|
1746
|
-
const buildAttributePart = (elem) => {
|
|
1747
|
-
const attributes = ["id", "resource-id", "content-desc", "class"];
|
|
1748
|
-
for (const attr of attributes) {
|
|
1749
|
-
if (elem.hasAttribute(attr)) {
|
|
1750
|
-
const value = elem.getAttribute(attr);
|
|
1751
|
-
if (value && value.trim() !== "") {
|
|
1752
|
-
return `[@${attr}="${value}"]`;
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
return "";
|
|
1757
|
-
};
|
|
1758
|
-
const getPath = (node, path2 = "") => {
|
|
1759
|
-
if (node.parentNode) {
|
|
1760
|
-
path2 = getPath(node.parentNode, path2);
|
|
1896
|
+
function midsceneGenerateHash(content, rect) {
|
|
1897
|
+
const combined = JSON.stringify({
|
|
1898
|
+
content,
|
|
1899
|
+
rect,
|
|
1900
|
+
_midscene_frame_id: getFrameId()
|
|
1901
|
+
});
|
|
1902
|
+
const hashHex = (0, import_js_sha256.default)(combined);
|
|
1903
|
+
return hashHex.slice(0, 10);
|
|
1761
1904
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
}
|
|
1775
|
-
path2 += part;
|
|
1905
|
+
// src/extractor/client-extractor.ts
|
|
1906
|
+
function getNodeAttributes2(node) {
|
|
1907
|
+
var _a;
|
|
1908
|
+
const attrs = {};
|
|
1909
|
+
if (node && node.nodeType === 1) {
|
|
1910
|
+
const element = node;
|
|
1911
|
+
for(let i = 0; i < element.attributes.length; i++){
|
|
1912
|
+
const attr = element.attributes[i];
|
|
1913
|
+
attrs[attr.nodeName] = (_a = attr.nodeValue) != null ? _a : "";
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
return attrs;
|
|
1776
1917
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1918
|
+
function getRect2(attributes) {
|
|
1919
|
+
var _a, _b, _c, _d;
|
|
1920
|
+
const x = Math.round(Number.parseFloat((_a = attributes.x) != null ? _a : "0"));
|
|
1921
|
+
const y = Math.round(Number.parseFloat((_b = attributes.y) != null ? _b : "0"));
|
|
1922
|
+
const width = Math.round(Number.parseFloat((_c = attributes.width) != null ? _c : "0"));
|
|
1923
|
+
const height = Math.round(Number.parseFloat((_d = attributes.height) != null ? _d : "0"));
|
|
1924
|
+
return {
|
|
1925
|
+
left: Math.max(0, Math.floor(x)),
|
|
1926
|
+
top: Math.max(0, Math.floor(y)),
|
|
1927
|
+
width: Math.max(0, width),
|
|
1928
|
+
height: Math.max(0, height)
|
|
1929
|
+
};
|
|
1787
1930
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1931
|
+
function validTextNodeContent(node) {
|
|
1932
|
+
var _a;
|
|
1933
|
+
if (node.nodeType === 3) {
|
|
1934
|
+
return ((_a = node.nodeValue) == null ? void 0 : _a.trim()) || "";
|
|
1935
|
+
}
|
|
1936
|
+
return "";
|
|
1791
1937
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1938
|
+
function getXPathForElement(element) {
|
|
1939
|
+
if (element.nodeType !== 1) {
|
|
1940
|
+
return "";
|
|
1941
|
+
}
|
|
1942
|
+
const getIndex = (sib, name)=>{
|
|
1943
|
+
let count = 1;
|
|
1944
|
+
for(let cur = sib.previousSibling; cur; cur = cur.previousSibling){
|
|
1945
|
+
if (cur.nodeType === 1 && cur.nodeName === name) {
|
|
1946
|
+
count++;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
return count;
|
|
1950
|
+
};
|
|
1951
|
+
const buildAttributePart = (elem)=>{
|
|
1952
|
+
const attributes = [
|
|
1953
|
+
"id",
|
|
1954
|
+
"resource-id",
|
|
1955
|
+
"content-desc",
|
|
1956
|
+
"class"
|
|
1957
|
+
];
|
|
1958
|
+
for (const attr of attributes){
|
|
1959
|
+
if (elem.hasAttribute(attr)) {
|
|
1960
|
+
const value = elem.getAttribute(attr);
|
|
1961
|
+
if (value && value.trim() !== "") {
|
|
1962
|
+
return `[@${attr}="${value}"]`;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
return "";
|
|
1967
|
+
};
|
|
1968
|
+
const getPath = (node, path2 = "")=>{
|
|
1969
|
+
if (node.parentNode) {
|
|
1970
|
+
path2 = getPath(node.parentNode, path2);
|
|
1971
|
+
}
|
|
1972
|
+
if (node.nodeType === 1) {
|
|
1973
|
+
const elem = node;
|
|
1974
|
+
const tagName = elem.nodeName.toLowerCase();
|
|
1975
|
+
let part = `/${tagName}`;
|
|
1976
|
+
const attributePart = buildAttributePart(elem);
|
|
1977
|
+
if (attributePart) {
|
|
1978
|
+
part += attributePart;
|
|
1979
|
+
} else {
|
|
1980
|
+
const index = getIndex(node, node.nodeName);
|
|
1981
|
+
if (index > 1) {
|
|
1982
|
+
part += `[${index}]`;
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
path2 += part;
|
|
1986
|
+
}
|
|
1987
|
+
return path2;
|
|
1988
|
+
};
|
|
1989
|
+
return getPath(element);
|
|
1797
1990
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
nodeType = import_constants3.NodeType.FORM_ITEM;
|
|
1819
|
-
break;
|
|
1820
|
-
case "NAV":
|
|
1821
|
-
case "LIST":
|
|
1822
|
-
case "CELL":
|
|
1823
|
-
nodeType = import_constants3.NodeType.CONTAINER;
|
|
1824
|
-
break;
|
|
1825
|
-
default:
|
|
1826
|
-
if (attributes.id === "android:id/input" || attributes.id === "android:id/inputArea") {
|
|
1827
|
-
nodeType = import_constants3.NodeType.FORM_ITEM;
|
|
1828
|
-
} else {
|
|
1829
|
-
nodeType = import_constants3.NodeType.CONTAINER;
|
|
1991
|
+
function extractTextWithPosition2(initNode) {
|
|
1992
|
+
const elementInfoArray = [];
|
|
1993
|
+
let nodeIndex = 1;
|
|
1994
|
+
function dfs(node, parentNode = null) {
|
|
1995
|
+
if (!node) {
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
const currentNodeDes = {
|
|
1999
|
+
node,
|
|
2000
|
+
children: []
|
|
2001
|
+
};
|
|
2002
|
+
if (parentNode) {
|
|
2003
|
+
parentNode.children.push(currentNodeDes);
|
|
2004
|
+
}
|
|
2005
|
+
collectElementInfo(node);
|
|
2006
|
+
if (node.childNodes && node.childNodes.length > 0) {
|
|
2007
|
+
for(let i = 0; i < node.childNodes.length; i++){
|
|
2008
|
+
dfs(node.childNodes[i], currentNodeDes);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
1830
2011
|
}
|
|
1831
|
-
|
|
2012
|
+
function collectElementInfo(node) {
|
|
2013
|
+
const attributes = getNodeAttributes2(node);
|
|
2014
|
+
const rect = getRect2(attributes);
|
|
2015
|
+
const nodeHashId = midsceneGenerateHash(attributes.placeholder, rect);
|
|
2016
|
+
const text = validTextNodeContent(node);
|
|
2017
|
+
let nodeType;
|
|
2018
|
+
switch(node.nodeName.toUpperCase()){
|
|
2019
|
+
case "TEXT":
|
|
2020
|
+
nodeType = _constants.NodeType.TEXT;
|
|
2021
|
+
break;
|
|
2022
|
+
case "IMAGE":
|
|
2023
|
+
nodeType = _constants.NodeType.IMG;
|
|
2024
|
+
break;
|
|
2025
|
+
case "BUTTON":
|
|
2026
|
+
nodeType = _constants.NodeType.BUTTON;
|
|
2027
|
+
break;
|
|
2028
|
+
case "SEARCHINPUT":
|
|
2029
|
+
case "TEXTINPUT":
|
|
2030
|
+
case "INPUT":
|
|
2031
|
+
nodeType = _constants.NodeType.FORM_ITEM;
|
|
2032
|
+
break;
|
|
2033
|
+
case "NAV":
|
|
2034
|
+
case "LIST":
|
|
2035
|
+
case "CELL":
|
|
2036
|
+
nodeType = _constants.NodeType.CONTAINER;
|
|
2037
|
+
break;
|
|
2038
|
+
default:
|
|
2039
|
+
if (attributes.id === "android:id/input" || attributes.id === "android:id/inputArea") {
|
|
2040
|
+
nodeType = _constants.NodeType.FORM_ITEM;
|
|
2041
|
+
} else {
|
|
2042
|
+
nodeType = _constants.NodeType.CONTAINER;
|
|
2043
|
+
}
|
|
2044
|
+
break;
|
|
2045
|
+
}
|
|
2046
|
+
const xpath = getXPathForElement(node);
|
|
2047
|
+
const elementInfo = {
|
|
2048
|
+
id: nodeHashId,
|
|
2049
|
+
indexId: nodeIndex++,
|
|
2050
|
+
nodeHashId,
|
|
2051
|
+
locator: xpath,
|
|
2052
|
+
attributes: __spreadValues({
|
|
2053
|
+
nodeType
|
|
2054
|
+
}, attributes),
|
|
2055
|
+
content: text,
|
|
2056
|
+
rect,
|
|
2057
|
+
center: [
|
|
2058
|
+
Math.round(rect.left + rect.width / 2),
|
|
2059
|
+
Math.round(rect.top + rect.height / 2)
|
|
2060
|
+
],
|
|
2061
|
+
nodeType,
|
|
2062
|
+
nodePath: ""
|
|
2063
|
+
};
|
|
2064
|
+
if (elementInfo.nodeType !== _constants.NodeType.CONTAINER) {
|
|
2065
|
+
elementInfoArray.push(elementInfo);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
const rootNode = initNode;
|
|
2069
|
+
const rootDescriptor = {
|
|
2070
|
+
node: rootNode,
|
|
2071
|
+
children: []
|
|
2072
|
+
};
|
|
2073
|
+
dfs(rootNode, rootDescriptor);
|
|
2074
|
+
return elementInfoArray;
|
|
1832
2075
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
indexId: nodeIndex++,
|
|
1837
|
-
nodeHashId,
|
|
1838
|
-
locator: xpath,
|
|
1839
|
-
attributes: __spreadValues({
|
|
1840
|
-
nodeType
|
|
1841
|
-
}, attributes),
|
|
1842
|
-
content: text,
|
|
1843
|
-
rect,
|
|
1844
|
-
center: [
|
|
1845
|
-
Math.round(rect.left + rect.width / 2),
|
|
1846
|
-
Math.round(rect.top + rect.height / 2)
|
|
1847
|
-
],
|
|
1848
|
-
nodeType,
|
|
1849
|
-
nodePath: ""
|
|
1850
|
-
};
|
|
1851
|
-
if (elementInfo.nodeType !== import_constants3.NodeType.CONTAINER) {
|
|
1852
|
-
elementInfoArray.push(elementInfo);
|
|
2076
|
+
// src/appium/page.ts
|
|
2077
|
+
function buttonToNumber(button) {
|
|
2078
|
+
return button === "left" ? 0 : button === "middle" ? 1 : 2;
|
|
1853
2079
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
2080
|
+
var Page = class {
|
|
2081
|
+
getElementInfos() {
|
|
2082
|
+
return __async(this, null, function*() {
|
|
2083
|
+
const pageSource = yield this.browser.getPageSource();
|
|
2084
|
+
const { width, height } = yield this.browser.getWindowSize();
|
|
2085
|
+
const parser = new _xmldom.DOMParser();
|
|
2086
|
+
const doc = parser.parseFromString(pageSource, "text/xml");
|
|
2087
|
+
const infos = extractTextWithPosition2(doc).filter((element)=>element.rect.height !== height && element.rect.width !== width && element.rect.left !== 0 && element.rect.top !== 0 && element.attributes.visible === "true");
|
|
2088
|
+
return infos;
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
size() {
|
|
2092
|
+
return __async(this, null, function*() {
|
|
2093
|
+
return this.browser.getWindowSize();
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
screenshotBase64() {
|
|
2097
|
+
return __async(this, null, function*() {
|
|
2098
|
+
const { width, height } = yield this.size();
|
|
2099
|
+
const path2 = (0, _utils.getTmpFile)("png");
|
|
2100
|
+
const screenshotBuffer = yield this.browser.saveScreenshot(path2);
|
|
2101
|
+
const resizedScreenshotBuffer = yield (0, _img.resizeImg)(screenshotBuffer, {
|
|
2102
|
+
width,
|
|
2103
|
+
height
|
|
2104
|
+
});
|
|
2105
|
+
_fs.default.writeFileSync(path2, resizedScreenshotBuffer);
|
|
2106
|
+
return (0, _img.base64Encoded)(path2);
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
get mouse() {
|
|
2110
|
+
return {
|
|
2111
|
+
click: (x, y, options)=>this.mouseClick(x, y, (options == null ? void 0 : options.button) || "left"),
|
|
2112
|
+
wheel: (deltaX, deltaY)=>this.mouseWheel(deltaX, deltaY),
|
|
2113
|
+
move: (x, y)=>this.mouseMove(x, y)
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
// Object that includes keyboard and mouse operations
|
|
2117
|
+
get keyboard() {
|
|
2118
|
+
return {
|
|
2119
|
+
type: (text)=>this.keyboardType(text),
|
|
2120
|
+
press: (key)=>this.keyboardPress(key)
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
clearInput(element) {
|
|
2124
|
+
return __async(this, null, function*() {
|
|
2125
|
+
if (!element) {
|
|
2126
|
+
return;
|
|
2127
|
+
}
|
|
2128
|
+
const ele = yield this.browser.$(element.locator);
|
|
2129
|
+
const blank = " ";
|
|
2130
|
+
yield this.keyboardType(blank);
|
|
2131
|
+
yield ele.clearValue();
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
url() {
|
|
2135
|
+
var _a;
|
|
2136
|
+
const platformName = (_a = this.browser.capabilities.platformName) == null ? void 0 : _a.toLowerCase();
|
|
2137
|
+
if (platformName === "ios") {
|
|
2138
|
+
const bundleId = this.browser.capabilities.bundleId;
|
|
2139
|
+
return bundleId;
|
|
2140
|
+
}
|
|
2141
|
+
if (platformName === "android") {
|
|
2142
|
+
const appActivity = this.browser.capabilities.appActivity;
|
|
2143
|
+
return appActivity;
|
|
2144
|
+
}
|
|
2145
|
+
return "";
|
|
2146
|
+
}
|
|
2147
|
+
// Scroll to top element
|
|
2148
|
+
scrollUntilTop() {
|
|
2149
|
+
return __async(this, null, function*() {
|
|
2150
|
+
const { height } = yield this.browser.getWindowSize();
|
|
2151
|
+
yield this.mouseWheel(0, height, 100);
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
// Scroll to bottom element
|
|
2155
|
+
scrollUntilBottom() {
|
|
2156
|
+
return __async(this, null, function*() {
|
|
2157
|
+
const { height } = yield this.browser.getWindowSize();
|
|
2158
|
+
yield this.mouseWheel(0, -height, 100);
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
// Scroll up one screen
|
|
2162
|
+
scrollUpOneScreen() {
|
|
2163
|
+
return __async(this, null, function*() {
|
|
2164
|
+
const { height } = yield this.browser.getWindowSize();
|
|
2165
|
+
yield this.mouseWheel(0, height, 1e3);
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
// Scroll down one screen
|
|
2169
|
+
scrollDownOneScreen() {
|
|
2170
|
+
return __async(this, null, function*() {
|
|
2171
|
+
const { height } = yield this.browser.getWindowSize();
|
|
2172
|
+
yield this.mouseWheel(0, -height, 1e3);
|
|
2173
|
+
});
|
|
2174
|
+
}
|
|
2175
|
+
keyboardType(text) {
|
|
2176
|
+
return __async(this, null, function*() {
|
|
2177
|
+
const actions = [];
|
|
2178
|
+
for (const char of text){
|
|
2179
|
+
actions.push({
|
|
2180
|
+
type: "keyDown",
|
|
2181
|
+
value: char
|
|
2182
|
+
});
|
|
2183
|
+
actions.push({
|
|
2184
|
+
type: "keyUp",
|
|
2185
|
+
value: char
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
if (!actions.length) {
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
yield this.browser.performActions([
|
|
2192
|
+
{
|
|
2193
|
+
type: "key",
|
|
2194
|
+
id: "keyboard",
|
|
2195
|
+
actions
|
|
2196
|
+
}
|
|
2197
|
+
]);
|
|
2198
|
+
});
|
|
2199
|
+
}
|
|
2200
|
+
keyboardPress(key) {
|
|
2201
|
+
return __async(this, null, function*() {
|
|
2202
|
+
yield this.browser.performActions([
|
|
2203
|
+
{
|
|
2204
|
+
type: "key",
|
|
2205
|
+
id: "keyboard",
|
|
2206
|
+
actions: [
|
|
2207
|
+
{
|
|
2208
|
+
type: "keyDown",
|
|
2209
|
+
value: key
|
|
2210
|
+
},
|
|
2211
|
+
{
|
|
2212
|
+
type: "keyUp",
|
|
2213
|
+
value: key
|
|
2214
|
+
}
|
|
2215
|
+
]
|
|
2216
|
+
}
|
|
2217
|
+
]);
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
mouseClick(x, y, button = "left") {
|
|
2221
|
+
return __async(this, null, function*() {
|
|
2222
|
+
yield this.mouseMove(x, y);
|
|
2223
|
+
yield this.browser.performActions([
|
|
2224
|
+
{
|
|
2225
|
+
type: "pointer",
|
|
2226
|
+
id: "mouse",
|
|
2227
|
+
parameters: {
|
|
2228
|
+
pointerType: "mouse"
|
|
2229
|
+
},
|
|
2230
|
+
actions: [
|
|
2231
|
+
{
|
|
2232
|
+
type: "pointerMove",
|
|
2233
|
+
duration: 0,
|
|
2234
|
+
x,
|
|
2235
|
+
y
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
type: "pointerDown",
|
|
2239
|
+
button: buttonToNumber(button)
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
type: "pause",
|
|
2243
|
+
duration: 100
|
|
2244
|
+
},
|
|
2245
|
+
{
|
|
2246
|
+
type: "pointerUp",
|
|
2247
|
+
button: buttonToNumber(button)
|
|
2248
|
+
}
|
|
2249
|
+
]
|
|
2250
|
+
}
|
|
2251
|
+
]);
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
mouseMove(x, y) {
|
|
2255
|
+
return __async(this, null, function*() {
|
|
2256
|
+
yield this.browser.performActions([
|
|
2257
|
+
{
|
|
2258
|
+
type: "pointer",
|
|
2259
|
+
id: "mouse",
|
|
2260
|
+
parameters: {
|
|
2261
|
+
pointerType: "mouse"
|
|
2262
|
+
},
|
|
2263
|
+
actions: [
|
|
2264
|
+
{
|
|
2265
|
+
type: "pointerMove",
|
|
2266
|
+
duration: 0,
|
|
2267
|
+
x,
|
|
2268
|
+
y
|
|
2269
|
+
}
|
|
2270
|
+
]
|
|
2271
|
+
}
|
|
2272
|
+
]);
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
mouseWheel(deltaX, deltaY, duration = 1e3) {
|
|
2276
|
+
return __async(this, null, function*() {
|
|
2277
|
+
const n = 4;
|
|
2278
|
+
const windowSize = yield this.browser.getWindowSize();
|
|
2279
|
+
const startX = deltaX < 0 ? (n - 1) * (windowSize.width / n) : windowSize.width / n;
|
|
2280
|
+
const startY = deltaY < 0 ? (n - 1) * (windowSize.height / n) : windowSize.height / n;
|
|
2281
|
+
const maxNegativeDeltaX = startX;
|
|
2282
|
+
const maxPositiveDeltaX = (n - 1) * (windowSize.width / n);
|
|
2283
|
+
const maxNegativeDeltaY = startY;
|
|
2284
|
+
const maxPositiveDeltaY = (n - 1) * (windowSize.height / n);
|
|
2285
|
+
deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
|
|
2286
|
+
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
2287
|
+
yield this.browser.performActions([
|
|
2288
|
+
{
|
|
2289
|
+
type: "pointer",
|
|
2290
|
+
id: "finger1",
|
|
2291
|
+
parameters: {
|
|
2292
|
+
pointerType: "touch"
|
|
2293
|
+
},
|
|
2294
|
+
actions: [
|
|
2295
|
+
{
|
|
2296
|
+
type: "pointerMove",
|
|
2297
|
+
duration: 0,
|
|
2298
|
+
x: startX,
|
|
2299
|
+
y: startY
|
|
2300
|
+
},
|
|
2301
|
+
{
|
|
2302
|
+
type: "pointerDown",
|
|
2303
|
+
button: 0
|
|
2304
|
+
},
|
|
2305
|
+
{
|
|
2306
|
+
type: "pause",
|
|
2307
|
+
duration
|
|
2308
|
+
},
|
|
2309
|
+
{
|
|
2310
|
+
type: "pointerMove",
|
|
2311
|
+
duration,
|
|
2312
|
+
origin: "pointer",
|
|
2313
|
+
// Use 'pointer' as the starting point
|
|
2314
|
+
x: deltaX,
|
|
2315
|
+
// X offset relative to the starting point
|
|
2316
|
+
y: deltaY
|
|
2317
|
+
},
|
|
2318
|
+
{
|
|
2319
|
+
type: "pointerUp",
|
|
2320
|
+
button: 0
|
|
2321
|
+
}
|
|
2322
|
+
]
|
|
2323
|
+
}
|
|
2324
|
+
]);
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
destroy() {
|
|
2328
|
+
return __async(this, null, function*() {});
|
|
2329
|
+
}
|
|
2330
|
+
constructor(browser){
|
|
2331
|
+
this.pageType = "appium";
|
|
2332
|
+
this.browser = browser;
|
|
2333
|
+
}
|
|
1903
2334
|
};
|
|
1904
|
-
}
|
|
1905
|
-
async clearInput(element) {
|
|
1906
|
-
if (!element) {
|
|
1907
|
-
return;
|
|
1908
|
-
}
|
|
1909
|
-
const ele = await this.browser.$(element.locator);
|
|
1910
|
-
const blank = " ";
|
|
1911
|
-
await this.keyboardType(blank);
|
|
1912
|
-
await ele.clearValue();
|
|
1913
|
-
}
|
|
1914
|
-
url() {
|
|
1915
|
-
var _a;
|
|
1916
|
-
const platformName = (_a = this.browser.capabilities.platformName) == null ? void 0 : _a.toLowerCase();
|
|
1917
|
-
if (platformName === "ios") {
|
|
1918
|
-
const bundleId = this.browser.capabilities.bundleId;
|
|
1919
|
-
return bundleId;
|
|
1920
|
-
}
|
|
1921
|
-
if (platformName === "android") {
|
|
1922
|
-
const appActivity = this.browser.capabilities.appActivity;
|
|
1923
|
-
return appActivity;
|
|
1924
|
-
}
|
|
1925
|
-
return "";
|
|
1926
|
-
}
|
|
1927
|
-
// Scroll to top element
|
|
1928
|
-
async scrollUntilTop() {
|
|
1929
|
-
const { height } = await this.browser.getWindowSize();
|
|
1930
|
-
await this.mouseWheel(0, height, 100);
|
|
1931
|
-
}
|
|
1932
|
-
// Scroll to bottom element
|
|
1933
|
-
async scrollUntilBottom() {
|
|
1934
|
-
const { height } = await this.browser.getWindowSize();
|
|
1935
|
-
await this.mouseWheel(0, -height, 100);
|
|
1936
|
-
}
|
|
1937
|
-
// Scroll up one screen
|
|
1938
|
-
async scrollUpOneScreen() {
|
|
1939
|
-
const { height } = await this.browser.getWindowSize();
|
|
1940
|
-
await this.mouseWheel(0, height, 1e3);
|
|
1941
|
-
}
|
|
1942
|
-
// Scroll down one screen
|
|
1943
|
-
async scrollDownOneScreen() {
|
|
1944
|
-
const { height } = await this.browser.getWindowSize();
|
|
1945
|
-
await this.mouseWheel(0, -height, 1e3);
|
|
1946
|
-
}
|
|
1947
|
-
async keyboardType(text) {
|
|
1948
|
-
const actions = [];
|
|
1949
|
-
for (const char of text) {
|
|
1950
|
-
actions.push({ type: "keyDown", value: char });
|
|
1951
|
-
actions.push({ type: "keyUp", value: char });
|
|
1952
|
-
}
|
|
1953
|
-
if (!actions.length) {
|
|
1954
|
-
return;
|
|
1955
|
-
}
|
|
1956
|
-
await this.browser.performActions([
|
|
1957
|
-
{
|
|
1958
|
-
type: "key",
|
|
1959
|
-
id: "keyboard",
|
|
1960
|
-
actions
|
|
1961
|
-
}
|
|
1962
|
-
]);
|
|
1963
|
-
}
|
|
1964
|
-
async keyboardPress(key) {
|
|
1965
|
-
await this.browser.performActions([
|
|
1966
|
-
{
|
|
1967
|
-
type: "key",
|
|
1968
|
-
id: "keyboard",
|
|
1969
|
-
actions: [
|
|
1970
|
-
{ type: "keyDown", value: key },
|
|
1971
|
-
{ type: "keyUp", value: key }
|
|
1972
|
-
]
|
|
1973
|
-
}
|
|
1974
|
-
]);
|
|
1975
|
-
}
|
|
1976
|
-
async mouseClick(x, y, button = "left") {
|
|
1977
|
-
await this.mouseMove(x, y);
|
|
1978
|
-
await this.browser.performActions([
|
|
1979
|
-
{
|
|
1980
|
-
type: "pointer",
|
|
1981
|
-
id: "mouse",
|
|
1982
|
-
parameters: { pointerType: "mouse" },
|
|
1983
|
-
actions: [
|
|
1984
|
-
{ type: "pointerMove", duration: 0, x, y },
|
|
1985
|
-
{ type: "pointerDown", button: buttonToNumber(button) },
|
|
1986
|
-
{ type: "pause", duration: 100 },
|
|
1987
|
-
{ type: "pointerUp", button: buttonToNumber(button) }
|
|
1988
|
-
]
|
|
1989
|
-
}
|
|
1990
|
-
]);
|
|
1991
|
-
}
|
|
1992
|
-
async mouseMove(x, y) {
|
|
1993
|
-
await this.browser.performActions([
|
|
1994
|
-
{
|
|
1995
|
-
type: "pointer",
|
|
1996
|
-
id: "mouse",
|
|
1997
|
-
parameters: { pointerType: "mouse" },
|
|
1998
|
-
actions: [{ type: "pointerMove", duration: 0, x, y }]
|
|
1999
|
-
}
|
|
2000
|
-
]);
|
|
2001
|
-
}
|
|
2002
|
-
async mouseWheel(deltaX, deltaY, duration = 1e3) {
|
|
2003
|
-
const n = 4;
|
|
2004
|
-
const windowSize = await this.browser.getWindowSize();
|
|
2005
|
-
const startX = deltaX < 0 ? (n - 1) * (windowSize.width / n) : windowSize.width / n;
|
|
2006
|
-
const startY = deltaY < 0 ? (n - 1) * (windowSize.height / n) : windowSize.height / n;
|
|
2007
|
-
const maxNegativeDeltaX = startX;
|
|
2008
|
-
const maxPositiveDeltaX = (n - 1) * (windowSize.width / n);
|
|
2009
|
-
const maxNegativeDeltaY = startY;
|
|
2010
|
-
const maxPositiveDeltaY = (n - 1) * (windowSize.height / n);
|
|
2011
|
-
deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
|
|
2012
|
-
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
2013
|
-
await this.browser.performActions([
|
|
2014
|
-
{
|
|
2015
|
-
type: "pointer",
|
|
2016
|
-
id: "finger1",
|
|
2017
|
-
parameters: { pointerType: "touch" },
|
|
2018
|
-
actions: [
|
|
2019
|
-
{ type: "pointerMove", duration: 0, x: startX, y: startY },
|
|
2020
|
-
{ type: "pointerDown", button: 0 },
|
|
2021
|
-
{ type: "pause", duration },
|
|
2022
|
-
{
|
|
2023
|
-
type: "pointerMove",
|
|
2024
|
-
duration,
|
|
2025
|
-
origin: "pointer",
|
|
2026
|
-
// Use 'pointer' as the starting point
|
|
2027
|
-
x: deltaX,
|
|
2028
|
-
// X offset relative to the starting point
|
|
2029
|
-
y: deltaY
|
|
2030
|
-
// Y offset relative to the starting point
|
|
2031
|
-
},
|
|
2032
|
-
{ type: "pointerUp", button: 0 }
|
|
2033
|
-
]
|
|
2034
|
-
}
|
|
2035
|
-
]);
|
|
2036
|
-
}
|
|
2037
|
-
};
|
|
2038
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
2039
|
-
0 && (module.exports = {
|
|
2040
|
-
AppiumAgent,
|
|
2041
|
-
AppiumPage
|
|
2042
2335
|
});
|
|
2043
|
-
/*! Bundled license information:
|
|
2336
|
+
/*! Bundled license information:
|
|
2044
2337
|
|
|
2045
2338
|
js-sha256/src/sha256.js:
|
|
2046
2339
|
(**
|
|
@@ -2051,4 +2344,4 @@ js-sha256/src/sha256.js:
|
|
|
2051
2344
|
* @copyright Chen, Yi-Cyuan 2014-2024
|
|
2052
2345
|
* @license MIT
|
|
2053
2346
|
*)
|
|
2054
|
-
*/
|
|
2347
|
+
*/
|