@open-wa/wa-automate 4.34.0 → 4.34.3

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.
@@ -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
  });
@@ -3011,8 +3012,8 @@ class Client {
3011
3012
  if ((a === null || a === void 0 ? void 0 : a.stickerMetadata) && typeof (a === null || a === void 0 ? void 0 : a.stickerMetadata) !== "object")
3012
3013
  throw new errors_1.CustomError(errors_1.ERROR_NAME.BAD_STICKER_METADATA, `Received ${typeof (a === null || a === void 0 ? void 0 : a.stickerMetadata)}: ${a === null || a === void 0 ? void 0 : a.stickerMetadata}`);
3013
3014
  }
3014
- if (((_a = a === null || a === void 0 ? void 0 : a.stickerMetadata) === null || _a === void 0 ? void 0 : _a.discord) && ((_b = this._createConfig) === null || _b === void 0 ? void 0 : _b.discord)) {
3015
- a.stickerMetadata = { discord: this._createConfig.discord };
3015
+ if (a.stickerMetadata && ((_a = this._createConfig) === null || _a === void 0 ? void 0 : _a.discord)) {
3016
+ a.stickerMetadata = Object.assign(Object.assign({}, (a.stickerMetadata || {})), { discord: `${((_b = a.stickerMetadata) === null || _b === void 0 ? void 0 : _b.discord) || this._createConfig.discord}` });
3016
3017
  }
3017
3018
  try {
3018
3019
  const { data } = yield axios_1.default.post(`${((fallback ? pkg.stickerUrl : 'https://sticker-api.openwa.dev') || this._createConfig.stickerServerEndpoint).replace(/\/$/, '')}/${func}`, Object.assign(Object.assign({}, a), { sessionInfo, config: this.getConfig() }), {
package/dist/cli/index.js CHANGED
@@ -183,9 +183,19 @@ function start() {
183
183
  spinner.succeed(`Port ${PORT} is now free.`);
184
184
  server_1.server.listen(PORT, () => __awaiter(this, void 0, void 0, function* () {
185
185
  spinner.succeed(`\n• Listening on port ${PORT}!`);
186
- (0, index_1.processSendData)({ port: PORT });
186
+ yield (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
+ yield (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 });
@@ -490,7 +490,7 @@ function getWAPage(browser) {
490
490
  * @internal
491
491
  */
492
492
  const kill = (p, b, exit, pid, reason = "LAUNCH_KILL") => __awaiter(void 0, void 0, void 0, function* () {
493
- (0, tools_1.processSendData)({
493
+ yield (0, tools_1.processSendData)({
494
494
  reason
495
495
  });
496
496
  (0, tools_1.timeout)(3000);
@@ -111,7 +111,7 @@ function popup(config) {
111
111
  });
112
112
  });
113
113
  server.listen(PORT);
114
- (0, tools_1.processSendData)({ port: PORT });
114
+ yield (0, tools_1.processSendData)({ port: PORT });
115
115
  const os = (0, os_name_1.default)();
116
116
  const appName = os.includes('macOS') ? 'google chrome' : os.includes('Windows') ? 'chrome' : 'google-chrome';
117
117
  const hasChrome = yield (0, command_exists_1.default)(appName).then(() => true).catch(() => false);
@@ -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) => Promise<unknown>;
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
@@ -211,13 +211,21 @@ exports.timePromise = timePromise;
211
211
  * @param {any} data - The data to be sent to the parent process.
212
212
  * @returns Nothing.
213
213
  */
214
- const processSendData = (data = {}) => {
215
- process.send({
214
+ const processSendData = (data = {}) => __awaiter(void 0, void 0, void 0, function* () {
215
+ const sd = (resolve, reject) => process.send({
216
216
  type: 'process:msg',
217
217
  data
218
+ }, (error) => {
219
+ if (error) {
220
+ console.error(error);
221
+ reject(error);
222
+ }
223
+ resolve(true);
218
224
  });
219
- return;
220
- };
225
+ return yield new Promise((resolve, reject) => {
226
+ sd(resolve, reject);
227
+ });
228
+ });
221
229
  exports.processSendData = processSendData;
222
230
  /**
223
231
  * It generates a link to the GitHub issue template for the current session
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.34.0",
3
+ "version": "4.34.3",
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",