scandit-datacapture-frameworks-core 7.6.2 → 8.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/Defaults.ts +64 -0
- package/__mocks__/ScanditDataCaptureCore.ts +148 -0
- package/dist/dts/camera/Camera.d.ts +32 -5
- package/dist/dts/camera/CameraController.d.ts +2 -2
- package/dist/dts/camera/VideoResolution.d.ts +1 -0
- package/dist/dts/camerahelpers/CameraOwner.d.ts +3 -0
- package/dist/dts/camerahelpers/CameraOwnershipHelper.d.ts +42 -0
- package/dist/dts/camerahelpers/CameraOwnershipManager.d.ts +24 -0
- package/dist/dts/camerahelpers/index.d.ts +3 -0
- package/dist/dts/common/Payload.d.ts +2 -0
- package/dist/dts/context/DataCaptureContext.d.ts +6 -10
- package/dist/dts/frame/FrameSource.d.ts +1 -0
- package/dist/dts/view/DataCaptureView.d.ts +2 -2
- package/dist/dts/view/index.d.ts +1 -1
- package/dist/index.js +647 -222
- package/dist/index.js.map +1 -1
- package/jest.config.js +39 -0
- package/node_modules/eventemitter3/LICENSE +21 -0
- package/node_modules/eventemitter3/README.md +94 -0
- package/node_modules/eventemitter3/dist/eventemitter3.esm.js +347 -0
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +1 -0
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +1 -0
- package/node_modules/eventemitter3/dist/eventemitter3.umd.js +355 -0
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +1 -0
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +1 -0
- package/node_modules/eventemitter3/index.d.ts +135 -0
- package/node_modules/eventemitter3/index.js +336 -0
- package/node_modules/eventemitter3/index.mjs +4 -0
- package/node_modules/eventemitter3/package.json +67 -0
- package/package.json +4 -4
- package/test/Camera.test.ts +294 -0
- package/dist/dts/view/ScreenStateManager.d.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -1709,91 +1709,6 @@ var CameraPosition;
|
|
|
1709
1709
|
CameraPosition["Unspecified"] = "unspecified";
|
|
1710
1710
|
})(CameraPosition || (CameraPosition = {}));
|
|
1711
1711
|
|
|
1712
|
-
class CameraController extends BaseNewController {
|
|
1713
|
-
static get _proxy() {
|
|
1714
|
-
return FactoryMaker.getInstance('CameraProxy');
|
|
1715
|
-
}
|
|
1716
|
-
static forCamera(camera) {
|
|
1717
|
-
const controller = new CameraController();
|
|
1718
|
-
controller.camera = camera;
|
|
1719
|
-
return controller;
|
|
1720
|
-
}
|
|
1721
|
-
constructor() {
|
|
1722
|
-
super('CameraProxy');
|
|
1723
|
-
}
|
|
1724
|
-
get privateCamera() {
|
|
1725
|
-
return this.camera;
|
|
1726
|
-
}
|
|
1727
|
-
static getFrame(frameId) {
|
|
1728
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1729
|
-
const result = yield CameraController._proxy.$getFrame({ frameId });
|
|
1730
|
-
if (result == null) {
|
|
1731
|
-
return PrivateFrameData.empty();
|
|
1732
|
-
}
|
|
1733
|
-
const frameDataJSON = JSON.parse(result.data);
|
|
1734
|
-
return PrivateFrameData.fromJSON(frameDataJSON);
|
|
1735
|
-
});
|
|
1736
|
-
}
|
|
1737
|
-
static getFrameOrNull(frameId) {
|
|
1738
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1739
|
-
const result = yield CameraController._proxy.$getFrame({ frameId });
|
|
1740
|
-
if (result == null) {
|
|
1741
|
-
return null;
|
|
1742
|
-
}
|
|
1743
|
-
const frameDataJSON = JSON.parse(result.data);
|
|
1744
|
-
return PrivateFrameData.fromJSON(frameDataJSON);
|
|
1745
|
-
});
|
|
1746
|
-
}
|
|
1747
|
-
getCurrentState() {
|
|
1748
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1749
|
-
const result = yield this._proxy.$getCurrentCameraState({ position: this.privateCamera.position });
|
|
1750
|
-
if (result == null) {
|
|
1751
|
-
return FrameSourceState.Off;
|
|
1752
|
-
}
|
|
1753
|
-
return result.data;
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
getIsTorchAvailable() {
|
|
1757
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1758
|
-
const result = yield this._proxy.$isTorchAvailable({ position: this.privateCamera.position });
|
|
1759
|
-
if (result == null) {
|
|
1760
|
-
return false;
|
|
1761
|
-
}
|
|
1762
|
-
return result.data === 'true';
|
|
1763
|
-
});
|
|
1764
|
-
}
|
|
1765
|
-
switchCameraToDesiredState(desiredState) {
|
|
1766
|
-
return this._proxy.$switchCameraToDesiredState({ desiredStateJson: desiredState.toString() });
|
|
1767
|
-
}
|
|
1768
|
-
subscribeListener() {
|
|
1769
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1770
|
-
yield this._proxy.$registerListenerForCameraEvents();
|
|
1771
|
-
this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
|
|
1772
|
-
this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEvent.bind(this));
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
unsubscribeListener() {
|
|
1776
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1777
|
-
yield this._proxy.$unregisterListenerForCameraEvents();
|
|
1778
|
-
this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
|
|
1779
|
-
this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEvent.bind(this));
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
|
-
dispose() {
|
|
1783
|
-
this.unsubscribeListener();
|
|
1784
|
-
this._proxy.dispose();
|
|
1785
|
-
}
|
|
1786
|
-
handleDidChangeStateEvent(ev) {
|
|
1787
|
-
const event = EventDataParser.parse(ev.data);
|
|
1788
|
-
if (event) {
|
|
1789
|
-
this.privateCamera.listeners.forEach(listener => {
|
|
1790
|
-
var _a;
|
|
1791
|
-
(_a = listener === null || listener === void 0 ? void 0 : listener.didChangeState) === null || _a === void 0 ? void 0 : _a.call(listener, this.camera, event.state);
|
|
1792
|
-
});
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
1712
|
var TorchState;
|
|
1798
1713
|
(function (TorchState) {
|
|
1799
1714
|
TorchState["On"] = "on";
|
|
@@ -1801,98 +1716,192 @@ var TorchState;
|
|
|
1801
1716
|
TorchState["Auto"] = "auto";
|
|
1802
1717
|
})(TorchState || (TorchState = {}));
|
|
1803
1718
|
|
|
1719
|
+
/**
|
|
1720
|
+
* Camera lifecycle and operation handling:
|
|
1721
|
+
*
|
|
1722
|
+
* Phase 1 - Initial State (before native creation starts):
|
|
1723
|
+
* - Camera object exists in TypeScript but not yet being created on native side
|
|
1724
|
+
* - State changes (torch, desired state, settings) only update TypeScript properties
|
|
1725
|
+
* - No native calls are triggered
|
|
1726
|
+
*
|
|
1727
|
+
* Phase 2 - Native Creation In Progress (after setFrameSource, before context set):
|
|
1728
|
+
* - setFrameSource() called on DataCaptureContext, triggering setNativeFrameSourceIsBeingCreated()
|
|
1729
|
+
* - A promise is created that will resolve when the native camera is ready
|
|
1730
|
+
* - State changes during this phase await the native ready promise before executing
|
|
1731
|
+
* - Native camera is created asynchronously
|
|
1732
|
+
*
|
|
1733
|
+
* Phase 3 - Active State (after context set):
|
|
1734
|
+
* - Native camera is ready and available
|
|
1735
|
+
* - The native ready promise is resolved
|
|
1736
|
+
* - All state changes execute immediately on native side
|
|
1737
|
+
*/
|
|
1804
1738
|
class Camera extends DefaultSerializeable {
|
|
1805
1739
|
static get coreDefaults() {
|
|
1806
1740
|
return getCoreDefaults();
|
|
1807
1741
|
}
|
|
1808
1742
|
set context(newContext) {
|
|
1809
1743
|
this._context = newContext;
|
|
1744
|
+
if (newContext) {
|
|
1745
|
+
// Phase 3: Native camera is ready, resolve the promise so waiting operations can proceed
|
|
1746
|
+
if (this.nativeReadyTimeout) {
|
|
1747
|
+
clearTimeout(this.nativeReadyTimeout);
|
|
1748
|
+
this.nativeReadyTimeout = null;
|
|
1749
|
+
}
|
|
1750
|
+
if (this.nativeReadyResolver) {
|
|
1751
|
+
this.nativeReadyResolver();
|
|
1752
|
+
this.nativeReadyResolver = null;
|
|
1753
|
+
this.nativeReadyRejecter = null;
|
|
1754
|
+
this.nativeReadyPromise = null;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
else {
|
|
1758
|
+
// When context is removed, reset everything
|
|
1759
|
+
if (this.nativeReadyTimeout) {
|
|
1760
|
+
clearTimeout(this.nativeReadyTimeout);
|
|
1761
|
+
this.nativeReadyTimeout = null;
|
|
1762
|
+
}
|
|
1763
|
+
this.nativeReadyResolver = null;
|
|
1764
|
+
this.nativeReadyRejecter = null;
|
|
1765
|
+
this.nativeReadyPromise = null;
|
|
1766
|
+
}
|
|
1810
1767
|
}
|
|
1811
1768
|
get context() {
|
|
1812
1769
|
return this._context;
|
|
1813
1770
|
}
|
|
1771
|
+
setNativeFrameSourceIsBeingCreated() {
|
|
1772
|
+
this.nativeReadyPromise = new Promise((resolve, reject) => {
|
|
1773
|
+
this.nativeReadyResolver = resolve;
|
|
1774
|
+
this.nativeReadyRejecter = reject;
|
|
1775
|
+
this.nativeReadyTimeout = setTimeout(() => {
|
|
1776
|
+
this.nativeReadyTimeout = null;
|
|
1777
|
+
if (this.nativeReadyRejecter) {
|
|
1778
|
+
this.nativeReadyRejecter(new Error('Camera native initialization timed out after 5 seconds'));
|
|
1779
|
+
this.nativeReadyResolver = null;
|
|
1780
|
+
this.nativeReadyRejecter = null;
|
|
1781
|
+
this.nativeReadyPromise = null;
|
|
1782
|
+
}
|
|
1783
|
+
}, 5000);
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
get isActiveCamera() {
|
|
1787
|
+
return this._context !== null;
|
|
1788
|
+
}
|
|
1814
1789
|
static get default() {
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
camera.position = Camera.coreDefaults.Camera.defaultPosition;
|
|
1818
|
-
return camera;
|
|
1819
|
-
}
|
|
1820
|
-
else {
|
|
1790
|
+
const defaultPosition = Camera.coreDefaults.Camera.defaultPosition;
|
|
1791
|
+
if (!defaultPosition) {
|
|
1821
1792
|
return null;
|
|
1822
1793
|
}
|
|
1794
|
+
return Camera.atPosition(defaultPosition);
|
|
1823
1795
|
}
|
|
1824
1796
|
static withSettings(settings) {
|
|
1825
|
-
|
|
1826
|
-
if (camera) {
|
|
1827
|
-
camera.settings = settings;
|
|
1828
|
-
}
|
|
1829
|
-
return camera;
|
|
1797
|
+
return Camera.create(undefined, settings);
|
|
1830
1798
|
}
|
|
1831
1799
|
static asPositionWithSettings(cameraPosition, settings) {
|
|
1832
|
-
|
|
1833
|
-
const camera = new Camera();
|
|
1834
|
-
camera.settings = settings;
|
|
1835
|
-
camera.position = cameraPosition;
|
|
1836
|
-
return camera;
|
|
1837
|
-
}
|
|
1838
|
-
else {
|
|
1839
|
-
return null;
|
|
1840
|
-
}
|
|
1800
|
+
return Camera.create(cameraPosition, settings);
|
|
1841
1801
|
}
|
|
1842
1802
|
static atPosition(cameraPosition) {
|
|
1843
|
-
if (Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
|
|
1844
|
-
const camera = new Camera();
|
|
1845
|
-
camera.position = cameraPosition;
|
|
1846
|
-
return camera;
|
|
1847
|
-
}
|
|
1848
|
-
else {
|
|
1803
|
+
if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
|
|
1849
1804
|
return null;
|
|
1850
1805
|
}
|
|
1806
|
+
const existingCamera = Camera._cameraInstances.get(cameraPosition);
|
|
1807
|
+
if (existingCamera) {
|
|
1808
|
+
return existingCamera;
|
|
1809
|
+
}
|
|
1810
|
+
return Camera.create(cameraPosition);
|
|
1851
1811
|
}
|
|
1852
1812
|
get desiredState() {
|
|
1853
1813
|
return this._desiredState;
|
|
1854
1814
|
}
|
|
1855
1815
|
set desiredTorchState(desiredTorchState) {
|
|
1856
1816
|
this._desiredTorchState = desiredTorchState;
|
|
1857
|
-
this.
|
|
1817
|
+
if (this.nativeReadyPromise) {
|
|
1818
|
+
// Phase 2: Wait for native camera to be ready, then update
|
|
1819
|
+
this.nativeReadyPromise.then(() => this.didChange());
|
|
1820
|
+
}
|
|
1821
|
+
else if (this.isActiveCamera) {
|
|
1822
|
+
// Phase 3: Execute immediately
|
|
1823
|
+
this.didChange();
|
|
1824
|
+
}
|
|
1825
|
+
// Phase 1: Just update the property, no action needed
|
|
1858
1826
|
}
|
|
1859
1827
|
get desiredTorchState() {
|
|
1860
1828
|
return this._desiredTorchState;
|
|
1861
1829
|
}
|
|
1862
|
-
constructor() {
|
|
1830
|
+
constructor(position, settings, desiredTorchState, desiredState) {
|
|
1863
1831
|
super();
|
|
1864
1832
|
this.type = 'camera';
|
|
1865
1833
|
this.settings = null;
|
|
1866
1834
|
this._desiredTorchState = TorchState.Off;
|
|
1867
1835
|
this._desiredState = FrameSourceState.Off;
|
|
1836
|
+
this.currentCameraState = FrameSourceState.Off;
|
|
1868
1837
|
this.listeners = [];
|
|
1869
1838
|
this._context = null;
|
|
1870
|
-
this.
|
|
1839
|
+
this.nativeReadyResolver = null;
|
|
1840
|
+
this.nativeReadyRejecter = null;
|
|
1841
|
+
this.nativeReadyPromise = null;
|
|
1842
|
+
this.nativeReadyTimeout = null;
|
|
1843
|
+
this.position = position || Camera.coreDefaults.Camera.defaultPosition;
|
|
1844
|
+
this.settings = settings || null;
|
|
1845
|
+
this._desiredTorchState = desiredTorchState || TorchState.Off;
|
|
1846
|
+
this._desiredState = desiredState || FrameSourceState.Off;
|
|
1847
|
+
this.controller = new CameraController(this);
|
|
1848
|
+
}
|
|
1849
|
+
static create(position, settings, desiredTorchState, desiredState) {
|
|
1850
|
+
const cameraPosition = position || Camera.coreDefaults.Camera.defaultPosition;
|
|
1851
|
+
if (!cameraPosition) {
|
|
1852
|
+
return null;
|
|
1853
|
+
}
|
|
1854
|
+
const existingCamera = Camera._cameraInstances.get(cameraPosition);
|
|
1855
|
+
if (existingCamera) {
|
|
1856
|
+
existingCamera.resetPhaseState();
|
|
1857
|
+
if (settings !== undefined) {
|
|
1858
|
+
existingCamera.settings = settings;
|
|
1859
|
+
}
|
|
1860
|
+
if (desiredTorchState !== undefined) {
|
|
1861
|
+
existingCamera._desiredTorchState = desiredTorchState;
|
|
1862
|
+
existingCamera.didChange();
|
|
1863
|
+
}
|
|
1864
|
+
if (desiredState !== undefined) {
|
|
1865
|
+
existingCamera._desiredState = desiredState;
|
|
1866
|
+
existingCamera.controller.switchCameraToDesiredState(desiredState);
|
|
1867
|
+
}
|
|
1868
|
+
return existingCamera;
|
|
1869
|
+
}
|
|
1870
|
+
if (!Camera.coreDefaults.Camera.availablePositions.includes(cameraPosition)) {
|
|
1871
|
+
return null;
|
|
1872
|
+
}
|
|
1873
|
+
const camera = new Camera(cameraPosition, settings, desiredTorchState, desiredState);
|
|
1874
|
+
Camera._cameraInstances.set(cameraPosition, camera);
|
|
1875
|
+
return camera;
|
|
1871
1876
|
}
|
|
1872
1877
|
switchToDesiredState(state) {
|
|
1873
|
-
this
|
|
1874
|
-
|
|
1878
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1879
|
+
this._desiredState = state;
|
|
1880
|
+
if (this.nativeReadyPromise) {
|
|
1881
|
+
// Phase 2: Wait for native camera to be ready, then switch state
|
|
1882
|
+
yield this.nativeReadyPromise;
|
|
1883
|
+
yield this.controller.switchCameraToDesiredState(state);
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
if (!this.isActiveCamera) {
|
|
1887
|
+
// Phase 1: Not yet added to context
|
|
1888
|
+
console.warn('The current camera is not added to the DataCaptureContext. Add camera to the DataCaptureContext first.');
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
// Phase 3: Execute immediately
|
|
1892
|
+
yield this.controller.switchCameraToDesiredState(state);
|
|
1893
|
+
});
|
|
1875
1894
|
}
|
|
1876
1895
|
getCurrentState() {
|
|
1877
|
-
return this.
|
|
1896
|
+
return Promise.resolve(this.currentCameraState);
|
|
1878
1897
|
}
|
|
1879
1898
|
getIsTorchAvailable() {
|
|
1880
1899
|
return this.controller.getIsTorchAvailable();
|
|
1881
1900
|
}
|
|
1882
|
-
/**
|
|
1883
|
-
* @deprecated
|
|
1884
|
-
*/
|
|
1885
|
-
get isTorchAvailable() {
|
|
1886
|
-
console.warn('isTorchAvailable is deprecated. Use getIsTorchAvailable instead.');
|
|
1887
|
-
return false;
|
|
1888
|
-
}
|
|
1889
1901
|
addListener(listener) {
|
|
1890
1902
|
if (listener == null) {
|
|
1891
1903
|
return;
|
|
1892
1904
|
}
|
|
1893
|
-
if (this.listeners.length === 0) {
|
|
1894
|
-
this.controller.subscribeListener();
|
|
1895
|
-
}
|
|
1896
1905
|
if (this.listeners.includes(listener)) {
|
|
1897
1906
|
return;
|
|
1898
1907
|
}
|
|
@@ -1906,13 +1915,21 @@ class Camera extends DefaultSerializeable {
|
|
|
1906
1915
|
return;
|
|
1907
1916
|
}
|
|
1908
1917
|
this.listeners.splice(this.listeners.indexOf(listener), 1);
|
|
1909
|
-
if (this.listeners.length === 0) {
|
|
1910
|
-
this.controller.unsubscribeListener();
|
|
1911
|
-
}
|
|
1912
1918
|
}
|
|
1913
1919
|
applySettings(settings) {
|
|
1914
|
-
this
|
|
1915
|
-
|
|
1920
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1921
|
+
this.settings = settings;
|
|
1922
|
+
if (this.nativeReadyPromise) {
|
|
1923
|
+
// Phase 2: Wait for native camera to be ready, then apply settings
|
|
1924
|
+
yield this.nativeReadyPromise;
|
|
1925
|
+
yield this.didChange();
|
|
1926
|
+
}
|
|
1927
|
+
else if (this.isActiveCamera) {
|
|
1928
|
+
// Phase 3: Execute immediately
|
|
1929
|
+
yield this.didChange();
|
|
1930
|
+
}
|
|
1931
|
+
// Phase 1: Just update the property, no action needed
|
|
1932
|
+
});
|
|
1916
1933
|
}
|
|
1917
1934
|
didChange() {
|
|
1918
1935
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1921,7 +1938,17 @@ class Camera extends DefaultSerializeable {
|
|
|
1921
1938
|
}
|
|
1922
1939
|
});
|
|
1923
1940
|
}
|
|
1941
|
+
resetPhaseState() {
|
|
1942
|
+
if (this.nativeReadyTimeout) {
|
|
1943
|
+
clearTimeout(this.nativeReadyTimeout);
|
|
1944
|
+
this.nativeReadyTimeout = null;
|
|
1945
|
+
}
|
|
1946
|
+
this.nativeReadyResolver = null;
|
|
1947
|
+
this.nativeReadyRejecter = null;
|
|
1948
|
+
this.nativeReadyPromise = null;
|
|
1949
|
+
}
|
|
1924
1950
|
}
|
|
1951
|
+
Camera._cameraInstances = new Map();
|
|
1925
1952
|
__decorate([
|
|
1926
1953
|
serializationDefault({})
|
|
1927
1954
|
], Camera.prototype, "settings", void 0);
|
|
@@ -1929,21 +1956,416 @@ __decorate([
|
|
|
1929
1956
|
nameForSerialization('desiredTorchState')
|
|
1930
1957
|
], Camera.prototype, "_desiredTorchState", void 0);
|
|
1931
1958
|
__decorate([
|
|
1932
|
-
|
|
1959
|
+
nameForSerialization('desiredState')
|
|
1933
1960
|
], Camera.prototype, "_desiredState", void 0);
|
|
1961
|
+
__decorate([
|
|
1962
|
+
ignoreFromSerialization
|
|
1963
|
+
], Camera.prototype, "currentCameraState", void 0);
|
|
1934
1964
|
__decorate([
|
|
1935
1965
|
ignoreFromSerialization
|
|
1936
1966
|
], Camera.prototype, "listeners", void 0);
|
|
1937
1967
|
__decorate([
|
|
1938
1968
|
ignoreFromSerialization
|
|
1939
1969
|
], Camera.prototype, "_context", void 0);
|
|
1970
|
+
__decorate([
|
|
1971
|
+
ignoreFromSerialization
|
|
1972
|
+
], Camera.prototype, "nativeReadyResolver", void 0);
|
|
1973
|
+
__decorate([
|
|
1974
|
+
ignoreFromSerialization
|
|
1975
|
+
], Camera.prototype, "nativeReadyRejecter", void 0);
|
|
1976
|
+
__decorate([
|
|
1977
|
+
ignoreFromSerialization
|
|
1978
|
+
], Camera.prototype, "nativeReadyPromise", void 0);
|
|
1979
|
+
__decorate([
|
|
1980
|
+
ignoreFromSerialization
|
|
1981
|
+
], Camera.prototype, "nativeReadyTimeout", void 0);
|
|
1940
1982
|
__decorate([
|
|
1941
1983
|
ignoreFromSerialization
|
|
1942
1984
|
], Camera.prototype, "controller", void 0);
|
|
1985
|
+
__decorate([
|
|
1986
|
+
ignoreFromSerialization
|
|
1987
|
+
], Camera, "_cameraInstances", void 0);
|
|
1943
1988
|
__decorate([
|
|
1944
1989
|
ignoreFromSerialization
|
|
1945
1990
|
], Camera, "coreDefaults", null);
|
|
1946
1991
|
|
|
1992
|
+
class CameraOwnershipManager {
|
|
1993
|
+
constructor() {
|
|
1994
|
+
this.owners = new Map();
|
|
1995
|
+
this.waitingQueue = new Map();
|
|
1996
|
+
this.protectedCameras = new Set();
|
|
1997
|
+
}
|
|
1998
|
+
static getInstance() {
|
|
1999
|
+
if (!CameraOwnershipManager.instance) {
|
|
2000
|
+
CameraOwnershipManager.instance = new CameraOwnershipManager();
|
|
2001
|
+
}
|
|
2002
|
+
return CameraOwnershipManager.instance;
|
|
2003
|
+
}
|
|
2004
|
+
requestOwnership(position, owner) {
|
|
2005
|
+
const currentOwner = this.owners.get(position);
|
|
2006
|
+
if (currentOwner && currentOwner.id !== owner.id) {
|
|
2007
|
+
return false; // Already owned by someone else
|
|
2008
|
+
}
|
|
2009
|
+
this.owners.set(position, owner);
|
|
2010
|
+
this.enableProtectionForOwner(position, owner);
|
|
2011
|
+
return true;
|
|
2012
|
+
}
|
|
2013
|
+
requestOwnershipAsync(position, owner, timeoutMs) {
|
|
2014
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2015
|
+
// Try immediate acquisition first
|
|
2016
|
+
if (this.requestOwnership(position, owner)) {
|
|
2017
|
+
return true;
|
|
2018
|
+
}
|
|
2019
|
+
// If not available, wait in queue
|
|
2020
|
+
return new Promise((resolve) => {
|
|
2021
|
+
const request = { owner, resolve };
|
|
2022
|
+
if (!this.waitingQueue.has(position)) {
|
|
2023
|
+
this.waitingQueue.set(position, []);
|
|
2024
|
+
}
|
|
2025
|
+
this.waitingQueue.get(position).push(request);
|
|
2026
|
+
// Optional timeout
|
|
2027
|
+
if (timeoutMs && timeoutMs > 0) {
|
|
2028
|
+
setTimeout(() => {
|
|
2029
|
+
this.removeFromQueue(position, request);
|
|
2030
|
+
resolve(false); // Timeout - ownership not acquired
|
|
2031
|
+
}, timeoutMs);
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
releaseOwnership(position, owner) {
|
|
2037
|
+
const currentOwner = this.owners.get(position);
|
|
2038
|
+
if (!currentOwner || currentOwner.id !== owner.id) {
|
|
2039
|
+
return false; // Not the owner
|
|
2040
|
+
}
|
|
2041
|
+
this.owners.delete(position);
|
|
2042
|
+
this.disableProtectionForPosition(position);
|
|
2043
|
+
this.processWaitingQueue(position);
|
|
2044
|
+
return true;
|
|
2045
|
+
}
|
|
2046
|
+
isOwner(position, owner) {
|
|
2047
|
+
const currentOwner = this.owners.get(position);
|
|
2048
|
+
return (currentOwner === null || currentOwner === void 0 ? void 0 : currentOwner.id) === owner.id;
|
|
2049
|
+
}
|
|
2050
|
+
getCurrentOwner(position) {
|
|
2051
|
+
return this.owners.get(position) || null;
|
|
2052
|
+
}
|
|
2053
|
+
checkOwnership(position, owner) {
|
|
2054
|
+
return this.isOwner(position, owner);
|
|
2055
|
+
}
|
|
2056
|
+
getOwnedPosition(owner) {
|
|
2057
|
+
for (const [position, currentOwner] of this.owners.entries()) {
|
|
2058
|
+
if (currentOwner.id === owner.id) {
|
|
2059
|
+
return position;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
return null;
|
|
2063
|
+
}
|
|
2064
|
+
getAllOwnedPositions(owner) {
|
|
2065
|
+
const positions = [];
|
|
2066
|
+
for (const [position, currentOwner] of this.owners.entries()) {
|
|
2067
|
+
if (currentOwner.id === owner.id) {
|
|
2068
|
+
positions.push(position);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
return positions;
|
|
2072
|
+
}
|
|
2073
|
+
enableProtectionForOwner(position, owner) {
|
|
2074
|
+
const camera = Camera.atPosition(position);
|
|
2075
|
+
if (!camera || this.protectedCameras.has(camera)) {
|
|
2076
|
+
return; // Camera not available or already protected
|
|
2077
|
+
}
|
|
2078
|
+
this.protectCameraForOwner(camera, position, owner);
|
|
2079
|
+
this.protectedCameras.add(camera);
|
|
2080
|
+
}
|
|
2081
|
+
disableProtectionForPosition(position) {
|
|
2082
|
+
const camera = Camera.atPosition(position);
|
|
2083
|
+
if (!camera || !this.protectedCameras.has(camera)) {
|
|
2084
|
+
return;
|
|
2085
|
+
}
|
|
2086
|
+
this.unprotectCamera(camera);
|
|
2087
|
+
this.protectedCameras.delete(camera);
|
|
2088
|
+
}
|
|
2089
|
+
processWaitingQueue(position) {
|
|
2090
|
+
const queue = this.waitingQueue.get(position);
|
|
2091
|
+
if (!queue || queue.length === 0) {
|
|
2092
|
+
return;
|
|
2093
|
+
}
|
|
2094
|
+
// Give ownership to the first in queue
|
|
2095
|
+
const nextRequest = queue.shift();
|
|
2096
|
+
this.owners.set(position, nextRequest.owner);
|
|
2097
|
+
this.enableProtectionForOwner(position, nextRequest.owner);
|
|
2098
|
+
nextRequest.resolve(true);
|
|
2099
|
+
// Clean up empty queue
|
|
2100
|
+
if (queue.length === 0) {
|
|
2101
|
+
this.waitingQueue.delete(position);
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
removeFromQueue(position, requestToRemove) {
|
|
2105
|
+
const queue = this.waitingQueue.get(position);
|
|
2106
|
+
if (!queue)
|
|
2107
|
+
return;
|
|
2108
|
+
const index = queue.indexOf(requestToRemove);
|
|
2109
|
+
if (index > -1) {
|
|
2110
|
+
queue.splice(index, 1);
|
|
2111
|
+
}
|
|
2112
|
+
if (queue.length === 0) {
|
|
2113
|
+
this.waitingQueue.delete(position);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
protectCameraForOwner(camera, position, _owner) {
|
|
2117
|
+
var _a, _b, _c;
|
|
2118
|
+
const originalSwitchToDesiredState = camera.switchToDesiredState.bind(camera);
|
|
2119
|
+
const originalApplySettings = camera.applySettings.bind(camera);
|
|
2120
|
+
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);
|
|
2121
|
+
// Protect switchToDesiredState - only owner can call it
|
|
2122
|
+
camera.switchToDesiredState = (state) => __awaiter(this, void 0, void 0, function* () {
|
|
2123
|
+
const currentOwner = this.getCurrentOwner(position);
|
|
2124
|
+
if (!currentOwner) {
|
|
2125
|
+
throw new Error(`Camera operation denied: No owner for camera at ${position}`);
|
|
2126
|
+
}
|
|
2127
|
+
// Allow operation - the owner is the only one who should have access to this camera instance
|
|
2128
|
+
return originalSwitchToDesiredState(state);
|
|
2129
|
+
});
|
|
2130
|
+
// Protect applySettings - only owner can call it
|
|
2131
|
+
camera.applySettings = (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
2132
|
+
const currentOwner = this.getCurrentOwner(position);
|
|
2133
|
+
if (!currentOwner) {
|
|
2134
|
+
throw new Error(`Camera operation denied: No owner for camera at ${position}`);
|
|
2135
|
+
}
|
|
2136
|
+
return originalApplySettings(settings);
|
|
2137
|
+
});
|
|
2138
|
+
// Protect desiredTorchState setter - only owner can set it
|
|
2139
|
+
if (originalSetDesiredTorchState) {
|
|
2140
|
+
Object.defineProperty(camera, 'desiredTorchState', {
|
|
2141
|
+
set: (value) => {
|
|
2142
|
+
const currentOwner = this.getCurrentOwner(position);
|
|
2143
|
+
if (!currentOwner) {
|
|
2144
|
+
throw new Error(`Camera operation denied: No owner for camera at ${position}`);
|
|
2145
|
+
}
|
|
2146
|
+
originalSetDesiredTorchState(value);
|
|
2147
|
+
},
|
|
2148
|
+
get: (_c = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(camera), 'desiredTorchState')) === null || _c === void 0 ? void 0 : _c.get,
|
|
2149
|
+
configurable: true
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
// Store originals for restoration
|
|
2153
|
+
camera.__originalMethods = {
|
|
2154
|
+
switchToDesiredState: originalSwitchToDesiredState,
|
|
2155
|
+
applySettings: originalApplySettings,
|
|
2156
|
+
setDesiredTorchState: originalSetDesiredTorchState
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2159
|
+
unprotectCamera(camera) {
|
|
2160
|
+
var _a;
|
|
2161
|
+
const originals = camera.__originalMethods;
|
|
2162
|
+
if (!originals)
|
|
2163
|
+
return;
|
|
2164
|
+
// Restore original methods
|
|
2165
|
+
camera.switchToDesiredState = originals.switchToDesiredState;
|
|
2166
|
+
camera.applySettings = originals.applySettings;
|
|
2167
|
+
if (originals.setDesiredTorchState) {
|
|
2168
|
+
Object.defineProperty(camera, 'desiredTorchState', {
|
|
2169
|
+
set: originals.setDesiredTorchState,
|
|
2170
|
+
get: (_a = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(camera), 'desiredTorchState')) === null || _a === void 0 ? void 0 : _a.get,
|
|
2171
|
+
configurable: true
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
delete camera.__originalMethods;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
class CameraOwnershipHelper {
|
|
2179
|
+
/**
|
|
2180
|
+
* Get camera instance for the owner (only works if you own it)
|
|
2181
|
+
*/
|
|
2182
|
+
static getCamera(position, owner) {
|
|
2183
|
+
// Check ownership
|
|
2184
|
+
if (!this.ownershipManager.checkOwnership(position, owner)) {
|
|
2185
|
+
console.warn(`Camera access denied: ${owner.id} does not own camera at ${position}`);
|
|
2186
|
+
return null;
|
|
2187
|
+
}
|
|
2188
|
+
return Camera.atPosition(position);
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Safely execute camera operations (only works if you own the camera)
|
|
2192
|
+
*/
|
|
2193
|
+
static withCamera(position, owner, operation) {
|
|
2194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2195
|
+
const camera = this.getCamera(position, owner);
|
|
2196
|
+
if (!camera) {
|
|
2197
|
+
return null;
|
|
2198
|
+
}
|
|
2199
|
+
try {
|
|
2200
|
+
const result = yield operation(camera);
|
|
2201
|
+
return result;
|
|
2202
|
+
}
|
|
2203
|
+
catch (error) {
|
|
2204
|
+
console.error(`Camera operation failed for ${owner.id}:`, error);
|
|
2205
|
+
throw error;
|
|
2206
|
+
}
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Execute camera operations, waiting for ownership if necessary
|
|
2211
|
+
*/
|
|
2212
|
+
static withCameraWhenAvailable(position, owner, operation, timeoutMs) {
|
|
2213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2214
|
+
// Try to get ownership, wait if necessary
|
|
2215
|
+
const acquired = yield this.requestOwnership(position, owner, timeoutMs);
|
|
2216
|
+
if (!acquired) {
|
|
2217
|
+
console.warn(`Could not acquire camera ownership for ${owner.id} within timeout`);
|
|
2218
|
+
return null;
|
|
2219
|
+
}
|
|
2220
|
+
const camera = Camera.atPosition(position);
|
|
2221
|
+
if (!camera) {
|
|
2222
|
+
console.warn(`Camera not available at position ${position}`);
|
|
2223
|
+
return null;
|
|
2224
|
+
}
|
|
2225
|
+
try {
|
|
2226
|
+
const result = yield operation(camera);
|
|
2227
|
+
return result;
|
|
2228
|
+
}
|
|
2229
|
+
catch (error) {
|
|
2230
|
+
console.error(`Camera operation failed for ${owner.id}:`, error);
|
|
2231
|
+
throw error;
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Request ownership and wait if necessary
|
|
2237
|
+
*/
|
|
2238
|
+
static requestOwnership(position, owner, timeoutMs) {
|
|
2239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2240
|
+
return this.ownershipManager.requestOwnershipAsync(position, owner, timeoutMs);
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* Release ownership
|
|
2245
|
+
*/
|
|
2246
|
+
static releaseOwnership(position, owner) {
|
|
2247
|
+
return this.ownershipManager.releaseOwnership(position, owner);
|
|
2248
|
+
}
|
|
2249
|
+
/**
|
|
2250
|
+
* Check if owner has ownership
|
|
2251
|
+
*/
|
|
2252
|
+
static hasOwnership(position, owner) {
|
|
2253
|
+
return this.ownershipManager.checkOwnership(position, owner);
|
|
2254
|
+
}
|
|
2255
|
+
/**
|
|
2256
|
+
* Get the camera position currently owned by the owner (if any)
|
|
2257
|
+
*/
|
|
2258
|
+
static getOwnedPosition(owner) {
|
|
2259
|
+
return this.ownershipManager.getOwnedPosition(owner);
|
|
2260
|
+
}
|
|
2261
|
+
/**
|
|
2262
|
+
* Get all camera positions currently owned by the owner
|
|
2263
|
+
*/
|
|
2264
|
+
static getAllOwnedPositions(owner) {
|
|
2265
|
+
return this.ownershipManager.getAllOwnedPositions(owner);
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Release ownership of all cameras owned by the owner
|
|
2269
|
+
*/
|
|
2270
|
+
static releaseAllOwnerships(owner) {
|
|
2271
|
+
const ownedPositions = this.getAllOwnedPositions(owner);
|
|
2272
|
+
for (const position of ownedPositions) {
|
|
2273
|
+
this.releaseOwnership(position, owner);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
CameraOwnershipHelper.ownershipManager = CameraOwnershipManager.getInstance();
|
|
2278
|
+
|
|
2279
|
+
class CameraController extends BaseNewController {
|
|
2280
|
+
static get _proxy() {
|
|
2281
|
+
return FactoryMaker.getInstance('CameraProxy');
|
|
2282
|
+
}
|
|
2283
|
+
constructor(camera) {
|
|
2284
|
+
super('CameraProxy');
|
|
2285
|
+
// Arrow function wrapper to avoid .bind(this) and always use current class state
|
|
2286
|
+
this.handleDidChangeStateEventWrapper = (ev) => {
|
|
2287
|
+
return this.handleDidChangeStateEvent(ev);
|
|
2288
|
+
};
|
|
2289
|
+
this.camera = camera;
|
|
2290
|
+
this.subscribeListener();
|
|
2291
|
+
}
|
|
2292
|
+
get privateCamera() {
|
|
2293
|
+
return this.camera;
|
|
2294
|
+
}
|
|
2295
|
+
static getFrame(frameId) {
|
|
2296
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2297
|
+
const result = yield CameraController._proxy.$getFrame({ frameId });
|
|
2298
|
+
if (result == null) {
|
|
2299
|
+
return PrivateFrameData.empty();
|
|
2300
|
+
}
|
|
2301
|
+
const frameDataJSON = JSON.parse(result.data);
|
|
2302
|
+
return PrivateFrameData.fromJSON(frameDataJSON);
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
static getFrameOrNull(frameId) {
|
|
2306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2307
|
+
const result = yield CameraController._proxy.$getFrame({ frameId });
|
|
2308
|
+
if (result == null) {
|
|
2309
|
+
return null;
|
|
2310
|
+
}
|
|
2311
|
+
const frameDataJSON = JSON.parse(result.data);
|
|
2312
|
+
return PrivateFrameData.fromJSON(frameDataJSON);
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
getCurrentState() {
|
|
2316
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2317
|
+
const result = yield this._proxy.$getCurrentCameraState({ position: this.privateCamera.position });
|
|
2318
|
+
if (result == null) {
|
|
2319
|
+
return FrameSourceState.Off;
|
|
2320
|
+
}
|
|
2321
|
+
return result.data;
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
getIsTorchAvailable() {
|
|
2325
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2326
|
+
const result = yield this._proxy.$isTorchAvailable({ position: this.privateCamera.position });
|
|
2327
|
+
if (result == null) {
|
|
2328
|
+
return false;
|
|
2329
|
+
}
|
|
2330
|
+
return result.data === 'true';
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
switchCameraToDesiredState(desiredState) {
|
|
2334
|
+
return this._proxy.$switchCameraToDesiredState({ desiredStateJson: desiredState.toString() });
|
|
2335
|
+
}
|
|
2336
|
+
subscribeListener() {
|
|
2337
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2338
|
+
yield this._proxy.$registerListenerForCameraEvents();
|
|
2339
|
+
this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
|
|
2340
|
+
this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
unsubscribeListener() {
|
|
2344
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2345
|
+
yield this._proxy.$unregisterListenerForCameraEvents();
|
|
2346
|
+
this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
|
|
2347
|
+
this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
|
|
2348
|
+
});
|
|
2349
|
+
}
|
|
2350
|
+
dispose() {
|
|
2351
|
+
this.unsubscribeListener();
|
|
2352
|
+
this._proxy.dispose();
|
|
2353
|
+
}
|
|
2354
|
+
handleDidChangeStateEvent(ev) {
|
|
2355
|
+
const event = EventDataParser.parse(ev.data);
|
|
2356
|
+
if (event) {
|
|
2357
|
+
if (event.cameraPosition !== this.privateCamera.position || !this.privateCamera.isActiveCamera) {
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
this.privateCamera.currentCameraState = event.state;
|
|
2361
|
+
this.privateCamera.listeners.forEach(listener => {
|
|
2362
|
+
var _a;
|
|
2363
|
+
(_a = listener === null || listener === void 0 ? void 0 : listener.didChangeState) === null || _a === void 0 ? void 0 : _a.call(listener, this.camera, this.privateCamera._desiredState);
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
|
|
1947
2369
|
class ControlImage extends DefaultSerializeable {
|
|
1948
2370
|
constructor(type, data, name) {
|
|
1949
2371
|
super();
|
|
@@ -2167,13 +2589,6 @@ class DataCaptureContext extends DefaultSerializeable {
|
|
|
2167
2589
|
static get deviceID() {
|
|
2168
2590
|
return DataCaptureContext.coreDefaults.deviceID;
|
|
2169
2591
|
}
|
|
2170
|
-
/**
|
|
2171
|
-
* @deprecated
|
|
2172
|
-
*/
|
|
2173
|
-
get deviceID() {
|
|
2174
|
-
console.log('The instance property "deviceID" on the DataCaptureContext is deprecated, please use the static property DataCaptureContext.deviceID instead.');
|
|
2175
|
-
return DataCaptureContext.deviceID;
|
|
2176
|
-
}
|
|
2177
2592
|
static forLicenseKey(licenseKey) {
|
|
2178
2593
|
const instance = DataCaptureContext.create(licenseKey, null, null);
|
|
2179
2594
|
// Call initialize to ensure the shared instance is updated.
|
|
@@ -2226,14 +2641,21 @@ class DataCaptureContext extends DefaultSerializeable {
|
|
|
2226
2641
|
}
|
|
2227
2642
|
}
|
|
2228
2643
|
setFrameSource(frameSource) {
|
|
2229
|
-
|
|
2230
|
-
this._frameSource
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
frameSource
|
|
2235
|
-
|
|
2236
|
-
|
|
2644
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2645
|
+
if (this._frameSource) {
|
|
2646
|
+
this._frameSource.context = null;
|
|
2647
|
+
}
|
|
2648
|
+
this._frameSource = frameSource;
|
|
2649
|
+
if (frameSource) {
|
|
2650
|
+
// Set the flag to indicate that the native frame source is being created
|
|
2651
|
+
frameSource.setNativeFrameSourceIsBeingCreated();
|
|
2652
|
+
}
|
|
2653
|
+
yield this.update();
|
|
2654
|
+
// Make camera active once the set on native side is complete
|
|
2655
|
+
if (frameSource) {
|
|
2656
|
+
frameSource.context = this;
|
|
2657
|
+
}
|
|
2658
|
+
});
|
|
2237
2659
|
}
|
|
2238
2660
|
addListener(listener) {
|
|
2239
2661
|
if (this.listeners.length === 0) {
|
|
@@ -2254,62 +2676,79 @@ class DataCaptureContext extends DefaultSerializeable {
|
|
|
2254
2676
|
}
|
|
2255
2677
|
}
|
|
2256
2678
|
addMode(mode) {
|
|
2257
|
-
this
|
|
2679
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2680
|
+
yield this.addModeInternal(mode);
|
|
2681
|
+
});
|
|
2258
2682
|
}
|
|
2259
2683
|
setMode(mode) {
|
|
2260
|
-
this
|
|
2261
|
-
|
|
2684
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2685
|
+
yield this.removeAllModes();
|
|
2686
|
+
yield this.addModeInternal(mode);
|
|
2687
|
+
});
|
|
2262
2688
|
}
|
|
2263
2689
|
addModeInternal(mode) {
|
|
2264
|
-
|
|
2265
|
-
this.modes.
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2690
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2691
|
+
if (!this.modes.includes(mode)) {
|
|
2692
|
+
this.modes.push(mode);
|
|
2693
|
+
yield this.controller.addModeToContext(mode);
|
|
2694
|
+
mode._context = this;
|
|
2695
|
+
}
|
|
2696
|
+
});
|
|
2269
2697
|
}
|
|
2270
2698
|
removeCurrentMode() {
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2699
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2700
|
+
if (this.modes.length === 0) {
|
|
2701
|
+
return;
|
|
2702
|
+
}
|
|
2703
|
+
if (this.modes.length > 1) {
|
|
2704
|
+
console.warn('removeCurrentMode() called with multiple modes active. Consider using removeMode() for specific mode removal. Only the first mode will be removed.');
|
|
2705
|
+
}
|
|
2706
|
+
yield this.removeModeInternal(this.modes[0]);
|
|
2707
|
+
});
|
|
2278
2708
|
}
|
|
2279
2709
|
removeMode(mode) {
|
|
2280
|
-
this
|
|
2710
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2711
|
+
yield this.removeModeInternal(mode);
|
|
2712
|
+
});
|
|
2281
2713
|
}
|
|
2282
2714
|
removeModeInternal(mode) {
|
|
2283
2715
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
this.controller.removeModeFromContext(mode);
|
|
2716
|
+
const index = this.modes.indexOf(mode);
|
|
2717
|
+
if (index !== -1) {
|
|
2718
|
+
this.modes.splice(index, 1);
|
|
2288
2719
|
}
|
|
2720
|
+
mode._context = null;
|
|
2721
|
+
yield this.controller.removeModeFromContext(mode);
|
|
2289
2722
|
});
|
|
2290
2723
|
}
|
|
2291
2724
|
removeAllModes() {
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
mode
|
|
2725
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2726
|
+
if (this.modes.length === 0) {
|
|
2727
|
+
return;
|
|
2728
|
+
}
|
|
2729
|
+
this.modes.forEach(mode => {
|
|
2730
|
+
mode._context = null;
|
|
2731
|
+
});
|
|
2732
|
+
this.modes = [];
|
|
2733
|
+
yield this.controller.removeAllModesFromContext();
|
|
2297
2734
|
});
|
|
2298
|
-
this.modes = [];
|
|
2299
|
-
this.controller.removeAllModesFromContext();
|
|
2300
2735
|
}
|
|
2301
2736
|
dispose() {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2737
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2738
|
+
var _a;
|
|
2739
|
+
if (!this.controller) {
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
(_a = this.view) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
2743
|
+
yield this.removeAllModes();
|
|
2744
|
+
this.controller.dispose();
|
|
2745
|
+
});
|
|
2309
2746
|
}
|
|
2310
2747
|
applySettings(settings) {
|
|
2311
|
-
this
|
|
2312
|
-
|
|
2748
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2749
|
+
this.settings = settings;
|
|
2750
|
+
yield this.update();
|
|
2751
|
+
});
|
|
2313
2752
|
}
|
|
2314
2753
|
static getOpenSourceSoftwareLicenseInfo() {
|
|
2315
2754
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2317,10 +2756,12 @@ class DataCaptureContext extends DefaultSerializeable {
|
|
|
2317
2756
|
});
|
|
2318
2757
|
}
|
|
2319
2758
|
update() {
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2759
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2760
|
+
if (!this.controller) {
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
yield this.controller.updateContextFromJSON();
|
|
2764
|
+
});
|
|
2324
2765
|
}
|
|
2325
2766
|
}
|
|
2326
2767
|
__decorate([
|
|
@@ -2537,20 +2978,24 @@ class BaseDataCaptureView extends DefaultSerializeable {
|
|
|
2537
2978
|
this.controller = new DataCaptureViewController(this);
|
|
2538
2979
|
}
|
|
2539
2980
|
addOverlay(overlay) {
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2981
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2982
|
+
if (this.overlays.includes(overlay)) {
|
|
2983
|
+
return;
|
|
2984
|
+
}
|
|
2985
|
+
overlay.view = this;
|
|
2986
|
+
this.overlays.push(overlay);
|
|
2987
|
+
yield this.controller.updateView();
|
|
2988
|
+
});
|
|
2546
2989
|
}
|
|
2547
2990
|
removeOverlay(overlay) {
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2991
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2992
|
+
if (!this.overlays.includes(overlay)) {
|
|
2993
|
+
return;
|
|
2994
|
+
}
|
|
2995
|
+
overlay.view = null;
|
|
2996
|
+
this.overlays.splice(this.overlays.indexOf(overlay), 1);
|
|
2997
|
+
yield this.controller.updateView();
|
|
2998
|
+
});
|
|
2554
2999
|
}
|
|
2555
3000
|
removeAllOverlays() {
|
|
2556
3001
|
if (this.overlays.length === 0) {
|
|
@@ -2698,27 +3143,6 @@ __decorate([
|
|
|
2698
3143
|
ignoreFromSerialization
|
|
2699
3144
|
], BaseDataCaptureView.prototype, "isViewCreated", void 0);
|
|
2700
3145
|
|
|
2701
|
-
class ScreenStateManager {
|
|
2702
|
-
constructor() {
|
|
2703
|
-
this.activeScreenId = null;
|
|
2704
|
-
}
|
|
2705
|
-
static getInstance() {
|
|
2706
|
-
if (!ScreenStateManager.instance) {
|
|
2707
|
-
ScreenStateManager.instance = new ScreenStateManager();
|
|
2708
|
-
}
|
|
2709
|
-
return ScreenStateManager.instance;
|
|
2710
|
-
}
|
|
2711
|
-
setActiveScreen(screenId) {
|
|
2712
|
-
if (this.activeScreenId === screenId) {
|
|
2713
|
-
return;
|
|
2714
|
-
}
|
|
2715
|
-
this.activeScreenId = screenId;
|
|
2716
|
-
}
|
|
2717
|
-
isScreenActive(screenId) {
|
|
2718
|
-
return (this.activeScreenId === null || this.activeScreenId === screenId);
|
|
2719
|
-
}
|
|
2720
|
-
}
|
|
2721
|
-
|
|
2722
3146
|
class ZoomSwitchControl extends DefaultSerializeable {
|
|
2723
3147
|
constructor() {
|
|
2724
3148
|
super(...arguments);
|
|
@@ -2899,6 +3323,7 @@ __decorate([
|
|
|
2899
3323
|
|
|
2900
3324
|
var VideoResolution;
|
|
2901
3325
|
(function (VideoResolution) {
|
|
3326
|
+
/** @deprecated Auto is deprecated. Please use the capture mode's recommendedCameraSettings for the best results. */
|
|
2902
3327
|
VideoResolution["Auto"] = "auto";
|
|
2903
3328
|
VideoResolution["HD"] = "hd";
|
|
2904
3329
|
VideoResolution["FullHD"] = "fullHd";
|
|
@@ -3715,5 +4140,5 @@ function createNativeProxy(nativeCaller) {
|
|
|
3715
4140
|
|
|
3716
4141
|
createEventEmitter();
|
|
3717
4142
|
|
|
3718
|
-
export { AdvancedInstanceAwareNativeProxy, AdvancedNativeProxy, AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseInstanceAwareNativeProxy, BaseNativeProxy, BaseNewController, Brush, Camera, CameraController, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FontFamily, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType,
|
|
4143
|
+
export { AdvancedInstanceAwareNativeProxy, AdvancedNativeProxy, AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, BaseInstanceAwareNativeProxy, BaseNativeProxy, BaseNewController, Brush, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, Color, ContextStatus, ControlImage, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureStrategy, FocusRange, FontFamily, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LogoStyle, MarginsWithUnit, MeasureUnit, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, WaveFormVibration, ZoomSwitchControl, createAdvancedInstanceAwareNativeProxy, createAdvancedNativeFromCtorProxy, createAdvancedNativeProxy, createNativeProxy, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, loadCoreDefaults, nameForSerialization, serializationDefault };
|
|
3719
4144
|
//# sourceMappingURL=index.js.map
|