@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.
- package/README.md +2 -132
- package/package.json +20 -25
- package/platforms/android/java/com/octanexplat/camera/CameraPreviewView.java +24 -0
- package/platforms/android/java/com/octanexplat/camera/CameraSessionBridge.java +153 -21
- package/platforms/ios/src/XplatSwitchingMovieWriter.swift +557 -0
- package/src/CameraView.android.tsrx +187 -154
- package/src/CameraView.ios.tsrx +124 -110
- package/src/CameraView.macos.tsrx +103 -96
- package/src/CameraView.tsrx +2 -0
- package/src/CameraView.web.tsrx +157 -146
- package/src/CameraView.windows.tsrx +134 -125
- package/src/camera-host.macos.ts +1059 -0
- package/src/camera-permission.mobile.ts +85 -81
- package/src/camera-permission.windows.ts +56 -53
- package/src/camera-session.ios.ts +89 -61
- package/src/camera-session.macos.ts +51 -49
- package/src/camera-session.windows.ts +113 -105
- package/src/host-movie.web.ts +257 -231
- package/src/index.ts +28 -26
- package/src/index.web.ts +27 -25
- package/src/layout-child.ts +86 -79
- package/src/layout-child.web.ts +54 -53
- package/src/layout-child.windows.ts +80 -74
- package/src/movie-metadata.web.ts +84 -81
- package/src/movie-storage.web.ts +142 -135
- package/src/movie-writer.ios.ts +170 -0
- package/src/photo-lifecycle.macos.ts +60 -0
- package/src/photo-sheet.macos.ts +505 -0
- package/src/preview-display.ios.ts +69 -0
- package/src/preview-pinch.ts +41 -0
- package/src/preview-tap.ts +22 -21
- package/src/props.ts +115 -93
- package/src/recording-haptics.ios.ts +39 -0
- package/src/recording-source.web.ts +159 -0
- package/src/session-backend.android.ts +552 -410
- package/src/session-backend.ios.ts +1500 -1148
- package/src/session-backend.linux.ts +886 -860
- package/src/session-backend.macos.ts +697 -679
- package/src/session-backend.ts +51 -49
- package/src/session-backend.web.ts +1181 -867
- package/src/session-backend.windows.ts +1540 -1467
- package/src/session-core.ts +925 -714
- package/src/session.ts +12 -12
- package/src/style-merge.ts +40 -37
- package/src/synthetic-session.ts +391 -339
- package/src/types.ts +372 -298
- package/types/generated/.tsrx-typegen-manifest.json +4 -24
- package/types/generated/CameraView.d.ts +2 -0
- package/types/generated/camera-host.macos.d.ts +33 -0
- package/types/generated/index.d.ts +27 -26
- package/types/generated/photo-lifecycle.macos.d.ts +12 -0
- package/types/generated/photo-sheet.macos.d.ts +36 -0
- package/types/generated/props.d.ts +24 -2
- package/types/generated/session-core.d.ts +30 -1
- package/types/generated/synthetic-session.d.ts +7 -0
- package/types/generated/types.d.ts +75 -1
- package/platforms/macos/src/CameraOwnership.swift +0 -22
- package/platforms/macos/src/PhotoCaptureLifecycle.swift +0 -34
- package/platforms/macos/src/XplatCameraHost.swift +0 -639
- package/platforms/macos/src/XplatPhotoCaptureSheet.swift +0 -192
- package/types/generated/CameraView.android.d.ts +0 -9
- package/types/generated/CameraView.ios.d.ts +0 -5
- package/types/generated/CameraView.macos.d.ts +0 -5
- package/types/generated/CameraView.mobile.d.ts +0 -5
- package/types/generated/CameraView.windows.d.ts +0 -11
- package/types/generated/camera-permission.mobile.d.ts +0 -2
- package/types/generated/camera-permission.windows.d.ts +0 -6
- package/types/generated/camera-session.ios.d.ts +0 -2
- package/types/generated/camera-session.macos.d.ts +0 -10
- package/types/generated/camera-session.windows.d.ts +0 -9
- package/types/generated/host-movie.web.d.ts +0 -100
- package/types/generated/index.web.d.ts +0 -7
- package/types/generated/layout-child.d.ts +0 -11
- package/types/generated/layout-child.windows.d.ts +0 -13
- package/types/generated/movie-metadata.web.d.ts +0 -9
- package/types/generated/movie-storage.web.d.ts +0 -5
- package/types/generated/preview-tap.d.ts +0 -7
- package/types/generated/session-backend.android.d.ts +0 -3
- package/types/generated/session-backend.ios.d.ts +0 -5
- package/types/generated/session-backend.linux.d.ts +0 -3
- package/types/generated/session-backend.macos.d.ts +0 -8
- package/types/generated/session-backend.web.d.ts +0 -3
- package/types/generated/session-backend.windows.d.ts +0 -37
- package/types/generated/style-merge.d.ts +0 -8
|
@@ -8,25 +8,26 @@ import { attachSessionPreview } from './session'
|
|
|
8
8
|
import { cameraHardwarePresent, ensureCameraPermission } from './camera-permission.windows'
|
|
9
9
|
import { startCameraPreview } from './camera-session.windows'
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
applyEscapeProps,
|
|
12
|
+
layoutChildProps,
|
|
13
|
+
nativeAccessibilityRole,
|
|
14
|
+
nativeAccessibilityState,
|
|
15
15
|
} from './layout-child.windows'
|
|
16
16
|
|
|
17
17
|
import { observePreviewTap } from './preview-tap'
|
|
18
18
|
|
|
19
19
|
class CameraPreview extends View {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
createNativeView() {
|
|
21
|
+
const { Microsoft } = globalThis as any
|
|
22
|
+
|
|
23
|
+
return new Microsoft.UI.Xaml.Controls.CaptureElement()
|
|
24
|
+
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
declare module '@octane-xplat/jsx/intrinsics' {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
interface NativeElements<TElement> {
|
|
29
|
+
camerapreview: Attributes<TElement, {}>
|
|
30
|
+
}
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
registerElement('camerapreview', CameraPreview)
|
|
@@ -35,118 +36,126 @@ registerElement('camerapreview', CameraPreview)
|
|
|
35
36
|
* With `session`, the preview attaches to the session-owned capture so
|
|
36
37
|
* movie recording shares it; without one the view owns its capture. */
|
|
37
38
|
export function CameraView(props: CameraViewProps): unknown @{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
39
|
+
const host = useRef<any>(null)
|
|
40
|
+
const active = props.active !== false
|
|
41
|
+
const facing = props.facing ?? 'back'
|
|
42
|
+
|
|
43
|
+
useImperativeHandle(props.ref, () => ({ native: host.current?.nativeViewProtected }), [])
|
|
44
|
+
|
|
45
|
+
const bindHost = useCallback((view: any) => {
|
|
46
|
+
host.current = view
|
|
47
|
+
}, [])
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const view = host.current
|
|
51
|
+
|
|
52
|
+
if (!view || !active) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let disposed = false
|
|
57
|
+
let stopPreview: (() => Promise<void>) | undefined
|
|
58
|
+
const fail = (message: string) => props.onError?.({ message })
|
|
59
|
+
|
|
60
|
+
if (props.session) {
|
|
61
|
+
if (props.facing !== undefined) {
|
|
62
|
+
fail('camera session conflicts with facing')
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const detach = attachSessionPreview(props.session, view, {
|
|
68
|
+
onReady: () => {
|
|
69
|
+
if (!disposed) {
|
|
70
|
+
props.onReady?.()
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
onDisplayReady: () => {
|
|
74
|
+
if (!disposed) {
|
|
75
|
+
props.onDisplayReady?.()
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
onError: (issue) => {
|
|
79
|
+
if (!disposed) {
|
|
80
|
+
fail(issue.message)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
disposed = true
|
|
87
|
+
detach()
|
|
88
|
+
}
|
|
89
|
+
} catch (error: any) {
|
|
90
|
+
fail(error?.message ?? 'camera session error')
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!cameraHardwarePresent()) {
|
|
96
|
+
fail('camera unsupported')
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
ensureCameraPermission().then(async (granted) => {
|
|
101
|
+
if (disposed) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!granted) {
|
|
106
|
+
fail('camera permission denied')
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
stopPreview = await startCameraPreview(view, facing, () => {
|
|
112
|
+
if (!disposed) {
|
|
113
|
+
props.onReady?.()
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
} catch (error: any) {
|
|
117
|
+
if (!disposed) {
|
|
118
|
+
fail(error?.message ?? 'camera error')
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
return () => {
|
|
124
|
+
disposed = true
|
|
125
|
+
void stopPreview?.()
|
|
126
|
+
}
|
|
127
|
+
}, [active, facing, props.session])
|
|
128
|
+
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
const view = host.current
|
|
131
|
+
|
|
132
|
+
if (!view) {
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
applyEscapeProps(view.nativeViewProtected, props)
|
|
137
|
+
}, [props.ref, props.windows])
|
|
138
|
+
|
|
139
|
+
useEffect(() => observePreviewTap(host.current, props.onTap), [props.onTap])
|
|
140
|
+
|
|
141
|
+
<masonview
|
|
142
|
+
id={props.id}
|
|
143
|
+
className={['vx-layers', 'vx-cameraview', props.className]}
|
|
144
|
+
{...layoutChildProps(props, {
|
|
145
|
+
display: 'grid',
|
|
146
|
+
gridTemplateRows: '1fr',
|
|
147
|
+
gridTemplateColumns: '1fr',
|
|
148
|
+
backgroundColor: '#000',
|
|
149
|
+
...props.style,
|
|
150
|
+
})}
|
|
151
|
+
accessible={props.accessible}
|
|
152
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
153
|
+
accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any}
|
|
154
|
+
accessibilityHint={props.accessibilityHint}
|
|
155
|
+
accessibilityValue={props.accessibilityValue}
|
|
156
|
+
accessibilityState={nativeAccessibilityState(props.accessibilityState) as any}
|
|
157
|
+
accessibilityLiveRegion={props.accessibilityLiveRegion as any}
|
|
158
|
+
>
|
|
159
|
+
<camerapreview ref={bindHost} style={{ gridRow: '1', gridColumn: '1' }} />
|
|
160
|
+
</masonview>
|
|
152
161
|
}
|