@nonstrict/recordkit 0.15.1 → 0.17.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/README.md +1 -1
- package/bin/recordkit-rpc +0 -0
- package/out/IpcRecordKit.js +12 -7
- package/out/IpcRecordKit.js.map +1 -1
- package/out/NonstrictRPC.js +4 -4
- package/out/NonstrictRPC.js.map +1 -1
- package/out/RecordKit.d.ts +32 -0
- package/out/RecordKit.js +34 -2
- package/out/RecordKit.js.map +1 -1
- package/out/index.cjs +50 -13
- package/out/index.cjs.map +1 -1
- package/package.json +1 -1
- package/src/IpcRecordKit.ts +13 -7
- package/src/NonstrictRPC.ts +4 -4
- package/src/RecordKit.ts +50 -3
package/bin/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# recordkit-rpc 0.
|
|
1
|
+
# recordkit-rpc 0.17.0
|
package/bin/recordkit-rpc
CHANGED
|
Binary file
|
package/out/IpcRecordKit.js
CHANGED
|
@@ -9,28 +9,33 @@ export class IpcRecordKit {
|
|
|
9
9
|
}
|
|
10
10
|
async initialize(recordKitRpcPath, logMessages = false) {
|
|
11
11
|
if (this.childProcess !== undefined) {
|
|
12
|
-
throw new Error('RecordKit RPC
|
|
12
|
+
throw new Error('RecordKit: [RPC] Already initialized.');
|
|
13
13
|
}
|
|
14
14
|
this.nsrpc.logMessages = logMessages;
|
|
15
15
|
this.childProcess = await new Promise((resolve, reject) => {
|
|
16
|
-
const childProcess = spawn(recordKitRpcPath, { stdio: ['pipe', 'pipe',
|
|
17
|
-
childProcess.on('close', (code, signal) => { console.
|
|
16
|
+
const childProcess = spawn(recordKitRpcPath, { stdio: ['pipe', 'pipe', logMessages ? 'pipe' : 'ignore'] });
|
|
17
|
+
childProcess.on('close', (code, signal) => { console.error(`RecordKit: [RPC] Closed with code ${code} and signal ${signal}`); });
|
|
18
18
|
childProcess.on('error', (error) => { reject(error); });
|
|
19
|
-
childProcess.on('exit', (code, signal) => { console.
|
|
19
|
+
childProcess.on('exit', (code, signal) => { console.error(`RecordKit: [RPC] Exited with code ${code} and signal ${signal}`); });
|
|
20
20
|
childProcess.on('spawn', () => { resolve(childProcess); });
|
|
21
21
|
});
|
|
22
|
-
const { stdout } = this.childProcess;
|
|
22
|
+
const { stdout, stderr } = this.childProcess;
|
|
23
23
|
if (!stdout) {
|
|
24
|
-
throw new Error('RecordKit RPC
|
|
24
|
+
throw new Error('RecordKit: [RPC] !! No stdout stream on child process.');
|
|
25
25
|
}
|
|
26
26
|
readline.createInterface({ input: stdout }).on('line', (line) => {
|
|
27
27
|
this.nsrpc.receive(line);
|
|
28
28
|
});
|
|
29
|
+
if (stderr) {
|
|
30
|
+
readline.createInterface({ input: stderr }).on('line', (line) => {
|
|
31
|
+
console.log(`RecordKit: [RPC] Lognoise on stderr: ${line}`);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
write(message) {
|
|
31
36
|
const stdin = this.childProcess?.stdin;
|
|
32
37
|
if (!stdin) {
|
|
33
|
-
throw new Error('RecordKit RPC
|
|
38
|
+
throw new Error('RecordKit: [RPC] !! Missing stdin stream.');
|
|
34
39
|
}
|
|
35
40
|
stdin.write(message + "\n");
|
|
36
41
|
}
|
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;IACf,YAAY,CAAgB;IAC3B,KAAK,CAAQ;IAEtB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,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AAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YAAC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;QAAC,CAAC;QAC5E,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IAC7B,CAAC;CACF"}
|
package/out/NonstrictRPC.js
CHANGED
|
@@ -15,13 +15,13 @@ export class NSRPC {
|
|
|
15
15
|
let message;
|
|
16
16
|
try {
|
|
17
17
|
if (this.logMessages) {
|
|
18
|
-
console.log("<
|
|
18
|
+
console.log("RecordKit: [RPC] <", data.trimEnd());
|
|
19
19
|
}
|
|
20
20
|
message = JSON.parse(data);
|
|
21
21
|
}
|
|
22
22
|
catch (error) {
|
|
23
23
|
if (this.logMessages) {
|
|
24
|
-
console.
|
|
24
|
+
console.error("RecordKit: [RPC] !! Above message is invalid JSON, will be ignored.");
|
|
25
25
|
}
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
@@ -30,7 +30,7 @@ export class NSRPC {
|
|
|
30
30
|
const responseHandler = this.responseHandlers.get(message.id);
|
|
31
31
|
this.responseHandlers.delete(message.id);
|
|
32
32
|
if (responseHandler === undefined) {
|
|
33
|
-
|
|
33
|
+
console.error("RecordKit: [RPC] !! Got a response for an unknown request.", message.id);
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
if ("error" in message) {
|
|
@@ -52,7 +52,7 @@ export class NSRPC {
|
|
|
52
52
|
sendMessage(message) {
|
|
53
53
|
const stringMessage = JSON.stringify(message);
|
|
54
54
|
if (this.logMessages) {
|
|
55
|
-
console.log(">
|
|
55
|
+
console.log("RecordKit: [RPC] >", stringMessage);
|
|
56
56
|
}
|
|
57
57
|
this.send(stringMessage);
|
|
58
58
|
}
|
package/out/NonstrictRPC.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonstrictRPC.js","sourceRoot":"","sources":["../src/NonstrictRPC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UA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C,CAAC;QAEH,MAAM,IAAI,CAAC,WAAW,CAAC;YACrB,MAAM,EAAE,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,KAAK,CAAC,aAAa,CAAC,MAAc;QAChC,MAAM,IAAI,CAAC,WAAW,CAAC;YACrB,SAAS,EAAE,gBAAgB;YAC3B,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
|
@@ -7,6 +7,9 @@ import { Recorder, RecorderSchemaItem } from "./Recorder.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @groupDescription Permissions
|
|
9
9
|
* Check and request the apps permission to access the recording devices.
|
|
10
|
+
*
|
|
11
|
+
* @groupDescription Logging
|
|
12
|
+
* Log what's going on to the console for easy debugging and troubleshooting.
|
|
10
13
|
*/
|
|
11
14
|
export declare class RecordKit {
|
|
12
15
|
private ipcRecordKit;
|
|
@@ -28,9 +31,34 @@ export declare class RecordKit {
|
|
|
28
31
|
* 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
32
|
*/
|
|
30
33
|
fallbackToNodeModules?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Set the global log level. Defaults to `debug`.
|
|
36
|
+
*
|
|
37
|
+
* This is the same as calling `setLogLevel` right after initialization.
|
|
38
|
+
*/
|
|
39
|
+
logLevel?: LogLevel;
|
|
31
40
|
/** @ignore */
|
|
32
41
|
logRpcMessages?: boolean;
|
|
33
42
|
}): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Set the global log level. Defaults to `debug`.
|
|
45
|
+
*
|
|
46
|
+
* Messages with a lower level than this will be ignored and not passed to any log handlers.
|
|
47
|
+
*
|
|
48
|
+
* @group Logging
|
|
49
|
+
*/
|
|
50
|
+
setLogLevel(logLevel: LogLevel): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Overrides the global log level for a specific category. Defaults to the global log level.
|
|
53
|
+
*
|
|
54
|
+
* Messages in the given category with a lower level than this will be ignored and not passed to any log handlers.
|
|
55
|
+
*
|
|
56
|
+
* @group Logging
|
|
57
|
+
*/
|
|
58
|
+
setCategoryLogLevel(params: {
|
|
59
|
+
category: string;
|
|
60
|
+
logLevel?: LogLevel;
|
|
61
|
+
}): Promise<void>;
|
|
34
62
|
/**
|
|
35
63
|
* @group Discovery
|
|
36
64
|
*/
|
|
@@ -149,3 +177,7 @@ export interface Bounds {
|
|
|
149
177
|
width: number;
|
|
150
178
|
height: number;
|
|
151
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* @group Logging
|
|
182
|
+
*/
|
|
183
|
+
export type LogLevel = 'trace' | 'debug' | 'info' | 'warning' | 'error' | 'critical';
|
package/out/RecordKit.js
CHANGED
|
@@ -9,6 +9,9 @@ import { existsSync } from "node:fs";
|
|
|
9
9
|
*
|
|
10
10
|
* @groupDescription Permissions
|
|
11
11
|
* Check and request the apps permission to access the recording devices.
|
|
12
|
+
*
|
|
13
|
+
* @groupDescription Logging
|
|
14
|
+
* Log what's going on to the console for easy debugging and troubleshooting.
|
|
12
15
|
*/
|
|
13
16
|
export class RecordKit {
|
|
14
17
|
ipcRecordKit = new IpcRecordKit();
|
|
@@ -26,10 +29,39 @@ export class RecordKit {
|
|
|
26
29
|
if (args.fallbackToNodeModules ?? true) {
|
|
27
30
|
if (!existsSync(rpcBinaryPath)) {
|
|
28
31
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
29
|
-
console.
|
|
32
|
+
console.error(`RecordKit: [RPC] !! Falling back to RPC binary from node_modules at ${rpcBinaryPath}`);
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
|
-
|
|
35
|
+
await this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
|
|
36
|
+
const logHandlerInstance = this.ipcRecordKit.nsrpc.registerClosure({
|
|
37
|
+
handler: (params) => { console.log('RecordKit:', params.formattedMessage); },
|
|
38
|
+
prefix: 'RecordKit.logHandler',
|
|
39
|
+
lifecycle: this
|
|
40
|
+
});
|
|
41
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogHandler', params: { logHandlerInstance } });
|
|
42
|
+
if (args.logLevel) {
|
|
43
|
+
await this.setLogLevel(args.logLevel);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set the global log level. Defaults to `debug`.
|
|
48
|
+
*
|
|
49
|
+
* Messages with a lower level than this will be ignored and not passed to any log handlers.
|
|
50
|
+
*
|
|
51
|
+
* @group Logging
|
|
52
|
+
*/
|
|
53
|
+
async setLogLevel(logLevel) {
|
|
54
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params: { logLevel } });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Overrides the global log level for a specific category. Defaults to the global log level.
|
|
58
|
+
*
|
|
59
|
+
* Messages in the given category with a lower level than this will be ignored and not passed to any log handlers.
|
|
60
|
+
*
|
|
61
|
+
* @group Logging
|
|
62
|
+
*/
|
|
63
|
+
async setCategoryLogLevel(params) {
|
|
64
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params });
|
|
33
65
|
}
|
|
34
66
|
/**
|
|
35
67
|
* @group Discovery
|
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,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC
|
|
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,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,SAAS;IACZ,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;IAEzC,cAAc;IACd,gBAAgB,CAAC;IAEjB;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,IAiBhB;QACC,IAAI,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QACtC,IAAI,IAAI,CAAC,qBAAqB,IAAI,IAAI,EAAE,CAAC;YACvC,IAAI,CAAC,UAAU,CAA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YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAY,CAAA;IAC9H,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,mBAAmB;QACvB,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAY,CAAA;IACzH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,uBAAuB;QAC3B,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAY,CAAA;IAC7H,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,4BAA4B;QAChC,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAS,CAAA;IAC/H,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,MAMC;QACD,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/index.cjs
CHANGED
|
@@ -42,13 +42,13 @@ class NSRPC {
|
|
|
42
42
|
let message;
|
|
43
43
|
try {
|
|
44
44
|
if (this.logMessages) {
|
|
45
|
-
console.log("<
|
|
45
|
+
console.log("RecordKit: [RPC] <", data.trimEnd());
|
|
46
46
|
}
|
|
47
47
|
message = JSON.parse(data);
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
|
50
50
|
if (this.logMessages) {
|
|
51
|
-
console.
|
|
51
|
+
console.error("RecordKit: [RPC] !! Above message is invalid JSON, will be ignored.");
|
|
52
52
|
}
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@ class NSRPC {
|
|
|
57
57
|
const responseHandler = this.responseHandlers.get(message.id);
|
|
58
58
|
this.responseHandlers.delete(message.id);
|
|
59
59
|
if (responseHandler === undefined) {
|
|
60
|
-
|
|
60
|
+
console.error("RecordKit: [RPC] !! Got a response for an unknown request.", message.id);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
if ("error" in message) {
|
|
@@ -79,7 +79,7 @@ class NSRPC {
|
|
|
79
79
|
sendMessage(message) {
|
|
80
80
|
const stringMessage = JSON.stringify(message);
|
|
81
81
|
if (this.logMessages) {
|
|
82
|
-
console.log(">
|
|
82
|
+
console.log("RecordKit: [RPC] >", stringMessage);
|
|
83
83
|
}
|
|
84
84
|
this.send(stringMessage);
|
|
85
85
|
}
|
|
@@ -212,28 +212,33 @@ class IpcRecordKit {
|
|
|
212
212
|
}
|
|
213
213
|
async initialize(recordKitRpcPath, logMessages = false) {
|
|
214
214
|
if (this.childProcess !== undefined) {
|
|
215
|
-
throw new Error('RecordKit RPC
|
|
215
|
+
throw new Error('RecordKit: [RPC] Already initialized.');
|
|
216
216
|
}
|
|
217
217
|
this.nsrpc.logMessages = logMessages;
|
|
218
218
|
this.childProcess = await new Promise((resolve, reject) => {
|
|
219
|
-
const childProcess = node_child_process.spawn(recordKitRpcPath, { stdio: ['pipe', 'pipe',
|
|
220
|
-
childProcess.on('close', (code, signal) => { console.
|
|
219
|
+
const childProcess = node_child_process.spawn(recordKitRpcPath, { stdio: ['pipe', 'pipe', logMessages ? 'pipe' : 'ignore'] });
|
|
220
|
+
childProcess.on('close', (code, signal) => { console.error(`RecordKit: [RPC] Closed with code ${code} and signal ${signal}`); });
|
|
221
221
|
childProcess.on('error', (error) => { reject(error); });
|
|
222
|
-
childProcess.on('exit', (code, signal) => { console.
|
|
222
|
+
childProcess.on('exit', (code, signal) => { console.error(`RecordKit: [RPC] Exited with code ${code} and signal ${signal}`); });
|
|
223
223
|
childProcess.on('spawn', () => { resolve(childProcess); });
|
|
224
224
|
});
|
|
225
|
-
const { stdout } = this.childProcess;
|
|
225
|
+
const { stdout, stderr } = this.childProcess;
|
|
226
226
|
if (!stdout) {
|
|
227
|
-
throw new Error('RecordKit RPC
|
|
227
|
+
throw new Error('RecordKit: [RPC] !! No stdout stream on child process.');
|
|
228
228
|
}
|
|
229
229
|
readline__namespace.createInterface({ input: stdout }).on('line', (line) => {
|
|
230
230
|
this.nsrpc.receive(line);
|
|
231
231
|
});
|
|
232
|
+
if (stderr) {
|
|
233
|
+
readline__namespace.createInterface({ input: stderr }).on('line', (line) => {
|
|
234
|
+
console.log(`RecordKit: [RPC] Lognoise on stderr: ${line}`);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
232
237
|
}
|
|
233
238
|
write(message) {
|
|
234
239
|
const stdin = this.childProcess?.stdin;
|
|
235
240
|
if (!stdin) {
|
|
236
|
-
throw new Error('RecordKit RPC
|
|
241
|
+
throw new Error('RecordKit: [RPC] !! Missing stdin stream.');
|
|
237
242
|
}
|
|
238
243
|
stdin.write(message + "\n");
|
|
239
244
|
}
|
|
@@ -311,6 +316,9 @@ class Recorder extends stream.EventEmitter {
|
|
|
311
316
|
*
|
|
312
317
|
* @groupDescription Permissions
|
|
313
318
|
* Check and request the apps permission to access the recording devices.
|
|
319
|
+
*
|
|
320
|
+
* @groupDescription Logging
|
|
321
|
+
* Log what's going on to the console for easy debugging and troubleshooting.
|
|
314
322
|
*/
|
|
315
323
|
class RecordKit {
|
|
316
324
|
ipcRecordKit = new IpcRecordKit();
|
|
@@ -328,10 +336,39 @@ class RecordKit {
|
|
|
328
336
|
if (args.fallbackToNodeModules ?? true) {
|
|
329
337
|
if (!node_fs.existsSync(rpcBinaryPath)) {
|
|
330
338
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
331
|
-
console.
|
|
339
|
+
console.error(`RecordKit: [RPC] !! Falling back to RPC binary from node_modules at ${rpcBinaryPath}`);
|
|
332
340
|
}
|
|
333
341
|
}
|
|
334
|
-
|
|
342
|
+
await this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
|
|
343
|
+
const logHandlerInstance = this.ipcRecordKit.nsrpc.registerClosure({
|
|
344
|
+
handler: (params) => { console.log('RecordKit:', params.formattedMessage); },
|
|
345
|
+
prefix: 'RecordKit.logHandler',
|
|
346
|
+
lifecycle: this
|
|
347
|
+
});
|
|
348
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogHandler', params: { logHandlerInstance } });
|
|
349
|
+
if (args.logLevel) {
|
|
350
|
+
await this.setLogLevel(args.logLevel);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Set the global log level. Defaults to `debug`.
|
|
355
|
+
*
|
|
356
|
+
* Messages with a lower level than this will be ignored and not passed to any log handlers.
|
|
357
|
+
*
|
|
358
|
+
* @group Logging
|
|
359
|
+
*/
|
|
360
|
+
async setLogLevel(logLevel) {
|
|
361
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params: { logLevel } });
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Overrides the global log level for a specific category. Defaults to the global log level.
|
|
365
|
+
*
|
|
366
|
+
* Messages in the given category with a lower level than this will be ignored and not passed to any log handlers.
|
|
367
|
+
*
|
|
368
|
+
* @group Logging
|
|
369
|
+
*/
|
|
370
|
+
async setCategoryLogLevel(params) {
|
|
371
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params });
|
|
335
372
|
}
|
|
336
373
|
/**
|
|
337
374
|
* @group Discovery
|
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 async manualRelease(target) {\n await this.sendRequest({\n procedure: \"manual-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, { stdio: ['pipe', 'pipe', process.stderr] });\n childProcess.on('close', (code, signal) => { console.log(`RecordKit RPC: Closed with code ${code} and signal ${signal}`); });\n childProcess.on('error', (error) => { reject(error); });\n childProcess.on('exit', (code, signal) => { console.log(`RecordKit RPC: Exited with code ${code} and signal ${signal}`); });\n childProcess.on('spawn', () => { resolve(childProcess); });\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 == 'appleDeviceStaticOrientation') {\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 async cancel() {\n await this.rpc.manualRelease(this.target);\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 rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');\n console.log(`Falling back to RPC binary from node_modules at ${rpcBinaryPath}`);\n }\n }\n return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);\n }\n /**\n * @group Discovery\n */\n async getWindows() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });\n }\n /**\n * @group Discovery\n */\n async getCameras() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });\n }\n /**\n * @group Discovery\n */\n async getMicrophones() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });\n }\n /**\n * @group Discovery\n */\n async getAppleDevices() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });\n }\n /**\n * @group Permissions\n */\n async getCameraAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });\n }\n /**\n * @group Permissions\n */\n async getMicrophoneAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });\n }\n /**\n * @group Permissions\n */\n async getScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });\n }\n /**\n * @group Permissions\n */\n async requestCameraAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });\n }\n /**\n * @group Permissions\n */\n async requestMicrophoneAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });\n }\n /**\n * @group Permissions\n */\n async requestScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });\n }\n async createRecorder(schema) {\n return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);\n }\n}\n/** @ignore */\nexport let recordkit = new RecordKit();\n//# sourceMappingURL=RecordKit.js.map"],"names":["randomUUID","spawn","readline","EventEmitter","existsSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,OAAO,UAAU,KAAK,EAAE,MAAM,UAAU,EAAE,CAAC,EAAE,CAAC;;ACEpG,MAAM,KAAK,CAAC;AACnB,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,IAAI,CAAC;AACT,IAAI,gBAAg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rictRPC.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(\"RecordKit: [RPC] <\", data.trimEnd());\n }\n message = JSON.parse(data);\n }\n catch (error) {\n if (this.logMessages) {\n console.error(\"RecordKit: [RPC] !! 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 console.error(\"RecordKit: [RPC] !! Got a response for an unknown request.\", message.id);\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(\"RecordKit: [RPC] >\", 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 async manualRelease(target) {\n await this.sendRequest({\n procedure: \"manual-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, { stdio: ['pipe', 'pipe', logMessages ? 'pipe' : 'ignore'] });\n childProcess.on('close', (code, signal) => { console.error(`RecordKit: [RPC] Closed with code ${code} and signal ${signal}`); });\n childProcess.on('error', (error) => { reject(error); });\n childProcess.on('exit', (code, signal) => { console.error(`RecordKit: [RPC] Exited with code ${code} and signal ${signal}`); });\n childProcess.on('spawn', () => { resolve(childProcess); });\n });\n const { stdout, stderr } = 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 if (stderr) {\n readline.createInterface({ input: stderr }).on('line', (line) => {\n console.log(`RecordKit: [RPC] Lognoise on stderr: ${line}`);\n });\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 == 'appleDeviceStaticOrientation') {\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 async cancel() {\n await this.rpc.manualRelease(this.target);\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 *\n * @groupDescription Logging\n * Log what's going on to the console for easy debugging and troubleshooting.\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 rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');\n console.error(`RecordKit: [RPC] !! Falling back to RPC binary from node_modules at ${rpcBinaryPath}`);\n }\n }\n await this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);\n const logHandlerInstance = this.ipcRecordKit.nsrpc.registerClosure({\n handler: (params) => { console.log('RecordKit:', params.formattedMessage); },\n prefix: 'RecordKit.logHandler',\n lifecycle: this\n });\n await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogHandler', params: { logHandlerInstance } });\n if (args.logLevel) {\n await this.setLogLevel(args.logLevel);\n }\n }\n /**\n * Set the global log level. Defaults to `debug`.\n *\n * Messages with a lower level than this will be ignored and not passed to any log handlers.\n *\n * @group Logging\n */\n async setLogLevel(logLevel) {\n await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params: { logLevel } });\n }\n /**\n * Overrides the global log level for a specific category. Defaults to the global log level.\n *\n * Messages in the given category with a lower level than this will be ignored and not passed to any log handlers.\n *\n * @group Logging\n */\n async setCategoryLogLevel(params) {\n await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params });\n }\n /**\n * @group Discovery\n */\n async getWindows() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });\n }\n /**\n * @group Discovery\n */\n async getCameras() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });\n }\n /**\n * @group Discovery\n */\n async getMicrophones() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });\n }\n /**\n * @group Discovery\n */\n async getAppleDevices() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getAppleDevices' });\n }\n /**\n * @group Permissions\n */\n async getCameraAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });\n }\n /**\n * @group Permissions\n */\n async getMicrophoneAuthorizationStatus() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });\n }\n /**\n * @group Permissions\n */\n async getScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });\n }\n /**\n * @group Permissions\n */\n async requestCameraAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });\n }\n /**\n * @group Permissions\n */\n async requestMicrophoneAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });\n }\n /**\n * @group Permissions\n */\n async requestScreenRecordingAccess() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });\n }\n async createRecorder(schema) {\n return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);\n }\n}\n/** @ignore */\nexport let recordkit = new RecordKit();\n//# sourceMappingURL=RecordKit.js.map"],"names":["randomUUID","spawn","readline","EventEmitter","existsSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,OAAO,UAAU,KAAK,EAAE,MAAM,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,oBAAoB,EAAE,IAAI,CAAC,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AE,kCAAkC,EAAE,CAAC,CAAC;AAClI,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,wBAAwB,GAAG;AACrC,QAAQ,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,0BAA0B,EAAE,CAAC,CAAC;AAC1H,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,mBAAmB,GAAG;AAChC,QAAQ,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;AACrH,KAAK;AACL;AACA;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
package/src/IpcRecordKit.ts
CHANGED
|
@@ -11,28 +11,34 @@ export class IpcRecordKit {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async initialize(recordKitRpcPath: string, logMessages: boolean = false): Promise<void> {
|
|
14
|
-
if (this.childProcess !== undefined) { throw new Error('RecordKit RPC
|
|
14
|
+
if (this.childProcess !== undefined) { throw new Error('RecordKit: [RPC] Already initialized.') }
|
|
15
15
|
|
|
16
16
|
this.nsrpc.logMessages = logMessages;
|
|
17
17
|
this.childProcess = await new Promise<ChildProcess>((resolve, reject) => {
|
|
18
|
-
const childProcess = spawn(recordKitRpcPath, { stdio: ['pipe', 'pipe',
|
|
19
|
-
childProcess.on('close', (code, signal) => { console.
|
|
18
|
+
const childProcess = spawn(recordKitRpcPath, { stdio: ['pipe', 'pipe', logMessages ? 'pipe' : 'ignore'] })
|
|
19
|
+
childProcess.on('close', (code, signal) => { console.error(`RecordKit: [RPC] Closed with code ${code} and signal ${signal}`) })
|
|
20
20
|
childProcess.on('error', (error) => { reject(error) })
|
|
21
|
-
childProcess.on('exit', (code, signal) => { console.
|
|
21
|
+
childProcess.on('exit', (code, signal) => { console.error(`RecordKit: [RPC] Exited with code ${code} and signal ${signal}`) })
|
|
22
22
|
childProcess.on('spawn', () => { resolve(childProcess) })
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
const { stdout } = this.childProcess
|
|
26
|
-
if (!stdout) { throw new Error('RecordKit RPC
|
|
25
|
+
const { stdout, stderr } = this.childProcess
|
|
26
|
+
if (!stdout) { throw new Error('RecordKit: [RPC] !! No stdout stream on child process.') }
|
|
27
27
|
|
|
28
28
|
readline.createInterface({ input: stdout }).on('line', (line) => {
|
|
29
29
|
this.nsrpc.receive(line);
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
if (stderr) {
|
|
33
|
+
readline.createInterface({ input: stderr }).on('line', (line) => {
|
|
34
|
+
console.log(`RecordKit: [RPC] Lognoise on stderr: ${line}`);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
private write(message: String) {
|
|
34
40
|
const stdin = this.childProcess?.stdin;
|
|
35
|
-
if (!stdin) { throw new Error('RecordKit RPC
|
|
41
|
+
if (!stdin) { throw new Error('RecordKit: [RPC] !! Missing stdin stream.') }
|
|
36
42
|
stdin.write(message + "\n")
|
|
37
43
|
}
|
|
38
44
|
}
|
package/src/NonstrictRPC.ts
CHANGED
|
@@ -128,12 +128,12 @@ export class NSRPC {
|
|
|
128
128
|
let message: NSRPCMessage
|
|
129
129
|
try {
|
|
130
130
|
if (this.logMessages) {
|
|
131
|
-
console.log("<
|
|
131
|
+
console.log("RecordKit: [RPC] <", data.trimEnd());
|
|
132
132
|
}
|
|
133
133
|
message = JSON.parse(data) as NSRPCMessage;
|
|
134
134
|
} catch (error) {
|
|
135
135
|
if (this.logMessages) {
|
|
136
|
-
console.
|
|
136
|
+
console.error("RecordKit: [RPC] !! Above message is invalid JSON, will be ignored.");
|
|
137
137
|
}
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
@@ -143,7 +143,7 @@ export class NSRPC {
|
|
|
143
143
|
const responseHandler = this.responseHandlers.get(message.id);
|
|
144
144
|
this.responseHandlers.delete(message.id);
|
|
145
145
|
if (responseHandler === undefined) {
|
|
146
|
-
|
|
146
|
+
console.error("RecordKit: [RPC] !! Got a response for an unknown request.", message.id);
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -166,7 +166,7 @@ export class NSRPC {
|
|
|
166
166
|
private sendMessage(message: NSRPCMessage) {
|
|
167
167
|
const stringMessage = JSON.stringify(message)
|
|
168
168
|
if (this.logMessages) {
|
|
169
|
-
console.log(">
|
|
169
|
+
console.log("RecordKit: [RPC] >", stringMessage);
|
|
170
170
|
}
|
|
171
171
|
this.send(stringMessage);
|
|
172
172
|
}
|
package/src/RecordKit.ts
CHANGED
|
@@ -10,6 +10,9 @@ import { existsSync } from "node:fs";
|
|
|
10
10
|
*
|
|
11
11
|
* @groupDescription Permissions
|
|
12
12
|
* Check and request the apps permission to access the recording devices.
|
|
13
|
+
*
|
|
14
|
+
* @groupDescription Logging
|
|
15
|
+
* Log what's going on to the console for easy debugging and troubleshooting.
|
|
13
16
|
*/
|
|
14
17
|
export class RecordKit {
|
|
15
18
|
private ipcRecordKit = new IpcRecordKit()
|
|
@@ -33,6 +36,12 @@ export class RecordKit {
|
|
|
33
36
|
* 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
37
|
*/
|
|
35
38
|
fallbackToNodeModules?: boolean,
|
|
39
|
+
/**
|
|
40
|
+
* Set the global log level. Defaults to `debug`.
|
|
41
|
+
*
|
|
42
|
+
* This is the same as calling `setLogLevel` right after initialization.
|
|
43
|
+
*/
|
|
44
|
+
logLevel?: LogLevel,
|
|
36
45
|
/** @ignore */
|
|
37
46
|
logRpcMessages?: boolean
|
|
38
47
|
}): Promise<void> {
|
|
@@ -40,11 +49,44 @@ export class RecordKit {
|
|
|
40
49
|
if (args.fallbackToNodeModules ?? true) {
|
|
41
50
|
if (!existsSync(rpcBinaryPath)) {
|
|
42
51
|
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin')
|
|
43
|
-
console.
|
|
52
|
+
console.error(`RecordKit: [RPC] !! Falling back to RPC binary from node_modules at ${rpcBinaryPath}`)
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
await this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages)
|
|
57
|
+
|
|
58
|
+
const logHandlerInstance = this.ipcRecordKit.nsrpc.registerClosure({
|
|
59
|
+
handler: (params) => { console.log('RecordKit:', params.formattedMessage) },
|
|
60
|
+
prefix: 'RecordKit.logHandler',
|
|
61
|
+
lifecycle: this
|
|
62
|
+
})
|
|
63
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogHandler', params: { logHandlerInstance } })
|
|
64
|
+
|
|
65
|
+
if (args.logLevel) {
|
|
66
|
+
await this.setLogLevel(args.logLevel)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Set the global log level. Defaults to `debug`.
|
|
72
|
+
*
|
|
73
|
+
* Messages with a lower level than this will be ignored and not passed to any log handlers.
|
|
74
|
+
*
|
|
75
|
+
* @group Logging
|
|
76
|
+
*/
|
|
77
|
+
async setLogLevel(logLevel: LogLevel): Promise<void> {
|
|
78
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params: { logLevel } })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Overrides the global log level for a specific category. Defaults to the global log level.
|
|
83
|
+
*
|
|
84
|
+
* Messages in the given category with a lower level than this will be ignored and not passed to any log handlers.
|
|
85
|
+
*
|
|
86
|
+
* @group Logging
|
|
87
|
+
*/
|
|
88
|
+
async setCategoryLogLevel(params: { category: string, logLevel?: LogLevel }): Promise<void> {
|
|
89
|
+
await this.ipcRecordKit.nsrpc.perform({ type: 'Logger', action: 'setLogLevel', params })
|
|
48
90
|
}
|
|
49
91
|
|
|
50
92
|
/**
|
|
@@ -209,4 +251,9 @@ export interface Bounds {
|
|
|
209
251
|
y: number;
|
|
210
252
|
width: number;
|
|
211
253
|
height: number;
|
|
212
|
-
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @group Logging
|
|
258
|
+
*/
|
|
259
|
+
export type LogLevel = 'trace' | 'debug' | 'info' | 'warning' | 'error' | 'critical'
|