@itwin/core-mobile 4.0.0-dev.6 → 4.0.0-dev.61
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 +15 -1
- package/lib/cjs/MobileBackend.d.ts +7 -7
- package/lib/cjs/MobileBackend.js +28 -24
- package/lib/cjs/MobileBackend.js.map +1 -1
- package/lib/cjs/MobileFrontend.d.ts +5 -5
- package/lib/cjs/MobileFrontend.js +25 -21
- package/lib/cjs/MobileFrontend.js.map +1 -1
- package/lib/cjs/__DOC_ONLY__.d.ts +33 -33
- package/lib/cjs/__DOC_ONLY__.js +56 -52
- package/lib/cjs/__DOC_ONLY__.js.map +1 -1
- package/lib/cjs/backend/MobileAuthorizationBackend.d.ts +17 -17
- package/lib/cjs/backend/MobileAuthorizationBackend.js +46 -46
- package/lib/cjs/backend/MobileAuthorizationBackend.js.map +1 -1
- package/lib/cjs/backend/MobileFileHandler.d.ts +112 -112
- package/lib/cjs/backend/MobileFileHandler.js +263 -263
- package/lib/cjs/backend/MobileHost.d.ts +72 -72
- package/lib/cjs/backend/MobileHost.d.ts.map +1 -1
- package/lib/cjs/backend/MobileHost.js +155 -156
- package/lib/cjs/backend/MobileHost.js.map +1 -1
- package/lib/cjs/backend/MobileRpcServer.d.ts +19 -19
- package/lib/cjs/backend/MobileRpcServer.js +156 -156
- package/lib/cjs/backend/MobileRpcServer.js.map +1 -1
- package/lib/cjs/backend/Request.d.ts +149 -149
- package/lib/cjs/backend/Request.d.ts.map +1 -1
- package/lib/cjs/backend/Request.js +267 -267
- package/lib/cjs/common/MobileAppChannel.d.ts +4 -4
- package/lib/cjs/common/MobileAppChannel.js +11 -11
- package/lib/cjs/common/MobileAppProps.d.ts +35 -35
- package/lib/cjs/common/MobileAppProps.d.ts.map +1 -1
- package/lib/cjs/common/MobileAppProps.js +26 -26
- package/lib/cjs/common/MobileEventLoop.d.ts +11 -11
- package/lib/cjs/common/MobileEventLoop.js +30 -30
- package/lib/cjs/common/MobileEventLoop.js.map +1 -1
- package/lib/cjs/common/MobileIpc.d.ts +17 -17
- package/lib/cjs/common/MobileIpc.js +70 -70
- package/lib/cjs/common/MobilePush.d.ts +20 -20
- package/lib/cjs/common/MobilePush.js +53 -53
- package/lib/cjs/common/MobilePush.js.map +1 -1
- package/lib/cjs/common/MobileRpcManager.d.ts +40 -40
- package/lib/cjs/common/MobileRpcManager.js +110 -110
- package/lib/cjs/common/MobileRpcManager.js.map +1 -1
- package/lib/cjs/common/MobileRpcProtocol.d.ts +58 -58
- package/lib/cjs/common/MobileRpcProtocol.d.ts.map +1 -1
- package/lib/cjs/common/MobileRpcProtocol.js +277 -277
- package/lib/cjs/common/MobileRpcProtocol.js.map +1 -1
- package/lib/cjs/common/MobileRpcRequest.d.ts +20 -20
- package/lib/cjs/common/MobileRpcRequest.js +50 -50
- package/lib/cjs/frontend/MobileApp.d.ts +23 -23
- package/lib/cjs/frontend/MobileApp.d.ts.map +1 -1
- package/lib/cjs/frontend/MobileApp.js +79 -80
- package/lib/cjs/frontend/MobileApp.js.map +1 -1
- package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts +17 -17
- package/lib/cjs/frontend/MobileAuthorizationFrontend.d.ts.map +1 -1
- package/lib/cjs/frontend/MobileAuthorizationFrontend.js +54 -46
- package/lib/cjs/frontend/MobileAuthorizationFrontend.js.map +1 -1
- package/lib/cjs/test/ios/MobilePlatform.test.d.ts +1 -1
- package/lib/cjs/test/ios/MobilePlatform.test.js +84 -84
- package/package.json +16 -16
|
@@ -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,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
|
-
|
|
29
|
-
MobileEventLoop.
|
|
30
|
-
MobileEventLoop
|
|
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;;
|
|
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":["/*---------------------------------------------------------------------------------------------\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,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,21 +1,21 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module RpcInterface
|
|
3
|
-
*/
|
|
4
|
-
import { RpcPushChannel, RpcPushConnection, RpcPushTransport, RpcRequestFulfillment } from "@itwin/core-common";
|
|
5
|
-
import { MobileRpcProtocol } from "./MobileRpcProtocol";
|
|
6
|
-
/** @internal */
|
|
7
|
-
export declare class MobilePushTransport extends RpcPushTransport {
|
|
8
|
-
private _protocol;
|
|
9
|
-
private _last;
|
|
10
|
-
get last(): number;
|
|
11
|
-
constructor(protocol: MobileRpcProtocol);
|
|
12
|
-
consume(response: RpcRequestFulfillment): boolean;
|
|
13
|
-
}
|
|
14
|
-
/** @internal */
|
|
15
|
-
export declare class MobilePushConnection<T> extends RpcPushConnection<T> {
|
|
16
|
-
private _protocol;
|
|
17
|
-
private _next;
|
|
18
|
-
constructor(channel: RpcPushChannel<T>, client: unknown, protocol: MobileRpcProtocol);
|
|
19
|
-
send(messageData: any): Promise<void>;
|
|
20
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module RpcInterface
|
|
3
|
+
*/
|
|
4
|
+
import { RpcPushChannel, RpcPushConnection, RpcPushTransport, RpcRequestFulfillment } from "@itwin/core-common";
|
|
5
|
+
import { MobileRpcProtocol } from "./MobileRpcProtocol";
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare class MobilePushTransport extends RpcPushTransport {
|
|
8
|
+
private _protocol;
|
|
9
|
+
private _last;
|
|
10
|
+
get last(): number;
|
|
11
|
+
constructor(protocol: MobileRpcProtocol);
|
|
12
|
+
consume(response: RpcRequestFulfillment): boolean;
|
|
13
|
+
}
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare class MobilePushConnection<T> extends RpcPushConnection<T> {
|
|
16
|
+
private _protocol;
|
|
17
|
+
private _next;
|
|
18
|
+
constructor(channel: RpcPushChannel<T>, client: unknown, protocol: MobileRpcProtocol);
|
|
19
|
+
send(messageData: any): Promise<void>;
|
|
20
|
+
}
|
|
21
21
|
//# sourceMappingURL=MobilePush.d.ts.map
|
|
@@ -1,54 +1,54 @@
|
|
|
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.MobilePushConnection = exports.MobilePushTransport = void 0;
|
|
11
|
-
const core_common_1 = require("@itwin/core-common");
|
|
12
|
-
const MobileEventLoop_1 = require("./MobileEventLoop");
|
|
13
|
-
const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
|
|
14
|
-
/* eslint-disable deprecation/deprecation */
|
|
15
|
-
const PUSH = "__push__";
|
|
16
|
-
/** @internal */
|
|
17
|
-
class MobilePushTransport extends core_common_1.RpcPushTransport {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
consume(response) {
|
|
25
|
-
if (response.interfaceName !== PUSH) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
this._last = response.status;
|
|
29
|
-
if (this.onMessage) {
|
|
30
|
-
const messageData = core_common_1.RpcMarshaling.deserialize(this._protocol, response.result);
|
|
31
|
-
this.onMessage(response.id, messageData);
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.MobilePushTransport = MobilePushTransport;
|
|
37
|
-
/** @internal */
|
|
38
|
-
class MobilePushConnection extends core_common_1.RpcPushConnection {
|
|
39
|
-
constructor(channel, client, protocol) {
|
|
40
|
-
super(channel, client);
|
|
41
|
-
this._next = -1;
|
|
42
|
-
this._protocol = protocol;
|
|
43
|
-
}
|
|
44
|
-
async send(messageData) {
|
|
45
|
-
MobileEventLoop_1.MobileEventLoop.addTask();
|
|
46
|
-
const result = await core_common_1.RpcMarshaling.serialize(this._protocol, messageData);
|
|
47
|
-
MobileEventLoop_1.MobileEventLoop.removeTask();
|
|
48
|
-
const fulfillment = { result, rawResult: messageData, interfaceName: PUSH, id: this.channel.id, status: ++this._next };
|
|
49
|
-
const encoded = MobileRpcProtocol_1.MobileRpcProtocol.encodeResponse(fulfillment);
|
|
50
|
-
this._protocol.sendToFrontend(encoded);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.MobilePushConnection = MobilePushConnection;
|
|
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.MobilePushConnection = exports.MobilePushTransport = void 0;
|
|
11
|
+
const core_common_1 = require("@itwin/core-common");
|
|
12
|
+
const MobileEventLoop_1 = require("./MobileEventLoop");
|
|
13
|
+
const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
|
|
14
|
+
/* eslint-disable deprecation/deprecation */
|
|
15
|
+
const PUSH = "__push__";
|
|
16
|
+
/** @internal */
|
|
17
|
+
class MobilePushTransport extends core_common_1.RpcPushTransport {
|
|
18
|
+
get last() { return this._last; }
|
|
19
|
+
constructor(protocol) {
|
|
20
|
+
super();
|
|
21
|
+
this._last = -1;
|
|
22
|
+
this._protocol = protocol;
|
|
23
|
+
}
|
|
24
|
+
consume(response) {
|
|
25
|
+
if (response.interfaceName !== PUSH) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
this._last = response.status;
|
|
29
|
+
if (this.onMessage) {
|
|
30
|
+
const messageData = core_common_1.RpcMarshaling.deserialize(this._protocol, response.result);
|
|
31
|
+
this.onMessage(response.id, messageData);
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.MobilePushTransport = MobilePushTransport;
|
|
37
|
+
/** @internal */
|
|
38
|
+
class MobilePushConnection extends core_common_1.RpcPushConnection {
|
|
39
|
+
constructor(channel, client, protocol) {
|
|
40
|
+
super(channel, client);
|
|
41
|
+
this._next = -1;
|
|
42
|
+
this._protocol = protocol;
|
|
43
|
+
}
|
|
44
|
+
async send(messageData) {
|
|
45
|
+
MobileEventLoop_1.MobileEventLoop.addTask();
|
|
46
|
+
const result = await core_common_1.RpcMarshaling.serialize(this._protocol, messageData);
|
|
47
|
+
MobileEventLoop_1.MobileEventLoop.removeTask();
|
|
48
|
+
const fulfillment = { result, rawResult: messageData, interfaceName: PUSH, id: this.channel.id, status: ++this._next };
|
|
49
|
+
const encoded = MobileRpcProtocol_1.MobileRpcProtocol.encodeResponse(fulfillment);
|
|
50
|
+
this._protocol.sendToFrontend(encoded);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.MobilePushConnection = MobilePushConnection;
|
|
54
54
|
//# sourceMappingURL=MobilePush.js.map
|
|
@@ -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,4CAA4C;AAE5C,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,gBAAgB;AAChB,MAAa,mBAAoB,SAAQ,8BAAgB;
|
|
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;IAIvD,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAExC,YAAmB,QAA2B;QAC5C,KAAK,EAAE,CAAC;QALF,UAAK,GAAW,CAAC,CAAC,CAAC;QAMzB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEM,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,41 +1,41 @@
|
|
|
1
|
-
import { RpcConfiguration, RpcInterfaceDefinition } from "@itwin/core-common";
|
|
2
|
-
import { MobileRpcProtocol } from "./MobileRpcProtocol";
|
|
3
|
-
/** RPC supported mobile platforms.
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare enum RpcMobilePlatform {
|
|
7
|
-
Unknown = 0,
|
|
8
|
-
Android = 1,
|
|
9
|
-
iOS = 2
|
|
10
|
-
}
|
|
11
|
-
/** Holds configuration for the RpcInterfaces used by the application.
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare abstract class MobileRpcConfiguration extends RpcConfiguration {
|
|
15
|
-
/** @internal */
|
|
16
|
-
static setup: {
|
|
17
|
-
obtainPort: () => number;
|
|
18
|
-
checkPlatform: () => boolean;
|
|
19
|
-
};
|
|
20
|
-
abstract protocol: MobileRpcProtocol;
|
|
21
|
-
private static _args;
|
|
22
|
-
private static getArgs;
|
|
23
|
-
private static getMobilePlatform;
|
|
24
|
-
/** Read the mobile rpc args */
|
|
25
|
-
static get args(): any;
|
|
26
|
-
/** Return type of mobile platform using browser userAgent */
|
|
27
|
-
static get platform(): RpcMobilePlatform;
|
|
28
|
-
}
|
|
29
|
-
/** Coordinates usage of RPC interfaces for an Mobile-based application.
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
export declare class MobileRpcManager {
|
|
33
|
-
/** @internal */
|
|
34
|
-
static ready(): Promise<void>;
|
|
35
|
-
private static performInitialization;
|
|
36
|
-
/** Initializes MobileRpcManager for the frontend of an application. */
|
|
37
|
-
static initializeClient(interfaces: RpcInterfaceDefinition[]): MobileRpcConfiguration;
|
|
38
|
-
/** Initializes MobileRpcManager for the backend of an application. */
|
|
39
|
-
static initializeImpl(interfaces: RpcInterfaceDefinition[]): MobileRpcConfiguration;
|
|
40
|
-
}
|
|
1
|
+
import { RpcConfiguration, RpcInterfaceDefinition } from "@itwin/core-common";
|
|
2
|
+
import { MobileRpcProtocol } from "./MobileRpcProtocol";
|
|
3
|
+
/** RPC supported mobile platforms.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare enum RpcMobilePlatform {
|
|
7
|
+
Unknown = 0,
|
|
8
|
+
Android = 1,
|
|
9
|
+
iOS = 2
|
|
10
|
+
}
|
|
11
|
+
/** Holds configuration for the RpcInterfaces used by the application.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class MobileRpcConfiguration extends RpcConfiguration {
|
|
15
|
+
/** @internal */
|
|
16
|
+
static setup: {
|
|
17
|
+
obtainPort: () => number;
|
|
18
|
+
checkPlatform: () => boolean;
|
|
19
|
+
};
|
|
20
|
+
abstract protocol: MobileRpcProtocol;
|
|
21
|
+
private static _args;
|
|
22
|
+
private static getArgs;
|
|
23
|
+
private static getMobilePlatform;
|
|
24
|
+
/** Read the mobile rpc args */
|
|
25
|
+
static get args(): any;
|
|
26
|
+
/** Return type of mobile platform using browser userAgent */
|
|
27
|
+
static get platform(): RpcMobilePlatform;
|
|
28
|
+
}
|
|
29
|
+
/** Coordinates usage of RPC interfaces for an Mobile-based application.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare class MobileRpcManager {
|
|
33
|
+
/** @internal */
|
|
34
|
+
static ready(): Promise<void>;
|
|
35
|
+
private static performInitialization;
|
|
36
|
+
/** Initializes MobileRpcManager for the frontend of an application. */
|
|
37
|
+
static initializeClient(interfaces: RpcInterfaceDefinition[]): MobileRpcConfiguration;
|
|
38
|
+
/** Initializes MobileRpcManager for the backend of an application. */
|
|
39
|
+
static initializeImpl(interfaces: RpcInterfaceDefinition[]): MobileRpcConfiguration;
|
|
40
|
+
}
|
|
41
41
|
//# sourceMappingURL=MobileRpcManager.d.ts.map
|