@codebolt/codeboltjs 1.1.63 → 1.1.64

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/index.d.ts CHANGED
@@ -83,7 +83,7 @@ declare class Codebolt {
83
83
  prependOnceListener<K_11>(eventName: string | symbol, listener: (...args: any[]) => void): any;
84
84
  eventNames(): (string | symbol)[];
85
85
  } | undefined;
86
- sendMessage: (message: string) => void;
86
+ sendMessage: (message: string, payload: any) => void;
87
87
  waitforReply: (message: string) => Promise<import("@codebolt/types").UserMessage>;
88
88
  processStarted: () => {
89
89
  event: {
package/modules/chat.d.ts CHANGED
@@ -24,7 +24,7 @@ declare const cbchat: {
24
24
  * Sends a message through the WebSocket connection.
25
25
  * @param {string} message - The message to be sent.
26
26
  */
27
- sendMessage: (message: string) => void;
27
+ sendMessage: (message: string, payload: any) => void;
28
28
  /**
29
29
  * Waits for a reply to a sent message.
30
30
  * @param {string} message - The message for which a reply is expected.
package/modules/chat.js CHANGED
@@ -58,11 +58,12 @@ const cbchat = {
58
58
  * Sends a message through the WebSocket connection.
59
59
  * @param {string} message - The message to be sent.
60
60
  */
61
- sendMessage: (message) => {
61
+ sendMessage: (message, payload) => {
62
62
  console.log(message);
63
63
  websocket_1.default.getWebsocket.send(JSON.stringify({
64
64
  "type": "sendMessage",
65
- "message": message
65
+ "message": message,
66
+ payload
66
67
  }));
67
68
  },
68
69
  /**
@@ -30,10 +30,24 @@ const cbterminal = {
30
30
  "message": command,
31
31
  executeInMain
32
32
  }));
33
+ let result = "";
33
34
  websocket_1.default.getWebsocket.on('message', (data) => {
34
35
  const response = JSON.parse(data);
35
36
  if (response.type === "commandOutput" || response.type === "commandError" || response.type === "commandFinish") {
36
- resolve(response);
37
+ if (response.type === "commandOutput") {
38
+ // Initialize result as an empty string
39
+ result += response.stdout + "/n"; // Append the output
40
+ }
41
+ else if (response.type === "commandError") {
42
+ result = response.stderr + "/n";
43
+ ; // Set result to the error
44
+ response.result = result;
45
+ resolve(response); // Resolve with the result string
46
+ }
47
+ else if (response.type === "commandFinish") {
48
+ response.result = result;
49
+ resolve(response); // Resolve with the result string
50
+ }
37
51
  }
38
52
  });
39
53
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.63",
3
+ "version": "1.1.64",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
File without changes
@@ -58,11 +58,12 @@ const cbchat = {
58
58
  * Sends a message through the WebSocket connection.
59
59
  * @param {string} message - The message to be sent.
60
60
  */
61
- sendMessage: (message: string) => {
61
+ sendMessage: (message: string, payload: any) => {
62
62
  console.log(message);
63
63
  cbws.getWebsocket.send(JSON.stringify({
64
64
  "type": "sendMessage",
65
- "message": message
65
+ "message": message,
66
+ payload
66
67
  }));
67
68
  },
68
69
 
@@ -130,10 +131,10 @@ const cbchat = {
130
131
  "type": "processStoped"
131
132
  }));
132
133
  },
133
- /**
134
- * Stops the ongoing process.
135
- * Sends a specific message to the server to stop the process.
136
- */
134
+ /**
135
+ * Stops the ongoing process.
136
+ * Sends a specific message to the server to stop the process.
137
+ */
137
138
  processFinished: () => {
138
139
  // Implement the logic to stop the process here
139
140
  console.log("Process Finished ...");
@@ -171,7 +172,7 @@ const cbchat = {
171
172
  cbws.getWebsocket.send(JSON.stringify({
172
173
  "type": "notificationEvent",
173
174
  "message": notificationMessage,
174
- "eventType":type
175
+ "eventType": type
175
176
  }));
176
177
  },
177
178
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/modules/fs.ts CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -26,10 +26,22 @@ const cbterminal = {
26
26
  "message": command,
27
27
  executeInMain
28
28
  }));
29
+ let result = "";
29
30
  cbws.getWebsocket.on('message', (data: string) => {
30
31
  const response = JSON.parse(data);
32
+
31
33
  if (response.type === "commandOutput" || response.type === "commandError" || response.type === "commandFinish") {
32
- resolve(response);
34
+ if (response.type === "commandOutput") {
35
+ // Initialize result as an empty string
36
+ result += response.stdout + "/n"; // Append the output
37
+ } else if (response.type === "commandError") {
38
+ result = response.stderr + "/n";; // Set result to the error
39
+ response.result = result;
40
+ resolve(response); // Resolve with the result string
41
+ } else if (response.type === "commandFinish") {
42
+ response.result = result;
43
+ resolve(response); // Resolve with the result string
44
+ }
33
45
  }
34
46
  });
35
47
  });
File without changes
File without changes