@itwin/core-mobile 3.6.0-dev.59 → 3.6.0-dev.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/lib/cjs/backend/MobileRpcServer.d.ts +1 -1
- package/lib/cjs/backend/MobileRpcServer.d.ts.map +1 -1
- package/lib/cjs/backend/MobileRpcServer.js +1 -1
- package/lib/cjs/backend/MobileRpcServer.js.map +1 -1
- package/lib/cjs/common/MobileIpc.js.map +1 -1
- package/lib/cjs/common/MobilePush.d.ts.map +1 -1
- package/lib/cjs/common/MobilePush.js +1 -0
- package/lib/cjs/common/MobilePush.js.map +1 -1
- package/lib/cjs/common/MobileRpcManager.d.ts +3 -3
- package/lib/cjs/common/MobileRpcManager.d.ts.map +1 -1
- package/lib/cjs/common/MobileRpcManager.js +4 -3
- package/lib/cjs/common/MobileRpcManager.js.map +1 -1
- package/lib/cjs/common/MobileRpcProtocol.d.ts +3 -3
- package/lib/cjs/common/MobileRpcProtocol.d.ts.map +1 -1
- package/lib/cjs/common/MobileRpcProtocol.js +1 -1
- package/lib/cjs/common/MobileRpcProtocol.js.map +1 -1
- package/lib/cjs/common/MobileRpcRequest.d.ts +1 -1
- package/lib/cjs/common/MobileRpcRequest.d.ts.map +1 -1
- package/lib/cjs/common/MobileRpcRequest.js +2 -1
- package/lib/cjs/common/MobileRpcRequest.js.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Change Log - @itwin/core-mobile
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 26 Jan 2023 22:53:27 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.5.5
|
|
6
|
+
Thu, 26 Jan 2023 22:53:27 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 3.5.4
|
|
11
|
+
Wed, 18 Jan 2023 15:27:15 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 3.5.3
|
|
16
|
+
Fri, 13 Jan 2023 17:23:07 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
4
19
|
|
|
5
20
|
## 3.5.2
|
|
6
21
|
Wed, 11 Jan 2023 16:46:30 GMT
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"MobileRpcServer.d.ts","sourceRoot":"","sources":["../../../src/backend/MobileRpcServer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,6BAA6B,CAAC;AAclF,gBAAgB;AAChB,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,SAyD7B"}
|
|
@@ -12,7 +12,7 @@ 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
|
-
/** @
|
|
15
|
+
/** @internal */
|
|
16
16
|
class MobileRpcServer {
|
|
17
17
|
constructor() {
|
|
18
18
|
/* _pingTime is a fix for ios/mobile case where when the app moves into foreground from
|
|
@@ -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,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,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,CAAC,IAAI,CAAC;YAC1B,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,gBAAgB;QACtB,eAAe,CAAC,OAAO,C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AAW,EAAE;YACzC,aAAa,CAAC,YAAY,CAAC,CAAC;YAC5B,YAAY,GAAG,SAAS,CAAC;SAC1B;QAED,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,OAAO;SACR;QAED,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,qCAAiB,CAAC,aAAa,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC;IAChE,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAzDD,wCAyDC","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 /* The UV event loop (internal to node) is retained by handles,\r\n such as those created for setInterval/setTimeout and client/server connections.\r\n In a simple app, the RPC server may be the only handle retaining the UV loop.\r\n Thus, we install a temporary timer on suspend to prevent the loop from exiting prematurely.\r\n */\r\n let retainUvLoop: NodeJS.Timer | undefined;\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 retainUvLoop = setInterval(() => { }, 1000);\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 clearInterval(retainUvLoop);\r\n retainUvLoop = undefined;\r\n });\r\n\r\n MobileHost.onWillTerminate.addListener(() => {\r\n if (typeof (retainUvLoop) !== \"undefined\") {\r\n clearInterval(retainUvLoop);\r\n retainUvLoop = undefined;\r\n }\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 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;AAStD,IAAI,KAA8B,CAAC;AAEnC,gBAAgB;AAChB,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,CAAC,IAAI,CAAC;YAC1B,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,CAAC,CAAC,CAA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G,EAAE;QAC1C,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,WAAW,EAAE;YACzC,aAAa,CAAC,YAAY,CAAC,CAAC;YAC5B,YAAY,GAAG,SAAS,CAAC;SAC1B;QAED,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,OAAO;SACR;QAED,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,qCAAiB,CAAC,aAAa,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC;IAChE,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAzDD,wCAyDC","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\n/* eslint-disable deprecation/deprecation */\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/** @internal */\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 /* The UV event loop (internal to node) is retained by handles,\r\n such as those created for setInterval/setTimeout and client/server connections.\r\n In a simple app, the RPC server may be the only handle retaining the UV loop.\r\n Thus, we install a temporary timer on suspend to prevent the loop from exiting prematurely.\r\n */\r\n let retainUvLoop: NodeJS.Timer | undefined;\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 retainUvLoop = setInterval(() => { }, 1000);\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 clearInterval(retainUvLoop);\r\n retainUvLoop = undefined;\r\n });\r\n\r\n MobileHost.onWillTerminate.addListener(() => {\r\n if (typeof (retainUvLoop) !== \"undefined\") {\r\n clearInterval(retainUvLoop);\r\n retainUvLoop = undefined;\r\n }\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 MobileRpcProtocol.obtainInterop = () => MobileRpcServer.interop;\r\n mobileReady = true;\r\n}\r\n"]}
|
|
@@ -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,CAAC,QAAQ,EAAE;YAC7G,IAAI,CAAC,cAAc,CA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W,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 {\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":"MobileIpc.js","sourceRoot":"","sources":["../../../src/common/MobileIpc.ts"],"names":[],"mappings":";A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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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobilePush.d.ts","sourceRoot":"","sources":["../../../src/common/MobilePush.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiB,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE/H,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"MobilePush.d.ts","sourceRoot":"","sources":["../../../src/common/MobilePush.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiB,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE/H,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMxD,gBAAgB;AAChB,qBAAa,mBAAoB,SAAQ,gBAAgB;IACvD,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,KAAK,CAAc;IAE3B,IAAW,IAAI,WAAyB;gBAErB,QAAQ,EAAE,iBAAiB;IAKvC,OAAO,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO;CAczD;AAED,gBAAgB;AAChB,qBAAa,oBAAoB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC/D,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,KAAK,CAAc;gBAER,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB;IAK9E,IAAI,CAAC,WAAW,EAAE,GAAG;CASnC"}
|
|
@@ -11,6 +11,7 @@ exports.MobilePushConnection = exports.MobilePushTransport = void 0;
|
|
|
11
11
|
const core_common_1 = require("@itwin/core-common");
|
|
12
12
|
const MobileEventLoop_1 = require("./MobileEventLoop");
|
|
13
13
|
const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
|
|
14
|
+
/* eslint-disable deprecation/deprecation */
|
|
14
15
|
const PUSH = "__push__";
|
|
15
16
|
/** @internal */
|
|
16
17
|
class MobilePushTransport extends core_common_1.RpcPushTransport {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobilePush.js","sourceRoot":"","sources":["../../../src/common/MobilePush.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+H;AAC/H,uDAAoD;AACpD,2DAAwD;AAExD,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,gBAAgB;AAChB,MAAa,mBAAoB,SAAQ,8BAAgB;IAMvD,Y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EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9I,MAAM,OAAO,GAAG,qCAAiB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACF;AAlBD,oDAkBC","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 { RpcMarshaling, RpcPushChannel, RpcPushConnection, RpcPushTransport, RpcRequestFulfillment } from \"@itwin/core-common\";\r\nimport { MobileEventLoop } from \"./MobileEventLoop\";\r\nimport { MobileRpcProtocol } from \"./MobileRpcProtocol\";\r\n\r\nconst PUSH = \"__push__\";\r\n\r\n/** @internal */\r\nexport class MobilePushTransport extends RpcPushTransport {\r\n private _protocol: MobileRpcProtocol;\r\n private _last: number = -1;\r\n\r\n public get last() { return this._last; }\r\n\r\n public constructor(protocol: MobileRpcProtocol) {\r\n super();\r\n this._protocol = protocol;\r\n }\r\n\r\n public consume(response: RpcRequestFulfillment): boolean {\r\n if (response.interfaceName !== PUSH) {\r\n return false;\r\n }\r\n\r\n this._last = response.status;\r\n\r\n if (this.onMessage) {\r\n const messageData = RpcMarshaling.deserialize(this._protocol, response.result);\r\n this.onMessage(response.id, messageData);\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class MobilePushConnection<T> extends RpcPushConnection<T> {\r\n private _protocol: MobileRpcProtocol;\r\n private _next: number = -1;\r\n\r\n public constructor(channel: RpcPushChannel<T>, client: unknown, protocol: MobileRpcProtocol) {\r\n super(channel, client);\r\n this._protocol = protocol;\r\n }\r\n\r\n public async send(messageData: any) {\r\n MobileEventLoop.addTask();\r\n const result = await RpcMarshaling.serialize(this._protocol, messageData);\r\n MobileEventLoop.removeTask();\r\n\r\n const fulfillment: RpcRequestFulfillment = { result, rawResult: messageData, interfaceName: PUSH, id: this.channel.id, status: ++this._next };\r\n const encoded = MobileRpcProtocol.encodeResponse(fulfillment);\r\n this._protocol.sendToFrontend(encoded);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MobilePush.js","sourceRoot":"","sources":["../../../src/common/MobilePush.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+H;AAC/H,uDAAoD;AACpD,2DAAwD;AAExD,4CAA4C;AAE5C,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,gBAAgB;AAChB,MAAa,mBAAoB,SAAQ,8BAAgB;IAMvD,YAAmB,QAA2B;QAC5C,KAAK,EAAE,CAAC;QALF,UAAK,GAAW,CAAC,CAAC,CAAC;QAMzB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IALD,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAOjC,OAAO,CAAC,QAA+B;QAC5C,IAAI,QAAQ,CAAC,aAAa,KAAK,IAAI,EAAE;YACnC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;QAE7B,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,MAAM,WAAW,GAAG,2BAAa,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC/E,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;SAC1C;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzBD,kDAyBC;AAED,gBAAgB;AAChB,MAAa,oBAAwB,SAAQ,+BAAoB;IAI/D,YAAmB,OAA0B,EAAE,MAAe,EAAE,QAA2B;QACzF,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAHjB,UAAK,GAAW,CAAC,CAAC,CAAC;QAIzB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAgB;QAChC,iCAAe,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,MAAM,2BAAa,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC1E,iCAAe,CAAC,UAAU,EAAE,CAAC;QAE7B,MAAM,WAAW,GAA0B,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9I,MAAM,OAAO,GAAG,qCAAiB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACF;AAlBD,oDAkBC","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 { RpcMarshaling, RpcPushChannel, RpcPushConnection, RpcPushTransport, RpcRequestFulfillment } from \"@itwin/core-common\";\r\nimport { MobileEventLoop } from \"./MobileEventLoop\";\r\nimport { MobileRpcProtocol } from \"./MobileRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nconst PUSH = \"__push__\";\r\n\r\n/** @internal */\r\nexport class MobilePushTransport extends RpcPushTransport {\r\n private _protocol: MobileRpcProtocol;\r\n private _last: number = -1;\r\n\r\n public get last() { return this._last; }\r\n\r\n public constructor(protocol: MobileRpcProtocol) {\r\n super();\r\n this._protocol = protocol;\r\n }\r\n\r\n public consume(response: RpcRequestFulfillment): boolean {\r\n if (response.interfaceName !== PUSH) {\r\n return false;\r\n }\r\n\r\n this._last = response.status;\r\n\r\n if (this.onMessage) {\r\n const messageData = RpcMarshaling.deserialize(this._protocol, response.result);\r\n this.onMessage(response.id, messageData);\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class MobilePushConnection<T> extends RpcPushConnection<T> {\r\n private _protocol: MobileRpcProtocol;\r\n private _next: number = -1;\r\n\r\n public constructor(channel: RpcPushChannel<T>, client: unknown, protocol: MobileRpcProtocol) {\r\n super(channel, client);\r\n this._protocol = protocol;\r\n }\r\n\r\n public async send(messageData: any) {\r\n MobileEventLoop.addTask();\r\n const result = await RpcMarshaling.serialize(this._protocol, messageData);\r\n MobileEventLoop.removeTask();\r\n\r\n const fulfillment: RpcRequestFulfillment = { result, rawResult: messageData, interfaceName: PUSH, id: this.channel.id, status: ++this._next };\r\n const encoded = MobileRpcProtocol.encodeResponse(fulfillment);\r\n this._protocol.sendToFrontend(encoded);\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RpcConfiguration, RpcInterfaceDefinition } from "@itwin/core-common";
|
|
2
2
|
import { MobileRpcProtocol } from "./MobileRpcProtocol";
|
|
3
3
|
/** RPC supported mobile platforms.
|
|
4
|
-
* @
|
|
4
|
+
* @internal
|
|
5
5
|
*/
|
|
6
6
|
export declare enum RpcMobilePlatform {
|
|
7
7
|
Unknown = 0,
|
|
@@ -9,7 +9,7 @@ export declare enum RpcMobilePlatform {
|
|
|
9
9
|
iOS = 2
|
|
10
10
|
}
|
|
11
11
|
/** Holds configuration for the RpcInterfaces used by the application.
|
|
12
|
-
* @
|
|
12
|
+
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export declare abstract class MobileRpcConfiguration extends RpcConfiguration {
|
|
15
15
|
/** @internal */
|
|
@@ -27,7 +27,7 @@ export declare abstract class MobileRpcConfiguration extends RpcConfiguration {
|
|
|
27
27
|
static get platform(): RpcMobilePlatform;
|
|
28
28
|
}
|
|
29
29
|
/** Coordinates usage of RPC interfaces for an Mobile-based application.
|
|
30
|
-
* @
|
|
30
|
+
* @internal
|
|
31
31
|
*/
|
|
32
32
|
export declare class MobileRpcManager {
|
|
33
33
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileRpcManager.d.ts","sourceRoot":"","sources":["../../../src/common/MobileRpcManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAe,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"MobileRpcManager.d.ts","sourceRoot":"","sources":["../../../src/common/MobileRpcManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAe,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,OAAO,IAAA;IACP,OAAO,IAAA;IACP,GAAG,IAAA;CACJ;AAED;;GAEG;AACH,8BAAsB,sBAAuB,SAAQ,gBAAgB;IACnE,gBAAgB;IAChB,OAAc,KAAK;;;MAGjB;IAEF,SAAyB,QAAQ,EAAE,iBAAiB,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAM;IAC1B,OAAO,CAAC,MAAM,CAAC,OAAO;IAoBtB,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAehC,+BAA+B;IAC/B,WAAkB,IAAI,IAAI,GAAG,CAK5B;IAED,6DAA6D;IAC7D,WAAkB,QAAQ,IAAI,iBAAiB,CAAuD;CACvG;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,gBAAgB;WACI,KAAK;IAUzB,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAgBpC,uEAAuE;WACzD,gBAAgB,CAAC,UAAU,EAAE,sBAAsB,EAAE,GAAG,sBAAsB;IAG5F,sEAAsE;WACxD,cAAc,CAAC,UAAU,EAAE,sBAAsB,EAAE,GAAG,sBAAsB;CAG3F"}
|
|
@@ -7,8 +7,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.MobileRpcManager = exports.MobileRpcConfiguration = exports.RpcMobilePlatform = void 0;
|
|
8
8
|
const core_common_1 = require("@itwin/core-common");
|
|
9
9
|
const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
|
|
10
|
+
/* eslint-disable deprecation/deprecation */
|
|
10
11
|
/** RPC supported mobile platforms.
|
|
11
|
-
* @
|
|
12
|
+
* @internal
|
|
12
13
|
*/
|
|
13
14
|
var RpcMobilePlatform;
|
|
14
15
|
(function (RpcMobilePlatform) {
|
|
@@ -17,7 +18,7 @@ var RpcMobilePlatform;
|
|
|
17
18
|
RpcMobilePlatform[RpcMobilePlatform["iOS"] = 2] = "iOS";
|
|
18
19
|
})(RpcMobilePlatform = exports.RpcMobilePlatform || (exports.RpcMobilePlatform = {}));
|
|
19
20
|
/** Holds configuration for the RpcInterfaces used by the application.
|
|
20
|
-
* @
|
|
21
|
+
* @internal
|
|
21
22
|
*/
|
|
22
23
|
class MobileRpcConfiguration extends core_common_1.RpcConfiguration {
|
|
23
24
|
static getArgs() {
|
|
@@ -70,7 +71,7 @@ MobileRpcConfiguration.setup = {
|
|
|
70
71
|
checkPlatform: () => typeof (process) !== "undefined" && process.platform === "ios",
|
|
71
72
|
};
|
|
72
73
|
/** Coordinates usage of RPC interfaces for an Mobile-based application.
|
|
73
|
-
* @
|
|
74
|
+
* @internal
|
|
74
75
|
*/
|
|
75
76
|
class MobileRpcManager {
|
|
76
77
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileRpcManager.js","sourceRoot":"","sources":["../../../src/common/MobileRpcManager.ts"],"names":[],"mappings":";AAAA;;;+F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ACL,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,UAAoC,EAAE,QAAqB;QAC9F,MAAM,MAAM,GAAG,KAAM,SAAQ,sBAAsB;YAApC;;gBACN,eAAU,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC;gBAC9B,aAAQ,GAAsB,IAAI,qCAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC7E,CAAC;SAAA,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;YAC5B,8BAAgB,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;SAC5C;QAED,MAAM,QAAQ,GAAG,8BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,8BAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,uEAAuE;IAChE,MAAM,CAAC,gBAAgB,CAAC,UAAoC;QACjE,OAAO,gBAAgB,CAAC,qBAAqB,CAAC,UAAU,EAAE,yBAAW,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IACD,sEAAsE;IAC/D,MAAM,CAAC,cAAc,CAAC,UAAoC;QAC/D,OAAO,gBAAgB,CAAC,qBAAqB,CAAC,UAAU,EAAE,yBAAW,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;CACF;AApCD,4CAoCC","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 { RpcConfiguration, RpcEndpoint, RpcInterfaceDefinition } from \"@itwin/core-common\";\r\nimport { MobileRpcProtocol } from \"./MobileRpcProtocol\";\r\n\r\n/** RPC supported mobile platforms.\r\n * @
|
|
1
|
+
{"version":3,"file":"MobileRpcManager.js","sourceRoot":"","sources":["../../../src/common/MobileRpcManager.ts"],"names":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AAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,UAAoC,EAAE,QAAqB;QAC9F,MAAM,MAAM,GAAG,KAAM,SAAQ,sBAAsB;YAApC;;gBACN,eAAU,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC;gBAC9B,aAAQ,GAAsB,IAAI,qCAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC7E,CAAC;SAAA,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;YAC5B,8BAAgB,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;SAC5C;QAED,MAAM,QAAQ,GAAG,8BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,8BAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,uEAAuE;IAChE,MAAM,CAAC,gBAAgB,CAAC,UAAoC;QACjE,OAAO,gBAAgB,CAAC,qBAAqB,CAAC,UAAU,EAAE,yBAAW,CAAC,QAAQ,CAAC,CAAC;IAClF,CAAC;IACD,sEAAsE;IAC/D,MAAM,CAAC,cAAc,CAAC,UAAoC;QAC/D,OAAO,gBAAgB,CAAC,qBAAqB,CAAC,UAAU,EAAE,yBAAW,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;CACF;AApCD,4CAoCC","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 { RpcConfiguration, RpcEndpoint, RpcInterfaceDefinition } from \"@itwin/core-common\";\r\nimport { MobileRpcProtocol } from \"./MobileRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** RPC supported mobile platforms.\r\n * @internal\r\n */\r\nexport enum RpcMobilePlatform {\r\n Unknown,\r\n Android,\r\n iOS,\r\n}\r\n\r\n/** Holds configuration for the RpcInterfaces used by the application.\r\n * @internal\r\n */\r\nexport abstract class MobileRpcConfiguration extends RpcConfiguration {\r\n /** @internal */\r\n public static setup = {\r\n obtainPort: () => 0,\r\n checkPlatform: () => typeof (process) !== \"undefined\" && (process.platform as any) === \"ios\",\r\n };\r\n\r\n public abstract override protocol: MobileRpcProtocol;\r\n private static _args: any;\r\n private static getArgs(): any {\r\n if (typeof window !== \"object\" || typeof window.location !== \"object\" || typeof window.location.hash !== \"string\") {\r\n return Object.freeze({});\r\n }\r\n const queryArgs: any = {};\r\n try {\r\n const matches = window.location.hash.match(/([^#=&]+)(=([^&]*))?/g);\r\n if (matches) {\r\n for (const comp of matches) {\r\n const array = comp.split(\"=\");\r\n if (array.length === 2) {\r\n const key = decodeURIComponent(array[0]);\r\n const val = decodeURIComponent(array[1]);\r\n queryArgs[key] = val;\r\n }\r\n }\r\n }\r\n } catch { }\r\n return Object.freeze(queryArgs);\r\n }\r\n private static getMobilePlatform(): RpcMobilePlatform {\r\n if (!MobileRpcConfiguration.args.platform)\r\n return RpcMobilePlatform.Unknown;\r\n\r\n const win: any = window;\r\n if (/android/i.test(MobileRpcConfiguration.args.platform)) {\r\n return RpcMobilePlatform.Android;\r\n }\r\n\r\n if (/iOS|iPadOS/i.test(MobileRpcConfiguration.args.platform) && !win.MSStream) {\r\n return RpcMobilePlatform.iOS;\r\n }\r\n\r\n return RpcMobilePlatform.Unknown;\r\n }\r\n /** Read the mobile rpc args */\r\n public static get args(): any {\r\n if (!this._args) {\r\n this._args = MobileRpcConfiguration.getArgs();\r\n }\r\n return this._args;\r\n }\r\n\r\n /** Return type of mobile platform using browser userAgent */\r\n public static get platform(): RpcMobilePlatform { return MobileRpcConfiguration.getMobilePlatform(); }\r\n}\r\n\r\n/** Coordinates usage of RPC interfaces for an Mobile-based application.\r\n * @internal\r\n */\r\nexport class MobileRpcManager {\r\n /** @internal */\r\n public static async ready() {\r\n return new Promise<void>(async (resolve) => {\r\n while (!(global as any).__iTwinJsRpcReady) {\r\n await new Promise((r) => setTimeout(r));\r\n }\r\n\r\n resolve();\r\n });\r\n }\r\n\r\n private static performInitialization(interfaces: RpcInterfaceDefinition[], endPoint: RpcEndpoint): MobileRpcConfiguration {\r\n const config = class extends MobileRpcConfiguration {\r\n public interfaces = () => interfaces;\r\n public protocol: MobileRpcProtocol = new MobileRpcProtocol(this, endPoint);\r\n };\r\n\r\n for (const def of interfaces) {\r\n RpcConfiguration.assign(def, () => config);\r\n }\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n RpcConfiguration.initializeInterfaces(instance);\r\n\r\n return instance;\r\n }\r\n\r\n /** Initializes MobileRpcManager for the frontend of an application. */\r\n public static initializeClient(interfaces: RpcInterfaceDefinition[]): MobileRpcConfiguration {\r\n return MobileRpcManager.performInitialization(interfaces, RpcEndpoint.Frontend);\r\n }\r\n /** Initializes MobileRpcManager for the backend of an application. */\r\n public static initializeImpl(interfaces: RpcInterfaceDefinition[]): MobileRpcConfiguration {\r\n return MobileRpcManager.performInitialization(interfaces, RpcEndpoint.Backend);\r\n }\r\n}\r\n\r\n"]}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import { RpcEndpoint, RpcProtocol, RpcRequestFulfillment } from "@itwin/core-common";
|
|
5
5
|
import { MobileRpcConfiguration } from "./MobileRpcManager";
|
|
6
6
|
import { MobileRpcRequest } from "./MobileRpcRequest";
|
|
7
|
-
/** @
|
|
7
|
+
/** @internal */
|
|
8
8
|
export declare type MobileRpcChunks = Array<string | Uint8Array>;
|
|
9
|
-
/** @
|
|
9
|
+
/** @internal */
|
|
10
10
|
export interface MobileRpcGateway {
|
|
11
11
|
handler: (payload: ArrayBuffer | string, connectionId: number) => void;
|
|
12
12
|
sendString: (message: string, connectionId: number) => void;
|
|
@@ -15,7 +15,7 @@ export interface MobileRpcGateway {
|
|
|
15
15
|
connectionId: number;
|
|
16
16
|
}
|
|
17
17
|
/** RPC interface protocol for an Mobile-based application.
|
|
18
|
-
* @
|
|
18
|
+
* @internal
|
|
19
19
|
*/
|
|
20
20
|
export declare class MobileRpcProtocol extends RpcProtocol {
|
|
21
21
|
socket: WebSocket;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileRpcProtocol.d.ts","sourceRoot":"","sources":["../../../src/common/MobileRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACsB,WAAW,EAAE,WAAW,EAAiD,qBAAqB,EAE1H,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"MobileRpcProtocol.d.ts","sourceRoot":"","sources":["../../../src/common/MobileRpcProtocol.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACsB,WAAW,EAAE,WAAW,EAAiD,qBAAqB,EAE1H,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,gBAAgB;AAChB,oBAAY,eAAe,GAAG,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;AAEzD,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACvE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,UAAU,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CAC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cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;CAW3E"}
|
|
@@ -16,7 +16,7 @@ const MobilePush_1 = require("./MobilePush");
|
|
|
16
16
|
const MobileRpcManager_1 = require("./MobileRpcManager");
|
|
17
17
|
const MobileRpcRequest_1 = require("./MobileRpcRequest");
|
|
18
18
|
/** RPC interface protocol for an Mobile-based application.
|
|
19
|
-
* @
|
|
19
|
+
* @internal
|
|
20
20
|
*/
|
|
21
21
|
class MobileRpcProtocol extends core_common_1.RpcProtocol {
|
|
22
22
|
constructor(configuration, endPoint) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileRpcProtocol.js","sourceRoot":"","sources":["../../../src/common/MobileRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,oDAG4B;AAC5B,uDAAoD;AACpD,2CAAiD;AACjD,6CAAyE;AACzE,yDAA4D;AAC5D,yDAAsD;AActD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,yBAAW;IAiChD,YAAY,aAAqC,EAAE,QAAqB;QACtE,KAAK,CAAC,aAAa,CAAC,CAAC;QAjChB,WAAM,GAAe,SAAiB,CAAC;QACvC,aAAQ,GAAkC,IAAI,GAAG,EAAE,CAAC;QACnD,aAAQ,GAAsB,EAAE,CAAC;QACjC,cAAS,GAAW,MAAM,CAAC,gBAAgB,CAAC;QAC5C,kBAAa,GAAuB,SAAS,CAAC;QAC9C,yBAAoB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpC,gBAAW,GAAG,mCAAgB,CAAC;QACvC,oBAAe,GAAqC,SAAS,CAAC;QAC9D,wBAAmB,GAAsC,SAAS,CAAC;QACnE,iBAAY,GAAiB,EAAE,CAAC;QAChC,UAAK,GAAW,CAAC,CAAC;QAyBxB,IAAI,QAAQ,KAAK,yBAAW,CAAC,QAAQ,EAAE;YACr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ExD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE;gBAC/B,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;aAC3E;iBAAM;gBACL,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;aAC3E;SACF;IACH,CAAC;CACF;AArTD,8CAqTC","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 { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelError, IpcWebSocket, RpcEndpoint, RpcProtocol, RpcPushChannel, RpcPushConnection, RpcRequest, RpcRequestFulfillment, RpcSerializedValue,\r\n SerializedRpcRequest,\r\n} from \"@itwin/core-common\";\r\nimport { MobileEventLoop } from \"./MobileEventLoop\";\r\nimport { MobileIpcTransport } from \"./MobileIpc\";\r\nimport { MobilePushConnection, MobilePushTransport } from \"./MobilePush\";\r\nimport { MobileRpcConfiguration } from \"./MobileRpcManager\";\r\nimport { MobileRpcRequest } from \"./MobileRpcRequest\";\r\n\r\n/** @beta */\r\nexport type MobileRpcChunks = Array<string | Uint8Array>;\r\n\r\n/** @beta */\r\nexport interface MobileRpcGateway {\r\n handler: (payload: ArrayBuffer | string, connectionId: number) => void;\r\n sendString: (message: string, connectionId: number) => void;\r\n sendBinary: (message: Uint8Array, connectionId: number) => void;\r\n port: number;\r\n connectionId: number;\r\n}\r\n\r\n/** RPC interface protocol for an Mobile-based application.\r\n * @beta\r\n */\r\nexport class MobileRpcProtocol extends RpcProtocol {\r\n public socket: WebSocket = (undefined as any);\r\n public requests: Map<string, MobileRpcRequest> = new Map();\r\n private _pending: MobileRpcChunks[] = [];\r\n private _capacity: number = Number.MAX_SAFE_INTEGER;\r\n private _sendInterval: number | undefined = undefined;\r\n private _sendIntervalHandler = () => this.trySend();\r\n public readonly requestType = MobileRpcRequest;\r\n private _partialRequest: SerializedRpcRequest | undefined = undefined;\r\n private _partialFulfillment: RpcRequestFulfillment | undefined = undefined;\r\n private _partialData: Uint8Array[] = [];\r\n private _port: number = 0;\r\n private _transport?: MobilePushTransport;\r\n private _ipc: MobileIpcTransport;\r\n public static obtainInterop(): MobileRpcGateway { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n\r\n public static async encodeRequest(request: MobileRpcRequest): Promise<MobileRpcChunks> {\r\n const serialized = await request.protocol.serialize(request);\r\n const data = serialized.parameters.data;\r\n serialized.parameters.data = data.map((v) => v.byteLength) as any[];\r\n return [JSON.stringify(serialized), ...data];\r\n }\r\n\r\n public static encodeResponse(fulfillment: RpcRequestFulfillment): MobileRpcChunks {\r\n const data = fulfillment.result.data;\r\n fulfillment.result.data = data.map((v) => v.byteLength) as any[];\r\n const raw = fulfillment.rawResult;\r\n fulfillment.rawResult = undefined;\r\n const encoded = [JSON.stringify(fulfillment), ...data];\r\n fulfillment.rawResult = raw;\r\n return encoded;\r\n }\r\n\r\n constructor(configuration: MobileRpcConfiguration, endPoint: RpcEndpoint) {\r\n super(configuration);\r\n\r\n if (endPoint === RpcEndpoint.Frontend) {\r\n this.initializeFrontend();\r\n } else if (endPoint === RpcEndpoint.Backend) {\r\n this.initializeBackend();\r\n }\r\n\r\n this._ipc = new MobileIpcTransport(this);\r\n IpcWebSocket.transport = this._ipc;\r\n }\r\n\r\n private initializeFrontend() {\r\n if (typeof (WebSocket) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"MobileRpcProtocol on frontend require websocket to work\");\r\n }\r\n if (!MobileRpcConfiguration.args.port) {\r\n throw new IModelError(BentleyStatus.ERROR, \"MobileRpcProtocol require 'port' parameter\");\r\n }\r\n\r\n this._port = MobileRpcConfiguration.args.port;\r\n this.connect(this._port, false);\r\n\r\n (window as any)._imodeljs_rpc_reconnect = (port: number) => {\r\n this.socket.close();\r\n window.location.hash = window.location.hash.replace(`port=${this._port}`, `port=${port}`);\r\n this._port = port;\r\n this.connect(port, true);\r\n };\r\n\r\n const transport = new MobilePushTransport(this);\r\n this._transport = transport;\r\n RpcPushChannel.setup(transport);\r\n }\r\n\r\n private connect(port: number, reset: boolean) {\r\n const socket = new WebSocket(`ws://localhost:${port}`);\r\n socket.binaryType = \"arraybuffer\";\r\n this.connectMessageHandler(socket);\r\n this.connectOpenHandler(socket, reset);\r\n this.connectErrorHandler(socket);\r\n this.socket = socket;\r\n }\r\n\r\n private connectMessageHandler(socket: WebSocket) {\r\n socket.addEventListener(\"message\", async (event) => {\r\n if (this.socket !== socket) {\r\n return;\r\n }\r\n\r\n this.handleMessageFromBackend(event.data);\r\n });\r\n }\r\n\r\n private connectOpenHandler(socket: WebSocket, reset: boolean) {\r\n socket.addEventListener(\"open\", (_event) => {\r\n if (this.socket !== socket) {\r\n return;\r\n }\r\n\r\n if (reset) {\r\n this.reset();\r\n\r\n const requests = new Map(RpcRequest.activeRequests);\r\n requests.forEach((req) => {\r\n req.cancel();\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n req.submit();\r\n });\r\n }\r\n\r\n this.scheduleSend();\r\n });\r\n }\r\n\r\n private connectErrorHandler(socket: WebSocket) {\r\n socket.addEventListener(\"error\", (_event) => {\r\n if (this.socket !== socket) {\r\n return;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, \"Socket error.\");\r\n });\r\n }\r\n\r\n private reset() {\r\n this.requests.clear();\r\n this._capacity = Number.MAX_SAFE_INTEGER;\r\n\r\n if (typeof (this._sendInterval) !== \"undefined\") {\r\n window.clearInterval(this._sendInterval);\r\n this._sendInterval = undefined;\r\n }\r\n\r\n this._partialRequest = undefined;\r\n this._partialFulfillment = undefined;\r\n this._partialData.length = 0;\r\n }\r\n\r\n private scheduleSend() {\r\n if (!this._pending.length) {\r\n return;\r\n }\r\n\r\n this.trySend();\r\n\r\n if (this._pending.length && typeof (this._sendInterval) === \"undefined\") {\r\n this._sendInterval = window.setInterval(this._sendIntervalHandler, 0);\r\n }\r\n }\r\n\r\n private trySend() {\r\n if (this.socket.readyState !== WebSocket.OPEN) {\r\n return;\r\n }\r\n\r\n while (this._capacity !== 0 && this._pending.length) {\r\n --this._capacity;\r\n const next = this._pending.shift()!;\r\n for (const chunk of next) {\r\n this.socket.send(chunk);\r\n }\r\n }\r\n\r\n if (!this._pending.length && typeof (this._sendInterval) !== \"undefined\") {\r\n window.clearInterval(this._sendInterval);\r\n this._sendInterval = undefined;\r\n }\r\n }\r\n\r\n private handleMessageFromBackend(data: string | ArrayBuffer) {\r\n if (typeof (data) === \"string\") {\r\n this.handleStringFromBackend(data);\r\n } else {\r\n this.handleBinaryFromBackend(data);\r\n }\r\n }\r\n\r\n private handleStringFromBackend(data: string) {\r\n if (this._partialFulfillment) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (already receiving response).\");\r\n }\r\n\r\n const response = JSON.parse(data) as RpcRequestFulfillment;\r\n this._partialFulfillment = response;\r\n\r\n if (!response.result.data.length) {\r\n this.notifyResponse();\r\n }\r\n }\r\n\r\n private handleBinaryFromBackend(data: ArrayBuffer) {\r\n const fulfillment = this._partialFulfillment;\r\n if (!fulfillment) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no response received).\");\r\n }\r\n\r\n this._partialData.push(new Uint8Array(data));\r\n if (this._partialData.length === fulfillment.result.data.length) {\r\n this.notifyResponse();\r\n }\r\n }\r\n\r\n private notifyResponse() {\r\n const response = this._partialFulfillment;\r\n if (!response) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no response exists).\");\r\n }\r\n\r\n ++this._capacity;\r\n this.consumePartialData(response.result);\r\n this._partialFulfillment = undefined;\r\n\r\n if (this._transport && this._transport.consume(response)) {\r\n return;\r\n }\r\n\r\n if (this._ipc.consumeResponse(response)) {\r\n return;\r\n }\r\n\r\n const request = this.requests.get(response.id) as MobileRpcRequest;\r\n this.requests.delete(response.id);\r\n request.notifyResponse(response);\r\n }\r\n\r\n private consumePartialData(value: RpcSerializedValue) {\r\n for (let i = 0, l = value.data.length; i !== l; ++i) {\r\n value.data[i] = this._partialData[i];\r\n }\r\n\r\n this._partialData.length = 0;\r\n }\r\n\r\n private initializeBackend() {\r\n const mobilegateway = MobileRpcProtocol.obtainInterop();\r\n if (mobilegateway === undefined || mobilegateway == null) {\r\n throw new IModelError(BentleyStatus.ERROR, \"MobileRpcProtocol on backend require native bridge to be setup\");\r\n }\r\n\r\n mobilegateway.handler = (payload, connectionId) => this.handleMessageFromFrontend(payload, connectionId);\r\n RpcPushConnection.for = (channel, client) => new MobilePushConnection(channel, client, this);\r\n RpcPushChannel.enabled = true;\r\n }\r\n\r\n private handleMessageFromFrontend(data: string | ArrayBuffer, connectionId: number) {\r\n if (typeof (data) === \"string\") {\r\n this.handleStringFromFrontend(data, connectionId);\r\n } else {\r\n this.handleBinaryFromFrontend(data, connectionId);\r\n }\r\n }\r\n\r\n private handleStringFromFrontend(data: string, connection: number) {\r\n if (this._partialRequest) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (already receiving request).\");\r\n }\r\n\r\n const request = JSON.parse(data) as SerializedRpcRequest;\r\n this._partialRequest = request;\r\n\r\n if (!request.parameters.data.length) {\r\n this.notifyRequest(connection); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private handleBinaryFromFrontend(data: ArrayBuffer, connection: number) {\r\n const request = this._partialRequest;\r\n if (!request) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no request received).\");\r\n }\r\n\r\n this._partialData.push(new Uint8Array(data));\r\n if (this._partialData.length === request.parameters.data.length) {\r\n this.notifyRequest(connection); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async notifyRequest(connection: number) {\r\n const request = this._partialRequest;\r\n if (!request) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no request exists).\");\r\n }\r\n\r\n this.consumePartialData(request.parameters);\r\n this._partialRequest = undefined;\r\n\r\n if (this._ipc.consumeRequest(request)) {\r\n return;\r\n }\r\n\r\n MobileEventLoop.addTask();\r\n const fulfillment = await this.fulfill(request);\r\n MobileEventLoop.removeTask();\r\n\r\n const response = MobileRpcProtocol.encodeResponse(fulfillment);\r\n this.sendToFrontend(response, connection);\r\n }\r\n\r\n public sendToBackend(message: MobileRpcChunks): void {\r\n this._pending.push(message);\r\n this.scheduleSend();\r\n }\r\n\r\n public sendToFrontend(message: MobileRpcChunks, connection?: number): void {\r\n const mobilegateway = MobileRpcProtocol.obtainInterop();\r\n\r\n for (const chunk of message) {\r\n if (typeof (chunk) === \"string\") {\r\n mobilegateway.sendString(chunk, connection || mobilegateway.connectionId);\r\n } else {\r\n mobilegateway.sendBinary(chunk, connection || mobilegateway.connectionId);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"MobileRpcProtocol.js","sourceRoot":"","sources":["../../../src/common/MobileRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,oDAG4B;AAC5B,uDAAoD;AACpD,2CAAiD;AACjD,6CAAyE;AACzE,yDAA4D;AAC5D,yDAAsD;AAgBtD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,yBAAW;IAiChD,YAAY,aAAqC,EAAE,QAAqB;QACtE,KAAK,CAAC,aAAa,CAAC,CAAC;QAjChB,WAAM,GAAe,SAAiB,CAAC;QACvC,aAAQ,GAAkC,IAAI,GAAG,EAAE,CAAC;QACnD,aAAQ,GAAsB,EAAE,CAAC;QACjC,cAAS,GAAW,MAAM,CAAC,gBAAgB,CAAC;QAC5C,kBAAa,GAAuB,SAAS,CAAC;QAC9C,yBAAoB,GAAG,GAAG,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AU,CAAC,CAAC;IAC5C,CAAC;IAEM,aAAa,CAAC,OAAwB;QAC3C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEM,cAAc,CAAC,OAAwB,EAAE,UAAmB;QACjE,MAAM,aAAa,GAAG,iBAAiB,CAAC,aAAa,EAAE,CAAC;QAExD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE;gBAC/B,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;aAC3E;iBAAM;gBACL,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;aAC3E;SACF;IACH,CAAC;CACF;AArTD,8CAqTC","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 { BentleyStatus } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelError, IpcWebSocket, RpcEndpoint, RpcProtocol, RpcPushChannel, RpcPushConnection, RpcRequest, RpcRequestFulfillment, RpcSerializedValue,\r\n SerializedRpcRequest,\r\n} from \"@itwin/core-common\";\r\nimport { MobileEventLoop } from \"./MobileEventLoop\";\r\nimport { MobileIpcTransport } from \"./MobileIpc\";\r\nimport { MobilePushConnection, MobilePushTransport } from \"./MobilePush\";\r\nimport { MobileRpcConfiguration } from \"./MobileRpcManager\";\r\nimport { MobileRpcRequest } from \"./MobileRpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @internal */\r\nexport type MobileRpcChunks = Array<string | Uint8Array>;\r\n\r\n/** @internal */\r\nexport interface MobileRpcGateway {\r\n handler: (payload: ArrayBuffer | string, connectionId: number) => void;\r\n sendString: (message: string, connectionId: number) => void;\r\n sendBinary: (message: Uint8Array, connectionId: number) => void;\r\n port: number;\r\n connectionId: number;\r\n}\r\n\r\n/** RPC interface protocol for an Mobile-based application.\r\n * @internal\r\n */\r\nexport class MobileRpcProtocol extends RpcProtocol {\r\n public socket: WebSocket = (undefined as any);\r\n public requests: Map<string, MobileRpcRequest> = new Map();\r\n private _pending: MobileRpcChunks[] = [];\r\n private _capacity: number = Number.MAX_SAFE_INTEGER;\r\n private _sendInterval: number | undefined = undefined;\r\n private _sendIntervalHandler = () => this.trySend();\r\n public readonly requestType = MobileRpcRequest;\r\n private _partialRequest: SerializedRpcRequest | undefined = undefined;\r\n private _partialFulfillment: RpcRequestFulfillment | undefined = undefined;\r\n private _partialData: Uint8Array[] = [];\r\n private _port: number = 0;\r\n private _transport?: MobilePushTransport;\r\n private _ipc: MobileIpcTransport;\r\n public static obtainInterop(): MobileRpcGateway { throw new IModelError(BentleyStatus.ERROR, \"Not implemented.\"); }\r\n\r\n public static async encodeRequest(request: MobileRpcRequest): Promise<MobileRpcChunks> {\r\n const serialized = await request.protocol.serialize(request);\r\n const data = serialized.parameters.data;\r\n serialized.parameters.data = data.map((v) => v.byteLength) as any[];\r\n return [JSON.stringify(serialized), ...data];\r\n }\r\n\r\n public static encodeResponse(fulfillment: RpcRequestFulfillment): MobileRpcChunks {\r\n const data = fulfillment.result.data;\r\n fulfillment.result.data = data.map((v) => v.byteLength) as any[];\r\n const raw = fulfillment.rawResult;\r\n fulfillment.rawResult = undefined;\r\n const encoded = [JSON.stringify(fulfillment), ...data];\r\n fulfillment.rawResult = raw;\r\n return encoded;\r\n }\r\n\r\n constructor(configuration: MobileRpcConfiguration, endPoint: RpcEndpoint) {\r\n super(configuration);\r\n\r\n if (endPoint === RpcEndpoint.Frontend) {\r\n this.initializeFrontend();\r\n } else if (endPoint === RpcEndpoint.Backend) {\r\n this.initializeBackend();\r\n }\r\n\r\n this._ipc = new MobileIpcTransport(this);\r\n IpcWebSocket.transport = this._ipc;\r\n }\r\n\r\n private initializeFrontend() {\r\n if (typeof (WebSocket) === \"undefined\") {\r\n throw new IModelError(BentleyStatus.ERROR, \"MobileRpcProtocol on frontend require websocket to work\");\r\n }\r\n if (!MobileRpcConfiguration.args.port) {\r\n throw new IModelError(BentleyStatus.ERROR, \"MobileRpcProtocol require 'port' parameter\");\r\n }\r\n\r\n this._port = MobileRpcConfiguration.args.port;\r\n this.connect(this._port, false);\r\n\r\n (window as any)._imodeljs_rpc_reconnect = (port: number) => {\r\n this.socket.close();\r\n window.location.hash = window.location.hash.replace(`port=${this._port}`, `port=${port}`);\r\n this._port = port;\r\n this.connect(port, true);\r\n };\r\n\r\n const transport = new MobilePushTransport(this);\r\n this._transport = transport;\r\n RpcPushChannel.setup(transport);\r\n }\r\n\r\n private connect(port: number, reset: boolean) {\r\n const socket = new WebSocket(`ws://localhost:${port}`);\r\n socket.binaryType = \"arraybuffer\";\r\n this.connectMessageHandler(socket);\r\n this.connectOpenHandler(socket, reset);\r\n this.connectErrorHandler(socket);\r\n this.socket = socket;\r\n }\r\n\r\n private connectMessageHandler(socket: WebSocket) {\r\n socket.addEventListener(\"message\", async (event) => {\r\n if (this.socket !== socket) {\r\n return;\r\n }\r\n\r\n this.handleMessageFromBackend(event.data);\r\n });\r\n }\r\n\r\n private connectOpenHandler(socket: WebSocket, reset: boolean) {\r\n socket.addEventListener(\"open\", (_event) => {\r\n if (this.socket !== socket) {\r\n return;\r\n }\r\n\r\n if (reset) {\r\n this.reset();\r\n\r\n const requests = new Map(RpcRequest.activeRequests);\r\n requests.forEach((req) => {\r\n req.cancel();\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n req.submit();\r\n });\r\n }\r\n\r\n this.scheduleSend();\r\n });\r\n }\r\n\r\n private connectErrorHandler(socket: WebSocket) {\r\n socket.addEventListener(\"error\", (_event) => {\r\n if (this.socket !== socket) {\r\n return;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, \"Socket error.\");\r\n });\r\n }\r\n\r\n private reset() {\r\n this.requests.clear();\r\n this._capacity = Number.MAX_SAFE_INTEGER;\r\n\r\n if (typeof (this._sendInterval) !== \"undefined\") {\r\n window.clearInterval(this._sendInterval);\r\n this._sendInterval = undefined;\r\n }\r\n\r\n this._partialRequest = undefined;\r\n this._partialFulfillment = undefined;\r\n this._partialData.length = 0;\r\n }\r\n\r\n private scheduleSend() {\r\n if (!this._pending.length) {\r\n return;\r\n }\r\n\r\n this.trySend();\r\n\r\n if (this._pending.length && typeof (this._sendInterval) === \"undefined\") {\r\n this._sendInterval = window.setInterval(this._sendIntervalHandler, 0);\r\n }\r\n }\r\n\r\n private trySend() {\r\n if (this.socket.readyState !== WebSocket.OPEN) {\r\n return;\r\n }\r\n\r\n while (this._capacity !== 0 && this._pending.length) {\r\n --this._capacity;\r\n const next = this._pending.shift()!;\r\n for (const chunk of next) {\r\n this.socket.send(chunk);\r\n }\r\n }\r\n\r\n if (!this._pending.length && typeof (this._sendInterval) !== \"undefined\") {\r\n window.clearInterval(this._sendInterval);\r\n this._sendInterval = undefined;\r\n }\r\n }\r\n\r\n private handleMessageFromBackend(data: string | ArrayBuffer) {\r\n if (typeof (data) === \"string\") {\r\n this.handleStringFromBackend(data);\r\n } else {\r\n this.handleBinaryFromBackend(data);\r\n }\r\n }\r\n\r\n private handleStringFromBackend(data: string) {\r\n if (this._partialFulfillment) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (already receiving response).\");\r\n }\r\n\r\n const response = JSON.parse(data) as RpcRequestFulfillment;\r\n this._partialFulfillment = response;\r\n\r\n if (!response.result.data.length) {\r\n this.notifyResponse();\r\n }\r\n }\r\n\r\n private handleBinaryFromBackend(data: ArrayBuffer) {\r\n const fulfillment = this._partialFulfillment;\r\n if (!fulfillment) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no response received).\");\r\n }\r\n\r\n this._partialData.push(new Uint8Array(data));\r\n if (this._partialData.length === fulfillment.result.data.length) {\r\n this.notifyResponse();\r\n }\r\n }\r\n\r\n private notifyResponse() {\r\n const response = this._partialFulfillment;\r\n if (!response) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no response exists).\");\r\n }\r\n\r\n ++this._capacity;\r\n this.consumePartialData(response.result);\r\n this._partialFulfillment = undefined;\r\n\r\n if (this._transport && this._transport.consume(response)) {\r\n return;\r\n }\r\n\r\n if (this._ipc.consumeResponse(response)) {\r\n return;\r\n }\r\n\r\n const request = this.requests.get(response.id) as MobileRpcRequest;\r\n this.requests.delete(response.id);\r\n request.notifyResponse(response);\r\n }\r\n\r\n private consumePartialData(value: RpcSerializedValue) {\r\n for (let i = 0, l = value.data.length; i !== l; ++i) {\r\n value.data[i] = this._partialData[i];\r\n }\r\n\r\n this._partialData.length = 0;\r\n }\r\n\r\n private initializeBackend() {\r\n const mobilegateway = MobileRpcProtocol.obtainInterop();\r\n if (mobilegateway === undefined || mobilegateway == null) {\r\n throw new IModelError(BentleyStatus.ERROR, \"MobileRpcProtocol on backend require native bridge to be setup\");\r\n }\r\n\r\n mobilegateway.handler = (payload, connectionId) => this.handleMessageFromFrontend(payload, connectionId);\r\n RpcPushConnection.for = (channel, client) => new MobilePushConnection(channel, client, this);\r\n RpcPushChannel.enabled = true;\r\n }\r\n\r\n private handleMessageFromFrontend(data: string | ArrayBuffer, connectionId: number) {\r\n if (typeof (data) === \"string\") {\r\n this.handleStringFromFrontend(data, connectionId);\r\n } else {\r\n this.handleBinaryFromFrontend(data, connectionId);\r\n }\r\n }\r\n\r\n private handleStringFromFrontend(data: string, connection: number) {\r\n if (this._partialRequest) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (already receiving request).\");\r\n }\r\n\r\n const request = JSON.parse(data) as SerializedRpcRequest;\r\n this._partialRequest = request;\r\n\r\n if (!request.parameters.data.length) {\r\n this.notifyRequest(connection); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private handleBinaryFromFrontend(data: ArrayBuffer, connection: number) {\r\n const request = this._partialRequest;\r\n if (!request) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no request received).\");\r\n }\r\n\r\n this._partialData.push(new Uint8Array(data));\r\n if (this._partialData.length === request.parameters.data.length) {\r\n this.notifyRequest(connection); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async notifyRequest(connection: number) {\r\n const request = this._partialRequest;\r\n if (!request) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid state (no request exists).\");\r\n }\r\n\r\n this.consumePartialData(request.parameters);\r\n this._partialRequest = undefined;\r\n\r\n if (this._ipc.consumeRequest(request)) {\r\n return;\r\n }\r\n\r\n MobileEventLoop.addTask();\r\n const fulfillment = await this.fulfill(request);\r\n MobileEventLoop.removeTask();\r\n\r\n const response = MobileRpcProtocol.encodeResponse(fulfillment);\r\n this.sendToFrontend(response, connection);\r\n }\r\n\r\n public sendToBackend(message: MobileRpcChunks): void {\r\n this._pending.push(message);\r\n this.scheduleSend();\r\n }\r\n\r\n public sendToFrontend(message: MobileRpcChunks, connection?: number): void {\r\n const mobilegateway = MobileRpcProtocol.obtainInterop();\r\n\r\n for (const chunk of message) {\r\n if (typeof (chunk) === \"string\") {\r\n mobilegateway.sendString(chunk, connection || mobilegateway.connectionId);\r\n } else {\r\n mobilegateway.sendBinary(chunk, connection || mobilegateway.connectionId);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { RpcRequest, RpcRequestFulfillment, RpcSerializedValue } from "@itwin/core-common";
|
|
5
5
|
import { MobileRpcProtocol } from "./MobileRpcProtocol";
|
|
6
|
-
/** @
|
|
6
|
+
/** @internal */
|
|
7
7
|
export declare class MobileRpcRequest extends RpcRequest {
|
|
8
8
|
private _res;
|
|
9
9
|
private _fulfillment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileRpcRequest.d.ts","sourceRoot":"","sources":["../../../src/common/MobileRpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"MobileRpcRequest.d.ts","sourceRoot":"","sources":["../../../src/common/MobileRpcRequest.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,gBAAgB;AAChB,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,OAAO,CAAC,IAAI,CAA4C;IACxD,OAAO,CAAC,YAAY,CAAgD;IAEpE,0DAA0D;IAC1D,SAAyB,QAAQ,EAAE,iBAAiB,CAA6C;IAEjG,yBAAyB;cACT,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IASvC,yBAAyB;cACT,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC;IASnD,kCAAkC;IAClC,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIxD,gBAAgB;IACT,cAAc,CAAC,WAAW,EAAE,qBAAqB;CAIzD"}
|
|
@@ -10,7 +10,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.MobileRpcRequest = void 0;
|
|
11
11
|
const core_common_1 = require("@itwin/core-common");
|
|
12
12
|
const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
|
|
13
|
-
|
|
13
|
+
/* eslint-disable deprecation/deprecation */
|
|
14
|
+
/** @internal */
|
|
14
15
|
class MobileRpcRequest extends core_common_1.RpcRequest {
|
|
15
16
|
constructor() {
|
|
16
17
|
super(...arguments);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileRpcRequest.js","sourceRoot":"","sources":["../../../src/common/MobileRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA2F;AAC3F,2DAAwD;AAExD,
|
|
1
|
+
{"version":3,"file":"MobileRpcRequest.js","sourceRoot":"","sources":["../../../src/common/MobileRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA2F;AAC3F,2DAAwD;AAExD,4CAA4C;AAE5C,gBAAgB;AAChB,MAAa,gBAAiB,SAAQ,wBAAU;IAAhD;;QACU,SAAI,GAA4B,GAAG,EAAE,CAAC,SAAS,CAAC;QAChD,iBAAY,GAAsC,SAAS,CAAC;QAEpE,0DAA0D;QACjC,aAAQ,GAAsB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAe,CAAC;IAgCnG,CAAC;IA9BC,yBAAyB;IACf,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAM,qCAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;YACrC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,yBAAyB;IACf,KAAK,CAAC,IAAI;QAClB,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACtD;QAED,OAAO,WAAW,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,kCAAkC;IACxB,SAAS,CAAC,KAAa,EAAE,MAAc;QAC/C,oBAAoB;IACtB,CAAC;IAED,gBAAgB;IACT,cAAc,CAAC,WAAkC;QACtD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;CACF;AArCD,4CAqCC","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 { RpcRequest, RpcRequestFulfillment, RpcSerializedValue } from \"@itwin/core-common\";\r\nimport { MobileRpcProtocol } from \"./MobileRpcProtocol\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @internal */\r\nexport class MobileRpcRequest extends RpcRequest {\r\n private _res: (value: number) => void = () => undefined;\r\n private _fulfillment: RpcRequestFulfillment | undefined = undefined;\r\n\r\n /** Convenience access to the protocol of this request. */\r\n public override readonly protocol: MobileRpcProtocol = this.client.configuration.protocol as any;\r\n\r\n /** Sends the request. */\r\n protected async send(): Promise<number> {\r\n this.protocol.requests.set(this.id, this);\r\n const parts = await MobileRpcProtocol.encodeRequest(this);\r\n this.protocol.sendToBackend(parts);\r\n return new Promise<number>((resolve) => {\r\n this._res = resolve;\r\n });\r\n }\r\n\r\n /** Loads the request. */\r\n protected async load(): Promise<RpcSerializedValue> {\r\n const fulfillment = this._fulfillment;\r\n if (!fulfillment) {\r\n throw new Error(\"No request fulfillment available.\");\r\n }\r\n\r\n return fulfillment.result;\r\n }\r\n\r\n /** Sets request header values. */\r\n protected setHeader(_name: string, _value: string): void {\r\n // No implementation\r\n }\r\n\r\n /** @internal */\r\n public notifyResponse(fulfillment: RpcRequestFulfillment) {\r\n this._fulfillment = fulfillment;\r\n this._res(fulfillment.status);\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.6.0-dev.
|
|
3
|
+
"version": "3.6.0-dev.62",
|
|
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.6.0-dev.
|
|
25
|
-
"@itwin/core-bentley": "^3.6.0-dev.
|
|
26
|
-
"@itwin/core-common": "^3.6.0-dev.
|
|
27
|
-
"@itwin/core-frontend": "^3.6.0-dev.
|
|
28
|
-
"@itwin/presentation-common": "^3.6.0-dev.
|
|
24
|
+
"@itwin/core-backend": "^3.6.0-dev.62",
|
|
25
|
+
"@itwin/core-bentley": "^3.6.0-dev.62",
|
|
26
|
+
"@itwin/core-common": "^3.6.0-dev.62",
|
|
27
|
+
"@itwin/core-frontend": "^3.6.0-dev.62",
|
|
28
|
+
"@itwin/presentation-common": "^3.6.0-dev.62"
|
|
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.6.0-dev.
|
|
40
|
-
"@itwin/core-backend": "3.6.0-dev.
|
|
41
|
-
"@itwin/core-bentley": "3.6.0-dev.
|
|
42
|
-
"@itwin/core-common": "3.6.0-dev.
|
|
43
|
-
"@itwin/core-frontend": "3.6.0-dev.
|
|
44
|
-
"@itwin/eslint-plugin": "3.6.0-dev.
|
|
45
|
-
"@itwin/presentation-common": "3.6.0-dev.
|
|
39
|
+
"@itwin/build-tools": "3.6.0-dev.62",
|
|
40
|
+
"@itwin/core-backend": "3.6.0-dev.62",
|
|
41
|
+
"@itwin/core-bentley": "3.6.0-dev.62",
|
|
42
|
+
"@itwin/core-common": "3.6.0-dev.62",
|
|
43
|
+
"@itwin/core-frontend": "3.6.0-dev.62",
|
|
44
|
+
"@itwin/eslint-plugin": "3.6.0-dev.62",
|
|
45
|
+
"@itwin/presentation-common": "3.6.0-dev.62",
|
|
46
46
|
"@types/chai": "4.3.1",
|
|
47
47
|
"@types/deep-assign": "^0.1.0",
|
|
48
48
|
"@types/fs-extra": "^4.0.7",
|