@itwin/core-mobile 4.0.0-dev.8 → 4.0.0-dev.81

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 (67) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +1 -1
  3. package/lib/cjs/MobileBackend.d.ts +7 -7
  4. package/lib/cjs/MobileBackend.js +28 -24
  5. package/lib/cjs/MobileBackend.js.map +1 -1
  6. package/lib/cjs/MobileFrontend.d.ts +5 -5
  7. package/lib/cjs/MobileFrontend.js +25 -21
  8. package/lib/cjs/MobileFrontend.js.map +1 -1
  9. package/lib/cjs/__DOC_ONLY__.d.ts +33 -33
  10. package/lib/cjs/__DOC_ONLY__.js +56 -52
  11. package/lib/cjs/__DOC_ONLY__.js.map +1 -1
  12. package/lib/cjs/backend/MobileAuthorizationBackend.d.ts +17 -17
  13. package/lib/cjs/backend/MobileAuthorizationBackend.js +46 -46
  14. package/lib/cjs/backend/MobileAuthorizationBackend.js.map +1 -1
  15. package/lib/cjs/backend/MobileFileHandler.d.ts +112 -112
  16. package/lib/cjs/backend/MobileFileHandler.d.ts.map +1 -1
  17. package/lib/cjs/backend/MobileFileHandler.js +263 -263
  18. package/lib/cjs/backend/MobileFileHandler.js.map +1 -1
  19. package/lib/cjs/backend/MobileHost.d.ts +72 -72
  20. package/lib/cjs/backend/MobileHost.d.ts.map +1 -1
  21. package/lib/cjs/backend/MobileHost.js +149 -156
  22. package/lib/cjs/backend/MobileHost.js.map +1 -1
  23. package/lib/cjs/backend/MobileRpcServer.d.ts +19 -19
  24. package/lib/cjs/backend/MobileRpcServer.js +156 -156
  25. package/lib/cjs/backend/MobileRpcServer.js.map +1 -1
  26. package/lib/cjs/backend/Request.d.ts +117 -149
  27. package/lib/cjs/backend/Request.d.ts.map +1 -1
  28. package/lib/cjs/backend/Request.js +255 -267
  29. package/lib/cjs/backend/Request.js.map +1 -1
  30. package/lib/cjs/common/MobileAppChannel.d.ts +4 -4
  31. package/lib/cjs/common/MobileAppChannel.js +11 -11
  32. package/lib/cjs/common/MobileAppChannel.js.map +1 -1
  33. package/lib/cjs/common/MobileAppProps.d.ts +35 -35
  34. package/lib/cjs/common/MobileAppProps.d.ts.map +1 -1
  35. package/lib/cjs/common/MobileAppProps.js +26 -26
  36. package/lib/cjs/common/MobileAppProps.js.map +1 -1
  37. package/lib/cjs/common/MobileEventLoop.d.ts +11 -11
  38. package/lib/cjs/common/MobileEventLoop.js +30 -30
  39. package/lib/cjs/common/MobileEventLoop.js.map +1 -1
  40. package/lib/cjs/common/MobileIpc.d.ts +17 -17
  41. package/lib/cjs/common/MobileIpc.js +70 -70
  42. package/lib/cjs/common/MobileIpc.js.map +1 -1
  43. package/lib/cjs/common/MobilePush.d.ts +20 -20
  44. package/lib/cjs/common/MobilePush.js +53 -53
  45. package/lib/cjs/common/MobilePush.js.map +1 -1
  46. package/lib/cjs/common/MobileRpcManager.d.ts +40 -40
  47. package/lib/cjs/common/MobileRpcManager.js +110 -110
  48. package/lib/cjs/common/MobileRpcManager.js.map +1 -1
  49. package/lib/cjs/common/MobileRpcProtocol.d.ts +58 -58
  50. package/lib/cjs/common/MobileRpcProtocol.d.ts.map +1 -1
  51. package/lib/cjs/common/MobileRpcProtocol.js +277 -277
  52. package/lib/cjs/common/MobileRpcProtocol.js.map +1 -1
  53. package/lib/cjs/common/MobileRpcRequest.d.ts +20 -20
  54. package/lib/cjs/common/MobileRpcRequest.js +50 -50
  55. package/lib/cjs/common/MobileRpcRequest.js.map +1 -1
  56. package/lib/cjs/frontend/MobileApp.d.ts +23 -23
  57. package/lib/cjs/frontend/MobileApp.d.ts.map +1 -1
  58. package/lib/cjs/frontend/MobileApp.js +79 -80
  59. package/lib/cjs/frontend/MobileApp.js.map +1 -1
  60. package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts +17 -17
  61. package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts.map +1 -1
  62. package/lib/cjs/frontend/MobileAuthorizationFrontend.js +54 -46
  63. package/lib/cjs/frontend/MobileAuthorizationFrontend.js.map +1 -1
  64. package/lib/cjs/test/ios/MobilePlatform.test.d.ts +1 -1
  65. package/lib/cjs/test/ios/MobilePlatform.test.js +84 -84
  66. package/lib/cjs/test/ios/MobilePlatform.test.js.map +1 -1
  67. package/package.json +18 -26
@@ -1 +1 @@
1
- {"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/backend/Request.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,0CAA0C;AAG1C,2BAAkD;AAClD,wCAAwC;AACxC,sDAAsG;AAEtG,MAAM,cAAc,GAAW,6BAA6B,CAAC;AAE7D,gBAAgB;AACH,QAAA,mBAAmB,GAAG,kBAAkB,CAAC;AA0GtD;;GAEG;AACH,MAAa,aAAc,SAAQ,2BAAY;IAI7C,YAAmB,WAAgC,EAAE,OAAgB,EAAE,WAAiC;QACtG,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,QAAa,EAAE,GAAG,GAAG,IAAI;QAC3C,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACpF,IAAI,CAAC,QAAQ,EAAE;YACb,KAAK,CAAC,OAAO,GAAG,+BAA+B,CAAC;YAChD,OAAO,KAAK,CAAC;SACd;QAED,IAAI,QAAQ,CAAC,QAAQ,EAAE;YACrB,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE;gBAC3B,KAAK,CAAC,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;gBACxD,KAAK,CAAC,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;aACrD;YACD,IAAI,QAAQ,CAAC,QAAQ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,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAPD,0BAOC","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 iTwinServiceClients\r\n */\r\nimport * as deepAssign from \"deep-assign\";\r\nimport * as _ from \"lodash\";\r\nimport * as https from \"https\";\r\nimport { IStringifyOptions, stringify } from \"qs\";\r\nimport * as sarequest from \"superagent\";\r\nimport { BentleyError, GetMetaDataFunction, HttpStatus, Logger, LogLevel } from \"@itwin/core-bentley\";\r\n\r\nconst loggerCategory: string = \"core-mobile-backend.Request\";\r\n\r\n/** @internal */\r\nexport const requestIdHeaderName = \"X-Correlation-Id\";\r\n\r\n/** Typical option to query REST API. Note that services may not quite support these fields,\r\n * and the interface is only provided as a hint.\r\n * @internal\r\n */\r\nexport interface RequestQueryOptions {\r\n /**\r\n * Select string used by the query (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Name,Size,Description\"\r\n */\r\n $select?: string;\r\n\r\n /**\r\n * Filter string used by the query (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Name like '*.pdf' and Size lt 1000\"\r\n */\r\n $filter?: string;\r\n\r\n /** Sets the limit on the number of entries to be returned by the query */\r\n $top?: number;\r\n\r\n /** Sets the number of entries to be skipped */\r\n $skip?: number;\r\n\r\n /**\r\n * Orders the return values (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Size desc\"\r\n */\r\n $orderby?: string;\r\n\r\n /**\r\n * Sets the limit on the number of entries to be returned by a single response.\r\n * Can be used with a Top option. For example if Top is set to 1000 and PageSize\r\n * is set to 100 then 10 requests will be performed to get result.\r\n */\r\n $pageSize?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface RequestQueryStringifyOptions {\r\n delimiter?: string;\r\n encode?: boolean;\r\n}\r\n\r\n/** Option to control the time outs\r\n * Use a short response timeout to detect unresponsive networks quickly, and a long deadline to give time for downloads on slow,\r\n * but reliable, networks. Note that both of these timers limit how long uploads of attached files are allowed to take. Use long\r\n * timeouts if you're uploading files.\r\n * @internal\r\n */\r\nexport interface RequestTimeoutOptions {\r\n /** Sets a deadline (in milliseconds) for the entire request (including all uploads, redirects, server processing time) to complete.\r\n * If the response isn't fully downloaded within that time, the request will be aborted\r\n */\r\n deadline?: number;\r\n\r\n /** Sets maximum time (in milliseconds) to wait for the first byte to arrive from the server, but it does not limit how long the entire\r\n * download can take. Response timeout should be at least few seconds longer than just the time it takes the server to respond, because\r\n * it also includes time to make DNS lookup, TCP/IP and TLS connections, and time to upload request data.\r\n */\r\n response?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface RequestOptions {\r\n method: string;\r\n headers?: any; // {Mas-App-Guid, Mas-UUid, User-Agent}\r\n body?: any;\r\n qs?: any | RequestQueryOptions;\r\n responseType?: string;\r\n timeout?: RequestTimeoutOptions; // Optional timeouts. If unspecified, an arbitrary default is setup.\r\n stream?: any; // Optional stream to read the response to/from (only for NodeJs applications)\r\n readStream?: any; // Optional stream to read input from (only for NodeJs applications)\r\n buffer?: any;\r\n parser?: any;\r\n accept?: string;\r\n redirects?: number;\r\n errorCallback?: (response: any) => ResponseError;\r\n retryCallback?: (error: any, response: any) => boolean;\r\n progressCallback?: ProgressCallback;\r\n agent?: https.Agent;\r\n retries?: number;\r\n useCorsProxy?: boolean;\r\n}\r\n\r\n/** Response object if the request was successful. Note that the status within the range of 200-299 are considered as a success.\r\n * @internal\r\n */\r\nexport interface Response {\r\n body: any; // Parsed body of response\r\n text: string | undefined; // Returned for responseType:text\r\n header: any; // Parsed headers of response\r\n status: number; // Status code of response\r\n}\r\n\r\n/** @internal */\r\nexport interface ProgressInfo {\r\n percent?: number;\r\n total?: number;\r\n loaded: number;\r\n}\r\n\r\n/** @internal */\r\nexport type ProgressCallback = (progress: ProgressInfo) => void;\r\n\r\n/** Error object that's thrown/rejected if the Request fails due to a network error, or if the status is *not* in the range of 200-299 (inclusive)\r\n * @internal\r\n */\r\nexport class ResponseError extends BentleyError {\r\n protected _data?: any;\r\n public status?: number;\r\n public description?: string;\r\n public constructor(errorNumber: number | HttpStatus, message?: string, getMetaData?: GetMetaDataFunction) {\r\n super(errorNumber, message, getMetaData);\r\n }\r\n\r\n /**\r\n * Parses error from server's response\r\n * @param response Http response from the server.\r\n * @returns Parsed error.\r\n * @internal\r\n */\r\n public static parse(response: any, log = true): ResponseError {\r\n const error = new ResponseError(ResponseError.parseHttpStatus(response.statusType));\r\n if (!response) {\r\n error.message = \"Couldn't get response object.\";\r\n return error;\r\n }\r\n\r\n if (response.response) {\r\n if (response.response.error) {\r\n error.name = response.response.error.name || error.name;\r\n error.description = response.response.error.message;\r\n }\r\n if (response.response.res) {\r\n error.message = response.response.res.statusMessage;\r\n }\r\n if (response.response.body && Object.keys(response.response.body).length > 0) {\r\n error._data = {};\r\n deepAssign(error._data, response.response.body);\r\n } else {\r\n error._data = response.response.text;\r\n }\r\n }\r\n\r\n error.status = response.status || response.statusCode;\r\n error.name = response.code || response.name || error.name;\r\n error.message = error.message || response.message || response.statusMessage;\r\n\r\n if (log)\r\n error.log();\r\n\r\n return error;\r\n }\r\n\r\n /**\r\n * Decides whether request should be retried or not\r\n * @param error Error returned by request\r\n * @param response Response returned by request\r\n * @internal\r\n */\r\n public static shouldRetry(error: any, response: any): boolean {\r\n if (error !== undefined && error !== null) {\r\n if ((error.status === undefined || error.status === null) && (error.res === undefined || error.res === null)) {\r\n return true;\r\n }\r\n }\r\n return (response !== undefined && response.statusType === HttpStatus.ServerError);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static parseHttpStatus(statusType: number): HttpStatus {\r\n switch (statusType) {\r\n case 1:\r\n return HttpStatus.Info;\r\n case 2:\r\n return HttpStatus.Success;\r\n case 3:\r\n return HttpStatus.Redirection;\r\n case 4:\r\n return HttpStatus.ClientError;\r\n case 5:\r\n return HttpStatus.ServerError;\r\n default:\r\n return HttpStatus.Success;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public logMessage(): string {\r\n return `${this.status} ${this.name}: ${this.message}`;\r\n }\r\n\r\n /**\r\n * Logs this error\r\n * @internal\r\n */\r\n public log(): void {\r\n Logger.logError(loggerCategory, this.logMessage(), () => this.getMetaData());\r\n }\r\n}\r\n\r\nconst logResponse = (req: sarequest.SuperAgentRequest, startTime: number) => (res: sarequest.Response) => {\r\n const elapsed = new Date().getTime() - startTime;\r\n const elapsedTime = `${elapsed}ms`;\r\n Logger.logTrace(loggerCategory, `${req.method.toUpperCase()} ${res.status} ${req.url} (${elapsedTime})`);\r\n};\r\n\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async\r\nconst logRequest = (req: sarequest.SuperAgentRequest): sarequest.SuperAgentRequest => {\r\n const startTime = new Date().getTime();\r\n return req.on(\"response\", logResponse(req, startTime));\r\n};\r\n\r\n/** Wrapper around making HTTP requests with the specific options.\r\n *\r\n * Usable in both a browser and node based environment.\r\n *\r\n * @param url Server URL to address the request\r\n * @param options Options to pass to the request\r\n * @returns Resolves to the response from the server\r\n * @throws ResponseError if the request fails due to network issues, or if the returned status is *outside* the range of 200-299 (inclusive)\r\n * @internal\r\n */\r\nexport async function request(url: string, options: RequestOptions): Promise<Response> {\r\n let sareq: sarequest.SuperAgentRequest = sarequest(options.method, url);\r\n if (options.retries)\r\n sareq = sareq.retry(options.retries, options.retryCallback);\r\n\r\n if (Logger.isEnabled(loggerCategory, LogLevel.Trace))\r\n sareq = sareq.use(logRequest);\r\n\r\n if (options.headers)\r\n sareq = sareq.set(options.headers);\r\n\r\n let queryStr: string = \"\";\r\n let fullUrl: string = \"\";\r\n if (options.qs && Object.keys(options.qs).length > 0) {\r\n const stringifyOptions: IStringifyOptions = { delimiter: \"&\", encode: false };\r\n queryStr = stringify(options.qs, stringifyOptions);\r\n sareq = sareq.query(queryStr);\r\n fullUrl = `${url}?${queryStr}`;\r\n } else {\r\n fullUrl = url;\r\n }\r\n\r\n Logger.logInfo(loggerCategory, fullUrl);\r\n\r\n if (options.accept)\r\n sareq = sareq.accept(options.accept);\r\n\r\n if (options.body)\r\n sareq = sareq.send(options.body);\r\n\r\n if (options.timeout)\r\n sareq = sareq.timeout(options.timeout);\r\n\r\n if (options.responseType)\r\n sareq = sareq.responseType(options.responseType);\r\n\r\n if (options.redirects)\r\n sareq = sareq.redirects(options.redirects);\r\n else\r\n sareq = sareq.redirects(0);\r\n\r\n if (options.buffer)\r\n sareq = sareq.buffer(options.buffer);\r\n\r\n if (options.parser)\r\n sareq = sareq.parse(options.parser);\r\n\r\n /** Default to any globally supplied proxy, unless an agent is specified in this call */\r\n if (options.agent)\r\n sareq = sareq.agent(options.agent);\r\n\r\n if (options.progressCallback) {\r\n sareq = sareq.on(\"progress\", (event: sarequest.ProgressEvent) => {\r\n if (event) {\r\n options.progressCallback!({\r\n loaded: event.loaded,\r\n total: event.total,\r\n percent: event.percent,\r\n });\r\n }\r\n });\r\n }\r\n\r\n const errorCallback = options.errorCallback ? options.errorCallback : ResponseError.parse;\r\n\r\n if (options.readStream) {\r\n if (typeof window !== \"undefined\")\r\n throw new Error(\"This option is not supported on browsers\");\r\n\r\n return new Promise<Response>((resolve, reject) => {\r\n sareq = sareq.type(\"blob\");\r\n options\r\n .readStream\r\n .pipe(sareq)\r\n .on(\"error\", (error: any) => {\r\n const parsedError = errorCallback(error);\r\n reject(parsedError);\r\n })\r\n .on(\"end\", () => {\r\n const retResponse: Response = {\r\n status: 201,\r\n header: undefined,\r\n body: undefined,\r\n text: undefined,\r\n };\r\n resolve(retResponse);\r\n });\r\n });\r\n }\r\n\r\n if (options.stream) {\r\n if (typeof window !== \"undefined\")\r\n throw new Error(\"This option is not supported on browsers\");\r\n\r\n return new Promise<Response>((resolve, reject) => {\r\n sareq\r\n .on(\"response\", (res: any) => {\r\n if (res.statusCode !== 200) {\r\n const parsedError = errorCallback(res);\r\n reject(parsedError);\r\n return;\r\n }\r\n })\r\n .pipe(options.stream)\r\n .on(\"error\", (error: any) => {\r\n const parsedError = errorCallback(error);\r\n reject(parsedError);\r\n })\r\n .on(\"finish\", () => {\r\n const retResponse: Response = {\r\n status: 200,\r\n header: undefined,\r\n body: undefined,\r\n text: undefined,\r\n };\r\n resolve(retResponse);\r\n });\r\n });\r\n }\r\n\r\n // console.log(\"%s %s %s\", url, options.method, queryStr);\r\n\r\n /**\r\n * Note:\r\n * Javascript's fetch returns status.OK if error is between 200-299 inclusive, and doesn't reject in this case.\r\n * Fetch only rejects if there's some network issue (permissions issue or similar)\r\n * Superagent rejects network issues, and errors outside the range of 200-299. We are currently using\r\n * superagent, but may eventually switch to JavaScript's fetch library.\r\n */\r\n try {\r\n const response = await sareq;\r\n const retResponse: Response = {\r\n body: response.body,\r\n text: response.text,\r\n header: response.header,\r\n status: response.status,\r\n };\r\n return retResponse;\r\n } catch (error) {\r\n const parsedError = errorCallback(error);\r\n throw parsedError;\r\n }\r\n}\r\n\r\n/**\r\n * fetch json from HTTP request\r\n * @param url server URL to address the request\r\n * @internal\r\n */\r\nexport async function getJson(url: string): Promise<any> {\r\n const options: RequestOptions = {\r\n method: \"GET\",\r\n responseType: \"json\",\r\n };\r\n const data = await request(url, options);\r\n return data.body;\r\n}\r\n"]}
1
+ {"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/backend/Request.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,4BAA4B;AAE5B,wCAAwC;AACxC,sDAAsG;AAEtG,MAAM,cAAc,GAAW,6BAA6B,CAAC;AAE7D,gBAAgB;AACH,QAAA,mBAAmB,GAAG,kBAAkB,CAAC;AAoEtD;;GAEG;AACH,MAAa,aAAc,SAAQ,2BAAY;IAI7C,YAAmB,WAAgC,EAAE,OAAgB,EAAE,WAAiC;QACtG,KAAK,CAAC,WAAW,EAAE,OA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,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,OAAO,GAAmB;QAC9B,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,MAAM;KACrB,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAPD,0BAOC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iTwinServiceClients\n */\nimport * as _ from \"lodash\";\nimport * as https from \"https\";\nimport * as sarequest from \"superagent\";\nimport { BentleyError, GetMetaDataFunction, HttpStatus, Logger, LogLevel } from \"@itwin/core-bentley\";\n\nconst loggerCategory: string = \"core-mobile-backend.Request\";\n\n/** @internal */\nexport const requestIdHeaderName = \"X-Correlation-Id\";\n\n/** @internal */\nexport interface RequestQueryStringifyOptions {\n delimiter?: string;\n encode?: boolean;\n}\n\n/** Option to control the time outs\n * Use a short response timeout to detect unresponsive networks quickly, and a long deadline to give time for downloads on slow,\n * but reliable, networks. Note that both of these timers limit how long uploads of attached files are allowed to take. Use long\n * timeouts if you're uploading files.\n * @internal\n */\nexport interface RequestTimeoutOptions {\n /** Sets a deadline (in milliseconds) for the entire request (including all uploads, redirects, server processing time) to complete.\n * If the response isn't fully downloaded within that time, the request will be aborted\n */\n deadline?: number;\n\n /** Sets maximum time (in milliseconds) to wait for the first byte to arrive from the server, but it does not limit how long the entire\n * download can take. Response timeout should be at least few seconds longer than just the time it takes the server to respond, because\n * it also includes time to make DNS lookup, TCP/IP and TLS connections, and time to upload request data.\n */\n response?: number;\n}\n\n/** @internal */\nexport interface RequestOptions {\n method: string;\n headers?: any; // {Mas-App-Guid, Mas-UUid, User-Agent}\n body?: any;\n responseType?: string;\n timeout?: RequestTimeoutOptions; // Optional timeouts. If unspecified, an arbitrary default is setup.\n stream?: any; // Optional stream to read the response to/from (only for NodeJs applications)\n readStream?: any; // Optional stream to read input from (only for NodeJs applications)\n buffer?: any;\n parser?: any;\n accept?: string;\n redirects?: number;\n errorCallback?: (response: any) => ResponseError;\n retryCallback?: (error: any, response: any) => boolean;\n progressCallback?: ProgressCallback;\n agent?: https.Agent;\n retries?: number;\n useCorsProxy?: boolean;\n}\n\n/** Response object if the request was successful. Note that the status within the range of 200-299 are considered as a success.\n * @internal\n */\nexport interface Response {\n body: any; // Parsed body of response\n text: string | undefined; // Returned for responseType:text\n header: any; // Parsed headers of response\n status: number; // Status code of response\n}\n\n/** @internal */\nexport interface ProgressInfo {\n percent?: number;\n total?: number;\n loaded: number;\n}\n\n/** @internal */\nexport type ProgressCallback = (progress: ProgressInfo) => void;\n\n/** Error object that's thrown/rejected if the Request fails due to a network error, or if the status is *not* in the range of 200-299 (inclusive)\n * @internal\n */\nexport class ResponseError extends BentleyError {\n protected _data?: any;\n public status?: number;\n public description?: string;\n public constructor(errorNumber: number | HttpStatus, message?: string, getMetaData?: GetMetaDataFunction) {\n super(errorNumber, message, getMetaData);\n }\n\n /**\n * Parses error from server's response\n * @param response Http response from the server.\n * @returns Parsed error.\n * @internal\n */\n public static parse(response: any, log = true): ResponseError {\n const error = new ResponseError(ResponseError.parseHttpStatus(response.statusType));\n if (!response) {\n error.message = \"Couldn't get response object.\";\n return error;\n }\n\n if (response.response) {\n if (response.response.error) {\n error.name = response.response.error.name || error.name;\n error.description = response.response.error.message;\n }\n if (response.response.res) {\n error.message = response.response.res.statusMessage;\n }\n if (response.response.body && Object.keys(response.response.body).length > 0) {\n error._data = {};\n _.merge(error._data, response.response.body);\n } else {\n error._data = response.response.text;\n }\n }\n\n error.status = response.status || response.statusCode;\n error.name = response.code || response.name || error.name;\n error.message = error.message || response.message || response.statusMessage;\n\n if (log)\n error.log();\n\n return error;\n }\n\n /**\n * Decides whether request should be retried or not\n * @param error Error returned by request\n * @param response Response returned by request\n * @internal\n */\n public static shouldRetry(error: any, response: any): boolean {\n if (error !== undefined && error !== null) {\n if ((error.status === undefined || error.status === null) && (error.res === undefined || error.res === null)) {\n return true;\n }\n }\n return (response !== undefined && response.statusType === HttpStatus.ServerError);\n }\n\n /**\n * @internal\n */\n public static parseHttpStatus(statusType: number): HttpStatus {\n switch (statusType) {\n case 1:\n return HttpStatus.Info;\n case 2:\n return HttpStatus.Success;\n case 3:\n return HttpStatus.Redirection;\n case 4:\n return HttpStatus.ClientError;\n case 5:\n return HttpStatus.ServerError;\n default:\n return HttpStatus.Success;\n }\n }\n\n /**\n * @internal\n */\n public logMessage(): string {\n return `${this.status} ${this.name}: ${this.message}`;\n }\n\n /**\n * Logs this error\n * @internal\n */\n public log(): void {\n Logger.logError(loggerCategory, this.logMessage(), () => this.getMetaData());\n }\n}\n\nconst logResponse = (req: sarequest.SuperAgentRequest, startTime: number) => (res: sarequest.Response) => {\n const elapsed = new Date().getTime() - startTime;\n const elapsedTime = `${elapsed}ms`;\n Logger.logTrace(loggerCategory, `${req.method.toUpperCase()} ${res.status} ${req.url} (${elapsedTime})`);\n};\n\n// eslint-disable-next-line @typescript-eslint/promise-function-async\nconst logRequest = (req: sarequest.SuperAgentRequest): sarequest.SuperAgentRequest => {\n const startTime = new Date().getTime();\n return req.on(\"response\", logResponse(req, startTime));\n};\n\n/** Wrapper around making HTTP requests with the specific options.\n *\n * Usable in both a browser and node based environment.\n *\n * @param url Server URL to address the request\n * @param options Options to pass to the request\n * @returns Resolves to the response from the server\n * @throws ResponseError if the request fails due to network issues, or if the returned status is *outside* the range of 200-299 (inclusive)\n * @internal\n */\nexport async function request(url: string, options: RequestOptions): Promise<Response> {\n let sareq: sarequest.SuperAgentRequest = sarequest(options.method, url);\n if (options.retries)\n sareq = sareq.retry(options.retries, options.retryCallback);\n\n if (Logger.isEnabled(loggerCategory, LogLevel.Trace))\n sareq = sareq.use(logRequest);\n\n if (options.headers)\n sareq = sareq.set(options.headers);\n\n Logger.logInfo(loggerCategory, url);\n\n if (options.accept)\n sareq = sareq.accept(options.accept);\n\n if (options.body)\n sareq = sareq.send(options.body);\n\n if (options.timeout)\n sareq = sareq.timeout(options.timeout);\n\n if (options.responseType)\n sareq = sareq.responseType(options.responseType);\n\n if (options.redirects)\n sareq = sareq.redirects(options.redirects);\n else\n sareq = sareq.redirects(0);\n\n if (options.buffer)\n sareq = sareq.buffer(options.buffer);\n\n if (options.parser)\n sareq = sareq.parse(options.parser);\n\n /** Default to any globally supplied proxy, unless an agent is specified in this call */\n if (options.agent)\n sareq = sareq.agent(options.agent);\n\n if (options.progressCallback) {\n sareq = sareq.on(\"progress\", (event: sarequest.ProgressEvent) => {\n if (event) {\n options.progressCallback!({\n loaded: event.loaded,\n total: event.total,\n percent: event.percent,\n });\n }\n });\n }\n\n const errorCallback = options.errorCallback ? options.errorCallback : ResponseError.parse;\n\n if (options.readStream) {\n if (typeof window !== \"undefined\")\n throw new Error(\"This option is not supported on browsers\");\n\n return new Promise<Response>((resolve, reject) => {\n sareq = sareq.type(\"blob\");\n options\n .readStream\n .pipe(sareq)\n .on(\"error\", (error: any) => {\n const parsedError = errorCallback(error);\n reject(parsedError);\n })\n .on(\"end\", () => {\n const retResponse: Response = {\n status: 201,\n header: undefined,\n body: undefined,\n text: undefined,\n };\n resolve(retResponse);\n });\n });\n }\n\n if (options.stream) {\n if (typeof window !== \"undefined\")\n throw new Error(\"This option is not supported on browsers\");\n\n return new Promise<Response>((resolve, reject) => {\n sareq\n .on(\"response\", (res: any) => {\n if (res.statusCode !== 200) {\n const parsedError = errorCallback(res);\n reject(parsedError);\n return;\n }\n })\n .pipe(options.stream)\n .on(\"error\", (error: any) => {\n const parsedError = errorCallback(error);\n reject(parsedError);\n })\n .on(\"finish\", () => {\n const retResponse: Response = {\n status: 200,\n header: undefined,\n body: undefined,\n text: undefined,\n };\n resolve(retResponse);\n });\n });\n }\n\n // console.log(\"%s %s %s\", url, options.method, queryStr);\n\n /**\n * Note:\n * Javascript's fetch returns status.OK if error is between 200-299 inclusive, and doesn't reject in this case.\n * Fetch only rejects if there's some network issue (permissions issue or similar)\n * Superagent rejects network issues, and errors outside the range of 200-299. We are currently using\n * superagent, but may eventually switch to JavaScript's fetch library.\n */\n try {\n const response = await sareq;\n const retResponse: Response = {\n body: response.body,\n text: response.text,\n header: response.header,\n status: response.status,\n };\n return retResponse;\n } catch (error) {\n const parsedError = errorCallback(error);\n throw parsedError;\n }\n}\n\n/**\n * fetch json from HTTP request\n * @param url server URL to address the request\n * @internal\n */\nexport async function getJson(url: string): Promise<any> {\n const options: RequestOptions = {\n method: \"GET\",\n responseType: \"json\",\n };\n const data = await request(url, options);\n return data.body;\n}\n"]}
@@ -1,5 +1,5 @@
1
- /** @internal */
2
- export declare const mobileAppChannel = "mobileApp";
3
- /** @internal */
4
- export declare const mobileAppNotify = "mobileApp-notify";
1
+ /** @internal */
2
+ export declare const mobileAppChannel = "mobileApp";
3
+ /** @internal */
4
+ export declare const mobileAppNotify = "mobileApp-notify";
5
5
  //# sourceMappingURL=MobileAppChannel.d.ts.map
@@ -1,12 +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";
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
12
  //# sourceMappingURL=MobileAppChannel.js.map
@@ -1 +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
+ {"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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @internal */\nexport const mobileAppChannel = \"mobileApp\";\n/** @internal */\nexport const mobileAppNotify = \"mobileApp-notify\";\n"]}
@@ -1,36 +1,36 @@
1
- import { AccessToken } from "@itwin/core-bentley";
2
- /** @beta */
3
- export declare enum Orientation {
4
- Unknown = 0,
5
- Portrait = 1,
6
- PortraitUpsideDown = 2,
7
- LandscapeLeft = 4,
8
- LandscapeRight = 8,
9
- FaceUp = 16,
10
- FaceDown = 32
11
- }
12
- /** @beta */
13
- export declare enum BatteryState {
14
- Unknown = 0,
15
- Unplugged = 1,
16
- Charging = 2,
17
- Full = 3
18
- }
19
- /** @beta */
20
- export interface MobileNotifications {
21
- notifyMemoryWarning: () => void;
22
- notifyOrientationChanged: () => void;
23
- notifyWillTerminate: () => void;
24
- notifyAuthAccessTokenChanged: (accessToken: string | undefined, expirationDate: string | undefined) => void;
25
- }
26
- /** @beta */
27
- export declare type DeviceEvents = "memoryWarning" | "orientationChanged" | "enterForeground" | "enterBackground" | "willTerminate" | "authAccessTokenChanged";
28
- /**
29
- * The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.
30
- * @beta
31
- */
32
- export interface MobileAppFunctions {
33
- reconnect: (connection: number) => Promise<void>;
34
- getAccessToken: () => Promise<[AccessToken, string]>;
35
- }
1
+ import { AccessToken } from "@itwin/core-bentley";
2
+ /** @beta */
3
+ export declare enum Orientation {
4
+ Unknown = 0,
5
+ Portrait = 1,
6
+ PortraitUpsideDown = 2,
7
+ LandscapeLeft = 4,
8
+ LandscapeRight = 8,
9
+ FaceUp = 16,
10
+ FaceDown = 32
11
+ }
12
+ /** @beta */
13
+ export declare enum BatteryState {
14
+ Unknown = 0,
15
+ Unplugged = 1,
16
+ Charging = 2,
17
+ Full = 3
18
+ }
19
+ /** @beta */
20
+ export interface MobileNotifications {
21
+ notifyMemoryWarning: () => void;
22
+ notifyOrientationChanged: () => void;
23
+ notifyWillTerminate: () => void;
24
+ notifyAuthAccessTokenChanged: (accessToken: string | undefined, expirationDate: string | undefined) => void;
25
+ }
26
+ /** @beta */
27
+ export type DeviceEvents = "memoryWarning" | "orientationChanged" | "enterForeground" | "enterBackground" | "willTerminate" | "authAccessTokenChanged";
28
+ /**
29
+ * The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.
30
+ * @beta
31
+ */
32
+ export interface MobileAppFunctions {
33
+ reconnect: (connection: number) => Promise<void>;
34
+ getAccessToken: () => Promise<[AccessToken, string]>;
35
+ }
36
36
  //# sourceMappingURL=MobileAppProps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAppProps.d.ts","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,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,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,4BAA4B,EAAE,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,cAAc,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC7G;AAED,YAAY;AACZ,oBAAY,YAAY,GAAG,eAAe,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,eAAe,GAAG,wBAAwB,CAAC;AAEvJ;;;EAGE;AACF,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,cAAc,EAAE,MAAM,OAAO,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD"}
1
+ {"version":3,"file":"MobileAppProps.d.ts","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,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,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,4BAA4B,EAAE,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,cAAc,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC7G;AAED,YAAY;AACZ,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,eAAe,GAAG,wBAAwB,CAAC;AAEvJ;;;EAGE;AACF,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,cAAc,EAAE,MAAM,OAAO,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD"}
@@ -1,27 +1,27 @@
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.BatteryState = exports.Orientation = void 0;
8
- /** @beta */
9
- var Orientation;
10
- (function (Orientation) {
11
- Orientation[Orientation["Unknown"] = 0] = "Unknown";
12
- Orientation[Orientation["Portrait"] = 1] = "Portrait";
13
- Orientation[Orientation["PortraitUpsideDown"] = 2] = "PortraitUpsideDown";
14
- Orientation[Orientation["LandscapeLeft"] = 4] = "LandscapeLeft";
15
- Orientation[Orientation["LandscapeRight"] = 8] = "LandscapeRight";
16
- Orientation[Orientation["FaceUp"] = 16] = "FaceUp";
17
- Orientation[Orientation["FaceDown"] = 32] = "FaceDown";
18
- })(Orientation = exports.Orientation || (exports.Orientation = {}));
19
- /** @beta */
20
- var BatteryState;
21
- (function (BatteryState) {
22
- BatteryState[BatteryState["Unknown"] = 0] = "Unknown";
23
- BatteryState[BatteryState["Unplugged"] = 1] = "Unplugged";
24
- BatteryState[BatteryState["Charging"] = 2] = "Charging";
25
- BatteryState[BatteryState["Full"] = 3] = "Full";
26
- })(BatteryState = exports.BatteryState || (exports.BatteryState = {}));
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.BatteryState = exports.Orientation = void 0;
8
+ /** @beta */
9
+ var Orientation;
10
+ (function (Orientation) {
11
+ Orientation[Orientation["Unknown"] = 0] = "Unknown";
12
+ Orientation[Orientation["Portrait"] = 1] = "Portrait";
13
+ Orientation[Orientation["PortraitUpsideDown"] = 2] = "PortraitUpsideDown";
14
+ Orientation[Orientation["LandscapeLeft"] = 4] = "LandscapeLeft";
15
+ Orientation[Orientation["LandscapeRight"] = 8] = "LandscapeRight";
16
+ Orientation[Orientation["FaceUp"] = 16] = "FaceUp";
17
+ Orientation[Orientation["FaceDown"] = 32] = "FaceDown";
18
+ })(Orientation = exports.Orientation || (exports.Orientation = {}));
19
+ /** @beta */
20
+ var BatteryState;
21
+ (function (BatteryState) {
22
+ BatteryState[BatteryState["Unknown"] = 0] = "Unknown";
23
+ BatteryState[BatteryState["Unplugged"] = 1] = "Unplugged";
24
+ BatteryState[BatteryState["Charging"] = 2] = "Charging";
25
+ BatteryState[BatteryState["Full"] = 3] = "Full";
26
+ })(BatteryState = exports.BatteryState || (exports.BatteryState = {}));
27
27
  //# sourceMappingURL=MobileAppProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileAppProps.js","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAI/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\nimport { AccessToken } from \"@itwin/core-bentley\";\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 notifyWillTerminate: () => void;\r\n notifyAuthAccessTokenChanged: (accessToken: string | undefined, expirationDate: string | undefined) => void;\r\n}\r\n\r\n/** @beta */\r\nexport type DeviceEvents = \"memoryWarning\" | \"orientationChanged\" | \"enterForeground\" | \"enterBackground\" | \"willTerminate\" | \"authAccessTokenChanged\";\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 getAccessToken: () => Promise<[AccessToken, string]>;\r\n}\r\n"]}
1
+ {"version":3,"file":"MobileAppProps.js","sourceRoot":"","sources":["../../../src/common/MobileAppProps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAI/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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { AccessToken } from \"@itwin/core-bentley\";\n\n/** @beta */\nexport enum Orientation {\n Unknown = 0,\n Portrait = 0x1,\n PortraitUpsideDown = 0x2,\n LandscapeLeft = 0x4,\n LandscapeRight = 0x8,\n FaceUp = 0x10,\n FaceDown = 0x20,\n}\n\n/** @beta */\nexport enum BatteryState {\n Unknown = 0,\n Unplugged = 1,\n Charging = 2,\n Full = 3,\n}\n\n/** @beta */\nexport interface MobileNotifications {\n notifyMemoryWarning: () => void;\n notifyOrientationChanged: () => void;\n notifyWillTerminate: () => void;\n notifyAuthAccessTokenChanged: (accessToken: string | undefined, expirationDate: string | undefined) => void;\n}\n\n/** @beta */\nexport type DeviceEvents = \"memoryWarning\" | \"orientationChanged\" | \"enterForeground\" | \"enterBackground\" | \"willTerminate\" | \"authAccessTokenChanged\";\n\n/**\n* The methods that may be invoked via Ipc from the frontend of a Mobile App that are implemented on its backend.\n* @beta\n*/\nexport interface MobileAppFunctions {\n reconnect: (connection: number) => Promise<void>;\n getAccessToken: () => Promise<[AccessToken, string]>;\n}\n"]}
@@ -1,12 +1,12 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
- /** @internal */
5
- export declare class MobileEventLoop {
6
- private static _activeTasks;
7
- private static _idleCallback;
8
- static addTask(): void;
9
- static removeTask(): void;
10
- private static _idleHandler;
11
- }
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ /** @internal */
5
+ export declare class MobileEventLoop {
6
+ private static _activeTasks;
7
+ private static _idleCallback;
8
+ static addTask(): void;
9
+ static removeTask(): void;
10
+ private static _idleHandler;
11
+ }
12
12
  //# sourceMappingURL=MobileEventLoop.d.ts.map
@@ -1,31 +1,31 @@
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
- /** @packageDocumentation
7
- * @module RpcInterface
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.MobileEventLoop = void 0;
11
- /** @internal */
12
- class MobileEventLoop {
13
- static addTask() {
14
- ++this._activeTasks;
15
- if (this._idleCallback === null) {
16
- this._idleCallback = setInterval(() => this._idleHandler());
17
- }
18
- }
19
- static removeTask() {
20
- --this._activeTasks;
21
- if (this._activeTasks === 0 && this._idleCallback !== null) {
22
- clearInterval(this._idleCallback);
23
- this._idleCallback = null;
24
- }
25
- }
26
- static _idleHandler() { }
27
- }
28
- exports.MobileEventLoop = MobileEventLoop;
29
- MobileEventLoop._activeTasks = 0;
30
- MobileEventLoop._idleCallback = null;
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
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MobileEventLoop = void 0;
11
+ /** @internal */
12
+ class MobileEventLoop {
13
+ static addTask() {
14
+ ++this._activeTasks;
15
+ if (this._idleCallback === null) {
16
+ this._idleCallback = setInterval(() => this._idleHandler());
17
+ }
18
+ }
19
+ static removeTask() {
20
+ --this._activeTasks;
21
+ if (this._activeTasks === 0 && this._idleCallback !== null) {
22
+ clearInterval(this._idleCallback);
23
+ this._idleCallback = null;
24
+ }
25
+ }
26
+ static _idleHandler() { }
27
+ }
28
+ MobileEventLoop._activeTasks = 0;
29
+ MobileEventLoop._idleCallback = null;
30
+ exports.MobileEventLoop = MobileEventLoop;
31
31
  //# sourceMappingURL=MobileEventLoop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileEventLoop.js","sourceRoot":"","sources":["../../../src/common/MobileEventLoop.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gBAAgB;AAChB,MAAa,eAAe;IAInB,MAAM,CAAC,OAAO;QACnB,EAAE,IAAI,CAAC,YAAY,CAAC;QAEpB,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE;YAC/B,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;SAC7D;IACH,CAAC;IAEM,MAAM,CAAC,UAAU;QACtB,EAAE,IAAI,CAAC,YAAY,CAAC;QAEpB,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE;YAC1D,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC3B;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,KAAK,CAAC;;AArBnC,0CAsBC;AArBgB,4BAAY,GAAG,CAAC,CAAC;AACjB,6BAAa,GAAwB,IAAI,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 RpcInterface\r\n */\r\n\r\n/** @internal */\r\nexport class MobileEventLoop {\r\n private static _activeTasks = 0;\r\n private static _idleCallback: NodeJS.Timer | null = null;\r\n\r\n public static addTask() {\r\n ++this._activeTasks;\r\n\r\n if (this._idleCallback === null) {\r\n this._idleCallback = setInterval(() => this._idleHandler());\r\n }\r\n }\r\n\r\n public static removeTask() {\r\n --this._activeTasks;\r\n\r\n if (this._activeTasks === 0 && this._idleCallback !== null) {\r\n clearInterval(this._idleCallback);\r\n this._idleCallback = null;\r\n }\r\n }\r\n\r\n private static _idleHandler() { }\r\n}\r\n"]}
1
+ {"version":3,"file":"MobileEventLoop.js","sourceRoot":"","sources":["../../../src/common/MobileEventLoop.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gBAAgB;AAChB,MAAa,eAAe;IAInB,MAAM,CAAC,OAAO;QACnB,EAAE,IAAI,CAAC,YAAY,CAAC;QAEpB,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE;YAC/B,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;SAC7D;IACH,CAAC;IAEM,MAAM,CAAC,UAAU;QACtB,EAAE,IAAI,CAAC,YAAY,CAAC;QAEpB,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE;YAC1D,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC3B;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,KAAK,CAAC;;AApBlB,4BAAY,GAAG,CAAC,CAAC;AACjB,6BAAa,GAAwB,IAAI,CAAC;AAF9C,0CAAe","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\n/** @internal */\nexport class MobileEventLoop {\n private static _activeTasks = 0;\n private static _idleCallback: NodeJS.Timer | null = null;\n\n public static addTask() {\n ++this._activeTasks;\n\n if (this._idleCallback === null) {\n this._idleCallback = setInterval(() => this._idleHandler());\n }\n }\n\n public static removeTask() {\n --this._activeTasks;\n\n if (this._activeTasks === 0 && this._idleCallback !== null) {\n clearInterval(this._idleCallback);\n this._idleCallback = null;\n }\n }\n\n private static _idleHandler() { }\n}\n"]}
@@ -1,18 +1,18 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
- import { IpcWebSocketMessage, IpcWebSocketTransport, RpcRequestFulfillment, SerializedRpcRequest } from "@itwin/core-common";
5
- import { MobileRpcProtocol } from "./MobileRpcProtocol";
6
- /** @internal */
7
- export declare class MobileIpcTransport extends IpcWebSocketTransport {
8
- private _protocol;
9
- private _client;
10
- constructor(protocol: MobileRpcProtocol);
11
- send(message: IpcWebSocketMessage): void;
12
- consumeRequest(request: SerializedRpcRequest): boolean;
13
- consumeResponse(response: RpcRequestFulfillment): boolean;
14
- private sendToBackend;
15
- private sendToFrontend;
16
- private broadcast;
17
- }
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { IpcWebSocketMessage, IpcWebSocketTransport, RpcRequestFulfillment, SerializedRpcRequest } from "@itwin/core-common";
5
+ import { MobileRpcProtocol } from "./MobileRpcProtocol";
6
+ /** @internal */
7
+ export declare class MobileIpcTransport extends IpcWebSocketTransport {
8
+ private _protocol;
9
+ private _client;
10
+ constructor(protocol: MobileRpcProtocol);
11
+ send(message: IpcWebSocketMessage): void;
12
+ consumeRequest(request: SerializedRpcRequest): boolean;
13
+ consumeResponse(response: RpcRequestFulfillment): boolean;
14
+ private sendToBackend;
15
+ private sendToFrontend;
16
+ private broadcast;
17
+ }
18
18
  //# sourceMappingURL=MobileIpc.d.ts.map
@@ -1,71 +1,71 @@
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
- /** @packageDocumentation
7
- * @module RpcInterface
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.MobileIpcTransport = void 0;
11
- const core_common_1 = require("@itwin/core-common");
12
- const MobileEventLoop_1 = require("./MobileEventLoop");
13
- const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
14
- const MobileRpcRequest_1 = require("./MobileRpcRequest");
15
- const IPC = "__ipc__";
16
- class IpcInterface extends core_common_1.RpcInterface {
17
- async send() { }
18
- }
19
- IpcInterface.interfaceName = IPC;
20
- IpcInterface.interfaceVersion = "0.0.0";
21
- /** @internal */
22
- class MobileIpcTransport extends core_common_1.IpcWebSocketTransport {
23
- constructor(protocol) {
24
- super();
25
- this._protocol = protocol;
26
- core_common_1.RpcManager.initializeInterface(IpcInterface);
27
- this._client = core_common_1.RpcManager.getClientForInterface(IpcInterface);
28
- }
29
- send(message) {
30
- if (message.type === core_common_1.IpcWebSocketMessageType.Send || message.type === core_common_1.IpcWebSocketMessageType.Invoke) {
31
- this.sendToBackend(message); // eslint-disable-line @typescript-eslint/no-floating-promises
32
- }
33
- else if (message.type === core_common_1.IpcWebSocketMessageType.Push || message.type === core_common_1.IpcWebSocketMessageType.Response) {
34
- this.sendToFrontend(message); // eslint-disable-line @typescript-eslint/no-floating-promises
35
- }
36
- }
37
- consumeRequest(request) {
38
- if (request.operation.interfaceDefinition !== IPC)
39
- return false;
40
- const message = core_common_1.RpcMarshaling.deserialize(this._protocol, request.parameters)[0];
41
- this.broadcast({}, message);
42
- return true;
43
- }
44
- consumeResponse(response) {
45
- if (response.interfaceName !== IPC)
46
- return false;
47
- const message = core_common_1.RpcMarshaling.deserialize(this._protocol, response.result);
48
- this.broadcast({}, message);
49
- return true;
50
- }
51
- async sendToBackend(message) {
52
- const request = new MobileRpcRequest_1.MobileRpcRequest(this._client, "send", [message]);
53
- const encoded = await MobileRpcProtocol_1.MobileRpcProtocol.encodeRequest(request);
54
- this._protocol.sendToBackend(encoded);
55
- request.dispose();
56
- }
57
- async sendToFrontend(message) {
58
- MobileEventLoop_1.MobileEventLoop.addTask();
59
- const result = await core_common_1.RpcMarshaling.serialize(this._protocol, message);
60
- MobileEventLoop_1.MobileEventLoop.removeTask();
61
- const fulfillment = { result, rawResult: message, interfaceName: IPC, id: message.channel, status: 0 };
62
- const encoded = MobileRpcProtocol_1.MobileRpcProtocol.encodeResponse(fulfillment);
63
- this._protocol.sendToFrontend(encoded);
64
- }
65
- broadcast(evt, message) {
66
- for (const listener of core_common_1.IpcWebSocket.receivers)
67
- listener(evt, message);
68
- }
69
- }
70
- exports.MobileIpcTransport = MobileIpcTransport;
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
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MobileIpcTransport = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const MobileEventLoop_1 = require("./MobileEventLoop");
13
+ const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
14
+ const MobileRpcRequest_1 = require("./MobileRpcRequest");
15
+ const IPC = "__ipc__";
16
+ class IpcInterface extends core_common_1.RpcInterface {
17
+ async send() { }
18
+ }
19
+ IpcInterface.interfaceName = IPC;
20
+ IpcInterface.interfaceVersion = "0.0.0";
21
+ /** @internal */
22
+ class MobileIpcTransport extends core_common_1.IpcWebSocketTransport {
23
+ constructor(protocol) {
24
+ super();
25
+ this._protocol = protocol;
26
+ core_common_1.RpcManager.initializeInterface(IpcInterface);
27
+ this._client = core_common_1.RpcManager.getClientForInterface(IpcInterface);
28
+ }
29
+ send(message) {
30
+ if (message.type === core_common_1.IpcWebSocketMessageType.Send || message.type === core_common_1.IpcWebSocketMessageType.Invoke) {
31
+ this.sendToBackend(message); // eslint-disable-line @typescript-eslint/no-floating-promises
32
+ }
33
+ else if (message.type === core_common_1.IpcWebSocketMessageType.Push || message.type === core_common_1.IpcWebSocketMessageType.Response) {
34
+ this.sendToFrontend(message); // eslint-disable-line @typescript-eslint/no-floating-promises
35
+ }
36
+ }
37
+ consumeRequest(request) {
38
+ if (request.operation.interfaceDefinition !== IPC)
39
+ return false;
40
+ const message = core_common_1.RpcMarshaling.deserialize(this._protocol, request.parameters)[0];
41
+ this.broadcast({}, message);
42
+ return true;
43
+ }
44
+ consumeResponse(response) {
45
+ if (response.interfaceName !== IPC)
46
+ return false;
47
+ const message = core_common_1.RpcMarshaling.deserialize(this._protocol, response.result);
48
+ this.broadcast({}, message);
49
+ return true;
50
+ }
51
+ async sendToBackend(message) {
52
+ const request = new MobileRpcRequest_1.MobileRpcRequest(this._client, "send", [message]);
53
+ const encoded = await MobileRpcProtocol_1.MobileRpcProtocol.encodeRequest(request);
54
+ this._protocol.sendToBackend(encoded);
55
+ request.dispose();
56
+ }
57
+ async sendToFrontend(message) {
58
+ MobileEventLoop_1.MobileEventLoop.addTask();
59
+ const result = await core_common_1.RpcMarshaling.serialize(this._protocol, message);
60
+ MobileEventLoop_1.MobileEventLoop.removeTask();
61
+ const fulfillment = { result, rawResult: message, interfaceName: IPC, id: message.channel, status: 0 };
62
+ const encoded = MobileRpcProtocol_1.MobileRpcProtocol.encodeResponse(fulfillment);
63
+ this._protocol.sendToFrontend(encoded);
64
+ }
65
+ broadcast(evt, message) {
66
+ for (const listener of core_common_1.IpcWebSocket.receivers)
67
+ listener(evt, message);
68
+ }
69
+ }
70
+ exports.MobileIpcTransport = MobileIpcTransport;
71
71
  //# sourceMappingURL=MobileIpc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MobileIpc.js","sourceRoot":"","sources":["../../../src/common/MobileIpc.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAG4B;AAC5B,uDAAoD;AACpD,2DAAwD;AACxD,yDAAsD;AAEtD,MAAM,GAAG,GAAG,SAAS,CAAC;AAEtB,MAAM,YAAa,SAAQ,0BAAY;IAG9B,KAAK,CAAC,IAAI,KAAK,CAAC;;AAFT,0BAAa,GAAG,GAAG,CAAC;AACpB,6BAAgB,GAAG,OAAO,CAAC;AAI3C,gBAAgB;AAChB,MAAa,kBAAmB,SAAQ,mCAAqB;IAI3D,YAAmB,QAA2B;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,wBAAU,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,wBAAU,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAChE,CAAC;IAEM,IAAI,CAAC,OAA4B;QACtC,IAAI,OAAO,CAAC,IAAI,KAAK,qCAAuB,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,qCAAuB,CAAC,MAAM,EAAE;YACpG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,8DAA8D;SAC5F;aAAM,IAAI,OAAO,CAAC,IAAI,KAAK,qCAAuB,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,qCAAuB,C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AAe,CAAC,UAAU,EAAE,CAAC;QAE7B,MAAM,WAAW,GAA0B,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC9H,MAAM,OAAO,GAAG,qCAAiB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,SAAS,CAAC,GAAU,EAAE,OAA4B;QACxD,KAAK,MAAM,QAAQ,IAAI,0BAAY,CAAC,SAAS;YAC3C,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AA3DD,gDA2DC","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 RpcInterface\r\n */\r\n\r\nimport {\r\n IpcWebSocket, IpcWebSocketMessage, IpcWebSocketMessageType, IpcWebSocketTransport, RpcInterface, RpcManager, RpcMarshaling, RpcRequestFulfillment,\r\n SerializedRpcRequest,\r\n} from \"@itwin/core-common\";\r\nimport { MobileEventLoop } from \"./MobileEventLoop\";\r\nimport { MobileRpcProtocol } from \"./MobileRpcProtocol\";\r\nimport { MobileRpcRequest } from \"./MobileRpcRequest\";\r\n\r\nconst IPC = \"__ipc__\";\r\n\r\nclass IpcInterface extends RpcInterface { // eslint-disable-line deprecation/deprecation\r\n public static interfaceName = IPC;\r\n public static interfaceVersion = \"0.0.0\";\r\n public async send() { }\r\n}\r\n\r\n/** @internal */\r\nexport class MobileIpcTransport extends IpcWebSocketTransport {\r\n private _protocol: MobileRpcProtocol;\r\n private _client: IpcInterface;\r\n\r\n public constructor(protocol: MobileRpcProtocol) {\r\n super();\r\n this._protocol = protocol;\r\n\r\n RpcManager.initializeInterface(IpcInterface);\r\n this._client = RpcManager.getClientForInterface(IpcInterface);\r\n }\r\n\r\n public send(message: IpcWebSocketMessage): void {\r\n if (message.type === IpcWebSocketMessageType.Send || message.type === IpcWebSocketMessageType.Invoke) {\r\n this.sendToBackend(message); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n } else if (message.type === IpcWebSocketMessageType.Push || message.type === IpcWebSocketMessageType.Response) {\r\n this.sendToFrontend(message); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n public consumeRequest(request: SerializedRpcRequest): boolean {\r\n if (request.operation.interfaceDefinition !== IPC)\r\n return false;\r\n\r\n const message = RpcMarshaling.deserialize(this._protocol, request.parameters)[0] as IpcWebSocketMessage;\r\n this.broadcast({} as Event, message);\r\n return true;\r\n }\r\n\r\n public consumeResponse(response: RpcRequestFulfillment): boolean {\r\n if (response.interfaceName !== IPC)\r\n return false;\r\n\r\n const message = RpcMarshaling.deserialize(this._protocol, response.result) as IpcWebSocketMessage;\r\n this.broadcast({} as Event, message);\r\n return true;\r\n }\r\n\r\n private async sendToBackend(message: IpcWebSocketMessage) {\r\n const request = new MobileRpcRequest(this._client, \"send\", [message]);\r\n const encoded = await MobileRpcProtocol.encodeRequest(request);\r\n this._protocol.sendToBackend(encoded);\r\n request.dispose();\r\n }\r\n\r\n private async sendToFrontend(message: IpcWebSocketMessage) {\r\n MobileEventLoop.addTask();\r\n const result = await RpcMarshaling.serialize(this._protocol, message);\r\n MobileEventLoop.removeTask();\r\n\r\n const fulfillment: RpcRequestFulfillment = { result, rawResult: message, interfaceName: IPC, id: message.channel, status: 0 };\r\n const encoded = MobileRpcProtocol.encodeResponse(fulfillment);\r\n this._protocol.sendToFrontend(encoded);\r\n }\r\n\r\n private broadcast(evt: Event, message: IpcWebSocketMessage) {\r\n for (const listener of IpcWebSocket.receivers)\r\n listener(evt, message);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Mob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ACzC,CAAC;IAEO,SAAS,CAAC,GAAU,EAAE,OAA4B;QACxD,KAAK,MAAM,QAAQ,IAAI,0BAAY,CAAC,SAAS;YAC3C,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AA3DD,gDA2DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport {\n IpcWebSocket, IpcWebSocketMessage, IpcWebSocketMessageType, IpcWebSocketTransport, RpcInterface, RpcManager, RpcMarshaling, RpcRequestFulfillment,\n SerializedRpcRequest,\n} from \"@itwin/core-common\";\nimport { MobileEventLoop } from \"./MobileEventLoop\";\nimport { MobileRpcProtocol } from \"./MobileRpcProtocol\";\nimport { MobileRpcRequest } from \"./MobileRpcRequest\";\n\nconst IPC = \"__ipc__\";\n\nclass IpcInterface extends RpcInterface { // eslint-disable-line deprecation/deprecation\n public static interfaceName = IPC;\n public static interfaceVersion = \"0.0.0\";\n public async send() { }\n}\n\n/** @internal */\nexport class MobileIpcTransport extends IpcWebSocketTransport {\n private _protocol: MobileRpcProtocol;\n private _client: IpcInterface;\n\n public constructor(protocol: MobileRpcProtocol) {\n super();\n this._protocol = protocol;\n\n RpcManager.initializeInterface(IpcInterface);\n this._client = RpcManager.getClientForInterface(IpcInterface);\n }\n\n public send(message: IpcWebSocketMessage): void {\n if (message.type === IpcWebSocketMessageType.Send || message.type === IpcWebSocketMessageType.Invoke) {\n this.sendToBackend(message); // eslint-disable-line @typescript-eslint/no-floating-promises\n } else if (message.type === IpcWebSocketMessageType.Push || message.type === IpcWebSocketMessageType.Response) {\n this.sendToFrontend(message); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n public consumeRequest(request: SerializedRpcRequest): boolean {\n if (request.operation.interfaceDefinition !== IPC)\n return false;\n\n const message = RpcMarshaling.deserialize(this._protocol, request.parameters)[0] as IpcWebSocketMessage;\n this.broadcast({} as Event, message);\n return true;\n }\n\n public consumeResponse(response: RpcRequestFulfillment): boolean {\n if (response.interfaceName !== IPC)\n return false;\n\n const message = RpcMarshaling.deserialize(this._protocol, response.result) as IpcWebSocketMessage;\n this.broadcast({} as Event, message);\n return true;\n }\n\n private async sendToBackend(message: IpcWebSocketMessage) {\n const request = new MobileRpcRequest(this._client, \"send\", [message]);\n const encoded = await MobileRpcProtocol.encodeRequest(request);\n this._protocol.sendToBackend(encoded);\n request.dispose();\n }\n\n private async sendToFrontend(message: IpcWebSocketMessage) {\n MobileEventLoop.addTask();\n const result = await RpcMarshaling.serialize(this._protocol, message);\n MobileEventLoop.removeTask();\n\n const fulfillment: RpcRequestFulfillment = { result, rawResult: message, interfaceName: IPC, id: message.channel, status: 0 };\n const encoded = MobileRpcProtocol.encodeResponse(fulfillment);\n this._protocol.sendToFrontend(encoded);\n }\n\n private broadcast(evt: Event, message: IpcWebSocketMessage) {\n for (const listener of IpcWebSocket.receivers)\n listener(evt, message);\n }\n}\n"]}