@midscene/web 0.0.1 → 0.1.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/index.js +337 -110
- package/dist/es/playwright-report.js +2380 -0
- package/dist/lib/index.js +338 -110
- package/dist/lib/playwright-report.js +2383 -0
- package/dist/script/htmlElement.js +596 -25
- package/dist/script/types/htmlElement.d.ts +2 -0
- package/dist/types/index.d.ts +116 -21
- package/dist/types/playwright-report.d.ts +10 -0
- package/package.json +25 -4
- package/modern.config.ts +0 -13
- package/modern.inspect.config.ts +0 -20
- package/playwright.config.ts +0 -42
- package/src/html-element/constants.ts +0 -10
- package/src/html-element/debug.ts +0 -3
- package/src/html-element/dom-util.ts +0 -11
- package/src/html-element/extractInfo.ts +0 -168
- package/src/html-element/index.ts +0 -1
- package/src/html-element/util.ts +0 -160
- package/src/img/img.ts +0 -132
- package/src/img/util.ts +0 -28
- package/src/index.ts +0 -2
- package/src/playwright/actions.ts +0 -276
- package/src/playwright/cdp.ts +0 -322
- package/src/playwright/element.ts +0 -74
- package/src/playwright/index.ts +0 -120
- package/src/playwright/utils.ts +0 -88
- package/src/puppeteer/element.ts +0 -49
- package/src/puppeteer/index.ts +0 -6
- package/src/puppeteer/utils.ts +0 -116
- package/tests/e2e/ai-auto-todo.spec.ts +0 -24
- package/tests/e2e/ai-xicha.spec.ts +0 -34
- package/tests/e2e/fixture.ts +0 -6
- package/tests/e2e/generate-test-data.spec.ts +0 -60
- package/tests/e2e/todo-app-midscene.spec.ts +0 -98
- package/tests/e2e/tool.ts +0 -63
- package/tsconfig.json +0 -23
- package/vitest.config.ts +0 -14
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var midscene_element_inspector = (() => {
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __defProps = Object.defineProperties;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
7
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
8
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
9
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
12
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
13
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -21,6 +23,16 @@ var midscene_element_inspector = (() => {
|
|
|
21
23
|
return a;
|
|
22
24
|
};
|
|
23
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
27
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
28
|
+
}) : x)(function(x) {
|
|
29
|
+
if (typeof require !== "undefined")
|
|
30
|
+
return require.apply(this, arguments);
|
|
31
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
32
|
+
});
|
|
33
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
34
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
35
|
+
};
|
|
24
36
|
var __export = (target, all) => {
|
|
25
37
|
for (var name in all)
|
|
26
38
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -33,22 +45,550 @@ var midscene_element_inspector = (() => {
|
|
|
33
45
|
}
|
|
34
46
|
return to;
|
|
35
47
|
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
49
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
50
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
51
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
52
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
53
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
54
|
+
mod
|
|
55
|
+
));
|
|
36
56
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
57
|
|
|
38
|
-
//
|
|
39
|
-
var
|
|
40
|
-
|
|
58
|
+
// ../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js
|
|
59
|
+
var require_sha256 = __commonJS({
|
|
60
|
+
"../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js"(exports, module) {
|
|
61
|
+
"use strict";
|
|
62
|
+
(function() {
|
|
63
|
+
"use strict";
|
|
64
|
+
var ERROR = "input is invalid type";
|
|
65
|
+
var WINDOW = typeof window === "object";
|
|
66
|
+
var root = WINDOW ? window : {};
|
|
67
|
+
if (root.JS_SHA256_NO_WINDOW) {
|
|
68
|
+
WINDOW = false;
|
|
69
|
+
}
|
|
70
|
+
var WEB_WORKER = !WINDOW && typeof self === "object";
|
|
71
|
+
var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node;
|
|
72
|
+
if (NODE_JS) {
|
|
73
|
+
root = global;
|
|
74
|
+
} else if (WEB_WORKER) {
|
|
75
|
+
root = self;
|
|
76
|
+
}
|
|
77
|
+
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module === "object" && module.exports;
|
|
78
|
+
var AMD = typeof define === "function" && define.amd;
|
|
79
|
+
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
|
|
80
|
+
var HEX_CHARS = "0123456789abcdef".split("");
|
|
81
|
+
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
82
|
+
var SHIFT = [24, 16, 8, 0];
|
|
83
|
+
var K = [
|
|
84
|
+
1116352408,
|
|
85
|
+
1899447441,
|
|
86
|
+
3049323471,
|
|
87
|
+
3921009573,
|
|
88
|
+
961987163,
|
|
89
|
+
1508970993,
|
|
90
|
+
2453635748,
|
|
91
|
+
2870763221,
|
|
92
|
+
3624381080,
|
|
93
|
+
310598401,
|
|
94
|
+
607225278,
|
|
95
|
+
1426881987,
|
|
96
|
+
1925078388,
|
|
97
|
+
2162078206,
|
|
98
|
+
2614888103,
|
|
99
|
+
3248222580,
|
|
100
|
+
3835390401,
|
|
101
|
+
4022224774,
|
|
102
|
+
264347078,
|
|
103
|
+
604807628,
|
|
104
|
+
770255983,
|
|
105
|
+
1249150122,
|
|
106
|
+
1555081692,
|
|
107
|
+
1996064986,
|
|
108
|
+
2554220882,
|
|
109
|
+
2821834349,
|
|
110
|
+
2952996808,
|
|
111
|
+
3210313671,
|
|
112
|
+
3336571891,
|
|
113
|
+
3584528711,
|
|
114
|
+
113926993,
|
|
115
|
+
338241895,
|
|
116
|
+
666307205,
|
|
117
|
+
773529912,
|
|
118
|
+
1294757372,
|
|
119
|
+
1396182291,
|
|
120
|
+
1695183700,
|
|
121
|
+
1986661051,
|
|
122
|
+
2177026350,
|
|
123
|
+
2456956037,
|
|
124
|
+
2730485921,
|
|
125
|
+
2820302411,
|
|
126
|
+
3259730800,
|
|
127
|
+
3345764771,
|
|
128
|
+
3516065817,
|
|
129
|
+
3600352804,
|
|
130
|
+
4094571909,
|
|
131
|
+
275423344,
|
|
132
|
+
430227734,
|
|
133
|
+
506948616,
|
|
134
|
+
659060556,
|
|
135
|
+
883997877,
|
|
136
|
+
958139571,
|
|
137
|
+
1322822218,
|
|
138
|
+
1537002063,
|
|
139
|
+
1747873779,
|
|
140
|
+
1955562222,
|
|
141
|
+
2024104815,
|
|
142
|
+
2227730452,
|
|
143
|
+
2361852424,
|
|
144
|
+
2428436474,
|
|
145
|
+
2756734187,
|
|
146
|
+
3204031479,
|
|
147
|
+
3329325298
|
|
148
|
+
];
|
|
149
|
+
var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
|
|
150
|
+
var blocks = [];
|
|
151
|
+
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
|
|
152
|
+
Array.isArray = function(obj) {
|
|
153
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
|
157
|
+
ArrayBuffer.isView = function(obj) {
|
|
158
|
+
return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
var createOutputMethod = function(outputType, is224) {
|
|
162
|
+
return function(message) {
|
|
163
|
+
return new Sha256(is224, true).update(message)[outputType]();
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
var createMethod = function(is224) {
|
|
167
|
+
var method = createOutputMethod("hex", is224);
|
|
168
|
+
if (NODE_JS) {
|
|
169
|
+
method = nodeWrap(method, is224);
|
|
170
|
+
}
|
|
171
|
+
method.create = function() {
|
|
172
|
+
return new Sha256(is224);
|
|
173
|
+
};
|
|
174
|
+
method.update = function(message) {
|
|
175
|
+
return method.create().update(message);
|
|
176
|
+
};
|
|
177
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
178
|
+
var type = OUTPUT_TYPES[i];
|
|
179
|
+
method[type] = createOutputMethod(type, is224);
|
|
180
|
+
}
|
|
181
|
+
return method;
|
|
182
|
+
};
|
|
183
|
+
var nodeWrap = function(method, is224) {
|
|
184
|
+
var crypto = __require("crypto");
|
|
185
|
+
var Buffer2 = __require("buffer").Buffer;
|
|
186
|
+
var algorithm = is224 ? "sha224" : "sha256";
|
|
187
|
+
var bufferFrom;
|
|
188
|
+
if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
|
|
189
|
+
bufferFrom = Buffer2.from;
|
|
190
|
+
} else {
|
|
191
|
+
bufferFrom = function(message) {
|
|
192
|
+
return new Buffer2(message);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
var nodeMethod = function(message) {
|
|
196
|
+
if (typeof message === "string") {
|
|
197
|
+
return crypto.createHash(algorithm).update(message, "utf8").digest("hex");
|
|
198
|
+
} else {
|
|
199
|
+
if (message === null || message === void 0) {
|
|
200
|
+
throw new Error(ERROR);
|
|
201
|
+
} else if (message.constructor === ArrayBuffer) {
|
|
202
|
+
message = new Uint8Array(message);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (Array.isArray(message) || ArrayBuffer.isView(message) || message.constructor === Buffer2) {
|
|
206
|
+
return crypto.createHash(algorithm).update(bufferFrom(message)).digest("hex");
|
|
207
|
+
} else {
|
|
208
|
+
return method(message);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
return nodeMethod;
|
|
212
|
+
};
|
|
213
|
+
var createHmacOutputMethod = function(outputType, is224) {
|
|
214
|
+
return function(key, message) {
|
|
215
|
+
return new HmacSha256(key, is224, true).update(message)[outputType]();
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
var createHmacMethod = function(is224) {
|
|
219
|
+
var method = createHmacOutputMethod("hex", is224);
|
|
220
|
+
method.create = function(key) {
|
|
221
|
+
return new HmacSha256(key, is224);
|
|
222
|
+
};
|
|
223
|
+
method.update = function(key, message) {
|
|
224
|
+
return method.create(key).update(message);
|
|
225
|
+
};
|
|
226
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
227
|
+
var type = OUTPUT_TYPES[i];
|
|
228
|
+
method[type] = createHmacOutputMethod(type, is224);
|
|
229
|
+
}
|
|
230
|
+
return method;
|
|
231
|
+
};
|
|
232
|
+
function Sha256(is224, sharedMemory) {
|
|
233
|
+
if (sharedMemory) {
|
|
234
|
+
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;
|
|
235
|
+
this.blocks = blocks;
|
|
236
|
+
} else {
|
|
237
|
+
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
238
|
+
}
|
|
239
|
+
if (is224) {
|
|
240
|
+
this.h0 = 3238371032;
|
|
241
|
+
this.h1 = 914150663;
|
|
242
|
+
this.h2 = 812702999;
|
|
243
|
+
this.h3 = 4144912697;
|
|
244
|
+
this.h4 = 4290775857;
|
|
245
|
+
this.h5 = 1750603025;
|
|
246
|
+
this.h6 = 1694076839;
|
|
247
|
+
this.h7 = 3204075428;
|
|
248
|
+
} else {
|
|
249
|
+
this.h0 = 1779033703;
|
|
250
|
+
this.h1 = 3144134277;
|
|
251
|
+
this.h2 = 1013904242;
|
|
252
|
+
this.h3 = 2773480762;
|
|
253
|
+
this.h4 = 1359893119;
|
|
254
|
+
this.h5 = 2600822924;
|
|
255
|
+
this.h6 = 528734635;
|
|
256
|
+
this.h7 = 1541459225;
|
|
257
|
+
}
|
|
258
|
+
this.block = this.start = this.bytes = this.hBytes = 0;
|
|
259
|
+
this.finalized = this.hashed = false;
|
|
260
|
+
this.first = true;
|
|
261
|
+
this.is224 = is224;
|
|
262
|
+
}
|
|
263
|
+
Sha256.prototype.update = function(message) {
|
|
264
|
+
if (this.finalized) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
var notString, type = typeof message;
|
|
268
|
+
if (type !== "string") {
|
|
269
|
+
if (type === "object") {
|
|
270
|
+
if (message === null) {
|
|
271
|
+
throw new Error(ERROR);
|
|
272
|
+
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
|
273
|
+
message = new Uint8Array(message);
|
|
274
|
+
} else if (!Array.isArray(message)) {
|
|
275
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
|
276
|
+
throw new Error(ERROR);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
} else {
|
|
280
|
+
throw new Error(ERROR);
|
|
281
|
+
}
|
|
282
|
+
notString = true;
|
|
283
|
+
}
|
|
284
|
+
var code, index = 0, i, length = message.length, blocks2 = this.blocks;
|
|
285
|
+
while (index < length) {
|
|
286
|
+
if (this.hashed) {
|
|
287
|
+
this.hashed = false;
|
|
288
|
+
blocks2[0] = this.block;
|
|
289
|
+
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;
|
|
290
|
+
}
|
|
291
|
+
if (notString) {
|
|
292
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
293
|
+
blocks2[i >>> 2] |= message[index] << SHIFT[i++ & 3];
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
297
|
+
code = message.charCodeAt(index);
|
|
298
|
+
if (code < 128) {
|
|
299
|
+
blocks2[i >>> 2] |= code << SHIFT[i++ & 3];
|
|
300
|
+
} else if (code < 2048) {
|
|
301
|
+
blocks2[i >>> 2] |= (192 | code >>> 6) << SHIFT[i++ & 3];
|
|
302
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
303
|
+
} else if (code < 55296 || code >= 57344) {
|
|
304
|
+
blocks2[i >>> 2] |= (224 | code >>> 12) << SHIFT[i++ & 3];
|
|
305
|
+
blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
|
|
306
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
307
|
+
} else {
|
|
308
|
+
code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023);
|
|
309
|
+
blocks2[i >>> 2] |= (240 | code >>> 18) << SHIFT[i++ & 3];
|
|
310
|
+
blocks2[i >>> 2] |= (128 | code >>> 12 & 63) << SHIFT[i++ & 3];
|
|
311
|
+
blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
|
|
312
|
+
blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
this.lastByteIndex = i;
|
|
317
|
+
this.bytes += i - this.start;
|
|
318
|
+
if (i >= 64) {
|
|
319
|
+
this.block = blocks2[16];
|
|
320
|
+
this.start = i - 64;
|
|
321
|
+
this.hash();
|
|
322
|
+
this.hashed = true;
|
|
323
|
+
} else {
|
|
324
|
+
this.start = i;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (this.bytes > 4294967295) {
|
|
328
|
+
this.hBytes += this.bytes / 4294967296 << 0;
|
|
329
|
+
this.bytes = this.bytes % 4294967296;
|
|
330
|
+
}
|
|
331
|
+
return this;
|
|
332
|
+
};
|
|
333
|
+
Sha256.prototype.finalize = function() {
|
|
334
|
+
if (this.finalized) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
this.finalized = true;
|
|
338
|
+
var blocks2 = this.blocks, i = this.lastByteIndex;
|
|
339
|
+
blocks2[16] = this.block;
|
|
340
|
+
blocks2[i >>> 2] |= EXTRA[i & 3];
|
|
341
|
+
this.block = blocks2[16];
|
|
342
|
+
if (i >= 56) {
|
|
343
|
+
if (!this.hashed) {
|
|
344
|
+
this.hash();
|
|
345
|
+
}
|
|
346
|
+
blocks2[0] = this.block;
|
|
347
|
+
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;
|
|
348
|
+
}
|
|
349
|
+
blocks2[14] = this.hBytes << 3 | this.bytes >>> 29;
|
|
350
|
+
blocks2[15] = this.bytes << 3;
|
|
351
|
+
this.hash();
|
|
352
|
+
};
|
|
353
|
+
Sha256.prototype.hash = function() {
|
|
354
|
+
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;
|
|
355
|
+
for (j = 16; j < 64; ++j) {
|
|
356
|
+
t1 = blocks2[j - 15];
|
|
357
|
+
s0 = (t1 >>> 7 | t1 << 25) ^ (t1 >>> 18 | t1 << 14) ^ t1 >>> 3;
|
|
358
|
+
t1 = blocks2[j - 2];
|
|
359
|
+
s1 = (t1 >>> 17 | t1 << 15) ^ (t1 >>> 19 | t1 << 13) ^ t1 >>> 10;
|
|
360
|
+
blocks2[j] = blocks2[j - 16] + s0 + blocks2[j - 7] + s1 << 0;
|
|
361
|
+
}
|
|
362
|
+
bc = b & c;
|
|
363
|
+
for (j = 0; j < 64; j += 4) {
|
|
364
|
+
if (this.first) {
|
|
365
|
+
if (this.is224) {
|
|
366
|
+
ab = 300032;
|
|
367
|
+
t1 = blocks2[0] - 1413257819;
|
|
368
|
+
h = t1 - 150054599 << 0;
|
|
369
|
+
d = t1 + 24177077 << 0;
|
|
370
|
+
} else {
|
|
371
|
+
ab = 704751109;
|
|
372
|
+
t1 = blocks2[0] - 210244248;
|
|
373
|
+
h = t1 - 1521486534 << 0;
|
|
374
|
+
d = t1 + 143694565 << 0;
|
|
375
|
+
}
|
|
376
|
+
this.first = false;
|
|
377
|
+
} else {
|
|
378
|
+
s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
|
|
379
|
+
s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
|
|
380
|
+
ab = a & b;
|
|
381
|
+
maj = ab ^ a & c ^ bc;
|
|
382
|
+
ch = e & f ^ ~e & g;
|
|
383
|
+
t1 = h + s1 + ch + K[j] + blocks2[j];
|
|
384
|
+
t2 = s0 + maj;
|
|
385
|
+
h = d + t1 << 0;
|
|
386
|
+
d = t1 + t2 << 0;
|
|
387
|
+
}
|
|
388
|
+
s0 = (d >>> 2 | d << 30) ^ (d >>> 13 | d << 19) ^ (d >>> 22 | d << 10);
|
|
389
|
+
s1 = (h >>> 6 | h << 26) ^ (h >>> 11 | h << 21) ^ (h >>> 25 | h << 7);
|
|
390
|
+
da = d & a;
|
|
391
|
+
maj = da ^ d & b ^ ab;
|
|
392
|
+
ch = h & e ^ ~h & f;
|
|
393
|
+
t1 = g + s1 + ch + K[j + 1] + blocks2[j + 1];
|
|
394
|
+
t2 = s0 + maj;
|
|
395
|
+
g = c + t1 << 0;
|
|
396
|
+
c = t1 + t2 << 0;
|
|
397
|
+
s0 = (c >>> 2 | c << 30) ^ (c >>> 13 | c << 19) ^ (c >>> 22 | c << 10);
|
|
398
|
+
s1 = (g >>> 6 | g << 26) ^ (g >>> 11 | g << 21) ^ (g >>> 25 | g << 7);
|
|
399
|
+
cd = c & d;
|
|
400
|
+
maj = cd ^ c & a ^ da;
|
|
401
|
+
ch = g & h ^ ~g & e;
|
|
402
|
+
t1 = f + s1 + ch + K[j + 2] + blocks2[j + 2];
|
|
403
|
+
t2 = s0 + maj;
|
|
404
|
+
f = b + t1 << 0;
|
|
405
|
+
b = t1 + t2 << 0;
|
|
406
|
+
s0 = (b >>> 2 | b << 30) ^ (b >>> 13 | b << 19) ^ (b >>> 22 | b << 10);
|
|
407
|
+
s1 = (f >>> 6 | f << 26) ^ (f >>> 11 | f << 21) ^ (f >>> 25 | f << 7);
|
|
408
|
+
bc = b & c;
|
|
409
|
+
maj = bc ^ b & d ^ cd;
|
|
410
|
+
ch = f & g ^ ~f & h;
|
|
411
|
+
t1 = e + s1 + ch + K[j + 3] + blocks2[j + 3];
|
|
412
|
+
t2 = s0 + maj;
|
|
413
|
+
e = a + t1 << 0;
|
|
414
|
+
a = t1 + t2 << 0;
|
|
415
|
+
this.chromeBugWorkAround = true;
|
|
416
|
+
}
|
|
417
|
+
this.h0 = this.h0 + a << 0;
|
|
418
|
+
this.h1 = this.h1 + b << 0;
|
|
419
|
+
this.h2 = this.h2 + c << 0;
|
|
420
|
+
this.h3 = this.h3 + d << 0;
|
|
421
|
+
this.h4 = this.h4 + e << 0;
|
|
422
|
+
this.h5 = this.h5 + f << 0;
|
|
423
|
+
this.h6 = this.h6 + g << 0;
|
|
424
|
+
this.h7 = this.h7 + h << 0;
|
|
425
|
+
};
|
|
426
|
+
Sha256.prototype.hex = function() {
|
|
427
|
+
this.finalize();
|
|
428
|
+
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;
|
|
429
|
+
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];
|
|
430
|
+
if (!this.is224) {
|
|
431
|
+
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];
|
|
432
|
+
}
|
|
433
|
+
return hex;
|
|
434
|
+
};
|
|
435
|
+
Sha256.prototype.toString = Sha256.prototype.hex;
|
|
436
|
+
Sha256.prototype.digest = function() {
|
|
437
|
+
this.finalize();
|
|
438
|
+
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;
|
|
439
|
+
var arr = [
|
|
440
|
+
h0 >>> 24 & 255,
|
|
441
|
+
h0 >>> 16 & 255,
|
|
442
|
+
h0 >>> 8 & 255,
|
|
443
|
+
h0 & 255,
|
|
444
|
+
h1 >>> 24 & 255,
|
|
445
|
+
h1 >>> 16 & 255,
|
|
446
|
+
h1 >>> 8 & 255,
|
|
447
|
+
h1 & 255,
|
|
448
|
+
h2 >>> 24 & 255,
|
|
449
|
+
h2 >>> 16 & 255,
|
|
450
|
+
h2 >>> 8 & 255,
|
|
451
|
+
h2 & 255,
|
|
452
|
+
h3 >>> 24 & 255,
|
|
453
|
+
h3 >>> 16 & 255,
|
|
454
|
+
h3 >>> 8 & 255,
|
|
455
|
+
h3 & 255,
|
|
456
|
+
h4 >>> 24 & 255,
|
|
457
|
+
h4 >>> 16 & 255,
|
|
458
|
+
h4 >>> 8 & 255,
|
|
459
|
+
h4 & 255,
|
|
460
|
+
h5 >>> 24 & 255,
|
|
461
|
+
h5 >>> 16 & 255,
|
|
462
|
+
h5 >>> 8 & 255,
|
|
463
|
+
h5 & 255,
|
|
464
|
+
h6 >>> 24 & 255,
|
|
465
|
+
h6 >>> 16 & 255,
|
|
466
|
+
h6 >>> 8 & 255,
|
|
467
|
+
h6 & 255
|
|
468
|
+
];
|
|
469
|
+
if (!this.is224) {
|
|
470
|
+
arr.push(h7 >>> 24 & 255, h7 >>> 16 & 255, h7 >>> 8 & 255, h7 & 255);
|
|
471
|
+
}
|
|
472
|
+
return arr;
|
|
473
|
+
};
|
|
474
|
+
Sha256.prototype.array = Sha256.prototype.digest;
|
|
475
|
+
Sha256.prototype.arrayBuffer = function() {
|
|
476
|
+
this.finalize();
|
|
477
|
+
var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
|
|
478
|
+
var dataView = new DataView(buffer);
|
|
479
|
+
dataView.setUint32(0, this.h0);
|
|
480
|
+
dataView.setUint32(4, this.h1);
|
|
481
|
+
dataView.setUint32(8, this.h2);
|
|
482
|
+
dataView.setUint32(12, this.h3);
|
|
483
|
+
dataView.setUint32(16, this.h4);
|
|
484
|
+
dataView.setUint32(20, this.h5);
|
|
485
|
+
dataView.setUint32(24, this.h6);
|
|
486
|
+
if (!this.is224) {
|
|
487
|
+
dataView.setUint32(28, this.h7);
|
|
488
|
+
}
|
|
489
|
+
return buffer;
|
|
490
|
+
};
|
|
491
|
+
function HmacSha256(key, is224, sharedMemory) {
|
|
492
|
+
var i, type = typeof key;
|
|
493
|
+
if (type === "string") {
|
|
494
|
+
var bytes = [], length = key.length, index = 0, code;
|
|
495
|
+
for (i = 0; i < length; ++i) {
|
|
496
|
+
code = key.charCodeAt(i);
|
|
497
|
+
if (code < 128) {
|
|
498
|
+
bytes[index++] = code;
|
|
499
|
+
} else if (code < 2048) {
|
|
500
|
+
bytes[index++] = 192 | code >>> 6;
|
|
501
|
+
bytes[index++] = 128 | code & 63;
|
|
502
|
+
} else if (code < 55296 || code >= 57344) {
|
|
503
|
+
bytes[index++] = 224 | code >>> 12;
|
|
504
|
+
bytes[index++] = 128 | code >>> 6 & 63;
|
|
505
|
+
bytes[index++] = 128 | code & 63;
|
|
506
|
+
} else {
|
|
507
|
+
code = 65536 + ((code & 1023) << 10 | key.charCodeAt(++i) & 1023);
|
|
508
|
+
bytes[index++] = 240 | code >>> 18;
|
|
509
|
+
bytes[index++] = 128 | code >>> 12 & 63;
|
|
510
|
+
bytes[index++] = 128 | code >>> 6 & 63;
|
|
511
|
+
bytes[index++] = 128 | code & 63;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
key = bytes;
|
|
515
|
+
} else {
|
|
516
|
+
if (type === "object") {
|
|
517
|
+
if (key === null) {
|
|
518
|
+
throw new Error(ERROR);
|
|
519
|
+
} else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
|
|
520
|
+
key = new Uint8Array(key);
|
|
521
|
+
} else if (!Array.isArray(key)) {
|
|
522
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
|
|
523
|
+
throw new Error(ERROR);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
} else {
|
|
527
|
+
throw new Error(ERROR);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (key.length > 64) {
|
|
531
|
+
key = new Sha256(is224, true).update(key).array();
|
|
532
|
+
}
|
|
533
|
+
var oKeyPad = [], iKeyPad = [];
|
|
534
|
+
for (i = 0; i < 64; ++i) {
|
|
535
|
+
var b = key[i] || 0;
|
|
536
|
+
oKeyPad[i] = 92 ^ b;
|
|
537
|
+
iKeyPad[i] = 54 ^ b;
|
|
538
|
+
}
|
|
539
|
+
Sha256.call(this, is224, sharedMemory);
|
|
540
|
+
this.update(iKeyPad);
|
|
541
|
+
this.oKeyPad = oKeyPad;
|
|
542
|
+
this.inner = true;
|
|
543
|
+
this.sharedMemory = sharedMemory;
|
|
544
|
+
}
|
|
545
|
+
HmacSha256.prototype = new Sha256();
|
|
546
|
+
HmacSha256.prototype.finalize = function() {
|
|
547
|
+
Sha256.prototype.finalize.call(this);
|
|
548
|
+
if (this.inner) {
|
|
549
|
+
this.inner = false;
|
|
550
|
+
var innerHash = this.array();
|
|
551
|
+
Sha256.call(this, this.is224, this.sharedMemory);
|
|
552
|
+
this.update(this.oKeyPad);
|
|
553
|
+
this.update(innerHash);
|
|
554
|
+
Sha256.prototype.finalize.call(this);
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
var exports2 = createMethod();
|
|
558
|
+
exports2.sha256 = exports2;
|
|
559
|
+
exports2.sha224 = createMethod(true);
|
|
560
|
+
exports2.sha256.hmac = createHmacMethod();
|
|
561
|
+
exports2.sha224.hmac = createHmacMethod(true);
|
|
562
|
+
if (COMMON_JS) {
|
|
563
|
+
module.exports = exports2;
|
|
564
|
+
} else {
|
|
565
|
+
root.sha256 = exports2.sha256;
|
|
566
|
+
root.sha224 = exports2.sha224;
|
|
567
|
+
if (AMD) {
|
|
568
|
+
define(function() {
|
|
569
|
+
return exports2;
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
})();
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// src/extractor/index.ts
|
|
578
|
+
var extractor_exports = {};
|
|
579
|
+
__export(extractor_exports, {
|
|
41
580
|
extractTextWithPositionDFS: () => extractTextWithPositionDFS
|
|
42
581
|
});
|
|
43
582
|
|
|
44
|
-
// src/
|
|
45
|
-
|
|
583
|
+
// src/extractor/util.ts
|
|
584
|
+
var import_js_sha256 = __toESM(require_sha256());
|
|
585
|
+
function logger(..._msg) {
|
|
46
586
|
}
|
|
47
587
|
var taskIdKey = "_midscene_retrieve_task_id";
|
|
48
588
|
function selectorForValue(val) {
|
|
49
589
|
return `[${taskIdKey}='${val}']`;
|
|
50
590
|
}
|
|
51
|
-
function setDataForNode(node,
|
|
591
|
+
function setDataForNode(node, nodeHash) {
|
|
52
592
|
const taskId = taskIdKey;
|
|
53
593
|
if (!(node instanceof HTMLElement)) {
|
|
54
594
|
return "";
|
|
@@ -57,8 +597,8 @@ var midscene_element_inspector = (() => {
|
|
|
57
597
|
console.error("No task id found");
|
|
58
598
|
return "";
|
|
59
599
|
}
|
|
60
|
-
const selector = selectorForValue(
|
|
61
|
-
node.setAttribute(taskIdKey,
|
|
600
|
+
const selector = selectorForValue(nodeHash);
|
|
601
|
+
node.setAttribute(taskIdKey, nodeHash.toString());
|
|
62
602
|
return selector;
|
|
63
603
|
}
|
|
64
604
|
function getPseudoElementContent(element) {
|
|
@@ -154,11 +694,17 @@ var midscene_element_inspector = (() => {
|
|
|
154
694
|
});
|
|
155
695
|
return Object.fromEntries(attributesList);
|
|
156
696
|
}
|
|
697
|
+
function generateHash(content, rect) {
|
|
698
|
+
const combined = JSON.stringify({ content, rect });
|
|
699
|
+
const hashHex = (0, import_js_sha256.default)(combined);
|
|
700
|
+
return hashHex.slice(0, 10);
|
|
701
|
+
}
|
|
702
|
+
window.generateHash = generateHash;
|
|
157
703
|
|
|
158
|
-
// src/
|
|
704
|
+
// src/extractor/constants.ts
|
|
159
705
|
var TEXT_SIZE_THRESHOLD = 9;
|
|
160
706
|
|
|
161
|
-
// src/
|
|
707
|
+
// src/extractor/dom-util.ts
|
|
162
708
|
function isInputElement(node) {
|
|
163
709
|
return node instanceof HTMLElement && node.tagName.toLowerCase() === "input";
|
|
164
710
|
}
|
|
@@ -169,22 +715,22 @@ var midscene_element_inspector = (() => {
|
|
|
169
715
|
return node instanceof HTMLElement && node.tagName.toLowerCase() === "img";
|
|
170
716
|
}
|
|
171
717
|
|
|
172
|
-
// src/
|
|
718
|
+
// src/extractor/extractor.ts
|
|
173
719
|
var container = document.body;
|
|
174
720
|
function generateId(numberId) {
|
|
175
721
|
return `${numberId}`;
|
|
176
722
|
}
|
|
177
723
|
function extractTextWithPositionDFS(initNode = container) {
|
|
178
724
|
const elementInfoArray = [];
|
|
179
|
-
const nodeMapTree = { node: initNode,
|
|
725
|
+
const nodeMapTree = { node: initNode, children: [] };
|
|
180
726
|
let nodeIndex = 1;
|
|
181
727
|
function dfs(node, parentNode = null) {
|
|
182
728
|
if (!node) {
|
|
183
729
|
return;
|
|
184
730
|
}
|
|
185
|
-
const currentNodeDes = { node,
|
|
186
|
-
if (parentNode == null ? void 0 : parentNode.
|
|
187
|
-
parentNode.
|
|
731
|
+
const currentNodeDes = { node, children: [] };
|
|
732
|
+
if (parentNode == null ? void 0 : parentNode.children) {
|
|
733
|
+
parentNode.children.push(currentNodeDes);
|
|
188
734
|
}
|
|
189
735
|
collectElementInfo(node);
|
|
190
736
|
for (let i = 0; i < node.childNodes.length; i++) {
|
|
@@ -200,9 +746,12 @@ var midscene_element_inspector = (() => {
|
|
|
200
746
|
}
|
|
201
747
|
if (isInputElement(node)) {
|
|
202
748
|
const attributes = getNodeAttributes(node);
|
|
203
|
-
const
|
|
749
|
+
const nodeHashId = generateHash(attributes.placeholder, rect);
|
|
750
|
+
const selector = setDataForNode(node, nodeHashId);
|
|
204
751
|
elementInfoArray.push({
|
|
205
|
-
id:
|
|
752
|
+
id: nodeHashId,
|
|
753
|
+
indexId: generateId(nodeIndex++),
|
|
754
|
+
nodeHashId,
|
|
206
755
|
locator: selector,
|
|
207
756
|
attributes: __spreadProps(__spreadValues({}, attributes), {
|
|
208
757
|
nodeType: "INPUT Node" /* INPUT */
|
|
@@ -216,14 +765,18 @@ var midscene_element_inspector = (() => {
|
|
|
216
765
|
if (isButtonElement(node)) {
|
|
217
766
|
const attributes = getNodeAttributes(node);
|
|
218
767
|
const pseudo = getPseudoElementContent(node);
|
|
219
|
-
const
|
|
768
|
+
const content = node.innerText || pseudo.before || pseudo.after || "";
|
|
769
|
+
const nodeHashId = generateHash(content, rect);
|
|
770
|
+
const selector = setDataForNode(node, nodeHashId);
|
|
220
771
|
elementInfoArray.push({
|
|
221
|
-
id:
|
|
772
|
+
id: nodeHashId,
|
|
773
|
+
indexId: generateId(nodeIndex++),
|
|
774
|
+
nodeHashId,
|
|
222
775
|
locator: selector,
|
|
223
776
|
attributes: __spreadProps(__spreadValues({}, attributes), {
|
|
224
777
|
nodeType: "BUTTON Node" /* BUTTON */
|
|
225
778
|
}),
|
|
226
|
-
content
|
|
779
|
+
content,
|
|
227
780
|
rect,
|
|
228
781
|
center: [Math.round(rect.left + rect.width / 2), Math.round(rect.top + rect.height / 2)]
|
|
229
782
|
});
|
|
@@ -231,9 +784,12 @@ var midscene_element_inspector = (() => {
|
|
|
231
784
|
}
|
|
232
785
|
if (isImgElement(node)) {
|
|
233
786
|
const attributes = getNodeAttributes(node);
|
|
234
|
-
const
|
|
787
|
+
const nodeHashId = generateHash("", rect);
|
|
788
|
+
const selector = setDataForNode(node, nodeHashId);
|
|
235
789
|
elementInfoArray.push({
|
|
236
|
-
id:
|
|
790
|
+
id: nodeHashId,
|
|
791
|
+
indexId: generateId(nodeIndex++),
|
|
792
|
+
nodeHashId,
|
|
237
793
|
locator: selector,
|
|
238
794
|
attributes: __spreadProps(__spreadValues({}, attributes), {
|
|
239
795
|
nodeType: "IMG Node" /* IMG */
|
|
@@ -251,9 +807,12 @@ var midscene_element_inspector = (() => {
|
|
|
251
807
|
return;
|
|
252
808
|
}
|
|
253
809
|
const attributes = getNodeAttributes(node);
|
|
254
|
-
const
|
|
810
|
+
const nodeHashId = generateHash(text, rect);
|
|
811
|
+
const selector = setDataForNode(node, nodeHashId);
|
|
255
812
|
elementInfoArray.push({
|
|
256
|
-
id:
|
|
813
|
+
id: nodeHashId,
|
|
814
|
+
indexId: generateId(nodeIndex++),
|
|
815
|
+
nodeHashId,
|
|
257
816
|
attributes: __spreadProps(__spreadValues({}, attributes), {
|
|
258
817
|
nodeType: "TEXT Node" /* TEXT */
|
|
259
818
|
}),
|
|
@@ -268,5 +827,17 @@ var midscene_element_inspector = (() => {
|
|
|
268
827
|
dfs(initNode, nodeMapTree);
|
|
269
828
|
return elementInfoArray;
|
|
270
829
|
}
|
|
271
|
-
return __toCommonJS(
|
|
830
|
+
return __toCommonJS(extractor_exports);
|
|
272
831
|
})();
|
|
832
|
+
/*! Bundled license information:
|
|
833
|
+
|
|
834
|
+
js-sha256/src/sha256.js:
|
|
835
|
+
(**
|
|
836
|
+
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
|
837
|
+
*
|
|
838
|
+
* @version 0.11.0
|
|
839
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
840
|
+
* @copyright Chen, Yi-Cyuan 2014-2024
|
|
841
|
+
* @license MIT
|
|
842
|
+
*)
|
|
843
|
+
*/
|