@itwin/core-common 4.0.0-dev.1 → 4.0.0-dev.4
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/lib/cjs/rpc/core/RpcControl.d.ts +0 -3
- package/lib/cjs/rpc/core/RpcControl.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcControl.js +0 -3
- package/lib/cjs/rpc/core/RpcControl.js.map +1 -1
- package/lib/esm/rpc/core/RpcControl.d.ts +0 -3
- package/lib/esm/rpc/core/RpcControl.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcControl.js +0 -3
- package/lib/esm/rpc/core/RpcControl.js.map +1 -1
- package/package.json +7 -7
|
@@ -6,14 +6,12 @@ import { RpcConfiguration } from "./RpcConfiguration";
|
|
|
6
6
|
import { RpcInvocation } from "./RpcInvocation";
|
|
7
7
|
/** An RPC operation control response.
|
|
8
8
|
* @public
|
|
9
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
10
9
|
*/
|
|
11
10
|
export declare abstract class RpcControlResponse {
|
|
12
11
|
message: string;
|
|
13
12
|
}
|
|
14
13
|
/** A pending RPC operation response.
|
|
15
14
|
* @public
|
|
16
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
17
15
|
*/
|
|
18
16
|
export declare class RpcPendingResponse extends RpcControlResponse {
|
|
19
17
|
/** Extended status regarding the pending operation. */
|
|
@@ -23,7 +21,6 @@ export declare class RpcPendingResponse extends RpcControlResponse {
|
|
|
23
21
|
}
|
|
24
22
|
/** A RPC operation response.
|
|
25
23
|
* @public
|
|
26
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
27
24
|
*/
|
|
28
25
|
export declare class RpcNotFoundResponse extends RpcControlResponse {
|
|
29
26
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcControl.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,qBAAqB,EAAc,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD
|
|
1
|
+
{"version":3,"file":"RpcControl.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,qBAAqB,EAAc,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD;;GAEG;AACH,8BAAsB,kBAAkB;IAC/B,OAAO,SAAwB;CACvC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,uDAAuD;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhC,qCAAqC;gBAClB,OAAO,GAAE,MAAW;CAIxC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzC,OAAO,SAAe;CACvC;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,gBAAgB;IAChB,OAAc,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IACjD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAK;IAC/B,OAAO,CAAC,cAAc,CAAmB;IACzC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAA4D;IAEtF,gBAAgB;WACF,iBAAiB;IAI/B,OAAO;IAKP,gBAAgB;IACH,iBAAiB;IAS9B,gBAAgB;WACF,MAAM,CAAC,aAAa,EAAE,gBAAgB,GAAG,iBAAiB;IAWxE,OAAO,CAAC,iBAAiB,CAIvB;IAEF,OAAO,CAAC,YAAY,CAelB;IAEF,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,cAAc;IAatB,gBAAgB;IACT,UAAU;IAgBjB,gBAAgB;IACT,sBAAsB,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO;CAc/E"}
|
|
@@ -17,7 +17,6 @@ const RpcRegistry_1 = require("./RpcRegistry");
|
|
|
17
17
|
/* eslint-disable deprecation/deprecation */
|
|
18
18
|
/** An RPC operation control response.
|
|
19
19
|
* @public
|
|
20
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
21
20
|
*/
|
|
22
21
|
class RpcControlResponse {
|
|
23
22
|
constructor() {
|
|
@@ -27,7 +26,6 @@ class RpcControlResponse {
|
|
|
27
26
|
exports.RpcControlResponse = RpcControlResponse;
|
|
28
27
|
/** A pending RPC operation response.
|
|
29
28
|
* @public
|
|
30
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
31
29
|
*/
|
|
32
30
|
class RpcPendingResponse extends RpcControlResponse {
|
|
33
31
|
/** Constructs a pending response. */
|
|
@@ -39,7 +37,6 @@ class RpcPendingResponse extends RpcControlResponse {
|
|
|
39
37
|
exports.RpcPendingResponse = RpcPendingResponse;
|
|
40
38
|
/** A RPC operation response.
|
|
41
39
|
* @public
|
|
42
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
43
40
|
*/
|
|
44
41
|
class RpcNotFoundResponse extends RpcControlResponse {
|
|
45
42
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yCAAmC;AAEnC,qDAAkD;AAClD,iDAAqE;AACrE,yDAAsD;AAEtD,iDAA8C;AAC9C,+CAA4C;AAE5C,4CAA4C;AAE5C;;;GAGG;AACH,MAAsB,kBAAkB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,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,WAAkB,CAAC,CAAC;QAC9F,uBAAU,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,uBAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEvD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACT,sBAAsB,CAAC,UAAyB,EAAE,MAAW;QAClE,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,EAAE,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,CAAC,aAAa,KAAK,mBAAmB,EAAE;YACjF,IAAI,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE;gBACxC,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;aAC/D;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AApHH,8CAqHC;AApHC,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { Base64 } from \"js-base64\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport abstract class RpcControlResponse {\r\n public message = \"RpcControlResponse\";\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public override message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n public override message = \"Not found\";\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n /** @internal */\r\n public static ensureInitialized() {\r\n this.channels.forEach((channel) => channel.initialize());\r\n }\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n if (!this._channelInterface.interfaceName) {\r\n return [];\r\n }\r\n\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n return Base64.encode(id);\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n this.initialize();\r\n\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n this._clientActive = true;\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized) {\r\n return;\r\n }\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n\r\n this._initialized = true;\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n this.initialize();\r\n\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n if (this._channelInterface.interfaceName) {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yCAAmC;AAEnC,qDAAkD;AAClD,iDAAqE;AACrE,yDAAsD;AAEtD,iDAA8C;AAC9C,+CAA4C;AAE5C,4CAA4C;AAE5C;;GAEG;AACH,MAAsB,kBAAkB;IAAxC;QACS,YAAO,GAAG,oBAAoB,CAAC;IACxC,CAAC;CAAA;AAFD,gDAEC;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,kBAAkB;IAIxD,qCAAqC;IACrC,YAAmB,UAAkB,EAAE;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AATD,gDASC;AAED;;GAEG;AACH,MAAa,mBAAoB,SAAQ,kBAAkB;IAA3D;;QACkB,YAAO,GAAG,WAAW,CAAC;IACxC,CAAC;CAAA;AAFD,kDAEC;AAED;;GAEG;AACH,MAAa,iBAAiB;IAc5B,YAAoB,aAA+B;;QAT3C,iBAAY,GAAG,KAAK,CAAC;QACrB,kBAAa,GAAG,KAAK,CAAC;QACtB,uBAAkB,GAA2C,SAAgB,CAAC;QAkC9E,sBAAiB,SAAG,KAAM,SAAQ,2BAAY;gBAG7C,KAAK,CAAC,i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AAa,EAAE;gBACxC,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;aAC/D;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AApHH,8CAqHC;AApHC,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { Base64 } from \"js-base64\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n */\r\nexport abstract class RpcControlResponse {\r\n public message = \"RpcControlResponse\";\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public override message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n public override message = \"Not found\";\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n /** @internal */\r\n public static ensureInitialized() {\r\n this.channels.forEach((channel) => channel.initialize());\r\n }\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n if (!this._channelInterface.interfaceName) {\r\n return [];\r\n }\r\n\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n return Base64.encode(id);\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n this.initialize();\r\n\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n this._clientActive = true;\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized) {\r\n return;\r\n }\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n\r\n this._initialized = true;\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n this.initialize();\r\n\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n if (this._channelInterface.interfaceName) {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
|
|
@@ -6,14 +6,12 @@ import { RpcConfiguration } from "./RpcConfiguration";
|
|
|
6
6
|
import { RpcInvocation } from "./RpcInvocation";
|
|
7
7
|
/** An RPC operation control response.
|
|
8
8
|
* @public
|
|
9
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
10
9
|
*/
|
|
11
10
|
export declare abstract class RpcControlResponse {
|
|
12
11
|
message: string;
|
|
13
12
|
}
|
|
14
13
|
/** A pending RPC operation response.
|
|
15
14
|
* @public
|
|
16
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
17
15
|
*/
|
|
18
16
|
export declare class RpcPendingResponse extends RpcControlResponse {
|
|
19
17
|
/** Extended status regarding the pending operation. */
|
|
@@ -23,7 +21,6 @@ export declare class RpcPendingResponse extends RpcControlResponse {
|
|
|
23
21
|
}
|
|
24
22
|
/** A RPC operation response.
|
|
25
23
|
* @public
|
|
26
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
27
24
|
*/
|
|
28
25
|
export declare class RpcNotFoundResponse extends RpcControlResponse {
|
|
29
26
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcControl.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,qBAAqB,EAAc,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD
|
|
1
|
+
{"version":3,"file":"RpcControl.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,qBAAqB,EAAc,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD;;GAEG;AACH,8BAAsB,kBAAkB;IAC/B,OAAO,SAAwB;CACvC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,uDAAuD;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhC,qCAAqC;gBAClB,OAAO,GAAE,MAAW;CAIxC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzC,OAAO,SAAe;CACvC;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,gBAAgB;IAChB,OAAc,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IACjD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAK;IAC/B,OAAO,CAAC,cAAc,CAAmB;IACzC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAA4D;IAEtF,gBAAgB;WACF,iBAAiB;IAI/B,OAAO;IAKP,gBAAgB;IACH,iBAAiB;IAS9B,gBAAgB;WACF,MAAM,CAAC,aAAa,EAAE,gBAAgB,GAAG,iBAAiB;IAWxE,OAAO,CAAC,iBAAiB,CAIvB;IAEF,OAAO,CAAC,YAAY,CAelB;IAEF,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,cAAc;IAatB,gBAAgB;IACT,UAAU;IAgBjB,gBAAgB;IACT,sBAAsB,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO;CAc/E"}
|
|
@@ -14,7 +14,6 @@ import { RpcRegistry } from "./RpcRegistry";
|
|
|
14
14
|
/* eslint-disable deprecation/deprecation */
|
|
15
15
|
/** An RPC operation control response.
|
|
16
16
|
* @public
|
|
17
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
18
17
|
*/
|
|
19
18
|
export class RpcControlResponse {
|
|
20
19
|
constructor() {
|
|
@@ -23,7 +22,6 @@ export class RpcControlResponse {
|
|
|
23
22
|
}
|
|
24
23
|
/** A pending RPC operation response.
|
|
25
24
|
* @public
|
|
26
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
27
25
|
*/
|
|
28
26
|
export class RpcPendingResponse extends RpcControlResponse {
|
|
29
27
|
/** Constructs a pending response. */
|
|
@@ -34,7 +32,6 @@ export class RpcPendingResponse extends RpcControlResponse {
|
|
|
34
32
|
}
|
|
35
33
|
/** A RPC operation response.
|
|
36
34
|
* @public
|
|
37
|
-
* @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.
|
|
38
35
|
*/
|
|
39
36
|
export class RpcNotFoundResponse extends RpcControlResponse {
|
|
40
37
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAyB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,4CAA4C;AAE5C;;;GAGG;AACH,MAAM,OAAgB,kBAAkB;IAAxC;QACS,YAAO,GAAG,oBAAoB,CAAC;IACxC,CAAC;CAAA;AAED;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IAIxD,qCAAqC;IACrC,YAAmB,UAAkB,EAAE;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IAA3D;;QACkB,YAAO,GAAG,WAAW,CAAC;IACxC,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAc5B,YAAoB,aAA+B;;QAT3C,iBAAY,GAAG,KAAK,CAAC;QACrB,kBAAa,GAAG,KAAK,CAAC;QACtB,uBAAkB,GAA2C,SAAgB,CAAC;QAkC9E,sBAAiB,SAAG,KAAM,SAAQ,YAAY;gBAG7C,KAAK,CAAC,iBAAiB,KAAuC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,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iB,CAAC,aAAa,CAAC;aAC/D;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AAnHD,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { Base64 } from \"js-base64\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport abstract class RpcControlResponse {\r\n public message = \"RpcControlResponse\";\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public override message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n * @deprecated in 3.6. The RPC system will be significantly refactored (or replaced) in version 5.0.\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n public override message = \"Not found\";\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n /** @internal */\r\n public static ensureInitialized() {\r\n this.channels.forEach((channel) => channel.initialize());\r\n }\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n if (!this._channelInterface.interfaceName) {\r\n return [];\r\n }\r\n\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n return Base64.encode(id);\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n this.initialize();\r\n\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n this._clientActive = true;\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized) {\r\n return;\r\n }\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n\r\n this._initialized = true;\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n this.initialize();\r\n\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n if (this._channelInterface.interfaceName) {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcControl.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcControl.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAyB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAA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E,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QAEzE,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,WAAkB,CAAC,CAAC;QAC9F,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEvD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACT,sBAAsB,CAAC,UAAyB,EAAE,MAAW;QAClE,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,EAAE,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,CAAC,aAAa,KAAK,mBAAmB,EAAE;YACjF,IAAI,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE;gBACxC,EAAE,CAAC,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;aAC/D;YAED,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;;AAnHD,gBAAgB;AACF,0BAAQ,GAAwB,EAAE,CAAC;AAClC,6BAAW,GAAG,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { Base64 } from \"js-base64\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { RpcInterfaceEndpoints, RpcManager } from \"../../RpcManager\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcInvocation } from \"./RpcInvocation\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** An RPC operation control response.\r\n * @public\r\n */\r\nexport abstract class RpcControlResponse {\r\n public message = \"RpcControlResponse\";\r\n}\r\n\r\n/** A pending RPC operation response.\r\n * @public\r\n */\r\nexport class RpcPendingResponse extends RpcControlResponse {\r\n /** Extended status regarding the pending operation. */\r\n public override message: string;\r\n\r\n /** Constructs a pending response. */\r\n public constructor(message: string = \"\") {\r\n super();\r\n this.message = message;\r\n }\r\n}\r\n\r\n/** A RPC operation response.\r\n * @public\r\n */\r\nexport class RpcNotFoundResponse extends RpcControlResponse {\r\n public override message = \"Not found\";\r\n}\r\n\r\n/** Manages requests and responses for an RPC configuration.\r\n * @internal\r\n */\r\nexport class RpcControlChannel {\r\n /** @internal */\r\n public static channels: RpcControlChannel[] = [];\r\n private static _obtainLock = 0;\r\n private _configuration: RpcConfiguration;\r\n private _initialized = false;\r\n private _clientActive = false;\r\n private _describeEndpoints: () => Promise<RpcInterfaceEndpoints[]> = undefined as any;\r\n\r\n /** @internal */\r\n public static ensureInitialized() {\r\n this.channels.forEach((channel) => channel.initialize());\r\n }\r\n\r\n private constructor(configuration: RpcConfiguration) {\r\n this._configuration = configuration;\r\n RpcControlChannel.channels.push(this);\r\n }\r\n\r\n /** @internal */\r\n public async describeEndpoints() {\r\n this.activateClient();\r\n if (!this._channelInterface.interfaceName) {\r\n return [];\r\n }\r\n\r\n return this._describeEndpoints();\r\n }\r\n\r\n /** @internal */\r\n public static obtain(configuration: RpcConfiguration): RpcControlChannel {\r\n if (RpcControlChannel._obtainLock)\r\n return undefined as any;\r\n\r\n ++RpcControlChannel._obtainLock;\r\n const channel = new RpcControlChannel(configuration);\r\n --RpcControlChannel._obtainLock;\r\n\r\n return channel;\r\n }\r\n\r\n private _channelInterface = class extends RpcInterface {\r\n public static readonly interfaceVersion = \"CONTROL\";\r\n public static readonly interfaceName = \"\";\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> { return this.forward(arguments); }\r\n };\r\n\r\n private _channelImpl = class extends RpcInterface {\r\n public async describeEndpoints(): Promise<RpcInterfaceEndpoints[]> {\r\n const endpoints: RpcInterfaceEndpoints[] = [];\r\n\r\n this.configuration.interfaces().forEach((definition) => {\r\n if (!RpcRegistry.instance.isRpcInterfaceInitialized(definition))\r\n return;\r\n\r\n const description: RpcInterfaceEndpoints = { interfaceName: definition.interfaceName, interfaceVersion: definition.interfaceVersion, operationNames: [], compatible: true };\r\n RpcOperation.forEach(definition, (operation) => description.operationNames.push(operation.operationName));\r\n endpoints.push(description);\r\n });\r\n\r\n return endpoints;\r\n }\r\n };\r\n\r\n private computeId(): string {\r\n const interfaces: string[] = [];\r\n this._configuration.interfaces().forEach((definition) => interfaces.push(`${definition.interfaceName}@${definition.interfaceVersion}`));\r\n const id = interfaces.sort().join(\",\");\r\n\r\n return Base64.encode(id);\r\n }\r\n\r\n private activateClient() {\r\n if (this._clientActive)\r\n return;\r\n\r\n this.initialize();\r\n\r\n const token: IModelRpcProps = { key: \"none\", iTwinId: \"none\", iModelId: \"none\", changeset: { id: \"none\" } };\r\n RpcOperation.forEach(this._channelInterface, (operation) => operation.policy.token = (_request) => RpcOperation.fallbackToken ?? token);\r\n const client = RpcManager.getClientForInterface(this._channelInterface);\r\n this._describeEndpoints = async () => client.describeEndpoints();\r\n this._clientActive = true;\r\n }\r\n\r\n /** @internal */\r\n public initialize() {\r\n if (this._initialized) {\r\n return;\r\n }\r\n\r\n const id = this.computeId();\r\n Object.defineProperty(this._channelInterface, \"interfaceName\", { value: id });\r\n Object.defineProperty(this._channelImpl, \"interfaceName\", { value: id });\r\n\r\n RpcConfiguration.assign(this._channelInterface, () => this._configuration.constructor as any);\r\n RpcManager.registerImpl(this._channelInterface, this._channelImpl);\r\n RpcManager.initializeInterface(this._channelInterface);\r\n\r\n this._initialized = true;\r\n }\r\n\r\n /** @internal */\r\n public handleUnknownOperation(invocation: RpcInvocation, _error: any): boolean {\r\n this.initialize();\r\n\r\n const op = invocation.request.operation;\r\n if (op.interfaceVersion === \"CONTROL\" && op.operationName === \"describeEndpoints\") {\r\n if (this._channelInterface.interfaceName) {\r\n op.interfaceDefinition = this._channelInterface.interfaceName;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-common",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.4",
|
|
4
4
|
"description": "iTwin.js components common to frontend and backend",
|
|
5
5
|
"main": "lib/cjs/core-common.js",
|
|
6
6
|
"module": "lib/esm/core-common.js",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"js-base64": "^3.6.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@itwin/core-bentley": "^4.0.0-dev.
|
|
32
|
-
"@itwin/core-geometry": "^4.0.0-dev.
|
|
31
|
+
"@itwin/core-bentley": "^4.0.0-dev.4",
|
|
32
|
+
"@itwin/core-geometry": "^4.0.0-dev.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@itwin/build-tools": "4.0.0-dev.
|
|
36
|
-
"@itwin/core-bentley": "4.0.0-dev.
|
|
37
|
-
"@itwin/core-geometry": "4.0.0-dev.
|
|
38
|
-
"@itwin/eslint-plugin": "4.0.0-dev.
|
|
35
|
+
"@itwin/build-tools": "4.0.0-dev.4",
|
|
36
|
+
"@itwin/core-bentley": "4.0.0-dev.4",
|
|
37
|
+
"@itwin/core-geometry": "4.0.0-dev.4",
|
|
38
|
+
"@itwin/eslint-plugin": "4.0.0-dev.4",
|
|
39
39
|
"@types/chai": "4.3.1",
|
|
40
40
|
"@types/flatbuffers": "~1.10.0",
|
|
41
41
|
"@types/mocha": "^8.2.2",
|