@q9labsai/chalk-client 4.1.5 → 4.1.8
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/access/grant.d.ts +8 -0
- package/dist/access/grant.d.ts.map +1 -1
- package/dist/{chunk-PBCGWE2V.js → chunk-C4BIONCP.js} +442 -7
- package/dist/chunk-DFLTEYWX.js +144 -0
- package/dist/chunk-JPNE4K2L.js +8911 -0
- package/dist/{chunk-DI7C5UEM.js → chunk-V6P6EHYO.js} +87 -175
- package/dist/client.d.ts +951 -59
- package/dist/client.d.ts.map +1 -1
- package/dist/connection/dependencies.d.ts +4 -4
- package/dist/connection/dependencies.d.ts.map +1 -1
- package/dist/connection/lifecycle.d.ts.map +1 -1
- package/dist/connection/production.d.ts.map +1 -1
- package/dist/connection/snapshot.d.ts +2 -2
- package/dist/connection/snapshot.d.ts.map +1 -1
- package/dist/effect.js +1012 -7052
- package/dist/generated/http-api.d.ts +941 -62
- package/dist/generated/http-api.d.ts.map +1 -1
- package/dist/generated/schemas.d.ts +1353 -31
- package/dist/generated/schemas.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -2
- package/dist/media/client.d.ts.map +1 -1
- package/dist/media/index.d.ts +2 -1
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +5 -1
- package/dist/media/observers.d.ts +3 -0
- package/dist/media/observers.d.ts.map +1 -0
- package/dist/media/plane.d.ts +25 -0
- package/dist/media/plane.d.ts.map +1 -1
- package/dist/media/rtk.d.ts +101 -0
- package/dist/media/rtk.d.ts.map +1 -0
- package/dist/media/target.d.ts +10 -0
- package/dist/media/target.d.ts.map +1 -0
- package/dist/public-invites/client.d.ts +4 -0
- package/dist/public-invites/client.d.ts.map +1 -0
- package/dist/public-invites/index.d.ts +5 -0
- package/dist/public-invites/index.d.ts.map +1 -0
- package/dist/public-invites/index.js +18 -0
- package/dist/public-invites/types.d.ts +67 -0
- package/dist/public-invites/types.d.ts.map +1 -0
- package/dist/server/{chunk-A6YMG5FM.js → chunk-C4XITY5U.js} +1 -1
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/index.cjs +72 -19
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +72 -19
- package/dist/server/server-only.js +1 -1
- package/dist/server/transport.d.cts +1 -1
- package/dist/server/transport.d.ts +1 -1
- package/dist/server/transport.d.ts.map +1 -1
- package/dist/server/types.d.cts +40 -0
- package/dist/server/types.d.ts +40 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/whiteboard/types.d.ts +1 -1
- package/dist/whiteboard/types.d.ts.map +1 -1
- package/dist/whiteboard/v1-client.d.ts +1 -1
- package/dist/whiteboard/v1-client.d.ts.map +1 -1
- package/package.json +20 -2
package/dist/access/grant.d.ts
CHANGED
|
@@ -27,6 +27,14 @@ export type ParticipantMediaAccess = {
|
|
|
27
27
|
readonly connectionId: string;
|
|
28
28
|
readonly stunServer: string;
|
|
29
29
|
};
|
|
30
|
+
} | {
|
|
31
|
+
readonly token: ParticipantMediaCredential;
|
|
32
|
+
readonly expiresAt: string;
|
|
33
|
+
readonly provider: "cloudflare_rtk";
|
|
34
|
+
readonly clientPayload: {
|
|
35
|
+
readonly providerSubject: string;
|
|
36
|
+
readonly token: string;
|
|
37
|
+
};
|
|
30
38
|
};
|
|
31
39
|
export type ParsedAccessGrant = {
|
|
32
40
|
readonly subject: AccessSubject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/access/grant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAGrH,OAAO,CAAC,MAAM,mBAAmB,EAAE,OAAO,MAAM,CAAC;AACjD,OAAO,CAAC,MAAM,oBAAoB,EAAE,OAAO,MAAM,CAAC;AAClD,QAAA,MAAM,gBAAgB,EAAE,OAAO,MAA8B,CAAC;AAE9D,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC;AAClG,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC;AAErG,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../src/access/grant.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
// src/media/observers.ts
|
|
2
|
+
function subscribeSnapshot(listeners, listener) {
|
|
3
|
+
listeners.add(listener);
|
|
4
|
+
return () => {
|
|
5
|
+
listeners.delete(listener);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function observePublications(listeners, listener, project) {
|
|
9
|
+
const publication = () => listener(project());
|
|
10
|
+
listeners.add(publication);
|
|
11
|
+
listener(project());
|
|
12
|
+
return () => {
|
|
13
|
+
listeners.delete(publication);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/media/target.ts
|
|
18
|
+
function resolveMediaTarget(participantId, stopped, tracks, target) {
|
|
19
|
+
if (target.participantId !== participantId) return { kind: "result", result: { outcome: "terminal_failure", errorCode: "invalid_participant" } };
|
|
20
|
+
if (stopped) return { kind: "result", result: { outcome: "terminal_failure", errorCode: "media_stopped" } };
|
|
21
|
+
const value = tracks.get(target.source);
|
|
22
|
+
if (value === void 0) return { kind: "result", result: { outcome: "terminal_failure", errorCode: "source_unavailable" } };
|
|
23
|
+
return { kind: "state", value };
|
|
24
|
+
}
|
|
25
|
+
|
|
1
26
|
// src/media/types.ts
|
|
2
27
|
var CloudflareSFUError = class extends Error {
|
|
3
28
|
constructor(message, code) {
|
|
@@ -157,8 +182,7 @@ var CloudflareSFUClient = class {
|
|
|
157
182
|
return this.#snapshot;
|
|
158
183
|
}
|
|
159
184
|
subscribe(listener) {
|
|
160
|
-
this.#snapshotListeners
|
|
161
|
-
return () => this.#snapshotListeners.delete(listener);
|
|
185
|
+
return subscribeSnapshot(this.#snapshotListeners, listener);
|
|
162
186
|
}
|
|
163
187
|
prepareLocalTrack(source, track) {
|
|
164
188
|
this.#requireActive();
|
|
@@ -225,10 +249,9 @@ var CloudflareSFUClient = class {
|
|
|
225
249
|
}
|
|
226
250
|
}
|
|
227
251
|
async setLocalPublicationTarget(target) {
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
const state =
|
|
231
|
-
if (!state) return { outcome: "terminal_failure", errorCode: "source_unavailable" };
|
|
252
|
+
const resolved = resolveMediaTarget(this.#participantId, this.#stopped, this.#localTracks, target);
|
|
253
|
+
if (resolved.kind === "result") return resolved.result;
|
|
254
|
+
const state = resolved.value;
|
|
232
255
|
if (state.enabled === target.enabled) return { outcome: "satisfied", errorCode: null };
|
|
233
256
|
try {
|
|
234
257
|
await this.#setPreparedTrackEnabled(state, target.enabled, target.operationId);
|
|
@@ -797,6 +820,416 @@ function requireCredential(options) {
|
|
|
797
820
|
throw new CloudflareSFUError("A media credential provider is required", "signaling_failed");
|
|
798
821
|
}
|
|
799
822
|
|
|
823
|
+
// src/media/rtk.ts
|
|
824
|
+
var CloudflareRTKError = class extends Error {
|
|
825
|
+
code;
|
|
826
|
+
constructor(message, code) {
|
|
827
|
+
super(message);
|
|
828
|
+
this.name = "CloudflareRTKError";
|
|
829
|
+
this.code = code;
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
var EMPTY_LOCAL2 = Object.freeze([]);
|
|
833
|
+
var EMPTY_REMOTE2 = Object.freeze([]);
|
|
834
|
+
var CloudflareRTKClient = class {
|
|
835
|
+
#participantId;
|
|
836
|
+
#onError;
|
|
837
|
+
#onScreenEnded;
|
|
838
|
+
#clientFactory;
|
|
839
|
+
#snapshotListeners = /* @__PURE__ */ new Set();
|
|
840
|
+
#sourceOperations = /* @__PURE__ */ new Map();
|
|
841
|
+
#connection = null;
|
|
842
|
+
#localTracks = /* @__PURE__ */ new Map();
|
|
843
|
+
#connectionUnsubscribers = [];
|
|
844
|
+
#participantUnsubscribers = /* @__PURE__ */ new Map();
|
|
845
|
+
#snapshot;
|
|
846
|
+
#stopped = false;
|
|
847
|
+
#screenDisableRequested = false;
|
|
848
|
+
#initialAuthToken;
|
|
849
|
+
constructor(options) {
|
|
850
|
+
if (!options.authToken.trim()) throw new CloudflareRTKError("A RealtimeKit auth token is required", "invalid_client");
|
|
851
|
+
if (!options.participantId.trim()) throw new CloudflareRTKError("A participant ID is required", "invalid_participant");
|
|
852
|
+
this.#participantId = options.participantId;
|
|
853
|
+
this.#onError = options.onError;
|
|
854
|
+
this.#onScreenEnded = options.onScreenEnded;
|
|
855
|
+
this.#clientFactory = options.clientFactory ?? defaultClientFactory;
|
|
856
|
+
this.#snapshot = freezeSnapshot2({
|
|
857
|
+
connection: { phase: "idle", peerConnectionState: null, iceConnectionState: null },
|
|
858
|
+
cursor: null,
|
|
859
|
+
localTracks: EMPTY_LOCAL2,
|
|
860
|
+
remoteTracks: EMPTY_REMOTE2,
|
|
861
|
+
failure: null
|
|
862
|
+
});
|
|
863
|
+
this.#initialAuthToken = options.authToken;
|
|
864
|
+
}
|
|
865
|
+
getSnapshot() {
|
|
866
|
+
return this.#snapshot;
|
|
867
|
+
}
|
|
868
|
+
subscribe(listener) {
|
|
869
|
+
return subscribeSnapshot(this.#snapshotListeners, listener);
|
|
870
|
+
}
|
|
871
|
+
prepareLocalTrack(source, track) {
|
|
872
|
+
this.#requireStartable();
|
|
873
|
+
validateTrack(source, track);
|
|
874
|
+
if (this.#localTracks.has(source)) throw new CloudflareRTKError(`A ${source} track is already prepared`, "media_failed");
|
|
875
|
+
const endedListener = source === "screen" ? () => this.#onScreenEnded?.() : null;
|
|
876
|
+
if (endedListener) track.addEventListener("ended", endedListener);
|
|
877
|
+
this.#localTracks.set(source, { source, track, enabled: false, endedListener });
|
|
878
|
+
this.#publishSnapshot();
|
|
879
|
+
}
|
|
880
|
+
async clearPreparedLocalTrack(source) {
|
|
881
|
+
const state = this.#localTracks.get(source);
|
|
882
|
+
if (!state) return;
|
|
883
|
+
if (state.enabled) {
|
|
884
|
+
await this.#setSourceEnabled(state, false);
|
|
885
|
+
}
|
|
886
|
+
if (state.endedListener) state.track.removeEventListener("ended", state.endedListener);
|
|
887
|
+
this.#localTracks.delete(source);
|
|
888
|
+
this.#publishSnapshot();
|
|
889
|
+
}
|
|
890
|
+
async start(localMedia) {
|
|
891
|
+
if (this.#snapshot.connection.phase === "live") return;
|
|
892
|
+
this.#requireStartable();
|
|
893
|
+
this.#setPhase("connecting", null);
|
|
894
|
+
try {
|
|
895
|
+
const tracks = localMedia.getTracks().filter((track) => track.kind === "audio" || track.kind === "video");
|
|
896
|
+
for (const track of tracks) {
|
|
897
|
+
const source = track.kind === "audio" ? "microphone" : "camera";
|
|
898
|
+
if (!this.#localTracks.has(source)) this.#localTracks.set(source, { source, track, enabled: false, endedListener: null });
|
|
899
|
+
}
|
|
900
|
+
await this.#openConnection(this.#initialAuthToken);
|
|
901
|
+
for (const state of this.#localTracks.values()) {
|
|
902
|
+
if (state.source === "microphone" || state.source === "camera") await this.#setSourceEnabled(state, true);
|
|
903
|
+
}
|
|
904
|
+
this.#setPhase("live", null);
|
|
905
|
+
} catch (error) {
|
|
906
|
+
this.#setFailure(error);
|
|
907
|
+
this.#reportError(error);
|
|
908
|
+
throw error;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
async setLocalPublicationTarget(target) {
|
|
912
|
+
const resolved = resolveMediaTarget(this.#participantId, this.#stopped, this.#localTracks, target);
|
|
913
|
+
if (resolved.kind === "result") return resolved.result;
|
|
914
|
+
const state = resolved.value;
|
|
915
|
+
const previous = this.#sourceOperations.get(target.source) ?? Promise.resolve();
|
|
916
|
+
const operation = previous.catch(() => void 0).then(async () => {
|
|
917
|
+
if (state.enabled === target.enabled) return "satisfied";
|
|
918
|
+
try {
|
|
919
|
+
await this.#setSourceEnabled(state, target.enabled);
|
|
920
|
+
return "confirmed";
|
|
921
|
+
} catch (error) {
|
|
922
|
+
this.#reportError(error);
|
|
923
|
+
return "retryable_failure";
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
this.#sourceOperations.set(target.source, operation);
|
|
927
|
+
try {
|
|
928
|
+
const outcome = await operation;
|
|
929
|
+
return { outcome, errorCode: outcome === "retryable_failure" ? "media_failed" : null };
|
|
930
|
+
} finally {
|
|
931
|
+
if (this.#sourceOperations.get(target.source) === operation) this.#sourceOperations.delete(target.source);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
observeLocalPublications(listener) {
|
|
935
|
+
return observePublications(this.#snapshotListeners, listener, () => this.#projectLocalPublications());
|
|
936
|
+
}
|
|
937
|
+
observeRemotePublications(listener) {
|
|
938
|
+
return observePublications(this.#snapshotListeners, listener, () => this.#projectRemotePublications());
|
|
939
|
+
}
|
|
940
|
+
async restart(input) {
|
|
941
|
+
if (!isRTKAccess(input)) throw new CloudflareRTKError("The RealtimeKit adapter requires a Cloudflare RealtimeKit access grant", "invalid_client");
|
|
942
|
+
if (this.#stopped) throw new CloudflareRTKError("The RealtimeKit media client has stopped", "media_stopped");
|
|
943
|
+
this.#setPhase("recovering", null);
|
|
944
|
+
try {
|
|
945
|
+
await this.#closeConnection();
|
|
946
|
+
await this.#openConnection(input.clientPayload.token);
|
|
947
|
+
for (const state of this.#localTracks.values()) if (state.enabled) await this.#setSourceEnabled(state, true);
|
|
948
|
+
this.#setPhase("live", null);
|
|
949
|
+
} catch (error) {
|
|
950
|
+
this.#setFailure(error);
|
|
951
|
+
this.#reportError(error);
|
|
952
|
+
throw error;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
stop() {
|
|
956
|
+
if (this.#stopped) return;
|
|
957
|
+
this.#stopped = true;
|
|
958
|
+
const leave = this.#closeConnection();
|
|
959
|
+
void leave.catch((error) => this.#reportError(error));
|
|
960
|
+
for (const state of this.#localTracks.values()) if (state.endedListener) state.track.removeEventListener("ended", state.endedListener);
|
|
961
|
+
this.#localTracks.clear();
|
|
962
|
+
this.#setPhase("stopped", null);
|
|
963
|
+
}
|
|
964
|
+
async #openConnection(authToken) {
|
|
965
|
+
this.#connection = await this.#clientFactory({ authToken, onError: (error) => this.#reportError(error) });
|
|
966
|
+
this.#bindConnection(this.#connection);
|
|
967
|
+
await this.#connection.join();
|
|
968
|
+
}
|
|
969
|
+
async #closeConnection() {
|
|
970
|
+
const connection = this.#connection;
|
|
971
|
+
this.#connection = null;
|
|
972
|
+
this.#unbindConnection();
|
|
973
|
+
if (connection) await connection.leave();
|
|
974
|
+
}
|
|
975
|
+
#bindConnection(connection) {
|
|
976
|
+
const selfAudio = connection.self.onAudioUpdate(() => this.#syncLocalState("microphone"));
|
|
977
|
+
const selfVideo = connection.self.onVideoUpdate(() => this.#syncLocalState("camera"));
|
|
978
|
+
const selfScreen = connection.self.onScreenShareUpdate((payload) => {
|
|
979
|
+
this.#syncLocalState("screen");
|
|
980
|
+
if (!payload.screenShareEnabled && !this.#screenDisableRequested) this.#onScreenEnded?.();
|
|
981
|
+
this.#screenDisableRequested = false;
|
|
982
|
+
});
|
|
983
|
+
const connectionLeft = connection.self.onLeft(() => {
|
|
984
|
+
if (this.#stopped) return;
|
|
985
|
+
const error = new CloudflareRTKError("The RealtimeKit connection ended unexpectedly", "media_failed");
|
|
986
|
+
this.#setFailure(error);
|
|
987
|
+
this.#reportError(error);
|
|
988
|
+
});
|
|
989
|
+
for (const participant of connection.participants.joined.list()) this.#bindParticipant(participant);
|
|
990
|
+
const participantJoined = connection.participants.joined.onJoined((participant) => {
|
|
991
|
+
this.#bindParticipant(participant);
|
|
992
|
+
this.#publishSnapshot();
|
|
993
|
+
});
|
|
994
|
+
const participantLeft = connection.participants.joined.onLeft((participant) => {
|
|
995
|
+
this.#unbindParticipant(participant.id);
|
|
996
|
+
this.#publishSnapshot();
|
|
997
|
+
});
|
|
998
|
+
this.#connectionUnsubscribers = [selfAudio, selfVideo, selfScreen, connectionLeft, participantJoined, participantLeft];
|
|
999
|
+
}
|
|
1000
|
+
#unbindConnection() {
|
|
1001
|
+
for (const unsubscribe of this.#connectionUnsubscribers) unsubscribe();
|
|
1002
|
+
this.#connectionUnsubscribers = [];
|
|
1003
|
+
for (const unsubscribers of this.#participantUnsubscribers.values()) for (const unsubscribe of unsubscribers) unsubscribe();
|
|
1004
|
+
this.#participantUnsubscribers.clear();
|
|
1005
|
+
}
|
|
1006
|
+
#bindParticipant(participant) {
|
|
1007
|
+
if (this.#participantUnsubscribers.has(participant.id)) return;
|
|
1008
|
+
const unsubscribers = [participant.onAudioUpdate?.(() => this.#publishSnapshot()), participant.onVideoUpdate?.(() => this.#publishSnapshot()), participant.onScreenShareUpdate?.(() => this.#publishSnapshot())].filter((unsubscribe) => unsubscribe !== void 0);
|
|
1009
|
+
this.#participantUnsubscribers.set(participant.id, unsubscribers);
|
|
1010
|
+
}
|
|
1011
|
+
#unbindParticipant(participantId) {
|
|
1012
|
+
const unsubscribers = this.#participantUnsubscribers.get(participantId);
|
|
1013
|
+
if (!unsubscribers) return;
|
|
1014
|
+
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
1015
|
+
this.#participantUnsubscribers.delete(participantId);
|
|
1016
|
+
}
|
|
1017
|
+
async #setSourceEnabled(state, enabled) {
|
|
1018
|
+
const connection = this.#connection;
|
|
1019
|
+
if (!connection) throw new CloudflareRTKError("The RealtimeKit connection is not active", "media_stopped");
|
|
1020
|
+
if (state.source === "microphone") {
|
|
1021
|
+
if (enabled) await connection.self.enableAudio(state.track);
|
|
1022
|
+
else await connection.self.disableAudio();
|
|
1023
|
+
} else if (state.source === "camera") {
|
|
1024
|
+
if (enabled) await connection.self.enableVideo(state.track);
|
|
1025
|
+
else await connection.self.disableVideo();
|
|
1026
|
+
} else {
|
|
1027
|
+
this.#screenDisableRequested = !enabled;
|
|
1028
|
+
if (enabled) await connection.self.enableScreenShare();
|
|
1029
|
+
else await connection.self.disableScreenShare();
|
|
1030
|
+
}
|
|
1031
|
+
state.enabled = enabled;
|
|
1032
|
+
state.track.enabled = enabled;
|
|
1033
|
+
this.#publishSnapshot();
|
|
1034
|
+
}
|
|
1035
|
+
#syncLocalState(source) {
|
|
1036
|
+
const state = this.#localTracks.get(source);
|
|
1037
|
+
const connection = this.#connection;
|
|
1038
|
+
if (!state || !connection) return;
|
|
1039
|
+
state.enabled = source === "microphone" ? connection.self.audioEnabled : source === "camera" ? connection.self.videoEnabled : connection.self.screenShareEnabled;
|
|
1040
|
+
state.track.enabled = state.enabled;
|
|
1041
|
+
this.#publishSnapshot();
|
|
1042
|
+
}
|
|
1043
|
+
#publishSnapshot() {
|
|
1044
|
+
this.#snapshot = freezeSnapshot2({ ...this.#snapshot, localTracks: this.#projectLocalTracks(), remoteTracks: this.#projectRemoteTracks() });
|
|
1045
|
+
this.#notifyListeners();
|
|
1046
|
+
}
|
|
1047
|
+
#projectLocalTracks() {
|
|
1048
|
+
return Object.freeze([...this.#localTracks.values()].map((state) => ({ source: state.source, enabled: state.enabled, publicationId: `${this.#participantId}:${state.source}`, track: state.track })));
|
|
1049
|
+
}
|
|
1050
|
+
#projectLocalPublications() {
|
|
1051
|
+
return Object.freeze(this.#projectLocalTracks().map((track) => ({ participantId: this.#participantId, source: track.source, enabled: track.enabled, publicationId: track.publicationId })));
|
|
1052
|
+
}
|
|
1053
|
+
#projectRemotePublications() {
|
|
1054
|
+
return Object.freeze(this.#projectRemoteTracks().map((track) => ({ participantId: track.participantId, source: track.source, enabled: true, publicationId: track.publicationId })));
|
|
1055
|
+
}
|
|
1056
|
+
#projectRemoteTracks() {
|
|
1057
|
+
return projectRemoteTracks(this.#connection?.participants.joined.list() ?? []);
|
|
1058
|
+
}
|
|
1059
|
+
#setPhase(phase, failure) {
|
|
1060
|
+
this.#snapshot = freezeSnapshot2({ ...this.#snapshot, connection: { phase, peerConnectionState: null, iceConnectionState: null }, failure });
|
|
1061
|
+
this.#notifyListeners();
|
|
1062
|
+
}
|
|
1063
|
+
#setFailure(error) {
|
|
1064
|
+
this.#setPhase("failed", { code: "media_failed", recoverable: true });
|
|
1065
|
+
if (!(error instanceof CloudflareRTKError)) this.#reportError(error);
|
|
1066
|
+
}
|
|
1067
|
+
#requireStartable() {
|
|
1068
|
+
if (this.#stopped) throw new CloudflareRTKError("The RealtimeKit media client has stopped", "media_stopped");
|
|
1069
|
+
}
|
|
1070
|
+
#reportError(error) {
|
|
1071
|
+
try {
|
|
1072
|
+
this.#onError?.(error);
|
|
1073
|
+
} catch {
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
#notifyListeners() {
|
|
1077
|
+
for (const listener of this.#snapshotListeners) {
|
|
1078
|
+
try {
|
|
1079
|
+
listener();
|
|
1080
|
+
} catch (error) {
|
|
1081
|
+
this.#reportError(error);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
function projectRemoteTracks(participants) {
|
|
1087
|
+
return Object.freeze(participants.flatMap(remoteTracksForParticipant));
|
|
1088
|
+
}
|
|
1089
|
+
function remoteTracksForParticipant(participant) {
|
|
1090
|
+
const participantId = participantIdentifier(participant);
|
|
1091
|
+
if (!participantId) return [];
|
|
1092
|
+
const publications = [];
|
|
1093
|
+
addRemotePublication(publications, participant, participantId, "microphone", participant.audioEnabled ? participant.audioTrack : null);
|
|
1094
|
+
addRemotePublication(publications, participant, participantId, "camera", participant.videoEnabled ? participant.videoTrack : null);
|
|
1095
|
+
addRemotePublication(publications, participant, participantId, "screen", participant.screenShareEnabled ? participant.screenShareTracks.video ?? null : null);
|
|
1096
|
+
return publications;
|
|
1097
|
+
}
|
|
1098
|
+
function participantIdentifier(participant) {
|
|
1099
|
+
return participant.customParticipantId?.trim() || participant.userId.trim() || participant.id.trim();
|
|
1100
|
+
}
|
|
1101
|
+
function addRemotePublication(publications, participant, participantId, source, track) {
|
|
1102
|
+
if (!track) return;
|
|
1103
|
+
publications.push({ participantId, source, publicationId: `${participant.id}:${source}`, track });
|
|
1104
|
+
}
|
|
1105
|
+
function validateTrack(source, track) {
|
|
1106
|
+
const expectedKind = source === "microphone" ? "audio" : "video";
|
|
1107
|
+
if (track.kind !== expectedKind) throw new CloudflareRTKError(`A ${source} track must be ${expectedKind}`, "invalid_target");
|
|
1108
|
+
}
|
|
1109
|
+
function isRTKAccess(value) {
|
|
1110
|
+
return value.provider === "cloudflare_rtk";
|
|
1111
|
+
}
|
|
1112
|
+
function freezeSnapshot2(snapshot) {
|
|
1113
|
+
const failure = snapshot.failure ? Object.freeze(snapshot.failure) : null;
|
|
1114
|
+
return Object.freeze({
|
|
1115
|
+
...snapshot,
|
|
1116
|
+
connection: Object.freeze(snapshot.connection),
|
|
1117
|
+
localTracks: Object.freeze(snapshot.localTracks.map((track) => Object.freeze(track))),
|
|
1118
|
+
remoteTracks: Object.freeze(snapshot.remoteTracks.map((track) => Object.freeze(track))),
|
|
1119
|
+
failure
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
async function defaultClientFactory(input) {
|
|
1123
|
+
const { default: RealtimeKitClient } = await import("@cloudflare/realtimekit");
|
|
1124
|
+
const client = await RealtimeKitClient.init({
|
|
1125
|
+
authToken: input.authToken,
|
|
1126
|
+
defaults: { audio: false, video: false },
|
|
1127
|
+
onError: input.onError
|
|
1128
|
+
});
|
|
1129
|
+
return adaptRealtimeKitClient(client);
|
|
1130
|
+
}
|
|
1131
|
+
function adaptRealtimeKitClient(client) {
|
|
1132
|
+
const self = client.self;
|
|
1133
|
+
return {
|
|
1134
|
+
join: () => client.join(),
|
|
1135
|
+
leave: () => client.leave(),
|
|
1136
|
+
self: {
|
|
1137
|
+
get peerId() {
|
|
1138
|
+
return self.peerId;
|
|
1139
|
+
},
|
|
1140
|
+
get audioEnabled() {
|
|
1141
|
+
return self.audioEnabled;
|
|
1142
|
+
},
|
|
1143
|
+
get videoEnabled() {
|
|
1144
|
+
return self.videoEnabled;
|
|
1145
|
+
},
|
|
1146
|
+
get screenShareEnabled() {
|
|
1147
|
+
return self.screenShareEnabled;
|
|
1148
|
+
},
|
|
1149
|
+
get audioTrack() {
|
|
1150
|
+
return self.audioTrack ?? null;
|
|
1151
|
+
},
|
|
1152
|
+
get videoTrack() {
|
|
1153
|
+
return self.videoTrack ?? null;
|
|
1154
|
+
},
|
|
1155
|
+
get screenShareTracks() {
|
|
1156
|
+
return {
|
|
1157
|
+
...self.screenShareTracks.audio ? { audio: self.screenShareTracks.audio } : {},
|
|
1158
|
+
...self.screenShareTracks.video ? { video: self.screenShareTracks.video } : {}
|
|
1159
|
+
};
|
|
1160
|
+
},
|
|
1161
|
+
enableAudio: (customTrack) => self.enableAudio(customTrack),
|
|
1162
|
+
enableVideo: (customTrack) => self.enableVideo(customTrack),
|
|
1163
|
+
enableScreenShare: () => self.enableScreenShare(),
|
|
1164
|
+
disableAudio: () => self.disableAudio(),
|
|
1165
|
+
disableVideo: () => self.disableVideo(),
|
|
1166
|
+
disableScreenShare: () => self.disableScreenShare(),
|
|
1167
|
+
onAudioUpdate: (listener) => {
|
|
1168
|
+
self.on("audioUpdate", listener);
|
|
1169
|
+
return () => self.off("audioUpdate", listener);
|
|
1170
|
+
},
|
|
1171
|
+
onVideoUpdate: (listener) => {
|
|
1172
|
+
self.on("videoUpdate", listener);
|
|
1173
|
+
return () => self.off("videoUpdate", listener);
|
|
1174
|
+
},
|
|
1175
|
+
onScreenShareUpdate: (listener) => {
|
|
1176
|
+
self.on("screenShareUpdate", listener);
|
|
1177
|
+
return () => self.off("screenShareUpdate", listener);
|
|
1178
|
+
},
|
|
1179
|
+
onLeft: (listener) => {
|
|
1180
|
+
self.on("roomLeft", listener);
|
|
1181
|
+
return () => self.off("roomLeft", listener);
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
participants: {
|
|
1185
|
+
joined: {
|
|
1186
|
+
list: () => client.participants.joined.toArray().map(toParticipant),
|
|
1187
|
+
onJoined: (listener) => {
|
|
1188
|
+
const callback = (participant) => listener(toParticipant(participant));
|
|
1189
|
+
client.participants.joined.on("participantJoined", callback);
|
|
1190
|
+
return () => client.participants.joined.off("participantJoined", callback);
|
|
1191
|
+
},
|
|
1192
|
+
onLeft: (listener) => {
|
|
1193
|
+
const callback = (participant) => listener(toParticipant(participant));
|
|
1194
|
+
client.participants.joined.on("participantLeft", callback);
|
|
1195
|
+
return () => client.participants.joined.off("participantLeft", callback);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
function toParticipant(participant) {
|
|
1202
|
+
return {
|
|
1203
|
+
id: participant.id,
|
|
1204
|
+
userId: participant.userId,
|
|
1205
|
+
...participant.customParticipantId === void 0 ? {} : { customParticipantId: participant.customParticipantId },
|
|
1206
|
+
audioEnabled: participant.audioEnabled,
|
|
1207
|
+
videoEnabled: participant.videoEnabled,
|
|
1208
|
+
screenShareEnabled: participant.screenShareEnabled,
|
|
1209
|
+
audioTrack: participant.audioTrack ?? null,
|
|
1210
|
+
videoTrack: participant.videoTrack ?? null,
|
|
1211
|
+
screenShareTracks: {
|
|
1212
|
+
...participant.screenShareTracks.audio ? { audio: participant.screenShareTracks.audio } : {},
|
|
1213
|
+
...participant.screenShareTracks.video ? { video: participant.screenShareTracks.video } : {}
|
|
1214
|
+
},
|
|
1215
|
+
onAudioUpdate: (listener) => {
|
|
1216
|
+
const callback = () => listener();
|
|
1217
|
+
participant.on("audioUpdate", callback);
|
|
1218
|
+
return () => participant.off("audioUpdate", callback);
|
|
1219
|
+
},
|
|
1220
|
+
onVideoUpdate: (listener) => {
|
|
1221
|
+
const callback = () => listener();
|
|
1222
|
+
participant.on("videoUpdate", callback);
|
|
1223
|
+
return () => participant.off("videoUpdate", callback);
|
|
1224
|
+
},
|
|
1225
|
+
onScreenShareUpdate: (listener) => {
|
|
1226
|
+
const callback = () => listener();
|
|
1227
|
+
participant.on("screenShareUpdate", callback);
|
|
1228
|
+
return () => participant.off("screenShareUpdate", callback);
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
|
|
800
1233
|
export {
|
|
801
1234
|
CloudflareSFUError,
|
|
802
1235
|
parseCloudflareSFUPublicationID,
|
|
@@ -807,5 +1240,7 @@ export {
|
|
|
807
1240
|
publicationKey,
|
|
808
1241
|
waitFor,
|
|
809
1242
|
CloudflareSFUClient,
|
|
810
|
-
createCloudflareSFUHTTPTransport
|
|
1243
|
+
createCloudflareSFUHTTPTransport,
|
|
1244
|
+
CloudflareRTKError,
|
|
1245
|
+
CloudflareRTKClient
|
|
811
1246
|
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createChalkEffectClient,
|
|
3
|
+
parseAccessGrant
|
|
4
|
+
} from "./chunk-JPNE4K2L.js";
|
|
5
|
+
|
|
6
|
+
// src/public-invites/client.ts
|
|
7
|
+
import { Effect } from "effect";
|
|
8
|
+
function createChalkPublicClient(options) {
|
|
9
|
+
const baseClientOptions = {
|
|
10
|
+
baseUrl: options.baseUrl,
|
|
11
|
+
credentials: options.credentials ?? (options.runtime === "react-native" ? void 0 : "include"),
|
|
12
|
+
fetch: options.fetch,
|
|
13
|
+
telemetry: options.telemetry
|
|
14
|
+
};
|
|
15
|
+
const createClient = (guestCredential, requestInit) => createChalkEffectClient({
|
|
16
|
+
...baseClientOptions,
|
|
17
|
+
...requestInit ? { fetch: requestInitFetch(options.fetch, requestInit) } : {},
|
|
18
|
+
headers: requestHeaders(options, guestCredential)
|
|
19
|
+
});
|
|
20
|
+
const createPublicSpace = async (input, idempotency) => {
|
|
21
|
+
const client = await Effect.runPromise(createClient(void 0));
|
|
22
|
+
const response = await Effect.runPromise(
|
|
23
|
+
client.spaces.createPublicSpace({
|
|
24
|
+
headers: { "Idempotency-Key": idempotencyKey(idempotency) },
|
|
25
|
+
payload: { display_name: required(input.displayName, "displayName") }
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
return publicSpaceCreated(response);
|
|
29
|
+
};
|
|
30
|
+
const arriveBySpacePublicInvite = async (input, arrival) => {
|
|
31
|
+
const client = await Effect.runPromise(createClient(arrival?.guestCredential ?? options.guestCredential));
|
|
32
|
+
const response = await Effect.runPromise(
|
|
33
|
+
client.spaces.arriveBySpacePublicInvite({
|
|
34
|
+
headers: {
|
|
35
|
+
"Idempotency-Key": idempotencyKey(arrival),
|
|
36
|
+
...arrival?.arrivalHandle === void 0 ? {} : { "X-Chalk-Arrival-Handle": required(arrival.arrivalHandle, "arrivalHandle") }
|
|
37
|
+
},
|
|
38
|
+
payload: {
|
|
39
|
+
display_name: required(input.displayName, "displayName"),
|
|
40
|
+
space_invite_token: required(input.spaceInviteToken, "spaceInviteToken")
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
return publicSpaceArrival(response);
|
|
45
|
+
};
|
|
46
|
+
const getSpacePublicInviteArrival = async (reference) => {
|
|
47
|
+
const normalized = arrivalReference(reference);
|
|
48
|
+
const client = await Effect.runPromise(createClient(normalized.guestCredential ?? options.guestCredential));
|
|
49
|
+
const response = await Effect.runPromise(
|
|
50
|
+
client.spaces.getSpacePublicInviteArrival({
|
|
51
|
+
headers: { "X-Chalk-Arrival-Handle": normalized.arrivalHandle }
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
return publicSpaceArrival(response);
|
|
55
|
+
};
|
|
56
|
+
const refreshSpacePublicInviteAccess = async (input, arrival) => {
|
|
57
|
+
const normalized = refreshInput(input, arrival);
|
|
58
|
+
const client = await Effect.runPromise(createClient(normalized.guestCredential ?? options.guestCredential));
|
|
59
|
+
const response = await Effect.runPromise(
|
|
60
|
+
client.spaces.refreshSpacePublicInviteAccess({
|
|
61
|
+
headers: { "X-Chalk-Arrival-Handle": normalized.arrivalHandle },
|
|
62
|
+
payload: { media_proof: required(normalized.mediaProof, "mediaProof") }
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
return parseAccessGrant(response);
|
|
66
|
+
};
|
|
67
|
+
const leaveSpacePublicInviteArrival = async (reference, leaveOptions) => {
|
|
68
|
+
const normalized = arrivalReference(reference);
|
|
69
|
+
const client = await Effect.runPromise(createClient(normalized.guestCredential ?? options.guestCredential, requestInitForLeave(leaveOptions)));
|
|
70
|
+
await Effect.runPromise(
|
|
71
|
+
client.spaces.leaveSpacePublicInviteArrival({
|
|
72
|
+
headers: { "X-Chalk-Arrival-Handle": normalized.arrivalHandle }
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
const getPublicStatus = async () => {
|
|
77
|
+
const client = await Effect.runPromise(createClient(void 0));
|
|
78
|
+
return Effect.runPromise(client.default.getPublicStatus({}));
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
arrive: arriveBySpacePublicInvite,
|
|
82
|
+
arriveBySpacePublicInvite,
|
|
83
|
+
create: createPublicSpace,
|
|
84
|
+
createPublicSpace,
|
|
85
|
+
getPublicStatus,
|
|
86
|
+
getSpacePublicInviteArrival,
|
|
87
|
+
leave: leaveSpacePublicInviteArrival,
|
|
88
|
+
leaveSpacePublicInviteArrival,
|
|
89
|
+
refresh: refreshSpacePublicInviteAccess,
|
|
90
|
+
refreshSpacePublicInviteAccess,
|
|
91
|
+
status: getSpacePublicInviteArrival
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
var createChalkPublicInviteClient = createChalkPublicClient;
|
|
95
|
+
function requestHeaders(options, guestCredential) {
|
|
96
|
+
const headers = { ...options.headers };
|
|
97
|
+
if (options.runtime === "react-native") {
|
|
98
|
+
headers["X-Chalk-Client"] = "react-native";
|
|
99
|
+
const credential = guestCredential ?? options.guestCredential;
|
|
100
|
+
if (credential !== void 0) headers.Authorization = `ChalkGuest ${required(credential, "guestCredential")}`;
|
|
101
|
+
}
|
|
102
|
+
return headers;
|
|
103
|
+
}
|
|
104
|
+
function idempotencyKey(options) {
|
|
105
|
+
return options?.idempotencyKey === void 0 ? globalThis.crypto.randomUUID() : required(options.idempotencyKey, "idempotencyKey");
|
|
106
|
+
}
|
|
107
|
+
function arrivalReference(reference) {
|
|
108
|
+
if (typeof reference === "string") return { arrivalHandle: required(reference, "arrivalHandle") };
|
|
109
|
+
return { arrivalHandle: required(reference.arrivalHandle, "arrivalHandle"), guestCredential: reference.guestCredential };
|
|
110
|
+
}
|
|
111
|
+
function refreshInput(input, arrival) {
|
|
112
|
+
const values = typeof input === "string" ? { arrivalHandle: arrival?.arrivalHandle, guestCredential: arrival?.guestCredential, mediaProof: input } : { arrivalHandle: input.arrivalHandle ?? arrival?.arrivalHandle, guestCredential: input.guestCredential ?? arrival?.guestCredential, mediaProof: input.mediaProof };
|
|
113
|
+
return {
|
|
114
|
+
...values,
|
|
115
|
+
arrivalHandle: required(values.arrivalHandle ?? "", "arrivalHandle")
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function requestInitForLeave(options) {
|
|
119
|
+
if (options?.keepalive === void 0) return void 0;
|
|
120
|
+
return { keepalive: options.keepalive };
|
|
121
|
+
}
|
|
122
|
+
function requestInitFetch(fetchImplementation, requestInit) {
|
|
123
|
+
const implementation = fetchImplementation ?? globalThis.fetch;
|
|
124
|
+
return (input, init) => implementation(input, { ...init, ...requestInit });
|
|
125
|
+
}
|
|
126
|
+
function publicSpaceCreated(value) {
|
|
127
|
+
const { arrival, ...created } = value;
|
|
128
|
+
return { ...created, arrival: publicSpaceArrival(arrival) };
|
|
129
|
+
}
|
|
130
|
+
function publicSpaceArrival(value) {
|
|
131
|
+
const { access, ...arrival } = value;
|
|
132
|
+
if (access === void 0) return arrival;
|
|
133
|
+
return { ...arrival, access: access === null ? null : parseAccessGrant(access) };
|
|
134
|
+
}
|
|
135
|
+
function required(value, name) {
|
|
136
|
+
const normalized = value.trim();
|
|
137
|
+
if (!normalized) throw new TypeError(`${name} is required`);
|
|
138
|
+
return normalized;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
createChalkPublicClient,
|
|
143
|
+
createChalkPublicInviteClient
|
|
144
|
+
};
|