@trap_stevo/filetide 0.0.89 → 0.0.91
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/FileTide.js +31 -19
- package/package.json +1 -1
package/dist/cjs/FileTide.js
CHANGED
|
@@ -436,7 +436,27 @@ class FileTide {
|
|
|
436
436
|
|
|
437
437
|
// --- FileTide Display Management ---
|
|
438
438
|
|
|
439
|
-
static
|
|
439
|
+
static setOutputHandler(handler = null) {
|
|
440
|
+
FileTide.outputHandler = typeof handler === "function" ? handler : null;
|
|
441
|
+
return FileTide.outputHandler;
|
|
442
|
+
}
|
|
443
|
+
static getOutputHandler() {
|
|
444
|
+
return FileTide.outputHandler;
|
|
445
|
+
}
|
|
446
|
+
static clearOutputHandler() {
|
|
447
|
+
FileTide.outputHandler = null;
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
static outputGradient(text, colors, metadata = {}) {
|
|
451
|
+
if (typeof FileTide.outputHandler === "function") {
|
|
452
|
+
FileTide.outputHandler({
|
|
453
|
+
text: String(text ?? ""),
|
|
454
|
+
colors,
|
|
455
|
+
type: "gradient",
|
|
456
|
+
metadata: metadata || {}
|
|
457
|
+
});
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
440
460
|
FileTideDebugUtilityManager.outputGradient(text, colors);
|
|
441
461
|
return;
|
|
442
462
|
}
|
|
@@ -584,7 +604,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
584
604
|
const {
|
|
585
605
|
currentSender
|
|
586
606
|
} = data;
|
|
587
|
-
if (currentSender && currentSender === userID) {
|
|
607
|
+
if (currentSender && currentSender === userID && displayTransferOutput) {
|
|
588
608
|
_FileTide.outputGradient(`[${userID}] Transfer successfully sent to ${data.recipientID}`, significantMessageColors);
|
|
589
609
|
return;
|
|
590
610
|
}
|
|
@@ -724,9 +744,6 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
724
744
|
client.clientTide.onEvent(userID, "transfer-complete", data => {
|
|
725
745
|
const savePath = FileUtilityManager.getTidePath(path.join(data.filePath, data.fileName));
|
|
726
746
|
try {
|
|
727
|
-
if (displayTransferOutput) {
|
|
728
|
-
_FileTide.outputGradient(`[${userID}] File transfer complete ~ ${data.fileName}`, significantMessageColors);
|
|
729
|
-
}
|
|
730
747
|
const transferState = FileTransferTrackingManager.getTransfer(data.fileName);
|
|
731
748
|
FileTideDebugUtilityManager.log("notice", true, `Transfer state ~ ${data.fileName} active | ${transferState !== null && transferState !== undefined ? true : false}`);
|
|
732
749
|
if (!transferState) {
|
|
@@ -734,11 +751,6 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
734
751
|
}
|
|
735
752
|
if (transferState.fileStream) {
|
|
736
753
|
fileTransferReceiver.completeTransfer(data, (transferData, transfers, success, error) => {
|
|
737
|
-
if (success && displayTransferOutput) {
|
|
738
|
-
_FileTide.outputGradient(`[${userID}] File saved at ~ ${savePath}\n`, significantMessageColors);
|
|
739
|
-
} else if (!success && displayTransferOutput) {
|
|
740
|
-
_FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n\t${error}\n`, errorMessageColors);
|
|
741
|
-
}
|
|
742
754
|
const transferStats = success ? this.transferStatsManager.completeTransfer(data.transferId || data.fileName) : this.transferStatsManager.failTransfer(data.transferId || data.fileName);
|
|
743
755
|
if (onTransferComplete) {
|
|
744
756
|
onTransferComplete({
|
|
@@ -746,15 +758,17 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
746
758
|
stats: transferStats
|
|
747
759
|
}, FileTransferTrackingManager.activeTransfers, success);
|
|
748
760
|
}
|
|
761
|
+
if (success && displayTransferOutput) {
|
|
762
|
+
_FileTide.outputGradient(`[${userID}] File saved at ~ ${savePath}\n`, significantMessageColors);
|
|
763
|
+
} else if (!success && displayTransferOutput) {
|
|
764
|
+
_FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n\t${error}\n`, errorMessageColors);
|
|
765
|
+
}
|
|
749
766
|
FileTransferTrackingManager.outputCurrentTransfers();
|
|
750
767
|
this.transferStatsManager.clearTransfer(data.transferId || data.fileName);
|
|
751
768
|
});
|
|
752
769
|
return;
|
|
753
770
|
}
|
|
754
771
|
FileTransferTrackingManager.untrackTransfer(data.fileName);
|
|
755
|
-
if (displayTransferOutput) {
|
|
756
|
-
_FileTide.outputGradient(`[${userID}] Transfer successfully sent to ~ ${data.recipientId} and saved at ~ ${path.join(data.filePath, data.fileName)}\n`, significantMessageColors);
|
|
757
|
-
}
|
|
758
772
|
const transferStats = this.transferStatsManager.completeTransfer(data.transferId || data.fileName);
|
|
759
773
|
if (onTransferComplete) {
|
|
760
774
|
onTransferComplete({
|
|
@@ -763,13 +777,11 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
763
777
|
}, FileTransferTrackingManager.activeTransfers, true);
|
|
764
778
|
}
|
|
765
779
|
if (displayTransferOutput) {
|
|
780
|
+
_FileTide.outputGradient(`[${userID}] Transfer successfully sent to ~ ${data.recipientId} and saved at ~ ${path.join(data.filePath, data.fileName)}\n`, significantMessageColors);
|
|
766
781
|
FileTransferTrackingManager.outputCurrentTransfers();
|
|
767
782
|
}
|
|
768
783
|
this.transferStatsManager.clearTransfer(data.transferId || data.fileName);
|
|
769
784
|
} catch (error) {
|
|
770
|
-
if (displayTransferOutput) {
|
|
771
|
-
_FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n${error}`, errorMessageColors);
|
|
772
|
-
}
|
|
773
785
|
const transferStats = this.transferStatsManager.failTransfer(data.transferId || data.fileName);
|
|
774
786
|
if (onTransferComplete) {
|
|
775
787
|
onTransferComplete({
|
|
@@ -778,6 +790,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
778
790
|
}, FileTransferTrackingManager.activeTransfers, false);
|
|
779
791
|
}
|
|
780
792
|
if (displayTransferOutput) {
|
|
793
|
+
_FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n${error}`, errorMessageColors);
|
|
781
794
|
FileTransferTrackingManager.outputCurrentTransfers();
|
|
782
795
|
}
|
|
783
796
|
this.transferStatsManager.clearTransfer(data.transferId || data.fileName);
|
|
@@ -785,9 +798,6 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
785
798
|
});
|
|
786
799
|
client.clientTide.onEvent(userID, "transfer-failed", async data => {
|
|
787
800
|
const transferState = FileTransferTrackingManager.getTransfer(data.fileName);
|
|
788
|
-
if (displayTransferOutput) {
|
|
789
|
-
_FileTide.outputGradient(`[${userID}] File transfer failed ~ ${data.fileName}${data.reason ? `\n${data.reason}` : ""}`, errorMessageColors);
|
|
790
|
-
}
|
|
791
801
|
if (transferState?.fileStream) {
|
|
792
802
|
try {
|
|
793
803
|
await new Promise(resolve => {
|
|
@@ -810,6 +820,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
810
820
|
onTransferComplete(failureData, FileTransferTrackingManager.activeTransfers, false);
|
|
811
821
|
}
|
|
812
822
|
if (displayTransferOutput) {
|
|
823
|
+
_FileTide.outputGradient(`[${userID}] File transfer failed ~ ${data.fileName}${data.reason ? `\n${data.reason}` : ""}`, errorMessageColors);
|
|
813
824
|
FileTransferTrackingManager.outputCurrentTransfers();
|
|
814
825
|
}
|
|
815
826
|
this.transferStatsManager.clearTransfer(data.transferId || data.fileName);
|
|
@@ -872,4 +883,5 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
872
883
|
return;
|
|
873
884
|
}
|
|
874
885
|
;
|
|
886
|
+
FileTide.outputHandler = null;
|
|
875
887
|
module.exports = FileTide;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.91",
|
|
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": {
|