@decentnetwork/beagle 0.1.51 → 0.1.53
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/carrier-node.d.ts +8 -1
- package/dist/carrier-node.js +16 -1
- package/dist/desktop/app.js +1 -1
- package/dist/embedded-host.js +29 -6
- package/package.json +3 -3
package/dist/carrier-node.d.ts
CHANGED
|
@@ -98,7 +98,14 @@ export declare class CarrierNode extends EventEmitter {
|
|
|
98
98
|
sendFile(userid: string, data: Uint8Array, name: string): string | null;
|
|
99
99
|
cancelSend(userid: string, fileId: string): boolean;
|
|
100
100
|
acceptFile(userid: string, fileNumber: number): void;
|
|
101
|
-
|
|
101
|
+
/** Returns the SDK's delivery verdict — "acked" is the only outcome that
|
|
102
|
+
* earns a "sent" checkmark. Older SDKs resolve void: report "accepted"
|
|
103
|
+
* (bytes out, delivery unproven) rather than inventing a confirmation. */
|
|
104
|
+
sendInlineFile(userid: string, data: Uint8Array, name: string): Promise<"acked" | "accepted" | "offline">;
|
|
105
|
+
/** True when the friend is a NATIVE Carrier client (iOS/Android/C): it can
|
|
106
|
+
* only receive files as the inline envelope — a toxcore sendFile offer is
|
|
107
|
+
* invisible to it and would hang at "sending" until the 60s give-up. */
|
|
108
|
+
isNativeFriend(userid: string): boolean;
|
|
102
109
|
/** Send on an application packet id. Used for the components channel (165);
|
|
103
110
|
* unavailable on an SDK build without custom packets, which simply means
|
|
104
111
|
* this peer can't offer forms — never that chat breaks. */
|
package/dist/carrier-node.js
CHANGED
|
@@ -204,11 +204,26 @@ export class CarrierNode extends EventEmitter {
|
|
|
204
204
|
acceptFile(userid, fileNumber) {
|
|
205
205
|
this.#require().acceptFile(userid, fileNumber);
|
|
206
206
|
}
|
|
207
|
+
/** Returns the SDK's delivery verdict — "acked" is the only outcome that
|
|
208
|
+
* earns a "sent" checkmark. Older SDKs resolve void: report "accepted"
|
|
209
|
+
* (bytes out, delivery unproven) rather than inventing a confirmation. */
|
|
207
210
|
async sendInlineFile(userid, data, name) {
|
|
208
211
|
const peer = this.#require();
|
|
209
212
|
if (!peer.sendInlineFile)
|
|
210
213
|
throw new Error("This peer SDK build has no inline-file support");
|
|
211
|
-
await peer.sendInlineFile(userid, { name, data });
|
|
214
|
+
const r = await peer.sendInlineFile(userid, { name, data });
|
|
215
|
+
return (r && typeof r === "object" ? r.delivery : undefined) ?? "accepted";
|
|
216
|
+
}
|
|
217
|
+
/** True when the friend is a NATIVE Carrier client (iOS/Android/C): it can
|
|
218
|
+
* only receive files as the inline envelope — a toxcore sendFile offer is
|
|
219
|
+
* invisible to it and would hang at "sending" until the 60s give-up. */
|
|
220
|
+
isNativeFriend(userid) {
|
|
221
|
+
try {
|
|
222
|
+
return this.#require().isNativeFriend?.(userid) ?? false;
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
212
227
|
}
|
|
213
228
|
/** Send on an application packet id. Used for the components channel (165);
|
|
214
229
|
* unavailable on an SDK build without custom packets, which simply means
|
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.53";
|
|
2
2
|
const ICON_PATHS = {
|
|
3
3
|
// ---- tab bar (the four must feel like one set) ----
|
|
4
4
|
users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
|
package/dist/embedded-host.js
CHANGED
|
@@ -592,24 +592,47 @@ export class EmbeddedHost {
|
|
|
592
592
|
this.#events.emit("event", { type: "chat", userid, dir: "out" });
|
|
593
593
|
return { queued: true, name: safe, size: data.length };
|
|
594
594
|
}
|
|
595
|
+
// A NATIVE friend (iOS/Android/C Carrier) takes the inline envelope for
|
|
596
|
+
// small files (single blob, the Beagle apps' own fast path). Larger files
|
|
597
|
+
// go through the normal sendFile below — peer >= 0.1.141 carries those to
|
|
598
|
+
// natives as DNFT1 frames inside friend messages (offset acks, FEC,
|
|
599
|
+
// resume; verified 100MB JS→iPad). Only route to inline what fits it.
|
|
600
|
+
const native = this.#node.isNativeFriend(userid);
|
|
601
|
+
const inlineNative = native && data.length <= INLINE_MAX_BYTES;
|
|
595
602
|
const msg = this.#messages.appendFile(userid, "out", { name: safe, size: data.length, status: "sending", sent: 0 });
|
|
596
603
|
if (!msg)
|
|
597
604
|
throw new Error("Could not create file message");
|
|
598
605
|
await mkdir(this.outboxDir, { recursive: true });
|
|
599
606
|
await writeFile(resolve(this.outboxDir, msg.id), data);
|
|
600
|
-
const fileId = this.#node.sendFile(userid, new Uint8Array(data), safe);
|
|
607
|
+
const fileId = inlineNative ? null : this.#node.sendFile(userid, new Uint8Array(data), safe);
|
|
601
608
|
if (!fileId) {
|
|
602
|
-
//
|
|
603
|
-
// path a native iOS/Android friend can receive at all.
|
|
609
|
+
// Native friend, or no transfer slot — the inline envelope path.
|
|
604
610
|
if (data.length > INLINE_MAX_BYTES) {
|
|
605
611
|
this.#messages.patchFile(userid, msg.id, { status: "failed" });
|
|
606
612
|
throw new Error(`Could not start the transfer, and the file is too large (${(data.length / 1024 / 1024).toFixed(1)} MB) ` +
|
|
607
613
|
`for the inline fallback (limit ${(INLINE_MAX_BYTES / 1024 / 1024).toFixed(1)} MB).`);
|
|
608
614
|
}
|
|
609
|
-
|
|
610
|
-
|
|
615
|
+
// "sent" means the PEER CONFIRMED receipt — nothing less. Stamping it
|
|
616
|
+
// when sendInlineFile resolved was the fake-sent of INBOX 2026-08-21:
|
|
617
|
+
// bytes left the machine, the phone had nothing, the UI showed a
|
|
618
|
+
// checkmark. The SDK's verdict now decides the chip.
|
|
619
|
+
let delivery;
|
|
620
|
+
try {
|
|
621
|
+
delivery = await this.#node.sendInlineFile(userid, new Uint8Array(data), safe);
|
|
622
|
+
}
|
|
623
|
+
catch (e) {
|
|
624
|
+
this.#messages.patchFile(userid, msg.id, { status: "failed" });
|
|
625
|
+
this.#events.emit("event", { type: "chat", userid, dir: "out" });
|
|
626
|
+
throw e;
|
|
627
|
+
}
|
|
628
|
+
const status = delivery === "acked" ? "sent" : delivery === "offline" ? "queued" : "failed";
|
|
629
|
+
this.#messages.patchFile(userid, msg.id, { status, sent: delivery === "acked" ? data.length : 0 });
|
|
611
630
|
this.#events.emit("event", { type: "chat", userid, dir: "out" });
|
|
612
|
-
|
|
631
|
+
if (delivery === "accepted") {
|
|
632
|
+
throw new Error(`The peer never confirmed receiving "${safe}" — it likely did not arrive. ` +
|
|
633
|
+
`Check that their app is open and try again.`);
|
|
634
|
+
}
|
|
635
|
+
return { inline: true, name: safe, size: data.length, delivery };
|
|
613
636
|
}
|
|
614
637
|
this.#activeSends.set(fileId, { peer: userid, msgId: msg.id });
|
|
615
638
|
this.#meta.ensure(userid);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/beagle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.53",
|
|
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,8 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@decentnetwork/chat-components": "^0.1.3",
|
|
29
|
-
"@decentnetwork/lan": "^0.1.
|
|
30
|
-
"@decentnetwork/peer": "^0.1.
|
|
29
|
+
"@decentnetwork/lan": "^0.1.280",
|
|
30
|
+
"@decentnetwork/peer": "^0.1.141",
|
|
31
31
|
"@decentnetwork/peer-webrtc": "^0.2.16",
|
|
32
32
|
"js-yaml": "^4.1.0",
|
|
33
33
|
"yargs": "^17.7.2"
|