@subiz/widget-v4 4.1.204 → 4.1.205

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 (38) hide show
  1. package/compiled_src/chatbox/Widget.js +5 -1
  2. package/compiled_src/chatbox/main.js +11 -1
  3. package/compiled_src/plugin.js +4 -1
  4. package/dist/{19e1c4525c1.27.js → 1a046b44d1d.27.js} +1 -1
  5. package/dist/{19e1c4525c1.339.js → 1a046b44d1d.339.js} +1 -1
  6. package/dist/{19e1c4525c1.459.js → 1a046b44d1d.459.js} +1 -1
  7. package/dist/1a046b44d1d.app.js +1 -0
  8. package/dist/{19e1c4525c1.chat.html → 1a046b44d1d.chat.html} +1 -1
  9. package/dist/1a046b44d1d.chat.js +1 -0
  10. package/dist/{19e1c4525c1.form.html → 1a046b44d1d.form.html} +1 -1
  11. package/dist/1a046b44d1d.form.js +1 -0
  12. package/dist/{19e1c4525c1.index.html → 1a046b44d1d.index.html} +1 -1
  13. package/dist/{19e1c4525c1.library.html → 1a046b44d1d.library.html} +1 -1
  14. package/dist/1a046b44d1d.library.js +1 -0
  15. package/dist/{19e1c4525c1.preview.html → 1a046b44d1d.preview.html} +1 -1
  16. package/dist/1a046b44d1d.preview.js +1 -0
  17. package/dist/1a046b44d1d.webview.js +1 -0
  18. package/dist/27.js +1 -1
  19. package/dist/459.js +1 -1
  20. package/dist/HASH +1 -1
  21. package/dist/screenshoot.js +63 -25
  22. package/package.json +2 -2
  23. package/src/chatbox/Widget.js +5 -1
  24. package/src/chatbox/main.js +13 -1
  25. package/src/plugin.js +5 -1
  26. package/dist/19e1c4525c1.app.js +0 -1
  27. package/dist/19e1c4525c1.chat.js +0 -1
  28. package/dist/19e1c4525c1.form.js +0 -1
  29. package/dist/19e1c4525c1.library.js +0 -1
  30. package/dist/19e1c4525c1.preview.js +0 -1
  31. package/dist/19e1c4525c1.webview.js +0 -1
  32. /package/dist/{19e1c4525c1.127.js → 1a046b44d1d.127.js} +0 -0
  33. /package/dist/{19e1c4525c1.132.js → 1a046b44d1d.132.js} +0 -0
  34. /package/dist/{19e1c4525c1.185.js → 1a046b44d1d.185.js} +0 -0
  35. /package/dist/{19e1c4525c1.278.js → 1a046b44d1d.278.js} +0 -0
  36. /package/dist/{19e1c4525c1.490.js → 1a046b44d1d.490.js} +0 -0
  37. /package/dist/{19e1c4525c1.74.js → 1a046b44d1d.74.js} +0 -0
  38. /package/dist/{19e1c4525c1.997.js → 1a046b44d1d.997.js} +0 -0
@@ -1282,7 +1282,7 @@ __webpack_require__.r(__webpack_exports__);
1282
1282
  window.cancelAnimationFrame(this.animationframe);
1283
1283
  }
1284
1284
  });
1285
- (Object.getOwnPropertyDescriptor(__WEBPACK_DEFAULT_EXPORT__, "name") || {}).writable || Object.defineProperty(__WEBPACK_DEFAULT_EXPORT__, "name", { value: "default", configurable: true });
1285
+ __webpack_require__.dn(__WEBPACK_DEFAULT_EXPORT__);
1286
1286
  function linearTransform(from, to, t, duration) {
1287
1287
  if (eqFloat(from, to)) return from;
1288
1288
  var s = to - from;
@@ -4121,6 +4121,14 @@ var n,l,u,t,i,o,r,f,e,c={},s=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine
4121
4121
  /******/ };
4122
4122
  /******/ })();
4123
4123
  /******/
4124
+ /******/ /* webpack/runtime/set anonymous default export name */
4125
+ /******/ (() => {
4126
+ /******/ // set .name for anonymous default exports per ES spec
4127
+ /******/ __webpack_require__.dn = (x) => {
4128
+ /******/ (Object.getOwnPropertyDescriptor(x, "name") || {}).writable || Object.defineProperty(x, "name", { value: "default", configurable: true });
4129
+ /******/ };
4130
+ /******/ })();
4131
+ /******/
4124
4132
  /******/ /* webpack/runtime/publicPath */
4125
4133
  /******/ (() => {
4126
4134
  /******/ __webpack_require__.p = "./";
@@ -4600,7 +4608,7 @@ let trackResponseFn = (param, done) => {
4600
4608
  });
4601
4609
  }
4602
4610
  });
4603
- (Object.getOwnPropertyDescriptor(api, "name") || {}).writable || Object.defineProperty(api, "name", { value: "default", configurable: true });
4611
+ __webpack_require__.dn(api);
4604
4612
  function fallbackGCSUrl(url) {
4605
4613
  try {
4606
4614
  const u = new URL(url);
@@ -4675,7 +4683,7 @@ const LIMIT = 80;
4675
4683
  });
4676
4684
  }
4677
4685
  });
4678
- (Object.getOwnPropertyDescriptor(lsdb, "name") || {}).writable || Object.defineProperty(lsdb, "name", { value: "default", configurable: true });
4686
+ __webpack_require__.dn(lsdb);
4679
4687
  function lsdb_toString(obj) {
4680
4688
  if (obj === undefined) return 'null';
4681
4689
  return JSON.stringify(obj);
@@ -4980,7 +4988,7 @@ let KvMaxSize = 500;
4980
4988
  this.initialized = false;
4981
4989
  }
4982
4990
  });
4983
- (Object.getOwnPropertyDescriptor(kv, "name") || {}).writable || Object.defineProperty(kv, "name", { value: "default", configurable: true });
4991
+ __webpack_require__.dn(kv);
4984
4992
  ;// ./src/store/api_fake.js
4985
4993
  function api_fake_defineProperty(e, r, t) { return (r = api_fake_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4986
4994
  function api_fake_toPropertyKey(t) { var i = api_fake_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
@@ -5071,7 +5079,7 @@ const OK200 = Promise.resolve({
5071
5079
  };
5072
5080
  }
5073
5081
  });
5074
- (Object.getOwnPropertyDescriptor(api_fake, "name") || {}).writable || Object.defineProperty(api_fake, "name", { value: "default", configurable: true });
5082
+ __webpack_require__.dn(api_fake);
5075
5083
  function makeFakeConvo(accid, convoid, userid, agentid) {
5076
5084
  let inteid = accid + '.subizv4.subikon';
5077
5085
  return {
@@ -5370,7 +5378,7 @@ function makeFakeMessages(accid, convoid, userid, agentid) {
5370
5378
  }
5371
5379
  reconnect() {}
5372
5380
  });
5373
- (Object.getOwnPropertyDescriptor(realtime_fake, "name") || {}).writable || Object.defineProperty(realtime_fake, "name", { value: "default", configurable: true });
5381
+ __webpack_require__.dn(realtime_fake);
5374
5382
  ;// ./src/store/store.js
5375
5383
  function store_defineProperty(e, r, t) { return (r = store_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5376
5384
  function store_toPropertyKey(t) { var i = store_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
@@ -5543,14 +5551,14 @@ class Store {
5543
5551
  store_defineProperty(this, "checkFormToken", (accid, token) => this.api.checkFormToken(accid, token));
5544
5552
  store_defineProperty(this, "submitForm2", (accid, token, data) => this.api.submitForm2(accid, token, data));
5545
5553
  store_defineProperty(this, "sendPresence", util/* default */.A.throttle(async () => {
5554
+ if (!this._track_page_view) return;
5546
5555
  if (this._die) return dieErr;
5547
5556
  await this.readyGate.entry();
5548
5557
  if (!util/* default */.A.get(this.cache.match('user'), 'id')) return;
5549
5558
  if (util/* default */.A.isUserBanned(this.cache.match('user'))) return;
5550
- if (!this._track_page_view) return;
5551
5559
  let hasfocus = this.browserVisibility === 'visible' && document.hasFocus();
5552
5560
  if (!hasfocus) return this.api.sendLostFocus();
5553
- this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
5561
+ this.sendPageview();
5554
5562
  }, 1000, {
5555
5563
  leading: false
5556
5564
  }));
@@ -5644,6 +5652,13 @@ class Store {
5644
5652
  this.sendPresence();
5645
5653
  });
5646
5654
  window.addEventListener('beforeunload', () => this.api.sendLostFocus());
5655
+ this._lastPresenceURL = window.location.href;
5656
+ this._urlCheckInterval = util/* default */.A.setInterval(() => {
5657
+ if (this._die) return util/* default */.A.clearInterval(this._urlCheckInterval);
5658
+ if (this._lastPresenceURL === window.location.href) return;
5659
+ this._lastPresenceURL = window.location.href;
5660
+ this.sendPresence();
5661
+ }, 2_000);
5647
5662
  this.doNotStartBot = () => {
5648
5663
  this._donotstartbot = true;
5649
5664
  };
@@ -6165,12 +6180,20 @@ class Store {
6165
6180
  this.cache.put('payment_methods', pms);
6166
6181
  this.pubsub.publish('account');
6167
6182
  }
6183
+ async sendPageview(p) {
6184
+ if (!p) p = {};
6185
+ let device = Object.assign({}, this.device);
6186
+ if (p.referrer) device.source_referrer = p.referrer;
6187
+ device.page_url = p.url || location.href;
6188
+ device.page_title = p.title || document.title;
6189
+ return this.api.sendContentView(device, p.url || location.href, p.title || document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
6190
+ }
6168
6191
  async track(e) {
6169
6192
  if (!e) {
6170
- let out = await this.api.sendContentView(this.device, location.href, document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);
6193
+ let out = await this.sendPageview();
6171
6194
  let traffic_source = util/* default */.A.get(out, 'body.by.device.source', '');
6172
6195
  if (traffic_source) this.kv.put('traffic_source', traffic_source);
6173
- return;
6196
+ return out;
6174
6197
  }
6175
6198
  if (typeof e === 'object') {
6176
6199
  if (!e.data) e.data = {};
@@ -6679,6 +6702,7 @@ class Store {
6679
6702
  this._die = true;
6680
6703
  this.clearBrowserData();
6681
6704
  util/* default */.A.clearInterval(this._seenInterval);
6705
+ util/* default */.A.clearInterval(this._urlCheckInterval);
6682
6706
  if (this.realtime) this.realtime.stop();
6683
6707
  this.readyGate.close();
6684
6708
  window.removeEventListener('blur', this.sendPresence);
@@ -11297,9 +11321,13 @@ class Widget extends common/* Com */.Mw {
11297
11321
  });
11298
11322
  }
11299
11323
  return (0,preact_module.h)("div", {
11300
- class: cls
11324
+ class: cls,
11325
+ onClick: this.onBgClick
11301
11326
  }, $header, $body);
11302
11327
  }
11328
+ onBgClick(event) {
11329
+ event.stopPropagation();
11330
+ }
11303
11331
  validateForm(formData) {
11304
11332
  let newformdata = {};
11305
11333
  util/* default */.A.map(formData, (field, key) => {
@@ -12403,6 +12431,14 @@ class Main extends common/* Com */.Mw {
12403
12431
  this.props.store.updateLastview(newView);
12404
12432
  this.forceUpdate();
12405
12433
  }
12434
+ getCurrentView() {
12435
+ let lastview = this.props.store.matchLastview() || {};
12436
+ return {
12437
+ is_show_widget: util/* default */.A.get(lastview, 'screen') === 'widget',
12438
+ view: util/* default */.A.get(lastview, 'view', ''),
12439
+ conversation_id: util/* default */.A.get(lastview, 'opts.cid', '')
12440
+ };
12441
+ }
12406
12442
  applyMessage(text) {
12407
12443
  this.refWidget.current && this.refWidget.current.applyMessage(text);
12408
12444
  }
@@ -12563,7 +12599,10 @@ function Plugin(plugin, store, $container, lib) {
12563
12599
  }
12564
12600
  domGate.open();
12565
12601
  };
12566
- this.call = (method, param) => domGate.entry().then(() => _ref.current[method](param));
12602
+ this.call = (method, param) => domGate.entry().then(() => {
12603
+ if (!_ref.current || typeof _ref.current[method] !== 'function') return;
12604
+ return _ref.current[method](param);
12605
+ });
12567
12606
  var _destroy = false;
12568
12607
  this.destroy = () => {
12569
12608
  _destroy = true;
@@ -12776,21 +12815,11 @@ class lib_Widget {
12776
12815
  lib_defineProperty(this, "setViewingProduct", p => this.store.linkProduct(p));
12777
12816
  lib_defineProperty(this, "getViewingProduct", () => this.store.getLinkedProduct());
12778
12817
  lib_defineProperty(this, "track", v => this.store.track(v));
12779
- lib_defineProperty(this, "event", async v => {
12818
+ lib_defineProperty(this, "event", async (type, payload, options) => {
12780
12819
  await this.store.readyGate.entry();
12781
- return this.store.api.sendEvent(v);
12782
- });
12783
- lib_defineProperty(this, "pageview", v => {
12784
- v = v || {};
12785
- return this.event({
12786
- type: 'content_viewed',
12787
- payload: {
12788
- url: v.url || location.href,
12789
- title: v.title || document.title,
12790
- referrer: v.referrer || document.referrer
12791
- }
12792
- });
12820
+ return this.store.api.sendEvent(normalizeCdpEvent(type, payload, options));
12793
12821
  });
12822
+ lib_defineProperty(this, "pageview", v => this.store.sendPageview(v));
12794
12823
  this.impressionTokens = {};
12795
12824
  this.domGate = new util/* default */.A.Gate();
12796
12825
  this.store = new Store(ApiURL, FileURL, RealtimeURL, inmem, fake);
@@ -13134,6 +13163,15 @@ class lib_Widget {
13134
13163
  this.store.doNotStartBot();
13135
13164
  }
13136
13165
  }
13166
+ function normalizeCdpEvent(type, payload, options) {
13167
+ if (type && typeof type === 'object') return type;
13168
+ let data = {
13169
+ type: type
13170
+ };
13171
+ if (payload !== undefined) data.payload = payload;
13172
+ if (options && typeof options === 'object') data = Object.assign({}, options, data);
13173
+ return data;
13174
+ }
13137
13175
  window.__sbz_WIDGET = lib_Widget;
13138
13176
  /* harmony default export */ const lib = (lib_Widget);
13139
13177
  ;// ./screenshoot.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.204",
3
+ "version": "4.1.205",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -21,7 +21,6 @@
21
21
  "preact": "10.19.3"
22
22
  },
23
23
  "devDependencies": {
24
- "tape": "^5.9.0",
25
24
  "@babel/cli": "^7.28.6",
26
25
  "@babel/core": "^7.29.0",
27
26
  "@babel/plugin-proposal-class-properties": "^7.18.6",
@@ -31,6 +30,7 @@
31
30
  "babel-plugin-syntax-jsx": "^6.18.0",
32
31
  "html-webpack-plugin": "^5.6.7",
33
32
  "puppeteer": "^25.0.4",
33
+ "tape": "^5.9.0",
34
34
  "webpack": "^5.107.1",
35
35
  "webpack-bundle-analyzer": "^5.3.0",
36
36
  "webpack-cli": "^7.0.2",
@@ -207,13 +207,17 @@ export default class Widget extends Com {
207
207
  )
208
208
  }
209
209
  return (
210
- <div class={cls}>
210
+ <div class={cls} onClick={this.onBgClick}>
211
211
  {$header}
212
212
  {$body}
213
213
  </div>
214
214
  )
215
215
  }
216
216
 
217
+ onBgClick(event) {
218
+ event.stopPropagation()
219
+ }
220
+
217
221
  validateForm(formData) {
218
222
  let newformdata = {}
219
223
  sb.map(formData, (field, key) => {
@@ -32,7 +32,10 @@ export default class Main extends Com {
32
32
  let margin_y = sb.get(chatbox, 'desktop_button.margin_y')
33
33
  chatbox.desktop_widget_max_height = margin_y ? `calc(100% - ${margin_y + 10}px)` : 'calc(100% - 40px)'
34
34
  const PREVIEW_MAX_WIDTH = 340
35
- chatbox.preview_max_width = Math.min(PREVIEW_MAX_WIDTH, chatbox.width) + 'px'
35
+ let previewMaxWidthVal = Math.min(PREVIEW_MAX_WIDTH, chatbox.width)
36
+ // avoid NaN when chatbox.width is undefined or null
37
+ if (Number.isNaN(previewMaxWidthVal) || !previewMaxWidthVal) previewMaxWidthVal = PREVIEW_MAX_WIDTH
38
+ chatbox.preview_max_width = previewMaxWidthVal + 'px'
36
39
  var outcss = sb.replaceCssVariable(css, chatbox)
37
40
  sb.setCss(this.props.plugin.id, this.$cssStyleDiv, outcss)
38
41
  }
@@ -198,6 +201,15 @@ export default class Main extends Com {
198
201
  this.forceUpdate()
199
202
  }
200
203
 
204
+ getCurrentView() {
205
+ let lastview = this.props.store.matchLastview() || {}
206
+ return {
207
+ is_show_widget: sb.get(lastview, 'screen') === 'widget',
208
+ view: sb.get(lastview, 'view', ''),
209
+ conversation_id: sb.get(lastview, 'opts.cid', ''),
210
+ }
211
+ }
212
+
201
213
  applyMessage(text) {
202
214
  this.refWidget.current && this.refWidget.current.applyMessage(text)
203
215
  }
package/src/plugin.js CHANGED
@@ -115,7 +115,11 @@ function Plugin(plugin, store, $container, lib) {
115
115
  domGate.open()
116
116
  }
117
117
 
118
- this.call = (method, param) => domGate.entry().then(() => _ref.current[method](param))
118
+ this.call = (method, param) =>
119
+ domGate.entry().then(() => {
120
+ if (!_ref.current || typeof _ref.current[method] !== 'function') return
121
+ return _ref.current[method](param)
122
+ })
119
123
 
120
124
  var _destroy = false
121
125
  this.destroy = () => {