@nonstrict/recordkit 0.3.0-alpha.2 → 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 +116 -28
- package/out/RecordKit.js +53 -1
- package/out/RecordKit.js.map +1 -1
- package/out/Recorder.d.ts +46 -12
- package/out/Recorder.js +10 -0
- package/out/Recorder.js.map +1 -1
- package/out/index.cjs +63 -1
- package/out/index.cjs.map +1 -1
- package/package.json +3 -4
- package/src/RecordKit.ts +140 -42
- package/src/Recorder.ts +90 -49
- 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,29 +116,23 @@ export interface Microphone {
|
|
|
22
116
|
manufacturer: string;
|
|
23
117
|
availability: 'available' | 'lidClosed' | 'unknownSuspended';
|
|
24
118
|
}
|
|
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;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @group Utilities
|
|
132
|
+
*/
|
|
25
133
|
export interface Bounds {
|
|
26
134
|
x: number;
|
|
27
135
|
y: number;
|
|
28
136
|
width: number;
|
|
29
137
|
height: number;
|
|
30
138
|
}
|
|
31
|
-
export declare class RecordKit {
|
|
32
|
-
private ipcRecordKit;
|
|
33
|
-
initialize(args: {
|
|
34
|
-
rpcBinaryPath: string;
|
|
35
|
-
fallbackToNodeModules: boolean;
|
|
36
|
-
logRpcMessages?: boolean;
|
|
37
|
-
}): Promise<void>;
|
|
38
|
-
getWindows(): Promise<Window[]>;
|
|
39
|
-
getCameras(): Promise<Camera[]>;
|
|
40
|
-
getMicrophones(): Promise<Microphone[]>;
|
|
41
|
-
getCameraAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
42
|
-
getMicrophoneAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
43
|
-
getScreenRecordingAccess(): Promise<boolean>;
|
|
44
|
-
requestCameraAccess(): Promise<boolean>;
|
|
45
|
-
requestMicrophoneAccess(): Promise<boolean>;
|
|
46
|
-
requestScreenRecordingAccess(): Promise<void>;
|
|
47
|
-
createRecorder(schema: RecorderSchema): Promise<Recorder>;
|
|
48
|
-
}
|
|
49
|
-
export declare let recordkit: RecordKit;
|
|
50
|
-
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,30 +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
|
+
*/
|
|
55
|
+
async getAppleDevices() {
|
|
56
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @group Permissions
|
|
60
|
+
*/
|
|
25
61
|
async getCameraAuthorizationStatus() {
|
|
26
62
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
27
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* @group Permissions
|
|
66
|
+
*/
|
|
28
67
|
async getMicrophoneAuthorizationStatus() {
|
|
29
68
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });
|
|
30
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @group Permissions
|
|
72
|
+
*/
|
|
31
73
|
async getScreenRecordingAccess() {
|
|
32
74
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });
|
|
33
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @group Permissions
|
|
78
|
+
*/
|
|
34
79
|
async requestCameraAccess() {
|
|
35
80
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });
|
|
36
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* @group Permissions
|
|
84
|
+
*/
|
|
37
85
|
async requestMicrophoneAccess() {
|
|
38
86
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });
|
|
39
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* @group Permissions
|
|
90
|
+
*/
|
|
40
91
|
async requestScreenRecordingAccess() {
|
|
41
92
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });
|
|
42
93
|
}
|
|
@@ -44,5 +95,6 @@ export class RecordKit {
|
|
|
44
95
|
return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);
|
|
45
96
|
}
|
|
46
97
|
}
|
|
98
|
+
/** @ignore */
|
|
47
99
|
export let recordkit = new RecordKit();
|
|
48
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,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"RecordKit.js","sourceRoot":"","sources":["../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4B;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
|
@@ -2,18 +2,44 @@
|
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { NSRPC } from "./NonstrictRPC.js";
|
|
4
4
|
import { EventEmitter } from "stream";
|
|
5
|
-
import { Camera, Microphone, Window } from "./RecordKit.js";
|
|
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
|
}
|
|
10
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @group Recording
|
|
29
|
+
*/
|
|
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,6 +47,17 @@ export interface WindowBasedCropSchema {
|
|
|
21
47
|
shows_cursor?: boolean;
|
|
22
48
|
mouse_events?: boolean;
|
|
23
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @group Recording Schemas
|
|
52
|
+
*/
|
|
53
|
+
export interface iPhonePortraitSchema {
|
|
54
|
+
type: 'iPhonePortrait';
|
|
55
|
+
filename?: string;
|
|
56
|
+
device: AppleDevice | string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @group Recording
|
|
60
|
+
*/
|
|
24
61
|
export type AbortReason = {
|
|
25
62
|
reason: 'userStopped';
|
|
26
63
|
result: RecordingResult;
|
|
@@ -32,6 +69,9 @@ export type AbortReason = {
|
|
|
32
69
|
reason: 'failed';
|
|
33
70
|
error: RecordKitError;
|
|
34
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* @group Recording
|
|
74
|
+
*/
|
|
35
75
|
export interface RecordingResult {
|
|
36
76
|
url: string;
|
|
37
77
|
info: BundleInfo;
|
|
@@ -41,19 +81,13 @@ export interface RecordKitError {
|
|
|
41
81
|
error_group: string;
|
|
42
82
|
debug_description: string;
|
|
43
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* @group Recording
|
|
86
|
+
*/
|
|
44
87
|
export interface BundleInfo {
|
|
45
88
|
version: 1;
|
|
46
89
|
files: {
|
|
47
|
-
type: 'screen' | 'webcam' | 'mouse';
|
|
90
|
+
type: 'screen' | 'webcam' | 'mouse' | 'appleDevice';
|
|
48
91
|
filename: string;
|
|
49
92
|
}[];
|
|
50
93
|
}
|
|
51
|
-
export declare class Recorder extends EventEmitter {
|
|
52
|
-
private readonly rpc;
|
|
53
|
-
private readonly target;
|
|
54
|
-
static newInstance(rpc: NSRPC, schema: RecorderSchema): Promise<Recorder>;
|
|
55
|
-
constructor(rpc: NSRPC, target: string);
|
|
56
|
-
prepare(): Promise<void>;
|
|
57
|
-
start(): Promise<void>;
|
|
58
|
-
stop(): Promise<RecordingResult>;
|
|
59
|
-
}
|
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);
|
|
@@ -20,6 +24,11 @@ export class Recorder extends EventEmitter {
|
|
|
20
24
|
item.window = item.window.id;
|
|
21
25
|
}
|
|
22
26
|
}
|
|
27
|
+
if (item.type == 'iPhonePortrait') {
|
|
28
|
+
if (typeof item.device != 'string') {
|
|
29
|
+
item.device = item.device.id;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
23
32
|
});
|
|
24
33
|
const weakRefObject = new WeakRef(object);
|
|
25
34
|
const onAbortInstance = rpc.registerClosure({
|
|
@@ -35,6 +44,7 @@ export class Recorder extends EventEmitter {
|
|
|
35
44
|
});
|
|
36
45
|
return object;
|
|
37
46
|
}
|
|
47
|
+
/** @ignore */
|
|
38
48
|
constructor(rpc, target) {
|
|
39
49
|
super();
|
|
40
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,EAAE,MAAM,QAAQ,CAAC;AAGtC;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IACvB,GAAG,CAAQ;IACX,MAAM,CAAS;IAEhC,cAAc;IACd,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAU,EAAE,MAAsB;QACzD,MAAM,MAAM,GAAG,WAAW,GAAG,UAAU,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAEzC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC1B,IAAI,IAAI,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;gBAC1B,IAAI,OAAO,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;oBACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAA;gBAC9B,CAAC;gBACD,IAAI,OAAO,IAAI,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;oBACvC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAA;gBACtC,CAAC;YACH,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,IAAI,iBAAiB,EAAE,CAAC;gBACnC,IAAI,OAAO,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;oBACnC,IAAI,CAAC,MAAM,GAAG,IA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,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAoB,CAAC;IAC5F,CAAC;CACF"}
|
package/out/index.cjs
CHANGED
|
@@ -231,9 +231,13 @@ class IpcRecordKit {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
/**
|
|
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);
|
|
@@ -251,6 +255,11 @@ class Recorder extends stream.EventEmitter {
|
|
|
251
255
|
item.window = item.window.id;
|
|
252
256
|
}
|
|
253
257
|
}
|
|
258
|
+
if (item.type == 'iPhonePortrait') {
|
|
259
|
+
if (typeof item.device != 'string') {
|
|
260
|
+
item.device = item.device.id;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
254
263
|
});
|
|
255
264
|
const weakRefObject = new WeakRef(object);
|
|
256
265
|
const onAbortInstance = rpc.registerClosure({
|
|
@@ -266,6 +275,7 @@ class Recorder extends stream.EventEmitter {
|
|
|
266
275
|
});
|
|
267
276
|
return object;
|
|
268
277
|
}
|
|
278
|
+
/** @ignore */
|
|
269
279
|
constructor(rpc, target) {
|
|
270
280
|
super();
|
|
271
281
|
this.rpc = rpc;
|
|
@@ -282,11 +292,29 @@ class Recorder extends stream.EventEmitter {
|
|
|
282
292
|
}
|
|
283
293
|
}
|
|
284
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
|
+
*/
|
|
285
304
|
class RecordKit {
|
|
286
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
|
+
*/
|
|
287
315
|
async initialize(args) {
|
|
288
316
|
let rpcBinaryPath = args.rpcBinaryPath;
|
|
289
|
-
if (args.fallbackToNodeModules) {
|
|
317
|
+
if (args.fallbackToNodeModules ?? true) {
|
|
290
318
|
if (!node_fs.existsSync(rpcBinaryPath)) {
|
|
291
319
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');
|
|
292
320
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
@@ -294,30 +322,63 @@ class RecordKit {
|
|
|
294
322
|
}
|
|
295
323
|
return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
|
|
296
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* @group Discovery
|
|
327
|
+
*/
|
|
297
328
|
async getWindows() {
|
|
298
329
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });
|
|
299
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* @group Discovery
|
|
333
|
+
*/
|
|
300
334
|
async getCameras() {
|
|
301
335
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });
|
|
302
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* @group Discovery
|
|
339
|
+
*/
|
|
303
340
|
async getMicrophones() {
|
|
304
341
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });
|
|
305
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* @group Discovery
|
|
345
|
+
*/
|
|
346
|
+
async getAppleDevices() {
|
|
347
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* @group Permissions
|
|
351
|
+
*/
|
|
306
352
|
async getCameraAuthorizationStatus() {
|
|
307
353
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
308
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* @group Permissions
|
|
357
|
+
*/
|
|
309
358
|
async getMicrophoneAuthorizationStatus() {
|
|
310
359
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });
|
|
311
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* @group Permissions
|
|
363
|
+
*/
|
|
312
364
|
async getScreenRecordingAccess() {
|
|
313
365
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });
|
|
314
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* @group Permissions
|
|
369
|
+
*/
|
|
315
370
|
async requestCameraAccess() {
|
|
316
371
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });
|
|
317
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* @group Permissions
|
|
375
|
+
*/
|
|
318
376
|
async requestMicrophoneAccess() {
|
|
319
377
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });
|
|
320
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* @group Permissions
|
|
381
|
+
*/
|
|
321
382
|
async requestScreenRecordingAccess() {
|
|
322
383
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });
|
|
323
384
|
}
|
|
@@ -325,6 +386,7 @@ class RecordKit {
|
|
|
325
386
|
return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);
|
|
326
387
|
}
|
|
327
388
|
}
|
|
389
|
+
/** @ignore */
|
|
328
390
|
let recordkit = new RecordKit();
|
|
329
391
|
|
|
330
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 });\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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,OAAO,UAAU,KAAK,EAAE,MAAM,UAAU,EAAE,CAAC,EAAE,CAAC;;ACEpG,MAAM,KAAK,CAAC;AACnB,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,IAAI,CAAC;AACT,IAAI,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;AACjC,IAAI,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;AAC/B,IAAI,WAAW,CAAC,IAAI,EAAE;AACtB,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACzB,KAAK;AACL,IAAI,OAAO,CAAC,IAAI,EAAE;AAClB;AACA;AACA;AACA,QAAQ,IAAI,OAAO,CAAC;AACpB,QAAQ,IAAI;AACZ,YAAY,IAAI,IAAI,CAAC,WAAW,EAAE;AAClC,gBAAgB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAClD,aAAa;AACb,YAAY,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IA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B,EAAE,CAAC,CAAC;AACzH,KAAK;AACL,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;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":";;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A;AACA;AACA,IAAI,MAAM,uBAAuB,GAAG;AACpC,QAAQ,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,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,51 +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 Bounds {
|
|
37
|
-
x: number;
|
|
38
|
-
y: number;
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
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
|
+
*/
|
|
43
14
|
export class RecordKit {
|
|
44
15
|
private ipcRecordKit = new IpcRecordKit()
|
|
45
16
|
|
|
46
|
-
|
|
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> {
|
|
47
39
|
let rpcBinaryPath = args.rpcBinaryPath
|
|
48
|
-
if (args.fallbackToNodeModules) {
|
|
40
|
+
if (args.fallbackToNodeModules ?? true) {
|
|
49
41
|
if (!existsSync(rpcBinaryPath)) {
|
|
50
42
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.')
|
|
51
43
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin')
|
|
@@ -55,38 +47,72 @@ export class RecordKit {
|
|
|
55
47
|
return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages)
|
|
56
48
|
}
|
|
57
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @group Discovery
|
|
52
|
+
*/
|
|
58
53
|
async getWindows(): Promise<Window[]> {
|
|
59
54
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' }) as Window[]
|
|
60
55
|
}
|
|
61
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @group Discovery
|
|
59
|
+
*/
|
|
62
60
|
async getCameras(): Promise<Camera[]> {
|
|
63
61
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' }) as Camera[]
|
|
64
62
|
}
|
|
65
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @group Discovery
|
|
66
|
+
*/
|
|
66
67
|
async getMicrophones(): Promise<Microphone[]> {
|
|
67
68
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' }) as Microphone[]
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @group Discovery
|
|
73
|
+
*/
|
|
74
|
+
async getAppleDevices(): Promise<AppleDevice[]> {
|
|
75
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' }) as AppleDevice[]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @group Permissions
|
|
80
|
+
*/
|
|
70
81
|
async getCameraAuthorizationStatus(): Promise<AuthorizationStatus> {
|
|
71
82
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' }) as AuthorizationStatus
|
|
72
83
|
}
|
|
73
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @group Permissions
|
|
87
|
+
*/
|
|
74
88
|
async getMicrophoneAuthorizationStatus(): Promise<AuthorizationStatus> {
|
|
75
89
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' }) as AuthorizationStatus
|
|
76
90
|
}
|
|
77
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @group Permissions
|
|
94
|
+
*/
|
|
78
95
|
async getScreenRecordingAccess(): Promise<boolean> {
|
|
79
96
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' }) as boolean
|
|
80
97
|
}
|
|
81
98
|
|
|
99
|
+
/**
|
|
100
|
+
* @group Permissions
|
|
101
|
+
*/
|
|
82
102
|
async requestCameraAccess(): Promise<boolean> {
|
|
83
103
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' }) as boolean
|
|
84
104
|
}
|
|
85
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @group Permissions
|
|
108
|
+
*/
|
|
86
109
|
async requestMicrophoneAccess(): Promise<boolean> {
|
|
87
110
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' }) as boolean
|
|
88
111
|
}
|
|
89
112
|
|
|
113
|
+
/**
|
|
114
|
+
* @group Permissions
|
|
115
|
+
*/
|
|
90
116
|
async requestScreenRecordingAccess(): Promise<void> {
|
|
91
117
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' }) as void
|
|
92
118
|
}
|
|
@@ -96,4 +122,76 @@ export class RecordKit {
|
|
|
96
122
|
}
|
|
97
123
|
}
|
|
98
124
|
|
|
99
|
-
|
|
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
|
@@ -2,60 +2,16 @@ import { randomUUID } from "crypto";
|
|
|
2
2
|
import { finalizationRegistry } from "./finalizationRegistry.js";
|
|
3
3
|
import { NSRPC } from "./NonstrictRPC.js";
|
|
4
4
|
import { EventEmitter } from "stream";
|
|
5
|
-
import { Camera, Microphone, Window } from "./RecordKit.js";
|
|
6
|
-
|
|
7
|
-
export interface RecorderSchema {
|
|
8
|
-
output_directory?: string
|
|
9
|
-
items: RecorderSchemaItem[]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type RecorderSchemaItem =
|
|
13
|
-
| WebcamSchema
|
|
14
|
-
| WindowBasedCropSchema
|
|
15
|
-
|
|
16
|
-
export interface WebcamSchema {
|
|
17
|
-
type: 'webcam'
|
|
18
|
-
filename?: string
|
|
19
|
-
camera: Camera | string
|
|
20
|
-
microphone: Microphone | string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface WindowBasedCropSchema {
|
|
24
|
-
type: 'windowBasedCrop'
|
|
25
|
-
filename?: string
|
|
26
|
-
window: Window | number // UInt32
|
|
27
|
-
shows_cursor?: boolean
|
|
28
|
-
mouse_events?: boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type AbortReason =
|
|
32
|
-
| { reason: 'userStopped'; result: RecordingResult; }
|
|
33
|
-
| { reason: 'interrupted'; result: RecordingResult; error: RecordKitError; }
|
|
34
|
-
| { reason: 'failed'; error: RecordKitError; }
|
|
35
|
-
|
|
36
|
-
export interface RecordingResult {
|
|
37
|
-
url: string
|
|
38
|
-
info: BundleInfo
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface RecordKitError {
|
|
42
|
-
message?: string // Message describing the problem and possible recovery options, intended to be shown directly to the end-user.
|
|
43
|
-
error_group: string // Generic title, used for grouping related errors
|
|
44
|
-
debug_description: string // Detailed technical description of this error, used in debugging
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface BundleInfo {
|
|
48
|
-
version: 1,
|
|
49
|
-
files: {
|
|
50
|
-
type: 'screen' | 'webcam' | 'mouse'
|
|
51
|
-
filename: string
|
|
52
|
-
}[]
|
|
53
|
-
}
|
|
5
|
+
import { AppleDevice, Camera, Microphone, Window } from "./RecordKit.js";
|
|
54
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @group Recording
|
|
9
|
+
*/
|
|
55
10
|
export class Recorder extends EventEmitter {
|
|
56
11
|
private readonly rpc: NSRPC;
|
|
57
12
|
private readonly target: string;
|
|
58
13
|
|
|
14
|
+
/** @ignore */
|
|
59
15
|
static async newInstance(rpc: NSRPC, schema: RecorderSchema): Promise<Recorder> {
|
|
60
16
|
const target = 'Recorder_' + randomUUID();
|
|
61
17
|
const object = new Recorder(rpc, target);
|
|
@@ -74,6 +30,11 @@ export class Recorder extends EventEmitter {
|
|
|
74
30
|
item.window = item.window.id
|
|
75
31
|
}
|
|
76
32
|
}
|
|
33
|
+
if (item.type == 'iPhonePortrait') {
|
|
34
|
+
if (typeof item.device != 'string') {
|
|
35
|
+
item.device = item.device.id
|
|
36
|
+
}
|
|
37
|
+
}
|
|
77
38
|
})
|
|
78
39
|
|
|
79
40
|
const weakRefObject = new WeakRef(object);
|
|
@@ -93,6 +54,7 @@ export class Recorder extends EventEmitter {
|
|
|
93
54
|
return object
|
|
94
55
|
}
|
|
95
56
|
|
|
57
|
+
/** @ignore */
|
|
96
58
|
constructor(rpc: NSRPC, target: string) {
|
|
97
59
|
super();
|
|
98
60
|
this.rpc = rpc;
|
|
@@ -111,3 +73,82 @@ export class Recorder extends EventEmitter {
|
|
|
111
73
|
return await this.rpc.perform({ target: this.target, action: 'stop' }) as RecordingResult;
|
|
112
74
|
}
|
|
113
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
|
}
|