@trap_stevo/filetide 0.0.17 → 0.0.19

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.
@@ -28,7 +28,7 @@ class FileMessagerClient {
28
28
  transports: ["websocket"],
29
29
  ...options
30
30
  });
31
- console.log(`[FileTide ~ File Messager] ~ Created client with ID ${clientID} and socket ${clientID}!`);
31
+ console.log(`\n[FileTide ~ File Messager] ~ Created client with ID ${clientID} and socket ${clientID}!`);
32
32
  return clientID;
33
33
  }
34
34
  joinRoom(userID, roomName, options = {}) {
@@ -36,7 +36,7 @@ class FileMessagerClient {
36
36
  url: this.clientOptions.url
37
37
  }, options);
38
38
  this.clientTide.joinChannel(socketName, roomName, userID, () => {
39
- console.log(`[FileTide ~ File Messager] ~ Client ~ ${userID} joined room ${roomName} successfully!`);
39
+ console.log(`\n[FileTide ~ File Messager] ~ Client ~ ${userID} joined room ${roomName} successfully!`);
40
40
  this.clients.set(userID, {
41
41
  roomName
42
42
  });
@@ -53,16 +53,15 @@ class FileMessagerClient {
53
53
  */
54
54
  sendDirectoryFiles(clientID, recipientId, filesData, baseDirectory, destinationPath) {
55
55
  const baseDirectoryName = path.basename(baseDirectory);
56
- const adjustedDestinationPath = path.join(destinationPath, baseDirectoryName);
56
+ const adjustedDestinationPath = FileUtilityManager.normalizePath(path.join(destinationPath, baseDirectoryName));
57
57
  const sendFilePromises = filesData.map(fileInfo => {
58
58
  const relativeFilePath = path.dirname(path.relative(baseDirectory, fileInfo.filePath));
59
- const fileDestinationPath = path.join(adjustedDestinationPath, relativeFilePath);
59
+ const fileDestinationPath = FileUtilityManager.normalizePath(path.join(adjustedDestinationPath, relativeFilePath));
60
60
  return this.sendFile(clientID, recipientId, fileInfo.fileName, fileInfo.fileData, fileDestinationPath);
61
61
  });
62
- Promise.all(sendFilePromises).then(() => console.log("All files in directory transferred successfully!")).catch(error => console.error("Did not transfer files: ", error));
62
+ Promise.all(sendFilePromises).then(() => console.log("\nAll files in directory transferred successfully!")).catch(error => console.error("Did not transfer files: ", error));
63
63
  }
64
64
  sendFile(clientID, recipientId, fileName, file, filePath = process.cwd()) {
65
- console.log(fileName, ": ", file);
66
65
  if (!file) {
67
66
  return;
68
67
  }
@@ -78,18 +77,12 @@ class FileMessagerClient {
78
77
  chunkIndex,
79
78
  filePath
80
79
  });
81
- console.log(`Chunk ${chunkIndex} sent successfully!`);
80
+ console.log(`\nChunk ${chunkIndex} sent successfully!`);
82
81
  resolve();
83
82
  });
84
83
  },
85
84
  onComplete: () => {
86
85
  return new Promise((resolve, reject) => {
87
- console.log({
88
- senderID: clientID,
89
- recipientId,
90
- fileName,
91
- filePath
92
- });
93
86
  this.clientTide.emitEvent(clientID, "transfer-complete", {
94
87
  senderID: clientID,
95
88
  recipientId,
@@ -100,24 +93,24 @@ class FileMessagerClient {
100
93
  });
101
94
  },
102
95
  onProgress: progress => {
103
- console.log(`[FileTide ~ File Messager] ~ Progress: ${progress.toFixed(2)}%`);
96
+ console.log(`\n[FileTide ~ File Messager] ~ ${progress.toFixed(2)}% |>>| ${fileName}`);
104
97
  },
105
98
  fileDetails: {
106
99
  name: fileName,
107
100
  path: filePath
108
101
  }
109
- }).then(() => console.log('File transfer complete!')).catch(error => console.error('File transfer failed:', error));
102
+ }).then(() => console.log(`[FileTide ~ File Messager] ~ File ~ ${fileName} transfer complete!`)).catch(error => console.error('File transfer failed:', error));
110
103
  }
111
104
  onFileChunkReceived(userID) {
112
105
  this.clientTide.onEvent(userID, "transfer-progress", data => {
113
- console.log(`[FileTide ~ File Messager] ~ Receiving file chunk for client ~ ${userID}: `, data.fileChunk);
114
- console.log("[FileTide ~ File Messager] ~ Progress: ", data.progress);
106
+ console.log(`\n[FileTide ~ File Messager] ~ Receiving file chunk for client ~ ${userID}: `, data.fileChunk);
107
+ console.log("\n[FileTide ~ File Messager] ~ Progress: ", data.progress);
115
108
  FileUtilityManager.saveChunk(userID, data.fileChunk, data.path, data.name);
116
109
  });
117
110
  }
118
111
  onFileTransferComplete(userID) {
119
112
  this.clientTide.onEvent(userID, "transfer-complete", data => {
120
- console.log(`[FileTide ~ File Messager] ~ File transfer completed for user ${userID}.`);
113
+ console.log(`\n[FileTide ~ File Messager] ~ File transfer completed for user ${userID}.`);
121
114
  FileUtilityManager.assembleFile(userID);
122
115
  });
123
116
  }
@@ -95,13 +95,6 @@ class FileTide {
95
95
  return;
96
96
  }
97
97
  console.log(`[FileTide] ~ Sending file to client ~ ${userID}...`);
98
- console.log({
99
- recipientId: userID,
100
- senderID,
101
- fileName,
102
- filePath,
103
- fileData
104
- });
105
98
  this.fileNet.transporter.sendFile(fileData, {
106
99
  onSendChunk: (transferId, chunkIndex, chunkData, totalChunks) => {
107
100
  return new Promise((resolve, reject) => {
@@ -48,7 +48,7 @@ class FileUtilityManager {
48
48
  function readDirectory(currentPath) {
49
49
  const fileList = fs.readdirSync(currentPath);
50
50
  fileList.forEach(file => {
51
- const filePath = path.join(currentPath, file);
51
+ const filePath = FileUtilityManager.normalizePath(path.join(currentPath, file));
52
52
  const stats = fs.statSync(filePath);
53
53
  if (stats.isFile()) {
54
54
  const fileData = FileUtilityManager.getFileData(filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
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": {