@subiz/widget-v4 4.1.160 → 4.1.162

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 (53) hide show
  1. package/compiled_src/chatbox/Event.js +6 -2
  2. package/compiled_src/chatbox/MessageInput.js +7 -0
  3. package/compiled_src/lib.js +19 -1
  4. package/dist/{1989dc3a5f1.app.js → 198a2601817.app.js} +1 -1
  5. package/dist/{1989dc3a5f1.chat.html → 198a2601817.chat.html} +1 -1
  6. package/dist/{1989dc3ac95.chat.js → 198a2601817.chat.js} +1 -1
  7. package/dist/{1989dc3a5f1.form.html → 198a2601817.form.html} +1 -1
  8. package/dist/{1989dc3ac95.form.js → 198a2601817.form.js} +1 -1
  9. package/dist/{1989dc3a5f1.index.html → 198a2601817.index.html} +1 -1
  10. package/dist/{1989dc3a5f1.library.html → 198a2601817.library.html} +1 -1
  11. package/dist/{1989dc3ac95.library.js → 198a2601817.library.js} +1 -1
  12. package/dist/{1989dc3a5f1.preview.html → 198a2601817.preview.html} +1 -1
  13. package/dist/198a2601817.preview.js +1 -0
  14. package/dist/{1989dc3a5f1.webview.js → 198a2601817.webview.js} +1 -1
  15. package/dist/HASH +1 -1
  16. package/dist/screenshoot.js +31 -2
  17. package/package.json +2 -2
  18. package/src/chatbox/Event.js +6 -1
  19. package/src/chatbox/MessageInput.js +10 -0
  20. package/src/lib.js +16 -2
  21. package/dist/1989dc3a5f1.chat.js +0 -1
  22. package/dist/1989dc3a5f1.form.js +0 -1
  23. package/dist/1989dc3a5f1.library.js +0 -1
  24. package/dist/1989dc3a5f1.preview.js +0 -1
  25. package/dist/1989dc3ac95.127.js +0 -1
  26. package/dist/1989dc3ac95.132.js +0 -1
  27. package/dist/1989dc3ac95.185.js +0 -1
  28. package/dist/1989dc3ac95.27.js +0 -1
  29. package/dist/1989dc3ac95.278.js +0 -1
  30. package/dist/1989dc3ac95.339.js +0 -1
  31. package/dist/1989dc3ac95.459.js +0 -1
  32. package/dist/1989dc3ac95.490.js +0 -1
  33. package/dist/1989dc3ac95.74.js +0 -1
  34. package/dist/1989dc3ac95.997.js +0 -1
  35. package/dist/1989dc3ac95.app.js +0 -1
  36. package/dist/1989dc3ac95.chat.html +0 -1
  37. package/dist/1989dc3ac95.form.html +0 -1
  38. package/dist/1989dc3ac95.index.html +0 -71
  39. package/dist/1989dc3ac95.library.html +0 -71
  40. package/dist/1989dc3ac95.preview.html +0 -759
  41. package/dist/1989dc3ac95.preview.js +0 -1
  42. package/dist/1989dc3ac95.webview.js +0 -1
  43. package/malicious-app.js.hash.js +0 -17
  44. /package/dist/{1989dc3a5f1.127.js → 198a2601817.127.js} +0 -0
  45. /package/dist/{1989dc3a5f1.132.js → 198a2601817.132.js} +0 -0
  46. /package/dist/{1989dc3a5f1.185.js → 198a2601817.185.js} +0 -0
  47. /package/dist/{1989dc3a5f1.27.js → 198a2601817.27.js} +0 -0
  48. /package/dist/{1989dc3a5f1.278.js → 198a2601817.278.js} +0 -0
  49. /package/dist/{1989dc3a5f1.339.js → 198a2601817.339.js} +0 -0
  50. /package/dist/{1989dc3a5f1.459.js → 198a2601817.459.js} +0 -0
  51. /package/dist/{1989dc3a5f1.490.js → 198a2601817.490.js} +0 -0
  52. /package/dist/{1989dc3a5f1.74.js → 198a2601817.74.js} +0 -0
  53. /package/dist/{1989dc3a5f1.997.js → 198a2601817.997.js} +0 -0
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 1989dc3ac95
1
+ 198a2601817
@@ -7202,6 +7202,13 @@ class MessageInput extends common/* Com */.Mw {
7202
7202
  }
7203
7203
  focus() {
7204
7204
  if (this.props.disabled) return;
7205
+ const activeElement = document.activeElement;
7206
+ let focused = false;
7207
+ if (activeElement) {
7208
+ if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') focused = true;
7209
+ if (activeElement.hasAttribute('contenteditable') && activeElement.getAttribute('contenteditable') === 'true') focused = true;
7210
+ }
7211
+ if (focused) return;
7205
7212
  this.refMessageInput.current && this.refMessageInput.current.focus();
7206
7213
  util/* default */.A.setTimeout(() => {
7207
7214
  this.refMessageInput.current && this.refMessageInput.current.focus();
@@ -8848,7 +8855,7 @@ class Event extends common/* Com */.Mw {
8848
8855
  let ev = this.props.event.ev;
8849
8856
  let attachments = util/* default */.A.get(ev, 'data.message.attachments');
8850
8857
  let hasForm = util/* default */.A.find(attachments, att => att.type === 'form');
8851
- if (ev.id === 'evshpgaeetsplfqprzmynrvrl') hasForm = true;
8858
+ if (isEmptyMessage(util/* default */.A.get(ev, 'data.message'))) return null;
8852
8859
  this.tryLoadOrder(ev);
8853
8860
  let t = new util/* default */.A.Date(ev.created).toLocaleString();
8854
8861
  if (util/* default */.A.get(ev, 'by.type') !== 'user') {
@@ -9117,6 +9124,10 @@ class Event extends common/* Com */.Mw {
9117
9124
  return acc.name;
9118
9125
  }
9119
9126
  }
9127
+ function isEmptyMessage(msg) {
9128
+ if (!msg) return true;
9129
+ if (!msg.text && !msg.block && !util/* default */.A.size(msg.attachments)) return true;
9130
+ }
9120
9131
  ;// ./src/chatbox/Events.js
9121
9132
 
9122
9133
 
@@ -11737,7 +11748,25 @@ class lib_Widget {
11737
11748
  return this.store.sendConversion(formid, values, impressiontoken);
11738
11749
  }
11739
11750
  startConvo(req) {
11740
- if (!req.is_light) return this.store.startConvo(req);else return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version);
11751
+ req = util/* default */.A.cloneDeep(req) || {};
11752
+ if (req.welcome_message) {
11753
+ return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version);
11754
+ }
11755
+ let members = req.members || [];
11756
+ if (req.bot_id) {
11757
+ let botid = req.bot_id;
11758
+ delete req.bot_id;
11759
+ if (!util/* default */.A.find(members, m => b.id == botid)) {
11760
+ members.push({
11761
+ type: 'bot',
11762
+ id: botid,
11763
+ bot_version: req.bot_version
11764
+ });
11765
+ }
11766
+ }
11767
+ req.members = members;
11768
+ req.initial_by = this.store.matchUser().id;
11769
+ return this.store.startConvo(req);
11741
11770
  }
11742
11771
  async showGreeting() {
11743
11772
  await this.domGate.entry();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.160",
3
+ "version": "4.1.162",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -30,7 +30,7 @@
30
30
  "babel-plugin-syntax-jsx": "^6.18.0",
31
31
  "html-webpack-plugin": "^5.6.3",
32
32
  "puppeteer": "^24.16.1",
33
- "webpack": "^5.101.0",
33
+ "webpack": "^5.101.1",
34
34
  "webpack-bundle-analyzer": "^4.10.2",
35
35
  "webpack-cli": "^6.0.1",
36
36
  "webpack-dev-server": "^5.2.2"
@@ -234,7 +234,7 @@ 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 (ev.id === 'evshpgaeetsplfqprzmynrvrl') hasForm = true
237
+ if (isEmptyMessage(sb.get(ev, 'data.message'))) return null
238
238
  this.tryLoadOrder(ev)
239
239
  let t = new sb.Date(ev.created).toLocaleString()
240
240
  // message of agent
@@ -468,3 +468,8 @@ export default class Event extends Com {
468
468
  return acc.name
469
469
  }
470
470
  }
471
+
472
+ function isEmptyMessage(msg) {
473
+ if (!msg) return true
474
+ if (!msg.text && !msg.block && !sb.size(msg.attachments)) return true
475
+ }
@@ -242,6 +242,16 @@ export default class MessageInput extends Com {
242
242
 
243
243
  focus() {
244
244
  if (this.props.disabled) return
245
+ // check document has current input focused, so we dont interupt the compose procedure
246
+ const activeElement = document.activeElement
247
+ let focused = false
248
+ if (activeElement) {
249
+ if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') focused = true
250
+ if (activeElement.hasAttribute('contenteditable') && activeElement.getAttribute('contenteditable') === 'true')
251
+ focused = true
252
+ }
253
+ if (focused) return
254
+
245
255
  this.refMessageInput.current && this.refMessageInput.current.focus()
246
256
  sb.setTimeout(() => {
247
257
  this.refMessageInput.current && this.refMessageInput.current.focus()
package/src/lib.js CHANGED
@@ -218,9 +218,23 @@ class Widget {
218
218
  return this.store.sendConversion(formid, values, impressiontoken)
219
219
  }
220
220
 
221
+ // req.bot_id != "" -> start conversation with bot id
221
222
  startConvo(req) {
222
- if (!req.is_light) return this.store.startConvo(req)
223
- else return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version)
223
+ req = sb.cloneDeep(req) || {}
224
+ if (req.welcome_message) {
225
+ return this.store.startLightConvo(req.bot_id, req.welcome_message, req.locale, req.is_testing, req.bot_version)
226
+ }
227
+ let members = req.members || []
228
+ if (req.bot_id) {
229
+ let botid = req.bot_id
230
+ delete req.bot_id
231
+ if (!sb.find(members, (m) => b.id == botid)) {
232
+ members.push({type: 'bot', id: botid, bot_version: req.bot_version})
233
+ }
234
+ }
235
+ req.members = members
236
+ req.initial_by = this.store.matchUser().id
237
+ return this.store.startConvo(req)
224
238
  }
225
239
 
226
240
  async showGreeting() {