@chipmobilesdk/rn-camera 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +130 -0
- package/README.md +11 -7
- package/lib/commonjs/config/types.js +54 -0
- package/lib/commonjs/config/types.js.map +1 -0
- package/lib/commonjs/core/capabilities.js +45 -0
- package/lib/commonjs/core/capabilities.js.map +1 -0
- package/lib/commonjs/core/captureController.js +107 -0
- package/lib/commonjs/core/captureController.js.map +1 -0
- package/lib/commonjs/core/contract.js +16 -0
- package/lib/commonjs/core/contract.js.map +1 -0
- package/lib/commonjs/core/controller.js +452 -0
- package/lib/commonjs/core/controller.js.map +1 -0
- package/lib/commonjs/core/sessionMachine.js +116 -0
- package/lib/commonjs/core/sessionMachine.js.map +1 -0
- package/lib/commonjs/core/sessionRuntime.js +218 -0
- package/lib/commonjs/core/sessionRuntime.js.map +1 -0
- package/lib/commonjs/diagnostics/errors.js +86 -0
- package/lib/commonjs/diagnostics/errors.js.map +1 -0
- package/lib/commonjs/diagnostics/logger.js +40 -0
- package/lib/commonjs/diagnostics/logger.js.map +1 -0
- package/lib/commonjs/geometry/coordinateMapping.js +156 -0
- package/lib/commonjs/geometry/coordinateMapping.js.map +1 -0
- package/lib/commonjs/index.js +130 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/native/cameraEngine.js +86 -0
- package/lib/commonjs/native/cameraEngine.js.map +1 -0
- package/lib/commonjs/native/visionCameraPeer.js +28 -0
- package/lib/commonjs/native/visionCameraPeer.js.map +1 -0
- package/lib/commonjs/native/visionSurface.js +38 -0
- package/lib/commonjs/native/visionSurface.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permissions/permissionPort.js +105 -0
- package/lib/commonjs/permissions/permissionPort.js.map +1 -0
- package/lib/commonjs/react/CameraPreview.js +136 -0
- package/lib/commonjs/react/CameraPreview.js.map +1 -0
- package/lib/commonjs/react/VisionCameraFeed.js +196 -0
- package/lib/commonjs/react/VisionCameraFeed.js.map +1 -0
- package/lib/commonjs/react/hooks.js +50 -0
- package/lib/commonjs/react/hooks.js.map +1 -0
- package/lib/commonjs/storage/artifactStore.js +98 -0
- package/lib/commonjs/storage/artifactStore.js.map +1 -0
- package/lib/commonjs/testing/conformance.js +109 -0
- package/lib/commonjs/testing/conformance.js.map +1 -0
- package/lib/commonjs/testing/index.js +50 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/testCameraAdapter.js +191 -0
- package/lib/commonjs/testing/testCameraAdapter.js.map +1 -0
- package/lib/module/config/types.js +49 -0
- package/lib/module/config/types.js.map +1 -0
- package/lib/module/core/capabilities.js +37 -0
- package/lib/module/core/capabilities.js.map +1 -0
- package/lib/module/core/captureController.js +98 -0
- package/lib/module/core/captureController.js.map +1 -0
- package/lib/module/core/contract.js +12 -0
- package/lib/module/core/contract.js.map +1 -0
- package/lib/module/core/controller.js +442 -0
- package/lib/module/core/controller.js.map +1 -0
- package/lib/module/core/sessionMachine.js +109 -0
- package/lib/module/core/sessionMachine.js.map +1 -0
- package/lib/module/core/sessionRuntime.js +215 -0
- package/lib/module/core/sessionRuntime.js.map +1 -0
- package/lib/module/diagnostics/errors.js +79 -0
- package/lib/module/diagnostics/errors.js.map +1 -0
- package/lib/module/diagnostics/logger.js +35 -0
- package/lib/module/diagnostics/logger.js.map +1 -0
- package/lib/module/geometry/coordinateMapping.js +149 -0
- package/lib/module/geometry/coordinateMapping.js.map +1 -0
- package/lib/module/index.js +44 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native/cameraEngine.js +83 -0
- package/lib/module/native/cameraEngine.js.map +1 -0
- package/lib/module/native/visionCameraPeer.js +24 -0
- package/lib/module/native/visionCameraPeer.js.map +1 -0
- package/lib/module/native/visionSurface.js +34 -0
- package/lib/module/native/visionSurface.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permissions/permissionPort.js +101 -0
- package/lib/module/permissions/permissionPort.js.map +1 -0
- package/lib/module/react/CameraPreview.js +130 -0
- package/lib/module/react/CameraPreview.js.map +1 -0
- package/lib/module/react/VisionCameraFeed.js +190 -0
- package/lib/module/react/VisionCameraFeed.js.map +1 -0
- package/lib/module/react/hooks.js +45 -0
- package/lib/module/react/hooks.js.map +1 -0
- package/lib/module/storage/artifactStore.js +94 -0
- package/lib/module/storage/artifactStore.js.map +1 -0
- package/lib/module/testing/conformance.js +102 -0
- package/lib/module/testing/conformance.js.map +1 -0
- package/lib/module/testing/index.js +13 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/testCameraAdapter.js +185 -0
- package/lib/module/testing/testCameraAdapter.js.map +1 -0
- package/lib/typescript/commonjs/config/types.d.ts +122 -0
- package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/capabilities.d.ts +16 -0
- package/lib/typescript/commonjs/core/capabilities.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/captureController.d.ts +48 -0
- package/lib/typescript/commonjs/core/captureController.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/contract.d.ts +92 -0
- package/lib/typescript/commonjs/core/contract.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/controller.d.ts +15 -0
- package/lib/typescript/commonjs/core/controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/sessionMachine.d.ts +46 -0
- package/lib/typescript/commonjs/core/sessionMachine.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/sessionRuntime.d.ts +64 -0
- package/lib/typescript/commonjs/core/sessionRuntime.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts +24 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/logger.d.ts +24 -0
- package/lib/typescript/commonjs/diagnostics/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/coordinateMapping.d.ts +23 -0
- package/lib/typescript/commonjs/geometry/coordinateMapping.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +32 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/cameraEngine.d.ts +50 -0
- package/lib/typescript/commonjs/native/cameraEngine.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/visionCameraPeer.d.ts +2 -0
- package/lib/typescript/commonjs/native/visionCameraPeer.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/visionSurface.d.ts +41 -0
- package/lib/typescript/commonjs/native/visionSurface.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permissions/permissionPort.d.ts +24 -0
- package/lib/typescript/commonjs/permissions/permissionPort.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/CameraPreview.d.ts +25 -0
- package/lib/typescript/commonjs/react/CameraPreview.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/VisionCameraFeed.d.ts +31 -0
- package/lib/typescript/commonjs/react/VisionCameraFeed.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/hooks.d.ts +12 -0
- package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/storage/artifactStore.d.ts +54 -0
- package/lib/typescript/commonjs/storage/artifactStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts +37 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +12 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/testCameraAdapter.d.ts +61 -0
- package/lib/typescript/commonjs/testing/testCameraAdapter.d.ts.map +1 -0
- package/lib/typescript/module/config/types.d.ts +122 -0
- package/lib/typescript/module/config/types.d.ts.map +1 -0
- package/lib/typescript/module/core/capabilities.d.ts +16 -0
- package/lib/typescript/module/core/capabilities.d.ts.map +1 -0
- package/lib/typescript/module/core/captureController.d.ts +48 -0
- package/lib/typescript/module/core/captureController.d.ts.map +1 -0
- package/lib/typescript/module/core/contract.d.ts +92 -0
- package/lib/typescript/module/core/contract.d.ts.map +1 -0
- package/lib/typescript/module/core/controller.d.ts +15 -0
- package/lib/typescript/module/core/controller.d.ts.map +1 -0
- package/lib/typescript/module/core/sessionMachine.d.ts +46 -0
- package/lib/typescript/module/core/sessionMachine.d.ts.map +1 -0
- package/lib/typescript/module/core/sessionRuntime.d.ts +64 -0
- package/lib/typescript/module/core/sessionRuntime.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/errors.d.ts +24 -0
- package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/logger.d.ts +24 -0
- package/lib/typescript/module/diagnostics/logger.d.ts.map +1 -0
- package/lib/typescript/module/geometry/coordinateMapping.d.ts +23 -0
- package/lib/typescript/module/geometry/coordinateMapping.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +32 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/native/cameraEngine.d.ts +50 -0
- package/lib/typescript/module/native/cameraEngine.d.ts.map +1 -0
- package/lib/typescript/module/native/visionCameraPeer.d.ts +2 -0
- package/lib/typescript/module/native/visionCameraPeer.d.ts.map +1 -0
- package/lib/typescript/module/native/visionSurface.d.ts +41 -0
- package/lib/typescript/module/native/visionSurface.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permissions/permissionPort.d.ts +24 -0
- package/lib/typescript/module/permissions/permissionPort.d.ts.map +1 -0
- package/lib/typescript/module/react/CameraPreview.d.ts +25 -0
- package/lib/typescript/module/react/CameraPreview.d.ts.map +1 -0
- package/lib/typescript/module/react/VisionCameraFeed.d.ts +31 -0
- package/lib/typescript/module/react/VisionCameraFeed.d.ts.map +1 -0
- package/lib/typescript/module/react/hooks.d.ts +12 -0
- package/lib/typescript/module/react/hooks.d.ts.map +1 -0
- package/lib/typescript/module/storage/artifactStore.d.ts +54 -0
- package/lib/typescript/module/storage/artifactStore.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance.d.ts +37 -0
- package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +12 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/testCameraAdapter.d.ts +61 -0
- package/lib/typescript/module/testing/testCameraAdapter.d.ts.map +1 -0
- package/package.json +49 -13
- package/skills/sdk-rn-camera/SKILL.md +6 -3
- package/src/index.ts +4 -12
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error taxonomy (FR-044) and redaction helper (FR-038).
|
|
3
|
+
*
|
|
4
|
+
* The taxonomy exists so consuming apps can branch on `code` and `recoverable`
|
|
5
|
+
* instead of string-matching messages. Messages never carry file paths or image
|
|
6
|
+
* payloads — `redact` is applied before any value reaches a log sink.
|
|
7
|
+
*/
|
|
8
|
+
import { SdkError } from '@chipmobilesdk/rn-core';
|
|
9
|
+
export type CameraErrorCode = 'permissionDenied' | 'cameraUnavailable' | 'cameraBlocked' | 'cameraInUse' | 'sessionConflict' | 'notReady' | 'captureInProgress' | 'captureFailed' | 'storageFailure' | 'unsupportedCapability' | 'interrupted';
|
|
10
|
+
/** The package's error; an `SdkError` (`@chipmobilesdk/rn-core`) with `pkg: 'rn-camera'`. */
|
|
11
|
+
export declare class CameraError extends SdkError<CameraErrorCode> {
|
|
12
|
+
constructor(code: CameraErrorCode, message?: string);
|
|
13
|
+
/** @deprecated Use `retryable`, the name every SDK package shares. */
|
|
14
|
+
get recoverable(): boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function isCameraError(value: unknown): value is CameraError;
|
|
17
|
+
/**
|
|
18
|
+
* Strips paths and payload-shaped strings from a value before logging (FR-038).
|
|
19
|
+
* Recurses through plain objects and arrays; known-sensitive keys are dropped
|
|
20
|
+
* wholesale rather than pattern-matched, since a bare filename has no separator
|
|
21
|
+
* for the path pattern to catch.
|
|
22
|
+
*/
|
|
23
|
+
export declare function redact(value: unknown): unknown;
|
|
24
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAiC,QAAQ,EAAkB,MAAM,wBAAwB,CAAC;AAEjG,MAAM,MAAM,eAAe,GACxB,kBAAkB,GAClB,mBAAmB,GACnB,eAAe,GACf,aAAa,GACb,iBAAiB,GACjB,UAAU,GACV,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,uBAAuB,GACvB,aAAa,CAAC;AAejB,6FAA6F;AAC7F,qBAAa,WAAY,SAAQ,QAAQ,CAAC,eAAe,CAAC;gBAC7C,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,MAAM;IAKnD,sEAAsE;IACtE,IAAI,WAAW,IAAI,OAAO,CAEzB;CACD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAeD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAqB9C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional consumer-supplied logger (research R4).
|
|
3
|
+
*
|
|
4
|
+
* The default is no logging at all, so FR-038 holds whether or not a consumer
|
|
5
|
+
* opts in. Event bodies carry codes and states only — never file paths, never
|
|
6
|
+
* image data — so an opted-in logger still cannot leak an image path.
|
|
7
|
+
*/
|
|
8
|
+
export type CameraLogEventType = 'session' | 'permission' | 'capture' | 'capability' | 'cleanup';
|
|
9
|
+
export interface CameraLogEvent {
|
|
10
|
+
readonly type: CameraLogEventType;
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly recoverable?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface CameraLogger {
|
|
15
|
+
log(event: CameraLogEvent): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Every event also reaches the app's SDK sinks (`installSdkSink`, CORE-08), as
|
|
19
|
+
* `<type>.<code>`: the same code-and-state body, so nothing new can leak.
|
|
20
|
+
*/
|
|
21
|
+
export declare function withSdkSinks(logger: CameraLogger): CameraLogger;
|
|
22
|
+
/** No-op logger used when the consumer supplies none. */
|
|
23
|
+
export declare const silentLogger: CameraLogger;
|
|
24
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAEjG,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3C;AAED,MAAM,WAAW,YAAY;IAC5B,GAAG,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CACjC;AAID;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAW/D;AAED,yDAAyD;AACzD,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidirectional coordinate mapping between preview space and captured-image
|
|
3
|
+
* space (FR-036, SC-012).
|
|
4
|
+
*
|
|
5
|
+
* Pure functions with no native involvement (research R5). Everything needed is
|
|
6
|
+
* already known in JavaScript, so keeping this pure is what makes the 2-pixel
|
|
7
|
+
* round-trip tolerance verifiable in CI rather than only on a device.
|
|
8
|
+
*
|
|
9
|
+
* Composition order, preview -> image: undo mirror, undo letterbox/crop offset,
|
|
10
|
+
* undo scale, undo orientation. Image -> preview reverses it exactly.
|
|
11
|
+
*/
|
|
12
|
+
import type { Point, PreviewGeometry, Rect } from '../config/types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Maps a preview-space point into captured-image space. Points outside the
|
|
15
|
+
* visible region stay representable (they fall outside the image bounds) rather
|
|
16
|
+
* than being clamped to an edge, so callers can detect an out-of-frame overlay.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mapPointToImage(point: Point, geometry: PreviewGeometry): Point;
|
|
19
|
+
/** Maps a captured-image point into preview space. Exact inverse of the above. */
|
|
20
|
+
export declare function mapPointToPreview(point: Point, geometry: PreviewGeometry): Point;
|
|
21
|
+
export declare function mapRectToImage(rect: Rect, geometry: PreviewGeometry): Rect;
|
|
22
|
+
export declare function mapRectToPreview(rect: Rect, geometry: PreviewGeometry): Rect;
|
|
23
|
+
//# sourceMappingURL=coordinateMapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinateMapping.d.ts","sourceRoot":"","sources":["../../../../src/geometry/coordinateMapping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,oBAAiB,CAAC;AAwEpE;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,KAAK,CAI9E;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,KAAK,CAQhF;AAYD,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAK1E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAK5E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @chipmobilesdk/rn-camera — reusable camera infrastructure for
|
|
3
|
+
* ChipMobileSdk-family React Native apps.
|
|
4
|
+
*
|
|
5
|
+
* This is the single public entrypoint (LIB-003). Modules under `core/`,
|
|
6
|
+
* `native/`, `permissions/`, `storage/`, `geometry/`, `diagnostics/`, and
|
|
7
|
+
* `testing/` are private; import them only through this file.
|
|
8
|
+
*
|
|
9
|
+
* The package contains no business logic, sends nothing over the network, and
|
|
10
|
+
* writes nothing to the device gallery. Phase one runs no on-device inference —
|
|
11
|
+
* see the reserved frame-processing extension point in the README.
|
|
12
|
+
*/
|
|
13
|
+
export type { ArtifactOwnership, CameraErrorLike, CameraPermissionState, CameraPosition, CameraState, CapabilityProfile, CapturedImage, CaptureRequest, FlashMode, Known, Maybe, Point, PreviewGeometry, Rect, ResizeMode, SessionStatus, StartOptions, Unavailable, } from './config/types.js';
|
|
14
|
+
export { known, unavailable } from './config/types.js';
|
|
15
|
+
export { createCameraController, DEFAULT_TEMPORARY_TTL_MS } from './core/controller.js';
|
|
16
|
+
export type { AppStatus, CameraController, CameraControllerOptions } from './core/controller.js';
|
|
17
|
+
export type { CameraEngine } from './native/cameraEngine.js';
|
|
18
|
+
export type { SurfaceInfo, SurfaceRegistry, VisionSurface } from './native/visionSurface.js';
|
|
19
|
+
export { createSurfaceRegistry } from './native/visionSurface.js';
|
|
20
|
+
export { createVisionCameraEngine } from './native/cameraEngine.js';
|
|
21
|
+
export type { PermissionPort } from './permissions/permissionPort.js';
|
|
22
|
+
export { createVisionCameraPermissions } from './permissions/permissionPort.js';
|
|
23
|
+
export type { ArtifactStore, FileSystemBridge, StoreOptions } from './storage/artifactStore.js';
|
|
24
|
+
export { createArtifactStore, createCacheArtifactStore } from './storage/artifactStore.js';
|
|
25
|
+
export { CameraPreview } from './react/CameraPreview.js';
|
|
26
|
+
export type { CameraPreviewProps } from './react/CameraPreview.js';
|
|
27
|
+
export { useCameraController, useCameraState } from './react/hooks.js';
|
|
28
|
+
export { mapPointToImage, mapPointToPreview, mapRectToImage, mapRectToPreview, } from './geometry/coordinateMapping.js';
|
|
29
|
+
export { CameraError, isCameraError, redact } from './diagnostics/errors.js';
|
|
30
|
+
export type { CameraErrorCode } from './diagnostics/errors.js';
|
|
31
|
+
export type { CameraLogEvent, CameraLogEventType, CameraLogger } from './diagnostics/logger.js';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,YAAY,EACX,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,SAAS,EACT,KAAK,EACL,KAAK,EACL,KAAK,EACL,eAAe,EACf,IAAI,EACJ,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,GACX,MAAM,mBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAgB,CAAC;AAGpD,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,sBAAmB,CAAC;AACrF,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sBAAmB,CAAC;AAG9F,YAAY,EAAE,YAAY,EAAE,MAAM,0BAAuB,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2BAAwB,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAAwB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAAuB,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,iCAA8B,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAA8B,CAAC;AAC7E,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,4BAAyB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,4BAAyB,CAAC;AAGxF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAAuB,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAAuB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAe,CAAC;AAGpE,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAChB,MAAM,iCAA8B,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,yBAAsB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAsB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,yBAAsB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CameraEngine port + default react-native-vision-camera adapter.
|
|
3
|
+
*
|
|
4
|
+
* This is the only module that knows a native camera library exists. The
|
|
5
|
+
* default adapter lazily requires it, mirroring
|
|
6
|
+
* `packages/rn-auth/src/tokens/secureStore.ts`, so unit tests that inject a
|
|
7
|
+
* fake never load native code.
|
|
8
|
+
*
|
|
9
|
+
* Preview frames never cross this boundary: `capture` returns a file reference
|
|
10
|
+
* plus metadata and nothing else (PERF-002, FR-021a).
|
|
11
|
+
*
|
|
12
|
+
* Targets the VisionCamera v5 API, where devices come from an async
|
|
13
|
+
* `CameraDeviceFactory` and capture runs through the photo output owned by the
|
|
14
|
+
* mounted preview surface (see `visionSurface`).
|
|
15
|
+
*/
|
|
16
|
+
import type { CapabilityProfile, CapturedImage, CaptureRequest, StartOptions } from '../config/types.js';
|
|
17
|
+
import type { CameraErrorCode } from '../diagnostics/errors.js';
|
|
18
|
+
import { type VisionSurface } from './visionSurface.js';
|
|
19
|
+
export interface CameraEngine {
|
|
20
|
+
start(options: StartOptions): Promise<void>;
|
|
21
|
+
stop(): Promise<void>;
|
|
22
|
+
capture(request: CaptureRequest): Promise<CapturedImage>;
|
|
23
|
+
setTorch(enabled: boolean): Promise<void>;
|
|
24
|
+
getCapabilities(): Promise<CapabilityProfile>;
|
|
25
|
+
/**
|
|
26
|
+
* True when `start()` only prepares the engine and the session becomes
|
|
27
|
+
* active once a mounted preview surface reports frames. The controller then
|
|
28
|
+
* waits for that report instead of calling the session active immediately,
|
|
29
|
+
* and times out rather than sitting in `starting` forever (CAM-08).
|
|
30
|
+
*/
|
|
31
|
+
readonly awaitsSurfaceStart?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Attaches the mounted preview surface this engine captures through.
|
|
34
|
+
* Returns the detach function. Engines that own their own session omit it.
|
|
35
|
+
*/
|
|
36
|
+
attachSurface?(surface: VisionSurface): () => void;
|
|
37
|
+
/**
|
|
38
|
+
* The engine lost the camera: another app took it, a call came in, the
|
|
39
|
+
* device was disconnected. The controller tears the session down with this
|
|
40
|
+
* code rather than leaving a frozen preview (CAM-19).
|
|
41
|
+
*/
|
|
42
|
+
subscribeToInterruptions?(listener: (code: CameraErrorCode) => void): () => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Default engine. VisionCamera drives the preview through its own React
|
|
46
|
+
* component, so this adapter owns capability discovery while `CameraPreview`
|
|
47
|
+
* owns the rendered surface and the photo output that capture runs through.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createVisionCameraEngine(): CameraEngine;
|
|
50
|
+
//# sourceMappingURL=cameraEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraEngine.d.ts","sourceRoot":"","sources":["../../../../src/native/cameraEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACX,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,MAAM,oBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAAuB,CAAC;AAE7D,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,oBAAiB,CAAC;AAE5E,MAAM,WAAW,YAAY;IAC5B,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzD,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC;;;OAGG;IACH,aAAa,CAAC,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,IAAI,CAAC;IACnD;;;;OAIG;IACH,wBAAwB,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACjF;AASD;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,YAAY,CAwEvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visionCameraPeer.d.ts","sourceRoot":"","sources":["../../../../src/native/visionCameraPeer.ts"],"names":[],"mappings":"AAqBA,wBAAgB,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAQvC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The port between a mounted preview surface and an engine.
|
|
3
|
+
*
|
|
4
|
+
* VisionCamera v5 owns capture through the session the `<Camera>` view
|
|
5
|
+
* configures, so the photo output only exists while a surface is mounted. The
|
|
6
|
+
* engine is created before any surface exists, so the surface attaches itself
|
|
7
|
+
* to the engine and the engine reads it back at capture time.
|
|
8
|
+
*
|
|
9
|
+
* The registry belongs to an engine instance, not to the module. A module-level
|
|
10
|
+
* slot meant two controllers — two screens in a stack — shared one, so a
|
|
11
|
+
* capture could run through the other screen's surface (CAM-20).
|
|
12
|
+
*/
|
|
13
|
+
import type { CameraErrorCode } from '../diagnostics/errors.js';
|
|
14
|
+
import type { CapturedImage, CaptureRequest } from '../config/types.js';
|
|
15
|
+
/** What the mounted preview actually is, once the device and format are known. */
|
|
16
|
+
export interface SurfaceInfo {
|
|
17
|
+
/** Capture dimensions of the selected format, in pixels. */
|
|
18
|
+
readonly imageWidth: number;
|
|
19
|
+
readonly imageHeight: number;
|
|
20
|
+
/** Clockwise degrees the image is rotated relative to the preview. */
|
|
21
|
+
readonly orientation: number;
|
|
22
|
+
/** The position of the device actually mounted, whatever was asked for. */
|
|
23
|
+
readonly cameraPosition: 'front' | 'back';
|
|
24
|
+
}
|
|
25
|
+
export interface VisionSurface {
|
|
26
|
+
capture(request: CaptureRequest): Promise<CapturedImage>;
|
|
27
|
+
}
|
|
28
|
+
/** What a surface reports back about its own session. */
|
|
29
|
+
export interface SurfaceEvents {
|
|
30
|
+
/** The preview is running: frames are arriving. */
|
|
31
|
+
onStarted(info: SurfaceInfo): void;
|
|
32
|
+
/** The session failed or was taken away (another app, a phone call). */
|
|
33
|
+
onFailed(code: CameraErrorCode): void;
|
|
34
|
+
}
|
|
35
|
+
export interface SurfaceRegistry {
|
|
36
|
+
/** Attaches the mounted surface. Returns the detach function. */
|
|
37
|
+
attach(surface: VisionSurface): () => void;
|
|
38
|
+
current(): VisionSurface | null;
|
|
39
|
+
}
|
|
40
|
+
export declare function createSurfaceRegistry(): SurfaceRegistry;
|
|
41
|
+
//# sourceMappingURL=visionSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visionSurface.d.ts","sourceRoot":"","sources":["../../../../src/native/visionSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAiB,CAAC;AAErE,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1C;AAED,MAAM,WAAW,aAAa;IAC7B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACzD;AAED,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC7B,mDAAmD;IACnD,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC/B,iEAAiE;IACjE,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,IAAI,CAAC;IAC3C,OAAO,IAAI,aAAa,GAAG,IAAI,CAAC;CAChC;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAavD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PermissionPort + default react-native-vision-camera adapter (FR-004..FR-008).
|
|
3
|
+
*
|
|
4
|
+
* `getStatus` never prompts and never opens a session (FR-005); only `request`
|
|
5
|
+
* may prompt, and it refuses to re-prompt once the OS reports a permanent
|
|
6
|
+
* denial (FR-006). The default adapter lazily requires the native module so
|
|
7
|
+
* unit tests that inject a fake never load native code — same approach as
|
|
8
|
+
* `packages/rn-auth/src/tokens/secureStore.ts`.
|
|
9
|
+
*
|
|
10
|
+
* The adapter targets the VisionCamera v5 API: permissions live on the
|
|
11
|
+
* `VisionCamera` hybrid object, not on the `Camera` component (which carries no
|
|
12
|
+
* statics since v5).
|
|
13
|
+
*/
|
|
14
|
+
import type { CameraPermissionState } from '../config/types.js';
|
|
15
|
+
export interface PermissionPort {
|
|
16
|
+
/** Reads current status. MUST NOT prompt or start a session (FR-005). */
|
|
17
|
+
getStatus(): Promise<CameraPermissionState>;
|
|
18
|
+
/** Explicitly requests permission (FR-006). */
|
|
19
|
+
request(): Promise<CameraPermissionState>;
|
|
20
|
+
/** Notifies on external changes, e.g. revocation in Settings (FR-007). */
|
|
21
|
+
subscribe(listener: (state: CameraPermissionState) => void): () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createVisionCameraPermissions(): PermissionPort;
|
|
24
|
+
//# sourceMappingURL=permissionPort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissionPort.d.ts","sourceRoot":"","sources":["../../../../src/permissions/permissionPort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAiB,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC9B,yEAAyE;IACzE,SAAS,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC5C,+CAA+C;IAC/C,OAAO,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC1C,0EAA0E;IAC1E,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACxE;AAwBD,wBAAgB,6BAA6B,IAAI,cAAc,CAoE9D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera preview surface (FR-009..FR-013, UX-001, UX-003).
|
|
3
|
+
*
|
|
4
|
+
* Renders the camera feed and nothing else: no shutter button, no permission
|
|
5
|
+
* copy, no error text, and no theme dependency. Consuming apps draw their own
|
|
6
|
+
* controls and overlays through `children`, positioned with the geometry
|
|
7
|
+
* reported by `onGeometryChange`.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { type AccessibilityRole, type StyleProp, type ViewStyle } from 'react-native';
|
|
11
|
+
import type { PreviewGeometry, ResizeMode } from '../config/types.js';
|
|
12
|
+
import type { CameraController } from '../core/controller.js';
|
|
13
|
+
export interface CameraPreviewProps {
|
|
14
|
+
readonly controller: CameraController;
|
|
15
|
+
readonly resizeMode?: ResizeMode;
|
|
16
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
17
|
+
readonly onGeometryChange?: (geometry: PreviewGeometry) => void;
|
|
18
|
+
/** Forwarded untouched; the package never overrides consumer a11y (UX-003). */
|
|
19
|
+
readonly accessibilityLabel?: string;
|
|
20
|
+
readonly accessibilityRole?: AccessibilityRole;
|
|
21
|
+
/** Overlay layer rendered above the feed. */
|
|
22
|
+
readonly children?: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export declare const CameraPreview: React.FC<CameraPreviewProps>;
|
|
25
|
+
//# sourceMappingURL=CameraPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraPreview.d.ts","sourceRoot":"","sources":["../../../../src/react/CameraPreview.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAoD,MAAM,OAAO,CAAC;AACzE,OAAO,EAEN,KAAK,iBAAiB,EAEtB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;AAM3D,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IAChE,+EAA+E;IAC/E,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAC/C,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC;AAiBD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAqHtD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The live VisionCamera surface rendered inside `CameraPreview`.
|
|
3
|
+
*
|
|
4
|
+
* Split into its own module so `CameraPreview` can require it lazily: consumers
|
|
5
|
+
* that only use the pure utilities or the test adapter never load the native
|
|
6
|
+
* module, while the hooks this component needs (`useCameraDevice`,
|
|
7
|
+
* `usePhotoOutput`) can still be called normally.
|
|
8
|
+
*
|
|
9
|
+
* It also owns capture. In VisionCamera v5 the photo output belongs to the
|
|
10
|
+
* session the `<Camera>` view configures, so the output only exists while this
|
|
11
|
+
* surface is mounted; it is published to the engine through `visionSurface`.
|
|
12
|
+
*/
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { type CameraPosition, type ResizeMode } from '../config/types.js';
|
|
15
|
+
import { type CameraErrorCode } from '../diagnostics/errors.js';
|
|
16
|
+
import type { SurfaceInfo, VisionSurface } from '../native/visionSurface.js';
|
|
17
|
+
export interface VisionCameraFeedProps {
|
|
18
|
+
readonly cameraPosition: CameraPosition;
|
|
19
|
+
readonly resizeMode: ResizeMode;
|
|
20
|
+
readonly torchEnabled: boolean;
|
|
21
|
+
/** False while the session is paused: the view stays mounted, the camera stops. */
|
|
22
|
+
readonly isActive: boolean;
|
|
23
|
+
/** Attaches this surface to the engine that captures through it. */
|
|
24
|
+
readonly attachSurface: (surface: VisionSurface) => () => void;
|
|
25
|
+
/** The preview is running; carries what the mounted device turned out to be. */
|
|
26
|
+
readonly onStarted: (info: SurfaceInfo) => void;
|
|
27
|
+
/** The session failed or the camera was taken away. */
|
|
28
|
+
readonly onFailed: (code: CameraErrorCode) => void;
|
|
29
|
+
}
|
|
30
|
+
export declare const VisionCameraFeed: React.FC<VisionCameraFeedProps>;
|
|
31
|
+
//# sourceMappingURL=VisionCameraFeed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionCameraFeed.d.ts","sourceRoot":"","sources":["../../../../src/react/VisionCameraFeed.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAS5D,OAAO,EAGN,KAAK,cAAc,EAInB,KAAK,UAAU,EACf,MAAM,oBAAiB,CAAC;AAEzB,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,0BAAuB,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,4BAAyB,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,MAAM,IAAI,CAAC;IAC/D,gFAAgF;IAChF,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;CACnD;AA0ID,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAmD5D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React bindings for the camera controller.
|
|
3
|
+
*
|
|
4
|
+
* `useCameraController` owns the controller lifetime and disposes it on
|
|
5
|
+
* unmount, which is what guarantees the camera is released when a screen goes
|
|
6
|
+
* away (FR-016).
|
|
7
|
+
*/
|
|
8
|
+
import type { CameraState } from '../config/types.js';
|
|
9
|
+
import { type CameraController, type CameraControllerOptions } from '../core/controller.js';
|
|
10
|
+
export declare function useCameraController(options: CameraControllerOptions): CameraController;
|
|
11
|
+
export declare function useCameraState(controller: CameraController): CameraState;
|
|
12
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAiB,CAAC;AACnD,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,MAAM,uBAAoB,CAAC;AAE5B,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,gBAAgB,CA0BtF;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,gBAAgB,GAAG,WAAW,CAUxE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArtifactStore port + default cache-directory adapter (FR-026..FR-029).
|
|
3
|
+
*
|
|
4
|
+
* Package-owned artifacts live in a dedicated `rn-camera` subdirectory of the
|
|
5
|
+
* platform cache directory (research R6). That dedicated prefix is what makes
|
|
6
|
+
* ownership checkable rather than advisory: `owns()` is a path-prefix test, so
|
|
7
|
+
* the package can refuse to delete anything it did not create (FR-028).
|
|
8
|
+
*/
|
|
9
|
+
export interface ArtifactStore {
|
|
10
|
+
/** Absolute path of the package-owned temporary directory. */
|
|
11
|
+
temporaryDirectory(): string;
|
|
12
|
+
/** True only for paths the package created (FR-028). */
|
|
13
|
+
owns(uri: string): boolean;
|
|
14
|
+
/** Deletes an artifact. Resolves even if already gone (FR-027). */
|
|
15
|
+
remove(uri: string): Promise<void>;
|
|
16
|
+
/** Deletes owned artifacts older than `olderThanMs`; returns the count. */
|
|
17
|
+
sweep(olderThanMs: number): Promise<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Brings a fresh capture under the store and returns its managed URI: a file
|
|
20
|
+
* already inside the store is recorded as created by this process, a file
|
|
21
|
+
* anywhere else is moved in. Without this, a capture the engine wrote to its
|
|
22
|
+
* own temporary directory is never owned, so `cleanup()` refuses it and the
|
|
23
|
+
* sweep never sees it. Optional so app-written stores keep compiling.
|
|
24
|
+
*/
|
|
25
|
+
adopt?(uri: string): Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
/** Minimal filesystem surface the adapter needs. Injectable for tests. */
|
|
28
|
+
export interface FileSystemBridge {
|
|
29
|
+
cacheDirectory(): string;
|
|
30
|
+
exists(path: string): Promise<boolean>;
|
|
31
|
+
unlink(path: string): Promise<void>;
|
|
32
|
+
list(directory: string): Promise<readonly string[]>;
|
|
33
|
+
createdAt(path: string): Promise<number>;
|
|
34
|
+
ensureDirectory(directory: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Moves a file. Needed by `adopt()` to pull a capture out of the engine's own
|
|
37
|
+
* temporary directory; a bridge without it can only adopt files already
|
|
38
|
+
* inside the store.
|
|
39
|
+
*/
|
|
40
|
+
move?(from: string, to: string): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface StoreOptions {
|
|
43
|
+
readonly fs?: FileSystemBridge;
|
|
44
|
+
/** Directory name under the cache directory. Defaults to `rn-camera`. */
|
|
45
|
+
readonly directoryName?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function createArtifactStore(fs: FileSystemBridge, directoryName?: string): ArtifactStore;
|
|
48
|
+
/**
|
|
49
|
+
* Default adapter. The concrete filesystem bridge is supplied by the native
|
|
50
|
+
* layer at runtime; it is a parameter rather than a hard import so the package
|
|
51
|
+
* takes no filesystem dependency of its own.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createCacheArtifactStore(options?: StoreOptions): ArtifactStore;
|
|
54
|
+
//# sourceMappingURL=artifactStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifactStore.d.ts","sourceRoot":"","sources":["../../../../src/storage/artifactStore.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,aAAa;IAC7B,8DAA8D;IAC9D,kBAAkB,IAAI,MAAM,CAAC;IAC7B,wDAAwD;IACxD,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,mEAAmE;IACnE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,2EAA2E;IAC3E,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrC;AAED,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAChC,cAAc,IAAI,MAAM,CAAC;IACzB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IACpD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD;;;;OAIG;IACH,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AAOD,wBAAgB,mBAAmB,CAClC,EAAE,EAAE,gBAAgB,EACpB,aAAa,SAAc,GACzB,aAAa,CAqEf;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,YAAiB,GAAG,aAAa,CAWlF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What any `PermissionPort` and `CameraEngine` must do (IOS-12, CAM-13).
|
|
3
|
+
*
|
|
4
|
+
* The same checks run against the in-memory test adapter and against the real
|
|
5
|
+
* VisionCamera adapters (native module mocked in Jest, or for real on a device),
|
|
6
|
+
* so the fake the app's tests rely on cannot drift from the adapter it stands in
|
|
7
|
+
* for. Each check builds its own port from a harness, under the conditions it
|
|
8
|
+
* needs.
|
|
9
|
+
*/
|
|
10
|
+
import { type Check, type ConformanceReport } from '@chipmobilesdk/rn-core/testing';
|
|
11
|
+
import type { CameraEngine } from '../native/cameraEngine.js';
|
|
12
|
+
import type { PermissionPort } from '../permissions/permissionPort.js';
|
|
13
|
+
export type SystemPermission = 'undetermined' | 'granted' | 'deniedPermanently';
|
|
14
|
+
export interface PermissionHarness {
|
|
15
|
+
/** A port over a system whose permission starts in `initial`. */
|
|
16
|
+
create(initial: SystemPermission): {
|
|
17
|
+
readonly port: PermissionPort;
|
|
18
|
+
/** Changes the system permission, as Settings would. */
|
|
19
|
+
setSystemState(state: SystemPermission): void;
|
|
20
|
+
/** How many times the system prompt was shown. */
|
|
21
|
+
prompts(): number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface CameraDeviceSpec {
|
|
25
|
+
readonly position: 'front' | 'back';
|
|
26
|
+
readonly hasFlash?: boolean;
|
|
27
|
+
readonly hasTorch?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface EngineHarness {
|
|
30
|
+
/** An engine on a device with these cameras. */
|
|
31
|
+
create(devices: readonly CameraDeviceSpec[]): CameraEngine;
|
|
32
|
+
}
|
|
33
|
+
export declare const permissionPortChecks: readonly Check<PermissionHarness>[];
|
|
34
|
+
export declare const cameraEngineChecks: readonly Check<EngineHarness>[];
|
|
35
|
+
export declare function runPermissionPortConformance(harness: PermissionHarness): Promise<ConformanceReport>;
|
|
36
|
+
export declare function runCameraEngineConformance(harness: EngineHarness): Promise<ConformanceReport>;
|
|
37
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAGN,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAA+B,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,SAAS,GAAG,mBAAmB,CAAC;AAEhF,MAAM,WAAW,iBAAiB;IACjC,iEAAiE;IACjE,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG;QAClC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;QAC9B,wDAAwD;QACxD,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;QAC9C,kDAAkD;QAClD,OAAO,IAAI,MAAM,CAAC;KAClB,CAAC;CACF;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC7B,gDAAgD;IAChD,MAAM,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAAG,YAAY,CAAC;CAC3D;AAED,eAAO,MAAM,oBAAoB,EAAE,SAAS,KAAK,CAAC,iBAAiB,CAAC,EA2CnE,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAAS,KAAK,CAAC,aAAa,CAAC,EAwC7D,CAAC;AAEF,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE7F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chipmobilesdk/rn-camera/testing`: test doubles and the port conformance suites.
|
|
3
|
+
*
|
|
4
|
+
* A separate entrypoint so the suites cannot reach a production bundle. The test
|
|
5
|
+
* adapter is also exported from the main entrypoint for compatibility; it leaves
|
|
6
|
+
* there only in a major release.
|
|
7
|
+
*/
|
|
8
|
+
export { createTestCamera, createMemoryFileSystem, DEFAULT_TEST_CAPABILITIES, } from './testCameraAdapter.js';
|
|
9
|
+
export type { MemoryFileSystem, TestCameraConfig, TestCameraHandles } from './testCameraAdapter.js';
|
|
10
|
+
export { cameraEngineChecks, permissionPortChecks, runCameraEngineConformance, runPermissionPortConformance, } from './conformance.js';
|
|
11
|
+
export type { CameraDeviceSpec, EngineHarness, PermissionHarness, SystemPermission, } from './conformance.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,GACzB,MAAM,wBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAEjG,OAAO,EACN,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,GAC5B,MAAM,kBAAe,CAAC;AACvB,YAAY,EACX,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,kBAAe,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic in-memory camera for tests (FR-041, SC-010).
|
|
3
|
+
*
|
|
4
|
+
* These are real implementations of the same published ports the production
|
|
5
|
+
* adapters implement, not a parallel mock — so a contract change breaks them at
|
|
6
|
+
* compile time and they cannot drift. Nothing here touches a native module, the
|
|
7
|
+
* filesystem, or a permission API.
|
|
8
|
+
*/
|
|
9
|
+
import { type CameraPermissionState, type CapabilityProfile, type CapturedImage } from '../config/types.js';
|
|
10
|
+
import { type CameraErrorCode } from '../diagnostics/errors.js';
|
|
11
|
+
import type { CameraEngine } from '../native/cameraEngine.js';
|
|
12
|
+
import type { PermissionPort } from '../permissions/permissionPort.js';
|
|
13
|
+
import { type ArtifactStore, type FileSystemBridge } from '../storage/artifactStore.js';
|
|
14
|
+
import type { AppStatus } from '../core/controller.js';
|
|
15
|
+
export interface MemoryFileSystem extends FileSystemBridge {
|
|
16
|
+
/** Seeds a file with an explicit creation time, for time-to-live tests. */
|
|
17
|
+
seed(path: string, createdAtMs: number): void;
|
|
18
|
+
/** Every path currently present. */
|
|
19
|
+
paths(): readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function createMemoryFileSystem(root?: string): MemoryFileSystem;
|
|
22
|
+
export declare const DEFAULT_TEST_CAPABILITIES: CapabilityProfile;
|
|
23
|
+
export interface TestCameraConfig {
|
|
24
|
+
readonly permission?: CameraPermissionState;
|
|
25
|
+
readonly capabilities?: Partial<CapabilityProfile>;
|
|
26
|
+
readonly captureResult?: Partial<CapturedImage>;
|
|
27
|
+
readonly captureError?: CameraErrorCode;
|
|
28
|
+
readonly startError?: CameraErrorCode;
|
|
29
|
+
readonly cacheRoot?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TestCameraHandles {
|
|
32
|
+
readonly engine: CameraEngine;
|
|
33
|
+
readonly permissions: PermissionPort;
|
|
34
|
+
readonly store: ArtifactStore;
|
|
35
|
+
readonly fs: MemoryFileSystem;
|
|
36
|
+
/** Drives the controller's app foreground/background handling. */
|
|
37
|
+
subscribeToAppState(listener: (status: AppStatus) => void): () => void;
|
|
38
|
+
setAppState(status: AppStatus): void;
|
|
39
|
+
/** Simulates a Settings-level permission change while running (FR-007). */
|
|
40
|
+
setPermission(state: CameraPermissionState): void;
|
|
41
|
+
/**
|
|
42
|
+
* Simulates the OS taking the camera away: an incoming call, another app,
|
|
43
|
+
* a disconnected device. A live session tears down with that code, exactly
|
|
44
|
+
* as the device adapter reports it (CAM-19), and the next start fails until
|
|
45
|
+
* `setStartError(null)` clears it.
|
|
46
|
+
*/
|
|
47
|
+
emitInterruption(code?: CameraErrorCode): void;
|
|
48
|
+
/** Simulates the preview failing to produce frames. */
|
|
49
|
+
emitPermissionRequestFailure(enabled: boolean): void;
|
|
50
|
+
setCaptureError(code: CameraErrorCode | null): void;
|
|
51
|
+
setStartError(code: CameraErrorCode | null): void;
|
|
52
|
+
/** How many times `request` showed the system prompt. */
|
|
53
|
+
prompts(): number;
|
|
54
|
+
/** Every capture the engine produced, in order. */
|
|
55
|
+
captures(): readonly CapturedImage[];
|
|
56
|
+
torchState(): boolean;
|
|
57
|
+
startCount(): number;
|
|
58
|
+
stopCount(): number;
|
|
59
|
+
}
|
|
60
|
+
export declare function createTestCamera(config?: TestCameraConfig): TestCameraHandles;
|
|
61
|
+
//# sourceMappingURL=testCameraAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testCameraAdapter.d.ts","sourceRoot":"","sources":["../../../../src/testing/testCameraAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAGN,KAAK,qBAAqB,EAE1B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAElB,MAAM,oBAAiB,CAAC;AACzB,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,0BAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAA+B,CAAC;AACpE,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,MAAM,6BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAoB,CAAC;AAGpD,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACzD,2EAA2E;IAC3E,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,oCAAoC;IACpC,KAAK,IAAI,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,SAAW,GAAG,gBAAgB,CAkCxE;AAED,eAAO,MAAM,yBAAyB,EAAE,iBAMvC,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,qBAAqB,CAAC;IAC5C,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,EAAE,gBAAgB,CAAC;IAC9B,kEAAkE;IAClE,mBAAmB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACvE,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACrC,2EAA2E;IAC3E,aAAa,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAClD;;;;;OAKG;IACH,gBAAgB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/C,uDAAuD;IACvD,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACrD,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;IACpD,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;IAClD,yDAAyD;IACzD,OAAO,IAAI,MAAM,CAAC;IAClB,mDAAmD;IACnD,QAAQ,IAAI,SAAS,aAAa,EAAE,CAAC;IACrC,UAAU,IAAI,OAAO,CAAC;IACtB,UAAU,IAAI,MAAM,CAAC;IACrB,SAAS,IAAI,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,gBAAqB,GAAG,iBAAiB,CAkJjF"}
|