@octane-xplat/camera 0.18.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 +108 -103
- 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 +194 -118
- package/src/CameraView.ios.tsrx +129 -76
- package/src/CameraView.macos.tsrx +108 -70
- package/src/CameraView.tsrx +2 -0
- package/src/CameraView.web.tsrx +160 -125
- package/src/CameraView.windows.tsrx +141 -92
- 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 +266 -222
- package/src/index.ts +28 -26
- package/src/index.web.ts +27 -25
- package/src/layout-child.ts +88 -79
- package/src/layout-child.web.ts +57 -51
- package/src/layout-child.windows.ts +82 -71
- package/src/movie-metadata.web.ts +87 -74
- 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 +118 -68
- 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 +1556 -1467
- package/src/session-core.ts +925 -711
- package/src/session.ts +12 -12
- package/src/style-merge.ts +43 -43
- package/src/synthetic-session.ts +392 -333
- package/src/types.ts +384 -239
- package/types/generated/.tsrx-typegen-manifest.json +18 -0
- package/types/generated/CameraView.d.ts +2 -0
- package/types/generated/CameraView.web.d.ts +4 -0
- package/types/generated/camera-host.macos.d.ts +33 -0
- package/types/generated/index.d.ts +34 -0
- package/types/generated/layout-child.web.d.ts +7 -0
- 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 +111 -0
- package/types/generated/session-backend.d.ts +6 -0
- package/types/{session-core.d.ts → generated/session-core.d.ts} +30 -1
- package/types/generated/session.d.ts +16 -0
- package/types/{synthetic-session.d.ts → generated/synthetic-session.d.ts} +15 -1
- package/types/{types.d.ts → generated/types.d.ts} +145 -2
- package/LICENSE +0 -21
- 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/index.d.ts +0 -48
- package/types/props.d.ts +0 -61
package/src/host-movie.web.ts
CHANGED
|
@@ -9,48 +9,48 @@ import type { MovieOutput, MovieOutputHandle } from './types'
|
|
|
9
9
|
// resolves absent and the adapter keeps its browser storage behavior.
|
|
10
10
|
|
|
11
11
|
export interface CameraHostServices {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
12
|
+
camera: {
|
|
13
|
+
permissionStatus(options: { kind: string }): Promise<{ status: string }>
|
|
14
|
+
requestPermission(options: { kind: string }): Promise<{ status: string }>
|
|
15
|
+
movieDirectory(): Promise<{ fileUrl: string | null }>
|
|
16
|
+
reserveMoviePath(options: {
|
|
17
|
+
fileUrl?: string
|
|
18
|
+
container?: string
|
|
19
|
+
}): Promise<{ reservation: { fileUrl: string } | null }>
|
|
20
|
+
writeMovieFile(options: {
|
|
21
|
+
fileUrl: string
|
|
22
|
+
base64: string
|
|
23
|
+
}): Promise<{ file: { name: string; uri: string } | null }>
|
|
24
|
+
movieFileInfo(options: {
|
|
25
|
+
fileUrl: string
|
|
26
|
+
}): Promise<{ info: { exists: boolean; fileUrl?: string; size?: number } | null }>
|
|
27
|
+
readMovieFile(options: { fileUrl: string }): Promise<{ base64: string | null }>
|
|
28
|
+
deleteMovieFile(options: { fileUrl: string }): Promise<{ removed: boolean }>
|
|
29
|
+
/** Optional chunked variants — a multi-hundred-MB movie must not
|
|
30
|
+
* round-trip through the bridge as one base64 payload. Absent on
|
|
31
|
+
* hosts built before the chunked contract; detected per client. */
|
|
32
|
+
writeMovieFileChunk?(options: {
|
|
33
|
+
fileUrl: string
|
|
34
|
+
base64: string
|
|
35
|
+
final?: boolean
|
|
36
|
+
}): Promise<{ file: { name: string; uri: string } | { ok: boolean } | null }>
|
|
37
|
+
readMovieFileChunk?(options: {
|
|
38
|
+
fileUrl: string
|
|
39
|
+
offset: number
|
|
40
|
+
length: number
|
|
41
|
+
}): Promise<{ base64: string | null }>
|
|
42
|
+
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const requiredMethods = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
'permissionStatus',
|
|
47
|
+
'requestPermission',
|
|
48
|
+
'movieDirectory',
|
|
49
|
+
'reserveMoviePath',
|
|
50
|
+
'writeMovieFile',
|
|
51
|
+
'movieFileInfo',
|
|
52
|
+
'readMovieFile',
|
|
53
|
+
'deleteMovieFile',
|
|
54
54
|
]
|
|
55
55
|
|
|
56
56
|
export type CameraHost = HostClient<CameraHostServices>
|
|
@@ -58,27 +58,32 @@ export type CameraHost = HostClient<CameraHostServices>
|
|
|
58
58
|
let hostProbe: Promise<CameraHost | null> | undefined
|
|
59
59
|
|
|
60
60
|
const probeHost = async (): Promise<CameraHost | null> => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
61
|
+
try {
|
|
62
|
+
const transport = createWebKitTransport()
|
|
63
|
+
|
|
64
|
+
if (!transport) {
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const client = createHostClient<CameraHostServices>(transport)
|
|
69
|
+
const capabilities: unknown = await client.capabilities().catch(() => null)
|
|
70
|
+
const methods =
|
|
71
|
+
typeof capabilities === 'object' &&
|
|
72
|
+
capabilities !== null &&
|
|
73
|
+
'camera' in capabilities &&
|
|
74
|
+
Array.isArray(capabilities.camera)
|
|
75
|
+
? capabilities.camera
|
|
76
|
+
: undefined
|
|
77
|
+
|
|
78
|
+
if (Array.isArray(methods) && requiredMethods.every((name) => methods.includes(name))) {
|
|
79
|
+
return client
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
client.dispose()
|
|
83
|
+
return null
|
|
84
|
+
} catch {
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
/** The camera-capable desktop host client, or null outside a qualified host.
|
|
@@ -86,70 +91,82 @@ const probeHost = async (): Promise<CameraHost | null> => {
|
|
|
86
91
|
* transport or capabilities failure, so the next call probes again rather
|
|
87
92
|
* than sticking 'absent' for the page lifetime. */
|
|
88
93
|
export async function cameraHost(): Promise<CameraHost | null> {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
hostProbe ??= probeHost()
|
|
95
|
+
|
|
96
|
+
const host = await hostProbe
|
|
97
|
+
|
|
98
|
+
if (!host) {
|
|
99
|
+
hostProbe = probeHost()
|
|
100
|
+
return hostProbe
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return host
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
const error = (kind: 'destinationUnavailable' | 'storageFailed' | 'unavailable', message: string) =>
|
|
100
|
-
|
|
107
|
+
new CameraCaptureError({ kind, operation: 'storage', message })
|
|
101
108
|
|
|
102
109
|
const dataToBase64 = (data: Uint8Array): string => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
for (let offset = 0; offset < data.length; offset += chunk) {
|
|
106
|
-
binary += String.fromCharCode(...data.subarray(offset, offset + chunk))
|
|
107
|
-
}
|
|
110
|
+
let binary = ''
|
|
111
|
+
const chunk = 0x8000
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
for (let offset = 0; offset < data.length; offset += chunk) {
|
|
114
|
+
binary += String.fromCharCode(...data.subarray(offset, offset + chunk))
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return btoa(binary)
|
|
110
118
|
}
|
|
111
119
|
|
|
112
120
|
const blobToBase64 = async (bytes: Blob): Promise<string> =>
|
|
113
|
-
|
|
121
|
+
dataToBase64(new Uint8Array(await bytes.arrayBuffer()))
|
|
114
122
|
|
|
115
123
|
const base64ToBlob = (base64: string, type: string): Blob => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
const binary = atob(base64)
|
|
125
|
+
const data = new Uint8Array(binary.length)
|
|
126
|
+
|
|
127
|
+
for (let index = 0; index < binary.length; index++) {
|
|
128
|
+
data[index] = binary.charCodeAt(index)
|
|
129
|
+
}
|
|
121
130
|
|
|
122
|
-
|
|
131
|
+
return new Blob([data], { type })
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
const mimeForFileUrl = (fileUrl: string): string =>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
fileUrl.endsWith('.webm')
|
|
136
|
+
? 'video/webm'
|
|
137
|
+
: fileUrl.endsWith('.mov')
|
|
138
|
+
? 'video/quicktime'
|
|
139
|
+
: 'video/mp4'
|
|
131
140
|
|
|
132
141
|
/** Reserve a host-side movie file. `destinationFileUrl` is validated
|
|
133
142
|
* host-side: it must be a new file inside the app-private storage root. */
|
|
134
|
-
export const reserveHostMovie
|
|
135
|
-
|
|
136
|
-
|
|
143
|
+
export const reserveHostMovie: (
|
|
144
|
+
host: CameraHost,
|
|
145
|
+
options: {
|
|
146
|
+
destinationFileUrl?: string
|
|
147
|
+
container?: string
|
|
148
|
+
},
|
|
149
|
+
) => Promise<{
|
|
150
|
+
fileUrl: string
|
|
151
|
+
}> = async (
|
|
152
|
+
host: CameraHost,
|
|
153
|
+
options: { destinationFileUrl?: string; container?: string },
|
|
137
154
|
): Promise<{ fileUrl: string }> => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
const { reservation } = await host.call('camera', 'reserveMoviePath', {
|
|
156
|
+
fileUrl: options.destinationFileUrl,
|
|
157
|
+
container: options.container,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
if (!reservation?.fileUrl) {
|
|
161
|
+
throw error(
|
|
162
|
+
'destinationUnavailable',
|
|
163
|
+
options.destinationFileUrl
|
|
164
|
+
? 'destinationFileUrl must be a new file inside the app-private recordings directory'
|
|
165
|
+
: 'The host could not allocate a movie recording file',
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return reservation
|
|
153
170
|
}
|
|
154
171
|
|
|
155
172
|
/** Bytes bridged per call when the host exposes the chunked movie contract —
|
|
@@ -161,135 +178,162 @@ const chunkedSupport = new WeakMap<CameraHost, Promise<boolean>>()
|
|
|
161
178
|
/** A host built before the chunked contract lacks the methods entirely —
|
|
162
179
|
* the capabilities probe answers that without a probe call. */
|
|
163
180
|
const supportsChunkedMovies = (host: CameraHost): Promise<boolean> => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
let probe = chunkedSupport.get(host)
|
|
182
|
+
|
|
183
|
+
if (!probe) {
|
|
184
|
+
probe = host
|
|
185
|
+
.capabilities()
|
|
186
|
+
.then((capabilities: unknown) => {
|
|
187
|
+
const methods =
|
|
188
|
+
typeof capabilities === 'object' &&
|
|
189
|
+
capabilities !== null &&
|
|
190
|
+
'camera' in capabilities &&
|
|
191
|
+
Array.isArray(capabilities.camera)
|
|
192
|
+
? capabilities.camera
|
|
193
|
+
: []
|
|
194
|
+
|
|
195
|
+
return methods.includes('writeMovieFileChunk') && methods.includes('readMovieFileChunk')
|
|
196
|
+
})
|
|
197
|
+
.catch(() => false)
|
|
198
|
+
|
|
199
|
+
chunkedSupport.set(host, probe)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return probe
|
|
178
203
|
}
|
|
179
204
|
|
|
180
205
|
/** Commit finalized movie bytes to host-side app-private storage. Hosts
|
|
181
206
|
* with the chunked contract stream 4MB slices — a multi-hundred-MB
|
|
182
207
|
* recording no longer materializes ~3-4x its size across the bridge. */
|
|
183
|
-
export const commitHostMovie
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
208
|
+
export const commitHostMovie: (
|
|
209
|
+
host: CameraHost,
|
|
210
|
+
fileUrl: string,
|
|
211
|
+
bytes: Blob,
|
|
212
|
+
) => Promise<MovieOutput> = async (
|
|
213
|
+
host: CameraHost,
|
|
214
|
+
fileUrl: string,
|
|
215
|
+
bytes: Blob,
|
|
187
216
|
): Promise<MovieOutput> => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
if (await supportsChunkedMovies(host)) {
|
|
218
|
+
for (let offset = 0; ; offset += MOVIE_CHUNK_BYTES) {
|
|
219
|
+
const slice = bytes.slice(offset, offset + MOVIE_CHUNK_BYTES)
|
|
220
|
+
const final = offset + MOVIE_CHUNK_BYTES >= bytes.size
|
|
221
|
+
const { file } = await host.call('camera', 'writeMovieFileChunk', {
|
|
222
|
+
fileUrl,
|
|
223
|
+
base64: dataToBase64(new Uint8Array(await slice.arrayBuffer())),
|
|
224
|
+
final,
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
if (final) {
|
|
228
|
+
const committed = file && 'uri' in file ? file : null
|
|
229
|
+
|
|
230
|
+
if (!committed?.uri) {
|
|
231
|
+
throw error('storageFailed', 'The host could not write the recorded movie')
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return { kind: 'nativeFile', resourceId: committed.uri, fileUrl: committed.uri }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (!file || !('ok' in file) || file.ok !== true) {
|
|
238
|
+
throw error('storageFailed', 'The host could not write a recorded movie chunk')
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const base64 = await blobToBase64(bytes)
|
|
244
|
+
const { file } = await host.call('camera', 'writeMovieFile', { fileUrl, base64 })
|
|
245
|
+
|
|
246
|
+
if (!file?.uri) {
|
|
247
|
+
throw error('storageFailed', 'The host could not write the recorded movie')
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return { kind: 'nativeFile', resourceId: file.uri, fileUrl: file.uri }
|
|
220
251
|
}
|
|
221
252
|
|
|
222
253
|
/** Drop an uncommitted host reservation after a failed attempt. */
|
|
223
|
-
export const removeHostReservation
|
|
224
|
-
|
|
254
|
+
export const removeHostReservation: (host: CameraHost, fileUrl: string) => Promise<void> = async (
|
|
255
|
+
host: CameraHost,
|
|
256
|
+
fileUrl: string,
|
|
257
|
+
): Promise<void> => {
|
|
258
|
+
await host.call('camera', 'deleteMovieFile', { fileUrl }).catch(() => {})
|
|
225
259
|
}
|
|
226
260
|
|
|
227
261
|
/** Reopen a host-stored movie as a temporary playback URL. The durable
|
|
228
262
|
* reference remains `fileUrl`; the returned url lives until `release()`. */
|
|
229
|
-
export const openHostMovie
|
|
230
|
-
|
|
231
|
-
|
|
263
|
+
export const openHostMovie: (
|
|
264
|
+
host: CameraHost,
|
|
265
|
+
output: MovieOutput,
|
|
266
|
+
) => Promise<MovieOutputHandle> = async (
|
|
267
|
+
host: CameraHost,
|
|
268
|
+
output: MovieOutput,
|
|
232
269
|
): Promise<MovieOutputHandle> => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
270
|
+
if (output.kind !== 'nativeFile' || !output.fileUrl) {
|
|
271
|
+
throw new CameraCaptureError({
|
|
272
|
+
kind: 'invalidArgument',
|
|
273
|
+
operation: 'openOutput',
|
|
274
|
+
message: 'Only file-backed output can be opened through the desktop host',
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const { info } = await host.call('camera', 'movieFileInfo', { fileUrl: output.fileUrl })
|
|
279
|
+
|
|
280
|
+
if (!info?.exists) {
|
|
281
|
+
throw error('unavailable', `Movie file is missing at ${output.fileUrl}`)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const size = Number(info.size ?? -1)
|
|
285
|
+
|
|
286
|
+
if (size > 0 && (await supportsChunkedMovies(host))) {
|
|
287
|
+
const data = new Uint8Array(size)
|
|
288
|
+
|
|
289
|
+
for (let offset = 0; offset < size; offset += MOVIE_CHUNK_BYTES) {
|
|
290
|
+
const { base64: chunk } = await host.call('camera', 'readMovieFileChunk', {
|
|
291
|
+
fileUrl: output.fileUrl,
|
|
292
|
+
offset,
|
|
293
|
+
length: Math.min(MOVIE_CHUNK_BYTES, size - offset),
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
if (chunk == null) {
|
|
297
|
+
throw error('unavailable', `Movie file could not be read at ${output.fileUrl}`)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let decoded: string
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
decoded = atob(chunk)
|
|
304
|
+
} catch {
|
|
305
|
+
throw error('unavailable', 'The host returned invalid movie bytes')
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (decoded.length !== Math.min(MOVIE_CHUNK_BYTES, size - offset)) {
|
|
309
|
+
throw error('unavailable', 'The stored movie changed or could not be read completely')
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
for (let index = 0; index < decoded.length; index += 1) {
|
|
313
|
+
data[offset + index] = decoded.charCodeAt(index)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const url = URL.createObjectURL(new Blob([data], { type: mimeForFileUrl(output.fileUrl) }))
|
|
318
|
+
|
|
319
|
+
return {
|
|
320
|
+
url,
|
|
321
|
+
fileUrl: output.fileUrl,
|
|
322
|
+
release: () => URL.revokeObjectURL(url),
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const { base64 } = await host.call('camera', 'readMovieFile', { fileUrl: output.fileUrl })
|
|
327
|
+
|
|
328
|
+
if (!base64) {
|
|
329
|
+
throw error('unavailable', `Movie file could not be read at ${output.fileUrl}`)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const url = URL.createObjectURL(base64ToBlob(base64, mimeForFileUrl(output.fileUrl)))
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
url,
|
|
336
|
+
fileUrl: output.fileUrl,
|
|
337
|
+
release: () => URL.revokeObjectURL(url),
|
|
338
|
+
}
|
|
295
339
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
// Keep this relative import extensionless so the NativeScript resolver picks
|
|
2
2
|
// the iOS or Android component for the current build target.
|
|
3
|
-
export { CameraView } from './CameraView'
|
|
3
|
+
export { CameraView } from './CameraView.tsrx'
|
|
4
4
|
export type { CameraAccessibilityRole, CameraViewHandle, CameraViewProps } from './props'
|
|
5
5
|
export { createCameraSession } from './session'
|
|
6
6
|
export { CameraCaptureError } from './types'
|
|
7
7
|
export type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
CameraCaptureErrorKind,
|
|
9
|
+
CameraDeviceInfo,
|
|
10
|
+
CameraFacing,
|
|
11
|
+
CameraInterruptionReason,
|
|
12
|
+
CameraOrientation,
|
|
13
|
+
CameraPermissionKind,
|
|
14
|
+
CameraPermissionStatus,
|
|
15
|
+
CameraPinchEvent,
|
|
16
|
+
CameraPreviewPoint,
|
|
17
|
+
CameraProfileCapability,
|
|
18
|
+
CameraRecorderState,
|
|
19
|
+
CameraSelection,
|
|
20
|
+
CameraSession,
|
|
21
|
+
CameraSessionCapabilities,
|
|
22
|
+
CameraSessionConfig,
|
|
23
|
+
CameraSessionEvent,
|
|
24
|
+
CameraSessionSnapshot,
|
|
25
|
+
CameraZoomState,
|
|
26
|
+
CaptureIssue,
|
|
27
|
+
EffectiveCaptureConfig,
|
|
28
|
+
MovieClip,
|
|
29
|
+
MovieEndReason,
|
|
30
|
+
MovieOutcome,
|
|
31
|
+
MovieOutput,
|
|
32
|
+
MovieOutputHandle,
|
|
33
|
+
MovieTake,
|
|
34
|
+
StartRecordingOptions,
|
|
33
35
|
} from './types'
|
|
34
36
|
|
|
35
37
|
export { createMemoryCameraStorage, createSyntheticCameraSession } from './synthetic-session'
|