scandit-react-native-datacapture-core 8.4.1 → 8.5.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.
- package/THIRD_PARTY.txt +0 -5
- package/android/build.gradle +3 -3
- package/android/generated/jni/CMakeLists.txt +21 -1
- package/dist/core.js +1581 -1545
- package/dist/core.js.map +1 -1
- package/dist/dts/hooks/ScanditProvider.d.ts +46 -0
- package/dist/dts/hooks/index.d.ts +5 -0
- package/dist/dts/hooks/useCameraPermission.d.ts +28 -0
- package/dist/dts/hooks/useIsForeground.d.ts +11 -0
- package/dist/dts/hooks/useScanditContext.d.ts +21 -0
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/native/ScanditNativeModule.d.ts +1 -1
- package/dist/dts/private/hooks/useMode.d.ts +49 -0
- package/dist/dts/private/hooks/useModeListener.d.ts +40 -0
- package/dist/dts/private/hooks/useNativeControl.d.ts +14 -0
- package/dist/dts/private/hooks/useOverlay.d.ts +68 -0
- package/dist/dts/private/hooks/useStableProp.d.ts +22 -0
- package/dist/dts/private/hooks/useViewHandle.d.ts +41 -0
- package/dist/dts/private/index.d.ts +11 -0
- package/dist/index.js +737 -6
- package/dist/index.js.flow +4 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/scandit-react-native-datacapture-core.podspec +1 -1
- package/specs/NativeScanditDataCaptureCore.ts +2 -3
- package/specs/RNTDataCaptureViewNativeComponent.ts +1 -4
- package/THIRD_PARTY_ID.txt +0 -545
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CameraPosition, DataCaptureContext, DataCaptureContextCreationOptions, DataCaptureContextSettings, FrameSourceState, TorchState } from 'scandit-datacapture-frameworks-core';
|
|
3
|
+
type CameraProps = {
|
|
4
|
+
frameSourceState?: FrameSourceState;
|
|
5
|
+
torchState?: TorchState;
|
|
6
|
+
cameraPosition?: CameraPosition;
|
|
7
|
+
};
|
|
8
|
+
export type ScanditProviderProps = CameraProps & {
|
|
9
|
+
/** Required on the root provider. Ignored (with a warning) on nested ones. */
|
|
10
|
+
licenseKey?: string;
|
|
11
|
+
/** Only used on the root provider. */
|
|
12
|
+
options?: DataCaptureContextCreationOptions;
|
|
13
|
+
/** Only used on the root provider. */
|
|
14
|
+
settings?: DataCaptureContextSettings;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Provides a `DataCaptureContext` and a singleton `Camera` to descendant AIO views.
|
|
19
|
+
*
|
|
20
|
+
* - **Root** (no parent `<ScanditProvider>` above): creates the context + camera,
|
|
21
|
+
* disposes them on unmount.
|
|
22
|
+
* - **Nested**: applies its own `frameSourceState` / `torchState` / `cameraPosition`
|
|
23
|
+
* props to the same singleton camera. Last writer wins; values are not reverted
|
|
24
|
+
* when a nested provider unmounts.
|
|
25
|
+
*
|
|
26
|
+
* The camera is recreated only when `cameraPosition` flips; torch and
|
|
27
|
+
* `frameSourceState` are applied directly to the live camera.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <ScanditProvider licenseKey={KEY}>
|
|
31
|
+
* <NavigationContainer> ... </NavigationContainer>
|
|
32
|
+
* </ScanditProvider>
|
|
33
|
+
*
|
|
34
|
+
* // Screen-local control:
|
|
35
|
+
* <ScanditProvider
|
|
36
|
+
* frameSourceState={isFocused ? FrameSourceState.On : FrameSourceState.Off}
|
|
37
|
+
* torchState={torch}
|
|
38
|
+
* cameraPosition={position}>
|
|
39
|
+
* <BarcodeCaptureView state="enabled" ... />
|
|
40
|
+
* </ScanditProvider>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function ScanditProvider(props: ScanditProviderProps): React.JSX.Element;
|
|
44
|
+
/** Internal — used by AIO views to attach modes to the shared context. */
|
|
45
|
+
export declare function useDataCaptureContextInternal(): DataCaptureContext;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useIsForeground } from './useIsForeground';
|
|
2
|
+
export { useCameraPermission } from './useCameraPermission';
|
|
3
|
+
export { useScanditContext } from './useScanditContext';
|
|
4
|
+
export { ScanditProvider } from './ScanditProvider';
|
|
5
|
+
export type { ScanditProviderProps } from './ScanditProvider';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type PermissionStatus = 'granted' | 'denied' | 'not-determined' | 'restricted';
|
|
2
|
+
interface CameraPermissionResult {
|
|
3
|
+
hasPermission: boolean;
|
|
4
|
+
permissionStatus: PermissionStatus;
|
|
5
|
+
requestPermission: () => Promise<boolean>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manages camera permission status.
|
|
9
|
+
*
|
|
10
|
+
* **Android**: real status via `PermissionsAndroid`; `requestPermission()` shows the native
|
|
11
|
+
* prompt; status re-checked when the app returns to the foreground (e.g. user flipped it
|
|
12
|
+
* in Settings).
|
|
13
|
+
*
|
|
14
|
+
* **iOS**: limited. Without a platform-specific native module we can't query
|
|
15
|
+
* `AVCaptureDevice.authorizationStatus` or drive the system prompt directly — iOS
|
|
16
|
+
* handles the permission dialog automatically the first time the camera is accessed.
|
|
17
|
+
* On iOS this hook returns `permissionStatus: 'not-determined'` initially and
|
|
18
|
+
* optimistically flips to `'granted'` after `requestPermission()` is called.
|
|
19
|
+
* It cannot detect denials after-the-fact; consumers should treat the iOS camera-start
|
|
20
|
+
* flow as the authoritative signal (surfaced via `<BarcodeCaptureView onError={...} />`).
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { hasPermission, requestPermission } = useCameraPermission();
|
|
24
|
+
* if (!hasPermission) return <Button onPress={requestPermission} title="Grant Camera Access" />;
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useCameraPermission(): CameraPermissionResult;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether the app is currently in the foreground.
|
|
3
|
+
* Useful for composing the `isActive` prop on scanning views:
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* const isForeground = useIsForeground();
|
|
7
|
+
* const isFocused = useIsFocused(); // from @react-navigation/native
|
|
8
|
+
* <BarcodeCaptureView isActive={isFocused && isForeground} ... />
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function useIsForeground(): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataCaptureContext, DataCaptureContextCreationOptions, DataCaptureContextSettings } from 'scandit-datacapture-frameworks-core';
|
|
2
|
+
interface UseScanditContextOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Applied at first render, then re-applied via `context.applySettings(...)`
|
|
5
|
+
* whenever the reference changes. Memoize this with `useMemo` (or build it
|
|
6
|
+
* once) — passing a fresh instance every render will spam `applySettings`.
|
|
7
|
+
*/
|
|
8
|
+
settings?: DataCaptureContextSettings;
|
|
9
|
+
/** Applied once at native initialization. Later changes are ignored. */
|
|
10
|
+
creationOptions?: DataCaptureContextCreationOptions;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Initializes (or retrieves) the DataCaptureContext singleton.
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const settings = useMemo(() => new DataCaptureContextSettings(), []);
|
|
17
|
+
* const context = useScanditContext('YOUR_LICENSE_KEY', { settings });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function useScanditContext(licenseKey: string, options?: UseScanditContextOptions): DataCaptureContext;
|
|
21
|
+
export {};
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export { Anchor } from 'scandit-datacapture-frameworks-core';
|
|
|
21
21
|
export { Orientation } from 'scandit-datacapture-frameworks-core';
|
|
22
22
|
export { Direction } from 'scandit-datacapture-frameworks-core';
|
|
23
23
|
export { ScanIntention } from 'scandit-datacapture-frameworks-core';
|
|
24
|
+
export { SelectionMode } from 'scandit-datacapture-frameworks-core';
|
|
24
25
|
export { ClusteringMode } from 'scandit-datacapture-frameworks-core';
|
|
25
26
|
export { Control } from 'scandit-datacapture-frameworks-core';
|
|
26
27
|
export { ZoomSwitchControl } from 'scandit-datacapture-frameworks-core';
|
|
@@ -88,5 +89,8 @@ export { ScanditIcon } from 'scandit-datacapture-frameworks-core';
|
|
|
88
89
|
export { ScanditIconShape } from 'scandit-datacapture-frameworks-core';
|
|
89
90
|
export { ScanditIconType } from 'scandit-datacapture-frameworks-core';
|
|
90
91
|
export { ScanditIconBuilder } from 'scandit-datacapture-frameworks-core';
|
|
92
|
+
export * from './hooks';
|
|
93
|
+
import * as _internal from './private/index';
|
|
94
|
+
export { _internal };
|
|
91
95
|
export * from './native/RNNativeCaller';
|
|
92
96
|
export * from './native/ScanditNativeModule';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DependencyList, MutableRefObject } from 'react';
|
|
2
|
+
export type ModeLifecycleState = 'enabled' | 'disabled' | 'detached';
|
|
3
|
+
/**
|
|
4
|
+
* Minimal shape of an overlay (or any resource) `useMode` can orchestrate.
|
|
5
|
+
* Matches `UseOverlayApi` — `useOverlay` returns objects assignable to this.
|
|
6
|
+
*/
|
|
7
|
+
export interface ModeAttachable {
|
|
8
|
+
attach: () => void | Promise<void>;
|
|
9
|
+
detach: () => void | Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export interface UseModeOptions<TMode> {
|
|
12
|
+
state: ModeLifecycleState;
|
|
13
|
+
createMode: () => TMode;
|
|
14
|
+
applySettings: (mode: TMode) => void | Promise<void>;
|
|
15
|
+
setEnabled: (mode: TMode, enabled: boolean) => void;
|
|
16
|
+
attach: (mode: TMode) => void | Promise<void>;
|
|
17
|
+
detach: (mode: TMode) => void | Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Resources attached/detached in lockstep with the mode. Each is `attach()`-ed
|
|
20
|
+
* after the consumer's `attach(mode)` resolves (in declaration order), and
|
|
21
|
+
* `detach()`-ed before the consumer's `detach(mode)` is called (in reverse
|
|
22
|
+
* order). Designed for the `UseOverlayApi` returned by `useOverlay`.
|
|
23
|
+
*/
|
|
24
|
+
attachables?: ReadonlyArray<ModeAttachable>;
|
|
25
|
+
/** Gate attach on external readiness (e.g. native view node mounted). Defaults to true. */
|
|
26
|
+
canAttach?: boolean;
|
|
27
|
+
/** Re-apply settings when any of these change (and the mode is attached). */
|
|
28
|
+
settingsDeps: DependencyList;
|
|
29
|
+
}
|
|
30
|
+
export interface UseModeApi<TMode> {
|
|
31
|
+
/** Lazy accessor. Creates the mode on first call; nulled out after detach. */
|
|
32
|
+
getMode: () => TMode;
|
|
33
|
+
/** Read-only view of the underlying ref. Null when no mode currently exists. */
|
|
34
|
+
modeRef: MutableRefObject<TMode | null>;
|
|
35
|
+
/** True while the mode is currently attached. */
|
|
36
|
+
isAttached: () => boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Mode-lifetime state machine shared by SDK view components.
|
|
40
|
+
*
|
|
41
|
+
* Owns: lazy mode creation, attach/detach transitions driven by `state`,
|
|
42
|
+
* `isEnabled` flips on `enabled`↔`disabled`, settings reapply on dep change,
|
|
43
|
+
* and detach-on-unmount.
|
|
44
|
+
*
|
|
45
|
+
* Side-effecting callbacks (`attach`, `detach`, `applySettings`, `setEnabled`,
|
|
46
|
+
* `createMode`) are read through a ref, so callers can pass closures without
|
|
47
|
+
* memoizing — only `state`, `canAttach`, and `settingsDeps` drive effects.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useMode<TMode>(options: UseModeOptions<TMode>): UseModeApi<TMode>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type UseModeListenerProps<TMode, TListener extends object> = {
|
|
2
|
+
mode: TMode | null;
|
|
3
|
+
listenerFns: TListener;
|
|
4
|
+
addListener: (mode: TMode, listener: TListener) => void;
|
|
5
|
+
removeListener: (mode: TMode, listener: TListener) => void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Registers a listener on a Scandit mode or view and keeps it up to date.
|
|
9
|
+
*
|
|
10
|
+
* Pass `listenerFns` with the callbacks you care about and leave the rest
|
|
11
|
+
* `undefined`. The hook only registers when `mode` is non-null and at least
|
|
12
|
+
* one callback is set; it unregisters automatically on unmount or when those
|
|
13
|
+
* conditions stop being true.
|
|
14
|
+
*
|
|
15
|
+
* The proxy installed on the target contains methods **only for keys whose
|
|
16
|
+
* values are currently defined**. This matters because some shared
|
|
17
|
+
* controllers do `if (listener.foo)` truthy checks (e.g.
|
|
18
|
+
* `BarcodeBatchBasicOverlayController.handleBrushForTrackedBarcode`) and a
|
|
19
|
+
* proxy method that returns `undefined` is interpreted as a real `null`
|
|
20
|
+
* response by the bridge — which wipes the configured default brush. When
|
|
21
|
+
* the set of defined keys changes (a callback flips between defined and
|
|
22
|
+
* undefined across renders), the proxy is rebuilt and the listener is
|
|
23
|
+
* unregistered + re-registered.
|
|
24
|
+
*
|
|
25
|
+
* Inline functions are fine — within the "defined" set, the registered
|
|
26
|
+
* listener is a stable proxy that always dispatches to the latest version of
|
|
27
|
+
* each callback without re-registering.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* useModeListener<BarcodeCapture, BarcodeCaptureListener>({
|
|
31
|
+
* mode,
|
|
32
|
+
* listenerFns: {
|
|
33
|
+
* didScan: onScan ? async (_c, session, getFD) => onScan(session, getFD) : undefined,
|
|
34
|
+
* },
|
|
35
|
+
* addListener: (m, l) => m.addListener(l),
|
|
36
|
+
* removeListener: (m, l) => m.removeListener(l),
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useModeListener<TMode, TListener extends object>({ mode, listenerFns, addListener, removeListener, }: UseModeListenerProps<TMode, TListener>): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ControlHost<C> {
|
|
2
|
+
addControl: (control: C) => Promise<void> | void;
|
|
3
|
+
removeControl: (control: C) => Promise<void> | void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Adds `control` to `view` while both are present and the control reference is
|
|
7
|
+
* stable. Removes the control on unmount or when either reference changes.
|
|
8
|
+
*
|
|
9
|
+
* The view is typically a `DataCaptureView` and the control is a Scandit
|
|
10
|
+
* `Control` (e.g. `TorchSwitchControl`, `ZoomSwitchControl`). Pair this with
|
|
11
|
+
* `useStableProp(control)` at the call site so inline `new XControl()`
|
|
12
|
+
* instantiation doesn't churn add/remove.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useNativeControl<V extends ControlHost<C>, C>(view: V | null, control: C | null | undefined): void;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { DependencyList, MutableRefObject } from 'react';
|
|
2
|
+
import { DataCaptureOverlay } from 'scandit-datacapture-frameworks-core';
|
|
3
|
+
import type { DataCaptureView } from '../../DataCaptureView';
|
|
4
|
+
export interface UseOverlayOptions<O extends DataCaptureOverlay> {
|
|
5
|
+
/**
|
|
6
|
+
* Ref to the underlying `DataCaptureView`. The overlay is added the first
|
|
7
|
+
* time `attach()` is called with `view.current` non-null.
|
|
8
|
+
*/
|
|
9
|
+
view: MutableRefObject<DataCaptureView | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the overlay should be attached. Defaults to `true`. Toggling at
|
|
12
|
+
* runtime triggers a detach/re-attach while the mode is otherwise attached.
|
|
13
|
+
*/
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Build the overlay. Re-invoked whenever `factoryDeps` change while the
|
|
17
|
+
* overlay is attached — the old overlay is removed and the new one added,
|
|
18
|
+
* preserving order with respect to `useMode`'s lifecycle.
|
|
19
|
+
*/
|
|
20
|
+
factory: () => O;
|
|
21
|
+
/**
|
|
22
|
+
* Deps that trigger a recreate (`removeOverlay` → `factory()` → `addOverlay`).
|
|
23
|
+
* Use for constructor-time props (e.g. overlay style). Defaults to `[]`.
|
|
24
|
+
*/
|
|
25
|
+
factoryDeps?: DependencyList;
|
|
26
|
+
/**
|
|
27
|
+
* Apply mutable state to the overlay (brushes, viewfinder, scan-area guides).
|
|
28
|
+
* Runs once after attach and whenever `updateDeps` change while attached.
|
|
29
|
+
*/
|
|
30
|
+
update?: (overlay: O) => void;
|
|
31
|
+
/** Deps that re-trigger `update`. Defaults to `[]`. */
|
|
32
|
+
updateDeps?: DependencyList;
|
|
33
|
+
}
|
|
34
|
+
export interface UseOverlayApi<O> {
|
|
35
|
+
/**
|
|
36
|
+
* Reactive overlay snapshot. `null` until attached and again after detach
|
|
37
|
+
* (and momentarily during a `factoryDeps`-driven recreate). Pass to
|
|
38
|
+
* `useModeListener` as the `mode` field so listener registration follows
|
|
39
|
+
* the overlay lifecycle.
|
|
40
|
+
*/
|
|
41
|
+
overlay: O | null;
|
|
42
|
+
/** Non-reactive accessor for imperative reads. */
|
|
43
|
+
getOverlay: () => O | null;
|
|
44
|
+
/** Add the overlay to the view. Idempotent. Call from `useMode.attachables`. */
|
|
45
|
+
attach: () => Promise<void>;
|
|
46
|
+
/** Remove the overlay from the view. Idempotent. Call from `useMode.attachables`. */
|
|
47
|
+
detach: () => Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Lifecycle helper for `DataCaptureView` overlays. Pass the returned value into
|
|
51
|
+
* `useMode({ attachables: [...] })` — `useMode` orders `attach()` after the
|
|
52
|
+
* mode is added to the context and `detach()` before it's removed.
|
|
53
|
+
*
|
|
54
|
+
* Listener registration is not handled here; pair with `useModeListener`
|
|
55
|
+
* keyed on the reactive `overlay` snapshot:
|
|
56
|
+
*
|
|
57
|
+
* ```tsx
|
|
58
|
+
* const basicOverlay = useOverlay<BarcodeBatchBasicOverlay>({ ... });
|
|
59
|
+
*
|
|
60
|
+
* useModeListener<BarcodeBatchBasicOverlay, BarcodeBatchBasicOverlayListener>({
|
|
61
|
+
* mode: basicOverlay.overlay,
|
|
62
|
+
* listenerFns: { brushForTrackedBarcode, didTapTrackedBarcode },
|
|
63
|
+
* addListener: (o, l) => { o.listener = l; },
|
|
64
|
+
* removeListener: o => { o.listener = null; },
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function useOverlay<O extends DataCaptureOverlay>(opts: UseOverlayOptions<O>): UseOverlayApi<O>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a referentially-stable copy of `value` as long as the structural
|
|
3
|
+
* content stays the same. Lets consumers pass inline SDK class instances
|
|
4
|
+
* (`new Brush(...)`, `new TorchSwitchControl()`) or plain options objects
|
|
5
|
+
* without memoizing — the effect deps array sees the same reference until
|
|
6
|
+
* the underlying content actually changes.
|
|
7
|
+
*
|
|
8
|
+
* SDK classes that extend `DefaultSerializeable` are compared via their
|
|
9
|
+
* `toJson()` output (which respects `@ignoreFromSerialization`), so private
|
|
10
|
+
* back-refs like `view` don't cause spurious diffs. Plain objects and arrays
|
|
11
|
+
* are compared via direct `JSON.stringify`.
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* function MyView({ brush }: { brush?: Brush | null }) {
|
|
15
|
+
* const stableBrush = useStableProp(brush);
|
|
16
|
+
* useEffect(() => {
|
|
17
|
+
* if (stableBrush) overlay.brush = stableBrush;
|
|
18
|
+
* }, [stableBrush]);
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function useStableProp<T>(value: T): T;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type ViewHandle<T> = {
|
|
2
|
+
/**
|
|
3
|
+
* Ref callback to pass to the view. Updates both the internal mutable ref
|
|
4
|
+
* and the reactive state so effects can depend on the view being mounted.
|
|
5
|
+
*/
|
|
6
|
+
ref: (v: T | null) => void;
|
|
7
|
+
/** Latest view instance for use inside effects/deps. */
|
|
8
|
+
current: T | null;
|
|
9
|
+
/** Same value as `current`, exposed as the mutable ref consumers also rely on. */
|
|
10
|
+
mutableRef: React.MutableRefObject<T | null>;
|
|
11
|
+
/** Stable random id used by views that need a parent-id linkage to native serialization. */
|
|
12
|
+
id: number;
|
|
13
|
+
/**
|
|
14
|
+
* `onLayout` handler to pass to the native component. Fires when the view is
|
|
15
|
+
* laid out (committed to the native tree), at which point `findNodeHandle`
|
|
16
|
+
* returns a valid handle. This is the signal `whenReady` resolves on.
|
|
17
|
+
*/
|
|
18
|
+
onLayout: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the first time the native view is laid out. Use this to gate
|
|
21
|
+
* native-view creation instead of `InteractionManager.runAfterInteractions`:
|
|
22
|
+
* layout is not starvable by a blocked JS interaction queue (e.g. a looping
|
|
23
|
+
* animation with `useNativeDriver: false`), which would otherwise leave the
|
|
24
|
+
* preview view never created. See SDC-32208.
|
|
25
|
+
*
|
|
26
|
+
* Callers that await `whenReady()` MUST also wire `onLayout` onto the mounted
|
|
27
|
+
* native component — otherwise the promise never resolves.
|
|
28
|
+
*/
|
|
29
|
+
whenReady: () => Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Bundles the `ref + viewState + viewId` pattern that AIO views share.
|
|
33
|
+
*
|
|
34
|
+
* - The returned `ref` is stable across renders.
|
|
35
|
+
* - `current` is a reactive snapshot — effects keyed on it re-run when the
|
|
36
|
+
* view mounts/unmounts. `mutableRef` exposes the same value for imperative
|
|
37
|
+
* reads that must not trigger re-renders.
|
|
38
|
+
* - `id` is generated once per hook instance and stays stable for the lifetime
|
|
39
|
+
* of the component, suitable for `parentId` serialization.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useViewHandle<T>(): ViewHandle<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { useDataCaptureContextInternal } from '../hooks/ScanditProvider';
|
|
2
|
+
export { useStableProp } from './hooks/useStableProp';
|
|
3
|
+
export { useModeListener } from './hooks/useModeListener';
|
|
4
|
+
export type { UseModeListenerProps } from './hooks/useModeListener';
|
|
5
|
+
export { useViewHandle } from './hooks/useViewHandle';
|
|
6
|
+
export type { ViewHandle } from './hooks/useViewHandle';
|
|
7
|
+
export { useNativeControl } from './hooks/useNativeControl';
|
|
8
|
+
export { useMode } from './hooks/useMode';
|
|
9
|
+
export type { ModeLifecycleState, UseModeOptions, UseModeApi } from './hooks/useMode';
|
|
10
|
+
export { useOverlay } from './hooks/useOverlay';
|
|
11
|
+
export type { UseOverlayOptions, UseOverlayApi } from './hooks/useOverlay';
|