@wppconnect-team/wppconnect 1.19.0 → 1.19.1

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.
@@ -53,7 +53,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
53
53
  function verb(n) { return function (v) { return step([n, v]); }; }
54
54
  function step(op) {
55
55
  if (f) throw new TypeError("Generator is already executing.");
56
- while (_) try {
56
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
57
57
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
58
58
  if (y = 0, t) op = [op[0] & 2, t.value];
59
59
  switch (op[0]) {
@@ -87,14 +87,13 @@ var getInterfaceStatus = function (waPage) { return __awaiter(void 0, void 0, vo
87
87
  switch (_a.label) {
88
88
  case 0: return [4 /*yield*/, waPage
89
89
  .waitForFunction(function () {
90
+ var _a, _b;
90
91
  var elLoginWrapper = document.querySelector('body > div > div > .landing-wrapper');
91
92
  var elQRCodeCanvas = document.querySelector('canvas');
92
93
  if (elLoginWrapper && elQRCodeCanvas) {
93
94
  return 'UNPAIRED';
94
95
  }
95
- var streamStatus = window['Store'] &&
96
- window['Store'].Stream &&
97
- window['Store'].Stream.displayInfo;
96
+ var streamStatus = (_b = (_a = WPP === null || WPP === void 0 ? void 0 : WPP.whatsapp) === null || _a === void 0 ? void 0 : _a.Stream) === null || _b === void 0 ? void 0 : _b.displayInfo;
98
97
  if (['PAIRING', 'RESUMING', 'SYNCING'].includes(streamStatus)) {
99
98
  return 'PAIRING';
100
99
  }
@@ -64,7 +64,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
64
64
  function verb(n) { return function (v) { return step([n, v]); }; }
65
65
  function step(op) {
66
66
  if (f) throw new TypeError("Generator is already executing.");
67
- while (_) try {
67
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
68
68
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
69
69
  if (y = 0, t) op = [op[0] & 2, t.value];
70
70
  switch (op[0]) {
@@ -111,6 +111,7 @@ var puppeteer_extra_plugin_stealth_1 = __importDefault(require("puppeteer-extra-
111
111
  var auth_1 = require("./auth");
112
112
  var WAuserAgente_1 = require("../config/WAuserAgente");
113
113
  var websocket_1 = require("./websocket");
114
+ var sleep_1 = require("../utils/sleep");
114
115
  function unregisterServiceWorker(page) {
115
116
  return __awaiter(this, void 0, void 0, function () {
116
117
  return __generator(this, function (_a) {
@@ -129,6 +130,10 @@ function unregisterServiceWorker(page) {
129
130
  // Disable service worker registration
130
131
  // @ts-ignore
131
132
  navigator.serviceWorker.register = new Promise(function () { });
133
+ setInterval(function () {
134
+ window.onerror = console.error;
135
+ window.onunhandledrejection = console.error;
136
+ }, 500);
132
137
  })];
133
138
  case 1:
134
139
  _a.sent();
@@ -290,10 +295,20 @@ function injectApi(page, onLoadingScreenCallBack) {
290
295
  if (injected) {
291
296
  return [2 /*return*/];
292
297
  }
298
+ // Wait for some loaded modules
299
+ return [4 /*yield*/, page
300
+ .waitForFunction(function () { var _a; return (((_a = window === null || window === void 0 ? void 0 : window.webpackChunkwhatsapp_web_client) === null || _a === void 0 ? void 0 : _a.length) || 0) > 3; })
301
+ .catch(function () { return null; })];
302
+ case 2:
303
+ // Wait for some loaded modules
304
+ _a.sent();
305
+ return [4 /*yield*/, (0, sleep_1.sleep)(100)];
306
+ case 3:
307
+ _a.sent();
293
308
  return [4 /*yield*/, page.addScriptTag({
294
309
  path: require.resolve('@wppconnect/wa-js'),
295
310
  })];
296
- case 2:
311
+ case 4:
297
312
  _a.sent();
298
313
  return [4 /*yield*/, page
299
314
  .evaluate(function () {
@@ -301,15 +316,15 @@ function injectApi(page, onLoadingScreenCallBack) {
301
316
  WPP.conn.setKeepAlive(true);
302
317
  })
303
318
  .catch(function () { return false; })];
304
- case 3:
319
+ case 5:
305
320
  _a.sent();
306
321
  return [4 /*yield*/, page.addScriptTag({
307
322
  path: require.resolve(path.join(__dirname, '../../dist/lib/wapi', 'wapi.js')),
308
323
  })];
309
- case 4:
324
+ case 6:
310
325
  _a.sent();
311
326
  return [4 /*yield*/, onLoadingScreen(page, onLoadingScreenCallBack)];
312
- case 5:
327
+ case 7:
313
328
  _a.sent();
314
329
  // Make sure WAPI is initialized
315
330
  return [4 /*yield*/, page
@@ -319,7 +334,7 @@ function injectApi(page, onLoadingScreenCallBack) {
319
334
  window.WPP.isReady);
320
335
  })
321
336
  .catch(function () { return false; })];
322
- case 6:
337
+ case 8:
323
338
  // Make sure WAPI is initialized
324
339
  _a.sent();
325
340
  return [2 /*return*/];
@@ -64,7 +64,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
64
64
  function verb(n) { return function (v) { return step([n, v]); }; }
65
65
  function step(op) {
66
66
  if (f) throw new TypeError("Generator is already executing.");
67
- while (_) try {
67
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
68
68
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
69
69
  if (y = 0, t) op = [op[0] & 2, t.value];
70
70
  switch (op[0]) {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {