@nonstrict/recordkit 0.2.1 → 0.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/.gitkeep +0 -0
- package/bin/recordkit-rpc +0 -0
- package/build.sh +32 -0
- package/jest.config.js +16 -0
- package/{dist → out}/IpcRecordKit.js +1 -0
- package/out/IpcRecordKit.js.map +1 -0
- package/{dist → out}/NonstrictRPC.js +1 -0
- package/out/NonstrictRPC.js.map +1 -0
- package/out/RecordKit.d.ts +50 -0
- package/out/RecordKit.js +48 -0
- package/out/RecordKit.js.map +1 -0
- package/out/Recorder.d.ts +59 -0
- package/{dist/RecordingSession.js → out/Recorder.js} +21 -5
- package/out/Recorder.js.map +1 -0
- package/{dist → out}/finalizationRegistry.js +1 -0
- package/out/finalizationRegistry.js.map +1 -0
- package/{dist → out}/index.cjs +54 -13
- package/out/index.cjs.map +1 -0
- package/out/index.d.ts +3 -0
- package/{dist → out}/index.js +1 -0
- package/out/index.js.map +1 -0
- package/package.json +9 -11
- package/rollup.config.js +11 -0
- package/src/IpcRecordKit.ts +46 -0
- package/src/NonstrictRPC.test.ts +98 -0
- package/src/NonstrictRPC.ts +308 -0
- package/src/RecordKit.ts +99 -0
- package/src/Recorder.ts +113 -0
- package/src/__snapshots__/NonstrictRPC.test.ts.snap +24 -0
- package/src/finalizationRegistry.ts +2 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +109 -0
- package/typedoc.json +6 -0
- package/dist/RecordKit.d.ts +0 -34
- package/dist/RecordKit.js +0 -22
- package/dist/RecordingSession.d.ts +0 -70
- package/dist/index.d.ts +0 -1
- /package/{dist → out}/IpcRecordKit.d.ts +0 -0
- /package/{dist → out}/NonstrictRPC.d.ts +0 -0
- /package/{dist → out}/finalizationRegistry.d.ts +0 -0
package/bin/.gitkeep
ADDED
|
File without changes
|
|
Binary file
|
package/build.sh
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/bin/bash -e
|
|
2
|
+
|
|
3
|
+
# Check arguments
|
|
4
|
+
VERSION_NUMBER="$1"
|
|
5
|
+
|
|
6
|
+
if [ -z "$VERSION_NUMBER" ]; then
|
|
7
|
+
echo "Missing version argument: ./build.sh 0.3.4"
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Clean up previous artifact directory
|
|
13
|
+
rm -r ./dist || echo "No old build to remove"
|
|
14
|
+
|
|
15
|
+
# Set version in package.json
|
|
16
|
+
function restore_package_json {
|
|
17
|
+
npm version 0.0.0
|
|
18
|
+
echo "Restored version"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# register the cleanup function to be called on the EXIT signal
|
|
22
|
+
trap restore_package_json EXIT
|
|
23
|
+
|
|
24
|
+
echo "Updating version number"
|
|
25
|
+
npm version $VERSION_NUMBER
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Build recordkit-electron
|
|
29
|
+
npm run build
|
|
30
|
+
contents=(*)
|
|
31
|
+
mkdir dist
|
|
32
|
+
cp -r ${contents[*]} dist
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
+
export default {
|
|
3
|
+
preset: "ts-jest/presets/default-esm",
|
|
4
|
+
testEnvironment: "node",
|
|
5
|
+
moduleNameMapper: {
|
|
6
|
+
"^(\\.{1,2}/.*)\\.js$": "$1",
|
|
7
|
+
},
|
|
8
|
+
transform: {
|
|
9
|
+
"^.+\\.tsx?$": [
|
|
10
|
+
"ts-jest",
|
|
11
|
+
{
|
|
12
|
+
useESM: true,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IpcRecordKit.js","sourceRoot":"","sources":["../src/IpcRecordKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE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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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Recorder, RecorderSchema } from "./Recorder.js";
|
|
2
|
+
type AuthorizationStatus = 'notDetermined' | 'restricted' | 'denied' | 'authorized';
|
|
3
|
+
export interface Window {
|
|
4
|
+
id: number;
|
|
5
|
+
title?: string;
|
|
6
|
+
frame: Bounds;
|
|
7
|
+
level: number;
|
|
8
|
+
application_process_id?: number;
|
|
9
|
+
application_name?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Camera {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
model_id: string;
|
|
15
|
+
manufacturer: string;
|
|
16
|
+
availability: 'available' | 'lidClosed' | 'unknownSuspended';
|
|
17
|
+
}
|
|
18
|
+
export interface Microphone {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
model_id: string;
|
|
22
|
+
manufacturer: string;
|
|
23
|
+
availability: 'available' | 'lidClosed' | 'unknownSuspended';
|
|
24
|
+
}
|
|
25
|
+
export interface Bounds {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class RecordKit {
|
|
32
|
+
private ipcRecordKit;
|
|
33
|
+
initialize(args: {
|
|
34
|
+
rpcBinaryPath: string;
|
|
35
|
+
fallbackToNodeModules: boolean;
|
|
36
|
+
logRpcMessages?: boolean;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
getWindows(): Promise<Window[]>;
|
|
39
|
+
getCameras(): Promise<Camera[]>;
|
|
40
|
+
getMicrophones(): Promise<Microphone[]>;
|
|
41
|
+
getCameraAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
42
|
+
getMicrophoneAuthorizationStatus(): Promise<AuthorizationStatus>;
|
|
43
|
+
getScreenRecordingAccess(): Promise<boolean>;
|
|
44
|
+
requestCameraAccess(): Promise<boolean>;
|
|
45
|
+
requestMicrophoneAccess(): Promise<boolean>;
|
|
46
|
+
requestScreenRecordingAccess(): Promise<void>;
|
|
47
|
+
createRecorder(schema: RecorderSchema): Promise<Recorder>;
|
|
48
|
+
}
|
|
49
|
+
export declare let recordkit: RecordKit;
|
|
50
|
+
export {};
|
package/out/RecordKit.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IpcRecordKit } from "./IpcRecordKit.js";
|
|
2
|
+
import { Recorder } from "./Recorder.js";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
export class RecordKit {
|
|
5
|
+
ipcRecordKit = new IpcRecordKit();
|
|
6
|
+
async initialize(args) {
|
|
7
|
+
let rpcBinaryPath = args.rpcBinaryPath;
|
|
8
|
+
if (!args.fallbackToNodeModules) {
|
|
9
|
+
if (!existsSync(rpcBinaryPath)) {
|
|
10
|
+
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');
|
|
11
|
+
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
|
|
15
|
+
}
|
|
16
|
+
async getWindows() {
|
|
17
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });
|
|
18
|
+
}
|
|
19
|
+
async getCameras() {
|
|
20
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });
|
|
21
|
+
}
|
|
22
|
+
async getMicrophones() {
|
|
23
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });
|
|
24
|
+
}
|
|
25
|
+
async getCameraAuthorizationStatus() {
|
|
26
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
27
|
+
}
|
|
28
|
+
async getMicrophoneAuthorizationStatus() {
|
|
29
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });
|
|
30
|
+
}
|
|
31
|
+
async getScreenRecordingAccess() {
|
|
32
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });
|
|
33
|
+
}
|
|
34
|
+
async requestCameraAccess() {
|
|
35
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });
|
|
36
|
+
}
|
|
37
|
+
async requestMicrophoneAccess() {
|
|
38
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });
|
|
39
|
+
}
|
|
40
|
+
async requestScreenRecordingAccess() {
|
|
41
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });
|
|
42
|
+
}
|
|
43
|
+
async createRecorder(schema) {
|
|
44
|
+
return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export let recordkit = new RecordKit();
|
|
48
|
+
//# sourceMappingURL=RecordKit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1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AAI,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import { NSRPC } from "./NonstrictRPC.js";
|
|
4
|
+
import { EventEmitter } from "stream";
|
|
5
|
+
import { Camera, Microphone, Window } from "./RecordKit.js";
|
|
6
|
+
export interface RecorderSchema {
|
|
7
|
+
output_directory?: string;
|
|
8
|
+
items: RecorderSchemaItem[];
|
|
9
|
+
}
|
|
10
|
+
export type RecorderSchemaItem = WebcamSchema | WindowBasedCropSchema;
|
|
11
|
+
export interface WebcamSchema {
|
|
12
|
+
type: 'webcam';
|
|
13
|
+
filename?: string;
|
|
14
|
+
camera: Camera | string;
|
|
15
|
+
microphone: Microphone | string;
|
|
16
|
+
}
|
|
17
|
+
export interface WindowBasedCropSchema {
|
|
18
|
+
type: 'windowBasedCrop';
|
|
19
|
+
filename?: string;
|
|
20
|
+
window: Window | number;
|
|
21
|
+
shows_cursor?: boolean;
|
|
22
|
+
mouse_events?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type AbortReason = {
|
|
25
|
+
reason: 'userStopped';
|
|
26
|
+
result: RecordingResult;
|
|
27
|
+
} | {
|
|
28
|
+
reason: 'interrupted';
|
|
29
|
+
result: RecordingResult;
|
|
30
|
+
error: RecordKitError;
|
|
31
|
+
} | {
|
|
32
|
+
reason: 'failed';
|
|
33
|
+
error: RecordKitError;
|
|
34
|
+
};
|
|
35
|
+
export interface RecordingResult {
|
|
36
|
+
url: string;
|
|
37
|
+
info: BundleInfo;
|
|
38
|
+
}
|
|
39
|
+
export interface RecordKitError {
|
|
40
|
+
message?: string;
|
|
41
|
+
error_group: string;
|
|
42
|
+
debug_description: string;
|
|
43
|
+
}
|
|
44
|
+
export interface BundleInfo {
|
|
45
|
+
version: 1;
|
|
46
|
+
files: {
|
|
47
|
+
type: 'screen' | 'webcam' | 'mouse';
|
|
48
|
+
filename: string;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
export declare class Recorder extends EventEmitter {
|
|
52
|
+
private readonly rpc;
|
|
53
|
+
private readonly target;
|
|
54
|
+
static newInstance(rpc: NSRPC, schema: RecorderSchema): Promise<Recorder>;
|
|
55
|
+
constructor(rpc: NSRPC, target: string);
|
|
56
|
+
prepare(): Promise<void>;
|
|
57
|
+
start(): Promise<void>;
|
|
58
|
+
stop(): Promise<RecordingResult>;
|
|
59
|
+
}
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
2
|
import { EventEmitter } from "stream";
|
|
3
|
-
export class
|
|
3
|
+
export class Recorder extends EventEmitter {
|
|
4
4
|
rpc;
|
|
5
5
|
target;
|
|
6
6
|
static async newInstance(rpc, schema) {
|
|
7
|
-
const target = '
|
|
8
|
-
const object = new
|
|
7
|
+
const target = 'Recorder_' + randomUUID();
|
|
8
|
+
const object = new Recorder(rpc, target);
|
|
9
|
+
schema.items.forEach(item => {
|
|
10
|
+
if (item.type == 'webcam') {
|
|
11
|
+
if (typeof item.camera != 'string') {
|
|
12
|
+
item.camera = item.camera.id;
|
|
13
|
+
}
|
|
14
|
+
if (typeof item.microphone != 'string') {
|
|
15
|
+
item.microphone = item.microphone.id;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (item.type == 'windowBasedCrop') {
|
|
19
|
+
if (typeof item.window != 'number') {
|
|
20
|
+
item.window = item.window.id;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
9
24
|
const weakRefObject = new WeakRef(object);
|
|
10
25
|
const onAbortInstance = rpc.registerClosure({
|
|
11
26
|
handler: (params) => { weakRefObject.deref()?.emit('abort', params.reason); },
|
|
12
|
-
prefix: '
|
|
27
|
+
prefix: 'Recorder.onAbort',
|
|
13
28
|
lifecycle: object
|
|
14
29
|
});
|
|
15
30
|
await rpc.initialize({
|
|
16
31
|
target,
|
|
17
|
-
type: '
|
|
32
|
+
type: 'Recorder',
|
|
18
33
|
params: { schema, onAbortInstance },
|
|
19
34
|
lifecycle: object
|
|
20
35
|
});
|
|
@@ -35,3 +50,4 @@ export class RecordingSession extends EventEmitter {
|
|
|
35
50
|
return await this.rpc.perform({ target: this.target, action: 'stop' });
|
|
36
51
|
}
|
|
37
52
|
}
|
|
53
|
+
//# sourceMappingURL=Recorder.js.map
|
|
@@ -0,0 +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;AAmDtC,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;gBAC1B,IAAI,OAAO,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;oBACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAA;gBAC9B,CAAC;gBACD,IAAI,OAAO,IAAI,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;oBACvC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAA;gBACtC,CAAC;YACH,CAAC;YACD,IAAI,IAAI,CAAC,IAAI,IAAI,iBAAiB,EAAE,CAAC;gBACnC,IAAI,OAAO,IAAI,CAAC,MA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I,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAoB,CAAC;IAC5F,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalizationRegistry.js","sourceRoot":"","sources":["../src/finalizationRegistry.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAa,KAAK,EAAE,UAAU,EAAE,EAAE,GAAG,MAAM,UAAU,EAAE,CAAA,CAAC,CAAC,CAAC,CAAA"}
|
package/{dist → out}/index.cjs
RENAMED
|
@@ -4,6 +4,7 @@ var node_child_process = require('node:child_process');
|
|
|
4
4
|
var readline = require('readline');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
6
|
var stream = require('stream');
|
|
7
|
+
var node_fs = require('node:fs');
|
|
7
8
|
|
|
8
9
|
function _interopNamespaceDefault(e) {
|
|
9
10
|
var n = Object.create(null);
|
|
@@ -221,21 +222,36 @@ class IpcRecordKit {
|
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
|
|
224
|
-
class
|
|
225
|
+
class Recorder extends stream.EventEmitter {
|
|
225
226
|
rpc;
|
|
226
227
|
target;
|
|
227
228
|
static async newInstance(rpc, schema) {
|
|
228
|
-
const target = '
|
|
229
|
-
const object = new
|
|
229
|
+
const target = 'Recorder_' + crypto.randomUUID();
|
|
230
|
+
const object = new Recorder(rpc, target);
|
|
231
|
+
schema.items.forEach(item => {
|
|
232
|
+
if (item.type == 'webcam') {
|
|
233
|
+
if (typeof item.camera != 'string') {
|
|
234
|
+
item.camera = item.camera.id;
|
|
235
|
+
}
|
|
236
|
+
if (typeof item.microphone != 'string') {
|
|
237
|
+
item.microphone = item.microphone.id;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (item.type == 'windowBasedCrop') {
|
|
241
|
+
if (typeof item.window != 'number') {
|
|
242
|
+
item.window = item.window.id;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
230
246
|
const weakRefObject = new WeakRef(object);
|
|
231
247
|
const onAbortInstance = rpc.registerClosure({
|
|
232
248
|
handler: (params) => { weakRefObject.deref()?.emit('abort', params.reason); },
|
|
233
|
-
prefix: '
|
|
249
|
+
prefix: 'Recorder.onAbort',
|
|
234
250
|
lifecycle: object
|
|
235
251
|
});
|
|
236
252
|
await rpc.initialize({
|
|
237
253
|
target,
|
|
238
|
-
type: '
|
|
254
|
+
type: 'Recorder',
|
|
239
255
|
params: { schema, onAbortInstance },
|
|
240
256
|
lifecycle: object
|
|
241
257
|
});
|
|
@@ -259,23 +275,48 @@ class RecordingSession extends stream.EventEmitter {
|
|
|
259
275
|
|
|
260
276
|
class RecordKit {
|
|
261
277
|
ipcRecordKit = new IpcRecordKit();
|
|
262
|
-
async initialize(
|
|
263
|
-
|
|
264
|
-
|
|
278
|
+
async initialize(args) {
|
|
279
|
+
let rpcBinaryPath = args.rpcBinaryPath;
|
|
280
|
+
if (!args.fallbackToNodeModules) {
|
|
281
|
+
if (!node_fs.existsSync(rpcBinaryPath)) {
|
|
282
|
+
console.log('Falling back to RPC binary from node_modules, no file at given RPC binary path.');
|
|
283
|
+
rpcBinaryPath = rpcBinaryPath.replace('node_modules/electron/dist/Electron.app/Contents/Resources', 'node_modules/@nonstrict/recordkit/bin');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
|
|
265
287
|
}
|
|
266
288
|
async getWindows() {
|
|
267
|
-
return await this.ipcRecordKit.nsrpc.perform({ type: '
|
|
289
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getWindows' });
|
|
268
290
|
}
|
|
269
291
|
async getCameras() {
|
|
270
|
-
return await this.ipcRecordKit.nsrpc.perform({ type: '
|
|
292
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getCameras' });
|
|
271
293
|
}
|
|
272
294
|
async getMicrophones() {
|
|
273
|
-
return await this.ipcRecordKit.nsrpc.perform({ type: '
|
|
295
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getMicrophones' });
|
|
296
|
+
}
|
|
297
|
+
async getCameraAuthorizationStatus() {
|
|
298
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getCameraAuthorizationStatus' });
|
|
299
|
+
}
|
|
300
|
+
async getMicrophoneAuthorizationStatus() {
|
|
301
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getMicrophoneAuthorizationStatus' });
|
|
302
|
+
}
|
|
303
|
+
async getScreenRecordingAccess() {
|
|
304
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'getScreenRecordingAccess' });
|
|
305
|
+
}
|
|
306
|
+
async requestCameraAccess() {
|
|
307
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestCameraAccess' });
|
|
308
|
+
}
|
|
309
|
+
async requestMicrophoneAccess() {
|
|
310
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestMicrophoneAccess' });
|
|
311
|
+
}
|
|
312
|
+
async requestScreenRecordingAccess() {
|
|
313
|
+
return await this.ipcRecordKit.nsrpc.perform({ type: 'AuthorizationStatus', action: 'requestScreenRecordingAccess' });
|
|
274
314
|
}
|
|
275
|
-
async
|
|
276
|
-
return
|
|
315
|
+
async createRecorder(schema) {
|
|
316
|
+
return Recorder.newInstance(this.ipcRecordKit.nsrpc, schema);
|
|
277
317
|
}
|
|
278
318
|
}
|
|
279
319
|
let recordkit = new RecordKit();
|
|
280
320
|
|
|
281
321
|
exports.recordkit = recordkit;
|
|
322
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,MAAM,EAAE,0BAA0B,EAAE,CAAC,CAAC;AAC1H,KAAK;AACL,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,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,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/out/index.d.ts
ADDED
package/{dist → out}/index.js
RENAMED
package/out/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nonstrict/recordkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
4
|
"description": "RecordKit gives you hassle-free recording in Electron apps on macOS.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "
|
|
7
|
-
"types": "
|
|
6
|
+
"main": "out/index.js",
|
|
7
|
+
"types": "out/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
"import": "./
|
|
10
|
-
"require": "./
|
|
9
|
+
"import": "./out/index.js",
|
|
10
|
+
"require": "./out/index.cjs"
|
|
11
11
|
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist"
|
|
14
|
-
],
|
|
15
12
|
"engines": {
|
|
16
13
|
"node": ">=18.16"
|
|
17
14
|
},
|
|
18
15
|
"scripts": {
|
|
19
16
|
"test": "jest",
|
|
20
|
-
"build": "rm -rf
|
|
17
|
+
"build": "rm -rf out && tsc && rollup -c",
|
|
21
18
|
"prepublish": "npm run build"
|
|
22
19
|
},
|
|
23
20
|
"keywords": [
|
|
@@ -34,7 +31,7 @@
|
|
|
34
31
|
"author": {
|
|
35
32
|
"name": "Nonstrict B.V.",
|
|
36
33
|
"email": "team+recordkit@nonstrict.com",
|
|
37
|
-
"url": "https://nonstrict.eu"
|
|
34
|
+
"url": "https://nonstrict.eu/recordkit"
|
|
38
35
|
},
|
|
39
36
|
"license": "SEE LICENSE IN License.md",
|
|
40
37
|
"devDependencies": {
|
|
@@ -43,9 +40,10 @@
|
|
|
43
40
|
"jest": "^29.7.0",
|
|
44
41
|
"rollup": "^4.12.0",
|
|
45
42
|
"ts-jest": "^29.1.2",
|
|
43
|
+
"typedoc": "^0.25.11",
|
|
46
44
|
"typescript": "^5.3.3"
|
|
47
45
|
},
|
|
48
46
|
"volta": {
|
|
49
47
|
"node": "18.19.1"
|
|
50
48
|
}
|
|
51
|
-
}
|
|
49
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ChildProcess, spawn } from 'node:child_process';
|
|
2
|
+
import * as readline from 'readline';
|
|
3
|
+
import { NSRPC } from "./NonstrictRPC.js";
|
|
4
|
+
|
|
5
|
+
export class IpcRecordKit {
|
|
6
|
+
private logMessages: boolean = false;
|
|
7
|
+
private childProcess?: ChildProcess;
|
|
8
|
+
readonly nsrpc: NSRPC;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
this.nsrpc = new NSRPC((message) => this.write(message));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async initialize(recordKitRpcPath: string, logMessages: boolean = false): Promise<void> {
|
|
15
|
+
if (this.childProcess !== undefined) { throw new Error('RecordKit RPC: Already initialized.') }
|
|
16
|
+
|
|
17
|
+
this.logMessages = logMessages;
|
|
18
|
+
this.childProcess = await new Promise<ChildProcess>((resolve, reject) => {
|
|
19
|
+
const childProcess = spawn(recordKitRpcPath)
|
|
20
|
+
childProcess.on('spawn', () => { resolve(childProcess) })
|
|
21
|
+
childProcess.on('error', (error) => { reject(error) })
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const { stdout } = this.childProcess
|
|
25
|
+
if (!stdout) { throw new Error('RecordKit RPC: No stdout stream on child process.') }
|
|
26
|
+
|
|
27
|
+
readline.createInterface({ input: stdout }).on('line', (line) => {
|
|
28
|
+
if (logMessages) {
|
|
29
|
+
console.log("< ", line.trimEnd());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.nsrpc.receive(line);
|
|
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
|
+
}
|
|
46
|
+
}
|