@purplecallio/react-native 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +266 -0
- package/dist/components/VideoView.d.ts +31 -0
- package/dist/components/VideoView.d.ts.map +1 -0
- package/dist/components/VideoView.js +45 -0
- package/dist/components/VideoView.js.map +1 -0
- package/dist/context.d.ts +79 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +247 -0
- package/dist/context.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +24 -0
- package/dist/errors.js.map +1 -0
- package/dist/hooks.d.ts +53 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +98 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/optional/inCallManager.d.ts +46 -0
- package/dist/optional/inCallManager.d.ts.map +1 -0
- package/dist/optional/inCallManager.js +79 -0
- package/dist/optional/inCallManager.js.map +1 -0
- package/dist/optional/netInfo.d.ts +38 -0
- package/dist/optional/netInfo.d.ts.map +1 -0
- package/dist/optional/netInfo.js +69 -0
- package/dist/optional/netInfo.js.map +1 -0
- package/dist/permissions.d.ts +29 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +41 -0
- package/dist/permissions.js.map +1 -0
- package/package.json +65 -0
package/dist/context.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.useMeetingContext = useMeetingContext;
|
|
37
|
+
exports.PurpleCallioProvider = PurpleCallioProvider;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const react_native_1 = require("react-native");
|
|
40
|
+
const sdk_1 = require("@purplecallio/sdk");
|
|
41
|
+
const errors_1 = require("./errors");
|
|
42
|
+
const inCallManager_1 = require("./optional/inCallManager");
|
|
43
|
+
const permissions_1 = require("./permissions");
|
|
44
|
+
const MeetingContext = (0, react_1.createContext)(null);
|
|
45
|
+
function useMeetingContext() {
|
|
46
|
+
const ctx = (0, react_1.useContext)(MeetingContext);
|
|
47
|
+
if (!ctx) {
|
|
48
|
+
throw new Error('useMeeting* hooks must be used within a <PurpleCallioProvider>');
|
|
49
|
+
}
|
|
50
|
+
return ctx;
|
|
51
|
+
}
|
|
52
|
+
const SCREEN_SHARE_UNSUPPORTED_MESSAGE = 'Screen sharing is not yet available on React Native — it requires native platform ' +
|
|
53
|
+
'integration (iOS Broadcast Upload Extension / Android MediaProjection) not yet ' +
|
|
54
|
+
'implemented in @purplecallio/react-native.';
|
|
55
|
+
function PurpleCallioProvider({ token, callId, signalUrl, video = true, audio = true, iceServers, overrideIceServers, pauseVideoInBackground = true, onStateChange, children, }) {
|
|
56
|
+
const engineRef = (0, react_1.useRef)(null);
|
|
57
|
+
const [connectionState, setConnectionState] = (0, react_1.useState)('idle');
|
|
58
|
+
const [participants, setParticipants] = (0, react_1.useState)([]);
|
|
59
|
+
const [media, setMedia] = (0, react_1.useState)({
|
|
60
|
+
camera: video,
|
|
61
|
+
microphone: audio,
|
|
62
|
+
screenShare: false,
|
|
63
|
+
});
|
|
64
|
+
const [remoteStream, setRemoteStream] = (0, react_1.useState)(null);
|
|
65
|
+
const [localStream, setLocalStream] = (0, react_1.useState)(null);
|
|
66
|
+
const [participantId, setParticipantId] = (0, react_1.useState)(null);
|
|
67
|
+
const [permissionsGranted, setPermissionsGranted] = (0, react_1.useState)(null);
|
|
68
|
+
// Create the engine once. @purplecallio/sdk's PurpleCallioMeeting is used
|
|
69
|
+
// unmodified here — this package is purely a framework adapter (lifecycle,
|
|
70
|
+
// permissions, rendering, audio routing), not a WebRTC/signaling
|
|
71
|
+
// reimplementation.
|
|
72
|
+
if (!engineRef.current) {
|
|
73
|
+
engineRef.current = new sdk_1.PurpleCallioMeeting({
|
|
74
|
+
token,
|
|
75
|
+
callId,
|
|
76
|
+
signalUrl,
|
|
77
|
+
video,
|
|
78
|
+
audio,
|
|
79
|
+
iceServers,
|
|
80
|
+
overrideIceServers,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const engine = engineRef.current;
|
|
84
|
+
// Subscribe to engine events.
|
|
85
|
+
(0, react_1.useEffect)(() => {
|
|
86
|
+
if (!engine)
|
|
87
|
+
return;
|
|
88
|
+
const offs = [];
|
|
89
|
+
offs.push(engine.on('connected', (p) => {
|
|
90
|
+
setConnectionState('connected');
|
|
91
|
+
setParticipantId(p.participantId);
|
|
92
|
+
}));
|
|
93
|
+
offs.push(engine.on('reconnected', () => setConnectionState('connected')));
|
|
94
|
+
offs.push(engine.on('disconnected', () => setConnectionState('disconnected')));
|
|
95
|
+
offs.push(engine.on('remote.stream', (stream) => setRemoteStream(stream)));
|
|
96
|
+
offs.push(engine.on('remote.stream.ended', () => setRemoteStream(null)));
|
|
97
|
+
offs.push(engine.on('participant.joined', () => setParticipants(engine.participants())));
|
|
98
|
+
offs.push(engine.on('participant.left', () => setParticipants(engine.participants())));
|
|
99
|
+
offs.push(engine.on('participant.updated', () => setParticipants(engine.participants())));
|
|
100
|
+
offs.push(engine.on('camera.enabled', () => setMedia((m) => ({ ...m, camera: true }))));
|
|
101
|
+
offs.push(engine.on('camera.disabled', () => setMedia((m) => ({ ...m, camera: false }))));
|
|
102
|
+
offs.push(engine.on('microphone.enabled', () => setMedia((m) => ({ ...m, microphone: true }))));
|
|
103
|
+
offs.push(engine.on('microphone.disabled', () => setMedia((m) => ({ ...m, microphone: false }))));
|
|
104
|
+
// Also poll onConnectionStateChanged directly so states the engine sets
|
|
105
|
+
// without a matching named event (e.g. 'connecting', 'joining') are
|
|
106
|
+
// reflected too — we pass through whatever the core engine reports,
|
|
107
|
+
// faithfully, rather than inventing our own state machine on top of it.
|
|
108
|
+
offs.push(engine.onConnectionStateChanged((state) => setConnectionState(state)));
|
|
109
|
+
return () => {
|
|
110
|
+
offs.forEach((off) => off());
|
|
111
|
+
};
|
|
112
|
+
}, [engine]);
|
|
113
|
+
// Sync localStream from engine when it becomes available. The engine
|
|
114
|
+
// doesn't emit a dedicated "local stream ready" event, so we poll its
|
|
115
|
+
// getter — mirrors the same pattern @purplecallio/react uses.
|
|
116
|
+
(0, react_1.useEffect)(() => {
|
|
117
|
+
if (!engine)
|
|
118
|
+
return;
|
|
119
|
+
const t = setInterval(() => {
|
|
120
|
+
const stream = engine.localStreamRef;
|
|
121
|
+
if (stream !== localStream)
|
|
122
|
+
setLocalStream(stream);
|
|
123
|
+
}, 250);
|
|
124
|
+
return () => clearInterval(t);
|
|
125
|
+
}, [engine, localStream]);
|
|
126
|
+
// Foreground/background lifecycle: pause the camera while backgrounded.
|
|
127
|
+
const cameraPausedByBackgroundRef = (0, react_1.useRef)(false);
|
|
128
|
+
(0, react_1.useEffect)(() => {
|
|
129
|
+
if (!engine || !pauseVideoInBackground)
|
|
130
|
+
return;
|
|
131
|
+
const subscription = react_native_1.AppState.addEventListener('change', (nextState) => {
|
|
132
|
+
if (nextState === 'background') {
|
|
133
|
+
if (engine.camera.isEnabled()) {
|
|
134
|
+
cameraPausedByBackgroundRef.current = true;
|
|
135
|
+
engine.camera.disable();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (nextState === 'active') {
|
|
139
|
+
if (cameraPausedByBackgroundRef.current) {
|
|
140
|
+
cameraPausedByBackgroundRef.current = false;
|
|
141
|
+
engine.camera.enable();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return () => subscription.remove();
|
|
146
|
+
}, [engine, pauseVideoInBackground]);
|
|
147
|
+
// Cleanup on unmount: the engine already stops local tracks and closes the
|
|
148
|
+
// peer connection in cleanupMedia()/leave(). We additionally make sure our
|
|
149
|
+
// own AppState listener (above, via its own effect cleanup) and
|
|
150
|
+
// InCallManager are torn down.
|
|
151
|
+
(0, react_1.useEffect)(() => {
|
|
152
|
+
return () => {
|
|
153
|
+
inCallManager_1.inCallManager.stop();
|
|
154
|
+
};
|
|
155
|
+
}, []);
|
|
156
|
+
const join = (0, react_1.useCallback)(async () => {
|
|
157
|
+
if (!engine)
|
|
158
|
+
return;
|
|
159
|
+
const granted = await (0, permissions_1.requestMediaPermissions)({ audio, video });
|
|
160
|
+
setPermissionsGranted(granted);
|
|
161
|
+
if (!granted) {
|
|
162
|
+
throw new Error('PurpleCallio: required media permissions were not granted. Camera/microphone ' +
|
|
163
|
+
'access must be allowed (see README for Android manifest / iOS Info.plist setup) ' +
|
|
164
|
+
'before joining a call.');
|
|
165
|
+
}
|
|
166
|
+
await engine.join();
|
|
167
|
+
inCallManager_1.inCallManager.start(video ? 'video' : 'audio');
|
|
168
|
+
}, [engine, audio, video]);
|
|
169
|
+
const leave = (0, react_1.useCallback)(async () => {
|
|
170
|
+
if (!engine)
|
|
171
|
+
return;
|
|
172
|
+
inCallManager_1.inCallManager.stop();
|
|
173
|
+
await engine.leave();
|
|
174
|
+
setConnectionState('disconnected');
|
|
175
|
+
setRemoteStream(null);
|
|
176
|
+
}, [engine]);
|
|
177
|
+
const toggleCamera = (0, react_1.useCallback)(() => engine?.camera.toggle(), [engine]);
|
|
178
|
+
const toggleMicrophone = (0, react_1.useCallback)(() => engine?.microphone.toggle(), [engine]);
|
|
179
|
+
const enableCamera = (0, react_1.useCallback)(() => engine?.camera.enable(), [engine]);
|
|
180
|
+
const disableCamera = (0, react_1.useCallback)(() => engine?.camera.disable(), [engine]);
|
|
181
|
+
const enableMicrophone = (0, react_1.useCallback)(() => engine?.microphone.enable(), [engine]);
|
|
182
|
+
const disableMicrophone = (0, react_1.useCallback)(() => engine?.microphone.disable(), [engine]);
|
|
183
|
+
const screenShare = (0, react_1.useMemo)(() => ({
|
|
184
|
+
start: () => Promise.reject(new errors_1.PurpleCallioUnsupportedFeatureError(SCREEN_SHARE_UNSUPPORTED_MESSAGE)),
|
|
185
|
+
stop: () => { },
|
|
186
|
+
isActive: () => false,
|
|
187
|
+
}), []);
|
|
188
|
+
const switchCamera = (0, react_1.useCallback)(() => {
|
|
189
|
+
const stream = engine?.localStreamRef;
|
|
190
|
+
const videoTrack = stream?.getVideoTracks?.()[0];
|
|
191
|
+
// `_switchCamera` is react-native-webrtc's native camera-switch API. It
|
|
192
|
+
// isn't part of the standard MediaStreamTrack type, hence the cast.
|
|
193
|
+
videoTrack?._switchCamera?.();
|
|
194
|
+
}, [engine]);
|
|
195
|
+
const setSpeakerphoneOn = (0, react_1.useCallback)((enabled) => {
|
|
196
|
+
inCallManager_1.inCallManager.setSpeakerphoneOn(enabled);
|
|
197
|
+
}, []);
|
|
198
|
+
const value = (0, react_1.useMemo)(() => ({
|
|
199
|
+
engine,
|
|
200
|
+
callId,
|
|
201
|
+
participantId,
|
|
202
|
+
connectionState,
|
|
203
|
+
participants,
|
|
204
|
+
media,
|
|
205
|
+
remoteStream,
|
|
206
|
+
localStream,
|
|
207
|
+
permissionsGranted,
|
|
208
|
+
join,
|
|
209
|
+
leave,
|
|
210
|
+
toggleCamera,
|
|
211
|
+
toggleMicrophone,
|
|
212
|
+
enableCamera,
|
|
213
|
+
disableCamera,
|
|
214
|
+
enableMicrophone,
|
|
215
|
+
disableMicrophone,
|
|
216
|
+
screenShare,
|
|
217
|
+
switchCamera,
|
|
218
|
+
setSpeakerphoneOn,
|
|
219
|
+
}), [
|
|
220
|
+
engine,
|
|
221
|
+
callId,
|
|
222
|
+
participantId,
|
|
223
|
+
connectionState,
|
|
224
|
+
participants,
|
|
225
|
+
media,
|
|
226
|
+
remoteStream,
|
|
227
|
+
localStream,
|
|
228
|
+
permissionsGranted,
|
|
229
|
+
join,
|
|
230
|
+
leave,
|
|
231
|
+
toggleCamera,
|
|
232
|
+
toggleMicrophone,
|
|
233
|
+
enableCamera,
|
|
234
|
+
disableCamera,
|
|
235
|
+
enableMicrophone,
|
|
236
|
+
disableMicrophone,
|
|
237
|
+
screenShare,
|
|
238
|
+
switchCamera,
|
|
239
|
+
setSpeakerphoneOn,
|
|
240
|
+
]);
|
|
241
|
+
(0, react_1.useEffect)(() => {
|
|
242
|
+
onStateChange?.(value);
|
|
243
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
|
+
}, [value, onStateChange]);
|
|
245
|
+
return react_1.default.createElement(MeetingContext.Provider, { value: value }, children);
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,8CAMC;AAOD,oDAkOC;AA/UD,+CAQe;AACf,+CAAwD;AAExD,2CAAsF;AAEtF,qCAA+D;AAC/D,4DAAyD;AACzD,+CAAwD;AA+ExD,MAAM,cAAc,GAAG,IAAA,qBAAa,EAA6B,IAAI,CAAC,CAAC;AAEvE,SAAgB,iBAAiB;IAC/B,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,cAAc,CAAC,CAAC;IACvC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,gCAAgC,GACpC,oFAAoF;IACpF,iFAAiF;IACjF,4CAA4C,CAAC;AAE/C,SAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,GAAG,IAAI,EACZ,KAAK,GAAG,IAAI,EACZ,UAAU,EACV,kBAAkB,EAClB,sBAAsB,GAAG,IAAI,EAC7B,aAAa,EACb,QAAQ,GACkB;IAC1B,MAAM,SAAS,GAAG,IAAA,cAAM,EAA6B,IAAI,CAAC,CAAC;IAE3D,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAkB,MAAM,CAAC,CAAC;IAChF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAgB,EAAE,CAAC,CAAC;IACpE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC;QACjC,MAAM,EAAE,KAAK;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YAAY;QACZ,gBAAgB;QAChB,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,iBAAiB;QACjB,WAAW;QACX,YAAY;QACZ,iBAAiB;KAClB,CAAC,EACF;QACE,MAAM;QACN,MAAM;QACN,aAAa;QACb,eAAe;QACf,YAAY;QACZ,KAAK;QACL,YAAY;QACZ,WAAW;QACX,kBAAkB;QAClB,IAAI;QACJ,KAAK;QACL,YAAY;QACZ,gBAAgB;QAChB,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,iBAAiB;QACjB,WAAW;QACX,YAAY;QACZ,iBAAiB;KAClB,CACF,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;QACvB,uDAAuD;IACzD,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;IAE3B,OAAO,8BAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAA2B,CAAC;AACrF,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a feature exposed by `@purplecallio/sdk`'s engine has no real
|
|
3
|
+
* implementation on React Native yet.
|
|
4
|
+
*
|
|
5
|
+
* Today this is used exclusively for screen sharing: mobile screen capture
|
|
6
|
+
* requires OS-level native integration (iOS Broadcast Upload Extension,
|
|
7
|
+
* Android foreground MediaProjection service) that is out of scope for a
|
|
8
|
+
* pure JS/TS adapter package. See the README's "Known Limitations" section.
|
|
9
|
+
*/
|
|
10
|
+
export declare class PurpleCallioUnsupportedFeatureError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,mCAAoC,SAAQ,KAAK;gBAChD,OAAO,EAAE,MAAM;CAS5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PurpleCallioUnsupportedFeatureError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Thrown when a feature exposed by `@purplecallio/sdk`'s engine has no real
|
|
6
|
+
* implementation on React Native yet.
|
|
7
|
+
*
|
|
8
|
+
* Today this is used exclusively for screen sharing: mobile screen capture
|
|
9
|
+
* requires OS-level native integration (iOS Broadcast Upload Extension,
|
|
10
|
+
* Android foreground MediaProjection service) that is out of scope for a
|
|
11
|
+
* pure JS/TS adapter package. See the README's "Known Limitations" section.
|
|
12
|
+
*/
|
|
13
|
+
class PurpleCallioUnsupportedFeatureError extends Error {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'PurpleCallioUnsupportedFeatureError';
|
|
17
|
+
// Restore the prototype chain — needed because TypeScript's `target`
|
|
18
|
+
// (ES2020) plus extending a built-in like Error can otherwise break
|
|
19
|
+
// `instanceof` checks when transpiled down for older engines.
|
|
20
|
+
Object.setPrototypeOf(this, PurpleCallioUnsupportedFeatureError.prototype);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.PurpleCallioUnsupportedFeatureError = PurpleCallioUnsupportedFeatureError;
|
|
24
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,MAAa,mCAAoC,SAAQ,KAAK;IAC5D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qCAAqC,CAAC;QAElD,qEAAqE;QACrE,oEAAoE;QACpE,8DAA8D;QAC9D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mCAAmC,CAAC,SAAS,CAAC,CAAC;IAC7E,CAAC;CACF;AAVD,kFAUC"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ConnectionState, Participant } from '@purplecallio/sdk';
|
|
2
|
+
/** Access the full meeting state + controls. */
|
|
3
|
+
export declare function useMeeting(): import("./context").MeetingContextValue;
|
|
4
|
+
/** Live list of participants (including yourself). */
|
|
5
|
+
export declare function useParticipants(): Participant[];
|
|
6
|
+
/** Look up a single participant by id. */
|
|
7
|
+
export declare function useParticipant(participantId: string): Participant | undefined;
|
|
8
|
+
/** Live connection state ('idle' | 'connecting' | 'connected' | ...), passed through verbatim from the engine. */
|
|
9
|
+
export declare function useConnection(): ConnectionState;
|
|
10
|
+
export interface DeviceInfo {
|
|
11
|
+
deviceId: string;
|
|
12
|
+
kind: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}
|
|
15
|
+
export interface DevicesResult {
|
|
16
|
+
audioInputs: DeviceInfo[];
|
|
17
|
+
videoInputs: DeviceInfo[];
|
|
18
|
+
/**
|
|
19
|
+
* Always empty. There is no meaningful `audiooutput` device-selection
|
|
20
|
+
* concept on mobile the way there is on web — call audio routing
|
|
21
|
+
* (speaker/earpiece/Bluetooth) is an OS-level concern, not a `deviceId`
|
|
22
|
+
* you pick. Use `switchCamera()` (front/back camera) and
|
|
23
|
+
* `setSpeakerphoneOn()` (speaker vs. earpiece) instead.
|
|
24
|
+
*/
|
|
25
|
+
audioOutputs: DeviceInfo[];
|
|
26
|
+
loading: boolean;
|
|
27
|
+
refresh: () => Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Enumerate available camera/microphone devices via
|
|
31
|
+
* `react-native-webrtc`'s `mediaDevices.enumerateDevices()`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useDevices(): DevicesResult;
|
|
34
|
+
export interface NetworkState {
|
|
35
|
+
/** `false` if `@react-native-community/netinfo` is not installed — see README. */
|
|
36
|
+
supported: boolean;
|
|
37
|
+
isConnected: boolean | null;
|
|
38
|
+
isInternetReachable: boolean | null;
|
|
39
|
+
type: string | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Surfaces device network connectivity via the optional
|
|
43
|
+
* `@react-native-community/netinfo` peer dependency, for a consuming app's
|
|
44
|
+
* own UI (e.g. an "you're offline" banner).
|
|
45
|
+
*
|
|
46
|
+
* This deliberately does NOT drive any reconnection logic — that's
|
|
47
|
+
* core-SDK territory. The engine's own `connectionState()` already reports
|
|
48
|
+
* `'reconnecting'`/`'disconnected'` transitions as the signaling layer sees
|
|
49
|
+
* them; this hook is just a convenience for surfacing *why* that might be
|
|
50
|
+
* happening.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useNetworkState(): NetworkState;
|
|
53
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKjE,gDAAgD;AAChD,wBAAgB,UAAU,4CAEzB;AAED,sDAAsD;AACtD,wBAAgB,eAAe,IAAI,WAAW,EAAE,CAE/C;AAED,0CAA0C;AAC1C,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAG7E;AAED,kHAAkH;AAClH,wBAAgB,aAAa,IAAI,eAAe,CAE/C;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;;;;;OAMG;IACH,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,aAAa,CAqC1C;AAED,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AASD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAsB9C"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMeeting = useMeeting;
|
|
4
|
+
exports.useParticipants = useParticipants;
|
|
5
|
+
exports.useParticipant = useParticipant;
|
|
6
|
+
exports.useConnection = useConnection;
|
|
7
|
+
exports.useDevices = useDevices;
|
|
8
|
+
exports.useNetworkState = useNetworkState;
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const react_native_webrtc_1 = require("react-native-webrtc");
|
|
11
|
+
const context_1 = require("./context");
|
|
12
|
+
const netInfo_1 = require("./optional/netInfo");
|
|
13
|
+
/** Access the full meeting state + controls. */
|
|
14
|
+
function useMeeting() {
|
|
15
|
+
return (0, context_1.useMeetingContext)();
|
|
16
|
+
}
|
|
17
|
+
/** Live list of participants (including yourself). */
|
|
18
|
+
function useParticipants() {
|
|
19
|
+
return (0, context_1.useMeetingContext)().participants;
|
|
20
|
+
}
|
|
21
|
+
/** Look up a single participant by id. */
|
|
22
|
+
function useParticipant(participantId) {
|
|
23
|
+
const participants = useParticipants();
|
|
24
|
+
return participants.find((p) => p.participantId === participantId);
|
|
25
|
+
}
|
|
26
|
+
/** Live connection state ('idle' | 'connecting' | 'connected' | ...), passed through verbatim from the engine. */
|
|
27
|
+
function useConnection() {
|
|
28
|
+
return (0, context_1.useMeetingContext)().connectionState;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Enumerate available camera/microphone devices via
|
|
32
|
+
* `react-native-webrtc`'s `mediaDevices.enumerateDevices()`.
|
|
33
|
+
*/
|
|
34
|
+
function useDevices() {
|
|
35
|
+
const [audioInputs, setAudioInputs] = (0, react_1.useState)([]);
|
|
36
|
+
const [videoInputs, setVideoInputs] = (0, react_1.useState)([]);
|
|
37
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
38
|
+
const refresh = (0, react_1.useCallback)(async () => {
|
|
39
|
+
const devices = (await react_native_webrtc_1.mediaDevices.enumerateDevices());
|
|
40
|
+
const inputs = [];
|
|
41
|
+
const vids = [];
|
|
42
|
+
devices.forEach((d) => {
|
|
43
|
+
const info = { deviceId: d.deviceId, kind: d.kind, label: d.label };
|
|
44
|
+
if (d.kind === 'audioinput')
|
|
45
|
+
inputs.push(info);
|
|
46
|
+
else if (d.kind === 'videoinput')
|
|
47
|
+
vids.push(info);
|
|
48
|
+
});
|
|
49
|
+
setAudioInputs(inputs);
|
|
50
|
+
setVideoInputs(vids);
|
|
51
|
+
setLoading(false);
|
|
52
|
+
}, []);
|
|
53
|
+
(0, react_1.useEffect)(() => {
|
|
54
|
+
refresh();
|
|
55
|
+
}, [refresh]);
|
|
56
|
+
return {
|
|
57
|
+
audioInputs,
|
|
58
|
+
videoInputs,
|
|
59
|
+
audioOutputs: [],
|
|
60
|
+
loading,
|
|
61
|
+
refresh,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const UNSUPPORTED_STATE = {
|
|
65
|
+
supported: false,
|
|
66
|
+
isConnected: null,
|
|
67
|
+
isInternetReachable: null,
|
|
68
|
+
type: null,
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Surfaces device network connectivity via the optional
|
|
72
|
+
* `@react-native-community/netinfo` peer dependency, for a consuming app's
|
|
73
|
+
* own UI (e.g. an "you're offline" banner).
|
|
74
|
+
*
|
|
75
|
+
* This deliberately does NOT drive any reconnection logic — that's
|
|
76
|
+
* core-SDK territory. The engine's own `connectionState()` already reports
|
|
77
|
+
* `'reconnecting'`/`'disconnected'` transitions as the signaling layer sees
|
|
78
|
+
* them; this hook is just a convenience for surfacing *why* that might be
|
|
79
|
+
* happening.
|
|
80
|
+
*/
|
|
81
|
+
function useNetworkState() {
|
|
82
|
+
const [state, setState] = (0, react_1.useState)(() => netInfo_1.netInfo.isSupported() ? { ...UNSUPPORTED_STATE, supported: true } : UNSUPPORTED_STATE);
|
|
83
|
+
(0, react_1.useEffect)(() => {
|
|
84
|
+
if (!netInfo_1.netInfo.isSupported())
|
|
85
|
+
return;
|
|
86
|
+
const apply = (s) => setState({
|
|
87
|
+
supported: true,
|
|
88
|
+
isConnected: s.isConnected,
|
|
89
|
+
isInternetReachable: s.isInternetReachable,
|
|
90
|
+
type: s.type,
|
|
91
|
+
});
|
|
92
|
+
netInfo_1.netInfo.fetch().then((s) => s && apply(s));
|
|
93
|
+
const unsubscribe = netInfo_1.netInfo.subscribe(apply);
|
|
94
|
+
return unsubscribe;
|
|
95
|
+
}, []);
|
|
96
|
+
return state;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;AASA,gCAEC;AAGD,0CAEC;AAGD,wCAGC;AAGD,sCAEC;AA2BD,gCAqCC;AA4BD,0CAsBC;AA7ID,iCAAyD;AACzD,6DAAmD;AAInD,uCAA8C;AAC9C,gDAA+D;AAE/D,gDAAgD;AAChD,SAAgB,UAAU;IACxB,OAAO,IAAA,2BAAiB,GAAE,CAAC;AAC7B,CAAC;AAED,sDAAsD;AACtD,SAAgB,eAAe;IAC7B,OAAO,IAAA,2BAAiB,GAAE,CAAC,Y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W,GAAG,iBAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { PurpleCallioProvider, useMeetingContext } from './context';
|
|
2
|
+
export type { PurpleCallioProviderProps, MeetingContextValue, ScreenShareControls } from './context';
|
|
3
|
+
export { useMeeting, useParticipants, useParticipant, useConnection, useDevices, useNetworkState } from './hooks';
|
|
4
|
+
export type { DeviceInfo, DevicesResult, NetworkState } from './hooks';
|
|
5
|
+
export { PurpleCallioVideoView } from './components/VideoView';
|
|
6
|
+
export type { PurpleCallioVideoViewProps } from './components/VideoView';
|
|
7
|
+
export { requestMediaPermissions } from './permissions';
|
|
8
|
+
export type { RequestMediaPermissionsOptions } from './permissions';
|
|
9
|
+
export { PurpleCallioUnsupportedFeatureError } from './errors';
|
|
10
|
+
export declare function setSpeakerphoneOn(enabled: boolean): void;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAClH,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAGpE,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAK/D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PurpleCallioUnsupportedFeatureError = exports.requestMediaPermissions = exports.PurpleCallioVideoView = exports.useNetworkState = exports.useDevices = exports.useConnection = exports.useParticipant = exports.useParticipants = exports.useMeeting = exports.useMeetingContext = exports.PurpleCallioProvider = void 0;
|
|
4
|
+
exports.setSpeakerphoneOn = setSpeakerphoneOn;
|
|
5
|
+
// Provider
|
|
6
|
+
var context_1 = require("./context");
|
|
7
|
+
Object.defineProperty(exports, "PurpleCallioProvider", { enumerable: true, get: function () { return context_1.PurpleCallioProvider; } });
|
|
8
|
+
Object.defineProperty(exports, "useMeetingContext", { enumerable: true, get: function () { return context_1.useMeetingContext; } });
|
|
9
|
+
// Hooks
|
|
10
|
+
var hooks_1 = require("./hooks");
|
|
11
|
+
Object.defineProperty(exports, "useMeeting", { enumerable: true, get: function () { return hooks_1.useMeeting; } });
|
|
12
|
+
Object.defineProperty(exports, "useParticipants", { enumerable: true, get: function () { return hooks_1.useParticipants; } });
|
|
13
|
+
Object.defineProperty(exports, "useParticipant", { enumerable: true, get: function () { return hooks_1.useParticipant; } });
|
|
14
|
+
Object.defineProperty(exports, "useConnection", { enumerable: true, get: function () { return hooks_1.useConnection; } });
|
|
15
|
+
Object.defineProperty(exports, "useDevices", { enumerable: true, get: function () { return hooks_1.useDevices; } });
|
|
16
|
+
Object.defineProperty(exports, "useNetworkState", { enumerable: true, get: function () { return hooks_1.useNetworkState; } });
|
|
17
|
+
// Rendering
|
|
18
|
+
var VideoView_1 = require("./components/VideoView");
|
|
19
|
+
Object.defineProperty(exports, "PurpleCallioVideoView", { enumerable: true, get: function () { return VideoView_1.PurpleCallioVideoView; } });
|
|
20
|
+
// Permissions
|
|
21
|
+
var permissions_1 = require("./permissions");
|
|
22
|
+
Object.defineProperty(exports, "requestMediaPermissions", { enumerable: true, get: function () { return permissions_1.requestMediaPermissions; } });
|
|
23
|
+
// Errors
|
|
24
|
+
var errors_1 = require("./errors");
|
|
25
|
+
Object.defineProperty(exports, "PurpleCallioUnsupportedFeatureError", { enumerable: true, get: function () { return errors_1.PurpleCallioUnsupportedFeatureError; } });
|
|
26
|
+
// Standalone audio-routing helper (also available via useMeeting().setSpeakerphoneOn,
|
|
27
|
+
// which is the same underlying bridge instance).
|
|
28
|
+
const inCallManager_1 = require("./optional/inCallManager");
|
|
29
|
+
function setSpeakerphoneOn(enabled) {
|
|
30
|
+
inCallManager_1.inCallManager.setSpeakerphoneOn(enabled);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAsBA,8CAEC;AAxBD,WAAW;AACX,qCAAoE;AAA3D,+GAAA,oBAAoB,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAGhD,QAAQ;AACR,iCAAkH;AAAzG,mGAAA,UAAU,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,wGAAA,eAAe,OAAA;AAGhG,YAAY;AACZ,oDAA+D;AAAtD,kHAAA,qBAAqB,OAAA;AAG9B,cAAc;AACd,6CAAwD;AAA/C,sHAAA,uBAAuB,OAAA;AAGhC,SAAS;AACT,mCAA+D;AAAtD,6HAAA,mCAAmC,OAAA;AAE5C,sFAAsF;AACtF,iDAAiD;AACjD,4DAAyD;AACzD,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,6BAAa,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defensive bridge to the *optional* peer dependency
|
|
3
|
+
* `react-native-incall-manager`, which manages call audio routing
|
|
4
|
+
* (speaker / earpiece / Bluetooth) — something `react-native-webrtc` does
|
|
5
|
+
* not handle on its own.
|
|
6
|
+
*
|
|
7
|
+
* It is listed in package.json as an optional peerDependency
|
|
8
|
+
* (`peerDependenciesMeta.react-native-incall-manager.optional = true`), so
|
|
9
|
+
* consumers who don't need custom audio routing behavior can skip
|
|
10
|
+
* installing it entirely. We load it with `require()` inside a try/catch so
|
|
11
|
+
* a missing install never crashes module evaluation — it just disables
|
|
12
|
+
* automatic audio routing and logs a one-time warning.
|
|
13
|
+
*/
|
|
14
|
+
export interface InCallManagerLike {
|
|
15
|
+
start(options?: {
|
|
16
|
+
media?: 'audio' | 'video';
|
|
17
|
+
auto?: boolean;
|
|
18
|
+
ringback?: string;
|
|
19
|
+
}): void;
|
|
20
|
+
stop(options?: {
|
|
21
|
+
busytone?: string;
|
|
22
|
+
}): void;
|
|
23
|
+
setForceSpeakerphoneOn?(enabled: boolean): void;
|
|
24
|
+
setSpeakerphoneOn?(enabled: boolean): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Default loader: defensively requires the real optional native module.
|
|
28
|
+
* Kept as a plain function (rather than inlined) so `InCallManagerBridge`
|
|
29
|
+
* can be constructed with a fake loader in tests, without needing the real
|
|
30
|
+
* native package installed or mocked at the module resolution level.
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadInCallManager(): InCallManagerLike | null;
|
|
33
|
+
export declare class InCallManagerBridge {
|
|
34
|
+
private readonly load;
|
|
35
|
+
constructor(load?: () => InCallManagerLike | null);
|
|
36
|
+
private resolve;
|
|
37
|
+
/** Called automatically by `<PurpleCallioProvider>` on `join()`. */
|
|
38
|
+
start(media: 'audio' | 'video'): void;
|
|
39
|
+
/** Called automatically by `<PurpleCallioProvider>` on `leave()`/unmount. */
|
|
40
|
+
stop(): void;
|
|
41
|
+
/** Force call audio to the loudspeaker (true) or earpiece/default route (false). */
|
|
42
|
+
setSpeakerphoneOn(enabled: boolean): void;
|
|
43
|
+
}
|
|
44
|
+
/** Shared default instance used by the provider and the standalone `setSpeakerphoneOn` export. */
|
|
45
|
+
export declare const inCallManager: InCallManagerBridge;
|
|
46
|
+
//# sourceMappingURL=inCallManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inCallManager.d.ts","sourceRoot":"","sources":["../../src/optional/inCallManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxF,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5C,sBAAsB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAChD,iBAAiB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC5C;AAeD;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,GAAG,IAAI,CAQ5D;AAED,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,GAAE,MAAM,iBAAiB,GAAG,IAAwB;IAErF,OAAO,CAAC,OAAO;IAMf,oEAAoE;IACpE,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;IAIrC,6EAA6E;IAC7E,IAAI,IAAI,IAAI;IAIZ,oFAAoF;IACpF,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAS1C;AAED,kGAAkG;AAClG,eAAO,MAAM,aAAa,qBAA4B,CAAC"}
|