@midsummer-ai/sdk 0.1.0-staging.4588 → 0.1.0-staging.4594
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/calls/contract.d.mts +1 -1
- package/calls/index.d.mts +1 -1
- package/calls/index.mjs +42 -0
- package/calls/protocol.d.mts +1 -1
- package/calls/protocol.mjs +2 -0
- package/calls/react.d.mts +1 -1
- package/calls/stand-in.d.mts +1 -1
- package/calls/stand-in.mjs +8 -0
- package/here-C2jhTheQ.mjs +1 -1
- package/package.json +1 -1
- package/{protocol-Cda1THdm.d.mts → protocol-Bh5GrnpV.d.mts} +19 -0
package/calls/contract.d.mts
CHANGED
package/calls/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { s as Json } from "../index-c616Dbux.mjs";
|
|
2
|
-
import { a as CallToken, c as Layer, d as TrackName, r as CallErrorCode } from "../protocol-
|
|
2
|
+
import { a as CallToken, c as Layer, d as TrackName, r as CallErrorCode } from "../protocol-Bh5GrnpV.mjs";
|
|
3
3
|
//#region src/calls/index.d.ts
|
|
4
4
|
/** The most a message sent with `send` carries, as JSON. */
|
|
5
5
|
declare const MAX_MESSAGE_BYTES: number;
|
package/calls/index.mjs
CHANGED
|
@@ -777,6 +777,30 @@ function sfuMedia(ctx, auto, declined, offer) {
|
|
|
777
777
|
if (own) channelSend(own, outbox, text);
|
|
778
778
|
else if (outbox.length < 64) outbox.push(text);
|
|
779
779
|
},
|
|
780
|
+
async renewRelays() {
|
|
781
|
+
if (closed || !await relayed(pc)) return;
|
|
782
|
+
const given = await ctx.post("relays", { participant: ctx.me });
|
|
783
|
+
if (closed || !given.iceServers.some((server) => server.username)) return;
|
|
784
|
+
pc.setConfiguration({
|
|
785
|
+
...pc.getConfiguration(),
|
|
786
|
+
...configOf(given.iceServers)
|
|
787
|
+
});
|
|
788
|
+
await serial(async () => {
|
|
789
|
+
if (closed) return;
|
|
790
|
+
pc.restartIce();
|
|
791
|
+
await pc.setLocalDescription(await pc.createOffer());
|
|
792
|
+
try {
|
|
793
|
+
const { answer: restarted } = await ctx.post("restart", {
|
|
794
|
+
participant: ctx.me,
|
|
795
|
+
offer: sdpOf(pc.localDescription)
|
|
796
|
+
});
|
|
797
|
+
await pc.setRemoteDescription(restarted);
|
|
798
|
+
} catch (error) {
|
|
799
|
+
if (!closed && pc.signalingState === "have-local-offer") await pc.setLocalDescription({ type: "rollback" }).catch(() => void 0);
|
|
800
|
+
throw error;
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
},
|
|
780
804
|
close() {
|
|
781
805
|
closed = true;
|
|
782
806
|
clearTimeout(connectBy);
|
|
@@ -788,6 +812,18 @@ function sfuMedia(ctx, auto, declined, offer) {
|
|
|
788
812
|
}
|
|
789
813
|
};
|
|
790
814
|
}
|
|
815
|
+
/** Whether a connection reaches the media through a relay now. */
|
|
816
|
+
async function relayed(pc) {
|
|
817
|
+
if (typeof pc.getStats !== "function") return false;
|
|
818
|
+
const report = await pc.getStats();
|
|
819
|
+
let found = false;
|
|
820
|
+
report.forEach((each) => {
|
|
821
|
+
if (each.type !== "transport" || !each.selectedCandidatePairId) return;
|
|
822
|
+
const pair = report.get(each.selectedCandidatePairId);
|
|
823
|
+
if ((pair?.localCandidateId ? report.get(pair.localCandidateId) : void 0)?.candidateType === "relay") found = true;
|
|
824
|
+
});
|
|
825
|
+
return found;
|
|
826
|
+
}
|
|
791
827
|
/** Media with no media server: a connection to each other participant, made once (see the top of this file). */
|
|
792
828
|
function relayMedia(ctx, rejoined) {
|
|
793
829
|
const peers = /* @__PURE__ */ new Map();
|
|
@@ -935,6 +971,7 @@ function relayMedia(ctx, rejoined) {
|
|
|
935
971
|
send(text) {
|
|
936
972
|
for (const peer of peers.values()) channelSend(peer.channel, peer.outbox, text);
|
|
937
973
|
},
|
|
974
|
+
async renewRelays() {},
|
|
938
975
|
close() {
|
|
939
976
|
for (const peer of [...peers.values()]) drop(peer);
|
|
940
977
|
}
|
|
@@ -1268,6 +1305,11 @@ var LiveCall = class {
|
|
|
1268
1305
|
this.credential = next;
|
|
1269
1306
|
this.renewed = true;
|
|
1270
1307
|
this.schedule();
|
|
1308
|
+
const session = this.session;
|
|
1309
|
+
if (session?.alive) await session.media.renewRelays().catch((error) => {
|
|
1310
|
+
const refused = callErrorOf(error);
|
|
1311
|
+
if (refused.code !== "invalid" && refused.code !== "not-found") throw error;
|
|
1312
|
+
});
|
|
1271
1313
|
}
|
|
1272
1314
|
/** Something in the background failed: a drop joins again, an ended room ends the call, anything else is an `error` event. */
|
|
1273
1315
|
background(error) {
|
package/calls/protocol.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as CallToken, c as Layer, d as TrackName, f as WireParticipant, i as CallOp, l as Sdp, m as WireSignal, n as CALL_STATUS, o as CallWire, p as WireRoom, r as CallErrorCode, s as IceServer, t as CALL_OPS, u as TRACK_KINDS } from "../protocol-
|
|
1
|
+
import { a as CallToken, c as Layer, d as TrackName, f as WireParticipant, i as CallOp, l as Sdp, m as WireSignal, n as CALL_STATUS, o as CallWire, p as WireRoom, r as CallErrorCode, s as IceServer, t as CALL_OPS, u as TRACK_KINDS } from "../protocol-Bh5GrnpV.mjs";
|
|
2
2
|
export { CALL_OPS, CALL_STATUS, CallErrorCode, CallOp, CallToken, CallWire, IceServer, Layer, Sdp, TRACK_KINDS, TrackName, WireParticipant, WireRoom, WireSignal };
|
package/calls/protocol.mjs
CHANGED
package/calls/react.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as TrackName } from "../protocol-
|
|
1
|
+
import { d as TrackName } from "../protocol-Bh5GrnpV.mjs";
|
|
2
2
|
import { Call, CallError, CallState, LocalTrack, Participant, Rtc, TokenSource } from "./index.mjs";
|
|
3
3
|
import { AudioHTMLAttributes, ReactNode, VideoHTMLAttributes } from "react";
|
|
4
4
|
//#region src/calls/react.d.ts
|
package/calls/stand-in.d.mts
CHANGED
package/calls/stand-in.mjs
CHANGED
|
@@ -225,6 +225,14 @@ function standIn(options = {}) {
|
|
|
225
225
|
await yours(token, body.participant);
|
|
226
226
|
throw noMediaServer();
|
|
227
227
|
},
|
|
228
|
+
async relays(token, body) {
|
|
229
|
+
await yours(token, body.participant);
|
|
230
|
+
return { iceServers: [] };
|
|
231
|
+
},
|
|
232
|
+
async restart(token, body) {
|
|
233
|
+
await yours(token, body.participant);
|
|
234
|
+
throw noMediaServer();
|
|
235
|
+
},
|
|
228
236
|
async layer(token, body) {
|
|
229
237
|
await yours(token, body.participant);
|
|
230
238
|
throw noMediaServer();
|
package/here-C2jhTheQ.mjs
CHANGED
|
@@ -12,7 +12,7 @@ function processEnv() {
|
|
|
12
12
|
* This package's version: `0.0.0-dev` here, and in a published package the version it was published at, which the
|
|
13
13
|
* release writes in its place as it stages the package (`stampSdk` in `scripts/release/packages.ts`).
|
|
14
14
|
*/
|
|
15
|
-
const SDK_VERSION = "0.1.0-staging.
|
|
15
|
+
const SDK_VERSION = "0.1.0-staging.4594";
|
|
16
16
|
/**
|
|
17
17
|
* The header that tells Midsummer which client made each of this package's calls: `Midsummer-Client: sdk/<version>
|
|
18
18
|
* <part>`, `part` the product whose client it is (`database`, `storage`, `queues`, ...), so the platform counts which
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midsummer-ai/sdk",
|
|
3
|
-
"version": "0.1.0-staging.
|
|
3
|
+
"version": "0.1.0-staging.4594",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Midsummer's handles for an app's code: its Database, Storage, Queues, Vector DB, AI, Email and Agents, with stand-ins for tests.",
|
|
@@ -129,6 +129,25 @@ interface CallWire {
|
|
|
129
129
|
}>;
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
|
+
/** New relays once the token was renewed, asked for what is left of the token that asks; none where the call gives none. */
|
|
133
|
+
relays: {
|
|
134
|
+
body: {
|
|
135
|
+
participant: string;
|
|
136
|
+
};
|
|
137
|
+
answer: {
|
|
138
|
+
iceServers: ReadonlyArray<IceServer>;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/** An offer that adds no track and only changes how the connection reaches the media, as onto new relays: the answer to apply. */
|
|
142
|
+
restart: {
|
|
143
|
+
body: {
|
|
144
|
+
participant: string;
|
|
145
|
+
offer: Sdp;
|
|
146
|
+
};
|
|
147
|
+
answer: {
|
|
148
|
+
answer: Sdp;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
132
151
|
layer: {
|
|
133
152
|
body: {
|
|
134
153
|
participant: string;
|