@octane-xplat/camera 0.19.0 → 0.20.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 (84) hide show
  1. package/README.md +2 -132
  2. package/package.json +20 -25
  3. package/platforms/android/java/com/octanexplat/camera/CameraPreviewView.java +24 -0
  4. package/platforms/android/java/com/octanexplat/camera/CameraSessionBridge.java +153 -21
  5. package/platforms/ios/src/XplatSwitchingMovieWriter.swift +557 -0
  6. package/src/CameraView.android.tsrx +187 -154
  7. package/src/CameraView.ios.tsrx +124 -110
  8. package/src/CameraView.macos.tsrx +103 -96
  9. package/src/CameraView.tsrx +2 -0
  10. package/src/CameraView.web.tsrx +157 -146
  11. package/src/CameraView.windows.tsrx +134 -125
  12. package/src/camera-host.macos.ts +1059 -0
  13. package/src/camera-permission.mobile.ts +85 -81
  14. package/src/camera-permission.windows.ts +56 -53
  15. package/src/camera-session.ios.ts +89 -61
  16. package/src/camera-session.macos.ts +51 -49
  17. package/src/camera-session.windows.ts +113 -105
  18. package/src/host-movie.web.ts +257 -231
  19. package/src/index.ts +28 -26
  20. package/src/index.web.ts +27 -25
  21. package/src/layout-child.ts +86 -79
  22. package/src/layout-child.web.ts +54 -53
  23. package/src/layout-child.windows.ts +80 -74
  24. package/src/movie-metadata.web.ts +84 -81
  25. package/src/movie-storage.web.ts +142 -135
  26. package/src/movie-writer.ios.ts +170 -0
  27. package/src/photo-lifecycle.macos.ts +60 -0
  28. package/src/photo-sheet.macos.ts +505 -0
  29. package/src/preview-display.ios.ts +69 -0
  30. package/src/preview-pinch.ts +41 -0
  31. package/src/preview-tap.ts +22 -21
  32. package/src/props.ts +115 -93
  33. package/src/recording-haptics.ios.ts +39 -0
  34. package/src/recording-source.web.ts +159 -0
  35. package/src/session-backend.android.ts +552 -410
  36. package/src/session-backend.ios.ts +1500 -1148
  37. package/src/session-backend.linux.ts +886 -860
  38. package/src/session-backend.macos.ts +697 -679
  39. package/src/session-backend.ts +51 -49
  40. package/src/session-backend.web.ts +1181 -867
  41. package/src/session-backend.windows.ts +1540 -1467
  42. package/src/session-core.ts +925 -714
  43. package/src/session.ts +12 -12
  44. package/src/style-merge.ts +40 -37
  45. package/src/synthetic-session.ts +391 -339
  46. package/src/types.ts +372 -298
  47. package/types/generated/.tsrx-typegen-manifest.json +4 -24
  48. package/types/generated/CameraView.d.ts +2 -0
  49. package/types/generated/camera-host.macos.d.ts +33 -0
  50. package/types/generated/index.d.ts +27 -26
  51. package/types/generated/photo-lifecycle.macos.d.ts +12 -0
  52. package/types/generated/photo-sheet.macos.d.ts +36 -0
  53. package/types/generated/props.d.ts +24 -2
  54. package/types/generated/session-core.d.ts +30 -1
  55. package/types/generated/synthetic-session.d.ts +7 -0
  56. package/types/generated/types.d.ts +75 -1
  57. package/platforms/macos/src/CameraOwnership.swift +0 -22
  58. package/platforms/macos/src/PhotoCaptureLifecycle.swift +0 -34
  59. package/platforms/macos/src/XplatCameraHost.swift +0 -639
  60. package/platforms/macos/src/XplatPhotoCaptureSheet.swift +0 -192
  61. package/types/generated/CameraView.android.d.ts +0 -9
  62. package/types/generated/CameraView.ios.d.ts +0 -5
  63. package/types/generated/CameraView.macos.d.ts +0 -5
  64. package/types/generated/CameraView.mobile.d.ts +0 -5
  65. package/types/generated/CameraView.windows.d.ts +0 -11
  66. package/types/generated/camera-permission.mobile.d.ts +0 -2
  67. package/types/generated/camera-permission.windows.d.ts +0 -6
  68. package/types/generated/camera-session.ios.d.ts +0 -2
  69. package/types/generated/camera-session.macos.d.ts +0 -10
  70. package/types/generated/camera-session.windows.d.ts +0 -9
  71. package/types/generated/host-movie.web.d.ts +0 -100
  72. package/types/generated/index.web.d.ts +0 -7
  73. package/types/generated/layout-child.d.ts +0 -11
  74. package/types/generated/layout-child.windows.d.ts +0 -13
  75. package/types/generated/movie-metadata.web.d.ts +0 -9
  76. package/types/generated/movie-storage.web.d.ts +0 -5
  77. package/types/generated/preview-tap.d.ts +0 -7
  78. package/types/generated/session-backend.android.d.ts +0 -3
  79. package/types/generated/session-backend.ios.d.ts +0 -5
  80. package/types/generated/session-backend.linux.d.ts +0 -3
  81. package/types/generated/session-backend.macos.d.ts +0 -8
  82. package/types/generated/session-backend.web.d.ts +0 -3
  83. package/types/generated/session-backend.windows.d.ts +0 -37
  84. package/types/generated/style-merge.d.ts +0 -8
package/src/types.ts CHANGED
@@ -19,66 +19,66 @@ export type CameraPermissionKind = 'camera' | 'microphone'
19
19
  * `unknown` exist so hosts that cannot distinguish user denial from
20
20
  * policy refusal do not fabricate `restricted`. */
21
21
  export type CameraPermissionStatus =
22
- | 'notDetermined'
23
- | 'granted'
24
- | 'denied'
25
- | 'restricted'
26
- | 'blocked'
27
- | 'unknown'
28
- | 'unavailable'
22
+ | 'notDetermined'
23
+ | 'granted'
24
+ | 'denied'
25
+ | 'restricted'
26
+ | 'blocked'
27
+ | 'unknown'
28
+ | 'unavailable'
29
29
 
30
30
  /** Portable error categories. `unsupported*` covers missing host features,
31
31
  * devices, or capture configurations — including adapters that are not
32
32
  * implemented yet during staged delivery. */
33
33
  export type CameraCaptureErrorKind =
34
- | 'permissionDenied'
35
- | 'permissionRestricted'
36
- | 'permissionBlocked'
37
- | 'unsupportedPlatform'
38
- | 'unsupportedConfiguration'
39
- | 'unavailable'
40
- | 'busy'
41
- | 'invalidState'
42
- | 'invalidArgument'
43
- | 'destinationUnavailable'
44
- | 'insufficientStorage'
45
- | 'noMedia'
46
- | 'captureFailed'
47
- | 'finalizationFailed'
48
- | 'storageFailed'
49
- | 'configurationMissing'
34
+ | 'permissionDenied'
35
+ | 'permissionRestricted'
36
+ | 'permissionBlocked'
37
+ | 'unsupportedPlatform'
38
+ | 'unsupportedConfiguration'
39
+ | 'unavailable'
40
+ | 'busy'
41
+ | 'invalidState'
42
+ | 'invalidArgument'
43
+ | 'destinationUnavailable'
44
+ | 'insufficientStorage'
45
+ | 'noMedia'
46
+ | 'captureFailed'
47
+ | 'finalizationFailed'
48
+ | 'storageFailed'
49
+ | 'configurationMissing'
50
50
 
51
51
  /** Structured diagnostic carried by failures and non-fatal warnings. */
52
52
  export interface CaptureIssue {
53
- /** Error category discriminator. */
54
- kind: CameraCaptureErrorKind
55
- /** Operation being attempted, e.g. 'startRecording', 'finalize'. */
56
- operation: string
57
- /** Human-readable failure description. */
58
- message: string
59
- /** Camera/mic authorization state. */
60
- permission?: CameraPermissionKind
61
- /** Underlying platform error when one exists — diagnostic only, never required for control flow. */
62
- cause?: unknown
53
+ /** Error category discriminator. */
54
+ kind: CameraCaptureErrorKind
55
+ /** Operation being attempted, e.g. 'startRecording', 'finalize'. */
56
+ operation: string
57
+ /** Human-readable failure description. */
58
+ message: string
59
+ /** Camera/mic authorization state. */
60
+ permission?: CameraPermissionKind
61
+ /** Underlying platform error when one exists — diagnostic only, never required for control flow. */
62
+ cause?: unknown
63
63
  }
64
64
 
65
65
  /** Error thrown or settled by the session API. Satisfies `CaptureIssue`
66
66
  * so `error.kind` drives control flow without unwrapping. */
67
67
  export class CameraCaptureError extends Error implements CaptureIssue {
68
- kind: CameraCaptureErrorKind
69
- operation: string
70
- permission?: CameraPermissionKind
71
- /** Underlying platform error when one exists — diagnostic only. */
72
- cause?: unknown
68
+ kind: CameraCaptureErrorKind
69
+ operation: string
70
+ permission?: CameraPermissionKind
71
+ /** Underlying platform error when one exists — diagnostic only. */
72
+ cause?: unknown
73
73
 
74
- constructor(issue: Omit<CaptureIssue, 'cause'> & { cause?: unknown }) {
75
- super(issue.message)
76
- this.name = 'CameraCaptureError'
77
- this.kind = issue.kind
78
- this.operation = issue.operation
79
- this.permission = issue.permission
80
- this.cause = issue.cause
81
- }
74
+ constructor(issue: Omit<CaptureIssue, 'cause'> & { cause?: unknown }) {
75
+ super(issue.message)
76
+ this.name = 'CameraCaptureError'
77
+ this.kind = issue.kind
78
+ this.operation = issue.operation
79
+ this.permission = issue.permission
80
+ this.cause = issue.cause
81
+ }
82
82
  }
83
83
 
84
84
  /** Lens direction vocabulary. */
@@ -90,19 +90,32 @@ export type CameraFacing = 'front' | 'back'
90
90
  * mirroring. The `CameraView` `onTap` event and
91
91
  * `CameraSession.focusAtPoint` share this space. */
92
92
  export interface CameraPreviewPoint {
93
- /** Focus/exposure point x, normalized 0-1. */
94
- x: number
95
- /** Focus/exposure point y, normalized 0-1. */
96
- y: number
93
+ /** Focus/exposure point x, normalized 0-1. */
94
+ x: number
95
+ /** Focus/exposure point y, normalized 0-1. */
96
+ y: number
97
+ }
98
+
99
+ /** Normalized pinch on the preview: `scale` is cumulative from gesture
100
+ * start (1 = no change) and `focus` is the focal point in the same
101
+ * preview space as `CameraPreviewPoint`. */
102
+ export interface CameraPinchEvent {
103
+ /** Scale factor relative to gesture start. */
104
+ scale: number
105
+ /** Gesture phase — began → moved → ended/cancelled. */
106
+ state: 'began' | 'moved' | 'ended' | 'cancelled'
107
+ /** Focal point normalized to the preview; falls back to the center when
108
+ * the platform does not report one. */
109
+ focus: CameraPreviewPoint
97
110
  }
98
111
 
99
112
  /** Capture orientation vocabulary. */
100
113
  export type CameraOrientation =
101
- | 'portrait'
102
- | 'portraitUpsideDown'
103
- | 'landscapeLeft'
104
- | 'landscapeRight'
105
- | 'unspecified'
114
+ | 'portrait'
115
+ | 'portraitUpsideDown'
116
+ | 'landscapeLeft'
117
+ | 'landscapeRight'
118
+ | 'unspecified'
106
119
 
107
120
  /** Camera selection for `CameraSessionConfig.camera`. Desktop and browser
108
121
  * hosts expose device identities instead of front/back semantics. */
@@ -110,85 +123,111 @@ export type CameraSelection = 'default' | 'front' | 'back' | { deviceId: string
110
123
 
111
124
  /** Configuration for opening a session. */
112
125
  export interface CameraSessionConfig {
113
- /** Lens or device identity. Default `'default'`: rear when available. */
114
- camera?: CameraSelection
115
- /** Include an audio track; requires microphone permission. Default
116
- * false — silent capture is a deliberate app choice, never a
117
- * fallback from denied microphone access. */
118
- audio?: boolean
119
- /** Capture profile. `'standard'` targets 720p at 30 fps and may select
120
- * a device-supported alternative; the started attempt discloses the
121
- * actual configuration. */
122
- profile?: 'standard'
126
+ /** Lens or device identity. Default `'default'`: rear when available. */
127
+ camera?: CameraSelection
128
+ /** Include an audio track; requires microphone permission. Default
129
+ * false — silent capture is a deliberate app choice, never a
130
+ * fallback from denied microphone access. */
131
+ audio?: boolean
132
+ /** iOS only: allow haptics AND system sounds while this session owns microphone
133
+ * capture (including preview). Other platforms ignore this iOS audio-session
134
+ * policy. Defaults to leaving the existing app policy unchanged. The previous
135
+ * value is restored after the last opted-in camera owner stops audio capture.
136
+ * External audio-session owners must coordinate policy changes with the app. */
137
+ ios?: { allowHapticsAndSystemSoundsDuringRecording?: boolean }
138
+ /** Capture profile. `'standard'` targets 720p at 30 fps and may select
139
+ * a device-supported alternative; the started attempt discloses the
140
+ * actual configuration. */
141
+ profile?: 'standard'
123
142
  }
124
143
 
125
144
  /** Resolution/frame-rate combination advertised by capability discovery.
126
145
  * Entries are supported combinations, not independent lists. */
127
146
  export interface CameraProfileCapability {
128
- /** Capture profile (resolution/framerate preset). */
129
- profile: 'standard'
130
- /** Frame width in pixels. */
131
- width: number
132
- /** Frame height in pixels. */
133
- height: number
134
- /** Frames per second. */
135
- frameRate: number
147
+ /** Capture profile (resolution/framerate preset). */
148
+ profile: 'standard'
149
+ /** Frame width in pixels. */
150
+ width: number
151
+ /** Frame height in pixels. */
152
+ height: number
153
+ /** Frames per second. */
154
+ frameRate: number
155
+ }
156
+
157
+ /** Live zoom state of the active camera. Ratios are relative to the
158
+ * device's unzoomed field of view: `1` is no zoom. Bounds belong to the
159
+ * currently bound device — a camera swap can change them. */
160
+ export interface CameraZoomState {
161
+ /** Current zoom ratio. */
162
+ zoom: number
163
+ /** Minimum ratio the active device accepts (1, or below 1 when the
164
+ * device switches to a wider constituent camera). */
165
+ minZoom: number
166
+ /** Maximum ratio the active device accepts. */
167
+ maxZoom: number
136
168
  }
137
169
 
138
170
  /** One usable camera device. */
139
171
  export interface CameraDeviceInfo {
140
- /** Device-stable camera identifier. */
141
- /** Store-assigned id. */
172
+ /** Device-stable camera identifier. */
173
+ /** Store-assigned id. */
142
174
 
143
- id: string
144
- /** Human-readable device name. */
145
- label: string
146
- /** Lens direction. */
147
- facing?: CameraFacing
175
+ id: string
176
+ /** Human-readable device name. */
177
+ label: string
178
+ /** Lens direction. */
179
+ facing?: CameraFacing
148
180
  }
149
181
 
150
182
  /** What the session's host can do right now. `supported: false` means the
151
183
  * adapter or host cannot record (reason explains); `available` reflects
152
184
  * current hardware/permission state and changes over time. */
153
185
  export interface CameraSessionCapabilities {
154
- /** A camera backend exists on this leaf. */
155
- supported: boolean
156
- /** Why capture is unsupported or currently unavailable. */
157
- reason?: string
158
- /** At least one usable camera is present. */
159
- available: boolean
160
- /** Detected camera devices. */
161
- cameras: CameraDeviceInfo[]
162
- /** Capture profiles the session can run. */
163
- profiles: CameraProfileCapability[]
164
- /** The session can add an audio track when permission allows. */
165
- audio: boolean
166
- /** `focusAtPoint` can move autofocus metering on the active camera —
167
- * false on fixed-focus devices (common for front cameras) and on
168
- * platforms without point-of-interest metering. */
169
- focusPointOfInterest: boolean
170
- /** `focusAtPoint` can move auto-exposure metering on the active
171
- * camera. */
172
- exposurePointOfInterest: boolean
173
- /** Fixed orientations the source can lock for a take. */
174
- orientations: CameraOrientation[]
175
- /** `native` enforcement can still overshoot at media boundaries;
176
- * `bestEffort` limits are scheduled and may overshoot more. */
177
- durationLimit: 'native' | 'bestEffort'
178
- /** Where `elapsedMs` comes from while recording. */
179
- elapsedTime: 'nativeMedia' | 'estimated'
180
- /** Where the clip was written. */
181
- output: {
182
- /** Output MIME type. */
183
- mimeType: string
184
- /** File container format. */
185
- container: string
186
- /** `appPrivateFile` output survives dispose and app restart;
187
- * `originLocal` is browser storage subject to site-data clearing. */
188
- storage: 'appPrivateFile' | 'originLocal'
189
- /** Accepts an app-supplied `destinationFileUrl` on start. */
190
- destinationFileUrl: boolean
191
- }
186
+ /** A camera backend exists on this leaf. */
187
+ supported: boolean
188
+ /** Why capture is unsupported or currently unavailable. */
189
+ reason?: string
190
+ /** At least one usable camera is present. */
191
+ available: boolean
192
+ /** Detected camera devices. */
193
+ cameras: CameraDeviceInfo[]
194
+ /** Capture profiles the session can run. */
195
+ profiles: CameraProfileCapability[]
196
+ /** The session can add an audio track when permission allows. */
197
+ audio: boolean
198
+ /** Live `switchCamera` preserves the take, continuous requested audio,
199
+ * held video during acquisition, and one output file. False means
200
+ * camera selection is available only through idle `configure`. */
201
+ cameraSwitchDuringRecording: boolean
202
+ /** `focusAtPoint` can move autofocus metering on the active camera —
203
+ * false on fixed-focus devices (common for front cameras) and on
204
+ * platforms without point-of-interest metering. */
205
+ focusPointOfInterest: boolean
206
+ /** `focusAtPoint` can move auto-exposure metering on the active
207
+ * camera. */
208
+ exposurePointOfInterest: boolean
209
+ /** The active camera reports live zoom control through `zoomState`
210
+ * and `setZoom` (`zoomState().maxZoom > minZoom`). */
211
+ zoom: boolean
212
+ /** Fixed orientations the source can lock for a take. */
213
+ orientations: CameraOrientation[]
214
+ /** `native` enforcement can still overshoot at media boundaries;
215
+ * `bestEffort` limits are scheduled and may overshoot more. */
216
+ durationLimit: 'native' | 'bestEffort'
217
+ /** Where `elapsedMs` comes from while recording. */
218
+ elapsedTime: 'nativeMedia' | 'estimated'
219
+ /** Where the clip was written. */
220
+ output: {
221
+ /** Output MIME type. */
222
+ mimeType: string
223
+ /** File container format. */
224
+ container: string
225
+ /** `appPrivateFile` output survives dispose and app restart;
226
+ * `originLocal` is browser storage subject to site-data clearing. */
227
+ storage: 'appPrivateFile' | 'originLocal'
228
+ /** Accepts an app-supplied `destinationFileUrl` on start. */
229
+ destinationFileUrl: boolean
230
+ }
192
231
  }
193
232
 
194
233
  /** Recorder lifecycle states. */
@@ -196,233 +235,268 @@ export type CameraRecorderState = 'idle' | 'starting' | 'recording' | 'finalizin
196
235
 
197
236
  /** Frozen capture configuration reported once capture actually begins. */
198
237
  export interface EffectiveCaptureConfig {
199
- /** The CameraDeviceInfo.id in use. */
200
- cameraId: string
201
- /** Lens direction. */
202
- facing?: CameraFacing
203
- /** Whether audio capture is enabled for video. */
204
- audio: boolean
205
- /** Frame width in pixels. */
206
- width: number
207
- /** Frame height in pixels. */
208
- height: number
209
- /** Frames per second. */
210
- frameRate: number
211
- /** Capture orientation. */
212
- orientation: CameraOrientation
213
- /** Output MIME type. */
214
- mimeType: string
215
- /** File container format. */
216
- container: string
238
+ /** The CameraDeviceInfo.id in use. */
239
+ cameraId: string
240
+ /** Lens direction. */
241
+ facing?: CameraFacing
242
+ /** Whether audio capture is enabled for video. */
243
+ audio: boolean
244
+ /** Frame width in pixels. */
245
+ width: number
246
+ /** Frame height in pixels. */
247
+ height: number
248
+ /** Frames per second. */
249
+ frameRate: number
250
+ /** Capture orientation. */
251
+ orientation: CameraOrientation
252
+ /** Output MIME type. */
253
+ mimeType: string
254
+ /** File container format. */
255
+ container: string
217
256
  }
218
257
 
219
258
  /** Observable session state. */
220
259
  export interface CameraSessionSnapshot {
221
- /** Current lifecycle state. */
222
- state: CameraRecorderState
223
- /** Non-prompting last-known authorization, refreshed by `permissions()`
224
- * and `requestPermission()`. */
225
- permission: Record<CameraPermissionKind, CameraPermissionStatus>
226
- /** Camera hardware/driver availability, separate from recorder state. */
227
- cameraAvailable: boolean
228
- /** An active preview view is attached to this session. */
229
- previewAttached: boolean
230
- /** Interrupted by the OS (call, route change, …). */
231
- interrupted: boolean
232
- /** Retry count for the current operation. */
233
- attempt?: {
234
- /** Device-stable camera identifier. */
235
- id: string
236
- /** Current lifecycle state. */
237
- state: 'starting' | 'recording' | 'finalizing'
238
- elapsedMs: number
239
- configuration?: EffectiveCaptureConfig
240
- }
260
+ /** A live switch is pending. Recorder state remains `recording`. */
261
+ switchingCamera: boolean
262
+ /** Latest camera confirmed by a started take or successful live switch.
263
+ * The attempt configuration remains the immutable starting config. */
264
+ activeCamera?: CameraDeviceInfo
265
+ /** Current lifecycle state. */
266
+ state: CameraRecorderState
267
+ /** Non-prompting last-known authorization, refreshed by `permissions()`
268
+ * and `requestPermission()`. */
269
+ permission: Record<CameraPermissionKind, CameraPermissionStatus>
270
+ /** Camera hardware/driver availability, separate from recorder state. */
271
+ cameraAvailable: boolean
272
+ /** An active preview view is attached to this session. */
273
+ previewAttached: boolean
274
+ /** Interrupted by the OS (call, route change, …). */
275
+ interrupted: boolean
276
+ /** Retry count for the current operation. */
277
+ attempt?: {
278
+ /** Device-stable camera identifier. */
279
+ id: string
280
+ /** Current lifecycle state. */
281
+ state: 'starting' | 'recording' | 'finalizing'
282
+ elapsedMs: number
283
+ configuration?: EffectiveCaptureConfig
284
+ }
241
285
  }
242
286
 
243
287
  /** What ended a capture attempt. `interrupted` covers system suspension
244
288
  * and preview teardown; `previewReleased` distinguishes an app-driven
245
289
  * deactivation from an OS interruption. */
246
290
  export type MovieEndReason =
247
- | 'stopped'
248
- | 'maximumDuration'
249
- | 'interrupted'
250
- | 'backgrounded'
251
- | 'cameraUnavailable'
252
- | 'previewReleased'
253
- | 'disposed'
254
- | 'captureError'
291
+ | 'stopped'
292
+ | 'maximumDuration'
293
+ | 'interrupted'
294
+ | 'backgrounded'
295
+ | 'cameraUnavailable'
296
+ | 'previewReleased'
297
+ | 'disposed'
298
+ | 'captureError'
255
299
 
256
300
  /** Portable completed-output reference. `resourceId` reopens the clip
257
301
  * through `openOutput`; `fileUrl` additionally guarantees file-backed
258
302
  * native output. `synthetic` marks test-seam clips. */
259
303
  export type MovieOutput =
260
- | {
261
- /** Error category discriminator. */
262
- kind: 'nativeFile'
263
- /** Store handle for the clip (gallery/native ref). */
264
- resourceId: string
265
- /** Filesystem URL of the written clip. */
266
- /** Filesystem URL of the written clip. */
304
+ | {
305
+ /** Error category discriminator. */
306
+ kind: 'nativeFile'
307
+ /** Store handle for the clip (gallery/native ref). */
308
+ resourceId: string
309
+ /** Filesystem URL of the written clip. */
310
+ /** Filesystem URL of the written clip. */
267
311
 
268
- fileUrl: string
269
- /** True for generated/test clips, not real captures. */
270
- synthetic?: boolean
271
- }
272
- | {
273
- /** Error category discriminator. */
274
- kind: 'browserStorage'
275
- /** Store handle for the clip (gallery/native ref). */
276
- resourceId: string
277
- retention: 'persistent' | 'bestEffort'
278
- /** True for generated/test clips, not real captures. */
279
- synthetic?: boolean
280
- }
312
+ fileUrl: string
313
+ /** True for generated/test clips, not real captures. */
314
+ synthetic?: boolean
315
+ }
316
+ | {
317
+ /** Error category discriminator. */
318
+ kind: 'browserStorage'
319
+ /** Store handle for the clip (gallery/native ref). */
320
+ resourceId: string
321
+ retention: 'persistent' | 'bestEffort'
322
+ /** True for generated/test clips, not real captures. */
323
+ synthetic?: boolean
324
+ }
281
325
 
282
326
  /** One finished recording. */
283
327
  export interface MovieClip {
284
- /** Where the clip was written. */
285
- output: MovieOutput
286
- /** Output MIME type. */
287
- mimeType: string
288
- /** Authoritative duration read from the finalized movie. */
289
- durationMs: number
290
- /** Presentation dimensions after the orientation transform. */
291
- width: number
292
- /** Frame height in pixels. */
293
- height: number
294
- /** Capture orientation. */
295
- orientation: CameraOrientation
296
- /** Whether the finalized movie actually contains an audio track.
297
- * Missing requested audio is a failure, not silent capture. */
298
- hasAudio: boolean
328
+ /** Where the clip was written. */
329
+ output: MovieOutput
330
+ /** Output MIME type. */
331
+ mimeType: string
332
+ /** Authoritative duration read from the finalized movie. */
333
+ durationMs: number
334
+ /** Presentation dimensions after the orientation transform. */
335
+ width: number
336
+ /** Frame height in pixels. */
337
+ height: number
338
+ /** Capture orientation. */
339
+ orientation: CameraOrientation
340
+ /** Whether the finalized movie actually contains an audio track.
341
+ * Missing requested audio is a failure, not silent capture. */
342
+ hasAudio: boolean
299
343
  }
300
344
 
301
345
  /** One immutable terminal result per admitted attempt. `partial` marks a
302
346
  * usable clip ended early by an external condition — still a success;
303
347
  * app review decides whether to keep it. */
304
348
  export type MovieOutcome =
305
- | {
306
- /** Error category discriminator. */
307
- kind: 'clip'
308
- clip: MovieClip
309
- /** Why recording stopped. */
310
- endReason: MovieEndReason
311
- partial: boolean
312
- warning?: CaptureIssue
313
- }
314
- | {
315
- /** Error category discriminator. */
316
- kind: 'failed'
317
- /** Why recording stopped. */
318
- endReason: MovieEndReason
319
- stage: 'preparation' | 'capture' | 'finalization' | 'storage'
320
- error: CaptureIssue
321
- }
349
+ | {
350
+ /** Error category discriminator. */
351
+ kind: 'clip'
352
+ clip: MovieClip
353
+ /** Why recording stopped. */
354
+ endReason: MovieEndReason
355
+ partial: boolean
356
+ warning?: CaptureIssue
357
+ }
358
+ | {
359
+ /** Error category discriminator. */
360
+ kind: 'failed'
361
+ /** Why recording stopped. */
362
+ endReason: MovieEndReason
363
+ stage: 'preparation' | 'capture' | 'finalization' | 'storage'
364
+ error: CaptureIssue
365
+ }
322
366
 
323
367
  /** Ordered lifecycle observation, correlated to an attempt when relevant. */
324
368
  export type CameraSessionEvent =
325
- | { type: 'stateChanged'; snapshot: CameraSessionSnapshot }
326
- | { type: 'started'; attemptId: string; configuration: EffectiveCaptureConfig }
327
- | { type: 'finished'; attemptId: string; outcome: MovieOutcome }
328
- | {
329
- /** Output kind discriminator. */
330
- type: 'interruption'
331
- phase: 'began' | 'ended'
332
- reason?: CameraInterruptionReason
333
- }
334
- | { type: 'availability'; available: boolean }
369
+ | { type: 'stateChanged'; snapshot: CameraSessionSnapshot }
370
+ | { type: 'started'; attemptId: string; configuration: EffectiveCaptureConfig }
371
+ | { type: 'finished'; attemptId: string; outcome: MovieOutcome }
372
+ | {
373
+ /** Output kind discriminator. */
374
+ type: 'interruption'
375
+ phase: 'began' | 'ended'
376
+ reason?: CameraInterruptionReason
377
+ }
378
+ | { type: 'availability'; available: boolean }
335
379
 
336
380
  /** Why the OS interrupted capture. */
337
381
  export type CameraInterruptionReason =
338
- | 'background'
339
- | 'audioInUse'
340
- | 'cameraInUse'
341
- | 'multitasking'
342
- | 'systemPressure'
343
- | 'unknown'
382
+ | 'background'
383
+ | 'audioInUse'
384
+ | 'cameraInUse'
385
+ | 'multitasking'
386
+ | 'systemPressure'
387
+ | 'unknown'
344
388
 
345
389
  /** Options for session.startRecording(). */
346
390
  export interface StartRecordingOptions {
347
- /** Positive finite milliseconds. Enforcement precision comes from
348
- * `capabilities().durationLimit`; the final duration is read from
349
- * the movie and may overshoot. */
350
- maximumDurationMs?: number
351
- /** Fixed orientation for the take. Must appear in
352
- * `capabilities().orientations`; omit for the source default. */
353
- orientation?: CameraOrientation
354
- /** App-supplied writable local `file://` URL (native hosts only,
355
- * where `capabilities().output.destinationFileUrl` is true).
356
- * Existing files are never overwritten. */
357
- destinationFileUrl?: string
391
+ /** Positive finite milliseconds. Enforcement precision comes from
392
+ * `capabilities().durationLimit`; the final duration is read from
393
+ * the movie and may overshoot. */
394
+ maximumDurationMs?: number
395
+ /** Fixed orientation for the take. Must appear in
396
+ * `capabilities().orientations`; omit for the source default. */
397
+ orientation?: CameraOrientation
398
+ /** App-supplied writable local `file://` URL (native hosts only,
399
+ * where `capabilities().output.destinationFileUrl` is true).
400
+ * Existing files are never overwritten. */
401
+ destinationFileUrl?: string
358
402
  }
359
403
 
360
404
  /** One admitted capture attempt. `completion` is available immediately and
361
405
  * settles exactly once with the terminal outcome; repeated `stop()`
362
406
  * joins the same finalization. */
363
407
  export interface MovieTake {
364
- /** Attempt identifier — unique per `startRecording` call. */
365
- readonly id: string
366
- /** Lifecycle phase; terminal value is `settled` (check `completion` for the outcome). */
367
- readonly state: 'starting' | 'recording' | 'finalizing' | 'settled'
368
- /** Elapsed capture time in milliseconds; excludes preparation and
369
- * finalization. Source identified by `capabilities().elapsedTime`. */
370
- readonly elapsedMs: number
371
- /** Terminal outcome — resolves exactly once; `stop()` returns this same promise. */
372
- readonly completion: Promise<MovieOutcome>
373
- /** Requests stop and joins finalization. Returns `completion`. */
374
- stop(): Promise<MovieOutcome>
408
+ /** Attempt identifier — unique per `startRecording` call. */
409
+ readonly id: string
410
+ /** Lifecycle phase; terminal value is `settled` (check `completion` for the outcome). */
411
+ readonly state: 'starting' | 'recording' | 'finalizing' | 'settled'
412
+ /** Elapsed capture time in milliseconds; excludes preparation and
413
+ * finalization. Source identified by `capabilities().elapsedTime`. */
414
+ readonly elapsedMs: number
415
+ /** Terminal outcome — resolves exactly once; `stop()` returns this same promise. */
416
+ readonly completion: Promise<MovieOutcome>
417
+ /** Requests stop and joins finalization. Returns `completion`. */
418
+ stop(): Promise<MovieOutcome>
375
419
  }
376
420
 
377
421
  /** Reopened access to a stored clip. `release()` frees temporary access;
378
422
  * it never deletes the clip. */
379
423
  export interface MovieOutputHandle {
380
- /** Playable/readable location for the clip. */
381
- readonly url: string
382
- /** On-disk path when the clip is file-backed; absent for memory/remote storage. */
383
- readonly fileUrl?: string
384
- /** Free temporary access to the clip — never deletes it. */
385
- release(): void
424
+ /** Playable/readable location for the clip. */
425
+ readonly url: string
426
+ /** On-disk path when the clip is file-backed; absent for memory/remote storage. */
427
+ readonly fileUrl?: string
428
+ /** Free temporary access to the clip — never deletes it. */
429
+ release(): void
386
430
  }
387
431
 
388
432
  /** An owned camera session — dispose when done. */
389
433
  export interface CameraSession {
390
- /** Non-prompting permission inspection; may return `unknown` when the
391
- * host cannot observe authorization. */
392
- permissions(): Promise<Record<CameraPermissionKind, CameraPermissionStatus>>
393
- /** Runs the system authorization flow for one kind. Calls are
394
- * serialized; a status other than `notDetermined` returns without
395
- * prompting. */
396
- requestPermission(kind: CameraPermissionKind): Promise<CameraPermissionStatus>
397
- /** Hardware/OS limits for this session — polled live, so values can change as devices come and go. */
398
- capabilities(): Promise<CameraSessionCapabilities>
399
- /** Point-in-time session state — subscribe for changes. */
400
- snapshot(): CameraSessionSnapshot
401
- /** Ordered lifecycle events. A caller never loses a result by
402
- * subscribing late — `completion` is authoritative. Listener
403
- * exceptions do not change capture. */
404
- subscribe(listener: (event: CameraSessionEvent) => void): () => void
405
- /** Tap-to-focus: meters one autofocus/auto-exposure pass at a
406
- * normalized preview-space point (see `CameraPreviewPoint`), pairing
407
- * with the `CameraView` `onTap` event. No-ops while no preview is
408
- * attached, after `dispose`, and on hosts without point-of-interest
409
- * metering — `capabilities()` reports `focusPointOfInterest` and
410
- * `exposurePointOfInterest` separately. Out-of-range coordinates
411
- * clamp to the preview edge; non-finite coordinates throw
412
- * `invalidArgument`. Metering is per-device state: a camera swap
413
- * through `configure` returns focus/exposure to the new device's
414
- * default. */
415
- focusAtPoint(point: CameraPreviewPoint): void
416
- /** Replaces configuration while idle. Validates against current
417
- * capabilities and rejects with `invalidState` during an attempt. */
418
- configure(config: Partial<CameraSessionConfig>): Promise<void>
419
- /** Admits one capture attempt. Throws `CameraCaptureError` before
420
- * admission for invalid arguments, busy, invalid state, or
421
- * unavailable camera — no attempt is created. */
422
- startRecording(options?: StartRecordingOptions): MovieTake
423
- /** Reopens a stored output for playback or reading. */
424
- openOutput(output: MovieOutput): Promise<MovieOutputHandle>
425
- /** Requests stop on any active attempt, awaits finalization, then
426
- * releases camera ownership. */
427
- dispose(): Promise<void>
434
+ /** Non-prompting permission inspection; may return `unknown` when the
435
+ * host cannot observe authorization. */
436
+ permissions(): Promise<Record<CameraPermissionKind, CameraPermissionStatus>>
437
+ /** Runs the system authorization flow for one kind. Calls are
438
+ * serialized; a status other than `notDetermined` returns without
439
+ * prompting. */
440
+ requestPermission(kind: CameraPermissionKind): Promise<CameraPermissionStatus>
441
+ /** Hardware/OS limits for this session — polled live, so values can change as devices come and go. */
442
+ capabilities(): Promise<CameraSessionCapabilities>
443
+ /** Point-in-time session state — subscribe for changes. */
444
+ snapshot(): CameraSessionSnapshot
445
+ /** Ordered lifecycle events. A caller never loses a result by
446
+ * subscribing late — `completion` is authoritative. Listener
447
+ * exceptions do not change capture. */
448
+ subscribe(listener: (event: CameraSessionEvent) => void): () => void
449
+ /** Tap-to-focus: meters one autofocus/auto-exposure pass at a
450
+ * normalized preview-space point (see `CameraPreviewPoint`), pairing
451
+ * with the `CameraView` `onTap` event. No-ops while no preview is
452
+ * attached, after `dispose`, and on hosts without point-of-interest
453
+ * metering — `capabilities()` reports `focusPointOfInterest` and
454
+ * `exposurePointOfInterest` separately. Out-of-range coordinates
455
+ * clamp to the preview edge; non-finite coordinates throw
456
+ * `invalidArgument`. Metering is per-device state: a camera swap
457
+ * through `configure` returns focus/exposure to the new device's
458
+ * default. */
459
+ focusAtPoint(point: CameraPreviewPoint): void
460
+ /** Live zoom state of the active camera (see `CameraZoomState`).
461
+ * Returns `undefined` while no camera is bound, after `dispose`, and
462
+ * on hosts or devices without zoom control — check
463
+ * `capabilities().zoom` before showing zoom UI. Values change with
464
+ * the bound device: re-read after `configure` or `switchCamera`. */
465
+ zoomState(): CameraZoomState | undefined
466
+ /** Writes a zoom ratio on the active camera without reconfiguring the
467
+ * session; works while recording. Values clamp to the active
468
+ * device's live `zoomState()` bounds on every write. No-ops while no
469
+ * camera is bound, after `dispose`, and on hosts without zoom
470
+ * control. Non-finite values throw `invalidArgument`. */
471
+ setZoom(ratio: number): void
472
+ /** Replaces configuration while idle. Validates against current
473
+ * capabilities and rejects with `invalidState` during an attempt,
474
+ * including one admitted while capability discovery was pending.
475
+ * Live camera changes use `switchCamera` when advertised; rejection
476
+ * leaves the take running and does not request stop. */
477
+ configure(config: Partial<CameraSessionConfig>): Promise<void>
478
+ /** Change only the camera during `recording`. Audio and elapsed time
479
+ * continue while video holds its last frame. Resolves when the replacement
480
+ * camera is producing frames on the existing recording path; this is source
481
+ * readiness, not an encoded-frame acknowledgement. Completion still belongs
482
+ * to the original take. Rejects `busy` for overlapping switches,
483
+ * `invalidState` outside recording, and `unsupportedConfiguration`
484
+ * when the host cannot preserve this contract. Use idle `configure`
485
+ * before starting a take. Cancellation never restarts recording.
486
+ * @example
487
+ * import type { CameraSession } from '@octane-xplat/camera'
488
+ * async function faceFront(session: CameraSession): Promise<void> {
489
+ * await session.switchCamera('front')
490
+ * }
491
+ */
492
+ switchCamera(camera: CameraSelection): Promise<void>
493
+ /** Admits one capture attempt. Throws `CameraCaptureError` before
494
+ * admission for invalid arguments, busy, invalid state, or
495
+ * unavailable camera — no attempt is created. */
496
+ startRecording(options?: StartRecordingOptions): MovieTake
497
+ /** Reopens a stored output for playback or reading. */
498
+ openOutput(output: MovieOutput): Promise<MovieOutputHandle>
499
+ /** Requests stop on any active attempt, awaits finalization, then
500
+ * releases camera ownership. */
501
+ dispose(): Promise<void>
428
502
  }