@octane-xplat/camera 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +2 -132
  2. package/package.json +20 -25
  3. package/platforms/android/java/com/octanexplat/camera/CameraPreviewView.java +24 -0
  4. package/platforms/android/java/com/octanexplat/camera/CameraSessionBridge.java +153 -21
  5. package/platforms/ios/src/XplatSwitchingMovieWriter.swift +557 -0
  6. package/src/CameraView.android.tsrx +187 -154
  7. package/src/CameraView.ios.tsrx +124 -110
  8. package/src/CameraView.macos.tsrx +103 -96
  9. package/src/CameraView.tsrx +2 -0
  10. package/src/CameraView.web.tsrx +157 -146
  11. package/src/CameraView.windows.tsrx +134 -125
  12. package/src/camera-host.macos.ts +1059 -0
  13. package/src/camera-permission.mobile.ts +85 -81
  14. package/src/camera-permission.windows.ts +56 -53
  15. package/src/camera-session.ios.ts +89 -61
  16. package/src/camera-session.macos.ts +51 -49
  17. package/src/camera-session.windows.ts +113 -105
  18. package/src/host-movie.web.ts +257 -231
  19. package/src/index.ts +28 -26
  20. package/src/index.web.ts +27 -25
  21. package/src/layout-child.ts +86 -79
  22. package/src/layout-child.web.ts +54 -53
  23. package/src/layout-child.windows.ts +80 -74
  24. package/src/movie-metadata.web.ts +84 -81
  25. package/src/movie-storage.web.ts +142 -135
  26. package/src/movie-writer.ios.ts +170 -0
  27. package/src/photo-lifecycle.macos.ts +60 -0
  28. package/src/photo-sheet.macos.ts +505 -0
  29. package/src/preview-display.ios.ts +69 -0
  30. package/src/preview-pinch.ts +41 -0
  31. package/src/preview-tap.ts +22 -21
  32. package/src/props.ts +115 -93
  33. package/src/recording-haptics.ios.ts +39 -0
  34. package/src/recording-source.web.ts +159 -0
  35. package/src/session-backend.android.ts +552 -410
  36. package/src/session-backend.ios.ts +1500 -1148
  37. package/src/session-backend.linux.ts +886 -860
  38. package/src/session-backend.macos.ts +697 -679
  39. package/src/session-backend.ts +51 -49
  40. package/src/session-backend.web.ts +1181 -867
  41. package/src/session-backend.windows.ts +1540 -1467
  42. package/src/session-core.ts +925 -714
  43. package/src/session.ts +12 -12
  44. package/src/style-merge.ts +40 -37
  45. package/src/synthetic-session.ts +391 -339
  46. package/src/types.ts +372 -298
  47. package/types/generated/.tsrx-typegen-manifest.json +4 -24
  48. package/types/generated/CameraView.d.ts +2 -0
  49. package/types/generated/camera-host.macos.d.ts +33 -0
  50. package/types/generated/index.d.ts +27 -26
  51. package/types/generated/photo-lifecycle.macos.d.ts +12 -0
  52. package/types/generated/photo-sheet.macos.d.ts +36 -0
  53. package/types/generated/props.d.ts +24 -2
  54. package/types/generated/session-core.d.ts +30 -1
  55. package/types/generated/synthetic-session.d.ts +7 -0
  56. package/types/generated/types.d.ts +75 -1
  57. package/platforms/macos/src/CameraOwnership.swift +0 -22
  58. package/platforms/macos/src/PhotoCaptureLifecycle.swift +0 -34
  59. package/platforms/macos/src/XplatCameraHost.swift +0 -639
  60. package/platforms/macos/src/XplatPhotoCaptureSheet.swift +0 -192
  61. package/types/generated/CameraView.android.d.ts +0 -9
  62. package/types/generated/CameraView.ios.d.ts +0 -5
  63. package/types/generated/CameraView.macos.d.ts +0 -5
  64. package/types/generated/CameraView.mobile.d.ts +0 -5
  65. package/types/generated/CameraView.windows.d.ts +0 -11
  66. package/types/generated/camera-permission.mobile.d.ts +0 -2
  67. package/types/generated/camera-permission.windows.d.ts +0 -6
  68. package/types/generated/camera-session.ios.d.ts +0 -2
  69. package/types/generated/camera-session.macos.d.ts +0 -10
  70. package/types/generated/camera-session.windows.d.ts +0 -9
  71. package/types/generated/host-movie.web.d.ts +0 -100
  72. package/types/generated/index.web.d.ts +0 -7
  73. package/types/generated/layout-child.d.ts +0 -11
  74. package/types/generated/layout-child.windows.d.ts +0 -13
  75. package/types/generated/movie-metadata.web.d.ts +0 -9
  76. package/types/generated/movie-storage.web.d.ts +0 -5
  77. package/types/generated/preview-tap.d.ts +0 -7
  78. package/types/generated/session-backend.android.d.ts +0 -3
  79. package/types/generated/session-backend.ios.d.ts +0 -5
  80. package/types/generated/session-backend.linux.d.ts +0 -3
  81. package/types/generated/session-backend.macos.d.ts +0 -8
  82. package/types/generated/session-backend.web.d.ts +0 -3
  83. package/types/generated/session-backend.windows.d.ts +0 -37
  84. package/types/generated/style-merge.d.ts +0 -8
@@ -4,88 +4,92 @@ import { android } from '@octane-xplat/platform/android'
4
4
  let requestCode = 7719
5
5
 
6
6
  export function cameraHardwarePresent(): boolean {
7
- if (isIOS) {
8
- return typeof (globalThis as any).AVCaptureDevice !== 'undefined'
9
- }
10
-
11
- if (!isAndroid) {
12
- return false
13
- }
14
-
15
- try {
16
- const context = Application.android?.context ?? Application.android?.startActivity
17
- return context?.getPackageManager()?.hasSystemFeature('android.hardware.camera.any') !== false
18
- } catch {
19
- return true
20
- }
7
+ if (isIOS) {
8
+ return typeof (globalThis as any).AVCaptureDevice !== 'undefined'
9
+ }
10
+
11
+ if (!isAndroid) {
12
+ return false
13
+ }
14
+
15
+ try {
16
+ const context = Application.android?.context ?? Application.android?.startActivity
17
+
18
+ return context?.getPackageManager()?.hasSystemFeature('android.hardware.camera.any') !== false
19
+ } catch {
20
+ return true
21
+ }
21
22
  }
22
23
 
23
24
  export async function ensureCameraPermission(): Promise<boolean> {
24
- try {
25
- if (isIOS) {
26
- const av = (globalThis as any).AVCaptureDevice
27
- const mediaType = (globalThis as any).AVMediaTypeVideo ?? 'vide'
28
- const status = av?.authorizationStatusForMediaType?.(mediaType)
29
- if (status === 3) {
30
- return true
31
- }
32
-
33
- if (status === 1 || status === 2) {
34
- return false
35
- }
36
-
37
- return await new Promise<boolean>((resolve) =>
38
- av.requestAccessForMediaTypeCompletionHandler(mediaType, resolve),
39
- )
40
- }
41
-
42
- if (isAndroid) {
43
- const permission = 'android.permission.CAMERA'
44
- const activity = Application.android.foregroundActivity ?? Application.android.startActivity
45
- if (
46
- activity?.checkSelfPermission?.(permission) ===
47
- android.content.pm.PackageManager.PERMISSION_GRANTED
48
- ) {
49
- return true
50
- }
51
-
52
- if (!activity) {
53
- return false
54
- }
55
-
56
- return await new Promise<boolean>((resolve) => {
57
- const currentRequest = requestCode++
58
- const finish = (granted: boolean) => {
59
- clearTimeout(timer)
60
- Application.android.off(Application.android.activityRequestPermissionsEvent, onResult)
61
-
62
- resolve(granted)
63
- }
64
-
65
- const onResult = (args: any) => {
66
- if (args.requestCode !== currentRequest) {
67
- return
68
- }
69
-
70
- finish(args.grantResults?.[0] === android.content.pm.PackageManager.PERMISSION_GRANTED)
71
- }
72
-
73
- // Same bound the session adapter uses — an activity destroyed or
74
- // rotated before the result must not hang the caller or leak the
75
- // listener.
76
- const timer = setTimeout(() => finish(false), 120_000)
77
- Application.android.on(Application.android.activityRequestPermissionsEvent, onResult)
78
-
79
- try {
80
- activity.requestPermissions([permission], currentRequest)
81
- } catch {
82
- finish(false)
83
- }
84
- })
85
- }
86
- } catch {
87
- return false
88
- }
89
-
90
- return false
25
+ try {
26
+ if (isIOS) {
27
+ const av = (globalThis as any).AVCaptureDevice
28
+ const mediaType = (globalThis as any).AVMediaTypeVideo ?? 'vide'
29
+ const status = av?.authorizationStatusForMediaType?.(mediaType)
30
+
31
+ if (status === 3) {
32
+ return true
33
+ }
34
+
35
+ if (status === 1 || status === 2) {
36
+ return false
37
+ }
38
+
39
+ return await new Promise<boolean>((resolve) =>
40
+ av.requestAccessForMediaTypeCompletionHandler(mediaType, resolve),
41
+ )
42
+ }
43
+
44
+ if (isAndroid) {
45
+ const permission = 'android.permission.CAMERA'
46
+ const activity = Application.android.foregroundActivity ?? Application.android.startActivity
47
+
48
+ if (
49
+ activity?.checkSelfPermission?.(permission) ===
50
+ android.content.pm.PackageManager.PERMISSION_GRANTED
51
+ ) {
52
+ return true
53
+ }
54
+
55
+ if (!activity) {
56
+ return false
57
+ }
58
+
59
+ return await new Promise<boolean>((resolve) => {
60
+ const currentRequest = requestCode++
61
+ const finish = (granted: boolean) => {
62
+ clearTimeout(timer)
63
+ Application.android.off(Application.android.activityRequestPermissionsEvent, onResult)
64
+
65
+ resolve(granted)
66
+ }
67
+
68
+ const onResult = (args: any) => {
69
+ if (args.requestCode !== currentRequest) {
70
+ return
71
+ }
72
+
73
+ finish(args.grantResults?.[0] === android.content.pm.PackageManager.PERMISSION_GRANTED)
74
+ }
75
+
76
+ // Same bound the session adapter uses — an activity destroyed or
77
+ // rotated before the result must not hang the caller or leak the
78
+ // listener.
79
+ const timer = setTimeout(() => finish(false), 120_000)
80
+
81
+ Application.android.on(Application.android.activityRequestPermissionsEvent, onResult)
82
+
83
+ try {
84
+ activity.requestPermissions([permission], currentRequest)
85
+ } catch {
86
+ finish(false)
87
+ }
88
+ })
89
+ }
90
+ } catch {
91
+ return false
92
+ }
93
+
94
+ return false
91
95
  }
@@ -6,71 +6,74 @@
6
6
  const windows = () => globalThis as any
7
7
 
8
8
  const toPromise = (op: any): Promise<any> => {
9
- const { NSWinRT } = windows()
10
- if (NSWinRT?.toPromise && op != null) {
11
- return NSWinRT.toPromise(op)
12
- }
9
+ const { NSWinRT } = windows()
13
10
 
14
- if (op?.done) {
15
- return new Promise((resolve, reject) => {
16
- try {
17
- op.done(resolve, reject)
18
- } catch (cause) {
19
- reject(cause)
20
- }
21
- })
22
- }
11
+ if (NSWinRT?.toPromise && op != null) {
12
+ return NSWinRT.toPromise(op)
13
+ }
23
14
 
24
- return Promise.resolve(op)
15
+ if (op?.done) {
16
+ return new Promise((resolve, reject) => {
17
+ try {
18
+ op.done(resolve, reject)
19
+ } catch (cause) {
20
+ reject(cause)
21
+ }
22
+ })
23
+ }
24
+
25
+ return Promise.resolve(op)
25
26
  }
26
27
 
27
28
  export function cameraHardwarePresent(): boolean {
28
- const { Windows, Microsoft } = windows()
29
- return !!(
30
- Windows?.Media?.Capture?.MediaCapture &&
31
- Windows?.Devices?.Enumeration?.DeviceInformation &&
32
- Microsoft?.UI?.Xaml?.Controls?.CaptureElement
33
- )
29
+ const { Windows, Microsoft } = windows()
30
+
31
+ return !!(
32
+ Windows?.Media?.Capture?.MediaCapture &&
33
+ Windows?.Devices?.Enumeration?.DeviceInformation &&
34
+ Microsoft?.UI?.Xaml?.Controls?.CaptureElement
35
+ )
34
36
  }
35
37
 
36
38
  export async function ensureCameraPermission(): Promise<boolean> {
37
- try {
38
- const { Windows } = windows()
39
- const capability =
40
- Windows?.Security?.Authorization?.AppCapabilityAccess?.AppCapability?.Create?.('webcam')
39
+ try {
40
+ const { Windows } = windows()
41
+ const capability =
42
+ Windows?.Security?.Authorization?.AppCapabilityAccess?.AppCapability?.Create?.('webcam')
43
+
44
+ if (capability) {
45
+ const status = capability.CheckAccess()
41
46
 
42
- if (capability) {
43
- const status = capability.CheckAccess()
44
- // AppCapabilityAccessStatus: DeniedBySystem=0, NotDeclaredByApp=1,
45
- // DeniedByUser=2, UserPromptRequired=3, Allowed=4.
46
- if (status === 4) {
47
- return true
48
- }
47
+ // AppCapabilityAccessStatus: DeniedBySystem=0, NotDeclaredByApp=1,
48
+ // DeniedByUser=2, UserPromptRequired=3, Allowed=4.
49
+ if (status === 4) {
50
+ return true
51
+ }
49
52
 
50
- if (status === 3) {
51
- return (await toPromise(capability.RequestAccessAsync())) === 4
52
- }
53
+ if (status === 3) {
54
+ return (await toPromise(capability.RequestAccessAsync())) === 4
55
+ }
53
56
 
54
- return false
55
- }
57
+ return false
58
+ }
56
59
 
57
- const enumeration = Windows?.Devices?.Enumeration
58
- const deviceClass = enumeration?.DeviceClass?.VideoCapture
59
- const info =
60
- deviceClass === undefined
61
- ? undefined
62
- : enumeration?.DeviceAccessInformation?.CreateFromDeviceClass(deviceClass)
60
+ const enumeration = Windows?.Devices?.Enumeration
61
+ const deviceClass = enumeration?.DeviceClass?.VideoCapture
62
+ const info =
63
+ deviceClass === undefined
64
+ ? undefined
65
+ : enumeration?.DeviceAccessInformation?.CreateFromDeviceClass(deviceClass)
63
66
 
64
- if (info) {
65
- // DeviceAccessStatus: Unspecified=0, Allowed=1, DeniedByUser=2,
66
- // DeniedBySystem=3. The enumeration API cannot prompt — an
67
- // Unspecified outcome is resolved by the preview's own
68
- // InitializeAsync, which runs the OS consent flow.
69
- return info.CurrentStatus !== 2 && info.CurrentStatus !== 3
70
- }
71
- } catch {
72
- return false
73
- }
67
+ if (info) {
68
+ // DeviceAccessStatus: Unspecified=0, Allowed=1, DeniedByUser=2,
69
+ // DeniedBySystem=3. The enumeration API cannot prompt — an
70
+ // Unspecified outcome is resolved by the preview's own
71
+ // InitializeAsync, which runs the OS consent flow.
72
+ return info.CurrentStatus !== 2 && info.CurrentStatus !== 3
73
+ }
74
+ } catch {
75
+ return false
76
+ }
74
77
 
75
- return false
78
+ return false
76
79
  }
@@ -1,65 +1,93 @@
1
+ import { observePreviewDisplay, previewLayerDisplaying } from './preview-display.ios'
2
+
1
3
  /** Attach an AVFoundation preview layer to a NativeScript UIView host. */
2
4
  export function startCameraPreview(
3
- view: any,
4
- facing: 'front' | 'back',
5
- onReady?: () => void,
5
+ view: any,
6
+ facing: 'front' | 'back',
7
+ onReady?: () => void,
8
+ onDisplayReady?: () => void,
6
9
  ): () => void {
7
- const av = globalThis as any
8
- const mediaType = av.AVMediaTypeVideo ?? 'vide'
9
- const desiredPosition =
10
- facing === 'front'
11
- ? (av.AVCaptureDevicePositionFront ?? 2)
12
- : (av.AVCaptureDevicePositionBack ?? 1)
13
-
14
- const devices = av.AVCaptureDevice.devicesWithMediaType(mediaType)
15
- let device: any = null
16
- for (let index = 0; index < devices.count; index++) {
17
- const candidate = devices.objectAtIndex(index)
18
- if (candidate.position === desiredPosition) {
19
- device = candidate
20
- break
21
- }
22
- }
23
-
24
- if (!device) {
25
- throw new Error('camera unavailable')
26
- }
27
-
28
- const session = av.AVCaptureSession.new()
29
- const input = av.AVCaptureDeviceInput.deviceInputWithDeviceError(device)
30
- if (!input || !session.canAddInput(input)) {
31
- throw new Error('camera input unavailable')
32
- }
33
-
34
- session.addInput(input)
35
- const layer = av.AVCaptureVideoPreviewLayer.layerWithSession(session)
36
- layer.videoGravity = 'resizeAspectFill'
37
- const connection = layer.connection
38
- if (connection) {
39
- connection.automaticallyAdjustsVideoMirroring = false
40
- if (connection.isVideoMirroringSupported) {
41
- connection.isVideoMirrored = facing === 'front'
42
- }
43
- }
44
-
45
- const nativeView = view.ios ?? view.nativeViewProtected
46
- if (!nativeView?.layer) {
47
- throw new Error('camera preview host unavailable')
48
- }
49
-
50
- nativeView.layer.addSublayer(layer)
51
- const updateFrame = () => {
52
- layer.frame = nativeView.bounds
53
- }
54
-
55
- view.on?.('layoutChanged', updateFrame)
56
- updateFrame()
57
- session.startRunning()
58
- onReady?.()
59
-
60
- return () => {
61
- view.off?.('layoutChanged', updateFrame)
62
- session.stopRunning()
63
- layer.removeFromSuperlayer()
64
- }
10
+ const av = globalThis as any
11
+ const mediaType = av.AVMediaTypeVideo ?? 'vide'
12
+ const desiredPosition =
13
+ facing === 'front'
14
+ ? (av.AVCaptureDevicePositionFront ?? 2)
15
+ : (av.AVCaptureDevicePositionBack ?? 1)
16
+
17
+ const devices = av.AVCaptureDevice.devicesWithMediaType(mediaType)
18
+ let device: any = null
19
+
20
+ for (let index = 0; index < devices.count; index++) {
21
+ const candidate = devices.objectAtIndex(index)
22
+
23
+ if (candidate.position === desiredPosition) {
24
+ device = candidate
25
+ break
26
+ }
27
+ }
28
+
29
+ if (!device) {
30
+ throw new Error('camera unavailable')
31
+ }
32
+
33
+ const session = av.AVCaptureSession.new()
34
+ const input = av.AVCaptureDeviceInput.deviceInputWithDeviceError(device)
35
+
36
+ if (!input || !session.canAddInput(input)) {
37
+ throw new Error('camera input unavailable')
38
+ }
39
+
40
+ session.addInput(input)
41
+
42
+ const layer = av.AVCaptureVideoPreviewLayer.layerWithSession(session)
43
+
44
+ layer.videoGravity = 'resizeAspectFill'
45
+
46
+ const connection = layer.connection
47
+
48
+ if (connection) {
49
+ connection.automaticallyAdjustsVideoMirroring = false
50
+ if (connection.isVideoMirroringSupported) {
51
+ connection.isVideoMirrored = facing === 'front'
52
+ }
53
+ }
54
+
55
+ const nativeView = view.ios ?? view.nativeViewProtected
56
+
57
+ if (!nativeView?.layer) {
58
+ throw new Error('camera preview host unavailable')
59
+ }
60
+
61
+ nativeView.layer.addSublayer(layer)
62
+
63
+ const updateFrame = () => {
64
+ layer.frame = nativeView.bounds
65
+ }
66
+
67
+ view.on?.('layoutChanged', updateFrame)
68
+ updateFrame()
69
+
70
+ let displayReady = false
71
+ const detachDisplay = observePreviewDisplay(layer, () => {
72
+ const showing = previewLayerDisplaying(layer)
73
+
74
+ if (showing === displayReady) {
75
+ return
76
+ }
77
+
78
+ displayReady = showing
79
+ if (showing) {
80
+ onDisplayReady?.()
81
+ }
82
+ })
83
+
84
+ session.startRunning()
85
+ onReady?.()
86
+
87
+ return () => {
88
+ view.off?.('layoutChanged', updateFrame)
89
+ detachDisplay?.()
90
+ session.stopRunning()
91
+ layer.removeFromSuperlayer()
92
+ }
65
93
  }
@@ -1,75 +1,77 @@
1
1
  import '@nativescript/macos-node-api'
2
+ import { createCameraHost } from './camera-host.macos.ts'
2
3
 
3
4
  interface CameraHost {
4
- attachPreview(view: object): string | null
5
- detachPreview(): void
6
- installObserver(emit: (message: string) => void): void
7
- permissionStatus(kind: string): string
8
- requestPermissionReply(kind: string, reply: (status: string) => void): void
9
- devices(): string
10
- audioDeviceAvailable(): boolean
11
- configure(options: { cameraId?: string; audio?: boolean; rotationAngle?: number }): string | null
12
- dispose(): void
13
- }
14
-
15
- declare const XplatCameraHost: {
16
- alloc(): { init(): CameraHost }
5
+ attachPreview(view: object): string | null
6
+ detachPreview(): void
7
+ installObserver(emit: (message: string) => void): void
8
+ permissionStatus(kind: string): string
9
+ requestPermissionReply(kind: string, reply: (status: string) => void): void
10
+ devices(): string
11
+ audioDeviceAvailable(): boolean
12
+ configure(options: { cameraId?: string; audio?: boolean; rotationAngle?: number }): string | null
13
+ dispose(): void
17
14
  }
18
15
 
19
16
  let helper: CameraHost | undefined
20
- const helperHost = () => (helper ??= XplatCameraHost.alloc().init())
17
+ const helperHost = () => (helper ??= createCameraHost())
21
18
 
22
19
  export function cameraHardwarePresent(): boolean {
23
- try {
24
- return JSON.parse(helperHost().devices()).length > 0
25
- } catch {
26
- return false
27
- }
20
+ try {
21
+ return JSON.parse(helperHost().devices()).length > 0
22
+ } catch {
23
+ return false
24
+ }
28
25
  }
29
26
 
30
27
  /** Preview-only permission entry point: prompts once from mount, mirrors the
31
28
  * iOS legacy path. Session code should use `session.requestPermission` —
32
29
  * explicit actions only. */
33
30
  export function ensureCameraPermission(): Promise<boolean> {
34
- const status = helperHost().permissionStatus('camera')
35
- if (status === 'granted') {
36
- return Promise.resolve(true)
37
- }
31
+ const status = helperHost().permissionStatus('camera')
38
32
 
39
- if (status === 'undeclared') {
40
- return Promise.resolve(false)
41
- }
33
+ if (status === 'granted') {
34
+ return Promise.resolve(true)
35
+ }
42
36
 
43
- return new Promise((resolve) =>
44
- helperHost().requestPermissionReply('camera', (next) => resolve(next === 'granted')),
45
- )
37
+ if (status === 'undeclared') {
38
+ return Promise.resolve(false)
39
+ }
40
+
41
+ return new Promise((resolve) =>
42
+ helperHost().requestPermissionReply('camera', (next) => resolve(next === 'granted')),
43
+ )
46
44
  }
47
45
 
48
46
  /** Legacy preview-only path: a dedicated XplatCameraHost owns the preview
49
47
  * session — shared with nothing, disposed with the view. The session-backed
50
48
  * path goes through `attachSessionPreview` instead. */
51
49
  export function startCameraPreview(
52
- view: object,
53
- _facing: 'front' | 'back',
54
- onReady?: () => void,
50
+ view: object,
51
+ _facing: 'front' | 'back',
52
+ onReady?: () => void,
55
53
  ): () => void {
56
- const host = XplatCameraHost.alloc().init()
57
- host.installObserver(() => {})
58
- const configured = host.configure({ audio: false })
59
- if (configured) {
60
- host.dispose()
61
- throw new Error(`camera unavailable: ${configured}`)
62
- }
54
+ const host = createCameraHost()
55
+
56
+ host.installObserver(() => {})
57
+
58
+ const configured = host.configure({ audio: false })
59
+
60
+ if (configured) {
61
+ host.dispose()
62
+ throw new Error(`camera unavailable: ${configured}`)
63
+ }
64
+
65
+ const failure = host.attachPreview(view)
63
66
 
64
- const failure = host.attachPreview(view)
65
- if (failure) {
66
- host.dispose()
67
- throw new Error(`camera unavailable: ${failure}`)
68
- }
67
+ if (failure) {
68
+ host.dispose()
69
+ throw new Error(`camera unavailable: ${failure}`)
70
+ }
69
71
 
70
- onReady?.()
71
- return () => {
72
- host.detachPreview()
73
- host.dispose()
74
- }
72
+ onReady?.()
73
+ return () => {
74
+ host.detachPreview()
75
+ host.dispose()
76
+ }
75
77
  }