@subiz/widget-v4 4.1.87 → 4.1.89

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 (35) hide show
  1. package/compiled_src/chatbox/Widget.js +2 -1
  2. package/compiled_src/lib.js +20 -1
  3. package/compiled_src/store/store.js +6 -1
  4. package/compiled_src/util/common.js +1 -0
  5. package/dist/190ba49045c.app.js +1 -0
  6. package/dist/{190815938a3.index.html → 190ba49045c.index.html} +1 -1
  7. package/dist/{190815938a3.library.html → 190ba49045c.library.html} +1 -1
  8. package/dist/190ba49045c.library.js +1 -0
  9. package/dist/{190815938a3.preview.html → 190ba49045c.preview.html} +1 -1
  10. package/dist/190ba49045c.preview.js +1 -0
  11. package/dist/190ba49045c.screenshoot.js +1 -0
  12. package/dist/190ba49045c.webview.js +1 -0
  13. package/dist/HASH +1 -1
  14. package/dist/screenshoot.html +1 -1
  15. package/dist/screenshoot.js +32 -6
  16. package/loader.js +4 -1
  17. package/package.json +6 -6
  18. package/src/chatbox/Widget.js +4 -3
  19. package/src/lib.js +21 -1
  20. package/src/store/store.js +7 -1
  21. package/src/util/common.js +1 -0
  22. package/dist/190815938a3.app.js +0 -1
  23. package/dist/190815938a3.library.js +0 -1
  24. package/dist/190815938a3.preview.js +0 -1
  25. package/dist/190815938a3.screenshoot.js +0 -1
  26. package/dist/190815938a3.webview.js +0 -1
  27. /package/dist/{190815938a3.127.js → 190ba49045c.127.js} +0 -0
  28. /package/dist/{190815938a3.132.js → 190ba49045c.132.js} +0 -0
  29. /package/dist/{190815938a3.185.js → 190ba49045c.185.js} +0 -0
  30. /package/dist/{190815938a3.27.js → 190ba49045c.27.js} +0 -0
  31. /package/dist/{190815938a3.278.js → 190ba49045c.278.js} +0 -0
  32. /package/dist/{190815938a3.459.js → 190ba49045c.459.js} +0 -0
  33. /package/dist/{190815938a3.490.js → 190ba49045c.490.js} +0 -0
  34. /package/dist/{190815938a3.74.js → 190ba49045c.74.js} +0 -0
  35. /package/dist/{190815938a3.997.js → 190ba49045c.997.js} +0 -0
@@ -2709,6 +2709,7 @@ function checkRunConditions(freq, conds, lastrun, store) {
2709
2709
  }
2710
2710
  break;
2711
2711
  case 'user_attribute':
2712
+ case 'user':
2712
2713
  let userprop;
2713
2714
  let attrs = op.get(store.matchUser(), 'attributes', []);
2714
2715
  let operator = op.get(cond, 'user.operator');
@@ -4899,10 +4900,15 @@ class Store {
4899
4900
  await this.readyGate.entry();
4900
4901
  if (!this.isInsync('account')) this.reconnect();
4901
4902
  }
4902
- async init(accid, mask, userRef) {
4903
+ async init(accid, mask, userRef, options) {
4903
4904
  this.readyGate.close();
4904
4905
  accid = (accid || '').trim();
4905
4906
  this.g_sync = {};
4907
+ if (!options || !options.use_subdomain_cookie) {
4908
+ if (window && window.location && window.location.hostname) {
4909
+ cookie.defaults.domain = '.' + window.location.hostname;
4910
+ }
4911
+ }
4906
4912
  if (!userRef) {
4907
4913
  try {
4908
4914
  userRef = this.cookie.get('__sbref', '');
@@ -5103,7 +5109,7 @@ class Store {
5103
5109
  setting = util/* default */.A.cloneDeep(setting) || {};
5104
5110
  setting.account = Object.assign({}, setting.account, this.forceAcc);
5105
5111
  if (!setting.account.logo_url) {
5106
- setting.account.logo_url = 'https://file-subiz.com/fiqpezhkmeyesdscyetk-default_logo.jpg';
5112
+ setting.account.logo_url = 'https://vcdn.subiz-cdn.com/file/fiqpezhkmeyesdscyetk-default_logo.jpg';
5107
5113
  }
5108
5114
  if (setting.user) {
5109
5115
  setting.user.account_id = setting.account.id;
@@ -8795,7 +8801,7 @@ var empty = __webpack_require__(9419);
8795
8801
  let Order = false;
8796
8802
  const LoadOrder = () => __webpack_require__.e(/* import() */ 185).then(__webpack_require__.bind(__webpack_require__, 4185));
8797
8803
 
8798
- const Widget_defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
8804
+ const Widget_defaultAvatar = 'https://vcdn.subiz-cdn.com/file/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
8799
8805
 
8800
8806
 
8801
8807
 
@@ -9056,7 +9062,8 @@ class Widget extends common/* Com */.Mw {
9056
9062
  value: util/* default */.A.stringify(field.value)
9057
9063
  };
9058
9064
  });
9059
- this.props.store.submitForm('chatbox_' + formName, formData, user);
9065
+ await this.props.store.submitForm('chatbox_' + formName, formData, user);
9066
+ await util/* default */.A.sleep(500);
9060
9067
  if (_creating != this._creating) return;
9061
9068
  if (this.props.cid) {
9062
9069
  this.setState({
@@ -10380,7 +10387,7 @@ class lib_Widget {
10380
10387
  param = param || {};
10381
10388
  let accid = param.account_id;
10382
10389
  let ref = param.ref;
10383
- let user = await this.store.init(accid, undefined, ref);
10390
+ let user = await this.store.init(accid, undefined, ref, param);
10384
10391
  util/* default */.A.setTimeout(() => window.postMessage({
10385
10392
  type: 'widget_loaded',
10386
10393
  account_id: accid
@@ -10395,6 +10402,25 @@ class lib_Widget {
10395
10402
  this.domGate.open();
10396
10403
  return user;
10397
10404
  }
10405
+ async start(param, $container, mask, cb) {
10406
+ param = param || {};
10407
+ let id = param.account_id;
10408
+ let outmask = await this.store.init(id, mask, param.ref, param);
10409
+ util/* default */.A.setTimeout(() => window.postMessage({
10410
+ type: 'widget_loaded',
10411
+ account_id: id
10412
+ }, '*'), 0);
10413
+ if (!$container) $container = document.body || document;
10414
+ this.pluginMgr = new PluginMgr(this, $container);
10415
+ let clean = util/* default */.A.setInterval(() => {
10416
+ if ($container && $container.isConnected) return;
10417
+ this.pluginMgr.destroy();
10418
+ util/* default */.A.clearInterval(clean);
10419
+ }, 1000);
10420
+ this.domGate.open();
10421
+ cb && cb(outmask);
10422
+ return outmask;
10423
+ }
10398
10424
  async setAccount(id, $container, mask, cb) {
10399
10425
  let outmask = await this.store.init(id, mask);
10400
10426
  util/* default */.A.setTimeout(() => window.postMessage({
@@ -10580,7 +10606,7 @@ window.__sbz_WIDGET = lib_Widget;
10580
10606
  ;// CONCATENATED MODULE: ./screenshoot.js
10581
10607
 
10582
10608
  let accid = 'acqsulrowbxiugvginhw';
10583
- let widget = new lib('https://api.subiz.com.vn/4.0/', 'https://file-subiz.com/', 'https://rt-0.subiz.com.vn/', true, true);
10609
+ let widget = new lib('https://api.subiz.com.vn/4.0/', 'https://vcdn.subiz-cdn.com/file/', 'https://api.subiz.com.vn/rt/0/', true, true);
10584
10610
  function main() {
10585
10611
  var $div = document.createElement('div');
10586
10612
  document.body.appendChild($div);
package/loader.js CHANGED
@@ -80,4 +80,7 @@ subizc2oasp.com
80
80
  // minify using UglifyJS 3 at https://jscompress.com
81
81
  !function(i,s,a,e,c){var o,t,r,u;i[e]||(i._sbzaccid=c,i[e]=function(){i[e].q.push(arguments)},i[e].q=[],i[e]("setAccount",c),r=["widget.subiz.net","storage.googleapis"+(t=".com"),"app.sbz.workers.dev",e+"a"+(o=function(e,t){var n=t<=6?5:o(e,t-1)+o(e,t-3);return e!==t?n:n.toString(32)})(20,20)+t,e+"b"+o(30,30)+t,e+"c"+o(40,40)+t],(u=function(e){var t,n;i._subiz_init_2094850928430||r[e]&&(t=s.createElement(a),n=s.getElementsByTagName(a)[0],t.async=1,t.src="https://"+r[e]+"/sbz/app.js?accid="+c,n.parentNode.insertBefore(t,n),setTimeout(u,2e3,e+1))})(0))}(window,document,"script","subiz","acpxkgumifuoofoosble");
82
82
 
83
- !function(i,s,a,e,z){var o,t,r,u;i[e]||(i._sbzaccid=z,i[e]=function(){i[e].q.push(arguments)},i[e].q=[],i[e]("setAccount",z),r=["widget.subiz.net","storage.googleapis"+(t=".com"),"app.sbz.workers.dev",e+"a"+(o=function(e,t){var n=t<=6?5:o(e,t-1)+o(e,t-3);return e!==t?n:n.toString(32)})(20,20)+t,e+"b"+o(30,30)+t,e+"c"+o(40,40)+t],(u=function(e){var t,n;i._subiz_init_2094850928430||r[e]&&(t=s.createElement(a),n=s.getElementsByTagName(a)[0],t.async=1,t.src="https://"+r[e]+"/sbz/app.js?accid="+,n.parentNode.insertBefore(t,n),setTimeout(u,2e3,e+1))})(0))}(window,document,"script","subiz","acpxkgumifuoofoosble");
83
+
84
+
85
+ !function(i,s,a,e,c){var o,t,r,u;i[e]||(i._sbzaccid=c,i[e]=function(){i[e].q.push(arguments)},i[e].q=[],r=["widget.subiz.net","storage.googleapis"+(t=".com"),"app.sbz.workers.dev",e+"a"+(o=function(e,t){var n=t<=6?5:o(e,t-1)+o(e,t-3);return e!==t?n:n.toString(32)})(20,20)+t,e+"b"+o(30,30)+t,e+"c"+o(40,40)+t],(u=function(e){var t,n;i._subiz_init_2094850928430||r[e]&&(t=s.createElement(a),n=s.getElementsByTagName(a)[0],t.async=1,t.src="https://"+r[e]+"/sbz/app.js?accid="+c,n.parentNode.insertBefore(t,n),setTimeout(u,2e3,e+1))})(0))}(window,document,"script","subiz","acpxkgumifuoofoosble");
86
+ subiz('load', {account_id: 'acpxkgumifuoofoosble', use_subdomain_cookie: true})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.87",
3
+ "version": "4.1.89",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -22,16 +22,16 @@
22
22
  "preact": "10.19.3"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/cli": "^7.24.7",
26
- "@babel/core": "^7.24.7",
25
+ "@babel/cli": "^7.24.8",
26
+ "@babel/core": "^7.24.9",
27
27
  "@babel/plugin-proposal-class-properties": "^7.18.6",
28
28
  "@babel/plugin-transform-react-jsx": "^7.24.7",
29
- "@babel/preset-env": "^7.24.7",
29
+ "@babel/preset-env": "^7.24.8",
30
30
  "babel-loader": "^9.1.3",
31
31
  "babel-plugin-syntax-jsx": "^6.18.0",
32
32
  "html-webpack-plugin": "^5.6.0",
33
- "puppeteer": "^22.12.1",
34
- "webpack": "^5.92.1",
33
+ "puppeteer": "^22.13.0",
34
+ "webpack": "^5.93.0",
35
35
  "webpack-bundle-analyzer": "^4.10.2",
36
36
  "webpack-cli": "^5.1.4",
37
37
  "webpack-dev-server": "^5.0.4"
@@ -87,8 +87,7 @@ export default class Widget extends Com {
87
87
  if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form
88
88
 
89
89
  if (!this.hasSentMessage(this.props.cid) && form && (sb.size(form.groups) || form.group_required)) return true
90
-
91
- let formRequired = this.isFormRequired()
90
+ let formRequired = this.isFormRequired() // nhap thieu truong require
92
91
  return (formRequired && !this.props.cid) || (formRequired && this.props.cid && this.state.clickedJoin)
93
92
  }
94
93
 
@@ -225,7 +224,9 @@ export default class Widget extends Com {
225
224
  let formData = sb.map(data, (field, key) => {
226
225
  return {key: key, type: field.type, value: sb.stringify(field.value)}
227
226
  })
228
- this.props.store.submitForm('chatbox_' + formName, formData, user)
227
+ await this.props.store.submitForm('chatbox_' + formName, formData, user)
228
+ // try to sleep so bot conditions with user attribute work
229
+ await sb.sleep(500)
229
230
 
230
231
  if (_creating != this._creating) return // outdated
231
232
  if (this.props.cid) {
package/src/lib.js CHANGED
@@ -70,7 +70,7 @@ class Widget {
70
70
  let accid = param.account_id
71
71
  let ref = param.ref
72
72
 
73
- let user = await this.store.init(accid, undefined, ref)
73
+ let user = await this.store.init(accid, undefined, ref, param)
74
74
  sb.setTimeout(() => window.postMessage({type: 'widget_loaded', account_id: accid}, '*'), 0) // send to chrome extension
75
75
 
76
76
  // add container to client site
@@ -87,6 +87,26 @@ class Widget {
87
87
  return user
88
88
  }
89
89
 
90
+ async start(param, $container, mask, cb) {
91
+ param = param || {}
92
+ let id = param.account_id
93
+ let outmask = await this.store.init(id, mask, param.ref, param)
94
+ sb.setTimeout(() => window.postMessage({type: 'widget_loaded', account_id: id}, '*'), 0) // send to chrome extension
95
+ // add container to client site
96
+ if (!$container) $container = document.body || document
97
+ this.pluginMgr = new PluginMgr(this, $container)
98
+
99
+ let clean = sb.setInterval(() => {
100
+ // check if the dom is deleted
101
+ if ($container && $container.isConnected) return
102
+ this.pluginMgr.destroy()
103
+ sb.clearInterval(clean)
104
+ }, 1000)
105
+ this.domGate.open()
106
+ cb && cb(outmask)
107
+ return outmask
108
+ }
109
+
90
110
  async setAccount(id, $container, mask, cb) {
91
111
  let outmask = await this.store.init(id, mask)
92
112
  sb.setTimeout(() => window.postMessage({type: 'widget_loaded', account_id: id}, '*'), 0) // send to chrome extension
@@ -407,11 +407,17 @@ export default class Store {
407
407
 
408
408
  now = () => sb.Date.now() + this.timeDiff // millisecond on server
409
409
 
410
- async init(accid, mask, userRef) {
410
+ async init(accid, mask, userRef, options) {
411
411
  this.readyGate.close()
412
412
  accid = (accid || '').trim()
413
413
  this.g_sync = {}
414
414
 
415
+ if (!options || !options.use_subdomain_cookie) {
416
+ if (window && window.location && window.location.hostname) {
417
+ cookie.defaults.domain = '.' + window.location.hostname
418
+ }
419
+ }
420
+
415
421
  if (!userRef) {
416
422
  // try to find userRef in cookie
417
423
  try {
@@ -918,6 +918,7 @@ export function checkRunConditions(freq, conds, lastrun, store) {
918
918
  }
919
919
  break
920
920
  case 'user_attribute':
921
+ case 'user':
921
922
  let userprop
922
923
  let attrs = op.get(store.matchUser(), 'attributes', [])
923
924
  let operator = op.get(cond, 'user.operator')