@wildix/xbees-connect 1.2.1 → 1.2.5

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.0",
3
+ "version": "1.2.5",
4
4
  "description": "This library provides easy communication between x-bees and integrated web applications",
5
5
  "author": "dimitri.chernykh <dimitri.chernykh@wildix.com>",
6
6
  "homepage": "",
@@ -30,6 +30,7 @@
30
30
  "access": "public"
31
31
  },
32
32
  "devDependencies": {
33
+ "@wildix/eslint-config-style-guide": "^1.2.2",
33
34
  "eslint": "^8.55.0",
34
35
  "rimraf": "^5.0.5",
35
36
  "typescript": "^5.3.3"
@@ -35,6 +35,7 @@ export class Client {
35
35
  listeners = [];
36
36
  useSubscription = false;
37
37
  userToken;
38
+ visible = false;
38
39
  userEmail;
39
40
  referrer;
40
41
  needAuthorize;
@@ -42,11 +43,13 @@ export class Client {
42
43
  iframeId;
43
44
  variant = null;
44
45
  localStorageManager = LocalStorageManager.getInstance();
46
+ userExtension;
45
47
  constructor() {
46
48
  const params = getUrlSearchParamsMap();
47
49
  this.iframeId = (params.get(UrlParams.ID) ?? params.get(DeprecatedUrlParams.ID));
48
50
  this.variant = (params.get(UrlParams.VARIANT) ?? params.get(DeprecatedUrlParams.VARIANT));
49
51
  this.userEmail = (params.get(UrlParams.USER) ?? params.get(DeprecatedUrlParams.USER));
52
+ this.userExtension = params.get(UrlParams.EXTENSION);
50
53
  this.userToken = (params.get(UrlParams.TOKEN) ?? params.get(DeprecatedUrlParams.TOKEN));
51
54
  this.referrer = (params.get(UrlParams.REFERRER) ?? params.get(DeprecatedUrlParams.REFERRER));
52
55
  this.needAuthorize = params.has(UrlParams.AUTHORIZE) ?? params.has(DeprecatedUrlParams.AUTHORIZE);
@@ -54,6 +57,7 @@ export class Client {
54
57
  this.isParentReactNativeWebView = !!window.ReactNativeWebView;
55
58
  this.worker = this.isParentReactNativeWebView ? new PostMessageControllerNative() : new PostMessageControllerWeb();
56
59
  this.addEventListener(EventType.PBX_TOKEN, (token) => (this.userToken = token));
60
+ this.addEventListener(EventType.VISIBILITY, (isActive) => (this.visible = isActive));
57
61
  }
58
62
  sendAsync(data) {
59
63
  return this.worker.sendAsync({
@@ -126,9 +130,15 @@ export class Client {
126
130
  getUserEmail() {
127
131
  return this.userEmail;
128
132
  }
133
+ getUserExtension() {
134
+ return this.userExtension;
135
+ }
129
136
  getReferrer() {
130
137
  return this.referrer;
131
138
  }
139
+ isVisible() {
140
+ return this.visible;
141
+ }
132
142
  getBackToAppUrl() {
133
143
  if (Client.getInstance().isPlatformNative()) {
134
144
  return `com.wildix.rnc://integrations/${this.iframeId}`;
@@ -320,4 +330,7 @@ export class Client {
320
330
  getTechnicalSupport() {
321
331
  return TechnicalSupport.getInstance();
322
332
  }
333
+ onVisibilityChange(callback) {
334
+ return this.addEventListener(EventType.VISIBILITY, callback);
335
+ }
323
336
  }
@@ -8,6 +8,7 @@ export var EventType;
8
8
  EventType["PBX_TOKEN"] = "xBeesPbxToken";
9
9
  EventType["REDIRECT_QUERY"] = "xBeesRedirectQuery";
10
10
  EventType["LOGOUT"] = "xBeesLogout";
11
+ EventType["VISIBILITY"] = "xBeesVisibility";
11
12
  })(EventType || (EventType = {}));
12
13
  export var ClientEventType;
13
14
  (function (ClientEventType) {
@@ -51,6 +52,7 @@ export var UrlParams;
51
52
  UrlParams["ID"] = "i";
52
53
  UrlParams["VARIANT"] = "v";
53
54
  UrlParams["USER"] = "u";
55
+ UrlParams["EXTENSION"] = "e";
54
56
  UrlParams["REFERRER"] = "r";
55
57
  UrlParams["AUTHORIZE"] = "a";
56
58
  })(UrlParams || (UrlParams = {}));
@@ -14,11 +14,13 @@ export default class ClientParams {
14
14
  needAuthorize;
15
15
  iframeId;
16
16
  variant = null;
17
+ userExtension = null;
17
18
  constructor() {
18
19
  const params = getUrlSearchParamsMap();
19
20
  this.iframeId = (params.get(UrlParams.ID) ?? params.get(DeprecatedUrlParams.ID));
20
21
  this.variant = (params.get(UrlParams.VARIANT) ?? params.get(DeprecatedUrlParams.VARIANT));
21
22
  this.userEmail = (params.get(UrlParams.USER) ?? params.get(DeprecatedUrlParams.USER));
23
+ this.userExtension = params.get(UrlParams.EXTENSION);
22
24
  this.userToken = (params.get(UrlParams.TOKEN) ?? params.get(DeprecatedUrlParams.TOKEN));
23
25
  this.referrer = (params.get(UrlParams.REFERRER) ?? params.get(DeprecatedUrlParams.REFERRER));
24
26
  this.needAuthorize = params.has(UrlParams.AUTHORIZE) ?? params.has(DeprecatedUrlParams.AUTHORIZE);
@@ -13,6 +13,7 @@ export declare class Client implements ConnectClient {
13
13
  private listeners;
14
14
  private useSubscription;
15
15
  private userToken;
16
+ private visible;
16
17
  private readonly userEmail;
17
18
  private readonly referrer;
18
19
  private readonly needAuthorize;
@@ -20,6 +21,7 @@ export declare class Client implements ConnectClient {
20
21
  private readonly iframeId;
21
22
  private readonly variant;
22
23
  private readonly localStorageManager;
24
+ private readonly userExtension;
23
25
  constructor();
24
26
  private sendAsync;
25
27
  private sendAsyncErrorSafe;
@@ -32,7 +34,9 @@ export declare class Client implements ConnectClient {
32
34
  isOpenedFromXBees(): boolean;
33
35
  getUserPbxToken(): string;
34
36
  getUserEmail(): string;
37
+ getUserExtension(): string | null;
35
38
  getReferrer(): string;
39
+ isVisible(): boolean;
36
40
  getBackToAppUrl(): string;
37
41
  isDataOnly(): boolean;
38
42
  isSetupDialog(): boolean;
@@ -71,4 +75,5 @@ export declare class Client implements ConnectClient {
71
75
  sendAnalytics(eventName: string, params?: Record<string, string>): void;
72
76
  setIntegrationStorageKey(integrationKey: string): void;
73
77
  getTechnicalSupport(): TechnicalSupport;
78
+ onVisibilityChange(callback: Callback<EventType.VISIBILITY>): RemoveEventListener;
74
79
  }
@@ -6,7 +6,8 @@ export declare enum EventType {
6
6
  USE_THEME = "xBeesUseTheme",
7
7
  PBX_TOKEN = "xBeesPbxToken",
8
8
  REDIRECT_QUERY = "xBeesRedirectQuery",
9
- LOGOUT = "xBeesLogout"
9
+ LOGOUT = "xBeesLogout",
10
+ VISIBILITY = "xBeesVisibility"
10
11
  }
11
12
  export declare enum ClientEventType {
12
13
  READY = "xBeesReady",
@@ -47,6 +48,7 @@ export declare enum UrlParams {
47
48
  ID = "i",
48
49
  VARIANT = "v",
49
50
  USER = "u",
51
+ EXTENSION = "e",
50
52
  REFERRER = "r",
51
53
  AUTHORIZE = "a"
52
54
  }
@@ -8,6 +8,7 @@ export default class ClientParams {
8
8
  readonly needAuthorize: boolean;
9
9
  readonly iframeId: string;
10
10
  readonly variant: WorkVariants | null;
11
+ readonly userExtension: string | null;
11
12
  constructor();
12
13
  toString(): string;
13
14
  }
@@ -19,6 +19,9 @@ export interface ConnectClient {
19
19
  /**
20
20
  * Retrieves current user's email */
21
21
  getUserEmail: () => string;
22
+ /**
23
+ * Retrieves current user's extension */
24
+ getUserExtension: () => string | null;
22
25
  /**
23
26
  * Retrieves url for x-bees app which uses integration */
24
27
  getReferrer: () => string;
@@ -28,6 +31,9 @@ export interface ConnectClient {
28
31
  /**
29
32
  * Retrieves the version of xBeesConnect */
30
33
  version: () => string;
34
+ /**
35
+ * Indicates whether the UI iframe with the integration is currently active */
36
+ isVisible: () => boolean;
31
37
  /**
32
38
  * Determines x-bees is running on mobile native platform */
33
39
  isPlatformNative: () => boolean;
@@ -151,4 +157,7 @@ export interface ConnectClient {
151
157
  /**
152
158
  * special object to provide x-bees technical support */
153
159
  getTechnicalSupport: () => TechnicalSupport;
160
+ /**
161
+ * Starts listen for the events of changing iframe activity and handle with the provided callback */
162
+ onVisibilityChange: (callback: Callback<EventType.VISIBILITY>) => RemoveEventListener;
154
163
  }
@@ -9,6 +9,7 @@ export type EventPayloadMap = {
9
9
  [EventType.ADD_CALL]: IPayloadCallStartedInfo;
10
10
  [EventType.USE_THEME]: IPayloadThemeChange;
11
11
  [EventType.PBX_TOKEN]: string;
12
+ [EventType.VISIBILITY]: boolean;
12
13
  [EventType.REDIRECT_QUERY]: string;
13
14
  };
14
15
  export type EventCallbackMap = {
@@ -17,6 +18,7 @@ export type EventCallbackMap = {
17
18
  [EventType.ADD_CALL]: (callStartInfo: EventPayloadMap[EventType.ADD_CALL]) => void;
18
19
  [EventType.USE_THEME]: (theme: EventPayloadMap[EventType.USE_THEME]) => void;
19
20
  [EventType.PBX_TOKEN]: (token: EventPayloadMap[EventType.PBX_TOKEN]) => void;
21
+ [EventType.VISIBILITY]: (isActive: EventPayloadMap[EventType.VISIBILITY]) => void;
20
22
  [EventType.REDIRECT_QUERY]: (query: EventPayloadMap[EventType.REDIRECT_QUERY]) => void;
21
23
  };
22
24
  export type RawMessageEvent = MessageEvent<string | Message>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.2.1",
3
+ "version": "1.2.5",
4
4
  "description": "This library provides easy communication between x-bees and integrated web applications",
5
5
  "author": "dimitri.chernykh <dimitri.chernykh@wildix.com>",
6
6
  "homepage": "",
@@ -30,6 +30,7 @@
30
30
  "access": "public"
31
31
  },
32
32
  "devDependencies": {
33
+ "@wildix/eslint-config-style-guide": "^1.2.2",
33
34
  "eslint": "^8.55.0",
34
35
  "rimraf": "^5.0.5",
35
36
  "typescript": "^5.3.3"
@@ -42,5 +43,5 @@
42
43
  "engines": {
43
44
  "node": ">=16"
44
45
  },
45
- "gitHead": "a2732739df49717b258c3a6b97a5cce3f333f43a"
46
+ "gitHead": "56d5acf92d57e033678929fcb9927126bc54a39c"
46
47
  }