@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/es/appium.js
CHANGED
|
@@ -1,2061 +1,2339 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
25
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
26
|
-
}) : x)(function(x) {
|
|
27
|
-
if (typeof require !== "undefined")
|
|
28
|
-
return require.apply(this, arguments);
|
|
29
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
30
|
-
});
|
|
31
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
32
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
33
|
-
};
|
|
34
|
-
var __copyProps = (to, from, except, desc) => {
|
|
35
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
36
|
-
for (let key of __getOwnPropNames(from))
|
|
37
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
38
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
39
|
-
}
|
|
40
|
-
return to;
|
|
41
|
-
};
|
|
42
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
43
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
44
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
45
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
46
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
47
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
48
|
-
mod
|
|
49
|
-
));
|
|
50
|
-
|
|
51
|
-
// ../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js
|
|
52
|
-
var require_dayjs_min = __commonJS({
|
|
53
|
-
"../../node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js"(exports, module) {
|
|
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) {
|
|
54
18
|
"use strict";
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}(exports, function() {
|
|
58
|
-
"use strict";
|
|
59
|
-
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) {
|
|
60
|
-
var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
|
|
61
|
-
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
|
|
62
|
-
} }, m = function(t2, e2, n2) {
|
|
63
|
-
var r2 = String(t2);
|
|
64
|
-
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
|
|
65
|
-
}, v = { s: m, z: function(t2) {
|
|
66
|
-
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
|
|
67
|
-
return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
|
|
68
|
-
}, m: function t2(e2, n2) {
|
|
69
|
-
if (e2.date() < n2.date())
|
|
70
|
-
return -t2(n2, e2);
|
|
71
|
-
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);
|
|
72
|
-
return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
|
|
73
|
-
}, a: function(t2) {
|
|
74
|
-
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
|
75
|
-
}, p: function(t2) {
|
|
76
|
-
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$/, "");
|
|
77
|
-
}, u: function(t2) {
|
|
78
|
-
return void 0 === t2;
|
|
79
|
-
} }, g = "en", D = {};
|
|
80
|
-
D[g] = M;
|
|
81
|
-
var p = "$isDayjsObject", S = function(t2) {
|
|
82
|
-
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
83
|
-
}, w = function t2(e2, n2, r2) {
|
|
84
|
-
var i2;
|
|
85
|
-
if (!e2)
|
|
86
|
-
return g;
|
|
87
|
-
if ("string" == typeof e2) {
|
|
88
|
-
var s2 = e2.toLowerCase();
|
|
89
|
-
D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
|
|
90
|
-
var u2 = e2.split("-");
|
|
91
|
-
if (!i2 && u2.length > 1)
|
|
92
|
-
return t2(u2[0]);
|
|
93
|
-
} else {
|
|
94
|
-
var a2 = e2.name;
|
|
95
|
-
D[a2] = e2, i2 = a2;
|
|
96
|
-
}
|
|
97
|
-
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
98
|
-
}, O = function(t2, e2) {
|
|
99
|
-
if (S(t2))
|
|
100
|
-
return t2.clone();
|
|
101
|
-
var n2 = "object" == typeof e2 ? e2 : {};
|
|
102
|
-
return n2.date = t2, n2.args = arguments, new _(n2);
|
|
103
|
-
}, b = v;
|
|
104
|
-
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
105
|
-
return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
|
|
106
|
-
};
|
|
107
|
-
var _ = function() {
|
|
108
|
-
function M2(t2) {
|
|
109
|
-
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
110
|
-
}
|
|
111
|
-
var m2 = M2.prototype;
|
|
112
|
-
return m2.parse = function(t2) {
|
|
113
|
-
this.$d = function(t3) {
|
|
114
|
-
var e2 = t3.date, n2 = t3.utc;
|
|
115
|
-
if (null === e2)
|
|
116
|
-
return /* @__PURE__ */ new Date(NaN);
|
|
117
|
-
if (b.u(e2))
|
|
118
|
-
return /* @__PURE__ */ new Date();
|
|
119
|
-
if (e2 instanceof Date)
|
|
120
|
-
return new Date(e2);
|
|
121
|
-
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
|
|
122
|
-
var r2 = e2.match($);
|
|
123
|
-
if (r2) {
|
|
124
|
-
var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
|
125
|
-
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);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return new Date(e2);
|
|
129
|
-
}(t2), this.init();
|
|
130
|
-
}, m2.init = function() {
|
|
131
|
-
var t2 = this.$d;
|
|
132
|
-
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();
|
|
133
|
-
}, m2.$utils = function() {
|
|
134
|
-
return b;
|
|
135
|
-
}, m2.isValid = function() {
|
|
136
|
-
return !(this.$d.toString() === l);
|
|
137
|
-
}, m2.isSame = function(t2, e2) {
|
|
138
|
-
var n2 = O(t2);
|
|
139
|
-
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
|
|
140
|
-
}, m2.isAfter = function(t2, e2) {
|
|
141
|
-
return O(t2) < this.startOf(e2);
|
|
142
|
-
}, m2.isBefore = function(t2, e2) {
|
|
143
|
-
return this.endOf(e2) < O(t2);
|
|
144
|
-
}, m2.$g = function(t2, e2, n2) {
|
|
145
|
-
return b.u(t2) ? this[e2] : this.set(n2, t2);
|
|
146
|
-
}, m2.unix = function() {
|
|
147
|
-
return Math.floor(this.valueOf() / 1e3);
|
|
148
|
-
}, m2.valueOf = function() {
|
|
149
|
-
return this.$d.getTime();
|
|
150
|
-
}, m2.startOf = function(t2, e2) {
|
|
151
|
-
var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
|
|
152
|
-
var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
|
|
153
|
-
return r2 ? i2 : i2.endOf(a);
|
|
154
|
-
}, $2 = function(t3, e3) {
|
|
155
|
-
return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
|
|
156
|
-
}, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
|
157
|
-
switch (f2) {
|
|
158
|
-
case h:
|
|
159
|
-
return r2 ? l2(1, 0) : l2(31, 11);
|
|
160
|
-
case c:
|
|
161
|
-
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
162
|
-
case o:
|
|
163
|
-
var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
164
|
-
return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
|
165
|
-
case a:
|
|
166
|
-
case d:
|
|
167
|
-
return $2(v2 + "Hours", 0);
|
|
168
|
-
case u:
|
|
169
|
-
return $2(v2 + "Minutes", 1);
|
|
170
|
-
case s:
|
|
171
|
-
return $2(v2 + "Seconds", 2);
|
|
172
|
-
case i:
|
|
173
|
-
return $2(v2 + "Milliseconds", 3);
|
|
174
|
-
default:
|
|
175
|
-
return this.clone();
|
|
176
|
-
}
|
|
177
|
-
}, m2.endOf = function(t2) {
|
|
178
|
-
return this.startOf(t2, false);
|
|
179
|
-
}, m2.$set = function(t2, e2) {
|
|
180
|
-
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;
|
|
181
|
-
if (o2 === c || o2 === h) {
|
|
182
|
-
var y2 = this.clone().set(d, 1);
|
|
183
|
-
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
|
184
|
-
} else
|
|
185
|
-
l2 && this.$d[l2]($2);
|
|
186
|
-
return this.init(), this;
|
|
187
|
-
}, m2.set = function(t2, e2) {
|
|
188
|
-
return this.clone().$set(t2, e2);
|
|
189
|
-
}, m2.get = function(t2) {
|
|
190
|
-
return this[b.p(t2)]();
|
|
191
|
-
}, m2.add = function(r2, f2) {
|
|
192
|
-
var d2, l2 = this;
|
|
193
|
-
r2 = Number(r2);
|
|
194
|
-
var $2 = b.p(f2), y2 = function(t2) {
|
|
195
|
-
var e2 = O(l2);
|
|
196
|
-
return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
|
|
197
|
-
};
|
|
198
|
-
if ($2 === c)
|
|
199
|
-
return this.set(c, this.$M + r2);
|
|
200
|
-
if ($2 === h)
|
|
201
|
-
return this.set(h, this.$y + r2);
|
|
202
|
-
if ($2 === a)
|
|
203
|
-
return y2(1);
|
|
204
|
-
if ($2 === o)
|
|
205
|
-
return y2(7);
|
|
206
|
-
var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
|
207
|
-
return b.w(m3, this);
|
|
208
|
-
}, m2.subtract = function(t2, e2) {
|
|
209
|
-
return this.add(-1 * t2, e2);
|
|
210
|
-
}, m2.format = function(t2) {
|
|
211
|
-
var e2 = this, n2 = this.$locale();
|
|
212
|
-
if (!this.isValid())
|
|
213
|
-
return n2.invalidDate || l;
|
|
214
|
-
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) {
|
|
215
|
-
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
|
|
216
|
-
}, d2 = function(t3) {
|
|
217
|
-
return b.s(s2 % 12 || 12, t3, "0");
|
|
218
|
-
}, $2 = f2 || function(t3, e3, n3) {
|
|
219
|
-
var r3 = t3 < 12 ? "AM" : "PM";
|
|
220
|
-
return n3 ? r3.toLowerCase() : r3;
|
|
221
|
-
};
|
|
222
|
-
return r2.replace(y, function(t3, r3) {
|
|
223
|
-
return r3 || function(t4) {
|
|
224
|
-
switch (t4) {
|
|
225
|
-
case "YY":
|
|
226
|
-
return String(e2.$y).slice(-2);
|
|
227
|
-
case "YYYY":
|
|
228
|
-
return b.s(e2.$y, 4, "0");
|
|
229
|
-
case "M":
|
|
230
|
-
return a2 + 1;
|
|
231
|
-
case "MM":
|
|
232
|
-
return b.s(a2 + 1, 2, "0");
|
|
233
|
-
case "MMM":
|
|
234
|
-
return h2(n2.monthsShort, a2, c2, 3);
|
|
235
|
-
case "MMMM":
|
|
236
|
-
return h2(c2, a2);
|
|
237
|
-
case "D":
|
|
238
|
-
return e2.$D;
|
|
239
|
-
case "DD":
|
|
240
|
-
return b.s(e2.$D, 2, "0");
|
|
241
|
-
case "d":
|
|
242
|
-
return String(e2.$W);
|
|
243
|
-
case "dd":
|
|
244
|
-
return h2(n2.weekdaysMin, e2.$W, o2, 2);
|
|
245
|
-
case "ddd":
|
|
246
|
-
return h2(n2.weekdaysShort, e2.$W, o2, 3);
|
|
247
|
-
case "dddd":
|
|
248
|
-
return o2[e2.$W];
|
|
249
|
-
case "H":
|
|
250
|
-
return String(s2);
|
|
251
|
-
case "HH":
|
|
252
|
-
return b.s(s2, 2, "0");
|
|
253
|
-
case "h":
|
|
254
|
-
return d2(1);
|
|
255
|
-
case "hh":
|
|
256
|
-
return d2(2);
|
|
257
|
-
case "a":
|
|
258
|
-
return $2(s2, u2, true);
|
|
259
|
-
case "A":
|
|
260
|
-
return $2(s2, u2, false);
|
|
261
|
-
case "m":
|
|
262
|
-
return String(u2);
|
|
263
|
-
case "mm":
|
|
264
|
-
return b.s(u2, 2, "0");
|
|
265
|
-
case "s":
|
|
266
|
-
return String(e2.$s);
|
|
267
|
-
case "ss":
|
|
268
|
-
return b.s(e2.$s, 2, "0");
|
|
269
|
-
case "SSS":
|
|
270
|
-
return b.s(e2.$ms, 3, "0");
|
|
271
|
-
case "Z":
|
|
272
|
-
return i2;
|
|
273
|
-
}
|
|
274
|
-
return null;
|
|
275
|
-
}(t3) || i2.replace(":", "");
|
|
276
|
-
});
|
|
277
|
-
}, m2.utcOffset = function() {
|
|
278
|
-
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
279
|
-
}, m2.diff = function(r2, d2, l2) {
|
|
280
|
-
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
|
|
281
|
-
return b.m(y2, m3);
|
|
282
|
-
};
|
|
283
|
-
switch (M3) {
|
|
284
|
-
case h:
|
|
285
|
-
$2 = D2() / 12;
|
|
286
|
-
break;
|
|
287
|
-
case c:
|
|
288
|
-
$2 = D2();
|
|
289
|
-
break;
|
|
290
|
-
case f:
|
|
291
|
-
$2 = D2() / 3;
|
|
292
|
-
break;
|
|
293
|
-
case o:
|
|
294
|
-
$2 = (g2 - v2) / 6048e5;
|
|
295
|
-
break;
|
|
296
|
-
case a:
|
|
297
|
-
$2 = (g2 - v2) / 864e5;
|
|
298
|
-
break;
|
|
299
|
-
case u:
|
|
300
|
-
$2 = g2 / n;
|
|
301
|
-
break;
|
|
302
|
-
case s:
|
|
303
|
-
$2 = g2 / e;
|
|
304
|
-
break;
|
|
305
|
-
case i:
|
|
306
|
-
$2 = g2 / t;
|
|
307
|
-
break;
|
|
308
|
-
default:
|
|
309
|
-
$2 = g2;
|
|
310
|
-
}
|
|
311
|
-
return l2 ? $2 : b.a($2);
|
|
312
|
-
}, m2.daysInMonth = function() {
|
|
313
|
-
return this.endOf(c).$D;
|
|
314
|
-
}, m2.$locale = function() {
|
|
315
|
-
return D[this.$L];
|
|
316
|
-
}, m2.locale = function(t2, e2) {
|
|
317
|
-
if (!t2)
|
|
318
|
-
return this.$L;
|
|
319
|
-
var n2 = this.clone(), r2 = w(t2, e2, true);
|
|
320
|
-
return r2 && (n2.$L = r2), n2;
|
|
321
|
-
}, m2.clone = function() {
|
|
322
|
-
return b.w(this.$d, this);
|
|
323
|
-
}, m2.toDate = function() {
|
|
324
|
-
return new Date(this.valueOf());
|
|
325
|
-
}, m2.toJSON = function() {
|
|
326
|
-
return this.isValid() ? this.toISOString() : null;
|
|
327
|
-
}, m2.toISOString = function() {
|
|
328
|
-
return this.$d.toISOString();
|
|
329
|
-
}, m2.toString = function() {
|
|
330
|
-
return this.$d.toUTCString();
|
|
331
|
-
}, M2;
|
|
332
|
-
}(), k = _.prototype;
|
|
333
|
-
return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
|
|
334
|
-
k[t2[1]] = function(e2) {
|
|
335
|
-
return this.$g(e2, t2[0], t2[1]);
|
|
336
|
-
};
|
|
337
|
-
}), O.extend = function(t2, e2) {
|
|
338
|
-
return t2.$i || (t2(e2, _, O), t2.$i = true), O;
|
|
339
|
-
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
340
|
-
return O(1e3 * t2);
|
|
341
|
-
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
19
|
+
Object.defineProperty(exports, "__esModule", {
|
|
20
|
+
value: true
|
|
342
21
|
});
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
root = self;
|
|
364
|
-
}
|
|
365
|
-
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module === "object" && module.exports;
|
|
366
|
-
var AMD = typeof define === "function" && define.amd;
|
|
367
|
-
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
|
|
368
|
-
var HEX_CHARS = "0123456789abcdef".split("");
|
|
369
|
-
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
370
|
-
var SHIFT = [24, 16, 8, 0];
|
|
371
|
-
var K = [
|
|
372
|
-
1116352408,
|
|
373
|
-
1899447441,
|
|
374
|
-
3049323471,
|
|
375
|
-
3921009573,
|
|
376
|
-
961987163,
|
|
377
|
-
1508970993,
|
|
378
|
-
2453635748,
|
|
379
|
-
2870763221,
|
|
380
|
-
3624381080,
|
|
381
|
-
310598401,
|
|
382
|
-
607225278,
|
|
383
|
-
1426881987,
|
|
384
|
-
1925078388,
|
|
385
|
-
2162078206,
|
|
386
|
-
2614888103,
|
|
387
|
-
3248222580,
|
|
388
|
-
3835390401,
|
|
389
|
-
4022224774,
|
|
390
|
-
264347078,
|
|
391
|
-
604807628,
|
|
392
|
-
770255983,
|
|
393
|
-
1249150122,
|
|
394
|
-
1555081692,
|
|
395
|
-
1996064986,
|
|
396
|
-
2554220882,
|
|
397
|
-
2821834349,
|
|
398
|
-
2952996808,
|
|
399
|
-
3210313671,
|
|
400
|
-
3336571891,
|
|
401
|
-
3584528711,
|
|
402
|
-
113926993,
|
|
403
|
-
338241895,
|
|
404
|
-
666307205,
|
|
405
|
-
773529912,
|
|
406
|
-
1294757372,
|
|
407
|
-
1396182291,
|
|
408
|
-
1695183700,
|
|
409
|
-
1986661051,
|
|
410
|
-
2177026350,
|
|
411
|
-
2456956037,
|
|
412
|
-
2730485921,
|
|
413
|
-
2820302411,
|
|
414
|
-
3259730800,
|
|
415
|
-
3345764771,
|
|
416
|
-
3516065817,
|
|
417
|
-
3600352804,
|
|
418
|
-
4094571909,
|
|
419
|
-
275423344,
|
|
420
|
-
430227734,
|
|
421
|
-
506948616,
|
|
422
|
-
659060556,
|
|
423
|
-
883997877,
|
|
424
|
-
958139571,
|
|
425
|
-
1322822218,
|
|
426
|
-
1537002063,
|
|
427
|
-
1747873779,
|
|
428
|
-
1955562222,
|
|
429
|
-
2024104815,
|
|
430
|
-
2227730452,
|
|
431
|
-
2361852424,
|
|
432
|
-
2428436474,
|
|
433
|
-
2756734187,
|
|
434
|
-
3204031479,
|
|
435
|
-
3329325298
|
|
436
|
-
];
|
|
437
|
-
var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
|
|
438
|
-
var blocks = [];
|
|
439
|
-
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
|
|
440
|
-
Array.isArray = function(obj) {
|
|
441
|
-
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
|
445
|
-
ArrayBuffer.isView = function(obj) {
|
|
446
|
-
return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
var createOutputMethod = function(outputType, is224) {
|
|
450
|
-
return function(message) {
|
|
451
|
-
return new Sha256(is224, true).update(message)[outputType]();
|
|
452
|
-
};
|
|
453
|
-
};
|
|
454
|
-
var createMethod = function(is224) {
|
|
455
|
-
var method = createOutputMethod("hex", is224);
|
|
456
|
-
if (NODE_JS) {
|
|
457
|
-
method = nodeWrap(method, is224);
|
|
458
|
-
}
|
|
459
|
-
method.create = function() {
|
|
460
|
-
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
|
|
461
42
|
};
|
|
462
|
-
|
|
463
|
-
|
|
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
|
|
464
67
|
};
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
var algorithm = is224 ? "sha224" : "sha256";
|
|
475
|
-
var bufferFrom;
|
|
476
|
-
if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|
|
477
|
-
bufferFrom = Buffer2.from;
|
|
478
|
-
} else {
|
|
479
|
-
bufferFrom = function(message) {
|
|
480
|
-
return new Buffer2(message);
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
var nodeMethod = function(message) {
|
|
484
|
-
if (typeof message === "string") {
|
|
485
|
-
return crypto.createHash(algorithm).update(message, "utf8").digest("hex");
|
|
486
|
-
} else {
|
|
487
|
-
if (message === null || message === void 0) {
|
|
488
|
-
throw new Error(ERROR);
|
|
489
|
-
} else if (message.constructor === ArrayBuffer) {
|
|
490
|
-
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
|
+
}
|
|
491
77
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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;
|
|
513
119
|
};
|
|
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
|
-
|
|
799
|
-
|
|
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();
|
|
800
1088
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
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
|
+
}));
|
|
813
1148
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
if (key.length > 64) {
|
|
819
|
-
key = new Sha256(is224, true).update(key).array();
|
|
820
|
-
}
|
|
821
|
-
var oKeyPad = [], iKeyPad = [];
|
|
822
|
-
for (i = 0; i < 64; ++i) {
|
|
823
|
-
var b = key[i] || 0;
|
|
824
|
-
oKeyPad[i] = 92 ^ b;
|
|
825
|
-
iKeyPad[i] = 54 ^ b;
|
|
826
|
-
}
|
|
827
|
-
Sha256.call(this, is224, sharedMemory);
|
|
828
|
-
this.update(iKeyPad);
|
|
829
|
-
this.oKeyPad = oKeyPad;
|
|
830
|
-
this.inner = true;
|
|
831
|
-
this.sharedMemory = sharedMemory;
|
|
832
|
-
}
|
|
833
|
-
HmacSha256.prototype = new Sha256();
|
|
834
|
-
HmacSha256.prototype.finalize = function() {
|
|
835
|
-
Sha256.prototype.finalize.call(this);
|
|
836
|
-
if (this.inner) {
|
|
837
|
-
this.inner = false;
|
|
838
|
-
var innerHash = this.array();
|
|
839
|
-
Sha256.call(this, this.is224, this.sharedMemory);
|
|
840
|
-
this.update(this.oKeyPad);
|
|
841
|
-
this.update(innerHash);
|
|
842
|
-
Sha256.prototype.finalize.call(this);
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
var exports2 = createMethod();
|
|
846
|
-
exports2.sha256 = exports2;
|
|
847
|
-
exports2.sha224 = createMethod(true);
|
|
848
|
-
exports2.sha256.hmac = createHmacMethod();
|
|
849
|
-
exports2.sha224.hmac = createHmacMethod(true);
|
|
850
|
-
if (COMMON_JS) {
|
|
851
|
-
module.exports = exports2;
|
|
852
|
-
} else {
|
|
853
|
-
root.sha256 = exports2.sha256;
|
|
854
|
-
root.sha224 = exports2.sha224;
|
|
855
|
-
if (AMD) {
|
|
856
|
-
define(function() {
|
|
857
|
-
return exports2;
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
})();
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
// src/common/agent.ts
|
|
866
|
-
import {
|
|
867
|
-
groupedActionDumpFileExt,
|
|
868
|
-
stringifyDumpData as stringifyDumpData2,
|
|
869
|
-
writeLogFile as writeLogFile2
|
|
870
|
-
} from "@midscene/core/utils";
|
|
871
|
-
|
|
872
|
-
// src/common/tasks.ts
|
|
873
|
-
import assert2 from "assert";
|
|
874
|
-
import {
|
|
875
|
-
Executor,
|
|
876
|
-
Insight,
|
|
877
|
-
plan
|
|
878
|
-
} from "@midscene/core";
|
|
879
|
-
import { sleep } from "@midscene/core/utils";
|
|
880
|
-
import { base64Encoded as base64Encoded2 } from "@midscene/shared/img";
|
|
881
|
-
|
|
882
|
-
// src/common/task-cache.ts
|
|
883
|
-
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
884
|
-
import { join } from "path";
|
|
885
|
-
import {
|
|
886
|
-
getLogDirByType,
|
|
887
|
-
stringifyDumpData,
|
|
888
|
-
writeLogFile
|
|
889
|
-
} from "@midscene/core/utils";
|
|
890
|
-
import { getMidscenePkgInfo } from "@midscene/shared/fs";
|
|
891
|
-
|
|
892
|
-
// src/common/utils.ts
|
|
893
|
-
var import_dayjs = __toESM(require_dayjs_min());
|
|
894
|
-
import assert from "assert";
|
|
895
|
-
import { randomUUID } from "crypto";
|
|
896
|
-
import { readFileSync } from "fs";
|
|
897
|
-
import path from "path";
|
|
898
|
-
import { NodeType } from "@midscene/shared/constants";
|
|
899
|
-
import { findNearestPackageJson } from "@midscene/shared/fs";
|
|
900
|
-
import {
|
|
901
|
-
base64Encoded,
|
|
902
|
-
imageInfoOfBase64
|
|
903
|
-
} from "@midscene/shared/img";
|
|
904
|
-
import { compositeElementInfoImg } from "@midscene/shared/img";
|
|
905
|
-
|
|
906
|
-
// src/web-element.ts
|
|
907
|
-
var WebElementInfo = class {
|
|
908
|
-
constructor({
|
|
909
|
-
content,
|
|
910
|
-
rect,
|
|
911
|
-
page,
|
|
912
|
-
locator,
|
|
913
|
-
id,
|
|
914
|
-
attributes,
|
|
915
|
-
indexId
|
|
916
|
-
}) {
|
|
917
|
-
this.content = content;
|
|
918
|
-
this.rect = rect;
|
|
919
|
-
this.center = [
|
|
920
|
-
Math.floor(rect.left + rect.width / 2),
|
|
921
|
-
Math.floor(rect.top + rect.height / 2)
|
|
922
|
-
];
|
|
923
|
-
this.page = page;
|
|
924
|
-
this.locator = locator;
|
|
925
|
-
this.id = id;
|
|
926
|
-
this.attributes = attributes;
|
|
927
|
-
this.indexId = indexId;
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
// src/common/utils.ts
|
|
932
|
-
async function parseContextFromWebPage(page, _opt) {
|
|
933
|
-
assert(page, "page is required");
|
|
934
|
-
if (page._forceUsePageContext) {
|
|
935
|
-
return await page._forceUsePageContext();
|
|
936
|
-
}
|
|
937
|
-
const url = page.url();
|
|
938
|
-
const file = await page.screenshot();
|
|
939
|
-
const screenshotBase64 = base64Encoded(file);
|
|
940
|
-
const captureElementSnapshot = await page.getElementInfos();
|
|
941
|
-
const elementsInfo = await alignElements(captureElementSnapshot, page);
|
|
942
|
-
const elementsPositionInfoWithoutText = elementsInfo.filter((elementInfo) => {
|
|
943
|
-
if (elementInfo.attributes.nodeType === NodeType.TEXT) {
|
|
944
|
-
return false;
|
|
1149
|
+
return textsAligned;
|
|
1150
|
+
});
|
|
945
1151
|
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
const screenshotBase64WithElementMarker = await compositeElementInfoImg({
|
|
950
|
-
inputImgBase64: screenshotBase64.split(";base64,").pop(),
|
|
951
|
-
elementsPositionInfo: elementsPositionInfoWithoutText
|
|
952
|
-
});
|
|
953
|
-
return {
|
|
954
|
-
content: elementsInfo,
|
|
955
|
-
size,
|
|
956
|
-
screenshotBase64,
|
|
957
|
-
screenshotBase64WithElementMarker: `data:image/png;base64,${screenshotBase64WithElementMarker}`,
|
|
958
|
-
url
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
var sizeThreshold = 3;
|
|
962
|
-
async function alignElements(elements, page) {
|
|
963
|
-
const validElements = elements.filter((item) => {
|
|
964
|
-
return item.rect.height >= sizeThreshold && item.rect.width >= sizeThreshold;
|
|
965
|
-
});
|
|
966
|
-
const textsAligned = [];
|
|
967
|
-
for (const item of validElements) {
|
|
968
|
-
const { rect, id, content, attributes, locator, indexId } = item;
|
|
969
|
-
textsAligned.push(
|
|
970
|
-
new WebElementInfo({
|
|
971
|
-
rect,
|
|
972
|
-
locator,
|
|
973
|
-
id,
|
|
974
|
-
content,
|
|
975
|
-
attributes,
|
|
976
|
-
page,
|
|
977
|
-
indexId
|
|
978
|
-
})
|
|
979
|
-
);
|
|
980
|
-
}
|
|
981
|
-
return textsAligned;
|
|
982
|
-
}
|
|
983
|
-
function reportFileName(tag = "web") {
|
|
984
|
-
const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
|
|
985
|
-
return `${tag}-${dateTimeInFileName}`;
|
|
986
|
-
}
|
|
987
|
-
function printReportMsg(filepath) {
|
|
988
|
-
console.log("Midscene - report file updated:", filepath);
|
|
989
|
-
}
|
|
990
|
-
function getCurrentExecutionFile(trace) {
|
|
991
|
-
const error = new Error();
|
|
992
|
-
const stackTrace = trace || error.stack;
|
|
993
|
-
const pkgDir = process.cwd() || "";
|
|
994
|
-
if (stackTrace) {
|
|
995
|
-
const stackLines = stackTrace.split("\n");
|
|
996
|
-
for (const line of stackLines) {
|
|
997
|
-
if (line.includes(".spec.") || line.includes(".test.") || line.includes(".ts") || line.includes(".js")) {
|
|
998
|
-
const match = line.match(/(?:at\s+)?(.*?\.(?:spec|test)\.[jt]s)/);
|
|
999
|
-
if (match == null ? void 0 : match[1]) {
|
|
1000
|
-
const targetFileName = match[1].replace(pkgDir, "").trim().replace("at ", "");
|
|
1001
|
-
return targetFileName;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1152
|
+
function reportFileName(tag = "web") {
|
|
1153
|
+
const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
|
|
1154
|
+
return `${tag}-${dateTimeInFileName}`;
|
|
1004
1155
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
}
|
|
1008
|
-
var testFileIndex = /* @__PURE__ */ new Map();
|
|
1009
|
-
function generateCacheId(fileName) {
|
|
1010
|
-
let taskFile = fileName || getCurrentExecutionFile();
|
|
1011
|
-
if (!taskFile) {
|
|
1012
|
-
taskFile = randomUUID();
|
|
1013
|
-
console.warn(
|
|
1014
|
-
"Midscene - using random UUID for cache id. Cache may be invalid."
|
|
1015
|
-
);
|
|
1016
|
-
}
|
|
1017
|
-
if (testFileIndex.has(taskFile)) {
|
|
1018
|
-
const currentIndex = testFileIndex.get(taskFile);
|
|
1019
|
-
if (currentIndex !== void 0) {
|
|
1020
|
-
testFileIndex.set(taskFile, currentIndex + 1);
|
|
1156
|
+
function printReportMsg(filepath) {
|
|
1157
|
+
console.log("Midscene - report file updated:", filepath);
|
|
1021
1158
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
getCacheGroupByPrompt(aiActionPrompt) {
|
|
1041
|
-
const { aiTasks = [] } = this.cache || { aiTasks: [] };
|
|
1042
|
-
const index = aiTasks.findIndex((item) => item.prompt === aiActionPrompt);
|
|
1043
|
-
const newCacheGroup = [];
|
|
1044
|
-
this.newCache.aiTasks.push({
|
|
1045
|
-
prompt: aiActionPrompt,
|
|
1046
|
-
tasks: newCacheGroup
|
|
1047
|
-
});
|
|
1048
|
-
return {
|
|
1049
|
-
readCache: (pageContext, type, actionPrompt) => {
|
|
1050
|
-
if (index === -1) {
|
|
1051
|
-
return false;
|
|
1052
|
-
}
|
|
1053
|
-
if (type === "plan") {
|
|
1054
|
-
return this.readCache(
|
|
1055
|
-
pageContext,
|
|
1056
|
-
type,
|
|
1057
|
-
actionPrompt,
|
|
1058
|
-
aiTasks[index].tasks
|
|
1059
|
-
);
|
|
1060
|
-
}
|
|
1061
|
-
return this.readCache(
|
|
1062
|
-
pageContext,
|
|
1063
|
-
type,
|
|
1064
|
-
actionPrompt,
|
|
1065
|
-
aiTasks[index].tasks
|
|
1066
|
-
);
|
|
1067
|
-
},
|
|
1068
|
-
saveCache: (cache) => {
|
|
1069
|
-
newCacheGroup.push(cache);
|
|
1070
|
-
this.writeCacheToFile();
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
readCache(pageContext, type, userPrompt, cacheGroup) {
|
|
1075
|
-
var _a;
|
|
1076
|
-
if (cacheGroup.length > 0) {
|
|
1077
|
-
const index = cacheGroup.findIndex((item) => item.prompt === userPrompt);
|
|
1078
|
-
if (index === -1) {
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1081
|
-
const taskRes = cacheGroup.splice(index, 1)[0];
|
|
1082
|
-
if ((taskRes == null ? void 0 : taskRes.type) === "locate" && !((_a = taskRes.response) == null ? void 0 : _a.elements.every((element) => {
|
|
1083
|
-
const findIndex = pageContext.content.findIndex(
|
|
1084
|
-
(contentElement) => contentElement.id === element.id
|
|
1085
|
-
);
|
|
1086
|
-
if (findIndex === -1) {
|
|
1087
|
-
return false;
|
|
1088
|
-
}
|
|
1089
|
-
return true;
|
|
1090
|
-
}))) {
|
|
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
|
+
}
|
|
1091
1175
|
return false;
|
|
1092
|
-
}
|
|
1093
|
-
if (taskRes && taskRes.type === type && taskRes.prompt === userPrompt && this.pageContextEqual(taskRes.pageContext, pageContext)) {
|
|
1094
|
-
return taskRes.response;
|
|
1095
|
-
}
|
|
1096
1176
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
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
|
+
/**
|
|
1103
1249
|
* Generate task cache data.
|
|
1104
1250
|
* This method is mainly used to create or obtain some cached data for tasks, and it returns a new cache object.
|
|
1105
1251
|
* In the cache object, it may contain task-related information, states, or other necessary data.
|
|
1106
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.
|
|
1107
1253
|
* @returns {Object} Returns a new cache object, which may include task cache data.
|
|
1108
|
-
*/
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
const midscenePkgInfo = getMidscenePkgInfo(__dirname);
|
|
1130
|
-
writeLogFile({
|
|
1131
|
-
fileName: `${this.cacheId}`,
|
|
1132
|
-
fileExt: "json",
|
|
1133
|
-
fileContent: stringifyDumpData(
|
|
1134
|
-
__spreadValues({
|
|
1135
|
-
pkgName: midscenePkgInfo.name,
|
|
1136
|
-
pkgVersion: midscenePkgInfo.version,
|
|
1137
|
-
cacheId: this.cacheId
|
|
1138
|
-
}, this.newCache),
|
|
1139
|
-
2
|
|
1140
|
-
),
|
|
1141
|
-
type: "cache"
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
// src/common/tasks.ts
|
|
1147
|
-
var PageTaskExecutor = class {
|
|
1148
|
-
constructor(page, opts) {
|
|
1149
|
-
this.page = page;
|
|
1150
|
-
this.insight = new Insight(async () => {
|
|
1151
|
-
return await parseContextFromWebPage(page);
|
|
1152
|
-
});
|
|
1153
|
-
this.taskCache = new TaskCache({
|
|
1154
|
-
fileName: opts == null ? void 0 : opts.cacheId
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
async recordScreenshot(timing) {
|
|
1158
|
-
const file = await this.page.screenshot();
|
|
1159
|
-
const item = {
|
|
1160
|
-
type: "screenshot",
|
|
1161
|
-
ts: Date.now(),
|
|
1162
|
-
screenshot: base64Encoded2(file),
|
|
1163
|
-
timing
|
|
1164
|
-
};
|
|
1165
|
-
return item;
|
|
1166
|
-
}
|
|
1167
|
-
wrapExecutorWithScreenshot(taskApply) {
|
|
1168
|
-
const taskWithScreenshot = __spreadProps(__spreadValues({}, taskApply), {
|
|
1169
|
-
executor: async (param, context, ...args) => {
|
|
1170
|
-
const recorder = [];
|
|
1171
|
-
const { task } = context;
|
|
1172
|
-
task.recorder = recorder;
|
|
1173
|
-
const shot = await this.recordScreenshot(`before ${task.type}`);
|
|
1174
|
-
recorder.push(shot);
|
|
1175
|
-
const result = await taskApply.executor(param, context, ...args);
|
|
1176
|
-
if (taskApply.type === "Action") {
|
|
1177
|
-
await sleep(1e3);
|
|
1178
|
-
const shot2 = await this.recordScreenshot("after Action");
|
|
1179
|
-
recorder.push(shot2);
|
|
1180
|
-
}
|
|
1181
|
-
return result;
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
return taskWithScreenshot;
|
|
1185
|
-
}
|
|
1186
|
-
async convertPlanToExecutable(plans, cacheGroup) {
|
|
1187
|
-
const tasks = plans.map((plan2) => {
|
|
1188
|
-
if (plan2.type === "Locate") {
|
|
1189
|
-
const taskFind = {
|
|
1190
|
-
type: "Insight",
|
|
1191
|
-
subType: "Locate",
|
|
1192
|
-
param: plan2.param,
|
|
1193
|
-
executor: async (param, taskContext) => {
|
|
1194
|
-
const { task } = taskContext;
|
|
1195
|
-
let insightDump;
|
|
1196
|
-
const dumpCollector = (dump) => {
|
|
1197
|
-
insightDump = dump;
|
|
1198
|
-
};
|
|
1199
|
-
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1200
|
-
const pageContext = await this.insight.contextRetrieverFn();
|
|
1201
|
-
const locateCache = cacheGroup == null ? void 0 : cacheGroup.readCache(
|
|
1202
|
-
pageContext,
|
|
1203
|
-
"locate",
|
|
1204
|
-
param.prompt
|
|
1205
|
-
);
|
|
1206
|
-
let locateResult;
|
|
1207
|
-
const callAI = this.insight.aiVendorFn;
|
|
1208
|
-
const element = await this.insight.locate(param.prompt, {
|
|
1209
|
-
quickAnswer: plan2.quickAnswer,
|
|
1210
|
-
callAI: async (...message) => {
|
|
1211
|
-
if (locateCache) {
|
|
1212
|
-
locateResult = locateCache;
|
|
1213
|
-
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;
|
|
1214
1275
|
}
|
|
1215
|
-
locateResult = await callAI(...message);
|
|
1216
|
-
assert2(locateResult);
|
|
1217
|
-
return locateResult;
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
|
-
if (locateResult) {
|
|
1221
|
-
cacheGroup == null ? void 0 : cacheGroup.saveCache({
|
|
1222
|
-
type: "locate",
|
|
1223
|
-
pageContext: {
|
|
1224
|
-
url: pageContext.url,
|
|
1225
|
-
size: pageContext.size
|
|
1226
|
-
},
|
|
1227
|
-
prompt: param.prompt,
|
|
1228
|
-
response: locateResult
|
|
1229
|
-
});
|
|
1230
1276
|
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1277
|
+
return void 0;
|
|
1278
|
+
}
|
|
1279
|
+
writeCacheToFile() {
|
|
1280
|
+
const midscenePkgInfo = (0, _fs1.getRunningPkgInfo)();
|
|
1281
|
+
if (!midscenePkgInfo) {
|
|
1282
|
+
return;
|
|
1236
1283
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
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: []
|
|
1247
1302
|
};
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
return taskFind;
|
|
1251
|
-
}
|
|
1252
|
-
if (plan2.type === "Assert" || plan2.type === "AssertWithoutThrow") {
|
|
1253
|
-
const assertPlan = plan2;
|
|
1254
|
-
const taskAssert = {
|
|
1255
|
-
type: "Insight",
|
|
1256
|
-
subType: "Assert",
|
|
1257
|
-
param: assertPlan.param,
|
|
1258
|
-
executor: async (param, taskContext) => {
|
|
1259
|
-
const { task } = taskContext;
|
|
1260
|
-
let insightDump;
|
|
1261
|
-
const dumpCollector = (dump) => {
|
|
1262
|
-
insightDump = dump;
|
|
1303
|
+
this.newCache = {
|
|
1304
|
+
aiTasks: []
|
|
1263
1305
|
};
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
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
|
|
1273
1318
|
};
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
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: []
|
|
1285
1753
|
};
|
|
1286
|
-
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
param: plan2.param,
|
|
1312
|
-
executor: async (taskParam) => {
|
|
1313
|
-
assert2(taskParam.value, "No key to press");
|
|
1314
|
-
await this.page.keyboard.press(taskParam.value);
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
return taskActionKeyboardPress;
|
|
1318
|
-
}
|
|
1319
|
-
if (plan2.type === "Tap") {
|
|
1320
|
-
const taskActionTap = {
|
|
1321
|
-
type: "Action",
|
|
1322
|
-
subType: "Tap",
|
|
1323
|
-
executor: async (param, { element }) => {
|
|
1324
|
-
assert2(element, "Element not found, cannot tap");
|
|
1325
|
-
await this.page.mouse.click(
|
|
1326
|
-
element.center[0],
|
|
1327
|
-
element.center[1]
|
|
1328
|
-
);
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
return taskActionTap;
|
|
1332
|
-
}
|
|
1333
|
-
if (plan2.type === "Hover") {
|
|
1334
|
-
const taskActionHover = {
|
|
1335
|
-
type: "Action",
|
|
1336
|
-
subType: "Hover",
|
|
1337
|
-
executor: async (param, { element }) => {
|
|
1338
|
-
assert2(element, "Element not found, cannot hover");
|
|
1339
|
-
await this.page.mouse.move(
|
|
1340
|
-
element.center[0],
|
|
1341
|
-
element.center[1]
|
|
1342
|
-
);
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
return taskActionHover;
|
|
1346
|
-
}
|
|
1347
|
-
if (plan2.type === "Scroll") {
|
|
1348
|
-
const taskActionScroll = {
|
|
1349
|
-
type: "Action",
|
|
1350
|
-
subType: "Scroll",
|
|
1351
|
-
param: plan2.param,
|
|
1352
|
-
executor: async (taskParam) => {
|
|
1353
|
-
const scrollToEventName = taskParam.scrollType;
|
|
1354
|
-
switch (scrollToEventName) {
|
|
1355
|
-
case "scrollUntilTop":
|
|
1356
|
-
await this.page.scrollUntilTop();
|
|
1357
|
-
break;
|
|
1358
|
-
case "scrollUntilBottom":
|
|
1359
|
-
await this.page.scrollUntilBottom();
|
|
1360
|
-
break;
|
|
1361
|
-
case "scrollUpOneScreen":
|
|
1362
|
-
await this.page.scrollUpOneScreen();
|
|
1363
|
-
break;
|
|
1364
|
-
case "scrollDownOneScreen":
|
|
1365
|
-
await this.page.scrollDownOneScreen();
|
|
1366
|
-
break;
|
|
1367
|
-
default:
|
|
1368
|
-
console.error(
|
|
1369
|
-
"Unknown scroll event type:",
|
|
1370
|
-
scrollToEventName
|
|
1371
|
-
);
|
|
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);
|
|
1372
1779
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
executor: async (taskParam) => {
|
|
1383
|
-
await sleep(taskParam.timeMs || 3e3);
|
|
1384
|
-
}
|
|
1385
|
-
};
|
|
1386
|
-
return taskActionSleep;
|
|
1387
|
-
}
|
|
1388
|
-
if (plan2.type === "Error") {
|
|
1389
|
-
const taskActionError = {
|
|
1390
|
-
type: "Action",
|
|
1391
|
-
subType: "Error",
|
|
1392
|
-
param: plan2.param,
|
|
1393
|
-
executor: async (taskParam) => {
|
|
1394
|
-
assert2(
|
|
1395
|
-
taskParam.thought,
|
|
1396
|
-
"An error occurred, but no thought provided"
|
|
1397
|
-
);
|
|
1398
|
-
throw new Error(taskParam.thought);
|
|
1399
|
-
}
|
|
1400
|
-
};
|
|
1401
|
-
return taskActionError;
|
|
1402
|
-
}
|
|
1403
|
-
throw new Error(`Unknown or Unsupported task type: ${plan2.type}`);
|
|
1404
|
-
}).map((task) => {
|
|
1405
|
-
return this.wrapExecutorWithScreenshot(task);
|
|
1406
|
-
});
|
|
1407
|
-
return tasks;
|
|
1408
|
-
}
|
|
1409
|
-
async action(userPrompt) {
|
|
1410
|
-
const taskExecutor = new Executor(userPrompt);
|
|
1411
|
-
const cacheGroup = this.taskCache.getCacheGroupByPrompt(userPrompt);
|
|
1412
|
-
let plans = [];
|
|
1413
|
-
const planningTask = {
|
|
1414
|
-
type: "Planning",
|
|
1415
|
-
param: {
|
|
1416
|
-
userPrompt
|
|
1417
|
-
},
|
|
1418
|
-
executor: async (param) => {
|
|
1419
|
-
const pageContext = await this.insight.contextRetrieverFn();
|
|
1420
|
-
let planResult;
|
|
1421
|
-
const planCache = cacheGroup.readCache(pageContext, "plan", userPrompt);
|
|
1422
|
-
if (planCache) {
|
|
1423
|
-
planResult = planCache;
|
|
1424
|
-
} else {
|
|
1425
|
-
planResult = await plan(param.userPrompt, {
|
|
1426
|
-
context: pageContext
|
|
1427
|
-
});
|
|
1428
|
-
}
|
|
1429
|
-
assert2(planResult.plans.length > 0, "No plans found");
|
|
1430
|
-
plans = planResult.plans;
|
|
1431
|
-
cacheGroup.saveCache({
|
|
1432
|
-
type: "plan",
|
|
1433
|
-
pageContext: {
|
|
1434
|
-
url: pageContext.url,
|
|
1435
|
-
size: pageContext.size
|
|
1436
|
-
},
|
|
1437
|
-
prompt: userPrompt,
|
|
1438
|
-
response: planResult
|
|
1439
|
-
});
|
|
1440
|
-
return {
|
|
1441
|
-
output: planResult,
|
|
1442
|
-
cache: {
|
|
1443
|
-
hit: Boolean(planCache)
|
|
1444
|
-
}
|
|
1445
|
-
};
|
|
1446
|
-
}
|
|
1447
|
-
};
|
|
1448
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(planningTask));
|
|
1449
|
-
let output = await taskExecutor.flush();
|
|
1450
|
-
if (taskExecutor.isInErrorState()) {
|
|
1451
|
-
return {
|
|
1452
|
-
output,
|
|
1453
|
-
executor: taskExecutor
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
const executables = await this.convertPlanToExecutable(plans, cacheGroup);
|
|
1457
|
-
await taskExecutor.append(executables);
|
|
1458
|
-
output = await taskExecutor.flush();
|
|
1459
|
-
return {
|
|
1460
|
-
output,
|
|
1461
|
-
executor: taskExecutor
|
|
1462
|
-
};
|
|
1463
|
-
}
|
|
1464
|
-
async query(demand) {
|
|
1465
|
-
const description = typeof demand === "string" ? demand : JSON.stringify(demand);
|
|
1466
|
-
const taskExecutor = new Executor(description);
|
|
1467
|
-
const queryTask = {
|
|
1468
|
-
type: "Insight",
|
|
1469
|
-
subType: "Query",
|
|
1470
|
-
param: {
|
|
1471
|
-
dataDemand: demand
|
|
1472
|
-
},
|
|
1473
|
-
executor: async (param) => {
|
|
1474
|
-
let insightDump;
|
|
1475
|
-
const dumpCollector = (dump) => {
|
|
1476
|
-
insightDump = dump;
|
|
1477
|
-
};
|
|
1478
|
-
this.insight.onceDumpUpdatedFn = dumpCollector;
|
|
1479
|
-
const data = await this.insight.extract(param.dataDemand);
|
|
1480
|
-
return {
|
|
1481
|
-
output: data,
|
|
1482
|
-
log: { dump: insightDump }
|
|
1483
|
-
};
|
|
1484
|
-
}
|
|
1485
|
-
};
|
|
1486
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(queryTask));
|
|
1487
|
-
const output = await taskExecutor.flush();
|
|
1488
|
-
return {
|
|
1489
|
-
output,
|
|
1490
|
-
executor: taskExecutor
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
async assert(assertion) {
|
|
1494
|
-
const description = `assert: ${assertion}`;
|
|
1495
|
-
const taskExecutor = new Executor(description);
|
|
1496
|
-
const assertionPlan = {
|
|
1497
|
-
type: "Assert",
|
|
1498
|
-
param: {
|
|
1499
|
-
assertion
|
|
1500
|
-
}
|
|
1501
|
-
};
|
|
1502
|
-
const assertTask = await this.convertPlanToExecutable([assertionPlan]);
|
|
1503
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(assertTask[0]));
|
|
1504
|
-
const output = await taskExecutor.flush();
|
|
1505
|
-
return {
|
|
1506
|
-
output,
|
|
1507
|
-
executor: taskExecutor
|
|
1508
|
-
};
|
|
1509
|
-
}
|
|
1510
|
-
async waitFor(assertion, opt) {
|
|
1511
|
-
const description = `waitFor: ${assertion}`;
|
|
1512
|
-
const taskExecutor = new Executor(description);
|
|
1513
|
-
const { timeoutMs, checkIntervalMs } = opt;
|
|
1514
|
-
assert2(assertion, "No assertion for waitFor");
|
|
1515
|
-
assert2(timeoutMs, "No timeoutMs for waitFor");
|
|
1516
|
-
assert2(checkIntervalMs, "No checkIntervalMs for waitFor");
|
|
1517
|
-
const overallStartTime = Date.now();
|
|
1518
|
-
let startTime = Date.now();
|
|
1519
|
-
let errorThought = "";
|
|
1520
|
-
while (Date.now() - overallStartTime < timeoutMs) {
|
|
1521
|
-
startTime = Date.now();
|
|
1522
|
-
const assertPlan = {
|
|
1523
|
-
type: "AssertWithoutThrow",
|
|
1524
|
-
param: {
|
|
1525
|
-
assertion
|
|
1526
|
-
}
|
|
1527
|
-
};
|
|
1528
|
-
const assertTask = await this.convertPlanToExecutable([assertPlan]);
|
|
1529
|
-
await taskExecutor.append(this.wrapExecutorWithScreenshot(assertTask[0]));
|
|
1530
|
-
const output = await taskExecutor.flush();
|
|
1531
|
-
if (output == null ? void 0 : output.pass) {
|
|
1532
|
-
return {
|
|
1533
|
-
output: void 0,
|
|
1534
|
-
executor: taskExecutor
|
|
1535
|
-
};
|
|
1536
|
-
}
|
|
1537
|
-
errorThought = (output == null ? void 0 : output.thought) || "unknown error";
|
|
1538
|
-
const now = Date.now();
|
|
1539
|
-
if (now - startTime < checkIntervalMs) {
|
|
1540
|
-
const timeRemaining = checkIntervalMs - (now - startTime);
|
|
1541
|
-
const sleepPlan = {
|
|
1542
|
-
type: "Sleep",
|
|
1543
|
-
param: {
|
|
1544
|
-
timeMs: timeRemaining
|
|
1545
|
-
}
|
|
1546
|
-
};
|
|
1547
|
-
const sleepTask = await this.convertPlanToExecutable([sleepPlan]);
|
|
1548
|
-
await taskExecutor.append(
|
|
1549
|
-
this.wrapExecutorWithScreenshot(sleepTask[0])
|
|
1550
|
-
);
|
|
1551
|
-
await taskExecutor.flush();
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
const errorPlan = {
|
|
1555
|
-
type: "Error",
|
|
1556
|
-
param: {
|
|
1557
|
-
thought: `waitFor timeout: ${errorThought}`
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1560
|
-
const errorTask = await this.convertPlanToExecutable([errorPlan]);
|
|
1561
|
-
await taskExecutor.append(errorTask[0]);
|
|
1562
|
-
await taskExecutor.flush();
|
|
1563
|
-
return {
|
|
1564
|
-
output: void 0,
|
|
1565
|
-
executor: taskExecutor
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1568
|
-
};
|
|
1569
|
-
|
|
1570
|
-
// src/common/agent.ts
|
|
1571
|
-
var PageAgent = class {
|
|
1572
|
-
constructor(page, opts) {
|
|
1573
|
-
this.page = page;
|
|
1574
|
-
this.opts = Object.assign(
|
|
1575
|
-
{
|
|
1576
|
-
generateReport: true,
|
|
1577
|
-
autoPrintReportMsg: true,
|
|
1578
|
-
groupName: "Midscene Report",
|
|
1579
|
-
groupDescription: ""
|
|
1580
|
-
},
|
|
1581
|
-
opts || {}
|
|
1582
|
-
);
|
|
1583
|
-
this.dump = {
|
|
1584
|
-
groupName: this.opts.groupName,
|
|
1585
|
-
groupDescription: this.opts.groupDescription,
|
|
1586
|
-
executions: []
|
|
1587
|
-
};
|
|
1588
|
-
this.taskExecutor = new PageTaskExecutor(this.page, {
|
|
1589
|
-
cacheId: opts == null ? void 0 : opts.cacheId
|
|
1590
|
-
});
|
|
1591
|
-
this.reportFileName = reportFileName((opts == null ? void 0 : opts.testId) || "web");
|
|
1592
|
-
}
|
|
1593
|
-
appendExecutionDump(execution) {
|
|
1594
|
-
const currentDump = this.dump;
|
|
1595
|
-
currentDump.executions.push(execution);
|
|
1596
|
-
}
|
|
1597
|
-
dumpDataString() {
|
|
1598
|
-
this.dump.groupName = this.opts.groupName;
|
|
1599
|
-
this.dump.groupDescription = this.opts.groupDescription;
|
|
1600
|
-
return stringifyDumpData2(this.dump);
|
|
1601
|
-
}
|
|
1602
|
-
writeOutActionDumps() {
|
|
1603
|
-
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1604
|
-
this.reportFile = writeLogFile2({
|
|
1605
|
-
fileName: this.reportFileName,
|
|
1606
|
-
fileExt: groupedActionDumpFileExt,
|
|
1607
|
-
fileContent: this.dumpDataString(),
|
|
1608
|
-
type: "dump",
|
|
1609
|
-
generateReport
|
|
1610
|
-
});
|
|
1611
|
-
if (generateReport && autoPrintReportMsg) {
|
|
1612
|
-
printReportMsg(this.reportFile);
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
async aiAction(taskPrompt) {
|
|
1616
|
-
const { executor } = await this.taskExecutor.action(taskPrompt);
|
|
1617
|
-
this.appendExecutionDump(executor.dump());
|
|
1618
|
-
this.writeOutActionDumps();
|
|
1619
|
-
if (executor.isInErrorState()) {
|
|
1620
|
-
const errorTask = executor.latestErrorTask();
|
|
1621
|
-
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}
|
|
1622
1789
|
${errorTask == null ? void 0 : errorTask.errorStack}`);
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
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}
|
|
1632
1801
|
${errorTask == null ? void 0 : errorTask.errorStack}`);
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
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}
|
|
1647
1819
|
${reasonMsg}`);
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
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}
|
|
1661
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;
|
|
1662
1895
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
if (type === "assert") {
|
|
1672
|
-
return this.aiAssert(taskPrompt);
|
|
1673
|
-
}
|
|
1674
|
-
throw new Error(
|
|
1675
|
-
`Unknown type: ${type}, only support 'action', 'query', 'assert'`
|
|
1676
|
-
);
|
|
1677
|
-
}
|
|
1678
|
-
};
|
|
1679
|
-
|
|
1680
|
-
// src/appium/page.ts
|
|
1681
|
-
import fs from "fs";
|
|
1682
|
-
import { getTmpFile } from "@midscene/core/utils";
|
|
1683
|
-
import { resizeImg } from "@midscene/shared/img";
|
|
1684
|
-
import { DOMParser } from "@xmldom/xmldom";
|
|
1685
|
-
|
|
1686
|
-
// src/extractor/web-extractor.ts
|
|
1687
|
-
import {
|
|
1688
|
-
CONTAINER_MINI_HEIGHT,
|
|
1689
|
-
CONTAINER_MINI_WIDTH,
|
|
1690
|
-
NodeType as NodeType2
|
|
1691
|
-
} from "@midscene/shared/constants";
|
|
1692
|
-
|
|
1693
|
-
// src/extractor/util.ts
|
|
1694
|
-
var import_js_sha256 = __toESM(require_sha256());
|
|
1695
|
-
var frameId = 0;
|
|
1696
|
-
function getFrameId() {
|
|
1697
|
-
return frameId;
|
|
1698
|
-
}
|
|
1699
|
-
function midsceneGenerateHash(content, rect) {
|
|
1700
|
-
const combined = JSON.stringify({
|
|
1701
|
-
content,
|
|
1702
|
-
rect,
|
|
1703
|
-
_midscene_frame_id: getFrameId()
|
|
1704
|
-
});
|
|
1705
|
-
const hashHex = (0, import_js_sha256.default)(combined);
|
|
1706
|
-
return hashHex.slice(0, 10);
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
// src/extractor/constants.ts
|
|
1710
|
-
import {
|
|
1711
|
-
NodeType as NodeType3,
|
|
1712
|
-
TEXT_MAX_SIZE,
|
|
1713
|
-
TEXT_SIZE_THRESHOLD
|
|
1714
|
-
} from "@midscene/shared/constants";
|
|
1715
|
-
|
|
1716
|
-
// src/extractor/client-extractor.ts
|
|
1717
|
-
function getNodeAttributes2(node) {
|
|
1718
|
-
var _a;
|
|
1719
|
-
const attrs = {};
|
|
1720
|
-
if (node && node.nodeType === 1) {
|
|
1721
|
-
const element = node;
|
|
1722
|
-
for (let i = 0; i < element.attributes.length; i++) {
|
|
1723
|
-
const attr = element.attributes[i];
|
|
1724
|
-
attrs[attr.nodeName] = (_a = attr.nodeValue) != null ? _a : "";
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
return attrs;
|
|
1728
|
-
}
|
|
1729
|
-
function getRect2(attributes) {
|
|
1730
|
-
var _a, _b, _c, _d;
|
|
1731
|
-
const x = Math.round(Number.parseFloat((_a = attributes.x) != null ? _a : "0"));
|
|
1732
|
-
const y = Math.round(Number.parseFloat((_b = attributes.y) != null ? _b : "0"));
|
|
1733
|
-
const width = Math.round(Number.parseFloat((_c = attributes.width) != null ? _c : "0"));
|
|
1734
|
-
const height = Math.round(Number.parseFloat((_d = attributes.height) != null ? _d : "0"));
|
|
1735
|
-
return {
|
|
1736
|
-
left: Math.max(0, Math.floor(x)),
|
|
1737
|
-
top: Math.max(0, Math.floor(y)),
|
|
1738
|
-
width: Math.max(0, width),
|
|
1739
|
-
height: Math.max(0, height)
|
|
1740
|
-
};
|
|
1741
|
-
}
|
|
1742
|
-
function validTextNodeContent(node) {
|
|
1743
|
-
var _a;
|
|
1744
|
-
if (node.nodeType === 3) {
|
|
1745
|
-
return ((_a = node.nodeValue) == null ? void 0 : _a.trim()) || "";
|
|
1746
|
-
}
|
|
1747
|
-
return "";
|
|
1748
|
-
}
|
|
1749
|
-
function getXPathForElement(element) {
|
|
1750
|
-
if (element.nodeType !== 1) {
|
|
1751
|
-
return "";
|
|
1752
|
-
}
|
|
1753
|
-
const getIndex = (sib, name) => {
|
|
1754
|
-
let count = 1;
|
|
1755
|
-
for (let cur = sib.previousSibling; cur; cur = cur.previousSibling) {
|
|
1756
|
-
if (cur.nodeType === 1 && cur.nodeName === name) {
|
|
1757
|
-
count++;
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
return count;
|
|
1761
|
-
};
|
|
1762
|
-
const buildAttributePart = (elem) => {
|
|
1763
|
-
const attributes = ["id", "resource-id", "content-desc", "class"];
|
|
1764
|
-
for (const attr of attributes) {
|
|
1765
|
-
if (elem.hasAttribute(attr)) {
|
|
1766
|
-
const value = elem.getAttribute(attr);
|
|
1767
|
-
if (value && value.trim() !== "") {
|
|
1768
|
-
return `[@${attr}="${value}"]`;
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
return "";
|
|
1773
|
-
};
|
|
1774
|
-
const getPath = (node, path2 = "") => {
|
|
1775
|
-
if (node.parentNode) {
|
|
1776
|
-
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);
|
|
1777
1904
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
}
|
|
1791
|
-
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;
|
|
1792
1917
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
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
|
+
};
|
|
1803
1930
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
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 "";
|
|
1807
1937
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
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);
|
|
1813
1990
|
}
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
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
|
+
}
|
|
2011
|
+
}
|
|
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
|
+
}
|
|
1846
2067
|
}
|
|
1847
|
-
|
|
2068
|
+
const rootNode = initNode;
|
|
2069
|
+
const rootDescriptor = {
|
|
2070
|
+
node: rootNode,
|
|
2071
|
+
children: []
|
|
2072
|
+
};
|
|
2073
|
+
dfs(rootNode, rootDescriptor);
|
|
2074
|
+
return elementInfoArray;
|
|
1848
2075
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
indexId: nodeIndex++,
|
|
1853
|
-
nodeHashId,
|
|
1854
|
-
locator: xpath,
|
|
1855
|
-
attributes: __spreadValues({
|
|
1856
|
-
nodeType
|
|
1857
|
-
}, attributes),
|
|
1858
|
-
content: text,
|
|
1859
|
-
rect,
|
|
1860
|
-
center: [
|
|
1861
|
-
Math.round(rect.left + rect.width / 2),
|
|
1862
|
-
Math.round(rect.top + rect.height / 2)
|
|
1863
|
-
],
|
|
1864
|
-
nodeType,
|
|
1865
|
-
nodePath: ""
|
|
1866
|
-
};
|
|
1867
|
-
if (elementInfo.nodeType !== NodeType3.CONTAINER) {
|
|
1868
|
-
elementInfoArray.push(elementInfo);
|
|
2076
|
+
// src/appium/page.ts
|
|
2077
|
+
function buttonToNumber(button) {
|
|
2078
|
+
return button === "left" ? 0 : button === "middle" ? 1 : 2;
|
|
1869
2079
|
}
|
|
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
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
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
|
+
}
|
|
1919
2334
|
};
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
if (!element) {
|
|
1923
|
-
return;
|
|
1924
|
-
}
|
|
1925
|
-
const ele = await this.browser.$(element.locator);
|
|
1926
|
-
const blank = " ";
|
|
1927
|
-
await this.keyboardType(blank);
|
|
1928
|
-
await ele.clearValue();
|
|
1929
|
-
}
|
|
1930
|
-
url() {
|
|
1931
|
-
var _a;
|
|
1932
|
-
const platformName = (_a = this.browser.capabilities.platformName) == null ? void 0 : _a.toLowerCase();
|
|
1933
|
-
if (platformName === "ios") {
|
|
1934
|
-
const bundleId = this.browser.capabilities.bundleId;
|
|
1935
|
-
return bundleId;
|
|
1936
|
-
}
|
|
1937
|
-
if (platformName === "android") {
|
|
1938
|
-
const appActivity = this.browser.capabilities.appActivity;
|
|
1939
|
-
return appActivity;
|
|
1940
|
-
}
|
|
1941
|
-
return "";
|
|
1942
|
-
}
|
|
1943
|
-
// Scroll to top element
|
|
1944
|
-
async scrollUntilTop() {
|
|
1945
|
-
const { height } = await this.browser.getWindowSize();
|
|
1946
|
-
await this.mouseWheel(0, height, 100);
|
|
1947
|
-
}
|
|
1948
|
-
// Scroll to bottom element
|
|
1949
|
-
async scrollUntilBottom() {
|
|
1950
|
-
const { height } = await this.browser.getWindowSize();
|
|
1951
|
-
await this.mouseWheel(0, -height, 100);
|
|
1952
|
-
}
|
|
1953
|
-
// Scroll up one screen
|
|
1954
|
-
async scrollUpOneScreen() {
|
|
1955
|
-
const { height } = await this.browser.getWindowSize();
|
|
1956
|
-
await this.mouseWheel(0, height, 1e3);
|
|
1957
|
-
}
|
|
1958
|
-
// Scroll down one screen
|
|
1959
|
-
async scrollDownOneScreen() {
|
|
1960
|
-
const { height } = await this.browser.getWindowSize();
|
|
1961
|
-
await this.mouseWheel(0, -height, 1e3);
|
|
1962
|
-
}
|
|
1963
|
-
async keyboardType(text) {
|
|
1964
|
-
const actions = [];
|
|
1965
|
-
for (const char of text) {
|
|
1966
|
-
actions.push({ type: "keyDown", value: char });
|
|
1967
|
-
actions.push({ type: "keyUp", value: char });
|
|
1968
|
-
}
|
|
1969
|
-
if (!actions.length) {
|
|
1970
|
-
return;
|
|
1971
|
-
}
|
|
1972
|
-
await this.browser.performActions([
|
|
1973
|
-
{
|
|
1974
|
-
type: "key",
|
|
1975
|
-
id: "keyboard",
|
|
1976
|
-
actions
|
|
1977
|
-
}
|
|
1978
|
-
]);
|
|
1979
|
-
}
|
|
1980
|
-
async keyboardPress(key) {
|
|
1981
|
-
await this.browser.performActions([
|
|
1982
|
-
{
|
|
1983
|
-
type: "key",
|
|
1984
|
-
id: "keyboard",
|
|
1985
|
-
actions: [
|
|
1986
|
-
{ type: "keyDown", value: key },
|
|
1987
|
-
{ type: "keyUp", value: key }
|
|
1988
|
-
]
|
|
1989
|
-
}
|
|
1990
|
-
]);
|
|
1991
|
-
}
|
|
1992
|
-
async mouseClick(x, y, button = "left") {
|
|
1993
|
-
await this.mouseMove(x, y);
|
|
1994
|
-
await this.browser.performActions([
|
|
1995
|
-
{
|
|
1996
|
-
type: "pointer",
|
|
1997
|
-
id: "mouse",
|
|
1998
|
-
parameters: { pointerType: "mouse" },
|
|
1999
|
-
actions: [
|
|
2000
|
-
{ type: "pointerMove", duration: 0, x, y },
|
|
2001
|
-
{ type: "pointerDown", button: buttonToNumber(button) },
|
|
2002
|
-
{ type: "pause", duration: 100 },
|
|
2003
|
-
{ type: "pointerUp", button: buttonToNumber(button) }
|
|
2004
|
-
]
|
|
2005
|
-
}
|
|
2006
|
-
]);
|
|
2007
|
-
}
|
|
2008
|
-
async mouseMove(x, y) {
|
|
2009
|
-
await this.browser.performActions([
|
|
2010
|
-
{
|
|
2011
|
-
type: "pointer",
|
|
2012
|
-
id: "mouse",
|
|
2013
|
-
parameters: { pointerType: "mouse" },
|
|
2014
|
-
actions: [{ type: "pointerMove", duration: 0, x, y }]
|
|
2015
|
-
}
|
|
2016
|
-
]);
|
|
2017
|
-
}
|
|
2018
|
-
async mouseWheel(deltaX, deltaY, duration = 1e3) {
|
|
2019
|
-
const n = 4;
|
|
2020
|
-
const windowSize = await this.browser.getWindowSize();
|
|
2021
|
-
const startX = deltaX < 0 ? (n - 1) * (windowSize.width / n) : windowSize.width / n;
|
|
2022
|
-
const startY = deltaY < 0 ? (n - 1) * (windowSize.height / n) : windowSize.height / n;
|
|
2023
|
-
const maxNegativeDeltaX = startX;
|
|
2024
|
-
const maxPositiveDeltaX = (n - 1) * (windowSize.width / n);
|
|
2025
|
-
const maxNegativeDeltaY = startY;
|
|
2026
|
-
const maxPositiveDeltaY = (n - 1) * (windowSize.height / n);
|
|
2027
|
-
deltaX = Math.max(-maxNegativeDeltaX, Math.min(deltaX, maxPositiveDeltaX));
|
|
2028
|
-
deltaY = Math.max(-maxNegativeDeltaY, Math.min(deltaY, maxPositiveDeltaY));
|
|
2029
|
-
await this.browser.performActions([
|
|
2030
|
-
{
|
|
2031
|
-
type: "pointer",
|
|
2032
|
-
id: "finger1",
|
|
2033
|
-
parameters: { pointerType: "touch" },
|
|
2034
|
-
actions: [
|
|
2035
|
-
{ type: "pointerMove", duration: 0, x: startX, y: startY },
|
|
2036
|
-
{ type: "pointerDown", button: 0 },
|
|
2037
|
-
{ type: "pause", duration },
|
|
2038
|
-
{
|
|
2039
|
-
type: "pointerMove",
|
|
2040
|
-
duration,
|
|
2041
|
-
origin: "pointer",
|
|
2042
|
-
// Use 'pointer' as the starting point
|
|
2043
|
-
x: deltaX,
|
|
2044
|
-
// X offset relative to the starting point
|
|
2045
|
-
y: deltaY
|
|
2046
|
-
// Y offset relative to the starting point
|
|
2047
|
-
},
|
|
2048
|
-
{ type: "pointerUp", button: 0 }
|
|
2049
|
-
]
|
|
2050
|
-
}
|
|
2051
|
-
]);
|
|
2052
|
-
}
|
|
2053
|
-
};
|
|
2054
|
-
export {
|
|
2055
|
-
PageAgent as AppiumAgent,
|
|
2056
|
-
Page as AppiumPage
|
|
2057
|
-
};
|
|
2058
|
-
/*! Bundled license information:
|
|
2335
|
+
});
|
|
2336
|
+
/*! Bundled license information:
|
|
2059
2337
|
|
|
2060
2338
|
js-sha256/src/sha256.js:
|
|
2061
2339
|
(**
|
|
@@ -2066,4 +2344,4 @@ js-sha256/src/sha256.js:
|
|
|
2066
2344
|
* @copyright Chen, Yi-Cyuan 2014-2024
|
|
2067
2345
|
* @license MIT
|
|
2068
2346
|
*)
|
|
2069
|
-
*/
|
|
2347
|
+
*/
|