secure-redact 1.0.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/LICENSE +21 -0
- package/README.md +178 -0
- package/dist/assets/advanced.worker-DSVrF0gl.js +890 -0
- package/dist/assets/advanced.worker-DSVrF0gl.js.map +1 -0
- package/dist/assets/index-C62fEJ4q.js +888 -0
- package/dist/assets/index-C62fEJ4q.js.map +1 -0
- package/dist/assets/nlp.worker-u7Lr_A3c.js +521 -0
- package/dist/assets/nlp.worker-u7Lr_A3c.js.map +1 -0
- package/dist/assets/ocr.worker-D5s6dY7M.js +139 -0
- package/dist/assets/ocr.worker-D5s6dY7M.js.map +1 -0
- package/dist/lib.d.ts +158 -0
- package/dist/secure-redact.es.js +30138 -0
- package/dist/secure-redact.es.js.map +1 -0
- package/dist/secure-redact.umd.js +108 -0
- package/dist/secure-redact.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
function He(i, o) {
|
|
2
|
+
return o.forEach(function(n) {
|
|
3
|
+
n && typeof n != "string" && !Array.isArray(n) && Object.keys(n).forEach(function(c) {
|
|
4
|
+
if (c !== "default" && !(c in i)) {
|
|
5
|
+
var s = Object.getOwnPropertyDescriptor(n, c);
|
|
6
|
+
Object.defineProperty(i, c, s.get ? s : {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return n[c];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}), Object.freeze(i);
|
|
15
|
+
}
|
|
16
|
+
function Je(i) {
|
|
17
|
+
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
18
|
+
}
|
|
19
|
+
var x = { exports: {} }, Se;
|
|
20
|
+
function Ve() {
|
|
21
|
+
return Se || (Se = 1, (function(i) {
|
|
22
|
+
var o = (function(n) {
|
|
23
|
+
var c = Object.prototype, s = c.hasOwnProperty, d = Object.defineProperty || function(r, e, t) {
|
|
24
|
+
r[e] = t.value;
|
|
25
|
+
}, p, k = typeof Symbol == "function" ? Symbol : {}, G = k.iterator || "@@iterator", j = k.asyncIterator || "@@asyncIterator", M = k.toStringTag || "@@toStringTag";
|
|
26
|
+
function O(r, e, t) {
|
|
27
|
+
return Object.defineProperty(r, e, {
|
|
28
|
+
value: t,
|
|
29
|
+
enumerable: !0,
|
|
30
|
+
configurable: !0,
|
|
31
|
+
writable: !0
|
|
32
|
+
}), r[e];
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
O({}, "");
|
|
36
|
+
} catch {
|
|
37
|
+
O = function(e, t, u) {
|
|
38
|
+
return e[t] = u;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function C(r, e, t, u) {
|
|
42
|
+
var a = e && e.prototype instanceof y ? e : y, h = Object.create(a.prototype), L = new H(u || []);
|
|
43
|
+
return d(h, "_invoke", { value: Q(r, t, L) }), h;
|
|
44
|
+
}
|
|
45
|
+
n.wrap = C;
|
|
46
|
+
function D(r, e, t) {
|
|
47
|
+
try {
|
|
48
|
+
return { type: "normal", arg: r.call(e, t) };
|
|
49
|
+
} catch (u) {
|
|
50
|
+
return { type: "throw", arg: u };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
var z = "suspendedStart", g = "suspendedYield", m = "executing", U = "completed", w = {};
|
|
54
|
+
function y() {
|
|
55
|
+
}
|
|
56
|
+
function R() {
|
|
57
|
+
}
|
|
58
|
+
function _() {
|
|
59
|
+
}
|
|
60
|
+
var B = {};
|
|
61
|
+
O(B, G, function() {
|
|
62
|
+
return this;
|
|
63
|
+
});
|
|
64
|
+
var F = Object.getPrototypeOf, W = F && F(F(J([])));
|
|
65
|
+
W && W !== c && s.call(W, G) && (B = W);
|
|
66
|
+
var N = _.prototype = y.prototype = Object.create(B);
|
|
67
|
+
R.prototype = _, d(N, "constructor", { value: _, configurable: !0 }), d(
|
|
68
|
+
_,
|
|
69
|
+
"constructor",
|
|
70
|
+
{ value: R, configurable: !0 }
|
|
71
|
+
), R.displayName = O(
|
|
72
|
+
_,
|
|
73
|
+
M,
|
|
74
|
+
"GeneratorFunction"
|
|
75
|
+
);
|
|
76
|
+
function Y(r) {
|
|
77
|
+
["next", "throw", "return"].forEach(function(e) {
|
|
78
|
+
O(r, e, function(t) {
|
|
79
|
+
return this._invoke(e, t);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
n.isGeneratorFunction = function(r) {
|
|
84
|
+
var e = typeof r == "function" && r.constructor;
|
|
85
|
+
return e ? e === R || // For the native GeneratorFunction constructor, the best we can
|
|
86
|
+
// do is to check its .name property.
|
|
87
|
+
(e.displayName || e.name) === "GeneratorFunction" : !1;
|
|
88
|
+
}, n.mark = function(r) {
|
|
89
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(r, _) : (r.__proto__ = _, O(r, M, "GeneratorFunction")), r.prototype = Object.create(N), r;
|
|
90
|
+
}, n.awrap = function(r) {
|
|
91
|
+
return { __await: r };
|
|
92
|
+
};
|
|
93
|
+
function $(r, e) {
|
|
94
|
+
function t(h, L, S, b) {
|
|
95
|
+
var E = D(r[h], r, L);
|
|
96
|
+
if (E.type === "throw")
|
|
97
|
+
b(E.arg);
|
|
98
|
+
else {
|
|
99
|
+
var l = E.arg, f = l.value;
|
|
100
|
+
return f && typeof f == "object" && s.call(f, "__await") ? e.resolve(f.__await).then(function(v) {
|
|
101
|
+
t("next", v, S, b);
|
|
102
|
+
}, function(v) {
|
|
103
|
+
t("throw", v, S, b);
|
|
104
|
+
}) : e.resolve(f).then(function(v) {
|
|
105
|
+
l.value = v, S(l);
|
|
106
|
+
}, function(v) {
|
|
107
|
+
return t("throw", v, S, b);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
var u;
|
|
112
|
+
function a(h, L) {
|
|
113
|
+
function S() {
|
|
114
|
+
return new e(function(b, E) {
|
|
115
|
+
t(h, L, b, E);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return u = // If enqueue has been called before, then we want to wait until
|
|
119
|
+
// all previous Promises have been resolved before calling invoke,
|
|
120
|
+
// so that results are always delivered in the correct order. If
|
|
121
|
+
// enqueue has not been called before, then it is important to
|
|
122
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
123
|
+
// so that the async generator function has the opportunity to do
|
|
124
|
+
// any necessary setup in a predictable way. This predictability
|
|
125
|
+
// is why the Promise constructor synchronously invokes its
|
|
126
|
+
// executor callback, and why async functions synchronously
|
|
127
|
+
// execute code before the first await. Since we implement simple
|
|
128
|
+
// async functions in terms of async generators, it is especially
|
|
129
|
+
// important to get this right, even though it requires care.
|
|
130
|
+
u ? u.then(
|
|
131
|
+
S,
|
|
132
|
+
// Avoid propagating failures to Promises returned by later
|
|
133
|
+
// invocations of the iterator.
|
|
134
|
+
S
|
|
135
|
+
) : S();
|
|
136
|
+
}
|
|
137
|
+
d(this, "_invoke", { value: a });
|
|
138
|
+
}
|
|
139
|
+
Y($.prototype), O($.prototype, j, function() {
|
|
140
|
+
return this;
|
|
141
|
+
}), n.AsyncIterator = $, n.async = function(r, e, t, u, a) {
|
|
142
|
+
a === void 0 && (a = Promise);
|
|
143
|
+
var h = new $(
|
|
144
|
+
C(r, e, t, u),
|
|
145
|
+
a
|
|
146
|
+
);
|
|
147
|
+
return n.isGeneratorFunction(e) ? h : h.next().then(function(L) {
|
|
148
|
+
return L.done ? L.value : h.next();
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
function Q(r, e, t) {
|
|
152
|
+
var u = z;
|
|
153
|
+
return function(h, L) {
|
|
154
|
+
if (u === m)
|
|
155
|
+
throw new Error("Generator is already running");
|
|
156
|
+
if (u === U) {
|
|
157
|
+
if (h === "throw")
|
|
158
|
+
throw L;
|
|
159
|
+
return Z();
|
|
160
|
+
}
|
|
161
|
+
for (t.method = h, t.arg = L; ; ) {
|
|
162
|
+
var S = t.delegate;
|
|
163
|
+
if (S) {
|
|
164
|
+
var b = P(S, t);
|
|
165
|
+
if (b) {
|
|
166
|
+
if (b === w) continue;
|
|
167
|
+
return b;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (t.method === "next")
|
|
171
|
+
t.sent = t._sent = t.arg;
|
|
172
|
+
else if (t.method === "throw") {
|
|
173
|
+
if (u === z)
|
|
174
|
+
throw u = U, t.arg;
|
|
175
|
+
t.dispatchException(t.arg);
|
|
176
|
+
} else t.method === "return" && t.abrupt("return", t.arg);
|
|
177
|
+
u = m;
|
|
178
|
+
var E = D(r, e, t);
|
|
179
|
+
if (E.type === "normal") {
|
|
180
|
+
if (u = t.done ? U : g, E.arg === w)
|
|
181
|
+
continue;
|
|
182
|
+
return {
|
|
183
|
+
value: E.arg,
|
|
184
|
+
done: t.done
|
|
185
|
+
};
|
|
186
|
+
} else E.type === "throw" && (u = U, t.method = "throw", t.arg = E.arg);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function P(r, e) {
|
|
191
|
+
var t = e.method, u = r.iterator[t];
|
|
192
|
+
if (u === p)
|
|
193
|
+
return e.delegate = null, t === "throw" && r.iterator.return && (e.method = "return", e.arg = p, P(r, e), e.method === "throw") || t !== "return" && (e.method = "throw", e.arg = new TypeError(
|
|
194
|
+
"The iterator does not provide a '" + t + "' method"
|
|
195
|
+
)), w;
|
|
196
|
+
var a = D(u, r.iterator, e.arg);
|
|
197
|
+
if (a.type === "throw")
|
|
198
|
+
return e.method = "throw", e.arg = a.arg, e.delegate = null, w;
|
|
199
|
+
var h = a.arg;
|
|
200
|
+
if (!h)
|
|
201
|
+
return e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, w;
|
|
202
|
+
if (h.done)
|
|
203
|
+
e[r.resultName] = h.value, e.next = r.nextLoc, e.method !== "return" && (e.method = "next", e.arg = p);
|
|
204
|
+
else
|
|
205
|
+
return h;
|
|
206
|
+
return e.delegate = null, w;
|
|
207
|
+
}
|
|
208
|
+
Y(N), O(N, M, "Generator"), O(N, G, function() {
|
|
209
|
+
return this;
|
|
210
|
+
}), O(N, "toString", function() {
|
|
211
|
+
return "[object Generator]";
|
|
212
|
+
});
|
|
213
|
+
function T(r) {
|
|
214
|
+
var e = { tryLoc: r[0] };
|
|
215
|
+
1 in r && (e.catchLoc = r[1]), 2 in r && (e.finallyLoc = r[2], e.afterLoc = r[3]), this.tryEntries.push(e);
|
|
216
|
+
}
|
|
217
|
+
function K(r) {
|
|
218
|
+
var e = r.completion || {};
|
|
219
|
+
e.type = "normal", delete e.arg, r.completion = e;
|
|
220
|
+
}
|
|
221
|
+
function H(r) {
|
|
222
|
+
this.tryEntries = [{ tryLoc: "root" }], r.forEach(T, this), this.reset(!0);
|
|
223
|
+
}
|
|
224
|
+
n.keys = function(r) {
|
|
225
|
+
var e = Object(r), t = [];
|
|
226
|
+
for (var u in e)
|
|
227
|
+
t.push(u);
|
|
228
|
+
return t.reverse(), function a() {
|
|
229
|
+
for (; t.length; ) {
|
|
230
|
+
var h = t.pop();
|
|
231
|
+
if (h in e)
|
|
232
|
+
return a.value = h, a.done = !1, a;
|
|
233
|
+
}
|
|
234
|
+
return a.done = !0, a;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
function J(r) {
|
|
238
|
+
if (r) {
|
|
239
|
+
var e = r[G];
|
|
240
|
+
if (e)
|
|
241
|
+
return e.call(r);
|
|
242
|
+
if (typeof r.next == "function")
|
|
243
|
+
return r;
|
|
244
|
+
if (!isNaN(r.length)) {
|
|
245
|
+
var t = -1, u = function a() {
|
|
246
|
+
for (; ++t < r.length; )
|
|
247
|
+
if (s.call(r, t))
|
|
248
|
+
return a.value = r[t], a.done = !1, a;
|
|
249
|
+
return a.value = p, a.done = !0, a;
|
|
250
|
+
};
|
|
251
|
+
return u.next = u;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return { next: Z };
|
|
255
|
+
}
|
|
256
|
+
n.values = J;
|
|
257
|
+
function Z() {
|
|
258
|
+
return { value: p, done: !0 };
|
|
259
|
+
}
|
|
260
|
+
return H.prototype = {
|
|
261
|
+
constructor: H,
|
|
262
|
+
reset: function(r) {
|
|
263
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = p, this.done = !1, this.delegate = null, this.method = "next", this.arg = p, this.tryEntries.forEach(K), !r)
|
|
264
|
+
for (var e in this)
|
|
265
|
+
e.charAt(0) === "t" && s.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = p);
|
|
266
|
+
},
|
|
267
|
+
stop: function() {
|
|
268
|
+
this.done = !0;
|
|
269
|
+
var r = this.tryEntries[0], e = r.completion;
|
|
270
|
+
if (e.type === "throw")
|
|
271
|
+
throw e.arg;
|
|
272
|
+
return this.rval;
|
|
273
|
+
},
|
|
274
|
+
dispatchException: function(r) {
|
|
275
|
+
if (this.done)
|
|
276
|
+
throw r;
|
|
277
|
+
var e = this;
|
|
278
|
+
function t(b, E) {
|
|
279
|
+
return h.type = "throw", h.arg = r, e.next = b, E && (e.method = "next", e.arg = p), !!E;
|
|
280
|
+
}
|
|
281
|
+
for (var u = this.tryEntries.length - 1; u >= 0; --u) {
|
|
282
|
+
var a = this.tryEntries[u], h = a.completion;
|
|
283
|
+
if (a.tryLoc === "root")
|
|
284
|
+
return t("end");
|
|
285
|
+
if (a.tryLoc <= this.prev) {
|
|
286
|
+
var L = s.call(a, "catchLoc"), S = s.call(a, "finallyLoc");
|
|
287
|
+
if (L && S) {
|
|
288
|
+
if (this.prev < a.catchLoc)
|
|
289
|
+
return t(a.catchLoc, !0);
|
|
290
|
+
if (this.prev < a.finallyLoc)
|
|
291
|
+
return t(a.finallyLoc);
|
|
292
|
+
} else if (L) {
|
|
293
|
+
if (this.prev < a.catchLoc)
|
|
294
|
+
return t(a.catchLoc, !0);
|
|
295
|
+
} else if (S) {
|
|
296
|
+
if (this.prev < a.finallyLoc)
|
|
297
|
+
return t(a.finallyLoc);
|
|
298
|
+
} else
|
|
299
|
+
throw new Error("try statement without catch or finally");
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
abrupt: function(r, e) {
|
|
304
|
+
for (var t = this.tryEntries.length - 1; t >= 0; --t) {
|
|
305
|
+
var u = this.tryEntries[t];
|
|
306
|
+
if (u.tryLoc <= this.prev && s.call(u, "finallyLoc") && this.prev < u.finallyLoc) {
|
|
307
|
+
var a = u;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
a && (r === "break" || r === "continue") && a.tryLoc <= e && e <= a.finallyLoc && (a = null);
|
|
312
|
+
var h = a ? a.completion : {};
|
|
313
|
+
return h.type = r, h.arg = e, a ? (this.method = "next", this.next = a.finallyLoc, w) : this.complete(h);
|
|
314
|
+
},
|
|
315
|
+
complete: function(r, e) {
|
|
316
|
+
if (r.type === "throw")
|
|
317
|
+
throw r.arg;
|
|
318
|
+
return r.type === "break" || r.type === "continue" ? this.next = r.arg : r.type === "return" ? (this.rval = this.arg = r.arg, this.method = "return", this.next = "end") : r.type === "normal" && e && (this.next = e), w;
|
|
319
|
+
},
|
|
320
|
+
finish: function(r) {
|
|
321
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
322
|
+
var t = this.tryEntries[e];
|
|
323
|
+
if (t.finallyLoc === r)
|
|
324
|
+
return this.complete(t.completion, t.afterLoc), K(t), w;
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
catch: function(r) {
|
|
328
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
329
|
+
var t = this.tryEntries[e];
|
|
330
|
+
if (t.tryLoc === r) {
|
|
331
|
+
var u = t.completion;
|
|
332
|
+
if (u.type === "throw") {
|
|
333
|
+
var a = u.arg;
|
|
334
|
+
K(t);
|
|
335
|
+
}
|
|
336
|
+
return a;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
throw new Error("illegal catch attempt");
|
|
340
|
+
},
|
|
341
|
+
delegateYield: function(r, e, t) {
|
|
342
|
+
return this.delegate = {
|
|
343
|
+
iterator: J(r),
|
|
344
|
+
resultName: e,
|
|
345
|
+
nextLoc: t
|
|
346
|
+
}, this.method === "next" && (this.arg = p), w;
|
|
347
|
+
}
|
|
348
|
+
}, n;
|
|
349
|
+
})(
|
|
350
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
351
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
352
|
+
// object. Either way, the resulting object will be used to initialize
|
|
353
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
354
|
+
i.exports
|
|
355
|
+
);
|
|
356
|
+
try {
|
|
357
|
+
regeneratorRuntime = o;
|
|
358
|
+
} catch {
|
|
359
|
+
typeof globalThis == "object" ? globalThis.regeneratorRuntime = o : Function("r", "regeneratorRuntime = r")(o);
|
|
360
|
+
}
|
|
361
|
+
})(x)), x.exports;
|
|
362
|
+
}
|
|
363
|
+
var ee, Ee;
|
|
364
|
+
function we() {
|
|
365
|
+
return Ee || (Ee = 1, ee = (i, o) => `${i}-${o}-${Math.random().toString(16).slice(3, 8)}`), ee;
|
|
366
|
+
}
|
|
367
|
+
var re, Oe;
|
|
368
|
+
function Fe() {
|
|
369
|
+
if (Oe) return re;
|
|
370
|
+
Oe = 1;
|
|
371
|
+
const i = we();
|
|
372
|
+
let o = 0;
|
|
373
|
+
return re = ({
|
|
374
|
+
id: n,
|
|
375
|
+
action: c,
|
|
376
|
+
payload: s = {}
|
|
377
|
+
}) => {
|
|
378
|
+
let d = n;
|
|
379
|
+
return typeof d > "u" && (d = i("Job", o), o += 1), {
|
|
380
|
+
id: d,
|
|
381
|
+
action: c,
|
|
382
|
+
payload: s
|
|
383
|
+
};
|
|
384
|
+
}, re;
|
|
385
|
+
}
|
|
386
|
+
var V = {}, Re;
|
|
387
|
+
function Le() {
|
|
388
|
+
if (Re) return V;
|
|
389
|
+
Re = 1;
|
|
390
|
+
let i = !1;
|
|
391
|
+
return V.logging = i, V.setLogging = (o) => {
|
|
392
|
+
i = o;
|
|
393
|
+
}, V.log = (...o) => i ? console.log.apply(this, o) : null, V;
|
|
394
|
+
}
|
|
395
|
+
var te, be;
|
|
396
|
+
function Ze() {
|
|
397
|
+
if (be) return te;
|
|
398
|
+
be = 1;
|
|
399
|
+
const i = Fe(), { log: o } = Le(), n = we();
|
|
400
|
+
let c = 0;
|
|
401
|
+
return te = () => {
|
|
402
|
+
const s = n("Scheduler", c), d = {}, p = {};
|
|
403
|
+
let k = [];
|
|
404
|
+
c += 1;
|
|
405
|
+
const G = () => k.length, j = () => Object.keys(d).length, M = () => {
|
|
406
|
+
if (k.length !== 0) {
|
|
407
|
+
const g = Object.keys(d);
|
|
408
|
+
for (let m = 0; m < g.length; m += 1)
|
|
409
|
+
if (typeof p[g[m]] > "u") {
|
|
410
|
+
k[0](d[g[m]]);
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}, O = (g, m) => new Promise((U, w) => {
|
|
415
|
+
const y = i({ action: g, payload: m });
|
|
416
|
+
k.push(async (R) => {
|
|
417
|
+
k.shift(), p[R.id] = y;
|
|
418
|
+
try {
|
|
419
|
+
U(await R[g].apply(this, [...m, y.id]));
|
|
420
|
+
} catch (_) {
|
|
421
|
+
w(_);
|
|
422
|
+
} finally {
|
|
423
|
+
delete p[R.id], M();
|
|
424
|
+
}
|
|
425
|
+
}), o(`[${s}]: Add ${y.id} to JobQueue`), o(`[${s}]: JobQueue length=${k.length}`), M();
|
|
426
|
+
});
|
|
427
|
+
return {
|
|
428
|
+
addWorker: (g) => (d[g.id] = g, o(`[${s}]: Add ${g.id}`), o(`[${s}]: Number of workers=${j()}`), M(), g.id),
|
|
429
|
+
addJob: async (g, ...m) => {
|
|
430
|
+
if (j() === 0)
|
|
431
|
+
throw Error(`[${s}]: You need to have at least one worker before adding jobs`);
|
|
432
|
+
return O(g, m);
|
|
433
|
+
},
|
|
434
|
+
terminate: async () => {
|
|
435
|
+
Object.keys(d).forEach(async (g) => {
|
|
436
|
+
await d[g].terminate();
|
|
437
|
+
}), k = [];
|
|
438
|
+
},
|
|
439
|
+
getQueueLen: G,
|
|
440
|
+
getNumWorkers: j
|
|
441
|
+
};
|
|
442
|
+
}, te;
|
|
443
|
+
}
|
|
444
|
+
function Qe(i) {
|
|
445
|
+
throw new Error('Could not dynamically require "' + i + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
446
|
+
}
|
|
447
|
+
var ne, ke;
|
|
448
|
+
function Xe() {
|
|
449
|
+
return ke || (ke = 1, ne = (i) => {
|
|
450
|
+
const o = {};
|
|
451
|
+
return typeof WorkerGlobalScope < "u" ? o.type = "webworker" : typeof document == "object" ? o.type = "browser" : typeof process == "object" && typeof Qe == "function" && (o.type = "node"), typeof i > "u" ? o : o[i];
|
|
452
|
+
}), ne;
|
|
453
|
+
}
|
|
454
|
+
var oe, _e;
|
|
455
|
+
function xe() {
|
|
456
|
+
if (_e) return oe;
|
|
457
|
+
_e = 1;
|
|
458
|
+
const o = Xe()("type") === "browser" ? (n) => new URL(n, window.location.href).href : (n) => n;
|
|
459
|
+
return oe = (n) => {
|
|
460
|
+
const c = { ...n };
|
|
461
|
+
return ["corePath", "workerPath", "langPath"].forEach((s) => {
|
|
462
|
+
n[s] && (c[s] = o(c[s]));
|
|
463
|
+
}), c;
|
|
464
|
+
}, oe;
|
|
465
|
+
}
|
|
466
|
+
var ae, Te;
|
|
467
|
+
function $e() {
|
|
468
|
+
return Te || (Te = 1, ae = {
|
|
469
|
+
TESSERACT_ONLY: 0,
|
|
470
|
+
LSTM_ONLY: 1,
|
|
471
|
+
TESSERACT_LSTM_COMBINED: 2,
|
|
472
|
+
DEFAULT: 3
|
|
473
|
+
}), ae;
|
|
474
|
+
}
|
|
475
|
+
const er = "7.0.0";
|
|
476
|
+
var rr = {
|
|
477
|
+
version: er
|
|
478
|
+
}, ie, Ae;
|
|
479
|
+
function tr() {
|
|
480
|
+
return Ae || (Ae = 1, ie = {
|
|
481
|
+
/*
|
|
482
|
+
* Use BlobURL for worker script by default
|
|
483
|
+
* TODO: remove this option
|
|
484
|
+
*
|
|
485
|
+
*/
|
|
486
|
+
workerBlobURL: !0,
|
|
487
|
+
logger: () => {
|
|
488
|
+
}
|
|
489
|
+
}), ie;
|
|
490
|
+
}
|
|
491
|
+
var se, qe;
|
|
492
|
+
function nr() {
|
|
493
|
+
if (qe) return se;
|
|
494
|
+
qe = 1;
|
|
495
|
+
const i = rr.version;
|
|
496
|
+
return se = {
|
|
497
|
+
...tr(),
|
|
498
|
+
workerPath: `https://cdn.jsdelivr.net/npm/tesseract.js@v${i}/dist/worker.min.js`
|
|
499
|
+
}, se;
|
|
500
|
+
}
|
|
501
|
+
var ue, Ne;
|
|
502
|
+
function or() {
|
|
503
|
+
return Ne || (Ne = 1, ue = ({ workerPath: i, workerBlobURL: o }) => {
|
|
504
|
+
let n;
|
|
505
|
+
if (Blob && URL && o) {
|
|
506
|
+
const c = new Blob([`importScripts("${i}");`], {
|
|
507
|
+
type: "application/javascript"
|
|
508
|
+
});
|
|
509
|
+
n = new Worker(URL.createObjectURL(c));
|
|
510
|
+
} else
|
|
511
|
+
n = new Worker(i);
|
|
512
|
+
return n;
|
|
513
|
+
}), ue;
|
|
514
|
+
}
|
|
515
|
+
var ce, Pe;
|
|
516
|
+
function ar() {
|
|
517
|
+
return Pe || (Pe = 1, ce = (i) => {
|
|
518
|
+
i.terminate();
|
|
519
|
+
}), ce;
|
|
520
|
+
}
|
|
521
|
+
var le, Ie;
|
|
522
|
+
function ir() {
|
|
523
|
+
return Ie || (Ie = 1, le = (i, o) => {
|
|
524
|
+
i.onmessage = ({ data: n }) => {
|
|
525
|
+
o(n);
|
|
526
|
+
};
|
|
527
|
+
}), le;
|
|
528
|
+
}
|
|
529
|
+
var fe, Me;
|
|
530
|
+
function sr() {
|
|
531
|
+
return Me || (Me = 1, fe = async (i, o) => {
|
|
532
|
+
i.postMessage(o);
|
|
533
|
+
}), fe;
|
|
534
|
+
}
|
|
535
|
+
var de, Ce;
|
|
536
|
+
function ur() {
|
|
537
|
+
if (Ce) return de;
|
|
538
|
+
Ce = 1;
|
|
539
|
+
const i = (n) => new Promise((c, s) => {
|
|
540
|
+
const d = new FileReader();
|
|
541
|
+
d.onload = () => {
|
|
542
|
+
c(d.result);
|
|
543
|
+
}, d.onerror = ({ target: { error: { code: p } } }) => {
|
|
544
|
+
s(Error(`File could not be read! Code=${p}`));
|
|
545
|
+
}, d.readAsArrayBuffer(n);
|
|
546
|
+
}), o = async (n) => {
|
|
547
|
+
let c = n;
|
|
548
|
+
if (typeof n > "u")
|
|
549
|
+
return "undefined";
|
|
550
|
+
if (typeof n == "string")
|
|
551
|
+
/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(n) ? c = atob(n.split(",")[1]).split("").map((s) => s.charCodeAt(0)) : c = await (await fetch(n)).arrayBuffer();
|
|
552
|
+
else if (typeof HTMLElement < "u" && n instanceof HTMLElement)
|
|
553
|
+
n.tagName === "IMG" && (c = await o(n.src)), n.tagName === "VIDEO" && (c = await o(n.poster)), n.tagName === "CANVAS" && await new Promise((s) => {
|
|
554
|
+
n.toBlob(async (d) => {
|
|
555
|
+
c = await i(d), s();
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
else if (typeof OffscreenCanvas < "u" && n instanceof OffscreenCanvas) {
|
|
559
|
+
const s = await n.convertToBlob();
|
|
560
|
+
c = await i(s);
|
|
561
|
+
} else (n instanceof File || n instanceof Blob) && (c = await i(n));
|
|
562
|
+
return new Uint8Array(c);
|
|
563
|
+
};
|
|
564
|
+
return de = o, de;
|
|
565
|
+
}
|
|
566
|
+
var he, Ge;
|
|
567
|
+
function cr() {
|
|
568
|
+
if (Ge) return he;
|
|
569
|
+
Ge = 1;
|
|
570
|
+
const i = nr(), o = or(), n = ar(), c = ir(), s = sr(), d = ur();
|
|
571
|
+
return he = {
|
|
572
|
+
defaultOptions: i,
|
|
573
|
+
spawnWorker: o,
|
|
574
|
+
terminateWorker: n,
|
|
575
|
+
onMessage: c,
|
|
576
|
+
send: s,
|
|
577
|
+
loadImage: d
|
|
578
|
+
}, he;
|
|
579
|
+
}
|
|
580
|
+
var pe, je;
|
|
581
|
+
function ze() {
|
|
582
|
+
if (je) return pe;
|
|
583
|
+
je = 1;
|
|
584
|
+
const i = xe(), o = Fe(), { log: n } = Le(), c = we(), s = $e(), {
|
|
585
|
+
defaultOptions: d,
|
|
586
|
+
spawnWorker: p,
|
|
587
|
+
terminateWorker: k,
|
|
588
|
+
onMessage: G,
|
|
589
|
+
loadImage: j,
|
|
590
|
+
send: M
|
|
591
|
+
} = cr();
|
|
592
|
+
let O = 0;
|
|
593
|
+
return pe = async (C = "eng", D = s.LSTM_ONLY, z = {}, g = {}) => {
|
|
594
|
+
const m = c("Worker", O), {
|
|
595
|
+
logger: U,
|
|
596
|
+
errorHandler: w,
|
|
597
|
+
...y
|
|
598
|
+
} = i({
|
|
599
|
+
...d,
|
|
600
|
+
...z
|
|
601
|
+
}), R = {}, _ = typeof C == "string" ? C.split("+") : C;
|
|
602
|
+
let B = D, F = g;
|
|
603
|
+
const W = [s.DEFAULT, s.LSTM_ONLY].includes(D) && !y.legacyCore;
|
|
604
|
+
let N, Y;
|
|
605
|
+
const $ = new Promise((l, f) => {
|
|
606
|
+
Y = l, N = f;
|
|
607
|
+
}), Q = (l) => {
|
|
608
|
+
N(l.message);
|
|
609
|
+
};
|
|
610
|
+
let P = p(y);
|
|
611
|
+
P.onerror = Q, O += 1;
|
|
612
|
+
const T = ({ id: l, action: f, payload: v }) => new Promise((A, q) => {
|
|
613
|
+
n(`[${m}]: Start ${l}, action=${f}`);
|
|
614
|
+
const I = `${f}-${l}`;
|
|
615
|
+
R[I] = { resolve: A, reject: q }, M(P, {
|
|
616
|
+
workerId: m,
|
|
617
|
+
jobId: l,
|
|
618
|
+
action: f,
|
|
619
|
+
payload: v
|
|
620
|
+
});
|
|
621
|
+
}), K = () => console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)"), H = (l) => T(o({
|
|
622
|
+
id: l,
|
|
623
|
+
action: "load",
|
|
624
|
+
payload: { options: { lstmOnly: W, corePath: y.corePath, logging: y.logging } }
|
|
625
|
+
})), J = (l, f, v) => T(o({
|
|
626
|
+
id: v,
|
|
627
|
+
action: "FS",
|
|
628
|
+
payload: { method: "writeFile", args: [l, f] }
|
|
629
|
+
})), Z = (l, f) => T(o({
|
|
630
|
+
id: f,
|
|
631
|
+
action: "FS",
|
|
632
|
+
payload: { method: "readFile", args: [l, { encoding: "utf8" }] }
|
|
633
|
+
})), r = (l, f) => T(o({
|
|
634
|
+
id: f,
|
|
635
|
+
action: "FS",
|
|
636
|
+
payload: { method: "unlink", args: [l] }
|
|
637
|
+
})), e = (l, f, v) => T(o({
|
|
638
|
+
id: v,
|
|
639
|
+
action: "FS",
|
|
640
|
+
payload: { method: l, args: f }
|
|
641
|
+
})), t = (l, f) => T(o({
|
|
642
|
+
id: f,
|
|
643
|
+
action: "loadLanguage",
|
|
644
|
+
payload: {
|
|
645
|
+
langs: l,
|
|
646
|
+
options: {
|
|
647
|
+
langPath: y.langPath,
|
|
648
|
+
dataPath: y.dataPath,
|
|
649
|
+
cachePath: y.cachePath,
|
|
650
|
+
cacheMethod: y.cacheMethod,
|
|
651
|
+
gzip: y.gzip,
|
|
652
|
+
lstmOnly: [s.DEFAULT, s.LSTM_ONLY].includes(B) && !y.legacyLang
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
})), u = (l, f, v, A) => T(o({
|
|
656
|
+
id: A,
|
|
657
|
+
action: "initialize",
|
|
658
|
+
payload: { langs: l, oem: f, config: v }
|
|
659
|
+
})), a = (l = "eng", f, v, A) => {
|
|
660
|
+
if (W && [s.TESSERACT_ONLY, s.TESSERACT_LSTM_COMBINED].includes(f)) throw Error("Legacy model requested but code missing.");
|
|
661
|
+
const q = f || B;
|
|
662
|
+
B = q;
|
|
663
|
+
const I = v || F;
|
|
664
|
+
F = I;
|
|
665
|
+
const X = (typeof l == "string" ? l.split("+") : l).filter((Ke) => !_.includes(Ke));
|
|
666
|
+
return _.push(...X), X.length > 0 ? t(X, A).then(() => u(l, q, I, A)) : u(l, q, I, A);
|
|
667
|
+
}, h = (l = {}, f) => T(o({
|
|
668
|
+
id: f,
|
|
669
|
+
action: "setParameters",
|
|
670
|
+
payload: { params: l }
|
|
671
|
+
})), L = async (l, f = {}, v = {
|
|
672
|
+
text: !0
|
|
673
|
+
}, A) => T(o({
|
|
674
|
+
id: A,
|
|
675
|
+
action: "recognize",
|
|
676
|
+
payload: { image: await j(l), options: f, output: v }
|
|
677
|
+
})), S = async (l, f) => {
|
|
678
|
+
if (W) throw Error("`worker.detect` requires Legacy model, which was not loaded.");
|
|
679
|
+
return T(o({
|
|
680
|
+
id: f,
|
|
681
|
+
action: "detect",
|
|
682
|
+
payload: { image: await j(l) }
|
|
683
|
+
}));
|
|
684
|
+
}, b = async () => (P !== null && (k(P), P = null), Promise.resolve());
|
|
685
|
+
G(P, ({
|
|
686
|
+
workerId: l,
|
|
687
|
+
jobId: f,
|
|
688
|
+
status: v,
|
|
689
|
+
action: A,
|
|
690
|
+
data: q
|
|
691
|
+
}) => {
|
|
692
|
+
const I = `${A}-${f}`;
|
|
693
|
+
if (v === "resolve")
|
|
694
|
+
n(`[${l}]: Complete ${f}`), R[I].resolve({ jobId: f, data: q }), delete R[I];
|
|
695
|
+
else if (v === "reject")
|
|
696
|
+
if (R[I].reject(q), delete R[I], A === "load" && N(q), w)
|
|
697
|
+
w(q);
|
|
698
|
+
else
|
|
699
|
+
throw Error(q);
|
|
700
|
+
else v === "progress" && U({ ...q, userJobId: f });
|
|
701
|
+
});
|
|
702
|
+
const E = {
|
|
703
|
+
id: m,
|
|
704
|
+
worker: P,
|
|
705
|
+
load: K,
|
|
706
|
+
writeText: J,
|
|
707
|
+
readText: Z,
|
|
708
|
+
removeFile: r,
|
|
709
|
+
FS: e,
|
|
710
|
+
reinitialize: a,
|
|
711
|
+
setParameters: h,
|
|
712
|
+
recognize: L,
|
|
713
|
+
detect: S,
|
|
714
|
+
terminate: b
|
|
715
|
+
};
|
|
716
|
+
return H().then(() => t(C)).then(() => u(C, D, g)).then(() => Y(E)).catch(() => {
|
|
717
|
+
}), $;
|
|
718
|
+
}, pe;
|
|
719
|
+
}
|
|
720
|
+
var ve, De;
|
|
721
|
+
function lr() {
|
|
722
|
+
if (De) return ve;
|
|
723
|
+
De = 1;
|
|
724
|
+
const i = ze();
|
|
725
|
+
return ve = {
|
|
726
|
+
recognize: async (c, s, d) => {
|
|
727
|
+
const p = await i(s, 1, d);
|
|
728
|
+
return p.recognize(c).finally(async () => {
|
|
729
|
+
await p.terminate();
|
|
730
|
+
});
|
|
731
|
+
},
|
|
732
|
+
detect: async (c, s) => {
|
|
733
|
+
const d = await i("osd", 0, s);
|
|
734
|
+
return d.detect(c).finally(async () => {
|
|
735
|
+
await d.terminate();
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}, ve;
|
|
739
|
+
}
|
|
740
|
+
var ge, Ue;
|
|
741
|
+
function fr() {
|
|
742
|
+
return Ue || (Ue = 1, ge = {
|
|
743
|
+
AFR: "afr",
|
|
744
|
+
AMH: "amh",
|
|
745
|
+
ARA: "ara",
|
|
746
|
+
ASM: "asm",
|
|
747
|
+
AZE: "aze",
|
|
748
|
+
AZE_CYRL: "aze_cyrl",
|
|
749
|
+
BEL: "bel",
|
|
750
|
+
BEN: "ben",
|
|
751
|
+
BOD: "bod",
|
|
752
|
+
BOS: "bos",
|
|
753
|
+
BUL: "bul",
|
|
754
|
+
CAT: "cat",
|
|
755
|
+
CEB: "ceb",
|
|
756
|
+
CES: "ces",
|
|
757
|
+
CHI_SIM: "chi_sim",
|
|
758
|
+
CHI_TRA: "chi_tra",
|
|
759
|
+
CHR: "chr",
|
|
760
|
+
CYM: "cym",
|
|
761
|
+
DAN: "dan",
|
|
762
|
+
DEU: "deu",
|
|
763
|
+
DZO: "dzo",
|
|
764
|
+
ELL: "ell",
|
|
765
|
+
ENG: "eng",
|
|
766
|
+
ENM: "enm",
|
|
767
|
+
EPO: "epo",
|
|
768
|
+
EST: "est",
|
|
769
|
+
EUS: "eus",
|
|
770
|
+
FAS: "fas",
|
|
771
|
+
FIN: "fin",
|
|
772
|
+
FRA: "fra",
|
|
773
|
+
FRK: "frk",
|
|
774
|
+
FRM: "frm",
|
|
775
|
+
GLE: "gle",
|
|
776
|
+
GLG: "glg",
|
|
777
|
+
GRC: "grc",
|
|
778
|
+
GUJ: "guj",
|
|
779
|
+
HAT: "hat",
|
|
780
|
+
HEB: "heb",
|
|
781
|
+
HIN: "hin",
|
|
782
|
+
HRV: "hrv",
|
|
783
|
+
HUN: "hun",
|
|
784
|
+
IKU: "iku",
|
|
785
|
+
IND: "ind",
|
|
786
|
+
ISL: "isl",
|
|
787
|
+
ITA: "ita",
|
|
788
|
+
ITA_OLD: "ita_old",
|
|
789
|
+
JAV: "jav",
|
|
790
|
+
JPN: "jpn",
|
|
791
|
+
KAN: "kan",
|
|
792
|
+
KAT: "kat",
|
|
793
|
+
KAT_OLD: "kat_old",
|
|
794
|
+
KAZ: "kaz",
|
|
795
|
+
KHM: "khm",
|
|
796
|
+
KIR: "kir",
|
|
797
|
+
KOR: "kor",
|
|
798
|
+
KUR: "kur",
|
|
799
|
+
LAO: "lao",
|
|
800
|
+
LAT: "lat",
|
|
801
|
+
LAV: "lav",
|
|
802
|
+
LIT: "lit",
|
|
803
|
+
MAL: "mal",
|
|
804
|
+
MAR: "mar",
|
|
805
|
+
MKD: "mkd",
|
|
806
|
+
MLT: "mlt",
|
|
807
|
+
MSA: "msa",
|
|
808
|
+
MYA: "mya",
|
|
809
|
+
NEP: "nep",
|
|
810
|
+
NLD: "nld",
|
|
811
|
+
NOR: "nor",
|
|
812
|
+
ORI: "ori",
|
|
813
|
+
PAN: "pan",
|
|
814
|
+
POL: "pol",
|
|
815
|
+
POR: "por",
|
|
816
|
+
PUS: "pus",
|
|
817
|
+
RON: "ron",
|
|
818
|
+
RUS: "rus",
|
|
819
|
+
SAN: "san",
|
|
820
|
+
SIN: "sin",
|
|
821
|
+
SLK: "slk",
|
|
822
|
+
SLV: "slv",
|
|
823
|
+
SPA: "spa",
|
|
824
|
+
SPA_OLD: "spa_old",
|
|
825
|
+
SQI: "sqi",
|
|
826
|
+
SRP: "srp",
|
|
827
|
+
SRP_LATN: "srp_latn",
|
|
828
|
+
SWA: "swa",
|
|
829
|
+
SWE: "swe",
|
|
830
|
+
SYR: "syr",
|
|
831
|
+
TAM: "tam",
|
|
832
|
+
TEL: "tel",
|
|
833
|
+
TGK: "tgk",
|
|
834
|
+
TGL: "tgl",
|
|
835
|
+
THA: "tha",
|
|
836
|
+
TIR: "tir",
|
|
837
|
+
TUR: "tur",
|
|
838
|
+
UIG: "uig",
|
|
839
|
+
UKR: "ukr",
|
|
840
|
+
URD: "urd",
|
|
841
|
+
UZB: "uzb",
|
|
842
|
+
UZB_CYRL: "uzb_cyrl",
|
|
843
|
+
VIE: "vie",
|
|
844
|
+
YID: "yid"
|
|
845
|
+
}), ge;
|
|
846
|
+
}
|
|
847
|
+
var ye, We;
|
|
848
|
+
function dr() {
|
|
849
|
+
return We || (We = 1, ye = {
|
|
850
|
+
OSD_ONLY: "0",
|
|
851
|
+
AUTO_OSD: "1",
|
|
852
|
+
AUTO_ONLY: "2",
|
|
853
|
+
AUTO: "3",
|
|
854
|
+
SINGLE_COLUMN: "4",
|
|
855
|
+
SINGLE_BLOCK_VERT_TEXT: "5",
|
|
856
|
+
SINGLE_BLOCK: "6",
|
|
857
|
+
SINGLE_LINE: "7",
|
|
858
|
+
SINGLE_WORD: "8",
|
|
859
|
+
CIRCLE_WORD: "9",
|
|
860
|
+
SINGLE_CHAR: "10",
|
|
861
|
+
SPARSE_TEXT: "11",
|
|
862
|
+
SPARSE_TEXT_OSD: "12",
|
|
863
|
+
RAW_LINE: "13"
|
|
864
|
+
}), ye;
|
|
865
|
+
}
|
|
866
|
+
var me, Be;
|
|
867
|
+
function hr() {
|
|
868
|
+
if (Be) return me;
|
|
869
|
+
Be = 1, Ve();
|
|
870
|
+
const i = Ze(), o = ze(), n = lr(), c = fr(), s = $e(), d = dr(), { setLogging: p } = Le();
|
|
871
|
+
return me = {
|
|
872
|
+
languages: c,
|
|
873
|
+
OEM: s,
|
|
874
|
+
PSM: d,
|
|
875
|
+
createScheduler: i,
|
|
876
|
+
createWorker: o,
|
|
877
|
+
setLogging: p,
|
|
878
|
+
...n
|
|
879
|
+
}, me;
|
|
880
|
+
}
|
|
881
|
+
var Ye = hr(), pr = /* @__PURE__ */ Je(Ye), gr = /* @__PURE__ */ He({
|
|
882
|
+
__proto__: null,
|
|
883
|
+
default: pr
|
|
884
|
+
}, [Ye]);
|
|
885
|
+
export {
|
|
886
|
+
gr as i
|
|
887
|
+
};
|
|
888
|
+
//# sourceMappingURL=index-C62fEJ4q.js.map
|