@nonstrict/recordkit 0.18.0 → 0.19.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 CHANGED
@@ -1 +1 @@
1
- # recordkit-rpc 0.18.0
1
+ # recordkit-rpc 0.19.0
package/bin/recordkit-rpc CHANGED
Binary file
@@ -1,4 +1,7 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
1
3
  import { Recorder, RecorderSchemaItem } from "./Recorder.js";
4
+ import { EventEmitter } from "stream";
2
5
  /**
3
6
  * Entry point for the RecordKit SDK, an instance is available as `recordkit` that can be imported from the module. Do not instantiate this class directly.
4
7
  *
@@ -11,7 +14,7 @@ import { Recorder, RecorderSchemaItem } from "./Recorder.js";
11
14
  * @groupDescription Logging
12
15
  * Log what's going on to the console for easy debugging and troubleshooting.
13
16
  */
14
- export declare class RecordKit {
17
+ export declare class RecordKit extends EventEmitter {
15
18
  private ipcRecordKit;
16
19
  /** @ignore */
17
20
  constructor();
package/out/RecordKit.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IpcRecordKit } from "./IpcRecordKit.js";
2
2
  import { Recorder } from "./Recorder.js";
3
+ import { EventEmitter } from "stream";
3
4
  import { existsSync } from "node:fs";
4
5
  /**
5
6
  * Entry point for the RecordKit SDK, an instance is available as `recordkit` that can be imported from the module. Do not instantiate this class directly.
@@ -13,10 +14,12 @@ import { existsSync } from "node:fs";
13
14
  * @groupDescription Logging
14
15
  * Log what's going on to the console for easy debugging and troubleshooting.
15
16
  */
16
- export class RecordKit {
17
+ export class RecordKit extends EventEmitter {
17
18
  ipcRecordKit = new IpcRecordKit();
18
19
  /** @ignore */
19
- constructor() { }
20
+ constructor() {
21
+ super();
22
+ }
20
23
  /**
21
24
  * Initialize the RecordKit SDK.
22
25
  *
@@ -34,7 +37,10 @@ export class RecordKit {
34
37
  }
35
38
  await this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
36
39
  const logHandlerInstance = this.ipcRecordKit.nsrpc.registerClosure({
37
- handler: (params) => { console.log('RecordKit:', params.formattedMessage); },
40
+ handler: (params) => {
41
+ console.log('RecordKit:', params.formattedMessage);
42
+ this.emit('log', params);
43
+ },
38
44
  prefix: 'RecordKit.logHandler',
39
45
  lifecycle: this
40
46
  });
@@ -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;;;;;;;;;;;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,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC/B,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,4DAA4D,EAAE,uCAAuC,CAAC,CAAA;gBAC5I,OAAO,CAAC,KAAK,CAAC,uEAAuE,aAAa,EAAE,CAAC,CAAA;YACvG,CAAC;QACH,CAAC;QAED,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;QAEtE,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,eAAe,CAAC;YACjE,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,gBAAgB,CAAC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ema = DisplaySingleFile | DisplaySegmented;
44
- interface DisplaySingleFile {
43
+ export type DisplaySchema = {
45
44
  type: 'display';
46
45
  display: Display | number;
47
46
  shows_cursor?: boolean;
@@ -50,8 +49,7 @@ interface DisplaySingleFile {
50
49
  include_audio?: boolean;
51
50
  output?: 'singleFile';
52
51
  filename?: string;
53
- }
54
- interface DisplaySegmented {
52
+ } | {
55
53
  type: 'display';
56
54
  display: Display | number;
57
55
  shows_cursor?: boolean;
@@ -61,12 +59,11 @@ interface DisplaySegmented {
61
59
  output: 'segmented';
62
60
  filenamePrefix?: string;
63
61
  segmentCallback?: (url: string) => void;
64
- }
62
+ };
65
63
  /**
66
64
  * @group Recording Schemas
67
65
  */
68
- export type WindowBasedCropSchema = WindowBasedCropSchemaSingleFile | WindowBasedCropSchemaSegmented;
69
- interface WindowBasedCropSchemaSingleFile {
66
+ export type WindowBasedCropSchema = {
70
67
  type: 'windowBasedCrop';
71
68
  window: Window | number;
72
69
  shows_cursor?: boolean;
@@ -74,8 +71,7 @@ interface WindowBasedCropSchemaSingleFile {
74
71
  keyboard_events?: boolean;
75
72
  output?: 'singleFile';
76
73
  filename?: string;
77
- }
78
- interface WindowBasedCropSchemaSegmented {
74
+ } | {
79
75
  type: 'windowBasedCrop';
80
76
  window: Window | number;
81
77
  shows_cursor?: boolean;
@@ -84,7 +80,7 @@ interface WindowBasedCropSchemaSegmented {
84
80
  output: 'segmented';
85
81
  filenamePrefix?: string;
86
82
  segmentCallback?: (url: string) => void;
87
- }
83
+ };
88
84
  /**
89
85
  * @group Recording Schemas
90
86
  */
@@ -129,4 +125,3 @@ export interface BundleInfo {
129
125
  filename: string;
130
126
  }[];
131
127
  }
132
- export {};
package/out/index.cjs CHANGED
@@ -341,10 +341,12 @@ class Recorder extends stream.EventEmitter {
341
341
  * @groupDescription Logging
342
342
  * Log what's going on to the console for easy debugging and troubleshooting.
343
343
  */
344
- class RecordKit {
344
+ class RecordKit extends stream.EventEmitter {
345
345
  ipcRecordKit = new IpcRecordKit();
346
346
  /** @ignore */
347
- constructor() { }
347
+ constructor() {
348
+ super();
349
+ }
348
350
  /**
349
351
  * Initialize the RecordKit SDK.
350
352
  *
@@ -362,7 +364,10 @@ class RecordKit {
362
364
  }
363
365
  await this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages);
364
366
  const logHandlerInstance = this.ipcRecordKit.nsrpc.registerClosure({
365
- handler: (params) => { console.log('RecordKit:', params.formattedMessage); },
367
+ handler: (params) => {
368
+ console.log('RecordKit:', params.formattedMessage);
369
+ this.emit('log', params);
370
+ },
366
371
  prefix: 'RecordKit.logHandler',
367
372
  lifecycle: this
368
373
  });
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(\"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 == 'display') {\n if (typeof item.display != 'number') {\n item.display = item.display.id;\n }\n if (item.output == 'segmented' && item.segmentCallback) {\n const segmentHandler = item.segmentCallback;\n item.segmentCallback = rpc.registerClosure({\n handler: (params) => { segmentHandler(params.path); },\n prefix: 'Display.onSegment',\n lifecycle: object\n });\n }\n }\n if (item.type == 'windowBasedCrop') {\n if (typeof item.window != 'number') {\n item.window = item.window.id;\n }\n if (item.output == 'segmented' && item.segmentCallback) {\n const segmentHandler = item.segmentCallback;\n item.segmentCallback = rpc.registerClosure({\n handler: (params) => { segmentHandler(params.path); },\n prefix: 'Window.onSegment',\n lifecycle: object\n });\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 getDisplays() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getDisplays' });\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,OAAO,EAAE,CAAC,CAAC;AAClE,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,KAAK,CAAC,qEAAqE,CAAC,CAAC;AACrG,aAAa;AACb,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,IAAI,QAAQ,IAAI,O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I,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;;;;"}
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(\"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 == 'display') {\n if (typeof item.display != 'number') {\n item.display = item.display.id;\n }\n if (item.output == 'segmented' && item.segmentCallback) {\n const segmentHandler = item.segmentCallback;\n item.segmentCallback = rpc.registerClosure({\n handler: (params) => { segmentHandler(params.path); },\n prefix: 'Display.onSegment',\n lifecycle: object\n });\n }\n }\n if (item.type == 'windowBasedCrop') {\n if (typeof item.window != 'number') {\n item.window = item.window.id;\n }\n if (item.output == 'segmented' && item.segmentCallback) {\n const segmentHandler = item.segmentCallback;\n item.segmentCallback = rpc.registerClosure({\n handler: (params) => { segmentHandler(params.path); },\n prefix: 'Window.onSegment',\n lifecycle: object\n });\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 { EventEmitter } from \"stream\";\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 extends EventEmitter {\n ipcRecordKit = new IpcRecordKit();\n /** @ignore */\n constructor() {\n super();\n }\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) => {\n console.log('RecordKit:', params.formattedMessage);\n this.emit('log', params);\n },\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 getDisplays() {\n return await this.ipcRecordKit.nsrpc.perform({ type: 'Recorder', action: 'getDisplays' });\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,C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;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nonstrict/recordkit",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Powerful screen recording for your Electron app on macOS.",
5
5
  "homepage": "https://nonstrict.eu/recordkit",
6
6
  "repository": "nonstrict-hq/RecordKit.Electron",
package/src/RecordKit.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IpcRecordKit } from "./IpcRecordKit.js";
2
2
  import { Recorder, RecorderSchemaItem } from "./Recorder.js";
3
+ import { EventEmitter } from "stream";
3
4
  import { existsSync } from "node:fs";
4
5
 
5
6
  /**
@@ -14,11 +15,13 @@ import { existsSync } from "node:fs";
14
15
  * @groupDescription Logging
15
16
  * Log what's going on to the console for easy debugging and troubleshooting.
16
17
  */
17
- export class RecordKit {
18
+ export class RecordKit extends EventEmitter {
18
19
  private ipcRecordKit = new IpcRecordKit()
19
20
 
20
21
  /** @ignore */
21
- constructor() { }
22
+ constructor() {
23
+ super()
24
+ }
22
25
 
23
26
  /**
24
27
  * Initialize the RecordKit SDK.
@@ -56,7 +59,10 @@ export class RecordKit {
56
59
  await this.ipcRecordKit.initialize(rpcBinaryPath, args.logRpcMessages)
57
60
 
58
61
  const logHandlerInstance = this.ipcRecordKit.nsrpc.registerClosure({
59
- handler: (params) => { console.log('RecordKit:', params.formattedMessage) },
62
+ handler: (params) => {
63
+ console.log('RecordKit:', params.formattedMessage)
64
+ this.emit('log', params)
65
+ },
60
66
  prefix: 'RecordKit.logHandler',
61
67
  lifecycle: this
62
68
  })
package/src/Recorder.ts CHANGED
@@ -126,9 +126,7 @@ export interface WebcamSchema {
126
126
  /**
127
127
  * @group Recording Schemas
128
128
  */
129
- export type DisplaySchema = DisplaySingleFile | DisplaySegmented
130
-
131
- interface DisplaySingleFile {
129
+ export type DisplaySchema = {
132
130
  type: 'display'
133
131
  display: Display | number // UInt32
134
132
  shows_cursor?: boolean
@@ -137,9 +135,7 @@ interface DisplaySingleFile {
137
135
  include_audio?: boolean
138
136
  output?: 'singleFile'
139
137
  filename?: string
140
- }
141
-
142
- interface DisplaySegmented {
138
+ } | {
143
139
  type: 'display'
144
140
  display: Display | number // UInt32
145
141
  shows_cursor?: boolean
@@ -154,9 +150,7 @@ interface DisplaySegmented {
154
150
  /**
155
151
  * @group Recording Schemas
156
152
  */
157
- export type WindowBasedCropSchema = WindowBasedCropSchemaSingleFile | WindowBasedCropSchemaSegmented
158
-
159
- interface WindowBasedCropSchemaSingleFile {
153
+ export type WindowBasedCropSchema = {
160
154
  type: 'windowBasedCrop'
161
155
  window: Window | number // UInt32
162
156
  shows_cursor?: boolean
@@ -164,9 +158,7 @@ interface WindowBasedCropSchemaSingleFile {
164
158
  keyboard_events?: boolean
165
159
  output?: 'singleFile'
166
160
  filename?: string
167
- }
168
-
169
- interface WindowBasedCropSchemaSegmented {
161
+ } | {
170
162
  type: 'windowBasedCrop'
171
163
  window: Window | number // UInt32
172
164
  shows_cursor?: boolean