@nonstrict/recordkit 0.3.0 → 0.3.2-alpha.7
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/License.md +2 -0
- package/Readme.md +16 -0
- package/bin/README.md +1 -0
- package/bin/recordkit-rpc +0 -0
- package/out/RecordKit.d.ts +115 -34
- package/out/RecordKit.js +50 -1
- package/out/RecordKit.js.map +1 -1
- package/out/Recorder.d.ts +38 -9
- package/out/Recorder.js +5 -0
- package/out/Recorder.js.map +1 -1
- package/out/index.cjs +55 -1
- package/out/index.cjs.map +1 -1
- package/package.json +3 -4
- package/src/RecordKit.ts +136 -49
- package/src/Recorder.ts +84 -55
- package/typedoc.json +16 -4
package/License.md
CHANGED
package/Readme.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# RecordKit for Electron
|
|
2
|
+
|
|
3
|
+
RecordKit is a screen recording SDK for macOS apps. Enabling simultaneous recording of the users screen, system audio, camera, microphone, mouse and keyboard. RecordKit is the recording foundation of apps. Generating easy to use video and JSON to build upon.
|
|
4
|
+
|
|
5
|
+
## Useful links
|
|
6
|
+
|
|
7
|
+
- [RecordKit Homepage](https://nonstrict.eu/recordkit)
|
|
8
|
+
- [Getting Started](https://nonstrict.eu/recordkit/try-electron.html)
|
|
9
|
+
- [Full API Reference](https://nonstrict.eu/recordkit/api/electron/)
|
|
10
|
+
- [NPM package](https://www.npmjs.com/package/@nonstrict/recordkit)
|
|
11
|
+
|
|
12
|
+
## License
|
|
13
|
+
|
|
14
|
+
RecordKit is a commercial product that offers a free trial license to evaluate and integrate it into your product. Visit [our website](https://nonstrict.eu/recordkit) to learn more about licensing our solution.
|
|
15
|
+
|
|
16
|
+
Copyright © 2024 Nonstrict B.V.
|
package/bin/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# recordkit-rpc 0.3.2-alpha.7
|
package/bin/recordkit-rpc
CHANGED
|
Binary file
|
package/out/RecordKit.d.ts
CHANGED
|
@@ -1,13 +1,104 @@
|
|
|
1
1
|
import { Recorder, RecorderSchema } from "./Recorder.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Entry point for the RecordKit SDK, an instance is available as `recordkit` that can be imported from the module. Do not instantiate this class directly.
|
|
4
|
+
*
|
|
5
|
+
* @groupDescription Discovery
|
|
6
|
+
* Discover the windows and devices that are available to record.
|
|
7
|
+
*
|
|
8
|
+
* @groupDescription Permissions
|
|
9
|
+
* Check and request the apps permission to access the recording devices.
|
|
10
|
+
*/
|
|
11
|
+
export declare class RecordKit {
|
|
12
|
+
private ipcRecordKit;
|
|
13
|
+
/** @ignore */
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the RecordKit SDK.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ Must be called before calling any other RecordKit method.
|
|
19
|
+
*
|
|
20
|
+
* @param args
|
|
21
|
+
*/
|
|
22
|
+
initialize(args: {
|
|
23
|
+
/**
|
|
24
|
+
* Path to the `recordkit-rpc` binary, most of the time this should be set to `path.join(process.resourcesPath, 'recordkit-rpc')`.
|
|
25
|
+
*/
|
|
26
|
+
rpcBinaryPath: string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to fallback to the RPC binary from `node_modules` if the given path does not exist. When enabled an extra check to see if the given path exists is performed. Most of the time this should be set to `!app.isPackaged`.
|
|
29
|
+
*/
|
|
30
|
+
fallbackToNodeModules?: boolean;
|
|
31
|
+
/** @ignore */
|
|
32
|
+
logRpcMessages?: boolean;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* @group Discovery
|
|
36
|
+
*/
|
|
37
|
+
getWindows(): Promise<Window[]>;
|
|
38
|
+
/**
|
|
39
|
+
* @group Discovery
|
|
40
|
+
*/
|
|
41
|
+
getCameras(): Promise<Camera[]>;
|
|
42
|
+
/**
|
|
43
|
+
* @group Discovery
|
|
44
|
+
*/
|
|
45
|
+
getMicrophones(): Promise<Microphone[]>;
|
|
46
|
+
/**
|
|
47
|
+
* @group Discovery
|
|
48
|
+
*/
|
|
49
|
+
getAppleDevices(): Promise<AppleDevice[]>;
|
|
50
|
+
/**
|
|
51
|
+
* @group Permissions
|
|
52
|
+
*/
|
|
53
|
+
getCameraAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
54
|
+
/**
|
|
55
|
+
* @group Permissions
|
|
56
|
+
*/
|
|
57
|
+
getMicrophoneAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
58
|
+
/**
|
|
59
|
+
* @group Permissions
|
|
60
|
+
*/
|
|
61
|
+
getScreenRecordingAccess(): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* @group Permissions
|
|
64
|
+
*/
|
|
65
|
+
requestCameraAccess(): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* @group Permissions
|
|
68
|
+
*/
|
|
69
|
+
requestMicrophoneAccess(): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* @group Permissions
|
|
72
|
+
*/
|
|
73
|
+
requestScreenRecordingAccess(): Promise<void>;
|
|
74
|
+
createRecorder(schema: RecorderSchema): Promise<Recorder>;
|
|
75
|
+
}
|
|
76
|
+
/** @ignore */
|
|
77
|
+
export declare let recordkit: RecordKit;
|
|
78
|
+
/**
|
|
79
|
+
* @group Permissions
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* Describes the apps permission to access a recording device.
|
|
83
|
+
*
|
|
84
|
+
* - `notDetermined` The user has not yet made a choice.
|
|
85
|
+
* - `restricted` The user cannot change the client's status, possibly due to active restrictions such as parental controls being in place.
|
|
86
|
+
* - `denied` The user explicitly denied access to the hardware supporting a media type for the client.
|
|
87
|
+
* - `authorized` Application is authorized to access the hardware.
|
|
88
|
+
*/
|
|
89
|
+
export type AuthorizationStatus = 'notDetermined' | 'restricted' | 'denied' | 'authorized';
|
|
90
|
+
/**
|
|
91
|
+
* @group Discovery
|
|
92
|
+
*/
|
|
93
|
+
export interface AppleDevice {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
model_id?: string;
|
|
97
|
+
availability: 'available';
|
|
10
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* @group Discovery
|
|
101
|
+
*/
|
|
11
102
|
export interface Camera {
|
|
12
103
|
id: string;
|
|
13
104
|
name: string;
|
|
@@ -15,6 +106,9 @@ export interface Camera {
|
|
|
15
106
|
manufacturer: string;
|
|
16
107
|
availability: 'available' | 'lidClosed' | 'unknownSuspended';
|
|
17
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* @group Discovery
|
|
111
|
+
*/
|
|
18
112
|
export interface Microphone {
|
|
19
113
|
id: string;
|
|
20
114
|
name: string;
|
|
@@ -22,36 +116,23 @@ export interface Microphone {
|
|
|
22
116
|
manufacturer: string;
|
|
23
117
|
availability: 'available' | 'lidClosed' | 'unknownSuspended';
|
|
24
118
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
119
|
+
/**
|
|
120
|
+
* @group Discovery
|
|
121
|
+
*/
|
|
122
|
+
export interface Window {
|
|
123
|
+
id: number;
|
|
124
|
+
title?: string;
|
|
125
|
+
frame: Bounds;
|
|
126
|
+
level: number;
|
|
127
|
+
application_process_id?: number;
|
|
128
|
+
application_name?: string;
|
|
30
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* @group Utilities
|
|
132
|
+
*/
|
|
31
133
|
export interface Bounds {
|
|
32
134
|
x: number;
|
|
33
135
|
y: number;
|
|
34
136
|
width: number;
|
|
35
137
|
height: number;
|
|
36
138
|
}
|
|
37
|
-
export declare class RecordKit {
|
|
38
|
-
private ipcRecordKit;
|
|
39
|
-
initialize(args: {
|
|
40
|
-
rpcBinaryPath: string;
|
|
41
|
-
fallbackToNodeModules: boolean;
|
|
42
|
-
logRpcMessages?: boolean;
|
|
43
|
-
}): Promise<void>;
|
|
44
|
-
getWindows(): Promise<Window[]>;
|
|
45
|
-
getCameras(): Promise<Camera[]>;
|
|
46
|
-
getMicrophones(): Promise<Microphone[]>;
|
|
47
|
-
getAppleDevices(): Promise<AppleDevice[]>;
|
|
48
|
-
getCameraAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
49
|
-
getMicrophoneAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
50
|
-
getScreenRecordingAccess(): Promise<boolean>;
|
|
51
|
-
requestCameraAccess(): Promise<boolean>;
|
|
52
|
-
requestMicrophoneAccess(): Promise<boolean>;
|
|
53
|
-
requestScreenRecordingAccess(): Promise<void>;
|
|
54
|
-
createRecorder(schema: RecorderSchema): Promise<Recorder>;
|
|
55
|
-
}
|
|
56
|
-
export declare let recordkit: RecordKit;
|
|
57
|
-
export {};
|
package/out/RecordKit.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import { IpcRecordKit } from "./IpcRecordKit.js";
|
|
2
2
|
import { Recorder } from "./Recorder.js";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
|
+
/**
|
|
5
|
+
* Entry point for the RecordKit SDK, an instance is available as `recordkit` that can be imported from the module. Do not instantiate this class directly.
|
|
6
|
+
*
|
|
7
|
+
* @groupDescription Discovery
|
|
8
|
+
* Discover the windows and devices that are available to record.
|
|
9
|
+
*
|
|
10
|
+
* @groupDescription Permissions
|
|
11
|
+
* Check and request the apps permission to access the recording devices.
|
|
12
|
+
*/
|
|
4
13
|
export class RecordKit {
|
|
5
14
|
ipcRecordKit = new IpcRecordKit();
|
|
15
|
+
/** @ignore */
|
|
16
|
+
constructor() { }
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the RecordKit SDK.
|
|
19
|
+
*
|
|
20
|
+
* ⚠️ Must be called before calling any other RecordKit method.
|
|
21
|
+
*
|
|
22
|
+
* @param args
|
|
23
|
+
*/
|
|
6
24
|
async initialize(args) {
|
|
7
25
|
let rpcBinaryPath = args.rpcBinaryPath;
|
|
8
|
-
if (args.fallbackToNodeModules) {
|
|
26
|
+
if (args.fallbackToNodeModules ?? true) {
|
|
9
27
|
if (!existsSync(rpcBinaryPath)) {
|
|
10
28
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');
|
|
11
29
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
@@ -13,33 +31,63 @@ export class RecordKit {
|
|
|
13
31
|
}
|
|
14
32
|
return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
|
|
15
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* @group Discovery
|
|
36
|
+
*/
|
|
16
37
|
async getWindows() {
|
|
17
38
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });
|
|
18
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @group Discovery
|
|
42
|
+
*/
|
|
19
43
|
async getCameras() {
|
|
20
44
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });
|
|
21
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @group Discovery
|
|
48
|
+
*/
|
|
22
49
|
async getMicrophones() {
|
|
23
50
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });
|
|
24
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @group Discovery
|
|
54
|
+
*/
|
|
25
55
|
async getAppleDevices() {
|
|
26
56
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });
|
|
27
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @group Permissions
|
|
60
|
+
*/
|
|
28
61
|
async getCameraAuthorizationStatus() {
|
|
29
62
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
30
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* @group Permissions
|
|
66
|
+
*/
|
|
31
67
|
async getMicrophoneAuthorizationStatus() {
|
|
32
68
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });
|
|
33
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @group Permissions
|
|
72
|
+
*/
|
|
34
73
|
async getScreenRecordingAccess() {
|
|
35
74
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });
|
|
36
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @group Permissions
|
|
78
|
+
*/
|
|
37
79
|
async requestCameraAccess() {
|
|
38
80
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });
|
|
39
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* @group Permissions
|
|
84
|
+
*/
|
|
40
85
|
async requestMicrophoneAccess() {
|
|
41
86
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });
|
|
42
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* @group Permissions
|
|
90
|
+
*/
|
|
43
91
|
async requestScreenRecordingAccess() {
|
|
44
92
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });
|
|
45
93
|
}
|
|
@@ -47,5 +95,6 @@ export class RecordKit {
|
|
|
47
95
|
return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);
|
|
48
96
|
}
|
|
49
97
|
}
|
|
98
|
+
/** @ignore */
|
|
50
99
|
export let recordkit = new RecordKit();
|
|
51
100
|
//# sourceMappingURL=RecordKit.js.map
|
package/out/RecordKit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordKit.js","sourceRoot":"","sources":["../src/RecordKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAA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B,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAY,CAAA;IAC7H,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,4BAA4B;QAChC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAS,CAAA;IAC/H,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAsB;QACzC,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACF;AAED,cAAc;AACd,MAAM,CAAC,IAAI,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
package/out/Recorder.d.ts
CHANGED
|
@@ -3,17 +3,43 @@
|
|
|
3
3
|
import { NSRPC } from "./NonstrictRPC.js";
|
|
4
4
|
import { EventEmitter } from "stream";
|
|
5
5
|
import { AppleDevice, Camera, Microphone, Window } from "./RecordKit.js";
|
|
6
|
+
/**
|
|
7
|
+
* @group Recording
|
|
8
|
+
*/
|
|
9
|
+
export declare class Recorder extends EventEmitter {
|
|
10
|
+
private readonly rpc;
|
|
11
|
+
private readonly target;
|
|
12
|
+
/** @ignore */
|
|
13
|
+
static newInstance(rpc: NSRPC, schema: RecorderSchema): Promise<Recorder>;
|
|
14
|
+
/** @ignore */
|
|
15
|
+
constructor(rpc: NSRPC, target: string);
|
|
16
|
+
prepare(): Promise<void>;
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
stop(): Promise<RecordingResult>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @group Recording
|
|
22
|
+
*/
|
|
6
23
|
export interface RecorderSchema {
|
|
7
24
|
output_directory?: string;
|
|
8
25
|
items: RecorderSchemaItem[];
|
|
9
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @group Recording
|
|
29
|
+
*/
|
|
10
30
|
export type RecorderSchemaItem = WebcamSchema | WindowBasedCropSchema | iPhonePortraitSchema;
|
|
31
|
+
/**
|
|
32
|
+
* @group Recording Schemas
|
|
33
|
+
*/
|
|
11
34
|
export interface WebcamSchema {
|
|
12
35
|
type: 'webcam';
|
|
13
36
|
filename?: string;
|
|
14
37
|
camera: Camera | string;
|
|
15
38
|
microphone: Microphone | string;
|
|
16
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @group Recording Schemas
|
|
42
|
+
*/
|
|
17
43
|
export interface WindowBasedCropSchema {
|
|
18
44
|
type: 'windowBasedCrop';
|
|
19
45
|
filename?: string;
|
|
@@ -21,11 +47,17 @@ export interface WindowBasedCropSchema {
|
|
|
21
47
|
shows_cursor?: boolean;
|
|
22
48
|
mouse_events?: boolean;
|
|
23
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @group Recording Schemas
|
|
52
|
+
*/
|
|
24
53
|
export interface iPhonePortraitSchema {
|
|
25
54
|
type: 'iPhonePortrait';
|
|
26
55
|
filename?: string;
|
|
27
56
|
device: AppleDevice | string;
|
|
28
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* @group Recording
|
|
60
|
+
*/
|
|
29
61
|
export type AbortReason = {
|
|
30
62
|
reason: 'userStopped';
|
|
31
63
|
result: RecordingResult;
|
|
@@ -37,6 +69,9 @@ export type AbortReason = {
|
|
|
37
69
|
reason: 'failed';
|
|
38
70
|
error: RecordKitError;
|
|
39
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* @group Recording
|
|
74
|
+
*/
|
|
40
75
|
export interface RecordingResult {
|
|
41
76
|
url: string;
|
|
42
77
|
info: BundleInfo;
|
|
@@ -46,6 +81,9 @@ export interface RecordKitError {
|
|
|
46
81
|
error_group: string;
|
|
47
82
|
debug_description: string;
|
|
48
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* @group Recording
|
|
86
|
+
*/
|
|
49
87
|
export interface BundleInfo {
|
|
50
88
|
version: 1;
|
|
51
89
|
files: {
|
|
@@ -53,12 +91,3 @@ export interface BundleInfo {
|
|
|
53
91
|
filename: string;
|
|
54
92
|
}[];
|
|
55
93
|
}
|
|
56
|
-
export declare class Recorder extends EventEmitter {
|
|
57
|
-
private readonly rpc;
|
|
58
|
-
private readonly target;
|
|
59
|
-
static newInstance(rpc: NSRPC, schema: RecorderSchema): Promise<Recorder>;
|
|
60
|
-
constructor(rpc: NSRPC, target: string);
|
|
61
|
-
prepare(): Promise<void>;
|
|
62
|
-
start(): Promise<void>;
|
|
63
|
-
stop(): Promise<RecordingResult>;
|
|
64
|
-
}
|
package/out/Recorder.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
2
|
import { EventEmitter } from "stream";
|
|
3
|
+
/**
|
|
4
|
+
* @group Recording
|
|
5
|
+
*/
|
|
3
6
|
export class Recorder extends EventEmitter {
|
|
4
7
|
rpc;
|
|
5
8
|
target;
|
|
9
|
+
/** @ignore */
|
|
6
10
|
static async newInstance(rpc, schema) {
|
|
7
11
|
const target = 'Recorder_' + randomUUID();
|
|
8
12
|
const object = new Recorder(rpc, target);
|
|
@@ -40,6 +44,7 @@ export class Recorder extends EventEmitter {
|
|
|
40
44
|
});
|
|
41
45
|
return object;
|
|
42
46
|
}
|
|
47
|
+
/** @ignore */
|
|
43
48
|
constructor(rpc, target) {
|
|
44
49
|
super();
|
|
45
50
|
this.rpc = rpc;
|
package/out/Recorder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Recorder.js","sourceRoot":"","sources":["../src/Recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Recorder.js","sourceRoot":"","sources":["../src/Recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,OAAO,EAAE,YAAY,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**
|
|
235
|
+
* @group Recording
|
|
236
|
+
*/
|
|
234
237
|
class Recorder extends stream.EventEmitter {
|
|
235
238
|
rpc;
|
|
236
239
|
target;
|
|
240
|
+
/** @ignore */
|
|
237
241
|
static async newInstance(rpc, schema) {
|
|
238
242
|
const target = 'Recorder_' + crypto.randomUUID();
|
|
239
243
|
const object = new Recorder(rpc, target);
|
|
@@ -271,6 +275,7 @@ class Recorder extends stream.EventEmitter {
|
|
|
271
275
|
});
|
|
272
276
|
return object;
|
|
273
277
|
}
|
|
278
|
+
/** @ignore */
|
|
274
279
|
constructor(rpc, target) {
|
|
275
280
|
super();
|
|
276
281
|
this.rpc = rpc;
|
|
@@ -287,11 +292,29 @@ class Recorder extends stream.EventEmitter {
|
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Entry point for the RecordKit SDK, an instance is available as `recordkit` that can be imported from the module. Do not instantiate this class directly.
|
|
297
|
+
*
|
|
298
|
+
* @groupDescription Discovery
|
|
299
|
+
* Discover the windows and devices that are available to record.
|
|
300
|
+
*
|
|
301
|
+
* @groupDescription Permissions
|
|
302
|
+
* Check and request the apps permission to access the recording devices.
|
|
303
|
+
*/
|
|
290
304
|
class RecordKit {
|
|
291
305
|
ipcRecordKit = new IpcRecordKit();
|
|
306
|
+
/** @ignore */
|
|
307
|
+
constructor() { }
|
|
308
|
+
/**
|
|
309
|
+
* Initialize the RecordKit SDK.
|
|
310
|
+
*
|
|
311
|
+
* ⚠️ Must be called before calling any other RecordKit method.
|
|
312
|
+
*
|
|
313
|
+
* @param args
|
|
314
|
+
*/
|
|
292
315
|
async initialize(args) {
|
|
293
316
|
let rpcBinaryPath = args.rpcBinaryPath;
|
|
294
|
-
if (args.fallbackToNodeModules) {
|
|
317
|
+
if (args.fallbackToNodeModules ?? true) {
|
|
295
318
|
if (!node_fs.existsSync(rpcBinaryPath)) {
|
|
296
319
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');
|
|
297
320
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
@@ -299,33 +322,63 @@ class RecordKit {
|
|
|
299
322
|
}
|
|
300
323
|
return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
|
|
301
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* @group Discovery
|
|
327
|
+
*/
|
|
302
328
|
async getWindows() {
|
|
303
329
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });
|
|
304
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* @group Discovery
|
|
333
|
+
*/
|
|
305
334
|
async getCameras() {
|
|
306
335
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });
|
|
307
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* @group Discovery
|
|
339
|
+
*/
|
|
308
340
|
async getMicrophones() {
|
|
309
341
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });
|
|
310
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* @group Discovery
|
|
345
|
+
*/
|
|
311
346
|
async getAppleDevices() {
|
|
312
347
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });
|
|
313
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* @group Permissions
|
|
351
|
+
*/
|
|
314
352
|
async getCameraAuthorizationStatus() {
|
|
315
353
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
316
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* @group Permissions
|
|
357
|
+
*/
|
|
317
358
|
async getMicrophoneAuthorizationStatus() {
|
|
318
359
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });
|
|
319
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* @group Permissions
|
|
363
|
+
*/
|
|
320
364
|
async getScreenRecordingAccess() {
|
|
321
365
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });
|
|
322
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* @group Permissions
|
|
369
|
+
*/
|
|
323
370
|
async requestCameraAccess() {
|
|
324
371
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });
|
|
325
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* @group Permissions
|
|
375
|
+
*/
|
|
326
376
|
async requestMicrophoneAccess() {
|
|
327
377
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });
|
|
328
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* @group Permissions
|
|
381
|
+
*/
|
|
329
382
|
async requestScreenRecordingAccess() {
|
|
330
383
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });
|
|
331
384
|
}
|
|
@@ -333,6 +386,7 @@ class RecordKit {
|
|
|
333
386
|
return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);
|
|
334
387
|
}
|
|
335
388
|
}
|
|
389
|
+
/** @ignore */
|
|
336
390
|
let recordkit = new RecordKit();
|
|
337
391
|
|
|
338
392
|
exports.recordkit = recordkit;
|
package/out/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["finalizationRegistry.js","NonstrictRPC.js","IpcRecordKit.js","Recorder.js","RecordKit.js"],"sourcesContent":["export const finalizationRegistry = new FinalizationRegistry(async (destructor) => { await destructor(); });\n//# sourceMappingURL=finalizationRegistry.js.map","import { randomUUID } from \"crypto\";\nimport { finalizationRegistry } from \"./finalizationRegistry.js\";\nexport class NSRPC {\n logMessages = false;\n send;\n responseHandlers = new Map();\n closureTargets = new Map();\n constructor(send) {\n this.send = send;\n }\n receive(data) {\n // TODO: For now we just assume the message is a valid NSRPC message, but we should:\n // - Check if the nsrpc property is set to a number in the range of 1..<2\n // - Validate the message against the defined interfaces above\n let message;\n try {\n if (this.logMessages) {\n console.log(\"< \", data.trimEnd());\n }\n message = JSON.parse(data);\n }\n catch (error) {\n if (this.logMessages) {\n console.log(\"!! Above message is invalid JSON, will be ignored.\");\n }\n return;\n }\n if (\"status\" in message) {\n // This is a response, dispatch it so it can be handled\n const responseHandler = this.responseHandlers.get(message.id);\n this.responseHandlers.delete(message.id);\n if (responseHandler === undefined) {\n // TODO: Got a response for a request we don't know about, log this\n return;\n }\n if (\"error\" in message) {\n responseHandler.reject(message.error);\n }\n else {\n responseHandler.resolve(message.result);\n }\n }\n else {\n // This is a request\n const responseBody = this.handleRequest(message);\n if (responseBody !== undefined) {\n this.sendResponse(message.id, responseBody);\n }\n }\n }\n /* Sending helpers */\n sendMessage(message) {\n const stringMessage = JSON.stringify(message);\n if (this.logMessages) {\n console.log(\"> \", stringMessage);\n }\n this.send(stringMessage);\n }\n sendResponse(id, response) {\n if (id === undefined) {\n return;\n }\n this.sendMessage({ ...response, nsrpc: 1, id });\n }\n async sendRequest(request) {\n const id = \"req_\" + randomUUID();\n const response = new Promise((resolve, reject) => {\n this.responseHandlers.set(id, { resolve, reject });\n });\n this.sendMessage({ ...request, nsrpc: 1, id });\n return response;\n }\n /* Request handling */\n handleRequest(request) {\n switch (request.procedure) {\n case \"init\":\n return {\n status: 501,\n error: {\n debugDescription: \"Init procedure not implemented.\",\n userMessage: \"Failed to communicate with external process. (Procedure not implemented)\",\n },\n };\n case \"perform\":\n if (\"action\" in request) {\n return {\n status: 501,\n error: {\n debugDescription: \"Perform procedure for (static) methods not implemented.\",\n userMessage: \"Failed to communicate with external process. (Procedure not implemented)\",\n },\n };\n }\n else {\n return this.handleClosureRequest(request);\n }\n case \"release\":\n return {\n status: 501,\n error: {\n debugDescription: \"Release procedure not implemented.\",\n userMessage: \"Failed to communicate with external process. (Procedure not implemented)\",\n },\n };\n }\n }\n handleClosureRequest(request) {\n const handler = this.closureTargets.get(request.target);\n if (handler === undefined) {\n return {\n status: 404,\n error: {\n debugDescription: `Perform target '${request.target}' not found.`,\n userMessage: \"Failed to communicate with external process. (Target not found)\",\n },\n };\n }\n try {\n const rawresult = handler(request.params ?? {});\n const result = rawresult === undefined ? undefined : rawresult;\n return {\n status: 200,\n result,\n };\n }\n catch (error) {\n return {\n status: 202,\n // TODO: Would be good to have an error type that we can throw that fills these fields more specifically. (But for now it doesn't matter since this is just communicated back the the CLI and not to the user.)\n error: {\n debugDescription: `${error}`,\n userMessage: \"Handler failed to perform request.\",\n underlyingError: error,\n },\n };\n }\n }\n /* Perform remote procedures */\n async initialize(args) {\n const target = args.target;\n finalizationRegistry.register(args.lifecycle, async () => {\n await this.release(target);\n });\n await this.sendRequest({\n target: args.target,\n type: args.type,\n params: args.params,\n procedure: \"init\",\n });\n }\n async perform(body) {\n return await this.sendRequest({\n ...body,\n procedure: \"perform\",\n });\n }\n async release(target) {\n await this.sendRequest({\n procedure: \"release\",\n target,\n });\n }\n /* Register locally available targets/actions */\n registerClosure(options) {\n const target = `target_${options.prefix}_${randomUUID()}`;\n this.closureTargets.set(target, options.handler);\n finalizationRegistry.register(options.lifecycle, () => {\n this.closureTargets.delete(target);\n });\n return target;\n }\n}\n//# sourceMappingURL=NonstrictRPC.js.map","import { spawn } from 'node:child_process';\nimport * as readline from 'readline';\nimport { NSRPC } from \"./NonstrictRPC.js\";\nexport class IpcRecordKit {\n childProcess;\n nsrpc;\n constructor() {\n this.nsrpc = new NSRPC((message) => this.write(message));\n }\n async initialize(recordKitRpcPath, logMessages = false) {\n if (this.childProcess !== undefined) {\n throw new Error('RecordKit RPC: Already initialized.');\n }\n this.nsrpc.logMessages = logMessages;\n this.childProcess = await new Promise((resolve, reject) => {\n const childProcess = spawn(recordKitRpcPath);\n childProcess.on('spawn', () => { resolve(childProcess); });\n childProcess.on('error', (error) => { reject(error); });\n });\n const { stdout } = this.childProcess;\n if (!stdout) {\n throw new Error('RecordKit RPC: No stdout stream on child process.');\n }\n readline.createInterface({ input: stdout }).on('line', (line) => {\n this.nsrpc.receive(line);\n });\n }\n write(message) {\n const stdin = this.childProcess?.stdin;\n if (!stdin) {\n throw new Error('RecordKit RPC: Missing stdin stream.');\n }\n stdin.write(message + \"\\n\");\n }\n}\n//# sourceMappingURL=IpcRecordKit.js.map","import { randomUUID } from \"crypto\";\nimport { EventEmitter } from \"stream\";\nexport class Recorder extends EventEmitter {\n rpc;\n target;\n static async newInstance(rpc, schema) {\n const target = 'Recorder_' + randomUUID();\n const object = new Recorder(rpc, target);\n schema.items.forEach(item => {\n if (item.type == 'webcam') {\n if (typeof item.camera != 'string') {\n item.camera = item.camera.id;\n }\n if (typeof item.microphone != 'string') {\n item.microphone = item.microphone.id;\n }\n }\n if (item.type == 'windowBasedCrop') {\n if (typeof item.window != 'number') {\n item.window = item.window.id;\n }\n }\n if (item.type == 'iPhonePortrait') {\n if (typeof item.device != 'string') {\n item.device = item.device.id;\n }\n }\n });\n const weakRefObject = new WeakRef(object);\n const onAbortInstance = rpc.registerClosure({\n handler: (params) => { weakRefObject.deref()?.emit('abort', params.reason); },\n prefix: 'Recorder.onAbort',\n lifecycle: object\n });\n await rpc.initialize({\n target,\n type: 'Recorder',\n params: { schema, onAbortInstance },\n lifecycle: object\n });\n return object;\n }\n constructor(rpc, target) {\n super();\n this.rpc = rpc;\n this.target = target;\n }\n async prepare() {\n await this.rpc.perform({ target: this.target, action: 'prepare' });\n }\n async start() {\n await this.rpc.perform({ target: this.target, action: 'start' });\n }\n async stop() {\n return await this.rpc.perform({ target: this.target, action: 'stop' });\n }\n}\n//# sourceMappingURL=Recorder.js.map","import { IpcRecordKit } from \"./IpcRecordKit.js\";\nimport { Recorder } from \"./Recorder.js\";\nimport { existsSync } from \"node:fs\";\nexport class RecordKit {\n ipcRecordKit = new IpcRecordKit();\n async initialize(args) {\n let rpcBinaryPath = args.rpcBinaryPath;\n if (args.fallbackToNodeModules) {\n if (!existsSync(rpcBinaryPath)) {\n console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');\n rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');\n }\n }\n return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);\n }\n async getWindows() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });\n }\n async getCameras() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });\n }\n async getMicrophones() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });\n }\n async getAppleDevices() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });\n }\n async getCameraAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });\n }\n async getMicrophoneAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });\n }\n async getScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });\n }\n async requestCameraAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });\n }\n async requestMicrophoneAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });\n }\n async requestScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });\n }\n async createRecorder(schema) {\n return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);\n }\n}\nexport let recordkit = new RecordKit();\n//# sourceMappingURL=RecordKit.js.map"],"names":["randomUUID","spawn","readline","EventEmitter","existsSync"],"m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AC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAC,CAAC;AAC9H,KAAK;AACL,IAAI,MAAM,cAAc,CAAC,MAAM,EAAE;AACjC,QAAQ,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACrE,KAAK;AACL,CAAC;AACS,IAAC,SAAS,GAAG,IAAI,SAAS;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["finalizationRegistry.js","NonstrictRPC.js","IpcRecordKit.js","Recorder.js","RecordKit.js"],"sourcesContent":["export const finalizationRegistry = new FinalizationRegistry(async (destructor) => { await destructor(); });\n//# sourceMappingURL=finalizationRegistry.js.map","import { randomUUID } from \"crypto\";\nimport { finalizationRegistry } from \"./finalizationRegistry.js\";\nexport class NSRPC {\n logMessages = false;\n send;\n responseHandlers = new Map();\n closureTargets = new Map();\n constructor(send) {\n this.send = send;\n }\n receive(data) {\n // TODO: For now we just assume the message is a valid NSRPC message, but we should:\n // - Check if the nsrpc property is set to a number in the range of 1..<2\n // - Validate the message against the defined interfaces above\n let message;\n try {\n if (this.logMessages) {\n console.log(\"< \", data.trimEnd());\n }\n message = JSON.parse(data);\n }\n catch (error) {\n if (this.logMessages) {\n console.log(\"!! Above message is invalid JSON, will be ignored.\");\n }\n return;\n }\n if (\"status\" in message) {\n // This is a response, dispatch it so it can be handled\n const responseHandler = this.responseHandlers.get(message.id);\n this.responseHandlers.delete(message.id);\n if (responseHandler === undefined) {\n // TODO: Got a response for a request we don't know about, log this\n return;\n }\n if (\"error\" in message) {\n responseHandler.reject(message.error);\n }\n else {\n responseHandler.resolve(message.result);\n }\n }\n else {\n // This is a request\n const responseBody = this.handleRequest(message);\n if (responseBody !== undefined) {\n this.sendResponse(message.id, responseBody);\n }\n }\n }\n /* Sending helpers */\n sendMessage(message) {\n const stringMessage = JSON.stringify(message);\n if (this.logMessages) {\n console.log(\"> \", stringMessage);\n }\n this.send(stringMessage);\n }\n sendResponse(id, response) {\n if (id === undefined) {\n return;\n }\n this.sendMessage({ ...response, nsrpc: 1, id });\n }\n async sendRequest(request) {\n const id = \"req_\" + randomUUID();\n const response = new Promise((resolve, reject) => {\n this.responseHandlers.set(id, { resolve, reject });\n });\n this.sendMessage({ ...request, nsrpc: 1, id });\n return response;\n }\n /* Request handling */\n handleRequest(request) {\n switch (request.procedure) {\n case \"init\":\n return {\n status: 501,\n error: {\n debugDescription: \"Init procedure not implemented.\",\n userMessage: \"Failed to communicate with external process. (Procedure not implemented)\",\n },\n };\n case \"perform\":\n if (\"action\" in request) {\n return {\n status: 501,\n error: {\n debugDescription: \"Perform procedure for (static) methods not implemented.\",\n userMessage: \"Failed to communicate with external process. (Procedure not implemented)\",\n },\n };\n }\n else {\n return this.handleClosureRequest(request);\n }\n case \"release\":\n return {\n status: 501,\n error: {\n debugDescription: \"Release procedure not implemented.\",\n userMessage: \"Failed to communicate with external process. (Procedure not implemented)\",\n },\n };\n }\n }\n handleClosureRequest(request) {\n const handler = this.closureTargets.get(request.target);\n if (handler === undefined) {\n return {\n status: 404,\n error: {\n debugDescription: `Perform target '${request.target}' not found.`,\n userMessage: \"Failed to communicate with external process. (Target not found)\",\n },\n };\n }\n try {\n const rawresult = handler(request.params ?? {});\n const result = rawresult === undefined ? undefined : rawresult;\n return {\n status: 200,\n result,\n };\n }\n catch (error) {\n return {\n status: 202,\n // TODO: Would be good to have an error type that we can throw that fills these fields more specifically. (But for now it doesn't matter since this is just communicated back the the CLI and not to the user.)\n error: {\n debugDescription: `${error}`,\n userMessage: \"Handler failed to perform request.\",\n underlyingError: error,\n },\n };\n }\n }\n /* Perform remote procedures */\n async initialize(args) {\n const target = args.target;\n finalizationRegistry.register(args.lifecycle, async () => {\n await this.release(target);\n });\n await this.sendRequest({\n target: args.target,\n type: args.type,\n params: args.params,\n procedure: \"init\",\n });\n }\n async perform(body) {\n return await this.sendRequest({\n ...body,\n procedure: \"perform\",\n });\n }\n async release(target) {\n await this.sendRequest({\n procedure: \"release\",\n target,\n });\n }\n /* Register locally available targets/actions */\n registerClosure(options) {\n const target = `target_${options.prefix}_${randomUUID()}`;\n this.closureTargets.set(target, options.handler);\n finalizationRegistry.register(options.lifecycle, () => {\n this.closureTargets.delete(target);\n });\n return target;\n }\n}\n//# sourceMappingURL=NonstrictRPC.js.map","import { spawn } from 'node:child_process';\nimport * as readline from 'readline';\nimport { NSRPC } from \"./NonstrictRPC.js\";\nexport class IpcRecordKit {\n childProcess;\n nsrpc;\n constructor() {\n this.nsrpc = new NSRPC((message) => this.write(message));\n }\n async initialize(recordKitRpcPath, logMessages = false) {\n if (this.childProcess !== undefined) {\n throw new Error('RecordKit RPC: Already initialized.');\n }\n this.nsrpc.logMessages = logMessages;\n this.childProcess = await new Promise((resolve, reject) => {\n const childProcess = spawn(recordKitRpcPath);\n childProcess.on('spawn', () => { resolve(childProcess); });\n childProcess.on('error', (error) => { reject(error); });\n });\n const { stdout } = this.childProcess;\n if (!stdout) {\n throw new Error('RecordKit RPC: No stdout stream on child process.');\n }\n readline.createInterface({ input: stdout }).on('line', (line) => {\n this.nsrpc.receive(line);\n });\n }\n write(message) {\n const stdin = this.childProcess?.stdin;\n if (!stdin) {\n throw new Error('RecordKit RPC: Missing stdin stream.');\n }\n stdin.write(message + \"\\n\");\n }\n}\n//# sourceMappingURL=IpcRecordKit.js.map","import { randomUUID } from \"crypto\";\nimport { EventEmitter } from \"stream\";\n/**\n * @group Recording\n */\nexport class Recorder extends EventEmitter {\n rpc;\n target;\n /** @ignore */\n static async newInstance(rpc, schema) {\n const target = 'Recorder_' + randomUUID();\n const object = new Recorder(rpc, target);\n schema.items.forEach(item => {\n if (item.type == 'webcam') {\n if (typeof item.camera != 'string') {\n item.camera = item.camera.id;\n }\n if (typeof item.microphone != 'string') {\n item.microphone = item.microphone.id;\n }\n }\n if (item.type == 'windowBasedCrop') {\n if (typeof item.window != 'number') {\n item.window = item.window.id;\n }\n }\n if (item.type == 'iPhonePortrait') {\n if (typeof item.device != 'string') {\n item.device = item.device.id;\n }\n }\n });\n const weakRefObject = new WeakRef(object);\n const onAbortInstance = rpc.registerClosure({\n handler: (params) => { weakRefObject.deref()?.emit('abort', params.reason); },\n prefix: 'Recorder.onAbort',\n lifecycle: object\n });\n await rpc.initialize({\n target,\n type: 'Recorder',\n params: { schema, onAbortInstance },\n lifecycle: object\n });\n return object;\n }\n /** @ignore */\n constructor(rpc, target) {\n super();\n this.rpc = rpc;\n this.target = target;\n }\n async prepare() {\n await this.rpc.perform({ target: this.target, action: 'prepare' });\n }\n async start() {\n await this.rpc.perform({ target: this.target, action: 'start' });\n }\n async stop() {\n return await this.rpc.perform({ target: this.target, action: 'stop' });\n }\n}\n//# sourceMappingURL=Recorder.js.map","import { IpcRecordKit } from \"./IpcRecordKit.js\";\nimport { Recorder } from \"./Recorder.js\";\nimport { existsSync } from \"node:fs\";\n/**\n * Entry point for the RecordKit SDK, an instance is available as `recordkit` that can be imported from the module. Do not instantiate this class directly.\n *\n * @groupDescription Discovery\n * Discover the windows and devices that are available to record.\n *\n * @groupDescription Permissions\n * Check and request the apps permission to access the recording devices.\n */\nexport class RecordKit {\n ipcRecordKit = new IpcRecordKit();\n /** @ignore */\n constructor() { }\n /**\n * Initialize the RecordKit SDK.\n *\n * ⚠️ Must be called before calling any other RecordKit method.\n *\n * @param args\n */\n async initialize(args) {\n let rpcBinaryPath = args.rpcBinaryPath;\n if (args.fallbackToNodeModules ?? true) {\n if (!existsSync(rpcBinaryPath)) {\n console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');\n rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');\n }\n }\n return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);\n }\n /**\n * @group Discovery\n */\n async getWindows() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });\n }\n /**\n * @group Discovery\n */\n async getCameras() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });\n }\n /**\n * @group Discovery\n */\n async getMicrophones() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });\n }\n /**\n * @group Discovery\n */\n async getAppleDevices() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });\n }\n /**\n * @group Permissions\n */\n async getCameraAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });\n }\n /**\n * @group Permissions\n */\n async getMicrophoneAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });\n }\n /**\n * @group Permissions\n */\n async getScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });\n }\n /**\n * @group Permissions\n */\n async requestCameraAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });\n }\n /**\n * @group Permissions\n */\n async requestMicrophoneAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });\n }\n /**\n * @group Permissions\n */\n async requestScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });\n }\n async createRecorder(schema) {\n return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);\n }\n}\n/** @ignore */\nexport let recordkit = new RecordKit();\n//# sourceMappingURL=RecordKit.js.map"],"names":["randomUUID","spawn","readline","EventEmitter","existsSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,OAAO,UAAU,KAAK,EAAE,MAAM,UA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C,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC,CAAC;AACzH,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,4BAA4B,GAAG;AACzC,QAAQ,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAC,CAAC;AAC9H,KAAK;AACL,IAAI,MAAM,cAAc,CAAC,MAAM,EAAE;AACjC,QAAQ,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACrE,KAAK;AACL,CAAC;AACD;AACU,IAAC,SAAS,GAAG,IAAI,SAAS;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nonstrict/recordkit",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.2-alpha.7",
|
|
4
|
+
"description": "Powerful screen recording for your Electron app on macOS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "out/index.js",
|
|
7
7
|
"types": "out/index.d.ts",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "jest",
|
|
17
|
-
"build": "rm -rf out && tsc && rollup -c"
|
|
18
|
-
"prepublish": "npm run build"
|
|
17
|
+
"build": "rm -rf out && tsc && rollup -c"
|
|
19
18
|
},
|
|
20
19
|
"keywords": [
|
|
21
20
|
"recording",
|
package/src/RecordKit.ts
CHANGED
|
@@ -1,58 +1,43 @@
|
|
|
1
1
|
import { IpcRecordKit } from "./IpcRecordKit.js";
|
|
2
|
-
import { Recorder, RecorderSchema
|
|
2
|
+
import { Recorder, RecorderSchema } from "./Recorder.js";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
frame: Bounds
|
|
15
|
-
level: number // Int
|
|
16
|
-
application_process_id?: number // Int32
|
|
17
|
-
application_name?: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface Camera {
|
|
21
|
-
id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
model_id: string;
|
|
24
|
-
manufacturer: string;
|
|
25
|
-
availability: 'available' | 'lidClosed' | 'unknownSuspended'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface Microphone {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
model_id: string;
|
|
32
|
-
manufacturer: string;
|
|
33
|
-
availability: 'available' | 'lidClosed' | 'unknownSuspended'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface AppleDevice {
|
|
37
|
-
id: string;
|
|
38
|
-
name: string;
|
|
39
|
-
model_id?: string;
|
|
40
|
-
availability: 'available'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface Bounds {
|
|
44
|
-
x: number;
|
|
45
|
-
y: number;
|
|
46
|
-
width: number;
|
|
47
|
-
height: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Entry point for the RecordKit SDK, an instance is available as `recordkit` that can be imported from the module. Do not instantiate this class directly.
|
|
7
|
+
*
|
|
8
|
+
* @groupDescription Discovery
|
|
9
|
+
* Discover the windows and devices that are available to record.
|
|
10
|
+
*
|
|
11
|
+
* @groupDescription Permissions
|
|
12
|
+
* Check and request the apps permission to access the recording devices.
|
|
13
|
+
*/
|
|
50
14
|
export class RecordKit {
|
|
51
15
|
private ipcRecordKit = new IpcRecordKit()
|
|
52
16
|
|
|
53
|
-
|
|
17
|
+
/** @ignore */
|
|
18
|
+
constructor() { }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the RecordKit SDK.
|
|
22
|
+
*
|
|
23
|
+
* ⚠️ Must be called before calling any other RecordKit method.
|
|
24
|
+
*
|
|
25
|
+
* @param args
|
|
26
|
+
*/
|
|
27
|
+
async initialize(args: {
|
|
28
|
+
/**
|
|
29
|
+
* Path to the `recordkit-rpc` binary, most of the time this should be set to `path.join(process.resourcesPath, 'recordkit-rpc')`.
|
|
30
|
+
*/
|
|
31
|
+
rpcBinaryPath: string,
|
|
32
|
+
/**
|
|
33
|
+
* Whether to fallback to the RPC binary from `node_modules` if the given path does not exist. When enabled an extra check to see if the given path exists is performed. Most of the time this should be set to `!app.isPackaged`.
|
|
34
|
+
*/
|
|
35
|
+
fallbackToNodeModules?: boolean,
|
|
36
|
+
/** @ignore */
|
|
37
|
+
logRpcMessages?: boolean
|
|
38
|
+
}): Promise<void> {
|
|
54
39
|
let rpcBinaryPath = args.rpcBinaryPath
|
|
55
|
-
if (args.fallbackToNodeModules) {
|
|
40
|
+
if (args.fallbackToNodeModules ?? true) {
|
|
56
41
|
if (!existsSync(rpcBinaryPath)) {
|
|
57
42
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.')
|
|
58
43
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin')
|
|
@@ -62,42 +47,72 @@ export class RecordKit {
|
|
|
62
47
|
return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages)
|
|
63
48
|
}
|
|
64
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @group Discovery
|
|
52
|
+
*/
|
|
65
53
|
async getWindows(): Promise<Window[]> {
|
|
66
54
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' }) as Window[]
|
|
67
55
|
}
|
|
68
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @group Discovery
|
|
59
|
+
*/
|
|
69
60
|
async getCameras(): Promise<Camera[]> {
|
|
70
61
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' }) as Camera[]
|
|
71
62
|
}
|
|
72
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @group Discovery
|
|
66
|
+
*/
|
|
73
67
|
async getMicrophones(): Promise<Microphone[]> {
|
|
74
68
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' }) as Microphone[]
|
|
75
69
|
}
|
|
76
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @group Discovery
|
|
73
|
+
*/
|
|
77
74
|
async getAppleDevices(): Promise<AppleDevice[]> {
|
|
78
75
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' }) as AppleDevice[]
|
|
79
76
|
}
|
|
80
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @group Permissions
|
|
80
|
+
*/
|
|
81
81
|
async getCameraAuthorizationStatus(): Promise<AuthorizationStatus> {
|
|
82
82
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' }) as AuthorizationStatus
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @group Permissions
|
|
87
|
+
*/
|
|
85
88
|
async getMicrophoneAuthorizationStatus(): Promise<AuthorizationStatus> {
|
|
86
89
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' }) as AuthorizationStatus
|
|
87
90
|
}
|
|
88
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @group Permissions
|
|
94
|
+
*/
|
|
89
95
|
async getScreenRecordingAccess(): Promise<boolean> {
|
|
90
96
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' }) as boolean
|
|
91
97
|
}
|
|
92
98
|
|
|
99
|
+
/**
|
|
100
|
+
* @group Permissions
|
|
101
|
+
*/
|
|
93
102
|
async requestCameraAccess(): Promise<boolean> {
|
|
94
103
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' }) as boolean
|
|
95
104
|
}
|
|
96
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @group Permissions
|
|
108
|
+
*/
|
|
97
109
|
async requestMicrophoneAccess(): Promise<boolean> {
|
|
98
110
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' }) as boolean
|
|
99
111
|
}
|
|
100
112
|
|
|
113
|
+
/**
|
|
114
|
+
* @group Permissions
|
|
115
|
+
*/
|
|
101
116
|
async requestScreenRecordingAccess(): Promise<void> {
|
|
102
117
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' }) as void
|
|
103
118
|
}
|
|
@@ -107,4 +122,76 @@ export class RecordKit {
|
|
|
107
122
|
}
|
|
108
123
|
}
|
|
109
124
|
|
|
110
|
-
|
|
125
|
+
/** @ignore */
|
|
126
|
+
export let recordkit = new RecordKit();
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @group Permissions
|
|
130
|
+
*
|
|
131
|
+
* @remarks
|
|
132
|
+
* Describes the apps permission to access a recording device.
|
|
133
|
+
*
|
|
134
|
+
* - `notDetermined` The user has not yet made a choice.
|
|
135
|
+
* - `restricted` The user cannot change the client's status, possibly due to active restrictions such as parental controls being in place.
|
|
136
|
+
* - `denied` The user explicitly denied access to the hardware supporting a media type for the client.
|
|
137
|
+
* - `authorized` Application is authorized to access the hardware.
|
|
138
|
+
*/
|
|
139
|
+
export type AuthorizationStatus =
|
|
140
|
+
| 'notDetermined' // The user has not yet made a choice.
|
|
141
|
+
| 'restricted' // The user cannot change the client's status, possibly due to active restrictions such as parental controls being in place.
|
|
142
|
+
| 'denied' // The user explicitly denied access to the hardware supporting a media type for the client.
|
|
143
|
+
| 'authorized' // Application is authorized to access the hardware.
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @group Discovery
|
|
147
|
+
*/
|
|
148
|
+
export interface AppleDevice {
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
model_id?: string;
|
|
152
|
+
availability: 'available'
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @group Discovery
|
|
157
|
+
*/
|
|
158
|
+
export interface Camera {
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
model_id: string;
|
|
162
|
+
manufacturer: string;
|
|
163
|
+
availability: 'available' | 'lidClosed' | 'unknownSuspended'
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @group Discovery
|
|
168
|
+
*/
|
|
169
|
+
export interface Microphone {
|
|
170
|
+
id: string;
|
|
171
|
+
name: string;
|
|
172
|
+
model_id: string;
|
|
173
|
+
manufacturer: string;
|
|
174
|
+
availability: 'available' | 'lidClosed' | 'unknownSuspended'
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @group Discovery
|
|
179
|
+
*/
|
|
180
|
+
export interface Window {
|
|
181
|
+
id: number; // UInt32
|
|
182
|
+
title?: string;
|
|
183
|
+
frame: Bounds
|
|
184
|
+
level: number // Int
|
|
185
|
+
application_process_id?: number // Int32
|
|
186
|
+
application_name?: string
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @group Utilities
|
|
191
|
+
*/
|
|
192
|
+
export interface Bounds {
|
|
193
|
+
x: number;
|
|
194
|
+
y: number;
|
|
195
|
+
width: number;
|
|
196
|
+
height: number;
|
|
197
|
+
}
|
package/src/Recorder.ts
CHANGED
|
@@ -4,65 +4,14 @@ import { NSRPC } from "./NonstrictRPC.js";
|
|
|
4
4
|
import { EventEmitter } from "stream";
|
|
5
5
|
import { AppleDevice, Camera, Microphone, Window } from "./RecordKit.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type RecorderSchemaItem =
|
|
13
|
-
| WebcamSchema
|
|
14
|
-
| WindowBasedCropSchema
|
|
15
|
-
| iPhonePortraitSchema
|
|
16
|
-
|
|
17
|
-
export interface WebcamSchema {
|
|
18
|
-
type: 'webcam'
|
|
19
|
-
filename?: string
|
|
20
|
-
camera: Camera | string
|
|
21
|
-
microphone: Microphone | string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface WindowBasedCropSchema {
|
|
25
|
-
type: 'windowBasedCrop'
|
|
26
|
-
filename?: string
|
|
27
|
-
window: Window | number // UInt32
|
|
28
|
-
shows_cursor?: boolean
|
|
29
|
-
mouse_events?: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface iPhonePortraitSchema {
|
|
33
|
-
type: 'iPhonePortrait'
|
|
34
|
-
filename?: string
|
|
35
|
-
device: AppleDevice | string
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type AbortReason =
|
|
39
|
-
| { reason: 'userStopped'; result: RecordingResult; }
|
|
40
|
-
| { reason: 'interrupted'; result: RecordingResult; error: RecordKitError; }
|
|
41
|
-
| { reason: 'failed'; error: RecordKitError; }
|
|
42
|
-
|
|
43
|
-
export interface RecordingResult {
|
|
44
|
-
url: string
|
|
45
|
-
info: BundleInfo
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface RecordKitError {
|
|
49
|
-
message?: string // Message describing the problem and possible recovery options, intended to be shown directly to the end-user.
|
|
50
|
-
error_group: string // Generic title, used for grouping related errors
|
|
51
|
-
debug_description: string // Detailed technical description of this error, used in debugging
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface BundleInfo {
|
|
55
|
-
version: 1,
|
|
56
|
-
files: {
|
|
57
|
-
type: 'screen' | 'webcam' | 'mouse' | 'appleDevice'
|
|
58
|
-
filename: string
|
|
59
|
-
}[]
|
|
60
|
-
}
|
|
61
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @group Recording
|
|
9
|
+
*/
|
|
62
10
|
export class Recorder extends EventEmitter {
|
|
63
11
|
private readonly rpc: NSRPC;
|
|
64
12
|
private readonly target: string;
|
|
65
13
|
|
|
14
|
+
/** @ignore */
|
|
66
15
|
static async newInstance(rpc: NSRPC, schema: RecorderSchema): Promise<Recorder> {
|
|
67
16
|
const target = 'Recorder_' + randomUUID();
|
|
68
17
|
const object = new Recorder(rpc, target);
|
|
@@ -105,6 +54,7 @@ export class Recorder extends EventEmitter {
|
|
|
105
54
|
return object
|
|
106
55
|
}
|
|
107
56
|
|
|
57
|
+
/** @ignore */
|
|
108
58
|
constructor(rpc: NSRPC, target: string) {
|
|
109
59
|
super();
|
|
110
60
|
this.rpc = rpc;
|
|
@@ -123,3 +73,82 @@ export class Recorder extends EventEmitter {
|
|
|
123
73
|
return await this.rpc.perform({ target: this.target, action: 'stop' }) as RecordingResult;
|
|
124
74
|
}
|
|
125
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @group Recording
|
|
79
|
+
*/
|
|
80
|
+
export interface RecorderSchema {
|
|
81
|
+
output_directory?: string
|
|
82
|
+
items: RecorderSchemaItem[]
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @group Recording
|
|
87
|
+
*/
|
|
88
|
+
export type RecorderSchemaItem =
|
|
89
|
+
| WebcamSchema
|
|
90
|
+
| WindowBasedCropSchema
|
|
91
|
+
| iPhonePortraitSchema
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @group Recording Schemas
|
|
95
|
+
*/
|
|
96
|
+
export interface WebcamSchema {
|
|
97
|
+
type: 'webcam'
|
|
98
|
+
filename?: string
|
|
99
|
+
camera: Camera | string
|
|
100
|
+
microphone: Microphone | string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @group Recording Schemas
|
|
105
|
+
*/
|
|
106
|
+
export interface WindowBasedCropSchema {
|
|
107
|
+
type: 'windowBasedCrop'
|
|
108
|
+
filename?: string
|
|
109
|
+
window: Window | number // UInt32
|
|
110
|
+
shows_cursor?: boolean
|
|
111
|
+
mouse_events?: boolean
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @group Recording Schemas
|
|
116
|
+
*/
|
|
117
|
+
export interface iPhonePortraitSchema {
|
|
118
|
+
type: 'iPhonePortrait'
|
|
119
|
+
filename?: string
|
|
120
|
+
device: AppleDevice | string
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @group Recording
|
|
125
|
+
*/
|
|
126
|
+
export type AbortReason =
|
|
127
|
+
| { reason: 'userStopped'; result: RecordingResult; }
|
|
128
|
+
| { reason: 'interrupted'; result: RecordingResult; error: RecordKitError; }
|
|
129
|
+
| { reason: 'failed'; error: RecordKitError; }
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @group Recording
|
|
133
|
+
*/
|
|
134
|
+
export interface RecordingResult {
|
|
135
|
+
url: string
|
|
136
|
+
info: BundleInfo
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface RecordKitError {
|
|
140
|
+
message?: string // Message describing the problem and possible recovery options, intended to be shown directly to the end-user.
|
|
141
|
+
error_group: string // Generic title, used for grouping related errors
|
|
142
|
+
debug_description: string // Detailed technical description of this error, used in debugging
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @group Recording
|
|
147
|
+
*/
|
|
148
|
+
export interface BundleInfo {
|
|
149
|
+
version: 1,
|
|
150
|
+
files: {
|
|
151
|
+
type: 'screen' | 'webcam' | 'mouse' | 'appleDevice'
|
|
152
|
+
filename: string
|
|
153
|
+
}[]
|
|
154
|
+
}
|
package/typedoc.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"entryPoints": [
|
|
3
|
+
"src/index.ts"
|
|
4
|
+
],
|
|
5
|
+
"navigationLinks": {
|
|
6
|
+
"Back to the Homepage": "http://nonstrict.eu/recordkit"
|
|
7
|
+
},
|
|
8
|
+
"excludeExternals": true,
|
|
9
|
+
"excludePrivate": true,
|
|
10
|
+
"excludeProtected": true,
|
|
11
|
+
"sort": [
|
|
12
|
+
"source-order",
|
|
13
|
+
"kind",
|
|
14
|
+
"instance-first",
|
|
15
|
+
"alphabetical"
|
|
16
|
+
],
|
|
17
|
+
"sortEntryPoints": false,
|
|
6
18
|
}
|