obi-sdk 0.1.1 → 0.1.2
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/README.md +57 -9
- package/dist/modular/chunks/index-634e0df5.js +4364 -0
- package/dist/modular/chunks/index-634e0df5.js.map +1 -0
- package/dist/modular/chunks/session-e208b5bb.js +22168 -0
- package/dist/modular/chunks/session-e208b5bb.js.map +1 -0
- package/dist/modular/core.js +210 -0
- package/dist/modular/core.js.map +1 -0
- package/dist/modular/index.js +411 -0
- package/dist/modular/index.js.map +1 -0
- package/dist/modular/ui.js +2215 -0
- package/dist/modular/ui.js.map +1 -0
- package/dist/obi-loader.iife.js +2 -0
- package/dist/obi-loader.iife.js.map +1 -0
- package/dist/obi-loader.js +83 -0
- package/dist/obi-loader.js.map +1 -0
- package/dist/obi-loader.umd.cjs +2 -0
- package/dist/obi-loader.umd.cjs.map +1 -0
- package/dist/obi-sdk.standalone.iife.js +634 -0
- package/dist/obi-sdk.standalone.iife.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { S as SDKState, O as ObiSDKConfigSchema, E as EventType } from "./chunks/index-634e0df5.js";
|
|
2
|
+
import { m as mitt } from "./chunks/session-e208b5bb.js";
|
|
3
|
+
import { O } from "./chunks/session-e208b5bb.js";
|
|
4
|
+
class ObiSDK {
|
|
5
|
+
constructor(config = {}) {
|
|
6
|
+
this.state = SDKState.READY;
|
|
7
|
+
this.emitter = mitt();
|
|
8
|
+
this.voiceEnabled = false;
|
|
9
|
+
this.screenCaptureEnabled = false;
|
|
10
|
+
this.config = ObiSDKConfigSchema.parse(config);
|
|
11
|
+
if (this.config.debug) {
|
|
12
|
+
console.log("ObiSDK initialized with config:", this.config);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async init() {
|
|
16
|
+
try {
|
|
17
|
+
if (this.config.enableVoice) {
|
|
18
|
+
await this.initVoice();
|
|
19
|
+
}
|
|
20
|
+
if (this.config.enableScreenCapture) {
|
|
21
|
+
await this.initScreenCapture();
|
|
22
|
+
}
|
|
23
|
+
this.setState(SDKState.READY);
|
|
24
|
+
this.emitter.emit(EventType.READY);
|
|
25
|
+
if (this.config.debug) {
|
|
26
|
+
console.log("ObiSDK ready");
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
const sdkError = {
|
|
30
|
+
code: "init_failed",
|
|
31
|
+
message: "Failed to initialize SDK",
|
|
32
|
+
details: error
|
|
33
|
+
};
|
|
34
|
+
this.handleError(sdkError);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async initVoice() {
|
|
38
|
+
if (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia) {
|
|
39
|
+
throw new Error("Voice recording not supported in this browser");
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
await window.navigator.mediaDevices.getUserMedia({ audio: true });
|
|
43
|
+
this.voiceEnabled = true;
|
|
44
|
+
if (this.config.debug) {
|
|
45
|
+
console.log("Voice capabilities initialized");
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new Error(`Microphone access denied: ${error}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async initScreenCapture() {
|
|
52
|
+
if (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getDisplayMedia) {
|
|
53
|
+
throw new Error("Screen capture not supported in this browser");
|
|
54
|
+
}
|
|
55
|
+
this.screenCaptureEnabled = true;
|
|
56
|
+
if (this.config.debug) {
|
|
57
|
+
console.log("Screen capture capabilities initialized");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Set the SDK state and emit state change event
|
|
62
|
+
*/
|
|
63
|
+
setState(newState) {
|
|
64
|
+
this.state = newState;
|
|
65
|
+
this.emitter.emit(EventType.STATE_CHANGE, newState);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handle SDK errors
|
|
69
|
+
*/
|
|
70
|
+
handleError(error) {
|
|
71
|
+
this.setState(SDKState.ERROR);
|
|
72
|
+
this.emitter.emit(EventType.ERROR, error);
|
|
73
|
+
if (this.config.debug) {
|
|
74
|
+
console.error("ObiSDK error:", error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Start voice recording
|
|
79
|
+
*/
|
|
80
|
+
async startVoiceRecording() {
|
|
81
|
+
if (!this.voiceEnabled) {
|
|
82
|
+
this.handleError({
|
|
83
|
+
code: "voice_disabled",
|
|
84
|
+
message: "Voice recording is not enabled or available"
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
this.setState(SDKState.AGENT_SPEAKING);
|
|
90
|
+
this.emitter.emit(EventType.VOICE_START);
|
|
91
|
+
if (this.config.debug) {
|
|
92
|
+
console.log("Voice recording started");
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
this.handleError({
|
|
96
|
+
code: "voice_start_failed",
|
|
97
|
+
message: "Failed to start voice recording",
|
|
98
|
+
details: error
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Stop voice recording
|
|
104
|
+
*/
|
|
105
|
+
async stopVoiceRecording() {
|
|
106
|
+
if (this.state === SDKState.READY) {
|
|
107
|
+
return { transcript: void 0 };
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const result = { transcript: "Sample transcript" };
|
|
111
|
+
this.setState(SDKState.READY);
|
|
112
|
+
this.emitter.emit(EventType.VOICE_STOP, result);
|
|
113
|
+
if (this.config.debug) {
|
|
114
|
+
console.log("Voice recording stopped:", result);
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
this.handleError({
|
|
119
|
+
code: "voice_stop_failed",
|
|
120
|
+
message: "Failed to stop voice recording",
|
|
121
|
+
details: error
|
|
122
|
+
});
|
|
123
|
+
return { transcript: void 0 };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Start screen capture
|
|
128
|
+
*/
|
|
129
|
+
async startScreenCapture() {
|
|
130
|
+
if (!this.screenCaptureEnabled) {
|
|
131
|
+
this.handleError({
|
|
132
|
+
code: "screen_capture_disabled",
|
|
133
|
+
message: "Screen capture is not enabled or available"
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
this.setState(SDKState.AGENT_SPEAKING);
|
|
139
|
+
this.emitter.emit(EventType.SCREEN_CAPTURE_START);
|
|
140
|
+
if (this.config.debug) {
|
|
141
|
+
console.log("Screen capture started");
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
this.handleError({
|
|
145
|
+
code: "screen_capture_start_failed",
|
|
146
|
+
message: "Failed to start screen capture",
|
|
147
|
+
details: error
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Stop screen capture
|
|
153
|
+
*/
|
|
154
|
+
async stopScreenCapture() {
|
|
155
|
+
if (this.state === SDKState.READY) {
|
|
156
|
+
return { screenshot: void 0 };
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
const result = { screenshot: "data:image/png;base64,..." };
|
|
160
|
+
this.setState(SDKState.READY);
|
|
161
|
+
this.emitter.emit(EventType.SCREEN_CAPTURE_STOP, result);
|
|
162
|
+
if (this.config.debug) {
|
|
163
|
+
console.log("Screen capture stopped");
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
this.handleError({
|
|
168
|
+
code: "screen_capture_stop_failed",
|
|
169
|
+
message: "Failed to stop screen capture",
|
|
170
|
+
details: error
|
|
171
|
+
});
|
|
172
|
+
return { screenshot: void 0 };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Subscribe to SDK events
|
|
177
|
+
*/
|
|
178
|
+
on(event, handler) {
|
|
179
|
+
this.emitter.on(event, handler);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Unsubscribe from SDK events
|
|
183
|
+
*/
|
|
184
|
+
off(event, handler) {
|
|
185
|
+
this.emitter.off(event, handler);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get current SDK state
|
|
189
|
+
*/
|
|
190
|
+
getState() {
|
|
191
|
+
return this.state;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Cleanup and dispose SDK resources
|
|
195
|
+
*/
|
|
196
|
+
dispose() {
|
|
197
|
+
this.emitter.all.clear();
|
|
198
|
+
if (this.config.debug) {
|
|
199
|
+
console.log("ObiSDK disposed");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
export {
|
|
204
|
+
EventType,
|
|
205
|
+
ObiSDK,
|
|
206
|
+
ObiSDKConfigSchema,
|
|
207
|
+
O as ObiSession,
|
|
208
|
+
SDKState
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../src/core/sdk.ts"],"sourcesContent":["import mitt from \"mitt\"\n\nimport { EventType, ObiError, ObiSDKConfig, ObiSDKConfigSchema, SDKState } from \"./types\"\n\ntype Events = {\n [EventType.READY]: void\n [EventType.ERROR]: ObiError\n [EventType.VOICE_START]: void\n [EventType.VOICE_STOP]: { transcript?: string }\n [EventType.SCREEN_CAPTURE_START]: void\n [EventType.SCREEN_CAPTURE_STOP]: { screenshot?: string }\n [EventType.STATE_CHANGE]: SDKState\n}\n\nexport class ObiSDK {\n private config: ObiSDKConfig\n private state: SDKState = SDKState.READY\n private emitter = mitt<Events>()\n private voiceEnabled = false\n private screenCaptureEnabled = false\n\n constructor(config: Partial<ObiSDKConfig> = {}) {\n this.config = ObiSDKConfigSchema.parse(config)\n\n if (this.config.debug) {\n console.log(\"ObiSDK initialized with config:\", this.config)\n }\n }\n\n async init(): Promise<void> {\n try {\n if (this.config.enableVoice) {\n await this.initVoice()\n }\n\n if (this.config.enableScreenCapture) {\n await this.initScreenCapture()\n }\n\n this.setState(SDKState.READY)\n this.emitter.emit(EventType.READY)\n\n if (this.config.debug) {\n console.log(\"ObiSDK ready\")\n }\n } catch (error) {\n const sdkError: ObiError = {\n code: \"init_failed\",\n message: \"Failed to initialize SDK\",\n details: error,\n }\n this.handleError(sdkError)\n }\n }\n\n private async initVoice(): Promise<void> {\n // Check if browser supports required voice APIs\n if (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia) {\n throw new Error(\"Voice recording not supported in this browser\")\n }\n\n try {\n // Request microphone permissions\n await window.navigator.mediaDevices.getUserMedia({ audio: true })\n this.voiceEnabled = true\n\n if (this.config.debug) {\n console.log(\"Voice capabilities initialized\")\n }\n } catch (error) {\n throw new Error(`Microphone access denied: ${error}`)\n }\n }\n\n private async initScreenCapture(): Promise<void> {\n // Check if browser supports required screen capture APIs\n if (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getDisplayMedia) {\n throw new Error(\"Screen capture not supported in this browser\")\n }\n\n this.screenCaptureEnabled = true\n\n if (this.config.debug) {\n console.log(\"Screen capture capabilities initialized\")\n }\n }\n\n /**\n * Set the SDK state and emit state change event\n */\n private setState(newState: SDKState): void {\n this.state = newState\n this.emitter.emit(EventType.STATE_CHANGE, newState)\n }\n\n /**\n * Handle SDK errors\n */\n private handleError(error: ObiError): void {\n this.setState(SDKState.ERROR)\n this.emitter.emit(EventType.ERROR, error)\n\n if (this.config.debug) {\n console.error(\"ObiSDK error:\", error)\n }\n }\n\n /**\n * Start voice recording\n */\n async startVoiceRecording(): Promise<void> {\n if (!this.voiceEnabled) {\n this.handleError({\n code: \"voice_disabled\",\n message: \"Voice recording is not enabled or available\",\n })\n return\n }\n\n try {\n this.setState(SDKState.AGENT_SPEAKING)\n this.emitter.emit(EventType.VOICE_START)\n\n if (this.config.debug) {\n console.log(\"Voice recording started\")\n }\n } catch (error) {\n this.handleError({\n code: \"voice_start_failed\",\n message: \"Failed to start voice recording\",\n details: error,\n })\n }\n }\n\n /**\n * Stop voice recording\n */\n async stopVoiceRecording(): Promise<{ transcript?: string }> {\n if (this.state === SDKState.READY) {\n return { transcript: undefined }\n }\n\n try {\n const result = { transcript: \"Sample transcript\" } // Placeholder for real implementation\n\n this.setState(SDKState.READY)\n this.emitter.emit(EventType.VOICE_STOP, result)\n\n if (this.config.debug) {\n console.log(\"Voice recording stopped:\", result)\n }\n\n return result\n } catch (error) {\n this.handleError({\n code: \"voice_stop_failed\",\n message: \"Failed to stop voice recording\",\n details: error,\n })\n return { transcript: undefined }\n }\n }\n\n /**\n * Start screen capture\n */\n async startScreenCapture(): Promise<void> {\n if (!this.screenCaptureEnabled) {\n this.handleError({\n code: \"screen_capture_disabled\",\n message: \"Screen capture is not enabled or available\",\n })\n return\n }\n\n try {\n this.setState(SDKState.AGENT_SPEAKING)\n this.emitter.emit(EventType.SCREEN_CAPTURE_START)\n\n if (this.config.debug) {\n console.log(\"Screen capture started\")\n }\n } catch (error) {\n this.handleError({\n code: \"screen_capture_start_failed\",\n message: \"Failed to start screen capture\",\n details: error,\n })\n }\n }\n\n /**\n * Stop screen capture\n */\n async stopScreenCapture(): Promise<{ screenshot?: string }> {\n if (this.state === SDKState.READY) {\n return { screenshot: undefined }\n }\n\n try {\n const result = { screenshot: \"data:image/png;base64,...\" } // Placeholder for real implementation\n\n this.setState(SDKState.READY)\n this.emitter.emit(EventType.SCREEN_CAPTURE_STOP, result)\n\n if (this.config.debug) {\n console.log(\"Screen capture stopped\")\n }\n\n return result\n } catch (error) {\n this.handleError({\n code: \"screen_capture_stop_failed\",\n message: \"Failed to stop screen capture\",\n details: error,\n })\n return { screenshot: undefined }\n }\n }\n\n /**\n * Subscribe to SDK events\n */\n on<E extends EventType>(event: E, handler: (data: Events[E]) => void): void {\n this.emitter.on(event, handler as any)\n }\n\n /**\n * Unsubscribe from SDK events\n */\n off<E extends EventType>(event: E, handler: (data: Events[E]) => void): void {\n this.emitter.off(event, handler as any)\n }\n\n /**\n * Get current SDK state\n */\n getState(): SDKState {\n return this.state\n }\n\n /**\n * Cleanup and dispose SDK resources\n */\n dispose(): void {\n this.emitter.all.clear()\n\n if (this.config.debug) {\n console.log(\"ObiSDK disposed\")\n }\n }\n}\n"],"names":[],"mappings":";;;AAcO,MAAM,OAAO;AAAA,EAOlB,YAAY,SAAgC,IAAI;AALhD,SAAQ,QAAkB,SAAS;AACnC,SAAQ,UAAU;AAClB,SAAQ,eAAe;AACvB,SAAQ,uBAAuB;AAGxB,SAAA,SAAS,mBAAmB,MAAM,MAAM;AAEzC,QAAA,KAAK,OAAO,OAAO;AACb,cAAA,IAAI,mCAAmC,KAAK,MAAM;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,MAAM,OAAsB;AACtB,QAAA;AACE,UAAA,KAAK,OAAO,aAAa;AAC3B,cAAM,KAAK;MACb;AAEI,UAAA,KAAK,OAAO,qBAAqB;AACnC,cAAM,KAAK;MACb;AAEK,WAAA,SAAS,SAAS,KAAK;AACvB,WAAA,QAAQ,KAAK,UAAU,KAAK;AAE7B,UAAA,KAAK,OAAO,OAAO;AACrB,gBAAQ,IAAI,cAAc;AAAA,MAC5B;AAAA,aACO,OAAO;AACd,YAAM,WAAqB;AAAA,QACzB,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAEX,WAAK,YAAY,QAAQ;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,MAAc,YAA2B;AAEnC,QAAA,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,UAAU,aAAa,cAAc;AAC3E,YAAA,IAAI,MAAM,+CAA+C;AAAA,IACjE;AAEI,QAAA;AAEF,YAAM,OAAO,UAAU,aAAa,aAAa,EAAE,OAAO,MAAM;AAChE,WAAK,eAAe;AAEhB,UAAA,KAAK,OAAO,OAAO;AACrB,gBAAQ,IA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AAAA;AAAA;AAAA,EAKA,GAAwB,OAAU,SAA0C;AACrE,SAAA,QAAQ,GAAG,OAAO,OAAc;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAyB,OAAU,SAA0C;AACtE,SAAA,QAAQ,IAAI,OAAO,OAAc;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA,EAKA,WAAqB;AACnB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACT,SAAA,QAAQ,IAAI;AAEb,QAAA,KAAK,OAAO,OAAO;AACrB,cAAQ,IAAI,iBAAiB;AAAA,IAC/B;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { S as SDKState, E as EventType } from "./chunks/index-634e0df5.js";
|
|
2
|
+
import { O } from "./chunks/index-634e0df5.js";
|
|
3
|
+
import { ObiSDK } from "./core.js";
|
|
4
|
+
import { O as O2 } from "./chunks/session-e208b5bb.js";
|
|
5
|
+
import { AudioEqualizer, Course, CourseList, CourseModal, DotLoader, NavIcon, NavigationBar, ObiControlPanel, ObiStatusWidget, ObiWidget, SearchingLoader, defineCustomElements } from "./ui.js";
|
|
6
|
+
function getDefaultExportFromCjs(x2) {
|
|
7
|
+
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
8
|
+
}
|
|
9
|
+
var react = { exports: {} };
|
|
10
|
+
var react_production_min = {};
|
|
11
|
+
var l = Symbol.for("react.element"), n = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), q = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), t = Symbol.for("react.provider"), u = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), x = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), z = Symbol.iterator;
|
|
12
|
+
function A(a) {
|
|
13
|
+
if (null === a || "object" !== typeof a)
|
|
14
|
+
return null;
|
|
15
|
+
a = z && a[z] || a["@@iterator"];
|
|
16
|
+
return "function" === typeof a ? a : null;
|
|
17
|
+
}
|
|
18
|
+
var B = { isMounted: function() {
|
|
19
|
+
return false;
|
|
20
|
+
}, enqueueForceUpdate: function() {
|
|
21
|
+
}, enqueueReplaceState: function() {
|
|
22
|
+
}, enqueueSetState: function() {
|
|
23
|
+
} }, C = Object.assign, D = {};
|
|
24
|
+
function E(a, b, e) {
|
|
25
|
+
this.props = a;
|
|
26
|
+
this.context = b;
|
|
27
|
+
this.refs = D;
|
|
28
|
+
this.updater = e || B;
|
|
29
|
+
}
|
|
30
|
+
E.prototype.isReactComponent = {};
|
|
31
|
+
E.prototype.setState = function(a, b) {
|
|
32
|
+
if ("object" !== typeof a && "function" !== typeof a && null != a)
|
|
33
|
+
throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
|
34
|
+
this.updater.enqueueSetState(this, a, b, "setState");
|
|
35
|
+
};
|
|
36
|
+
E.prototype.forceUpdate = function(a) {
|
|
37
|
+
this.updater.enqueueForceUpdate(this, a, "forceUpdate");
|
|
38
|
+
};
|
|
39
|
+
function F() {
|
|
40
|
+
}
|
|
41
|
+
F.prototype = E.prototype;
|
|
42
|
+
function G(a, b, e) {
|
|
43
|
+
this.props = a;
|
|
44
|
+
this.context = b;
|
|
45
|
+
this.refs = D;
|
|
46
|
+
this.updater = e || B;
|
|
47
|
+
}
|
|
48
|
+
var H = G.prototype = new F();
|
|
49
|
+
H.constructor = G;
|
|
50
|
+
C(H, E.prototype);
|
|
51
|
+
H.isPureReactComponent = true;
|
|
52
|
+
var I = Array.isArray, J = Object.prototype.hasOwnProperty, K = { current: null }, L = { key: true, ref: true, __self: true, __source: true };
|
|
53
|
+
function M(a, b, e) {
|
|
54
|
+
var d, c = {}, k = null, h = null;
|
|
55
|
+
if (null != b)
|
|
56
|
+
for (d in void 0 !== b.ref && (h = b.ref), void 0 !== b.key && (k = "" + b.key), b)
|
|
57
|
+
J.call(b, d) && !L.hasOwnProperty(d) && (c[d] = b[d]);
|
|
58
|
+
var g = arguments.length - 2;
|
|
59
|
+
if (1 === g)
|
|
60
|
+
c.children = e;
|
|
61
|
+
else if (1 < g) {
|
|
62
|
+
for (var f = Array(g), m = 0; m < g; m++)
|
|
63
|
+
f[m] = arguments[m + 2];
|
|
64
|
+
c.children = f;
|
|
65
|
+
}
|
|
66
|
+
if (a && a.defaultProps)
|
|
67
|
+
for (d in g = a.defaultProps, g)
|
|
68
|
+
void 0 === c[d] && (c[d] = g[d]);
|
|
69
|
+
return { $$typeof: l, type: a, key: k, ref: h, props: c, _owner: K.current };
|
|
70
|
+
}
|
|
71
|
+
function N(a, b) {
|
|
72
|
+
return { $$typeof: l, type: a.type, key: b, ref: a.ref, props: a.props, _owner: a._owner };
|
|
73
|
+
}
|
|
74
|
+
function O3(a) {
|
|
75
|
+
return "object" === typeof a && null !== a && a.$$typeof === l;
|
|
76
|
+
}
|
|
77
|
+
function escape(a) {
|
|
78
|
+
var b = { "=": "=0", ":": "=2" };
|
|
79
|
+
return "$" + a.replace(/[=:]/g, function(a2) {
|
|
80
|
+
return b[a2];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var P = /\/+/g;
|
|
84
|
+
function Q(a, b) {
|
|
85
|
+
return "object" === typeof a && null !== a && null != a.key ? escape("" + a.key) : b.toString(36);
|
|
86
|
+
}
|
|
87
|
+
function R(a, b, e, d, c) {
|
|
88
|
+
var k = typeof a;
|
|
89
|
+
if ("undefined" === k || "boolean" === k)
|
|
90
|
+
a = null;
|
|
91
|
+
var h = false;
|
|
92
|
+
if (null === a)
|
|
93
|
+
h = true;
|
|
94
|
+
else
|
|
95
|
+
switch (k) {
|
|
96
|
+
case "string":
|
|
97
|
+
case "number":
|
|
98
|
+
h = true;
|
|
99
|
+
break;
|
|
100
|
+
case "object":
|
|
101
|
+
switch (a.$$typeof) {
|
|
102
|
+
case l:
|
|
103
|
+
case n:
|
|
104
|
+
h = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (h)
|
|
108
|
+
return h = a, c = c(h), a = "" === d ? "." + Q(h, 0) : d, I(c) ? (e = "", null != a && (e = a.replace(P, "$&/") + "/"), R(c, b, e, "", function(a2) {
|
|
109
|
+
return a2;
|
|
110
|
+
})) : null != c && (O3(c) && (c = N(c, e + (!c.key || h && h.key === c.key ? "" : ("" + c.key).replace(P, "$&/") + "/") + a)), b.push(c)), 1;
|
|
111
|
+
h = 0;
|
|
112
|
+
d = "" === d ? "." : d + ":";
|
|
113
|
+
if (I(a))
|
|
114
|
+
for (var g = 0; g < a.length; g++) {
|
|
115
|
+
k = a[g];
|
|
116
|
+
var f = d + Q(k, g);
|
|
117
|
+
h += R(k, b, e, f, c);
|
|
118
|
+
}
|
|
119
|
+
else if (f = A(a), "function" === typeof f)
|
|
120
|
+
for (a = f.call(a), g = 0; !(k = a.next()).done; )
|
|
121
|
+
k = k.value, f = d + Q(k, g++), h += R(k, b, e, f, c);
|
|
122
|
+
else if ("object" === k)
|
|
123
|
+
throw b = String(a), Error("Objects are not valid as a React child (found: " + ("[object Object]" === b ? "object with keys {" + Object.keys(a).join(", ") + "}" : b) + "). If you meant to render a collection of children, use an array instead.");
|
|
124
|
+
return h;
|
|
125
|
+
}
|
|
126
|
+
function S(a, b, e) {
|
|
127
|
+
if (null == a)
|
|
128
|
+
return a;
|
|
129
|
+
var d = [], c = 0;
|
|
130
|
+
R(a, d, "", "", function(a2) {
|
|
131
|
+
return b.call(e, a2, c++);
|
|
132
|
+
});
|
|
133
|
+
return d;
|
|
134
|
+
}
|
|
135
|
+
function T(a) {
|
|
136
|
+
if (-1 === a._status) {
|
|
137
|
+
var b = a._result;
|
|
138
|
+
b = b();
|
|
139
|
+
b.then(function(b2) {
|
|
140
|
+
if (0 === a._status || -1 === a._status)
|
|
141
|
+
a._status = 1, a._result = b2;
|
|
142
|
+
}, function(b2) {
|
|
143
|
+
if (0 === a._status || -1 === a._status)
|
|
144
|
+
a._status = 2, a._result = b2;
|
|
145
|
+
});
|
|
146
|
+
-1 === a._status && (a._status = 0, a._result = b);
|
|
147
|
+
}
|
|
148
|
+
if (1 === a._status)
|
|
149
|
+
return a._result.default;
|
|
150
|
+
throw a._result;
|
|
151
|
+
}
|
|
152
|
+
var U = { current: null }, V = { transition: null }, W = { ReactCurrentDispatcher: U, ReactCurrentBatchConfig: V, ReactCurrentOwner: K };
|
|
153
|
+
function X() {
|
|
154
|
+
throw Error("act(...) is not supported in production builds of React.");
|
|
155
|
+
}
|
|
156
|
+
react_production_min.Children = { map: S, forEach: function(a, b, e) {
|
|
157
|
+
S(a, function() {
|
|
158
|
+
b.apply(this, arguments);
|
|
159
|
+
}, e);
|
|
160
|
+
}, count: function(a) {
|
|
161
|
+
var b = 0;
|
|
162
|
+
S(a, function() {
|
|
163
|
+
b++;
|
|
164
|
+
});
|
|
165
|
+
return b;
|
|
166
|
+
}, toArray: function(a) {
|
|
167
|
+
return S(a, function(a2) {
|
|
168
|
+
return a2;
|
|
169
|
+
}) || [];
|
|
170
|
+
}, only: function(a) {
|
|
171
|
+
if (!O3(a))
|
|
172
|
+
throw Error("React.Children.only expected to receive a single React element child.");
|
|
173
|
+
return a;
|
|
174
|
+
} };
|
|
175
|
+
react_production_min.Component = E;
|
|
176
|
+
react_production_min.Fragment = p;
|
|
177
|
+
react_production_min.Profiler = r;
|
|
178
|
+
react_production_min.PureComponent = G;
|
|
179
|
+
react_production_min.StrictMode = q;
|
|
180
|
+
react_production_min.Suspense = w;
|
|
181
|
+
react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = W;
|
|
182
|
+
react_production_min.act = X;
|
|
183
|
+
react_production_min.cloneElement = function(a, b, e) {
|
|
184
|
+
if (null === a || void 0 === a)
|
|
185
|
+
throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + a + ".");
|
|
186
|
+
var d = C({}, a.props), c = a.key, k = a.ref, h = a._owner;
|
|
187
|
+
if (null != b) {
|
|
188
|
+
void 0 !== b.ref && (k = b.ref, h = K.current);
|
|
189
|
+
void 0 !== b.key && (c = "" + b.key);
|
|
190
|
+
if (a.type && a.type.defaultProps)
|
|
191
|
+
var g = a.type.defaultProps;
|
|
192
|
+
for (f in b)
|
|
193
|
+
J.call(b, f) && !L.hasOwnProperty(f) && (d[f] = void 0 === b[f] && void 0 !== g ? g[f] : b[f]);
|
|
194
|
+
}
|
|
195
|
+
var f = arguments.length - 2;
|
|
196
|
+
if (1 === f)
|
|
197
|
+
d.children = e;
|
|
198
|
+
else if (1 < f) {
|
|
199
|
+
g = Array(f);
|
|
200
|
+
for (var m = 0; m < f; m++)
|
|
201
|
+
g[m] = arguments[m + 2];
|
|
202
|
+
d.children = g;
|
|
203
|
+
}
|
|
204
|
+
return { $$typeof: l, type: a.type, key: c, ref: k, props: d, _owner: h };
|
|
205
|
+
};
|
|
206
|
+
react_production_min.createContext = function(a) {
|
|
207
|
+
a = { $$typeof: u, _currentValue: a, _currentValue2: a, _threadCount: 0, Provider: null, Consumer: null, _defaultValue: null, _globalName: null };
|
|
208
|
+
a.Provider = { $$typeof: t, _context: a };
|
|
209
|
+
return a.Consumer = a;
|
|
210
|
+
};
|
|
211
|
+
react_production_min.createElement = M;
|
|
212
|
+
react_production_min.createFactory = function(a) {
|
|
213
|
+
var b = M.bind(null, a);
|
|
214
|
+
b.type = a;
|
|
215
|
+
return b;
|
|
216
|
+
};
|
|
217
|
+
react_production_min.createRef = function() {
|
|
218
|
+
return { current: null };
|
|
219
|
+
};
|
|
220
|
+
react_production_min.forwardRef = function(a) {
|
|
221
|
+
return { $$typeof: v, render: a };
|
|
222
|
+
};
|
|
223
|
+
react_production_min.isValidElement = O3;
|
|
224
|
+
react_production_min.lazy = function(a) {
|
|
225
|
+
return { $$typeof: y, _payload: { _status: -1, _result: a }, _init: T };
|
|
226
|
+
};
|
|
227
|
+
react_production_min.memo = function(a, b) {
|
|
228
|
+
return { $$typeof: x, type: a, compare: void 0 === b ? null : b };
|
|
229
|
+
};
|
|
230
|
+
react_production_min.startTransition = function(a) {
|
|
231
|
+
var b = V.transition;
|
|
232
|
+
V.transition = {};
|
|
233
|
+
try {
|
|
234
|
+
a();
|
|
235
|
+
} finally {
|
|
236
|
+
V.transition = b;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
react_production_min.unstable_act = X;
|
|
240
|
+
react_production_min.useCallback = function(a, b) {
|
|
241
|
+
return U.current.useCallback(a, b);
|
|
242
|
+
};
|
|
243
|
+
react_production_min.useContext = function(a) {
|
|
244
|
+
return U.current.useContext(a);
|
|
245
|
+
};
|
|
246
|
+
react_production_min.useDebugValue = function() {
|
|
247
|
+
};
|
|
248
|
+
react_production_min.useDeferredValue = function(a) {
|
|
249
|
+
return U.current.useDeferredValue(a);
|
|
250
|
+
};
|
|
251
|
+
react_production_min.useEffect = function(a, b) {
|
|
252
|
+
return U.current.useEffect(a, b);
|
|
253
|
+
};
|
|
254
|
+
react_production_min.useId = function() {
|
|
255
|
+
return U.current.useId();
|
|
256
|
+
};
|
|
257
|
+
react_production_min.useImperativeHandle = function(a, b, e) {
|
|
258
|
+
return U.current.useImperativeHandle(a, b, e);
|
|
259
|
+
};
|
|
260
|
+
react_production_min.useInsertionEffect = function(a, b) {
|
|
261
|
+
return U.current.useInsertionEffect(a, b);
|
|
262
|
+
};
|
|
263
|
+
react_production_min.useLayoutEffect = function(a, b) {
|
|
264
|
+
return U.current.useLayoutEffect(a, b);
|
|
265
|
+
};
|
|
266
|
+
react_production_min.useMemo = function(a, b) {
|
|
267
|
+
return U.current.useMemo(a, b);
|
|
268
|
+
};
|
|
269
|
+
react_production_min.useReducer = function(a, b, e) {
|
|
270
|
+
return U.current.useReducer(a, b, e);
|
|
271
|
+
};
|
|
272
|
+
react_production_min.useRef = function(a) {
|
|
273
|
+
return U.current.useRef(a);
|
|
274
|
+
};
|
|
275
|
+
react_production_min.useState = function(a) {
|
|
276
|
+
return U.current.useState(a);
|
|
277
|
+
};
|
|
278
|
+
react_production_min.useSyncExternalStore = function(a, b, e) {
|
|
279
|
+
return U.current.useSyncExternalStore(a, b, e);
|
|
280
|
+
};
|
|
281
|
+
react_production_min.useTransition = function() {
|
|
282
|
+
return U.current.useTransition();
|
|
283
|
+
};
|
|
284
|
+
react_production_min.version = "18.3.1";
|
|
285
|
+
{
|
|
286
|
+
react.exports = react_production_min;
|
|
287
|
+
}
|
|
288
|
+
var reactExports = react.exports;
|
|
289
|
+
const React = /* @__PURE__ */ getDefaultExportFromCjs(reactExports);
|
|
290
|
+
function useObiSDK(config) {
|
|
291
|
+
const [sdk, setSDK] = reactExports.useState(null);
|
|
292
|
+
const [state, setState] = reactExports.useState(SDKState.READY);
|
|
293
|
+
const [error, setError] = reactExports.useState(null);
|
|
294
|
+
reactExports.useEffect(() => {
|
|
295
|
+
const newSDK = new ObiSDK(config);
|
|
296
|
+
setSDK(newSDK);
|
|
297
|
+
newSDK.init().catch((err) => {
|
|
298
|
+
console.error("Failed to initialize Obi SDK:", err);
|
|
299
|
+
});
|
|
300
|
+
newSDK.on(EventType.STATE_CHANGE, (newState) => {
|
|
301
|
+
setState(newState);
|
|
302
|
+
});
|
|
303
|
+
newSDK.on(EventType.ERROR, (err) => {
|
|
304
|
+
setError(err);
|
|
305
|
+
});
|
|
306
|
+
return () => {
|
|
307
|
+
newSDK.dispose();
|
|
308
|
+
};
|
|
309
|
+
}, []);
|
|
310
|
+
const startVoiceRecording = async () => {
|
|
311
|
+
if (sdk) {
|
|
312
|
+
return sdk.startVoiceRecording();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const stopVoiceRecording = async () => {
|
|
316
|
+
if (sdk) {
|
|
317
|
+
return sdk.stopVoiceRecording();
|
|
318
|
+
}
|
|
319
|
+
return { transcript: void 0 };
|
|
320
|
+
};
|
|
321
|
+
const startScreenCapture = async () => {
|
|
322
|
+
if (sdk) {
|
|
323
|
+
return sdk.startScreenCapture();
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const stopScreenCapture = async () => {
|
|
327
|
+
if (sdk) {
|
|
328
|
+
return sdk.stopScreenCapture();
|
|
329
|
+
}
|
|
330
|
+
return { screenshot: void 0 };
|
|
331
|
+
};
|
|
332
|
+
return {
|
|
333
|
+
sdk,
|
|
334
|
+
state,
|
|
335
|
+
error,
|
|
336
|
+
startVoiceRecording,
|
|
337
|
+
stopVoiceRecording,
|
|
338
|
+
startScreenCapture,
|
|
339
|
+
stopScreenCapture,
|
|
340
|
+
isReady: state === SDKState.READY,
|
|
341
|
+
isActive: state !== SDKState.READY,
|
|
342
|
+
isError: state === SDKState.ERROR
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function ObiStatusWidgetReact({ state = SDKState.READY, className }) {
|
|
346
|
+
return /* @__PURE__ */ React.createElement("obi-status-widget", { state, className });
|
|
347
|
+
}
|
|
348
|
+
function ObiControlPanelReact({
|
|
349
|
+
state = SDKState.READY,
|
|
350
|
+
voiceEnabled = true,
|
|
351
|
+
screenEnabled = true,
|
|
352
|
+
onVoiceStart,
|
|
353
|
+
onScreenStart,
|
|
354
|
+
onStop,
|
|
355
|
+
className
|
|
356
|
+
}) {
|
|
357
|
+
const handleVoiceStart = () => {
|
|
358
|
+
if (onVoiceStart)
|
|
359
|
+
onVoiceStart();
|
|
360
|
+
};
|
|
361
|
+
const handleScreenStart = () => {
|
|
362
|
+
if (onScreenStart)
|
|
363
|
+
onScreenStart();
|
|
364
|
+
};
|
|
365
|
+
const handleStop = () => {
|
|
366
|
+
if (onStop)
|
|
367
|
+
onStop();
|
|
368
|
+
};
|
|
369
|
+
return /* @__PURE__ */ React.createElement(
|
|
370
|
+
"obi-control-panel",
|
|
371
|
+
{
|
|
372
|
+
state,
|
|
373
|
+
voiceEnabled,
|
|
374
|
+
screenEnabled,
|
|
375
|
+
onvoicestart: handleVoiceStart,
|
|
376
|
+
onscreenstart: handleScreenStart,
|
|
377
|
+
onstop: handleStop,
|
|
378
|
+
className
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
const VERSION = "0.1.0";
|
|
383
|
+
const createSession = async (options = {}) => {
|
|
384
|
+
const { ObiSession } = await import("./chunks/session-e208b5bb.js").then((n2) => n2.s);
|
|
385
|
+
return new ObiSession(options);
|
|
386
|
+
};
|
|
387
|
+
export {
|
|
388
|
+
AudioEqualizer,
|
|
389
|
+
Course,
|
|
390
|
+
CourseList,
|
|
391
|
+
CourseModal,
|
|
392
|
+
DotLoader,
|
|
393
|
+
EventType,
|
|
394
|
+
NavIcon,
|
|
395
|
+
NavigationBar,
|
|
396
|
+
ObiControlPanel,
|
|
397
|
+
ObiControlPanelReact,
|
|
398
|
+
ObiSDK,
|
|
399
|
+
O as ObiSDKConfigSchema,
|
|
400
|
+
O2 as ObiSession,
|
|
401
|
+
ObiStatusWidget,
|
|
402
|
+
ObiStatusWidgetReact,
|
|
403
|
+
ObiWidget,
|
|
404
|
+
SDKState,
|
|
405
|
+
SearchingLoader,
|
|
406
|
+
VERSION,
|
|
407
|
+
createSession,
|
|
408
|
+
defineCustomElements,
|
|
409
|
+
useObiSDK
|
|
410
|
+
};
|
|
411
|
+
//# sourceMappingURL=index.js.map
|