@trap_stevo/filetide 0.0.45 → 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.
@@ -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) {
@@ -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 = {}, roomName, userID, onLaunch, onIncomingFile, onIncomingTransfer, onTransferBarrier, onTransferProgress, enableTransferBarrier = true, options = {}, headers = {}, onConnect = null, onDisconnect = null, authURL = "", authHeaders = {}, useAuthentication = false, queryAuthToken = false) {
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")]);
@@ -522,6 +534,7 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
522
534
  const capacitor = new ChunkCapacitor(directoryContents, 100);
523
535
  const contents = capacitor.getAllChunks();
524
536
  for (let files of contents) {
537
+ totalFilesSent += files.length;
525
538
  client.clientTide.emitEvent(userID, "send-file-list-to-client", {
526
539
  senderID: data.recipientID,
527
540
  recipientID: data.senderID,
@@ -529,7 +542,6 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
529
542
  listedFiles: files
530
543
  });
531
544
  }
532
- totalFilesSent += totalItems;
533
545
  });
534
546
  setTimeout(() => {
535
547
  _FileTide.outputGradient(`[${userID}] Sent file list to ${data.senderID}!`, significantMessageColors);
@@ -544,13 +556,13 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
544
556
  _FileTide.outputGradient(`[${userID} | FileTide Error] ${error}`, errorMessageColors);
545
557
  });
546
558
  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);
559
+ _FileTide.outputGradient(`[${userID}] Successfully received all ${HUDUtilityManager.convertNumberToMoneyFormat(data.totalItemsSent, false)} contents in ${data.senderID}'s file list!`, significantMessageColors);
548
560
  if (onFileListReceived) {
549
561
  onFileListReceived(data);
550
562
  }
551
563
  });
552
564
  client.clientTide.onEvent(userID, "client-file-list", async data => {
553
- _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);
554
566
  if (onListFiles) {
555
567
  onListFiles(data);
556
568
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.45",
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.42",
34
+ "@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.43",
35
35
  "chalk": "^4.1.2",
36
36
  "readline": "^1.3.0"
37
37
  },