@subiz/widget-v4 4.1.201 → 4.1.202

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.
Files changed (35) hide show
  1. package/compiled_src/bot.js +1 -7
  2. package/compiled_src/chatbox/Widget.js +1 -0
  3. package/compiled_src/lib.js +1 -1
  4. package/compiled_src/store/store.js +14 -1
  5. package/compiled_src/util/common.js +18 -18
  6. package/dist/{19d6b530a9c.app.js → 19d8a41ce33.app.js} +1 -1
  7. package/dist/{19d6b530a9c.chat.html → 19d8a41ce33.chat.html} +1 -1
  8. package/dist/{19d6b530a9c.chat.js → 19d8a41ce33.chat.js} +1 -1
  9. package/dist/{19d6b530a9c.form.html → 19d8a41ce33.form.html} +1 -1
  10. package/dist/19d8a41ce33.form.js +1 -0
  11. package/dist/{19d6b530a9c.index.html → 19d8a41ce33.index.html} +1 -1
  12. package/dist/{19d6b530a9c.library.html → 19d8a41ce33.library.html} +1 -1
  13. package/dist/{19d6b530a9c.library.js → 19d8a41ce33.library.js} +1 -1
  14. package/dist/{19d6b530a9c.preview.html → 19d8a41ce33.preview.html} +1 -1
  15. package/dist/{19d6b530a9c.preview.js → 19d8a41ce33.preview.js} +1 -1
  16. package/dist/{19d6b530a9c.webview.js → 19d8a41ce33.webview.js} +1 -1
  17. package/dist/HASH +1 -1
  18. package/dist/screenshoot.js +34 -20
  19. package/package.json +1 -1
  20. package/src/bot.js +1 -7
  21. package/src/chatbox/Widget.js +1 -1
  22. package/src/lib.js +1 -1
  23. package/src/store/store.js +17 -2
  24. package/src/util/common.js +22 -21
  25. package/dist/19d6b530a9c.form.js +0 -1
  26. /package/dist/{19d6b530a9c.127.js → 19d8a41ce33.127.js} +0 -0
  27. /package/dist/{19d6b530a9c.132.js → 19d8a41ce33.132.js} +0 -0
  28. /package/dist/{19d6b530a9c.185.js → 19d8a41ce33.185.js} +0 -0
  29. /package/dist/{19d6b530a9c.27.js → 19d8a41ce33.27.js} +0 -0
  30. /package/dist/{19d6b530a9c.278.js → 19d8a41ce33.278.js} +0 -0
  31. /package/dist/{19d6b530a9c.339.js → 19d8a41ce33.339.js} +0 -0
  32. /package/dist/{19d6b530a9c.459.js → 19d8a41ce33.459.js} +0 -0
  33. /package/dist/{19d6b530a9c.490.js → 19d8a41ce33.490.js} +0 -0
  34. /package/dist/{19d6b530a9c.74.js → 19d8a41ce33.74.js} +0 -0
  35. /package/dist/{19d6b530a9c.997.js → 19d8a41ce33.997.js} +0 -0
@@ -19,13 +19,7 @@ function _default(store) {
19
19
  if (!match) return;
20
20
  let welcomMessages = bot.welcome_messages;
21
21
  welcomMessages = _index.default.filter(welcomMessages, msg => {
22
- if (!_index.default.size(msg.attachments)) {
23
- if (msg.block || msg.format === 'block') {
24
- if (_index.default.isBlockEmpty(msg.block)) return false;
25
- } else {
26
- if (!(msg.text || '').trim()) return false;
27
- }
28
- }
22
+ if (_index.default.isEmptyMessage(msg)) return false;
29
23
  return true;
30
24
  });
31
25
  if (_index.default.size(welcomMessages)) {
@@ -798,6 +798,7 @@ class Widget extends _common.Com {
798
798
  agentids = agentids || _index.default.agentsOfConvo(convo)[0];
799
799
  return (0, _preact.h)("div", {
800
800
  class: "convo-list--item",
801
+ "data-cid": convo.id,
801
802
  onClick: () => this.goToConvo(convo.id),
802
803
  key: convo.id
803
804
  }, (0, _preact.h)(_AgentsAvatar.default, {
@@ -20,7 +20,7 @@ class Widget {
20
20
  _defineProperty(this, "getUser", () => _index.default.parseJSON(_index.default.stringify(this.store.matchUser())));
21
21
  _defineProperty(this, "setViewingProduct", p => this.store.linkProduct(p));
22
22
  _defineProperty(this, "getViewingProduct", () => this.store.getLinkedProduct());
23
- _defineProperty(this, "track", () => this.store.track());
23
+ _defineProperty(this, "track", v => this.store.track(v));
24
24
  this.impressionTokens = {};
25
25
  this.domGate = new _index.default.Gate();
26
26
  this.store = new _store.default(ApiURL, FileURL, RealtimeURL, inmem, fake);
@@ -571,7 +571,17 @@ class Store {
571
571
  }
572
572
  this.readyGate.close();
573
573
  accid = (accid || '').trim();
574
- this.lightConvos = this.kv.match('light_convos') || {};
574
+ let lightConvos = this.kv.match('light_convos') || {};
575
+ this.lightConvos = {};
576
+ _index.default.map(lightConvos, convo => {
577
+ let in7Day = convo.created > _index.default.Date.now() - 7 * 24 * 3_600_000;
578
+ let events = _index.default.filter(convo.events, ev => ev.type === 'message_sent');
579
+ let messages = _index.default.map(events, ev => _index.default.get(ev, 'data.message') || {});
580
+ messages = _index.default.filter(messages, msg => !_index.default.isEmptyMessage(msg));
581
+ if (in7Day && _index.default.size(messages)) {
582
+ this.lightConvos[convo.id] = convo;
583
+ }
584
+ });
575
585
  this.cache = new _kv.default(new _lsdb.default('sbz2023', true), 'kv');
576
586
  if (this.realtime) this.realtime.stop();
577
587
  if (this.fake) this.realtime = new _realtime_fake.default();else this.realtime = new Realtime(this.RealtimeURL, realtimep, xhrsend, accid);
@@ -795,6 +805,9 @@ class Store {
795
805
  if (traffic_source) this.kv.put('traffic_source', traffic_source);
796
806
  return;
797
807
  }
808
+ if (typeof e === 'object') {
809
+ if (!e.data) e.data = {};
810
+ }
798
811
  return this.api.sendEvent(e);
799
812
  }
800
813
  async onWs(ev) {
@@ -354,12 +354,6 @@ function filter(collection, predicate) {
354
354
  if (!collection) return [];
355
355
  if (!predicate) return collection;
356
356
  var out = [];
357
- if (Array.isArray(collection)) {
358
- for (let i = 0; i < collection.length; i++) {
359
- if (predicate(collection[i], i)) out.push(collection[i]);
360
- }
361
- return out;
362
- }
363
357
  if (typeof collection === 'object') {
364
358
  var keys = Object.keys(collection);
365
359
  for (let i = 0; i < keys.length; i++) {
@@ -368,6 +362,12 @@ function filter(collection, predicate) {
368
362
  }
369
363
  return out;
370
364
  }
365
+ if (Array.isArray(collection)) {
366
+ for (let i = 0; i < collection.length; i++) {
367
+ if (predicate(collection[i], i)) out.push(collection[i]);
368
+ }
369
+ return out;
370
+ }
371
371
  return out;
372
372
  }
373
373
  function includes(collection, value) {
@@ -380,12 +380,6 @@ function map(collection, predicate) {
380
380
  if (!collection) return [];
381
381
  if (!predicate) predicate = i => i;
382
382
  var out = [];
383
- if (Array.isArray(collection)) {
384
- for (let i = 0; i < collection.length; i++) {
385
- out.push(predicate(collection[i], i));
386
- }
387
- return out;
388
- }
389
383
  if (typeof collection === 'object') {
390
384
  var keys = Object.keys(collection);
391
385
  for (let i = 0; i < keys.length; i++) {
@@ -394,6 +388,12 @@ function map(collection, predicate) {
394
388
  }
395
389
  return out;
396
390
  }
391
+ if (Array.isArray(collection)) {
392
+ for (let i = 0; i < collection.length; i++) {
393
+ out.push(predicate(collection[i], i));
394
+ }
395
+ return out;
396
+ }
397
397
  return out;
398
398
  }
399
399
  function each(collection, predicate) {
@@ -476,12 +476,6 @@ function find(collection, f) {
476
476
  function findIndex(collection, f) {
477
477
  if (!collection) return -1;
478
478
  if (!f) return -1;
479
- if (Array.isArray(collection)) {
480
- for (let i = 0; i < collection.length; i++) {
481
- if (f(collection[i], i)) return i;
482
- }
483
- return -1;
484
- }
485
479
  if (typeof collection === 'object') {
486
480
  var keys = Object.keys(collection);
487
481
  for (let i = 0; i < keys.length; i++) {
@@ -489,6 +483,12 @@ function findIndex(collection, f) {
489
483
  if (f(collection[k], k)) return k;
490
484
  }
491
485
  }
486
+ if (Array.isArray(collection)) {
487
+ for (let i = 0; i < collection.length; i++) {
488
+ if (f(collection[i], i)) return i;
489
+ }
490
+ return -1;
491
+ }
492
492
  return -1;
493
493
  }
494
494
  function orderBy(a, k, d) {