@subiz/widget-v4 4.1.210 → 4.1.211

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 (124) hide show
  1. package/README.md +21 -2
  2. package/assets/less/chatbox.less +9 -0
  3. package/assets/less/form.less +10 -0
  4. package/assets/less/message.less +114 -13
  5. package/assets/less/widget.less +21 -16
  6. package/compiled_src/call/css.js +1 -1
  7. package/compiled_src/chatbox/Buttons.js +7 -4
  8. package/compiled_src/chatbox/ChatButton.js +115 -29
  9. package/compiled_src/chatbox/Event.js +37 -5
  10. package/compiled_src/chatbox/Events.js +348 -129
  11. package/compiled_src/chatbox/FormAttachment.js +1 -1
  12. package/compiled_src/chatbox/Header.js +6 -2
  13. package/compiled_src/chatbox/InfoMessage.js +1 -1
  14. package/compiled_src/chatbox/MessageInput.js +24 -9
  15. package/compiled_src/chatbox/OrderAttachments.js +13 -13
  16. package/compiled_src/chatbox/QuoteMessage.js +3 -2
  17. package/compiled_src/chatbox/TextMessage.js +22 -18
  18. package/compiled_src/chatbox/Widget.js +200 -129
  19. package/compiled_src/chatbox/block.js +39 -29
  20. package/compiled_src/chatbox/conversation-history.js +44 -0
  21. package/compiled_src/chatbox/event-layout.js +59 -0
  22. package/compiled_src/chatbox/greeting.js +32 -0
  23. package/compiled_src/common.js +13 -9
  24. package/compiled_src/form/css.js +1 -1
  25. package/compiled_src/lib.js +22 -32
  26. package/compiled_src/notif/css.js +1 -1
  27. package/compiled_src/plugin.js +11 -18
  28. package/compiled_src/popup/css.js +1 -1
  29. package/compiled_src/popup/popup.js +1 -1
  30. package/compiled_src/store/api.js +0 -2
  31. package/compiled_src/store/api_fake.js +1 -1
  32. package/compiled_src/store/attachments.js +28 -0
  33. package/compiled_src/store/chain.js +24 -10
  34. package/compiled_src/store/kv.js +9 -13
  35. package/compiled_src/store/lsdb.js +1 -1
  36. package/compiled_src/store/store.js +356 -117
  37. package/compiled_src/util/common.js +48 -41
  38. package/compiled_src/util/event.js +15 -0
  39. package/compiled_src/util/pubsub.js +28 -13
  40. package/compiled_src/util/url.js +18 -0
  41. package/dist/.HASH +1 -0
  42. package/dist/127.js +13 -13
  43. package/dist/132.js +1 -1
  44. package/dist/1a0ddc53cbb.127.js +1 -0
  45. package/dist/{1a0d80f6e72.132.js → 1a0ddc53cbb.132.js} +1 -1
  46. package/dist/1a0ddc53cbb.278.js +1 -0
  47. package/dist/{1a0d80f6e72.339.js → 1a0ddc53cbb.339.js} +1 -1
  48. package/dist/1a0ddc53cbb.app.js +1 -0
  49. package/dist/{1a0d80f6e72.chat.html → 1a0ddc53cbb.chat.html} +1 -1
  50. package/dist/1a0ddc53cbb.chat.js +1 -0
  51. package/dist/{1a0d80f6e72.form.html → 1a0ddc53cbb.form.html} +1 -1
  52. package/dist/1a0ddc53cbb.form.js +1 -0
  53. package/dist/{1a0d80f6e72.index.html → 1a0ddc53cbb.index.html} +1 -1
  54. package/dist/{1a0d80f6e72.library.html → 1a0ddc53cbb.library.html} +1 -1
  55. package/dist/1a0ddc53cbb.library.js +1 -0
  56. package/dist/{1a0d80f6e72.preview.html → 1a0ddc53cbb.preview.html} +1 -1
  57. package/dist/1a0ddc53cbb.preview.js +1 -0
  58. package/dist/1a0ddc53cbb.webview.js +1 -0
  59. package/dist/screenshoot.js +1492 -616
  60. package/package.json +10 -3
  61. package/src/chatbox/Buttons.js +5 -4
  62. package/src/chatbox/ChatButton.js +120 -39
  63. package/src/chatbox/Event.js +38 -5
  64. package/src/chatbox/Events.js +306 -134
  65. package/src/chatbox/FormAttachment.js +1 -1
  66. package/src/chatbox/Header.js +4 -4
  67. package/src/chatbox/InfoMessage.js +1 -1
  68. package/src/chatbox/MessageInput.js +15 -10
  69. package/src/chatbox/OrderAttachments.js +13 -13
  70. package/src/chatbox/QuoteMessage.js +3 -2
  71. package/src/chatbox/TextMessage.js +21 -20
  72. package/src/chatbox/Widget.js +150 -150
  73. package/src/chatbox/block.js +29 -27
  74. package/src/chatbox/conversation-history.js +37 -0
  75. package/src/chatbox/event-layout.js +72 -0
  76. package/src/chatbox/greeting.js +13 -0
  77. package/src/common.js +15 -9
  78. package/src/lib.js +22 -35
  79. package/src/plugin.js +11 -13
  80. package/src/popup/popup.js +1 -1
  81. package/src/store/api.js +0 -2
  82. package/src/store/api_fake.js +1 -1
  83. package/src/store/attachments.js +21 -0
  84. package/src/store/chain.js +25 -12
  85. package/src/store/kv.js +10 -19
  86. package/src/store/lsdb.js +1 -1
  87. package/src/store/store.js +313 -130
  88. package/src/util/common.js +48 -43
  89. package/src/util/event.js +7 -0
  90. package/src/util/pubsub.js +27 -8
  91. package/src/util/url.js +14 -0
  92. package/test.cjs +59 -0
  93. package/assets/less/contact.less +0 -126
  94. package/compiled_src/util/common.test.js +0 -414
  95. package/compiled_src/util/event.test.js +0 -38
  96. package/compiled_src/util/extractor.test.js +0 -299
  97. package/compiled_src/util/extractor.test2.js +0 -61
  98. package/compiled_src/util/gate.test.js +0 -18
  99. package/compiled_src/util/pubsub.test.js +0 -35
  100. package/dist/1a0d80f6e72.127.js +0 -1
  101. package/dist/1a0d80f6e72.278.js +0 -1
  102. package/dist/1a0d80f6e72.74.js +0 -1
  103. package/dist/1a0d80f6e72.997.js +0 -1
  104. package/dist/1a0d80f6e72.app.js +0 -1
  105. package/dist/1a0d80f6e72.chat.js +0 -1
  106. package/dist/1a0d80f6e72.form.js +0 -1
  107. package/dist/1a0d80f6e72.library.js +0 -1
  108. package/dist/1a0d80f6e72.preview.js +0 -1
  109. package/dist/1a0d80f6e72.webview.js +0 -1
  110. package/dist/74.js +0 -376
  111. package/dist/997.js +0 -37
  112. package/dist/HASH +0 -1
  113. package/src/contact/contact.js +0 -400
  114. package/src/contact/css.js +0 -1
  115. package/src/util/common.test.js +0 -301
  116. package/src/util/event.test.js +0 -31
  117. package/src/util/extractor.test.js +0 -240
  118. package/src/util/extractor.test2.js +0 -56
  119. package/src/util/gate.test.js +0 -20
  120. package/src/util/pubsub.test.js +0 -37
  121. /package/dist/{1a0d80f6e72.185.js → 1a0ddc53cbb.185.js} +0 -0
  122. /package/dist/{1a0d80f6e72.27.js → 1a0ddc53cbb.27.js} +0 -0
  123. /package/dist/{1a0d80f6e72.459.js → 1a0ddc53cbb.459.js} +0 -0
  124. /package/dist/{1a0d80f6e72.490.js → 1a0ddc53cbb.490.js} +0 -0
@@ -1,31 +0,0 @@
1
- var test = require('tape')
2
- var {normalizeCdpEvent} = require('./event.js')
3
-
4
- test('normalize cdp event new signature', (t) => {
5
- t.deepEqual(
6
- normalizeCdpEvent('content_viewed', {
7
- url: 'https://example.com/products/pd2345',
8
- title: 'Bàn phím cơ không dây',
9
- }, {event_source_id: 'evt_1234'}),
10
- {
11
- type: 'content_viewed',
12
- payload: {
13
- url: 'https://example.com/products/pd2345',
14
- title: 'Bàn phím cơ không dây',
15
- },
16
- event_source_id: 'evt_1234',
17
- },
18
- )
19
- t.end()
20
- })
21
-
22
- test('normalize cdp event without payload', (t) => {
23
- t.deepEqual(normalizeCdpEvent('login'), {type: 'login'})
24
- t.end()
25
- })
26
-
27
- test('normalize cdp event keeps old object signature', (t) => {
28
- let event = {type: 'product_viewed', payload: {id: 'pd2345'}}
29
- t.equal(normalizeCdpEvent(event), event)
30
- t.end()
31
- })
@@ -1,240 +0,0 @@
1
- var test = require('tape')
2
- var lo = require('lodash')
3
-
4
- let { extractEmails, extractPhones, extractLinks, extractText, extractEmojis, maskEmojis } = require('./extractor.js')
5
-
6
- test('extract emails', t => {
7
- var tcs = [
8
- {
9
- text: 'email',
10
- out: [],
11
- },
12
- {
13
- text: 'email cua toi la thanh@live.com va b@live.com',
14
- out: [
15
- { index: 17, length: 14 },
16
- { index: 35, length: 10 },
17
- ],
18
- },
19
- {
20
- text: 'email cua toi la :thanh@live.com',
21
- out: [{ index: 18, length: 14 }],
22
- },
23
- {
24
- text: 'email cua toi la :thanh@live.com/',
25
- out: [{ index: 18, length: 14 }],
26
- },
27
- ]
28
-
29
- tcs.map(tc => {
30
- var out = extractEmails(tc.text)
31
- var isequal = lo.isEqual(out, tc.out)
32
- t.true(isequal)
33
- })
34
- t.end()
35
- })
36
-
37
- test('extract phones', t => {
38
- var tcs = [
39
- {
40
- text: '',
41
- out: [],
42
- },
43
- {
44
- text: 'sdt cua toi la 01234.566.7 va 0245092485',
45
- out: [
46
- { index: 15, length: 11 },
47
- { index: 30, length: 10 },
48
- ],
49
- },
50
- {
51
- text: 'a 0974.06.2222',
52
- out: [{ index: 2, length: 12 }],
53
- },
54
- {
55
- text: 'https://donghoduyanh.com/tissot/t-classic-quartz/tissot-classic-dream-t0334103605101-262-560-4335.html',
56
- out: [
57
- { index: 71, length: 13 },
58
- { index: 85, length: 12 },
59
- ],
60
- },
61
- ]
62
- tcs.map(tc => {
63
- var out = extractPhones(tc.text)
64
- var isequal = lo.isEqual(out, tc.out)
65
- t.true(isequal)
66
- })
67
- t.end()
68
- })
69
-
70
- test('extract link', t => {
71
- var tcs = [
72
- {
73
- text: '',
74
- out: [],
75
- },
76
- {
77
- text: 'vao https://subiz.com a',
78
- out: [{ index: 4, length: 17 }],
79
- },
80
- {
81
- text: 'day htt://a.com',
82
- out: [{ index: 10, length: 5 }],
83
- },
84
- {
85
- text: 'chao http://http.ne/22',
86
- out: [{ index: 5, length: 17 }],
87
- },
88
- {
89
- text: 'chao google.com',
90
- out: [{ index: 5, length: 10 }],
91
- },
92
- ]
93
- tcs.map(tc => {
94
- var out = extractLinks(tc.text)
95
- var isequal = lo.isEqual(out, tc.out)
96
- t.true(isequal)
97
- })
98
- t.end()
99
- })
100
-
101
- test('extract emojis', t => {
102
- var tcs = [
103
- {
104
- text: 'xin chao :smiling:',
105
- out: [{ index: 9, length: 9 }],
106
- },
107
- {
108
- text: 'xin chao :smiling: :angry:',
109
- out: [
110
- { index: 9, length: 9 },
111
- { index: 19, length: 7 },
112
- ],
113
- },
114
- {
115
- text: 'xin chao ::smiling:',
116
- out: [{ index: 10, length: 9 }],
117
- },
118
- {
119
- text: 'xin chao :smil e:',
120
- out: [],
121
- },
122
- {
123
- text: 'xin chao :smil e:',
124
- out: [],
125
- },
126
- {
127
- text: 'xin chao :smil:smiling:',
128
- out: [{ index: 14, length: 9 }],
129
- },
130
- ]
131
- tcs.map(tc => {
132
- var out = extractEmojis(tc.text)
133
- var isequal = lo.isEqual(out, tc.out)
134
- t.true(isequal)
135
- })
136
- t.end()
137
- })
138
-
139
- test('extract text', t => {
140
- var tcs = [
141
- {
142
- text: 'xin chao',
143
- out: [{ type: 'text', text: 'xin chao' }],
144
- },
145
- {
146
- text: 'xin chao thanhpk@live.com',
147
- out: [
148
- { type: 'text', text: 'xin chao ' },
149
- { type: 'email', text: 'thanhpk@live.com' },
150
- ],
151
- },
152
- {
153
- text: 'xin chao thanhpk-0365045844@live.com, sdt: 03650451844',
154
- out: [
155
- { type: 'text', text: 'xin chao ' },
156
- { type: 'email', text: 'thanhpk-0365045844@live.com' },
157
- { type: 'text', text: ', sdt: ' },
158
- { type: 'phone', text: '03650451844' },
159
- ],
160
- },
161
- {
162
- text: 'xin chao https://subiz.com, sdt: 03650451844',
163
- out: [
164
- { type: 'text', text: 'xin chao ' },
165
- { type: 'link', text: 'https://subiz.com' },
166
- { type: 'text', text: ', sdt: ' },
167
- { type: 'phone', text: '03650451844' },
168
- ],
169
- },
170
- {
171
- text: 'https://google.com he :smiling:, :ll:',
172
- out: [
173
- { type: 'link', text: 'https://google.com' },
174
- { type: 'text', text: ' he ' },
175
- { type: 'emoji', text: ':smiling:' },
176
- { type: 'text', text: ', :ll:' },
177
- ],
178
- },
179
- {
180
- text: 'google.com/?a=5&b=6 he :smiling:, :ll:',
181
- out: [
182
- { type: 'link', text: 'google.com/?a=5&b=6' },
183
- { type: 'text', text: ' he ' },
184
- { type: 'emoji', text: ':smiling:' },
185
- { type: 'text', text: ', :ll:' },
186
- ],
187
- },
188
- ]
189
- tcs.map(tc => {
190
- var out = extractText(tc.text)
191
- var isequal = lo.isEqual(out, tc.out)
192
- t.true(isequal)
193
- })
194
- t.end()
195
- })
196
-
197
- test('mask emoji', t => {
198
- var tcs = [
199
- {
200
- text: 'xin chao :smiling:',
201
- out: [
202
- { type: 'text', value: 'xin chao ' },
203
- { type: 'emoji', value: ':smiling:' },
204
- ],
205
- },
206
- {
207
- text: 'xin chao :smiling: :angry:',
208
- out: [
209
- { type: 'text', value: 'xin chao ' },
210
- { type: 'emoji', value: ':smiling:' },
211
- { type: 'text', value: ' ' },
212
- { type: 'emoji', value: ':angry:' },
213
- ],
214
- },
215
- {
216
- text: 'xin chao ::smiling:',
217
- out: [
218
- { type: 'text', value: 'xin chao :' },
219
- { type: 'emoji', value: ':smiling:' },
220
- ],
221
- },
222
- {
223
- text: 'xin chao :smil e:',
224
- out: [{ type: 'text', value: 'xin chao :smil e:' }],
225
- },
226
- {
227
- text: 'xin chao :smil:smiling:',
228
- out: [
229
- { type: 'text', value: 'xin chao :smil' },
230
- { type: 'emoji', value: ':smiling:' },
231
- ],
232
- },
233
- ]
234
-
235
- tcs.forEach(tc => {
236
- var out = maskEmojis(tc.text)
237
- t.equal(JSON.stringify(out), JSON.stringify(tc.out))
238
- })
239
- t.end()
240
- })
@@ -1,56 +0,0 @@
1
- // somehow require error so we need copy paste function test here
2
- function extractLinks(text) {
3
- text = text || ''
4
- var reg = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z()]{2,6}\b([-a-zA-Z0-9@:%_\+.,~#?&//=]*)/gim
5
- var out = []
6
- var match
7
- while ((match = reg.exec(text))) {
8
- out.push({index: match.index, length: reg.lastIndex - match.index})
9
- }
10
-
11
- return out
12
- }
13
-
14
- function main() {
15
- var tcs = [
16
- {
17
- text: '',
18
- out: [],
19
- },
20
- {
21
- text: 'vao https://subiz.com a',
22
- out: [{ index: 4, length: 17 }],
23
- },
24
- {
25
- text: 'day htt://a.com',
26
- out: [{ index: 10, length: 5 }],
27
- },
28
- {
29
- text: 'chao http://http.ne/22',
30
- out: [{ index: 5, length: 17 }],
31
- },
32
- {
33
- text: 'chao google.com',
34
- out: [{ index: 5, length: 10 }],
35
- },
36
- {
37
- text: 'Bạn có thể xem hình ảnh của Mazda2 1.5L AT qua liên kết dưới đây:',
38
- out: [],
39
- },
40
- {
41
- text: 'Giá: 386.000.000 VNĐ',
42
- out: [],
43
- },
44
- ]
45
-
46
- for (var i = 0; i < tcs.length; i++) {
47
- var tc = tcs[i]
48
- var out = extractLinks(tc.text)
49
- if (JSON.stringify(out) !== JSON.stringify(tc.out)) {
50
- console.error('FAIL', tc.text, '\n', JSON.stringify(out, null, 4), '\n', JSON.stringify(tc.out, null, 4))
51
- } else {
52
- console.info('PASS', tc.text)
53
- }
54
- }
55
- }
56
- main()
@@ -1,20 +0,0 @@
1
- var test = require('tape')
2
- var Gate = require('./gate.js')
3
-
4
- test('gate', async t => {
5
- var gate = new Gate() // gate is closed by default
6
-
7
- var flip = 0
8
- setTimeout(function () {
9
- flip = 1
10
- gate.open()
11
- }, 1000)
12
-
13
- await gate.entry()
14
- t.equal(flip, 1)
15
-
16
- await gate.entry()
17
- await gate.entry()
18
- t.equal(flip, 1)
19
- t.end()
20
- })
@@ -1,37 +0,0 @@
1
- var test = require('tape')
2
- var Pubsub = require('./pubsub.js')
3
-
4
- test('pubsub simple', t => {
5
- var ps = new Pubsub()
6
- var msg = { name: 'thanh' }
7
- var count = 0
8
- ps.on('hi', payload => {
9
- t.equal(payload, msg)
10
- count++
11
- })
12
- ps.on('hi', payload => {
13
- t.equal(payload, msg)
14
- count++
15
- })
16
- var sub = ps.on('hi', payload => {
17
- t.equal(payload, msg)
18
- count++
19
- })
20
-
21
- ps.publish('hi', msg)
22
- t.equal(count, 3)
23
-
24
- ps.un(sub)
25
- ps.publish('hi', msg)
26
- ps.publish('hi', msg)
27
- t.equal(count, 7)
28
-
29
- ps.only('hi', payload => {
30
- count--
31
- })
32
-
33
- ps.publish('hi', 0)
34
- t.equal(count, 6)
35
-
36
- t.end()
37
- })
File without changes
File without changes
File without changes
File without changes