@midscene/shared 0.9.1 → 0.9.2-beta-20250114083542.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.
@@ -7,7 +7,8 @@ declare enum NodeType {
7
7
  FORM_ITEM = "FORM_ITEM Node",
8
8
  BUTTON = "BUTTON Node",
9
9
  IMG = "IMG Node",
10
- TEXT = "TEXT Node"
10
+ TEXT = "TEXT Node",
11
+ POSITION = "POSITION Node"
11
12
  }
12
13
 
13
14
  export { CONTAINER_MINI_HEIGHT, CONTAINER_MINI_WIDTH, NodeType, TEXT_MAX_SIZE, TEXT_SIZE_THRESHOLD };
@@ -37,5 +37,6 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
37
37
  NodeType2["BUTTON"] = "BUTTON Node";
38
38
  NodeType2["IMG"] = "IMG Node";
39
39
  NodeType2["TEXT"] = "TEXT Node";
40
+ NodeType2["POSITION"] = "POSITION Node";
40
41
  return NodeType2;
41
42
  })(NodeType || {});
@@ -1,4 +1,7 @@
1
1
  declare const ifInBrowser: boolean;
2
2
  declare function uuid(): string;
3
+ declare function getFrameId(): number;
4
+ declare function setFrameId(id: number): void;
5
+ declare function generateHashId(rect: any, content?: string): string;
3
6
 
4
- export { ifInBrowser, uuid };
7
+ export { generateHashId, getFrameId, ifInBrowser, setFrameId, uuid };
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
6
11
  var __export = (target, all) => {
7
12
  for (var name in all)
8
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,20 +20,595 @@ var __copyProps = (to, from, except, desc) => {
15
20
  }
16
21
  return to;
17
22
  };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
18
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
32
 
33
+ // resolve-false:/empty-stub
34
+ var require_empty_stub = __commonJS({
35
+ "resolve-false:/empty-stub"(exports, module2) {
36
+ "use strict";
37
+ module2.exports = {};
38
+ }
39
+ });
40
+
41
+ // ../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js
42
+ var require_sha256 = __commonJS({
43
+ "../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js"(exports, module2) {
44
+ "use strict";
45
+ (function() {
46
+ "use strict";
47
+ var ERROR = "input is invalid type";
48
+ var WINDOW = typeof window === "object";
49
+ var root = WINDOW ? window : {};
50
+ if (root.JS_SHA256_NO_WINDOW) {
51
+ WINDOW = false;
52
+ }
53
+ var WEB_WORKER = !WINDOW && typeof self === "object";
54
+ var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node;
55
+ if (NODE_JS) {
56
+ root = global;
57
+ } else if (WEB_WORKER) {
58
+ root = self;
59
+ }
60
+ var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module2 === "object" && module2.exports;
61
+ var AMD = typeof define === "function" && define.amd;
62
+ var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined";
63
+ var HEX_CHARS = "0123456789abcdef".split("");
64
+ var EXTRA = [-2147483648, 8388608, 32768, 128];
65
+ var SHIFT = [24, 16, 8, 0];
66
+ var K = [
67
+ 1116352408,
68
+ 1899447441,
69
+ 3049323471,
70
+ 3921009573,
71
+ 961987163,
72
+ 1508970993,
73
+ 2453635748,
74
+ 2870763221,
75
+ 3624381080,
76
+ 310598401,
77
+ 607225278,
78
+ 1426881987,
79
+ 1925078388,
80
+ 2162078206,
81
+ 2614888103,
82
+ 3248222580,
83
+ 3835390401,
84
+ 4022224774,
85
+ 264347078,
86
+ 604807628,
87
+ 770255983,
88
+ 1249150122,
89
+ 1555081692,
90
+ 1996064986,
91
+ 2554220882,
92
+ 2821834349,
93
+ 2952996808,
94
+ 3210313671,
95
+ 3336571891,
96
+ 3584528711,
97
+ 113926993,
98
+ 338241895,
99
+ 666307205,
100
+ 773529912,
101
+ 1294757372,
102
+ 1396182291,
103
+ 1695183700,
104
+ 1986661051,
105
+ 2177026350,
106
+ 2456956037,
107
+ 2730485921,
108
+ 2820302411,
109
+ 3259730800,
110
+ 3345764771,
111
+ 3516065817,
112
+ 3600352804,
113
+ 4094571909,
114
+ 275423344,
115
+ 430227734,
116
+ 506948616,
117
+ 659060556,
118
+ 883997877,
119
+ 958139571,
120
+ 1322822218,
121
+ 1537002063,
122
+ 1747873779,
123
+ 1955562222,
124
+ 2024104815,
125
+ 2227730452,
126
+ 2361852424,
127
+ 2428436474,
128
+ 2756734187,
129
+ 3204031479,
130
+ 3329325298
131
+ ];
132
+ var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
133
+ var blocks = [];
134
+ if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
135
+ Array.isArray = function(obj) {
136
+ return Object.prototype.toString.call(obj) === "[object Array]";
137
+ };
138
+ }
139
+ if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
140
+ ArrayBuffer.isView = function(obj) {
141
+ return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer;
142
+ };
143
+ }
144
+ var createOutputMethod = function(outputType, is224) {
145
+ return function(message) {
146
+ return new Sha256(is224, true).update(message)[outputType]();
147
+ };
148
+ };
149
+ var createMethod = function(is224) {
150
+ var method = createOutputMethod("hex", is224);
151
+ if (NODE_JS) {
152
+ method = nodeWrap(method, is224);
153
+ }
154
+ method.create = function() {
155
+ return new Sha256(is224);
156
+ };
157
+ method.update = function(message) {
158
+ return method.create().update(message);
159
+ };
160
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
161
+ var type = OUTPUT_TYPES[i];
162
+ method[type] = createOutputMethod(type, is224);
163
+ }
164
+ return method;
165
+ };
166
+ var nodeWrap = function(method, is224) {
167
+ var crypto = require_empty_stub();
168
+ var Buffer2 = require_empty_stub().Buffer;
169
+ var algorithm = is224 ? "sha224" : "sha256";
170
+ var bufferFrom;
171
+ if (Buffer2.from && !root.JS_SHA256_NO_BUFFER_FROM) {
172
+ bufferFrom = Buffer2.from;
173
+ } else {
174
+ bufferFrom = function(message) {
175
+ return new Buffer2(message);
176
+ };
177
+ }
178
+ var nodeMethod = function(message) {
179
+ if (typeof message === "string") {
180
+ return crypto.createHash(algorithm).update(message, "utf8").digest("hex");
181
+ } else {
182
+ if (message === null || message === void 0) {
183
+ throw new Error(ERROR);
184
+ } else if (message.constructor === ArrayBuffer) {
185
+ message = new Uint8Array(message);
186
+ }
187
+ }
188
+ if (Array.isArray(message) || ArrayBuffer.isView(message) || message.constructor === Buffer2) {
189
+ return crypto.createHash(algorithm).update(bufferFrom(message)).digest("hex");
190
+ } else {
191
+ return method(message);
192
+ }
193
+ };
194
+ return nodeMethod;
195
+ };
196
+ var createHmacOutputMethod = function(outputType, is224) {
197
+ return function(key, message) {
198
+ return new HmacSha256(key, is224, true).update(message)[outputType]();
199
+ };
200
+ };
201
+ var createHmacMethod = function(is224) {
202
+ var method = createHmacOutputMethod("hex", is224);
203
+ method.create = function(key) {
204
+ return new HmacSha256(key, is224);
205
+ };
206
+ method.update = function(key, message) {
207
+ return method.create(key).update(message);
208
+ };
209
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
210
+ var type = OUTPUT_TYPES[i];
211
+ method[type] = createHmacOutputMethod(type, is224);
212
+ }
213
+ return method;
214
+ };
215
+ function Sha256(is224, sharedMemory) {
216
+ if (sharedMemory) {
217
+ 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;
218
+ this.blocks = blocks;
219
+ } else {
220
+ this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
221
+ }
222
+ if (is224) {
223
+ this.h0 = 3238371032;
224
+ this.h1 = 914150663;
225
+ this.h2 = 812702999;
226
+ this.h3 = 4144912697;
227
+ this.h4 = 4290775857;
228
+ this.h5 = 1750603025;
229
+ this.h6 = 1694076839;
230
+ this.h7 = 3204075428;
231
+ } else {
232
+ this.h0 = 1779033703;
233
+ this.h1 = 3144134277;
234
+ this.h2 = 1013904242;
235
+ this.h3 = 2773480762;
236
+ this.h4 = 1359893119;
237
+ this.h5 = 2600822924;
238
+ this.h6 = 528734635;
239
+ this.h7 = 1541459225;
240
+ }
241
+ this.block = this.start = this.bytes = this.hBytes = 0;
242
+ this.finalized = this.hashed = false;
243
+ this.first = true;
244
+ this.is224 = is224;
245
+ }
246
+ Sha256.prototype.update = function(message) {
247
+ if (this.finalized) {
248
+ return;
249
+ }
250
+ var notString, type = typeof message;
251
+ if (type !== "string") {
252
+ if (type === "object") {
253
+ if (message === null) {
254
+ throw new Error(ERROR);
255
+ } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
256
+ message = new Uint8Array(message);
257
+ } else if (!Array.isArray(message)) {
258
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
259
+ throw new Error(ERROR);
260
+ }
261
+ }
262
+ } else {
263
+ throw new Error(ERROR);
264
+ }
265
+ notString = true;
266
+ }
267
+ var code, index = 0, i, length = message.length, blocks2 = this.blocks;
268
+ while (index < length) {
269
+ if (this.hashed) {
270
+ this.hashed = false;
271
+ blocks2[0] = this.block;
272
+ 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;
273
+ }
274
+ if (notString) {
275
+ for (i = this.start; index < length && i < 64; ++index) {
276
+ blocks2[i >>> 2] |= message[index] << SHIFT[i++ & 3];
277
+ }
278
+ } else {
279
+ for (i = this.start; index < length && i < 64; ++index) {
280
+ code = message.charCodeAt(index);
281
+ if (code < 128) {
282
+ blocks2[i >>> 2] |= code << SHIFT[i++ & 3];
283
+ } else if (code < 2048) {
284
+ blocks2[i >>> 2] |= (192 | code >>> 6) << SHIFT[i++ & 3];
285
+ blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
286
+ } else if (code < 55296 || code >= 57344) {
287
+ blocks2[i >>> 2] |= (224 | code >>> 12) << SHIFT[i++ & 3];
288
+ blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
289
+ blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
290
+ } else {
291
+ code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023);
292
+ blocks2[i >>> 2] |= (240 | code >>> 18) << SHIFT[i++ & 3];
293
+ blocks2[i >>> 2] |= (128 | code >>> 12 & 63) << SHIFT[i++ & 3];
294
+ blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
295
+ blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
296
+ }
297
+ }
298
+ }
299
+ this.lastByteIndex = i;
300
+ this.bytes += i - this.start;
301
+ if (i >= 64) {
302
+ this.block = blocks2[16];
303
+ this.start = i - 64;
304
+ this.hash();
305
+ this.hashed = true;
306
+ } else {
307
+ this.start = i;
308
+ }
309
+ }
310
+ if (this.bytes > 4294967295) {
311
+ this.hBytes += this.bytes / 4294967296 << 0;
312
+ this.bytes = this.bytes % 4294967296;
313
+ }
314
+ return this;
315
+ };
316
+ Sha256.prototype.finalize = function() {
317
+ if (this.finalized) {
318
+ return;
319
+ }
320
+ this.finalized = true;
321
+ var blocks2 = this.blocks, i = this.lastByteIndex;
322
+ blocks2[16] = this.block;
323
+ blocks2[i >>> 2] |= EXTRA[i & 3];
324
+ this.block = blocks2[16];
325
+ if (i >= 56) {
326
+ if (!this.hashed) {
327
+ this.hash();
328
+ }
329
+ blocks2[0] = this.block;
330
+ 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;
331
+ }
332
+ blocks2[14] = this.hBytes << 3 | this.bytes >>> 29;
333
+ blocks2[15] = this.bytes << 3;
334
+ this.hash();
335
+ };
336
+ Sha256.prototype.hash = function() {
337
+ 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;
338
+ for (j = 16; j < 64; ++j) {
339
+ t1 = blocks2[j - 15];
340
+ s0 = (t1 >>> 7 | t1 << 25) ^ (t1 >>> 18 | t1 << 14) ^ t1 >>> 3;
341
+ t1 = blocks2[j - 2];
342
+ s1 = (t1 >>> 17 | t1 << 15) ^ (t1 >>> 19 | t1 << 13) ^ t1 >>> 10;
343
+ blocks2[j] = blocks2[j - 16] + s0 + blocks2[j - 7] + s1 << 0;
344
+ }
345
+ bc = b & c;
346
+ for (j = 0; j < 64; j += 4) {
347
+ if (this.first) {
348
+ if (this.is224) {
349
+ ab = 300032;
350
+ t1 = blocks2[0] - 1413257819;
351
+ h = t1 - 150054599 << 0;
352
+ d = t1 + 24177077 << 0;
353
+ } else {
354
+ ab = 704751109;
355
+ t1 = blocks2[0] - 210244248;
356
+ h = t1 - 1521486534 << 0;
357
+ d = t1 + 143694565 << 0;
358
+ }
359
+ this.first = false;
360
+ } else {
361
+ s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
362
+ s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
363
+ ab = a & b;
364
+ maj = ab ^ a & c ^ bc;
365
+ ch = e & f ^ ~e & g;
366
+ t1 = h + s1 + ch + K[j] + blocks2[j];
367
+ t2 = s0 + maj;
368
+ h = d + t1 << 0;
369
+ d = t1 + t2 << 0;
370
+ }
371
+ s0 = (d >>> 2 | d << 30) ^ (d >>> 13 | d << 19) ^ (d >>> 22 | d << 10);
372
+ s1 = (h >>> 6 | h << 26) ^ (h >>> 11 | h << 21) ^ (h >>> 25 | h << 7);
373
+ da = d & a;
374
+ maj = da ^ d & b ^ ab;
375
+ ch = h & e ^ ~h & f;
376
+ t1 = g + s1 + ch + K[j + 1] + blocks2[j + 1];
377
+ t2 = s0 + maj;
378
+ g = c + t1 << 0;
379
+ c = t1 + t2 << 0;
380
+ s0 = (c >>> 2 | c << 30) ^ (c >>> 13 | c << 19) ^ (c >>> 22 | c << 10);
381
+ s1 = (g >>> 6 | g << 26) ^ (g >>> 11 | g << 21) ^ (g >>> 25 | g << 7);
382
+ cd = c & d;
383
+ maj = cd ^ c & a ^ da;
384
+ ch = g & h ^ ~g & e;
385
+ t1 = f + s1 + ch + K[j + 2] + blocks2[j + 2];
386
+ t2 = s0 + maj;
387
+ f = b + t1 << 0;
388
+ b = t1 + t2 << 0;
389
+ s0 = (b >>> 2 | b << 30) ^ (b >>> 13 | b << 19) ^ (b >>> 22 | b << 10);
390
+ s1 = (f >>> 6 | f << 26) ^ (f >>> 11 | f << 21) ^ (f >>> 25 | f << 7);
391
+ bc = b & c;
392
+ maj = bc ^ b & d ^ cd;
393
+ ch = f & g ^ ~f & h;
394
+ t1 = e + s1 + ch + K[j + 3] + blocks2[j + 3];
395
+ t2 = s0 + maj;
396
+ e = a + t1 << 0;
397
+ a = t1 + t2 << 0;
398
+ this.chromeBugWorkAround = true;
399
+ }
400
+ this.h0 = this.h0 + a << 0;
401
+ this.h1 = this.h1 + b << 0;
402
+ this.h2 = this.h2 + c << 0;
403
+ this.h3 = this.h3 + d << 0;
404
+ this.h4 = this.h4 + e << 0;
405
+ this.h5 = this.h5 + f << 0;
406
+ this.h6 = this.h6 + g << 0;
407
+ this.h7 = this.h7 + h << 0;
408
+ };
409
+ Sha256.prototype.hex = function() {
410
+ this.finalize();
411
+ 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;
412
+ 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];
413
+ if (!this.is224) {
414
+ 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];
415
+ }
416
+ return hex;
417
+ };
418
+ Sha256.prototype.toString = Sha256.prototype.hex;
419
+ Sha256.prototype.digest = function() {
420
+ this.finalize();
421
+ 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;
422
+ var arr = [
423
+ h0 >>> 24 & 255,
424
+ h0 >>> 16 & 255,
425
+ h0 >>> 8 & 255,
426
+ h0 & 255,
427
+ h1 >>> 24 & 255,
428
+ h1 >>> 16 & 255,
429
+ h1 >>> 8 & 255,
430
+ h1 & 255,
431
+ h2 >>> 24 & 255,
432
+ h2 >>> 16 & 255,
433
+ h2 >>> 8 & 255,
434
+ h2 & 255,
435
+ h3 >>> 24 & 255,
436
+ h3 >>> 16 & 255,
437
+ h3 >>> 8 & 255,
438
+ h3 & 255,
439
+ h4 >>> 24 & 255,
440
+ h4 >>> 16 & 255,
441
+ h4 >>> 8 & 255,
442
+ h4 & 255,
443
+ h5 >>> 24 & 255,
444
+ h5 >>> 16 & 255,
445
+ h5 >>> 8 & 255,
446
+ h5 & 255,
447
+ h6 >>> 24 & 255,
448
+ h6 >>> 16 & 255,
449
+ h6 >>> 8 & 255,
450
+ h6 & 255
451
+ ];
452
+ if (!this.is224) {
453
+ arr.push(h7 >>> 24 & 255, h7 >>> 16 & 255, h7 >>> 8 & 255, h7 & 255);
454
+ }
455
+ return arr;
456
+ };
457
+ Sha256.prototype.array = Sha256.prototype.digest;
458
+ Sha256.prototype.arrayBuffer = function() {
459
+ this.finalize();
460
+ var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
461
+ var dataView = new DataView(buffer);
462
+ dataView.setUint32(0, this.h0);
463
+ dataView.setUint32(4, this.h1);
464
+ dataView.setUint32(8, this.h2);
465
+ dataView.setUint32(12, this.h3);
466
+ dataView.setUint32(16, this.h4);
467
+ dataView.setUint32(20, this.h5);
468
+ dataView.setUint32(24, this.h6);
469
+ if (!this.is224) {
470
+ dataView.setUint32(28, this.h7);
471
+ }
472
+ return buffer;
473
+ };
474
+ function HmacSha256(key, is224, sharedMemory) {
475
+ var i, type = typeof key;
476
+ if (type === "string") {
477
+ var bytes = [], length = key.length, index = 0, code;
478
+ for (i = 0; i < length; ++i) {
479
+ code = key.charCodeAt(i);
480
+ if (code < 128) {
481
+ bytes[index++] = code;
482
+ } else if (code < 2048) {
483
+ bytes[index++] = 192 | code >>> 6;
484
+ bytes[index++] = 128 | code & 63;
485
+ } else if (code < 55296 || code >= 57344) {
486
+ bytes[index++] = 224 | code >>> 12;
487
+ bytes[index++] = 128 | code >>> 6 & 63;
488
+ bytes[index++] = 128 | code & 63;
489
+ } else {
490
+ code = 65536 + ((code & 1023) << 10 | key.charCodeAt(++i) & 1023);
491
+ bytes[index++] = 240 | code >>> 18;
492
+ bytes[index++] = 128 | code >>> 12 & 63;
493
+ bytes[index++] = 128 | code >>> 6 & 63;
494
+ bytes[index++] = 128 | code & 63;
495
+ }
496
+ }
497
+ key = bytes;
498
+ } else {
499
+ if (type === "object") {
500
+ if (key === null) {
501
+ throw new Error(ERROR);
502
+ } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
503
+ key = new Uint8Array(key);
504
+ } else if (!Array.isArray(key)) {
505
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
506
+ throw new Error(ERROR);
507
+ }
508
+ }
509
+ } else {
510
+ throw new Error(ERROR);
511
+ }
512
+ }
513
+ if (key.length > 64) {
514
+ key = new Sha256(is224, true).update(key).array();
515
+ }
516
+ var oKeyPad = [], iKeyPad = [];
517
+ for (i = 0; i < 64; ++i) {
518
+ var b = key[i] || 0;
519
+ oKeyPad[i] = 92 ^ b;
520
+ iKeyPad[i] = 54 ^ b;
521
+ }
522
+ Sha256.call(this, is224, sharedMemory);
523
+ this.update(iKeyPad);
524
+ this.oKeyPad = oKeyPad;
525
+ this.inner = true;
526
+ this.sharedMemory = sharedMemory;
527
+ }
528
+ HmacSha256.prototype = new Sha256();
529
+ HmacSha256.prototype.finalize = function() {
530
+ Sha256.prototype.finalize.call(this);
531
+ if (this.inner) {
532
+ this.inner = false;
533
+ var innerHash = this.array();
534
+ Sha256.call(this, this.is224, this.sharedMemory);
535
+ this.update(this.oKeyPad);
536
+ this.update(innerHash);
537
+ Sha256.prototype.finalize.call(this);
538
+ }
539
+ };
540
+ var exports2 = createMethod();
541
+ exports2.sha256 = exports2;
542
+ exports2.sha224 = createMethod(true);
543
+ exports2.sha256.hmac = createHmacMethod();
544
+ exports2.sha224.hmac = createHmacMethod(true);
545
+ if (COMMON_JS) {
546
+ module2.exports = exports2;
547
+ } else {
548
+ root.sha256 = exports2.sha256;
549
+ root.sha224 = exports2.sha224;
550
+ if (AMD) {
551
+ define(function() {
552
+ return exports2;
553
+ });
554
+ }
555
+ }
556
+ })();
557
+ }
558
+ });
559
+
20
560
  // src/utils.ts
21
561
  var utils_exports = {};
22
562
  __export(utils_exports, {
563
+ generateHashId: () => generateHashId,
564
+ getFrameId: () => getFrameId,
23
565
  ifInBrowser: () => ifInBrowser,
566
+ setFrameId: () => setFrameId,
24
567
  uuid: () => uuid
25
568
  });
26
569
  module.exports = __toCommonJS(utils_exports);
27
- var import_node_crypto = require("crypto");
570
+ var import_js_sha256 = __toESM(require_sha256());
28
571
  var ifInBrowser = typeof window !== "undefined";
29
572
  function uuid() {
30
- if (ifInBrowser) {
31
- return Math.random().toString(36).substring(2, 15);
573
+ return Math.random().toString(36).substring(2, 15);
574
+ }
575
+ var hashMap = {};
576
+ var frameId = 0;
577
+ function getFrameId() {
578
+ return frameId;
579
+ }
580
+ function setFrameId(id) {
581
+ frameId = id;
582
+ }
583
+ function generateHashId(rect, content = "") {
584
+ const combined = JSON.stringify({
585
+ content,
586
+ rect,
587
+ _midscene_frame_id: getFrameId()
588
+ });
589
+ let sliceLength = 8;
590
+ let slicedHash = "";
591
+ const hashHex = import_js_sha256.sha256.create().update(combined).hex();
592
+ while (sliceLength < hashHex.length - 1) {
593
+ slicedHash = hashHex.slice(0, sliceLength);
594
+ if (hashMap[slicedHash] && hashMap[slicedHash] !== combined) {
595
+ sliceLength++;
596
+ continue;
597
+ }
598
+ hashMap[slicedHash] = combined;
599
+ break;
32
600
  }
33
- return (0, import_node_crypto.randomUUID)();
601
+ return slicedHash;
34
602
  }
603
+ /*! Bundled license information:
604
+
605
+ js-sha256/src/sha256.js:
606
+ (**
607
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
608
+ *
609
+ * @version 0.11.0
610
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
611
+ * @copyright Chen, Yi-Cyuan 2014-2024
612
+ * @license MIT
613
+ *)
614
+ */
@@ -7,7 +7,8 @@ declare enum NodeType {
7
7
  FORM_ITEM = "FORM_ITEM Node",
8
8
  BUTTON = "BUTTON Node",
9
9
  IMG = "IMG Node",
10
- TEXT = "TEXT Node"
10
+ TEXT = "TEXT Node",
11
+ POSITION = "POSITION Node"
11
12
  }
12
13
 
13
14
  export { CONTAINER_MINI_HEIGHT, CONTAINER_MINI_WIDTH, NodeType, TEXT_MAX_SIZE, TEXT_SIZE_THRESHOLD };
@@ -9,6 +9,7 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
9
9
  NodeType2["BUTTON"] = "BUTTON Node";
10
10
  NodeType2["IMG"] = "IMG Node";
11
11
  NodeType2["TEXT"] = "TEXT Node";
12
+ NodeType2["POSITION"] = "POSITION Node";
12
13
  return NodeType2;
13
14
  })(NodeType || {});
14
15
  export {
@@ -1,4 +1,7 @@
1
1
  declare const ifInBrowser: boolean;
2
2
  declare function uuid(): string;
3
+ declare function getFrameId(): number;
4
+ declare function setFrameId(id: number): void;
5
+ declare function generateHashId(rect: any, content?: string): string;
3
6
 
4
- export { ifInBrowser, uuid };
7
+ export { generateHashId, getFrameId, ifInBrowser, setFrameId, uuid };