@trap_stevo/filetide 0.0.44 → 0.0.46
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/cjs/FileMessager.js
CHANGED
|
@@ -48,6 +48,7 @@ class FileMessager {
|
|
|
48
48
|
this.fileNet.on("get-client", this.handleGetClient.bind(this));
|
|
49
49
|
this.fileNet.on("notify-transfer-barrier", this.handleNotifyTransferBarrier.bind(this));
|
|
50
50
|
this.fileNet.on("send-current-transfer-state", this.handleSendCurrentTransferState.bind(this));
|
|
51
|
+
this.fileNet.on("sent-file-list-to-client", this.handleSentFileListToClient.bind(this));
|
|
51
52
|
this.fileNet.on("send-file-list-to-client", this.handleSendFileListToClient.bind(this));
|
|
52
53
|
this.fileNet.on("list-client-files", this.handleListClientFiles.bind(this));
|
|
53
54
|
this.fileNet.on("transfer-start", this.handleFileTransferStart.bind(this));
|
|
@@ -144,6 +145,28 @@ class FileMessager {
|
|
|
144
145
|
} = transferData;
|
|
145
146
|
this.requestFromClient(requesterID, senderID, filePath, destinationPath);
|
|
146
147
|
}
|
|
148
|
+
handleSentFileListToClient(listData) {
|
|
149
|
+
const {
|
|
150
|
+
totalItemsSent,
|
|
151
|
+
recipientID,
|
|
152
|
+
senderID
|
|
153
|
+
} = listData;
|
|
154
|
+
try {
|
|
155
|
+
const recipientConnectionID = FileNetClientManager.getOnlineClient(recipientID).id;
|
|
156
|
+
const senderConnectionID = FileNetClientManager.getOnlineClient(senderID).id;
|
|
157
|
+
const senderClient = this.getClientFromID(senderConnectionID);
|
|
158
|
+
const client = this.getClientFromID(recipientConnectionID);
|
|
159
|
+
if (!client || !senderClient) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.fileNet.emitToTide(client.tideID, "client-file-list-received", {
|
|
163
|
+
senderID,
|
|
164
|
+
totalItemsSent
|
|
165
|
+
});
|
|
166
|
+
} catch (error) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
147
170
|
handleSendFileListToClient(listData) {
|
|
148
171
|
const {
|
|
149
172
|
listedFiles,
|
|
@@ -25,11 +25,20 @@ class FileMessagerClient {
|
|
|
25
25
|
constructor(options = {}, transportOptions = {
|
|
26
26
|
parallelChunks: 3,
|
|
27
27
|
maxRetries: 3
|
|
28
|
+
}, messagerSettings = {
|
|
29
|
+
maxReconnectionAttempts: 5,
|
|
30
|
+
reconnectionAttempts: 5,
|
|
31
|
+
maxReconnectionDelay: 10000
|
|
28
32
|
}) {
|
|
33
|
+
const {
|
|
34
|
+
maxReconnectionAttempts = 15,
|
|
35
|
+
reconnectionAttempts = 15,
|
|
36
|
+
maxReconnectionDelay = 10000
|
|
37
|
+
} = messagerSettings;
|
|
29
38
|
this.clientOptions = FileMessagerConfigManager.getClientOptions(options);
|
|
30
39
|
this.transporter = new FileTransferManager(transportOptions);
|
|
31
40
|
this.activeTransferTypes = new Map();
|
|
32
|
-
this.clientTide = new HUDIoTide();
|
|
41
|
+
this.clientTide = new HUDIoTide(maxReconnectionAttempts, reconnectionAttempts, maxReconnectionDelay);
|
|
33
42
|
this.clients = new Map();
|
|
34
43
|
}
|
|
35
44
|
createClientInstance(clientID, clientOptions, options = {}, headers = {}, onConnect = null, onDisconnect = null, authURL = "", authHeaders = {}, useAuthentication = false, queryAuthToken = false) {
|
package/dist/cjs/FileTide.js
CHANGED
|
@@ -4,6 +4,9 @@ var _FileTide;
|
|
|
4
4
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
5
5
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
6
6
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
7
|
+
const {
|
|
8
|
+
HUDUtilityManager
|
|
9
|
+
} = require("@trap_stevo/legendarybuilderpronodejs-utilities");
|
|
7
10
|
const chalk = require("chalk");
|
|
8
11
|
const path = require("path");
|
|
9
12
|
const fs = require("fs");
|
|
@@ -68,6 +71,8 @@ class FileTide {
|
|
|
68
71
|
* Initialize and start a new client for each user.
|
|
69
72
|
* @param {Object} clientOptions - Configuration for client (e.g., serverUrl)
|
|
70
73
|
* @param {Object} connectionOptions - Configuration for the client connection
|
|
74
|
+
* @param {Object} transportOptions - Configuration for the file transporter
|
|
75
|
+
* @param {Object} messagerSettings - Configuration for the messager
|
|
71
76
|
* @param {String} roomName - The name of the room to join
|
|
72
77
|
* @param {String} userID - The ID of the client user
|
|
73
78
|
* @param {Function} onLaunch - Callback for when a file messager launches
|
|
@@ -85,11 +90,18 @@ class FileTide {
|
|
|
85
90
|
* @param {Boolean} [useAuthentication=true] - Whether to enable connection authentication
|
|
86
91
|
* @param {Boolean} [queryAuthToken=false] - Whether to enable connection authentication tokens
|
|
87
92
|
*/
|
|
88
|
-
launchMessager(clientOptions = {}, connectionOptions = {},
|
|
93
|
+
launchMessager(clientOptions = {}, connectionOptions = {}, transportOptions = {
|
|
94
|
+
parallelChunks: 3,
|
|
95
|
+
maxRetries: 3
|
|
96
|
+
}, messagerSettings = {
|
|
97
|
+
maxReconnectionAttempts: 15,
|
|
98
|
+
reconnectionAttempts: 15,
|
|
99
|
+
maxReconnectionDelay: 10000
|
|
100
|
+
}, roomName, userID, onLaunch, onIncomingFile, onIncomingTransfer, onTransferBarrier, onTransferProgress, enableTransferBarrier = true, options = {}, headers = {}, onConnect = null, onDisconnect = null, authURL = "", authHeaders = {}, useAuthentication = false, queryAuthToken = false) {
|
|
89
101
|
if (this.clients.has(userID)) {
|
|
90
102
|
this.stopMessager(userID);
|
|
91
103
|
}
|
|
92
|
-
const newClient = new FileMessagerClient(clientOptions);
|
|
104
|
+
const newClient = new FileMessagerClient(clientOptions, transportOptions, messagerSettings);
|
|
93
105
|
const enterRoom = newClient.joinRoom(userID, roomName, connectionOptions, headers, onConnect, onDisconnect, authURL, authHeaders, useAuthentication, queryAuthToken);
|
|
94
106
|
this.transferBarrier = enableTransferBarrier;
|
|
95
107
|
this.clientShorePolicies.set(userID, [FileUtilityManager.getTidePath(">CurrentUser"), FileUtilityManager.getTidePath(">Downloads"), FileUtilityManager.getTidePath(">Documents")]);
|
|
@@ -275,6 +287,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
275
287
|
onTransferRequested,
|
|
276
288
|
onTransferStatus,
|
|
277
289
|
onListFiles,
|
|
290
|
+
onFileListReceived,
|
|
278
291
|
onCurrentOnlineClients,
|
|
279
292
|
onClientTiding,
|
|
280
293
|
onCurrentClientIDAlreadyOnline
|
|
@@ -516,10 +529,12 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
516
529
|
client.clientTide.onEvent(userID, "list-files", async data => {
|
|
517
530
|
_FileTide.outputGradient(`[${userID}] Sending file list to ${data.senderID}...!`, significantMessageColors);
|
|
518
531
|
const currentClientShorePolicies = this.getShorePolicies(userID);
|
|
532
|
+
let totalFilesSent = 0;
|
|
519
533
|
const listedFiles = await this.listFiles(currentClientShorePolicies || [">Downloads"], data.depth || 1, (totalItems, directoryContents) => {
|
|
520
534
|
const capacitor = new ChunkCapacitor(directoryContents, 100);
|
|
521
535
|
const contents = capacitor.getAllChunks();
|
|
522
536
|
for (let files of contents) {
|
|
537
|
+
totalFilesSent += files.length;
|
|
523
538
|
client.clientTide.emitEvent(userID, "send-file-list-to-client", {
|
|
524
539
|
senderID: data.recipientID,
|
|
525
540
|
recipientID: data.senderID,
|
|
@@ -530,13 +545,24 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
530
545
|
});
|
|
531
546
|
setTimeout(() => {
|
|
532
547
|
_FileTide.outputGradient(`[${userID}] Sent file list to ${data.senderID}!`, significantMessageColors);
|
|
548
|
+
client.clientTide.emitEvent(userID, "sent-file-list-to-client", {
|
|
549
|
+
senderID: data.recipientID,
|
|
550
|
+
recipientID: data.senderID,
|
|
551
|
+
totalItemsSent: totalFilesSent
|
|
552
|
+
});
|
|
533
553
|
}, 1000);
|
|
534
554
|
});
|
|
535
555
|
client.clientTide.onEvent(userID, "error", async error => {
|
|
536
556
|
_FileTide.outputGradient(`[${userID} | FileTide Error] ${error}`, errorMessageColors);
|
|
537
557
|
});
|
|
558
|
+
client.clientTide.onEvent(userID, "client-file-list-received", async data => {
|
|
559
|
+
_FileTide.outputGradient(`[${userID}] Successfully received all ${HUDUtilityManager.convertNumberToMoneyFormat(data.totalItemsSent, false)} contents in ${data.senderID}'s file list!`, significantMessageColors);
|
|
560
|
+
if (onFileListReceived) {
|
|
561
|
+
onFileListReceived(data);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
538
564
|
client.clientTide.onEvent(userID, "client-file-list", async data => {
|
|
539
|
-
_FileTide.outputGradient(`[${userID}] Received ${data.totalItems} directory contents from ${data.senderID}'s file list!`, significantMessageColors);
|
|
565
|
+
_FileTide.outputGradient(`[${userID}] Received ${HUDUtilityManager.convertNumberToMoneyFormat(data.totalItems, false)} directory contents from ${data.senderID}'s file list!`, significantMessageColors);
|
|
540
566
|
if (onListFiles) {
|
|
541
567
|
onListFiles(data);
|
|
542
568
|
}
|
|
@@ -117,7 +117,7 @@ class FileUtilityManager {
|
|
|
117
117
|
};
|
|
118
118
|
results.push(dirMetadata);
|
|
119
119
|
const processEntries = list.map(async file => {
|
|
120
|
-
const filePath = path.join(dir, file.name);
|
|
120
|
+
const filePath = FileUtilityManager.getTidePath(path.join(dir, file.name));
|
|
121
121
|
try {
|
|
122
122
|
if (file.isDirectory()) {
|
|
123
123
|
console.log(`[FileTide] Depth >> ${currentDepth} | Including directory ~ ${filePath}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "Revolutionizing real-time file transfer with seamless, instant communication across any device. Deliver files instantly, regardless of platform, and experience unparalleled speed and control in managing transfers. Elevate your file-sharing capabilities with a tool designed for precision, efficiency, and effortless connectivity.",
|
|
5
5
|
"main": "dist/cjs/FileTide.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@trap_stevo/iotide": "^0.0.37",
|
|
33
33
|
"@trap_stevo/iotide-client": "^0.0.23",
|
|
34
|
-
"@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.
|
|
34
|
+
"@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.43",
|
|
35
35
|
"chalk": "^4.1.2",
|
|
36
36
|
"readline": "^1.3.0"
|
|
37
37
|
},
|