@subiz/widget-v4 4.1.201 → 4.1.202
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/bot.js +1 -7
- package/compiled_src/chatbox/Widget.js +1 -0
- package/compiled_src/lib.js +1 -1
- package/compiled_src/store/store.js +14 -1
- package/compiled_src/util/common.js +18 -18
- package/dist/{19d6b530a9c.app.js → 19d8a41ce33.app.js} +1 -1
- package/dist/{19d6b530a9c.chat.html → 19d8a41ce33.chat.html} +1 -1
- package/dist/{19d6b530a9c.chat.js → 19d8a41ce33.chat.js} +1 -1
- package/dist/{19d6b530a9c.form.html → 19d8a41ce33.form.html} +1 -1
- package/dist/19d8a41ce33.form.js +1 -0
- package/dist/{19d6b530a9c.index.html → 19d8a41ce33.index.html} +1 -1
- package/dist/{19d6b530a9c.library.html → 19d8a41ce33.library.html} +1 -1
- package/dist/{19d6b530a9c.library.js → 19d8a41ce33.library.js} +1 -1
- package/dist/{19d6b530a9c.preview.html → 19d8a41ce33.preview.html} +1 -1
- package/dist/{19d6b530a9c.preview.js → 19d8a41ce33.preview.js} +1 -1
- package/dist/{19d6b530a9c.webview.js → 19d8a41ce33.webview.js} +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +34 -20
- package/package.json +1 -1
- package/src/bot.js +1 -7
- package/src/chatbox/Widget.js +1 -1
- package/src/lib.js +1 -1
- package/src/store/store.js +17 -2
- package/src/util/common.js +22 -21
- package/dist/19d6b530a9c.form.js +0 -1
- /package/dist/{19d6b530a9c.127.js → 19d8a41ce33.127.js} +0 -0
- /package/dist/{19d6b530a9c.132.js → 19d8a41ce33.132.js} +0 -0
- /package/dist/{19d6b530a9c.185.js → 19d8a41ce33.185.js} +0 -0
- /package/dist/{19d6b530a9c.27.js → 19d8a41ce33.27.js} +0 -0
- /package/dist/{19d6b530a9c.278.js → 19d8a41ce33.278.js} +0 -0
- /package/dist/{19d6b530a9c.339.js → 19d8a41ce33.339.js} +0 -0
- /package/dist/{19d6b530a9c.459.js → 19d8a41ce33.459.js} +0 -0
- /package/dist/{19d6b530a9c.490.js → 19d8a41ce33.490.js} +0 -0
- /package/dist/{19d6b530a9c.74.js → 19d8a41ce33.74.js} +0 -0
- /package/dist/{19d6b530a9c.997.js → 19d8a41ce33.997.js} +0 -0
package/dist/HASH
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
19d8a41ce33
|
package/dist/screenshoot.js
CHANGED
|
@@ -1971,12 +1971,6 @@ function filter(collection, predicate) {
|
|
|
1971
1971
|
if (!collection) return [];
|
|
1972
1972
|
if (!predicate) return collection;
|
|
1973
1973
|
var out = [];
|
|
1974
|
-
if (Array.isArray(collection)) {
|
|
1975
|
-
for (let i = 0; i < collection.length; i++) {
|
|
1976
|
-
if (predicate(collection[i], i)) out.push(collection[i]);
|
|
1977
|
-
}
|
|
1978
|
-
return out;
|
|
1979
|
-
}
|
|
1980
1974
|
if (typeof collection === 'object') {
|
|
1981
1975
|
var keys = Object.keys(collection);
|
|
1982
1976
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -1985,6 +1979,12 @@ function filter(collection, predicate) {
|
|
|
1985
1979
|
}
|
|
1986
1980
|
return out;
|
|
1987
1981
|
}
|
|
1982
|
+
if (Array.isArray(collection)) {
|
|
1983
|
+
for (let i = 0; i < collection.length; i++) {
|
|
1984
|
+
if (predicate(collection[i], i)) out.push(collection[i]);
|
|
1985
|
+
}
|
|
1986
|
+
return out;
|
|
1987
|
+
}
|
|
1988
1988
|
return out;
|
|
1989
1989
|
}
|
|
1990
1990
|
function includes(collection, value) {
|
|
@@ -1997,12 +1997,6 @@ function map(collection, predicate) {
|
|
|
1997
1997
|
if (!collection) return [];
|
|
1998
1998
|
if (!predicate) predicate = i => i;
|
|
1999
1999
|
var out = [];
|
|
2000
|
-
if (Array.isArray(collection)) {
|
|
2001
|
-
for (let i = 0; i < collection.length; i++) {
|
|
2002
|
-
out.push(predicate(collection[i], i));
|
|
2003
|
-
}
|
|
2004
|
-
return out;
|
|
2005
|
-
}
|
|
2006
2000
|
if (typeof collection === 'object') {
|
|
2007
2001
|
var keys = Object.keys(collection);
|
|
2008
2002
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -2011,6 +2005,12 @@ function map(collection, predicate) {
|
|
|
2011
2005
|
}
|
|
2012
2006
|
return out;
|
|
2013
2007
|
}
|
|
2008
|
+
if (Array.isArray(collection)) {
|
|
2009
|
+
for (let i = 0; i < collection.length; i++) {
|
|
2010
|
+
out.push(predicate(collection[i], i));
|
|
2011
|
+
}
|
|
2012
|
+
return out;
|
|
2013
|
+
}
|
|
2014
2014
|
return out;
|
|
2015
2015
|
}
|
|
2016
2016
|
function each(collection, predicate) {
|
|
@@ -2093,12 +2093,6 @@ function find(collection, f) {
|
|
|
2093
2093
|
function findIndex(collection, f) {
|
|
2094
2094
|
if (!collection) return -1;
|
|
2095
2095
|
if (!f) return -1;
|
|
2096
|
-
if (Array.isArray(collection)) {
|
|
2097
|
-
for (let i = 0; i < collection.length; i++) {
|
|
2098
|
-
if (f(collection[i], i)) return i;
|
|
2099
|
-
}
|
|
2100
|
-
return -1;
|
|
2101
|
-
}
|
|
2102
2096
|
if (typeof collection === 'object') {
|
|
2103
2097
|
var keys = Object.keys(collection);
|
|
2104
2098
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -2106,6 +2100,12 @@ function findIndex(collection, f) {
|
|
|
2106
2100
|
if (f(collection[k], k)) return k;
|
|
2107
2101
|
}
|
|
2108
2102
|
}
|
|
2103
|
+
if (Array.isArray(collection)) {
|
|
2104
|
+
for (let i = 0; i < collection.length; i++) {
|
|
2105
|
+
if (f(collection[i], i)) return i;
|
|
2106
|
+
}
|
|
2107
|
+
return -1;
|
|
2108
|
+
}
|
|
2109
2109
|
return -1;
|
|
2110
2110
|
}
|
|
2111
2111
|
function orderBy(a, k, d) {
|
|
@@ -5900,7 +5900,17 @@ class Store {
|
|
|
5900
5900
|
}
|
|
5901
5901
|
this.readyGate.close();
|
|
5902
5902
|
accid = (accid || '').trim();
|
|
5903
|
-
|
|
5903
|
+
let lightConvos = this.kv.match('light_convos') || {};
|
|
5904
|
+
this.lightConvos = {};
|
|
5905
|
+
util/* default */.A.map(lightConvos, convo => {
|
|
5906
|
+
let in7Day = convo.created > util/* default */.A.Date.now() - 7 * 24 * 3_600_000;
|
|
5907
|
+
let events = util/* default */.A.filter(convo.events, ev => ev.type === 'message_sent');
|
|
5908
|
+
let messages = util/* default */.A.map(events, ev => util/* default */.A.get(ev, 'data.message') || {});
|
|
5909
|
+
messages = util/* default */.A.filter(messages, msg => !util/* default */.A.isEmptyMessage(msg));
|
|
5910
|
+
if (in7Day && util/* default */.A.size(messages)) {
|
|
5911
|
+
this.lightConvos[convo.id] = convo;
|
|
5912
|
+
}
|
|
5913
|
+
});
|
|
5904
5914
|
this.cache = new kv(new lsdb('sbz2023', true), 'kv');
|
|
5905
5915
|
if (this.realtime) this.realtime.stop();
|
|
5906
5916
|
if (this.fake) this.realtime = new realtime_fake();else this.realtime = new Realtime(this.RealtimeURL, realtimep, xhrsend, accid);
|
|
@@ -6124,6 +6134,9 @@ class Store {
|
|
|
6124
6134
|
if (traffic_source) this.kv.put('traffic_source', traffic_source);
|
|
6125
6135
|
return;
|
|
6126
6136
|
}
|
|
6137
|
+
if (typeof e === 'object') {
|
|
6138
|
+
if (!e.data) e.data = {};
|
|
6139
|
+
}
|
|
6127
6140
|
return this.api.sendEvent(e);
|
|
6128
6141
|
}
|
|
6129
6142
|
async onWs(ev) {
|
|
@@ -11724,6 +11737,7 @@ class Widget extends common/* Com */.Mw {
|
|
|
11724
11737
|
agentids = agentids || util/* default */.A.agentsOfConvo(convo)[0];
|
|
11725
11738
|
return (0,preact_module.h)("div", {
|
|
11726
11739
|
class: "convo-list--item",
|
|
11740
|
+
"data-cid": convo.id,
|
|
11727
11741
|
onClick: () => this.goToConvo(convo.id),
|
|
11728
11742
|
key: convo.id
|
|
11729
11743
|
}, (0,preact_module.h)(AgentsAvatar, {
|
|
@@ -12694,7 +12708,7 @@ class lib_Widget {
|
|
|
12694
12708
|
lib_defineProperty(this, "getUser", () => util/* default */.A.parseJSON(util/* default */.A.stringify(this.store.matchUser())));
|
|
12695
12709
|
lib_defineProperty(this, "setViewingProduct", p => this.store.linkProduct(p));
|
|
12696
12710
|
lib_defineProperty(this, "getViewingProduct", () => this.store.getLinkedProduct());
|
|
12697
|
-
lib_defineProperty(this, "track",
|
|
12711
|
+
lib_defineProperty(this, "track", v => this.store.track(v));
|
|
12698
12712
|
this.impressionTokens = {};
|
|
12699
12713
|
this.domGate = new util/* default */.A.Gate();
|
|
12700
12714
|
this.store = new Store(ApiURL, FileURL, RealtimeURL, inmem, fake);
|
package/package.json
CHANGED
package/src/bot.js
CHANGED
|
@@ -14,13 +14,7 @@ export default function (store) {
|
|
|
14
14
|
|
|
15
15
|
let welcomMessages = bot.welcome_messages
|
|
16
16
|
welcomMessages = sb.filter(welcomMessages, (msg) => {
|
|
17
|
-
if (
|
|
18
|
-
if (msg.block || msg.format === 'block') {
|
|
19
|
-
if (sb.isBlockEmpty(msg.block)) return false
|
|
20
|
-
} else {
|
|
21
|
-
if (!(msg.text || '').trim()) return false
|
|
22
|
-
}
|
|
23
|
-
}
|
|
17
|
+
if (sb.isEmptyMessage(msg)) return false
|
|
24
18
|
return true
|
|
25
19
|
})
|
|
26
20
|
if (sb.size(welcomMessages)) {
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -739,7 +739,7 @@ export default class Widget extends Com {
|
|
|
739
739
|
agentids = agentids || sb.agentsOfConvo(convo)[0]
|
|
740
740
|
|
|
741
741
|
return (
|
|
742
|
-
<div class='convo-list--item' onClick={() => this.goToConvo(convo.id)} key={convo.id}>
|
|
742
|
+
<div class='convo-list--item' data-cid={convo.id} onClick={() => this.goToConvo(convo.id)} key={convo.id}>
|
|
743
743
|
<AgentsAvatar
|
|
744
744
|
plugin={this.props.plugin}
|
|
745
745
|
store={this.props.store}
|
package/src/lib.js
CHANGED
|
@@ -316,7 +316,7 @@ class Widget {
|
|
|
316
316
|
setViewingProduct = (p) => this.store.linkProduct(p)
|
|
317
317
|
getViewingProduct = () => this.store.getLinkedProduct()
|
|
318
318
|
|
|
319
|
-
track = () => this.store.track()
|
|
319
|
+
track = (v) => this.store.track(v)
|
|
320
320
|
|
|
321
321
|
async setLocale(locale) {
|
|
322
322
|
await this.domGate.entry()
|
package/src/store/store.js
CHANGED
|
@@ -403,7 +403,7 @@ export default class Store {
|
|
|
403
403
|
|
|
404
404
|
if (id === '*') {
|
|
405
405
|
this._touchAcc()
|
|
406
|
-
// combind with
|
|
406
|
+
// combind with light convo
|
|
407
407
|
return sb.filter(this.cache.all(), (value, k) => k.startsWith('convo_')).concat(sb.map(this.lightConvos))
|
|
408
408
|
}
|
|
409
409
|
|
|
@@ -633,7 +633,19 @@ export default class Store {
|
|
|
633
633
|
|
|
634
634
|
this.readyGate.close()
|
|
635
635
|
accid = (accid || '').trim()
|
|
636
|
-
|
|
636
|
+
let lightConvos = this.kv.match('light_convos') || {}
|
|
637
|
+
this.lightConvos = {}
|
|
638
|
+
sb.map(lightConvos, (convo) => {
|
|
639
|
+
let in7Day = convo.created > sb.Date.now() - 7 * 24 * 3_600_000
|
|
640
|
+
let events = sb.filter(convo.events, (ev) => ev.type === 'message_sent')
|
|
641
|
+
|
|
642
|
+
let messages = sb.map(events, (ev) => sb.get(ev, 'data.message') || {})
|
|
643
|
+
messages = sb.filter(messages, (msg) => !sb.isEmptyMessage(msg))
|
|
644
|
+
|
|
645
|
+
if (in7Day && sb.size(messages)) {
|
|
646
|
+
this.lightConvos[convo.id] = convo
|
|
647
|
+
}
|
|
648
|
+
})
|
|
637
649
|
this.cache = new KV(new LSDB('sbz2023', true), 'kv')
|
|
638
650
|
if (this.realtime) this.realtime.stop()
|
|
639
651
|
if (this.fake) this.realtime = new RealtimeFake()
|
|
@@ -920,6 +932,9 @@ export default class Store {
|
|
|
920
932
|
return
|
|
921
933
|
}
|
|
922
934
|
|
|
935
|
+
if (typeof e === 'object') {
|
|
936
|
+
if (!e.data) e.data = {}
|
|
937
|
+
}
|
|
923
938
|
return this.api.sendEvent(e)
|
|
924
939
|
}
|
|
925
940
|
|
package/src/util/common.js
CHANGED
|
@@ -329,13 +329,6 @@ export function filter(collection, predicate) {
|
|
|
329
329
|
if (!predicate) return collection
|
|
330
330
|
|
|
331
331
|
var out = []
|
|
332
|
-
if (Array.isArray(collection)) {
|
|
333
|
-
for (let i = 0; i < collection.length; i++) {
|
|
334
|
-
if (predicate(collection[i], i)) out.push(collection[i])
|
|
335
|
-
}
|
|
336
|
-
return out
|
|
337
|
-
}
|
|
338
|
-
|
|
339
332
|
if (typeof collection === 'object') {
|
|
340
333
|
var keys = Object.keys(collection)
|
|
341
334
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -345,6 +338,13 @@ export function filter(collection, predicate) {
|
|
|
345
338
|
return out
|
|
346
339
|
}
|
|
347
340
|
|
|
341
|
+
if (Array.isArray(collection)) {
|
|
342
|
+
for (let i = 0; i < collection.length; i++) {
|
|
343
|
+
if (predicate(collection[i], i)) out.push(collection[i])
|
|
344
|
+
}
|
|
345
|
+
return out
|
|
346
|
+
}
|
|
347
|
+
|
|
348
348
|
return out
|
|
349
349
|
}
|
|
350
350
|
|
|
@@ -361,13 +361,6 @@ export function map(collection, predicate) {
|
|
|
361
361
|
if (!predicate) predicate = (i) => i
|
|
362
362
|
|
|
363
363
|
var out = []
|
|
364
|
-
if (Array.isArray(collection)) {
|
|
365
|
-
for (let i = 0; i < collection.length; i++) {
|
|
366
|
-
out.push(predicate(collection[i], i))
|
|
367
|
-
}
|
|
368
|
-
return out
|
|
369
|
-
}
|
|
370
|
-
|
|
371
364
|
if (typeof collection === 'object') {
|
|
372
365
|
var keys = Object.keys(collection)
|
|
373
366
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -377,6 +370,13 @@ export function map(collection, predicate) {
|
|
|
377
370
|
return out
|
|
378
371
|
}
|
|
379
372
|
|
|
373
|
+
if (Array.isArray(collection)) {
|
|
374
|
+
for (let i = 0; i < collection.length; i++) {
|
|
375
|
+
out.push(predicate(collection[i], i))
|
|
376
|
+
}
|
|
377
|
+
return out
|
|
378
|
+
}
|
|
379
|
+
|
|
380
380
|
return out
|
|
381
381
|
}
|
|
382
382
|
|
|
@@ -483,13 +483,6 @@ function findIndex(collection, f) {
|
|
|
483
483
|
if (!collection) return -1
|
|
484
484
|
if (!f) return -1
|
|
485
485
|
|
|
486
|
-
if (Array.isArray(collection)) {
|
|
487
|
-
for (let i = 0; i < collection.length; i++) {
|
|
488
|
-
if (f(collection[i], i)) return i
|
|
489
|
-
}
|
|
490
|
-
return -1
|
|
491
|
-
}
|
|
492
|
-
|
|
493
486
|
if (typeof collection === 'object') {
|
|
494
487
|
var keys = Object.keys(collection)
|
|
495
488
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -497,6 +490,14 @@ function findIndex(collection, f) {
|
|
|
497
490
|
if (f(collection[k], k)) return k
|
|
498
491
|
}
|
|
499
492
|
}
|
|
493
|
+
|
|
494
|
+
if (Array.isArray(collection)) {
|
|
495
|
+
for (let i = 0; i < collection.length; i++) {
|
|
496
|
+
if (f(collection[i], i)) return i
|
|
497
|
+
}
|
|
498
|
+
return -1
|
|
499
|
+
}
|
|
500
|
+
|
|
500
501
|
return -1
|
|
501
502
|
}
|
|
502
503
|
|