@decentnetwork/lan 0.1.225 → 0.1.226
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/ui/desktop/app.js +6 -2
- package/package.json +1 -1
package/dist/ui/desktop/app.js
CHANGED
|
@@ -1950,6 +1950,10 @@ function dkFileDownload(blob, name) {
|
|
|
1950
1950
|
function useRtcFileController(selfId, onReceivedText) {
|
|
1951
1951
|
const [incoming, setIncoming] = React.useState([]);
|
|
1952
1952
|
const peersRef = React.useRef(/* @__PURE__ */ new Map());
|
|
1953
|
+
const onReceivedTextRef = React.useRef(onReceivedText);
|
|
1954
|
+
React.useEffect(() => {
|
|
1955
|
+
onReceivedTextRef.current = onReceivedText;
|
|
1956
|
+
}, [onReceivedText]);
|
|
1953
1957
|
React.useEffect(() => {
|
|
1954
1958
|
if (!selfId || !window.RTCPeerConnection || !window.dkRtcSignalBus) return;
|
|
1955
1959
|
const bus = dkRtcSignalBus();
|
|
@@ -1989,7 +1993,7 @@ function useRtcFileController(selfId, onReceivedText) {
|
|
|
1989
1993
|
const blob = new Blob(sess.chunks, { type: meta.mime || "application/octet-stream" });
|
|
1990
1994
|
const dl = dkFileDownload(blob, meta.name || "agentnet-file");
|
|
1991
1995
|
setIncoming((arr) => [{ id: fileId, peerId, name: dl.name, size: blob.size, url: dl.url }].concat(arr).slice(0, 8));
|
|
1992
|
-
if (
|
|
1996
|
+
if (onReceivedTextRef.current) onReceivedTextRef.current(peerId, "received file via WebRTC: " + dl.name + " (" + dkFileSize(blob.size) + ")");
|
|
1993
1997
|
cleanup(fileId);
|
|
1994
1998
|
} else if (msg.type === "cancel") {
|
|
1995
1999
|
cleanup(fileId);
|
|
@@ -2071,7 +2075,7 @@ function useRtcFileController(selfId, onReceivedText) {
|
|
|
2071
2075
|
off();
|
|
2072
2076
|
for (const id of Array.from(peersRef.current.keys())) cleanup(id);
|
|
2073
2077
|
};
|
|
2074
|
-
}, [selfId
|
|
2078
|
+
}, [selfId]);
|
|
2075
2079
|
const sendFile = React.useCallback(async (peerId, file, onProgress) => {
|
|
2076
2080
|
if (!peerId || !file || !window.RTCPeerConnection || !window.dkRtcSignalBus) {
|
|
2077
2081
|
return { ok: false, fallback: true, error: "WebRTC unavailable" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/lan",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.226",
|
|
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",
|