@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.
- package/README.md +9 -9
- package/package.json +113 -103
- package/src/CameraView.android.tsrx +64 -21
- package/src/CameraView.ios.tsrx +48 -9
- package/src/CameraView.macos.tsrx +38 -7
- package/src/CameraView.web.tsrx +35 -11
- package/src/CameraView.windows.tsrx +56 -16
- package/src/host-movie.web.ts +22 -4
- package/src/layout-child.ts +3 -1
- package/src/layout-child.web.ts +6 -1
- package/src/layout-child.windows.ts +6 -1
- package/src/movie-metadata.web.ts +11 -1
- package/src/props.ts +28 -0
- package/src/session-backend.windows.ts +25 -9
- package/src/session-core.ts +4 -1
- package/src/style-merge.ts +3 -6
- package/src/synthetic-session.ts +7 -0
- package/src/types.ts +72 -1
- package/types/generated/.tsrx-typegen-manifest.json +38 -0
- package/types/generated/CameraView.android.d.ts +9 -0
- package/types/generated/CameraView.ios.d.ts +5 -0
- package/types/generated/CameraView.macos.d.ts +5 -0
- package/types/generated/CameraView.mobile.d.ts +5 -0
- package/types/generated/CameraView.web.d.ts +4 -0
- package/types/generated/CameraView.windows.d.ts +11 -0
- package/types/generated/camera-permission.mobile.d.ts +2 -0
- package/types/generated/camera-permission.windows.d.ts +6 -0
- package/types/generated/camera-session.ios.d.ts +2 -0
- package/types/generated/camera-session.macos.d.ts +10 -0
- package/types/generated/camera-session.windows.d.ts +9 -0
- package/types/generated/host-movie.web.d.ts +100 -0
- package/types/generated/index.d.ts +33 -0
- package/types/generated/index.web.d.ts +7 -0
- package/types/generated/layout-child.d.ts +11 -0
- package/types/generated/layout-child.web.d.ts +7 -0
- package/types/generated/layout-child.windows.d.ts +13 -0
- package/types/generated/movie-metadata.web.d.ts +9 -0
- package/types/generated/movie-storage.web.d.ts +5 -0
- package/types/generated/preview-tap.d.ts +7 -0
- package/types/{props.d.ts → generated/props.d.ts} +29 -1
- package/types/generated/session-backend.android.d.ts +3 -0
- package/types/generated/session-backend.d.ts +6 -0
- package/types/generated/session-backend.ios.d.ts +5 -0
- package/types/generated/session-backend.linux.d.ts +3 -0
- package/types/generated/session-backend.macos.d.ts +8 -0
- package/types/generated/session-backend.web.d.ts +3 -0
- package/types/generated/session-backend.windows.d.ts +37 -0
- package/types/{session-core.d.ts → generated/session-core.d.ts} +1 -1
- package/types/generated/session.d.ts +16 -0
- package/types/generated/style-merge.d.ts +8 -0
- package/types/{synthetic-session.d.ts → generated/synthetic-session.d.ts} +8 -1
- package/types/{types.d.ts → generated/types.d.ts} +70 -1
- package/LICENSE +0 -21
- package/types/index.d.ts +0 -48
package/src/CameraView.web.tsrx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
/** @jsxImportSource @octane-xplat/jsx/dom */
|
|
2
|
+
import type { JSX } from 'octane/jsx-runtime'
|
|
1
3
|
import { useImperativeHandle, useEffect, useRef } from 'octane'
|
|
2
4
|
import type { CameraViewProps } from './props'
|
|
3
5
|
import { attachSessionPreview } from './session'
|
|
4
6
|
import { applyEscapeProps, layoutChildProps } from './layout-child.web'
|
|
5
7
|
|
|
6
8
|
/** Live web preview backed by getUserMedia. */
|
|
7
|
-
export function CameraView(props: CameraViewProps) @{
|
|
8
|
-
const hostRef = useRef<any>(null)
|
|
9
|
+
export function CameraView(props: CameraViewProps): JSX.Element @{
|
|
10
|
+
const hostRef = useRef<any>(null)
|
|
9
11
|
const video = useRef<HTMLVideoElement | null>(null)
|
|
10
12
|
const facing = props.facing ?? 'back'
|
|
11
13
|
const active = props.active !== false
|
|
@@ -13,7 +15,10 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
13
15
|
|
|
14
16
|
useEffect(() => {
|
|
15
17
|
const element = video.current
|
|
16
|
-
if (!element || !active)
|
|
18
|
+
if (!element || !active) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
if (props.session) {
|
|
18
23
|
if (props.facing !== undefined) {
|
|
19
24
|
props.onError?.({ message: 'camera session conflicts with facing' })
|
|
@@ -47,7 +52,10 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
47
52
|
})
|
|
48
53
|
.then((nextStream) => {
|
|
49
54
|
if (disposed) {
|
|
50
|
-
for (const track of nextStream.getTracks())
|
|
55
|
+
for (const track of nextStream.getTracks()) {
|
|
56
|
+
track.stop()
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
return
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -67,11 +75,15 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
67
75
|
return () => {
|
|
68
76
|
disposed = true
|
|
69
77
|
element.srcObject = null
|
|
70
|
-
if (stream)
|
|
78
|
+
if (stream) {
|
|
79
|
+
for (const track of stream.getTracks()) {
|
|
80
|
+
track.stop()
|
|
81
|
+
}
|
|
82
|
+
}
|
|
71
83
|
}
|
|
72
84
|
}, [active, facing, props.session])
|
|
73
85
|
|
|
74
|
-
useImperativeHandle(props.ref, () => ({ native: hostRef.current }), undefined)
|
|
86
|
+
useImperativeHandle(props.ref, () => ({ native: hostRef.current }), undefined)
|
|
75
87
|
|
|
76
88
|
<div
|
|
77
89
|
id={props.id}
|
|
@@ -95,9 +107,12 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
95
107
|
@if (active) {
|
|
96
108
|
<video
|
|
97
109
|
ref={(element: HTMLVideoElement | null) => {
|
|
98
|
-
|
|
110
|
+
hostRef.current = element
|
|
99
111
|
video.current = element
|
|
100
|
-
if (!element)
|
|
112
|
+
if (!element) {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
|
|
101
116
|
applyEscapeProps(element, props)
|
|
102
117
|
}}
|
|
103
118
|
muted={true}
|
|
@@ -106,9 +121,15 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
106
121
|
onClick={(event: MouseEvent) => {
|
|
107
122
|
const onTap = props.onTap
|
|
108
123
|
const target = event.currentTarget as HTMLElement | null
|
|
109
|
-
if (!onTap || !target)
|
|
124
|
+
if (!onTap || !target) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
110
128
|
const rect = target.getBoundingClientRect()
|
|
111
|
-
if (!(rect.width > 0) || !(rect.height > 0))
|
|
129
|
+
if (!(rect.width > 0) || !(rect.height > 0)) {
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
112
133
|
onTap({
|
|
113
134
|
x: Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width)),
|
|
114
135
|
y: Math.min(1, Math.max(0, (event.clientY - rect.top) / rect.height)),
|
|
@@ -122,7 +143,10 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
122
143
|
transform: facing === 'front' ? 'scaleX(-1)' : undefined,
|
|
123
144
|
}}
|
|
124
145
|
onPlaying={() => {
|
|
125
|
-
if (props.session || readyFired.current)
|
|
146
|
+
if (props.session || readyFired.current) {
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
|
|
126
150
|
readyFired.current = true
|
|
127
151
|
props.onReady?.()
|
|
128
152
|
}}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
/** @jsxImportSource @
|
|
1
|
+
/** @jsxImportSource @octane-xplat/jsx */
|
|
2
2
|
import { useImperativeHandle, useCallback, useEffect, useRef } from 'octane'
|
|
3
3
|
import { View } from '@nativescript/core'
|
|
4
4
|
import { registerElement } from '@nativescript-community/octane'
|
|
5
|
-
import type { Attributes } from '@
|
|
5
|
+
import type { Attributes } from '@octane-xplat/jsx/intrinsics'
|
|
6
6
|
import type { CameraViewProps } from './props'
|
|
7
7
|
import { attachSessionPreview } from './session'
|
|
8
8
|
import { cameraHardwarePresent, ensureCameraPermission } from './camera-permission.windows'
|
|
9
9
|
import { startCameraPreview } from './camera-session.windows'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
applyEscapeProps,
|
|
12
|
+
layoutChildProps,
|
|
13
|
+
nativeAccessibilityRole,
|
|
14
|
+
nativeAccessibilityState,
|
|
15
|
+
} from './layout-child.windows'
|
|
16
|
+
|
|
11
17
|
import { observePreviewTap } from './preview-tap'
|
|
12
18
|
|
|
13
19
|
class CameraPreview extends View {
|
|
@@ -17,9 +23,9 @@ class CameraPreview extends View {
|
|
|
17
23
|
}
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
declare module '@
|
|
21
|
-
interface
|
|
22
|
-
camerapreview: Attributes<
|
|
26
|
+
declare module '@octane-xplat/jsx/intrinsics' {
|
|
27
|
+
interface NativeElements<TElement> {
|
|
28
|
+
camerapreview: Attributes<TElement, {}>
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
|
|
@@ -28,7 +34,7 @@ registerElement('camerapreview', CameraPreview)
|
|
|
28
34
|
/** Live Windows preview backed by WinUI `CaptureElement` + `MediaCapture`.
|
|
29
35
|
* With `session`, the preview attaches to the session-owned capture so
|
|
30
36
|
* movie recording shares it; without one the view owns its capture. */
|
|
31
|
-
export function CameraView(props: CameraViewProps) @{
|
|
37
|
+
export function CameraView(props: CameraViewProps): unknown @{
|
|
32
38
|
const host = useRef<any>(null)
|
|
33
39
|
const active = props.active !== false
|
|
34
40
|
const facing = props.facing ?? 'back'
|
|
@@ -40,7 +46,10 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
40
46
|
|
|
41
47
|
useEffect(() => {
|
|
42
48
|
const view = host.current
|
|
43
|
-
if (!view || !active)
|
|
49
|
+
if (!view || !active) {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
let disposed = false
|
|
45
54
|
let stopPreview: (() => Promise<void>) | undefined
|
|
46
55
|
const fail = (message: string) => props.onError?.({ message })
|
|
@@ -54,10 +63,14 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
54
63
|
try {
|
|
55
64
|
const detach = attachSessionPreview(props.session, view, {
|
|
56
65
|
onReady: () => {
|
|
57
|
-
if (!disposed)
|
|
66
|
+
if (!disposed) {
|
|
67
|
+
props.onReady?.()
|
|
68
|
+
}
|
|
58
69
|
},
|
|
59
70
|
onError: (issue) => {
|
|
60
|
-
if (!disposed)
|
|
71
|
+
if (!disposed) {
|
|
72
|
+
fail(issue.message)
|
|
73
|
+
}
|
|
61
74
|
},
|
|
62
75
|
})
|
|
63
76
|
|
|
@@ -77,7 +90,10 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
77
90
|
}
|
|
78
91
|
|
|
79
92
|
ensureCameraPermission().then(async (granted) => {
|
|
80
|
-
if (disposed)
|
|
93
|
+
if (disposed) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
if (!granted) {
|
|
82
98
|
fail('camera permission denied')
|
|
83
99
|
return
|
|
@@ -85,10 +101,14 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
85
101
|
|
|
86
102
|
try {
|
|
87
103
|
stopPreview = await startCameraPreview(view, facing, () => {
|
|
88
|
-
if (!disposed)
|
|
104
|
+
if (!disposed) {
|
|
105
|
+
props.onReady?.()
|
|
106
|
+
}
|
|
89
107
|
})
|
|
90
108
|
} catch (error: any) {
|
|
91
|
-
if (!disposed)
|
|
109
|
+
if (!disposed) {
|
|
110
|
+
fail(error?.message ?? 'camera error')
|
|
111
|
+
}
|
|
92
112
|
}
|
|
93
113
|
})
|
|
94
114
|
|
|
@@ -100,13 +120,33 @@ export function CameraView(props: CameraViewProps) @{
|
|
|
100
120
|
|
|
101
121
|
useEffect(() => {
|
|
102
122
|
const view = host.current
|
|
103
|
-
if (!view)
|
|
123
|
+
if (!view) {
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
104
127
|
applyEscapeProps(view.nativeViewProtected, props)
|
|
105
128
|
}, [props.ref, props.windows])
|
|
106
129
|
|
|
107
130
|
useEffect(() => observePreviewTap(host.current, props.onTap), [props.onTap])
|
|
108
131
|
|
|
109
|
-
<masonview
|
|
110
|
-
|
|
132
|
+
<masonview
|
|
133
|
+
id={props.id}
|
|
134
|
+
className={['vx-layers', 'vx-cameraview', props.className]}
|
|
135
|
+
{...layoutChildProps(props, {
|
|
136
|
+
display: 'grid',
|
|
137
|
+
gridTemplateRows: '1fr',
|
|
138
|
+
gridTemplateColumns: '1fr',
|
|
139
|
+
backgroundColor: '#000',
|
|
140
|
+
...props.style,
|
|
141
|
+
})}
|
|
142
|
+
accessible={props.accessible}
|
|
143
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
144
|
+
accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any}
|
|
145
|
+
accessibilityHint={props.accessibilityHint}
|
|
146
|
+
accessibilityValue={props.accessibilityValue}
|
|
147
|
+
accessibilityState={nativeAccessibilityState(props.accessibilityState) as any}
|
|
148
|
+
accessibilityLiveRegion={props.accessibilityLiveRegion as any}
|
|
149
|
+
>
|
|
150
|
+
<camerapreview ref={bindHost} style={{ gridRow: '1', gridColumn: '1' }} />
|
|
111
151
|
</masonview>
|
|
112
152
|
}
|
package/src/host-movie.web.ts
CHANGED
|
@@ -131,7 +131,15 @@ const mimeForFileUrl = (fileUrl: string): string =>
|
|
|
131
131
|
|
|
132
132
|
/** Reserve a host-side movie file. `destinationFileUrl` is validated
|
|
133
133
|
* host-side: it must be a new file inside the app-private storage root. */
|
|
134
|
-
export const reserveHostMovie
|
|
134
|
+
export const reserveHostMovie: (
|
|
135
|
+
host: CameraHost,
|
|
136
|
+
options: {
|
|
137
|
+
destinationFileUrl?: string
|
|
138
|
+
container?: string
|
|
139
|
+
},
|
|
140
|
+
) => Promise<{
|
|
141
|
+
fileUrl: string
|
|
142
|
+
}> = async (
|
|
135
143
|
host: CameraHost,
|
|
136
144
|
options: { destinationFileUrl?: string; container?: string },
|
|
137
145
|
): Promise<{ fileUrl: string }> => {
|
|
@@ -180,7 +188,11 @@ const supportsChunkedMovies = (host: CameraHost): Promise<boolean> => {
|
|
|
180
188
|
/** Commit finalized movie bytes to host-side app-private storage. Hosts
|
|
181
189
|
* with the chunked contract stream 4MB slices — a multi-hundred-MB
|
|
182
190
|
* recording no longer materializes ~3-4x its size across the bridge. */
|
|
183
|
-
export const commitHostMovie
|
|
191
|
+
export const commitHostMovie: (
|
|
192
|
+
host: CameraHost,
|
|
193
|
+
fileUrl: string,
|
|
194
|
+
bytes: Blob,
|
|
195
|
+
) => Promise<MovieOutput> = async (
|
|
184
196
|
host: CameraHost,
|
|
185
197
|
fileUrl: string,
|
|
186
198
|
bytes: Blob,
|
|
@@ -220,13 +232,19 @@ export const commitHostMovie = async (
|
|
|
220
232
|
}
|
|
221
233
|
|
|
222
234
|
/** Drop an uncommitted host reservation after a failed attempt. */
|
|
223
|
-
export const removeHostReservation
|
|
235
|
+
export const removeHostReservation: (host: CameraHost, fileUrl: string) => Promise<void> = async (
|
|
236
|
+
host: CameraHost,
|
|
237
|
+
fileUrl: string,
|
|
238
|
+
): Promise<void> => {
|
|
224
239
|
await host.call('camera', 'deleteMovieFile', { fileUrl }).catch(() => {})
|
|
225
240
|
}
|
|
226
241
|
|
|
227
242
|
/** Reopen a host-stored movie as a temporary playback URL. The durable
|
|
228
243
|
* reference remains `fileUrl`; the returned url lives until `release()`. */
|
|
229
|
-
export const openHostMovie
|
|
244
|
+
export const openHostMovie: (
|
|
245
|
+
host: CameraHost,
|
|
246
|
+
output: MovieOutput,
|
|
247
|
+
) => Promise<MovieOutputHandle> = async (
|
|
230
248
|
host: CameraHost,
|
|
231
249
|
output: MovieOutput,
|
|
232
250
|
): Promise<MovieOutputHandle> => {
|
package/src/layout-child.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { mergeStyle } from './style-merge'
|
|
|
6
6
|
export function layoutChildProps(
|
|
7
7
|
props: CameraViewProps,
|
|
8
8
|
baseStyle: Record<string, any> | string | undefined = props.style,
|
|
9
|
-
) {
|
|
9
|
+
): {
|
|
10
|
+
style: string | Record<string, any>
|
|
11
|
+
} {
|
|
10
12
|
const style: Record<string, any> = { ...(typeof baseStyle === 'object' ? baseStyle : {}) }
|
|
11
13
|
if (props.row !== undefined) {
|
|
12
14
|
style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
|
package/src/layout-child.web.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { CameraViewProps } from './props'
|
|
2
2
|
|
|
3
|
-
export function layoutChildProps(
|
|
3
|
+
export function layoutChildProps(
|
|
4
|
+
props: CameraViewProps,
|
|
5
|
+
baseStyle: any = props.style,
|
|
6
|
+
): {
|
|
7
|
+
style: any
|
|
8
|
+
} {
|
|
4
9
|
const style = { ...baseStyle }
|
|
5
10
|
if (props.row !== undefined) {
|
|
6
11
|
style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
|
|
@@ -9,7 +9,9 @@ import { mergeStyle } from './style-merge'
|
|
|
9
9
|
export function layoutChildProps(
|
|
10
10
|
props: CameraViewProps,
|
|
11
11
|
baseStyle: Record<string, any> | string | undefined = props.style,
|
|
12
|
-
) {
|
|
12
|
+
): {
|
|
13
|
+
style: string | Record<string, any>
|
|
14
|
+
} {
|
|
13
15
|
const style: Record<string, any> = { ...(typeof baseStyle === 'object' ? baseStyle : {}) }
|
|
14
16
|
if (props.row !== undefined) {
|
|
15
17
|
style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
|
|
@@ -26,12 +28,15 @@ export function layoutChildProps(
|
|
|
26
28
|
if (props.dock === 'left' || props.dock === 'top' || props.dock === 'bottom') {
|
|
27
29
|
style.left = style.left ?? 0
|
|
28
30
|
}
|
|
31
|
+
|
|
29
32
|
if (props.dock === 'right' || props.dock === 'top' || props.dock === 'bottom') {
|
|
30
33
|
style.right = style.right ?? 0
|
|
31
34
|
}
|
|
35
|
+
|
|
32
36
|
if (props.dock === 'top' || props.dock === 'left' || props.dock === 'right') {
|
|
33
37
|
style.top = style.top ?? 0
|
|
34
38
|
}
|
|
39
|
+
|
|
35
40
|
if (props.dock === 'bottom' || props.dock === 'left' || props.dock === 'right') {
|
|
36
41
|
style.bottom = style.bottom ?? 0
|
|
37
42
|
}
|
|
@@ -2,7 +2,17 @@ import { BlobSource, Input, MP4, WEBM } from 'mediabunny'
|
|
|
2
2
|
import { CameraCaptureError } from './types'
|
|
3
3
|
|
|
4
4
|
/** Read packet end timestamps and track metadata, never the wall-clock stop time. */
|
|
5
|
-
export async function inspectMovie(
|
|
5
|
+
export async function inspectMovie(
|
|
6
|
+
bytes: Blob,
|
|
7
|
+
audioRequested: boolean,
|
|
8
|
+
): Promise<{
|
|
9
|
+
durationMs: number
|
|
10
|
+
width: number
|
|
11
|
+
height: number
|
|
12
|
+
hasAudio: boolean
|
|
13
|
+
mimeType: string
|
|
14
|
+
orientation: 'unspecified'
|
|
15
|
+
}> {
|
|
6
16
|
if (!bytes.size) {
|
|
7
17
|
throw new CameraCaptureError({
|
|
8
18
|
kind: 'noMedia',
|
package/src/props.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Octane } from 'octane/jsx-runtime'
|
|
2
2
|
import type { CameraPreviewPoint, CameraSession } from './types'
|
|
3
3
|
|
|
4
|
+
/** Accessibility roles the preview accepts. */
|
|
4
5
|
export type CameraAccessibilityRole =
|
|
5
6
|
| 'button'
|
|
6
7
|
| 'link'
|
|
@@ -18,36 +19,59 @@ export type CameraAccessibilityRole =
|
|
|
18
19
|
| 'spinbutton'
|
|
19
20
|
| 'tab'
|
|
20
21
|
|
|
22
|
+
/** Imperative handle exposed through the CameraView `ref`. */
|
|
21
23
|
export interface CameraViewHandle {
|
|
22
24
|
/** The native preview surface (`HTMLVideoElement` on web). */
|
|
23
25
|
native: any
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
/** Props for the CameraView element. */
|
|
26
29
|
export interface CameraViewProps {
|
|
30
|
+
/** Class list applied to the preview element. */
|
|
27
31
|
className?: any
|
|
32
|
+
/** Inline style (string CSS or object). */
|
|
28
33
|
style?: any
|
|
34
|
+
/** Element id passed through to the host element. */
|
|
29
35
|
id?: string
|
|
36
|
+
/** Zero-based row index in the parent grid. */
|
|
30
37
|
row?: number
|
|
38
|
+
/** Zero-based column index. */
|
|
31
39
|
col?: number
|
|
40
|
+
/** Row tracks to span (>= 1). */
|
|
32
41
|
rowSpan?: number
|
|
42
|
+
/** Column tracks to span (>= 1). */
|
|
33
43
|
colSpan?: number
|
|
44
|
+
/** Edge of the parent dock layout this child pins to. */
|
|
34
45
|
dock?: 'left' | 'top' | 'right' | 'bottom'
|
|
46
|
+
/** Absolute x offset in dips. */
|
|
35
47
|
left?: number
|
|
48
|
+
/** Absolute y offset in dips. */
|
|
36
49
|
top?: number
|
|
50
|
+
/** Flex grow factor. */
|
|
37
51
|
flexGrow?: number
|
|
52
|
+
/** Flex shrink factor. */
|
|
38
53
|
flexShrink?: number
|
|
54
|
+
/** Cross-axis self alignment. */
|
|
39
55
|
alignSelf?: string
|
|
56
|
+
/** Sibling ordering. */
|
|
40
57
|
order?: number
|
|
58
|
+
/** Expose to assistive tech as an accessibility element. */
|
|
41
59
|
accessible?: boolean
|
|
60
|
+
/** Spoken name for assistive tech. */
|
|
42
61
|
accessibilityLabel?: string
|
|
62
|
+
/** Semantic role mapped per platform. */
|
|
43
63
|
accessibilityRole?: CameraAccessibilityRole
|
|
64
|
+
/** Spoken hint describing what activating does. */
|
|
44
65
|
accessibilityHint?: string
|
|
66
|
+
/** Spoken current value text. */
|
|
45
67
|
accessibilityValue?: string
|
|
68
|
+
/** State flags merged into the platform a11y state. */
|
|
46
69
|
accessibilityState?: {
|
|
47
70
|
disabled?: boolean
|
|
48
71
|
selected?: boolean
|
|
49
72
|
checked?: boolean
|
|
50
73
|
}
|
|
74
|
+
/** Live-region announcements: polite queues, assertive interrupts. */
|
|
51
75
|
accessibilityLiveRegion?: 'none' | 'polite' | 'assertive'
|
|
52
76
|
/** Shared camera owner enabling movie recording. When set, the preview
|
|
53
77
|
* attaches to the session's acquisition instead of owning one, and
|
|
@@ -59,6 +83,7 @@ export interface CameraViewProps {
|
|
|
59
83
|
active?: boolean
|
|
60
84
|
/** Fires after the preview surface starts. */
|
|
61
85
|
onReady?: () => void
|
|
86
|
+
/** Camera/preview errors. */
|
|
62
87
|
onError?: (error: { message?: string }) => void
|
|
63
88
|
/** Notification-only tap event — fires with the normalized
|
|
64
89
|
* preview-space position (`CameraPreviewPoint`) and never consumes
|
|
@@ -71,7 +96,10 @@ export interface CameraViewProps {
|
|
|
71
96
|
ref?: Octane.Ref<CameraViewHandle>
|
|
72
97
|
/** Platform-specific properties applied to the preview surface. */
|
|
73
98
|
ios?: Record<string, any>
|
|
99
|
+
/** Platform escape hatch — same bag contract as `ios`. */
|
|
74
100
|
android?: Record<string, any>
|
|
101
|
+
/** Platform escape hatch — same bag contract as `ios`. */
|
|
75
102
|
web?: Record<string, any>
|
|
103
|
+
/** Platform escape hatch — same bag contract as `ios`. */
|
|
76
104
|
windows?: Record<string, any>
|
|
77
105
|
}
|
|
@@ -87,7 +87,9 @@ const issue = (
|
|
|
87
87
|
|
|
88
88
|
/** AppCapabilityAccessStatus → portable permission. `notDeclared` is a
|
|
89
89
|
* setup error, not a status — callers surface `configurationMissing`. */
|
|
90
|
-
export const accessStatusToPermission
|
|
90
|
+
export const accessStatusToPermission: (
|
|
91
|
+
status: number | undefined,
|
|
92
|
+
) => CameraPermissionStatus | 'notDeclared' = (
|
|
91
93
|
status: number | undefined,
|
|
92
94
|
): CameraPermissionStatus | 'notDeclared' => {
|
|
93
95
|
switch (status) {
|
|
@@ -107,9 +109,9 @@ export const accessStatusToPermission = (
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
/** DeviceAccessStatus → portable permission for hosts without AppCapability. */
|
|
110
|
-
export const deviceAccessStatusToPermission
|
|
112
|
+
export const deviceAccessStatusToPermission: (
|
|
111
113
|
status: number | undefined,
|
|
112
|
-
): CameraPermissionStatus => {
|
|
114
|
+
) => CameraPermissionStatus = (status: number | undefined): CameraPermissionStatus => {
|
|
113
115
|
switch (status) {
|
|
114
116
|
case deviceAccessAllowed:
|
|
115
117
|
return 'granted'
|
|
@@ -126,12 +128,16 @@ export const deviceAccessStatusToPermission = (
|
|
|
126
128
|
|
|
127
129
|
/** Enclosure panel → facing. Desktop cameras often report no panel — an
|
|
128
130
|
* external webcam never fabricates front/back semantics. */
|
|
129
|
-
export const panelToFacing
|
|
131
|
+
export const panelToFacing: (panel: number | undefined) => 'front' | 'back' | undefined = (
|
|
132
|
+
panel: number | undefined,
|
|
133
|
+
): 'front' | 'back' | undefined =>
|
|
130
134
|
panel === panelFront ? 'front' : panel === panelBack ? 'back' : undefined
|
|
131
135
|
|
|
132
136
|
/** Stored display rotation (degrees CW) → cardinal orientation, matching the
|
|
133
137
|
* iOS transform mapping. Missing or unrecognized values stay `unspecified`. */
|
|
134
|
-
export const videoOrientationToOrientation
|
|
138
|
+
export const videoOrientationToOrientation: (degrees: number | undefined) => CameraOrientation = (
|
|
139
|
+
degrees: number | undefined,
|
|
140
|
+
): CameraOrientation => {
|
|
135
141
|
switch (degrees) {
|
|
136
142
|
case fileOrientation90:
|
|
137
143
|
return 'portrait'
|
|
@@ -146,7 +152,9 @@ export const videoOrientationToOrientation = (degrees: number | undefined): Came
|
|
|
146
152
|
}
|
|
147
153
|
}
|
|
148
154
|
|
|
149
|
-
export const orientationToRotation
|
|
155
|
+
export const orientationToRotation: (orientation: CameraOrientation) => number | undefined = (
|
|
156
|
+
orientation: CameraOrientation,
|
|
157
|
+
): number | undefined =>
|
|
150
158
|
orientation === 'portrait'
|
|
151
159
|
? recordRotation90
|
|
152
160
|
: orientation === 'portraitUpsideDown'
|
|
@@ -165,7 +173,11 @@ export interface WindowsCameraDevice {
|
|
|
165
173
|
|
|
166
174
|
/** Camera selection: explicit deviceId wins; front/back match the enclosure
|
|
167
175
|
* panel; `default` takes the OS-preferred camera then the first device. */
|
|
168
|
-
export const selectCameraDevice
|
|
176
|
+
export const selectCameraDevice: (
|
|
177
|
+
camera: CameraSessionConfig['camera'],
|
|
178
|
+
devices: WindowsCameraDevice[],
|
|
179
|
+
defaultId: string | undefined,
|
|
180
|
+
) => WindowsCameraDevice | undefined = (
|
|
169
181
|
camera: CameraSessionConfig['camera'],
|
|
170
182
|
devices: WindowsCameraDevice[],
|
|
171
183
|
defaultId: string | undefined,
|
|
@@ -195,7 +207,9 @@ export interface WindowsStreamProfile {
|
|
|
195
207
|
/** Pick the standard profile: 1280x720 @ 30 fps when the source offers it,
|
|
196
208
|
* otherwise the smallest stream then lowest frame rate. The selected
|
|
197
209
|
* combination is disclosed — never an idealized 720p claim. */
|
|
198
|
-
export const chooseStandardProfile
|
|
210
|
+
export const chooseStandardProfile: (
|
|
211
|
+
profiles: WindowsStreamProfile[],
|
|
212
|
+
) => WindowsStreamProfile | undefined = (
|
|
199
213
|
profiles: WindowsStreamProfile[],
|
|
200
214
|
): WindowsStreamProfile | undefined => {
|
|
201
215
|
if (!profiles.length) {
|
|
@@ -223,7 +237,9 @@ export const chooseStandardProfile = (
|
|
|
223
237
|
/** Classify a native failure without depending on projected error shapes.
|
|
224
238
|
* HRESULTs surface as `number`/`hresult`; MediaCapture failures also carry a
|
|
225
239
|
* numeric `code`. */
|
|
226
|
-
export const captureFailureKind
|
|
240
|
+
export const captureFailureKind: (cause: unknown) => CaptureIssue['kind'] = (
|
|
241
|
+
cause: unknown,
|
|
242
|
+
): CaptureIssue['kind'] => {
|
|
227
243
|
const code = Number(
|
|
228
244
|
(cause as any)?.number ?? (cause as any)?.hresult ?? (cause as any)?.code ?? Number.NaN,
|
|
229
245
|
)
|
package/src/session-core.ts
CHANGED
|
@@ -321,7 +321,10 @@ export class SharedCameraSession implements CameraSession {
|
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
async permissions() {
|
|
324
|
+
async permissions(): Promise<{
|
|
325
|
+
camera: CameraPermissionStatus
|
|
326
|
+
microphone: CameraPermissionStatus
|
|
327
|
+
}> {
|
|
325
328
|
const [camera, microphone] = await Promise.all([
|
|
326
329
|
this.backend.checkPermission('camera'),
|
|
327
330
|
this.backend.checkPermission('microphone'),
|
package/src/style-merge.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
const kebab = (key: string) => key.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase())
|
|
2
2
|
|
|
3
3
|
/** Anything accepted as a style value, including nested arrays. */
|
|
4
|
-
export type StyleInput =
|
|
5
|
-
| string
|
|
6
|
-
| Record<string, any>
|
|
7
|
-
| null
|
|
8
|
-
| undefined
|
|
9
|
-
| readonly StyleInput[]
|
|
4
|
+
export type StyleInput = string | Record<string, any> | null | undefined | readonly StyleInput[]
|
|
10
5
|
|
|
11
6
|
/** Merge component-emitted style defaults under the authored `style` prop.
|
|
12
7
|
* Authored keys win; array styles fold in order; a string style is appended
|
|
@@ -15,10 +10,12 @@ export function mergeStyle(
|
|
|
15
10
|
base: Record<string, any>,
|
|
16
11
|
style?: Record<string, any> | readonly (Record<string, any> | null | undefined)[] | null,
|
|
17
12
|
): Record<string, any>
|
|
13
|
+
|
|
18
14
|
export function mergeStyle(
|
|
19
15
|
base: Record<string, any>,
|
|
20
16
|
style?: StyleInput,
|
|
21
17
|
): string | Record<string, any>
|
|
18
|
+
|
|
22
19
|
export function mergeStyle(
|
|
23
20
|
base: Record<string, any>,
|
|
24
21
|
style?: StyleInput,
|
package/src/synthetic-session.ts
CHANGED
|
@@ -27,6 +27,7 @@ import type {
|
|
|
27
27
|
* partial completions, and failures.
|
|
28
28
|
*/
|
|
29
29
|
export interface SyntheticCameraScript {
|
|
30
|
+
/** Storage access state. */
|
|
30
31
|
permission: {
|
|
31
32
|
camera: CameraPermissionStatus
|
|
32
33
|
microphone: CameraPermissionStatus
|
|
@@ -53,16 +54,22 @@ export interface SyntheticCameraScript {
|
|
|
53
54
|
focusRequests?: CameraPreviewPoint[]
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
/** Storage backing for synthetic/test camera clips. */
|
|
56
58
|
export interface SyntheticCameraStorage {
|
|
59
|
+
/** Write a synthetic clip to storage. */
|
|
57
60
|
write(path: string, bytes: Uint8Array): void | Promise<void>
|
|
61
|
+
/** Read a stored clip. */
|
|
58
62
|
read(path: string): Uint8Array | undefined | Promise<Uint8Array | undefined>
|
|
63
|
+
/** Remove a stored clip; optional — reopen paths degrade gracefully without it. */
|
|
59
64
|
delete?(path: string): void | Promise<void>
|
|
65
|
+
/** Probe for a stored clip without reading it. */
|
|
60
66
|
exists?(path: string): boolean | Promise<boolean>
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
/** In-memory storage for the seam — a `fileUrl`-shaped map so outcomes
|
|
64
70
|
* exercise the same reopen path without touching a real filesystem. */
|
|
65
71
|
export function createMemoryCameraStorage(): SyntheticCameraStorage & {
|
|
72
|
+
/** Stored clip bytes keyed by path — specs assert on this map directly. */
|
|
66
73
|
files: Map<string, Uint8Array>
|
|
67
74
|
} {
|
|
68
75
|
const files = new Map<string, Uint8Array>()
|