@decentnetwork/lan 0.1.165 → 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
@@ -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.165",
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",