@subiz/widget-v4 4.1.17 → 4.1.18

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 (135) hide show
  1. package/assets/less/widget_header.less +2 -1
  2. package/compiled_src/call/call.js +7 -7
  3. package/compiled_src/chatbox/DropdownSelect.js +1 -1
  4. package/compiled_src/chatbox/Event.js +1 -1
  5. package/compiled_src/chatbox/Events.js +3 -3
  6. package/compiled_src/chatbox/MessageInput.js +2 -2
  7. package/compiled_src/chatbox/Order.js +1 -1
  8. package/compiled_src/chatbox/Rating.js +1 -1
  9. package/compiled_src/chatbox/Typing.js +3 -3
  10. package/compiled_src/chatbox/Widget.js +6 -6
  11. package/compiled_src/chatbox/time.js +1 -1
  12. package/compiled_src/common.js +2 -2
  13. package/compiled_src/contact/contact.js +1 -1
  14. package/compiled_src/lib.js +6 -6
  15. package/compiled_src/notif/notif.js +7 -7
  16. package/compiled_src/order/address_picker.js +1 -1
  17. package/compiled_src/popup/countdown.js +2 -2
  18. package/compiled_src/popup/popup.js +8 -8
  19. package/compiled_src/store/api.js +1 -1
  20. package/compiled_src/store/store.js +3 -3
  21. package/compiled_src/util/campaign.js +6 -6
  22. package/compiled_src/util/common.js +5 -0
  23. package/dist/132.js +6612 -0
  24. package/dist/178.js +406 -0
  25. package/dist/1861083ae18.132.js +1 -0
  26. package/dist/1861083ae18.178.js +1 -0
  27. package/dist/1861083ae18.213.js +1 -0
  28. package/dist/1861083ae18.335.js +1 -0
  29. package/dist/1861083ae18.362.js +1 -0
  30. package/dist/1861083ae18.441.js +1 -0
  31. package/dist/1861083ae18.605.js +1 -0
  32. package/dist/1861083ae18.678.js +1 -0
  33. package/dist/1861083ae18.782.js +1 -0
  34. package/dist/1861083ae18.app.js +1 -0
  35. package/dist/1861083ae18.index.html +26 -0
  36. package/dist/1861083ae18.library.html +26 -0
  37. package/dist/1861083ae18.library.js +1 -0
  38. package/dist/1861083ae18.preview.html +759 -0
  39. package/dist/1861083ae18.preview.js +1 -0
  40. package/dist/1861083ae18.screenshoot.js +1 -0
  41. package/dist/1861083ae18.webview.js +1 -0
  42. package/dist/213.js +2779 -0
  43. package/dist/335.js +372 -0
  44. package/dist/362.js +107 -0
  45. package/dist/441.js +2855 -0
  46. package/dist/605.js +305 -0
  47. package/dist/678.js +107 -0
  48. package/dist/782.js +107 -0
  49. package/dist/HASH +1 -0
  50. package/dist/assets/img/Facebook.64607ec.png +0 -0
  51. package/dist/assets/img/Zalo.6845707.png +0 -0
  52. package/dist/assets/img/award1a.1a58e10.png +0 -0
  53. package/dist/assets/img/award3a.3b74423.png +0 -0
  54. package/dist/assets/img/award4a.ed6ccd4.png +0 -0
  55. package/dist/assets/img/award5.39eb7ae.png +0 -0
  56. package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
  57. package/dist/assets/img/caret.998eb8f.svg +1 -0
  58. package/dist/assets/img/convos_empty.2353007.svg +72 -0
  59. package/dist/assets/img/default.06e6ee0.jpg +0 -0
  60. package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
  61. package/dist/assets/img/done_gray.d7e8203.svg +4 -0
  62. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  63. package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
  64. package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
  65. package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
  66. package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
  67. package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
  68. package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
  69. package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
  70. package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
  71. package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
  72. package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
  73. package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
  74. package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
  75. package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
  76. package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
  77. package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
  78. package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
  79. package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
  80. package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
  81. package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
  82. package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
  83. package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
  84. package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
  85. package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
  86. package/dist/assets/img/empty.29bed2d.svg +23 -0
  87. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  88. package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
  89. package/dist/assets/img/external-link.90577cc.svg +1 -0
  90. package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
  91. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  92. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  93. package/dist/assets/img/image_default.be0698b.png +0 -0
  94. package/dist/assets/img/info.ebce7ea.svg +1 -0
  95. package/dist/assets/img/loader.37000a7.svg +1 -0
  96. package/dist/assets/img/loading_static.8f403ae.svg +10 -0
  97. package/dist/assets/img/main-service1.d536cc2.png +0 -0
  98. package/dist/assets/img/main-service2.9b99549.png +0 -0
  99. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  100. package/dist/assets/img/package.8d37d0f.svg +5 -0
  101. package/dist/assets/img/package_fade.763c001.svg +1 -0
  102. package/dist/assets/img/rating--average.1ea492c.svg +12 -0
  103. package/dist/assets/img/rating--great.e3d712e.svg +16 -0
  104. package/dist/assets/img/rating--poor.2938a25.svg +12 -0
  105. package/dist/assets/img/search.f9705ff.svg +1 -0
  106. package/dist/assets/img/send.6db52a9.svg +3 -0
  107. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  108. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  109. package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
  110. package/dist/assets/img/x.26fdfa3.svg +5 -0
  111. package/dist/malicious-app.js +13 -0
  112. package/dist/screenshoot.html +7 -0
  113. package/dist/screenshoot.js +5633 -0
  114. package/package.json +7 -7
  115. package/src/call/call.js +7 -7
  116. package/src/chatbox/DropdownSelect.js +1 -1
  117. package/src/chatbox/Event.js +1 -1
  118. package/src/chatbox/Events.js +3 -3
  119. package/src/chatbox/MessageInput.js +2 -2
  120. package/src/chatbox/Order.js +1 -1
  121. package/src/chatbox/Rating.js +1 -1
  122. package/src/chatbox/Typing.js +3 -3
  123. package/src/chatbox/Widget.js +6 -6
  124. package/src/chatbox/time.js +1 -1
  125. package/src/common.js +2 -2
  126. package/src/contact/contact.js +1 -1
  127. package/src/lib.js +6 -6
  128. package/src/notif/notif.js +7 -7
  129. package/src/order/address_picker.js +1 -1
  130. package/src/popup/countdown.js +2 -2
  131. package/src/popup/popup.js +8 -8
  132. package/src/store/api.js +2 -3
  133. package/src/store/store.js +3 -3
  134. package/src/util/campaign.js +6 -6
  135. package/src/util/common.js +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.17",
3
+ "version": "4.1.18",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -12,15 +12,15 @@
12
12
  "@subiz/ajax": "^3.0.12",
13
13
  "@subiz/flow": "^1.0.9",
14
14
  "@subiz/storage": "0.0.8",
15
- "@subiz/wsclient": "^3.1.9",
15
+ "@subiz/wsclient": "^4.0.9",
16
16
  "cookie_js": "1.4.2",
17
- "core-js": "^3.27.2",
17
+ "core-js": "^3.28.0",
18
18
  "css-loader": "5.2.7",
19
19
  "file-loader": "^6.2.0",
20
20
  "less": "^4.1.3",
21
21
  "less-loader": "^11.1.0",
22
22
  "marked": "^4.2.12",
23
- "preact": "^10.11.3"
23
+ "preact": "^10.12.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@babel/cli": "^7.20.7",
@@ -31,10 +31,10 @@
31
31
  "babel-loader": "^9.1.2",
32
32
  "babel-plugin-syntax-jsx": "^6.18.0",
33
33
  "html-webpack-plugin": "^5.5.0",
34
- "prettier": "^2.8.3",
35
- "puppeteer": "^19.6.3",
34
+ "prettier": "^2.8.4",
35
+ "puppeteer": "^19.7.0",
36
36
  "webpack": "^5.75.0",
37
- "webpack-bundle-analyzer": "^4.7.0",
37
+ "webpack-bundle-analyzer": "^4.8.0",
38
38
  "webpack-cli": "^5.0.1",
39
39
  "webpack-dev-server": "^4.11.1"
40
40
  }
package/src/call/call.js CHANGED
@@ -22,7 +22,7 @@ export default class Notif extends Com {
22
22
  constructor(props) {
23
23
  super(props)
24
24
 
25
- setTimeout(async () => {
25
+ sb.setTimeout(async () => {
26
26
  let {body: impression} = await this.props.store.sendImpression(this.props.plugin.id)
27
27
  this.impressionToken = sb.get(impression, 'impression_token') || ''
28
28
 
@@ -95,7 +95,7 @@ export default class Notif extends Com {
95
95
  if (!this.props.t) return
96
96
 
97
97
  if (!close) {
98
- clearTimeout(this.lastCloseTimeout)
98
+ sb.clearTimeout(this.lastCloseTimeout)
99
99
 
100
100
  this.setState({closeAnimation: false})
101
101
  let timestamp = this.randomTimestampt()
@@ -133,8 +133,8 @@ export default class Notif extends Com {
133
133
  }
134
134
  this.setState({closeAnimation: true})
135
135
  this.mouse_leave = sb.Date.now()
136
- this.lastCloseTimeout = setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
137
- if (this.props.plugin._dont_close) setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
136
+ this.lastCloseTimeout = sb.setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
137
+ if (this.props.plugin._dont_close) sb.setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
138
138
  }
139
139
 
140
140
  async refreshCSS() {
@@ -149,7 +149,7 @@ export default class Notif extends Com {
149
149
  }
150
150
 
151
151
  componentWillUnmount() {
152
- clearInterval(this.interval)
152
+ sb.clearInterval(this.interval)
153
153
  sb.setCss(this.props.plugin.id, this.$cssStyleDiv, '')
154
154
  }
155
155
 
@@ -166,7 +166,7 @@ export default class Notif extends Com {
166
166
  this.props.store.onResetCSS(this, () => this.refreshCSS())
167
167
  await this.refreshCSS()
168
168
 
169
- this.interval = setInterval(() => {
169
+ this.interval = sb.setInterval(() => {
170
170
  if (this.props._destroy) return this.componentWillUnmount()
171
171
  // keep notification open when user hover on it
172
172
  // but dont close right after mouse leave, activate after 1 sec
@@ -182,7 +182,7 @@ export default class Notif extends Com {
182
182
  }
183
183
  }, 1000)
184
184
 
185
- setTimeout(() => {
185
+ sb.setTimeout(() => {
186
186
  this.setState({cssready: true})
187
187
  this.setClose(false) // auto open when created
188
188
  }, 50)
@@ -114,7 +114,7 @@ export default class DropdownSelect extends Com {
114
114
  focusFilter() {
115
115
  if (!this.filterRef.current) return
116
116
  this.filterRef.current.focus()
117
- setTimeout(() => {
117
+ sb.setTimeout(() => {
118
118
  if (!this.filterRef.current) return
119
119
  this.filterRef.current.focus()
120
120
  }, 100)
@@ -167,7 +167,7 @@ export default class Event extends Com {
167
167
  }
168
168
 
169
169
  if (sb.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
170
- setTimeout(() => this.setState({refresh: this.state.refresh}), 1000)
170
+ sb.setTimeout(() => this.setState({refresh: this.state.refresh}), 1000)
171
171
  }
172
172
 
173
173
  // only show sending while the message is send too long (>300ms) but haven't returned from
@@ -173,7 +173,7 @@ export default class Events extends Com {
173
173
  this.setState({error: false})
174
174
  this.scrollToBottom()
175
175
 
176
- setTimeout(() => this.setState({loading: false}), 50)
176
+ sb.setTimeout(() => this.setState({loading: false}), 50)
177
177
  }
178
178
 
179
179
  isBottom() {
@@ -183,11 +183,11 @@ export default class Events extends Com {
183
183
  }
184
184
 
185
185
  scrollToBottom() {
186
- setTimeout(() => {
186
+ sb.setTimeout(() => {
187
187
  const $div = this.refBody
188
188
  if ($div) $div.scrollTop = $div.scrollHeight
189
189
  })
190
- setTimeout(() => {
190
+ sb.setTimeout(() => {
191
191
  const $div = this.refBody
192
192
  if ($div) $div.scrollTop = $div.scrollHeight
193
193
  }, 200)
@@ -228,10 +228,10 @@ export default class MessageInput extends Com {
228
228
  focus() {
229
229
  if (this.props.disabled) return
230
230
  this.refMessageInput.current && this.refMessageInput.current.focus()
231
- setTimeout(() => {
231
+ sb.setTimeout(() => {
232
232
  this.refMessageInput.current && this.refMessageInput.current.focus()
233
233
  })
234
- setTimeout(() => {
234
+ sb.setTimeout(() => {
235
235
  this.refMessageInput.current && this.refMessageInput.current.focus()
236
236
  }, 100)
237
237
  }
@@ -59,7 +59,7 @@ export default class Order extends Com {
59
59
  render() {
60
60
  if (this._show != this.props.show) {
61
61
  this._show = this.props.show
62
- setTimeout(() => {
62
+ sb.setTimeout(() => {
63
63
  if (!this._show) this.close()
64
64
  else this.open()
65
65
  })
@@ -155,7 +155,7 @@ export default class Rating extends Com {
155
155
  if (!this.state.hide) return
156
156
  this.setState({hide: false})
157
157
  if (!this.refRating.current) return
158
- setTimeout(() => {
158
+ sb.setTimeout(() => {
159
159
  if (this.refComment.current) this.refComment.current.focus()
160
160
  }, 400)
161
161
  this.refComment.current.value = ''
@@ -23,7 +23,7 @@ export default class Typing extends Com {
23
23
 
24
24
  if (sb.get(ev, 'type') === 'message_sent') {
25
25
  // stop the typing
26
- if (this.timer) clearTimeout(this.timer)
26
+ if (this.timer) sb.clearTimeout(this.timer)
27
27
  this.timer = null
28
28
  this.setState({isShow: false})
29
29
  return
@@ -35,8 +35,8 @@ export default class Typing extends Com {
35
35
 
36
36
  if (sb.get(ev, 'type') !== 'conversation_typing') return
37
37
  this.setState({ev: ev, isShow: true})
38
- if (this.timer) clearTimeout(this.timer)
39
- this.timer = setTimeout(() => {
38
+ if (this.timer) sb.clearTimeout(this.timer)
39
+ this.timer = sb.setTimeout(() => {
40
40
  if (sb.convoOfEv(ev) !== this.props.cid) return
41
41
 
42
42
  this.timer = null
@@ -53,7 +53,7 @@ export default class Widget extends Com {
53
53
  this.closeOrder()
54
54
  this.setState({clickedJoin: false, quickReplyMessage: {}})
55
55
  // this.props.store.setLastview('chat', { cid: this.props.cid })
56
- setTimeout(() => {
56
+ sb.setTimeout(() => {
57
57
  // focus Events then focus MessageInput
58
58
  // if there is any pending form, MessageInput will be disabled
59
59
  // and dont steal focus from Events
@@ -642,8 +642,8 @@ export default class Widget extends Com {
642
642
  if (this.props.store.isPreview) return
643
643
  var $input = this.msgInput.current
644
644
  if (!$input) return
645
- setTimeout(() => $input && $input.blur())
646
- setTimeout(() => $input && $input.blur(), 300) // force lose focus
645
+ sb.setTimeout(() => $input && $input.blur())
646
+ sb.setTimeout(() => $input && $input.blur(), 300) // force lose focus
647
647
  }
648
648
 
649
649
  focusInput() {
@@ -659,7 +659,7 @@ export default class Widget extends Com {
659
659
  if (!field.value) firstemptykey = key
660
660
  })
661
661
 
662
- setTimeout(() => {
662
+ sb.setTimeout(() => {
663
663
  var $input = this['form_' + encode(firstemptykey)]
664
664
  if (!$input) return
665
665
 
@@ -670,8 +670,8 @@ export default class Widget extends Com {
670
670
 
671
671
  var $input = this.msgInput.current
672
672
  if (!$input) return
673
- setTimeout(() => $input.focus())
674
- setTimeout(() => $input.focus(), 300) // force focus
673
+ sb.setTimeout(() => $input.focus())
674
+ sb.setTimeout(() => $input.focus(), 300) // force focus
675
675
  }
676
676
 
677
677
  onRate(rating) {
@@ -1,7 +1,7 @@
1
1
  import sb from '../util/index.js'
2
2
 
3
3
  var g_pub = new sb.Pubsub()
4
- setInterval(() => g_pub.publish('time'), 20 * 1000)
4
+ sb.setInterval(() => g_pub.publish('time'), 20 * 1000)
5
5
 
6
6
  import {Com} from '../common.js'
7
7
  import {h} from 'preact'
package/src/common.js CHANGED
@@ -5,7 +5,7 @@ export class Com extends Component {
5
5
  constructor(props) {
6
6
  super(props)
7
7
  this._isMounted = true
8
- setTimeout(() => {
8
+ sb.setTimeout(() => {
9
9
  if (this.componentWillUnmount) {
10
10
  let old = this.componentWillUnmount.bind(this)
11
11
  this.componentWillUnmount = () => {
@@ -74,7 +74,7 @@ let downloadLock = false
74
74
 
75
75
  export function downloadLanguage(store, locale, force) {
76
76
  if (downloadLock)
77
- return new Promise((resolve) => setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100))
77
+ return new Promise((resolve) => sb.setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100))
78
78
 
79
79
  downloadLock = true
80
80
  // let locale = getLocale()
@@ -262,7 +262,7 @@ export default class Contact extends Com {
262
262
 
263
263
  if (this.state.pluginjson !== pluginstringify) {
264
264
  this.refreshCSS()
265
- setTimeout(() => this.setState({pluginjson: pluginstringify}))
265
+ sb.setTimeout(() => this.setState({pluginjson: pluginstringify}))
266
266
  }
267
267
 
268
268
  if (this.state.close) return null
package/src/lib.js CHANGED
@@ -33,11 +33,11 @@ class Widget {
33
33
  if (!$container) $container = document.body
34
34
  this.pluginMgr = new PluginMgr(this, $container)
35
35
 
36
- let clean = setInterval(() => {
36
+ let clean = sb.setInterval(() => {
37
37
  // check if the dom is deleted
38
38
  if ($container && $container.isConnected) return
39
39
  this.pluginMgr.destroy()
40
- clearInterval(clean)
40
+ sb.clearInterval(clean)
41
41
  }, 1000)
42
42
  this.domGate.open()
43
43
  return user
@@ -57,11 +57,11 @@ class Widget {
57
57
  if (!$container) $container = document.body || document
58
58
  this.pluginMgr = new PluginMgr(this, $container)
59
59
 
60
- let clean = setInterval(() => {
60
+ let clean = sb.setInterval(() => {
61
61
  // check if the dom is deleted
62
62
  if ($container && $container.isConnected) return
63
63
  this.pluginMgr.destroy()
64
- clearInterval(clean)
64
+ sb.clearInterval(clean)
65
65
  }, 1000)
66
66
  this.domGate.open()
67
67
  return user
@@ -73,11 +73,11 @@ class Widget {
73
73
  if (!$container) $container = document.body || document
74
74
  this.pluginMgr = new PluginMgr(this, $container)
75
75
 
76
- let clean = setInterval(() => {
76
+ let clean = sb.setInterval(() => {
77
77
  // check if the dom is deleted
78
78
  if ($container && $container.isConnected) return
79
79
  this.pluginMgr.destroy()
80
- clearInterval(clean)
80
+ sb.clearInterval(clean)
81
81
  }, 1000)
82
82
  this.domGate.open()
83
83
  cb && cb(outmask)
@@ -22,7 +22,7 @@ export default class Notif extends Com {
22
22
  constructor(props) {
23
23
  super(props)
24
24
 
25
- setTimeout(async () => {
25
+ sb.setTimeout(async () => {
26
26
  let {body: impression} = await this.props.store.sendImpression(this.props.plugin.id)
27
27
  this.impressionToken = sb.get(impression, 'impression_token') || ''
28
28
 
@@ -96,7 +96,7 @@ export default class Notif extends Com {
96
96
  if (!this.props.t) return
97
97
 
98
98
  if (!close) {
99
- clearTimeout(this.lastCloseTimeout)
99
+ sb.clearTimeout(this.lastCloseTimeout)
100
100
 
101
101
  this.setState({closeAnimation: false})
102
102
  let timestamp = this.randomTimestampt()
@@ -139,8 +139,8 @@ export default class Notif extends Com {
139
139
  }
140
140
  this.setState({closeAnimation: true})
141
141
  this.mouse_leave = sb.Date.now()
142
- this.lastCloseTimeout = setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
143
- if (this.props.plugin._dont_close) setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
142
+ this.lastCloseTimeout = sb.setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
143
+ if (this.props.plugin._dont_close) sb.setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
144
144
  }
145
145
 
146
146
  async refreshCSS() {
@@ -155,7 +155,7 @@ export default class Notif extends Com {
155
155
  }
156
156
 
157
157
  componentWillUnmount() {
158
- clearInterval(this.interval)
158
+ sb.clearInterval(this.interval)
159
159
  sb.setCss(this.props.plugin.id, this.$cssStyleDiv, '')
160
160
  }
161
161
 
@@ -172,7 +172,7 @@ export default class Notif extends Com {
172
172
  this.props.store.onResetCSS(this, () => this.refreshCSS())
173
173
  await this.refreshCSS()
174
174
 
175
- this.interval = setInterval(() => {
175
+ this.interval = sb.setInterval(() => {
176
176
  if (this.props._destroy) return this.componentWillUnmount()
177
177
  // keep notification open when user hover on it
178
178
  // but dont close right after mouse leave, activate after 1 sec
@@ -188,7 +188,7 @@ export default class Notif extends Com {
188
188
  }
189
189
  }, 1000)
190
190
 
191
- setTimeout(() => {
191
+ sb.setTimeout(() => {
192
192
  this.setState({cssready: true})
193
193
  this.setClose(false) // auto open when created
194
194
  }, 50)
@@ -106,7 +106,7 @@ export default class AddressPicker extends Com {
106
106
  focusFilter() {
107
107
  if (!this.filterRef.current) return
108
108
  this.filterRef.current.focus()
109
- setTimeout(() => {
109
+ sb.setTimeout(() => {
110
110
  if (!this.filterRef.current) return
111
111
  this.filterRef.current.focus()
112
112
  }, 100)
@@ -15,7 +15,7 @@ export default class Countdown extends Com {
15
15
 
16
16
  constructor(props) {
17
17
  super(props)
18
- this.timer = setInterval(() => {
18
+ this.timer = sb.setInterval(() => {
19
19
  if (this.props._destroy) return this.componentWillUnmount()
20
20
  let cd = this.props.com.countdown || {}
21
21
  let newFlipKey = 'cd' + ':' + cd.skin + ':' + cd.size + ':' + this.props.plugin.popup.font_family + ':'
@@ -25,7 +25,7 @@ export default class Countdown extends Com {
25
25
  }
26
26
 
27
27
  componentWillUnmount() {
28
- clearInterval(this.timer)
28
+ sb.clearInterval(this.timer)
29
29
  }
30
30
 
31
31
  getCountDownDeltaSec(countdown) {
@@ -19,14 +19,14 @@ export default class Popup extends Com {
19
19
  constructor(props) {
20
20
  super(props)
21
21
  this._formRef = createRef()
22
- setTimeout(() => this.fillForm(), 1000)
22
+ sb.setTimeout(() => this.fillForm(), 1000)
23
23
 
24
- setTimeout(async () => {
24
+ sb.setTimeout(async () => {
25
25
  let {body: impression} = await this.props.store.sendImpression(this.props.plugin.id)
26
26
  this.impressionToken = sb.get(impression, 'impression_token') || ''
27
27
  }, 10)
28
28
 
29
- setTimeout(() => {
29
+ sb.setTimeout(() => {
30
30
  let fonts = {}
31
31
  fonts[this.props.plugin.popup.font_family] = true
32
32
  let images = {}
@@ -48,7 +48,7 @@ export default class Popup extends Com {
48
48
  // preload images and fonts
49
49
  sb.map(images, (_, image) => sb.preloadImg(image, () => this.setState({imageReady: true})))
50
50
  sb.preloadWebfonts(Object.keys(fonts))
51
- setTimeout(async () => {
51
+ sb.setTimeout(async () => {
52
52
  await this.waitForFont(Object.keys(fonts))
53
53
  this.setState({fontReady: true})
54
54
  })
@@ -169,9 +169,9 @@ export default class Popup extends Com {
169
169
  if (close) {
170
170
  document.body.style.setProperty('overflow', this.lastoverflow)
171
171
  this.setState({closeAnimation: true})
172
- setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
172
+ sb.setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
173
173
  if (this.props.plugin._dont_close)
174
- setTimeout(() => {
174
+ sb.setTimeout(() => {
175
175
  this.lastoverflow = window.getComputedStyle(document.body).getPropertyValue('overflow')
176
176
  document.body.style.setProperty('overflow', 'hidden', 'important')
177
177
  this.setState({closeAnimation: false, close: false})
@@ -255,7 +255,7 @@ export default class Popup extends Com {
255
255
  }
256
256
 
257
257
  for (let a of actions) {
258
- if (a.action === 'close') setTimeout(() => this.setClose(true), 100)
258
+ if (a.action === 'close') sb.setTimeout(() => this.setClose(true), 100)
259
259
  if (a.action === 'next_page') this.props.nextPage()
260
260
  }
261
261
 
@@ -747,7 +747,7 @@ export default class Popup extends Com {
747
747
  this.props.store.onResetCSS(this, () => this.refreshCSS())
748
748
 
749
749
  await this.refreshCSS()
750
- setTimeout(() => {
750
+ sb.setTimeout(() => {
751
751
  this.setState({cssready: true})
752
752
  this.setClose(false) // auto open when created
753
753
  }, 50)
package/src/store/api.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import sb from '../util/index.js'
2
-
3
2
  const ajax = require('@subiz/ajax/src/ajax.js')
4
3
  ajax.env.XMLHttpRequest = window.XMLHttpRequest
5
4
 
@@ -41,7 +40,7 @@ export default class {
41
40
 
42
41
  return done(true)
43
42
  })
44
- // .beforeHook((param, done) => setTimeout((_) => done(true), 1000))
43
+ // .beforeHook((param, done) => sb.setTimeout((_) => done(true), 1000))
45
44
  }
46
45
 
47
46
  setAgentId(agid) {
@@ -109,7 +108,7 @@ export default class {
109
108
  if (!force && this.last_token && age < 3000) {
110
109
  // the token is still good, but should get new one
111
110
  if (this.token_generator)
112
- setTimeout(async () => {
111
+ sb.setTimeout(async () => {
113
112
  let token, err
114
113
  try {
115
114
  token = await tokenGenerator(profile_id)
@@ -4,7 +4,7 @@ import stor8 from '@subiz/storage'
4
4
  import API from './api.js'
5
5
  import APIFake from './api_fake.js'
6
6
  import RealtimeFake from './realtime_fake.js'
7
- var Realtime = require('@subiz/wsclient/index.js')
7
+ var Realtime = require('@subiz/wsclient')
8
8
  var cookie = require('cookie_js')
9
9
  cookie.defaults.path = '/'
10
10
  cookie.expiresMultiplier = 60 * 60 * 24 // days
@@ -79,7 +79,7 @@ export default class Store {
79
79
  if (!user.id) return // store not init
80
80
  var dev = this.getDeviceInfo()
81
81
  if (!dev.ga_tracking_ids || !dev.ga_client_id) return
82
- clearInterval(_gaInterval)
82
+ sb.clearInterval(_gaInterval)
83
83
  this.device = dev
84
84
 
85
85
  // update gclient id
@@ -463,7 +463,7 @@ export default class Store {
463
463
  seenLoop() {
464
464
  // periodically send seen
465
465
  this.seenQueue = []
466
- clearInterval(this._seenInterval)
466
+ sb.clearInterval(this._seenInterval)
467
467
  this._seenInterval = sb.setInterval(() => {
468
468
  // deduplicate
469
469
  this.seenQueue = [...new Set(this.seenQueue)]
@@ -65,14 +65,14 @@ export function trackInactivity(seconds, cb) {
65
65
  let resetTime = () => {
66
66
  inactiveSeconds = 0
67
67
  }
68
- let timer = setInterval(() => {
68
+ let timer = common.setInterval(() => {
69
69
  inactiveSeconds++
70
70
  if (inactiveSeconds < seconds) return
71
71
  if (cb) cb()
72
72
  for (let ev of events) {
73
73
  document.removeEventListener(ev, resetTime, false)
74
74
  }
75
- clearInterval(timer)
75
+ common.clearInterval(timer)
76
76
  }, 1000)
77
77
 
78
78
  for (let ev of events) {
@@ -81,21 +81,21 @@ export function trackInactivity(seconds, cb) {
81
81
  }
82
82
 
83
83
  let timeOnPage = 0 // seconds
84
- setInterval(() => {
84
+ common.setInterval(() => {
85
85
  timeOnPage += 5
86
86
  }, 5000)
87
87
 
88
88
  // when user has been on the page for at least X seconds
89
89
  export function trackTimeOnPage(seconds, cb) {
90
90
  if (seconds < 1) {
91
- return setTimeout(function () {
91
+ return common.setTimeout(function () {
92
92
  cb(seconds)
93
93
  }, 100)
94
94
  }
95
95
 
96
- let timer = setInterval(() => {
96
+ let timer = common.setInterval(() => {
97
97
  if (timeOnPage < seconds) return
98
98
  if (cb) cb(timeOnPage)
99
- clearInterval(timer)
99
+ common.clearInterval(timer)
100
100
  }, 1000)
101
101
  }
@@ -16,6 +16,8 @@ export var Date = f.contentWindow.Date
16
16
  export var requestAnimationFrame = f.contentWindow.requestAnimationFrame
17
17
  export var setTimeout = f.contentWindow.setTimeout.bind(f.contentWindow)
18
18
  export var setInterval = f.contentWindow.setInterval.bind(f.contentWindow)
19
+ export var clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow)
20
+ export var clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow)
19
21
 
20
22
  // convoOfEv extracts the ID of the conversation
21
23
  // that event is sent to