@octane-xplat/camera 0.18.0 → 0.19.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 (54) hide show
  1. package/README.md +9 -9
  2. package/package.json +113 -103
  3. package/src/CameraView.android.tsrx +64 -21
  4. package/src/CameraView.ios.tsrx +48 -9
  5. package/src/CameraView.macos.tsrx +38 -7
  6. package/src/CameraView.web.tsrx +35 -11
  7. package/src/CameraView.windows.tsrx +56 -16
  8. package/src/host-movie.web.ts +22 -4
  9. package/src/layout-child.ts +3 -1
  10. package/src/layout-child.web.ts +6 -1
  11. package/src/layout-child.windows.ts +6 -1
  12. package/src/movie-metadata.web.ts +11 -1
  13. package/src/props.ts +28 -0
  14. package/src/session-backend.windows.ts +25 -9
  15. package/src/session-core.ts +4 -1
  16. package/src/style-merge.ts +3 -6
  17. package/src/synthetic-session.ts +7 -0
  18. package/src/types.ts +72 -1
  19. package/types/generated/.tsrx-typegen-manifest.json +38 -0
  20. package/types/generated/CameraView.android.d.ts +9 -0
  21. package/types/generated/CameraView.ios.d.ts +5 -0
  22. package/types/generated/CameraView.macos.d.ts +5 -0
  23. package/types/generated/CameraView.mobile.d.ts +5 -0
  24. package/types/generated/CameraView.web.d.ts +4 -0
  25. package/types/generated/CameraView.windows.d.ts +11 -0
  26. package/types/generated/camera-permission.mobile.d.ts +2 -0
  27. package/types/generated/camera-permission.windows.d.ts +6 -0
  28. package/types/generated/camera-session.ios.d.ts +2 -0
  29. package/types/generated/camera-session.macos.d.ts +10 -0
  30. package/types/generated/camera-session.windows.d.ts +9 -0
  31. package/types/generated/host-movie.web.d.ts +100 -0
  32. package/types/generated/index.d.ts +33 -0
  33. package/types/generated/index.web.d.ts +7 -0
  34. package/types/generated/layout-child.d.ts +11 -0
  35. package/types/generated/layout-child.web.d.ts +7 -0
  36. package/types/generated/layout-child.windows.d.ts +13 -0
  37. package/types/generated/movie-metadata.web.d.ts +9 -0
  38. package/types/generated/movie-storage.web.d.ts +5 -0
  39. package/types/generated/preview-tap.d.ts +7 -0
  40. package/types/{props.d.ts → generated/props.d.ts} +29 -1
  41. package/types/generated/session-backend.android.d.ts +3 -0
  42. package/types/generated/session-backend.d.ts +6 -0
  43. package/types/generated/session-backend.ios.d.ts +5 -0
  44. package/types/generated/session-backend.linux.d.ts +3 -0
  45. package/types/generated/session-backend.macos.d.ts +8 -0
  46. package/types/generated/session-backend.web.d.ts +3 -0
  47. package/types/generated/session-backend.windows.d.ts +37 -0
  48. package/types/{session-core.d.ts → generated/session-core.d.ts} +1 -1
  49. package/types/generated/session.d.ts +16 -0
  50. package/types/generated/style-merge.d.ts +8 -0
  51. package/types/{synthetic-session.d.ts → generated/synthetic-session.d.ts} +8 -1
  52. package/types/{types.d.ts → generated/types.d.ts} +70 -1
  53. package/LICENSE +0 -21
  54. package/types/index.d.ts +0 -48
@@ -1,35 +1,59 @@
1
1
  import type { Octane } from 'octane/jsx-runtime';
2
- import type { CameraPreviewPoint, CameraSession } from './types';
2
+ import type { CameraPreviewPoint, CameraSession } from './types.js';
3
+ /** Accessibility roles the preview accepts. */
3
4
  export type CameraAccessibilityRole = 'button' | 'link' | 'search' | 'image' | 'heading' | 'adjustable' | 'summary' | 'text' | 'none' | 'progressbar' | 'checkbox' | 'switch' | 'radio' | 'spinbutton' | 'tab';
5
+ /** Imperative handle exposed through the CameraView `ref`. */
4
6
  export interface CameraViewHandle {
5
7
  /** The native preview surface (`HTMLVideoElement` on web). */
6
8
  native: any;
7
9
  }
10
+ /** Props for the CameraView element. */
8
11
  export interface CameraViewProps {
12
+ /** Class list applied to the preview element. */
9
13
  className?: any;
14
+ /** Inline style (string CSS or object). */
10
15
  style?: any;
16
+ /** Element id passed through to the host element. */
11
17
  id?: string;
18
+ /** Zero-based row index in the parent grid. */
12
19
  row?: number;
20
+ /** Zero-based column index. */
13
21
  col?: number;
22
+ /** Row tracks to span (>= 1). */
14
23
  rowSpan?: number;
24
+ /** Column tracks to span (>= 1). */
15
25
  colSpan?: number;
26
+ /** Edge of the parent dock layout this child pins to. */
16
27
  dock?: 'left' | 'top' | 'right' | 'bottom';
28
+ /** Absolute x offset in dips. */
17
29
  left?: number;
30
+ /** Absolute y offset in dips. */
18
31
  top?: number;
32
+ /** Flex grow factor. */
19
33
  flexGrow?: number;
34
+ /** Flex shrink factor. */
20
35
  flexShrink?: number;
36
+ /** Cross-axis self alignment. */
21
37
  alignSelf?: string;
38
+ /** Sibling ordering. */
22
39
  order?: number;
40
+ /** Expose to assistive tech as an accessibility element. */
23
41
  accessible?: boolean;
42
+ /** Spoken name for assistive tech. */
24
43
  accessibilityLabel?: string;
44
+ /** Semantic role mapped per platform. */
25
45
  accessibilityRole?: CameraAccessibilityRole;
46
+ /** Spoken hint describing what activating does. */
26
47
  accessibilityHint?: string;
48
+ /** Spoken current value text. */
27
49
  accessibilityValue?: string;
50
+ /** State flags merged into the platform a11y state. */
28
51
  accessibilityState?: {
29
52
  disabled?: boolean;
30
53
  selected?: boolean;
31
54
  checked?: boolean;
32
55
  };
56
+ /** Live-region announcements: polite queues, assertive interrupts. */
33
57
  accessibilityLiveRegion?: 'none' | 'polite' | 'assertive';
34
58
  /** Shared camera owner enabling movie recording. When set, the preview
35
59
  * attaches to the session's acquisition instead of owning one, and
@@ -41,6 +65,7 @@ export interface CameraViewProps {
41
65
  active?: boolean;
42
66
  /** Fires after the preview surface starts. */
43
67
  onReady?: () => void;
68
+ /** Camera/preview errors. */
44
69
  onError?: (error: {
45
70
  message?: string;
46
71
  }) => void;
@@ -55,7 +80,10 @@ export interface CameraViewProps {
55
80
  ref?: Octane.Ref<CameraViewHandle>;
56
81
  /** Platform-specific properties applied to the preview surface. */
57
82
  ios?: Record<string, any>;
83
+ /** Platform escape hatch — same bag contract as `ios`. */
58
84
  android?: Record<string, any>;
85
+ /** Platform escape hatch — same bag contract as `ios`. */
59
86
  web?: Record<string, any>;
87
+ /** Platform escape hatch — same bag contract as `ios`. */
60
88
  windows?: Record<string, any>;
61
89
  }
@@ -0,0 +1,3 @@
1
+ import type { CameraSessionBackend } from './session-core.js';
2
+ import type { CameraSessionConfig } from './types.js';
3
+ export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
@@ -0,0 +1,6 @@
1
+ import type { CameraSessionBackend } from './session-core.js';
2
+ import type { CameraSessionConfig } from './types.js';
3
+ /** Default adapter for platforms without a movie-capture implementation
4
+ * yet. Honest `unsupported` reporting — never fabricated capture. Kept
5
+ * platform-pure so web and native fallback builds share it. */
6
+ export declare function createSessionBackend(_config: CameraSessionConfig): CameraSessionBackend;
@@ -0,0 +1,5 @@
1
+ import type { CameraSessionBackend } from './session-core.js';
2
+ import type { CameraSessionConfig } from './types.js';
3
+ /** iOS adapter: one AVCaptureSession shared between the attached preview
4
+ * and a single AVCaptureMovieFileOutput capture attempt. */
5
+ export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
@@ -0,0 +1,3 @@
1
+ import type { CameraSessionBackend } from './session-core.js';
2
+ import type { CameraSessionConfig } from './types.js';
3
+ export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
@@ -0,0 +1,8 @@
1
+ import '@nativescript/macos-node-api';
2
+ import type { CameraSessionBackend } from './session-core.js';
3
+ import type { CameraSessionConfig } from './types.js';
4
+ /** AppKit adapter: one XplatCameraHost (AVCaptureSession) shared between the
5
+ * attached preview and a single AVCaptureMovieFileOutput capture attempt.
6
+ * The Swift leaf owns the session, inputs, preview layer, and recording
7
+ * delegate; this adapter owns admission, semantics, and contract mapping. */
8
+ export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
@@ -0,0 +1,3 @@
1
+ import type { CameraSessionBackend } from './session-core.js';
2
+ import type { CameraSessionConfig } from './types.js';
3
+ export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
@@ -0,0 +1,37 @@
1
+ import type { CameraSessionBackend } from './session-core.js';
2
+ import type { CameraOrientation, CameraPermissionStatus, CameraSessionConfig, CaptureIssue } from './types.js';
3
+ /** AppCapabilityAccessStatus → portable permission. `notDeclared` is a
4
+ * setup error, not a status — callers surface `configurationMissing`. */
5
+ export declare const accessStatusToPermission: (status: number | undefined) => CameraPermissionStatus | 'notDeclared';
6
+ /** DeviceAccessStatus → portable permission for hosts without AppCapability. */
7
+ export declare const deviceAccessStatusToPermission: (status: number | undefined) => CameraPermissionStatus;
8
+ /** Enclosure panel → facing. Desktop cameras often report no panel — an
9
+ * external webcam never fabricates front/back semantics. */
10
+ export declare const panelToFacing: (panel: number | undefined) => 'front' | 'back' | undefined;
11
+ /** Stored display rotation (degrees CW) → cardinal orientation, matching the
12
+ * iOS transform mapping. Missing or unrecognized values stay `unspecified`. */
13
+ export declare const videoOrientationToOrientation: (degrees: number | undefined) => CameraOrientation;
14
+ export declare const orientationToRotation: (orientation: CameraOrientation) => number | undefined;
15
+ export interface WindowsCameraDevice {
16
+ id: string;
17
+ label: string;
18
+ facing?: 'front' | 'back';
19
+ }
20
+ /** Camera selection: explicit deviceId wins; front/back match the enclosure
21
+ * panel; `default` takes the OS-preferred camera then the first device. */
22
+ export declare const selectCameraDevice: (camera: CameraSessionConfig['camera'], devices: WindowsCameraDevice[], defaultId: string | undefined) => WindowsCameraDevice | undefined;
23
+ export interface WindowsStreamProfile {
24
+ width: number;
25
+ height: number;
26
+ frameRate: number;
27
+ subtype?: string;
28
+ }
29
+ /** Pick the standard profile: 1280x720 @ 30 fps when the source offers it,
30
+ * otherwise the smallest stream then lowest frame rate. The selected
31
+ * combination is disclosed — never an idealized 720p claim. */
32
+ export declare const chooseStandardProfile: (profiles: WindowsStreamProfile[]) => WindowsStreamProfile | undefined;
33
+ /** Classify a native failure without depending on projected error shapes.
34
+ * HRESULTs surface as `number`/`hresult`; MediaCapture failures also carry a
35
+ * numeric `code`. */
36
+ export declare const captureFailureKind: (cause: unknown) => CaptureIssue['kind'];
37
+ export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
@@ -1,4 +1,4 @@
1
- import type { CameraInterruptionReason, CameraPermissionKind, CameraPermissionStatus, CameraPreviewPoint, CameraSession, CameraSessionCapabilities, CameraSessionConfig, CameraSessionEvent, CameraSessionSnapshot, CaptureIssue, EffectiveCaptureConfig, MovieEndReason, MovieOutput, MovieOutputHandle, MovieTake, StartRecordingOptions } from './types';
1
+ import type { CameraInterruptionReason, CameraPermissionKind, CameraPermissionStatus, CameraPreviewPoint, CameraSession, CameraSessionCapabilities, CameraSessionConfig, CameraSessionEvent, CameraSessionSnapshot, CaptureIssue, EffectiveCaptureConfig, MovieEndReason, MovieOutput, MovieOutputHandle, MovieTake, StartRecordingOptions } from './types.js';
2
2
  /** Result an adapter reports when a capture attempt settles. Media
3
3
  * metadata is already read from the finalized movie by the adapter. */
4
4
  export type BackendSettle = {
@@ -0,0 +1,16 @@
1
+ import type { BackendPreviewListener } from './session-core.js';
2
+ import type { CameraSession, CameraSessionConfig } from './types.js';
3
+ /** Create a shared camera owner: one acquisition shared between a
4
+ * `CameraView` preview (`session` prop) and at most one movie-recording
5
+ * attempt. Creating a session never prompts for permission or acquires
6
+ * hardware — both happen when a session-backed preview activates or a
7
+ * permission request runs.
8
+ *
9
+ * Recording support is delivered per platform; `capabilities()` reports
10
+ * honest `supported`/`available` state on every host. */
11
+ export declare function createCameraSession(config?: CameraSessionConfig): CameraSession;
12
+ /** Package-internal: attach `host` as the session's preview surface.
13
+ * Used by `CameraView` when its `session` prop is set; detaching the
14
+ * returned function requests stop on an in-flight attempt and releases
15
+ * camera ownership once finalization settles. */
16
+ export declare function attachSessionPreview(session: CameraSession, host: unknown, listener?: BackendPreviewListener): () => void;
@@ -0,0 +1,8 @@
1
+ /** Anything accepted as a style value, including nested arrays. */
2
+ export type StyleInput = string | Record<string, any> | null | undefined | readonly StyleInput[];
3
+ /** Merge component-emitted style defaults under the authored `style` prop.
4
+ * Authored keys win; array styles fold in order; a string style is appended
5
+ * after the serialized defaults so its declarations override them too. */
6
+ export declare function mergeStyle(base: Record<string, any>, style?: Record<string, any> | readonly (Record<string, any> | null | undefined)[] | null): Record<string, any>;
7
+ export declare function mergeStyle(base: Record<string, any>, style?: StyleInput): string | Record<string, any>;
8
+ export type StyleProp = string | Record<string, any> | readonly StyleProp[] | null | undefined;
@@ -1,4 +1,4 @@
1
- import type { CameraInterruptionReason, CameraPermissionStatus, CameraPreviewPoint, CameraSession, CameraSessionConfig } from './types';
1
+ import type { CameraInterruptionReason, CameraPermissionStatus, CameraPreviewPoint, CameraSession, CameraSessionConfig } from './types.js';
2
2
  /** Development/testing seam — a deterministic camera source that drives
3
3
  * the shared session state machine without hardware. NOT a production
4
4
  * recording source: outcomes carry `synthetic: true` on their output so
@@ -9,6 +9,7 @@ import type { CameraInterruptionReason, CameraPermissionStatus, CameraPreviewPoi
9
9
  * partial completions, and failures.
10
10
  */
11
11
  export interface SyntheticCameraScript {
12
+ /** Storage access state. */
12
13
  permission: {
13
14
  camera: CameraPermissionStatus;
14
15
  microphone: CameraPermissionStatus;
@@ -34,15 +35,21 @@ export interface SyntheticCameraScript {
34
35
  * here so a spec can observe metering requests. */
35
36
  focusRequests?: CameraPreviewPoint[];
36
37
  }
38
+ /** Storage backing for synthetic/test camera clips. */
37
39
  export interface SyntheticCameraStorage {
40
+ /** Write a synthetic clip to storage. */
38
41
  write(path: string, bytes: Uint8Array): void | Promise<void>;
42
+ /** Read a stored clip. */
39
43
  read(path: string): Uint8Array | undefined | Promise<Uint8Array | undefined>;
44
+ /** Remove a stored clip; optional — reopen paths degrade gracefully without it. */
40
45
  delete?(path: string): void | Promise<void>;
46
+ /** Probe for a stored clip without reading it. */
41
47
  exists?(path: string): boolean | Promise<boolean>;
42
48
  }
43
49
  /** In-memory storage for the seam — a `fileUrl`-shaped map so outcomes
44
50
  * exercise the same reopen path without touching a real filesystem. */
45
51
  export declare function createMemoryCameraStorage(): SyntheticCameraStorage & {
52
+ /** Stored clip bytes keyed by path — specs assert on this map directly. */
46
53
  files: Map<string, Uint8Array>;
47
54
  };
48
55
  /** Create a `CameraSession` backed by the deterministic synthetic source.
@@ -23,12 +23,15 @@ export type CameraPermissionStatus = 'notDetermined' | 'granted' | 'denied' | 'r
23
23
  export type CameraCaptureErrorKind = 'permissionDenied' | 'permissionRestricted' | 'permissionBlocked' | 'unsupportedPlatform' | 'unsupportedConfiguration' | 'unavailable' | 'busy' | 'invalidState' | 'invalidArgument' | 'destinationUnavailable' | 'insufficientStorage' | 'noMedia' | 'captureFailed' | 'finalizationFailed' | 'storageFailed' | 'configurationMissing';
24
24
  /** Structured diagnostic carried by failures and non-fatal warnings. */
25
25
  export interface CaptureIssue {
26
+ /** Error category discriminator. */
26
27
  kind: CameraCaptureErrorKind;
27
28
  /** Operation being attempted, e.g. 'startRecording', 'finalize'. */
28
29
  operation: string;
30
+ /** Human-readable failure description. */
29
31
  message: string;
32
+ /** Camera/mic authorization state. */
30
33
  permission?: CameraPermissionKind;
31
- /** Host-specific detail for logging; never required for control flow. */
34
+ /** Underlying platform error when one exists — diagnostic only, never required for control flow. */
32
35
  cause?: unknown;
33
36
  }
34
37
  /** Error thrown or settled by the session API. Satisfies `CaptureIssue`
@@ -37,11 +40,13 @@ export declare class CameraCaptureError extends Error implements CaptureIssue {
37
40
  kind: CameraCaptureErrorKind;
38
41
  operation: string;
39
42
  permission?: CameraPermissionKind;
43
+ /** Underlying platform error when one exists — diagnostic only. */
40
44
  cause?: unknown;
41
45
  constructor(issue: Omit<CaptureIssue, 'cause'> & {
42
46
  cause?: unknown;
43
47
  });
44
48
  }
49
+ /** Lens direction vocabulary. */
45
50
  export type CameraFacing = 'front' | 'back';
46
51
  /** A normalized position on the live preview as the user sees it:
47
52
  * `{x: 0, y: 0}` is the top-left corner and `{x: 1, y: 1}` is
@@ -49,15 +54,19 @@ export type CameraFacing = 'front' | 'back';
49
54
  * mirroring. The `CameraView` `onTap` event and
50
55
  * `CameraSession.focusAtPoint` share this space. */
51
56
  export interface CameraPreviewPoint {
57
+ /** Focus/exposure point x, normalized 0-1. */
52
58
  x: number;
59
+ /** Focus/exposure point y, normalized 0-1. */
53
60
  y: number;
54
61
  }
62
+ /** Capture orientation vocabulary. */
55
63
  export type CameraOrientation = 'portrait' | 'portraitUpsideDown' | 'landscapeLeft' | 'landscapeRight' | 'unspecified';
56
64
  /** Camera selection for `CameraSessionConfig.camera`. Desktop and browser
57
65
  * hosts expose device identities instead of front/back semantics. */
58
66
  export type CameraSelection = 'default' | 'front' | 'back' | {
59
67
  deviceId: string;
60
68
  };
69
+ /** Configuration for opening a session. */
61
70
  export interface CameraSessionConfig {
62
71
  /** Lens or device identity. Default `'default'`: rear when available. */
63
72
  camera?: CameraSelection;
@@ -73,25 +82,38 @@ export interface CameraSessionConfig {
73
82
  /** Resolution/frame-rate combination advertised by capability discovery.
74
83
  * Entries are supported combinations, not independent lists. */
75
84
  export interface CameraProfileCapability {
85
+ /** Capture profile (resolution/framerate preset). */
76
86
  profile: 'standard';
87
+ /** Frame width in pixels. */
77
88
  width: number;
89
+ /** Frame height in pixels. */
78
90
  height: number;
91
+ /** Frames per second. */
79
92
  frameRate: number;
80
93
  }
94
+ /** One usable camera device. */
81
95
  export interface CameraDeviceInfo {
96
+ /** Device-stable camera identifier. */
97
+ /** Store-assigned id. */
82
98
  id: string;
99
+ /** Human-readable device name. */
83
100
  label: string;
101
+ /** Lens direction. */
84
102
  facing?: CameraFacing;
85
103
  }
86
104
  /** What the session's host can do right now. `supported: false` means the
87
105
  * adapter or host cannot record (reason explains); `available` reflects
88
106
  * current hardware/permission state and changes over time. */
89
107
  export interface CameraSessionCapabilities {
108
+ /** A camera backend exists on this leaf. */
90
109
  supported: boolean;
91
110
  /** Why capture is unsupported or currently unavailable. */
92
111
  reason?: string;
112
+ /** At least one usable camera is present. */
93
113
  available: boolean;
114
+ /** Detected camera devices. */
94
115
  cameras: CameraDeviceInfo[];
116
+ /** Capture profiles the session can run. */
95
117
  profiles: CameraProfileCapability[];
96
118
  /** The session can add an audio track when permission allows. */
97
119
  audio: boolean;
@@ -109,8 +131,11 @@ export interface CameraSessionCapabilities {
109
131
  durationLimit: 'native' | 'bestEffort';
110
132
  /** Where `elapsedMs` comes from while recording. */
111
133
  elapsedTime: 'nativeMedia' | 'estimated';
134
+ /** Where the clip was written. */
112
135
  output: {
136
+ /** Output MIME type. */
113
137
  mimeType: string;
138
+ /** File container format. */
114
139
  container: string;
115
140
  /** `appPrivateFile` output survives dispose and app restart;
116
141
  * `originLocal` is browser storage subject to site-data clearing. */
@@ -119,20 +144,32 @@ export interface CameraSessionCapabilities {
119
144
  destinationFileUrl: boolean;
120
145
  };
121
146
  }
147
+ /** Recorder lifecycle states. */
122
148
  export type CameraRecorderState = 'idle' | 'starting' | 'recording' | 'finalizing' | 'disposed';
123
149
  /** Frozen capture configuration reported once capture actually begins. */
124
150
  export interface EffectiveCaptureConfig {
151
+ /** The CameraDeviceInfo.id in use. */
125
152
  cameraId: string;
153
+ /** Lens direction. */
126
154
  facing?: CameraFacing;
155
+ /** Whether audio capture is enabled for video. */
127
156
  audio: boolean;
157
+ /** Frame width in pixels. */
128
158
  width: number;
159
+ /** Frame height in pixels. */
129
160
  height: number;
161
+ /** Frames per second. */
130
162
  frameRate: number;
163
+ /** Capture orientation. */
131
164
  orientation: CameraOrientation;
165
+ /** Output MIME type. */
132
166
  mimeType: string;
167
+ /** File container format. */
133
168
  container: string;
134
169
  }
170
+ /** Observable session state. */
135
171
  export interface CameraSessionSnapshot {
172
+ /** Current lifecycle state. */
136
173
  state: CameraRecorderState;
137
174
  /** Non-prompting last-known authorization, refreshed by `permissions()`
138
175
  * and `requestPermission()`. */
@@ -141,9 +178,13 @@ export interface CameraSessionSnapshot {
141
178
  cameraAvailable: boolean;
142
179
  /** An active preview view is attached to this session. */
143
180
  previewAttached: boolean;
181
+ /** Interrupted by the OS (call, route change, …). */
144
182
  interrupted: boolean;
183
+ /** Retry count for the current operation. */
145
184
  attempt?: {
185
+ /** Device-stable camera identifier. */
146
186
  id: string;
187
+ /** Current lifecycle state. */
147
188
  state: 'starting' | 'recording' | 'finalizing';
148
189
  elapsedMs: number;
149
190
  configuration?: EffectiveCaptureConfig;
@@ -157,24 +198,37 @@ export type MovieEndReason = 'stopped' | 'maximumDuration' | 'interrupted' | 'ba
157
198
  * through `openOutput`; `fileUrl` additionally guarantees file-backed
158
199
  * native output. `synthetic` marks test-seam clips. */
159
200
  export type MovieOutput = {
201
+ /** Error category discriminator. */
160
202
  kind: 'nativeFile';
203
+ /** Store handle for the clip (gallery/native ref). */
161
204
  resourceId: string;
205
+ /** Filesystem URL of the written clip. */
206
+ /** Filesystem URL of the written clip. */
162
207
  fileUrl: string;
208
+ /** True for generated/test clips, not real captures. */
163
209
  synthetic?: boolean;
164
210
  } | {
211
+ /** Error category discriminator. */
165
212
  kind: 'browserStorage';
213
+ /** Store handle for the clip (gallery/native ref). */
166
214
  resourceId: string;
167
215
  retention: 'persistent' | 'bestEffort';
216
+ /** True for generated/test clips, not real captures. */
168
217
  synthetic?: boolean;
169
218
  };
219
+ /** One finished recording. */
170
220
  export interface MovieClip {
221
+ /** Where the clip was written. */
171
222
  output: MovieOutput;
223
+ /** Output MIME type. */
172
224
  mimeType: string;
173
225
  /** Authoritative duration read from the finalized movie. */
174
226
  durationMs: number;
175
227
  /** Presentation dimensions after the orientation transform. */
176
228
  width: number;
229
+ /** Frame height in pixels. */
177
230
  height: number;
231
+ /** Capture orientation. */
178
232
  orientation: CameraOrientation;
179
233
  /** Whether the finalized movie actually contains an audio track.
180
234
  * Missing requested audio is a failure, not silent capture. */
@@ -184,13 +238,17 @@ export interface MovieClip {
184
238
  * usable clip ended early by an external condition — still a success;
185
239
  * app review decides whether to keep it. */
186
240
  export type MovieOutcome = {
241
+ /** Error category discriminator. */
187
242
  kind: 'clip';
188
243
  clip: MovieClip;
244
+ /** Why recording stopped. */
189
245
  endReason: MovieEndReason;
190
246
  partial: boolean;
191
247
  warning?: CaptureIssue;
192
248
  } | {
249
+ /** Error category discriminator. */
193
250
  kind: 'failed';
251
+ /** Why recording stopped. */
194
252
  endReason: MovieEndReason;
195
253
  stage: 'preparation' | 'capture' | 'finalization' | 'storage';
196
254
  error: CaptureIssue;
@@ -208,6 +266,7 @@ export type CameraSessionEvent = {
208
266
  attemptId: string;
209
267
  outcome: MovieOutcome;
210
268
  } | {
269
+ /** Output kind discriminator. */
211
270
  type: 'interruption';
212
271
  phase: 'began' | 'ended';
213
272
  reason?: CameraInterruptionReason;
@@ -215,7 +274,9 @@ export type CameraSessionEvent = {
215
274
  type: 'availability';
216
275
  available: boolean;
217
276
  };
277
+ /** Why the OS interrupted capture. */
218
278
  export type CameraInterruptionReason = 'background' | 'audioInUse' | 'cameraInUse' | 'multitasking' | 'systemPressure' | 'unknown';
279
+ /** Options for session.startRecording(). */
219
280
  export interface StartRecordingOptions {
220
281
  /** Positive finite milliseconds. Enforcement precision comes from
221
282
  * `capabilities().durationLimit`; the final duration is read from
@@ -233,11 +294,14 @@ export interface StartRecordingOptions {
233
294
  * settles exactly once with the terminal outcome; repeated `stop()`
234
295
  * joins the same finalization. */
235
296
  export interface MovieTake {
297
+ /** Attempt identifier — unique per `startRecording` call. */
236
298
  readonly id: string;
299
+ /** Lifecycle phase; terminal value is `settled` (check `completion` for the outcome). */
237
300
  readonly state: 'starting' | 'recording' | 'finalizing' | 'settled';
238
301
  /** Elapsed capture time in milliseconds; excludes preparation and
239
302
  * finalization. Source identified by `capabilities().elapsedTime`. */
240
303
  readonly elapsedMs: number;
304
+ /** Terminal outcome — resolves exactly once; `stop()` returns this same promise. */
241
305
  readonly completion: Promise<MovieOutcome>;
242
306
  /** Requests stop and joins finalization. Returns `completion`. */
243
307
  stop(): Promise<MovieOutcome>;
@@ -247,9 +311,12 @@ export interface MovieTake {
247
311
  export interface MovieOutputHandle {
248
312
  /** Playable/readable location for the clip. */
249
313
  readonly url: string;
314
+ /** On-disk path when the clip is file-backed; absent for memory/remote storage. */
250
315
  readonly fileUrl?: string;
316
+ /** Free temporary access to the clip — never deletes it. */
251
317
  release(): void;
252
318
  }
319
+ /** An owned camera session — dispose when done. */
253
320
  export interface CameraSession {
254
321
  /** Non-prompting permission inspection; may return `unknown` when the
255
322
  * host cannot observe authorization. */
@@ -258,7 +325,9 @@ export interface CameraSession {
258
325
  * serialized; a status other than `notDetermined` returns without
259
326
  * prompting. */
260
327
  requestPermission(kind: CameraPermissionKind): Promise<CameraPermissionStatus>;
328
+ /** Hardware/OS limits for this session — polled live, so values can change as devices come and go. */
261
329
  capabilities(): Promise<CameraSessionCapabilities>;
330
+ /** Point-in-time session state — subscribe for changes. */
262
331
  snapshot(): CameraSessionSnapshot;
263
332
  /** Ordered lifecycle events. A caller never loses a result by
264
333
  * subscribing late — `completion` is authoritative. Listener
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2026 Alec Larson
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
package/types/index.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import type { UniversalComponent } from 'octane/universal'
2
- import type { CameraViewProps } from './props.js'
3
- import type { CameraSession, CameraSessionConfig } from './types.js'
4
- import type { SyntheticCameraScript, SyntheticCameraStorage } from './synthetic-session.js'
5
-
6
- export declare const CameraView: UniversalComponent<CameraViewProps>
7
- export type { CameraViewHandle, CameraViewProps, CameraAccessibilityRole } from './props.js'
8
-
9
- export declare function createCameraSession(config?: CameraSessionConfig): CameraSession
10
- export declare function createSyntheticCameraSession(
11
- config?: CameraSessionConfig,
12
- script?: Partial<SyntheticCameraScript>,
13
- storage?: SyntheticCameraStorage,
14
- ): CameraSession
15
-
16
- export declare function createMemoryCameraStorage(): SyntheticCameraStorage & {
17
- files: Map<string, Uint8Array>
18
- }
19
-
20
- export { CameraCaptureError } from './types.js'
21
- export type {
22
- CameraCaptureErrorKind,
23
- CameraDeviceInfo,
24
- CameraFacing,
25
- CameraInterruptionReason,
26
- CameraOrientation,
27
- CameraPermissionKind,
28
- CameraPermissionStatus,
29
- CameraProfileCapability,
30
- CameraRecorderState,
31
- CameraSelection,
32
- CameraSession,
33
- CameraSessionCapabilities,
34
- CameraSessionConfig,
35
- CameraSessionEvent,
36
- CameraSessionSnapshot,
37
- CaptureIssue,
38
- EffectiveCaptureConfig,
39
- MovieClip,
40
- MovieEndReason,
41
- MovieOutcome,
42
- MovieOutput,
43
- MovieOutputHandle,
44
- MovieTake,
45
- StartRecordingOptions,
46
- } from './types.js'
47
-
48
- export type { SyntheticCameraScript, SyntheticCameraStorage } from './synthetic-session.js'