@decentnetwork/beagle 0.1.130 → 0.1.131
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 +486 -147
- package/dist/desktop/vendor/peer-webrtc.js +138 -35
- package/dist/embedded-host.js +42 -3
- package/dist/group-file.d.ts +46 -0
- package/dist/group-file.js +92 -0
- package/dist/message-store.d.ts +14 -1
- package/dist/message-store.js +11 -2
- package/package.json +5 -5
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.131";
|
|
2
2
|
"use strict";
|
|
3
3
|
(() => {
|
|
4
4
|
// packages/beagle-ui/dist/beagle-ui.js
|
|
@@ -301,6 +301,94 @@ window.__DK_UI_VERSION="0.1.130";
|
|
|
301
301
|
const s = String(text == null ? "" : text).replace(/\s+/g, " ").trim();
|
|
302
302
|
return s.length > max ? s.slice(0, max - 1) + "\u2026" : s;
|
|
303
303
|
}
|
|
304
|
+
function hostHasExits(d) {
|
|
305
|
+
if (!d || typeof d !== "object")
|
|
306
|
+
return false;
|
|
307
|
+
if (d.exitsSupported === false)
|
|
308
|
+
return false;
|
|
309
|
+
return !!d.exitFeature && typeof d.exitFeature === "object";
|
|
310
|
+
}
|
|
311
|
+
function desktopPollPath({ wantExits, opened, supported }) {
|
|
312
|
+
if (!wantExits || supported !== true)
|
|
313
|
+
return "/api/desktop";
|
|
314
|
+
return opened ? "/api/desktop?exits=1&open=1" : "/api/desktop?exits=1";
|
|
315
|
+
}
|
|
316
|
+
function exitControls({ exitFeature, routeFallback, exits }) {
|
|
317
|
+
const has = hostHasExits({ exitFeature });
|
|
318
|
+
const list = Array.isArray(exits) ? exits : [];
|
|
319
|
+
const anyFailed = list.some((r) => (r.nodes || []).some((n) => n.status === "failed"));
|
|
320
|
+
return {
|
|
321
|
+
refresh: has && list.length > 0,
|
|
322
|
+
reconnect: has,
|
|
323
|
+
reconnectAll: has && anyFailed,
|
|
324
|
+
noExitNotice: has && exitFeature.available === false,
|
|
325
|
+
fallbackNotice: has && !!(routeFallback && routeFallback.from),
|
|
326
|
+
anyFailed: has && anyFailed
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
var VOICE_RE = /^voice-(\d+)(?:-(\d+))?\.(m4a|aac|ogg|oga|opus|mp3|wav|caf|amr)$/i;
|
|
330
|
+
function isVoiceName(name) {
|
|
331
|
+
return VOICE_RE.test(String(name || "").trim());
|
|
332
|
+
}
|
|
333
|
+
function voiceDurationMs(name) {
|
|
334
|
+
const m = VOICE_RE.exec(String(name || "").trim());
|
|
335
|
+
if (!m || !m[2])
|
|
336
|
+
return null;
|
|
337
|
+
const d = Number(m[2]);
|
|
338
|
+
return d > 0 && d < 36e5 ? d : null;
|
|
339
|
+
}
|
|
340
|
+
function formatDuration(ms) {
|
|
341
|
+
if (ms == null || !(ms >= 0))
|
|
342
|
+
return "";
|
|
343
|
+
const s = Math.round(ms / 1e3);
|
|
344
|
+
return Math.floor(s / 60) + ":" + String(s % 60).padStart(2, "0");
|
|
345
|
+
}
|
|
346
|
+
var EXT_KIND = {
|
|
347
|
+
image: ["png", "jpg", "jpeg", "gif", "webp", "svg", "heic", "bmp"],
|
|
348
|
+
video: ["mp4", "mov", "webm", "m4v", "mkv", "avi"],
|
|
349
|
+
audio: ["mp3", "m4a", "aac", "wav", "ogg", "oga", "flac", "opus", "caf", "amr"]
|
|
350
|
+
};
|
|
351
|
+
function fileMediaKind(name, contentType) {
|
|
352
|
+
if (isVoiceName(name))
|
|
353
|
+
return "audio";
|
|
354
|
+
const ct = String(contentType || "").toLowerCase();
|
|
355
|
+
if (/^(image|video|audio)\//.test(ct))
|
|
356
|
+
return ct.split("/")[0];
|
|
357
|
+
const ext = (String(name || "").split(".").pop() || "").toLowerCase();
|
|
358
|
+
for (const kind of Object.keys(EXT_KIND))
|
|
359
|
+
if (EXT_KIND[kind].includes(ext))
|
|
360
|
+
return kind;
|
|
361
|
+
return "file";
|
|
362
|
+
}
|
|
363
|
+
function cgpFile(message) {
|
|
364
|
+
const f = message && typeof message === "object" ? message.file : null;
|
|
365
|
+
if (!f || typeof f !== "object")
|
|
366
|
+
return null;
|
|
367
|
+
const name = typeof f.filename === "string" && f.filename ? f.filename : null;
|
|
368
|
+
if (!name)
|
|
369
|
+
return null;
|
|
370
|
+
const size = Number(f.size);
|
|
371
|
+
const contentType = typeof f.contentType === "string" ? f.contentType : "";
|
|
372
|
+
const voice = isVoiceName(name);
|
|
373
|
+
return {
|
|
374
|
+
name,
|
|
375
|
+
size: Number.isFinite(size) && size >= 0 ? size : null,
|
|
376
|
+
contentType,
|
|
377
|
+
media: fileMediaKind(name, contentType),
|
|
378
|
+
voice,
|
|
379
|
+
durationMs: voice ? voiceDurationMs(name) : null
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
function fileLabel(file, T) {
|
|
383
|
+
if (!file)
|
|
384
|
+
return "";
|
|
385
|
+
if (file.voice) {
|
|
386
|
+
const d = formatDuration(file.durationMs);
|
|
387
|
+
return "\u{1F3A4} " + (T && T.voiceMessage || "Voice message") + (d ? " " + d : "");
|
|
388
|
+
}
|
|
389
|
+
const icon = file.media === "image" ? "\u{1F5BC} " : file.media === "video" ? "\u{1F3AC} " : "\u{1F4CE} ";
|
|
390
|
+
return icon + file.name;
|
|
391
|
+
}
|
|
304
392
|
function dkHash(s) {
|
|
305
393
|
let h = 2166136261;
|
|
306
394
|
for (let i = 0; i < s.length; i++) {
|
|
@@ -357,15 +445,8 @@ window.__DK_UI_VERSION="0.1.130";
|
|
|
357
445
|
}
|
|
358
446
|
var dkFileUrl = fileUrl;
|
|
359
447
|
var dkFileDownloadUrl = fileDownloadUrl;
|
|
360
|
-
function dkFileMediaKind(name) {
|
|
361
|
-
|
|
362
|
-
if (["png", "jpg", "jpeg", "gif", "webp", "svg", "heic", "bmp"].includes(ext))
|
|
363
|
-
return "image";
|
|
364
|
-
if (["mp4", "mov", "webm", "m4v", "mkv", "avi"].includes(ext))
|
|
365
|
-
return "video";
|
|
366
|
-
if (["mp3", "m4a", "aac", "wav", "ogg", "flac", "opus"].includes(ext))
|
|
367
|
-
return "audio";
|
|
368
|
-
return "file";
|
|
448
|
+
function dkFileMediaKind(name, contentType) {
|
|
449
|
+
return fileMediaKind(name, contentType);
|
|
369
450
|
}
|
|
370
451
|
function dkDayLabel(ts) {
|
|
371
452
|
if (!ts)
|
|
@@ -517,6 +598,9 @@ window.__DK_UI_VERSION="0.1.130";
|
|
|
517
598
|
size: dkFileSize(m.file.size),
|
|
518
599
|
dir: m.dir,
|
|
519
600
|
media: dkFileMediaKind(m.file.name),
|
|
601
|
+
// voice-<ms>-<durMs>.m4a: shown as a voice note with its length.
|
|
602
|
+
voice: isVoiceName(m.file.name),
|
|
603
|
+
durationMs: voiceDurationMs(m.file.name),
|
|
520
604
|
status: m.file.status,
|
|
521
605
|
pct: m.file.status === "sending" && m.file.size ? Math.min(100, (m.file.sent || 0) / m.file.size * 100) : void 0,
|
|
522
606
|
kbps: m.file.kbps
|
|
@@ -526,6 +610,8 @@ window.__DK_UI_VERSION="0.1.130";
|
|
|
526
610
|
// never went out at all — rendered as delivered.
|
|
527
611
|
status: m.dir === "out" ? m.status === "queued" || m.status === "sending" || m.status === "failed" || m.status === "sent" ? m.status : "read" : void 0,
|
|
528
612
|
error: m.error,
|
|
613
|
+
// Real sender of a file relayed by a group (the thread is the group).
|
|
614
|
+
origin: m.origin,
|
|
529
615
|
// false = went to a live session but nobody acknowledged it (one tick).
|
|
530
616
|
// Dropped here before, so that state could never render.
|
|
531
617
|
confirmed: m.confirmed,
|
|
@@ -588,6 +674,7 @@ window.__DK_UI_VERSION="0.1.130";
|
|
|
588
674
|
const wantExitsRef = React.useRef(wantExits);
|
|
589
675
|
wantExitsRef.current = wantExits;
|
|
590
676
|
const exitsOpenedRef = React.useRef(false);
|
|
677
|
+
const exitsSupportedRef = React.useRef(null);
|
|
591
678
|
const [snap, setSnap] = React.useState({
|
|
592
679
|
me: DK_ME_FALLBACK,
|
|
593
680
|
peers: [],
|
|
@@ -604,11 +691,13 @@ window.__DK_UI_VERSION="0.1.130";
|
|
|
604
691
|
const refresh = React.useCallback(async () => {
|
|
605
692
|
var _a, _b, _c;
|
|
606
693
|
try {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
694
|
+
const path = desktopPollPath({
|
|
695
|
+
wantExits: wantExitsRef.current,
|
|
696
|
+
opened: exitsOpenedRef.current,
|
|
697
|
+
supported: exitsSupportedRef.current
|
|
698
|
+
});
|
|
699
|
+
if (path.includes("open=1"))
|
|
610
700
|
exitsOpenedRef.current = false;
|
|
611
|
-
}
|
|
612
701
|
const d = await dkGet(path);
|
|
613
702
|
if (d && d.locked) {
|
|
614
703
|
setSnap((s) => ({ ...s, locked: true, loaded: true }));
|
|
@@ -620,6 +709,13 @@ window.__DK_UI_VERSION="0.1.130";
|
|
|
620
709
|
}, 300);
|
|
621
710
|
return;
|
|
622
711
|
}
|
|
712
|
+
const had = exitsSupportedRef.current;
|
|
713
|
+
exitsSupportedRef.current = hostHasExits(d);
|
|
714
|
+
if (had !== true && exitsSupportedRef.current && wantExitsRef.current && exitsOpenedRef.current) {
|
|
715
|
+
setTimeout(() => {
|
|
716
|
+
refreshRef.current && refreshRef.current();
|
|
717
|
+
}, 0);
|
|
718
|
+
}
|
|
623
719
|
setSnap({
|
|
624
720
|
locked: false,
|
|
625
721
|
me: d.me || DK_ME_FALLBACK,
|
|
@@ -1783,6 +1879,165 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
1783
1879
|
function isGreetingItem(m) {
|
|
1784
1880
|
return !!m && m.kind === GREETING_KIND;
|
|
1785
1881
|
}
|
|
1882
|
+
var PROOF_KEY = { eth: "proof.eth", sol: "proof.sol" };
|
|
1883
|
+
var HEAD = "Beagle wallet binding";
|
|
1884
|
+
var LINE = "I bind this wallet to my Beagle identity.";
|
|
1885
|
+
var ADDRESS_RE = { eth: /^0x[0-9a-fA-F]{40}$/, sol: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/ };
|
|
1886
|
+
var USERID_RE = /^[1-9A-HJ-NP-Za-km-z]{32,48}$/;
|
|
1887
|
+
var ISSUED_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
|
|
1888
|
+
function isWalletAddress(chain, address) {
|
|
1889
|
+
const re = ADDRESS_RE[chain];
|
|
1890
|
+
return !!re && typeof address === "string" && re.test(address);
|
|
1891
|
+
}
|
|
1892
|
+
function proofTime(date = /* @__PURE__ */ new Date()) {
|
|
1893
|
+
return new Date(Math.floor(date.getTime() / 1e3) * 1e3).toISOString().replace(".000Z", "Z");
|
|
1894
|
+
}
|
|
1895
|
+
function walletProofMessage({ userid, chain, address, issued }) {
|
|
1896
|
+
if (!USERID_RE.test(String(userid || "")))
|
|
1897
|
+
throw new Error("wallet proof: bad userid");
|
|
1898
|
+
if (!isWalletAddress(chain, address))
|
|
1899
|
+
throw new Error("wallet proof: bad chain or address");
|
|
1900
|
+
if (!ISSUED_RE.test(String(issued || "")))
|
|
1901
|
+
throw new Error("wallet proof: bad issued time");
|
|
1902
|
+
return [HEAD, "", LINE, "", `userid: ${userid}`, `chain: ${chain}`, `address: ${address}`, `issued: ${issued}`].join("\n");
|
|
1903
|
+
}
|
|
1904
|
+
var B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1905
|
+
function base58Encode(bytes) {
|
|
1906
|
+
const digits = [];
|
|
1907
|
+
for (const b of bytes) {
|
|
1908
|
+
let carry = b;
|
|
1909
|
+
for (let j = 0; j < digits.length; j++) {
|
|
1910
|
+
carry += digits[j] << 8;
|
|
1911
|
+
digits[j] = carry % 58;
|
|
1912
|
+
carry = carry / 58 | 0;
|
|
1913
|
+
}
|
|
1914
|
+
while (carry > 0) {
|
|
1915
|
+
digits.push(carry % 58);
|
|
1916
|
+
carry = carry / 58 | 0;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
let out = "";
|
|
1920
|
+
for (const b of bytes) {
|
|
1921
|
+
if (b !== 0)
|
|
1922
|
+
break;
|
|
1923
|
+
out += "1";
|
|
1924
|
+
}
|
|
1925
|
+
for (let i = digits.length - 1; i >= 0; i--)
|
|
1926
|
+
out += B58[digits[i]];
|
|
1927
|
+
return out;
|
|
1928
|
+
}
|
|
1929
|
+
function base58Decode(str2) {
|
|
1930
|
+
const bytes = [];
|
|
1931
|
+
for (const c of String(str2)) {
|
|
1932
|
+
let carry = B58.indexOf(c);
|
|
1933
|
+
if (carry < 0)
|
|
1934
|
+
throw new Error("not base58");
|
|
1935
|
+
for (let j = 0; j < bytes.length; j++) {
|
|
1936
|
+
carry += bytes[j] * 58;
|
|
1937
|
+
bytes[j] = carry & 255;
|
|
1938
|
+
carry >>= 8;
|
|
1939
|
+
}
|
|
1940
|
+
while (carry > 0) {
|
|
1941
|
+
bytes.push(carry & 255);
|
|
1942
|
+
carry >>= 8;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
for (const c of String(str2)) {
|
|
1946
|
+
if (c !== "1")
|
|
1947
|
+
break;
|
|
1948
|
+
bytes.push(0);
|
|
1949
|
+
}
|
|
1950
|
+
return Uint8Array.from(bytes.reverse());
|
|
1951
|
+
}
|
|
1952
|
+
var utf8Hex = (s) => "0x" + Array.from(new TextEncoder().encode(s), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
1953
|
+
async function signEthProof(provider, { userid, address, issued = proofTime() }) {
|
|
1954
|
+
const message = walletProofMessage({ userid, chain: "eth", address, issued });
|
|
1955
|
+
const signature = await provider.request({ method: "personal_sign", params: [utf8Hex(message), address] });
|
|
1956
|
+
return { message, signature: String(signature) };
|
|
1957
|
+
}
|
|
1958
|
+
async function signSolProof(wallet, { userid, address, issued = proofTime() }) {
|
|
1959
|
+
const message = walletProofMessage({ userid, chain: "sol", address, issued });
|
|
1960
|
+
const r = await wallet.signMessage(new TextEncoder().encode(message), "utf8");
|
|
1961
|
+
const sig = r && r.signature ? r.signature : r;
|
|
1962
|
+
return { message, signature: base58Encode(Uint8Array.from(sig)) };
|
|
1963
|
+
}
|
|
1964
|
+
function stripNul(text) {
|
|
1965
|
+
return String(text == null ? "" : text).replace(/\0+$/u, "");
|
|
1966
|
+
}
|
|
1967
|
+
function parseBeagleContact(raw) {
|
|
1968
|
+
const text = stripNul(raw);
|
|
1969
|
+
const shape = (j) => ({
|
|
1970
|
+
name: j.name || "",
|
|
1971
|
+
ens: j.ens || "",
|
|
1972
|
+
userid: j.userid || j.userId || "",
|
|
1973
|
+
address: j.address || "",
|
|
1974
|
+
avatar: j.avatar || j.avatarUrl || "",
|
|
1975
|
+
description: j.description || "",
|
|
1976
|
+
kind: j.kind || ""
|
|
1977
|
+
});
|
|
1978
|
+
const fence = /```\s*beagle-contact\s*\n([\s\S]*?)\n```/i.exec(text);
|
|
1979
|
+
if (fence) {
|
|
1980
|
+
try {
|
|
1981
|
+
const j = JSON.parse(fence[1].trim());
|
|
1982
|
+
if (j && (j.type === "beagle_contact" || j.type === "beagle-contact"))
|
|
1983
|
+
return shape(j);
|
|
1984
|
+
} catch (e) {
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
if (/^\s*BCR1\s+/i.test(text)) {
|
|
1988
|
+
try {
|
|
1989
|
+
const j = JSON.parse(text.replace(/^\s*BCR1\s+/i, "").trim());
|
|
1990
|
+
if (j && j.type === "beagle_contact")
|
|
1991
|
+
return shape(j);
|
|
1992
|
+
} catch (e) {
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
return null;
|
|
1996
|
+
}
|
|
1997
|
+
function isCarrierAddress(addr) {
|
|
1998
|
+
const s = String(addr || "").trim();
|
|
1999
|
+
if (s.length < 48 || s.length > 56)
|
|
2000
|
+
return false;
|
|
2001
|
+
let b;
|
|
2002
|
+
try {
|
|
2003
|
+
b = base58Decode(s);
|
|
2004
|
+
} catch (e) {
|
|
2005
|
+
return false;
|
|
2006
|
+
}
|
|
2007
|
+
if (b.length !== 38)
|
|
2008
|
+
return false;
|
|
2009
|
+
const c = [0, 0];
|
|
2010
|
+
for (let i = 0; i < 36; i++)
|
|
2011
|
+
c[i % 2] ^= b[i];
|
|
2012
|
+
return b[36] === c[0] && b[37] === c[1];
|
|
2013
|
+
}
|
|
2014
|
+
function isUserId(id) {
|
|
2015
|
+
const s = String(id || "").trim();
|
|
2016
|
+
if (s.length < 40 || s.length > 46)
|
|
2017
|
+
return false;
|
|
2018
|
+
try {
|
|
2019
|
+
return base58Decode(s).length === 32;
|
|
2020
|
+
} catch (e) {
|
|
2021
|
+
return false;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
function cardFriend(card, peers) {
|
|
2025
|
+
if (!card)
|
|
2026
|
+
return null;
|
|
2027
|
+
const ids = [card.userid, card.address].filter(Boolean);
|
|
2028
|
+
if (!ids.length)
|
|
2029
|
+
return null;
|
|
2030
|
+
return (peers || []).find((p) => p && !p.pending && (ids.includes(p.userId) || p.address && ids.includes(p.address))) || null;
|
|
2031
|
+
}
|
|
2032
|
+
function nameCardView(card, peers) {
|
|
2033
|
+
const c = card || {};
|
|
2034
|
+
const address = isCarrierAddress(c.address) ? String(c.address).trim() : "";
|
|
2035
|
+
const userid = c.userid || (!address && isUserId(c.address) ? String(c.address).trim() : "");
|
|
2036
|
+
const isGroup = c.kind === "group" || c.type === "group";
|
|
2037
|
+
const friend = cardFriend(c, peers);
|
|
2038
|
+
const action = friend ? "chat" : address ? isGroup ? "join" : "add" : null;
|
|
2039
|
+
return { userid, address, isGroup, friend, action };
|
|
2040
|
+
}
|
|
1786
2041
|
var DK_CMD_HIST_KEY = "beagle.assistant.history";
|
|
1787
2042
|
var DK_CMD_HIST_MAX = 50;
|
|
1788
2043
|
function RequestsBlock({ T, requests, onAct }) {
|
|
@@ -1970,7 +2225,7 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
1970
2225
|
textOverflow: "ellipsis",
|
|
1971
2226
|
flex: 1,
|
|
1972
2227
|
minWidth: 0
|
|
1973
|
-
} }, dkRowPreview(row.preview)))), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-end", gap: 4, flexShrink: 0 } }, /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 10.5, color: "var(--faint)" } }, row.lastTime), peer.app ? null : row.unread ? /* @__PURE__ */ React.createElement(Unread, { n: row.unread }) : peer.pending ? /* @__PURE__ */ React.createElement(Icon, { name: "clock", size: 11, stroke: 2.2, color: "var(--warn, #d29922)", title: "friend request pending" }) : /* @__PURE__ */ React.createElement(StatusDot, { online: peer.online })));
|
|
2228
|
+
} }, dkRowPreview(row.preview, T)))), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-end", gap: 4, flexShrink: 0 } }, /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 10.5, color: "var(--faint)" } }, row.lastTime), peer.app ? null : row.unread ? /* @__PURE__ */ React.createElement(Unread, { n: row.unread }) : peer.pending ? /* @__PURE__ */ React.createElement(Icon, { name: "clock", size: 11, stroke: 2.2, color: "var(--warn, #d29922)", title: "friend request pending" }) : /* @__PURE__ */ React.createElement(StatusDot, { online: peer.online })));
|
|
1974
2229
|
}
|
|
1975
2230
|
function dkActivityTs(p, isProtocol, fix) {
|
|
1976
2231
|
const row = rosterRow(p, isProtocol || (() => false), fix);
|
|
@@ -2169,41 +2424,7 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2169
2424
|
return out;
|
|
2170
2425
|
}
|
|
2171
2426
|
function dkParseBeagleContact(raw) {
|
|
2172
|
-
|
|
2173
|
-
const fence = /```\s*beagle-contact\s*\n([\s\S]*?)\n```/i.exec(text);
|
|
2174
|
-
if (fence) {
|
|
2175
|
-
try {
|
|
2176
|
-
const j = JSON.parse(fence[1].trim());
|
|
2177
|
-
if (j && (j.type === "beagle_contact" || j.type === "beagle-contact")) {
|
|
2178
|
-
return {
|
|
2179
|
-
name: j.name || "",
|
|
2180
|
-
ens: j.ens || "",
|
|
2181
|
-
userid: j.userid || j.userId || "",
|
|
2182
|
-
address: j.address || "",
|
|
2183
|
-
avatar: j.avatar || j.avatarUrl || "",
|
|
2184
|
-
description: j.description || ""
|
|
2185
|
-
};
|
|
2186
|
-
}
|
|
2187
|
-
} catch (e) {
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
if (/^\s*BCR1\s+/i.test(text)) {
|
|
2191
|
-
try {
|
|
2192
|
-
const j = JSON.parse(text.replace(/^\s*BCR1\s+/i, "").trim());
|
|
2193
|
-
if (j && j.type === "beagle_contact") {
|
|
2194
|
-
return {
|
|
2195
|
-
name: j.name || "",
|
|
2196
|
-
ens: j.ens || "",
|
|
2197
|
-
userid: j.userid || j.userId || "",
|
|
2198
|
-
address: j.address || "",
|
|
2199
|
-
avatar: j.avatar || "",
|
|
2200
|
-
description: j.description || ""
|
|
2201
|
-
};
|
|
2202
|
-
}
|
|
2203
|
-
} catch (e) {
|
|
2204
|
-
}
|
|
2205
|
-
}
|
|
2206
|
-
return null;
|
|
2427
|
+
return parseBeagleContact(raw);
|
|
2207
2428
|
}
|
|
2208
2429
|
function dkEncodeBeagleContact(p) {
|
|
2209
2430
|
const j = {
|
|
@@ -2221,7 +2442,7 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2221
2442
|
const link = "\n\n[Open name card](https://app.beagle.chat/#/chat?address=" + encodeURIComponent(p.address || "") + ")";
|
|
2222
2443
|
return head + bio + link + "\n\n```beagle-contact\n" + JSON.stringify(j) + "\n```\n";
|
|
2223
2444
|
}
|
|
2224
|
-
function dkRowPreview(text) {
|
|
2445
|
+
function dkRowPreview(text, T) {
|
|
2225
2446
|
const card = dkContactPreview(text);
|
|
2226
2447
|
if (card)
|
|
2227
2448
|
return card;
|
|
@@ -2229,7 +2450,7 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2229
2450
|
const mine = /^you:\s*/i.test(s);
|
|
2230
2451
|
const cgp = dkParseCGP1(s.replace(/^you:\s*/i, ""));
|
|
2231
2452
|
if (cgp)
|
|
2232
|
-
return (mine ? "you: " : "") + cgp.sender + ": " + cgp.body.replace(/\s+/g, " ");
|
|
2453
|
+
return (mine ? "you: " : "") + cgp.sender + ": " + (cgp.file ? fileLabel(cgp.file, T) : cgp.body.replace(/\s+/g, " "));
|
|
2233
2454
|
return s;
|
|
2234
2455
|
}
|
|
2235
2456
|
function dkContactPreview(text) {
|
|
@@ -2375,7 +2596,8 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2375
2596
|
const senderId = origin.userid || origin.friendid || null;
|
|
2376
2597
|
const sender = origin.nickname || origin.user_info && origin.user_info.name || (senderId ? senderId.slice(0, 10) : "member");
|
|
2377
2598
|
const body = j.message && j.message.text || j.render && j.render.plain || "";
|
|
2378
|
-
|
|
2599
|
+
const file = cgpFile(j.message);
|
|
2600
|
+
return { sender, senderId, body: String(body), ts: null, strong: true, file };
|
|
2379
2601
|
}
|
|
2380
2602
|
function dkGroupParse(text) {
|
|
2381
2603
|
const cgp = dkParseCGP1(text);
|
|
@@ -2692,11 +2914,44 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2692
2914
|
return /* @__PURE__ */ React.createElement(DkGreetingMsg, { m: props.m, peer: props.peer, T: props.T });
|
|
2693
2915
|
return /* @__PURE__ */ React.createElement(DkMsgBody, { ...props });
|
|
2694
2916
|
}
|
|
2917
|
+
function DkGroupFileCard({ file, T, offline }) {
|
|
2918
|
+
const voice = file.voice;
|
|
2919
|
+
const label = voice ? (T && T.voiceMessage || "Voice message") + (file.durationMs ? " \xB7 " + formatDuration(file.durationMs) : "") : file.name;
|
|
2920
|
+
return /* @__PURE__ */ React.createElement("div", { style: {
|
|
2921
|
+
display: "flex",
|
|
2922
|
+
alignItems: "center",
|
|
2923
|
+
gap: 10,
|
|
2924
|
+
padding: "9px 12px",
|
|
2925
|
+
borderRadius: 12,
|
|
2926
|
+
maxWidth: 320,
|
|
2927
|
+
background: offline ? "rgba(245,158,11,0.16)" : "var(--bub-them)",
|
|
2928
|
+
border: "1px solid " + (offline ? "rgba(245,158,11,0.55)" : "var(--line)")
|
|
2929
|
+
} }, /* @__PURE__ */ React.createElement("span", { style: {
|
|
2930
|
+
width: 34,
|
|
2931
|
+
height: 34,
|
|
2932
|
+
borderRadius: 17,
|
|
2933
|
+
flexShrink: 0,
|
|
2934
|
+
display: "inline-flex",
|
|
2935
|
+
alignItems: "center",
|
|
2936
|
+
justifyContent: "center",
|
|
2937
|
+
background: "var(--panel-2)",
|
|
2938
|
+
border: "1px solid var(--line)"
|
|
2939
|
+
} }, /* @__PURE__ */ React.createElement(Icon, { name: voice ? "mic" : file.media === "image" ? "image" : file.media === "video" ? "video" : "file", size: 17, stroke: 2, color: "var(--faint)" })), /* @__PURE__ */ React.createElement("span", { style: { display: "flex", flexDirection: "column", minWidth: 0, gap: 2 } }, /* @__PURE__ */ React.createElement("span", { style: {
|
|
2940
|
+
fontFamily: voice ? "var(--ui)" : "var(--mono)",
|
|
2941
|
+
fontSize: 12.5,
|
|
2942
|
+
fontWeight: 600,
|
|
2943
|
+
color: "var(--text)",
|
|
2944
|
+
whiteSpace: "nowrap",
|
|
2945
|
+
overflow: "hidden",
|
|
2946
|
+
textOverflow: "ellipsis"
|
|
2947
|
+
} }, label), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--ui)", fontSize: 11, color: "var(--faint)", lineHeight: 1.35 } }, file.size != null ? dkFileSize(file.size) + " \xB7 " : "", T && T.groupFileNotDelivered || "Not delivered to this device: the group sends agents only a description of files.")));
|
|
2948
|
+
}
|
|
2695
2949
|
function DkMsgBody({ m, peer, T, lang, onTheater, onDelete, onCancel, onRetry, onRetryMsg, onReveal, onOpenFile, onCall, onFormSubmit, onNameCard, onAssistantRemove, onAssistantAdopt, answered, selMode, selected, onToggleSel, busy, isGroup }) {
|
|
2696
2950
|
const mine = m.from === "me";
|
|
2697
2951
|
const nativeMedia = !m.file ? dkNativeMediaFromText(m.text) : null;
|
|
2698
2952
|
const grp = isGroup && m.dir !== "out" && !m.file && !nativeMedia ? dkGroupParse(m.text) : null;
|
|
2699
|
-
const
|
|
2953
|
+
const fileSender = !mine && m.file && m.origin && (m.origin.userid || m.origin.nickname) ? { sender: m.origin.nickname || (m.origin.userid || "").slice(0, 10), senderId: m.origin.userid || null } : null;
|
|
2954
|
+
const grpSender = grp || fileSender || (nativeMedia && nativeMedia.sender ? { sender: nativeMedia.sender, senderId: null } : null);
|
|
2700
2955
|
const read = window.ChatComponents ? window.ChatComponents.readMessage((grp ? grp.body : m.text) || "") : { text: grp ? grp.body : m.text, form: null, interaction: null };
|
|
2701
2956
|
const submitted = read.form && answered ? answered.get(read.form.custom_id) : null;
|
|
2702
2957
|
const rtcFile = !mine && !m.file ? dkRtcFileFromText(peer.userId || peer.id, m.text) : null;
|
|
@@ -2795,7 +3050,10 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2795
3050
|
style: mediaBtnStyle
|
|
2796
3051
|
},
|
|
2797
3052
|
/* @__PURE__ */ React.createElement(Icon, { name: "maximize", size: 16, stroke: 2, color: "#fff" })
|
|
2798
|
-
))), rtcFile.media === "audio" && /* @__PURE__ */ React.createElement("audio", { src: rtcFile.url, controls: true, style: { width: "100%" } }), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "0 2px" } }, /* @__PURE__ */ React.createElement("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, rtcFile.name), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", flexShrink: 0 } }, dkFileSize(rtcFile.size)), /* @__PURE__ */ React.createElement("a", { href: rtcFile.url, download: rtcFile.name, title: "download", style: { display: "inline-flex", flexShrink: 0 } }, /* @__PURE__ */ React.createElement(Icon, { name: "download", size: 15, stroke: 2, color: "var(--accent)" })))) : m.file ? (
|
|
3053
|
+
))), rtcFile.media === "audio" && /* @__PURE__ */ React.createElement("audio", { src: rtcFile.url, controls: true, style: { width: "100%" } }), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "0 2px" } }, /* @__PURE__ */ React.createElement("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, rtcFile.name), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", flexShrink: 0 } }, dkFileSize(rtcFile.size)), /* @__PURE__ */ React.createElement("a", { href: rtcFile.url, download: rtcFile.name, title: "download", style: { display: "inline-flex", flexShrink: 0 } }, /* @__PURE__ */ React.createElement(Icon, { name: "download", size: 15, stroke: 2, color: "var(--accent)" })))) : m.file ? /* @__PURE__ */ React.createElement(
|
|
3054
|
+
React.Fragment,
|
|
3055
|
+
null,
|
|
3056
|
+
fileSender && /* @__PURE__ */ React.createElement(DkGroupSender, { grp: fileSender, T }),
|
|
2799
3057
|
// Inline preview/player. Received media: as soon as it's saved.
|
|
2800
3058
|
// Sent media: once it's fully delivered ('sent') — the daemon keeps a
|
|
2801
3059
|
// local copy so it plays on the sender's side too.
|
|
@@ -2859,7 +3117,7 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2859
3117
|
style: mediaBtnStyle
|
|
2860
3118
|
},
|
|
2861
3119
|
/* @__PURE__ */ React.createElement(Icon, { name: "maximize", size: 16, stroke: 2, color: "#fff" })
|
|
2862
|
-
))), m.file.media === "audio" && /* @__PURE__ */ React.createElement("audio", { src: dkFileUrl(m.file.name), controls: true, style: { width: "100%" } }), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "0 2px" } }, /* @__PURE__ */ React.createElement("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, m.file.name), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", flexShrink: 0 } }, m.file.size), onReveal && /* @__PURE__ */ React.createElement(
|
|
3120
|
+
))), m.file.media === "audio" && m.file.voice && /* @__PURE__ */ React.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, padding: "0 2px", fontFamily: "var(--ui)", fontSize: 12, color: "var(--dim)" } }, /* @__PURE__ */ React.createElement(Icon, { name: "mic", size: 14, stroke: 2, color: "var(--accent)" }), T && T.voiceMessage || "Voice message", m.file.durationMs ? " \xB7 " + formatDuration(m.file.durationMs) : ""), m.file.media === "audio" && /* @__PURE__ */ React.createElement("audio", { src: dkFileUrl(m.file.name), controls: true, style: { width: "100%" } }), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "0 2px" } }, /* @__PURE__ */ React.createElement("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, m.file.name), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)", flexShrink: 0 } }, m.file.size), onReveal && /* @__PURE__ */ React.createElement(
|
|
2863
3121
|
"button",
|
|
2864
3122
|
{
|
|
2865
3123
|
title: T.revealInFinder || "\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u663E\u793A / Show in file manager",
|
|
@@ -3002,7 +3260,7 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
3002
3260
|
}
|
|
3003
3261
|
}
|
|
3004
3262
|
}
|
|
3005
|
-
) : nativeMedia.kind === "audio" ? /* @__PURE__ */ React.createElement("audio", { controls: true, src: nativeMedia.url, style: { maxWidth: "100%" } }) : /* @__PURE__ */ React.createElement("video", { controls: true, src: nativeMedia.url, style: { maxWidth: "100%", borderRadius: 12, border: "1px solid var(--line)" } })) : (() => {
|
|
3263
|
+
) : nativeMedia.kind === "audio" ? /* @__PURE__ */ React.createElement("audio", { controls: true, src: nativeMedia.url, style: { maxWidth: "100%" } }) : /* @__PURE__ */ React.createElement("video", { controls: true, src: nativeMedia.url, style: { maxWidth: "100%", borderRadius: 12, border: "1px solid var(--line)" } })) : grp && grp.file ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DkGroupSender, { grp, T }), /* @__PURE__ */ React.createElement(DkGroupFileCard, { file: grp.file, T, offline: m.via === "offline" })) : (() => {
|
|
3006
3264
|
const contact = !read.form ? dkParseBeagleContact(read.text) : null;
|
|
3007
3265
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, grp && /* @__PURE__ */ React.createElement(DkGroupSender, { grp, T }), contact && (contact.address || contact.userid) ? /* @__PURE__ */ React.createElement(DkContactCardMsg, { card: contact, mine, T, onNameCard }) : /* @__PURE__ */ React.createElement("div", { style: {
|
|
3008
3266
|
padding: "8px 12px",
|
|
@@ -3628,16 +3886,18 @@ ${peer.address}`
|
|
|
3628
3886
|
))),
|
|
3629
3887
|
pubProfile && /* @__PURE__ */ React.createElement(DkPublicProfile, { T, userid: peer.userId, fallbackName: peer.alias, isFriend: true, onClose: () => setPubProfile(false) }),
|
|
3630
3888
|
nameCardProf && (() => {
|
|
3631
|
-
const
|
|
3889
|
+
const cardFriend2 = cardFriend(nameCardProf, peers);
|
|
3632
3890
|
return /* @__PURE__ */ React.createElement(
|
|
3633
3891
|
DkPublicProfile,
|
|
3634
3892
|
{
|
|
3635
3893
|
T,
|
|
3636
|
-
userid:
|
|
3637
|
-
fallbackName: nameCardProf.name || nameCardProf.ens,
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3894
|
+
userid: cardFriend2 && cardFriend2.userId || nameCardProf.userid || nameCardProf.address,
|
|
3895
|
+
fallbackName: cardFriend2 && cardFriend2.alias || nameCardProf.name || nameCardProf.ens,
|
|
3896
|
+
card: nameCardProf,
|
|
3897
|
+
friend: cardFriend2,
|
|
3898
|
+
isFriend: !!cardFriend2,
|
|
3899
|
+
onMessage: cardFriend2 && onOpenChat ? () => {
|
|
3900
|
+
onOpenChat(cardFriend2.id);
|
|
3641
3901
|
setNameCardProf(null);
|
|
3642
3902
|
} : void 0,
|
|
3643
3903
|
onClose: () => setNameCardProf(null)
|
|
@@ -3675,65 +3935,6 @@ ${peer.address}`
|
|
|
3675
3935
|
return /* @__PURE__ */ React.createElement("div", { style: { flex: 1, display: "flex", minWidth: 0, minHeight: 0 } }, /* @__PURE__ */ React.createElement(PeerSidebar, { T, peers, requests, activeId, onSelect, onAct, onAdd, prefillAddr, onPrefillConsumed, muted, isProtocol, protocolFix }), peer ? /* @__PURE__ */ React.createElement(Conversation, { T, peer, lang, peers, onOpenChat: onSelect, thread, isProtocol, onSend, onSendFile, onSendRtcFile, onAlias, onRemove, onOpenNet, onCall, onReloadThread, hasEarlier, onLoadEarlier, onAssistantRemove, onAssistantAdopt, muted: !!muted && muted.includes(peer.id), onToggleMute }) : /* @__PURE__ */ React.createElement(ChatEmpty, { T }));
|
|
3676
3936
|
}
|
|
3677
3937
|
Object.assign(window, { ChatTab });
|
|
3678
|
-
var PROOF_KEY = { eth: "proof.eth", sol: "proof.sol" };
|
|
3679
|
-
var HEAD = "Beagle wallet binding";
|
|
3680
|
-
var LINE = "I bind this wallet to my Beagle identity.";
|
|
3681
|
-
var ADDRESS_RE = { eth: /^0x[0-9a-fA-F]{40}$/, sol: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/ };
|
|
3682
|
-
var USERID_RE = /^[1-9A-HJ-NP-Za-km-z]{32,48}$/;
|
|
3683
|
-
var ISSUED_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
|
|
3684
|
-
function isWalletAddress(chain, address) {
|
|
3685
|
-
const re = ADDRESS_RE[chain];
|
|
3686
|
-
return !!re && typeof address === "string" && re.test(address);
|
|
3687
|
-
}
|
|
3688
|
-
function proofTime(date = /* @__PURE__ */ new Date()) {
|
|
3689
|
-
return new Date(Math.floor(date.getTime() / 1e3) * 1e3).toISOString().replace(".000Z", "Z");
|
|
3690
|
-
}
|
|
3691
|
-
function walletProofMessage({ userid, chain, address, issued }) {
|
|
3692
|
-
if (!USERID_RE.test(String(userid || "")))
|
|
3693
|
-
throw new Error("wallet proof: bad userid");
|
|
3694
|
-
if (!isWalletAddress(chain, address))
|
|
3695
|
-
throw new Error("wallet proof: bad chain or address");
|
|
3696
|
-
if (!ISSUED_RE.test(String(issued || "")))
|
|
3697
|
-
throw new Error("wallet proof: bad issued time");
|
|
3698
|
-
return [HEAD, "", LINE, "", `userid: ${userid}`, `chain: ${chain}`, `address: ${address}`, `issued: ${issued}`].join("\n");
|
|
3699
|
-
}
|
|
3700
|
-
var B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
3701
|
-
function base58Encode(bytes) {
|
|
3702
|
-
const digits = [];
|
|
3703
|
-
for (const b of bytes) {
|
|
3704
|
-
let carry = b;
|
|
3705
|
-
for (let j = 0; j < digits.length; j++) {
|
|
3706
|
-
carry += digits[j] << 8;
|
|
3707
|
-
digits[j] = carry % 58;
|
|
3708
|
-
carry = carry / 58 | 0;
|
|
3709
|
-
}
|
|
3710
|
-
while (carry > 0) {
|
|
3711
|
-
digits.push(carry % 58);
|
|
3712
|
-
carry = carry / 58 | 0;
|
|
3713
|
-
}
|
|
3714
|
-
}
|
|
3715
|
-
let out = "";
|
|
3716
|
-
for (const b of bytes) {
|
|
3717
|
-
if (b !== 0)
|
|
3718
|
-
break;
|
|
3719
|
-
out += "1";
|
|
3720
|
-
}
|
|
3721
|
-
for (let i = digits.length - 1; i >= 0; i--)
|
|
3722
|
-
out += B58[digits[i]];
|
|
3723
|
-
return out;
|
|
3724
|
-
}
|
|
3725
|
-
var utf8Hex = (s) => "0x" + Array.from(new TextEncoder().encode(s), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
3726
|
-
async function signEthProof(provider, { userid, address, issued = proofTime() }) {
|
|
3727
|
-
const message = walletProofMessage({ userid, chain: "eth", address, issued });
|
|
3728
|
-
const signature = await provider.request({ method: "personal_sign", params: [utf8Hex(message), address] });
|
|
3729
|
-
return { message, signature: String(signature) };
|
|
3730
|
-
}
|
|
3731
|
-
async function signSolProof(wallet, { userid, address, issued = proofTime() }) {
|
|
3732
|
-
const message = walletProofMessage({ userid, chain: "sol", address, issued });
|
|
3733
|
-
const r = await wallet.signMessage(new TextEncoder().encode(message), "utf8");
|
|
3734
|
-
const sig = r && r.signature ? r.signature : r;
|
|
3735
|
-
return { message, signature: base58Encode(Uint8Array.from(sig)) };
|
|
3736
|
-
}
|
|
3737
3938
|
function CopyBtn({ value, copiedText = "Copied", copyFailedText = "Copy failed", copyTitle = "Copy" }) {
|
|
3738
3939
|
const [status, setStatus] = React.useState(null);
|
|
3739
3940
|
const timer = React.useRef(null);
|
|
@@ -3995,7 +4196,20 @@ ${peer.address}`
|
|
|
3995
4196
|
/* @__PURE__ */ React.createElement("img", { src: p.image, alt: `punk #${p.id}`, style: { width: "100%", height: "100%", imageRendering: "pixelated", display: "block" } })
|
|
3996
4197
|
))))));
|
|
3997
4198
|
}
|
|
3998
|
-
function
|
|
4199
|
+
function DkNameCardNoProfile({ T, view, card, onMessage, isMe }) {
|
|
4200
|
+
const [addState, setAddState] = React.useState(null);
|
|
4201
|
+
const lbl = { width: 110, flexShrink: 0, fontFamily: "var(--mono)", fontSize: 11, fontWeight: 600, color: "var(--faint)", textTransform: "uppercase", letterSpacing: 0.5 };
|
|
4202
|
+
const rowS = { display: "flex", alignItems: "center", gap: 10, padding: "10px 0", borderTop: "1px solid var(--line)" };
|
|
4203
|
+
const cta = { padding: "7px 16px", borderRadius: 9, cursor: "pointer", fontFamily: "var(--ui)", fontSize: 12.5, border: "none", background: "var(--accent)", color: "#fff" };
|
|
4204
|
+
const kvRow = (label, value, head = 8) => /* @__PURE__ */ React.createElement("div", { style: rowS, key: label }, /* @__PURE__ */ React.createElement("span", { style: lbl }, label), /* @__PURE__ */ React.createElement("span", { title: value, style: { flex: 1, minWidth: 0, fontFamily: "var(--mono)", fontSize: 11.5, color: "var(--dim)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, shortKey(value, head, 6)), /* @__PURE__ */ React.createElement(CopyBtn, { value, copiedText: T.copied, copyFailedText: T.copyFailed, copyTitle: T.copy }));
|
|
4205
|
+
const add = () => {
|
|
4206
|
+
setAddState("busy");
|
|
4207
|
+
fetch("/api/add", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ address: view.address }) }).then((r) => r.json()).then((r) => setAddState(r.ok !== false ? "sent" : r.error || T.addFailed || "failed")).catch((e) => setAddState(String(e && e.message || e)));
|
|
4208
|
+
};
|
|
4209
|
+
return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column" } }, /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)", paddingBottom: 10, lineHeight: 1.5 } }, view.friend ? T.cardIsFriend || "Already in your chats." : T.cardNoEns || "No beagles.eth name registered."), card && card.description && /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--dim)", paddingBottom: 10, lineHeight: 1.5 } }, card.description), view.userid && kvRow(T.userId || "user id", view.userid, 10), view.address && kvRow(T.addr || "address", view.address), !isMe && view.action && /* @__PURE__ */ React.createElement("div", { style: { ...rowS, justifyContent: "flex-end", gap: 8 } }, view.action === "chat" ? onMessage && /* @__PURE__ */ React.createElement("button", { onClick: onMessage, style: cta }, T.openChat || "Open chat") : addState === "sent" ? /* @__PURE__ */ React.createElement(Tag, { tone: "accent" }, T.dirSent || "requested") : addState && addState !== "busy" ? /* @__PURE__ */ React.createElement("span", { title: addState, style: { fontFamily: "var(--ui)", fontSize: 11.5, color: "var(--warn, #f59e0b)" } }, T.addFailed || "failed") : /* @__PURE__ */ React.createElement("button", { onClick: add, disabled: addState === "busy", style: { ...cta, opacity: addState === "busy" ? 0.6 : 1 } }, addState === "busy" ? "\u2026" : view.action === "join" ? T.joinGroup || "Join group" : T.dirAdd || "Add")));
|
|
4210
|
+
}
|
|
4211
|
+
function DkPublicProfile({ T, userid, fallbackName, onClose, isFriend, isMe, onMessage, card, friend }) {
|
|
4212
|
+
const view = card ? nameCardView(card, friend ? [friend] : []) : null;
|
|
3999
4213
|
const [st, setSt] = React.useState({ loading: true });
|
|
4000
4214
|
const [addState, setAddState] = React.useState(null);
|
|
4001
4215
|
const [recOpen, setRecOpen] = React.useState(false);
|
|
@@ -4046,7 +4260,7 @@ ${peer.address}`
|
|
|
4046
4260
|
const links = prof ? Object.entries(prof.links || {}) : [];
|
|
4047
4261
|
const lbl = { width: 110, flexShrink: 0, fontFamily: "var(--mono)", fontSize: 11, fontWeight: 600, color: "var(--faint)", textTransform: "uppercase", letterSpacing: 0.5 };
|
|
4048
4262
|
const rowS = { display: "flex", alignItems: "center", gap: 10, padding: "10px 0", borderTop: "1px solid var(--line)" };
|
|
4049
|
-
return /* @__PURE__ */ React.createElement("div", { onClick: onClose, style: { position: "fixed", inset: 0, zIndex: 90, background: "color-mix(in oklab, #000, transparent 38%)", display: "flex", alignItems: "center", justifyContent: "center", padding: 24 } }, /* @__PURE__ */ React.createElement("div", { onClick: (e) => e.stopPropagation(), style: { width: 420, maxWidth: "94vw", background: "var(--panel)", border: "1px solid var(--line)", borderRadius: 16, padding: "20px 22px", display: "flex", flexDirection: "column", gap: 14 } }, /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 14 } }, prof && prof.avatarUrl ? /* @__PURE__ */ React.createElement(DkImgAvatar, { url: prof.avatarUrl, seed: userid, size: 56, radius: 14 }) : prof && prof.punkId != null ? /* @__PURE__ */ React.createElement(DkPunkAvatar, { id: prof.punkId, size: 56, radius: 14, fallbackSeed: userid }) : /* @__PURE__ */ React.createElement(DkIdenticon, { seed: userid, size: 56, radius: 14 }), /* @__PURE__ */ React.createElement("div", { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 17, fontWeight: 700, color: "var(--text)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, prof && prof.displayName || fallbackName || shortKey(userid, 10, 6)), prof && prof.ens && /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--mono)", fontSize: 12, color: "var(--accent)", marginTop: 2 } }, prof.ens)), /* @__PURE__ */ React.createElement(Btn, { icon: "x", size: "sm", onClick: onClose })), st.loading ? /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)" } }, T.dirLoading || "loading\u2026") : !prof ? /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)" } }, T.pubNone || "No public profile \u2014 this user has not registered a beagles.eth name.") : /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column" } }, prof.description && /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--dim)", paddingBottom: 12, lineHeight: 1.5 } }, prof.description), links.length > 0 && // Label keeps its column; pills wrap inside their OWN container so
|
|
4263
|
+
return /* @__PURE__ */ React.createElement("div", { onClick: onClose, style: { position: "fixed", inset: 0, zIndex: 90, background: "color-mix(in oklab, #000, transparent 38%)", display: "flex", alignItems: "center", justifyContent: "center", padding: 24 } }, /* @__PURE__ */ React.createElement("div", { onClick: (e) => e.stopPropagation(), style: { width: 420, maxWidth: "94vw", background: "var(--panel)", border: "1px solid var(--line)", borderRadius: 16, padding: "20px 22px", display: "flex", flexDirection: "column", gap: 14 } }, /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 14 } }, prof && prof.avatarUrl ? /* @__PURE__ */ React.createElement(DkImgAvatar, { url: prof.avatarUrl, seed: userid, size: 56, radius: 14 }) : prof && prof.punkId != null ? /* @__PURE__ */ React.createElement(DkPunkAvatar, { id: prof.punkId, size: 56, radius: 14, fallbackSeed: userid }) : friend ? /* @__PURE__ */ React.createElement(DkAvatar, { peer: friend, size: 56, radius: 14, dot: false }) : card && card.avatar ? /* @__PURE__ */ React.createElement(DkImgAvatar, { url: card.avatar, seed: userid, size: 56, radius: 14 }) : /* @__PURE__ */ React.createElement(DkIdenticon, { seed: userid, size: 56, radius: 14 }), /* @__PURE__ */ React.createElement("div", { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 17, fontWeight: 700, color: "var(--text)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, prof && prof.displayName || fallbackName || shortKey(userid, 10, 6)), prof && prof.ens && /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--mono)", fontSize: 12, color: "var(--accent)", marginTop: 2 } }, prof.ens)), /* @__PURE__ */ React.createElement(Btn, { icon: "x", size: "sm", onClick: onClose })), st.loading ? /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)" } }, T.dirLoading || "loading\u2026") : !prof && view ? /* @__PURE__ */ React.createElement(DkNameCardNoProfile, { T, view, card, onMessage, isMe }) : !prof ? /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)" } }, T.pubNone || "No public profile \u2014 this user has not registered a beagles.eth name.") : /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column" } }, prof.description && /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--dim)", paddingBottom: 12, lineHeight: 1.5 } }, prof.description), links.length > 0 && // Label keeps its column; pills wrap inside their OWN container so
|
|
4050
4264
|
// an overflowing pill lands under the first pill, never under the label.
|
|
4051
4265
|
/* @__PURE__ */ React.createElement("div", { style: { ...rowS, alignItems: "flex-start" } }, /* @__PURE__ */ React.createElement("span", { style: { ...lbl, paddingTop: 5 } }, T.linksCard || "links"), /* @__PURE__ */ React.createElement("div", { style: { flex: 1, minWidth: 0, display: "flex", gap: 8, flexWrap: "wrap" } }, links.map(([k, h]) => /* @__PURE__ */ React.createElement(
|
|
4052
4266
|
"a",
|
|
@@ -4085,7 +4299,7 @@ ${peer.address}`
|
|
|
4085
4299
|
disabled: addState === "busy",
|
|
4086
4300
|
style: { ...cta, border: "none", background: "var(--accent)", color: "#fff", opacity: addState === "busy" ? 0.6 : 1 }
|
|
4087
4301
|
},
|
|
4088
|
-
addState === "busy" ? "\u2026" : T.dirAdd || "Add"
|
|
4302
|
+
addState === "busy" ? "\u2026" : view && view.isGroup ? T.joinGroup || "Join group" : T.dirAdd || "Add"
|
|
4089
4303
|
)));
|
|
4090
4304
|
})(), recOpen && /* @__PURE__ */ React.createElement("div", { style: { borderTop: "1px solid var(--line)", paddingTop: 10, display: "flex", flexDirection: "column", gap: 4, maxHeight: 200, overflowY: "auto" } }, /* @__PURE__ */ React.createElement("span", { style: { ...lbl, width: "auto", paddingBottom: 4 } }, T.pubRecTitle || "send this card to\u2026"), !recPeers ? /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--ui)", fontSize: 12, color: "var(--faint)" } }, T.dirLoading || "loading\u2026") : recPeers.length === 0 ? /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--ui)", fontSize: 12, color: "var(--faint)" } }, T.dirEmpty || "nobody") : recPeers.map((p) => /* @__PURE__ */ React.createElement(
|
|
4091
4305
|
"button",
|
|
@@ -5209,13 +5423,89 @@ ${peer.address}`
|
|
|
5209
5423
|
};
|
|
5210
5424
|
}
|
|
5211
5425
|
Object.assign(window, { dkRtcSignalBus, makeDaemonSignaling });
|
|
5426
|
+
var CALL_END_STATES = /* @__PURE__ */ new Set(["noAnswer", "unreachable", "failed", "busy", "declined"]);
|
|
5427
|
+
var CALL_END_LINGER_MS = 3500;
|
|
5428
|
+
var EN = {
|
|
5429
|
+
calling: "calling\u2026",
|
|
5430
|
+
remoteRinging: "ringing\u2026",
|
|
5431
|
+
connecting: "connecting\u2026",
|
|
5432
|
+
reconnecting: "reconnecting\u2026",
|
|
5433
|
+
noAnswer: "No answer",
|
|
5434
|
+
cantReach: "Can't reach {name}",
|
|
5435
|
+
callFailed: "Call failed",
|
|
5436
|
+
busy: "Busy",
|
|
5437
|
+
declined: "Declined"
|
|
5438
|
+
};
|
|
5439
|
+
function str(T, key) {
|
|
5440
|
+
return T && T[key] || EN[key];
|
|
5441
|
+
}
|
|
5442
|
+
function callStateLabel(state, T, name) {
|
|
5443
|
+
switch (state) {
|
|
5444
|
+
case "ringing":
|
|
5445
|
+
return str(T, "calling");
|
|
5446
|
+
case "remoteRinging":
|
|
5447
|
+
case "remoteOnline":
|
|
5448
|
+
return str(T, "remoteRinging");
|
|
5449
|
+
case "connecting":
|
|
5450
|
+
return str(T, "connecting");
|
|
5451
|
+
case "disconnected":
|
|
5452
|
+
return str(T, "reconnecting");
|
|
5453
|
+
case "noAnswer":
|
|
5454
|
+
return str(T, "noAnswer");
|
|
5455
|
+
case "unreachable":
|
|
5456
|
+
return str(T, "cantReach").replace("{name}", name || "");
|
|
5457
|
+
case "failed":
|
|
5458
|
+
return str(T, "callFailed");
|
|
5459
|
+
case "busy":
|
|
5460
|
+
return str(T, "busy");
|
|
5461
|
+
case "declined":
|
|
5462
|
+
return str(T, "declined");
|
|
5463
|
+
default:
|
|
5464
|
+
return state || "";
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5467
|
+
function callStateTone(state) {
|
|
5468
|
+
if (state === "connected")
|
|
5469
|
+
return "ok";
|
|
5470
|
+
if (CALL_END_STATES.has(state))
|
|
5471
|
+
return "danger";
|
|
5472
|
+
return "warn";
|
|
5473
|
+
}
|
|
5474
|
+
function endStateFor(reason, error) {
|
|
5475
|
+
if (reason === "noAnswer" || reason === "unreachable" || reason === "busy" || reason === "declined")
|
|
5476
|
+
return reason;
|
|
5477
|
+
if (reason === "failed")
|
|
5478
|
+
return "failed";
|
|
5479
|
+
if (error)
|
|
5480
|
+
return error.sendFailed ? "unreachable" : "failed";
|
|
5481
|
+
return null;
|
|
5482
|
+
}
|
|
5212
5483
|
function useCallController(selfId, onCallLog) {
|
|
5213
5484
|
const [incoming, setIncoming] = React.useState(null);
|
|
5214
5485
|
const [active, setActive] = React.useState(null);
|
|
5215
5486
|
const [localStream, setLocalStream] = React.useState(null);
|
|
5216
5487
|
const [remoteStream, setRemoteStream] = React.useState(null);
|
|
5217
5488
|
const [sharing, setSharing] = React.useState(false);
|
|
5489
|
+
const [notice, setNotice] = React.useState(null);
|
|
5218
5490
|
const engineRef = React.useRef(null);
|
|
5491
|
+
const lingerTimer = React.useRef(null);
|
|
5492
|
+
const noticeTimer = React.useRef(null);
|
|
5493
|
+
const endWithReason = React.useCallback((match, state) => {
|
|
5494
|
+
setActive((a) => a && !a.ended && match(a) ? { ...a, state, ended: true } : a);
|
|
5495
|
+
clearTimeout(lingerTimer.current);
|
|
5496
|
+
lingerTimer.current = setTimeout(() => {
|
|
5497
|
+
setActive((a) => a && a.ended ? null : a);
|
|
5498
|
+
}, CALL_END_LINGER_MS);
|
|
5499
|
+
}, []);
|
|
5500
|
+
const flashNotice = React.useCallback((text) => {
|
|
5501
|
+
setNotice(text);
|
|
5502
|
+
clearTimeout(noticeTimer.current);
|
|
5503
|
+
noticeTimer.current = setTimeout(() => setNotice(null), 4e3);
|
|
5504
|
+
}, []);
|
|
5505
|
+
React.useEffect(() => () => {
|
|
5506
|
+
clearTimeout(lingerTimer.current);
|
|
5507
|
+
clearTimeout(noticeTimer.current);
|
|
5508
|
+
}, []);
|
|
5219
5509
|
const onCallLogRef = React.useRef(onCallLog);
|
|
5220
5510
|
React.useEffect(() => {
|
|
5221
5511
|
onCallLogRef.current = onCallLog;
|
|
@@ -5269,7 +5559,7 @@ ${peer.address}`
|
|
|
5269
5559
|
if (onCallLogRef.current)
|
|
5270
5560
|
onCallLogRef.current(info.peerId, !!info.video, "incoming");
|
|
5271
5561
|
});
|
|
5272
|
-
engine.on("stateChanged", (info, state) => setActive((a) => a && a.callId === info.callId ? { ...a, state } : a));
|
|
5562
|
+
engine.on("stateChanged", (info, state) => setActive((a) => a && !a.ended && a.callId === info.callId ? { ...a, state } : a));
|
|
5273
5563
|
engine.on("localStream", (id, s) => {
|
|
5274
5564
|
setLocalStream(s);
|
|
5275
5565
|
try {
|
|
@@ -5278,8 +5568,14 @@ ${peer.address}`
|
|
|
5278
5568
|
}
|
|
5279
5569
|
});
|
|
5280
5570
|
engine.on("remoteStream", (id, s) => setRemoteStream(s));
|
|
5281
|
-
engine.on("ended", (id) => {
|
|
5282
|
-
|
|
5571
|
+
engine.on("ended", (id, reason) => {
|
|
5572
|
+
const endState = endStateFor(reason);
|
|
5573
|
+
const a0 = activeRef.current;
|
|
5574
|
+
if (endState && a0 && a0.callId === id && a0.direction === "outgoing" && CALL_END_STATES.has(endState)) {
|
|
5575
|
+
endWithReason((a) => a.callId === id, endState);
|
|
5576
|
+
} else {
|
|
5577
|
+
setActive((a) => a && a.callId === id ? null : a);
|
|
5578
|
+
}
|
|
5283
5579
|
setIncoming((i) => i && i.callId === id ? null : i);
|
|
5284
5580
|
setLocalStream(null);
|
|
5285
5581
|
setRemoteStream(null);
|
|
@@ -5312,15 +5608,20 @@ ${peer.address}`
|
|
|
5312
5608
|
setActive({ callId: null, peerId, video: !!video, direction: "outgoing", state: "ringing" });
|
|
5313
5609
|
if (onCallLogRef.current)
|
|
5314
5610
|
onCallLogRef.current(peerId, !!video, "outgoing");
|
|
5611
|
+
let engine = null;
|
|
5315
5612
|
waitEngine().then((eng) => {
|
|
5316
5613
|
if (!eng)
|
|
5317
5614
|
throw new Error("Calls unavailable (engine not ready)");
|
|
5615
|
+
engine = eng;
|
|
5318
5616
|
return eng.call(peerId, { audio: true, video: !!video });
|
|
5319
|
-
}).then((callId) =>
|
|
5320
|
-
|
|
5321
|
-
|
|
5617
|
+
}).then((callId) => {
|
|
5618
|
+
const info = (engine && engine.calls || []).find((c) => c.callId === callId);
|
|
5619
|
+
setActive((a) => a && a.peerId === peerId && a.callId === null && !a.ended ? { ...a, callId, state: info && info.state || a.state } : a);
|
|
5620
|
+
}).catch((e) => {
|
|
5621
|
+
console.warn("[call] could not start call:", e && e.message || e);
|
|
5622
|
+
endWithReason((a) => a.peerId === peerId && a.callId === null, endStateFor(null, e || {}));
|
|
5322
5623
|
});
|
|
5323
|
-
}, [waitEngine]);
|
|
5624
|
+
}, [waitEngine, endWithReason]);
|
|
5324
5625
|
const incomingRef = React.useRef(null);
|
|
5325
5626
|
React.useEffect(() => {
|
|
5326
5627
|
incomingRef.current = incoming;
|
|
@@ -5381,8 +5682,11 @@ ${peer.address}`
|
|
|
5381
5682
|
if (!eng)
|
|
5382
5683
|
throw new Error("Calls unavailable (engine not ready)");
|
|
5383
5684
|
return eng.accept(pending.callId);
|
|
5384
|
-
}).catch((e) =>
|
|
5385
|
-
|
|
5685
|
+
}).catch((e) => {
|
|
5686
|
+
console.warn("[call] accept failed:", e && e.message || e);
|
|
5687
|
+
endWithReason((a) => a.callId === pending.callId, "failed");
|
|
5688
|
+
});
|
|
5689
|
+
}, [waitEngine, endWithReason]);
|
|
5386
5690
|
const reject = React.useCallback(() => {
|
|
5387
5691
|
const eng = engineRef.current;
|
|
5388
5692
|
const inc = incomingRef.current;
|
|
@@ -5395,7 +5699,8 @@ ${peer.address}`
|
|
|
5395
5699
|
const hangup = React.useCallback(() => {
|
|
5396
5700
|
const eng = engineRef.current;
|
|
5397
5701
|
const a = activeRef.current;
|
|
5398
|
-
|
|
5702
|
+
clearTimeout(lingerTimer.current);
|
|
5703
|
+
if (eng && a && a.callId && !a.ended)
|
|
5399
5704
|
eng.hangup(a.callId);
|
|
5400
5705
|
setActive(null);
|
|
5401
5706
|
setLocalStream(null);
|
|
@@ -5416,16 +5721,18 @@ ${peer.address}`
|
|
|
5416
5721
|
else
|
|
5417
5722
|
await eng.shareScreen(a.callId);
|
|
5418
5723
|
} catch (e) {
|
|
5419
|
-
if (e && e.name !== "NotAllowedError")
|
|
5420
|
-
|
|
5724
|
+
if (e && e.name !== "NotAllowedError") {
|
|
5725
|
+
console.warn("[call] screen share failed:", e && e.message || e);
|
|
5726
|
+
flashNotice("shareFailed");
|
|
5727
|
+
}
|
|
5421
5728
|
}
|
|
5422
|
-
}, [active]);
|
|
5729
|
+
}, [active, flashNotice]);
|
|
5423
5730
|
const setVideoOn = React.useCallback((v) => {
|
|
5424
5731
|
const eng = engineRef.current, a = active;
|
|
5425
5732
|
if (eng && a && a.callId)
|
|
5426
5733
|
eng.setLocalTrackEnabled(a.callId, "video", v);
|
|
5427
5734
|
}, [active]);
|
|
5428
|
-
return { incoming, active, localStream, remoteStream, sharing, start, accept, reject, hangup, setMuted, setVideoOn, toggleShare };
|
|
5735
|
+
return { incoming, active, localStream, remoteStream, sharing, notice, start, accept, reject, hangup, setMuted, setVideoOn, toggleShare };
|
|
5429
5736
|
}
|
|
5430
5737
|
function VideoSurface({ stream, muted, style }) {
|
|
5431
5738
|
const ref = React.useCallback((el) => {
|
|
@@ -5526,7 +5833,7 @@ ${peer.address}`
|
|
|
5526
5833
|
const [secs, setSecs] = React.useState(0);
|
|
5527
5834
|
const [muted, setMuted] = React.useState(false);
|
|
5528
5835
|
const [featured, setFeatured] = React.useState("remote");
|
|
5529
|
-
const connected = call && call.state === "connected";
|
|
5836
|
+
const connected = call && call.state === "connected" && !call.ended;
|
|
5530
5837
|
React.useEffect(() => {
|
|
5531
5838
|
if (!connected)
|
|
5532
5839
|
return;
|
|
@@ -5547,7 +5854,8 @@ ${peer.address}`
|
|
|
5547
5854
|
const video = call.video || ctl.sharing || streamHasVideo(ctl.remoteStream) || streamHasVideo(ctl.localStream);
|
|
5548
5855
|
const mm = String(Math.floor(secs / 60)).padStart(2, "0");
|
|
5549
5856
|
const ss = String(secs % 60).padStart(2, "0");
|
|
5550
|
-
const stateLabel = connected ? mm + ":" + ss : call.state
|
|
5857
|
+
const stateLabel = connected ? mm + ":" + ss : callStateLabel(call.state, T, name);
|
|
5858
|
+
const noticeText = ctl.notice === "shareFailed" ? T && T.shareFailed || "Screen share failed" : null;
|
|
5551
5859
|
const toggleMute = () => {
|
|
5552
5860
|
const n = !muted;
|
|
5553
5861
|
setMuted(n);
|
|
@@ -5555,7 +5863,7 @@ ${peer.address}`
|
|
|
5555
5863
|
};
|
|
5556
5864
|
const canShare = connected && typeof navigator !== "undefined" && navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia;
|
|
5557
5865
|
const controls = /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: 18, alignItems: "flex-start" } }, /* @__PURE__ */ React.createElement(CallBtn, { icon: muted ? "micFill" : "mic", label: muted ? T && T.unmute || "unmute" : T && T.mute || "mute", active: muted, onClick: toggleMute }), canShare && /* @__PURE__ */ React.createElement(CallBtn, { icon: "monitor", label: ctl.sharing ? T && T.stopShare || "stop share" : T && T.share || "share", active: ctl.sharing, onClick: ctl.toggleShare }), /* @__PURE__ */ React.createElement(CallBtn, { icon: "phone", label: T && T.endCall || "end", danger: true, wide: true, onClick: ctl.hangup }));
|
|
5558
|
-
return /* @__PURE__ */ React.createElement("div", { style: { position: "fixed", inset: 0, zIndex: 70, background: "var(--bg)", display: "flex", flexDirection: "column" } }, ctl.remoteStream && /* @__PURE__ */ React.createElement(AudioSink, { stream: ctl.remoteStream }), /* @__PURE__ */ React.createElement("div", { style: { height: 52, flexShrink: 0, display: "flex", alignItems: "center", gap: 10, padding: "0 18px", borderBottom: "1px solid var(--line)" } }, /* @__PURE__ */ React.createElement(Icon, { name: video ? "video" : "phone", size: 16, color: "var(--accent)", stroke: 2 }), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 13, fontWeight: 700, color: "var(--text)" } }, name), /* @__PURE__ */ React.createElement(Tag, { tone: connected ? "
|
|
5866
|
+
return /* @__PURE__ */ React.createElement("div", { style: { position: "fixed", inset: 0, zIndex: 70, background: "var(--bg)", display: "flex", flexDirection: "column" } }, ctl.remoteStream && /* @__PURE__ */ React.createElement(AudioSink, { stream: ctl.remoteStream }), /* @__PURE__ */ React.createElement("div", { style: { height: 52, flexShrink: 0, display: "flex", alignItems: "center", gap: 10, padding: "0 18px", borderBottom: "1px solid var(--line)" } }, /* @__PURE__ */ React.createElement(Icon, { name: video ? "video" : "phone", size: 16, color: "var(--accent)", stroke: 2 }), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 13, fontWeight: 700, color: "var(--text)" } }, name), /* @__PURE__ */ React.createElement(Tag, { tone: callStateTone(call.ended ? call.state : connected ? "connected" : call.state) }, stateLabel), noticeText && /* @__PURE__ */ React.createElement(Tag, { tone: "danger" }, noticeText), /* @__PURE__ */ React.createElement("div", { style: { flex: 1 } }), connected && /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 14, fontWeight: 700, color: "var(--text)", letterSpacing: 1 } }, mm, ":", ss)), video ? (() => {
|
|
5559
5867
|
const tiles = [
|
|
5560
5868
|
{ key: "remote", stream: ctl.remoteStream, label: name, mirror: false },
|
|
5561
5869
|
{ key: "local", stream: ctl.localStream, label: ctl.sharing ? T && T.yourScreen || "Your screen" : T && T.you || "You", mirror: !ctl.sharing }
|
|
@@ -5605,7 +5913,7 @@ ${peer.address}`
|
|
|
5605
5913
|
/* @__PURE__ */ React.createElement("span", { style: { position: "absolute", left: 6, bottom: 5, padding: "2px 6px", borderRadius: 6, background: "rgba(0,0,0,.6)", color: "#fff", fontSize: 10, fontFamily: "var(--mono)" } }, t.label)
|
|
5606
5914
|
)))))
|
|
5607
5915
|
);
|
|
5608
|
-
})() : /* @__PURE__ */ React.createElement("div", { style: { flex: 1, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 22 } }, /* @__PURE__ */ React.createElement("div", { style: { position: "relative", display: "flex", alignItems: "center", justifyContent: "center" } }, !connected && /* @__PURE__ */ React.createElement("span", { style: { position: "absolute", width: 150, height: 150, borderRadius: 999, border: "2px solid var(--accent)", animation: "dkpulse 2s ease-out infinite" } }), /* @__PURE__ */ React.createElement(DkIdenticon, { seed: call.peerId, size: 108, radius: 26 })), /* @__PURE__ */ React.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--mono)", fontSize: 22, fontWeight: 700, color: "var(--text)" } }, name), /* @__PURE__ */ React.createElement("div", { style: { marginTop: 8, fontFamily: "var(--mono)", fontSize: 12.5, color: "var(--faint)" } }, stateLabel)), /* @__PURE__ */ React.createElement("div", { style: { marginTop: 18 } }, controls)));
|
|
5916
|
+
})() : /* @__PURE__ */ React.createElement("div", { style: { flex: 1, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 22 } }, /* @__PURE__ */ React.createElement("div", { style: { position: "relative", display: "flex", alignItems: "center", justifyContent: "center" } }, !connected && !call.ended && /* @__PURE__ */ React.createElement("span", { style: { position: "absolute", width: 150, height: 150, borderRadius: 999, border: "2px solid var(--accent)", animation: "dkpulse 2s ease-out infinite" } }), /* @__PURE__ */ React.createElement(DkIdenticon, { seed: call.peerId, size: 108, radius: 26 })), /* @__PURE__ */ React.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--mono)", fontSize: 22, fontWeight: 700, color: "var(--text)" } }, name), /* @__PURE__ */ React.createElement("div", { style: { marginTop: 8, fontFamily: "var(--mono)", fontSize: call.ended ? 15 : 12.5, fontWeight: call.ended ? 700 : 400, color: call.ended ? "var(--danger)" : "var(--faint)" } }, stateLabel)), /* @__PURE__ */ React.createElement("div", { style: { marginTop: 18 } }, controls)));
|
|
5609
5917
|
}
|
|
5610
5918
|
Object.assign(window, { useCallController, CallOverlay, IncomingCallModal });
|
|
5611
5919
|
function DkDirAvatar({ p, size }) {
|
|
@@ -6179,7 +6487,7 @@ ${peer.address}`
|
|
|
6179
6487
|
const stuck = n.online && !n.reachable;
|
|
6180
6488
|
const failed = n.status === "failed";
|
|
6181
6489
|
const usable = n.reachable && featureOn !== false;
|
|
6182
|
-
return /* @__PURE__ */ React.createElement("div", { key: n.ip, className: "dk-wrap", style: { display: "flex", alignItems: "center", gap: 12, rowGap: 6, padding: "10px 14px", borderBottom: i < region.nodes.length - 1 ? "1px solid var(--line)" : "none", background: active ? "color-mix(in oklab, var(--accent), transparent 92%)" : "transparent" } }, /* @__PURE__ */ React.createElement(StatusDot, { online: n.reachable }), /* @__PURE__ */ React.createElement(Mono, { size: 13, copy: n.ip }, n.ip), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)" } }, n.host), /* @__PURE__ */ React.createElement("div", { style: { flex: 1 } }), n.reachable ? /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11.5, color: n.ping > 200 ? "var(--warn)" : "var(--dim)" } }, n.ping, "ms") : failed ? /* @__PURE__ */ React.createElement(Tag, { tone: "danger", title: "Failed 3 checks in a row \u2014 no longer checked; Reconnect to try again" }, T.exitFailed || "failed") : n.status === "unknown" ? /* @__PURE__ */ React.createElement(Tag, { tone: "off" }, T.exitNotChecked || "not checked") : stuck ? /* @__PURE__ */ React.createElement(Tag, { tone: "warn", title: "Announces online but IP won't pass \u2014 session desync or NAT-blocked" }, "online \xB7 no route") : n.status === "down" ? /* @__PURE__ */ React.createElement(Tag, { tone: "warn", title: "No answer \u2014 checked again only when you open this panel or press Refresh; 3 in a row and it is no longer checked" }, T.exitDown || "down", " \xB7 ", n.fails, "/3") : /* @__PURE__ */ React.createElement(Tag, { tone: "off" }, "offline"), failed ? /* @__PURE__ */ React.createElement(ReconnectBtn, { T, ip: n.ip, onReconnect }) : active ? /* @__PURE__ */ React.createElement(Btn, { tone: "ok", icon: "check", size: "sm", onClick: () => onSetExit(null) }, T.routing) : /* @__PURE__ */ React.createElement(Btn, { size: "sm", icon: "route", disabled: !usable, onClick: () => usable && onSetExit(n.ip), style: { opacity: usable ? 1 : 0.4 } }, T.routeThru));
|
|
6490
|
+
return /* @__PURE__ */ React.createElement("div", { key: n.ip, className: "dk-wrap", style: { display: "flex", alignItems: "center", gap: 12, rowGap: 6, padding: "10px 14px", borderBottom: i < region.nodes.length - 1 ? "1px solid var(--line)" : "none", background: active ? "color-mix(in oklab, var(--accent), transparent 92%)" : "transparent" } }, /* @__PURE__ */ React.createElement(StatusDot, { online: n.reachable }), /* @__PURE__ */ React.createElement(Mono, { size: 13, copy: n.ip }, n.ip), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11, color: "var(--faint)" } }, n.host), /* @__PURE__ */ React.createElement("div", { style: { flex: 1 } }), n.reachable ? /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11.5, color: n.ping > 200 ? "var(--warn)" : "var(--dim)" } }, n.ping, "ms") : failed ? /* @__PURE__ */ React.createElement(Tag, { tone: "danger", title: "Failed 3 checks in a row \u2014 no longer checked; Reconnect to try again" }, T.exitFailed || "failed") : n.status === "unknown" ? /* @__PURE__ */ React.createElement(Tag, { tone: "off" }, T.exitNotChecked || "not checked") : stuck ? /* @__PURE__ */ React.createElement(Tag, { tone: "warn", title: "Announces online but IP won't pass \u2014 session desync or NAT-blocked" }, "online \xB7 no route") : n.status === "down" ? /* @__PURE__ */ React.createElement(Tag, { tone: "warn", title: "No answer \u2014 checked again only when you open this panel or press Refresh; 3 in a row and it is no longer checked" }, T.exitDown || "down", " \xB7 ", n.fails, "/3") : /* @__PURE__ */ React.createElement(Tag, { tone: "off" }, "offline"), failed && onReconnect ? /* @__PURE__ */ React.createElement(ReconnectBtn, { T, ip: n.ip, onReconnect }) : active ? /* @__PURE__ */ React.createElement(Btn, { tone: "ok", icon: "check", size: "sm", onClick: () => onSetExit(null) }, T.routing) : /* @__PURE__ */ React.createElement(Btn, { size: "sm", icon: "route", disabled: !usable, onClick: () => usable && onSetExit(n.ip), style: { opacity: usable ? 1 : 0.4 } }, T.routeThru));
|
|
6183
6491
|
})));
|
|
6184
6492
|
}
|
|
6185
6493
|
function LanEnableCard({ backend, onArm, onCancel }) {
|
|
@@ -6284,13 +6592,14 @@ ${peer.address}`
|
|
|
6284
6592
|
)));
|
|
6285
6593
|
}
|
|
6286
6594
|
function NetworkTab({ T, me, peers, exits, activeExit, exitFeature, routeFallback, onReconnectExit, onRefreshExits, reqCount, onSetExit, onOpenChat, backend, onArmLan, onCancelLan }) {
|
|
6287
|
-
const
|
|
6288
|
-
const
|
|
6595
|
+
const ctl = exitControls({ exitFeature, routeFallback, exits });
|
|
6596
|
+
const featureOn = !ctl.noExitNotice;
|
|
6597
|
+
const anyFailed = ctl.anyFailed;
|
|
6289
6598
|
if (backend && backend.switchable && !backend.hasVirtualLan) {
|
|
6290
6599
|
return /* @__PURE__ */ React.createElement("div", { style: { flex: 1, overflow: "auto", background: "var(--bg)" } }, /* @__PURE__ */ React.createElement("div", { className: "dk-page", style: { maxWidth: 1040, margin: "0 auto", padding: "24px 28px 60px", display: "flex", flexDirection: "column", gap: 26 } }, /* @__PURE__ */ React.createElement(MyNode, { T, me, activeExit, peers, reqCount }), /* @__PURE__ */ React.createElement(LanEnableCard, { backend, onArm: onArmLan, onCancel: onCancelLan })));
|
|
6291
6600
|
}
|
|
6292
6601
|
const lanless = !!backend && backend.hasVirtualLan === false;
|
|
6293
|
-
return /* @__PURE__ */ React.createElement("div", { style: { flex: 1, overflow: "auto", background: "var(--bg)" } }, /* @__PURE__ */ React.createElement("div", { className: "dk-page", style: { maxWidth: 1040, margin: "0 auto", padding: "24px 28px 60px", display: "flex", flexDirection: "column", gap: 26 } }, /* @__PURE__ */ React.createElement(MyNode, { T, me, activeExit, peers, reqCount }), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 12 } }, /* @__PURE__ */ React.createElement(Section, { label: T.peerRouting, count: peers.length }), /* @__PURE__ */ React.createElement(PeerTable, { T, peers, onOpenChat }), !peers.length && /* @__PURE__ */ React.createElement("div", { style: { padding: "14px 16px", borderRadius: 11, border: "1px dashed var(--line)", fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)" } }, T.noPeersYet || "No friends yet \u2014 add one from Chat and it shows up here with its route.")), lanless ? null : /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 12 } }, /* @__PURE__ */ React.createElement(Section, { label: T.exitNodes, trailing: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: 6 } },
|
|
6602
|
+
return /* @__PURE__ */ React.createElement("div", { style: { flex: 1, overflow: "auto", background: "var(--bg)" } }, /* @__PURE__ */ React.createElement("div", { className: "dk-page", style: { maxWidth: 1040, margin: "0 auto", padding: "24px 28px 60px", display: "flex", flexDirection: "column", gap: 26 } }, /* @__PURE__ */ React.createElement(MyNode, { T, me, activeExit, peers, reqCount }), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 12 } }, /* @__PURE__ */ React.createElement(Section, { label: T.peerRouting, count: peers.length }), /* @__PURE__ */ React.createElement(PeerTable, { T, peers, onOpenChat }), !peers.length && /* @__PURE__ */ React.createElement("div", { style: { padding: "14px 16px", borderRadius: 11, border: "1px dashed var(--line)", fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)" } }, T.noPeersYet || "No friends yet \u2014 add one from Chat and it shows up here with its route.")), lanless ? null : /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 12 } }, /* @__PURE__ */ React.createElement(Section, { label: T.exitNodes, trailing: /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: 6 } }, ctl.refresh && onRefreshExits && /* @__PURE__ */ React.createElement(ReconnectBtn, { T, ip: null, onReconnect: () => onRefreshExits(), label: T.exitRefresh || "Refresh" }), ctl.reconnectAll && onReconnectExit && /* @__PURE__ */ React.createElement(ReconnectBtn, { T, ip: null, onReconnect: onReconnectExit, label: T.exitReconnectAll || "Reconnect all" }), /* @__PURE__ */ React.createElement(Btn, { icon: "plus", size: "sm" }, T.addExit)) }), ctl.noExitNotice && /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 4, padding: "11px 14px", borderRadius: 10, background: "var(--panel-2)", border: "1px dashed var(--line)" } }, /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 12.5, fontWeight: 700, color: "var(--text)" } }, T.noExitAvailable || "No exit available \u2014 routing and proxy are off."), anyFailed && /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--ui)", fontSize: 12, color: "var(--dim)" } }, T.noExitHint || "Every exit failed 3 times and is no longer checked automatically. Press Reconnect to try one again.")), ctl.fallbackNotice && /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 10, padding: "11px 14px", borderRadius: 10, background: "color-mix(in oklab, var(--warn), transparent 90%)", border: "1px solid color-mix(in oklab, var(--warn), transparent 70%)" } }, /* @__PURE__ */ React.createElement(Icon, { name: "route", size: 17, color: "var(--warn)", stroke: 2 }), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 12.5, color: "var(--text)" } }, T.routeFellBack || "Routing fell back to direct: every exit it used failed. Reconnect one to route through it again.")), activeExit && /* @__PURE__ */ React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 10, padding: "11px 14px", borderRadius: 10, background: "color-mix(in oklab, var(--warn), transparent 90%)", border: "1px solid color-mix(in oklab, var(--warn), transparent 70%)" } }, /* @__PURE__ */ React.createElement(Icon, { name: "route", size: 17, color: "var(--warn)", stroke: 2 }), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 12.5, color: "var(--text)" } }, T.egressVia), /* @__PURE__ */ React.createElement(Mono, { size: 13, copy: activeExit }, activeExit), /* @__PURE__ */ React.createElement("div", { style: { flex: 1 } }), /* @__PURE__ */ React.createElement(Btn, { tone: "danger", icon: "unlink", size: "sm", onClick: () => onSetExit(null) }, T.stopRouting)), /* @__PURE__ */ React.createElement("div", { className: "dk-grid1", style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 12 } }, exits.map((r) => /* @__PURE__ */ React.createElement(ExitCard, { key: r.region, T, region: r, activeExit, onSetExit, onReconnect: ctl.reconnect ? onReconnectExit : null, featureOn }))))));
|
|
6294
6603
|
}
|
|
6295
6604
|
Object.assign(window, { NetworkTab });
|
|
6296
6605
|
var dkAudioCtx = null;
|
|
@@ -6809,6 +7118,21 @@ ${peer.address}`
|
|
|
6809
7118
|
audioOnly: "audio",
|
|
6810
7119
|
endCall: "end",
|
|
6811
7120
|
you: "you",
|
|
7121
|
+
calling: "calling\u2026",
|
|
7122
|
+
remoteRinging: "ringing\u2026",
|
|
7123
|
+
connecting: "connecting\u2026",
|
|
7124
|
+
reconnecting: "reconnecting\u2026",
|
|
7125
|
+
noAnswer: "No answer",
|
|
7126
|
+
cantReach: "Can't reach {name}",
|
|
7127
|
+
callFailed: "Call failed",
|
|
7128
|
+
busy: "Busy",
|
|
7129
|
+
declined: "Declined",
|
|
7130
|
+
joinGroup: "Join group",
|
|
7131
|
+
cardIsFriend: "Already in your chats.",
|
|
7132
|
+
cardNoEns: "No beagles.eth name registered.",
|
|
7133
|
+
voiceMessage: "Voice message",
|
|
7134
|
+
groupFileNotDelivered: "Not delivered to this device: the group sends agents only a description of files.",
|
|
7135
|
+
shareFailed: "Screen share failed",
|
|
6812
7136
|
meeting: "Meeting",
|
|
6813
7137
|
meetingRooms: "Meeting rooms",
|
|
6814
7138
|
nextVersion: "next version",
|
|
@@ -7021,6 +7345,21 @@ ${peer.address}`
|
|
|
7021
7345
|
audioOnly: "\u8BED\u97F3",
|
|
7022
7346
|
endCall: "\u6302\u65AD",
|
|
7023
7347
|
you: "\u6211",
|
|
7348
|
+
calling: "\u547C\u53EB\u4E2D\u2026",
|
|
7349
|
+
remoteRinging: "\u5BF9\u65B9\u54CD\u94C3\u4E2D\u2026",
|
|
7350
|
+
connecting: "\u8FDE\u63A5\u4E2D\u2026",
|
|
7351
|
+
reconnecting: "\u91CD\u65B0\u8FDE\u63A5\u4E2D\u2026",
|
|
7352
|
+
noAnswer: "\u65E0\u4EBA\u63A5\u542C",
|
|
7353
|
+
cantReach: "\u65E0\u6CD5\u8054\u7CFB {name}",
|
|
7354
|
+
callFailed: "\u901A\u8BDD\u5931\u8D25",
|
|
7355
|
+
busy: "\u5BF9\u65B9\u5FD9",
|
|
7356
|
+
declined: "\u5BF9\u65B9\u5DF2\u62D2\u7EDD",
|
|
7357
|
+
joinGroup: "\u52A0\u5165\u7FA4",
|
|
7358
|
+
cardIsFriend: "\u5DF2\u5728\u4F60\u7684\u4F1A\u8BDD\u91CC\u3002",
|
|
7359
|
+
cardNoEns: "\u5BF9\u65B9\u8FD8\u6CA1\u6709\u6CE8\u518C beagles.eth \u540D\u5B57\u3002",
|
|
7360
|
+
voiceMessage: "\u8BED\u97F3\u6D88\u606F",
|
|
7361
|
+
groupFileNotDelivered: "\u672A\u9001\u8FBE\u672C\u8BBE\u5907\uFF1A\u7FA4\u7EC4\u53EA\u5411\u4EE3\u7406\u53D1\u9001\u6587\u4EF6\u8BF4\u660E\uFF0C\u4E0D\u542B\u6587\u4EF6\u5185\u5BB9\u3002",
|
|
7362
|
+
shareFailed: "\u5C4F\u5E55\u5171\u4EAB\u5931\u8D25",
|
|
7024
7363
|
meeting: "\u4F1A\u8BAE",
|
|
7025
7364
|
meetingRooms: "\u4F1A\u8BAE\u623F\u95F4",
|
|
7026
7365
|
nextVersion: "\u4E0B\u4E2A\u7248\u672C",
|