@itwin/core-common 4.4.0-dev.2 → 4.4.0-dev.21
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 +21 -1
- package/lib/cjs/IModel.d.ts +10 -2
- package/lib/cjs/IModel.d.ts.map +1 -1
- package/lib/cjs/IModel.js +28 -9
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/MaterialProps.d.ts +18 -0
- package/lib/cjs/MaterialProps.d.ts.map +1 -1
- package/lib/cjs/MaterialProps.js.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts +5 -3
- package/lib/cjs/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.js +37 -1
- package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
- package/lib/cjs/geometry/TextString.d.ts +10 -1
- package/lib/cjs/geometry/TextString.d.ts.map +1 -1
- package/lib/cjs/geometry/TextString.js.map +1 -1
- package/lib/cjs/rpc/core/RpcInvocation.js +2 -2
- package/lib/cjs/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/cjs/rpc/core/RpcMarshaling.d.ts +1 -1
- package/lib/cjs/rpc/core/RpcMarshaling.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcMarshaling.js +1 -1
- package/lib/cjs/rpc/core/RpcMarshaling.js.map +1 -1
- package/lib/cjs/rpc/core/RpcProtocol.js +2 -2
- package/lib/cjs/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/cjs/tile/IModelTileIO.d.ts +2 -2
- package/lib/cjs/tile/IModelTileIO.js +2 -2
- package/lib/cjs/tile/IModelTileIO.js.map +1 -1
- package/lib/esm/IModel.d.ts +10 -2
- package/lib/esm/IModel.d.ts.map +1 -1
- package/lib/esm/IModel.js +28 -9
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/MaterialProps.d.ts +18 -0
- package/lib/esm/MaterialProps.d.ts.map +1 -1
- package/lib/esm/MaterialProps.js.map +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts +5 -3
- package/lib/esm/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/esm/geometry/ElementGeometry.js +38 -2
- package/lib/esm/geometry/ElementGeometry.js.map +1 -1
- package/lib/esm/geometry/TextString.d.ts +10 -1
- package/lib/esm/geometry/TextString.d.ts.map +1 -1
- package/lib/esm/geometry/TextString.js.map +1 -1
- package/lib/esm/rpc/core/RpcInvocation.js +2 -2
- package/lib/esm/rpc/core/RpcInvocation.js.map +1 -1
- package/lib/esm/rpc/core/RpcMarshaling.d.ts +1 -1
- package/lib/esm/rpc/core/RpcMarshaling.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcMarshaling.js +1 -1
- package/lib/esm/rpc/core/RpcMarshaling.js.map +1 -1
- package/lib/esm/rpc/core/RpcProtocol.js +2 -2
- package/lib/esm/rpc/core/RpcProtocol.js.map +1 -1
- package/lib/esm/tile/IModelTileIO.d.ts +2 -2
- package/lib/esm/tile/IModelTileIO.js +2 -2
- package/lib/esm/tile/IModelTileIO.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Geometry
|
|
3
3
|
*/
|
|
4
|
-
import { Point3d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from "@itwin/core-geometry";
|
|
4
|
+
import { Point2d, Point3d, Range2d, Transform, XYZProps, YawPitchRollAngles, YawPitchRollProps } from "@itwin/core-geometry";
|
|
5
5
|
import { FontId } from "../Fonts";
|
|
6
|
+
/**
|
|
7
|
+
* Optional cached text layout information used to support legacy proxy graphics.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export interface TextStringGlyphData {
|
|
11
|
+
glyphIds: number[];
|
|
12
|
+
glyphOrigins: Point2d[];
|
|
13
|
+
range: Range2d;
|
|
14
|
+
}
|
|
6
15
|
/** Properties for a TextString class.
|
|
7
16
|
* @see [[GeometryStreamEntryProps]]
|
|
8
17
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextString.d.ts","sourceRoot":"","sources":["../../../src/geometry/TextString.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAY,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"TextString.d.ts","sourceRoot":"","sources":["../../../src/geometry/TextString.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAY,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACvI,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,EAAE,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oCAAoC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED;;;;GAIG;AACH,qBAAa,UAAU;IACrB,kBAAkB;IACX,IAAI,EAAE,MAAM,CAAC;IACpB,6FAA6F;IACtF,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CAAC;IAC5B,kCAAkC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACtB,oCAAoC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACxB,uCAAuC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC3B,+CAA+C;IAC/C,SAAgB,MAAM,EAAE,OAAO,CAAC;IAChC,+CAA+C;IAC/C,SAAgB,QAAQ,EAAE,kBAAkB,CAAC;IAC7C,IAAW,KAAK,WAAwE;gBAErE,KAAK,EAAE,eAAe;IAYlC,MAAM,IAAI,eAAe;IAiBzB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;CAmBvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextString.js","sourceRoot":"","sources":["../../../src/geometry/TextString.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"TextString.js","sourceRoot":"","sources":["../../../src/geometry/TextString.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAuI;AAuCvI;;;;GAIG;AACH,MAAa,UAAU;IAmBrB,IAAW,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAExF,YAAmB,KAAsB;QACvC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,KAAK,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QACnF,MAAM,MAAM,GAAG,IAAI,wBAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC;YACtD,OAAO,KAAK,CAAC;QACf,MAAM,WAAW,GAAG,kCAAkB,CAAC,kBAAkB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC/E,IAAI,SAAS,KAAK,WAAW;YAC3B,OAAO,KAAK,CAAC;QACf,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;QACvC,IAAI,SAAS,GAAG,OAAO,IAAI,QAAQ,GAAG,OAAO;YAC3C,OAAO,KAAK,CAAC;QACf,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC;QACjF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArED,gCAqEC","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 Geometry\r\n */\r\n\r\nimport { Point2d, Point3d, Range2d, Transform, Vector3d, XYZProps, YawPitchRollAngles, YawPitchRollProps } from \"@itwin/core-geometry\";\r\nimport { FontId } from \"../Fonts\";\r\n\r\n/**\r\n * Optional cached text layout information used to support legacy proxy graphics.\r\n * @beta\r\n */\r\nexport interface TextStringGlyphData {\r\n glyphIds: number[];\r\n glyphOrigins: Point2d[];\r\n range: Range2d;\r\n}\r\n\r\n/** Properties for a TextString class.\r\n * @see [[GeometryStreamEntryProps]]\r\n * @public\r\n * @extensions\r\n */\r\nexport interface TextStringProps {\r\n /** text string */\r\n text: string;\r\n /** FontId for the TextString. FontIds are mapped to font names and types via the FontMap */\r\n font: FontId;\r\n /* text height */\r\n height: number;\r\n /* width / height ratio. Default is 1.0 */\r\n widthFactor?: number;\r\n /** bold text. Default is false */\r\n bold?: boolean;\r\n /** italic text. Default is false */\r\n italic?: boolean;\r\n /** underline text. Default is false */\r\n underline?: boolean;\r\n /** Optional position relative to element's placement. Default is 0,0,0 */\r\n origin?: XYZProps;\r\n /** Optional rotation relative to element's placement. Default is identity matrix */\r\n rotation?: YawPitchRollProps;\r\n}\r\n\r\n/** A single line of text, all with the same font, styles (underline, bold, italic), and size.\r\n * This class also holds the origin and direction for the text.\r\n * A paragraph is composed of one or more instances of TextStrings.\r\n * @public\r\n */\r\nexport class TextString {\r\n /** Text string */\r\n public text: string;\r\n /** FontId for this TextString. FontIds are mapped to font names and types via the FontMap */\r\n public font: FontId;\r\n /* text height, in meters */\r\n public height: number;\r\n /* width / height ratio. Default is 1.0 */\r\n public widthFactor?: number;\r\n /** bold text. Default is false */\r\n public bold?: boolean;\r\n /** italic text. Default is false */\r\n public italic?: boolean;\r\n /** underline text. Default is false */\r\n public underline?: boolean;\r\n /** position relative to element's placement */\r\n public readonly origin: Point3d;\r\n /** Rotation relative to element's placement */\r\n public readonly rotation: YawPitchRollAngles;\r\n public get width() { return this.height * (this.widthFactor ? this.widthFactor : 1.0); }\r\n\r\n public constructor(props: TextStringProps) {\r\n this.text = props.text;\r\n this.font = props.font;\r\n this.height = props.height;\r\n this.widthFactor = props.widthFactor;\r\n this.bold = props.bold;\r\n this.italic = props.italic;\r\n this.underline = props.underline;\r\n this.origin = Point3d.fromJSON(props.origin);\r\n this.rotation = YawPitchRollAngles.fromJSON(props.rotation);\r\n }\r\n\r\n public toJSON(): TextStringProps {\r\n const val: any = {};\r\n val.text = this.text;\r\n val.font = this.font;\r\n val.height = this.height;\r\n val.widthFactor = this.widthFactor;\r\n val.bold = this.bold;\r\n val.italic = this.italic;\r\n val.underline = this.underline;\r\n if (!this.origin.isAlmostZero)\r\n val.origin = this.origin;\r\n if (!this.rotation.isIdentity())\r\n val.rotation = this.rotation;\r\n\r\n return val;\r\n }\r\n\r\n public transformInPlace(transform: Transform): boolean {\r\n const newOrigin = transform.multiplyPoint3d(this.origin, this.origin);\r\n const newTransform = this.rotation.toMatrix3d().multiplyMatrixTransform(transform);\r\n const scales = new Vector3d();\r\n if (!newTransform.matrix.normalizeColumnsInPlace(scales))\r\n return false;\r\n const newRotation = YawPitchRollAngles.createFromMatrix3d(newTransform.matrix);\r\n if (undefined === newRotation)\r\n return false;\r\n const newHeight = this.height * scales.y;\r\n const newWidth = this.width * scales.x;\r\n if (newHeight < 1.0e-10 || newWidth < 1.0e-10)\r\n return false;\r\n this.origin.setFrom(newOrigin);\r\n this.rotation.setFrom(newRotation);\r\n this.height = newHeight;\r\n this.widthFactor = (newHeight === newWidth ? undefined : (newWidth / newHeight));\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -156,14 +156,14 @@ class RpcInvocation {
|
|
|
156
156
|
async fulfillResolved(value) {
|
|
157
157
|
this._timeOut = new Date().getTime();
|
|
158
158
|
this.protocol.events.raiseEvent(RpcConstants_1.RpcProtocolEvent.BackendResponseCreated, this);
|
|
159
|
-
const result =
|
|
159
|
+
const result = RpcMarshaling_1.RpcMarshaling.serialize(this.protocol, value);
|
|
160
160
|
return this.fulfill(result, value);
|
|
161
161
|
}
|
|
162
162
|
async fulfillRejected(reason) {
|
|
163
163
|
this._timeOut = new Date().getTime();
|
|
164
164
|
if (!RpcConfiguration_1.RpcConfiguration.developmentMode)
|
|
165
165
|
reason.stack = undefined;
|
|
166
|
-
const result =
|
|
166
|
+
const result = RpcMarshaling_1.RpcMarshaling.serialize(this.protocol, reason);
|
|
167
167
|
if (reason instanceof RpcControl_1.RpcPendingResponse) {
|
|
168
168
|
this._pending = true;
|
|
169
169
|
this._threw = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAA8J;AAC9J,qEAAkE;AAElE,mDAAgD;AAChD,qDAAkD;AAElD,yDAAsD;AACtD,iDAAoE;AACpE,6CAA0F;AAC1F,mDAAoE;AACpE,iDAA8C;AAC9C,+CAA+H;AAC/H,+CAAgE;AAqChE;;GAEG;AACH,MAAa,aAAa;IAwBxB,mCAAmC;IACnC,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,+BAAgB,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,+BAAgB,CAAC,OAAO,CAAC,CAAC;gBACxC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,+BAAgB,CAAC,QAAQ,CAAC,CAAC;oBAC1C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,+BAAgB,CAAC,SAAS,CAAC,CAAC;wBAC5C,+BAAgB,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,4CAA4C;IAC5C,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;IACtC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,OAAO,CAAC,OAAqB;QACzC,OAAQ,OAAe,CAAC,gCAAkB,CAAC,CAAC;IAC9C,CAAC;IAED,gCAAgC;IAChC,YAAmB,QAAqB,EAAE,OAA6B;QA7C/D,WAAM,GAAY,KAAK,CAAC;QACxB,aAAQ,GAAY,KAAK,CAAC;QAC1B,cAAS,GAAY,KAAK,CAAC;QAC3B,eAAU,GAAY,KAAK,CAAC;Q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SAAS,CAAC,aAAa,IAAI,CAAC,CAAC;QAEzK,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,uBAAuB,CAAC,WAAkC,EAAE,SAAc;QAChF,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE;YAClC,OAAO;SACR;QAED,IAAI,aAA+D,CAAC;QACpE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,aAAa,GAAG,SAAS,CAAC;SAC3B;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE;YACzB,aAAa,GAAG,UAAU,CAAC;SAC5B;aAAM,IAAI,IAAI,CAAC,UAAU,EAAE;YAC1B,aAAa,GAAG,WAAW,CAAC;SAC7B;QAED,IAAI,aAAa,EAAE;YACjB,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,MAAM,GAAqB,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;SAChC;QAED,IAAI,SAAS,YAAY,2BAAY,EAAE;YACrC,WAAW,CAAC,MAAM,GAAG,6BAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;SACzD;IACH,CAAC;;;AA5Qa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD;AAD/D,sCAAa","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n\r\n readonly user?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n user?: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n user: request.user,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.setAttributes({ error: true });\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = await RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = await RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation?.policy.allowResponseCompression || false,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof BentleyError) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcInvocation.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcInvocation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAA8J;AAC9J,qEAAkE;AAElE,mDAAgD;AAChD,qDAAkD;AAElD,yDAAsD;AACtD,iDAAoE;AACpE,6CAA0F;AAC1F,mDAAoE;AACpE,iDAA8C;AAC9C,+CAA+H;AAC/H,+CAAgE;AAqChE;;GAEG;AACH,MAAa,aAAa;IAwBxB,mCAAmC;IACnC,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,+BAAgB,CAAC,Q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AI,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;YAC9F,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpD,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,eAAe;YACjD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;SAChC;QAED,IAAI,SAAS,YAAY,2BAAY,EAAE;YACrC,WAAW,CAAC,MAAM,GAAG,6BAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;SACzD;IACH,CAAC;;;AA5Qa,yBAAW,GAAmB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,AAAhD,CAAiD;AAD/D,sCAAa","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 { AccessToken, BentleyError, BentleyStatus, GuidString, IModelStatus, Logger, RpcInterfaceStatus, StatusCategory, Tracing } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { IModelError } from \"../../IModelError\";\r\nimport { RpcInterface } from \"../../RpcInterface\";\r\nimport { SessionProps } from \"../../SessionProps\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus } from \"./RpcConstants\";\r\nimport { RpcControlChannel, RpcNotFoundResponse, RpcPendingResponse } from \"./RpcControl\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcManagedStatus, RpcProtocol, RpcProtocolVersion, RpcRequestFulfillment, SerializedRpcRequest } from \"./RpcProtocol\";\r\nimport { CURRENT_INVOCATION, RpcRegistry } from \"./RpcRegistry\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** The properties of an RpcActivity.\r\n * @public\r\n * @extensions\r\n */\r\nexport interface RpcActivity extends SessionProps {\r\n /** Used for logging to correlate an Rpc activity between frontend and backend */\r\n readonly activityId: GuidString;\r\n\r\n /** access token for authorization */\r\n readonly accessToken: AccessToken;\r\n\r\n /** the name of the current rpc method */\r\n readonly rpcMethod?: string;\r\n\r\n readonly user?: string;\r\n}\r\n\r\n/** Serialized format for sending the request across the RPC layer\r\n * @public\r\n */\r\nexport interface SerializedRpcActivity {\r\n id: string;\r\n applicationId: string;\r\n applicationVersion: string;\r\n sessionId: string;\r\n authorization: string;\r\n user?: string;\r\n csrfToken?: { headerName: string, headerValue: string };\r\n}\r\n\r\n/** @internal */\r\nexport type RpcActivityRun = (activity: RpcActivity, fn: () => Promise<any>) => Promise<any>;\r\n\r\n/** An RPC operation invocation in response to a request.\r\n * @internal\r\n */\r\nexport class RpcInvocation {\r\n public static runActivity: RpcActivityRun = async (_activity, fn) => fn();\r\n private _threw: boolean = false;\r\n private _pending: boolean = false;\r\n private _notFound: boolean = false;\r\n private _noContent: boolean = false;\r\n private _timeIn: number = 0;\r\n private _timeOut: number = 0;\r\n\r\n /** The protocol for this invocation. */\r\n public readonly protocol: RpcProtocol;\r\n\r\n /** The received request. */\r\n public readonly request: SerializedRpcRequest;\r\n\r\n /** The operation of the request. */\r\n public readonly operation: RpcOperation = undefined as any;\r\n\r\n /** The implementation response. */\r\n public readonly result: Promise<any>;\r\n\r\n /** The fulfillment for this request. */\r\n public readonly fulfillment: Promise<RpcRequestFulfillment>;\r\n\r\n /** The status for this request. */\r\n public get status(): RpcRequestStatus {\r\n return this._threw ? RpcRequestStatus.Rejected :\r\n this._pending ? RpcRequestStatus.Pending :\r\n this._notFound ? RpcRequestStatus.NotFound :\r\n this._noContent ? RpcRequestStatus.NoContent :\r\n RpcRequestStatus.Resolved;\r\n }\r\n\r\n /** The elapsed time for this invocation. */\r\n public get elapsed(): number {\r\n return this._timeOut - this._timeIn;\r\n }\r\n\r\n /**\r\n * The invocation for the current RPC operation.\r\n * @note The return value of this function is only reliable in an RPC impl class member function where program control was received from the RpcInvocation constructor function.\r\n */\r\n public static current(rpcImpl: RpcInterface): RpcInvocation {\r\n return (rpcImpl as any)[CURRENT_INVOCATION];\r\n }\r\n\r\n /** Constructs an invocation. */\r\n public constructor(protocol: RpcProtocol, request: SerializedRpcRequest) {\r\n this._timeIn = new Date().getTime();\r\n this.protocol = protocol;\r\n this.request = request;\r\n\r\n try {\r\n try {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n\r\n const backend = this.operation.interfaceVersion;\r\n const frontend = this.request.operation.interfaceVersion;\r\n if (!RpcInterface.isVersionCompatible(backend, frontend)) {\r\n throw new IModelError(RpcInterfaceStatus.IncompatibleVersion, `Backend version ${backend} does not match frontend version ${frontend} for RPC interface ${this.operation.operationName}.`);\r\n }\r\n } catch (error) {\r\n if (this.handleUnknownOperation(error)) {\r\n this.operation = RpcOperation.lookup(this.request.operation.interfaceDefinition, this.request.operation.operationName);\r\n } else {\r\n throw error;\r\n }\r\n }\r\n\r\n this.result = this.resolve();\r\n } catch (error) {\r\n this.result = this.reject(error);\r\n }\r\n\r\n this.fulfillment = this.result.then(async (value) => this._threw ? this.fulfillRejected(value) : this.fulfillResolved(value), async (reason) => this.fulfillRejected(reason));\r\n }\r\n\r\n private handleUnknownOperation(error: any): boolean {\r\n RpcControlChannel.ensureInitialized();\r\n return this.protocol.configuration.controlChannel.handleUnknownOperation(this, error);\r\n }\r\n\r\n public static sanitizeForLog(activity?: RpcActivity) {\r\n /* eslint-disable @typescript-eslint/naming-convention */\r\n return activity ? {\r\n ActivityId: activity.activityId, SessionId: activity.sessionId, ApplicationId: activity.applicationId, ApplicationVersion: activity.applicationVersion, rpcMethod: activity.rpcMethod,\r\n } : undefined;\r\n /* eslint-enable @typescript-eslint/naming-convention */\r\n }\r\n\r\n private async resolve(): Promise<any> {\r\n const request = this.request;\r\n const activity: RpcActivity = {\r\n activityId: request.id,\r\n applicationId: request.applicationId,\r\n applicationVersion: request.applicationVersion,\r\n sessionId: request.sessionId,\r\n user: request.user,\r\n accessToken: request.authorization,\r\n rpcMethod: request.operation.operationName,\r\n };\r\n\r\n try {\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.RequestReceived, this);\r\n\r\n const parameters = request.parametersOverride || RpcMarshaling.deserialize(this.protocol, request.parameters);\r\n this.applyPolicies(parameters);\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition);\r\n (impl as any)[CURRENT_INVOCATION] = this;\r\n const op = this.lookupOperationFunction(impl);\r\n\r\n return await RpcInvocation.runActivity(activity, async () => op.call(impl, ...parameters)\r\n .catch(async (error) => {\r\n // this catch block is intentionally placed inside `runActivity` to attach the right logging metadata and use the correct openTelemetry span.\r\n if (!(error instanceof RpcPendingResponse)) {\r\n Logger.logError(CommonLoggerCategory.RpcInterfaceBackend, \"Error in RPC operation\", { error: BentleyError.getErrorProps(error) });\r\n Tracing.setAttributes({ error: true });\r\n }\r\n throw error;\r\n }));\r\n } catch (error: unknown) {\r\n return this.reject(error);\r\n }\r\n }\r\n\r\n private applyPolicies(parameters: any) {\r\n if (!parameters || !Array.isArray(parameters))\r\n return;\r\n\r\n for (let i = 0; i !== parameters.length; ++i) {\r\n const parameter = parameters[i];\r\n const isToken = typeof (parameter) === \"object\" && parameter !== null && parameter.hasOwnProperty(\"iModelId\") && parameter.hasOwnProperty(\"iTwinId\");\r\n if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {\r\n const inflated = this.protocol.inflateToken(parameter, this.request);\r\n parameters[i] = inflated;\r\n\r\n if (!RpcInvocation.compareTokens(parameter, inflated)) {\r\n if (RpcConfiguration.throwOnTokenMismatch) {\r\n throw new IModelError(BentleyStatus.ERROR, \"IModelRpcProps mismatch detected for this request.\");\r\n } else {\r\n Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, \"IModelRpcProps mismatch detected for this request.\");\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static compareTokens(a: IModelRpcProps, b: IModelRpcProps): boolean {\r\n return a.key === b.key &&\r\n a.iTwinId === b.iTwinId &&\r\n a.iModelId === b.iModelId &&\r\n (undefined === a.changeset || (a.changeset.id === b.changeset?.id));\r\n }\r\n\r\n private async reject(error: any): Promise<any> {\r\n this._threw = true;\r\n return error;\r\n }\r\n\r\n private async fulfillResolved(value: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendResponseCreated, this);\r\n const result = RpcMarshaling.serialize(this.protocol, value);\r\n return this.fulfill(result, value);\r\n }\r\n\r\n private async fulfillRejected(reason: any): Promise<RpcRequestFulfillment> {\r\n this._timeOut = new Date().getTime();\r\n if (!RpcConfiguration.developmentMode)\r\n reason.stack = undefined;\r\n\r\n const result = RpcMarshaling.serialize(this.protocol, reason);\r\n\r\n if (reason instanceof RpcPendingResponse) {\r\n this._pending = true;\r\n this._threw = false;\r\n result.objects = reason.message;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);\r\n } else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {\r\n this._noContent = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);\r\n } else if (reason instanceof RpcNotFoundResponse) {\r\n this._notFound = true;\r\n this._threw = false;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNotFound, this);\r\n } else {\r\n this._threw = true;\r\n this.protocol.events.raiseEvent(RpcProtocolEvent.BackendErrorOccurred, this);\r\n }\r\n\r\n return this.fulfill(result, reason);\r\n }\r\n\r\n private supportsNoContent() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedNoContent && this.request.protocolVersion >= RpcProtocolVersion.IntroducedNoContent;\r\n }\r\n\r\n private supportsStatusCategory() {\r\n if (!this.request.protocolVersion) {\r\n return false;\r\n }\r\n\r\n if (!this.protocol.supportsStatusCategory) {\r\n return false;\r\n }\r\n\r\n return RpcProtocol.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory && this.request.protocolVersion >= RpcProtocolVersion.IntroducedStatusCategory;\r\n }\r\n\r\n private fulfill(result: RpcSerializedValue, rawResult: any): RpcRequestFulfillment {\r\n const fulfillment: RpcRequestFulfillment = {\r\n result,\r\n rawResult,\r\n status: this.protocol.getCode(this.status),\r\n id: this.request.id,\r\n interfaceName: (typeof (this.operation) === \"undefined\") ? \"\" : this.operation.interfaceDefinition.interfaceName,\r\n allowCompression: this.operation?.policy.allowResponseCompression || false,\r\n };\r\n\r\n this.transformResponseStatus(fulfillment, rawResult);\r\n\r\n try {\r\n const impl = RpcRegistry.instance.getImplForInterface(this.operation.interfaceDefinition) as any;\r\n if (impl[CURRENT_INVOCATION] === this) {\r\n impl[CURRENT_INVOCATION] = undefined;\r\n }\r\n } catch (_err) { }\r\n\r\n return fulfillment;\r\n }\r\n\r\n private lookupOperationFunction(implementation: RpcInterface): (...args: any[]) => Promise<any> {\r\n const func = (implementation as any)[this.operation.operationName];\r\n if (!func || typeof (func) !== \"function\")\r\n throw new IModelError(BentleyStatus.ERROR, `RPC interface class \"${implementation.constructor.name}\" does not implement operation \"${this.operation.operationName}\".`);\r\n\r\n return func;\r\n }\r\n\r\n private transformResponseStatus(fulfillment: RpcRequestFulfillment, rawResult: any) {\r\n if (!this.supportsStatusCategory()) {\r\n return;\r\n }\r\n\r\n let managedStatus: \"notFound\" | \"pending\" | \"noContent\" | undefined;\r\n if (this._pending) {\r\n managedStatus = \"pending\";\r\n } else if (this._notFound) {\r\n managedStatus = \"notFound\";\r\n } else if (this._noContent) {\r\n managedStatus = \"noContent\";\r\n }\r\n\r\n if (managedStatus) {\r\n const responseValue = fulfillment.result.objects;\r\n const status: RpcManagedStatus = { iTwinRpcCoreResponse: true, managedStatus, responseValue };\r\n fulfillment.result.objects = JSON.stringify(status);\r\n status.responseValue = rawResult; // for ipc case\r\n fulfillment.rawResult = status;\r\n }\r\n\r\n if (rawResult instanceof BentleyError) {\r\n fulfillment.status = StatusCategory.for(rawResult).code;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -29,7 +29,7 @@ export declare namespace RpcSerializedValue {
|
|
|
29
29
|
export declare class RpcMarshaling {
|
|
30
30
|
private constructor();
|
|
31
31
|
/** Serializes a value. */
|
|
32
|
-
static serialize(protocol: RpcProtocol | undefined, value: any):
|
|
32
|
+
static serialize(protocol: RpcProtocol | undefined, value: any): RpcSerializedValue;
|
|
33
33
|
/** Deserializes a value. */
|
|
34
34
|
static deserialize(protocol: RpcProtocol | undefined, value: RpcSerializedValue): any;
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcMarshaling.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAY5C,gBAAgB;AAChB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,IAAI,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,yBAAiB,sBAAsB,CAAC;IACtC,SAAgB,aAAa,IAAI,sBAAsB,CAEtD;CACF;AAED,gBAAgB;AAChB,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,eAAe,CAAC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AG,GAAG;CAoB7F"}
|
|
@@ -36,7 +36,7 @@ var RpcSerializedValue;
|
|
|
36
36
|
class RpcMarshaling {
|
|
37
37
|
constructor() { }
|
|
38
38
|
/** Serializes a value. */
|
|
39
|
-
static
|
|
39
|
+
static serialize(protocol, value) {
|
|
40
40
|
const serialized = RpcSerializedValue.create();
|
|
41
41
|
if (typeof (value) === "undefined") {
|
|
42
42
|
return serialized;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcMarshaling.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mDAA+D;AAI/D,0BAA0B;AAC1B,4CAA4C;AAE5C,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,UAAU,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9I,CAAC;AAED,IAAI,gBAAoC,CAAC;AACzC,IAAI,cAAc,GAAG,CAAC,CAAC;AAUvB,gBAAgB;AAChB,IAAiB,sBAAsB,CAItC;AAJD,WAAiB,sBAAsB;IACrC,SAAgB,aAAa;QAC3B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC3D,CAAC;IAFe,oCAAa,gBAE5B,CAAA;AACH,CAAC,EAJgB,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAItC;AAUD,gBAAgB;AAChB,IAAiB,kBAAkB,CAIlC;AAJD,WAAiB,kBAAkB;IACjC,SAAgB,MAAM,CAAC,OAAO,GAAG,EAAE,EAAE,OAAqB,EAAE;QAC1D,OAAO,EAAE,OA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,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAC/F,KAAK,CAAC,KAAK,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SAC/C;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus, IModelError } from \"../../IModelError\";\r\nimport { BackendReadable } from \"../../BackendTypes\";\r\nimport { RpcProtocol } from \"./RpcProtocol\";\r\n\r\n// cspell:ignore unmarshal\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction isBuffer(val: any): boolean {\r\n return val && typeof (val.constructor) !== \"undefined\" && typeof (val.constructor.isBuffer) === \"function\" && val.constructor.isBuffer(val);\r\n}\r\n\r\nlet marshalingTarget: RpcSerializedValue;\r\nlet chunkThreshold = 0;\r\n\r\n/** @internal */\r\nexport interface MarshalingBinaryMarker {\r\n isBinary: true;\r\n index: number;\r\n size: number;\r\n chunks: number;\r\n}\r\n\r\n/** @internal */\r\nexport namespace MarshalingBinaryMarker {\r\n export function createDefault(): MarshalingBinaryMarker {\r\n return { isBinary: true, index: 0, size: -1, chunks: 1 };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface RpcSerializedValue {\r\n objects: string;\r\n data: Uint8Array[];\r\n chunks?: number;\r\n stream?: BackendReadable;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcSerializedValue {\r\n export function create(objects = \"\", data: Uint8Array[] = []): RpcSerializedValue {\r\n return { objects, data };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcMarshaling {\r\n private constructor() { }\r\n\r\n /** Serializes a value. */\r\n public static async serialize(protocol: RpcProtocol | undefined, value: any): Promise<RpcSerializedValue> {\r\n const serialized = RpcSerializedValue.create();\r\n\r\n if (typeof (value) === \"undefined\") {\r\n return serialized;\r\n }\r\n\r\n marshalingTarget = serialized;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return serialized;\r\n }\r\n\r\n /** Deserializes a value. */\r\n public static deserialize(protocol: RpcProtocol | undefined, value: RpcSerializedValue): any {\r\n if (value.objects === \"\") {\r\n return undefined;\r\n }\r\n\r\n marshalingTarget = value;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n let result;\r\n try {\r\n result = JSON.parse(value.objects, (_key, _value) => WireFormat.unmarshal(_key, _value));\r\n } catch (error) {\r\n if (error instanceof SyntaxError)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid JSON: \"${value.objects}\"`);\r\n throw error;\r\n }\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return result;\r\n }\r\n}\r\n\r\nclass WireFormat {\r\n /** JSON.stringify replacer callback. */\r\n public static marshal(this: any, _key: string, value: any) {\r\n const asBinary = WireFormat.marshalBinary(value);\r\n if (asBinary) {\r\n return asBinary;\r\n }\r\n\r\n const asError = WireFormat.marshalError(value);\r\n if (asError) {\r\n return asError;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** JSON.parse reviver callback. */\r\n public static unmarshal(_key: string, value: any) {\r\n if (typeof (value) === \"object\" && value !== null && value.hasOwnProperty(\"isBinary\") && value.isBinary) {\r\n return WireFormat.unmarshalBinary(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n private static marshalBinary(value: any): any {\r\n if (value instanceof Uint8Array || isBuffer(value)) {\r\n const marker: MarshalingBinaryMarker = { isBinary: true, index: -1, size: value.byteLength, chunks: 1 };\r\n\r\n if (chunkThreshold && value.byteLength > chunkThreshold) {\r\n marker.index = marshalingTarget.data.length;\r\n marker.chunks = 0;\r\n\r\n let cursor = value.byteOffset;\r\n const end = cursor + value.byteLength;\r\n let chunk = chunkThreshold;\r\n\r\n for (; ;) {\r\n if (cursor >= end) {\r\n break;\r\n }\r\n\r\n marshalingTarget.data.push(new Uint8Array(value.buffer, cursor, chunk));\r\n ++marker.chunks;\r\n cursor += chunk;\r\n\r\n const consumed = cursor - value.byteOffset;\r\n const remaining = value.byteLength - consumed;\r\n chunk = Math.min(chunkThreshold, remaining);\r\n }\r\n } else {\r\n marker.index = marshalingTarget.data.push(value) - 1;\r\n }\r\n\r\n return marker;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n private static unmarshalBinary(value: MarshalingBinaryMarker): any {\r\n if (value.index >= marshalingTarget.data.length) {\r\n throw new IModelError(BentleyStatus.ERROR, `Cannot unmarshal missing binary value.`);\r\n }\r\n\r\n if (value.chunks === 0) {\r\n return new Uint8Array();\r\n } else if (value.chunks === 1) {\r\n return new Uint8Array(marshalingTarget.data[value.index]);\r\n } else {\r\n const buffer = new ArrayBuffer(value.size);\r\n const view = new Uint8Array(buffer);\r\n\r\n let cursor = 0;\r\n for (let c = 0; c !== value.chunks; ++c) {\r\n const chunk = marshalingTarget.data[value.index + c];\r\n view.set(chunk, cursor);\r\n cursor += chunk.byteLength;\r\n }\r\n\r\n return view;\r\n }\r\n }\r\n\r\n private static marshalError(value: any) {\r\n if (value instanceof Error) {\r\n const props = Object.getOwnPropertyDescriptors(value);\r\n props.isError = { configurable: true, enumerable: true, writable: true, value: true };\r\n props.name = { configurable: true, enumerable: true, writable: true, value: value.name };\r\n props.message = { configurable: true, enumerable: true, writable: true, value: value.message };\r\n props.stack = { configurable: true, enumerable: true, writable: true, value: value.stack };\r\n return Object.create(Object.prototype, props);\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcMarshaling.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcMarshaling.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,mDAA+D;AAI/D,0BAA0B;AAC1B,4CAA4C;AAE5C,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,UAAU,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9I,CAAC;AAED,IAAI,gBAAoC,CAAC;AACzC,IAAI,cAAc,GAAG,CAAC,CAAC;AAUvB,gBAAgB;AAChB,IAAiB,sBAAsB,CAItC;AAJD,WAAiB,sBAAsB;IACrC,SAAgB,aAAa;QAC3B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC3D,CAAC;IAFe,oCAAa,gBAE5B,CAAA;AACH,CAAC,EAJgB,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAItC;AAUD,gBAAgB;AAChB,IAAiB,kBAAkB,CAIlC;AAJD,WAAiB,kBAAkB;IACjC,SAAgB,MAAM,CAAC,OAAO,GAAG,EAAE,EAAE,OAAqB,EAAE;QAC1D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAFe,yBAAM,SAErB,CAAA;AACH,CAAC,EAJgB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAIlC;AAED,gBAAgB;AAChB,MAAa,aAAa;IACxB,gBAAwB,CAAC;IAE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AAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SAC/C;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RpcInterface\r\n */\r\n\r\nimport { BentleyStatus, IModelError } from \"../../IModelError\";\r\nimport { BackendReadable } from \"../../BackendTypes\";\r\nimport { RpcProtocol } from \"./RpcProtocol\";\r\n\r\n// cspell:ignore unmarshal\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nfunction isBuffer(val: any): boolean {\r\n return val && typeof (val.constructor) !== \"undefined\" && typeof (val.constructor.isBuffer) === \"function\" && val.constructor.isBuffer(val);\r\n}\r\n\r\nlet marshalingTarget: RpcSerializedValue;\r\nlet chunkThreshold = 0;\r\n\r\n/** @internal */\r\nexport interface MarshalingBinaryMarker {\r\n isBinary: true;\r\n index: number;\r\n size: number;\r\n chunks: number;\r\n}\r\n\r\n/** @internal */\r\nexport namespace MarshalingBinaryMarker {\r\n export function createDefault(): MarshalingBinaryMarker {\r\n return { isBinary: true, index: 0, size: -1, chunks: 1 };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface RpcSerializedValue {\r\n objects: string;\r\n data: Uint8Array[];\r\n chunks?: number;\r\n stream?: BackendReadable;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcSerializedValue {\r\n export function create(objects = \"\", data: Uint8Array[] = []): RpcSerializedValue {\r\n return { objects, data };\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class RpcMarshaling {\r\n private constructor() { }\r\n\r\n /** Serializes a value. */\r\n public static serialize(protocol: RpcProtocol | undefined, value: any): RpcSerializedValue {\r\n const serialized = RpcSerializedValue.create();\r\n\r\n if (typeof (value) === \"undefined\") {\r\n return serialized;\r\n }\r\n\r\n marshalingTarget = serialized;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n serialized.objects = JSON.stringify(value, (_key, _value) => WireFormat.marshal(_key, _value));\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return serialized;\r\n }\r\n\r\n /** Deserializes a value. */\r\n public static deserialize(protocol: RpcProtocol | undefined, value: RpcSerializedValue): any {\r\n if (value.objects === \"\") {\r\n return undefined;\r\n }\r\n\r\n marshalingTarget = value;\r\n chunkThreshold = protocol ? protocol.transferChunkThreshold : 0;\r\n let result;\r\n try {\r\n result = JSON.parse(value.objects, (_key, _value) => WireFormat.unmarshal(_key, _value));\r\n } catch (error) {\r\n if (error instanceof SyntaxError)\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid JSON: \"${value.objects}\"`);\r\n throw error;\r\n }\r\n marshalingTarget = undefined as any;\r\n chunkThreshold = 0;\r\n\r\n return result;\r\n }\r\n}\r\n\r\nclass WireFormat {\r\n /** JSON.stringify replacer callback. */\r\n public static marshal(this: any, _key: string, value: any) {\r\n const asBinary = WireFormat.marshalBinary(value);\r\n if (asBinary) {\r\n return asBinary;\r\n }\r\n\r\n const asError = WireFormat.marshalError(value);\r\n if (asError) {\r\n return asError;\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** JSON.parse reviver callback. */\r\n public static unmarshal(_key: string, value: any) {\r\n if (typeof (value) === \"object\" && value !== null && value.hasOwnProperty(\"isBinary\") && value.isBinary) {\r\n return WireFormat.unmarshalBinary(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n private static marshalBinary(value: any): any {\r\n if (value instanceof Uint8Array || isBuffer(value)) {\r\n const marker: MarshalingBinaryMarker = { isBinary: true, index: -1, size: value.byteLength, chunks: 1 };\r\n\r\n if (chunkThreshold && value.byteLength > chunkThreshold) {\r\n marker.index = marshalingTarget.data.length;\r\n marker.chunks = 0;\r\n\r\n let cursor = value.byteOffset;\r\n const end = cursor + value.byteLength;\r\n let chunk = chunkThreshold;\r\n\r\n for (; ;) {\r\n if (cursor >= end) {\r\n break;\r\n }\r\n\r\n marshalingTarget.data.push(new Uint8Array(value.buffer, cursor, chunk));\r\n ++marker.chunks;\r\n cursor += chunk;\r\n\r\n const consumed = cursor - value.byteOffset;\r\n const remaining = value.byteLength - consumed;\r\n chunk = Math.min(chunkThreshold, remaining);\r\n }\r\n } else {\r\n marker.index = marshalingTarget.data.push(value) - 1;\r\n }\r\n\r\n return marker;\r\n } else {\r\n return undefined;\r\n }\r\n }\r\n\r\n private static unmarshalBinary(value: MarshalingBinaryMarker): any {\r\n if (value.index >= marshalingTarget.data.length) {\r\n throw new IModelError(BentleyStatus.ERROR, `Cannot unmarshal missing binary value.`);\r\n }\r\n\r\n if (value.chunks === 0) {\r\n return new Uint8Array();\r\n } else if (value.chunks === 1) {\r\n return new Uint8Array(marshalingTarget.data[value.index]);\r\n } else {\r\n const buffer = new ArrayBuffer(value.size);\r\n const view = new Uint8Array(buffer);\r\n\r\n let cursor = 0;\r\n for (let c = 0; c !== value.chunks; ++c) {\r\n const chunk = marshalingTarget.data[value.index + c];\r\n view.set(chunk, cursor);\r\n cursor += chunk.byteLength;\r\n }\r\n\r\n return view;\r\n }\r\n }\r\n\r\n private static marshalError(value: any) {\r\n if (value instanceof Error) {\r\n const props = Object.getOwnPropertyDescriptors(value);\r\n props.isError = { configurable: true, enumerable: true, writable: true, value: true };\r\n props.name = { configurable: true, enumerable: true, writable: true, value: value.name };\r\n props.message = { configurable: true, enumerable: true, writable: true, value: value.message };\r\n props.stack = { configurable: true, enumerable: true, writable: true, value: value.stack };\r\n return Object.create(Object.prototype, props);\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
|
|
@@ -17,7 +17,7 @@ const RpcMarshaling_1 = require("./RpcMarshaling");
|
|
|
17
17
|
var RpcRequestFulfillment;
|
|
18
18
|
(function (RpcRequestFulfillment) {
|
|
19
19
|
async function forUnknownError(request, error) {
|
|
20
|
-
const result =
|
|
20
|
+
const result = RpcMarshaling_1.RpcMarshaling.serialize(undefined, error);
|
|
21
21
|
return {
|
|
22
22
|
interfaceName: request.operation.interfaceDefinition,
|
|
23
23
|
id: request.id,
|
|
@@ -75,7 +75,7 @@ class RpcProtocol {
|
|
|
75
75
|
},
|
|
76
76
|
method: request.method,
|
|
77
77
|
path: request.path,
|
|
78
|
-
parameters:
|
|
78
|
+
parameters: RpcMarshaling_1.RpcMarshaling.serialize(request.protocol, request.parameters),
|
|
79
79
|
caching: RpcConstants_1.RpcResponseCacheControl.None,
|
|
80
80
|
protocolVersion: RpcProtocol.protocolVersion,
|
|
81
81
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8C;AAG9C,yDAAsD;AACtD,iDAA6F;AAE7F,mDAAuE;AACvE,mDAAoE;AAwDpE,gBAAgB;AAChB,IAAiB,qBAAqB,CAYrC;AAZD,WAAiB,qBAAqB;IAC7B,KAAK,UAAU,eAAe,CAAC,OAA6B,EAAE,KAAU;QAC7E,MAAM,MAAM,GAAG,MAAM,6BAAa,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAE/D,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,mBAAmB;YACpD,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,MAAM;YACN,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,+BAAgB,CAAC,QAAQ;SAClC,CAAC;IACJ,CAAC;IAVqB,qCAAe,kBAUpC,CAAA;AACH,CAAC,EAZgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAYrC;AAOD;;GAEG;AACH,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,2DAA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ACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAhH9F,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,sBAAO,EAAE,AAAlD,CAAmD;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,AAAtD,CAAuD;AALzE,kCAAW","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 { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse } from \"./RpcControl\";\r\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** A serialized RPC operation descriptor.\r\n * @internal\r\n */\r\nexport interface SerializedRpcOperation {\r\n interfaceDefinition: string;\r\n operationName: string;\r\n interfaceVersion: string;\r\n encodedRequest?: string;\r\n}\r\n\r\n/** A serialized RPC operation request.\r\n * @internal\r\n */\r\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\r\n operation: SerializedRpcOperation;\r\n method: string;\r\n path: string;\r\n parameters: RpcSerializedValue;\r\n caching: RpcResponseCacheControl;\r\n ip?: string;\r\n protocolVersion?: number;\r\n parametersOverride?: any[];\r\n}\r\n\r\n/** An RPC operation request fulfillment.\r\n * @internal\r\n */\r\nexport interface RpcRequestFulfillment {\r\n /** The RPC interface for the request. */\r\n interfaceName: string;\r\n\r\n /** The id for the request. */\r\n id: string;\r\n\r\n /** The result for the request. */\r\n result: RpcSerializedValue;\r\n\r\n /** The un-serialized result for the request. */\r\n rawResult: any;\r\n\r\n /** A protocol-specific status code value for the request. */\r\n status: number;\r\n\r\n /* A protocol-specific value for retrying this request. */\r\n retry?: string;\r\n\r\n /** Whether to compress the result with one of the client's supported encodings. */\r\n allowCompression?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcRequestFulfillment {\r\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\r\n const result = await RpcMarshaling.serialize(undefined, error);\r\n\r\n return {\r\n interfaceName: request.operation.interfaceDefinition,\r\n id: request.id,\r\n result,\r\n rawResult: error,\r\n status: RpcRequestStatus.Rejected,\r\n };\r\n }\r\n}\r\n\r\n/** Handles RPC protocol events.\r\n * @internal\r\n */\r\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\r\n\r\n/** Documents changes to the RPC protocol version.\r\n * @internal\r\n */\r\nexport enum RpcProtocolVersion {\r\n None = 0,\r\n IntroducedNoContent = 1,\r\n IntroducedStatusCategory = 2\r\n}\r\n\r\n/**\r\n * A backend response that is handled internally by the RPC system.\r\n * @internal\r\n */\r\nexport interface RpcManagedStatus {\r\n iTwinRpcCoreResponse: true;\r\n managedStatus: \"pending\" | \"notFound\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\r\n}\r\n\r\n/** An application protocol for an RPC interface.\r\n * @internal\r\n */\r\nexport abstract class RpcProtocol {\r\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\r\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\r\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\r\n\r\n /** The name of the RPC protocol version header. */\r\n public protocolVersionHeaderName = \"\";\r\n\r\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\r\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** The configuration for the protocol. */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** The RPC request class for this protocol. */\r\n public abstract readonly requestType: typeof RpcRequest;\r\n\r\n /** The RPC invocation class for this protocol. */\r\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\r\n\r\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the request id header. */\r\n id: \"\",\r\n\r\n /** The name of the application id header */\r\n applicationId: \"\",\r\n\r\n /** The name of the version header. */\r\n applicationVersion: \"\",\r\n\r\n /** The name of the session id header */\r\n sessionId: \"\",\r\n\r\n /** The name of the authorization header. */\r\n authorization: \"\",\r\n };\r\n\r\n /** If greater than zero, specifies where to break large binary request payloads. */\r\n public transferChunkThreshold: number = 0;\r\n\r\n /** Used by protocols that can transmit stream values natively. */\r\n public preserveStreams: boolean = false;\r\n\r\n /** Used by protocols that can transmit IModelRpcProps values natively. */\r\n public checkToken: boolean = false;\r\n\r\n /** Used by protocols that support user-defined status codes. */\r\n public supportsStatusCategory: boolean = false;\r\n\r\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\r\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\r\n\r\n /** Override to supply the status corresponding to a protocol-specific code value. */\r\n public getStatus(code: number): RpcRequestStatus {\r\n return code;\r\n }\r\n\r\n /** Override to supply the protocol-specific code corresponding to a status value. */\r\n public getCode(status: RpcRequestStatus): number {\r\n return status;\r\n }\r\n\r\n /** Override to supply the protocol-specific path value for an RPC operation. */\r\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\r\n return JSON.stringify(operation);\r\n }\r\n\r\n /** Override to supply the operation for a protocol-specific path value. */\r\n public getOperationFromPath(path: string): SerializedRpcOperation {\r\n return JSON.parse(path);\r\n }\r\n\r\n /** Obtains the implementation result on the backend for an RPC operation request. */\r\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\r\n return new (this.invocationType)(this, request).fulfillment;\r\n }\r\n\r\n /** Serializes a request. */\r\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\r\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\r\n return {\r\n ...serializedContext,\r\n operation: {\r\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\r\n operationName: request.operation.operationName,\r\n interfaceVersion: request.operation.interfaceVersion,\r\n },\r\n method: request.method,\r\n path: request.path,\r\n parameters: await RpcMarshaling.serialize(request.protocol, request.parameters),\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: RpcProtocol.protocolVersion,\r\n };\r\n }\r\n\r\n /** Constructs a protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n this.configuration = configuration;\r\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\r\n }\r\n\r\n /** @internal */\r\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8C;AAG9C,yDAAsD;AACtD,iDAA6F;AAE7F,mDAAuE;AACvE,mDAAoE;AAwDpE,gBAAgB;AAChB,IAAiB,qBAAqB,CAYrC;AAZD,WAAiB,qBAAqB;IAC7B,KAAK,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;QACzD,2BAAsB,GAAY,KAAK,CAAC;QAkD7C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,gBAAgB;IACT,sBAAsB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAEnG,gBAAgB;IACT,oBAAoB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;IAE/F,gBAAgB;IACT,qBAAqB,CAAC,WAAmC,EAAE,OAAqB,IAAU,CAAC;IAElG,gBAAgB;IACT,mBAAmB,CAAC,WAAmC,EAAE,KAAmB,IAAU,CAAC;;AAhH9F,+DAA+D;AACxC,kBAAM,GAAqC,IAAI,sBAAO,EAAE,AAAlD,CAAmD;AAEhF,oFAAoF;AAC7D,2BAAe,GAAW,kBAAkB,CAAC,wBAAwB,AAAtD,CAAuD;AALzE,kCAAW","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 { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelRpcProps } from \"../../IModel\";\r\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\r\nimport { RpcConfiguration } from \"./RpcConfiguration\";\r\nimport { RpcProtocolEvent, RpcRequestStatus, RpcResponseCacheControl } from \"./RpcConstants\";\r\nimport { RpcNotFoundResponse } from \"./RpcControl\";\r\nimport { RpcInvocation, SerializedRpcActivity } from \"./RpcInvocation\";\r\nimport { RpcMarshaling, RpcSerializedValue } from \"./RpcMarshaling\";\r\nimport { RpcOperation } from \"./RpcOperation\";\r\nimport { RpcRequest } from \"./RpcRequest\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** A serialized RPC operation descriptor.\r\n * @internal\r\n */\r\nexport interface SerializedRpcOperation {\r\n interfaceDefinition: string;\r\n operationName: string;\r\n interfaceVersion: string;\r\n encodedRequest?: string;\r\n}\r\n\r\n/** A serialized RPC operation request.\r\n * @internal\r\n */\r\nexport interface SerializedRpcRequest extends SerializedRpcActivity {\r\n operation: SerializedRpcOperation;\r\n method: string;\r\n path: string;\r\n parameters: RpcSerializedValue;\r\n caching: RpcResponseCacheControl;\r\n ip?: string;\r\n protocolVersion?: number;\r\n parametersOverride?: any[];\r\n}\r\n\r\n/** An RPC operation request fulfillment.\r\n * @internal\r\n */\r\nexport interface RpcRequestFulfillment {\r\n /** The RPC interface for the request. */\r\n interfaceName: string;\r\n\r\n /** The id for the request. */\r\n id: string;\r\n\r\n /** The result for the request. */\r\n result: RpcSerializedValue;\r\n\r\n /** The un-serialized result for the request. */\r\n rawResult: any;\r\n\r\n /** A protocol-specific status code value for the request. */\r\n status: number;\r\n\r\n /* A protocol-specific value for retrying this request. */\r\n retry?: string;\r\n\r\n /** Whether to compress the result with one of the client's supported encodings. */\r\n allowCompression?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport namespace RpcRequestFulfillment {\r\n export async function forUnknownError(request: SerializedRpcRequest, error: any): Promise<RpcRequestFulfillment> {\r\n const result = RpcMarshaling.serialize(undefined, error);\r\n\r\n return {\r\n interfaceName: request.operation.interfaceDefinition,\r\n id: request.id,\r\n result,\r\n rawResult: error,\r\n status: RpcRequestStatus.Rejected,\r\n };\r\n }\r\n}\r\n\r\n/** Handles RPC protocol events.\r\n * @internal\r\n */\r\nexport type RpcProtocolEventHandler = (type: RpcProtocolEvent, object: RpcRequest | RpcInvocation, err?: any) => void;\r\n\r\n/** Documents changes to the RPC protocol version.\r\n * @internal\r\n */\r\nexport enum RpcProtocolVersion {\r\n None = 0,\r\n IntroducedNoContent = 1,\r\n IntroducedStatusCategory = 2\r\n}\r\n\r\n/**\r\n * A backend response that is handled internally by the RPC system.\r\n * @internal\r\n */\r\nexport interface RpcManagedStatus {\r\n iTwinRpcCoreResponse: true;\r\n managedStatus: \"pending\" | \"notFound\" | \"noContent\";\r\n responseValue: string | { message: string } | RpcNotFoundResponse;\r\n}\r\n\r\n/** An application protocol for an RPC interface.\r\n * @internal\r\n */\r\nexport abstract class RpcProtocol {\r\n /** Events raised by all protocols. See [[RpcProtocolEvent]] */\r\n public static readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** A version code that identifies the RPC protocol capabilties of this endpoint. */\r\n public static readonly protocolVersion: number = RpcProtocolVersion.IntroducedStatusCategory;\r\n\r\n /** The name of the RPC protocol version header. */\r\n public protocolVersionHeaderName = \"\";\r\n\r\n /** Events raised by the protocol. See [[RpcProtocolEvent]] */\r\n public readonly events: BeEvent<RpcProtocolEventHandler> = new BeEvent();\r\n\r\n /** The configuration for the protocol. */\r\n public readonly configuration: RpcConfiguration;\r\n\r\n /** The RPC request class for this protocol. */\r\n public abstract readonly requestType: typeof RpcRequest;\r\n\r\n /** The RPC invocation class for this protocol. */\r\n public readonly invocationType: typeof RpcInvocation = RpcInvocation;\r\n\r\n public serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\r\n /** The name of the request id header. */\r\n id: \"\",\r\n\r\n /** The name of the application id header */\r\n applicationId: \"\",\r\n\r\n /** The name of the version header. */\r\n applicationVersion: \"\",\r\n\r\n /** The name of the session id header */\r\n sessionId: \"\",\r\n\r\n /** The name of the authorization header. */\r\n authorization: \"\",\r\n };\r\n\r\n /** If greater than zero, specifies where to break large binary request payloads. */\r\n public transferChunkThreshold: number = 0;\r\n\r\n /** Used by protocols that can transmit stream values natively. */\r\n public preserveStreams: boolean = false;\r\n\r\n /** Used by protocols that can transmit IModelRpcProps values natively. */\r\n public checkToken: boolean = false;\r\n\r\n /** Used by protocols that support user-defined status codes. */\r\n public supportsStatusCategory: boolean = false;\r\n\r\n /** If checkToken is true, will be called on the backend to inflate the IModelRpcProps for each request. */\r\n public inflateToken(tokenFromBody: IModelRpcProps, _request: SerializedRpcRequest): IModelRpcProps { return tokenFromBody; }\r\n\r\n /** Override to supply the status corresponding to a protocol-specific code value. */\r\n public getStatus(code: number): RpcRequestStatus {\r\n return code;\r\n }\r\n\r\n /** Override to supply the protocol-specific code corresponding to a status value. */\r\n public getCode(status: RpcRequestStatus): number {\r\n return status;\r\n }\r\n\r\n /** Override to supply the protocol-specific path value for an RPC operation. */\r\n public supplyPathForOperation(operation: RpcOperation, _request: RpcRequest | undefined): string {\r\n return JSON.stringify(operation);\r\n }\r\n\r\n /** Override to supply the operation for a protocol-specific path value. */\r\n public getOperationFromPath(path: string): SerializedRpcOperation {\r\n return JSON.parse(path);\r\n }\r\n\r\n /** Obtains the implementation result on the backend for an RPC operation request. */\r\n public async fulfill(request: SerializedRpcRequest): Promise<RpcRequestFulfillment> {\r\n return new (this.invocationType)(this, request).fulfillment;\r\n }\r\n\r\n /** Serializes a request. */\r\n public async serialize(request: RpcRequest): Promise<SerializedRpcRequest> {\r\n const serializedContext = await RpcConfiguration.requestContext.serialize(request);\r\n return {\r\n ...serializedContext,\r\n operation: {\r\n interfaceDefinition: request.operation.interfaceDefinition.interfaceName,\r\n operationName: request.operation.operationName,\r\n interfaceVersion: request.operation.interfaceVersion,\r\n },\r\n method: request.method,\r\n path: request.path,\r\n parameters: RpcMarshaling.serialize(request.protocol, request.parameters),\r\n caching: RpcResponseCacheControl.None,\r\n protocolVersion: RpcProtocol.protocolVersion,\r\n };\r\n }\r\n\r\n /** Constructs a protocol. */\r\n public constructor(configuration: RpcConfiguration) {\r\n this.configuration = configuration;\r\n this.events.addListener((type, object) => RpcProtocol.events.raiseEvent(type, object));\r\n }\r\n\r\n /** @internal */\r\n public onRpcClientInitialized(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplInitialized(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcClientTerminated(_definition: RpcInterfaceDefinition, _client: RpcInterface): void { }\r\n\r\n /** @internal */\r\n public onRpcImplTerminated(_definition: RpcInterfaceDefinition, _impl: RpcInterface): void { }\r\n}\r\n"]}
|
|
@@ -27,13 +27,13 @@ export declare enum CurrentImdlVersion {
|
|
|
27
27
|
* front-end is not capable of reading the tile content. Otherwise, this front-end can read the tile content even if the header specifies a
|
|
28
28
|
* greater minor version than CurrentVersion.Minor, although some data may be skipped.
|
|
29
29
|
*/
|
|
30
|
-
Major =
|
|
30
|
+
Major = 33,
|
|
31
31
|
/** The unsigned 16-bit minor version number. If the major version in the tile header is equal to CurrentVersion.Major, then this package can
|
|
32
32
|
* read the tile content even if the minor version in the tile header is greater than this value, although some data may be skipped.
|
|
33
33
|
*/
|
|
34
34
|
Minor = 0,
|
|
35
35
|
/** The unsigned 32-bit version number derived from the 16-bit major and minor version numbers. */
|
|
36
|
-
Combined =
|
|
36
|
+
Combined = 2162688
|
|
37
37
|
}
|
|
38
38
|
/** Header embedded at the beginning of binary tile data in iMdl format describing its contents.
|
|
39
39
|
* @internal
|
|
@@ -36,13 +36,13 @@ var CurrentImdlVersion;
|
|
|
36
36
|
* front-end is not capable of reading the tile content. Otherwise, this front-end can read the tile content even if the header specifies a
|
|
37
37
|
* greater minor version than CurrentVersion.Minor, although some data may be skipped.
|
|
38
38
|
*/
|
|
39
|
-
CurrentImdlVersion[CurrentImdlVersion["Major"] =
|
|
39
|
+
CurrentImdlVersion[CurrentImdlVersion["Major"] = 33] = "Major";
|
|
40
40
|
/** The unsigned 16-bit minor version number. If the major version in the tile header is equal to CurrentVersion.Major, then this package can
|
|
41
41
|
* read the tile content even if the minor version in the tile header is greater than this value, although some data may be skipped.
|
|
42
42
|
*/
|
|
43
43
|
CurrentImdlVersion[CurrentImdlVersion["Minor"] = 0] = "Minor";
|
|
44
44
|
/** The unsigned 32-bit version number derived from the 16-bit major and minor version numbers. */
|
|
45
|
-
CurrentImdlVersion[CurrentImdlVersion["Combined"] =
|
|
45
|
+
CurrentImdlVersion[CurrentImdlVersion["Combined"] = 2162688] = "Combined";
|
|
46
46
|
})(CurrentImdlVersion = exports.CurrentImdlVersion || (exports.CurrentImdlVersion = {}));
|
|
47
47
|
/** Header embedded at the beginning of binary tile data in iMdl format describing its contents.
|
|
48
48
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTileIO.js","sourceRoot":"","sources":["../../../src/tile/IModelTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AACzD,wDAA+C;AAE/C,qCAA+E;AAE/E;;GAEG;AACH,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,uBAAuB;IACvB,yCAAQ,CAAA;IACR,6CAA6C;IAC7C,6DAAuB,CAAA;IACvB,wEAAwE;IACxE,qDAAmB,CAAA;IACnB,mEAAmE;IACnE,2EAA8B,CAAA;IAC9B,uEAAuE;IACvE,8EAA+B,CAAA;AACjC,CAAC,EAXW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAWpB;AAED;;GAEG;AACH,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B;;;OAGG;IACH,8DAAU,CAAA;IACV;;OAEG;IACH,6DAAS,CAAA;IACT,kGAAkG;IAClG,yEAAkC,CAAA;AACpC,CAAC,EAZW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAY7B;AAED;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAkBxC,IAAW,YAAY,KAAa,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC;IACnE,IAAW,YAAY,KAAa,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3E,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC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a,kBAAkB;IAStB,MAAM,CAAC,QAAQ,CAAC,MAAkB;QACvC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9F,CAAC;IAID,YAAoB,MAAc,EAAE,gBAAwB,EAAE,KAAa;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;;AANa,8BAAW,GAAG,EAAE,CAAC;AAhBpB,gDAAkB","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 Tile\r\n */\r\n\r\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { ElementAlignedBox3d } from \"../geometry/Placement\";\r\nimport { nextPoint3d64FromByteStream, TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Flags describing the geometry contained within a tile in iMdl format.\r\n * @internal\r\n */\r\nexport enum ImdlFlags {\r\n /** No special flags */\r\n None = 0,\r\n /** The tile contains some curved geometry */\r\n ContainsCurves = 1 << 0,\r\n /** Some geometry within the tile range was omitted based on its size */\r\n Incomplete = 1 << 2,\r\n /** The tile must be refined by sub-division, not magnification. */\r\n DisallowMagnification = 1 << 3,\r\n /** The tile's feature table contains features from multiple models. */\r\n MultiModelFeatureTable = 1 << 4,\r\n}\r\n\r\n/** Describes the maximum major and minor version of the iMdl tile format supported by this version of this package.\r\n * @internal\r\n */\r\nexport enum CurrentImdlVersion {\r\n /** The unsigned 16-bit major version number. If the major version specified in the tile header is greater than this value, then this\r\n * front-end is not capable of reading the tile content. Otherwise, this front-end can read the tile content even if the header specifies a\r\n * greater minor version than CurrentVersion.Minor, although some data may be skipped.\r\n */\r\n Major =
|
|
1
|
+
{"version":3,"file":"IModelTileIO.js","sourceRoot":"","sources":["../../../src/tile/IModelTileIO.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AACzD,wDAA+C;AAE/C,qCAA+E;AAE/E;;GAEG;AACH,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,uBAAuB;IACvB,yCAAQ,CAAA;IACR,6CAA6C;IAC7C,6DAAuB,CAAA;IACvB,wEAAwE;IACxE,qDAAmB,CAAA;IACnB,mEAAmE;IACnE,2EAA8B,CAAA;IAC9B,uEAAuE;IACvE,8EAA+B,CAAA;AACjC,CAAC,EAXW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAWpB;AAED;;GAEG;AACH,IAAY,kBAYX;AAZD,WAAY,kBAAkB;IAC5B;;;OAGG;IACH,8DAAU,CAAA;IACV;;OAEG;IACH,6DAAS,CAAA;IACT,kGAAkG;IAClG,yEAAkC,CAAA;AACpC,CAAC,EAZW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAY7B;AAED;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAU;IAkBxC,IAAW,YAAY,KAAa,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC;IACnE,IAAW,YAAY,KAAa,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3E,IAAW,OAAO,KAAc,OAAO,mBAAU,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IA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,MAAM,CAAC,QAAQ,CAAC,MAAkB;QACvC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9F,CAAC;IAID,YAAoB,MAAc,EAAE,gBAAwB,EAAE,KAAa;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;;AANa,8BAAW,GAAG,EAAE,CAAC;AAhBpB,gDAAkB","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 Tile\r\n */\r\n\r\nimport { assert, ByteStream } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport { ElementAlignedBox3d } from \"../geometry/Placement\";\r\nimport { nextPoint3d64FromByteStream, TileFormat, TileHeader } from \"./TileIO\";\r\n\r\n/** Flags describing the geometry contained within a tile in iMdl format.\r\n * @internal\r\n */\r\nexport enum ImdlFlags {\r\n /** No special flags */\r\n None = 0,\r\n /** The tile contains some curved geometry */\r\n ContainsCurves = 1 << 0,\r\n /** Some geometry within the tile range was omitted based on its size */\r\n Incomplete = 1 << 2,\r\n /** The tile must be refined by sub-division, not magnification. */\r\n DisallowMagnification = 1 << 3,\r\n /** The tile's feature table contains features from multiple models. */\r\n MultiModelFeatureTable = 1 << 4,\r\n}\r\n\r\n/** Describes the maximum major and minor version of the iMdl tile format supported by this version of this package.\r\n * @internal\r\n */\r\nexport enum CurrentImdlVersion {\r\n /** The unsigned 16-bit major version number. If the major version specified in the tile header is greater than this value, then this\r\n * front-end is not capable of reading the tile content. Otherwise, this front-end can read the tile content even if the header specifies a\r\n * greater minor version than CurrentVersion.Minor, although some data may be skipped.\r\n */\r\n Major = 33,\r\n /** The unsigned 16-bit minor version number. If the major version in the tile header is equal to CurrentVersion.Major, then this package can\r\n * read the tile content even if the minor version in the tile header is greater than this value, although some data may be skipped.\r\n */\r\n Minor = 0,\r\n /** The unsigned 32-bit version number derived from the 16-bit major and minor version numbers. */\r\n Combined = (Major << 0x10) | Minor,\r\n}\r\n\r\n/** Header embedded at the beginning of binary tile data in iMdl format describing its contents.\r\n * @internal\r\n */\r\nexport class ImdlHeader extends TileHeader {\r\n /** The size of this header in bytes. */\r\n public readonly headerLength: number;\r\n /** Flags describing the geometry contained within the tile */\r\n public readonly flags: ImdlFlags;\r\n /** A bounding box no larger than the tile's range, tightly enclosing the tile's geometry; or a null range if the tile is empty */\r\n public readonly contentRange: ElementAlignedBox3d;\r\n /** The chord tolerance in meters at which the tile's geometry was faceted */\r\n public readonly tolerance: number;\r\n /** The number of elements which contributed at least some geometry to the tile content */\r\n public readonly numElementsIncluded: number;\r\n /** The number of elements within the tile range which contributed no geometry to the tile content */\r\n public readonly numElementsExcluded: number;\r\n /** The total number of bytes in the binary tile data, including this header */\r\n public readonly tileLength: number;\r\n /** A bitfield wherein each set bit indicates an empty sub-volume. */\r\n public readonly emptySubRanges: number;\r\n\r\n public get versionMajor(): number { return this.version >>> 0x10; }\r\n public get versionMinor(): number { return (this.version & 0xffff) >>> 0; }\r\n\r\n public get isValid(): boolean { return TileFormat.IModel === this.format; }\r\n public get isReadableVersion(): boolean { return this.versionMajor <= CurrentImdlVersion.Major; }\r\n\r\n /** Deserialize a header from the binary data at the stream's current position.\r\n * If the binary data does not contain a valid header, the Header will be marked 'invalid'.\r\n */\r\n public constructor(stream: ByteStream) {\r\n super(stream);\r\n this.headerLength = stream.readUint32();\r\n this.flags = stream.readUint32();\r\n\r\n this.contentRange = new Range3d();\r\n nextPoint3d64FromByteStream(stream, this.contentRange.low);\r\n nextPoint3d64FromByteStream(stream, this.contentRange.high);\r\n\r\n this.tolerance = stream.readFloat64();\r\n this.numElementsIncluded = stream.readUint32();\r\n this.numElementsExcluded = stream.readUint32();\r\n this.tileLength = stream.readUint32();\r\n\r\n // empty sub-volume bit field introduced in format v02.00\r\n this.emptySubRanges = this.versionMajor >= 2 ? stream.readUint32() : 0;\r\n\r\n // Skip any unprocessed bytes in header\r\n const remainingHeaderBytes = this.headerLength - stream.curPos;\r\n assert(remainingHeaderBytes >= 0);\r\n stream.advance(remainingHeaderBytes);\r\n\r\n if (stream.isPastTheEnd)\r\n this.invalidate();\r\n }\r\n}\r\n\r\n/** Header preceding the feature table embedded in an iMdl tile's content.\r\n * @internal\r\n */\r\nexport class FeatureTableHeader {\r\n // The number of bytes the entire table occupies.\r\n public readonly length: number;\r\n // The number of subcategories in the table.\r\n // NOTE: This used to be \"max features\" which was useless and unused. It is only accurate if ImdlFlags.HasMultiModelFeatureTable is set.\r\n public readonly numSubCategories: number;\r\n // The number of features in the table.\r\n public readonly count: number;\r\n\r\n public static readFrom(stream: ByteStream) {\r\n const length = stream.readUint32();\r\n const maxFeatures = stream.readUint32();\r\n const count = stream.readUint32();\r\n return stream.isPastTheEnd ? undefined : new FeatureTableHeader(length, maxFeatures, count);\r\n }\r\n\r\n public static sizeInBytes = 12;\r\n\r\n private constructor(length: number, numSubCategories: number, count: number) {\r\n this.length = length;\r\n this.numSubCategories = numSubCategories;\r\n this.count = count;\r\n }\r\n}\r\n"]}
|
package/lib/esm/IModel.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
4
|
import { BeEvent, GuidString, Id64String, OpenMode } from "@itwin/core-bentley";
|
|
5
|
-
import { Angle, Point3d, Range3dProps, Transform, Vector3d, XYAndZ, XYZProps, YawPitchRollAngles, YawPitchRollProps } from "@itwin/core-geometry";
|
|
5
|
+
import { Angle, Point3d, Range3dProps, Transform, TransformProps, Vector3d, XYAndZ, XYZProps, YawPitchRollAngles, YawPitchRollProps } from "@itwin/core-geometry";
|
|
6
6
|
import { ChangesetIdWithIndex } from "./ChangesetProps";
|
|
7
7
|
import { Cartographic, CartographicProps } from "./geometry/Cartographic";
|
|
8
8
|
import { GeographicCRS, GeographicCRSProps } from "./geometry/CoordinateReferenceSystem";
|
|
@@ -33,7 +33,8 @@ export interface IModelRpcProps extends IModelRpcOpenProps {
|
|
|
33
33
|
* of the origin property. This cartographicOrigin is offered as a convenient pre-calculated value representing the location of the ECEF origin.
|
|
34
34
|
* The 3D coordinate system this class represents is positioned at specified origin and the axis positioned according to
|
|
35
35
|
* the other properties.
|
|
36
|
-
* If
|
|
36
|
+
* If transform property is defined then it will not be computed from other properties.
|
|
37
|
+
* If the xVector and yVector properties are defined (and transform is not defined) then they take precedence over the YawPitchRoll orientation property. The xVector and yVector
|
|
37
38
|
* represent the direction and scale of the X and Y axes. The Z axis is always perpendicular (according to the right hand rule) to these X-Y axes.
|
|
38
39
|
* The scaling in the Z direction is always unity. The scale of the X and Y axes is represented by the size of the vector length.
|
|
39
40
|
* If the xVector and yVector are not present then the YawPitchRoll properties indicates the angles for all tree axes. Scaling in that case
|
|
@@ -55,6 +56,10 @@ export interface EcefLocationProps {
|
|
|
55
56
|
readonly xVector?: XYZProps;
|
|
56
57
|
/** Optional Y column vector used with [[xVector]] to calculate potentially non-rigid transform if a projection is present. */
|
|
57
58
|
readonly yVector?: XYZProps;
|
|
59
|
+
/** Optional potentially non-rigid transform defining the ECEF location.
|
|
60
|
+
* @note If this property is supplied, the other properties are ignored.
|
|
61
|
+
*/
|
|
62
|
+
readonly transform?: TransformProps;
|
|
58
63
|
}
|
|
59
64
|
/** Properties of the [Root Subject]($docs/bis/guide/references/glossary#subject-root).
|
|
60
65
|
* @public
|
|
@@ -196,6 +201,7 @@ export declare class EcefLocation implements EcefLocationProps {
|
|
|
196
201
|
readonly xVector?: Vector3d;
|
|
197
202
|
/** Optional Y column vector used with [[xVector]] to calculate potentially non-rigid transform if a projection is present. */
|
|
198
203
|
readonly yVector?: Vector3d;
|
|
204
|
+
/** The transform from iModel Spatial coordinates to ECEF from this EcefLocation */
|
|
199
205
|
private readonly _transform;
|
|
200
206
|
/** Get the transform from iModel Spatial coordinates to ECEF from this EcefLocation */
|
|
201
207
|
getTransform(): Transform;
|
|
@@ -207,6 +213,8 @@ export declare class EcefLocation implements EcefLocationProps {
|
|
|
207
213
|
get isValid(): boolean;
|
|
208
214
|
/** Construct ECEF Location from cartographic origin with optional known point and angle. */
|
|
209
215
|
static createFromCartographicOrigin(origin: Cartographic, point?: Point3d, angle?: Angle): EcefLocation;
|
|
216
|
+
/** Construct ECEF Location from transform with optional position on the earth used to establish the ECEF origin and orientation. */
|
|
217
|
+
static createFromTransform(transform: Transform): EcefLocation;
|
|
210
218
|
/** Get the location center of the earth in the iModel coordinate system. */
|
|
211
219
|
get earthCenter(): Point3d;
|
|
212
220
|
/** Return true if this location is equivalent to another location within a small tolerance. */
|
package/lib/esm/IModel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModel.d.ts","sourceRoot":"","sources":["../../src/IModel.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAAoB,UAAU,EAAQ,UAAU,EAAyB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACvI,OAAO,EACL,KAAK,EAAsD,OAAO,EAAW,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"IModel.d.ts","sourceRoot":"","sources":["../../src/IModel.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAAoB,UAAU,EAAQ,UAAU,EAAy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
|
20
20
|
getTransform() { return this._transform; }
|
|
21
21
|
/** Construct a new EcefLocation. Once constructed, it is frozen and cannot be modified. */
|
|
22
22
|
constructor(props) {
|
|
23
|
+
/** The transform from iModel Spatial coordinates to ECEF from this EcefLocation */
|
|
24
|
+
this._transform = Transform.createIdentity();
|
|
23
25
|
this.origin = Point3d.fromJSON(props.origin).freeze();
|
|
24
26
|
this.orientation = YawPitchRollAngles.fromJSON(props.orientation).freeze();
|
|
25
27
|
if (props.cartographicOrigin)
|
|
@@ -28,16 +30,22 @@ export class EcefLocation {
|
|
|
28
30
|
this.xVector = Vector3d.fromJSON(props.xVector).freeze();
|
|
29
31
|
this.yVector = Vector3d.fromJSON(props.yVector).freeze();
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (props.transform) {
|
|
34
|
+
this._transform.setFromJSON(props.transform);
|
|
35
|
+
this._transform.freeze();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
let matrix;
|
|
39
|
+
if (this.xVector && this.yVector) {
|
|
40
|
+
const zVector = this.xVector.crossProduct(this.yVector);
|
|
41
|
+
if (zVector.normalizeInPlace())
|
|
42
|
+
matrix = Matrix3d.createColumns(this.xVector, this.yVector, zVector);
|
|
43
|
+
}
|
|
44
|
+
if (!matrix)
|
|
45
|
+
matrix = this.orientation.toMatrix3d();
|
|
46
|
+
this._transform = Transform.createOriginAndMatrix(this.origin, matrix);
|
|
47
|
+
this._transform.freeze();
|
|
36
48
|
}
|
|
37
|
-
if (!matrix)
|
|
38
|
-
matrix = this.orientation.toMatrix3d();
|
|
39
|
-
this._transform = Transform.createOriginAndMatrix(this.origin, matrix);
|
|
40
|
-
this._transform.freeze();
|
|
41
49
|
}
|
|
42
50
|
/** Returns true if this EcefLocation is not located at the center of the Earth.
|
|
43
51
|
* @alpha are locations very close to the center considered valid? What are the specific criteria?
|
|
@@ -66,6 +74,14 @@ export class EcefLocation {
|
|
|
66
74
|
}
|
|
67
75
|
return new EcefLocation({ origin: ecefOrigin, orientation: YawPitchRollAngles.createFromMatrix3d(matrix), cartographicOrigin: origin });
|
|
68
76
|
}
|
|
77
|
+
/** Construct ECEF Location from transform with optional position on the earth used to establish the ECEF origin and orientation. */
|
|
78
|
+
static createFromTransform(transform) {
|
|
79
|
+
const ecefOrigin = transform.getOrigin();
|
|
80
|
+
const angleFromInput = YawPitchRollAngles.createDegrees(0, 0, 0);
|
|
81
|
+
const locationOrientationFromInputT = YawPitchRollAngles.createFromMatrix3d(transform.getMatrix(), angleFromInput);
|
|
82
|
+
const transformProps = transform.toJSON();
|
|
83
|
+
return new EcefLocation({ origin: ecefOrigin, orientation: locationOrientationFromInputT ?? angleFromInput, transform: transformProps });
|
|
84
|
+
}
|
|
69
85
|
/** Get the location center of the earth in the iModel coordinate system. */
|
|
70
86
|
get earthCenter() {
|
|
71
87
|
const matrix = this.orientation.toMatrix3d();
|
|
@@ -81,6 +97,8 @@ export class EcefLocation {
|
|
|
81
97
|
return false;
|
|
82
98
|
if (this.yVector !== undefined && other.yVector !== undefined && !this.yVector.isAlmostEqual(other.yVector))
|
|
83
99
|
return false;
|
|
100
|
+
if (!this.getTransform().isAlmostEqual(other.getTransform()))
|
|
101
|
+
return false;
|
|
84
102
|
const thisCarto = this.cartographicOrigin;
|
|
85
103
|
const otherCarto = other.cartographicOrigin;
|
|
86
104
|
if (undefined === thisCarto || undefined === otherCarto)
|
|
@@ -91,6 +109,7 @@ export class EcefLocation {
|
|
|
91
109
|
const props = {
|
|
92
110
|
origin: this.origin.toJSON(),
|
|
93
111
|
orientation: this.orientation.toJSON(),
|
|
112
|
+
transform: this.getTransform().toJSON(),
|
|
94
113
|
};
|
|
95
114
|
if (this.cartographicOrigin)
|
|
96
115
|
props.cartographicOrigin = this.cartographicOrigin.toJSON();
|