@subiz/widget-v4 4.1.170 → 4.1.173

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 (44) hide show
  1. package/chat.js +18 -1
  2. package/compiled_src/chatbox/ChatButton.js +1 -0
  3. package/compiled_src/chatbox/main.js +13 -3
  4. package/compiled_src/lib.js +3 -0
  5. package/compiled_src/plugin.js +1 -0
  6. package/compiled_src/store/api.js +4 -1
  7. package/compiled_src/store/store.js +17 -10
  8. package/compiled_src/util/common.js +1 -1
  9. package/dist/198c50be7a7.app.js +1 -0
  10. package/dist/{198a92fcacc.chat.html → 198c50be7a7.chat.html} +1 -1
  11. package/dist/198c50be7a7.chat.js +1 -0
  12. package/dist/{198a92fcacc.form.html → 198c50be7a7.form.html} +1 -1
  13. package/dist/198c50be7a7.form.js +1 -0
  14. package/dist/{198a92fcacc.index.html → 198c50be7a7.index.html} +1 -1
  15. package/dist/{198a92fcacc.library.html → 198c50be7a7.library.html} +1 -1
  16. package/dist/198c50be7a7.library.js +1 -0
  17. package/dist/{198a92fcacc.preview.html → 198c50be7a7.preview.html} +1 -1
  18. package/dist/198c50be7a7.preview.js +1 -0
  19. package/dist/{198a92fcacc.chat.js → 198c50be7a7.webview.js} +1 -1
  20. package/dist/HASH +1 -1
  21. package/dist/screenshoot.js +46 -18
  22. package/package.json +2 -2
  23. package/src/chatbox/ChatButton.js +3 -0
  24. package/src/chatbox/main.js +13 -4
  25. package/src/lib.js +4 -0
  26. package/src/plugin.js +1 -0
  27. package/src/store/api.js +4 -1
  28. package/src/store/store.js +19 -13
  29. package/src/util/common.js +1 -1
  30. package/dist/198a92fcacc.app.js +0 -1
  31. package/dist/198a92fcacc.form.js +0 -1
  32. package/dist/198a92fcacc.library.js +0 -1
  33. package/dist/198a92fcacc.preview.js +0 -1
  34. package/dist/198a92fcacc.webview.js +0 -1
  35. /package/dist/{198a92fcacc.127.js → 198c50be7a7.127.js} +0 -0
  36. /package/dist/{198a92fcacc.132.js → 198c50be7a7.132.js} +0 -0
  37. /package/dist/{198a92fcacc.185.js → 198c50be7a7.185.js} +0 -0
  38. /package/dist/{198a92fcacc.27.js → 198c50be7a7.27.js} +0 -0
  39. /package/dist/{198a92fcacc.278.js → 198c50be7a7.278.js} +0 -0
  40. /package/dist/{198a92fcacc.339.js → 198c50be7a7.339.js} +0 -0
  41. /package/dist/{198a92fcacc.459.js → 198c50be7a7.459.js} +0 -0
  42. /package/dist/{198a92fcacc.490.js → 198c50be7a7.490.js} +0 -0
  43. /package/dist/{198a92fcacc.74.js → 198c50be7a7.74.js} +0 -0
  44. /package/dist/{198a92fcacc.997.js → 198c50be7a7.997.js} +0 -0
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 198a92fcacc
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, {
@@ -11310,6 +11332,7 @@ function Plugin(plugin, store, $container, lib) {
11310
11332
  var _this = this;
11311
11333
  this.getState = () => state;
11312
11334
  var run = async function () {
11335
+ if (typeof sbz_info != 'undefined') sbz_info[util/* default */.A.Date.now() + '.run'] = state;
11313
11336
  if (_destroy) return;
11314
11337
  if (state !== 'hold') return;
11315
11338
  if (plugin.type === 'popup' && store.isConverted(plugin.id)) return;
@@ -11317,6 +11340,7 @@ function Plugin(plugin, store, $container, lib) {
11317
11340
  if (plugin.type === 'chatbox' || plugin.type === 'notification') lastrun = undefined;
11318
11341
  if (!plugin.enabled) return;
11319
11342
  let match = util/* default */.A.checkRunConditions(plugin.initiative_frequency, plugin.conditions, lastrun, store);
11343
+ if (typeof sbz_info != 'undefined') sbz_info[util/* default */.A.Date.now() + '.run.match'] = match;
11320
11344
  if (!match) return;
11321
11345
  state = 'running';
11322
11346
  await _this.update(plugin);
@@ -11504,6 +11528,7 @@ class PluginMgr {
11504
11528
  });
11505
11529
  });
11506
11530
  let pluginM = this.lib.store.matchPlugin();
11531
+ if (typeof sbz_info != 'undefined') sbz_info['plugins'] = pluginM;
11507
11532
  let foundchatbox = false;
11508
11533
  util/* default */.A.each(pluginM, conf => {
11509
11534
  if (conf.type === 'chatbox') {
@@ -11647,6 +11672,9 @@ class lib_Widget {
11647
11672
  logout(userref) {
11648
11673
  return this.store.logout(userref);
11649
11674
  }
11675
+ overrideBotId(botid) {
11676
+ this.store.overrideBotId(botid);
11677
+ }
11650
11678
  async init(param, $container) {
11651
11679
  param = param || {};
11652
11680
  let accid = param.account_id;
@@ -11829,14 +11857,14 @@ class lib_Widget {
11829
11857
  }
11830
11858
  async showWidget(view, cid) {
11831
11859
  await this.domGate.entry();
11832
- this.pluginMgr.showCurrentChatbox({
11860
+ return this.pluginMgr.showCurrentChatbox({
11833
11861
  view,
11834
11862
  cid: cid
11835
11863
  });
11836
11864
  }
11837
11865
  async showTyping() {
11838
11866
  await this.domGate.entry();
11839
- this.pluginMgr.showCurrentChatboxTyping();
11867
+ return this.pluginMgr.showCurrentChatboxTyping();
11840
11868
  }
11841
11869
  async hideWidget() {
11842
11870
  await this.domGate.entry();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.170",
3
+ "version": "4.1.173",
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.4",
32
32
  "puppeteer": "^24.16.2",
33
- "webpack": "^5.101.1",
33
+ "webpack": "^5.101.2",
34
34
  "webpack-bundle-analyzer": "^4.10.2",
35
35
  "webpack-cli": "^6.0.1",
36
36
  "webpack-dev-server": "^5.2.2"
@@ -266,6 +266,8 @@ export default class ChatButton extends Com {
266
266
  }
267
267
 
268
268
  renderButton() {
269
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_button = sb.Date.now()
270
+
269
271
  let accountSetting = this.props.plugin.chatbox
270
272
  accountSetting = this.fixMissingSetting(accountSetting)
271
273
  let imgsrc =
@@ -369,6 +371,7 @@ export default class ChatButton extends Com {
369
371
  height: ${imgheight - 4}px !important;
370
372
 
371
373
  `
374
+
372
375
  return (
373
376
  <div class={cls} onClick={(e) => this.onClick(e)}>
374
377
  <div class={whitebgcls} style={whiteBgStyle}></div>
@@ -73,10 +73,19 @@ export default class Main extends Com {
73
73
  }
74
74
 
75
75
  render() {
76
- if (!this.state.cssready) return null
77
- if (sb.isUserBanned(this.props.store.matchUser())) return null
78
- if (!this.props.t) return null
79
-
76
+ if (!this.state.cssready) {
77
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_css_not_ready = sb.Date.now()
78
+ return null
79
+ }
80
+ if (sb.isUserBanned(this.props.store.matchUser())) {
81
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_user_is_banned = sb.Date.now()
82
+ return null
83
+ }
84
+ if (!this.props.t) {
85
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_no_t = sb.Date.now()
86
+ return null
87
+ }
88
+ if (typeof sbz_info != 'undefined') sbz_info.render_chatbox_main = sb.Date.now()
80
89
  return (
81
90
  <div class={this.props.store.isMobile() ? 'mobile' : 'desktop'}>
82
91
  <ChatButton
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/plugin.js CHANGED
@@ -255,6 +255,7 @@ export default class PluginMgr {
255
255
  })
256
256
 
257
257
  let pluginM = this.lib.store.matchPlugin()
258
+ if (typeof sbz_info != 'undefined') sbz_info['plugins'] = pluginM
258
259
  let foundchatbox = false
259
260
  sb.each(pluginM, (conf) => {
260
261
  if (conf.type === 'chatbox') {
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)
@@ -980,21 +986,20 @@ export default class Store {
980
986
  this.pubsub.publish('events', oldev)
981
987
  }
982
988
 
983
- if (ev.type === 'message_sent') {
984
- let idemkey = sb.get(ev, 'data.message.idempotency_key')
985
- let found = sb.find(this.listEvents(cid), (oldev) => oldev.id === idemkey)
986
- if (found) {
987
- // keeping old created so the ui can be static
988
- this.chain.del(cid, found.id)
989
- ev.created = found.created
990
- }
991
-
992
- convo.last_message_sent = ev
993
- }
994
-
995
989
  // dont store pong and typing
996
990
  if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {
997
991
  this.chain.put(cid, ev.id, sb.getMs(ev.created), ev)
992
+ if (ev.type === 'message_sent') {
993
+ let idemkey = sb.get(ev, 'data.message.idempotency_key')
994
+ let found = sb.find(this.listEvents(cid), (oldev) => oldev.id === idemkey)
995
+ if (found) {
996
+ // keeping old created so the ui can be static
997
+ this.chain.del(cid, found.id)
998
+ ev.created = found.created
999
+ }
1000
+
1001
+ convo.last_message_sent = ev
1002
+ }
998
1003
  }
999
1004
  this._setConvo(convo)
1000
1005
  this.pubsub.publish('account')
@@ -1344,6 +1349,7 @@ export default class Store {
1344
1349
 
1345
1350
  src = src.replace('https://file.mysubiz.com/', this.FileURL)
1346
1351
  src = src.replace('http://file.mysubiz.com/', this.FileURL)
1352
+ return src
1347
1353
  return src.replace('vcdn.subiz-cdn.com', 'cdn.subiz.net')
1348
1354
  }
1349
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
  }