@trap_stevo/filetide 0.0.88 → 0.0.89

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.
@@ -77,7 +77,7 @@ class FileMessagerClient {
77
77
  }, options, headers, onConnect, onDisconnect, authURL, authHeaders, useAuthentication, queryAuthToken);
78
78
  return () => {
79
79
  this.clientTide.joinChannel(socketName, roomName, userID, () => {
80
- FileTideDebugUtilityManager.outputGradient(`\n[FileTide ~ Tider] ~ Client ~ ${userID} joined room ${roomName} successfully!`, significantMessageColors);
80
+ FileTideDebugUtilityManager.outputGradient(`\n[FileTide ~ Tider] ~ ${userID} joined room ${roomName} successfully!`, significantMessageColors);
81
81
  this.clients.set(userID, {
82
82
  roomName
83
83
  });
@@ -363,7 +363,7 @@ function _createClientInstance(clientID, clientOptions, options = {}, headers =
363
363
  await onDisconnect(...disconnectArguments);
364
364
  }
365
365
  });
366
- FileTideDebugUtilityManager.outputGradient(`\n[FileTide ~ Tider] ~ Created client with ID ${clientID} and socket ${clientID}!`, significantMessageColors);
366
+ FileTideDebugUtilityManager.outputGradient(`\n[FileTide ~ Tider] ~ Created with ID '${clientID}' and origin '${clientID}'!`, significantMessageColors);
367
367
  return clientID;
368
368
  }
369
369
  function _getAdaptiveTideSize(chunkSize, tideSize = 500, minTideSize = 10, maxTideSize = 2000) {
@@ -373,11 +373,6 @@ function _getAdaptiveTideSize(chunkSize, tideSize = 500, minTideSize = 10, maxTi
373
373
  if (networkStatus.state === NETWORK_TRAFFIC_STATES.CONGESTED) {
374
374
  tideDurationMs *= 0.50;
375
375
  }
376
-
377
- /*
378
- * Determine how many chunks current network conditions
379
- * can reasonably support during one Tide duration.
380
- */
381
376
  const networkTideBytes = Math.max(sendRateBps * (tideDurationMs / 1000), chunkSize);
382
377
  const networkTideSize = Math.max(1, Math.floor(networkTideBytes / chunkSize));
383
378
  const normalizedMinTideSize = Math.max(1, minTideSize);
@@ -48,6 +48,8 @@ class FileTide {
48
48
  /**
49
49
  * Set up file transfer event listeners natively.
50
50
  * Automatically checks and creates directories as needed.
51
+ * @param {Object} [options = {}] - Additional messager and transfer lifecycle options.
52
+ * @param {Boolean} [options.displayTransferOutput=true] - Whether FileTide should render transfer lifecycle output directly to the terminal.
51
53
  */
52
54
  _classPrivateMethodInitSpec(this, _FileTide_brand);
53
55
  this.transferStatsManager = new FileTransferStatsManager();
@@ -463,7 +465,8 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
463
465
  onCurrentClientIDAlreadyOnline,
464
466
  onCurrentClientUnauthorized,
465
467
  onBeforeCurrentClientUnauthorizedDisconnect,
466
- onCurrentClientUnauthorizedDisconnect
468
+ onCurrentClientUnauthorizedDisconnect,
469
+ displayTransferOutput = true
467
470
  } = options;
468
471
  const fileTransferReceiver = new FileTransferReceiverManager();
469
472
  client.clientTide.onEvent(userID, "current-online-clients", data => {
@@ -721,7 +724,9 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
721
724
  client.clientTide.onEvent(userID, "transfer-complete", data => {
722
725
  const savePath = FileUtilityManager.getTidePath(path.join(data.filePath, data.fileName));
723
726
  try {
724
- _FileTide.outputGradient(`[${userID}] File transfer complete ~ ${data.fileName}`, significantMessageColors);
727
+ if (displayTransferOutput) {
728
+ _FileTide.outputGradient(`[${userID}] File transfer complete ~ ${data.fileName}`, significantMessageColors);
729
+ }
725
730
  const transferState = FileTransferTrackingManager.getTransfer(data.fileName);
726
731
  FileTideDebugUtilityManager.log("notice", true, `Transfer state ~ ${data.fileName} active | ${transferState !== null && transferState !== undefined ? true : false}`);
727
732
  if (!transferState) {
@@ -729,9 +734,9 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
729
734
  }
730
735
  if (transferState.fileStream) {
731
736
  fileTransferReceiver.completeTransfer(data, (transferData, transfers, success, error) => {
732
- if (success) {
737
+ if (success && displayTransferOutput) {
733
738
  _FileTide.outputGradient(`[${userID}] File saved at ~ ${savePath}\n`, significantMessageColors);
734
- } else if (!success) {
739
+ } else if (!success && displayTransferOutput) {
735
740
  _FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n\t${error}\n`, errorMessageColors);
736
741
  }
737
742
  const transferStats = success ? this.transferStatsManager.completeTransfer(data.transferId || data.fileName) : this.transferStatsManager.failTransfer(data.transferId || data.fileName);
@@ -747,7 +752,9 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
747
752
  return;
748
753
  }
749
754
  FileTransferTrackingManager.untrackTransfer(data.fileName);
750
- _FileTide.outputGradient(`[${userID}] Transfer successfully sent to ~ ${data.recipientId} and saved at ~ ${path.join(data.filePath, data.fileName)}\n`, significantMessageColors);
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
+ }
751
758
  const transferStats = this.transferStatsManager.completeTransfer(data.transferId || data.fileName);
752
759
  if (onTransferComplete) {
753
760
  onTransferComplete({
@@ -755,10 +762,14 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
755
762
  stats: transferStats
756
763
  }, FileTransferTrackingManager.activeTransfers, true);
757
764
  }
758
- FileTransferTrackingManager.outputCurrentTransfers();
765
+ if (displayTransferOutput) {
766
+ FileTransferTrackingManager.outputCurrentTransfers();
767
+ }
759
768
  this.transferStatsManager.clearTransfer(data.transferId || data.fileName);
760
769
  } catch (error) {
761
- _FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n${error}`, errorMessageColors);
770
+ if (displayTransferOutput) {
771
+ _FileTide.outputGradient(`[${userID}] Did not save file at ~ ${savePath}\n${error}`, errorMessageColors);
772
+ }
762
773
  const transferStats = this.transferStatsManager.failTransfer(data.transferId || data.fileName);
763
774
  if (onTransferComplete) {
764
775
  onTransferComplete({
@@ -766,13 +777,17 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
766
777
  stats: transferStats
767
778
  }, FileTransferTrackingManager.activeTransfers, false);
768
779
  }
769
- FileTransferTrackingManager.outputCurrentTransfers();
780
+ if (displayTransferOutput) {
781
+ FileTransferTrackingManager.outputCurrentTransfers();
782
+ }
770
783
  this.transferStatsManager.clearTransfer(data.transferId || data.fileName);
771
784
  }
772
785
  });
773
786
  client.clientTide.onEvent(userID, "transfer-failed", async data => {
774
787
  const transferState = FileTransferTrackingManager.getTransfer(data.fileName);
775
- _FileTide.outputGradient(`[${userID}] File transfer failed ~ ${data.fileName}${data.reason ? `\n${data.reason}` : ""}`, errorMessageColors);
788
+ if (displayTransferOutput) {
789
+ _FileTide.outputGradient(`[${userID}] File transfer failed ~ ${data.fileName}${data.reason ? `\n${data.reason}` : ""}`, errorMessageColors);
790
+ }
776
791
  if (transferState?.fileStream) {
777
792
  try {
778
793
  await new Promise(resolve => {
@@ -794,7 +809,9 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
794
809
  if (onTransferComplete) {
795
810
  onTransferComplete(failureData, FileTransferTrackingManager.activeTransfers, false);
796
811
  }
797
- FileTransferTrackingManager.outputCurrentTransfers();
812
+ if (displayTransferOutput) {
813
+ FileTransferTrackingManager.outputCurrentTransfers();
814
+ }
798
815
  this.transferStatsManager.clearTransfer(data.transferId || data.fileName);
799
816
  });
800
817
  client.clientTide.onEvent(userID, "transfer-requested", async data => {
@@ -838,7 +855,6 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
838
855
  _FileTide.outputGradient(`[${userID} | FileTide Error] ${error}`, errorMessageColors);
839
856
  });
840
857
  client.clientTide.onEvent(userID, "client-file-list-received", async data => {
841
- _FileTide.outputGradient(`[${userID}] Successfully received all ${HUDUtilityManager.convertNumberToMoneyFormat(data.totalItemsSent, false)} contents in ${data.senderID}'s file list!`, significantMessageColors);
842
858
  if (onFileListReceived) {
843
859
  onFileListReceived(data);
844
860
  }
@@ -848,7 +864,6 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
848
864
  clientID: userID,
849
865
  tideID: client.clientTide.sockets[userID].tideID
850
866
  });
851
- _FileTide.outputGradient(`[${userID}] Received ${HUDUtilityManager.convertNumberToMoneyFormat(data.totalItems, false)} directory contents from ${data.senderID}'s file list!`, significantMessageColors);
852
867
  if (onListFiles) {
853
868
  onListFiles(data);
854
869
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.88",
3
+ "version": "0.0.89",
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": {