@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,135 @@
1
1
  # @chipmobilesdk/rn-camera
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - The test adapter is only at `@chipmobilesdk/rn-camera/testing`. `createTestCamera`,
8
+ `createMemoryFileSystem`, `DEFAULT_TEST_CAPABILITIES` and their configuration and handle
9
+ types are gone from the main entrypoint, which had re-exported them since FR-041. That
10
+ re-export put the fake camera in the module graph of every app that imported the
11
+ package, and Metro does not tree-shake it back out, so a production bundle shipped a
12
+ camera nobody could use (PERF-14, TOOL-09). ([#21](https://github.com/operationd8979/chip-mobile-sdk/pull/21))
13
+
14
+ **Migration:** one line in a test — `from '@chipmobilesdk/rn-camera'` becomes
15
+ `from '@chipmobilesdk/rn-camera/testing'`. The subpath has existed since 0.3.0 and the
16
+ exports are identical; nothing about the adapter itself changed. The README said the
17
+ main entrypoint would keep them "until the next major release": this is that move,
18
+ brought forward into a minor because the package is pre-1.0 and the cost was a bundle,
19
+ not an API.
20
+
21
+ The layer table's exception for `index.ts` importing `./testing/testCameraAdapter` is
22
+ gone with it, so the `sdk/boundaries` rule now holds the same line here as everywhere
23
+ else: test doubles stay out of production code, and the package's own contract test
24
+ reaches the adapter the way a consumer's test does.
25
+
26
+ - Every package now ships built JavaScript with declaration files, instead of asking the
27
+ app to compile its TypeScript. ([#22](https://github.com/operationd8979/chip-mobile-sdk/pull/22))
28
+
29
+ Each tarball carries `lib/commonjs`, `lib/module` and `lib/typescript` (built with
30
+ `react-native-builder-bob`), and `src/` alongside them. What that changes for a
31
+ consumer:
32
+
33
+ - **Nothing to add to `transformIgnorePatterns`.** `require` resolves to the CommonJS
34
+ build, so an app's Jest loads this package without being told to transform it. That
35
+ was the one thing every consuming app had to know about us (DEP-04).
36
+ - **Typechecking reads our `.d.ts`** rather than compiling our source under our
37
+ `tsconfig`. A consumer's stricter — or looser — settings no longer meet our code.
38
+ - **`import` resolves to ESM**, so a bundler can tree-shake what it does not use.
39
+
40
+ No exported name changed, and no subpath moved: `.`, `./testing`, `./push`,
41
+ `./advanced`, `./app-auth`, `./keychain` and rn-core's twelve subpaths resolve exactly
42
+ as before, each now with its own declarations for both module systems. publint and
43
+ `attw --profile node16` pass on all twelve packages, which they could not before.
44
+
45
+ Inside the monorepo nothing changed either, and that is deliberate: every subpath also
46
+ declares a private `chipmobilesdk-source` condition pointing at its TypeScript, and
47
+ Metro, Jest and `tsc` here ask for that condition first. The demo app bundles 371
48
+ modules straight from `packages/*/src`, so editing a package still changes the app with
49
+ no build step, and coverage is still measured on the source. The condition is named for
50
+ this organization rather than using the conventional `source` because third-party
51
+ packages declare that one too — `@dr.pogodin/react-native-fs` does — and asking for it
52
+ pulled their sources into our stricter compile.
53
+
54
+ `npm run build:packages` builds everything, `prepack` rebuilds before any `npm pack`,
55
+ and `lib/` is git-ignored: the published bytes are produced by the release, never
56
+ committed. `npm run check:manifests` now fails a package whose `main`, `module`,
57
+ `types`, `source` condition, `files`, build script or `prepack` do not match this shape.
58
+
59
+ ### Patch Changes
60
+
61
+ - Every peer range has an upper bound, and no package declares a peer it does not use. ([#21](https://github.com/operationd8979/chip-mobile-sdk/pull/21))
62
+
63
+ A peer range is now a caret, a tilde or an explicit `<`, except for `react` and
64
+ `react-native`: an app brings exactly one of each, so a floor is the only useful thing
65
+ to say about them. Every other peer is a library the app installs beside us, and an
66
+ open `>=` was a promise about versions nobody had run — mmkv 3→4 lost entitlements and
67
+ pending purchases exactly that way.
68
+
69
+ **Four of the new ceilings exclude a version that is already published**, so an app
70
+ that took the open range at its word may now see a peer warning. The new bound is the
71
+ major this release is tested against, which is the thing the old range failed to say:
72
+
73
+ | Peer | Was | Now | Published above the ceiling |
74
+ |---|---|---|---|
75
+ | `react-native-app-auth` (rn-auth) | `>=8` | `^8.0.0` | 9.0.0 |
76
+ | `react-native-keychain` (rn-auth) | `>=10` | `^10.0.0` | 11.0.0 |
77
+ | `@op-engineering/op-sqlite` (rn-local-db) | `>=17.1.0` | `^17.1.0` | 18.x, 19.x |
78
+ | `@react-native-firebase/messaging` (rn-notification) | `>=26.0.0` | `^26.0.0` | 27.x |
79
+
80
+ The others — `react-native-vision-camera` `^5.1.1`, `react-native-svg` `^15.15.0`,
81
+ `react-native-unistyles` `^3.2.0`, `@dr.pogodin/react-native-fs` `^2.39.2`,
82
+ `react-native-quick-crypto` `^1.0.0`, `react-native-notify-kit` `^10.5.0`,
83
+ `react-native-localize` `^3.7.0`, `react-native-mmkv` `^4.0.0` — exclude nothing that
84
+ exists today. rn-payment's mmkv range was already bounded (`>=4.0.0 <5`) and is now
85
+ written as the caret that means the same thing.
86
+
87
+ Peers nothing imports are gone. `rn-theme`, `rn-local-db` and `rn-notification` asked
88
+ for `react` without having a component or a hook between them; `rn-auth`, `rn-ai` and
89
+ `rn-i18n` asked for `react-native` without touching a React Native API (rn-auth reaches
90
+ both native modules through `lazyPeer`, rn-i18n formats on `Intl`); `rn-notification`
91
+ asked for `@react-native-firebase/app`, which messaging declares itself. `rn-ai` no
92
+ longer peers on `@chipmobilesdk/rn-auth` at all — it asks for a `TokenProvider`, a
93
+ two-method interface rn-auth's `auth` satisfies, so an app with its own token source
94
+ installs nothing extra. An app that enables push or signs in through rn-auth installs
95
+ the same packages as before; it is the manifest that stopped overstating.
96
+
97
+ `react-native-localize` is declared optional, which is what the code already did: the
98
+ time-zone reader goes through `lazyPeer` and falls back to `Intl` without it. The
99
+ `peerDependenciesMeta` entries that said `optional: false` are gone — that is npm's
100
+ default, and writing it down only invited the question of which peers were undecided.
101
+
102
+ `npm run check:manifests` now fails on an unbounded peer range, a peer nothing in
103
+ `src/` imports, and a `peerDependenciesMeta` entry for either, so the policy holds
104
+ without anyone remembering it.
105
+
106
+ - Each package's public API and its weight are now recorded in the repository, so a change
107
+ to either is reviewed rather than discovered. ([#23](https://github.com/operationd8979/chip-mobile-sdk/pull/23))
108
+
109
+ `packages/<pkg>/etc/*.api.md` is an api-extractor report per entrypoint — twenty-seven
110
+ of them, generated from the declarations the package publishes and committed. A renamed
111
+ type, a widened union, one more optional field: all of it shows up in a pull request's
112
+ diff. `npm run check:api` fails when a report is out of date and `npm run api:update`
113
+ rewrites them.
114
+
115
+ A report that moves now needs a **minor or major** changeset for that package.
116
+ `check:changesets` enforces it, because the report is generated from what the package
117
+ publishes, and a patch release that moves the public surface is how a consumer's build
118
+ breaks on `npm update`. A report added for the first time is a baseline, not a change.
119
+ `./testing` deliberately has no report: test doubles are not a surface a release is
120
+ gated on.
121
+
122
+ `npm run check:size` holds every entrypoint to a budget in `.size-limit.json`, measured
123
+ on the ESM build with peers and rn-core treated as external — they are what an app
124
+ installs beside us, not our weight. Each budget started at today's measurement plus five
125
+ per cent, so growth becomes a decision someone makes instead of a drift nobody sees. The
126
+ current figures run from 500 B (`rn-core/lazy`) to 19 kB (rn-notification).
127
+
128
+ No behaviour or API changed in this release; the entry is here so the changelog records
129
+ when the reports and the budgets began.
130
+ - Updated dependencies ([#22](https://github.com/operationd8979/chip-mobile-sdk/pull/22), [#23](https://github.com/operationd8979/chip-mobile-sdk/pull/23)):
131
+ - @chipmobilesdk/rn-core@0.2.0
132
+
3
133
  ## 0.4.0
4
134
 
5
135
  ### Minor Changes
package/README.md CHANGED
@@ -19,7 +19,7 @@ The package is **infrastructure, not a feature**. It contains no business logic,
19
19
  | React Native | >= 0.85 |
20
20
  | Android | `minSdkVersion` **24**, `targetSdkVersion` 36 |
21
21
  | iOS | 15.1+ |
22
- | `react-native-vision-camera` | 5.1.x |
22
+ | `react-native-vision-camera` | `^5.1.1` |
23
23
 
24
24
  > **Android `minSdkVersion` stays at 24.** Secondary sources claim VisionCamera v5 requires 26. That is wrong for 5.1.1: its `gradle.properties` declares `VisionCamera_minSdkVersion=23` and its `build.gradle` resolves `rootProject.ext.minSdkVersion` first. Bumping to 26 would drop Android 7.0 and 7.1 devices for no reason.
25
25
 
@@ -260,7 +260,8 @@ or quality is required.
260
260
  `createTestCamera()` returns real implementations of the same published ports the production adapters implement — not a parallel mock, so it cannot drift from the contract without a compile error.
261
261
 
262
262
  ```ts
263
- import { createCameraController, createTestCamera } from '@chipmobilesdk/rn-camera';
263
+ import { createCameraController } from '@chipmobilesdk/rn-camera';
264
+ import { createTestCamera } from '@chipmobilesdk/rn-camera/testing';
264
265
 
265
266
  const camera = createTestCamera({ permission: 'granted' });
266
267
  const controller = createCameraController({
@@ -305,9 +306,11 @@ expectConformance(
305
306
  );
306
307
  ```
307
308
 
308
- `createTestCamera` and its helpers are exported from `./testing` too; the main
309
- entrypoint keeps them until the next major release. `camera.prompts()` counts how often
310
- `request()` showed the system prompt.
309
+ `createTestCamera` and its helpers live at `@chipmobilesdk/rn-camera/testing`, and only
310
+ there as of 0.4.0 — on the main entrypoint the fake camera joined the module graph of
311
+ every app that imported the package, which Metro does not tree-shake back out. A test
312
+ that imported it from `@chipmobilesdk/rn-camera` changes that one line and nothing else.
313
+ `camera.prompts()` counts how often `request()` showed the system prompt.
311
314
 
312
315
  Add a module mapping so an accidental import of the native module resolves in Jest:
313
316
 
@@ -396,8 +399,9 @@ Everything is exported from `@chipmobilesdk/rn-camera`, test doubles and conform
396
399
  `mapRectToPreview`, plus `Point`, `Rect`, and `PreviewGeometry`
397
400
  - Diagnostics: `CameraError`, `CameraErrorCode`, `isCameraError`, `redact`, and
398
401
  the logger event/type contracts
399
- - Testing: `createTestCamera`, `createMemoryFileSystem`,
400
- `DEFAULT_TEST_CAPABILITIES`, and their configuration/handle types
402
+ - Testing, from `@chipmobilesdk/rn-camera/testing` rather than the main entrypoint:
403
+ `createTestCamera`, `createMemoryFileSystem`, `DEFAULT_TEST_CAPABILITIES`, and their
404
+ configuration/handle types
401
405
  - Metadata helpers: `known`, `unavailable`, `Known`, `Unavailable`, `Maybe`
402
406
 
403
407
  Stable for semver: types, controller, preview, mapping, errors. Experimental and may change in a minor: the diagnostics logger shape and the test adapter configuration.
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.known = known;
7
+ exports.unavailable = unavailable;
8
+ /**
9
+ * Public type contract for @chipmobilesdk/rn-camera.
10
+ *
11
+ * Every type here is re-exported from `src/index.ts` (LIB-002/LIB-003). See
12
+ * `specs/006-rn-camera-package/contracts/public-api.md` for the authoritative
13
+ * contract and `data-model.md` for the rules behind each field.
14
+ */
15
+
16
+ /** Camera authorization status. Seven distinguishable outcomes (FR-004). */
17
+
18
+ /**
19
+ * A metadata field the platform could not determine (FR-022). Distinct from an
20
+ * absent property so consumers can tell "not reported" from "not asked for".
21
+ */
22
+
23
+ function known(value) {
24
+ return {
25
+ available: true,
26
+ value
27
+ };
28
+ }
29
+ function unavailable() {
30
+ return {
31
+ available: false
32
+ };
33
+ }
34
+
35
+ /** What this device and platform actually support (FR-033). */
36
+
37
+ /** Instruction to take one still photo. Carries no business context (FR-002). */
38
+
39
+ /** Result of one successful capture. Always a file reference (FR-021/FR-021a). */
40
+
41
+ /** Options accepted when starting a session. */
42
+
43
+ /**
44
+ * Relationship between captured-image space and on-screen preview space.
45
+ * Consumed by the pure mapping functions in `geometry/coordinateMapping`.
46
+ */
47
+
48
+ /** Aggregate observable state exposed by the controller. */
49
+
50
+ /**
51
+ * Structural view of a CameraError, kept here so `CameraState` does not create
52
+ * a circular import with the diagnostics module.
53
+ */
54
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["known","value","available","unavailable"],"sourceRoot":"../../../src","sources":["config/types.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAoBA;AACA;AACA;AACA;;AAYO,SAASA,KAAKA,CAAIC,KAAQ,EAAY;EAC5C,OAAO;IAAEC,SAAS,EAAE,IAAI;IAAED;EAAM,CAAC;AAClC;AAEO,SAASE,WAAWA,CAAA,EAAgB;EAC1C,OAAO;IAAED,SAAS,EAAE;EAAM,CAAC;AAC5B;;AAEA;;AASA;;AAgBA;;AAgBA;;AAKA;AACA;AACA;AACA;;AAwBA;;AAkBA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.EMPTY_CAPABILITIES = void 0;
7
+ exports.assertSupported = assertSupported;
8
+ exports.supportsFlashMode = supportsFlashMode;
9
+ exports.supportsPosition = supportsPosition;
10
+ exports.supportsTorch = supportsTorch;
11
+ var _errors = require("../diagnostics/errors.js");
12
+ /**
13
+ * Capability gating (FR-033, FR-034).
14
+ *
15
+ * An unsupported capability must produce an `unsupportedCapability` result, not
16
+ * an unexpected failure — that is what lets an app hide a control instead of
17
+ * discovering at tap time that the device has no flash.
18
+ */
19
+
20
+ const EMPTY_CAPABILITIES = exports.EMPTY_CAPABILITIES = {
21
+ availablePositions: [],
22
+ hasFlash: false,
23
+ hasTorch: false,
24
+ supportsOrientationChange: false,
25
+ hasCameraHardware: false
26
+ };
27
+ function supportsPosition(profile, position) {
28
+ return profile?.availablePositions.includes(position) ?? false;
29
+ }
30
+
31
+ /** `off` is always legal — it is the absence of flash, not a use of it. */
32
+ function supportsFlashMode(profile, mode) {
33
+ return mode === 'off' ? true : profile?.hasFlash === true;
34
+ }
35
+ function supportsTorch(profile) {
36
+ return profile?.hasTorch === true;
37
+ }
38
+
39
+ /** Throws the uniform unsupported error so every gate reads the same way. */
40
+ function assertSupported(supported, what) {
41
+ if (!supported) {
42
+ throw new _errors.CameraError('unsupportedCapability', `Not supported on this device: ${what}`);
43
+ }
44
+ }
45
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","EMPTY_CAPABILITIES","exports","availablePositions","hasFlash","hasTorch","supportsOrientationChange","hasCameraHardware","supportsPosition","profile","position","includes","supportsFlashMode","mode","supportsTorch","assertSupported","supported","what","CameraError"],"sourceRoot":"../../../src","sources":["core/capabilities.ts"],"mappings":";;;;;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMC,kBAAqC,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EACpDE,kBAAkB,EAAE,EAAE;EACtBC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,KAAK;EACfC,yBAAyB,EAAE,KAAK;EAChCC,iBAAiB,EAAE;AACpB,CAAC;AAEM,SAASC,gBAAgBA,CAC/BC,OAAiC,EACjCC,QAAwB,EACd;EACV,OAAOD,OAAO,EAAEN,kBAAkB,CAACQ,QAAQ,CAACD,QAAQ,CAAC,IAAI,KAAK;AAC/D;;AAEA;AACO,SAASE,iBAAiBA,CAACH,OAAiC,EAAEI,IAAe,EAAW;EAC9F,OAAOA,IAAI,KAAK,KAAK,GAAG,IAAI,GAAGJ,OAAO,EAAEL,QAAQ,KAAK,IAAI;AAC1D;AAEO,SAASU,aAAaA,CAACL,OAAiC,EAAW;EACzE,OAAOA,OAAO,EAAEJ,QAAQ,KAAK,IAAI;AAClC;;AAEA;AACO,SAASU,eAAeA,CAACC,SAAkB,EAAEC,IAAY,EAAQ;EACvE,IAAI,CAACD,SAAS,EAAE;IACf,MAAM,IAAIE,mBAAW,CAAC,uBAAuB,EAAE,iCAAiCD,IAAI,EAAE,CAAC;EACxF;AACD","ignoreList":[]}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SingleFlight = exports.DEFAULT_QUALITY = void 0;
7
+ exports.assertCaptureAllowed = assertCaptureAllowed;
8
+ exports.clampMaxDimension = clampMaxDimension;
9
+ exports.clampQuality = clampQuality;
10
+ exports.finalizeResult = finalizeResult;
11
+ var _types = require("../config/types.js");
12
+ var _errors = require("../diagnostics/errors.js");
13
+ var _capabilities = require("./capabilities.js");
14
+ var _sessionMachine = require("./sessionMachine.js");
15
+ /**
16
+ * Capture guards, single-flight enforcement, and metadata assembly
17
+ * (FR-020..FR-026b).
18
+ *
19
+ * The single-flight guard rejects rather than queues or coalesces. A queue
20
+ * turns a double-tapped shutter into two photos the user never asked for, and
21
+ * coalescing hides a deliberate second capture behind an accidental one — so a
22
+ * fast, explicit `captureInProgress` error is the only option that lets the app
23
+ * decide (clarification session 2026-07-26).
24
+ */
25
+
26
+ const DEFAULT_QUALITY = exports.DEFAULT_QUALITY = 0.9;
27
+ function clampQuality(quality) {
28
+ if (quality === undefined || Number.isNaN(quality)) {
29
+ return DEFAULT_QUALITY;
30
+ }
31
+ return Math.min(1, Math.max(0, quality));
32
+ }
33
+ function clampMaxDimension(maxDimension) {
34
+ if (maxDimension === undefined || !Number.isFinite(maxDimension) || maxDimension <= 0) {
35
+ return (0, _types.unavailable)();
36
+ }
37
+ return (0, _types.known)(Math.floor(maxDimension));
38
+ }
39
+ /**
40
+ * Validates a capture request against permission, readiness, and capability.
41
+ * Throws before any artifact could be created, so a rejected capture never
42
+ * leaves a file behind (FR-020).
43
+ */
44
+ function assertCaptureAllowed(context, request) {
45
+ if (!context.permissionGranted) {
46
+ throw new _errors.CameraError('permissionDenied', 'Camera permission is not granted');
47
+ }
48
+ if (!(0, _sessionMachine.canCapture)(context.sessionStatus)) {
49
+ throw new _errors.CameraError('notReady', `Camera is not ready (session: ${context.sessionStatus})`);
50
+ }
51
+ const flashMode = request.flashMode ?? context.flashMode;
52
+ (0, _capabilities.assertSupported)((0, _capabilities.supportsFlashMode)(context.capabilities, flashMode), `flash mode "${flashMode}"`);
53
+ const position = request.cameraPosition ?? context.cameraPosition;
54
+ (0, _capabilities.assertSupported)((0, _capabilities.supportsPosition)(context.capabilities, position), `${position} camera`);
55
+ if (position !== context.cameraPosition) {
56
+ // The photo would come from the camera that is running, while the
57
+ // metadata said it came from the one that was asked for (CAM-06).
58
+ throw new _errors.CameraError('notReady', `The ${context.cameraPosition} camera is running. Call start({ cameraPosition: ` + `'${position}' }) before capturing with the ${position} camera.`);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Normalizes whatever the engine returned into the published contract, filling
64
+ * in effective hint values and marking undeterminable fields explicitly
65
+ * unavailable rather than guessing them (FR-022, FR-023).
66
+ */
67
+ function finalizeResult(raw, request, context) {
68
+ const ownership = request.destination ? 'appOwned' : 'packageTemporary';
69
+ return {
70
+ ...raw,
71
+ ownership,
72
+ // The camera that took it, which the guard above has made the running one.
73
+ cameraPosition: raw.cameraPosition ?? context.cameraPosition,
74
+ timestamp: raw.timestamp ?? Date.now(),
75
+ effectiveQuality: raw.effectiveQuality ?? clampQuality(request.quality),
76
+ effectiveMaxDimension: raw.effectiveMaxDimension ?? clampMaxDimension(request.maxDimension),
77
+ fileSize: raw.fileSize ?? (0, _types.unavailable)(),
78
+ orientation: raw.orientation ?? (0, _types.unavailable)()
79
+ };
80
+ }
81
+
82
+ /**
83
+ * Serializes captures. The slot is taken synchronously, before the operation
84
+ * runs, so two calls in the same tick cannot both pass the check — and the
85
+ * operation's own first `emit()` already sees `busy`. Holding the operation's
86
+ * promise instead set the slot only after that first emit, so `capturing: true`
87
+ * was never published at all.
88
+ */
89
+ class SingleFlight {
90
+ active = false;
91
+ get busy() {
92
+ return this.active;
93
+ }
94
+ async run(operation) {
95
+ if (this.active) {
96
+ throw new _errors.CameraError('captureInProgress', 'A capture is already in progress');
97
+ }
98
+ this.active = true;
99
+ try {
100
+ return await operation();
101
+ } finally {
102
+ this.active = false;
103
+ }
104
+ }
105
+ }
106
+ exports.SingleFlight = SingleFlight;
107
+ //# sourceMappingURL=captureController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_errors","_capabilities","_sessionMachine","DEFAULT_QUALITY","exports","clampQuality","quality","undefined","Number","isNaN","Math","min","max","clampMaxDimension","maxDimension","isFinite","unavailable","known","floor","assertCaptureAllowed","context","request","permissionGranted","CameraError","canCapture","sessionStatus","flashMode","assertSupported","supportsFlashMode","capabilities","position","cameraPosition","supportsPosition","finalizeResult","raw","ownership","destination","timestamp","Date","now","effectiveQuality","effectiveMaxDimension","fileSize","orientation","SingleFlight","active","busy","run","operation"],"sourceRoot":"../../../src","sources":["core/captureController.ts"],"mappings":";;;;;;;;;;AAWA,IAAAA,MAAA,GAAAC,OAAA;AAWA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAzBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBO,MAAMI,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,GAAG;AAE3B,SAASE,YAAYA,CAACC,OAA2B,EAAU;EACjE,IAAIA,OAAO,KAAKC,SAAS,IAAIC,MAAM,CAACC,KAAK,CAACH,OAAO,CAAC,EAAE;IACnD,OAAOH,eAAe;EACvB;EACA,OAAOO,IAAI,CAACC,GAAG,C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AA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_TEMPORARY_TTL_MS = void 0;
7
+ /**
8
+ * What a camera controller is, for the app that drives it.
9
+ *
10
+ * The contract lives apart from the orchestration in `controller.ts`: it is
11
+ * what a consumer reads, and what a test double has to satisfy, while the file
12
+ * next to it is how this package happens to satisfy it.
13
+ */
14
+
15
+ const DEFAULT_TEMPORARY_TTL_MS = exports.DEFAULT_TEMPORARY_TTL_MS = 24 * 60 * 60 * 1000;
16
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEFAULT_TEMPORARY_TTL_MS","exports"],"sourceRoot":"../../../src","sources":["core/contract.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBO,MAAMA,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI","ignoreList":[]}