scandit-datacapture-frameworks-label 7.2.0-beta.1

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 (50) hide show
  1. package/dist/dts/defaults/LabelCaptureDefaults.d.ts +13 -0
  2. package/dist/dts/defaults/index.d.ts +1 -0
  3. package/dist/dts/index.d.ts +2 -0
  4. package/dist/dts/labelcapture/BarcodeField.d.ts +8 -0
  5. package/dist/dts/labelcapture/CapturedLabel.d.ts +18 -0
  6. package/dist/dts/labelcapture/CustomBarcode.d.ts +15 -0
  7. package/dist/dts/labelcapture/CustomText.d.ts +10 -0
  8. package/dist/dts/labelcapture/ExpiryDateText.d.ts +11 -0
  9. package/dist/dts/labelcapture/ImeiOneBarcode.d.ts +10 -0
  10. package/dist/dts/labelcapture/ImeiTwoBarcode.d.ts +10 -0
  11. package/dist/dts/labelcapture/LabelCapture.d.ts +24 -0
  12. package/dist/dts/labelcapture/LabelCaptureContextFeatures.d.ts +7 -0
  13. package/dist/dts/labelcapture/LabelCaptureListener.d.ts +5 -0
  14. package/dist/dts/labelcapture/LabelCaptureSession.d.ts +8 -0
  15. package/dist/dts/labelcapture/LabelCaptureSettings.d.ts +15 -0
  16. package/dist/dts/labelcapture/LabelDateComponentFormat.d.ts +5 -0
  17. package/dist/dts/labelcapture/LabelDateFormat.d.ts +9 -0
  18. package/dist/dts/labelcapture/LabelDateResult.d.ts +17 -0
  19. package/dist/dts/labelcapture/LabelDefinition.d.ts +18 -0
  20. package/dist/dts/labelcapture/LabelField.d.ts +24 -0
  21. package/dist/dts/labelcapture/LabelFieldDefinition.d.ts +19 -0
  22. package/dist/dts/labelcapture/LabelFieldLocation.d.ts +17 -0
  23. package/dist/dts/labelcapture/LabelFieldLocationType.d.ts +12 -0
  24. package/dist/dts/labelcapture/LabelFieldState.d.ts +5 -0
  25. package/dist/dts/labelcapture/LabelFieldType.d.ts +5 -0
  26. package/dist/dts/labelcapture/PackingDateText.d.ts +11 -0
  27. package/dist/dts/labelcapture/PartNumberBarcode.d.ts +10 -0
  28. package/dist/dts/labelcapture/SerialNumberBarcode.d.ts +10 -0
  29. package/dist/dts/labelcapture/TextField.d.ts +3 -0
  30. package/dist/dts/labelcapture/TotalPriceText.d.ts +5 -0
  31. package/dist/dts/labelcapture/UnitPriceText.d.ts +5 -0
  32. package/dist/dts/labelcapture/WeightText.d.ts +5 -0
  33. package/dist/dts/labelcapture/controller/LabelCaptureAdvancedOverlayController.d.ts +76 -0
  34. package/dist/dts/labelcapture/controller/LabelCaptureBasicOverlayController.d.ts +42 -0
  35. package/dist/dts/labelcapture/controller/LabelCaptureController.d.ts +14 -0
  36. package/dist/dts/labelcapture/controller/LabelCaptureListenerController.d.ts +25 -0
  37. package/dist/dts/labelcapture/index.d.ts +36 -0
  38. package/dist/dts/labelcapture/private/PrivateLabelCapture.d.ts +7 -0
  39. package/dist/dts/labelcapture/private/PrivateLabelCaptureAdvancedOverlayView.d.ts +3 -0
  40. package/dist/dts/labelcapture/private/PrivateLabelCaptureContextFeatures.d.ts +5 -0
  41. package/dist/dts/labelcapture/private/PrivateLabelCaptureDateResult.d.ts +5 -0
  42. package/dist/dts/labelcapture/private/PrivateLabelCaptureSession.d.ts +34 -0
  43. package/dist/dts/labelcapture/private/PrivateLabelField.d.ts +24 -0
  44. package/dist/dts/labelcapture/view/LabelCaptureAdvancedOverlay.d.ts +27 -0
  45. package/dist/dts/labelcapture/view/LabelCaptureAdvancedOverlayListener.d.ts +13 -0
  46. package/dist/dts/labelcapture/view/LabelCaptureAdvancedOverlayView.d.ts +3 -0
  47. package/dist/dts/labelcapture/view/LabelCaptureBasicOverlay.d.ts +42 -0
  48. package/dist/index.js +1303 -0
  49. package/dist/index.js.map +1 -0
  50. package/package.json +22 -0
package/dist/index.js ADDED
@@ -0,0 +1,1303 @@
1
+ import { FactoryMaker, CameraSettings, Brush, nameForSerialization, DefaultSerializeable, ignoreFromSerialization, ignoreFromSerializationIfNull, Quadrilateral, BaseController, Anchor, PointWithUnit, Rect, Point, Size, serializationDefault, NoViewfinder } from 'scandit-datacapture-frameworks-core';
2
+ import { Barcode, getBarcodeDefaults } from 'scandit-datacapture-frameworks-barcode';
3
+
4
+ function loadLabelCaptureDefaults(jsonDefaults) {
5
+ const defaults = parseLabelCaptureDefaults(jsonDefaults);
6
+ FactoryMaker.bindInstanceIfNotExists('LabelCaptureDefaults', defaults);
7
+ }
8
+ function getLabelCaptureDefaults() {
9
+ return FactoryMaker.getInstance('LabelCaptureDefaults');
10
+ }
11
+ function parseLabelCaptureDefaults(jsonDefaults) {
12
+ return {
13
+ LabelCapture: {
14
+ RecommendedCameraSettings: CameraSettings
15
+ .fromJSON(jsonDefaults.LabelCapture.RecommendedCameraSettings),
16
+ LabelCaptureBasicOverlay: {
17
+ DefaultPredictedFieldBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultPredictedFieldBrush),
18
+ DefaultCapturedFieldBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultCapturedFieldBrush),
19
+ DefaultLabelBrush: Brush.fromJSON(jsonDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultLabelBrush)
20
+ },
21
+ },
22
+ };
23
+ }
24
+
25
+ /******************************************************************************
26
+ Copyright (c) Microsoft Corporation.
27
+
28
+ Permission to use, copy, modify, and/or distribute this software for any
29
+ purpose with or without fee is hereby granted.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
32
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
33
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
34
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
35
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
36
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37
+ PERFORMANCE OF THIS SOFTWARE.
38
+ ***************************************************************************** */
39
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
40
+
41
+
42
+ function __decorate(decorators, target, key, desc) {
43
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
44
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
45
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
46
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
47
+ }
48
+
49
+ function __awaiter(thisArg, _arguments, P, generator) {
50
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
51
+ return new (P || (P = Promise))(function (resolve, reject) {
52
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
53
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
54
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
55
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
56
+ });
57
+ }
58
+
59
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
60
+ var e = new Error(message);
61
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
62
+ };
63
+
64
+ class LabelFieldDefinition extends DefaultSerializeable {
65
+ get name() {
66
+ return this._name;
67
+ }
68
+ get patterns() {
69
+ return this._patterns;
70
+ }
71
+ set patterns(value) {
72
+ this._patterns = value;
73
+ }
74
+ get optional() {
75
+ return this._optional;
76
+ }
77
+ set optional(value) {
78
+ this._optional = value;
79
+ }
80
+ get hiddenProperties() {
81
+ return this._hiddenProperties;
82
+ }
83
+ set hiddenProperties(newValue) {
84
+ for (const key in this._hiddenProperties) {
85
+ if (Object.prototype.hasOwnProperty.call(this._hiddenProperties, key)) {
86
+ delete this[key];
87
+ }
88
+ }
89
+ for (const key in newValue) {
90
+ if (Object.prototype.hasOwnProperty.call(newValue, key)) {
91
+ const item = newValue[key];
92
+ this[key] = item;
93
+ }
94
+ }
95
+ this._hiddenProperties = newValue;
96
+ }
97
+ constructor(name) {
98
+ super();
99
+ this._patterns = [];
100
+ this._optional = false;
101
+ this._hiddenProperties = {};
102
+ this._name = name;
103
+ }
104
+ }
105
+ __decorate([
106
+ nameForSerialization('name')
107
+ ], LabelFieldDefinition.prototype, "_name", undefined);
108
+ __decorate([
109
+ nameForSerialization('patterns')
110
+ ], LabelFieldDefinition.prototype, "_patterns", undefined);
111
+ __decorate([
112
+ nameForSerialization('optional')
113
+ ], LabelFieldDefinition.prototype, "_optional", undefined);
114
+ __decorate([
115
+ ignoreFromSerialization
116
+ ], LabelFieldDefinition.prototype, "_hiddenProperties", undefined);
117
+
118
+ class BarcodeField extends LabelFieldDefinition {
119
+ get symbologySettings() {
120
+ return this._symbologySettings;
121
+ }
122
+ constructor(name, symbologies) {
123
+ super(name);
124
+ this._symbologySettings = symbologies;
125
+ this._symbologies = symbologies.reduce((acc, item) => {
126
+ acc[item.symbology.toString()] = item;
127
+ return acc;
128
+ }, {});
129
+ }
130
+ }
131
+ __decorate([
132
+ nameForSerialization('symbologies'),
133
+ ignoreFromSerializationIfNull
134
+ ], BarcodeField.prototype, "_symbologies", undefined);
135
+ __decorate([
136
+ ignoreFromSerialization
137
+ ], BarcodeField.prototype, "_symbologySettings", undefined);
138
+
139
+ class LabelDateResult extends DefaultSerializeable {
140
+ constructor(day, month, year, dayString, monthString, yearString) {
141
+ super();
142
+ this._day = day;
143
+ this._month = month;
144
+ this._year = year;
145
+ this._dayString = dayString;
146
+ this._monthString = monthString;
147
+ this._yearString = yearString;
148
+ }
149
+ get day() {
150
+ return this._day;
151
+ }
152
+ get month() {
153
+ return this._month;
154
+ }
155
+ get year() {
156
+ return this._year;
157
+ }
158
+ get dayString() {
159
+ var _a;
160
+ return (_a = this._dayString) !== null && _a !== undefined ? _a : '';
161
+ }
162
+ get monthString() {
163
+ var _a;
164
+ return (_a = this._monthString) !== null && _a !== undefined ? _a : '';
165
+ }
166
+ get yearString() {
167
+ var _a;
168
+ return (_a = this._yearString) !== null && _a !== undefined ? _a : '';
169
+ }
170
+ static fromJSON(json) {
171
+ return new LabelDateResult(json.day, json.month, json.year, json.dayStr, json.monthStr, json.yearStr);
172
+ }
173
+ }
174
+ __decorate([
175
+ nameForSerialization('day')
176
+ ], LabelDateResult.prototype, "_day", undefined);
177
+ __decorate([
178
+ nameForSerialization('month')
179
+ ], LabelDateResult.prototype, "_month", undefined);
180
+ __decorate([
181
+ nameForSerialization('year')
182
+ ], LabelDateResult.prototype, "_year", undefined);
183
+ __decorate([
184
+ nameForSerialization('dayStr')
185
+ ], LabelDateResult.prototype, "_dayString", undefined);
186
+ __decorate([
187
+ nameForSerialization('monthStr')
188
+ ], LabelDateResult.prototype, "_monthString", undefined);
189
+ __decorate([
190
+ nameForSerialization('yearStr')
191
+ ], LabelDateResult.prototype, "_yearString", undefined);
192
+
193
+ class LabelField {
194
+ get name() {
195
+ return this._name;
196
+ }
197
+ get type() {
198
+ return this._type;
199
+ }
200
+ get predictedLocation() {
201
+ return this._predictedLocation;
202
+ }
203
+ get state() {
204
+ return this._state;
205
+ }
206
+ get isRequired() {
207
+ return this._isRequired;
208
+ }
209
+ get barcode() {
210
+ return this._barcode;
211
+ }
212
+ get text() {
213
+ return this._text;
214
+ }
215
+ asDate() {
216
+ return this._dateResult;
217
+ }
218
+ static fromJSON(json) {
219
+ const field = new LabelField();
220
+ field._name = json.name;
221
+ field._type = json.type;
222
+ field._predictedLocation = Quadrilateral.fromJSON(json.location);
223
+ field._state = json.state;
224
+ field._isRequired = json.isRequired;
225
+ field._barcode = json.barcode ? Barcode.fromJSON(json.barcode) : null;
226
+ field._text = json.text;
227
+ field._dateResult = json.date ? LabelDateResult.fromJSON(json.date) : null;
228
+ return field;
229
+ }
230
+ }
231
+
232
+ class CapturedLabel {
233
+ get fields() {
234
+ return this._fields;
235
+ }
236
+ get name() {
237
+ return this._name;
238
+ }
239
+ get isComplete() {
240
+ return this._isComplete;
241
+ }
242
+ get predictedBounds() {
243
+ return this._predictedBounds;
244
+ }
245
+ get deltaTimeToPrediction() {
246
+ return this._deltaTimeToPrediction;
247
+ }
248
+ get trackingID() {
249
+ return this._trackingID;
250
+ }
251
+ static fromJSON(json) {
252
+ const label = new CapturedLabel();
253
+ label._fields = json.fields.map(LabelField.fromJSON);
254
+ label._name = json.name;
255
+ label._predictedBounds = Quadrilateral.fromJSON(json.predictedBounds);
256
+ label._deltaTimeToPrediction = json.deltaTimeToPrediction;
257
+ label._trackingID = json.trackingId;
258
+ label._isComplete = json.isComplete;
259
+ return label;
260
+ }
261
+ }
262
+
263
+ class CustomBarcode extends BarcodeField {
264
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
265
+ return new CustomBarcode(name, symbologySettings);
266
+ }
267
+ static initWithNameAndSymbologies(name, symbologies) {
268
+ const symbologySettings = Object.values(symbologies).map(symbology => {
269
+ const symbologyObj = CustomBarcode.barcodeDefaults.SymbologySettings[symbology];
270
+ symbologyObj.isEnabled = true;
271
+ return symbologyObj;
272
+ });
273
+ return new CustomBarcode(name, symbologySettings);
274
+ }
275
+ static initWithNameAndSymbology(name, symbology) {
276
+ return CustomBarcode.initWithNameAndSymbologies(name, [symbology]);
277
+ }
278
+ constructor(name, symbologies) {
279
+ super(name, symbologies);
280
+ this.location = null;
281
+ this._dataTypePatterns = [];
282
+ this._fieldType = 'customBarcode';
283
+ }
284
+ get dataTypePatterns() {
285
+ return this._dataTypePatterns;
286
+ }
287
+ set dataTypePatterns(value) {
288
+ this._dataTypePatterns = value;
289
+ }
290
+ static get barcodeDefaults() {
291
+ return getBarcodeDefaults();
292
+ }
293
+ }
294
+ __decorate([
295
+ nameForSerialization('location')
296
+ ], CustomBarcode.prototype, "location", undefined);
297
+ __decorate([
298
+ nameForSerialization('dataTypePatterns')
299
+ ], CustomBarcode.prototype, "_dataTypePatterns", undefined);
300
+ __decorate([
301
+ nameForSerialization('fieldType')
302
+ ], CustomBarcode.prototype, "_fieldType", undefined);
303
+
304
+ class TextField extends LabelFieldDefinition {
305
+ }
306
+
307
+ class CustomText extends TextField {
308
+ constructor(name) {
309
+ super(name);
310
+ this.location = null;
311
+ this._dataTypePatterns = [];
312
+ this._fieldType = 'customText';
313
+ }
314
+ get dataTypePatterns() {
315
+ return this._dataTypePatterns;
316
+ }
317
+ set dataTypePatterns(value) {
318
+ this._dataTypePatterns = value;
319
+ }
320
+ }
321
+ __decorate([
322
+ nameForSerialization('location')
323
+ ], CustomText.prototype, "location", undefined);
324
+ __decorate([
325
+ nameForSerialization('dataTypePatterns')
326
+ ], CustomText.prototype, "_dataTypePatterns", undefined);
327
+ __decorate([
328
+ nameForSerialization('fieldType')
329
+ ], CustomText.prototype, "_fieldType", undefined);
330
+
331
+ class ExpiryDateText extends TextField {
332
+ constructor(name) {
333
+ super(name);
334
+ this._fieldType = 'expiryDateText';
335
+ this._dataTypePatterns = [];
336
+ this._labelDateFormat = null;
337
+ }
338
+ get labelDateFormat() {
339
+ return this._labelDateFormat;
340
+ }
341
+ set labelDateFormat(value) {
342
+ this._labelDateFormat = value;
343
+ }
344
+ get dataTypePatterns() {
345
+ return this._dataTypePatterns;
346
+ }
347
+ }
348
+ __decorate([
349
+ nameForSerialization('fieldType')
350
+ ], ExpiryDateText.prototype, "_fieldType", undefined);
351
+ __decorate([
352
+ nameForSerialization('dataTypePatterns')
353
+ ], ExpiryDateText.prototype, "_dataTypePatterns", undefined);
354
+ __decorate([
355
+ nameForSerialization('labelDateFormat')
356
+ ], ExpiryDateText.prototype, "_labelDateFormat", undefined);
357
+
358
+ class ImeiOneBarcode extends BarcodeField {
359
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
360
+ return new ImeiOneBarcode(name, symbologySettings);
361
+ }
362
+ static initWithNameAndSymbologies(name, symbologies) {
363
+ const symbologySettings = Object.values(symbologies).map(symbology => {
364
+ const symbologyObj = ImeiOneBarcode.barcodeDefaults.SymbologySettings[symbology];
365
+ symbologyObj.isEnabled = true;
366
+ return symbologyObj;
367
+ });
368
+ return new ImeiOneBarcode(name, symbologySettings);
369
+ }
370
+ static initWithNameAndSymbology(name, symbology) {
371
+ return ImeiOneBarcode.initWithNameAndSymbologies(name, [symbology]);
372
+ }
373
+ static get barcodeDefaults() {
374
+ return getBarcodeDefaults();
375
+ }
376
+ constructor(name, symbologies) {
377
+ super(name, symbologies);
378
+ this._fieldType = 'imeiOneBarcode';
379
+ }
380
+ }
381
+ __decorate([
382
+ nameForSerialization('fieldType')
383
+ ], ImeiOneBarcode.prototype, "_fieldType", undefined);
384
+
385
+ class ImeiTwoBarcode extends BarcodeField {
386
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
387
+ return new ImeiTwoBarcode(name, symbologySettings);
388
+ }
389
+ static initWithNameAndSymbologies(name, symbologies) {
390
+ const symbologySettings = Object.values(symbologies).map(symbology => {
391
+ const symbologyObj = ImeiTwoBarcode.barcodeDefaults.SymbologySettings[symbology];
392
+ symbologyObj.isEnabled = true;
393
+ return symbologyObj;
394
+ });
395
+ return new ImeiTwoBarcode(name, symbologySettings);
396
+ }
397
+ static initWithNameAndSymbology(name, symbology) {
398
+ return ImeiTwoBarcode.initWithNameAndSymbologies(name, [symbology]);
399
+ }
400
+ static get barcodeDefaults() {
401
+ return getBarcodeDefaults();
402
+ }
403
+ constructor(name, symbologies) {
404
+ super(name, symbologies);
405
+ this._fieldType = 'imeiTwoBarcode';
406
+ }
407
+ }
408
+ __decorate([
409
+ nameForSerialization('fieldType')
410
+ ], ImeiTwoBarcode.prototype, "_fieldType", undefined);
411
+
412
+ class LabelCaptureContextFeatures {
413
+ static getFeature(name) {
414
+ return LabelCaptureContextFeatures._features[name];
415
+ }
416
+ }
417
+ LabelCaptureContextFeatures._features = {};
418
+ var LabelCaptureContextFeaturesFlags;
419
+ (function (LabelCaptureContextFeaturesFlags) {
420
+ LabelCaptureContextFeaturesFlags["isBarcodeArFull"] = "label-capture-ar-full";
421
+ })(LabelCaptureContextFeaturesFlags || (LabelCaptureContextFeaturesFlags = {}));
422
+
423
+ class LabelCaptureSession {
424
+ get capturedLabels() {
425
+ return this._capturedLabels;
426
+ }
427
+ get frameSequenceID() {
428
+ return this._frameSequenceID;
429
+ }
430
+ static fromJSON(json) {
431
+ const session = new LabelCaptureSession();
432
+ session._frameSequenceID = json.frameSequenceId;
433
+ session._capturedLabels = json.labels
434
+ .map(CapturedLabel.fromJSON);
435
+ session._capturedLabels
436
+ .forEach(label => label.frameSequenceID = session._frameSequenceID);
437
+ return session;
438
+ }
439
+ }
440
+
441
+ var LabelCaptureListenerEvents;
442
+ (function (LabelCaptureListenerEvents) {
443
+ LabelCaptureListenerEvents["didUpdateSession"] = "LabelCaptureListener.didUpdateSession";
444
+ })(LabelCaptureListenerEvents || (LabelCaptureListenerEvents = {}));
445
+ class LabelCaptureListenerController extends BaseController {
446
+ constructor() {
447
+ super('LabelCaptureListenerProxy');
448
+ }
449
+ static forLabelCapture(labelCapture) {
450
+ const controller = new LabelCaptureListenerController();
451
+ controller.mode = labelCapture;
452
+ return controller;
453
+ }
454
+ subscribeListener() {
455
+ return __awaiter(this, undefined, undefined, function* () {
456
+ yield this._proxy.$registerListenerForEvents();
457
+ this._proxy.on$didUpdateSession = (ev) => __awaiter(this, undefined, undefined, function* () {
458
+ const payload = JSON.parse(ev.data);
459
+ const session = LabelCaptureSession.fromJSON(JSON.parse(payload.session));
460
+ LabelCaptureContextFeatures._features[LabelCaptureContextFeaturesFlags.isBarcodeArFull] = payload.isBarcodeArFull == true;
461
+ this.notifyListenersOfDidUpdateSession(session);
462
+ yield this._proxy.$finishDidUpdateSessionCallback({ isEnabled: this.mode.isEnabled });
463
+ });
464
+ });
465
+ }
466
+ unsubscribeListener() {
467
+ return __awaiter(this, undefined, undefined, function* () {
468
+ yield this._proxy.$unregisterListenerForEvents();
469
+ });
470
+ }
471
+ notifyListenersOfDidUpdateSession(session) {
472
+ const mode = this.mode;
473
+ mode.isInListenerCallback = true;
474
+ mode.listeners.forEach(listener => {
475
+ if (listener.didUpdateSession) {
476
+ listener.didUpdateSession(this.mode, session);
477
+ }
478
+ });
479
+ mode.isInListenerCallback = false;
480
+ }
481
+ }
482
+
483
+ class LabelCaptureController extends BaseController {
484
+ constructor() {
485
+ super('LabelCaptureProxy');
486
+ }
487
+ setModeEnabledState(isEnabled) {
488
+ return this._proxy.$setModeEnabledState({ isEnabled });
489
+ }
490
+ updateLabelCaptureSettings(settingsJson) {
491
+ return this._proxy.$updateLabelCaptureSettings({ settingsJson });
492
+ }
493
+ }
494
+
495
+ class LabelCapture extends DefaultSerializeable {
496
+ get isEnabled() {
497
+ return this._isEnabled;
498
+ }
499
+ set isEnabled(isEnabled) {
500
+ this._isEnabled = isEnabled;
501
+ this.modeController.setModeEnabledState(isEnabled);
502
+ }
503
+ get context() {
504
+ return this._context;
505
+ }
506
+ static get recommendedCameraSettings() {
507
+ return getLabelCaptureDefaults().LabelCapture.RecommendedCameraSettings;
508
+ }
509
+ get _context() {
510
+ return this.privateContext;
511
+ }
512
+ set _context(newContext) {
513
+ if (newContext == null) {
514
+ this.listenerController.unsubscribeListener();
515
+ }
516
+ else if (this.privateContext == null) {
517
+ this.listenerController.subscribeListener();
518
+ }
519
+ this.privateContext = newContext;
520
+ }
521
+ static forContext(context, settings) {
522
+ const mode = new LabelCapture();
523
+ mode.settings = settings;
524
+ if (context) {
525
+ context.addMode(mode);
526
+ }
527
+ return mode;
528
+ }
529
+ constructor() {
530
+ super();
531
+ this.type = 'labelCapture';
532
+ this._isEnabled = true;
533
+ this.privateContext = null;
534
+ this.listeners = [];
535
+ this.isInListenerCallback = false;
536
+ this.listenerController = LabelCaptureListenerController.forLabelCapture(this);
537
+ this.modeController = new LabelCaptureController();
538
+ }
539
+ applySettings(settings) {
540
+ this.settings = settings;
541
+ return this.modeController.updateLabelCaptureSettings(JSON.stringify(settings.toJSON()));
542
+ }
543
+ addListener(listener) {
544
+ if (this.listeners.includes(listener)) {
545
+ return;
546
+ }
547
+ this.listeners.push(listener);
548
+ }
549
+ removeListener(listener) {
550
+ if (!this.listeners.includes(listener)) {
551
+ return;
552
+ }
553
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
554
+ }
555
+ }
556
+ __decorate([
557
+ nameForSerialization('enabled')
558
+ ], LabelCapture.prototype, "_isEnabled", undefined);
559
+ __decorate([
560
+ ignoreFromSerialization
561
+ ], LabelCapture.prototype, "privateContext", undefined);
562
+ __decorate([
563
+ ignoreFromSerialization
564
+ ], LabelCapture.prototype, "listeners", undefined);
565
+ __decorate([
566
+ ignoreFromSerialization
567
+ ], LabelCapture.prototype, "listenerController", undefined);
568
+ __decorate([
569
+ ignoreFromSerialization
570
+ ], LabelCapture.prototype, "isInListenerCallback", undefined);
571
+ __decorate([
572
+ ignoreFromSerialization
573
+ ], LabelCapture.prototype, "modeController", undefined);
574
+
575
+ var LabelCaptureAdvancedOverlayListenerEvents;
576
+ (function (LabelCaptureAdvancedOverlayListenerEvents) {
577
+ LabelCaptureAdvancedOverlayListenerEvents["viewForLabel"] = "LabelCaptureAdvancedOverlayListener.viewForLabel";
578
+ LabelCaptureAdvancedOverlayListenerEvents["anchorForLabel"] = "LabelCaptureAdvancedOverlayListener.anchorForLabel";
579
+ LabelCaptureAdvancedOverlayListenerEvents["offsetForLabel"] = "LabelCaptureAdvancedOverlayListener.offsetForLabel";
580
+ LabelCaptureAdvancedOverlayListenerEvents["viewForCapturedLabelField"] = "LabelCaptureAdvancedOverlayListener.viewForCapturedLabelField";
581
+ LabelCaptureAdvancedOverlayListenerEvents["anchorForCapturedLabelField"] = "LabelCaptureAdvancedOverlayListener.anchorForCapturedLabelField";
582
+ LabelCaptureAdvancedOverlayListenerEvents["offsetForCapturedLabelField"] = "LabelCaptureAdvancedOverlayListener.offsetForCapturedLabelField";
583
+ })(LabelCaptureAdvancedOverlayListenerEvents || (LabelCaptureAdvancedOverlayListenerEvents = {}));
584
+ class LabelCaptureAdvancedOverlayController extends BaseController {
585
+ constructor() {
586
+ super('LabelCaptureAdvancedOverlayProxy');
587
+ }
588
+ static forOverlay(overlay) {
589
+ const proxy = new LabelCaptureAdvancedOverlayController();
590
+ proxy.overlay = overlay;
591
+ return proxy;
592
+ }
593
+ setViewForCapturedLabel(label, view) {
594
+ return this._proxy.$setViewForCapturedLabel({
595
+ jsonView: view ? JSON.stringify(view.toJSON()) : null,
596
+ trackingId: label.trackingID
597
+ });
598
+ }
599
+ setAnchorForCapturedLabel(label, anchor) {
600
+ return this._proxy.$setAnchorForCapturedLabel({
601
+ anchor: anchor,
602
+ trackingId: label.trackingID
603
+ });
604
+ }
605
+ setOffsetForCapturedLabel(label, offset) {
606
+ return this._proxy.$setOffsetForCapturedLabel({
607
+ offsetJson: JSON.stringify(offset.toJSON()),
608
+ trackingId: label.trackingID
609
+ });
610
+ }
611
+ setViewForCapturedLabelField(label, field, view) {
612
+ const identifier = `${label.trackingID}§${field.name}`;
613
+ return this.setViewForCapturedLabelFieldPrivate(identifier, view);
614
+ }
615
+ setViewForCapturedLabelFieldPrivate(identifier, view) {
616
+ return this._proxy.$setViewForCapturedLabelField({
617
+ view: view ? JSON.stringify(view.toJSON()) : null,
618
+ identifier: identifier
619
+ });
620
+ }
621
+ setAnchorForCapturedLabelField(label, field, anchor) {
622
+ const identifier = `${label.trackingID}§${field.name}`;
623
+ return this.setAnchorForCapturedLabelFieldPrivate(identifier, anchor);
624
+ }
625
+ setAnchorForCapturedLabelFieldPrivate(identifier, anchor) {
626
+ return this._proxy.$setAnchorForCapturedLabelField({
627
+ anchor: anchor,
628
+ identifier: identifier
629
+ });
630
+ }
631
+ setOffsetForCapturedLabelField(label, field, offset) {
632
+ const identifier = `${label.trackingID}§${field.name}`;
633
+ return this.setOffsetForCapturedLabelFieldPrivate(identifier, offset);
634
+ }
635
+ setOffsetForCapturedLabelFieldPrivate(identifier, offset) {
636
+ return this._proxy.$setOffsetForCapturedLabelField({
637
+ offset: JSON.stringify(offset.toJSON()),
638
+ identifier: identifier
639
+ });
640
+ }
641
+ clearCapturedLabelViews() {
642
+ return this._proxy.$clearCapturedLabelViews();
643
+ }
644
+ subscribeListener() {
645
+ this._proxy.$registerListenerForAdvancedOverlayEvents();
646
+ this._proxy.on$viewForLabel = (ev) => __awaiter(this, undefined, undefined, function* () {
647
+ const payload = JSON.parse(ev.data);
648
+ let view = null;
649
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
650
+ if (this.overlay.listener && this.overlay.listener.viewForCapturedLabel) {
651
+ view = this.overlay.listener.viewForCapturedLabel(this.overlay, label);
652
+ }
653
+ yield this.setViewForCapturedLabel(label, view);
654
+ });
655
+ this._proxy.on$anchorForLabel = (ev) => __awaiter(this, undefined, undefined, function* () {
656
+ const payload = JSON.parse(ev.data);
657
+ let anchor = Anchor.Center;
658
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
659
+ if (this.overlay.listener && this.overlay.listener.anchorForCapturedLabel) {
660
+ anchor = this.overlay.listener.anchorForCapturedLabel(this.overlay, label);
661
+ }
662
+ yield this.setAnchorForCapturedLabel(label, anchor);
663
+ });
664
+ this._proxy.on$offsetForLabel = (ev) => __awaiter(this, undefined, undefined, function* () {
665
+ const payload = JSON.parse(ev.data);
666
+ let offset = PointWithUnit.zero;
667
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
668
+ if (this.overlay.listener && this.overlay.listener.offsetForCapturedLabel) {
669
+ offset = this.overlay.listener.offsetForCapturedLabel(this.overlay, label);
670
+ }
671
+ yield this.setOffsetForCapturedLabel(label, offset);
672
+ });
673
+ this._proxy.on$viewForCapturedLabelField = (ev) => __awaiter(this, undefined, undefined, function* () {
674
+ const payload = JSON.parse(ev.data);
675
+ let view = null;
676
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
677
+ if (this.overlay.listener && this.overlay.listener.viewForCapturedLabelField) {
678
+ view = this.overlay.listener.viewForCapturedLabelField(this.overlay, field);
679
+ }
680
+ yield this.setViewForCapturedLabelFieldPrivate(payload.identifier, view);
681
+ });
682
+ this._proxy.on$anchorForCapturedLabelField = (ev) => __awaiter(this, undefined, undefined, function* () {
683
+ const payload = JSON.parse(ev.data);
684
+ let anchor = Anchor.Center;
685
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
686
+ if (this.overlay.listener && this.overlay.listener.anchorForCapturedLabelField) {
687
+ anchor = this.overlay.listener.anchorForCapturedLabelField(this.overlay, field);
688
+ }
689
+ yield this.setAnchorForCapturedLabelFieldPrivate(payload.identifier, anchor);
690
+ });
691
+ this._proxy.on$offsetForCapturedLabelField = (ev) => __awaiter(this, undefined, undefined, function* () {
692
+ const payload = JSON.parse(ev.data);
693
+ let offset = PointWithUnit.zero;
694
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
695
+ if (this.overlay.listener && this.overlay.listener.offsetForCapturedLabelField) {
696
+ offset = this.overlay.listener.offsetForCapturedLabelField(this.overlay, field);
697
+ }
698
+ yield this.setOffsetForCapturedLabelFieldPrivate(payload.identifier, offset);
699
+ });
700
+ }
701
+ unsubscribeListener() {
702
+ return this._proxy.$unregisterListenerForAdvancedOverlayEvents();
703
+ }
704
+ updateAdvancedOverlay(advancedOverlayJson) {
705
+ return this._proxy.$updateLabelCaptureAdvancedOverlay({ advancedOverlayJson });
706
+ }
707
+ }
708
+
709
+ class LabelCaptureAdvancedOverlay extends DefaultSerializeable {
710
+ set view(newView) {
711
+ if (newView == null) {
712
+ this.proxy.unsubscribeListener();
713
+ }
714
+ else if (this._view == null) {
715
+ this.proxy.subscribeListener();
716
+ }
717
+ this._view = newView;
718
+ }
719
+ get view() {
720
+ return this._view;
721
+ }
722
+ get shouldShowScanAreaGuides() {
723
+ return this._shouldShowScanAreaGuides;
724
+ }
725
+ set shouldShowScanAreaGuides(shouldShow) {
726
+ this._shouldShowScanAreaGuides = shouldShow;
727
+ this.proxy.updateAdvancedOverlay(JSON.stringify(this.toJSON()));
728
+ }
729
+ static withLabelCaptureForView(labelCapture, view) {
730
+ const overlay = new LabelCaptureAdvancedOverlay();
731
+ overlay.mode = labelCapture;
732
+ if (view) {
733
+ view.addOverlay(overlay);
734
+ }
735
+ return overlay;
736
+ }
737
+ constructor() {
738
+ super();
739
+ this.type = 'labelCaptureAdvanced';
740
+ this.listener = null;
741
+ this._shouldShowScanAreaGuides = false;
742
+ this.proxy = LabelCaptureAdvancedOverlayController.forOverlay(this);
743
+ }
744
+ setViewForCapturedLabel(capturedLabel, view) {
745
+ if (LabelCaptureContextFeatures.getFeature(LabelCaptureContextFeaturesFlags.isBarcodeArFull) == false) {
746
+ const errorText = 'The method no longer supports rendering any kind of images. Remove them to be able to set the view for your label. For further details about this backwards incompatible change, contact support@scandit.com.';
747
+ if (view.hasImageInRender()) {
748
+ return new Promise((resolve, reject) => reject(errorText));
749
+ }
750
+ }
751
+ return this.proxy.setViewForCapturedLabel(capturedLabel, view);
752
+ }
753
+ setViewForCapturedLabelField(field, capturedLabel, view) {
754
+ if (LabelCaptureContextFeatures.getFeature(LabelCaptureContextFeaturesFlags.isBarcodeArFull) == false) {
755
+ const errorText = 'The method no longer supports rendering any kind of images. Remove them to be able to set the view for your label. For further details about this backwards incompatible change, contact support@scandit.com.';
756
+ if (view.hasImageInRender()) {
757
+ return new Promise((resolve, reject) => reject(errorText));
758
+ }
759
+ }
760
+ return this.proxy.setViewForCapturedLabelField(capturedLabel, field, view);
761
+ }
762
+ setAnchorForCapturedLabel(capturedLabel, anchor) {
763
+ return this.proxy.setAnchorForCapturedLabel(capturedLabel, anchor);
764
+ }
765
+ setAnchorForCapturedLabelField(field, capturedLabel, anchor) {
766
+ return this.proxy.setAnchorForCapturedLabelField(capturedLabel, field, anchor);
767
+ }
768
+ setOffsetForCapturedLabel(capturedLabel, offset) {
769
+ return this.proxy.setOffsetForCapturedLabel(capturedLabel, offset);
770
+ }
771
+ setOffsetForCapturedLabelField(field, capturedLabel, offset) {
772
+ return this.proxy.setOffsetForCapturedLabelField(capturedLabel, field, offset);
773
+ }
774
+ clearCapturedLabelViews() {
775
+ return this.proxy.clearCapturedLabelViews();
776
+ }
777
+ }
778
+ __decorate([
779
+ ignoreFromSerialization
780
+ ], LabelCaptureAdvancedOverlay.prototype, "proxy", undefined);
781
+ __decorate([
782
+ ignoreFromSerialization
783
+ ], LabelCaptureAdvancedOverlay.prototype, "mode", undefined);
784
+ __decorate([
785
+ ignoreFromSerialization
786
+ ], LabelCaptureAdvancedOverlay.prototype, "_view", undefined);
787
+ __decorate([
788
+ ignoreFromSerialization
789
+ ], LabelCaptureAdvancedOverlay.prototype, "listener", undefined);
790
+ __decorate([
791
+ nameForSerialization('shouldShowScanAreaGuides')
792
+ ], LabelCaptureAdvancedOverlay.prototype, "_shouldShowScanAreaGuides", undefined);
793
+
794
+ class LabelCaptureSettings extends DefaultSerializeable {
795
+ static fromJSON(json) {
796
+ // tslint:disable-next-line:no-console
797
+ throw new Error('This property is deprecated in favour of LabelCaptureSettings.settingsFromLabelDefinitions. Please update your code to use the new property.');
798
+ }
799
+ static settingsFromLabelDefinitions(definitions, properties) {
800
+ const settings = new LabelCaptureSettings();
801
+ settings._definitions = definitions;
802
+ if (properties) {
803
+ settings.properties = properties;
804
+ }
805
+ return settings;
806
+ }
807
+ constructor() {
808
+ super();
809
+ this._definitions = [];
810
+ this.properties = {};
811
+ }
812
+ setProperty(name, value) {
813
+ this[name] = value;
814
+ }
815
+ getProperty(name) {
816
+ return this[name];
817
+ }
818
+ }
819
+ __decorate([
820
+ nameForSerialization('labelDefinitions')
821
+ ], LabelCaptureSettings.prototype, "_definitions", undefined);
822
+
823
+ var LabelDateComponentFormat;
824
+ (function (LabelDateComponentFormat) {
825
+ LabelDateComponentFormat["DMY"] = "dmy";
826
+ LabelDateComponentFormat["MDY"] = "mdy";
827
+ LabelDateComponentFormat["YMD"] = "ymd";
828
+ })(LabelDateComponentFormat || (LabelDateComponentFormat = {}));
829
+
830
+ class LabelDateFormat extends DefaultSerializeable {
831
+ constructor(componentFormat, acceptPartialDates) {
832
+ super();
833
+ this._componentFormat = componentFormat;
834
+ this._acceptPartialDates = acceptPartialDates;
835
+ }
836
+ get componentFormat() {
837
+ return this._componentFormat;
838
+ }
839
+ get acceptPartialDates() {
840
+ return this._acceptPartialDates;
841
+ }
842
+ }
843
+ __decorate([
844
+ nameForSerialization('componentFormat')
845
+ ], LabelDateFormat.prototype, "_componentFormat", undefined);
846
+ __decorate([
847
+ nameForSerialization('acceptPartialDates')
848
+ ], LabelDateFormat.prototype, "_acceptPartialDates", undefined);
849
+
850
+ class LabelDefinition extends DefaultSerializeable {
851
+ get name() {
852
+ return this._name;
853
+ }
854
+ get fields() {
855
+ return this._fields;
856
+ }
857
+ set fields(values) {
858
+ this._fields = values;
859
+ }
860
+ get hiddenProperties() {
861
+ return this._hiddenProperties;
862
+ }
863
+ set hiddenProperties(newValue) {
864
+ for (const key in this._hiddenProperties) {
865
+ if (Object.prototype.hasOwnProperty.call(this._hiddenProperties, key)) {
866
+ delete this[key];
867
+ }
868
+ }
869
+ for (const key in newValue) {
870
+ if (Object.prototype.hasOwnProperty.call(newValue, key)) {
871
+ const item = newValue[key];
872
+ this[key] = item;
873
+ }
874
+ }
875
+ this._hiddenProperties = newValue;
876
+ }
877
+ static fromJSON(json) {
878
+ const definition = new LabelDefinition(json.name);
879
+ definition._fields = json.fields;
880
+ definition.hiddenProperties = json.hidden_properties;
881
+ return definition;
882
+ }
883
+ constructor(name) {
884
+ super();
885
+ this._name = '';
886
+ this._fields = [];
887
+ this._hiddenProperties = {};
888
+ this._name = name;
889
+ }
890
+ }
891
+ __decorate([
892
+ nameForSerialization('name')
893
+ ], LabelDefinition.prototype, "_name", undefined);
894
+ __decorate([
895
+ nameForSerialization('fields')
896
+ ], LabelDefinition.prototype, "_fields", undefined);
897
+ __decorate([
898
+ ignoreFromSerialization
899
+ ], LabelDefinition.prototype, "_hiddenProperties", undefined);
900
+
901
+ var LabelFieldLocationType;
902
+ (function (LabelFieldLocationType) {
903
+ LabelFieldLocationType["TopLeft"] = "topLeft";
904
+ LabelFieldLocationType["TopRight"] = "topRight";
905
+ LabelFieldLocationType["BottomRight"] = "bottomRight";
906
+ LabelFieldLocationType["BottomLeft"] = "bottomLeft";
907
+ LabelFieldLocationType["Top"] = "top";
908
+ LabelFieldLocationType["Right"] = "right";
909
+ LabelFieldLocationType["Bottom"] = "bottom";
910
+ LabelFieldLocationType["Left"] = "left";
911
+ LabelFieldLocationType["Center"] = "center";
912
+ LabelFieldLocationType["WholeLabel"] = "wholeLabel";
913
+ })(LabelFieldLocationType || (LabelFieldLocationType = {}));
914
+
915
+ class LabelFieldLocation extends DefaultSerializeable {
916
+ constructor() {
917
+ super(...arguments);
918
+ this._rect = null;
919
+ this._type = null;
920
+ }
921
+ static forRect(rect) {
922
+ const location = new LabelFieldLocation();
923
+ location._rect = rect;
924
+ return location;
925
+ }
926
+ static for(left, top, right, bottom) {
927
+ const location = new LabelFieldLocation();
928
+ location._rect = new Rect(new Point(left, top), new Size(right - left, bottom - top));
929
+ return location;
930
+ }
931
+ static topLeft() {
932
+ const location = new LabelFieldLocation();
933
+ location._type = LabelFieldLocationType.TopLeft;
934
+ return location;
935
+ }
936
+ static topRight() {
937
+ const location = new LabelFieldLocation();
938
+ location._type = LabelFieldLocationType.TopRight;
939
+ return location;
940
+ }
941
+ static bottomLeft() {
942
+ const location = new LabelFieldLocation();
943
+ location._type = LabelFieldLocationType.BottomLeft;
944
+ return location;
945
+ }
946
+ static bottomRight() {
947
+ const location = new LabelFieldLocation();
948
+ location._type = LabelFieldLocationType.BottomRight;
949
+ return location;
950
+ }
951
+ static top() {
952
+ const location = new LabelFieldLocation();
953
+ location._type = LabelFieldLocationType.Top;
954
+ return location;
955
+ }
956
+ static bottom() {
957
+ const location = new LabelFieldLocation();
958
+ location._type = LabelFieldLocationType.Bottom;
959
+ return location;
960
+ }
961
+ static left() {
962
+ const location = new LabelFieldLocation();
963
+ location._type = LabelFieldLocationType.Left;
964
+ return location;
965
+ }
966
+ static right() {
967
+ const location = new LabelFieldLocation();
968
+ location._type = LabelFieldLocationType.Right;
969
+ return location;
970
+ }
971
+ static center() {
972
+ const location = new LabelFieldLocation();
973
+ location._type = LabelFieldLocationType.Center;
974
+ return location;
975
+ }
976
+ static wholeLabel() {
977
+ const location = new LabelFieldLocation();
978
+ location._type = LabelFieldLocationType.WholeLabel;
979
+ return location;
980
+ }
981
+ }
982
+ __decorate([
983
+ nameForSerialization('rect')
984
+ ], LabelFieldLocation.prototype, "_rect", undefined);
985
+ __decorate([
986
+ nameForSerialization('type'),
987
+ ignoreFromSerializationIfNull
988
+ ], LabelFieldLocation.prototype, "_type", undefined);
989
+
990
+ var LabelFieldState;
991
+ (function (LabelFieldState) {
992
+ LabelFieldState["Captured"] = "captured";
993
+ LabelFieldState["Predicted"] = "predicted";
994
+ LabelFieldState["Unknown"] = "unknown";
995
+ })(LabelFieldState || (LabelFieldState = {}));
996
+
997
+ var LabelFieldType;
998
+ (function (LabelFieldType) {
999
+ LabelFieldType["Barcode"] = "barcode";
1000
+ LabelFieldType["Text"] = "text";
1001
+ LabelFieldType["Unknown"] = "unknown";
1002
+ })(LabelFieldType || (LabelFieldType = {}));
1003
+
1004
+ class PackingDateText extends TextField {
1005
+ constructor(name) {
1006
+ super(name);
1007
+ this._fieldType = 'packingDateText';
1008
+ this._dataTypePatterns = [];
1009
+ this._labelDateFormat = null;
1010
+ }
1011
+ get dataTypePatterns() {
1012
+ return this._dataTypePatterns;
1013
+ }
1014
+ get labelDateFormat() {
1015
+ return this._labelDateFormat;
1016
+ }
1017
+ set labelDateFormat(value) {
1018
+ this._labelDateFormat = value;
1019
+ }
1020
+ }
1021
+ __decorate([
1022
+ nameForSerialization('fieldType')
1023
+ ], PackingDateText.prototype, "_fieldType", undefined);
1024
+ __decorate([
1025
+ nameForSerialization('dataTypePatterns')
1026
+ ], PackingDateText.prototype, "_dataTypePatterns", undefined);
1027
+ __decorate([
1028
+ nameForSerialization('labelDateFormat')
1029
+ ], PackingDateText.prototype, "_labelDateFormat", undefined);
1030
+
1031
+ class PartNumberBarcode extends BarcodeField {
1032
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
1033
+ return new PartNumberBarcode(name, symbologySettings);
1034
+ }
1035
+ static initWithNameAndSymbologies(name, symbologies) {
1036
+ const symbologySettings = Object.values(symbologies).map(symbology => {
1037
+ const symbologyObj = PartNumberBarcode.barcodeDefaults.SymbologySettings[symbology];
1038
+ symbologyObj.isEnabled = true;
1039
+ return symbologyObj;
1040
+ });
1041
+ return new PartNumberBarcode(name, symbologySettings);
1042
+ }
1043
+ static initWithNameAndSymbology(name, symbology) {
1044
+ return PartNumberBarcode.initWithNameAndSymbologies(name, [symbology]);
1045
+ }
1046
+ static get barcodeDefaults() {
1047
+ return getBarcodeDefaults();
1048
+ }
1049
+ constructor(name, symbologies) {
1050
+ super(name, symbologies);
1051
+ this._fieldType = 'partNumberBarcode';
1052
+ }
1053
+ }
1054
+ __decorate([
1055
+ nameForSerialization('fieldType')
1056
+ ], PartNumberBarcode.prototype, "_fieldType", undefined);
1057
+
1058
+ class SerialNumberBarcode extends BarcodeField {
1059
+ static initWithNameAndSymbologySettings(name, symbologySettings) {
1060
+ return new SerialNumberBarcode(name, symbologySettings);
1061
+ }
1062
+ static initWithNameAndSymbologies(name, symbologies) {
1063
+ const symbologySettings = Object.values(symbologies).map(symbology => {
1064
+ const symbologyObj = SerialNumberBarcode.barcodeDefaults.SymbologySettings[symbology];
1065
+ symbologyObj.isEnabled = true;
1066
+ return symbologyObj;
1067
+ });
1068
+ return new SerialNumberBarcode(name, symbologySettings);
1069
+ }
1070
+ static initWithNameAndSymbology(name, symbology) {
1071
+ return SerialNumberBarcode.initWithNameAndSymbologies(name, [symbology]);
1072
+ }
1073
+ static get barcodeDefaults() {
1074
+ return getBarcodeDefaults();
1075
+ }
1076
+ constructor(name, symbologies) {
1077
+ super(name, symbologies);
1078
+ this._fieldType = 'serialNumberBarcode';
1079
+ }
1080
+ }
1081
+ __decorate([
1082
+ nameForSerialization('fieldType')
1083
+ ], SerialNumberBarcode.prototype, "_fieldType", undefined);
1084
+
1085
+ class TotalPriceText extends TextField {
1086
+ constructor(name) {
1087
+ super(name);
1088
+ this._fieldType = 'totalPriceText';
1089
+ }
1090
+ }
1091
+ __decorate([
1092
+ nameForSerialization('fieldType')
1093
+ ], TotalPriceText.prototype, "_fieldType", undefined);
1094
+
1095
+ class UnitPriceText extends TextField {
1096
+ constructor(name) {
1097
+ super(name);
1098
+ this._fieldType = 'unitPriceText';
1099
+ }
1100
+ }
1101
+ __decorate([
1102
+ nameForSerialization('fieldType')
1103
+ ], UnitPriceText.prototype, "_fieldType", undefined);
1104
+
1105
+ class WeightText extends TextField {
1106
+ constructor(name) {
1107
+ super(name);
1108
+ this._fieldType = 'weightText';
1109
+ }
1110
+ }
1111
+ __decorate([
1112
+ nameForSerialization('fieldType')
1113
+ ], WeightText.prototype, "_fieldType", undefined);
1114
+
1115
+ var LabelCaptureBasicOverlayListenerEvents;
1116
+ (function (LabelCaptureBasicOverlayListenerEvents) {
1117
+ LabelCaptureBasicOverlayListenerEvents["brushForFieldOfLabel"] = "LabelCaptureBasicOverlayListener.brushForFieldOfLabel";
1118
+ LabelCaptureBasicOverlayListenerEvents["brushForLabel"] = "LabelCaptureBasicOverlayListener.brushForLabel";
1119
+ LabelCaptureBasicOverlayListenerEvents["didTapLabel"] = "LabelCaptureBasicOverlayListener.didTapLabel";
1120
+ })(LabelCaptureBasicOverlayListenerEvents || (LabelCaptureBasicOverlayListenerEvents = {}));
1121
+ class LabelCaptureBasicOverlayController extends BaseController {
1122
+ constructor() {
1123
+ super('LabelCaptureBasicOverlayProxy');
1124
+ }
1125
+ static forOverlay(overlay) {
1126
+ const proxy = new LabelCaptureBasicOverlayController();
1127
+ proxy.overlay = overlay;
1128
+ return proxy;
1129
+ }
1130
+ setBrushForFieldOfLabel(brush, field, label) {
1131
+ return this._proxy.$setBrushForFieldOfLabel({
1132
+ brushJson: brush ? JSON.stringify(brush.toJSON()) : null,
1133
+ fieldName: field.name,
1134
+ trackingId: label.trackingID
1135
+ });
1136
+ }
1137
+ setBrushForLabel(brush, label) {
1138
+ return this._proxy.$setBrushForLabel({
1139
+ brushJson: brush ? JSON.stringify(brush.toJSON()) : null,
1140
+ trackingId: label.trackingID
1141
+ });
1142
+ }
1143
+ subscribeListener() {
1144
+ return __awaiter(this, undefined, undefined, function* () {
1145
+ yield this._proxy.$registerListenerForBasicOverlayEvents();
1146
+ this._proxy.on$brushForFieldOfLabel = (ev) => __awaiter(this, undefined, undefined, function* () {
1147
+ const payload = JSON.parse(ev.data);
1148
+ let brush = this.overlay.capturedFieldBrush;
1149
+ const field = LabelField.fromJSON(JSON.parse(payload.field));
1150
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1151
+ if (this.overlay.listener && this.overlay.listener.brushForFieldOfLabel) {
1152
+ brush = this.overlay.listener.brushForFieldOfLabel(this.overlay, field, label);
1153
+ }
1154
+ yield this.setBrushForFieldOfLabel(brush, field, label);
1155
+ });
1156
+ this._proxy.on$brushForLabel = (ev) => __awaiter(this, undefined, undefined, function* () {
1157
+ const payload = JSON.parse(ev.data);
1158
+ let brush = this.overlay.labelBrush;
1159
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1160
+ if (this.overlay.listener && this.overlay.listener.brushForLabel) {
1161
+ brush = this.overlay.listener.brushForLabel(this.overlay, label);
1162
+ }
1163
+ yield this.setBrushForLabel(brush, label);
1164
+ });
1165
+ this._proxy.on$didTapLabel = (ev) => __awaiter(this, undefined, undefined, function* () {
1166
+ const payload = JSON.parse(ev.data);
1167
+ if (this.overlay.listener && this.overlay.listener.didTapLabel) {
1168
+ const label = CapturedLabel.fromJSON(JSON.parse(payload.label));
1169
+ this.overlay.listener.didTapLabel(this.overlay, label);
1170
+ }
1171
+ });
1172
+ });
1173
+ }
1174
+ unsubscribeListener() {
1175
+ return __awaiter(this, undefined, undefined, function* () {
1176
+ yield this._proxy.$unregisterListenerForBasicOverlayEvents();
1177
+ });
1178
+ }
1179
+ updateBasicOverlay(basicOverlayJson) {
1180
+ return this._proxy.$updateLabelCaptureBasicOverlay({ basicOverlayJson });
1181
+ }
1182
+ }
1183
+
1184
+ class LabelCaptureBasicOverlay extends DefaultSerializeable {
1185
+ static get defaultPredictedFieldBrush() {
1186
+ return LabelCaptureBasicOverlay.labelCaptureDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultPredictedFieldBrush;
1187
+ }
1188
+ static get defaultCapturedFieldBrush() {
1189
+ return LabelCaptureBasicOverlay.labelCaptureDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultCapturedFieldBrush;
1190
+ }
1191
+ static get defaultLabelBrush() {
1192
+ return LabelCaptureBasicOverlay.labelCaptureDefaults.LabelCapture.LabelCaptureBasicOverlay.DefaultLabelBrush;
1193
+ }
1194
+ static get labelCaptureDefaults() {
1195
+ return getLabelCaptureDefaults();
1196
+ }
1197
+ set view(newView) {
1198
+ if (newView == null) {
1199
+ this.controller.unsubscribeListener();
1200
+ }
1201
+ else if (this._view == null) {
1202
+ this.controller.subscribeListener();
1203
+ }
1204
+ this._view = newView;
1205
+ }
1206
+ get view() {
1207
+ return this._view;
1208
+ }
1209
+ get predictedFieldBrush() {
1210
+ return this._predictedFieldBrush;
1211
+ }
1212
+ set predictedFieldBrush(newBrush) {
1213
+ this._predictedFieldBrush = newBrush;
1214
+ this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1215
+ }
1216
+ get capturedFieldBrush() {
1217
+ return this._capturedFieldBrush;
1218
+ }
1219
+ set capturedFieldBrush(newBrush) {
1220
+ this._capturedFieldBrush = newBrush;
1221
+ this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1222
+ }
1223
+ get labelBrush() {
1224
+ return this._labelBrush;
1225
+ }
1226
+ set labelBrush(newBrush) {
1227
+ this._labelBrush = newBrush;
1228
+ this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1229
+ }
1230
+ get shouldShowScanAreaGuides() {
1231
+ return this._shouldShowScanAreaGuides;
1232
+ }
1233
+ set shouldShowScanAreaGuides(shouldShow) {
1234
+ this._shouldShowScanAreaGuides = shouldShow;
1235
+ this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1236
+ }
1237
+ get viewfinder() {
1238
+ return this._viewfinder;
1239
+ }
1240
+ set viewfinder(newViewfinder) {
1241
+ this._viewfinder = newViewfinder;
1242
+ this.controller.updateBasicOverlay(JSON.stringify(this.toJSON()));
1243
+ }
1244
+ static withLabelCapture(labelCapture) {
1245
+ return LabelCaptureBasicOverlay.withLabelCaptureForView(labelCapture, null);
1246
+ }
1247
+ static withLabelCaptureForView(labelCapture, view) {
1248
+ const overlay = new LabelCaptureBasicOverlay();
1249
+ overlay.mode = labelCapture;
1250
+ if (view) {
1251
+ view.addOverlay(overlay);
1252
+ }
1253
+ return overlay;
1254
+ }
1255
+ constructor() {
1256
+ super();
1257
+ this.type = 'labelCaptureBasic';
1258
+ this._predictedFieldBrush = LabelCaptureBasicOverlay.defaultPredictedFieldBrush.copy;
1259
+ this._capturedFieldBrush = LabelCaptureBasicOverlay.defaultCapturedFieldBrush.copy;
1260
+ this._labelBrush = LabelCaptureBasicOverlay.defaultLabelBrush.copy;
1261
+ this._shouldShowScanAreaGuides = false;
1262
+ this.listener = null;
1263
+ this._viewfinder = null;
1264
+ this.controller = LabelCaptureBasicOverlayController.forOverlay(this);
1265
+ }
1266
+ setBrushForFieldOfLabel(brush, field, label) {
1267
+ return this.controller.setBrushForFieldOfLabel(brush, field, label);
1268
+ }
1269
+ setBrushForLabel(brush, label) {
1270
+ return this.controller.setBrushForLabel(brush, label);
1271
+ }
1272
+ }
1273
+ __decorate([
1274
+ ignoreFromSerialization
1275
+ ], LabelCaptureBasicOverlay.prototype, "mode", undefined);
1276
+ __decorate([
1277
+ ignoreFromSerialization
1278
+ ], LabelCaptureBasicOverlay.prototype, "_view", undefined);
1279
+ __decorate([
1280
+ nameForSerialization('defaultPredictedFieldBrush')
1281
+ ], LabelCaptureBasicOverlay.prototype, "_predictedFieldBrush", undefined);
1282
+ __decorate([
1283
+ nameForSerialization('defaultCapturedFieldBrush')
1284
+ ], LabelCaptureBasicOverlay.prototype, "_capturedFieldBrush", undefined);
1285
+ __decorate([
1286
+ nameForSerialization('defaultLabelBrush')
1287
+ ], LabelCaptureBasicOverlay.prototype, "_labelBrush", undefined);
1288
+ __decorate([
1289
+ nameForSerialization('shouldShowScanAreaGuides')
1290
+ ], LabelCaptureBasicOverlay.prototype, "_shouldShowScanAreaGuides", undefined);
1291
+ __decorate([
1292
+ ignoreFromSerialization
1293
+ ], LabelCaptureBasicOverlay.prototype, "listener", undefined);
1294
+ __decorate([
1295
+ ignoreFromSerialization
1296
+ ], LabelCaptureBasicOverlay.prototype, "controller", undefined);
1297
+ __decorate([
1298
+ serializationDefault(NoViewfinder),
1299
+ nameForSerialization('viewfinder')
1300
+ ], LabelCaptureBasicOverlay.prototype, "_viewfinder", undefined);
1301
+
1302
+ export { BarcodeField, CapturedLabel, CustomBarcode, CustomText, ExpiryDateText, ImeiOneBarcode, ImeiTwoBarcode, LabelCapture, LabelCaptureAdvancedOverlay, LabelCaptureAdvancedOverlayController, LabelCaptureAdvancedOverlayListenerEvents, LabelCaptureBasicOverlay, LabelCaptureBasicOverlayController, LabelCaptureBasicOverlayListenerEvents, LabelCaptureContextFeatures, LabelCaptureContextFeaturesFlags, LabelCaptureController, LabelCaptureListenerController, LabelCaptureListenerEvents, LabelCaptureSession, LabelCaptureSettings, LabelDateComponentFormat, LabelDateFormat, LabelDateResult, LabelDefinition, LabelField, LabelFieldDefinition, LabelFieldLocation, LabelFieldLocationType, LabelFieldState, LabelFieldType, PackingDateText, PartNumberBarcode, SerialNumberBarcode, TextField, TotalPriceText, UnitPriceText, WeightText, getLabelCaptureDefaults, loadLabelCaptureDefaults };
1303
+ //# sourceMappingURL=index.js.map