@subiz/widget-v4 4.1.157 → 4.1.159

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 (42) hide show
  1. package/assets/less/message.less +6 -0
  2. package/assets/less/message_input.less +1 -1
  3. package/compiled_src/bot.js +1 -1
  4. package/compiled_src/chatbox/Event.js +8 -1
  5. package/compiled_src/chatbox/Widget.js +3 -1
  6. package/compiled_src/lib.js +4 -1
  7. package/compiled_src/store/store.js +21 -2
  8. package/dist/1988902e994.app.js +1 -0
  9. package/dist/{19888eff7f5.chat.html → 1988902e994.chat.html} +1 -1
  10. package/dist/1988902e994.chat.js +1 -0
  11. package/dist/{19888eff7f5.form.html → 1988902e994.form.html} +1 -1
  12. package/dist/1988902e994.form.js +1 -0
  13. package/dist/{19888eff7f5.index.html → 1988902e994.index.html} +1 -1
  14. package/dist/{19888eff7f5.library.html → 1988902e994.library.html} +1 -1
  15. package/dist/1988902e994.library.js +1 -0
  16. package/dist/{19888eff7f5.preview.html → 1988902e994.preview.html} +1 -1
  17. package/dist/1988902e994.preview.js +1 -0
  18. package/dist/1988902e994.webview.js +1 -0
  19. package/dist/HASH +1 -1
  20. package/dist/screenshoot.js +2 -4
  21. package/package.json +2 -2
  22. package/src/bot.js +6 -1
  23. package/src/chatbox/Event.js +8 -0
  24. package/src/chatbox/Widget.js +2 -0
  25. package/src/lib.js +7 -2
  26. package/src/store/store.js +20 -1
  27. package/dist/19888eff7f5.app.js +0 -1
  28. package/dist/19888eff7f5.chat.js +0 -1
  29. package/dist/19888eff7f5.form.js +0 -1
  30. package/dist/19888eff7f5.library.js +0 -1
  31. package/dist/19888eff7f5.preview.js +0 -1
  32. package/dist/19888eff7f5.webview.js +0 -1
  33. /package/dist/{19888eff7f5.127.js → 1988902e994.127.js} +0 -0
  34. /package/dist/{19888eff7f5.132.js → 1988902e994.132.js} +0 -0
  35. /package/dist/{19888eff7f5.185.js → 1988902e994.185.js} +0 -0
  36. /package/dist/{19888eff7f5.27.js → 1988902e994.27.js} +0 -0
  37. /package/dist/{19888eff7f5.278.js → 1988902e994.278.js} +0 -0
  38. /package/dist/{19888eff7f5.339.js → 1988902e994.339.js} +0 -0
  39. /package/dist/{19888eff7f5.459.js → 1988902e994.459.js} +0 -0
  40. /package/dist/{19888eff7f5.490.js → 1988902e994.490.js} +0 -0
  41. /package/dist/{19888eff7f5.74.js → 1988902e994.74.js} +0 -0
  42. /package/dist/{19888eff7f5.997.js → 1988902e994.997.js} +0 -0
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 19888eff7f5
1
+ 1988902e994
@@ -4352,7 +4352,6 @@ let KvMaxSize = 500;
4352
4352
  init() {
4353
4353
  if (this.initialized) return;
4354
4354
  let inmemItemM = {};
4355
- console.time('KV' + this.name);
4356
4355
  let allitems = this.db.all('items');
4357
4356
  allitems.forEach(function (item) {
4358
4357
  inmemItemM[item.key] = item.value;
@@ -4372,7 +4371,6 @@ let KvMaxSize = 500;
4372
4371
  this.db.removes('items', [removekeys]);
4373
4372
  }
4374
4373
  this.initialized = true;
4375
- console.timeEnd('KV' + this.name);
4376
4374
  }
4377
4375
  all() {
4378
4376
  if (this.dead) return [];
@@ -5690,9 +5688,9 @@ class Store {
5690
5688
  traffic_source: 'direct',
5691
5689
  events: [ev]
5692
5690
  };
5693
- this.pubsub.publish('events', ev);
5694
5691
  this.lightConvos[convoid] = newconvo;
5695
5692
  this.kv.put('light_convos', this.lightConvos);
5693
+ this.pubsub.publish('events', ev);
5696
5694
  return {
5697
5695
  convo: newconvo
5698
5696
  };
@@ -6344,7 +6342,7 @@ class ChatButton extends common/* Com */.Mw {
6344
6342
  if (!agent) agent = this.props.store.matchAgent('*')[byid] || {};
6345
6343
  agent = util/* default */.A.cloneDeep(agent);
6346
6344
  agent.fullname = agent.fullname || util/* default */.A.get(account, 'name') || this.props.t('agent');
6347
- agent.avatar_url = agent.avatar_url || defaultAvatar;
6345
+ agent.avatar_url = agent.avatar_url || account.logo_url || __webpack_require__(3582);
6348
6346
  let position = util/* default */.A.get(accountSetting, 'desktop_button.position') || 'right';
6349
6347
  if (this.props.store.isMobile()) {
6350
6348
  position = util/* default */.A.get(accountSetting, 'mobile_button.position') || position;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.157",
3
+ "version": "4.1.159",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -29,7 +29,7 @@
29
29
  "babel-loader": "^10.0.0",
30
30
  "babel-plugin-syntax-jsx": "^6.18.0",
31
31
  "html-webpack-plugin": "^5.6.3",
32
- "puppeteer": "^24.16.0",
32
+ "puppeteer": "^24.16.1",
33
33
  "webpack": "^5.101.0",
34
34
  "webpack-bundle-analyzer": "^4.10.2",
35
35
  "webpack-cli": "^6.0.1",
package/src/bot.js CHANGED
@@ -13,7 +13,12 @@ export default function (store) {
13
13
  if (!match) return
14
14
  if (bot.id.startsWith('at')) {
15
15
  if (!bot.welcome_message) return
16
- let {error} = await store.startLightConvo(bot.id, bot.welcome_message, common.getLocale(bot, sb.detectLang()))
16
+ let {error} = await store.startLightConvo(
17
+ bot.id,
18
+ bot.welcome_message,
19
+ common.getLocale(bot, sb.detectLang()),
20
+ true,
21
+ )
17
22
  if (error) return console.error(error)
18
23
  store.logBotRun(bot.id)
19
24
  return
@@ -384,6 +384,8 @@ export default class Event extends Com {
384
384
 
385
385
  renderReactions() {
386
386
  if (this.props.store.isAIDevMode()) return null
387
+ let cid = sb.get(this.props.event.ev, 'data.message.conversation_id', '')
388
+ if (cid.startsWith('cslight')) return null
387
389
  let ev = sb.get(this.props.event, 'ev') || {}
388
390
  let pongs = sb.get(ev, 'data.message.pongs') || []
389
391
  let hasLike = this.hasLike()
@@ -427,6 +429,12 @@ export default class Event extends Com {
427
429
  <div class={dislikecls} onClick={() => this.onSendReaction(hasDislike ? 'remove_dislike' : 'dislike')}>
428
430
  <div class='message-event-action-btn-svg dislike' /> Bad
429
431
  </div>
432
+ <div
433
+ class='message-event-action-btn message-event-action-btn__dev'
434
+ onClick={() => this.props.store.onShowMessageInfo(ev.id)}
435
+ >
436
+ <div class='message-event-action-btn-svg info' /> Info
437
+ </div>
430
438
  </div>
431
439
  )
432
440
  }
@@ -783,11 +783,13 @@ export default class Widget extends Com {
783
783
  let _creating = this._creating
784
784
  this.setState({creating: true})
785
785
  let botid = cid.split('_')[0].slice(7) // 6 = len(cslight)
786
+ let oldconvo = this.props.store.matchConvo(this.props.cid)
786
787
  const {convo, error} = await this.props.store.startConvo({
787
788
  locale: this.props.t.locale(),
788
789
  message: text,
789
790
  members: [{type: 'bot', id: botid}],
790
791
  initial_by: this.props.store.matchUser().id,
792
+ is_testing: oldconvo.is_testing,
791
793
  })
792
794
  if (_creating != this._creating) return // outdated
793
795
  if (error) {
package/src/lib.js CHANGED
@@ -118,7 +118,7 @@ class Widget {
118
118
  }
119
119
 
120
120
  async setAccount(id, $container, mask, cb) {
121
- if (!id) return {error: 'empty_account_id'} // do nothing
121
+ if (!id) return {error: 'empty_account_id'} // do nothing
122
122
  let outmask = await this.store.init(id, mask)
123
123
  sb.setTimeout(() => window.postMessage({type: 'widget_loaded', account_id: id}, '*'), 0) // send to chrome extension
124
124
  // add container to client site
@@ -219,7 +219,8 @@ class Widget {
219
219
  }
220
220
 
221
221
  startConvo(req) {
222
- return this.store.startConvo(req)
222
+ if (!req.is_light) return this.store.startConvo(req)
223
+ else return this.store.startLightConvo(req.bot_id, bot.welcome_message, req.locale, req.is_testing)
223
224
  }
224
225
 
225
226
  async showGreeting() {
@@ -317,6 +318,10 @@ class Widget {
317
318
  this.subs.push(cb)
318
319
  }
319
320
 
321
+ overrideWelcomeMessage(msg) {
322
+ this.store.overrideWelcomeMessage(msg)
323
+ }
324
+
320
325
  overrideAccount(acc) {
321
326
  this.store.overrideAcc(acc)
322
327
  }
@@ -200,6 +200,20 @@ export default class Store {
200
200
  return this.api.create_ticket(ticket)
201
201
  }
202
202
 
203
+ overrideWelcomeMessage(msg) {
204
+ sb.map(this.lightConvos, (convo, convoid) => {
205
+ if (convo.last_message_sent) {
206
+ convo.last_message_sent.data.message = msg
207
+ convo.last_message_sent.data.message.conversation_id = convoid
208
+ }
209
+
210
+ let ev = sb.get(convo.events, '0')
211
+ ev.data.message = msg
212
+ ev.data.message.conversation_id = convoid
213
+ this.pubsub.publish('events', ev)
214
+ })
215
+ }
216
+
203
217
  async overrideAcc(acc) {
204
218
  this.forceAcc = sb.cloneDeep(acc)
205
219
  await this.readyGate.entry()
@@ -213,6 +227,10 @@ export default class Store {
213
227
  sb.setTimeout(this.pubsub.publish('resetCSS'), 10)
214
228
  }
215
229
 
230
+ onShowMessageInfo(evid) {
231
+ this.pubsub.publish('events', {type: 'show_event_info', id: evid})
232
+ }
233
+
216
234
  getDeviceInfo() {
217
235
  let device = {
218
236
  screen_resolution: window.screen.width + 'x' + window.screen.height,
@@ -1001,7 +1019,7 @@ export default class Store {
1001
1019
  this.kv.put('light_convos', this.lightConvos)
1002
1020
  }
1003
1021
 
1004
- startLightConvo(botid, message, locale) {
1022
+ startLightConvo(botid, message, locale, is_testing) {
1005
1023
  let convoid = 'cslight' + botid + '_' + this.now()
1006
1024
  let user = this.cache.match('user') || {}
1007
1025
 
@@ -1031,6 +1049,7 @@ export default class Store {
1031
1049
  touchpoint: {id: convoid, channel: 'subiz', source: 'web'},
1032
1050
  traffic_source: 'direct',
1033
1051
  events: [ev],
1052
+ is_testing: is_testing,
1034
1053
  }
1035
1054
  this.lightConvos[convoid] = newconvo
1036
1055
  this.kv.put('light_convos', this.lightConvos)