@codebolt/codeboltjs 1.1.32 → 1.1.33
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 -2
- package/modules/browser.d.ts +7 -3
- package/modules/browser.js +28 -8
- package/package.json +1 -1
- package/src/modules/browser.ts +33 -11
package/index.d.ts
CHANGED
|
@@ -52,8 +52,8 @@ declare class Codebolt {
|
|
|
52
52
|
getMarkdown: () => Promise<import("@codebolt/types").GetMarkdownResponse>;
|
|
53
53
|
getPDF: () => void;
|
|
54
54
|
pdfToText: () => void;
|
|
55
|
-
getContent: () =>
|
|
56
|
-
extractText: () =>
|
|
55
|
+
getContent: () => Promise<import("@codebolt/types").GetContentResponse>;
|
|
56
|
+
extractText: () => Promise<import("@codebolt/types").ExtractTextResponse>;
|
|
57
57
|
close: () => void;
|
|
58
58
|
scroll: (direction: string, pixels: string) => Promise<unknown>;
|
|
59
59
|
type: (elementid: string, text: string) => Promise<unknown>;
|
package/modules/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GoToPageResponse, UrlResponse, GetMarkdownResponse, HtmlReceived } from '@codebolt/types';
|
|
1
|
+
import { GoToPageResponse, UrlResponse, GetMarkdownResponse, HtmlReceived, ExtractTextResponse, GetContentResponse } from '@codebolt/types';
|
|
2
2
|
/**
|
|
3
3
|
* A module for interacting with a browser through WebSockets.
|
|
4
4
|
*/
|
|
@@ -34,6 +34,7 @@ declare const cbbrowser: {
|
|
|
34
34
|
getMarkdown: () => Promise<GetMarkdownResponse>;
|
|
35
35
|
/**
|
|
36
36
|
* Retrieves the PDF content of the current page.
|
|
37
|
+
*
|
|
37
38
|
*/
|
|
38
39
|
getPDF: () => void;
|
|
39
40
|
/**
|
|
@@ -42,12 +43,15 @@ declare const cbbrowser: {
|
|
|
42
43
|
pdfToText: () => void;
|
|
43
44
|
/**
|
|
44
45
|
* Retrieves the content of the current page.
|
|
46
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
45
47
|
*/
|
|
46
|
-
getContent: () =>
|
|
48
|
+
getContent: () => Promise<GetContentResponse>;
|
|
47
49
|
/**
|
|
48
50
|
* Extracts text from the current page.
|
|
51
|
+
* @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
|
|
52
|
+
*
|
|
49
53
|
*/
|
|
50
|
-
extractText: () =>
|
|
54
|
+
extractText: () => Promise<ExtractTextResponse>;
|
|
51
55
|
/**
|
|
52
56
|
* Closes the current page.
|
|
53
57
|
*/
|
package/modules/browser.js
CHANGED
|
@@ -102,6 +102,7 @@ const cbbrowser = {
|
|
|
102
102
|
},
|
|
103
103
|
/**
|
|
104
104
|
* Retrieves the PDF content of the current page.
|
|
105
|
+
*
|
|
105
106
|
*/
|
|
106
107
|
getPDF: () => {
|
|
107
108
|
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
@@ -120,21 +121,40 @@ const cbbrowser = {
|
|
|
120
121
|
},
|
|
121
122
|
/**
|
|
122
123
|
* Retrieves the content of the current page.
|
|
124
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
123
125
|
*/
|
|
124
126
|
getContent: () => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
return new Promise((resolve, reject) => {
|
|
128
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
129
|
+
"type": "browserEvent",
|
|
130
|
+
action: 'getContent'
|
|
131
|
+
}));
|
|
132
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
133
|
+
const response = JSON.parse(data);
|
|
134
|
+
if (response.event === "getContentResponse") {
|
|
135
|
+
resolve(response);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
129
139
|
},
|
|
130
140
|
/**
|
|
131
141
|
* Extracts text from the current page.
|
|
142
|
+
* @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
|
|
143
|
+
*
|
|
132
144
|
*/
|
|
133
145
|
extractText: () => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
148
|
+
"type": "browserEvent",
|
|
149
|
+
action: 'extractText'
|
|
150
|
+
}));
|
|
151
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
152
|
+
const response = JSON.parse(data);
|
|
153
|
+
if (response.event === "extractTextResponse") {
|
|
154
|
+
resolve(response);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
138
158
|
},
|
|
139
159
|
/**
|
|
140
160
|
* Closes the current page.
|
package/package.json
CHANGED
package/src/modules/browser.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import cbws from './websocket';
|
|
2
|
-
import {GoToPageResponse,UrlResponse,GetMarkdownResponse,HtmlReceived} from '@codebolt/types'
|
|
2
|
+
import {GoToPageResponse,UrlResponse,GetMarkdownResponse,HtmlReceived,ExtractTextResponse,GetContentResponse} from '@codebolt/types'
|
|
3
3
|
/**
|
|
4
4
|
* A module for interacting with a browser through WebSockets.
|
|
5
5
|
*/
|
|
@@ -105,6 +105,7 @@ const cbbrowser = {
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Retrieves the PDF content of the current page.
|
|
108
|
+
*
|
|
108
109
|
*/
|
|
109
110
|
getPDF: () => {
|
|
110
111
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -125,22 +126,43 @@ const cbbrowser = {
|
|
|
125
126
|
|
|
126
127
|
/**
|
|
127
128
|
* Retrieves the content of the current page.
|
|
129
|
+
* @returns {Promise<GetContentResponse>} A promise that resolves with the content.
|
|
128
130
|
*/
|
|
129
|
-
getContent: () => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
getContent: ():Promise<GetContentResponse> => {
|
|
132
|
+
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
135
|
+
"type": "browserEvent",
|
|
136
|
+
action: 'getContent'
|
|
137
|
+
}));
|
|
138
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
139
|
+
const response = JSON.parse(data);
|
|
140
|
+
if (response.event === "getContentResponse") {
|
|
141
|
+
resolve(response);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
134
145
|
},
|
|
135
146
|
|
|
136
147
|
/**
|
|
137
148
|
* Extracts text from the current page.
|
|
149
|
+
* @returns {Promise<ExtractTextResponse>} A promise that resolves with the extracted text.
|
|
150
|
+
*
|
|
138
151
|
*/
|
|
139
|
-
extractText: () => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
152
|
+
extractText: ():Promise<ExtractTextResponse> => {
|
|
153
|
+
|
|
154
|
+
return new Promise((resolve, reject) => {
|
|
155
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
156
|
+
"type": "browserEvent",
|
|
157
|
+
action: 'extractText'
|
|
158
|
+
}));
|
|
159
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
160
|
+
const response = JSON.parse(data);
|
|
161
|
+
if (response.event === "extractTextResponse") {
|
|
162
|
+
resolve(response);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
144
166
|
},
|
|
145
167
|
|
|
146
168
|
/**
|