@codebolt/codeboltjs 1.1.63 → 1.1.65

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: {
@@ -108,7 +108,7 @@ declare class Codebolt {
108
108
  };
109
109
  stopProcess: () => void;
110
110
  processFinished: () => void;
111
- sendConfirmationRequest: (confirmationMessage: string, buttons?: string[]) => Promise<string>;
111
+ sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
112
112
  sendNotificationEvent: (notificationMessage: string, type: "debug" | "git" | "planner" | "browser" | "editor" | "terminal" | "preview") => void;
113
113
  };
114
114
  terminal: {
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.
@@ -53,7 +53,7 @@ declare const cbchat: {
53
53
  * Sends a confirmation request to the server with two options: Yes or No.
54
54
  * @returns {Promise<string>} A promise that resolves with the server's response.
55
55
  */
56
- sendConfirmationRequest: (confirmationMessage: string, buttons?: string[]) => Promise<string>;
56
+ sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
57
57
  /**
58
58
  * Sends a notification event to the server.
59
59
  * @param {string} notificationMessage - The message to be sent in the notification.
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
  /**
@@ -142,16 +143,17 @@ const cbchat = {
142
143
  * Sends a confirmation request to the server with two options: Yes or No.
143
144
  * @returns {Promise<string>} A promise that resolves with the server's response.
144
145
  */
145
- sendConfirmationRequest: (confirmationMessage, buttons = []) => {
146
+ sendConfirmationRequest: (confirmationMessage, buttons = [], withFeedback = false) => {
146
147
  return new Promise((resolve, reject) => {
147
148
  websocket_1.default.getWebsocket.send(JSON.stringify({
148
149
  "type": "confirmationRequest",
149
150
  "message": confirmationMessage,
150
- buttons: buttons
151
+ buttons: buttons,
152
+ withFeedback
151
153
  }));
152
154
  websocket_1.default.getWebsocket.on('message', (data) => {
153
155
  const response = JSON.parse(data);
154
- if (response.type === "confirmationResponse") {
156
+ if (response.type === "confirmationResponse" || response.type === "feedbackResponse") {
155
157
  resolve(response); // Resolve the Promise with the server's response
156
158
  }
157
159
  });
@@ -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.65",
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 ...");
@@ -147,17 +148,18 @@ const cbchat = {
147
148
  * Sends a confirmation request to the server with two options: Yes or No.
148
149
  * @returns {Promise<string>} A promise that resolves with the server's response.
149
150
  */
150
- sendConfirmationRequest: (confirmationMessage: string, buttons: string[] = []): Promise<string> => {
151
+ sendConfirmationRequest: (confirmationMessage: string, buttons: string[] = [],withFeedback:boolean=false): Promise<string> => {
151
152
  return new Promise((resolve, reject) => {
152
153
  cbws.getWebsocket.send(JSON.stringify({
153
154
  "type": "confirmationRequest",
154
155
  "message": confirmationMessage,
155
- buttons: buttons
156
+ buttons: buttons,
157
+ withFeedback
156
158
 
157
159
  }));
158
160
  cbws.getWebsocket.on('message', (data: string) => {
159
161
  const response = JSON.parse(data);
160
- if (response.type === "confirmationResponse") {
162
+ if (response.type === "confirmationResponse" || response.type === "feedbackResponse" ) {
161
163
  resolve(response); // Resolve the Promise with the server's response
162
164
  }
163
165
  });
@@ -171,7 +173,7 @@ const cbchat = {
171
173
  cbws.getWebsocket.send(JSON.stringify({
172
174
  "type": "notificationEvent",
173
175
  "message": notificationMessage,
174
- "eventType":type
176
+ "eventType": type
175
177
  }));
176
178
  },
177
179
 
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