@codebolt/codeboltjs 1.1.59 → 1.1.60
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 +1 -1
- package/modules/browser.d.ts +1 -1
- package/modules/browser.js +12 -4
- package/package.json +1 -1
- package/src/modules/browser.ts +8 -0
package/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare class Codebolt {
|
|
|
47
47
|
newPage: () => Promise<unknown>;
|
|
48
48
|
getUrl: () => Promise<import("@codebolt/types").UrlResponse>;
|
|
49
49
|
goToPage: (url: string) => Promise<import("@codebolt/types").GoToPageResponse>;
|
|
50
|
-
screenshot: () =>
|
|
50
|
+
screenshot: () => Promise<unknown>;
|
|
51
51
|
getHTML: () => Promise<import("@codebolt/types").HtmlReceived>;
|
|
52
52
|
getMarkdown: () => Promise<import("@codebolt/types").GetMarkdownResponse>;
|
|
53
53
|
getPDF: () => void;
|
package/modules/browser.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare const cbbrowser: {
|
|
|
21
21
|
/**
|
|
22
22
|
* Takes a screenshot of the current page.
|
|
23
23
|
*/
|
|
24
|
-
screenshot: () =>
|
|
24
|
+
screenshot: () => Promise<unknown>;
|
|
25
25
|
/**
|
|
26
26
|
* Retrieves the HTML content of the current page.
|
|
27
27
|
* @returns {Promise<HtmlReceived>} A promise that resolves with the HTML content.
|
package/modules/browser.js
CHANGED
|
@@ -67,10 +67,18 @@ const cbbrowser = {
|
|
|
67
67
|
* Takes a screenshot of the current page.
|
|
68
68
|
*/
|
|
69
69
|
screenshot: () => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
72
|
+
"type": "browserEvent",
|
|
73
|
+
action: 'screenshot'
|
|
74
|
+
}));
|
|
75
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
76
|
+
const response = JSON.parse(data);
|
|
77
|
+
if (response.event === "screenshotResponse") {
|
|
78
|
+
resolve(response.payload);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
74
82
|
},
|
|
75
83
|
/**
|
|
76
84
|
* Retrieves the HTML content of the current page.
|
package/package.json
CHANGED
package/src/modules/browser.ts
CHANGED
|
@@ -68,10 +68,18 @@ const cbbrowser = {
|
|
|
68
68
|
* Takes a screenshot of the current page.
|
|
69
69
|
*/
|
|
70
70
|
screenshot: () => {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
71
72
|
cbws.getWebsocket.send(JSON.stringify({
|
|
72
73
|
"type": "browserEvent",
|
|
73
74
|
action: 'screenshot'
|
|
74
75
|
}));
|
|
76
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
77
|
+
const response = JSON.parse(data);
|
|
78
|
+
if (response.event === "screenshotResponse") {
|
|
79
|
+
resolve(response.payload);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
75
83
|
},
|
|
76
84
|
|
|
77
85
|
/**
|