@94ai/nf-softphone 8.3.7 → 8.3.10

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.
@@ -0,0 +1,648 @@
1
+ type Option = {
2
+ origin: string
3
+ ancestorOrigin: string
4
+ destinationOrigin: string
5
+ scrollingText: string
6
+ scrollview: string
7
+ envMap: Record<Env, string>,
8
+ env: string
9
+ selector: string
10
+ el: string
11
+ agentTag: string
12
+ agentId: string
13
+ appKey: string
14
+ appSecret: string
15
+ timestamp: string | number
16
+ sign: string
17
+ sgGateway: string
18
+ sgBase: string
19
+ sgOpen: string
20
+ sgDomain: string
21
+
22
+ extStatus: '0' | '1'
23
+ instanceMap: Record<string, any>,
24
+
25
+ callShow: '0' | '1'
26
+ transferToLaborShow: '0' | '1'
27
+ restShow: '0' | '1'
28
+ networkDetectShow: '0' | '1'
29
+ muteShow: '0' | '1'
30
+ logShow: '0' | '1'
31
+ timingShow: '0' | '1'
32
+ signShow: '0' | '1'
33
+
34
+ softphoneConnectCallBack: Function
35
+ softphoneCallRefreshCallBack: Function
36
+ softphoneSeatStatusChangeCallBack: Function
37
+ softphoneAcceptCallBack: Function
38
+ softphoneIgnoreCallBack: Function
39
+ softphoneHangupCallBack: Function
40
+ softphoneSessionStateChangeCallBack: Function
41
+ softphoneIncomingCallBack: Function
42
+ softphoneSendDtmfCallBack: Function
43
+ softphoneConnectRegisteredCallBack: Function
44
+ softphoneSignOverduedCallBack: Function
45
+ }
46
+
47
+ type Env = 'test' |'dev'| 'sg'| 'gray'| 'prod'
48
+
49
+ function generateUUID() { // Public Domain/MIT
50
+ let d = Date.now();
51
+ if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
52
+ d += performance.now(); //use high-precision timer if available
53
+ }
54
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
55
+ const r = (d + Math.random() * 16) % 16 | 0;
56
+ d = Math.floor(d / 16);
57
+ return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
58
+ });
59
+ }
60
+
61
+ function debounce(func, wait, immediate) {
62
+ let timeout, args, context, timestamp, result
63
+
64
+ const later = function() {
65
+ // 据上一次触发时间间隔
66
+ const last = +new Date() - timestamp
67
+
68
+ // 上次被包装函数被调用时间间隔last小于设定时间间隔wait
69
+ if (last < wait && last > 0) {
70
+ timeout = setTimeout(later, wait - last)
71
+ } else {
72
+ timeout = null
73
+ // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
74
+ if (!immediate) {
75
+ result = func.apply(context, args)
76
+ if (!timeout) context = args = null
77
+ }
78
+ }
79
+ }
80
+
81
+ return function(...args) {
82
+ // @ts-ignore
83
+ context = this
84
+ timestamp = +new Date()
85
+ const callNow = immediate && !timeout
86
+ // 如果延时不存在,重新设定延时
87
+ if (!timeout) timeout = setTimeout(later, wait)
88
+ if (callNow) {
89
+ result = func.apply(context, args)
90
+ // @ts-ignore
91
+ context = args = null
92
+ }
93
+
94
+ return result
95
+ }
96
+ }
97
+
98
+ // 用于存储传入 nextTick 的回调函数
99
+ const callbacks: any = [];
100
+ // 标记是否已经安排了回调函数的执行
101
+ let pending = false;
102
+
103
+ // 执行队列中的所有回调函数
104
+ function flushCallbacks() {
105
+ pending = false;
106
+ // 复制一份当前的回调队列,避免在执行过程中添加新的回调影响循环
107
+ const copies: any = callbacks.slice(0);
108
+ callbacks.length = 0;
109
+ // 依次执行每个回调函数,并处理可能出现的异常
110
+ for (let i = 0; i < copies.length; i++) {
111
+ try {
112
+ copies[i]();
113
+ } catch (e) {
114
+ console.error('Error in nextTick callback:', e);
115
+ }
116
+ }
117
+ }
118
+
119
+ // 根据浏览器支持情况选择合适的异步执行方式
120
+ let timerFunc;
121
+ if (typeof Promise !== 'undefined') {
122
+ // 如果支持 Promise,使用 Promise 的 then 方法创建微任务
123
+ const p = Promise.resolve();
124
+ timerFunc = () => {
125
+ p.then(flushCallbacks);
126
+ };
127
+ } else if (typeof MutationObserver !== 'undefined') {
128
+ // 如果支持 MutationObserver,使用它创建微任务
129
+ let counter = 1;
130
+ const observer = new MutationObserver(flushCallbacks);
131
+ const textNode = document.createTextNode(String(counter));
132
+ observer.observe(textNode, {
133
+ characterData: true
134
+ });
135
+ timerFunc = () => {
136
+ counter = (counter + 1) % 2;
137
+ textNode.data = String(counter);
138
+ };
139
+ } else if (typeof setImmediate !== 'undefined') {
140
+ // 如果支持 setImmediate,使用它创建宏任务
141
+ timerFunc = () => {
142
+ setImmediate(flushCallbacks);
143
+ };
144
+ } else {
145
+ // 最后使用 setTimeout 作为兜底方案创建宏任务
146
+ timerFunc = () => {
147
+ setTimeout(flushCallbacks, 0);
148
+ };
149
+ }
150
+
151
+ // 实现 nextTick 函数,支持传入回调函数或返回 Promise
152
+ async function nextTick(cb?) {
153
+ return new Promise((resolve) => {
154
+ // 将回调函数和 resolve 函数封装成一个新的回调
155
+ callbacks.push(() => {
156
+ if (cb) {
157
+ try {
158
+ cb();
159
+ } catch (e) {
160
+ console.error('Error in nextTick callback:', e);
161
+ }
162
+ }
163
+ // 当回调执行完毕后,resolve Promise
164
+ resolve(true);
165
+ });
166
+ // 如果当前没有正在执行的回调安排,安排一次新的执行
167
+ if (!pending) {
168
+ pending = true;
169
+ timerFunc();
170
+ }
171
+ });
172
+ }
173
+
174
+ export class SoftphoneManager {
175
+
176
+ id
177
+ timer
178
+
179
+ constructor() {
180
+ /**
181
+ * 隔离链接实例
182
+ */
183
+ this.id = generateUUID()
184
+ }
185
+
186
+ option: Partial<Option> = {
187
+ origin: 'ai-softphone',
188
+ ancestorOrigin: 'nf-softphone',
189
+ destinationOrigin: '*',
190
+
191
+ scrollview: undefined,
192
+ scrollingText: '正在滚动中...',
193
+
194
+ envMap: {
195
+ test: 'http://softphone.test.k8s.com',
196
+ dev: 'http://softphone.dev.k8s.com',
197
+ sg: 'https://seatsg.94ai.com',
198
+ gray: 'http://softphone.gray.94ai.com',
199
+ prod: 'https://seat.94ai.com',
200
+ },
201
+ env: 'prod',
202
+ selector: undefined,
203
+ el: undefined,
204
+
205
+ agentId: undefined,
206
+ agentTag: undefined,
207
+ appKey: undefined,
208
+ appSecret: undefined,
209
+
210
+ sgGateway: undefined,
211
+ sgBase: undefined,
212
+ sgOpen: undefined,
213
+ sgDomain: undefined,
214
+
215
+ timestamp: undefined,
216
+ sign: undefined,
217
+
218
+ extStatus: '0',
219
+
220
+ callShow: '1',
221
+ transferToLaborShow: '1',
222
+ restShow: '1',
223
+ networkDetectShow: '1',
224
+ muteShow: '1',
225
+ logShow: '1',
226
+ timingShow: '1',
227
+ signShow: '1',
228
+
229
+ instanceMap: {},
230
+
231
+ softphoneConnectCallBack: () => {console.log('softphone-connect')},
232
+ softphoneCallRefreshCallBack: () => {console.log('softphone-call-refresh')},
233
+ softphoneSeatStatusChangeCallBack: () => {console.log('softphone-seats-status-change')},
234
+ softphoneAcceptCallBack: () => {console.log('softphone-accept')},
235
+ softphoneIgnoreCallBack: () => {console.log('softphone-ignore')},
236
+ softphoneHangupCallBack: () => {console.log('softphone-hangup')},
237
+ softphoneSessionStateChangeCallBack: () => {console.log('softphone-session-state-change')},
238
+ softphoneIncomingCallBack: () => {console.log('softphone-incoming')},
239
+ softphoneSendDtmfCallBack: () => {console.log('softphone-send-dtmf')},
240
+ softphoneConnectRegisteredCallBack: () => {console.log('softphone-connect-registered')},
241
+ softphoneSignOverduedCallBack: (done) => {
242
+ done({
243
+ timestamp: undefined,
244
+ sign: undefined
245
+ })
246
+ },
247
+ }
248
+
249
+
250
+ loadCssCode = (code) => {
251
+ const styleId = 'nf-softphone'
252
+ if (!document.getElementById(styleId)) {
253
+ const style = document.createElement('style');
254
+ style.id = styleId
255
+ style.type = 'text/css';
256
+ // @ts-ignore
257
+ style.rel = 'stylesheet';
258
+ //for Chrome Firefox Opera Safari
259
+ style.appendChild(document.createTextNode(code));
260
+ //for IE
261
+ //style.styleSheet.cssText = code;
262
+ const head = document.getElementsByTagName('head')[0];
263
+ head.appendChild(style);
264
+ }
265
+ }
266
+
267
+ removeCssCode = () => {
268
+ const styleId = 'nf-softphone'
269
+ const css = document.getElementById(styleId)
270
+ if (css) {
271
+ if (css.parentNode) {
272
+ css.parentNode.removeChild(css);
273
+ }
274
+ }
275
+ }
276
+
277
+ /**
278
+ * 隔离软电话容器
279
+ */
280
+ getContextDomElement = (el: string) => {
281
+ return (this.option.selector ? (document.querySelector(this.option.selector) ?? document) : document).querySelector(el)
282
+ }
283
+ /**
284
+ * 隔离软电话容器内容
285
+ */
286
+ getSoftphoneDomElement = (el: string) => {
287
+ return this.getContextDomElement(this.option.el!)?.querySelector(el) || this.getContextDomElement(el) || document.querySelector(el)
288
+ }
289
+
290
+ signOverdued = (data: {
291
+ sign: string
292
+ timestamp: string | number
293
+ }) => {
294
+ const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') as HTMLIFrameElement
295
+ iframe?.contentWindow?.postMessage(JSON.stringify({
296
+ origin: 'nf-softphone',
297
+ ancestorOrigin: this.option.ancestorOrigin,
298
+ destinationOrigin: 'ai-softphone',
299
+ type: 'softphone-sign-overdued',
300
+ data
301
+ }), '*')
302
+ }
303
+
304
+ handlingCommunication = (e: {data: `{
305
+ type: string,
306
+ ancestorOrigin: string,
307
+ origin: string,
308
+ data: 'expand' | 'shrink'
309
+ }` | string}) => {
310
+ const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe')
311
+ if (iframe) {
312
+ let data: Record<string, any> = {}
313
+ try {
314
+ data = JSON.parse(e.data)
315
+ } catch (e) {}
316
+ if ((data.ancestorOrigin === this.option.ancestorOrigin && data.origin !== this.option.ancestorOrigin) ||
317
+ (data.ancestorOrigin === this.option.origin && data.origin === this.option.origin)) {
318
+ if (data.destinationOrigin === '*' || data.destinationOrigin === this.option.destinationOrigin) {
319
+ if (data.type === 'softphone-expand') {
320
+ if (data.data === 'expand') {
321
+ iframe.setAttribute('style', 'position: fixed;z-index:999;');
322
+ } else if (data.data === 'shrink') {
323
+ iframe.removeAttribute('style');
324
+ }
325
+ return
326
+ }
327
+ if (data.type === 'softphone-connect') {
328
+ this.option.softphoneConnectCallBack?.(data)
329
+ } else if (data.type === 'softphone-call-refresh') {
330
+ this.option.softphoneCallRefreshCallBack?.(data)
331
+ } else if (data.type === 'softphone-seats-status-change') {
332
+ this.option.softphoneSeatStatusChangeCallBack?.(data)
333
+ } else if (data.type === 'softphone-accept') {
334
+ this.option.softphoneAcceptCallBack?.(data)
335
+ } else if (data.type === 'softphone-ignore') {
336
+ this.option.softphoneIgnoreCallBack?.(data)
337
+ } else if (data.type === 'softphone-hangup') {
338
+ this.option.softphoneHangupCallBack?.(data)
339
+ } else if (data.type === 'softphone-session-state-change') {
340
+ this.option.softphoneSessionStateChangeCallBack?.(data)
341
+ } else if (data.type === 'softphone-incoming') {
342
+ this.option.softphoneIncomingCallBack?.(data)
343
+ } else if (data.type === 'softphone-send-dtmf') {
344
+ this.option.softphoneSendDtmfCallBack?.(data)
345
+ } else if (data.type === 'softphone-connect-registered') {
346
+ this.option.softphoneConnectRegisteredCallBack?.(data)
347
+ } else if (data.type === 'softphone-sign-overdued') {
348
+ const done = (data) => {
349
+ const {
350
+ sign,
351
+ timestamp
352
+ } = data
353
+ this.signOverdued({
354
+ sign,
355
+ timestamp
356
+ })
357
+ }
358
+ this.option.softphoneSignOverduedCallBack?.(done)
359
+ }
360
+ }
361
+ }
362
+ }
363
+ }
364
+
365
+ handlingScroll = debounce(async () => {
366
+ const {
367
+ top,
368
+ left,
369
+ } = (await this.refreshStyle() || {})
370
+ if (top && left) {
371
+ (this.getSoftphoneDomElement('.nf-softphone-iframe') as HTMLIFrameElement)?.contentWindow?.postMessage(JSON.stringify({
372
+ type: 'softphone-scroll',
373
+ origin: this.option.origin,
374
+ ancestorOrigin: this.option.ancestorOrigin,
375
+ destinationOrigin: this.option.destinationOrigin,
376
+ data: {
377
+ paddingTop: top + 'px',
378
+ }
379
+ }), '*')
380
+ }
381
+ }, 500, false)
382
+
383
+ handlerInteractive = () => {
384
+ /**
385
+ * 实时处理层级
386
+ */
387
+ window.addEventListener('message', this.handlingCommunication, false);
388
+ if (this.option.scrollview) {
389
+ document.querySelector(this.option.scrollview)?.addEventListener('scroll', this.handlingScroll)
390
+ document.querySelector(this.option.scrollview)?.addEventListener('scroll', this.handlingScrollTransparent)
391
+ }
392
+
393
+ this.loadCssCode(`
394
+ .nf-transparent {
395
+ visibility: hidden;
396
+ }
397
+ .nf-softphone-text {
398
+ text-align: center;
399
+ line-height: 32px;
400
+ margin-top: -32px;
401
+ }
402
+ .nf-softphone-container {
403
+ margin-left: 10px;
404
+ height: 32px;
405
+ min-width: 600px;
406
+ }
407
+ .nf-softphone-iframe-container {
408
+ height: 32px;
409
+ width: 100%;
410
+ overflow: visible;
411
+ }
412
+ .nf-softphone-iframe {
413
+ width: 100vw;
414
+ height: 100vh;
415
+ top: 0;
416
+ left: 0;
417
+ }
418
+ `);
419
+ }
420
+
421
+ handlerDomRemove = () => {
422
+ Object.keys(this.option.instanceMap!).forEach(key => {
423
+ const el = document.getElementById(key)
424
+ if (el && el.parentNode) {
425
+ el.parentNode.removeChild(el)
426
+ }
427
+ })
428
+ }
429
+
430
+ _containerScrolling
431
+
432
+ get containerScrolling() {
433
+ return this._containerScrolling
434
+ }
435
+
436
+ set containerScrolling(value: boolean) {
437
+ if (this.containerScrolling !== value) {
438
+ this._containerScrolling = value
439
+ const nfSoftphoneContainer = this.getSoftphoneDomElement('.nf-softphone-container')
440
+ const nfSoftphoneText = this.getSoftphoneDomElement('.nf-softphone-text')
441
+ nfSoftphoneContainer?.setAttribute('class', `nf-softphone-container ${value === true ? 'nf-transparent' : ''}`)
442
+ nfSoftphoneText?.setAttribute('style', `display: ${value === true ? 'block' : 'none'}`)
443
+ }
444
+ }
445
+
446
+ handlingScrollTransparent = () => {
447
+ this.containerScrolling = true
448
+ }
449
+
450
+ refreshStyle = async () => {
451
+ clearTimeout(this.timer)
452
+ this.timer = undefined
453
+ const nfSoftphoneContainer = this.getSoftphoneDomElement('.nf-softphone-container')
454
+ const nfSoftphoneIframeContainer = this.getSoftphoneDomElement('.nf-softphone-iframe-container')
455
+ if (nfSoftphoneContainer && nfSoftphoneIframeContainer) {
456
+ const containerStyle = nfSoftphoneContainer.getAttribute('style')
457
+ const iframeContainerStyle = nfSoftphoneIframeContainer.getAttribute('style')
458
+ nfSoftphoneContainer.removeAttribute('style')
459
+ nfSoftphoneIframeContainer.removeAttribute('style')
460
+ const leftMargin = getComputedStyle(nfSoftphoneContainer).marginLeft
461
+ const top = nfSoftphoneContainer.getBoundingClientRect().top
462
+ if (top <= 0) {
463
+ nfSoftphoneContainer.setAttribute('style', containerStyle!)
464
+ nfSoftphoneIframeContainer.setAttribute('style', iframeContainerStyle!)
465
+ return {
466
+ top: 0,
467
+ left: 0,
468
+ leftMargin
469
+ }
470
+ }
471
+ const left = nfSoftphoneContainer.getBoundingClientRect().left
472
+ if (left <= 0) {
473
+ nfSoftphoneContainer.setAttribute('style', containerStyle!)
474
+ nfSoftphoneIframeContainer.setAttribute('style', iframeContainerStyle!)
475
+ return {
476
+ top: 0,
477
+ left: 0,
478
+ leftMargin
479
+ }
480
+ }
481
+ nfSoftphoneContainer.setAttribute('style', `margin-top:${top}px;margin-left:${leftMargin};margin-bottom:${top}px;`)
482
+ nfSoftphoneIframeContainer.setAttribute('style', `margin-top:-${2 * top}px;margin-left:-${left}px;`)
483
+ this.timer = setTimeout(() => {
484
+ clearTimeout(this.timer)
485
+ this.timer = undefined
486
+ this.containerScrolling = false
487
+ }, 100)
488
+ return {
489
+ leftMargin,
490
+ top,
491
+ left
492
+ }
493
+ }
494
+ return {
495
+ leftMargin: 0,
496
+ top: 0,
497
+ left: 0
498
+ }
499
+ }
500
+
501
+ handlerDomGenerater = async () => {
502
+ const nfSoftphone = document.createElement('div');
503
+ const nfSoftphoneText = document.createElement('div');
504
+ nfSoftphoneText.innerText = this.option.scrollingText || '正在滚动中...'
505
+
506
+ const nfSoftphoneContainer = document.createElement('div');
507
+ const iframeContainer = document.createElement('div');
508
+ const iframe = document.createElement('iframe');
509
+
510
+ const uuid = this.id + '-container'
511
+ this.option.instanceMap![uuid] = nfSoftphone
512
+ nfSoftphone.setAttribute('id', uuid)
513
+ nfSoftphone.setAttribute('class', 'nf-softphone')
514
+ nfSoftphoneText.setAttribute('class', 'nf-softphone-text')
515
+ nfSoftphoneText.setAttribute('style', "display: none;")
516
+ nfSoftphoneContainer.setAttribute('class', "nf-softphone-container")
517
+ iframeContainer.setAttribute('class', "nf-softphone-iframe-container")
518
+ iframe.setAttribute('class', "nf-softphone-iframe")
519
+ iframe.setAttribute('src', "")
520
+ iframe.setAttribute('frameborder', "0")
521
+ iframe.setAttribute('scrolling', "no")
522
+ iframe.setAttribute('allow', "camera *; microphone *")
523
+ iframeContainer.appendChild(iframe)
524
+ nfSoftphoneContainer.appendChild(iframeContainer)
525
+ nfSoftphone.appendChild(nfSoftphoneContainer)
526
+ nfSoftphone.appendChild(nfSoftphoneText)
527
+ const destination = (this.option.el ? this.getSoftphoneDomElement(this.option.el) ?? document.body : document.body)
528
+ destination.appendChild(nfSoftphone)
529
+ await nextTick()
530
+ const {
531
+ top,
532
+ left,
533
+ } = await this.refreshStyle()
534
+ const {
535
+ envMap,
536
+ env,
537
+ agentTag,
538
+ agentId,
539
+ appSecret,
540
+ extStatus,
541
+ appKey,
542
+ ancestorOrigin,
543
+ destinationOrigin,
544
+ callShow,
545
+ transferToLaborShow,
546
+ restShow,
547
+ networkDetectShow,
548
+ muteShow,
549
+ logShow,
550
+ timingShow,
551
+ signShow,
552
+ sign,
553
+ timestamp,
554
+ sgGateway,
555
+ sgBase,
556
+ sgOpen,
557
+ sgDomain,
558
+ } = this.option
559
+ let url = `${ envMap?.[env!] ?? env }/#/?cross=1&open=1`
560
+ url += agentTag ? `&agentTag=${agentTag}` : ''
561
+ url += agentId ? `&agentId=${agentId}` : ''
562
+ url += appSecret ? `&appSecret=${appSecret}` : ''
563
+ url += sign ? `&sign=${sign}` : ''
564
+ url += timestamp ? `&timestamp=${timestamp}` : ''
565
+ url += sgGateway ? `&sgGateway=${sgGateway}` : ''
566
+ url += sgBase ? `&sgBase=${sgBase}` : ''
567
+ url += sgOpen ? `&sgOpen=${sgOpen}` : ''
568
+ url += sgDomain ? `&sgDomain=${sgDomain}` : ''
569
+ url += `&appKey=${appKey}&extStatus=${extStatus}&paddingTop=${top}px&paddingLeft=${left}px&ancestorOrigin=${ancestorOrigin}&destinationOrigin=${destinationOrigin}`
570
+ url += `&callShow=${callShow}`
571
+ url += `&transferToLaborShow=${transferToLaborShow}`
572
+ url += `&restShow=${restShow}`
573
+ url += `&networkDetectShow=${networkDetectShow}`
574
+ url += `&muteShow=${muteShow}`
575
+ url += `&logShow=${logShow}`
576
+ url += `&timingShow=${timingShow}`
577
+ url += `&signShow=${signShow}`
578
+ iframe.src = url
579
+ }
580
+
581
+ initSoftphone = (option) => {
582
+ this.option = option ? { ...this.option, ...option } :this.option
583
+ this.handlerInteractive()
584
+ this.handlerDomGenerater()
585
+ return this
586
+ }
587
+
588
+ postMessageCommunicate = (type, status?: boolean) => {
589
+ const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') as HTMLIFrameElement
590
+ if (iframe) {
591
+ iframe.contentWindow!.postMessage(JSON.stringify({
592
+ origin: 'nf-softphone',
593
+ ancestorOrigin: this.option.ancestorOrigin,
594
+ destinationOrigin: this.option.destinationOrigin,
595
+ type,
596
+ data: {
597
+ status,
598
+ type: 'manual'
599
+ }
600
+ }), '*')
601
+ }
602
+ }
603
+ connect = () => {
604
+ this.postMessageCommunicate('softphone-connect', true)
605
+ }
606
+
607
+
608
+ disconnect = () => {
609
+ this.postMessageCommunicate('softphone-connect', false)
610
+ }
611
+
612
+ seatsStatusChange = (status: boolean) => {
613
+ this.postMessageCommunicate('softphone-seats-status-change', status)
614
+ }
615
+
616
+ accept = () => {
617
+ this.postMessageCommunicate('softphone-accept')
618
+ }
619
+ ignore = () => {
620
+ this.postMessageCommunicate('softphone-ignore')
621
+ }
622
+ hangup = () => {
623
+ this.postMessageCommunicate('softphone-hangup')
624
+ }
625
+ sendDtmf = () => {
626
+ this.postMessageCommunicate('softphone-send-dtmf')
627
+ }
628
+
629
+ removeTimer = () => {
630
+ clearTimeout(this.timer)
631
+ this.timer = undefined
632
+ }
633
+
634
+ destroy = () => {
635
+ window.removeEventListener('message', this.handlingCommunication, false);
636
+ if (this.option.scrollview) {
637
+ document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScroll)
638
+ document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScrollTransparent)
639
+ }
640
+ this.removeCssCode()
641
+ this.handlerDomRemove()
642
+ this.removeTimer()
643
+ }
644
+ }
645
+
646
+ const softphoneManager = new SoftphoneManager()
647
+
648
+ export default softphoneManager
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-softphone",
3
- "version": "8.3.7",
3
+ "version": "8.3.10",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,7 +14,7 @@
14
14
  "url": "http://94ai.gitlab.com/ui/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^8.3.7",
17
+ "@94ai/nf-theme-chalk": "^8.3.10",
18
18
  "vue-demi": "^0.14.5"
19
19
  },
20
20
  "peerDependenciesMeta": {
@@ -30,5 +30,5 @@
30
30
  "types": "lib/index.d.ts",
31
31
  "main": "lib/nf-softphone.cjs.js",
32
32
  "module": "lib/nf-softphone.esm-bundler.js",
33
- "gitHead": "815294672478f6cafaabf695d819efc02b5e3a1d"
33
+ "gitHead": "6affefa4036fd77f4cf3ade94993077481835bd1"
34
34
  }