@itwin/core-mobile 4.0.0-dev.7 → 4.0.0-dev.72
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 +48 -1
- package/README.md +1 -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 +117 -149
- package/lib/cjs/backend/Request.d.ts.map +1 -1
- package/lib/cjs/backend/Request.js +255 -267
- package/lib/cjs/backend/Request.js.map +1 -1
- 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 +20 -24
|
@@ -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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Ac,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
|
|
@@ -1,111 +1,111 @@
|
|
|
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.MobileRpcManager = exports.MobileRpcConfiguration = exports.RpcMobilePlatform = void 0;
|
|
8
|
-
const core_common_1 = require("@itwin/core-common");
|
|
9
|
-
const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
|
|
10
|
-
/* eslint-disable deprecation/deprecation */
|
|
11
|
-
/** RPC supported mobile platforms.
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
var RpcMobilePlatform;
|
|
15
|
-
(function (RpcMobilePlatform) {
|
|
16
|
-
RpcMobilePlatform[RpcMobilePlatform["Unknown"] = 0] = "Unknown";
|
|
17
|
-
RpcMobilePlatform[RpcMobilePlatform["Android"] = 1] = "Android";
|
|
18
|
-
RpcMobilePlatform[RpcMobilePlatform["iOS"] = 2] = "iOS";
|
|
19
|
-
})(RpcMobilePlatform = exports.RpcMobilePlatform || (exports.RpcMobilePlatform = {}));
|
|
20
|
-
/** Holds configuration for the RpcInterfaces used by the application.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
class MobileRpcConfiguration extends core_common_1.RpcConfiguration {
|
|
24
|
-
static getArgs() {
|
|
25
|
-
if (typeof window !== "object" || typeof window.location !== "object" || typeof window.location.hash !== "string") {
|
|
26
|
-
return Object.freeze({});
|
|
27
|
-
}
|
|
28
|
-
const queryArgs = {};
|
|
29
|
-
try {
|
|
30
|
-
const matches = window.location.hash.match(/([^#=&]+)(=([^&]*))?/g);
|
|
31
|
-
if (matches) {
|
|
32
|
-
for (const comp of matches) {
|
|
33
|
-
const array = comp.split("=");
|
|
34
|
-
if (array.length === 2) {
|
|
35
|
-
const key = decodeURIComponent(array[0]);
|
|
36
|
-
const val = decodeURIComponent(array[1]);
|
|
37
|
-
queryArgs[key] = val;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch { }
|
|
43
|
-
return Object.freeze(queryArgs);
|
|
44
|
-
}
|
|
45
|
-
static getMobilePlatform() {
|
|
46
|
-
if (!MobileRpcConfiguration.args.platform)
|
|
47
|
-
return RpcMobilePlatform.Unknown;
|
|
48
|
-
const win = window;
|
|
49
|
-
if (/android/i.test(MobileRpcConfiguration.args.platform)) {
|
|
50
|
-
return RpcMobilePlatform.Android;
|
|
51
|
-
}
|
|
52
|
-
if (/iOS|iPadOS/i.test(MobileRpcConfiguration.args.platform) && !win.MSStream) {
|
|
53
|
-
return RpcMobilePlatform.iOS;
|
|
54
|
-
}
|
|
55
|
-
return RpcMobilePlatform.Unknown;
|
|
56
|
-
}
|
|
57
|
-
/** Read the mobile rpc args */
|
|
58
|
-
static get args() {
|
|
59
|
-
if (!this._args) {
|
|
60
|
-
this._args = MobileRpcConfiguration.getArgs();
|
|
61
|
-
}
|
|
62
|
-
return this._args;
|
|
63
|
-
}
|
|
64
|
-
/** Return type of mobile platform using browser userAgent */
|
|
65
|
-
static get platform() { return MobileRpcConfiguration.getMobilePlatform(); }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/** Coordinates usage of RPC interfaces for an Mobile-based application.
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
class MobileRpcManager {
|
|
77
|
-
/** @internal */
|
|
78
|
-
static async ready() {
|
|
79
|
-
return new Promise(async (resolve) => {
|
|
80
|
-
while (!global.__iTwinJsRpcReady) {
|
|
81
|
-
await new Promise((r) => setTimeout(r));
|
|
82
|
-
}
|
|
83
|
-
resolve();
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
static performInitialization(interfaces, endPoint) {
|
|
87
|
-
const config = class extends MobileRpcConfiguration {
|
|
88
|
-
constructor() {
|
|
89
|
-
super(...arguments);
|
|
90
|
-
this.interfaces = () => interfaces;
|
|
91
|
-
this.protocol = new MobileRpcProtocol_1.MobileRpcProtocol(this, endPoint);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
for (const def of interfaces) {
|
|
95
|
-
core_common_1.RpcConfiguration.assign(def, () => config);
|
|
96
|
-
}
|
|
97
|
-
const instance = core_common_1.RpcConfiguration.obtain(config);
|
|
98
|
-
core_common_1.RpcConfiguration.initializeInterfaces(instance);
|
|
99
|
-
return instance;
|
|
100
|
-
}
|
|
101
|
-
/** Initializes MobileRpcManager for the frontend of an application. */
|
|
102
|
-
static initializeClient(interfaces) {
|
|
103
|
-
return MobileRpcManager.performInitialization(interfaces, core_common_1.RpcEndpoint.Frontend);
|
|
104
|
-
}
|
|
105
|
-
/** Initializes MobileRpcManager for the backend of an application. */
|
|
106
|
-
static initializeImpl(interfaces) {
|
|
107
|
-
return MobileRpcManager.performInitialization(interfaces, core_common_1.RpcEndpoint.Backend);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.MobileRpcManager = MobileRpcManager;
|
|
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.MobileRpcManager = exports.MobileRpcConfiguration = exports.RpcMobilePlatform = void 0;
|
|
8
|
+
const core_common_1 = require("@itwin/core-common");
|
|
9
|
+
const MobileRpcProtocol_1 = require("./MobileRpcProtocol");
|
|
10
|
+
/* eslint-disable deprecation/deprecation */
|
|
11
|
+
/** RPC supported mobile platforms.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
var RpcMobilePlatform;
|
|
15
|
+
(function (RpcMobilePlatform) {
|
|
16
|
+
RpcMobilePlatform[RpcMobilePlatform["Unknown"] = 0] = "Unknown";
|
|
17
|
+
RpcMobilePlatform[RpcMobilePlatform["Android"] = 1] = "Android";
|
|
18
|
+
RpcMobilePlatform[RpcMobilePlatform["iOS"] = 2] = "iOS";
|
|
19
|
+
})(RpcMobilePlatform = exports.RpcMobilePlatform || (exports.RpcMobilePlatform = {}));
|
|
20
|
+
/** Holds configuration for the RpcInterfaces used by the application.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
class MobileRpcConfiguration extends core_common_1.RpcConfiguration {
|
|
24
|
+
static getArgs() {
|
|
25
|
+
if (typeof window !== "object" || typeof window.location !== "object" || typeof window.location.hash !== "string") {
|
|
26
|
+
return Object.freeze({});
|
|
27
|
+
}
|
|
28
|
+
const queryArgs = {};
|
|
29
|
+
try {
|
|
30
|
+
const matches = window.location.hash.match(/([^#=&]+)(=([^&]*))?/g);
|
|
31
|
+
if (matches) {
|
|
32
|
+
for (const comp of matches) {
|
|
33
|
+
const array = comp.split("=");
|
|
34
|
+
if (array.length === 2) {
|
|
35
|
+
const key = decodeURIComponent(array[0]);
|
|
36
|
+
const val = decodeURIComponent(array[1]);
|
|
37
|
+
queryArgs[key] = val;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch { }
|
|
43
|
+
return Object.freeze(queryArgs);
|
|
44
|
+
}
|
|
45
|
+
static getMobilePlatform() {
|
|
46
|
+
if (!MobileRpcConfiguration.args.platform)
|
|
47
|
+
return RpcMobilePlatform.Unknown;
|
|
48
|
+
const win = window;
|
|
49
|
+
if (/android/i.test(MobileRpcConfiguration.args.platform)) {
|
|
50
|
+
return RpcMobilePlatform.Android;
|
|
51
|
+
}
|
|
52
|
+
if (/iOS|iPadOS/i.test(MobileRpcConfiguration.args.platform) && !win.MSStream) {
|
|
53
|
+
return RpcMobilePlatform.iOS;
|
|
54
|
+
}
|
|
55
|
+
return RpcMobilePlatform.Unknown;
|
|
56
|
+
}
|
|
57
|
+
/** Read the mobile rpc args */
|
|
58
|
+
static get args() {
|
|
59
|
+
if (!this._args) {
|
|
60
|
+
this._args = MobileRpcConfiguration.getArgs();
|
|
61
|
+
}
|
|
62
|
+
return this._args;
|
|
63
|
+
}
|
|
64
|
+
/** Return type of mobile platform using browser userAgent */
|
|
65
|
+
static get platform() { return MobileRpcConfiguration.getMobilePlatform(); }
|
|
66
|
+
}
|
|
67
|
+
/** @internal */
|
|
68
|
+
MobileRpcConfiguration.setup = {
|
|
69
|
+
obtainPort: () => 0,
|
|
70
|
+
checkPlatform: () => typeof (process) !== "undefined" && process.platform === "ios",
|
|
71
|
+
};
|
|
72
|
+
exports.MobileRpcConfiguration = MobileRpcConfiguration;
|
|
73
|
+
/** Coordinates usage of RPC interfaces for an Mobile-based application.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
class MobileRpcManager {
|
|
77
|
+
/** @internal */
|
|
78
|
+
static async ready() {
|
|
79
|
+
return new Promise(async (resolve) => {
|
|
80
|
+
while (!global.__iTwinJsRpcReady) {
|
|
81
|
+
await new Promise((r) => setTimeout(r));
|
|
82
|
+
}
|
|
83
|
+
resolve();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
static performInitialization(interfaces, endPoint) {
|
|
87
|
+
const config = class extends MobileRpcConfiguration {
|
|
88
|
+
constructor() {
|
|
89
|
+
super(...arguments);
|
|
90
|
+
this.interfaces = () => interfaces;
|
|
91
|
+
this.protocol = new MobileRpcProtocol_1.MobileRpcProtocol(this, endPoint);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
for (const def of interfaces) {
|
|
95
|
+
core_common_1.RpcConfiguration.assign(def, () => config);
|
|
96
|
+
}
|
|
97
|
+
const instance = core_common_1.RpcConfiguration.obtain(config);
|
|
98
|
+
core_common_1.RpcConfiguration.initializeInterfaces(instance);
|
|
99
|
+
return instance;
|
|
100
|
+
}
|
|
101
|
+
/** Initializes MobileRpcManager for the frontend of an application. */
|
|
102
|
+
static initializeClient(interfaces) {
|
|
103
|
+
return MobileRpcManager.performInitialization(interfaces, core_common_1.RpcEndpoint.Frontend);
|
|
104
|
+
}
|
|
105
|
+
/** Initializes MobileRpcManager for the backend of an application. */
|
|
106
|
+
static initializeImpl(interfaces) {
|
|
107
|
+
return MobileRpcManager.performInitialization(interfaces, core_common_1.RpcEndpoint.Backend);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.MobileRpcManager = MobileRpcManager;
|
|
111
111
|
//# sourceMappingURL=MobileRpcManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileRpcManager.js","sourceRoot":"","sources":["../../../src/common/MobileRpcManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,oDAA2F;AAC3F,2DAAwD;AAExD,4CAA4C;AAE5C;;GAEG;AACH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,+DAAO,CAAA;IACP,+DAAO,CAAA;IACP,uDAAG,CAAA;AACL,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAED;;GAEG;AACH,MAAsB,sBAAuB,SAAQ,8BAAgB;IAS3D,MAAM,CAAC,OAAO;QACpB,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE;YACjH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SAC1B;QACD,MAAM,SAAS,GAAQ,EAAE,CAAC;QAC1B,IAAI;YACF,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACpE,IAAI,OAAO,EAAE;gBACX,KAAK,MAAM,IAAI,IAAI,OA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AE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;aACzC;YAED,OAAO,EAAE,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"]}
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module RpcInterface
|
|
3
|
-
*/
|
|
4
|
-
import { RpcEndpoint, RpcProtocol, RpcRequestFulfillment } from "@itwin/core-common";
|
|
5
|
-
import { MobileRpcConfiguration } from "./MobileRpcManager";
|
|
6
|
-
import { MobileRpcRequest } from "./MobileRpcRequest";
|
|
7
|
-
/** @internal */
|
|
8
|
-
export
|
|
9
|
-
/** @internal */
|
|
10
|
-
export interface MobileRpcGateway {
|
|
11
|
-
handler: (payload: ArrayBuffer | string, connectionId: number) => void;
|
|
12
|
-
sendString: (message: string, connectionId: number) => void;
|
|
13
|
-
sendBinary: (message: Uint8Array, connectionId: number) => void;
|
|
14
|
-
port: number;
|
|
15
|
-
connectionId: number;
|
|
16
|
-
}
|
|
17
|
-
/** RPC interface protocol for an Mobile-based application.
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
export declare class MobileRpcProtocol extends RpcProtocol {
|
|
21
|
-
socket: WebSocket;
|
|
22
|
-
requests: Map<string, MobileRpcRequest>;
|
|
23
|
-
private _pending;
|
|
24
|
-
private _capacity;
|
|
25
|
-
private _sendInterval;
|
|
26
|
-
private _sendIntervalHandler;
|
|
27
|
-
readonly requestType: typeof MobileRpcRequest;
|
|
28
|
-
private _partialRequest;
|
|
29
|
-
private _partialFulfillment;
|
|
30
|
-
private _partialData;
|
|
31
|
-
private _port;
|
|
32
|
-
private _transport?;
|
|
33
|
-
private _ipc;
|
|
34
|
-
static obtainInterop(): MobileRpcGateway;
|
|
35
|
-
static encodeRequest(request: MobileRpcRequest): Promise<MobileRpcChunks>;
|
|
36
|
-
static encodeResponse(fulfillment: RpcRequestFulfillment): MobileRpcChunks;
|
|
37
|
-
constructor(configuration: MobileRpcConfiguration, endPoint: RpcEndpoint);
|
|
38
|
-
private initializeFrontend;
|
|
39
|
-
private connect;
|
|
40
|
-
private connectMessageHandler;
|
|
41
|
-
private connectOpenHandler;
|
|
42
|
-
private connectErrorHandler;
|
|
43
|
-
private reset;
|
|
44
|
-
private scheduleSend;
|
|
45
|
-
private trySend;
|
|
46
|
-
private handleMessageFromBackend;
|
|
47
|
-
private handleStringFromBackend;
|
|
48
|
-
private handleBinaryFromBackend;
|
|
49
|
-
private notifyResponse;
|
|
50
|
-
private consumePartialData;
|
|
51
|
-
private initializeBackend;
|
|
52
|
-
private handleMessageFromFrontend;
|
|
53
|
-
private handleStringFromFrontend;
|
|
54
|
-
private handleBinaryFromFrontend;
|
|
55
|
-
private notifyRequest;
|
|
56
|
-
sendToBackend(message: MobileRpcChunks): void;
|
|
57
|
-
sendToFrontend(message: MobileRpcChunks, connection?: number): void;
|
|
58
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module RpcInterface
|
|
3
|
+
*/
|
|
4
|
+
import { RpcEndpoint, RpcProtocol, RpcRequestFulfillment } from "@itwin/core-common";
|
|
5
|
+
import { MobileRpcConfiguration } from "./MobileRpcManager";
|
|
6
|
+
import { MobileRpcRequest } from "./MobileRpcRequest";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export type MobileRpcChunks = Array<string | Uint8Array>;
|
|
9
|
+
/** @internal */
|
|
10
|
+
export interface MobileRpcGateway {
|
|
11
|
+
handler: (payload: ArrayBuffer | string, connectionId: number) => void;
|
|
12
|
+
sendString: (message: string, connectionId: number) => void;
|
|
13
|
+
sendBinary: (message: Uint8Array, connectionId: number) => void;
|
|
14
|
+
port: number;
|
|
15
|
+
connectionId: number;
|
|
16
|
+
}
|
|
17
|
+
/** RPC interface protocol for an Mobile-based application.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare class MobileRpcProtocol extends RpcProtocol {
|
|
21
|
+
socket: WebSocket;
|
|
22
|
+
requests: Map<string, MobileRpcRequest>;
|
|
23
|
+
private _pending;
|
|
24
|
+
private _capacity;
|
|
25
|
+
private _sendInterval;
|
|
26
|
+
private _sendIntervalHandler;
|
|
27
|
+
readonly requestType: typeof MobileRpcRequest;
|
|
28
|
+
private _partialRequest;
|
|
29
|
+
private _partialFulfillment;
|
|
30
|
+
private _partialData;
|
|
31
|
+
private _port;
|
|
32
|
+
private _transport?;
|
|
33
|
+
private _ipc;
|
|
34
|
+
static obtainInterop(): MobileRpcGateway;
|
|
35
|
+
static encodeRequest(request: MobileRpcRequest): Promise<MobileRpcChunks>;
|
|
36
|
+
static encodeResponse(fulfillment: RpcRequestFulfillment): MobileRpcChunks;
|
|
37
|
+
constructor(configuration: MobileRpcConfiguration, endPoint: RpcEndpoint);
|
|
38
|
+
private initializeFrontend;
|
|
39
|
+
private connect;
|
|
40
|
+
private connectMessageHandler;
|
|
41
|
+
private connectOpenHandler;
|
|
42
|
+
private connectErrorHandler;
|
|
43
|
+
private reset;
|
|
44
|
+
private scheduleSend;
|
|
45
|
+
private trySend;
|
|
46
|
+
private handleMessageFromBackend;
|
|
47
|
+
private handleStringFromBackend;
|
|
48
|
+
private handleBinaryFromBackend;
|
|
49
|
+
private notifyResponse;
|
|
50
|
+
private consumePartialData;
|
|
51
|
+
private initializeBackend;
|
|
52
|
+
private handleMessageFromFrontend;
|
|
53
|
+
private handleStringFromFrontend;
|
|
54
|
+
private handleBinaryFromFrontend;
|
|
55
|
+
private notifyRequest;
|
|
56
|
+
sendToBackend(message: MobileRpcChunks): void;
|
|
57
|
+
sendToFrontend(message: MobileRpcChunks, connection?: number): void;
|
|
58
|
+
}
|
|
59
59
|
//# sourceMappingURL=MobileRpcProtocol.d.ts.map
|
|
@@ -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;AAItD,gBAAgB;AAChB,
|
|
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,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,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