@subiz/widget-v4 4.1.14 → 4.1.15

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 (99) hide show
  1. package/compiled_src/popup/popup.js +6 -1
  2. package/compiled_src/store/store.js +36 -62
  3. package/compiled_src/util/common.js +2 -2
  4. package/inject.js +254 -98
  5. package/package.json +4 -4
  6. package/src/popup/popup.js +8 -1
  7. package/src/store/store.js +32 -61
  8. package/src/util/common.js +2 -2
  9. package/dist/132.js +0 -6612
  10. package/dist/178.js +0 -406
  11. package/dist/1857b1f5c4f.132.js +0 -1
  12. package/dist/1857b1f5c4f.178.js +0 -1
  13. package/dist/1857b1f5c4f.213.js +0 -1
  14. package/dist/1857b1f5c4f.335.js +0 -1
  15. package/dist/1857b1f5c4f.362.js +0 -1
  16. package/dist/1857b1f5c4f.441.js +0 -1
  17. package/dist/1857b1f5c4f.605.js +0 -1
  18. package/dist/1857b1f5c4f.678.js +0 -1
  19. package/dist/1857b1f5c4f.782.js +0 -1
  20. package/dist/1857b1f5c4f.app.js +0 -1
  21. package/dist/1857b1f5c4f.index.html +0 -26
  22. package/dist/1857b1f5c4f.library.html +0 -26
  23. package/dist/1857b1f5c4f.library.js +0 -1
  24. package/dist/1857b1f5c4f.preview.html +0 -759
  25. package/dist/1857b1f5c4f.preview.js +0 -1
  26. package/dist/1857b1f5c4f.screenshoot.js +0 -1
  27. package/dist/1857b1f5c4f.webview.js +0 -1
  28. package/dist/213.js +0 -2774
  29. package/dist/335.js +0 -372
  30. package/dist/362.js +0 -107
  31. package/dist/441.js +0 -2855
  32. package/dist/605.js +0 -305
  33. package/dist/678.js +0 -107
  34. package/dist/782.js +0 -107
  35. package/dist/HASH +0 -1
  36. package/dist/assets/img/Facebook.64607ec.png +0 -0
  37. package/dist/assets/img/Zalo.6845707.png +0 -0
  38. package/dist/assets/img/award1a.1a58e10.png +0 -0
  39. package/dist/assets/img/award3a.3b74423.png +0 -0
  40. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  41. package/dist/assets/img/award5.39eb7ae.png +0 -0
  42. package/dist/assets/img/bubble_default.7d5e4ab.svg +0 -20
  43. package/dist/assets/img/caret.998eb8f.svg +0 -1
  44. package/dist/assets/img/convos_empty.2353007.svg +0 -72
  45. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  46. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  47. package/dist/assets/img/done_gray.d7e8203.svg +0 -4
  48. package/dist/assets/img/done_green.b817fd4.svg +0 -4
  49. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  50. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  51. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  52. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  53. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  54. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  55. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  56. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  57. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  58. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  59. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  60. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  61. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  62. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  63. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  67. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  70. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  71. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  72. package/dist/assets/img/empty.29bed2d.svg +0 -23
  73. package/dist/assets/img/empty_1.0b98af0.svg +0 -11
  74. package/dist/assets/img/examplte_logo.f86535f.svg +0 -1
  75. package/dist/assets/img/external-link.90577cc.svg +0 -1
  76. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  77. package/dist/assets/img/ghn.070f8e3.svg +0 -17
  78. package/dist/assets/img/ghtk.326eac1.svg +0 -18
  79. package/dist/assets/img/image_default.be0698b.png +0 -0
  80. package/dist/assets/img/info.ebce7ea.svg +0 -1
  81. package/dist/assets/img/loader.37000a7.svg +0 -1
  82. package/dist/assets/img/loading_static.8f403ae.svg +0 -10
  83. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  84. package/dist/assets/img/main-service2.9b99549.png +0 -0
  85. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  86. package/dist/assets/img/package.8d37d0f.svg +0 -5
  87. package/dist/assets/img/package_fade.763c001.svg +0 -1
  88. package/dist/assets/img/rating--average.1ea492c.svg +0 -12
  89. package/dist/assets/img/rating--great.e3d712e.svg +0 -16
  90. package/dist/assets/img/rating--poor.2938a25.svg +0 -12
  91. package/dist/assets/img/search.f9705ff.svg +0 -1
  92. package/dist/assets/img/send.6db52a9.svg +0 -3
  93. package/dist/assets/img/shop.f7dc7d8.svg +0 -1
  94. package/dist/assets/img/shop_faded.df7845a.svg +0 -1
  95. package/dist/assets/img/subiz-mono.877e9f5.svg +0 -3
  96. package/dist/assets/img/x.26fdfa3.svg +0 -5
  97. package/dist/malicious-app.js +0 -13
  98. package/dist/screenshoot.html +0 -7
  99. package/dist/screenshoot.js +0 -5607
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.14",
3
+ "version": "4.1.15",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -14,7 +14,7 @@
14
14
  "@subiz/storage": "0.0.8",
15
15
  "@subiz/wsclient": "^3.1.9",
16
16
  "cookie_js": "1.4.2",
17
- "core-js": "^3.27.1",
17
+ "core-js": "^3.27.0",
18
18
  "css-loader": "5.2.7",
19
19
  "file-loader": "^6.2.0",
20
20
  "less": "^4.1.3",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@babel/cli": "^7.20.7",
27
- "@babel/core": "^7.20.12",
27
+ "@babel/core": "^7.20.7",
28
28
  "@babel/plugin-proposal-class-properties": "^7.18.6",
29
29
  "@babel/plugin-transform-react-jsx": "^7.20.7",
30
30
  "@babel/preset-env": "^7.20.2",
31
- "babel-loader": "^9.1.2",
31
+ "babel-loader": "^9.1.0",
32
32
  "babel-plugin-syntax-jsx": "^6.18.0",
33
33
  "html-webpack-plugin": "^5.5.0",
34
34
  "prettier": "^2.8.1",
@@ -285,6 +285,10 @@ export default class Popup extends Com {
285
285
  primarystyle.font_weight = primarystyle.font_weight || '500'
286
286
  primarystyle.font_size = primarystyle.font_size || popup.font_size || '14px'
287
287
  primarystyle.background = primarystyle.background || popup.text_color
288
+
289
+ if (this.props.mobile && com.mobile_style) {
290
+ primarystyle = Object.assign(primarystyle, com.mobile_style)
291
+ }
288
292
  let $primary = null
289
293
  if (com.buttons.primary_enabled && com.buttons.primary_text) {
290
294
  let style = Object.assign({font_size: popup.font_size || '14px'}, page.primary_button)
@@ -304,6 +308,9 @@ export default class Popup extends Com {
304
308
  let $secondary = null
305
309
  if (com.buttons.secondary_enabled && com.buttons.secondary_text) {
306
310
  let style = Object.assign({font_size: popup.font_size || '14px'}, page.secondary_button)
311
+ if (this.props.mobile && com.mobile_style) {
312
+ style = Object.assign(style, com.mobile_style)
313
+ }
307
314
  $secondary = (
308
315
  <div
309
316
  class={'btn btn__secondary'}
@@ -700,7 +707,7 @@ export default class Popup extends Com {
700
707
  (this.props.mobile && com.mobile_style) || com.style,
701
708
  )
702
709
  delete style.margin_top
703
- delete style.margin_bottom
710
+ //delete style.margin_bottom
704
711
 
705
712
  return (
706
713
  <div class='text popup_component' style={this.js2css(style)} onClick={(e) => e.stopPropagation()}>
@@ -47,11 +47,10 @@ export default class Store {
47
47
  this.cookie = inmemCookie
48
48
  }
49
49
 
50
- cleanLocalStorage()
51
50
  this.pubsub = new sb.Pubsub()
52
- this.kv = new stor8.kv(new stor8.lsdb('sbz2023', this.inmem), 'kv')
53
- this.cache = new stor8.kv(new stor8.lsdb('sbz2023', true), 'kv')
54
- this.chain = new stor8.chain(new stor8.lsdb('cbz2023', true), 'ch')
51
+ this.kv = new stor8.kv(new stor8.lsdb('sbz2020', this.inmem), 'kv')
52
+ this.cache = new stor8.kv(new stor8.lsdb('sbz2020', true), 'kv')
53
+ this.chain = new stor8.chain(new stor8.lsdb('cbz2020', true), 'ch')
55
54
  this.getLocaleContent = this.api.getLocaleContent
56
55
 
57
56
  // dont dupplicate seen
@@ -61,9 +60,9 @@ export default class Store {
61
60
  window.addEventListener('focus', () => this.sendPresence())
62
61
 
63
62
  // faster send rate when has focus
64
- sb.setInterval(() => this.browserVisibility === 'visible' && document.hasFocus() && this.sendPresence(), 20000) // dont bother delete this
63
+ setInterval(() => this.browserVisibility === 'visible' && document.hasFocus() && this.sendPresence(), 20000) // dont bother delete this
65
64
  // slower send rate send when no focus
66
- sb.setInterval(() => (this.browserVisibility !== 'visible' || document.hasFocus()) && this.sendPresence(), 60000) // dont bother delete this
65
+ setInterval(() => (this.browserVisibility !== 'visible' || document.hasFocus()) && this.sendPresence(), 60000) // dont bother delete this
67
66
 
68
67
  onVisibilityChange((val) => {
69
68
  this.browserVisibility = val
@@ -74,8 +73,8 @@ export default class Store {
74
73
  this.device = this.getDeviceInfo()
75
74
 
76
75
  // try to get Google Analytics tracking id and client id by periodically checking it after an interval
77
- const _gaInterval = sb.setInterval(() => {
78
- let user = this.cache.match('user') || {}
76
+ const _gaInterval = setInterval(() => {
77
+ let user = this.kv.match('user') || {}
79
78
  if (!user.id) return // store not init
80
79
  var dev = this.getDeviceInfo()
81
80
  if (!dev.ga_tracking_ids || !dev.ga_client_id) return
@@ -143,7 +142,7 @@ export default class Store {
143
142
  await this.readyGate.entry()
144
143
  this.disconnect('account')
145
144
  await this.reconnect()
146
- sb.setTimeout(this.pubsub.publish('resetCSS'), 10)
145
+ setTimeout(this.pubsub.publish('resetCSS'), 10)
147
146
  }
148
147
 
149
148
  getDeviceInfo() {
@@ -226,7 +225,7 @@ export default class Store {
226
225
  // must ensure only call this function after init is done
227
226
  matchUser = () => {
228
227
  this._touchAcc()
229
- return this.cache.match('user')
228
+ return this.kv.match('user')
230
229
  }
231
230
 
232
231
  suggest_addresses = (keyword) => this.api.suggest_address(keyword)
@@ -294,7 +293,7 @@ export default class Store {
294
293
  listEvents = (id) => {
295
294
  if (!id || id === '*' || typeof id !== 'string') return
296
295
  if (!this.isInsync('events' + id)) {
297
- sb.setTimeout(async () => {
296
+ setTimeout(async () => {
298
297
  await this.readyGate.entry()
299
298
  await this.reconnectGate.entry(undefined, true)
300
299
  if (this.isInsync('events' + id)) return this.reconnectGate.open()
@@ -325,16 +324,7 @@ export default class Store {
325
324
  wsGate = new sb.Gate(true)
326
325
 
327
326
  // last widget screen
328
- matchLastview = () => {
329
- let lastView = this.kv.match('lastview') || {}
330
-
331
- // make sure last view of correct user
332
- let user = this.cache.match('user') || {}
333
- if (!user.id) return {}
334
- if (lastView.user_id != user.id) return {}
335
- return lastView
336
- }
337
-
327
+ matchLastview = () => this.kv.match('lastview') || {}
338
328
  matchIsOpen = () => !!this.kv.match('isopen') // is widget currently open
339
329
  matchHasManuallyClosed = () => !!this.kv.match('hasManuallyClosed') // true if user has ever closed the widget
340
330
  matchClosePreviewAt = () => this.kv.match('close_preview_at') || 0
@@ -342,8 +332,8 @@ export default class Store {
342
332
  sendPresence = sb.throttle(
343
333
  async () => {
344
334
  await this.readyGate.entry()
345
- if (!sb.get(this.cache.match('user'), 'id')) return // store not init
346
- if (sb.isUserBanned(this.cache.match('user'))) return
335
+ if (!sb.get(this.kv.match('user'), 'id')) return // store not init
336
+ if (sb.isUserBanned(this.kv.match('user'))) return
347
337
 
348
338
  let hasfocus = this.browserVisibility === 'visible' && document.hasFocus()
349
339
  if (!hasfocus) {
@@ -464,10 +454,10 @@ export default class Store {
464
454
  // periodically send seen
465
455
  this.seenQueue = []
466
456
  clearInterval(this._seenInterval)
467
- this._seenInterval = sb.setInterval(() => {
457
+ this._seenInterval = setInterval(() => {
468
458
  // deduplicate
469
459
  this.seenQueue = [...new Set(this.seenQueue)]
470
- let user = this.cache.match('user') || {}
460
+ let user = this.kv.match('user') || {}
471
461
  sb.map(this.seenQueue, (id) => {
472
462
  var events = this.listEvents(id)
473
463
  if (!events) return
@@ -560,7 +550,7 @@ export default class Store {
560
550
 
561
551
  _setUser(user) {
562
552
  user = sb.cloneDeep(user)
563
- let olduser = this.cache.match('user') || {}
553
+ let olduser = this.kv.match('user') || {}
564
554
  var accid = olduser.account_id || user.account_id
565
555
  var id = olduser.id || user.id
566
556
 
@@ -577,7 +567,7 @@ export default class Store {
577
567
  olduser.account_id = accid
578
568
  olduser.id = id
579
569
 
580
- this.cache.put('user', olduser)
570
+ this.kv.put('user', olduser)
581
571
  this.pubsub.publish('account')
582
572
  }
583
573
 
@@ -676,7 +666,7 @@ export default class Store {
676
666
  if (!ev || !ev.type) return
677
667
  ev.created = sb.getMs(ev.created)
678
668
  if (ev.type === 'user_info_updated') {
679
- let user = sb.cloneDeep(this.cache.match('user'))
669
+ let user = sb.cloneDeep(this.kv.match('user'))
680
670
  let attrs = sb.get(ev, 'data.user.attributes') || []
681
671
  sb.map(attrs, (attr) => sb.setUserAttr(user, attr))
682
672
  this._setUser(user)
@@ -684,7 +674,7 @@ export default class Store {
684
674
  }
685
675
 
686
676
  // convo events
687
- let user = this.cache.match('user') || {}
677
+ let user = this.kv.match('user') || {}
688
678
  let cid = sb.convoOfEv(ev)
689
679
  let convo
690
680
 
@@ -712,7 +702,7 @@ export default class Store {
712
702
  // so re-get events of this conversation to ensure we dont miss any event
713
703
  if (ev.type === 'conversation_joined') {
714
704
  let members = sb.get(ev, 'data.conversation.members', [])
715
- let me = sb.find(members, (m) => m.id === this.cache.match('user').id)
705
+ let me = sb.find(members, (m) => m.id === this.kv.match('user').id)
716
706
  if (me) {
717
707
  await this.chain.reload(cid, (type, anchor, limit) => this.listmessageapi(type, anchor, limit))
718
708
  this.markSync('events' + cid)
@@ -743,7 +733,7 @@ export default class Store {
743
733
  }
744
734
 
745
735
  async restConvoEvent(ev) {
746
- let user = this.cache.match('user')
736
+ let user = this.kv.match('user')
747
737
  let cid = sb.convoOfEv(ev)
748
738
  let convo = this.cache.match('convo_' + cid) || {}
749
739
  if (ev.type === 'conversation_state_updated') {
@@ -868,7 +858,7 @@ export default class Store {
868
858
  await this.readyGate.entry()
869
859
  var idempotency = sb.randomString(36)
870
860
 
871
- let user = this.cache.match('user') || {}
861
+ let user = this.kv.match('user') || {}
872
862
 
873
863
  var event = {
874
864
  id: idempotency,
@@ -935,7 +925,7 @@ export default class Store {
935
925
  let count = 0
936
926
 
937
927
  // ignore invalid conversation
938
- let user = this.cache.match('user')
928
+ let user = this.kv.match('user')
939
929
 
940
930
  let channel = sb.get(convo, 'touchpoint.channel', '')
941
931
  if (channel && channel != 'subiz') return
@@ -974,11 +964,7 @@ export default class Store {
974
964
  }
975
965
  }
976
966
  closePreview = () => this.kv.put('close_preview_at', new sb.Date().getTime())
977
- setLastview = (view, opts) => {
978
- let user = this.cache.match('user') || {}
979
- if (!user.id) return // store not init
980
- this.kv.put('lastview', {user_id: user.id, view, opts})
981
- }
967
+ setLastview = (view, opts) => this.kv.put('lastview', {view, opts})
982
968
 
983
969
  matchLastPluginRun(pluginid) {
984
970
  let log = this.kv.match('plugin_run_logs') || {}
@@ -997,7 +983,7 @@ export default class Store {
997
983
  }
998
984
 
999
985
  sendImpression(id) {
1000
- let user = this.cache.match('user') || {}
986
+ let user = this.kv.match('user') || {}
1001
987
  let log = this.kv.match('plugin_run_logs') || {}
1002
988
  log[id] = {web_plugin_id: id, created: this.now()}
1003
989
  this.kv.put('plugin_run_logs', log)
@@ -1012,7 +998,7 @@ export default class Store {
1012
998
  }
1013
999
 
1014
1000
  sendConversion(id, fields, impressionToken) {
1015
- let user = this.cache.match('user') || {}
1001
+ let user = this.kv.match('user') || {}
1016
1002
  let submission = {account_id: user.account_id, user_id: user.id, fields: fields}
1017
1003
 
1018
1004
  let conv = this.kv.match('conversions') || {}
@@ -1048,7 +1034,7 @@ export default class Store {
1048
1034
  })
1049
1035
 
1050
1036
  // mark conversation as received
1051
- let user = this.cache.match('user') || {}
1037
+ let user = this.kv.match('user') || {}
1052
1038
  for (let i = 0; i < events.length; i++) {
1053
1039
  let ev = events[i].value
1054
1040
 
@@ -1069,15 +1055,15 @@ export default class Store {
1069
1055
  let startms = sb.Date.now()
1070
1056
 
1071
1057
  // store not init
1072
- if (!sb.get(this.cache.match('user'), 'id')) return sb.setTimeout(() => this.loopTime(), 240000)
1058
+ if (!sb.get(this.kv.match('user'), 'id')) return setTimeout(() => this.loopTime(), 240000)
1073
1059
 
1074
1060
  let {body: t, error} = await this.api.time()
1075
- if (error) return sb.setTimeout(() => this.loopTime(), 30000)
1061
+ if (error) return setTimeout(() => this.loopTime(), 30000)
1076
1062
  var latences = Math.abs(sb.Date.now() - startms) / 2
1077
1063
  var serverMs = new sb.Date(t).getTime() + latences
1078
1064
  var localMs = sb.Date.now()
1079
1065
  this.timeDiff = Math.floor(serverMs - localMs)
1080
- sb.setTimeout(() => this.loopTime(), 240000)
1066
+ setTimeout(() => this.loopTime(), 240000)
1081
1067
  }
1082
1068
 
1083
1069
  replaceFileUrl(src) {
@@ -1112,9 +1098,9 @@ export default class Store {
1112
1098
  if ((k || '').startsWith('__sb')) this.cookie.remove(k)
1113
1099
  })
1114
1100
  this.kv.destroy()
1115
- this.kv = new stor8.kv(new stor8.lsdb('sbz2023', this.inmem), 'kv')
1101
+ this.kv = new stor8.kv(new stor8.lsdb('sbz2020', this.inmem), 'kv')
1116
1102
  this.chain.destroy()
1117
- this.chain = new stor8.chain(new stor8.lsdb('cbz2023', true), 'ch')
1103
+ this.chain = new stor8.chain(new stor8.lsdb('cbz2020', true), 'ch')
1118
1104
  }
1119
1105
 
1120
1106
  destroy() {
@@ -1259,18 +1245,3 @@ let tabletCheck =
1259
1245
  /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
1260
1246
  navigator.userAgent,
1261
1247
  )
1262
-
1263
- let cleanLocalStorage = () => {
1264
- try {
1265
- localStorage
1266
- } catch (e) {
1267
- return
1268
- }
1269
- sb.setTimeout(() => {
1270
- for (var key in localStorage) {
1271
- if ((key && key.startsWith('cbz2020')) || key.startsWith('sbz2020')) {
1272
- localStorage.removeItem(key)
1273
- }
1274
- }
1275
- })
1276
- }
@@ -14,8 +14,8 @@ export var stringify = f.contentWindow.JSON.stringify
14
14
  var parse = f.contentWindow.JSON.parse
15
15
  export var Date = f.contentWindow.Date
16
16
  export var requestAnimationFrame = f.contentWindow.requestAnimationFrame
17
- export var setTimeout = f.contentWindow.setTimeout.bind(f.contentWindow)
18
- export var setInterval = f.contentWindow.setInterval.bind(f.contentWindow)
17
+ export var setTimeout = f.contentWindow.setTimeout
18
+ export var setInterval = f.contentWindow.setInterval
19
19
 
20
20
  // convoOfEv extracts the ID of the conversation
21
21
  // that event is sent to