@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
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import AppKit
|
|
2
|
-
import AVFoundation
|
|
3
|
-
|
|
4
|
-
/// App-owned still-photo UI. No microphone input, movie output or Photos writes.
|
|
5
|
-
@objc(XplatPhotoCaptureSheet)
|
|
6
|
-
public final class XplatPhotoCaptureSheet: NSObject, NSWindowDelegate {
|
|
7
|
-
private let host = XplatCameraHost()
|
|
8
|
-
private let lifecycle = PhotoCaptureLifecycle()
|
|
9
|
-
private var sheet: NSWindow?
|
|
10
|
-
private weak var parent: NSWindow?
|
|
11
|
-
private var reply: ((String?) -> Void)?
|
|
12
|
-
private var timeout: DispatchWorkItem?
|
|
13
|
-
private var closeObserver: NSObjectProtocol?
|
|
14
|
-
private var preview: NSView?
|
|
15
|
-
private var captureButton: NSButton?
|
|
16
|
-
private var statusLabel: NSTextField?
|
|
17
|
-
private var options: NSDictionary = [:]
|
|
18
|
-
private var disposed = false
|
|
19
|
-
var operationTimeout: TimeInterval = 15
|
|
20
|
-
|
|
21
|
-
@objc public func permissionStatus() -> NSString { host.permissionStatus("camera") }
|
|
22
|
-
|
|
23
|
-
@objc public func present(_ options: NSDictionary, reply: @escaping (String?) -> Void) {
|
|
24
|
-
guard let parent = NSApp.keyWindow ?? NSApp.mainWindow else { reply(nil); return }
|
|
25
|
-
presentOnWindow(parent, options: options, reply: reply)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Explicit host window also allows deterministic AppKit lifecycle checks.
|
|
29
|
-
func presentOnWindow(_ parent: NSWindow, options: NSDictionary, reply: @escaping (String?) -> Void) {
|
|
30
|
-
guard !disposed, sheet == nil, parent.attachedSheet == nil,
|
|
31
|
-
!(options["saveToGallery"] as? Bool ?? false)
|
|
32
|
-
else { reply(nil); return }
|
|
33
|
-
self.options = options
|
|
34
|
-
self.reply = reply
|
|
35
|
-
self.parent = parent
|
|
36
|
-
let sheet = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 640, height: 480),
|
|
37
|
-
styleMask: [.titled, .closable], backing: .buffered, defer: false)
|
|
38
|
-
sheet.title = "Take a photo"
|
|
39
|
-
sheet.delegate = self
|
|
40
|
-
let content = NSView(frame: NSRect(x: 0, y: 0, width: 640, height: 480))
|
|
41
|
-
let preview = NSView(frame: NSRect(x: 16, y: 80, width: 608, height: 384))
|
|
42
|
-
preview.wantsLayer = true
|
|
43
|
-
preview.layer?.backgroundColor = NSColor.black.cgColor
|
|
44
|
-
content.addSubview(preview)
|
|
45
|
-
let status = NSTextField(labelWithString: "Choose Capture to start the camera.")
|
|
46
|
-
status.frame = NSRect(x: 16, y: 48, width: 440, height: 22)
|
|
47
|
-
content.addSubview(status)
|
|
48
|
-
let cancel = NSButton(title: "Cancel", target: self, action: #selector(cancelPhoto))
|
|
49
|
-
cancel.keyEquivalent = "\u{1b}"
|
|
50
|
-
cancel.frame = NSRect(x: 432, y: 12, width: 92, height: 32)
|
|
51
|
-
content.addSubview(cancel)
|
|
52
|
-
let capture = NSButton(title: "Capture", target: self, action: #selector(capturePhoto))
|
|
53
|
-
capture.keyEquivalent = "\r"
|
|
54
|
-
capture.frame = NSRect(x: 528, y: 12, width: 96, height: 32)
|
|
55
|
-
content.addSubview(capture)
|
|
56
|
-
sheet.contentView = content
|
|
57
|
-
self.sheet = sheet
|
|
58
|
-
self.preview = preview
|
|
59
|
-
statusLabel = status
|
|
60
|
-
captureButton = capture
|
|
61
|
-
closeObserver = NotificationCenter.default.addObserver(forName: NSWindow.willCloseNotification,
|
|
62
|
-
object: parent, queue: .main) { [weak self] _ in self?.complete(nil) }
|
|
63
|
-
parent.beginSheet(sheet) { [weak self] _ in self?.complete(nil) }
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private func deadline(_ token: Int) {
|
|
67
|
-
timeout?.cancel()
|
|
68
|
-
let work = DispatchWorkItem { [weak self] in
|
|
69
|
-
guard let self, lifecycle.accepts(token) else { return }
|
|
70
|
-
complete(nil)
|
|
71
|
-
}
|
|
72
|
-
timeout = work
|
|
73
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + operationTimeout, execute: work)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
@objc private func capturePhoto() {
|
|
77
|
-
if let token = lifecycle.prepare() {
|
|
78
|
-
captureButton?.isEnabled = false
|
|
79
|
-
statusLabel?.stringValue = "Starting camera…"
|
|
80
|
-
deadline(token)
|
|
81
|
-
// Authorization happens only after the user presses Capture.
|
|
82
|
-
host.requestPermission("camera") { [weak self] status in
|
|
83
|
-
guard let self, lifecycle.accepts(token) else { return }
|
|
84
|
-
guard status == "granted" else { complete(nil); return }
|
|
85
|
-
DispatchQueue.global(qos: .userInitiated).async { [self] in
|
|
86
|
-
let failure = self.host.configure(["photo": true, "audio": false])
|
|
87
|
-
DispatchQueue.main.async { [self] in
|
|
88
|
-
guard self.lifecycle.accepts(token) else { return }
|
|
89
|
-
guard failure == nil, let preview = self.preview else { self.complete(nil); return }
|
|
90
|
-
self.host.installObserver { [weak self] message in
|
|
91
|
-
guard let self, lifecycle.accepts(token),
|
|
92
|
-
let data = message.data(using: .utf8),
|
|
93
|
-
let event = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
|
|
94
|
-
else { return }
|
|
95
|
-
if event["type"] as? String == "previewReady", event["ready"] as? Bool == true,
|
|
96
|
-
lifecycle.ready(token) {
|
|
97
|
-
timeout?.cancel()
|
|
98
|
-
captureButton?.isEnabled = true
|
|
99
|
-
statusLabel?.stringValue = "Frame your photo, then choose Capture."
|
|
100
|
-
} else if event["type"] as? String == "interrupted" ||
|
|
101
|
-
(event["type"] as? String == "availability" && event["available"] as? Bool == false) {
|
|
102
|
-
complete(nil)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if self.host.attachPreview(preview) != nil { self.complete(nil) }
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
guard let token = lifecycle.capture() else { return }
|
|
112
|
-
captureButton?.isEnabled = false
|
|
113
|
-
statusLabel?.stringValue = "Taking photo…"
|
|
114
|
-
deadline(token)
|
|
115
|
-
if host.capturePhoto({ [weak self] data in
|
|
116
|
-
guard let self, lifecycle.accepts(token) else { return }
|
|
117
|
-
guard let data, let result = persist(data as Data) else { complete(nil); return }
|
|
118
|
-
complete(result)
|
|
119
|
-
}) != nil { complete(nil) }
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private func persist(_ data: Data) -> String? {
|
|
123
|
-
guard let source = NSBitmapImageRep(data: data) else { return nil }
|
|
124
|
-
let width = (options["width"] as? NSNumber)?.doubleValue ?? Double(source.pixelsWide)
|
|
125
|
-
let height = (options["height"] as? NSNumber)?.doubleValue ?? Double(source.pixelsHigh)
|
|
126
|
-
guard width.isFinite, height.isFinite, width >= 1, height >= 1, width <= 16384, height <= 16384, width * height <= 64_000_000 else { return nil }
|
|
127
|
-
let keepAspectRatio = options["keepAspectRatio"] as? Bool ?? true
|
|
128
|
-
let scale = min(width / Double(source.pixelsWide), height / Double(source.pixelsHigh), 1)
|
|
129
|
-
let size = NSSize(width: keepAspectRatio ? Double(source.pixelsWide) * scale : width,
|
|
130
|
-
height: keepAspectRatio ? Double(source.pixelsHigh) * scale : height)
|
|
131
|
-
guard let bitmap = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size.width),
|
|
132
|
-
pixelsHigh: Int(size.height), bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true,
|
|
133
|
-
isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0),
|
|
134
|
-
let context = NSGraphicsContext(bitmapImageRep: bitmap) else { return nil }
|
|
135
|
-
NSGraphicsContext.saveGraphicsState()
|
|
136
|
-
NSGraphicsContext.current = context
|
|
137
|
-
let image = NSImage(size: NSSize(width: source.pixelsWide, height: source.pixelsHigh))
|
|
138
|
-
image.addRepresentation(source)
|
|
139
|
-
image.draw(in: NSRect(origin: .zero, size: size))
|
|
140
|
-
NSGraphicsContext.restoreGraphicsState()
|
|
141
|
-
guard let jpeg = bitmap.representation(using: .jpeg, properties: [.compressionFactor: 0.9]) else { return nil }
|
|
142
|
-
let name = "octane-capture-\(UUID().uuidString).jpg"
|
|
143
|
-
let url = FileManager.default.temporaryDirectory.appendingPathComponent(name)
|
|
144
|
-
do {
|
|
145
|
-
let payload: [String: String] = ["name": name, "uri": url.path,
|
|
146
|
-
"dataUrl": "data:image/jpeg;base64," + jpeg.base64EncodedString()]
|
|
147
|
-
let message = try JSONSerialization.data(withJSONObject: payload)
|
|
148
|
-
try jpeg.write(to: url, options: .atomic)
|
|
149
|
-
return String(data: message, encoding: .utf8)
|
|
150
|
-
} catch {
|
|
151
|
-
try? FileManager.default.removeItem(at: url)
|
|
152
|
-
return nil
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
@objc private func cancelPhoto() { complete(nil) }
|
|
157
|
-
public func windowShouldClose(_ sender: NSWindow) -> Bool { complete(nil); return false }
|
|
158
|
-
|
|
159
|
-
private func complete(_ result: String?) {
|
|
160
|
-
guard lifecycle.finish() else { return }
|
|
161
|
-
let callback = reply
|
|
162
|
-
reply = nil
|
|
163
|
-
dispose()
|
|
164
|
-
callback?(result)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@objc public func discard(_ path: String) {
|
|
168
|
-
let url = URL(fileURLWithPath: path).standardizedFileURL
|
|
169
|
-
guard url.deletingLastPathComponent() == FileManager.default.temporaryDirectory.standardizedFileURL,
|
|
170
|
-
url.lastPathComponent.hasPrefix("octane-capture-") else { return }
|
|
171
|
-
try? FileManager.default.removeItem(at: url)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
@objc public func dispose() {
|
|
175
|
-
guard !disposed else { return }
|
|
176
|
-
disposed = true
|
|
177
|
-
timeout?.cancel()
|
|
178
|
-
timeout = nil
|
|
179
|
-
if let closeObserver { NotificationCenter.default.removeObserver(closeObserver) }
|
|
180
|
-
closeObserver = nil
|
|
181
|
-
host.dispose()
|
|
182
|
-
if let sheet { parent?.endSheet(sheet); sheet.orderOut(nil) }
|
|
183
|
-
sheet = nil
|
|
184
|
-
preview = nil
|
|
185
|
-
captureButton = nil
|
|
186
|
-
statusLabel = nil
|
|
187
|
-
// Disposal is also a cancellation, including an external owner teardown.
|
|
188
|
-
if lifecycle.finish() { let callback = reply; reply = nil; callback?(nil) }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
deinit { dispose() }
|
|
192
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Attributes } from '@octane-xplat/jsx/intrinsics';
|
|
2
|
-
import type { CameraViewProps } from './props.js';
|
|
3
|
-
declare module '@octane-xplat/jsx/intrinsics' {
|
|
4
|
-
interface NativeElements<TElement> {
|
|
5
|
-
camerapreview: Attributes<TElement, {}>;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
/** Live Android preview backed by CameraX. */
|
|
9
|
-
export declare function CameraView(props: CameraViewProps): unknown;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CameraViewProps } from './props.js';
|
|
2
|
-
/** Live iOS preview backed by AVFoundation. With `session`, the preview
|
|
3
|
-
* attaches to the session-owned AVCaptureSession so movie recording can
|
|
4
|
-
* share it; without one the view owns its session as before. */
|
|
5
|
-
export declare function CameraView(props: CameraViewProps): unknown;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CameraViewProps } from './props.js';
|
|
2
|
-
/** Live AppKit preview backed by AVFoundation. With `session`, the preview
|
|
3
|
-
* attaches to the session-owned AVCaptureSession so movie recording can
|
|
4
|
-
* share it; without one the view owns its session as before. */
|
|
5
|
-
export declare function CameraView(props: CameraViewProps): unknown;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { UniversalComponent } from 'octane/universal';
|
|
2
|
-
import type { CameraViewProps } from './props.js';
|
|
3
|
-
/** TypeScript fallback; the NativeScript resolver selects the .ios/.android
|
|
4
|
-
* implementation first at runtime. */
|
|
5
|
-
export declare const CameraView: UniversalComponent<CameraViewProps>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Attributes } from '@octane-xplat/jsx/intrinsics';
|
|
2
|
-
import type { CameraViewProps } from './props.js';
|
|
3
|
-
declare module '@octane-xplat/jsx/intrinsics' {
|
|
4
|
-
interface NativeElements<TElement> {
|
|
5
|
-
camerapreview: Attributes<TElement, {}>;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
/** Live Windows preview backed by WinUI `CaptureElement` + `MediaCapture`.
|
|
9
|
-
* With `session`, the preview attaches to the session-owned capture so
|
|
10
|
-
* movie recording shares it; without one the view owns its capture. */
|
|
11
|
-
export declare function CameraView(props: CameraViewProps): unknown;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** Windows camera-permission probe for preview-only `CameraView` callers.
|
|
2
|
-
* Uses `AppCapability` when projected and falls back to
|
|
3
|
-
* `DeviceAccessInformation`; both are non-prompting checks — only
|
|
4
|
-
* `RequestAccessAsync` may show the system prompt. */
|
|
5
|
-
export declare function cameraHardwarePresent(): boolean;
|
|
6
|
-
export declare function ensureCameraPermission(): Promise<boolean>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import '@nativescript/macos-node-api';
|
|
2
|
-
export declare function cameraHardwarePresent(): boolean;
|
|
3
|
-
/** Preview-only permission entry point: prompts once from mount, mirrors the
|
|
4
|
-
* iOS legacy path. Session code should use `session.requestPermission` —
|
|
5
|
-
* explicit actions only. */
|
|
6
|
-
export declare function ensureCameraPermission(): Promise<boolean>;
|
|
7
|
-
/** Legacy preview-only path: a dedicated XplatCameraHost owns the preview
|
|
8
|
-
* session — shared with nothing, disposed with the view. The session-backed
|
|
9
|
-
* path goes through `attachSessionPreview` instead. */
|
|
10
|
-
export declare function startCameraPreview(view: object, _facing: 'front' | 'back', onReady?: () => void): () => void;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Standalone (non-session) WinUI preview for `CameraView` without a
|
|
2
|
-
* `session` prop. Owns a private `MediaCapture` bound to a
|
|
3
|
-
* `CaptureElement`; the returned function stops preview and closes the
|
|
4
|
-
* device. Session-backed previews share their capture through
|
|
5
|
-
* `session-backend.windows.ts` instead. */
|
|
6
|
-
/** Attach a MediaCapture preview to the view's `CaptureElement`.
|
|
7
|
-
* `facing` maps to enclosure panels; desktop cameras without a panel fall
|
|
8
|
-
* back to the OS default — front/back is a preference, never a fabrication. */
|
|
9
|
-
export declare function startCameraPreview(view: any, facing: 'front' | 'back', onReady?: () => void): Promise<() => Promise<void>>;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { type HostClient } from '@octane-xplat/platform/host';
|
|
2
|
-
import type { MovieOutput, MovieOutputHandle } from './types.js';
|
|
3
|
-
export interface CameraHostServices {
|
|
4
|
-
camera: {
|
|
5
|
-
permissionStatus(options: {
|
|
6
|
-
kind: string;
|
|
7
|
-
}): Promise<{
|
|
8
|
-
status: string;
|
|
9
|
-
}>;
|
|
10
|
-
requestPermission(options: {
|
|
11
|
-
kind: string;
|
|
12
|
-
}): Promise<{
|
|
13
|
-
status: string;
|
|
14
|
-
}>;
|
|
15
|
-
movieDirectory(): Promise<{
|
|
16
|
-
fileUrl: string | null;
|
|
17
|
-
}>;
|
|
18
|
-
reserveMoviePath(options: {
|
|
19
|
-
fileUrl?: string;
|
|
20
|
-
container?: string;
|
|
21
|
-
}): Promise<{
|
|
22
|
-
reservation: {
|
|
23
|
-
fileUrl: string;
|
|
24
|
-
} | null;
|
|
25
|
-
}>;
|
|
26
|
-
writeMovieFile(options: {
|
|
27
|
-
fileUrl: string;
|
|
28
|
-
base64: string;
|
|
29
|
-
}): Promise<{
|
|
30
|
-
file: {
|
|
31
|
-
name: string;
|
|
32
|
-
uri: string;
|
|
33
|
-
} | null;
|
|
34
|
-
}>;
|
|
35
|
-
movieFileInfo(options: {
|
|
36
|
-
fileUrl: string;
|
|
37
|
-
}): Promise<{
|
|
38
|
-
info: {
|
|
39
|
-
exists: boolean;
|
|
40
|
-
fileUrl?: string;
|
|
41
|
-
size?: number;
|
|
42
|
-
} | null;
|
|
43
|
-
}>;
|
|
44
|
-
readMovieFile(options: {
|
|
45
|
-
fileUrl: string;
|
|
46
|
-
}): Promise<{
|
|
47
|
-
base64: string | null;
|
|
48
|
-
}>;
|
|
49
|
-
deleteMovieFile(options: {
|
|
50
|
-
fileUrl: string;
|
|
51
|
-
}): Promise<{
|
|
52
|
-
removed: boolean;
|
|
53
|
-
}>;
|
|
54
|
-
/** Optional chunked variants — a multi-hundred-MB movie must not
|
|
55
|
-
* round-trip through the bridge as one base64 payload. Absent on
|
|
56
|
-
* hosts built before the chunked contract; detected per client. */
|
|
57
|
-
writeMovieFileChunk?(options: {
|
|
58
|
-
fileUrl: string;
|
|
59
|
-
base64: string;
|
|
60
|
-
final?: boolean;
|
|
61
|
-
}): Promise<{
|
|
62
|
-
file: {
|
|
63
|
-
name: string;
|
|
64
|
-
uri: string;
|
|
65
|
-
} | {
|
|
66
|
-
ok: boolean;
|
|
67
|
-
} | null;
|
|
68
|
-
}>;
|
|
69
|
-
readMovieFileChunk?(options: {
|
|
70
|
-
fileUrl: string;
|
|
71
|
-
offset: number;
|
|
72
|
-
length: number;
|
|
73
|
-
}): Promise<{
|
|
74
|
-
base64: string | null;
|
|
75
|
-
}>;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
export type CameraHost = HostClient<CameraHostServices>;
|
|
79
|
-
/** The camera-capable desktop host client, or null outside a qualified host.
|
|
80
|
-
* Only a confirmed client stays cached — a null result may be a transient
|
|
81
|
-
* transport or capabilities failure, so the next call probes again rather
|
|
82
|
-
* than sticking 'absent' for the page lifetime. */
|
|
83
|
-
export declare function cameraHost(): Promise<CameraHost | null>;
|
|
84
|
-
/** Reserve a host-side movie file. `destinationFileUrl` is validated
|
|
85
|
-
* host-side: it must be a new file inside the app-private storage root. */
|
|
86
|
-
export declare const reserveHostMovie: (host: CameraHost, options: {
|
|
87
|
-
destinationFileUrl?: string;
|
|
88
|
-
container?: string;
|
|
89
|
-
}) => Promise<{
|
|
90
|
-
fileUrl: string;
|
|
91
|
-
}>;
|
|
92
|
-
/** Commit finalized movie bytes to host-side app-private storage. Hosts
|
|
93
|
-
* with the chunked contract stream 4MB slices — a multi-hundred-MB
|
|
94
|
-
* recording no longer materializes ~3-4x its size across the bridge. */
|
|
95
|
-
export declare const commitHostMovie: (host: CameraHost, fileUrl: string, bytes: Blob) => Promise<MovieOutput>;
|
|
96
|
-
/** Drop an uncommitted host reservation after a failed attempt. */
|
|
97
|
-
export declare const removeHostReservation: (host: CameraHost, fileUrl: string) => Promise<void>;
|
|
98
|
-
/** Reopen a host-stored movie as a temporary playback URL. The durable
|
|
99
|
-
* reference remains `fileUrl`; the returned url lives until `release()`. */
|
|
100
|
-
export declare const openHostMovie: (host: CameraHost, output: MovieOutput) => Promise<MovieOutputHandle>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { CameraView } from './CameraView.web.js';
|
|
2
|
-
export type { CameraAccessibilityRole, CameraViewHandle, CameraViewProps } from './props.js';
|
|
3
|
-
export { createCameraSession } from './session.js';
|
|
4
|
-
export { CameraCaptureError } from './types.js';
|
|
5
|
-
export type { CameraCaptureErrorKind, CameraDeviceInfo, CameraFacing, CameraInterruptionReason, CameraOrientation, CameraPermissionKind, CameraPermissionStatus, CameraPreviewPoint, CameraProfileCapability, CameraRecorderState, CameraSelection, CameraSession, CameraSessionCapabilities, CameraSessionConfig, CameraSessionEvent, CameraSessionSnapshot, CaptureIssue, EffectiveCaptureConfig, MovieClip, MovieEndReason, MovieOutcome, MovieOutput, MovieOutputHandle, MovieTake, StartRecordingOptions, } from './types.js';
|
|
6
|
-
export { createMemoryCameraStorage, createSyntheticCameraSession } from './synthetic-session.js';
|
|
7
|
-
export type { SyntheticCameraScript, SyntheticCameraStorage } from './synthetic-session.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CameraViewProps } from './props.js';
|
|
2
|
-
/** NativeScript reads layout fields from a child view during parent layout. */
|
|
3
|
-
export declare function layoutChildProps(props: CameraViewProps, baseStyle?: Record<string, any> | string | undefined): {
|
|
4
|
-
style: string | Record<string, any>;
|
|
5
|
-
};
|
|
6
|
-
export declare function applyEscapeProps(view: any, props: {
|
|
7
|
-
ios?: any;
|
|
8
|
-
android?: any;
|
|
9
|
-
}): void;
|
|
10
|
-
export declare function nativeAccessibilityRole(role?: string): string | undefined;
|
|
11
|
-
export declare function nativeAccessibilityState(state?: CameraViewProps['accessibilityState']): string | undefined;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CameraViewProps } from './props.js';
|
|
2
|
-
/** Windows twins of the layout-child helpers — the unsuffixed module
|
|
3
|
-
* resolves the platform escape bag through `isIOS`, which has no Windows
|
|
4
|
-
* branch. Pure helpers are re-declared here to keep divergence at the file
|
|
5
|
-
* boundary. */
|
|
6
|
-
export declare function layoutChildProps(props: CameraViewProps, baseStyle?: Record<string, any> | string | undefined): {
|
|
7
|
-
style: string | Record<string, any>;
|
|
8
|
-
};
|
|
9
|
-
export declare function applyEscapeProps(view: any, props: {
|
|
10
|
-
windows?: any;
|
|
11
|
-
}): void;
|
|
12
|
-
export declare function nativeAccessibilityRole(role?: string): string | undefined;
|
|
13
|
-
export declare function nativeAccessibilityState(state?: CameraViewProps['accessibilityState']): string | undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Read packet end timestamps and track metadata, never the wall-clock stop time. */
|
|
2
|
-
export declare function inspectMovie(bytes: Blob, audioRequested: boolean): Promise<{
|
|
3
|
-
durationMs: number;
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
hasAudio: boolean;
|
|
7
|
-
mimeType: string;
|
|
8
|
-
orientation: 'unspecified';
|
|
9
|
-
}>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { MovieClip, MovieOutput, MovieOutputHandle } from './types.js';
|
|
2
|
-
export declare function reserveMovie(): Promise<string>;
|
|
3
|
-
export declare function commitMovie(id: string, bytes: Blob, clip: MovieClip): Promise<void>;
|
|
4
|
-
export declare function removeReservation(id: string): Promise<void>;
|
|
5
|
-
export declare function openStoredMovie(output: MovieOutput): Promise<MovieOutputHandle>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CameraPreviewPoint } from './types.js';
|
|
2
|
-
/** Attach a notification-only 'tap' observer to a preview host view and
|
|
3
|
-
* report each tap as a `CameraPreviewPoint` normalized to the view's
|
|
4
|
-
* bounds. The tap gesture never consumes the touch — recognizers layered
|
|
5
|
-
* above the preview still see it. Platforms whose runtime never
|
|
6
|
-
* dispatches 'tap' simply never fire the callback. */
|
|
7
|
-
export declare function observePreviewTap(view: any, onTap: ((point: CameraPreviewPoint) => void) | undefined): () => void;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CameraSessionBackend } from './session-core.js';
|
|
2
|
-
import type { CameraSessionConfig } from './types.js';
|
|
3
|
-
/** iOS adapter: one AVCaptureSession shared between the attached preview
|
|
4
|
-
* and a single AVCaptureMovieFileOutput capture attempt. */
|
|
5
|
-
export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import '@nativescript/macos-node-api';
|
|
2
|
-
import type { CameraSessionBackend } from './session-core.js';
|
|
3
|
-
import type { CameraSessionConfig } from './types.js';
|
|
4
|
-
/** AppKit adapter: one XplatCameraHost (AVCaptureSession) shared between the
|
|
5
|
-
* attached preview and a single AVCaptureMovieFileOutput capture attempt.
|
|
6
|
-
* The Swift leaf owns the session, inputs, preview layer, and recording
|
|
7
|
-
* delegate; this adapter owns admission, semantics, and contract mapping. */
|
|
8
|
-
export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { CameraSessionBackend } from './session-core.js';
|
|
2
|
-
import type { CameraOrientation, CameraPermissionStatus, CameraSessionConfig, CaptureIssue } from './types.js';
|
|
3
|
-
/** AppCapabilityAccessStatus → portable permission. `notDeclared` is a
|
|
4
|
-
* setup error, not a status — callers surface `configurationMissing`. */
|
|
5
|
-
export declare const accessStatusToPermission: (status: number | undefined) => CameraPermissionStatus | 'notDeclared';
|
|
6
|
-
/** DeviceAccessStatus → portable permission for hosts without AppCapability. */
|
|
7
|
-
export declare const deviceAccessStatusToPermission: (status: number | undefined) => CameraPermissionStatus;
|
|
8
|
-
/** Enclosure panel → facing. Desktop cameras often report no panel — an
|
|
9
|
-
* external webcam never fabricates front/back semantics. */
|
|
10
|
-
export declare const panelToFacing: (panel: number | undefined) => 'front' | 'back' | undefined;
|
|
11
|
-
/** Stored display rotation (degrees CW) → cardinal orientation, matching the
|
|
12
|
-
* iOS transform mapping. Missing or unrecognized values stay `unspecified`. */
|
|
13
|
-
export declare const videoOrientationToOrientation: (degrees: number | undefined) => CameraOrientation;
|
|
14
|
-
export declare const orientationToRotation: (orientation: CameraOrientation) => number | undefined;
|
|
15
|
-
export interface WindowsCameraDevice {
|
|
16
|
-
id: string;
|
|
17
|
-
label: string;
|
|
18
|
-
facing?: 'front' | 'back';
|
|
19
|
-
}
|
|
20
|
-
/** Camera selection: explicit deviceId wins; front/back match the enclosure
|
|
21
|
-
* panel; `default` takes the OS-preferred camera then the first device. */
|
|
22
|
-
export declare const selectCameraDevice: (camera: CameraSessionConfig['camera'], devices: WindowsCameraDevice[], defaultId: string | undefined) => WindowsCameraDevice | undefined;
|
|
23
|
-
export interface WindowsStreamProfile {
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
frameRate: number;
|
|
27
|
-
subtype?: string;
|
|
28
|
-
}
|
|
29
|
-
/** Pick the standard profile: 1280x720 @ 30 fps when the source offers it,
|
|
30
|
-
* otherwise the smallest stream then lowest frame rate. The selected
|
|
31
|
-
* combination is disclosed — never an idealized 720p claim. */
|
|
32
|
-
export declare const chooseStandardProfile: (profiles: WindowsStreamProfile[]) => WindowsStreamProfile | undefined;
|
|
33
|
-
/** Classify a native failure without depending on projected error shapes.
|
|
34
|
-
* HRESULTs surface as `number`/`hresult`; MediaCapture failures also carry a
|
|
35
|
-
* numeric `code`. */
|
|
36
|
-
export declare const captureFailureKind: (cause: unknown) => CaptureIssue['kind'];
|
|
37
|
-
export declare function createSessionBackend(config: CameraSessionConfig): CameraSessionBackend;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Anything accepted as a style value, including nested arrays. */
|
|
2
|
-
export type StyleInput = string | Record<string, any> | null | undefined | readonly StyleInput[];
|
|
3
|
-
/** Merge component-emitted style defaults under the authored `style` prop.
|
|
4
|
-
* Authored keys win; array styles fold in order; a string style is appended
|
|
5
|
-
* after the serialized defaults so its declarations override them too. */
|
|
6
|
-
export declare function mergeStyle(base: Record<string, any>, style?: Record<string, any> | readonly (Record<string, any> | null | undefined)[] | null): Record<string, any>;
|
|
7
|
-
export declare function mergeStyle(base: Record<string, any>, style?: StyleInput): string | Record<string, any>;
|
|
8
|
-
export type StyleProp = string | Record<string, any> | readonly StyleProp[] | null | undefined;
|