@subiz/widget-v4 4.1.165 → 4.1.166
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.
- package/compiled_src/chatbox/Event.js +2 -0
- package/compiled_src/store/store.js +20 -32
- package/dist/198a3614cdc.app.js +1 -0
- package/dist/{198a3089a0c.chat.html → 198a3614cdc.chat.html} +1 -1
- package/dist/198a3614cdc.chat.js +1 -0
- package/dist/{198a3089a0c.form.html → 198a3614cdc.form.html} +1 -1
- package/dist/198a3614cdc.form.js +1 -0
- package/dist/{198a3089a0c.index.html → 198a3614cdc.index.html} +1 -1
- package/dist/{198a3089a0c.library.html → 198a3614cdc.library.html} +1 -1
- package/dist/198a3614cdc.library.js +1 -0
- package/dist/{198a3089a0c.preview.html → 198a3614cdc.preview.html} +1 -1
- package/dist/198a3614cdc.preview.js +1 -0
- package/dist/198a3614cdc.webview.js +1 -0
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +39 -10
- package/inject.html +11 -2
- package/package.json +1 -1
- package/src/chatbox/Event.js +2 -1
- package/src/lib.js +0 -1
- package/src/store/store.js +24 -33
- package/dist/198a3089a0c.app.js +0 -1
- package/dist/198a3089a0c.chat.js +0 -1
- package/dist/198a3089a0c.form.js +0 -1
- package/dist/198a3089a0c.library.js +0 -1
- package/dist/198a3089a0c.preview.js +0 -1
- package/dist/198a3089a0c.webview.js +0 -1
- /package/dist/{198a3089a0c.127.js → 198a3614cdc.127.js} +0 -0
- /package/dist/{198a3089a0c.132.js → 198a3614cdc.132.js} +0 -0
- /package/dist/{198a3089a0c.185.js → 198a3614cdc.185.js} +0 -0
- /package/dist/{198a3089a0c.27.js → 198a3614cdc.27.js} +0 -0
- /package/dist/{198a3089a0c.278.js → 198a3614cdc.278.js} +0 -0
- /package/dist/{198a3089a0c.339.js → 198a3614cdc.339.js} +0 -0
- /package/dist/{198a3089a0c.459.js → 198a3614cdc.459.js} +0 -0
- /package/dist/{198a3089a0c.490.js → 198a3614cdc.490.js} +0 -0
- /package/dist/{198a3089a0c.74.js → 198a3614cdc.74.js} +0 -0
- /package/dist/{198a3089a0c.997.js → 198a3614cdc.997.js} +0 -0
package/dist/HASH
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
198a3614cdc
|
package/dist/screenshoot.js
CHANGED
|
@@ -420,6 +420,7 @@ module.exports = ajax
|
|
|
420
420
|
var localStorageMemory = {};
|
|
421
421
|
var cache = {};
|
|
422
422
|
localStorageMemory.length = 0;
|
|
423
|
+
localStorageMemory.cache = cache;
|
|
423
424
|
localStorageMemory.getItem = function (key) {
|
|
424
425
|
if (key in cache) return cache[key];
|
|
425
426
|
return null;
|
|
@@ -4093,10 +4094,14 @@ const LIMIT = 80;
|
|
|
4093
4094
|
}
|
|
4094
4095
|
}
|
|
4095
4096
|
clear(table) {
|
|
4097
|
+
var keys = [];
|
|
4096
4098
|
for (var i = 0; i < this.localStorage.length; i++) {
|
|
4097
4099
|
let key = this.localStorage.key(i);
|
|
4098
4100
|
if (!key.startsWith(this.schema + '#' + table + '#')) continue;
|
|
4099
|
-
|
|
4101
|
+
keys.push(key);
|
|
4102
|
+
}
|
|
4103
|
+
for (var i = 0; i < keys.length; i++) {
|
|
4104
|
+
this.localStorage.removeItem(keys[i]);
|
|
4100
4105
|
}
|
|
4101
4106
|
this.allkeys = {};
|
|
4102
4107
|
}
|
|
@@ -4823,6 +4828,7 @@ var cookie = __webpack_require__(5672);
|
|
|
4823
4828
|
cookie.defaults.path = '/';
|
|
4824
4829
|
cookie.expiresMultiplier = 60 * 60 * 24;
|
|
4825
4830
|
cookie.defaults.expires = 3650;
|
|
4831
|
+
let store_memlocalStorage = __webpack_require__(450);
|
|
4826
4832
|
const MAX_CONVO = 20;
|
|
4827
4833
|
const page_loaded = util/* default */.A.Date.now();
|
|
4828
4834
|
class Store {
|
|
@@ -4833,6 +4839,7 @@ class Store {
|
|
|
4833
4839
|
store_defineProperty(this, "_currentViewingProduct", {});
|
|
4834
4840
|
store_defineProperty(this, "new_visitor", true);
|
|
4835
4841
|
store_defineProperty(this, "matchUser", () => {
|
|
4842
|
+
if (!this.cache) return undefined;
|
|
4836
4843
|
this._touchAcc();
|
|
4837
4844
|
return this.cache.match('user');
|
|
4838
4845
|
});
|
|
@@ -4841,6 +4848,7 @@ class Store {
|
|
|
4841
4848
|
store_defineProperty(this, "matchPaymentMethods", () => this.cache.match('payment_methods'));
|
|
4842
4849
|
store_defineProperty(this, "matchUnread", () => {
|
|
4843
4850
|
let user = this.matchUser();
|
|
4851
|
+
if (!user || !user.id) return;
|
|
4844
4852
|
let allconvos = this.matchConvo('*');
|
|
4845
4853
|
let unreadcount = 0;
|
|
4846
4854
|
util/* default */.A.map(allconvos, convo => {
|
|
@@ -4971,6 +4979,7 @@ class Store {
|
|
|
4971
4979
|
this.seenQueue.push(id);
|
|
4972
4980
|
});
|
|
4973
4981
|
store_defineProperty(this, "onUpdate", (o, cb) => this.pubsub.on2(o, 'account', cb));
|
|
4982
|
+
store_defineProperty(this, "onDestroyed", (o, cb) => this.pubsub.on2(o, 'destroy', cb));
|
|
4974
4983
|
store_defineProperty(this, "onConnection", (o, cb) => this.pubsub.on2(o, 'connection', cb));
|
|
4975
4984
|
store_defineProperty(this, "onResetCSS", (o, cb) => this.pubsub.on2(o, 'resetCSS', cb));
|
|
4976
4985
|
store_defineProperty(this, "onHighlight", (o, cb) => this.pubsub.on2(o, 'highlight', cb));
|
|
@@ -5007,7 +5016,6 @@ class Store {
|
|
|
5007
5016
|
this.FileURL = FileURL;
|
|
5008
5017
|
this._track_page_view = true;
|
|
5009
5018
|
this.device_type = 'desktop';
|
|
5010
|
-
this.lightConvos = {};
|
|
5011
5019
|
if (this.fake) this.api = new api_fake(ApiURL, FileURL);else this.api = new api(ApiURL, FileURL);
|
|
5012
5020
|
if (!inmem) {
|
|
5013
5021
|
try {
|
|
@@ -5272,7 +5280,12 @@ class Store {
|
|
|
5272
5280
|
}
|
|
5273
5281
|
}
|
|
5274
5282
|
}
|
|
5275
|
-
if (this.cookie.get('__sbref', userRef) != userRef)
|
|
5283
|
+
if (this.cookie.get('__sbref', userRef) != userRef) {
|
|
5284
|
+
cleanMyLocalStorage();
|
|
5285
|
+
this.clearBrowserData();
|
|
5286
|
+
}
|
|
5287
|
+
this.lightConvos = {};
|
|
5288
|
+
this.cache = new kv(new lsdb('sbz2023', true), 'kv');
|
|
5276
5289
|
this.api.setAuth({
|
|
5277
5290
|
accid: accid
|
|
5278
5291
|
});
|
|
@@ -5345,6 +5358,7 @@ class Store {
|
|
|
5345
5358
|
util/* default */.A.clearInterval(this._seenInterval);
|
|
5346
5359
|
this._seenInterval = util/* default */.A.setInterval(() => {
|
|
5347
5360
|
if (this._die) return util/* default */.A.clearInterval(this._seenInterval);
|
|
5361
|
+
if (!this.cache) return;
|
|
5348
5362
|
this.seenQueue = [...new Set(this.seenQueue)];
|
|
5349
5363
|
let user = this.cache.match('user') || {};
|
|
5350
5364
|
util/* default */.A.map(this.seenQueue, id => {
|
|
@@ -5378,7 +5392,7 @@ class Store {
|
|
|
5378
5392
|
let user = this.matchUser();
|
|
5379
5393
|
if (!old) return;
|
|
5380
5394
|
let mem = util/* default */.A.find(old.members, mem => mem.type == 'user' && mem.id == user.id);
|
|
5381
|
-
mem.seen_at = this.now();
|
|
5395
|
+
if (mem) mem.seen_at = this.now();
|
|
5382
5396
|
this.kv.put('light_convos', this.lightConvos);
|
|
5383
5397
|
this.g_haveSentSeenM[lastmsgsent.id] = true;
|
|
5384
5398
|
return;
|
|
@@ -5951,7 +5965,7 @@ class Store {
|
|
|
5951
5965
|
async loopTime() {
|
|
5952
5966
|
if (this._die) return;
|
|
5953
5967
|
let startms = this.now();
|
|
5954
|
-
if (!util/* default */.A.get(this.cache.match('user'), 'id')) return util/* default */.A.setTimeout(() => this.loopTime(), 240000);
|
|
5968
|
+
if (!this.cache || !util/* default */.A.get(this.cache.match('user'), 'id')) return util/* default */.A.setTimeout(() => this.loopTime(), 240000);
|
|
5955
5969
|
let {
|
|
5956
5970
|
body: t,
|
|
5957
5971
|
error
|
|
@@ -5988,15 +6002,17 @@ class Store {
|
|
|
5988
6002
|
util/* default */.A.each(this.cookie.all(), (v, k) => {
|
|
5989
6003
|
if ((k || '').startsWith('__sb')) this.cookie.remove(k);
|
|
5990
6004
|
});
|
|
5991
|
-
this.kv.destroy();
|
|
6005
|
+
if (this.kv) this.kv.destroy();
|
|
5992
6006
|
this.kv = new kv(new lsdb('sbz2023', this.inmem), 'kv');
|
|
5993
|
-
this.chain.destroy();
|
|
6007
|
+
if (this.chain) this.chain.destroy();
|
|
5994
6008
|
this.chain = new Chain(new lsdb('cbz2023', true), 'ch');
|
|
6009
|
+
if (this.realtime) this.realtime.stop();
|
|
6010
|
+
if (this.cache) this.cache.destroy();
|
|
6011
|
+
this.pubsub.publish('destroy');
|
|
5995
6012
|
}
|
|
5996
6013
|
destroy() {
|
|
5997
6014
|
this._die = true;
|
|
5998
|
-
|
|
5999
|
-
if (this.chain) this.chain.destroy();
|
|
6015
|
+
this.clearBrowserData();
|
|
6000
6016
|
util/* default */.A.clearInterval(this._seenInterval);
|
|
6001
6017
|
if (this.realtime) this.realtime.stop();
|
|
6002
6018
|
this.readyGate.close();
|
|
@@ -6132,6 +6148,7 @@ let cleanLocalStorage = () => {
|
|
|
6132
6148
|
for (var key in localStorage) {
|
|
6133
6149
|
if (key && (key.startsWith('cbz2020') || key.startsWith('sbz2020'))) {
|
|
6134
6150
|
localStorage.removeItem(key);
|
|
6151
|
+
store_memlocalStorage.removeItem(key);
|
|
6135
6152
|
}
|
|
6136
6153
|
}
|
|
6137
6154
|
});
|
|
@@ -6146,6 +6163,7 @@ let cleanMyLocalStorage = () => {
|
|
|
6146
6163
|
for (var key in localStorage) {
|
|
6147
6164
|
if (key && (key.startsWith('cbz2020') || key.startsWith('sbz2020') || key.startsWith('sbz2022') || key.startsWith('sbz2023'))) {
|
|
6148
6165
|
localStorage.removeItem(key);
|
|
6166
|
+
store_memlocalStorage.removeItem(key);
|
|
6149
6167
|
}
|
|
6150
6168
|
}
|
|
6151
6169
|
});
|
|
@@ -6337,6 +6355,9 @@ class ChatButton extends common/* Com */.Mw {
|
|
|
6337
6355
|
let lastview = this.props.store.matchLastview();
|
|
6338
6356
|
if (util/* default */.A.get(lastview, 'view')) {
|
|
6339
6357
|
if (lastview.view !== 'list' || util/* default */.A.size(this.props.store.matchConvo('*')) > 0) {
|
|
6358
|
+
if (lastview.view == 'chat' && !util/* default */.A.get(lastview, 'opts.cid')) {
|
|
6359
|
+
return this.onPreviewClick();
|
|
6360
|
+
}
|
|
6340
6361
|
return this.props.onClick && this.props.onClick(Object.assign({}, lastview.opts, {
|
|
6341
6362
|
view: lastview.view
|
|
6342
6363
|
}));
|
|
@@ -6367,6 +6388,7 @@ class ChatButton extends common/* Com */.Mw {
|
|
|
6367
6388
|
}
|
|
6368
6389
|
renderPreview() {
|
|
6369
6390
|
let account = this.props.store.matchAccount();
|
|
6391
|
+
if (!account) return null;
|
|
6370
6392
|
let accountSetting = this.props.plugin.chatbox;
|
|
6371
6393
|
let byid = util/* default */.A.get(this.state.previewEvent, 'by.display_id', util/* default */.A.get(this.state.previewEvent, 'by.id'));
|
|
6372
6394
|
let agent = this.props.store.matchAgent(byid);
|
|
@@ -6933,6 +6955,7 @@ Vui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi
|
|
|
6933
6955
|
if (util/* default */.A.size(allconvos) === 0) return null;
|
|
6934
6956
|
var $unreadcount = null;
|
|
6935
6957
|
let user = this.props.store.matchUser();
|
|
6958
|
+
if (!user || !user.id) return null;
|
|
6936
6959
|
let unreadcount = 0;
|
|
6937
6960
|
util/* default */.A.map(allconvos, convo => {
|
|
6938
6961
|
if (convo.id == this.props.cid) return;
|
|
@@ -9948,7 +9971,7 @@ class Widget extends common/* Com */.Mw {
|
|
|
9948
9971
|
creating: true
|
|
9949
9972
|
});
|
|
9950
9973
|
let botid = cid.split('_')[0].slice(7);
|
|
9951
|
-
let oldconvo = this.props.store.matchConvo(this.props.cid);
|
|
9974
|
+
let oldconvo = this.props.store.matchConvo(this.props.cid) || {};
|
|
9952
9975
|
const {
|
|
9953
9976
|
convo,
|
|
9954
9977
|
error
|
|
@@ -11080,6 +11103,12 @@ class Main extends common/* Com */.Mw {
|
|
|
11080
11103
|
this.props.store.onResetCSS(this, () => this.refreshCSS());
|
|
11081
11104
|
this.props.store.onConvoEvent(this, ev => this.onConvoEvent(ev));
|
|
11082
11105
|
this.props.store.onUpdate(this, _ => this.checkExpand());
|
|
11106
|
+
this.props.store.onDestroyed(this, _ => {
|
|
11107
|
+
this.setState({
|
|
11108
|
+
widgetView: '',
|
|
11109
|
+
widgetConvoId: ''
|
|
11110
|
+
});
|
|
11111
|
+
});
|
|
11083
11112
|
await this.refreshCSS();
|
|
11084
11113
|
this.setState({
|
|
11085
11114
|
cssready: true
|
package/inject.html
CHANGED
|
@@ -4,8 +4,17 @@
|
|
|
4
4
|
</head>
|
|
5
5
|
<body style="background: #ffca7a; display: flex; margin: 0">
|
|
6
6
|
<div
|
|
7
|
-
style="
|
|
7
|
+
style="
|
|
8
|
+
margin: auto;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
position: relative;
|
|
11
|
+
width: 750px;
|
|
12
|
+
height: 100vh;
|
|
13
|
+
background: #ffe2b7;
|
|
14
|
+
border-left: 3px dashed #ffa92a;
|
|
15
|
+
border-right: 3px dashed #ffa92a;
|
|
16
|
+
"
|
|
8
17
|
class="container"
|
|
9
|
-
|
|
18
|
+
></div>
|
|
10
19
|
</body>
|
|
11
20
|
</html>
|
package/package.json
CHANGED
package/src/chatbox/Event.js
CHANGED
|
@@ -411,7 +411,8 @@ export default class Event extends Com {
|
|
|
411
411
|
renderAIDevNote() {
|
|
412
412
|
if (!this.props.isLast) return null
|
|
413
413
|
if (!this.props.store.isAIDevMode()) return null
|
|
414
|
-
|
|
414
|
+
let cid = sb.get(this.props.event.ev, 'data.message.conversation_id', '')
|
|
415
|
+
if (cid.startsWith('cslight')) return null
|
|
415
416
|
let ev = sb.get(this.props.event, 'ev') || {}
|
|
416
417
|
let pongs = sb.get(ev, 'data.message.pongs') || []
|
|
417
418
|
let hasLike = this.hasLike()
|
package/src/lib.js
CHANGED
package/src/store/store.js
CHANGED
|
@@ -124,6 +124,7 @@ export default class Store {
|
|
|
124
124
|
this.setUser({attributes: [{type: 'text', text: ga_client_id, key: 'ga_client_id'}]})
|
|
125
125
|
}
|
|
126
126
|
}, 2000)
|
|
127
|
+
this.loopCheckConnectionStatus()
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
async loopCheckConnectionStatus() {
|
|
@@ -498,10 +499,7 @@ export default class Store {
|
|
|
498
499
|
now = () => sb.Date.now() + this.timeDiff // millisecond on server
|
|
499
500
|
|
|
500
501
|
async init(accid, mask, userRef, options) {
|
|
501
|
-
this.readyGate.close()
|
|
502
|
-
accid = (accid || '').trim()
|
|
503
502
|
this.g_sync = {}
|
|
504
|
-
|
|
505
503
|
if (!options || !options.use_subdomain_cookie) {
|
|
506
504
|
if (window && window.location && window.location.hostname) {
|
|
507
505
|
cookie.defaults.domain = '.' + window.location.hostname
|
|
@@ -543,22 +541,34 @@ export default class Store {
|
|
|
543
541
|
cleanMyLocalStorage()
|
|
544
542
|
this.clearBrowserData()
|
|
545
543
|
}
|
|
546
|
-
this.lightConvos = {} // convo that have not been created, for faking bot conversation
|
|
547
|
-
this.cache = new KV(new LSDB('sbz2023', true), 'kv')
|
|
548
544
|
|
|
549
545
|
this.api.setAuth({accid: accid})
|
|
550
546
|
// set cookie forever
|
|
551
547
|
if (userRef) this.cookie.set('__sbref', userRef)
|
|
552
|
-
|
|
548
|
+
|
|
549
|
+
return this._initResource(
|
|
550
|
+
accid,
|
|
551
|
+
{accid: accid, mask: mask, ref: userRef},
|
|
552
|
+
{account_id: accid, user_ref: userRef, user_mask: mask},
|
|
553
|
+
)
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async _initResource(accid, auth, realtimep) {
|
|
557
|
+
this.g_sync = {}
|
|
558
|
+
|
|
559
|
+
let user = await this.api.setAuth(auth)
|
|
553
560
|
if (user.error) {
|
|
554
561
|
console.error(user)
|
|
555
562
|
return user
|
|
556
563
|
}
|
|
557
564
|
|
|
565
|
+
this.readyGate.close()
|
|
566
|
+
accid = (accid || '').trim()
|
|
567
|
+
this.lightConvos = this.kv.match('light_convos') || {}
|
|
568
|
+
this.cache = new KV(new LSDB('sbz2023', true), 'kv')
|
|
558
569
|
if (this.realtime) this.realtime.stop()
|
|
559
570
|
if (this.fake) this.realtime = new RealtimeFake()
|
|
560
|
-
else
|
|
561
|
-
this.realtime = new Realtime(this.RealtimeURL, {account_id: accid, user_ref: userRef, user_mask: mask}, xhrsend)
|
|
571
|
+
else this.realtime = new Realtime(this.RealtimeURL, realtimep, xhrsend)
|
|
562
572
|
|
|
563
573
|
this.realtime.onEvent(this.onWs.bind(this))
|
|
564
574
|
this.realtime.onInterrupted(async () => {
|
|
@@ -566,43 +576,24 @@ export default class Store {
|
|
|
566
576
|
this.reconnect()
|
|
567
577
|
})
|
|
568
578
|
|
|
569
|
-
this.lightConvos = this.kv.match('light_convos') || {}
|
|
570
579
|
this.seenLoop()
|
|
571
580
|
await this.reconnect({user: user}) // already fetched
|
|
572
581
|
this.readyGate.open()
|
|
573
582
|
this.reconnectWs(accid, user.id)
|
|
574
|
-
this.loopCheckConnectionStatus()
|
|
575
583
|
return user
|
|
576
584
|
}
|
|
577
585
|
|
|
578
586
|
async login(accid, user_id, tokenGenerator) {
|
|
579
587
|
if (this._die) return dieErr
|
|
580
|
-
|
|
581
|
-
if (user.error) return user
|
|
582
|
-
|
|
588
|
+
cleanMyLocalStorage()
|
|
583
589
|
this.clearBrowserData()
|
|
584
|
-
this.readyGate.close()
|
|
585
|
-
accid = (accid || '').trim()
|
|
586
590
|
|
|
587
|
-
this.g_sync = {}
|
|
588
591
|
this.new_visitor = false // for checking returning or new visitor
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
this.realtime.onEvent(this.onWs.bind(this))
|
|
595
|
-
this.realtime.onInterrupted(async () => {
|
|
596
|
-
await this.reconnectWs(accid, user.id)
|
|
597
|
-
this.reconnect()
|
|
598
|
-
})
|
|
599
|
-
|
|
600
|
-
this.seenLoop()
|
|
601
|
-
await this.reconnect()
|
|
602
|
-
this.readyGate.open()
|
|
603
|
-
this.reconnectWs(accid, user.id)
|
|
604
|
-
|
|
605
|
-
return user
|
|
592
|
+
return this._initResource(
|
|
593
|
+
accid,
|
|
594
|
+
{accid: accid, profile_id: user_id, tokenGenerator: tokenGenerator},
|
|
595
|
+
{getAccessToken: () => this.api.token_generator()},
|
|
596
|
+
)
|
|
606
597
|
}
|
|
607
598
|
|
|
608
599
|
logout(userRef) {
|