@subiz/widget-v4 4.1.82 → 4.1.84

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 (109) hide show
  1. package/compiled_src/bot.js +1 -1
  2. package/compiled_src/call/call.js +2 -2
  3. package/compiled_src/chatbox/AgentsAvatar.js +1 -1
  4. package/compiled_src/chatbox/AudioAttachments.js +1 -1
  5. package/compiled_src/chatbox/ButtonAttachments.js +1 -1
  6. package/compiled_src/chatbox/Buttons.js +1 -1
  7. package/compiled_src/chatbox/ChatButton.js +8 -30
  8. package/compiled_src/chatbox/DropdownSelect.js +2 -2
  9. package/compiled_src/chatbox/Emoji.js +1 -1
  10. package/compiled_src/chatbox/Event.js +1 -1
  11. package/compiled_src/chatbox/Events.js +1 -1
  12. package/compiled_src/chatbox/FileAttachments.js +1 -1
  13. package/compiled_src/chatbox/FormAttachment.js +1 -1
  14. package/compiled_src/chatbox/FormAttachments.js +1 -1
  15. package/compiled_src/chatbox/FormSubmitAttachments.js +1 -1
  16. package/compiled_src/chatbox/GenericTemplateAttachments.js +1 -1
  17. package/compiled_src/chatbox/Header.js +1 -1
  18. package/compiled_src/chatbox/ImageAttachments.js +2 -2
  19. package/compiled_src/chatbox/InfoMessage.js +1 -1
  20. package/compiled_src/chatbox/ListField.js +1 -1
  21. package/compiled_src/chatbox/MessageInput.js +2 -2
  22. package/compiled_src/chatbox/Order.js +2 -2
  23. package/compiled_src/chatbox/OrderAttachments.js +1 -1
  24. package/compiled_src/chatbox/ProductAttachments.js +1 -1
  25. package/compiled_src/chatbox/QuickReplies.js +1 -1
  26. package/compiled_src/chatbox/Rating.js +2 -2
  27. package/compiled_src/chatbox/TextMessage.js +18 -97
  28. package/compiled_src/chatbox/Typing.js +1 -1
  29. package/compiled_src/chatbox/VideoAttachments.js +1 -1
  30. package/compiled_src/chatbox/Widget.js +2 -2
  31. package/compiled_src/chatbox/block.js +152 -0
  32. package/compiled_src/chatbox/main.js +1 -1
  33. package/compiled_src/chatbox/releaseAnimation.js +1 -1
  34. package/compiled_src/chatbox/time.js +1 -1
  35. package/compiled_src/common.js +1 -1
  36. package/compiled_src/contact/contact.js +2 -2
  37. package/compiled_src/lib.js +2 -2
  38. package/compiled_src/notif/notif.js +37 -37
  39. package/compiled_src/order/address_picker.js +2 -2
  40. package/compiled_src/order/icon.js +1 -1
  41. package/compiled_src/order/index.js +1 -1
  42. package/compiled_src/order/order.js +2 -2
  43. package/compiled_src/plugin.js +1 -1
  44. package/compiled_src/popup/countdown.js +2 -2
  45. package/compiled_src/popup/popup.js +2 -2
  46. package/compiled_src/popup/tick.core.commonjs.js +1 -1
  47. package/compiled_src/store/api.js +2 -2
  48. package/compiled_src/store/api_fake.js +2 -2
  49. package/compiled_src/store/store.js +2 -2
  50. package/compiled_src/util/common.js +174 -1
  51. package/compiled_src/util/index.js +0 -2
  52. package/dist/127.js +273 -0
  53. package/dist/132.js +2569 -6434
  54. package/dist/185.js +1885 -0
  55. package/dist/19077b40b00.127.js +1 -0
  56. package/dist/19077b40b00.132.js +1 -0
  57. package/dist/19077b40b00.185.js +1 -0
  58. package/dist/19077b40b00.27.js +1 -0
  59. package/dist/19077b40b00.278.js +1 -0
  60. package/dist/19077b40b00.459.js +1 -0
  61. package/dist/19077b40b00.490.js +1 -0
  62. package/dist/19077b40b00.74.js +1 -0
  63. package/dist/19077b40b00.997.js +1 -0
  64. package/dist/19077b40b00.app.js +1 -0
  65. package/dist/{18a02a9c54e.index.html → 19077b40b00.index.html} +4 -4
  66. package/dist/{18a02a9c54e.library.html → 19077b40b00.library.html} +4 -4
  67. package/dist/19077b40b00.library.js +1 -0
  68. package/dist/{18a02a9c54e.preview.html → 19077b40b00.preview.html} +1 -1
  69. package/dist/19077b40b00.preview.js +1 -0
  70. package/dist/19077b40b00.screenshoot.js +1 -0
  71. package/dist/19077b40b00.webview.js +1 -0
  72. package/dist/{782.js → 27.js} +7 -7
  73. package/dist/278.js +406 -0
  74. package/dist/{362.js → 459.js} +7 -7
  75. package/dist/{605.js → 490.js} +60 -61
  76. package/dist/{335.js → 74.js} +35 -35
  77. package/dist/{678.js → 997.js} +6 -6
  78. package/dist/HASH +1 -1
  79. package/dist/malicious-app.js +6 -4
  80. package/dist/screenshoot.html +1 -1
  81. package/dist/screenshoot.js +5690 -1605
  82. package/package.json +1 -1
  83. package/src/chatbox/ChatButton.js +5 -36
  84. package/src/chatbox/Emoji.js +1 -1
  85. package/src/chatbox/TextMessage.js +18 -96
  86. package/src/chatbox/block.js +161 -0
  87. package/src/common.js +2 -10
  88. package/src/notif/notif.js +30 -43
  89. package/src/util/common.js +224 -0
  90. package/src/util/index.js +0 -3
  91. package/compiled_src/util/extractor.js +0 -136
  92. package/dist/178.js +0 -406
  93. package/dist/18a02a9c54e.132.js +0 -1
  94. package/dist/18a02a9c54e.178.js +0 -1
  95. package/dist/18a02a9c54e.213.js +0 -1
  96. package/dist/18a02a9c54e.335.js +0 -1
  97. package/dist/18a02a9c54e.362.js +0 -1
  98. package/dist/18a02a9c54e.441.js +0 -1
  99. package/dist/18a02a9c54e.605.js +0 -1
  100. package/dist/18a02a9c54e.678.js +0 -1
  101. package/dist/18a02a9c54e.782.js +0 -1
  102. package/dist/18a02a9c54e.app.js +0 -1
  103. package/dist/18a02a9c54e.library.js +0 -1
  104. package/dist/18a02a9c54e.preview.js +0 -1
  105. package/dist/18a02a9c54e.screenshoot.js +0 -1
  106. package/dist/18a02a9c54e.webview.js +0 -1
  107. package/dist/213.js +0 -2780
  108. package/dist/441.js +0 -2855
  109. package/src/util/extractor.js +0 -166
@@ -1,5 +1,133 @@
1
1
  var op = require('./op.js')
2
2
 
3
+
4
+ export function extractEmojis (text) {
5
+ var out = []
6
+ for (var i = 0; i < text.length; i++) {
7
+ for (var e = 0; e < emojis.length; e++) {
8
+ if (text.indexOf(emojis[e], i) !== i) continue
9
+ out.push({ index: i, length: emojis[e].length })
10
+ i += emojis[e].length - 1
11
+ break
12
+ }
13
+ }
14
+
15
+ return out
16
+ }
17
+
18
+ export function extractLinks (text) {
19
+ text = text || ''
20
+ var reg = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.,~#?&//=]*)/gim
21
+ var out = []
22
+ var match
23
+ while ((match = reg.exec(text))) {
24
+ out.push({ index: match.index, length: reg.lastIndex - match.index })
25
+ }
26
+
27
+ return out
28
+ }
29
+
30
+ export function extractEmails (text) {
31
+ text = text || ''
32
+ var reg = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gim
33
+
34
+ var out = []
35
+ var match
36
+ while ((match = reg.exec(text))) {
37
+ out.push({ index: match.index, length: reg.lastIndex - match.index })
38
+ }
39
+
40
+ return out
41
+ }
42
+
43
+ export function extractPhones (msg) {
44
+ msg = msg || ''
45
+ var fgmsg = ''
46
+ // fine-grained msg
47
+ // remove '-' in number-number
48
+ // remove ' ' in number number
49
+ // remove '.' in number.number
50
+
51
+ var realchmap = {}
52
+ for (var i = 0; i < msg.length; i++) {
53
+ var ch = msg.charAt(i)
54
+
55
+ if (ch !== '.' && ch !== '-' && ch !== ' ') {
56
+ fgmsg += ch
57
+ realchmap[fgmsg.length - 1] = i
58
+ continue
59
+ }
60
+
61
+ var prevCh = i > 0 ? msg.charAt(i - 1) : '-'
62
+ var nextCh = i < msg.length - 1 ? msg.charAt(i + 1) : '-'
63
+
64
+ if ('0123456789'.indexOf(prevCh) !== -1 && '0123456789'.indexOf(nextCh) !== -1) continue
65
+ fgmsg += ch
66
+ realchmap[fgmsg.length - 1] = i
67
+ }
68
+
69
+ var reg = /([0-9]{8,13})/gim
70
+
71
+ var out = []
72
+ var match
73
+ while ((match = reg.exec(fgmsg))) {
74
+ out.push({ index: realchmap[match.index], length: realchmap[reg.lastIndex - 1] - realchmap[match.index] + 1 })
75
+ }
76
+
77
+ return out
78
+ }
79
+
80
+ export function extract (text, extractor, type) {
81
+ if (!text) return []
82
+ var out = []
83
+ var lastindex = 0
84
+ var tags = extractor(text)
85
+ if (size(tags) === 0) return [{ type: 'text', text }]
86
+ each(tags, tag => {
87
+ out.push({ type: 'text', text: text.substr(lastindex, tag.index - lastindex) })
88
+ out.push({ type, text: text.substr(tag.index, tag.length) })
89
+ lastindex = tag.index + tag.length
90
+ })
91
+ var lastTag = last(tags)
92
+ out.push({
93
+ type: 'text',
94
+ text: text.substr(lastTag.index + lastTag.length, text.length - lastTag.index + lastTag.length),
95
+ })
96
+
97
+ return filter(out, o => o.text !== '')
98
+ }
99
+
100
+ export function pipeExtracts (text, extractors) {
101
+ var out = []
102
+ if (size(extractors) === 0) return [{ type: 'text', text }]
103
+ var ext = extractors.shift()
104
+
105
+ var tags = extract(text, ext, ext.type)
106
+ each(tags, t => {
107
+ if (t.type !== 'text') return out.push(t)
108
+ out = out.concat(pipeExtracts(t.text, extractors.slice()))
109
+ })
110
+
111
+ return out
112
+ }
113
+
114
+ export function extractText (text) {
115
+ var link = extractLinks
116
+ link.type = 'link'
117
+
118
+ var email = extractEmails
119
+ email.type = 'email'
120
+
121
+ var phone = extractPhones
122
+ phone.type = 'phone'
123
+
124
+ var emoji = extractEmojis
125
+ emoji.type = 'emoji'
126
+
127
+ return pipeExtracts(text, [email, link, phone, emoji])
128
+ }
129
+
130
+
3
131
  export function parseJSON(str) {
4
132
  try {
5
133
  return parse(str)
@@ -1143,3 +1271,99 @@ const ALL_CURRENCIES = [
1143
1271
 
1144
1272
  //}
1145
1273
  //}
1274
+
1275
+ export function blockToText(block) {
1276
+ return _blockToText(block).trim()
1277
+ }
1278
+
1279
+ function _blockToText(block) {
1280
+ if (!block || !block.type) return ''
1281
+ let out = ''
1282
+ if (block.type == 'bullet_list' || block.type == 'ordered_list') {
1283
+ map(block.content, (item) => {
1284
+ preifx = '\n* '
1285
+ if (block.type == 'ordered_list') {
1286
+ prefix = i + '\n. '
1287
+ }
1288
+ out += prefix + blockToText(item).trim()
1289
+ })
1290
+ return out
1291
+ }
1292
+
1293
+ if (block.type == 'heading' || block.type == 'paragraph') {
1294
+ out += '\n'
1295
+ }
1296
+
1297
+ if (
1298
+ block.type == '' ||
1299
+ block.type == 'text' ||
1300
+ block.type == 'link' ||
1301
+ block.type == 'mention-agent' ||
1302
+ block.type == 'dynamic-field'
1303
+ ) {
1304
+ return out + block.text
1305
+ }
1306
+
1307
+ if (block.type == 'horizontal_rule') return out + '\n---\n'
1308
+ if (block.type == 'emoji') {
1309
+ let code
1310
+ if (size(block.attrs) > 0) code = block.attrs['code']
1311
+ if (code == '') code = block.text
1312
+
1313
+ if (code != '') {
1314
+ let emoji = find(LEXICAL_EMOJI_LIST, (emoji) => emoji.code === code)
1315
+ out + op.get(emoji, 'text', code)
1316
+ }
1317
+ return out
1318
+ }
1319
+
1320
+ map(block.content, (block) => {
1321
+ out += blockToText(block)
1322
+ })
1323
+ return out
1324
+ }
1325
+
1326
+
1327
+ let emojis = [
1328
+ 'like',
1329
+ 'unlike',
1330
+ 'wink',
1331
+ 'tongue-out',
1332
+ 'tired',
1333
+ 'surprised',
1334
+ 'smiling',
1335
+ 'sleepy',
1336
+ 'sad',
1337
+ 'neutral',
1338
+ 'heart-eyes',
1339
+ 'grinning',
1340
+ 'crying',
1341
+ 'confused',
1342
+ 'angry',
1343
+
1344
+ 'cry',
1345
+ 'heart_eyes',
1346
+ 'neutral_face',
1347
+ 'emoji--disappointed',
1348
+ 'smile',
1349
+ 'open_mouth',
1350
+ 'tired_face',
1351
+ 'stuck_out_tongue',
1352
+ 'moyai',
1353
+ 'thumbsdown',
1354
+ 'dislike',
1355
+ 'thumbsup',
1356
+ 'ok_hand',
1357
+ 'octopus',
1358
+ 'pig2',
1359
+ 'wave',
1360
+ 'mouse',
1361
+ 'mouse2',
1362
+ 'rat',
1363
+ ]
1364
+ emojis = map(emojis, e => ':' + e + ':')
1365
+
1366
+ function absLink(url) {
1367
+ if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('//')) return 'http://' + url
1368
+ return url
1369
+ }
package/src/util/index.js CHANGED
@@ -26,9 +26,6 @@ sb.set = op.set
26
26
 
27
27
  sb.Pubsub = require('./pubsub.js').default
28
28
 
29
- import * as extractor from './extractor.js'
30
- sb = Object.assign(sb, extractor)
31
-
32
29
  import * as campaign from './campaign.js'
33
30
  sb = Object.assign(sb, campaign)
34
31
 
@@ -1,136 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extract = extract;
7
- exports.extractEmails = extractEmails;
8
- exports.extractEmojis = extractEmojis;
9
- exports.extractLinks = extractLinks;
10
- exports.extractPhones = extractPhones;
11
- exports.extractText = extractText;
12
- exports.pipeExtracts = pipeExtracts;
13
- var common = require('./common.js');
14
- let emojis = ['like', 'unlike', 'wink', 'tongue-out', 'tired', 'surprised', 'smiling', 'sleepy', 'sad', 'neutral', 'heart-eyes', 'grinning', 'crying', 'confused', 'angry', 'cry', 'heart_eyes', 'neutral_face', 'emoji--disappointed', 'smile', 'open_mouth', 'tired_face', 'stuck_out_tongue', 'moyai', 'thumbsdown', 'dislike', 'thumbsup', 'ok_hand', 'octopus', 'pig2', 'wave', 'mouse', 'mouse2', 'rat'];
15
- emojis = common.map(emojis, e => ':' + e + ':');
16
- function extractEmojis(text) {
17
- var out = [];
18
- for (var i = 0; i < text.length; i++) {
19
- for (var e = 0; e < emojis.length; e++) {
20
- if (text.indexOf(emojis[e], i) !== i) continue;
21
- out.push({
22
- index: i,
23
- length: emojis[e].length
24
- });
25
- i += emojis[e].length - 1;
26
- break;
27
- }
28
- }
29
- return out;
30
- }
31
- function extractLinks(text) {
32
- text = text || '';
33
- var reg = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.,~#?&//=]*)/gim;
34
- var out = [];
35
- var match;
36
- while (match = reg.exec(text)) {
37
- out.push({
38
- index: match.index,
39
- length: reg.lastIndex - match.index
40
- });
41
- }
42
- return out;
43
- }
44
- function extractEmails(text) {
45
- text = text || '';
46
- var reg = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gim;
47
- var out = [];
48
- var match;
49
- while (match = reg.exec(text)) {
50
- out.push({
51
- index: match.index,
52
- length: reg.lastIndex - match.index
53
- });
54
- }
55
- return out;
56
- }
57
- function extractPhones(msg) {
58
- msg = msg || '';
59
- var fgmsg = '';
60
- var realchmap = {};
61
- for (var i = 0; i < msg.length; i++) {
62
- var ch = msg.charAt(i);
63
- if (ch !== '.' && ch !== '-' && ch !== ' ') {
64
- fgmsg += ch;
65
- realchmap[fgmsg.length - 1] = i;
66
- continue;
67
- }
68
- var prevCh = i > 0 ? msg.charAt(i - 1) : '-';
69
- var nextCh = i < msg.length - 1 ? msg.charAt(i + 1) : '-';
70
- if ('0123456789'.indexOf(prevCh) !== -1 && '0123456789'.indexOf(nextCh) !== -1) continue;
71
- fgmsg += ch;
72
- realchmap[fgmsg.length - 1] = i;
73
- }
74
- var reg = /([0-9]{8,13})/gim;
75
- var out = [];
76
- var match;
77
- while (match = reg.exec(fgmsg)) {
78
- out.push({
79
- index: realchmap[match.index],
80
- length: realchmap[reg.lastIndex - 1] - realchmap[match.index] + 1
81
- });
82
- }
83
- return out;
84
- }
85
- function extract(text, extractor, type) {
86
- if (!text) return [];
87
- var out = [];
88
- var lastindex = 0;
89
- var tags = extractor(text);
90
- if (common.size(tags) === 0) return [{
91
- type: 'text',
92
- text
93
- }];
94
- common.each(tags, tag => {
95
- out.push({
96
- type: 'text',
97
- text: text.substr(lastindex, tag.index - lastindex)
98
- });
99
- out.push({
100
- type,
101
- text: text.substr(tag.index, tag.length)
102
- });
103
- lastindex = tag.index + tag.length;
104
- });
105
- var lastTag = common.last(tags);
106
- out.push({
107
- type: 'text',
108
- text: text.substr(lastTag.index + lastTag.length, text.length - lastTag.index + lastTag.length)
109
- });
110
- return common.filter(out, o => o.text !== '');
111
- }
112
- function pipeExtracts(text, extractors) {
113
- var out = [];
114
- if (common.size(extractors) === 0) return [{
115
- type: 'text',
116
- text
117
- }];
118
- var ext = extractors.shift();
119
- var tags = extract(text, ext, ext.type);
120
- common.each(tags, t => {
121
- if (t.type !== 'text') return out.push(t);
122
- out = out.concat(pipeExtracts(t.text, extractors.slice()));
123
- });
124
- return out;
125
- }
126
- function extractText(text) {
127
- var link = extractLinks;
128
- link.type = 'link';
129
- var email = extractEmails;
130
- email.type = 'email';
131
- var phone = extractPhones;
132
- phone.type = 'phone';
133
- var emoji = extractEmojis;
134
- emoji.type = 'emoji';
135
- return pipeExtracts(text, [email, link, phone, emoji]);
136
- }