@itwin/core-mobile 3.3.0-dev.5 → 3.3.0-dev.52

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/lib/cjs/MobileBackend.d.ts +0 -2
  3. package/lib/cjs/MobileBackend.d.ts.map +1 -1
  4. package/lib/cjs/MobileBackend.js +0 -2
  5. package/lib/cjs/MobileBackend.js.map +1 -1
  6. package/lib/cjs/MobileFrontend.d.ts +0 -2
  7. package/lib/cjs/MobileFrontend.d.ts.map +1 -1
  8. package/lib/cjs/MobileFrontend.js +0 -2
  9. package/lib/cjs/MobileFrontend.js.map +1 -1
  10. package/lib/cjs/__DOC_ONLY__.d.ts +31 -0
  11. package/lib/cjs/__DOC_ONLY__.d.ts.map +1 -1
  12. package/lib/cjs/__DOC_ONLY__.js +31 -0
  13. package/lib/cjs/__DOC_ONLY__.js.map +1 -1
  14. package/lib/cjs/backend/MobileAuthorizationBackend.d.ts.map +1 -1
  15. package/lib/cjs/backend/MobileAuthorizationBackend.js +12 -19
  16. package/lib/cjs/backend/MobileAuthorizationBackend.js.map +1 -1
  17. package/lib/cjs/backend/MobileHost.d.ts.map +1 -1
  18. package/lib/cjs/backend/MobileHost.js +6 -4
  19. package/lib/cjs/backend/MobileHost.js.map +1 -1
  20. package/lib/cjs/frontend/MobileApp.d.ts +8 -5
  21. package/lib/cjs/frontend/MobileApp.d.ts.map +1 -1
  22. package/lib/cjs/frontend/MobileApp.js +1 -4
  23. package/lib/cjs/frontend/MobileApp.js.map +1 -1
  24. package/package.json +16 -16
  25. package/lib/cjs/backend/AndroidHost.d.ts +0 -11
  26. package/lib/cjs/backend/AndroidHost.d.ts.map +0 -1
  27. package/lib/cjs/backend/AndroidHost.js +0 -23
  28. package/lib/cjs/backend/AndroidHost.js.map +0 -1
  29. package/lib/cjs/backend/iOSHost.d.ts +0 -11
  30. package/lib/cjs/backend/iOSHost.d.ts.map +0 -1
  31. package/lib/cjs/backend/iOSHost.js +0 -23
  32. package/lib/cjs/backend/iOSHost.js.map +0 -1
  33. package/lib/cjs/frontend/AndroidApp.d.ts +0 -14
  34. package/lib/cjs/frontend/AndroidApp.d.ts.map +0 -1
  35. package/lib/cjs/frontend/AndroidApp.js +0 -17
  36. package/lib/cjs/frontend/AndroidApp.js.map +0 -1
  37. package/lib/cjs/frontend/IOSApp.d.ts +0 -14
  38. package/lib/cjs/frontend/IOSApp.d.ts.map +0 -1
  39. package/lib/cjs/frontend/IOSApp.js +0 -21
  40. package/lib/cjs/frontend/IOSApp.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,33 @@
1
1
  # Change Log - @itwin/core-mobile
2
2
 
3
- This log was last generated on Fri, 15 Apr 2022 13:49:25 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 21 Jun 2022 18:06:33 GMT and should not be manually modified.
4
+
5
+ ## 3.2.4
6
+ Tue, 21 Jun 2022 18:06:33 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.2.3
11
+ Fri, 17 Jun 2022 15:18:39 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 3.2.2
16
+ Fri, 10 Jun 2022 16:11:36 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 3.2.1
21
+ Tue, 07 Jun 2022 15:02:56 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 3.2.0
26
+ Fri, 20 May 2022 13:10:54 GMT
27
+
28
+ ### Updates
29
+
30
+ - Remove auth access and configuration via typescript.
4
31
 
5
32
  ## 3.1.3
6
33
  Fri, 15 Apr 2022 13:49:25 GMT
@@ -1,5 +1,3 @@
1
- export * from "./backend/AndroidHost";
2
- export * from "./backend/iOSHost";
3
1
  export * from "./backend/MobileAuthorizationBackend";
4
2
  export * from "./backend/MobileFileHandler";
5
3
  export * from "./backend/MobileHost";
@@ -1 +1 @@
1
- {"version":3,"file":"MobileBackend.d.ts","sourceRoot":"","sources":["../../src/MobileBackend.ts"],"names":[],"mappings":"AAOA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"MobileBackend.d.ts","sourceRoot":"","sources":["../../src/MobileBackend.ts"],"names":[],"mappings":"AAOA,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC"}
@@ -15,8 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // Barrel file for backend of a mobile application
18
- __exportStar(require("./backend/AndroidHost"), exports);
19
- __exportStar(require("./backend/iOSHost"), exports);
20
18
  __exportStar(require("./backend/MobileAuthorizationBackend"), exports);
21
19
  __exportStar(require("./backend/MobileFileHandler"), exports);
22
20
  __exportStar(require("./backend/MobileHost"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"MobileBackend.js","sourceRoot":"","sources":["../../src/MobileBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,kDAAkD;AAElD,wDAAsC;AACtC,oDAAkC;AAClC,uEAAqD;AACrD,8DAA4C;AAC5C,uDAAqC;AACrC,0DAAwC;AACxC,4DAA0C;AAC1C,6DAA2C;AAC3C,4DAA0C","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n// Barrel file for backend of a mobile application\r\n\r\nexport * from \"./backend/AndroidHost\";\r\nexport * from \"./backend/iOSHost\";\r\nexport * from \"./backend/MobileAuthorizationBackend\";\r\nexport * from \"./backend/MobileFileHandler\";\r\nexport * from \"./backend/MobileHost\";\r\nexport * from \"./common/MobileAppProps\";\r\nexport * from \"./common/MobileRpcManager\";\r\nexport * from \"./common/MobileRpcProtocol\";\r\nexport * from \"./common/MobileRpcRequest\";\r\n"]}
1
+ {"version":3,"file":"MobileBackend.js","sourceRoot":"","sources":["../../src/MobileBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,kDAAkD;AAElD,uEAAqD;AACrD,8DAA4C;AAC5C,uDAAqC;AACrC,0DAAwC;AACxC,4DAA0C;AAC1C,6DAA2C;AAC3C,4DAA0C","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n// Barrel file for backend of a mobile application\r\n\r\nexport * from \"./backend/MobileAuthorizationBackend\";\r\nexport * from \"./backend/MobileFileHandler\";\r\nexport * from \"./backend/MobileHost\";\r\nexport * from \"./common/MobileAppProps\";\r\nexport * from \"./common/MobileRpcManager\";\r\nexport * from \"./common/MobileRpcProtocol\";\r\nexport * from \"./common/MobileRpcRequest\";\r\n"]}
@@ -2,7 +2,5 @@ export * from "./common/MobileAppProps";
2
2
  export * from "./common/MobileRpcManager";
3
3
  export * from "./common/MobileRpcProtocol";
4
4
  export * from "./common/MobileRpcRequest";
5
- export * from "./frontend/AndroidApp";
6
- export * from "./frontend/IOSApp";
7
5
  export * from "./frontend/MobileApp";
8
6
  //# sourceMappingURL=MobileFrontend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileFrontend.d.ts","sourceRoot":"","sources":["../../src/MobileFrontend.ts"],"names":[],"mappings":"AAKA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"MobileFrontend.d.ts","sourceRoot":"","sources":["../../src/MobileFrontend.ts"],"names":[],"mappings":"AAKA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC"}
@@ -18,7 +18,5 @@ __exportStar(require("./common/MobileAppProps"), exports);
18
18
  __exportStar(require("./common/MobileRpcManager"), exports);
19
19
  __exportStar(require("./common/MobileRpcProtocol"), exports);
20
20
  __exportStar(require("./common/MobileRpcRequest"), exports);
21
- __exportStar(require("./frontend/AndroidApp"), exports);
22
- __exportStar(require("./frontend/IOSApp"), exports);
23
21
  __exportStar(require("./frontend/MobileApp"), exports);
24
22
  //# sourceMappingURL=MobileFrontend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileFrontend.js","sourceRoot":"","sources":["../../src/MobileFrontend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,0DAAwC;AACxC,4DAA0C;AAC1C,6DAA2C;AAC3C,4DAA0C;AAC1C,wDAAsC;AACtC,oDAAkC;AAClC,uDAAqC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nexport * from \"./common/MobileAppProps\";\r\nexport * from \"./common/MobileRpcManager\";\r\nexport * from \"./common/MobileRpcProtocol\";\r\nexport * from \"./common/MobileRpcRequest\";\r\nexport * from \"./frontend/AndroidApp\";\r\nexport * from \"./frontend/IOSApp\";\r\nexport * from \"./frontend/MobileApp\";\r\n"]}
1
+ {"version":3,"file":"MobileFrontend.js","sourceRoot":"","sources":["../../src/MobileFrontend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,0DAAwC;AACxC,4DAA0C;AAC1C,6DAA2C;AAC3C,4DAA0C;AAC1C,uDAAqC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nexport * from \"./common/MobileAppProps\";\r\nexport * from \"./common/MobileRpcManager\";\r\nexport * from \"./common/MobileRpcProtocol\";\r\nexport * from \"./common/MobileRpcRequest\";\r\nexport * from \"./frontend/MobileApp\";\r\n"]}
@@ -1,3 +1,34 @@
1
1
  export * from "./MobileBackend";
2
2
  export * from "./MobileFrontend";
3
+ /** @docs-package-description
4
+ * The core-mobile package provides the necessary tools to run an ITwin.js application on iOS and Android. It provides a layer of communication between native tooling for mobile apps and ITwin.js core.
5
+ */
6
+ /**
7
+ * @docs-group-description MobileApp
8
+ * Classes for configuring and administering an iTwin.js application on mobile.
9
+ */
10
+ /**
11
+ * @docs-group-description MobileAppProps
12
+ * Configuration options for use with MobileApp.
13
+ */
14
+ /**
15
+ * @docs-group-description MobileHost
16
+ * Classes for configuring and administering the backend host on mobile.
17
+ */
18
+ /**
19
+ * @docs-group-description MobileRpcManager
20
+ * Coordinates usage of RPC interfaces for mobile applications.
21
+ */
22
+ /**
23
+ * @docs-group-description MobileRpcServer
24
+ * Provides RPC handling for the backend host on mobile.
25
+ */
26
+ /**
27
+ * @docs-group-description iModelHub
28
+ * Classes for interacting with iModelHub.
29
+ */
30
+ /**
31
+ * @docs-group-description RpcInterface
32
+ * Used to define a set of operations exposed by a service that a client can call, using configurable protocols.
33
+ */
3
34
  //# sourceMappingURL=__DOC_ONLY__.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"__DOC_ONLY__.d.ts","sourceRoot":"","sources":["../../src/__DOC_ONLY__.ts"],"names":[],"mappings":"AASA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"__DOC_ONLY__.d.ts","sourceRoot":"","sources":["../../src/__DOC_ONLY__.ts"],"names":[],"mappings":"AASA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAEjC;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
@@ -19,4 +19,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  // Do not import it in real code!
20
20
  __exportStar(require("./MobileBackend"), exports);
21
21
  __exportStar(require("./MobileFrontend"), exports);
22
+ /** @docs-package-description
23
+ * The core-mobile package provides the necessary tools to run an ITwin.js application on iOS and Android. It provides a layer of communication between native tooling for mobile apps and ITwin.js core.
24
+ */
25
+ /**
26
+ * @docs-group-description MobileApp
27
+ * Classes for configuring and administering an iTwin.js application on mobile.
28
+ */
29
+ /**
30
+ * @docs-group-description MobileAppProps
31
+ * Configuration options for use with MobileApp.
32
+ */
33
+ /**
34
+ * @docs-group-description MobileHost
35
+ * Classes for configuring and administering the backend host on mobile.
36
+ */
37
+ /**
38
+ * @docs-group-description MobileRpcManager
39
+ * Coordinates usage of RPC interfaces for mobile applications.
40
+ */
41
+ /**
42
+ * @docs-group-description MobileRpcServer
43
+ * Provides RPC handling for the backend host on mobile.
44
+ */
45
+ /**
46
+ * @docs-group-description iModelHub
47
+ * Classes for interacting with iModelHub.
48
+ */
49
+ /**
50
+ * @docs-group-description RpcInterface
51
+ * Used to define a set of operations exposed by a service that a client can call, using configurable protocols.
52
+ */
22
53
  //# sourceMappingURL=__DOC_ONLY__.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"__DOC_ONLY__.js","sourceRoot":"","sources":["../../src/__DOC_ONLY__.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,sDAAsD;AACtD,0EAA0E;AAC1E,iCAAiC;AAEjC,kDAAgC;AAChC,mDAAiC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n// THIS FILE EXISTS ONLY FOR DOCUMENTATION GENERATION.\r\n// It imports both frontend and backend code, which is not legal anywhere.\r\n// Do not import it in real code!\r\n\r\nexport * from \"./MobileBackend\";\r\nexport * from \"./MobileFrontend\";\r\n"]}
1
+ {"version":3,"file":"__DOC_ONLY__.js","sourceRoot":"","sources":["../../src/__DOC_ONLY__.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,sDAAsD;AACtD,0EAA0E;AAC1E,iCAAiC;AAEjC,kDAAgC;AAChC,mDAAiC;AAEjC;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n// THIS FILE EXISTS ONLY FOR DOCUMENTATION GENERATION.\r\n// It imports both frontend and backend code, which is not legal anywhere.\r\n// Do not import it in real code!\r\n\r\nexport * from \"./MobileBackend\";\r\nexport * from \"./MobileFrontend\";\r\n\r\n/** @docs-package-description\r\n * The core-mobile package provides the necessary tools to run an ITwin.js application on iOS and Android. It provides a layer of communication between native tooling for mobile apps and ITwin.js core.\r\n */\r\n/**\r\n * @docs-group-description MobileApp\r\n * Classes for configuring and administering an iTwin.js application on mobile.\r\n */\r\n/**\r\n * @docs-group-description MobileAppProps\r\n * Configuration options for use with MobileApp.\r\n */\r\n/**\r\n * @docs-group-description MobileHost\r\n * Classes for configuring and administering the backend host on mobile.\r\n */\r\n/**\r\n * @docs-group-description MobileRpcManager\r\n * Coordinates usage of RPC interfaces for mobile applications.\r\n */\r\n/**\r\n * @docs-group-description MobileRpcServer\r\n * Provides RPC handling for the backend host on mobile.\r\n */\r\n/**\r\n * @docs-group-description iModelHub\r\n * Classes for interacting with iModelHub.\r\n */\r\n/**\r\n * @docs-group-description RpcInterface\r\n * Used to define a set of operations exposed by a service that a client can call, using configurable protocols.\r\n */\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAuthorizationBackend.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IACpE,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,KAAK,WAAW,GAEtB;IAEY,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IA2B5C,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CAIpE"}
1
+ {"version":3,"file":"MobileAuthorizationBackend.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IACpE,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,KAAK,WAAW,GAEtB;IAEY,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAkB5C,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM;CAIpE"}
@@ -25,25 +25,18 @@ class MobileAuthorizationBackend {
25
25
  if (this._fetchingToken) {
26
26
  return Promise.reject(); // short-circuits any recursive use of this function
27
27
  }
28
- return new Promise((resolve, reject) => {
29
- if (this._accessToken && !this._hasExpired) {
30
- resolve(this._accessToken);
31
- }
32
- else {
33
- this._fetchingToken = true;
34
- MobileHost_1.MobileHost.device.authGetAccessToken((tokenString, expirationDate, error) => {
35
- if (error) {
36
- this._accessToken = "";
37
- reject(error);
38
- }
39
- this._accessToken = tokenString !== null && tokenString !== void 0 ? tokenString : "";
40
- if (expirationDate !== undefined)
41
- this._expirationDate = new Date(expirationDate);
42
- resolve(this._accessToken);
43
- });
44
- this._fetchingToken = false;
45
- }
46
- });
28
+ if (this._accessToken && !this._hasExpired) {
29
+ return this._accessToken;
30
+ }
31
+ else {
32
+ this._fetchingToken = true;
33
+ const result = await MobileHost_1.MobileHost.authGetAccessToken();
34
+ this._accessToken = result[0];
35
+ if (result[1])
36
+ this._expirationDate = new Date(result[1]);
37
+ this._fetchingToken = false;
38
+ return this._accessToken;
39
+ }
47
40
  }
48
41
  setAccessToken(accessToken, expirationDate) {
49
42
  this._accessToken = accessToken !== null && accessToken !== void 0 ? accessToken : "";
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAuthorizationBackend.js","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,6CAA0C;AAE1C;;GAEG;AACH,MAAa,0BAA0B;IAAvC;QACU,iBAAY,GAAgB,EAAE,CAAC;QAE/B,kBAAa,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,cAAc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AAX,WAAW,GAAI,EAAE,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;CACF;AAzCD,gEAyCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module OIDC\r\n */\r\n\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient } from \"@itwin/core-common\";\r\nimport { MobileHost } from \"./MobileHost\";\r\n\r\n/** Utility to provide and cache auth tokens from native mobile apps to IModelHost.\r\n * @internal\r\n */\r\nexport class MobileAuthorizationBackend implements AuthorizationClient {\r\n private _accessToken: AccessToken = \"\";\r\n private _expirationDate: Date | undefined;\r\n private _expiryBuffer = 60 * 10; // ten minutes\r\n private _fetchingToken = false;\r\n\r\n private get _hasExpired(): boolean {\r\n return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (this._fetchingToken) {\r\n return Promise.reject(); // short-circuits any recursive use of this function\r\n }\r\n\r\n return new Promise<AccessToken>((resolve, reject) => {\r\n if (this._accessToken && !this._hasExpired) {\r\n resolve(this._accessToken);\r\n } else {\r\n this._fetchingToken = true;\r\n MobileHost.device.authGetAccessToken((tokenString?: AccessToken, expirationDate?: string, error?: string) => {\r\n if (error) {\r\n this._accessToken = \"\";\r\n reject(error);\r\n }\r\n\r\n this._accessToken = tokenString ?? \"\";\r\n if (expirationDate !== undefined)\r\n this._expirationDate = new Date(expirationDate);\r\n\r\n resolve(this._accessToken);\r\n });\r\n this._fetchingToken = false;\r\n }\r\n });\r\n }\r\n\r\n public setAccessToken(accessToken?: string, expirationDate?: string) {\r\n this._accessToken = accessToken ?? \"\";\r\n this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MobileAuthorizationBackend.js","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,6CAA0C;AAE1C;;GAEG;AACH,MAAa,0BAA0B;IAAvC;QACU,iBAAY,GAAgB,EAAE,CAAC;QAE/B,kBAAa,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,cAAc;QACvC,mBAAc,GAAG,KAAK,CAAC;IA4BjC,CAAC;IA1BC,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,eAAe,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IACxH,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,oDAAoD;SAC9E;QAED,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAC1C,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;aAAM;YACL,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,MAAM,MAAM,GAAG,MAAM,uBAAU,CAAC,kBAAkB,EAAE,CAAC;YACrD,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,MAAM,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAC5B,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;IACH,CAAC;IAEM,cAAc,CAAC,WAAoB,EAAE,cAAuB;QACjE,IAAI,CAAC,YAAY,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/E,CAAC;CACF;AAhCD,gEAgCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module OIDC\r\n */\r\n\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient } from \"@itwin/core-common\";\r\nimport { MobileHost } from \"./MobileHost\";\r\n\r\n/** Utility to provide and cache auth tokens from native mobile apps to IModelHost.\r\n * @internal\r\n */\r\nexport class MobileAuthorizationBackend implements AuthorizationClient {\r\n private _accessToken: AccessToken = \"\";\r\n private _expirationDate: Date | undefined;\r\n private _expiryBuffer = 60 * 10; // ten minutes\r\n private _fetchingToken = false;\r\n\r\n private get _hasExpired(): boolean {\r\n return this._expirationDate !== undefined && this._expirationDate.getTime() - Date.now() <= this._expiryBuffer * 1000;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (this._fetchingToken) {\r\n return Promise.reject(); // short-circuits any recursive use of this function\r\n }\r\n\r\n if (this._accessToken && !this._hasExpired) {\r\n return this._accessToken;\r\n } else {\r\n this._fetchingToken = true;\r\n const result = await MobileHost.authGetAccessToken();\r\n this._accessToken = result[0];\r\n if (result[1])\r\n this._expirationDate = new Date(result[1]);\r\n this._fetchingToken = false;\r\n return this._accessToken;\r\n }\r\n }\r\n\r\n public setAccessToken(accessToken?: string, expirationDate?: string) {\r\n this._accessToken = accessToken ?? \"\";\r\n this._expirationDate = expirationDate ? new Date(expirationDate) : undefined;\r\n }\r\n}\r\n"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C,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;CAC1H;AAYD,YAAY;AACZ,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE,YAAY,CAAC;QACtB,oDAAoD;QACpD,aAAa,CAAC,EAAE,sBAAsB,EAAE,CAAC;KAC1C,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAe;IACtC,WAAkB,MAAM,iBAA4B;IACpD,gBAAuB,eAAe,kDAAiB;IACvD,gBAAuB,oBAAoB,kDAAiB;IAC5D,gBAAuB,iBAAiB,kDAAiB;IACzD,gBAAuB,iBAAiB,kDAAiB;IACzD,gBAAuB,eAAe,kDAAiB;IACvD,gBAAuB,wBAAwB,wBAA6B,MAAM,GAAG,SAAS,kBAAkB,MAAM,GAAG,SAAS,KAAK,IAAI,EAAI;IAE/I,yEAAyE;WAC3D,oBAAoB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAIlI,iBAAiB;WACH,SAAS,CAAC,UAAU,EAAE,MAAM;IAI1C,iBAAiB;WACG,kBAAkB;IAWtC,iBAAiB;WACG,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCpJ,WAAkB,OAAO,YAAyC;IAElE,yCAAyC;WACrB,OAAO,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAiDjE"}
@@ -65,7 +65,7 @@ class MobileHost {
65
65
  /** @internal */
66
66
  static async authGetAccessToken() {
67
67
  return new Promise((resolve, reject) => {
68
- MobileHost.device.authGetAccessToken((tokenString, expirationDate, error) => {
68
+ this.device.authGetAccessToken((tokenString, expirationDate, error) => {
69
69
  if (error) {
70
70
  reject(error);
71
71
  }
@@ -109,7 +109,7 @@ class MobileHost {
109
109
  static get isValid() { return undefined !== this._device; }
110
110
  /** Start the backend of a mobile app. */
111
111
  static async startup(opt) {
112
- var _a, _b, _c, _d, _e;
112
+ var _a, _b, _c, _d, _e, _f, _g;
113
113
  const authorizationClient = new MobileAuthorizationBackend_1.MobileAuthorizationBackend();
114
114
  if (!this.isValid) {
115
115
  this._device = (_b = (_a = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _a === void 0 ? void 0 : _a.device) !== null && _b !== void 0 ? _b : new MobileDevice();
@@ -137,12 +137,14 @@ class MobileHost {
137
137
  // following will provide impl for device specific api.
138
138
  (0, MobileRpcServer_1.setupMobileRpc)();
139
139
  }
140
- const iModelHostConfiguration = (_c = opt === null || opt === void 0 ? void 0 : opt.iModelHost) !== null && _c !== void 0 ? _c : new core_backend_1.IModelHostConfiguration();
140
+ const socket = (_d = (_c = opt === null || opt === void 0 ? void 0 : opt.ipcHost) === null || _c === void 0 ? void 0 : _c.socket) !== null && _d !== void 0 ? _d : new core_common_1.IpcWebSocketBackend();
141
+ opt = { ...opt, mobileHost: { ...opt === null || opt === void 0 ? void 0 : opt.mobileHost }, ipcHost: { ...opt === null || opt === void 0 ? void 0 : opt.ipcHost, socket } };
142
+ const iModelHostConfiguration = (_e = opt === null || opt === void 0 ? void 0 : opt.iModelHost) !== null && _e !== void 0 ? _e : new core_backend_1.IModelHostConfiguration();
141
143
  iModelHostConfiguration.authorizationClient = authorizationClient;
142
144
  await core_backend_1.NativeHost.startup({ ...opt, iModelHost: iModelHostConfiguration });
143
145
  if (core_backend_1.IpcHost.isValid)
144
146
  MobileAppHandler.register();
145
- const rpcInterfaces = (_e = (_d = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _d === void 0 ? void 0 : _d.rpcInterfaces) !== null && _e !== void 0 ? _e : [
147
+ const rpcInterfaces = (_g = (_f = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _f === void 0 ? void 0 : _f.rpcInterfaces) !== null && _g !== void 0 ? _g : [
146
148
  core_common_1.IModelReadRpcInterface,
147
149
  core_common_1.IModelTileRpcInterface,
148
150
  core_common_1.SnapshotIModelRpcInterface,
@@ -1 +1 @@
1
- {"version":3,"file":"MobileHost.js","sourceRoot":"","sources":["../../../src/backend/MobileHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA4E;AAC5E,sDAA+G;AAC/G,oDAG4B;AAC5B,2DAAwF;AAExF,oEAAsE;AACtE,iEAA+E;AAE/E,iEAA8D;AAC9D,6EAA0E;AAC1E,uDAAmD;AAwBnD,YAAY;AACZ,MAAsB,YAAY;IACzB,IAAI,CAAC,SAAuB,EAAE,GAAG,IAAW;QACjD,QAAQ,SAAS,EAAE;YACjB,KAAK,eAAe;gBAClB,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YACxD,KAAK,oBAAoB;gBACvB,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC7D,KAAK,iBAAiB;gBACpB,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC1D,KAAK,iBAAiB;gBACpB,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC1D,KAAK,eAAe;gBAClB,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YACxD,KAAK,wBAAwB;gBAC3B,UAAU,CAAC,wBAAwB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,MAAM;SAC3E;IACH,CAAC;C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C,4BAAiB,GAAG,IAAI,sBAAO,EAAE,CAAC;AAClC,0BAAe,GAAG,IAAI,sBAAO,EAAE,CAAC;AAChC,mCAAwB,GAAG,IAAI,sBAAO,EAAiF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AccessToken, BeEvent, BriefcaseStatus } from \"@itwin/core-bentley\";\r\nimport { IModelHostConfiguration, IpcHandler, IpcHost, NativeHost, NativeHostOpts } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, IModelTileRpcInterface, RpcInterfaceDefinition,\r\n SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { CancelRequest, DownloadFailed, UserCancelledError } from \"./MobileFileHandler\";\r\nimport { ProgressCallback } from \"./Request\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { mobileAppChannel, mobileAppNotify } from \"../common/MobileAppChannel\";\r\nimport { BatteryState, DeviceEvents, MobileAppFunctions, MobileNotifications, Orientation } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAuthorizationBackend } from \"./MobileAuthorizationBackend\";\r\nimport { setupMobileRpc } from \"./MobileRpcServer\";\r\n\r\n/** @beta */\r\nexport type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;\r\n/** @beta */\r\nexport type MobileProgressCallback = (bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => void;\r\n/** @beta */\r\nexport type MobileCancelCallback = () => boolean;\r\n\r\n/** @beta */\r\nexport interface DownloadTask {\r\n url: string;\r\n downloadPath: string;\r\n isDetached: boolean;\r\n isRunning: boolean;\r\n totalBytes?: number;\r\n doneBytes?: number;\r\n cancelId?: number;\r\n isBackground?: boolean;\r\n cancel?: MobileCancelCallback;\r\n toBackground: () => boolean;\r\n toForeground: () => boolean;\r\n}\r\n\r\n/** @beta */\r\nexport abstract class MobileDevice {\r\n public emit(eventName: DeviceEvents, ...args: any[]) {\r\n switch (eventName) {\r\n case \"memoryWarning\":\r\n MobileHost.onMemoryWarning.raiseEvent(...args); break;\r\n case \"orientationChanged\":\r\n MobileHost.onOrientationChanged.raiseEvent(...args); break;\r\n case \"enterForeground\":\r\n MobileHost.onEnterForeground.raiseEvent(...args); break;\r\n case \"enterBackground\":\r\n MobileHost.onEnterBackground.raiseEvent(...args); break;\r\n case \"willTerminate\":\r\n MobileHost.onWillTerminate.raiseEvent(...args); break;\r\n case \"authAccessTokenChanged\":\r\n MobileHost.onAuthAccessTokenChanged.raiseEvent(args[0], args[1]); break;\r\n }\r\n }\r\n\r\n public abstract getOrientation(): Orientation;\r\n public abstract getBatteryState(): BatteryState;\r\n public abstract getBatteryLevel(): number;\r\n public abstract createDownloadTask(downloadUrl: string, isBackground: boolean, downloadTo: string, completion: MobileCompletionCallback, progress?: MobileProgressCallback): number;\r\n public abstract cancelDownloadTask(cancelId: number): boolean;\r\n public abstract getDownloadTasks(): DownloadTask[];\r\n public abstract resumeDownloadInForeground(requestId: number): boolean;\r\n public abstract resumeDownloadInBackground(requestId: number): boolean;\r\n public abstract reconnect(connection: number): void;\r\n public abstract authGetAccessToken(callback: (accessToken?: string, expirationDate?: string, err?: string) => void): void;\r\n}\r\n\r\nclass MobileAppHandler extends IpcHandler implements MobileAppFunctions {\r\n public get channelName() { return mobileAppChannel; }\r\n public async reconnect(connection: number) {\r\n MobileHost.reconnect(connection);\r\n }\r\n public async getAccessToken() {\r\n return MobileHost.authGetAccessToken();\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport interface MobileHostOpts extends NativeHostOpts {\r\n mobileHost?: {\r\n device?: MobileDevice;\r\n /** list of RPC interface definitions to register */\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n };\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class MobileHost {\r\n private static _device?: MobileDevice;\r\n public static get device() { return this._device!; }\r\n public static readonly onMemoryWarning = new BeEvent();\r\n public static readonly onOrientationChanged = new BeEvent();\r\n public static readonly onEnterForeground = new BeEvent();\r\n public static readonly onEnterBackground = new BeEvent();\r\n public static readonly onWillTerminate = new BeEvent();\r\n public static readonly onAuthAccessTokenChanged = new BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>();\r\n\r\n /** Send a notification to the MobileApp connected to this MobileHost. */\r\n public static notifyMobileFrontend<T extends keyof MobileNotifications>(methodName: T, ...args: Parameters<MobileNotifications[T]>) {\r\n return IpcHost.send(mobileAppNotify, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static reconnect(connection: number) {\r\n this.device.reconnect(connection);\r\n }\r\n\r\n /** @internal */\r\n public static async authGetAccessToken() {\r\n return new Promise<[AccessToken, string]>((resolve, reject) => {\r\n MobileHost.device.authGetAccessToken((tokenString?: AccessToken, expirationDate?: string, error?: string) => {\r\n if (error) {\r\n reject(error);\r\n }\r\n resolve([tokenString ?? \"\", expirationDate ?? \"\"]);\r\n });\r\n });\r\n }\r\n\r\n /** @internal */\r\n public static async downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n\r\n let progressCb: MobileProgressCallback | undefined;\r\n let lastReportedOn = Date.now();\r\n const minTimeBeforeReportingProgress = 1000;\r\n if (progress) {\r\n progressCb = (_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => {\r\n const currentTime = Date.now();\r\n const timeSinceLastEvent = currentTime - lastReportedOn;\r\n // report all event for last 5 Mbs so we never miss 100% progress event\r\n const lastEvent = (totalBytesExpectedToWrite - totalBytesWritten) < 1024 * 1024 * 5;\r\n if (timeSinceLastEvent < minTimeBeforeReportingProgress && !lastEvent)\r\n return;\r\n\r\n lastReportedOn = currentTime;\r\n const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2));\r\n progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent });\r\n };\r\n }\r\n const requestId = this.device.createDownloadTask(downloadUrl, false, downloadTo, (_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => {\r\n if (cancelled)\r\n reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, \"User cancelled download\"));\r\n else if (err)\r\n reject(new DownloadFailed(400, \"Download failed\"));\r\n else\r\n resolve();\r\n }, progressCb);\r\n if (cancelRequest) {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n cancelRequest.cancel = () => { return this.device.cancelDownloadTask(requestId); };\r\n }\r\n });\r\n }\r\n\r\n public static get isValid() { return undefined !== this._device; }\r\n\r\n /** Start the backend of a mobile app. */\r\n public static async startup(opt?: MobileHostOpts): Promise<void> {\r\n const authorizationClient = new MobileAuthorizationBackend();\r\n if (!this.isValid) {\r\n this._device = opt?.mobileHost?.device ?? new (MobileDevice as any)();\r\n // set global device interface.\r\n (global as any).__iTwinJsNativeBridge = this._device;\r\n this.onMemoryWarning.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyMemoryWarning\");\r\n });\r\n this.onOrientationChanged.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyOrientationChanged\");\r\n });\r\n this.onEnterForeground.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyEnterForeground\");\r\n });\r\n this.onEnterBackground.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyEnterBackground\");\r\n });\r\n this.onWillTerminate.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyWillTerminate\");\r\n });\r\n this.onAuthAccessTokenChanged.addListener((accessToken: string | undefined, expirationDate: string | undefined) => {\r\n authorizationClient.setAccessToken(accessToken, expirationDate);\r\n MobileHost.notifyMobileFrontend(\"notifyAuthAccessTokenChanged\", accessToken, expirationDate);\r\n });\r\n\r\n // following will provide impl for device specific api.\r\n setupMobileRpc();\r\n }\r\n const iModelHostConfiguration = opt?.iModelHost ?? new IModelHostConfiguration();\r\n iModelHostConfiguration.authorizationClient = authorizationClient;\r\n await NativeHost.startup({ ...opt, iModelHost: iModelHostConfiguration });\r\n\r\n if (IpcHost.isValid)\r\n MobileAppHandler.register();\r\n\r\n const rpcInterfaces = opt?.mobileHost?.rpcInterfaces ?? [\r\n IModelReadRpcInterface,\r\n IModelTileRpcInterface,\r\n SnapshotIModelRpcInterface,\r\n PresentationRpcInterface,\r\n ];\r\n\r\n MobileRpcManager.initializeImpl(rpcInterfaces);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MobileHost.js","sourceRoot":"","sources":["../../../src/backend/MobileHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA4E;AAC5E,sDAA+G;AAC/G,oDAG4B;AAC5B,2DAAwF;AAExF,oEAAsE;AACtE,iEAA+E;AAE/E,iEAA8D;AAC9D,6EAA0E;AAC1E,uDAAmD;AAwBnD,YAAY;AACZ,MAAsB,YAAY;IACzB,IAAI,CAAC,SAAuB,EAAE,GAAG,IAAW;QACjD,QAAQ,SAAS,EAAE;YACjB,KAAK,eAAe;gBAClB,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YACxD,KAAK,oBAAoB;gBACvB,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC7D,KAAK,iBAAiB;gBACpB,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC1D,KAAK,iBAAiB;gBACpB,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC1D,KAAK,eAAe;gBAClB,UAAU,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;gBAAC,MAAM;YAC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AAE,UAAU,EAAE,uBAAuB,EAAE,CAAC,CAAC;QAE1E,IAAI,sBAAO,CAAC,OAAO;YACjB,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAE9B,MAAM,aAAa,GAAG,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,aAAa,mCAAI;YACtD,oCAAsB;YACtB,oCAAsB;YACtB,wCAA0B;YAC1B,8CAAwB;SACzB,CAAC;QAEF,mCAAgB,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;;AAvHH,gCAwHC;AArHwB,0BAAe,GAAG,IAAI,sBAAO,EAAE,CAAC;AAChC,+BAAoB,GAAG,IAAI,sBAAO,EAAE,CAAC;AACrC,4BAAiB,GAAG,IAAI,sBAAO,EAAE,CAAC;AAClC,4BAAiB,GAAG,IAAI,sBAAO,EAAE,CAAC;AAClC,0BAAe,GAAG,IAAI,sBAAO,EAAE,CAAC;AAChC,mCAAwB,GAAG,IAAI,sBAAO,EAAiF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AccessToken, BeEvent, BriefcaseStatus } from \"@itwin/core-bentley\";\r\nimport { IModelHostConfiguration, IpcHandler, IpcHost, NativeHost, NativeHostOpts } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, IModelTileRpcInterface, IpcWebSocketBackend, RpcInterfaceDefinition,\r\n SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { CancelRequest, DownloadFailed, UserCancelledError } from \"./MobileFileHandler\";\r\nimport { ProgressCallback } from \"./Request\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { mobileAppChannel, mobileAppNotify } from \"../common/MobileAppChannel\";\r\nimport { BatteryState, DeviceEvents, MobileAppFunctions, MobileNotifications, Orientation } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAuthorizationBackend } from \"./MobileAuthorizationBackend\";\r\nimport { setupMobileRpc } from \"./MobileRpcServer\";\r\n\r\n/** @beta */\r\nexport type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;\r\n/** @beta */\r\nexport type MobileProgressCallback = (bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => void;\r\n/** @beta */\r\nexport type MobileCancelCallback = () => boolean;\r\n\r\n/** @beta */\r\nexport interface DownloadTask {\r\n url: string;\r\n downloadPath: string;\r\n isDetached: boolean;\r\n isRunning: boolean;\r\n totalBytes?: number;\r\n doneBytes?: number;\r\n cancelId?: number;\r\n isBackground?: boolean;\r\n cancel?: MobileCancelCallback;\r\n toBackground: () => boolean;\r\n toForeground: () => boolean;\r\n}\r\n\r\n/** @beta */\r\nexport abstract class MobileDevice {\r\n public emit(eventName: DeviceEvents, ...args: any[]) {\r\n switch (eventName) {\r\n case \"memoryWarning\":\r\n MobileHost.onMemoryWarning.raiseEvent(...args); break;\r\n case \"orientationChanged\":\r\n MobileHost.onOrientationChanged.raiseEvent(...args); break;\r\n case \"enterForeground\":\r\n MobileHost.onEnterForeground.raiseEvent(...args); break;\r\n case \"enterBackground\":\r\n MobileHost.onEnterBackground.raiseEvent(...args); break;\r\n case \"willTerminate\":\r\n MobileHost.onWillTerminate.raiseEvent(...args); break;\r\n case \"authAccessTokenChanged\":\r\n MobileHost.onAuthAccessTokenChanged.raiseEvent(args[0], args[1]); break;\r\n }\r\n }\r\n\r\n public abstract getOrientation(): Orientation;\r\n public abstract getBatteryState(): BatteryState;\r\n public abstract getBatteryLevel(): number;\r\n public abstract createDownloadTask(downloadUrl: string, isBackground: boolean, downloadTo: string, completion: MobileCompletionCallback, progress?: MobileProgressCallback): number;\r\n public abstract cancelDownloadTask(cancelId: number): boolean;\r\n public abstract getDownloadTasks(): DownloadTask[];\r\n public abstract resumeDownloadInForeground(requestId: number): boolean;\r\n public abstract resumeDownloadInBackground(requestId: number): boolean;\r\n public abstract reconnect(connection: number): void;\r\n public abstract authGetAccessToken(callback: (accessToken?: string, expirationDate?: string, err?: string) => void): void;\r\n}\r\n\r\nclass MobileAppHandler extends IpcHandler implements MobileAppFunctions {\r\n public get channelName() { return mobileAppChannel; }\r\n public async reconnect(connection: number) {\r\n MobileHost.reconnect(connection);\r\n }\r\n public async getAccessToken() {\r\n return MobileHost.authGetAccessToken();\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport interface MobileHostOpts extends NativeHostOpts {\r\n mobileHost?: {\r\n device?: MobileDevice;\r\n /** list of RPC interface definitions to register */\r\n rpcInterfaces?: RpcInterfaceDefinition[];\r\n };\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class MobileHost {\r\n private static _device?: MobileDevice;\r\n public static get device() { return this._device!; }\r\n public static readonly onMemoryWarning = new BeEvent();\r\n public static readonly onOrientationChanged = new BeEvent();\r\n public static readonly onEnterForeground = new BeEvent();\r\n public static readonly onEnterBackground = new BeEvent();\r\n public static readonly onWillTerminate = new BeEvent();\r\n public static readonly onAuthAccessTokenChanged = new BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>();\r\n\r\n /** Send a notification to the MobileApp connected to this MobileHost. */\r\n public static notifyMobileFrontend<T extends keyof MobileNotifications>(methodName: T, ...args: Parameters<MobileNotifications[T]>) {\r\n return IpcHost.send(mobileAppNotify, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static reconnect(connection: number) {\r\n this.device.reconnect(connection);\r\n }\r\n\r\n /** @internal */\r\n public static async authGetAccessToken() {\r\n return new Promise<[AccessToken, string]>((resolve, reject) => {\r\n this.device.authGetAccessToken((tokenString?: AccessToken, expirationDate?: string, error?: string) => {\r\n if (error) {\r\n reject(error);\r\n }\r\n resolve([tokenString ?? \"\", expirationDate ?? \"\"]);\r\n });\r\n });\r\n }\r\n\r\n /** @internal */\r\n public static async downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n\r\n let progressCb: MobileProgressCallback | undefined;\r\n let lastReportedOn = Date.now();\r\n const minTimeBeforeReportingProgress = 1000;\r\n if (progress) {\r\n progressCb = (_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => {\r\n const currentTime = Date.now();\r\n const timeSinceLastEvent = currentTime - lastReportedOn;\r\n // report all event for last 5 Mbs so we never miss 100% progress event\r\n const lastEvent = (totalBytesExpectedToWrite - totalBytesWritten) < 1024 * 1024 * 5;\r\n if (timeSinceLastEvent < minTimeBeforeReportingProgress && !lastEvent)\r\n return;\r\n\r\n lastReportedOn = currentTime;\r\n const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2));\r\n progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent });\r\n };\r\n }\r\n const requestId = this.device.createDownloadTask(downloadUrl, false, downloadTo, (_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => {\r\n if (cancelled)\r\n reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, \"User cancelled download\"));\r\n else if (err)\r\n reject(new DownloadFailed(400, \"Download failed\"));\r\n else\r\n resolve();\r\n }, progressCb);\r\n if (cancelRequest) {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n cancelRequest.cancel = () => { return this.device.cancelDownloadTask(requestId); };\r\n }\r\n });\r\n }\r\n\r\n public static get isValid() { return undefined !== this._device; }\r\n\r\n /** Start the backend of a mobile app. */\r\n public static async startup(opt?: MobileHostOpts): Promise<void> {\r\n const authorizationClient = new MobileAuthorizationBackend();\r\n if (!this.isValid) {\r\n this._device = opt?.mobileHost?.device ?? new (MobileDevice as any)();\r\n // set global device interface.\r\n (global as any).__iTwinJsNativeBridge = this._device;\r\n this.onMemoryWarning.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyMemoryWarning\");\r\n });\r\n this.onOrientationChanged.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyOrientationChanged\");\r\n });\r\n this.onEnterForeground.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyEnterForeground\");\r\n });\r\n this.onEnterBackground.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyEnterBackground\");\r\n });\r\n this.onWillTerminate.addListener(() => {\r\n MobileHost.notifyMobileFrontend(\"notifyWillTerminate\");\r\n });\r\n this.onAuthAccessTokenChanged.addListener((accessToken: string | undefined, expirationDate: string | undefined) => {\r\n authorizationClient.setAccessToken(accessToken, expirationDate);\r\n MobileHost.notifyMobileFrontend(\"notifyAuthAccessTokenChanged\", accessToken, expirationDate);\r\n });\r\n\r\n // following will provide impl for device specific api.\r\n setupMobileRpc();\r\n }\r\n\r\n const socket = opt?.ipcHost?.socket ?? new IpcWebSocketBackend();\r\n opt = { ...opt, mobileHost: { ...opt?.mobileHost }, ipcHost: { ...opt?.ipcHost, socket } };\r\n\r\n const iModelHostConfiguration = opt?.iModelHost ?? new IModelHostConfiguration();\r\n iModelHostConfiguration.authorizationClient = authorizationClient;\r\n await NativeHost.startup({ ...opt, iModelHost: iModelHostConfiguration });\r\n\r\n if (IpcHost.isValid)\r\n MobileAppHandler.register();\r\n\r\n const rpcInterfaces = opt?.mobileHost?.rpcInterfaces ?? [\r\n IModelReadRpcInterface,\r\n IModelTileRpcInterface,\r\n SnapshotIModelRpcInterface,\r\n PresentationRpcInterface,\r\n ];\r\n\r\n MobileRpcManager.initializeImpl(rpcInterfaces);\r\n }\r\n}\r\n"]}
@@ -2,6 +2,12 @@ import { AsyncMethodsOf, BeEvent, PromiseReturnType } from "@itwin/core-bentley"
2
2
  import { NativeAppOpts } from "@itwin/core-frontend";
3
3
  import { MobileAppFunctions } from "../common/MobileAppProps";
4
4
  /** @beta */
5
+ export declare type MobileAppOpts = NativeAppOpts & {
6
+ iModelApp: {
7
+ authorizationClient?: never;
8
+ };
9
+ };
10
+ /** @beta */
5
11
  export declare class MobileApp {
6
12
  static onMemoryWarning: BeEvent<() => void>;
7
13
  static onOrientationChanged: BeEvent<() => void>;
@@ -12,10 +18,7 @@ export declare class MobileApp {
12
18
  static callBackend<T extends AsyncMethodsOf<MobileAppFunctions>>(methodName: T, ...args: Parameters<MobileAppFunctions[T]>): Promise<PromiseReturnType<MobileAppFunctions[T]>>;
13
19
  private static _isValid;
14
20
  static get isValid(): boolean;
15
- /**
16
- * This is called by either AndroidApp.startup or IOSApp.startup - it should not be called directly
17
- * @internal
18
- */
19
- static startup(opts?: NativeAppOpts): Promise<void>;
21
+ /** @beta */
22
+ static startup(opts?: MobileAppOpts): Promise<void>;
20
23
  }
21
24
  //# sourceMappingURL=MobileApp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/MobileApp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAU,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAqB,aAAa,EAAuB,MAAM,sBAAsB,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAuB,MAAM,0BAA0B,CAAC;AAwBnF,YAAY;AACZ,qBAAa,SAAS;IACpB,OAAc,eAAe,gBAAqB,IAAI,EAAI;IAC1D,OAAc,oBAAoB,gBAAqB,IAAI,EAAI;IAC/D,OAAc,iBAAiB,gBAAqB,IAAI,EAAI;IAC5D,OAAc,iBAAiB,gBAAqB,IAAI,EAAI;IAC5D,OAAc,eAAe,gBAAqB,IAAI,EAAI;IAC1D,OAAc,wBAAwB,wBAA6B,MAAM,GAAG,SAAS,kBAAkB,MAAM,GAAG,SAAS,KAAK,IAAI,EAAI;WAClH,WAAW,CAAC,CAAC,SAAS,cAAc,CAAC,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,kBAA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.callIpcChannel(MobileAppChannel_1.mobileAppChannel, methodName, ...args);
36
36
  }
37
37
  static get isValid() { return this._isValid; }
38
- /**
39
- * This is called by either AndroidApp.startup or IOSApp.startup - it should not be called directly
40
- * @internal
41
- */
38
+ /** @beta */
42
39
  static async startup(opts) {
43
40
  var _a, _b;
44
41
  const iModelAppOpts = {
@@ -1 +1 @@
1
- {"version":3,"file":"MobileApp.js","sourceRoot":"","sources":["../../../src/frontend/MobileApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAyF;AACzF,oDAA0G;AAC1G,wDAA6F;AAC7F,iEAA+E;AAE/E,iEAA8D;AAC9D,+EAA4E;AAE5E,yCAAyC;AACzC,MAAM,sBAAuB,SAAQ,mCAAmB;IACtD,IAAW,WAAW,KAAK,OAAO,kCAAe,CAAC,CAAC,CAAC;IAE7C,mBAAmB;QACxB,qBAAM,CAAC,UAAU,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QACrD,IAAI,SAAS,CAAC,eAAe,CAAC,iBAAiB,KAAK,CAAC,EAAE;YACrD,KAAK,CAAC,oBAAoB,CAAC,CAAC;SAC7B;QACD,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;IACzC,CAAC;IACM,wBAAwB,KAAK,SAAS,CAAC,oBAAoB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC3E,qBAAqB,KAAK,SAAS,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACrE,qBAAqB,KAAK,SAAS,CAAC,iBAAiB,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACrE,mBAAmB,KAAK,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACjE,4BAA4B,CAAC,WAA+B,EAAE,cAAkC;QACrG,SAAS,CAAC,wBAAwB,CAAC,UAAU,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC7E,CAAC;CACF;AAED,YAAY;AACZ,MAAa,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BAAe,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC5C,8BAAoB,GAAG,IAAI,sBAAO,EAAc,CAAC;AACjD,2BAAiB,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC9C,2BAAiB,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC9C,yBAAe,GAAG,IAAI,sBAAO,EAAc,CAAC;AAC5C,kCAAwB,GAAG,IAAI,sBAAO,EAAiF,CAAC;AAKvH,kBAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AsyncMethodsOf, BeEvent, Logger, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport { IModelReadRpcInterface, IModelTileRpcInterface, IpcWebSocketFrontend } from \"@itwin/core-common\";\r\nimport { IpcApp, NativeApp, NativeAppOpts, NotificationHandler } from \"@itwin/core-frontend\";\r\nimport { mobileAppChannel, mobileAppNotify } from \"../common/MobileAppChannel\";\r\nimport { MobileAppFunctions, MobileNotifications } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAuthorizationFrontend } from \"./MobileAuthorizationFrontend\";\r\n\r\n/** receive notifications from backend */\r\nclass MobileAppNotifyHandler extends NotificationHandler implements MobileNotifications {\r\n public get channelName() { return mobileAppNotify; }\r\n\r\n public notifyMemoryWarning() {\r\n Logger.logWarning(\"mobileApp\", \"Low memory warning\");\r\n if (MobileApp.onMemoryWarning.numberOfListeners === 0) {\r\n alert(\"Low memory warning\");\r\n }\r\n MobileApp.onMemoryWarning.raiseEvent();\r\n }\r\n public notifyOrientationChanged() { MobileApp.onOrientationChanged.raiseEvent(); }\r\n public notifyEnterForeground() { MobileApp.onEnterBackground.raiseEvent(); }\r\n public notifyEnterBackground() { MobileApp.onEnterBackground.raiseEvent(); }\r\n public notifyWillTerminate() { MobileApp.onWillTerminate.raiseEvent(); }\r\n public notifyAuthAccessTokenChanged(accessToken: string | undefined, expirationDate: string | undefined) {\r\n MobileApp.onAuthAccessTokenChanged.raiseEvent(accessToken, expirationDate);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport class MobileApp {\r\n public static onMemoryWarning = new BeEvent<() => void>();\r\n public static onOrientationChanged = new BeEvent<() => void>();\r\n public static onEnterForeground = new BeEvent<() => void>();\r\n public static onEnterBackground = new BeEvent<() => void>();\r\n public static onWillTerminate = new BeEvent<() => void>();\r\n public static onAuthAccessTokenChanged = new BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>();\r\n public static async callBackend<T extends AsyncMethodsOf<MobileAppFunctions>>(methodName: T, ...args: Parameters<MobileAppFunctions[T]>) {\r\n return IpcApp.callIpcChannel(mobileAppChannel, methodName, ...args) as PromiseReturnType<MobileAppFunctions[T]>;\r\n }\r\n\r\n private static _isValid = false;\r\n public static get isValid() { return this._isValid; }\r\n /**\r\n * This is called by either AndroidApp.startup or IOSApp.startup - it should not be called directly\r\n * @internal\r\n */\r\n public static async startup(opts?: NativeAppOpts) {\r\n const iModelAppOpts = {\r\n ...opts?.iModelApp,\r\n };\r\n const authorizationClient = new MobileAuthorizationFrontend();\r\n iModelAppOpts.authorizationClient = authorizationClient;\r\n\r\n if (!this._isValid) {\r\n this.onAuthAccessTokenChanged.addListener((accessToken: string | undefined, expirationDate: string | undefined) => {\r\n authorizationClient.setAccessToken(accessToken, expirationDate);\r\n });\r\n\r\n const rpcInterfaces = opts?.iModelApp?.rpcInterfaces ?? [IModelReadRpcInterface, IModelTileRpcInterface];\r\n MobileRpcManager.initializeClient(rpcInterfaces);\r\n this._isValid = true;\r\n }\r\n\r\n const socket = new IpcWebSocketFrontend(); // needs work\r\n await NativeApp.startup(socket, { ...opts, iModelApp: iModelAppOpts });\r\n\r\n MobileAppNotifyHandler.register(); // receives notifications from backend\r\n }\r\n}\r\n"]}
1
+ {"version":3,"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AG,IAAI,sBAAO,EAAiF,CAAC;AAKvH,kBAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { AsyncMethodsOf, BeEvent, Logger, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport { IModelReadRpcInterface, IModelTileRpcInterface, IpcWebSocketFrontend } from \"@itwin/core-common\";\r\nimport { IModelAppOptions, IpcApp, NativeApp, NativeAppOpts, NotificationHandler } from \"@itwin/core-frontend\";\r\nimport { mobileAppChannel, mobileAppNotify } from \"../common/MobileAppChannel\";\r\nimport { MobileAppFunctions, MobileNotifications } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAuthorizationFrontend } from \"./MobileAuthorizationFrontend\";\r\n\r\n/** @beta */\r\nexport type MobileAppOpts = NativeAppOpts & { iModelApp: { authorizationClient?: never } };\r\n\r\n/** receive notifications from backend */\r\nclass MobileAppNotifyHandler extends NotificationHandler implements MobileNotifications {\r\n public get channelName() { return mobileAppNotify; }\r\n\r\n public notifyMemoryWarning() {\r\n Logger.logWarning(\"mobileApp\", \"Low memory warning\");\r\n if (MobileApp.onMemoryWarning.numberOfListeners === 0) {\r\n alert(\"Low memory warning\");\r\n }\r\n MobileApp.onMemoryWarning.raiseEvent();\r\n }\r\n public notifyOrientationChanged() { MobileApp.onOrientationChanged.raiseEvent(); }\r\n public notifyEnterForeground() { MobileApp.onEnterBackground.raiseEvent(); }\r\n public notifyEnterBackground() { MobileApp.onEnterBackground.raiseEvent(); }\r\n public notifyWillTerminate() { MobileApp.onWillTerminate.raiseEvent(); }\r\n public notifyAuthAccessTokenChanged(accessToken: string | undefined, expirationDate: string | undefined) {\r\n MobileApp.onAuthAccessTokenChanged.raiseEvent(accessToken, expirationDate);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport class MobileApp {\r\n public static onMemoryWarning = new BeEvent<() => void>();\r\n public static onOrientationChanged = new BeEvent<() => void>();\r\n public static onEnterForeground = new BeEvent<() => void>();\r\n public static onEnterBackground = new BeEvent<() => void>();\r\n public static onWillTerminate = new BeEvent<() => void>();\r\n public static onAuthAccessTokenChanged = new BeEvent<(accessToken: string | undefined, expirationDate: string | undefined) => void>();\r\n public static async callBackend<T extends AsyncMethodsOf<MobileAppFunctions>>(methodName: T, ...args: Parameters<MobileAppFunctions[T]>) {\r\n return IpcApp.callIpcChannel(mobileAppChannel, methodName, ...args) as PromiseReturnType<MobileAppFunctions[T]>;\r\n }\r\n\r\n private static _isValid = false;\r\n public static get isValid() { return this._isValid; }\r\n /** @beta */\r\n public static async startup(opts?: MobileAppOpts) {\r\n const iModelAppOpts: IModelAppOptions = {\r\n ...opts?.iModelApp,\r\n };\r\n const authorizationClient = new MobileAuthorizationFrontend();\r\n iModelAppOpts.authorizationClient = authorizationClient;\r\n\r\n if (!this._isValid) {\r\n this.onAuthAccessTokenChanged.addListener((accessToken: string | undefined, expirationDate: string | undefined) => {\r\n authorizationClient.setAccessToken(accessToken, expirationDate);\r\n });\r\n\r\n const rpcInterfaces = opts?.iModelApp?.rpcInterfaces ?? [IModelReadRpcInterface, IModelTileRpcInterface];\r\n MobileRpcManager.initializeClient(rpcInterfaces);\r\n this._isValid = true;\r\n }\r\n\r\n const socket = new IpcWebSocketFrontend(); // needs work\r\n await NativeApp.startup(socket, { ...opts, iModelApp: iModelAppOpts });\r\n\r\n MobileAppNotifyHandler.register(); // receives notifications from backend\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-mobile",
3
- "version": "3.3.0-dev.5",
3
+ "version": "3.3.0-dev.52",
4
4
  "description": "iTwin.js MobileHost and MobileApp",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -21,29 +21,29 @@
21
21
  "url": "http://www.bentley.com"
22
22
  },
23
23
  "peerDependencies": {
24
- "@itwin/core-backend": "^3.3.0-dev.5",
25
- "@itwin/core-bentley": "^3.3.0-dev.5",
26
- "@itwin/core-common": "^3.3.0-dev.5",
27
- "@itwin/core-frontend": "^3.3.0-dev.5",
28
- "@itwin/presentation-common": "^3.3.0-dev.5"
24
+ "@itwin/core-backend": "^3.3.0-dev.52",
25
+ "@itwin/core-bentley": "^3.3.0-dev.52",
26
+ "@itwin/core-common": "^3.3.0-dev.52",
27
+ "@itwin/core-frontend": "^3.3.0-dev.52",
28
+ "@itwin/presentation-common": "^3.3.0-dev.52"
29
29
  },
30
30
  "dependencies": {
31
31
  "deep-assign": "^2.0.0",
32
32
  "lodash": "^4.17.10",
33
33
  "js-base64": "^3.6.1",
34
34
  "qs": "^6.5.1",
35
- "superagent": "^7.0.1",
35
+ "superagent": "7.1.3",
36
36
  "ws": "^7.5.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@itwin/build-tools": "3.3.0-dev.5",
40
- "@itwin/core-backend": "3.3.0-dev.5",
41
- "@itwin/core-bentley": "3.3.0-dev.5",
42
- "@itwin/core-common": "3.3.0-dev.5",
43
- "@itwin/core-frontend": "3.3.0-dev.5",
44
- "@itwin/eslint-plugin": "3.3.0-dev.5",
45
- "@itwin/presentation-common": "3.3.0-dev.5",
46
- "@types/chai": "^4.1.4",
39
+ "@itwin/build-tools": "3.3.0-dev.52",
40
+ "@itwin/core-backend": "3.3.0-dev.52",
41
+ "@itwin/core-bentley": "3.3.0-dev.52",
42
+ "@itwin/core-common": "3.3.0-dev.52",
43
+ "@itwin/core-frontend": "3.3.0-dev.52",
44
+ "@itwin/eslint-plugin": "3.3.0-dev.52",
45
+ "@itwin/presentation-common": "3.3.0-dev.52",
46
+ "@types/chai": "4.3.1",
47
47
  "@types/deep-assign": "^0.1.0",
48
48
  "@types/fs-extra": "^4.0.7",
49
49
  "@types/lodash": "^4.14.0",
@@ -58,7 +58,7 @@
58
58
  "dotenv-expand": "^5.1.0",
59
59
  "eslint": "^7.11.0",
60
60
  "js-base64": "^3.6.1",
61
- "mocha": "^8.3.2",
61
+ "mocha": "^10.0.0",
62
62
  "rimraf": "^3.0.2",
63
63
  "typescript": "~4.4.0"
64
64
  },
@@ -1,11 +0,0 @@
1
- import { MobileHost, MobileHostOpts } from "./MobileHost";
2
- /** @beta */
3
- export declare type AndroidHostOpts = MobileHostOpts;
4
- /** @beta */
5
- export declare class AndroidHost extends MobileHost {
6
- /**
7
- * Start the backend of an Android app.
8
- */
9
- static startup(opt?: AndroidHostOpts): Promise<void>;
10
- }
11
- //# sourceMappingURL=AndroidHost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AndroidHost.d.ts","sourceRoot":"","sources":["../../../src/backend/AndroidHost.ts"],"names":[],"mappings":"AAMA,OAAO,EAAgB,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAExE,YAAY;AACZ,oBAAY,eAAe,GAAG,cAAc,CAAC;AAE7C,YAAY;AACZ,qBAAa,WAAY,SAAQ,UAAU;IACzC;;OAEG;WAC0B,OAAO,CAAC,GAAG,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAK3E"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.AndroidHost = void 0;
8
- const core_common_1 = require("@itwin/core-common");
9
- const MobileHost_1 = require("./MobileHost");
10
- /** @beta */
11
- class AndroidHost extends MobileHost_1.MobileHost {
12
- /**
13
- * Start the backend of an Android app.
14
- */
15
- static async startup(opt) {
16
- var _a, _b, _c, _d;
17
- const device = (_b = (_a = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _a === void 0 ? void 0 : _a.device) !== null && _b !== void 0 ? _b : new MobileHost_1.MobileDevice();
18
- const socket = (_d = (_c = opt === null || opt === void 0 ? void 0 : opt.ipcHost) === null || _c === void 0 ? void 0 : _c.socket) !== null && _d !== void 0 ? _d : new core_common_1.IpcWebSocketBackend();
19
- return MobileHost_1.MobileHost.startup({ ...opt, mobileHost: { ...opt === null || opt === void 0 ? void 0 : opt.mobileHost, device }, ipcHost: { ...opt === null || opt === void 0 ? void 0 : opt.ipcHost, socket } });
20
- }
21
- }
22
- exports.AndroidHost = AndroidHost;
23
- //# sourceMappingURL=AndroidHost.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AndroidHost.js","sourceRoot":"","sources":["../../../src/backend/AndroidHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAAyD;AACzD,6CAAwE;AAKxE,YAAY;AACZ,MAAa,WAAY,SAAQ,uBAAU;IACzC;;OAEG;IACI,MAAM,CAAU,KAAK,CAAC,OAAO,CAAC,GAAqB;;QACxD,MAAM,MAAM,GAAG,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,MAAM,mCAAI,IAAK,yBAAoB,EAAE,CAAC;QACtE,MAAM,MAAM,GAAG,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,0CAAE,MAAM,mCAAI,IAAI,iCAAmB,EAAE,CAAC;QACjE,OAAO,uBAAU,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,EAAE,UAAU,EAAE,EAAE,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1H,CAAC;CACF;AATD,kCASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { IpcWebSocketBackend } from \"@itwin/core-common\";\r\nimport { MobileDevice, MobileHost, MobileHostOpts } from \"./MobileHost\";\r\n\r\n/** @beta */\r\nexport type AndroidHostOpts = MobileHostOpts;\r\n\r\n/** @beta */\r\nexport class AndroidHost extends MobileHost {\r\n /**\r\n * Start the backend of an Android app.\r\n */\r\n public static override async startup(opt?: AndroidHostOpts): Promise<void> {\r\n const device = opt?.mobileHost?.device ?? new (MobileDevice as any)();\r\n const socket = opt?.ipcHost?.socket ?? new IpcWebSocketBackend();\r\n return MobileHost.startup({ ...opt, mobileHost: { ...opt?.mobileHost, device }, ipcHost: { ...opt?.ipcHost, socket } });\r\n }\r\n}\r\n"]}
@@ -1,11 +0,0 @@
1
- import { MobileHost, MobileHostOpts } from "./MobileHost";
2
- /** @beta */
3
- export declare type IOSHostOpts = MobileHostOpts;
4
- /** @beta */
5
- export declare class IOSHost extends MobileHost {
6
- /**
7
- * Start the backend of an IOS app.
8
- */
9
- static startup(opt?: IOSHostOpts): Promise<void>;
10
- }
11
- //# sourceMappingURL=iOSHost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iOSHost.d.ts","sourceRoot":"","sources":["../../../src/backend/iOSHost.ts"],"names":[],"mappings":"AAMA,OAAO,EAAgB,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAExE,YAAY;AACZ,oBAAY,WAAW,GAAG,cAAc,CAAC;AAEzC,YAAY;AACZ,qBAAa,OAAQ,SAAQ,UAAU;IACrC;;OAEG;WAC0B,OAAO,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAKvE"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.IOSHost = void 0;
8
- const core_common_1 = require("@itwin/core-common");
9
- const MobileHost_1 = require("./MobileHost");
10
- /** @beta */
11
- class IOSHost extends MobileHost_1.MobileHost {
12
- /**
13
- * Start the backend of an IOS app.
14
- */
15
- static async startup(opt) {
16
- var _a, _b, _c, _d;
17
- const device = (_b = (_a = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _a === void 0 ? void 0 : _a.device) !== null && _b !== void 0 ? _b : new MobileHost_1.MobileDevice();
18
- const socket = (_d = (_c = opt === null || opt === void 0 ? void 0 : opt.ipcHost) === null || _c === void 0 ? void 0 : _c.socket) !== null && _d !== void 0 ? _d : new core_common_1.IpcWebSocketBackend();
19
- return MobileHost_1.MobileHost.startup({ ...opt, mobileHost: { ...opt === null || opt === void 0 ? void 0 : opt.mobileHost, device }, ipcHost: { ...opt === null || opt === void 0 ? void 0 : opt.ipcHost, socket } });
20
- }
21
- }
22
- exports.IOSHost = IOSHost;
23
- //# sourceMappingURL=iOSHost.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iOSHost.js","sourceRoot":"","sources":["../../../src/backend/iOSHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAAyD;AACzD,6CAAwE;AAKxE,YAAY;AACZ,MAAa,OAAQ,SAAQ,uBAAU;IACrC;;OAEG;IACI,MAAM,CAAU,KAAK,CAAC,OAAO,CAAC,GAAiB;;QACpD,MAAM,MAAM,GAAG,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,MAAM,mCAAI,IAAK,yBAAoB,EAAE,CAAC;QACtE,MAAM,MAAM,GAAG,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,0CAAE,MAAM,mCAAI,IAAI,iCAAmB,EAAE,CAAC;QACjE,OAAO,uBAAU,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,EAAE,UAAU,EAAE,EAAE,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1H,CAAC;CACF;AATD,0BASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { IpcWebSocketBackend } from \"@itwin/core-common\";\r\nimport { MobileDevice, MobileHost, MobileHostOpts } from \"./MobileHost\";\r\n\r\n/** @beta */\r\nexport type IOSHostOpts = MobileHostOpts;\r\n\r\n/** @beta */\r\nexport class IOSHost extends MobileHost {\r\n /**\r\n * Start the backend of an IOS app.\r\n */\r\n public static override async startup(opt?: IOSHostOpts): Promise<void> {\r\n const device = opt?.mobileHost?.device ?? new (MobileDevice as any)();\r\n const socket = opt?.ipcHost?.socket ?? new IpcWebSocketBackend();\r\n return MobileHost.startup({ ...opt, mobileHost: { ...opt?.mobileHost, device }, ipcHost: { ...opt?.ipcHost, socket } });\r\n }\r\n}\r\n"]}
@@ -1,14 +0,0 @@
1
- import { RpcInterfaceDefinition } from "@itwin/core-common";
2
- import { IModelAppOptions } from "@itwin/core-frontend";
3
- /** @beta */
4
- export declare class AndroidApp {
5
- private static _isValid;
6
- static get isValid(): boolean;
7
- static startup(opts?: {
8
- mobileApp?: {
9
- rpcInterfaces?: RpcInterfaceDefinition[];
10
- };
11
- iModelApp?: IModelAppOptions;
12
- }): Promise<void>;
13
- }
14
- //# sourceMappingURL=AndroidApp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AndroidApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/AndroidApp.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,YAAY;AACZ,qBAAa,UAAU;IAErB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,WAAkB,OAAO,YAA4B;WACjC,OAAO,CAAC,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE;YAAE,aAAa,CAAC,EAAE,sBAAsB,EAAE,CAAA;SAAE,CAAC;QAAC,SAAS,CAAC,EAAE,gBAAgB,CAAA;KAAE;CAM9H"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AndroidApp = void 0;
4
- const MobileApp_1 = require("./MobileApp");
5
- /** @beta */
6
- class AndroidApp {
7
- static get isValid() { return this._isValid; }
8
- static async startup(opts) {
9
- if (!this._isValid) {
10
- this._isValid = true;
11
- }
12
- await MobileApp_1.MobileApp.startup(opts);
13
- }
14
- }
15
- exports.AndroidApp = AndroidApp;
16
- AndroidApp._isValid = false;
17
- //# sourceMappingURL=AndroidApp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AndroidApp.js","sourceRoot":"","sources":["../../../src/frontend/AndroidApp.ts"],"names":[],"mappings":";;;AAMA,2CAAwC;AAExC,YAAY;AACZ,MAAa,UAAU;IAGd,MAAM,KAAK,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAiG;QAC3H,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;QACD,MAAM,qBAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;;AATH,gCAUC;AARgB,mBAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { RpcInterfaceDefinition } from \"@itwin/core-common\";\r\nimport { IModelAppOptions } from \"@itwin/core-frontend\";\r\nimport { MobileApp } from \"./MobileApp\";\r\n\r\n/** @beta */\r\nexport class AndroidApp {\r\n\r\n private static _isValid = false;\r\n public static get isValid() { return this._isValid; }\r\n public static async startup(opts?: { mobileApp?: { rpcInterfaces?: RpcInterfaceDefinition[] }, iModelApp?: IModelAppOptions }) {\r\n if (!this._isValid) {\r\n this._isValid = true;\r\n }\r\n await MobileApp.startup(opts);\r\n }\r\n}\r\n"]}
@@ -1,14 +0,0 @@
1
- import { NativeAppOpts } from "@itwin/core-frontend";
2
- /** @beta */
3
- export declare type IOSAppOpts = NativeAppOpts & {
4
- iModelApp: {
5
- authorizationClient?: never;
6
- };
7
- };
8
- /** @beta */
9
- export declare class IOSApp {
10
- private static _isValid;
11
- static get isValid(): boolean;
12
- static startup(opts?: IOSAppOpts): Promise<void>;
13
- }
14
- //# sourceMappingURL=IOSApp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOSApp.d.ts","sourceRoot":"","sources":["../../../src/frontend/IOSApp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,YAAY;AACZ,oBAAY,UAAU,GAAG,aAAa,GAAG;IAAE,SAAS,EAAE;QAAE,mBAAmB,CAAC,EAAE,KAAK,CAAA;KAAE,CAAA;CAAE,CAAC;AAExF,YAAY;AACZ,qBAAa,MAAM;IAEjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,WAAkB,OAAO,YAA4B;WACjC,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU;CAM9C"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.IOSApp = void 0;
8
- const MobileApp_1 = require("./MobileApp");
9
- /** @beta */
10
- class IOSApp {
11
- static get isValid() { return this._isValid; }
12
- static async startup(opts) {
13
- if (!this._isValid) {
14
- this._isValid = true;
15
- }
16
- await MobileApp_1.MobileApp.startup(opts);
17
- }
18
- }
19
- exports.IOSApp = IOSApp;
20
- IOSApp._isValid = false;
21
- //# sourceMappingURL=IOSApp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IOSApp.js","sourceRoot":"","sources":["../../../src/frontend/IOSApp.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,2CAAwC;AAKxC,YAAY;AACZ,MAAa,MAAM;IAGV,MAAM,KAAK,OAAO,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;QACD,MAAM,qBAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;;AATH,wBAUC;AARgB,eAAQ,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { NativeAppOpts } from \"@itwin/core-frontend\";\r\nimport { MobileApp } from \"./MobileApp\";\r\n\r\n/** @beta */\r\nexport type IOSAppOpts = NativeAppOpts & { iModelApp: { authorizationClient?: never } };\r\n\r\n/** @beta */\r\nexport class IOSApp {\r\n\r\n private static _isValid = false;\r\n public static get isValid() { return this._isValid; }\r\n public static async startup(opts?: IOSAppOpts) {\r\n if (!this._isValid) {\r\n this._isValid = true;\r\n }\r\n await MobileApp.startup(opts);\r\n }\r\n}\r\n"]}