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