@trap_stevo/filetide 0.0.43 → 0.0.45
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 +34 -14
- package/dist/cjs/FileMessagerClient.js +3 -3
- package/dist/cjs/FileTide.js +17 -0
- package/dist/cjs/HUDManagers/FileTransferManager.js +2 -1
- package/dist/cjs/HUDManagers/FileTransferRecoveryManager.js +3 -3
- package/dist/cjs/HUDManagers/FileUtilityManager.js +1 -1
- package/package.json +1 -1
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,
|
|
@@ -236,7 +259,7 @@ class FileMessager {
|
|
|
236
259
|
console.log(`[FileTide ~ File Messager] ~ File transfer completed: ${fileName} from ${senderID} to ${recipientId}`);
|
|
237
260
|
const tidingTransfers = this.currentTidingTransfers.get(senderID);
|
|
238
261
|
if (tidingTransfers) {
|
|
239
|
-
tidingTransfers.delete(
|
|
262
|
+
tidingTransfers.delete(senderID);
|
|
240
263
|
}
|
|
241
264
|
}
|
|
242
265
|
}
|
|
@@ -280,7 +303,7 @@ class FileMessager {
|
|
|
280
303
|
console.log(`[FileTide ~ File Messager] ~ File transfer completed: ${fileName} from ${senderID} to ${recipientId}`);
|
|
281
304
|
const tidingTransfers = this.currentTidingTransfers.get(senderID);
|
|
282
305
|
if (tidingTransfers) {
|
|
283
|
-
tidingTransfers.delete(
|
|
306
|
+
tidingTransfers.delete(senderID);
|
|
284
307
|
}
|
|
285
308
|
}
|
|
286
309
|
} catch (error) {
|
|
@@ -490,26 +513,23 @@ class FileMessager {
|
|
|
490
513
|
const currentOnlineClients = Object.fromEntries(FileNetClientManager.getOnlineClients());
|
|
491
514
|
this.fileNet.emit("current-online-clients", currentOnlineClients);
|
|
492
515
|
this.fileNet.emit("current-clients", currentOnlineClients);
|
|
493
|
-
this.
|
|
516
|
+
const senderClient = this.getClientFromID(clientDetails.id);
|
|
517
|
+
this.fileNet.emitToTide(senderClient.tideID, "save-current-transfer-states", {
|
|
494
518
|
clientID: clientData.clientID
|
|
495
519
|
});
|
|
496
520
|
const tidingTransfers = this.currentTidingTransfers.get(clientData.clientID);
|
|
497
521
|
if (tidingTransfers && tidingTransfers.size > 0) {
|
|
498
522
|
for (let recipientID of tidingTransfers.keys()) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
} catch (error) {
|
|
508
|
-
console.log(`[FileTide ~ Net Activity] ~ Did not save current transfer state signal to ~ ${recipientID}\n\t${error}`);
|
|
523
|
+
const recipientConnectionID = FileNetClientManager.getOnlineClient(data.recipientID).id;
|
|
524
|
+
const client = this.getClientFromID(recipientConnectionID);
|
|
525
|
+
if (client) {
|
|
526
|
+
this.fileNet.emitToTide(client.tideID, "save-current-transfer-states", {
|
|
527
|
+
clientID: recipientID
|
|
528
|
+
});
|
|
509
529
|
}
|
|
510
530
|
}
|
|
531
|
+
this.currentTidingTransfers.delete(clientData.clientID);
|
|
511
532
|
}
|
|
512
|
-
this.currentTidingTransfers.delete(clientData.clientID);
|
|
513
533
|
} catch (error) {
|
|
514
534
|
console.log(`[FileTide ~ Net Activity] ~ Did not process client ~ ${clientData} offline signal ~ ${error}`);
|
|
515
535
|
}
|
|
@@ -189,7 +189,7 @@ class FileMessagerClient {
|
|
|
189
189
|
},
|
|
190
190
|
onComplete: () => {
|
|
191
191
|
return new Promise((resolve, reject) => {
|
|
192
|
-
FileTransferRecoveryManager.clearTransferState(
|
|
192
|
+
FileTransferRecoveryManager.clearTransferState(clientID, recipientId, `${filePath}-${fileName}`);
|
|
193
193
|
this.clientTide.emitEvent(clientID, "transfer-complete", {
|
|
194
194
|
senderID: clientID,
|
|
195
195
|
recipientId,
|
|
@@ -295,7 +295,7 @@ class FileMessagerClient {
|
|
|
295
295
|
});
|
|
296
296
|
chunkBatch.length = 0;
|
|
297
297
|
}
|
|
298
|
-
FileTransferRecoveryManager.clearTransferState(
|
|
298
|
+
FileTransferRecoveryManager.clearTransferState(clientID, recipientId, `${filePath}-${fileName}`);
|
|
299
299
|
this.clientTide.emitEvent(clientID, "transfer-complete", {
|
|
300
300
|
senderID: clientID,
|
|
301
301
|
recipientId,
|
|
@@ -360,7 +360,7 @@ class FileMessagerClient {
|
|
|
360
360
|
},
|
|
361
361
|
onComplete: () => {
|
|
362
362
|
return new Promise((resolve, reject) => {
|
|
363
|
-
FileTransferRecoveryManager.clearTransferState(
|
|
363
|
+
FileTransferRecoveryManager.clearTransferState(clientID, recipientId, `${filePath}-${fileName}`);
|
|
364
364
|
this.clientTide.emitEvent(clientID, "transfer-complete", {
|
|
365
365
|
senderID: clientID,
|
|
366
366
|
recipientId,
|
package/dist/cjs/FileTide.js
CHANGED
|
@@ -113,6 +113,9 @@ class FileTide {
|
|
|
113
113
|
getTidePath(inputPath) {
|
|
114
114
|
return FileUtilityManager.getTidePath(inputPath);
|
|
115
115
|
}
|
|
116
|
+
getTidingTransferStates() {
|
|
117
|
+
return FileTransferRecoveryManager.memoryStorage;
|
|
118
|
+
}
|
|
116
119
|
saveTransferStates() {
|
|
117
120
|
FileTransferRecoveryManager.flushToDisk();
|
|
118
121
|
}
|
|
@@ -272,6 +275,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
272
275
|
onTransferRequested,
|
|
273
276
|
onTransferStatus,
|
|
274
277
|
onListFiles,
|
|
278
|
+
onFileListReceived,
|
|
275
279
|
onCurrentOnlineClients,
|
|
276
280
|
onClientTiding,
|
|
277
281
|
onCurrentClientIDAlreadyOnline
|
|
@@ -513,6 +517,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
513
517
|
client.clientTide.onEvent(userID, "list-files", async data => {
|
|
514
518
|
_FileTide.outputGradient(`[${userID}] Sending file list to ${data.senderID}...!`, significantMessageColors);
|
|
515
519
|
const currentClientShorePolicies = this.getShorePolicies(userID);
|
|
520
|
+
let totalFilesSent = 0;
|
|
516
521
|
const listedFiles = await this.listFiles(currentClientShorePolicies || [">Downloads"], data.depth || 1, (totalItems, directoryContents) => {
|
|
517
522
|
const capacitor = new ChunkCapacitor(directoryContents, 100);
|
|
518
523
|
const contents = capacitor.getAllChunks();
|
|
@@ -524,14 +529,26 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
524
529
|
listedFiles: files
|
|
525
530
|
});
|
|
526
531
|
}
|
|
532
|
+
totalFilesSent += totalItems;
|
|
527
533
|
});
|
|
528
534
|
setTimeout(() => {
|
|
529
535
|
_FileTide.outputGradient(`[${userID}] Sent file list to ${data.senderID}!`, significantMessageColors);
|
|
536
|
+
client.clientTide.emitEvent(userID, "sent-file-list-to-client", {
|
|
537
|
+
senderID: data.recipientID,
|
|
538
|
+
recipientID: data.senderID,
|
|
539
|
+
totalItemsSent: totalFilesSent
|
|
540
|
+
});
|
|
530
541
|
}, 1000);
|
|
531
542
|
});
|
|
532
543
|
client.clientTide.onEvent(userID, "error", async error => {
|
|
533
544
|
_FileTide.outputGradient(`[${userID} | FileTide Error] ${error}`, errorMessageColors);
|
|
534
545
|
});
|
|
546
|
+
client.clientTide.onEvent(userID, "client-file-list-received", async data => {
|
|
547
|
+
_FileTide.outputGradient(`[${userID}] Successfully received all ${data.totalItemsSent} contents in ${data.senderID}'s file list!`, significantMessageColors);
|
|
548
|
+
if (onFileListReceived) {
|
|
549
|
+
onFileListReceived(data);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
535
552
|
client.clientTide.onEvent(userID, "client-file-list", async data => {
|
|
536
553
|
_FileTide.outputGradient(`[${userID}] Received ${data.totalItems} directory contents from ${data.senderID}'s file list!`, significantMessageColors);
|
|
537
554
|
if (onListFiles) {
|
|
@@ -178,6 +178,7 @@ async function _startTransfer(file, transferId, fileDetails, originDetails, onSe
|
|
|
178
178
|
transferState.activeChunks++;
|
|
179
179
|
try {
|
|
180
180
|
await onSendChunk(transferId, chunkIndex, this.chunkSize, chunk, transferState.totalChunks, transferState.completedChunks + 1);
|
|
181
|
+
transferState.transferredSize += this.chunkSize;
|
|
181
182
|
transferState.completedChunks++;
|
|
182
183
|
transferState.activeChunks--;
|
|
183
184
|
updateProgress();
|
|
@@ -190,7 +191,7 @@ async function _startTransfer(file, transferId, fileDetails, originDetails, onSe
|
|
|
190
191
|
resolve();
|
|
191
192
|
}
|
|
192
193
|
} catch (error) {
|
|
193
|
-
console.error(`Did not send chunk ${chunkIndex} ~ ${error.message}`);
|
|
194
|
+
console.error(`[FileTide ~ File Messager] ~ Did not send chunk ${chunkIndex} ~ ${error.message}`);
|
|
194
195
|
transferState.activeChunks--;
|
|
195
196
|
const retryCount = (transferState.failedChunks.get(chunkIndex) || 0) + 1;
|
|
196
197
|
if (retryCount > this.maxRetries) {
|
|
@@ -47,9 +47,9 @@ class FileTransferRecoveryManager {
|
|
|
47
47
|
if (transferState) {
|
|
48
48
|
try {
|
|
49
49
|
fs.writeFileSync(storageFile, JSON.stringify(transferState, null, 2));
|
|
50
|
-
console.log(`Saved transfer state to disk
|
|
50
|
+
console.log(`Saved transfer state to disk ~ ${storageFile}`);
|
|
51
51
|
} catch (error) {
|
|
52
|
-
console.error(`Error saving transfer state for ${key}
|
|
52
|
+
console.error(`Error saving transfer state for ${key} ~ ${error.message}`);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -84,7 +84,7 @@ class FileTransferRecoveryManager {
|
|
|
84
84
|
senderName,
|
|
85
85
|
filePath
|
|
86
86
|
} = state;
|
|
87
|
-
console.log("Saving current state ~ ",
|
|
87
|
+
console.log("Saving current state ~ ", key);
|
|
88
88
|
this.saveToDisk(clientName, senderName, filePath);
|
|
89
89
|
}
|
|
90
90
|
;
|
|
@@ -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.45",
|
|
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": {
|