@subiz/widget-v4 4.0.63 → 4.0.64

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 (55) hide show
  1. package/babel.config.js +2 -4
  2. package/compiled_src/bot.js +7 -1
  3. package/compiled_src/call/call.js +15 -12
  4. package/compiled_src/chatbox/DropdownSelect.js +75 -66
  5. package/compiled_src/chatbox/MessageInput.js +7 -4
  6. package/compiled_src/chatbox/Order.js +94 -90
  7. package/compiled_src/chatbox/Rating.js +10 -7
  8. package/compiled_src/chatbox/Widget.js +27 -23
  9. package/compiled_src/contact/contact.js +9 -6
  10. package/compiled_src/lib.js +14 -9
  11. package/compiled_src/notif/notif.js +15 -12
  12. package/compiled_src/order/address_picker.js +71 -63
  13. package/compiled_src/order/order.js +330 -316
  14. package/compiled_src/popup/countdown.js +7 -4
  15. package/compiled_src/popup/popup.js +12 -9
  16. package/compiled_src/store/api.js +110 -80
  17. package/compiled_src/store/api_fake.js +82 -55
  18. package/compiled_src/store/store.js +170 -133
  19. package/dist/132.js +633 -588
  20. package/dist/17ee31b89ac.132.js +1 -0
  21. package/dist/{17e757ccadd.178.js → 17ee31b89ac.178.js} +0 -0
  22. package/dist/17ee31b89ac.213.js +1 -0
  23. package/dist/17ee31b89ac.335.js +1 -0
  24. package/dist/{17e757ccadd.362.js → 17ee31b89ac.362.js} +1 -1
  25. package/dist/17ee31b89ac.441.js +1 -0
  26. package/dist/17ee31b89ac.605.js +1 -0
  27. package/dist/{17e757ccadd.678.js → 17ee31b89ac.678.js} +0 -0
  28. package/dist/{17e757ccadd.782.js → 17ee31b89ac.782.js} +1 -1
  29. package/dist/17ee31b89ac.app.js +1 -0
  30. package/dist/{17e757ccadd.index.html → 17ee31b89ac.index.html} +1 -1
  31. package/dist/{17e757ccadd.library.html → 17ee31b89ac.library.html} +1 -1
  32. package/dist/17ee31b89ac.library.js +1 -0
  33. package/dist/{17e757ccadd.preview.html → 17ee31b89ac.preview.html} +1 -1
  34. package/dist/17ee31b89ac.preview.js +1 -0
  35. package/dist/17ee31b89ac.screenshoot.js +1 -0
  36. package/dist/213.js +19 -13
  37. package/dist/335.js +9 -6
  38. package/dist/362.js +1 -1
  39. package/dist/441.js +2 -2
  40. package/dist/605.js +15 -12
  41. package/dist/782.js +1 -1
  42. package/dist/HASH +1 -1
  43. package/dist/screenshoot.html +1 -1
  44. package/dist/screenshoot.js +372 -273
  45. package/package.json +12 -12
  46. package/src/bot.js +2 -1
  47. package/dist/17e757ccadd.132.js +0 -1
  48. package/dist/17e757ccadd.213.js +0 -1
  49. package/dist/17e757ccadd.335.js +0 -1
  50. package/dist/17e757ccadd.441.js +0 -1
  51. package/dist/17e757ccadd.605.js +0 -1
  52. package/dist/17e757ccadd.app.js +0 -1
  53. package/dist/17e757ccadd.library.js +0 -1
  54. package/dist/17e757ccadd.preview.js +0 -1
  55. package/dist/17e757ccadd.screenshoot.js +0 -1
@@ -17,6 +17,8 @@ var _realtime_fake = _interopRequireDefault(require("./realtime_fake.js"));
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
+ 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
+
20
22
  var flow = require('@subiz/flow');
21
23
 
22
24
  var Realtime = require('@subiz/wsclient/index.js');
@@ -32,6 +34,174 @@ const page_loaded = _index.default.Date.now();
32
34
 
33
35
  class Store {
34
36
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fakeapi, agenttoken) {
37
+ _defineProperty(this, "inmem", false);
38
+
39
+ _defineProperty(this, "cookie", cookie);
40
+
41
+ _defineProperty(this, "new_visitor", true);
42
+
43
+ _defineProperty(this, "matchUser", () => {
44
+ this._touchAcc();
45
+
46
+ return this.kv.match('user');
47
+ });
48
+
49
+ _defineProperty(this, "suggest_addresses", keyword => this.api.suggest_address(keyword));
50
+
51
+ _defineProperty(this, "matchSession", () => this.kv.match('session') || {});
52
+
53
+ _defineProperty(this, "matchAccount", () => this.cache.match('account'));
54
+
55
+ _defineProperty(this, "matchPaymentMethods", () => this.cache.match('payment_methods'));
56
+
57
+ _defineProperty(this, "matchUnread", () => {
58
+ let user = this.matchUser();
59
+ let allconvos = this.matchConvo('*');
60
+ let unreadcount = 0;
61
+
62
+ _index.default.map(allconvos, convo => {
63
+ if (!_index.default.isConvoSeen(convo, user.id)) unreadcount++;
64
+ });
65
+
66
+ return unreadcount;
67
+ });
68
+
69
+ _defineProperty(this, "matchPlugin", () => {
70
+ if (_index.default.size(this.forcePlugins) > 0) return _index.default.cloneDeep(this.forcePlugins);
71
+ return _index.default.cloneDeep(this.cache.match('plugin')) || {};
72
+ });
73
+
74
+ _defineProperty(this, "device", {});
75
+
76
+ _defineProperty(this, "browserVisibility", 'visible');
77
+
78
+ _defineProperty(this, "matchAgent", id => {
79
+ let agentM = this.cache.match('agent') || {};
80
+ if (id === '*') return agentM;
81
+ return agentM[id];
82
+ });
83
+
84
+ _defineProperty(this, "matchConvo", id => {
85
+ if (!id) return;
86
+
87
+ if (id === '*') {
88
+ this._touchAcc();
89
+
90
+ return _index.default.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
91
+ }
92
+
93
+ if (!this.isInsync(id)) this.fetchConvo(id);
94
+ return this.cache.match('convo_' + id);
95
+ });
96
+
97
+ _defineProperty(this, "fetchConvo", async cid => {
98
+ await this.readyGate.entry();
99
+ await this.reconnectGate.entry(undefined, true);
100
+ if (this.isInsync(cid)) return this.reconnectGate.open();
101
+ this.markSync(cid);
102
+ let {
103
+ body: convo,
104
+ error
105
+ } = await this.api.getConversation(cid);
106
+ if (convo && !error) this._setConvo(convo);
107
+ return this.reconnectGate.open();
108
+ });
109
+
110
+ _defineProperty(this, "list_provinces", () => this.api.list_provinces());
111
+
112
+ _defineProperty(this, "list_districts", p => this.api.list_districts(p));
113
+
114
+ _defineProperty(this, "list_wards", p => this.api.list_wards(p));
115
+
116
+ _defineProperty(this, "list_provices", void 0);
117
+
118
+ _defineProperty(this, "listEvents", id => {
119
+ if (!id || id === '*' || typeof id !== 'string') return;
120
+
121
+ if (!this.isInsync('events' + id)) {
122
+ setTimeout(async () => {
123
+ await this.readyGate.entry();
124
+ await this.reconnectGate.entry(undefined, true);
125
+ if (this.isInsync('events' + id)) return this.reconnectGate.open();
126
+ this.markSync('events' + id);
127
+ await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
128
+ this.pubsub.publish('account');
129
+ return this.reconnectGate.open();
130
+ }, 10);
131
+ }
132
+
133
+ return this.chain.listM(id);
134
+ });
135
+
136
+ _defineProperty(this, "fetchMoreEvents", async convoid => {
137
+ let {
138
+ error
139
+ } = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
140
+ this.pubsub.publish('account');
141
+ return {
142
+ error
143
+ };
144
+ });
145
+
146
+ _defineProperty(this, "matchBot", () => this.cache.match('bot') || {});
147
+
148
+ _defineProperty(this, "readyGate", new _index.default.Gate());
149
+
150
+ _defineProperty(this, "convoGate", new _index.default.Gate(true));
151
+
152
+ _defineProperty(this, "reconnectGate", new _index.default.Gate(true));
153
+
154
+ _defineProperty(this, "matchLastview", () => this.kv.match('lastview') || {});
155
+
156
+ _defineProperty(this, "matchIsOpen", () => !!this.kv.match('isopen'));
157
+
158
+ _defineProperty(this, "matchHasManuallyClosed", () => !!this.kv.match('hasManuallyClosed'));
159
+
160
+ _defineProperty(this, "matchClosePreviewAt", () => this.kv.match('close_preview_at') || 0);
161
+
162
+ _defineProperty(this, "sendPresence", _index.default.throttle(async () => {
163
+ await this.readyGate.entry();
164
+ if (!_index.default.get(this.kv.match('user'), 'id')) return;
165
+ if (_index.default.isUserBanned(this.kv.match('user'))) return;
166
+ return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
167
+ }, 1000));
168
+
169
+ _defineProperty(this, "now", () => _index.default.Date.now() + this.timeDiff);
170
+
171
+ _defineProperty(this, "seenQueue", []);
172
+
173
+ _defineProperty(this, "_typing", _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000));
174
+
175
+ _defineProperty(this, "onConvoEvent", (o, cb) => this.pubsub.on2(o, 'events', cb));
176
+
177
+ _defineProperty(this, "seenConvo", id => {
178
+ if (!id || id === 'create') return;
179
+ this.seenQueue.push(id);
180
+ });
181
+
182
+ _defineProperty(this, "onUpdate", (o, cb) => this.pubsub.on2(o, 'account', cb));
183
+
184
+ _defineProperty(this, "onResetCSS", (o, cb) => this.pubsub.on2(o, 'resetCSS', cb));
185
+
186
+ _defineProperty(this, "onHighlight", (o, cb) => this.pubsub.on2(o, 'highlight', cb));
187
+
188
+ _defineProperty(this, "setHasManuallyClosed", () => this.kv.put('hasManuallyClosed', true));
189
+
190
+ _defineProperty(this, "setIsOpen", isopen => {
191
+ let lastisopen = this.kv.match('isopen');
192
+ this.kv.put('isopen', isopen);
193
+ if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
194
+ });
195
+
196
+ _defineProperty(this, "closePreview", () => this.kv.put('close_preview_at', new _index.default.Date().getTime()));
197
+
198
+ _defineProperty(this, "setLastview", (view, opts) => this.kv.put('lastview', {
199
+ view,
200
+ opts
201
+ }));
202
+
203
+ _defineProperty(this, "timeDiff", 0);
204
+
35
205
  this.agent_token = agenttoken;
36
206
  this.g_sync = {};
37
207
  this.forceDevice = null;
@@ -85,9 +255,6 @@ class Store {
85
255
  }, 2000);
86
256
  }
87
257
 
88
- inmem = false;
89
- cookie = cookie;
90
-
91
258
  isInsync(key) {
92
259
  return _index.default.Date.now() - (this.g_sync[key] || 0) < 300000;
93
260
  }
@@ -188,115 +355,12 @@ class Store {
188
355
  this.g_sync[key] = _index.default.Date.now();
189
356
  }
190
357
 
191
- new_visitor = true;
192
-
193
358
  async _touchAcc() {
194
359
  if (this.isInsync('account')) return;
195
360
  await this.readyGate.entry();
196
361
  if (!this.isInsync('account')) this.reconnect();
197
362
  }
198
363
 
199
- matchUser = () => {
200
- this._touchAcc();
201
-
202
- return this.kv.match('user');
203
- };
204
- suggest_addresses = keyword => this.api.suggest_address(keyword);
205
- matchSession = () => this.kv.match('session') || {};
206
- matchAccount = () => this.cache.match('account');
207
- matchPaymentMethods = () => this.cache.match('payment_methods');
208
- matchUnread = () => {
209
- let user = this.matchUser();
210
- let allconvos = this.matchConvo('*');
211
- let unreadcount = 0;
212
-
213
- _index.default.map(allconvos, convo => {
214
- if (!_index.default.isConvoSeen(convo, user.id)) unreadcount++;
215
- });
216
-
217
- return unreadcount;
218
- };
219
- matchPlugin = () => {
220
- if (_index.default.size(this.forcePlugins) > 0) return _index.default.cloneDeep(this.forcePlugins);
221
- return _index.default.cloneDeep(this.cache.match('plugin')) || {};
222
- };
223
- device = {};
224
- browserVisibility = 'visible';
225
- matchAgent = id => {
226
- let agentM = this.cache.match('agent') || {};
227
- if (id === '*') return agentM;
228
- return agentM[id];
229
- };
230
- matchConvo = id => {
231
- if (!id) return;
232
-
233
- if (id === '*') {
234
- this._touchAcc();
235
-
236
- return _index.default.filter(this.cache.all(), (value, k) => k.startsWith('convo_'));
237
- }
238
-
239
- if (!this.isInsync(id)) this.fetchConvo(id);
240
- return this.cache.match('convo_' + id);
241
- };
242
- fetchConvo = async cid => {
243
- await this.readyGate.entry();
244
- await this.reconnectGate.entry(undefined, true);
245
- if (this.isInsync(cid)) return this.reconnectGate.open();
246
- this.markSync(cid);
247
- let {
248
- body: convo,
249
- error
250
- } = await this.api.getConversation(cid);
251
- if (convo && !error) this._setConvo(convo);
252
- return this.reconnectGate.open();
253
- };
254
- list_provinces = () => this.api.list_provinces();
255
- list_districts = p => this.api.list_districts(p);
256
- list_wards = p => this.api.list_wards(p);
257
- list_provices;
258
- listEvents = id => {
259
- if (!id || id === '*' || typeof id !== 'string') return;
260
-
261
- if (!this.isInsync('events' + id)) {
262
- setTimeout(async () => {
263
- await this.readyGate.entry();
264
- await this.reconnectGate.entry(undefined, true);
265
- if (this.isInsync('events' + id)) return this.reconnectGate.open();
266
- this.markSync('events' + id);
267
- await this.chain.reload(id, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
268
- this.pubsub.publish('account');
269
- return this.reconnectGate.open();
270
- }, 10);
271
- }
272
-
273
- return this.chain.listM(id);
274
- };
275
- fetchMoreEvents = async convoid => {
276
- let {
277
- error
278
- } = await this.chain.fetchMore(convoid, 50, (type, anchor, limit) => this.listmessageapi(type, anchor, limit));
279
- this.pubsub.publish('account');
280
- return {
281
- error
282
- };
283
- };
284
- matchBot = () => this.cache.match('bot') || {};
285
- readyGate = new _index.default.Gate();
286
- convoGate = new _index.default.Gate(true);
287
- reconnectGate = new _index.default.Gate(true);
288
- matchLastview = () => this.kv.match('lastview') || {};
289
- matchIsOpen = () => !!this.kv.match('isopen');
290
- matchHasManuallyClosed = () => !!this.kv.match('hasManuallyClosed');
291
- matchClosePreviewAt = () => this.kv.match('close_preview_at') || 0;
292
- sendPresence = _index.default.throttle(async () => {
293
- await this.readyGate.entry();
294
- if (!_index.default.get(this.kv.match('user'), 'id')) return;
295
- if (_index.default.isUserBanned(this.kv.match('user'))) return;
296
- return this.api.sendPresence(this.device, this.browserVisibility === 'visible' && document.hasFocus());
297
- }, 1000);
298
- now = () => _index.default.Date.now() + this.timeDiff;
299
-
300
364
  async init(accid, mask) {
301
365
  this.readyGate.close();
302
366
  accid = (accid || '').trim();
@@ -355,8 +419,6 @@ class Store {
355
419
  return mask;
356
420
  }
357
421
 
358
- seenQueue = [];
359
-
360
422
  seenLoop() {
361
423
  this.seenQueue = [];
362
424
  clearInterval(this._seenInterval);
@@ -747,8 +809,6 @@ class Store {
747
809
  this._typing(cid);
748
810
  }
749
811
 
750
- _typing = _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000);
751
-
752
812
  async startConvo(req) {
753
813
  await this.readyGate.entry();
754
814
  this.convoGate.close();
@@ -846,12 +906,6 @@ class Store {
846
906
  sendEventToThirdParty('SUBIZ Chat', 'Sent', 'User');
847
907
  }
848
908
 
849
- onConvoEvent = (o, cb) => this.pubsub.on2(o, 'events', cb);
850
- seenConvo = id => {
851
- if (!id || id === 'create') return;
852
- this.seenQueue.push(id);
853
- };
854
-
855
909
  _setConvo(convo) {
856
910
  let count = 0;
857
911
  let user = this.kv.match('user');
@@ -883,21 +937,6 @@ class Store {
883
937
  this.cache.put('convo_' + convo.id, convo);
884
938
  }
885
939
 
886
- onUpdate = (o, cb) => this.pubsub.on2(o, 'account', cb);
887
- onResetCSS = (o, cb) => this.pubsub.on2(o, 'resetCSS', cb);
888
- onHighlight = (o, cb) => this.pubsub.on2(o, 'highlight', cb);
889
- setHasManuallyClosed = () => this.kv.put('hasManuallyClosed', true);
890
- setIsOpen = isopen => {
891
- let lastisopen = this.kv.match('isopen');
892
- this.kv.put('isopen', isopen);
893
- if (!lastisopen && isopen) sendEventToThirdParty('SUBIZ Chat', 'Opened', 'Subiz Windows');
894
- };
895
- closePreview = () => this.kv.put('close_preview_at', new _index.default.Date().getTime());
896
- setLastview = (view, opts) => this.kv.put('lastview', {
897
- view,
898
- opts
899
- });
900
-
901
940
  matchLastPluginRun(pluginid) {
902
941
  let log = this.kv.match('plugin_run_logs') || {};
903
942
  return log[pluginid];
@@ -1002,8 +1041,6 @@ class Store {
1002
1041
  return [events, anchor];
1003
1042
  }
1004
1043
 
1005
- timeDiff = 0;
1006
-
1007
1044
  async loopTime() {
1008
1045
  let startms = _index.default.Date.now();
1009
1046