@phystack/hub-client 4.4.53 → 4.4.55
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/index.d.ts +18 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +252 -188
- package/dist/index.js.map +1 -1
- package/dist/peripheral-twin.d.ts +10 -9
- package/dist/peripheral-twin.d.ts.map +1 -1
- package/dist/peripheral-twin.js +24 -54
- package/dist/peripheral-twin.js.map +1 -1
- package/dist/services/phyhub-connection.service.d.ts +1 -0
- package/dist/services/phyhub-connection.service.d.ts.map +1 -1
- package/dist/services/phyhub-connection.service.js +17 -0
- package/dist/services/phyhub-connection.service.js.map +1 -1
- package/dist/services/phyhub-direct-connection.service.d.ts +21 -0
- package/dist/services/phyhub-direct-connection.service.d.ts.map +1 -0
- package/dist/services/phyhub-direct-connection.service.js +101 -0
- package/dist/services/phyhub-direct-connection.service.js.map +1 -0
- package/dist/services/webrtc/data-channel-handler.d.ts +45 -0
- package/dist/services/webrtc/data-channel-handler.d.ts.map +1 -0
- package/dist/services/webrtc/data-channel-handler.js +260 -0
- package/dist/services/webrtc/data-channel-handler.js.map +1 -0
- package/dist/services/webrtc/index.d.ts +8 -0
- package/dist/services/webrtc/index.d.ts.map +1 -0
- package/dist/services/webrtc/index.js +18 -0
- package/dist/services/webrtc/index.js.map +1 -0
- package/dist/services/webrtc/media-stream-handler.d.ts +57 -0
- package/dist/services/webrtc/media-stream-handler.d.ts.map +1 -0
- package/dist/services/webrtc/media-stream-handler.js +367 -0
- package/dist/services/webrtc/media-stream-handler.js.map +1 -0
- package/dist/services/webrtc/peer-connection-manager.d.ts +40 -0
- package/dist/services/webrtc/peer-connection-manager.d.ts.map +1 -0
- package/dist/services/webrtc/peer-connection-manager.js +335 -0
- package/dist/services/webrtc/peer-connection-manager.js.map +1 -0
- package/dist/services/webrtc/types.d.ts +133 -0
- package/dist/services/webrtc/types.d.ts.map +1 -0
- package/dist/services/webrtc/types.js +12 -0
- package/dist/services/webrtc/types.js.map +1 -0
- package/dist/services/webrtc/webrtc-globals.d.ts +4 -0
- package/dist/services/webrtc/webrtc-globals.d.ts.map +1 -0
- package/dist/services/webrtc/webrtc-globals.js +72 -0
- package/dist/services/webrtc/webrtc-globals.js.map +1 -0
- package/dist/services/webrtc/webrtc-manager.d.ts +35 -0
- package/dist/services/webrtc/webrtc-manager.d.ts.map +1 -0
- package/dist/services/webrtc/webrtc-manager.js +274 -0
- package/dist/services/webrtc/webrtc-manager.js.map +1 -0
- package/dist/test/communication-comprehensive-test.d.ts +8 -0
- package/dist/test/communication-comprehensive-test.d.ts.map +1 -0
- package/dist/test/communication-comprehensive-test.js +356 -0
- package/dist/test/communication-comprehensive-test.js.map +1 -0
- package/dist/test/webrtc-channel-names-test.d.ts +2 -0
- package/dist/test/webrtc-channel-names-test.d.ts.map +1 -0
- package/dist/test/webrtc-channel-names-test.js +177 -0
- package/dist/test/webrtc-channel-names-test.js.map +1 -0
- package/dist/test/webrtc-comprehensive-test.d.ts +2 -0
- package/dist/test/webrtc-comprehensive-test.d.ts.map +1 -0
- package/dist/test/webrtc-comprehensive-test.js +328 -0
- package/dist/test/webrtc-comprehensive-test.js.map +1 -0
- package/dist/test/webrtc-reconnect-test.d.ts +4 -0
- package/dist/test/webrtc-reconnect-test.d.ts.map +1 -0
- package/dist/test/webrtc-reconnect-test.js +244 -0
- package/dist/test/webrtc-reconnect-test.js.map +1 -0
- package/dist/test/webrtc-test-harness.d.ts +4 -0
- package/dist/test/webrtc-test-harness.d.ts.map +1 -0
- package/dist/test/webrtc-test-harness.js +169 -0
- package/dist/test/webrtc-test-harness.js.map +1 -0
- package/dist/twin-messaging.d.ts +23 -0
- package/dist/twin-messaging.d.ts.map +1 -0
- package/dist/twin-messaging.js +96 -0
- package/dist/twin-messaging.js.map +1 -0
- package/dist/types/twin.types.d.ts +36 -20
- package/dist/types/twin.types.d.ts.map +1 -1
- package/dist/types/twin.types.js.map +1 -1
- package/docs/webrtc-howto.md +398 -0
- package/docs/webrtc-test.md +330 -0
- package/package.json +3 -3
- package/scripts/webrtc-test.sh +401 -0
- package/src/index.ts +370 -259
- package/src/peripheral-twin.ts +44 -67
- package/src/services/phyhub-connection.service.ts +24 -0
- package/src/services/phyhub-direct-connection.service.ts +159 -0
- package/src/services/webrtc/data-channel-handler.ts +362 -0
- package/src/services/webrtc/index.ts +36 -0
- package/src/services/webrtc/media-stream-handler.ts +515 -0
- package/src/services/webrtc/peer-connection-manager.ts +463 -0
- package/src/services/webrtc/types.ts +270 -0
- package/src/services/webrtc/webrtc-globals.ts +108 -0
- package/src/services/webrtc/webrtc-manager.ts +490 -0
- package/src/test/communication-comprehensive-test.ts +533 -0
- package/src/test/webrtc-channel-names-test.ts +266 -0
- package/src/test/webrtc-comprehensive-test.ts +494 -0
- package/src/test/webrtc-reconnect-test.ts +345 -0
- package/src/test/webrtc-test-harness.ts +254 -0
- package/src/twin-messaging.ts +193 -0
- package/src/types/twin.types.ts +59 -20
- package/dist/services/webrtc/datachannel.d.ts +0 -10
- package/dist/services/webrtc/datachannel.d.ts.map +0 -1
- package/dist/services/webrtc/datachannel.js +0 -290
- package/dist/services/webrtc/datachannel.js.map +0 -1
- package/dist/services/webrtc/mediastream.d.ts +0 -10
- package/dist/services/webrtc/mediastream.d.ts.map +0 -1
- package/dist/services/webrtc/mediastream.js +0 -396
- package/dist/services/webrtc/mediastream.js.map +0 -1
- package/dist/services/webrtc/peer-connection-ice.d.ts +0 -32
- package/dist/services/webrtc/peer-connection-ice.d.ts.map +0 -1
- package/dist/services/webrtc/peer-connection-ice.js +0 -483
- package/dist/services/webrtc/peer-connection-ice.js.map +0 -1
- package/src/services/webrtc/datachannel.ts +0 -421
- package/src/services/webrtc/mediastream.ts +0 -602
- package/src/services/webrtc/peer-connection-ice.ts +0 -689
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Twin Messaging Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates emit/on/to methods for any twin type.
|
|
5
|
+
* Provides a consistent messaging API across all instance types.
|
|
6
|
+
*
|
|
7
|
+
* Backwards Compatibility:
|
|
8
|
+
* - Message format: `${typePrefix}:${eventType}` is unchanged from pre-PR 144
|
|
9
|
+
* - Old emit() calls work with new on() handlers and vice versa
|
|
10
|
+
* - Old callback signature (data) => {...} works - the respond parameter is optional
|
|
11
|
+
* - emit() supports both fire-and-forget and request-response patterns
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { TwinMessageResult, TwinMessageResultStatus } from './types/twin.types';
|
|
15
|
+
|
|
16
|
+
export interface TwinMessagingContext {
|
|
17
|
+
/** Function to send events via the hub */
|
|
18
|
+
sendEvent: (targetTwinId: string, payload: any) => void;
|
|
19
|
+
/** Function to register message listeners */
|
|
20
|
+
onTwinMessage: (twinId: string, callback: (payload: any) => void) => void;
|
|
21
|
+
/** The twin ID for this instance */
|
|
22
|
+
twinId: string;
|
|
23
|
+
/** Source device ID for message metadata */
|
|
24
|
+
deviceId: string;
|
|
25
|
+
/** Type prefix for message routing (e.g., 'edgeInstance', 'peripheralInstance') */
|
|
26
|
+
typePrefix: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TwinMessagingMethods {
|
|
30
|
+
/**
|
|
31
|
+
* Send a message to the twin.
|
|
32
|
+
* - Without callback: Fire-and-forget (returns void)
|
|
33
|
+
* - With callback: Request-response pattern (returns Promise)
|
|
34
|
+
*/
|
|
35
|
+
emit: {
|
|
36
|
+
(type: string, payload: any): void;
|
|
37
|
+
(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
38
|
+
};
|
|
39
|
+
/** Listen for events, with optional respond callback for request-response */
|
|
40
|
+
on: (type: string, callback: (message: any, respond?: (result: TwinMessageResult) => void) => void) => void;
|
|
41
|
+
/** Target a specific twin for messaging */
|
|
42
|
+
to: (targetTwinId: string) => {
|
|
43
|
+
emit: {
|
|
44
|
+
(type: string, payload: any): void;
|
|
45
|
+
(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const REQUEST_TIMEOUT = 10000;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates messaging methods (emit, on, to) for a twin instance.
|
|
54
|
+
* This provides a consistent API across all instance types (Edge, Screen, Peripheral, etc.)
|
|
55
|
+
*/
|
|
56
|
+
export function createTwinMessaging(context: TwinMessagingContext): TwinMessagingMethods {
|
|
57
|
+
const { sendEvent, onTwinMessage, twinId, deviceId, typePrefix } = context;
|
|
58
|
+
|
|
59
|
+
// Registry for pending requests - enables request-response pattern via emit/on
|
|
60
|
+
const pendingRequests = new Map<string, {
|
|
61
|
+
resolve: (value: TwinMessageResult) => void;
|
|
62
|
+
reject: (reason: TwinMessageResult) => void;
|
|
63
|
+
timeoutId: ReturnType<typeof setTimeout>;
|
|
64
|
+
}>();
|
|
65
|
+
|
|
66
|
+
const generateRequestId = () => `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
67
|
+
|
|
68
|
+
// Helper: Build message payload
|
|
69
|
+
const buildPayload = (type: string, data: any) => ({
|
|
70
|
+
type: `${typePrefix}:${type}`,
|
|
71
|
+
sourceTwinId: twinId,
|
|
72
|
+
sourceDeviceId: deviceId,
|
|
73
|
+
data,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Helper: Send request and wait for response
|
|
77
|
+
const sendRequest = (
|
|
78
|
+
targetTwinId: string,
|
|
79
|
+
type: string,
|
|
80
|
+
payload: any,
|
|
81
|
+
callback: (response: TwinMessageResult) => void
|
|
82
|
+
): Promise<TwinMessageResult> => {
|
|
83
|
+
const requestId = generateRequestId();
|
|
84
|
+
|
|
85
|
+
return new Promise<TwinMessageResult>((resolve, reject) => {
|
|
86
|
+
const timeoutId = setTimeout(() => {
|
|
87
|
+
pendingRequests.delete(requestId);
|
|
88
|
+
const error: TwinMessageResult = {
|
|
89
|
+
status: TwinMessageResultStatus.Error,
|
|
90
|
+
message: `Request timed out after ${REQUEST_TIMEOUT}ms`,
|
|
91
|
+
};
|
|
92
|
+
reject(error);
|
|
93
|
+
}, REQUEST_TIMEOUT);
|
|
94
|
+
|
|
95
|
+
pendingRequests.set(requestId, { resolve, reject, timeoutId });
|
|
96
|
+
|
|
97
|
+
// Send with requestId embedded
|
|
98
|
+
sendEvent(targetTwinId, buildPayload(type, { ...payload, requestId }));
|
|
99
|
+
}).then(result => {
|
|
100
|
+
callback(result);
|
|
101
|
+
return result;
|
|
102
|
+
}).catch(error => {
|
|
103
|
+
callback(error);
|
|
104
|
+
throw error;
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Set up response listener - handles all incoming responses for this twin
|
|
109
|
+
onTwinMessage(twinId, (payload: any) => {
|
|
110
|
+
const messageType = payload.data?.type || payload.type;
|
|
111
|
+
if (messageType === `${typePrefix}:response`) {
|
|
112
|
+
const responseData = payload.data?.data || payload.data;
|
|
113
|
+
const requestId = responseData?.requestId;
|
|
114
|
+
const pending = pendingRequests.get(requestId);
|
|
115
|
+
if (pending) {
|
|
116
|
+
clearTimeout(pending.timeoutId);
|
|
117
|
+
pendingRequests.delete(requestId);
|
|
118
|
+
// Extract result without requestId
|
|
119
|
+
const { requestId: _, ...result } = responseData;
|
|
120
|
+
pending.resolve(result as TwinMessageResult);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// emit: Dual-purpose - fire-and-forget or request-response based on callback presence
|
|
126
|
+
function emit(type: string, payload: any): void;
|
|
127
|
+
function emit(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
128
|
+
function emit(
|
|
129
|
+
type: string,
|
|
130
|
+
payload: any,
|
|
131
|
+
callback?: (response: TwinMessageResult) => void
|
|
132
|
+
): void | Promise<TwinMessageResult> {
|
|
133
|
+
if (callback) {
|
|
134
|
+
// Request-response pattern
|
|
135
|
+
return sendRequest(twinId, type, payload, callback);
|
|
136
|
+
} else {
|
|
137
|
+
// Fire-and-forget
|
|
138
|
+
sendEvent(twinId, buildPayload(type, payload));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// on: Listen for events, with respond callback for request-response
|
|
143
|
+
const on = (
|
|
144
|
+
type: string,
|
|
145
|
+
callback: (message: any, respond?: (result: TwinMessageResult) => void) => void
|
|
146
|
+
) => {
|
|
147
|
+
onTwinMessage(twinId, (payload: any) => {
|
|
148
|
+
const messageType = payload.data?.type || payload.type;
|
|
149
|
+
if (messageType === `${typePrefix}:${type}`) {
|
|
150
|
+
const messageData = payload.data?.data || payload.data;
|
|
151
|
+
const requestId = messageData?.requestId;
|
|
152
|
+
const sourceTwinId = payload.sourceTwinId;
|
|
153
|
+
|
|
154
|
+
// Create respond callback if this is a request (has requestId and source)
|
|
155
|
+
const respond = (requestId && sourceTwinId)
|
|
156
|
+
? (result: TwinMessageResult) => {
|
|
157
|
+
sendEvent(sourceTwinId, buildPayload('response', { ...result, requestId }));
|
|
158
|
+
}
|
|
159
|
+
: undefined;
|
|
160
|
+
|
|
161
|
+
// Pass message without requestId (strip it from the payload)
|
|
162
|
+
// Preserve null/undefined if original messageData was falsy
|
|
163
|
+
if (!messageData) {
|
|
164
|
+
callback(messageData, respond);
|
|
165
|
+
} else {
|
|
166
|
+
const { requestId: _, ...cleanData } = messageData;
|
|
167
|
+
callback(cleanData, respond);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// to: Target a specific twin
|
|
174
|
+
const to = (targetTwinId: string) => {
|
|
175
|
+
function targetEmit(type: string, payload: any): void;
|
|
176
|
+
function targetEmit(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
177
|
+
function targetEmit(
|
|
178
|
+
type: string,
|
|
179
|
+
payload: any,
|
|
180
|
+
callback?: (response: TwinMessageResult) => void
|
|
181
|
+
): void | Promise<TwinMessageResult> {
|
|
182
|
+
if (callback) {
|
|
183
|
+
return sendRequest(targetTwinId, type, payload, callback);
|
|
184
|
+
} else {
|
|
185
|
+
sendEvent(targetTwinId, buildPayload(type, payload));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return { emit: targetEmit };
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return { emit, on, to };
|
|
193
|
+
}
|
package/src/types/twin.types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PhyHubClient } from '..';
|
|
2
|
-
import { PhygridDataChannel, PhygridMediaStream } from '
|
|
2
|
+
import { PhygridDataChannel, PhygridMediaStream } from '../services/webrtc/types';
|
|
3
3
|
|
|
4
4
|
export enum TwinTypeEnum {
|
|
5
5
|
Device = 'Device',
|
|
@@ -627,30 +627,56 @@ export interface PeripheralTwinResponse extends TwinResponseBase {
|
|
|
627
627
|
}
|
|
628
628
|
|
|
629
629
|
export interface PeripheralInstance extends PeripheralTwinResponse {
|
|
630
|
-
|
|
631
|
-
|
|
630
|
+
/**
|
|
631
|
+
* Send a message to the twin.
|
|
632
|
+
* - Without callback: Fire-and-forget (returns void)
|
|
633
|
+
* - With callback: Request-response pattern (returns Promise)
|
|
634
|
+
*/
|
|
635
|
+
emit: {
|
|
636
|
+
(type: string, payload: any): void;
|
|
637
|
+
(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
638
|
+
};
|
|
639
|
+
/** Listen for events/actions of a given type */
|
|
640
|
+
on: (type: string, callback: (message: any, respond?: (result: TwinMessageResult) => void) => void) => void;
|
|
641
|
+
/** Send event to a specific twin */
|
|
632
642
|
to: (targetTwinId: string) => {
|
|
633
|
-
emit:
|
|
643
|
+
emit: {
|
|
644
|
+
(type: string, payload: any): void;
|
|
645
|
+
(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
646
|
+
};
|
|
634
647
|
};
|
|
635
648
|
updateReported: (properties: Record<string, any>) => Promise<TwinResponse>;
|
|
636
649
|
updateDesired: (properties: Record<string, any>) => Promise<TwinResponse>;
|
|
637
650
|
onUpdateReported: (callback: (reportedProperties: Record<string, any>) => void) => void;
|
|
638
651
|
onUpdateDesired: (callback: (desiredProperties: Record<string, any>) => void) => void;
|
|
639
652
|
remove: () => Promise<TwinResponse | void>;
|
|
640
|
-
getDataChannel: () => Promise<PhygridDataChannel>;
|
|
641
|
-
onDataChannel: (callback: (dc: PhygridDataChannel) => void) => void;
|
|
642
|
-
getMediaStream: () => Promise<{
|
|
653
|
+
getDataChannel: (channelName?: string) => Promise<PhygridDataChannel>;
|
|
654
|
+
onDataChannel: (callback: (dc: PhygridDataChannel) => void, channelName?: string) => void;
|
|
655
|
+
getMediaStream: (channelName?: string) => Promise<{
|
|
643
656
|
stream: PhygridMediaStream;
|
|
644
657
|
close: () => void;
|
|
645
658
|
}>;
|
|
646
|
-
onMediaStream: (callback: (stream: PhygridMediaStream) => void) => Promise<void>;
|
|
659
|
+
onMediaStream: (callback: (stream: PhygridMediaStream) => void, channelName?: string) => Promise<void>;
|
|
647
660
|
}
|
|
648
661
|
|
|
649
662
|
export interface Instance {
|
|
650
|
-
|
|
651
|
-
|
|
663
|
+
/**
|
|
664
|
+
* Send a message to the twin.
|
|
665
|
+
* - Without callback: Fire-and-forget (returns void)
|
|
666
|
+
* - With callback: Request-response pattern (returns Promise)
|
|
667
|
+
*/
|
|
668
|
+
emit: {
|
|
669
|
+
(type: string, payload: any): void;
|
|
670
|
+
(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
671
|
+
};
|
|
672
|
+
/** Listen for events/actions of a given type */
|
|
673
|
+
on: (type: string, callback: (message: any, respond?: (result: TwinMessageResult) => void) => void) => void;
|
|
674
|
+
/** Send event to a specific twin */
|
|
652
675
|
to: (twinId: string) => {
|
|
653
|
-
emit:
|
|
676
|
+
emit: {
|
|
677
|
+
(type: string, payload: any): void;
|
|
678
|
+
(type: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
679
|
+
};
|
|
654
680
|
};
|
|
655
681
|
createPeripheralTwin: (
|
|
656
682
|
peripheralName: string,
|
|
@@ -659,11 +685,11 @@ export interface Instance {
|
|
|
659
685
|
descriptors?: Record<string, string>
|
|
660
686
|
) => Promise<TwinResponse>;
|
|
661
687
|
getPeripheralTwins: (twinId?: string) => Promise<PeripheralTwinResponse[]>;
|
|
662
|
-
getDataChannel: () => Promise<PhygridDataChannel>;
|
|
663
|
-
onDataChannel: (callback: (dc: PhygridDataChannel) => void) => void;
|
|
688
|
+
getDataChannel: (channelName?: string) => Promise<PhygridDataChannel>;
|
|
689
|
+
onDataChannel: (callback: (dc: PhygridDataChannel) => void, channelName?: string) => void;
|
|
664
690
|
updateReported: (properties: Record<string, any>) => Promise<TwinResponse>;
|
|
665
|
-
getMediaStream: () => Promise<{ stream: PhygridMediaStream; close: () => void }>;
|
|
666
|
-
onMediaStream: (callback: (stream: PhygridMediaStream) => void) => Promise<void>;
|
|
691
|
+
getMediaStream: (channelName?: string) => Promise<{ stream: PhygridMediaStream; close: () => void }>;
|
|
692
|
+
onMediaStream: (callback: (stream: PhygridMediaStream) => void, channelName?: string) => Promise<void>;
|
|
667
693
|
[key: string]: any; // Allow any additional properties
|
|
668
694
|
}
|
|
669
695
|
|
|
@@ -819,11 +845,24 @@ export interface IPeripheralTwinInstance {
|
|
|
819
845
|
twinId: string;
|
|
820
846
|
edgeInstance: Instance | null;
|
|
821
847
|
peripheralTwinResponse: TwinResponse | null;
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
848
|
+
/**
|
|
849
|
+
* Send a message to the twin.
|
|
850
|
+
* - Without callback: Fire-and-forget (returns void)
|
|
851
|
+
* - With callback: Request-response pattern (returns Promise)
|
|
852
|
+
*/
|
|
853
|
+
emit: {
|
|
854
|
+
(eventType: string, payload: any): void;
|
|
855
|
+
(eventType: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
856
|
+
};
|
|
857
|
+
/** Listen for events/actions, with optional respond callback for request-response */
|
|
858
|
+
on: (eventType: string, callback: (message: any, respond?: (result: TwinMessageResult) => void) => void) => void;
|
|
859
|
+
/** Send event to a specific twin */
|
|
860
|
+
to: (targetTwinId: string) => {
|
|
861
|
+
emit: {
|
|
862
|
+
(eventType: string, payload: any): void;
|
|
863
|
+
(eventType: string, payload: any, callback: (response: TwinMessageResult) => void): Promise<TwinMessageResult>;
|
|
864
|
+
};
|
|
865
|
+
};
|
|
827
866
|
getDataChannel: () => Promise<PhygridDataChannel | undefined>;
|
|
828
867
|
onDataChannel: (callback: (dc: PhygridDataChannel) => void) => Promise<void>;
|
|
829
868
|
getMediaStream: () => Promise<{stream: PhygridMediaStream; close: () => void} | undefined>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PhygridDataChannel, WebRTCConnectionOptions } from '../../types/webrtc.types';
|
|
2
|
-
export interface WebRTCDataChannelResult {
|
|
3
|
-
dataChannel: PhygridDataChannel;
|
|
4
|
-
close: () => void;
|
|
5
|
-
_rawPeerConnection?: RTCPeerConnection;
|
|
6
|
-
_rawDataChannel?: RTCDataChannel;
|
|
7
|
-
}
|
|
8
|
-
export type WebRTCDataChannelConnectionResult = WebRTCDataChannelResult;
|
|
9
|
-
export declare function createWebRTCDataChannelConnection(options: WebRTCConnectionOptions): Promise<WebRTCDataChannelConnectionResult>;
|
|
10
|
-
//# sourceMappingURL=datachannel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datachannel.d.ts","sourceRoot":"","sources":["../../../src/services/webrtc/datachannel.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AA4CvF,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,kBAAkB,CAAC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;IACvC,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC;AAED,MAAM,MAAM,iCAAiC,GAAG,uBAAuB,CAAC;AAOxE,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iCAAiC,CAAC,CAyK5C"}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWebRTCDataChannelConnection = createWebRTCDataChannelConnection;
|
|
4
|
-
(async function initializeWebRTCGlobals() {
|
|
5
|
-
if (typeof window !== 'undefined')
|
|
6
|
-
return;
|
|
7
|
-
try {
|
|
8
|
-
const wrtc = require('@roamhq/wrtc');
|
|
9
|
-
if (typeof global.MediaStream === 'undefined' && wrtc.MediaStream) {
|
|
10
|
-
global.MediaStream = wrtc.MediaStream;
|
|
11
|
-
console.log('Global MediaStream initialized');
|
|
12
|
-
}
|
|
13
|
-
if (typeof global.RTCDataChannel === 'undefined' && wrtc.RTCDataChannel) {
|
|
14
|
-
global.RTCDataChannel = wrtc.RTCDataChannel;
|
|
15
|
-
console.log('Global RTCDataChannel initialized');
|
|
16
|
-
}
|
|
17
|
-
if (typeof global.RTCPeerConnection === 'undefined' && wrtc.RTCPeerConnection) {
|
|
18
|
-
global.RTCPeerConnection = wrtc.RTCPeerConnection;
|
|
19
|
-
console.log('Global RTCPeerConnection initialized');
|
|
20
|
-
}
|
|
21
|
-
if (typeof global.RTCSessionDescription === 'undefined' && wrtc.RTCSessionDescription) {
|
|
22
|
-
global.RTCSessionDescription = wrtc.RTCSessionDescription;
|
|
23
|
-
console.log('Global RTCSessionDescription initialized');
|
|
24
|
-
}
|
|
25
|
-
if (typeof global.RTCIceCandidate === 'undefined' && wrtc.RTCIceCandidate) {
|
|
26
|
-
global.RTCIceCandidate = wrtc.RTCIceCandidate;
|
|
27
|
-
console.log('Global RTCIceCandidate initialized');
|
|
28
|
-
}
|
|
29
|
-
console.log('WebRTC globals successfully initialized');
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error('Failed to initialize WebRTC globals:', error);
|
|
33
|
-
}
|
|
34
|
-
})().catch(err => console.error('Error in WebRTC globals initialization:', err));
|
|
35
|
-
const peer_connection_ice_1 = require("./peer-connection-ice");
|
|
36
|
-
(async function initializeWebRTCGlobals() {
|
|
37
|
-
if (typeof window !== 'undefined')
|
|
38
|
-
return;
|
|
39
|
-
try {
|
|
40
|
-
const wrtc = require('@roamhq/wrtc');
|
|
41
|
-
if (typeof global.MediaStream === 'undefined' && wrtc.MediaStream) {
|
|
42
|
-
global.MediaStream = wrtc.MediaStream;
|
|
43
|
-
console.log('Global MediaStream initialized');
|
|
44
|
-
}
|
|
45
|
-
if (typeof global.RTCPeerConnection === 'undefined' && wrtc.RTCPeerConnection) {
|
|
46
|
-
global.RTCPeerConnection = wrtc.RTCPeerConnection;
|
|
47
|
-
console.log('Global RTCPeerConnection initialized');
|
|
48
|
-
}
|
|
49
|
-
if (typeof global.RTCSessionDescription === 'undefined' && wrtc.RTCSessionDescription) {
|
|
50
|
-
global.RTCSessionDescription = wrtc.RTCSessionDescription;
|
|
51
|
-
console.log('Global RTCSessionDescription initialized');
|
|
52
|
-
}
|
|
53
|
-
if (typeof global.RTCIceCandidate === 'undefined' && wrtc.RTCIceCandidate) {
|
|
54
|
-
global.RTCIceCandidate = wrtc.RTCIceCandidate;
|
|
55
|
-
console.log('Global RTCIceCandidate initialized');
|
|
56
|
-
}
|
|
57
|
-
console.log('WebRTC globals successfully initialized');
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
console.error('Failed to initialize WebRTC globals:', error);
|
|
61
|
-
}
|
|
62
|
-
})().catch(err => console.error('Error in WebRTC globals initialization:', err));
|
|
63
|
-
const CONNECTION_TIMEOUT = 15000;
|
|
64
|
-
const RECONNECT_DELAY = 1000;
|
|
65
|
-
const INITIAL_RETRY_DELAY = 1000;
|
|
66
|
-
const MAX_RETRY_DELAY = 30000;
|
|
67
|
-
async function createWebRTCDataChannelConnection(options) {
|
|
68
|
-
let pc = null;
|
|
69
|
-
let isShuttingDown = false;
|
|
70
|
-
let isReconnecting = false;
|
|
71
|
-
let currentConnectionId = 0;
|
|
72
|
-
let pendingCandidates = [];
|
|
73
|
-
let activeDataChannel = null;
|
|
74
|
-
const { targetTwinId, sendTwinMessage, subscribeTwin, onTwinMessage, offTwinMessage, useStun = true, isInitiator = true, channelPrefix = 'channel', mediaOptions = { isMediaConnection: false }, } = options;
|
|
75
|
-
const { persistentChannel, setupDataChannel, setCleanupFn } = createPersistentDataChannel();
|
|
76
|
-
setCleanupFn(() => {
|
|
77
|
-
if (mediaOptions.isMediaConnection && mediaOptions.localStream) {
|
|
78
|
-
mediaOptions.localStream.getTracks().forEach(track => track.stop());
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const callbacks = {
|
|
82
|
-
async onCreateConnection(pcInstance, connectionId, localInitiator) {
|
|
83
|
-
console.log(`Creating data channel for connection ID: ${connectionId} ${JSON.stringify(localInitiator)}`);
|
|
84
|
-
const channelId = `${channelPrefix}-${targetTwinId}`;
|
|
85
|
-
return new Promise(resolve => {
|
|
86
|
-
if (isInitiator) {
|
|
87
|
-
const dataChannel = pcInstance.createDataChannel(channelId);
|
|
88
|
-
dataChannel.binaryType = 'arraybuffer';
|
|
89
|
-
setupDataChannel(dataChannel, isReconnecting, isShuttingDown, triggerReconnect);
|
|
90
|
-
resolve(dataChannel);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
pcInstance.ondatachannel = event => {
|
|
94
|
-
console.log('Data channel received in hub-client');
|
|
95
|
-
const dataChannel = event.channel;
|
|
96
|
-
dataChannel.binaryType = 'arraybuffer';
|
|
97
|
-
setupDataChannel(dataChannel, isReconnecting, isShuttingDown, triggerReconnect);
|
|
98
|
-
};
|
|
99
|
-
resolve(null);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
onCloseCleanup() {
|
|
104
|
-
if (mediaOptions.isMediaConnection && mediaOptions.localStream) {
|
|
105
|
-
mediaOptions.localStream.getTracks().forEach(track => track.stop());
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
async onSubscribe() {
|
|
109
|
-
await subscribeTwin(targetTwinId);
|
|
110
|
-
},
|
|
111
|
-
async sendSignalingMessage(type, data) {
|
|
112
|
-
await sendTwinMessage(targetTwinId, {
|
|
113
|
-
type: `${channelPrefix}-${targetTwinId}:${type}`,
|
|
114
|
-
data,
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
setupMessageHandling(messageHandler) {
|
|
118
|
-
onTwinMessage(targetTwinId, messageHandler);
|
|
119
|
-
},
|
|
120
|
-
removeMessageHandling(messageHandler) {
|
|
121
|
-
console.log(`Removing message listener for twin ${targetTwinId}`);
|
|
122
|
-
offTwinMessage(targetTwinId, messageHandler);
|
|
123
|
-
},
|
|
124
|
-
reportConnectionState(info) {
|
|
125
|
-
console.log(info);
|
|
126
|
-
},
|
|
127
|
-
reportError(info, error) {
|
|
128
|
-
console.error(info, error || '');
|
|
129
|
-
},
|
|
130
|
-
async retryConnection(retries, toggledUseStun, nextDelay) {
|
|
131
|
-
isReconnecting = false;
|
|
132
|
-
return (0, peer_connection_ice_1.attemptConnection)(state, { ...options, useStun: toggledUseStun !== null && toggledUseStun !== void 0 ? toggledUseStun : useStun }, retries, toggledUseStun !== null && toggledUseStun !== void 0 ? toggledUseStun : useStun, nextDelay !== null && nextDelay !== void 0 ? nextDelay : INITIAL_RETRY_DELAY, INITIAL_RETRY_DELAY, CONNECTION_TIMEOUT, MAX_RETRY_DELAY, callbacks);
|
|
133
|
-
},
|
|
134
|
-
safeReject(error) {
|
|
135
|
-
throw error;
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
const state = {
|
|
139
|
-
pc,
|
|
140
|
-
isShuttingDown,
|
|
141
|
-
isReconnecting,
|
|
142
|
-
currentConnectionId,
|
|
143
|
-
pendingCandidates,
|
|
144
|
-
activeDataChannel,
|
|
145
|
-
useStun,
|
|
146
|
-
channelPrefix,
|
|
147
|
-
targetTwinId,
|
|
148
|
-
isInitiator,
|
|
149
|
-
connectionType: 'datachannel',
|
|
150
|
-
};
|
|
151
|
-
function triggerReconnect(attempt) {
|
|
152
|
-
if (isReconnecting || isShuttingDown) {
|
|
153
|
-
console.log(`triggerReconnect() called but already reconnecting or shutting down (attempt ${attempt})`);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
isReconnecting = true;
|
|
157
|
-
(0, peer_connection_ice_1.triggerReconnect)(state, attempt, RECONNECT_DELAY, callbacks);
|
|
158
|
-
}
|
|
159
|
-
const result = await (0, peer_connection_ice_1.attemptConnection)(state, { ...options }, 0, useStun, INITIAL_RETRY_DELAY, INITIAL_RETRY_DELAY, CONNECTION_TIMEOUT, MAX_RETRY_DELAY, callbacks);
|
|
160
|
-
return {
|
|
161
|
-
dataChannel: persistentChannel,
|
|
162
|
-
_rawPeerConnection: result._rawPeerConnection,
|
|
163
|
-
_rawDataChannel: result._rawDataChannel,
|
|
164
|
-
close: () => {
|
|
165
|
-
isShuttingDown = true;
|
|
166
|
-
if (result.close) {
|
|
167
|
-
result.close();
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
const createPersistentDataChannel = () => {
|
|
173
|
-
const messageListeners = [];
|
|
174
|
-
const closeListeners = [];
|
|
175
|
-
let currentDataChannel = null;
|
|
176
|
-
let activeDataChannel = null;
|
|
177
|
-
let reconnectAttempts = 0;
|
|
178
|
-
let cleanupFn = null;
|
|
179
|
-
const setCleanupFn = (fn) => {
|
|
180
|
-
cleanupFn = fn;
|
|
181
|
-
};
|
|
182
|
-
const persistentChannel = {
|
|
183
|
-
send: (data) => {
|
|
184
|
-
if (activeDataChannel && activeDataChannel.readyState === 'open') {
|
|
185
|
-
try {
|
|
186
|
-
if (typeof data === 'object' && data !== null) {
|
|
187
|
-
activeDataChannel.send(JSON.stringify(data));
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
activeDataChannel.send(data);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
catch (error) {
|
|
194
|
-
console.error('Error sending data:', error);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
console.warn('Channel not ready, dropping message. State:', activeDataChannel ? activeDataChannel.readyState : 'no channel');
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
onMessage: (callback) => {
|
|
202
|
-
console.log('Adding message listener to persistent channel');
|
|
203
|
-
messageListeners.push(callback);
|
|
204
|
-
},
|
|
205
|
-
offMessage: (callback) => {
|
|
206
|
-
const index = messageListeners.indexOf(callback);
|
|
207
|
-
if (index !== -1) {
|
|
208
|
-
messageListeners.splice(index, 1);
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
onClose: (callback) => {
|
|
212
|
-
closeListeners.push(callback);
|
|
213
|
-
},
|
|
214
|
-
offClose: (callback) => {
|
|
215
|
-
const index = closeListeners.indexOf(callback);
|
|
216
|
-
if (index !== -1) {
|
|
217
|
-
closeListeners.splice(index, 1);
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
close: () => {
|
|
221
|
-
if (currentDataChannel && currentDataChannel.readyState !== 'closed') {
|
|
222
|
-
currentDataChannel.close();
|
|
223
|
-
}
|
|
224
|
-
if (cleanupFn)
|
|
225
|
-
cleanupFn();
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
const setupDataChannel = (dc, isReconnecting, isShuttingDown, triggerReconnect) => {
|
|
229
|
-
console.log('Setting up data channel with listeners');
|
|
230
|
-
currentDataChannel = dc;
|
|
231
|
-
activeDataChannel = dc;
|
|
232
|
-
dc.onopen = () => {
|
|
233
|
-
console.log('Data channel opened in setupDataChannel, readyState:', dc.readyState);
|
|
234
|
-
currentDataChannel = dc;
|
|
235
|
-
activeDataChannel = dc;
|
|
236
|
-
};
|
|
237
|
-
dc.onmessage = event => {
|
|
238
|
-
console.log('Received message in data channel:', typeof event.data);
|
|
239
|
-
let parsedData = event.data;
|
|
240
|
-
if (typeof event.data === 'string') {
|
|
241
|
-
try {
|
|
242
|
-
parsedData = JSON.parse(event.data);
|
|
243
|
-
}
|
|
244
|
-
catch (e) {
|
|
245
|
-
parsedData = event.data;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
if (messageListeners.length === 0) {
|
|
249
|
-
console.warn('No message listeners registered for data channel');
|
|
250
|
-
}
|
|
251
|
-
messageListeners.forEach(listener => {
|
|
252
|
-
try {
|
|
253
|
-
listener(parsedData);
|
|
254
|
-
}
|
|
255
|
-
catch (error) {
|
|
256
|
-
console.error('Error handling message:', error);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
|
-
dc.onclose = () => {
|
|
261
|
-
console.log('Data channel closed');
|
|
262
|
-
closeListeners.forEach(listener => {
|
|
263
|
-
try {
|
|
264
|
-
listener();
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
console.error('Error in close listener:', error);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
if (!isShuttingDown && !isReconnecting) {
|
|
271
|
-
console.log('Data channel closed unexpectedly, triggering reconnect');
|
|
272
|
-
triggerReconnect(reconnectAttempts++);
|
|
273
|
-
}
|
|
274
|
-
activeDataChannel = null;
|
|
275
|
-
};
|
|
276
|
-
dc.onerror = error => {
|
|
277
|
-
console.error('Data channel error:', error);
|
|
278
|
-
if (!isShuttingDown && !isReconnecting) {
|
|
279
|
-
console.log('Data channel error, triggering reconnect');
|
|
280
|
-
triggerReconnect(reconnectAttempts++);
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
};
|
|
284
|
-
return {
|
|
285
|
-
persistentChannel,
|
|
286
|
-
setupDataChannel,
|
|
287
|
-
setCleanupFn,
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
|
-
//# sourceMappingURL=datachannel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"datachannel.js","sourceRoot":"","sources":["../../../src/services/webrtc/datachannel.ts"],"names":[],"mappings":";;AAmGA,8EA2KC;AA7QD,CAAC,KAAK,UAAU,uBAAuB;IAErC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAE1C,IAAI,CAAC;QAEH,MAAM,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;QAGrC,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAClE,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,WAAW,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxE,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,OAAO,MAAM,CAAC,iBAAiB,KAAK,WAAW,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC9E,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,OAAO,MAAM,CAAC,qBAAqB,KAAK,WAAW,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACtF,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,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C;YACD,iBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC,CAAC;QAEF,EAAE,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;YAE5C,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,EAAE,CAAC;gBACvC,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;gBACxD,gBAAgB,CAAC,iBAAiB,EAAE,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,iBAAiB;QACjB,gBAAgB;QAChB,YAAY;KACb,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PhygridMediaStream, WebRTCConnectionOptions } from '../../types/webrtc.types';
|
|
2
|
-
export interface WebRTCMediaStreamResult {
|
|
3
|
-
mediaStream: PhygridMediaStream;
|
|
4
|
-
close: () => void;
|
|
5
|
-
_rawPeerConnection?: RTCPeerConnection;
|
|
6
|
-
_rawMediaStream?: MediaStream;
|
|
7
|
-
}
|
|
8
|
-
export type WebRTCMediaStreamConnectionResult = WebRTCMediaStreamResult;
|
|
9
|
-
export declare function createWebRTCMediaStreamConnection(options: WebRTCConnectionOptions): Promise<WebRTCMediaStreamConnectionResult>;
|
|
10
|
-
//# sourceMappingURL=mediastream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mediastream.d.ts","sourceRoot":"","sources":["../../../src/services/webrtc/mediastream.ts"],"names":[],"mappings":"AAyCA,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EAExB,MAAM,0BAA0B,CAAC;AAQlC,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,kBAAkB,CAAC;IAChC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;IACvC,eAAe,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,MAAM,iCAAiC,GAAG,uBAAuB,CAAC;AAQxE,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iCAAiC,CAAC,CAiQ5C"}
|