@open-wa/wa-automate 4.34.1 → 4.34.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -701,7 +701,7 @@ export declare class Client {
701
701
  * Returns a PNG DataURL screenshot of the session
702
702
  * @returns `Promise<DataURL>`
703
703
  */
704
- getSnapshot(): Promise<DataURL>;
704
+ getSnapshot(chatId?: ChatId): Promise<DataURL>;
705
705
  /**
706
706
  * Returns an array of group ids where the host account is admin
707
707
  */
@@ -1692,9 +1692,10 @@ class Client {
1692
1692
  * Returns a PNG DataURL screenshot of the session
1693
1693
  * @returns `Promise<DataURL>`
1694
1694
  */
1695
- getSnapshot() {
1695
+ getSnapshot(chatId) {
1696
1696
  return __awaiter(this, void 0, void 0, function* () {
1697
- const screenshot = yield this.getPage().screenshot({
1697
+ const snapshotElement = chatId ? yield this._page.evaluateHandle(({ chatId }) => WAPI.getSnapshotElement(chatId), { chatId }) : this.getPage();
1698
+ const screenshot = yield snapshotElement.screenshot({
1698
1699
  type: "png",
1699
1700
  encoding: "base64"
1700
1701
  });
package/dist/cli/index.js CHANGED
@@ -186,6 +186,16 @@ function start() {
186
186
  (0, index_1.processSendData)({ port: PORT });
187
187
  yield ready(Object.assign(Object.assign(Object.assign(Object.assign({}, cliConfig), createConfig), client.getSessionInfo()), { hostAccountNumber: yield client.getHostNumber() }));
188
188
  }));
189
+ process.on('message', function (data) {
190
+ var _a;
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ if (((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.command) === "port_report") {
193
+ const response = { port: PORT };
194
+ (0, index_1.processSendData)(response);
195
+ return response;
196
+ }
197
+ });
198
+ });
189
199
  if (cliConfig.tunnel) {
190
200
  spinner.info(`\n• Setting up external tunnel`);
191
201
  const tunnel = yield (0, localtunnel_1.default)({ port: PORT });
@@ -67,7 +67,7 @@ export declare function timePromise(fn: () => Promise<any>): Promise<string>;
67
67
  * @param {any} data - The data to be sent to the parent process.
68
68
  * @returns Nothing.
69
69
  */
70
- export declare const processSendData: (data?: any) => void;
70
+ export declare const processSendData: (data?: any) => boolean;
71
71
  /**
72
72
  * It generates a link to the GitHub issue template for the current session
73
73
  * @param {ConfigObject} config - the config object
@@ -212,11 +212,18 @@ exports.timePromise = timePromise;
212
212
  * @returns Nothing.
213
213
  */
214
214
  const processSendData = (data = {}) => {
215
- process.send({
215
+ const sd = () => process.send({
216
216
  type: 'process:msg',
217
217
  data
218
+ }, (error) => {
219
+ if (error) {
220
+ console.error(error);
221
+ }
218
222
  });
219
- return;
223
+ return sd();
224
+ // return await new Promise((resolve, reject)=>{
225
+ // sd(resolve,reject)
226
+ // })
220
227
  };
221
228
  exports.processSendData = processSendData;
222
229
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.34.1",
3
+ "version": "4.34.4",
4
4
  "licenseCheckUrl": "https://funcs.openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://funcs.openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",