@codebolt/codeboltjs 1.1.36 → 1.1.38
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 +2 -0
- package/modules/browser.d.ts +10 -0
- package/modules/browser.js +36 -0
- package/modules/chat.d.ts +1 -1
- package/modules/chat.js +1 -1
- package/modules/codeutils.js +3 -1
- package/package.json +1 -1
- package/src/modules/browser.ts +38 -0
- package/src/modules/chat.ts +1 -1
- package/src/modules/codeutils.ts +5 -2
package/index.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ declare class Codebolt {
|
|
|
53
53
|
getPDF: () => void;
|
|
54
54
|
pdfToText: () => void;
|
|
55
55
|
getContent: () => Promise<import("@codebolt/types").GetContentResponse>;
|
|
56
|
+
getSnapShot: () => Promise<any>;
|
|
57
|
+
getBrowserInfo: () => Promise<any>;
|
|
56
58
|
extractText: () => Promise<import("@codebolt/types").ExtractTextResponse>;
|
|
57
59
|
close: () => void;
|
|
58
60
|
scroll: (direction: string, pixels: string) => Promise<unknown>;
|
package/modules/browser.d.ts
CHANGED
|
@@ -46,6 +46,16 @@ declare const cbbrowser: {
|
|
|
46
46
|
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
47
47
|
*/
|
|
48
48
|
getContent: () => Promise<GetContentResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the snapshot of the current page.
|
|
51
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
52
|
+
*/
|
|
53
|
+
getSnapShot: () => Promise<any>;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves browser info like height width scrollx scrolly of the current page.
|
|
56
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
57
|
+
*/
|
|
58
|
+
getBrowserInfo: () => Promise<any>;
|
|
49
59
|
/**
|
|
50
60
|
* Extracts text from the current page.
|
|
51
61
|
* @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
|
package/modules/browser.js
CHANGED
|
@@ -145,6 +145,42 @@ const cbbrowser = {
|
|
|
145
145
|
});
|
|
146
146
|
});
|
|
147
147
|
},
|
|
148
|
+
/**
|
|
149
|
+
* Retrieves the snapshot of the current page.
|
|
150
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
151
|
+
*/
|
|
152
|
+
getSnapShot: () => {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
155
|
+
"type": "browserEvent",
|
|
156
|
+
action: 'getSnapShot'
|
|
157
|
+
}));
|
|
158
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
159
|
+
const response = JSON.parse(data);
|
|
160
|
+
if (response.event === "getSnapShotResponse") {
|
|
161
|
+
resolve(response);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves browser info like height width scrollx scrolly of the current page.
|
|
168
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
169
|
+
*/
|
|
170
|
+
getBrowserInfo: () => {
|
|
171
|
+
return new Promise((resolve, reject) => {
|
|
172
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
173
|
+
"type": "browserEvent",
|
|
174
|
+
action: 'getBrowserInfo'
|
|
175
|
+
}));
|
|
176
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
177
|
+
const response = JSON.parse(data);
|
|
178
|
+
if (response.event === "getBrowserInfoResponse") {
|
|
179
|
+
resolve(response);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
},
|
|
148
184
|
/**
|
|
149
185
|
* Extracts text from the current page.
|
|
150
186
|
* @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
|
package/modules/chat.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare const cbchat: {
|
|
|
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.
|
|
31
|
-
* @returns {Promise<
|
|
31
|
+
* @returns {Promise<ChatMessage>} A promise that resolves with the reply.
|
|
32
32
|
*/
|
|
33
33
|
waitforReply: (message: string) => Promise<string>;
|
|
34
34
|
/**
|
package/modules/chat.js
CHANGED
|
@@ -62,7 +62,7 @@ const cbchat = {
|
|
|
62
62
|
/**
|
|
63
63
|
* Waits for a reply to a sent message.
|
|
64
64
|
* @param {string} message - The message for which a reply is expected.
|
|
65
|
-
* @returns {Promise<
|
|
65
|
+
* @returns {Promise<ChatMessage>} A promise that resolves with the reply.
|
|
66
66
|
*/
|
|
67
67
|
waitforReply: (message) => {
|
|
68
68
|
return new Promise((resolve, reject) => {
|
package/modules/codeutils.js
CHANGED
|
@@ -70,7 +70,8 @@ const cbcodeutils = {
|
|
|
70
70
|
else if (path_1.default.extname(file.name) === '.js') {
|
|
71
71
|
const code = fs.readFileSync(path_1.default.join(directory, file.name), 'utf-8');
|
|
72
72
|
console.log(code);
|
|
73
|
-
|
|
73
|
+
let tree = parser.parse(code);
|
|
74
|
+
tree.rootNode.path = path_1.default.join(directory, file.name); // Set file path for t
|
|
74
75
|
trees.push(tree);
|
|
75
76
|
}
|
|
76
77
|
});
|
|
@@ -82,6 +83,7 @@ const cbcodeutils = {
|
|
|
82
83
|
// Read a single JavaScript file
|
|
83
84
|
const code = fs.readFileSync(pathInput, 'utf-8');
|
|
84
85
|
let tree = parser.parse(code);
|
|
86
|
+
tree.rootNode.path = pathInput; // Set file path for t
|
|
85
87
|
trees.push(tree);
|
|
86
88
|
}
|
|
87
89
|
resolve({ event: 'GetJsTreeResponse', payload: trees }); // Return an array of abstract syntax trees (ASTs)
|
package/package.json
CHANGED
package/src/modules/browser.ts
CHANGED
|
@@ -152,6 +152,44 @@ const cbbrowser = {
|
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
},
|
|
155
|
+
/**
|
|
156
|
+
* Retrieves the snapshot of the current page.
|
|
157
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
158
|
+
*/
|
|
159
|
+
getSnapShot: ():Promise<any> => {
|
|
160
|
+
|
|
161
|
+
return new Promise((resolve, reject) => {
|
|
162
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
163
|
+
"type": "browserEvent",
|
|
164
|
+
action: 'getSnapShot'
|
|
165
|
+
}));
|
|
166
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
167
|
+
const response = JSON.parse(data);
|
|
168
|
+
if (response.event === "getSnapShotResponse") {
|
|
169
|
+
resolve(response);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* Retrieves browser info like height width scrollx scrolly of the current page.
|
|
176
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
177
|
+
*/
|
|
178
|
+
getBrowserInfo: ():Promise<any> => {
|
|
179
|
+
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
182
|
+
"type": "browserEvent",
|
|
183
|
+
action: 'getBrowserInfo'
|
|
184
|
+
}));
|
|
185
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
186
|
+
const response = JSON.parse(data);
|
|
187
|
+
if (response.event === "getBrowserInfoResponse") {
|
|
188
|
+
resolve(response);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
},
|
|
155
193
|
|
|
156
194
|
/**
|
|
157
195
|
* Extracts text from the current page.
|
package/src/modules/chat.ts
CHANGED
|
@@ -63,7 +63,7 @@ const cbchat = {
|
|
|
63
63
|
/**
|
|
64
64
|
* Waits for a reply to a sent message.
|
|
65
65
|
* @param {string} message - The message for which a reply is expected.
|
|
66
|
-
* @returns {Promise<
|
|
66
|
+
* @returns {Promise<ChatMessage>} A promise that resolves with the reply.
|
|
67
67
|
*/
|
|
68
68
|
waitforReply: (message: string): Promise<string> => {
|
|
69
69
|
return new Promise((resolve, reject) => {
|
package/src/modules/codeutils.ts
CHANGED
|
@@ -33,6 +33,7 @@ const cbcodeutils = {
|
|
|
33
33
|
parser.setLanguage(JavaScript);
|
|
34
34
|
const trees = [];
|
|
35
35
|
const functionNodes = [];
|
|
36
|
+
|
|
36
37
|
const processDirectory = (directory:any) => {
|
|
37
38
|
console.log("isdir")
|
|
38
39
|
// Read all files in the directory
|
|
@@ -46,7 +47,8 @@ const cbcodeutils = {
|
|
|
46
47
|
} else if (path.extname(file.name) === '.js') {
|
|
47
48
|
const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
|
|
48
49
|
console.log(code);
|
|
49
|
-
|
|
50
|
+
let tree:any = parser.parse(code);
|
|
51
|
+
tree.rootNode.path = path.join(directory, file.name); // Set file path for t
|
|
50
52
|
trees.push(tree);
|
|
51
53
|
}
|
|
52
54
|
});
|
|
@@ -57,7 +59,8 @@ const cbcodeutils = {
|
|
|
57
59
|
} else if (path.extname(pathInput) === '.js') {
|
|
58
60
|
// Read a single JavaScript file
|
|
59
61
|
const code = fs.readFileSync(pathInput, 'utf-8');
|
|
60
|
-
let tree = parser.parse(code);
|
|
62
|
+
let tree:any = parser.parse(code);
|
|
63
|
+
tree.rootNode.path = pathInput; // Set file path for t
|
|
61
64
|
|
|
62
65
|
trees.push(tree);
|
|
63
66
|
}
|