@subiz/widget-v4 4.0.92 → 4.0.94

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 (175) hide show
  1. package/assets/less/chatbox.less +8 -0
  2. package/assets/less/message.less +8 -3
  3. package/assets/less/order.less +10 -0
  4. package/compiled_src/bot.js +0 -11
  5. package/compiled_src/call/call.js +0 -61
  6. package/compiled_src/call/css.js +0 -2
  7. package/compiled_src/chatbox/AgentsAvatar.js +0 -16
  8. package/compiled_src/chatbox/AudioAttachments.js +0 -14
  9. package/compiled_src/chatbox/ButtonAttachments.js +1 -14
  10. package/compiled_src/chatbox/Buttons.js +0 -13
  11. package/compiled_src/chatbox/ChatButton.js +1 -78
  12. package/compiled_src/chatbox/DropdownSelect.js +3 -44
  13. package/compiled_src/chatbox/Emoji.js +0 -7
  14. package/compiled_src/chatbox/Event.js +0 -59
  15. package/compiled_src/chatbox/Events.js +4 -44
  16. package/compiled_src/chatbox/FileAttachments.js +0 -14
  17. package/compiled_src/chatbox/FormAttachment.js +1 -52
  18. package/compiled_src/chatbox/FormAttachments.js +0 -14
  19. package/compiled_src/chatbox/FormSubmitAttachments.js +0 -11
  20. package/compiled_src/chatbox/GenericTemplateAttachments.js +1 -20
  21. package/compiled_src/chatbox/Header.js +1 -46
  22. package/compiled_src/chatbox/ImageAttachments.js +0 -16
  23. package/compiled_src/chatbox/InfoMessage.js +0 -13
  24. package/compiled_src/chatbox/ListField.js +0 -16
  25. package/compiled_src/chatbox/MessageInput.js +1 -47
  26. package/compiled_src/chatbox/Order.js +0 -35
  27. package/compiled_src/chatbox/OrderAttachments.js +98 -39
  28. package/compiled_src/chatbox/PoweredBy.js +0 -7
  29. package/compiled_src/chatbox/ProductAttachments.js +0 -19
  30. package/compiled_src/chatbox/QuickReplies.js +0 -18
  31. package/compiled_src/chatbox/Rating.js +0 -37
  32. package/compiled_src/chatbox/ShadowDomRoot.js +0 -9
  33. package/compiled_src/chatbox/TextMessage.js +0 -64
  34. package/compiled_src/chatbox/Typing.js +0 -15
  35. package/compiled_src/chatbox/VideoAttachments.js +0 -14
  36. package/compiled_src/chatbox/Widget.js +6 -167
  37. package/compiled_src/chatbox/css.js +0 -2
  38. package/compiled_src/chatbox/dragscroll.js +1 -5
  39. package/compiled_src/chatbox/main.js +1 -40
  40. package/compiled_src/chatbox/releaseAnimation.js +0 -11
  41. package/compiled_src/chatbox/spinner.js +0 -10
  42. package/compiled_src/chatbox/time.js +0 -22
  43. package/compiled_src/chatbox/touchscroll.js +0 -7
  44. package/compiled_src/common.js +0 -22
  45. package/compiled_src/contact/contact.js +2 -52
  46. package/compiled_src/contact/css.js +0 -2
  47. package/compiled_src/lib.js +19 -46
  48. package/compiled_src/notif/css.js +0 -2
  49. package/compiled_src/notif/notif.js +0 -63
  50. package/compiled_src/order/address_picker.js +4 -38
  51. package/compiled_src/order/icon.js +0 -16
  52. package/compiled_src/order/index.js +1 -34
  53. package/compiled_src/order/order.js +2 -156
  54. package/compiled_src/plugin.js +1 -77
  55. package/compiled_src/popup/countdown.js +2 -33
  56. package/compiled_src/popup/css.js +0 -2
  57. package/compiled_src/popup/popup.js +2 -165
  58. package/compiled_src/popup/tick.core.commonjs.js +72 -222
  59. package/compiled_src/popup/tick.view.flip.commonjs.js +23 -31
  60. package/compiled_src/store/api.js +99 -65
  61. package/compiled_src/store/api_fake.js +3 -39
  62. package/compiled_src/store/realtime_fake.js +0 -6
  63. package/compiled_src/store/store.js +46 -249
  64. package/compiled_src/util/campaign.js +0 -13
  65. package/compiled_src/util/common.js +15 -185
  66. package/compiled_src/util/common.test.js +0 -4
  67. package/compiled_src/util/extractor.js +1 -21
  68. package/compiled_src/util/extractor.test.js +0 -3
  69. package/compiled_src/util/gate.js +0 -7
  70. package/compiled_src/util/gate.test.js +1 -2
  71. package/compiled_src/util/index.js +3 -7
  72. package/compiled_src/util/mutex.js +31 -0
  73. package/compiled_src/util/op.js +1 -14
  74. package/compiled_src/util/order.js +118 -0
  75. package/compiled_src/util/pubsub.js +0 -6
  76. package/compiled_src/util/pubsub.test.js +0 -2
  77. package/package.json +12 -13
  78. package/src/chatbox/OrderAttachments.js +111 -18
  79. package/src/lib.js +24 -2
  80. package/src/store/api.js +110 -21
  81. package/src/store/api_fake.js +5 -6
  82. package/src/store/store.js +47 -17
  83. package/src/util/index.js +4 -0
  84. package/src/util/mutex.js +27 -0
  85. package/src/util/order.js +120 -0
  86. package/dist/132.js +0 -7092
  87. package/dist/178.js +0 -406
  88. package/dist/18364d15f37.132.js +0 -1
  89. package/dist/18364d15f37.178.js +0 -1
  90. package/dist/18364d15f37.213.js +0 -1
  91. package/dist/18364d15f37.335.js +0 -1
  92. package/dist/18364d15f37.362.js +0 -1
  93. package/dist/18364d15f37.441.js +0 -1
  94. package/dist/18364d15f37.605.js +0 -1
  95. package/dist/18364d15f37.678.js +0 -1
  96. package/dist/18364d15f37.782.js +0 -1
  97. package/dist/18364d15f37.app.js +0 -1
  98. package/dist/18364d15f37.index.html +0 -26
  99. package/dist/18364d15f37.library.html +0 -26
  100. package/dist/18364d15f37.library.js +0 -1
  101. package/dist/18364d15f37.preview.html +0 -759
  102. package/dist/18364d15f37.preview.js +0 -1
  103. package/dist/18364d15f37.screenshoot.js +0 -1
  104. package/dist/213.js +0 -3215
  105. package/dist/335.js +0 -411
  106. package/dist/362.js +0 -107
  107. package/dist/441.js +0 -2834
  108. package/dist/605.js +0 -328
  109. package/dist/678.js +0 -107
  110. package/dist/782.js +0 -107
  111. package/dist/HASH +0 -1
  112. package/dist/assets/img/Facebook.64607ec.png +0 -0
  113. package/dist/assets/img/Zalo.6845707.png +0 -0
  114. package/dist/assets/img/award1a.1a58e10.png +0 -0
  115. package/dist/assets/img/award3a.3b74423.png +0 -0
  116. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  117. package/dist/assets/img/award5.39eb7ae.png +0 -0
  118. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  119. package/dist/assets/img/caret.998eb8f.svg +0 -1
  120. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  121. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  122. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  123. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  124. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  125. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  126. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  127. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  128. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  129. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  130. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  131. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  132. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  133. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  134. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  135. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  136. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  137. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  138. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  139. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  140. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  141. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  142. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  143. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  144. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  145. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  146. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  147. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  148. package/dist/assets/img/empty.29bed2d.svg +0 -23
  149. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  150. package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
  151. package/dist/assets/img/external-link.90577cc.svg +0 -1
  152. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  153. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  154. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  155. package/dist/assets/img/image_default.be0698b.png +0 -0
  156. package/dist/assets/img/info.ebce7ea.svg +0 -1
  157. package/dist/assets/img/loader.37000a7.svg +0 -1
  158. package/dist/assets/img/loading_static.8f403ae.svg +0 -10
  159. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  160. package/dist/assets/img/main-service2.9b99549.png +0 -0
  161. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  162. package/dist/assets/img/package.8d37d0f.svg +0 -5
  163. package/dist/assets/img/package_fade.763c001.svg +0 -1
  164. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  165. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  166. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  167. package/dist/assets/img/search.f9705ff.svg +0 -1
  168. package/dist/assets/img/send.6db52a9.svg +0 -3
  169. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  170. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  171. package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
  172. package/dist/assets/img/x.26fdfa3.svg +0 -5
  173. package/dist/malicious-app.js +0 -13
  174. package/dist/screenshoot.html +0 -7
  175. package/dist/screenshoot.js +0 -5953
@@ -4,27 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _index = _interopRequireDefault(require("./util/index.js"));
9
-
10
8
  var common = _interopRequireWildcard(require("./common.js"));
11
-
12
9
  var _preact = require("preact");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  const LoadChatbox = () => Promise.resolve().then(() => _interopRequireWildcard(require('./chatbox/main.js')));
21
-
22
14
  const LoadContact = () => Promise.resolve().then(() => _interopRequireWildcard(require('./contact/contact.js')));
23
-
24
15
  const LoadPopup = () => Promise.resolve().then(() => _interopRequireWildcard(require('./popup/popup.js')));
25
-
26
16
  const LoadNotif = () => Promise.resolve().then(() => _interopRequireWildcard(require('./notif/notif.js')));
27
-
28
17
  function Plugin(plugin, store, $container, lib) {
29
18
  if (!$container) throw '$div must is a valid html node';
30
19
  var $div = document.createElement('div');
@@ -32,30 +21,23 @@ function Plugin(plugin, store, $container, lib) {
32
21
  $container.appendChild($div);
33
22
 
34
23
  let _locale = common.getLocale(plugin, _index.default.detectLang());
35
-
36
24
  var domGate = new _index.default.Gate();
37
25
  var pageIndex = 0;
38
26
  var highlight;
39
27
  var state = 'hold';
40
-
41
28
  var _this = this;
42
-
43
29
  this.getState = () => state;
44
-
45
30
  var run = async function () {
46
31
  if (_destroy) return;
47
32
  if (state !== 'hold') return;
48
33
  if (plugin.type === 'popup' && store.isConverted(plugin.id)) return;
49
34
  let lastrun = store.matchLastPluginRun(plugin.id);
50
35
  if (plugin.type === 'chatbox' || plugin.type === 'notification') lastrun = undefined;
51
-
52
36
  let match = _index.default.checkRunConditions(plugin.initiative_frequency, plugin.conditions, lastrun, store);
53
-
54
37
  if (!match) return;
55
38
  state = 'running';
56
39
  await _this.update(plugin);
57
40
  };
58
-
59
41
  this.forceRunPopup = async () => {
60
42
  if (_index.default.get(_ref, 'current')) {
61
43
  _ref.current.openPopup();
@@ -63,26 +45,19 @@ function Plugin(plugin, store, $container, lib) {
63
45
  _render();
64
46
  }
65
47
  };
66
-
67
48
  var _ref = (0, _preact.createRef)();
68
-
69
49
  let Chatbox = null;
70
50
  let Popup = null;
71
51
  let Contact = null;
72
52
  let Notif = null;
73
-
74
53
  var showCurrentChatbox = p => lib.showWidget(p);
75
-
76
54
  var nextPage = () => {
77
55
  pageIndex++;
78
-
79
56
  _render();
80
57
  };
81
-
82
58
  var _render = async () => {
83
59
  if (_destroy) return;
84
60
  if (!$div) return;
85
-
86
61
  if (plugin.type === 'chatbox') {
87
62
  if (!Chatbox) Chatbox = (await LoadChatbox()).default;
88
63
  (0, _preact.render)((0, _preact.h)(Chatbox, {
@@ -93,7 +68,6 @@ function Plugin(plugin, store, $container, lib) {
93
68
  t: this.t
94
69
  }), $div);
95
70
  }
96
-
97
71
  if (plugin.type === 'popup') {
98
72
  if (!Popup) Popup = (await LoadPopup()).default;
99
73
  (0, _preact.render)((0, _preact.h)(Popup, {
@@ -109,7 +83,6 @@ function Plugin(plugin, store, $container, lib) {
109
83
  showWidget: showCurrentChatbox
110
84
  }), $div);
111
85
  }
112
-
113
86
  if (plugin.type === 'notification') {
114
87
  if (!Notif) Notif = (await LoadNotif()).default;
115
88
  (0, _preact.render)((0, _preact.h)(Notif, {
@@ -121,7 +94,6 @@ function Plugin(plugin, store, $container, lib) {
121
94
  ref: _ref
122
95
  }), $div);
123
96
  }
124
-
125
97
  if (plugin.type === 'contact') {
126
98
  if (!Contact) Contact = (await LoadContact()).default;
127
99
  (0, _preact.render)((0, _preact.h)(Contact, {
@@ -132,23 +104,19 @@ function Plugin(plugin, store, $container, lib) {
132
104
  ref: _ref
133
105
  }), $div);
134
106
  }
135
-
136
107
  domGate.open();
137
108
  };
138
-
139
109
  this.call = (method, param) => domGate.entry().then(() => _ref.current[method](param));
140
-
141
110
  var _destroy = false;
142
-
143
111
  this.destroy = () => {
144
112
  _destroy = true;
145
113
  (0, _preact.render)(null, $div);
114
+
146
115
  $div.parentNode.removeChild($div);
147
116
  };
148
117
 
149
118
  this.highlight = comref => {
150
119
  highlight = comref;
151
-
152
120
  _render();
153
121
  };
154
122
 
@@ -157,73 +125,55 @@ function Plugin(plugin, store, $container, lib) {
157
125
  plugin = config;
158
126
  if (state === 'hold') return;
159
127
  if (state === 'finished') return;
160
-
161
128
  _render();
162
129
  };
163
130
 
164
131
  let t = key => {
165
132
  if (_locale === 'debug') return `{{${key}}}`;
166
-
167
133
  let messages = _index.default.get(common.langMessages, _locale, []);
168
-
169
134
  let message = _index.default.find(messages, message => message.key === key);
170
-
171
135
  return _index.default.get(message, 'message', key);
172
136
  };
173
-
174
137
  let acc = store.matchAccount();
175
-
176
138
  t.i18n = i18nText => {
177
139
  if (!i18nText) return '';
178
140
  let fallbackLocale = plugin.locale || acc.locale || 'vi-VN';
179
141
  fallbackLocale = fallbackLocale.replace('-', '_');
180
-
181
142
  let locale = _locale.replace('-', '_');
182
-
183
143
  return i18nText[locale] || i18nText[fallbackLocale];
184
144
  };
185
-
186
145
  t.locale = () => _locale;
187
-
188
146
  this.forceDownloadLanguage = async () => {
189
147
  await common.downloadLanguage(store, _locale, true);
190
148
  this.update(plugin);
191
149
  };
192
-
193
150
  this.setLocale = async locale => {
194
151
  if (_locale === locale) return locale;
195
152
  this.t = null;
196
-
197
153
  _render();
198
154
 
199
155
  _locale = common.getLocale(plugin, locale);
200
156
  await common.downloadLanguage(store, _locale);
201
157
  this.t = t;
202
-
203
158
  _render();
204
-
205
159
  return _locale;
206
160
  };
207
161
 
208
162
  let images = {};
209
-
210
163
  _index.default.map(_index.default.get(plugin, 'popup.pages'), page => {
211
164
  if (!page) return;
212
-
213
165
  _index.default.map(page.components, com => {
214
166
  if (com.type === 'image' && com.image && com.image.url && com.image.url.startsWith('http')) {
215
167
  images[com.image.url] = true;
216
168
  }
217
169
  });
218
170
  });
219
-
220
171
  if (_index.default.size(images) >= 0) _index.default.map(images, (_, image) => _index.default.preloadImg(image));
221
172
  let triggers = _index.default.get(plugin, 'triggers') || [{
222
173
  type: 'after_pageview',
223
174
  after_pageview_sec: 0,
224
175
  disabled: false
225
176
  }];
226
-
227
177
  for (var i = 0; i < _index.default.size(triggers); i++) {
228
178
  var tr = triggers[i];
229
179
  if (!tr) continue;
@@ -234,7 +184,6 @@ function Plugin(plugin, store, $container, lib) {
234
184
  if (tr.type === 'inactivity_duration') _index.default.trackInactivity(tr.inactivity_sec, run);
235
185
  if (tr.type === 'after_pageview') _index.default.trackTimeOnPage(tr.after_pageview_sec, run);
236
186
  }
237
-
238
187
  this.update(plugin);
239
188
  common.downloadLanguage(store, _locale).then(() => {
240
189
  this.t = t;
@@ -262,18 +211,15 @@ class PluginMgr {
262
211
  if (this._destroy) return;
263
212
  let pluginM = this.lib.store.matchPlugin();
264
213
  let foundchatbox = false;
265
-
266
214
  _index.default.each(pluginM, conf => {
267
215
  if (conf.type === 'chatbox') {
268
216
  if (foundchatbox) return;
269
217
  foundchatbox = true;
270
218
  }
271
-
272
219
  if (!this.pluginM[conf.id]) {
273
220
  this.pluginM[conf.id] = new Plugin(conf, this.lib.store, $div, lib);
274
221
  return;
275
222
  }
276
-
277
223
  this.pluginM[conf.id].update(conf);
278
224
  });
279
225
 
@@ -285,105 +231,83 @@ class PluginMgr {
285
231
  });
286
232
  let pluginM = this.lib.store.matchPlugin();
287
233
  let foundchatbox = false;
288
-
289
234
  _index.default.each(pluginM, conf => {
290
235
  if (conf.type === 'chatbox') {
291
236
  if (foundchatbox) return;
292
237
  foundchatbox = true;
293
238
  }
294
-
295
239
  if (!this.pluginM[conf.id]) this.pluginM[conf.id] = new Plugin(conf, this.lib.store, $div, lib);
296
240
  });
297
241
  }
298
-
299
242
  findChatbox() {
300
243
  var pluginM = this.lib.store.matchPlugin();
301
-
302
244
  let chatboxs = _index.default.filter(this.pluginM, (plugin, id) => pluginM[id].type === 'chatbox');
303
-
304
245
  if (_index.default.size(chatboxs) === 0) {
305
246
  console.error('no chatbox found.');
306
247
  return;
307
248
  }
308
-
309
249
  let chatbox = _index.default.find(chatboxs, chatbox => chatbox.getState() === 'running');
310
-
311
250
  if (!chatbox) {
312
251
  chatbox = chatboxs[0];
313
252
  }
314
-
315
253
  if (!chatbox) {
316
254
  console.error('found no suitable chatbox to run.');
317
255
  return;
318
256
  }
319
-
320
257
  return chatbox;
321
258
  }
322
-
323
259
  getCurrentView() {
324
260
  let chatbox = this.findChatbox();
325
261
  if (!chatbox) return;
326
262
  return chatbox.call('getCurrentView');
327
263
  }
328
-
329
264
  showCurrentChatbox(p) {
330
265
  let chatbox = this.findChatbox();
331
266
  if (!chatbox) return;
332
267
  chatbox.call('showWidget', p);
333
268
  }
334
-
335
269
  showCurrentGreeting() {
336
270
  let chatbox = this.findChatbox();
337
271
  if (!chatbox) return;
338
272
  chatbox.call('showGreeting');
339
273
  }
340
-
341
274
  hideCurrentGreeting() {
342
275
  let chatbox = this.findChatbox();
343
276
  if (!chatbox) return;
344
277
  chatbox.call('hideGreeting');
345
278
  }
346
-
347
279
  hideCurrentChatbox() {
348
280
  let chatbox = this.findChatbox();
349
281
  if (!chatbox) return;
350
282
  chatbox.call('hideWidget');
351
283
  }
352
-
353
284
  forceUpdateLang(id) {
354
285
  let plugin = this.pluginM[id];
355
286
  if (!plugin) return;
356
287
  plugin.forceDownloadLanguage();
357
288
  }
358
-
359
289
  forceRunPopup(id) {
360
290
  let plugin = this.pluginM[id];
361
291
  if (!plugin) return;
362
292
  plugin.forceRunPopup(id);
363
293
  }
364
-
365
294
  setPluginLocale(id, locale) {
366
295
  let plugin = this.pluginM[id];
367
296
  if (!plugin) return;
368
297
  return plugin.setLocale(locale);
369
298
  }
370
-
371
299
  setCurrentChatboxLocale(locale) {
372
300
  let chatbox = this.findChatbox();
373
301
  if (!chatbox) return;
374
302
  chatbox.setLocale(locale);
375
303
  }
376
-
377
304
  destroy() {
378
305
  _index.default.map(this.pluginM, (conf, id) => {
379
306
  if (this.pluginM[id]) return;
380
307
  this.pluginM[id].destroy();
381
308
  delete this.pluginM[id];
382
309
  });
383
-
384
310
  this._destroy = true;
385
311
  }
386
-
387
312
  }
388
-
389
313
  exports.default = PluginMgr;
@@ -4,31 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _common = require("../common.js");
9
-
10
8
  var _tickCoreCommonjs = _interopRequireDefault(require("./tick.core.commonjs.js"));
11
-
12
9
  var _index = _interopRequireDefault(require("../util/index.js"));
13
-
14
10
  var _tickViewFlipCommonjs = _interopRequireDefault(require("./tick.view.flip.commonjs.js"));
15
-
16
11
  var _preact = require("preact");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
14
  _tickCoreCommonjs.default.plugin.add(_tickViewFlipCommonjs.default);
23
-
24
15
  class Countdown extends _common.Com {
25
16
  constructor(props) {
26
17
  super(props);
27
-
28
18
  _defineProperty(this, "state", {
29
19
  flipKey: '43'
30
20
  });
31
-
32
21
  this.timer = setInterval(() => {
33
22
  if (this.props._destroy) return this.componentWillUnmount();
34
23
  let cd = this.props.com.countdown || {};
@@ -39,26 +28,21 @@ class Countdown extends _common.Com {
39
28
  this.forceUpdate();
40
29
  }, 500);
41
30
  }
42
-
43
31
  componentWillUnmount() {
44
32
  clearInterval(this.timer);
45
33
  }
46
-
47
34
  getCountDownDeltaSec(countdown) {
48
35
  let dest;
49
36
  if (countdown.expire_time_type === 'fixed_time') dest = countdown.fixed_time;
50
37
  if (countdown.expire_time_type === 'visit_time') dest = this.props.store.pageLoaded() + countdown.visit_time * 60000;
51
-
52
38
  if (countdown.expire_time_type === 'repeat_daily') {
53
39
  var start = new _index.default.Date();
54
40
  start.setHours(0, 0, 0, 0);
55
41
  dest = start.getTime() + countdown.repeat_daily * 60000;
56
42
  }
57
-
58
43
  if (countdown.expire_time_type === 'repeat_weekly') {
59
44
  let daytill = 0;
60
45
  let todayweekday = new _index.default.Date().getDay();
61
-
62
46
  if (todayweekday === 0) {
63
47
  if (countdown.repeat_weekly_weekday === 'sunday') {
64
48
  daytill = 0;
@@ -72,7 +56,6 @@ class Countdown extends _common.Com {
72
56
  daytill = WEEKDAY_INDEX[countdown.repeat_weekly_weekday] - todayweekday;
73
57
  }
74
58
  }
75
-
76
59
  if (daytill < 0) delta = 0;else if (daytill == 0) {
77
60
  var start = new _index.default.Date();
78
61
  start.setHours(0, 0, 0, 0);
@@ -83,9 +66,7 @@ class Countdown extends _common.Com {
83
66
  dest = start.getTime() + countdown.repeat_weekly_min * 60000 + daytill * 86400000;
84
67
  }
85
68
  }
86
-
87
69
  let delta = dest - _index.default.Date.now();
88
-
89
70
  if (delta < 0) delta = 0;
90
71
  return Math.floor(delta / 1000) || 0;
91
72
  }
@@ -152,11 +133,9 @@ class Countdown extends _common.Com {
152
133
  })
153
134
  }, sec1))));
154
135
  }
155
-
156
136
  renderFlipCountdown(day, hour0, hour1, min0, min1, sec0, sec1) {
157
137
  let $day = null;
158
138
  if (day > 99) day = 99;
159
-
160
139
  if (day > 0) {
161
140
  let day0 = Math.floor(day / 10) + '';
162
141
  let day1 = day % 10 + '';
@@ -171,7 +150,6 @@ class Countdown extends _common.Com {
171
150
  class: "countdown_label"
172
151
  }, this.props.t('day')));
173
152
  }
174
-
175
153
  return (0, _preact.h)("div", {
176
154
  class: "countdown"
177
155
  }, $day, (0, _preact.h)("div", {
@@ -203,7 +181,6 @@ class Countdown extends _common.Com {
203
181
  class: "countdown_label"
204
182
  }, this.props.t('sec'))));
205
183
  }
206
-
207
184
  render() {
208
185
  let delta = this.getCountDownDeltaSec(this.props.com.countdown);
209
186
  let day = Math.floor(delta / 86400);
@@ -216,17 +193,15 @@ class Countdown extends _common.Com {
216
193
  let min1 = min % 10 + '';
217
194
  let hour0 = Math.floor(hour / 10) + '';
218
195
  let hour1 = hour % 10 + '';
219
-
220
196
  if (this.props.com.countdown.skin === 'electric') {
221
197
  return this.renderElectricCountdown(day, hour0, hour1, min0, min1, sec0, sec1);
222
198
  }
223
-
224
199
  return this.renderFlipCountdown(day, hour0, hour1, min0, min1, sec0, sec1);
225
200
  }
226
-
227
201
  }
228
202
 
229
203
  exports.default = Countdown;
204
+
230
205
  const WEEKDAY_INDEX = {
231
206
  sunday: 0,
232
207
  monday: 1,
@@ -236,34 +211,29 @@ const WEEKDAY_INDEX = {
236
211
  friday: 5,
237
212
  saturday: 6
238
213
  };
239
-
240
214
  class Flip extends _common.Com {
241
215
  constructor(props) {
242
216
  super(props);
243
217
  this._tickRef = (0, _preact.createRef)();
244
218
  }
245
-
246
219
  componentDidMount() {
247
220
  this._tickInstance = _tickCoreCommonjs.default.DOM.create(this._tickRef.current, {
248
221
  value: this.props.value
249
222
  });
250
223
  }
251
-
252
224
  componentDidUpdate() {
253
225
  if (!this._tickInstance) return;
254
226
  this._tickInstance.value = this.props.value;
255
227
  }
256
-
257
228
  componentWillUnmount() {
258
229
  if (!this._tickInstance) return;
259
-
260
230
  _tickCoreCommonjs.default.DOM.destroy(this._tickRef.current);
261
231
  }
262
-
263
232
  render() {
264
233
  let fs = '28px';
265
234
  if (this.props.com.countdown.size === 'sm') fs = '20px';
266
235
  if (this.props.com.countdown.size === 'lg') fs = '40px';
236
+
267
237
  return (0, _preact.h)("div", {
268
238
  ref: this._tickRef,
269
239
  class: "tick"
@@ -278,5 +248,4 @@ class Flip extends _common.Com {
278
248
  })
279
249
  })));
280
250
  }
281
-
282
251
  }
@@ -4,7 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _default = require('css-loader!less-loader!../../assets/less/popup.less');
9
-
10
8
  exports.default = _default;