@subiz/widget-v4 4.1.162 → 4.1.163

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 (30) hide show
  1. package/compiled_src/chatbox/Event.js +2 -6
  2. package/compiled_src/chatbox/TextMessage.js +2 -7
  3. package/compiled_src/util/common.js +11 -0
  4. package/dist/{198a2601817.app.js → 198a2dde018.app.js} +1 -1
  5. package/dist/{198a2601817.chat.html → 198a2dde018.chat.html} +1 -1
  6. package/dist/{198a2601817.chat.js → 198a2dde018.chat.js} +1 -1
  7. package/dist/{198a2601817.form.html → 198a2dde018.form.html} +1 -1
  8. package/dist/{198a2601817.form.js → 198a2dde018.form.js} +1 -1
  9. package/dist/{198a2601817.index.html → 198a2dde018.index.html} +1 -1
  10. package/dist/{198a2601817.library.html → 198a2dde018.library.html} +1 -1
  11. package/dist/{198a2601817.library.js → 198a2dde018.library.js} +1 -1
  12. package/dist/{198a2601817.preview.html → 198a2dde018.preview.html} +1 -1
  13. package/dist/{198a2601817.preview.js → 198a2dde018.preview.js} +1 -1
  14. package/dist/{198a2601817.webview.js → 198a2dde018.webview.js} +1 -1
  15. package/dist/HASH +1 -1
  16. package/package.json +1 -1
  17. package/src/chatbox/Event.js +2 -6
  18. package/src/chatbox/TextMessage.js +1 -13
  19. package/src/util/common.js +21 -4
  20. package/tracking.js +44 -0
  21. /package/dist/{198a2601817.127.js → 198a2dde018.127.js} +0 -0
  22. /package/dist/{198a2601817.132.js → 198a2dde018.132.js} +0 -0
  23. /package/dist/{198a2601817.185.js → 198a2dde018.185.js} +0 -0
  24. /package/dist/{198a2601817.27.js → 198a2dde018.27.js} +0 -0
  25. /package/dist/{198a2601817.278.js → 198a2dde018.278.js} +0 -0
  26. /package/dist/{198a2601817.339.js → 198a2dde018.339.js} +0 -0
  27. /package/dist/{198a2601817.459.js → 198a2dde018.459.js} +0 -0
  28. /package/dist/{198a2601817.490.js → 198a2dde018.490.js} +0 -0
  29. /package/dist/{198a2601817.74.js → 198a2dde018.74.js} +0 -0
  30. /package/dist/{198a2601817.997.js → 198a2dde018.997.js} +0 -0
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 198a2601817
1
+ 198a2dde018
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.162",
3
+ "version": "4.1.163",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -234,7 +234,8 @@ export default class Event extends Com {
234
234
  let ev = this.props.event.ev
235
235
  let attachments = sb.get(ev, 'data.message.attachments')
236
236
  let hasForm = sb.find(attachments, (att) => att.type === 'form')
237
- if (isEmptyMessage(sb.get(ev, 'data.message'))) return null
237
+ if (sb.isEmptyMessage(sb.get(ev, 'data.message'))) return null
238
+
238
239
  this.tryLoadOrder(ev)
239
240
  let t = new sb.Date(ev.created).toLocaleString()
240
241
  // message of agent
@@ -468,8 +469,3 @@ export default class Event extends Com {
468
469
  return acc.name
469
470
  }
470
471
  }
471
-
472
- function isEmptyMessage(msg) {
473
- if (!msg) return true
474
- if (!msg.text && !msg.block && !sb.size(msg.attachments)) return true
475
- }
@@ -73,7 +73,7 @@ export default class TextMessage extends Com {
73
73
  }
74
74
 
75
75
  renderBlock(block) {
76
- if (isEmptyBlock(block)) return null
76
+ if (sb.isEmptyBlock(block)) return null
77
77
  let t = new sb.Date(sb.get(this.props.ev, 'created')).toLocaleString()
78
78
  let byType = sb.get(this.props.ev, 'by.type')
79
79
  if (byType !== 'user') byType = 'agent'
@@ -94,15 +94,3 @@ export default class TextMessage extends Com {
94
94
  )
95
95
  }
96
96
  }
97
-
98
- function isEmptyBlock(block) {
99
- if (!block || !block.type) return true
100
- let hasContent =
101
- sb.size(
102
- sb.filter(
103
- sb.map(block.content, (block) => isEmptyBlock(block)),
104
- (isEmpty) => !isEmpty,
105
- ),
106
- ) > 0
107
- return !sb.trim(block.text) && !hasContent
108
- }
@@ -12,7 +12,7 @@ var op = require('./op.js')
12
12
  * @return Array The HSL representation
13
13
  */
14
14
  export function rgbToHsl(r, g, b) {
15
- ;(r /= 255), (g /= 255), (b /= 255)
15
+ ;((r /= 255), (g /= 255), (b /= 255))
16
16
 
17
17
  var max = Math.max(r, g, b),
18
18
  min = Math.min(r, g, b)
@@ -721,9 +721,9 @@ export function replaceCssVariable(css, setting) {
721
721
  'desktop_button.height',
722
722
  'desktop_button.margin_x',
723
723
  'desktop_button.margin_y',
724
- 'form_header_font_size',
725
- 'form_desc_font_size',
726
- 'form_input_label_font_size',
724
+ 'form_header_font_size',
725
+ 'form_desc_font_size',
726
+ 'form_input_label_font_size',
727
727
  'width',
728
728
  'height',
729
729
  ].includes(path)
@@ -1548,3 +1548,20 @@ function absLink(url) {
1548
1548
  if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('//')) return 'http://' + url
1549
1549
  return url
1550
1550
  }
1551
+
1552
+ export function isEmptyBlock(block) {
1553
+ if (!block || !block.type) return true
1554
+ let hasContent =
1555
+ size(
1556
+ filter(
1557
+ map(block.content, (block) => isEmptyBlock(block)),
1558
+ (isEmpty) => !isEmpty,
1559
+ ),
1560
+ ) > 0
1561
+ return !trim(block.text) && !hasContent
1562
+ }
1563
+
1564
+ export function isEmptyMessage(msg) {
1565
+ if (!msg) return true
1566
+ if (!msg.text && isEmptyBlock(msg.block) && !size(msg.attachments)) return true
1567
+ }
package/tracking.js ADDED
@@ -0,0 +1,44 @@
1
+ // send signal to server when the chatbox is not visible
2
+
3
+ setTimeout(() => {
4
+ var $button = document.querySelector('div.chat-button')
5
+
6
+ let status = ''
7
+ if ($button) {
8
+ var rect = $button.getBoundingClientRect()
9
+ var visible = rect.width > 0 && rect.height > 0
10
+ if (visible) {
11
+ // the chatbox is visible
12
+ return
13
+ } else {
14
+ // the chatbox is not visible
15
+ status = 'hidden'
16
+ }
17
+ } else {
18
+ // the chatbox is not found in DOM
19
+ status = 'not-found'
20
+ }
21
+
22
+ // Collect device and browser info
23
+ var info = {
24
+ status: status,
25
+ userAgent: navigator.userAgent,
26
+ platform: navigator.platform,
27
+ language: navigator.language,
28
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
29
+ }
30
+
31
+ // Send via XHR
32
+ var xhr = new XMLHttpRequest()
33
+ xhr.open('POST', 'https://api.subiz.com.vn/4.1/chatbox-failed', true)
34
+ xhr.withCredentials = false
35
+ xhr.setRequestHeader('Content-Type', 'text/plain')
36
+
37
+ xhr.onreadystatechange = function () {
38
+ if (xhr.readyState === XMLHttpRequest.DONE) {
39
+ console.log('Server responded with:', xhr.status, xhr.responseText)
40
+ }
41
+ }
42
+
43
+ xhr.send(JSON.stringify(info))
44
+ }, 10000)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes