@m4trix/core 0.10.0 → 0.11.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/dist/api/index.js DELETED
@@ -1,81 +0,0 @@
1
- // src/api/socket-handler/SocketIoFactory.ts
2
- var SocketIoFactory = class _SocketIoFactory {
3
- constructor(socket, prefix, hooks) {
4
- this.socket = socket;
5
- this.prefix = prefix;
6
- this.hooks = hooks;
7
- }
8
- static setupSocketHandlers({
9
- enableVoiceEvents,
10
- enableChatEvents,
11
- enableTranscriptEvents,
12
- prefix = "",
13
- socket,
14
- hooks
15
- }) {
16
- const factory = new _SocketIoFactory(socket, prefix, hooks);
17
- if (enableVoiceEvents) {
18
- factory.setupVoiceEvents();
19
- }
20
- if (enableChatEvents) {
21
- factory.setupChatEvents(socket);
22
- }
23
- if (enableTranscriptEvents) {
24
- factory.setupTranscriptEvents(socket);
25
- }
26
- }
27
- setupVoiceEvents() {
28
- const {
29
- onVoiceInputFile,
30
- onVoiceInputChunk,
31
- onVoiceInputCommit,
32
- onVoiceOutputDelta,
33
- onVoiceOutputCommit,
34
- onVoiceOutputFile,
35
- onVoiceOutputTranscriptDelta,
36
- onVoiceOutputTranscriptFull
37
- } = this.hooks;
38
- const prefix = this.prefixEvent;
39
- if (onVoiceInputFile) {
40
- this.socket.on(prefix("voice:input_file"), onVoiceInputFile);
41
- }
42
- if (onVoiceInputChunk) {
43
- this.socket.on(prefix("voice:input_chunk"), onVoiceInputChunk);
44
- }
45
- if (onVoiceInputCommit) {
46
- this.socket.on(prefix("voice:input_commit"), onVoiceInputCommit);
47
- }
48
- if (onVoiceOutputDelta) {
49
- this.socket.on(prefix("voice:output_delta"), onVoiceOutputDelta);
50
- }
51
- if (onVoiceOutputCommit) {
52
- this.socket.on(prefix("voice:output_commit"), onVoiceOutputCommit);
53
- }
54
- if (onVoiceOutputFile) {
55
- this.socket.on(prefix("voice:output_file"), onVoiceOutputFile);
56
- }
57
- if (onVoiceOutputTranscriptDelta) {
58
- this.socket.on(
59
- prefix("voice:output_transcript_delta"),
60
- onVoiceOutputTranscriptDelta
61
- );
62
- }
63
- if (onVoiceOutputTranscriptFull) {
64
- this.socket.on(
65
- prefix("voice:output_transcript_full"),
66
- onVoiceOutputTranscriptFull
67
- );
68
- }
69
- }
70
- setupChatEvents(_socket) {
71
- }
72
- setupTranscriptEvents(_socket) {
73
- }
74
- prefixEvent(event) {
75
- return this.prefix ? `${this.prefix}:${event}` : event;
76
- }
77
- };
78
-
79
- export { SocketIoFactory };
80
- //# sourceMappingURL=out.js.map
81
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/socket-handler/SocketIoFactory.ts"],"names":[],"mappings":";AAGO,IAAM,kBAAN,MAAM,iBAAgB;AAAA,EAKnB,YAAY,QAAgB,QAAgB,OAAsB;AACxE,SAAK,SAAS;AACd,SAAK,SAAS;AACd,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,OAAO,oBAAoB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF,GAKS;AAGP,UAAM,UAAU,IAAI,iBAAgB,QAAQ,QAAQ,KAAM;AAC1D,QAAI,mBAAmB;AACrB,cAAQ,iBAAiB;AAAA,IAC3B;AAEA,QAAI,kBAAkB;AACpB,cAAQ,gBAAgB,MAAM;AAAA,IAChC;AAEA,QAAI,wBAAwB;AAC1B,cAAQ,sBAAsB,MAAM;AAAA,IACtC;AAAA,EACF;AAAA,EAEQ,mBAAyB;AAC/B,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,KAAK;AAET,UAAM,SAAS,KAAK;AAEpB,QAAI,kBAAkB;AACpB,WAAK,OAAO,GAAG,OAAO,kBAAkB,GAAG,gBAAgB;AAAA,IAC7D;AAEA,QAAI,mBAAmB;AACrB,WAAK,OAAO,GAAG,OAAO,mBAAmB,GAAG,iBAAiB;AAAA,IAC/D;AAEA,QAAI,oBAAoB;AACtB,WAAK,OAAO,GAAG,OAAO,oBAAoB,GAAG,kBAAkB;AAAA,IACjE;AAEA,QAAI,oBAAoB;AACtB,WAAK,OAAO,GAAG,OAAO,oBAAoB,GAAG,kBAAkB;AAAA,IACjE;AAEA,QAAI,qBAAqB;AACvB,WAAK,OAAO,GAAG,OAAO,qBAAqB,GAAG,mBAAmB;AAAA,IACnE;AAEA,QAAI,mBAAmB;AACrB,WAAK,OAAO,GAAG,OAAO,mBAAmB,GAAG,iBAAiB;AAAA,IAC/D;AAEA,QAAI,8BAA8B;AAChC,WAAK,OAAO;AAAA,QACV,OAAO,+BAA+B;AAAA,QACtC;AAAA,MACF;AAAA,IACF;AAEA,QAAI,6BAA6B;AAC/B,WAAK,OAAO;AAAA,QACV,OAAO,8BAA8B;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,gBAAgB,SAAuB;AAAA,EAE/C;AAAA,EAEQ,sBAAsB,SAAuB;AAAA,EAErD;AAAA,EAEQ,YAAY,OAAuB;AACzC,WAAO,KAAK,SAAS,GAAG,KAAK,MAAM,IAAI,KAAK,KAAK;AAAA,EACnD;AACF","sourcesContent":["import { Socket } from 'socket.io';\nimport { Hooks, SetupSocketHandlersParams } from './socket-factory-types';\n\nexport class SocketIoFactory {\n private socket: Socket;\n private prefix: string;\n private hooks: Hooks<Socket>;\n\n private constructor(socket: Socket, prefix: string, hooks: Hooks<Socket>) {\n this.socket = socket;\n this.prefix = prefix;\n this.hooks = hooks;\n }\n\n static setupSocketHandlers({\n enableVoiceEvents,\n enableChatEvents,\n enableTranscriptEvents,\n prefix = '',\n socket,\n hooks,\n }: SetupSocketHandlersParams<\n Socket,\n {\n socket: Socket;\n }\n >): void {\n // Adapter will override the hooks\n\n const factory = new SocketIoFactory(socket, prefix, hooks!);\n if (enableVoiceEvents) {\n factory.setupVoiceEvents();\n }\n\n if (enableChatEvents) {\n factory.setupChatEvents(socket);\n }\n\n if (enableTranscriptEvents) {\n factory.setupTranscriptEvents(socket);\n }\n }\n\n private setupVoiceEvents(): void {\n const {\n onVoiceInputFile,\n onVoiceInputChunk,\n onVoiceInputCommit,\n onVoiceOutputDelta,\n onVoiceOutputCommit,\n onVoiceOutputFile,\n onVoiceOutputTranscriptDelta,\n onVoiceOutputTranscriptFull,\n } = this.hooks;\n\n const prefix = this.prefixEvent;\n\n if (onVoiceInputFile) {\n this.socket.on(prefix('voice:input_file'), onVoiceInputFile);\n }\n\n if (onVoiceInputChunk) {\n this.socket.on(prefix('voice:input_chunk'), onVoiceInputChunk);\n }\n\n if (onVoiceInputCommit) {\n this.socket.on(prefix('voice:input_commit'), onVoiceInputCommit);\n }\n\n if (onVoiceOutputDelta) {\n this.socket.on(prefix('voice:output_delta'), onVoiceOutputDelta);\n }\n\n if (onVoiceOutputCommit) {\n this.socket.on(prefix('voice:output_commit'), onVoiceOutputCommit);\n }\n\n if (onVoiceOutputFile) {\n this.socket.on(prefix('voice:output_file'), onVoiceOutputFile);\n }\n\n if (onVoiceOutputTranscriptDelta) {\n this.socket.on(\n prefix('voice:output_transcript_delta'),\n onVoiceOutputTranscriptDelta\n );\n }\n\n if (onVoiceOutputTranscriptFull) {\n this.socket.on(\n prefix('voice:output_transcript_full'),\n onVoiceOutputTranscriptFull\n );\n }\n }\n\n private setupChatEvents(_socket: Socket): void {\n // TODO: Implement chat event handler\n }\n\n private setupTranscriptEvents(_socket: Socket): void {\n // TODO: Implement transcript event handlers\n }\n\n private prefixEvent(event: string): string {\n return this.prefix ? `${this.prefix}:${event}` : event;\n }\n}\n"]}