@wppconnect-team/wppconnect 1.39.0 → 1.40.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.40.1 (2026-02-28)
2
+
3
+ ### Bug Fixes
4
+
5
+ - bump wa-js version ([#2713](https://github.com/wppconnect-team/wppconnect/issues/2713)) ([4647644](https://github.com/wppconnect-team/wppconnect/commit/46476440010e8c12e02dbfb1ba962342c3c1a39e))
6
+
7
+ # 1.40.0 (2026-02-27)
8
+
9
+ ### Features
10
+
11
+ - add event listener for new chat and expose onNewChat method ([#2712](https://github.com/wppconnect-team/wppconnect/issues/2712)) ([081f355](https://github.com/wppconnect-team/wppconnect/commit/081f35543bac9181bccfc1e815b1c7c5e4123cdd))
12
+
1
13
  # 1.39.0 (2026-02-27)
2
14
 
3
15
  ### Features
@@ -1,12 +1,12 @@
1
+ import { MsgKey } from '@wppconnect/wa-js/dist/whatsapp';
1
2
  import { Page } from 'puppeteer';
2
3
  import { CreateConfig } from '../../config/create-config';
3
- import { Ack, Chat, LiveLocation, Message, ParticipantEvent, PresenceEvent, Wid, IncomingCall } from '../model';
4
+ import { Ack, Chat, IncomingCall, LiveLocation, Message, ParticipantEvent, PresenceEvent, Wid } from '../model';
4
5
  import { SocketState, SocketStream } from '../model/enum';
5
6
  import { InterfaceMode } from '../model/enum/interface-mode';
6
7
  import { InterfaceState } from '../model/enum/interface-state';
7
- import { ProfileLayer } from './profile.layer';
8
8
  import { Label } from '../model/label';
9
- import { MsgKey } from '@wppconnect/wa-js/dist/whatsapp';
9
+ import { ProfileLayer } from './profile.layer';
10
10
  declare global {
11
11
  interface Window {
12
12
  onMessage: any;
@@ -257,4 +257,11 @@ export declare class ListenerLayer extends ProfileLayer {
257
257
  }) => any): {
258
258
  dispose: () => void;
259
259
  };
260
+ /**
261
+ * @event Listens to chats being added to ChatStore (Cache Layer)
262
+ * @returns Disposable object to stop the listening
263
+ */
264
+ onNewChat(callback: (chat: Chat) => any): {
265
+ dispose: () => void;
266
+ };
260
267
  }
@@ -127,6 +127,8 @@ var ListenerLayer = /** @class */ (function (_super) {
127
127
  'onPollResponse',
128
128
  'onUpdateLabel',
129
129
  'onOrderStatusUpdate',
130
+ 'onParticipantsChanged',
131
+ 'onNewChat',
130
132
  ], false);
131
133
  _loop_1 = function (func) {
132
134
  var has;
@@ -177,8 +179,9 @@ var ListenerLayer = /** @class */ (function (_super) {
177
179
  return [3 /*break*/, 2];
178
180
  case 5: return [4 /*yield*/, this.page
179
181
  .evaluate(function () {
182
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
180
183
  try {
181
- if (!window['onMessage'].exposed) {
184
+ if (!((_a = window['onMessage']) === null || _a === void 0 ? void 0 : _a.exposed)) {
182
185
  WPP.on('chat.new_message', function (msg) {
183
186
  if (msg.isSentByMe || msg.isStatusV3) {
184
187
  return;
@@ -195,7 +198,7 @@ var ListenerLayer = /** @class */ (function (_super) {
195
198
  console.error(error);
196
199
  }
197
200
  try {
198
- if (!window['onAck'].exposed) {
201
+ if (!((_b = window['onAck']) === null || _b === void 0 ? void 0 : _b.exposed)) {
199
202
  window.WAPI.waitNewAcknowledgements(window['onAck']);
200
203
  window['onAck'].exposed = true;
201
204
  }
@@ -204,7 +207,7 @@ var ListenerLayer = /** @class */ (function (_super) {
204
207
  console.error(error);
205
208
  }
206
209
  try {
207
- if (!window['onMessageEdit'].exposed) {
210
+ if (!((_c = window['onMessageEdit']) === null || _c === void 0 ? void 0 : _c.exposed)) {
208
211
  WPP.on('chat.msg_edited', function (data) {
209
212
  var eventData = {
210
213
  chat: data.chat,
@@ -220,7 +223,7 @@ var ListenerLayer = /** @class */ (function (_super) {
220
223
  console.error(error);
221
224
  }
222
225
  try {
223
- if (!window['onAnyMessage'].exposed) {
226
+ if (!((_d = window['onAnyMessage']) === null || _d === void 0 ? void 0 : _d.exposed)) {
224
227
  WPP.on('chat.new_message', function (msg) {
225
228
  var serialized = WAPI.processMessageObj(msg, true, false);
226
229
  if (serialized) {
@@ -234,7 +237,7 @@ var ListenerLayer = /** @class */ (function (_super) {
234
237
  console.error(error);
235
238
  }
236
239
  try {
237
- if (!window['onStateChange'].exposed) {
240
+ if (!((_e = window['onStateChange']) === null || _e === void 0 ? void 0 : _e.exposed)) {
238
241
  window.WAPI.onStateChange(window['onStateChange']);
239
242
  window['onStateChange'].exposed = true;
240
243
  }
@@ -243,7 +246,7 @@ var ListenerLayer = /** @class */ (function (_super) {
243
246
  console.error(error);
244
247
  }
245
248
  try {
246
- if (!window['onStreamChange'].exposed) {
249
+ if (!((_f = window['onStreamChange']) === null || _f === void 0 ? void 0 : _f.exposed)) {
247
250
  window.WAPI.onStreamChange(window['onStreamChange']);
248
251
  window['onStreamChange'].exposed = true;
249
252
  }
@@ -252,7 +255,7 @@ var ListenerLayer = /** @class */ (function (_super) {
252
255
  console.error(error);
253
256
  }
254
257
  try {
255
- if (!window['onAddedToGroup'].exposed) {
258
+ if (!((_g = window['onAddedToGroup']) === null || _g === void 0 ? void 0 : _g.exposed)) {
256
259
  window.WAPI.onAddedToGroup(window['onAddedToGroup']);
257
260
  window['onAddedToGroup'].exposed = true;
258
261
  }
@@ -261,7 +264,7 @@ var ListenerLayer = /** @class */ (function (_super) {
261
264
  console.error(error);
262
265
  }
263
266
  try {
264
- if (!window['onIncomingCall'].exposed) {
267
+ if (!((_h = window['onIncomingCall']) === null || _h === void 0 ? void 0 : _h.exposed)) {
265
268
  window.WAPI.onIncomingCall(window['onIncomingCall']);
266
269
  window['onIncomingCall'].exposed = true;
267
270
  }
@@ -270,7 +273,7 @@ var ListenerLayer = /** @class */ (function (_super) {
270
273
  console.error(error);
271
274
  }
272
275
  try {
273
- if (!window['onInterfaceChange'].exposed) {
276
+ if (!((_j = window['onInterfaceChange']) === null || _j === void 0 ? void 0 : _j.exposed)) {
274
277
  window.WAPI.onInterfaceChange(window['onInterfaceChange']);
275
278
  window['onInterfaceChange'].exposed = true;
276
279
  }
@@ -279,7 +282,7 @@ var ListenerLayer = /** @class */ (function (_super) {
279
282
  console.error(error);
280
283
  }
281
284
  try {
282
- if (!window['onNotificationMessage'].exposed) {
285
+ if (!((_k = window['onNotificationMessage']) === null || _k === void 0 ? void 0 : _k.exposed)) {
283
286
  window.WAPI.onNotificationMessage(window['onNotificationMessage']);
284
287
  window['onNotificationMessage'].exposed = true;
285
288
  }
@@ -288,7 +291,7 @@ var ListenerLayer = /** @class */ (function (_super) {
288
291
  console.error(error);
289
292
  }
290
293
  try {
291
- if (!window['onPresenceChanged'].exposed) {
294
+ if (!((_l = window['onPresenceChanged']) === null || _l === void 0 ? void 0 : _l.exposed)) {
292
295
  WPP.on('chat.presence_change', window['onPresenceChanged']);
293
296
  window['onPresenceChanged'].exposed = true;
294
297
  }
@@ -297,7 +300,7 @@ var ListenerLayer = /** @class */ (function (_super) {
297
300
  console.error(error);
298
301
  }
299
302
  try {
300
- if (!window['onLiveLocation'].exposed) {
303
+ if (!((_m = window['onLiveLocation']) === null || _m === void 0 ? void 0 : _m.exposed)) {
301
304
  window.WAPI.onLiveLocation(window['onLiveLocation']);
302
305
  window['onLiveLocation'].exposed = true;
303
306
  }
@@ -306,7 +309,7 @@ var ListenerLayer = /** @class */ (function (_super) {
306
309
  console.error(error);
307
310
  }
308
311
  try {
309
- if (!window['onRevokedMessage'].exposed) {
312
+ if (!((_o = window['onRevokedMessage']) === null || _o === void 0 ? void 0 : _o.exposed)) {
310
313
  WPP.on('chat.msg_revoke', function (data) {
311
314
  var eventData = {
312
315
  author: data.author,
@@ -324,7 +327,7 @@ var ListenerLayer = /** @class */ (function (_super) {
324
327
  console.error(error);
325
328
  }
326
329
  try {
327
- if (!window['onReactionMessage'].exposed) {
330
+ if (!((_p = window['onReactionMessage']) === null || _p === void 0 ? void 0 : _p.exposed)) {
328
331
  WPP.on('chat.new_reaction', function (data) {
329
332
  var eventData = {
330
333
  id: data.id,
@@ -344,7 +347,7 @@ var ListenerLayer = /** @class */ (function (_super) {
344
347
  console.error(error);
345
348
  }
346
349
  try {
347
- if (!window['onPollResponse'].exposed) {
350
+ if (!((_q = window['onPollResponse']) === null || _q === void 0 ? void 0 : _q.exposed)) {
348
351
  WPP.on('chat.poll_response', function (data) {
349
352
  var eventData = {
350
353
  msgId: data.msgId,
@@ -362,7 +365,7 @@ var ListenerLayer = /** @class */ (function (_super) {
362
365
  console.error(error);
363
366
  }
364
367
  try {
365
- if (!window['onUpdateLabel'].exposed) {
368
+ if (!((_r = window['onUpdateLabel']) === null || _r === void 0 ? void 0 : _r.exposed)) {
366
369
  WPP.on('chat.update_label', function (data) {
367
370
  var eventData = {
368
371
  chat: data.chat,
@@ -379,7 +382,7 @@ var ListenerLayer = /** @class */ (function (_super) {
379
382
  console.error(error);
380
383
  }
381
384
  try {
382
- if (!window['onOrderStatusUpdate'].exposed) {
385
+ if (!((_s = window['onOrderStatusUpdate']) === null || _s === void 0 ? void 0 : _s.exposed)) {
383
386
  WPP.on('order.payment_status', function (data) {
384
387
  var eventData = {
385
388
  method: data.method,
@@ -396,7 +399,7 @@ var ListenerLayer = /** @class */ (function (_super) {
396
399
  console.error(error);
397
400
  }
398
401
  try {
399
- if (!window['onParticipantsChanged'].exposed) {
402
+ if (!((_t = window['onParticipantsChanged']) === null || _t === void 0 ? void 0 : _t.exposed)) {
400
403
  WPP.on('group.participant_changed', function (participantChangedEvent) {
401
404
  window['onParticipantsChanged'](participantChangedEvent);
402
405
  });
@@ -406,6 +409,17 @@ var ListenerLayer = /** @class */ (function (_super) {
406
409
  catch (error) {
407
410
  console.error(error);
408
411
  }
412
+ try {
413
+ if (!((_u = window['onNewChat']) === null || _u === void 0 ? void 0 : _u.exposed)) {
414
+ WPP.on('chat.new_chat', function (chat) {
415
+ window['onNewChat'](chat);
416
+ });
417
+ window['onNewChat'].exposed = true;
418
+ }
419
+ }
420
+ catch (error) {
421
+ console.error(error);
422
+ }
409
423
  })
410
424
  .catch(function () { })];
411
425
  case 6:
@@ -646,6 +660,13 @@ var ListenerLayer = /** @class */ (function (_super) {
646
660
  ListenerLayer.prototype.onOrderStatusUpdate = function (callback) {
647
661
  return this.registerEvent('onOrderStatusUpdate', callback);
648
662
  };
663
+ /**
664
+ * @event Listens to chats being added to ChatStore (Cache Layer)
665
+ * @returns Disposable object to stop the listening
666
+ */
667
+ ListenerLayer.prototype.onNewChat = function (callback) {
668
+ return this.registerEvent('onNewChat', callback);
669
+ };
649
670
  return ListenerLayer;
650
671
  }(profile_layer_1.ProfileLayer));
651
672
  exports.ListenerLayer = ListenerLayer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "1.39.0",
3
+ "version": "1.40.1",
4
4
  "description": "WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -93,7 +93,7 @@
93
93
  "webpack-cli": "^6.0.1"
94
94
  },
95
95
  "dependencies": {
96
- "@wppconnect/wa-js": "^3.22.0",
96
+ "@wppconnect/wa-js": "^3.22.1",
97
97
  "@wppconnect/wa-version": "^1.5.3099",
98
98
  "atob": "^2.1.2",
99
99
  "axios": "^1.13.5",