@recallai/desktop-sdk 2024.1.29-7103406afedf9a84d60e110b15b96f741630f117 → 2024.2.1-0c0f140ff96917a5c30940d71d7fd0712780a89c
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/binding.gyp +11 -1
- package/desktop_sdk_macos.framework/Headers/desktop_sdk_macos-Swift.h +6 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo +0 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo +0 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.abi.json +587 -35
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.private.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.swiftmodule +0 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.abi.json +587 -35
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.private.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.swiftmodule +0 -0
- package/desktop_sdk_macos.framework/Versions/A/Headers/desktop_sdk_macos-Swift.h +6 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo +0 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo +0 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.abi.json +587 -35
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.private.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.swiftmodule +0 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.abi.json +587 -35
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.private.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/A/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.swiftmodule +0 -0
- package/desktop_sdk_macos.framework/Versions/A/desktop_sdk_macos +0 -0
- package/desktop_sdk_macos.framework/Versions/Current/Headers/desktop_sdk_macos-Swift.h +6 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo +0 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo +0 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.abi.json +587 -35
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.private.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/arm64-apple-macos.swiftmodule +0 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.abi.json +587 -35
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.private.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.swiftinterface +17 -0
- package/desktop_sdk_macos.framework/Versions/Current/Modules/desktop_sdk_macos.swiftmodule/x86_64-apple-macos.swiftmodule +0 -0
- package/desktop_sdk_macos.framework/Versions/Current/desktop_sdk_macos +0 -0
- package/desktop_sdk_macos.framework/desktop_sdk_macos +0 -0
- package/index.d.ts +5 -0
- package/index.js +8 -1
- package/package.json +6 -3
- package/src/RecallAiDesktopSdk.h +4 -1
- package/src/main.cc +82 -31
|
@@ -49,6 +49,9 @@ extension desktop_sdk_macos.ScreenShareFrame : Swift.Equatable {
|
|
|
49
49
|
public protocol AudioDeviceAudioDelegate {
|
|
50
50
|
func handleDeviceAudioBuffer(sampleBuffer: AVFAudio.AVAudioPCMBuffer)
|
|
51
51
|
}
|
|
52
|
+
public struct RecallAiSdkEvent {
|
|
53
|
+
public func serialize() -> Swift.String
|
|
54
|
+
}
|
|
52
55
|
public struct Meeting : Swift.CustomDebugStringConvertible, Swift.Equatable {
|
|
53
56
|
public var title: Swift.String?
|
|
54
57
|
public var meetingId: Swift.String?
|
|
@@ -83,11 +86,13 @@ public struct MeetingParticipant : Swift.CustomDebugStringConvertible, Swift.Equ
|
|
|
83
86
|
public class RecallAiDesktopSdk {
|
|
84
87
|
public init(config: desktop_sdk_macos.RecallAiDesktopSdkConfig)
|
|
85
88
|
public func toggle(enabled: Swift.Bool)
|
|
89
|
+
public func registerEventCallback(callback: @escaping (desktop_sdk_macos.RecallAiSdkEvent) -> Swift.Void)
|
|
86
90
|
public func installCameraExtension(extensionBundleIdentifier: Swift.String)
|
|
87
91
|
public func uninstallCameraExtension(extensionBundleIdentifier: Swift.String)
|
|
88
92
|
@objc deinit
|
|
89
93
|
}
|
|
90
94
|
public protocol MeetingAppMediaCapturerDelegate {
|
|
95
|
+
func handleMixedVideoBuffer(sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
91
96
|
func handleVideoBuffer(frameId: Swift.Int, sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
92
97
|
func handleSpeakerAudioBuffer(sampleBuffer: AVFAudio.AVAudioPCMBuffer)
|
|
93
98
|
}
|
|
@@ -105,8 +110,11 @@ public protocol MeetingAppMediaCapturerDelegate {
|
|
|
105
110
|
public func RecallAiSdkInit(configJson: Swift.UnsafePointer<Swift.Int8>)
|
|
106
111
|
@_cdecl("recallai_sdk_toggle")
|
|
107
112
|
public func RecallAiSdkToggle(enabled: Swift.Bool)
|
|
113
|
+
@_cdecl("recallai_sdk_register_callback")
|
|
114
|
+
public func RecallAiSdkRegisterCallback(callback: Swift.UnsafeRawPointer, userData: Swift.UnsafeMutableRawPointer)
|
|
108
115
|
public struct UiElementSelector {
|
|
109
116
|
public var title: Swift.String?
|
|
117
|
+
public var titleContains: Swift.String?
|
|
110
118
|
public var desc: Swift.String?
|
|
111
119
|
public var descContains: Swift.String?
|
|
112
120
|
public var label: Swift.String?
|
|
@@ -168,6 +176,7 @@ extension ApplicationServices.AXUIElement {
|
|
|
168
176
|
}
|
|
169
177
|
public func getAttribute<T>(attribute: Swift.String) -> T?
|
|
170
178
|
public func getFrameRelativeTo(root: ApplicationServices.AXUIElement) -> CoreFoundation.CGRect?
|
|
179
|
+
public func getProportionalFrameRelativeTo(root: ApplicationServices.AXUIElement) -> CoreFoundation.CGRect?
|
|
171
180
|
public func getCGWindowId() -> CoreGraphics.CGWindowID?
|
|
172
181
|
public func click()
|
|
173
182
|
}
|
|
@@ -187,6 +196,7 @@ public class ZoomMeetingRecorder : desktop_sdk_macos.MeetingAppMediaCapturerDele
|
|
|
187
196
|
public func start()
|
|
188
197
|
public func updateMainWindows(windows: [ApplicationServices.AXUIElement])
|
|
189
198
|
public func end()
|
|
199
|
+
public func handleMixedVideoBuffer(sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
190
200
|
public func handleVideoBuffer(frameId: Swift.Int, sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
191
201
|
public func handleScreenBuffer(sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
192
202
|
public func handleDeviceAudioBuffer(sampleBuffer: AVFAudio.AVAudioPCMBuffer)
|
|
@@ -194,6 +204,11 @@ public class ZoomMeetingRecorder : desktop_sdk_macos.MeetingAppMediaCapturerDele
|
|
|
194
204
|
public func handleActiveSpeakerChange(streamId: Swift.Int?)
|
|
195
205
|
@objc deinit
|
|
196
206
|
}
|
|
207
|
+
public struct MixedVideoRect : Swift.Codable, Swift.Equatable {
|
|
208
|
+
public static func == (a: desktop_sdk_macos.MixedVideoRect, b: desktop_sdk_macos.MixedVideoRect) -> Swift.Bool
|
|
209
|
+
public func encode(to encoder: Swift.Encoder) throws
|
|
210
|
+
public init(from decoder: Swift.Decoder) throws
|
|
211
|
+
}
|
|
197
212
|
public class MeetingRecorder {
|
|
198
213
|
public init(config: desktop_sdk_macos.RecallAiDesktopSdkConfig)
|
|
199
214
|
public func start(title: Swift.String, meetingId: Swift.String?, platform: Swift.String)
|
|
@@ -208,6 +223,8 @@ public class MeetingRecorder {
|
|
|
208
223
|
public func screenShareStarted()
|
|
209
224
|
public func screenShareStopped()
|
|
210
225
|
public func handleActiveSpeakerChange(participantId: Swift.Int?)
|
|
226
|
+
public func setMixedVideoRects(rects: [desktop_sdk_macos.MixedVideoRect])
|
|
227
|
+
public func handleMixedVideoBuffer(buffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
211
228
|
public func handleVideoBuffer(participantId: Swift.Int, buffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
212
229
|
public func handleScreenBuffer(buffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
213
230
|
public func handleAudioBuffer(streamId: Swift.Int, buffer: AVFAudio.AVAudioPCMBuffer)
|
|
@@ -49,6 +49,9 @@ extension desktop_sdk_macos.ScreenShareFrame : Swift.Equatable {
|
|
|
49
49
|
public protocol AudioDeviceAudioDelegate {
|
|
50
50
|
func handleDeviceAudioBuffer(sampleBuffer: AVFAudio.AVAudioPCMBuffer)
|
|
51
51
|
}
|
|
52
|
+
public struct RecallAiSdkEvent {
|
|
53
|
+
public func serialize() -> Swift.String
|
|
54
|
+
}
|
|
52
55
|
public struct Meeting : Swift.CustomDebugStringConvertible, Swift.Equatable {
|
|
53
56
|
public var title: Swift.String?
|
|
54
57
|
public var meetingId: Swift.String?
|
|
@@ -83,11 +86,13 @@ public struct MeetingParticipant : Swift.CustomDebugStringConvertible, Swift.Equ
|
|
|
83
86
|
public class RecallAiDesktopSdk {
|
|
84
87
|
public init(config: desktop_sdk_macos.RecallAiDesktopSdkConfig)
|
|
85
88
|
public func toggle(enabled: Swift.Bool)
|
|
89
|
+
public func registerEventCallback(callback: @escaping (desktop_sdk_macos.RecallAiSdkEvent) -> Swift.Void)
|
|
86
90
|
public func installCameraExtension(extensionBundleIdentifier: Swift.String)
|
|
87
91
|
public func uninstallCameraExtension(extensionBundleIdentifier: Swift.String)
|
|
88
92
|
@objc deinit
|
|
89
93
|
}
|
|
90
94
|
public protocol MeetingAppMediaCapturerDelegate {
|
|
95
|
+
func handleMixedVideoBuffer(sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
91
96
|
func handleVideoBuffer(frameId: Swift.Int, sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
92
97
|
func handleSpeakerAudioBuffer(sampleBuffer: AVFAudio.AVAudioPCMBuffer)
|
|
93
98
|
}
|
|
@@ -105,8 +110,11 @@ public protocol MeetingAppMediaCapturerDelegate {
|
|
|
105
110
|
public func RecallAiSdkInit(configJson: Swift.UnsafePointer<Swift.Int8>)
|
|
106
111
|
@_cdecl("recallai_sdk_toggle")
|
|
107
112
|
public func RecallAiSdkToggle(enabled: Swift.Bool)
|
|
113
|
+
@_cdecl("recallai_sdk_register_callback")
|
|
114
|
+
public func RecallAiSdkRegisterCallback(callback: Swift.UnsafeRawPointer, userData: Swift.UnsafeMutableRawPointer)
|
|
108
115
|
public struct UiElementSelector {
|
|
109
116
|
public var title: Swift.String?
|
|
117
|
+
public var titleContains: Swift.String?
|
|
110
118
|
public var desc: Swift.String?
|
|
111
119
|
public var descContains: Swift.String?
|
|
112
120
|
public var label: Swift.String?
|
|
@@ -168,6 +176,7 @@ extension ApplicationServices.AXUIElement {
|
|
|
168
176
|
}
|
|
169
177
|
public func getAttribute<T>(attribute: Swift.String) -> T?
|
|
170
178
|
public func getFrameRelativeTo(root: ApplicationServices.AXUIElement) -> CoreFoundation.CGRect?
|
|
179
|
+
public func getProportionalFrameRelativeTo(root: ApplicationServices.AXUIElement) -> CoreFoundation.CGRect?
|
|
171
180
|
public func getCGWindowId() -> CoreGraphics.CGWindowID?
|
|
172
181
|
public func click()
|
|
173
182
|
}
|
|
@@ -187,6 +196,7 @@ public class ZoomMeetingRecorder : desktop_sdk_macos.MeetingAppMediaCapturerDele
|
|
|
187
196
|
public func start()
|
|
188
197
|
public func updateMainWindows(windows: [ApplicationServices.AXUIElement])
|
|
189
198
|
public func end()
|
|
199
|
+
public func handleMixedVideoBuffer(sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
190
200
|
public func handleVideoBuffer(frameId: Swift.Int, sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
191
201
|
public func handleScreenBuffer(sampleBuffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
192
202
|
public func handleDeviceAudioBuffer(sampleBuffer: AVFAudio.AVAudioPCMBuffer)
|
|
@@ -194,6 +204,11 @@ public class ZoomMeetingRecorder : desktop_sdk_macos.MeetingAppMediaCapturerDele
|
|
|
194
204
|
public func handleActiveSpeakerChange(streamId: Swift.Int?)
|
|
195
205
|
@objc deinit
|
|
196
206
|
}
|
|
207
|
+
public struct MixedVideoRect : Swift.Codable, Swift.Equatable {
|
|
208
|
+
public static func == (a: desktop_sdk_macos.MixedVideoRect, b: desktop_sdk_macos.MixedVideoRect) -> Swift.Bool
|
|
209
|
+
public func encode(to encoder: Swift.Encoder) throws
|
|
210
|
+
public init(from decoder: Swift.Decoder) throws
|
|
211
|
+
}
|
|
197
212
|
public class MeetingRecorder {
|
|
198
213
|
public init(config: desktop_sdk_macos.RecallAiDesktopSdkConfig)
|
|
199
214
|
public func start(title: Swift.String, meetingId: Swift.String?, platform: Swift.String)
|
|
@@ -208,6 +223,8 @@ public class MeetingRecorder {
|
|
|
208
223
|
public func screenShareStarted()
|
|
209
224
|
public func screenShareStopped()
|
|
210
225
|
public func handleActiveSpeakerChange(participantId: Swift.Int?)
|
|
226
|
+
public func setMixedVideoRects(rects: [desktop_sdk_macos.MixedVideoRect])
|
|
227
|
+
public func handleMixedVideoBuffer(buffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
211
228
|
public func handleVideoBuffer(participantId: Swift.Int, buffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
212
229
|
public func handleScreenBuffer(buffer: CoreVideo.CVPixelBuffer, presTime: CoreMedia.CMTime)
|
|
213
230
|
public func handleAudioBuffer(streamId: Swift.Int, buffer: AVFAudio.AVAudioPCMBuffer)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
declare module '@recallai/desktop-sdk' {
|
|
2
2
|
export function init(config: RecallAiSdkConfig): void;
|
|
3
3
|
export function toggle(enabled: boolean): void;
|
|
4
|
+
export function callback(callback: (event: RecallAiSdkEvent) => void): void;
|
|
4
5
|
|
|
5
6
|
interface RecallAiSdkConfig {
|
|
6
7
|
api_key: string
|
|
7
8
|
recording_config: RecordingConfig
|
|
8
9
|
}
|
|
10
|
+
|
|
11
|
+
interface RecallAiSdkEvent {
|
|
12
|
+
type: "recording_start" | "recording_stop"
|
|
13
|
+
}
|
|
9
14
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recallai/desktop-sdk",
|
|
3
|
-
"version": "2024.01
|
|
3
|
+
"version": "2024.02.01-0c0f140ff96917a5c30940d71d7fd0712780a89c",
|
|
4
4
|
"description": "Recall Desktop SDK (Alpha)",
|
|
5
5
|
"gypfile": true,
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
|
-
"dependencies": {
|
|
9
|
-
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"node-addon-api": "7.1.0",
|
|
10
|
+
"node-addon-api": "^7.1.0"
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/RecallAiDesktopSdk.h
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
void
|
|
1
|
+
typedef void (*recallai_sdk_event_callback)(const char* event, void* userdata);
|
|
2
|
+
|
|
3
|
+
void recallai_sdk_init(const char* configJson);
|
|
2
4
|
void recallai_sdk_toggle(bool enabled);
|
|
5
|
+
void recallai_sdk_register_callback(recallai_sdk_event_callback callback, void* userdata);
|
package/src/main.cc
CHANGED
|
@@ -1,47 +1,98 @@
|
|
|
1
|
-
#include <
|
|
1
|
+
#include <napi.h>
|
|
2
2
|
|
|
3
|
-
extern "C"
|
|
4
|
-
|
|
3
|
+
extern "C"
|
|
4
|
+
{
|
|
5
|
+
#include "RecallAiDesktopSdk.h"
|
|
5
6
|
}
|
|
6
7
|
|
|
8
|
+
using Napi::Function;
|
|
9
|
+
using Napi::Object;
|
|
10
|
+
using Napi::Persistent;
|
|
11
|
+
using Napi::Reference;
|
|
12
|
+
using Napi::String;
|
|
13
|
+
using Napi::Value;
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
void SdkInit(const FunctionCallbackInfo<Value>& args) {
|
|
16
|
-
Isolate* isolate = args.GetIsolate();
|
|
17
|
-
if (args.Length() < 1) {
|
|
18
|
-
isolate->ThrowException(v8::Exception::TypeError(
|
|
19
|
-
String::NewFromUtf8(isolate, "Wrong number of arguments").ToLocalChecked()));
|
|
15
|
+
void SdkInit(const Napi::CallbackInfo &args)
|
|
16
|
+
{
|
|
17
|
+
Napi::Env env = args.Env();
|
|
18
|
+
if (args.Length() < 1)
|
|
19
|
+
{
|
|
20
|
+
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
String
|
|
24
|
-
|
|
25
|
-
recallai_sdk_init(cstr);
|
|
26
|
-
args.GetReturnValue().Set(Undefined(isolate));
|
|
23
|
+
|
|
24
|
+
Napi::String str(env, args[0]);
|
|
25
|
+
std::string cstr = str.Utf8Value();
|
|
26
|
+
recallai_sdk_init(cstr.data());
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
void SdkToggle(const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
void SdkToggle(const Napi::CallbackInfo &args)
|
|
30
|
+
{
|
|
31
|
+
Napi::Env env = args.Env();
|
|
32
|
+
if (args.Length() < 1)
|
|
33
|
+
{
|
|
34
|
+
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
bool enabled = args[0]
|
|
38
|
+
bool enabled = args[0].As<Napi::Boolean>();
|
|
38
39
|
recallai_sdk_toggle(enabled);
|
|
39
|
-
args.GetReturnValue().Set(Undefined(isolate));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
struct EventUserData
|
|
43
|
+
{
|
|
44
|
+
Napi::ThreadSafeFunction callback;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
void SdkHandleEvent(const char *event, void *userdata)
|
|
48
|
+
{
|
|
49
|
+
EventUserData *data = (EventUserData *)userdata;
|
|
50
|
+
data->callback.BlockingCall(event, [](Napi::Env env, Napi::Function jsCallback, const char *event)
|
|
51
|
+
{ jsCallback.Call({Napi::String::New(env, event)}); });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void SdkRegisterEventCallback(const Napi::CallbackInfo &args)
|
|
55
|
+
{
|
|
56
|
+
Napi::Env env = args.Env();
|
|
57
|
+
if (args.Length() < 1)
|
|
58
|
+
{
|
|
59
|
+
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!args[0].IsFunction())
|
|
64
|
+
{
|
|
65
|
+
Napi::TypeError::New(env, "First argument must be a function").ThrowAsJavaScriptException();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Reference<Value> *context = new Reference<Value>(Persistent(args.This()));
|
|
70
|
+
|
|
71
|
+
EventUserData *userdata = new EventUserData();
|
|
72
|
+
userdata->callback = Napi::ThreadSafeFunction::New(
|
|
73
|
+
env,
|
|
74
|
+
args[0].As<Napi::Function>(),
|
|
75
|
+
"RecallAiSdkCallback", // Resource name
|
|
76
|
+
0, // Max queue size (0 = unlimited).
|
|
77
|
+
1, // Initial thread count
|
|
78
|
+
context, // Context,
|
|
79
|
+
[](Napi::Env,
|
|
80
|
+
Reference<Value> *ctx) { // Finalizer used to clean threads up
|
|
81
|
+
delete ctx;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
recallai_sdk_register_callback(SdkHandleEvent, userdata);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Napi::Object Init(Napi::Env env, Napi::Object exports)
|
|
88
|
+
{
|
|
89
|
+
exports.Set(Napi::String::New(env, "init"),
|
|
90
|
+
Napi::Function::New(env, SdkInit));
|
|
91
|
+
exports.Set(Napi::String::New(env, "toggle"),
|
|
92
|
+
Napi::Function::New(env, SdkToggle));
|
|
93
|
+
exports.Set(Napi::String::New(env, "callback"),
|
|
94
|
+
Napi::Function::New(env, SdkRegisterEventCallback));
|
|
95
|
+
return exports;
|
|
45
96
|
}
|
|
46
97
|
|
|
47
|
-
|
|
98
|
+
NODE_API_MODULE(hello, Init)
|