@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
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # `@octane-xplat/camera`
2
2
 
3
- ```sh
4
- pnpm add @octane-xplat/camera
5
- ```
6
-
7
3
  Live camera preview for Octane xplat apps: `getUserMedia` video on web,
8
4
  `AVCaptureSession` on iOS, CameraX on Android,
9
5
  `AVCaptureSession` + `AVCaptureVideoPreviewLayer` on macOS (AppKit), and
10
6
  `MediaCapture` + `CaptureElement` on the Windows (WinUI 3) target.
11
7
 
8
+ ```sh
9
+ bun add @octane-xplat/camera
10
+ ```
11
+
12
12
  ```tsx
13
13
  import { CameraView } from '@octane-xplat/camera'
14
14
 
@@ -25,7 +25,7 @@ export function Preview() {
25
25
  ```
26
26
 
27
27
  This is the preview surface only — for one-shot still capture and library
28
- picking use [`@octane-xplat/media`](../media/README.md). Permissions are
28
+ picking use [`@octane-xplat/media`](https://github.com/octane-xplat/octane-xplat/blob/main/packages/media/README.md). Permissions are
29
29
  requested when the session starts; `onError` is how a denial shows up.
30
30
  `ref` hands you the platform surface (`HTMLVideoElement` on web) for
31
31
  controls the shared props don't cover, and the `ios`/`android`/`web`/
@@ -120,7 +120,7 @@ output in the app's private storage root instead of IndexedDB. Windows records
120
120
  through `MediaCapture` into app-private MP4 files and is pending real-host
121
121
  qualification. On Linux the GJS/WebKitGTK host owns media permissions and
122
122
  writes MP4 clips under the app's data directory.
123
- See [Record and reopen a camera movie](../../docs/app/movie-capture.md) for
123
+ See [Record and reopen a camera movie](https://octane-xplat.goddardai.org/movie-capture) for
124
124
  explicit permission actions, audio, local output, and qualification limits.
125
125
 
126
126
  ```ts
@@ -130,6 +130,6 @@ await session.requestPermission('camera')
130
130
  console.log(await session.capabilities())
131
131
  ```
132
132
 
133
- Guide: [Building screens](../../docs/app/primitives.md) (leaf components);
134
- component index: [`docs/app/components.md`](../../docs/app/components.md).
135
- Exercised by [`CameraDemo`](../demos/src/CameraDemo.tsrx).
133
+ Guide: [Building screens](https://octane-xplat.goddardai.org/primitives) (leaf components);
134
+ component index: [`docs/app/components.md`](https://octane-xplat.goddardai.org/components).
135
+ Exercised by [`CameraDemo`](https://github.com/octane-xplat/octane-xplat/blob/main/packages/demos/src/CameraDemo.tsrx).
package/package.json CHANGED
@@ -1,104 +1,114 @@
1
1
  {
2
- "name": "@octane-xplat/camera",
3
- "version": "0.18.0",
4
- "description": "Live camera preview for Octane xplat — web getUserMedia + native capture (AVCapture / CameraX)",
5
- "keywords": [
6
- "android",
7
- "camera",
8
- "camera-preview",
9
- "cross-platform",
10
- "ios",
11
- "nativescript",
12
- "octane",
13
- "photo",
14
- "video-capture",
15
- "web",
16
- "xplat"
17
- ],
18
- "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/camera",
19
- "license": "MIT",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/octane-xplat/octane-xplat",
23
- "directory": "packages/camera"
24
- },
25
- "files": [
26
- "types",
27
- "src",
28
- "platforms",
29
- "!src/**/*.test.*",
30
- "!src/**/*.spec.*"
31
- ],
32
- "type": "module",
33
- "exports": {
34
- ".": {
35
- "types": "./types/index.d.ts",
36
- "linux": "./src/index.web.ts",
37
- "web": "./src/index.web.ts",
38
- "native": "./src/index.ts",
39
- "default": "./src/index.ts"
40
- }
41
- },
42
- "publishConfig": {
43
- "access": "public"
44
- },
45
- "dependencies": {
46
- "@octane-xplat/platform": "0.18.0",
47
- "mediabunny": "1.61.3"
48
- },
49
- "devDependencies": {
50
- "@nativescript-community/octane": "0.2.5",
51
- "@nativescript/core": "9.1.3",
52
- "@octane-xplat/macos-renderer": "0.18.0",
53
- "@octanejs/vite-plugin": "0.1.61",
54
- "octane": "0.14.0",
55
- "tsrx-typegen": "0.4.0",
56
- "typescript": "5.9.3",
57
- "vite": "8.3.0",
58
- "vitest": "4.1.11"
59
- },
60
- "peerDependencies": {
61
- "@nativescript-community/octane": ">=0.2.1 <1",
62
- "@nativescript/core": ">=9.1.0 <10",
63
- "octane": ">=0.6.3 <1"
64
- },
65
- "peerDependenciesMeta": {
66
- "@nativescript-community/octane": {
67
- "optional": true
68
- },
69
- "@nativescript/core": {
70
- "optional": true
71
- },
72
- "octane": {
73
- "optional": true
74
- }
75
- },
76
- "nativescript": {
77
- "platforms": {
78
- "ios": "7.0.0",
79
- "android": "7.0.0"
80
- }
81
- },
82
- "xplat": {
83
- "macos": {
84
- "swiftHeaderImports": [
85
- "AppKit/AppKit.h"
86
- ],
87
- "frameworks": [
88
- "AVFoundation",
89
- "CoreMedia",
90
- "AppKit"
91
- ]
92
- }
93
- },
94
- "scripts": {
95
- "typegen": "tsc -p tsconfig.types.json",
96
- "test:packed": "node tests/packed-consumer.mjs",
97
- "pack:check": "tsrx-typegen --pack-check",
98
- "test": "vitest run && node --test tests/*.test.mjs",
99
- "test:macos-photo": "node tests/photo-native.macos.mjs",
100
- "test:macos-photo-hardware": "node tests/photo-hardware.macos.mjs",
101
- "test:web": "node tests/browser-conformance.web.mjs",
102
- "test:webkitgtk": "node tests/webkitgtk-conformance.linux.mjs"
103
- }
104
- }
2
+ "name": "@octane-xplat/camera",
3
+ "version": "0.19.0",
4
+ "description": "Live camera preview for Octane xplat — web getUserMedia + native capture (AVCapture / CameraX)",
5
+ "keywords": [
6
+ "android",
7
+ "camera",
8
+ "camera-preview",
9
+ "cross-platform",
10
+ "ios",
11
+ "nativescript",
12
+ "octane",
13
+ "photo",
14
+ "video-capture",
15
+ "web",
16
+ "xplat"
17
+ ],
18
+ "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/camera",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/octane-xplat/octane-xplat",
23
+ "directory": "packages/camera"
24
+ },
25
+ "files": [
26
+ "types/generated",
27
+ "src",
28
+ "platforms",
29
+ "!src/**/*.test.*",
30
+ "!src/**/*.spec.*"
31
+ ],
32
+ "type": "module",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./types/generated/index.d.ts",
36
+ "linux": "./src/index.web.ts",
37
+ "web": "./src/index.web.ts",
38
+ "native": "./src/index.ts",
39
+ "default": "./src/index.ts"
40
+ }
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "typegen": "tsrx-typegen --target camera",
47
+ "prepack": "bun run typegen && tsrx-typegen --pack-check",
48
+ "test:packed": "node tests/packed-consumer.mjs",
49
+ "pack:check": "tsrx-typegen --pack-check",
50
+ "test": "vitest run && node --test tests/*.test.mjs",
51
+ "test:macos-photo": "node tests/photo-native.macos.mjs",
52
+ "test:macos-photo-hardware": "node tests/photo-hardware.macos.mjs",
53
+ "test:web": "node tests/browser-conformance.web.mjs",
54
+ "test:webkitgtk": "node tests/webkitgtk-conformance.linux.mjs",
55
+ "typecheck": "tsrx-tsc --noEmit -p tsconfig.types.json"
56
+ },
57
+ "dependencies": {
58
+ "@octane-xplat/jsx": "0.19.0",
59
+ "@octane-xplat/platform": "0.19.0",
60
+ "mediabunny": "1.62.1"
61
+ },
62
+ "devDependencies": {
63
+ "@nativescript-community/octane": "0.2.5",
64
+ "@nativescript/core": "9.1.3",
65
+ "@octane-xplat/macos-renderer": "0.19.0",
66
+ "@octanejs/vite-plugin": "0.5.0",
67
+ "octane": "0.16.3",
68
+ "tsrx-typegen": "0.5.0",
69
+ "typescript": "5.9.3",
70
+ "vite": "8.3.0",
71
+ "vitest": "4.1.11",
72
+ "@tsrx/typescript-plugin": "0.4.11",
73
+ "@nativescript/macos-node-api": "0.4.4-next.2026-08-09-31292056208"
74
+ },
75
+ "peerDependencies": {
76
+ "@nativescript-community/octane": ">=0.2.1 <1",
77
+ "@nativescript/core": ">=9.1.0 <10",
78
+ "octane": ">=0.6.3 <1",
79
+ "@nativescript/macos-node-api": "0.4.4-next.2026-08-09-31292056208"
80
+ },
81
+ "peerDependenciesMeta": {
82
+ "@nativescript-community/octane": {
83
+ "optional": true
84
+ },
85
+ "@nativescript/core": {
86
+ "optional": true
87
+ },
88
+ "octane": {
89
+ "optional": true
90
+ },
91
+ "@nativescript/macos-node-api": {
92
+ "optional": true
93
+ }
94
+ },
95
+ "nativescript": {
96
+ "platforms": {
97
+ "ios": "7.0.0",
98
+ "android": "7.0.0"
99
+ }
100
+ },
101
+ "xplat": {
102
+ "macos": {
103
+ "swiftHeaderImports": [
104
+ "AppKit/AppKit.h"
105
+ ],
106
+ "frameworks": [
107
+ "AVFoundation",
108
+ "CoreMedia",
109
+ "AppKit"
110
+ ]
111
+ }
112
+ },
113
+ "types": "./types/generated/index.d.ts"
114
+ }
@@ -1,16 +1,21 @@
1
- /** @jsxImportSource @nativescript-community/octane */
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
2
  import { useImperativeHandle, useCallback, useEffect, useRef } from 'octane'
3
3
  import { Application, View } from '@nativescript/core'
4
4
  import { registerElement } from '@nativescript-community/octane'
5
- import type { Attributes } from '@nativescript-community/octane/intrinsics'
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.mobile'
9
- import { applyEscapeProps, layoutChildProps, nativeAccessibilityRole, nativeAccessibilityState } from './layout-child'
9
+ import {
10
+ applyEscapeProps,
11
+ layoutChildProps,
12
+ nativeAccessibilityRole,
13
+ nativeAccessibilityState,
14
+ } from './layout-child'
15
+
10
16
  import { observePreviewTap } from './preview-tap'
11
17
  import { java } from '@octane-xplat/platform/android'
12
18
 
13
-
14
19
  class CameraPreview extends View {
15
20
  createNativeView() {
16
21
  const nativeClass = (globalThis as any).com.octanexplat.camera.CameraPreviewView
@@ -18,20 +23,20 @@ class CameraPreview extends View {
18
23
  }
19
24
  }
20
25
 
21
- declare module '@nativescript-community/octane/intrinsics' {
22
- interface NativeScriptElements {
23
- camerapreview: Attributes<typeof CameraPreview>
26
+ declare module '@octane-xplat/jsx/intrinsics' {
27
+ interface NativeElements<TElement> {
28
+ camerapreview: Attributes<TElement, {}>
24
29
  }
25
30
  }
26
31
 
27
32
  registerElement('camerapreview', CameraPreview)
28
33
 
29
34
  /** Live Android preview backed by CameraX. */
30
- export function CameraView(props: CameraViewProps) @{
35
+ export function CameraView(props: CameraViewProps): unknown @{
31
36
  const host = useRef<any>(null)
32
37
  const active = props.active !== false
33
38
  const facing = props.facing ?? 'back'
34
- useImperativeHandle(props.ref, () => ({ native: host.current.android }), []);
39
+ useImperativeHandle(props.ref, () => ({ native: host.current.android }), [])
35
40
 
36
41
  const bindHost = useCallback((view: any) => {
37
42
  host.current = view
@@ -39,12 +44,17 @@ export function CameraView(props: CameraViewProps) @{
39
44
 
40
45
  useEffect(() => {
41
46
  const nativeView = host.current?.android
42
- if (!nativeView) return
47
+ if (!nativeView) {
48
+ return
49
+ }
50
+
43
51
  let disposed = false
44
52
  let provider: any
45
53
  let preview: any
46
54
  nativeView.setCameraActive(active)
47
- if (!active) return () => nativeView.setCameraActive(false)
55
+ if (!active) {
56
+ return () => nativeView.setCameraActive(false)
57
+ }
48
58
 
49
59
  const fail = (message: string) => props.onError?.({ message })
50
60
  if (props.session) {
@@ -59,7 +69,10 @@ export function CameraView(props: CameraViewProps) @{
59
69
  onError: (issue) => fail(issue.message),
60
70
  })
61
71
 
62
- return () => { detach(); nativeView.setCameraActive(false) }
72
+ return () => {
73
+ detach()
74
+ nativeView.setCameraActive(false)
75
+ }
63
76
  } catch (error: any) {
64
77
  fail(error?.message ?? 'camera session error')
65
78
  return () => nativeView.setCameraActive(false)
@@ -72,7 +85,10 @@ export function CameraView(props: CameraViewProps) @{
72
85
  }
73
86
 
74
87
  ensureCameraPermission().then((granted) => {
75
- if (disposed) return
88
+ if (disposed) {
89
+ return
90
+ }
91
+
76
92
  if (!granted) {
77
93
  fail('camera permission denied')
78
94
  return
@@ -82,17 +98,24 @@ export function CameraView(props: CameraViewProps) @{
82
98
  const context = Application.android.context
83
99
  const cameraX = (globalThis as any).androidx.camera
84
100
  const future = cameraX.lifecycle.ProcessCameraProvider.getInstance(context)
85
- const executor = (globalThis as any).androidx.core.content.ContextCompat.getMainExecutor(context)
101
+ const executor = (globalThis as any).androidx.core.content.ContextCompat.getMainExecutor(
102
+ context,
103
+ )
104
+
86
105
  future.addListener(
87
106
  new java.lang.Runnable({
88
107
  run() {
89
- if (disposed) return
108
+ if (disposed) {
109
+ return
110
+ }
111
+
90
112
  try {
91
113
  provider = future.get()
92
114
  const selectorClass = cameraX.core.CameraSelector
93
- const lens = facing === 'front'
94
- ? selectorClass.LENS_FACING_FRONT
95
- : selectorClass.LENS_FACING_BACK
115
+ const lens =
116
+ facing === 'front'
117
+ ? selectorClass.LENS_FACING_FRONT
118
+ : selectorClass.LENS_FACING_BACK
96
119
 
97
120
  const selector = new selectorClass.Builder().requireLensFacing(lens).build()
98
121
  preview = new cameraX.core.Preview.Builder().build()
@@ -124,13 +147,33 @@ export function CameraView(props: CameraViewProps) @{
124
147
 
125
148
  useEffect(() => {
126
149
  const view = host.current
127
- if (!view) return
150
+ if (!view) {
151
+ return
152
+ }
153
+
128
154
  applyEscapeProps(view.android, props)
129
155
  }, [props.ref, props.android])
130
156
 
131
157
  useEffect(() => observePreviewTap(host.current, props.onTap), [props.onTap])
132
158
 
133
- <masonview id={props.id} className={['vx-layers', 'vx-cameraview', props.className]} {...layoutChildProps(props, {display: "grid", gridTemplateRows: "1fr", gridTemplateColumns: "1fr", ...({ backgroundColor: '#000', ...props.style })})} accessible={props.accessible} accessibilityLabel={props.accessibilityLabel} accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any} accessibilityHint={props.accessibilityHint} accessibilityValue={props.accessibilityValue} accessibilityState={nativeAccessibilityState(props.accessibilityState) as any} accessibilityLiveRegion={props.accessibilityLiveRegion as any}>
134
- <camerapreview ref={bindHost} style={{gridRow: '1', gridColumn: '1'}} />
159
+ <masonview
160
+ id={props.id}
161
+ className={['vx-layers', 'vx-cameraview', props.className]}
162
+ {...layoutChildProps(props, {
163
+ display: 'grid',
164
+ gridTemplateRows: '1fr',
165
+ gridTemplateColumns: '1fr',
166
+ backgroundColor: '#000',
167
+ ...props.style,
168
+ })}
169
+ accessible={props.accessible}
170
+ accessibilityLabel={props.accessibilityLabel}
171
+ accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any}
172
+ accessibilityHint={props.accessibilityHint}
173
+ accessibilityValue={props.accessibilityValue}
174
+ accessibilityState={nativeAccessibilityState(props.accessibilityState) as any}
175
+ accessibilityLiveRegion={props.accessibilityLiveRegion as any}
176
+ >
177
+ <camerapreview ref={bindHost} style={{ gridRow: '1', gridColumn: '1' }} />
135
178
  </masonview>
136
179
  }
@@ -1,20 +1,30 @@
1
- /** @jsxImportSource @nativescript-community/octane */
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
2
  import { useImperativeHandle, useCallback, useEffect, useRef } from 'octane'
3
3
  import type { CameraViewProps } from './props'
4
4
  import { cameraHardwarePresent, ensureCameraPermission } from './camera-permission.mobile'
5
5
  import { startCameraPreview } from './camera-session.ios'
6
6
  import { attachSessionPreview } from './session'
7
- import { applyEscapeProps, layoutChildProps, nativeAccessibilityRole, nativeAccessibilityState } from './layout-child'
7
+ import {
8
+ applyEscapeProps,
9
+ layoutChildProps,
10
+ nativeAccessibilityRole,
11
+ nativeAccessibilityState,
12
+ } from './layout-child'
13
+
8
14
  import { observePreviewTap } from './preview-tap'
9
15
 
10
16
  /** Live iOS preview backed by AVFoundation. With `session`, the preview
11
17
  * attaches to the session-owned AVCaptureSession so movie recording can
12
18
  * share it; without one the view owns its session as before. */
13
- export function CameraView(props: CameraViewProps) @{
19
+ export function CameraView(props: CameraViewProps): unknown @{
14
20
  const host = useRef<any>(null)
15
21
  const active = props.active !== false
16
22
  const facing = props.facing ?? 'back'
17
- useImperativeHandle(props.ref, () => ({ native: host.current.ios ?? host.current.nativeViewProtected }), []);
23
+ useImperativeHandle(
24
+ props.ref,
25
+ () => ({ native: host.current.ios ?? host.current.nativeViewProtected }),
26
+ [],
27
+ )
18
28
 
19
29
  const bindHost = useCallback((view: any) => {
20
30
  host.current = view
@@ -22,7 +32,10 @@ export function CameraView(props: CameraViewProps) @{
22
32
 
23
33
  useEffect(() => {
24
34
  const view = host.current
25
- if (!view || !active) return
35
+ if (!view || !active) {
36
+ return
37
+ }
38
+
26
39
  let disposed = false
27
40
  let stopPreview: (() => void) | undefined
28
41
  const fail = (message: string) => props.onError?.({ message })
@@ -36,7 +49,9 @@ export function CameraView(props: CameraViewProps) @{
36
49
  try {
37
50
  const detach = attachSessionPreview(props.session, view, {
38
51
  onReady: () => {
39
- if (!disposed) props.onReady?.()
52
+ if (!disposed) {
53
+ props.onReady?.()
54
+ }
40
55
  },
41
56
  })
42
57
 
@@ -56,7 +71,10 @@ export function CameraView(props: CameraViewProps) @{
56
71
  }
57
72
 
58
73
  ensureCameraPermission().then((granted) => {
59
- if (disposed) return
74
+ if (disposed) {
75
+ return
76
+ }
77
+
60
78
  if (!granted) {
61
79
  fail('camera permission denied')
62
80
  return
@@ -77,11 +95,32 @@ export function CameraView(props: CameraViewProps) @{
77
95
 
78
96
  useEffect(() => {
79
97
  const view = host.current
80
- if (!view) return
98
+ if (!view) {
99
+ return
100
+ }
101
+
81
102
  applyEscapeProps(view.ios ?? view.nativeViewProtected, props)
82
103
  }, [props.ref, props.ios])
83
104
 
84
105
  useEffect(() => observePreviewTap(host.current, props.onTap), [props.onTap])
85
106
 
86
- <masonview ref={bindHost} id={props.id} className={['vx-layers', 'vx-cameraview', props.className]} {...layoutChildProps(props, {display: "grid", gridTemplateRows: "1fr", gridTemplateColumns: "1fr", ...({ backgroundColor: '#000', ...props.style })})} accessible={props.accessible} accessibilityLabel={props.accessibilityLabel} accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any} accessibilityHint={props.accessibilityHint} accessibilityValue={props.accessibilityValue} accessibilityState={nativeAccessibilityState(props.accessibilityState) as any} accessibilityLiveRegion={props.accessibilityLiveRegion as any}/>
107
+ <masonview
108
+ ref={bindHost}
109
+ id={props.id}
110
+ className={['vx-layers', 'vx-cameraview', props.className]}
111
+ {...layoutChildProps(props, {
112
+ display: 'grid',
113
+ gridTemplateRows: '1fr',
114
+ gridTemplateColumns: '1fr',
115
+ backgroundColor: '#000',
116
+ ...props.style,
117
+ })}
118
+ accessible={props.accessible}
119
+ accessibilityLabel={props.accessibilityLabel}
120
+ accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any}
121
+ accessibilityHint={props.accessibilityHint}
122
+ accessibilityValue={props.accessibilityValue}
123
+ accessibilityState={nativeAccessibilityState(props.accessibilityState) as any}
124
+ accessibilityLiveRegion={props.accessibilityLiveRegion as any}
125
+ />
87
126
  }
@@ -1,7 +1,12 @@
1
- /** @jsxImportSource @octane-xplat/macos-renderer */
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
2
  import { useImperativeHandle, useCallback, useEffect, useRef } from 'octane'
3
3
  import type { CameraViewProps } from './props'
4
- import { cameraHardwarePresent, ensureCameraPermission, startCameraPreview } from './camera-session.macos'
4
+ import {
5
+ cameraHardwarePresent,
6
+ ensureCameraPermission,
7
+ startCameraPreview,
8
+ } from './camera-session.macos'
9
+
5
10
  import { attachSessionPreview } from './session'
6
11
  import { layoutChildProps, nativeAccessibilityRole, nativeAccessibilityState } from './layout-child'
7
12
  import { observePreviewTap } from './preview-tap'
@@ -9,7 +14,7 @@ import { observePreviewTap } from './preview-tap'
9
14
  /** Live AppKit preview backed by AVFoundation. With `session`, the preview
10
15
  * attaches to the session-owned AVCaptureSession so movie recording can
11
16
  * share it; without one the view owns its session as before. */
12
- export function CameraView(props: CameraViewProps) @{
17
+ export function CameraView(props: CameraViewProps): unknown @{
13
18
  const host = useRef<any>(null)
14
19
  const active = props.active !== false
15
20
  const facing = props.facing ?? 'back'
@@ -21,7 +26,10 @@ export function CameraView(props: CameraViewProps) @{
21
26
 
22
27
  useEffect(() => {
23
28
  const view = host.current
24
- if (!view || !active) return
29
+ if (!view || !active) {
30
+ return
31
+ }
32
+
25
33
  let disposed = false
26
34
  let stopPreview: (() => void) | undefined
27
35
  const fail = (message: string) => props.onError?.({ message })
@@ -35,7 +43,9 @@ export function CameraView(props: CameraViewProps) @{
35
43
  try {
36
44
  const detach = attachSessionPreview(props.session, view, {
37
45
  onReady: () => {
38
- if (!disposed) props.onReady?.()
46
+ if (!disposed) {
47
+ props.onReady?.()
48
+ }
39
49
  },
40
50
  })
41
51
 
@@ -55,7 +65,10 @@ export function CameraView(props: CameraViewProps) @{
55
65
  }
56
66
 
57
67
  ensureCameraPermission().then((granted) => {
58
- if (disposed) return
68
+ if (disposed) {
69
+ return
70
+ }
71
+
59
72
  if (!granted) {
60
73
  fail('camera permission denied')
61
74
  return
@@ -76,5 +89,23 @@ export function CameraView(props: CameraViewProps) @{
76
89
 
77
90
  useEffect(() => observePreviewTap(host.current, props.onTap), [props.onTap])
78
91
 
79
- <masonview ref={bindHost} id={props.id} className={['vx-layers', 'vx-cameraview', props.className]} {...layoutChildProps(props, {display: "grid", gridTemplateRows: "1fr", gridTemplateColumns: "1fr", ...({ backgroundColor: '#000000', ...props.style })})} accessible={props.accessible} accessibilityLabel={props.accessibilityLabel} accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any} accessibilityHint={props.accessibilityHint} accessibilityValue={props.accessibilityValue} accessibilityState={nativeAccessibilityState(props.accessibilityState) as any} accessibilityLiveRegion={props.accessibilityLiveRegion as any}/>
92
+ <masonview
93
+ ref={bindHost}
94
+ id={props.id}
95
+ className={['vx-layers', 'vx-cameraview', props.className]}
96
+ {...layoutChildProps(props, {
97
+ display: 'grid',
98
+ gridTemplateRows: '1fr',
99
+ gridTemplateColumns: '1fr',
100
+ backgroundColor: '#000000',
101
+ ...props.style,
102
+ })}
103
+ accessible={props.accessible}
104
+ accessibilityLabel={props.accessibilityLabel}
105
+ accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any}
106
+ accessibilityHint={props.accessibilityHint}
107
+ accessibilityValue={props.accessibilityValue}
108
+ accessibilityState={nativeAccessibilityState(props.accessibilityState) as any}
109
+ accessibilityLiveRegion={props.accessibilityLiveRegion as any}
110
+ />
80
111
  }