@decentnetwork/beagle 0.1.48 → 0.1.49
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/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.49";
|
|
2
2
|
const ICON_PATHS = {
|
|
3
3
|
// ---- tab bar (the four must feel like one set) ----
|
|
4
4
|
users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
|
|
@@ -124,21 +124,28 @@ var PeerWebRTC = (() => {
|
|
|
124
124
|
function byteLength(text) {
|
|
125
125
|
return new TextEncoder().encode(text).length;
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/^(red|ulpfec|flexfec-03)$/i
|
|
130
|
-
];
|
|
131
|
-
function payloadTypesFor(lines, codec) {
|
|
132
|
-
const pts = /* @__PURE__ */ new Set();
|
|
127
|
+
function videoPayloadTypes(lines) {
|
|
128
|
+
const out = /* @__PURE__ */ new Map();
|
|
133
129
|
for (const line of lines) {
|
|
134
130
|
const m = /^a=rtpmap:(\d+)\s+([A-Za-z0-9-]+)\//.exec(line);
|
|
135
|
-
if (m
|
|
136
|
-
|
|
131
|
+
if (m)
|
|
132
|
+
out.set(m[1], { pt: m[1], name: m[2], fmtp: "" });
|
|
137
133
|
}
|
|
138
134
|
for (const line of lines) {
|
|
139
|
-
const m = /^a=fmtp:(\d+)\s+
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
const m = /^a=fmtp:(\d+)\s+(.*)$/.exec(line);
|
|
136
|
+
const e = m && out.get(m[1]);
|
|
137
|
+
if (e)
|
|
138
|
+
e.fmtp = m[2];
|
|
139
|
+
}
|
|
140
|
+
return [...out.values()];
|
|
141
|
+
}
|
|
142
|
+
function payloadTypesToDrop(lines, drop) {
|
|
143
|
+
const all = videoPayloadTypes(lines);
|
|
144
|
+
const pts = new Set(all.filter((p) => p.name.toLowerCase() !== "rtx" && drop(p)).map((p) => p.pt));
|
|
145
|
+
for (const p of all) {
|
|
146
|
+
const apt = /(?:^|;|\s)apt=(\d+)/.exec(p.fmtp);
|
|
147
|
+
if (p.name.toLowerCase() === "rtx" && apt && pts.has(apt[1]))
|
|
148
|
+
pts.add(p.pt);
|
|
142
149
|
}
|
|
143
150
|
return pts;
|
|
144
151
|
}
|
|
@@ -159,18 +166,37 @@ var PeerWebRTC = (() => {
|
|
|
159
166
|
}
|
|
160
167
|
return out;
|
|
161
168
|
}
|
|
162
|
-
function
|
|
169
|
+
function stripCandidates(lines) {
|
|
170
|
+
return lines.filter((l) => !l.startsWith("a=candidate:") && !l.startsWith("a=end-of-candidates"));
|
|
171
|
+
}
|
|
172
|
+
var CODEC_REDUCTIONS = [
|
|
173
|
+
// 1. Codecs the phones have never negotiated.
|
|
174
|
+
(p) => /^(VP9|AV1|AV1X|H265|HEVC)$/i.test(p.name),
|
|
175
|
+
// 2. Redundancy/FEC payloads — nice to have, not required to connect.
|
|
176
|
+
(p) => /^(red|ulpfec|flexfec-03)$/i.test(p.name),
|
|
177
|
+
// 3. Duplicate H264 profiles. Chrome offers six (baseline/main/high ×
|
|
178
|
+
// packetization-mode 0/1) at ~230 bytes each; the phones use constrained
|
|
179
|
+
// baseline (profile-level-id=42…) with packetization-mode=1. Keep those
|
|
180
|
+
// and VP8, drop the rest.
|
|
181
|
+
(p) => /^H264$/i.test(p.name) && !(/profile-level-id=42/i.test(p.fmtp) && /packetization-mode=1/i.test(p.fmtp))
|
|
182
|
+
];
|
|
183
|
+
function shrinkSdpForInvite(sdp, budget = CARRIER_MAX_INVITE_DATA_LEN, opts = {}) {
|
|
163
184
|
if (byteLength(sdp) <= budget)
|
|
164
185
|
return sdp;
|
|
165
186
|
const crlf = sdp.includes("\r\n");
|
|
187
|
+
const join = (l) => l.join(crlf ? "\r\n" : "\n");
|
|
166
188
|
let lines = sdp.replace(/\r\n/g, "\n").split("\n");
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
189
|
+
lines = stripCandidates(lines);
|
|
190
|
+
if (byteLength(join(lines)) <= budget)
|
|
191
|
+
return join(lines);
|
|
192
|
+
if (opts.codecs !== false) {
|
|
193
|
+
for (const reduction of CODEC_REDUCTIONS) {
|
|
194
|
+
lines = stripPayloadTypes(lines, payloadTypesToDrop(lines, reduction));
|
|
195
|
+
if (byteLength(join(lines)) <= budget)
|
|
196
|
+
return join(lines);
|
|
197
|
+
}
|
|
172
198
|
}
|
|
173
|
-
return
|
|
199
|
+
return join(lines);
|
|
174
200
|
}
|
|
175
201
|
|
|
176
202
|
// node_modules/@decentnetwork/peer-webrtc/dist/signal.js
|
|
@@ -215,12 +241,16 @@ var PeerWebRTC = (() => {
|
|
|
215
241
|
if (bytes <= budget)
|
|
216
242
|
return { signal, bytes, shrunk: false };
|
|
217
243
|
let out = signal;
|
|
218
|
-
if (signal.
|
|
219
|
-
|
|
244
|
+
if (signal.sdp) {
|
|
245
|
+
const envelope = bytes - byteLength(signal.sdp);
|
|
246
|
+
out = {
|
|
247
|
+
...signal,
|
|
248
|
+
sdp: shrinkSdpForInvite(signal.sdp, budget - envelope, { codecs: signal.type === "offer" })
|
|
249
|
+
};
|
|
220
250
|
bytes = encodeSignalBytes(out).length;
|
|
221
251
|
}
|
|
222
252
|
if (bytes > budget) {
|
|
223
|
-
throw new Error(`RtcSignal "${signal.type}" is ${bytes}B, over the ${budget}B invite cap \u2014 the peer would never receive it`);
|
|
253
|
+
throw new Error(`RtcSignal "${signal.type}" is ${bytes}B after shrinking, over the ${budget}B invite cap \u2014 the peer would never receive it`);
|
|
224
254
|
}
|
|
225
255
|
return { signal: out, bytes, shrunk: true };
|
|
226
256
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/beagle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"description": "Beagle — P2P chat, file transfer and calls for regular users, on the Decent Network. No admin privilege required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@decentnetwork/chat-components": "^0.1.3",
|
|
29
29
|
"@decentnetwork/lan": "^0.1.276",
|
|
30
30
|
"@decentnetwork/peer": "^0.1.139",
|
|
31
|
-
"@decentnetwork/peer-webrtc": "^0.2.
|
|
31
|
+
"@decentnetwork/peer-webrtc": "^0.2.16",
|
|
32
32
|
"js-yaml": "^4.1.0",
|
|
33
33
|
"yargs": "^17.7.2"
|
|
34
34
|
},
|