@subiz/widget-v4 4.1.17 → 4.1.19
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/assets/less/widget_header.less +3 -1
- package/compiled_src/call/call.js +7 -7
- package/compiled_src/chatbox/DropdownSelect.js +1 -1
- package/compiled_src/chatbox/Event.js +1 -1
- package/compiled_src/chatbox/Events.js +3 -3
- package/compiled_src/chatbox/MessageInput.js +2 -2
- package/compiled_src/chatbox/Order.js +1 -1
- package/compiled_src/chatbox/Rating.js +1 -1
- package/compiled_src/chatbox/Typing.js +3 -3
- package/compiled_src/chatbox/Widget.js +6 -6
- package/compiled_src/chatbox/time.js +1 -1
- package/compiled_src/common.js +2 -2
- package/compiled_src/contact/contact.js +1 -1
- package/compiled_src/lib.js +6 -6
- package/compiled_src/notif/notif.js +7 -7
- package/compiled_src/order/address_picker.js +1 -1
- package/compiled_src/popup/countdown.js +2 -2
- package/compiled_src/popup/popup.js +8 -8
- package/compiled_src/store/api.js +1 -1
- package/compiled_src/store/store.js +3 -3
- package/compiled_src/util/campaign.js +6 -6
- package/compiled_src/util/common.js +5 -0
- package/package.json +7 -7
- package/src/call/call.js +7 -7
- package/src/chatbox/DropdownSelect.js +1 -1
- package/src/chatbox/Event.js +1 -1
- package/src/chatbox/Events.js +3 -3
- package/src/chatbox/MessageInput.js +2 -2
- package/src/chatbox/Order.js +1 -1
- package/src/chatbox/Rating.js +1 -1
- package/src/chatbox/Typing.js +3 -3
- package/src/chatbox/Widget.js +6 -6
- package/src/chatbox/time.js +1 -1
- package/src/common.js +2 -2
- package/src/contact/contact.js +1 -1
- package/src/lib.js +6 -6
- package/src/notif/notif.js +7 -7
- package/src/order/address_picker.js +1 -1
- package/src/popup/countdown.js +2 -2
- package/src/popup/popup.js +8 -8
- package/src/store/api.js +2 -3
- package/src/store/store.js +3 -3
- package/src/util/campaign.js +6 -6
- package/src/util/common.js +2 -0
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
font-weight: 400;
|
|
15
15
|
display: flex;
|
|
16
16
|
border-radius: 5px;
|
|
17
|
-
align-items: center;
|
|
18
17
|
justify-content: center;
|
|
19
18
|
width: 20px;
|
|
20
19
|
height: 20px;
|
|
21
20
|
cursor: pointer;
|
|
21
|
+
position: relative;
|
|
22
|
+
top: 5px;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
|
|
43
44
|
.widget-header--description {
|
|
44
45
|
font-size: 14px;
|
|
46
|
+
white-space: pre-wrap;
|
|
45
47
|
opacity: 0.8;
|
|
46
48
|
flex: 1;
|
|
47
49
|
.color(@white);
|
|
@@ -28,7 +28,7 @@ class Notif extends _common.Com {
|
|
|
28
28
|
title: '',
|
|
29
29
|
last_show: 0
|
|
30
30
|
});
|
|
31
|
-
setTimeout(async () => {
|
|
31
|
+
_index.default.setTimeout(async () => {
|
|
32
32
|
let {
|
|
33
33
|
body: impression
|
|
34
34
|
} = await this.props.store.sendImpression(this.props.plugin.id);
|
|
@@ -101,7 +101,7 @@ class Notif extends _common.Com {
|
|
|
101
101
|
await this.waitForT();
|
|
102
102
|
if (!this.props.t) return;
|
|
103
103
|
if (!close) {
|
|
104
|
-
clearTimeout(this.lastCloseTimeout);
|
|
104
|
+
_index.default.clearTimeout(this.lastCloseTimeout);
|
|
105
105
|
this.setState({
|
|
106
106
|
closeAnimation: false
|
|
107
107
|
});
|
|
@@ -138,11 +138,11 @@ class Notif extends _common.Com {
|
|
|
138
138
|
closeAnimation: true
|
|
139
139
|
});
|
|
140
140
|
this.mouse_leave = _index.default.Date.now();
|
|
141
|
-
this.lastCloseTimeout = setTimeout(() => this.setState({
|
|
141
|
+
this.lastCloseTimeout = _index.default.setTimeout(() => this.setState({
|
|
142
142
|
close: true,
|
|
143
143
|
closeAnimation: false
|
|
144
144
|
}), 150);
|
|
145
|
-
if (this.props.plugin._dont_close) setTimeout(() => this.setState({
|
|
145
|
+
if (this.props.plugin._dont_close) _index.default.setTimeout(() => this.setState({
|
|
146
146
|
closeAnimation: false,
|
|
147
147
|
close: false
|
|
148
148
|
}), 1000);
|
|
@@ -156,7 +156,7 @@ class Notif extends _common.Com {
|
|
|
156
156
|
this.setClose(this.state.close);
|
|
157
157
|
}
|
|
158
158
|
componentWillUnmount() {
|
|
159
|
-
clearInterval(this.interval);
|
|
159
|
+
_index.default.clearInterval(this.interval);
|
|
160
160
|
_index.default.setCss(this.props.plugin.id, this.$cssStyleDiv, '');
|
|
161
161
|
}
|
|
162
162
|
async componentDidMount() {
|
|
@@ -172,7 +172,7 @@ class Notif extends _common.Com {
|
|
|
172
172
|
}
|
|
173
173
|
this.props.store.onResetCSS(this, () => this.refreshCSS());
|
|
174
174
|
await this.refreshCSS();
|
|
175
|
-
this.interval = setInterval(() => {
|
|
175
|
+
this.interval = _index.default.setInterval(() => {
|
|
176
176
|
if (this.props._destroy) return this.componentWillUnmount();
|
|
177
177
|
let mouseleave = this.mouse_leave;
|
|
178
178
|
if (mouseleave === 0) mouseleave = _index.default.Date.now();
|
|
@@ -185,7 +185,7 @@ class Notif extends _common.Com {
|
|
|
185
185
|
return this.setClose(false);
|
|
186
186
|
}
|
|
187
187
|
}, 1000);
|
|
188
|
-
setTimeout(() => {
|
|
188
|
+
_index.default.setTimeout(() => {
|
|
189
189
|
this.setState({
|
|
190
190
|
cssready: true
|
|
191
191
|
});
|
|
@@ -112,7 +112,7 @@ class DropdownSelect extends _common.Com {
|
|
|
112
112
|
focusFilter() {
|
|
113
113
|
if (!this.filterRef.current) return;
|
|
114
114
|
this.filterRef.current.focus();
|
|
115
|
-
setTimeout(() => {
|
|
115
|
+
_index.default.setTimeout(() => {
|
|
116
116
|
if (!this.filterRef.current) return;
|
|
117
117
|
this.filterRef.current.focus();
|
|
118
118
|
}, 100);
|
|
@@ -183,7 +183,7 @@ class Event extends _common.Com {
|
|
|
183
183
|
}));
|
|
184
184
|
}
|
|
185
185
|
if (_index.default.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
186
|
-
setTimeout(() => this.setState({
|
|
186
|
+
_index.default.setTimeout(() => this.setState({
|
|
187
187
|
refresh: this.state.refresh
|
|
188
188
|
}), 1000);
|
|
189
189
|
}
|
|
@@ -168,7 +168,7 @@ class Events extends _common.Com {
|
|
|
168
168
|
error: false
|
|
169
169
|
});
|
|
170
170
|
this.scrollToBottom();
|
|
171
|
-
setTimeout(() => this.setState({
|
|
171
|
+
_index.default.setTimeout(() => this.setState({
|
|
172
172
|
loading: false
|
|
173
173
|
}), 50);
|
|
174
174
|
}
|
|
@@ -178,11 +178,11 @@ class Events extends _common.Com {
|
|
|
178
178
|
return $container.scrollHeight < $container.scrollTop + $container.offsetHeight + 50;
|
|
179
179
|
}
|
|
180
180
|
scrollToBottom() {
|
|
181
|
-
setTimeout(() => {
|
|
181
|
+
_index.default.setTimeout(() => {
|
|
182
182
|
const $div = this.refBody;
|
|
183
183
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
184
184
|
});
|
|
185
|
-
setTimeout(() => {
|
|
185
|
+
_index.default.setTimeout(() => {
|
|
186
186
|
const $div = this.refBody;
|
|
187
187
|
if ($div) $div.scrollTop = $div.scrollHeight;
|
|
188
188
|
}, 200);
|
|
@@ -216,10 +216,10 @@ class MessageInput extends _common.Com {
|
|
|
216
216
|
focus() {
|
|
217
217
|
if (this.props.disabled) return;
|
|
218
218
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
219
|
-
setTimeout(() => {
|
|
219
|
+
_index.default.setTimeout(() => {
|
|
220
220
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
221
221
|
});
|
|
222
|
-
setTimeout(() => {
|
|
222
|
+
_index.default.setTimeout(() => {
|
|
223
223
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
224
224
|
}, 100);
|
|
225
225
|
}
|
|
@@ -188,7 +188,7 @@ class Rating extends _common.Com {
|
|
|
188
188
|
hide: false
|
|
189
189
|
});
|
|
190
190
|
if (!this.refRating.current) return;
|
|
191
|
-
setTimeout(() => {
|
|
191
|
+
_index.default.setTimeout(() => {
|
|
192
192
|
if (this.refComment.current) this.refComment.current.focus();
|
|
193
193
|
}, 400);
|
|
194
194
|
this.refComment.current.value = '';
|
|
@@ -24,7 +24,7 @@ class Typing extends _common.Com {
|
|
|
24
24
|
let oldby = _index.default.get(this.state.ev, 'by.id');
|
|
25
25
|
if (oldby && _index.default.get(ev, 'by.id') !== oldby) return;
|
|
26
26
|
if (_index.default.get(ev, 'type') === 'message_sent') {
|
|
27
|
-
if (this.timer) clearTimeout(this.timer);
|
|
27
|
+
if (this.timer) _index.default.clearTimeout(this.timer);
|
|
28
28
|
this.timer = null;
|
|
29
29
|
this.setState({
|
|
30
30
|
isShow: false
|
|
@@ -38,8 +38,8 @@ class Typing extends _common.Com {
|
|
|
38
38
|
ev: ev,
|
|
39
39
|
isShow: true
|
|
40
40
|
});
|
|
41
|
-
if (this.timer) clearTimeout(this.timer);
|
|
42
|
-
this.timer = setTimeout(() => {
|
|
41
|
+
if (this.timer) _index.default.clearTimeout(this.timer);
|
|
42
|
+
this.timer = _index.default.setTimeout(() => {
|
|
43
43
|
if (_index.default.convoOfEv(ev) !== this.props.cid) return;
|
|
44
44
|
this.timer = null;
|
|
45
45
|
this.setState({
|
|
@@ -110,7 +110,7 @@ class Widget extends _common.Com {
|
|
|
110
110
|
clickedJoin: false,
|
|
111
111
|
quickReplyMessage: {}
|
|
112
112
|
});
|
|
113
|
-
setTimeout(() => {
|
|
113
|
+
_index.default.setTimeout(() => {
|
|
114
114
|
this.events && this.events.focus();
|
|
115
115
|
if (!this.props.store.isMobile()) this.focusInput();
|
|
116
116
|
}, 100);
|
|
@@ -644,8 +644,8 @@ class Widget extends _common.Com {
|
|
|
644
644
|
if (this.props.store.isPreview) return;
|
|
645
645
|
var $input = this.msgInput.current;
|
|
646
646
|
if (!$input) return;
|
|
647
|
-
setTimeout(() => $input && $input.blur());
|
|
648
|
-
setTimeout(() => $input && $input.blur(), 300);
|
|
647
|
+
_index.default.setTimeout(() => $input && $input.blur());
|
|
648
|
+
_index.default.setTimeout(() => $input && $input.blur(), 300);
|
|
649
649
|
}
|
|
650
650
|
focusInput() {
|
|
651
651
|
if (this.props.store.isPreview) return;
|
|
@@ -656,7 +656,7 @@ class Widget extends _common.Com {
|
|
|
656
656
|
if (firstemptykey) return;
|
|
657
657
|
if (!field.value) firstemptykey = key;
|
|
658
658
|
});
|
|
659
|
-
setTimeout(() => {
|
|
659
|
+
_index.default.setTimeout(() => {
|
|
660
660
|
var $input = this['form_' + encode(firstemptykey)];
|
|
661
661
|
if (!$input) return;
|
|
662
662
|
$input.focus();
|
|
@@ -665,8 +665,8 @@ class Widget extends _common.Com {
|
|
|
665
665
|
}
|
|
666
666
|
var $input = this.msgInput.current;
|
|
667
667
|
if (!$input) return;
|
|
668
|
-
setTimeout(() => $input.focus());
|
|
669
|
-
setTimeout(() => $input.focus(), 300);
|
|
668
|
+
_index.default.setTimeout(() => $input.focus());
|
|
669
|
+
_index.default.setTimeout(() => $input.focus(), 300);
|
|
670
670
|
}
|
|
671
671
|
onRate(rating) {
|
|
672
672
|
if (!this.props.cid) return;
|
|
@@ -9,7 +9,7 @@ var _common = require("../common.js");
|
|
|
9
9
|
var _preact = require("preact");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
var g_pub = new _index.default.Pubsub();
|
|
12
|
-
setInterval(() => g_pub.publish('time'), 20 * 1000);
|
|
12
|
+
_index.default.setInterval(() => g_pub.publish('time'), 20 * 1000);
|
|
13
13
|
class Time extends _common.Com {
|
|
14
14
|
constructor(props) {
|
|
15
15
|
super(props);
|
package/compiled_src/common.js
CHANGED
|
@@ -13,7 +13,7 @@ class Com extends _preact.Component {
|
|
|
13
13
|
constructor(props) {
|
|
14
14
|
super(props);
|
|
15
15
|
this._isMounted = true;
|
|
16
|
-
setTimeout(() => {
|
|
16
|
+
_index.default.setTimeout(() => {
|
|
17
17
|
if (this.componentWillUnmount) {
|
|
18
18
|
let old = this.componentWillUnmount.bind(this);
|
|
19
19
|
this.componentWillUnmount = () => {
|
|
@@ -69,7 +69,7 @@ let langMessages = {};
|
|
|
69
69
|
exports.langMessages = langMessages;
|
|
70
70
|
let downloadLock = false;
|
|
71
71
|
function downloadLanguage(store, locale, force) {
|
|
72
|
-
if (downloadLock) return new Promise(resolve => setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100));
|
|
72
|
+
if (downloadLock) return new Promise(resolve => _index.default.setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100));
|
|
73
73
|
downloadLock = true;
|
|
74
74
|
let messages;
|
|
75
75
|
if (locale === 'debug' || langMessages[locale] && !force) {
|
|
@@ -252,7 +252,7 @@ class Contact extends _common.Com {
|
|
|
252
252
|
let pluginstringify = JSON.stringify(this.props.plugin);
|
|
253
253
|
if (this.state.pluginjson !== pluginstringify) {
|
|
254
254
|
this.refreshCSS();
|
|
255
|
-
setTimeout(() => this.setState({
|
|
255
|
+
_index.default.setTimeout(() => this.setState({
|
|
256
256
|
pluginjson: pluginstringify
|
|
257
257
|
}));
|
|
258
258
|
}
|
package/compiled_src/lib.js
CHANGED
|
@@ -43,10 +43,10 @@ class Widget {
|
|
|
43
43
|
let user = await this.store.login(accid, user_id, tokenGenerator);
|
|
44
44
|
if (!$container) $container = document.body;
|
|
45
45
|
this.pluginMgr = new _plugin.default(this, $container);
|
|
46
|
-
let clean = setInterval(() => {
|
|
46
|
+
let clean = _index.default.setInterval(() => {
|
|
47
47
|
if ($container && $container.isConnected) return;
|
|
48
48
|
this.pluginMgr.destroy();
|
|
49
|
-
clearInterval(clean);
|
|
49
|
+
_index.default.clearInterval(clean);
|
|
50
50
|
}, 1000);
|
|
51
51
|
this.domGate.open();
|
|
52
52
|
return user;
|
|
@@ -61,10 +61,10 @@ class Widget {
|
|
|
61
61
|
let user = await this.store.init(accid, undefined, ref);
|
|
62
62
|
if (!$container) $container = document.body || document;
|
|
63
63
|
this.pluginMgr = new _plugin.default(this, $container);
|
|
64
|
-
let clean = setInterval(() => {
|
|
64
|
+
let clean = _index.default.setInterval(() => {
|
|
65
65
|
if ($container && $container.isConnected) return;
|
|
66
66
|
this.pluginMgr.destroy();
|
|
67
|
-
clearInterval(clean);
|
|
67
|
+
_index.default.clearInterval(clean);
|
|
68
68
|
}, 1000);
|
|
69
69
|
this.domGate.open();
|
|
70
70
|
return user;
|
|
@@ -73,10 +73,10 @@ class Widget {
|
|
|
73
73
|
let outmask = await this.store.init(id, mask);
|
|
74
74
|
if (!$container) $container = document.body || document;
|
|
75
75
|
this.pluginMgr = new _plugin.default(this, $container);
|
|
76
|
-
let clean = setInterval(() => {
|
|
76
|
+
let clean = _index.default.setInterval(() => {
|
|
77
77
|
if ($container && $container.isConnected) return;
|
|
78
78
|
this.pluginMgr.destroy();
|
|
79
|
-
clearInterval(clean);
|
|
79
|
+
_index.default.clearInterval(clean);
|
|
80
80
|
}, 1000);
|
|
81
81
|
this.domGate.open();
|
|
82
82
|
cb && cb(outmask);
|
|
@@ -28,7 +28,7 @@ class Notif extends _common.Com {
|
|
|
28
28
|
title: '',
|
|
29
29
|
last_show: 0
|
|
30
30
|
});
|
|
31
|
-
setTimeout(async () => {
|
|
31
|
+
_index.default.setTimeout(async () => {
|
|
32
32
|
let {
|
|
33
33
|
body: impression
|
|
34
34
|
} = await this.props.store.sendImpression(this.props.plugin.id);
|
|
@@ -101,7 +101,7 @@ class Notif extends _common.Com {
|
|
|
101
101
|
await this.waitForT();
|
|
102
102
|
if (!this.props.t) return;
|
|
103
103
|
if (!close) {
|
|
104
|
-
clearTimeout(this.lastCloseTimeout);
|
|
104
|
+
_index.default.clearTimeout(this.lastCloseTimeout);
|
|
105
105
|
this.setState({
|
|
106
106
|
closeAnimation: false
|
|
107
107
|
});
|
|
@@ -140,11 +140,11 @@ class Notif extends _common.Com {
|
|
|
140
140
|
closeAnimation: true
|
|
141
141
|
});
|
|
142
142
|
this.mouse_leave = _index.default.Date.now();
|
|
143
|
-
this.lastCloseTimeout = setTimeout(() => this.setState({
|
|
143
|
+
this.lastCloseTimeout = _index.default.setTimeout(() => this.setState({
|
|
144
144
|
close: true,
|
|
145
145
|
closeAnimation: false
|
|
146
146
|
}), 150);
|
|
147
|
-
if (this.props.plugin._dont_close) setTimeout(() => this.setState({
|
|
147
|
+
if (this.props.plugin._dont_close) _index.default.setTimeout(() => this.setState({
|
|
148
148
|
closeAnimation: false,
|
|
149
149
|
close: false
|
|
150
150
|
}), 1000);
|
|
@@ -158,7 +158,7 @@ class Notif extends _common.Com {
|
|
|
158
158
|
this.setClose(this.state.close);
|
|
159
159
|
}
|
|
160
160
|
componentWillUnmount() {
|
|
161
|
-
clearInterval(this.interval);
|
|
161
|
+
_index.default.clearInterval(this.interval);
|
|
162
162
|
_index.default.setCss(this.props.plugin.id, this.$cssStyleDiv, '');
|
|
163
163
|
}
|
|
164
164
|
async componentDidMount() {
|
|
@@ -174,7 +174,7 @@ class Notif extends _common.Com {
|
|
|
174
174
|
}
|
|
175
175
|
this.props.store.onResetCSS(this, () => this.refreshCSS());
|
|
176
176
|
await this.refreshCSS();
|
|
177
|
-
this.interval = setInterval(() => {
|
|
177
|
+
this.interval = _index.default.setInterval(() => {
|
|
178
178
|
if (this.props._destroy) return this.componentWillUnmount();
|
|
179
179
|
let mouseleave = this.mouse_leave;
|
|
180
180
|
if (mouseleave === 0) mouseleave = _index.default.Date.now();
|
|
@@ -187,7 +187,7 @@ class Notif extends _common.Com {
|
|
|
187
187
|
return this.setClose(false);
|
|
188
188
|
}
|
|
189
189
|
}, 1000);
|
|
190
|
-
setTimeout(() => {
|
|
190
|
+
_index.default.setTimeout(() => {
|
|
191
191
|
this.setState({
|
|
192
192
|
cssready: true
|
|
193
193
|
});
|
|
@@ -108,7 +108,7 @@ class AddressPicker extends _common.Com {
|
|
|
108
108
|
focusFilter() {
|
|
109
109
|
if (!this.filterRef.current) return;
|
|
110
110
|
this.filterRef.current.focus();
|
|
111
|
-
setTimeout(() => {
|
|
111
|
+
_index.default.setTimeout(() => {
|
|
112
112
|
if (!this.filterRef.current) return;
|
|
113
113
|
this.filterRef.current.focus();
|
|
114
114
|
}, 100);
|
|
@@ -20,7 +20,7 @@ class Countdown extends _common.Com {
|
|
|
20
20
|
_defineProperty(this, "state", {
|
|
21
21
|
flipKey: '43'
|
|
22
22
|
});
|
|
23
|
-
this.timer = setInterval(() => {
|
|
23
|
+
this.timer = _index.default.setInterval(() => {
|
|
24
24
|
if (this.props._destroy) return this.componentWillUnmount();
|
|
25
25
|
let cd = this.props.com.countdown || {};
|
|
26
26
|
let newFlipKey = 'cd' + ':' + cd.skin + ':' + cd.size + ':' + this.props.plugin.popup.font_family + ':';
|
|
@@ -31,7 +31,7 @@ class Countdown extends _common.Com {
|
|
|
31
31
|
}, 500);
|
|
32
32
|
}
|
|
33
33
|
componentWillUnmount() {
|
|
34
|
-
clearInterval(this.timer);
|
|
34
|
+
_index.default.clearInterval(this.timer);
|
|
35
35
|
}
|
|
36
36
|
getCountDownDeltaSec(countdown) {
|
|
37
37
|
let dest;
|
|
@@ -27,14 +27,14 @@ class Popup extends _common.Com {
|
|
|
27
27
|
fontReady: false
|
|
28
28
|
});
|
|
29
29
|
this._formRef = (0, _preact.createRef)();
|
|
30
|
-
setTimeout(() => this.fillForm(), 1000);
|
|
31
|
-
setTimeout(async () => {
|
|
30
|
+
_index.default.setTimeout(() => this.fillForm(), 1000);
|
|
31
|
+
_index.default.setTimeout(async () => {
|
|
32
32
|
let {
|
|
33
33
|
body: impression
|
|
34
34
|
} = await this.props.store.sendImpression(this.props.plugin.id);
|
|
35
35
|
this.impressionToken = _index.default.get(impression, 'impression_token') || '';
|
|
36
36
|
}, 10);
|
|
37
|
-
setTimeout(() => {
|
|
37
|
+
_index.default.setTimeout(() => {
|
|
38
38
|
let fonts = {};
|
|
39
39
|
fonts[this.props.plugin.popup.font_family] = true;
|
|
40
40
|
let images = {};
|
|
@@ -58,7 +58,7 @@ class Popup extends _common.Com {
|
|
|
58
58
|
imageReady: true
|
|
59
59
|
})));
|
|
60
60
|
_index.default.preloadWebfonts(Object.keys(fonts));
|
|
61
|
-
setTimeout(async () => {
|
|
61
|
+
_index.default.setTimeout(async () => {
|
|
62
62
|
await this.waitForFont(Object.keys(fonts));
|
|
63
63
|
this.setState({
|
|
64
64
|
fontReady: true
|
|
@@ -177,11 +177,11 @@ class Popup extends _common.Com {
|
|
|
177
177
|
this.setState({
|
|
178
178
|
closeAnimation: true
|
|
179
179
|
});
|
|
180
|
-
setTimeout(() => this.setState({
|
|
180
|
+
_index.default.setTimeout(() => this.setState({
|
|
181
181
|
close: true,
|
|
182
182
|
closeAnimation: false
|
|
183
183
|
}), 150);
|
|
184
|
-
if (this.props.plugin._dont_close) setTimeout(() => {
|
|
184
|
+
if (this.props.plugin._dont_close) _index.default.setTimeout(() => {
|
|
185
185
|
this.lastoverflow = window.getComputedStyle(document.body).getPropertyValue('overflow');
|
|
186
186
|
document.body.style.setProperty('overflow', 'hidden', 'important');
|
|
187
187
|
this.setState({
|
|
@@ -266,7 +266,7 @@ class Popup extends _common.Com {
|
|
|
266
266
|
if (a.action === 'open_widget') this.props.showWidget('list');
|
|
267
267
|
}
|
|
268
268
|
for (let a of actions) {
|
|
269
|
-
if (a.action === 'close') setTimeout(() => this.setClose(true), 100);
|
|
269
|
+
if (a.action === 'close') _index.default.setTimeout(() => this.setClose(true), 100);
|
|
270
270
|
if (a.action === 'next_page') this.props.nextPage();
|
|
271
271
|
}
|
|
272
272
|
for (let a of actions) {
|
|
@@ -695,7 +695,7 @@ class Popup extends _common.Com {
|
|
|
695
695
|
}
|
|
696
696
|
this.props.store.onResetCSS(this, () => this.refreshCSS());
|
|
697
697
|
await this.refreshCSS();
|
|
698
|
-
setTimeout(() => {
|
|
698
|
+
_index.default.setTimeout(() => {
|
|
699
699
|
this.setState({
|
|
700
700
|
cssready: true
|
|
701
701
|
});
|
|
@@ -186,7 +186,7 @@ class _default {
|
|
|
186
186
|
return this.last_token;
|
|
187
187
|
}
|
|
188
188
|
if (!force && this.last_token && age < 3000) {
|
|
189
|
-
if (this.token_generator) setTimeout(async () => {
|
|
189
|
+
if (this.token_generator) _index.default.setTimeout(async () => {
|
|
190
190
|
let token, err;
|
|
191
191
|
try {
|
|
192
192
|
token = await tokenGenerator(profile_id);
|
|
@@ -14,7 +14,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
14
14
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
15
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
16
|
var flow = require('@subiz/flow');
|
|
17
|
-
var Realtime = require('@subiz/wsclient
|
|
17
|
+
var Realtime = require('@subiz/wsclient');
|
|
18
18
|
var cookie = require('cookie_js');
|
|
19
19
|
cookie.defaults.path = '/';
|
|
20
20
|
cookie.expiresMultiplier = 60 * 60 * 24;
|
|
@@ -208,7 +208,7 @@ class Store {
|
|
|
208
208
|
if (!user.id) return;
|
|
209
209
|
var dev = this.getDeviceInfo();
|
|
210
210
|
if (!dev.ga_tracking_ids || !dev.ga_client_id) return;
|
|
211
|
-
clearInterval(_gaInterval);
|
|
211
|
+
_index.default.clearInterval(_gaInterval);
|
|
212
212
|
this.device = dev;
|
|
213
213
|
let ga_client_id = dev.ga_client_id;
|
|
214
214
|
if (ga_client_id !== _index.default.getUserAttr(user, 'ga_client_id', 'text')) {
|
|
@@ -405,7 +405,7 @@ class Store {
|
|
|
405
405
|
}
|
|
406
406
|
seenLoop() {
|
|
407
407
|
this.seenQueue = [];
|
|
408
|
-
clearInterval(this._seenInterval);
|
|
408
|
+
_index.default.clearInterval(this._seenInterval);
|
|
409
409
|
this._seenInterval = _index.default.setInterval(() => {
|
|
410
410
|
this.seenQueue = [...new Set(this.seenQueue)];
|
|
411
411
|
let user = this.cache.match('user') || {};
|
|
@@ -50,32 +50,32 @@ function trackInactivity(seconds, cb) {
|
|
|
50
50
|
let resetTime = () => {
|
|
51
51
|
inactiveSeconds = 0;
|
|
52
52
|
};
|
|
53
|
-
let timer = setInterval(() => {
|
|
53
|
+
let timer = common.setInterval(() => {
|
|
54
54
|
inactiveSeconds++;
|
|
55
55
|
if (inactiveSeconds < seconds) return;
|
|
56
56
|
if (cb) cb();
|
|
57
57
|
for (let ev of events) {
|
|
58
58
|
document.removeEventListener(ev, resetTime, false);
|
|
59
59
|
}
|
|
60
|
-
clearInterval(timer);
|
|
60
|
+
common.clearInterval(timer);
|
|
61
61
|
}, 1000);
|
|
62
62
|
for (let ev of events) {
|
|
63
63
|
document.addEventListener(ev, resetTime, false);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
let timeOnPage = 0;
|
|
67
|
-
setInterval(() => {
|
|
67
|
+
common.setInterval(() => {
|
|
68
68
|
timeOnPage += 5;
|
|
69
69
|
}, 5000);
|
|
70
70
|
function trackTimeOnPage(seconds, cb) {
|
|
71
71
|
if (seconds < 1) {
|
|
72
|
-
return setTimeout(function () {
|
|
72
|
+
return common.setTimeout(function () {
|
|
73
73
|
cb(seconds);
|
|
74
74
|
}, 100);
|
|
75
75
|
}
|
|
76
|
-
let timer = setInterval(() => {
|
|
76
|
+
let timer = common.setInterval(() => {
|
|
77
77
|
if (timeOnPage < seconds) return;
|
|
78
78
|
if (cb) cb(timeOnPage);
|
|
79
|
-
clearInterval(timer);
|
|
79
|
+
common.clearInterval(timer);
|
|
80
80
|
}, 1000);
|
|
81
81
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Date = exports.DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = exports.DEFVAL = void 0;
|
|
7
7
|
exports.agentsOfConvo = agentsOfConvo;
|
|
8
8
|
exports.checkRunConditions = checkRunConditions;
|
|
9
|
+
exports.clearTimeout = exports.clearInterval = void 0;
|
|
9
10
|
exports.cloneDeep = cloneDeep;
|
|
10
11
|
exports.convoOfEv = convoOfEv;
|
|
11
12
|
exports.convoToEv = convoToEv;
|
|
@@ -84,6 +85,10 @@ var setTimeout = f.contentWindow.setTimeout.bind(f.contentWindow);
|
|
|
84
85
|
exports.setTimeout = setTimeout;
|
|
85
86
|
var setInterval = f.contentWindow.setInterval.bind(f.contentWindow);
|
|
86
87
|
exports.setInterval = setInterval;
|
|
88
|
+
var clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow);
|
|
89
|
+
exports.clearInterval = clearInterval;
|
|
90
|
+
var clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow);
|
|
91
|
+
exports.clearTimeout = clearTimeout;
|
|
87
92
|
function convoOfEv(ev) {
|
|
88
93
|
if (!ev) return '';
|
|
89
94
|
switch (ev.type) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.19",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"@subiz/ajax": "^3.0.12",
|
|
13
13
|
"@subiz/flow": "^1.0.9",
|
|
14
14
|
"@subiz/storage": "0.0.8",
|
|
15
|
-
"@subiz/wsclient": "^
|
|
15
|
+
"@subiz/wsclient": "^4.0.9",
|
|
16
16
|
"cookie_js": "1.4.2",
|
|
17
|
-
"core-js": "^3.
|
|
17
|
+
"core-js": "^3.28.0",
|
|
18
18
|
"css-loader": "5.2.7",
|
|
19
19
|
"file-loader": "^6.2.0",
|
|
20
20
|
"less": "^4.1.3",
|
|
21
21
|
"less-loader": "^11.1.0",
|
|
22
22
|
"marked": "^4.2.12",
|
|
23
|
-
"preact": "^10.
|
|
23
|
+
"preact": "^10.12.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/cli": "^7.20.7",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"babel-loader": "^9.1.2",
|
|
32
32
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
33
33
|
"html-webpack-plugin": "^5.5.0",
|
|
34
|
-
"prettier": "^2.8.
|
|
35
|
-
"puppeteer": "^19.
|
|
34
|
+
"prettier": "^2.8.4",
|
|
35
|
+
"puppeteer": "^19.7.0",
|
|
36
36
|
"webpack": "^5.75.0",
|
|
37
|
-
"webpack-bundle-analyzer": "^4.
|
|
37
|
+
"webpack-bundle-analyzer": "^4.8.0",
|
|
38
38
|
"webpack-cli": "^5.0.1",
|
|
39
39
|
"webpack-dev-server": "^4.11.1"
|
|
40
40
|
}
|
package/src/call/call.js
CHANGED
|
@@ -22,7 +22,7 @@ export default class Notif extends Com {
|
|
|
22
22
|
constructor(props) {
|
|
23
23
|
super(props)
|
|
24
24
|
|
|
25
|
-
setTimeout(async () => {
|
|
25
|
+
sb.setTimeout(async () => {
|
|
26
26
|
let {body: impression} = await this.props.store.sendImpression(this.props.plugin.id)
|
|
27
27
|
this.impressionToken = sb.get(impression, 'impression_token') || ''
|
|
28
28
|
|
|
@@ -95,7 +95,7 @@ export default class Notif extends Com {
|
|
|
95
95
|
if (!this.props.t) return
|
|
96
96
|
|
|
97
97
|
if (!close) {
|
|
98
|
-
clearTimeout(this.lastCloseTimeout)
|
|
98
|
+
sb.clearTimeout(this.lastCloseTimeout)
|
|
99
99
|
|
|
100
100
|
this.setState({closeAnimation: false})
|
|
101
101
|
let timestamp = this.randomTimestampt()
|
|
@@ -133,8 +133,8 @@ export default class Notif extends Com {
|
|
|
133
133
|
}
|
|
134
134
|
this.setState({closeAnimation: true})
|
|
135
135
|
this.mouse_leave = sb.Date.now()
|
|
136
|
-
this.lastCloseTimeout = setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
|
|
137
|
-
if (this.props.plugin._dont_close) setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
|
|
136
|
+
this.lastCloseTimeout = sb.setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
|
|
137
|
+
if (this.props.plugin._dont_close) sb.setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
async refreshCSS() {
|
|
@@ -149,7 +149,7 @@ export default class Notif extends Com {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
componentWillUnmount() {
|
|
152
|
-
clearInterval(this.interval)
|
|
152
|
+
sb.clearInterval(this.interval)
|
|
153
153
|
sb.setCss(this.props.plugin.id, this.$cssStyleDiv, '')
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -166,7 +166,7 @@ export default class Notif extends Com {
|
|
|
166
166
|
this.props.store.onResetCSS(this, () => this.refreshCSS())
|
|
167
167
|
await this.refreshCSS()
|
|
168
168
|
|
|
169
|
-
this.interval = setInterval(() => {
|
|
169
|
+
this.interval = sb.setInterval(() => {
|
|
170
170
|
if (this.props._destroy) return this.componentWillUnmount()
|
|
171
171
|
// keep notification open when user hover on it
|
|
172
172
|
// but dont close right after mouse leave, activate after 1 sec
|
|
@@ -182,7 +182,7 @@ export default class Notif extends Com {
|
|
|
182
182
|
}
|
|
183
183
|
}, 1000)
|
|
184
184
|
|
|
185
|
-
setTimeout(() => {
|
|
185
|
+
sb.setTimeout(() => {
|
|
186
186
|
this.setState({cssready: true})
|
|
187
187
|
this.setClose(false) // auto open when created
|
|
188
188
|
}, 50)
|
|
@@ -114,7 +114,7 @@ export default class DropdownSelect extends Com {
|
|
|
114
114
|
focusFilter() {
|
|
115
115
|
if (!this.filterRef.current) return
|
|
116
116
|
this.filterRef.current.focus()
|
|
117
|
-
setTimeout(() => {
|
|
117
|
+
sb.setTimeout(() => {
|
|
118
118
|
if (!this.filterRef.current) return
|
|
119
119
|
this.filterRef.current.focus()
|
|
120
120
|
}, 100)
|
package/src/chatbox/Event.js
CHANGED
|
@@ -167,7 +167,7 @@ export default class Event extends Com {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
if (sb.getMsgField(ev, 'idempotency') === ev.id && this.props.store.now() - ev.created < 900) {
|
|
170
|
-
setTimeout(() => this.setState({refresh: this.state.refresh}), 1000)
|
|
170
|
+
sb.setTimeout(() => this.setState({refresh: this.state.refresh}), 1000)
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
// only show sending while the message is send too long (>300ms) but haven't returned from
|
package/src/chatbox/Events.js
CHANGED
|
@@ -173,7 +173,7 @@ export default class Events extends Com {
|
|
|
173
173
|
this.setState({error: false})
|
|
174
174
|
this.scrollToBottom()
|
|
175
175
|
|
|
176
|
-
setTimeout(() => this.setState({loading: false}), 50)
|
|
176
|
+
sb.setTimeout(() => this.setState({loading: false}), 50)
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
isBottom() {
|
|
@@ -183,11 +183,11 @@ export default class Events extends Com {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
scrollToBottom() {
|
|
186
|
-
setTimeout(() => {
|
|
186
|
+
sb.setTimeout(() => {
|
|
187
187
|
const $div = this.refBody
|
|
188
188
|
if ($div) $div.scrollTop = $div.scrollHeight
|
|
189
189
|
})
|
|
190
|
-
setTimeout(() => {
|
|
190
|
+
sb.setTimeout(() => {
|
|
191
191
|
const $div = this.refBody
|
|
192
192
|
if ($div) $div.scrollTop = $div.scrollHeight
|
|
193
193
|
}, 200)
|
|
@@ -228,10 +228,10 @@ export default class MessageInput extends Com {
|
|
|
228
228
|
focus() {
|
|
229
229
|
if (this.props.disabled) return
|
|
230
230
|
this.refMessageInput.current && this.refMessageInput.current.focus()
|
|
231
|
-
setTimeout(() => {
|
|
231
|
+
sb.setTimeout(() => {
|
|
232
232
|
this.refMessageInput.current && this.refMessageInput.current.focus()
|
|
233
233
|
})
|
|
234
|
-
setTimeout(() => {
|
|
234
|
+
sb.setTimeout(() => {
|
|
235
235
|
this.refMessageInput.current && this.refMessageInput.current.focus()
|
|
236
236
|
}, 100)
|
|
237
237
|
}
|
package/src/chatbox/Order.js
CHANGED
package/src/chatbox/Rating.js
CHANGED
|
@@ -155,7 +155,7 @@ export default class Rating extends Com {
|
|
|
155
155
|
if (!this.state.hide) return
|
|
156
156
|
this.setState({hide: false})
|
|
157
157
|
if (!this.refRating.current) return
|
|
158
|
-
setTimeout(() => {
|
|
158
|
+
sb.setTimeout(() => {
|
|
159
159
|
if (this.refComment.current) this.refComment.current.focus()
|
|
160
160
|
}, 400)
|
|
161
161
|
this.refComment.current.value = ''
|
package/src/chatbox/Typing.js
CHANGED
|
@@ -23,7 +23,7 @@ export default class Typing extends Com {
|
|
|
23
23
|
|
|
24
24
|
if (sb.get(ev, 'type') === 'message_sent') {
|
|
25
25
|
// stop the typing
|
|
26
|
-
if (this.timer) clearTimeout(this.timer)
|
|
26
|
+
if (this.timer) sb.clearTimeout(this.timer)
|
|
27
27
|
this.timer = null
|
|
28
28
|
this.setState({isShow: false})
|
|
29
29
|
return
|
|
@@ -35,8 +35,8 @@ export default class Typing extends Com {
|
|
|
35
35
|
|
|
36
36
|
if (sb.get(ev, 'type') !== 'conversation_typing') return
|
|
37
37
|
this.setState({ev: ev, isShow: true})
|
|
38
|
-
if (this.timer) clearTimeout(this.timer)
|
|
39
|
-
this.timer = setTimeout(() => {
|
|
38
|
+
if (this.timer) sb.clearTimeout(this.timer)
|
|
39
|
+
this.timer = sb.setTimeout(() => {
|
|
40
40
|
if (sb.convoOfEv(ev) !== this.props.cid) return
|
|
41
41
|
|
|
42
42
|
this.timer = null
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -53,7 +53,7 @@ export default class Widget extends Com {
|
|
|
53
53
|
this.closeOrder()
|
|
54
54
|
this.setState({clickedJoin: false, quickReplyMessage: {}})
|
|
55
55
|
// this.props.store.setLastview('chat', { cid: this.props.cid })
|
|
56
|
-
setTimeout(() => {
|
|
56
|
+
sb.setTimeout(() => {
|
|
57
57
|
// focus Events then focus MessageInput
|
|
58
58
|
// if there is any pending form, MessageInput will be disabled
|
|
59
59
|
// and dont steal focus from Events
|
|
@@ -642,8 +642,8 @@ export default class Widget extends Com {
|
|
|
642
642
|
if (this.props.store.isPreview) return
|
|
643
643
|
var $input = this.msgInput.current
|
|
644
644
|
if (!$input) return
|
|
645
|
-
setTimeout(() => $input && $input.blur())
|
|
646
|
-
setTimeout(() => $input && $input.blur(), 300) // force lose focus
|
|
645
|
+
sb.setTimeout(() => $input && $input.blur())
|
|
646
|
+
sb.setTimeout(() => $input && $input.blur(), 300) // force lose focus
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
focusInput() {
|
|
@@ -659,7 +659,7 @@ export default class Widget extends Com {
|
|
|
659
659
|
if (!field.value) firstemptykey = key
|
|
660
660
|
})
|
|
661
661
|
|
|
662
|
-
setTimeout(() => {
|
|
662
|
+
sb.setTimeout(() => {
|
|
663
663
|
var $input = this['form_' + encode(firstemptykey)]
|
|
664
664
|
if (!$input) return
|
|
665
665
|
|
|
@@ -670,8 +670,8 @@ export default class Widget extends Com {
|
|
|
670
670
|
|
|
671
671
|
var $input = this.msgInput.current
|
|
672
672
|
if (!$input) return
|
|
673
|
-
setTimeout(() => $input.focus())
|
|
674
|
-
setTimeout(() => $input.focus(), 300) // force focus
|
|
673
|
+
sb.setTimeout(() => $input.focus())
|
|
674
|
+
sb.setTimeout(() => $input.focus(), 300) // force focus
|
|
675
675
|
}
|
|
676
676
|
|
|
677
677
|
onRate(rating) {
|
package/src/chatbox/time.js
CHANGED
package/src/common.js
CHANGED
|
@@ -5,7 +5,7 @@ export class Com extends Component {
|
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props)
|
|
7
7
|
this._isMounted = true
|
|
8
|
-
setTimeout(() => {
|
|
8
|
+
sb.setTimeout(() => {
|
|
9
9
|
if (this.componentWillUnmount) {
|
|
10
10
|
let old = this.componentWillUnmount.bind(this)
|
|
11
11
|
this.componentWillUnmount = () => {
|
|
@@ -74,7 +74,7 @@ let downloadLock = false
|
|
|
74
74
|
|
|
75
75
|
export function downloadLanguage(store, locale, force) {
|
|
76
76
|
if (downloadLock)
|
|
77
|
-
return new Promise((resolve) => setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100))
|
|
77
|
+
return new Promise((resolve) => sb.setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100))
|
|
78
78
|
|
|
79
79
|
downloadLock = true
|
|
80
80
|
// let locale = getLocale()
|
package/src/contact/contact.js
CHANGED
|
@@ -262,7 +262,7 @@ export default class Contact extends Com {
|
|
|
262
262
|
|
|
263
263
|
if (this.state.pluginjson !== pluginstringify) {
|
|
264
264
|
this.refreshCSS()
|
|
265
|
-
setTimeout(() => this.setState({pluginjson: pluginstringify}))
|
|
265
|
+
sb.setTimeout(() => this.setState({pluginjson: pluginstringify}))
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
if (this.state.close) return null
|
package/src/lib.js
CHANGED
|
@@ -33,11 +33,11 @@ class Widget {
|
|
|
33
33
|
if (!$container) $container = document.body
|
|
34
34
|
this.pluginMgr = new PluginMgr(this, $container)
|
|
35
35
|
|
|
36
|
-
let clean = setInterval(() => {
|
|
36
|
+
let clean = sb.setInterval(() => {
|
|
37
37
|
// check if the dom is deleted
|
|
38
38
|
if ($container && $container.isConnected) return
|
|
39
39
|
this.pluginMgr.destroy()
|
|
40
|
-
clearInterval(clean)
|
|
40
|
+
sb.clearInterval(clean)
|
|
41
41
|
}, 1000)
|
|
42
42
|
this.domGate.open()
|
|
43
43
|
return user
|
|
@@ -57,11 +57,11 @@ class Widget {
|
|
|
57
57
|
if (!$container) $container = document.body || document
|
|
58
58
|
this.pluginMgr = new PluginMgr(this, $container)
|
|
59
59
|
|
|
60
|
-
let clean = setInterval(() => {
|
|
60
|
+
let clean = sb.setInterval(() => {
|
|
61
61
|
// check if the dom is deleted
|
|
62
62
|
if ($container && $container.isConnected) return
|
|
63
63
|
this.pluginMgr.destroy()
|
|
64
|
-
clearInterval(clean)
|
|
64
|
+
sb.clearInterval(clean)
|
|
65
65
|
}, 1000)
|
|
66
66
|
this.domGate.open()
|
|
67
67
|
return user
|
|
@@ -73,11 +73,11 @@ class Widget {
|
|
|
73
73
|
if (!$container) $container = document.body || document
|
|
74
74
|
this.pluginMgr = new PluginMgr(this, $container)
|
|
75
75
|
|
|
76
|
-
let clean = setInterval(() => {
|
|
76
|
+
let clean = sb.setInterval(() => {
|
|
77
77
|
// check if the dom is deleted
|
|
78
78
|
if ($container && $container.isConnected) return
|
|
79
79
|
this.pluginMgr.destroy()
|
|
80
|
-
clearInterval(clean)
|
|
80
|
+
sb.clearInterval(clean)
|
|
81
81
|
}, 1000)
|
|
82
82
|
this.domGate.open()
|
|
83
83
|
cb && cb(outmask)
|
package/src/notif/notif.js
CHANGED
|
@@ -22,7 +22,7 @@ export default class Notif extends Com {
|
|
|
22
22
|
constructor(props) {
|
|
23
23
|
super(props)
|
|
24
24
|
|
|
25
|
-
setTimeout(async () => {
|
|
25
|
+
sb.setTimeout(async () => {
|
|
26
26
|
let {body: impression} = await this.props.store.sendImpression(this.props.plugin.id)
|
|
27
27
|
this.impressionToken = sb.get(impression, 'impression_token') || ''
|
|
28
28
|
|
|
@@ -96,7 +96,7 @@ export default class Notif extends Com {
|
|
|
96
96
|
if (!this.props.t) return
|
|
97
97
|
|
|
98
98
|
if (!close) {
|
|
99
|
-
clearTimeout(this.lastCloseTimeout)
|
|
99
|
+
sb.clearTimeout(this.lastCloseTimeout)
|
|
100
100
|
|
|
101
101
|
this.setState({closeAnimation: false})
|
|
102
102
|
let timestamp = this.randomTimestampt()
|
|
@@ -139,8 +139,8 @@ export default class Notif extends Com {
|
|
|
139
139
|
}
|
|
140
140
|
this.setState({closeAnimation: true})
|
|
141
141
|
this.mouse_leave = sb.Date.now()
|
|
142
|
-
this.lastCloseTimeout = setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
|
|
143
|
-
if (this.props.plugin._dont_close) setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
|
|
142
|
+
this.lastCloseTimeout = sb.setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
|
|
143
|
+
if (this.props.plugin._dont_close) sb.setTimeout(() => this.setState({closeAnimation: false, close: false}), 1000)
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
async refreshCSS() {
|
|
@@ -155,7 +155,7 @@ export default class Notif extends Com {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
componentWillUnmount() {
|
|
158
|
-
clearInterval(this.interval)
|
|
158
|
+
sb.clearInterval(this.interval)
|
|
159
159
|
sb.setCss(this.props.plugin.id, this.$cssStyleDiv, '')
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -172,7 +172,7 @@ export default class Notif extends Com {
|
|
|
172
172
|
this.props.store.onResetCSS(this, () => this.refreshCSS())
|
|
173
173
|
await this.refreshCSS()
|
|
174
174
|
|
|
175
|
-
this.interval = setInterval(() => {
|
|
175
|
+
this.interval = sb.setInterval(() => {
|
|
176
176
|
if (this.props._destroy) return this.componentWillUnmount()
|
|
177
177
|
// keep notification open when user hover on it
|
|
178
178
|
// but dont close right after mouse leave, activate after 1 sec
|
|
@@ -188,7 +188,7 @@ export default class Notif extends Com {
|
|
|
188
188
|
}
|
|
189
189
|
}, 1000)
|
|
190
190
|
|
|
191
|
-
setTimeout(() => {
|
|
191
|
+
sb.setTimeout(() => {
|
|
192
192
|
this.setState({cssready: true})
|
|
193
193
|
this.setClose(false) // auto open when created
|
|
194
194
|
}, 50)
|
|
@@ -106,7 +106,7 @@ export default class AddressPicker extends Com {
|
|
|
106
106
|
focusFilter() {
|
|
107
107
|
if (!this.filterRef.current) return
|
|
108
108
|
this.filterRef.current.focus()
|
|
109
|
-
setTimeout(() => {
|
|
109
|
+
sb.setTimeout(() => {
|
|
110
110
|
if (!this.filterRef.current) return
|
|
111
111
|
this.filterRef.current.focus()
|
|
112
112
|
}, 100)
|
package/src/popup/countdown.js
CHANGED
|
@@ -15,7 +15,7 @@ export default class Countdown extends Com {
|
|
|
15
15
|
|
|
16
16
|
constructor(props) {
|
|
17
17
|
super(props)
|
|
18
|
-
this.timer = setInterval(() => {
|
|
18
|
+
this.timer = sb.setInterval(() => {
|
|
19
19
|
if (this.props._destroy) return this.componentWillUnmount()
|
|
20
20
|
let cd = this.props.com.countdown || {}
|
|
21
21
|
let newFlipKey = 'cd' + ':' + cd.skin + ':' + cd.size + ':' + this.props.plugin.popup.font_family + ':'
|
|
@@ -25,7 +25,7 @@ export default class Countdown extends Com {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
componentWillUnmount() {
|
|
28
|
-
clearInterval(this.timer)
|
|
28
|
+
sb.clearInterval(this.timer)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
getCountDownDeltaSec(countdown) {
|
package/src/popup/popup.js
CHANGED
|
@@ -19,14 +19,14 @@ export default class Popup extends Com {
|
|
|
19
19
|
constructor(props) {
|
|
20
20
|
super(props)
|
|
21
21
|
this._formRef = createRef()
|
|
22
|
-
setTimeout(() => this.fillForm(), 1000)
|
|
22
|
+
sb.setTimeout(() => this.fillForm(), 1000)
|
|
23
23
|
|
|
24
|
-
setTimeout(async () => {
|
|
24
|
+
sb.setTimeout(async () => {
|
|
25
25
|
let {body: impression} = await this.props.store.sendImpression(this.props.plugin.id)
|
|
26
26
|
this.impressionToken = sb.get(impression, 'impression_token') || ''
|
|
27
27
|
}, 10)
|
|
28
28
|
|
|
29
|
-
setTimeout(() => {
|
|
29
|
+
sb.setTimeout(() => {
|
|
30
30
|
let fonts = {}
|
|
31
31
|
fonts[this.props.plugin.popup.font_family] = true
|
|
32
32
|
let images = {}
|
|
@@ -48,7 +48,7 @@ export default class Popup extends Com {
|
|
|
48
48
|
// preload images and fonts
|
|
49
49
|
sb.map(images, (_, image) => sb.preloadImg(image, () => this.setState({imageReady: true})))
|
|
50
50
|
sb.preloadWebfonts(Object.keys(fonts))
|
|
51
|
-
setTimeout(async () => {
|
|
51
|
+
sb.setTimeout(async () => {
|
|
52
52
|
await this.waitForFont(Object.keys(fonts))
|
|
53
53
|
this.setState({fontReady: true})
|
|
54
54
|
})
|
|
@@ -169,9 +169,9 @@ export default class Popup extends Com {
|
|
|
169
169
|
if (close) {
|
|
170
170
|
document.body.style.setProperty('overflow', this.lastoverflow)
|
|
171
171
|
this.setState({closeAnimation: true})
|
|
172
|
-
setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
|
|
172
|
+
sb.setTimeout(() => this.setState({close: true, closeAnimation: false}), 150)
|
|
173
173
|
if (this.props.plugin._dont_close)
|
|
174
|
-
setTimeout(() => {
|
|
174
|
+
sb.setTimeout(() => {
|
|
175
175
|
this.lastoverflow = window.getComputedStyle(document.body).getPropertyValue('overflow')
|
|
176
176
|
document.body.style.setProperty('overflow', 'hidden', 'important')
|
|
177
177
|
this.setState({closeAnimation: false, close: false})
|
|
@@ -255,7 +255,7 @@ export default class Popup extends Com {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
for (let a of actions) {
|
|
258
|
-
if (a.action === 'close') setTimeout(() => this.setClose(true), 100)
|
|
258
|
+
if (a.action === 'close') sb.setTimeout(() => this.setClose(true), 100)
|
|
259
259
|
if (a.action === 'next_page') this.props.nextPage()
|
|
260
260
|
}
|
|
261
261
|
|
|
@@ -747,7 +747,7 @@ export default class Popup extends Com {
|
|
|
747
747
|
this.props.store.onResetCSS(this, () => this.refreshCSS())
|
|
748
748
|
|
|
749
749
|
await this.refreshCSS()
|
|
750
|
-
setTimeout(() => {
|
|
750
|
+
sb.setTimeout(() => {
|
|
751
751
|
this.setState({cssready: true})
|
|
752
752
|
this.setClose(false) // auto open when created
|
|
753
753
|
}, 50)
|
package/src/store/api.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import sb from '../util/index.js'
|
|
2
|
-
|
|
3
2
|
const ajax = require('@subiz/ajax/src/ajax.js')
|
|
4
3
|
ajax.env.XMLHttpRequest = window.XMLHttpRequest
|
|
5
4
|
|
|
@@ -41,7 +40,7 @@ export default class {
|
|
|
41
40
|
|
|
42
41
|
return done(true)
|
|
43
42
|
})
|
|
44
|
-
// .beforeHook((param, done) => setTimeout((_) => done(true), 1000))
|
|
43
|
+
// .beforeHook((param, done) => sb.setTimeout((_) => done(true), 1000))
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
setAgentId(agid) {
|
|
@@ -109,7 +108,7 @@ export default class {
|
|
|
109
108
|
if (!force && this.last_token && age < 3000) {
|
|
110
109
|
// the token is still good, but should get new one
|
|
111
110
|
if (this.token_generator)
|
|
112
|
-
setTimeout(async () => {
|
|
111
|
+
sb.setTimeout(async () => {
|
|
113
112
|
let token, err
|
|
114
113
|
try {
|
|
115
114
|
token = await tokenGenerator(profile_id)
|
package/src/store/store.js
CHANGED
|
@@ -4,7 +4,7 @@ import stor8 from '@subiz/storage'
|
|
|
4
4
|
import API from './api.js'
|
|
5
5
|
import APIFake from './api_fake.js'
|
|
6
6
|
import RealtimeFake from './realtime_fake.js'
|
|
7
|
-
var Realtime = require('@subiz/wsclient
|
|
7
|
+
var Realtime = require('@subiz/wsclient')
|
|
8
8
|
var cookie = require('cookie_js')
|
|
9
9
|
cookie.defaults.path = '/'
|
|
10
10
|
cookie.expiresMultiplier = 60 * 60 * 24 // days
|
|
@@ -79,7 +79,7 @@ export default class Store {
|
|
|
79
79
|
if (!user.id) return // store not init
|
|
80
80
|
var dev = this.getDeviceInfo()
|
|
81
81
|
if (!dev.ga_tracking_ids || !dev.ga_client_id) return
|
|
82
|
-
clearInterval(_gaInterval)
|
|
82
|
+
sb.clearInterval(_gaInterval)
|
|
83
83
|
this.device = dev
|
|
84
84
|
|
|
85
85
|
// update gclient id
|
|
@@ -463,7 +463,7 @@ export default class Store {
|
|
|
463
463
|
seenLoop() {
|
|
464
464
|
// periodically send seen
|
|
465
465
|
this.seenQueue = []
|
|
466
|
-
clearInterval(this._seenInterval)
|
|
466
|
+
sb.clearInterval(this._seenInterval)
|
|
467
467
|
this._seenInterval = sb.setInterval(() => {
|
|
468
468
|
// deduplicate
|
|
469
469
|
this.seenQueue = [...new Set(this.seenQueue)]
|
package/src/util/campaign.js
CHANGED
|
@@ -65,14 +65,14 @@ export function trackInactivity(seconds, cb) {
|
|
|
65
65
|
let resetTime = () => {
|
|
66
66
|
inactiveSeconds = 0
|
|
67
67
|
}
|
|
68
|
-
let timer = setInterval(() => {
|
|
68
|
+
let timer = common.setInterval(() => {
|
|
69
69
|
inactiveSeconds++
|
|
70
70
|
if (inactiveSeconds < seconds) return
|
|
71
71
|
if (cb) cb()
|
|
72
72
|
for (let ev of events) {
|
|
73
73
|
document.removeEventListener(ev, resetTime, false)
|
|
74
74
|
}
|
|
75
|
-
clearInterval(timer)
|
|
75
|
+
common.clearInterval(timer)
|
|
76
76
|
}, 1000)
|
|
77
77
|
|
|
78
78
|
for (let ev of events) {
|
|
@@ -81,21 +81,21 @@ export function trackInactivity(seconds, cb) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
let timeOnPage = 0 // seconds
|
|
84
|
-
setInterval(() => {
|
|
84
|
+
common.setInterval(() => {
|
|
85
85
|
timeOnPage += 5
|
|
86
86
|
}, 5000)
|
|
87
87
|
|
|
88
88
|
// when user has been on the page for at least X seconds
|
|
89
89
|
export function trackTimeOnPage(seconds, cb) {
|
|
90
90
|
if (seconds < 1) {
|
|
91
|
-
return setTimeout(function () {
|
|
91
|
+
return common.setTimeout(function () {
|
|
92
92
|
cb(seconds)
|
|
93
93
|
}, 100)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
let timer = setInterval(() => {
|
|
96
|
+
let timer = common.setInterval(() => {
|
|
97
97
|
if (timeOnPage < seconds) return
|
|
98
98
|
if (cb) cb(timeOnPage)
|
|
99
|
-
clearInterval(timer)
|
|
99
|
+
common.clearInterval(timer)
|
|
100
100
|
}, 1000)
|
|
101
101
|
}
|
package/src/util/common.js
CHANGED
|
@@ -16,6 +16,8 @@ export var Date = f.contentWindow.Date
|
|
|
16
16
|
export var requestAnimationFrame = f.contentWindow.requestAnimationFrame
|
|
17
17
|
export var setTimeout = f.contentWindow.setTimeout.bind(f.contentWindow)
|
|
18
18
|
export var setInterval = f.contentWindow.setInterval.bind(f.contentWindow)
|
|
19
|
+
export var clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow)
|
|
20
|
+
export var clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow)
|
|
19
21
|
|
|
20
22
|
// convoOfEv extracts the ID of the conversation
|
|
21
23
|
// that event is sent to
|