@subiz/widget-v4 4.1.172 → 4.1.174

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 (40) hide show
  1. package/chat.js +18 -1
  2. package/compiled_src/chatbox/Widget.js +1 -0
  3. package/compiled_src/lib.js +3 -0
  4. package/compiled_src/store/api.js +4 -1
  5. package/compiled_src/store/store.js +8 -1
  6. package/compiled_src/util/common.js +1 -1
  7. package/dist/198c50be7a7.app.js +1 -0
  8. package/dist/{198b082f7d0.chat.html → 198c50be7a7.chat.html} +1 -1
  9. package/dist/198c50be7a7.chat.js +1 -0
  10. package/dist/{198b082f7d0.form.html → 198c50be7a7.form.html} +1 -1
  11. package/dist/198c50be7a7.form.js +1 -0
  12. package/dist/{198b082f7d0.index.html → 198c50be7a7.index.html} +1 -1
  13. package/dist/{198b082f7d0.library.html → 198c50be7a7.library.html} +1 -1
  14. package/dist/198c50be7a7.library.js +1 -0
  15. package/dist/{198b082f7d0.preview.html → 198c50be7a7.preview.html} +1 -1
  16. package/dist/198c50be7a7.preview.js +1 -0
  17. package/dist/{198b082f7d0.chat.js → 198c50be7a7.webview.js} +1 -1
  18. package/dist/HASH +1 -1
  19. package/dist/screenshoot.js +41 -16
  20. package/package.json +5 -5
  21. package/src/chatbox/Widget.js +1 -0
  22. package/src/lib.js +4 -0
  23. package/src/store/api.js +4 -1
  24. package/src/store/store.js +8 -1
  25. package/src/util/common.js +1 -1
  26. package/dist/198b082f7d0.app.js +0 -1
  27. package/dist/198b082f7d0.form.js +0 -1
  28. package/dist/198b082f7d0.library.js +0 -1
  29. package/dist/198b082f7d0.preview.js +0 -1
  30. package/dist/198b082f7d0.webview.js +0 -1
  31. /package/dist/{198b082f7d0.127.js → 198c50be7a7.127.js} +0 -0
  32. /package/dist/{198b082f7d0.132.js → 198c50be7a7.132.js} +0 -0
  33. /package/dist/{198b082f7d0.185.js → 198c50be7a7.185.js} +0 -0
  34. /package/dist/{198b082f7d0.27.js → 198c50be7a7.27.js} +0 -0
  35. /package/dist/{198b082f7d0.278.js → 198c50be7a7.278.js} +0 -0
  36. /package/dist/{198b082f7d0.339.js → 198c50be7a7.339.js} +0 -0
  37. /package/dist/{198b082f7d0.459.js → 198c50be7a7.459.js} +0 -0
  38. /package/dist/{198b082f7d0.490.js → 198c50be7a7.490.js} +0 -0
  39. /package/dist/{198b082f7d0.74.js → 198c50be7a7.74.js} +0 -0
  40. /package/dist/{198b082f7d0.997.js → 198c50be7a7.997.js} +0 -0
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 198b082f7d0
1
+ 198c50be7a7
@@ -2470,7 +2470,7 @@ XMLHttpRequest.prototype.send = function (body) {
2470
2470
  response: this.responseText
2471
2471
  });
2472
2472
  }
2473
- old(a, b, c);
2473
+ if (typeof old == 'function') old(a, b, c);
2474
2474
  };
2475
2475
  return _originalSend.apply(this, arguments);
2476
2476
  };
@@ -3896,8 +3896,11 @@ function jsonifyTextPlain(param, done) {
3896
3896
  _defineProperty(this, "time", _ => ajax.setBaseUrl(this.ApiURL).withCredentials(true).setParser('json').get('/time'));
3897
3897
  _defineProperty(this, "updateUser", data => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}`, data));
3898
3898
  _defineProperty(this, "getUser", _ => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`));
3899
- _defineProperty(this, "getAccountSetting", () => {
3899
+ _defineProperty(this, "getAccountSetting", p => {
3900
3900
  let href = util/* default */.A.get(document, 'location.href');
3901
+ if (p && p.bot_id) {
3902
+ return this.apireq.addQuery('url', href).addQuery('bot_id', p.bot_id).get(`/accounts/${this.accid}/settings`);
3903
+ }
3901
3904
  return this.apireq.addQuery('url', href).get(`/accounts/${this.accid}/settings`);
3902
3905
  });
3903
3906
  _defineProperty(this, "sendImpression", impression => this.apireq.post(`/accounts/${this.accid}/campaigns/${impression.campaign_id}/impressions`, impression));
@@ -5187,6 +5190,10 @@ class Store {
5187
5190
  await this.readyGate.entry();
5188
5191
  this.reconnect();
5189
5192
  }
5193
+ async overrideBotId(botid) {
5194
+ this.forceBotId = botid;
5195
+ await this.readyGate.entry();
5196
+ }
5190
5197
  async overrideChatbox(chatbox) {
5191
5198
  this.forceChatbox = chatbox;
5192
5199
  await this.readyGate.entry();
@@ -5431,7 +5438,9 @@ class Store {
5431
5438
  let fetchuser = p && p.user ? Promise.resolve({
5432
5439
  body: p.user
5433
5440
  }) : this.api.getUser();
5434
- let outs = await Promise.all([fetchuser, this.api.getAccountSetting()]);
5441
+ let outs = await Promise.all([fetchuser, this.api.getAccountSetting({
5442
+ bot_id: this.forceBotId
5443
+ })]);
5435
5444
  let error = util/* default */.A.find(outs, out => out.error);
5436
5445
  if (error) return console.error(error);
5437
5446
  let set = outs[1].body;
@@ -5670,17 +5679,17 @@ class Store {
5670
5679
  this.chain.put(cid, oldev.id, util/* default */.A.getMs(oldev.created), oldev);
5671
5680
  this.pubsub.publish('events', oldev);
5672
5681
  }
5673
- if (ev.type === 'message_sent') {
5674
- let idemkey = util/* default */.A.get(ev, 'data.message.idempotency_key');
5675
- let found = util/* default */.A.find(this.listEvents(cid), oldev => oldev.id === idemkey);
5676
- if (found) {
5677
- this.chain.del(cid, found.id);
5678
- ev.created = found.created;
5679
- }
5680
- convo.last_message_sent = ev;
5681
- }
5682
5682
  if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {
5683
5683
  this.chain.put(cid, ev.id, util/* default */.A.getMs(ev.created), ev);
5684
+ if (ev.type === 'message_sent') {
5685
+ let idemkey = util/* default */.A.get(ev, 'data.message.idempotency_key');
5686
+ let found = util/* default */.A.find(this.listEvents(cid), oldev => oldev.id === idemkey);
5687
+ if (found) {
5688
+ this.chain.del(cid, found.id);
5689
+ ev.created = found.created;
5690
+ }
5691
+ convo.last_message_sent = ev;
5692
+ }
5684
5693
  }
5685
5694
  this._setConvo(convo);
5686
5695
  this.pubsub.publish('account');
@@ -6009,7 +6018,9 @@ class Store {
6009
6018
  src = src.replace('http://file.subiz.com/', this.FileURL);
6010
6019
  src = src.replace('https://file.mysubiz.com/', this.FileURL);
6011
6020
  src = src.replace('http://file.mysubiz.com/', this.FileURL);
6012
- return src.replace('vcdn.subiz-cdn.com', 'cdn.subiz.net');
6021
+ return src;
6022
+ // removed by dead control flow
6023
+ {}
6013
6024
  }
6014
6025
  clearBrowserData() {
6015
6026
  util/* default */.A.each(this.cookie.all(), (v, k) => {
@@ -6463,6 +6474,7 @@ class ChatButton extends common/* Com */.Mw {
6463
6474
  this._buttonLoaded = true;
6464
6475
  }
6465
6476
  renderButton() {
6477
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_button = util/* default */.A.Date.now();
6466
6478
  let accountSetting = this.props.plugin.chatbox;
6467
6479
  accountSetting = this.fixMissingSetting(accountSetting);
6468
6480
  let imgsrc = util/* default */.A.get(accountSetting, 'desktop_button.background_image_url') || util/* default */.A.get(accountSetting, 'desktop_button.background_mask_url') || defaultBubble;
@@ -11139,9 +11151,19 @@ class Main extends common/* Com */.Mw {
11139
11151
  }
11140
11152
  }
11141
11153
  render() {
11142
- if (!this.state.cssready) return null;
11143
- if (util/* default */.A.isUserBanned(this.props.store.matchUser())) return null;
11144
- if (!this.props.t) return null;
11154
+ if (!this.state.cssready) {
11155
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_css_not_ready = util/* default */.A.Date.now();
11156
+ return null;
11157
+ }
11158
+ if (util/* default */.A.isUserBanned(this.props.store.matchUser())) {
11159
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_user_is_banned = util/* default */.A.Date.now();
11160
+ return null;
11161
+ }
11162
+ if (!this.props.t) {
11163
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_no_t = util/* default */.A.Date.now();
11164
+ return null;
11165
+ }
11166
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_main = util/* default */.A.Date.now();
11145
11167
  return (0,preact_module.h)("div", {
11146
11168
  class: this.props.store.isMobile() ? 'mobile' : 'desktop'
11147
11169
  }, (0,preact_module.h)(ChatButton, {
@@ -11650,6 +11672,9 @@ class lib_Widget {
11650
11672
  logout(userref) {
11651
11673
  return this.store.logout(userref);
11652
11674
  }
11675
+ overrideBotId(botid) {
11676
+ this.store.overrideBotId(botid);
11677
+ }
11653
11678
  async init(param, $container) {
11654
11679
  param = param || {};
11655
11680
  let accid = param.account_id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.172",
3
+ "version": "4.1.174",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -13,10 +13,10 @@
13
13
  "@subiz/flow": "^1.1.0",
14
14
  "@subiz/wsclient": "^4.0.34",
15
15
  "cookie_js": "1.4.2",
16
- "core-js": "^3.45.0",
16
+ "core-js": "^3.45.1",
17
17
  "css-loader": "5.2.7",
18
18
  "file-loader": "^6.2.0",
19
- "less": "^4.4.0",
19
+ "less": "^4.4.1",
20
20
  "less-loader": "^12.3.0",
21
21
  "preact": "10.19.3"
22
22
  },
@@ -29,8 +29,8 @@
29
29
  "babel-loader": "^10.0.0",
30
30
  "babel-plugin-syntax-jsx": "^6.18.0",
31
31
  "html-webpack-plugin": "^5.6.4",
32
- "puppeteer": "^24.16.2",
33
- "webpack": "^5.101.2",
32
+ "puppeteer": "^24.17.0",
33
+ "webpack": "^5.101.3",
34
34
  "webpack-bundle-analyzer": "^4.10.2",
35
35
  "webpack-cli": "^6.0.1",
36
36
  "webpack-dev-server": "^5.2.2"
@@ -785,6 +785,7 @@ export default class Widget extends Com {
785
785
  let botid = cid.split('_')[0].slice(7) // 6 = len(cslight)
786
786
  let oldconvo = this.props.store.matchConvo(this.props.cid) || {}
787
787
  const {convo, error} = await this.props.store.startConvo({
788
+ state: 'active', // so it would not run through rule
788
789
  locale: this.props.t.locale(),
789
790
  message: text,
790
791
  members: [{type: 'bot', id: botid, bot_version: oldconvo.bot_version}],
package/src/lib.js CHANGED
@@ -74,6 +74,10 @@ class Widget {
74
74
  return this.store.logout(userref)
75
75
  }
76
76
 
77
+ overrideBotId (botid) {
78
+ this.store.overrideBotId(botid)
79
+ }
80
+
77
81
  async init(param, $container) {
78
82
  param = param || {}
79
83
  let accid = param.account_id
package/src/store/api.js CHANGED
@@ -357,8 +357,11 @@ export default class {
357
357
  updateUser = (data) => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}`, data)
358
358
 
359
359
  getUser = (_) => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`)
360
- getAccountSetting = () => {
360
+ getAccountSetting = (p) => {
361
361
  let href = sb.get(document, 'location.href') // send full href, this could be used to select which bot (ai-agent) should be returned
362
+ if (p && p.bot_id) {
363
+ return this.apireq.addQuery('url', href).addQuery('bot_id', p.bot_id).get(`/accounts/${this.accid}/settings`)
364
+ }
362
365
  return this.apireq.addQuery('url', href).get(`/accounts/${this.accid}/settings`)
363
366
  }
364
367
 
@@ -220,6 +220,12 @@ export default class Store {
220
220
  this.reconnect()
221
221
  }
222
222
 
223
+ async overrideBotId(botid) {
224
+ this.forceBotId = botid
225
+ await this.readyGate.entry()
226
+ //this.reconnect()
227
+ }
228
+
223
229
  async overrideChatbox(chatbox) {
224
230
  this.forceChatbox = chatbox
225
231
  await this.readyGate.entry()
@@ -689,7 +695,7 @@ export default class Store {
689
695
  this.markSync('account')
690
696
 
691
697
  let fetchuser = p && p.user ? Promise.resolve({body: p.user}) : this.api.getUser()
692
- let outs = await Promise.all([fetchuser, this.api.getAccountSetting()])
698
+ let outs = await Promise.all([fetchuser, this.api.getAccountSetting({bot_id: this.forceBotId})])
693
699
 
694
700
  let error = sb.find(outs, (out) => out.error)
695
701
  if (error) return console.error(error)
@@ -1343,6 +1349,7 @@ export default class Store {
1343
1349
 
1344
1350
  src = src.replace('https://file.mysubiz.com/', this.FileURL)
1345
1351
  src = src.replace('http://file.mysubiz.com/', this.FileURL)
1352
+ return src
1346
1353
  return src.replace('vcdn.subiz-cdn.com', 'cdn.subiz.net')
1347
1354
  }
1348
1355
 
@@ -253,7 +253,7 @@ XMLHttpRequest.prototype.send = function (body) {
253
253
  response: this.responseText,
254
254
  })
255
255
  }
256
- old(a, b, c)
256
+ if (typeof old == 'function') old(a, b, c)
257
257
  }
258
258
  return _originalSend.apply(this, arguments)
259
259
  }