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