scandit-datacapture-frameworks-core 8.4.0 → 8.5.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/__mocks__/Defaults.ts +61 -61
  2. package/__mocks__/ScanditDataCaptureCore.ts +7 -5
  3. package/dist/dts/LicenseInfo.d.ts +2 -2
  4. package/dist/dts/camera/Camera.d.ts +7 -7
  5. package/dist/dts/camera/CameraSettings.d.ts +5 -5
  6. package/dist/dts/camera/FocusGesture.d.ts +2 -2
  7. package/dist/dts/camera/FocusGestureListener.d.ts +2 -2
  8. package/dist/dts/camera/PinchToZoom.d.ts +4 -4
  9. package/dist/dts/camera/PrivateFocusGestureDeserializer.d.ts +1 -1
  10. package/dist/dts/camera/PrivateZoomGestureDeserializer.d.ts +1 -1
  11. package/dist/dts/camera/SwipeToZoom.d.ts +4 -4
  12. package/dist/dts/camera/TapToFocus.d.ts +5 -5
  13. package/dist/dts/camera/TorchSwitchControl.d.ts +2 -2
  14. package/dist/dts/camera/ZoomGesture.d.ts +1 -1
  15. package/dist/dts/camera/ZoomGestureListener.d.ts +1 -1
  16. package/dist/dts/camera/ZoomSwitchControl.d.ts +3 -3
  17. package/dist/dts/camera/controller/CameraController.d.ts +4 -4
  18. package/dist/dts/camera/index.d.ts +24 -24
  19. package/dist/dts/camerahelpers/CameraOwnershipHelper.d.ts +3 -3
  20. package/dist/dts/camerahelpers/CameraOwnershipManager.d.ts +2 -2
  21. package/dist/dts/camerahelpers/index.d.ts +8 -8
  22. package/dist/dts/common/Brush.d.ts +2 -2
  23. package/dist/dts/common/MarginsWithUnit.d.ts +2 -2
  24. package/dist/dts/common/NumberWithUnit.d.ts +2 -2
  25. package/dist/dts/common/Observable.d.ts +1 -1
  26. package/dist/dts/common/Payload.d.ts +3 -3
  27. package/dist/dts/common/Point.d.ts +1 -1
  28. package/dist/dts/common/PointWithUnit.d.ts +2 -2
  29. package/dist/dts/common/Quadrilateral.d.ts +2 -2
  30. package/dist/dts/common/Rect.d.ts +3 -3
  31. package/dist/dts/common/RectWithUnit.d.ts +3 -3
  32. package/dist/dts/common/ScanIntention.d.ts +3 -0
  33. package/dist/dts/common/ScanditIcon.d.ts +4 -4
  34. package/dist/dts/common/ScanditIconBuilder.d.ts +4 -4
  35. package/dist/dts/common/ScanditIconType.d.ts +5 -1
  36. package/dist/dts/common/SelectionMode.d.ts +5 -0
  37. package/dist/dts/common/Size.d.ts +1 -1
  38. package/dist/dts/common/SizeWithAspect.d.ts +2 -2
  39. package/dist/dts/common/SizeWithUnit.d.ts +2 -2
  40. package/dist/dts/common/SizeWithUnitAndAspect.d.ts +5 -5
  41. package/dist/dts/common/index.d.ts +57 -55
  42. package/dist/dts/context/DataCaptureComponent.d.ts +1 -1
  43. package/dist/dts/context/DataCaptureContextListener.d.ts +2 -2
  44. package/dist/dts/context/DataCaptureContextSettings.d.ts +3 -3
  45. package/dist/dts/context/DataCaptureMode.d.ts +2 -2
  46. package/dist/dts/context/index.d.ts +12 -12
  47. package/dist/dts/controllers/index.d.ts +1 -1
  48. package/dist/dts/defaults/CoreDefaults.d.ts +12 -3
  49. package/dist/dts/defaults/index.d.ts +3 -3
  50. package/dist/dts/defaults/loadCoreDefaults.d.ts +1 -1
  51. package/dist/dts/feedback/Sound.d.ts +1 -1
  52. package/dist/dts/feedback/Vibration.d.ts +3 -2
  53. package/dist/dts/feedback/VibrationType.d.ts +1 -0
  54. package/dist/dts/feedback/index.d.ts +7 -7
  55. package/dist/dts/frame/FrameData.d.ts +1 -1
  56. package/dist/dts/frame/FrameDataSettingsBuilder.d.ts +1 -1
  57. package/dist/dts/frame/FrameSource.d.ts +4 -4
  58. package/dist/dts/frame/FrameSourceListener.d.ts +2 -2
  59. package/dist/dts/frame/ImageFrameSource.d.ts +8 -7
  60. package/dist/dts/frame/MacroModeListener.d.ts +1 -1
  61. package/dist/dts/frame/TorchListener.d.ts +1 -1
  62. package/dist/dts/frame/index.d.ts +13 -13
  63. package/dist/dts/helpers/index.d.ts +1 -1
  64. package/dist/dts/locationselection/RadiusLocationSelection.d.ts +3 -3
  65. package/dist/dts/locationselection/RectangularLocationSelection.d.ts +3 -3
  66. package/dist/dts/locationselection/index.d.ts +6 -6
  67. package/dist/dts/proxies/NativeProxy.d.ts +2 -2
  68. package/dist/dts/proxies/index.d.ts +5 -5
  69. package/dist/dts/proxy-types.d.ts +1 -1
  70. package/dist/dts/serializable/DefaultSerializable.d.ts +1 -1
  71. package/dist/dts/serializable/index.d.ts +7 -7
  72. package/dist/dts/view/Control.d.ts +2 -2
  73. package/dist/dts/view/ControlImage.d.ts +1 -1
  74. package/dist/dts/view/DataCaptureOverlay.d.ts +2 -2
  75. package/dist/dts/view/DataCaptureViewController.d.ts +7 -7
  76. package/dist/dts/view/DataCaptureViewListener.d.ts +2 -2
  77. package/dist/dts/view/index.d.ts +7 -7
  78. package/dist/dts/viewfinder/AimerViewfinder.d.ts +3 -3
  79. package/dist/dts/viewfinder/LaserlineViewfinder.d.ts +3 -3
  80. package/dist/dts/viewfinder/RectangularViewfinderAnimation.d.ts +1 -1
  81. package/dist/dts/viewfinder/index.d.ts +9 -9
  82. package/dist/index.js +1696 -1651
  83. package/dist/index.js.map +1 -1
  84. package/jest.config.js +5 -15
  85. package/package.json +1 -1
  86. package/test/Camera.test.ts +18 -8
  87. package/test/CameraSettings.test.ts +340 -341
  88. package/test/ProxyRegistration.test.ts +6 -7
  89. package/test/ZoomSwitchControl.test.ts +100 -100
  90. package/test/generated/CoreProxyAdapter.test.ts +4 -7
package/dist/index.js CHANGED
@@ -391,11 +391,6 @@ class FactoryMaker {
391
391
  }
392
392
  FactoryMaker.instances = new Map();
393
393
 
394
- var FocusGestureListenerEvents;
395
- (function (FocusGestureListenerEvents) {
396
- FocusGestureListenerEvents["onFocusGesture"] = "FocusGestureListener.onFocusGesture";
397
- })(FocusGestureListenerEvents || (FocusGestureListenerEvents = {}));
398
-
399
394
  /******************************************************************************
400
395
  Copyright (c) Microsoft Corporation.
401
396
 
@@ -493,7 +488,7 @@ class DefaultSerializeable {
493
488
  }
494
489
  // Serialize the array if the elements are serializeable
495
490
  if (Array.isArray(value)) {
496
- value = value.map(e => e.toJSON ? e.toJSON() : e);
491
+ value = value.map(e => (e.toJSON ? e.toJSON() : e));
497
492
  }
498
493
  const propertyName = customPropertyNames[property] || property;
499
494
  json[propertyName] = value;
@@ -673,119 +668,6 @@ class PrivateZoomGestureDeserializer {
673
668
  }
674
669
  }
675
670
 
676
- var ZoomGestureListenerEvents;
677
- (function (ZoomGestureListenerEvents) {
678
- ZoomGestureListenerEvents["onZoomInGesture"] = "ZoomGestureListener.onZoomInGesture";
679
- ZoomGestureListenerEvents["onZoomOutGesture"] = "ZoomGestureListener.onZoomOutGesture";
680
- })(ZoomGestureListenerEvents || (ZoomGestureListenerEvents = {}));
681
-
682
- var CameraPosition;
683
- (function (CameraPosition) {
684
- CameraPosition["WorldFacing"] = "worldFacing";
685
- CameraPosition["UserFacing"] = "userFacing";
686
- CameraPosition["Unspecified"] = "unspecified";
687
- })(CameraPosition || (CameraPosition = {}));
688
-
689
- var FrameSourceListenerEvents;
690
- (function (FrameSourceListenerEvents) {
691
- FrameSourceListenerEvents["didChangeState"] = "FrameSourceListener.onStateChanged";
692
- })(FrameSourceListenerEvents || (FrameSourceListenerEvents = {}));
693
-
694
- var TorchListenerEvents;
695
- (function (TorchListenerEvents) {
696
- TorchListenerEvents["didChangeTorchToState"] = "TorchListener.onTorchStateChanged";
697
- })(TorchListenerEvents || (TorchListenerEvents = {}));
698
-
699
- var MacroModeListenerEvents;
700
- (function (MacroModeListenerEvents) {
701
- MacroModeListenerEvents["didChangeMacroMode"] = "MacroModeListener.onMacroModeChanged";
702
- })(MacroModeListenerEvents || (MacroModeListenerEvents = {}));
703
-
704
- var FrameSourceState;
705
- (function (FrameSourceState) {
706
- FrameSourceState["On"] = "on";
707
- FrameSourceState["Off"] = "off";
708
- FrameSourceState["Starting"] = "starting";
709
- FrameSourceState["Stopping"] = "stopping";
710
- FrameSourceState["Standby"] = "standby";
711
- FrameSourceState["BootingUp"] = "bootingUp";
712
- FrameSourceState["WakingUp"] = "wakingUp";
713
- FrameSourceState["GoingToSleep"] = "goingToSleep";
714
- FrameSourceState["ShuttingDown"] = "shuttingDown";
715
- })(FrameSourceState || (FrameSourceState = {}));
716
-
717
- class ImageBuffer {
718
- get width() {
719
- return this._width;
720
- }
721
- get height() {
722
- return this._height;
723
- }
724
- get data() {
725
- return this._data;
726
- }
727
- }
728
-
729
- class FrameDataSettings extends DefaultSerializeable {
730
- constructor() {
731
- super();
732
- // Enables the file system cache for the frame.
733
- this._isFileSystemCacheEnabled = false;
734
- // The quality of the image. 0-100.
735
- this._imageQuality = 100;
736
- // Enables the auto-rotation of the frame.
737
- this._isAutoRotateEnabled = false;
738
- }
739
- get isFileSystemCacheEnabled() {
740
- return this._isFileSystemCacheEnabled;
741
- }
742
- set isFileSystemCacheEnabled(enabled) {
743
- this._isFileSystemCacheEnabled = enabled;
744
- }
745
- get imageQuality() {
746
- return this._imageQuality;
747
- }
748
- set imageQuality(quality) {
749
- if (quality < 0 || quality > 100) {
750
- throw new Error('Image quality must be between 0 and 100');
751
- }
752
- this._imageQuality = quality;
753
- }
754
- get isAutoRotateEnabled() {
755
- return this._isAutoRotateEnabled;
756
- }
757
- set isAutoRotateEnabled(enabled) {
758
- this._isAutoRotateEnabled = enabled;
759
- }
760
- }
761
- __decorate([
762
- nameForSerialization('sc_frame_isFileSystemCacheEnabled')
763
- ], FrameDataSettings.prototype, "_isFileSystemCacheEnabled", void 0);
764
- __decorate([
765
- nameForSerialization('sc_frame_imageQuality')
766
- ], FrameDataSettings.prototype, "_imageQuality", void 0);
767
- __decorate([
768
- nameForSerialization('sc_frame_autoRotate')
769
- ], FrameDataSettings.prototype, "_isAutoRotateEnabled", void 0);
770
-
771
- class FrameDataSettingsBuilder {
772
- constructor(settings) {
773
- this.settings = settings;
774
- }
775
- enableFileSystemCache(enabled) {
776
- this.settings.isFileSystemCacheEnabled = enabled;
777
- return this;
778
- }
779
- setImageQuality(quality) {
780
- this.settings.imageQuality = quality;
781
- return this;
782
- }
783
- enableAutoRotate(enabled) {
784
- this.settings.isAutoRotateEnabled = enabled;
785
- return this;
786
- }
787
- }
788
-
789
671
  var FontFamily;
790
672
  (function (FontFamily) {
791
673
  FontFamily["SystemDefault"] = "systemDefault";
@@ -1087,6 +969,10 @@ var ScanditIconType;
1087
969
  ScanditIconType["InspectItem"] = "inspectItem";
1088
970
  ScanditIconType["StarOutlined"] = "starOutlined";
1089
971
  ScanditIconType["Print"] = "print";
972
+ ScanditIconType["Plus"] = "plus";
973
+ ScanditIconType["Minus"] = "minus";
974
+ ScanditIconType["Delete"] = "delete";
975
+ ScanditIconType["Slash"] = "slash";
1090
976
  })(ScanditIconType || (ScanditIconType = {}));
1091
977
 
1092
978
  class Size extends DefaultSerializeable {
@@ -1452,9 +1338,19 @@ var ScanIntention;
1452
1338
  (function (ScanIntention) {
1453
1339
  ScanIntention["Manual"] = "manual";
1454
1340
  ScanIntention["Smart"] = "smart";
1341
+ /**
1342
+ * @deprecated Use SelectionMode.Auto instead. Will be removed in 9.0.
1343
+ */
1455
1344
  ScanIntention["SmartSelection"] = "smartSelection";
1456
1345
  })(ScanIntention || (ScanIntention = {}));
1457
1346
 
1347
+ var SelectionMode;
1348
+ (function (SelectionMode) {
1349
+ SelectionMode["Off"] = "off";
1350
+ SelectionMode["On"] = "on";
1351
+ SelectionMode["Auto"] = "auto";
1352
+ })(SelectionMode || (SelectionMode = {}));
1353
+
1458
1354
  /**
1459
1355
  * Symbol returned by parseIfShouldHandle when an event should be skipped
1460
1356
  * (filtered out based on viewId/modeId mismatch).
@@ -1574,57 +1470,299 @@ class HTMLElementState {
1574
1470
  this.shouldBeUnderContent = false;
1575
1471
  }
1576
1472
  get isValid() {
1577
- return this.isShown !== undefined && this.isShown !== null
1578
- && this.position !== undefined && this.position !== null
1579
- && this.size !== undefined && this.size !== null
1580
- && this.shouldBeUnderContent !== undefined && this.shouldBeUnderContent !== null;
1473
+ return (this.isShown !== undefined &&
1474
+ this.isShown !== null &&
1475
+ this.position !== undefined &&
1476
+ this.position !== null &&
1477
+ this.size !== undefined &&
1478
+ this.size !== null &&
1479
+ this.shouldBeUnderContent !== undefined &&
1480
+ this.shouldBeUnderContent !== null);
1581
1481
  }
1582
1482
  didChangeComparedTo(other) {
1583
1483
  var _a, _b, _c, _d;
1584
1484
  if (!other)
1585
1485
  return true;
1586
- const positionChanged = (_b = (_a = this.position) === null || _a === void 0 ? void 0 : _a.didChangeComparedTo(other.position)) !== null && _b !== void 0 ? _b : (this.position !== other.position);
1587
- const sizeChanged = (_d = (_c = this.size) === null || _c === void 0 ? void 0 : _c.didChangeComparedTo(other.size)) !== null && _d !== void 0 ? _d : (this.size !== other.size);
1486
+ const positionChanged = (_b = (_a = this.position) === null || _a === void 0 ? void 0 : _a.didChangeComparedTo(other.position)) !== null && _b !== void 0 ? _b : this.position !== other.position;
1487
+ const sizeChanged = (_d = (_c = this.size) === null || _c === void 0 ? void 0 : _c.didChangeComparedTo(other.size)) !== null && _d !== void 0 ? _d : this.size !== other.size;
1588
1488
  return positionChanged || sizeChanged || this.shouldBeUnderContent !== other.shouldBeUnderContent;
1589
1489
  }
1590
1490
  }
1591
1491
 
1592
- class BaseController {
1593
- get _proxy() {
1594
- return this._cachedProxy;
1492
+ class RectangularViewfinderAnimation extends DefaultSerializeable {
1493
+ static fromJSON(json) {
1494
+ if (json === null) {
1495
+ return null;
1496
+ }
1497
+ return new RectangularViewfinderAnimation(json.looping);
1595
1498
  }
1596
- constructor(proxyName) {
1597
- this._cachedProxy = FactoryMaker.createInstance(proxyName);
1499
+ get isLooping() {
1500
+ return this._isLooping;
1501
+ }
1502
+ constructor(isLooping) {
1503
+ super();
1504
+ this._isLooping = false;
1505
+ this._isLooping = isLooping;
1598
1506
  }
1599
1507
  }
1508
+ __decorate([
1509
+ nameForSerialization('isLooping')
1510
+ ], RectangularViewfinderAnimation.prototype, "_isLooping", void 0);
1600
1511
 
1601
- /*
1602
- * This file is part of the Scandit Data Capture SDK
1603
- *
1604
- * Copyright (C) 2025- Scandit AG. All rights reserved.
1605
- */
1606
- /**
1607
- * Adapter class for Core operations.
1608
- * Provides typed methods that internally call $executeCore.
1609
- * Generated from schema definition to ensure parameter and method name consistency.
1610
- */
1611
- class CoreProxyAdapter {
1612
- constructor(proxy) {
1613
- this.proxy = proxy;
1512
+ // Capacitor returns nested values as already-parsed objects; other bridges (Cordova, RN) return JSON strings.
1513
+ function parseOrUse(value) {
1514
+ return typeof value === 'string' ? JSON.parse(value) : value;
1515
+ }
1516
+ function parseDefaults(jsonDefaults) {
1517
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1518
+ const coreDefaults = {
1519
+ Camera: {
1520
+ Settings: {
1521
+ preferredResolution: jsonDefaults.Camera.Settings.preferredResolution,
1522
+ zoomFactor: jsonDefaults.Camera.Settings.zoomFactor,
1523
+ focusRange: jsonDefaults.Camera.Settings.focusRange,
1524
+ zoomGestureZoomFactor: jsonDefaults.Camera.Settings.zoomGestureZoomFactor,
1525
+ zoomLevels: (_a = jsonDefaults.Camera.Settings.zoomLevels) !== null && _a !== void 0 ? _a : [1, 2],
1526
+ focusGestureStrategy: jsonDefaults.Camera.Settings.focusGestureStrategy,
1527
+ shouldPreferSmoothAutoFocus: jsonDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
1528
+ torchLevel: (_b = jsonDefaults.Camera.Settings.torchLevel) !== null && _b !== void 0 ? _b : 1.0,
1529
+ macroMode: ((_c = jsonDefaults.Camera.Settings.macroMode) !== null && _c !== void 0 ? _c : 'auto'),
1530
+ adaptiveExposure: (_d = jsonDefaults.Camera.Settings.adaptiveExposure) !== null && _d !== void 0 ? _d : false,
1531
+ manualLensPosition: (_e = jsonDefaults.Camera.Settings.manualLensPosition) !== null && _e !== void 0 ? _e : 0,
1532
+ focusStrategy: (_f = jsonDefaults.Camera.Settings.focusStrategy) !== null && _f !== void 0 ? _f : 'auto',
1533
+ properties: jsonDefaults.Camera.Settings.properties,
1534
+ },
1535
+ defaultPosition: (jsonDefaults.Camera.defaultPosition || null),
1536
+ availablePositions: jsonDefaults.Camera.availablePositions,
1537
+ },
1538
+ ZoomSwitchControl: {
1539
+ orientation: ((_h = (_g = jsonDefaults.ZoomSwitchControl) === null || _g === void 0 ? void 0 : _g.orientation) !== null && _h !== void 0 ? _h : 'horizontal'),
1540
+ isAlwaysExpanded: (_k = (_j = jsonDefaults.ZoomSwitchControl) === null || _j === void 0 ? void 0 : _j.isAlwaysExpanded) !== null && _k !== void 0 ? _k : false,
1541
+ isExpanded: (_m = (_l = jsonDefaults.ZoomSwitchControl) === null || _l === void 0 ? void 0 : _l.isExpanded) !== null && _m !== void 0 ? _m : false,
1542
+ accessibilityLabel: (_p = (_o = jsonDefaults.ZoomSwitchControl) === null || _o === void 0 ? void 0 : _o.accessibilityLabel) !== null && _p !== void 0 ? _p : 'Zoom <level>',
1543
+ accessibilityHint: (_r = (_q = jsonDefaults.ZoomSwitchControl) === null || _q === void 0 ? void 0 : _q.accessibilityHint) !== null && _r !== void 0 ? _r : 'Adjusts the camera zoom level',
1544
+ },
1545
+ DataCaptureView: {
1546
+ scanAreaMargins: MarginsWithUnit['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.scanAreaMargins)),
1547
+ pointOfInterest: PointWithUnit['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.pointOfInterest)),
1548
+ logoAnchor: jsonDefaults.DataCaptureView.logoAnchor,
1549
+ logoOffset: PointWithUnit['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.logoOffset)),
1550
+ focusGesture: PrivateFocusGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.focusGesture)),
1551
+ zoomGesture: PrivateZoomGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.zoomGesture)),
1552
+ zoomGestures: jsonDefaults.DataCaptureView.zoomGestures
1553
+ ? PrivateZoomGestureDeserializer['fromJSONArray'](parseOrUse(jsonDefaults.DataCaptureView.zoomGestures).map(parseOrUse))
1554
+ : PrivateZoomGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.zoomGesture)) != null
1555
+ ? [PrivateZoomGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.zoomGesture))]
1556
+ : [],
1557
+ logoStyle: jsonDefaults.DataCaptureView.logoStyle,
1558
+ shouldShowZoomNotification: jsonDefaults.DataCaptureView.shouldShowZoomNotification,
1559
+ },
1560
+ RectangularViewfinder: Object.keys(jsonDefaults.RectangularViewfinder.styles).reduce((acc, key) => {
1561
+ const viewfinder = jsonDefaults.RectangularViewfinder.styles[key];
1562
+ acc.styles[key] = {
1563
+ size: SizeWithUnitAndAspect['fromJSON'](parseOrUse(viewfinder.size)),
1564
+ color: Color['fromJSON'](viewfinder.color),
1565
+ disabledColor: Color['fromJSON'](viewfinder.disabledColor),
1566
+ style: viewfinder.style,
1567
+ lineStyle: viewfinder.lineStyle,
1568
+ dimming: viewfinder.dimming,
1569
+ disabledDimming: viewfinder.disabledDimming,
1570
+ animation: RectangularViewfinderAnimation['fromJSON'](parseOrUse(viewfinder.animation)),
1571
+ };
1572
+ return acc;
1573
+ }, { defaultStyle: jsonDefaults.RectangularViewfinder.defaultStyle, styles: {} }),
1574
+ AimerViewfinder: {
1575
+ frameColor: Color['fromJSON'](jsonDefaults.AimerViewfinder.frameColor),
1576
+ dotColor: Color['fromJSON'](jsonDefaults.AimerViewfinder.dotColor),
1577
+ },
1578
+ Brush: new Brush(Color['fromJSON'](jsonDefaults.Brush.fillColor), Color['fromJSON'](jsonDefaults.Brush.strokeColor), jsonDefaults.Brush.strokeWidth),
1579
+ LaserlineViewfinder: {
1580
+ width: NumberWithUnit['fromJSON'](parseOrUse(jsonDefaults.LaserlineViewfinder.width)),
1581
+ enabledColor: Color['fromJSON'](jsonDefaults.LaserlineViewfinder.enabledColor),
1582
+ disabledColor: Color['fromJSON'](jsonDefaults.LaserlineViewfinder.disabledColor),
1583
+ },
1584
+ deviceID: jsonDefaults.deviceID,
1585
+ };
1586
+ // Inject defaults to avoid a circular dependency between these classes and the defaults
1587
+ Brush['defaults'] = coreDefaults.Brush;
1588
+ return coreDefaults;
1589
+ }
1590
+
1591
+ let coreDefaultsLoader;
1592
+ function setCoreDefaultsLoader(loader) {
1593
+ coreDefaultsLoader = loader;
1594
+ }
1595
+ function ensureCoreDefaults() {
1596
+ var _a, _b;
1597
+ const existing = (_a = FactoryMaker.instances.get('CoreDefaults')) === null || _a === void 0 ? void 0 : _a.instance;
1598
+ if (existing) {
1599
+ return existing;
1614
1600
  }
1615
- /**
1616
- * Gets the camera state for a given position
1617
- * @param cameraPosition Camera position as JSON string
1618
- */
1619
- getCameraState(_a) {
1620
- return __awaiter(this, arguments, void 0, function* ({ cameraPosition }) {
1621
- const result = yield this.proxy.$executeCore({
1622
- moduleName: 'CoreModule',
1623
- methodName: 'getCameraState',
1624
- isEventRegistration: false,
1625
- cameraPosition,
1626
- });
1627
- return JSON.parse(result.data);
1601
+ coreDefaultsLoader === null || coreDefaultsLoader === void 0 ? void 0 : coreDefaultsLoader();
1602
+ const reloaded = (_b = FactoryMaker.instances.get('CoreDefaults')) === null || _b === void 0 ? void 0 : _b.instance;
1603
+ if (reloaded) {
1604
+ return reloaded;
1605
+ }
1606
+ throw new Error('CoreDefaults missing and re-init failed');
1607
+ }
1608
+ function loadCoreDefaults(jsonDefaults) {
1609
+ const coreDefaults = parseDefaults(jsonDefaults);
1610
+ FactoryMaker.bindInstanceIfNotExists('CoreDefaults', coreDefaults);
1611
+ }
1612
+
1613
+ function getCoreDefaults() {
1614
+ return ensureCoreDefaults();
1615
+ }
1616
+
1617
+ class ContextStatus {
1618
+ static fromJSON(json) {
1619
+ const status = new ContextStatus();
1620
+ status._code = json.code;
1621
+ status._message = json.message;
1622
+ status._isValid = json.isValid;
1623
+ return status;
1624
+ }
1625
+ get message() {
1626
+ return this._message;
1627
+ }
1628
+ get code() {
1629
+ return this._code;
1630
+ }
1631
+ get isValid() {
1632
+ return this._isValid;
1633
+ }
1634
+ }
1635
+
1636
+ class FrameDataSettings extends DefaultSerializeable {
1637
+ constructor() {
1638
+ super();
1639
+ // Enables the file system cache for the frame.
1640
+ this._isFileSystemCacheEnabled = false;
1641
+ // The quality of the image. 0-100.
1642
+ this._imageQuality = 100;
1643
+ // Enables the auto-rotation of the frame.
1644
+ this._isAutoRotateEnabled = false;
1645
+ }
1646
+ get isFileSystemCacheEnabled() {
1647
+ return this._isFileSystemCacheEnabled;
1648
+ }
1649
+ set isFileSystemCacheEnabled(enabled) {
1650
+ this._isFileSystemCacheEnabled = enabled;
1651
+ }
1652
+ get imageQuality() {
1653
+ return this._imageQuality;
1654
+ }
1655
+ set imageQuality(quality) {
1656
+ if (quality < 0 || quality > 100) {
1657
+ throw new Error('Image quality must be between 0 and 100');
1658
+ }
1659
+ this._imageQuality = quality;
1660
+ }
1661
+ get isAutoRotateEnabled() {
1662
+ return this._isAutoRotateEnabled;
1663
+ }
1664
+ set isAutoRotateEnabled(enabled) {
1665
+ this._isAutoRotateEnabled = enabled;
1666
+ }
1667
+ }
1668
+ __decorate([
1669
+ nameForSerialization('sc_frame_isFileSystemCacheEnabled')
1670
+ ], FrameDataSettings.prototype, "_isFileSystemCacheEnabled", void 0);
1671
+ __decorate([
1672
+ nameForSerialization('sc_frame_imageQuality')
1673
+ ], FrameDataSettings.prototype, "_imageQuality", void 0);
1674
+ __decorate([
1675
+ nameForSerialization('sc_frame_autoRotate')
1676
+ ], FrameDataSettings.prototype, "_isAutoRotateEnabled", void 0);
1677
+
1678
+ class FrameDataSettingsBuilder {
1679
+ constructor(settings) {
1680
+ this.settings = settings;
1681
+ }
1682
+ enableFileSystemCache(enabled) {
1683
+ this.settings.isFileSystemCacheEnabled = enabled;
1684
+ return this;
1685
+ }
1686
+ setImageQuality(quality) {
1687
+ this.settings.imageQuality = quality;
1688
+ return this;
1689
+ }
1690
+ enableAutoRotate(enabled) {
1691
+ this.settings.isAutoRotateEnabled = enabled;
1692
+ return this;
1693
+ }
1694
+ }
1695
+
1696
+ class DataCaptureContextSettings extends DefaultSerializeable {
1697
+ constructor() {
1698
+ super();
1699
+ this._frameSettings = new FrameDataSettings();
1700
+ }
1701
+ get frameDataSettings() {
1702
+ return this._frameSettings;
1703
+ }
1704
+ set frameDataSettings(settings) {
1705
+ this._frameSettings = settings;
1706
+ }
1707
+ frameDataSettingsBuilder() {
1708
+ return new FrameDataSettingsBuilder(this._frameSettings);
1709
+ }
1710
+ setProperty(name, value) {
1711
+ this[name] = value;
1712
+ }
1713
+ getProperty(name) {
1714
+ return this[name];
1715
+ }
1716
+ }
1717
+ __decorate([
1718
+ nameForSerialization('frameDataSettings')
1719
+ ], DataCaptureContextSettings.prototype, "_frameSettings", void 0);
1720
+
1721
+ class OpenSourceSoftwareLicenseInfo {
1722
+ constructor(licenseText) {
1723
+ this._licenseText = licenseText;
1724
+ }
1725
+ get licenseText() {
1726
+ return this._licenseText;
1727
+ }
1728
+ }
1729
+
1730
+ class BaseController {
1731
+ get _proxy() {
1732
+ return this._cachedProxy;
1733
+ }
1734
+ constructor(proxyName) {
1735
+ this._cachedProxy = FactoryMaker.createInstance(proxyName);
1736
+ }
1737
+ }
1738
+
1739
+ /*
1740
+ * This file is part of the Scandit Data Capture SDK
1741
+ *
1742
+ * Copyright (C) 2025- Scandit AG. All rights reserved.
1743
+ */
1744
+ /**
1745
+ * Adapter class for Core operations.
1746
+ * Provides typed methods that internally call $executeCore.
1747
+ * Generated from schema definition to ensure parameter and method name consistency.
1748
+ */
1749
+ class CoreProxyAdapter {
1750
+ constructor(proxy) {
1751
+ this.proxy = proxy;
1752
+ }
1753
+ /**
1754
+ * Gets the camera state for a given position
1755
+ * @param cameraPosition Camera position as JSON string
1756
+ */
1757
+ getCameraState(_a) {
1758
+ return __awaiter(this, arguments, void 0, function* ({ cameraPosition }) {
1759
+ const result = yield this.proxy.$executeCore({
1760
+ moduleName: 'CoreModule',
1761
+ methodName: 'getCameraState',
1762
+ isEventRegistration: false,
1763
+ cameraPosition,
1764
+ });
1765
+ return JSON.parse(result.data);
1628
1766
  });
1629
1767
  }
1630
1768
  /**
@@ -2151,926 +2289,740 @@ class CoreProxyAdapter {
2151
2289
  }
2152
2290
  }
2153
2291
 
2154
- class ImageFrameSourceController extends BaseController {
2155
- constructor(imageFrameSource) {
2156
- super('CoreProxy');
2157
- this.handleDidChangeStateEventWrapper = (ev) => {
2158
- return this.handleDidChangeStateEvent(ev);
2159
- };
2160
- this.imageFrameSource = imageFrameSource;
2161
- this.adapter = new CoreProxyAdapter(this._proxy);
2162
- void this.subscribeListener();
2292
+ var DataCaptureContextEvents;
2293
+ (function (DataCaptureContextEvents) {
2294
+ DataCaptureContextEvents["didChangeStatus"] = "DataCaptureContextListener.onStatusChanged";
2295
+ DataCaptureContextEvents["didStartObservingContext"] = "DataCaptureContextListener.onObservationStarted";
2296
+ })(DataCaptureContextEvents || (DataCaptureContextEvents = {}));
2297
+ class DataCaptureContextController extends BaseController {
2298
+ get framework() {
2299
+ return this._proxy.framework;
2163
2300
  }
2164
- get privateImageFrameSource() {
2165
- return this.imageFrameSource;
2301
+ get frameworkVersion() {
2302
+ return this._proxy.frameworkVersion;
2166
2303
  }
2167
- getCurrentState() {
2168
- return __awaiter(this, void 0, void 0, function* () {
2169
- return yield this.adapter.getCameraState({
2170
- cameraPosition: JSON.stringify(this.privateImageFrameSource.position),
2171
- });
2172
- });
2304
+ get privateContext() {
2305
+ return this.context;
2173
2306
  }
2174
- switchCameraToDesiredState(desiredStateJson) {
2307
+ static forDataCaptureContext(context) {
2308
+ return new DataCaptureContextController(context);
2309
+ }
2310
+ static getOpenSourceSoftwareLicenseInfo() {
2175
2311
  return __awaiter(this, void 0, void 0, function* () {
2176
- yield this.adapter.switchCameraToDesiredState({
2177
- stateJson: desiredStateJson,
2178
- });
2312
+ const proxy = FactoryMaker.getInstance('CoreProxy');
2313
+ if (!proxy) {
2314
+ return new OpenSourceSoftwareLicenseInfo('Unable to load the open source software license info.');
2315
+ }
2316
+ const adapter = new CoreProxyAdapter(proxy);
2317
+ const result = yield adapter.getOpenSourceSoftwareLicenseInfo();
2318
+ return new OpenSourceSoftwareLicenseInfo(result);
2179
2319
  });
2180
2320
  }
2321
+ constructor(context) {
2322
+ super('DataCaptureContextProxy');
2323
+ this._listenerRegistered = false;
2324
+ this.adapter = new CoreProxyAdapter(this._proxy);
2325
+ this.context = context;
2326
+ }
2181
2327
  subscribeListener() {
2182
2328
  return __awaiter(this, void 0, void 0, function* () {
2183
- yield this.adapter.registerFrameSourceListener();
2184
- this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
2185
- this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
2329
+ if (this._listenerRegistered) {
2330
+ return;
2331
+ }
2332
+ yield this.adapter.subscribeContextListener();
2333
+ this._proxy.subscribeForEvents(Object.values(DataCaptureContextEvents));
2334
+ this._proxy.eventEmitter.on(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
2335
+ this._proxy.eventEmitter.on(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
2336
+ this._listenerRegistered = true;
2186
2337
  });
2187
2338
  }
2188
- unsubscribeListener() {
2339
+ updateContextFromJSON() {
2189
2340
  return __awaiter(this, void 0, void 0, function* () {
2190
- yield this.adapter.unregisterFrameSourceListener();
2191
- this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
2192
- this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
2341
+ try {
2342
+ yield this.adapter.updateContextFromJson({ contextJson: JSON.stringify(this.context.toJSON()) });
2343
+ }
2344
+ catch (error) {
2345
+ this.notifyListenersOfDeserializationError(error);
2346
+ throw error;
2347
+ }
2193
2348
  });
2194
2349
  }
2350
+ addModeToContext(mode) {
2351
+ return this.adapter.addModeToContext({ modeJson: JSON.stringify(mode.toJSON()) });
2352
+ }
2353
+ removeModeFromContext(mode) {
2354
+ return this.adapter.removeModeFromContext({ modeJson: JSON.stringify(mode.toJSON()) });
2355
+ }
2356
+ removeAllModesFromContext() {
2357
+ return this.adapter.removeAllModes();
2358
+ }
2195
2359
  dispose() {
2196
2360
  void this.unsubscribeListener();
2361
+ void this.adapter.disposeContext();
2197
2362
  this._proxy.dispose();
2198
2363
  }
2199
- handleDidChangeStateEvent(ev) {
2200
- const event = EventDataParser.parseIfShouldHandle(ev, {});
2201
- if (event === SKIP) {
2202
- return;
2203
- }
2204
- if (event === null) {
2205
- console.error('ImageFrameSourceController didChangeState payload is null');
2206
- return;
2364
+ unsubscribeListener() {
2365
+ return __awaiter(this, void 0, void 0, function* () {
2366
+ if (!this._listenerRegistered) {
2367
+ return;
2368
+ }
2369
+ yield this.adapter.unsubscribeContextListener();
2370
+ this._proxy.unsubscribeFromEvents(Object.values(DataCaptureContextEvents));
2371
+ this._proxy.eventEmitter.off(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
2372
+ this._proxy.eventEmitter.off(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
2373
+ this._listenerRegistered = false;
2374
+ });
2375
+ }
2376
+ initialize() {
2377
+ return this.initializeContextFromJSON();
2378
+ }
2379
+ initializeContextFromJSON() {
2380
+ return __awaiter(this, void 0, void 0, function* () {
2381
+ try {
2382
+ yield this.adapter.createContextFromJson({ contextJson: JSON.stringify(this.context.toJSON()) });
2383
+ }
2384
+ catch (error) {
2385
+ this.notifyListenersOfDeserializationError(error);
2386
+ throw error;
2387
+ }
2388
+ });
2389
+ }
2390
+ handleDidChangeStatusEvent(eventPayload) {
2391
+ const event = EventDataParser.parseIfShouldHandle(eventPayload, {});
2392
+ if (event === SKIP) {
2393
+ return;
2207
2394
  }
2208
- const newState = event.state;
2209
- this.privateImageFrameSource.listeners.forEach(listener => {
2210
- if (listener.didChangeState) {
2211
- listener.didChangeState(this.imageFrameSource, newState);
2395
+ if (event === null) {
2396
+ console.error('DataCaptureContextController didChangeStatus payload is null');
2397
+ return;
2398
+ }
2399
+ const contextStatus = ContextStatus['fromJSON'](JSON.parse(event.status));
2400
+ this.notifyListenersOfDidChangeStatus(contextStatus);
2401
+ }
2402
+ handleDidStartObservingContextEvent() {
2403
+ this.privateContext.listeners.forEach(listener => {
2404
+ var _a;
2405
+ (_a = listener.didStartObservingContext) === null || _a === void 0 ? void 0 : _a.call(listener, this.context);
2406
+ });
2407
+ }
2408
+ notifyListenersOfDeserializationError(error) {
2409
+ const contextStatus = ContextStatus['fromJSON']({
2410
+ message: error,
2411
+ code: -1,
2412
+ isValid: true,
2413
+ });
2414
+ this.notifyListenersOfDidChangeStatus(contextStatus);
2415
+ }
2416
+ notifyListenersOfDidChangeStatus(contextStatus) {
2417
+ this.privateContext.listeners.forEach(listener => {
2418
+ if (listener.didChangeStatus) {
2419
+ listener.didChangeStatus(this.context, contextStatus);
2212
2420
  }
2213
2421
  });
2214
2422
  }
2215
2423
  }
2216
2424
 
2217
- class ImageFrameSource extends DefaultSerializeable {
2218
- set context(newContext) {
2219
- if (newContext == null) {
2220
- void this.controller.unsubscribeListener();
2221
- }
2222
- else if (this._context == null) {
2223
- void this.controller.subscribeListener();
2425
+ class DataCaptureContext extends DefaultSerializeable {
2426
+ static get sharedInstance() {
2427
+ if (DataCaptureContext._instance == null) {
2428
+ DataCaptureContext._instance = new DataCaptureContext('', '', null);
2224
2429
  }
2225
- this._context = newContext;
2430
+ return DataCaptureContext._instance;
2226
2431
  }
2227
- get context() {
2228
- return this._context;
2432
+ static getOpenSourceSoftwareLicenseInfo() {
2433
+ return __awaiter(this, void 0, void 0, function* () {
2434
+ return DataCaptureContextController.getOpenSourceSoftwareLicenseInfo();
2435
+ });
2229
2436
  }
2230
- get desiredState() {
2231
- return this._desiredState;
2437
+ static get coreDefaults() {
2438
+ return getCoreDefaults();
2232
2439
  }
2233
- static create(image) {
2234
- const imageFrameSource = new ImageFrameSource();
2235
- imageFrameSource.image = image;
2236
- return imageFrameSource;
2440
+ get frameSource() {
2441
+ return this._frameSource;
2237
2442
  }
2238
- static fromJSON(json) {
2239
- return ImageFrameSource.create(json.image);
2443
+ static get deviceID() {
2444
+ return DataCaptureContext.coreDefaults.deviceID;
2240
2445
  }
2241
- constructor() {
2242
- super();
2243
- this.type = 'image';
2244
- this.image = '';
2245
- this._id = `${Date.now()}`;
2246
- this._desiredState = FrameSourceState.Off;
2247
- this.listeners = [];
2248
- this._context = null;
2249
- this.controller = new ImageFrameSourceController(this);
2446
+ static forLicenseKey(licenseKey) {
2447
+ const instance = DataCaptureContext.create(licenseKey, null, null);
2448
+ // Call initialize to ensure the shared instance is updated.
2449
+ void instance.controller.initialize();
2450
+ return instance;
2250
2451
  }
2251
- switchToDesiredState(state) {
2252
- this._desiredState = state;
2253
- return this.controller.switchCameraToDesiredState(state);
2452
+ static forLicenseKeyWithSettings(licenseKey, settings) {
2453
+ const instance = DataCaptureContext.create(licenseKey, null, settings);
2454
+ // Call initialize to ensure the shared instance is updated.
2455
+ void instance.controller.initialize();
2456
+ return instance;
2254
2457
  }
2255
- addListener(listener) {
2256
- if (listener == null) {
2257
- return;
2258
- }
2259
- if (this.listeners.includes(listener)) {
2260
- return;
2261
- }
2262
- this.listeners.push(listener);
2458
+ static forLicenseKeyWithOptions(licenseKey, options) {
2459
+ const instance = DataCaptureContext.create(licenseKey, options, null);
2460
+ // Call initialize to ensure the shared instance is updated.
2461
+ void instance.controller.initialize();
2462
+ return instance;
2263
2463
  }
2264
- removeListener(listener) {
2265
- if (listener == null) {
2266
- return;
2267
- }
2268
- if (!this.listeners.includes(listener)) {
2269
- return;
2270
- }
2271
- this.listeners.splice(this.listeners.indexOf(listener), 1);
2464
+ static initialize(licenseKey, options = null, settings = null) {
2465
+ DataCaptureContext.create(licenseKey, options, settings);
2466
+ void DataCaptureContext.sharedInstance.controller.initialize();
2467
+ return DataCaptureContext.sharedInstance;
2272
2468
  }
2273
- getCurrentState() {
2274
- return this.controller.getCurrentState();
2469
+ static create(licenseKey, options, settings) {
2470
+ DataCaptureContext.sharedInstance.licenseKey = licenseKey;
2471
+ DataCaptureContext.sharedInstance.deviceName = (options === null || options === void 0 ? void 0 : options.deviceName) || '';
2472
+ DataCaptureContext.sharedInstance.settings = settings || new DataCaptureContextSettings();
2473
+ return DataCaptureContext.sharedInstance;
2275
2474
  }
2276
- didChange() {
2277
- if (this.context) {
2278
- return this.context.update();
2475
+ constructor(licenseKey, deviceName, settings) {
2476
+ super();
2477
+ this.licenseKey = licenseKey;
2478
+ this.deviceName = deviceName;
2479
+ this._framework = 'unknown';
2480
+ this._frameworkVersion = 'unknown';
2481
+ this.settings = new DataCaptureContextSettings();
2482
+ this._frameSource = null;
2483
+ this.view = null;
2484
+ this.modes = [];
2485
+ this.listeners = [];
2486
+ this.licenseKey = licenseKey;
2487
+ this.deviceName = deviceName;
2488
+ if (settings) {
2489
+ this.settings = settings;
2279
2490
  }
2280
- else {
2281
- return Promise.resolve();
2491
+ if (this.controller == null) {
2492
+ this.controller = DataCaptureContextController.forDataCaptureContext(this);
2493
+ this._framework = this.controller.framework;
2494
+ this._frameworkVersion = this.controller.frameworkVersion;
2282
2495
  }
2283
2496
  }
2284
- }
2285
- __decorate([
2286
- nameForSerialization('id')
2287
- ], ImageFrameSource.prototype, "_id", void 0);
2288
- __decorate([
2289
- nameForSerialization('desiredState')
2290
- ], ImageFrameSource.prototype, "_desiredState", void 0);
2291
- __decorate([
2292
- ignoreFromSerialization
2293
- ], ImageFrameSource.prototype, "listeners", void 0);
2294
- __decorate([
2295
- ignoreFromSerialization
2296
- ], ImageFrameSource.prototype, "_context", void 0);
2297
- __decorate([
2298
- ignoreFromSerialization
2299
- ], ImageFrameSource.prototype, "controller", void 0);
2300
-
2301
- class PrivateFrameData {
2302
- get imageBuffers() {
2303
- return this._imageBuffers;
2497
+ setFrameSource(frameSource) {
2498
+ return __awaiter(this, void 0, void 0, function* () {
2499
+ if (this._frameSource) {
2500
+ this._frameSource.context = null;
2501
+ }
2502
+ this._frameSource = frameSource;
2503
+ if (frameSource) {
2504
+ // Set the flag to indicate that the native frame source is being created
2505
+ frameSource.setNativeFrameSourceIsBeingCreated();
2506
+ }
2507
+ yield this.update();
2508
+ // Make camera active once the set on native side is complete
2509
+ if (frameSource) {
2510
+ frameSource.context = this;
2511
+ }
2512
+ });
2304
2513
  }
2305
- get imageBuffer() {
2306
- return this._imageBuffers[0];
2514
+ addListener(listener) {
2515
+ return __awaiter(this, void 0, void 0, function* () {
2516
+ if (this.listeners.length === 0) {
2517
+ yield this.controller.subscribeListener();
2518
+ }
2519
+ if (this.listeners.includes(listener)) {
2520
+ return;
2521
+ }
2522
+ this.listeners.push(listener);
2523
+ });
2307
2524
  }
2308
- get orientation() {
2309
- return this._orientation;
2525
+ removeListener(listener) {
2526
+ return __awaiter(this, void 0, void 0, function* () {
2527
+ if (!this.listeners.includes(listener)) {
2528
+ return;
2529
+ }
2530
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
2531
+ if (this.listeners.length === 0) {
2532
+ return this.controller.unsubscribeListener();
2533
+ }
2534
+ });
2310
2535
  }
2311
- get timestamp() {
2312
- return this._timestamp;
2536
+ addMode(mode) {
2537
+ return __awaiter(this, void 0, void 0, function* () {
2538
+ yield this.addModeInternal(mode);
2539
+ });
2313
2540
  }
2314
- static fromJSON(json) {
2315
- var _a;
2316
- const frameData = new PrivateFrameData();
2317
- frameData._imageBuffers = json.imageBuffers.map((imageBufferJSON) => {
2318
- const imageBuffer = new ImageBuffer();
2319
- imageBuffer._width = imageBufferJSON.width;
2320
- imageBuffer._height = imageBufferJSON.height;
2321
- imageBuffer._data = imageBufferJSON.data;
2322
- return imageBuffer;
2541
+ setMode(mode) {
2542
+ return __awaiter(this, void 0, void 0, function* () {
2543
+ yield this.removeAllModes();
2544
+ yield this.addModeInternal(mode);
2323
2545
  });
2324
- frameData._orientation = json.orientation;
2325
- frameData._timestamp = (_a = json.timestamp) !== null && _a !== void 0 ? _a : -1;
2326
- return frameData;
2327
2546
  }
2328
- static empty() {
2329
- const frameData = new PrivateFrameData();
2330
- frameData._imageBuffers = [];
2331
- frameData._orientation = 90;
2332
- frameData._timestamp = -1;
2333
- return frameData;
2334
- }
2335
- }
2336
-
2337
- var TorchState;
2338
- (function (TorchState) {
2339
- TorchState["On"] = "on";
2340
- TorchState["Off"] = "off";
2341
- TorchState["Auto"] = "auto";
2342
- })(TorchState || (TorchState = {}));
2343
-
2344
- /**
2345
- * Camera lifecycle and operation handling:
2346
- *
2347
- * Phase 1 - Initial State (before native creation starts):
2348
- * - Camera object exists in TypeScript but not yet being created on native side
2349
- * - State changes (torch, desired state, settings) only update TypeScript properties
2350
- * - No native calls are triggered
2351
- *
2352
- * Phase 2 - Native Creation In Progress (after setFrameSource, before context set):
2353
- * - setFrameSource() called on DataCaptureContext, triggering setNativeFrameSourceIsBeingCreated()
2354
- * - A promise is created that will resolve when the native camera is ready
2355
- * - State changes during this phase await the native ready promise before executing
2356
- * - Native camera is created asynchronously
2357
- *
2358
- * Phase 3 - Active State (after context set):
2359
- * - Native camera is ready and available
2360
- * - The native ready promise is resolved
2361
- * - All state changes execute immediately on native side
2362
- */
2363
- class Camera extends DefaultSerializeable {
2364
- static get coreDefaults() {
2365
- return getCoreDefaults();
2366
- }
2367
- static create(position, settings, desiredTorchState, desiredState) {
2368
- const cameraPosition = position || Camera.coreDefaults.Camera.defaultPosition;
2369
- if (!cameraPosition) {
2370
- return null;
2371
- }
2372
- const existingCamera = Camera._cameraInstances.get(cameraPosition);
2373
- if (existingCamera) {
2374
- existingCamera.resetPhaseState();
2375
- if (settings !== undefined) {
2376
- existingCamera.settings = settings;
2377
- }
2378
- if (desiredTorchState !== undefined) {
2379
- existingCamera._desiredTorchState = desiredTorchState;
2380
- void existingCamera.didChange();
2547
+ removeCurrentMode() {
2548
+ return __awaiter(this, void 0, void 0, function* () {
2549
+ if (this.modes.length === 0) {
2550
+ return;
2381
2551
  }
2382
- if (desiredState !== undefined) {
2383
- existingCamera._desiredState = desiredState;
2384
- void existingCamera.controller.switchCameraToDesiredState(desiredState);
2552
+ if (this.modes.length > 1) {
2553
+ console.warn('removeCurrentMode() called with multiple modes active. Consider using removeMode() for specific mode removal. Only the first mode will be removed.');
2385
2554
  }
2386
- return existingCamera;
2387
- }
2388
- if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
2389
- return null;
2390
- }
2391
- const camera = new Camera(cameraPosition, settings, desiredTorchState, desiredState);
2392
- Camera._cameraInstances.set(cameraPosition, camera);
2393
- return camera;
2555
+ yield this.removeModeInternal(this.modes[0]);
2556
+ });
2394
2557
  }
2395
- static withSettings(settings) {
2396
- return Camera.create(undefined, settings);
2558
+ removeMode(mode) {
2559
+ return __awaiter(this, void 0, void 0, function* () {
2560
+ yield this.removeModeInternal(mode);
2561
+ });
2397
2562
  }
2398
- static asPositionWithSettings(cameraPosition, settings) {
2399
- return Camera.create(cameraPosition, settings);
2563
+ removeAllModes() {
2564
+ return __awaiter(this, void 0, void 0, function* () {
2565
+ if (this.modes.length === 0) {
2566
+ return;
2567
+ }
2568
+ this.modes.forEach(mode => {
2569
+ mode._context = null;
2570
+ });
2571
+ this.modes = [];
2572
+ yield this.controller.removeAllModesFromContext();
2573
+ });
2400
2574
  }
2401
- static atPosition(cameraPosition) {
2402
- if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
2403
- return null;
2404
- }
2405
- const existingCamera = Camera._cameraInstances.get(cameraPosition);
2406
- if (existingCamera) {
2407
- return existingCamera;
2408
- }
2409
- return Camera.create(cameraPosition);
2575
+ dispose() {
2576
+ return __awaiter(this, void 0, void 0, function* () {
2577
+ var _a;
2578
+ if (!this.controller) {
2579
+ return;
2580
+ }
2581
+ (_a = this.view) === null || _a === void 0 ? void 0 : _a.dispose();
2582
+ yield this.removeAllModes();
2583
+ this.controller.dispose();
2584
+ });
2410
2585
  }
2411
- constructor(position, settings, desiredTorchState, desiredState) {
2412
- super();
2413
- this.type = 'camera';
2414
- this.settings = null;
2415
- this._desiredTorchState = TorchState.Off;
2416
- this._desiredState = FrameSourceState.Off;
2417
- this._hasTorchStateListeners = false;
2418
- this._hasMacroModeListeners = false;
2419
- this.currentCameraState = FrameSourceState.Off;
2420
- this.listeners = [];
2421
- this.torchListeners = [];
2422
- this.macroModeListeners = [];
2423
- this.zoomListeners = [];
2424
- this._hasZoomListeners = false;
2425
- this._context = null;
2426
- this.nativeReadyResolver = null;
2427
- this.nativeReadyRejecter = null;
2428
- this.nativeReadyPromise = null;
2429
- this.nativeReadyTimeout = null;
2430
- this._position = position || Camera.coreDefaults.Camera.defaultPosition;
2431
- this.settings = settings || null;
2432
- this._desiredTorchState = desiredTorchState || TorchState.Off;
2433
- this._desiredState = desiredState || FrameSourceState.Off;
2434
- this.controller = new CameraController(this);
2586
+ applySettings(settings) {
2587
+ return __awaiter(this, void 0, void 0, function* () {
2588
+ this.settings = settings;
2589
+ yield this.update();
2590
+ });
2435
2591
  }
2436
- switchToDesiredState(state) {
2592
+ update() {
2437
2593
  return __awaiter(this, void 0, void 0, function* () {
2438
- this._desiredState = state;
2439
- if (this.nativeReadyPromise) {
2440
- // Phase 2: Wait for native camera to be ready, then switch state
2441
- yield this.nativeReadyPromise;
2442
- yield this.controller.switchCameraToDesiredState(state);
2594
+ if (!this.controller) {
2443
2595
  return;
2444
2596
  }
2445
- if (!this.isActiveCamera) {
2446
- // Phase 1: Not yet added to context
2447
- console.warn('The current camera is not added to the DataCaptureContext. Add camera to the DataCaptureContext first.');
2448
- return;
2597
+ yield this.controller.updateContextFromJSON();
2598
+ });
2599
+ }
2600
+ addModeInternal(mode) {
2601
+ return __awaiter(this, void 0, void 0, function* () {
2602
+ if (!this.modes.includes(mode)) {
2603
+ this.modes.push(mode);
2604
+ yield this.controller.addModeToContext(mode);
2605
+ mode._context = this;
2449
2606
  }
2450
- // Phase 3: Execute immediately
2451
- yield this.controller.switchCameraToDesiredState(state);
2452
2607
  });
2453
2608
  }
2454
- getCurrentState() {
2455
- return Promise.resolve(this.currentCameraState);
2609
+ removeModeInternal(mode) {
2610
+ return __awaiter(this, void 0, void 0, function* () {
2611
+ const index = this.modes.indexOf(mode);
2612
+ if (index !== -1) {
2613
+ this.modes.splice(index, 1);
2614
+ }
2615
+ mode._context = null;
2616
+ yield this.controller.removeModeFromContext(mode);
2617
+ });
2456
2618
  }
2457
- getIsTorchAvailable() {
2458
- return this.controller.getIsTorchAvailable();
2619
+ }
2620
+ __decorate([
2621
+ ignoreFromSerialization
2622
+ ], DataCaptureContext.prototype, "controller", void 0);
2623
+ __decorate([
2624
+ nameForSerialization('framework')
2625
+ ], DataCaptureContext.prototype, "_framework", void 0);
2626
+ __decorate([
2627
+ nameForSerialization('frameworkVersion')
2628
+ ], DataCaptureContext.prototype, "_frameworkVersion", void 0);
2629
+ __decorate([
2630
+ nameForSerialization('frameSource')
2631
+ ], DataCaptureContext.prototype, "_frameSource", void 0);
2632
+ __decorate([
2633
+ ignoreFromSerialization
2634
+ ], DataCaptureContext.prototype, "view", void 0);
2635
+ __decorate([
2636
+ ignoreFromSerialization
2637
+ ], DataCaptureContext.prototype, "modes", void 0);
2638
+ __decorate([
2639
+ ignoreFromSerialization
2640
+ ], DataCaptureContext.prototype, "listeners", void 0);
2641
+ __decorate([
2642
+ ignoreFromSerialization
2643
+ ], DataCaptureContext, "_instance", void 0);
2644
+ __decorate([
2645
+ ignoreFromSerialization
2646
+ ], DataCaptureContext, "coreDefaults", null);
2647
+
2648
+ var VibrationType;
2649
+ (function (VibrationType) {
2650
+ VibrationType["default"] = "default";
2651
+ VibrationType["selectionHaptic"] = "selectionHaptic";
2652
+ VibrationType["successHaptic"] = "successHaptic";
2653
+ VibrationType["failureHaptic"] = "failureHaptic";
2654
+ VibrationType["waveForm"] = "waveForm";
2655
+ VibrationType["impactHaptic"] = "impactHaptic";
2656
+ })(VibrationType || (VibrationType = {}));
2657
+
2658
+ class Vibration extends DefaultSerializeable {
2659
+ static get defaultVibration() {
2660
+ return new Vibration(VibrationType.default);
2459
2661
  }
2460
- addListener(listener) {
2461
- if (listener == null) {
2462
- return;
2463
- }
2464
- if (this.listeners.includes(listener)) {
2465
- return;
2466
- }
2467
- this.listeners.push(listener);
2662
+ static get selectionHapticFeedback() {
2663
+ return new Vibration(VibrationType.selectionHaptic);
2468
2664
  }
2469
- removeListener(listener) {
2470
- if (listener == null) {
2471
- return;
2472
- }
2473
- if (!this.listeners.includes(listener)) {
2474
- return;
2475
- }
2476
- this.listeners.splice(this.listeners.indexOf(listener), 1);
2665
+ static get successHapticFeedback() {
2666
+ return new Vibration(VibrationType.successHaptic);
2477
2667
  }
2478
- addTorchListener(listener) {
2479
- if (this.torchListeners.includes(listener)) {
2480
- return;
2481
- }
2482
- this.torchListeners.push(listener);
2483
- this._hasTorchStateListeners = this.torchListeners.length > 0;
2484
- if (this.torchListeners.length === 1) {
2485
- void this.controller.subscribeTorchListener();
2486
- }
2487
- if (this.isActiveCamera) {
2488
- void this.didChange();
2489
- }
2668
+ static get failureHapticFeedback() {
2669
+ return new Vibration(VibrationType.failureHaptic);
2490
2670
  }
2491
- removeTorchListener(listener) {
2492
- if (!this.torchListeners.includes(listener)) {
2493
- return;
2494
- }
2495
- this.torchListeners.splice(this.torchListeners.indexOf(listener), 1);
2496
- this._hasTorchStateListeners = this.torchListeners.length > 0;
2497
- if (this.torchListeners.length === 0) {
2498
- void this.controller.unsubscribeTorchListener();
2499
- }
2500
- if (this.isActiveCamera) {
2501
- void this.didChange();
2671
+ static get impactHapticFeedback() {
2672
+ return new Vibration(VibrationType.impactHaptic);
2673
+ }
2674
+ static fromJSON(json) {
2675
+ if (json.type === 'waveForm') {
2676
+ return new WaveFormVibration(json.timings, json.amplitudes);
2502
2677
  }
2678
+ return new Vibration(json.type);
2503
2679
  }
2504
- addMacroModeListener(listener) {
2505
- if (this.macroModeListeners.includes(listener)) {
2506
- return;
2507
- }
2508
- this.macroModeListeners.push(listener);
2509
- this._hasMacroModeListeners = this.macroModeListeners.length > 0;
2510
- if (this.macroModeListeners.length === 1) {
2511
- void this.controller.subscribeMacroModeListener();
2512
- }
2513
- if (this.isActiveCamera) {
2514
- void this.didChange();
2515
- }
2680
+ constructor(type) {
2681
+ super();
2682
+ this.type = type;
2516
2683
  }
2517
- removeMacroModeListener(listener) {
2518
- if (!this.macroModeListeners.includes(listener)) {
2519
- return;
2520
- }
2521
- this.macroModeListeners.splice(this.macroModeListeners.indexOf(listener), 1);
2522
- this._hasMacroModeListeners = this.macroModeListeners.length > 0;
2523
- if (this.macroModeListeners.length === 0) {
2524
- void this.controller.unsubscribeMacroModeListener();
2525
- }
2526
- if (this.isActiveCamera) {
2527
- void this.didChange();
2528
- }
2684
+ }
2685
+ class WaveFormVibration extends Vibration {
2686
+ get timings() {
2687
+ return this._timings;
2529
2688
  }
2530
- addZoomListener(listener) {
2531
- if (this.zoomListeners.includes(listener)) {
2532
- return;
2533
- }
2534
- this.zoomListeners.push(listener);
2535
- this._hasZoomListeners = this.zoomListeners.length > 0;
2536
- if (this.zoomListeners.length === 1) {
2537
- void this.controller.subscribeZoomListener();
2538
- }
2539
- if (this.isActiveCamera) {
2540
- void this.didChange();
2541
- }
2689
+ get amplitudes() {
2690
+ return this._amplitudes;
2542
2691
  }
2543
- removeZoomListener(listener) {
2544
- if (!this.zoomListeners.includes(listener)) {
2545
- return;
2546
- }
2547
- this.zoomListeners.splice(this.zoomListeners.indexOf(listener), 1);
2548
- this._hasZoomListeners = this.zoomListeners.length > 0;
2549
- if (this.zoomListeners.length === 0) {
2550
- void this.controller.unsubscribeZoomListener();
2551
- }
2552
- if (this.isActiveCamera) {
2553
- void this.didChange();
2554
- }
2692
+ constructor(timings, amplitudes = null) {
2693
+ super(VibrationType.waveForm);
2694
+ this._timings = timings;
2695
+ this._amplitudes = amplitudes;
2555
2696
  }
2556
- applySettings(settings) {
2557
- return __awaiter(this, void 0, void 0, function* () {
2558
- this.settings = settings;
2559
- if (this.nativeReadyPromise) {
2560
- // Phase 2: Wait for native camera to be ready, then apply settings
2561
- yield this.nativeReadyPromise;
2562
- yield this.didChange();
2563
- }
2564
- else if (this.isActiveCamera) {
2565
- // Phase 3: Execute immediately
2566
- yield this.didChange();
2567
- }
2568
- // Phase 1: Just update the property, no action needed
2569
- });
2697
+ }
2698
+ __decorate([
2699
+ nameForSerialization('timings')
2700
+ ], WaveFormVibration.prototype, "_timings", void 0);
2701
+ __decorate([
2702
+ ignoreFromSerializationIfNull,
2703
+ nameForSerialization('amplitudes')
2704
+ ], WaveFormVibration.prototype, "_amplitudes", void 0);
2705
+
2706
+ class Sound extends DefaultSerializeable {
2707
+ static get defaultSound() {
2708
+ return new Sound(null);
2570
2709
  }
2571
- set context(newContext) {
2572
- this._context = newContext;
2573
- if (newContext) {
2574
- // Phase 3: Native camera is ready, resolve the promise so waiting operations can proceed
2575
- if (this.nativeReadyTimeout) {
2576
- clearTimeout(this.nativeReadyTimeout);
2577
- this.nativeReadyTimeout = null;
2578
- }
2579
- if (this.nativeReadyResolver) {
2580
- this.nativeReadyResolver();
2581
- this.nativeReadyResolver = null;
2582
- this.nativeReadyRejecter = null;
2583
- this.nativeReadyPromise = null;
2584
- }
2585
- }
2586
- else {
2587
- // When context is removed, reset everything
2588
- if (this.nativeReadyTimeout) {
2589
- clearTimeout(this.nativeReadyTimeout);
2590
- this.nativeReadyTimeout = null;
2591
- }
2592
- this.nativeReadyResolver = null;
2593
- this.nativeReadyRejecter = null;
2594
- this.nativeReadyPromise = null;
2595
- }
2710
+ static fromJSON(json) {
2711
+ return new Sound(json.resource);
2596
2712
  }
2597
- get context() {
2598
- return this._context;
2713
+ constructor(resource) {
2714
+ super();
2715
+ this.resource = null;
2716
+ this.resource = resource;
2599
2717
  }
2600
- setNativeFrameSourceIsBeingCreated() {
2601
- this.nativeReadyPromise = new Promise((resolve, reject) => {
2602
- this.nativeReadyResolver = resolve;
2603
- this.nativeReadyRejecter = reject;
2604
- this.nativeReadyTimeout = setTimeout(() => {
2605
- this.nativeReadyTimeout = null;
2606
- if (this.nativeReadyRejecter) {
2607
- this.nativeReadyRejecter(new Error('Camera native initialization timed out after 5 seconds'));
2608
- this.nativeReadyResolver = null;
2609
- this.nativeReadyRejecter = null;
2610
- this.nativeReadyPromise = null;
2611
- }
2612
- }, 5000);
2613
- });
2718
+ }
2719
+ __decorate([
2720
+ ignoreFromSerializationIfNull
2721
+ ], Sound.prototype, "resource", void 0);
2722
+
2723
+ class FeedbackController extends BaseController {
2724
+ static forFeedback(feedback) {
2725
+ const controller = new FeedbackController(feedback);
2726
+ return controller;
2614
2727
  }
2615
- get isActiveCamera() {
2616
- return this._context !== null;
2728
+ constructor(feedback) {
2729
+ super('CoreProxy');
2730
+ this.feedback = feedback;
2731
+ this.adapter = new CoreProxyAdapter(this._proxy);
2617
2732
  }
2618
- static get default() {
2619
- const defaultPosition = Camera.coreDefaults.Camera.defaultPosition;
2620
- if (!defaultPosition) {
2621
- return null;
2622
- }
2623
- return Camera.atPosition(defaultPosition);
2733
+ emit() {
2734
+ void this.adapter.emitFeedback({ feedbackJson: JSON.stringify(this.feedback.toJSON()) });
2624
2735
  }
2625
- static isMacroModeAvailable() {
2626
- return __awaiter(this, void 0, void 0, function* () {
2627
- const proxy = FactoryMaker.getInstance('CoreProxy');
2628
- if (!proxy) {
2629
- return false;
2630
- }
2631
- const adapter = new CoreProxyAdapter(proxy);
2632
- return yield adapter.isMacroModeAvailable();
2633
- });
2736
+ dispose() {
2737
+ this._proxy.dispose();
2634
2738
  }
2635
- get position() {
2636
- return this._position;
2739
+ }
2740
+
2741
+ class Feedback extends DefaultSerializeable {
2742
+ static get defaultFeedback() {
2743
+ return new Feedback(Vibration.defaultVibration, Sound.defaultSound);
2637
2744
  }
2638
- get isTorchAvailable() {
2639
- return this.controller.getIsTorchAvailable();
2745
+ get vibration() {
2746
+ return this._vibration;
2640
2747
  }
2641
- get desiredState() {
2642
- return this._desiredState;
2748
+ get sound() {
2749
+ return this._sound;
2643
2750
  }
2644
- set desiredTorchState(desiredTorchState) {
2645
- this._desiredTorchState = desiredTorchState;
2646
- if (this.nativeReadyPromise) {
2647
- // Phase 2: Wait for native camera to be ready, then update
2648
- void this.nativeReadyPromise.then(() => this.didChange());
2649
- }
2650
- else if (this.isActiveCamera) {
2651
- // Phase 3: Execute immediately
2652
- void this.didChange();
2653
- }
2654
- // Phase 1: Just update the property, no action needed
2751
+ static fromJSON(json) {
2752
+ return new Feedback((json === null || json === void 0 ? void 0 : json.vibration) ? Vibration.fromJSON(json.vibration) : null, (json === null || json === void 0 ? void 0 : json.sound) ? Sound.fromJSON(json.sound) : null);
2655
2753
  }
2656
- get desiredTorchState() {
2657
- return this._desiredTorchState;
2754
+ constructor(vibration, sound) {
2755
+ super();
2756
+ this._vibration = null;
2757
+ this._sound = null;
2758
+ this._vibration = vibration;
2759
+ this._sound = sound;
2760
+ this.controller = new FeedbackController(this);
2658
2761
  }
2659
- didChange() {
2660
- return __awaiter(this, void 0, void 0, function* () {
2661
- if (this.context) {
2662
- yield this.context.update();
2663
- }
2664
- });
2762
+ emit() {
2763
+ this.controller.emit();
2665
2764
  }
2666
- resetPhaseState() {
2667
- if (this.nativeReadyTimeout) {
2668
- clearTimeout(this.nativeReadyTimeout);
2669
- this.nativeReadyTimeout = null;
2670
- }
2671
- this.nativeReadyResolver = null;
2672
- this.nativeReadyRejecter = null;
2673
- this.nativeReadyPromise = null;
2765
+ toJSON() {
2766
+ return super.toJSON();
2674
2767
  }
2675
2768
  }
2676
- Camera._cameraInstances = new Map();
2677
- __decorate([
2678
- ignoreFromSerialization
2679
- ], Camera.prototype, "controller", void 0);
2680
- __decorate([
2681
- serializationDefault({})
2682
- ], Camera.prototype, "settings", void 0);
2683
- __decorate([
2684
- nameForSerialization('position')
2685
- ], Camera.prototype, "_position", void 0);
2686
- __decorate([
2687
- nameForSerialization('desiredTorchState')
2688
- ], Camera.prototype, "_desiredTorchState", void 0);
2689
- __decorate([
2690
- nameForSerialization('desiredState')
2691
- ], Camera.prototype, "_desiredState", void 0);
2692
2769
  __decorate([
2693
- nameForSerialization('hasTorchStateListeners')
2694
- ], Camera.prototype, "_hasTorchStateListeners", void 0);
2770
+ ignoreFromSerializationIfNull,
2771
+ nameForSerialization('vibration')
2772
+ ], Feedback.prototype, "_vibration", void 0);
2695
2773
  __decorate([
2696
- nameForSerialization('hasMacroModeListeners')
2697
- ], Camera.prototype, "_hasMacroModeListeners", void 0);
2774
+ ignoreFromSerializationIfNull,
2775
+ nameForSerialization('sound')
2776
+ ], Feedback.prototype, "_sound", void 0);
2698
2777
  __decorate([
2699
2778
  ignoreFromSerialization
2700
- ], Camera.prototype, "currentCameraState", void 0);
2701
- __decorate([
2702
- ignoreFromSerialization
2703
- ], Camera.prototype, "listeners", void 0);
2704
- __decorate([
2705
- ignoreFromSerialization
2706
- ], Camera.prototype, "torchListeners", void 0);
2707
- __decorate([
2708
- ignoreFromSerialization
2709
- ], Camera.prototype, "macroModeListeners", void 0);
2710
- __decorate([
2711
- ignoreFromSerialization
2712
- ], Camera.prototype, "zoomListeners", void 0);
2713
- __decorate([
2714
- nameForSerialization('hasZoomListeners')
2715
- ], Camera.prototype, "_hasZoomListeners", void 0);
2716
- __decorate([
2717
- ignoreFromSerialization
2718
- ], Camera.prototype, "_context", void 0);
2719
- __decorate([
2720
- ignoreFromSerialization
2721
- ], Camera.prototype, "nativeReadyResolver", void 0);
2722
- __decorate([
2723
- ignoreFromSerialization
2724
- ], Camera.prototype, "nativeReadyRejecter", void 0);
2725
- __decorate([
2726
- ignoreFromSerialization
2727
- ], Camera.prototype, "nativeReadyPromise", void 0);
2728
- __decorate([
2729
- ignoreFromSerialization
2730
- ], Camera.prototype, "nativeReadyTimeout", void 0);
2731
- __decorate([
2732
- ignoreFromSerialization
2733
- ], Camera, "_cameraInstances", void 0);
2734
- __decorate([
2735
- ignoreFromSerialization
2736
- ], Camera, "coreDefaults", null);
2779
+ ], Feedback.prototype, "controller", void 0);
2737
2780
 
2738
- class CameraOwnershipManager {
2739
- static getInstance() {
2740
- if (!CameraOwnershipManager.instance) {
2741
- CameraOwnershipManager.instance = new CameraOwnershipManager();
2742
- }
2743
- return CameraOwnershipManager.instance;
2781
+ var FocusGestureListenerEvents;
2782
+ (function (FocusGestureListenerEvents) {
2783
+ FocusGestureListenerEvents["onFocusGesture"] = "FocusGestureListener.onFocusGesture";
2784
+ })(FocusGestureListenerEvents || (FocusGestureListenerEvents = {}));
2785
+
2786
+ var ZoomGestureListenerEvents;
2787
+ (function (ZoomGestureListenerEvents) {
2788
+ ZoomGestureListenerEvents["onZoomInGesture"] = "ZoomGestureListener.onZoomInGesture";
2789
+ ZoomGestureListenerEvents["onZoomOutGesture"] = "ZoomGestureListener.onZoomOutGesture";
2790
+ })(ZoomGestureListenerEvents || (ZoomGestureListenerEvents = {}));
2791
+
2792
+ var FrameSourceListenerEvents;
2793
+ (function (FrameSourceListenerEvents) {
2794
+ FrameSourceListenerEvents["didChangeState"] = "FrameSourceListener.onStateChanged";
2795
+ })(FrameSourceListenerEvents || (FrameSourceListenerEvents = {}));
2796
+
2797
+ var TorchListenerEvents;
2798
+ (function (TorchListenerEvents) {
2799
+ TorchListenerEvents["didChangeTorchToState"] = "TorchListener.onTorchStateChanged";
2800
+ })(TorchListenerEvents || (TorchListenerEvents = {}));
2801
+
2802
+ var MacroModeListenerEvents;
2803
+ (function (MacroModeListenerEvents) {
2804
+ MacroModeListenerEvents["didChangeMacroMode"] = "MacroModeListener.onMacroModeChanged";
2805
+ })(MacroModeListenerEvents || (MacroModeListenerEvents = {}));
2806
+
2807
+ var ZoomListenerEvents;
2808
+ (function (ZoomListenerEvents) {
2809
+ ZoomListenerEvents["didChangeZoomLevel"] = "ZoomListener.onZoomLevelChanged";
2810
+ })(ZoomListenerEvents || (ZoomListenerEvents = {}));
2811
+
2812
+ class CameraController extends BaseController {
2813
+ constructor(camera) {
2814
+ super('CoreProxy');
2815
+ // Arrow function wrapper to avoid .bind(this) and always use current class state
2816
+ this.handleDidChangeStateEventWrapper = (ev) => {
2817
+ return this.handleDidChangeStateEvent(ev);
2818
+ };
2819
+ // Arrow function wrapper to avoid .bind(this) and always use current class state
2820
+ this.handleDidChangeTorchToStateEventWrapper = (ev) => {
2821
+ return this.handleDidChangeTorchToStateEvent(ev);
2822
+ };
2823
+ // Arrow function wrapper to avoid .bind(this) and always use current class state
2824
+ this.handleDidChangeMacroModeEventWrapper = (ev) => {
2825
+ return this.handleDidChangeMacroModeEvent(ev);
2826
+ };
2827
+ // Arrow function wrapper to avoid .bind(this) and always use current class state
2828
+ this.handleDidChangeZoomLevelEventWrapper = (ev) => {
2829
+ return this.handleDidChangeZoomLevelEvent(ev);
2830
+ };
2831
+ this.camera = camera;
2832
+ this.adapter = new CoreProxyAdapter(this._proxy);
2833
+ void this.subscribeListener();
2744
2834
  }
2745
- constructor() {
2746
- this.owners = new Map();
2747
- this.waitingQueue = new Map();
2748
- this.protectedCameras = new Set();
2835
+ get privateCamera() {
2836
+ return this.camera;
2749
2837
  }
2750
- requestOwnership(position, owner) {
2751
- const currentOwner = this.owners.get(position);
2752
- if (currentOwner && currentOwner.id !== owner.id) {
2753
- return false; // Already owned by someone else
2754
- }
2755
- this.owners.set(position, owner);
2756
- this.enableProtectionForOwner(position, owner);
2757
- return true;
2838
+ getCurrentState() {
2839
+ return __awaiter(this, void 0, void 0, function* () {
2840
+ return yield this.adapter.getCameraState({
2841
+ cameraPosition: this.privateCamera._position,
2842
+ });
2843
+ });
2758
2844
  }
2759
- requestOwnershipAsync(position, owner, timeoutMs) {
2845
+ getIsTorchAvailable() {
2760
2846
  return __awaiter(this, void 0, void 0, function* () {
2761
- // Try immediate acquisition first
2762
- if (this.requestOwnership(position, owner)) {
2763
- return true;
2764
- }
2765
- // If not available, wait in queue
2766
- return new Promise((resolve) => {
2767
- const request = { owner, resolve };
2768
- if (!this.waitingQueue.has(position)) {
2769
- this.waitingQueue.set(position, []);
2770
- }
2771
- this.waitingQueue.get(position).push(request);
2772
- // Optional timeout
2773
- if (timeoutMs && timeoutMs > 0) {
2774
- setTimeout(() => {
2775
- this.removeFromQueue(position, request);
2776
- resolve(false); // Timeout - ownership not acquired
2777
- }, timeoutMs);
2778
- }
2847
+ return yield this.adapter.isTorchAvailable({
2848
+ cameraPosition: this.privateCamera._position,
2779
2849
  });
2780
2850
  });
2781
2851
  }
2782
- releaseOwnership(position, owner) {
2783
- const currentOwner = this.owners.get(position);
2784
- if (!currentOwner || currentOwner.id !== owner.id) {
2785
- return false; // Not the owner
2786
- }
2787
- this.owners.delete(position);
2788
- this.disableProtectionForPosition(position);
2789
- this.processWaitingQueue(position);
2790
- return true;
2852
+ switchCameraToDesiredState(desiredState) {
2853
+ return __awaiter(this, void 0, void 0, function* () {
2854
+ yield this.adapter.switchCameraToDesiredState({
2855
+ stateJson: desiredState.toString(),
2856
+ });
2857
+ });
2791
2858
  }
2792
- isOwner(position, owner) {
2793
- const currentOwner = this.owners.get(position);
2794
- return (currentOwner === null || currentOwner === void 0 ? void 0 : currentOwner.id) === owner.id;
2859
+ subscribeListener() {
2860
+ return __awaiter(this, void 0, void 0, function* () {
2861
+ yield this.adapter.registerFrameSourceListener();
2862
+ this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
2863
+ this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
2864
+ });
2795
2865
  }
2796
- getCurrentOwner(position) {
2797
- return this.owners.get(position) || null;
2866
+ unsubscribeListener() {
2867
+ return __awaiter(this, void 0, void 0, function* () {
2868
+ yield this.adapter.unregisterFrameSourceListener();
2869
+ this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
2870
+ this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
2871
+ });
2798
2872
  }
2799
- checkOwnership(position, owner) {
2800
- return this.isOwner(position, owner);
2873
+ subscribeTorchListener() {
2874
+ return __awaiter(this, void 0, void 0, function* () {
2875
+ yield this.adapter.registerTorchStateListener();
2876
+ this._proxy.subscribeForEvents([TorchListenerEvents.didChangeTorchToState]);
2877
+ this._proxy.eventEmitter.on(TorchListenerEvents.didChangeTorchToState, this.handleDidChangeTorchToStateEventWrapper);
2878
+ });
2801
2879
  }
2802
- getOwnedPosition(owner) {
2803
- for (const [position, currentOwner] of this.owners.entries()) {
2804
- if (currentOwner.id === owner.id) {
2805
- return position;
2806
- }
2807
- }
2808
- return null;
2880
+ unsubscribeTorchListener() {
2881
+ return __awaiter(this, void 0, void 0, function* () {
2882
+ yield this.adapter.unregisterTorchStateListener();
2883
+ this._proxy.unsubscribeFromEvents([TorchListenerEvents.didChangeTorchToState]);
2884
+ this._proxy.eventEmitter.off(TorchListenerEvents.didChangeTorchToState, this.handleDidChangeTorchToStateEventWrapper);
2885
+ });
2809
2886
  }
2810
- getAllOwnedPositions(owner) {
2811
- const positions = [];
2812
- for (const [position, currentOwner] of this.owners.entries()) {
2813
- if (currentOwner.id === owner.id) {
2814
- positions.push(position);
2815
- }
2816
- }
2817
- return positions;
2887
+ subscribeMacroModeListener() {
2888
+ return __awaiter(this, void 0, void 0, function* () {
2889
+ yield this.adapter.registerMacroModeListener();
2890
+ this._proxy.subscribeForEvents([MacroModeListenerEvents.didChangeMacroMode]);
2891
+ this._proxy.eventEmitter.on(MacroModeListenerEvents.didChangeMacroMode, this.handleDidChangeMacroModeEventWrapper);
2892
+ });
2818
2893
  }
2819
- enableProtectionForOwner(position, owner) {
2820
- const camera = Camera.atPosition(position);
2821
- if (!camera || this.protectedCameras.has(camera)) {
2822
- return; // Camera not available or already protected
2823
- }
2824
- this.protectCameraForOwner(camera, position, owner);
2825
- this.protectedCameras.add(camera);
2894
+ unsubscribeMacroModeListener() {
2895
+ return __awaiter(this, void 0, void 0, function* () {
2896
+ yield this.adapter.unregisterMacroModeListener();
2897
+ this._proxy.unsubscribeFromEvents([MacroModeListenerEvents.didChangeMacroMode]);
2898
+ this._proxy.eventEmitter.off(MacroModeListenerEvents.didChangeMacroMode, this.handleDidChangeMacroModeEventWrapper);
2899
+ });
2826
2900
  }
2827
- disableProtectionForPosition(position) {
2828
- const camera = Camera.atPosition(position);
2829
- if (!camera || !this.protectedCameras.has(camera)) {
2901
+ subscribeZoomListener() {
2902
+ return __awaiter(this, void 0, void 0, function* () {
2903
+ yield this.adapter.registerZoomLevelListener();
2904
+ this._proxy.subscribeForEvents([ZoomListenerEvents.didChangeZoomLevel]);
2905
+ this._proxy.eventEmitter.on(ZoomListenerEvents.didChangeZoomLevel, this.handleDidChangeZoomLevelEventWrapper);
2906
+ });
2907
+ }
2908
+ unsubscribeZoomListener() {
2909
+ return __awaiter(this, void 0, void 0, function* () {
2910
+ yield this.adapter.unregisterZoomLevelListener();
2911
+ this._proxy.unsubscribeFromEvents([ZoomListenerEvents.didChangeZoomLevel]);
2912
+ this._proxy.eventEmitter.off(ZoomListenerEvents.didChangeZoomLevel, this.handleDidChangeZoomLevelEventWrapper);
2913
+ });
2914
+ }
2915
+ dispose() {
2916
+ void this.unsubscribeListener();
2917
+ void this.unsubscribeTorchListener();
2918
+ void this.unsubscribeMacroModeListener();
2919
+ void this.unsubscribeZoomListener();
2920
+ this._proxy.dispose();
2921
+ }
2922
+ handleDidChangeStateEvent(ev) {
2923
+ const event = EventDataParser.parseIfShouldHandle(ev, {});
2924
+ if (event === SKIP || event === null) {
2830
2925
  return;
2831
2926
  }
2832
- this.unprotectCamera(camera);
2833
- this.protectedCameras.delete(camera);
2834
- }
2835
- processWaitingQueue(position) {
2836
- const queue = this.waitingQueue.get(position);
2837
- if (!queue || queue.length === 0) {
2927
+ if (event.cameraPosition !== this.privateCamera._position || !this.privateCamera.isActiveCamera) {
2838
2928
  return;
2839
2929
  }
2840
- // Give ownership to the first in queue
2841
- const nextRequest = queue.shift();
2842
- this.owners.set(position, nextRequest.owner);
2843
- this.enableProtectionForOwner(position, nextRequest.owner);
2844
- nextRequest.resolve(true);
2845
- // Clean up empty queue
2846
- if (queue.length === 0) {
2847
- this.waitingQueue.delete(position);
2848
- }
2930
+ this.privateCamera.currentCameraState = event.state;
2931
+ this.privateCamera.listeners.forEach(listener => {
2932
+ var _a;
2933
+ (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeState) === null || _a === void 0 ? void 0 : _a.call(listener, this.camera, this.privateCamera._desiredState);
2934
+ });
2849
2935
  }
2850
- removeFromQueue(position, requestToRemove) {
2851
- const queue = this.waitingQueue.get(position);
2852
- if (!queue)
2936
+ handleDidChangeTorchToStateEvent(ev) {
2937
+ const event = EventDataParser.parseIfShouldHandle(ev, {});
2938
+ if (event === SKIP || event === null) {
2853
2939
  return;
2854
- const index = queue.indexOf(requestToRemove);
2855
- if (index > -1) {
2856
- queue.splice(index, 1);
2857
2940
  }
2858
- if (queue.length === 0) {
2859
- this.waitingQueue.delete(position);
2941
+ if (this.privateCamera.isActiveCamera) {
2942
+ const torchState = event.state;
2943
+ this.privateCamera.desiredTorchState = torchState;
2944
+ this.privateCamera.torchListeners.forEach(listener => {
2945
+ var _a;
2946
+ (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeTorchToState) === null || _a === void 0 ? void 0 : _a.call(listener, torchState);
2947
+ });
2860
2948
  }
2861
2949
  }
2862
- protectCameraForOwner(camera, position, _owner) {
2863
- var _a, _b, _c, _d;
2864
- const originalSwitchToDesiredState = camera.switchToDesiredState.bind(camera);
2865
- const originalApplySettings = camera.applySettings.bind(camera);
2866
- 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);
2867
- // Protect switchToDesiredState - only owner can call it
2868
- camera.switchToDesiredState = (state) => __awaiter(this, void 0, void 0, function* () {
2869
- const currentOwner = this.getCurrentOwner(position);
2870
- if (!currentOwner) {
2871
- throw new Error(`Camera operation denied: No owner for camera at ${position}`);
2872
- }
2873
- // Allow operation - the owner is the only one who should have access to this camera instance
2874
- return originalSwitchToDesiredState(state);
2875
- });
2876
- // Protect applySettings - only owner can call it
2877
- camera.applySettings = (settings) => __awaiter(this, void 0, void 0, function* () {
2878
- const currentOwner = this.getCurrentOwner(position);
2879
- if (!currentOwner) {
2880
- throw new Error(`Camera operation denied: No owner for camera at ${position}`);
2881
- }
2882
- return originalApplySettings(settings);
2883
- });
2884
- // Protect desiredTorchState setter - only owner can set it
2885
- if (originalSetDesiredTorchState) {
2886
- Object.defineProperty(camera, 'desiredTorchState', {
2887
- set: (value) => {
2888
- const currentOwner = this.getCurrentOwner(position);
2889
- if (!currentOwner) {
2890
- throw new Error(`Camera operation denied: No owner for camera at ${position}`);
2891
- }
2892
- originalSetDesiredTorchState(value);
2893
- },
2894
- 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),
2895
- configurable: true
2950
+ handleDidChangeMacroModeEvent(ev) {
2951
+ const event = EventDataParser.parseIfShouldHandle(ev, {});
2952
+ if (event === SKIP || event === null) {
2953
+ return;
2954
+ }
2955
+ if (this.privateCamera.isActiveCamera) {
2956
+ const macroMode = event.macroMode;
2957
+ this.privateCamera.macroModeListeners.forEach(listener => {
2958
+ var _a;
2959
+ (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeMacroMode) === null || _a === void 0 ? void 0 : _a.call(listener, macroMode);
2896
2960
  });
2897
2961
  }
2898
- // Store originals for restoration
2899
- camera.__originalMethods = {
2900
- switchToDesiredState: originalSwitchToDesiredState,
2901
- applySettings: originalApplySettings,
2902
- setDesiredTorchState: originalSetDesiredTorchState
2903
- };
2904
2962
  }
2905
- unprotectCamera(camera) {
2906
- var _a, _b;
2907
- const originals = camera.__originalMethods;
2908
- if (!originals)
2963
+ handleDidChangeZoomLevelEvent(ev) {
2964
+ const event = EventDataParser.parseIfShouldHandle(ev, {});
2965
+ if (event === SKIP || event === null) {
2909
2966
  return;
2910
- // Restore original methods
2911
- camera.switchToDesiredState = originals.switchToDesiredState;
2912
- camera.applySettings = originals.applySettings;
2913
- if (originals.setDesiredTorchState) {
2914
- Object.defineProperty(camera, 'desiredTorchState', {
2915
- set: originals.setDesiredTorchState,
2916
- 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),
2917
- configurable: true
2967
+ }
2968
+ if (this.privateCamera.isActiveCamera) {
2969
+ this.privateCamera.zoomListeners.forEach(listener => {
2970
+ var _a;
2971
+ (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeZoomLevel) === null || _a === void 0 ? void 0 : _a.call(listener, event.oldZoomLevel, event.newZoomLevel);
2918
2972
  });
2919
2973
  }
2920
- delete camera.__originalMethods;
2921
2974
  }
2922
2975
  }
2923
2976
 
2924
- class CameraOwnershipHelper {
2925
- /**
2926
- * Get camera instance for the owner (only works if you own it)
2927
- */
2928
- static getCamera(position, owner) {
2929
- // Check ownership
2930
- if (!this.ownershipManager.checkOwnership(position, owner)) {
2931
- console.warn(`Camera access denied: ${owner.id} does not own camera at ${position}`);
2932
- return null;
2933
- }
2934
- return Camera.atPosition(position);
2935
- }
2936
- /**
2937
- * Safely execute camera operations (only works if you own the camera)
2938
- */
2939
- static withCamera(position, owner, operation) {
2940
- return __awaiter(this, void 0, void 0, function* () {
2941
- const camera = this.getCamera(position, owner);
2942
- if (!camera) {
2943
- return null;
2944
- }
2945
- try {
2946
- const result = yield operation(camera);
2947
- return result;
2948
- }
2949
- catch (error) {
2950
- console.error(`Camera operation failed for ${owner.id}:`, error);
2951
- throw error;
2952
- }
2953
- });
2954
- }
2955
- /**
2956
- * Execute camera operations, waiting for ownership if necessary
2957
- */
2958
- static withCameraWhenAvailable(position, owner, operation, timeoutMs) {
2959
- return __awaiter(this, void 0, void 0, function* () {
2960
- // Try to get ownership, wait if necessary
2961
- const acquired = yield this.requestOwnership(position, owner, timeoutMs);
2962
- if (!acquired) {
2963
- console.warn(`Could not acquire camera ownership for ${owner.id} within timeout`);
2964
- return null;
2965
- }
2966
- const camera = Camera.atPosition(position);
2967
- if (!camera) {
2968
- console.warn(`Camera not available at position ${position}`);
2969
- return null;
2970
- }
2971
- try {
2972
- const result = yield operation(camera);
2973
- return result;
2974
- }
2975
- catch (error) {
2976
- console.error(`Camera operation failed for ${owner.id}:`, error);
2977
- throw error;
2978
- }
2979
- });
2980
- }
2981
- /**
2982
- * Request ownership and wait if necessary
2983
- */
2984
- static requestOwnership(position, owner, timeoutMs) {
2985
- return __awaiter(this, void 0, void 0, function* () {
2986
- return this.ownershipManager.requestOwnershipAsync(position, owner, timeoutMs);
2987
- });
2988
- }
2989
- /**
2990
- * Release ownership
2991
- */
2992
- static releaseOwnership(position, owner) {
2993
- return this.ownershipManager.releaseOwnership(position, owner);
2994
- }
2995
- /**
2996
- * Check if owner has ownership
2997
- */
2998
- static hasOwnership(position, owner) {
2999
- return this.ownershipManager.checkOwnership(position, owner);
3000
- }
3001
- /**
3002
- * Get the camera position currently owned by the owner (if unknown)
3003
- */
3004
- static getOwnedPosition(owner) {
3005
- return this.ownershipManager.getOwnedPosition(owner);
2977
+ var FrameSourceState;
2978
+ (function (FrameSourceState) {
2979
+ FrameSourceState["On"] = "on";
2980
+ FrameSourceState["Off"] = "off";
2981
+ FrameSourceState["Starting"] = "starting";
2982
+ FrameSourceState["Stopping"] = "stopping";
2983
+ FrameSourceState["Standby"] = "standby";
2984
+ FrameSourceState["BootingUp"] = "bootingUp";
2985
+ FrameSourceState["WakingUp"] = "wakingUp";
2986
+ FrameSourceState["GoingToSleep"] = "goingToSleep";
2987
+ FrameSourceState["ShuttingDown"] = "shuttingDown";
2988
+ })(FrameSourceState || (FrameSourceState = {}));
2989
+
2990
+ class ImageBuffer {
2991
+ get width() {
2992
+ return this._width;
3006
2993
  }
3007
- /**
3008
- * Get all camera positions currently owned by the owner
3009
- */
3010
- static getAllOwnedPositions(owner) {
3011
- return this.ownershipManager.getAllOwnedPositions(owner);
2994
+ get height() {
2995
+ return this._height;
3012
2996
  }
3013
- /**
3014
- * Release ownership of all cameras owned by the owner
3015
- */
3016
- static releaseAllOwnerships(owner) {
3017
- const ownedPositions = this.getAllOwnedPositions(owner);
3018
- for (const position of ownedPositions) {
3019
- this.releaseOwnership(position, owner);
3020
- }
2997
+ get data() {
2998
+ return this._data;
3021
2999
  }
3022
3000
  }
3023
- CameraOwnershipHelper.ownershipManager = CameraOwnershipManager.getInstance();
3024
3001
 
3025
- var ZoomListenerEvents;
3026
- (function (ZoomListenerEvents) {
3027
- ZoomListenerEvents["didChangeZoomLevel"] = "ZoomListener.onZoomLevelChanged";
3028
- })(ZoomListenerEvents || (ZoomListenerEvents = {}));
3029
-
3030
- class CameraController extends BaseController {
3031
- constructor(camera) {
3002
+ class ImageFrameSourceController extends BaseController {
3003
+ constructor(imageFrameSource) {
3032
3004
  super('CoreProxy');
3033
- // Arrow function wrapper to avoid .bind(this) and always use current class state
3034
3005
  this.handleDidChangeStateEventWrapper = (ev) => {
3035
3006
  return this.handleDidChangeStateEvent(ev);
3036
3007
  };
3037
- // Arrow function wrapper to avoid .bind(this) and always use current class state
3038
- this.handleDidChangeTorchToStateEventWrapper = (ev) => {
3039
- return this.handleDidChangeTorchToStateEvent(ev);
3040
- };
3041
- // Arrow function wrapper to avoid .bind(this) and always use current class state
3042
- this.handleDidChangeMacroModeEventWrapper = (ev) => {
3043
- return this.handleDidChangeMacroModeEvent(ev);
3044
- };
3045
- // Arrow function wrapper to avoid .bind(this) and always use current class state
3046
- this.handleDidChangeZoomLevelEventWrapper = (ev) => {
3047
- return this.handleDidChangeZoomLevelEvent(ev);
3048
- };
3049
- this.camera = camera;
3008
+ this.imageFrameSource = imageFrameSource;
3050
3009
  this.adapter = new CoreProxyAdapter(this._proxy);
3051
3010
  void this.subscribeListener();
3052
3011
  }
3053
- get privateCamera() {
3054
- return this.camera;
3012
+ get privateImageFrameSource() {
3013
+ return this.imageFrameSource;
3055
3014
  }
3056
3015
  getCurrentState() {
3057
3016
  return __awaiter(this, void 0, void 0, function* () {
3058
3017
  return yield this.adapter.getCameraState({
3059
- cameraPosition: JSON.stringify(this.privateCamera._position)
3060
- });
3061
- });
3062
- }
3063
- getIsTorchAvailable() {
3064
- return __awaiter(this, void 0, void 0, function* () {
3065
- return yield this.adapter.isTorchAvailable({
3066
- cameraPosition: JSON.stringify(this.privateCamera._position)
3018
+ cameraPosition: JSON.stringify(this.privateImageFrameSource.position),
3067
3019
  });
3068
3020
  });
3069
3021
  }
3070
- switchCameraToDesiredState(desiredState) {
3022
+ switchCameraToDesiredState(desiredStateJson) {
3071
3023
  return __awaiter(this, void 0, void 0, function* () {
3072
3024
  yield this.adapter.switchCameraToDesiredState({
3073
- stateJson: desiredState.toString()
3025
+ stateJson: desiredStateJson,
3074
3026
  });
3075
3027
  });
3076
3028
  }
@@ -3088,108 +3040,152 @@ class CameraController extends BaseController {
3088
3040
  this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
3089
3041
  });
3090
3042
  }
3091
- subscribeTorchListener() {
3092
- return __awaiter(this, void 0, void 0, function* () {
3093
- yield this.adapter.registerTorchStateListener();
3094
- this._proxy.subscribeForEvents([TorchListenerEvents.didChangeTorchToState]);
3095
- this._proxy.eventEmitter.on(TorchListenerEvents.didChangeTorchToState, this.handleDidChangeTorchToStateEventWrapper);
3096
- });
3043
+ dispose() {
3044
+ void this.unsubscribeListener();
3045
+ this._proxy.dispose();
3097
3046
  }
3098
- unsubscribeTorchListener() {
3099
- return __awaiter(this, void 0, void 0, function* () {
3100
- yield this.adapter.unregisterTorchStateListener();
3101
- this._proxy.unsubscribeFromEvents([TorchListenerEvents.didChangeTorchToState]);
3102
- this._proxy.eventEmitter.off(TorchListenerEvents.didChangeTorchToState, this.handleDidChangeTorchToStateEventWrapper);
3047
+ handleDidChangeStateEvent(ev) {
3048
+ const event = EventDataParser.parseIfShouldHandle(ev, {});
3049
+ if (event === SKIP) {
3050
+ return;
3051
+ }
3052
+ if (event === null) {
3053
+ console.error('ImageFrameSourceController didChangeState payload is null');
3054
+ return;
3055
+ }
3056
+ const newState = event.state;
3057
+ this.privateImageFrameSource.listeners.forEach(listener => {
3058
+ if (listener.didChangeState) {
3059
+ listener.didChangeState(this.imageFrameSource, newState);
3060
+ }
3103
3061
  });
3104
3062
  }
3105
- subscribeMacroModeListener() {
3106
- return __awaiter(this, void 0, void 0, function* () {
3107
- yield this.adapter.registerMacroModeListener();
3108
- this._proxy.subscribeForEvents([MacroModeListenerEvents.didChangeMacroMode]);
3109
- this._proxy.eventEmitter.on(MacroModeListenerEvents.didChangeMacroMode, this.handleDidChangeMacroModeEventWrapper);
3110
- });
3063
+ }
3064
+
3065
+ class ImageFrameSource extends DefaultSerializeable {
3066
+ set context(newContext) {
3067
+ if (newContext == null) {
3068
+ void this.controller.unsubscribeListener();
3069
+ }
3070
+ else if (this._context == null) {
3071
+ void this.controller.subscribeListener();
3072
+ }
3073
+ this._context = newContext;
3111
3074
  }
3112
- unsubscribeMacroModeListener() {
3113
- return __awaiter(this, void 0, void 0, function* () {
3114
- yield this.adapter.unregisterMacroModeListener();
3115
- this._proxy.unsubscribeFromEvents([MacroModeListenerEvents.didChangeMacroMode]);
3116
- this._proxy.eventEmitter.off(MacroModeListenerEvents.didChangeMacroMode, this.handleDidChangeMacroModeEventWrapper);
3117
- });
3075
+ get context() {
3076
+ return this._context;
3118
3077
  }
3119
- subscribeZoomListener() {
3120
- return __awaiter(this, void 0, void 0, function* () {
3121
- yield this.adapter.registerZoomLevelListener();
3122
- this._proxy.subscribeForEvents([ZoomListenerEvents.didChangeZoomLevel]);
3123
- this._proxy.eventEmitter.on(ZoomListenerEvents.didChangeZoomLevel, this.handleDidChangeZoomLevelEventWrapper);
3124
- });
3078
+ get desiredState() {
3079
+ return this._desiredState;
3125
3080
  }
3126
- unsubscribeZoomListener() {
3127
- return __awaiter(this, void 0, void 0, function* () {
3128
- yield this.adapter.unregisterZoomLevelListener();
3129
- this._proxy.unsubscribeFromEvents([ZoomListenerEvents.didChangeZoomLevel]);
3130
- this._proxy.eventEmitter.off(ZoomListenerEvents.didChangeZoomLevel, this.handleDidChangeZoomLevelEventWrapper);
3131
- });
3081
+ static create(image) {
3082
+ const imageFrameSource = new ImageFrameSource();
3083
+ imageFrameSource.image = image;
3084
+ return imageFrameSource;
3132
3085
  }
3133
- dispose() {
3134
- void this.unsubscribeListener();
3135
- void this.unsubscribeTorchListener();
3136
- void this.unsubscribeMacroModeListener();
3137
- void this.unsubscribeZoomListener();
3138
- this._proxy.dispose();
3086
+ static fromJSON(json) {
3087
+ return ImageFrameSource.create(json.image);
3139
3088
  }
3140
- handleDidChangeStateEvent(ev) {
3141
- const event = EventDataParser.parseIfShouldHandle(ev, {});
3142
- if (event === SKIP || event === null) {
3089
+ constructor() {
3090
+ super();
3091
+ this.type = 'image';
3092
+ this.image = '';
3093
+ this._id = `${Date.now()}`;
3094
+ this._desiredState = FrameSourceState.Off;
3095
+ this.listeners = [];
3096
+ this._context = null;
3097
+ this.controller = new ImageFrameSourceController(this);
3098
+ }
3099
+ switchToDesiredState(state) {
3100
+ this._desiredState = state;
3101
+ return this.controller.switchCameraToDesiredState(state);
3102
+ }
3103
+ addListener(listener) {
3104
+ if (listener == null) {
3143
3105
  return;
3144
3106
  }
3145
- if (event.cameraPosition !== this.privateCamera._position || !this.privateCamera.isActiveCamera) {
3107
+ if (this.listeners.includes(listener)) {
3146
3108
  return;
3147
3109
  }
3148
- this.privateCamera.currentCameraState = event.state;
3149
- this.privateCamera.listeners.forEach(listener => {
3150
- var _a;
3151
- (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeState) === null || _a === void 0 ? void 0 : _a.call(listener, this.camera, this.privateCamera._desiredState);
3152
- });
3110
+ this.listeners.push(listener);
3153
3111
  }
3154
- handleDidChangeTorchToStateEvent(ev) {
3155
- const event = EventDataParser.parseIfShouldHandle(ev, {});
3156
- if (event === SKIP || event === null) {
3112
+ removeListener(listener) {
3113
+ if (listener == null) {
3157
3114
  return;
3158
3115
  }
3159
- if (this.privateCamera.isActiveCamera) {
3160
- const torchState = event.state;
3161
- this.privateCamera.desiredTorchState = torchState;
3162
- this.privateCamera.torchListeners.forEach(listener => {
3163
- var _a;
3164
- (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeTorchToState) === null || _a === void 0 ? void 0 : _a.call(listener, torchState);
3165
- });
3166
- }
3167
- }
3168
- handleDidChangeMacroModeEvent(ev) {
3169
- const event = EventDataParser.parseIfShouldHandle(ev, {});
3170
- if (event === SKIP || event === null) {
3116
+ if (!this.listeners.includes(listener)) {
3171
3117
  return;
3172
3118
  }
3173
- if (this.privateCamera.isActiveCamera) {
3174
- const macroMode = event.macroMode;
3175
- this.privateCamera.macroModeListeners.forEach(listener => {
3176
- var _a;
3177
- (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeMacroMode) === null || _a === void 0 ? void 0 : _a.call(listener, macroMode);
3178
- });
3179
- }
3119
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
3180
3120
  }
3181
- handleDidChangeZoomLevelEvent(ev) {
3182
- const event = EventDataParser.parseIfShouldHandle(ev, {});
3183
- if (event === SKIP || event === null) {
3184
- return;
3121
+ getCurrentState() {
3122
+ return this.controller.getCurrentState();
3123
+ }
3124
+ didChange() {
3125
+ if (this.context) {
3126
+ return this.context.update();
3185
3127
  }
3186
- if (this.privateCamera.isActiveCamera) {
3187
- this.privateCamera.zoomListeners.forEach(listener => {
3188
- var _a;
3189
- (_a = listener === null || listener === void 0 ? void 0 : listener.didChangeZoomLevel) === null || _a === void 0 ? void 0 : _a.call(listener, event.oldZoomLevel, event.newZoomLevel);
3190
- });
3128
+ else {
3129
+ return Promise.resolve();
3191
3130
  }
3192
3131
  }
3132
+ setNativeFrameSourceIsBeingCreated() {
3133
+ // ImageFrameSource has no asynchronous native initialization step, so
3134
+ // there is nothing to track here. The method exists only to satisfy the
3135
+ // PrivateFrameSource contract that DataCaptureContext.setFrameSource()
3136
+ // invokes on every frame source.
3137
+ }
3138
+ }
3139
+ __decorate([
3140
+ nameForSerialization('id')
3141
+ ], ImageFrameSource.prototype, "_id", void 0);
3142
+ __decorate([
3143
+ nameForSerialization('desiredState')
3144
+ ], ImageFrameSource.prototype, "_desiredState", void 0);
3145
+ __decorate([
3146
+ ignoreFromSerialization
3147
+ ], ImageFrameSource.prototype, "listeners", void 0);
3148
+ __decorate([
3149
+ ignoreFromSerialization
3150
+ ], ImageFrameSource.prototype, "_context", void 0);
3151
+ __decorate([
3152
+ ignoreFromSerialization
3153
+ ], ImageFrameSource.prototype, "controller", void 0);
3154
+
3155
+ class PrivateFrameData {
3156
+ get imageBuffers() {
3157
+ return this._imageBuffers;
3158
+ }
3159
+ get imageBuffer() {
3160
+ return this._imageBuffers[0];
3161
+ }
3162
+ get orientation() {
3163
+ return this._orientation;
3164
+ }
3165
+ get timestamp() {
3166
+ return this._timestamp;
3167
+ }
3168
+ static fromJSON(json) {
3169
+ var _a;
3170
+ const frameData = new PrivateFrameData();
3171
+ frameData._imageBuffers = json.imageBuffers.map((imageBufferJSON) => {
3172
+ const imageBuffer = new ImageBuffer();
3173
+ imageBuffer._width = imageBufferJSON.width;
3174
+ imageBuffer._height = imageBufferJSON.height;
3175
+ imageBuffer._data = imageBufferJSON.data;
3176
+ return imageBuffer;
3177
+ });
3178
+ frameData._orientation = json.orientation;
3179
+ frameData._timestamp = (_a = json.timestamp) !== null && _a !== void 0 ? _a : -1;
3180
+ return frameData;
3181
+ }
3182
+ static empty() {
3183
+ const frameData = new PrivateFrameData();
3184
+ frameData._imageBuffers = [];
3185
+ frameData._orientation = 90;
3186
+ frameData._timestamp = -1;
3187
+ return frameData;
3188
+ }
3193
3189
  }
3194
3190
 
3195
3191
  class FrameDataController extends BaseController {
@@ -3219,445 +3215,437 @@ class FrameDataController extends BaseController {
3219
3215
  }
3220
3216
  }
3221
3217
 
3222
- class ControlImage extends DefaultSerializeable {
3223
- static fromBase64EncodedImage(data) {
3224
- if (data === null)
3218
+ var TorchState;
3219
+ (function (TorchState) {
3220
+ TorchState["On"] = "on";
3221
+ TorchState["Off"] = "off";
3222
+ TorchState["Auto"] = "auto";
3223
+ })(TorchState || (TorchState = {}));
3224
+
3225
+ /**
3226
+ * Camera lifecycle and operation handling:
3227
+ *
3228
+ * Phase 1 - Initial State (before native creation starts):
3229
+ * - Camera object exists in TypeScript but not yet being created on native side
3230
+ * - State changes (torch, desired state, settings) only update TypeScript properties
3231
+ * - No native calls are triggered
3232
+ *
3233
+ * Phase 2 - Native Creation In Progress (after setFrameSource, before context set):
3234
+ * - setFrameSource() called on DataCaptureContext, triggering setNativeFrameSourceIsBeingCreated()
3235
+ * - A promise is created that will resolve when the native camera is ready
3236
+ * - State changes during this phase await the native ready promise before executing
3237
+ * - Native camera is created asynchronously
3238
+ *
3239
+ * Phase 3 - Active State (after context set):
3240
+ * - Native camera is ready and available
3241
+ * - The native ready promise is resolved
3242
+ * - All state changes execute immediately on native side
3243
+ */
3244
+ class Camera extends DefaultSerializeable {
3245
+ static get coreDefaults() {
3246
+ return getCoreDefaults();
3247
+ }
3248
+ static create(position, settings, desiredTorchState, desiredState) {
3249
+ const cameraPosition = position || Camera.coreDefaults.Camera.defaultPosition;
3250
+ if (!cameraPosition) {
3251
+ return null;
3252
+ }
3253
+ const existingCamera = Camera._cameraInstances.get(cameraPosition);
3254
+ if (existingCamera) {
3255
+ existingCamera.resetPhaseState();
3256
+ if (settings !== undefined) {
3257
+ existingCamera.settings = settings;
3258
+ }
3259
+ if (desiredTorchState !== undefined) {
3260
+ existingCamera._desiredTorchState = desiredTorchState;
3261
+ void existingCamera.didChange();
3262
+ }
3263
+ if (desiredState !== undefined) {
3264
+ existingCamera._desiredState = desiredState;
3265
+ void existingCamera.controller.switchCameraToDesiredState(desiredState);
3266
+ }
3267
+ return existingCamera;
3268
+ }
3269
+ if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
3225
3270
  return null;
3226
- return new ControlImage("base64", data, null);
3271
+ }
3272
+ const camera = new Camera(cameraPosition, settings, desiredTorchState, desiredState);
3273
+ Camera._cameraInstances.set(cameraPosition, camera);
3274
+ return camera;
3227
3275
  }
3228
- static fromResourceName(resource) {
3229
- return new ControlImage("resource", null, resource);
3276
+ static withSettings(settings) {
3277
+ return Camera.create(undefined, settings);
3230
3278
  }
3231
- constructor(type, data, name) {
3232
- super();
3233
- this.type = type;
3234
- this._data = data;
3235
- this._name = name;
3236
- }
3237
- isBase64EncodedImage() {
3238
- return this.type === "base64";
3239
- }
3240
- get data() {
3241
- return this._data;
3242
- }
3243
- }
3244
- __decorate([
3245
- ignoreFromSerializationIfNull,
3246
- nameForSerialization('data')
3247
- ], ControlImage.prototype, "_data", void 0);
3248
- __decorate([
3249
- ignoreFromSerializationIfNull,
3250
- nameForSerialization('name')
3251
- ], ControlImage.prototype, "_name", void 0);
3252
-
3253
- class ContextStatus {
3254
- static fromJSON(json) {
3255
- const status = new ContextStatus();
3256
- status._code = json.code;
3257
- status._message = json.message;
3258
- status._isValid = json.isValid;
3259
- return status;
3260
- }
3261
- get message() {
3262
- return this._message;
3263
- }
3264
- get code() {
3265
- return this._code;
3279
+ static asPositionWithSettings(cameraPosition, settings) {
3280
+ return Camera.create(cameraPosition, settings);
3266
3281
  }
3267
- get isValid() {
3268
- return this._isValid;
3282
+ static atPosition(cameraPosition) {
3283
+ if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
3284
+ return null;
3285
+ }
3286
+ const existingCamera = Camera._cameraInstances.get(cameraPosition);
3287
+ if (existingCamera) {
3288
+ return existingCamera;
3289
+ }
3290
+ return Camera.create(cameraPosition);
3269
3291
  }
3270
- }
3271
-
3272
- class DataCaptureContextSettings extends DefaultSerializeable {
3273
- constructor() {
3292
+ constructor(position, settings, desiredTorchState, desiredState) {
3274
3293
  super();
3275
- this._frameSettings = new FrameDataSettings();
3276
- }
3277
- get frameDataSettings() {
3278
- return this._frameSettings;
3279
- }
3280
- set frameDataSettings(settings) {
3281
- this._frameSettings = settings;
3282
- }
3283
- frameDataSettingsBuilder() {
3284
- return new FrameDataSettingsBuilder(this._frameSettings);
3285
- }
3286
- setProperty(name, value) {
3287
- this[name] = value;
3288
- }
3289
- getProperty(name) {
3290
- return this[name];
3291
- }
3292
- }
3293
- __decorate([
3294
- nameForSerialization('frameDataSettings')
3295
- ], DataCaptureContextSettings.prototype, "_frameSettings", void 0);
3296
-
3297
- class OpenSourceSoftwareLicenseInfo {
3298
- constructor(licenseText) {
3299
- this._licenseText = licenseText;
3300
- }
3301
- get licenseText() {
3302
- return this._licenseText;
3303
- }
3304
- }
3305
-
3306
- var DataCaptureContextEvents;
3307
- (function (DataCaptureContextEvents) {
3308
- DataCaptureContextEvents["didChangeStatus"] = "DataCaptureContextListener.onStatusChanged";
3309
- DataCaptureContextEvents["didStartObservingContext"] = "DataCaptureContextListener.onObservationStarted";
3310
- })(DataCaptureContextEvents || (DataCaptureContextEvents = {}));
3311
- class DataCaptureContextController extends BaseController {
3312
- get framework() {
3313
- return this._proxy.framework;
3314
- }
3315
- get frameworkVersion() {
3316
- return this._proxy.frameworkVersion;
3317
- }
3318
- get privateContext() {
3319
- return this.context;
3320
- }
3321
- static forDataCaptureContext(context) {
3322
- return new DataCaptureContextController(context);
3323
- }
3324
- static getOpenSourceSoftwareLicenseInfo() {
3325
- return __awaiter(this, void 0, void 0, function* () {
3326
- const proxy = FactoryMaker.getInstance('CoreProxy');
3327
- if (!proxy) {
3328
- return new OpenSourceSoftwareLicenseInfo('Unable to load the open source software license info.');
3329
- }
3330
- const adapter = new CoreProxyAdapter(proxy);
3331
- const result = yield adapter.getOpenSourceSoftwareLicenseInfo();
3332
- return new OpenSourceSoftwareLicenseInfo(result);
3333
- });
3334
- }
3335
- constructor(context) {
3336
- super('DataCaptureContextProxy');
3337
- this._listenerRegistered = false;
3338
- this.adapter = new CoreProxyAdapter(this._proxy);
3339
- this.context = context;
3294
+ this.type = 'camera';
3295
+ this.settings = null;
3296
+ this._desiredTorchState = TorchState.Off;
3297
+ this._desiredState = FrameSourceState.Off;
3298
+ this._hasTorchStateListeners = false;
3299
+ this._hasMacroModeListeners = false;
3300
+ this.currentCameraState = FrameSourceState.Off;
3301
+ this.listeners = [];
3302
+ this.torchListeners = [];
3303
+ this.macroModeListeners = [];
3304
+ this.zoomListeners = [];
3305
+ this._hasZoomListeners = false;
3306
+ this._context = null;
3307
+ this.nativeReadyResolver = null;
3308
+ this.nativeReadyRejecter = null;
3309
+ this.nativeReadyPromise = null;
3310
+ this.nativeReadyTimeout = null;
3311
+ this._position = position || Camera.coreDefaults.Camera.defaultPosition;
3312
+ this.settings = settings || null;
3313
+ this._desiredTorchState = desiredTorchState || TorchState.Off;
3314
+ this._desiredState = desiredState || FrameSourceState.Off;
3315
+ this.controller = new CameraController(this);
3340
3316
  }
3341
- subscribeListener() {
3317
+ switchToDesiredState(state) {
3342
3318
  return __awaiter(this, void 0, void 0, function* () {
3343
- if (this._listenerRegistered) {
3319
+ this._desiredState = state;
3320
+ if (this.nativeReadyPromise) {
3321
+ // Phase 2: Wait for native camera to be ready, then switch state
3322
+ yield this.nativeReadyPromise;
3323
+ yield this.controller.switchCameraToDesiredState(state);
3344
3324
  return;
3345
3325
  }
3346
- yield this.adapter.subscribeContextListener();
3347
- this._proxy.subscribeForEvents(Object.values(DataCaptureContextEvents));
3348
- this._proxy.eventEmitter.on(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
3349
- this._proxy.eventEmitter.on(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
3350
- this._listenerRegistered = true;
3351
- });
3352
- }
3353
- updateContextFromJSON() {
3354
- return __awaiter(this, void 0, void 0, function* () {
3355
- try {
3356
- yield this.adapter.updateContextFromJson({ contextJson: JSON.stringify(this.context.toJSON()) });
3357
- }
3358
- catch (error) {
3359
- this.notifyListenersOfDeserializationError(error);
3360
- throw error;
3361
- }
3362
- });
3363
- }
3364
- addModeToContext(mode) {
3365
- return this.adapter.addModeToContext({ modeJson: JSON.stringify(mode.toJSON()) });
3366
- }
3367
- removeModeFromContext(mode) {
3368
- return this.adapter.removeModeFromContext({ modeJson: JSON.stringify(mode.toJSON()) });
3369
- }
3370
- removeAllModesFromContext() {
3371
- return this.adapter.removeAllModes();
3372
- }
3373
- dispose() {
3374
- void this.unsubscribeListener();
3375
- void this.adapter.disposeContext();
3376
- this._proxy.dispose();
3377
- }
3378
- unsubscribeListener() {
3379
- return __awaiter(this, void 0, void 0, function* () {
3380
- if (!this._listenerRegistered) {
3326
+ if (!this.isActiveCamera) {
3327
+ // Phase 1: Not yet added to context
3328
+ console.warn('The current camera is not added to the DataCaptureContext. Add camera to the DataCaptureContext first.');
3381
3329
  return;
3382
3330
  }
3383
- yield this.adapter.unsubscribeContextListener();
3384
- this._proxy.unsubscribeFromEvents(Object.values(DataCaptureContextEvents));
3385
- this._proxy.eventEmitter.off(DataCaptureContextEvents.didChangeStatus, this.handleDidChangeStatusEvent.bind(this));
3386
- this._proxy.eventEmitter.off(DataCaptureContextEvents.didStartObservingContext, this.handleDidStartObservingContextEvent.bind(this));
3387
- this._listenerRegistered = false;
3331
+ // Phase 3: Execute immediately
3332
+ yield this.controller.switchCameraToDesiredState(state);
3388
3333
  });
3389
3334
  }
3390
- initialize() {
3391
- return this.initializeContextFromJSON();
3335
+ getCurrentState() {
3336
+ return Promise.resolve(this.currentCameraState);
3392
3337
  }
3393
- initializeContextFromJSON() {
3394
- return __awaiter(this, void 0, void 0, function* () {
3395
- try {
3396
- yield this.adapter.createContextFromJson({ contextJson: JSON.stringify(this.context.toJSON()) });
3397
- }
3398
- catch (error) {
3399
- this.notifyListenersOfDeserializationError(error);
3400
- throw error;
3401
- }
3402
- });
3338
+ getIsTorchAvailable() {
3339
+ return this.controller.getIsTorchAvailable();
3403
3340
  }
3404
- handleDidChangeStatusEvent(eventPayload) {
3405
- const event = EventDataParser.parseIfShouldHandle(eventPayload, {});
3406
- if (event === SKIP) {
3341
+ addListener(listener) {
3342
+ if (listener == null) {
3407
3343
  return;
3408
3344
  }
3409
- if (event === null) {
3410
- console.error('DataCaptureContextController didChangeStatus payload is null');
3345
+ if (this.listeners.includes(listener)) {
3411
3346
  return;
3412
3347
  }
3413
- const contextStatus = ContextStatus['fromJSON'](JSON.parse(event.status));
3414
- this.notifyListenersOfDidChangeStatus(contextStatus);
3415
- }
3416
- handleDidStartObservingContextEvent() {
3417
- this.privateContext.listeners.forEach(listener => {
3418
- var _a;
3419
- (_a = listener.didStartObservingContext) === null || _a === void 0 ? void 0 : _a.call(listener, this.context);
3420
- });
3421
- }
3422
- notifyListenersOfDeserializationError(error) {
3423
- const contextStatus = ContextStatus['fromJSON']({
3424
- message: error,
3425
- code: -1,
3426
- isValid: true,
3427
- });
3428
- this.notifyListenersOfDidChangeStatus(contextStatus);
3429
- }
3430
- notifyListenersOfDidChangeStatus(contextStatus) {
3431
- this.privateContext.listeners.forEach(listener => {
3432
- if (listener.didChangeStatus) {
3433
- listener.didChangeStatus(this.context, contextStatus);
3434
- }
3435
- });
3348
+ this.listeners.push(listener);
3436
3349
  }
3437
- }
3438
-
3439
- class DataCaptureContext extends DefaultSerializeable {
3440
- static get sharedInstance() {
3441
- if (DataCaptureContext._instance == null) {
3442
- DataCaptureContext._instance = new DataCaptureContext('', '', null);
3350
+ removeListener(listener) {
3351
+ if (listener == null) {
3352
+ return;
3443
3353
  }
3444
- return DataCaptureContext._instance;
3354
+ if (!this.listeners.includes(listener)) {
3355
+ return;
3356
+ }
3357
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
3445
3358
  }
3446
- static getOpenSourceSoftwareLicenseInfo() {
3447
- return __awaiter(this, void 0, void 0, function* () {
3448
- return DataCaptureContextController.getOpenSourceSoftwareLicenseInfo();
3449
- });
3450
- }
3451
- static get coreDefaults() {
3452
- return getCoreDefaults();
3453
- }
3454
- get frameSource() {
3455
- return this._frameSource;
3456
- }
3457
- static get deviceID() {
3458
- return DataCaptureContext.coreDefaults.deviceID;
3459
- }
3460
- static forLicenseKey(licenseKey) {
3461
- const instance = DataCaptureContext.create(licenseKey, null, null);
3462
- // Call initialize to ensure the shared instance is updated.
3463
- void instance.controller.initialize();
3464
- return instance;
3359
+ addTorchListener(listener) {
3360
+ if (this.torchListeners.includes(listener)) {
3361
+ return;
3362
+ }
3363
+ this.torchListeners.push(listener);
3364
+ this._hasTorchStateListeners = this.torchListeners.length > 0;
3365
+ if (this.torchListeners.length === 1) {
3366
+ void this.controller.subscribeTorchListener();
3367
+ }
3368
+ if (this.isActiveCamera) {
3369
+ void this.didChange();
3370
+ }
3465
3371
  }
3466
- static forLicenseKeyWithSettings(licenseKey, settings) {
3467
- const instance = DataCaptureContext.create(licenseKey, null, settings);
3468
- // Call initialize to ensure the shared instance is updated.
3469
- void instance.controller.initialize();
3470
- return instance;
3372
+ removeTorchListener(listener) {
3373
+ if (!this.torchListeners.includes(listener)) {
3374
+ return;
3375
+ }
3376
+ this.torchListeners.splice(this.torchListeners.indexOf(listener), 1);
3377
+ this._hasTorchStateListeners = this.torchListeners.length > 0;
3378
+ if (this.torchListeners.length === 0) {
3379
+ void this.controller.unsubscribeTorchListener();
3380
+ }
3381
+ if (this.isActiveCamera) {
3382
+ void this.didChange();
3383
+ }
3471
3384
  }
3472
- static forLicenseKeyWithOptions(licenseKey, options) {
3473
- const instance = DataCaptureContext.create(licenseKey, options, null);
3474
- // Call initialize to ensure the shared instance is updated.
3475
- void instance.controller.initialize();
3476
- return instance;
3385
+ addMacroModeListener(listener) {
3386
+ if (this.macroModeListeners.includes(listener)) {
3387
+ return;
3388
+ }
3389
+ this.macroModeListeners.push(listener);
3390
+ this._hasMacroModeListeners = this.macroModeListeners.length > 0;
3391
+ if (this.macroModeListeners.length === 1) {
3392
+ void this.controller.subscribeMacroModeListener();
3393
+ }
3394
+ if (this.isActiveCamera) {
3395
+ void this.didChange();
3396
+ }
3477
3397
  }
3478
- static initialize(licenseKey, options = null, settings = null) {
3479
- DataCaptureContext.create(licenseKey, options, settings);
3480
- void DataCaptureContext.sharedInstance.controller.initialize();
3481
- return DataCaptureContext.sharedInstance;
3398
+ removeMacroModeListener(listener) {
3399
+ if (!this.macroModeListeners.includes(listener)) {
3400
+ return;
3401
+ }
3402
+ this.macroModeListeners.splice(this.macroModeListeners.indexOf(listener), 1);
3403
+ this._hasMacroModeListeners = this.macroModeListeners.length > 0;
3404
+ if (this.macroModeListeners.length === 0) {
3405
+ void this.controller.unsubscribeMacroModeListener();
3406
+ }
3407
+ if (this.isActiveCamera) {
3408
+ void this.didChange();
3409
+ }
3482
3410
  }
3483
- static create(licenseKey, options, settings) {
3484
- DataCaptureContext.sharedInstance.licenseKey = licenseKey;
3485
- DataCaptureContext.sharedInstance.deviceName = (options === null || options === void 0 ? void 0 : options.deviceName) || '';
3486
- DataCaptureContext.sharedInstance.settings = settings || new DataCaptureContextSettings();
3487
- return DataCaptureContext.sharedInstance;
3411
+ addZoomListener(listener) {
3412
+ if (this.zoomListeners.includes(listener)) {
3413
+ return;
3414
+ }
3415
+ this.zoomListeners.push(listener);
3416
+ this._hasZoomListeners = this.zoomListeners.length > 0;
3417
+ if (this.zoomListeners.length === 1) {
3418
+ void this.controller.subscribeZoomListener();
3419
+ }
3420
+ if (this.isActiveCamera) {
3421
+ void this.didChange();
3422
+ }
3488
3423
  }
3489
- constructor(licenseKey, deviceName, settings) {
3490
- super();
3491
- this.licenseKey = licenseKey;
3492
- this.deviceName = deviceName;
3493
- this._framework = 'unknown';
3494
- this._frameworkVersion = 'unknown';
3495
- this.settings = new DataCaptureContextSettings();
3496
- this._frameSource = null;
3497
- this.view = null;
3498
- this.modes = [];
3499
- this.listeners = [];
3500
- this.licenseKey = licenseKey;
3501
- this.deviceName = deviceName;
3502
- if (settings) {
3503
- this.settings = settings;
3424
+ removeZoomListener(listener) {
3425
+ if (!this.zoomListeners.includes(listener)) {
3426
+ return;
3504
3427
  }
3505
- if (this.controller == null) {
3506
- this.controller = DataCaptureContextController.forDataCaptureContext(this);
3507
- this._framework = this.controller.framework;
3508
- this._frameworkVersion = this.controller.frameworkVersion;
3428
+ this.zoomListeners.splice(this.zoomListeners.indexOf(listener), 1);
3429
+ this._hasZoomListeners = this.zoomListeners.length > 0;
3430
+ if (this.zoomListeners.length === 0) {
3431
+ void this.controller.unsubscribeZoomListener();
3432
+ }
3433
+ if (this.isActiveCamera) {
3434
+ void this.didChange();
3509
3435
  }
3510
3436
  }
3511
- setFrameSource(frameSource) {
3437
+ applySettings(settings) {
3512
3438
  return __awaiter(this, void 0, void 0, function* () {
3513
- if (this._frameSource) {
3514
- this._frameSource.context = null;
3515
- }
3516
- this._frameSource = frameSource;
3517
- if (frameSource) {
3518
- // Set the flag to indicate that the native frame source is being created
3519
- frameSource.setNativeFrameSourceIsBeingCreated();
3439
+ this.settings = settings;
3440
+ if (this.nativeReadyPromise) {
3441
+ // Phase 2: Wait for native camera to be ready, then apply settings
3442
+ yield this.nativeReadyPromise;
3443
+ yield this.didChange();
3520
3444
  }
3521
- yield this.update();
3522
- // Make camera active once the set on native side is complete
3523
- if (frameSource) {
3524
- frameSource.context = this;
3445
+ else if (this.isActiveCamera) {
3446
+ // Phase 3: Execute immediately
3447
+ yield this.didChange();
3525
3448
  }
3449
+ // Phase 1: Just update the property, no action needed
3526
3450
  });
3527
3451
  }
3528
- addListener(listener) {
3529
- return __awaiter(this, void 0, void 0, function* () {
3530
- if (this.listeners.length === 0) {
3531
- yield this.controller.subscribeListener();
3532
- }
3533
- if (this.listeners.includes(listener)) {
3534
- return;
3452
+ set context(newContext) {
3453
+ this._context = newContext;
3454
+ if (newContext) {
3455
+ // Phase 3: Native camera is ready, resolve the promise so waiting operations can proceed
3456
+ if (this.nativeReadyTimeout) {
3457
+ clearTimeout(this.nativeReadyTimeout);
3458
+ this.nativeReadyTimeout = null;
3535
3459
  }
3536
- this.listeners.push(listener);
3537
- });
3538
- }
3539
- removeListener(listener) {
3540
- return __awaiter(this, void 0, void 0, function* () {
3541
- if (!this.listeners.includes(listener)) {
3542
- return;
3460
+ if (this.nativeReadyResolver) {
3461
+ this.nativeReadyResolver();
3462
+ this.nativeReadyResolver = null;
3463
+ this.nativeReadyRejecter = null;
3464
+ this.nativeReadyPromise = null;
3543
3465
  }
3544
- this.listeners.splice(this.listeners.indexOf(listener), 1);
3545
- if (this.listeners.length === 0) {
3546
- return this.controller.unsubscribeListener();
3466
+ }
3467
+ else {
3468
+ // When context is removed, reset everything
3469
+ if (this.nativeReadyTimeout) {
3470
+ clearTimeout(this.nativeReadyTimeout);
3471
+ this.nativeReadyTimeout = null;
3547
3472
  }
3548
- });
3473
+ this.nativeReadyResolver = null;
3474
+ this.nativeReadyRejecter = null;
3475
+ this.nativeReadyPromise = null;
3476
+ }
3549
3477
  }
3550
- addMode(mode) {
3551
- return __awaiter(this, void 0, void 0, function* () {
3552
- yield this.addModeInternal(mode);
3553
- });
3478
+ get context() {
3479
+ return this._context;
3554
3480
  }
3555
- setMode(mode) {
3556
- return __awaiter(this, void 0, void 0, function* () {
3557
- yield this.removeAllModes();
3558
- yield this.addModeInternal(mode);
3481
+ setNativeFrameSourceIsBeingCreated() {
3482
+ this.nativeReadyPromise = new Promise((resolve, reject) => {
3483
+ this.nativeReadyResolver = resolve;
3484
+ this.nativeReadyRejecter = reject;
3485
+ this.nativeReadyTimeout = setTimeout(() => {
3486
+ this.nativeReadyTimeout = null;
3487
+ if (this.nativeReadyRejecter) {
3488
+ this.nativeReadyRejecter(new Error('Camera native initialization timed out after 5 seconds'));
3489
+ this.nativeReadyResolver = null;
3490
+ this.nativeReadyRejecter = null;
3491
+ this.nativeReadyPromise = null;
3492
+ }
3493
+ }, 5000);
3559
3494
  });
3560
3495
  }
3561
- removeCurrentMode() {
3562
- return __awaiter(this, void 0, void 0, function* () {
3563
- if (this.modes.length === 0) {
3564
- return;
3565
- }
3566
- if (this.modes.length > 1) {
3567
- console.warn('removeCurrentMode() called with multiple modes active. Consider using removeMode() for specific mode removal. Only the first mode will be removed.');
3568
- }
3569
- yield this.removeModeInternal(this.modes[0]);
3570
- });
3496
+ get isActiveCamera() {
3497
+ return this._context !== null;
3571
3498
  }
3572
- removeMode(mode) {
3573
- return __awaiter(this, void 0, void 0, function* () {
3574
- yield this.removeModeInternal(mode);
3575
- });
3499
+ static get default() {
3500
+ const defaultPosition = Camera.coreDefaults.Camera.defaultPosition;
3501
+ if (!defaultPosition) {
3502
+ return null;
3503
+ }
3504
+ return Camera.atPosition(defaultPosition);
3576
3505
  }
3577
- removeAllModes() {
3506
+ static isMacroModeAvailable() {
3578
3507
  return __awaiter(this, void 0, void 0, function* () {
3579
- if (this.modes.length === 0) {
3580
- return;
3508
+ const proxy = FactoryMaker.getInstance('CoreProxy');
3509
+ if (!proxy) {
3510
+ return false;
3581
3511
  }
3582
- this.modes.forEach(mode => {
3583
- mode._context = null;
3584
- });
3585
- this.modes = [];
3586
- yield this.controller.removeAllModesFromContext();
3512
+ const adapter = new CoreProxyAdapter(proxy);
3513
+ return yield adapter.isMacroModeAvailable();
3587
3514
  });
3588
3515
  }
3589
- dispose() {
3590
- return __awaiter(this, void 0, void 0, function* () {
3591
- var _a;
3592
- if (!this.controller) {
3593
- return;
3594
- }
3595
- (_a = this.view) === null || _a === void 0 ? void 0 : _a.dispose();
3596
- yield this.removeAllModes();
3597
- this.controller.dispose();
3598
- });
3516
+ get position() {
3517
+ return this._position;
3599
3518
  }
3600
- applySettings(settings) {
3601
- return __awaiter(this, void 0, void 0, function* () {
3602
- this.settings = settings;
3603
- yield this.update();
3604
- });
3519
+ get isTorchAvailable() {
3520
+ return this.controller.getIsTorchAvailable();
3605
3521
  }
3606
- update() {
3607
- return __awaiter(this, void 0, void 0, function* () {
3608
- if (!this.controller) {
3609
- return;
3610
- }
3611
- yield this.controller.updateContextFromJSON();
3612
- });
3522
+ get desiredState() {
3523
+ return this._desiredState;
3613
3524
  }
3614
- addModeInternal(mode) {
3615
- return __awaiter(this, void 0, void 0, function* () {
3616
- if (!this.modes.includes(mode)) {
3617
- this.modes.push(mode);
3618
- yield this.controller.addModeToContext(mode);
3619
- mode._context = this;
3620
- }
3621
- });
3525
+ set desiredTorchState(desiredTorchState) {
3526
+ this._desiredTorchState = desiredTorchState;
3527
+ if (this.nativeReadyPromise) {
3528
+ // Phase 2: Wait for native camera to be ready, then update
3529
+ void this.nativeReadyPromise.then(() => this.didChange());
3530
+ }
3531
+ else if (this.isActiveCamera) {
3532
+ // Phase 3: Execute immediately
3533
+ void this.didChange();
3534
+ }
3535
+ // Phase 1: Just update the property, no action needed
3622
3536
  }
3623
- removeModeInternal(mode) {
3537
+ get desiredTorchState() {
3538
+ return this._desiredTorchState;
3539
+ }
3540
+ didChange() {
3624
3541
  return __awaiter(this, void 0, void 0, function* () {
3625
- const index = this.modes.indexOf(mode);
3626
- if (index !== -1) {
3627
- this.modes.splice(index, 1);
3542
+ if (this.context) {
3543
+ yield this.context.update();
3628
3544
  }
3629
- mode._context = null;
3630
- yield this.controller.removeModeFromContext(mode);
3631
3545
  });
3632
3546
  }
3547
+ resetPhaseState() {
3548
+ if (this.nativeReadyTimeout) {
3549
+ clearTimeout(this.nativeReadyTimeout);
3550
+ this.nativeReadyTimeout = null;
3551
+ }
3552
+ this.nativeReadyResolver = null;
3553
+ this.nativeReadyRejecter = null;
3554
+ this.nativeReadyPromise = null;
3555
+ }
3633
3556
  }
3557
+ Camera._cameraInstances = new Map();
3634
3558
  __decorate([
3635
3559
  ignoreFromSerialization
3636
- ], DataCaptureContext.prototype, "controller", void 0);
3560
+ ], Camera.prototype, "controller", void 0);
3637
3561
  __decorate([
3638
- nameForSerialization('framework')
3639
- ], DataCaptureContext.prototype, "_framework", void 0);
3562
+ serializationDefault({})
3563
+ ], Camera.prototype, "settings", void 0);
3640
3564
  __decorate([
3641
- nameForSerialization('frameworkVersion')
3642
- ], DataCaptureContext.prototype, "_frameworkVersion", void 0);
3565
+ nameForSerialization('position')
3566
+ ], Camera.prototype, "_position", void 0);
3643
3567
  __decorate([
3644
- nameForSerialization('frameSource')
3645
- ], DataCaptureContext.prototype, "_frameSource", void 0);
3568
+ nameForSerialization('desiredTorchState')
3569
+ ], Camera.prototype, "_desiredTorchState", void 0);
3570
+ __decorate([
3571
+ nameForSerialization('desiredState')
3572
+ ], Camera.prototype, "_desiredState", void 0);
3573
+ __decorate([
3574
+ nameForSerialization('hasTorchStateListeners')
3575
+ ], Camera.prototype, "_hasTorchStateListeners", void 0);
3576
+ __decorate([
3577
+ nameForSerialization('hasMacroModeListeners')
3578
+ ], Camera.prototype, "_hasMacroModeListeners", void 0);
3646
3579
  __decorate([
3647
3580
  ignoreFromSerialization
3648
- ], DataCaptureContext.prototype, "view", void 0);
3581
+ ], Camera.prototype, "currentCameraState", void 0);
3649
3582
  __decorate([
3650
3583
  ignoreFromSerialization
3651
- ], DataCaptureContext.prototype, "modes", void 0);
3584
+ ], Camera.prototype, "listeners", void 0);
3652
3585
  __decorate([
3653
3586
  ignoreFromSerialization
3654
- ], DataCaptureContext.prototype, "listeners", void 0);
3587
+ ], Camera.prototype, "torchListeners", void 0);
3655
3588
  __decorate([
3656
3589
  ignoreFromSerialization
3657
- ], DataCaptureContext, "_instance", void 0);
3590
+ ], Camera.prototype, "macroModeListeners", void 0);
3658
3591
  __decorate([
3659
3592
  ignoreFromSerialization
3660
- ], DataCaptureContext, "coreDefaults", null);
3593
+ ], Camera.prototype, "zoomListeners", void 0);
3594
+ __decorate([
3595
+ nameForSerialization('hasZoomListeners')
3596
+ ], Camera.prototype, "_hasZoomListeners", void 0);
3597
+ __decorate([
3598
+ ignoreFromSerialization
3599
+ ], Camera.prototype, "_context", void 0);
3600
+ __decorate([
3601
+ ignoreFromSerialization
3602
+ ], Camera.prototype, "nativeReadyResolver", void 0);
3603
+ __decorate([
3604
+ ignoreFromSerialization
3605
+ ], Camera.prototype, "nativeReadyRejecter", void 0);
3606
+ __decorate([
3607
+ ignoreFromSerialization
3608
+ ], Camera.prototype, "nativeReadyPromise", void 0);
3609
+ __decorate([
3610
+ ignoreFromSerialization
3611
+ ], Camera.prototype, "nativeReadyTimeout", void 0);
3612
+ __decorate([
3613
+ ignoreFromSerialization
3614
+ ], Camera, "_cameraInstances", void 0);
3615
+ __decorate([
3616
+ ignoreFromSerialization
3617
+ ], Camera, "coreDefaults", null);
3618
+
3619
+ class ControlImage extends DefaultSerializeable {
3620
+ static fromBase64EncodedImage(data) {
3621
+ if (data === null)
3622
+ return null;
3623
+ return new ControlImage('base64', data, null);
3624
+ }
3625
+ static fromResourceName(resource) {
3626
+ return new ControlImage('resource', null, resource);
3627
+ }
3628
+ constructor(type, data, name) {
3629
+ super();
3630
+ this.type = type;
3631
+ this._data = data;
3632
+ this._name = name;
3633
+ }
3634
+ isBase64EncodedImage() {
3635
+ return this.type === 'base64';
3636
+ }
3637
+ get data() {
3638
+ return this._data;
3639
+ }
3640
+ }
3641
+ __decorate([
3642
+ ignoreFromSerializationIfNull,
3643
+ nameForSerialization('data')
3644
+ ], ControlImage.prototype, "_data", void 0);
3645
+ __decorate([
3646
+ ignoreFromSerializationIfNull,
3647
+ nameForSerialization('name')
3648
+ ], ControlImage.prototype, "_name", void 0);
3661
3649
 
3662
3650
  var DataCaptureViewEvents;
3663
3651
  (function (DataCaptureViewEvents) {
@@ -3688,13 +3676,19 @@ class DataCaptureViewController extends BaseController {
3688
3676
  }
3689
3677
  viewPointForFramePoint(point) {
3690
3678
  return __awaiter(this, void 0, void 0, function* () {
3691
- const result = yield this.adapter.viewPointForFramePoint({ viewId: this.view.viewId, pointJson: JSON.stringify(point.toJSON()) });
3679
+ const result = yield this.adapter.viewPointForFramePoint({
3680
+ viewId: this.view.viewId,
3681
+ pointJson: JSON.stringify(point.toJSON()),
3682
+ });
3692
3683
  return Point['fromJSON'](JSON.parse(result));
3693
3684
  });
3694
3685
  }
3695
3686
  viewQuadrilateralForFrameQuadrilateral(quadrilateral) {
3696
3687
  return __awaiter(this, void 0, void 0, function* () {
3697
- const result = yield this.adapter.viewQuadrilateralForFrameQuadrilateral({ viewId: this.view.viewId, quadrilateralJson: JSON.stringify(quadrilateral.toJSON()) });
3688
+ const result = yield this.adapter.viewQuadrilateralForFrameQuadrilateral({
3689
+ viewId: this.view.viewId,
3690
+ quadrilateralJson: JSON.stringify(quadrilateral.toJSON()),
3691
+ });
3698
3692
  return Quadrilateral['fromJSON'](JSON.parse(result));
3699
3693
  });
3700
3694
  }
@@ -3862,7 +3856,10 @@ class DataCaptureViewController extends BaseController {
3862
3856
  return;
3863
3857
  }
3864
3858
  yield this.adapter.registerZoomGestureListener({ viewId: this.view.viewId });
3865
- this._proxy.subscribeForEvents([ZoomGestureListenerEvents.onZoomInGesture, ZoomGestureListenerEvents.onZoomOutGesture]);
3859
+ this._proxy.subscribeForEvents([
3860
+ ZoomGestureListenerEvents.onZoomInGesture,
3861
+ ZoomGestureListenerEvents.onZoomOutGesture,
3862
+ ]);
3866
3863
  this._proxy.eventEmitter.on(ZoomGestureListenerEvents.onZoomInGesture, this.handleOnZoomInGestureEventWrapper);
3867
3864
  this._proxy.eventEmitter.on(ZoomGestureListenerEvents.onZoomOutGesture, this.handleOnZoomOutGestureEventWrapper);
3868
3865
  this._zoomGestureListenerRegistered = true;
@@ -3874,14 +3871,19 @@ class DataCaptureViewController extends BaseController {
3874
3871
  return;
3875
3872
  }
3876
3873
  yield this.adapter.unregisterZoomGestureListener({ viewId: this.view.viewId });
3877
- this._proxy.unsubscribeFromEvents([ZoomGestureListenerEvents.onZoomInGesture, ZoomGestureListenerEvents.onZoomOutGesture]);
3874
+ this._proxy.unsubscribeFromEvents([
3875
+ ZoomGestureListenerEvents.onZoomInGesture,
3876
+ ZoomGestureListenerEvents.onZoomOutGesture,
3877
+ ]);
3878
3878
  this._proxy.eventEmitter.off(ZoomGestureListenerEvents.onZoomInGesture, this.handleOnZoomInGestureEventWrapper);
3879
3879
  this._proxy.eventEmitter.off(ZoomGestureListenerEvents.onZoomOutGesture, this.handleOnZoomOutGestureEventWrapper);
3880
3880
  this._zoomGestureListenerRegistered = false;
3881
3881
  });
3882
3882
  }
3883
3883
  handleOnZoomInGestureEvent(eventPayload) {
3884
- const event = EventDataParser.parseIfShouldHandle(eventPayload, { viewId: this.view.viewId });
3884
+ const event = EventDataParser.parseIfShouldHandle(eventPayload, {
3885
+ viewId: this.view.viewId,
3886
+ });
3885
3887
  if (event === SKIP) {
3886
3888
  return;
3887
3889
  }
@@ -3901,7 +3903,9 @@ class DataCaptureViewController extends BaseController {
3901
3903
  }
3902
3904
  }
3903
3905
  handleOnZoomOutGestureEvent(eventPayload) {
3904
- const event = EventDataParser.parseIfShouldHandle(eventPayload, { viewId: this.view.viewId });
3906
+ const event = EventDataParser.parseIfShouldHandle(eventPayload, {
3907
+ viewId: this.view.viewId,
3908
+ });
3905
3909
  if (event === SKIP) {
3906
3910
  return;
3907
3911
  }
@@ -3924,7 +3928,9 @@ class DataCaptureViewController extends BaseController {
3924
3928
  return this._proxy.$createDataCaptureView({ viewJson: JSON.stringify(this.view.toJSON()) });
3925
3929
  }
3926
3930
  handleDidChangeSizeEvent(eventPayload) {
3927
- const event = EventDataParser.parseIfShouldHandle(eventPayload, { viewId: this.view.viewId });
3931
+ const event = EventDataParser.parseIfShouldHandle(eventPayload, {
3932
+ viewId: this.view.viewId,
3933
+ });
3928
3934
  if (event === SKIP) {
3929
3935
  return;
3930
3936
  }
@@ -4665,7 +4671,7 @@ class CameraSettings extends DefaultSerializeable {
4665
4671
  'manualLensPosition',
4666
4672
  'shouldPreferSmoothAutoFocus',
4667
4673
  'focusStrategy',
4668
- 'focusGestureStrategy'
4674
+ 'focusGestureStrategy',
4669
4675
  ];
4670
4676
  this.focus = {
4671
4677
  range: CameraSettings.coreDefaults.Camera.Settings.focusRange,
@@ -4674,9 +4680,11 @@ class CameraSettings extends DefaultSerializeable {
4674
4680
  manualLensPosition: CameraSettings.coreDefaults.Camera.Settings.manualLensPosition,
4675
4681
  focusStrategy: CameraSettings.coreDefaults.Camera.Settings.focusStrategy,
4676
4682
  };
4677
- this.preferredResolution = (_a = settings === null || settings === void 0 ? void 0 : settings.preferredResolution) !== null && _a !== void 0 ? _a : CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
4683
+ this.preferredResolution =
4684
+ (_a = settings === null || settings === void 0 ? void 0 : settings.preferredResolution) !== null && _a !== void 0 ? _a : CameraSettings.coreDefaults.Camera.Settings.preferredResolution;
4678
4685
  this.zoomFactor = (_b = settings === null || settings === void 0 ? void 0 : settings.zoomFactor) !== null && _b !== void 0 ? _b : CameraSettings.coreDefaults.Camera.Settings.zoomFactor;
4679
- this.zoomGestureZoomFactor = (_c = settings === null || settings === void 0 ? void 0 : settings.zoomGestureZoomFactor) !== null && _c !== void 0 ? _c : CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
4686
+ this.zoomGestureZoomFactor =
4687
+ (_c = settings === null || settings === void 0 ? void 0 : settings.zoomGestureZoomFactor) !== null && _c !== void 0 ? _c : CameraSettings.coreDefaults.Camera.Settings.zoomGestureZoomFactor;
4680
4688
  this.torchLevel = (_d = settings === null || settings === void 0 ? void 0 : settings.torchLevel) !== null && _d !== void 0 ? _d : CameraSettings.coreDefaults.Camera.Settings.torchLevel;
4681
4689
  this.macroMode = (_e = settings === null || settings === void 0 ? void 0 : settings.macroMode) !== null && _e !== void 0 ? _e : CameraSettings.coreDefaults.Camera.Settings.macroMode;
4682
4690
  this.adaptiveExposure = (_f = settings === null || settings === void 0 ? void 0 : settings.adaptiveExposure) !== null && _f !== void 0 ? _f : CameraSettings.coreDefaults.Camera.Settings.adaptiveExposure;
@@ -4734,27 +4742,301 @@ var ZoomSwitchOrientation;
4734
4742
  ZoomSwitchOrientation["Vertical"] = "vertical";
4735
4743
  })(ZoomSwitchOrientation || (ZoomSwitchOrientation = {}));
4736
4744
 
4737
- const NoViewfinder = { type: 'none' };
4745
+ var CameraPosition;
4746
+ (function (CameraPosition) {
4747
+ CameraPosition["WorldFacing"] = "worldFacing";
4748
+ CameraPosition["UserFacing"] = "userFacing";
4749
+ CameraPosition["Unspecified"] = "unspecified";
4750
+ })(CameraPosition || (CameraPosition = {}));
4738
4751
 
4739
- class RectangularViewfinderAnimation extends DefaultSerializeable {
4740
- static fromJSON(json) {
4741
- if (json === null) {
4752
+ class CameraOwnershipManager {
4753
+ static getInstance() {
4754
+ if (!CameraOwnershipManager.instance) {
4755
+ CameraOwnershipManager.instance = new CameraOwnershipManager();
4756
+ }
4757
+ return CameraOwnershipManager.instance;
4758
+ }
4759
+ constructor() {
4760
+ this.owners = new Map();
4761
+ this.waitingQueue = new Map();
4762
+ this.protectedCameras = new Set();
4763
+ }
4764
+ requestOwnership(position, owner) {
4765
+ const currentOwner = this.owners.get(position);
4766
+ if (currentOwner && currentOwner.id !== owner.id) {
4767
+ return false; // Already owned by someone else
4768
+ }
4769
+ this.owners.set(position, owner);
4770
+ this.enableProtectionForOwner(position, owner);
4771
+ return true;
4772
+ }
4773
+ requestOwnershipAsync(position, owner, timeoutMs) {
4774
+ return __awaiter(this, void 0, void 0, function* () {
4775
+ // Try immediate acquisition first
4776
+ if (this.requestOwnership(position, owner)) {
4777
+ return true;
4778
+ }
4779
+ // If not available, wait in queue
4780
+ return new Promise(resolve => {
4781
+ const request = { owner, resolve };
4782
+ if (!this.waitingQueue.has(position)) {
4783
+ this.waitingQueue.set(position, []);
4784
+ }
4785
+ this.waitingQueue.get(position).push(request);
4786
+ // Optional timeout
4787
+ if (timeoutMs && timeoutMs > 0) {
4788
+ setTimeout(() => {
4789
+ this.removeFromQueue(position, request);
4790
+ resolve(false); // Timeout - ownership not acquired
4791
+ }, timeoutMs);
4792
+ }
4793
+ });
4794
+ });
4795
+ }
4796
+ releaseOwnership(position, owner) {
4797
+ const currentOwner = this.owners.get(position);
4798
+ if (!currentOwner || currentOwner.id !== owner.id) {
4799
+ return false; // Not the owner
4800
+ }
4801
+ this.owners.delete(position);
4802
+ this.disableProtectionForPosition(position);
4803
+ this.processWaitingQueue(position);
4804
+ return true;
4805
+ }
4806
+ isOwner(position, owner) {
4807
+ const currentOwner = this.owners.get(position);
4808
+ return (currentOwner === null || currentOwner === void 0 ? void 0 : currentOwner.id) === owner.id;
4809
+ }
4810
+ getCurrentOwner(position) {
4811
+ return this.owners.get(position) || null;
4812
+ }
4813
+ checkOwnership(position, owner) {
4814
+ return this.isOwner(position, owner);
4815
+ }
4816
+ getOwnedPosition(owner) {
4817
+ for (const [position, currentOwner] of this.owners.entries()) {
4818
+ if (currentOwner.id === owner.id) {
4819
+ return position;
4820
+ }
4821
+ }
4822
+ return null;
4823
+ }
4824
+ getAllOwnedPositions(owner) {
4825
+ const positions = [];
4826
+ for (const [position, currentOwner] of this.owners.entries()) {
4827
+ if (currentOwner.id === owner.id) {
4828
+ positions.push(position);
4829
+ }
4830
+ }
4831
+ return positions;
4832
+ }
4833
+ enableProtectionForOwner(position, owner) {
4834
+ const camera = Camera.atPosition(position);
4835
+ if (!camera || this.protectedCameras.has(camera)) {
4836
+ return; // Camera not available or already protected
4837
+ }
4838
+ this.protectCameraForOwner(camera, position, owner);
4839
+ this.protectedCameras.add(camera);
4840
+ }
4841
+ disableProtectionForPosition(position) {
4842
+ const camera = Camera.atPosition(position);
4843
+ if (!camera || !this.protectedCameras.has(camera)) {
4844
+ return;
4845
+ }
4846
+ this.unprotectCamera(camera);
4847
+ this.protectedCameras.delete(camera);
4848
+ }
4849
+ processWaitingQueue(position) {
4850
+ const queue = this.waitingQueue.get(position);
4851
+ if (!queue || queue.length === 0) {
4852
+ return;
4853
+ }
4854
+ // Give ownership to the first in queue
4855
+ const nextRequest = queue.shift();
4856
+ this.owners.set(position, nextRequest.owner);
4857
+ this.enableProtectionForOwner(position, nextRequest.owner);
4858
+ nextRequest.resolve(true);
4859
+ // Clean up empty queue
4860
+ if (queue.length === 0) {
4861
+ this.waitingQueue.delete(position);
4862
+ }
4863
+ }
4864
+ removeFromQueue(position, requestToRemove) {
4865
+ const queue = this.waitingQueue.get(position);
4866
+ if (!queue)
4867
+ return;
4868
+ const index = queue.indexOf(requestToRemove);
4869
+ if (index > -1) {
4870
+ queue.splice(index, 1);
4871
+ }
4872
+ if (queue.length === 0) {
4873
+ this.waitingQueue.delete(position);
4874
+ }
4875
+ }
4876
+ protectCameraForOwner(camera, position, _owner) {
4877
+ var _a, _b, _c, _d;
4878
+ const originalSwitchToDesiredState = camera.switchToDesiredState.bind(camera);
4879
+ const originalApplySettings = camera.applySettings.bind(camera);
4880
+ 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);
4881
+ // Protect switchToDesiredState - only owner can call it
4882
+ camera.switchToDesiredState = (state) => __awaiter(this, void 0, void 0, function* () {
4883
+ const currentOwner = this.getCurrentOwner(position);
4884
+ if (!currentOwner) {
4885
+ throw new Error(`Camera operation denied: No owner for camera at ${position}`);
4886
+ }
4887
+ // Allow operation - the owner is the only one who should have access to this camera instance
4888
+ return originalSwitchToDesiredState(state);
4889
+ });
4890
+ // Protect applySettings - only owner can call it
4891
+ camera.applySettings = (settings) => __awaiter(this, void 0, void 0, function* () {
4892
+ const currentOwner = this.getCurrentOwner(position);
4893
+ if (!currentOwner) {
4894
+ throw new Error(`Camera operation denied: No owner for camera at ${position}`);
4895
+ }
4896
+ return originalApplySettings(settings);
4897
+ });
4898
+ // Protect desiredTorchState setter - only owner can set it
4899
+ if (originalSetDesiredTorchState) {
4900
+ Object.defineProperty(camera, 'desiredTorchState', {
4901
+ set: (value) => {
4902
+ const currentOwner = this.getCurrentOwner(position);
4903
+ if (!currentOwner) {
4904
+ throw new Error(`Camera operation denied: No owner for camera at ${position}`);
4905
+ }
4906
+ originalSetDesiredTorchState(value);
4907
+ },
4908
+ 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),
4909
+ configurable: true,
4910
+ });
4911
+ }
4912
+ // Store originals for restoration
4913
+ camera.__originalMethods = {
4914
+ switchToDesiredState: originalSwitchToDesiredState,
4915
+ applySettings: originalApplySettings,
4916
+ setDesiredTorchState: originalSetDesiredTorchState,
4917
+ };
4918
+ }
4919
+ unprotectCamera(camera) {
4920
+ var _a, _b;
4921
+ const originals = camera.__originalMethods;
4922
+ if (!originals)
4923
+ return;
4924
+ // Restore original methods
4925
+ camera.switchToDesiredState = originals.switchToDesiredState;
4926
+ camera.applySettings = originals.applySettings;
4927
+ if (originals.setDesiredTorchState) {
4928
+ Object.defineProperty(camera, 'desiredTorchState', {
4929
+ set: originals.setDesiredTorchState,
4930
+ 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),
4931
+ configurable: true,
4932
+ });
4933
+ }
4934
+ delete camera.__originalMethods;
4935
+ }
4936
+ }
4937
+
4938
+ class CameraOwnershipHelper {
4939
+ /**
4940
+ * Get camera instance for the owner (only works if you own it)
4941
+ */
4942
+ static getCamera(position, owner) {
4943
+ // Check ownership
4944
+ if (!this.ownershipManager.checkOwnership(position, owner)) {
4945
+ console.warn(`Camera access denied: ${owner.id} does not own camera at ${position}`);
4742
4946
  return null;
4743
4947
  }
4744
- return new RectangularViewfinderAnimation(json.looping);
4948
+ return Camera.atPosition(position);
4745
4949
  }
4746
- get isLooping() {
4747
- return this._isLooping;
4950
+ /**
4951
+ * Safely execute camera operations (only works if you own the camera)
4952
+ */
4953
+ static withCamera(position, owner, operation) {
4954
+ return __awaiter(this, void 0, void 0, function* () {
4955
+ const camera = this.getCamera(position, owner);
4956
+ if (!camera) {
4957
+ return null;
4958
+ }
4959
+ try {
4960
+ const result = yield operation(camera);
4961
+ return result;
4962
+ }
4963
+ catch (error) {
4964
+ console.error(`Camera operation failed for ${owner.id}:`, error);
4965
+ throw error;
4966
+ }
4967
+ });
4968
+ }
4969
+ /**
4970
+ * Execute camera operations, waiting for ownership if necessary
4971
+ */
4972
+ static withCameraWhenAvailable(position, owner, operation, timeoutMs) {
4973
+ return __awaiter(this, void 0, void 0, function* () {
4974
+ // Try to get ownership, wait if necessary
4975
+ const acquired = yield this.requestOwnership(position, owner, timeoutMs);
4976
+ if (!acquired) {
4977
+ console.warn(`Could not acquire camera ownership for ${owner.id} within timeout`);
4978
+ return null;
4979
+ }
4980
+ const camera = Camera.atPosition(position);
4981
+ if (!camera) {
4982
+ console.warn(`Camera not available at position ${position}`);
4983
+ return null;
4984
+ }
4985
+ try {
4986
+ const result = yield operation(camera);
4987
+ return result;
4988
+ }
4989
+ catch (error) {
4990
+ console.error(`Camera operation failed for ${owner.id}:`, error);
4991
+ throw error;
4992
+ }
4993
+ });
4994
+ }
4995
+ /**
4996
+ * Request ownership and wait if necessary
4997
+ */
4998
+ static requestOwnership(position, owner, timeoutMs) {
4999
+ return __awaiter(this, void 0, void 0, function* () {
5000
+ return this.ownershipManager.requestOwnershipAsync(position, owner, timeoutMs);
5001
+ });
5002
+ }
5003
+ /**
5004
+ * Release ownership
5005
+ */
5006
+ static releaseOwnership(position, owner) {
5007
+ return this.ownershipManager.releaseOwnership(position, owner);
5008
+ }
5009
+ /**
5010
+ * Check if owner has ownership
5011
+ */
5012
+ static hasOwnership(position, owner) {
5013
+ return this.ownershipManager.checkOwnership(position, owner);
5014
+ }
5015
+ /**
5016
+ * Get the camera position currently owned by the owner (if unknown)
5017
+ */
5018
+ static getOwnedPosition(owner) {
5019
+ return this.ownershipManager.getOwnedPosition(owner);
5020
+ }
5021
+ /**
5022
+ * Get all camera positions currently owned by the owner
5023
+ */
5024
+ static getAllOwnedPositions(owner) {
5025
+ return this.ownershipManager.getAllOwnedPositions(owner);
4748
5026
  }
4749
- constructor(isLooping) {
4750
- super();
4751
- this._isLooping = false;
4752
- this._isLooping = isLooping;
5027
+ /**
5028
+ * Release ownership of all cameras owned by the owner
5029
+ */
5030
+ static releaseAllOwnerships(owner) {
5031
+ const ownedPositions = this.getAllOwnedPositions(owner);
5032
+ for (const position of ownedPositions) {
5033
+ this.releaseOwnership(position, owner);
5034
+ }
4753
5035
  }
4754
5036
  }
4755
- __decorate([
4756
- nameForSerialization('isLooping')
4757
- ], RectangularViewfinderAnimation.prototype, "_isLooping", void 0);
5037
+ CameraOwnershipHelper.ownershipManager = CameraOwnershipManager.getInstance();
5038
+
5039
+ const NoViewfinder = { type: 'none' };
4758
5040
 
4759
5041
  class RectangularViewfinder extends DefaultSerializeable {
4760
5042
  get sizeWithUnitAndAspect() {
@@ -4897,240 +5179,6 @@ class LaserlineViewfinder extends DefaultSerializeable {
4897
5179
  }
4898
5180
  }
4899
5181
 
4900
- // Capacitor returns nested values as already-parsed objects; other bridges (Cordova, RN) return JSON strings.
4901
- function parseOrUse(value) {
4902
- return typeof value === 'string' ? JSON.parse(value) : value;
4903
- }
4904
- function parseDefaults(jsonDefaults) {
4905
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4906
- const coreDefaults = {
4907
- Camera: {
4908
- Settings: {
4909
- preferredResolution: jsonDefaults.Camera.Settings.preferredResolution,
4910
- zoomFactor: jsonDefaults.Camera.Settings.zoomFactor,
4911
- focusRange: jsonDefaults.Camera.Settings.focusRange,
4912
- zoomGestureZoomFactor: jsonDefaults.Camera.Settings.zoomGestureZoomFactor,
4913
- zoomLevels: (_a = jsonDefaults.Camera.Settings.zoomLevels) !== null && _a !== void 0 ? _a : [1, 2],
4914
- focusGestureStrategy: jsonDefaults.Camera.Settings.focusGestureStrategy,
4915
- shouldPreferSmoothAutoFocus: jsonDefaults.Camera.Settings.shouldPreferSmoothAutoFocus,
4916
- torchLevel: (_b = jsonDefaults.Camera.Settings.torchLevel) !== null && _b !== void 0 ? _b : 1.0,
4917
- macroMode: ((_c = jsonDefaults.Camera.Settings.macroMode) !== null && _c !== void 0 ? _c : 'auto'),
4918
- adaptiveExposure: (_d = jsonDefaults.Camera.Settings.adaptiveExposure) !== null && _d !== void 0 ? _d : false,
4919
- manualLensPosition: (_e = jsonDefaults.Camera.Settings.manualLensPosition) !== null && _e !== void 0 ? _e : 0,
4920
- focusStrategy: (_f = jsonDefaults.Camera.Settings.focusStrategy) !== null && _f !== void 0 ? _f : 'auto',
4921
- properties: jsonDefaults.Camera.Settings.properties,
4922
- },
4923
- defaultPosition: (jsonDefaults.Camera.defaultPosition || null),
4924
- availablePositions: jsonDefaults.Camera.availablePositions,
4925
- },
4926
- ZoomSwitchControl: {
4927
- orientation: ((_h = (_g = jsonDefaults.ZoomSwitchControl) === null || _g === void 0 ? void 0 : _g.orientation) !== null && _h !== void 0 ? _h : 'horizontal'),
4928
- isAlwaysExpanded: (_k = (_j = jsonDefaults.ZoomSwitchControl) === null || _j === void 0 ? void 0 : _j.isAlwaysExpanded) !== null && _k !== void 0 ? _k : false,
4929
- isExpanded: (_m = (_l = jsonDefaults.ZoomSwitchControl) === null || _l === void 0 ? void 0 : _l.isExpanded) !== null && _m !== void 0 ? _m : false,
4930
- accessibilityLabel: (_p = (_o = jsonDefaults.ZoomSwitchControl) === null || _o === void 0 ? void 0 : _o.accessibilityLabel) !== null && _p !== void 0 ? _p : 'Zoom <level>',
4931
- accessibilityHint: (_r = (_q = jsonDefaults.ZoomSwitchControl) === null || _q === void 0 ? void 0 : _q.accessibilityHint) !== null && _r !== void 0 ? _r : 'Adjusts the camera zoom level',
4932
- },
4933
- DataCaptureView: {
4934
- scanAreaMargins: MarginsWithUnit['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.scanAreaMargins)),
4935
- pointOfInterest: PointWithUnit['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.pointOfInterest)),
4936
- logoAnchor: jsonDefaults.DataCaptureView.logoAnchor,
4937
- logoOffset: PointWithUnit['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.logoOffset)),
4938
- focusGesture: PrivateFocusGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.focusGesture)),
4939
- zoomGesture: PrivateZoomGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.zoomGesture)),
4940
- zoomGestures: jsonDefaults.DataCaptureView.zoomGestures
4941
- ? PrivateZoomGestureDeserializer['fromJSONArray'](parseOrUse(jsonDefaults.DataCaptureView.zoomGestures).map(parseOrUse))
4942
- : PrivateZoomGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.zoomGesture)) != null
4943
- ? [PrivateZoomGestureDeserializer['fromJSON'](parseOrUse(jsonDefaults.DataCaptureView.zoomGesture))]
4944
- : [],
4945
- logoStyle: jsonDefaults.DataCaptureView.logoStyle,
4946
- shouldShowZoomNotification: jsonDefaults.DataCaptureView.shouldShowZoomNotification,
4947
- },
4948
- RectangularViewfinder: Object.keys(jsonDefaults.RectangularViewfinder.styles).reduce((acc, key) => {
4949
- const viewfinder = jsonDefaults.RectangularViewfinder.styles[key];
4950
- acc.styles[key] = {
4951
- size: SizeWithUnitAndAspect['fromJSON'](parseOrUse(viewfinder.size)),
4952
- color: Color['fromJSON'](viewfinder.color),
4953
- disabledColor: Color['fromJSON'](viewfinder.disabledColor),
4954
- style: viewfinder.style,
4955
- lineStyle: viewfinder.lineStyle,
4956
- dimming: viewfinder.dimming,
4957
- disabledDimming: viewfinder.disabledDimming,
4958
- animation: RectangularViewfinderAnimation['fromJSON'](parseOrUse(viewfinder.animation)),
4959
- };
4960
- return acc;
4961
- }, { defaultStyle: jsonDefaults.RectangularViewfinder.defaultStyle, styles: {} }),
4962
- AimerViewfinder: {
4963
- frameColor: Color['fromJSON'](jsonDefaults.AimerViewfinder.frameColor),
4964
- dotColor: Color['fromJSON'](jsonDefaults.AimerViewfinder.dotColor),
4965
- },
4966
- Brush: new Brush(Color['fromJSON'](jsonDefaults.Brush.fillColor), Color['fromJSON'](jsonDefaults.Brush.strokeColor), jsonDefaults.Brush.strokeWidth),
4967
- LaserlineViewfinder: {
4968
- width: NumberWithUnit['fromJSON'](parseOrUse(jsonDefaults.LaserlineViewfinder.width)),
4969
- enabledColor: Color['fromJSON'](jsonDefaults.LaserlineViewfinder.enabledColor),
4970
- disabledColor: Color['fromJSON'](jsonDefaults.LaserlineViewfinder.disabledColor),
4971
- },
4972
- deviceID: jsonDefaults.deviceID,
4973
- };
4974
- // Inject defaults to avoid a circular dependency between these classes and the defaults
4975
- Brush['defaults'] = coreDefaults.Brush;
4976
- return coreDefaults;
4977
- }
4978
-
4979
- let coreDefaultsLoader;
4980
- function setCoreDefaultsLoader(loader) {
4981
- coreDefaultsLoader = loader;
4982
- }
4983
- function ensureCoreDefaults() {
4984
- var _a, _b;
4985
- const existing = (_a = FactoryMaker.instances.get('CoreDefaults')) === null || _a === void 0 ? void 0 : _a.instance;
4986
- if (existing) {
4987
- return existing;
4988
- }
4989
- coreDefaultsLoader === null || coreDefaultsLoader === void 0 ? void 0 : coreDefaultsLoader();
4990
- const reloaded = (_b = FactoryMaker.instances.get('CoreDefaults')) === null || _b === void 0 ? void 0 : _b.instance;
4991
- if (reloaded) {
4992
- return reloaded;
4993
- }
4994
- throw new Error('CoreDefaults missing and re-init failed');
4995
- }
4996
- function loadCoreDefaults(jsonDefaults) {
4997
- const coreDefaults = parseDefaults(jsonDefaults);
4998
- FactoryMaker.bindInstanceIfNotExists('CoreDefaults', coreDefaults);
4999
- }
5000
-
5001
- function getCoreDefaults() {
5002
- return ensureCoreDefaults();
5003
- }
5004
-
5005
- var VibrationType;
5006
- (function (VibrationType) {
5007
- VibrationType["default"] = "default";
5008
- VibrationType["selectionHaptic"] = "selectionHaptic";
5009
- VibrationType["successHaptic"] = "successHaptic";
5010
- VibrationType["waveForm"] = "waveForm";
5011
- VibrationType["impactHaptic"] = "impactHaptic";
5012
- })(VibrationType || (VibrationType = {}));
5013
-
5014
- class Vibration extends DefaultSerializeable {
5015
- static get defaultVibration() {
5016
- return new Vibration(VibrationType.default);
5017
- }
5018
- static get selectionHapticFeedback() {
5019
- return new Vibration(VibrationType.selectionHaptic);
5020
- }
5021
- static get successHapticFeedback() {
5022
- return new Vibration(VibrationType.successHaptic);
5023
- }
5024
- static get impactHapticFeedback() {
5025
- return new Vibration(VibrationType.impactHaptic);
5026
- }
5027
- static fromJSON(json) {
5028
- if (json.type === 'waveForm') {
5029
- return new WaveFormVibration(json.timings, json.amplitudes);
5030
- }
5031
- return new Vibration(json.type);
5032
- }
5033
- constructor(type) {
5034
- super();
5035
- this.type = type;
5036
- }
5037
- }
5038
- class WaveFormVibration extends Vibration {
5039
- get timings() {
5040
- return this._timings;
5041
- }
5042
- get amplitudes() {
5043
- return this._amplitudes;
5044
- }
5045
- constructor(timings, amplitudes = null) {
5046
- super(VibrationType.waveForm);
5047
- this._timings = timings;
5048
- this._amplitudes = amplitudes;
5049
- }
5050
- }
5051
- __decorate([
5052
- nameForSerialization('timings')
5053
- ], WaveFormVibration.prototype, "_timings", void 0);
5054
- __decorate([
5055
- ignoreFromSerializationIfNull,
5056
- nameForSerialization('amplitudes')
5057
- ], WaveFormVibration.prototype, "_amplitudes", void 0);
5058
-
5059
- class Sound extends DefaultSerializeable {
5060
- static get defaultSound() {
5061
- return new Sound(null);
5062
- }
5063
- static fromJSON(json) {
5064
- return new Sound(json.resource);
5065
- }
5066
- constructor(resource) {
5067
- super();
5068
- this.resource = null;
5069
- this.resource = resource;
5070
- }
5071
- }
5072
- __decorate([
5073
- ignoreFromSerializationIfNull
5074
- ], Sound.prototype, "resource", void 0);
5075
-
5076
- class FeedbackController extends BaseController {
5077
- static forFeedback(feedback) {
5078
- const controller = new FeedbackController(feedback);
5079
- return controller;
5080
- }
5081
- constructor(feedback) {
5082
- super('CoreProxy');
5083
- this.feedback = feedback;
5084
- this.adapter = new CoreProxyAdapter(this._proxy);
5085
- }
5086
- emit() {
5087
- void this.adapter.emitFeedback({ feedbackJson: JSON.stringify(this.feedback.toJSON()) });
5088
- }
5089
- dispose() {
5090
- this._proxy.dispose();
5091
- }
5092
- }
5093
-
5094
- class Feedback extends DefaultSerializeable {
5095
- static get defaultFeedback() {
5096
- return new Feedback(Vibration.defaultVibration, Sound.defaultSound);
5097
- }
5098
- get vibration() {
5099
- return this._vibration;
5100
- }
5101
- get sound() {
5102
- return this._sound;
5103
- }
5104
- static fromJSON(json) {
5105
- return new Feedback((json === null || json === void 0 ? void 0 : json.vibration) ? Vibration.fromJSON(json.vibration) : null, (json === null || json === void 0 ? void 0 : json.sound) ? Sound.fromJSON(json.sound) : null);
5106
- }
5107
- constructor(vibration, sound) {
5108
- super();
5109
- this._vibration = null;
5110
- this._sound = null;
5111
- this._vibration = vibration;
5112
- this._sound = sound;
5113
- this.controller = new FeedbackController(this);
5114
- }
5115
- emit() {
5116
- this.controller.emit();
5117
- }
5118
- toJSON() {
5119
- return super.toJSON();
5120
- }
5121
- }
5122
- __decorate([
5123
- ignoreFromSerializationIfNull,
5124
- nameForSerialization('vibration')
5125
- ], Feedback.prototype, "_vibration", void 0);
5126
- __decorate([
5127
- ignoreFromSerializationIfNull,
5128
- nameForSerialization('sound')
5129
- ], Feedback.prototype, "_sound", void 0);
5130
- __decorate([
5131
- ignoreFromSerialization
5132
- ], Feedback.prototype, "controller", void 0);
5133
-
5134
5182
  const NoneLocationSelection = { type: 'none' };
5135
5183
 
5136
5184
  class RadiusLocationSelection extends DefaultSerializeable {
@@ -5189,7 +5237,8 @@ class RectangularLocationSelection extends DefaultSerializeable {
5189
5237
  const height = NumberWithUnit['fromJSON'](rectangularLocationSelectionJSON.aspect.height);
5190
5238
  return this.withHeightAndAspectRatio(height, rectangularLocationSelectionJSON.aspect.aspect);
5191
5239
  }
5192
- else if (rectangularLocationSelectionJSON.aspect.shorterDimension && rectangularLocationSelectionJSON.aspect.aspect) {
5240
+ else if (rectangularLocationSelectionJSON.aspect.shorterDimension &&
5241
+ rectangularLocationSelectionJSON.aspect.aspect) {
5193
5242
  const shorterDimension = NumberWithUnit['fromJSON'](rectangularLocationSelectionJSON.aspect.shorterDimension);
5194
5243
  const sizeWithUnitAndAspect = SizeWithUnitAndAspect['sizeWithShorterDimensionAndAspectRatio'](shorterDimension, rectangularLocationSelectionJSON.aspect.aspect);
5195
5244
  const locationSelection = new RectangularLocationSelection();
@@ -5259,7 +5308,7 @@ const nativeProxyHook = {
5259
5308
  // Event registration methods with $$ prefix
5260
5309
  // These establish persistent event listeners (callbackContext.successAndKeepCallback())
5261
5310
  // and get special handling in Cordova to set up continuous event callbacks
5262
- if (prop.startsWith("$$")) {
5311
+ if (prop.startsWith('$$')) {
5263
5312
  return (args) => {
5264
5313
  const methodName = prop.substring(2);
5265
5314
  return nativeProxy._callEventRegistration(methodName, args);
@@ -5268,7 +5317,7 @@ const nativeProxyHook = {
5268
5317
  // All the methods with the following structure
5269
5318
  // $methodName will be redirected to the special _call
5270
5319
  // method on AdvancedNativeProxy
5271
- if (prop.startsWith("$")) {
5320
+ if (prop.startsWith('$')) {
5272
5321
  if (prop in nativeProxy) {
5273
5322
  return nativeProxy[prop];
5274
5323
  }
@@ -5279,7 +5328,7 @@ const nativeProxyHook = {
5279
5328
  else {
5280
5329
  return nativeProxy[prop];
5281
5330
  }
5282
- }
5331
+ },
5283
5332
  };
5284
5333
  class NativeProxy {
5285
5334
  constructor(nativeCaller) {
@@ -5367,11 +5416,7 @@ function registerProxies(proxyTypeNames, provider) {
5367
5416
  });
5368
5417
  }
5369
5418
 
5370
- const CORE_PROXY_TYPE_NAMES = [
5371
- 'CoreProxy',
5372
- 'DataCaptureViewProxy',
5373
- 'DataCaptureContextProxy'
5374
- ];
5419
+ const CORE_PROXY_TYPE_NAMES = ['CoreProxy', 'DataCaptureViewProxy', 'DataCaptureContextProxy'];
5375
5420
 
5376
5421
  function registerCoreProxies(provider) {
5377
5422
  registerProxies(CORE_PROXY_TYPE_NAMES, provider);
@@ -5393,5 +5438,5 @@ var ClusteringMode;
5393
5438
  ClusteringMode["AutoWithManualCorrection"] = "autoWithManualCorrection";
5394
5439
  })(ClusteringMode || (ClusteringMode = {}));
5395
5440
 
5396
- export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, ClusteringMode, Color, ContextStatus, ControlImage, CoreProxyAdapter, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureListenerEvents, FocusGestureStrategy, FocusRange, FontFamily, FrameDataController, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MacroMode, MacroModeListenerEvents, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, PinchToZoom, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, SKIP, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchListenerEvents, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomGestureListenerEvents, ZoomListenerEvents, ZoomSwitchControl, ZoomSwitchOrientation, createNativeProxy, ensureCoreDefaults, generateIdentifier, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, registerCoreProxies, registerProxies, serializationDefault, setCoreDefaultsLoader };
5441
+ export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, ClusteringMode, Color, ContextStatus, ControlImage, CoreProxyAdapter, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureListenerEvents, FocusGestureStrategy, FocusRange, FontFamily, FrameDataController, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MacroMode, MacroModeListenerEvents, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, PinchToZoom, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, SKIP, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, SelectionMode, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchListenerEvents, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomGestureListenerEvents, ZoomListenerEvents, ZoomSwitchControl, ZoomSwitchOrientation, createNativeProxy, ensureCoreDefaults, generateIdentifier, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, registerCoreProxies, registerProxies, serializationDefault, setCoreDefaultsLoader };
5397
5442
  //# sourceMappingURL=index.js.map