@ankhorage/expo-runtime 6.0.3 → 7.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ankhorage/expo-runtime
2
2
 
3
+ ## 7.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - a930f62: Align the barcode scanner adapter with ZORA 25 and forward scan callbacks directly to Expo Camera.
8
+
3
9
  ## 6.0.3
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # EXPO-RUNTIME
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v6.0.3](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v7.0.0](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
7
7
 
8
8
  Declarative runtime integration for Expo apps: maps app capabilities to permissions, packages, config plugins, providers, and adapters
9
9
 
@@ -1,4 +1,9 @@
1
1
  import { type BarcodeScannerViewProps } from '@ankhorage/zora';
2
+ import { type CameraViewProps } from 'expo-camera';
2
3
  import React from 'react';
3
- export declare function ExpoBarcodeScannerAdapter(props: BarcodeScannerViewProps): React.JSX.Element;
4
+ export interface ExpoBarcodeScannerAdapterProps extends BarcodeScannerViewProps {
5
+ readonly onBarcodeScanned?: CameraViewProps['onBarcodeScanned'];
6
+ }
7
+ /*** Renders the ZORA scanner surface with Expo Camera and its native scan callback. */
8
+ export declare function ExpoBarcodeScannerAdapter(props: ExpoBarcodeScannerAdapterProps): React.JSX.Element;
4
9
  //# sourceMappingURL=ExpoBarcodeScannerAdapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoBarcodeScannerAdapter.d.ts","sourceRoot":"","sources":["../src/ExpoBarcodeScannerAdapter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,qBAqDvE"}
1
+ {"version":3,"file":"ExpoBarcodeScannerAdapter.d.ts","sourceRoot":"","sources":["../src/ExpoBarcodeScannerAdapter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAgC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,WAAW,8BAA+B,SAAQ,uBAAuB;IAC7E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CACjE;AAED,uFAAuF;AACvF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,8BAA8B,qBAqC9E"}
@@ -3,13 +3,13 @@ import { BarcodeScannerView } from '@ankhorage/zora';
3
3
  import { CameraView } from 'expo-camera';
4
4
  import React from 'react';
5
5
  import { StyleSheet } from 'react-native';
6
- import { BARCODE_SCANNER_TYPES, dispatchExpoBarcodeScan, mapPermissionStatusToCameraPermissionStatus, } from './barcodeScanRuntime';
6
+ import { BARCODE_SCANNER_TYPES, mapPermissionStatusToCameraPermissionStatus, } from './barcodeScanRuntime';
7
7
  const CAMERA_BARCODE_TYPES = [...BARCODE_SCANNER_TYPES];
8
+ /*** Renders the ZORA scanner surface with Expo Camera and its native scan callback. */
8
9
  export function ExpoBarcodeScannerAdapter(props) {
9
10
  const { onBarcodeScanned, onRequestPermission, ...viewProps } = props;
10
11
  const cameraPermission = usePermission(Permission.Camera);
11
12
  const [isRequestingPermission, setIsRequestingPermission] = React.useState(false);
12
- const lastScanRef = React.useRef(null);
13
13
  const permissionStatus = mapPermissionStatusToCameraPermissionStatus(cameraPermission.status, isRequestingPermission);
14
14
  const handleRequestPermission = React.useCallback(async () => {
15
15
  setIsRequestingPermission(true);
@@ -21,12 +21,7 @@ export function ExpoBarcodeScannerAdapter(props) {
21
21
  setIsRequestingPermission(false);
22
22
  }
23
23
  }, [cameraPermission, onRequestPermission]);
24
- const handleBarcodeScanned = React.useCallback((result) => {
25
- void dispatchExpoBarcodeScan(result, lastScanRef.current, Date.now(), onBarcodeScanned, (record) => {
26
- lastScanRef.current = record;
27
- });
28
- }, [onBarcodeScanned]);
29
- const camera = permissionStatus === 'granted' ? (<CameraView barcodeScannerSettings={{ barcodeTypes: CAMERA_BARCODE_TYPES }} onBarcodeScanned={handleBarcodeScanned} style={styles.camera}/>) : undefined;
24
+ const camera = permissionStatus === 'granted' ? (<CameraView barcodeScannerSettings={{ barcodeTypes: CAMERA_BARCODE_TYPES }} onBarcodeScanned={onBarcodeScanned} style={styles.camera}/>) : undefined;
30
25
  return (<BarcodeScannerView {...viewProps} camera={camera} onRequestPermission={handleRequestPermission} permissionStatus={permissionStatus}/>);
31
26
  }
32
27
  const styles = StyleSheet.create({
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoBarcodeScannerAdapter.js","sourceRoot":"","sources":["../src/ExpoBarcodeScannerAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAgC,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAgD,UAAU,EAAE,MAAM,aAAa,CAAC;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ACT,WAAW,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,CAAC,CACF,CAAC;IACJ,CAAC,EACD,CAAC,gBAAgB,CAAC,CACnB,CAAC;IAEF,MAAM,MAAM,GACV,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,CAC/B,CAAC,UAAU,CACT,sBAAsB,CAAC,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC,CAC/D,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CACvC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EACrB,CACH,CAAC,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,CACL,CAAC,kBAAkB,CACjB,IAAI,SAAS,CAAC,CACd,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,mBAAmB,CAAC,CAAC,uBAAuB,CAAC,CAC7C,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,EACnC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC","sourcesContent":["import { Permission, usePermission } from '@ankhorage/permissions';\nimport { BarcodeScannerView, type BarcodeScannerViewProps } from '@ankhorage/zora';\nimport { type BarcodeScanningResult, type BarcodeType, CameraView } from 'expo-camera';\nimport React from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport {\n BARCODE_SCANNER_TYPES,\n type BarcodeScanRecord,\n dispatchExpoBarcodeScan,\n mapPermissionStatusToCameraPermissionStatus,\n} from './barcodeScanRuntime';\n\nconst CAMERA_BARCODE_TYPES: BarcodeType[] = [...BARCODE_SCANNER_TYPES];\n\nexport function ExpoBarcodeScannerAdapter(props: BarcodeScannerViewProps) {\n const { onBarcodeScanned, onRequestPermission, ...viewProps } = props;\n const cameraPermission = usePermission(Permission.Camera);\n const [isRequestingPermission, setIsRequestingPermission] = React.useState(false);\n const lastScanRef = React.useRef<BarcodeScanRecord | null>(null);\n\n const permissionStatus = mapPermissionStatusToCameraPermissionStatus(\n cameraPermission.status,\n isRequestingPermission,\n );\n\n const handleRequestPermission = React.useCallback(async () => {\n setIsRequestingPermission(true);\n try {\n await cameraPermission.request();\n await onRequestPermission?.();\n } finally {\n setIsRequestingPermission(false);\n }\n }, [cameraPermission, onRequestPermission]);\n\n const handleBarcodeScanned = React.useCallback(\n (result: BarcodeScanningResult) => {\n void dispatchExpoBarcodeScan(\n result,\n lastScanRef.current,\n Date.now(),\n onBarcodeScanned,\n (record) => {\n lastScanRef.current = record;\n },\n );\n },\n [onBarcodeScanned],\n );\n\n const camera =\n permissionStatus === 'granted' ? (\n <CameraView\n barcodeScannerSettings={{ barcodeTypes: CAMERA_BARCODE_TYPES }}\n onBarcodeScanned={handleBarcodeScanned}\n style={styles.camera}\n />\n ) : undefined;\n\n return (\n <BarcodeScannerView\n {...viewProps}\n camera={camera}\n onRequestPermission={handleRequestPermission}\n permissionStatus={permissionStatus}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n camera: {\n flex: 1,\n },\n});\n"]}
1
+ {"version":3,"file":"ExpoBarcodeScannerAdapter.js","sourceRoot":"","sources":["../src/ExpoBarcodeScannerAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAgC,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAoB,UAAU,EAAwB,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EACL,qBAAqB,EACrB,2CAA2C,GAC5C,MAAM,sBAAsB,CAAC;AAE9B,MAAM,oBAAoB,GAAkB,CAAC,GAAG,qBAAqB,CAAC,CAAC;AAMvE,uFAAuF;AACvF,MAAM,UAAU,yBAAyB,CAAC,KAAqC;IAC7E,MAAM,EAAE,gBAA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;CACF,CAAC,CAAC","sourcesContent":["import { Permission, usePermission } from '@ankhorage/permissions';\nimport { BarcodeScannerView, type BarcodeScannerViewProps } from '@ankhorage/zora';\nimport { type BarcodeType, CameraView, type CameraViewProps } from 'expo-camera';\nimport React from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport {\n BARCODE_SCANNER_TYPES,\n mapPermissionStatusToCameraPermissionStatus,\n} from './barcodeScanRuntime';\n\nconst CAMERA_BARCODE_TYPES: BarcodeType[] = [...BARCODE_SCANNER_TYPES];\n\nexport interface ExpoBarcodeScannerAdapterProps extends BarcodeScannerViewProps {\n readonly onBarcodeScanned?: CameraViewProps['onBarcodeScanned'];\n}\n\n/*** Renders the ZORA scanner surface with Expo Camera and its native scan callback. */\nexport function ExpoBarcodeScannerAdapter(props: ExpoBarcodeScannerAdapterProps) {\n const { onBarcodeScanned, onRequestPermission, ...viewProps } = props;\n const cameraPermission = usePermission(Permission.Camera);\n const [isRequestingPermission, setIsRequestingPermission] = React.useState(false);\n\n const permissionStatus = mapPermissionStatusToCameraPermissionStatus(\n cameraPermission.status,\n isRequestingPermission,\n );\n\n const handleRequestPermission = React.useCallback(async () => {\n setIsRequestingPermission(true);\n try {\n await cameraPermission.request();\n await onRequestPermission?.();\n } finally {\n setIsRequestingPermission(false);\n }\n }, [cameraPermission, onRequestPermission]);\n\n const camera =\n permissionStatus === 'granted' ? (\n <CameraView\n barcodeScannerSettings={{ barcodeTypes: CAMERA_BARCODE_TYPES }}\n onBarcodeScanned={onBarcodeScanned}\n style={styles.camera}\n />\n ) : undefined;\n\n return (\n <BarcodeScannerView\n {...viewProps}\n camera={camera}\n onRequestPermission={handleRequestPermission}\n permissionStatus={permissionStatus}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n camera: {\n flex: 1,\n },\n});\n"]}
@@ -1,18 +1,6 @@
1
1
  import type { PermissionStatus } from '@ankhorage/permissions';
2
- import type { BarcodeScanResult, CameraPermissionStatus } from '@ankhorage/zora';
3
- export declare const BARCODE_SCAN_DEDUPE_WINDOW_MS = 1500;
2
+ import type { CameraPermissionStatus } from '@ankhorage/zora';
4
3
  export declare const BARCODE_SCANNER_TYPES: readonly ["aztec", "codabar", "code39", "code93", "code128", "datamatrix", "ean13", "ean8", "itf14", "pdf417", "qr", "upc_a", "upc_e"];
5
- export interface BarcodeScanRecord extends BarcodeScanResult {
6
- readonly timestamp: number;
7
- }
8
- export interface ExpoBarcodeScanResultLike {
9
- readonly data: string;
10
- readonly type?: string;
11
- }
12
- type ExpoBarcodeScanCallback = (result: BarcodeScanResult) => Promise<void> | void;
4
+ /*** Maps the Permissions owner status to ZORA's documented camera UI status. */
13
5
  export declare function mapPermissionStatusToCameraPermissionStatus(status: PermissionStatus, isRequestingPermission: boolean): CameraPermissionStatus;
14
- export declare function normalizeExpoBarcodeScanResult(result: ExpoBarcodeScanResultLike): BarcodeScanResult | null;
15
- export declare function shouldIgnoreBarcodeScan(previous: BarcodeScanRecord | null, next: BarcodeScanResult, now: number): boolean;
16
- export declare function dispatchExpoBarcodeScan(result: ExpoBarcodeScanResultLike, previous: BarcodeScanRecord | null, now: number, onBarcodeScanned: ExpoBarcodeScanCallback | undefined, onAccepted: (record: BarcodeScanRecord) => void): Promise<boolean>;
17
- export {};
18
6
  //# sourceMappingURL=barcodeScanRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"barcodeScanRuntime.d.ts","sourceRoot":"","sources":["../src/barcodeScanRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGjF,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,eAAO,MAAM,qBAAqB,wIAcS,CAAC;AAE5C,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEnF,wBAAgB,2CAA2C,CACzD,MAAM,EAAE,gBAAgB,EACxB,sBAAsB,EAAE,OAAO,GAC9B,sBAAsB,CAaxB;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,yBAAyB,GAChC,iBAAiB,GAAG,IAAI,CAY1B;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,EAClC,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,MAAM,GACV,OAAO,CAUT;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,yBAAyB,EACjC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,EAClC,GAAG,EAAE,MAAM,EACX,gBAAgB,EAAE,uBAAuB,GAAG,SAAS,EACrD,UAAU,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAC9C,OAAO,CAAC,OAAO,CAAC,CAalB"}
1
+ {"version":3,"file":"barcodeScanRuntime.d.ts","sourceRoot":"","sources":["../src/barcodeScanRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG9D,eAAO,MAAM,qBAAqB,wIAcS,CAAC;AAE5C,gFAAgF;AAChF,wBAAgB,2CAA2C,CACzD,MAAM,EAAE,gBAAgB,EACxB,sBAAsB,EAAE,OAAO,GAC9B,sBAAsB,CAaxB"}
@@ -1,4 +1,3 @@
1
- export const BARCODE_SCAN_DEDUPE_WINDOW_MS = 1500;
2
1
  export const BARCODE_SCANNER_TYPES = [
3
2
  'aztec',
4
3
  'codabar',
@@ -14,6 +13,7 @@ export const BARCODE_SCANNER_TYPES = [
14
13
  'upc_a',
15
14
  'upc_e',
16
15
  ];
16
+ /*** Maps the Permissions owner status to ZORA's documented camera UI status. */
17
17
  export function mapPermissionStatusToCameraPermissionStatus(status, isRequestingPermission) {
18
18
  if (isRequestingPermission) {
19
19
  return 'requesting';
@@ -27,36 +27,4 @@ export function mapPermissionStatusToCameraPermissionStatus(status, isRequesting
27
27
  return 'denied';
28
28
  }
29
29
  }
30
- export function normalizeExpoBarcodeScanResult(result) {
31
- const value = result.data.trim();
32
- if (value.length === 0) {
33
- return null;
34
- }
35
- const type = typeof result.type === 'string' && result.type.length > 0 ? result.type : undefined;
36
- return {
37
- value,
38
- type,
39
- };
40
- }
41
- export function shouldIgnoreBarcodeScan(previous, next, now) {
42
- if (previous === null) {
43
- return false;
44
- }
45
- return (previous.value === next.value &&
46
- previous.type === next.type &&
47
- now - previous.timestamp < BARCODE_SCAN_DEDUPE_WINDOW_MS);
48
- }
49
- export async function dispatchExpoBarcodeScan(result, previous, now, onBarcodeScanned, onAccepted) {
50
- const normalizedResult = normalizeExpoBarcodeScanResult(result);
51
- if (normalizedResult === null || shouldIgnoreBarcodeScan(previous, normalizedResult, now)) {
52
- return false;
53
- }
54
- const record = {
55
- ...normalizedResult,
56
- timestamp: now,
57
- };
58
- onAccepted(record);
59
- await onBarcodeScanned?.(normalizedResult);
60
- return true;
61
- }
62
30
  //# sourceMappingURL=barcodeScanRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"barcodeScanRuntime.js","sourceRoot":"","sources":["../src/barcodeScanRuntime.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAElD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO;IACP,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,OAAO;IACP,MAAM;IACN,OAAO;IACP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G,8BAA8B,CAAC,MAAM,CAAC,CAAC;IAChE,IAAI,gBAAgB,KAAK,IAAI,IAAI,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,CAAC;QAC1F,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG;QACb,GAAG,gBAAgB;QACnB,SAAS,EAAE,GAAG;KACf,CAAC;IACF,UAAU,CAAC,MAAM,CAAC,CAAC;IACnB,MAAM,gBAAgB,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { PermissionStatus } from '@ankhorage/permissions';\nimport type { BarcodeScanResult, CameraPermissionStatus } from '@ankhorage/zora';\nimport type { BarcodeType } from 'expo-camera';\n\nexport const BARCODE_SCAN_DEDUPE_WINDOW_MS = 1500;\n\nexport const BARCODE_SCANNER_TYPES = [\n 'aztec',\n 'codabar',\n 'code39',\n 'code93',\n 'code128',\n 'datamatrix',\n 'ean13',\n 'ean8',\n 'itf14',\n 'pdf417',\n 'qr',\n 'upc_a',\n 'upc_e',\n] as const satisfies readonly BarcodeType[];\n\nexport interface BarcodeScanRecord extends BarcodeScanResult {\n readonly timestamp: number;\n}\n\nexport interface ExpoBarcodeScanResultLike {\n readonly data: string;\n readonly type?: string;\n}\n\ntype ExpoBarcodeScanCallback = (result: BarcodeScanResult) => Promise<void> | void;\n\nexport function mapPermissionStatusToCameraPermissionStatus(\n status: PermissionStatus,\n isRequestingPermission: boolean,\n): CameraPermissionStatus {\n if (isRequestingPermission) {\n return 'requesting';\n }\n\n switch (status) {\n case 'granted':\n return 'granted';\n case 'unknown':\n return 'unknown';\n default:\n return 'denied';\n }\n}\n\nexport function normalizeExpoBarcodeScanResult(\n result: ExpoBarcodeScanResultLike,\n): BarcodeScanResult | null {\n const value = result.data.trim();\n if (value.length === 0) {\n return null;\n }\n\n const type = typeof result.type === 'string' && result.type.length > 0 ? result.type : undefined;\n\n return {\n value,\n type,\n };\n}\n\nexport function shouldIgnoreBarcodeScan(\n previous: BarcodeScanRecord | null,\n next: BarcodeScanResult,\n now: number,\n): boolean {\n if (previous === null) {\n return false;\n }\n\n return (\n previous.value === next.value &&\n previous.type === next.type &&\n now - previous.timestamp < BARCODE_SCAN_DEDUPE_WINDOW_MS\n );\n}\n\nexport async function dispatchExpoBarcodeScan(\n result: ExpoBarcodeScanResultLike,\n previous: BarcodeScanRecord | null,\n now: number,\n onBarcodeScanned: ExpoBarcodeScanCallback | undefined,\n onAccepted: (record: BarcodeScanRecord) => void,\n): Promise<boolean> {\n const normalizedResult = normalizeExpoBarcodeScanResult(result);\n if (normalizedResult === null || shouldIgnoreBarcodeScan(previous, normalizedResult, now)) {\n return false;\n }\n\n const record = {\n ...normalizedResult,\n timestamp: now,\n };\n onAccepted(record);\n await onBarcodeScanned?.(normalizedResult);\n return true;\n}\n"]}
1
+ {"version":3,"file":"barcodeScanRuntime.js","sourceRoot":"","sources":["../src/barcodeScanRuntime.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,OAAO;IACP,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,YAAY;IACZ,OAAO;IACP,MAAM;IACN,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,OAAO;IACP,OAAO;CACkC,CAAC;AAE5C,gFAAgF;AAChF,MAAM,UAAU,2CAA2C,CACzD,MAAwB,EACxB,sBAA+B;IAE/B,IAAI,sBAAsB,EAAE,CAAC;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["import type { PermissionStatus } from '@ankhorage/permissions';\nimport type { CameraPermissionStatus } from '@ankhorage/zora';\nimport type { BarcodeType } from 'expo-camera';\n\nexport const BARCODE_SCANNER_TYPES = [\n 'aztec',\n 'codabar',\n 'code39',\n 'code93',\n 'code128',\n 'datamatrix',\n 'ean13',\n 'ean8',\n 'itf14',\n 'pdf417',\n 'qr',\n 'upc_a',\n 'upc_e',\n] as const satisfies readonly BarcodeType[];\n\n/*** Maps the Permissions owner status to ZORA's documented camera UI status. */\nexport function mapPermissionStatusToCameraPermissionStatus(\n status: PermissionStatus,\n isRequestingPermission: boolean,\n): CameraPermissionStatus {\n if (isRequestingPermission) {\n return 'requesting';\n }\n\n switch (status) {\n case 'granted':\n return 'granted';\n case 'unknown':\n return 'unknown';\n default:\n return 'denied';\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export { BARCODE_SCAN_DEDUPE_WINDOW_MS, BARCODE_SCANNER_TYPES, type BarcodeScanRecord, type ExpoBarcodeScanResultLike, mapPermissionStatusToCameraPermissionStatus, normalizeExpoBarcodeScanResult, shouldIgnoreBarcodeScan, } from './barcodeScanRuntime';
1
+ export { BARCODE_SCANNER_TYPES, mapPermissionStatusToCameraPermissionStatus, } from './barcodeScanRuntime';
2
2
  export { type ExpoBundledMediaRegistrySourceEntry, getExpoBundledMediaRegistrySource, } from './bundledMediaRegistrySource';
3
3
  export { createExpoBundledMediaResolver, type ExpoBundledMediaRegistry, type ExpoBundledMediaResolver, type ExpoBundledMediaResolverArgs, type ExpoBundledMediaValue, resolveExpoBundledMediaAsset, } from './bundledMediaResolver';
4
4
  export { type ExecuteExpoRuntimeCapabilityArgs, executeExpoRuntimeCapabilityAsync, type ExpoRuntimeCapabilityDiagnostic, type ExpoRuntimeCapabilityDiagnosticCode, type ExpoRuntimeCapabilityExecutionResult, type ExpoRuntimeCapabilityHandler, type ExpoRuntimeCapabilityHandlerArgs, type ExpoRuntimeRouteResolution, resolveExpoRuntimeRoutePath, } from './capabilityBridge';
5
5
  export type { ComponentRegistry } from './componentRegistry';
6
6
  export { createComponentRegistry } from './componentRegistry';
7
7
  export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
8
- export { ExpoBarcodeScannerAdapter } from './ExpoBarcodeScannerAdapter';
8
+ export { ExpoBarcodeScannerAdapter, type ExpoBarcodeScannerAdapterProps, } from './ExpoBarcodeScannerAdapter';
9
9
  export { ExpoRuntimeProviders, type ExpoRuntimeProvidersProps } from './ExpoRuntimeProviders';
10
10
  export { ExpoZoraIconFontProvider, type ExpoZoraIconFontProviderProps, } from './ExpoZoraIconFontProvider';
11
11
  export { type ExpoRuntimeConfigPluginOutput, type ExpoRuntimeDependencyMap, type ExpoRuntimeGeneratedAppOutputPlan, type ExpoRuntimeNativeOutputPlan, resolveExpoRuntimeConfigPluginOutput, resolveExpoRuntimeDependencyMap, resolveExpoRuntimeGeneratedAppOutput, resolveExpoRuntimeNativeOutput, } from './generatedAppOutput';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,2CAA2C,EAC3C,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,mCAAmC,EACxC,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,gCAAgC,EACrC,iCAAiC,EACjC,KAAK,+BAA+B,EACpC,KAAK,mCAAmC,EACxC,KAAK,oCAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,gCAAgC,EACrC,KAAK,0BAA0B,EAC/B,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,iBAAiB,E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CAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,gCAAgC,EACrC,KAAK,0BAA0B,EAC/B,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,yBAAyB,EACzB,KAAK,8BAA8B,GACpC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,KAAK,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EACL,wBAAwB,EACxB,KAAK,6BAA6B,GACnC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,2BAA2B,EAChC,oCAAoC,EACpC,+BAA+B,EAC/B,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACL,KAAK,gCAAgC,EACrC,mCAAmC,GACpC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- export { BARCODE_SCAN_DEDUPE_WINDOW_MS, BARCODE_SCANNER_TYPES, mapPermissionStatusToCameraPermissionStatus, normalizeExpoBarcodeScanResult, shouldIgnoreBarcodeScan, } from './barcodeScanRuntime';
1
+ export { BARCODE_SCANNER_TYPES, mapPermissionStatusToCameraPermissionStatus, } from './barcodeScanRuntime';
2
2
  export { getExpoBundledMediaRegistrySource, } from './bundledMediaRegistrySource';
3
3
  export { createExpoBundledMediaResolver, resolveExpoBundledMediaAsset, } from './bundledMediaResolver';
4
4
  export { executeExpoRuntimeCapabilityAsync, resolveExpoRuntimeRoutePath, } from './capabilityBridge';
5
5
  export { createComponentRegistry } from './componentRegistry';
6
6
  export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
7
- export { ExpoBarcodeScannerAdapter } from './ExpoBarcodeScannerAdapter';
7
+ export { ExpoBarcodeScannerAdapter, } from './ExpoBarcodeScannerAdapter';
8
8
  export { ExpoRuntimeProviders } from './ExpoRuntimeProviders';
9
9
  export { ExpoZoraIconFontProvider, } from './ExpoZoraIconFontProvider';
10
10
  export { resolveExpoRuntimeConfigPluginOutput, resolveExpoRuntimeDependencyMap, resolveExpoRuntimeGeneratedAppOutput, resolveExpoRuntimeNativeOutput, } from './generatedAppOutput';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EAGrB,2CAA2C,EAC3C,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,8BAA8B,EAK9B,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,iCAAiC,EAOjC,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAkC,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EACL,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAKL,oCAAoC,EACpC,+BAA+B,EAC/B,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAEL,mCAAmC,GACpC,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export {\n BARCODE_SCAN_DEDUPE_WINDOW_MS,\n BARCODE_SCANNER_TYPES,\n type BarcodeScanRecord,\n type ExpoBarcodeScanResultLike,\n mapPermissionStatusToCameraPermissionStatus,\n normalizeExpoBarcodeScanResult,\n shouldIgnoreBarcodeScan,\n} from './barcodeScanRuntime';\nexport {\n type ExpoBundledMediaRegistrySourceEntry,\n getExpoBundledMediaRegistrySource,\n} from './bundledMediaRegistrySource';\nexport {\n createExpoBundledMediaResolver,\n type ExpoBundledMediaRegistry,\n type ExpoBundledMediaResolver,\n type ExpoBundledMediaResolverArgs,\n type ExpoBundledMediaValue,\n resolveExpoBundledMediaAsset,\n} from './bundledMediaResolver';\nexport {\n type ExecuteExpoRuntimeCapabilityArgs,\n executeExpoRuntimeCapabilityAsync,\n type ExpoRuntimeCapabilityDiagnostic,\n type ExpoRuntimeCapabilityDiagnosticCode,\n type ExpoRuntimeCapabilityExecutionResult,\n type ExpoRuntimeCapabilityHandler,\n type ExpoRuntimeCapabilityHandlerArgs,\n type ExpoRuntimeRouteResolution,\n resolveExpoRuntimeRoutePath,\n} from './capabilityBridge';\nexport type { ComponentRegistry } from './componentRegistry';\nexport { createComponentRegistry } from './componentRegistry';\nexport { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';\nexport { ExpoBarcodeScannerAdapter } from './ExpoBarcodeScannerAdapter';\nexport { ExpoRuntimeProviders, type ExpoRuntimeProvidersProps } from './ExpoRuntimeProviders';\nexport {\n ExpoZoraIconFontProvider,\n type ExpoZoraIconFontProviderProps,\n} from './ExpoZoraIconFontProvider';\nexport {\n type ExpoRuntimeConfigPluginOutput,\n type ExpoRuntimeDependencyMap,\n type ExpoRuntimeGeneratedAppOutputPlan,\n type ExpoRuntimeNativeOutputPlan,\n resolveExpoRuntimeConfigPluginOutput,\n resolveExpoRuntimeDependencyMap,\n resolveExpoRuntimeGeneratedAppOutput,\n resolveExpoRuntimeNativeOutput,\n} from './generatedAppOutput';\nexport { getExpoBarcodeScannerViewSource } from './generatedSources';\nexport {\n type ExpoRuntimeLayoutIntegrationPlan,\n resolveExpoRuntimeLayoutIntegration,\n} from './layoutIntegrationPlanning';\nexport type {\n ExpoRuntimeAdapterId,\n ExpoRuntimePlan,\n ExpoRuntimeProviderId,\n} from './resolveExpoRuntimePlan';\nexport { resolveExpoRuntimePlan } from './resolveExpoRuntimePlan';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,2CAA2C,GAC5C,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,8BAA8B,EAK9B,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,iCAAiC,EAOjC,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,yBAAyB,GAE1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAkC,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EACL,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAKL,oCAAoC,EACpC,+BAA+B,EAC/B,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAEL,mCAAmC,GACpC,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export {\n BARCODE_SCANNER_TYPES,\n mapPermissionStatusToCameraPermissionStatus,\n} from './barcodeScanRuntime';\nexport {\n type ExpoBundledMediaRegistrySourceEntry,\n getExpoBundledMediaRegistrySource,\n} from './bundledMediaRegistrySource';\nexport {\n createExpoBundledMediaResolver,\n type ExpoBundledMediaRegistry,\n type ExpoBundledMediaResolver,\n type ExpoBundledMediaResolverArgs,\n type ExpoBundledMediaValue,\n resolveExpoBundledMediaAsset,\n} from './bundledMediaResolver';\nexport {\n type ExecuteExpoRuntimeCapabilityArgs,\n executeExpoRuntimeCapabilityAsync,\n type ExpoRuntimeCapabilityDiagnostic,\n type ExpoRuntimeCapabilityDiagnosticCode,\n type ExpoRuntimeCapabilityExecutionResult,\n type ExpoRuntimeCapabilityHandler,\n type ExpoRuntimeCapabilityHandlerArgs,\n type ExpoRuntimeRouteResolution,\n resolveExpoRuntimeRoutePath,\n} from './capabilityBridge';\nexport type { ComponentRegistry } from './componentRegistry';\nexport { createComponentRegistry } from './componentRegistry';\nexport { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';\nexport {\n ExpoBarcodeScannerAdapter,\n type ExpoBarcodeScannerAdapterProps,\n} from './ExpoBarcodeScannerAdapter';\nexport { ExpoRuntimeProviders, type ExpoRuntimeProvidersProps } from './ExpoRuntimeProviders';\nexport {\n ExpoZoraIconFontProvider,\n type ExpoZoraIconFontProviderProps,\n} from './ExpoZoraIconFontProvider';\nexport {\n type ExpoRuntimeConfigPluginOutput,\n type ExpoRuntimeDependencyMap,\n type ExpoRuntimeGeneratedAppOutputPlan,\n type ExpoRuntimeNativeOutputPlan,\n resolveExpoRuntimeConfigPluginOutput,\n resolveExpoRuntimeDependencyMap,\n resolveExpoRuntimeGeneratedAppOutput,\n resolveExpoRuntimeNativeOutput,\n} from './generatedAppOutput';\nexport { getExpoBarcodeScannerViewSource } from './generatedSources';\nexport {\n type ExpoRuntimeLayoutIntegrationPlan,\n resolveExpoRuntimeLayoutIntegration,\n} from './layoutIntegrationPlanning';\nexport type {\n ExpoRuntimeAdapterId,\n ExpoRuntimePlan,\n ExpoRuntimeProviderId,\n} from './resolveExpoRuntimePlan';\nexport { resolveExpoRuntimePlan } from './resolveExpoRuntimePlan';\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/expo-runtime",
3
3
  "type": "module",
4
- "version": "6.0.3",
4
+ "version": "7.0.0",
5
5
  "description": "Declarative runtime integration for Expo apps: maps app capabilities to permissions, packages, config plugins, providers, and adapters",
6
6
  "homepage": "https://github.com/ankhorage/expo-runtime#readme",
7
7
  "bugs": {
@@ -183,7 +183,7 @@
183
183
  },
184
184
  "peerDependencies": {
185
185
  "@ankhorage/permissions": "^0.2.63",
186
- "@ankhorage/zora": "^24.0.0",
186
+ "@ankhorage/zora": "^25.8.3",
187
187
  "@react-native-vector-icons/fontawesome": "^13.1.4",
188
188
  "@react-native-vector-icons/fontawesome5": "^13.1.4",
189
189
  "@react-native-vector-icons/fontawesome6": "^13.1.4",
@@ -253,7 +253,7 @@
253
253
  "@ankhorage/devtools": "^2.3.18",
254
254
  "@ankhorage/paradox": "^0.2.27",
255
255
  "@ankhorage/permissions": "^0.2.63",
256
- "@ankhorage/zora": "^24.0.0",
256
+ "@ankhorage/zora": "^25.8.3",
257
257
  "@react-native-vector-icons/fontawesome": "^13.1.4",
258
258
  "@react-native-vector-icons/fontawesome5": "^13.1.4",
259
259
  "@react-native-vector-icons/fontawesome6": "^13.1.4",
@@ -1,71 +1,25 @@
1
1
  import { describe, expect, it } from 'bun:test';
2
+ import type { CameraViewProps } from 'expo-camera';
2
3
 
3
4
  import {
4
- BARCODE_SCAN_DEDUPE_WINDOW_MS,
5
5
  BARCODE_SCANNER_TYPES,
6
- dispatchExpoBarcodeScan,
7
6
  mapPermissionStatusToCameraPermissionStatus,
8
- normalizeExpoBarcodeScanResult,
9
- shouldIgnoreBarcodeScan,
10
7
  } from './barcodeScanRuntime';
8
+ import type { ExpoBarcodeScannerAdapterProps } from './ExpoBarcodeScannerAdapter';
11
9
 
12
- describe('Expo barcode event helpers', () => {
13
- it('normalizes Expo barcode scan payloads for the runtime event pipeline', () => {
14
- expect(
15
- normalizeExpoBarcodeScanResult({
16
- data: ' 0123456789 ',
17
- type: 'ean13',
18
- }),
19
- ).toEqual({
20
- value: '0123456789',
21
- type: 'ean13',
22
- });
23
- });
24
-
25
- it('drops empty scan payloads', () => {
26
- expect(
27
- normalizeExpoBarcodeScanResult({
28
- data: ' ',
29
- type: 'qr',
30
- }),
31
- ).toBeNull();
10
+ describe('Expo barcode adapter configuration', () => {
11
+ it('uses the Expo Camera callback and payload contract at the adapter boundary', () => {
12
+ const callback: NonNullable<CameraViewProps['onBarcodeScanned']> = (result) => {
13
+ expect(result).toEqual({ data: '4006381333931', type: 'ean13' });
14
+ };
15
+ const props: ExpoBarcodeScannerAdapterProps = {
16
+ onBarcodeScanned: callback,
17
+ permissionStatus: 'granted',
18
+ };
19
+
20
+ expect(props.onBarcodeScanned).toBe(callback);
32
21
  });
33
- });
34
22
 
35
- describe('Expo barcode event deduplication', () => {
36
- it('suppresses repeated scans inside the dedupe window', () => {
37
- expect(
38
- shouldIgnoreBarcodeScan(
39
- {
40
- value: '0123456789',
41
- type: 'ean13',
42
- timestamp: 1_000,
43
- },
44
- {
45
- value: '0123456789',
46
- type: 'ean13',
47
- },
48
- 1_000 + BARCODE_SCAN_DEDUPE_WINDOW_MS - 1,
49
- ),
50
- ).toBe(true);
51
- expect(
52
- shouldIgnoreBarcodeScan(
53
- {
54
- value: '0123456789',
55
- type: 'ean13',
56
- timestamp: 1_000,
57
- },
58
- {
59
- value: '0123456789',
60
- type: 'ean13',
61
- },
62
- 1_000 + BARCODE_SCAN_DEDUPE_WINDOW_MS,
63
- ),
64
- ).toBe(false);
65
- });
66
- });
67
-
68
- describe('Expo barcode adapter configuration', () => {
69
23
  it('maps permission states into the ZORA camera permission surface', () => {
70
24
  expect(mapPermissionStatusToCameraPermissionStatus('unknown', false)).toBe('unknown');
71
25
  expect(mapPermissionStatusToCameraPermissionStatus('granted', false)).toBe('granted');
@@ -90,29 +44,4 @@ describe('Expo barcode adapter configuration', () => {
90
44
  'upc_e',
91
45
  ]);
92
46
  });
93
-
94
- it.each([
95
- ['qr', 'https://ankhorage.dev'],
96
- ['ean13', '4006381333931'],
97
- ['ean8', '96385074'],
98
- ])('normalizes and forwards an accepted %s event', async (type, data) => {
99
- const forwarded: { value: string; type?: string }[] = [];
100
- let acceptedRecord: { value: string; type?: string; timestamp: number } | undefined;
101
-
102
- expect(
103
- await dispatchExpoBarcodeScan(
104
- { data, type },
105
- null,
106
- 1_000,
107
- (result) => {
108
- forwarded.push(result);
109
- },
110
- (record) => {
111
- acceptedRecord = record;
112
- },
113
- ),
114
- ).toBe(true);
115
- expect(forwarded).toEqual([{ value: data, type }]);
116
- expect(acceptedRecord).toEqual({ value: data, type, timestamp: 1_000 });
117
- });
118
47
  });
@@ -1,23 +1,25 @@
1
1
  import { Permission, usePermission } from '@ankhorage/permissions';
2
2
  import { BarcodeScannerView, type BarcodeScannerViewProps } from '@ankhorage/zora';
3
- import { type BarcodeScanningResult, type BarcodeType, CameraView } from 'expo-camera';
3
+ import { type BarcodeType, CameraView, type CameraViewProps } from 'expo-camera';
4
4
  import React from 'react';
5
5
  import { StyleSheet } from 'react-native';
6
6
 
7
7
  import {
8
8
  BARCODE_SCANNER_TYPES,
9
- type BarcodeScanRecord,
10
- dispatchExpoBarcodeScan,
11
9
  mapPermissionStatusToCameraPermissionStatus,
12
10
  } from './barcodeScanRuntime';
13
11
 
14
12
  const CAMERA_BARCODE_TYPES: BarcodeType[] = [...BARCODE_SCANNER_TYPES];
15
13
 
16
- export function ExpoBarcodeScannerAdapter(props: BarcodeScannerViewProps) {
14
+ export interface ExpoBarcodeScannerAdapterProps extends BarcodeScannerViewProps {
15
+ readonly onBarcodeScanned?: CameraViewProps['onBarcodeScanned'];
16
+ }
17
+
18
+ /*** Renders the ZORA scanner surface with Expo Camera and its native scan callback. */
19
+ export function ExpoBarcodeScannerAdapter(props: ExpoBarcodeScannerAdapterProps) {
17
20
  const { onBarcodeScanned, onRequestPermission, ...viewProps } = props;
18
21
  const cameraPermission = usePermission(Permission.Camera);
19
22
  const [isRequestingPermission, setIsRequestingPermission] = React.useState(false);
20
- const lastScanRef = React.useRef<BarcodeScanRecord | null>(null);
21
23
 
22
24
  const permissionStatus = mapPermissionStatusToCameraPermissionStatus(
23
25
  cameraPermission.status,
@@ -34,26 +36,11 @@ export function ExpoBarcodeScannerAdapter(props: BarcodeScannerViewProps) {
34
36
  }
35
37
  }, [cameraPermission, onRequestPermission]);
36
38
 
37
- const handleBarcodeScanned = React.useCallback(
38
- (result: BarcodeScanningResult) => {
39
- void dispatchExpoBarcodeScan(
40
- result,
41
- lastScanRef.current,
42
- Date.now(),
43
- onBarcodeScanned,
44
- (record) => {
45
- lastScanRef.current = record;
46
- },
47
- );
48
- },
49
- [onBarcodeScanned],
50
- );
51
-
52
39
  const camera =
53
40
  permissionStatus === 'granted' ? (
54
41
  <CameraView
55
42
  barcodeScannerSettings={{ barcodeTypes: CAMERA_BARCODE_TYPES }}
56
- onBarcodeScanned={handleBarcodeScanned}
43
+ onBarcodeScanned={onBarcodeScanned}
57
44
  style={styles.camera}
58
45
  />
59
46
  ) : undefined;
@@ -1,9 +1,7 @@
1
1
  import type { PermissionStatus } from '@ankhorage/permissions';
2
- import type { BarcodeScanResult, CameraPermissionStatus } from '@ankhorage/zora';
2
+ import type { CameraPermissionStatus } from '@ankhorage/zora';
3
3
  import type { BarcodeType } from 'expo-camera';
4
4
 
5
- export const BARCODE_SCAN_DEDUPE_WINDOW_MS = 1500;
6
-
7
5
  export const BARCODE_SCANNER_TYPES = [
8
6
  'aztec',
9
7
  'codabar',
@@ -20,17 +18,7 @@ export const BARCODE_SCANNER_TYPES = [
20
18
  'upc_e',
21
19
  ] as const satisfies readonly BarcodeType[];
22
20
 
23
- export interface BarcodeScanRecord extends BarcodeScanResult {
24
- readonly timestamp: number;
25
- }
26
-
27
- export interface ExpoBarcodeScanResultLike {
28
- readonly data: string;
29
- readonly type?: string;
30
- }
31
-
32
- type ExpoBarcodeScanCallback = (result: BarcodeScanResult) => Promise<void> | void;
33
-
21
+ /*** Maps the Permissions owner status to ZORA's documented camera UI status. */
34
22
  export function mapPermissionStatusToCameraPermissionStatus(
35
23
  status: PermissionStatus,
36
24
  isRequestingPermission: boolean,
@@ -48,56 +36,3 @@ export function mapPermissionStatusToCameraPermissionStatus(
48
36
  return 'denied';
49
37
  }
50
38
  }
51
-
52
- export function normalizeExpoBarcodeScanResult(
53
- result: ExpoBarcodeScanResultLike,
54
- ): BarcodeScanResult | null {
55
- const value = result.data.trim();
56
- if (value.length === 0) {
57
- return null;
58
- }
59
-
60
- const type = typeof result.type === 'string' && result.type.length > 0 ? result.type : undefined;
61
-
62
- return {
63
- value,
64
- type,
65
- };
66
- }
67
-
68
- export function shouldIgnoreBarcodeScan(
69
- previous: BarcodeScanRecord | null,
70
- next: BarcodeScanResult,
71
- now: number,
72
- ): boolean {
73
- if (previous === null) {
74
- return false;
75
- }
76
-
77
- return (
78
- previous.value === next.value &&
79
- previous.type === next.type &&
80
- now - previous.timestamp < BARCODE_SCAN_DEDUPE_WINDOW_MS
81
- );
82
- }
83
-
84
- export async function dispatchExpoBarcodeScan(
85
- result: ExpoBarcodeScanResultLike,
86
- previous: BarcodeScanRecord | null,
87
- now: number,
88
- onBarcodeScanned: ExpoBarcodeScanCallback | undefined,
89
- onAccepted: (record: BarcodeScanRecord) => void,
90
- ): Promise<boolean> {
91
- const normalizedResult = normalizeExpoBarcodeScanResult(result);
92
- if (normalizedResult === null || shouldIgnoreBarcodeScan(previous, normalizedResult, now)) {
93
- return false;
94
- }
95
-
96
- const record = {
97
- ...normalizedResult,
98
- timestamp: now,
99
- };
100
- onAccepted(record);
101
- await onBarcodeScanned?.(normalizedResult);
102
- return true;
103
- }
package/src/index.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  export {
2
- BARCODE_SCAN_DEDUPE_WINDOW_MS,
3
2
  BARCODE_SCANNER_TYPES,
4
- type BarcodeScanRecord,
5
- type ExpoBarcodeScanResultLike,
6
3
  mapPermissionStatusToCameraPermissionStatus,
7
- normalizeExpoBarcodeScanResult,
8
- shouldIgnoreBarcodeScan,
9
4
  } from './barcodeScanRuntime';
10
5
  export {
11
6
  type ExpoBundledMediaRegistrySourceEntry,
@@ -33,7 +28,10 @@ export {
33
28
  export type { ComponentRegistry } from './componentRegistry';
34
29
  export { createComponentRegistry } from './componentRegistry';
35
30
  export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
36
- export { ExpoBarcodeScannerAdapter } from './ExpoBarcodeScannerAdapter';
31
+ export {
32
+ ExpoBarcodeScannerAdapter,
33
+ type ExpoBarcodeScannerAdapterProps,
34
+ } from './ExpoBarcodeScannerAdapter';
37
35
  export { ExpoRuntimeProviders, type ExpoRuntimeProvidersProps } from './ExpoRuntimeProviders';
38
36
  export {
39
37
  ExpoZoraIconFontProvider,