@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.
Files changed (185) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/README.md +11 -7
  3. package/lib/commonjs/config/types.js +54 -0
  4. package/lib/commonjs/config/types.js.map +1 -0
  5. package/lib/commonjs/core/capabilities.js +45 -0
  6. package/lib/commonjs/core/capabilities.js.map +1 -0
  7. package/lib/commonjs/core/captureController.js +107 -0
  8. package/lib/commonjs/core/captureController.js.map +1 -0
  9. package/lib/commonjs/core/contract.js +16 -0
  10. package/lib/commonjs/core/contract.js.map +1 -0
  11. package/lib/commonjs/core/controller.js +452 -0
  12. package/lib/commonjs/core/controller.js.map +1 -0
  13. package/lib/commonjs/core/sessionMachine.js +116 -0
  14. package/lib/commonjs/core/sessionMachine.js.map +1 -0
  15. package/lib/commonjs/core/sessionRuntime.js +218 -0
  16. package/lib/commonjs/core/sessionRuntime.js.map +1 -0
  17. package/lib/commonjs/diagnostics/errors.js +86 -0
  18. package/lib/commonjs/diagnostics/errors.js.map +1 -0
  19. package/lib/commonjs/diagnostics/logger.js +40 -0
  20. package/lib/commonjs/diagnostics/logger.js.map +1 -0
  21. package/lib/commonjs/geometry/coordinateMapping.js +156 -0
  22. package/lib/commonjs/geometry/coordinateMapping.js.map +1 -0
  23. package/lib/commonjs/index.js +130 -0
  24. package/lib/commonjs/index.js.map +1 -0
  25. package/lib/commonjs/native/cameraEngine.js +86 -0
  26. package/lib/commonjs/native/cameraEngine.js.map +1 -0
  27. package/lib/commonjs/native/visionCameraPeer.js +28 -0
  28. package/lib/commonjs/native/visionCameraPeer.js.map +1 -0
  29. package/lib/commonjs/native/visionSurface.js +38 -0
  30. package/lib/commonjs/native/visionSurface.js.map +1 -0
  31. package/lib/commonjs/package.json +1 -0
  32. package/lib/commonjs/permissions/permissionPort.js +105 -0
  33. package/lib/commonjs/permissions/permissionPort.js.map +1 -0
  34. package/lib/commonjs/react/CameraPreview.js +136 -0
  35. package/lib/commonjs/react/CameraPreview.js.map +1 -0
  36. package/lib/commonjs/react/VisionCameraFeed.js +196 -0
  37. package/lib/commonjs/react/VisionCameraFeed.js.map +1 -0
  38. package/lib/commonjs/react/hooks.js +50 -0
  39. package/lib/commonjs/react/hooks.js.map +1 -0
  40. package/lib/commonjs/storage/artifactStore.js +98 -0
  41. package/lib/commonjs/storage/artifactStore.js.map +1 -0
  42. package/lib/commonjs/testing/conformance.js +109 -0
  43. package/lib/commonjs/testing/conformance.js.map +1 -0
  44. package/lib/commonjs/testing/index.js +50 -0
  45. package/lib/commonjs/testing/index.js.map +1 -0
  46. package/lib/commonjs/testing/testCameraAdapter.js +191 -0
  47. package/lib/commonjs/testing/testCameraAdapter.js.map +1 -0
  48. package/lib/module/config/types.js +49 -0
  49. package/lib/module/config/types.js.map +1 -0
  50. package/lib/module/core/capabilities.js +37 -0
  51. package/lib/module/core/capabilities.js.map +1 -0
  52. package/lib/module/core/captureController.js +98 -0
  53. package/lib/module/core/captureController.js.map +1 -0
  54. package/lib/module/core/contract.js +12 -0
  55. package/lib/module/core/contract.js.map +1 -0
  56. package/lib/module/core/controller.js +442 -0
  57. package/lib/module/core/controller.js.map +1 -0
  58. package/lib/module/core/sessionMachine.js +109 -0
  59. package/lib/module/core/sessionMachine.js.map +1 -0
  60. package/lib/module/core/sessionRuntime.js +215 -0
  61. package/lib/module/core/sessionRuntime.js.map +1 -0
  62. package/lib/module/diagnostics/errors.js +79 -0
  63. package/lib/module/diagnostics/errors.js.map +1 -0
  64. package/lib/module/diagnostics/logger.js +35 -0
  65. package/lib/module/diagnostics/logger.js.map +1 -0
  66. package/lib/module/geometry/coordinateMapping.js +149 -0
  67. package/lib/module/geometry/coordinateMapping.js.map +1 -0
  68. package/lib/module/index.js +44 -0
  69. package/lib/module/index.js.map +1 -0
  70. package/lib/module/native/cameraEngine.js +83 -0
  71. package/lib/module/native/cameraEngine.js.map +1 -0
  72. package/lib/module/native/visionCameraPeer.js +24 -0
  73. package/lib/module/native/visionCameraPeer.js.map +1 -0
  74. package/lib/module/native/visionSurface.js +34 -0
  75. package/lib/module/native/visionSurface.js.map +1 -0
  76. package/lib/module/package.json +1 -0
  77. package/lib/module/permissions/permissionPort.js +101 -0
  78. package/lib/module/permissions/permissionPort.js.map +1 -0
  79. package/lib/module/react/CameraPreview.js +130 -0
  80. package/lib/module/react/CameraPreview.js.map +1 -0
  81. package/lib/module/react/VisionCameraFeed.js +190 -0
  82. package/lib/module/react/VisionCameraFeed.js.map +1 -0
  83. package/lib/module/react/hooks.js +45 -0
  84. package/lib/module/react/hooks.js.map +1 -0
  85. package/lib/module/storage/artifactStore.js +94 -0
  86. package/lib/module/storage/artifactStore.js.map +1 -0
  87. package/lib/module/testing/conformance.js +102 -0
  88. package/lib/module/testing/conformance.js.map +1 -0
  89. package/lib/module/testing/index.js +13 -0
  90. package/lib/module/testing/index.js.map +1 -0
  91. package/lib/module/testing/testCameraAdapter.js +185 -0
  92. package/lib/module/testing/testCameraAdapter.js.map +1 -0
  93. package/lib/typescript/commonjs/config/types.d.ts +122 -0
  94. package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
  95. package/lib/typescript/commonjs/core/capabilities.d.ts +16 -0
  96. package/lib/typescript/commonjs/core/capabilities.d.ts.map +1 -0
  97. package/lib/typescript/commonjs/core/captureController.d.ts +48 -0
  98. package/lib/typescript/commonjs/core/captureController.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/core/contract.d.ts +92 -0
  100. package/lib/typescript/commonjs/core/contract.d.ts.map +1 -0
  101. package/lib/typescript/commonjs/core/controller.d.ts +15 -0
  102. package/lib/typescript/commonjs/core/controller.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/core/sessionMachine.d.ts +46 -0
  104. package/lib/typescript/commonjs/core/sessionMachine.d.ts.map +1 -0
  105. package/lib/typescript/commonjs/core/sessionRuntime.d.ts +64 -0
  106. package/lib/typescript/commonjs/core/sessionRuntime.d.ts.map +1 -0
  107. package/lib/typescript/commonjs/diagnostics/errors.d.ts +24 -0
  108. package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/diagnostics/logger.d.ts +24 -0
  110. package/lib/typescript/commonjs/diagnostics/logger.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/geometry/coordinateMapping.d.ts +23 -0
  112. package/lib/typescript/commonjs/geometry/coordinateMapping.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/index.d.ts +32 -0
  114. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/native/cameraEngine.d.ts +50 -0
  116. package/lib/typescript/commonjs/native/cameraEngine.d.ts.map +1 -0
  117. package/lib/typescript/commonjs/native/visionCameraPeer.d.ts +2 -0
  118. package/lib/typescript/commonjs/native/visionCameraPeer.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/native/visionSurface.d.ts +41 -0
  120. package/lib/typescript/commonjs/native/visionSurface.d.ts.map +1 -0
  121. package/lib/typescript/commonjs/package.json +1 -0
  122. package/lib/typescript/commonjs/permissions/permissionPort.d.ts +24 -0
  123. package/lib/typescript/commonjs/permissions/permissionPort.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/react/CameraPreview.d.ts +25 -0
  125. package/lib/typescript/commonjs/react/CameraPreview.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/react/VisionCameraFeed.d.ts +31 -0
  127. package/lib/typescript/commonjs/react/VisionCameraFeed.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/react/hooks.d.ts +12 -0
  129. package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/storage/artifactStore.d.ts +54 -0
  131. package/lib/typescript/commonjs/storage/artifactStore.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/testing/conformance.d.ts +37 -0
  133. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/testing/index.d.ts +12 -0
  135. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/testing/testCameraAdapter.d.ts +61 -0
  137. package/lib/typescript/commonjs/testing/testCameraAdapter.d.ts.map +1 -0
  138. package/lib/typescript/module/config/types.d.ts +122 -0
  139. package/lib/typescript/module/config/types.d.ts.map +1 -0
  140. package/lib/typescript/module/core/capabilities.d.ts +16 -0
  141. package/lib/typescript/module/core/capabilities.d.ts.map +1 -0
  142. package/lib/typescript/module/core/captureController.d.ts +48 -0
  143. package/lib/typescript/module/core/captureController.d.ts.map +1 -0
  144. package/lib/typescript/module/core/contract.d.ts +92 -0
  145. package/lib/typescript/module/core/contract.d.ts.map +1 -0
  146. package/lib/typescript/module/core/controller.d.ts +15 -0
  147. package/lib/typescript/module/core/controller.d.ts.map +1 -0
  148. package/lib/typescript/module/core/sessionMachine.d.ts +46 -0
  149. package/lib/typescript/module/core/sessionMachine.d.ts.map +1 -0
  150. package/lib/typescript/module/core/sessionRuntime.d.ts +64 -0
  151. package/lib/typescript/module/core/sessionRuntime.d.ts.map +1 -0
  152. package/lib/typescript/module/diagnostics/errors.d.ts +24 -0
  153. package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
  154. package/lib/typescript/module/diagnostics/logger.d.ts +24 -0
  155. package/lib/typescript/module/diagnostics/logger.d.ts.map +1 -0
  156. package/lib/typescript/module/geometry/coordinateMapping.d.ts +23 -0
  157. package/lib/typescript/module/geometry/coordinateMapping.d.ts.map +1 -0
  158. package/lib/typescript/module/index.d.ts +32 -0
  159. package/lib/typescript/module/index.d.ts.map +1 -0
  160. package/lib/typescript/module/native/cameraEngine.d.ts +50 -0
  161. package/lib/typescript/module/native/cameraEngine.d.ts.map +1 -0
  162. package/lib/typescript/module/native/visionCameraPeer.d.ts +2 -0
  163. package/lib/typescript/module/native/visionCameraPeer.d.ts.map +1 -0
  164. package/lib/typescript/module/native/visionSurface.d.ts +41 -0
  165. package/lib/typescript/module/native/visionSurface.d.ts.map +1 -0
  166. package/lib/typescript/module/package.json +1 -0
  167. package/lib/typescript/module/permissions/permissionPort.d.ts +24 -0
  168. package/lib/typescript/module/permissions/permissionPort.d.ts.map +1 -0
  169. package/lib/typescript/module/react/CameraPreview.d.ts +25 -0
  170. package/lib/typescript/module/react/CameraPreview.d.ts.map +1 -0
  171. package/lib/typescript/module/react/VisionCameraFeed.d.ts +31 -0
  172. package/lib/typescript/module/react/VisionCameraFeed.d.ts.map +1 -0
  173. package/lib/typescript/module/react/hooks.d.ts +12 -0
  174. package/lib/typescript/module/react/hooks.d.ts.map +1 -0
  175. package/lib/typescript/module/storage/artifactStore.d.ts +54 -0
  176. package/lib/typescript/module/storage/artifactStore.d.ts.map +1 -0
  177. package/lib/typescript/module/testing/conformance.d.ts +37 -0
  178. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  179. package/lib/typescript/module/testing/index.d.ts +12 -0
  180. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  181. package/lib/typescript/module/testing/testCameraAdapter.d.ts +61 -0
  182. package/lib/typescript/module/testing/testCameraAdapter.d.ts.map +1 -0
  183. package/package.json +49 -13
  184. package/skills/sdk-rn-camera/SKILL.md +6 -3
  185. package/src/index.ts +4 -12
@@ -0,0 +1,92 @@
1
+ /**
2
+ * What a camera controller is, for the app that drives it.
3
+ *
4
+ * The contract lives apart from the orchestration in `controller.ts`: it is
5
+ * what a consumer reads, and what a test double has to satisfy, while the file
6
+ * next to it is how this package happens to satisfy it.
7
+ */
8
+ import type { CameraPermissionState, CameraState, CapabilityProfile, CapturedImage, CaptureRequest, FlashMode, StartOptions } from '../config/types';
9
+ import type { CameraError } from '../diagnostics/errors';
10
+ import type { CameraLogger } from '../diagnostics/logger';
11
+ import type { CameraEngine } from '../native/cameraEngine';
12
+ import type { SurfaceInfo, VisionSurface } from '../native/visionSurface';
13
+ import type { PermissionPort } from '../permissions/permissionPort';
14
+ import type { ArtifactStore } from '../storage/artifactStore';
15
+ export declare const DEFAULT_TEMPORARY_TTL_MS: number;
16
+ export type AppStatus = 'active' | 'background';
17
+ export interface CameraControllerOptions {
18
+ /** Required. Use the default adapters, or `createTestCamera()` in tests. */
19
+ readonly engine: CameraEngine;
20
+ readonly permissions: PermissionPort;
21
+ readonly store?: ArtifactStore | undefined;
22
+ readonly logger?: CameraLogger | undefined;
23
+ readonly temporaryTtlMs?: number;
24
+ /**
25
+ * App foreground/background source. Defaults to rn-core's shared `appLifecycle()`,
26
+ * where `inactive` counts as background. Injectable so lifecycle rules are
27
+ * testable without an app (FR-015).
28
+ */
29
+ readonly subscribeToAppState?: (listener: (status: AppStatus) => void) => () => void;
30
+ /**
31
+ * Set false to skip the sweep that runs when the controller is first used
32
+ * (tests). Defaults to true.
33
+ */
34
+ readonly sweepOnInit?: boolean;
35
+ /**
36
+ * How long to wait for a preview surface to report frames before failing the
37
+ * start (FR-014). Only applies to an engine whose session belongs to the
38
+ * surface (`awaitsSurfaceStart`). Defaults to 8 s.
39
+ */
40
+ readonly startTimeoutMs?: number;
41
+ /** Test seam for that timeout. */
42
+ readonly scheduler?: {
43
+ setTimeout(callback: () => void, ms: number): unknown;
44
+ clearTimeout(handle: unknown): void;
45
+ };
46
+ }
47
+ export interface CameraController {
48
+ readonly state: CameraState;
49
+ subscribe(listener: (state: CameraState) => void): () => void;
50
+ getPermission(): Promise<CameraPermissionState>;
51
+ requestPermission(): Promise<CameraPermissionState>;
52
+ start(options?: StartOptions): Promise<void>;
53
+ pause(): Promise<void>;
54
+ resume(): Promise<void>;
55
+ stop(): Promise<void>;
56
+ capture(request?: CaptureRequest): Promise<CapturedImage>;
57
+ cleanup(image: CapturedImage | string): Promise<void>;
58
+ getCapabilities(): Promise<CapabilityProfile>;
59
+ setFlashMode(mode: FlashMode): void;
60
+ setTorch(enabled: boolean): Promise<void>;
61
+ /** Marks the preview surface mounted, enabling foreground auto-restart. */
62
+ setSurfaceMounted(mounted: boolean): void;
63
+ /**
64
+ * Attaches the mounted preview surface to the engine, for an engine that
65
+ * captures through it. Returns the detach function; a no-op for engines that
66
+ * own their own session.
67
+ */
68
+ attachSurface(surface: VisionSurface): () => void;
69
+ /**
70
+ * The preview reported frames: the session is active for real, not merely
71
+ * requested (CAM-08). What the surface turned out to be — the format's pixel
72
+ * size, the orientation, the device's own position — is published as
73
+ * `state.surface` for coordinate mapping.
74
+ */
75
+ reportSurfaceStarted(info: SurfaceInfo): void;
76
+ /** The preview's own session failed, or the OS took the camera away. */
77
+ reportSurfaceFailed(code: CameraError['code']): void;
78
+ /**
79
+ * Called by `CameraPreview` when the native preview surface cannot load (the
80
+ * VisionCamera module is missing or unlinked). Fails the session with
81
+ * `cameraUnavailable` rather than leaving a black preview and no error.
82
+ */
83
+ reportSurfaceUnavailable(): void;
84
+ /**
85
+ * Releases ports, listeners, and the camera. Safe to call twice. Afterwards
86
+ * `start`, `resume`, `capture` and the permission and capability reads reject
87
+ * with `notReady`; `stop`, `pause` and `cleanup` stay safe no-ops so teardown
88
+ * code never has to check.
89
+ */
90
+ dispose(): Promise<void>;
91
+ }
92
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../../../src/core/contract.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,a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AAI,CAAC,CAAC;IAC7C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1D,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9C,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C,2EAA2E;IAC3E,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,IAAI,CAAC;IAClD;;;;;OAKG;IACH,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9C,wEAAwE;IACxE,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACrD;;;;OAIG;IACH,wBAAwB,IAAI,IAAI,CAAC;IACjC;;;;;OAKG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Camera controller — the object consuming apps actually drive.
3
+ *
4
+ * It owns observable state and orchestrates the three ports (engine,
5
+ * permissions, artifact store). All I/O lives here; the decisions live in
6
+ * `sessionMachine` and `captureController`, which stay pure so they can be
7
+ * tested without a camera.
8
+ */
9
+ import { type CameraController, type CameraControllerOptions } from './contract';
10
+ /** 24 hours (FR-029). */
11
+ export { DEFAULT_TEMPORARY_TTL_MS, type AppStatus, type CameraController, type CameraControllerOptions, } from './contract';
12
+ /** 8 s: a cold camera on a slow device, with room to spare (PERF-001 is 1.5 s). */
13
+ export declare const DEFAULT_START_TIMEOUT_MS = 8000;
14
+ export declare function createCameraController(options: CameraControllerOptions): CameraController;
15
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/core/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,OAAO,EAGN,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,MAAM,YAAY,CAAC;AAYpB,yBAAyB;AACzB,OAAO,EACN,wBAAwB,EACxB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC5B,MAAM,YAAY,CAAC;AAQpB,mFAAmF;AACnF,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAE9C,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,gBAAgB,CA2ZzF"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Session lifecycle state machine (FR-014..FR-019).
3
+ *
4
+ * Pure and synchronous: it decides what a transition means, the controller
5
+ * performs the I/O. That split is what makes every lifecycle rule in
6
+ * `data-model.md` section 2 testable without a camera.
7
+ *
8
+ * Backgrounding STOPS rather than pauses. Both operating systems can reclaim
9
+ * the camera anyway, and holding it risks leaving the OS camera indicator lit
10
+ * after the app is no longer in front of the user (FR-015).
11
+ */
12
+ import type { SessionStatus } from '../config/types';
13
+ import { CameraError, type CameraErrorCode } from '../diagnostics/errors';
14
+ export type SessionEvent = {
15
+ readonly type: 'START';
16
+ } | {
17
+ readonly type: 'STARTED';
18
+ } | {
19
+ readonly type: 'PAUSE';
20
+ } | {
21
+ readonly type: 'RESUME';
22
+ } | {
23
+ readonly type: 'STOP';
24
+ } | {
25
+ readonly type: 'STOPPED';
26
+ } | {
27
+ readonly type: 'BACKGROUND';
28
+ } | {
29
+ readonly type: 'FOREGROUND';
30
+ readonly surfaceMounted: boolean;
31
+ } | {
32
+ readonly type: 'FAIL';
33
+ readonly code: CameraErrorCode;
34
+ } | {
35
+ readonly type: 'START_TIMEOUT';
36
+ };
37
+ export interface SessionSnapshot {
38
+ readonly status: SessionStatus;
39
+ readonly error: CameraError | null;
40
+ }
41
+ export declare const initialSession: SessionSnapshot;
42
+ export declare function canStart(status: SessionStatus): boolean;
43
+ /** Capture is only ever legal from a fully active session (FR-020). */
44
+ export declare function canCapture(status: SessionStatus): boolean;
45
+ export declare function sessionReducer(snapshot: SessionSnapshot, event: SessionEvent): SessionSnapshot;
46
+ //# sourceMappingURL=sessionMachine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionMachine.d.ts","sourceRoot":"","sources":["../../../../src/core/sessionMachine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE1E,MAAM,MAAM,YAAY,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;CAAE,GACjE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,cAAc,EAAE,eAAiD,CAAC;AAK/E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAEvD;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAEzD;AAMD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,GAAG,eAAe,CAqD9F"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The session's own I/O: starting it, waiting for frames, releasing it, and
3
+ * following the app in and out of the foreground.
4
+ *
5
+ * Split out of `controller.ts`, which had grown to hold three jobs at once:
6
+ * publishing state, running the session, and serving the public API. The
7
+ * decisions still live in `sessionMachine` (pure); this is the part that
8
+ * actually awaits the engine, and the controller composes it.
9
+ *
10
+ * It reads and writes the controller's state through `SessionContext` rather
11
+ * than owning it: one snapshot reaches subscribers, whichever part of the
12
+ * controller changed it.
13
+ */
14
+ import type { StartOptions } from '../config/types';
15
+ import { type CameraErrorCode } from '../diagnostics/errors';
16
+ import type { CameraLogger } from '../diagnostics/logger';
17
+ import type { CameraEngine } from '../native/cameraEngine';
18
+ import type { SurfaceInfo } from '../native/visionSurface';
19
+ import type { SessionEvent, SessionSnapshot } from './sessionMachine';
20
+ /** What the runtime needs from the controller that owns the state. */
21
+ export interface SessionContext {
22
+ readonly engine: CameraEngine;
23
+ readonly logger: CameraLogger;
24
+ /** How long to wait for a preview surface to report frames. */
25
+ readonly startTimeoutMs: number;
26
+ readonly scheduler: {
27
+ setTimeout(callback: () => void, ms: number): unknown;
28
+ clearTimeout(handle: unknown): void;
29
+ };
30
+ session(): SessionSnapshot;
31
+ dispatch(event: SessionEvent): void;
32
+ emit(): void;
33
+ cameraPosition(): 'front' | 'back';
34
+ setCameraPosition(position: 'front' | 'back'): void;
35
+ torchEnabled(): boolean;
36
+ setTorchEnabled(enabled: boolean): void;
37
+ surfaceMounted(): boolean;
38
+ permissionGranted(): boolean;
39
+ disposed(): boolean;
40
+ }
41
+ export interface SessionRuntime {
42
+ /** Starts the engine and, where the surface owns the session, waits for frames. */
43
+ start(options?: StartOptions): Promise<void>;
44
+ /** Turns the torch off and releases the camera. Safe from any state. */
45
+ release(): Promise<void>;
46
+ /** Torch off, whatever the session is doing. */
47
+ forceTorchOff(): Promise<void>;
48
+ /** The app went to the background or came back. */
49
+ onAppState(status: 'active' | 'background'): void;
50
+ /** The preview reported frames; carries what the mounted device turned out to be. */
51
+ reportSurfaceStarted(info: SurfaceInfo): void;
52
+ /** The preview's own session failed, or the OS took the camera. */
53
+ reportSurfaceFailed(code: CameraErrorCode): void;
54
+ /** The engine lost the camera: another app, a call, a disconnected device. */
55
+ onInterruption(code: CameraErrorCode): void;
56
+ /** What the surface last reported, for the published state. */
57
+ surfaceInfo(): SurfaceInfo | null;
58
+ /** Set when the app foregrounds with a surface mounted, so the session restarts. */
59
+ armResumeOnForeground(): void;
60
+ /** A release still in flight, so a restart can wait for it. */
61
+ pending(): Promise<void> | undefined;
62
+ }
63
+ export declare function createSessionRuntime(context: SessionContext): SessionRuntime;
64
+ //# sourceMappingURL=sessionRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/sessionRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,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,CAAC;IAC/B,mDAAmD;IACnD,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAC;IAClD,qFAAqF;IACrF,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9C,mEAAmE;IACnE,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,8EAA8E;IAC9E,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAC5C,+DAA+D;IAC/D,WAAW,IAAI,WAAW,GAAG,IAAI,CAAC;IAClC,oFAAoF;IACpF,qBAAqB,IAAI,IAAI,CAAC;IAC9B,+DAA+D;IAC/D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CA+K5E"}
@@ -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';
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,iBAAiB,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';
14
+ export { known, unavailable } from './config/types';
15
+ export { createCameraController, DEFAULT_TEMPORARY_TTL_MS } from './core/controller';
16
+ export type { AppStatus, CameraController, CameraControllerOptions } from './core/controller';
17
+ export type { CameraEngine } from './native/cameraEngine';
18
+ export type { SurfaceInfo, SurfaceRegistry, VisionSurface } from './native/visionSurface';
19
+ export { createSurfaceRegistry } from './native/visionSurface';
20
+ export { createVisionCameraEngine } from './native/cameraEngine';
21
+ export type { PermissionPort } from './permissions/permissionPort';
22
+ export { createVisionCameraPermissions } from './permissions/permissionPort';
23
+ export type { ArtifactStore, FileSystemBridge, StoreOptions } from './storage/artifactStore';
24
+ export { createArtifactStore, createCacheArtifactStore } from './storage/artifactStore';
25
+ export { CameraPreview } from './react/CameraPreview';
26
+ export type { CameraPreviewProps } from './react/CameraPreview';
27
+ export { useCameraController, useCameraState } from './react/hooks';
28
+ export { mapPointToImage, mapPointToPreview, mapRectToImage, mapRectToPreview, } from './geometry/coordinateMapping';
29
+ export { CameraError, isCameraError, redact } from './diagnostics/errors';
30
+ export type { CameraErrorCode } from './diagnostics/errors';
31
+ export type { CameraLogEvent, CameraLogEventType, CameraLogger } from './diagnostics/logger';
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,gBAAgB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+ *
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';
17
+ import type { CameraErrorCode } from '../diagnostics/errors';
18
+ import { type VisionSurface } from './visionSurface';
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,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,iBAAiB,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,2 @@
1
+ export declare function loadVisionCamera<T>(): T;
2
+ //# sourceMappingURL=visionCameraPeer.d.ts.map
@@ -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';
14
+ import type { CapturedImage, CaptureRequest } from '../config/types';
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,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,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":"commonjs"}
@@ -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';
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,iBAAiB,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';
12
+ import type { CameraController } from '../core/controller';
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,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,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';
15
+ import { type CameraErrorCode } from '../diagnostics/errors';
16
+ import type { SurfaceInfo, VisionSurface } from '../native/visionSurface';
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,iBAAiB,CAAC;AAEzB,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,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';
9
+ import { type CameraController, type CameraControllerOptions } from '../core/controller';
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,iBAAiB,CAAC;AACnD,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,gBAAgB,CA0BtF;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,gBAAgB,GAAG,WAAW,CAUxE"}