@subiz/widget-v4 4.1.199 → 4.1.200

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 (56) hide show
  1. package/assets/less/message.less +1 -1
  2. package/assets/less/widget_header.less +0 -1
  3. package/compiled_src/chatbox/Event.js +1 -1
  4. package/compiled_src/chatbox/Events.js +2 -1
  5. package/compiled_src/lib.js +1 -0
  6. package/compiled_src/plugin.js +1 -0
  7. package/compiled_src/store/store.js +3 -0
  8. package/compiled_src/util/common.js +27 -14
  9. package/compiled_src/util/common.test.js +43 -133
  10. package/dist/132.js +21 -21
  11. package/dist/185.js +49 -49
  12. package/dist/{19c2dc9a6ec.132.js → 19c2dd58182.132.js} +1 -1
  13. package/dist/19c2dd58182.185.js +1 -0
  14. package/dist/19c2dd58182.278.js +1 -0
  15. package/dist/19c2dd58182.339.js +1 -0
  16. package/dist/19c2dd58182.459.js +1 -0
  17. package/dist/19c2dd58182.app.js +1 -0
  18. package/dist/{19c2dc9a6ec.chat.html → 19c2dd58182.chat.html} +1 -1
  19. package/dist/19c2dd58182.chat.js +1 -0
  20. package/dist/{19c2dc9a6ec.form.html → 19c2dd58182.form.html} +1 -1
  21. package/dist/{19c2dc9a6ec.form.js → 19c2dd58182.form.js} +1 -1
  22. package/dist/{19c2dc9a6ec.index.html → 19c2dd58182.index.html} +1 -1
  23. package/dist/{19c2dc9a6ec.library.html → 19c2dd58182.library.html} +1 -1
  24. package/dist/19c2dd58182.library.js +1 -0
  25. package/dist/{19c2dc9a6ec.preview.html → 19c2dd58182.preview.html} +1 -1
  26. package/dist/19c2dd58182.preview.js +1 -0
  27. package/dist/19c2dd58182.webview.js +1 -0
  28. package/dist/459.js +11 -11
  29. package/dist/74.js +1 -0
  30. package/dist/HASH +1 -1
  31. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  32. package/dist/screenshoot.js +3050 -3043
  33. package/package.json +10 -9
  34. package/src/chatbox/Event.js +1 -1
  35. package/src/chatbox/Events.js +2 -1
  36. package/src/chatbox/Widget.js +1 -0
  37. package/src/lib.js +2 -0
  38. package/src/plugin.js +1 -0
  39. package/src/store/store.js +3 -0
  40. package/src/util/common.js +31 -16
  41. package/src/util/common.test.js +108 -193
  42. package/dist/19c2dc9a6ec.185.js +0 -1
  43. package/dist/19c2dc9a6ec.278.js +0 -1
  44. package/dist/19c2dc9a6ec.339.js +0 -1
  45. package/dist/19c2dc9a6ec.459.js +0 -1
  46. package/dist/19c2dc9a6ec.app.js +0 -1
  47. package/dist/19c2dc9a6ec.chat.js +0 -1
  48. package/dist/19c2dc9a6ec.library.js +0 -1
  49. package/dist/19c2dc9a6ec.preview.js +0 -1
  50. package/dist/19c2dc9a6ec.webview.js +0 -1
  51. package/dist/DEVHASH +0 -1
  52. /package/dist/{19c2dc9a6ec.127.js → 19c2dd58182.127.js} +0 -0
  53. /package/dist/{19c2dc9a6ec.27.js → 19c2dd58182.27.js} +0 -0
  54. /package/dist/{19c2dc9a6ec.490.js → 19c2dd58182.490.js} +0 -0
  55. /package/dist/{19c2dc9a6ec.74.js → 19c2dd58182.74.js} +0 -0
  56. /package/dist/{19c2dc9a6ec.997.js → 19c2dd58182.997.js} +0 -0
@@ -821,7 +821,7 @@ a.product_attachment__title {
821
821
  z-index: 10;
822
822
 
823
823
  &.ended {
824
- bottom: 14px;
824
+ bottom: -10px;
825
825
  }
826
826
  }
827
827
 
@@ -85,7 +85,6 @@
85
85
  }
86
86
 
87
87
  .widget-header--description {
88
- color: red;
89
88
  position: relative; // for tooltip
90
89
  text-align: center;
91
90
  margin-top: 15px;
@@ -490,7 +490,7 @@ class Event extends _common.Com {
490
490
  onClick: () => this.onSendReaction(hasDislike ? 'remove_dislike' : 'dislike')
491
491
  }, (0, _preact.h)("div", {
492
492
  class: "message-event-action-btn-svg dislike"
493
- }))), _index.default.get(this.props.event, 'is_end') && (0, _preact.h)("div", {
493
+ }))), _index.default.get(this.props.event, 'is_end') && !this.props.isConvoEnded && (0, _preact.h)("div", {
494
494
  class: "message-event-actions-static"
495
495
  }, (0, _preact.h)("div", {
496
496
  class: likecls,
@@ -151,7 +151,7 @@ class Events extends _common.Com {
151
151
  processEvents(convo, events);
152
152
  events.push(fakeev);
153
153
  let $events = _index.default.map(events, ev => {
154
- let isLast = ev.is_last_message_send;
154
+ let isLast = ev.is_last_message_send && _index.default.get(convo, 'state') !== 'ended';
155
155
  return (0, _preact.h)(_Event.default, {
156
156
  isLast: isLast,
157
157
  chatbox: this.props.chatbox,
@@ -162,6 +162,7 @@ class Events extends _common.Com {
162
162
  onPostback: this.props.onPostback,
163
163
  onFocusSourceEventFromQuote: this.onFocusSourceEventFromQuote,
164
164
  ref: ele => this.setEventChildRef(ele, ev.ev.id),
165
+ isConvoEnded: _index.default.get(convo, 'state') === 'ended',
165
166
  event: ev,
166
167
  t: this.props.t,
167
168
  key: ev.ev.id
@@ -77,6 +77,7 @@ class Widget {
77
77
  let accid = param.account_id;
78
78
  let ref = param.ref;
79
79
  let user = await this.store.init(accid, undefined, ref, param);
80
+ if (this.store.isDead()) return user;
80
81
  _index.default.setTimeout(() => window.postMessage({
81
82
  type: 'widget_loaded',
82
83
  account_id: accid
@@ -17,6 +17,7 @@ function Plugin(plugin, store, $container, lib) {
17
17
  if (!$container) throw '$div must is a valid html node';
18
18
  var $div = document.createElement('div');
19
19
  $div.id = plugin.id;
20
+ if (store.isDead()) return;
20
21
  let acc = store.matchAccount();
21
22
  $div.setAttribute('sbz-plugin-type', plugin.type);
22
23
  $div.setAttribute('sbz-plugin-account-id', acc.id);
@@ -1282,6 +1282,9 @@ class Store {
1282
1282
  if (this.cache) this.cache.destroy();
1283
1283
  this.pubsub.publish('destroy');
1284
1284
  }
1285
+ isDead() {
1286
+ return this._die;
1287
+ }
1285
1288
  destroy() {
1286
1289
  this._die = true;
1287
1290
  this.clearBrowserData();
@@ -7,6 +7,7 @@ exports.XMLHttpRequest = exports.Date = exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE
7
7
  exports.agentsOfConvo = agentsOfConvo;
8
8
  exports.blockToText = blockToText;
9
9
  exports.checkRunConditions = checkRunConditions;
10
+ exports.checkUrlCondition = checkUrlCondition;
10
11
  exports.clearTimeout = exports.clearInterval = void 0;
11
12
  exports.cloneDeep = cloneDeep;
12
13
  exports.convoOfEv = convoOfEv;
@@ -832,20 +833,7 @@ function checkRunConditions(freq, conds, lastrun, store) {
832
833
  var cond = conds[i];
833
834
  switch (cond.key) {
834
835
  case 'url':
835
- let exclude_urls = filter(cond.exclude_urls, url => norm(url));
836
- if (size(exclude_urls) > 0) {
837
- let found = find(exclude_urls, url => {
838
- return norm(window.location.href).indexOf(norm(url)) > -1;
839
- });
840
- if (found) return false;
841
- }
842
- let urls = filter(cond.urls, url => norm(url));
843
- if (size(urls) > 0) {
844
- let found = find(urls, url => {
845
- return norm(window.location.href).indexOf(norm(url)) > -1;
846
- });
847
- if (!found) return false;
848
- }
836
+ if (!checkUrlCondition(cond, window.location.href)) return false;
849
837
  break;
850
838
  case 'url_path':
851
839
  let excludePaths = filter(cond.exclude_url_paths, url => norm(url));
@@ -1343,4 +1331,29 @@ function isEmptyAttachment(msg) {
1343
1331
  }
1344
1332
  return true;
1345
1333
  })) == 0;
1334
+ }
1335
+ function checkUrlCondition(cond, href) {
1336
+ let exclude_urls = filter(cond.exclude_urls, url => norm(url));
1337
+ let foundExclude = false;
1338
+ let excludeLen = 0;
1339
+ map(exclude_urls, url => {
1340
+ if (norm(href).indexOf(url) > -1) {
1341
+ if (excludeLen < size(url)) excludeLen = size(url);
1342
+ foundExclude = true;
1343
+ }
1344
+ });
1345
+ let includeLen = 0;
1346
+ let urls = filter(cond.urls, url => norm(url));
1347
+ let foundInclude = size(urls) == 0;
1348
+ map(urls, url => {
1349
+ if (norm(href).indexOf(url) > -1) {
1350
+ if (includeLen < size(url)) includeLen = size(url);
1351
+ foundInclude = true;
1352
+ }
1353
+ });
1354
+ if (foundExclude) {
1355
+ if (excludeLen >= includeLen) return false;
1356
+ }
1357
+ if (!foundInclude) return false;
1358
+ return true;
1346
1359
  }
@@ -1,137 +1,47 @@
1
1
  "use strict";
2
2
 
3
- const test = require('tape');
4
- const util = require('./common.js');
5
- test('util.getNotiDescription', t => {
6
- var tcs = [{
7
- desc: 'not a message sent',
8
- event: {
9
- type: 'conversation_updated'
10
- },
11
- text: ''
12
- }, {
13
- desc: 'an email',
14
- event: {
15
- type: 'message_sent',
16
- data: {
17
- message: {
18
- fields: [{
19
- key: 'from',
20
- value: '"thanh"'
21
- }, {
22
- key: 'to',
23
- value: '"van"'
24
- }]
25
- }
26
- }
27
- },
28
- text: 'sent an email'
29
- }, {
30
- desc: 'empty msg',
31
- event: {},
32
- text: ''
33
- }, {
34
- desc: 'markdown',
35
- event: {
36
- type: 'message_sent',
37
- data: {
38
- message: {
39
- format: 'markdown',
40
- text: 'xin chao'
41
- }
42
- }
43
- },
44
- text: 'sent a message'
45
- }, {
46
- desc: 'html',
47
- event: {
48
- type: 'message_sent',
49
- data: {
50
- message: {
51
- format: 'html',
52
- text: '<b>xin chao</b>'
53
- }
54
- }
55
- },
56
- text: 'sent a message'
57
- }, {
58
- desc: 'multiple attachemnts',
59
- event: {
60
- type: 'message_sent',
61
- data: {
62
- message: {
63
- attachments: [{}, {}, {}]
64
- }
65
- }
66
- },
67
- text: 'sent a message with 3 attachments'
68
- }, {
69
- desc: 'text with attachment',
70
- event: {
71
- type: 'message_sent',
72
- data: {
73
- message: {
74
- type: 'text',
75
- text: 'xin chao',
76
- attachments: [{}]
77
- }
78
- }
79
- },
80
- text: 'sent a message with 1 attachments'
81
- }, {
82
- desc: '1 attachment no type',
83
- event: {
84
- type: 'message_sent',
85
- data: {
86
- message: {
87
- attachments: [{}]
88
- }
89
- }
90
- },
91
- text: 'sent an attachment'
92
- }, {
93
- desc: 'audio ',
94
- event: {
95
- type: 'message_sent',
96
- data: {
97
- message: {
98
- attachments: [{
99
- mimetype: 'audio/mp3'
100
- }]
101
- }
102
- }
103
- },
104
- text: 'sent an audio'
105
- }, {
106
- desc: 'video',
107
- event: {
108
- type: 'message_sent',
109
- data: {
110
- message: {
111
- attachments: [{
112
- mimetype: 'video/ogg'
113
- }]
114
- }
115
- }
116
- },
117
- text: 'sent a video'
118
- }, {
119
- desc: 'image',
120
- event: {
121
- type: 'message_sent',
122
- data: {
123
- message: {
124
- attachments: [{
125
- mimetype: 'image/jpeg'
126
- }]
127
- }
3
+ var _module = require("module");
4
+ const _require = (0, _module.createRequire)(import.meta.url);
5
+ global.require = _require;
6
+ global.XMLHttpRequest = {
7
+ prototype: {
8
+ open: function () {}
9
+ }
10
+ };
11
+ global.document = {
12
+ JSON: JSON,
13
+ body: {
14
+ appendChild: function () {}
15
+ },
16
+ documentElement: {
17
+ appendChild: function () {}
18
+ },
19
+ createElement: function () {
20
+ return {
21
+ contentWindow: global,
22
+ contentDocument: global.document,
23
+ style: {
24
+ display: false
128
25
  }
26
+ };
27
+ }
28
+ };
29
+ const test = _require('tape');
30
+ const util = _require('./common.js');
31
+ test('util.checkUrlCondition', t => {
32
+ var tcs = [{
33
+ name: 'minvoice',
34
+ cond: {
35
+ key: 'url',
36
+ urls: ['qlhd.minvoice.com.vn'],
37
+ exclude_urls: ['minvoice.com.vn', 'minvoice.net', 'hdt.minvoice.com.vn']
129
38
  },
130
- text: 'sent a picture'
39
+ href: 'https://qlhd.minvoice.com.vn/#/login',
40
+ pass: true
131
41
  }];
132
42
  tcs.map(tc => {
133
- var out = util.getNotiDescription(tc.event);
134
- t.equal(out, tc.text);
43
+ var out = util.checkUrlCondition(tc.cond, tc.href);
44
+ t.equal(out, tc.pass);
135
45
  });
136
46
  t.end();
137
47
  });
@@ -361,17 +271,17 @@ test('test insert message', t => {
361
271
  });
362
272
  test('mapizeDeep a map', t => {
363
273
  var topicM = {
364
- '0': {
274
+ 0: {
365
275
  topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxnairroppcktrg',
366
276
  read: false,
367
277
  updated: 1570586074000
368
278
  },
369
- '1': {
279
+ 1: {
370
280
  topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxmkozwryrgjvag',
371
281
  read: false,
372
282
  updated: 1570551305000
373
283
  },
374
- '2': {
284
+ 2: {
375
285
  topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlvkqgspihkfzsnm',
376
286
  read: false,
377
287
  updated: 1570289320000
@@ -400,11 +310,11 @@ test('mapizeDeep a map', t => {
400
310
  });
401
311
  test('mapize a map', t => {
402
312
  var topicM = {
403
- '0': {
313
+ 0: {
404
314
  topic: 't1',
405
315
  updated: 157
406
316
  },
407
- '1': {
317
+ 1: {
408
318
  topic: 't2',
409
319
  updated: 158
410
320
  }
package/dist/132.js CHANGED
@@ -2509,27 +2509,6 @@ class Popup extends common/* Com */.Mw {
2509
2509
 
2510
2510
  /***/ },
2511
2511
 
2512
- /***/ 2931
2513
- (module, __unused_webpack_exports, __webpack_require__) {
2514
-
2515
- module.exports = __webpack_require__.p + "assets/img/Zalo.6845707.png";
2516
-
2517
- /***/ },
2518
-
2519
- /***/ 4707
2520
- (module, __unused_webpack_exports, __webpack_require__) {
2521
-
2522
- module.exports = __webpack_require__.p + "assets/img/Facebook.64607ec.png";
2523
-
2524
- /***/ },
2525
-
2526
- /***/ 8271
2527
- (module, __unused_webpack_exports, __webpack_require__) {
2528
-
2529
- module.exports = __webpack_require__.p + "assets/img/fb_inverse_circle.36c2cfc.png";
2530
-
2531
- /***/ },
2532
-
2533
2512
  /***/ 9459
2534
2513
  (module) {
2535
2514
 
@@ -2797,6 +2776,27 @@ module.exports = function () {
2797
2776
  return module.exports;
2798
2777
  }();
2799
2778
 
2779
+ /***/ },
2780
+
2781
+ /***/ 4707
2782
+ (module, __unused_webpack_exports, __webpack_require__) {
2783
+
2784
+ module.exports = __webpack_require__.p + "assets/img/Facebook.64607ec.png";
2785
+
2786
+ /***/ },
2787
+
2788
+ /***/ 2931
2789
+ (module, __unused_webpack_exports, __webpack_require__) {
2790
+
2791
+ module.exports = __webpack_require__.p + "assets/img/Zalo.6845707.png";
2792
+
2793
+ /***/ },
2794
+
2795
+ /***/ 8271
2796
+ (module, __unused_webpack_exports, __webpack_require__) {
2797
+
2798
+ module.exports = __webpack_require__.p + "assets/img/fb_inverse_circle.36c2cfc.png";
2799
+
2800
2800
  /***/ }
2801
2801
 
2802
2802
  }]);
package/dist/185.js CHANGED
@@ -1,40 +1,5 @@
1
1
  (self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[185],{
2
2
 
3
- /***/ 185
4
- (module, __unused_webpack_exports, __webpack_require__) {
5
-
6
- module.exports = __webpack_require__.p + "assets/img/loader.37000a7.svg";
7
-
8
- /***/ },
9
-
10
- /***/ 1113
11
- (module, __unused_webpack_exports, __webpack_require__) {
12
-
13
- module.exports = __webpack_require__.p + "assets/img/ghn.070f8e3.svg";
14
-
15
- /***/ },
16
-
17
- /***/ 2523
18
- (module, __unused_webpack_exports, __webpack_require__) {
19
-
20
- module.exports = __webpack_require__.p + "assets/img/shop_faded.df7845a.svg";
21
-
22
- /***/ },
23
-
24
- /***/ 3080
25
- (module, __unused_webpack_exports, __webpack_require__) {
26
-
27
- module.exports = __webpack_require__.p + "assets/img/x.26fdfa3.svg";
28
-
29
- /***/ },
30
-
31
- /***/ 3142
32
- (module, __unused_webpack_exports, __webpack_require__) {
33
-
34
- module.exports = __webpack_require__.p + "assets/img/not_found_search.2ddb8d1.png";
35
-
36
- /***/ },
37
-
38
3
  /***/ 4185
39
4
  (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
40
5
 
@@ -1761,38 +1726,38 @@ class Order extends common/* Com */.Mw {
1761
1726
 
1762
1727
  /***/ },
1763
1728
 
1764
- /***/ 5244
1729
+ /***/ 7741
1765
1730
  (module, __unused_webpack_exports, __webpack_require__) {
1766
1731
 
1767
- module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
1732
+ module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
1768
1733
 
1769
1734
  /***/ },
1770
1735
 
1771
- /***/ 5452
1736
+ /***/ 5860
1772
1737
  (module, __unused_webpack_exports, __webpack_require__) {
1773
1738
 
1774
- module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
1739
+ module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
1775
1740
 
1776
1741
  /***/ },
1777
1742
 
1778
- /***/ 5860
1743
+ /***/ 6907
1779
1744
  (module, __unused_webpack_exports, __webpack_require__) {
1780
1745
 
1781
- module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
1746
+ module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
1782
1747
 
1783
1748
  /***/ },
1784
1749
 
1785
- /***/ 6857
1750
+ /***/ 1113
1786
1751
  (module, __unused_webpack_exports, __webpack_require__) {
1787
1752
 
1788
- module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
1753
+ module.exports = __webpack_require__.p + "assets/img/ghn.070f8e3.svg";
1789
1754
 
1790
1755
  /***/ },
1791
1756
 
1792
- /***/ 6907
1757
+ /***/ 7362
1793
1758
  (module, __unused_webpack_exports, __webpack_require__) {
1794
1759
 
1795
- module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
1760
+ module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
1796
1761
 
1797
1762
  /***/ },
1798
1763
 
@@ -1803,17 +1768,17 @@ module.exports = __webpack_require__.p + "assets/img/info.ebce7ea.svg";
1803
1768
 
1804
1769
  /***/ },
1805
1770
 
1806
- /***/ 7362
1771
+ /***/ 185
1807
1772
  (module, __unused_webpack_exports, __webpack_require__) {
1808
1773
 
1809
- module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
1774
+ module.exports = __webpack_require__.p + "assets/img/loader.37000a7.svg";
1810
1775
 
1811
1776
  /***/ },
1812
1777
 
1813
- /***/ 7741
1778
+ /***/ 3142
1814
1779
  (module, __unused_webpack_exports, __webpack_require__) {
1815
1780
 
1816
- module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
1781
+ module.exports = __webpack_require__.p + "assets/img/not_found_search.2ddb8d1.png";
1817
1782
 
1818
1783
  /***/ },
1819
1784
 
@@ -1822,6 +1787,41 @@ module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
1822
1787
 
1823
1788
  module.exports = __webpack_require__.p + "assets/img/package.8d37d0f.svg";
1824
1789
 
1790
+ /***/ },
1791
+
1792
+ /***/ 6857
1793
+ (module, __unused_webpack_exports, __webpack_require__) {
1794
+
1795
+ module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
1796
+
1797
+ /***/ },
1798
+
1799
+ /***/ 5452
1800
+ (module, __unused_webpack_exports, __webpack_require__) {
1801
+
1802
+ module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
1803
+
1804
+ /***/ },
1805
+
1806
+ /***/ 5244
1807
+ (module, __unused_webpack_exports, __webpack_require__) {
1808
+
1809
+ module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
1810
+
1811
+ /***/ },
1812
+
1813
+ /***/ 2523
1814
+ (module, __unused_webpack_exports, __webpack_require__) {
1815
+
1816
+ module.exports = __webpack_require__.p + "assets/img/shop_faded.df7845a.svg";
1817
+
1818
+ /***/ },
1819
+
1820
+ /***/ 3080
1821
+ (module, __unused_webpack_exports, __webpack_require__) {
1822
+
1823
+ module.exports = __webpack_require__.p + "assets/img/x.26fdfa3.svg";
1824
+
1825
1825
  /***/ }
1826
1826
 
1827
1827
  }]);