ranuts 0.1.0-alpha.17 → 0.1.0-alpha.18

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 (89) hide show
  1. package/dist/examples/clone-deep-example.d.ts +1 -0
  2. package/dist/examples/is-equal-example.d.ts +1 -0
  3. package/dist/index.d.ts +5 -4
  4. package/dist/index.js +15 -7
  5. package/dist/{mimeType-eRf1TlBb.js → mimeType-BEdNg_IR.js} +59 -2
  6. package/dist/src/arithmetic/index.d.ts +139 -1
  7. package/dist/src/ml/index.js +1140 -1202
  8. package/dist/src/node/body.d.ts +0 -1
  9. package/dist/src/node/command.d.ts +0 -1
  10. package/dist/src/node/ctx2req.d.ts +0 -1
  11. package/dist/src/node/fs.d.ts +0 -2
  12. package/dist/src/node/get.d.ts +1 -1
  13. package/dist/src/node/index.d.ts +24 -22
  14. package/dist/src/node/index.js +1 -1
  15. package/dist/src/node/paresUrl.d.ts +0 -1
  16. package/dist/src/node/readFile.d.ts +0 -1
  17. package/dist/src/node/server.d.ts +0 -1
  18. package/dist/src/node/stream.d.ts +0 -1
  19. package/dist/src/node/traverse.d.ts +0 -1
  20. package/dist/src/node/websocket.d.ts +0 -4
  21. package/dist/src/node/ws.d.ts +0 -1
  22. package/dist/src/optimize/index.d.ts +4 -12
  23. package/dist/src/ran/min.d.ts +15 -1
  24. package/dist/src/utils/behavior.d.ts +5 -0
  25. package/dist/src/utils/bom.d.ts +8 -1
  26. package/dist/src/utils/index.d.ts +8 -7
  27. package/dist/src/utils/index.js +2851 -2585
  28. package/dist/src/utils/number.d.ts +2 -0
  29. package/dist/src/utils/obj.d.ts +37 -1
  30. package/dist/src/utils/signal.d.ts +6 -0
  31. package/dist/src/utils/str.d.ts +10 -2
  32. package/dist/src/utils/subscribe.d.ts +10 -11
  33. package/dist/src/utils/throttle.d.ts +3 -7
  34. package/dist/src/utils/visual/application.d.ts +9 -5
  35. package/dist/src/utils/visual/enums.d.ts +23 -17
  36. package/dist/src/utils/visual/event/index.d.ts +6 -3
  37. package/dist/src/utils/visual/graphics/graphics.d.ts +67 -8
  38. package/dist/src/utils/visual/graphics/graphicsData.d.ts +4 -1
  39. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +23 -4
  40. package/dist/src/utils/visual/graphics/index.d.ts +4 -3
  41. package/dist/src/utils/visual/index.d.ts +7 -4
  42. package/dist/src/utils/visual/math/enums.d.ts +1 -0
  43. package/dist/src/utils/visual/math/index.d.ts +5 -4
  44. package/dist/src/utils/visual/math/matrix.d.ts +87 -6
  45. package/dist/src/utils/visual/math/transform.d.ts +12 -10
  46. package/dist/src/utils/visual/render/batchRenderer.d.ts +72 -0
  47. package/dist/src/utils/visual/render/canvasRenderer.d.ts +2 -1
  48. package/dist/src/utils/visual/render/render.d.ts +8 -3
  49. package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
  50. package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
  51. package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
  52. package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
  53. package/dist/src/utils/visual/render/utils/webgl/batchPool.d.ts +28 -0
  54. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +2 -0
  55. package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
  56. package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
  57. package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
  58. package/dist/src/utils/visual/render/webGlRenderer.d.ts +12 -2
  59. package/dist/src/utils/visual/shape/circle.d.ts +3 -3
  60. package/dist/src/utils/visual/shape/ellipse.d.ts +2 -2
  61. package/dist/src/utils/visual/shape/index.d.ts +7 -5
  62. package/dist/src/utils/visual/shape/polygon.d.ts +5 -4
  63. package/dist/src/utils/visual/shape/rectangle.d.ts +3 -3
  64. package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
  65. package/dist/src/utils/visual/shape/shape.d.ts +2 -3
  66. package/dist/src/utils/visual/style/index.d.ts +3 -2
  67. package/dist/src/utils/visual/style/line.d.ts +4 -3
  68. package/dist/src/utils/visual/types.d.ts +14 -3
  69. package/dist/src/utils/visual/vertex/container.d.ts +40 -5
  70. package/dist/src/utils/visual/vertex/index.d.ts +5 -4
  71. package/dist/src/utils/visual/vertex/point.d.ts +2 -2
  72. package/dist/src/utils/visual/vertex/vertex.d.ts +1 -1
  73. package/dist/src/vnode/modules/index.d.ts +1 -5
  74. package/dist/src/vnode/modules/listeners.d.ts +1 -3
  75. package/dist/src/wicket/bridge.d.ts +4 -0
  76. package/dist/src/wicket/index.d.ts +29 -0
  77. package/dist/test/cloneDeep.test.d.ts +1 -0
  78. package/dist/test/is-equal.test.d.ts +1 -0
  79. package/dist/test/visual/math.test.d.ts +1 -0
  80. package/dist/tsconfig.json +2 -1
  81. package/dist/umd/index.umd.cjs +1 -1
  82. package/dist/umd/ml/ml.umd.cjs +1 -1
  83. package/dist/umd/node/node.umd.cjs +1 -1
  84. package/dist/umd/utils/utils.umd.cjs +1 -1
  85. package/dist/umd/wasm/wasm.umd.cjs +1 -1
  86. package/dist/{ws-CQA-0Bzm.js → ws-BWkMlufE.js} +81 -81
  87. package/package.json +23 -19
  88. package/readme.md +1 -1
  89. package/dist/src/utils/visual/vertex/application.d.ts +0 -13
@@ -1,1291 +1,1229 @@
1
1
  var runtime = { exports: {} };
2
- (function(module) {
3
- var runtime2 = function(exports) {
4
- var Op = Object.prototype;
5
- var hasOwn = Op.hasOwnProperty;
6
- var defineProperty = Object.defineProperty || function(obj, key, desc) {
7
- obj[key] = desc.value;
8
- };
9
- var undefined$1;
10
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
11
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
12
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
13
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
14
- function define(obj, key, value) {
15
- Object.defineProperty(obj, key, {
16
- value,
17
- enumerable: true,
18
- configurable: true,
19
- writable: true
20
- });
21
- return obj[key];
22
- }
23
- try {
24
- define({}, "");
25
- } catch (err) {
26
- define = function(obj, key, value) {
27
- return obj[key] = value;
2
+ var hasRequiredRuntime;
3
+ function requireRuntime() {
4
+ if (hasRequiredRuntime) return runtime.exports;
5
+ hasRequiredRuntime = 1;
6
+ (function(module) {
7
+ var runtime2 = function(exports) {
8
+ var Op = Object.prototype;
9
+ var hasOwn = Op.hasOwnProperty;
10
+ var defineProperty = Object.defineProperty || function(obj, key, desc) {
11
+ obj[key] = desc.value;
28
12
  };
29
- }
30
- function wrap(innerFn, outerFn, self, tryLocsList) {
31
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
32
- var generator = Object.create(protoGenerator.prototype);
33
- var context = new Context(tryLocsList || []);
34
- defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) });
35
- return generator;
36
- }
37
- exports.wrap = wrap;
38
- function tryCatch(fn, obj, arg) {
13
+ var undefined$1;
14
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
15
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
16
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
17
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
18
+ function define(obj, key, value) {
19
+ Object.defineProperty(obj, key, {
20
+ value,
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true
24
+ });
25
+ return obj[key];
26
+ }
39
27
  try {
40
- return { type: "normal", arg: fn.call(obj, arg) };
28
+ define({}, "");
41
29
  } catch (err) {
42
- return { type: "throw", arg: err };
30
+ define = function(obj, key, value) {
31
+ return obj[key] = value;
32
+ };
43
33
  }
44
- }
45
- var GenStateSuspendedStart = "suspendedStart";
46
- var GenStateSuspendedYield = "suspendedYield";
47
- var GenStateExecuting = "executing";
48
- var GenStateCompleted = "completed";
49
- var ContinueSentinel = {};
50
- function Generator() {
51
- }
52
- function GeneratorFunction() {
53
- }
54
- function GeneratorFunctionPrototype() {
55
- }
56
- var IteratorPrototype = {};
57
- define(IteratorPrototype, iteratorSymbol, function() {
58
- return this;
59
- });
60
- var getProto = Object.getPrototypeOf;
61
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
62
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
63
- IteratorPrototype = NativeIteratorPrototype;
64
- }
65
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
66
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
67
- defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true });
68
- defineProperty(
69
- GeneratorFunctionPrototype,
70
- "constructor",
71
- { value: GeneratorFunction, configurable: true }
72
- );
73
- GeneratorFunction.displayName = define(
74
- GeneratorFunctionPrototype,
75
- toStringTagSymbol,
76
- "GeneratorFunction"
77
- );
78
- function defineIteratorMethods(prototype) {
79
- ["next", "throw", "return"].forEach(function(method) {
80
- define(prototype, method, function(arg) {
81
- return this._invoke(method, arg);
82
- });
34
+ function wrap(innerFn, outerFn, self, tryLocsList) {
35
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
36
+ var generator = Object.create(protoGenerator.prototype);
37
+ var context = new Context(tryLocsList || []);
38
+ defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) });
39
+ return generator;
40
+ }
41
+ exports.wrap = wrap;
42
+ function tryCatch(fn, obj, arg) {
43
+ try {
44
+ return { type: "normal", arg: fn.call(obj, arg) };
45
+ } catch (err) {
46
+ return { type: "throw", arg: err };
47
+ }
48
+ }
49
+ var GenStateSuspendedStart = "suspendedStart";
50
+ var GenStateSuspendedYield = "suspendedYield";
51
+ var GenStateExecuting = "executing";
52
+ var GenStateCompleted = "completed";
53
+ var ContinueSentinel = {};
54
+ function Generator() {
55
+ }
56
+ function GeneratorFunction() {
57
+ }
58
+ function GeneratorFunctionPrototype() {
59
+ }
60
+ var IteratorPrototype = {};
61
+ define(IteratorPrototype, iteratorSymbol, function() {
62
+ return this;
83
63
  });
84
- }
85
- exports.isGeneratorFunction = function(genFun) {
86
- var ctor = typeof genFun === "function" && genFun.constructor;
87
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
88
- // do is to check its .name property.
89
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
90
- };
91
- exports.mark = function(genFun) {
92
- if (Object.setPrototypeOf) {
93
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
94
- } else {
95
- genFun.__proto__ = GeneratorFunctionPrototype;
96
- define(genFun, toStringTagSymbol, "GeneratorFunction");
64
+ var getProto = Object.getPrototypeOf;
65
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
66
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
67
+ IteratorPrototype = NativeIteratorPrototype;
97
68
  }
98
- genFun.prototype = Object.create(Gp);
99
- return genFun;
100
- };
101
- exports.awrap = function(arg) {
102
- return { __await: arg };
103
- };
104
- function AsyncIterator(generator, PromiseImpl) {
105
- function invoke(method, arg, resolve, reject) {
106
- var record = tryCatch(generator[method], generator, arg);
107
- if (record.type === "throw") {
108
- reject(record.arg);
69
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
70
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
71
+ defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true });
72
+ defineProperty(
73
+ GeneratorFunctionPrototype,
74
+ "constructor",
75
+ { value: GeneratorFunction, configurable: true }
76
+ );
77
+ GeneratorFunction.displayName = define(
78
+ GeneratorFunctionPrototype,
79
+ toStringTagSymbol,
80
+ "GeneratorFunction"
81
+ );
82
+ function defineIteratorMethods(prototype) {
83
+ ["next", "throw", "return"].forEach(function(method) {
84
+ define(prototype, method, function(arg) {
85
+ return this._invoke(method, arg);
86
+ });
87
+ });
88
+ }
89
+ exports.isGeneratorFunction = function(genFun) {
90
+ var ctor = typeof genFun === "function" && genFun.constructor;
91
+ return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
92
+ // do is to check its .name property.
93
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
94
+ };
95
+ exports.mark = function(genFun) {
96
+ if (Object.setPrototypeOf) {
97
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
109
98
  } else {
110
- var result = record.arg;
111
- var value = result.value;
112
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
113
- return PromiseImpl.resolve(value.__await).then(function(value2) {
114
- invoke("next", value2, resolve, reject);
115
- }, function(err) {
116
- invoke("throw", err, resolve, reject);
99
+ genFun.__proto__ = GeneratorFunctionPrototype;
100
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
101
+ }
102
+ genFun.prototype = Object.create(Gp);
103
+ return genFun;
104
+ };
105
+ exports.awrap = function(arg) {
106
+ return { __await: arg };
107
+ };
108
+ function AsyncIterator(generator, PromiseImpl) {
109
+ function invoke(method, arg, resolve, reject) {
110
+ var record = tryCatch(generator[method], generator, arg);
111
+ if (record.type === "throw") {
112
+ reject(record.arg);
113
+ } else {
114
+ var result = record.arg;
115
+ var value = result.value;
116
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
117
+ return PromiseImpl.resolve(value.__await).then(function(value2) {
118
+ invoke("next", value2, resolve, reject);
119
+ }, function(err) {
120
+ invoke("throw", err, resolve, reject);
121
+ });
122
+ }
123
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
124
+ result.value = unwrapped;
125
+ resolve(result);
126
+ }, function(error) {
127
+ return invoke("throw", error, resolve, reject);
117
128
  });
118
129
  }
119
- return PromiseImpl.resolve(value).then(function(unwrapped) {
120
- result.value = unwrapped;
121
- resolve(result);
122
- }, function(error) {
123
- return invoke("throw", error, resolve, reject);
124
- });
125
130
  }
126
- }
127
- var previousPromise;
128
- function enqueue(method, arg) {
129
- function callInvokeWithMethodAndArg() {
130
- return new PromiseImpl(function(resolve, reject) {
131
- invoke(method, arg, resolve, reject);
132
- });
131
+ var previousPromise;
132
+ function enqueue(method, arg) {
133
+ function callInvokeWithMethodAndArg() {
134
+ return new PromiseImpl(function(resolve, reject) {
135
+ invoke(method, arg, resolve, reject);
136
+ });
137
+ }
138
+ return previousPromise = // If enqueue has been called before, then we want to wait until
139
+ // all previous Promises have been resolved before calling invoke,
140
+ // so that results are always delivered in the correct order. If
141
+ // enqueue has not been called before, then it is important to
142
+ // call invoke immediately, without waiting on a callback to fire,
143
+ // so that the async generator function has the opportunity to do
144
+ // any necessary setup in a predictable way. This predictability
145
+ // is why the Promise constructor synchronously invokes its
146
+ // executor callback, and why async functions synchronously
147
+ // execute code before the first await. Since we implement simple
148
+ // async functions in terms of async generators, it is especially
149
+ // important to get this right, even though it requires care.
150
+ previousPromise ? previousPromise.then(
151
+ callInvokeWithMethodAndArg,
152
+ // Avoid propagating failures to Promises returned by later
153
+ // invocations of the iterator.
154
+ callInvokeWithMethodAndArg
155
+ ) : callInvokeWithMethodAndArg();
133
156
  }
134
- return previousPromise = // If enqueue has been called before, then we want to wait until
135
- // all previous Promises have been resolved before calling invoke,
136
- // so that results are always delivered in the correct order. If
137
- // enqueue has not been called before, then it is important to
138
- // call invoke immediately, without waiting on a callback to fire,
139
- // so that the async generator function has the opportunity to do
140
- // any necessary setup in a predictable way. This predictability
141
- // is why the Promise constructor synchronously invokes its
142
- // executor callback, and why async functions synchronously
143
- // execute code before the first await. Since we implement simple
144
- // async functions in terms of async generators, it is especially
145
- // important to get this right, even though it requires care.
146
- previousPromise ? previousPromise.then(
147
- callInvokeWithMethodAndArg,
148
- // Avoid propagating failures to Promises returned by later
149
- // invocations of the iterator.
150
- callInvokeWithMethodAndArg
151
- ) : callInvokeWithMethodAndArg();
157
+ defineProperty(this, "_invoke", { value: enqueue });
152
158
  }
153
- defineProperty(this, "_invoke", { value: enqueue });
154
- }
155
- defineIteratorMethods(AsyncIterator.prototype);
156
- define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
157
- return this;
158
- });
159
- exports.AsyncIterator = AsyncIterator;
160
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
161
- if (PromiseImpl === void 0) PromiseImpl = Promise;
162
- var iter = new AsyncIterator(
163
- wrap(innerFn, outerFn, self, tryLocsList),
164
- PromiseImpl
165
- );
166
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
167
- return result.done ? result.value : iter.next();
159
+ defineIteratorMethods(AsyncIterator.prototype);
160
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
161
+ return this;
168
162
  });
169
- };
170
- function makeInvokeMethod(innerFn, self, context) {
171
- var state = GenStateSuspendedStart;
172
- return function invoke(method, arg) {
173
- if (state === GenStateExecuting) {
174
- throw new Error("Generator is already running");
175
- }
176
- if (state === GenStateCompleted) {
177
- if (method === "throw") {
178
- throw arg;
163
+ exports.AsyncIterator = AsyncIterator;
164
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
165
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
166
+ var iter = new AsyncIterator(
167
+ wrap(innerFn, outerFn, self, tryLocsList),
168
+ PromiseImpl
169
+ );
170
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
171
+ return result.done ? result.value : iter.next();
172
+ });
173
+ };
174
+ function makeInvokeMethod(innerFn, self, context) {
175
+ var state = GenStateSuspendedStart;
176
+ return function invoke(method, arg) {
177
+ if (state === GenStateExecuting) {
178
+ throw new Error("Generator is already running");
179
179
  }
180
- return doneResult();
181
- }
182
- context.method = method;
183
- context.arg = arg;
184
- while (true) {
185
- var delegate = context.delegate;
186
- if (delegate) {
187
- var delegateResult = maybeInvokeDelegate(delegate, context);
188
- if (delegateResult) {
189
- if (delegateResult === ContinueSentinel) continue;
190
- return delegateResult;
180
+ if (state === GenStateCompleted) {
181
+ if (method === "throw") {
182
+ throw arg;
191
183
  }
184
+ return doneResult();
192
185
  }
193
- if (context.method === "next") {
194
- context.sent = context._sent = context.arg;
195
- } else if (context.method === "throw") {
196
- if (state === GenStateSuspendedStart) {
186
+ context.method = method;
187
+ context.arg = arg;
188
+ while (true) {
189
+ var delegate = context.delegate;
190
+ if (delegate) {
191
+ var delegateResult = maybeInvokeDelegate(delegate, context);
192
+ if (delegateResult) {
193
+ if (delegateResult === ContinueSentinel) continue;
194
+ return delegateResult;
195
+ }
196
+ }
197
+ if (context.method === "next") {
198
+ context.sent = context._sent = context.arg;
199
+ } else if (context.method === "throw") {
200
+ if (state === GenStateSuspendedStart) {
201
+ state = GenStateCompleted;
202
+ throw context.arg;
203
+ }
204
+ context.dispatchException(context.arg);
205
+ } else if (context.method === "return") {
206
+ context.abrupt("return", context.arg);
207
+ }
208
+ state = GenStateExecuting;
209
+ var record = tryCatch(innerFn, self, context);
210
+ if (record.type === "normal") {
211
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
212
+ if (record.arg === ContinueSentinel) {
213
+ continue;
214
+ }
215
+ return {
216
+ value: record.arg,
217
+ done: context.done
218
+ };
219
+ } else if (record.type === "throw") {
197
220
  state = GenStateCompleted;
198
- throw context.arg;
221
+ context.method = "throw";
222
+ context.arg = record.arg;
199
223
  }
200
- context.dispatchException(context.arg);
201
- } else if (context.method === "return") {
202
- context.abrupt("return", context.arg);
203
224
  }
204
- state = GenStateExecuting;
205
- var record = tryCatch(innerFn, self, context);
206
- if (record.type === "normal") {
207
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
208
- if (record.arg === ContinueSentinel) {
209
- continue;
225
+ };
226
+ }
227
+ function maybeInvokeDelegate(delegate, context) {
228
+ var methodName = context.method;
229
+ var method = delegate.iterator[methodName];
230
+ if (method === undefined$1) {
231
+ context.delegate = null;
232
+ if (methodName === "throw" && delegate.iterator["return"]) {
233
+ context.method = "return";
234
+ context.arg = undefined$1;
235
+ maybeInvokeDelegate(delegate, context);
236
+ if (context.method === "throw") {
237
+ return ContinueSentinel;
210
238
  }
211
- return {
212
- value: record.arg,
213
- done: context.done
214
- };
215
- } else if (record.type === "throw") {
216
- state = GenStateCompleted;
239
+ }
240
+ if (methodName !== "return") {
217
241
  context.method = "throw";
218
- context.arg = record.arg;
242
+ context.arg = new TypeError(
243
+ "The iterator does not provide a '" + methodName + "' method"
244
+ );
219
245
  }
246
+ return ContinueSentinel;
220
247
  }
221
- };
222
- }
223
- function maybeInvokeDelegate(delegate, context) {
224
- var methodName = context.method;
225
- var method = delegate.iterator[methodName];
226
- if (method === undefined$1) {
227
- context.delegate = null;
228
- if (methodName === "throw" && delegate.iterator["return"]) {
229
- context.method = "return";
230
- context.arg = undefined$1;
231
- maybeInvokeDelegate(delegate, context);
232
- if (context.method === "throw") {
233
- return ContinueSentinel;
234
- }
248
+ var record = tryCatch(method, delegate.iterator, context.arg);
249
+ if (record.type === "throw") {
250
+ context.method = "throw";
251
+ context.arg = record.arg;
252
+ context.delegate = null;
253
+ return ContinueSentinel;
235
254
  }
236
- if (methodName !== "return") {
255
+ var info = record.arg;
256
+ if (!info) {
237
257
  context.method = "throw";
238
- context.arg = new TypeError(
239
- "The iterator does not provide a '" + methodName + "' method"
240
- );
258
+ context.arg = new TypeError("iterator result is not an object");
259
+ context.delegate = null;
260
+ return ContinueSentinel;
261
+ }
262
+ if (info.done) {
263
+ context[delegate.resultName] = info.value;
264
+ context.next = delegate.nextLoc;
265
+ if (context.method !== "return") {
266
+ context.method = "next";
267
+ context.arg = undefined$1;
268
+ }
269
+ } else {
270
+ return info;
241
271
  }
242
- return ContinueSentinel;
243
- }
244
- var record = tryCatch(method, delegate.iterator, context.arg);
245
- if (record.type === "throw") {
246
- context.method = "throw";
247
- context.arg = record.arg;
248
- context.delegate = null;
249
- return ContinueSentinel;
250
- }
251
- var info = record.arg;
252
- if (!info) {
253
- context.method = "throw";
254
- context.arg = new TypeError("iterator result is not an object");
255
272
  context.delegate = null;
256
273
  return ContinueSentinel;
257
274
  }
258
- if (info.done) {
259
- context[delegate.resultName] = info.value;
260
- context.next = delegate.nextLoc;
261
- if (context.method !== "return") {
262
- context.method = "next";
263
- context.arg = undefined$1;
275
+ defineIteratorMethods(Gp);
276
+ define(Gp, toStringTagSymbol, "Generator");
277
+ define(Gp, iteratorSymbol, function() {
278
+ return this;
279
+ });
280
+ define(Gp, "toString", function() {
281
+ return "[object Generator]";
282
+ });
283
+ function pushTryEntry(locs) {
284
+ var entry = { tryLoc: locs[0] };
285
+ if (1 in locs) {
286
+ entry.catchLoc = locs[1];
264
287
  }
265
- } else {
266
- return info;
288
+ if (2 in locs) {
289
+ entry.finallyLoc = locs[2];
290
+ entry.afterLoc = locs[3];
291
+ }
292
+ this.tryEntries.push(entry);
267
293
  }
268
- context.delegate = null;
269
- return ContinueSentinel;
270
- }
271
- defineIteratorMethods(Gp);
272
- define(Gp, toStringTagSymbol, "Generator");
273
- define(Gp, iteratorSymbol, function() {
274
- return this;
275
- });
276
- define(Gp, "toString", function() {
277
- return "[object Generator]";
278
- });
279
- function pushTryEntry(locs) {
280
- var entry = { tryLoc: locs[0] };
281
- if (1 in locs) {
282
- entry.catchLoc = locs[1];
294
+ function resetTryEntry(entry) {
295
+ var record = entry.completion || {};
296
+ record.type = "normal";
297
+ delete record.arg;
298
+ entry.completion = record;
283
299
  }
284
- if (2 in locs) {
285
- entry.finallyLoc = locs[2];
286
- entry.afterLoc = locs[3];
300
+ function Context(tryLocsList) {
301
+ this.tryEntries = [{ tryLoc: "root" }];
302
+ tryLocsList.forEach(pushTryEntry, this);
303
+ this.reset(true);
287
304
  }
288
- this.tryEntries.push(entry);
289
- }
290
- function resetTryEntry(entry) {
291
- var record = entry.completion || {};
292
- record.type = "normal";
293
- delete record.arg;
294
- entry.completion = record;
295
- }
296
- function Context(tryLocsList) {
297
- this.tryEntries = [{ tryLoc: "root" }];
298
- tryLocsList.forEach(pushTryEntry, this);
299
- this.reset(true);
300
- }
301
- exports.keys = function(val) {
302
- var object = Object(val);
303
- var keys = [];
304
- for (var key in object) {
305
- keys.push(key);
306
- }
307
- keys.reverse();
308
- return function next() {
309
- while (keys.length) {
310
- var key2 = keys.pop();
311
- if (key2 in object) {
312
- next.value = key2;
313
- next.done = false;
314
- return next;
315
- }
305
+ exports.keys = function(val) {
306
+ var object = Object(val);
307
+ var keys = [];
308
+ for (var key in object) {
309
+ keys.push(key);
316
310
  }
317
- next.done = true;
318
- return next;
311
+ keys.reverse();
312
+ return function next() {
313
+ while (keys.length) {
314
+ var key2 = keys.pop();
315
+ if (key2 in object) {
316
+ next.value = key2;
317
+ next.done = false;
318
+ return next;
319
+ }
320
+ }
321
+ next.done = true;
322
+ return next;
323
+ };
319
324
  };
320
- };
321
- function values(iterable) {
322
- if (iterable) {
323
- var iteratorMethod = iterable[iteratorSymbol];
324
- if (iteratorMethod) {
325
- return iteratorMethod.call(iterable);
326
- }
327
- if (typeof iterable.next === "function") {
328
- return iterable;
329
- }
330
- if (!isNaN(iterable.length)) {
331
- var i = -1, next = function next2() {
332
- while (++i < iterable.length) {
333
- if (hasOwn.call(iterable, i)) {
334
- next2.value = iterable[i];
335
- next2.done = false;
336
- return next2;
325
+ function values(iterable) {
326
+ if (iterable) {
327
+ var iteratorMethod = iterable[iteratorSymbol];
328
+ if (iteratorMethod) {
329
+ return iteratorMethod.call(iterable);
330
+ }
331
+ if (typeof iterable.next === "function") {
332
+ return iterable;
333
+ }
334
+ if (!isNaN(iterable.length)) {
335
+ var i = -1, next = function next2() {
336
+ while (++i < iterable.length) {
337
+ if (hasOwn.call(iterable, i)) {
338
+ next2.value = iterable[i];
339
+ next2.done = false;
340
+ return next2;
341
+ }
337
342
  }
338
- }
339
- next2.value = undefined$1;
340
- next2.done = true;
341
- return next2;
342
- };
343
- return next.next = next;
343
+ next2.value = undefined$1;
344
+ next2.done = true;
345
+ return next2;
346
+ };
347
+ return next.next = next;
348
+ }
344
349
  }
350
+ return { next: doneResult };
345
351
  }
346
- return { next: doneResult };
347
- }
348
- exports.values = values;
349
- function doneResult() {
350
- return { value: undefined$1, done: true };
351
- }
352
- Context.prototype = {
353
- constructor: Context,
354
- reset: function(skipTempReset) {
355
- this.prev = 0;
356
- this.next = 0;
357
- this.sent = this._sent = undefined$1;
358
- this.done = false;
359
- this.delegate = null;
360
- this.method = "next";
361
- this.arg = undefined$1;
362
- this.tryEntries.forEach(resetTryEntry);
363
- if (!skipTempReset) {
364
- for (var name2 in this) {
365
- if (name2.charAt(0) === "t" && hasOwn.call(this, name2) && !isNaN(+name2.slice(1))) {
366
- this[name2] = undefined$1;
352
+ exports.values = values;
353
+ function doneResult() {
354
+ return { value: undefined$1, done: true };
355
+ }
356
+ Context.prototype = {
357
+ constructor: Context,
358
+ reset: function(skipTempReset) {
359
+ this.prev = 0;
360
+ this.next = 0;
361
+ this.sent = this._sent = undefined$1;
362
+ this.done = false;
363
+ this.delegate = null;
364
+ this.method = "next";
365
+ this.arg = undefined$1;
366
+ this.tryEntries.forEach(resetTryEntry);
367
+ if (!skipTempReset) {
368
+ for (var name in this) {
369
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
370
+ this[name] = undefined$1;
371
+ }
367
372
  }
368
373
  }
369
- }
370
- },
371
- stop: function() {
372
- this.done = true;
373
- var rootEntry = this.tryEntries[0];
374
- var rootRecord = rootEntry.completion;
375
- if (rootRecord.type === "throw") {
376
- throw rootRecord.arg;
377
- }
378
- return this.rval;
379
- },
380
- dispatchException: function(exception) {
381
- if (this.done) {
382
- throw exception;
383
- }
384
- var context = this;
385
- function handle(loc, caught) {
386
- record.type = "throw";
387
- record.arg = exception;
388
- context.next = loc;
389
- if (caught) {
390
- context.method = "next";
391
- context.arg = undefined$1;
374
+ },
375
+ stop: function() {
376
+ this.done = true;
377
+ var rootEntry = this.tryEntries[0];
378
+ var rootRecord = rootEntry.completion;
379
+ if (rootRecord.type === "throw") {
380
+ throw rootRecord.arg;
392
381
  }
393
- return !!caught;
394
- }
395
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
396
- var entry = this.tryEntries[i];
397
- var record = entry.completion;
398
- if (entry.tryLoc === "root") {
399
- return handle("end");
382
+ return this.rval;
383
+ },
384
+ dispatchException: function(exception) {
385
+ if (this.done) {
386
+ throw exception;
400
387
  }
401
- if (entry.tryLoc <= this.prev) {
402
- var hasCatch = hasOwn.call(entry, "catchLoc");
403
- var hasFinally = hasOwn.call(entry, "finallyLoc");
404
- if (hasCatch && hasFinally) {
405
- if (this.prev < entry.catchLoc) {
406
- return handle(entry.catchLoc, true);
407
- } else if (this.prev < entry.finallyLoc) {
408
- return handle(entry.finallyLoc);
409
- }
410
- } else if (hasCatch) {
411
- if (this.prev < entry.catchLoc) {
412
- return handle(entry.catchLoc, true);
413
- }
414
- } else if (hasFinally) {
415
- if (this.prev < entry.finallyLoc) {
416
- return handle(entry.finallyLoc);
388
+ var context = this;
389
+ function handle(loc, caught) {
390
+ record.type = "throw";
391
+ record.arg = exception;
392
+ context.next = loc;
393
+ if (caught) {
394
+ context.method = "next";
395
+ context.arg = undefined$1;
396
+ }
397
+ return !!caught;
398
+ }
399
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
400
+ var entry = this.tryEntries[i];
401
+ var record = entry.completion;
402
+ if (entry.tryLoc === "root") {
403
+ return handle("end");
404
+ }
405
+ if (entry.tryLoc <= this.prev) {
406
+ var hasCatch = hasOwn.call(entry, "catchLoc");
407
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
408
+ if (hasCatch && hasFinally) {
409
+ if (this.prev < entry.catchLoc) {
410
+ return handle(entry.catchLoc, true);
411
+ } else if (this.prev < entry.finallyLoc) {
412
+ return handle(entry.finallyLoc);
413
+ }
414
+ } else if (hasCatch) {
415
+ if (this.prev < entry.catchLoc) {
416
+ return handle(entry.catchLoc, true);
417
+ }
418
+ } else if (hasFinally) {
419
+ if (this.prev < entry.finallyLoc) {
420
+ return handle(entry.finallyLoc);
421
+ }
422
+ } else {
423
+ throw new Error("try statement without catch or finally");
417
424
  }
418
- } else {
419
- throw new Error("try statement without catch or finally");
420
425
  }
421
426
  }
422
- }
423
- },
424
- abrupt: function(type, arg) {
425
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
426
- var entry = this.tryEntries[i];
427
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
428
- var finallyEntry = entry;
429
- break;
427
+ },
428
+ abrupt: function(type, arg) {
429
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
430
+ var entry = this.tryEntries[i];
431
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
432
+ var finallyEntry = entry;
433
+ break;
434
+ }
430
435
  }
431
- }
432
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
433
- finallyEntry = null;
434
- }
435
- var record = finallyEntry ? finallyEntry.completion : {};
436
- record.type = type;
437
- record.arg = arg;
438
- if (finallyEntry) {
439
- this.method = "next";
440
- this.next = finallyEntry.finallyLoc;
441
- return ContinueSentinel;
442
- }
443
- return this.complete(record);
444
- },
445
- complete: function(record, afterLoc) {
446
- if (record.type === "throw") {
447
- throw record.arg;
448
- }
449
- if (record.type === "break" || record.type === "continue") {
450
- this.next = record.arg;
451
- } else if (record.type === "return") {
452
- this.rval = this.arg = record.arg;
453
- this.method = "return";
454
- this.next = "end";
455
- } else if (record.type === "normal" && afterLoc) {
456
- this.next = afterLoc;
457
- }
458
- return ContinueSentinel;
459
- },
460
- finish: function(finallyLoc) {
461
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
462
- var entry = this.tryEntries[i];
463
- if (entry.finallyLoc === finallyLoc) {
464
- this.complete(entry.completion, entry.afterLoc);
465
- resetTryEntry(entry);
436
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
437
+ finallyEntry = null;
438
+ }
439
+ var record = finallyEntry ? finallyEntry.completion : {};
440
+ record.type = type;
441
+ record.arg = arg;
442
+ if (finallyEntry) {
443
+ this.method = "next";
444
+ this.next = finallyEntry.finallyLoc;
466
445
  return ContinueSentinel;
467
446
  }
468
- }
469
- },
470
- "catch": function(tryLoc) {
471
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
472
- var entry = this.tryEntries[i];
473
- if (entry.tryLoc === tryLoc) {
474
- var record = entry.completion;
475
- if (record.type === "throw") {
476
- var thrown = record.arg;
447
+ return this.complete(record);
448
+ },
449
+ complete: function(record, afterLoc) {
450
+ if (record.type === "throw") {
451
+ throw record.arg;
452
+ }
453
+ if (record.type === "break" || record.type === "continue") {
454
+ this.next = record.arg;
455
+ } else if (record.type === "return") {
456
+ this.rval = this.arg = record.arg;
457
+ this.method = "return";
458
+ this.next = "end";
459
+ } else if (record.type === "normal" && afterLoc) {
460
+ this.next = afterLoc;
461
+ }
462
+ return ContinueSentinel;
463
+ },
464
+ finish: function(finallyLoc) {
465
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
466
+ var entry = this.tryEntries[i];
467
+ if (entry.finallyLoc === finallyLoc) {
468
+ this.complete(entry.completion, entry.afterLoc);
477
469
  resetTryEntry(entry);
470
+ return ContinueSentinel;
478
471
  }
479
- return thrown;
480
472
  }
473
+ },
474
+ "catch": function(tryLoc) {
475
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
476
+ var entry = this.tryEntries[i];
477
+ if (entry.tryLoc === tryLoc) {
478
+ var record = entry.completion;
479
+ if (record.type === "throw") {
480
+ var thrown = record.arg;
481
+ resetTryEntry(entry);
482
+ }
483
+ return thrown;
484
+ }
485
+ }
486
+ throw new Error("illegal catch attempt");
487
+ },
488
+ delegateYield: function(iterable, resultName, nextLoc) {
489
+ this.delegate = {
490
+ iterator: values(iterable),
491
+ resultName,
492
+ nextLoc
493
+ };
494
+ if (this.method === "next") {
495
+ this.arg = undefined$1;
496
+ }
497
+ return ContinueSentinel;
481
498
  }
482
- throw new Error("illegal catch attempt");
483
- },
484
- delegateYield: function(iterable, resultName, nextLoc) {
485
- this.delegate = {
486
- iterator: values(iterable),
487
- resultName,
488
- nextLoc
489
- };
490
- if (this.method === "next") {
491
- this.arg = undefined$1;
492
- }
493
- return ContinueSentinel;
499
+ };
500
+ return exports;
501
+ }(
502
+ // If this script is executing as a CommonJS module, use module.exports
503
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
504
+ // object. Either way, the resulting object will be used to initialize
505
+ // the regeneratorRuntime variable at the top of this file.
506
+ module.exports
507
+ );
508
+ try {
509
+ regeneratorRuntime = runtime2;
510
+ } catch (accidentalStrictMode) {
511
+ if (typeof globalThis === "object") {
512
+ globalThis.regeneratorRuntime = runtime2;
513
+ } else {
514
+ Function("r", "regeneratorRuntime = r")(runtime2);
494
515
  }
495
- };
496
- return exports;
497
- }(
498
- // If this script is executing as a CommonJS module, use module.exports
499
- // as the regeneratorRuntime namespace. Otherwise create a new empty
500
- // object. Either way, the resulting object will be used to initialize
501
- // the regeneratorRuntime variable at the top of this file.
502
- module.exports
503
- );
504
- try {
505
- regeneratorRuntime = runtime2;
506
- } catch (accidentalStrictMode) {
507
- if (typeof globalThis === "object") {
508
- globalThis.regeneratorRuntime = runtime2;
509
- } else {
510
- Function("r", "regeneratorRuntime = r")(runtime2);
511
516
  }
512
- }
513
- })(runtime);
514
- var getId$3 = (prefix, cnt) => `${prefix}-${cnt}-${Math.random().toString(16).slice(3, 8)}`;
515
- const getId$2 = getId$3;
516
- let jobCounter = 0;
517
- var createJob$2 = ({
518
- id: _id,
519
- action,
520
- payload = {}
521
- }) => {
522
- let id = _id;
523
- if (typeof id === "undefined") {
524
- id = getId$2("Job", jobCounter);
525
- jobCounter += 1;
526
- }
527
- return {
528
- id,
517
+ })(runtime);
518
+ return runtime.exports;
519
+ }
520
+ var getId;
521
+ var hasRequiredGetId;
522
+ function requireGetId() {
523
+ if (hasRequiredGetId) return getId;
524
+ hasRequiredGetId = 1;
525
+ getId = (prefix, cnt) => `${prefix}-${cnt}-${Math.random().toString(16).slice(3, 8)}`;
526
+ return getId;
527
+ }
528
+ var createJob;
529
+ var hasRequiredCreateJob;
530
+ function requireCreateJob() {
531
+ if (hasRequiredCreateJob) return createJob;
532
+ hasRequiredCreateJob = 1;
533
+ const getId2 = requireGetId();
534
+ let jobCounter = 0;
535
+ createJob = ({
536
+ id: _id,
529
537
  action,
530
- payload
531
- };
532
- };
533
- var log$2 = {};
534
- let logging = false;
535
- log$2.logging = logging;
536
- log$2.setLogging = (_logging) => {
537
- logging = _logging;
538
- };
539
- log$2.log = (...args) => logging ? console.log.apply(void 0, args) : null;
540
- const createJob$1 = createJob$2;
541
- const { log: log$1 } = log$2;
542
- const getId$1 = getId$3;
543
- let schedulerCounter = 0;
544
- var createScheduler$1 = () => {
545
- const id = getId$1("Scheduler", schedulerCounter);
546
- const workers = {};
547
- const runningWorkers = {};
548
- let jobQueue = [];
549
- schedulerCounter += 1;
550
- const getQueueLen = () => jobQueue.length;
551
- const getNumWorkers = () => Object.keys(workers).length;
552
- const dequeue = () => {
553
- if (jobQueue.length !== 0) {
554
- const wIds = Object.keys(workers);
555
- for (let i = 0; i < wIds.length; i += 1) {
556
- if (typeof runningWorkers[wIds[i]] === "undefined") {
557
- jobQueue[0](workers[wIds[i]]);
558
- break;
559
- }
560
- }
538
+ payload = {}
539
+ }) => {
540
+ let id = _id;
541
+ if (typeof id === "undefined") {
542
+ id = getId2("Job", jobCounter);
543
+ jobCounter += 1;
561
544
  }
545
+ return {
546
+ id,
547
+ action,
548
+ payload
549
+ };
562
550
  };
563
- const queue = (action, payload) => new Promise((resolve, reject) => {
564
- const job = createJob$1({ action, payload });
565
- jobQueue.push(async (w) => {
566
- jobQueue.shift();
567
- runningWorkers[w.id] = job;
568
- try {
569
- resolve(await w[action].apply(void 0, [...payload, job.id]));
570
- } catch (err) {
571
- reject(err);
572
- } finally {
573
- delete runningWorkers[w.id];
574
- dequeue();
551
+ return createJob;
552
+ }
553
+ var log = {};
554
+ var hasRequiredLog;
555
+ function requireLog() {
556
+ if (hasRequiredLog) return log;
557
+ hasRequiredLog = 1;
558
+ let logging = false;
559
+ log.logging = logging;
560
+ log.setLogging = (_logging) => {
561
+ logging = _logging;
562
+ };
563
+ log.log = (...args) => logging ? console.log.apply(this, args) : null;
564
+ return log;
565
+ }
566
+ var createScheduler;
567
+ var hasRequiredCreateScheduler;
568
+ function requireCreateScheduler() {
569
+ if (hasRequiredCreateScheduler) return createScheduler;
570
+ hasRequiredCreateScheduler = 1;
571
+ const createJob2 = requireCreateJob();
572
+ const { log: log2 } = requireLog();
573
+ const getId2 = requireGetId();
574
+ let schedulerCounter = 0;
575
+ createScheduler = () => {
576
+ const id = getId2("Scheduler", schedulerCounter);
577
+ const workers = {};
578
+ const runningWorkers = {};
579
+ let jobQueue = [];
580
+ schedulerCounter += 1;
581
+ const getQueueLen = () => jobQueue.length;
582
+ const getNumWorkers = () => Object.keys(workers).length;
583
+ const dequeue = () => {
584
+ if (jobQueue.length !== 0) {
585
+ const wIds = Object.keys(workers);
586
+ for (let i = 0; i < wIds.length; i += 1) {
587
+ if (typeof runningWorkers[wIds[i]] === "undefined") {
588
+ jobQueue[0](workers[wIds[i]]);
589
+ break;
590
+ }
591
+ }
575
592
  }
593
+ };
594
+ const queue = (action, payload) => new Promise((resolve, reject) => {
595
+ const job = createJob2({ action, payload });
596
+ jobQueue.push(async (w) => {
597
+ jobQueue.shift();
598
+ runningWorkers[w.id] = job;
599
+ try {
600
+ resolve(await w[action].apply(this, [...payload, job.id]));
601
+ } catch (err) {
602
+ reject(err);
603
+ } finally {
604
+ delete runningWorkers[w.id];
605
+ dequeue();
606
+ }
607
+ });
608
+ log2(`[${id}]: Add ${job.id} to JobQueue`);
609
+ log2(`[${id}]: JobQueue length=${jobQueue.length}`);
610
+ dequeue();
576
611
  });
577
- log$1(`[${id}]: Add ${job.id} to JobQueue`);
578
- log$1(`[${id}]: JobQueue length=${jobQueue.length}`);
579
- dequeue();
580
- });
581
- const addWorker = (w) => {
582
- workers[w.id] = w;
583
- log$1(`[${id}]: Add ${w.id}`);
584
- log$1(`[${id}]: Number of workers=${getNumWorkers()}`);
585
- dequeue();
586
- return w.id;
612
+ const addWorker = (w) => {
613
+ workers[w.id] = w;
614
+ log2(`[${id}]: Add ${w.id}`);
615
+ log2(`[${id}]: Number of workers=${getNumWorkers()}`);
616
+ dequeue();
617
+ return w.id;
618
+ };
619
+ const addJob = async (action, ...payload) => {
620
+ if (getNumWorkers() === 0) {
621
+ throw Error(`[${id}]: You need to have at least one worker before adding jobs`);
622
+ }
623
+ return queue(action, payload);
624
+ };
625
+ const terminate = async () => {
626
+ Object.keys(workers).forEach(async (wid) => {
627
+ await workers[wid].terminate();
628
+ });
629
+ jobQueue = [];
630
+ };
631
+ return {
632
+ addWorker,
633
+ addJob,
634
+ terminate,
635
+ getQueueLen,
636
+ getNumWorkers
637
+ };
587
638
  };
588
- const addJob = async (action, ...payload) => {
589
- if (getNumWorkers() === 0) {
590
- throw Error(`[${id}]: You need to have at least one worker before adding jobs`);
639
+ return createScheduler;
640
+ }
641
+ function commonjsRequire(path) {
642
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
643
+ }
644
+ var getEnvironment;
645
+ var hasRequiredGetEnvironment;
646
+ function requireGetEnvironment() {
647
+ if (hasRequiredGetEnvironment) return getEnvironment;
648
+ hasRequiredGetEnvironment = 1;
649
+ getEnvironment = (key) => {
650
+ const env = {};
651
+ if (typeof WorkerGlobalScope !== "undefined") {
652
+ env.type = "webworker";
653
+ } else if (typeof document === "object") {
654
+ env.type = "browser";
655
+ } else if (typeof process === "object" && typeof commonjsRequire === "function") {
656
+ env.type = "node";
591
657
  }
592
- return queue(action, payload);
658
+ if (typeof key === "undefined") {
659
+ return env;
660
+ }
661
+ return env[key];
593
662
  };
594
- const terminate = async () => {
595
- Object.keys(workers).forEach(async (wid) => {
596
- await workers[wid].terminate();
663
+ return getEnvironment;
664
+ }
665
+ var resolvePaths;
666
+ var hasRequiredResolvePaths;
667
+ function requireResolvePaths() {
668
+ if (hasRequiredResolvePaths) return resolvePaths;
669
+ hasRequiredResolvePaths = 1;
670
+ const isBrowser = requireGetEnvironment()("type") === "browser";
671
+ const resolveURL = isBrowser ? (s) => new URL(s, window.location.href).href : (s) => s;
672
+ resolvePaths = (options) => {
673
+ const opts = { ...options };
674
+ ["corePath", "workerPath", "langPath"].forEach((key) => {
675
+ if (options[key]) {
676
+ opts[key] = resolveURL(opts[key]);
677
+ }
597
678
  });
598
- jobQueue = [];
679
+ return opts;
599
680
  };
600
- return {
601
- addWorker,
602
- addJob,
603
- terminate,
604
- getQueueLen,
605
- getNumWorkers
606
- };
607
- };
608
- function commonjsRequire(path) {
609
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
681
+ return resolvePaths;
610
682
  }
611
- function isElectron$1() {
612
- if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
613
- return true;
614
- }
615
- if (typeof process !== "undefined" && typeof process.versions === "object" && !!process.versions.electron) {
616
- return true;
617
- }
618
- if (typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent.indexOf("Electron") >= 0) {
619
- return true;
620
- }
621
- return false;
683
+ var OEM;
684
+ var hasRequiredOEM;
685
+ function requireOEM() {
686
+ if (hasRequiredOEM) return OEM;
687
+ hasRequiredOEM = 1;
688
+ OEM = {
689
+ TESSERACT_ONLY: 0,
690
+ LSTM_ONLY: 1,
691
+ TESSERACT_LSTM_COMBINED: 2,
692
+ DEFAULT: 3
693
+ };
694
+ return OEM;
622
695
  }
623
- var isElectron_1 = isElectron$1;
624
- const isElectron = isElectron_1;
625
- var getEnvironment = (key) => {
626
- const env = {};
627
- if (typeof WorkerGlobalScope !== "undefined") {
628
- env.type = "webworker";
629
- } else if (isElectron()) {
630
- env.type = "electron";
631
- } else if (typeof document === "object") {
632
- env.type = "browser";
633
- } else if (typeof process === "object" && typeof commonjsRequire === "function") {
634
- env.type = "node";
635
- }
636
- if (typeof key === "undefined") {
637
- return env;
638
- }
639
- return env[key];
696
+ const version = "6.0.0";
697
+ const require$$0 = {
698
+ version
640
699
  };
641
- const isBrowser = getEnvironment("type") === "browser";
642
- const resolveURL = isBrowser ? (s) => new URL(s, window.location.href).href : (s) => s;
643
- var resolvePaths$1 = (options) => {
644
- const opts = { ...options };
645
- ["corePath", "workerPath", "langPath"].forEach((key) => {
646
- if (options[key]) {
647
- opts[key] = resolveURL(opts[key]);
700
+ var defaultOptions;
701
+ var hasRequiredDefaultOptions$1;
702
+ function requireDefaultOptions$1() {
703
+ if (hasRequiredDefaultOptions$1) return defaultOptions;
704
+ hasRequiredDefaultOptions$1 = 1;
705
+ defaultOptions = {
706
+ /*
707
+ * Use BlobURL for worker script by default
708
+ * TODO: remove this option
709
+ *
710
+ */
711
+ workerBlobURL: true,
712
+ logger: () => {
648
713
  }
649
- });
650
- return opts;
651
- };
652
- var circularize$1 = (page) => {
653
- const blocks = [];
654
- const paragraphs = [];
655
- const lines = [];
656
- const words = [];
657
- const symbols = [];
658
- if (page.blocks) {
659
- page.blocks.forEach((block) => {
660
- block.paragraphs.forEach((paragraph) => {
661
- paragraph.lines.forEach((line) => {
662
- line.words.forEach((word) => {
663
- word.symbols.forEach((sym) => {
664
- symbols.push({
665
- ...sym,
666
- page,
667
- block,
668
- paragraph,
669
- line,
670
- word
671
- });
672
- });
673
- words.push({
674
- ...word,
675
- page,
676
- block,
677
- paragraph,
678
- line
679
- });
680
- });
681
- lines.push({
682
- ...line,
683
- page,
684
- block,
685
- paragraph
686
- });
687
- });
688
- paragraphs.push({
689
- ...paragraph,
690
- page,
691
- block
692
- });
693
- });
694
- blocks.push({
695
- ...block,
696
- page
714
+ };
715
+ return defaultOptions;
716
+ }
717
+ var defaultOptions_1;
718
+ var hasRequiredDefaultOptions;
719
+ function requireDefaultOptions() {
720
+ if (hasRequiredDefaultOptions) return defaultOptions_1;
721
+ hasRequiredDefaultOptions = 1;
722
+ const version2 = require$$0.version;
723
+ const defaultOptions2 = requireDefaultOptions$1();
724
+ defaultOptions_1 = {
725
+ ...defaultOptions2,
726
+ workerPath: `https://cdn.jsdelivr.net/npm/tesseract.js@v${version2}/dist/worker.min.js`
727
+ };
728
+ return defaultOptions_1;
729
+ }
730
+ var spawnWorker;
731
+ var hasRequiredSpawnWorker;
732
+ function requireSpawnWorker() {
733
+ if (hasRequiredSpawnWorker) return spawnWorker;
734
+ hasRequiredSpawnWorker = 1;
735
+ spawnWorker = ({ workerPath, workerBlobURL }) => {
736
+ let worker;
737
+ if (Blob && URL && workerBlobURL) {
738
+ const blob = new Blob([`importScripts("${workerPath}");`], {
739
+ type: "application/javascript"
697
740
  });
698
- });
699
- }
700
- return {
701
- ...page,
702
- blocks,
703
- paragraphs,
704
- lines,
705
- words,
706
- symbols
741
+ worker = new Worker(URL.createObjectURL(blob));
742
+ } else {
743
+ worker = new Worker(workerPath);
744
+ }
745
+ return worker;
707
746
  };
708
- };
709
- var OEM$2 = {
710
- TESSERACT_ONLY: 0,
711
- LSTM_ONLY: 1,
712
- TESSERACT_LSTM_COMBINED: 2,
713
- DEFAULT: 3
714
- };
715
- const name = "tesseract.js";
716
- const version$1 = "5.1.0";
717
- const description = "Pure Javascript Multilingual OCR";
718
- const main = "src/index.js";
719
- const types = "src/index.d.ts";
720
- const unpkg = "dist/tesseract.min.js";
721
- const jsdelivr = "dist/tesseract.min.js";
722
- const scripts = {
723
- start: "node scripts/server.js",
724
- build: "rimraf dist && webpack --config scripts/webpack.config.prod.js && rollup -c scripts/rollup.esm.mjs",
725
- "profile:tesseract": "webpack-bundle-analyzer dist/tesseract-stats.json",
726
- "profile:worker": "webpack-bundle-analyzer dist/worker-stats.json",
727
- prepublishOnly: "npm run build",
728
- wait: "rimraf dist && wait-on http://localhost:3000/dist/tesseract.min.js",
729
- test: "npm-run-all -p -r start test:all",
730
- "test:all": "npm-run-all wait test:browser:* test:node:all",
731
- "test:node": "nyc mocha --exit --bail --require ./scripts/test-helper.js",
732
- "test:node:all": "npm run test:node -- ./tests/*.test.js",
733
- "test:browser-tpl": "mocha-headless-chrome -a incognito -a no-sandbox -a disable-setuid-sandbox -a disable-logging -t 300000",
734
- "test:browser:detect": "npm run test:browser-tpl -- -f ./tests/detect.test.html",
735
- "test:browser:recognize": "npm run test:browser-tpl -- -f ./tests/recognize.test.html",
736
- "test:browser:scheduler": "npm run test:browser-tpl -- -f ./tests/scheduler.test.html",
737
- "test:browser:FS": "npm run test:browser-tpl -- -f ./tests/FS.test.html",
738
- lint: "eslint src",
739
- "lint:fix": "eslint --fix src",
740
- postinstall: "opencollective-postinstall || true"
741
- };
742
- const browser$1 = {
743
- "./src/worker/node/index.js": "./src/worker/browser/index.js"
744
- };
745
- const author = "";
746
- const contributors = [
747
- "jeromewu"
748
- ];
749
- const license = "Apache-2.0";
750
- const devDependencies = {
751
- "@babel/core": "^7.21.4",
752
- "@babel/eslint-parser": "^7.21.3",
753
- "@babel/preset-env": "^7.21.4",
754
- "@rollup/plugin-commonjs": "^24.1.0",
755
- acorn: "^8.8.2",
756
- "babel-loader": "^9.1.2",
757
- buffer: "^6.0.3",
758
- cors: "^2.8.5",
759
- eslint: "^7.32.0",
760
- "eslint-config-airbnb-base": "^14.2.1",
761
- "eslint-plugin-import": "^2.27.5",
762
- "expect.js": "^0.3.1",
763
- express: "^4.18.2",
764
- mocha: "^10.2.0",
765
- "mocha-headless-chrome": "^4.0.0",
766
- "npm-run-all": "^4.1.5",
767
- nyc: "^15.1.0",
768
- rimraf: "^5.0.0",
769
- rollup: "^3.20.7",
770
- "wait-on": "^7.0.1",
771
- webpack: "^5.79.0",
772
- "webpack-bundle-analyzer": "^4.8.0",
773
- "webpack-cli": "^5.0.1",
774
- "webpack-dev-middleware": "^6.0.2",
775
- "rollup-plugin-sourcemaps": "^0.6.3"
776
- };
777
- const dependencies = {
778
- "bmp-js": "^0.1.0",
779
- "idb-keyval": "^6.2.0",
780
- "is-electron": "^2.2.2",
781
- "is-url": "^1.2.4",
782
- "node-fetch": "^2.6.9",
783
- "opencollective-postinstall": "^2.0.3",
784
- "regenerator-runtime": "^0.13.3",
785
- "tesseract.js-core": "^5.1.0",
786
- "wasm-feature-detect": "^1.2.11",
787
- zlibjs: "^0.3.1"
788
- };
789
- const overrides = {
790
- "@rollup/pluginutils": "^5.0.2"
791
- };
792
- const repository = {
793
- type: "git",
794
- url: "https://github.com/naptha/tesseract.js.git"
795
- };
796
- const bugs = {
797
- url: "https://github.com/naptha/tesseract.js/issues"
798
- };
799
- const homepage = "https://github.com/naptha/tesseract.js";
800
- const collective = {
801
- type: "opencollective",
802
- url: "https://opencollective.com/tesseractjs"
803
- };
804
- const require$$0 = {
805
- name,
806
- version: version$1,
807
- description,
808
- main,
809
- types,
810
- unpkg,
811
- jsdelivr,
812
- scripts,
813
- browser: browser$1,
814
- author,
815
- contributors,
816
- license,
817
- devDependencies,
818
- dependencies,
819
- overrides,
820
- repository,
821
- bugs,
822
- homepage,
823
- collective
824
- };
825
- var defaultOptions$3 = {
826
- /*
827
- * Use BlobURL for worker script by default
828
- * TODO: remove this option
829
- *
830
- */
831
- workerBlobURL: true,
832
- logger: () => {
833
- }
834
- };
835
- const version = require$$0.version;
836
- const defaultOptions$2 = defaultOptions$3;
837
- var defaultOptions_1 = {
838
- ...defaultOptions$2,
839
- workerPath: `https://cdn.jsdelivr.net/npm/tesseract.js@v${version}/dist/worker.min.js`
840
- };
841
- var spawnWorker$2 = ({ workerPath, workerBlobURL }) => {
842
- let worker;
843
- if (Blob && URL && workerBlobURL) {
844
- const blob = new Blob([`importScripts("${workerPath}");`], {
845
- type: "application/javascript"
846
- });
847
- worker = new Worker(URL.createObjectURL(blob));
848
- } else {
849
- worker = new Worker(workerPath);
850
- }
851
- return worker;
852
- };
853
- var terminateWorker$2 = (worker) => {
854
- worker.terminate();
855
- };
856
- var onMessage$2 = (worker, handler) => {
857
- worker.onmessage = ({ data }) => {
858
- handler(data);
747
+ return spawnWorker;
748
+ }
749
+ var terminateWorker;
750
+ var hasRequiredTerminateWorker;
751
+ function requireTerminateWorker() {
752
+ if (hasRequiredTerminateWorker) return terminateWorker;
753
+ hasRequiredTerminateWorker = 1;
754
+ terminateWorker = (worker) => {
755
+ worker.terminate();
859
756
  };
860
- };
861
- var send$2 = async (worker, packet) => {
862
- worker.postMessage(packet);
863
- };
864
- const readFromBlobOrFile = (blob) => new Promise((resolve, reject) => {
865
- const fileReader = new FileReader();
866
- fileReader.onload = () => {
867
- resolve(fileReader.result);
757
+ return terminateWorker;
758
+ }
759
+ var onMessage;
760
+ var hasRequiredOnMessage;
761
+ function requireOnMessage() {
762
+ if (hasRequiredOnMessage) return onMessage;
763
+ hasRequiredOnMessage = 1;
764
+ onMessage = (worker, handler) => {
765
+ worker.onmessage = ({ data }) => {
766
+ handler(data);
767
+ };
868
768
  };
869
- fileReader.onerror = ({ target: { error: { code } } }) => {
870
- reject(Error(`File could not be read! Code=${code}`));
769
+ return onMessage;
770
+ }
771
+ var send;
772
+ var hasRequiredSend;
773
+ function requireSend() {
774
+ if (hasRequiredSend) return send;
775
+ hasRequiredSend = 1;
776
+ send = async (worker, packet) => {
777
+ worker.postMessage(packet);
871
778
  };
872
- fileReader.readAsArrayBuffer(blob);
873
- });
874
- const loadImage$2 = async (image) => {
875
- let data = image;
876
- if (typeof image === "undefined") {
877
- return "undefined";
878
- }
879
- if (typeof image === "string") {
880
- if (/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(image)) {
881
- data = atob(image.split(",")[1]).split("").map((c) => c.charCodeAt(0));
882
- } else {
883
- const resp = await fetch(image);
884
- data = await resp.arrayBuffer();
885
- }
886
- } else if (typeof HTMLElement !== "undefined" && image instanceof HTMLElement) {
887
- if (image.tagName === "IMG") {
888
- data = await loadImage$2(image.src);
889
- }
890
- if (image.tagName === "VIDEO") {
891
- data = await loadImage$2(image.poster);
779
+ return send;
780
+ }
781
+ var loadImage_1;
782
+ var hasRequiredLoadImage;
783
+ function requireLoadImage() {
784
+ if (hasRequiredLoadImage) return loadImage_1;
785
+ hasRequiredLoadImage = 1;
786
+ const readFromBlobOrFile = (blob) => new Promise((resolve, reject) => {
787
+ const fileReader = new FileReader();
788
+ fileReader.onload = () => {
789
+ resolve(fileReader.result);
790
+ };
791
+ fileReader.onerror = ({ target: { error: { code } } }) => {
792
+ reject(Error(`File could not be read! Code=${code}`));
793
+ };
794
+ fileReader.readAsArrayBuffer(blob);
795
+ });
796
+ const loadImage = async (image) => {
797
+ let data = image;
798
+ if (typeof image === "undefined") {
799
+ return "undefined";
892
800
  }
893
- if (image.tagName === "CANVAS") {
894
- await new Promise((resolve) => {
895
- image.toBlob(async (blob) => {
896
- data = await readFromBlobOrFile(blob);
897
- resolve();
801
+ if (typeof image === "string") {
802
+ if (/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(image)) {
803
+ data = atob(image.split(",")[1]).split("").map((c) => c.charCodeAt(0));
804
+ } else {
805
+ const resp = await fetch(image);
806
+ data = await resp.arrayBuffer();
807
+ }
808
+ } else if (typeof HTMLElement !== "undefined" && image instanceof HTMLElement) {
809
+ if (image.tagName === "IMG") {
810
+ data = await loadImage(image.src);
811
+ }
812
+ if (image.tagName === "VIDEO") {
813
+ data = await loadImage(image.poster);
814
+ }
815
+ if (image.tagName === "CANVAS") {
816
+ await new Promise((resolve) => {
817
+ image.toBlob(async (blob) => {
818
+ data = await readFromBlobOrFile(blob);
819
+ resolve();
820
+ });
898
821
  });
899
- });
822
+ }
823
+ } else if (typeof OffscreenCanvas !== "undefined" && image instanceof OffscreenCanvas) {
824
+ const blob = await image.convertToBlob();
825
+ data = await readFromBlobOrFile(blob);
826
+ } else if (image instanceof File || image instanceof Blob) {
827
+ data = await readFromBlobOrFile(image);
900
828
  }
901
- } else if (typeof OffscreenCanvas !== "undefined" && image instanceof OffscreenCanvas) {
902
- const blob = await image.convertToBlob();
903
- data = await readFromBlobOrFile(blob);
904
- } else if (image instanceof File || image instanceof Blob) {
905
- data = await readFromBlobOrFile(image);
906
- }
907
- return new Uint8Array(data);
908
- };
909
- var loadImage_1 = loadImage$2;
910
- const defaultOptions$1 = defaultOptions_1;
911
- const spawnWorker$1 = spawnWorker$2;
912
- const terminateWorker$1 = terminateWorker$2;
913
- const onMessage$1 = onMessage$2;
914
- const send$1 = send$2;
915
- const loadImage$1 = loadImage_1;
916
- var browser = {
917
- defaultOptions: defaultOptions$1,
918
- spawnWorker: spawnWorker$1,
919
- terminateWorker: terminateWorker$1,
920
- onMessage: onMessage$1,
921
- send: send$1,
922
- loadImage: loadImage$1
923
- };
924
- const resolvePaths = resolvePaths$1;
925
- const circularize = circularize$1;
926
- const createJob = createJob$2;
927
- const { log } = log$2;
928
- const getId = getId$3;
929
- const OEM$1 = OEM$2;
930
- const {
931
- defaultOptions,
932
- spawnWorker,
933
- terminateWorker,
934
- onMessage,
935
- loadImage,
936
- send
937
- } = browser;
938
- let workerCounter = 0;
939
- var createWorker$2 = async (langs = "eng", oem = OEM$1.LSTM_ONLY, _options = {}, config = {}) => {
940
- const id = getId("Worker", workerCounter);
941
- const {
942
- logger,
943
- errorHandler,
944
- ...options
945
- } = resolvePaths({
946
- ...defaultOptions,
947
- ..._options
948
- });
949
- const resolves = {};
950
- const rejects = {};
951
- const currentLangs = typeof langs === "string" ? langs.split("+") : langs;
952
- let currentOem = oem;
953
- let currentConfig = config;
954
- const lstmOnlyCore = [OEM$1.DEFAULT, OEM$1.LSTM_ONLY].includes(oem) && !options.legacyCore;
955
- let workerResReject;
956
- let workerResResolve;
957
- const workerRes = new Promise((resolve, reject) => {
958
- workerResResolve = resolve;
959
- workerResReject = reject;
960
- });
961
- const workerError = (event) => {
962
- workerResReject(event.message);
963
- };
964
- let worker = spawnWorker(options);
965
- worker.onerror = workerError;
966
- workerCounter += 1;
967
- const setResolve = (promiseId, res) => {
968
- resolves[promiseId] = res;
829
+ return new Uint8Array(data);
969
830
  };
970
- const setReject = (promiseId, rej) => {
971
- rejects[promiseId] = rej;
831
+ loadImage_1 = loadImage;
832
+ return loadImage_1;
833
+ }
834
+ var browser;
835
+ var hasRequiredBrowser;
836
+ function requireBrowser() {
837
+ if (hasRequiredBrowser) return browser;
838
+ hasRequiredBrowser = 1;
839
+ const defaultOptions2 = requireDefaultOptions();
840
+ const spawnWorker2 = requireSpawnWorker();
841
+ const terminateWorker2 = requireTerminateWorker();
842
+ const onMessage2 = requireOnMessage();
843
+ const send2 = requireSend();
844
+ const loadImage = requireLoadImage();
845
+ browser = {
846
+ defaultOptions: defaultOptions2,
847
+ spawnWorker: spawnWorker2,
848
+ terminateWorker: terminateWorker2,
849
+ onMessage: onMessage2,
850
+ send: send2,
851
+ loadImage
972
852
  };
973
- const startJob = ({ id: jobId, action, payload }) => new Promise((resolve, reject) => {
974
- log(`[${id}]: Start ${jobId}, action=${action}`);
975
- const promiseId = `${action}-${jobId}`;
976
- setResolve(promiseId, resolve);
977
- setReject(promiseId, reject);
978
- send(worker, {
979
- workerId: id,
980
- jobId,
981
- action,
982
- payload
853
+ return browser;
854
+ }
855
+ var createWorker;
856
+ var hasRequiredCreateWorker;
857
+ function requireCreateWorker() {
858
+ if (hasRequiredCreateWorker) return createWorker;
859
+ hasRequiredCreateWorker = 1;
860
+ const resolvePaths2 = requireResolvePaths();
861
+ const createJob2 = requireCreateJob();
862
+ const { log: log2 } = requireLog();
863
+ const getId2 = requireGetId();
864
+ const OEM2 = requireOEM();
865
+ const {
866
+ defaultOptions: defaultOptions2,
867
+ spawnWorker: spawnWorker2,
868
+ terminateWorker: terminateWorker2,
869
+ onMessage: onMessage2,
870
+ loadImage,
871
+ send: send2
872
+ } = requireBrowser();
873
+ let workerCounter = 0;
874
+ createWorker = async (langs = "eng", oem = OEM2.LSTM_ONLY, _options = {}, config = {}) => {
875
+ const id = getId2("Worker", workerCounter);
876
+ const {
877
+ logger,
878
+ errorHandler,
879
+ ...options
880
+ } = resolvePaths2({
881
+ ...defaultOptions2,
882
+ ..._options
983
883
  });
984
- });
985
- const load = () => console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)");
986
- const loadInternal = (jobId) => startJob(createJob({
987
- id: jobId,
988
- action: "load",
989
- payload: { options: { lstmOnly: lstmOnlyCore, corePath: options.corePath, logging: options.logging } }
990
- }));
991
- const writeText = (path, text, jobId) => startJob(createJob({
992
- id: jobId,
993
- action: "FS",
994
- payload: { method: "writeFile", args: [path, text] }
995
- }));
996
- const readText = (path, jobId) => startJob(createJob({
997
- id: jobId,
998
- action: "FS",
999
- payload: { method: "readFile", args: [path, { encoding: "utf8" }] }
1000
- }));
1001
- const removeFile = (path, jobId) => startJob(createJob({
1002
- id: jobId,
1003
- action: "FS",
1004
- payload: { method: "unlink", args: [path] }
1005
- }));
1006
- const FS = (method, args, jobId) => startJob(createJob({
1007
- id: jobId,
1008
- action: "FS",
1009
- payload: { method, args }
1010
- }));
1011
- const loadLanguage = () => console.warn("`loadLanguage` is depreciated and should be removed from code (workers now come with language pre-loaded)");
1012
- const loadLanguageInternal = (_langs, jobId) => startJob(createJob({
1013
- id: jobId,
1014
- action: "loadLanguage",
1015
- payload: {
1016
- langs: _langs,
1017
- options: {
1018
- langPath: options.langPath,
1019
- dataPath: options.dataPath,
1020
- cachePath: options.cachePath,
1021
- cacheMethod: options.cacheMethod,
1022
- gzip: options.gzip,
1023
- lstmOnly: [OEM$1.LSTM_ONLY, OEM$1.TESSERACT_LSTM_COMBINED].includes(currentOem) && !options.legacyLang
884
+ const promises = {};
885
+ const currentLangs = typeof langs === "string" ? langs.split("+") : langs;
886
+ let currentOem = oem;
887
+ let currentConfig = config;
888
+ const lstmOnlyCore = [OEM2.DEFAULT, OEM2.LSTM_ONLY].includes(oem) && !options.legacyCore;
889
+ let workerResReject;
890
+ let workerResResolve;
891
+ const workerRes = new Promise((resolve, reject) => {
892
+ workerResResolve = resolve;
893
+ workerResReject = reject;
894
+ });
895
+ const workerError = (event) => {
896
+ workerResReject(event.message);
897
+ };
898
+ let worker = spawnWorker2(options);
899
+ worker.onerror = workerError;
900
+ workerCounter += 1;
901
+ const startJob = ({ id: jobId, action, payload }) => new Promise((resolve, reject) => {
902
+ log2(`[${id}]: Start ${jobId}, action=${action}`);
903
+ const promiseId = `${action}-${jobId}`;
904
+ promises[promiseId] = { resolve, reject };
905
+ send2(worker, {
906
+ workerId: id,
907
+ jobId,
908
+ action,
909
+ payload
910
+ });
911
+ });
912
+ const load = () => console.warn("`load` is depreciated and should be removed from code (workers now come pre-loaded)");
913
+ const loadInternal = (jobId) => startJob(createJob2({
914
+ id: jobId,
915
+ action: "load",
916
+ payload: { options: { lstmOnly: lstmOnlyCore, corePath: options.corePath, logging: options.logging } }
917
+ }));
918
+ const writeText = (path, text, jobId) => startJob(createJob2({
919
+ id: jobId,
920
+ action: "FS",
921
+ payload: { method: "writeFile", args: [path, text] }
922
+ }));
923
+ const readText = (path, jobId) => startJob(createJob2({
924
+ id: jobId,
925
+ action: "FS",
926
+ payload: { method: "readFile", args: [path, { encoding: "utf8" }] }
927
+ }));
928
+ const removeFile = (path, jobId) => startJob(createJob2({
929
+ id: jobId,
930
+ action: "FS",
931
+ payload: { method: "unlink", args: [path] }
932
+ }));
933
+ const FS = (method, args, jobId) => startJob(createJob2({
934
+ id: jobId,
935
+ action: "FS",
936
+ payload: { method, args }
937
+ }));
938
+ const loadLanguageInternal = (_langs, jobId) => startJob(createJob2({
939
+ id: jobId,
940
+ action: "loadLanguage",
941
+ payload: {
942
+ langs: _langs,
943
+ options: {
944
+ langPath: options.langPath,
945
+ dataPath: options.dataPath,
946
+ cachePath: options.cachePath,
947
+ cacheMethod: options.cacheMethod,
948
+ gzip: options.gzip,
949
+ lstmOnly: [OEM2.DEFAULT, OEM2.LSTM_ONLY].includes(currentOem) && !options.legacyLang
950
+ }
1024
951
  }
1025
- }
1026
- }));
1027
- const initialize = () => console.warn("`initialize` is depreciated and should be removed from code (workers now come pre-initialized)");
1028
- const initializeInternal = (_langs, _oem, _config, jobId) => startJob(createJob({
1029
- id: jobId,
1030
- action: "initialize",
1031
- payload: { langs: _langs, oem: _oem, config: _config }
1032
- }));
1033
- const reinitialize = (langs2 = "eng", oem2, config2, jobId) => {
1034
- if (lstmOnlyCore && [OEM$1.TESSERACT_ONLY, OEM$1.TESSERACT_LSTM_COMBINED].includes(oem2)) throw Error("Legacy model requested but code missing.");
1035
- const _oem = oem2 || currentOem;
1036
- currentOem = _oem;
1037
- const _config = config2 || currentConfig;
1038
- currentConfig = _config;
1039
- const langsArr = typeof langs2 === "string" ? langs2.split("+") : langs2;
1040
- const _langs = langsArr.filter((x) => !currentLangs.includes(x));
1041
- currentLangs.push(..._langs);
1042
- if (_langs.length > 0) {
1043
- return loadLanguageInternal(_langs, jobId).then(() => initializeInternal(langs2, _oem, _config, jobId));
1044
- }
1045
- return initializeInternal(langs2, _oem, _config, jobId);
1046
- };
1047
- const setParameters = (params = {}, jobId) => startJob(createJob({
1048
- id: jobId,
1049
- action: "setParameters",
1050
- payload: { params }
1051
- }));
1052
- const recognize2 = async (image, opts = {}, output = {
1053
- blocks: true,
1054
- text: true,
1055
- hocr: true,
1056
- tsv: true
1057
- }, jobId) => startJob(createJob({
1058
- id: jobId,
1059
- action: "recognize",
1060
- payload: { image: await loadImage(image), options: opts, output }
1061
- }));
1062
- const getPDF = (title = "Tesseract OCR Result", textonly = false, jobId) => {
1063
- return startJob(createJob({
952
+ }));
953
+ const initializeInternal = (_langs, _oem, _config, jobId) => startJob(createJob2({
1064
954
  id: jobId,
1065
- action: "getPDF",
1066
- payload: { title, textonly }
955
+ action: "initialize",
956
+ payload: { langs: _langs, oem: _oem, config: _config }
1067
957
  }));
1068
- };
1069
- const detect2 = async (image, jobId) => {
1070
- if (lstmOnlyCore) throw Error("`worker.detect` requires Legacy model, which was not loaded.");
1071
- return startJob(createJob({
958
+ const reinitialize = (langs2 = "eng", oem2, config2, jobId) => {
959
+ if (lstmOnlyCore && [OEM2.TESSERACT_ONLY, OEM2.TESSERACT_LSTM_COMBINED].includes(oem2)) throw Error("Legacy model requested but code missing.");
960
+ const _oem = oem2 || currentOem;
961
+ currentOem = _oem;
962
+ const _config = config2 || currentConfig;
963
+ currentConfig = _config;
964
+ const langsArr = typeof langs2 === "string" ? langs2.split("+") : langs2;
965
+ const _langs = langsArr.filter((x) => !currentLangs.includes(x));
966
+ currentLangs.push(..._langs);
967
+ if (_langs.length > 0) {
968
+ return loadLanguageInternal(_langs, jobId).then(() => initializeInternal(langs2, _oem, _config, jobId));
969
+ }
970
+ return initializeInternal(langs2, _oem, _config, jobId);
971
+ };
972
+ const setParameters = (params = {}, jobId) => startJob(createJob2({
1072
973
  id: jobId,
1073
- action: "detect",
1074
- payload: { image: await loadImage(image) }
974
+ action: "setParameters",
975
+ payload: { params }
1075
976
  }));
1076
- };
1077
- const terminate = async () => {
1078
- if (worker !== null) {
1079
- terminateWorker(worker);
1080
- worker = null;
1081
- }
1082
- return Promise.resolve();
1083
- };
1084
- onMessage(worker, ({
1085
- workerId,
1086
- jobId,
1087
- status,
1088
- action,
1089
- data
1090
- }) => {
1091
- const promiseId = `${action}-${jobId}`;
1092
- if (status === "resolve") {
1093
- log(`[${workerId}]: Complete ${jobId}`);
1094
- let d = data;
1095
- if (action === "recognize") {
1096
- d = circularize(data);
1097
- } else if (action === "getPDF") {
1098
- d = Array.from({ ...data, length: Object.keys(data).length });
977
+ const recognize = async (image, opts = {}, output = {
978
+ text: true
979
+ }, jobId) => startJob(createJob2({
980
+ id: jobId,
981
+ action: "recognize",
982
+ payload: { image: await loadImage(image), options: opts, output }
983
+ }));
984
+ const detect = async (image, jobId) => {
985
+ if (lstmOnlyCore) throw Error("`worker.detect` requires Legacy model, which was not loaded.");
986
+ return startJob(createJob2({
987
+ id: jobId,
988
+ action: "detect",
989
+ payload: { image: await loadImage(image) }
990
+ }));
991
+ };
992
+ const terminate = async () => {
993
+ if (worker !== null) {
994
+ terminateWorker2(worker);
995
+ worker = null;
1099
996
  }
1100
- resolves[promiseId]({ jobId, data: d });
1101
- } else if (status === "reject") {
1102
- rejects[promiseId](data);
1103
- if (action === "load") workerResReject(data);
1104
- if (errorHandler) {
1105
- errorHandler(data);
1106
- } else {
1107
- throw Error(data);
997
+ return Promise.resolve();
998
+ };
999
+ onMessage2(worker, ({
1000
+ workerId,
1001
+ jobId,
1002
+ status,
1003
+ action,
1004
+ data
1005
+ }) => {
1006
+ const promiseId = `${action}-${jobId}`;
1007
+ if (status === "resolve") {
1008
+ log2(`[${workerId}]: Complete ${jobId}`);
1009
+ promises[promiseId].resolve({ jobId, data });
1010
+ delete promises[promiseId];
1011
+ } else if (status === "reject") {
1012
+ promises[promiseId].reject(data);
1013
+ delete promises[promiseId];
1014
+ if (action === "load") workerResReject(data);
1015
+ if (errorHandler) {
1016
+ errorHandler(data);
1017
+ } else {
1018
+ throw Error(data);
1019
+ }
1020
+ } else if (status === "progress") {
1021
+ logger({ ...data, userJobId: jobId });
1108
1022
  }
1109
- } else if (status === "progress") {
1110
- logger({ ...data, userJobId: jobId });
1111
- }
1112
- });
1113
- const resolveObj = {
1114
- id,
1115
- worker,
1116
- setResolve,
1117
- setReject,
1118
- load,
1119
- writeText,
1120
- readText,
1121
- removeFile,
1122
- FS,
1123
- loadLanguage,
1124
- initialize,
1125
- reinitialize,
1126
- setParameters,
1127
- recognize: recognize2,
1128
- getPDF,
1129
- detect: detect2,
1130
- terminate
1023
+ });
1024
+ const resolveObj = {
1025
+ id,
1026
+ worker,
1027
+ load,
1028
+ writeText,
1029
+ readText,
1030
+ removeFile,
1031
+ FS,
1032
+ reinitialize,
1033
+ setParameters,
1034
+ recognize,
1035
+ detect,
1036
+ terminate
1037
+ };
1038
+ loadInternal().then(() => loadLanguageInternal(langs)).then(() => initializeInternal(langs, oem, config)).then(() => workerResResolve(resolveObj)).catch(() => {
1039
+ });
1040
+ return workerRes;
1131
1041
  };
1132
- loadInternal().then(() => loadLanguageInternal(langs)).then(() => initializeInternal(langs, oem, config)).then(() => workerResResolve(resolveObj)).catch(() => {
1133
- });
1134
- return workerRes;
1135
- };
1136
- const createWorker$1 = createWorker$2;
1137
- const recognize = async (image, langs, options) => {
1138
- const worker = await createWorker$1(langs, 1, options);
1139
- return worker.recognize(image).finally(async () => {
1140
- await worker.terminate();
1141
- });
1142
- };
1143
- const detect = async (image, options) => {
1144
- const worker = await createWorker$1("osd", 0, options);
1145
- return worker.detect(image).finally(async () => {
1146
- await worker.terminate();
1147
- });
1148
- };
1149
- var Tesseract$1 = {
1150
- recognize,
1151
- detect
1152
- };
1153
- var languages$1 = {
1154
- AFR: "afr",
1155
- AMH: "amh",
1156
- ARA: "ara",
1157
- ASM: "asm",
1158
- AZE: "aze",
1159
- AZE_CYRL: "aze_cyrl",
1160
- BEL: "bel",
1161
- BEN: "ben",
1162
- BOD: "bod",
1163
- BOS: "bos",
1164
- BUL: "bul",
1165
- CAT: "cat",
1166
- CEB: "ceb",
1167
- CES: "ces",
1168
- CHI_SIM: "chi_sim",
1169
- CHI_TRA: "chi_tra",
1170
- CHR: "chr",
1171
- CYM: "cym",
1172
- DAN: "dan",
1173
- DEU: "deu",
1174
- DZO: "dzo",
1175
- ELL: "ell",
1176
- ENG: "eng",
1177
- ENM: "enm",
1178
- EPO: "epo",
1179
- EST: "est",
1180
- EUS: "eus",
1181
- FAS: "fas",
1182
- FIN: "fin",
1183
- FRA: "fra",
1184
- FRK: "frk",
1185
- FRM: "frm",
1186
- GLE: "gle",
1187
- GLG: "glg",
1188
- GRC: "grc",
1189
- GUJ: "guj",
1190
- HAT: "hat",
1191
- HEB: "heb",
1192
- HIN: "hin",
1193
- HRV: "hrv",
1194
- HUN: "hun",
1195
- IKU: "iku",
1196
- IND: "ind",
1197
- ISL: "isl",
1198
- ITA: "ita",
1199
- ITA_OLD: "ita_old",
1200
- JAV: "jav",
1201
- JPN: "jpn",
1202
- KAN: "kan",
1203
- KAT: "kat",
1204
- KAT_OLD: "kat_old",
1205
- KAZ: "kaz",
1206
- KHM: "khm",
1207
- KIR: "kir",
1208
- KOR: "kor",
1209
- KUR: "kur",
1210
- LAO: "lao",
1211
- LAT: "lat",
1212
- LAV: "lav",
1213
- LIT: "lit",
1214
- MAL: "mal",
1215
- MAR: "mar",
1216
- MKD: "mkd",
1217
- MLT: "mlt",
1218
- MSA: "msa",
1219
- MYA: "mya",
1220
- NEP: "nep",
1221
- NLD: "nld",
1222
- NOR: "nor",
1223
- ORI: "ori",
1224
- PAN: "pan",
1225
- POL: "pol",
1226
- POR: "por",
1227
- PUS: "pus",
1228
- RON: "ron",
1229
- RUS: "rus",
1230
- SAN: "san",
1231
- SIN: "sin",
1232
- SLK: "slk",
1233
- SLV: "slv",
1234
- SPA: "spa",
1235
- SPA_OLD: "spa_old",
1236
- SQI: "sqi",
1237
- SRP: "srp",
1238
- SRP_LATN: "srp_latn",
1239
- SWA: "swa",
1240
- SWE: "swe",
1241
- SYR: "syr",
1242
- TAM: "tam",
1243
- TEL: "tel",
1244
- TGK: "tgk",
1245
- TGL: "tgl",
1246
- THA: "tha",
1247
- TIR: "tir",
1248
- TUR: "tur",
1249
- UIG: "uig",
1250
- UKR: "ukr",
1251
- URD: "urd",
1252
- UZB: "uzb",
1253
- UZB_CYRL: "uzb_cyrl",
1254
- VIE: "vie",
1255
- YID: "yid"
1256
- };
1257
- var PSM$1 = {
1258
- OSD_ONLY: "0",
1259
- AUTO_OSD: "1",
1260
- AUTO_ONLY: "2",
1261
- AUTO: "3",
1262
- SINGLE_COLUMN: "4",
1263
- SINGLE_BLOCK_VERT_TEXT: "5",
1264
- SINGLE_BLOCK: "6",
1265
- SINGLE_LINE: "7",
1266
- SINGLE_WORD: "8",
1267
- CIRCLE_WORD: "9",
1268
- SINGLE_CHAR: "10",
1269
- SPARSE_TEXT: "11",
1270
- SPARSE_TEXT_OSD: "12",
1271
- RAW_LINE: "13"
1272
- };
1273
- const createScheduler = createScheduler$1;
1274
- const createWorker = createWorker$2;
1275
- const Tesseract = Tesseract$1;
1276
- const languages = languages$1;
1277
- const OEM = OEM$2;
1278
- const PSM = PSM$1;
1279
- const { setLogging } = log$2;
1280
- var src = {
1281
- languages,
1282
- OEM,
1283
- PSM,
1284
- createScheduler,
1285
- createWorker,
1286
- setLogging,
1287
- ...Tesseract
1288
- };
1042
+ return createWorker;
1043
+ }
1044
+ var Tesseract;
1045
+ var hasRequiredTesseract;
1046
+ function requireTesseract() {
1047
+ if (hasRequiredTesseract) return Tesseract;
1048
+ hasRequiredTesseract = 1;
1049
+ const createWorker2 = requireCreateWorker();
1050
+ const recognize = async (image, langs, options) => {
1051
+ const worker = await createWorker2(langs, 1, options);
1052
+ return worker.recognize(image).finally(async () => {
1053
+ await worker.terminate();
1054
+ });
1055
+ };
1056
+ const detect = async (image, options) => {
1057
+ const worker = await createWorker2("osd", 0, options);
1058
+ return worker.detect(image).finally(async () => {
1059
+ await worker.terminate();
1060
+ });
1061
+ };
1062
+ Tesseract = {
1063
+ recognize,
1064
+ detect
1065
+ };
1066
+ return Tesseract;
1067
+ }
1068
+ var languages;
1069
+ var hasRequiredLanguages;
1070
+ function requireLanguages() {
1071
+ if (hasRequiredLanguages) return languages;
1072
+ hasRequiredLanguages = 1;
1073
+ languages = {
1074
+ AFR: "afr",
1075
+ AMH: "amh",
1076
+ ARA: "ara",
1077
+ ASM: "asm",
1078
+ AZE: "aze",
1079
+ AZE_CYRL: "aze_cyrl",
1080
+ BEL: "bel",
1081
+ BEN: "ben",
1082
+ BOD: "bod",
1083
+ BOS: "bos",
1084
+ BUL: "bul",
1085
+ CAT: "cat",
1086
+ CEB: "ceb",
1087
+ CES: "ces",
1088
+ CHI_SIM: "chi_sim",
1089
+ CHI_TRA: "chi_tra",
1090
+ CHR: "chr",
1091
+ CYM: "cym",
1092
+ DAN: "dan",
1093
+ DEU: "deu",
1094
+ DZO: "dzo",
1095
+ ELL: "ell",
1096
+ ENG: "eng",
1097
+ ENM: "enm",
1098
+ EPO: "epo",
1099
+ EST: "est",
1100
+ EUS: "eus",
1101
+ FAS: "fas",
1102
+ FIN: "fin",
1103
+ FRA: "fra",
1104
+ FRK: "frk",
1105
+ FRM: "frm",
1106
+ GLE: "gle",
1107
+ GLG: "glg",
1108
+ GRC: "grc",
1109
+ GUJ: "guj",
1110
+ HAT: "hat",
1111
+ HEB: "heb",
1112
+ HIN: "hin",
1113
+ HRV: "hrv",
1114
+ HUN: "hun",
1115
+ IKU: "iku",
1116
+ IND: "ind",
1117
+ ISL: "isl",
1118
+ ITA: "ita",
1119
+ ITA_OLD: "ita_old",
1120
+ JAV: "jav",
1121
+ JPN: "jpn",
1122
+ KAN: "kan",
1123
+ KAT: "kat",
1124
+ KAT_OLD: "kat_old",
1125
+ KAZ: "kaz",
1126
+ KHM: "khm",
1127
+ KIR: "kir",
1128
+ KOR: "kor",
1129
+ KUR: "kur",
1130
+ LAO: "lao",
1131
+ LAT: "lat",
1132
+ LAV: "lav",
1133
+ LIT: "lit",
1134
+ MAL: "mal",
1135
+ MAR: "mar",
1136
+ MKD: "mkd",
1137
+ MLT: "mlt",
1138
+ MSA: "msa",
1139
+ MYA: "mya",
1140
+ NEP: "nep",
1141
+ NLD: "nld",
1142
+ NOR: "nor",
1143
+ ORI: "ori",
1144
+ PAN: "pan",
1145
+ POL: "pol",
1146
+ POR: "por",
1147
+ PUS: "pus",
1148
+ RON: "ron",
1149
+ RUS: "rus",
1150
+ SAN: "san",
1151
+ SIN: "sin",
1152
+ SLK: "slk",
1153
+ SLV: "slv",
1154
+ SPA: "spa",
1155
+ SPA_OLD: "spa_old",
1156
+ SQI: "sqi",
1157
+ SRP: "srp",
1158
+ SRP_LATN: "srp_latn",
1159
+ SWA: "swa",
1160
+ SWE: "swe",
1161
+ SYR: "syr",
1162
+ TAM: "tam",
1163
+ TEL: "tel",
1164
+ TGK: "tgk",
1165
+ TGL: "tgl",
1166
+ THA: "tha",
1167
+ TIR: "tir",
1168
+ TUR: "tur",
1169
+ UIG: "uig",
1170
+ UKR: "ukr",
1171
+ URD: "urd",
1172
+ UZB: "uzb",
1173
+ UZB_CYRL: "uzb_cyrl",
1174
+ VIE: "vie",
1175
+ YID: "yid"
1176
+ };
1177
+ return languages;
1178
+ }
1179
+ var PSM;
1180
+ var hasRequiredPSM;
1181
+ function requirePSM() {
1182
+ if (hasRequiredPSM) return PSM;
1183
+ hasRequiredPSM = 1;
1184
+ PSM = {
1185
+ OSD_ONLY: "0",
1186
+ AUTO_OSD: "1",
1187
+ AUTO_ONLY: "2",
1188
+ AUTO: "3",
1189
+ SINGLE_COLUMN: "4",
1190
+ SINGLE_BLOCK_VERT_TEXT: "5",
1191
+ SINGLE_BLOCK: "6",
1192
+ SINGLE_LINE: "7",
1193
+ SINGLE_WORD: "8",
1194
+ CIRCLE_WORD: "9",
1195
+ SINGLE_CHAR: "10",
1196
+ SPARSE_TEXT: "11",
1197
+ SPARSE_TEXT_OSD: "12",
1198
+ RAW_LINE: "13"
1199
+ };
1200
+ return PSM;
1201
+ }
1202
+ var src;
1203
+ var hasRequiredSrc;
1204
+ function requireSrc() {
1205
+ if (hasRequiredSrc) return src;
1206
+ hasRequiredSrc = 1;
1207
+ requireRuntime();
1208
+ const createScheduler2 = requireCreateScheduler();
1209
+ const createWorker2 = requireCreateWorker();
1210
+ const Tesseract2 = requireTesseract();
1211
+ const languages2 = requireLanguages();
1212
+ const OEM2 = requireOEM();
1213
+ const PSM2 = requirePSM();
1214
+ const { setLogging } = requireLog();
1215
+ src = {
1216
+ languages: languages2,
1217
+ OEM: OEM2,
1218
+ PSM: PSM2,
1219
+ createScheduler: createScheduler2,
1220
+ createWorker: createWorker2,
1221
+ setLogging,
1222
+ ...Tesseract2
1223
+ };
1224
+ return src;
1225
+ }
1226
+ var srcExports = requireSrc();
1289
1227
  const ocr = async ({ images = [], language = "eng", langPath = "" }) => {
1290
1228
  if (images.length === 0) return { success: false, data: null, message: "images must be a array" };
1291
1229
  if (!language) return { success: false, data: null, message: "languages must be a array" };
@@ -1293,8 +1231,8 @@ const ocr = async ({ images = [], language = "eng", langPath = "" }) => {
1293
1231
  if (langPath) {
1294
1232
  options = { langPath };
1295
1233
  }
1296
- const scheduler = src.createScheduler();
1297
- const worker = await src.createWorker(language, 3, options);
1234
+ const scheduler = srcExports.createScheduler();
1235
+ const worker = await srcExports.createWorker(language, 3, options);
1298
1236
  scheduler.addWorker(worker);
1299
1237
  const results = await Promise.all(images.map((image) => scheduler.addJob("recognize", image)));
1300
1238
  await scheduler.terminate();