scandit-react-native-datacapture-core 8.5.3 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/ui/ScanditViewGroupManager.kt +15 -0
  3. package/android/src/main/kotlin/com/scandit/datacapture/reactnative/core/utils/ViewWindowEvents.kt +32 -0
  4. package/android/src/main/newArch/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCoreModule.kt +4 -0
  5. package/android/src/main/oldArch/kotlin/com/scandit/datacapture/reactnative/core/ScanditDataCaptureCoreModule.kt +4 -0
  6. package/dist/core.js +471 -1
  7. package/dist/core.js.flow +2337 -0
  8. package/dist/core.js.map +1 -1
  9. package/dist/dts/core.d.ts +2151 -0
  10. package/dist/dts/experimental.d.ts +1 -9
  11. package/dist/dts/index.d.ts +672 -96
  12. package/dist/experimental.js.flow +3 -3
  13. package/dist/index.js +583 -143
  14. package/dist/index.js.flow +948 -96
  15. package/dist/index.js.map +1 -1
  16. package/ios/Sources/ScanditDataCaptureCore.swift +10 -1
  17. package/ios/Sources/Shared/DataCaptureViewWrapper.swift +7 -0
  18. package/package.json +9 -8
  19. package/scandit-react-native-datacapture-core.podspec +1 -1
  20. package/dist/dts/DataCaptureVersion.d.ts +0 -4
  21. package/dist/dts/DataCaptureView.d.ts +0 -61
  22. package/dist/dts/hooks/ScanditProvider.d.ts +0 -46
  23. package/dist/dts/hooks/index.d.ts +0 -5
  24. package/dist/dts/hooks/useCameraPermission.d.ts +0 -28
  25. package/dist/dts/hooks/useIsForeground.d.ts +0 -11
  26. package/dist/dts/hooks/useScanditContext.d.ts +0 -21
  27. package/dist/dts/native/CoreNativeCallerProvider.d.ts +0 -4
  28. package/dist/dts/native/RNNativeCaller.d.ts +0 -23
  29. package/dist/dts/native/ScanditNativeModule.d.ts +0 -6
  30. package/dist/dts/native/initProxy.d.ts +0 -1
  31. package/dist/dts/private/Defaults.d.ts +0 -1
  32. package/dist/dts/private/hooks/useMode.d.ts +0 -49
  33. package/dist/dts/private/hooks/useModeListener.d.ts +0 -40
  34. package/dist/dts/private/hooks/useNativeControl.d.ts +0 -14
  35. package/dist/dts/private/hooks/useOverlay.d.ts +0 -68
  36. package/dist/dts/private/hooks/useStableProp.d.ts +0 -22
  37. package/dist/dts/private/hooks/useViewHandle.d.ts +0 -41
  38. package/dist/dts/private/index.d.ts +0 -11
  39. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -99,7 +99,7 @@ if (file( "${rootProject.projectDir}/build-test.gradle").exists()) {
99
99
  }
100
100
 
101
101
  dependencies {
102
- def sdk_version = "8.5.3"
102
+ def sdk_version = "8.6.0"
103
103
 
104
104
  println("Version of the native sdk used in this build: ${safeExtGet('frameworks_sdk_version', sdk_version)}")
105
105
  if (findProject(':scandit-datacapture-frameworks-core') != null) {
@@ -11,6 +11,7 @@ import android.view.View
11
11
  import android.view.ViewGroup
12
12
  import com.facebook.react.uimanager.ThemedReactContext
13
13
  import com.facebook.react.uimanager.ViewGroupManager
14
+ import com.scandit.datacapture.reactnative.core.utils.ViewWindowEvents
14
15
 
15
16
  abstract class ScanditViewGroupManager<T> :
16
17
  ViewGroupManager<T>() where T : ViewGroup {
@@ -31,6 +32,20 @@ abstract class ScanditViewGroupManager<T> :
31
32
  containers.add(it)
32
33
  }
33
34
 
35
+ // Drives the JS single-owner camera model (SDC-32484): attach -> the
36
+ // hosting wrapper claims camera ownership, detach -> it releases.
37
+ container.addOnAttachStateChangeListener(
38
+ object : android.view.View.OnAttachStateChangeListener {
39
+ override fun onViewAttachedToWindow(v: android.view.View) {
40
+ ViewWindowEvents.notifyWindowChanged(v.id, attached = true)
41
+ }
42
+
43
+ override fun onViewDetachedFromWindow(v: android.view.View) {
44
+ ViewWindowEvents.notifyWindowChanged(v.id, attached = false)
45
+ }
46
+ }
47
+ )
48
+
34
49
  if (containers.size == 1) {
35
50
  scheduleMeasureAndLayout()
36
51
  }
@@ -0,0 +1,32 @@
1
+ /*
2
+ * This file is part of the Scandit Data Capture SDK
3
+ *
4
+ * Copyright (C) 2026- Scandit AG. All rights reserved.
5
+ */
6
+ package com.scandit.datacapture.reactnative.core.utils
7
+
8
+ import com.scandit.datacapture.frameworks.core.events.Emitter
9
+
10
+ /**
11
+ * Relays per-view window attach/detach signals to JS (SDC-32484 single-owner
12
+ * camera model): the JS layer claims camera ownership when a scanner view's
13
+ * native container enters the window and releases it when it leaves. The core
14
+ * module registers the emitter at setup; view containers call
15
+ * [notifyWindowChanged] from their attach-state hooks. No-op until an emitter
16
+ * is registered.
17
+ */
18
+ object ViewWindowEvents {
19
+ const val WINDOW_ATTACHED_EVENT = "NativeView.onWindowAttached"
20
+ const val WINDOW_DETACHED_EVENT = "NativeView.onWindowDetached"
21
+
22
+ @Volatile
23
+ var emitter: Emitter? = null
24
+
25
+ fun notifyWindowChanged(viewId: Int, attached: Boolean) {
26
+ if (viewId <= 0) return
27
+ emitter?.emit(
28
+ if (attached) WINDOW_ATTACHED_EVENT else WINDOW_DETACHED_EVENT,
29
+ mutableMapOf("viewId" to viewId)
30
+ )
31
+ }
32
+ }
@@ -16,6 +16,7 @@ import com.scandit.datacapture.frameworks.core.CoreModule
16
16
  import com.scandit.datacapture.frameworks.core.FrameworkModule
17
17
  import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
18
18
  import com.scandit.datacapture.reactnative.core.utils.ReactNativeEventEmitter
19
+ import com.scandit.datacapture.reactnative.core.utils.ViewWindowEvents
19
20
 
20
21
  @ReactModule(name = ScanditDataCaptureCoreModuleBase.NAME)
21
22
  class ScanditDataCaptureCoreModule(
@@ -55,6 +56,9 @@ class ScanditDataCaptureCoreModule(
55
56
  val emitter = ReactNativeEventEmitter { payload ->
56
57
  emitOnScanditEvent(payload)
57
58
  }
59
+ // Per-view window attach/detach events for the JS camera-ownership
60
+ // model (SDC-32484); view containers emit through this relay.
61
+ ViewWindowEvents.emitter = emitter
58
62
 
59
63
  val coreModule = CoreModule.create(emitter)
60
64
  coreModule.onCreate(reactContext)
@@ -17,6 +17,7 @@ import com.scandit.datacapture.frameworks.core.CoreModule
17
17
  import com.scandit.datacapture.frameworks.core.FrameworkModule
18
18
  import com.scandit.datacapture.frameworks.core.locator.ServiceLocator
19
19
  import com.scandit.datacapture.reactnative.core.utils.ReactNativeEventEmitter
20
+ import com.scandit.datacapture.reactnative.core.utils.ViewWindowEvents
20
21
 
21
22
  @ReactModule(name = ScanditDataCaptureCoreModuleBase.NAME)
22
23
  class ScanditDataCaptureCoreModule(
@@ -54,6 +55,9 @@ class ScanditDataCaptureCoreModule(
54
55
 
55
56
  // Create emitter with bridge-based RCTDeviceEventEmitter
56
57
  val emitter = ReactNativeEventEmitter(reactContext)
58
+ // Per-view window attach/detach events for the JS camera-ownership
59
+ // model (SDC-32484); view containers emit through this relay.
60
+ ViewWindowEvents.emitter = emitter
57
61
 
58
62
  val coreModule = CoreModule.create(emitter)
59
63
  coreModule.onCreate(reactContext)
package/dist/core.js CHANGED
@@ -1834,6 +1834,42 @@ class CoreProxyAdapter {
1834
1834
  return result;
1835
1835
  });
1836
1836
  }
1837
+ /**
1838
+ * Adds an NV21 frame to the tracked sequence frame source with the given id
1839
+ * @param frameSourceId The id of the sequence frame source the frame is added to
1840
+ * @param width Frame width in pixels
1841
+ * @param height Frame height in pixels
1842
+ * @param frameData Base64-encoded NV21 frame bytes
1843
+ */
1844
+ addFrameToSequenceFrameSource(_a) {
1845
+ return __awaiter(this, arguments, void 0, function* ({ frameSourceId, width, height, frameData, }) {
1846
+ const result = yield this.proxy.$executeCore({
1847
+ moduleName: 'CoreModule',
1848
+ methodName: 'addFrameToSequenceFrameSource',
1849
+ isEventRegistration: false,
1850
+ frameSourceId,
1851
+ width,
1852
+ height,
1853
+ frameData,
1854
+ });
1855
+ return result;
1856
+ });
1857
+ }
1858
+ /**
1859
+ * Returns the current state of the tracked sequence frame source with the given id
1860
+ * @param frameSourceId The id of the sequence frame source to get the state of
1861
+ */
1862
+ getSequenceFrameSourceState(_a) {
1863
+ return __awaiter(this, arguments, void 0, function* ({ frameSourceId }) {
1864
+ const result = yield this.proxy.$executeCore({
1865
+ moduleName: 'CoreModule',
1866
+ methodName: 'getSequenceFrameSourceState',
1867
+ isEventRegistration: false,
1868
+ frameSourceId,
1869
+ });
1870
+ return JSON.parse(result.data);
1871
+ });
1872
+ }
1837
1873
  /**
1838
1874
  * Registers a persistent listener for torch state change events
1839
1875
  */
@@ -2511,6 +2547,26 @@ class DataCaptureContext extends DefaultSerializeable {
2511
2547
  }
2512
2548
  });
2513
2549
  }
2550
+ /**
2551
+ * Mirror a frame-source change that already occurred on the native side (e.g. a
2552
+ * CameraSwitchControl tap handled by the native camera switcher, which swaps the context's
2553
+ * active camera on its own). Repoints the TS-side frame source and active-context pointers
2554
+ * WITHOUT re-serializing to native — native is already in this state, so calling
2555
+ * setFrameSource() would trigger a redundant, and failing, swap.
2556
+ *
2557
+ * Private on purpose: framework-internal callers (CameraSwitchControlController) reach it
2558
+ * through the PrivateDataCaptureContext cast, keeping it off the public SDK surface.
2559
+ */
2560
+ adoptActiveFrameSource(frameSource) {
2561
+ if (this._frameSource === frameSource) {
2562
+ return;
2563
+ }
2564
+ if (this._frameSource) {
2565
+ this._frameSource.context = null;
2566
+ }
2567
+ this._frameSource = frameSource;
2568
+ frameSource.context = this;
2569
+ }
2514
2570
  addListener(listener) {
2515
2571
  return __awaiter(this, void 0, void 0, function* () {
2516
2572
  if (this.listeners.length === 0) {
@@ -3152,6 +3208,191 @@ __decorate([
3152
3208
  ignoreFromSerialization
3153
3209
  ], ImageFrameSource.prototype, "controller", void 0);
3154
3210
 
3211
+ class SequenceFrameSourceController extends BaseController {
3212
+ constructor(sequenceFrameSource) {
3213
+ super('CoreProxy');
3214
+ this.handleDidChangeStateEventWrapper = (ev) => {
3215
+ return this.handleDidChangeStateEvent(ev);
3216
+ };
3217
+ this.sequenceFrameSource = sequenceFrameSource;
3218
+ this.adapter = new CoreProxyAdapter(this._proxy);
3219
+ void this.subscribeListener();
3220
+ }
3221
+ get privateSequenceFrameSource() {
3222
+ return this.sequenceFrameSource;
3223
+ }
3224
+ getCurrentState() {
3225
+ return __awaiter(this, void 0, void 0, function* () {
3226
+ return yield this.adapter.getSequenceFrameSourceState({
3227
+ frameSourceId: this.privateSequenceFrameSource._id,
3228
+ });
3229
+ });
3230
+ }
3231
+ switchToDesiredState(desiredState) {
3232
+ return __awaiter(this, void 0, void 0, function* () {
3233
+ yield this.adapter.switchCameraToDesiredState({
3234
+ stateJson: desiredState.toString(),
3235
+ });
3236
+ });
3237
+ }
3238
+ addFrame(width, height, frameData) {
3239
+ return __awaiter(this, void 0, void 0, function* () {
3240
+ yield this.adapter.addFrameToSequenceFrameSource({
3241
+ frameSourceId: this.privateSequenceFrameSource._id,
3242
+ width,
3243
+ height,
3244
+ frameData,
3245
+ });
3246
+ });
3247
+ }
3248
+ subscribeListener() {
3249
+ return __awaiter(this, void 0, void 0, function* () {
3250
+ yield this.adapter.registerFrameSourceListener();
3251
+ this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
3252
+ this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
3253
+ });
3254
+ }
3255
+ unsubscribeListener() {
3256
+ return __awaiter(this, void 0, void 0, function* () {
3257
+ yield this.adapter.unregisterFrameSourceListener();
3258
+ this._proxy.unsubscribeFromEvents([FrameSourceListenerEvents.didChangeState]);
3259
+ this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateEventWrapper);
3260
+ });
3261
+ }
3262
+ dispose() {
3263
+ void this.unsubscribeListener();
3264
+ this._proxy.dispose();
3265
+ }
3266
+ handleDidChangeStateEvent(ev) {
3267
+ const event = EventDataParser.parseIfShouldHandle(ev, {});
3268
+ if (event === SKIP) {
3269
+ return;
3270
+ }
3271
+ if (event === null) {
3272
+ console.error('SequenceFrameSourceController didChangeState payload is null');
3273
+ return;
3274
+ }
3275
+ const newState = event.state;
3276
+ this.privateSequenceFrameSource.listeners.forEach(listener => {
3277
+ if (listener.didChangeState) {
3278
+ listener.didChangeState(this.sequenceFrameSource, newState);
3279
+ }
3280
+ });
3281
+ }
3282
+ }
3283
+
3284
+ /**
3285
+ * A frame source that processes frames fed to it via {@link SequenceFrameSource.addFrame},
3286
+ * in the order they are added. Use it when the camera is not handled by the SDK (e.g. when
3287
+ * another framework owns the camera).
3288
+ */
3289
+ class SequenceFrameSource extends DefaultSerializeable {
3290
+ set context(newContext) {
3291
+ if (newContext == null) {
3292
+ void this.controller.unsubscribeListener();
3293
+ }
3294
+ else if (this._context == null) {
3295
+ void this.controller.subscribeListener();
3296
+ }
3297
+ this._context = newContext;
3298
+ }
3299
+ get context() {
3300
+ return this._context;
3301
+ }
3302
+ get desiredState() {
3303
+ return this._desiredState;
3304
+ }
3305
+ /**
3306
+ * Creates a sequence frame source for the given camera position. On iOS the lens position
3307
+ * (0.0-1.0) sets the capture device lens position; on Android it is ignored.
3308
+ */
3309
+ static create(position, lensPosition) {
3310
+ const sequenceFrameSource = new SequenceFrameSource();
3311
+ sequenceFrameSource.position = position;
3312
+ sequenceFrameSource._lensPosition = lensPosition !== null && lensPosition !== void 0 ? lensPosition : 1;
3313
+ return sequenceFrameSource;
3314
+ }
3315
+ static fromJSON(json) {
3316
+ return SequenceFrameSource.create(json.position, json.lensPosition);
3317
+ }
3318
+ constructor() {
3319
+ super();
3320
+ this.type = 'sequence';
3321
+ this._lensPosition = 1;
3322
+ this._id = `${Date.now()}-${SequenceFrameSource.nextInstanceId++}`;
3323
+ this._desiredState = FrameSourceState.Off;
3324
+ this.listeners = [];
3325
+ this._context = null;
3326
+ this.controller = new SequenceFrameSourceController(this);
3327
+ }
3328
+ switchToDesiredState(state) {
3329
+ this._desiredState = state;
3330
+ return this.controller.switchToDesiredState(state);
3331
+ }
3332
+ /**
3333
+ * Adds a frame with the given width and height. The frame data must be the Base64 encoding
3334
+ * of the raw NV21 bytes of the frame. If this frame source is on and connected to a
3335
+ * data capture context, this is the next frame that will be processed.
3336
+ */
3337
+ addFrame(width, height, frameData) {
3338
+ return this.controller.addFrame(width, height, frameData);
3339
+ }
3340
+ addListener(listener) {
3341
+ if (listener == null) {
3342
+ return;
3343
+ }
3344
+ if (this.listeners.includes(listener)) {
3345
+ return;
3346
+ }
3347
+ this.listeners.push(listener);
3348
+ }
3349
+ removeListener(listener) {
3350
+ if (listener == null) {
3351
+ return;
3352
+ }
3353
+ if (!this.listeners.includes(listener)) {
3354
+ return;
3355
+ }
3356
+ this.listeners.splice(this.listeners.indexOf(listener), 1);
3357
+ }
3358
+ getCurrentState() {
3359
+ return this.controller.getCurrentState();
3360
+ }
3361
+ didChange() {
3362
+ if (this.context) {
3363
+ return this.context.update();
3364
+ }
3365
+ return Promise.resolve();
3366
+ }
3367
+ setNativeFrameSourceIsBeingCreated() {
3368
+ // SequenceFrameSource has no asynchronous native initialization step, so
3369
+ // there is nothing to track here. The method exists only to satisfy the
3370
+ // PrivateFrameSource contract that DataCaptureContext.setFrameSource()
3371
+ // invokes on every frame source.
3372
+ }
3373
+ }
3374
+ // The native handlers key their instance-reuse and addFrame routing on this id, so it must
3375
+ // be unique across instances — a timestamp alone can collide within the same millisecond.
3376
+ SequenceFrameSource.nextInstanceId = 0;
3377
+ __decorate([
3378
+ nameForSerialization('lensPosition')
3379
+ ], SequenceFrameSource.prototype, "_lensPosition", void 0);
3380
+ __decorate([
3381
+ nameForSerialization('id')
3382
+ ], SequenceFrameSource.prototype, "_id", void 0);
3383
+ __decorate([
3384
+ nameForSerialization('desiredState')
3385
+ ], SequenceFrameSource.prototype, "_desiredState", void 0);
3386
+ __decorate([
3387
+ ignoreFromSerialization
3388
+ ], SequenceFrameSource.prototype, "listeners", void 0);
3389
+ __decorate([
3390
+ ignoreFromSerialization
3391
+ ], SequenceFrameSource.prototype, "_context", void 0);
3392
+ __decorate([
3393
+ ignoreFromSerialization
3394
+ ], SequenceFrameSource.prototype, "controller", void 0);
3395
+
3155
3396
  class PrivateFrameData {
3156
3397
  get imageBuffers() {
3157
3398
  return this._imageBuffers;
@@ -3188,6 +3429,86 @@ class PrivateFrameData {
3188
3429
  }
3189
3430
  }
3190
3431
 
3432
+ /**
3433
+ * Keeps the TS-side camera state in sync with the native camera switcher.
3434
+ *
3435
+ * The native `CameraSwitchControl` swaps the DataCaptureContext's active camera on its own when
3436
+ * tapped; the TS layer is never told, so `DataCaptureContext.frameSource` and the two cameras'
3437
+ * `_desiredState` drift out of sync (leading to "Unable to switch the camera" rejections when the
3438
+ * app later acts on a camera native no longer treats as active). This controller listens to the
3439
+ * frame-source state events (which carry the camera position) and repoints the TS state to mirror
3440
+ * the native switch — without issuing any native call, since native is already in that state.
3441
+ */
3442
+ class CameraSwitchControlController extends BaseController {
3443
+ constructor(control) {
3444
+ super('CoreProxy');
3445
+ this.subscribed = false;
3446
+ // Arrow-function wrapper (matches CameraController) so `this` stays bound and always current.
3447
+ this.handleDidChangeStateWrapper = (ev) => {
3448
+ return this.handleDidChangeState(ev);
3449
+ };
3450
+ this.control = control;
3451
+ this.adapter = new CoreProxyAdapter(this._proxy);
3452
+ }
3453
+ subscribe() {
3454
+ return __awaiter(this, void 0, void 0, function* () {
3455
+ if (this.subscribed) {
3456
+ return;
3457
+ }
3458
+ this.subscribed = true;
3459
+ yield this.adapter.registerFrameSourceListener();
3460
+ this._proxy.subscribeForEvents([FrameSourceListenerEvents.didChangeState]);
3461
+ this._proxy.eventEmitter.on(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateWrapper);
3462
+ });
3463
+ }
3464
+ unsubscribe() {
3465
+ if (!this.subscribed) {
3466
+ return;
3467
+ }
3468
+ this.subscribed = false;
3469
+ // Only detach our JS handler. We intentionally do NOT unregister the native frame-source
3470
+ // listener — the active camera's own CameraController may still depend on it.
3471
+ this._proxy.eventEmitter.off(FrameSourceListenerEvents.didChangeState, this.handleDidChangeStateWrapper);
3472
+ }
3473
+ handleDidChangeState(ev) {
3474
+ var _a;
3475
+ const event = EventDataParser.parseIfShouldHandle(ev, {});
3476
+ if (event === SKIP || event === null) {
3477
+ return;
3478
+ }
3479
+ // Only react when a camera reaches a STABLE up state (on/standby). Transition states
3480
+ // (starting, bootingUp, …) must never be written into `desiredState`: that field serializes
3481
+ // to native, whose state machine rejects transition values as a desired state
3482
+ // (BAR_REQUIRES(!isTransition(state)) in async_start_stop_state_machine.cc → abort).
3483
+ // The paired "off" event for the outgoing camera is likewise ignored.
3484
+ if (event.state !== FrameSourceState.On && event.state !== FrameSourceState.Standby) {
3485
+ return;
3486
+ }
3487
+ const context = (_a = this.control.attachedView) === null || _a === void 0 ? void 0 : _a.context;
3488
+ if (!context) {
3489
+ return;
3490
+ }
3491
+ const primary = this.control.primaryCamera;
3492
+ const secondary = this.control.secondaryCamera;
3493
+ const next = event.cameraPosition === primary.position
3494
+ ? primary
3495
+ : event.cameraPosition === secondary.position
3496
+ ? secondary
3497
+ : null;
3498
+ if (!next || context.frameSource === next) {
3499
+ return;
3500
+ }
3501
+ const previous = context.frameSource;
3502
+ context.adoptActiveFrameSource(next);
3503
+ next._desiredState = event.state;
3504
+ next.currentCameraState = event.state;
3505
+ if (previous) {
3506
+ previous._desiredState = FrameSourceState.Off;
3507
+ previous.currentCameraState = FrameSourceState.Off;
3508
+ }
3509
+ }
3510
+ }
3511
+
3191
3512
  class FrameDataController extends BaseController {
3192
3513
  constructor() {
3193
3514
  super('CoreProxy');
@@ -4578,6 +4899,155 @@ __decorate([
4578
4899
  nameForSerialization('accessibilityHintWhenOn')
4579
4900
  ], TorchSwitchControl.prototype, "accessibilityHintWhenOn", void 0);
4580
4901
 
4902
+ class CameraSwitchControl extends DefaultSerializeable {
4903
+ get view() {
4904
+ return this._view;
4905
+ }
4906
+ // Attaching to / detaching from a view is the lifecycle hook for keeping the TS camera state
4907
+ // in sync with the native camera switcher: subscribe while attached, unsubscribe when removed.
4908
+ set view(view) {
4909
+ var _a, _b;
4910
+ this._view = view;
4911
+ if (view) {
4912
+ this.controller = (_a = this.controller) !== null && _a !== void 0 ? _a : new CameraSwitchControlController(this);
4913
+ void this.controller.subscribe();
4914
+ }
4915
+ else {
4916
+ (_b = this.controller) === null || _b === void 0 ? void 0 : _b.unsubscribe();
4917
+ }
4918
+ }
4919
+ /** @internal Read-only view access for the sync controller. */
4920
+ get attachedView() {
4921
+ return this._view;
4922
+ }
4923
+ constructor(primaryCamera, secondaryCamera) {
4924
+ super();
4925
+ this.type = 'camera';
4926
+ this.icon = {
4927
+ primaryCamera: { default: null, pressed: null },
4928
+ secondaryCamera: { default: null, pressed: null },
4929
+ };
4930
+ this._view = null;
4931
+ this.controller = null;
4932
+ this.anchor = null;
4933
+ this.offset = null;
4934
+ this.accessibilityLabelWhenWorldFacing = null;
4935
+ this.accessibilityHintWhenWorldFacing = null;
4936
+ this.accessibilityLabelWhenUserFacing = null;
4937
+ this.accessibilityHintWhenUserFacing = null;
4938
+ this._primaryCamera = primaryCamera;
4939
+ this._secondaryCamera = secondaryCamera;
4940
+ }
4941
+ get primaryCamera() {
4942
+ return this._primaryCamera;
4943
+ }
4944
+ get secondaryCamera() {
4945
+ return this._secondaryCamera;
4946
+ }
4947
+ get primaryCameraImage() {
4948
+ var _a, _b;
4949
+ if (((_a = this.icon.primaryCamera.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
4950
+ return (_b = this.icon.primaryCamera.default) === null || _b === void 0 ? void 0 : _b.data;
4951
+ }
4952
+ return null;
4953
+ }
4954
+ set primaryCameraImage(primaryCameraImage) {
4955
+ var _a;
4956
+ this.icon.primaryCamera.default = ControlImage.fromBase64EncodedImage(primaryCameraImage);
4957
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
4958
+ }
4959
+ get primaryCameraPressedImage() {
4960
+ var _a, _b;
4961
+ if (((_a = this.icon.primaryCamera.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
4962
+ return (_b = this.icon.primaryCamera.pressed) === null || _b === void 0 ? void 0 : _b.data;
4963
+ }
4964
+ return null;
4965
+ }
4966
+ set primaryCameraPressedImage(primaryCameraPressedImage) {
4967
+ var _a;
4968
+ this.icon.primaryCamera.pressed = ControlImage.fromBase64EncodedImage(primaryCameraPressedImage);
4969
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
4970
+ }
4971
+ get secondaryCameraImage() {
4972
+ var _a, _b;
4973
+ if (((_a = this.icon.secondaryCamera.default) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
4974
+ return (_b = this.icon.secondaryCamera.default) === null || _b === void 0 ? void 0 : _b.data;
4975
+ }
4976
+ return null;
4977
+ }
4978
+ set secondaryCameraImage(secondaryCameraImage) {
4979
+ var _a;
4980
+ this.icon.secondaryCamera.default = ControlImage.fromBase64EncodedImage(secondaryCameraImage);
4981
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
4982
+ }
4983
+ get secondaryCameraPressedImage() {
4984
+ var _a, _b;
4985
+ if (((_a = this.icon.secondaryCamera.pressed) === null || _a === void 0 ? void 0 : _a.isBase64EncodedImage()) == true) {
4986
+ return (_b = this.icon.secondaryCamera.pressed) === null || _b === void 0 ? void 0 : _b.data;
4987
+ }
4988
+ return null;
4989
+ }
4990
+ set secondaryCameraPressedImage(secondaryCameraPressedImage) {
4991
+ var _a;
4992
+ this.icon.secondaryCamera.pressed = ControlImage.fromBase64EncodedImage(secondaryCameraPressedImage);
4993
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
4994
+ }
4995
+ setPrimaryCameraImage(resource) {
4996
+ var _a;
4997
+ this.icon.primaryCamera.default = ControlImage.fromResourceName(resource);
4998
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
4999
+ }
5000
+ setPrimaryCameraPressedImage(resource) {
5001
+ var _a;
5002
+ this.icon.primaryCamera.pressed = ControlImage.fromResourceName(resource);
5003
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
5004
+ }
5005
+ setSecondaryCameraImage(resource) {
5006
+ var _a;
5007
+ this.icon.secondaryCamera.default = ControlImage.fromResourceName(resource);
5008
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
5009
+ }
5010
+ setSecondaryCameraPressedImage(resource) {
5011
+ var _a;
5012
+ this.icon.secondaryCamera.pressed = ControlImage.fromResourceName(resource);
5013
+ void ((_a = this.view) === null || _a === void 0 ? void 0 : _a['controlUpdated']());
5014
+ }
5015
+ }
5016
+ __decorate([
5017
+ nameForSerialization('primaryCamera')
5018
+ ], CameraSwitchControl.prototype, "_primaryCamera", void 0);
5019
+ __decorate([
5020
+ nameForSerialization('secondaryCamera')
5021
+ ], CameraSwitchControl.prototype, "_secondaryCamera", void 0);
5022
+ __decorate([
5023
+ ignoreFromSerialization
5024
+ ], CameraSwitchControl.prototype, "_view", void 0);
5025
+ __decorate([
5026
+ ignoreFromSerialization
5027
+ ], CameraSwitchControl.prototype, "controller", void 0);
5028
+ __decorate([
5029
+ ignoreFromSerializationIfNull
5030
+ ], CameraSwitchControl.prototype, "anchor", void 0);
5031
+ __decorate([
5032
+ ignoreFromSerializationIfNull
5033
+ ], CameraSwitchControl.prototype, "offset", void 0);
5034
+ __decorate([
5035
+ ignoreFromSerializationIfNull,
5036
+ nameForSerialization('accessibilityLabelWhenWorldFacing')
5037
+ ], CameraSwitchControl.prototype, "accessibilityLabelWhenWorldFacing", void 0);
5038
+ __decorate([
5039
+ ignoreFromSerializationIfNull,
5040
+ nameForSerialization('accessibilityHintWhenWorldFacing')
5041
+ ], CameraSwitchControl.prototype, "accessibilityHintWhenWorldFacing", void 0);
5042
+ __decorate([
5043
+ ignoreFromSerializationIfNull,
5044
+ nameForSerialization('accessibilityLabelWhenUserFacing')
5045
+ ], CameraSwitchControl.prototype, "accessibilityLabelWhenUserFacing", void 0);
5046
+ __decorate([
5047
+ ignoreFromSerializationIfNull,
5048
+ nameForSerialization('accessibilityHintWhenUserFacing')
5049
+ ], CameraSwitchControl.prototype, "accessibilityHintWhenUserFacing", void 0);
5050
+
4581
5051
  var VideoResolution;
4582
5052
  (function (VideoResolution) {
4583
5053
  /** @deprecated Auto is deprecated. Please use the capture mode's recommendedCameraSettings for the best results. */
@@ -5435,5 +5905,5 @@ var ClusteringMode;
5435
5905
  ClusteringMode["AutoWithManualCorrection"] = "autoWithManualCorrection";
5436
5906
  })(ClusteringMode || (ClusteringMode = {}));
5437
5907
 
5438
- 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 };
5908
+ export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, CameraSwitchControl, CameraSwitchControlController, 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, SequenceFrameSource, 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 };
5439
5909
  //# sourceMappingURL=core.js.map