@94ai/nf-softphone 7.0.0 → 8.0.1

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/lib/index.d.ts CHANGED
@@ -233,6 +233,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
233
233
  "softphone-session-state-change": (event: any) => void;
234
234
  "softphone-incoming": (event: any) => void;
235
235
  "softphone-connect-registered": (event: any) => void;
236
+ "softphone-sign-overdued": (event: any) => void;
236
237
  }, {
237
238
  sgGateway: string;
238
239
  sgBase: string;
@@ -628,6 +629,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
628
629
  "softphone-session-state-change": (event: any) => void;
629
630
  "softphone-incoming": (event: any) => void;
630
631
  "softphone-connect-registered": (event: any) => void;
632
+ "softphone-sign-overdued": (event: any) => void;
631
633
  }, string, {
632
634
  sgGateway: string;
633
635
  sgBase: string;
@@ -215,6 +215,18 @@ __sfc_main.setup = (__props, __ctx) => {
215
215
  emit("softphone-send-dtmf", data);
216
216
  } else if (data.type === "softphone-connect-registered") {
217
217
  emit("softphone-connect-registered", data);
218
+ } else if (data.type === "softphone-sign-overdued") {
219
+ const done = (data2) => {
220
+ const {
221
+ sign,
222
+ timestamp
223
+ } = data2;
224
+ signOverdued({
225
+ sign,
226
+ timestamp
227
+ });
228
+ };
229
+ emit("softphone-sign-overdued", done);
218
230
  }
219
231
  }
220
232
  }
@@ -350,27 +362,33 @@ __sfc_main.setup = (__props, __ctx) => {
350
362
  timer = void 0;
351
363
  }
352
364
  });
353
- const postMessageCommunicate = (type, status) => {
365
+ const postMessageCommunicate = (type, data = {}, operationType = "manual", ancestorOrigin = props.ancestorOrigin, destinationOrigin = props.destinationOrigin) => {
354
366
  var _a2;
355
367
  (_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
356
368
  origin: "nf-softphone",
357
- ancestorOrigin: props.ancestorOrigin,
358
- destinationOrigin: props.destinationOrigin,
369
+ ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
370
+ destinationOrigin: destinationOrigin || props.destinationOrigin,
359
371
  type,
360
372
  data: {
361
- status,
362
- type: "manual"
373
+ ...data,
374
+ type: operationType
363
375
  }
364
376
  }), "*");
365
377
  };
366
378
  const connect = () => {
367
- postMessageCommunicate("softphone-connect", true);
379
+ postMessageCommunicate("softphone-connect", {
380
+ status: true
381
+ });
368
382
  };
369
383
  const disconnect = () => {
370
- postMessageCommunicate("softphone-connect", false);
384
+ postMessageCommunicate("softphone-connect", {
385
+ status: false
386
+ });
371
387
  };
372
388
  const seatsStatusChange = (status) => {
373
- postMessageCommunicate("softphone-seats-status-change", status);
389
+ postMessageCommunicate("softphone-seats-status-change", {
390
+ status
391
+ });
374
392
  };
375
393
  const accept = () => {
376
394
  postMessageCommunicate("softphone-accept");
@@ -384,6 +402,9 @@ __sfc_main.setup = (__props, __ctx) => {
384
402
  const sendDtmf = () => {
385
403
  postMessageCommunicate("softphone-send-dtmf");
386
404
  };
405
+ const signOverdued = (data) => {
406
+ postMessageCommunicate("softphone-sign-overdued", data, "auto", props.ancestorOrigin, "ai-softphone");
407
+ };
387
408
  return Object.assign({
388
409
  container,
389
410
  iframeContainer,
@@ -505,6 +526,12 @@ class SoftphoneManager {
505
526
  },
506
527
  softphoneConnectRegisteredCallBack: () => {
507
528
  console.log("softphone-connect-registered");
529
+ },
530
+ softphoneSignOverduedCallBack: (done) => {
531
+ done({
532
+ timestamp: void 0,
533
+ sign: void 0
534
+ });
508
535
  }
509
536
  };
510
537
  this.loadCssCode = (code) => {
@@ -535,8 +562,19 @@ class SoftphoneManager {
535
562
  var _a;
536
563
  return ((_a = this.getContextDomElement(this.option.el)) == null ? void 0 : _a.querySelector(el)) || this.getContextDomElement(el) || document.querySelector(el);
537
564
  };
565
+ this.signOverdued = (data) => {
566
+ var _a;
567
+ const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
568
+ (_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage(JSON.stringify({
569
+ origin: "nf-softphone",
570
+ ancestorOrigin: this.option.ancestorOrigin,
571
+ destinationOrigin: "ai-softphone",
572
+ type: "softphone-sign-overdued",
573
+ data
574
+ }), "*");
575
+ };
538
576
  this.handlingCommunication = (e) => {
539
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
577
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
540
578
  const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
541
579
  if (iframe) {
542
580
  let data = {};
@@ -574,6 +612,18 @@ class SoftphoneManager {
574
612
  (_r = (_q = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _r.call(_q, data);
575
613
  } else if (data.type === "softphone-connect-registered") {
576
614
  (_t = (_s = this.option).softphoneConnectRegisteredCallBack) == null ? void 0 : _t.call(_s, data);
615
+ } else if (data.type === "softphone-sign-overdued") {
616
+ const done = (data2) => {
617
+ const {
618
+ sign,
619
+ timestamp
620
+ } = data2;
621
+ this.signOverdued({
622
+ sign,
623
+ timestamp
624
+ });
625
+ };
626
+ (_v = (_u = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _v.call(_u, done);
577
627
  }
578
628
  }
579
629
  }
@@ -213,6 +213,18 @@ __sfc_main.setup = (__props, __ctx) => {
213
213
  emit("softphone-send-dtmf", data);
214
214
  } else if (data.type === "softphone-connect-registered") {
215
215
  emit("softphone-connect-registered", data);
216
+ } else if (data.type === "softphone-sign-overdued") {
217
+ const done = (data2) => {
218
+ const {
219
+ sign,
220
+ timestamp
221
+ } = data2;
222
+ signOverdued({
223
+ sign,
224
+ timestamp
225
+ });
226
+ };
227
+ emit("softphone-sign-overdued", done);
216
228
  }
217
229
  }
218
230
  }
@@ -348,27 +360,33 @@ __sfc_main.setup = (__props, __ctx) => {
348
360
  timer = void 0;
349
361
  }
350
362
  });
351
- const postMessageCommunicate = (type, status) => {
363
+ const postMessageCommunicate = (type, data = {}, operationType = "manual", ancestorOrigin = props.ancestorOrigin, destinationOrigin = props.destinationOrigin) => {
352
364
  var _a2;
353
365
  (_a2 = iframeDom.value) == null ? void 0 : _a2.contentWindow.postMessage(JSON.stringify({
354
366
  origin: "nf-softphone",
355
- ancestorOrigin: props.ancestorOrigin,
356
- destinationOrigin: props.destinationOrigin,
367
+ ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
368
+ destinationOrigin: destinationOrigin || props.destinationOrigin,
357
369
  type,
358
370
  data: {
359
- status,
360
- type: "manual"
371
+ ...data,
372
+ type: operationType
361
373
  }
362
374
  }), "*");
363
375
  };
364
376
  const connect = () => {
365
- postMessageCommunicate("softphone-connect", true);
377
+ postMessageCommunicate("softphone-connect", {
378
+ status: true
379
+ });
366
380
  };
367
381
  const disconnect = () => {
368
- postMessageCommunicate("softphone-connect", false);
382
+ postMessageCommunicate("softphone-connect", {
383
+ status: false
384
+ });
369
385
  };
370
386
  const seatsStatusChange = (status) => {
371
- postMessageCommunicate("softphone-seats-status-change", status);
387
+ postMessageCommunicate("softphone-seats-status-change", {
388
+ status
389
+ });
372
390
  };
373
391
  const accept = () => {
374
392
  postMessageCommunicate("softphone-accept");
@@ -382,6 +400,9 @@ __sfc_main.setup = (__props, __ctx) => {
382
400
  const sendDtmf = () => {
383
401
  postMessageCommunicate("softphone-send-dtmf");
384
402
  };
403
+ const signOverdued = (data) => {
404
+ postMessageCommunicate("softphone-sign-overdued", data, "auto", props.ancestorOrigin, "ai-softphone");
405
+ };
385
406
  return Object.assign({
386
407
  container,
387
408
  iframeContainer,
@@ -503,6 +524,12 @@ class SoftphoneManager {
503
524
  },
504
525
  softphoneConnectRegisteredCallBack: () => {
505
526
  console.log("softphone-connect-registered");
527
+ },
528
+ softphoneSignOverduedCallBack: (done) => {
529
+ done({
530
+ timestamp: void 0,
531
+ sign: void 0
532
+ });
506
533
  }
507
534
  };
508
535
  this.loadCssCode = (code) => {
@@ -533,8 +560,19 @@ class SoftphoneManager {
533
560
  var _a;
534
561
  return ((_a = this.getContextDomElement(this.option.el)) == null ? void 0 : _a.querySelector(el)) || this.getContextDomElement(el) || document.querySelector(el);
535
562
  };
563
+ this.signOverdued = (data) => {
564
+ var _a;
565
+ const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
566
+ (_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage(JSON.stringify({
567
+ origin: "nf-softphone",
568
+ ancestorOrigin: this.option.ancestorOrigin,
569
+ destinationOrigin: "ai-softphone",
570
+ type: "softphone-sign-overdued",
571
+ data
572
+ }), "*");
573
+ };
536
574
  this.handlingCommunication = (e) => {
537
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
575
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
538
576
  const iframe = this.getSoftphoneDomElement(".nf-softphone-iframe");
539
577
  if (iframe) {
540
578
  let data = {};
@@ -572,6 +610,18 @@ class SoftphoneManager {
572
610
  (_r = (_q = this.option).softphoneSendDtmfCallBack) == null ? void 0 : _r.call(_q, data);
573
611
  } else if (data.type === "softphone-connect-registered") {
574
612
  (_t = (_s = this.option).softphoneConnectRegisteredCallBack) == null ? void 0 : _t.call(_s, data);
613
+ } else if (data.type === "softphone-sign-overdued") {
614
+ const done = (data2) => {
615
+ const {
616
+ sign,
617
+ timestamp
618
+ } = data2;
619
+ this.signOverdued({
620
+ sign,
621
+ timestamp
622
+ });
623
+ };
624
+ (_v = (_u = this.option).softphoneSignOverduedCallBack) == null ? void 0 : _v.call(_u, done);
575
625
  }
576
626
  }
577
627
  }
@@ -82,6 +82,7 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
82
82
  "softphone-session-state-change": (event: any) => void;
83
83
  "softphone-incoming": (event: any) => void;
84
84
  "softphone-connect-registered": (event: any) => void;
85
+ "softphone-sign-overdued": (event: any) => void;
85
86
  }, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
86
87
  sgGateway?: string | undefined;
87
88
  sgBase?: string | undefined;
@@ -8,6 +8,10 @@ export declare class SoftphoneManager {
8
8
  removeCssCode: () => void;
9
9
  getContextDomElement: (el: string) => Element | null;
10
10
  getSoftphoneDomElement: (el: string) => Element | null;
11
+ signOverdued: (data: {
12
+ sign: string;
13
+ timestamp: string | number;
14
+ }) => void;
11
15
  handlingCommunication: (e: {
12
16
  data: `{
13
17
  type: string,
package/lib/type.d.ts CHANGED
@@ -38,5 +38,6 @@ export declare type Option = {
38
38
  softphoneIncomingCallBack: Function;
39
39
  softphoneSendDtmfCallBack: Function;
40
40
  softphoneConnectRegisteredCallBack: Function;
41
+ softphoneSignOverduedCallBack: Function;
41
42
  };
42
43
  export declare type Env = 'test' | 'dev' | 'sg' | 'gray' | 'prod';
@@ -118,6 +118,7 @@ const emit = defineEmits<{
118
118
  (e: 'softphone-session-state-change', event: any): void
119
119
  (e: 'softphone-incoming', event: any): void
120
120
  (e: 'softphone-connect-registered', event: any): void
121
+ (e: 'softphone-sign-overdued', event: any): void
121
122
  }>()
122
123
 
123
124
  const container = ref()
@@ -168,6 +169,18 @@ const handlingCommunication = (e: {data: `{
168
169
  emit('softphone-send-dtmf', data)
169
170
  } else if (data.type === 'softphone-connect-registered') {
170
171
  emit('softphone-connect-registered', data)
172
+ } else if (data.type === 'softphone-sign-overdued') {
173
+ const done = (data) => {
174
+ const {
175
+ sign,
176
+ timestamp
177
+ } = data
178
+ signOverdued({
179
+ sign,
180
+ timestamp
181
+ })
182
+ }
183
+ emit('softphone-sign-overdued', done)
171
184
  }
172
185
  }
173
186
  }
@@ -305,29 +318,41 @@ onUnmounted(() => {
305
318
  }
306
319
  })
307
320
 
308
- const postMessageCommunicate = (type, status?: boolean) => {
321
+ const postMessageCommunicate = (
322
+ type,
323
+ data: Record<string, any> = {},
324
+ operationType = 'manual',
325
+ ancestorOrigin = props.ancestorOrigin,
326
+ destinationOrigin = props.destinationOrigin
327
+ ) => {
309
328
  iframeDom.value?.contentWindow.postMessage(JSON.stringify({
310
329
  origin: 'nf-softphone',
311
- ancestorOrigin: props.ancestorOrigin,
312
- destinationOrigin: props.destinationOrigin,
330
+ ancestorOrigin: ancestorOrigin || props.ancestorOrigin,
331
+ destinationOrigin: destinationOrigin || props.destinationOrigin,
313
332
  type,
314
333
  data: {
315
- status,
316
- type: 'manual'
334
+ ...data,
335
+ type: operationType
317
336
  }
318
337
  }), '*')
319
338
  }
320
339
  const connect = () => {
321
- postMessageCommunicate('softphone-connect', true)
340
+ postMessageCommunicate('softphone-connect', {
341
+ status: true
342
+ })
322
343
  }
323
344
 
324
345
 
325
346
  const disconnect = () => {
326
- postMessageCommunicate('softphone-connect', false)
347
+ postMessageCommunicate('softphone-connect', {
348
+ status: false
349
+ })
327
350
  }
328
351
 
329
352
  const seatsStatusChange = (status) => {
330
- postMessageCommunicate('softphone-seats-status-change', status)
353
+ postMessageCommunicate('softphone-seats-status-change', {
354
+ status
355
+ })
331
356
  }
332
357
 
333
358
  const accept = () => {
@@ -343,6 +368,13 @@ const sendDtmf = () => {
343
368
  postMessageCommunicate('softphone-send-dtmf')
344
369
  }
345
370
 
371
+ const signOverdued = (data: {
372
+ sign: string
373
+ timestamp: string | number
374
+ }) => {
375
+ postMessageCommunicate('softphone-sign-overdued', data, 'auto', props.ancestorOrigin, 'ai-softphone')
376
+ }
377
+
346
378
  defineExpose({
347
379
  connect,
348
380
  disconnect,
@@ -72,6 +72,12 @@ export class SoftphoneManager {
72
72
  softphoneIncomingCallBack: () => {console.log('softphone-incoming')},
73
73
  softphoneSendDtmfCallBack: () => {console.log('softphone-send-dtmf')},
74
74
  softphoneConnectRegisteredCallBack: () => {console.log('softphone-connect-registered')},
75
+ softphoneSignOverduedCallBack: (done) => {
76
+ done({
77
+ timestamp: undefined,
78
+ sign: undefined
79
+ })
80
+ },
75
81
  }
76
82
 
77
83
 
@@ -115,6 +121,20 @@ export class SoftphoneManager {
115
121
  return this.getContextDomElement(this.option.el!)?.querySelector(el) || this.getContextDomElement(el) || document.querySelector(el)
116
122
  }
117
123
 
124
+ signOverdued = (data: {
125
+ sign: string
126
+ timestamp: string | number
127
+ }) => {
128
+ const iframe = this.getSoftphoneDomElement('.nf-softphone-iframe') as HTMLIFrameElement
129
+ iframe?.contentWindow?.postMessage(JSON.stringify({
130
+ origin: 'nf-softphone',
131
+ ancestorOrigin: this.option.ancestorOrigin,
132
+ destinationOrigin: 'ai-softphone',
133
+ type: 'softphone-sign-overdued',
134
+ data
135
+ }), '*')
136
+ }
137
+
118
138
  handlingCommunication = (e: {data: `{
119
139
  type: string,
120
140
  ancestorOrigin: string,
@@ -158,6 +178,18 @@ export class SoftphoneManager {
158
178
  this.option.softphoneSendDtmfCallBack?.(data)
159
179
  } else if (data.type === 'softphone-connect-registered') {
160
180
  this.option.softphoneConnectRegisteredCallBack?.(data)
181
+ } else if (data.type === 'softphone-sign-overdued') {
182
+ const done = (data) => {
183
+ const {
184
+ sign,
185
+ timestamp
186
+ } = data
187
+ this.signOverdued({
188
+ sign,
189
+ timestamp
190
+ })
191
+ }
192
+ this.option.softphoneSignOverduedCallBack?.(done)
161
193
  }
162
194
  }
163
195
  }
package/package/type.ts CHANGED
@@ -41,6 +41,7 @@ export type Option = {
41
41
  softphoneIncomingCallBack: Function
42
42
  softphoneSendDtmfCallBack: Function
43
43
  softphoneConnectRegisteredCallBack: Function
44
+ softphoneSignOverduedCallBack: Function
44
45
  }
45
46
 
46
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-softphone",
3
- "version": "7.0.0",
3
+ "version": "8.0.1",
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": "^7.0.0",
17
+ "@94ai/nf-theme-chalk": "^8.0.1",
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": "5fecc6a0815d494bfaa76c4c5d1f34c8dd64a61d"
33
+ "gitHead": "316144e9cd2a06b10e14476d5fdc7f1d42fa88c6"
34
34
  }