scandit-react-native-datacapture-core 8.5.1 → 8.6.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 (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
@@ -1,96 +1,672 @@
1
- import { initCoreProxy } from './native/initProxy';
2
- import { initCoreDefaults } from './private/Defaults';
3
- export { initCoreDefaults };
4
- export { initCoreProxy };
5
- export { Point } from 'scandit-datacapture-frameworks-core';
6
- export { Quadrilateral } from 'scandit-datacapture-frameworks-core';
7
- export { NumberWithUnit } from 'scandit-datacapture-frameworks-core';
8
- export { PointWithUnit } from 'scandit-datacapture-frameworks-core';
9
- export { Rect } from 'scandit-datacapture-frameworks-core';
10
- export { RectWithUnit } from 'scandit-datacapture-frameworks-core';
11
- export { SizeWithUnit } from 'scandit-datacapture-frameworks-core';
12
- export { Size } from 'scandit-datacapture-frameworks-core';
13
- export { SizeWithAspect } from 'scandit-datacapture-frameworks-core';
14
- export { SizeWithUnitAndAspect } from 'scandit-datacapture-frameworks-core';
15
- export { MarginsWithUnit } from 'scandit-datacapture-frameworks-core';
16
- export { Color } from 'scandit-datacapture-frameworks-core';
17
- export { Brush } from 'scandit-datacapture-frameworks-core';
18
- export { MeasureUnit } from 'scandit-datacapture-frameworks-core';
19
- export { SizingMode } from 'scandit-datacapture-frameworks-core';
20
- export { Anchor } from 'scandit-datacapture-frameworks-core';
21
- export { Orientation } from 'scandit-datacapture-frameworks-core';
22
- export { Direction } from 'scandit-datacapture-frameworks-core';
23
- export { ScanIntention } from 'scandit-datacapture-frameworks-core';
24
- export { SelectionMode } from 'scandit-datacapture-frameworks-core';
25
- export { ClusteringMode } from 'scandit-datacapture-frameworks-core';
26
- export { Control } from 'scandit-datacapture-frameworks-core';
27
- export { ZoomSwitchControl } from 'scandit-datacapture-frameworks-core';
28
- export { ZoomSwitchOrientation } from 'scandit-datacapture-frameworks-core';
29
- export { TorchSwitchControl } from 'scandit-datacapture-frameworks-core';
30
- export { FrameSourceState } from 'scandit-datacapture-frameworks-core';
31
- export { FrameSourceListener } from 'scandit-datacapture-frameworks-core';
32
- export { TorchListener } from 'scandit-datacapture-frameworks-core';
33
- export { MacroModeListener } from 'scandit-datacapture-frameworks-core';
34
- export { ZoomListener } from 'scandit-datacapture-frameworks-core';
35
- export { FrameSource } from 'scandit-datacapture-frameworks-core';
36
- export { FrameDataSettings } from 'scandit-datacapture-frameworks-core';
37
- export { FrameDataSettingsBuilder } from 'scandit-datacapture-frameworks-core';
38
- export { DataCaptureContextListener } from 'scandit-datacapture-frameworks-core';
39
- export { ContextStatus } from 'scandit-datacapture-frameworks-core';
40
- export { Camera } from 'scandit-datacapture-frameworks-core';
41
- export { TorchState } from 'scandit-datacapture-frameworks-core';
42
- export { CameraPosition } from 'scandit-datacapture-frameworks-core';
43
- export { VideoResolution } from 'scandit-datacapture-frameworks-core';
44
- export { FocusRange } from 'scandit-datacapture-frameworks-core';
45
- export { FocusGesture } from 'scandit-datacapture-frameworks-core';
46
- export { FocusGestureStrategy } from 'scandit-datacapture-frameworks-core';
47
- export { FocusGestureListener } from 'scandit-datacapture-frameworks-core';
48
- export { ZoomGesture } from 'scandit-datacapture-frameworks-core';
49
- export { ZoomGestureListener } from 'scandit-datacapture-frameworks-core';
50
- export { SwipeToZoom } from 'scandit-datacapture-frameworks-core';
51
- export { PinchToZoom } from 'scandit-datacapture-frameworks-core';
52
- export { CameraSettings } from 'scandit-datacapture-frameworks-core';
53
- export { MacroMode } from 'scandit-datacapture-frameworks-core';
54
- export { FrameData } from 'scandit-datacapture-frameworks-core';
55
- export { ImageBuffer } from 'scandit-datacapture-frameworks-core';
56
- export { ImageFrameSource } from 'scandit-datacapture-frameworks-core';
57
- export { TapToFocus } from 'scandit-datacapture-frameworks-core';
58
- export { DataCaptureMode } from 'scandit-datacapture-frameworks-core';
59
- export { DataCaptureComponent } from 'scandit-datacapture-frameworks-core';
60
- export { DataCaptureContextCreationOptions } from 'scandit-datacapture-frameworks-core';
61
- export { DataCaptureContextSettings } from 'scandit-datacapture-frameworks-core';
62
- export { DataCaptureContext } from 'scandit-datacapture-frameworks-core';
63
- export { DataCaptureOverlay } from 'scandit-datacapture-frameworks-core';
64
- export { LogoStyle } from 'scandit-datacapture-frameworks-core';
65
- export * from './DataCaptureVersion';
66
- export * from './DataCaptureView';
67
- export { Vibration } from 'scandit-datacapture-frameworks-core';
68
- export { WaveFormVibration } from 'scandit-datacapture-frameworks-core';
69
- export { Sound } from 'scandit-datacapture-frameworks-core';
70
- export { Feedback } from 'scandit-datacapture-frameworks-core';
71
- export { LocationSelection } from 'scandit-datacapture-frameworks-core';
72
- export { NoneLocationSelection } from 'scandit-datacapture-frameworks-core';
73
- export { RadiusLocationSelection } from 'scandit-datacapture-frameworks-core';
74
- export { RectangularLocationSelection } from 'scandit-datacapture-frameworks-core';
75
- export { Viewfinder } from 'scandit-datacapture-frameworks-core';
76
- export { NoViewfinder } from 'scandit-datacapture-frameworks-core';
77
- export { RectangularViewfinder } from 'scandit-datacapture-frameworks-core';
78
- export { AimerViewfinder } from 'scandit-datacapture-frameworks-core';
79
- export { LaserlineViewfinder } from 'scandit-datacapture-frameworks-core';
80
- export { RectangularViewfinderStyle } from 'scandit-datacapture-frameworks-core';
81
- export { RectangularViewfinderLineStyle } from 'scandit-datacapture-frameworks-core';
82
- export { RectangularViewfinderAnimation } from 'scandit-datacapture-frameworks-core';
83
- export { LicenseInfo } from 'scandit-datacapture-frameworks-core';
84
- export { Expiration } from 'scandit-datacapture-frameworks-core';
85
- export { OpenSourceSoftwareLicenseInfo } from 'scandit-datacapture-frameworks-core';
86
- export { FontFamily } from 'scandit-datacapture-frameworks-core';
87
- export { TextAlignment } from 'scandit-datacapture-frameworks-core';
88
- export { ScanditIcon } from 'scandit-datacapture-frameworks-core';
89
- export { ScanditIconShape } from 'scandit-datacapture-frameworks-core';
90
- export { ScanditIconType } from 'scandit-datacapture-frameworks-core';
91
- export { ScanditIconBuilder } from 'scandit-datacapture-frameworks-core';
92
- export * from './hooks';
93
- import * as _internal from './private/index';
94
- export { _internal };
95
- export * from './native/RNNativeCaller';
96
- export * from './native/ScanditNativeModule';
1
+ import { Size, Orientation, BaseDataCaptureView, MarginsWithUnit, PointWithUnit, LogoStyle, Anchor, FocusGesture, ZoomGesture, Point, Quadrilateral, Control, Serializeable, DataCaptureContext, DataCaptureContextSettings, DataCaptureContextCreationOptions, FrameSourceState, TorchState, CameraPosition, DataCaptureOverlay as DataCaptureOverlay$1, NativeCaller } from './core';
2
+ export { AimerViewfinder, Anchor, Brush, Camera, CameraPosition, CameraSettings, CameraSwitchControl, ClusteringMode, Color, ContextStatus, Control, DataCaptureComponent, DataCaptureContext, DataCaptureContextCreationOptions, DataCaptureContextListener, DataCaptureContextSettings, DataCaptureMode, DataCaptureOverlay, Direction, Expiration, Feedback, FocusGesture, FocusGestureListener, FocusGestureStrategy, FocusRange, FontFamily, FrameData, FrameDataSettings, FrameDataSettingsBuilder, FrameSource, FrameSourceListener, FrameSourceState, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, LocationSelection, LogoStyle, MacroMode, MacroModeListener, MarginsWithUnit, MeasureUnit, NoViewfinder, NoneLocationSelection, NumberWithUnit, OpenSourceSoftwareLicenseInfo, Orientation, PinchToZoom, Point, PointWithUnit, Quadrilateral, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, SelectionMode, SequenceFrameSource, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchListener, TorchState, TorchSwitchControl, Vibration, VibrationType, VideoResolution, Viewfinder, WaveFormVibration, ZoomGesture, ZoomGestureListener, ZoomListener, ZoomSwitchControl, ZoomSwitchOrientation } from './core';
3
+ import React$1, { DependencyList, MutableRefObject } from 'react';
4
+ import { StyleProp, ViewStyle, LayoutChangeEvent, NativeModule } from 'react-native';
5
+
6
+ declare function initCoreProxy(): void;
7
+
8
+ declare function initCoreDefaults(): void;
9
+
10
+ declare class DataCaptureVersion {
11
+ static get pluginVersion(): string;
12
+ static get sdkVersion(): string;
13
+ }
14
+
15
+ interface DataCaptureOverlay extends Serializeable {
16
+ }
17
+ interface DataCaptureViewListener {
18
+ didChangeSize?(view: DataCaptureView, size: Size, orientation: Orientation): void;
19
+ }
20
+ interface DataCaptureViewProps {
21
+ context: DataCaptureContext;
22
+ style: StyleProp<ViewStyle>;
23
+ parentId?: number;
24
+ onLayout?: (event: LayoutChangeEvent) => void;
25
+ /**
26
+ * Internal (AIO wrappers): receives the native teardown promise on unmount so
27
+ * the camera coordinator can park it as a barrier — a sibling screen's fresh
28
+ * view must not be created until this view's native dispose has fully
29
+ * completed, or iOS rendering never re-binds to it (SDC-32484).
30
+ */
31
+ onNativeDispose?: (teardown: Promise<unknown>) => void;
32
+ }
33
+ declare class DataCaptureView extends React$1.Component<DataCaptureViewProps> {
34
+ protected view: BaseDataCaptureView;
35
+ private _isMounted;
36
+ private _viewCreated;
37
+ private _createViewRafHandle;
38
+ constructor(props: DataCaptureViewProps);
39
+ get scanAreaMargins(): MarginsWithUnit;
40
+ set scanAreaMargins(newValue: MarginsWithUnit);
41
+ get pointOfInterest(): PointWithUnit;
42
+ set pointOfInterest(newValue: PointWithUnit);
43
+ get logoStyle(): LogoStyle;
44
+ set logoStyle(style: LogoStyle);
45
+ get logoAnchor(): Anchor;
46
+ set logoAnchor(newValue: Anchor);
47
+ get logoOffset(): PointWithUnit;
48
+ set logoOffset(newValue: PointWithUnit);
49
+ get focusGesture(): FocusGesture | null;
50
+ set focusGesture(newValue: FocusGesture | null);
51
+ get zoomGestures(): ZoomGesture[];
52
+ set zoomGestures(newValue: ZoomGesture[]);
53
+ /** @deprecated Use zoomGestures instead. Will be removed in a future version. */
54
+ get zoomGesture(): ZoomGesture | null;
55
+ /** @deprecated Use zoomGestures instead. Will be removed in a future version. */
56
+ set zoomGesture(newValue: ZoomGesture | null);
57
+ get shouldShowZoomNotification(): boolean;
58
+ set shouldShowZoomNotification(newValue: boolean);
59
+ setProperty<T>(name: string, value: T): void;
60
+ addOverlay(overlay: DataCaptureOverlay): Promise<void>;
61
+ removeOverlay(overlay: DataCaptureOverlay): Promise<void>;
62
+ addListener(listener: DataCaptureViewListener): void;
63
+ removeListener(listener: DataCaptureViewListener): void;
64
+ viewPointForFramePoint(point: Point): Promise<Point>;
65
+ viewQuadrilateralForFrameQuadrilateral(quadrilateral: Quadrilateral): Promise<Quadrilateral>;
66
+ addControl(control: Control): Promise<void>;
67
+ addControlWithAnchorAndOffset(control: Control, anchor: Anchor, offset: PointWithUnit): void;
68
+ removeControl(control: Control): void;
69
+ componentWillUnmount(): void;
70
+ componentDidMount(): void;
71
+ render(): React$1.JSX.Element;
72
+ protected removeAllOverlays(): void;
73
+ private onNativeViewLayout;
74
+ private tryCreateDataCaptureView;
75
+ private scheduleCreateDataCaptureView;
76
+ }
77
+
78
+ /**
79
+ * Returns whether the app is currently in the foreground.
80
+ * Useful for composing the `isActive` prop on scanning views:
81
+ *
82
+ * ```tsx
83
+ * const isForeground = useIsForeground();
84
+ * const isFocused = useIsFocused(); // from @react-navigation/native
85
+ * <BarcodeCaptureView isActive={isFocused && isForeground} ... />
86
+ * ```
87
+ */
88
+ declare function useIsForeground(): boolean;
89
+
90
+ type PermissionStatus = 'granted' | 'denied' | 'not-determined' | 'restricted';
91
+ interface CameraPermissionResult {
92
+ hasPermission: boolean;
93
+ permissionStatus: PermissionStatus;
94
+ requestPermission: () => Promise<boolean>;
95
+ }
96
+ /**
97
+ * Manages camera permission status.
98
+ *
99
+ * **Android**: real status via `PermissionsAndroid`; `requestPermission()` shows the native
100
+ * prompt; status re-checked when the app returns to the foreground (e.g. user flipped it
101
+ * in Settings).
102
+ *
103
+ * **iOS**: limited. Without a platform-specific native module we can't query
104
+ * `AVCaptureDevice.authorizationStatus` or drive the system prompt directly — iOS
105
+ * handles the permission dialog automatically the first time the camera is accessed.
106
+ * On iOS this hook returns `permissionStatus: 'not-determined'` initially and
107
+ * optimistically flips to `'granted'` after `requestPermission()` is called.
108
+ * It cannot detect denials after-the-fact; consumers should treat the iOS camera-start
109
+ * flow as the authoritative signal (surfaced via `<BarcodeCaptureView onError={...} />`).
110
+ *
111
+ * ```tsx
112
+ * const { hasPermission, requestPermission } = useCameraPermission();
113
+ * if (!hasPermission) return <Button onPress={requestPermission} title="Grant Camera Access" />;
114
+ * ```
115
+ */
116
+ declare function useCameraPermission(): CameraPermissionResult;
117
+
118
+ interface UseScanditContextOptions {
119
+ /**
120
+ * Applied at first render, then re-applied via `context.applySettings(...)`
121
+ * whenever the reference changes. Memoize this with `useMemo` (or build it
122
+ * once) — passing a fresh instance every render will spam `applySettings`.
123
+ */
124
+ settings?: DataCaptureContextSettings;
125
+ /** Applied once at native initialization. Later changes are ignored. */
126
+ creationOptions?: DataCaptureContextCreationOptions;
127
+ }
128
+ /**
129
+ * Initializes (or retrieves) the DataCaptureContext singleton.
130
+ *
131
+ * ```tsx
132
+ * const settings = useMemo(() => new DataCaptureContextSettings(), []);
133
+ * const context = useScanditContext('YOUR_LICENSE_KEY', { settings });
134
+ * ```
135
+ */
136
+ declare function useScanditContext(licenseKey: string, options?: UseScanditContextOptions): DataCaptureContext;
137
+
138
+ type CameraClaimMode = 'shared' | 'exclusive';
139
+ /**
140
+ * Identity object registered by a view. Ownership is by object identity: the
141
+ * registered object IS the owner handle. Mutated in place by `updateClaim`.
142
+ */
143
+ interface CameraClaim {
144
+ mode: CameraClaimMode;
145
+ active: boolean;
146
+ }
147
+ /**
148
+ * The ownership surface `useCameraClaim` is built on, plus camera-wide
149
+ * controls (torch/position) and lifecycle.
150
+ */
151
+ interface CameraCoordinator {
152
+ setTorch(torch: TorchState): Promise<void>;
153
+ setPosition(position: CameraPosition): Promise<void>;
154
+ /**
155
+ * Resolves when the current op chain has drained (errors swallowed).
156
+ * Test/diagnostic aid — production code awaits `whenGranted` instead.
157
+ */
158
+ idle(): Promise<void>;
159
+ dispose(): Promise<void>;
160
+ /** Register a claim handle. Registration alone takes no ownership. */
161
+ addClaim(claim: CameraClaim): void;
162
+ /**
163
+ * Patch a claim's `mode`/`active`. Setting `active: true` claims ownership
164
+ * (superseding the previous owner); `active: false` releases the camera if
165
+ * the claim is the current owner, and is ignored otherwise.
166
+ */
167
+ updateClaim(claim: CameraClaim, patch: Partial<CameraClaim>): void;
168
+ /**
169
+ * Drop a claim. `teardown`, if given, is awaited (timeout-raced) before any
170
+ * later camera operation, so a dying view's native dispose can never race
171
+ * the next owner's switch-on.
172
+ */
173
+ removeClaim(claim: CameraClaim, teardown?: Promise<unknown>): void;
174
+ /** Resolves once the chain has applied the state this claim implies. */
175
+ whenGranted(claim: CameraClaim): Promise<void>;
176
+ }
177
+ type ScanditInternal = {
178
+ context: DataCaptureContext;
179
+ owner: CameraCoordinator;
180
+ };
181
+ type CameraProps = {
182
+ frameSourceState?: FrameSourceState;
183
+ torchState?: TorchState;
184
+ cameraPosition?: CameraPosition;
185
+ };
186
+ type ScanditProviderProps = CameraProps & {
187
+ /** Required on the root provider. Ignored (with a warning) on nested ones. */
188
+ licenseKey?: string;
189
+ /** Only used on the root provider. */
190
+ options?: DataCaptureContextCreationOptions;
191
+ /** Only used on the root provider. */
192
+ settings?: DataCaptureContextSettings;
193
+ /**
194
+ * Called when an asynchronous camera operation rejects (e.g. a frame-source
195
+ * transition fails). Failures are still logged via `console.warn`; this hook
196
+ * lets consumers surface them (telemetry, UI). Only honored on the root
197
+ * provider, which owns the camera. The latest callback is always used.
198
+ */
199
+ onError?: (error: unknown) => void;
200
+ children: React$1.ReactNode;
201
+ };
202
+ /**
203
+ * Provides a `DataCaptureContext` and a singleton `Camera` to descendant AIO views.
204
+ *
205
+ * - **Root** (no parent `<ScanditProvider>` above): creates the context + camera,
206
+ * disposes them on unmount.
207
+ * - **Nested**: applies its own `frameSourceState` / `torchState` / `cameraPosition`
208
+ * props to the same singleton camera. Last writer wins; values are not reverted
209
+ * when a nested provider unmounts.
210
+ *
211
+ * The camera is ownership-driven: exactly one view owns it at a time (last
212
+ * claim wins), and it is only on while the owner is a provider-camera view (or
213
+ * `frameSourceState={On}` is set). Torch and position are applied to the
214
+ * coordinator; the camera instance is recreated only when `cameraPosition`
215
+ * flips.
216
+ *
217
+ * ```tsx
218
+ * <ScanditProvider licenseKey={KEY}>
219
+ * <NavigationContainer> ... </NavigationContainer>
220
+ * </ScanditProvider>
221
+ *
222
+ * // Screen-local control:
223
+ * <ScanditProvider
224
+ * frameSourceState={isFocused ? FrameSourceState.On : FrameSourceState.Off}
225
+ * torchState={torch}
226
+ * cameraPosition={position}>
227
+ * <BarcodeCaptureView state="enabled" ... />
228
+ * </ScanditProvider>
229
+ * ```
230
+ */
231
+ declare function ScanditProvider(props: ScanditProviderProps): React$1.JSX.Element;
232
+ /** Internal — exposes the shared context + camera coordinator to AIO views. */
233
+ declare function useScanditInternal(): ScanditInternal;
234
+ /** Internal — used by AIO views to attach modes to the shared context. */
235
+ declare function useDataCaptureContextInternal(): DataCaptureContext;
236
+
237
+
238
+
239
+ /**
240
+ * Returns a referentially-stable copy of `value` as long as the structural
241
+ * content stays the same. Lets consumers pass inline SDK class instances
242
+ * (`new Brush(...)`, `new TorchSwitchControl()`) or plain options objects
243
+ * without memoizing — the effect deps array sees the same reference until
244
+ * the underlying content actually changes.
245
+ *
246
+ * SDK classes that extend `DefaultSerializeable` are compared via their
247
+ * `toJson()` output (which respects `@ignoreFromSerialization`), so private
248
+ * back-refs like `view` don't cause spurious diffs. Plain objects and arrays
249
+ * are compared via direct `JSON.stringify`.
250
+ *
251
+ * ```tsx
252
+ * function MyView({ brush }: { brush?: Brush | null }) {
253
+ * const stableBrush = useStableProp(brush);
254
+ * useEffect(() => {
255
+ * if (stableBrush) overlay.brush = stableBrush;
256
+ * }, [stableBrush]);
257
+ * }
258
+ * ```
259
+ */
260
+ declare function useStableProp<T>(value: T): T;
261
+
262
+ /**
263
+ * Mirrors a fixed set of prop values onto a live native-view instance via
264
+ * direct property assignment.
265
+ *
266
+ * `keys` is constrained to `keyof Props & keyof Target` and combined with an
267
+ * `as const satisfies ReadonlyArray<...>` at the call site, so a rename on
268
+ * either side — prop interface or native view — is a compile error.
269
+ *
270
+ * `undefined` values are skipped to preserve SDK defaults. The effect is
271
+ * gated on `target` so setter RPCs only fire after the native view is
272
+ * attached.
273
+ *
274
+ * For batched-update layers that expose an `updateWithProps(prev, next)`
275
+ * method, keep their own diff effect rather than using this hook — it would
276
+ * fire one RPC per key instead of one per render.
277
+ *
278
+ * ```ts
279
+ * const KEYS = ['shouldShowTorchControl', 'torchControlPosition'] as const
280
+ * satisfies ReadonlyArray<keyof MyProps & keyof BaseView>;
281
+ *
282
+ * usePassThroughProps(baseView, props, KEYS);
283
+ * ```
284
+ */
285
+ declare function usePassThroughProps<Props extends object, Target extends object, Keys extends ReadonlyArray<keyof Props & keyof Target>>(target: Target | null, props: Props, keys: Keys): void;
286
+
287
+ type UseModeListenerProps<TMode, TListener extends object> = {
288
+ mode: TMode | null;
289
+ listenerFns: TListener;
290
+ addListener: (mode: TMode, listener: TListener) => void;
291
+ removeListener: (mode: TMode, listener: TListener) => void;
292
+ };
293
+ /**
294
+ * Registers a listener on a Scandit mode or view and keeps it up to date.
295
+ *
296
+ * Pass `listenerFns` with the callbacks you care about and leave the rest
297
+ * `undefined`. The hook only registers when `mode` is non-null and at least
298
+ * one callback is set; it unregisters automatically on unmount or when those
299
+ * conditions stop being true.
300
+ *
301
+ * The proxy installed on the target contains methods **only for keys whose
302
+ * values are currently defined**. This matters because some shared
303
+ * controllers do `if (listener.foo)` truthy checks (e.g.
304
+ * `BarcodeBatchBasicOverlayController.handleBrushForTrackedBarcode`) and a
305
+ * proxy method that returns `undefined` is interpreted as a real `null`
306
+ * response by the bridge — which wipes the configured default brush. When
307
+ * the set of defined keys changes (a callback flips between defined and
308
+ * undefined across renders), the proxy is rebuilt and the listener is
309
+ * unregistered + re-registered.
310
+ *
311
+ * Inline functions are fine — within the "defined" set, the registered
312
+ * listener is a stable proxy that always dispatches to the latest version of
313
+ * each callback without re-registering.
314
+ *
315
+ * ```tsx
316
+ * useModeListener<BarcodeCapture, BarcodeCaptureListener>({
317
+ * mode,
318
+ * listenerFns: {
319
+ * didScan: onScan ? async (_c, session, getFD) => onScan(session, getFD) : undefined,
320
+ * },
321
+ * addListener: (m, l) => m.addListener(l),
322
+ * removeListener: (m, l) => m.removeListener(l),
323
+ * });
324
+ * ```
325
+ */
326
+ declare function useModeListener<TMode, TListener extends object>({ mode, listenerFns, addListener, removeListener, }: UseModeListenerProps<TMode, TListener>): void;
327
+
328
+ type ViewHandle<T> = {
329
+ /**
330
+ * Ref callback to pass to the view. Updates both the internal mutable ref
331
+ * and the reactive state so effects can depend on the view being mounted.
332
+ */
333
+ ref: (v: T | null) => void;
334
+ /** Latest view instance for use inside effects/deps. */
335
+ current: T | null;
336
+ /** Same value as `current`, exposed as the mutable ref consumers also rely on. */
337
+ mutableRef: React.MutableRefObject<T | null>;
338
+ /** Stable, process-unique id used by views that need a parent-id linkage to native serialization. */
339
+ id: number;
340
+ /**
341
+ * `onLayout` handler to pass to the native component. Fires when the view is
342
+ * laid out (committed to the native tree), at which point `findNodeHandle`
343
+ * returns a valid handle. This is the signal `whenReady` resolves on.
344
+ */
345
+ onLayout: () => void;
346
+ /**
347
+ * Resolves the first time the native view is laid out. Use this to gate
348
+ * native-view creation instead of `InteractionManager.runAfterInteractions`:
349
+ * layout is not starvable by a blocked JS interaction queue (e.g. a looping
350
+ * animation with `useNativeDriver: false`), which would otherwise leave the
351
+ * preview view never created. See SDC-32208.
352
+ *
353
+ * Callers that await `whenReady()` MUST also wire `onLayout` onto the mounted
354
+ * native component — otherwise the promise never resolves.
355
+ */
356
+ whenReady: () => Promise<void>;
357
+ };
358
+ /**
359
+ * Bundles the `ref + viewState + viewId` pattern that AIO views share.
360
+ *
361
+ * - The returned `ref` is stable across renders.
362
+ * - `current` is a reactive snapshot — effects keyed on it re-run when the
363
+ * view mounts/unmounts. `mutableRef` exposes the same value for imperative
364
+ * reads that must not trigger re-renders.
365
+ * - `id` is generated once per hook instance and stays stable for the lifetime
366
+ * of the component, suitable for `parentId` serialization.
367
+ */
368
+ declare function useViewHandle<T>(): ViewHandle<T>;
369
+
370
+ interface ControlHost<C> {
371
+ addControl: (control: C) => Promise<void> | void;
372
+ removeControl: (control: C) => Promise<void> | void;
373
+ }
374
+ /**
375
+ * Adds `control` to `view` while both are present and the control reference is
376
+ * stable. Removes the control on unmount or when either reference changes.
377
+ *
378
+ * The view is typically a `DataCaptureView` and the control is a Scandit
379
+ * `Control` (e.g. `TorchSwitchControl`, `ZoomSwitchControl`). Pair this with
380
+ * `useStableProp(control)` at the call site so inline `new XControl()`
381
+ * instantiation doesn't churn add/remove.
382
+ */
383
+ declare function useNativeControl<V extends ControlHost<C>, C>(view: V | null, control: C | null | undefined): void;
384
+
385
+ /**
386
+ * Minimal shape of an overlay (or any resource) `useMode` can orchestrate.
387
+ * Matches `UseOverlayApi` — `useOverlay` returns objects assignable to this.
388
+ */
389
+ interface ModeAttachable {
390
+ attach: () => void | Promise<void>;
391
+ detach: () => void | Promise<void>;
392
+ }
393
+ interface UseModeOptions<TMode> {
394
+ /**
395
+ * Initial user veto. When `true`, the mode is attached but the first
396
+ * `setEnabled` is *not* an enable — it honors the veto (the mode comes up
397
+ * disabled). After attach, drive on/off with the returned `enable()` /
398
+ * `disable()`. `false`/unset means the mode auto-enables on attach.
399
+ */
400
+ disabled?: boolean;
401
+ createMode: () => TMode;
402
+ applySettings: (mode: TMode) => void | Promise<void>;
403
+ setEnabled: (mode: TMode, enabled: boolean) => void | Promise<void>;
404
+ attach: (mode: TMode) => void | Promise<void>;
405
+ detach: (mode: TMode) => void | Promise<void>;
406
+ /**
407
+ * Resources attached/detached in lockstep with the mode. Each is `attach()`-ed
408
+ * after the consumer's `attach(mode)` resolves (in declaration order), and
409
+ * `detach()`-ed before the consumer's `detach(mode)` is called (in reverse
410
+ * order). Designed for the `UseOverlayApi` returned by `useOverlay`.
411
+ */
412
+ attachables?: ReadonlyArray<ModeAttachable>;
413
+ /** Gate attach on external readiness (e.g. native view node mounted). Defaults to true. */
414
+ canAttach?: boolean;
415
+ /** Re-apply settings when any of these change (and the mode is attached). */
416
+ settingsDeps: DependencyList;
417
+ }
418
+ interface UseModeApi<TMode> {
419
+ /** Lazy accessor. Creates the mode on first call; nulled out after detach. */
420
+ getMode: () => TMode;
421
+ /** Read-only view of the underlying ref. Null when no mode currently exists. */
422
+ modeRef: MutableRefObject<TMode | null>;
423
+ /** True while the mode is currently attached. */
424
+ isAttached: () => boolean;
425
+ /** Enable the mode now (applied on attach if called before it completes). */
426
+ enable: () => Promise<void>;
427
+ /** Disable the mode now (applied on attach if called before it completes). */
428
+ disable: () => Promise<void>;
429
+ /**
430
+ * Attach (add to context) the mode now. Idempotent; serialized with `detach()`.
431
+ * Re-attaches the *same* instance, so the listener registered via
432
+ * `useModeListener` survives (it stays on the mode and re-subscribes when the
433
+ * mode is re-added to a context). Drive from screen focus so the focused view
434
+ * always owns the context's single active mode — the native context is
435
+ * single-active-mode and `addMode` of a non-coexisting mode silently evicts
436
+ * the others, so a blurred view must `detach()` and re-`attach()` on focus
437
+ * rather than merely toggling `enabled`.
438
+ */
439
+ attach: () => Promise<void>;
440
+ /** Detach (remove from context) the mode now. Idempotent; serialized with `attach()`. */
441
+ detach: () => Promise<void>;
442
+ }
443
+ /**
444
+ * Mode-lifetime helper shared by SDK view components.
445
+ *
446
+ * Owns: lazy mode creation, attach-on-mount / detach-on-unmount, settings
447
+ * reapply on dep change, and the mode's `isEnabled` via the returned
448
+ * `enable()` / `disable()`. The first `setEnabled` after attach honors the
449
+ * `disabled` veto, so a view declared `disabled` comes up off.
450
+ *
451
+ * Enable/disable intent is tracked in a ref (not React state) and applied as
452
+ * soon as the mode is attached — calling `enable()`/`disable()` before attach
453
+ * completes is fine; the pending value is flushed on attach.
454
+ *
455
+ * Side-effecting callbacks (`attach`, `detach`, `applySettings`, `setEnabled`,
456
+ * `createMode`) are read through a ref, so callers can pass closures without
457
+ * memoizing — only `canAttach` and `settingsDeps` drive effects.
458
+ */
459
+ declare function useMode<TMode>(options: UseModeOptions<TMode>): UseModeApi<TMode>;
460
+
461
+
462
+
463
+ interface UseOverlayOptions<O extends DataCaptureOverlay$1> {
464
+ /**
465
+ * Ref to the underlying `DataCaptureView`. The overlay is added the first
466
+ * time `attach()` is called with `view.current` non-null.
467
+ */
468
+ view: MutableRefObject<DataCaptureView | null>;
469
+ /**
470
+ * Whether the overlay should be attached. Defaults to `true`. Toggling at
471
+ * runtime triggers a detach/re-attach while the mode is otherwise attached.
472
+ */
473
+ enabled?: boolean;
474
+ /**
475
+ * Build the overlay. Re-invoked whenever `factoryDeps` change while the
476
+ * overlay is attached — the old overlay is removed and the new one added,
477
+ * preserving order with respect to `useMode`'s lifecycle.
478
+ */
479
+ factory: () => O;
480
+ /**
481
+ * Deps that trigger a recreate (`removeOverlay` → `factory()` → `addOverlay`).
482
+ * Use for constructor-time props (e.g. overlay style). Defaults to `[]`.
483
+ */
484
+ factoryDeps?: DependencyList;
485
+ /**
486
+ * Apply mutable state to the overlay (brushes, viewfinder, scan-area guides).
487
+ * Runs once after attach and whenever `updateDeps` change while attached.
488
+ */
489
+ update?: (overlay: O) => void;
490
+ /** Deps that re-trigger `update`. Defaults to `[]`. */
491
+ updateDeps?: DependencyList;
492
+ }
493
+ interface UseOverlayApi<O> {
494
+ /**
495
+ * Reactive overlay snapshot. `null` until attached and again after detach
496
+ * (and momentarily during a `factoryDeps`-driven recreate). Pass to
497
+ * `useModeListener` as the `mode` field so listener registration follows
498
+ * the overlay lifecycle.
499
+ */
500
+ overlay: O | null;
501
+ /** Non-reactive accessor for imperative reads. */
502
+ getOverlay: () => O | null;
503
+ /** Add the overlay to the view. Idempotent. Call from `useMode.attachables`. */
504
+ attach: () => Promise<void>;
505
+ /** Remove the overlay from the view. Idempotent. Call from `useMode.attachables`. */
506
+ detach: () => Promise<void>;
507
+ }
508
+ /**
509
+ * Lifecycle helper for `DataCaptureView` overlays. Pass the returned value into
510
+ * `useMode({ attachables: [...] })` — `useMode` orders `attach()` after the
511
+ * mode is added to the context and `detach()` before it's removed.
512
+ *
513
+ * Listener registration is not handled here; pair with `useModeListener`
514
+ * keyed on the reactive `overlay` snapshot:
515
+ *
516
+ * ```tsx
517
+ * const basicOverlay = useOverlay<BarcodeBatchBasicOverlay>({ ... });
518
+ *
519
+ * useModeListener<BarcodeBatchBasicOverlay, BarcodeBatchBasicOverlayListener>({
520
+ * mode: basicOverlay.overlay,
521
+ * listenerFns: { brushForTrackedBarcode, didTapTrackedBarcode },
522
+ * addListener: (o, l) => { o.listener = l; },
523
+ * removeListener: o => { o.listener = null; },
524
+ * });
525
+ * ```
526
+ */
527
+ declare function useOverlay<O extends DataCaptureOverlay$1>(opts: UseOverlayOptions<O>): UseOverlayApi<O>;
528
+
529
+ interface ScanditNavigationProp {
530
+ /**
531
+ * Subscribe to a screen `focus` or `blur` event. Must return an unsubscribe
532
+ * function. React Navigation's `navigation` object satisfies this; any custom
533
+ * source can implement the same method.
534
+ */
535
+ addListener?(type: 'focus' | 'blur', callback: () => void): () => void;
536
+ }
537
+ interface EnableDisableHandle {
538
+ /** Turn scanning on now (enable the mode, turn the camera on). */
539
+ enable(): Promise<void>;
540
+ /** Turn scanning off now (disable the mode, turn the camera off). */
541
+ disable(): Promise<void>;
542
+ }
543
+ interface UseLifecycleHookProps {
544
+ /** Navigation object (e.g. React Navigation's `navigation`) for screen focus/blur. */
545
+ navigation?: ScanditNavigationProp;
546
+ disabled?: boolean;
547
+ appStateHandlingDisabled?: boolean;
548
+ /** Called when the view should run: focused AND foregrounded AND not `disabled`. */
549
+ onEnable: () => Promise<void>;
550
+ /** Called when the view should be off: blurred, backgrounded, or `disabled`. */
551
+ onDisable: () => Promise<void>;
552
+ }
553
+ /**
554
+ * Handle modes lifetime by calling `onEnable` / `onDisable` when the navigation focus or blur event happens or AppState changes to not active.
555
+ */
556
+ declare function useLifecycleHook({ navigation, disabled, appStateHandlingDisabled, onEnable, onDisable, }: UseLifecycleHookProps): void;
557
+
558
+ interface UseCameraClaimOptions {
559
+ /**
560
+ * `'shared'`: wants the provider camera on, coexisting with other shared
561
+ * claims. `'exclusive'`: takes camera 0 for itself and forces the provider
562
+ * camera off/released for as long as this claim is active. An active
563
+ * exclusive claim always wins over any number of active shared claims.
564
+ */
565
+ mode: CameraClaimMode;
566
+ /** Declarative desired state — wire straight from the view's enable/disable. */
567
+ active: boolean;
568
+ /**
569
+ * Ref to the wrapper's Scandit view component (its React tag matches the
570
+ * `viewId` carried by the native window events). When given, the claim also
571
+ * follows the native view's window lifecycle: entering a window (re-)claims
572
+ * camera ownership if `active`, leaving it releases — covering reveals, tab
573
+ * switches and covered screens without any navigation-library coupling.
574
+ */
575
+ nativeViewRef?: React.RefObject<unknown>;
576
+ }
577
+ interface CameraClaimHandle {
578
+ /**
579
+ * Resolves once the coordinator's reconcile loop has applied the state this
580
+ * claim implies (shared → provider camera on; exclusive → provider camera
581
+ * released, this claim's native view owns camera 0). Resolves immediately
582
+ * while `active` is false — there is nothing to grant. Re-arms every call:
583
+ * awaiting it again after `active` flips true→false→true waits for the
584
+ * fresh transition, never a stale resolution.
585
+ */
586
+ granted(): Promise<void>;
587
+ /**
588
+ * Detach-time: drops the claim. `teardown`, when given, is a native-dispose
589
+ * barrier — the coordinator parks it and makes every later camera
590
+ * transition wait for it to settle (resolve OR reject) before running, so a
591
+ * popped view's async dispose can't race the next view's camera. Safe to
592
+ * call more than once; only the first call has an effect.
593
+ */
594
+ release(teardown?: Promise<unknown>): void;
595
+ }
596
+ /**
597
+ * The entire camera-ownership contract a view wrapper needs to learn. Register
598
+ * a claim and drive it declaratively via `active`; the coordinator in
599
+ * `ScanditProvider.tsx` derives the actual camera state from the full set of
600
+ * currently-registered claims (see its module doc for the derivation rules)
601
+ * and coalesces rapid changes into a single native transition.
602
+ */
603
+ declare function useCameraClaim({ mode, active, nativeViewRef }: UseCameraClaimOptions): CameraClaimHandle;
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+ type index_d_CameraClaimHandle = CameraClaimHandle;
617
+ type index_d_EnableDisableHandle = EnableDisableHandle;
618
+ type index_d_ScanditNavigationProp = ScanditNavigationProp;
619
+ type index_d_UseCameraClaimOptions = UseCameraClaimOptions;
620
+ type index_d_UseModeApi<TMode> = UseModeApi<TMode>;
621
+ type index_d_UseModeListenerProps<TMode, TListener extends object> = UseModeListenerProps<TMode, TListener>;
622
+ type index_d_UseModeOptions<TMode> = UseModeOptions<TMode>;
623
+ type index_d_UseOverlayApi<O> = UseOverlayApi<O>;
624
+ type index_d_UseOverlayOptions<O extends DataCaptureOverlay$1> = UseOverlayOptions<O>;
625
+ type index_d_ViewHandle<T> = ViewHandle<T>;
626
+ declare const index_d_useCameraClaim: typeof useCameraClaim;
627
+ declare const index_d_useDataCaptureContextInternal: typeof useDataCaptureContextInternal;
628
+ declare const index_d_useLifecycleHook: typeof useLifecycleHook;
629
+ declare const index_d_useMode: typeof useMode;
630
+ declare const index_d_useModeListener: typeof useModeListener;
631
+ declare const index_d_useNativeControl: typeof useNativeControl;
632
+ declare const index_d_useOverlay: typeof useOverlay;
633
+ declare const index_d_usePassThroughProps: typeof usePassThroughProps;
634
+ declare const index_d_useScanditInternal: typeof useScanditInternal;
635
+ declare const index_d_useStableProp: typeof useStableProp;
636
+ declare const index_d_useViewHandle: typeof useViewHandle;
637
+ declare namespace index_d {
638
+ export { index_d_useCameraClaim as useCameraClaim, index_d_useDataCaptureContextInternal as useDataCaptureContextInternal, index_d_useLifecycleHook as useLifecycleHook, index_d_useMode as useMode, index_d_useModeListener as useModeListener, index_d_useNativeControl as useNativeControl, index_d_useOverlay as useOverlay, index_d_usePassThroughProps as usePassThroughProps, index_d_useScanditInternal as useScanditInternal, index_d_useStableProp as useStableProp, index_d_useViewHandle as useViewHandle };
639
+ export type { index_d_CameraClaimHandle as CameraClaimHandle, index_d_EnableDisableHandle as EnableDisableHandle, index_d_ScanditNavigationProp as ScanditNavigationProp, index_d_UseCameraClaimOptions as UseCameraClaimOptions, index_d_UseModeApi as UseModeApi, index_d_UseModeListenerProps as UseModeListenerProps, index_d_UseModeOptions as UseModeOptions, index_d_UseOverlayApi as UseOverlayApi, index_d_UseOverlayOptions as UseOverlayOptions, index_d_ViewHandle as ViewHandle };
640
+ }
641
+
642
+ interface ScanditNativeModule extends NativeModule {
643
+ [key: string]: any;
644
+ }
645
+ declare function getNativeModule(name: string): ScanditNativeModule;
646
+ declare function getModuleDefaults(name: string): any;
647
+
648
+ declare class RNNativeCaller implements NativeCaller {
649
+ private nativeModule;
650
+ private _nativeEventEmitter;
651
+ constructor(nativeModule: ScanditNativeModule);
652
+ /**
653
+ * Lazily creates the NativeEventEmitter only when needed (old architecture fallback).
654
+ * Avoids the "NativeEventEmitter was called with a non-null argument without the
655
+ * required addListener method" warning that fires when eagerly constructing the
656
+ * emitter for TurboModule-based native modules.
657
+ */
658
+ private get nativeEventEmitter();
659
+ get framework(): string;
660
+ get frameworkVersion(): string;
661
+ callFn(fnName: string, args: object | undefined | null, _meta?: {
662
+ isEventRegistration?: boolean;
663
+ }): Promise<any>;
664
+ registerEvent(evName: string, handler: (args: any) => Promise<void>): Promise<any>;
665
+ unregisterEvent(evName: string, subscription: any): Promise<void>;
666
+ eventHook(args: any): any;
667
+ }
668
+ declare function createRNNativeCaller(nativeModule: ScanditNativeModule): RNNativeCaller;
669
+
670
+ export { DataCaptureVersion, RNNativeCaller, ScanditProvider, index_d as _internal, createRNNativeCaller, getModuleDefaults, getNativeModule, initCoreDefaults, initCoreProxy, useCameraPermission, useIsForeground, useScanditContext };
671
+ export type { DataCaptureViewListener, ScanditNativeModule, ScanditProviderProps };
672
+ export { DataCaptureView };