@trap_stevo/filetide 0.0.51 → 0.0.52
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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
4
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
5
|
+
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"); }
|
|
3
6
|
const {
|
|
4
7
|
OmniMap
|
|
5
8
|
} = require("@trap_stevo/legendarybuilderpronodejs-utilities/HUDStructs");
|
|
@@ -7,6 +10,9 @@ const IoTide = require("@trap_stevo/iotide");
|
|
|
7
10
|
const {
|
|
8
11
|
FileMessagerConfigManager
|
|
9
12
|
} = require("./HUDManagers/FileMessagerConfigManager");
|
|
13
|
+
const {
|
|
14
|
+
FileNetUtilityManager
|
|
15
|
+
} = require("./HUDManagers/FileNetUtilityManager");
|
|
10
16
|
const {
|
|
11
17
|
FileNetClientManager
|
|
12
18
|
} = require("./HUDManagers/FileNetClientManager");
|
|
@@ -14,6 +20,7 @@ const {
|
|
|
14
20
|
FileTransferManager
|
|
15
21
|
} = require("./HUDManagers/FileTransferManager");
|
|
16
22
|
const HUDTargetQueue = require("./HUDManagers/HUDTargetQueueManager");
|
|
23
|
+
var _FileMessager_brand = /*#__PURE__*/new WeakSet();
|
|
17
24
|
class FileMessager {
|
|
18
25
|
constructor(options = {
|
|
19
26
|
pingTimeout: 3600000,
|
|
@@ -21,7 +28,8 @@ class FileMessager {
|
|
|
21
28
|
}, transportOptions = {
|
|
22
29
|
parallelChunks: 3,
|
|
23
30
|
maxRetries: 3
|
|
24
|
-
}) {
|
|
31
|
+
}, debugMode = false) {
|
|
32
|
+
_classPrivateMethodInitSpec(this, _FileMessager_brand);
|
|
25
33
|
const serverOptions = FileMessagerConfigManager.getServerOptions(options);
|
|
26
34
|
this.transporter = new FileTransferManager(transportOptions);
|
|
27
35
|
this.transferQueue = new HUDTargetQueue();
|
|
@@ -30,6 +38,7 @@ class FileMessager {
|
|
|
30
38
|
this.currentTidingTransfers = new Map();
|
|
31
39
|
this.fileNet = new IoTide(serverOptions.port, serverOptions, true, this.onConnect.bind(this), this.onDisconnect.bind(this));
|
|
32
40
|
this.onlineClients = new OmniMap();
|
|
41
|
+
this.debugMode = debugMode;
|
|
33
42
|
return;
|
|
34
43
|
}
|
|
35
44
|
onConnect(socket) {
|
|
@@ -46,6 +55,7 @@ class FileMessager {
|
|
|
46
55
|
this.fileNet.on("get-client-transfer-barrier-response", this.handleClientTransferBarrierResponse.bind(this));
|
|
47
56
|
this.fileNet.on("get-client-transfer-state", this.handleGetClientTransferState.bind(this));
|
|
48
57
|
this.fileNet.on("get-client", this.handleGetClient.bind(this));
|
|
58
|
+
this.fileNet.on("acknowledge-transfer-tide", this.handleAcknowledgeTransferTide.bind(this));
|
|
49
59
|
this.fileNet.on("notify-transfer-barrier", this.handleNotifyTransferBarrier.bind(this));
|
|
50
60
|
this.fileNet.on("send-current-transfer-state", this.handleSendCurrentTransferState.bind(this));
|
|
51
61
|
this.fileNet.on("sent-file-list-to-client", this.handleSentFileListToClient.bind(this));
|
|
@@ -121,7 +131,7 @@ class FileMessager {
|
|
|
121
131
|
path: filePath,
|
|
122
132
|
fileSize
|
|
123
133
|
});
|
|
124
|
-
|
|
134
|
+
_assertClassBrand(_FileMessager_brand, this, _log).call(this, `[FileTide ~ File Messager] ~ Sent chunk ${chunkIndex} of ${fileName} to client ~ ${clientData.userID}!`);
|
|
125
135
|
if (senderClient) {
|
|
126
136
|
this.fileNet.emitToTide(senderClient.tideID, "transfer-status", {
|
|
127
137
|
status: `Chunk ${chunkIndex} of ${fileName} sent to client ${clientData.userID}!`,
|
|
@@ -233,7 +243,7 @@ class FileMessager {
|
|
|
233
243
|
completedChunks,
|
|
234
244
|
totalChunks
|
|
235
245
|
} = chunkData;
|
|
236
|
-
|
|
246
|
+
_assertClassBrand(_FileMessager_brand, this, _log).call(this, `[FileTide ~ File Messager] ~ Transferring file ~ ${fileName} | chunk ${chunkIndex + 1} >> ${completedChunks} of ${totalChunks} to client (${recipientId})`);
|
|
237
247
|
const recipientClient = FileNetClientManager.getOnlineClient(recipientId);
|
|
238
248
|
const senderClient = FileNetClientManager.getOnlineClient(senderID);
|
|
239
249
|
this.sendFileChunkToClient({
|
|
@@ -277,7 +287,7 @@ class FileMessager {
|
|
|
277
287
|
completedChunks,
|
|
278
288
|
totalChunks
|
|
279
289
|
} = transferData;
|
|
280
|
-
|
|
290
|
+
_assertClassBrand(_FileMessager_brand, this, _log).call(this, `[FileTide ~ File Messager] ~ Transferring file ~ ${fileName} | chunk ${chunkIndex + 1} >> ${completedChunks} of ${totalChunks} to client (${recipientId})`);
|
|
281
291
|
const recipientClient = FileNetClientManager.getOnlineClient(recipientId);
|
|
282
292
|
const senderClient = FileNetClientManager.getOnlineClient(senderID);
|
|
283
293
|
this.sendFileChunkToClient({
|
|
@@ -397,6 +407,13 @@ class FileMessager {
|
|
|
397
407
|
return;
|
|
398
408
|
}
|
|
399
409
|
}
|
|
410
|
+
handleAcknowledgeTransferTide(data) {
|
|
411
|
+
try {
|
|
412
|
+
console.log(`[FileTide ~ Net Activity] ~ ${data.recipientName} acknowledged tide transfer from ${data.senderName}.\n\n\t~ [${data.fileName}-${data.transferStats.startTime}] ~\n\n\t\tFile Name ~ ${data.fileName}\n\t\tDestination ~ ${data.path}\n\n\t\t\tProgress ~ ${data.transferStats.progress.toFixed(2)}%\n\t\t\tETA ~ ${data.transferStats.timeLeft <= 0 ? "Now" : FileNetUtilityManager.convertSeconds(data.transferStats.timeLeft.toFixed(2))}\n\t\t\tSpeed ~ ${FileNetUtilityManager.getFormattedSize(data.transferStats.speed, true)}/s\n\t\t\tSize ~ ${FileNetUtilityManager.getFormattedSize(data.transferStats.totalSize, true)}\n\t\t\tTransferred ~ ${FileNetUtilityManager.getFormattedSize(data.transferStats.current, true)}\n`);
|
|
413
|
+
} catch (error) {
|
|
414
|
+
console.log(`[FileTide ~ Net Activity] ~ ${data.recipientName} acknowledged tide transfer from ${data.senderName}.\n\n${error}`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
400
417
|
handleNotifyTransferBarrier(data, emitToChannel) {
|
|
401
418
|
const accepted = data.accepted;
|
|
402
419
|
const transferID = data.data.transferID;
|
|
@@ -552,5 +569,11 @@ class FileMessager {
|
|
|
552
569
|
}
|
|
553
570
|
}
|
|
554
571
|
}
|
|
572
|
+
function _log(...message) {
|
|
573
|
+
if (!this.debugMode) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
console.log(...message);
|
|
577
|
+
}
|
|
555
578
|
;
|
|
556
579
|
module.exports = FileMessager;
|
package/dist/cjs/FileTide.js
CHANGED
|
@@ -474,8 +474,16 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
474
474
|
};
|
|
475
475
|
currentTransferState.transferredSize += data.chunkSize || 512 * 1024;
|
|
476
476
|
FileTransferRecoveryManager.saveTransferState(userID, data.senderName, `${data.path}-${data.fileName}`, data.chunkIndex, currentTransferState.transferredSize);
|
|
477
|
+
const taskBarStats = this.progressBarManager.getTaskBar(data.fileName);
|
|
478
|
+
client.clientTide.emitEvent(userID, "acknowledge-transfer-tide", {
|
|
479
|
+
fileName: data.fileName,
|
|
480
|
+
senderName: data.senderName,
|
|
481
|
+
recipientName: userID,
|
|
482
|
+
transferStateID: `${data.path}-${data.fileName}`,
|
|
483
|
+
path: data.path,
|
|
484
|
+
transferStats: taskBarStats
|
|
485
|
+
});
|
|
477
486
|
if (onTransferProgress) {
|
|
478
|
-
const taskBarStats = this.progressBarManager.getTaskBar(data.fileName);
|
|
479
487
|
onTransferProgress({
|
|
480
488
|
...data,
|
|
481
489
|
stats: taskBarStats
|
|
@@ -508,7 +516,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
508
516
|
client.clientTide.onEvent(userID, "transfer-complete", data => {
|
|
509
517
|
const savePath = FileUtilityManager.getTidePath(path.join(data.filePath, data.fileName));
|
|
510
518
|
try {
|
|
511
|
-
_FileTide.outputGradient(`[${userID}] File transfer complete
|
|
519
|
+
_FileTide.outputGradient(`[${userID}] File transfer complete ~ ${data.fileName}`, significantMessageColors);
|
|
512
520
|
const transferState = fileTransferReceiver.activeTransfers.get(data.fileName);
|
|
513
521
|
if (!transferState) {
|
|
514
522
|
return;
|
|
@@ -516,9 +524,9 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
516
524
|
fileTransferReceiver.completeTransfer(data, (transferData, transfers, success, error) => {
|
|
517
525
|
if (success) {
|
|
518
526
|
FileTransferRecoveryManager.clearTransferState(userID, data.senderID, `${data.filePath}-${data.fileName}`);
|
|
519
|
-
_FileTide.outputGradient(`[${userID}] File saved at
|
|
527
|
+
_FileTide.outputGradient(`[${userID}] File saved at ~ ${savePath}\n`, significantMessageColors);
|
|
520
528
|
} else if (!success) {
|
|
521
|
-
_FileTide.outputGradient(`[${userID}] Did not save file at
|
|
529
|
+
_FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n\t${error}\n`, errorMessageColors);
|
|
522
530
|
}
|
|
523
531
|
if (onTransferComplete) {
|
|
524
532
|
const taskBarStats = this.progressBarManager.getTaskBar(data.fileName);
|
|
@@ -527,9 +535,12 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
527
535
|
stats: taskBarStats
|
|
528
536
|
}, fileTransferReceiver.activeTransfers, success);
|
|
529
537
|
}
|
|
538
|
+
setTimeout(() => {
|
|
539
|
+
this.progressBarManager.clearTaskBar(data.fileName);
|
|
540
|
+
}, this.progressBarManager.completionTimeout);
|
|
530
541
|
});
|
|
531
542
|
} catch (error) {
|
|
532
|
-
_FileTide.outputGradient(`[${userID}] Did not save file at
|
|
543
|
+
_FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n${error}`, errorMessageColors);
|
|
533
544
|
if (onTransferComplete) {
|
|
534
545
|
const taskBarStats = this.progressBarManager.getTaskBar(data.fileName);
|
|
535
546
|
onTransferComplete({
|
|
@@ -537,6 +548,9 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
537
548
|
stats: taskBarStats
|
|
538
549
|
}, fileTransferReceiver.activeTransfers, false);
|
|
539
550
|
}
|
|
551
|
+
setTimeout(() => {
|
|
552
|
+
this.progressBarManager.clearTaskBar(data.fileName);
|
|
553
|
+
}, this.progressBarManager.completionTimeout);
|
|
540
554
|
}
|
|
541
555
|
});
|
|
542
556
|
client.clientTide.onEvent(userID, "transfer-requested", async data => {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const readline = require("readline");
|
|
4
4
|
const chalk = require("chalk");
|
|
5
|
+
const {
|
|
6
|
+
FileNetUtilityManager
|
|
7
|
+
} = require("../HUDManagers/FileNetUtilityManager");
|
|
5
8
|
class ConsoleProgressBarManager {
|
|
6
9
|
constructor(tasks = [], options = {}) {
|
|
7
10
|
const rows = process.stdout.rows || 24;
|
|
@@ -20,41 +23,6 @@ class ConsoleProgressBarManager {
|
|
|
20
23
|
this.allTasksCompleted = false;
|
|
21
24
|
this.taskBars = tasks.map((task, index) => this.createTaskBar(task, index));
|
|
22
25
|
}
|
|
23
|
-
convertSeconds(seconds) {
|
|
24
|
-
if (seconds === 0) return "0 s";
|
|
25
|
-
const units = [{
|
|
26
|
-
name: "y",
|
|
27
|
-
seconds: 60 * 60 * 24 * 365
|
|
28
|
-
}, {
|
|
29
|
-
name: "mo",
|
|
30
|
-
seconds: 60 * 60 * 24 * 30
|
|
31
|
-
}, {
|
|
32
|
-
name: "w",
|
|
33
|
-
seconds: 60 * 60 * 24 * 7
|
|
34
|
-
}, {
|
|
35
|
-
name: "d",
|
|
36
|
-
seconds: 60 * 60 * 24
|
|
37
|
-
}, {
|
|
38
|
-
name: "h",
|
|
39
|
-
seconds: 60 * 60
|
|
40
|
-
}, {
|
|
41
|
-
name: "m",
|
|
42
|
-
seconds: 60
|
|
43
|
-
}, {
|
|
44
|
-
name: "s",
|
|
45
|
-
seconds: 1
|
|
46
|
-
}];
|
|
47
|
-
let remainingSeconds = seconds;
|
|
48
|
-
let result = "";
|
|
49
|
-
for (const unit of units) {
|
|
50
|
-
const count = Math.floor(remainingSeconds / unit.seconds);
|
|
51
|
-
if (count > 0) {
|
|
52
|
-
result += `${count}${unit.name} `;
|
|
53
|
-
remainingSeconds %= unit.seconds;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return result.trim();
|
|
57
|
-
}
|
|
58
26
|
createTaskBar(task, index) {
|
|
59
27
|
const defaultOptions = {
|
|
60
28
|
barLength: 40,
|
|
@@ -81,32 +49,6 @@ class ConsoleProgressBarManager {
|
|
|
81
49
|
startTime: Date.now(),
|
|
82
50
|
taskIndex: index,
|
|
83
51
|
completed: false,
|
|
84
|
-
getFormattedSize: size => {
|
|
85
|
-
if (!settings.dynamicUnits) return `${size.toFixed(1)} B`;
|
|
86
|
-
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
87
|
-
let unitIndex = 0;
|
|
88
|
-
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
89
|
-
size /= 1024;
|
|
90
|
-
unitIndex++;
|
|
91
|
-
}
|
|
92
|
-
return `${size.toFixed(2)} ${units[unitIndex]}`;
|
|
93
|
-
},
|
|
94
|
-
getUnitData: size => {
|
|
95
|
-
if (!settings.dynamicUnits) return {
|
|
96
|
-
current: size.toFixed(1),
|
|
97
|
-
unit: "B"
|
|
98
|
-
};
|
|
99
|
-
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
100
|
-
let unitIndex = 0;
|
|
101
|
-
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
102
|
-
size /= 1024;
|
|
103
|
-
unitIndex++;
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
current: size.toFixed(2),
|
|
107
|
-
unit: units[unitIndex]
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
52
|
redraw: () => {
|
|
111
53
|
if (!isNaN(newBar.taskIndex) && !isNaN(this.barsPerPage) && process.stdout.isTTY) {
|
|
112
54
|
readline.cursorTo(process.stdout, 0, newBar.taskIndex % this.barsPerPage);
|
|
@@ -119,7 +61,7 @@ class ConsoleProgressBarManager {
|
|
|
119
61
|
const percentage = newBar.current / newBar.totalSize * 100;
|
|
120
62
|
const elapsedTime = (Date.now() - newBar.startTime) / 1000;
|
|
121
63
|
const speed = newBar.current / elapsedTime;
|
|
122
|
-
const speedData =
|
|
64
|
+
const speedData = FileNetUtilityManager.getFormattedSize(speed, settings.dynamicUnits);
|
|
123
65
|
const timeLeft = (newBar.totalSize - newBar.current) / (speed || 1);
|
|
124
66
|
newBar.progress = percentage;
|
|
125
67
|
newBar.timeLeft = timeLeft;
|
|
@@ -127,7 +69,7 @@ class ConsoleProgressBarManager {
|
|
|
127
69
|
const filledLength = Math.round(settings.barLength * (newBar.current / newBar.totalSize));
|
|
128
70
|
const bar = settings.barColor(settings.filledChar.repeat(filledLength)) + settings.unfilledChar.repeat(settings.barLength - filledLength);
|
|
129
71
|
try {
|
|
130
|
-
process.stdout.write(`${settings.taskNameColor(newBar.taskName)} > ${settings.totalSizeColor(
|
|
72
|
+
process.stdout.write(`${settings.taskNameColor(newBar.taskName)} > ${settings.totalSizeColor(FileNetUtilityManager.getFormattedSize(newBar.totalSize, settings.dynamicUnits))} | ${settings.sizeTransferredColor(FileNetUtilityManager.getFormattedSize(newBar.current, settings.dynamicUnits))} ${settings.speedColor(`${speedData}/s`)} | ${settings.taskETAColor(FileNetUtilityManager.convertSeconds(timeLeft.toFixed(2)))} [${bar}] ${settings.percentageColor(percentage.toFixed(2) + "%")}`);
|
|
131
73
|
} catch (error) {
|
|
132
74
|
console.log(error);
|
|
133
75
|
}
|
|
@@ -220,10 +162,10 @@ class ConsoleProgressBarManager {
|
|
|
220
162
|
taskName: bar.taskName,
|
|
221
163
|
progress: `${(bar.current / bar.totalSize * 100).toFixed(2)}%`,
|
|
222
164
|
completed: bar.completed,
|
|
223
|
-
currentSize:
|
|
224
|
-
totalSize:
|
|
225
|
-
speed: `${
|
|
226
|
-
timeLeft:
|
|
165
|
+
currentSize: FileNetUtilityManager.getFormattedSize(bar.current, true),
|
|
166
|
+
totalSize: FileNetUtilityManager.getFormattedSize(bar.totalSize, true),
|
|
167
|
+
speed: `${FileNetUtilityManager.getUnitData(bar.speed, true).current} ${FileNetUtilityManager.getUnitData(bar.speed, true).unit}/s`,
|
|
168
|
+
timeLeft: FileNetUtilityManager.convertSeconds(bar.timeLeft.toFixed(2))
|
|
227
169
|
}))
|
|
228
170
|
};
|
|
229
171
|
return stats;
|
|
@@ -17,6 +17,67 @@ class FileNetUtilityManager {
|
|
|
17
17
|
console.log(coloredText);
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
static convertSeconds(seconds) {
|
|
21
|
+
if (seconds === 0) return "0 s";
|
|
22
|
+
const units = [{
|
|
23
|
+
name: "y",
|
|
24
|
+
seconds: 60 * 60 * 24 * 365
|
|
25
|
+
}, {
|
|
26
|
+
name: "mo",
|
|
27
|
+
seconds: 60 * 60 * 24 * 30
|
|
28
|
+
}, {
|
|
29
|
+
name: "w",
|
|
30
|
+
seconds: 60 * 60 * 24 * 7
|
|
31
|
+
}, {
|
|
32
|
+
name: "d",
|
|
33
|
+
seconds: 60 * 60 * 24
|
|
34
|
+
}, {
|
|
35
|
+
name: "h",
|
|
36
|
+
seconds: 60 * 60
|
|
37
|
+
}, {
|
|
38
|
+
name: "m",
|
|
39
|
+
seconds: 60
|
|
40
|
+
}, {
|
|
41
|
+
name: "s",
|
|
42
|
+
seconds: 1
|
|
43
|
+
}];
|
|
44
|
+
let remainingSeconds = seconds;
|
|
45
|
+
let result = "";
|
|
46
|
+
for (const unit of units) {
|
|
47
|
+
const count = Math.floor(remainingSeconds / unit.seconds);
|
|
48
|
+
if (count > 0) {
|
|
49
|
+
result += `${count}${unit.name} `;
|
|
50
|
+
remainingSeconds %= unit.seconds;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result.trim();
|
|
54
|
+
}
|
|
55
|
+
static getFormattedSize(size, dynamicUnits = true) {
|
|
56
|
+
if (!dynamicUnits) return `${size.toFixed(1)} B`;
|
|
57
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
58
|
+
let unitIndex = 0;
|
|
59
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
60
|
+
size /= 1024;
|
|
61
|
+
unitIndex++;
|
|
62
|
+
}
|
|
63
|
+
return `${size.toFixed(2)} ${units[unitIndex]}`;
|
|
64
|
+
}
|
|
65
|
+
static getUnitData(size, dynamicUnits = true) {
|
|
66
|
+
if (!dynamicUnits) return {
|
|
67
|
+
current: size.toFixed(1),
|
|
68
|
+
unit: "B"
|
|
69
|
+
};
|
|
70
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
71
|
+
let unitIndex = 0;
|
|
72
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
73
|
+
size /= 1024;
|
|
74
|
+
unitIndex++;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
current: size.toFixed(2),
|
|
78
|
+
unit: units[unitIndex]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
20
81
|
}
|
|
21
82
|
module.exports = {
|
|
22
83
|
FileNetUtilityManager,
|
|
@@ -77,16 +77,23 @@ class FileTransferManager {
|
|
|
77
77
|
} = await fileHandle.read(Buffer.alloc(end - start), 0, end - start, start);
|
|
78
78
|
const transferState = this.activeTransfers.get(transferId);
|
|
79
79
|
chunkBuffer.set(chunkIndex, buffer);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
try {
|
|
81
|
+
while (chunkBuffer.has(nextExpectedChunk)) {
|
|
82
|
+
const nextChunkBuffer = chunkBuffer.get(nextExpectedChunk);
|
|
83
|
+
await onSendChunk(transferId, nextExpectedChunk, this.chunkSize, nextChunkBuffer, totalChunks, this.activeTransfers.get(transferId).completedChunks + 1);
|
|
84
|
+
chunkBuffer.delete(nextExpectedChunk);
|
|
85
|
+
nextExpectedChunk++;
|
|
86
|
+
transferState.transferredSize += this.chunkSize;
|
|
87
|
+
transferState.completedChunks++;
|
|
88
|
+
updateProgress();
|
|
89
|
+
}
|
|
90
|
+
if (transferState.completedChunks === transferState.totalChunks) {
|
|
91
|
+
return onComplete(transferId).then(() => {
|
|
92
|
+
this.activeTransfers.delete(transferId);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error(`[FileTide ~ Transporter] ~ Did not send chunk ${chunkIndex} ~ ${error.message}`);
|
|
90
97
|
return onComplete(transferId).then(() => {
|
|
91
98
|
this.activeTransfers.delete(transferId);
|
|
92
99
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.52",
|
|
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": {
|