@subiz/widget-v4 4.1.210 → 4.1.212

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 (130) hide show
  1. package/README.md +21 -2
  2. package/assets/img/dot_chat.svg +3 -0
  3. package/assets/less/chatbox.less +9 -0
  4. package/assets/less/form.less +10 -0
  5. package/assets/less/message.less +114 -13
  6. package/assets/less/widget.less +15 -18
  7. package/compiled_src/call/css.js +1 -1
  8. package/compiled_src/chatbox/Buttons.js +7 -4
  9. package/compiled_src/chatbox/ChatButton.js +127 -29
  10. package/compiled_src/chatbox/Event.js +37 -5
  11. package/compiled_src/chatbox/Events.js +348 -129
  12. package/compiled_src/chatbox/FormAttachment.js +1 -1
  13. package/compiled_src/chatbox/Header.js +7 -2
  14. package/compiled_src/chatbox/InfoMessage.js +1 -1
  15. package/compiled_src/chatbox/MessageInput.js +24 -9
  16. package/compiled_src/chatbox/OrderAttachments.js +13 -13
  17. package/compiled_src/chatbox/QuoteMessage.js +3 -2
  18. package/compiled_src/chatbox/TextMessage.js +22 -18
  19. package/compiled_src/chatbox/Widget.js +200 -129
  20. package/compiled_src/chatbox/block.js +39 -29
  21. package/compiled_src/chatbox/conversation-history.js +44 -0
  22. package/compiled_src/chatbox/event-layout.js +59 -0
  23. package/compiled_src/chatbox/greeting.js +32 -0
  24. package/compiled_src/chatbox/main.js +3 -0
  25. package/compiled_src/common.js +13 -9
  26. package/compiled_src/form/css.js +1 -1
  27. package/compiled_src/lib.js +22 -32
  28. package/compiled_src/notif/css.js +1 -1
  29. package/compiled_src/plugin.js +11 -18
  30. package/compiled_src/popup/css.js +1 -1
  31. package/compiled_src/popup/popup.js +1 -1
  32. package/compiled_src/store/api.js +0 -2
  33. package/compiled_src/store/api_fake.js +1 -1
  34. package/compiled_src/store/attachments.js +28 -0
  35. package/compiled_src/store/chain.js +24 -10
  36. package/compiled_src/store/kv.js +9 -13
  37. package/compiled_src/store/lsdb.js +1 -1
  38. package/compiled_src/store/store.js +356 -117
  39. package/compiled_src/util/common.js +48 -41
  40. package/compiled_src/util/event.js +15 -0
  41. package/compiled_src/util/pubsub.js +28 -13
  42. package/compiled_src/util/url.js +18 -0
  43. package/dist/127.js +13 -13
  44. package/dist/132.js +1 -1
  45. package/dist/1a0f6f3ff1a.127.js +1 -0
  46. package/dist/{1a0d80f6e72.132.js → 1a0f6f3ff1a.132.js} +1 -1
  47. package/dist/{1a0d80f6e72.27.js → 1a0f6f3ff1a.27.js} +1 -1
  48. package/dist/1a0f6f3ff1a.278.js +1 -0
  49. package/dist/{1a0d80f6e72.339.js → 1a0f6f3ff1a.339.js} +1 -1
  50. package/dist/1a0f6f3ff1a.459.js +1 -0
  51. package/dist/1a0f6f3ff1a.app.js +1 -0
  52. package/dist/{1a0d80f6e72.chat.html → 1a0f6f3ff1a.chat.html} +1 -1
  53. package/dist/1a0f6f3ff1a.chat.js +1 -0
  54. package/dist/{1a0d80f6e72.form.html → 1a0f6f3ff1a.form.html} +1 -1
  55. package/dist/1a0f6f3ff1a.form.js +1 -0
  56. package/dist/{1a0d80f6e72.index.html → 1a0f6f3ff1a.index.html} +1 -1
  57. package/dist/{1a0d80f6e72.library.html → 1a0f6f3ff1a.library.html} +1 -1
  58. package/dist/1a0f6f3ff1a.library.js +1 -0
  59. package/dist/{1a0d80f6e72.preview.html → 1a0f6f3ff1a.preview.html} +1 -1
  60. package/dist/1a0f6f3ff1a.preview.js +1 -0
  61. package/dist/1a0f6f3ff1a.webview.js +1 -0
  62. package/dist/27.js +2 -2
  63. package/dist/459.js +2 -2
  64. package/dist/HASH +1 -1
  65. package/dist/assets/img/dot_chat.335fd8a.svg +3 -0
  66. package/dist/screenshoot.js +1523 -619
  67. package/package.json +12 -5
  68. package/src/chatbox/Buttons.js +5 -4
  69. package/src/chatbox/ChatButton.js +133 -39
  70. package/src/chatbox/Event.js +38 -5
  71. package/src/chatbox/Events.js +306 -134
  72. package/src/chatbox/FormAttachment.js +1 -1
  73. package/src/chatbox/Header.js +5 -4
  74. package/src/chatbox/InfoMessage.js +1 -1
  75. package/src/chatbox/MessageInput.js +15 -10
  76. package/src/chatbox/OrderAttachments.js +13 -13
  77. package/src/chatbox/QuoteMessage.js +3 -2
  78. package/src/chatbox/TextMessage.js +21 -20
  79. package/src/chatbox/Widget.js +150 -150
  80. package/src/chatbox/block.js +29 -27
  81. package/src/chatbox/conversation-history.js +37 -0
  82. package/src/chatbox/event-layout.js +72 -0
  83. package/src/chatbox/greeting.js +13 -0
  84. package/src/chatbox/main.js +3 -0
  85. package/src/common.js +15 -9
  86. package/src/lib.js +22 -35
  87. package/src/plugin.js +11 -13
  88. package/src/popup/popup.js +1 -1
  89. package/src/store/api.js +0 -2
  90. package/src/store/api_fake.js +1 -1
  91. package/src/store/attachments.js +21 -0
  92. package/src/store/chain.js +25 -12
  93. package/src/store/kv.js +10 -19
  94. package/src/store/lsdb.js +1 -1
  95. package/src/store/store.js +313 -130
  96. package/src/util/common.js +48 -43
  97. package/src/util/event.js +7 -0
  98. package/src/util/pubsub.js +27 -8
  99. package/src/util/url.js +14 -0
  100. package/test.cjs +59 -0
  101. package/assets/less/contact.less +0 -126
  102. package/compiled_src/util/common.test.js +0 -414
  103. package/compiled_src/util/event.test.js +0 -38
  104. package/compiled_src/util/extractor.test.js +0 -299
  105. package/compiled_src/util/extractor.test2.js +0 -61
  106. package/compiled_src/util/gate.test.js +0 -18
  107. package/compiled_src/util/pubsub.test.js +0 -35
  108. package/dist/1a0d80f6e72.127.js +0 -1
  109. package/dist/1a0d80f6e72.278.js +0 -1
  110. package/dist/1a0d80f6e72.459.js +0 -1
  111. package/dist/1a0d80f6e72.74.js +0 -1
  112. package/dist/1a0d80f6e72.997.js +0 -1
  113. package/dist/1a0d80f6e72.app.js +0 -1
  114. package/dist/1a0d80f6e72.chat.js +0 -1
  115. package/dist/1a0d80f6e72.form.js +0 -1
  116. package/dist/1a0d80f6e72.library.js +0 -1
  117. package/dist/1a0d80f6e72.preview.js +0 -1
  118. package/dist/1a0d80f6e72.webview.js +0 -1
  119. package/dist/74.js +0 -376
  120. package/dist/997.js +0 -37
  121. package/src/contact/contact.js +0 -400
  122. package/src/contact/css.js +0 -1
  123. package/src/util/common.test.js +0 -301
  124. package/src/util/event.test.js +0 -31
  125. package/src/util/extractor.test.js +0 -240
  126. package/src/util/extractor.test2.js +0 -56
  127. package/src/util/gate.test.js +0 -20
  128. package/src/util/pubsub.test.js +0 -37
  129. /package/dist/{1a0d80f6e72.185.js → 1a0f6f3ff1a.185.js} +0 -0
  130. /package/dist/{1a0d80f6e72.490.js → 1a0f6f3ff1a.490.js} +0 -0
@@ -1,414 +0,0 @@
1
- "use strict";
2
-
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
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']
38
- },
39
- href: 'https://qlhd.minvoice.com.vn/#/login',
40
- pass: true
41
- }];
42
- tcs.map(tc => {
43
- var out = util.checkUrlCondition(tc.cond, tc.href);
44
- t.equal(out, tc.pass);
45
- });
46
- t.end();
47
- });
48
- test('util.randomString', t => {
49
- t.equal(10, util.randomString(10).length);
50
- t.equal(11, util.randomString(11).length);
51
- t.equal(12, util.randomString(12).length);
52
- t.end();
53
- });
54
- test('replaceCssVariable mobile height', t => {
55
- let css = "height: '@mobile_height';";
56
- t.equal(util.replaceCssVariable(css, {}), 'height: 100%;', 'defaults to full mobile height');
57
- t.equal(util.replaceCssVariable(css, {
58
- mobile_height: '50%'
59
- }), 'height: 50%;', 'uses configured mobile height');
60
- t.end();
61
- });
62
- test('convert message event first msg send', t => {
63
- var events = [{
64
- by: {
65
- id: 1
66
- },
67
- type: 'message_sent',
68
- created: 1100
69
- }, {
70
- by: {
71
- id: 1
72
- },
73
- type: 'message_sent',
74
- created: 1200
75
- }, {
76
- by: {
77
- id: 1
78
- },
79
- type: 'message_sent',
80
- created: 1300
81
- }];
82
- var expect = [{
83
- by: {
84
- id: 1
85
- },
86
- type: 'message_sent',
87
- created: 1100,
88
- mode: 'lead',
89
- show_time: true
90
- }, {
91
- by: {
92
- id: 1
93
- },
94
- type: 'message_sent',
95
- created: 1200,
96
- mode: 'follow',
97
- show_time: false
98
- }, {
99
- by: {
100
- id: 1
101
- },
102
- type: 'message_sent',
103
- created: 1300,
104
- mode: 'follow',
105
- show_time: false
106
- }];
107
- util.convertMessageEvent(events, 0);
108
- util.convertMessageEvent(events, 1);
109
- util.convertMessageEvent(events, 2);
110
- t.equal(JSON.stringify(events), JSON.stringify(expect));
111
- t.end();
112
- });
113
- test('convert message event message tag', t => {
114
- var events = [{
115
- type: 'conversation_state_updated'
116
- }, {
117
- type: 'conversation_tagged'
118
- }, {
119
- type: 'conversation_tagged'
120
- }, {
121
- type: 'conversation_tagged'
122
- }, {
123
- type: 'conversation_state_updated'
124
- }];
125
- var expect = [{
126
- type: 'conversation_state_updated'
127
- }, {
128
- type: 'conversation_tagged',
129
- mode: 'hide'
130
- }, {
131
- type: 'conversation_tagged',
132
- mode: 'hide'
133
- }, {
134
- type: 'conversation_tagged',
135
- mode: 'combine'
136
- }, {
137
- type: 'conversation_state_updated'
138
- }];
139
- events.map((_, i) => util.convertMessageEvent(events, i));
140
- t.equal(JSON.stringify(events), JSON.stringify(expect));
141
- var events = [{
142
- type: 'conversation_tagged'
143
- }, {
144
- type: 'conversation_tagged'
145
- }, {
146
- type: 'conversation_tagged'
147
- }];
148
- var expect = [{
149
- type: 'conversation_tagged',
150
- mode: 'hide'
151
- }, {
152
- type: 'conversation_tagged',
153
- mode: 'hide'
154
- }, {
155
- type: 'conversation_tagged',
156
- mode: 'combine'
157
- }];
158
- events.map((_, i) => util.convertMessageEvent(events, i));
159
- t.end();
160
- });
161
- test('convert message event message tag, msg_sent mixup', t => {
162
- var events = [{
163
- type: 'conversation_state_updated'
164
- }, {
165
- type: 'conversation_tagged'
166
- }, {
167
- by: {
168
- id: 1
169
- },
170
- type: 'message_sent'
171
- }, {
172
- by: {
173
- id: 2
174
- },
175
- type: 'message_sent'
176
- }, {
177
- type: 'conversation_tagged'
178
- }, {
179
- type: 'conversation_tagged'
180
- }, {
181
- type: 'conversation_state_updated'
182
- }];
183
- var expect = [{
184
- type: 'conversation_state_updated'
185
- }, {
186
- type: 'conversation_tagged',
187
- mode: 'combine'
188
- }, {
189
- by: {
190
- id: 1
191
- },
192
- type: 'message_sent',
193
- mode: 'lead',
194
- show_time: false
195
- }, {
196
- by: {
197
- id: 2
198
- },
199
- type: 'message_sent',
200
- mode: 'lead',
201
- show_time: false
202
- }, {
203
- type: 'conversation_tagged',
204
- mode: 'hide'
205
- }, {
206
- type: 'conversation_tagged',
207
- mode: 'combine'
208
- }, {
209
- type: 'conversation_state_updated'
210
- }];
211
- events.map((_, i) => util.convertMessageEvent(events, i));
212
- t.equal(JSON.stringify(events), JSON.stringify(expect));
213
- t.end();
214
- });
215
- test('test insert message', t => {
216
- var events = [{
217
- type: 'conversation_state_updated'
218
- }, {
219
- id: 1,
220
- type: 'conversation_tagged'
221
- }, {
222
- by: {
223
- id: 1
224
- },
225
- type: 'message_sent'
226
- }, {
227
- by: {
228
- id: 2
229
- },
230
- type: 'message_sent'
231
- }, {
232
- type: 'conversation_tagged'
233
- }, {
234
- type: 'conversation_tagged'
235
- }, {
236
- type: 'conversation_state_updated'
237
- }];
238
- events.map((_, i) => util.convertMessageEvent(events, i));
239
- events.splice(2, 0, {
240
- id: 2,
241
- type: 'conversation_tagged'
242
- });
243
- util.convertUpdatedOrDeletedMessageEvent(events, 2);
244
- var expect = [{
245
- type: 'conversation_state_updated'
246
- }, {
247
- id: 1,
248
- type: 'conversation_tagged',
249
- mode: 'hide'
250
- }, {
251
- id: 2,
252
- type: 'conversation_tagged',
253
- mode: 'combine'
254
- }, {
255
- by: {
256
- id: 1
257
- },
258
- type: 'message_sent',
259
- mode: 'lead',
260
- show_time: false
261
- }, {
262
- by: {
263
- id: 2
264
- },
265
- type: 'message_sent',
266
- mode: 'lead',
267
- show_time: false
268
- }, {
269
- type: 'conversation_tagged',
270
- mode: 'hide'
271
- }, {
272
- type: 'conversation_tagged',
273
- mode: 'combine'
274
- }, {
275
- type: 'conversation_state_updated'
276
- }];
277
- t.equal(JSON.stringify(events), JSON.stringify(expect));
278
- t.end();
279
- });
280
- test('mapizeDeep a map', t => {
281
- var topicM = {
282
- 0: {
283
- topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxnairroppcktrg',
284
- read: false,
285
- updated: 1570586074000
286
- },
287
- 1: {
288
- topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxmkozwryrgjvag',
289
- read: false,
290
- updated: 1570551305000
291
- },
292
- 2: {
293
- topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlvkqgspihkfzsnm',
294
- read: false,
295
- updated: 1570289320000
296
- }
297
- };
298
- var out = util.mapizeDeep(topicM, 'topic');
299
- topicM['0'].topic = 't3';
300
- t.deepEqual(out, {
301
- 'account.acqcsmrppbftadjzxnvo.conversation.csqlxnairroppcktrg': {
302
- topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxnairroppcktrg',
303
- read: false,
304
- updated: 1570586074000
305
- },
306
- 'account.acqcsmrppbftadjzxnvo.conversation.csqlxmkozwryrgjvag': {
307
- topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlxmkozwryrgjvag',
308
- read: false,
309
- updated: 1570551305000
310
- },
311
- 'account.acqcsmrppbftadjzxnvo.conversation.csqlvkqgspihkfzsnm': {
312
- topic: 'account.acqcsmrppbftadjzxnvo.conversation.csqlvkqgspihkfzsnm',
313
- read: false,
314
- updated: 1570289320000
315
- }
316
- });
317
- t.end();
318
- });
319
- test('mapize a map', t => {
320
- var topicM = {
321
- 0: {
322
- topic: 't1',
323
- updated: 157
324
- },
325
- 1: {
326
- topic: 't2',
327
- updated: 158
328
- }
329
- };
330
- var out = util.mapize(topicM, 'topic');
331
- t.deepEqual(out, {
332
- t1: {
333
- topic: 't1',
334
- updated: 157
335
- },
336
- t2: {
337
- topic: 't2',
338
- updated: 158
339
- }
340
- });
341
- t.end();
342
- });
343
- test('mapize', t => {
344
- var arr = [{
345
- id: 0,
346
- value: 0
347
- }, {
348
- id: 1,
349
- value: 1
350
- }, {
351
- id: 2,
352
- value: 2
353
- }, {
354
- id: 3,
355
- value: 3
356
- }, {
357
- id: 4,
358
- value: 4
359
- }];
360
- var m = util.mapize(arr, 'id');
361
- for (var i = 0; i < arr.length; i++) {
362
- t.equal(m[i], arr[i]);
363
- }
364
- t.end();
365
- });
366
- test('convo id from topic', t => {
367
- t.equal('csqldpucwamyuaetjf', util.convoIdFromTopic('account.acqcsmrppbftadjzxnvo.conversation.csqldpucwamyuaetjf'));
368
- t.end();
369
- });
370
- test('user of convo', t => {
371
- var convo = {
372
- id: 'csqlmhetrpccwprnms',
373
- account_id: 'acqcsmrppbftadjzxnvo',
374
- created: 1568970100964184000,
375
- members: [{
376
- type: 'bot',
377
- id: 'agqhgvgtbwhsbolwtp',
378
- name: 'Automation bot',
379
- membership: 'active'
380
- }, {
381
- type: 'user',
382
- id: 'usqlmfpdhxmajzggsjosw',
383
- name: '',
384
- membership: 'active'
385
- }, {
386
- type: 'agent',
387
- id: 'agqcsmrppbfqstjwen',
388
- name: 'Thành',
389
- membership: 'active'
390
- }, {
391
- type: 'user',
392
- id: 'usqlmfpdhxmajzgasdf',
393
- name: '',
394
- membership: 'active'
395
- }, {
396
- type: 'agent',
397
- id: 'agqczwdrggvdnlbuom',
398
- name: 'THanh',
399
- membership: 'observer'
400
- }],
401
- ended: 1569004072969908700,
402
- state: 'ended',
403
- accepted: 1568970101938098700,
404
- actived: 1568974069989570300,
405
- response_sec: 0,
406
- first_message: 'sdfg',
407
- subject: 'sdfg'
408
- };
409
- var users = util.usersOfConvo(convo);
410
- t.equal(users.length, 2);
411
- t.equal(users[0], 'usqlmfpdhxmajzggsjosw');
412
- t.equal(users[1], 'usqlmfpdhxmajzgasdf');
413
- t.end();
414
- });
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- var test = require('tape');
4
- var {
5
- normalizeCdpEvent
6
- } = require('./event.js');
7
- test('normalize cdp event new signature', t => {
8
- t.deepEqual(normalizeCdpEvent('content_viewed', {
9
- url: 'https://example.com/products/pd2345',
10
- title: 'Bàn phím cơ không dây'
11
- }, {
12
- event_source_id: 'evt_1234'
13
- }), {
14
- type: 'content_viewed',
15
- payload: {
16
- url: 'https://example.com/products/pd2345',
17
- title: 'Bàn phím cơ không dây'
18
- },
19
- event_source_id: 'evt_1234'
20
- });
21
- t.end();
22
- });
23
- test('normalize cdp event without payload', t => {
24
- t.deepEqual(normalizeCdpEvent('login'), {
25
- type: 'login'
26
- });
27
- t.end();
28
- });
29
- test('normalize cdp event keeps old object signature', t => {
30
- let event = {
31
- type: 'product_viewed',
32
- payload: {
33
- id: 'pd2345'
34
- }
35
- };
36
- t.equal(normalizeCdpEvent(event), event);
37
- t.end();
38
- });