@decentnetwork/beagle 0.1.151 → 0.1.154
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 +662 -55
- package/dist/friend-store.d.ts +17 -0
- package/dist/friend-store.js +40 -0
- package/dist/server.js +10 -0
- package/package.json +2 -2
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.154";
|
|
2
2
|
"use strict";
|
|
3
3
|
(() => {
|
|
4
4
|
// packages/beagle-ui/dist/beagle-ui.js
|
|
@@ -2109,6 +2109,10 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2109
2109
|
};
|
|
2110
2110
|
try {
|
|
2111
2111
|
const r = await it.sender(it.file, onProgress);
|
|
2112
|
+
if (r && r.rtcFailed) {
|
|
2113
|
+
it.rtcFailed = true;
|
|
2114
|
+
it.rtcError = r.rtcError ? String(r.rtcError) : null;
|
|
2115
|
+
}
|
|
2112
2116
|
if (r && r.ok === false) {
|
|
2113
2117
|
it.status = "failed";
|
|
2114
2118
|
it.error = r.error && String(r.error) || "send failed";
|
|
@@ -2166,16 +2170,6 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2166
2170
|
}
|
|
2167
2171
|
};
|
|
2168
2172
|
}
|
|
2169
|
-
function failureReport(done, lang) {
|
|
2170
|
-
const failed = (done || []).filter((x) => x.status === "failed");
|
|
2171
|
-
if (!failed.length)
|
|
2172
|
-
return null;
|
|
2173
|
-
const zh = lang === "zh";
|
|
2174
|
-
if (done.length === 1)
|
|
2175
|
-
return (zh ? "\u53D1\u9001\u5931\u8D25: " : "Send failed: ") + (failed[0].error || "");
|
|
2176
|
-
const head = zh ? `${done.length} \u4E2A\u6587\u4EF6\u4E2D\u6709 ${failed.length} \u4E2A\u6CA1\u6709\u53D1\u9001:` : `${failed.length} of ${done.length} files did not send:`;
|
|
2177
|
-
return head + "\n\n" + failed.map((x) => `\u2022 ${x.name} \u2014 ${x.error || (zh ? "\u53D1\u9001\u5931\u8D25" : "send failed")}`).join("\n");
|
|
2178
|
-
}
|
|
2179
2173
|
function successFlash(done, lang) {
|
|
2180
2174
|
const n = (done || []).length;
|
|
2181
2175
|
const zh = lang === "zh";
|
|
@@ -2184,9 +2178,301 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2184
2178
|
return rtc ? zh ? "WebRTC \u6587\u4EF6\u53D1\u9001\u5B8C\u6210" : "WebRTC file sent" : zh ? "\u6587\u4EF6\u5DF2\u63D0\u4EA4\u53D1\u9001" : "File send started";
|
|
2185
2179
|
return rtc ? zh ? `\u5DF2\u901A\u8FC7 WebRTC \u53D1\u9001 ${n} \u4E2A\u6587\u4EF6` : `${n} files sent via WebRTC` : zh ? `\u5DF2\u63D0\u4EA4\u53D1\u9001 ${n} \u4E2A\u6587\u4EF6` : `${n} file sends started`;
|
|
2186
2180
|
}
|
|
2181
|
+
function keptResults(done) {
|
|
2182
|
+
return (done || []).filter((x) => x.status === "failed" || x.rtcFailed);
|
|
2183
|
+
}
|
|
2184
|
+
function resultLabel(it, lang) {
|
|
2185
|
+
const zh = lang === "zh";
|
|
2186
|
+
const name = (it.via === "webrtc" ? "WebRTC \xB7 " : "") + (it.name || "file");
|
|
2187
|
+
if (it.status === "failed") {
|
|
2188
|
+
const why = it.error || (zh ? "\u53D1\u9001\u5931\u8D25" : "send failed");
|
|
2189
|
+
if (it.rtcFailed)
|
|
2190
|
+
return name + (zh ? " \xB7 \u5931\u8D25(WebRTC \u4E0E Carrier \u5747\u672A\u6210\u529F): " : " \xB7 failed (WebRTC, then Carrier): ") + why;
|
|
2191
|
+
return name + (zh ? " \xB7 \u5931\u8D25: " : " \xB7 failed: ") + why;
|
|
2192
|
+
}
|
|
2193
|
+
return name + (zh ? " \xB7 WebRTC \u5931\u8D25 \u2014 \u5DF2\u901A\u8FC7 Carrier \u53D1\u9001" : " \xB7 WebRTC failed \u2014 sent via Carrier");
|
|
2194
|
+
}
|
|
2195
|
+
function finishFlash(done, lang) {
|
|
2196
|
+
const zh = lang === "zh";
|
|
2197
|
+
const failed = (done || []).filter((x) => x.status === "failed").length;
|
|
2198
|
+
if (failed) {
|
|
2199
|
+
const n = (done || []).length;
|
|
2200
|
+
return ["err", n === 1 ? zh ? "\u53D1\u9001\u5931\u8D25,\u89C1\u4E0B\u65B9" : "Send failed \u2014 see below" : zh ? `${n} \u4E2A\u6587\u4EF6\u4E2D\u6709 ${failed} \u4E2A\u6CA1\u6709\u53D1\u9001,\u89C1\u4E0B\u65B9` : `${failed} of ${n} files did not send \u2014 see below`];
|
|
2201
|
+
}
|
|
2202
|
+
if ((done || []).some((x) => x.rtcFailed))
|
|
2203
|
+
return ["ok", zh ? "WebRTC \u5931\u8D25,\u5DF2\u901A\u8FC7 Carrier \u53D1\u9001" : "WebRTC failed \u2014 sent via Carrier"];
|
|
2204
|
+
return ["ok", successFlash(done, lang)];
|
|
2205
|
+
}
|
|
2206
|
+
var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
2207
|
+
var DROP = /* @__PURE__ */ new Set(["script", "style", "head", "title", "template", "noscript", "svg", "math", "iframe", "object", "canvas", "video", "audio", "select", "button", "textarea"]);
|
|
2208
|
+
var PARA = /* @__PURE__ */ new Set(["p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "pre", "blockquote", "table", "hr", "figure", "section", "article", "header", "footer", "main", "aside", "nav", "dl"]);
|
|
2209
|
+
var LINE = /* @__PURE__ */ new Set(["div", "li", "tr", "dt", "dd", "figcaption", "address", "details", "summary", "caption"]);
|
|
2210
|
+
var SEMANTIC = /<(h[1-6]|b|strong|i|em|a\s|ul|ol|li|code|pre|table|blockquote)\b|font-weight:\s*(bold|[6-9]00)|font-style:\s*italic/i;
|
|
2211
|
+
var ENT = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " ", ensp: " ", emsp: " ", thinsp: " ", hellip: "\u2026", mdash: "\u2014", ndash: "\u2013", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", middot: "\xB7", copy: "\xA9", reg: "\xAE", trade: "\u2122", times: "\xD7" };
|
|
2212
|
+
function decodeEntities(s) {
|
|
2213
|
+
return String(s).replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (m, e) => {
|
|
2214
|
+
if (e[0] === "#") {
|
|
2215
|
+
const n = e[1] === "x" || e[1] === "X" ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
|
|
2216
|
+
try {
|
|
2217
|
+
return n > 0 && n < 1114112 ? String.fromCodePoint(n) : m;
|
|
2218
|
+
} catch (x) {
|
|
2219
|
+
return m;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
const v = ENT[e.toLowerCase()];
|
|
2223
|
+
return v != null ? v : m;
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
function attrsOf(src) {
|
|
2227
|
+
const out = {};
|
|
2228
|
+
const re = /([^\s=/>]+)(?:\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
|
|
2229
|
+
let m;
|
|
2230
|
+
while (m = re.exec(src))
|
|
2231
|
+
out[m[1].toLowerCase()] = decodeEntities(m[3] != null ? m[3] : m[4] != null ? m[4] : m[5] != null ? m[5] : "");
|
|
2232
|
+
return out;
|
|
2233
|
+
}
|
|
2234
|
+
function parseHtml(html) {
|
|
2235
|
+
const root = { tag: "#root", attrs: {}, children: [] };
|
|
2236
|
+
const stack = [root];
|
|
2237
|
+
const top = () => stack[stack.length - 1];
|
|
2238
|
+
const src = String(html || "");
|
|
2239
|
+
const re = /<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?\]\]>|<![^>]*>|<\?[^>]*>|<\/\s*([a-zA-Z][\w:-]*)\s*>|<([a-zA-Z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
2240
|
+
let last = 0;
|
|
2241
|
+
let m;
|
|
2242
|
+
const text = (s) => {
|
|
2243
|
+
if (s)
|
|
2244
|
+
top().children.push({ text: decodeEntities(s) });
|
|
2245
|
+
};
|
|
2246
|
+
const closeTo = (tag) => {
|
|
2247
|
+
for (let i = stack.length - 1; i > 0; i--) {
|
|
2248
|
+
if (stack[i].tag === tag) {
|
|
2249
|
+
stack.length = i;
|
|
2250
|
+
return true;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
return false;
|
|
2254
|
+
};
|
|
2255
|
+
while (m = re.exec(src)) {
|
|
2256
|
+
text(src.slice(last, m.index));
|
|
2257
|
+
last = re.lastIndex;
|
|
2258
|
+
if (m[1]) {
|
|
2259
|
+
closeTo(m[1].toLowerCase());
|
|
2260
|
+
continue;
|
|
2261
|
+
}
|
|
2262
|
+
if (!m[2])
|
|
2263
|
+
continue;
|
|
2264
|
+
const tag = m[2].toLowerCase();
|
|
2265
|
+
const raw = m[3] || "";
|
|
2266
|
+
if (DROP.has(tag) && !/\/\s*$/.test(raw)) {
|
|
2267
|
+
const end = new RegExp("</\\s*" + tag + "\\s*>", "ig");
|
|
2268
|
+
end.lastIndex = last;
|
|
2269
|
+
const e = end.exec(src);
|
|
2270
|
+
last = re.lastIndex = e ? end.lastIndex : src.length;
|
|
2271
|
+
continue;
|
|
2272
|
+
}
|
|
2273
|
+
if (PARA.has(tag) || tag === "li" || LINE.has(tag)) {
|
|
2274
|
+
if (top().tag === "p")
|
|
2275
|
+
stack.pop();
|
|
2276
|
+
}
|
|
2277
|
+
if (tag === "li") {
|
|
2278
|
+
for (let i = stack.length - 1; i > 0; i--) {
|
|
2279
|
+
if (stack[i].tag === "ul" || stack[i].tag === "ol")
|
|
2280
|
+
break;
|
|
2281
|
+
if (stack[i].tag === "li") {
|
|
2282
|
+
stack.length = i;
|
|
2283
|
+
break;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
const node = { tag, attrs: attrsOf(raw), children: [] };
|
|
2288
|
+
top().children.push(node);
|
|
2289
|
+
if (!VOID.has(tag) && !/\/\s*$/.test(raw))
|
|
2290
|
+
stack.push(node);
|
|
2291
|
+
}
|
|
2292
|
+
text(src.slice(last));
|
|
2293
|
+
return root;
|
|
2294
|
+
}
|
|
2295
|
+
var styleOf = (n) => String(n.attrs && n.attrs.style || "").toLowerCase();
|
|
2296
|
+
var isBoldStyle = (s) => /font-weight:\s*(bold|bolder|[6-9]00)\b/.test(s);
|
|
2297
|
+
var isPlainWeight = (s) => /font-weight:\s*(normal|[1-4]00)\b/.test(s);
|
|
2298
|
+
function safeHref(h) {
|
|
2299
|
+
const v = String(h || "").trim();
|
|
2300
|
+
return /^(https?:|mailto:)/i.test(v) ? v : "";
|
|
2301
|
+
}
|
|
2302
|
+
function wrap(s, mark) {
|
|
2303
|
+
const mm = /^(\s*)([\s\S]*?)(\s*)$/.exec(s);
|
|
2304
|
+
if (!mm[2])
|
|
2305
|
+
return s;
|
|
2306
|
+
return mm[1] + mm[2].split("\n").map((l) => l.trim() ? mark + l.trim() + mark : l).join("\n") + mm[3];
|
|
2307
|
+
}
|
|
2308
|
+
function inline(n, ctx) {
|
|
2309
|
+
if (n.text != null)
|
|
2310
|
+
return ctx.pre ? n.text : n.text.replace(/[ \t\r\n\f ]+/g, " ");
|
|
2311
|
+
const tag = n.tag;
|
|
2312
|
+
if (tag === "br")
|
|
2313
|
+
return "\n";
|
|
2314
|
+
if (tag === "img" || VOID.has(tag))
|
|
2315
|
+
return "";
|
|
2316
|
+
const st = styleOf(n);
|
|
2317
|
+
let bold = tag === "b" || tag === "strong" || isBoldStyle(st);
|
|
2318
|
+
if ((tag === "b" || tag === "strong") && isPlainWeight(st))
|
|
2319
|
+
bold = false;
|
|
2320
|
+
const italic = tag === "i" || tag === "em" || /font-style:\s*italic/.test(st);
|
|
2321
|
+
if (tag === "code" && !ctx.pre) {
|
|
2322
|
+
const t = n.children.map((c) => inline(c, { ...ctx, code: true })).join("");
|
|
2323
|
+
return t.trim() ? "`" + t.replace(/`/g, "'").replace(/\n/g, " ") + "`" : t;
|
|
2324
|
+
}
|
|
2325
|
+
const inner = n.children.map((c) => inline(c, { ...ctx, bold: ctx.bold || bold, italic: ctx.italic || italic })).join("");
|
|
2326
|
+
if (tag === "a") {
|
|
2327
|
+
const href = safeHref(n.attrs.href);
|
|
2328
|
+
const label = inner.replace(/\s+/g, " ").trim();
|
|
2329
|
+
if (!href)
|
|
2330
|
+
return inner;
|
|
2331
|
+
if (!label || label === href || label === href.replace(/^mailto:/i, ""))
|
|
2332
|
+
return " " + href + " ";
|
|
2333
|
+
return "[" + label.replace(/[[\]]/g, "") + "](" + href.replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\s/g, "%20") + ")";
|
|
2334
|
+
}
|
|
2335
|
+
let out = inner;
|
|
2336
|
+
if (bold && !ctx.bold && !ctx.code)
|
|
2337
|
+
out = wrap(out, "**");
|
|
2338
|
+
if (italic && !ctx.italic && !ctx.code && !(bold && !ctx.bold))
|
|
2339
|
+
out = wrap(out, "*");
|
|
2340
|
+
return out;
|
|
2341
|
+
}
|
|
2342
|
+
function rawText(n) {
|
|
2343
|
+
if (n.text != null)
|
|
2344
|
+
return n.text;
|
|
2345
|
+
if (n.tag === "br")
|
|
2346
|
+
return "\n";
|
|
2347
|
+
return n.children.map(rawText).join("");
|
|
2348
|
+
}
|
|
2349
|
+
function hasBlock(n) {
|
|
2350
|
+
return (n.children || []).some((c) => c.text == null && (PARA.has(c.tag) || LINE.has(c.tag) || hasBlock(c)));
|
|
2351
|
+
}
|
|
2352
|
+
function blocks(n, ctx, out) {
|
|
2353
|
+
let buf = "";
|
|
2354
|
+
const flush = (gap) => {
|
|
2355
|
+
const t = buf.split("\n").map((l) => l.replace(/[ \t]+/g, " ").trim()).join("\n").replace(/^\n+|\n+$/g, "");
|
|
2356
|
+
if (t)
|
|
2357
|
+
out.push({ text: (ctx.prefix || "") + t.split("\n").join("\n" + (ctx.cont || ctx.prefix || "")), gap });
|
|
2358
|
+
buf = "";
|
|
2359
|
+
};
|
|
2360
|
+
for (const c of n.children) {
|
|
2361
|
+
if (c.text == null && !(PARA.has(c.tag) || LINE.has(c.tag)) && hasBlock(c)) {
|
|
2362
|
+
flush(out.length ? 1 : 0);
|
|
2363
|
+
blocks(c, ctx, out);
|
|
2364
|
+
continue;
|
|
2365
|
+
}
|
|
2366
|
+
if (c.text != null || !(PARA.has(c.tag) || LINE.has(c.tag))) {
|
|
2367
|
+
buf += inline(c, ctx);
|
|
2368
|
+
continue;
|
|
2369
|
+
}
|
|
2370
|
+
flush(out.length ? 1 : 0);
|
|
2371
|
+
const tag = c.tag;
|
|
2372
|
+
const h = /^h([1-6])$/.exec(tag);
|
|
2373
|
+
if (h) {
|
|
2374
|
+
const t = c.children.map((x) => inline(x, { ...ctx, bold: true })).join("").replace(/\s+/g, " ").trim();
|
|
2375
|
+
if (t)
|
|
2376
|
+
out.push({ text: "#".repeat(Number(h[1])) + " " + t, gap: 2 });
|
|
2377
|
+
} else if (tag === "pre") {
|
|
2378
|
+
const code = rawText(c).replace(/\n+$/, "");
|
|
2379
|
+
if (code.trim())
|
|
2380
|
+
out.push({ text: "```\n" + code + "\n```", gap: 2 });
|
|
2381
|
+
} else if (tag === "hr") {
|
|
2382
|
+
} else if (tag === "ul" || tag === "ol") {
|
|
2383
|
+
listLines(c, 0, ctx).forEach((t, i) => out.push({ text: t, gap: i === 0 ? 2 : 1 }));
|
|
2384
|
+
} else if (tag === "blockquote") {
|
|
2385
|
+
const sub = [];
|
|
2386
|
+
blocks(c, { ...ctx, prefix: "", cont: "" }, sub);
|
|
2387
|
+
const t = joinBlocks(sub);
|
|
2388
|
+
if (t)
|
|
2389
|
+
out.push({ text: t.split("\n").map((l) => "> " + l).join("\n"), gap: 2 });
|
|
2390
|
+
} else if (tag === "table") {
|
|
2391
|
+
const rows = [];
|
|
2392
|
+
const walk = (x) => {
|
|
2393
|
+
for (const y of x.children || []) {
|
|
2394
|
+
if (y.tag === "tr")
|
|
2395
|
+
rows.push(y);
|
|
2396
|
+
else if (y.children)
|
|
2397
|
+
walk(y);
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2400
|
+
walk(c);
|
|
2401
|
+
const lines = rows.map((r) => r.children.filter((d) => d.tag === "td" || d.tag === "th").map((d) => d.children.map((x) => inline(x, ctx)).join("").replace(/\s+/g, " ").trim()).join(" | ")).filter(Boolean);
|
|
2402
|
+
if (lines.length)
|
|
2403
|
+
out.push({ text: lines.join("\n"), gap: 2 });
|
|
2404
|
+
} else {
|
|
2405
|
+
const sub = [];
|
|
2406
|
+
blocks(c, ctx, sub);
|
|
2407
|
+
const gap = PARA.has(tag) ? 2 : 1;
|
|
2408
|
+
sub.forEach((s, i) => out.push({ text: s.text, gap: i === 0 ? gap : s.gap }));
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
flush(out.length ? 1 : 0);
|
|
2412
|
+
return out;
|
|
2413
|
+
}
|
|
2414
|
+
function listLines(list, depth, ctx) {
|
|
2415
|
+
const lines = [];
|
|
2416
|
+
let k = Number(list.attrs && list.attrs.start) || 1;
|
|
2417
|
+
const isList = (x) => x.tag === "ul" || x.tag === "ol";
|
|
2418
|
+
for (const li of list.children) {
|
|
2419
|
+
if (isList(li)) {
|
|
2420
|
+
lines.push(...listLines(li, depth + 1, ctx));
|
|
2421
|
+
continue;
|
|
2422
|
+
}
|
|
2423
|
+
if (li.tag !== "li")
|
|
2424
|
+
continue;
|
|
2425
|
+
const own = { tag: "li", attrs: {}, children: li.children.filter((x) => !isList(x)) };
|
|
2426
|
+
const text = joinBlocks(blocks(own, ctx, [])).replace(/\s*\n\s*/g, " ").trim();
|
|
2427
|
+
lines.push(" ".repeat(depth) + (list.tag === "ol" ? k++ + ". " : "- ") + text);
|
|
2428
|
+
for (const sub of li.children)
|
|
2429
|
+
if (isList(sub))
|
|
2430
|
+
lines.push(...listLines(sub, depth + 1, ctx));
|
|
2431
|
+
}
|
|
2432
|
+
return lines;
|
|
2433
|
+
}
|
|
2434
|
+
function joinBlocks(list) {
|
|
2435
|
+
let s = "";
|
|
2436
|
+
for (const b of list) {
|
|
2437
|
+
if (!b.text)
|
|
2438
|
+
continue;
|
|
2439
|
+
s += s ? (b.gap >= 2 ? "\n\n" : "\n") + b.text : b.text;
|
|
2440
|
+
}
|
|
2441
|
+
return s;
|
|
2442
|
+
}
|
|
2443
|
+
function hasFormatting(html) {
|
|
2444
|
+
return SEMANTIC.test(String(html || ""));
|
|
2445
|
+
}
|
|
2446
|
+
function htmlToMarkdown(html) {
|
|
2447
|
+
let src = String(html || "");
|
|
2448
|
+
const fs = src.indexOf("<!--StartFragment-->");
|
|
2449
|
+
const fe = src.indexOf("<!--EndFragment-->");
|
|
2450
|
+
if (fs >= 0 && fe > fs)
|
|
2451
|
+
src = src.slice(fs + 20, fe);
|
|
2452
|
+
const tree = parseHtml(src);
|
|
2453
|
+
const md = joinBlocks(blocks(tree, {}, [])).replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").replace(/\*\*\*\*/g, "").trim();
|
|
2454
|
+
return md;
|
|
2455
|
+
}
|
|
2456
|
+
function pasteText(html, plain) {
|
|
2457
|
+
if (!html || !hasFormatting(html))
|
|
2458
|
+
return null;
|
|
2459
|
+
const md = htmlToMarkdown(html);
|
|
2460
|
+
if (!md)
|
|
2461
|
+
return null;
|
|
2462
|
+
return md;
|
|
2463
|
+
}
|
|
2464
|
+
function pastedFileName(file, i = 0, now = /* @__PURE__ */ new Date()) {
|
|
2465
|
+
const ext = (/\/(png|jpe?g|gif|webp|bmp|heic|avif)$/i.exec(file && file.type || "") || [])[1] || "png";
|
|
2466
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
2467
|
+
const stamp = now.getFullYear() + p(now.getMonth() + 1) + p(now.getDate()) + "-" + p(now.getHours()) + p(now.getMinutes()) + p(now.getSeconds());
|
|
2468
|
+
const generic = !file || !file.name || /^image\.(png|jpe?g|gif|webp|bmp)$/i.test(file.name);
|
|
2469
|
+
if (!generic)
|
|
2470
|
+
return file.name;
|
|
2471
|
+
return "pasted-" + stamp + (i ? "-" + (i + 1) : "") + "." + ext.toLowerCase().replace("jpeg", "jpg");
|
|
2472
|
+
}
|
|
2187
2473
|
var PROOF_KEY = { eth: "proof.eth", sol: "proof.sol" };
|
|
2188
2474
|
var HEAD = "Beagle wallet binding";
|
|
2189
|
-
var
|
|
2475
|
+
var LINE2 = "I bind this wallet to my Beagle identity.";
|
|
2190
2476
|
var ADDRESS_RE = { eth: /^0x[0-9a-fA-F]{40}$/, sol: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/ };
|
|
2191
2477
|
var USERID_RE = /^[1-9A-HJ-NP-Za-km-z]{32,48}$/;
|
|
2192
2478
|
var ISSUED_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
|
|
@@ -2204,7 +2490,7 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
2204
2490
|
throw new Error("wallet proof: bad chain or address");
|
|
2205
2491
|
if (!ISSUED_RE.test(String(issued || "")))
|
|
2206
2492
|
throw new Error("wallet proof: bad issued time");
|
|
2207
|
-
return [HEAD, "",
|
|
2493
|
+
return [HEAD, "", LINE2, "", `userid: ${userid}`, `chain: ${chain}`, `address: ${address}`, `issued: ${issued}`].join("\n");
|
|
2208
2494
|
}
|
|
2209
2495
|
var B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2210
2496
|
function base58Encode(bytes) {
|
|
@@ -3814,6 +4100,8 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
3814
4100
|
const rtcFile = !mine && !m.file ? dkRtcFileFromText(peer.userId || peer.id, m.text) : null;
|
|
3815
4101
|
const callRec = !m.file ? dkCallFromText(m.text) : null;
|
|
3816
4102
|
const mentionsMe = isGroup && !mine && !m.file && typeof m.text === "string" && messageMentionsMe(m.text, mentionNames());
|
|
4103
|
+
const copyText = !m.file && !nativeMedia && !rtcFile && !callRec && typeof read.text === "string" && read.text.trim() ? read.text : "";
|
|
4104
|
+
const [copied, setCopied] = React.useState(false);
|
|
3817
4105
|
return /* @__PURE__ */ React.createElement(
|
|
3818
4106
|
"div",
|
|
3819
4107
|
{
|
|
@@ -4180,7 +4468,24 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
4180
4468
|
return null;
|
|
4181
4469
|
const title = mine ? via === "offline" ? T.viaOutOffline || "posted to the offline relay \u2014 they get it when they come online" : T.viaOutOnline || "sent over a live session (online)" : via === "offline" ? "delivered via express relay (offline)" : "delivered over a live session (online)";
|
|
4182
4470
|
return /* @__PURE__ */ React.createElement("span", { title, style: { fontFamily: "var(--mono)", fontSize: 9, color: via === "offline" ? "#f59e0b" : "var(--faint)" } }, via === "offline" ? "\u79BB\u7EBF" : "\u5728\u7EBF");
|
|
4183
|
-
})(), !selMode &&
|
|
4471
|
+
})(), !selMode && copyText && /* @__PURE__ */ React.createElement(
|
|
4472
|
+
"button",
|
|
4473
|
+
{
|
|
4474
|
+
"data-testid": "msg-copy",
|
|
4475
|
+
title: copied ? T.copied || "copied" : T.copyMarkdown || "copy (Markdown)",
|
|
4476
|
+
onClick: (e) => {
|
|
4477
|
+
e.stopPropagation();
|
|
4478
|
+
dkCopy(copyText).then((ok) => {
|
|
4479
|
+
if (ok !== false) {
|
|
4480
|
+
setCopied(true);
|
|
4481
|
+
setTimeout(() => setCopied(false), 1200);
|
|
4482
|
+
}
|
|
4483
|
+
});
|
|
4484
|
+
},
|
|
4485
|
+
style: { background: "none", border: "none", cursor: "pointer", padding: 0, marginLeft: 2, display: "inline-flex", opacity: copied ? 1 : 0.55 }
|
|
4486
|
+
},
|
|
4487
|
+
/* @__PURE__ */ React.createElement(Icon, { name: copied ? "check" : "copy", size: 11, stroke: 2, color: copied ? "var(--accent)" : "var(--faint)" })
|
|
4488
|
+
), !selMode && m.id && /* @__PURE__ */ React.createElement(
|
|
4184
4489
|
"button",
|
|
4185
4490
|
{
|
|
4186
4491
|
title: T.delete || "delete",
|
|
@@ -4539,10 +4844,93 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
4539
4844
|
};
|
|
4540
4845
|
const [dragOver, setDragOver] = React.useState(false);
|
|
4541
4846
|
const [sending, setSending] = React.useState(null);
|
|
4847
|
+
const [sendResults, setSendResults] = React.useState([]);
|
|
4542
4848
|
const [theater, setTheater] = React.useState(null);
|
|
4543
4849
|
React.useEffect(() => {
|
|
4544
4850
|
setDraft("");
|
|
4545
4851
|
}, [peer.id]);
|
|
4852
|
+
React.useLayoutEffect(() => {
|
|
4853
|
+
const el = inputRef.current;
|
|
4854
|
+
if (!el)
|
|
4855
|
+
return;
|
|
4856
|
+
el.style.height = "auto";
|
|
4857
|
+
el.style.height = Math.min(el.scrollHeight + 2, 180) + "px";
|
|
4858
|
+
}, [draft]);
|
|
4859
|
+
const [pending, setPending] = React.useState([]);
|
|
4860
|
+
const pendingRef = React.useRef(pending);
|
|
4861
|
+
pendingRef.current = pending;
|
|
4862
|
+
const dropPending = (keep) => setPending((arr) => {
|
|
4863
|
+
arr.forEach((p) => {
|
|
4864
|
+
if (p.url && !(keep && keep.includes(p)))
|
|
4865
|
+
URL.revokeObjectURL(p.url);
|
|
4866
|
+
});
|
|
4867
|
+
return keep || [];
|
|
4868
|
+
});
|
|
4869
|
+
React.useEffect(() => () => pendingRef.current.forEach((p) => p.url && URL.revokeObjectURL(p.url)), []);
|
|
4870
|
+
React.useEffect(() => {
|
|
4871
|
+
dropPending();
|
|
4872
|
+
}, [peer.id]);
|
|
4873
|
+
const addPending = (files, pasted) => {
|
|
4874
|
+
const list = Array.from(files || []).filter(Boolean);
|
|
4875
|
+
if (!list.length || peer.app)
|
|
4876
|
+
return;
|
|
4877
|
+
const items = list.map((f, i) => {
|
|
4878
|
+
const file = pasted ? new File([f], pastedFileName(f, i), { type: f.type || "image/png" }) : f;
|
|
4879
|
+
const image = /^image\//.test(file.type || "");
|
|
4880
|
+
return { id: Math.random().toString(36).slice(2), file, image, url: image ? URL.createObjectURL(file) : null };
|
|
4881
|
+
});
|
|
4882
|
+
setPending((arr) => arr.concat(items).slice(0, 20));
|
|
4883
|
+
};
|
|
4884
|
+
const removePending = (id) => {
|
|
4885
|
+
dropPending(pendingRef.current.filter((p) => p.id !== id));
|
|
4886
|
+
requestAnimationFrame(() => inputRef.current && inputRef.current.focus());
|
|
4887
|
+
};
|
|
4888
|
+
const insertAtCaret = (text) => {
|
|
4889
|
+
const el = inputRef.current;
|
|
4890
|
+
const a = el ? el.selectionStart : draft.length;
|
|
4891
|
+
const b = el ? el.selectionEnd : draft.length;
|
|
4892
|
+
const next = draft.slice(0, a) + text + draft.slice(b);
|
|
4893
|
+
setDraft(next);
|
|
4894
|
+
histIdx.current = null;
|
|
4895
|
+
const caret = a + text.length;
|
|
4896
|
+
requestAnimationFrame(() => {
|
|
4897
|
+
const e2 = inputRef.current;
|
|
4898
|
+
if (e2) {
|
|
4899
|
+
e2.focus();
|
|
4900
|
+
try {
|
|
4901
|
+
e2.setSelectionRange(caret, caret);
|
|
4902
|
+
} catch (x) {
|
|
4903
|
+
}
|
|
4904
|
+
}
|
|
4905
|
+
});
|
|
4906
|
+
};
|
|
4907
|
+
const onPaste = (e) => {
|
|
4908
|
+
const cd = e.clipboardData;
|
|
4909
|
+
if (!cd)
|
|
4910
|
+
return;
|
|
4911
|
+
const files = [];
|
|
4912
|
+
for (const it of Array.from(cd.items || [])) {
|
|
4913
|
+
if (it.kind === "file") {
|
|
4914
|
+
const f = it.getAsFile();
|
|
4915
|
+
if (f)
|
|
4916
|
+
files.push(f);
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
if (!files.length && cd.files && cd.files.length)
|
|
4920
|
+
files.push(...Array.from(cd.files));
|
|
4921
|
+
const md = pasteText(cd.getData("text/html"), cd.getData("text/plain"));
|
|
4922
|
+
if (files.length && !peer.app) {
|
|
4923
|
+
e.preventDefault();
|
|
4924
|
+
addPending(files, true);
|
|
4925
|
+
if (md)
|
|
4926
|
+
insertAtCaret(md);
|
|
4927
|
+
return;
|
|
4928
|
+
}
|
|
4929
|
+
if (md) {
|
|
4930
|
+
e.preventDefault();
|
|
4931
|
+
insertAtCaret(md);
|
|
4932
|
+
}
|
|
4933
|
+
};
|
|
4546
4934
|
React.useEffect(() => {
|
|
4547
4935
|
setTheater(null);
|
|
4548
4936
|
}, [peer.id]);
|
|
@@ -4557,6 +4945,11 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
4557
4945
|
return () => window.removeEventListener("keydown", onKey);
|
|
4558
4946
|
}, [theater]);
|
|
4559
4947
|
const sendDraft = () => {
|
|
4948
|
+
if (pending.length) {
|
|
4949
|
+
followScrollRef.current = true;
|
|
4950
|
+
sendFiles(pending.map((p) => p.file));
|
|
4951
|
+
dropPending();
|
|
4952
|
+
}
|
|
4560
4953
|
if (draft.trim()) {
|
|
4561
4954
|
followScrollRef.current = true;
|
|
4562
4955
|
rememberCommand(draft.trim());
|
|
@@ -4567,11 +4960,11 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
4567
4960
|
};
|
|
4568
4961
|
const finishRef = React.useRef(null);
|
|
4569
4962
|
finishRef.current = (done) => {
|
|
4570
|
-
const
|
|
4571
|
-
if (
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4963
|
+
const kept = keptResults(done);
|
|
4964
|
+
if (kept.length)
|
|
4965
|
+
setSendResults((prev) => prev.concat(kept).slice(-20));
|
|
4966
|
+
const [kind, msg] = finishFlash(done, lang);
|
|
4967
|
+
showFlash(kind, msg);
|
|
4575
4968
|
requestAnimationFrame(scrollToBottom);
|
|
4576
4969
|
};
|
|
4577
4970
|
const queueRef = React.useRef(null);
|
|
@@ -4589,10 +4982,13 @@ ${lines}`, { assistant: { kind: "adopt", rows: fresh } }));
|
|
|
4589
4982
|
queueRef.current.add(files, sender, { via: mode, peerId: peer.id });
|
|
4590
4983
|
};
|
|
4591
4984
|
const mySending = sending ? sending.filter((s) => s.peerId === peer.id) : [];
|
|
4985
|
+
const myResults = sendResults.filter((s) => s.peerId === peer.id);
|
|
4986
|
+
const dismissResults = () => setSendResults((prev) => prev.filter((s) => s.peerId !== peer.id));
|
|
4592
4987
|
const onDrop = (e) => {
|
|
4593
4988
|
e.preventDefault();
|
|
4594
4989
|
setDragOver(false);
|
|
4595
|
-
|
|
4990
|
+
addPending(e.dataTransfer.files, false);
|
|
4991
|
+
requestAnimationFrame(() => inputRef.current && inputRef.current.focus());
|
|
4596
4992
|
};
|
|
4597
4993
|
return /* @__PURE__ */ React.createElement(
|
|
4598
4994
|
"div",
|
|
@@ -4750,7 +5146,7 @@ ${peer.address}`
|
|
|
4750
5146
|
stroke: 2.2,
|
|
4751
5147
|
color: flash.kind === "err" ? "var(--danger)" : "var(--accent)"
|
|
4752
5148
|
}
|
|
4753
|
-
), flash.msg), mySending.length > 0 && /* @__PURE__ */ React.createElement("div", { "data-testid": "file-send-queue", style: { maxWidth: 1200, margin: "0 auto 8px", display: "flex", flexDirection: "column", gap: 3, fontFamily: "var(--mono)", fontSize: 11.5, color: "var(--faint)", maxHeight: 132, overflowY: "auto" } }, mySending.length > 1 && /* @__PURE__ */ React.createElement("div", { style: { color: "var(--dim)" } }, (lang === "zh" ? "\u53D1\u9001 " : "Sending ") + mySending.filter((s) => s.status === "sent" || s.status === "failed").length + " / " + mySending.length + (lang === "zh" ? " \u4E2A\u6587\u4EF6" : " files")), mySending.map((s) => /* @__PURE__ */ React.createElement("div", { key: s.id, "data-status": s.status, style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0, color: s.status === "failed" ? "var(--danger)" : void 0 } }, /* @__PURE__ */ React.createElement(
|
|
5149
|
+
), flash.msg), (mySending.length > 0 || myResults.length > 0) && /* @__PURE__ */ React.createElement("div", { "data-testid": "file-send-queue", style: { maxWidth: 1200, margin: "0 auto 8px", display: "flex", flexDirection: "column", gap: 3, fontFamily: "var(--mono)", fontSize: 11.5, color: "var(--faint)", maxHeight: 132, overflowY: "auto" } }, mySending.length > 1 && /* @__PURE__ */ React.createElement("div", { style: { color: "var(--dim)" } }, (lang === "zh" ? "\u53D1\u9001 " : "Sending ") + mySending.filter((s) => s.status === "sent" || s.status === "failed").length + " / " + mySending.length + (lang === "zh" ? " \u4E2A\u6587\u4EF6" : " files")), mySending.map((s) => /* @__PURE__ */ React.createElement("div", { key: s.id, "data-status": s.status, style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0, color: s.status === "failed" ? "var(--danger)" : void 0 } }, /* @__PURE__ */ React.createElement(
|
|
4754
5150
|
Icon,
|
|
4755
5151
|
{
|
|
4756
5152
|
name: s.status === "sent" ? "check" : s.status === "failed" ? "x" : "paperclip",
|
|
@@ -4758,7 +5154,78 @@ ${peer.address}`
|
|
|
4758
5154
|
stroke: 2,
|
|
4759
5155
|
color: s.status === "failed" ? "var(--danger)" : s.status === "waiting" ? "var(--faint)" : "var(--accent)"
|
|
4760
5156
|
}
|
|
4761
|
-
), /* @__PURE__ */ React.createElement("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, (s.status === "sending" ? lang === "zh" ? "\u53D1\u9001\u4E2D: " : "Sending: " : "") + (s.via === "webrtc" ? "WebRTC \xB7 " : "") + s.name + (s.status === "sending" ? (s.size ? " \xB7 " + dkFileSize(s.sent || 0) + " / " + dkFileSize(s.size) : "") + (s.pct != null ? " \xB7 " + Math.min(100, Math.max(0, s.pct)).toFixed(1) + "%" : "") + (s.kbps != null ? " \xB7 " + dkSpeed(s.kbps) : "") : s.status === "waiting" ? " \xB7 " + (s.size ? dkFileSize(s.size) + " \xB7 " : "") + (lang === "zh" ? "\u7B49\u5F85\u4E2D" : "waiting") : s.status === "failed" ? " \xB7 " + (s.error || "") : " \xB7 " + (lang === "zh" ? "\u5DF2\u63D0\u4EA4" : "done")))))
|
|
5157
|
+
), /* @__PURE__ */ React.createElement("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, (s.status === "sending" ? lang === "zh" ? "\u53D1\u9001\u4E2D: " : "Sending: " : "") + (s.via === "webrtc" ? "WebRTC \xB7 " : "") + s.name + (s.status === "sending" ? (s.size ? " \xB7 " + dkFileSize(s.sent || 0) + " / " + dkFileSize(s.size) : "") + (s.pct != null ? " \xB7 " + Math.min(100, Math.max(0, s.pct)).toFixed(1) + "%" : "") + (s.kbps != null ? " \xB7 " + dkSpeed(s.kbps) : "") : s.status === "waiting" ? " \xB7 " + (s.size ? dkFileSize(s.size) + " \xB7 " : "") + (lang === "zh" ? "\u7B49\u5F85\u4E2D" : "waiting") : s.status === "failed" ? " \xB7 " + (s.error || "") : " \xB7 " + (lang === "zh" ? "\u5DF2\u63D0\u4EA4" : "done"))))), myResults.map((s, i) => /* @__PURE__ */ React.createElement(
|
|
5158
|
+
"div",
|
|
5159
|
+
{
|
|
5160
|
+
key: "r" + s.id,
|
|
5161
|
+
"data-testid": "file-send-result",
|
|
5162
|
+
"data-status": s.status,
|
|
5163
|
+
"data-rtc-failed": s.rtcFailed ? "1" : void 0,
|
|
5164
|
+
title: s.rtcError ? "WebRTC: " + s.rtcError : void 0,
|
|
5165
|
+
style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0, color: s.status === "failed" ? "var(--danger)" : "var(--dim)" }
|
|
5166
|
+
},
|
|
5167
|
+
/* @__PURE__ */ React.createElement(
|
|
5168
|
+
Icon,
|
|
5169
|
+
{
|
|
5170
|
+
name: s.status === "failed" ? "x" : "check",
|
|
5171
|
+
size: 13,
|
|
5172
|
+
stroke: 2,
|
|
5173
|
+
color: s.status === "failed" ? "var(--danger)" : "var(--faint)"
|
|
5174
|
+
}
|
|
5175
|
+
),
|
|
5176
|
+
/* @__PURE__ */ React.createElement("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 } }, resultLabel(s, lang)),
|
|
5177
|
+
i === myResults.length - 1 && /* @__PURE__ */ React.createElement(
|
|
5178
|
+
"button",
|
|
5179
|
+
{
|
|
5180
|
+
onClick: dismissResults,
|
|
5181
|
+
title: lang === "zh" ? "\u5173\u95ED" : "Dismiss",
|
|
5182
|
+
"aria-label": lang === "zh" ? "\u5173\u95ED" : "Dismiss",
|
|
5183
|
+
style: { flexShrink: 0, border: "none", background: "transparent", color: "var(--faint)", cursor: "pointer", padding: "0 2px", fontFamily: "var(--mono)", fontSize: 11.5 }
|
|
5184
|
+
},
|
|
5185
|
+
lang === "zh" ? "\u5173\u95ED" : "dismiss"
|
|
5186
|
+
)
|
|
5187
|
+
))), pending.length > 0 && /* @__PURE__ */ React.createElement("div", { "data-testid": "composer-attachments", style: { maxWidth: 1200, margin: "0 auto 8px", display: "flex", flexWrap: "wrap", gap: 8 } }, pending.map((p) => /* @__PURE__ */ React.createElement(
|
|
5188
|
+
"div",
|
|
5189
|
+
{
|
|
5190
|
+
key: p.id,
|
|
5191
|
+
"data-testid": "composer-attachment",
|
|
5192
|
+
title: p.file.name + " \xB7 " + dkFileSize(p.file.size),
|
|
5193
|
+
style: {
|
|
5194
|
+
position: "relative",
|
|
5195
|
+
borderRadius: 9,
|
|
5196
|
+
border: "1px solid var(--line)",
|
|
5197
|
+
background: "var(--panel-2)",
|
|
5198
|
+
overflow: "hidden",
|
|
5199
|
+
...p.image ? { width: 72, height: 72 } : { height: 40, maxWidth: 220, display: "flex", alignItems: "center", gap: 6, padding: "0 28px 0 10px" }
|
|
5200
|
+
}
|
|
5201
|
+
},
|
|
5202
|
+
p.image ? /* @__PURE__ */ React.createElement("img", { src: p.url, alt: p.file.name, style: { width: "100%", height: "100%", objectFit: "cover", display: "block" } }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Icon, { name: "paperclip", size: 14, stroke: 2, color: "var(--faint)" }), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 11.5, color: "var(--dim)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, p.file.name)),
|
|
5203
|
+
/* @__PURE__ */ React.createElement(
|
|
5204
|
+
"button",
|
|
5205
|
+
{
|
|
5206
|
+
"data-testid": "composer-attachment-remove",
|
|
5207
|
+
onClick: () => removePending(p.id),
|
|
5208
|
+
title: lang === "zh" ? "\u79FB\u9664" : "Remove",
|
|
5209
|
+
"aria-label": lang === "zh" ? "\u79FB\u9664" : "Remove",
|
|
5210
|
+
style: {
|
|
5211
|
+
position: "absolute",
|
|
5212
|
+
top: 3,
|
|
5213
|
+
right: 3,
|
|
5214
|
+
width: 20,
|
|
5215
|
+
height: 20,
|
|
5216
|
+
borderRadius: 999,
|
|
5217
|
+
border: "none",
|
|
5218
|
+
cursor: "pointer",
|
|
5219
|
+
padding: 0,
|
|
5220
|
+
background: "rgba(0,0,0,0.62)",
|
|
5221
|
+
display: "flex",
|
|
5222
|
+
alignItems: "center",
|
|
5223
|
+
justifyContent: "center"
|
|
5224
|
+
}
|
|
5225
|
+
},
|
|
5226
|
+
/* @__PURE__ */ React.createElement(Icon, { name: "x", size: 12, stroke: 2.4, color: "#fff" })
|
|
5227
|
+
)
|
|
5228
|
+
))), /* @__PURE__ */ React.createElement("div", { style: { maxWidth: 1200, margin: "0 auto", display: "flex", alignItems: "flex-end", gap: phone ? 6 : 10 } }, /* @__PURE__ */ React.createElement(
|
|
4762
5229
|
"input",
|
|
4763
5230
|
{
|
|
4764
5231
|
ref: fileRef,
|
|
@@ -4812,10 +5279,13 @@ ${peer.address}`
|
|
|
4812
5279
|
/* @__PURE__ */ React.createElement("span", { style: { fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, "@", c.insert),
|
|
4813
5280
|
c.insert !== c.sender && /* @__PURE__ */ React.createElement("span", { style: { fontSize: 11, color: "var(--faint)", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, c.sender)
|
|
4814
5281
|
))), /* @__PURE__ */ React.createElement(
|
|
4815
|
-
"
|
|
5282
|
+
"textarea",
|
|
4816
5283
|
{
|
|
4817
5284
|
ref: inputRef,
|
|
5285
|
+
rows: 1,
|
|
5286
|
+
"data-testid": "composer",
|
|
4818
5287
|
value: draft,
|
|
5288
|
+
onPaste,
|
|
4819
5289
|
onChange: (e) => {
|
|
4820
5290
|
histIdx.current = null;
|
|
4821
5291
|
setDraft(e.target.value);
|
|
@@ -4848,18 +5318,18 @@ ${peer.address}`
|
|
|
4848
5318
|
return;
|
|
4849
5319
|
}
|
|
4850
5320
|
}
|
|
4851
|
-
if (e.key === "Enter" && !e.shiftKey) {
|
|
5321
|
+
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
4852
5322
|
e.preventDefault();
|
|
4853
5323
|
sendDraft();
|
|
4854
5324
|
return;
|
|
4855
5325
|
}
|
|
4856
|
-
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
5326
|
+
if ((e.key === "ArrowUp" || e.key === "ArrowDown") && !draft.includes("\n")) {
|
|
4857
5327
|
if (walkHistory(e.key === "ArrowUp" ? -1 : 1))
|
|
4858
5328
|
e.preventDefault();
|
|
4859
5329
|
}
|
|
4860
5330
|
},
|
|
4861
5331
|
placeholder: phone ? `${T.message}\u2026` : `${T.message} ${verifiedLabel(peer.app ? null : peer.userId, peer.alias) || shortKey(peer.userId, 6, 4)}\u2026`,
|
|
4862
|
-
style: { flex: 1,
|
|
5332
|
+
style: { flex: 1, minHeight: 38, maxHeight: 180, boxSizing: "border-box", resize: "none", overflowY: "auto", borderRadius: 9, border: "1px solid var(--line)", background: "var(--panel-2)", color: "var(--text)", fontFamily: "var(--ui)", fontSize: 13.5, lineHeight: "18px", padding: "9px 14px", outline: "none", minWidth: 0 }
|
|
4863
5333
|
}
|
|
4864
5334
|
)), /* @__PURE__ */ React.createElement(Btn, { tone: "solid", icon: "arrowUp", title: T.send, onClick: sendDraft }))),
|
|
4865
5335
|
theater && /* @__PURE__ */ React.createElement("div", { onClick: () => setTheater(null), style: {
|
|
@@ -4909,7 +5379,7 @@ ${peer.address}`
|
|
|
4909
5379
|
style: { maxWidth: "100%", maxHeight: "100%", objectFit: "contain", borderRadius: 6 }
|
|
4910
5380
|
}
|
|
4911
5381
|
))),
|
|
4912
|
-
pubProfile && /* @__PURE__ */ React.createElement(DkPublicProfile, { T, userid: peer.userId, fallbackName: verifiedLabel(peer.userId, peer.alias), isFriend: true, onClose: () => setPubProfile(false) }),
|
|
5382
|
+
pubProfile && /* @__PURE__ */ React.createElement(DkPublicProfile, { T, userid: peer.userId, fallbackName: verifiedLabel(peer.userId, peer.alias), isFriend: true, friend: peer, onClose: () => setPubProfile(false) }),
|
|
4913
5383
|
nameCardProf && (() => {
|
|
4914
5384
|
const cardFriend2 = cardFriend(nameCardProf, peers);
|
|
4915
5385
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -4960,6 +5430,75 @@ ${peer.address}`
|
|
|
4960
5430
|
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 }));
|
|
4961
5431
|
}
|
|
4962
5432
|
Object.assign(window, { ChatTab });
|
|
5433
|
+
var PLATFORM = { ios: "iOS", android: "Android", darwin: "macOS", macos: "macOS", linux: "Linux", win32: "Windows", windows: "Windows", js: "Browser", browser: "Browser", web: "Browser", agent: "Agent" };
|
|
5434
|
+
var clean2 = (v) => typeof v === "string" && v.trim() ? v.trim() : "";
|
|
5435
|
+
function platformLabel(p) {
|
|
5436
|
+
const v = clean2(p);
|
|
5437
|
+
if (!v)
|
|
5438
|
+
return "";
|
|
5439
|
+
return Object.prototype.hasOwnProperty.call(PLATFORM, v.toLowerCase()) ? PLATFORM[v.toLowerCase()] : v;
|
|
5440
|
+
}
|
|
5441
|
+
function osVersionLabel(v) {
|
|
5442
|
+
const s = clean2(v);
|
|
5443
|
+
return !s || /^[a-z]+-?$/i.test(s) ? "" : s;
|
|
5444
|
+
}
|
|
5445
|
+
function rspLabel(protocol, notAdvertised) {
|
|
5446
|
+
if (typeof protocol !== "string")
|
|
5447
|
+
return "";
|
|
5448
|
+
return protocol ? protocol.toUpperCase() : notAdvertised || "Not advertised";
|
|
5449
|
+
}
|
|
5450
|
+
var LINK_BASE = { twitter: "https://x.com/", linkedin: "https://www.linkedin.com/in/", github: "https://github.com/" };
|
|
5451
|
+
var shortDate = (ms) => {
|
|
5452
|
+
try {
|
|
5453
|
+
return new Date(ms).toLocaleString(void 0, { dateStyle: "medium", timeStyle: "short" });
|
|
5454
|
+
} catch (e) {
|
|
5455
|
+
return new Date(ms).toLocaleString();
|
|
5456
|
+
}
|
|
5457
|
+
};
|
|
5458
|
+
function friendCardView(friend, prof, T = {}, fmtDate2 = shortDate) {
|
|
5459
|
+
const f = friend || {};
|
|
5460
|
+
const p = prof || {};
|
|
5461
|
+
const name = clean2(p.displayName) || clean2(f.alias) || clean2(f.name);
|
|
5462
|
+
const ens = clean2(p.ens) || clean2(f.ensClaim) || clean2(f.ens);
|
|
5463
|
+
const description = clean2(p.description) || clean2(f.description);
|
|
5464
|
+
const avatarUrl = clean2(p.avatarUrl) || clean2(f.avatarUrl) || clean2(f.pushedAvatarUrl);
|
|
5465
|
+
const punkId = p.punkId != null ? p.punkId : f.punkId != null ? f.punkId : null;
|
|
5466
|
+
const userid = f.userId || f.id || "";
|
|
5467
|
+
const address = clean2(f.address) || clean2(p.address);
|
|
5468
|
+
const rows = [];
|
|
5469
|
+
if (friend) {
|
|
5470
|
+
const status = f.online ? T.statusOnline || "Online" : (T.statusOffline || "Offline") + (f.lastSessionAt ? " \xB7 " + (T.lastSeen || "last seen") + " " + fmtDate2(f.lastSessionAt) : "");
|
|
5471
|
+
rows.push({ key: "status", label: T.status || "Status", value: status, online: !!f.online });
|
|
5472
|
+
}
|
|
5473
|
+
if (clean2(p.eth))
|
|
5474
|
+
rows.push({ key: "eth", label: "ethereum", value: p.eth, copy: true, head: 8 });
|
|
5475
|
+
if (clean2(p.sol))
|
|
5476
|
+
rows.push({ key: "sol", label: "solana", value: p.sol, copy: true, head: 8 });
|
|
5477
|
+
if (userid)
|
|
5478
|
+
rows.push({ key: "userid", label: T.userId || "user id", value: userid, copy: true, head: 10 });
|
|
5479
|
+
if (address && address !== userid)
|
|
5480
|
+
rows.push({ key: "address", label: T.addr || "address", value: address, copy: true, head: 8 });
|
|
5481
|
+
const links = Object.entries(p.links || {}).filter(([, h]) => clean2(h)).map(([k, h]) => ({ key: k, label: k, href: (LINK_BASE[k] || "") + h }));
|
|
5482
|
+
const site = clean2(f.profileUrl);
|
|
5483
|
+
if (site && !links.some((l) => l.href === site))
|
|
5484
|
+
links.push({ key: "website", label: T.website || "website", href: site });
|
|
5485
|
+
const client = [];
|
|
5486
|
+
if (friend) {
|
|
5487
|
+
const plat = platformLabel(f.platform);
|
|
5488
|
+
if (plat)
|
|
5489
|
+
client.push({ key: "platform", label: T.friendPlatform || "Platform", value: plat });
|
|
5490
|
+
const os = osVersionLabel(f.osVersion);
|
|
5491
|
+
if (os)
|
|
5492
|
+
client.push({ key: "os", label: T.friendOsVersion || "OS version", value: os });
|
|
5493
|
+
const app = clean2(f.appVersion);
|
|
5494
|
+
if (app)
|
|
5495
|
+
client.push({ key: "app", label: T.friendAppVersion || "App version", value: app });
|
|
5496
|
+
const rsp = rspLabel(f.rspProtocol, T.friendRspNotAdvertised);
|
|
5497
|
+
if (rsp)
|
|
5498
|
+
client.push({ key: "rsp", label: "RSP", value: rsp });
|
|
5499
|
+
}
|
|
5500
|
+
return { name, ens, description, avatarUrl, punkId, userid, address, rows, links, client };
|
|
5501
|
+
}
|
|
4963
5502
|
function CopyBtn({ value, copiedText = "Copied", copyFailedText = "Copy failed", copyTitle = "Copy" }) {
|
|
4964
5503
|
const [status, setStatus] = React.useState(null);
|
|
4965
5504
|
const timer = React.useRef(null);
|
|
@@ -5236,7 +5775,7 @@ ${peer.address}`
|
|
|
5236
5775
|
function DkPublicProfile({ T, userid, fallbackName, onClose, isFriend, isMe, onMessage, card, friend }) {
|
|
5237
5776
|
const view = card ? nameCardView(card, friend ? [friend] : []) : null;
|
|
5238
5777
|
const [st, setSt] = React.useState({ loading: true });
|
|
5239
|
-
const ensV = useEnsVerdict(userid, st.prof && st.prof.ens);
|
|
5778
|
+
const ensV = useEnsVerdict(userid, st.prof && st.prof.ens || friend && (friend.ensClaim || friend.ens) || "");
|
|
5240
5779
|
const [addState, setAddState] = React.useState(null);
|
|
5241
5780
|
const [recOpen, setRecOpen] = React.useState(false);
|
|
5242
5781
|
const [recPeers, setRecPeers] = React.useState(null);
|
|
@@ -5252,13 +5791,14 @@ ${peer.address}`
|
|
|
5252
5791
|
};
|
|
5253
5792
|
const recommendTo = (p) => {
|
|
5254
5793
|
const prof2 = st.prof || {};
|
|
5794
|
+
const fc = friend ? friendCardView(friend, st.prof, T) : null;
|
|
5255
5795
|
const text = dkEncodeBeagleContact({
|
|
5256
|
-
name: prof2.displayName || fallbackName || "",
|
|
5257
|
-
ens: prof2.ens || "",
|
|
5796
|
+
name: fc && fc.name || prof2.displayName || fallbackName || "",
|
|
5797
|
+
ens: fc && fc.ens || prof2.ens || "",
|
|
5258
5798
|
userid,
|
|
5259
|
-
address: prof2.address || "",
|
|
5260
|
-
avatar: prof2.avatarUrl || "",
|
|
5261
|
-
description: prof2.description || ""
|
|
5799
|
+
address: fc && fc.address || prof2.address || "",
|
|
5800
|
+
avatar: fc && fc.avatarUrl || prof2.avatarUrl || "",
|
|
5801
|
+
description: fc && fc.description || prof2.description || ""
|
|
5262
5802
|
});
|
|
5263
5803
|
setRecState((s) => ({ ...s, [p.id]: "busy" }));
|
|
5264
5804
|
fetch("/api/chat-send", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ userid: p.userId, text }) }).then((r) => r.json()).then((r) => setRecState((s) => ({ ...s, [p.id]: r.ok !== false ? "sent" : r.error || "failed" }))).catch((e) => setRecState((s) => ({ ...s, [p.id]: String(e && e.message || e) })));
|
|
@@ -5282,17 +5822,20 @@ ${peer.address}`
|
|
|
5282
5822
|
};
|
|
5283
5823
|
}, [userid]);
|
|
5284
5824
|
const prof = st.prof;
|
|
5285
|
-
const
|
|
5286
|
-
const
|
|
5825
|
+
const fv = isFriend && friend ? friendCardView(friend, prof, T) : null;
|
|
5826
|
+
const pv = prof || {};
|
|
5827
|
+
const LINK_BASE2 = { twitter: "https://x.com/", linkedin: "https://www.linkedin.com/in/", github: "https://github.com/" };
|
|
5828
|
+
const links = fv ? fv.links.map((l) => [l.label, l.href, true]) : prof ? Object.entries(prof.links || {}) : [];
|
|
5829
|
+
const cardAddress = fv ? fv.address : pv.address;
|
|
5287
5830
|
const lbl = { width: 110, flexShrink: 0, fontFamily: "var(--mono)", fontSize: 11, fontWeight: 600, color: "var(--faint)", textTransform: "uppercase", letterSpacing: 0.5 };
|
|
5288
5831
|
const rowS = { display: "flex", alignItems: "center", gap: 10, padding: "10px 0", borderTop: "1px solid var(--line)" };
|
|
5289
|
-
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: { display: "flex", alignItems: "center", gap: 5, fontFamily: "var(--mono)", fontSize: 12, color: "var(--accent)", marginTop: 2 } }, prof.ens, /* @__PURE__ */ React.createElement(DkEnsMark, { verdict: ensV, T }))), /* @__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" } },
|
|
5832
|
+
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", maxHeight: "calc(100dvh - 48px)", overflowY: "auto", 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 }) : fv && fv.avatarUrl ? /* @__PURE__ */ React.createElement(DkImgAvatar, { url: fv.avatarUrl, seed: userid, size: 56, radius: 14 }) : 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" } }, fv && fv.name || prof && prof.displayName || fallbackName || shortKey(userid, 10, 6)), (fv ? fv.ens : prof && prof.ens) && /* @__PURE__ */ React.createElement("div", { "data-testid": "friend-card-ens", style: { display: "flex", alignItems: "center", gap: 5, fontFamily: "var(--mono)", fontSize: 12, color: "var(--accent)", marginTop: 2 } }, fv ? fv.ens : prof.ens, /* @__PURE__ */ React.createElement(DkEnsMark, { verdict: ensV, T }))), /* @__PURE__ */ React.createElement(Btn, { icon: "x", size: "sm", onClick: onClose })), st.loading && !fv ? /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)" } }, T.dirLoading || "loading\u2026") : !prof && !fv && view ? /* @__PURE__ */ React.createElement(DkNameCardNoProfile, { T, view, card, onMessage, isMe }) : !prof && !fv ? /* @__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", { "data-testid": fv ? "friend-card" : void 0, style: { display: "flex", flexDirection: "column" } }, (fv ? fv.description : pv.description) && /* @__PURE__ */ React.createElement("div", { "data-testid": "friend-card-bio", style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--dim)", paddingBottom: 12, lineHeight: 1.5, overflowWrap: "anywhere" } }, fv ? fv.description : pv.description), links.length > 0 && // Label keeps its column; pills wrap inside their OWN container so
|
|
5290
5833
|
// an overflowing pill lands under the first pill, never under the label.
|
|
5291
|
-
/* @__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(
|
|
5834
|
+
/* @__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, full]) => /* @__PURE__ */ React.createElement(
|
|
5292
5835
|
"a",
|
|
5293
5836
|
{
|
|
5294
5837
|
key: k,
|
|
5295
|
-
href: (
|
|
5838
|
+
href: full ? h : (LINK_BASE2[k] || "") + h,
|
|
5296
5839
|
target: "_blank",
|
|
5297
5840
|
rel: "noreferrer",
|
|
5298
5841
|
style: { display: "inline-flex", alignItems: "center", gap: 5, padding: "4px 10px", borderRadius: 999, border: "1px solid var(--line)", textDecoration: "none", fontFamily: "var(--ui)", fontSize: 12, color: "var(--accent)" }
|
|
@@ -5301,10 +5844,13 @@ ${peer.address}`
|
|
|
5301
5844
|
" \u2197"
|
|
5302
5845
|
)))), (() => {
|
|
5303
5846
|
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 }));
|
|
5847
|
+
if (fv) {
|
|
5848
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, fv.rows.map((r) => r.copy ? kvRow(r.label, r.value, r.head) : /* @__PURE__ */ React.createElement("div", { style: rowS, key: r.key, "data-testid": "friend-card-" + r.key }, /* @__PURE__ */ React.createElement("span", { style: lbl }, r.label), /* @__PURE__ */ React.createElement("span", { style: { flex: 1, minWidth: 0, display: "inline-flex", alignItems: "center", gap: 6, fontFamily: "var(--mono)", fontSize: 11.5, color: "var(--dim)" } }, r.key === "status" && /* @__PURE__ */ React.createElement("span", { style: { width: 7, height: 7, borderRadius: 999, flexShrink: 0, background: r.online ? "var(--online)" : "var(--faint)" } }), r.value))));
|
|
5849
|
+
}
|
|
5304
5850
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, prof.eth && kvRow("ethereum", prof.eth), prof.sol && kvRow("solana", prof.sol), kvRow(T.userId || "user id", userid, 10), prof.address && kvRow(T.addr || "address", prof.address));
|
|
5305
5851
|
})(), (() => {
|
|
5306
5852
|
const cta = { padding: "7px 16px", borderRadius: 9, cursor: "pointer", fontFamily: "var(--ui)", fontSize: 12.5 };
|
|
5307
|
-
return /* @__PURE__ */ React.createElement("div", { style: { ...rowS, justifyContent: "flex-end", gap: 8 } }, !isMe &&
|
|
5853
|
+
return /* @__PURE__ */ React.createElement("div", { style: { ...rowS, justifyContent: "flex-end", gap: 8 } }, !isMe && cardAddress && /* @__PURE__ */ React.createElement(
|
|
5308
5854
|
"button",
|
|
5309
5855
|
{
|
|
5310
5856
|
onClick: openRecommend,
|
|
@@ -5318,10 +5864,10 @@ ${peer.address}`
|
|
|
5318
5864
|
style: { ...cta, border: "none", background: "var(--accent)", color: "#fff" }
|
|
5319
5865
|
},
|
|
5320
5866
|
T.pubMessage || "Message"
|
|
5321
|
-
), !isMe && !isFriend &&
|
|
5867
|
+
), !isMe && !isFriend && pv.address && (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(
|
|
5322
5868
|
"button",
|
|
5323
5869
|
{
|
|
5324
|
-
onClick: () => addFriend(
|
|
5870
|
+
onClick: () => addFriend(pv.address),
|
|
5325
5871
|
disabled: addState === "busy",
|
|
5326
5872
|
style: { ...cta, border: "none", background: "var(--accent)", color: "#fff", opacity: addState === "busy" ? 0.6 : 1 }
|
|
5327
5873
|
},
|
|
@@ -5337,7 +5883,7 @@ ${peer.address}`
|
|
|
5337
5883
|
/* @__PURE__ */ React.createElement(DkAvatar, { peer: p, size: 26, radius: 7, dot: false }),
|
|
5338
5884
|
/* @__PURE__ */ React.createElement("span", { style: { flex: 1, minWidth: 0, fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--text)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, /* @__PURE__ */ React.createElement(DkVerifiedName, { userid: p.userId, name: p.alias, fallback: shortKey(p.userId, 8, 6), T })),
|
|
5339
5885
|
recState[p.id] === "sent" ? /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--ui)", fontSize: 11.5, color: "var(--online)" } }, T.pubRecSent || "sent \u2713") : recState[p.id] === "busy" ? /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--ui)", fontSize: 11.5, color: "var(--faint)" } }, "\u2026") : recState[p.id] ? /* @__PURE__ */ React.createElement("span", { title: recState[p.id], style: { fontFamily: "var(--ui)", fontSize: 11.5, color: "var(--warn, #f59e0b)" } }, T.addFailed || "failed") : /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--ui)", fontSize: 11.5, color: "var(--accent)" } }, T.send || "Send")
|
|
5340
|
-
))))));
|
|
5886
|
+
))), fv && fv.client.length > 0 && /* @__PURE__ */ React.createElement("div", { "data-testid": "friend-card-client" }, fv.client.map((r) => /* @__PURE__ */ React.createElement("div", { key: r.key, style: rowS, "data-testid": "friend-card-" + r.key }, /* @__PURE__ */ React.createElement("span", { style: lbl }, r.label), /* @__PURE__ */ React.createElement("span", { title: r.value, style: { flex: 1, minWidth: 0, color: "var(--dim)", fontFamily: "var(--mono)", fontSize: 11.5, overflowWrap: "anywhere" } }, r.value)))))));
|
|
5341
5887
|
}
|
|
5342
5888
|
function dkAvatarDataUrl(file) {
|
|
5343
5889
|
return new Promise((resolve, reject) => {
|
|
@@ -6215,6 +6761,8 @@ ${peer.address}`
|
|
|
6215
6761
|
justifyContent: "center"
|
|
6216
6762
|
} }, /* @__PURE__ */ React.createElement(Icon, { name: app.icon, size: 19, color: "var(--accent)", stroke: 1.8 })), /* @__PURE__ */ React.createElement("div", { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 14, fontWeight: 600, color: "var(--text)" } }, pickText(app.name, t && t.lang, app.id)), /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--ui)", fontSize: 12.5, color: "var(--faint)", marginTop: 2 } }, pickText(app.blurb, t && t.lang, "")), /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--mono)", fontSize: 11, color: "var(--dim)", marginTop: 3 } }, app.host ? zh ? "\u672C\u673A\u5E94\u7528" : "runs in this app" : String(app.origin || "").replace(/^https?:\/\//, ""))), /* @__PURE__ */ React.createElement(Btn, { tone: "accent", size: "sm", onClick: busy ? void 0 : () => open(app) }, busy === app.id ? zh ? "\u6253\u5F00\u4E2D\u2026" : "opening\u2026" : zh ? "\u6253\u5F00" : "Open")))));
|
|
6217
6763
|
}
|
|
6764
|
+
var DK_Z_CALL_OVERLAY = 1e3;
|
|
6765
|
+
var DK_Z_INCOMING_CALL = 1010;
|
|
6218
6766
|
var CLAIM_SUPPRESS_MS = 5 * 6e4;
|
|
6219
6767
|
function newPageId() {
|
|
6220
6768
|
return "p" + Math.random().toString(36).slice(2, 10) + Date.now().toString(36).slice(-4);
|
|
@@ -7154,7 +7702,7 @@ ${peer.address}`
|
|
|
7154
7702
|
return null;
|
|
7155
7703
|
const peer = (peers || []).find((p) => p.id === inc.peerId) || { id: inc.peerId };
|
|
7156
7704
|
const name = verifiedLabel(inc.peerId, peer.alias) || peer.name || shortKey(inc.peerId, 10, 6);
|
|
7157
|
-
return /* @__PURE__ */ React.createElement("div", { style: { position: "fixed", inset: 0, zIndex:
|
|
7705
|
+
return /* @__PURE__ */ React.createElement("div", { "data-testid": "incoming-call", style: { position: "fixed", inset: 0, zIndex: DK_Z_INCOMING_CALL, background: "color-mix(in oklab, var(--bg), transparent 15%)", display: "flex", alignItems: "center", justifyContent: "center" } }, /* @__PURE__ */ React.createElement("div", { style: { width: 320, padding: 26, borderRadius: 18, background: "var(--panel)", border: "1px solid var(--line)", textAlign: "center", boxShadow: "0 20px 60px rgba(0,0,0,0.4)" } }, /* @__PURE__ */ React.createElement("div", { style: { position: "relative", display: "inline-flex", alignItems: "center", justifyContent: "center", marginBottom: 14 } }, /* @__PURE__ */ React.createElement("span", { style: { position: "absolute", width: 96, height: 96, borderRadius: 999, border: "2px solid var(--accent)", animation: "dkpulse 2s ease-out infinite" } }), /* @__PURE__ */ React.createElement(DkIdenticon, { seed: inc.peerId, size: 72, radius: 18 })), /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--mono)", fontSize: 17, fontWeight: 700, color: "var(--text)" } }, name), /* @__PURE__ */ React.createElement("div", { style: { fontFamily: "var(--mono)", fontSize: 12.5, color: "var(--faint)", marginTop: 4, display: "flex", gap: 6, alignItems: "center", justifyContent: "center" } }, /* @__PURE__ */ React.createElement(Icon, { name: inc.video ? "video" : "phone", size: 14, stroke: 2 }), T && (inc.video ? T.incomingVideo : T.incomingAudio) || "Incoming " + (inc.video ? "video" : "audio") + " call"), (inc.via === "rsp" || inc.via === "rsp-doorbell") && /* @__PURE__ */ React.createElement("div", { style: { color: "var(--faint)", fontSize: 12, marginTop: 6 } }, inc.via === "rsp-doorbell" ? "RSP \xB7 Doorbell" : "RSP"), /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: 14, justifyContent: "center", marginTop: 22 } }, /* @__PURE__ */ React.createElement(CallBtn, { icon: "phone", label: T && T.decline || "Decline", danger: true, onClick: ctl.reject }), /* @__PURE__ */ React.createElement(CallBtn, { icon: inc.video ? "video" : "phone", label: T && T.accept || "Accept", active: true, onClick: ctl.accept }))));
|
|
7158
7706
|
}
|
|
7159
7707
|
function CallBtn({ icon, label, onClick, active, danger, wide }) {
|
|
7160
7708
|
const bg = danger ? "var(--danger)" : active ? "var(--accent)" : "var(--chip)";
|
|
@@ -7207,7 +7755,7 @@ ${peer.address}`
|
|
|
7207
7755
|
};
|
|
7208
7756
|
const canShare = connected && typeof navigator !== "undefined" && navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia;
|
|
7209
7757
|
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 }));
|
|
7210
|
-
return /* @__PURE__ */ React.createElement("div", { style: { position: "fixed", inset: 0, zIndex:
|
|
7758
|
+
return /* @__PURE__ */ React.createElement("div", { "data-testid": "call-overlay", style: { position: "fixed", inset: 0, zIndex: DK_Z_CALL_OVERLAY, 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 ? (() => {
|
|
7211
7759
|
const tiles = [
|
|
7212
7760
|
{ key: "remote", stream: ctl.remoteStream, label: name, mirror: false },
|
|
7213
7761
|
{ key: "local", stream: ctl.localStream, label: ctl.sharing ? T && T.yourScreen || "Your screen" : T && T.you || "You", mirror: !ctl.sharing }
|
|
@@ -7416,6 +7964,8 @@ ${peer.address}`
|
|
|
7416
7964
|
var DEFAULTS = {
|
|
7417
7965
|
openTimeoutMs: 2e4,
|
|
7418
7966
|
// DataChannel open
|
|
7967
|
+
offerResendMs: 3e3,
|
|
7968
|
+
// sender: repeat the offer until answered
|
|
7419
7969
|
highWater: 4 * 1024 * 1024,
|
|
7420
7970
|
// in-flight bytes before the send loop waits
|
|
7421
7971
|
bufferWaitMs: 3e4,
|
|
@@ -7508,6 +8058,7 @@ ${peer.address}`
|
|
|
7508
8058
|
const PC = o.RTCPeerConnection;
|
|
7509
8059
|
const sessions = /* @__PURE__ */ new Map();
|
|
7510
8060
|
const finished = /* @__PURE__ */ new Map();
|
|
8061
|
+
const ended = /* @__PURE__ */ new Map();
|
|
7511
8062
|
const envelope = (fileId, type, extra) => Object.assign({ dkRtc: 1, kind: FILE_RTC_KIND, fileId, type, ts: Date.now() }, extra || {});
|
|
7512
8063
|
const signal = (peerId, fileId, type, extra) => o.bus.send(peerId, envelope(fileId, type, extra));
|
|
7513
8064
|
let off = null;
|
|
@@ -7516,6 +8067,9 @@ ${peer.address}`
|
|
|
7516
8067
|
for (const [id, at] of finished)
|
|
7517
8068
|
if (at < cut)
|
|
7518
8069
|
finished.delete(id);
|
|
8070
|
+
for (const [id, at] of ended)
|
|
8071
|
+
if (at < cut)
|
|
8072
|
+
ended.delete(id);
|
|
7519
8073
|
};
|
|
7520
8074
|
const closeRecv = (fileId) => {
|
|
7521
8075
|
const s = sessions.get(fileId);
|
|
@@ -7534,6 +8088,7 @@ ${peer.address}`
|
|
|
7534
8088
|
} catch (e) {
|
|
7535
8089
|
}
|
|
7536
8090
|
sessions.delete(fileId);
|
|
8091
|
+
ended.set(fileId, Date.now());
|
|
7537
8092
|
};
|
|
7538
8093
|
const attachChannel = (peerId, fileId, s, dc) => {
|
|
7539
8094
|
dc.binaryType = "arraybuffer";
|
|
@@ -7594,15 +8149,17 @@ ${peer.address}`
|
|
|
7594
8149
|
try {
|
|
7595
8150
|
if (env.type === "offer") {
|
|
7596
8151
|
pruneFinished();
|
|
7597
|
-
if (finished.has(fileId)) {
|
|
8152
|
+
if (finished.has(fileId) || ended.has(fileId)) {
|
|
7598
8153
|
log("[file-rtc] offer for a finished transfer ignored " + fileId);
|
|
7599
8154
|
return;
|
|
7600
8155
|
}
|
|
7601
|
-
if (s
|
|
7602
|
-
|
|
8156
|
+
if (s) {
|
|
8157
|
+
if (s.answerSdp && s.peerId === peerId)
|
|
8158
|
+
signal(peerId, fileId, "answer", { sdp: s.answerSdp }).catch(() => {
|
|
8159
|
+
});
|
|
7603
8160
|
return;
|
|
7604
8161
|
}
|
|
7605
|
-
const sess = { peerId, pc: null, dc: null, meta: env.meta || null, chunks: [], received: 0, pendingCandidates: [], completed: false };
|
|
8162
|
+
const sess = { peerId, pc: null, dc: null, meta: env.meta || null, chunks: [], received: 0, pendingCandidates: [], completed: false, answerSdp: null };
|
|
7606
8163
|
sessions.set(fileId, sess);
|
|
7607
8164
|
const pc = new PC({ iceServers: await o.iceServers() });
|
|
7608
8165
|
sess.pc = pc;
|
|
@@ -7623,6 +8180,7 @@ ${peer.address}`
|
|
|
7623
8180
|
}
|
|
7624
8181
|
const answer = await pc.createAnswer();
|
|
7625
8182
|
await pc.setLocalDescription(answer);
|
|
8183
|
+
sess.answerSdp = answer.sdp;
|
|
7626
8184
|
await signal(peerId, fileId, "answer", { sdp: answer.sdp });
|
|
7627
8185
|
} else if (env.type === "candidate" && s && env.candidate) {
|
|
7628
8186
|
if (s.pc && s.pc.remoteDescription) {
|
|
@@ -7658,6 +8216,8 @@ ${peer.address}`
|
|
|
7658
8216
|
log("[file-rtc] stale answer ignored for " + env.fileId + " state=" + s.pc.signalingState);
|
|
7659
8217
|
return;
|
|
7660
8218
|
}
|
|
8219
|
+
if (s.stopResend)
|
|
8220
|
+
s.stopResend();
|
|
7661
8221
|
await s.pc.setRemoteDescription({ type: "answer", sdp: env.sdp });
|
|
7662
8222
|
for (const c of s.pendingCandidates.splice(0)) {
|
|
7663
8223
|
try {
|
|
@@ -7679,7 +8239,7 @@ ${peer.address}`
|
|
|
7679
8239
|
const fileId = newId();
|
|
7680
8240
|
const pc = new PC({ iceServers: await o.iceServers() });
|
|
7681
8241
|
const dc = pc.createDataChannel("agentnet-file", { ordered: true });
|
|
7682
|
-
const s = { peerId, pc, dc, pendingCandidates: [] };
|
|
8242
|
+
const s = { peerId, pc, dc, pendingCandidates: [], stopResend: null };
|
|
7683
8243
|
senders.set(fileId, s);
|
|
7684
8244
|
let acked = null;
|
|
7685
8245
|
const ack = new Promise((resolve) => {
|
|
@@ -7695,7 +8255,15 @@ ${peer.address}`
|
|
|
7695
8255
|
} catch (e) {
|
|
7696
8256
|
}
|
|
7697
8257
|
});
|
|
8258
|
+
let resendTimer = null;
|
|
8259
|
+
s.stopResend = () => {
|
|
8260
|
+
if (resendTimer) {
|
|
8261
|
+
clearInterval(resendTimer);
|
|
8262
|
+
resendTimer = null;
|
|
8263
|
+
}
|
|
8264
|
+
};
|
|
7698
8265
|
const cleanup = () => {
|
|
8266
|
+
s.stopResend();
|
|
7699
8267
|
try {
|
|
7700
8268
|
dc.close();
|
|
7701
8269
|
} catch (e) {
|
|
@@ -7717,8 +8285,25 @@ ${peer.address}`
|
|
|
7717
8285
|
const offer = await pc.createOffer();
|
|
7718
8286
|
await pc.setLocalDescription(offer);
|
|
7719
8287
|
const mime = file.type || "application/octet-stream";
|
|
7720
|
-
|
|
7721
|
-
await
|
|
8288
|
+
const meta = { name: file.name, size: file.size, mime };
|
|
8289
|
+
await signal(peerId, fileId, "offer", { sdp: offer.sdp, meta });
|
|
8290
|
+
let resends = 0;
|
|
8291
|
+
resendTimer = setInterval(() => {
|
|
8292
|
+
if (pc.signalingState !== "have-local-offer" || dc.readyState !== "connecting") {
|
|
8293
|
+
s.stopResend();
|
|
8294
|
+
return;
|
|
8295
|
+
}
|
|
8296
|
+
resends++;
|
|
8297
|
+
log("[file-rtc] no answer yet, offer resent (" + resends + ") " + fileId);
|
|
8298
|
+
const sdp = pc.localDescription && pc.localDescription.sdp || offer.sdp;
|
|
8299
|
+
signal(peerId, fileId, "offer", { sdp, meta }).catch(() => {
|
|
8300
|
+
});
|
|
8301
|
+
}, opt.offerResendMs);
|
|
8302
|
+
try {
|
|
8303
|
+
await waitForOpen(dc, opt.openTimeoutMs, () => rtcState(pc));
|
|
8304
|
+
} finally {
|
|
8305
|
+
s.stopResend();
|
|
8306
|
+
}
|
|
7722
8307
|
dc.send(JSON.stringify({ type: "meta", name: file.name, size: file.size, mime }));
|
|
7723
8308
|
let sent = 0;
|
|
7724
8309
|
const startedAt = Date.now();
|
|
@@ -7800,7 +8385,8 @@ ${peer.address}`
|
|
|
7800
8385
|
sendFile,
|
|
7801
8386
|
// for tests
|
|
7802
8387
|
_sessions: sessions,
|
|
7803
|
-
_finished: finished
|
|
8388
|
+
_finished: finished,
|
|
8389
|
+
_ended: ended
|
|
7804
8390
|
};
|
|
7805
8391
|
}
|
|
7806
8392
|
function dkFileIceServers() {
|
|
@@ -8360,6 +8946,15 @@ ${peer.address}`
|
|
|
8360
8946
|
updLanNoRestart: "Installed, but the daemon did not come back within a minute \u2014 the new version applies on its next start.",
|
|
8361
8947
|
pubOpen: "View public profile",
|
|
8362
8948
|
pubNone: "No public profile \u2014 this user has not registered a beagles.eth name.",
|
|
8949
|
+
friendPlatform: "Platform",
|
|
8950
|
+
friendOsVersion: "OS version",
|
|
8951
|
+
friendAppVersion: "App version",
|
|
8952
|
+
friendRspNotAdvertised: "Not advertised",
|
|
8953
|
+
status: "Status",
|
|
8954
|
+
statusOnline: "Online",
|
|
8955
|
+
statusOffline: "Offline",
|
|
8956
|
+
lastSeen: "last seen",
|
|
8957
|
+
website: "website",
|
|
8363
8958
|
ensNoEthWallet: "no Ethereum wallet extension found (MetaMask\u2026)",
|
|
8364
8959
|
ensNoSolWallet: "no Solana wallet extension found (Phantom\u2026)",
|
|
8365
8960
|
ensWalletOwned: "registered via your mobile wallet as",
|
|
@@ -8373,6 +8968,7 @@ ${peer.address}`
|
|
|
8373
8968
|
copy: "Copy",
|
|
8374
8969
|
copied: "Copied",
|
|
8375
8970
|
copyFailed: "Copy failed",
|
|
8971
|
+
copyMarkdown: "Copy (Markdown)",
|
|
8376
8972
|
needProfile: "Set your name first \u2014 a friend request with no name is just a key.",
|
|
8377
8973
|
dangerZone: "Danger zone",
|
|
8378
8974
|
deleteNode: "Delete this node",
|
|
@@ -8597,6 +9193,15 @@ ${peer.address}`
|
|
|
8597
9193
|
updLanNoRestart: "\u5DF2\u5B89\u88C5,\u4F46 daemon \u4E00\u5206\u949F\u5185\u6CA1\u6709\u91CD\u65B0\u8D77\u6765\u2014\u2014\u4E0B\u6B21\u542F\u52A8\u65F6\u751F\u6548\u3002",
|
|
8598
9194
|
pubOpen: "\u67E5\u770B\u516C\u5F00\u8D44\u6599",
|
|
8599
9195
|
pubNone: "\u6682\u65E0\u516C\u5F00\u8D44\u6599\u2014\u2014\u5BF9\u65B9\u8FD8\u6CA1\u6709\u6CE8\u518C beagles.eth \u540D\u5B57\u3002",
|
|
9196
|
+
friendPlatform: "\u5E73\u53F0",
|
|
9197
|
+
friendOsVersion: "\u7CFB\u7EDF\u7248\u672C",
|
|
9198
|
+
friendAppVersion: "\u5E94\u7528\u7248\u672C",
|
|
9199
|
+
friendRspNotAdvertised: "\u672A\u58F0\u660E\u652F\u6301",
|
|
9200
|
+
status: "\u72B6\u6001",
|
|
9201
|
+
statusOnline: "\u5728\u7EBF",
|
|
9202
|
+
statusOffline: "\u79BB\u7EBF",
|
|
9203
|
+
lastSeen: "\u6700\u540E\u5728\u7EBF",
|
|
9204
|
+
website: "\u7F51\u7AD9",
|
|
8600
9205
|
ensNoEthWallet: "\u672A\u68C0\u6D4B\u5230\u4EE5\u592A\u574A\u94B1\u5305\u63D2\u4EF6(MetaMask \u7B49)",
|
|
8601
9206
|
ensNoSolWallet: "\u672A\u68C0\u6D4B\u5230 Solana \u94B1\u5305\u63D2\u4EF6(Phantom \u7B49)",
|
|
8602
9207
|
ensWalletOwned: "\u5DF2\u901A\u8FC7\u624B\u673A\u94B1\u5305\u6CE8\u518C\u4E3A",
|
|
@@ -8610,6 +9215,7 @@ ${peer.address}`
|
|
|
8610
9215
|
copy: "\u590D\u5236",
|
|
8611
9216
|
copied: "\u5DF2\u590D\u5236",
|
|
8612
9217
|
copyFailed: "\u590D\u5236\u5931\u8D25",
|
|
9218
|
+
copyMarkdown: "\u590D\u5236\uFF08Markdown\uFF09",
|
|
8613
9219
|
needProfile: "\u5148\u8BBE\u7F6E\u6635\u79F0 \u2014\u2014 \u6CA1\u6709\u540D\u5B57\u7684\u597D\u53CB\u8BF7\u6C42\u5C31\u53EA\u662F\u4E00\u4E32\u5BC6\u94A5\u3002",
|
|
8614
9220
|
dangerZone: "\u5371\u9669\u64CD\u4F5C",
|
|
8615
9221
|
deleteNode: "\u5220\u9664\u6B64\u8282\u70B9",
|
|
@@ -9168,19 +9774,20 @@ ${peer.address}`
|
|
|
9168
9774
|
});
|
|
9169
9775
|
if (!peerTakesRtcFile(peerId))
|
|
9170
9776
|
return toxcore();
|
|
9777
|
+
const viaCarrier = (rtcError) => toxcore().then((rr) => Object.assign({}, rr, { rtcFailed: true, rtcError: rtcError || "WebRTC file send failed" }));
|
|
9171
9778
|
return rtcFileCtl.sendFile(peerId, file, onProgress).then((r) => {
|
|
9172
9779
|
if (r && r.ok && r.via === "webrtc") {
|
|
9173
9780
|
return fetch(
|
|
9174
9781
|
"/api/webrtc-file-save?dir=out&userid=" + encodeURIComponent(peerId) + "&name=" + encodeURIComponent(file.name),
|
|
9175
9782
|
{ method: "POST", body: file }
|
|
9176
|
-
).then(() => {
|
|
9783
|
+
).catch(() => null).then(() => {
|
|
9177
9784
|
data.loadThread(peerId);
|
|
9178
9785
|
data.refresh();
|
|
9179
9786
|
return { ok: true, via: "webrtc" };
|
|
9180
9787
|
});
|
|
9181
9788
|
}
|
|
9182
|
-
return
|
|
9183
|
-
}
|
|
9789
|
+
return viaCarrier(r && r.error);
|
|
9790
|
+
}, (e) => viaCarrier(e && e.message || String(e)));
|
|
9184
9791
|
};
|
|
9185
9792
|
const onSendRtcFile = (file, onProgress) => {
|
|
9186
9793
|
if (!activeId || !file)
|
package/dist/friend-store.d.ts
CHANGED
|
@@ -5,7 +5,24 @@ export interface FriendStoreEntry {
|
|
|
5
5
|
punkId?: number;
|
|
6
6
|
platform?: string;
|
|
7
7
|
appVersion?: string;
|
|
8
|
+
osVersion?: string;
|
|
9
|
+
/** Their status line (Carrier userinfo description). */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** The profile link they set (userinfo url). */
|
|
12
|
+
profileUrl?: string;
|
|
13
|
+
/** The beagles.eth name they CLAIM in their profile — unverified here; the
|
|
14
|
+
* UI marks it verified only from the gateway's record for this userid. */
|
|
15
|
+
ens?: string;
|
|
16
|
+
/** The avatar URL they advertised (http(s) only). */
|
|
17
|
+
avatarUrl?: string;
|
|
18
|
+
/** "rsp/1", "rsp/2", … when their profile extra declares RSP with a node;
|
|
19
|
+
* "" when a profile arrived without one; undefined when none arrived. */
|
|
20
|
+
rspProtocol?: string;
|
|
21
|
+
/** Last live session with them (ms epoch), when the SDK recorded one. */
|
|
22
|
+
sessionAt?: number;
|
|
8
23
|
}
|
|
24
|
+
/** RSP declared in a profile's `extra` JSON: {"rsp":{"protocol":"rsp/2","nodeUrl":"https://…"}}. */
|
|
25
|
+
export declare function rspProtocolFromExtra(extra: unknown): string;
|
|
9
26
|
/** A punk id as the store or a backend may carry it: a finite non-negative
|
|
10
27
|
* number. Punk 0 is a real CryptoPunk; a string or a negative is not one. */
|
|
11
28
|
export declare function punkIdOf(v: unknown): number | undefined;
|
package/dist/friend-store.js
CHANGED
|
@@ -10,9 +10,39 @@
|
|
|
10
10
|
// version): lan ≤ 0.1.308 dropped these from its friends-list, so on a
|
|
11
11
|
// daemon backend only a beagles.eth record could supply an avatar — on
|
|
12
12
|
// mac-dev 8 of 16 pushed punks never reached the screen (2026-10-31).
|
|
13
|
+
// The rest of that profile too (status line, OS version, profile URL, the
|
|
14
|
+
// beagles.eth name they claim, RSP support from `extra`): the friend card
|
|
15
|
+
// shows what the phone apps show (decent-hq 2026-11-25; first attempted on
|
|
16
|
+
// codex/js-friend-client-info, 68c38cc).
|
|
13
17
|
//
|
|
14
18
|
// Cached by mtime: the list is polled every 2.5s per tab.
|
|
15
19
|
import { readFileSync, statSync } from "node:fs";
|
|
20
|
+
const str = (v, max = 256) => typeof v === "string" && v.trim() && v.length <= max ? v.trim() : undefined;
|
|
21
|
+
const httpUrl = (v) => {
|
|
22
|
+
const s = str(v, 2048);
|
|
23
|
+
if (!s)
|
|
24
|
+
return undefined;
|
|
25
|
+
try {
|
|
26
|
+
const u = new URL(s);
|
|
27
|
+
return u.protocol === "https:" || u.protocol === "http:" ? s : undefined;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/** RSP declared in a profile's `extra` JSON: {"rsp":{"protocol":"rsp/2","nodeUrl":"https://…"}}. */
|
|
34
|
+
export function rspProtocolFromExtra(extra) {
|
|
35
|
+
if (typeof extra !== "string" || extra.length > 1024)
|
|
36
|
+
return "";
|
|
37
|
+
try {
|
|
38
|
+
const rsp = JSON.parse(extra)?.rsp;
|
|
39
|
+
if (typeof rsp?.protocol === "string" && /^rsp\/[1-9]\d{0,3}$/i.test(rsp.protocol) && httpUrl(rsp.nodeUrl)) {
|
|
40
|
+
return rsp.protocol.toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch { /* no RSP declaration */ }
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
16
46
|
/** A punk id as the store or a backend may carry it: a finite non-negative
|
|
17
47
|
* number. Punk 0 is a real CryptoPunk; a string or a negative is not one. */
|
|
18
48
|
export function punkIdOf(v) {
|
|
@@ -39,6 +69,16 @@ export function parseFriendStore(raw) {
|
|
|
39
69
|
punkId: punkIdOf(r.punkId),
|
|
40
70
|
platform: typeof r.platform === "string" ? r.platform : undefined,
|
|
41
71
|
appVersion: typeof r.appVersion === "string" ? r.appVersion : undefined,
|
|
72
|
+
osVersion: str(r.osVersion, 64),
|
|
73
|
+
description: str(r.description, 512),
|
|
74
|
+
profileUrl: httpUrl(r.url),
|
|
75
|
+
ens: typeof r.ens === "string" && /^[a-z0-9-]+(\.[a-z0-9-]+)*\.eth$/i.test(r.ens.trim()) ? r.ens.trim().toLowerCase() : undefined,
|
|
76
|
+
avatarUrl: httpUrl(r.avatarUrl),
|
|
77
|
+
// A profile arrived when any of its fields did (protoVersion is set by
|
|
78
|
+
// every client that pushes one).
|
|
79
|
+
rspProtocol: (typeof r.extra === "string" || typeof r.protoVersion === "number" || typeof r.platform === "string")
|
|
80
|
+
? rspProtocolFromExtra(r.extra) : undefined,
|
|
81
|
+
sessionAt: typeof r.sessionAt === "number" ? r.sessionAt : undefined,
|
|
42
82
|
});
|
|
43
83
|
}
|
|
44
84
|
return map;
|
package/dist/server.js
CHANGED
|
@@ -2250,6 +2250,16 @@ export function startBeagleServer(opts) {
|
|
|
2250
2250
|
// The client they advertised with their profile, for the UI.
|
|
2251
2251
|
platform: f.platform ?? stamp?.platform ?? null,
|
|
2252
2252
|
appVersion: f.appVersion ?? stamp?.appVersion ?? null,
|
|
2253
|
+
// The rest of their pushed profile, for the friend card (what the
|
|
2254
|
+
// phone apps show). From the SDK's store: the daemon's
|
|
2255
|
+
// friends-list does not carry these.
|
|
2256
|
+
osVersion: f.osVersion ?? stamp?.osVersion ?? null,
|
|
2257
|
+
description: f.description || f.descr || stamp?.description || null,
|
|
2258
|
+
profileUrl: stamp?.profileUrl ?? null,
|
|
2259
|
+
ensClaim: stamp?.ens ?? null,
|
|
2260
|
+
pushedAvatarUrl: stamp?.avatarUrl ?? null,
|
|
2261
|
+
rspProtocol: stamp?.rspProtocol ?? null,
|
|
2262
|
+
lastSessionAt: stamp?.sessionAt ?? null,
|
|
2253
2263
|
};
|
|
2254
2264
|
});
|
|
2255
2265
|
const pend = pending.ok ? (pending.data?.pending ?? []) : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/beagle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.154",
|
|
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",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"start": "node dist/cli.js"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@decentnetwork/beagle-ui": "^0.2.
|
|
29
|
+
"@decentnetwork/beagle-ui": "^0.2.56",
|
|
30
30
|
"@decentnetwork/chat-components": "^0.1.3",
|
|
31
31
|
"@decentnetwork/lan": "^0.1.316",
|
|
32
32
|
"@decentnetwork/peer": "^0.1.178",
|