@ankhorage/expo-runtime 6.0.2 → 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 +12 -0
- package/README.md +1 -2
- package/dist/ExpoBarcodeScannerAdapter.d.ts +6 -1
- package/dist/ExpoBarcodeScannerAdapter.d.ts.map +1 -1
- package/dist/ExpoBarcodeScannerAdapter.js +3 -8
- package/dist/ExpoBarcodeScannerAdapter.js.map +1 -1
- package/dist/barcodeScanRuntime.d.ts +2 -14
- package/dist/barcodeScanRuntime.d.ts.map +1 -1
- package/dist/barcodeScanRuntime.js +1 -33
- package/dist/barcodeScanRuntime.js.map +1 -1
- package/dist/capabilityBridge.d.ts +1 -1
- package/dist/capabilityBridge.d.ts.map +1 -1
- package/dist/capabilityBridge.js.map +1 -1
- package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.d.ts +2 -2
- package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.d.ts.map +1 -1
- package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.js +58 -12
- package/dist/features/capabilities/executeExpoRuntimeCapabilityAsync.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/expoRuntimeCapability.d.ts +11 -0
- package/dist/types/expoRuntimeCapability.d.ts.map +1 -1
- package/dist/types/expoRuntimeCapability.js.map +1 -1
- package/package.json +3 -3
- package/src/ExpoBarcodeScannerAdapter.test.tsx +13 -84
- package/src/ExpoBarcodeScannerAdapter.tsx +8 -21
- package/src/barcodeScanRuntime.ts +2 -67
- package/src/capabilityBridge.ts +3 -0
- package/src/expoCapabilityBridge.test.ts +119 -3
- package/src/features/capabilities/executeExpoRuntimeCapabilityAsync.ts +72 -14
- package/src/index.ts +7 -6
- package/src/types/expoRuntimeCapability.ts +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 6.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7b0e21d: Return structured execution results and actionable rejection diagnostics from the Expo Runtime capability bridge.
|
|
14
|
+
|
|
3
15
|
## 6.0.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# EXPO-RUNTIME
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Declarative runtime integration for Expo apps: maps app capabilities to permissions, packages, config plugins, providers, and adapters
|
|
9
9
|
|
|
@@ -55,7 +55,6 @@ export function createBasicExpoRuntimePlan() {
|
|
|
55
55
|
- [Module relationships](././paradox/diagrams/module-relationships.mmd)
|
|
56
56
|
- [Export graph](././paradox/diagrams/export-graph.mmd)
|
|
57
57
|
- [createExpoRuntimeRegistry sequence](././paradox/diagrams/sequences/create-expo-runtime-registry.mmd)
|
|
58
|
-
- [executeExpoRuntimeCapabilityAsync sequence](././paradox/diagrams/sequences/execute-expo-runtime-capability-async.mmd)
|
|
59
58
|
- [ExpoBarcodeScannerAdapter sequence](././paradox/diagrams/sequences/expo-barcode-scanner-adapter.mmd)
|
|
60
59
|
- [ExpoZoraIconFontProvider sequence](././paradox/diagrams/sequences/expo-zora-icon-font-provider.mmd)
|
|
61
60
|
- [getExpoBundledMediaRegistrySource sequence](././paradox/diagrams/sequences/get-expo-bundled-media-registry-source.mmd)
|
|
@@ -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
|
|
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;
|
|
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,
|
|
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
|
|
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,
|
|
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,gBAAgB,EAAE,mBAAmB,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACtE,MAAM,gBAAgB,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1D,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElF,MAAM,gBAAgB,GAAG,2CAA2C,CAClE,gBAAgB,CAAC,MAAM,EACvB,sBAAsB,CACvB,CAAC;IAEF,MAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;QAC3D,yBAAyB,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,gBAAgB,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,mBAAmB,EAAE,EAAE,CAAC;QAChC,CAAC;gBAAS,CAAC;YACT,yBAAyB,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,EAAE,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAE5C,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,gBAAgB,CAAC,CACnC,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 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 {
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { executeExpoRuntimeCapabilityAsync } from './features/capabilities/executeExpoRuntimeCapabilityAsync';
|
|
2
2
|
export { resolveExpoRuntimeRoutePath } from './features/navigation/resolveExpoRuntimeRoutePath';
|
|
3
|
-
export type { ExecuteExpoRuntimeCapabilityArgs, ExpoRuntimeCapabilityHandler, ExpoRuntimeCapabilityHandlerArgs, } from './types/expoRuntimeCapability';
|
|
3
|
+
export type { ExecuteExpoRuntimeCapabilityArgs, ExpoRuntimeCapabilityDiagnostic, ExpoRuntimeCapabilityDiagnosticCode, ExpoRuntimeCapabilityExecutionResult, ExpoRuntimeCapabilityHandler, ExpoRuntimeCapabilityHandlerArgs, } from './types/expoRuntimeCapability';
|
|
4
4
|
export type { ExpoRuntimeRouteResolution } from './types/expoRuntimeRoute';
|
|
5
5
|
//# sourceMappingURL=capabilityBridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityBridge.d.ts","sourceRoot":"","sources":["../src/capabilityBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2DAA2D,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,YAAY,EACV,gCAAgC,EAChC,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"capabilityBridge.d.ts","sourceRoot":"","sources":["../src/capabilityBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2DAA2D,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAChG,YAAY,EACV,gCAAgC,EAChC,+BAA+B,EAC/B,mCAAmC,EACnC,oCAAoC,EACpC,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilityBridge.js","sourceRoot":"","sources":["../src/capabilityBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2DAA2D,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC","sourcesContent":["export { executeExpoRuntimeCapabilityAsync } from './features/capabilities/executeExpoRuntimeCapabilityAsync';\nexport { resolveExpoRuntimeRoutePath } from './features/navigation/resolveExpoRuntimeRoutePath';\nexport type {\n ExecuteExpoRuntimeCapabilityArgs,\n ExpoRuntimeCapabilityHandler,\n ExpoRuntimeCapabilityHandlerArgs,\n} from './types/expoRuntimeCapability';\nexport type { ExpoRuntimeRouteResolution } from './types/expoRuntimeRoute';\n"]}
|
|
1
|
+
{"version":3,"file":"capabilityBridge.js","sourceRoot":"","sources":["../src/capabilityBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,2DAA2D,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC","sourcesContent":["export { executeExpoRuntimeCapabilityAsync } from './features/capabilities/executeExpoRuntimeCapabilityAsync';\nexport { resolveExpoRuntimeRoutePath } from './features/navigation/resolveExpoRuntimeRoutePath';\nexport type {\n ExecuteExpoRuntimeCapabilityArgs,\n ExpoRuntimeCapabilityDiagnostic,\n ExpoRuntimeCapabilityDiagnosticCode,\n ExpoRuntimeCapabilityExecutionResult,\n ExpoRuntimeCapabilityHandler,\n ExpoRuntimeCapabilityHandlerArgs,\n} from './types/expoRuntimeCapability';\nexport type { ExpoRuntimeRouteResolution } from './types/expoRuntimeRoute';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExecuteExpoRuntimeCapabilityArgs } from '../../types/expoRuntimeCapability';
|
|
1
|
+
import type { ExecuteExpoRuntimeCapabilityArgs, ExpoRuntimeCapabilityExecutionResult } from '../../types/expoRuntimeCapability';
|
|
2
2
|
/*** Execute an Expo-owned capability or delegate another canonical capability to its runtime handler. */
|
|
3
|
-
export declare function executeExpoRuntimeCapabilityAsync(args: ExecuteExpoRuntimeCapabilityArgs): Promise<
|
|
3
|
+
export declare function executeExpoRuntimeCapabilityAsync(args: ExecuteExpoRuntimeCapabilityArgs): Promise<ExpoRuntimeCapabilityExecutionResult>;
|
|
4
4
|
//# sourceMappingURL=executeExpoRuntimeCapabilityAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeExpoRuntimeCapabilityAsync.d.ts","sourceRoot":"","sources":["../../../src/features/capabilities/executeExpoRuntimeCapabilityAsync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,
|
|
1
|
+
{"version":3,"file":"executeExpoRuntimeCapabilityAsync.d.ts","sourceRoot":"","sources":["../../../src/features/capabilities/executeExpoRuntimeCapabilityAsync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,EAEhC,oCAAoC,EAGrC,MAAM,mCAAmC,CAAC;AAE3C,yGAAyG;AACzG,wBAAsB,iCAAiC,CACrD,IAAI,EAAE,gCAAgC,GACrC,OAAO,CAAC,oCAAoC,CAAC,CAqB/C"}
|
|
@@ -2,13 +2,36 @@ import { isCapability } from '@ankhorage/capability';
|
|
|
2
2
|
/*** Execute an Expo-owned capability or delegate another canonical capability to its runtime handler. */
|
|
3
3
|
export async function executeExpoRuntimeCapabilityAsync(args) {
|
|
4
4
|
const { capability, input, capabilityHandlers, alertImpl } = args;
|
|
5
|
-
if (!isCapability(capability))
|
|
6
|
-
return
|
|
5
|
+
if (!isCapability(capability)) {
|
|
6
|
+
return rejectCapabilityExecution({
|
|
7
|
+
code: 'invalid-capability-descriptor',
|
|
8
|
+
message: 'The capability descriptor is invalid.',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
7
11
|
if (capability.id === 'expo.alert') {
|
|
8
|
-
executeExpoAlert(input, alertImpl);
|
|
9
|
-
|
|
12
|
+
return executeExpoAlert(input, alertImpl);
|
|
13
|
+
}
|
|
14
|
+
const handler = findCapabilityHandler(capabilityHandlers, capability.id);
|
|
15
|
+
if (!handler) {
|
|
16
|
+
return rejectCapabilityExecution({
|
|
17
|
+
code: 'missing-capability-handler',
|
|
18
|
+
message: `No Expo Runtime capability handler is configured for '${capability.id}'.`,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return executeForeignCapabilityHandlerAsync(handler, capability, input);
|
|
22
|
+
}
|
|
23
|
+
/*** Execute a foreign capability handler and translate its failure into the bridge result contract. */
|
|
24
|
+
async function executeForeignCapabilityHandlerAsync(handler, capability, input) {
|
|
25
|
+
try {
|
|
26
|
+
await handler({ capability, input });
|
|
27
|
+
return { ok: true };
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return rejectCapabilityExecution({
|
|
31
|
+
code: 'capability-handler-failed',
|
|
32
|
+
message: `The handler for '${capability.id}' failed: ${getFailureMessage(error)}`,
|
|
33
|
+
});
|
|
10
34
|
}
|
|
11
|
-
await findCapabilityHandler(capabilityHandlers, capability.id)?.({ capability, input });
|
|
12
35
|
}
|
|
13
36
|
/*** Find the configured executor for one canonical capability without dynamic record access. */
|
|
14
37
|
function findCapabilityHandler(capabilityHandlers, capabilityId) {
|
|
@@ -16,15 +39,38 @@ function findCapabilityHandler(capabilityHandlers, capabilityId) {
|
|
|
16
39
|
}
|
|
17
40
|
/*** Display a valid Expo-owned alert invocation without exposing alert as a generic action. */
|
|
18
41
|
function executeExpoAlert(input, alertImpl) {
|
|
19
|
-
if (!isExpoAlertInput(input))
|
|
20
|
-
return
|
|
21
|
-
|
|
42
|
+
if (!isExpoAlertInput(input)) {
|
|
43
|
+
return rejectCapabilityExecution({
|
|
44
|
+
code: 'invalid-expo-alert-input',
|
|
45
|
+
message: "The 'expo.alert' capability requires an input object with only a string 'message'.",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (!alertImpl) {
|
|
49
|
+
return rejectCapabilityExecution({
|
|
50
|
+
code: 'missing-expo-alert-handler',
|
|
51
|
+
message: "No Expo alert host callback is configured for 'expo.alert'.",
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
alertImpl(input.message);
|
|
55
|
+
return { ok: true };
|
|
22
56
|
}
|
|
23
57
|
/*** Validate the serializable input accepted by the Expo alert capability. */
|
|
24
58
|
function isExpoAlertInput(input) {
|
|
25
|
-
|
|
26
|
-
input
|
|
27
|
-
|
|
28
|
-
|
|
59
|
+
if (typeof input !== 'object' ||
|
|
60
|
+
input === null ||
|
|
61
|
+
Array.isArray(input) ||
|
|
62
|
+
!('message' in input)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const entries = Object.entries(input);
|
|
66
|
+
return entries.length === 1 && typeof input.message === 'string';
|
|
67
|
+
}
|
|
68
|
+
/*** Report a rejected capability invocation with a diagnostic that a runtime owner can surface. */
|
|
69
|
+
function rejectCapabilityExecution(diagnostic) {
|
|
70
|
+
return { ok: false, diagnostics: [diagnostic] };
|
|
71
|
+
}
|
|
72
|
+
/*** Convert any foreign handler failure into a diagnostic-safe message. */
|
|
73
|
+
function getFailureMessage(error) {
|
|
74
|
+
return error instanceof Error ? error.message : String(error);
|
|
29
75
|
}
|
|
30
76
|
//# sourceMappingURL=executeExpoRuntimeCapabilityAsync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeExpoRuntimeCapabilityAsync.js","sourceRoot":"","sources":["../../../src/features/capabilities/executeExpoRuntimeCapabilityAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"executeExpoRuntimeCapabilityAsync.js","sourceRoot":"","sources":["../../../src/features/capabilities/executeExpoRuntimeCapabilityAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAWrD,yGAAyG;AACzG,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,IAAsC;IAEtC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAClE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,yBAAyB,CAAC;YAC/B,IAAI,EAAE,+BAA+B;YACrC,OAAO,EAAE,uCAAuC;SACjD,CAAC,CAAC;IACL,CAAC;IAED,IAAI,UAAU,CAAC,EAAE,KAAK,YAAY,EAAE,CAAC;QACnC,OAAO,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,OAAO,GAAG,qBAAqB,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;IACzE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,yBAAyB,CAAC;YAC/B,IAAI,EAAE,4BAA4B;YAClC,OAAO,EAAE,yDAAyD,UAAU,CAAC,EAAE,IAAI;SACpF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,oCAAoC,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED,uGAAuG;AACvG,KAAK,UAAU,oCAAoC,CACjD,OAAyE,EACzE,UAAsB,EACtB,KAAc;IAEd,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACrC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,yBAAyB,CAAC;YAC/B,IAAI,EAAE,2BAA2B;YACjC,OAAO,EAAE,oBAAoB,UAAU,CAAC,EAAE,aAAa,iBAAiB,CAAC,KAAK,CAAC,EAAE;SAClF,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,gGAAgG;AAChG,SAAS,qBAAqB,CAC5B,kBAAuE,EACvE,YAA8B;IAE9B,OAAO,kBAAkB,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,KAAK,YAAY,CAAC,EAAE,OAAO,CAAC;AAC/F,CAAC;AAED,+FAA+F;AAC/F,SAAS,gBAAgB,CACvB,KAAc,EACd,SAAkD;IAElD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,yBAAyB,CAAC;YAC/B,IAAI,EAAE,0BAA0B;YAChC,OAAO,EAAE,oFAAoF;SAC9F,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,yBAAyB,CAAC;YAC/B,IAAI,EAAE,4BAA4B;YAClC,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IACD,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC;AAED,8EAA8E;AAC9E,SAAS,gBAAgB,CAAC,KAAc;IACtC,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,EACrB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AACnE,CAAC;AAED,mGAAmG;AACnG,SAAS,yBAAyB,CAChC,UAA2C;IAE3C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,2EAA2E;AAC3E,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { isCapability } from '@ankhorage/capability';\nimport type { Capability } from '@ankhorage/contracts/capability';\n\nimport type {\n ExecuteExpoRuntimeCapabilityArgs,\n ExpoRuntimeCapabilityDiagnostic,\n ExpoRuntimeCapabilityExecutionResult,\n ExpoRuntimeCapabilityHandler,\n ExpoRuntimeCapabilityHandlerArgs,\n} from '../../types/expoRuntimeCapability';\n\n/*** Execute an Expo-owned capability or delegate another canonical capability to its runtime handler. */\nexport async function executeExpoRuntimeCapabilityAsync(\n args: ExecuteExpoRuntimeCapabilityArgs,\n): Promise<ExpoRuntimeCapabilityExecutionResult> {\n const { capability, input, capabilityHandlers, alertImpl } = args;\n if (!isCapability(capability)) {\n return rejectCapabilityExecution({\n code: 'invalid-capability-descriptor',\n message: 'The capability descriptor is invalid.',\n });\n }\n\n if (capability.id === 'expo.alert') {\n return executeExpoAlert(input, alertImpl);\n }\n\n const handler = findCapabilityHandler(capabilityHandlers, capability.id);\n if (!handler) {\n return rejectCapabilityExecution({\n code: 'missing-capability-handler',\n message: `No Expo Runtime capability handler is configured for '${capability.id}'.`,\n });\n }\n return executeForeignCapabilityHandlerAsync(handler, capability, input);\n}\n\n/*** Execute a foreign capability handler and translate its failure into the bridge result contract. */\nasync function executeForeignCapabilityHandlerAsync(\n handler: (args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void,\n capability: Capability,\n input: unknown,\n): Promise<ExpoRuntimeCapabilityExecutionResult> {\n try {\n await handler({ capability, input });\n return { ok: true };\n } catch (error) {\n return rejectCapabilityExecution({\n code: 'capability-handler-failed',\n message: `The handler for '${capability.id}' failed: ${getFailureMessage(error)}`,\n });\n }\n}\n\n/*** Find the configured executor for one canonical capability without dynamic record access. */\nfunction findCapabilityHandler(\n capabilityHandlers: readonly ExpoRuntimeCapabilityHandler[] | undefined,\n capabilityId: Capability['id'],\n): ((args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void) | undefined {\n return capabilityHandlers?.find((handler) => handler.capabilityId === capabilityId)?.execute;\n}\n\n/*** Display a valid Expo-owned alert invocation without exposing alert as a generic action. */\nfunction executeExpoAlert(\n input: unknown,\n alertImpl: ((message: string) => void) | undefined,\n): ExpoRuntimeCapabilityExecutionResult {\n if (!isExpoAlertInput(input)) {\n return rejectCapabilityExecution({\n code: 'invalid-expo-alert-input',\n message: \"The 'expo.alert' capability requires an input object with only a string 'message'.\",\n });\n }\n if (!alertImpl) {\n return rejectCapabilityExecution({\n code: 'missing-expo-alert-handler',\n message: \"No Expo alert host callback is configured for 'expo.alert'.\",\n });\n }\n alertImpl(input.message);\n return { ok: true };\n}\n\n/*** Validate the serializable input accepted by the Expo alert capability. */\nfunction isExpoAlertInput(input: unknown): input is { readonly message: string } {\n if (\n typeof input !== 'object' ||\n input === null ||\n Array.isArray(input) ||\n !('message' in input)\n ) {\n return false;\n }\n const entries = Object.entries(input);\n return entries.length === 1 && typeof input.message === 'string';\n}\n\n/*** Report a rejected capability invocation with a diagnostic that a runtime owner can surface. */\nfunction rejectCapabilityExecution(\n diagnostic: ExpoRuntimeCapabilityDiagnostic,\n): ExpoRuntimeCapabilityExecutionResult {\n return { ok: false, diagnostics: [diagnostic] };\n}\n\n/*** Convert any foreign handler failure into a diagnostic-safe message. */\nfunction getFailureMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export {
|
|
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
|
-
export { type ExecuteExpoRuntimeCapabilityArgs, executeExpoRuntimeCapabilityAsync, type ExpoRuntimeCapabilityHandler, type ExpoRuntimeCapabilityHandlerArgs, type ExpoRuntimeRouteResolution, resolveExpoRuntimeRoutePath, } from './capabilityBridge';
|
|
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';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,2CAA2C,GAC5C,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,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 {
|
|
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,
|
|
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"]}
|
|
@@ -7,6 +7,17 @@ export interface ExpoRuntimeCapabilityHandler {
|
|
|
7
7
|
readonly capabilityId: Capability['id'];
|
|
8
8
|
readonly execute: (args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void;
|
|
9
9
|
}
|
|
10
|
+
export type ExpoRuntimeCapabilityDiagnosticCode = 'invalid-capability-descriptor' | 'invalid-expo-alert-input' | 'capability-handler-failed' | 'missing-capability-handler' | 'missing-expo-alert-handler';
|
|
11
|
+
export interface ExpoRuntimeCapabilityDiagnostic {
|
|
12
|
+
readonly code: ExpoRuntimeCapabilityDiagnosticCode;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
}
|
|
15
|
+
export type ExpoRuntimeCapabilityExecutionResult = {
|
|
16
|
+
readonly ok: true;
|
|
17
|
+
} | {
|
|
18
|
+
readonly ok: false;
|
|
19
|
+
readonly diagnostics: readonly ExpoRuntimeCapabilityDiagnostic[];
|
|
20
|
+
};
|
|
10
21
|
export interface ExecuteExpoRuntimeCapabilityArgs {
|
|
11
22
|
readonly capability: unknown;
|
|
12
23
|
readonly input?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoRuntimeCapability.d.ts","sourceRoot":"","sources":["../../src/types/expoRuntimeCapability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,gCAAgC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACpF;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD"}
|
|
1
|
+
{"version":3,"file":"expoRuntimeCapability.d.ts","sourceRoot":"","sources":["../../src/types/expoRuntimeCapability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,gCAAgC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACpF;AAED,MAAM,MAAM,mCAAmC,GAC3C,+BAA+B,GAC/B,0BAA0B,GAC1B,2BAA2B,GAC3B,4BAA4B,GAC5B,4BAA4B,CAAC;AAEjC,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,mCAAmC,CAAC;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,oCAAoC,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACrB;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,WAAW,EAAE,SAAS,+BAA+B,EAAE,CAAC;CAClE,CAAC;AAEN,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expoRuntimeCapability.js","sourceRoot":"","sources":["../../src/types/expoRuntimeCapability.ts"],"names":[],"mappings":"","sourcesContent":["import type { Capability } from '@ankhorage/contracts/capability';\n\nexport interface ExpoRuntimeCapabilityHandlerArgs {\n readonly capability: Capability;\n readonly input: unknown;\n}\n\nexport interface ExpoRuntimeCapabilityHandler {\n readonly capabilityId: Capability['id'];\n readonly execute: (args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void;\n}\n\nexport interface ExecuteExpoRuntimeCapabilityArgs {\n readonly capability: unknown;\n readonly input?: unknown;\n readonly capabilityHandlers?: readonly ExpoRuntimeCapabilityHandler[];\n readonly alertImpl?: (message: string) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expoRuntimeCapability.js","sourceRoot":"","sources":["../../src/types/expoRuntimeCapability.ts"],"names":[],"mappings":"","sourcesContent":["import type { Capability } from '@ankhorage/contracts/capability';\n\nexport interface ExpoRuntimeCapabilityHandlerArgs {\n readonly capability: Capability;\n readonly input: unknown;\n}\n\nexport interface ExpoRuntimeCapabilityHandler {\n readonly capabilityId: Capability['id'];\n readonly execute: (args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void;\n}\n\nexport type ExpoRuntimeCapabilityDiagnosticCode =\n | 'invalid-capability-descriptor'\n | 'invalid-expo-alert-input'\n | 'capability-handler-failed'\n | 'missing-capability-handler'\n | 'missing-expo-alert-handler';\n\nexport interface ExpoRuntimeCapabilityDiagnostic {\n readonly code: ExpoRuntimeCapabilityDiagnosticCode;\n readonly message: string;\n}\n\nexport type ExpoRuntimeCapabilityExecutionResult =\n | { readonly ok: true }\n | {\n readonly ok: false;\n readonly diagnostics: readonly ExpoRuntimeCapabilityDiagnostic[];\n };\n\nexport interface ExecuteExpoRuntimeCapabilityArgs {\n readonly capability: unknown;\n readonly input?: unknown;\n readonly capabilityHandlers?: readonly ExpoRuntimeCapabilityHandler[];\n readonly alertImpl?: (message: string) => void;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/expo-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
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": "^
|
|
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": "^
|
|
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
|
|
13
|
-
it('
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
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
|
|
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={
|
|
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 {
|
|
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
|
-
|
|
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/capabilityBridge.ts
CHANGED
|
@@ -2,6 +2,9 @@ export { executeExpoRuntimeCapabilityAsync } from './features/capabilities/execu
|
|
|
2
2
|
export { resolveExpoRuntimeRoutePath } from './features/navigation/resolveExpoRuntimeRoutePath';
|
|
3
3
|
export type {
|
|
4
4
|
ExecuteExpoRuntimeCapabilityArgs,
|
|
5
|
+
ExpoRuntimeCapabilityDiagnostic,
|
|
6
|
+
ExpoRuntimeCapabilityDiagnosticCode,
|
|
7
|
+
ExpoRuntimeCapabilityExecutionResult,
|
|
5
8
|
ExpoRuntimeCapabilityHandler,
|
|
6
9
|
ExpoRuntimeCapabilityHandlerArgs,
|
|
7
10
|
} from './types/expoRuntimeCapability';
|
|
@@ -4,7 +4,7 @@ import { describe, expect, test } from 'bun:test';
|
|
|
4
4
|
import { CAPABILITIES } from './capabilities';
|
|
5
5
|
import { executeExpoRuntimeCapabilityAsync, resolveExpoRuntimeRoutePath } from './capabilityBridge';
|
|
6
6
|
|
|
7
|
-
describe('expoCapabilityBridge', () => {
|
|
7
|
+
describe('expoCapabilityBridge Expo-owned capabilities', () => {
|
|
8
8
|
test('resolves dynamic route params and keeps unused params', () => {
|
|
9
9
|
expect(resolveExpoRuntimeRoutePath('/users/[id]', { id: 42, tab: 'profile' })).toEqual({
|
|
10
10
|
resolvedPath: '/users/42',
|
|
@@ -17,15 +17,74 @@ describe('expoCapabilityBridge', () => {
|
|
|
17
17
|
|
|
18
18
|
const expoAlertCapability = findCapabilityById('expo.alert');
|
|
19
19
|
|
|
20
|
-
await executeExpoRuntimeCapabilityAsync({
|
|
20
|
+
const result = await executeExpoRuntimeCapabilityAsync({
|
|
21
21
|
capability: expoAlertCapability,
|
|
22
22
|
input: { message: 'Saved' },
|
|
23
23
|
alertImpl: (message) => messages.push(message),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
expect(result).toEqual({ ok: true });
|
|
26
27
|
expect(messages).toEqual(['Saved']);
|
|
27
28
|
});
|
|
28
29
|
|
|
30
|
+
test('rejects malformed Expo alert input without invoking the host callback', async () => {
|
|
31
|
+
const messages: string[] = [];
|
|
32
|
+
|
|
33
|
+
const result = await executeExpoRuntimeCapabilityAsync({
|
|
34
|
+
capability: findCapabilityById('expo.alert'),
|
|
35
|
+
input: { message: 42 },
|
|
36
|
+
alertImpl: (message) => messages.push(message),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
expect(result).toEqual({
|
|
40
|
+
ok: false,
|
|
41
|
+
diagnostics: [
|
|
42
|
+
{
|
|
43
|
+
code: 'invalid-expo-alert-input',
|
|
44
|
+
message:
|
|
45
|
+
"The 'expo.alert' capability requires an input object with only a string 'message'.",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
expect(messages).toEqual([]);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('expoCapabilityBridge rejected Expo-owned capabilities', () => {
|
|
53
|
+
test('rejects a valid Expo alert invocation when no alert host is configured', async () => {
|
|
54
|
+
const result = await executeExpoRuntimeCapabilityAsync({
|
|
55
|
+
capability: findCapabilityById('expo.alert'),
|
|
56
|
+
input: { message: 'Saved' },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(result).toEqual({
|
|
60
|
+
ok: false,
|
|
61
|
+
diagnostics: [
|
|
62
|
+
{
|
|
63
|
+
code: 'missing-expo-alert-handler',
|
|
64
|
+
message: "No Expo alert host callback is configured for 'expo.alert'.",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('rejects an invalid capability descriptor', async () => {
|
|
71
|
+
const result = await executeExpoRuntimeCapabilityAsync({
|
|
72
|
+
capability: { id: 'expo.alert' },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(result).toEqual({
|
|
76
|
+
ok: false,
|
|
77
|
+
diagnostics: [
|
|
78
|
+
{
|
|
79
|
+
code: 'invalid-capability-descriptor',
|
|
80
|
+
message: 'The capability descriptor is invalid.',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('expoCapabilityBridge foreign capabilities', () => {
|
|
29
88
|
test('delegates foreign canonical capabilities to their configured runtime handler', async () => {
|
|
30
89
|
const calls: string[] = [];
|
|
31
90
|
const capability = {
|
|
@@ -35,7 +94,7 @@ describe('expoCapabilityBridge', () => {
|
|
|
35
94
|
binding: { kind: 'action', bindableAs: ['target'] },
|
|
36
95
|
} as const;
|
|
37
96
|
|
|
38
|
-
await executeExpoRuntimeCapabilityAsync({
|
|
97
|
+
const result = await executeExpoRuntimeCapabilityAsync({
|
|
39
98
|
capability,
|
|
40
99
|
input: { route: 'users/[id]', params: { id: 42 } },
|
|
41
100
|
capabilityHandlers: [
|
|
@@ -46,8 +105,65 @@ describe('expoCapabilityBridge', () => {
|
|
|
46
105
|
],
|
|
47
106
|
});
|
|
48
107
|
|
|
108
|
+
expect(result).toEqual({ ok: true });
|
|
49
109
|
expect(calls).toEqual(['navigator.navigate']);
|
|
50
110
|
});
|
|
111
|
+
|
|
112
|
+
test('rejects a foreign canonical capability without a configured runtime handler', async () => {
|
|
113
|
+
const result = await executeExpoRuntimeCapabilityAsync({
|
|
114
|
+
capability: {
|
|
115
|
+
id: 'theme.setMode',
|
|
116
|
+
owner: '@ankhorage/surface',
|
|
117
|
+
access: ['invoke'],
|
|
118
|
+
binding: { kind: 'action', bindableAs: ['target'] },
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(result).toEqual({
|
|
123
|
+
ok: false,
|
|
124
|
+
diagnostics: [
|
|
125
|
+
{
|
|
126
|
+
code: 'missing-capability-handler',
|
|
127
|
+
message: "No Expo Runtime capability handler is configured for 'theme.setMode'.",
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('expoCapabilityBridge failed foreign capability handlers', () => {
|
|
134
|
+
test('rejects synchronous and asynchronous foreign handler failures', async () => {
|
|
135
|
+
const capability = {
|
|
136
|
+
id: 'navigator.navigate',
|
|
137
|
+
owner: '@ankhorage/navigator',
|
|
138
|
+
access: ['invoke'],
|
|
139
|
+
binding: { kind: 'action', bindableAs: ['target'] },
|
|
140
|
+
} as const;
|
|
141
|
+
const failures = [
|
|
142
|
+
() => {
|
|
143
|
+
throw new Error('synchronous failure');
|
|
144
|
+
},
|
|
145
|
+
() => Promise.reject(new Error('asynchronous failure')),
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
for (const execute of failures) {
|
|
149
|
+
const result = await executeExpoRuntimeCapabilityAsync({
|
|
150
|
+
capability,
|
|
151
|
+
capabilityHandlers: [{ capabilityId: 'navigator.navigate', execute }],
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(result).toEqual({
|
|
155
|
+
ok: false,
|
|
156
|
+
diagnostics: [
|
|
157
|
+
{
|
|
158
|
+
code: 'capability-handler-failed',
|
|
159
|
+
message: `The handler for 'navigator.navigate' failed: ${
|
|
160
|
+
execute === failures[0] ? 'synchronous failure' : 'asynchronous failure'
|
|
161
|
+
}`,
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
51
167
|
});
|
|
52
168
|
|
|
53
169
|
function findCapabilityById(capabilityId: string): Capability {
|
|
@@ -3,6 +3,8 @@ import type { Capability } from '@ankhorage/contracts/capability';
|
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
5
|
ExecuteExpoRuntimeCapabilityArgs,
|
|
6
|
+
ExpoRuntimeCapabilityDiagnostic,
|
|
7
|
+
ExpoRuntimeCapabilityExecutionResult,
|
|
6
8
|
ExpoRuntimeCapabilityHandler,
|
|
7
9
|
ExpoRuntimeCapabilityHandlerArgs,
|
|
8
10
|
} from '../../types/expoRuntimeCapability';
|
|
@@ -10,16 +12,44 @@ import type {
|
|
|
10
12
|
/*** Execute an Expo-owned capability or delegate another canonical capability to its runtime handler. */
|
|
11
13
|
export async function executeExpoRuntimeCapabilityAsync(
|
|
12
14
|
args: ExecuteExpoRuntimeCapabilityArgs,
|
|
13
|
-
): Promise<
|
|
15
|
+
): Promise<ExpoRuntimeCapabilityExecutionResult> {
|
|
14
16
|
const { capability, input, capabilityHandlers, alertImpl } = args;
|
|
15
|
-
if (!isCapability(capability))
|
|
17
|
+
if (!isCapability(capability)) {
|
|
18
|
+
return rejectCapabilityExecution({
|
|
19
|
+
code: 'invalid-capability-descriptor',
|
|
20
|
+
message: 'The capability descriptor is invalid.',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
16
23
|
|
|
17
24
|
if (capability.id === 'expo.alert') {
|
|
18
|
-
executeExpoAlert(input, alertImpl);
|
|
19
|
-
return;
|
|
25
|
+
return executeExpoAlert(input, alertImpl);
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
const handler = findCapabilityHandler(capabilityHandlers, capability.id);
|
|
29
|
+
if (!handler) {
|
|
30
|
+
return rejectCapabilityExecution({
|
|
31
|
+
code: 'missing-capability-handler',
|
|
32
|
+
message: `No Expo Runtime capability handler is configured for '${capability.id}'.`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return executeForeignCapabilityHandlerAsync(handler, capability, input);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/*** Execute a foreign capability handler and translate its failure into the bridge result contract. */
|
|
39
|
+
async function executeForeignCapabilityHandlerAsync(
|
|
40
|
+
handler: (args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void,
|
|
41
|
+
capability: Capability,
|
|
42
|
+
input: unknown,
|
|
43
|
+
): Promise<ExpoRuntimeCapabilityExecutionResult> {
|
|
44
|
+
try {
|
|
45
|
+
await handler({ capability, input });
|
|
46
|
+
return { ok: true };
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return rejectCapabilityExecution({
|
|
49
|
+
code: 'capability-handler-failed',
|
|
50
|
+
message: `The handler for '${capability.id}' failed: ${getFailureMessage(error)}`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
23
53
|
}
|
|
24
54
|
|
|
25
55
|
/*** Find the configured executor for one canonical capability without dynamic record access. */
|
|
@@ -34,17 +64,45 @@ function findCapabilityHandler(
|
|
|
34
64
|
function executeExpoAlert(
|
|
35
65
|
input: unknown,
|
|
36
66
|
alertImpl: ((message: string) => void) | undefined,
|
|
37
|
-
):
|
|
38
|
-
if (!isExpoAlertInput(input))
|
|
39
|
-
|
|
67
|
+
): ExpoRuntimeCapabilityExecutionResult {
|
|
68
|
+
if (!isExpoAlertInput(input)) {
|
|
69
|
+
return rejectCapabilityExecution({
|
|
70
|
+
code: 'invalid-expo-alert-input',
|
|
71
|
+
message: "The 'expo.alert' capability requires an input object with only a string 'message'.",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (!alertImpl) {
|
|
75
|
+
return rejectCapabilityExecution({
|
|
76
|
+
code: 'missing-expo-alert-handler',
|
|
77
|
+
message: "No Expo alert host callback is configured for 'expo.alert'.",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
alertImpl(input.message);
|
|
81
|
+
return { ok: true };
|
|
40
82
|
}
|
|
41
83
|
|
|
42
84
|
/*** Validate the serializable input accepted by the Expo alert capability. */
|
|
43
85
|
function isExpoAlertInput(input: unknown): input is { readonly message: string } {
|
|
44
|
-
|
|
45
|
-
typeof input
|
|
46
|
-
input
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
86
|
+
if (
|
|
87
|
+
typeof input !== 'object' ||
|
|
88
|
+
input === null ||
|
|
89
|
+
Array.isArray(input) ||
|
|
90
|
+
!('message' in input)
|
|
91
|
+
) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const entries = Object.entries(input);
|
|
95
|
+
return entries.length === 1 && typeof input.message === 'string';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/*** Report a rejected capability invocation with a diagnostic that a runtime owner can surface. */
|
|
99
|
+
function rejectCapabilityExecution(
|
|
100
|
+
diagnostic: ExpoRuntimeCapabilityDiagnostic,
|
|
101
|
+
): ExpoRuntimeCapabilityExecutionResult {
|
|
102
|
+
return { ok: false, diagnostics: [diagnostic] };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/*** Convert any foreign handler failure into a diagnostic-safe message. */
|
|
106
|
+
function getFailureMessage(error: unknown): string {
|
|
107
|
+
return error instanceof Error ? error.message : String(error);
|
|
50
108
|
}
|
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,
|
|
@@ -22,6 +17,9 @@ export {
|
|
|
22
17
|
export {
|
|
23
18
|
type ExecuteExpoRuntimeCapabilityArgs,
|
|
24
19
|
executeExpoRuntimeCapabilityAsync,
|
|
20
|
+
type ExpoRuntimeCapabilityDiagnostic,
|
|
21
|
+
type ExpoRuntimeCapabilityDiagnosticCode,
|
|
22
|
+
type ExpoRuntimeCapabilityExecutionResult,
|
|
25
23
|
type ExpoRuntimeCapabilityHandler,
|
|
26
24
|
type ExpoRuntimeCapabilityHandlerArgs,
|
|
27
25
|
type ExpoRuntimeRouteResolution,
|
|
@@ -30,7 +28,10 @@ export {
|
|
|
30
28
|
export type { ComponentRegistry } from './componentRegistry';
|
|
31
29
|
export { createComponentRegistry } from './componentRegistry';
|
|
32
30
|
export { createExpoRuntimeRegistry } from './createExpoRuntimeRegistry';
|
|
33
|
-
export {
|
|
31
|
+
export {
|
|
32
|
+
ExpoBarcodeScannerAdapter,
|
|
33
|
+
type ExpoBarcodeScannerAdapterProps,
|
|
34
|
+
} from './ExpoBarcodeScannerAdapter';
|
|
34
35
|
export { ExpoRuntimeProviders, type ExpoRuntimeProvidersProps } from './ExpoRuntimeProviders';
|
|
35
36
|
export {
|
|
36
37
|
ExpoZoraIconFontProvider,
|
|
@@ -10,6 +10,25 @@ export interface ExpoRuntimeCapabilityHandler {
|
|
|
10
10
|
readonly execute: (args: ExpoRuntimeCapabilityHandlerArgs) => Promise<void> | void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export type ExpoRuntimeCapabilityDiagnosticCode =
|
|
14
|
+
| 'invalid-capability-descriptor'
|
|
15
|
+
| 'invalid-expo-alert-input'
|
|
16
|
+
| 'capability-handler-failed'
|
|
17
|
+
| 'missing-capability-handler'
|
|
18
|
+
| 'missing-expo-alert-handler';
|
|
19
|
+
|
|
20
|
+
export interface ExpoRuntimeCapabilityDiagnostic {
|
|
21
|
+
readonly code: ExpoRuntimeCapabilityDiagnosticCode;
|
|
22
|
+
readonly message: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type ExpoRuntimeCapabilityExecutionResult =
|
|
26
|
+
| { readonly ok: true }
|
|
27
|
+
| {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly diagnostics: readonly ExpoRuntimeCapabilityDiagnostic[];
|
|
30
|
+
};
|
|
31
|
+
|
|
13
32
|
export interface ExecuteExpoRuntimeCapabilityArgs {
|
|
14
33
|
readonly capability: unknown;
|
|
15
34
|
readonly input?: unknown;
|