@subiz/widget-v4 4.1.209 → 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.
- package/README.md +21 -2
- package/assets/less/chatbox.less +9 -0
- package/assets/less/form.less +10 -0
- package/assets/less/message.less +114 -13
- package/assets/less/widget.less +21 -16
- package/compiled_src/call/css.js +1 -1
- package/compiled_src/chatbox/Buttons.js +7 -4
- package/compiled_src/chatbox/ChatButton.js +115 -29
- package/compiled_src/chatbox/Event.js +37 -5
- package/compiled_src/chatbox/Events.js +348 -129
- package/compiled_src/chatbox/FormAttachment.js +1 -1
- package/compiled_src/chatbox/Header.js +6 -2
- package/compiled_src/chatbox/InfoMessage.js +1 -1
- package/compiled_src/chatbox/MessageInput.js +24 -9
- package/compiled_src/chatbox/OrderAttachments.js +13 -13
- package/compiled_src/chatbox/QuoteMessage.js +3 -2
- package/compiled_src/chatbox/TextMessage.js +22 -18
- package/compiled_src/chatbox/Widget.js +200 -129
- package/compiled_src/chatbox/block.js +39 -29
- package/compiled_src/chatbox/conversation-history.js +44 -0
- package/compiled_src/chatbox/event-layout.js +59 -0
- package/compiled_src/chatbox/greeting.js +32 -0
- package/compiled_src/common.js +13 -9
- package/compiled_src/form/css.js +1 -1
- package/compiled_src/lib.js +22 -32
- package/compiled_src/notif/css.js +1 -1
- package/compiled_src/plugin.js +11 -18
- package/compiled_src/popup/css.js +1 -1
- package/compiled_src/popup/popup.js +1 -1
- package/compiled_src/store/api.js +0 -2
- package/compiled_src/store/api_fake.js +1 -1
- package/compiled_src/store/attachments.js +28 -0
- package/compiled_src/store/chain.js +24 -10
- package/compiled_src/store/kv.js +9 -13
- package/compiled_src/store/lsdb.js +1 -1
- package/compiled_src/store/store.js +356 -117
- package/compiled_src/util/common.js +48 -41
- package/compiled_src/util/event.js +15 -0
- package/compiled_src/util/pubsub.js +28 -13
- package/compiled_src/util/url.js +18 -0
- package/dist/.HASH +1 -0
- package/dist/127.js +13 -13
- package/dist/132.js +1 -1
- package/dist/1a0ddc53cbb.127.js +1 -0
- package/dist/{1a08405c848.132.js → 1a0ddc53cbb.132.js} +1 -1
- package/dist/{1a08405c848.27.js → 1a0ddc53cbb.27.js} +1 -1
- package/dist/1a0ddc53cbb.278.js +1 -0
- package/dist/{1a08405c848.339.js → 1a0ddc53cbb.339.js} +1 -1
- package/dist/1a0ddc53cbb.459.js +1 -0
- package/dist/1a0ddc53cbb.app.js +1 -0
- package/dist/1a0ddc53cbb.chat.html +1 -0
- package/dist/1a0ddc53cbb.chat.js +1 -0
- package/dist/1a0ddc53cbb.form.html +1 -0
- package/dist/1a0ddc53cbb.form.js +1 -0
- package/dist/1a0ddc53cbb.index.html +72 -0
- package/dist/1a0ddc53cbb.library.html +72 -0
- package/dist/1a0ddc53cbb.library.js +1 -0
- package/dist/1a0ddc53cbb.preview.html +759 -0
- package/dist/1a0ddc53cbb.preview.js +1 -0
- package/dist/1a0ddc53cbb.webview.js +1 -0
- package/dist/27.js +4 -4
- package/dist/459.js +4 -4
- package/dist/screenshoot.js +1523 -654
- package/package.json +10 -3
- package/src/call/css.js +1 -1
- package/src/chatbox/Buttons.js +5 -4
- package/src/chatbox/ChatButton.js +120 -39
- package/src/chatbox/Event.js +38 -5
- package/src/chatbox/Events.js +306 -134
- package/src/chatbox/FormAttachment.js +1 -1
- package/src/chatbox/Header.js +4 -4
- package/src/chatbox/InfoMessage.js +1 -1
- package/src/chatbox/MessageInput.js +15 -10
- package/src/chatbox/OrderAttachments.js +13 -13
- package/src/chatbox/QuoteMessage.js +3 -2
- package/src/chatbox/TextMessage.js +21 -20
- package/src/chatbox/Widget.js +150 -150
- package/src/chatbox/block.js +29 -27
- package/src/chatbox/conversation-history.js +37 -0
- package/src/chatbox/event-layout.js +72 -0
- package/src/chatbox/greeting.js +13 -0
- package/src/common.js +15 -9
- package/src/form/css.js +1 -1
- package/src/lib.js +22 -35
- package/src/notif/css.js +1 -1
- package/src/plugin.js +11 -13
- package/src/popup/css.js +1 -1
- package/src/popup/popup.js +1 -1
- package/src/store/api.js +0 -2
- package/src/store/api_fake.js +1 -1
- package/src/store/attachments.js +21 -0
- package/src/store/chain.js +25 -12
- package/src/store/kv.js +10 -19
- package/src/store/lsdb.js +1 -1
- package/src/store/store.js +313 -130
- package/src/util/common.js +48 -43
- package/src/util/event.js +7 -0
- package/src/util/pubsub.js +27 -8
- package/src/util/url.js +14 -0
- package/test.cjs +59 -0
- package/webpack.prod.js +3 -0
- package/assets/less/contact.less +0 -126
- package/compiled_src/util/common.test.js +0 -414
- package/compiled_src/util/event.test.js +0 -38
- package/compiled_src/util/extractor.test.js +0 -299
- package/compiled_src/util/extractor.test2.js +0 -61
- package/compiled_src/util/gate.test.js +0 -18
- package/compiled_src/util/pubsub.test.js +0 -35
- package/dist/1a08405c848.127.js +0 -1
- package/dist/1a08405c848.278.js +0 -1
- package/dist/1a08405c848.459.js +0 -1
- package/dist/1a08405c848.74.js +0 -1
- package/dist/1a08405c848.997.js +0 -1
- package/dist/1a08405c848.app.js +0 -1
- package/dist/1a08405c848.chat.html +0 -1
- package/dist/1a08405c848.chat.js +0 -1
- package/dist/1a08405c848.form.html +0 -1
- package/dist/1a08405c848.form.js +0 -1
- package/dist/1a08405c848.index.html +0 -1
- package/dist/1a08405c848.library.html +0 -1
- package/dist/1a08405c848.library.js +0 -1
- package/dist/1a08405c848.preview.html +0 -1
- package/dist/1a08405c848.preview.js +0 -1
- package/dist/1a08405c848.webview.js +0 -1
- package/dist/74.js +0 -376
- package/dist/997.js +0 -37
- package/dist/HASH +0 -1
- package/src/contact/contact.js +0 -400
- package/src/contact/css.js +0 -1
- package/src/util/common.test.js +0 -301
- package/src/util/event.test.js +0 -31
- package/src/util/extractor.test.js +0 -240
- package/src/util/extractor.test2.js +0 -56
- package/src/util/gate.test.js +0 -20
- package/src/util/pubsub.test.js +0 -37
- /package/dist/{1a08405c848.185.js → 1a0ddc53cbb.185.js} +0 -0
- /package/dist/{1a08405c848.490.js → 1a0ddc53cbb.490.js} +0 -0
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var test = require('tape');
|
|
4
|
-
var lo = require('lodash');
|
|
5
|
-
let {
|
|
6
|
-
extractEmails,
|
|
7
|
-
extractPhones,
|
|
8
|
-
extractLinks,
|
|
9
|
-
extractText,
|
|
10
|
-
extractEmojis,
|
|
11
|
-
maskEmojis
|
|
12
|
-
} = require('./extractor.js');
|
|
13
|
-
test('extract emails', t => {
|
|
14
|
-
var tcs = [{
|
|
15
|
-
text: 'email',
|
|
16
|
-
out: []
|
|
17
|
-
}, {
|
|
18
|
-
text: 'email cua toi la thanh@live.com va b@live.com',
|
|
19
|
-
out: [{
|
|
20
|
-
index: 17,
|
|
21
|
-
length: 14
|
|
22
|
-
}, {
|
|
23
|
-
index: 35,
|
|
24
|
-
length: 10
|
|
25
|
-
}]
|
|
26
|
-
}, {
|
|
27
|
-
text: 'email cua toi la :thanh@live.com',
|
|
28
|
-
out: [{
|
|
29
|
-
index: 18,
|
|
30
|
-
length: 14
|
|
31
|
-
}]
|
|
32
|
-
}, {
|
|
33
|
-
text: 'email cua toi la :thanh@live.com/',
|
|
34
|
-
out: [{
|
|
35
|
-
index: 18,
|
|
36
|
-
length: 14
|
|
37
|
-
}]
|
|
38
|
-
}];
|
|
39
|
-
tcs.map(tc => {
|
|
40
|
-
var out = extractEmails(tc.text);
|
|
41
|
-
var isequal = lo.isEqual(out, tc.out);
|
|
42
|
-
t.true(isequal);
|
|
43
|
-
});
|
|
44
|
-
t.end();
|
|
45
|
-
});
|
|
46
|
-
test('extract phones', t => {
|
|
47
|
-
var tcs = [{
|
|
48
|
-
text: '',
|
|
49
|
-
out: []
|
|
50
|
-
}, {
|
|
51
|
-
text: 'sdt cua toi la 01234.566.7 va 0245092485',
|
|
52
|
-
out: [{
|
|
53
|
-
index: 15,
|
|
54
|
-
length: 11
|
|
55
|
-
}, {
|
|
56
|
-
index: 30,
|
|
57
|
-
length: 10
|
|
58
|
-
}]
|
|
59
|
-
}, {
|
|
60
|
-
text: 'a 0974.06.2222',
|
|
61
|
-
out: [{
|
|
62
|
-
index: 2,
|
|
63
|
-
length: 12
|
|
64
|
-
}]
|
|
65
|
-
}, {
|
|
66
|
-
text: 'https://donghoduyanh.com/tissot/t-classic-quartz/tissot-classic-dream-t0334103605101-262-560-4335.html',
|
|
67
|
-
out: [{
|
|
68
|
-
index: 71,
|
|
69
|
-
length: 13
|
|
70
|
-
}, {
|
|
71
|
-
index: 85,
|
|
72
|
-
length: 12
|
|
73
|
-
}]
|
|
74
|
-
}];
|
|
75
|
-
tcs.map(tc => {
|
|
76
|
-
var out = extractPhones(tc.text);
|
|
77
|
-
var isequal = lo.isEqual(out, tc.out);
|
|
78
|
-
t.true(isequal);
|
|
79
|
-
});
|
|
80
|
-
t.end();
|
|
81
|
-
});
|
|
82
|
-
test('extract link', t => {
|
|
83
|
-
var tcs = [{
|
|
84
|
-
text: '',
|
|
85
|
-
out: []
|
|
86
|
-
}, {
|
|
87
|
-
text: 'vao https://subiz.com a',
|
|
88
|
-
out: [{
|
|
89
|
-
index: 4,
|
|
90
|
-
length: 17
|
|
91
|
-
}]
|
|
92
|
-
}, {
|
|
93
|
-
text: 'day htt://a.com',
|
|
94
|
-
out: [{
|
|
95
|
-
index: 10,
|
|
96
|
-
length: 5
|
|
97
|
-
}]
|
|
98
|
-
}, {
|
|
99
|
-
text: 'chao http://http.ne/22',
|
|
100
|
-
out: [{
|
|
101
|
-
index: 5,
|
|
102
|
-
length: 17
|
|
103
|
-
}]
|
|
104
|
-
}, {
|
|
105
|
-
text: 'chao google.com',
|
|
106
|
-
out: [{
|
|
107
|
-
index: 5,
|
|
108
|
-
length: 10
|
|
109
|
-
}]
|
|
110
|
-
}];
|
|
111
|
-
tcs.map(tc => {
|
|
112
|
-
var out = extractLinks(tc.text);
|
|
113
|
-
var isequal = lo.isEqual(out, tc.out);
|
|
114
|
-
t.true(isequal);
|
|
115
|
-
});
|
|
116
|
-
t.end();
|
|
117
|
-
});
|
|
118
|
-
test('extract emojis', t => {
|
|
119
|
-
var tcs = [{
|
|
120
|
-
text: 'xin chao :smiling:',
|
|
121
|
-
out: [{
|
|
122
|
-
index: 9,
|
|
123
|
-
length: 9
|
|
124
|
-
}]
|
|
125
|
-
}, {
|
|
126
|
-
text: 'xin chao :smiling: :angry:',
|
|
127
|
-
out: [{
|
|
128
|
-
index: 9,
|
|
129
|
-
length: 9
|
|
130
|
-
}, {
|
|
131
|
-
index: 19,
|
|
132
|
-
length: 7
|
|
133
|
-
}]
|
|
134
|
-
}, {
|
|
135
|
-
text: 'xin chao ::smiling:',
|
|
136
|
-
out: [{
|
|
137
|
-
index: 10,
|
|
138
|
-
length: 9
|
|
139
|
-
}]
|
|
140
|
-
}, {
|
|
141
|
-
text: 'xin chao :smil e:',
|
|
142
|
-
out: []
|
|
143
|
-
}, {
|
|
144
|
-
text: 'xin chao :smil e:',
|
|
145
|
-
out: []
|
|
146
|
-
}, {
|
|
147
|
-
text: 'xin chao :smil:smiling:',
|
|
148
|
-
out: [{
|
|
149
|
-
index: 14,
|
|
150
|
-
length: 9
|
|
151
|
-
}]
|
|
152
|
-
}];
|
|
153
|
-
tcs.map(tc => {
|
|
154
|
-
var out = extractEmojis(tc.text);
|
|
155
|
-
var isequal = lo.isEqual(out, tc.out);
|
|
156
|
-
t.true(isequal);
|
|
157
|
-
});
|
|
158
|
-
t.end();
|
|
159
|
-
});
|
|
160
|
-
test('extract text', t => {
|
|
161
|
-
var tcs = [{
|
|
162
|
-
text: 'xin chao',
|
|
163
|
-
out: [{
|
|
164
|
-
type: 'text',
|
|
165
|
-
text: 'xin chao'
|
|
166
|
-
}]
|
|
167
|
-
}, {
|
|
168
|
-
text: 'xin chao thanhpk@live.com',
|
|
169
|
-
out: [{
|
|
170
|
-
type: 'text',
|
|
171
|
-
text: 'xin chao '
|
|
172
|
-
}, {
|
|
173
|
-
type: 'email',
|
|
174
|
-
text: 'thanhpk@live.com'
|
|
175
|
-
}]
|
|
176
|
-
}, {
|
|
177
|
-
text: 'xin chao thanhpk-0365045844@live.com, sdt: 03650451844',
|
|
178
|
-
out: [{
|
|
179
|
-
type: 'text',
|
|
180
|
-
text: 'xin chao '
|
|
181
|
-
}, {
|
|
182
|
-
type: 'email',
|
|
183
|
-
text: 'thanhpk-0365045844@live.com'
|
|
184
|
-
}, {
|
|
185
|
-
type: 'text',
|
|
186
|
-
text: ', sdt: '
|
|
187
|
-
}, {
|
|
188
|
-
type: 'phone',
|
|
189
|
-
text: '03650451844'
|
|
190
|
-
}]
|
|
191
|
-
}, {
|
|
192
|
-
text: 'xin chao https://subiz.com, sdt: 03650451844',
|
|
193
|
-
out: [{
|
|
194
|
-
type: 'text',
|
|
195
|
-
text: 'xin chao '
|
|
196
|
-
}, {
|
|
197
|
-
type: 'link',
|
|
198
|
-
text: 'https://subiz.com'
|
|
199
|
-
}, {
|
|
200
|
-
type: 'text',
|
|
201
|
-
text: ', sdt: '
|
|
202
|
-
}, {
|
|
203
|
-
type: 'phone',
|
|
204
|
-
text: '03650451844'
|
|
205
|
-
}]
|
|
206
|
-
}, {
|
|
207
|
-
text: 'https://google.com he :smiling:, :ll:',
|
|
208
|
-
out: [{
|
|
209
|
-
type: 'link',
|
|
210
|
-
text: 'https://google.com'
|
|
211
|
-
}, {
|
|
212
|
-
type: 'text',
|
|
213
|
-
text: ' he '
|
|
214
|
-
}, {
|
|
215
|
-
type: 'emoji',
|
|
216
|
-
text: ':smiling:'
|
|
217
|
-
}, {
|
|
218
|
-
type: 'text',
|
|
219
|
-
text: ', :ll:'
|
|
220
|
-
}]
|
|
221
|
-
}, {
|
|
222
|
-
text: 'google.com/?a=5&b=6 he :smiling:, :ll:',
|
|
223
|
-
out: [{
|
|
224
|
-
type: 'link',
|
|
225
|
-
text: 'google.com/?a=5&b=6'
|
|
226
|
-
}, {
|
|
227
|
-
type: 'text',
|
|
228
|
-
text: ' he '
|
|
229
|
-
}, {
|
|
230
|
-
type: 'emoji',
|
|
231
|
-
text: ':smiling:'
|
|
232
|
-
}, {
|
|
233
|
-
type: 'text',
|
|
234
|
-
text: ', :ll:'
|
|
235
|
-
}]
|
|
236
|
-
}];
|
|
237
|
-
tcs.map(tc => {
|
|
238
|
-
var out = extractText(tc.text);
|
|
239
|
-
var isequal = lo.isEqual(out, tc.out);
|
|
240
|
-
t.true(isequal);
|
|
241
|
-
});
|
|
242
|
-
t.end();
|
|
243
|
-
});
|
|
244
|
-
test('mask emoji', t => {
|
|
245
|
-
var tcs = [{
|
|
246
|
-
text: 'xin chao :smiling:',
|
|
247
|
-
out: [{
|
|
248
|
-
type: 'text',
|
|
249
|
-
value: 'xin chao '
|
|
250
|
-
}, {
|
|
251
|
-
type: 'emoji',
|
|
252
|
-
value: ':smiling:'
|
|
253
|
-
}]
|
|
254
|
-
}, {
|
|
255
|
-
text: 'xin chao :smiling: :angry:',
|
|
256
|
-
out: [{
|
|
257
|
-
type: 'text',
|
|
258
|
-
value: 'xin chao '
|
|
259
|
-
}, {
|
|
260
|
-
type: 'emoji',
|
|
261
|
-
value: ':smiling:'
|
|
262
|
-
}, {
|
|
263
|
-
type: 'text',
|
|
264
|
-
value: ' '
|
|
265
|
-
}, {
|
|
266
|
-
type: 'emoji',
|
|
267
|
-
value: ':angry:'
|
|
268
|
-
}]
|
|
269
|
-
}, {
|
|
270
|
-
text: 'xin chao ::smiling:',
|
|
271
|
-
out: [{
|
|
272
|
-
type: 'text',
|
|
273
|
-
value: 'xin chao :'
|
|
274
|
-
}, {
|
|
275
|
-
type: 'emoji',
|
|
276
|
-
value: ':smiling:'
|
|
277
|
-
}]
|
|
278
|
-
}, {
|
|
279
|
-
text: 'xin chao :smil e:',
|
|
280
|
-
out: [{
|
|
281
|
-
type: 'text',
|
|
282
|
-
value: 'xin chao :smil e:'
|
|
283
|
-
}]
|
|
284
|
-
}, {
|
|
285
|
-
text: 'xin chao :smil:smiling:',
|
|
286
|
-
out: [{
|
|
287
|
-
type: 'text',
|
|
288
|
-
value: 'xin chao :smil'
|
|
289
|
-
}, {
|
|
290
|
-
type: 'emoji',
|
|
291
|
-
value: ':smiling:'
|
|
292
|
-
}]
|
|
293
|
-
}];
|
|
294
|
-
tcs.forEach(tc => {
|
|
295
|
-
var out = maskEmojis(tc.text);
|
|
296
|
-
t.equal(JSON.stringify(out), JSON.stringify(tc.out));
|
|
297
|
-
});
|
|
298
|
-
t.end();
|
|
299
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function extractLinks(text) {
|
|
4
|
-
text = text || '';
|
|
5
|
-
var reg = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z()]{2,6}\b([-a-zA-Z0-9@:%_\+.,~#?&//=]*)/gim;
|
|
6
|
-
var out = [];
|
|
7
|
-
var match;
|
|
8
|
-
while (match = reg.exec(text)) {
|
|
9
|
-
out.push({
|
|
10
|
-
index: match.index,
|
|
11
|
-
length: reg.lastIndex - match.index
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return out;
|
|
15
|
-
}
|
|
16
|
-
function main() {
|
|
17
|
-
var tcs = [{
|
|
18
|
-
text: '',
|
|
19
|
-
out: []
|
|
20
|
-
}, {
|
|
21
|
-
text: 'vao https://subiz.com a',
|
|
22
|
-
out: [{
|
|
23
|
-
index: 4,
|
|
24
|
-
length: 17
|
|
25
|
-
}]
|
|
26
|
-
}, {
|
|
27
|
-
text: 'day htt://a.com',
|
|
28
|
-
out: [{
|
|
29
|
-
index: 10,
|
|
30
|
-
length: 5
|
|
31
|
-
}]
|
|
32
|
-
}, {
|
|
33
|
-
text: 'chao http://http.ne/22',
|
|
34
|
-
out: [{
|
|
35
|
-
index: 5,
|
|
36
|
-
length: 17
|
|
37
|
-
}]
|
|
38
|
-
}, {
|
|
39
|
-
text: 'chao google.com',
|
|
40
|
-
out: [{
|
|
41
|
-
index: 5,
|
|
42
|
-
length: 10
|
|
43
|
-
}]
|
|
44
|
-
}, {
|
|
45
|
-
text: 'Bạn có thể xem hình ảnh của Mazda2 1.5L AT qua liên kết dưới đây:',
|
|
46
|
-
out: []
|
|
47
|
-
}, {
|
|
48
|
-
text: 'Giá: 386.000.000 VNĐ',
|
|
49
|
-
out: []
|
|
50
|
-
}];
|
|
51
|
-
for (var i = 0; i < tcs.length; i++) {
|
|
52
|
-
var tc = tcs[i];
|
|
53
|
-
var out = extractLinks(tc.text);
|
|
54
|
-
if (JSON.stringify(out) !== JSON.stringify(tc.out)) {
|
|
55
|
-
console.error('FAIL', tc.text, '\n', JSON.stringify(out, null, 4), '\n', JSON.stringify(tc.out, null, 4));
|
|
56
|
-
} else {
|
|
57
|
-
console.info('PASS', tc.text);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
main();
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var test = require('tape');
|
|
4
|
-
var Gate = require('./gate.js');
|
|
5
|
-
test('gate', async t => {
|
|
6
|
-
var gate = new Gate();
|
|
7
|
-
var flip = 0;
|
|
8
|
-
setTimeout(function () {
|
|
9
|
-
flip = 1;
|
|
10
|
-
gate.open();
|
|
11
|
-
}, 1000);
|
|
12
|
-
await gate.entry();
|
|
13
|
-
t.equal(flip, 1);
|
|
14
|
-
await gate.entry();
|
|
15
|
-
await gate.entry();
|
|
16
|
-
t.equal(flip, 1);
|
|
17
|
-
t.end();
|
|
18
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var test = require('tape');
|
|
4
|
-
var Pubsub = require('./pubsub.js');
|
|
5
|
-
test('pubsub simple', t => {
|
|
6
|
-
var ps = new Pubsub();
|
|
7
|
-
var msg = {
|
|
8
|
-
name: 'thanh'
|
|
9
|
-
};
|
|
10
|
-
var count = 0;
|
|
11
|
-
ps.on('hi', payload => {
|
|
12
|
-
t.equal(payload, msg);
|
|
13
|
-
count++;
|
|
14
|
-
});
|
|
15
|
-
ps.on('hi', payload => {
|
|
16
|
-
t.equal(payload, msg);
|
|
17
|
-
count++;
|
|
18
|
-
});
|
|
19
|
-
var sub = ps.on('hi', payload => {
|
|
20
|
-
t.equal(payload, msg);
|
|
21
|
-
count++;
|
|
22
|
-
});
|
|
23
|
-
ps.publish('hi', msg);
|
|
24
|
-
t.equal(count, 3);
|
|
25
|
-
ps.un(sub);
|
|
26
|
-
ps.publish('hi', msg);
|
|
27
|
-
ps.publish('hi', msg);
|
|
28
|
-
t.equal(count, 7);
|
|
29
|
-
ps.only('hi', payload => {
|
|
30
|
-
count--;
|
|
31
|
-
});
|
|
32
|
-
ps.publish('hi', 0);
|
|
33
|
-
t.equal(count, 6);
|
|
34
|
-
t.end();
|
|
35
|
-
});
|
package/dist/1a08405c848.127.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[127],{6127(t,e,n){n.r(e),n.d(e,{default:()=>i});var a=n(5922),r=n(2840),s=n(172);class i extends r.Mw{render(){let t=a.A.get(this.props.ev,"by.type");if("user"===t)return null;this.props.store.matchAccount();var e=a.A.get(this.props.ev,"data.message.attachments",[]);let r=a.A.filter(e,t=>"order"===t.type&&t.order).map(t=>t.order);return 0===r.length?null:a.A.map(r,(e,r)=>{!function(t){let e=0,n=0,a=0;op.map(t.items,t=>{if(!t.product)return 0;let r=op.get(t,"product.price",0)*(t.quantity||0);a+=r,"percentage"==t.discount_type?t.discount_percentage>0&&(n+=r*t.discount_percentage/1e4,r*=1-(t.discount_percentage||0)/1e4):"amount"==t.discount_type&&t.discount_amount>0&&(n+=t.discount_amount,r-=t.discount_amount||0,r<=0&&(r=0)),t.total=r,e+=r});let r={};op.map(t.items,(t,e)=>{if(!t.product)return;let n=t.product.tax;if(!n)return;if(!n.id)return;let a=t.total*n.percentage/1e4;t.total_tax=a,r[e]={tax:n,taxprice:a}});let s=0;op.map(r,t=>s+=t.taxprice);let i=0;"percentage"==t.discount_type&&t.discount_percentage>0?i=(e+s)*t.discount_percentage/1e4:"amount"==t.discount_type&&(i=t.discount_amount||0);let o=op.get(t,"shipping.nominal_fee",0);if(o>0&&op.get(t,"shipping.tax.id")){let e=t.shipping.tax,n=o*(e.percentage/1e4);r.ship={tax:e,taxprice:n},t.shipping.total_tax=n}s=0,op.map(r,t=>s+=t.taxprice);let l=e+s-i+o;l+=t.adjustment||0,l<0&&(l=0),t.subtotal=e,t._computed_discount=i,t._taxM=r,t.total=l,t.total_tax=s,t._discount_before_tax=n,t._order_value=a}(e);let i=null;e.note&&(i=(0,s.h)("div",null,(0,s.h)("div",{class:"order_attachment__label"},this.props.t("note")),(0,s.h)("div",{class:"order_attachment__note",title:e.note},e.note)));let l=null;a.A.size(e.items)>0&&(l=(0,s.h)("div",null,(0,s.h)("div",{class:"order_attachment__label"},this.props.t("product")),a.A.map(e.items,t=>{let e=t.product||{};return(0,s.h)("div",{class:"order_attachment__product"},(0,s.h)("img",{class:"order_attachment__product_img",alt:""+a.A.get(e,"id"),src:a.A.get(e,"image",n(2876))}),(0,s.h)("div",{style:"overflow: hidden !important;"},(0,s.h)("div",{class:"order_attachment__product_name",title:this.props.t.i18n(e.i18n_name)||e.name},this.props.t.i18n(e.i18n_name)||e.name),(0,s.h)("div",{class:"order_attachment__product_desc"},function(t,e=" - "){let n=op.get(t,"options",[]),a=op.get(t,"props",[]),r=op.filter(n,t=>op.size(t.values)>1),s=[];return op.each(r,t=>{let e=op.find(a,e=>e.key===t.key)||{};e.value&&s.push(e.value)}),s.join(e)}(e," / ")),(0,s.h)("div",{class:"order_attachment__product_desc"},this.props.t("qty")," ",t.quantity," · ",a.A.formatCurrency(e.price))))})));let c=(0,s.h)("div",{class:"order_attachment__footer"},(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",null,this.props.t("total"))," ",(0,s.h)("div",null,(0,s.h)("b",{class:"order_attachment__total"},a.A.formatCurrency(e.total))))),d=a.A.find(a.A.get(e,"user.attributes",[]),t=>"phones"===t.key)||{key:"phones",text:""},_=a.A.get(e,"shipping.address.phone","").trim();_=_||a.A.trim(d.text),_&&(_=this.props.t("phn")+": "+_);let p=null;(o(e)||_)&&(p=(0,s.h)("div",null,(0,s.h)("div",{class:"order_attachment__label"},this.props.t("ship_to")),(0,s.h)("div",null,o(e)),(0,s.h)("div",{class:"order_attachment__text_truncate"},_)));let u=null;e._discount_before_tax&&(u=(0,s.h)("div",{class:"order_attachment__footer"},(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("subtotal_before_tax"))," ",(0,s.h)("div",null,a.A.formatCurrency(e._order_value))),(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_before_tax"))," ",(0,s.h)("div",null,"-",a.A.formatCurrency(e._discount_before_tax)))));let h=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("subtotal"))," ",(0,s.h)("div",{style:""},a.A.formatCurrency(e.subtotal))),m=null;if(e.total_tax){let t="";if(1===a.A.size(e._taxM)){let n=a.A.get(e._taxM,"0.tax",{});n.name&&n.percentage&&(t=`(${n.name} ${Math.round(n.percentage||0)/100}%)`)}m=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("tax")," ",t),(0,s.h)("div",{style:""},a.A.formatCurrency(e.total_tax)))}let g=null;"percentage"===e.discount_type&&e.discount_percentage&&(g=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_after_tax")," (",Math.round(e.discount_percentage/100),"%)")," ",(0,s.h)("div",{style:""},"-",a.A.formatCurrency(e._computed_discount)))),"amount"===e.discount_type&&e.discount_amount&&(g=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("discount_after_tax"))," ",(0,s.h)("div",{class:"no-shrink"},"-",a.A.formatCurrency(e._computed_discount))));let f=null;a.A.get(e,"shipping.nominal_fee")&&(f=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},this.props.t("shipping_fee"))," ",(0,s.h)("div",{style:""},a.A.formatCurrency(a.A.get(e,"shipping.nominal_fee",0)))));let v=null;return e.adjustment&&(v=(0,s.h)("div",{class:"d-flex align-items-center justify-content-between"},(0,s.h)("div",{class:"order_attachment__label no_margin"},e.adjustment_description)," ",(0,s.h)("div",{class:"no-shrink"},a.A.formatCurrency(e.adjustment)))),h=(0,s.h)("div",{class:"order_attachment__footer"},h,m,f,g,v),f||v||g||m||(h=null),(0,s.h)("div",{class:`order_attachment order_attachment__${t}`},(0,s.h)("div",{class:"order_attachment__header"},this.props.t("order"),(0,s.h)("span",{class:"order_attachment__text_muted order_attachment__text_sm"},function(t={}){return t.number||t.id||""}(e))),l,p,i,u,h,c)})}}function o(t,e){let n=op.get(t,"shipping.address",{}),a=[n.address,n.ward,n.district,n.province].filter(t=>t).join(", ").trim();return e&&(a=(a||"").replace(/Hà Nội/gi,"HN").replace(/Hồ Chí Minh/gi,"HCM").replace(/Thành Phố/gi,"TP")),a}}}]);
|