@xiuchang-midscene/shared 2.0.2 → 2.0.3
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/oss/index.mjs +1 -1
- package/dist/lib/oss/index.js +1 -1
- package/package.json +1 -1
- package/src/oss/index.ts +1 -1
- package/dist/es/baseDB.mjs.bak +0 -109
- package/dist/es/build/copy-static.mjs.bak +0 -31
- package/dist/es/build/rspack-config.mjs.bak +0 -4
- package/dist/es/cli/cli-runner.mjs.bak +0 -140
- package/dist/es/cli/index.mjs.bak +0 -2
- package/dist/es/common.mjs.bak +0 -37
- package/dist/es/constants/example-code.mjs.bak +0 -223
- package/dist/es/constants/index.mjs.bak +0 -23
- package/dist/es/env/basic.mjs.bak +0 -6
- package/dist/es/env/constants.mjs.bak +0 -70
- package/dist/es/env/global-config-manager.mjs.bak +0 -94
- package/dist/es/env/helper.mjs.bak +0 -43
- package/dist/es/env/index.mjs.bak +0 -5
- package/dist/es/env/init-debug.mjs.bak +0 -18
- package/dist/es/env/model-config-manager.mjs.bak +0 -79
- package/dist/es/env/parse-model-config.mjs.bak +0 -132
- package/dist/es/env/types.mjs.bak +0 -220
- package/dist/es/env/utils.mjs.bak +0 -26
- package/dist/es/extractor/constants.mjs.bak +0 -2
- package/dist/es/extractor/debug.mjs.bak +0 -6
- package/dist/es/extractor/dom-util.mjs.bak +0 -92
- package/dist/es/extractor/index.mjs.bak +0 -5
- package/dist/es/extractor/locator.mjs.bak +0 -250
- package/dist/es/extractor/tree.mjs.bak +0 -78
- package/dist/es/extractor/util.mjs.bak +0 -245
- package/dist/es/extractor/web-extractor.mjs.bak +0 -303
- package/dist/es/img/box-select.mjs.bak +0 -824
- package/dist/es/img/canvas-fallback.mjs.bak +0 -238
- package/dist/es/img/get-photon.mjs.bak +0 -45
- package/dist/es/img/get-sharp.mjs.bak +0 -11
- package/dist/es/img/index.mjs.bak +0 -4
- package/dist/es/img/info.mjs.bak +0 -29
- package/dist/es/img/transform.mjs.bak +0 -295
- package/dist/es/index.mjs.bak +0 -4
- package/dist/es/logger.mjs.bak +0 -64
- package/dist/es/mcp/base-server.mjs.bak +0 -281
- package/dist/es/mcp/base-tools.mjs.bak +0 -91
- package/dist/es/mcp/chrome-path.mjs.bak +0 -35
- package/dist/es/mcp/index.mjs.bak +0 -7
- package/dist/es/mcp/inject-report-html-plugin.mjs.bak +0 -53
- package/dist/es/mcp/launcher-helper.mjs.bak +0 -52
- package/dist/es/mcp/tool-generator.mjs.bak +0 -297
- package/dist/es/mcp/types.mjs.bak +0 -3
- package/dist/es/node/fs.mjs.bak +0 -44
- package/dist/es/node/index.mjs.bak +0 -2
- package/dist/es/node/port.mjs.bak +0 -24
- package/dist/es/oss/demo.mjs.bak +0 -30
- package/dist/es/oss/index.mjs.bak +0 -90
- package/dist/es/polyfills/async-hooks.mjs.bak +0 -2
- package/dist/es/polyfills/index.mjs.bak +0 -1
- package/dist/es/types/index.mjs.bak +0 -3
- package/dist/es/us-keyboard-layout.mjs.bak +0 -1414
- package/dist/es/utils.mjs.bak +0 -72
- package/dist/es/zod-schema-utils.mjs.bak +0 -54
- package/dist/lib/baseDB.js.bak +0 -149
- package/dist/lib/build/copy-static.js.bak +0 -79
- package/dist/lib/build/rspack-config.js.bak +0 -38
- package/dist/lib/cli/cli-runner.js.bak +0 -196
- package/dist/lib/cli/index.js.bak +0 -48
- package/dist/lib/common.js.bak +0 -93
- package/dist/lib/constants/example-code.js.bak +0 -260
- package/dist/lib/constants/index.js.bak +0 -96
- package/dist/lib/env/basic.js.bak +0 -40
- package/dist/lib/env/constants.js.bak +0 -113
- package/dist/lib/env/global-config-manager.js.bak +0 -128
- package/dist/lib/env/helper.js.bak +0 -80
- package/dist/lib/env/index.js.bak +0 -90
- package/dist/lib/env/init-debug.js.bak +0 -52
- package/dist/lib/env/model-config-manager.js.bak +0 -113
- package/dist/lib/env/parse-model-config.js.bak +0 -178
- package/dist/lib/env/types.js.bak +0 -554
- package/dist/lib/env/utils.js.bak +0 -72
- package/dist/lib/extractor/constants.js.bak +0 -42
- package/dist/lib/extractor/debug.js.bak +0 -12
- package/dist/lib/extractor/dom-util.js.bak +0 -153
- package/dist/lib/extractor/index.js.bak +0 -81
- package/dist/lib/extractor/locator.js.bak +0 -296
- package/dist/lib/extractor/tree.js.bak +0 -124
- package/dist/lib/extractor/util.js.bak +0 -336
- package/dist/lib/extractor/web-extractor.js.bak +0 -349
- package/dist/lib/img/box-select.js.bak +0 -875
- package/dist/lib/img/canvas-fallback.js.bak +0 -305
- package/dist/lib/img/get-photon.js.bak +0 -82
- package/dist/lib/img/get-sharp.js.bak +0 -45
- package/dist/lib/img/index.js.bak +0 -95
- package/dist/lib/img/info.js.bak +0 -83
- package/dist/lib/img/transform.js.bak +0 -387
- package/dist/lib/index.js.bak +0 -47
- package/dist/lib/logger.js.bak +0 -114
- package/dist/lib/mcp/base-server.js.bak +0 -331
- package/dist/lib/mcp/base-tools.js.bak +0 -125
- package/dist/lib/mcp/chrome-path.js.bak +0 -72
- package/dist/lib/mcp/index.js.bak +0 -100
- package/dist/lib/mcp/inject-report-html-plugin.js.bak +0 -98
- package/dist/lib/mcp/launcher-helper.js.bak +0 -86
- package/dist/lib/mcp/tool-generator.js.bak +0 -334
- package/dist/lib/mcp/types.js.bak +0 -40
- package/dist/lib/node/fs.js.bak +0 -97
- package/dist/lib/node/index.js.bak +0 -65
- package/dist/lib/node/port.js.bak +0 -61
- package/dist/lib/oss/demo.js.bak +0 -36
- package/dist/lib/oss/index.js.bak +0 -138
- package/dist/lib/polyfills/async-hooks.js.bak +0 -36
- package/dist/lib/polyfills/index.js.bak +0 -58
- package/dist/lib/types/index.js.bak +0 -37
- package/dist/lib/us-keyboard-layout.js.bak +0 -1457
- package/dist/lib/utils.js.bak +0 -148
- package/dist/lib/zod-schema-utils.js.bak +0 -97
- package/dist/types/baseDB.d.ts.bak +0 -25
- package/dist/types/build/copy-static.d.ts.bak +0 -31
- package/dist/types/build/rspack-config.d.ts.bak +0 -8
- package/dist/types/cli/cli-runner.d.ts.bak +0 -14
- package/dist/types/cli/index.d.ts.bak +0 -2
- package/dist/types/common.d.ts.bak +0 -12
- package/dist/types/constants/example-code.d.ts.bak +0 -2
- package/dist/types/constants/index.d.ts.bak +0 -21
- package/dist/types/env/basic.d.ts.bak +0 -6
- package/dist/types/env/constants.d.ts.bak +0 -40
- package/dist/types/env/global-config-manager.d.ts.bak +0 -32
- package/dist/types/env/helper.d.ts.bak +0 -4
- package/dist/types/env/index.d.ts.bak +0 -4
- package/dist/types/env/init-debug.d.ts.bak +0 -1
- package/dist/types/env/model-config-manager.d.ts.bak +0 -25
- package/dist/types/env/parse-model-config.d.ts.bak +0 -31
- package/dist/types/env/types.d.ts.bak +0 -318
- package/dist/types/env/utils.d.ts.bak +0 -38
- package/dist/types/extractor/constants.d.ts.bak +0 -1
- package/dist/types/extractor/debug.d.ts.bak +0 -1
- package/dist/types/extractor/dom-util.d.ts.bak +0 -56
- package/dist/types/extractor/index.d.ts.bak +0 -32
- package/dist/types/extractor/locator.d.ts.bak +0 -9
- package/dist/types/extractor/tree.d.ts.bak +0 -6
- package/dist/types/extractor/util.d.ts.bak +0 -47
- package/dist/types/extractor/web-extractor.d.ts.bak +0 -19
- package/dist/types/img/box-select.d.ts.bak +0 -26
- package/dist/types/img/canvas-fallback.d.ts.bak +0 -105
- package/dist/types/img/get-photon.d.ts.bak +0 -19
- package/dist/types/img/get-sharp.d.ts.bak +0 -3
- package/dist/types/img/index.d.ts.bak +0 -3
- package/dist/types/img/info.d.ts.bak +0 -29
- package/dist/types/img/transform.d.ts.bak +0 -107
- package/dist/types/index.d.ts.bak +0 -4
- package/dist/types/logger.d.ts.bak +0 -5
- package/dist/types/mcp/base-server.d.ts.bak +0 -93
- package/dist/types/mcp/base-tools.d.ts.bak +0 -79
- package/dist/types/mcp/chrome-path.d.ts.bak +0 -2
- package/dist/types/mcp/index.d.ts.bak +0 -7
- package/dist/types/mcp/inject-report-html-plugin.d.ts.bak +0 -18
- package/dist/types/mcp/launcher-helper.d.ts.bak +0 -94
- package/dist/types/mcp/tool-generator.d.ts.bak +0 -10
- package/dist/types/mcp/types.d.ts.bak +0 -103
- package/dist/types/node/fs.d.ts.bak +0 -15
- package/dist/types/node/index.d.ts.bak +0 -2
- package/dist/types/node/port.d.ts.bak +0 -8
- package/dist/types/oss/demo.d.ts.bak +0 -1
- package/dist/types/oss/index.d.ts.bak +0 -34
- package/dist/types/polyfills/async-hooks.d.ts.bak +0 -6
- package/dist/types/polyfills/index.d.ts.bak +0 -4
- package/dist/types/types/index.d.ts.bak +0 -34
- package/dist/types/us-keyboard-layout.d.ts.bak +0 -32
- package/dist/types/utils.d.ts.bak +0 -34
- package/dist/types/zod-schema-utils.d.ts.bak +0 -23
|
@@ -1,875 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
compositeElementInfoImg: ()=>compositeElementInfoImg,
|
|
37
|
-
processImageElementInfo: ()=>processImageElementInfo,
|
|
38
|
-
annotateRects: ()=>annotateRects
|
|
39
|
-
});
|
|
40
|
-
const external_node_assert_namespaceObject = require("node:assert");
|
|
41
|
-
var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
|
|
42
|
-
const index_js_namespaceObject = require("../constants/index.js");
|
|
43
|
-
const external_get_photon_js_namespaceObject = require("./get-photon.js");
|
|
44
|
-
var external_get_photon_js_default = /*#__PURE__*/ __webpack_require__.n(external_get_photon_js_namespaceObject);
|
|
45
|
-
const external_transform_js_namespaceObject = require("./transform.js");
|
|
46
|
-
const DIGIT_FONT = {
|
|
47
|
-
0: [
|
|
48
|
-
[
|
|
49
|
-
0,
|
|
50
|
-
1,
|
|
51
|
-
1,
|
|
52
|
-
1,
|
|
53
|
-
0
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
1,
|
|
57
|
-
0,
|
|
58
|
-
0,
|
|
59
|
-
0,
|
|
60
|
-
1
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
|
-
1,
|
|
64
|
-
0,
|
|
65
|
-
0,
|
|
66
|
-
0,
|
|
67
|
-
1
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
1,
|
|
71
|
-
0,
|
|
72
|
-
0,
|
|
73
|
-
0,
|
|
74
|
-
1
|
|
75
|
-
],
|
|
76
|
-
[
|
|
77
|
-
1,
|
|
78
|
-
0,
|
|
79
|
-
0,
|
|
80
|
-
0,
|
|
81
|
-
1
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
1,
|
|
85
|
-
0,
|
|
86
|
-
0,
|
|
87
|
-
0,
|
|
88
|
-
1
|
|
89
|
-
],
|
|
90
|
-
[
|
|
91
|
-
0,
|
|
92
|
-
1,
|
|
93
|
-
1,
|
|
94
|
-
1,
|
|
95
|
-
0
|
|
96
|
-
]
|
|
97
|
-
],
|
|
98
|
-
1: [
|
|
99
|
-
[
|
|
100
|
-
0,
|
|
101
|
-
0,
|
|
102
|
-
1,
|
|
103
|
-
0,
|
|
104
|
-
0
|
|
105
|
-
],
|
|
106
|
-
[
|
|
107
|
-
0,
|
|
108
|
-
1,
|
|
109
|
-
1,
|
|
110
|
-
0,
|
|
111
|
-
0
|
|
112
|
-
],
|
|
113
|
-
[
|
|
114
|
-
0,
|
|
115
|
-
0,
|
|
116
|
-
1,
|
|
117
|
-
0,
|
|
118
|
-
0
|
|
119
|
-
],
|
|
120
|
-
[
|
|
121
|
-
0,
|
|
122
|
-
0,
|
|
123
|
-
1,
|
|
124
|
-
0,
|
|
125
|
-
0
|
|
126
|
-
],
|
|
127
|
-
[
|
|
128
|
-
0,
|
|
129
|
-
0,
|
|
130
|
-
1,
|
|
131
|
-
0,
|
|
132
|
-
0
|
|
133
|
-
],
|
|
134
|
-
[
|
|
135
|
-
0,
|
|
136
|
-
0,
|
|
137
|
-
1,
|
|
138
|
-
0,
|
|
139
|
-
0
|
|
140
|
-
],
|
|
141
|
-
[
|
|
142
|
-
0,
|
|
143
|
-
1,
|
|
144
|
-
1,
|
|
145
|
-
1,
|
|
146
|
-
0
|
|
147
|
-
]
|
|
148
|
-
],
|
|
149
|
-
2: [
|
|
150
|
-
[
|
|
151
|
-
0,
|
|
152
|
-
1,
|
|
153
|
-
1,
|
|
154
|
-
1,
|
|
155
|
-
0
|
|
156
|
-
],
|
|
157
|
-
[
|
|
158
|
-
1,
|
|
159
|
-
0,
|
|
160
|
-
0,
|
|
161
|
-
0,
|
|
162
|
-
1
|
|
163
|
-
],
|
|
164
|
-
[
|
|
165
|
-
0,
|
|
166
|
-
0,
|
|
167
|
-
0,
|
|
168
|
-
0,
|
|
169
|
-
1
|
|
170
|
-
],
|
|
171
|
-
[
|
|
172
|
-
0,
|
|
173
|
-
0,
|
|
174
|
-
1,
|
|
175
|
-
1,
|
|
176
|
-
0
|
|
177
|
-
],
|
|
178
|
-
[
|
|
179
|
-
0,
|
|
180
|
-
1,
|
|
181
|
-
0,
|
|
182
|
-
0,
|
|
183
|
-
0
|
|
184
|
-
],
|
|
185
|
-
[
|
|
186
|
-
1,
|
|
187
|
-
0,
|
|
188
|
-
0,
|
|
189
|
-
0,
|
|
190
|
-
0
|
|
191
|
-
],
|
|
192
|
-
[
|
|
193
|
-
1,
|
|
194
|
-
1,
|
|
195
|
-
1,
|
|
196
|
-
1,
|
|
197
|
-
1
|
|
198
|
-
]
|
|
199
|
-
],
|
|
200
|
-
3: [
|
|
201
|
-
[
|
|
202
|
-
0,
|
|
203
|
-
1,
|
|
204
|
-
1,
|
|
205
|
-
1,
|
|
206
|
-
0
|
|
207
|
-
],
|
|
208
|
-
[
|
|
209
|
-
1,
|
|
210
|
-
0,
|
|
211
|
-
0,
|
|
212
|
-
0,
|
|
213
|
-
1
|
|
214
|
-
],
|
|
215
|
-
[
|
|
216
|
-
0,
|
|
217
|
-
0,
|
|
218
|
-
0,
|
|
219
|
-
0,
|
|
220
|
-
1
|
|
221
|
-
],
|
|
222
|
-
[
|
|
223
|
-
0,
|
|
224
|
-
0,
|
|
225
|
-
1,
|
|
226
|
-
1,
|
|
227
|
-
0
|
|
228
|
-
],
|
|
229
|
-
[
|
|
230
|
-
0,
|
|
231
|
-
0,
|
|
232
|
-
0,
|
|
233
|
-
0,
|
|
234
|
-
1
|
|
235
|
-
],
|
|
236
|
-
[
|
|
237
|
-
1,
|
|
238
|
-
0,
|
|
239
|
-
0,
|
|
240
|
-
0,
|
|
241
|
-
1
|
|
242
|
-
],
|
|
243
|
-
[
|
|
244
|
-
0,
|
|
245
|
-
1,
|
|
246
|
-
1,
|
|
247
|
-
1,
|
|
248
|
-
0
|
|
249
|
-
]
|
|
250
|
-
],
|
|
251
|
-
4: [
|
|
252
|
-
[
|
|
253
|
-
0,
|
|
254
|
-
0,
|
|
255
|
-
0,
|
|
256
|
-
1,
|
|
257
|
-
0
|
|
258
|
-
],
|
|
259
|
-
[
|
|
260
|
-
0,
|
|
261
|
-
0,
|
|
262
|
-
1,
|
|
263
|
-
1,
|
|
264
|
-
0
|
|
265
|
-
],
|
|
266
|
-
[
|
|
267
|
-
0,
|
|
268
|
-
1,
|
|
269
|
-
0,
|
|
270
|
-
1,
|
|
271
|
-
0
|
|
272
|
-
],
|
|
273
|
-
[
|
|
274
|
-
1,
|
|
275
|
-
0,
|
|
276
|
-
0,
|
|
277
|
-
1,
|
|
278
|
-
0
|
|
279
|
-
],
|
|
280
|
-
[
|
|
281
|
-
1,
|
|
282
|
-
1,
|
|
283
|
-
1,
|
|
284
|
-
1,
|
|
285
|
-
1
|
|
286
|
-
],
|
|
287
|
-
[
|
|
288
|
-
0,
|
|
289
|
-
0,
|
|
290
|
-
0,
|
|
291
|
-
1,
|
|
292
|
-
0
|
|
293
|
-
],
|
|
294
|
-
[
|
|
295
|
-
0,
|
|
296
|
-
0,
|
|
297
|
-
0,
|
|
298
|
-
1,
|
|
299
|
-
0
|
|
300
|
-
]
|
|
301
|
-
],
|
|
302
|
-
5: [
|
|
303
|
-
[
|
|
304
|
-
1,
|
|
305
|
-
1,
|
|
306
|
-
1,
|
|
307
|
-
1,
|
|
308
|
-
1
|
|
309
|
-
],
|
|
310
|
-
[
|
|
311
|
-
1,
|
|
312
|
-
0,
|
|
313
|
-
0,
|
|
314
|
-
0,
|
|
315
|
-
0
|
|
316
|
-
],
|
|
317
|
-
[
|
|
318
|
-
1,
|
|
319
|
-
1,
|
|
320
|
-
1,
|
|
321
|
-
1,
|
|
322
|
-
0
|
|
323
|
-
],
|
|
324
|
-
[
|
|
325
|
-
0,
|
|
326
|
-
0,
|
|
327
|
-
0,
|
|
328
|
-
0,
|
|
329
|
-
1
|
|
330
|
-
],
|
|
331
|
-
[
|
|
332
|
-
0,
|
|
333
|
-
0,
|
|
334
|
-
0,
|
|
335
|
-
0,
|
|
336
|
-
1
|
|
337
|
-
],
|
|
338
|
-
[
|
|
339
|
-
1,
|
|
340
|
-
0,
|
|
341
|
-
0,
|
|
342
|
-
0,
|
|
343
|
-
1
|
|
344
|
-
],
|
|
345
|
-
[
|
|
346
|
-
0,
|
|
347
|
-
1,
|
|
348
|
-
1,
|
|
349
|
-
1,
|
|
350
|
-
0
|
|
351
|
-
]
|
|
352
|
-
],
|
|
353
|
-
6: [
|
|
354
|
-
[
|
|
355
|
-
0,
|
|
356
|
-
1,
|
|
357
|
-
1,
|
|
358
|
-
1,
|
|
359
|
-
0
|
|
360
|
-
],
|
|
361
|
-
[
|
|
362
|
-
1,
|
|
363
|
-
0,
|
|
364
|
-
0,
|
|
365
|
-
0,
|
|
366
|
-
0
|
|
367
|
-
],
|
|
368
|
-
[
|
|
369
|
-
1,
|
|
370
|
-
0,
|
|
371
|
-
0,
|
|
372
|
-
0,
|
|
373
|
-
0
|
|
374
|
-
],
|
|
375
|
-
[
|
|
376
|
-
1,
|
|
377
|
-
1,
|
|
378
|
-
1,
|
|
379
|
-
1,
|
|
380
|
-
0
|
|
381
|
-
],
|
|
382
|
-
[
|
|
383
|
-
1,
|
|
384
|
-
0,
|
|
385
|
-
0,
|
|
386
|
-
0,
|
|
387
|
-
1
|
|
388
|
-
],
|
|
389
|
-
[
|
|
390
|
-
1,
|
|
391
|
-
0,
|
|
392
|
-
0,
|
|
393
|
-
0,
|
|
394
|
-
1
|
|
395
|
-
],
|
|
396
|
-
[
|
|
397
|
-
0,
|
|
398
|
-
1,
|
|
399
|
-
1,
|
|
400
|
-
1,
|
|
401
|
-
0
|
|
402
|
-
]
|
|
403
|
-
],
|
|
404
|
-
7: [
|
|
405
|
-
[
|
|
406
|
-
1,
|
|
407
|
-
1,
|
|
408
|
-
1,
|
|
409
|
-
1,
|
|
410
|
-
1
|
|
411
|
-
],
|
|
412
|
-
[
|
|
413
|
-
0,
|
|
414
|
-
0,
|
|
415
|
-
0,
|
|
416
|
-
0,
|
|
417
|
-
1
|
|
418
|
-
],
|
|
419
|
-
[
|
|
420
|
-
0,
|
|
421
|
-
0,
|
|
422
|
-
0,
|
|
423
|
-
1,
|
|
424
|
-
0
|
|
425
|
-
],
|
|
426
|
-
[
|
|
427
|
-
0,
|
|
428
|
-
0,
|
|
429
|
-
1,
|
|
430
|
-
0,
|
|
431
|
-
0
|
|
432
|
-
],
|
|
433
|
-
[
|
|
434
|
-
0,
|
|
435
|
-
0,
|
|
436
|
-
1,
|
|
437
|
-
0,
|
|
438
|
-
0
|
|
439
|
-
],
|
|
440
|
-
[
|
|
441
|
-
0,
|
|
442
|
-
0,
|
|
443
|
-
1,
|
|
444
|
-
0,
|
|
445
|
-
0
|
|
446
|
-
],
|
|
447
|
-
[
|
|
448
|
-
0,
|
|
449
|
-
0,
|
|
450
|
-
1,
|
|
451
|
-
0,
|
|
452
|
-
0
|
|
453
|
-
]
|
|
454
|
-
],
|
|
455
|
-
8: [
|
|
456
|
-
[
|
|
457
|
-
0,
|
|
458
|
-
1,
|
|
459
|
-
1,
|
|
460
|
-
1,
|
|
461
|
-
0
|
|
462
|
-
],
|
|
463
|
-
[
|
|
464
|
-
1,
|
|
465
|
-
0,
|
|
466
|
-
0,
|
|
467
|
-
0,
|
|
468
|
-
1
|
|
469
|
-
],
|
|
470
|
-
[
|
|
471
|
-
1,
|
|
472
|
-
0,
|
|
473
|
-
0,
|
|
474
|
-
0,
|
|
475
|
-
1
|
|
476
|
-
],
|
|
477
|
-
[
|
|
478
|
-
0,
|
|
479
|
-
1,
|
|
480
|
-
1,
|
|
481
|
-
1,
|
|
482
|
-
0
|
|
483
|
-
],
|
|
484
|
-
[
|
|
485
|
-
1,
|
|
486
|
-
0,
|
|
487
|
-
0,
|
|
488
|
-
0,
|
|
489
|
-
1
|
|
490
|
-
],
|
|
491
|
-
[
|
|
492
|
-
1,
|
|
493
|
-
0,
|
|
494
|
-
0,
|
|
495
|
-
0,
|
|
496
|
-
1
|
|
497
|
-
],
|
|
498
|
-
[
|
|
499
|
-
0,
|
|
500
|
-
1,
|
|
501
|
-
1,
|
|
502
|
-
1,
|
|
503
|
-
0
|
|
504
|
-
]
|
|
505
|
-
],
|
|
506
|
-
9: [
|
|
507
|
-
[
|
|
508
|
-
0,
|
|
509
|
-
1,
|
|
510
|
-
1,
|
|
511
|
-
1,
|
|
512
|
-
0
|
|
513
|
-
],
|
|
514
|
-
[
|
|
515
|
-
1,
|
|
516
|
-
0,
|
|
517
|
-
0,
|
|
518
|
-
0,
|
|
519
|
-
1
|
|
520
|
-
],
|
|
521
|
-
[
|
|
522
|
-
1,
|
|
523
|
-
0,
|
|
524
|
-
0,
|
|
525
|
-
0,
|
|
526
|
-
1
|
|
527
|
-
],
|
|
528
|
-
[
|
|
529
|
-
0,
|
|
530
|
-
1,
|
|
531
|
-
1,
|
|
532
|
-
1,
|
|
533
|
-
1
|
|
534
|
-
],
|
|
535
|
-
[
|
|
536
|
-
0,
|
|
537
|
-
0,
|
|
538
|
-
0,
|
|
539
|
-
0,
|
|
540
|
-
1
|
|
541
|
-
],
|
|
542
|
-
[
|
|
543
|
-
0,
|
|
544
|
-
0,
|
|
545
|
-
0,
|
|
546
|
-
0,
|
|
547
|
-
1
|
|
548
|
-
],
|
|
549
|
-
[
|
|
550
|
-
0,
|
|
551
|
-
1,
|
|
552
|
-
1,
|
|
553
|
-
1,
|
|
554
|
-
0
|
|
555
|
-
]
|
|
556
|
-
]
|
|
557
|
-
};
|
|
558
|
-
const FONT_WIDTH = 5;
|
|
559
|
-
const FONT_HEIGHT = 7;
|
|
560
|
-
const FONT_SCALE = 2;
|
|
561
|
-
function drawDigit(pixels, width, height, digit, startX, startY, color) {
|
|
562
|
-
const bitmap = DIGIT_FONT[digit];
|
|
563
|
-
if (!bitmap) return;
|
|
564
|
-
for(let row = 0; row < FONT_HEIGHT; row++)for(let col = 0; col < FONT_WIDTH; col++)if (1 === bitmap[row][col]) for(let sy = 0; sy < FONT_SCALE; sy++)for(let sx = 0; sx < FONT_SCALE; sx++){
|
|
565
|
-
const x = startX + col * FONT_SCALE + sx;
|
|
566
|
-
const y = startY + row * FONT_SCALE + sy;
|
|
567
|
-
if (x >= 0 && x < width && y >= 0 && y < height) {
|
|
568
|
-
const idx = (y * width + x) * 4;
|
|
569
|
-
pixels[idx + 0] = color.r;
|
|
570
|
-
pixels[idx + 1] = color.g;
|
|
571
|
-
pixels[idx + 2] = color.b;
|
|
572
|
-
pixels[idx + 3] = color.a;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
function drawNumber(pixels, width, height, num, startX, startY, color) {
|
|
577
|
-
const str = num.toString();
|
|
578
|
-
let x = startX;
|
|
579
|
-
for (const digit of str){
|
|
580
|
-
drawDigit(pixels, width, height, digit, x, startY, color);
|
|
581
|
-
x += FONT_WIDTH * FONT_SCALE + 1;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
function getNumberWidth(num) {
|
|
585
|
-
return num.toString().length * (FONT_WIDTH * FONT_SCALE + 1) - 1;
|
|
586
|
-
}
|
|
587
|
-
function drawRect(pixels, width, height, rect, color, thickness) {
|
|
588
|
-
const x = Math.floor(rect.x);
|
|
589
|
-
const y = Math.floor(rect.y);
|
|
590
|
-
const w = Math.floor(rect.w);
|
|
591
|
-
const h = Math.floor(rect.h);
|
|
592
|
-
for(let py = y; py < y + h && py < height; py++)for(let px = x; px < x + w && px < width; px++){
|
|
593
|
-
if (px < 0 || py < 0) continue;
|
|
594
|
-
const isLeftBorder = px >= x && px < x + thickness;
|
|
595
|
-
const isRightBorder = px <= x + w - 1 && px > x + w - thickness - 1;
|
|
596
|
-
const isTopBorder = py >= y && py < y + thickness;
|
|
597
|
-
const isBottomBorder = py <= y + h - 1 && py > y + h - thickness - 1;
|
|
598
|
-
if (isLeftBorder || isRightBorder || isTopBorder || isBottomBorder) {
|
|
599
|
-
const idx = (py * width + px) * 4;
|
|
600
|
-
pixels[idx + 0] = color.r;
|
|
601
|
-
pixels[idx + 1] = color.g;
|
|
602
|
-
pixels[idx + 2] = color.b;
|
|
603
|
-
pixels[idx + 3] = color.a;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
function fillRect(pixels, width, height, rect, color) {
|
|
608
|
-
const x = Math.floor(rect.x);
|
|
609
|
-
const y = Math.floor(rect.y);
|
|
610
|
-
const w = Math.floor(rect.w);
|
|
611
|
-
const h = Math.floor(rect.h);
|
|
612
|
-
for(let py = y; py < y + h && py < height; py++)for(let px = x; px < x + w && px < width; px++){
|
|
613
|
-
if (px < 0 || py < 0) continue;
|
|
614
|
-
const idx = (py * width + px) * 4;
|
|
615
|
-
pixels[idx + 0] = color.r;
|
|
616
|
-
pixels[idx + 1] = color.g;
|
|
617
|
-
pixels[idx + 2] = color.b;
|
|
618
|
-
pixels[idx + 3] = color.a;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
function blendPixels(basePixels, overlayPixels, width, height) {
|
|
622
|
-
const result = new Uint8Array(basePixels.length);
|
|
623
|
-
for(let i = 0; i < basePixels.length; i += 4){
|
|
624
|
-
const overlayAlpha = overlayPixels[i + 3] / 255;
|
|
625
|
-
const baseAlpha = basePixels[i + 3] / 255;
|
|
626
|
-
if (0 === overlayAlpha) {
|
|
627
|
-
result[i + 0] = basePixels[i + 0];
|
|
628
|
-
result[i + 1] = basePixels[i + 1];
|
|
629
|
-
result[i + 2] = basePixels[i + 2];
|
|
630
|
-
result[i + 3] = basePixels[i + 3];
|
|
631
|
-
} else {
|
|
632
|
-
const outAlpha = overlayAlpha + baseAlpha * (1 - overlayAlpha);
|
|
633
|
-
if (0 === outAlpha) {
|
|
634
|
-
result[i + 0] = overlayPixels[i + 0];
|
|
635
|
-
result[i + 1] = overlayPixels[i + 1];
|
|
636
|
-
result[i + 2] = overlayPixels[i + 2];
|
|
637
|
-
result[i + 3] = overlayPixels[i + 3];
|
|
638
|
-
} else {
|
|
639
|
-
result[i + 0] = Math.round((overlayPixels[i + 0] * overlayAlpha + basePixels[i + 0] * baseAlpha * (1 - overlayAlpha)) / outAlpha);
|
|
640
|
-
result[i + 1] = Math.round((overlayPixels[i + 1] * overlayAlpha + basePixels[i + 1] * baseAlpha * (1 - overlayAlpha)) / outAlpha);
|
|
641
|
-
result[i + 2] = Math.round((overlayPixels[i + 2] * overlayAlpha + basePixels[i + 2] * baseAlpha * (1 - overlayAlpha)) / outAlpha);
|
|
642
|
-
result[i + 3] = Math.round(255 * outAlpha);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
return result;
|
|
647
|
-
}
|
|
648
|
-
const createSvgOverlay = async (elements, imageWidth, imageHeight, boxPadding = 5, borderThickness = 2, prompt)=>{
|
|
649
|
-
const overlayPixels = new Uint8Array(imageWidth * imageHeight * 4);
|
|
650
|
-
const colors = [
|
|
651
|
-
{
|
|
652
|
-
rect: {
|
|
653
|
-
r: 0xc6,
|
|
654
|
-
g: 0x23,
|
|
655
|
-
b: 0x00,
|
|
656
|
-
a: 0xff
|
|
657
|
-
},
|
|
658
|
-
text: {
|
|
659
|
-
r: 0xff,
|
|
660
|
-
g: 0xff,
|
|
661
|
-
b: 0xff,
|
|
662
|
-
a: 0xff
|
|
663
|
-
}
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
rect: {
|
|
667
|
-
r: 0x00,
|
|
668
|
-
g: 0x00,
|
|
669
|
-
b: 0xff,
|
|
670
|
-
a: 0xff
|
|
671
|
-
},
|
|
672
|
-
text: {
|
|
673
|
-
r: 0xff,
|
|
674
|
-
g: 0xff,
|
|
675
|
-
b: 0xff,
|
|
676
|
-
a: 0xff
|
|
677
|
-
}
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
rect: {
|
|
681
|
-
r: 0x8b,
|
|
682
|
-
g: 0x45,
|
|
683
|
-
b: 0x13,
|
|
684
|
-
a: 0xff
|
|
685
|
-
},
|
|
686
|
-
text: {
|
|
687
|
-
r: 0xff,
|
|
688
|
-
g: 0xff,
|
|
689
|
-
b: 0xff,
|
|
690
|
-
a: 0xff
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
rect: {
|
|
695
|
-
r: 0x3e,
|
|
696
|
-
g: 0x7b,
|
|
697
|
-
b: 0x27,
|
|
698
|
-
a: 0xff
|
|
699
|
-
},
|
|
700
|
-
text: {
|
|
701
|
-
r: 0xff,
|
|
702
|
-
g: 0xff,
|
|
703
|
-
b: 0xff,
|
|
704
|
-
a: 0xff
|
|
705
|
-
}
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
rect: {
|
|
709
|
-
r: 0x50,
|
|
710
|
-
g: 0x00,
|
|
711
|
-
b: 0x73,
|
|
712
|
-
a: 0xff
|
|
713
|
-
},
|
|
714
|
-
text: {
|
|
715
|
-
r: 0xff,
|
|
716
|
-
g: 0xff,
|
|
717
|
-
b: 0xff,
|
|
718
|
-
a: 0xff
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
];
|
|
722
|
-
if (prompt) {
|
|
723
|
-
const promptMargin = 20;
|
|
724
|
-
const promptHeight = 30;
|
|
725
|
-
const promptY = imageHeight - promptHeight - promptMargin;
|
|
726
|
-
fillRect(overlayPixels, imageWidth, imageHeight, {
|
|
727
|
-
x: 0,
|
|
728
|
-
y: promptY,
|
|
729
|
-
w: imageWidth,
|
|
730
|
-
h: promptHeight
|
|
731
|
-
}, {
|
|
732
|
-
r: 0x00,
|
|
733
|
-
g: 0x00,
|
|
734
|
-
b: 0x00,
|
|
735
|
-
a: 0xcc
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
for(let index = 0; index < elements.length; index++){
|
|
739
|
-
const element = elements[index];
|
|
740
|
-
const color = colors[index % colors.length];
|
|
741
|
-
const paddedLeft = Math.max(0, element.rect.left - boxPadding);
|
|
742
|
-
const paddedTop = Math.max(0, element.rect.top - boxPadding);
|
|
743
|
-
const paddedWidth = Math.min(imageWidth - paddedLeft, element.rect.width + 2 * boxPadding);
|
|
744
|
-
const paddedHeight = Math.min(imageHeight - paddedTop, element.rect.height + 2 * boxPadding);
|
|
745
|
-
const paddedRect = {
|
|
746
|
-
x: paddedLeft,
|
|
747
|
-
y: paddedTop,
|
|
748
|
-
w: paddedWidth,
|
|
749
|
-
h: paddedHeight
|
|
750
|
-
};
|
|
751
|
-
drawRect(overlayPixels, imageWidth, imageHeight, paddedRect, color.rect, borderThickness);
|
|
752
|
-
const indexId = element.indexId;
|
|
753
|
-
if ('number' != typeof indexId) continue;
|
|
754
|
-
const textWidth = getNumberWidth(indexId);
|
|
755
|
-
const textHeight = FONT_HEIGHT * FONT_SCALE;
|
|
756
|
-
const rectWidth = textWidth + 5;
|
|
757
|
-
const rectHeight = textHeight + 4;
|
|
758
|
-
let rectX = paddedLeft - rectWidth;
|
|
759
|
-
let rectY = paddedTop + Math.floor(paddedHeight / 2) - Math.floor(textHeight / 2) - 2;
|
|
760
|
-
const checkOverlap = (x, y)=>elements.slice(0, index).some((otherElement)=>x < otherElement.rect.left + otherElement.rect.width && x + rectWidth > otherElement.rect.left && y < otherElement.rect.top + otherElement.rect.height && y + rectHeight > otherElement.rect.top);
|
|
761
|
-
const isWithinBounds = (x, y)=>x >= 0 && x + rectWidth <= imageWidth && y >= 0 && y + rectHeight <= imageHeight;
|
|
762
|
-
if (checkOverlap(rectX, rectY) || !isWithinBounds(rectX, rectY)) if (!checkOverlap(paddedLeft, paddedTop - rectHeight - 2) && isWithinBounds(paddedLeft, paddedTop - rectHeight - 2)) {
|
|
763
|
-
rectX = paddedLeft;
|
|
764
|
-
rectY = paddedTop - rectHeight - 2;
|
|
765
|
-
} else if (!checkOverlap(paddedLeft, paddedTop + paddedHeight + 2) && isWithinBounds(paddedLeft, paddedTop + paddedHeight + 2)) {
|
|
766
|
-
rectX = paddedLeft;
|
|
767
|
-
rectY = paddedTop + paddedHeight + 2;
|
|
768
|
-
} else if (!checkOverlap(paddedLeft + paddedWidth + 2, paddedTop) && isWithinBounds(paddedLeft + paddedWidth + 2, paddedTop)) {
|
|
769
|
-
rectX = paddedLeft + paddedWidth + 2;
|
|
770
|
-
rectY = paddedTop;
|
|
771
|
-
} else {
|
|
772
|
-
rectX = paddedLeft;
|
|
773
|
-
rectY = paddedTop + 2;
|
|
774
|
-
}
|
|
775
|
-
fillRect(overlayPixels, imageWidth, imageHeight, {
|
|
776
|
-
x: rectX,
|
|
777
|
-
y: rectY,
|
|
778
|
-
w: rectWidth,
|
|
779
|
-
h: rectHeight
|
|
780
|
-
}, color.rect);
|
|
781
|
-
const textX = rectX + Math.floor((rectWidth - textWidth) / 2);
|
|
782
|
-
const textY = rectY + Math.floor((rectHeight - textHeight) / 2);
|
|
783
|
-
drawNumber(overlayPixels, imageWidth, imageHeight, indexId, textX, textY, color.text);
|
|
784
|
-
}
|
|
785
|
-
return overlayPixels;
|
|
786
|
-
};
|
|
787
|
-
const compositeElementInfoImg = async (options)=>{
|
|
788
|
-
external_node_assert_default()(options.inputImgBase64, 'inputImgBase64 is required');
|
|
789
|
-
const { PhotonImage, SamplingFilter, resize } = await external_get_photon_js_default()();
|
|
790
|
-
let width = 0;
|
|
791
|
-
let height = 0;
|
|
792
|
-
if (options.size) {
|
|
793
|
-
width = options.size.width;
|
|
794
|
-
height = options.size.height;
|
|
795
|
-
}
|
|
796
|
-
let photonImage = await (0, external_transform_js_namespaceObject.photonFromBase64)(options.inputImgBase64);
|
|
797
|
-
if (width && height) {
|
|
798
|
-
const imageWidth = photonImage.get_width();
|
|
799
|
-
const imageHeight = photonImage.get_height();
|
|
800
|
-
if (imageWidth !== width || imageHeight !== height) {
|
|
801
|
-
const resized = resize(photonImage, width, height, SamplingFilter.Nearest);
|
|
802
|
-
photonImage.free();
|
|
803
|
-
photonImage = resized;
|
|
804
|
-
}
|
|
805
|
-
} else {
|
|
806
|
-
width = photonImage.get_width();
|
|
807
|
-
height = photonImage.get_height();
|
|
808
|
-
}
|
|
809
|
-
if (!width || !height) {
|
|
810
|
-
photonImage.free();
|
|
811
|
-
throw Error('Image processing failed because width or height is undefined');
|
|
812
|
-
}
|
|
813
|
-
const { elementsPositionInfo, prompt } = options;
|
|
814
|
-
try {
|
|
815
|
-
const basePixels = photonImage.get_raw_pixels();
|
|
816
|
-
const overlayPixels = await createSvgOverlay(elementsPositionInfo, width, height, options.annotationPadding, options.borderThickness, prompt);
|
|
817
|
-
const blendedPixels = blendPixels(basePixels, overlayPixels, width, height);
|
|
818
|
-
const resultImage = new PhotonImage(blendedPixels, width, height);
|
|
819
|
-
const base64 = await (0, external_transform_js_namespaceObject.photonToBase64)(resultImage, 90);
|
|
820
|
-
resultImage.free();
|
|
821
|
-
return base64;
|
|
822
|
-
} finally{
|
|
823
|
-
photonImage.free();
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
const processImageElementInfo = async (options)=>{
|
|
827
|
-
const base64Image = options.inputImgBase64.split(';base64,').pop();
|
|
828
|
-
external_node_assert_default()(base64Image, 'base64Image is undefined');
|
|
829
|
-
const [compositeElementInfoImgBase64, compositeElementInfoImgWithoutTextBase64] = await Promise.all([
|
|
830
|
-
compositeElementInfoImg({
|
|
831
|
-
inputImgBase64: options.inputImgBase64,
|
|
832
|
-
elementsPositionInfo: options.elementsPositionInfo
|
|
833
|
-
}),
|
|
834
|
-
compositeElementInfoImg({
|
|
835
|
-
inputImgBase64: options.inputImgBase64,
|
|
836
|
-
elementsPositionInfo: options.elementsPositionInfoWithoutText
|
|
837
|
-
})
|
|
838
|
-
]);
|
|
839
|
-
return {
|
|
840
|
-
compositeElementInfoImgBase64,
|
|
841
|
-
compositeElementInfoImgWithoutTextBase64
|
|
842
|
-
};
|
|
843
|
-
};
|
|
844
|
-
async function annotateRects(imgBase64, rects, prompt) {
|
|
845
|
-
const markedImage = await compositeElementInfoImg({
|
|
846
|
-
inputImgBase64: imgBase64,
|
|
847
|
-
elementsPositionInfo: rects.map((rect, index)=>({
|
|
848
|
-
id: `rect-${index}`,
|
|
849
|
-
rect,
|
|
850
|
-
indexId: index + 1,
|
|
851
|
-
attributes: {
|
|
852
|
-
nodeType: index_js_namespaceObject.NodeType.CONTAINER
|
|
853
|
-
},
|
|
854
|
-
content: '',
|
|
855
|
-
center: [
|
|
856
|
-
rect.left + rect.width / 2,
|
|
857
|
-
rect.top + rect.height / 2
|
|
858
|
-
]
|
|
859
|
-
})),
|
|
860
|
-
annotationPadding: 0,
|
|
861
|
-
prompt
|
|
862
|
-
});
|
|
863
|
-
return markedImage;
|
|
864
|
-
}
|
|
865
|
-
exports.annotateRects = __webpack_exports__.annotateRects;
|
|
866
|
-
exports.compositeElementInfoImg = __webpack_exports__.compositeElementInfoImg;
|
|
867
|
-
exports.processImageElementInfo = __webpack_exports__.processImageElementInfo;
|
|
868
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
869
|
-
"annotateRects",
|
|
870
|
-
"compositeElementInfoImg",
|
|
871
|
-
"processImageElementInfo"
|
|
872
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
873
|
-
Object.defineProperty(exports, '__esModule', {
|
|
874
|
-
value: true
|
|
875
|
-
});
|