@chipmobilesdk/rn-camera 0.3.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 (197) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/README.md +47 -14
  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 +25 -6
  185. package/src/config/types.ts +8 -0
  186. package/src/core/captureController.ts +11 -1
  187. package/src/core/contract.ts +109 -0
  188. package/src/core/controller.ts +96 -148
  189. package/src/core/sessionRuntime.ts +242 -0
  190. package/src/index.ts +7 -13
  191. package/src/native/cameraEngine.ts +28 -8
  192. package/src/native/visionSurface.ts +43 -18
  193. package/src/react/CameraPreview.tsx +40 -7
  194. package/src/react/VisionCameraFeed.tsx +61 -5
  195. package/src/react/hooks.ts +1 -1
  196. package/src/storage/artifactStore.ts +9 -2
  197. package/src/testing/testCameraAdapter.ts +29 -7
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","useState","useSyncExternalStore","createCameraController","useCameraController","options","optionsRef","controller","setController","current","disposedRef","WeakSet","disposed","has","undefined","add","dispose","catch","useCameraState","subscribe","state"],"sourceRoot":"../../../src","sources":["react/hooks.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,oBAAoB,QAAQ,OAAO;AAGzE,SACCC,sBAAsB,QAGhB,uBAAoB;AAE3B,OAAO,SAASC,mBAAmBA,CAACC,OAAgC,EAAoB;EACvF;EACA;EACA,MAAMC,UAAU,GAAGN,MAAM,CAACK,OAAO,CAAC;EAClC;EACA;EACA,MAAM,CAACE,UAAU,EAAEC,aAAa,CAAC,GAAGP,QAAQ,CAAC,MAAME,sBAAsB,CAACG,UAAU,CAACG,OAAO,CAAC,CAAC;EAC9F,MAAMC,WAAW,GAAGV,MAAM,CAAC,IAAIW,OAAO,CAAmB,CAAC,CAAC;EAE3DZ,SAAS,CAAC,MAAM;IACf;IACA;IACA;IACA;IACA,MAAMa,QAAQ,GAAGF,WAAW,CAACD,OAAO;IACpC,IAAIG,QAAQ,CAACC,GAAG,CAACN,UAAU,CAAC,EAAE;MAC7BC,aAAa,CAACL,sBAAsB,CAACG,UAAU,CAACG,OAAO,CAAC,CAAC;MACzD,OAAOK,SAAS;IACjB;IACA,OAAO,MAAM;MACZF,QAAQ,CAACG,GAAG,CAACR,UAAU,CAAC;MACxBA,UAAU,CAACS,OAAO,CAAC,CAAC,CAACC,KAAK,CAAC,MAAMH,SAAS,CAAC;IAC5C,CAAC;EACF,CAAC,EAAE,CAACP,UAAU,CAAC,CAAC;EAEhB,OAAOA,UAAU;AAClB;AAEA,OAAO,SAASW,cAAcA,CAACX,UAA4B,EAAe;EACzE;EACA;EACA;EACA;EACA,OAAOL,oBAAoB,CAC1BK,UAAU,CAACY,SAAS,EACpB,MAAMZ,UAAU,CAACa,KAAK,EACtB,MAAMb,UAAU,CAACa,KAClB,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * ArtifactStore port + default cache-directory adapter (FR-026..FR-029).
5
+ *
6
+ * Package-owned artifacts live in a dedicated `rn-camera` subdirectory of the
7
+ * platform cache directory (research R6). That dedicated prefix is what makes
8
+ * ownership checkable rather than advisory: `owns()` is a path-prefix test, so
9
+ * the package can refuse to delete anything it did not create (FR-028).
10
+ */
11
+
12
+ import { CameraError } from "../diagnostics/errors.js";
13
+
14
+ /** Minimal filesystem surface the adapter needs. Injectable for tests. */
15
+
16
+ /** Normalizes separators so prefix comparison works on both platforms. */
17
+ function normalize(path) {
18
+ return path.replace(/\\/g, '/').replace(/^file:\/\//, '');
19
+ }
20
+ export function createArtifactStore(fs, directoryName = 'rn-camera') {
21
+ const root = `${fs.cacheDirectory().replace(/\/$/, '')}/${directoryName}`;
22
+ const normalizedRoot = normalize(root);
23
+ // Artifacts created by this process are never swept, no matter their age.
24
+ const createdThisProcess = new Set();
25
+ function owns(uri) {
26
+ return normalize(uri).startsWith(`${normalizedRoot}/`);
27
+ }
28
+ return {
29
+ temporaryDirectory() {
30
+ return root;
31
+ },
32
+ owns,
33
+ async remove(uri) {
34
+ if (!owns(uri)) {
35
+ return;
36
+ }
37
+ const path = normalize(uri);
38
+ // Idempotent: a missing artifact is a successful cleanup (FR-027).
39
+ if (await fs.exists(path)) {
40
+ await fs.unlink(path);
41
+ }
42
+ createdThisProcess.delete(path);
43
+ },
44
+ async sweep(olderThanMs) {
45
+ await fs.ensureDirectory(root);
46
+ const entries = await fs.list(root);
47
+ const cutoff = Date.now() - olderThanMs;
48
+ let removed = 0;
49
+ for (const entry of entries) {
50
+ const path = normalize(entry);
51
+ if (createdThisProcess.has(path)) {
52
+ continue;
53
+ }
54
+ const created = await fs.createdAt(path);
55
+ if (created < cutoff) {
56
+ await fs.unlink(path);
57
+ removed += 1;
58
+ }
59
+ }
60
+ return removed;
61
+ },
62
+ async adopt(uri) {
63
+ const path = normalize(uri);
64
+ if (owns(uri)) {
65
+ createdThisProcess.add(path);
66
+ return uri;
67
+ }
68
+ if (!fs.move) {
69
+ throw new CameraError('storageFailure', 'This FileSystemBridge has no move(), so it cannot adopt a capture');
70
+ }
71
+ await fs.ensureDirectory(root);
72
+ const name = path.slice(path.lastIndexOf('/') + 1) || `capture-${Date.now()}.jpg`;
73
+ const target = `${root}/${name}`;
74
+ await fs.move(path, target);
75
+ createdThisProcess.add(normalize(target));
76
+ return uri.startsWith('file://') ? `file://${normalize(target)}` : target;
77
+ }
78
+ };
79
+ }
80
+
81
+ /**
82
+ * Default adapter. The concrete filesystem bridge is supplied by the native
83
+ * layer at runtime; it is a parameter rather than a hard import so the package
84
+ * takes no filesystem dependency of its own.
85
+ */
86
+ export function createCacheArtifactStore(options = {}) {
87
+ const fs = options.fs;
88
+ if (!fs) {
89
+ // A typed error, like every other failure this package reports.
90
+ throw new CameraError('storageFailure', 'createCacheArtifactStore requires a FileSystemBridge. Pass `fs`, or use ' + 'createTestCamera() in tests.');
91
+ }
92
+ return createArtifactStore(fs, options.directoryName);
93
+ }
94
+ //# sourceMappingURL=artifactStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CameraError","normalize","path","replace","createArtifactStore","fs","directoryName","root","cacheDirectory","normalizedRoot","createdThisProcess","Set","owns","uri","startsWith","temporaryDirectory","remove","exists","unlink","delete","sweep","olderThanMs","ensureDirectory","entries","list","cutoff","Date","now","removed","entry","has","created","createdAt","adopt","add","move","name","slice","lastIndexOf","target","createCacheArtifactStore","options"],"sourceRoot":"../../../src","sources":["storage/artifactStore.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,0BAAuB;;AAqBnD;;AAsBA;AACA,SAASC,SAASA,CAACC,IAAY,EAAU;EACxC,OAAOA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AAC1D;AAEA,OAAO,SAASC,mBAAmBA,CAClCC,EAAoB,EACpBC,aAAa,GAAG,WAAW,EACX;EAChB,MA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A,MAAM,IAAIL,WAAW,CACpB,gBAAgB,EAChB,0EAA0E,GACzE,8BACF,CAAC;EACF;EACA,OAAOI,mBAAmB,CAACC,EAAE,EAAEoC,OAAO,CAACnC,aAAa,CAAC;AACtD","ignoreList":[]}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * What any `PermissionPort` and `CameraEngine` must do (IOS-12, CAM-13).
5
+ *
6
+ * The same checks run against the in-memory test adapter and against the real
7
+ * VisionCamera adapters (native module mocked in Jest, or for real on a device),
8
+ * so the fake the app's tests rely on cannot drift from the adapter it stands in
9
+ * for. Each check builds its own port from a harness, under the conditions it
10
+ * needs.
11
+ */
12
+ import { ensure, runChecks } from '@chipmobilesdk/rn-core/testing';
13
+ export const permissionPortChecks = [{
14
+ name: 'reads the status without prompting',
15
+ async run(harness) {
16
+ const system = harness.create('undetermined');
17
+ ensure((await system.port.getStatus()) === 'undetermined', 'expected undetermined');
18
+ ensure(system.prompts() === 0, 'getStatus prompted');
19
+ }
20
+ }, {
21
+ name: 'reports a grant after prompting once',
22
+ async run(harness) {
23
+ const system = harness.create('undetermined');
24
+ const state = await system.port.request();
25
+ ensure(state === 'granted', `expected granted, got ${state}`);
26
+ ensure(system.prompts() === 1, `expected one prompt, got ${system.prompts()}`);
27
+ }
28
+ }, {
29
+ name: 'never prompts again after a permanent denial',
30
+ async run(harness) {
31
+ const system = harness.create('deniedPermanently');
32
+ const state = await system.port.request();
33
+ ensure(state === 'deniedPermanently', `expected deniedPermanently, got ${state}`);
34
+ ensure(system.prompts() === 0, 'prompted after a permanent denial');
35
+ }
36
+ }, {
37
+ name: 'tells subscribers about a change, and nothing after unsubscribing',
38
+ async run(harness) {
39
+ const system = harness.create('undetermined');
40
+ const seen = [];
41
+ const unsubscribe = system.port.subscribe(state => seen.push(state));
42
+ await system.port.request();
43
+ ensure(seen.includes('granted'), `subscriber saw ${JSON.stringify(seen)}`);
44
+ unsubscribe();
45
+ unsubscribe();
46
+ const before = seen.length;
47
+ system.setSystemState('deniedPermanently');
48
+ await system.port.getStatus();
49
+ ensure(seen.length === before, 'notified after unsubscribing');
50
+ }
51
+ }];
52
+ export const cameraEngineChecks = [{
53
+ name: 'refuses to start without a camera, as cameraUnavailable',
54
+ async run(harness) {
55
+ const engine = harness.create([]);
56
+ let code;
57
+ try {
58
+ await engine.start({});
59
+ } catch (error) {
60
+ code = error.code;
61
+ }
62
+ ensure(code === 'cameraUnavailable', `expected cameraUnavailable, got ${String(code)}`);
63
+ }
64
+ }, {
65
+ name: 'starts when a camera exists',
66
+ async run(harness) {
67
+ await harness.create([{
68
+ position: 'back'
69
+ }]).start({});
70
+ }
71
+ }, {
72
+ name: 'reports capabilities from the cameras present',
73
+ async run(harness) {
74
+ const capabilities = await harness.create([{
75
+ position: 'back',
76
+ hasTorch: true,
77
+ hasFlash: true
78
+ }, {
79
+ position: 'front'
80
+ }]).getCapabilities();
81
+ ensure(capabilities.hasCameraHardware, 'no camera hardware reported');
82
+ ensure(capabilities.hasTorch && capabilities.hasFlash, 'torch or flash not reported');
83
+ const positions = [...capabilities.availablePositions].sort();
84
+ ensure(positions.join(',') === 'back,front', `positions ${positions.join(',')}`);
85
+ }
86
+ }, {
87
+ name: 'stops safely, even without a start and twice',
88
+ async run(harness) {
89
+ const engine = harness.create([{
90
+ position: 'back'
91
+ }]);
92
+ await engine.stop();
93
+ await engine.stop();
94
+ }
95
+ }];
96
+ export function runPermissionPortConformance(harness) {
97
+ return runChecks(() => harness, permissionPortChecks);
98
+ }
99
+ export function runCameraEngineConformance(harness) {
100
+ return runChecks(() => harness, cameraEngineChecks);
101
+ }
102
+ //# sourceMappingURL=conformance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ensure","runChecks","permissionPortChecks","name","run","harness","system","create","port","getStatus","prompts","state","request","seen","unsubscribe","subscribe","push","includes","JSON","stringify","before","length","setSystemState","cameraEngineChecks","engine","code","start","error","String","position","capabilities","hasTorch","hasFlash","getCapabilities","hasCameraHardware","positions","availablePositions","sort","join","stop","runPermissionPortConformance","runCameraEngineConformance"],"sourceRoot":"../../../src","sources":["testing/conformance.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACCA,MAAM,EACNC,SAAS,QAGH,gCAAgC;AA8BvC,OAAO,MAAMC,oBAAyD,GAAG,CACxE;EACCC,IAAI,EAAE,oCAAoC;EAC1C,MAAMC,GAAGA,CAACC,OAAO,EAAE;IAClB,MAAMC,MAAM,GAAGD,OAAO,CAACE,MAAM,CAAC,cAAc,CAAC;IAC7CP,MAAM,CAAC,CAAC,MAAMM,MAAM,CAACE,IAAI,CAACC,SAAS,CAAC,CAAC,MAAM,cAAc,EAAE,uBAAuB,CAAC;IACnFT,MAAM,CAACM,MAAM,CAACI,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC;EACrD;AACD,CAAC,EACD;EACCP,IAAI,EAAE,sCAAsC;EAC5C,MAAMC,GAAGA,CAACC,OAAO,EAAE;IAClB,MAAMC,MAAM,GAAGD,OAAO,CAACE,MAAM,CAAC,cAAc,CAAC;IAC7C,MAAMI,KAAK,GAAG,MAAML,MAAM,CAACE,IAAI,CAACI,OAAO,CAAC,CAAC;IACzCZ,MAAM,CAACW,KAAK,KAAK,SAAS,EAAE,yBAAyBA,KAAK,EAAE,CAAC;IAC7DX,MAAM,CAACM,MAAM,CAACI,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,4BAA4BJ,MAAM,CAACI,OAAO,CAAC,CAAC,EAAE,CAAC;EAC/E;AACD,CAAC,EACD;EACCP,IAAI,EAAE,8CAA8C;EACpD,MAAMC,GAAGA,CAACC,OAAO,EAAE;IAClB,MAAMC,MAAM,GAAGD,OAAO,CAACE,MAAM,CAAC,mBAAmB,CAAC;IAClD,MAAMI,KAAK,GAAG,MAAML,MAAM,CAACE,IAAI,CAACI,OAAO,CAAC,CAAC;IACzCZ,MAAM,CAACW,KAAK,KAAK,mBAAmB,EAAE,mCA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Mf,MAAM,CAACe,IAAI,CAAC,CAAC;EACpB;AACD,CAAC,CACD;AAED,OAAO,SAASC,4BAA4BA,CAC3CnC,OAA0B,EACG;EAC7B,OAAOJ,SAAS,CAAC,MAAMI,OAAO,EAAEH,oBAAoB,CAAC;AACtD;AAEA,OAAO,SAASuC,0BAA0BA,CAACpC,OAAsB,EAA8B;EAC9F,OAAOJ,SAAS,CAAC,MAAMI,OAAO,EAAEkB,kBAAkB,CAAC;AACpD","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * `@chipmobilesdk/rn-camera/testing`: test doubles and the port conformance suites.
5
+ *
6
+ * A separate entrypoint so the suites cannot reach a production bundle. The test
7
+ * adapter is also exported from the main entrypoint for compatibility; it leaves
8
+ * there only in a major release.
9
+ */
10
+
11
+ export { createTestCamera, createMemoryFileSystem, DEFAULT_TEST_CAPABILITIES } from "./testCameraAdapter.js";
12
+ export { cameraEngineChecks, permissionPortChecks, runCameraEngineConformance, runPermissionPortConformance } from "./conformance.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createTestCamera","createMemoryFileSystem","DEFAULT_TEST_CAPABILITIES","cameraEngineChecks","permissionPortChecks","runCameraEngineConformance","runPermissionPortConformance"],"sourceRoot":"../../../src","sources":["testing/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACCA,gBAAgB,EAChBC,sBAAsB,EACtBC,yBAAyB,QACnB,wBAAqB;AAG5B,SACCC,kBAAkB,EAClBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,4BAA4B,QACtB,kBAAe","ignoreList":[]}
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Deterministic in-memory camera for tests (FR-041, SC-010).
5
+ *
6
+ * These are real implementations of the same published ports the production
7
+ * adapters implement, not a parallel mock — so a contract change breaks them at
8
+ * compile time and they cannot drift. Nothing here touches a native module, the
9
+ * filesystem, or a permission API.
10
+ */
11
+
12
+ import { createListenerSet } from '@chipmobilesdk/rn-core';
13
+ import { known, unavailable } from "../config/types.js";
14
+ import { CameraError } from "../diagnostics/errors.js";
15
+ import { createArtifactStore } from "../storage/artifactStore.js";
16
+ import { clampQuality } from "../core/captureController.js";
17
+ export function createMemoryFileSystem(root = '/cache') {
18
+ const files = new Map();
19
+ const directories = new Set();
20
+ return {
21
+ cacheDirectory: () => root,
22
+ async exists(path) {
23
+ return files.has(path);
24
+ },
25
+ async unlink(path) {
26
+ files.delete(path);
27
+ },
28
+ async list(directory) {
29
+ const prefix = `${directory.replace(/\/$/, '')}/`;
30
+ return Array.from(files.keys()).filter(path => path.startsWith(prefix));
31
+ },
32
+ async createdAt(path) {
33
+ return files.get(path) ?? Date.now();
34
+ },
35
+ async ensureDirectory(directory) {
36
+ directories.add(directory);
37
+ },
38
+ async move(from, to) {
39
+ if (!files.has(from)) {
40
+ throw new Error('No such file');
41
+ }
42
+ files.set(to, files.get(from) ?? Date.now());
43
+ files.delete(from);
44
+ },
45
+ seed(path, createdAtMs) {
46
+ files.set(path, createdAtMs);
47
+ },
48
+ paths: () => Array.from(files.keys())
49
+ };
50
+ }
51
+ export const DEFAULT_TEST_CAPABILITIES = {
52
+ availablePositions: ['back', 'front'],
53
+ hasFlash: true,
54
+ hasTorch: true,
55
+ supportsOrientationChange: true,
56
+ hasCameraHardware: true
57
+ };
58
+ export function createTestCamera(config = {}) {
59
+ const fs = createMemoryFileSystem(config.cacheRoot ?? '/cache');
60
+ const store = createArtifactStore(fs);
61
+ const capabilities = {
62
+ ...DEFAULT_TEST_CAPABILITIES,
63
+ ...config.capabilities
64
+ };
65
+ let permission = config.permission ?? 'undetermined';
66
+ let captureError = config.captureError ?? null;
67
+ let startError = config.startError ?? null;
68
+ let torch = false;
69
+ let starts = 0;
70
+ let stops = 0;
71
+ let sequence = 0;
72
+ let promptCount = 0;
73
+ const produced = [];
74
+ // The same listener sets as the real adapters, so a throwing subscriber behaves
75
+ // identically here and on a device.
76
+ const permissionListeners = createListenerSet();
77
+ const appStateListeners = createListenerSet();
78
+ const interruptionListeners = createListenerSet();
79
+ let requestThrows = false;
80
+ const permissions = {
81
+ async getStatus() {
82
+ return permission;
83
+ },
84
+ async request() {
85
+ if (requestThrows) {
86
+ // What a native module that cannot be reached does.
87
+ throw new Error('permission request failed');
88
+ }
89
+ // Mirrors the real adapter: never re-prompt after a permanent denial.
90
+ if (permission === 'deniedPermanently') {
91
+ return permission;
92
+ }
93
+ if (permission === 'undetermined' || permission === 'denied') {
94
+ promptCount += 1;
95
+ permission = 'granted';
96
+ }
97
+ permissionListeners.notify(permission);
98
+ return permission;
99
+ },
100
+ subscribe: listener => permissionListeners.add(listener)
101
+ };
102
+ const engine = {
103
+ subscribeToInterruptions: listener => interruptionListeners.add(listener),
104
+ async start() {
105
+ starts += 1;
106
+ if (startError) {
107
+ throw new CameraError(startError);
108
+ }
109
+ if (!capabilities.hasCameraHardware) {
110
+ throw new CameraError('cameraUnavailable');
111
+ }
112
+ },
113
+ async stop() {
114
+ stops += 1;
115
+ torch = false;
116
+ },
117
+ async capture(request) {
118
+ if (captureError) {
119
+ throw new CameraError(captureError);
120
+ }
121
+ sequence += 1;
122
+ const position = request.cameraPosition ?? 'back';
123
+ const uri = request.destination ?? `${store.temporaryDirectory()}/capture-${sequence}.jpg`;
124
+ fs.seed(uri, Date.now());
125
+ const image = {
126
+ uri,
127
+ mimeType: 'image/jpeg',
128
+ width: 1920,
129
+ height: 1080,
130
+ timestamp: Date.now(),
131
+ cameraPosition: position,
132
+ ownership: request.destination ? 'appOwned' : 'packageTemporary',
133
+ // Clamped the way the real path clamps it, not a second copy of 0.9.
134
+ effectiveQuality: clampQuality(request.quality),
135
+ effectiveMaxDimension: request.maxDimension === undefined ? unavailable() : known(request.maxDimension),
136
+ fileSize: known(1024),
137
+ orientation: known(0),
138
+ ...config.captureResult
139
+ };
140
+ produced.push(image);
141
+ return image;
142
+ },
143
+ async setTorch(enabled) {
144
+ torch = enabled;
145
+ },
146
+ async getCapabilities() {
147
+ return capabilities;
148
+ }
149
+ };
150
+ return {
151
+ engine,
152
+ permissions,
153
+ store,
154
+ fs,
155
+ subscribeToAppState: listener => appStateListeners.add(listener),
156
+ setAppState(status) {
157
+ appStateListeners.notify(status);
158
+ },
159
+ setPermission(state) {
160
+ permission = state;
161
+ permissionListeners.notify(state);
162
+ },
163
+ emitInterruption(code = 'interrupted') {
164
+ // The OS took the camera away. A live session hears about it, and the
165
+ // next start attempt fails until the app clears it.
166
+ startError = code;
167
+ interruptionListeners.notify(code);
168
+ },
169
+ emitPermissionRequestFailure(enabled) {
170
+ requestThrows = enabled;
171
+ },
172
+ setCaptureError(code) {
173
+ captureError = code;
174
+ },
175
+ setStartError(code) {
176
+ startError = code;
177
+ },
178
+ prompts: () => promptCount,
179
+ captures: () => produced,
180
+ torchState: () => torch,
181
+ startCount: () => starts,
182
+ stopCount: () => stops
183
+ };
184
+ }
185
+ //# sourceMappingURL=testCameraAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createListenerSet","known","unavailable","CameraError","createArtifactStore","clampQuality","createMemoryFileSystem","root","files","Map","directories","Set","cacheDirectory","exists","path","has","unlink","delete","list","directory","prefix","replace","Array","from","keys","filter","startsWith","createdAt","get","Date","now","ensureDirectory","add","move","to","Error","set","seed","createdAtMs","paths","DEFAULT_TEST_CAPABILITIES","availablePositions","hasFlash","hasTorch","supportsOrientationChange","hasCameraHardware","createTestCamera","config","fs","cacheRoot","store","capabilities","permission","captureError","startError","torch","starts","stops","sequence","promptCount","produced","permissionListeners","appStateListeners","interruptionListeners","requestThrows","permissions","getStatus","request","notify","subscribe","listener","engine","subscribeToInterruptions","start","stop","capture","position","cameraPosition","uri","destination","temporaryDirectory","image","mimeType","width","height","timestamp","ownership","effectiveQuality","quality","effectiveMaxDimension","maxDimension","undefined","fileSize","orientation","captureResult","push","setTorch","enabled","getCapabilities","subscribeToAppState","setAppState","status","setPermission","state","emitInterruption","code","emitPermissionRequestFailure","setCaptureError","setStartError","prompts","captures","torchState","startCount","stopCount"],"sourceRoot":"../../../src","sources":["testing/testCameraAdapter.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iBAAiB,QAAQ,wBAAwB;AAE1D,SACCC,KAAK,EACLC,WAAW,QAML,oBAAiB;AACxB,SAASC,WAAW,QAA8B,0BAAuB;AAGzE,SACCC,mBAAmB,QAGb,6BAA0B;AAEjC,SAASC,YAAY,QAAQ,8BAA2B;AASxD,OAAO,SAASC,sBAAsBA,CAACC,IAAI,GAAG,QAAQ,EAAoB;EACzE,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACvC,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAAS,CAAC;EAErC,OAAO;IACNC,cAAc,EAAEA,CAAA,KAAML,IAAI;IAC1B,MAAMM,MAAMA,CAACC,IAAI,EAAE;MAClB,OAAON,KAAK,CAACO,GAAG,CAACD,IAAI,CAAC;IACvB,CAAC;IACD,MAAME,MAAMA,CAACF,IAAI,EAAE;MAClBN,KAAK,CAACS,MAAM,CAACH,IAAI,CAAC;IACnB,CAAC;IACD,MAAMI,IAAIA,CAACC,SAAS,EAAE;MACrB,MAAMC,MAAM,GAAG,GAAGD,SAAS,CAACE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG;MACjD,OAAOC,KAAK,CAACC,IAAI,CAACf,KAAK,CAACgB,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CAACX,IAAI,IAAIA,IAAI,CAACY,UAAU,CAACN,MAAM,CAAC,CAAC;IACxE,CAAC;IACD,MAAMO,SAASA,CAACb,IAAI,EAAE;MACrB,OAAON,KAAK,CAACoB,GAAG,CAACd,IAAI,CAAC,IAAIe,IAAI,CAACC,GAAG,CAAC,CAAC;IACrC,CAAC;IACD,MAAMC,eAAeA,CAACZ,SAAS,EAAE;MAChCT,WAAW,CAACsB,GAAG,CAACb,SA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AOA,KAAK;IACb,CAAC;IAED,MAAMe,QAAQA,CAACC,OAAgB,EAAE;MAChC1C,KAAK,GAAG0C,OAAO;IAChB,CAAC;IAED,MAAMC,eAAeA,CAAA,EAAG;MACvB,OAAO/C,YAAY;IACpB;EACD,CAAC;EAED,OAAO;IACNoB,MAAM;IACNN,WAAW;IACXf,KAAK;IACLF,EAAE;IAEFmD,mBAAmB,EAAE7B,QAAQ,IAAIR,iBAAiB,CAAC9B,GAAG,CAACsC,QAAQ,CAAC;IAEhE8B,WAAWA,CAACC,MAAM,EAAE;MACnBvC,iBAAiB,CAACM,MAAM,CAACiC,MAAM,CAAC;IACjC,CAAC;IAEDC,aAAaA,CAACC,KAAK,EAAE;MACpBnD,UAAU,GAAGmD,KAAK;MAClB1C,mBAAmB,CAACO,MAAM,CAACmC,KAAK,CAAC;IAClC,CAAC;IAEDC,gBAAgBA,CAACC,IAAqB,GAAG,aAAa,EAAE;MACvD;MACA;MACAnD,UAAU,GAAGmD,IAAI;MACjB1C,qBAAqB,CAACK,MAAM,CAACqC,IAAI,CAAC;IACnC,CAAC;IAEDC,4BAA4BA,CAACT,OAAO,EAAE;MACrCjC,aAAa,GAAGiC,OAAO;IACxB,CAAC;IAEDU,eAAeA,CAACF,IAAI,EAAE;MACrBpD,YAAY,GAAGoD,IAAI;IACpB,CAAC;IAEDG,aAAaA,CAACH,IAAI,EAAE;MACnBnD,UAAU,GAAGmD,IAAI;IAClB,CAAC;IAEDI,OAAO,EAAEA,CAAA,KAAMlD,WAAW;IAC1BmD,QAAQ,EAAEA,CAAA,KAAMlD,QAAQ;IACxBmD,UAAU,EAAEA,CAAA,KAAMxD,KAAK;IACvByD,UAAU,EAAEA,CAAA,KAAMxD,MAAM;IACxByD,SAAS,EAAEA,CAAA,KAAMxD;EAClB,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Public type contract for @chipmobilesdk/rn-camera.
3
+ *
4
+ * Every type here is re-exported from `src/index.ts` (LIB-002/LIB-003). See
5
+ * `specs/006-rn-camera-package/contracts/public-api.md` for the authoritative
6
+ * contract and `data-model.md` for the rules behind each field.
7
+ */
8
+ /** Camera authorization status. Seven distinguishable outcomes (FR-004). */
9
+ export type CameraPermissionState = 'undetermined' | 'requesting' | 'granted' | 'denied' | 'deniedPermanently' | 'unavailable' | 'unsupported';
10
+ export type CameraPosition = 'front' | 'back';
11
+ export type FlashMode = 'auto' | 'on' | 'off';
12
+ export type ResizeMode = 'cover' | 'contain';
13
+ export type ArtifactOwnership = 'packageTemporary' | 'appOwned';
14
+ import type { SurfaceInfo } from '../native/visionSurface';
15
+ export type SessionStatus = 'idle' | 'starting' | 'active' | 'paused' | 'stopping' | 'stopped' | 'error';
16
+ /**
17
+ * A metadata field the platform could not determine (FR-022). Distinct from an
18
+ * absent property so consumers can tell "not reported" from "not asked for".
19
+ */
20
+ export interface Unavailable {
21
+ readonly available: false;
22
+ }
23
+ export interface Known<T> {
24
+ readonly available: true;
25
+ readonly value: T;
26
+ }
27
+ export type Maybe<T> = Known<T> | Unavailable;
28
+ export declare function known<T>(value: T): Known<T>;
29
+ export declare function unavailable(): Unavailable;
30
+ /** What this device and platform actually support (FR-033). */
31
+ export interface CapabilityProfile {
32
+ readonly availablePositions: readonly CameraPosition[];
33
+ readonly hasFlash: boolean;
34
+ readonly hasTorch: boolean;
35
+ readonly supportsOrientationChange: boolean;
36
+ readonly hasCameraHardware: boolean;
37
+ }
38
+ /** Instruction to take one still photo. Carries no business context (FR-002). */
39
+ export interface CaptureRequest {
40
+ /** 0..1, clamped to what the device supports. */
41
+ readonly quality?: number;
42
+ /** Longest edge in pixels, applied within device limits. */
43
+ readonly maxDimension?: number;
44
+ readonly cameraPosition?: CameraPosition;
45
+ readonly flashMode?: FlashMode;
46
+ /**
47
+ * Supplying a destination makes the result `appOwned` and the package writes
48
+ * directly there. Omitting it makes the result `packageTemporary` (FR-026a).
49
+ * This is the only way ownership is decided.
50
+ */
51
+ readonly destination?: string;
52
+ }
53
+ /** Result of one successful capture. Always a file reference (FR-021/FR-021a). */
54
+ export interface CapturedImage {
55
+ /** File URI or handle. Never a base64 string, never an in-memory buffer. */
56
+ readonly uri: string;
57
+ readonly mimeType: string;
58
+ readonly width: number;
59
+ readonly height: number;
60
+ readonly timestamp: number;
61
+ readonly cameraPosition: CameraPosition;
62
+ readonly ownership: ArtifactOwnership;
63
+ readonly effectiveQuality: number;
64
+ readonly effectiveMaxDimension: Maybe<number>;
65
+ readonly fileSize: Maybe<number>;
66
+ readonly orientation: Maybe<number>;
67
+ }
68
+ /** Options accepted when starting a session. */
69
+ export interface StartOptions {
70
+ readonly cameraPosition?: CameraPosition;
71
+ }
72
+ /**
73
+ * Relationship between captured-image space and on-screen preview space.
74
+ * Consumed by the pure mapping functions in `geometry/coordinateMapping`.
75
+ */
76
+ export interface PreviewGeometry {
77
+ readonly imageWidth: number;
78
+ readonly imageHeight: number;
79
+ readonly previewWidth: number;
80
+ readonly previewHeight: number;
81
+ readonly resizeMode: ResizeMode;
82
+ /** Clockwise degrees: 0, 90, 180, or 270. */
83
+ readonly orientation: number;
84
+ readonly isMirrored: boolean;
85
+ }
86
+ export interface Point {
87
+ readonly x: number;
88
+ readonly y: number;
89
+ }
90
+ export interface Rect {
91
+ readonly x: number;
92
+ readonly y: number;
93
+ readonly width: number;
94
+ readonly height: number;
95
+ }
96
+ /** Aggregate observable state exposed by the controller. */
97
+ export interface CameraState {
98
+ readonly session: SessionStatus;
99
+ readonly permission: CameraPermissionState;
100
+ readonly capabilities: CapabilityProfile | null;
101
+ readonly cameraPosition: CameraPosition;
102
+ readonly flashMode: FlashMode;
103
+ readonly torchEnabled: boolean;
104
+ readonly capturing: boolean;
105
+ /**
106
+ * What the mounted preview surface reported about itself: the capture
107
+ * dimensions of the selected format, its orientation, and the position of
108
+ * the device actually running. `null` until a surface reports (CAM-10).
109
+ */
110
+ readonly surface: SurfaceInfo | null;
111
+ readonly error: CameraErrorLike | null;
112
+ }
113
+ /**
114
+ * Structural view of a CameraError, kept here so `CameraState` does not create
115
+ * a circular import with the diagnostics module.
116
+ */
117
+ export interface CameraErrorLike {
118
+ readonly code: string;
119
+ readonly recoverable: boolean;
120
+ readonly message: string;
121
+ }
122
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,qBAAqB,GAC9B,cAAc,GACd,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,mBAAmB,GACnB,aAAa,GACb,aAAa,CAAC;AAEjB,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC;AAC9C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC;AAC9C,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAC7C,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,UAAU,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,aAAa,GACxB,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;CAC1B;AAED,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CAClB;AAED,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;AAE9C,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE3C;AAED,wBAAgB,WAAW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AAC;IACrC,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Capability gating (FR-033, FR-034).
3
+ *
4
+ * An unsupported capability must produce an `unsupportedCapability` result, not
5
+ * an unexpected failure — that is what lets an app hide a control instead of
6
+ * discovering at tap time that the device has no flash.
7
+ */
8
+ import type { CameraPosition, CapabilityProfile, FlashMode } from '../config/types';
9
+ export declare const EMPTY_CAPABILITIES: CapabilityProfile;
10
+ export declare function supportsPosition(profile: CapabilityProfile | null, position: CameraPosition): boolean;
11
+ /** `off` is always legal — it is the absence of flash, not a use of it. */
12
+ export declare function supportsFlashMode(profile: CapabilityProfile | null, mode: FlashMode): boolean;
13
+ export declare function supportsTorch(profile: CapabilityProfile | null): boolean;
14
+ /** Throws the uniform unsupported error so every gate reads the same way. */
15
+ export declare function assertSupported(supported: boolean, what: string): void;
16
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../../src/core/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGpF,eAAO,MAAM,kBAAkB,EAAE,iBAMhC,CAAC;AAEF,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,iBAAiB,GAAG,IAAI,EACjC,QAAQ,EAAE,cAAc,GACtB,OAAO,CAET;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAE7F;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAExE;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAItE"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Capture guards, single-flight enforcement, and metadata assembly
3
+ * (FR-020..FR-026b).
4
+ *
5
+ * The single-flight guard rejects rather than queues or coalesces. A queue
6
+ * turns a double-tapped shutter into two photos the user never asked for, and
7
+ * coalescing hides a deliberate second capture behind an accidental one — so a
8
+ * fast, explicit `captureInProgress` error is the only option that lets the app
9
+ * decide (clarification session 2026-07-26).
10
+ */
11
+ import { type CameraPosition, type CapabilityProfile, type CapturedImage, type CaptureRequest, type FlashMode, type Maybe, type SessionStatus } from '../config/types';
12
+ import type { CameraEngine } from '../native/cameraEngine';
13
+ export declare const DEFAULT_QUALITY = 0.9;
14
+ export declare function clampQuality(quality: number | undefined): number;
15
+ export declare function clampMaxDimension(maxDimension: number | undefined): Maybe<number>;
16
+ export interface CaptureContext {
17
+ readonly engine: CameraEngine;
18
+ readonly sessionStatus: SessionStatus;
19
+ readonly permissionGranted: boolean;
20
+ readonly capabilities: CapabilityProfile | null;
21
+ readonly cameraPosition: CameraPosition;
22
+ readonly flashMode: FlashMode;
23
+ }
24
+ /**
25
+ * Validates a capture request against permission, readiness, and capability.
26
+ * Throws before any artifact could be created, so a rejected capture never
27
+ * leaves a file behind (FR-020).
28
+ */
29
+ export declare function assertCaptureAllowed(context: CaptureContext, request: CaptureRequest): void;
30
+ /**
31
+ * Normalizes whatever the engine returned into the published contract, filling
32
+ * in effective hint values and marking undeterminable fields explicitly
33
+ * unavailable rather than guessing them (FR-022, FR-023).
34
+ */
35
+ export declare function finalizeResult(raw: CapturedImage, request: CaptureRequest, context: CaptureContext): CapturedImage;
36
+ /**
37
+ * Serializes captures. The slot is taken synchronously, before the operation
38
+ * runs, so two calls in the same tick cannot both pass the check — and the
39
+ * operation's own first `emit()` already sees `busy`. Holding the operation's
40
+ * promise instead set the slot only after that first emit, so `capturing: true`
41
+ * was never published at all.
42
+ */
43
+ export declare class SingleFlight {
44
+ private active;
45
+ get busy(): boolean;
46
+ run(operation: () => Promise<CapturedImage>): Promise<CapturedImage>;
47
+ }
48
+ //# sourceMappingURL=captureController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureController.d.ts","sourceRoot":"","sources":["../../../../src/core/captureController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKhE;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAKjF;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAChD,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAqB3F;AAED;;;;GAIG;AACH,wBA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