@nonstrict/recordkit 0.3.0-alpha.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/recordkit-rpc +0 -0
- package/out/IpcRecordKit.d.ts +0 -1
- package/out/IpcRecordKit.js +1 -8
- package/out/IpcRecordKit.js.map +1 -1
- package/out/NonstrictRPC.d.ts +1 -0
- package/out/NonstrictRPC.js +19 -3
- package/out/NonstrictRPC.js.map +1 -1
- package/out/RecordKit.d.ts +7 -0
- package/out/RecordKit.js +4 -1
- package/out/RecordKit.js.map +1 -1
- package/out/Recorder.d.ts +8 -3
- package/out/Recorder.js +5 -0
- package/out/Recorder.js.map +1 -1
- package/out/index.cjs +29 -12
- package/out/index.cjs.map +1 -1
- package/package.json +2 -2
- package/src/IpcRecordKit.ts +30 -40
- package/src/NonstrictRPC.ts +19 -3
- package/src/RecordKit.ts +12 -1
- package/src/Recorder.ts +14 -2
package/bin/recordkit-rpc
CHANGED
|
Binary file
|
package/out/IpcRecordKit.d.ts
CHANGED
package/out/IpcRecordKit.js
CHANGED
|
@@ -2,7 +2,6 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import * as readline from 'readline';
|
|
3
3
|
import { NSRPC } from "./NonstrictRPC.js";
|
|
4
4
|
export class IpcRecordKit {
|
|
5
|
-
logMessages = false;
|
|
6
5
|
childProcess;
|
|
7
6
|
nsrpc;
|
|
8
7
|
constructor() {
|
|
@@ -12,7 +11,7 @@ export class IpcRecordKit {
|
|
|
12
11
|
if (this.childProcess !== undefined) {
|
|
13
12
|
throw new Error('RecordKit RPC: Already initialized.');
|
|
14
13
|
}
|
|
15
|
-
this.logMessages = logMessages;
|
|
14
|
+
this.nsrpc.logMessages = logMessages;
|
|
16
15
|
this.childProcess = await new Promise((resolve, reject) => {
|
|
17
16
|
const childProcess = spawn(recordKitRpcPath);
|
|
18
17
|
childProcess.on('spawn', () => { resolve(childProcess); });
|
|
@@ -23,9 +22,6 @@ export class IpcRecordKit {
|
|
|
23
22
|
throw new Error('RecordKit RPC: No stdout stream on child process.');
|
|
24
23
|
}
|
|
25
24
|
readline.createInterface({ input: stdout }).on('line', (line) => {
|
|
26
|
-
if (logMessages) {
|
|
27
|
-
console.log("< ", line.trimEnd());
|
|
28
|
-
}
|
|
29
25
|
this.nsrpc.receive(line);
|
|
30
26
|
});
|
|
31
27
|
}
|
|
@@ -34,9 +30,6 @@ export class IpcRecordKit {
|
|
|
34
30
|
if (!stdin) {
|
|
35
31
|
throw new Error('RecordKit RPC: Missing stdin stream.');
|
|
36
32
|
}
|
|
37
|
-
if (this.logMessages) {
|
|
38
|
-
console.log("> ", message);
|
|
39
|
-
}
|
|
40
33
|
stdin.write(message + "\n");
|
|
41
34
|
}
|
|
42
35
|
}
|
package/out/IpcRecordKit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IpcRecordKit.js","sourceRoot":"","sources":["../src/IpcRecordKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"IpcRecordKit.js","sourceRoot":"","sources":["../src/IpcRecordKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,MAAM,OAAO,YAAY;IACf,YAAY,CAAgB;IAC3B,KAAK,CAAQ;IAEtB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3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AK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAC7B,CAAC;CACF"}
|
package/out/NonstrictRPC.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface NSRPCPerformClosureRequest {
|
|
|
7
7
|
}
|
|
8
8
|
type ClosureTarget = (params: Record<string, unknown>) => Record<string, unknown> | void;
|
|
9
9
|
export declare class NSRPC {
|
|
10
|
+
logMessages: boolean;
|
|
10
11
|
private readonly send;
|
|
11
12
|
private responseHandlers;
|
|
12
13
|
private closureTargets;
|
package/out/NonstrictRPC.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
2
|
import { finalizationRegistry } from "./finalizationRegistry.js";
|
|
3
3
|
export class NSRPC {
|
|
4
|
+
logMessages = false;
|
|
4
5
|
send;
|
|
5
6
|
responseHandlers = new Map();
|
|
6
7
|
closureTargets = new Map();
|
|
@@ -9,10 +10,21 @@ export class NSRPC {
|
|
|
9
10
|
}
|
|
10
11
|
receive(data) {
|
|
11
12
|
// TODO: For now we just assume the message is a valid NSRPC message, but we should:
|
|
12
|
-
// - Handle invalid JSON comming in
|
|
13
13
|
// - Check if the nsrpc property is set to a number in the range of 1..<2
|
|
14
14
|
// - Validate the message against the defined interfaces above
|
|
15
|
-
|
|
15
|
+
let message;
|
|
16
|
+
try {
|
|
17
|
+
if (this.logMessages) {
|
|
18
|
+
console.log("< ", data.trimEnd());
|
|
19
|
+
}
|
|
20
|
+
message = JSON.parse(data);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (this.logMessages) {
|
|
24
|
+
console.log("!! Above message is invalid JSON, will be ignored.");
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
16
28
|
if ("status" in message) {
|
|
17
29
|
// This is a response, dispatch it so it can be handled
|
|
18
30
|
const responseHandler = this.responseHandlers.get(message.id);
|
|
@@ -38,7 +50,11 @@ export class NSRPC {
|
|
|
38
50
|
}
|
|
39
51
|
/* Sending helpers */
|
|
40
52
|
sendMessage(message) {
|
|
41
|
-
|
|
53
|
+
const stringMessage = JSON.stringify(message);
|
|
54
|
+
if (this.logMessages) {
|
|
55
|
+
console.log("> ", stringMessage);
|
|
56
|
+
}
|
|
57
|
+
this.send(stringMessage);
|
|
42
58
|
}
|
|
43
59
|
sendResponse(id, response) {
|
|
44
60
|
if (id === undefined) {
|
package/out/NonstrictRPC.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonstrictRPC.js","sourceRoot":"","sources":["../src/NonstrictRPC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AA+GjE,MAAM,OAAO,KAAK;
|
|
1
|
+
{"version":3,"file":"NonstrictRPC.js","sourceRoot":"","sources":["../src/NonstrictRPC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AA+GjE,MAAM,OAAO,KAAK;IAChB,WAAW,GAAG,KAAK,CAAC;IACH,IAAI,CAAyB;IAEtC,gBAAgB,GAA+B,IAAI,GAAG,EAAE,CAAC;IACzD,cAAc,GAA+B,IAAI,GAAG,EAAE,CAAC;IAE/D,YAAY,IAA4B;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,oFAAoF;QACpF,yEAAyE;QACzE,8DAA8D;QAC9D,IAAI,OAAqB,CAAA;QACzB,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YACpC,CAAC;YACD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAiB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,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,MAAM;SAClB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAKb;QACC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC;YAC5B,GAAG,IAAI;YACP,SAAS,EAAE,SAAS;SACd,CAAC,CAAC;IACZ,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,MAAc;QAClC,MAAM,IAAI,CAAC,WAAW,CAAC;YACrB,SAAS,EAAE,SAAS;YACpB,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,gDAAgD;IAEhD,eAAe,CAAC,OAIf;QACC,MAAM,MAAM,GAAG,UAAU,OAAO,CAAC,MAAM,IAAI,UAAU,EAAE,EAAE,CAAC;QAC1D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAEjD,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE;YACpD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
package/out/RecordKit.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface Microphone {
|
|
|
22
22
|
manufacturer: string;
|
|
23
23
|
availability: 'available' | 'lidClosed' | 'unknownSuspended';
|
|
24
24
|
}
|
|
25
|
+
export interface AppleDevice {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
model_id?: string;
|
|
29
|
+
availability: 'available';
|
|
30
|
+
}
|
|
25
31
|
export interface Bounds {
|
|
26
32
|
x: number;
|
|
27
33
|
y: number;
|
|
@@ -38,6 +44,7 @@ export declare class RecordKit {
|
|
|
38
44
|
getWindows(): Promise<Window[]>;
|
|
39
45
|
getCameras(): Promise<Camera[]>;
|
|
40
46
|
getMicrophones(): Promise<Microphone[]>;
|
|
47
|
+
getAppleDevices(): Promise<AppleDevice[]>;
|
|
41
48
|
getCameraAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
42
49
|
getMicrophoneAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
43
50
|
getScreenRecordingAccess(): Promise<boolean>;
|
package/out/RecordKit.js
CHANGED
|
@@ -5,7 +5,7 @@ export class RecordKit {
|
|
|
5
5
|
ipcRecordKit = new IpcRecordKit();
|
|
6
6
|
async initialize(args) {
|
|
7
7
|
let rpcBinaryPath = args.rpcBinaryPath;
|
|
8
|
-
if (
|
|
8
|
+
if (args.fallbackToNodeModules) {
|
|
9
9
|
if (!existsSync(rpcBinaryPath)) {
|
|
10
10
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');
|
|
11
11
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
@@ -22,6 +22,9 @@ export class RecordKit {
|
|
|
22
22
|
async getMicrophones() {
|
|
23
23
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });
|
|
24
24
|
}
|
|
25
|
+
async getAppleDevices() {
|
|
26
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });
|
|
27
|
+
}
|
|
25
28
|
async getCameraAuthorizationStatus() {
|
|
26
29
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
27
30
|
}
|
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,EAA+B,MAAM,eAAe,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AAqB,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,MAAM,CAAC,IAAI,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
package/out/Recorder.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
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
6
|
export interface RecorderSchema {
|
|
7
7
|
output_directory?: string;
|
|
8
8
|
items: RecorderSchemaItem[];
|
|
9
9
|
}
|
|
10
|
-
export type RecorderSchemaItem = WebcamSchema | WindowBasedCropSchema;
|
|
10
|
+
export type RecorderSchemaItem = WebcamSchema | WindowBasedCropSchema | iPhonePortraitSchema;
|
|
11
11
|
export interface WebcamSchema {
|
|
12
12
|
type: 'webcam';
|
|
13
13
|
filename?: string;
|
|
@@ -21,6 +21,11 @@ export interface WindowBasedCropSchema {
|
|
|
21
21
|
shows_cursor?: boolean;
|
|
22
22
|
mouse_events?: boolean;
|
|
23
23
|
}
|
|
24
|
+
export interface iPhonePortraitSchema {
|
|
25
|
+
type: 'iPhonePortrait';
|
|
26
|
+
filename?: string;
|
|
27
|
+
device: AppleDevice | string;
|
|
28
|
+
}
|
|
24
29
|
export type AbortReason = {
|
|
25
30
|
reason: 'userStopped';
|
|
26
31
|
result: RecordingResult;
|
|
@@ -44,7 +49,7 @@ export interface RecordKitError {
|
|
|
44
49
|
export interface BundleInfo {
|
|
45
50
|
version: 1;
|
|
46
51
|
files: {
|
|
47
|
-
type: 'screen' | 'webcam' | 'mouse';
|
|
52
|
+
type: 'screen' | 'webcam' | 'mouse' | 'appleDevice';
|
|
48
53
|
filename: string;
|
|
49
54
|
}[];
|
|
50
55
|
}
|
package/out/Recorder.js
CHANGED
|
@@ -20,6 +20,11 @@ export class Recorder extends EventEmitter {
|
|
|
20
20
|
item.window = item.window.id;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
if (item.type == 'iPhonePortrait') {
|
|
24
|
+
if (typeof item.device != 'string') {
|
|
25
|
+
item.device = item.device.id;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
23
28
|
});
|
|
24
29
|
const weakRefObject = new WeakRef(object);
|
|
25
30
|
const onAbortInstance = rpc.registerClosure({
|
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;AA0DtC,MAAM,OAAO,QAAS,SAAQ,YAAY;IACvB,GAAG,CAAQ;IACX,MAAM,CAAS;IAEhC,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;gB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H,OAAO,MAAM,CAAA;IACf,CAAC;IAED,YAAY,GAAU,EAAE,MAAc;QACpC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,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
|
@@ -28,6 +28,7 @@ var readline__namespace = /*#__PURE__*/_interopNamespaceDefault(readline);
|
|
|
28
28
|
const finalizationRegistry = new FinalizationRegistry(async (destructor) => { await destructor(); });
|
|
29
29
|
|
|
30
30
|
class NSRPC {
|
|
31
|
+
logMessages = false;
|
|
31
32
|
send;
|
|
32
33
|
responseHandlers = new Map();
|
|
33
34
|
closureTargets = new Map();
|
|
@@ -36,10 +37,21 @@ class NSRPC {
|
|
|
36
37
|
}
|
|
37
38
|
receive(data) {
|
|
38
39
|
// TODO: For now we just assume the message is a valid NSRPC message, but we should:
|
|
39
|
-
// - Handle invalid JSON comming in
|
|
40
40
|
// - Check if the nsrpc property is set to a number in the range of 1..<2
|
|
41
41
|
// - Validate the message against the defined interfaces above
|
|
42
|
-
|
|
42
|
+
let message;
|
|
43
|
+
try {
|
|
44
|
+
if (this.logMessages) {
|
|
45
|
+
console.log("< ", data.trimEnd());
|
|
46
|
+
}
|
|
47
|
+
message = JSON.parse(data);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (this.logMessages) {
|
|
51
|
+
console.log("!! Above message is invalid JSON, will be ignored.");
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
43
55
|
if ("status" in message) {
|
|
44
56
|
// This is a response, dispatch it so it can be handled
|
|
45
57
|
const responseHandler = this.responseHandlers.get(message.id);
|
|
@@ -65,7 +77,11 @@ class NSRPC {
|
|
|
65
77
|
}
|
|
66
78
|
/* Sending helpers */
|
|
67
79
|
sendMessage(message) {
|
|
68
|
-
|
|
80
|
+
const stringMessage = JSON.stringify(message);
|
|
81
|
+
if (this.logMessages) {
|
|
82
|
+
console.log("> ", stringMessage);
|
|
83
|
+
}
|
|
84
|
+
this.send(stringMessage);
|
|
69
85
|
}
|
|
70
86
|
sendResponse(id, response) {
|
|
71
87
|
if (id === undefined) {
|
|
@@ -183,7 +199,6 @@ class NSRPC {
|
|
|
183
199
|
}
|
|
184
200
|
|
|
185
201
|
class IpcRecordKit {
|
|
186
|
-
logMessages = false;
|
|
187
202
|
childProcess;
|
|
188
203
|
nsrpc;
|
|
189
204
|
constructor() {
|
|
@@ -193,7 +208,7 @@ class IpcRecordKit {
|
|
|
193
208
|
if (this.childProcess !== undefined) {
|
|
194
209
|
throw new Error('RecordKit RPC: Already initialized.');
|
|
195
210
|
}
|
|
196
|
-
this.logMessages = logMessages;
|
|
211
|
+
this.nsrpc.logMessages = logMessages;
|
|
197
212
|
this.childProcess = await new Promise((resolve, reject) => {
|
|
198
213
|
const childProcess = node_child_process.spawn(recordKitRpcPath);
|
|
199
214
|
childProcess.on('spawn', () => { resolve(childProcess); });
|
|
@@ -204,9 +219,6 @@ class IpcRecordKit {
|
|
|
204
219
|
throw new Error('RecordKit RPC: No stdout stream on child process.');
|
|
205
220
|
}
|
|
206
221
|
readline__namespace.createInterface({ input: stdout }).on('line', (line) => {
|
|
207
|
-
if (logMessages) {
|
|
208
|
-
console.log("< ", line.trimEnd());
|
|
209
|
-
}
|
|
210
222
|
this.nsrpc.receive(line);
|
|
211
223
|
});
|
|
212
224
|
}
|
|
@@ -215,9 +227,6 @@ class IpcRecordKit {
|
|
|
215
227
|
if (!stdin) {
|
|
216
228
|
throw new Error('RecordKit RPC: Missing stdin stream.');
|
|
217
229
|
}
|
|
218
|
-
if (this.logMessages) {
|
|
219
|
-
console.log("> ", message);
|
|
220
|
-
}
|
|
221
230
|
stdin.write(message + "\n");
|
|
222
231
|
}
|
|
223
232
|
}
|
|
@@ -242,6 +251,11 @@ class Recorder extends stream.EventEmitter {
|
|
|
242
251
|
item.window = item.window.id;
|
|
243
252
|
}
|
|
244
253
|
}
|
|
254
|
+
if (item.type == 'iPhonePortrait') {
|
|
255
|
+
if (typeof item.device != 'string') {
|
|
256
|
+
item.device = item.device.id;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
245
259
|
});
|
|
246
260
|
const weakRefObject = new WeakRef(object);
|
|
247
261
|
const onAbortInstance = rpc.registerClosure({
|
|
@@ -277,7 +291,7 @@ class RecordKit {
|
|
|
277
291
|
ipcRecordKit = new IpcRecordKit();
|
|
278
292
|
async initialize(args) {
|
|
279
293
|
let rpcBinaryPath = args.rpcBinaryPath;
|
|
280
|
-
if (
|
|
294
|
+
if (args.fallbackToNodeModules) {
|
|
281
295
|
if (!node_fs.existsSync(rpcBinaryPath)) {
|
|
282
296
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');
|
|
283
297
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
@@ -294,6 +308,9 @@ class RecordKit {
|
|
|
294
308
|
async getMicrophones() {
|
|
295
309
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });
|
|
296
310
|
}
|
|
311
|
+
async getAppleDevices() {
|
|
312
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });
|
|
313
|
+
}
|
|
297
314
|
async getCameraAuthorizationStatus() {
|
|
298
315
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
299
316
|
}
|
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 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 // - Handle invalid JSON comming in\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 const message = JSON.parse(data);\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 this.send(JSON.stringify(message));\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 logMessages = false;\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.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 if (logMessages) {\n console.log(\"< \", line.trimEnd());\n }\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 if (this.logMessages) {\n console.log(\"> \", message);\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,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;AACA,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACzC,QAAQ,IAAI,QAAQ,IAAI,OAAO,EAAE;AACjC;AACA,YAAY,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC1E,YAAY,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACrD,YAAY,IAAI,eAAe,KAAK,SAAS,EAAE;AAC/C;AACA,gBAAgB,OAAO;AACvB,aAAa;AACb,YAAY,IAAI,OAAO,IAAI,OAAO,EAAE;AACpC,gBAAgB,eAAe,CAAC,MAAM,CAAC,O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","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"],"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,IAAI,CAAC,CAAC;AACvC,SAAS;AACT,QAAQ,OAAO,KAAK,EAAE;AACtB,YAAY,IAAI,IAAI,CAAC,WAAW,EAAE;AAClC,gBAAgB,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;AAClF,aAAa;AACb,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,IAAI,QAAQ,IAAI,OAAO,EAAE;AACjC;AACA,YAAY,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I,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,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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nonstrict/recordkit",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "RecordKit gives you hassle-free recording in Electron apps on macOS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "out/index.js",
|
|
@@ -46,4 +46,4 @@
|
|
|
46
46
|
"volta": {
|
|
47
47
|
"node": "18.19.1"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
package/src/IpcRecordKit.ts
CHANGED
|
@@ -3,44 +3,34 @@ import * as readline from 'readline';
|
|
|
3
3
|
import { NSRPC } from "./NonstrictRPC.js";
|
|
4
4
|
|
|
5
5
|
export class IpcRecordKit {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
private write(message: String) {
|
|
37
|
-
const stdin = this.childProcess?.stdin;
|
|
38
|
-
if (!stdin) { throw new Error('RecordKit RPC: Missing stdin stream.') }
|
|
39
|
-
|
|
40
|
-
if (this.logMessages) {
|
|
41
|
-
console.log("> ", message);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
stdin.write(message + "\n")
|
|
45
|
-
}
|
|
6
|
+
private childProcess?: ChildProcess;
|
|
7
|
+
readonly nsrpc: NSRPC;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
this.nsrpc = new NSRPC((message) => this.write(message));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async initialize(recordKitRpcPath: string, logMessages: boolean = false): Promise<void> {
|
|
14
|
+
if (this.childProcess !== undefined) { throw new Error('RecordKit RPC: Already initialized.') }
|
|
15
|
+
|
|
16
|
+
this.nsrpc.logMessages = logMessages;
|
|
17
|
+
this.childProcess = await new Promise<ChildProcess>((resolve, reject) => {
|
|
18
|
+
const childProcess = spawn(recordKitRpcPath)
|
|
19
|
+
childProcess.on('spawn', () => { resolve(childProcess) })
|
|
20
|
+
childProcess.on('error', (error) => { reject(error) })
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const { stdout } = this.childProcess
|
|
24
|
+
if (!stdout) { throw new Error('RecordKit RPC: No stdout stream on child process.') }
|
|
25
|
+
|
|
26
|
+
readline.createInterface({ input: stdout }).on('line', (line) => {
|
|
27
|
+
this.nsrpc.receive(line);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private write(message: String) {
|
|
32
|
+
const stdin = this.childProcess?.stdin;
|
|
33
|
+
if (!stdin) { throw new Error('RecordKit RPC: Missing stdin stream.') }
|
|
34
|
+
stdin.write(message + "\n")
|
|
35
|
+
}
|
|
46
36
|
}
|
package/src/NonstrictRPC.ts
CHANGED
|
@@ -111,6 +111,7 @@ type ClosureTarget = (
|
|
|
111
111
|
) => Record<string, unknown> | void;
|
|
112
112
|
|
|
113
113
|
export class NSRPC {
|
|
114
|
+
logMessages = false;
|
|
114
115
|
private readonly send: (data: string) => void;
|
|
115
116
|
|
|
116
117
|
private responseHandlers: Map<string, PromiseSource> = new Map();
|
|
@@ -122,10 +123,21 @@ export class NSRPC {
|
|
|
122
123
|
|
|
123
124
|
receive(data: string) {
|
|
124
125
|
// TODO: For now we just assume the message is a valid NSRPC message, but we should:
|
|
125
|
-
// - Handle invalid JSON comming in
|
|
126
126
|
// - Check if the nsrpc property is set to a number in the range of 1..<2
|
|
127
127
|
// - Validate the message against the defined interfaces above
|
|
128
|
-
|
|
128
|
+
let message: NSRPCMessage
|
|
129
|
+
try {
|
|
130
|
+
if (this.logMessages) {
|
|
131
|
+
console.log("< ", data.trimEnd());
|
|
132
|
+
}
|
|
133
|
+
message = JSON.parse(data) as NSRPCMessage;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (this.logMessages) {
|
|
136
|
+
console.log("!! Above message is invalid JSON, will be ignored.");
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
129
141
|
if ("status" in message) {
|
|
130
142
|
// This is a response, dispatch it so it can be handled
|
|
131
143
|
const responseHandler = this.responseHandlers.get(message.id);
|
|
@@ -152,7 +164,11 @@ export class NSRPC {
|
|
|
152
164
|
/* Sending helpers */
|
|
153
165
|
|
|
154
166
|
private sendMessage(message: NSRPCMessage) {
|
|
155
|
-
|
|
167
|
+
const stringMessage = JSON.stringify(message)
|
|
168
|
+
if (this.logMessages) {
|
|
169
|
+
console.log("> ", stringMessage);
|
|
170
|
+
}
|
|
171
|
+
this.send(stringMessage);
|
|
156
172
|
}
|
|
157
173
|
|
|
158
174
|
private sendResponse(id: string | undefined, response: NSRPCResponseBody) {
|
package/src/RecordKit.ts
CHANGED
|
@@ -33,6 +33,13 @@ export interface Microphone {
|
|
|
33
33
|
availability: 'available' | 'lidClosed' | 'unknownSuspended'
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export interface AppleDevice {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
model_id?: string;
|
|
40
|
+
availability: 'available'
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
export interface Bounds {
|
|
37
44
|
x: number;
|
|
38
45
|
y: number;
|
|
@@ -45,7 +52,7 @@ export class RecordKit {
|
|
|
45
52
|
|
|
46
53
|
async initialize(args: { rpcBinaryPath: string, fallbackToNodeModules: boolean, logRpcMessages?: boolean }): Promise<void> {
|
|
47
54
|
let rpcBinaryPath = args.rpcBinaryPath
|
|
48
|
-
if (
|
|
55
|
+
if (args.fallbackToNodeModules) {
|
|
49
56
|
if (!existsSync(rpcBinaryPath)) {
|
|
50
57
|
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.')
|
|
51
58
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin')
|
|
@@ -67,6 +74,10 @@ export class RecordKit {
|
|
|
67
74
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' }) as Microphone[]
|
|
68
75
|
}
|
|
69
76
|
|
|
77
|
+
async getAppleDevices(): Promise<AppleDevice[]> {
|
|
78
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' }) as AppleDevice[]
|
|
79
|
+
}
|
|
80
|
+
|
|
70
81
|
async getCameraAuthorizationStatus(): Promise<AuthorizationStatus> {
|
|
71
82
|
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' }) as AuthorizationStatus
|
|
72
83
|
}
|
package/src/Recorder.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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";
|
|
5
|
+
import { AppleDevice, Camera, Microphone, Window } from "./RecordKit.js";
|
|
6
6
|
|
|
7
7
|
export interface RecorderSchema {
|
|
8
8
|
output_directory?: string
|
|
@@ -12,6 +12,7 @@ export interface RecorderSchema {
|
|
|
12
12
|
export type RecorderSchemaItem =
|
|
13
13
|
| WebcamSchema
|
|
14
14
|
| WindowBasedCropSchema
|
|
15
|
+
| iPhonePortraitSchema
|
|
15
16
|
|
|
16
17
|
export interface WebcamSchema {
|
|
17
18
|
type: 'webcam'
|
|
@@ -28,6 +29,12 @@ export interface WindowBasedCropSchema {
|
|
|
28
29
|
mouse_events?: boolean
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
export interface iPhonePortraitSchema {
|
|
33
|
+
type: 'iPhonePortrait'
|
|
34
|
+
filename?: string
|
|
35
|
+
device: AppleDevice | string
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
export type AbortReason =
|
|
32
39
|
| { reason: 'userStopped'; result: RecordingResult; }
|
|
33
40
|
| { reason: 'interrupted'; result: RecordingResult; error: RecordKitError; }
|
|
@@ -47,7 +54,7 @@ export interface RecordKitError {
|
|
|
47
54
|
export interface BundleInfo {
|
|
48
55
|
version: 1,
|
|
49
56
|
files: {
|
|
50
|
-
type: 'screen' | 'webcam' | 'mouse'
|
|
57
|
+
type: 'screen' | 'webcam' | 'mouse' | 'appleDevice'
|
|
51
58
|
filename: string
|
|
52
59
|
}[]
|
|
53
60
|
}
|
|
@@ -74,6 +81,11 @@ export class Recorder extends EventEmitter {
|
|
|
74
81
|
item.window = item.window.id
|
|
75
82
|
}
|
|
76
83
|
}
|
|
84
|
+
if (item.type == 'iPhonePortrait') {
|
|
85
|
+
if (typeof item.device != 'string') {
|
|
86
|
+
item.device = item.device.id
|
|
87
|
+
}
|
|
88
|
+
}
|
|
77
89
|
})
|
|
78
90
|
|
|
79
91
|
const weakRefObject = new WeakRef(object);
|