@decentnetwork/lan 0.1.164 → 0.1.166

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.
Binary file
Binary file
Binary file
Binary file
@@ -466,10 +466,14 @@ export class DaemonServer {
466
466
  // receive is the inline FileModel-JSON-over-bulkmsg envelope the
467
467
  // Beagle apps themselves use. Detected via the DHT-key signature.
468
468
  if (this.peerManager?.isNativeFriend(userid)) {
469
- const INLINE_MAX = 2 * 1024 * 1024; // base64 inflates ~1.37x; protocol cap is 5MB
469
+ // The FileModel JSON envelope is base64 (inflates ~1.34x) + a little
470
+ // JSON overhead, and the whole thing must fit the 5MB bulkmsg cap
471
+ // (CARRIER_MAX_APP_BULKMSG_LEN). 3.5MB raw → ~4.7MB envelope, safely
472
+ // under 5MB. (Was a conservative 2MB.)
473
+ const INLINE_MAX = 3.5 * 1024 * 1024;
470
474
  if (data.length > INLINE_MAX) {
471
475
  throw new Error(`This friend is a native (iOS/Android) client — files are sent inline and limited to ` +
472
- `${(INLINE_MAX / 1024 / 1024) | 0} MB (this is ${(data.length / 1024 / 1024).toFixed(1)} MB).`);
476
+ `${(INLINE_MAX / 1024 / 1024).toFixed(1)} MB (this is ${(data.length / 1024 / 1024).toFixed(1)} MB).`);
473
477
  }
474
478
  await this.peerManager.sendInlineFile(userid, new Uint8Array(data), name);
475
479
  this.logger.info(`Sent inline file "${name}" (${data.length}B) to native peer ${userid.slice(0, 8)}`);
@@ -1694,8 +1694,53 @@ function AudioSink({ stream }) {
1694
1694
  }, [stream]);
1695
1695
  return /* @__PURE__ */ React.createElement("audio", { ref, autoPlay: true });
1696
1696
  }
1697
+ function useRingtone(active) {
1698
+ React.useEffect(() => {
1699
+ if (!active) return void 0;
1700
+ let ctx;
1701
+ try {
1702
+ ctx = new (window.AudioContext || window.webkitAudioContext)();
1703
+ } catch (e) {
1704
+ return void 0;
1705
+ }
1706
+ if (ctx.state === "suspended") {
1707
+ ctx.resume().catch(() => {
1708
+ });
1709
+ }
1710
+ let stopped = false;
1711
+ const timers = [];
1712
+ const burst = () => {
1713
+ if (stopped || ctx.state === "closed") return;
1714
+ [440, 480].forEach((f) => {
1715
+ const o = ctx.createOscillator(), g = ctx.createGain();
1716
+ o.type = "sine";
1717
+ o.frequency.value = f;
1718
+ o.connect(g);
1719
+ g.connect(ctx.destination);
1720
+ const t = ctx.currentTime;
1721
+ g.gain.setValueAtTime(1e-4, t);
1722
+ g.gain.exponentialRampToValueAtTime(0.12, t + 0.05);
1723
+ g.gain.setValueAtTime(0.12, t + 0.9);
1724
+ g.gain.exponentialRampToValueAtTime(1e-4, t + 1);
1725
+ o.start(t);
1726
+ o.stop(t + 1.05);
1727
+ });
1728
+ timers.push(setTimeout(burst, 3e3));
1729
+ };
1730
+ burst();
1731
+ return () => {
1732
+ stopped = true;
1733
+ timers.forEach(clearTimeout);
1734
+ try {
1735
+ ctx.close();
1736
+ } catch (e) {
1737
+ }
1738
+ };
1739
+ }, [active]);
1740
+ }
1697
1741
  function IncomingCallModal({ T, ctl, peers }) {
1698
1742
  const inc = ctl.incoming;
1743
+ useRingtone(!!inc);
1699
1744
  if (!inc) return null;
1700
1745
  const peer = (peers || []).find((p) => p.id === inc.peerId) || { id: inc.peerId };
1701
1746
  const name = peer.alias || peer.name || shortKey(inc.peerId, 10, 6);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/lan",
3
- "version": "0.1.164",
3
+ "version": "0.1.166",
4
4
  "description": "Private virtual LAN for self-hosted services and AI agents, built on Elastos Carrier. NAT-traversal, name service, ACL, all over a peer-to-peer mesh — no public IP required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",