@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.
Files changed (67) hide show
  1. package/README.md +2 -132
  2. package/package.json +108 -103
  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 +194 -118
  7. package/src/CameraView.ios.tsrx +129 -76
  8. package/src/CameraView.macos.tsrx +108 -70
  9. package/src/CameraView.tsrx +2 -0
  10. package/src/CameraView.web.tsrx +160 -125
  11. package/src/CameraView.windows.tsrx +141 -92
  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 +266 -222
  19. package/src/index.ts +28 -26
  20. package/src/index.web.ts +27 -25
  21. package/src/layout-child.ts +88 -79
  22. package/src/layout-child.web.ts +57 -51
  23. package/src/layout-child.windows.ts +82 -71
  24. package/src/movie-metadata.web.ts +87 -74
  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 +118 -68
  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 +1556 -1467
  42. package/src/session-core.ts +925 -711
  43. package/src/session.ts +12 -12
  44. package/src/style-merge.ts +43 -43
  45. package/src/synthetic-session.ts +392 -333
  46. package/src/types.ts +384 -239
  47. package/types/generated/.tsrx-typegen-manifest.json +18 -0
  48. package/types/generated/CameraView.d.ts +2 -0
  49. package/types/generated/CameraView.web.d.ts +4 -0
  50. package/types/generated/camera-host.macos.d.ts +33 -0
  51. package/types/generated/index.d.ts +34 -0
  52. package/types/generated/layout-child.web.d.ts +7 -0
  53. package/types/generated/photo-lifecycle.macos.d.ts +12 -0
  54. package/types/generated/photo-sheet.macos.d.ts +36 -0
  55. package/types/generated/props.d.ts +111 -0
  56. package/types/generated/session-backend.d.ts +6 -0
  57. package/types/{session-core.d.ts → generated/session-core.d.ts} +30 -1
  58. package/types/generated/session.d.ts +16 -0
  59. package/types/{synthetic-session.d.ts → generated/synthetic-session.d.ts} +15 -1
  60. package/types/{types.d.ts → generated/types.d.ts} +145 -2
  61. package/LICENSE +0 -21
  62. package/platforms/macos/src/CameraOwnership.swift +0 -22
  63. package/platforms/macos/src/PhotoCaptureLifecycle.swift +0 -34
  64. package/platforms/macos/src/XplatCameraHost.swift +0 -639
  65. package/platforms/macos/src/XplatPhotoCaptureSheet.swift +0 -192
  66. package/types/index.d.ts +0 -48
  67. package/types/props.d.ts +0 -61
package/src/index.web.ts CHANGED
@@ -3,31 +3,33 @@ export type { CameraAccessibilityRole, CameraViewHandle, CameraViewProps } from
3
3
  export { createCameraSession } from './session'
4
4
  export { CameraCaptureError } from './types'
5
5
  export type {
6
- CameraCaptureErrorKind,
7
- CameraDeviceInfo,
8
- CameraFacing,
9
- CameraInterruptionReason,
10
- CameraOrientation,
11
- CameraPermissionKind,
12
- CameraPermissionStatus,
13
- CameraPreviewPoint,
14
- CameraProfileCapability,
15
- CameraRecorderState,
16
- CameraSelection,
17
- CameraSession,
18
- CameraSessionCapabilities,
19
- CameraSessionConfig,
20
- CameraSessionEvent,
21
- CameraSessionSnapshot,
22
- CaptureIssue,
23
- EffectiveCaptureConfig,
24
- MovieClip,
25
- MovieEndReason,
26
- MovieOutcome,
27
- MovieOutput,
28
- MovieOutputHandle,
29
- MovieTake,
30
- StartRecordingOptions,
6
+ CameraCaptureErrorKind,
7
+ CameraDeviceInfo,
8
+ CameraFacing,
9
+ CameraInterruptionReason,
10
+ CameraOrientation,
11
+ CameraPermissionKind,
12
+ CameraPermissionStatus,
13
+ CameraPinchEvent,
14
+ CameraPreviewPoint,
15
+ CameraProfileCapability,
16
+ CameraRecorderState,
17
+ CameraSelection,
18
+ CameraSession,
19
+ CameraSessionCapabilities,
20
+ CameraSessionConfig,
21
+ CameraSessionEvent,
22
+ CameraSessionSnapshot,
23
+ CameraZoomState,
24
+ CaptureIssue,
25
+ EffectiveCaptureConfig,
26
+ MovieClip,
27
+ MovieEndReason,
28
+ MovieOutcome,
29
+ MovieOutput,
30
+ MovieOutputHandle,
31
+ MovieTake,
32
+ StartRecordingOptions,
31
33
  } from './types'
32
34
 
33
35
  export { createMemoryCameraStorage, createSyntheticCameraSession } from './synthetic-session'
@@ -4,100 +4,109 @@ import { mergeStyle } from './style-merge'
4
4
 
5
5
  /** NativeScript reads layout fields from a child view during parent layout. */
6
6
  export function layoutChildProps(
7
- props: CameraViewProps,
8
- baseStyle: Record<string, any> | string | undefined = props.style,
9
- ) {
10
- const style: Record<string, any> = { ...(typeof baseStyle === 'object' ? baseStyle : {}) }
11
- if (props.row !== undefined) {
12
- style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
13
- } else if (props.rowSpan !== undefined) {
14
- style.gridRow = `span ${props.rowSpan}`
15
- }
16
- if (props.col !== undefined) {
17
- style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`
18
- } else if (props.colSpan !== undefined) {
19
- style.gridColumn = `span ${props.colSpan}`
20
- }
21
- if (props.dock !== undefined) {
22
- style.position = style.position ?? 'absolute'
23
- if (props.dock === 'left' || props.dock === 'top' || props.dock === 'bottom') {
24
- style.left = style.left ?? 0
25
- }
26
-
27
- if (props.dock === 'right' || props.dock === 'top' || props.dock === 'bottom') {
28
- style.right = style.right ?? 0
29
- }
30
-
31
- if (props.dock === 'top' || props.dock === 'left' || props.dock === 'right') {
32
- style.top = style.top ?? 0
33
- }
34
-
35
- if (props.dock === 'bottom' || props.dock === 'left' || props.dock === 'right') {
36
- style.bottom = style.bottom ?? 0
37
- }
38
- }
39
- for (const key of ['left', 'top', 'flexGrow', 'flexShrink', 'alignSelf', 'order'] as const) {
40
- if (props[key] !== undefined) {
41
- style[key] = props[key]
42
- }
43
- }
44
- if ((props.left !== undefined || props.top !== undefined) && props.dock === undefined) {
45
- style.position = style.position ?? 'absolute'
46
- }
47
- return { style: typeof baseStyle === 'string' ? mergeStyle(style, baseStyle) : style }
7
+ props: CameraViewProps,
8
+ baseStyle: Record<string, any> | string | undefined = props.style,
9
+ ): {
10
+ style: string | Record<string, any>
11
+ } {
12
+ const style: Record<string, any> = { ...(typeof baseStyle === 'object' ? baseStyle : {}) }
13
+
14
+ if (props.row !== undefined) {
15
+ style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
16
+ } else if (props.rowSpan !== undefined) {
17
+ style.gridRow = `span ${props.rowSpan}`
18
+ }
19
+
20
+ if (props.col !== undefined) {
21
+ style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`
22
+ } else if (props.colSpan !== undefined) {
23
+ style.gridColumn = `span ${props.colSpan}`
24
+ }
25
+
26
+ if (props.dock !== undefined) {
27
+ style.position = style.position ?? 'absolute'
28
+ if (props.dock === 'left' || props.dock === 'top' || props.dock === 'bottom') {
29
+ style.left = style.left ?? 0
30
+ }
31
+
32
+ if (props.dock === 'right' || props.dock === 'top' || props.dock === 'bottom') {
33
+ style.right = style.right ?? 0
34
+ }
35
+
36
+ if (props.dock === 'top' || props.dock === 'left' || props.dock === 'right') {
37
+ style.top = style.top ?? 0
38
+ }
39
+
40
+ if (props.dock === 'bottom' || props.dock === 'left' || props.dock === 'right') {
41
+ style.bottom = style.bottom ?? 0
42
+ }
43
+ }
44
+
45
+ for (const key of ['left', 'top', 'flexGrow', 'flexShrink', 'alignSelf', 'order'] as const) {
46
+ if (props[key] !== undefined) {
47
+ style[key] = props[key]
48
+ }
49
+ }
50
+
51
+ if ((props.left !== undefined || props.top !== undefined) && props.dock === undefined) {
52
+ style.position = style.position ?? 'absolute'
53
+ }
54
+
55
+ return { style: typeof baseStyle === 'string' ? mergeStyle(style, baseStyle) : style }
48
56
  }
49
57
 
50
58
  export function applyEscapeProps(view: any, props: { ios?: any; android?: any }): void {
51
- if (!view) {
52
- return
53
- }
54
-
55
- const bag = isIOS ? props.ios : props.android
56
- if (bag) {
57
- Object.assign(view, bag)
58
- }
59
+ if (!view) {
60
+ return
61
+ }
62
+
63
+ const bag = isIOS ? props.ios : props.android
64
+
65
+ if (bag) {
66
+ Object.assign(view, bag)
67
+ }
59
68
  }
60
69
 
61
70
  const nativeRoles: Record<string, string> = {
62
- button: 'button',
63
- link: 'link',
64
- search: 'search',
65
- image: 'image',
66
- heading: 'header',
67
- adjustable: 'adjustable',
68
- summary: 'summary',
69
- text: 'text',
70
- none: 'none',
71
- progressbar: 'progressBar',
72
- checkbox: 'checkbox',
73
- switch: 'switch',
74
- radio: 'radioButton',
75
- spinbutton: 'spinButton',
76
- tab: 'button',
71
+ button: 'button',
72
+ link: 'link',
73
+ search: 'search',
74
+ image: 'image',
75
+ heading: 'header',
76
+ adjustable: 'adjustable',
77
+ summary: 'summary',
78
+ text: 'text',
79
+ none: 'none',
80
+ progressbar: 'progressBar',
81
+ checkbox: 'checkbox',
82
+ switch: 'switch',
83
+ radio: 'radioButton',
84
+ spinbutton: 'spinButton',
85
+ tab: 'button',
77
86
  }
78
87
 
79
88
  export function nativeAccessibilityRole(role?: string): string | undefined {
80
- return role ? nativeRoles[role] : undefined
89
+ return role ? nativeRoles[role] : undefined
81
90
  }
82
91
 
83
92
  export function nativeAccessibilityState(
84
- state?: CameraViewProps['accessibilityState'],
93
+ state?: CameraViewProps['accessibilityState'],
85
94
  ): string | undefined {
86
- if (state?.disabled) {
87
- return 'disabled'
88
- }
95
+ if (state?.disabled) {
96
+ return 'disabled'
97
+ }
89
98
 
90
- if (state?.selected) {
91
- return 'selected'
92
- }
99
+ if (state?.selected) {
100
+ return 'selected'
101
+ }
93
102
 
94
- if (state?.checked === true) {
95
- return 'checked'
96
- }
103
+ if (state?.checked === true) {
104
+ return 'checked'
105
+ }
97
106
 
98
- if (state?.checked === false) {
99
- return 'unchecked'
100
- }
107
+ if (state?.checked === false) {
108
+ return 'unchecked'
109
+ }
101
110
 
102
- return undefined
111
+ return undefined
103
112
  }
@@ -1,66 +1,72 @@
1
1
  import type { CameraViewProps } from './props'
2
2
 
3
- export function layoutChildProps(props: CameraViewProps, baseStyle: any = props.style) {
4
- const style = { ...baseStyle }
5
- if (props.row !== undefined) {
6
- style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
7
- } else if (props.rowSpan !== undefined) {
8
- style.gridRow = `span ${props.rowSpan}`
9
- }
3
+ export function layoutChildProps(
4
+ props: CameraViewProps,
5
+ baseStyle: any = props.style,
6
+ ): {
7
+ style: any
8
+ } {
9
+ const style = { ...baseStyle }
10
10
 
11
- if (props.col !== undefined) {
12
- style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`
13
- } else if (props.colSpan !== undefined) {
14
- style.gridColumn = `span ${props.colSpan}`
15
- }
11
+ if (props.row !== undefined) {
12
+ style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
13
+ } else if (props.rowSpan !== undefined) {
14
+ style.gridRow = `span ${props.rowSpan}`
15
+ }
16
16
 
17
- if (props.left !== undefined) {
18
- style.left = props.left
19
- }
17
+ if (props.col !== undefined) {
18
+ style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`
19
+ } else if (props.colSpan !== undefined) {
20
+ style.gridColumn = `span ${props.colSpan}`
21
+ }
20
22
 
21
- if (props.top !== undefined) {
22
- style.top = props.top
23
- }
23
+ if (props.left !== undefined) {
24
+ style.left = props.left
25
+ }
24
26
 
25
- if (props.flexGrow !== undefined) {
26
- style.flexGrow = props.flexGrow
27
- }
27
+ if (props.top !== undefined) {
28
+ style.top = props.top
29
+ }
28
30
 
29
- if (props.flexShrink !== undefined) {
30
- style.flexShrink = props.flexShrink
31
- }
31
+ if (props.flexGrow !== undefined) {
32
+ style.flexGrow = props.flexGrow
33
+ }
32
34
 
33
- if (props.alignSelf !== undefined) {
34
- style.alignSelf = props.alignSelf
35
- }
35
+ if (props.flexShrink !== undefined) {
36
+ style.flexShrink = props.flexShrink
37
+ }
36
38
 
37
- if (props.order !== undefined) {
38
- style.order = props.order
39
- }
39
+ if (props.alignSelf !== undefined) {
40
+ style.alignSelf = props.alignSelf
41
+ }
40
42
 
41
- return { style }
43
+ if (props.order !== undefined) {
44
+ style.order = props.order
45
+ }
46
+
47
+ return { style }
42
48
  }
43
49
 
44
50
  export function applyEscapeProps(element: any, props: { web?: any }): void {
45
- if (!element || !props.web) {
46
- return
47
- }
51
+ if (!element || !props.web) {
52
+ return
53
+ }
48
54
 
49
- for (const [key, value] of Object.entries(props.web)) {
50
- if (key.includes('-')) {
51
- if (value == null || value === false) {
52
- element.removeAttribute(key)
53
- } else {
54
- element.setAttribute(key, value === true ? '' : String(value))
55
- }
56
- } else if (key in element) {
57
- try {
58
- element[key] = value
59
- } catch {
60
- element.setAttribute(key, String(value))
61
- }
62
- } else if (value != null) {
63
- element.setAttribute(key, String(value))
64
- }
65
- }
55
+ for (const [key, value] of Object.entries(props.web)) {
56
+ if (key.includes('-')) {
57
+ if (value == null || value === false) {
58
+ element.removeAttribute(key)
59
+ } else {
60
+ element.setAttribute(key, value === true ? '' : String(value))
61
+ }
62
+ } else if (key in element) {
63
+ try {
64
+ element[key] = value
65
+ } catch {
66
+ element.setAttribute(key, String(value))
67
+ }
68
+ } else if (value != null) {
69
+ element.setAttribute(key, String(value))
70
+ }
71
+ }
66
72
  }
@@ -7,92 +7,103 @@ import { mergeStyle } from './style-merge'
7
7
  * boundary. */
8
8
 
9
9
  export function layoutChildProps(
10
- props: CameraViewProps,
11
- baseStyle: Record<string, any> | string | undefined = props.style,
12
- ) {
13
- const style: Record<string, any> = { ...(typeof baseStyle === 'object' ? baseStyle : {}) }
14
- if (props.row !== undefined) {
15
- style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
16
- } else if (props.rowSpan !== undefined) {
17
- style.gridRow = `span ${props.rowSpan}`
18
- }
19
- if (props.col !== undefined) {
20
- style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`
21
- } else if (props.colSpan !== undefined) {
22
- style.gridColumn = `span ${props.colSpan}`
23
- }
24
- if (props.dock !== undefined) {
25
- style.position = style.position ?? 'absolute'
26
- if (props.dock === 'left' || props.dock === 'top' || props.dock === 'bottom') {
27
- style.left = style.left ?? 0
28
- }
29
- if (props.dock === 'right' || props.dock === 'top' || props.dock === 'bottom') {
30
- style.right = style.right ?? 0
31
- }
32
- if (props.dock === 'top' || props.dock === 'left' || props.dock === 'right') {
33
- style.top = style.top ?? 0
34
- }
35
- if (props.dock === 'bottom' || props.dock === 'left' || props.dock === 'right') {
36
- style.bottom = style.bottom ?? 0
37
- }
38
- }
39
- for (const key of ['left', 'top', 'flexGrow', 'flexShrink', 'alignSelf', 'order'] as const) {
40
- if (props[key] !== undefined) {
41
- style[key] = props[key]
42
- }
43
- }
44
- if ((props.left !== undefined || props.top !== undefined) && props.dock === undefined) {
45
- style.position = style.position ?? 'absolute'
46
- }
47
- return { style: typeof baseStyle === 'string' ? mergeStyle(style, baseStyle) : style }
10
+ props: CameraViewProps,
11
+ baseStyle: Record<string, any> | string | undefined = props.style,
12
+ ): {
13
+ style: string | Record<string, any>
14
+ } {
15
+ const style: Record<string, any> = { ...(typeof baseStyle === 'object' ? baseStyle : {}) }
16
+
17
+ if (props.row !== undefined) {
18
+ style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
19
+ } else if (props.rowSpan !== undefined) {
20
+ style.gridRow = `span ${props.rowSpan}`
21
+ }
22
+
23
+ if (props.col !== undefined) {
24
+ style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`
25
+ } else if (props.colSpan !== undefined) {
26
+ style.gridColumn = `span ${props.colSpan}`
27
+ }
28
+
29
+ if (props.dock !== undefined) {
30
+ style.position = style.position ?? 'absolute'
31
+ if (props.dock === 'left' || props.dock === 'top' || props.dock === 'bottom') {
32
+ style.left = style.left ?? 0
33
+ }
34
+
35
+ if (props.dock === 'right' || props.dock === 'top' || props.dock === 'bottom') {
36
+ style.right = style.right ?? 0
37
+ }
38
+
39
+ if (props.dock === 'top' || props.dock === 'left' || props.dock === 'right') {
40
+ style.top = style.top ?? 0
41
+ }
42
+
43
+ if (props.dock === 'bottom' || props.dock === 'left' || props.dock === 'right') {
44
+ style.bottom = style.bottom ?? 0
45
+ }
46
+ }
47
+
48
+ for (const key of ['left', 'top', 'flexGrow', 'flexShrink', 'alignSelf', 'order'] as const) {
49
+ if (props[key] !== undefined) {
50
+ style[key] = props[key]
51
+ }
52
+ }
53
+
54
+ if ((props.left !== undefined || props.top !== undefined) && props.dock === undefined) {
55
+ style.position = style.position ?? 'absolute'
56
+ }
57
+
58
+ return { style: typeof baseStyle === 'string' ? mergeStyle(style, baseStyle) : style }
48
59
  }
49
60
 
50
61
  export function applyEscapeProps(view: any, props: { windows?: any }): void {
51
- if (view && props.windows) {
52
- Object.assign(view, props.windows)
53
- }
62
+ if (view && props.windows) {
63
+ Object.assign(view, props.windows)
64
+ }
54
65
  }
55
66
 
56
67
  const nativeRoles: Record<string, string> = {
57
- button: 'button',
58
- link: 'link',
59
- search: 'search',
60
- image: 'image',
61
- heading: 'header',
62
- adjustable: 'adjustable',
63
- summary: 'summary',
64
- text: 'text',
65
- none: 'none',
66
- progressbar: 'progressBar',
67
- checkbox: 'checkbox',
68
- switch: 'switch',
69
- radio: 'radioButton',
70
- spinbutton: 'spinButton',
71
- tab: 'button',
68
+ button: 'button',
69
+ link: 'link',
70
+ search: 'search',
71
+ image: 'image',
72
+ heading: 'header',
73
+ adjustable: 'adjustable',
74
+ summary: 'summary',
75
+ text: 'text',
76
+ none: 'none',
77
+ progressbar: 'progressBar',
78
+ checkbox: 'checkbox',
79
+ switch: 'switch',
80
+ radio: 'radioButton',
81
+ spinbutton: 'spinButton',
82
+ tab: 'button',
72
83
  }
73
84
 
74
85
  export function nativeAccessibilityRole(role?: string): string | undefined {
75
- return role ? nativeRoles[role] : undefined
86
+ return role ? nativeRoles[role] : undefined
76
87
  }
77
88
 
78
89
  export function nativeAccessibilityState(
79
- state?: CameraViewProps['accessibilityState'],
90
+ state?: CameraViewProps['accessibilityState'],
80
91
  ): string | undefined {
81
- if (state?.disabled) {
82
- return 'disabled'
83
- }
92
+ if (state?.disabled) {
93
+ return 'disabled'
94
+ }
84
95
 
85
- if (state?.selected) {
86
- return 'selected'
87
- }
96
+ if (state?.selected) {
97
+ return 'selected'
98
+ }
88
99
 
89
- if (state?.checked === true) {
90
- return 'checked'
91
- }
100
+ if (state?.checked === true) {
101
+ return 'checked'
102
+ }
92
103
 
93
- if (state?.checked === false) {
94
- return 'unchecked'
95
- }
104
+ if (state?.checked === false) {
105
+ return 'unchecked'
106
+ }
96
107
 
97
- return undefined
108
+ return undefined
98
109
  }