@codebolt/codeboltjs 1.1.26 → 1.1.28

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
@@ -86,6 +86,7 @@ declare class Codebolt {
86
86
  event: import("./modules/chat").CustomEventEmitter;
87
87
  stopProcess: () => void;
88
88
  };
89
+ stopProcess: () => void;
89
90
  };
90
91
  terminal: {
91
92
  eventEmitter: import("./modules/terminal").CustomEventEmitter;
@@ -95,8 +96,10 @@ declare class Codebolt {
95
96
  executeCommandWithStream(command: string): import("./modules/terminal").CustomEventEmitter;
96
97
  };
97
98
  codeutils: {
98
- getCodeTree: (fileName: any, source: any, filePath: any) => Promise<any>;
99
+ getCodeTree: () => Promise<any>;
100
+ getJsTree: (filePath: string) => Promise<any>;
99
101
  getAllFilesAsMarkDown: () => Promise<unknown>;
102
+ matchProblem: (matcherDefinition: object, problemPatterns: [], problems: []) => Promise<unknown>;
100
103
  };
101
104
  docutils: {
102
105
  pdf_to_text: (pdf_path: any) => Promise<string>;
@@ -155,6 +158,7 @@ declare class Codebolt {
155
158
  };
156
159
  debug: {
157
160
  debug(log: string, type: import("./modules/debug").logType): Promise<unknown>;
161
+ openDebugBrowser(url: string, port: number): Promise<unknown>;
158
162
  };
159
163
  tokenizer: {
160
164
  addToken: (key: string) => Promise<any>;
package/modules/chat.d.ts CHANGED
@@ -30,5 +30,6 @@ declare const cbchat: {
30
30
  event: CustomEventEmitter;
31
31
  stopProcess: () => void;
32
32
  };
33
+ stopProcess: () => void;
33
34
  };
34
35
  export default cbchat;
package/modules/chat.js CHANGED
@@ -90,6 +90,14 @@ const cbchat = {
90
90
  }));
91
91
  }
92
92
  };
93
+ },
94
+ stopProcess: () => {
95
+ // Implement the logic to stop the process here
96
+ console.log("Stopping process...");
97
+ // For example, you might want to send a specific message to the server to stop the process
98
+ websocket_1.default.getWebsocket.send(JSON.stringify({
99
+ "type": "processStoped"
100
+ }));
93
101
  }
94
102
  };
95
103
  exports.default = cbchat;
@@ -2,14 +2,9 @@
2
2
  * A utility module for working with code.
3
3
  */
4
4
  declare const cbcodeutils: {
5
- /**
6
- * Asynchronously generates a code tree from the provided source code.
7
- * @param {any} fileName - The name of the file.
8
- * @param {any} source - The source code to generate the tree from.
9
- * @param {any} filePath - The file path where the source code is located.
10
- * @returns {Promise<any>} A promise that resolves with the code tree.
11
- */
12
- getCodeTree: (fileName: any, source: any, filePath: any) => Promise<any>;
5
+ getCodeTree: () => Promise<any>;
6
+ getJsTree: (filePath: string) => Promise<any>;
13
7
  getAllFilesAsMarkDown: () => Promise<unknown>;
8
+ matchProblem: (matcherDefinition: object, problemPatterns: [], problems: []) => Promise<unknown>;
14
9
  };
15
10
  export default cbcodeutils;
@@ -8,16 +8,35 @@ const websocket_1 = __importDefault(require("./websocket"));
8
8
  * A utility module for working with code.
9
9
  */
10
10
  const cbcodeutils = {
11
- /**
12
- * Asynchronously generates a code tree from the provided source code.
13
- * @param {any} fileName - The name of the file.
14
- * @param {any} source - The source code to generate the tree from.
15
- * @param {any} filePath - The file path where the source code is located.
16
- * @returns {Promise<any>} A promise that resolves with the code tree.
17
- */
18
- getCodeTree: (fileName, source, filePath) => {
11
+ getCodeTree: () => {
19
12
  return new Promise((resolve, reject) => {
20
- // Implementation would go here
13
+ websocket_1.default.getWebsocket.send(JSON.stringify({
14
+ "type": "codeEvent",
15
+ "action": "getCodeTree"
16
+ }));
17
+ websocket_1.default.getWebsocket.on('message', (data) => {
18
+ const response = JSON.parse(data);
19
+ if (response.type === "getCodeTreeResponse") {
20
+ resolve(response.markdown); // Resolve the Promise with the response data
21
+ }
22
+ });
23
+ });
24
+ },
25
+ getJsTree: (filePath) => {
26
+ return new Promise((resolve, reject) => {
27
+ websocket_1.default.getWebsocket.send(JSON.stringify({
28
+ "type": "codeEvent",
29
+ "action": "getJsTree",
30
+ payload: {
31
+ filePath
32
+ }
33
+ }));
34
+ websocket_1.default.getWebsocket.on('message', (data) => {
35
+ const response = JSON.parse(data);
36
+ if (response.type === "getgetJsTreeResponse") {
37
+ resolve(response.payload); // Resolve the Promise with the response data
38
+ }
39
+ });
21
40
  });
22
41
  },
23
42
  getAllFilesAsMarkDown: () => {
@@ -33,6 +52,25 @@ const cbcodeutils = {
33
52
  }
34
53
  });
35
54
  });
55
+ },
56
+ matchProblem: (matcherDefinition, problemPatterns, problems) => {
57
+ return new Promise((resolve, reject) => {
58
+ websocket_1.default.getWebsocket.send(JSON.stringify({
59
+ "type": "codeEvent",
60
+ "action": "getJsTree",
61
+ payload: {
62
+ matcherDefinition,
63
+ problemPatterns,
64
+ problems
65
+ }
66
+ }));
67
+ websocket_1.default.getWebsocket.on('message', (data) => {
68
+ const response = JSON.parse(data);
69
+ if (response.type === "getgetJsTreeResponse") {
70
+ resolve(response.payload); // Resolve the Promise with the response data
71
+ }
72
+ });
73
+ });
36
74
  }
37
75
  };
38
76
  exports.default = cbcodeutils;
@@ -5,5 +5,6 @@ export declare enum logType {
5
5
  }
6
6
  export declare const debug: {
7
7
  debug(log: string, type: logType): Promise<unknown>;
8
+ openDebugBrowser(url: string, port: number): Promise<unknown>;
8
9
  };
9
10
  export default debug;
package/modules/debug.js CHANGED
@@ -16,6 +16,7 @@ exports.debug = {
16
16
  return new Promise((resolve, reject) => {
17
17
  websocket_1.default.getWebsocket.send(JSON.stringify({
18
18
  "type": "debugEvent",
19
+ "action": "addLog",
19
20
  message: {
20
21
  log,
21
22
  type
@@ -28,6 +29,24 @@ exports.debug = {
28
29
  }
29
30
  });
30
31
  });
32
+ },
33
+ openDebugBrowser(url, port) {
34
+ return new Promise((resolve, reject) => {
35
+ websocket_1.default.getWebsocket.send(JSON.stringify({
36
+ "type": "debugEvent",
37
+ "action": "openDebugBrowser",
38
+ message: {
39
+ url,
40
+ port
41
+ }
42
+ }));
43
+ websocket_1.default.getWebsocket.on('message', (data) => {
44
+ const response = JSON.parse(data);
45
+ if (response.type === "openDebugBrowserResponse") {
46
+ resolve(response); // Resolve the Promise with the response data
47
+ }
48
+ });
49
+ });
31
50
  }
32
51
  };
33
52
  exports.default = exports.debug;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
package/src/index.ts CHANGED
@@ -39,7 +39,6 @@ class Codebolt { // Extend EventEmitter
39
39
  constructor() {
40
40
 
41
41
  this.websocket = cbws.getWebsocket;
42
-
43
42
  }
44
43
  /**
45
44
  * @method setupMessageListener
@@ -92,6 +92,14 @@ const cbchat = {
92
92
  }));
93
93
  }
94
94
  };
95
+ },
96
+ stopProcess: () => {
97
+ // Implement the logic to stop the process here
98
+ console.log("Stopping process...");
99
+ // For example, you might want to send a specific message to the server to stop the process
100
+ cbws.getWebsocket.send(JSON.stringify({
101
+ "type": "processStoped"
102
+ }));
95
103
  }
96
104
  };
97
105
 
@@ -4,16 +4,37 @@ import cbws from './websocket';
4
4
  * A utility module for working with code.
5
5
  */
6
6
  const cbcodeutils = {
7
- /**
8
- * Asynchronously generates a code tree from the provided source code.
9
- * @param {any} fileName - The name of the file.
10
- * @param {any} source - The source code to generate the tree from.
11
- * @param {any} filePath - The file path where the source code is located.
12
- * @returns {Promise<any>} A promise that resolves with the code tree.
13
- */
14
- getCodeTree: (fileName: any, source: any, filePath: any): Promise<any> => {
7
+
8
+
9
+ getCodeTree: (): Promise<any> => {
15
10
  return new Promise((resolve, reject) => {
16
- // Implementation would go here
11
+ cbws.getWebsocket.send(JSON.stringify({
12
+ "type": "codeEvent",
13
+ "action":"getCodeTree"
14
+ }));
15
+ cbws.getWebsocket.on('message', (data: string) => {
16
+ const response = JSON.parse(data);
17
+ if (response.type === "getCodeTreeResponse") {
18
+ resolve(response.markdown); // Resolve the Promise with the response data
19
+ }
20
+ });
21
+ });
22
+ },
23
+ getJsTree: (filePath:string): Promise<any> => {
24
+ return new Promise((resolve, reject) => {
25
+ cbws.getWebsocket.send(JSON.stringify({
26
+ "type": "codeEvent",
27
+ "action":"getJsTree",
28
+ payload:{
29
+ filePath
30
+ }
31
+ }));
32
+ cbws.getWebsocket.on('message', (data: string) => {
33
+ const response = JSON.parse(data);
34
+ if (response.type === "getgetJsTreeResponse") {
35
+ resolve(response.payload); // Resolve the Promise with the response data
36
+ }
37
+ });
17
38
  });
18
39
  },
19
40
  getAllFilesAsMarkDown:()=>{
@@ -29,6 +50,25 @@ const cbcodeutils = {
29
50
  }
30
51
  });
31
52
  });
53
+ },
54
+ matchProblem:(matcherDefinition:object, problemPatterns:[], problems:[])=>{
55
+ return new Promise((resolve, reject) => {
56
+ cbws.getWebsocket.send(JSON.stringify({
57
+ "type": "codeEvent",
58
+ "action":"getJsTree",
59
+ payload:{
60
+ matcherDefinition,
61
+ problemPatterns,
62
+ problems
63
+ }
64
+ }));
65
+ cbws.getWebsocket.on('message', (data: string) => {
66
+ const response = JSON.parse(data);
67
+ if (response.type === "getgetJsTreeResponse") {
68
+ resolve(response.payload); // Resolve the Promise with the response data
69
+ }
70
+ });
71
+ });
32
72
  }
33
73
  };
34
74
 
@@ -12,6 +12,7 @@ export const debug={
12
12
  return new Promise((resolve, reject) => {
13
13
  cbws.getWebsocket.send(JSON.stringify({
14
14
  "type": "debugEvent",
15
+ "action":"addLog",
15
16
  message:{
16
17
  log,
17
18
  type
@@ -26,6 +27,25 @@ export const debug={
26
27
  })
27
28
 
28
29
 
30
+ },
31
+ openDebugBrowser(url:string,port:number){
32
+ return new Promise((resolve, reject) => {
33
+ cbws.getWebsocket.send(JSON.stringify({
34
+ "type": "debugEvent",
35
+ "action":"openDebugBrowser",
36
+ message:{
37
+ url,
38
+ port
39
+ }
40
+ }));
41
+ cbws.getWebsocket.on('message', (data: string) => {
42
+ const response = JSON.parse(data);
43
+ if (response.type === "openDebugBrowserResponse") {
44
+ resolve(response); // Resolve the Promise with the response data
45
+ }
46
+ })
47
+ })
48
+
29
49
  }
30
50
  }
31
51