@subiz/widget-v4 4.1.71 → 4.1.73

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 (92) hide show
  1. package/app.js +0 -42
  2. package/assets/less/widget.less +6 -5
  3. package/assets/less/widget_header.less +5 -3
  4. package/compiled_src/chatbox/AudioAttachments.js +25 -32
  5. package/compiled_src/chatbox/Event.js +19 -3
  6. package/compiled_src/chatbox/InfoMessage.js +2 -1
  7. package/compiled_src/chatbox/OrderAttachments.js +102 -6
  8. package/compiled_src/chatbox/PoweredBy.js +20 -27
  9. package/compiled_src/chatbox/TextMessage.js +0 -14
  10. package/compiled_src/chatbox/VideoAttachments.js +1 -0
  11. package/compiled_src/chatbox/Widget.js +21 -21
  12. package/compiled_src/chatbox/time.js +46 -28
  13. package/compiled_src/lib.js +2 -2
  14. package/compiled_src/order/icon.js +2 -2
  15. package/compiled_src/order/index.js +2 -2
  16. package/compiled_src/plugin.js +2 -4
  17. package/compiled_src/store/api.js +1 -16
  18. package/compiled_src/store/store.js +2 -5
  19. package/compiled_src/util/common.js +12 -494
  20. package/compiled_src/util/index.js +0 -2
  21. package/dist/127.js +273 -0
  22. package/dist/132.js +2 -2
  23. package/dist/185.js +1885 -0
  24. package/dist/18eaf7ad0c6.127.js +1 -0
  25. package/dist/{18e74ca84ff.132.js → 18eaf7ad0c6.132.js} +1 -1
  26. package/dist/18eaf7ad0c6.185.js +1 -0
  27. package/dist/18eaf7ad0c6.278.js +1 -0
  28. package/dist/{18e74ca84ff.490.js → 18eaf7ad0c6.490.js} +1 -1
  29. package/dist/{18e74ca84ff.74.js → 18eaf7ad0c6.74.js} +1 -1
  30. package/dist/18eaf7ad0c6.app.js +1 -0
  31. package/dist/{18e74ca84ff.index.html → 18eaf7ad0c6.index.html} +1 -1
  32. package/dist/{18e74ca84ff.library.html → 18eaf7ad0c6.library.html} +1 -1
  33. package/dist/18eaf7ad0c6.library.js +1 -0
  34. package/dist/{18e74ca84ff.preview.html → 18eaf7ad0c6.preview.html} +1 -1
  35. package/dist/18eaf7ad0c6.preview.js +1 -0
  36. package/dist/18eaf7ad0c6.screenshoot.js +1 -0
  37. package/dist/18eaf7ad0c6.webview.js +1 -0
  38. package/dist/18ed1c3d33e.127.js +1 -0
  39. package/dist/18ed1c3d33e.132.js +1 -0
  40. package/dist/18ed1c3d33e.185.js +1 -0
  41. package/dist/18ed1c3d33e.27.js +1 -0
  42. package/dist/18ed1c3d33e.278.js +1 -0
  43. package/dist/18ed1c3d33e.459.js +1 -0
  44. package/dist/18ed1c3d33e.490.js +1 -0
  45. package/dist/18ed1c3d33e.74.js +1 -0
  46. package/dist/18ed1c3d33e.997.js +1 -0
  47. package/dist/18ed1c3d33e.app.js +1 -0
  48. package/dist/18ed1c3d33e.index.html +33 -0
  49. package/dist/18ed1c3d33e.library.html +33 -0
  50. package/dist/18ed1c3d33e.library.js +1 -0
  51. package/dist/18ed1c3d33e.preview.html +759 -0
  52. package/dist/18ed1c3d33e.preview.js +1 -0
  53. package/dist/18ed1c3d33e.screenshoot.js +1 -0
  54. package/dist/18ed1c3d33e.webview.js +1 -0
  55. package/dist/278.js +1 -1
  56. package/dist/490.js +1 -1
  57. package/dist/74.js +1 -1
  58. package/dist/HASH +1 -1
  59. package/dist/screenshoot.html +1 -1
  60. package/dist/screenshoot.js +4740 -627
  61. package/inject.js +3 -3
  62. package/package.json +6 -6
  63. package/src/chatbox/AudioAttachments.js +19 -26
  64. package/src/chatbox/Event.js +22 -3
  65. package/src/chatbox/InfoMessage.js +11 -11
  66. package/src/chatbox/OrderAttachments.js +118 -5
  67. package/src/chatbox/PoweredBy.js +14 -22
  68. package/src/chatbox/TextMessage.js +0 -14
  69. package/src/chatbox/VideoAttachments.js +1 -1
  70. package/src/chatbox/Widget.js +16 -20
  71. package/src/chatbox/time.js +54 -24
  72. package/src/lib.js +2 -2
  73. package/src/order/icon.js +2 -2
  74. package/src/order/index.js +2 -2
  75. package/src/plugin.js +4 -3
  76. package/src/store/api.js +1 -14
  77. package/src/store/store.js +3 -11
  78. package/src/util/common.js +13 -215
  79. package/src/util/index.js +0 -3
  80. package/compiled_src/util/order.js +0 -112
  81. package/dist/18e74ca84ff.278.js +0 -1
  82. package/dist/18e74ca84ff.497.js +0 -1
  83. package/dist/18e74ca84ff.app.js +0 -1
  84. package/dist/18e74ca84ff.library.js +0 -1
  85. package/dist/18e74ca84ff.preview.js +0 -1
  86. package/dist/18e74ca84ff.screenshoot.js +0 -1
  87. package/dist/18e74ca84ff.webview.js +0 -1
  88. package/dist/497.js +0 -6721
  89. package/src/util/order.js +0 -120
  90. /package/dist/{18e74ca84ff.27.js → 18eaf7ad0c6.27.js} +0 -0
  91. /package/dist/{18e74ca84ff.459.js → 18eaf7ad0c6.459.js} +0 -0
  92. /package/dist/{18e74ca84ff.997.js → 18eaf7ad0c6.997.js} +0 -0
@@ -20,21 +20,16 @@ class Time extends _common.Com {
20
20
  }
21
21
  updateTime() {
22
22
  var t = '';
23
- if (this.props.ago) {
24
- if (this.props.short) {
25
- if (Math.abs(this.props.time - new _index.default.Date().getTime()) > 86400000 * 10) {
26
- let tim = new _index.default.Date(this.props.time);
27
- let tzyear = tim.getFullYear();
28
- let locale = _index.default.get(navigator, 'languages.0', 'en-US');
29
- let tzmonthname = tim.toLocaleDateString(locale, {
30
- month: 'short'
31
- });
32
- let tzdate = tim.getDate();
33
- t = tzdate + ' ' + tzmonthname + ' ' + tzyear;
34
- }
23
+ let forceLocale = '';
24
+ if (this.props.t) {
25
+ if (this.props.t.locale && typeof this.props.t.locale === 'function') {
26
+ forceLocale = this.props.t.locale();
35
27
  }
36
- if (!t && this.props.time > 0) t = ago(this.props.time, new _index.default.Date().getTime());
37
- } else t = _index.default.shortTime(this.props.time, this.props.tzoffset);
28
+ }
29
+ if (this.props.ago) {
30
+ if (this.props.short) {}
31
+ if (!t && this.props.time > 0) t = ago(this.props.time, new _index.default.Date().getTime(), this.props.t);
32
+ } else t = _index.default.shortTime(this.props.time, this.props.tzoffset, Date.now(), forceLocale);
38
33
  if (this.props.uppercase) t = t.toUpperCase();
39
34
  if (t === this.state.t) return;
40
35
  this.setState({
@@ -46,26 +41,49 @@ class Time extends _common.Com {
46
41
  this.updateTime();
47
42
  }
48
43
  render() {
44
+ let locale = _index.default.get(navigator, 'languages.0', 'en-US');
45
+ if (this.props.t) {
46
+ if (this.props.t.locale && typeof this.props.t.locale === 'function') {
47
+ locale = this.props.t.locale();
48
+ }
49
+ }
50
+ let title = new Date(this.props.time).toLocaleString(locale);
49
51
  return (0, _preact.h)("span", {
50
- style: this.props.style
52
+ style: this.props.style,
53
+ title: title
51
54
  }, this.state.t);
52
55
  }
53
56
  }
54
57
  exports.default = Time;
55
- function ago(timeA, timeB) {
56
- const relObj = {
57
- s: '%d s',
58
- m: '1m',
59
- mm: '%dm',
60
- h: '1h',
61
- hh: '%dh',
62
- d: '1d',
63
- dd: '%dd',
64
- M: '1M',
65
- MM: '%M',
66
- y: '1y',
67
- yy: '%dy'
58
+ function ago(timeA, timeB, t) {
59
+ let relObj = {
60
+ s: '%d sec',
61
+ m: '1 min',
62
+ mm: '%d mins',
63
+ h: '1 hour',
64
+ hh: '%d hours',
65
+ d: '1 day',
66
+ dd: '%d days',
67
+ M: '1 month',
68
+ MM: '%d months',
69
+ y: '1 year',
70
+ yy: '%d years'
68
71
  };
72
+ if (t) {
73
+ relObj = {
74
+ s: `%d ${t('second_short')}`,
75
+ m: `1 ${t('minute_short')}`,
76
+ mm: `%d ${t('minutes_short')}`,
77
+ h: `1 ${t('hour_short')}`,
78
+ hh: `%d ${t('hours_short')}`,
79
+ d: `1 ${t('day_short')}`,
80
+ dd: `%d ${t('days_short')}`,
81
+ M: `1 ${t('month_short')}`,
82
+ MM: `%d ${t('months_short')}`,
83
+ y: `1 ${t('year_short')}`,
84
+ yy: `%d ${t('years_short')}`
85
+ };
86
+ }
69
87
  const loc = relObj;
70
88
  const T = [{
71
89
  l: 's',
@@ -12,10 +12,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
12
12
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
13
13
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
14
  var $link = document.createElement('link');
15
- $link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap';
15
+ $link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
16
16
  $link.rel = 'stylesheet';
17
17
  document.head.append($link);
18
- _index.default.preloadWebfonts(['Inter'], [400, 500, 600]);
18
+ _index.default.preloadWebfonts(['Inter'], [400, 500]);
19
19
  class Widget {
20
20
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fake) {
21
21
  _defineProperty(this, "version", () => '4.5');
@@ -14,10 +14,10 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  let promiseMainCSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('../chatbox/css.js'))))();
16
16
  var $link = document.createElement('link');
17
- $link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
17
+ $link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
18
18
  $link.rel = 'stylesheet';
19
19
  document.head.append($link);
20
- _index.default.preloadWebfonts(['Roboto'], [400, 500]);
20
+ _index.default.preloadWebfonts(['Inter'], [400, 500]);
21
21
  let defaultAvatar = require('../../assets/img/default_avatar.png');
22
22
  class Icon extends common.Com {
23
23
  render() {
@@ -26,10 +26,10 @@ function getUrlParameter(name) {
26
26
  return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
27
27
  }
28
28
  var $link = document.createElement('link');
29
- $link.href = 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap';
29
+ $link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
30
30
  $link.rel = 'stylesheet';
31
31
  document.head.append($link);
32
- _index.default.preloadWebfonts(['Roboto'], [400, 500]);
32
+ _index.default.preloadWebfonts(['Inter'], [400, 500]);
33
33
  async function load() {
34
34
  let store = new _store.default(config.ApiURL, config.FileURL, config.RealtimeURL, true);
35
35
  let signkey = getUrlParameter('x-signed-key');
@@ -7,10 +7,10 @@ exports.default = void 0;
7
7
  var _index = _interopRequireDefault(require("./util/index.js"));
8
8
  var common = _interopRequireWildcard(require("./common.js"));
9
9
  var _preact = require("preact");
10
+ var _main = _interopRequireDefault(require("./chatbox/main.js"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- const LoadChatbox = () => Promise.resolve().then(() => _interopRequireWildcard(require('./chatbox/main.js')));
14
14
  const LoadContact = () => Promise.resolve().then(() => _interopRequireWildcard(require('./contact/contact.js')));
15
15
  const LoadPopup = () => Promise.resolve().then(() => _interopRequireWildcard(require('./popup/popup.js')));
16
16
  const LoadNotif = () => Promise.resolve().then(() => _interopRequireWildcard(require('./notif/notif.js')));
@@ -49,7 +49,6 @@ function Plugin(plugin, store, $container, lib) {
49
49
  }
50
50
  };
51
51
  var _ref = (0, _preact.createRef)();
52
- let Chatbox = null;
53
52
  let Popup = null;
54
53
  let Contact = null;
55
54
  let Notif = null;
@@ -62,8 +61,7 @@ function Plugin(plugin, store, $container, lib) {
62
61
  if (_destroy) return;
63
62
  if (!$div) return;
64
63
  if (plugin.type === 'chatbox') {
65
- if (!Chatbox) Chatbox = (await LoadChatbox()).default;
66
- (0, _preact.render)((0, _preact.h)(Chatbox, {
64
+ (0, _preact.render)((0, _preact.h)(_main.default, {
67
65
  destroy: _destroy,
68
66
  plugin: plugin,
69
67
  store: store,
@@ -58,22 +58,7 @@ class _default {
58
58
  }
59
59
  }));
60
60
  _defineProperty(this, "sendTyping", cid => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`));
61
- _defineProperty(this, "sendLostFocus", (device, productid, source_id, sku) => this.sendEvent({
62
- by: {
63
- id: this.uid,
64
- device: device
65
- },
66
- type: 'presence_updated',
67
- data: {
68
- presence: {
69
- viewing_product_sku: sku,
70
- viewing_product_source_id: source_id,
71
- viewing_product_id: productid,
72
- pinged: _index.default.Date.now(),
73
- is_focused: false
74
- }
75
- }
76
- }));
61
+ _defineProperty(this, "sendLostFocus", () => this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`));
77
62
  _defineProperty(this, "uploadToS3", async file => {
78
63
  let {
79
64
  body: signed,
@@ -126,10 +126,7 @@ class Store {
126
126
  if (_index.default.isUserBanned(this.cache.match('user'))) return;
127
127
  if (!this._track_page_view) return;
128
128
  let hasfocus = this.browserVisibility === 'visible' && document.hasFocus();
129
- if (!hasfocus) {
130
- this.api.sendLostFocus(this.device, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
131
- return;
132
- }
129
+ if (!hasfocus) return this.api.sendLostFocus();
133
130
  this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
134
131
  }, 1000, {
135
132
  leading: false
@@ -206,7 +203,7 @@ class Store {
206
203
  }, 20000);
207
204
  this._presenceInterval2 = _index.default.setInterval(() => {
208
205
  if (this._die) return _index.default.clearInterval(this._presenceInterval2);
209
- if (this.browserVisibility !== 'visible' || document.hasFocus()) this.sendPresence();
206
+ if (this.browserVisibility !== 'visible' || !document.hasFocus()) this.sendPresence();
210
207
  }, 60000);
211
208
  onVisibilityChange(val => {
212
209
  if (this._die) return;