scandit-datacapture-frameworks-core 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/__mocks__/Defaults.ts +1 -1
  2. package/dist/dts/EventEmitter.d.ts +1 -2
  3. package/dist/dts/FactoryMaker.d.ts +5 -5
  4. package/dist/dts/camera/Camera.d.ts +11 -11
  5. package/dist/dts/camera/CameraController.d.ts +14 -11
  6. package/dist/dts/camera/CameraSettings.d.ts +2 -2
  7. package/dist/dts/camerahelpers/CameraOwnershipHelper.d.ts +1 -1
  8. package/dist/dts/camerahelpers/CameraOwnershipManager.d.ts +1 -1
  9. package/dist/dts/common/Brush.d.ts +3 -3
  10. package/dist/dts/common/ScanditIconType.d.ts +1 -1
  11. package/dist/dts/context/DataCaptureContext.d.ts +5 -5
  12. package/dist/dts/context/controller/DataCaptureContextController.d.ts +12 -12
  13. package/dist/dts/controllers/{BaseNewController.d.ts → BaseController.d.ts} +1 -1
  14. package/dist/dts/controllers/index.d.ts +1 -1
  15. package/dist/dts/defaults/CoreDefaults.d.ts +1 -1
  16. package/dist/dts/defaults/loadCoreDefaults.d.ts +1 -1
  17. package/dist/dts/feedback/Feedback.d.ts +3 -3
  18. package/dist/dts/feedback/FeedbackController.d.ts +10 -6
  19. package/dist/dts/frame/ImageFrameSource.d.ts +1 -1
  20. package/dist/dts/frame/ImageFrameSourceController.d.ts +5 -9
  21. package/dist/dts/helpers/Helpers.d.ts +1 -0
  22. package/dist/dts/helpers/index.d.ts +1 -0
  23. package/dist/dts/index.d.ts +3 -1
  24. package/dist/dts/proxies/BaseProxy.d.ts +7 -0
  25. package/dist/dts/proxies/NativeCaller.d.ts +6 -4
  26. package/dist/dts/proxies/NativeProxy.d.ts +7 -5
  27. package/dist/dts/proxies/ProxyRegistration.d.ts +5 -0
  28. package/dist/dts/proxies/index.d.ts +2 -2
  29. package/dist/dts/proxy-registration.d.ts +2 -0
  30. package/dist/dts/proxy-types.d.ts +5 -0
  31. package/dist/dts/view/ControlImage.d.ts +1 -1
  32. package/dist/dts/view/DataCaptureView.d.ts +6 -6
  33. package/dist/dts/view/DataCaptureViewController.d.ts +44 -17
  34. package/dist/dts/viewfinder/AimerViewfinder.d.ts +1 -1
  35. package/dist/dts/viewfinder/LaserlineViewfinder.d.ts +1 -1
  36. package/dist/dts/viewfinder/RectangularViewfinder.d.ts +8 -8
  37. package/dist/index.js +482 -695
  38. package/dist/index.js.map +1 -1
  39. package/package.json +3 -2
  40. package/test/ProxyRegistration.test.ts +75 -0
  41. package/dist/dts/BaseController.d.ts +0 -50
  42. package/dist/dts/proxies/AdvancedInstanceAwareNativeProxy.d.ts +0 -30
  43. package/dist/dts/proxies/BaseInstanceAwareNativeProxy.d.ts +0 -5
package/dist/index.js CHANGED
@@ -391,210 +391,17 @@ class FactoryMaker {
391
391
  }
392
392
  FactoryMaker.instances = new Map();
393
393
 
394
- function createEventEmitter() {
395
- const ee = new EventEmitter();
396
- FactoryMaker.bindInstanceIfNotExists('EventEmitter', ee);
397
- }
398
-
399
- /******************************************************************************
400
- Copyright (c) Microsoft Corporation.
401
-
402
- Permission to use, copy, modify, and/or distribute this software for any
403
- purpose with or without fee is hereby granted.
404
-
405
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
406
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
407
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
408
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
409
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
410
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
411
- PERFORMANCE OF THIS SOFTWARE.
412
- ***************************************************************************** */
413
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
414
-
415
-
416
- function __decorate(decorators, target, key, desc) {
417
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
418
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
419
- 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;
420
- return c > 3 && r && Object.defineProperty(target, key, r), r;
421
- }
422
-
423
- function __awaiter(thisArg, _arguments, P, generator) {
424
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
425
- return new (P || (P = Promise))(function (resolve, reject) {
426
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
427
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
428
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
429
- step((generator = generator.apply(thisArg, _arguments || [])).next());
430
- });
431
- }
432
-
433
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
434
- var e = new Error(message);
435
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
436
- };
437
-
438
- class BaseController {
439
- get _proxy() {
440
- return FactoryMaker.getInstance(this.proxyName);
441
- }
442
- constructor(proxyName) {
443
- this.eventEmitter = FactoryMaker.getInstance('EventEmitter');
444
- this.proxyName = proxyName;
445
- }
446
- }
447
- class BaseNativeProxy {
448
- constructor() {
449
- this.eventEmitter = FactoryMaker.getInstance('EventEmitter');
450
- }
451
- }
452
- /**
453
- * JS Proxy hook to act as middleware to all the calls performed by an AdvancedNativeProxy instance
454
- * This will allow AdvancedNativeProxy to call dynamically the methods defined in the interface defined
455
- * as parameter in createAdvancedNativeProxy function
456
- */
457
- const advancedNativeProxyHook = {
458
- /**
459
- * Dynamic property getter for the AdvancedNativeProxy
460
- * In order to call a native method this needs to be preceded by the `$` symbol on the name, ie `$methodName`
461
- * In order to set a native event handler this needs to be preceded by `on$` prefix, ie `on$eventName`
462
- * @param advancedNativeProxy
463
- * @param prop
464
- */
465
- get(advancedNativeProxy, prop) {
466
- // Early return if prop is not a string
467
- if (typeof prop !== 'string') {
468
- return undefined;
469
- }
470
- // Important: $ and on$ are required since if they are not added all
471
- // properties present on AdvancedNativeProxy will be redirected to the
472
- // advancedNativeProxy._call, which will call native even for the own
473
- // properties of the class
474
- // All the methods with the following structure
475
- // $methodName will be redirected to the special _call
476
- // method on AdvancedNativeProxy
477
- if (prop.startsWith("$")) {
478
- if (prop in advancedNativeProxy) {
479
- return advancedNativeProxy[prop];
480
- }
481
- return (args) => {
482
- return advancedNativeProxy._call(prop.substring(1), args);
483
- };
484
- // All methods with the following structure
485
- // on$methodName will trigger the event handler properties
486
- }
487
- else if (prop.startsWith("on$")) {
488
- return advancedNativeProxy[prop.substring(3)];
489
- // Everything else will be taken as a property
490
- }
491
- else {
492
- return advancedNativeProxy[prop];
493
- }
494
- }
495
- };
496
- /**
497
- * AdvancedNativeProxy will provide an easy way to communicate between native proxies
498
- * and other parts of the architecture such as the controller layer
499
- */
500
- class AdvancedNativeProxy extends BaseNativeProxy {
501
- constructor(nativeCaller, events = []) {
502
- super();
503
- this.nativeCaller = nativeCaller;
504
- this.events = events;
505
- this.eventSubscriptions = new Map();
506
- this.events.forEach((event) => __awaiter(this, void 0, void 0, function* () {
507
- yield this._registerEvent(event);
508
- }));
509
- // Wrapping the AdvancedNativeProxy instance with the JS proxy hook
510
- return new Proxy(this, advancedNativeProxyHook);
511
- }
512
- dispose() {
513
- return __awaiter(this, void 0, void 0, function* () {
514
- for (const event of this.events) {
515
- yield this._unregisterEvent(event);
516
- }
517
- this.eventSubscriptions.clear();
518
- this.events = [];
519
- });
520
- }
521
- _call(fnName, args) {
522
- return this.nativeCaller.callFn(fnName, args);
523
- }
524
- _registerEvent(event) {
525
- return __awaiter(this, void 0, void 0, function* () {
526
- const handler = (args) => __awaiter(this, void 0, void 0, function* () {
527
- this.eventEmitter.emit(event.nativeEventName, args);
528
- });
529
- this.eventEmitter.on(event.nativeEventName, (args) => __awaiter(this, void 0, void 0, function* () {
530
- // Call to the special method defined on the JS Proxy hook
531
- try {
532
- const hookArg = this.nativeCaller.eventHook(args);
533
- yield this[`on$${event.name}`](hookArg);
534
- }
535
- catch (e) {
536
- console.error(`Error while trying to execute handler for ${event.nativeEventName}`, e);
537
- throw e;
538
- }
539
- }));
540
- const subscription = yield this.nativeCaller.registerEvent(event.nativeEventName, handler);
541
- this.eventSubscriptions.set(event.name, subscription);
542
- });
543
- }
544
- _unregisterEvent(event) {
545
- return __awaiter(this, void 0, void 0, function* () {
546
- const subscription = this.eventSubscriptions.get(event.name);
547
- yield this.nativeCaller.unregisterEvent(event.nativeEventName, subscription);
548
- this.eventEmitter.off(event.nativeEventName);
549
- this.eventSubscriptions.delete(event.name);
550
- });
551
- }
552
- }
553
- /**
554
- * Function to create a custom AdvancedNativeProxy. This will return an object which will provide dynamically the
555
- * methods specified in the PROXY interface.
556
- *
557
- * The Proxy interface implemented in order to call native methods will require a special mark
558
- * `$methodName` for method calls
559
- * `on$methodName` for the listeners added to the events defined in eventsEnum
560
- * @param nativeCaller
561
- * @param eventsEnum
562
- */
563
- function createAdvancedNativeProxy(nativeCaller, eventsEnum = undefined) {
564
- const eventsList = eventsEnum == null ? [] : Object.entries(eventsEnum).map(([key, value]) => ({
565
- name: key,
566
- nativeEventName: value
567
- }));
568
- return new AdvancedNativeProxy(nativeCaller, eventsList);
569
- }
570
- /**
571
- * Function to create a custom AdvancedNativeProxy. This will return an object which will provide dynamically the
572
- * methods specified in the PROXY interface.
573
- *
574
- * The Proxy interface implemented in order to call native methods will require a special mark
575
- * `$methodName` for method calls
576
- * `on$methodName` for the listeners added to the events defined in eventsEnum
577
- * @param klass
578
- * @param nativeCaller
579
- * @param eventsEnum
580
- */
581
- function createAdvancedNativeFromCtorProxy(klass, nativeCaller, eventsEnum = undefined) {
582
- const eventsList = Object.entries(eventsEnum).map(([key, value]) => ({
583
- name: key,
584
- nativeEventName: value
585
- }));
586
- return new klass(nativeCaller, eventsList);
587
- }
588
-
589
394
  function getCoreDefaults() {
590
395
  return FactoryMaker.getInstance('CoreDefaults');
591
396
  }
592
397
 
398
+ /* eslint-disable @typescript-eslint/no-explicit-any */
593
399
  function ignoreFromSerialization(target, propertyName) {
594
400
  target.ignoredProperties = target.ignoredProperties || [];
595
401
  target.ignoredProperties.push(propertyName);
596
402
  }
597
403
 
404
+ /* eslint-disable @typescript-eslint/no-explicit-any */
598
405
  function nameForSerialization(customName) {
599
406
  return (target, propertyName) => {
600
407
  target.customPropertyNames = target.customPropertyNames || {};
@@ -602,11 +409,13 @@ function nameForSerialization(customName) {
602
409
  };
603
410
  }
604
411
 
412
+ /* eslint-disable @typescript-eslint/no-explicit-any */
605
413
  function ignoreFromSerializationIfNull(target, propertyName) {
606
414
  target.ignoredIfNullProperties = target.ignoredIfNullProperties || [];
607
415
  target.ignoredIfNullProperties.push(propertyName);
608
416
  }
609
417
 
418
+ /* eslint-disable @typescript-eslint/no-explicit-any */
610
419
  function serializationDefault(defaultValue) {
611
420
  return (target, propertyName) => {
612
421
  target.customPropertyDefaults = target.customPropertyDefaults || {};
@@ -666,7 +475,7 @@ class TapToFocus extends DefaultSerializeable {
666
475
 
667
476
  class PrivateFocusGestureDeserializer {
668
477
  static fromJSON(json) {
669
- if (json && json.type === new TapToFocus().type) {
478
+ if (json && json.type === new TapToFocus()['type']) {
670
479
  return new TapToFocus();
671
480
  }
672
481
  else {
@@ -684,7 +493,7 @@ class SwipeToZoom extends DefaultSerializeable {
684
493
 
685
494
  class PrivateZoomGestureDeserializer {
686
495
  static fromJSON(json) {
687
- if (json && json.type === new SwipeToZoom().type) {
496
+ if (json && json.type === new SwipeToZoom()['type']) {
688
497
  return new SwipeToZoom();
689
498
  }
690
499
  else {
@@ -693,6 +502,45 @@ class PrivateZoomGestureDeserializer {
693
502
  }
694
503
  }
695
504
 
505
+ /******************************************************************************
506
+ Copyright (c) Microsoft Corporation.
507
+
508
+ Permission to use, copy, modify, and/or distribute this software for any
509
+ purpose with or without fee is hereby granted.
510
+
511
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
512
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
513
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
514
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
515
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
516
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
517
+ PERFORMANCE OF THIS SOFTWARE.
518
+ ***************************************************************************** */
519
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
520
+
521
+
522
+ function __decorate(decorators, target, key, desc) {
523
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
524
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
525
+ 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;
526
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
527
+ }
528
+
529
+ function __awaiter(thisArg, _arguments, P, generator) {
530
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
531
+ return new (P || (P = Promise))(function (resolve, reject) {
532
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
533
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
534
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
535
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
536
+ });
537
+ }
538
+
539
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
540
+ var e = new Error(message);
541
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
542
+ };
543
+
696
544
  var FrameSourceState;
697
545
  (function (FrameSourceState) {
698
546
  FrameSourceState["On"] = "on";
@@ -1068,7 +916,7 @@ var ScanditIconType;
1068
916
  ScanditIconType["ArrowDown"] = "arrowDown";
1069
917
  ScanditIconType["ToPick"] = "toPick";
1070
918
  ScanditIconType["Checkmark"] = "checkmark";
1071
- ScanditIconType["XMark"] = "xmark";
919
+ ScanditIconType["XMark"] = "xMark";
1072
920
  ScanditIconType["QuestionMark"] = "questionMark";
1073
921
  ScanditIconType["ExclamationMark"] = "exclamationMark";
1074
922
  ScanditIconType["LowStock"] = "lowStock";
@@ -1400,14 +1248,14 @@ class Brush extends DefaultSerializeable {
1400
1248
  get copy() {
1401
1249
  return new Brush(this.fillColor, this.strokeColor, this.strokeWidth);
1402
1250
  }
1251
+ static fromJSON(brushJson) {
1252
+ return new Brush(Color.fromHex(brushJson.fillColor), Color.fromHex(brushJson.strokeColor), brushJson.strokeWidth);
1253
+ }
1403
1254
  constructor(fillColor = Brush.defaults.fillColor, strokeColor = Brush.defaults.strokeColor, strokeWidth = Brush.defaults.strokeWidth) {
1404
1255
  super();
1405
1256
  this.fill = { color: fillColor };
1406
1257
  this.stroke = { color: strokeColor, width: strokeWidth };
1407
1258
  }
1408
- static fromJSON(brushJson) {
1409
- return new Brush(Color.fromHex(brushJson.fillColor), Color.fromHex(brushJson.strokeColor), brushJson.strokeWidth);
1410
- }
1411
1259
  }
1412
1260
 
1413
1261
  var Anchor;
@@ -1525,7 +1373,7 @@ class HTMLElementState {
1525
1373
  }
1526
1374
  }
1527
1375
 
1528
- class BaseNewController {
1376
+ class BaseController {
1529
1377
  get _proxy() {
1530
1378
  return this._cachedProxy;
1531
1379
  }
@@ -1534,14 +1382,14 @@ class BaseNewController {
1534
1382
  }
1535
1383
  }
1536
1384
 
1537
- class ImageFrameSourceController extends BaseNewController {
1385
+ class ImageFrameSourceController extends BaseController {
1538
1386
  constructor(imageFrameSource) {
1539
1387
  super('ImageFrameSourceProxy');
1540
1388
  this.handleDidChangeStateEventWrapper = (ev) => {
1541
1389
  return this.handleDidChangeStateEvent(ev);
1542
1390
  };
1543
1391
  this.imageFrameSource = imageFrameSource;
1544
- this.subscribeListener();
1392
+ void this.subscribeListener();
1545
1393
  }
1546
1394
  get privateImageFrameSource() {
1547
1395
  return this.imageFrameSource;
@@ -1560,7 +1408,7 @@ class ImageFrameSourceController extends BaseNewController {
1560
1408
  }
1561
1409
  subscribeListener() {
1562
1410
  return __awaiter(this, void 0, void 0, function* () {
1563
- yield this._proxy.$registerListenerForCameraEvents();
1411
+ yield this._proxy.$$registerListenerForCameraEvents();
1564
1412
  this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
1565
1413
  this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
1566
1414
  });
@@ -1573,7 +1421,7 @@ class ImageFrameSourceController extends BaseNewController {
1573
1421
  });
1574
1422
  }
1575
1423
  dispose() {
1576
- this.unsubscribeListener();
1424
+ void this.unsubscribeListener();
1577
1425
  this._proxy.dispose();
1578
1426
  }
1579
1427
  handleDidChangeStateEvent(ev) {
@@ -1594,10 +1442,10 @@ class ImageFrameSourceController extends BaseNewController {
1594
1442
  class ImageFrameSource extends DefaultSerializeable {
1595
1443
  set context(newContext) {
1596
1444
  if (newContext == null) {
1597
- this.controller.unsubscribeListener();
1445
+ void this.controller.unsubscribeListener();
1598
1446
  }
1599
1447
  else if (this._context == null) {
1600
- this.controller.subscribeListener();
1448
+ void this.controller.subscribeListener();
1601
1449
  }
1602
1450
  this._context = newContext;
1603
1451
  }
@@ -1625,14 +1473,6 @@ class ImageFrameSource extends DefaultSerializeable {
1625
1473
  this._context = null;
1626
1474
  this.controller = new ImageFrameSourceController(this);
1627
1475
  }
1628
- didChange() {
1629
- if (this.context) {
1630
- return this.context.update();
1631
- }
1632
- else {
1633
- return Promise.resolve();
1634
- }
1635
- }
1636
1476
  switchToDesiredState(state) {
1637
1477
  this._desiredState = state;
1638
1478
  return this.controller.switchCameraToDesiredState(state);
@@ -1658,6 +1498,14 @@ class ImageFrameSource extends DefaultSerializeable {
1658
1498
  getCurrentState() {
1659
1499
  return this.controller.getCurrentState();
1660
1500
  }
1501
+ didChange() {
1502
+ if (this.context) {
1503
+ return this.context.update();
1504
+ }
1505
+ else {
1506
+ return Promise.resolve();
1507
+ }
1508
+ }
1661
1509
  }
1662
1510
  __decorate([
1663
1511
  nameForSerialization('id')
@@ -1739,59 +1587,33 @@ class Camera extends DefaultSerializeable {
1739
1587
  static get coreDefaults() {
1740
1588
  return getCoreDefaults();
1741
1589
  }
1742
- set context(newContext) {
1743
- this._context = newContext;
1744
- if (newContext) {
1745
- // Phase 3: Native camera is ready, resolve the promise so waiting operations can proceed
1746
- if (this.nativeReadyTimeout) {
1747
- clearTimeout(this.nativeReadyTimeout);
1748
- this.nativeReadyTimeout = null;
1590
+ static create(position, settings, desiredTorchState, desiredState) {
1591
+ const cameraPosition = position || Camera.coreDefaults.Camera.defaultPosition;
1592
+ if (!cameraPosition) {
1593
+ return null;
1594
+ }
1595
+ const existingCamera = Camera._cameraInstances.get(cameraPosition);
1596
+ if (existingCamera) {
1597
+ existingCamera.resetPhaseState();
1598
+ if (settings !== undefined) {
1599
+ existingCamera.settings = settings;
1749
1600
  }
1750
- if (this.nativeReadyResolver) {
1751
- this.nativeReadyResolver();
1752
- this.nativeReadyResolver = null;
1753
- this.nativeReadyRejecter = null;
1754
- this.nativeReadyPromise = null;
1601
+ if (desiredTorchState !== undefined) {
1602
+ existingCamera._desiredTorchState = desiredTorchState;
1603
+ void existingCamera.didChange();
1755
1604
  }
1756
- }
1757
- else {
1758
- // When context is removed, reset everything
1759
- if (this.nativeReadyTimeout) {
1760
- clearTimeout(this.nativeReadyTimeout);
1761
- this.nativeReadyTimeout = null;
1605
+ if (desiredState !== undefined) {
1606
+ existingCamera._desiredState = desiredState;
1607
+ void existingCamera.controller.switchCameraToDesiredState(desiredState);
1762
1608
  }
1763
- this.nativeReadyResolver = null;
1764
- this.nativeReadyRejecter = null;
1765
- this.nativeReadyPromise = null;
1609
+ return existingCamera;
1766
1610
  }
1767
- }
1768
- get context() {
1769
- return this._context;
1770
- }
1771
- setNativeFrameSourceIsBeingCreated() {
1772
- this.nativeReadyPromise = new Promise((resolve, reject) => {
1773
- this.nativeReadyResolver = resolve;
1774
- this.nativeReadyRejecter = reject;
1775
- this.nativeReadyTimeout = setTimeout(() => {
1776
- this.nativeReadyTimeout = null;
1777
- if (this.nativeReadyRejecter) {
1778
- this.nativeReadyRejecter(new Error('Camera native initialization timed out after 5 seconds'));
1779
- this.nativeReadyResolver = null;
1780
- this.nativeReadyRejecter = null;
1781
- this.nativeReadyPromise = null;
1782
- }
1783
- }, 5000);
1784
- });
1785
- }
1786
- get isActiveCamera() {
1787
- return this._context !== null;
1788
- }
1789
- static get default() {
1790
- const defaultPosition = Camera.coreDefaults.Camera.defaultPosition;
1791
- if (!defaultPosition) {
1611
+ if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
1792
1612
  return null;
1793
1613
  }
1794
- return Camera.atPosition(defaultPosition);
1614
+ const camera = new Camera(cameraPosition, settings, desiredTorchState, desiredState);
1615
+ Camera._cameraInstances.set(cameraPosition, camera);
1616
+ return camera;
1795
1617
  }
1796
1618
  static withSettings(settings) {
1797
1619
  return Camera.create(undefined, settings);
@@ -1809,24 +1631,6 @@ class Camera extends DefaultSerializeable {
1809
1631
  }
1810
1632
  return Camera.create(cameraPosition);
1811
1633
  }
1812
- get desiredState() {
1813
- return this._desiredState;
1814
- }
1815
- set desiredTorchState(desiredTorchState) {
1816
- this._desiredTorchState = desiredTorchState;
1817
- if (this.nativeReadyPromise) {
1818
- // Phase 2: Wait for native camera to be ready, then update
1819
- this.nativeReadyPromise.then(() => this.didChange());
1820
- }
1821
- else if (this.isActiveCamera) {
1822
- // Phase 3: Execute immediately
1823
- this.didChange();
1824
- }
1825
- // Phase 1: Just update the property, no action needed
1826
- }
1827
- get desiredTorchState() {
1828
- return this._desiredTorchState;
1829
- }
1830
1634
  constructor(position, settings, desiredTorchState, desiredState) {
1831
1635
  super();
1832
1636
  this.type = 'camera';
@@ -1846,34 +1650,6 @@ class Camera extends DefaultSerializeable {
1846
1650
  this._desiredState = desiredState || FrameSourceState.Off;
1847
1651
  this.controller = new CameraController(this);
1848
1652
  }
1849
- static create(position, settings, desiredTorchState, desiredState) {
1850
- const cameraPosition = position || Camera.coreDefaults.Camera.defaultPosition;
1851
- if (!cameraPosition) {
1852
- return null;
1853
- }
1854
- const existingCamera = Camera._cameraInstances.get(cameraPosition);
1855
- if (existingCamera) {
1856
- existingCamera.resetPhaseState();
1857
- if (settings !== undefined) {
1858
- existingCamera.settings = settings;
1859
- }
1860
- if (desiredTorchState !== undefined) {
1861
- existingCamera._desiredTorchState = desiredTorchState;
1862
- existingCamera.didChange();
1863
- }
1864
- if (desiredState !== undefined) {
1865
- existingCamera._desiredState = desiredState;
1866
- existingCamera.controller.switchCameraToDesiredState(desiredState);
1867
- }
1868
- return existingCamera;
1869
- }
1870
- if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
1871
- return null;
1872
- }
1873
- const camera = new Camera(cameraPosition, settings, desiredTorchState, desiredState);
1874
- Camera._cameraInstances.set(cameraPosition, camera);
1875
- return camera;
1876
- }
1877
1653
  switchToDesiredState(state) {
1878
1654
  return __awaiter(this, void 0, void 0, function* () {
1879
1655
  this._desiredState = state;
@@ -1931,6 +1707,78 @@ class Camera extends DefaultSerializeable {
1931
1707
  // Phase 1: Just update the property, no action needed
1932
1708
  });
1933
1709
  }
1710
+ set context(newContext) {
1711
+ this._context = newContext;
1712
+ if (newContext) {
1713
+ // Phase 3: Native camera is ready, resolve the promise so waiting operations can proceed
1714
+ if (this.nativeReadyTimeout) {
1715
+ clearTimeout(this.nativeReadyTimeout);
1716
+ this.nativeReadyTimeout = null;
1717
+ }
1718
+ if (this.nativeReadyResolver) {
1719
+ this.nativeReadyResolver();
1720
+ this.nativeReadyResolver = null;
1721
+ this.nativeReadyRejecter = null;
1722
+ this.nativeReadyPromise = null;
1723
+ }
1724
+ }
1725
+ else {
1726
+ // When context is removed, reset everything
1727
+ if (this.nativeReadyTimeout) {
1728
+ clearTimeout(this.nativeReadyTimeout);
1729
+ this.nativeReadyTimeout = null;
1730
+ }
1731
+ this.nativeReadyResolver = null;
1732
+ this.nativeReadyRejecter = null;
1733
+ this.nativeReadyPromise = null;
1734
+ }
1735
+ }
1736
+ get context() {
1737
+ return this._context;
1738
+ }
1739
+ setNativeFrameSourceIsBeingCreated() {
1740
+ this.nativeReadyPromise = new Promise((resolve, reject) => {
1741
+ this.nativeReadyResolver = resolve;
1742
+ this.nativeReadyRejecter = reject;
1743
+ this.nativeReadyTimeout = setTimeout(() => {
1744
+ this.nativeReadyTimeout = null;
1745
+ if (this.nativeReadyRejecter) {
1746
+ this.nativeReadyRejecter(new Error('Camera native initialization timed out after 5 seconds'));
1747
+ this.nativeReadyResolver = null;
1748
+ this.nativeReadyRejecter = null;
1749
+ this.nativeReadyPromise = null;
1750
+ }
1751
+ }, 5000);
1752
+ });
1753
+ }
1754
+ get isActiveCamera() {
1755
+ return this._context !== null;
1756
+ }
1757
+ static get default() {
1758
+ const defaultPosition = Camera.coreDefaults.Camera.defaultPosition;
1759
+ if (!defaultPosition) {
1760
+ return null;
1761
+ }
1762
+ return Camera.atPosition(defaultPosition);
1763
+ }
1764
+ get desiredState() {
1765
+ return this._desiredState;
1766
+ }
1767
+ set desiredTorchState(desiredTorchState) {
1768
+ this._desiredTorchState = desiredTorchState;
1769
+ if (this.nativeReadyPromise) {
1770
+ // Phase 2: Wait for native camera to be ready, then update
1771
+ void this.nativeReadyPromise.then(() => this.didChange());
1772
+ }
1773
+ else if (this.isActiveCamera) {
1774
+ // Phase 3: Execute immediately
1775
+ void this.didChange();
1776
+ }
1777
+ // Phase 1: Just update the property, no action needed
1778
+ }
1779
+ get desiredTorchState() {
1780
+ return this._desiredTorchState;
1781
+ }
1934
1782
  didChange() {
1935
1783
  return __awaiter(this, void 0, void 0, function* () {
1936
1784
  if (this.context) {
@@ -1949,6 +1797,9 @@ class Camera extends DefaultSerializeable {
1949
1797
  }
1950
1798
  }
1951
1799
  Camera._cameraInstances = new Map();
1800
+ __decorate([
1801
+ ignoreFromSerialization
1802
+ ], Camera.prototype, "controller", void 0);
1952
1803
  __decorate([
1953
1804
  serializationDefault({})
1954
1805
  ], Camera.prototype, "settings", void 0);
@@ -1979,9 +1830,6 @@ __decorate([
1979
1830
  __decorate([
1980
1831
  ignoreFromSerialization
1981
1832
  ], Camera.prototype, "nativeReadyTimeout", void 0);
1982
- __decorate([
1983
- ignoreFromSerialization
1984
- ], Camera.prototype, "controller", void 0);
1985
1833
  __decorate([
1986
1834
  ignoreFromSerialization
1987
1835
  ], Camera, "_cameraInstances", void 0);
@@ -1990,17 +1838,17 @@ __decorate([
1990
1838
  ], Camera, "coreDefaults", null);
1991
1839
 
1992
1840
  class CameraOwnershipManager {
1993
- constructor() {
1994
- this.owners = new Map();
1995
- this.waitingQueue = new Map();
1996
- this.protectedCameras = new Set();
1997
- }
1998
1841
  static getInstance() {
1999
1842
  if (!CameraOwnershipManager.instance) {
2000
1843
  CameraOwnershipManager.instance = new CameraOwnershipManager();
2001
1844
  }
2002
1845
  return CameraOwnershipManager.instance;
2003
1846
  }
1847
+ constructor() {
1848
+ this.owners = new Map();
1849
+ this.waitingQueue = new Map();
1850
+ this.protectedCameras = new Set();
1851
+ }
2004
1852
  requestOwnership(position, owner) {
2005
1853
  const currentOwner = this.owners.get(position);
2006
1854
  if (currentOwner && currentOwner.id !== owner.id) {
@@ -2114,7 +1962,7 @@ class CameraOwnershipManager {
2114
1962
  }
2115
1963
  }
2116
1964
  protectCameraForOwner(camera, position, _owner) {
2117
- var _a, _b, _c;
1965
+ var _a, _b, _c, _d;
2118
1966
  const originalSwitchToDesiredState = camera.switchToDesiredState.bind(camera);
2119
1967
  const originalApplySettings = camera.applySettings.bind(camera);
2120
1968
  const originalSetDesiredTorchState = (_b = (_a = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(camera), 'desiredTorchState')) === null || _a === void 0 ? void 0 : _a.set) === null || _b === void 0 ? void 0 : _b.bind(camera);
@@ -2145,11 +1993,12 @@ class CameraOwnershipManager {
2145
1993
  }
2146
1994
  originalSetDesiredTorchState(value);
2147
1995
  },
2148
- get: (_c = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(camera), 'desiredTorchState')) === null || _c === void 0 ? void 0 : _c.get,
1996
+ get: (_d = (_c = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(camera), 'desiredTorchState')) === null || _c === void 0 ? void 0 : _c.get) === null || _d === void 0 ? void 0 : _d.bind(camera),
2149
1997
  configurable: true
2150
1998
  });
2151
1999
  }
2152
2000
  // Store originals for restoration
2001
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2153
2002
  camera.__originalMethods = {
2154
2003
  switchToDesiredState: originalSwitchToDesiredState,
2155
2004
  applySettings: originalApplySettings,
@@ -2157,7 +2006,8 @@ class CameraOwnershipManager {
2157
2006
  };
2158
2007
  }
2159
2008
  unprotectCamera(camera) {
2160
- var _a;
2009
+ var _a, _b;
2010
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2161
2011
  const originals = camera.__originalMethods;
2162
2012
  if (!originals)
2163
2013
  return;
@@ -2167,10 +2017,11 @@ class CameraOwnershipManager {
2167
2017
  if (originals.setDesiredTorchState) {
2168
2018
  Object.defineProperty(camera, 'desiredTorchState', {
2169
2019
  set: originals.setDesiredTorchState,
2170
- get: (_a = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(camera), 'desiredTorchState')) === null || _a === void 0 ? void 0 : _a.get,
2020
+ get: (_b = (_a = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(camera), 'desiredTorchState')) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.bind(camera),
2171
2021
  configurable: true
2172
2022
  });
2173
2023
  }
2024
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2174
2025
  delete camera.__originalMethods;
2175
2026
  }
2176
2027
  }
@@ -2253,7 +2104,7 @@ class CameraOwnershipHelper {
2253
2104
  return this.ownershipManager.checkOwnership(position, owner);
2254
2105
  }
2255
2106
  /**
2256
- * Get the camera position currently owned by the owner (if any)
2107
+ * Get the camera position currently owned by the owner (if unknown)
2257
2108
  */
2258
2109
  static getOwnedPosition(owner) {
2259
2110
  return this.ownershipManager.getOwnedPosition(owner);
@@ -2276,22 +2127,10 @@ class CameraOwnershipHelper {
2276
2127
  }
2277
2128
  CameraOwnershipHelper.ownershipManager = CameraOwnershipManager.getInstance();
2278
2129
 
2279
- class CameraController extends BaseNewController {
2130
+ class CameraController extends BaseController {
2280
2131
  static get _proxy() {
2281
2132
  return FactoryMaker.getInstance('CameraProxy');
2282
2133
  }
2283
- constructor(camera) {
2284
- super('CameraProxy');
2285
- // Arrow function wrapper to avoid .bind(this) and always use current class state
2286
- this.handleDidChangeStateEventWrapper = (ev) => {
2287
- return this.handleDidChangeStateEvent(ev);
2288
- };
2289
- this.camera = camera;
2290
- this.subscribeListener();
2291
- }
2292
- get privateCamera() {
2293
- return this.camera;
2294
- }
2295
2134
  static getFrame(frameId) {
2296
2135
  return __awaiter(this, void 0, void 0, function* () {
2297
2136
  const result = yield CameraController._proxy.$getFrame({ frameId });
@@ -2312,6 +2151,18 @@ class CameraController extends BaseNewController {
2312
2151
  return PrivateFrameData.fromJSON(frameDataJSON);
2313
2152
  });
2314
2153
  }
2154
+ constructor(camera) {
2155
+ super('CameraProxy');
2156
+ // Arrow function wrapper to avoid .bind(this) and always use current class state
2157
+ this.handleDidChangeStateEventWrapper = (ev) => {
2158
+ return this.handleDidChangeStateEvent(ev);
2159
+ };
2160
+ this.camera = camera;
2161
+ void this.subscribeListener();
2162
+ }
2163
+ get privateCamera() {
2164
+ return this.camera;
2165
+ }
2315
2166
  getCurrentState() {
2316
2167
  return __awaiter(this, void 0, void 0, function* () {
2317
2168
  const result = yield this._proxy.$getCurrentCameraState({ position: this.privateCamera.position });
@@ -2335,7 +2186,7 @@ class CameraController extends BaseNewController {
2335
2186
  }
2336
2187
  subscribeListener() {
2337
2188
  return __awaiter(this, void 0, void 0, function* () {
2338
- yield this._proxy.$registerListenerForCameraEvents();
2189
+ yield this._proxy.$$registerListenerForCameraEvents();
2339
2190
  this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
2340
2191
  this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
2341
2192
  });
@@ -2348,7 +2199,7 @@ class CameraController extends BaseNewController {
2348
2199
  });
2349
2200
  }
2350
2201
  dispose() {
2351
- this.unsubscribeListener();
2202
+ void this.unsubscribeListener();
2352
2203
  this._proxy.dispose();
2353
2204
  }
2354
2205
  handleDidChangeStateEvent(ev) {
@@ -2367,12 +2218,6 @@ class CameraController extends BaseNewController {
2367
2218
  }
2368
2219
 
2369
2220
  class ControlImage extends DefaultSerializeable {
2370
- constructor(type, data, name) {
2371
- super();
2372
- this.type = type;
2373
- this._data = data;
2374
- this._name = name;
2375
- }
2376
2221
  static fromBase64EncodedImage(data) {
2377
2222
  if (data === null)
2378
2223
  return null;
@@ -2381,6 +2226,12 @@ class ControlImage extends DefaultSerializeable {
2381
2226
  static fromResourceName(resource) {
2382
2227
  return new ControlImage("resource", null, resource);
2383
2228
  }
2229
+ constructor(type, data, name) {
2230
+ super();
2231
+ this.type = type;
2232
+ this._data = data;
2233
+ this._name = name;
2234
+ }
2384
2235
  isBase64EncodedImage() {
2385
2236
  return this.type === "base64";
2386
2237
  }
@@ -2455,7 +2306,7 @@ var DataCaptureContextEvents;
2455
2306
  DataCaptureContextEvents["didChangeStatus"] = "DataCaptureContextListener.onStatusChanged";
2456
2307
  DataCaptureContextEvents["didStartObservingContext"] = "DataCaptureContextListener.onObservationStarted";
2457
2308
  })(DataCaptureContextEvents || (DataCaptureContextEvents = {}));
2458
- class DataCaptureContextController extends BaseNewController {
2309
+ class DataCaptureContextController extends BaseController {
2459
2310
  get framework() {
2460
2311
  return this._proxy.framework;
2461
2312
  }
@@ -2470,10 +2321,29 @@ class DataCaptureContextController extends BaseNewController {
2470
2321
  controller.context = context;
2471
2322
  return controller;
2472
2323
  }
2324
+ static getOpenSourceSoftwareLicenseInfo() {
2325
+ return __awaiter(this, void 0, void 0, function* () {
2326
+ const proxy = FactoryMaker.getInstance('DataCaptureContextProxy');
2327
+ const result = yield proxy.$getOpenSourceSoftwareLicenseInfo();
2328
+ return new OpenSourceSoftwareLicenseInfo(result.data);
2329
+ });
2330
+ }
2473
2331
  constructor() {
2474
2332
  super('DataCaptureContextProxy');
2475
2333
  this._listenerRegistered = false;
2476
2334
  }
2335
+ subscribeListener() {
2336
+ return __awaiter(this, void 0, void 0, function* () {
2337
+ if (this._listenerRegistered) {
2338
+ return;
2339
+ }
2340
+ yield this._proxy.$$subscribeContextListener();
2341
+ this._proxy.subscribeForEvents(Object.values(DataCaptureContextEvents));
2342
+ this._proxy.eventEmitter.on(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
2343
+ this._proxy.eventEmitter.on(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
2344
+ this._listenerRegistered = true;
2345
+ });
2346
+ }
2477
2347
  updateContextFromJSON() {
2478
2348
  return __awaiter(this, void 0, void 0, function* () {
2479
2349
  try {
@@ -2495,19 +2365,21 @@ class DataCaptureContextController extends BaseNewController {
2495
2365
  return this._proxy.$removeAllModes();
2496
2366
  }
2497
2367
  dispose() {
2498
- this.unsubscribeListener();
2499
- this._proxy.$disposeContext();
2368
+ void this.unsubscribeListener();
2369
+ void this._proxy.$disposeContext();
2500
2370
  this._proxy.dispose();
2501
2371
  }
2502
2372
  unsubscribeListener() {
2503
- if (!this._listenerRegistered) {
2504
- return;
2505
- }
2506
- this._proxy.$unsubscribeContextListener();
2507
- this._proxy.unsubscribeFromEvents(Object.values(DataCaptureContextEvents));
2508
- this._proxy.eventEmitter.off(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
2509
- this._proxy.eventEmitter.off(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
2510
- this._listenerRegistered = false;
2373
+ return __awaiter(this, void 0, void 0, function* () {
2374
+ if (!this._listenerRegistered) {
2375
+ return;
2376
+ }
2377
+ yield this._proxy.$unsubscribeContextListener();
2378
+ this._proxy.unsubscribeFromEvents(Object.values(DataCaptureContextEvents));
2379
+ this._proxy.eventEmitter.off(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
2380
+ this._proxy.eventEmitter.off(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
2381
+ this._listenerRegistered = false;
2382
+ });
2511
2383
  }
2512
2384
  initialize() {
2513
2385
  return this.initializeContextFromJSON();
@@ -2523,30 +2395,13 @@ class DataCaptureContextController extends BaseNewController {
2523
2395
  }
2524
2396
  });
2525
2397
  }
2526
- static getOpenSourceSoftwareLicenseInfo() {
2527
- return __awaiter(this, void 0, void 0, function* () {
2528
- const proxy = FactoryMaker.getInstance('DataCaptureContextProxy');
2529
- const result = yield proxy.$getOpenSourceSoftwareLicenseInfo();
2530
- return new OpenSourceSoftwareLicenseInfo(result.data);
2531
- });
2532
- }
2533
- subscribeListener() {
2534
- if (this._listenerRegistered) {
2535
- return;
2536
- }
2537
- this._proxy.$subscribeContextListener();
2538
- this._proxy.subscribeForEvents(Object.values(DataCaptureContextEvents));
2539
- this._proxy.eventEmitter.on(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
2540
- this._proxy.eventEmitter.on(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
2541
- this._listenerRegistered = true;
2542
- }
2543
2398
  handleDidChangeStatusEvent(eventPayload) {
2544
2399
  const event = EventDataParser.parse(eventPayload.data);
2545
2400
  if (event === null) {
2546
2401
  console.error('DataCaptureContextController didChangeStatus payload is null');
2547
2402
  return;
2548
2403
  }
2549
- const contextStatus = ContextStatus.fromJSON(JSON.parse(event.status));
2404
+ const contextStatus = ContextStatus['fromJSON'](JSON.parse(event.status));
2550
2405
  this.notifyListenersOfDidChangeStatus(contextStatus);
2551
2406
  }
2552
2407
  handleDidStartObservingContextEvent() {
@@ -2556,8 +2411,7 @@ class DataCaptureContextController extends BaseNewController {
2556
2411
  });
2557
2412
  }
2558
2413
  notifyListenersOfDeserializationError(error) {
2559
- const contextStatus = ContextStatus
2560
- .fromJSON({
2414
+ const contextStatus = ContextStatus['fromJSON']({
2561
2415
  message: error,
2562
2416
  code: -1,
2563
2417
  isValid: true,
@@ -2580,6 +2434,11 @@ class DataCaptureContext extends DefaultSerializeable {
2580
2434
  }
2581
2435
  return DataCaptureContext._instance;
2582
2436
  }
2437
+ static getOpenSourceSoftwareLicenseInfo() {
2438
+ return __awaiter(this, void 0, void 0, function* () {
2439
+ return DataCaptureContextController.getOpenSourceSoftwareLicenseInfo();
2440
+ });
2441
+ }
2583
2442
  static get coreDefaults() {
2584
2443
  return getCoreDefaults();
2585
2444
  }
@@ -2592,24 +2451,24 @@ class DataCaptureContext extends DefaultSerializeable {
2592
2451
  static forLicenseKey(licenseKey) {
2593
2452
  const instance = DataCaptureContext.create(licenseKey, null, null);
2594
2453
  // Call initialize to ensure the shared instance is updated.
2595
- instance.controller.initialize();
2454
+ void instance.controller.initialize();
2596
2455
  return instance;
2597
2456
  }
2598
2457
  static forLicenseKeyWithSettings(licenseKey, settings) {
2599
2458
  const instance = DataCaptureContext.create(licenseKey, null, settings);
2600
2459
  // Call initialize to ensure the shared instance is updated.
2601
- instance.controller.initialize();
2460
+ void instance.controller.initialize();
2602
2461
  return instance;
2603
2462
  }
2604
2463
  static forLicenseKeyWithOptions(licenseKey, options) {
2605
2464
  const instance = DataCaptureContext.create(licenseKey, options, null);
2606
2465
  // Call initialize to ensure the shared instance is updated.
2607
- instance.controller.initialize();
2466
+ void instance.controller.initialize();
2608
2467
  return instance;
2609
2468
  }
2610
2469
  static initialize(licenseKey, options = null, settings = null) {
2611
2470
  DataCaptureContext.create(licenseKey, options, settings);
2612
- DataCaptureContext.sharedInstance.controller.initialize();
2471
+ void DataCaptureContext.sharedInstance.controller.initialize();
2613
2472
  return DataCaptureContext.sharedInstance;
2614
2473
  }
2615
2474
  static create(licenseKey, options, settings) {
@@ -2658,22 +2517,26 @@ class DataCaptureContext extends DefaultSerializeable {
2658
2517
  });
2659
2518
  }
2660
2519
  addListener(listener) {
2661
- if (this.listeners.length === 0) {
2662
- this.controller.subscribeListener();
2663
- }
2664
- if (this.listeners.includes(listener)) {
2665
- return;
2666
- }
2667
- this.listeners.push(listener);
2520
+ return __awaiter(this, void 0, void 0, function* () {
2521
+ if (this.listeners.length === 0) {
2522
+ yield this.controller.subscribeListener();
2523
+ }
2524
+ if (this.listeners.includes(listener)) {
2525
+ return;
2526
+ }
2527
+ this.listeners.push(listener);
2528
+ });
2668
2529
  }
2669
2530
  removeListener(listener) {
2670
- if (!this.listeners.includes(listener)) {
2671
- return;
2672
- }
2673
- this.listeners.splice(this.listeners.indexOf(listener), 1);
2674
- if (this.listeners.length === 0) {
2675
- this.controller.unsubscribeListener();
2676
- }
2531
+ return __awaiter(this, void 0, void 0, function* () {
2532
+ if (!this.listeners.includes(listener)) {
2533
+ return;
2534
+ }
2535
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
2536
+ if (this.listeners.length === 0) {
2537
+ return this.controller.unsubscribeListener();
2538
+ }
2539
+ });
2677
2540
  }
2678
2541
  addMode(mode) {
2679
2542
  return __awaiter(this, void 0, void 0, function* () {
@@ -2686,15 +2549,6 @@ class DataCaptureContext extends DefaultSerializeable {
2686
2549
  yield this.addModeInternal(mode);
2687
2550
  });
2688
2551
  }
2689
- addModeInternal(mode) {
2690
- return __awaiter(this, void 0, void 0, function* () {
2691
- if (!this.modes.includes(mode)) {
2692
- this.modes.push(mode);
2693
- yield this.controller.addModeToContext(mode);
2694
- mode._context = this;
2695
- }
2696
- });
2697
- }
2698
2552
  removeCurrentMode() {
2699
2553
  return __awaiter(this, void 0, void 0, function* () {
2700
2554
  if (this.modes.length === 0) {
@@ -2711,16 +2565,6 @@ class DataCaptureContext extends DefaultSerializeable {
2711
2565
  yield this.removeModeInternal(mode);
2712
2566
  });
2713
2567
  }
2714
- removeModeInternal(mode) {
2715
- return __awaiter(this, void 0, void 0, function* () {
2716
- const index = this.modes.indexOf(mode);
2717
- if (index !== -1) {
2718
- this.modes.splice(index, 1);
2719
- }
2720
- mode._context = null;
2721
- yield this.controller.removeModeFromContext(mode);
2722
- });
2723
- }
2724
2568
  removeAllModes() {
2725
2569
  return __awaiter(this, void 0, void 0, function* () {
2726
2570
  if (this.modes.length === 0) {
@@ -2750,11 +2594,6 @@ class DataCaptureContext extends DefaultSerializeable {
2750
2594
  yield this.update();
2751
2595
  });
2752
2596
  }
2753
- static getOpenSourceSoftwareLicenseInfo() {
2754
- return __awaiter(this, void 0, void 0, function* () {
2755
- return DataCaptureContextController.getOpenSourceSoftwareLicenseInfo();
2756
- });
2757
- }
2758
2597
  update() {
2759
2598
  return __awaiter(this, void 0, void 0, function* () {
2760
2599
  if (!this.controller) {
@@ -2763,6 +2602,25 @@ class DataCaptureContext extends DefaultSerializeable {
2763
2602
  yield this.controller.updateContextFromJSON();
2764
2603
  });
2765
2604
  }
2605
+ addModeInternal(mode) {
2606
+ return __awaiter(this, void 0, void 0, function* () {
2607
+ if (!this.modes.includes(mode)) {
2608
+ this.modes.push(mode);
2609
+ yield this.controller.addModeToContext(mode);
2610
+ mode._context = this;
2611
+ }
2612
+ });
2613
+ }
2614
+ removeModeInternal(mode) {
2615
+ return __awaiter(this, void 0, void 0, function* () {
2616
+ const index = this.modes.indexOf(mode);
2617
+ if (index !== -1) {
2618
+ this.modes.splice(index, 1);
2619
+ }
2620
+ mode._context = null;
2621
+ yield this.controller.removeModeFromContext(mode);
2622
+ });
2623
+ }
2766
2624
  }
2767
2625
  __decorate([
2768
2626
  ignoreFromSerialization
@@ -2799,78 +2657,97 @@ var DataCaptureViewEvents;
2799
2657
  class DataCaptureViewController extends BaseController {
2800
2658
  constructor(view) {
2801
2659
  super('DataCaptureViewProxy');
2660
+ this._listenerRegistered = false;
2661
+ // Arrow function wrapper to avoid .bind(this) and always use current class state
2662
+ this.handleDidChangeSizeEventWrapper = (eventPayload) => {
2663
+ return this.handleDidChangeSizeEvent(eventPayload);
2664
+ };
2802
2665
  this.view = view;
2803
2666
  }
2804
2667
  viewPointForFramePoint(point) {
2805
2668
  return __awaiter(this, void 0, void 0, function* () {
2806
- const result = yield this._proxy.viewPointForFramePoint({ viewId: this.view.viewId, pointJson: JSON.stringify(point.toJSON()) });
2807
- return Point.fromJSON(JSON.parse(result.data));
2669
+ const result = yield this._proxy.$viewPointForFramePoint({ viewId: this.view.viewId, pointJson: JSON.stringify(point.toJSON()) });
2670
+ return Point['fromJSON'](JSON.parse(result.data));
2808
2671
  });
2809
2672
  }
2810
2673
  viewQuadrilateralForFrameQuadrilateral(quadrilateral) {
2811
2674
  return __awaiter(this, void 0, void 0, function* () {
2812
- const result = yield this._proxy.viewQuadrilateralForFrameQuadrilateral({ viewId: this.view.viewId, quadrilateralJson: JSON.stringify(quadrilateral.toJSON()) });
2813
- return Quadrilateral.fromJSON(JSON.parse(result.data));
2675
+ const result = yield this._proxy.$viewQuadrilateralForFrameQuadrilateral({ viewId: this.view.viewId, quadrilateralJson: JSON.stringify(quadrilateral.toJSON()) });
2676
+ return Quadrilateral['fromJSON'](JSON.parse(result.data));
2814
2677
  });
2815
2678
  }
2816
2679
  setPositionAndSize(top, left, width, height, shouldBeUnderWebView) {
2817
- return this._proxy.setPositionAndSize(top, left, width, height, shouldBeUnderWebView);
2680
+ return this._proxy.$setDataCaptureViewPositionAndSize({ top, left, width, height, shouldBeUnderWebView });
2818
2681
  }
2819
2682
  show() {
2820
2683
  if (!this.isViewCreated())
2821
2684
  return Promise.resolve();
2822
- return this._proxy.show();
2685
+ return this._proxy.$showDataCaptureView({ viewId: this.view.viewId });
2823
2686
  }
2824
2687
  hide() {
2825
2688
  if (!this.isViewCreated())
2826
2689
  return Promise.resolve();
2827
- return this._proxy.hide();
2690
+ return this._proxy.$hideDataCaptureView({ viewId: this.view.viewId });
2828
2691
  }
2829
2692
  createNativeView() {
2830
2693
  return __awaiter(this, void 0, void 0, function* () {
2831
2694
  yield this.createView();
2832
- this.subscribeListener();
2695
+ yield this.subscribeListener();
2833
2696
  });
2834
2697
  }
2835
2698
  removeNativeView() {
2836
- return this._proxy.removeView(this.view.viewId);
2837
- }
2838
- createView() {
2839
- return this._proxy.createView(JSON.stringify(this.view.toJSON()));
2699
+ return this._proxy.$removeDataCaptureView({ viewId: this.view.viewId });
2840
2700
  }
2841
2701
  updateView() {
2842
2702
  if (!this.isViewCreated())
2843
2703
  return Promise.resolve();
2844
- return this._proxy.updateView(JSON.stringify(this.view.toJSON()));
2704
+ return this._proxy.$updateDataCaptureView({ viewJson: JSON.stringify(this.view.toJSON()) });
2845
2705
  }
2846
2706
  dispose() {
2847
- this.unsubscribeListener();
2707
+ void this.unsubscribeListener();
2708
+ this._proxy.dispose();
2848
2709
  }
2849
2710
  subscribeListener() {
2850
- var _a, _b;
2851
- this._proxy.registerListenerForViewEvents(this.view.viewId);
2852
- (_b = (_a = this._proxy).subscribeDidChangeSize) === null || _b === void 0 ? void 0 : _b.call(_a);
2853
- this.eventEmitter.on(DataCaptureViewEvents.didChangeSize, (data) => {
2854
- const event = EventDataParser.parse(data);
2855
- if (event === null) {
2856
- console.error('DataCaptureViewController didChangeSize payload is null');
2711
+ return __awaiter(this, void 0, void 0, function* () {
2712
+ if (this._listenerRegistered) {
2857
2713
  return;
2858
2714
  }
2859
- if (event.viewId !== this.view.viewId) {
2715
+ yield this._proxy.$$registerListenerForViewEvents({ viewId: this.view.viewId });
2716
+ this._proxy.subscribeForEvents(Object.values(DataCaptureViewEvents));
2717
+ this._proxy.eventEmitter.on(DataCaptureViewEvents.didChangeSize, this.handleDidChangeSizeEventWrapper);
2718
+ this._listenerRegistered = true;
2719
+ });
2720
+ }
2721
+ unsubscribeListener() {
2722
+ return __awaiter(this, void 0, void 0, function* () {
2723
+ if (!this._listenerRegistered) {
2860
2724
  return;
2861
2725
  }
2862
- const size = Size.fromJSON(event.size);
2863
- const orientation = event.orientation;
2864
- this.view.listeners.forEach(listener => {
2865
- if (listener.didChangeSize) {
2866
- listener.didChangeSize(this.view.viewComponent, size, orientation);
2867
- }
2868
- });
2726
+ yield this._proxy.$unregisterListenerForViewEvents({ viewId: this.view.viewId });
2727
+ this._proxy.unsubscribeFromEvents(Object.values(DataCaptureViewEvents));
2728
+ this._proxy.eventEmitter.off(DataCaptureViewEvents.didChangeSize, this.handleDidChangeSizeEventWrapper);
2729
+ this._listenerRegistered = false;
2869
2730
  });
2870
2731
  }
2871
- unsubscribeListener() {
2872
- this._proxy.unregisterListenerForViewEvents(this.view.viewId);
2873
- this.eventEmitter.removeAllListeners(DataCaptureViewEvents.didChangeSize);
2732
+ createView() {
2733
+ return this._proxy.$createDataCaptureView({ viewJson: JSON.stringify(this.view.toJSON()) });
2734
+ }
2735
+ handleDidChangeSizeEvent(eventPayload) {
2736
+ const event = EventDataParser.parse(eventPayload.data);
2737
+ if (event === null) {
2738
+ console.error('DataCaptureViewController didChangeSize payload is null');
2739
+ return;
2740
+ }
2741
+ if (event.viewId !== this.view.viewId) {
2742
+ return;
2743
+ }
2744
+ const size = Size['fromJSON'](event.size);
2745
+ const orientation = event.orientation;
2746
+ this.view.listeners.forEach(listener => {
2747
+ if (listener.didChangeSize) {
2748
+ listener.didChangeSize(this.view.viewComponent, size, orientation);
2749
+ }
2750
+ });
2874
2751
  }
2875
2752
  isViewCreated() {
2876
2753
  return this.view.viewId > 0;
@@ -2906,49 +2783,49 @@ class BaseDataCaptureView extends DefaultSerializeable {
2906
2783
  }
2907
2784
  set scanAreaMargins(newValue) {
2908
2785
  this._scanAreaMargins = newValue;
2909
- this.controller.updateView();
2786
+ void this.controller.updateView();
2910
2787
  }
2911
2788
  get pointOfInterest() {
2912
2789
  return this._pointOfInterest;
2913
2790
  }
2914
2791
  set pointOfInterest(newValue) {
2915
2792
  this._pointOfInterest = newValue;
2916
- this.controller.updateView();
2793
+ void this.controller.updateView();
2917
2794
  }
2918
2795
  get logoAnchor() {
2919
2796
  return this._logoAnchor;
2920
2797
  }
2921
2798
  set logoAnchor(newValue) {
2922
2799
  this._logoAnchor = newValue;
2923
- this.controller.updateView();
2800
+ void this.controller.updateView();
2924
2801
  }
2925
2802
  get logoOffset() {
2926
2803
  return this._logoOffset;
2927
2804
  }
2928
2805
  set logoOffset(newValue) {
2929
2806
  this._logoOffset = newValue;
2930
- this.controller.updateView();
2807
+ void this.controller.updateView();
2931
2808
  }
2932
2809
  get focusGesture() {
2933
2810
  return this._focusGesture;
2934
2811
  }
2935
2812
  set focusGesture(newValue) {
2936
2813
  this._focusGesture = newValue;
2937
- this.controller.updateView();
2814
+ void this.controller.updateView();
2938
2815
  }
2939
2816
  get zoomGesture() {
2940
2817
  return this._zoomGesture;
2941
2818
  }
2942
2819
  set zoomGesture(newValue) {
2943
2820
  this._zoomGesture = newValue;
2944
- this.controller.updateView();
2821
+ void this.controller.updateView();
2945
2822
  }
2946
2823
  get logoStyle() {
2947
2824
  return this._logoStyle;
2948
2825
  }
2949
2826
  set logoStyle(newValue) {
2950
2827
  this._logoStyle = newValue;
2951
- this.controller.updateView();
2828
+ void this.controller.updateView();
2952
2829
  }
2953
2830
  get privateContext() {
2954
2831
  return this.context;
@@ -2960,12 +2837,12 @@ class BaseDataCaptureView extends DefaultSerializeable {
2960
2837
  }
2961
2838
  constructor(context) {
2962
2839
  super();
2963
- this._context = null;
2964
- this._viewId = -1;
2965
2840
  this.parentId = null;
2966
2841
  this.overlays = [];
2967
- this.controls = [];
2968
2842
  this.listeners = [];
2843
+ this._context = null;
2844
+ this._viewId = -1;
2845
+ this.controls = [];
2969
2846
  this.isViewCreated = false;
2970
2847
  this.context = context;
2971
2848
  this._scanAreaMargins = this.coreDefaults.DataCaptureView.scanAreaMargins;
@@ -3006,7 +2883,7 @@ class BaseDataCaptureView extends DefaultSerializeable {
3006
2883
  overlay.view = null;
3007
2884
  this.overlays.splice(this.overlays.indexOf(overlay), 1);
3008
2885
  }
3009
- this.controller.updateView();
2886
+ void this.controller.updateView();
3010
2887
  }
3011
2888
  addListener(listener) {
3012
2889
  if (!this.listeners.includes(listener)) {
@@ -3025,11 +2902,13 @@ class BaseDataCaptureView extends DefaultSerializeable {
3025
2902
  return this.controller.viewQuadrilateralForFrameQuadrilateral(quadrilateral);
3026
2903
  }
3027
2904
  addControl(control) {
3028
- if (!this.controls.includes(control)) {
3029
- control.view = this;
3030
- this.controls.push(control);
3031
- this.controller.updateView();
3032
- }
2905
+ return __awaiter(this, void 0, void 0, function* () {
2906
+ if (!this.controls.includes(control)) {
2907
+ control.view = this;
2908
+ this.controls.push(control);
2909
+ yield this.controller.updateView();
2910
+ }
2911
+ });
3033
2912
  }
3034
2913
  addControlWithAnchorAndOffset(control, anchor, offset) {
3035
2914
  if (!this.controls.includes(control)) {
@@ -3037,18 +2916,20 @@ class BaseDataCaptureView extends DefaultSerializeable {
3037
2916
  control.anchor = anchor;
3038
2917
  control.offset = offset;
3039
2918
  this.controls.push(control);
3040
- this.controller.updateView();
2919
+ void this.controller.updateView();
3041
2920
  }
3042
2921
  }
3043
2922
  removeControl(control) {
3044
2923
  if (this.controls.includes(control)) {
3045
2924
  control.view = null;
3046
2925
  this.controls.splice(this.controls.indexOf(control), 1);
3047
- this.controller.updateView();
2926
+ void this.controller.updateView();
3048
2927
  }
3049
2928
  }
3050
2929
  controlUpdated() {
3051
- this.controller.updateView();
2930
+ return __awaiter(this, void 0, void 0, function* () {
2931
+ yield this.controller.updateView();
2932
+ });
3052
2933
  }
3053
2934
  createNativeView(viewId) {
3054
2935
  return __awaiter(this, void 0, void 0, function* () {
@@ -3065,7 +2946,7 @@ class BaseDataCaptureView extends DefaultSerializeable {
3065
2946
  if (!this.isViewCreated) {
3066
2947
  return Promise.resolve();
3067
2948
  }
3068
- this.controller.removeNativeView();
2949
+ yield this.controller.removeNativeView();
3069
2950
  this.isViewCreated = false;
3070
2951
  });
3071
2952
  }
@@ -3098,10 +2979,17 @@ class BaseDataCaptureView extends DefaultSerializeable {
3098
2979
  }
3099
2980
  __decorate([
3100
2981
  ignoreFromSerialization
3101
- ], BaseDataCaptureView.prototype, "_context", void 0);
2982
+ ], BaseDataCaptureView.prototype, "viewComponent", void 0);
2983
+ __decorate([
2984
+ nameForSerialization('parentId'),
2985
+ ignoreFromSerializationIfNull
2986
+ ], BaseDataCaptureView.prototype, "parentId", void 0);
3102
2987
  __decorate([
3103
2988
  ignoreFromSerialization
3104
- ], BaseDataCaptureView.prototype, "viewComponent", void 0);
2989
+ ], BaseDataCaptureView.prototype, "listeners", void 0);
2990
+ __decorate([
2991
+ ignoreFromSerialization
2992
+ ], BaseDataCaptureView.prototype, "_context", void 0);
3105
2993
  __decorate([
3106
2994
  ignoreFromSerialization
3107
2995
  ], BaseDataCaptureView.prototype, "coreDefaults", null);
@@ -3111,10 +2999,6 @@ __decorate([
3111
2999
  __decorate([
3112
3000
  nameForSerialization('viewId')
3113
3001
  ], BaseDataCaptureView.prototype, "_viewId", void 0);
3114
- __decorate([
3115
- nameForSerialization('parentId'),
3116
- ignoreFromSerializationIfNull
3117
- ], BaseDataCaptureView.prototype, "parentId", void 0);
3118
3002
  __decorate([
3119
3003
  nameForSerialization('pointOfInterest')
3120
3004
  ], BaseDataCaptureView.prototype, "_pointOfInterest", void 0);
@@ -3136,9 +3020,6 @@ __decorate([
3136
3020
  __decorate([
3137
3021
  ignoreFromSerialization
3138
3022
  ], BaseDataCaptureView.prototype, "controller", void 0);
3139
- __decorate([
3140
- ignoreFromSerialization
3141
- ], BaseDataCaptureView.prototype, "listeners", void 0);
3142
3023
  __decorate([
3143
3024
  ignoreFromSerialization
3144
3025
  ], BaseDataCaptureView.prototype, "isViewCreated", void 0);
@@ -3165,7 +3046,7 @@ class ZoomSwitchControl extends DefaultSerializeable {
3165
3046
  set zoomedOutImage(zoomedOutImage) {
3166
3047
  var _a;
3167
3048
  this.icon.zoomedOut.default = ControlImage.fromBase64EncodedImage(zoomedOutImage);
3168
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3049
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3169
3050
  }
3170
3051
  get zoomedInImage() {
3171
3052
  var _a, _b;
@@ -3177,7 +3058,7 @@ class ZoomSwitchControl extends DefaultSerializeable {
3177
3058
  set zoomedInImage(zoomedInImage) {
3178
3059
  var _a;
3179
3060
  this.icon.zoomedIn.default = ControlImage.fromBase64EncodedImage(zoomedInImage);
3180
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3061
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3181
3062
  }
3182
3063
  get zoomedInPressedImage() {
3183
3064
  var _a, _b;
@@ -3189,7 +3070,7 @@ class ZoomSwitchControl extends DefaultSerializeable {
3189
3070
  set zoomedInPressedImage(zoomedInPressedImage) {
3190
3071
  var _a;
3191
3072
  this.icon.zoomedIn.pressed = ControlImage.fromBase64EncodedImage(zoomedInPressedImage);
3192
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3073
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3193
3074
  }
3194
3075
  get zoomedOutPressedImage() {
3195
3076
  var _a, _b;
@@ -3201,27 +3082,27 @@ class ZoomSwitchControl extends DefaultSerializeable {
3201
3082
  set zoomedOutPressedImage(zoomedOutPressedImage) {
3202
3083
  var _a;
3203
3084
  this.icon.zoomedOut.pressed = ControlImage.fromBase64EncodedImage(zoomedOutPressedImage);
3204
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3085
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3205
3086
  }
3206
3087
  setZoomedInImage(resource) {
3207
3088
  var _a;
3208
3089
  this.icon.zoomedIn.default = ControlImage.fromResourceName(resource);
3209
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3090
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3210
3091
  }
3211
3092
  setZoomedInPressedImage(resource) {
3212
3093
  var _a;
3213
3094
  this.icon.zoomedIn.pressed = ControlImage.fromResourceName(resource);
3214
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3095
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3215
3096
  }
3216
3097
  setZoomedOutImage(resource) {
3217
3098
  var _a;
3218
3099
  this.icon.zoomedOut.default = ControlImage.fromResourceName(resource);
3219
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3100
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3220
3101
  }
3221
3102
  setZoomedOutPressedImage(resource) {
3222
3103
  var _a;
3223
3104
  this.icon.zoomedOut.pressed = ControlImage.fromResourceName(resource);
3224
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3105
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3225
3106
  }
3226
3107
  }
3227
3108
  __decorate([
@@ -3250,7 +3131,7 @@ class TorchSwitchControl extends DefaultSerializeable {
3250
3131
  set torchOffImage(torchOffImage) {
3251
3132
  var _a;
3252
3133
  this.icon.off.default = ControlImage.fromBase64EncodedImage(torchOffImage);
3253
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3134
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3254
3135
  }
3255
3136
  get torchOffPressedImage() {
3256
3137
  var _a, _b;
@@ -3262,7 +3143,7 @@ class TorchSwitchControl extends DefaultSerializeable {
3262
3143
  set torchOffPressedImage(torchOffPressedImage) {
3263
3144
  var _a;
3264
3145
  this.icon.off.pressed = ControlImage.fromBase64EncodedImage(torchOffPressedImage);
3265
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3146
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3266
3147
  }
3267
3148
  get torchOnImage() {
3268
3149
  var _a, _b;
@@ -3274,7 +3155,7 @@ class TorchSwitchControl extends DefaultSerializeable {
3274
3155
  set torchOnImage(torchOnImage) {
3275
3156
  var _a;
3276
3157
  this.icon.on.default = ControlImage.fromBase64EncodedImage(torchOnImage);
3277
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3158
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3278
3159
  }
3279
3160
  get torchOnPressedImage() {
3280
3161
  var _a, _b;
@@ -3286,22 +3167,22 @@ class TorchSwitchControl extends DefaultSerializeable {
3286
3167
  setTorchOffImage(resource) {
3287
3168
  var _a;
3288
3169
  this.icon.off.default = ControlImage.fromResourceName(resource);
3289
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3170
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3290
3171
  }
3291
3172
  setTorchOffPressedImage(resource) {
3292
3173
  var _a;
3293
3174
  this.icon.off.pressed = ControlImage.fromResourceName(resource);
3294
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3175
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3295
3176
  }
3296
3177
  setTorchOnImage(resource) {
3297
3178
  var _a;
3298
3179
  this.icon.on.default = ControlImage.fromResourceName(resource);
3299
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3180
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3300
3181
  }
3301
3182
  setTorchOnPressedImage(resource) {
3302
3183
  var _a;
3303
3184
  this.icon.on.pressed = ControlImage.fromResourceName(resource);
3304
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3185
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3305
3186
  }
3306
3187
  setImageResource(resource) {
3307
3188
  var _a;
@@ -3309,12 +3190,12 @@ class TorchSwitchControl extends DefaultSerializeable {
3309
3190
  this.icon.off.pressed = ControlImage.fromResourceName(resource);
3310
3191
  this.icon.on.default = ControlImage.fromResourceName(resource);
3311
3192
  this.icon.on.pressed = ControlImage.fromResourceName(resource);
3312
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3193
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3313
3194
  }
3314
3195
  set torchOnPressedImage(torchOnPressedImage) {
3315
3196
  var _a;
3316
3197
  this.icon.on.pressed = ControlImage.fromBase64EncodedImage(torchOnPressedImage);
3317
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.controlUpdated();
3198
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
3318
3199
  }
3319
3200
  }
3320
3201
  __decorate([
@@ -3391,6 +3272,9 @@ class CameraSettings extends DefaultSerializeable {
3391
3272
  constructor(settings) {
3392
3273
  var _a, _b, _c, _d, _e, _f;
3393
3274
  super();
3275
+ this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
3276
+ this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
3277
+ this.zoomGestureZoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
3394
3278
  this.focusHiddenProperties = [
3395
3279
  'range',
3396
3280
  'manualLensPosition',
@@ -3398,9 +3282,6 @@ class CameraSettings extends DefaultSerializeable {
3398
3282
  'focusStrategy',
3399
3283
  'focusGestureStrategy'
3400
3284
  ];
3401
- this.preferredResolution = CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
3402
- this.zoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
3403
- this.zoomGestureZoomFactor = CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
3404
3285
  this.focus = {
3405
3286
  range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
3406
3287
  focusGestureStrategy: CameraSettings.coreDefaults.Camera.Settings.focusGestureStrategy,
@@ -3474,13 +3355,11 @@ class RectangularViewfinder extends DefaultSerializeable {
3474
3355
  constructor(style, lineStyle) {
3475
3356
  super();
3476
3357
  this.type = 'rectangular';
3477
- this.eventEmitter = FactoryMaker.getInstance('EventEmitter');
3478
3358
  const viewfinderStyle = style || this.coreDefaults.RectangularViewfinder.defaultStyle;
3479
3359
  this._style = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].style;
3480
3360
  this._lineStyle = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].lineStyle;
3481
3361
  this._dimming = parseFloat(this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].dimming);
3482
- this._disabledDimming =
3483
- parseFloat(this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].disabledDimming);
3362
+ this._disabledDimming = parseFloat(this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].disabledDimming);
3484
3363
  this._animation = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].animation;
3485
3364
  this.color = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].color;
3486
3365
  this._sizeWithUnitAndAspect = this.coreDefaults.RectangularViewfinder.styles[viewfinderStyle].size;
@@ -3536,9 +3415,13 @@ class RectangularViewfinder extends DefaultSerializeable {
3536
3415
  this.update();
3537
3416
  }
3538
3417
  update() {
3539
- this.eventEmitter.emit('viewfinder.update');
3418
+ var _a;
3419
+ (_a = this._onChange) === null || _a === void 0 ? void 0 : _a.call(this);
3540
3420
  }
3541
3421
  }
3422
+ __decorate([
3423
+ ignoreFromSerialization
3424
+ ], RectangularViewfinder.prototype, "_onChange", void 0);
3542
3425
  __decorate([
3543
3426
  nameForSerialization('style')
3544
3427
  ], RectangularViewfinder.prototype, "_style", void 0);
@@ -3561,9 +3444,6 @@ __decorate([
3561
3444
  __decorate([
3562
3445
  nameForSerialization('disabledColor')
3563
3446
  ], RectangularViewfinder.prototype, "_disabledColor", void 0);
3564
- __decorate([
3565
- ignoreFromSerialization
3566
- ], RectangularViewfinder.prototype, "eventEmitter", void 0);
3567
3447
 
3568
3448
  var RectangularViewfinderStyle;
3569
3449
  (function (RectangularViewfinderStyle) {
@@ -3602,6 +3482,7 @@ class LaserlineViewfinder extends DefaultSerializeable {
3602
3482
  }
3603
3483
  }
3604
3484
 
3485
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3605
3486
  function parseDefaults(jsonDefaults) {
3606
3487
  const coreDefaults = {
3607
3488
  Camera: {
@@ -3618,53 +3499,46 @@ function parseDefaults(jsonDefaults) {
3618
3499
  availablePositions: jsonDefaults.Camera.availablePositions,
3619
3500
  },
3620
3501
  DataCaptureView: {
3621
- scanAreaMargins: MarginsWithUnit
3622
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.scanAreaMargins)),
3623
- pointOfInterest: PointWithUnit
3624
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.pointOfInterest)),
3502
+ scanAreaMargins: MarginsWithUnit['fromJSON'](JSON.parse(jsonDefaults.DataCaptureView.scanAreaMargins)),
3503
+ pointOfInterest: PointWithUnit['fromJSON'](JSON.parse(jsonDefaults.DataCaptureView.pointOfInterest)),
3625
3504
  logoAnchor: jsonDefaults.DataCaptureView.logoAnchor,
3626
- logoOffset: PointWithUnit
3627
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.logoOffset)),
3628
- focusGesture: PrivateFocusGestureDeserializer
3629
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.focusGesture)),
3630
- zoomGesture: PrivateZoomGestureDeserializer
3631
- .fromJSON(JSON.parse(jsonDefaults.DataCaptureView.zoomGesture)),
3505
+ logoOffset: PointWithUnit['fromJSON'](JSON.parse(jsonDefaults.DataCaptureView.logoOffset)),
3506
+ focusGesture: PrivateFocusGestureDeserializer['fromJSON'](JSON.parse(jsonDefaults.DataCaptureView.focusGesture)),
3507
+ zoomGesture: PrivateZoomGestureDeserializer['fromJSON'](JSON.parse(jsonDefaults.DataCaptureView.zoomGesture)),
3632
3508
  logoStyle: jsonDefaults.DataCaptureView.logoStyle,
3633
3509
  },
3634
3510
  RectangularViewfinder: Object
3635
3511
  .keys(jsonDefaults.RectangularViewfinder.styles)
3512
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3636
3513
  .reduce((acc, key) => {
3637
3514
  const viewfinder = jsonDefaults.RectangularViewfinder.styles[key];
3638
3515
  acc.styles[key] = {
3639
- size: SizeWithUnitAndAspect
3640
- .fromJSON(JSON.parse(viewfinder.size)),
3641
- color: Color.fromJSON(viewfinder.color),
3642
- disabledColor: Color.fromJSON(viewfinder.disabledColor),
3516
+ size: SizeWithUnitAndAspect['fromJSON'](JSON.parse(viewfinder.size)),
3517
+ color: Color['fromJSON'](viewfinder.color),
3518
+ disabledColor: Color['fromJSON'](viewfinder.disabledColor),
3643
3519
  style: viewfinder.style,
3644
3520
  lineStyle: viewfinder.lineStyle,
3645
3521
  dimming: viewfinder.dimming,
3646
3522
  disabledDimming: viewfinder.disabledDimming,
3647
- animation: RectangularViewfinderAnimation
3648
- .fromJSON(JSON.parse(viewfinder.animation)),
3523
+ animation: RectangularViewfinderAnimation['fromJSON'](JSON.parse(viewfinder.animation)),
3649
3524
  };
3525
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
3650
3526
  return acc;
3651
3527
  }, { defaultStyle: jsonDefaults.RectangularViewfinder.defaultStyle, styles: {} }),
3652
3528
  AimerViewfinder: {
3653
- frameColor: Color.fromJSON(jsonDefaults.AimerViewfinder.frameColor),
3654
- dotColor: Color.fromJSON(jsonDefaults.AimerViewfinder.dotColor),
3529
+ frameColor: Color['fromJSON'](jsonDefaults.AimerViewfinder.frameColor),
3530
+ dotColor: Color['fromJSON'](jsonDefaults.AimerViewfinder.dotColor),
3655
3531
  },
3656
- Brush: new Brush(Color
3657
- .fromJSON(jsonDefaults.Brush.fillColor), Color
3658
- .fromJSON(jsonDefaults.Brush.strokeColor), jsonDefaults.Brush.strokeWidth),
3532
+ Brush: new Brush(Color['fromJSON'](jsonDefaults.Brush.fillColor), Color['fromJSON'](jsonDefaults.Brush.strokeColor), jsonDefaults.Brush.strokeWidth),
3659
3533
  LaserlineViewfinder: {
3660
- width: NumberWithUnit.fromJSON(JSON.parse(jsonDefaults.LaserlineViewfinder.width)),
3661
- enabledColor: Color.fromJSON(jsonDefaults.LaserlineViewfinder.enabledColor),
3662
- disabledColor: Color.fromJSON(jsonDefaults.LaserlineViewfinder.disabledColor),
3534
+ width: NumberWithUnit['fromJSON'](JSON.parse(jsonDefaults.LaserlineViewfinder.width)),
3535
+ enabledColor: Color['fromJSON'](jsonDefaults.LaserlineViewfinder.enabledColor),
3536
+ disabledColor: Color['fromJSON'](jsonDefaults.LaserlineViewfinder.disabledColor),
3663
3537
  },
3664
3538
  deviceID: jsonDefaults.deviceID,
3665
3539
  };
3666
3540
  // Inject defaults to avoid a circular dependency between these classes and the defaults
3667
- Brush.defaults = coreDefaults.Brush;
3541
+ Brush['defaults'] = coreDefaults.Brush;
3668
3542
  return coreDefaults;
3669
3543
  }
3670
3544
 
@@ -3744,17 +3618,20 @@ __decorate([
3744
3618
  ignoreFromSerializationIfNull
3745
3619
  ], Sound.prototype, "resource", void 0);
3746
3620
 
3747
- class FeedbackController {
3748
- constructor(feedback) {
3749
- this.feedback = feedback;
3750
- this._proxy = FactoryMaker.getInstance('FeedbackProxy');
3751
- }
3621
+ class FeedbackController extends BaseController {
3752
3622
  static forFeedback(feedback) {
3753
3623
  const controller = new FeedbackController(feedback);
3754
3624
  return controller;
3755
3625
  }
3626
+ constructor(feedback) {
3627
+ super('FeedbackProxy');
3628
+ this.feedback = feedback;
3629
+ }
3756
3630
  emit() {
3757
- this._proxy.emitFeedback(this.feedback);
3631
+ void this._proxy.$emitFeedback({ feedbackJson: JSON.stringify(this.feedback.toJSON()) });
3632
+ }
3633
+ dispose() {
3634
+ this._proxy.dispose();
3758
3635
  }
3759
3636
  }
3760
3637
 
@@ -3777,7 +3654,7 @@ class Feedback extends DefaultSerializeable {
3777
3654
  this._sound = null;
3778
3655
  this._vibration = vibration;
3779
3656
  this._sound = sound;
3780
- this.controller = FeedbackController.forFeedback(this);
3657
+ this.controller = new FeedbackController(this);
3781
3658
  }
3782
3659
  emit() {
3783
3660
  this.controller.emit();
@@ -3828,45 +3705,37 @@ class RectangularLocationSelection extends DefaultSerializeable {
3828
3705
  }
3829
3706
  static withSize(size) {
3830
3707
  const locationSelection = new RectangularLocationSelection();
3831
- locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect.sizeWithWidthAndHeight(size);
3708
+ locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect['sizeWithWidthAndHeight'](size);
3832
3709
  return locationSelection;
3833
3710
  }
3834
3711
  static withWidthAndAspectRatio(width, heightToWidthAspectRatio) {
3835
3712
  const locationSelection = new RectangularLocationSelection();
3836
- locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect
3837
- .sizeWithWidthAndAspectRatio(width, heightToWidthAspectRatio);
3713
+ locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect['sizeWithWidthAndAspectRatio'](width, heightToWidthAspectRatio);
3838
3714
  return locationSelection;
3839
3715
  }
3840
3716
  static withHeightAndAspectRatio(height, widthToHeightAspectRatio) {
3841
3717
  const locationSelection = new RectangularLocationSelection();
3842
- locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect
3843
- .sizeWithHeightAndAspectRatio(height, widthToHeightAspectRatio);
3718
+ locationSelection._sizeWithUnitAndAspect = SizeWithUnitAndAspect['sizeWithHeightAndAspectRatio'](height, widthToHeightAspectRatio);
3844
3719
  return locationSelection;
3845
3720
  }
3846
3721
  static fromJSON(rectangularLocationSelectionJSON) {
3847
3722
  if (rectangularLocationSelectionJSON.aspect.width && rectangularLocationSelectionJSON.aspect.height) {
3848
- const width = NumberWithUnit
3849
- .fromJSON(rectangularLocationSelectionJSON.aspect.width);
3850
- const height = NumberWithUnit
3851
- .fromJSON(rectangularLocationSelectionJSON.aspect.height);
3723
+ const width = NumberWithUnit['fromJSON'](rectangularLocationSelectionJSON.aspect.width);
3724
+ const height = NumberWithUnit['fromJSON'](rectangularLocationSelectionJSON.aspect.height);
3852
3725
  const size = new SizeWithUnit(width, height);
3853
3726
  return this.withSize(size);
3854
3727
  }
3855
3728
  else if (rectangularLocationSelectionJSON.aspect.width && rectangularLocationSelectionJSON.aspect.aspect) {
3856
- const width = NumberWithUnit
3857
- .fromJSON(rectangularLocationSelectionJSON.aspect.width);
3729
+ const width = NumberWithUnit['fromJSON'](rectangularLocationSelectionJSON.aspect.width);
3858
3730
  return this.withWidthAndAspectRatio(width, rectangularLocationSelectionJSON.aspect.aspect);
3859
3731
  }
3860
3732
  else if (rectangularLocationSelectionJSON.aspect.height && rectangularLocationSelectionJSON.aspect.aspect) {
3861
- const height = NumberWithUnit
3862
- .fromJSON(rectangularLocationSelectionJSON.aspect.height);
3733
+ const height = NumberWithUnit['fromJSON'](rectangularLocationSelectionJSON.aspect.height);
3863
3734
  return this.withHeightAndAspectRatio(height, rectangularLocationSelectionJSON.aspect.aspect);
3864
3735
  }
3865
3736
  else if (rectangularLocationSelectionJSON.aspect.shorterDimension && rectangularLocationSelectionJSON.aspect.aspect) {
3866
- const shorterDimension = NumberWithUnit
3867
- .fromJSON(rectangularLocationSelectionJSON.aspect.shorterDimension);
3868
- const sizeWithUnitAndAspect = SizeWithUnitAndAspect
3869
- .sizeWithShorterDimensionAndAspectRatio(shorterDimension, rectangularLocationSelectionJSON.aspect.aspect);
3737
+ const shorterDimension = NumberWithUnit['fromJSON'](rectangularLocationSelectionJSON.aspect.shorterDimension);
3738
+ const sizeWithUnitAndAspect = SizeWithUnitAndAspect['sizeWithShorterDimensionAndAspectRatio'](shorterDimension, rectangularLocationSelectionJSON.aspect.aspect);
3870
3739
  const locationSelection = new RectangularLocationSelection();
3871
3740
  locationSelection._sizeWithUnitAndAspect = sizeWithUnitAndAspect;
3872
3741
  return locationSelection;
@@ -3887,7 +3756,6 @@ class LicenseInfo extends DefaultSerializeable {
3887
3756
  }
3888
3757
  __decorate([
3889
3758
  nameForSerialization('expiration')
3890
- // @ts-ignore
3891
3759
  ], LicenseInfo.prototype, "_expiration", void 0);
3892
3760
 
3893
3761
  var Expiration;
@@ -3897,162 +3765,50 @@ var Expiration;
3897
3765
  Expiration["NotAvailable"] = "notAvailable";
3898
3766
  })(Expiration || (Expiration = {}));
3899
3767
 
3900
- class BaseInstanceAwareNativeProxy {
3901
- constructor() {
3902
- this.eventEmitter = new EventEmitter();
3903
- }
3904
- }
3905
-
3906
3768
  /**
3907
3769
  * JS Proxy hook to act as middleware to all the calls performed by an AdvancedNativeProxy instance
3908
3770
  * This will allow AdvancedNativeProxy to call dynamically the methods defined in the interface defined
3909
- * as parameter in createAdvancedNativeProxy function
3771
+ * as parameter in createNativeProxy function
3910
3772
  */
3911
- const advancedInstanceAwareNativeProxyHook = {
3773
+ const nativeProxyHook = {
3912
3774
  /**
3913
3775
  * Dynamic property getter for the AdvancedNativeProxy
3914
- * In order to call a native method this needs to be preceded by the `$` symbol on the name, ie `$methodName`
3915
- * In order to set a native event handler this needs to be preceded by `on$` prefix, ie `on$eventName`
3776
+ *
3777
+ * Prefix Conventions:
3778
+ * - `$methodName` - Regular native method calls (one-time execution)
3779
+ * - `$$methodName` - Event registration methods (persistent listeners)
3780
+ * - `on$eventName` - Event handler registration
3781
+ *
3782
+ * The `$$` prefix is used for methods that establish persistent event listeners on the native side
3783
+ * (using callbackContext.successAndKeepCallback() in Cordova). This enables automatic detection
3784
+ * in Cordova without requiring manual event configuration lists.
3785
+ *
3786
+ * Examples:
3787
+ * - `$$registerListenerForCameraEvents()` - Sets up persistent camera event listener
3788
+ * - `$unregisterListenerForCameraEvents()` - Regular call to cleanup (not persistent)
3789
+ * - `$getCurrentCameraState()` - Regular one-time native method call
3790
+ *
3916
3791
  * @param advancedNativeProxy
3917
3792
  * @param prop
3918
3793
  */
3919
- get(advancedNativeProxy, prop) {
3794
+ get(nativeProxy, prop) {
3920
3795
  // Early return if prop is not a string
3921
3796
  if (typeof prop !== 'string') {
3922
3797
  return undefined;
3923
3798
  }
3924
- // Important: $ and on$ are required since if they are not added all
3799
+ // Important: $, and $$ are required since if they are not added all
3925
3800
  // properties present on AdvancedNativeProxy will be redirected to the
3926
3801
  // advancedNativeProxy._call, which will call native even for the own
3927
3802
  // properties of the class
3928
- // All the methods with the following structure
3929
- // $methodName will be redirected to the special _call
3930
- // method on AdvancedNativeProxy
3931
- if (prop.startsWith("$")) {
3932
- if (prop in advancedNativeProxy) {
3933
- return advancedNativeProxy[prop];
3934
- }
3803
+ // Event registration methods with $$ prefix
3804
+ // These establish persistent event listeners (callbackContext.successAndKeepCallback())
3805
+ // and get special handling in Cordova to set up continuous event callbacks
3806
+ if (prop.startsWith("$$")) {
3935
3807
  return (args) => {
3936
- return advancedNativeProxy._call(prop.substring(1), args);
3808
+ const methodName = prop.substring(2);
3809
+ return nativeProxy._callEventRegistration(methodName, args);
3937
3810
  };
3938
- // All methods with the following structure
3939
- // on$methodName will trigger the event handler properties
3940
- }
3941
- else if (prop.startsWith("on$")) {
3942
- return advancedNativeProxy[prop.substring(3)];
3943
- // Everything else will be taken as a property
3944
- }
3945
- else {
3946
- return advancedNativeProxy[prop];
3947
- }
3948
- }
3949
- };
3950
- /**
3951
- * AdvancedNativeProxy will provide an easy way to communicate between native proxies
3952
- * and other parts of the architecture such as the controller layer
3953
- */
3954
- class AdvancedInstanceAwareNativeProxy extends BaseInstanceAwareNativeProxy {
3955
- constructor(nativeCaller, events = []) {
3956
- super();
3957
- this.nativeCaller = nativeCaller;
3958
- this.events = events;
3959
- this.eventSubscriptions = new Map();
3960
- this.eventHandlers = new Map();
3961
- this.events.forEach((event) => __awaiter(this, void 0, void 0, function* () {
3962
- yield this._registerEvent(event);
3963
- }));
3964
- // Wrapping the AdvancedNativeProxy instance with the JS proxy hook
3965
- return new Proxy(this, advancedInstanceAwareNativeProxyHook);
3966
- }
3967
- dispose() {
3968
- return __awaiter(this, void 0, void 0, function* () {
3969
- for (const event of this.events) {
3970
- yield this._unregisterEvent(event);
3971
- }
3972
- this.eventSubscriptions.clear();
3973
- this.events = [];
3974
- });
3975
- }
3976
- _call(fnName, args) {
3977
- return this.nativeCaller.callFn(fnName, args);
3978
- }
3979
- _registerEvent(event) {
3980
- return __awaiter(this, void 0, void 0, function* () {
3981
- const handler = (args) => __awaiter(this, void 0, void 0, function* () {
3982
- this.eventEmitter.emit(event.nativeEventName, args);
3983
- });
3984
- const instanceHandler = (args) => __awaiter(this, void 0, void 0, function* () {
3985
- try {
3986
- const hookArg = this.nativeCaller.eventHook(args);
3987
- yield this[`on$${event.name}`](hookArg);
3988
- }
3989
- catch (e) {
3990
- console.error(`Error while trying to execute handler for ${event.nativeEventName}`, e);
3991
- throw e;
3992
- }
3993
- });
3994
- // Store the instance-specific handler
3995
- this.eventHandlers.set(event.nativeEventName, instanceHandler);
3996
- this.eventEmitter.on(event.nativeEventName, instanceHandler);
3997
- const subscription = yield this.nativeCaller.registerEvent(event.nativeEventName, handler);
3998
- this.eventSubscriptions.set(event.name, subscription);
3999
- });
4000
- }
4001
- _unregisterEvent(event) {
4002
- return __awaiter(this, void 0, void 0, function* () {
4003
- const subscription = this.eventSubscriptions.get(event.name);
4004
- yield this.nativeCaller.unregisterEvent(event.nativeEventName, subscription);
4005
- // Get the instance-specific handler
4006
- const handler = this.eventHandlers.get(event.nativeEventName);
4007
- if (handler) {
4008
- // Remove only this instance's handler
4009
- this.eventEmitter.off(event.nativeEventName, handler);
4010
- this.eventHandlers.delete(event.nativeEventName);
4011
- }
4012
- this.eventSubscriptions.delete(event.name);
4013
- });
4014
- }
4015
- }
4016
- /**
4017
- * Function to create a custom AdvancedNativeProxy. This will return an object which will provide dynamically the
4018
- * methods specified in the PROXY interface.
4019
- *
4020
- * The Proxy interface implemented in order to call native methods will require a special mark
4021
- * `$methodName` for method calls
4022
- * `on$methodName` for the listeners added to the events defined in eventsEnum
4023
- * @param nativeCaller
4024
- * @param eventsEnum
4025
- */
4026
- function createAdvancedInstanceAwareNativeProxy(nativeCaller, eventsEnum = undefined) {
4027
- const eventsList = eventsEnum == null ? [] : Object.entries(eventsEnum).map(([key, value]) => ({
4028
- name: key,
4029
- nativeEventName: value
4030
- }));
4031
- return new AdvancedInstanceAwareNativeProxy(nativeCaller, eventsList);
4032
- }
4033
-
4034
- /**
4035
- * JS Proxy hook to act as middleware to all the calls performed by an AdvancedNativeProxy instance
4036
- * This will allow AdvancedNativeProxy to call dynamically the methods defined in the interface defined
4037
- * as parameter in createAdvancedNativeProxy function
4038
- */
4039
- const nativeProxyHook = {
4040
- /**
4041
- * Dynamic property getter for the AdvancedNativeProxy
4042
- * In order to call a native method this needs to be preceded by the `$` symbol on the name, ie `$methodName`
4043
- * In order to set a native event handler this needs to be preceded by `on$` prefix, ie `on$eventName`
4044
- * @param advancedNativeProxy
4045
- * @param prop
4046
- */
4047
- get(nativeProxy, prop) {
4048
- // Early return if prop is not a string
4049
- if (typeof prop !== 'string') {
4050
- return undefined;
4051
3811
  }
4052
- // Important: $ and on$ are required since if they are not added all
4053
- // properties present on AdvancedNativeProxy will be redirected to the
4054
- // advancedNativeProxy._call, which will call native even for the own
4055
- // properties of the class
4056
3812
  // All the methods with the following structure
4057
3813
  // $methodName will be redirected to the special _call
4058
3814
  // method on AdvancedNativeProxy
@@ -4069,15 +3825,16 @@ const nativeProxyHook = {
4069
3825
  }
4070
3826
  }
4071
3827
  };
4072
- class NativeProxy extends BaseInstanceAwareNativeProxy {
3828
+ class NativeProxy {
4073
3829
  constructor(nativeCaller) {
4074
- super();
3830
+ this.eventEmitter = new EventEmitter();
4075
3831
  this.nativeCaller = nativeCaller;
4076
3832
  this.eventSubscriptions = new Map();
4077
3833
  this.eventHandlers = new Map();
4078
3834
  // Create the cached handler once
4079
3835
  this.cachedEventHandler = (eventName) => (args) => __awaiter(this, void 0, void 0, function* () {
4080
3836
  this.eventEmitter.emit(eventName, args);
3837
+ return Promise.resolve();
4081
3838
  });
4082
3839
  // Wrapping the NativeProxy instance with the JS proxy hook
4083
3840
  return new Proxy(this, nativeProxyHook);
@@ -4119,6 +3876,9 @@ class NativeProxy extends BaseInstanceAwareNativeProxy {
4119
3876
  _call(fnName, args) {
4120
3877
  return this.nativeCaller.callFn(fnName, args);
4121
3878
  }
3879
+ _callEventRegistration(fnName, args) {
3880
+ return this.nativeCaller.callFn(fnName, args, { isEventRegistration: true });
3881
+ }
4122
3882
  _registerEvent(event) {
4123
3883
  return __awaiter(this, void 0, void 0, function* () {
4124
3884
  const handler = this.cachedEventHandler(event);
@@ -4138,7 +3898,34 @@ function createNativeProxy(nativeCaller) {
4138
3898
  return new NativeProxy(nativeCaller);
4139
3899
  }
4140
3900
 
4141
- createEventEmitter();
3901
+ function registerProxies(proxyTypeNames, provider) {
3902
+ proxyTypeNames.forEach(proxyType => {
3903
+ FactoryMaker.bindLazyInstance(proxyType, () => {
3904
+ const caller = provider.getNativeCaller(proxyType);
3905
+ return createNativeProxy(caller);
3906
+ });
3907
+ });
3908
+ }
3909
+
3910
+ const CORE_PROXY_TYPE_NAMES = [
3911
+ 'DataCaptureViewProxy',
3912
+ 'DataCaptureContextProxy',
3913
+ 'CameraProxy',
3914
+ 'ImageFrameSourceProxy',
3915
+ 'FeedbackProxy',
3916
+ ];
3917
+
3918
+ function registerCoreProxies(provider) {
3919
+ registerProxies(CORE_PROXY_TYPE_NAMES, provider);
3920
+ }
3921
+
3922
+ function generateIdentifier() {
3923
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
3924
+ const r = (Math.random() * 16) | 0;
3925
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
3926
+ return v.toString(16);
3927
+ });
3928
+ }
4142
3929
 
4143
- export { AdvancedInstanceAwareNativeProxy, AdvancedNativeProxy, AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseInstanceAwareNativeProxy, BaseNativeProxy, BaseNewController, Brush, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FontFamily, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, createAdvancedInstanceAwareNativeProxy, createAdvancedNativeFromCtorProxy, createAdvancedNativeProxy, createNativeProxy, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
3930
+ export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FontFamily, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, createNativeProxy, generateIdentifier, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, registerCoreProxies, registerProxies, serializationDefault };
4144
3931
  //# sourceMappingURL=index.js.map