@94ai/nf-softphone 9.0.0 → 10.0.0

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.
@@ -1,54 +1,54 @@
1
- import { Option } from '../..nf-softphone/lib/type';
2
- export declare class SoftphoneManager {
3
- id: any;
4
- timer: any;
5
- constructor();
6
- option: Partial<Option>;
7
- loadCssCode: (code: any) => void;
8
- removeCssCode: () => void;
9
- getContextDomElement: (el: string) => Element | null;
10
- getSoftphoneDomElement: (el: string) => Element | null;
11
- signOverdued: (data: {
12
- sign: string;
13
- timestamp: string | number;
14
- }) => void;
15
- handlingCommunication: (e: {
1
+ import { Option } from '../..nf-softphone/lib/type';
2
+ export declare class SoftphoneManager {
3
+ id: any;
4
+ timer: any;
5
+ constructor();
6
+ option: Partial<Option>;
7
+ loadCssCode: (code: any) => void;
8
+ removeCssCode: () => void;
9
+ getContextDomElement: (el: string) => Element | null;
10
+ getSoftphoneDomElement: (el: string) => Element | null;
11
+ signOverdued: (data: {
12
+ sign: string;
13
+ timestamp: string | number;
14
+ }) => void;
15
+ handlingCommunication: (e: {
16
16
  data: `{
17
17
  type: string,
18
18
  ancestorOrigin: string,
19
19
  origin: string,
20
20
  data: 'expand' | 'shrink'
21
- }` | string;
22
- }) => void;
23
- handlingScroll: (...args: any[]) => any;
24
- handlerInteractive: () => void;
25
- handlerDomRemove: () => void;
26
- _containerScrolling: any;
27
- get containerScrolling(): boolean;
28
- set containerScrolling(value: boolean);
29
- handlingScrollTransparent: () => void;
30
- refreshStyle: () => Promise<{
31
- top: number;
32
- left: number;
33
- leftMargin: string;
34
- } | {
35
- leftMargin: number;
36
- top: number;
37
- left: number;
38
- }>;
39
- handlerDomGenerater: () => Promise<void>;
40
- initSoftphone: (option: any) => this;
41
- postMessageCommunicate: (type: any, status?: boolean | undefined, param?: any) => void;
42
- connect: () => void;
43
- disconnect: () => void;
44
- seatsStatusChange: (status: boolean) => void;
45
- accept: () => void;
46
- ignore: () => void;
47
- hangup: () => void;
48
- sendDtmf: () => void;
49
- requestOpenApi: (param: any) => Promise<unknown>;
50
- removeTimer: () => void;
51
- destroy: () => void;
52
- }
53
- declare const softphoneManager: SoftphoneManager;
54
- export default softphoneManager;
21
+ }` | string;
22
+ }) => void;
23
+ handlingScroll: (...args: any[]) => any;
24
+ handlerInteractive: () => void;
25
+ handlerDomRemove: () => void;
26
+ _containerScrolling: any;
27
+ get containerScrolling(): boolean;
28
+ set containerScrolling(value: boolean);
29
+ handlingScrollTransparent: () => void;
30
+ refreshStyle: () => Promise<{
31
+ top: number;
32
+ left: number;
33
+ leftMargin: string;
34
+ } | {
35
+ leftMargin: number;
36
+ top: number;
37
+ left: number;
38
+ }>;
39
+ handlerDomGenerater: () => Promise<void>;
40
+ initSoftphone: (option: any) => this;
41
+ postMessageCommunicate: (type: any, status?: boolean | undefined, param?: any) => void;
42
+ connect: () => void;
43
+ disconnect: () => void;
44
+ seatsStatusChange: (status: boolean) => void;
45
+ accept: () => void;
46
+ ignore: () => void;
47
+ hangup: () => void;
48
+ sendDtmf: () => void;
49
+ requestOpenApi: (param: any) => Promise<unknown>;
50
+ removeTimer: () => void;
51
+ destroy: () => void;
52
+ }
53
+ declare const softphoneManager: SoftphoneManager;
54
+ export default softphoneManager;
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
package/lib/type.d.ts CHANGED
@@ -1,46 +1,46 @@
1
- export declare 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
- extStatus: '0' | '1';
22
- instanceMap: Record<string, any>;
23
- requestOpenApiCallBackMap: Record<string, any>;
24
- callShow: '0' | '1';
25
- transferToLaborShow: '0' | '1';
26
- restShow: '0' | '1';
27
- networkDetectShow: '0' | '1';
28
- muteShow: '0' | '1';
29
- logShow: '0' | '1';
30
- timingShow: '0' | '1';
31
- signShow: '0' | '1';
32
- softphoneConnectCallBack: Function;
33
- softphoneCallRefreshCallBack: Function;
34
- softphoneSeatStatusChangeCallBack: Function;
35
- softphoneAcceptCallBack: Function;
36
- softphoneIgnoreCallBack: Function;
37
- softphoneHangupCallBack: Function;
38
- softphoneSessionStateChangeCallBack: Function;
39
- softphoneIncomingCallBack: Function;
40
- softphoneSendDtmfCallBack: Function;
41
- softphoneAutoIgnoreCallback: Function;
42
- softphoneConnectRegisteredCallBack: Function;
43
- softphoneSignOverduedCallBack: Function;
44
- softphoneRequestOpenApiCallBack: Function;
45
- };
46
- export declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
1
+ export declare 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
+ extStatus: '0' | '1';
22
+ instanceMap: Record<string, any>;
23
+ requestOpenApiCallBackMap: Record<string, any>;
24
+ callShow: '0' | '1';
25
+ transferToLaborShow: '0' | '1';
26
+ restShow: '0' | '1';
27
+ networkDetectShow: '0' | '1';
28
+ muteShow: '0' | '1';
29
+ logShow: '0' | '1';
30
+ timingShow: '0' | '1';
31
+ signShow: '0' | '1';
32
+ softphoneConnectCallBack: Function;
33
+ softphoneCallRefreshCallBack: Function;
34
+ softphoneSeatStatusChangeCallBack: Function;
35
+ softphoneAcceptCallBack: Function;
36
+ softphoneIgnoreCallBack: Function;
37
+ softphoneHangupCallBack: Function;
38
+ softphoneSessionStateChangeCallBack: Function;
39
+ softphoneIncomingCallBack: Function;
40
+ softphoneSendDtmfCallBack: Function;
41
+ softphoneAutoIgnoreCallback: Function;
42
+ softphoneConnectRegisteredCallBack: Function;
43
+ softphoneSignOverduedCallBack: Function;
44
+ softphoneRequestOpenApiCallBack: Function;
45
+ };
46
+ export declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
@@ -95,9 +95,7 @@ class SoftphoneManager {
95
95
  const styleId = 'nf-softphone'
96
96
  const css = document.getElementById(styleId)
97
97
  if (css) {
98
- if (css.parentNode) {
99
- css.parentNode.removeChild(css);
100
- }
98
+ css.parentNode.removeChild(css);
101
99
  }
102
100
  }
103
101
 
@@ -111,7 +109,7 @@ class SoftphoneManager {
111
109
  * 隔离软电话容器内容
112
110
  */
113
111
  getSoftphoneDomElement = (el) => {
114
- return this.getContextDomElement(this.option.el).querySelector(el) || this.getContextDomElement(el) || document.querySelector(el)
112
+ return this.getContextDomElement(this.option.el)?.querySelector(el) || this.getContextDomElement(el) || document.querySelector(el)
115
113
  }
116
114
 
117
115
  signOverdued = (data) => {
@@ -30,7 +30,8 @@ function debounce(func, wait, immediate) {
30
30
  }
31
31
  }
32
32
 
33
- return function(...args) {
33
+ return function(...callArgs) {
34
+ args = callArgs
34
35
  // @ts-ignore
35
36
  context = this
36
37
  timestamp = +new Date()
@@ -276,10 +276,12 @@ const handlingScroll = debounce(async () => {
276
276
  }, 500, false)
277
277
 
278
278
  onMounted(async () => {
279
+ const position = await refreshStyle()
280
+ if (!position || !iframeDom.value) return
279
281
  const {
280
282
  top,
281
283
  left
282
- } = await refreshStyle()
284
+ } = position
283
285
  const {
284
286
  envMap,
285
287
  env,
@@ -61,7 +61,8 @@ function generateUUID() { // Public Domain/MIT
61
61
  });
62
62
  }
63
63
 
64
- function debounce(func, wait, immediate) {
64
+ // Private scroll scheduler: the only call site uses trailing execution.
65
+ function debounce(func, wait) {
65
66
  let timeout, args, context, timestamp, result
66
67
 
67
68
  const later = function() {
@@ -73,26 +74,18 @@ function debounce(func, wait, immediate) {
73
74
  timeout = setTimeout(later, wait - last)
74
75
  } else {
75
76
  timeout = null
76
- // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
77
- if (!immediate) {
78
- result = func.apply(context, args)
79
- if (!timeout) context = args = null
80
- }
77
+ result = func.apply(context, args)
78
+ if (!timeout) context = args = null
81
79
  }
82
80
  }
83
81
 
84
- return function(...args) {
82
+ return function(...callArgs) {
83
+ args = callArgs
85
84
  // @ts-ignore
86
85
  context = this
87
86
  timestamp = +new Date()
88
- const callNow = immediate && !timeout
89
87
  // 如果延时不存在,重新设定延时
90
88
  if (!timeout) timeout = setTimeout(later, wait)
91
- if (callNow) {
92
- result = func.apply(context, args)
93
- // @ts-ignore
94
- context = args = null
95
- }
96
89
 
97
90
  return result
98
91
  }
@@ -151,18 +144,11 @@ if (typeof Promise !== 'undefined') {
151
144
  };
152
145
  }
153
146
 
154
- // 实现 nextTick 函数,支持传入回调函数或返回 Promise
155
- async function nextTick(cb?) {
147
+ // Private DOM-generation barrier; all callers await it without a callback.
148
+ async function nextTick() {
156
149
  return new Promise((resolve) => {
157
150
  // 将回调函数和 resolve 函数封装成一个新的回调
158
151
  callbacks.push(() => {
159
- if (cb) {
160
- try {
161
- cb();
162
- } catch (e) {
163
- console.error('Error in nextTick callback:', e);
164
- }
165
- }
166
152
  // 当回调执行完毕后,resolve Promise
167
153
  resolve(true);
168
154
  });
@@ -291,9 +277,7 @@ export class SoftphoneManager {
291
277
  const styleId = 'nf-softphone'
292
278
  const css = document.getElementById(styleId)
293
279
  if (css) {
294
- if (css.parentNode) {
295
- css.parentNode.removeChild(css);
296
- }
280
+ css.parentNode!.removeChild(css);
297
281
  }
298
282
  }
299
283
 
@@ -405,7 +389,7 @@ export class SoftphoneManager {
405
389
  }
406
390
  }), '*')
407
391
  }
408
- }, 500, false)
392
+ }, 500)
409
393
 
410
394
  handlerInteractive = () => {
411
395
  /**
@@ -123,9 +123,7 @@ export class SoftphoneManager {
123
123
  const styleId = 'nf-softphone'
124
124
  const css = document.getElementById(styleId)
125
125
  if (css) {
126
- if (css.parentNode) {
127
- css.parentNode.removeChild(css);
128
- }
126
+ css.parentNode!.removeChild(css);
129
127
  }
130
128
  }
131
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-softphone",
3
- "version": "9.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,9 +14,10 @@
14
14
  "url": "http://gitlab.94ai.pro/ui/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-utils": "^9.0.0",
18
- "@94ai/nf-theme-chalk": "^9.0.0",
19
- "vue-demi": "^0.14.5"
17
+ "@94ai/common-utils": "^10.0.0",
18
+ "@94ai/nf-theme-chalk": "^10.0.0",
19
+ "vue-demi": "^0.14.5",
20
+ "@94ai/vue2-runtime-helpers": "1.0.1"
20
21
  },
21
22
  "peerDependenciesMeta": {
22
23
  "@vue/composition-api": {
@@ -25,11 +26,10 @@
25
26
  },
26
27
  "peerDependencies": {
27
28
  "@vue/composition-api": "^1.0.0-rc.1",
28
- "element-ui": ">=2.13.2",
29
- "vue": "^2.0.0 || >=3.0.0"
29
+ "vue": "^2.0.0 || >=3.0.0",
30
+ "element-ui": ">=2.13.2"
30
31
  },
31
32
  "types": "lib/index.d.ts",
32
33
  "main": "lib/nf-softphone.cjs.js",
33
- "module": "lib/nf-softphone.esm-bundler.js",
34
- "gitHead": "afe3016f0e42dfb7fedf6cbbe400ec08bf4b8662"
34
+ "module": "lib/nf-softphone.esm-bundler.js"
35
35
  }