@swiftbrowser/react 0.28.0 → 0.28.1
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 +40 -0
- package/dist/avAsset.d.ts +218 -0
- package/dist/avAsset.d.ts.map +1 -0
- package/dist/components/controls.d.ts +2 -1
- package/dist/components/controls.d.ts.map +1 -1
- package/dist/host/tree.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +578 -47
- package/dist/index.js.map +1 -1
- package/dist/videoRecorder.d.ts +65 -0
- package/dist/videoRecorder.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useVideoRecorder()`: the camera, as an iOS app records video with an
|
|
3
|
+
* `AVCaptureSession` and a movie file output. `open()` asks for the camera
|
|
4
|
+
* and the microphone and starts the live picture, which `CameraPreview`
|
|
5
|
+
* shows; `record()` records it and `time` counts; `stop()` resolves with
|
|
6
|
+
* the recording (a URL to play with `useAVPlayer`, its length, type and
|
|
7
|
+
* size) and leaves the camera open for the next; `close()` lets the camera
|
|
8
|
+
* go (as leaving the view does). The page records with `getUserMedia` and
|
|
9
|
+
* `MediaRecorder` (Web/src/videoRecorder.ts) into a `blob:` URL; the native
|
|
10
|
+
* app with an `AVCaptureSession` (VideoRecorderBridge.swift) into a
|
|
11
|
+
* QuickTime file in Documents/Recordings.
|
|
12
|
+
*/
|
|
13
|
+
import type { CameraFacing, VideoRecording } from '@swiftbrowser/web/src/videoRecorder';
|
|
14
|
+
import { type ReactNode } from 'react';
|
|
15
|
+
import { type ViewModifiers } from './modifiers';
|
|
16
|
+
export type { CameraFacing, VideoRecording };
|
|
17
|
+
/** `closed` (no camera), `opening` (asking for it), `ready` (its picture shows), `recording`, `paused`, `stopping`. */
|
|
18
|
+
export type VideoRecorderStatus = 'closed' | 'opening' | 'ready' | 'recording' | 'paused' | 'stopping';
|
|
19
|
+
export interface VideoRecorder {
|
|
20
|
+
/** Whether this page or app can record video at all. */
|
|
21
|
+
available: boolean;
|
|
22
|
+
status: VideoRecorderStatus;
|
|
23
|
+
/** The live picture's stream while the camera is open, for `CameraPreview`. */
|
|
24
|
+
stream: string | null;
|
|
25
|
+
/** The camera in use. */
|
|
26
|
+
facing: CameraFacing;
|
|
27
|
+
/** Seconds recorded so far (it holds while paused). */
|
|
28
|
+
time: number;
|
|
29
|
+
/** Why the last call failed (`permission: …` when the camera was refused), or null. */
|
|
30
|
+
error: string | null;
|
|
31
|
+
/** Opens the camera (`facing`, else the one used last, else the front); the picture shows once `status` is `ready`. */
|
|
32
|
+
open(facing?: CameraFacing): Promise<void>;
|
|
33
|
+
/** Lets the camera go (a recording under way is cancelled). */
|
|
34
|
+
close(): Promise<void>;
|
|
35
|
+
/** The other camera, front or back. */
|
|
36
|
+
flip(): Promise<void>;
|
|
37
|
+
record(): Promise<void>;
|
|
38
|
+
pause(): Promise<void>;
|
|
39
|
+
resume(): Promise<void>;
|
|
40
|
+
/** Ends the recording and resolves with it, or null when there was none. The camera stays open. */
|
|
41
|
+
stop(): Promise<VideoRecording | null>;
|
|
42
|
+
/** Ends the recording and keeps nothing. */
|
|
43
|
+
cancel(): Promise<void>;
|
|
44
|
+
/** Lets go of a recording `stop` made, when the app is done with it (saved it, or deleted it). */
|
|
45
|
+
discard(url: string): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface VideoRecorderOptions {
|
|
48
|
+
/** Milliseconds between readings of the recorded time (100: ten a second). */
|
|
49
|
+
timeInterval?: number;
|
|
50
|
+
}
|
|
51
|
+
export declare function useVideoRecorder(options?: VideoRecorderOptions): VideoRecorder;
|
|
52
|
+
export interface CameraPreviewProps extends ViewModifiers {
|
|
53
|
+
/** The recorder whose camera to show (its `stream`); nothing shows while it is closed. */
|
|
54
|
+
recorder: Pick<VideoRecorder, 'stream' | 'facing'>;
|
|
55
|
+
/** `videoGravity`: fill the view (the default, as the Camera app does) or fit in it. */
|
|
56
|
+
gravity?: 'resizeAspect' | 'resizeAspectFill' | 'resize';
|
|
57
|
+
/** Flipped left to right; by default the front camera is, as a mirror. */
|
|
58
|
+
mirrored?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The camera's live picture (an `AVCaptureVideoPreviewLayer`), black while
|
|
62
|
+
* the recorder's camera is closed. It fills its frame, cropping as needed.
|
|
63
|
+
*/
|
|
64
|
+
export declare function CameraPreview(props: CameraPreviewProps): ReactNode;
|
|
65
|
+
//# sourceMappingURL=videoRecorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"videoRecorder.d.ts","sourceRoot":"","sources":["../src/videoRecorder.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7E,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE7C,uHAAuH;AACvH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEvG,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,+EAA+E;IAC/E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,yBAAyB;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,uFAAuF;IACvF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uHAAuH;IACvH,IAAI,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,+DAA+D;IAC/D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,uCAAuC;IACvC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,mGAAmG;IACnG,IAAI,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACvC,4CAA4C;IAC5C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,kGAAkG;IAClG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAsIlF;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,0FAA0F;IAC1F,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;IACnD,wFAAwF;IACxF,OAAO,CAAC,EAAE,cAAc,GAAG,kBAAkB,GAAG,QAAQ,CAAC;IACzD,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAoBlE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swiftbrowser/react",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SwiftUI's components for React: a react-reconciler host that emits SwiftBrowser render ops into the @swiftbrowser/web renderer, so a pure React/TypeScript web app gets the same iOS UI as a SwiftUI app in the browser.",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test:unit": "vitest run"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@swiftbrowser/web": "0.28.
|
|
32
|
+
"@swiftbrowser/web": "0.28.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^19.0.0",
|