@subiz/widget-v4 4.1.31 → 4.1.33

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 (79) hide show
  1. package/compiled_src/plugin.js +1 -0
  2. package/compiled_src/store/api.js +2 -2
  3. package/compiled_src/store/store.js +26 -1
  4. package/compiled_src/util/campaign.js +2 -6
  5. package/compiled_src/util/common.js +5 -7
  6. package/compiled_src/util/order.js +2 -4
  7. package/compiled_src/util/pubsub.js +3 -6
  8. package/dist/132.js +6661 -0
  9. package/dist/178.js +406 -0
  10. package/dist/213.js +2780 -0
  11. package/dist/335.js +372 -0
  12. package/dist/362.js +107 -0
  13. package/dist/441.js +2983 -0
  14. package/dist/605.js +305 -0
  15. package/dist/678.js +107 -0
  16. package/dist/782.js +107 -0
  17. package/dist/HASH +1 -0
  18. package/dist/assets/img/Facebook.64607ec.png +0 -0
  19. package/dist/assets/img/Zalo.6845707.png +0 -0
  20. package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
  21. package/dist/assets/img/caret.998eb8f.svg +1 -0
  22. package/dist/assets/img/convos_empty.2353007.svg +72 -0
  23. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  24. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  25. package/dist/assets/img/done_gray.d7e8203.svg +4 -0
  26. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  27. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  28. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  29. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  30. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  31. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  32. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  33. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  34. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  35. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  36. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  37. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  38. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  39. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  40. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  41. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  42. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  43. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  44. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  45. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  46. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  47. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  48. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  49. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  50. package/dist/assets/img/empty.29bed2d.svg +23 -0
  51. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  52. package/dist/assets/img/external-link.90577cc.svg +1 -0
  53. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  54. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  55. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  56. package/dist/assets/img/image_default.be0698b.png +0 -0
  57. package/dist/assets/img/info.ebce7ea.svg +1 -0
  58. package/dist/assets/img/loader.37000a7.svg +1 -0
  59. package/dist/assets/img/loading_static.a27f0ac.svg +10 -0
  60. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  61. package/dist/assets/img/package.8d37d0f.svg +5 -0
  62. package/dist/assets/img/package_fade.763c001.svg +1 -0
  63. package/dist/assets/img/rating--average.1ea492c.svg +12 -0
  64. package/dist/assets/img/rating--great.e3d712e.svg +16 -0
  65. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  66. package/dist/assets/img/search.f9705ff.svg +1 -0
  67. package/dist/assets/img/send.6db52a9.svg +3 -0
  68. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  69. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  70. package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
  71. package/dist/assets/img/x.26fdfa3.svg +5 -0
  72. package/dist/malicious-app.js +13 -0
  73. package/dist/screenshoot.html +7 -0
  74. package/dist/screenshoot.js +6365 -0
  75. package/package.json +18 -18
  76. package/src/plugin.js +1 -1
  77. package/src/store/api.js +3 -2
  78. package/src/store/store.js +31 -2
  79. package/src/util/common.js +1 -0
@@ -32,6 +32,7 @@ function Plugin(plugin, store, $container, lib) {
32
32
  if (plugin.type === 'popup' && store.isConverted(plugin.id)) return;
33
33
  let lastrun = store.matchLastPluginRun(plugin.id);
34
34
  if (plugin.type === 'chatbox' || plugin.type === 'notification') lastrun = undefined;
35
+ if (!plugin.enabled) return;
35
36
  let match = _index.default.checkRunConditions(plugin.initiative_frequency, plugin.conditions, lastrun, store);
36
37
  if (!match) return;
37
38
  state = 'running';
@@ -10,7 +10,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
10
10
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
11
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
12
  const ajax = require('@subiz/ajax/src/ajax.js');
13
- ajax.env.XMLHttpRequest = window.XMLHttpRequest;
13
+ ajax.env.XMLHttpRequest = _index.default.XMLHttpRequest;
14
14
  function jsonifyTextPlain(param, done) {
15
15
  let req = param.request;
16
16
  if (req.content_type === 'text/plain' && req.body !== undefined) req.body = _index.default.stringify(req.body);
@@ -41,7 +41,7 @@ class _default {
41
41
  _defineProperty(this, "markAsSeen", (cid, messageId) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/messages/${messageId}/seen`));
42
42
  _defineProperty(this, "getConversation", cid => this.apireq.get(`/accounts/${this.accid}/conversations/${cid}`));
43
43
  _defineProperty(this, "getLocaleContent", locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`));
44
- _defineProperty(this, "sendEvent", data => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/events`, data));
44
+ _defineProperty(this, "sendEvent", data => this.apireq.addQuery('shorten', true).post(`/accounts/${this.accid}/users/${this.uid}/events`, data));
45
45
  _defineProperty(this, "sendTyping", cid => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`));
46
46
  _defineProperty(this, "sendLostFocus", (device, productid, source_id, sku) => this.sendEvent({
47
47
  by: {
@@ -367,7 +367,7 @@ class Store {
367
367
  account_id: accid,
368
368
  user_ref: userRef,
369
369
  user_mask: mask
370
- });
370
+ }, xhrsend);
371
371
  this.realtime.onEvent(this.onWs.bind(this));
372
372
  this.realtime.onInterrupted(() => this.reconnectWs(accid, user.id));
373
373
  this.seenLoop();
@@ -1080,4 +1080,29 @@ let cleanMyLocalStorage = () => {
1080
1080
  }
1081
1081
  }
1082
1082
  });
1083
+ };
1084
+ function dofetch(method, url, body, cb) {
1085
+ let headers = {};
1086
+ if (body) headers['content-type'] = 'text/plain';
1087
+ fetch(url, {
1088
+ method: method,
1089
+ headers: headers,
1090
+ body: body
1091
+ }).then(res => res.text().then(text => cb && cb(text, res.status))).catch(err => cb && cb(err, -1));
1092
+ }
1093
+ var xhrsend = function (method, url, body, cb) {
1094
+ if (typeof _index.default.XMLHttpRequest === 'undefined') return dofetch(method, url, body, cb);
1095
+ var request = new _index.default.XMLHttpRequest();
1096
+ request.onreadystatechange = function (e) {
1097
+ if (request.readyState !== 4) return;
1098
+ cb && cb(request.responseText, request.status);
1099
+ cb = undefined;
1100
+ };
1101
+ request.onerror = function () {
1102
+ cb && cb(request.responseText, -1);
1103
+ cb = undefined;
1104
+ };
1105
+ request.open(method, url);
1106
+ if (body) request.setRequestHeader('content-type', 'text/plain');
1107
+ request.send(body);
1083
1108
  };
@@ -37,9 +37,7 @@ function trackAreaClicked(selector, cb) {
37
37
  on('click', selector, cb);
38
38
  });
39
39
  }
40
- function trackInactivity() {
41
- let seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
42
- let cb = arguments.length > 1 ? arguments[1] : undefined;
40
+ function trackInactivity(seconds = 0, cb) {
43
41
  let events = ['scroll', 'keyup', 'keydown', 'mousemove', 'mousewheel', 'mouseenter', 'mouseover', 'mousedown', 'touchstart', 'touchmove', 'touchenter'];
44
42
  let inactiveSeconds = 0;
45
43
  let resetTime = () => {
@@ -62,9 +60,7 @@ let timeOnPage = 0;
62
60
  common.setInterval(() => {
63
61
  timeOnPage += 5;
64
62
  }, 5000);
65
- function trackTimeOnPage() {
66
- let seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
67
- let cb = arguments.length > 1 ? arguments[1] : undefined;
63
+ function trackTimeOnPage(seconds = 0, cb) {
68
64
  if (seconds < 1) {
69
65
  return common.setTimeout(function () {
70
66
  cb(seconds);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Date = exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = exports.DEFVAL = void 0;
6
+ exports.XMLHttpRequest = exports.Date = exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = exports.DEFVAL = void 0;
7
7
  exports.agentsOfConvo = agentsOfConvo;
8
8
  exports.checkRunConditions = checkRunConditions;
9
9
  exports.clearTimeout = exports.clearInterval = void 0;
@@ -90,6 +90,8 @@ var clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow);
90
90
  exports.clearInterval = clearInterval;
91
91
  var clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow);
92
92
  exports.clearTimeout = clearTimeout;
93
+ var XMLHttpRequest = f.contentWindow.XMLHttpRequest;
94
+ exports.XMLHttpRequest = XMLHttpRequest;
93
95
  function convoOfEv(ev) {
94
96
  if (!ev) return '';
95
97
  switch (ev.type) {
@@ -157,10 +159,7 @@ function getMsgField(ev, fieldName) {
157
159
  function isObject(item) {
158
160
  return item && typeof item === 'object' && !Array.isArray(item);
159
161
  }
160
- function merge(target) {
161
- for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
162
- sources[_key - 1] = arguments[_key];
163
- }
162
+ function merge(target, ...sources) {
164
163
  if (!sources.length) return target;
165
164
  const source = sources.shift();
166
165
  if (isObject(target) && isObject(source)) {
@@ -959,8 +958,7 @@ function getUrlParameter() {
959
958
  }
960
959
  var sleep = ms => new Promise(res => setTimeout(res, ms));
961
960
  exports.sleep = sleep;
962
- function formatCurrency(val) {
963
- let currency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'VND';
961
+ function formatCurrency(val, currency = 'VND') {
964
962
  let currencyObj = ALL_CURRENCIES.find(cur => cur.code === currency) || {
965
963
  name: 'Dong',
966
964
  code: 'VND',
@@ -14,8 +14,7 @@ op.map = common.map;
14
14
  op.each = common.each;
15
15
  op.size = common.size;
16
16
  op.find = common.find;
17
- function getProductPropName(product) {
18
- let seperator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' - ';
17
+ function getProductPropName(product, seperator = ' - ') {
19
18
  let options = op.get(product, 'options', []);
20
19
  let props = op.get(product, 'props', []);
21
20
  let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
@@ -26,8 +25,7 @@ function getProductPropName(product) {
26
25
  });
27
26
  return names.join(seperator);
28
27
  }
29
- function getOrderDisplayName() {
30
- let order = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
+ function getOrderDisplayName(order = {}) {
31
29
  return order.number || order.id || '';
32
30
  }
33
31
  function displayOrderShippingAddress(order, isShorten) {
@@ -14,12 +14,9 @@ class Pubsub {
14
14
  }
15
15
  publish(topic, payload, payload2, payload3) {
16
16
  this.listeners[topic] = filter(this.listeners[topic], sub => sub.obj._isMounted);
17
- map(this.listeners[topic], _ref => {
18
- let {
19
- cb
20
- } = _ref;
21
- return cb(payload, payload2, payload3);
22
- });
17
+ map(this.listeners[topic], ({
18
+ cb
19
+ }) => cb(payload, payload2, payload3));
23
20
  }
24
21
  on2(obj, topic, cb) {
25
22
  if (!this.listeners[topic]) this.listeners[topic] = [];