@itwin/core-mobile 3.1.0-dev.0 → 3.1.0-dev.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.
Files changed (37) hide show
  1. package/lib/cjs/MobileBackend.d.ts +5 -2
  2. package/lib/cjs/MobileBackend.d.ts.map +1 -1
  3. package/lib/cjs/MobileBackend.js +5 -2
  4. package/lib/cjs/MobileBackend.js.map +1 -1
  5. package/lib/cjs/MobileFrontend.d.ts +4 -1
  6. package/lib/cjs/MobileFrontend.d.ts.map +1 -1
  7. package/lib/cjs/MobileFrontend.js +4 -1
  8. package/lib/cjs/MobileFrontend.js.map +1 -1
  9. package/lib/cjs/__DOC_ONLY__.d.ts +2 -8
  10. package/lib/cjs/__DOC_ONLY__.d.ts.map +1 -1
  11. package/lib/cjs/__DOC_ONLY__.js +2 -8
  12. package/lib/cjs/__DOC_ONLY__.js.map +1 -1
  13. package/lib/cjs/backend/MobileAuthorizationBackend.d.ts +1 -1
  14. package/lib/cjs/backend/MobileAuthorizationBackend.d.ts.map +1 -1
  15. package/lib/cjs/backend/MobileAuthorizationBackend.js +1 -1
  16. package/lib/cjs/backend/MobileAuthorizationBackend.js.map +1 -1
  17. package/lib/cjs/backend/MobileHost.d.ts +2 -6
  18. package/lib/cjs/backend/MobileHost.d.ts.map +1 -1
  19. package/lib/cjs/backend/MobileHost.js +3 -12
  20. package/lib/cjs/backend/MobileHost.js.map +1 -1
  21. package/lib/cjs/backend/MobileRpcServer.d.ts +1 -0
  22. package/lib/cjs/backend/MobileRpcServer.d.ts.map +1 -1
  23. package/lib/cjs/backend/MobileRpcServer.js +2 -1
  24. package/lib/cjs/backend/MobileRpcServer.js.map +1 -1
  25. package/lib/cjs/common/MobileAppChannel.d.ts +5 -0
  26. package/lib/cjs/common/MobileAppChannel.d.ts.map +1 -0
  27. package/lib/cjs/common/MobileAppChannel.js +12 -0
  28. package/lib/cjs/common/MobileAppChannel.js.map +1 -0
  29. package/lib/cjs/common/MobileAppProps.d.ts +5 -5
  30. package/lib/cjs/common/MobileAppProps.d.ts.map +1 -1
  31. package/lib/cjs/common/MobileAppProps.js +3 -5
  32. package/lib/cjs/common/MobileAppProps.js.map +1 -1
  33. package/lib/cjs/frontend/MobileApp.d.ts +1 -1
  34. package/lib/cjs/frontend/MobileApp.d.ts.map +1 -1
  35. package/lib/cjs/frontend/MobileApp.js +4 -4
  36. package/lib/cjs/frontend/MobileApp.js.map +1 -1
  37. package/package.json +13 -13
@@ -1,7 +1,10 @@
1
1
  export * from "./backend/AndroidHost";
2
2
  export * from "./backend/iOSHost";
3
- export * from "./backend/MobileHost";
4
3
  export * from "./backend/MobileAuthorizationBackend";
5
- export * from "./common/MobileRpcManager";
6
4
  export * from "./backend/MobileFileHandler";
5
+ export * from "./backend/MobileHost";
6
+ export * from "./common/MobileAppProps";
7
+ export * from "./common/MobileRpcManager";
8
+ export * from "./common/MobileRpcProtocol";
9
+ export * from "./common/MobileRpcRequest";
7
10
  //# sourceMappingURL=MobileBackend.d.ts.map
@@ -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,sBAAsB,CAAC;AACrC,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC"}
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"}
@@ -17,8 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // Barrel file for backend of a mobile application
18
18
  __exportStar(require("./backend/AndroidHost"), exports);
19
19
  __exportStar(require("./backend/iOSHost"), exports);
20
- __exportStar(require("./backend/MobileHost"), exports);
21
20
  __exportStar(require("./backend/MobileAuthorizationBackend"), exports);
22
- __exportStar(require("./common/MobileRpcManager"), exports);
23
21
  __exportStar(require("./backend/MobileFileHandler"), exports);
22
+ __exportStar(require("./backend/MobileHost"), exports);
23
+ __exportStar(require("./common/MobileAppProps"), exports);
24
+ __exportStar(require("./common/MobileRpcManager"), exports);
25
+ __exportStar(require("./common/MobileRpcProtocol"), exports);
26
+ __exportStar(require("./common/MobileRpcRequest"), exports);
24
27
  //# sourceMappingURL=MobileBackend.js.map
@@ -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,uDAAqC;AACrC,uEAAqD;AACrD,4DAA0C;AAC1C,8DAA4C","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/MobileHost\";\r\nexport * from \"./backend/MobileAuthorizationBackend\";\r\nexport * from \"./common/MobileRpcManager\";\r\nexport * from \"./backend/MobileFileHandler\";\r\n\r\n"]}
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,5 +1,8 @@
1
+ export * from "./common/MobileAppProps";
2
+ export * from "./common/MobileRpcManager";
3
+ export * from "./common/MobileRpcProtocol";
4
+ export * from "./common/MobileRpcRequest";
1
5
  export * from "./frontend/AndroidApp";
2
6
  export * from "./frontend/IOSApp";
3
7
  export * from "./frontend/MobileApp";
4
- export * from "./common/MobileRpcManager";
5
8
  //# sourceMappingURL=MobileFrontend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileFrontend.d.ts","sourceRoot":"","sources":["../../src/MobileFrontend.ts"],"names":[],"mappings":"AAKA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,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,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common/MobileAppProps"), exports);
18
+ __exportStar(require("./common/MobileRpcManager"), exports);
19
+ __exportStar(require("./common/MobileRpcProtocol"), exports);
20
+ __exportStar(require("./common/MobileRpcRequest"), exports);
17
21
  __exportStar(require("./frontend/AndroidApp"), exports);
18
22
  __exportStar(require("./frontend/IOSApp"), exports);
19
23
  __exportStar(require("./frontend/MobileApp"), exports);
20
- __exportStar(require("./common/MobileRpcManager"), exports);
21
24
  //# sourceMappingURL=MobileFrontend.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileFrontend.js","sourceRoot":"","sources":["../../src/MobileFrontend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;AAE/F,wDAAsC;AACtC,oDAAkC;AAClC,uDAAqC;AACrC,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\nexport * from \"./frontend/AndroidApp\";\r\nexport * from \"./frontend/IOSApp\";\r\nexport * from \"./frontend/MobileApp\";\r\nexport * from \"./common/MobileRpcManager\";\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,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,9 +1,3 @@
1
- export * from "./frontend/AndroidApp";
2
- export * from "./frontend/IOSApp";
3
- export * from "./frontend/MobileApp";
4
- export * from "./common/MobileRpcManager";
5
- export * from "./backend/AndroidHost";
6
- export * from "./backend/iOSHost";
7
- export * from "./backend/MobileHost";
8
- export * from "./common/MobileRpcManager";
1
+ export * from "./MobileBackend";
2
+ export * from "./MobileFrontend";
9
3
  //# 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,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,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"}
@@ -17,12 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // THIS FILE EXISTS ONLY FOR DOCUMENTATION GENERATION.
18
18
  // It imports both frontend and backend code, which is not legal anywhere.
19
19
  // Do not import it in real code!
20
- __exportStar(require("./frontend/AndroidApp"), exports);
21
- __exportStar(require("./frontend/IOSApp"), exports);
22
- __exportStar(require("./frontend/MobileApp"), exports);
23
- __exportStar(require("./common/MobileRpcManager"), exports);
24
- __exportStar(require("./backend/AndroidHost"), exports);
25
- __exportStar(require("./backend/iOSHost"), exports);
26
- __exportStar(require("./backend/MobileHost"), exports);
27
- __exportStar(require("./common/MobileRpcManager"), exports);
20
+ __exportStar(require("./MobileBackend"), exports);
21
+ __exportStar(require("./MobileFrontend"), exports);
28
22
  //# 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,wDAAsC;AACtC,oDAAkC;AAClC,uDAAqC;AACrC,4DAA0C;AAC1C,wDAAsC;AACtC,oDAAkC;AAClC,uDAAqC;AACrC,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// 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 \"./frontend/AndroidApp\";\r\nexport * from \"./frontend/IOSApp\";\r\nexport * from \"./frontend/MobileApp\";\r\nexport * from \"./common/MobileRpcManager\";\r\nexport * from \"./backend/AndroidHost\";\r\nexport * from \"./backend/iOSHost\";\r\nexport * from \"./backend/MobileHost\";\r\nexport * from \"./common/MobileRpcManager\";\r\n\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","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"]}
@@ -30,7 +30,7 @@ export interface MobileAppAuthorizationConfiguration {
30
30
  readonly expiryBuffer?: number;
31
31
  }
32
32
  /** Utility to provide OIDC/OAuth tokens from native ios app to frontend
33
- * @internal
33
+ * @beta
34
34
  */
35
35
  export declare class MobileAuthorizationBackend implements AuthorizationClient {
36
36
  protected _accessToken?: AccessToken;
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAuthorizationBackend.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAsB,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAe,MAAM,oBAAoB,CAAC;AAGtE;;;GAGG;AACH,MAAM,WAAW,mCAAmC;IAClD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IACpE,SAAS,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC;IAC9B,MAAM,CAAC,EAAE,mCAAmC,CAAC;IAC7C,YAAY,SAAW;IACvB,SAAS,CA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AC,EAAE,WAAW,CAAC;IAC9B,MAAM,CAAC,EAAE,mCAAmC,CAAC;IAC7C,YAAY,SAAW;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAc,kBAAkB,SAAoC;IACpE,IAAW,WAAW,WAAwF;IAC9G,SAAS,CAAC,QAAQ,SAA6B;IAC/C,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEL,MAAM,CAAC,EAAE,mCAAmC;IAI/D,0FAA0F;IAC7E,UAAU,CAAC,MAAM,CAAC,EAAE,mCAAmC,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BpF,gCAAgC;IACnB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAYpC,iCAAiC;IACpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAY9B,cAAc,CAAC,KAAK,CAAC,EAAE,WAAW;IAM5B,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAMnD,yBAAyB;IACZ,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;IAYjD;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM;CAiBf"}
@@ -12,7 +12,7 @@ const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_common_1 = require("@itwin/core-common");
13
13
  const MobileHost_1 = require("./MobileHost");
14
14
  /** Utility to provide OIDC/OAuth tokens from native ios app to frontend
15
- * @internal
15
+ * @beta
16
16
  */
17
17
  class MobileAuthorizationBackend {
18
18
  constructor(config) {
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAuthorizationBackend.js","sourceRoot":"","sources":["../../../src/backend/MobileAuthorizationBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAsE;AACtE,oDAAsE;AACtE,6CAA0C;AAiC1C;;GAEG;AACH,MAAa,0BAA0B;IAUrC,YAAmB,MAA4C;QAPxD,iBAAY,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,uDAAuD;QAI5E,aAAQ,GAAG,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AAyB;IAClB,KAAK,CAAC,YAAY;QACvB,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClD,uBAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,eAA6B,EAAE,GAAY,EAAE,EAAE;gBACnF,IAAI,CAAC,GAAG,IAAI,eAAe,EAAE;oBAC3B,OAAO,CAAC,eAAe,CAAC,CAAC;iBAC1B;qBAAM;oBACL,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;iBACxB;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD;;;;;;;OAOG;IACK,MAAM;;QACZ,IAAI,IAAI,CAAC,IAAI;YACX,OAAO,IAAI,CAAC,IAAI,CAAC;QAEnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAC3C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,mCAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEnE,IAAI,MAAM,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,CAAA;YACnC,SAAS,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;;AAnHH,gEAoHC;AA/Ge,6CAAkB,GAAG,gCAAgC,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/** @packageDocumentation\r\n * @module OIDC\r\n */\r\n\r\nimport { AccessToken, assert, AuthStatus } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient, IModelError } from \"@itwin/core-common\";\r\nimport { MobileHost } from \"./MobileHost\";\r\n\r\n/**\r\n * Client configuration to generate OIDC/OAuth tokens for mobile applications\r\n * @beta\r\n */\r\nexport interface MobileAppAuthorizationConfiguration {\r\n /**\r\n * The OAuth token issuer URL. Defaults to Bentley's auth URL if undefined.\r\n */\r\n issuerUrl?: string;\r\n\r\n /**\r\n * Upon signing in, the client application receives a response from the Bentley IMS OIDC/OAuth2 provider at this URI\r\n * For mobile/desktop applications, must start with `http://localhost:${redirectPort}` or `https://localhost:${redirectPort}`\r\n */\r\n readonly redirectUri?: string;\r\n\r\n /** Client application's identifier as registered with the OIDC/OAuth2 provider. */\r\n readonly clientId: string;\r\n\r\n /** List of space separated scopes to request access to various resources. */\r\n readonly scope: string;\r\n\r\n /**\r\n * Time in seconds that's used as a buffer to check the token for validity/expiry.\r\n * The checks for authorization, and refreshing access tokens all use this buffer - i.e., the token is considered expired if the current time is within the specified\r\n * time of the actual expiry.\r\n * @note If unspecified this defaults to 10 minutes.\r\n */\r\n readonly expiryBuffer?: number;\r\n}\r\n\r\n/** Utility to provide OIDC/OAuth tokens from native ios app to frontend\r\n * @internal\r\n */\r\nexport class MobileAuthorizationBackend implements AuthorizationClient {\r\n protected _accessToken?: AccessToken;\r\n public config?: MobileAppAuthorizationConfiguration;\r\n public expireSafety = 60 * 10; // refresh token 10 minutes before real expiration time\r\n public issuerUrl?: string;\r\n public static defaultRedirectUri = \"imodeljs://app/signin-callback\";\r\n public get redirectUri() { return this.config?.redirectUri ?? MobileAuthorizationBackend.defaultRedirectUri; }\r\n protected _baseUrl = \"https://ims.bentley.com\";\r\n protected _url?: string;\r\n\r\n public constructor(config?: MobileAppAuthorizationConfiguration) {\r\n this.config = config;\r\n }\r\n\r\n /** Used to initialize the client - must be awaited before any other methods are called */\r\n public async initialize(config?: MobileAppAuthorizationConfiguration): Promise<void> {\r\n this.config = config ?? this.config;\r\n if (!this.config)\r\n throw new IModelError(AuthStatus.Error, \"Must specify a valid configuration when initializing authorization\");\r\n if (this.config.expiryBuffer)\r\n this.expireSafety = this.config.expiryBuffer;\r\n this.issuerUrl = this.config.issuerUrl ?? this.getUrl();\r\n if (!this.issuerUrl)\r\n throw new IModelError(AuthStatus.Error, \"The URL of the authorization provider was not initialized\");\r\n\r\n MobileHost.device.authStateChanged = (tokenString?: AccessToken) => {\r\n this.setAccessToken(tokenString);\r\n };\r\n\r\n return new Promise<void>((resolve, reject) => {\r\n assert(this.config !== undefined);\r\n MobileHost.device.authInit({ ...this.config, issuerUrl: this.issuerUrl }, (err?: string) => {\r\n if (!err) {\r\n resolve();\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n\r\n /** Start the sign-in process */\r\n public async signIn(): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n MobileHost.device.authSignIn((err?: string) => {\r\n if (!err) {\r\n resolve();\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n\r\n /** Start the sign-out process */\r\n public async signOut(): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n MobileHost.device.authSignOut((err?: string) => {\r\n if (!err) {\r\n resolve();\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n\r\n public setAccessToken(token?: AccessToken) {\r\n if (token === this._accessToken)\r\n return;\r\n this._accessToken = token;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (!this._accessToken)\r\n this.setAccessToken(await this.refreshToken());\r\n return this._accessToken ?? \"\";\r\n }\r\n\r\n /** return accessToken */\r\n public async refreshToken(): Promise<AccessToken> {\r\n return new Promise<AccessToken>((resolve, reject) => {\r\n MobileHost.device.authGetAccessToken((tokenStringJson?: AccessToken, err?: string) => {\r\n if (!err && tokenStringJson) {\r\n resolve(tokenStringJson);\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n /**\r\n * Gets the URL of the service. Uses the default URL provided by client implementations.\r\n * If defined, the value of `IMJS_URL_PREFIX` will be used as a prefix to all urls provided\r\n * by the client implementations.\r\n *\r\n * Note that for consistency sake, the URL is stripped of any trailing \"/\".\r\n * @returns URL for the service\r\n */\r\n private getUrl(): string {\r\n if (this._url)\r\n return this._url;\r\n\r\n if (!this._baseUrl) {\r\n throw new Error(\"The client is missing a default url.\");\r\n }\r\n\r\n const prefix = process.env.IMJS_URL_PREFIX;\r\n const authority = new URL(this.config?.issuerUrl ?? this._baseUrl);\r\n\r\n if (prefix && !this.config?.issuerUrl)\r\n authority.hostname = prefix + authority.hostname;\r\n this._url = authority.href.replace(/\\/$/, \"\");\r\n\r\n return this._url;\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;;;AAEH,sDAAsE;AACtE,oDAAsE;AACtE,6CAA0C;AAiC1C;;GAEG;AACH,MAAa,0BAA0B;IAUrC,YAAmB,MAA4C;QAPxD,iBAAY,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,uDAAuD;QAI5E,aAAQ,GAAG,yBAAyB,CAAC;QAI7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAND,IAAW,WAAW,iBAAK,OAAO,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,WAAW,mCAAI,0BAA0B,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAQ9G,0FAA0F;IACnF,KAAK,CAAC,UAAU,CAAC,MAA4C;;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,IAAI,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,MAA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,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACK,MAAM;;QACZ,IAAI,IAAI,CAAC,IAAI;YACX,OAAO,IAAI,CAAC,IAAI,CAAC;QAEnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAC3C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,mCAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEnE,IAAI,MAAM,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,CAAA;YACnC,SAAS,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;;AApHH,gEAqHC;AAhHe,6CAAkB,GAAG,gCAAgC,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/** @packageDocumentation\r\n * @module OIDC\r\n */\r\n\r\nimport { AccessToken, assert, AuthStatus } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient, IModelError } from \"@itwin/core-common\";\r\nimport { MobileHost } from \"./MobileHost\";\r\n\r\n/**\r\n * Client configuration to generate OIDC/OAuth tokens for mobile applications\r\n * @beta\r\n */\r\nexport interface MobileAppAuthorizationConfiguration {\r\n /**\r\n * The OAuth token issuer URL. Defaults to Bentley's auth URL if undefined.\r\n */\r\n issuerUrl?: string;\r\n\r\n /**\r\n * Upon signing in, the client application receives a response from the Bentley IMS OIDC/OAuth2 provider at this URI\r\n * For mobile/desktop applications, must start with `http://localhost:${redirectPort}` or `https://localhost:${redirectPort}`\r\n */\r\n readonly redirectUri?: string;\r\n\r\n /** Client application's identifier as registered with the OIDC/OAuth2 provider. */\r\n readonly clientId: string;\r\n\r\n /** List of space separated scopes to request access to various resources. */\r\n readonly scope: string;\r\n\r\n /**\r\n * Time in seconds that's used as a buffer to check the token for validity/expiry.\r\n * The checks for authorization, and refreshing access tokens all use this buffer - i.e., the token is considered expired if the current time is within the specified\r\n * time of the actual expiry.\r\n * @note If unspecified this defaults to 10 minutes.\r\n */\r\n readonly expiryBuffer?: number;\r\n}\r\n\r\n/** Utility to provide OIDC/OAuth tokens from native ios app to frontend\r\n * @beta\r\n */\r\nexport class MobileAuthorizationBackend implements AuthorizationClient {\r\n protected _accessToken?: AccessToken;\r\n public config?: MobileAppAuthorizationConfiguration;\r\n public expireSafety = 60 * 10; // refresh token 10 minutes before real expiration time\r\n public issuerUrl?: string;\r\n public static defaultRedirectUri = \"imodeljs://app/signin-callback\";\r\n public get redirectUri() { return this.config?.redirectUri ?? MobileAuthorizationBackend.defaultRedirectUri; }\r\n protected _baseUrl = \"https://ims.bentley.com\";\r\n protected _url?: string;\r\n\r\n public constructor(config?: MobileAppAuthorizationConfiguration) {\r\n this.config = config;\r\n }\r\n\r\n /** Used to initialize the client - must be awaited before any other methods are called */\r\n public async initialize(config?: MobileAppAuthorizationConfiguration): Promise<void> {\r\n this.config = config ?? this.config;\r\n if (!this.config)\r\n throw new IModelError(AuthStatus.Error, \"Must specify a valid configuration when initializing authorization\");\r\n if (this.config.expiryBuffer)\r\n this.expireSafety = this.config.expiryBuffer;\r\n this.issuerUrl = this.config.issuerUrl ?? this.getUrl();\r\n if (!this.issuerUrl)\r\n throw new IModelError(AuthStatus.Error, \"The URL of the authorization provider was not initialized\");\r\n\r\n MobileHost.device.authStateChanged = (tokenString?: AccessToken) => {\r\n this.setAccessToken(tokenString);\r\n };\r\n\r\n return new Promise<void>((resolve, reject) => {\r\n assert(this.config !== undefined);\r\n MobileHost.device.authInit({ ...this.config, issuerUrl: this.issuerUrl }, (err?: string) => {\r\n if (!err) {\r\n resolve();\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n\r\n /** Start the sign-in process */\r\n public async signIn(): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n MobileHost.device.authSignIn((err?: string) => {\r\n if (!err) {\r\n resolve();\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n\r\n /** Start the sign-out process */\r\n public async signOut(): Promise<void> {\r\n return new Promise<void>((resolve, reject) => {\r\n MobileHost.device.authSignOut((err?: string) => {\r\n if (!err) {\r\n resolve();\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n\r\n public setAccessToken(token?: AccessToken) {\r\n if (token === this._accessToken)\r\n return;\r\n this._accessToken = token;\r\n }\r\n\r\n public async getAccessToken(): Promise<AccessToken> {\r\n if (!this._accessToken)\r\n this.setAccessToken(await this.refreshToken());\r\n return this._accessToken ?? \"\";\r\n }\r\n\r\n /** return accessToken */\r\n public async refreshToken(): Promise<AccessToken> {\r\n return new Promise<AccessToken>((resolve, reject) => {\r\n MobileHost.device.authGetAccessToken((tokenStringJson?: AccessToken, err?: string) => {\r\n if (!err && tokenStringJson) {\r\n resolve(tokenStringJson);\r\n } else {\r\n reject(new Error(err));\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Gets the URL of the service. Uses the default URL provided by client implementations.\r\n * If defined, the value of `IMJS_URL_PREFIX` will be used as a prefix to all urls provided\r\n * by the client implementations.\r\n *\r\n * Note that for consistency sake, the URL is stripped of any trailing \"/\".\r\n * @returns URL for the service\r\n */\r\n private getUrl(): string {\r\n if (this._url)\r\n return this._url;\r\n\r\n if (!this._baseUrl) {\r\n throw new Error(\"The client is missing a default url.\");\r\n }\r\n\r\n const prefix = process.env.IMJS_URL_PREFIX;\r\n const authority = new URL(this.config?.issuerUrl ?? this._baseUrl);\r\n\r\n if (prefix && !this.config?.issuerUrl)\r\n authority.hostname = prefix + authority.hostname;\r\n this._url = authority.href.replace(/\\/$/, \"\");\r\n\r\n return this._url;\r\n }\r\n}\r\n"]}
@@ -4,7 +4,7 @@ import { RpcInterfaceDefinition } from "@itwin/core-common";
4
4
  import { CancelRequest } from "./MobileFileHandler";
5
5
  import { ProgressCallback } from "./Request";
6
6
  import { BatteryState, DeviceEvents, Orientation } from "../common/MobileAppProps";
7
- import { MobileAppAuthorizationConfiguration, MobileAuthorizationBackend } from "./MobileAuthorizationBackend";
7
+ import { MobileAppAuthorizationConfiguration } from "./MobileAuthorizationBackend";
8
8
  /** @beta */
9
9
  export declare type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;
10
10
  /** @beta */
@@ -49,10 +49,8 @@ export interface MobileHostOpts extends NativeHostOpts {
49
49
  device?: MobileDevice;
50
50
  /** list of RPC interface definitions to register */
51
51
  rpcInterfaces?: RpcInterfaceDefinition[];
52
- /** if present, [[NativeHost.authorizationClient]] will be set to an instance of MobileAppAuthorizationConfiguration and will be initialized. */
52
+ /** if present, [[IModelHost.authorizationClient]] will be set to an instance of [[MobileAuthorizationBackend]]. */
53
53
  authConfig?: MobileAppAuthorizationConfiguration;
54
- /** if true, do not attempt to initialize AuthorizationClient on startup */
55
- noInitializeAuthClient?: boolean;
56
54
  };
57
55
  }
58
56
  /**
@@ -66,8 +64,6 @@ export declare class MobileHost {
66
64
  static readonly onEnterForeground: BeEvent<import("@itwin/core-bentley").Listener>;
67
65
  static readonly onEnterBackground: BeEvent<import("@itwin/core-bentley").Listener>;
68
66
  static readonly onWillTerminate: BeEvent<import("@itwin/core-bentley").Listener>;
69
- /** @internal */
70
- static get authorization(): MobileAuthorizationBackend;
71
67
  /** @internal */
72
68
  static reconnect(connection: number): void;
73
69
  /** @internal */
@@ -1 +1 @@
1
- {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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;CAsBjE"}
@@ -10,9 +10,8 @@ const core_backend_1 = require("@itwin/core-backend");
10
10
  const core_common_1 = require("@itwin/core-common");
11
11
  const MobileFileHandler_1 = require("./MobileFileHandler");
12
12
  const presentation_common_1 = require("@itwin/presentation-common");
13
- const MobileAppProps_1 = require("../common/MobileAppProps");
13
+ const MobileAppChannel_1 = require("../common/MobileAppChannel");
14
14
  const MobileRpcManager_1 = require("../common/MobileRpcManager");
15
- const MobileAuthorizationBackend_1 = require("./MobileAuthorizationBackend");
16
15
  const MobileRpcServer_1 = require("./MobileRpcServer");
17
16
  /** @beta */
18
17
  class MobileDevice {
@@ -39,7 +38,7 @@ class MobileDevice {
39
38
  }
40
39
  exports.MobileDevice = MobileDevice;
41
40
  class MobileAppHandler extends core_backend_1.IpcHandler {
42
- get channelName() { return MobileAppProps_1.mobileAppChannel; }
41
+ get channelName() { return MobileAppChannel_1.mobileAppChannel; }
43
42
  async reconnect(connection) {
44
43
  MobileHost.reconnect(connection);
45
44
  }
@@ -49,8 +48,6 @@ class MobileAppHandler extends core_backend_1.IpcHandler {
49
48
  */
50
49
  class MobileHost {
51
50
  static get device() { return this._device; }
52
- /** @internal */
53
- static get authorization() { return core_backend_1.IModelHost.authorizationClient; }
54
51
  /** @internal */
55
52
  static reconnect(connection) {
56
53
  this.device.reconnect(connection);
@@ -91,7 +88,7 @@ class MobileHost {
91
88
  static get isValid() { return undefined !== this._device; }
92
89
  /** Start the backend of a mobile app. */
93
90
  static async startup(opt) {
94
- var _a, _b, _c, _d, _e, _f, _g, _h;
91
+ var _a, _b, _c, _d;
95
92
  if (!this.isValid) {
96
93
  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();
97
94
  // set global device interface.
@@ -109,12 +106,6 @@ class MobileHost {
109
106
  presentation_common_1.PresentationRpcInterface,
110
107
  ];
111
108
  MobileRpcManager_1.MobileRpcManager.initializeImpl(rpcInterfaces);
112
- const authorizationBackend = new MobileAuthorizationBackend_1.MobileAuthorizationBackend((_e = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _e === void 0 ? void 0 : _e.authConfig);
113
- const connectivityStatus = core_backend_1.NativeHost.checkInternetConnectivity();
114
- if (((_f = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _f === void 0 ? void 0 : _f.authConfig) && true !== ((_g = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _g === void 0 ? void 0 : _g.noInitializeAuthClient) && connectivityStatus === core_common_1.InternetConnectivityStatus.Online) {
115
- await authorizationBackend.initialize((_h = opt === null || opt === void 0 ? void 0 : opt.mobileHost) === null || _h === void 0 ? void 0 : _h.authConfig);
116
- }
117
- core_backend_1.IModelHost.authorizationClient = authorizationBackend;
118
109
  }
119
110
  }
120
111
  exports.MobileHost = MobileHost;
@@ -1 +1 @@
1
- {"version":3,"file":"MobileHost.js","sourceRoot":"","sources":["../../../src/backend/MobileHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA+D;AAC/D,sDAAkG;AAClG,oDAG4B;AAC5B,2DAAwF;AAExF,oEAAsE;AACtE,6DAAyH;AACzH,iEAA8D;AAC9D,6EAA+G;AAC/G,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,CAA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G,uBAAH,GAAG,CAAE,UAAU,0CAAE,UAAU,KAAI,IAAI,MAAK,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,sBAAsB,CAAA,IAAI,kBAAkB,KAAK,wCAA0B,CAAC,MAAM,EAAE;YAC/I,MAAM,oBAAoB,CAAC,UAAU,CAAC,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,UAAU,CAAC,CAAC;SACpE;QACD,yBAAU,CAAC,mBAAmB,GAAG,oBAAoB,CAAC;IACxD,CAAC;;AApFH,gCAqFC;AAlFwB,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","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 { BeEvent, BriefcaseStatus } from \"@itwin/core-bentley\";\r\nimport { IModelHost, IpcHandler, IpcHost, NativeHost, NativeHostOpts } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, IModelTileRpcInterface, InternetConnectivityStatus, 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 { BatteryState, DeviceEvents, mobileAppChannel, MobileAppFunctions, Orientation } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAppAuthorizationConfiguration, 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 }\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 authSignIn(callback: (err?: string) => void): void;\r\n public abstract authSignOut(callback: (err?: string) => void): void;\r\n public abstract authGetAccessToken(callback: (accessToken?: string, err?: string) => void): void;\r\n public authInit(_config: MobileAppAuthorizationConfiguration, callback: (err?: string) => void): void { callback(); }\r\n public abstract authStateChanged(accessToken?: string, err?: string): 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}\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 /** if present, [[NativeHost.authorizationClient]] will be set to an instance of MobileAppAuthorizationConfiguration and will be initialized. */\r\n authConfig?: MobileAppAuthorizationConfiguration;\r\n /** if true, do not attempt to initialize AuthorizationClient on startup */\r\n noInitializeAuthClient?: boolean;\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\r\n /** @internal */\r\n public static get authorization() { return IModelHost.authorizationClient as MobileAuthorizationBackend; }\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 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 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 // following will provide impl for device specific api.\r\n setupMobileRpc();\r\n }\r\n\r\n await NativeHost.startup(opt);\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 const authorizationBackend = new MobileAuthorizationBackend(opt?.mobileHost?.authConfig);\r\n const connectivityStatus = NativeHost.checkInternetConnectivity();\r\n if (opt?.mobileHost?.authConfig && true !== opt?.mobileHost?.noInitializeAuthClient && connectivityStatus === InternetConnectivityStatus.Online) {\r\n await authorizationBackend.initialize(opt?.mobileHost?.authConfig);\r\n }\r\n IModelHost.authorizationClient = authorizationBackend;\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,sDAA+D;AAC/D,sDAAsF;AACtF,oDAG4B;AAC5B,2DAAwF;AAExF,oEAAsE;AACtE,iEAA8D;AAE9D,iEAA8D;AAE9D,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;SACzD;IACH,CAAC;IAcM,QAAQ,CAAC,OAA4C,EAAE,QAAgC,IAAU,QAAQ,EAAE,CAAC,CAAC,CAAC;CAEtH;AA9BD,oCA8BC;AAED,MAAM,gBAAiB,SAAQ,yBAAU;IACvC,IAAW,WAAW,KAAK,OAAO,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AG,CAAC,CAAC;QAC9B,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;;AA1EH,gCA2EC;AAxEwB,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","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 { BeEvent, BriefcaseStatus } from \"@itwin/core-bentley\";\r\nimport { 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 } from \"../common/MobileAppChannel\";\r\nimport { BatteryState, DeviceEvents, MobileAppFunctions, Orientation } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\r\nimport { MobileAppAuthorizationConfiguration } 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 }\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 authSignIn(callback: (err?: string) => void): void;\r\n public abstract authSignOut(callback: (err?: string) => void): void;\r\n public abstract authGetAccessToken(callback: (accessToken?: string, err?: string) => void): void;\r\n public authInit(_config: MobileAppAuthorizationConfiguration, callback: (err?: string) => void): void { callback(); }\r\n public abstract authStateChanged(accessToken?: string, err?: string): 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}\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 /** if present, [[IModelHost.authorizationClient]] will be set to an instance of [[MobileAuthorizationBackend]]. */\r\n authConfig?: MobileAppAuthorizationConfiguration;\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\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 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 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 // following will provide impl for device specific api.\r\n setupMobileRpc();\r\n }\r\n\r\n await NativeHost.startup(opt);\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,4 +1,5 @@
1
1
  import { MobileRpcGateway } from "../common/MobileRpcProtocol";
2
+ /** @beta */
2
3
  export declare class MobileRpcServer {
3
4
  private static _nextId;
4
5
  static interop: MobileRpcGateway;
@@ -1 +1 @@
1
- {"version":3,"file":"MobileRpcServer.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileRpcServer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,6BAA6B,CAAC;AAYlF,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAM;IAE5B,OAAc,OAAO,EAAE,gBAAgB,CAMrC;IAEF,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,UAAU,CAAiB;;IAoBnC,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,oBAAoB;IAiBrB,OAAO;CAUf;AAKD,wBAAgB,cAAc,SAiC7B"}
1
+ {"version":3,"file":"MobileRpcServer.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileRpcServer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,6BAA6B,CAAC;AAYlF,YAAY;AACZ,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAM;IAE5B,OAAc,OAAO,EAAE,gBAAgB,CAMrC;IAEF,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,UAAU,CAAiB;;IAoBnC,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,oBAAoB;IAiBrB,OAAO;CAUf;AAKD,wBAAgB,cAAc,SAiC7B"}
@@ -12,9 +12,10 @@ const MobileRpcManager_1 = require("../common/MobileRpcManager");
12
12
  const MobileHost_1 = require("./MobileHost");
13
13
  const core_bentley_1 = require("@itwin/core-bentley");
14
14
  let addon;
15
+ /** @beta */
15
16
  class MobileRpcServer {
16
17
  constructor() {
17
- /* _pingTime is a fix for ios/mobile case where when app move into foreground from
18
+ /* _pingTime is a fix for ios/mobile case where when the app moves into foreground from
18
19
  * background backend restart ws.Server and then notify frontend to reconnect. But ws.Server
19
20
  * listening event is not fired as node yield to kevent and wait for some io event to happen.
20
21
  * This causes a delay in reconnection which may be as long a 40 secs. To solve the issue we
@@ -1 +1 @@
1
- {"version":3,"file":"MobileRpcServer.js","sourceRoot":"","sources":["../../../src/backend/MobileRpcServer.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yBAAyB;AACzB,oDAAgE;AAChE,mEAAkF;AAClF,iEAAoE;AACpE,6CAA0C;AAC1C,sDAAsD;AAOtD,IAAI,KAA8B,CAAC;AAEnC,MAAa,eAAe;IAgB1B;QACE;;;;;;;;WAQG;QACH,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,GAAG,yCAAsB,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACvD,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,GAAG,EAAE,eAAe,CAAC,OAAO,CAAC;QAC/C,eAAe,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC;QAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;YAChC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAoB,CAAC;YACzD,IAAI,CAAC,KAAK,GAAG,OAAO,CA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,CAAC;AAjCD,wCAiCC","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 * as ws from \"ws\";\r\nimport { BentleyStatus, IModelError } from \"@itwin/core-common\";\r\nimport { MobileRpcGateway, MobileRpcProtocol } from \"../common/MobileRpcProtocol\";\r\nimport { MobileRpcConfiguration } from \"../common/MobileRpcManager\";\r\nimport { MobileHost } from \"./MobileHost\";\r\nimport { ProcessDetector } from \"@itwin/core-bentley\";\r\n\r\ninterface MobileAddon {\r\n notifyListening: (port: number) => void;\r\n registerDeviceImpl: () => void;\r\n}\r\n\r\nlet addon: MobileAddon | undefined;\r\n\r\nexport class MobileRpcServer {\r\n private static _nextId = -1;\r\n\r\n public static interop: MobileRpcGateway = {\r\n handler: (_payload: ArrayBuffer | string) => { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); },\r\n sendString: (_message: string, _connectionId: number) => { throw new IModelError(BentleyStatus.ERROR, \"No connection.\"); },\r\n sendBinary: (_message: Uint8Array, _connectionId: number) => { throw new IModelError(BentleyStatus.ERROR, \"No connection.\"); },\r\n port: 0,\r\n connectionId: 0,\r\n };\r\n\r\n private _server: ws.Server;\r\n private _connection: ws | undefined;\r\n private _port: number;\r\n private _connectionId: number;\r\n private _pingTimer: NodeJS.Timeout;\r\n public constructor() {\r\n /* _pingTime is a fix for ios/mobile case where when app move into foreground from\r\n * background backend restart ws.Server and then notify frontend to reconnect. But ws.Server\r\n * listening event is not fired as node yield to kevent and wait for some io event to happen.\r\n * This causes a delay in reconnection which may be as long a 40 secs. To solve the issue we\r\n * create _pingTimer which causes kevent to yield back to uv poll so timer event can be fired.\r\n * This allow listening event to go through quickly (max 5ms). Once the listening event occur we\r\n * clear the timer. Here we use setInterval() just to make sure otherwise setTimeout() could equally\r\n * be effective\r\n */\r\n this._pingTimer = setInterval(() => { }, 5);\r\n this._port = MobileRpcConfiguration.setup.obtainPort();\r\n this._server = new ws.Server({ port: this._port });\r\n this._connectionId = ++MobileRpcServer._nextId;\r\n MobileRpcServer.interop.connectionId = this._connectionId;\r\n this._onListening();\r\n this._onConnection();\r\n }\r\n\r\n private _onListening() {\r\n this._server.on(\"listening\", () => {\r\n const address = this._server.address() as ws.AddressInfo;\r\n this._port = address.port;\r\n clearInterval(this._pingTimer);\r\n this._notifyListening();\r\n });\r\n }\r\n\r\n private _notifyListening() {\r\n MobileRpcServer.interop.port = this._port;\r\n\r\n if (addon) {\r\n addon.notifyListening(this._port);\r\n }\r\n\r\n if (this._connectionId !== 0) {\r\n MobileHost.reconnect(this._port);\r\n }\r\n }\r\n\r\n private _onConnection() {\r\n this._server.on(\"connection\", (connection) => {\r\n this._connection = connection;\r\n this._connection.on(\"message\", (data) => this._onConnectionMessage(data));\r\n this._createSender();\r\n (global as any).__iTwinJsRpcReady = true;\r\n });\r\n }\r\n\r\n private _createSender() {\r\n const sender = (message: string | Uint8Array, connectionId: number) => {\r\n if (connectionId !== this._connectionId) {\r\n return;\r\n }\r\n\r\n this._connection!.send(message, (err) => {\r\n if (err) {\r\n throw err;\r\n }\r\n });\r\n };\r\n\r\n MobileRpcServer.interop.sendString = sender;\r\n MobileRpcServer.interop.sendBinary = sender;\r\n }\r\n\r\n private _onConnectionMessage(data: ws.Data) {\r\n let message = data;\r\n if (Array.isArray(message)) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Unsupported data type\");\r\n }\r\n\r\n if (Buffer.isBuffer(message)) {\r\n if (message.byteOffset !== 0 || message.byteLength !== message.buffer.byteLength) {\r\n message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);\r\n } else {\r\n message = message.buffer;\r\n }\r\n }\r\n\r\n MobileRpcServer.interop.handler(message, this._connectionId);\r\n }\r\n\r\n public dispose() {\r\n clearInterval(this._pingTimer);\r\n if (this._connection) {\r\n MobileRpcServer.interop.sendString = () => { };\r\n MobileRpcServer.interop.sendBinary = () => { };\r\n this._connection.close();\r\n }\r\n\r\n this._server.close();\r\n }\r\n}\r\n\r\nlet mobileReady = false;\r\nlet hasSuspended = false;\r\n\r\nexport function setupMobileRpc() {\r\n if (mobileReady) {\r\n return;\r\n }\r\n\r\n if (ProcessDetector.isMobileAppBackend) {\r\n addon = (process as any)._linkedBinding(\"iModelJsMobile\");\r\n addon?.registerDeviceImpl();\r\n }\r\n\r\n let server: MobileRpcServer | null = new MobileRpcServer();\r\n\r\n MobileHost.onEnterBackground.addListener(() => {\r\n hasSuspended = true;\r\n\r\n if (server === null) {\r\n return;\r\n }\r\n\r\n server.dispose();\r\n server = null;\r\n });\r\n\r\n MobileHost.onEnterForeground.addListener(() => {\r\n if (!hasSuspended) {\r\n return;\r\n }\r\n\r\n server = new MobileRpcServer();\r\n });\r\n\r\n MobileRpcProtocol.obtainInterop = () => MobileRpcServer.interop;\r\n mobileReady = true;\r\n}\r\n"]}
1
+ {"version":3,"file":"MobileRpcServer.js","sourceRoot":"","sources":["../../../src/backend/MobileRpcServer.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yBAAyB;AACzB,oDAAgE;AAChE,mEAAkF;AAClF,iEAAoE;AACpE,6CAA0C;AAC1C,sDAAsD;AAOtD,IAAI,KAA8B,CAAC;AAEnC,YAAY;AACZ,MAAa,eAAe;IAgB1B;QACE;;;;;;;;WAQG;QACH,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,GAAG,yCAAsB,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACvD,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,GAAG,EAAE,eAAe,CAAC,OAAO,CAAC;QAC/C,eAAe,CAAC,OAAO,C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CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,uBAAU,CAAC,iBAAiB,CAAC,WAAW,CAAC,GAAG,EAAE;QAC5C,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QAED,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,qCAAiB,CAAC,aAAa,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC;IAChE,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAjCD,wCAiCC","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 * as ws from \"ws\";\r\nimport { BentleyStatus, IModelError } from \"@itwin/core-common\";\r\nimport { MobileRpcGateway, MobileRpcProtocol } from \"../common/MobileRpcProtocol\";\r\nimport { MobileRpcConfiguration } from \"../common/MobileRpcManager\";\r\nimport { MobileHost } from \"./MobileHost\";\r\nimport { ProcessDetector } from \"@itwin/core-bentley\";\r\n\r\ninterface MobileAddon {\r\n notifyListening: (port: number) => void;\r\n registerDeviceImpl: () => void;\r\n}\r\n\r\nlet addon: MobileAddon | undefined;\r\n\r\n/** @beta */\r\nexport class MobileRpcServer {\r\n private static _nextId = -1;\r\n\r\n public static interop: MobileRpcGateway = {\r\n handler: (_payload: ArrayBuffer | string) => { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); },\r\n sendString: (_message: string, _connectionId: number) => { throw new IModelError(BentleyStatus.ERROR, \"No connection.\"); },\r\n sendBinary: (_message: Uint8Array, _connectionId: number) => { throw new IModelError(BentleyStatus.ERROR, \"No connection.\"); },\r\n port: 0,\r\n connectionId: 0,\r\n };\r\n\r\n private _server: ws.Server;\r\n private _connection: ws | undefined;\r\n private _port: number;\r\n private _connectionId: number;\r\n private _pingTimer: NodeJS.Timeout;\r\n public constructor() {\r\n /* _pingTime is a fix for ios/mobile case where when the app moves into foreground from\r\n * background backend restart ws.Server and then notify frontend to reconnect. But ws.Server\r\n * listening event is not fired as node yield to kevent and wait for some io event to happen.\r\n * This causes a delay in reconnection which may be as long a 40 secs. To solve the issue we\r\n * create _pingTimer which causes kevent to yield back to uv poll so timer event can be fired.\r\n * This allow listening event to go through quickly (max 5ms). Once the listening event occur we\r\n * clear the timer. Here we use setInterval() just to make sure otherwise setTimeout() could equally\r\n * be effective\r\n */\r\n this._pingTimer = setInterval(() => { }, 5);\r\n this._port = MobileRpcConfiguration.setup.obtainPort();\r\n this._server = new ws.Server({ port: this._port });\r\n this._connectionId = ++MobileRpcServer._nextId;\r\n MobileRpcServer.interop.connectionId = this._connectionId;\r\n this._onListening();\r\n this._onConnection();\r\n }\r\n\r\n private _onListening() {\r\n this._server.on(\"listening\", () => {\r\n const address = this._server.address() as ws.AddressInfo;\r\n this._port = address.port;\r\n clearInterval(this._pingTimer);\r\n this._notifyListening();\r\n });\r\n }\r\n\r\n private _notifyListening() {\r\n MobileRpcServer.interop.port = this._port;\r\n\r\n if (addon) {\r\n addon.notifyListening(this._port);\r\n }\r\n\r\n if (this._connectionId !== 0) {\r\n MobileHost.reconnect(this._port);\r\n }\r\n }\r\n\r\n private _onConnection() {\r\n this._server.on(\"connection\", (connection) => {\r\n this._connection = connection;\r\n this._connection.on(\"message\", (data) => this._onConnectionMessage(data));\r\n this._createSender();\r\n (global as any).__iTwinJsRpcReady = true;\r\n });\r\n }\r\n\r\n private _createSender() {\r\n const sender = (message: string | Uint8Array, connectionId: number) => {\r\n if (connectionId !== this._connectionId) {\r\n return;\r\n }\r\n\r\n this._connection!.send(message, (err) => {\r\n if (err) {\r\n throw err;\r\n }\r\n });\r\n };\r\n\r\n MobileRpcServer.interop.sendString = sender;\r\n MobileRpcServer.interop.sendBinary = sender;\r\n }\r\n\r\n private _onConnectionMessage(data: ws.Data) {\r\n let message = data;\r\n if (Array.isArray(message)) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Unsupported data type\");\r\n }\r\n\r\n if (Buffer.isBuffer(message)) {\r\n if (message.byteOffset !== 0 || message.byteLength !== message.buffer.byteLength) {\r\n message = new Uint8Array(message.buffer, message.byteOffset, message.byteLength);\r\n } else {\r\n message = message.buffer;\r\n }\r\n }\r\n\r\n MobileRpcServer.interop.handler(message, this._connectionId);\r\n }\r\n\r\n public dispose() {\r\n clearInterval(this._pingTimer);\r\n if (this._connection) {\r\n MobileRpcServer.interop.sendString = () => { };\r\n MobileRpcServer.interop.sendBinary = () => { };\r\n this._connection.close();\r\n }\r\n\r\n this._server.close();\r\n }\r\n}\r\n\r\nlet mobileReady = false;\r\nlet hasSuspended = false;\r\n\r\nexport function setupMobileRpc() {\r\n if (mobileReady) {\r\n return;\r\n }\r\n\r\n if (ProcessDetector.isMobileAppBackend) {\r\n addon = (process as any)._linkedBinding(\"iModelJsMobile\");\r\n addon?.registerDeviceImpl();\r\n }\r\n\r\n let server: MobileRpcServer | null = new MobileRpcServer();\r\n\r\n MobileHost.onEnterBackground.addListener(() => {\r\n hasSuspended = true;\r\n\r\n if (server === null) {\r\n return;\r\n }\r\n\r\n server.dispose();\r\n server = null;\r\n });\r\n\r\n MobileHost.onEnterForeground.addListener(() => {\r\n if (!hasSuspended) {\r\n return;\r\n }\r\n\r\n server = new MobileRpcServer();\r\n });\r\n\r\n MobileRpcProtocol.obtainInterop = () => MobileRpcServer.interop;\r\n mobileReady = true;\r\n}\r\n"]}
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const mobileAppChannel = "mobileApp";
3
+ /** @internal */
4
+ export declare const mobileAppNotify = "mobileApp-notify";
5
+ //# sourceMappingURL=MobileAppChannel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MobileAppChannel.d.ts","sourceRoot":"","sources":["../../../src/common/MobileAppChannel.ts"],"names":[],"mappings":"AAKA,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAC5C,gBAAgB;AAChB,eAAO,MAAM,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,12 @@
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.mobileAppNotify = exports.mobileAppChannel = void 0;
8
+ /** @internal */
9
+ exports.mobileAppChannel = "mobileApp";
10
+ /** @internal */
11
+ exports.mobileAppNotify = "mobileApp-notify";
12
+ //# sourceMappingURL=MobileAppChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MobileAppChannel.js","sourceRoot":"","sources":["../../../src/common/MobileAppChannel.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gBAAgB;AACH,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAC5C,gBAAgB;AACH,QAAA,eAAe,GAAG,kBAAkB,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\n/** @internal */\r\nexport const mobileAppChannel = \"mobileApp\";\r\n/** @internal */\r\nexport const mobileAppNotify = \"mobileApp-notify\";\r\n"]}
@@ -1,7 +1,4 @@
1
- /** @internal */
2
- export declare const mobileAppChannel = "mobileApp";
3
- /** @internal */
4
- export declare const mobileAppNotify = "mobileApp-notify";
1
+ /** @beta */
5
2
  export declare enum Orientation {
6
3
  Unknown = 0,
7
4
  Portrait = 1,
@@ -11,12 +8,14 @@ export declare enum Orientation {
11
8
  FaceUp = 16,
12
9
  FaceDown = 32
13
10
  }
11
+ /** @beta */
14
12
  export declare enum BatteryState {
15
13
  Unknown = 0,
16
14
  Unplugged = 1,
17
15
  Charging = 2,
18
16
  Full = 3
19
17
  }
18
+ /** @beta */
20
19
  export interface MobileNotifications {
21
20
  notifyMemoryWarning: () => void;
22
21
  notifyOrientationChanged: () => void;
@@ -24,10 +23,11 @@ export interface MobileNotifications {
24
23
  notifyEnterBackground: () => void;
25
24
  notifyWillTerminate: () => void;
26
25
  }
26
+ /** @beta */
27
27
  export declare type DeviceEvents = "memoryWarning" | "orientationChanged" | "enterForeground" | "enterBackground" | "willTerminate";
28
28
  /**
29
29
  * The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.
30
- * @internal
30
+ * @beta
31
31
  */
32
32
  export interface MobileAppFunctions {
33
33
  reconnect: (connection: number) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAppProps.d.ts","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":"AAKA,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAC5C,gBAAgB;AAChB,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,oBAAY,WAAW;IACrB,OAAO,IAAI;IACX,QAAQ,IAAM;IACd,kBAAkB,IAAM;IACxB,aAAa,IAAM;IACnB,cAAc,IAAM;IACpB,MAAM,KAAO;IACb,QAAQ,KAAO;CAChB;AAED,oBAAY,YAAY;IACtB,OAAO,IAAI;IACX,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,IAAI,IAAI;CACT;AAED,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,oBAAY,YAAY,GAAG,eAAe,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE5H;;;EAGE;AACF,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD"}
1
+ {"version":3,"file":"MobileAppProps.d.ts","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":"AAKA,YAAY;AACZ,oBAAY,WAAW;IACrB,OAAO,IAAI;IACX,QAAQ,IAAM;IACd,kBAAkB,IAAM;IACxB,aAAa,IAAM;IACnB,cAAc,IAAM;IACpB,MAAM,KAAO;IACb,QAAQ,KAAO;CAChB;AAED,YAAY;AACZ,oBAAY,YAAY;IACtB,OAAO,IAAI;IACX,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,IAAI,IAAI;CACT;AAED,YAAY;AACZ,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,YAAY;AACZ,oBAAY,YAAY,GAAG,eAAe,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE5H;;;EAGE;AACF,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD"}
@@ -4,11 +4,8 @@
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.BatteryState = exports.Orientation = exports.mobileAppNotify = exports.mobileAppChannel = void 0;
8
- /** @internal */
9
- exports.mobileAppChannel = "mobileApp";
10
- /** @internal */
11
- exports.mobileAppNotify = "mobileApp-notify";
7
+ exports.BatteryState = exports.Orientation = void 0;
8
+ /** @beta */
12
9
  var Orientation;
13
10
  (function (Orientation) {
14
11
  Orientation[Orientation["Unknown"] = 0] = "Unknown";
@@ -19,6 +16,7 @@ var Orientation;
19
16
  Orientation[Orientation["FaceUp"] = 16] = "FaceUp";
20
17
  Orientation[Orientation["FaceDown"] = 32] = "FaceDown";
21
18
  })(Orientation = exports.Orientation || (exports.Orientation = {}));
19
+ /** @beta */
22
20
  var BatteryState;
23
21
  (function (BatteryState) {
24
22
  BatteryState[BatteryState["Unknown"] = 0] = "Unknown";
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAppProps.js","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gBAAgB;AACH,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAC5C,gBAAgB;AACH,QAAA,eAAe,GAAG,kBAAkB,CAAC;AAElD,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,mDAAW,CAAA;IACX,qDAAc,CAAA;IACd,yEAAwB,CAAA;IACxB,+DAAmB,CAAA;IACnB,iEAAoB,CAAA;IACpB,kDAAa,CAAA;IACb,sDAAe,CAAA;AACjB,CAAC,EARW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAQtB;AAED,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,yDAAa,CAAA;IACb,uDAAY,CAAA;IACZ,+CAAQ,CAAA;AACV,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB","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/** @internal */\r\nexport const mobileAppChannel = \"mobileApp\";\r\n/** @internal */\r\nexport const mobileAppNotify = \"mobileApp-notify\";\r\n\r\nexport enum Orientation {\r\n Unknown = 0,\r\n Portrait = 0x1,\r\n PortraitUpsideDown = 0x2,\r\n LandscapeLeft = 0x4,\r\n LandscapeRight = 0x8,\r\n FaceUp = 0x10,\r\n FaceDown = 0x20,\r\n}\r\n\r\nexport enum BatteryState {\r\n Unknown = 0,\r\n Unplugged = 1,\r\n Charging = 2,\r\n Full = 3,\r\n}\r\n\r\nexport interface MobileNotifications {\r\n notifyMemoryWarning: () => void;\r\n notifyOrientationChanged: () => void;\r\n notifyEnterForeground: () => void;\r\n notifyEnterBackground: () => void;\r\n notifyWillTerminate: () => void;\r\n}\r\n\r\nexport type DeviceEvents = \"memoryWarning\" | \"orientationChanged\" | \"enterForeground\" | \"enterBackground\" | \"willTerminate\";\r\n\r\n/**\r\n* The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.\r\n* @internal\r\n*/\r\nexport interface MobileAppFunctions {\r\n reconnect: (connection: number) => Promise<void>;\r\n}\r\n"]}
1
+ {"version":3,"file":"MobileAppProps.js","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,YAAY;AACZ,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,mDAAW,CAAA;IACX,qDAAc,CAAA;IACd,yEAAwB,CAAA;IACxB,+DAAmB,CAAA;IACnB,iEAAoB,CAAA;IACpB,kDAAa,CAAA;IACb,sDAAe,CAAA;AACjB,CAAC,EARW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAQtB;AAED,YAAY;AACZ,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,yDAAa,CAAA;IACb,uDAAY,CAAA;IACZ,+CAAQ,CAAA;AACV,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB","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/** @beta */\r\nexport enum Orientation {\r\n Unknown = 0,\r\n Portrait = 0x1,\r\n PortraitUpsideDown = 0x2,\r\n LandscapeLeft = 0x4,\r\n LandscapeRight = 0x8,\r\n FaceUp = 0x10,\r\n FaceDown = 0x20,\r\n}\r\n\r\n/** @beta */\r\nexport enum BatteryState {\r\n Unknown = 0,\r\n Unplugged = 1,\r\n Charging = 2,\r\n Full = 3,\r\n}\r\n\r\n/** @beta */\r\nexport interface MobileNotifications {\r\n notifyMemoryWarning: () => void;\r\n notifyOrientationChanged: () => void;\r\n notifyEnterForeground: () => void;\r\n notifyEnterBackground: () => void;\r\n notifyWillTerminate: () => void;\r\n}\r\n\r\n/** @beta */\r\nexport type DeviceEvents = \"memoryWarning\" | \"orientationChanged\" | \"enterForeground\" | \"enterBackground\" | \"willTerminate\";\r\n\r\n/**\r\n* The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.\r\n* @beta\r\n*/\r\nexport interface MobileAppFunctions {\r\n reconnect: (connection: number) => Promise<void>;\r\n}\r\n"]}
@@ -12,7 +12,7 @@ export declare class MobileApp {
12
12
  private static _isValid;
13
13
  static get isValid(): boolean;
14
14
  /**
15
- * This is called by either ElectronApp.startup or MobileApp.startup - it should not be called directly
15
+ * This is called by either AndroidApp.startup or IOSApp.startup - it should not be called directly
16
16
  * @internal
17
17
  */
18
18
  static startup(opts?: NativeAppOpts): Promise<void>;
@@ -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;AAC7F,OAAO,EAAoB,kBAAkB,EAAwC,MAAM,0BAA0B,CAAC;AAoBtH,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;WACtC,WAAW,CAAC,CAAC,SAAS,cAAc,CAAC,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAIvI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,WAAkB,OAAO,YAA4B;IACrD;;;OAGG;WACiB,OAAO,CAAC,IAAI,CAAC,EAAE,aAAa;CAWjD"}
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;AAoBnF,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;WACtC,WAAW,CAAC,CAAC,SAAS,cAAc,CAAC,kBAAkB,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAIvI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,WAAkB,OAAO,YAA4B;IACrD;;;OAGG;WACiB,OAAO,CAAC,IAAI,CAAC,EAAE,aAAa;CAWjD"}
@@ -8,11 +8,11 @@ exports.MobileApp = void 0;
8
8
  const core_bentley_1 = require("@itwin/core-bentley");
9
9
  const core_common_1 = require("@itwin/core-common");
10
10
  const core_frontend_1 = require("@itwin/core-frontend");
11
- const MobileAppProps_1 = require("../common/MobileAppProps");
11
+ const MobileAppChannel_1 = require("../common/MobileAppChannel");
12
12
  const MobileRpcManager_1 = require("../common/MobileRpcManager");
13
13
  /** receive notifications from backend */
14
14
  class MobileAppNotifyHandler extends core_frontend_1.NotificationHandler {
15
- get channelName() { return MobileAppProps_1.mobileAppNotify; }
15
+ get channelName() { return MobileAppChannel_1.mobileAppNotify; }
16
16
  notifyMemoryWarning() {
17
17
  core_bentley_1.Logger.logWarning("mobileApp", "Low memory warning");
18
18
  if (MobileApp.onMemoryWarning.numberOfListeners === 0) {
@@ -28,11 +28,11 @@ class MobileAppNotifyHandler extends core_frontend_1.NotificationHandler {
28
28
  /** @beta */
29
29
  class MobileApp {
30
30
  static async callBackend(methodName, ...args) {
31
- return core_frontend_1.IpcApp.callIpcChannel(MobileAppProps_1.mobileAppChannel, methodName, ...args);
31
+ return core_frontend_1.IpcApp.callIpcChannel(MobileAppChannel_1.mobileAppChannel, methodName, ...args);
32
32
  }
33
33
  static get isValid() { return this._isValid; }
34
34
  /**
35
- * This is called by either ElectronApp.startup or MobileApp.startup - it should not be called directly
35
+ * This is called by either AndroidApp.startup or IOSApp.startup - it should not be called directly
36
36
  * @internal
37
37
  */
38
38
  static async startup(opts) {
@@ -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,6DAAsH;AACtH,iEAA8D;AAE9D,yCAAyC;AACzC,MAAM,sBAAuB,SAAQ,mCAAmB;IACtD,IAAW,WAAW,KAAK,OAAO,gCAAe,CAAC,CAAC,CAAC;IAE7C,mBAAmB;QACxB,qBAAM,CAAC,UAAU,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QACrD,IAAI,SAAS,CAAC,eAAe,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EAAE,CAAC,CAAC,sCAAsC;IAC3E,CAAC;;AA1BH,8BA2BC;AA1Be,yBAAe,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;AAK3C,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, MobileAppFunctions, mobileAppNotify, MobileNotifications } from \"../common/MobileAppProps\";\r\nimport { MobileRpcManager } from \"../common/MobileRpcManager\";\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}\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 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 ElectronApp.startup or MobileApp.startup - it should not be called directly\r\n * @internal\r\n */\r\n public static async startup(opts?: NativeAppOpts) {\r\n if (!this._isValid) {\r\n const rpcInterfaces = opts?.iModelApp?.rpcInterfaces ?? [IModelReadRpcInterface, IModelTileRpcInterface];\r\n MobileRpcManager.initializeClient(rpcInterfaces);\r\n this._isValid = true;\r\n }\r\n const socket = new IpcWebSocketFrontend(); // needs work\r\n await NativeApp.startup(socket, opts);\r\n\r\n MobileAppNotifyHandler.register(); // receives notifications from backend\r\n }\r\n}\r\n"]}
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;AAE9D,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,C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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;AAK3C,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\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}\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 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 if (!this._isValid) {\r\n const rpcInterfaces = opts?.iModelApp?.rpcInterfaces ?? [IModelReadRpcInterface, IModelTileRpcInterface];\r\n MobileRpcManager.initializeClient(rpcInterfaces);\r\n this._isValid = true;\r\n }\r\n const socket = new IpcWebSocketFrontend(); // needs work\r\n await NativeApp.startup(socket, opts);\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.1.0-dev.0",
3
+ "version": "3.1.0-dev.1",
4
4
  "description": "iTwin.js MobileHost and MobileApp",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -21,11 +21,11 @@
21
21
  "url": "http://www.bentley.com"
22
22
  },
23
23
  "peerDependencies": {
24
- "@itwin/core-backend": "^3.1.0-dev.0",
25
- "@itwin/core-bentley": "^3.1.0-dev.0",
26
- "@itwin/core-common": "^3.1.0-dev.0",
27
- "@itwin/core-frontend": "^3.1.0-dev.0",
28
- "@itwin/presentation-common": "^3.1.0-dev.0"
24
+ "@itwin/core-backend": "^3.1.0-dev.1",
25
+ "@itwin/core-bentley": "^3.1.0-dev.1",
26
+ "@itwin/core-common": "^3.1.0-dev.1",
27
+ "@itwin/core-frontend": "^3.1.0-dev.1",
28
+ "@itwin/presentation-common": "^3.1.0-dev.1"
29
29
  },
30
30
  "dependencies": {
31
31
  "deep-assign": "^2.0.0",
@@ -36,13 +36,13 @@
36
36
  "ws": "^7.5.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@itwin/build-tools": "3.1.0-dev.0",
40
- "@itwin/core-backend": "3.1.0-dev.0",
41
- "@itwin/core-bentley": "3.1.0-dev.0",
42
- "@itwin/core-common": "3.1.0-dev.0",
43
- "@itwin/core-frontend": "3.1.0-dev.0",
44
- "@itwin/eslint-plugin": "3.1.0-dev.0",
45
- "@itwin/presentation-common": "3.1.0-dev.0",
39
+ "@itwin/build-tools": "3.1.0-dev.1",
40
+ "@itwin/core-backend": "3.1.0-dev.1",
41
+ "@itwin/core-bentley": "3.1.0-dev.1",
42
+ "@itwin/core-common": "3.1.0-dev.1",
43
+ "@itwin/core-frontend": "3.1.0-dev.1",
44
+ "@itwin/eslint-plugin": "3.1.0-dev.1",
45
+ "@itwin/presentation-common": "3.1.0-dev.1",
46
46
  "@types/chai": "^4.1.4",
47
47
  "@types/deep-assign": "^0.1.0",
48
48
  "@types/fs-extra": "^4.0.7",