@itwin/core-common 5.2.0-dev.5 → 5.2.0-dev.8

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.
Files changed (154) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/AnalysisStyle.d.ts.map +1 -1
  3. package/lib/cjs/AnalysisStyle.js +2 -0
  4. package/lib/cjs/AnalysisStyle.js.map +1 -1
  5. package/lib/cjs/BlobReader.d.ts.map +1 -1
  6. package/lib/cjs/BlobReader.js +10 -2
  7. package/lib/cjs/BlobReader.js.map +1 -1
  8. package/lib/cjs/DisplayStyleSettings.d.ts.map +1 -1
  9. package/lib/cjs/DisplayStyleSettings.js +1 -1
  10. package/lib/cjs/DisplayStyleSettings.js.map +1 -1
  11. package/lib/cjs/ECSqlTypes.js +1 -1
  12. package/lib/cjs/ECSqlTypes.js.map +1 -1
  13. package/lib/cjs/FeatureIndex.d.ts.map +1 -1
  14. package/lib/cjs/FeatureIndex.js +2 -1
  15. package/lib/cjs/FeatureIndex.js.map +1 -1
  16. package/lib/cjs/GeometryParams.d.ts.map +1 -1
  17. package/lib/cjs/GeometryParams.js +6 -0
  18. package/lib/cjs/GeometryParams.js.map +1 -1
  19. package/lib/cjs/Gradient.d.ts.map +1 -1
  20. package/lib/cjs/Gradient.js +5 -0
  21. package/lib/cjs/Gradient.js.map +1 -1
  22. package/lib/cjs/HiddenLine.d.ts.map +1 -1
  23. package/lib/cjs/HiddenLine.js +4 -1
  24. package/lib/cjs/HiddenLine.js.map +1 -1
  25. package/lib/cjs/IModel.d.ts.map +1 -1
  26. package/lib/cjs/IModel.js +7 -7
  27. package/lib/cjs/IModel.js.map +1 -1
  28. package/lib/cjs/Localization.d.ts.map +1 -1
  29. package/lib/cjs/Localization.js +3 -0
  30. package/lib/cjs/Localization.js.map +1 -1
  31. package/lib/cjs/TextureMapping.js +2 -2
  32. package/lib/cjs/TextureMapping.js.map +1 -1
  33. package/lib/cjs/ThematicDisplay.d.ts.map +1 -1
  34. package/lib/cjs/ThematicDisplay.js +3 -1
  35. package/lib/cjs/ThematicDisplay.js.map +1 -1
  36. package/lib/cjs/Tween.d.ts +1 -1
  37. package/lib/cjs/Tween.d.ts.map +1 -1
  38. package/lib/cjs/Tween.js +4 -2
  39. package/lib/cjs/Tween.js.map +1 -1
  40. package/lib/cjs/geometry/AdditionalTransform.d.ts.map +1 -1
  41. package/lib/cjs/geometry/AdditionalTransform.js +1 -0
  42. package/lib/cjs/geometry/AdditionalTransform.js.map +1 -1
  43. package/lib/cjs/geometry/AreaPattern.d.ts.map +1 -1
  44. package/lib/cjs/geometry/AreaPattern.js +13 -0
  45. package/lib/cjs/geometry/AreaPattern.js.map +1 -1
  46. package/lib/cjs/geometry/CoordinateReferenceSystem.d.ts.map +1 -1
  47. package/lib/cjs/geometry/CoordinateReferenceSystem.js +7 -0
  48. package/lib/cjs/geometry/CoordinateReferenceSystem.js.map +1 -1
  49. package/lib/cjs/geometry/ElementGeometry.d.ts.map +1 -1
  50. package/lib/cjs/geometry/ElementGeometry.js +19 -10
  51. package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
  52. package/lib/cjs/geometry/ElementGeometryFB.d.ts.map +1 -1
  53. package/lib/cjs/geometry/ElementGeometryFB.js +1 -0
  54. package/lib/cjs/geometry/ElementGeometryFB.js.map +1 -1
  55. package/lib/cjs/geometry/GeodeticDatum.d.ts.map +1 -1
  56. package/lib/cjs/geometry/GeodeticDatum.js +7 -0
  57. package/lib/cjs/geometry/GeodeticDatum.js.map +1 -1
  58. package/lib/cjs/geometry/GeometryStream.d.ts.map +1 -1
  59. package/lib/cjs/geometry/GeometryStream.js +2 -2
  60. package/lib/cjs/geometry/GeometryStream.js.map +1 -1
  61. package/lib/cjs/geometry/LineStyle.d.ts.map +1 -1
  62. package/lib/cjs/geometry/LineStyle.js +3 -0
  63. package/lib/cjs/geometry/LineStyle.js.map +1 -1
  64. package/lib/cjs/geometry/Placement.d.ts.map +1 -1
  65. package/lib/cjs/geometry/Placement.js +1 -1
  66. package/lib/cjs/geometry/Placement.js.map +1 -1
  67. package/lib/cjs/internal/PackedFeatureTable.d.ts.map +1 -1
  68. package/lib/cjs/internal/PackedFeatureTable.js +1 -1
  69. package/lib/cjs/internal/PackedFeatureTable.js.map +1 -1
  70. package/lib/cjs/rpc/core/RpcConfiguration.d.ts +0 -3
  71. package/lib/cjs/rpc/core/RpcConfiguration.d.ts.map +1 -1
  72. package/lib/cjs/rpc/core/RpcConfiguration.js +10 -2
  73. package/lib/cjs/rpc/core/RpcConfiguration.js.map +1 -1
  74. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js +1 -1
  75. package/lib/cjs/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  76. package/lib/cjs/rpc/web/WebAppRpcRequest.js +1 -1
  77. package/lib/cjs/rpc/web/WebAppRpcRequest.js.map +1 -1
  78. package/lib/esm/AnalysisStyle.d.ts.map +1 -1
  79. package/lib/esm/AnalysisStyle.js +2 -0
  80. package/lib/esm/AnalysisStyle.js.map +1 -1
  81. package/lib/esm/BlobReader.d.ts.map +1 -1
  82. package/lib/esm/BlobReader.js +10 -2
  83. package/lib/esm/BlobReader.js.map +1 -1
  84. package/lib/esm/DisplayStyleSettings.d.ts.map +1 -1
  85. package/lib/esm/DisplayStyleSettings.js +2 -2
  86. package/lib/esm/DisplayStyleSettings.js.map +1 -1
  87. package/lib/esm/ECSqlTypes.js +1 -1
  88. package/lib/esm/ECSqlTypes.js.map +1 -1
  89. package/lib/esm/FeatureIndex.d.ts.map +1 -1
  90. package/lib/esm/FeatureIndex.js +2 -1
  91. package/lib/esm/FeatureIndex.js.map +1 -1
  92. package/lib/esm/GeometryParams.d.ts.map +1 -1
  93. package/lib/esm/GeometryParams.js +6 -0
  94. package/lib/esm/GeometryParams.js.map +1 -1
  95. package/lib/esm/Gradient.d.ts.map +1 -1
  96. package/lib/esm/Gradient.js +5 -0
  97. package/lib/esm/Gradient.js.map +1 -1
  98. package/lib/esm/HiddenLine.d.ts.map +1 -1
  99. package/lib/esm/HiddenLine.js +4 -1
  100. package/lib/esm/HiddenLine.js.map +1 -1
  101. package/lib/esm/IModel.d.ts.map +1 -1
  102. package/lib/esm/IModel.js +8 -8
  103. package/lib/esm/IModel.js.map +1 -1
  104. package/lib/esm/Localization.d.ts.map +1 -1
  105. package/lib/esm/Localization.js +3 -0
  106. package/lib/esm/Localization.js.map +1 -1
  107. package/lib/esm/TextureMapping.js +3 -3
  108. package/lib/esm/TextureMapping.js.map +1 -1
  109. package/lib/esm/ThematicDisplay.d.ts.map +1 -1
  110. package/lib/esm/ThematicDisplay.js +3 -1
  111. package/lib/esm/ThematicDisplay.js.map +1 -1
  112. package/lib/esm/Tween.d.ts +1 -1
  113. package/lib/esm/Tween.d.ts.map +1 -1
  114. package/lib/esm/Tween.js +4 -2
  115. package/lib/esm/Tween.js.map +1 -1
  116. package/lib/esm/geometry/AdditionalTransform.d.ts.map +1 -1
  117. package/lib/esm/geometry/AdditionalTransform.js +1 -0
  118. package/lib/esm/geometry/AdditionalTransform.js.map +1 -1
  119. package/lib/esm/geometry/AreaPattern.d.ts.map +1 -1
  120. package/lib/esm/geometry/AreaPattern.js +13 -0
  121. package/lib/esm/geometry/AreaPattern.js.map +1 -1
  122. package/lib/esm/geometry/CoordinateReferenceSystem.d.ts.map +1 -1
  123. package/lib/esm/geometry/CoordinateReferenceSystem.js +7 -0
  124. package/lib/esm/geometry/CoordinateReferenceSystem.js.map +1 -1
  125. package/lib/esm/geometry/ElementGeometry.d.ts.map +1 -1
  126. package/lib/esm/geometry/ElementGeometry.js +20 -11
  127. package/lib/esm/geometry/ElementGeometry.js.map +1 -1
  128. package/lib/esm/geometry/ElementGeometryFB.d.ts.map +1 -1
  129. package/lib/esm/geometry/ElementGeometryFB.js +1 -0
  130. package/lib/esm/geometry/ElementGeometryFB.js.map +1 -1
  131. package/lib/esm/geometry/GeodeticDatum.d.ts.map +1 -1
  132. package/lib/esm/geometry/GeodeticDatum.js +7 -0
  133. package/lib/esm/geometry/GeodeticDatum.js.map +1 -1
  134. package/lib/esm/geometry/GeometryStream.d.ts.map +1 -1
  135. package/lib/esm/geometry/GeometryStream.js +3 -3
  136. package/lib/esm/geometry/GeometryStream.js.map +1 -1
  137. package/lib/esm/geometry/LineStyle.d.ts.map +1 -1
  138. package/lib/esm/geometry/LineStyle.js +3 -0
  139. package/lib/esm/geometry/LineStyle.js.map +1 -1
  140. package/lib/esm/geometry/Placement.d.ts.map +1 -1
  141. package/lib/esm/geometry/Placement.js +2 -2
  142. package/lib/esm/geometry/Placement.js.map +1 -1
  143. package/lib/esm/internal/PackedFeatureTable.d.ts.map +1 -1
  144. package/lib/esm/internal/PackedFeatureTable.js +2 -2
  145. package/lib/esm/internal/PackedFeatureTable.js.map +1 -1
  146. package/lib/esm/rpc/core/RpcConfiguration.d.ts +0 -3
  147. package/lib/esm/rpc/core/RpcConfiguration.d.ts.map +1 -1
  148. package/lib/esm/rpc/core/RpcConfiguration.js +10 -2
  149. package/lib/esm/rpc/core/RpcConfiguration.js.map +1 -1
  150. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js +1 -1
  151. package/lib/esm/rpc/web/BentleyCloudRpcProtocol.js.map +1 -1
  152. package/lib/esm/rpc/web/WebAppRpcRequest.js +2 -2
  153. package/lib/esm/rpc/web/WebAppRpcRequest.js.map +1 -1
  154. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"PackedFeatureTable.js","sourceRoot":"","sources":["../../../src/internal/PackedFeatureTable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwYH,kDASC;AA/YD,sDAE6B;AAC7B,kDAA2J;AAC3J,sDAAkD;AAElD;;;;GAIG;AACH,MAAa,kBAAkB;IACb,IAAI,CAAc;IAClB,YAAY,CAAa;IACzB,gBAAgB,CAAkB;IAClC,WAAW,CAAS;IACpB,UAAU,CAAU;IACpB,IAAI,CAAY;IACzB,gBAAgB,CAAa;IAEpC,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IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;gBAC/B,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7H,CAAC;YAED,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Rendering\n */\n\nimport {\n assert, Id64, Id64String, UintArray,\n} from \"@itwin/core-bentley\";\nimport { BatchType, ComputeNodeId, Feature, FeatureTable, ModelFeature, PackedFeature, PackedFeatureWithIndex, RenderFeatureTable } from \"../FeatureTable\";\nimport { GeometryClass } from \"../GeometryParams\";\n\n/**\n * An immutable, packed representation of a [[FeatureTable]]. The features are packed into a single array of 32-bit integer values,\n * wherein each feature occupies 3 32-bit integers.\n * @internal\n */\nexport class PackedFeatureTable implements RenderFeatureTable {\n public readonly data: Uint32Array;\n public readonly batchModelId: Id64String;\n public readonly batchModelIdPair: Id64.Uint32Pair;\n public readonly numFeatures: number;\n public readonly anyDefined: boolean;\n public readonly type: BatchType;\n public animationNodeIds?: UintArray;\n\n public get byteLength(): number { return this.data.byteLength; }\n\n /** Construct a PackedFeatureTable from the packed binary data.\n * This is used internally when deserializing Tiles in iMdl format.\n * @internal\n */\n public constructor(data: Uint32Array, modelId: Id64String, numFeatures: number, type: BatchType, animationNodeIds?: UintArray) {\n this.data = data;\n this.batchModelId = modelId;\n this.batchModelIdPair = Id64.getUint32Pair(modelId);\n this.numFeatures = numFeatures;\n this.type = type;\n this.animationNodeIds = animationNodeIds;\n\n switch (this.numFeatures) {\n case 0:\n this.anyDefined = false;\n break;\n case 1:\n this.anyDefined = ModelFeature.isDefined(this.getFeature(0, ModelFeature.create()));\n break;\n default:\n this.anyDefined = true;\n break;\n }\n\n assert(this.data.length >= this._subCategoriesOffset);\n assert(undefined === this.animationNodeIds || this.animationNodeIds.length === this.numFeatures);\n }\n\n /** Create a packed feature table from a [[FeatureTable]]. */\n public static pack(featureTable: FeatureTable): PackedFeatureTable {\n // We must determine how many subcategories we have ahead of time to compute the size of the Uint32Array, as\n // the array cannot be resized after it is created.\n // We are not too worried about this as FeatureTables created on the front-end will contain few if any features; those obtained from the\n // back-end arrive within tiles already in the packed format.\n const subcategories = new Map<string, number>();\n for (const iv of featureTable.getArray()) {\n const found = subcategories.get(iv.value.subCategoryId.toString());\n if (undefined === found)\n subcategories.set(iv.value.subCategoryId, subcategories.size);\n }\n\n // We need 3 32-bit integers per feature, plus 2 32-bit integers per subcategory.\n const subCategoriesOffset = 3 * featureTable.length;\n const nUint32s = subCategoriesOffset + 2 * subcategories.size;\n const uint32s = new Uint32Array(nUint32s);\n\n for (const iv of featureTable.getArray()) {\n const feature = iv.value;\n const index = iv.index * 3;\n\n let subCategoryIndex = subcategories.get(feature.subCategoryId)!;\n assert(undefined !== subCategoryIndex); // we inserted it above...\n subCategoryIndex |= (feature.geometryClass << 24);\n\n uint32s[index + 0] = Id64.getLowerUint32(feature.elementId);\n uint32s[index + 1] = Id64.getUpperUint32(feature.elementId);\n uint32s[index + 2] = subCategoryIndex;\n }\n\n subcategories.forEach((index: number, id: string, _map) => {\n const index32 = subCategoriesOffset + 2 * index;\n uint32s[index32 + 0] = Id64.getLowerUint32(id);\n uint32s[index32 + 1] = Id64.getUpperUint32(id);\n });\n\n return new PackedFeatureTable(uint32s, featureTable.modelId, featureTable.length, featureTable.type);\n }\n\n /** Retrieve the Feature associated with the specified index. */\n public getFeature(featureIndex: number, result: ModelFeature): ModelFeature {\n const packed = this.getPackedFeature(featureIndex, scratchPackedFeature);\n return ModelFeature.unpack(packed, result, this.batchModelId);\n }\n\n /** Returns the Feature associated with the specified index, or undefined if the index is out of range. */\n public findFeature(featureIndex: number, result: ModelFeature): ModelFeature | undefined {\n return featureIndex < this.numFeatures ? this.getFeature(featureIndex, result) : undefined;\n }\n\n /** @internal */\n public getElementIdPair(featureIndex: number, out?: Id64.Uint32Pair): Id64.Uint32Pair {\n out = out ?? { lower: 0, upper: 0 };\n assert(featureIndex < this.numFeatures);\n const offset = 3 * featureIndex;\n out.lower = this.data[offset];\n out.upper = this.data[offset + 1];\n return out;\n }\n\n /** @internal */\n public getSubCategoryIdPair(featureIndex: number): Id64.Uint32Pair {\n const index = 3 * featureIndex;\n let subCatIndex = this.data[index + 2];\n subCatIndex = (subCatIndex & 0x00ffffff) >>> 0;\n subCatIndex = subCatIndex * 2 + this._subCategoriesOffset;\n return { lower: this.data[subCatIndex], upper: this.data[subCatIndex + 1] };\n }\n\n /** @internal */\n public getAnimationNodeId(featureIndex: number): number {\n return undefined !== this.animationNodeIds && featureIndex < this.numFeatures ? this.animationNodeIds[featureIndex] : 0;\n }\n\n /** @internal */\n public getPackedFeature(featureIndex: number, result: PackedFeature): PackedFeature {\n assert(featureIndex < this.numFeatures);\n\n const index32 = 3 * featureIndex;\n result.elementId.lower = this.data[index32];\n result.elementId.upper = this.data[index32 + 1];\n\n const subCatIndexAndClass = this.data[index32 + 2];\n result.geometryClass = (subCatIndexAndClass >>> 24) & 0xff;\n\n let subCatIndex = (subCatIndexAndClass & 0x00ffffff) >>> 0;\n subCatIndex = subCatIndex * 2 + this._subCategoriesOffset;\n result.subCategoryId.lower = this.data[subCatIndex];\n result.subCategoryId.upper = this.data[subCatIndex + 1];\n\n result.animationNodeId = this.getAnimationNodeId(featureIndex);\n result.modelId.lower = this.batchModelIdPair.lower;\n result.modelId.upper = this.batchModelIdPair.upper;\n\n return result;\n }\n\n public getModelIdPair(_featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair {\n out.lower = this.batchModelIdPair.lower;\n out.upper = this.batchModelIdPair.upper;\n return out;\n }\n\n /** Returns the element ID of the Feature associated with the specified index, or undefined if the index is out of range. */\n public findElementId(featureIndex: number): Id64String | undefined {\n if (featureIndex >= this.numFeatures)\n return undefined;\n else\n return this.readId(3 * featureIndex);\n }\n\n /** Return true if this table contains exactly 1 feature. */\n public get isUniform(): boolean { return 1 === this.numFeatures; }\n\n /** If this table contains exactly 1 feature, return it. */\n public getUniform(result: ModelFeature): ModelFeature | undefined {\n return this.isUniform ? this.getFeature(0, result) : undefined;\n }\n\n public get isVolumeClassifier(): boolean { return BatchType.VolumeClassifier === this.type; }\n public get isPlanarClassifier(): boolean { return BatchType.VolumeClassifier === this.type; }\n public get isClassifier(): boolean { return this.isVolumeClassifier || this.isPlanarClassifier; }\n\n /** Unpack the features into a [[FeatureTable]]. */\n public unpack(): FeatureTable {\n const table = new FeatureTable(this.numFeatures, this.batchModelId);\n const feature = ModelFeature.create();\n for (let i = 0; i < this.numFeatures; i++) {\n this.getFeature(i, feature);\n table.insertWithIndex(new Feature(feature.elementId, feature.subCategoryId, feature.geometryClass), i);\n }\n\n return table;\n }\n\n public populateAnimationNodeIds(computeNodeId: ComputeNodeId, maxNodeId: number): void {\n assert(undefined === this.animationNodeIds);\n this.animationNodeIds = populateAnimationNodeIds(this, computeNodeId, maxNodeId);\n }\n\n public * iterator(output: PackedFeatureWithIndex): Iterator<PackedFeatureWithIndex> {\n for (let i = 0; i < this.numFeatures; i++) {\n this.getPackedFeature(i, output);\n output.index = i;\n yield output;\n }\n }\n\n public iterable(output: PackedFeatureWithIndex): Iterable<PackedFeatureWithIndex> {\n return {\n [Symbol.iterator]: () => this.iterator(output),\n };\n }\n\n private get _subCategoriesOffset(): number { return this.numFeatures * 3; }\n\n private readId(offset32: number): Id64String {\n return Id64.fromUint32Pair(this.data[offset32], this.data[offset32 + 1]);\n }\n}\n\ninterface PackedFeatureModelEntry {\n lastFeatureIndex: number;\n idLower: number;\n idUpper: number;\n}\n\nconst scratchPackedFeatureModelEntry = { lastFeatureIndex: -1, idLower: -1, idUpper: -1 };\n\n/** A table of model Ids associated with a [[MultiModelPackedFeatureTable]].\n * The feature indices in the packed feature table are grouped together by model, such that the first N features belong to model 1, the next M features to model 2, and so on.\n * The model table itself consists of one entry per model, where each entry looks like:\n * indexOfLastFeatureInModel: u32\n * modelId: u64\n * The modelId associated with a feature can therefore be derived by finding the entry in the model table with the highest indexOfLastFeatureInModel no greater than the feature index.\n * This lookup can be optimized using binary search.\n * Moreover, while iterating the feature table in sequence, the model table can be iterated in parallel so that no per-feature lookup of model Id is required.\n * @internal\n */\nexport class PackedFeatureModelTable {\n private readonly _data: Uint32Array;\n\n public constructor(data: Uint32Array) {\n this._data = data;\n assert(this._data.length % 3 === 0);\n }\n\n /** The number of models in the table. */\n public get length(): number {\n return this._data.length / 3;\n }\n\n public get byteLength(): number {\n return this._data.byteLength;\n }\n\n private getLastFeatureIndex(modelIndex: number): number {\n return this._data[modelIndex * 3];\n }\n\n public getEntry(modelIndex: number, result: PackedFeatureModelEntry): PackedFeatureModelEntry {\n if (modelIndex >= this.length) {\n result.idLower = result.idUpper = 0;\n result.lastFeatureIndex = Number.MAX_SAFE_INTEGER;\n return result;\n }\n\n const index = modelIndex * 3;\n result.lastFeatureIndex = this._data[index + 0];\n result.idLower = this._data[index + 1];\n result.idUpper = this._data[index + 2];\n return result;\n }\n\n /** Get the Id of the model associated with the specified feature, or an invalid Id if the feature is not associated with any model. */\n public getModelIdPair(featureIndex: number, result?: Id64.Uint32Pair): Id64.Uint32Pair {\n if (!result)\n result = { lower: 0, upper: 0 };\n else\n result.lower = result.upper = 0;\n\n let first = 0;\n const last = this.length;\n let count = last;\n while (count > 0) {\n const step = Math.floor(count / 2);\n const mid = first + step;\n const lastFeatureIndex = this.getLastFeatureIndex(mid);\n if (featureIndex > lastFeatureIndex) {\n first = mid + 1;\n count -= step + 1;\n } else {\n count = step;\n }\n }\n\n if (first < last) {\n result.lower = this._data[first * 3 + 1];\n result.upper = this._data[first * 3 + 2];\n }\n\n return result;\n }\n}\n\n/** A PackedFeatureTable with a PackedFeatureModelTable appended to it, capable of storing features belonging to more than one model.\n * @internal\n */\nexport class MultiModelPackedFeatureTable implements RenderFeatureTable {\n private readonly _features: PackedFeatureTable;\n private readonly _models: PackedFeatureModelTable;\n\n public constructor(features: PackedFeatureTable, models: PackedFeatureModelTable) {\n this._features = features;\n this._models = models;\n }\n\n public static create(data: Uint32Array, batchModelId: Id64String, numFeatures: number, type: BatchType, numSubCategories: number): MultiModelPackedFeatureTable {\n const modelTableOffset = 3 * numFeatures + 2 * numSubCategories;\n const featureData = data.subarray(0, modelTableOffset);\n const features = new PackedFeatureTable(featureData, batchModelId, numFeatures, type);\n\n const modelData = data.subarray(modelTableOffset);\n const models = new PackedFeatureModelTable(modelData);\n\n return new MultiModelPackedFeatureTable(features, models);\n }\n\n public get batchModelId() { return this._features.batchModelId; }\n public get batchModelIdPair() { return this._features.batchModelIdPair; }\n public get numFeatures() { return this._features.numFeatures; }\n public get type() { return this._features.type; }\n public get animationNodeIds(): UintArray | undefined { return this._features.animationNodeIds; }\n public set animationNodeIds(ids: UintArray | undefined) { this._features.animationNodeIds = ids; }\n\n public get byteLength() {\n return this._features.byteLength + this._models.byteLength;\n }\n\n public getPackedFeature(featureIndex: number, result: PackedFeature): PackedFeature {\n this._features.getPackedFeature(featureIndex, result);\n this._models.getModelIdPair(featureIndex, result.modelId);\n return result;\n }\n\n public getFeature(featureIndex: number, result: ModelFeature): ModelFeature {\n const packed = this.getPackedFeature(featureIndex, scratchPackedFeature);\n return ModelFeature.unpack(packed, result);\n }\n\n public findFeature(featureIndex: number, result: ModelFeature): ModelFeature | undefined {\n return featureIndex < this.numFeatures ? this.getFeature(featureIndex, result) : undefined;\n }\n\n public getElementIdPair(featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair {\n return this._features.getElementIdPair(featureIndex, out);\n }\n\n public getModelIdPair(featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair {\n this._models.getModelIdPair(featureIndex, out);\n return out;\n }\n\n public findElementId(featureIndex: number): Id64String | undefined {\n return this._features.findElementId(featureIndex);\n }\n\n public * iterator(output: PackedFeatureWithIndex): Iterator<PackedFeatureWithIndex> {\n // Rather than perform a binary search on the model table to find each feature's model Id, traverse the model table in parallel with the feature table.\n let modelIndex = 0;\n const modelEntry = this._models.getEntry(modelIndex, scratchPackedFeatureModelEntry);\n\n for (let featureIndex = 0; featureIndex < this.numFeatures; featureIndex++) {\n if (featureIndex > modelEntry.lastFeatureIndex)\n this._models.getEntry(++modelIndex, modelEntry);\n\n this._features.getPackedFeature(featureIndex, output);\n output.modelId.lower = modelEntry.idLower;\n output.modelId.upper = modelEntry.idUpper;\n output.index = featureIndex;\n yield output;\n }\n }\n\n public iterable(output: PackedFeatureWithIndex): Iterable<PackedFeatureWithIndex> {\n return {\n [Symbol.iterator]: () => this.iterator(output),\n };\n }\n\n public getAnimationNodeId(featureIndex: number): number {\n return this._features.getAnimationNodeId(featureIndex);\n }\n\n public populateAnimationNodeIds(computeNodeId: ComputeNodeId, maxNodeId: number): void {\n this._features.animationNodeIds = populateAnimationNodeIds(this, computeNodeId, maxNodeId);\n }\n}\n\nexport function createPackedFeature(): PackedFeature {\n const pair = { upper: 0, lower: 0 };\n return {\n modelId: { ...pair },\n elementId: { ...pair },\n subCategoryId: { ...pair },\n geometryClass: GeometryClass.Primary,\n animationNodeId: 0,\n };\n}\n\nconst scratchPackedFeature = createPackedFeature();\n\nfunction populateAnimationNodeIds(table: RenderFeatureTable, computeNodeId: ComputeNodeId, maxNodeId: number): UintArray | undefined {\n assert(maxNodeId > 0);\n\n let nodeIds;\n const outputFeature = PackedFeature.createWithIndex();\n for (const feature of table.iterable(outputFeature)) {\n const nodeId = computeNodeId(feature);\n assert(nodeId <= maxNodeId);\n if (0 !== nodeId) {\n if (!nodeIds) {\n const size = table.numFeatures;\n nodeIds = maxNodeId < 0x100 ? new Uint8Array(size) : (maxNodeId < 0x10000 ? new Uint16Array(size) : new Uint32Array(size));\n }\n\n nodeIds[feature.index] = nodeId;\n }\n }\n\n return nodeIds;\n}\n\n"]}
1
+ {"version":3,"file":"PackedFeatureTable.js","sourceRoot":"","sources":["../../../src/internal/PackedFeatureTable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwYH,kDASC;AA/YD,sDAE6B;AAC7B,kDAA2J;AAC3J,sDAAkD;AAElD;;;;GAIG;AACH,MAAa,kBAAkB;IACb,IAAI,CAAc;IAClB,YAAY,CAAa;IACzB,gBAAgB,CAAkB;IAClC,WAAW,CAAS;IACpB,UAAU,CAAU;IACpB,IAAI,CAAY;IACzB,gBAAgB,CAAa;IAEpC,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAEhE;;;OAGG;IACH,YAAmB,IAAiB,EAAE,OAAmB,EAAE,WAAmB,EAAE,IAAe,EAAE,gBAA4B;QAC3H,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,mBAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAEzC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;YACzB,KAAK,CAAC;gBACJ,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;gBACxB,MAAM;YACR,KAAK,CAAC;gBACJ,IAAI,CAAC,UAAU,GAAG,2BAAY,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,2BAAY,CAAC,MAAM,EAAE,CAAC,C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CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB,GAAG,mBAAmB,EAAE,CAAC;AAEnD,SAAS,wBAAwB,CAAC,KAAyB,EAAE,aAA4B,EAAE,SAAiB;IAC1G,IAAA,qBAAM,EAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAEtB,IAAI,OAAO,CAAC;IACZ,MAAM,aAAa,GAAG,4BAAa,CAAC,eAAe,EAAE,CAAC;IACtD,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACtC,IAAA,qBAAM,EAAC,MAAM,IAAI,SAAS,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;gBAC/B,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7H,CAAC;YAED,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Rendering\n */\n\nimport {\n assert, expectDefined, Id64, Id64String, UintArray,\n} from \"@itwin/core-bentley\";\nimport { BatchType, ComputeNodeId, Feature, FeatureTable, ModelFeature, PackedFeature, PackedFeatureWithIndex, RenderFeatureTable } from \"../FeatureTable\";\nimport { GeometryClass } from \"../GeometryParams\";\n\n/**\n * An immutable, packed representation of a [[FeatureTable]]. The features are packed into a single array of 32-bit integer values,\n * wherein each feature occupies 3 32-bit integers.\n * @internal\n */\nexport class PackedFeatureTable implements RenderFeatureTable {\n public readonly data: Uint32Array;\n public readonly batchModelId: Id64String;\n public readonly batchModelIdPair: Id64.Uint32Pair;\n public readonly numFeatures: number;\n public readonly anyDefined: boolean;\n public readonly type: BatchType;\n public animationNodeIds?: UintArray;\n\n public get byteLength(): number { return this.data.byteLength; }\n\n /** Construct a PackedFeatureTable from the packed binary data.\n * This is used internally when deserializing Tiles in iMdl format.\n * @internal\n */\n public constructor(data: Uint32Array, modelId: Id64String, numFeatures: number, type: BatchType, animationNodeIds?: UintArray) {\n this.data = data;\n this.batchModelId = modelId;\n this.batchModelIdPair = Id64.getUint32Pair(modelId);\n this.numFeatures = numFeatures;\n this.type = type;\n this.animationNodeIds = animationNodeIds;\n\n switch (this.numFeatures) {\n case 0:\n this.anyDefined = false;\n break;\n case 1:\n this.anyDefined = ModelFeature.isDefined(this.getFeature(0, ModelFeature.create()));\n break;\n default:\n this.anyDefined = true;\n break;\n }\n\n assert(this.data.length >= this._subCategoriesOffset);\n assert(undefined === this.animationNodeIds || this.animationNodeIds.length === this.numFeatures);\n }\n\n /** Create a packed feature table from a [[FeatureTable]]. */\n public static pack(featureTable: FeatureTable): PackedFeatureTable {\n // We must determine how many subcategories we have ahead of time to compute the size of the Uint32Array, as\n // the array cannot be resized after it is created.\n // We are not too worried about this as FeatureTables created on the front-end will contain few if any features; those obtained from the\n // back-end arrive within tiles already in the packed format.\n const subcategories = new Map<string, number>();\n for (const iv of featureTable.getArray()) {\n const found = subcategories.get(iv.value.subCategoryId.toString());\n if (undefined === found)\n subcategories.set(iv.value.subCategoryId, subcategories.size);\n }\n\n // We need 3 32-bit integers per feature, plus 2 32-bit integers per subcategory.\n const subCategoriesOffset = 3 * featureTable.length;\n const nUint32s = subCategoriesOffset + 2 * subcategories.size;\n const uint32s = new Uint32Array(nUint32s);\n\n for (const iv of featureTable.getArray()) {\n const feature = iv.value;\n const index = iv.index * 3;\n\n let subCategoryIndex = expectDefined(subcategories.get(feature.subCategoryId));\n assert(undefined !== subCategoryIndex); // we inserted it above...\n subCategoryIndex |= (feature.geometryClass << 24);\n\n uint32s[index + 0] = Id64.getLowerUint32(feature.elementId);\n uint32s[index + 1] = Id64.getUpperUint32(feature.elementId);\n uint32s[index + 2] = subCategoryIndex;\n }\n\n subcategories.forEach((index: number, id: string, _map) => {\n const index32 = subCategoriesOffset + 2 * index;\n uint32s[index32 + 0] = Id64.getLowerUint32(id);\n uint32s[index32 + 1] = Id64.getUpperUint32(id);\n });\n\n return new PackedFeatureTable(uint32s, featureTable.modelId, featureTable.length, featureTable.type);\n }\n\n /** Retrieve the Feature associated with the specified index. */\n public getFeature(featureIndex: number, result: ModelFeature): ModelFeature {\n const packed = this.getPackedFeature(featureIndex, scratchPackedFeature);\n return ModelFeature.unpack(packed, result, this.batchModelId);\n }\n\n /** Returns the Feature associated with the specified index, or undefined if the index is out of range. */\n public findFeature(featureIndex: number, result: ModelFeature): ModelFeature | undefined {\n return featureIndex < this.numFeatures ? this.getFeature(featureIndex, result) : undefined;\n }\n\n /** @internal */\n public getElementIdPair(featureIndex: number, out?: Id64.Uint32Pair): Id64.Uint32Pair {\n out = out ?? { lower: 0, upper: 0 };\n assert(featureIndex < this.numFeatures);\n const offset = 3 * featureIndex;\n out.lower = this.data[offset];\n out.upper = this.data[offset + 1];\n return out;\n }\n\n /** @internal */\n public getSubCategoryIdPair(featureIndex: number): Id64.Uint32Pair {\n const index = 3 * featureIndex;\n let subCatIndex = this.data[index + 2];\n subCatIndex = (subCatIndex & 0x00ffffff) >>> 0;\n subCatIndex = subCatIndex * 2 + this._subCategoriesOffset;\n return { lower: this.data[subCatIndex], upper: this.data[subCatIndex + 1] };\n }\n\n /** @internal */\n public getAnimationNodeId(featureIndex: number): number {\n return undefined !== this.animationNodeIds && featureIndex < this.numFeatures ? this.animationNodeIds[featureIndex] : 0;\n }\n\n /** @internal */\n public getPackedFeature(featureIndex: number, result: PackedFeature): PackedFeature {\n assert(featureIndex < this.numFeatures);\n\n const index32 = 3 * featureIndex;\n result.elementId.lower = this.data[index32];\n result.elementId.upper = this.data[index32 + 1];\n\n const subCatIndexAndClass = this.data[index32 + 2];\n result.geometryClass = (subCatIndexAndClass >>> 24) & 0xff;\n\n let subCatIndex = (subCatIndexAndClass & 0x00ffffff) >>> 0;\n subCatIndex = subCatIndex * 2 + this._subCategoriesOffset;\n result.subCategoryId.lower = this.data[subCatIndex];\n result.subCategoryId.upper = this.data[subCatIndex + 1];\n\n result.animationNodeId = this.getAnimationNodeId(featureIndex);\n result.modelId.lower = this.batchModelIdPair.lower;\n result.modelId.upper = this.batchModelIdPair.upper;\n\n return result;\n }\n\n public getModelIdPair(_featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair {\n out.lower = this.batchModelIdPair.lower;\n out.upper = this.batchModelIdPair.upper;\n return out;\n }\n\n /** Returns the element ID of the Feature associated with the specified index, or undefined if the index is out of range. */\n public findElementId(featureIndex: number): Id64String | undefined {\n if (featureIndex >= this.numFeatures)\n return undefined;\n else\n return this.readId(3 * featureIndex);\n }\n\n /** Return true if this table contains exactly 1 feature. */\n public get isUniform(): boolean { return 1 === this.numFeatures; }\n\n /** If this table contains exactly 1 feature, return it. */\n public getUniform(result: ModelFeature): ModelFeature | undefined {\n return this.isUniform ? this.getFeature(0, result) : undefined;\n }\n\n public get isVolumeClassifier(): boolean { return BatchType.VolumeClassifier === this.type; }\n public get isPlanarClassifier(): boolean { return BatchType.VolumeClassifier === this.type; }\n public get isClassifier(): boolean { return this.isVolumeClassifier || this.isPlanarClassifier; }\n\n /** Unpack the features into a [[FeatureTable]]. */\n public unpack(): FeatureTable {\n const table = new FeatureTable(this.numFeatures, this.batchModelId);\n const feature = ModelFeature.create();\n for (let i = 0; i < this.numFeatures; i++) {\n this.getFeature(i, feature);\n table.insertWithIndex(new Feature(feature.elementId, feature.subCategoryId, feature.geometryClass), i);\n }\n\n return table;\n }\n\n public populateAnimationNodeIds(computeNodeId: ComputeNodeId, maxNodeId: number): void {\n assert(undefined === this.animationNodeIds);\n this.animationNodeIds = populateAnimationNodeIds(this, computeNodeId, maxNodeId);\n }\n\n public * iterator(output: PackedFeatureWithIndex): Iterator<PackedFeatureWithIndex> {\n for (let i = 0; i < this.numFeatures; i++) {\n this.getPackedFeature(i, output);\n output.index = i;\n yield output;\n }\n }\n\n public iterable(output: PackedFeatureWithIndex): Iterable<PackedFeatureWithIndex> {\n return {\n [Symbol.iterator]: () => this.iterator(output),\n };\n }\n\n private get _subCategoriesOffset(): number { return this.numFeatures * 3; }\n\n private readId(offset32: number): Id64String {\n return Id64.fromUint32Pair(this.data[offset32], this.data[offset32 + 1]);\n }\n}\n\ninterface PackedFeatureModelEntry {\n lastFeatureIndex: number;\n idLower: number;\n idUpper: number;\n}\n\nconst scratchPackedFeatureModelEntry = { lastFeatureIndex: -1, idLower: -1, idUpper: -1 };\n\n/** A table of model Ids associated with a [[MultiModelPackedFeatureTable]].\n * The feature indices in the packed feature table are grouped together by model, such that the first N features belong to model 1, the next M features to model 2, and so on.\n * The model table itself consists of one entry per model, where each entry looks like:\n * indexOfLastFeatureInModel: u32\n * modelId: u64\n * The modelId associated with a feature can therefore be derived by finding the entry in the model table with the highest indexOfLastFeatureInModel no greater than the feature index.\n * This lookup can be optimized using binary search.\n * Moreover, while iterating the feature table in sequence, the model table can be iterated in parallel so that no per-feature lookup of model Id is required.\n * @internal\n */\nexport class PackedFeatureModelTable {\n private readonly _data: Uint32Array;\n\n public constructor(data: Uint32Array) {\n this._data = data;\n assert(this._data.length % 3 === 0);\n }\n\n /** The number of models in the table. */\n public get length(): number {\n return this._data.length / 3;\n }\n\n public get byteLength(): number {\n return this._data.byteLength;\n }\n\n private getLastFeatureIndex(modelIndex: number): number {\n return this._data[modelIndex * 3];\n }\n\n public getEntry(modelIndex: number, result: PackedFeatureModelEntry): PackedFeatureModelEntry {\n if (modelIndex >= this.length) {\n result.idLower = result.idUpper = 0;\n result.lastFeatureIndex = Number.MAX_SAFE_INTEGER;\n return result;\n }\n\n const index = modelIndex * 3;\n result.lastFeatureIndex = this._data[index + 0];\n result.idLower = this._data[index + 1];\n result.idUpper = this._data[index + 2];\n return result;\n }\n\n /** Get the Id of the model associated with the specified feature, or an invalid Id if the feature is not associated with any model. */\n public getModelIdPair(featureIndex: number, result?: Id64.Uint32Pair): Id64.Uint32Pair {\n if (!result)\n result = { lower: 0, upper: 0 };\n else\n result.lower = result.upper = 0;\n\n let first = 0;\n const last = this.length;\n let count = last;\n while (count > 0) {\n const step = Math.floor(count / 2);\n const mid = first + step;\n const lastFeatureIndex = this.getLastFeatureIndex(mid);\n if (featureIndex > lastFeatureIndex) {\n first = mid + 1;\n count -= step + 1;\n } else {\n count = step;\n }\n }\n\n if (first < last) {\n result.lower = this._data[first * 3 + 1];\n result.upper = this._data[first * 3 + 2];\n }\n\n return result;\n }\n}\n\n/** A PackedFeatureTable with a PackedFeatureModelTable appended to it, capable of storing features belonging to more than one model.\n * @internal\n */\nexport class MultiModelPackedFeatureTable implements RenderFeatureTable {\n private readonly _features: PackedFeatureTable;\n private readonly _models: PackedFeatureModelTable;\n\n public constructor(features: PackedFeatureTable, models: PackedFeatureModelTable) {\n this._features = features;\n this._models = models;\n }\n\n public static create(data: Uint32Array, batchModelId: Id64String, numFeatures: number, type: BatchType, numSubCategories: number): MultiModelPackedFeatureTable {\n const modelTableOffset = 3 * numFeatures + 2 * numSubCategories;\n const featureData = data.subarray(0, modelTableOffset);\n const features = new PackedFeatureTable(featureData, batchModelId, numFeatures, type);\n\n const modelData = data.subarray(modelTableOffset);\n const models = new PackedFeatureModelTable(modelData);\n\n return new MultiModelPackedFeatureTable(features, models);\n }\n\n public get batchModelId() { return this._features.batchModelId; }\n public get batchModelIdPair() { return this._features.batchModelIdPair; }\n public get numFeatures() { return this._features.numFeatures; }\n public get type() { return this._features.type; }\n public get animationNodeIds(): UintArray | undefined { return this._features.animationNodeIds; }\n public set animationNodeIds(ids: UintArray | undefined) { this._features.animationNodeIds = ids; }\n\n public get byteLength() {\n return this._features.byteLength + this._models.byteLength;\n }\n\n public getPackedFeature(featureIndex: number, result: PackedFeature): PackedFeature {\n this._features.getPackedFeature(featureIndex, result);\n this._models.getModelIdPair(featureIndex, result.modelId);\n return result;\n }\n\n public getFeature(featureIndex: number, result: ModelFeature): ModelFeature {\n const packed = this.getPackedFeature(featureIndex, scratchPackedFeature);\n return ModelFeature.unpack(packed, result);\n }\n\n public findFeature(featureIndex: number, result: ModelFeature): ModelFeature | undefined {\n return featureIndex < this.numFeatures ? this.getFeature(featureIndex, result) : undefined;\n }\n\n public getElementIdPair(featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair {\n return this._features.getElementIdPair(featureIndex, out);\n }\n\n public getModelIdPair(featureIndex: number, out: Id64.Uint32Pair): Id64.Uint32Pair {\n this._models.getModelIdPair(featureIndex, out);\n return out;\n }\n\n public findElementId(featureIndex: number): Id64String | undefined {\n return this._features.findElementId(featureIndex);\n }\n\n public * iterator(output: PackedFeatureWithIndex): Iterator<PackedFeatureWithIndex> {\n // Rather than perform a binary search on the model table to find each feature's model Id, traverse the model table in parallel with the feature table.\n let modelIndex = 0;\n const modelEntry = this._models.getEntry(modelIndex, scratchPackedFeatureModelEntry);\n\n for (let featureIndex = 0; featureIndex < this.numFeatures; featureIndex++) {\n if (featureIndex > modelEntry.lastFeatureIndex)\n this._models.getEntry(++modelIndex, modelEntry);\n\n this._features.getPackedFeature(featureIndex, output);\n output.modelId.lower = modelEntry.idLower;\n output.modelId.upper = modelEntry.idUpper;\n output.index = featureIndex;\n yield output;\n }\n }\n\n public iterable(output: PackedFeatureWithIndex): Iterable<PackedFeatureWithIndex> {\n return {\n [Symbol.iterator]: () => this.iterator(output),\n };\n }\n\n public getAnimationNodeId(featureIndex: number): number {\n return this._features.getAnimationNodeId(featureIndex);\n }\n\n public populateAnimationNodeIds(computeNodeId: ComputeNodeId, maxNodeId: number): void {\n this._features.animationNodeIds = populateAnimationNodeIds(this, computeNodeId, maxNodeId);\n }\n}\n\nexport function createPackedFeature(): PackedFeature {\n const pair = { upper: 0, lower: 0 };\n return {\n modelId: { ...pair },\n elementId: { ...pair },\n subCategoryId: { ...pair },\n geometryClass: GeometryClass.Primary,\n animationNodeId: 0,\n };\n}\n\nconst scratchPackedFeature = createPackedFeature();\n\nfunction populateAnimationNodeIds(table: RenderFeatureTable, computeNodeId: ComputeNodeId, maxNodeId: number): UintArray | undefined {\n assert(maxNodeId > 0);\n\n let nodeIds;\n const outputFeature = PackedFeature.createWithIndex();\n for (const feature of table.iterable(outputFeature)) {\n const nodeId = computeNodeId(feature);\n assert(nodeId <= maxNodeId);\n if (0 !== nodeId) {\n if (!nodeIds) {\n const size = table.numFeatures;\n nodeIds = maxNodeId < 0x100 ? new Uint8Array(size) : (maxNodeId < 0x10000 ? new Uint16Array(size) : new Uint32Array(size));\n }\n\n nodeIds[feature.index] = nodeId;\n }\n }\n\n return nodeIds;\n}\n\n"]}
@@ -1,6 +1,3 @@
1
- /** @packageDocumentation
2
- * @module RpcInterface
3
- */
4
1
  import { RpcInterface, RpcInterfaceDefinition } from "../../RpcInterface";
5
2
  import { RpcControlChannel } from "./RpcControl";
6
3
  import { RpcProtocol, RpcRequestFulfillment } from "./RpcProtocol";
@@ -1 +1 @@
1
- {"version":3,"file":"RpcConfiguration.d.ts","sourceRoot":"","sources":["../../../../src/rpc/core/RpcConfiguration.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MA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CAAC,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;IAIzF,gBAAgB;IACT,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAI5F,gBAAgB;IACT,mBAAmB,CAAC,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;CAGzF;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,gBAAgB;IACpD,UAAU,gBAAY;IACtB,QAAQ,EAAE,WAAW,CAA+B;CAC5D;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,SAAgB,WAAW,0BAAoB;CAChD;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IACvC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAa;IACzC,WAAW,EAAE,qBAAqB,GAAG,SAAS,CAAa;cAElD,IAAI;IAYpB,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;cAItC,IAAI;CAGrB"}
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RpcDirectRequest = exports.RpcDirectProtocol = exports.RpcDefaultConfiguration = exports.RpcConfiguration = exports.RpcRoutingMap = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ /** @packageDocumentation
9
+ * @module RpcInterface
10
+ */
11
+ const core_bentley_1 = require("@itwin/core-bentley");
4
12
  const RpcManager_1 = require("../../RpcManager");
5
13
  const RpcControl_1 = require("./RpcControl");
6
14
  const RpcProtocol_1 = require("./RpcProtocol");
@@ -12,7 +20,7 @@ var RpcRoutingMap;
12
20
  (function (RpcRoutingMap) {
13
21
  function create() {
14
22
  const configurations = new Map();
15
- return Object.assign((routing) => configurations.get(routing.id)(), { configurations });
23
+ return Object.assign((routing) => configurations.get((0, core_bentley_1.expectDefined)(routing).id)(), { configurations });
16
24
  }
17
25
  RpcRoutingMap.create = create;
18
26
  })(RpcRoutingMap || (exports.RpcRoutingMap = RpcRoutingMap = {}));
@@ -172,7 +180,7 @@ class RpcDirectRequest extends RpcRequest_1.RpcRequest {
172
180
  this.headers.set(name, value);
173
181
  }
174
182
  async load() {
175
- return this.fulfillment.result;
183
+ return (0, core_bentley_1.expectDefined)(this.fulfillment).result;
176
184
  }
177
185
  }
178
186
  exports.RpcDirectRequest = RpcDirectRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"RpcConfiguration.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcConfiguration.ts"],"names":[],"mappings":";;;AAQA,iDAA8C;AAC9C,6CAAiD;AAEjD,+CAAmE;AACnE,+CAAyC;AACzC,6CAA0C;AAE1C,uDAAoD;AAQpD,gBAAgB;AAChB,IAAiB,aAAa,CAK7B;AALD,WAAiB,aAAa;IAC5B,SAAgB,MAAM;QACpB,MAAM,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,OAAyB,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,OAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7G,CAAC;IAHe,oBAAM,SAGrB,CAAA;AACH,CAAC,EALgB,aAAa,6BAAb,aAAa,QAK7B;AAED;;;GAGG;AACH,MAAsB,gBAAgB;IACpC;;OAEG;IACI,MAAM,CAAC,eAAe,GAAY,KAAK,CAAC;IAE/C,iGAAiG;IAC1F,MAAM,CAAC,wBAAwB,GAAY,KAAK,CAAC;IAExD;;;OAGG;IACI,MAAM,CAAC,UAAU,GAAY,KAAK,CAAC;IAE1C;;;;OAIG;IACI,MAAM,CAAC,oBA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UAAU,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;;AAjJH,4CAkJC;AAED;;GAEG;AACH,MAAa,uBAAwB,SAAQ,gBAAgB;IACpD,UAAU,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC;IACtB,QAAQ,GAAgB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAC5D;AAHD,0DAGC;AAED;;GAEG;AACH,MAAa,iBAAkB,SAAQ,yBAAW;IAChC,WAAW,GAAG,gBAAgB,CAAC;CAChD;AAFD,8CAEC;AAED;;GAEG;AACH,MAAa,gBAAiB,SAAQ,uBAAU;IACvC,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IACzC,WAAW,GAAsC,SAAS,CAAC;IAExD,KAAK,CAAC,IAAI;QAClB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,OAAO,IAAI,OAAO,CAAS,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YACnD,IAAI,CAAC;gBACH,IAAI,CAAC,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBACxD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,sEAAsE;YACrF,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAES,SAAS,CAAC,IAAY,EAAE,KAAa;QAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAES,KAAK,CAAC,IAAI;QAClB,OAAO,IAAI,CAAC,WAAY,CAAC,MAAM,CAAC;IAClC,CAAC;CACF;AAvBD,4CAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcManager } from \"../../RpcManager\";\nimport { RpcControlChannel } from \"./RpcControl\";\nimport { SerializedRpcActivity } from \"./RpcInvocation\";\nimport { RpcProtocol, RpcRequestFulfillment } from \"./RpcProtocol\";\nimport { INSTANCE } from \"./RpcRegistry\";\nimport { RpcRequest } from \"./RpcRequest\";\nimport { RpcRequestContext } from \"./RpcRequestContext\";\nimport { RpcRoutingToken } from \"./RpcRoutingToken\";\n\n/** @internal */\nexport type RpcConfigurationSupplier = (routing?: RpcRoutingToken) => { new(): RpcConfiguration }; // eslint-disable-line @typescript-eslint/prefer-function-type\n\n/** @internal */\nexport interface RpcRoutingMap extends RpcConfigurationSupplier { configurations: Map<number, RpcConfigurationSupplier> }\n\n/** @internal */\nexport namespace RpcRoutingMap {\n export function create(): RpcRoutingMap {\n const configurations = new Map();\n return Object.assign((routing?: RpcRoutingToken) => configurations.get(routing!.id)(), { configurations });\n }\n}\n\n/** A RpcConfiguration specifies how calls on an RPC interface will be marshalled, plus other operating parameters.\n * RpcConfiguration is the base class for specific configurations.\n * @beta\n */\nexport abstract class RpcConfiguration {\n /** Whether development mode is enabled.\n * @note This parameter determines whether developer convenience features like backend stack traces are available.\n */\n public static developmentMode: boolean = false;\n\n /** Whether frontend checks that are relevant in a cloud-hosted routing scenario are disabled. */\n public static disableRoutingValidation: boolean = false;\n\n /** Whether strict mode is enabled.\n * This parameter determines system behaviors relating to strict checking:\n * - Whether an error is thrown if the type marshaling system encounters an unregistered type (only in strict mode).\n */\n public static strictMode: boolean = false;\n\n /**\n * Whether to throw an error when the IModelRpcProps in the operation parameter list differs from the token in the URL.\n * @note By default, a warning is logged and the operation is allowed to proceed.\n * @note The parameter token is always replaced by the url token (unless RpcOperationPolicy.allowTokenMismatch is set).\n */\n public static throwOnTokenMismatch = false;\n\n /** @internal Sets the configuration supplier for an RPC interface class. */\n public static assign<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, supplier: RpcConfigurationSupplier): void {\n const map = definition.prototype.configurationSupplier as RpcRoutingMap | undefined;\n if (!map || typeof (map.configurations) === \"undefined\") {\n definition.prototype.configurationSupplier = supplier;\n } else {\n map.configurations.set(RpcRoutingToken.default.id, supplier);\n }\n }\n\n /** Sets the configuration supplier for an RPC interface class for a given routing. */\n public static assignWithRouting<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, routing: RpcRoutingToken, configuration: new () => RpcConfiguration): void {\n if (!definition.prototype.configurationSupplier) {\n RpcConfiguration.assign(definition, RpcRoutingMap.create());\n }\n\n let map = definition.prototype.configurationSupplier as RpcRoutingMap;\n if (typeof (map.configurations) === \"undefined\") {\n const existing = map as RpcConfigurationSupplier;\n map = RpcRoutingMap.create();\n RpcConfiguration.assign(definition, map);\n map.configurations.set(RpcRoutingToken.default.id, existing);\n }\n\n const supplier = () => configuration;\n map.configurations.set(routing.id, supplier);\n }\n\n /** Obtains the instance of an RPC configuration class. */\n public static obtain<T extends RpcConfiguration>(configurationConstructor: new () => T): T {\n let instance = (configurationConstructor as any)[INSTANCE] as T;\n if (!instance)\n instance = (configurationConstructor as any)[INSTANCE] = new configurationConstructor();\n\n return instance;\n }\n\n /** @internal Enables passing of application-specific context with each RPC request. */\n public static requestContext: RpcRequestContext = {\n getId: (_request: RpcRequest): string => \"\",\n serialize: async (request: RpcRequest): Promise<SerializedRpcActivity> => ({\n id: request.id,\n applicationId: \"\",\n applicationVersion: \"\",\n sessionId: \"\",\n authorization: \"\",\n }),\n };\n\n /** @internal */\n public attached: RpcInterfaceDefinition[] = [];\n\n /** The protocol of the configuration.\n * @internal\n */\n public abstract readonly protocol: RpcProtocol;\n\n /** The RPC interfaces managed by the configuration. */\n public abstract readonly interfaces: () => RpcInterfaceDefinition[];\n\n /** @internal */\n public allowAttachedInterfaces: boolean = true;\n\n /** @internal */\n public get attachedInterfaces(): ReadonlyArray<RpcInterfaceDefinition> { return this.attached; }\n\n /** The target interval (in milliseconds) between connection attempts for pending RPC operation requests. */\n public pendingOperationRetryInterval = 10000;\n\n /** The maximum number of transient faults permitted before request failure. */\n public transientFaultLimit = 4;\n\n /** @internal */\n public readonly routing: RpcRoutingToken = RpcRoutingToken.default;\n\n /** The control channel for the configuration.\n * @internal\n */\n public readonly controlChannel = RpcControlChannel.obtain(this);\n\n /** @internal */\n public attach<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): void {\n if (!this.allowAttachedInterfaces) {\n return;\n }\n\n if (this.interfaces().indexOf(definition) !== -1 || this.attached.indexOf(definition) !== -1) {\n return;\n }\n\n this.attached.push(definition);\n RpcConfiguration.assign(definition, () => this.constructor as any);\n RpcManager.initializeInterface(definition);\n }\n\n /** Initializes the RPC interfaces managed by the configuration. */\n public static initializeInterfaces(configuration: RpcConfiguration) {\n configuration.interfaces().forEach((definition) => RpcManager.initializeInterface(definition));\n }\n\n /** @internal */\n public static supply(definition: RpcInterface): RpcConfiguration {\n return RpcConfiguration.obtain(definition.configurationSupplier ? definition.configurationSupplier(definition.routing) : RpcDefaultConfiguration);\n }\n\n /** @internal */\n public onRpcClientInitialized(definition: RpcInterfaceDefinition, client: RpcInterface): void {\n this.protocol.onRpcClientInitialized(definition, client);\n }\n\n /** @internal */\n public onRpcImplInitialized(definition: RpcInterfaceDefinition, impl: RpcInterface): void {\n this.protocol.onRpcImplInitialized(definition, impl);\n }\n\n /** @internal */\n public onRpcClientTerminated(definition: RpcInterfaceDefinition, client: RpcInterface): void {\n this.protocol.onRpcClientTerminated(definition, client);\n }\n\n /** @internal */\n public onRpcImplTerminated(definition: RpcInterfaceDefinition, impl: RpcInterface): void {\n this.protocol.onRpcImplTerminated(definition, impl);\n }\n}\n\n/** A default configuration that can be used for basic testing within a library.\n * @internal\n */\nexport class RpcDefaultConfiguration extends RpcConfiguration {\n public interfaces = () => [];\n public protocol: RpcProtocol = new RpcDirectProtocol(this);\n}\n\n/** A default protocol that can be used for basic testing within a library.\n * @internal\n */\nexport class RpcDirectProtocol extends RpcProtocol {\n public readonly requestType = RpcDirectRequest;\n}\n\n/** A default request type that can be used for basic testing within a library.\n * @internal\n */\nexport class RpcDirectRequest extends RpcRequest {\n public headers: Map<string, string> = new Map();\n public fulfillment: RpcRequestFulfillment | undefined = undefined;\n\n protected async send() {\n const request = await this.protocol.serialize(this);\n return new Promise<number>(async (resolve, reject) => {\n try {\n this.fulfillment = await this.protocol.fulfill(request);\n resolve(this.fulfillment.status);\n } catch (err) {\n reject(err); // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors\n }\n });\n }\n\n protected setHeader(name: string, value: string): void {\n this.headers.set(name, value);\n }\n\n protected async load() {\n return this.fulfillment!.result;\n }\n}\n"]}
1
+ {"version":3,"file":"RpcConfiguration.js","sourceRoot":"","sources":["../../../../src/rpc/core/RpcConfiguration.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAoD;AAEpD,iDAA8C;AAC9C,6CAAiD;AAEjD,+CAAmE;AACnE,+CAAyC;AACzC,6CAA0C;AAE1C,uDAAoD;AAQpD,gBAAgB;AAChB,IAAiB,aAAa,CAK7B;AALD,WAAiB,aAAa;IAC5B,SAAgB,MAAM;QACpB,MAAM,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,OAAyB,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,IAAA,4BAAa,EAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;IAC3H,CAAC;IAHe,oBAAM,SAGrB,CAAA;AACH,CAAC,EALgB,aAAa,6BAAb,aAAa,QAK7B;AAED;;;GAGG;AACH,MAAsB,gBAAgB;IACpC;;OAEG;IACI,MAAM,CAAC,eAAe,GAAY,KAAK,CAAC;IAE/C,iGAAiG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AAO,IAAA,4BAAa,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IAChD,CAAC;CACF;AAvBD,4CAuBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\nimport { expectDefined } from \"@itwin/core-bentley\";\nimport { RpcInterface, RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcManager } from \"../../RpcManager\";\nimport { RpcControlChannel } from \"./RpcControl\";\nimport { SerializedRpcActivity } from \"./RpcInvocation\";\nimport { RpcProtocol, RpcRequestFulfillment } from \"./RpcProtocol\";\nimport { INSTANCE } from \"./RpcRegistry\";\nimport { RpcRequest } from \"./RpcRequest\";\nimport { RpcRequestContext } from \"./RpcRequestContext\";\nimport { RpcRoutingToken } from \"./RpcRoutingToken\";\n\n/** @internal */\nexport type RpcConfigurationSupplier = (routing?: RpcRoutingToken) => { new(): RpcConfiguration }; // eslint-disable-line @typescript-eslint/prefer-function-type\n\n/** @internal */\nexport interface RpcRoutingMap extends RpcConfigurationSupplier { configurations: Map<number, RpcConfigurationSupplier> }\n\n/** @internal */\nexport namespace RpcRoutingMap {\n export function create(): RpcRoutingMap {\n const configurations = new Map();\n return Object.assign((routing?: RpcRoutingToken) => configurations.get(expectDefined(routing).id)(), { configurations });\n }\n}\n\n/** A RpcConfiguration specifies how calls on an RPC interface will be marshalled, plus other operating parameters.\n * RpcConfiguration is the base class for specific configurations.\n * @beta\n */\nexport abstract class RpcConfiguration {\n /** Whether development mode is enabled.\n * @note This parameter determines whether developer convenience features like backend stack traces are available.\n */\n public static developmentMode: boolean = false;\n\n /** Whether frontend checks that are relevant in a cloud-hosted routing scenario are disabled. */\n public static disableRoutingValidation: boolean = false;\n\n /** Whether strict mode is enabled.\n * This parameter determines system behaviors relating to strict checking:\n * - Whether an error is thrown if the type marshaling system encounters an unregistered type (only in strict mode).\n */\n public static strictMode: boolean = false;\n\n /**\n * Whether to throw an error when the IModelRpcProps in the operation parameter list differs from the token in the URL.\n * @note By default, a warning is logged and the operation is allowed to proceed.\n * @note The parameter token is always replaced by the url token (unless RpcOperationPolicy.allowTokenMismatch is set).\n */\n public static throwOnTokenMismatch = false;\n\n /** @internal Sets the configuration supplier for an RPC interface class. */\n public static assign<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, supplier: RpcConfigurationSupplier): void {\n const map = definition.prototype.configurationSupplier as RpcRoutingMap | undefined;\n if (!map || typeof (map.configurations) === \"undefined\") {\n definition.prototype.configurationSupplier = supplier;\n } else {\n map.configurations.set(RpcRoutingToken.default.id, supplier);\n }\n }\n\n /** Sets the configuration supplier for an RPC interface class for a given routing. */\n public static assignWithRouting<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>, routing: RpcRoutingToken, configuration: new () => RpcConfiguration): void {\n if (!definition.prototype.configurationSupplier) {\n RpcConfiguration.assign(definition, RpcRoutingMap.create());\n }\n\n let map = definition.prototype.configurationSupplier as RpcRoutingMap;\n if (typeof (map.configurations) === \"undefined\") {\n const existing = map as RpcConfigurationSupplier;\n map = RpcRoutingMap.create();\n RpcConfiguration.assign(definition, map);\n map.configurations.set(RpcRoutingToken.default.id, existing);\n }\n\n const supplier = () => configuration;\n map.configurations.set(routing.id, supplier);\n }\n\n /** Obtains the instance of an RPC configuration class. */\n public static obtain<T extends RpcConfiguration>(configurationConstructor: new () => T): T {\n let instance = (configurationConstructor as any)[INSTANCE] as T;\n if (!instance)\n instance = (configurationConstructor as any)[INSTANCE] = new configurationConstructor();\n\n return instance;\n }\n\n /** @internal Enables passing of application-specific context with each RPC request. */\n public static requestContext: RpcRequestContext = {\n getId: (_request: RpcRequest): string => \"\",\n serialize: async (request: RpcRequest): Promise<SerializedRpcActivity> => ({\n id: request.id,\n applicationId: \"\",\n applicationVersion: \"\",\n sessionId: \"\",\n authorization: \"\",\n }),\n };\n\n /** @internal */\n public attached: RpcInterfaceDefinition[] = [];\n\n /** The protocol of the configuration.\n * @internal\n */\n public abstract readonly protocol: RpcProtocol;\n\n /** The RPC interfaces managed by the configuration. */\n public abstract readonly interfaces: () => RpcInterfaceDefinition[];\n\n /** @internal */\n public allowAttachedInterfaces: boolean = true;\n\n /** @internal */\n public get attachedInterfaces(): ReadonlyArray<RpcInterfaceDefinition> { return this.attached; }\n\n /** The target interval (in milliseconds) between connection attempts for pending RPC operation requests. */\n public pendingOperationRetryInterval = 10000;\n\n /** The maximum number of transient faults permitted before request failure. */\n public transientFaultLimit = 4;\n\n /** @internal */\n public readonly routing: RpcRoutingToken = RpcRoutingToken.default;\n\n /** The control channel for the configuration.\n * @internal\n */\n public readonly controlChannel = RpcControlChannel.obtain(this);\n\n /** @internal */\n public attach<T extends RpcInterface>(definition: RpcInterfaceDefinition<T>): void {\n if (!this.allowAttachedInterfaces) {\n return;\n }\n\n if (this.interfaces().indexOf(definition) !== -1 || this.attached.indexOf(definition) !== -1) {\n return;\n }\n\n this.attached.push(definition);\n RpcConfiguration.assign(definition, () => this.constructor as any);\n RpcManager.initializeInterface(definition);\n }\n\n /** Initializes the RPC interfaces managed by the configuration. */\n public static initializeInterfaces(configuration: RpcConfiguration) {\n configuration.interfaces().forEach((definition) => RpcManager.initializeInterface(definition));\n }\n\n /** @internal */\n public static supply(definition: RpcInterface): RpcConfiguration {\n return RpcConfiguration.obtain(definition.configurationSupplier ? definition.configurationSupplier(definition.routing) : RpcDefaultConfiguration);\n }\n\n /** @internal */\n public onRpcClientInitialized(definition: RpcInterfaceDefinition, client: RpcInterface): void {\n this.protocol.onRpcClientInitialized(definition, client);\n }\n\n /** @internal */\n public onRpcImplInitialized(definition: RpcInterfaceDefinition, impl: RpcInterface): void {\n this.protocol.onRpcImplInitialized(definition, impl);\n }\n\n /** @internal */\n public onRpcClientTerminated(definition: RpcInterfaceDefinition, client: RpcInterface): void {\n this.protocol.onRpcClientTerminated(definition, client);\n }\n\n /** @internal */\n public onRpcImplTerminated(definition: RpcInterfaceDefinition, impl: RpcInterface): void {\n this.protocol.onRpcImplTerminated(definition, impl);\n }\n}\n\n/** A default configuration that can be used for basic testing within a library.\n * @internal\n */\nexport class RpcDefaultConfiguration extends RpcConfiguration {\n public interfaces = () => [];\n public protocol: RpcProtocol = new RpcDirectProtocol(this);\n}\n\n/** A default protocol that can be used for basic testing within a library.\n * @internal\n */\nexport class RpcDirectProtocol extends RpcProtocol {\n public readonly requestType = RpcDirectRequest;\n}\n\n/** A default request type that can be used for basic testing within a library.\n * @internal\n */\nexport class RpcDirectRequest extends RpcRequest {\n public headers: Map<string, string> = new Map();\n public fulfillment: RpcRequestFulfillment | undefined = undefined;\n\n protected async send() {\n const request = await this.protocol.serialize(this);\n return new Promise<number>(async (resolve, reject) => {\n try {\n this.fulfillment = await this.protocol.fulfill(request);\n resolve(this.fulfillment.status);\n } catch (err) {\n reject(err); // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors\n }\n });\n }\n\n protected setHeader(name: string, value: string): void {\n this.headers.set(name, value);\n }\n\n protected async load() {\n return expectDefined(this.fulfillment).result;\n }\n}\n"]}
@@ -85,7 +85,7 @@ class BentleyCloudRpcProtocol extends WebAppRpcProtocol_1.WebAppRpcProtocol {
85
85
  }
86
86
  }
87
87
  iTwinId = encodeURIComponent(token.iTwinId || "");
88
- iModelId = encodeURIComponent(token.iModelId);
88
+ iModelId = encodeURIComponent(token.iModelId || "");
89
89
  routeChangesetId = token.changeset?.id || "0";
90
90
  appMode = AppMode.MilestoneReview;
91
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BentleyCloudRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAChD,+DAA4D;AAC5D,uDAAoD;AAIpD,2DAAwD;AAGxD,IAAK,OAEJ;AAFD,WAAK,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,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC5E,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;SACjF,CAAC;IACJ,CAAC;CACF;AApID,0DAoIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"../../IModel\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\nimport { RpcOperation } from \"../core/RpcOperation\";\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { OpenAPIParameter } from \"./OpenAPI\";\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\n\nenum AppMode {\n MilestoneReview = \"1\",\n}\n\n/** An http protocol for Bentley cloud RPC interface deployments.\n * @internal\n */\nexport abstract class BentleyCloudRpcProtocol extends WebAppRpcProtocol {\n public override checkToken = true;\n\n /** The name of various HTTP request headers based on client's request context */\n public override serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\n /** The name of the HTTP request id header. */\n id: \"X-Correlation-Id\",\n\n /** The name of the HTTP application id header. */\n applicationId: \"X-Application-Id\",\n\n /** The name of the HTTP application version header. */\n applicationVersion: \"X-Application-Version\",\n\n /** The name of the HTTP session id header. */\n sessionId: \"X-Session-Id\",\n\n /** The name of the HTTP authorization header. */\n authorization: \"Authorization\",\n };\n\n /** The name of the RPC protocol version header. */\n public override protocolVersionHeaderName = \"X-Protocol-Version\";\n\n /** Returns the operation specified by an OpenAPI-compatible URI path. */\n public override getOperationFromPath(path: string): SerializedRpcOperation {\n const url = new URL(path, \"https://localhost/\");\n const components = url.pathname.split(\"/\").filter((x) => x); // filter out empty segments\n\n const operationComponent = components.slice(-1)[0];\n const encodedRequest = url.searchParams.get(\"parameters\") || \"\";\n\n // The encodedRequest should be base64 - fail now if any other characters detected.\n if (/[^a-zA-Z0-9=+\\/$]/.test(encodedRequest))\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Malformed URL parameters detected.`);\n\n const firstHyphen = operationComponent.indexOf(\"-\");\n const lastHyphen = operationComponent.lastIndexOf(\"-\");\n const interfaceDefinition = operationComponent.slice(0, firstHyphen);\n const interfaceVersion = operationComponent.slice(firstHyphen + 1, lastHyphen);\n const operationName = operationComponent.slice(lastHyphen + 1);\n\n return { interfaceDefinition, operationName, interfaceVersion, encodedRequest };\n }\n\n /** Supplies the OpenAPI-compatible URI path for an RPC operation. */\n public override supplyPathForOperation(operation: RpcOperation, request: RpcRequest | undefined) {\n const prefix = this.pathPrefix;\n const appTitle = this.info.title;\n const appVersion = this.info.version;\n const operationId = `${operation.interfaceDefinition.interfaceName}-${operation.interfaceVersion}-${operation.operationName}`;\n\n let appMode: string = \"\";\n let iTwinId: string = \"\";\n let iModelId: string = \"\";\n let routeChangesetId: string | undefined;\n /* Note: The changesetId field is omitted in the route in the case of ReadWrite connections since the connection is generally expected to be at the\n * latest version and not some specific changeset. Also, for the first version (before any changesets), the changesetId in the route is arbitrarily\n * set to \"0\" instead of an empty string, since the latter is more un-intuitive for a route. However, in all other use cases, including the changesetId\n * held by the IModelRpcProps itself, the changesetId of \"\" (i.e., empty string) signifies the first version - this is more intuitive and retains\n * compatibility with the majority of use cases. */\n\n if (request === undefined) {\n appMode = \"{modeId}\";\n iTwinId = \"{iTwinId}\";\n iModelId = \"{iModelId}\";\n routeChangesetId = \"{changeSetId}\";\n } else {\n let token = operation.policy.token(request) || RpcOperation.fallbackToken;\n\n if (!token || !token.iModelId) {\n if (RpcConfiguration.disableRoutingValidation) {\n token = { key: \"\" };\n } else {\n throw new IModelError(BentleyStatus.ERROR, \"Invalid iModelToken for RPC operation request\");\n }\n }\n\n iTwinId = encodeURIComponent(token.iTwinId || \"\");\n iModelId = encodeURIComponent(token.iModelId!);\n\n routeChangesetId = token.changeset?.id || \"0\";\n appMode = AppMode.MilestoneReview;\n }\n\n return `${prefix}/${appTitle}/${appVersion}/mode/${appMode}/context/${iTwinId}/imodel/${iModelId}${!!routeChangesetId ? `/changeset/${routeChangesetId}` : \"\"}/${operationId}`;\n }\n\n /**\n * Inflates the IModelRpcProps from the URL path for each request on the backend.\n * @note This function updates the IModelRpcProps value supplied in the request body.\n */\n public override inflateToken(tokenFromBody: IModelRpcProps, request: SerializedRpcRequest): IModelRpcProps {\n const urlPathComponents = request.path.split(\"/\");\n\n let iModelId = tokenFromBody.iModelId;\n let iTwinId = tokenFromBody.iTwinId;\n const changeset = { id: tokenFromBody.changeset?.id ?? \"0\", index: tokenFromBody.changeset?.index };\n\n for (let i = 0; i <= urlPathComponents.length; ++i) {\n const key = urlPathComponents[i];\n const value = urlPathComponents[i + 1];\n if (key === \"mode\") {\n ++i;\n } else if (key === \"context\") {\n iTwinId = value;\n ++i;\n } else if (key === \"imodel\") {\n iModelId = value;\n ++i;\n } else if (key === \"changeset\") {\n changeset.id = (value === \"0\") ? \"\" : value;\n ++i;\n }\n }\n\n // Overwrite the key if it includes a : because its most likely a guid. We know what it should be based off of the url.\n // Leave it alone if its a non guid key.\n return { key: tokenFromBody.key === undefined || tokenFromBody.key.includes(\":\") ? `${iModelId}:${changeset.id}` : tokenFromBody.key, iTwinId, iModelId, changeset };\n }\n\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\n * @internal\n */\n public supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[] {\n return [\n { name: \"modeId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"iTwinId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"iModelId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"changeSetId\", in: \"path\", required: false, schema: { type: \"string\" } },\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"BentleyCloudRpcProtocol.js","sourceRoot":"","sources":["../../../../src/rpc/web/BentleyCloudRpcProtocol.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AAEpD,mDAAgD;AAChD,+DAA4D;AAC5D,uDAAoD;AAIpD,2DAAwD;AAGxD,IAAK,OAEJ;AAFD,WAAK,OAAO;IACV,gCAAqB,CAAA;AACvB,CAAC,EAFI,OAAO,KAAP,OAAO,QAEX;AAED;;GAEG;AACH,MAAsB,uBAAwB,SAAQ,qCAAiB;IACrD,UAAU,GAAG,IAAI,CAAC;IAElC,iFAAiF;IACjE,yCAAyC,GAA0B;QACjF,8CAA8C;QAC9C,EAAE,EAAE,kBAAkB;QAEtB,kDAAkD;QAClD,aAAa,EAAE,kBAAkB;QAEjC,uDAAuD;QACvD,kBAAkB,EAAE,uBAAuB;QAE3C,8CAA8C;QAC9C,SAAS,EAAE,cAAc;QAEzB,iDAAiD;QACjD,aAAa,EAAE,eAAe;KAC/B,CAAC;IAEF,mDAAmD;IACnC,yBAAyB,GAAG,oBAAoB,CAAC;IAEjE,yEAAyE;IACzD,oBAAoB,CAAC,IAAY;QAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,4BAA4B;QAEzF,MAAM,kBAAkB,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,MAAM,cAAc,GAAG,GAAG,CAAC,YAAY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;;OAEG;IACI,gCAAgC,CAAC,UAAwB;QAC9D,OAAO;YACL,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC1E,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC3E,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC5E,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;SACjF,CAAC;IACJ,CAAC;CACF;AApID,0DAoIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelRpcProps } from \"../../IModel\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcConfiguration } from \"../core/RpcConfiguration\";\nimport { RpcOperation } from \"../core/RpcOperation\";\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { OpenAPIParameter } from \"./OpenAPI\";\nimport { WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\nimport { SerializedRpcActivity } from \"../core/RpcInvocation\";\n\nenum AppMode {\n MilestoneReview = \"1\",\n}\n\n/** An http protocol for Bentley cloud RPC interface deployments.\n * @internal\n */\nexport abstract class BentleyCloudRpcProtocol extends WebAppRpcProtocol {\n public override checkToken = true;\n\n /** The name of various HTTP request headers based on client's request context */\n public override serializedClientRequestContextHeaderNames: SerializedRpcActivity = {\n /** The name of the HTTP request id header. */\n id: \"X-Correlation-Id\",\n\n /** The name of the HTTP application id header. */\n applicationId: \"X-Application-Id\",\n\n /** The name of the HTTP application version header. */\n applicationVersion: \"X-Application-Version\",\n\n /** The name of the HTTP session id header. */\n sessionId: \"X-Session-Id\",\n\n /** The name of the HTTP authorization header. */\n authorization: \"Authorization\",\n };\n\n /** The name of the RPC protocol version header. */\n public override protocolVersionHeaderName = \"X-Protocol-Version\";\n\n /** Returns the operation specified by an OpenAPI-compatible URI path. */\n public override getOperationFromPath(path: string): SerializedRpcOperation {\n const url = new URL(path, \"https://localhost/\");\n const components = url.pathname.split(\"/\").filter((x) => x); // filter out empty segments\n\n const operationComponent = components.slice(-1)[0];\n const encodedRequest = url.searchParams.get(\"parameters\") || \"\";\n\n // The encodedRequest should be base64 - fail now if any other characters detected.\n if (/[^a-zA-Z0-9=+\\/$]/.test(encodedRequest))\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Malformed URL parameters detected.`);\n\n const firstHyphen = operationComponent.indexOf(\"-\");\n const lastHyphen = operationComponent.lastIndexOf(\"-\");\n const interfaceDefinition = operationComponent.slice(0, firstHyphen);\n const interfaceVersion = operationComponent.slice(firstHyphen + 1, lastHyphen);\n const operationName = operationComponent.slice(lastHyphen + 1);\n\n return { interfaceDefinition, operationName, interfaceVersion, encodedRequest };\n }\n\n /** Supplies the OpenAPI-compatible URI path for an RPC operation. */\n public override supplyPathForOperation(operation: RpcOperation, request: RpcRequest | undefined) {\n const prefix = this.pathPrefix;\n const appTitle = this.info.title;\n const appVersion = this.info.version;\n const operationId = `${operation.interfaceDefinition.interfaceName}-${operation.interfaceVersion}-${operation.operationName}`;\n\n let appMode: string = \"\";\n let iTwinId: string = \"\";\n let iModelId: string = \"\";\n let routeChangesetId: string | undefined;\n /* Note: The changesetId field is omitted in the route in the case of ReadWrite connections since the connection is generally expected to be at the\n * latest version and not some specific changeset. Also, for the first version (before any changesets), the changesetId in the route is arbitrarily\n * set to \"0\" instead of an empty string, since the latter is more un-intuitive for a route. However, in all other use cases, including the changesetId\n * held by the IModelRpcProps itself, the changesetId of \"\" (i.e., empty string) signifies the first version - this is more intuitive and retains\n * compatibility with the majority of use cases. */\n\n if (request === undefined) {\n appMode = \"{modeId}\";\n iTwinId = \"{iTwinId}\";\n iModelId = \"{iModelId}\";\n routeChangesetId = \"{changeSetId}\";\n } else {\n let token = operation.policy.token(request) || RpcOperation.fallbackToken;\n\n if (!token || !token.iModelId) {\n if (RpcConfiguration.disableRoutingValidation) {\n token = { key: \"\" };\n } else {\n throw new IModelError(BentleyStatus.ERROR, \"Invalid iModelToken for RPC operation request\");\n }\n }\n\n iTwinId = encodeURIComponent(token.iTwinId || \"\");\n iModelId = encodeURIComponent(token.iModelId || \"\");\n\n routeChangesetId = token.changeset?.id || \"0\";\n appMode = AppMode.MilestoneReview;\n }\n\n return `${prefix}/${appTitle}/${appVersion}/mode/${appMode}/context/${iTwinId}/imodel/${iModelId}${!!routeChangesetId ? `/changeset/${routeChangesetId}` : \"\"}/${operationId}`;\n }\n\n /**\n * Inflates the IModelRpcProps from the URL path for each request on the backend.\n * @note This function updates the IModelRpcProps value supplied in the request body.\n */\n public override inflateToken(tokenFromBody: IModelRpcProps, request: SerializedRpcRequest): IModelRpcProps {\n const urlPathComponents = request.path.split(\"/\");\n\n let iModelId = tokenFromBody.iModelId;\n let iTwinId = tokenFromBody.iTwinId;\n const changeset = { id: tokenFromBody.changeset?.id ?? \"0\", index: tokenFromBody.changeset?.index };\n\n for (let i = 0; i <= urlPathComponents.length; ++i) {\n const key = urlPathComponents[i];\n const value = urlPathComponents[i + 1];\n if (key === \"mode\") {\n ++i;\n } else if (key === \"context\") {\n iTwinId = value;\n ++i;\n } else if (key === \"imodel\") {\n iModelId = value;\n ++i;\n } else if (key === \"changeset\") {\n changeset.id = (value === \"0\") ? \"\" : value;\n ++i;\n }\n }\n\n // Overwrite the key if it includes a : because its most likely a guid. We know what it should be based off of the url.\n // Leave it alone if its a non guid key.\n return { key: tokenFromBody.key === undefined || tokenFromBody.key.includes(\":\") ? `${iModelId}:${changeset.id}` : tokenFromBody.key, iTwinId, iModelId, changeset };\n }\n\n /** Returns the OpenAPI-compatible URI path parameters for an RPC operation.\n * @internal\n */\n public supplyPathParametersForOperation(_operation: RpcOperation): OpenAPIParameter[] {\n return [\n { name: \"modeId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"iTwinId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"iModelId\", in: \"path\", required: true, schema: { type: \"string\" } },\n { name: \"changeSetId\", in: \"path\", required: false, schema: { type: \"string\" } },\n ];\n }\n}\n"]}
@@ -131,7 +131,7 @@ class WebAppRpcRequest extends RpcRequest_1.RpcRequest {
131
131
  resolve(await this.loadBinary(response));
132
132
  }
133
133
  else if (responseType === RpcConstants_1.RpcContentType.Multipart) {
134
- resolve(await this.loadMultipart(response, contentType));
134
+ resolve(await this.loadMultipart(response, (0, core_bentley_1.expectNotNull)(contentType)));
135
135
  }
136
136
  else {
137
137
  resolve(await this.loadText(response));
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoD;AACpD,mDAAiF;AAEjF,uDAA2F;AAC3F,yDAAmF;AAEnF,mDAAgD;AAChD,uEAAoE;AACpE,iDAA8C;AAC9C,2DAA+F;AAQ/F;;GAEG;AACH,MAAa,gBAAiB,SAAQ,uBAAU;IACtC,QAAQ,GAAY,KAAK,CAAC;IAC1B,QAAQ,GAAgB,EAAE,CAAC;IAC3B,WAAW,GAAW,EAAE,CAAC;IACjC,IAAY,QAAQ,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC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CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,OAAO,GAAG;QACtB,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,QAA8B,EAAE,YAAmC,EAAE,IAAuB,EAAE,IAAwB,EAAiB,EAAE;YAC1L,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,IAAuB,EAAiC,EAAE;YAC3G,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC;;AAxPJ,4CAyPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus } from \"@itwin/core-bentley\";\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\nimport { RpcInterface } from \"../../RpcInterface\";\nimport { RpcContentType, RpcProtocolEvent, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\nimport { RpcRequestFulfillment, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\nimport { RpcMultipart } from \"./RpcMultipart\";\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\ndeclare const location: any;\n\n/** @internal */\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\n\n/** A web application RPC request.\n * @internal\n */\nexport class WebAppRpcRequest extends RpcRequest {\n private _loading: boolean = false;\n private _request: RequestInit = {};\n private _pathSuffix: string = \"\";\n private get _headers() { return this._request.headers as { [key: string]: string }; }\n\n /** The maximum size permitted for an encoded component in a URL.\n * Note that some backends limit the total cumulative request size. Our current node backends accept requests with a max size of 16 kb.\n * In addition to the url size, an authorization header may also add considerably to the request size.\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\n */\n public static maxUrlComponentSize = 1024 * 8;\n\n /** The HTTP method for this request. */\n public override method: HttpMethod_T;\n\n /** Convenience access to the protocol of this request. */\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\n\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\n public metadata = { status: 0, message: \"\" };\n\n /** Parses a request. */\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\n return this.backend.parseRequest(protocol, req);\n }\n\n /** Sends the response for a web request. */\n public static async sendResponse(\n protocol: WebAppRpcProtocol,\n request: SerializedRpcRequest,\n fulfillment: RpcRequestFulfillment,\n req: HttpServerRequest,\n res: HttpServerResponse,\n ): Promise<void> {\n return this.backend.sendResponse(protocol, request, fulfillment, req, res);\n }\n\n /** Determines the most efficient transport type for an RPC value. */\n public static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\n return RpcContentType.Binary;\n } else if (value.data.length > 0) {\n return RpcContentType.Multipart;\n } else if (value.stream) {\n return RpcContentType.Stream;\n } else {\n return RpcContentType.Text;\n }\n }\n\n /** Constructs a web application request. */\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\n super(client, operation, parameters);\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\n this.method = \"head\";\n this._request.headers = {};\n }\n\n /** Sets request header values. */\n protected setHeader(name: string, value: string): void {\n this._headers[name] = value;\n }\n\n /** Sends the request. */\n protected async send(): Promise<number> {\n this._loading = true;\n await this.setupTransport();\n\n return new Promise<number>(async (resolve, reject) => {\n try {\n resolve(await this.performFetch());\n } catch (reason) {\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\n }\n });\n }\n\n protected override computeRetryAfter(attempts: number): number {\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\n if (retryAfter) {\n this.resetTransientFaultCount();\n\n const r = Number(retryAfter);\n if (Number.isFinite(r)) {\n return r * 1000;\n }\n\n const d = Date.parse(retryAfter);\n if (!Number.isNaN(d)) {\n return d - Date.now();\n }\n } else {\n this.recordTransientFault();\n }\n\n return super.computeRetryAfter(attempts);\n }\n\n protected override handleUnknownResponse(code: number) {\n if (this.protocol.isTimeout(code)) {\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\n } else {\n this.reject(new ServerError(code, \"Unknown server response code.\"));\n }\n }\n\n protected async load(): Promise<RpcSerializedValue> {\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\n try {\n if (!this._loading)\n return;\n\n const response = this._response;\n if (!response) {\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\n return;\n }\n\n if (this.protocol.protocolVersionHeaderName) {\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\n if (version) {\n this.responseProtocolVersion = parseInt(version, 10);\n }\n }\n\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\n\n if (responseType === RpcContentType.Binary) {\n resolve(await this.loadBinary(response));\n } else if (responseType === RpcContentType.Multipart) {\n resolve(await this.loadMultipart(response, contentType!));\n } else {\n resolve(await this.loadText(response));\n }\n\n this._loading = false;\n this.setLastUpdatedTime();\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\n } catch (reason) {\n if (!this._loading)\n return;\n\n this._loading = false;\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\n }\n });\n }\n\n /** Override to supply an alternate fetch function. */\n protected supplyFetch(): typeof fetch {\n return fetch;\n }\n\n /** Override to supply an alternate Request function. */\n protected supplyRequest(): typeof Request {\n return Request;\n }\n\n private async performFetch(): Promise<number> {\n const requestClass = this.supplyRequest();\n const fetchFunction = this.supplyFetch();\n\n const path = new URL(this.path, typeof location !== \"undefined\" ? location.origin : undefined);\n if (this._pathSuffix) {\n const params = new URLSearchParams();\n params.set(\"parameters\", this._pathSuffix);\n path.search = `?${params.toString()}`;\n }\n\n const request = new requestClass(path.toString(), this._request);\n const response = await fetchFunction(request);\n this._response = response;\n this.metadata.status = response.status;\n return response.status;\n }\n\n private async loadText(response: Response) {\n const value = await response.text();\n this.metadata.message = value;\n return RpcSerializedValue.create(value);\n }\n\n private async loadBinary(response: Response) {\n const value = new Uint8Array(await response.arrayBuffer());\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\n return RpcSerializedValue.create(objects, [value]);\n }\n\n private async loadMultipart(response: Response, contentType: string) {\n const data = await response.arrayBuffer();\n const value = new RpcMultipartParser(contentType, new Uint8Array(data)).parse();\n return value;\n }\n\n private async setupTransport(): Promise<void> {\n const parameters = (await this.protocol.serialize(this)).parameters;\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\n\n if (transportType === RpcContentType.Binary) {\n this.setupBinaryTransport(parameters);\n } else if (transportType === RpcContentType.Multipart) {\n this.setupMultipartTransport(parameters);\n } else {\n this.setupTextTransport(parameters);\n }\n }\n\n private setupBinaryTransport(parameters: RpcSerializedValue) {\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\n this._request.method = \"post\";\n this._request.body = parameters.data[0];\n }\n\n private setupMultipartTransport(parameters: RpcSerializedValue) {\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._request.method = \"post\";\n this._request.body = RpcMultipart.createForm(parameters);\n }\n\n private setupTextTransport(parameters: RpcSerializedValue) {\n if (this.operation.policy.allowResponseCaching(this)) {\n const encodedBody = btoa(parameters.objects);\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\n this._request.method = \"get\";\n this._request.body = undefined;\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._pathSuffix = encodedBody;\n return;\n }\n }\n\n this._pathSuffix = \"\";\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\n this._request.method = \"post\";\n this._request.body = parameters.objects;\n }\n\n /** @internal */\n public static backend = {\n sendResponse: async (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse): Promise<void> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n parseRequest: async (_protocol: WebAppRpcProtocol, _req: HttpServerRequest): Promise<SerializedRpcRequest> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n };\n}\n"]}
1
+ {"version":3,"file":"WebAppRpcRequest.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcRequest.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmE;AACnE,mDAAiF;AAEjF,uDAA2F;AAC3F,yDAAmF;AAEnF,mDAAgD;AAChD,uEAAoE;AACpE,iDAA8C;AAC9C,2DAA+F;AAQ/F;;GAEG;AACH,MAAa,gBAAiB,SAAQ,uBAAU;IACtC,QAAQ,GAAY,KAAK,CAAC;IAC1B,QAAQ,GAAgB,EAAE,CAAC;IAC3B,WAAW,GAAW,EAAE,CAAC;IACjC,IAAY,QAAQ,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAoC,CAAC,CAAC,CAAC;IAErF;;;;OAIG;IACI,MAAM,CAAC,mB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,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,OAAO,GAAG;QACtB,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,QAA8B,EAAE,YAAmC,EAAE,IAAuB,EAAE,IAAwB,EAAiB,EAAE;YAC1L,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,SAA4B,EAAE,IAAuB,EAAiC,EAAE;YAC3G,MAAM,IAAI,yBAAW,CAAC,4BAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC;;AAxPJ,4CAyPC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus, expectNotNull } from \"@itwin/core-bentley\";\nimport { IModelError, ServerError, ServerTimeoutError } from \"../../IModelError\";\nimport { RpcInterface } from \"../../RpcInterface\";\nimport { RpcContentType, RpcProtocolEvent, WEB_RPC_CONSTANTS } from \"../core/RpcConstants\";\nimport { MarshalingBinaryMarker, RpcSerializedValue } from \"../core/RpcMarshaling\";\nimport { RpcRequestFulfillment, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { RpcMultipartParser } from \"./multipart/RpcMultipartParser\";\nimport { RpcMultipart } from \"./RpcMultipart\";\nimport { HttpServerRequest, HttpServerResponse, WebAppRpcProtocol } from \"./WebAppRpcProtocol\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\ndeclare const location: any;\n\n/** @internal */\nexport type HttpMethod_T = \"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\" | \"trace\"; // eslint-disable-line @typescript-eslint/naming-convention\n\n/** A web application RPC request.\n * @internal\n */\nexport class WebAppRpcRequest extends RpcRequest {\n private _loading: boolean = false;\n private _request: RequestInit = {};\n private _pathSuffix: string = \"\";\n private get _headers() { return this._request.headers as { [key: string]: string }; }\n\n /** The maximum size permitted for an encoded component in a URL.\n * Note that some backends limit the total cumulative request size. Our current node backends accept requests with a max size of 16 kb.\n * In addition to the url size, an authorization header may also add considerably to the request size.\n * @note This is used for features like encoding the payload of a cacheable request in the URL.\n */\n public static maxUrlComponentSize = 1024 * 8;\n\n /** The HTTP method for this request. */\n public override method: HttpMethod_T;\n\n /** Convenience access to the protocol of this request. */\n public override readonly protocol: WebAppRpcProtocol = this.client.configuration.protocol as any;\n\n /** Standardized access to metadata about the request (useful for purposes such as logging). */\n public metadata = { status: 0, message: \"\" };\n\n /** Parses a request. */\n public static async parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\n return this.backend.parseRequest(protocol, req);\n }\n\n /** Sends the response for a web request. */\n public static async sendResponse(\n protocol: WebAppRpcProtocol,\n request: SerializedRpcRequest,\n fulfillment: RpcRequestFulfillment,\n req: HttpServerRequest,\n res: HttpServerResponse,\n ): Promise<void> {\n return this.backend.sendResponse(protocol, request, fulfillment, req, res);\n }\n\n /** Determines the most efficient transport type for an RPC value. */\n public static computeTransportType(value: RpcSerializedValue, source: any): RpcContentType {\n if (source instanceof Uint8Array || (Array.isArray(source) && source[0] instanceof Uint8Array)) {\n return RpcContentType.Binary;\n } else if (value.data.length > 0) {\n return RpcContentType.Multipart;\n } else if (value.stream) {\n return RpcContentType.Stream;\n } else {\n return RpcContentType.Text;\n }\n }\n\n /** Constructs a web application request. */\n public constructor(client: RpcInterface, operation: string, parameters: any[]) {\n super(client, operation, parameters);\n this.path = this.protocol.supplyPathForOperation(this.operation, this);\n this.method = \"head\";\n this._request.headers = {};\n }\n\n /** Sets request header values. */\n protected setHeader(name: string, value: string): void {\n this._headers[name] = value;\n }\n\n /** Sends the request. */\n protected async send(): Promise<number> {\n this._loading = true;\n await this.setupTransport();\n\n return new Promise<number>(async (resolve, reject) => {\n try {\n resolve(await this.performFetch());\n } catch (reason) {\n reject(new ServerError(-1, typeof (reason) === \"string\" ? reason : \"Server connection error.\"));\n }\n });\n }\n\n protected override computeRetryAfter(attempts: number): number {\n const retryAfter = this._response && this._response.headers.get(\"Retry-After\");\n if (retryAfter) {\n this.resetTransientFaultCount();\n\n const r = Number(retryAfter);\n if (Number.isFinite(r)) {\n return r * 1000;\n }\n\n const d = Date.parse(retryAfter);\n if (!Number.isNaN(d)) {\n return d - Date.now();\n }\n } else {\n this.recordTransientFault();\n }\n\n return super.computeRetryAfter(attempts);\n }\n\n protected override handleUnknownResponse(code: number) {\n if (this.protocol.isTimeout(code)) {\n this.reject(new ServerTimeoutError(\"Request timeout.\"));\n } else {\n this.reject(new ServerError(code, \"Unknown server response code.\"));\n }\n }\n\n protected async load(): Promise<RpcSerializedValue> {\n return new Promise<RpcSerializedValue>(async (resolve, reject) => {\n try {\n if (!this._loading)\n return;\n\n const response = this._response;\n if (!response) {\n reject(new IModelError(BentleyStatus.ERROR, \"Invalid state.\"));\n return;\n }\n\n if (this.protocol.protocolVersionHeaderName) {\n const version = response.headers.get(this.protocol.protocolVersionHeaderName);\n if (version) {\n this.responseProtocolVersion = parseInt(version, 10);\n }\n }\n\n const contentType = response.headers.get(WEB_RPC_CONSTANTS.CONTENT);\n const responseType = WebAppRpcProtocol.computeContentType(contentType);\n\n if (responseType === RpcContentType.Binary) {\n resolve(await this.loadBinary(response));\n } else if (responseType === RpcContentType.Multipart) {\n resolve(await this.loadMultipart(response, expectNotNull(contentType)));\n } else {\n resolve(await this.loadText(response));\n }\n\n this._loading = false;\n this.setLastUpdatedTime();\n this.protocol.events.raiseEvent(RpcProtocolEvent.ResponseLoaded, this);\n } catch (reason) {\n if (!this._loading)\n return;\n\n this._loading = false;\n reject(new ServerError(this.metadata.status, typeof (reason) === \"string\" ? reason : \"Unknown server response error.\"));\n }\n });\n }\n\n /** Override to supply an alternate fetch function. */\n protected supplyFetch(): typeof fetch {\n return fetch;\n }\n\n /** Override to supply an alternate Request function. */\n protected supplyRequest(): typeof Request {\n return Request;\n }\n\n private async performFetch(): Promise<number> {\n const requestClass = this.supplyRequest();\n const fetchFunction = this.supplyFetch();\n\n const path = new URL(this.path, typeof location !== \"undefined\" ? location.origin : undefined);\n if (this._pathSuffix) {\n const params = new URLSearchParams();\n params.set(\"parameters\", this._pathSuffix);\n path.search = `?${params.toString()}`;\n }\n\n const request = new requestClass(path.toString(), this._request);\n const response = await fetchFunction(request);\n this._response = response;\n this.metadata.status = response.status;\n return response.status;\n }\n\n private async loadText(response: Response) {\n const value = await response.text();\n this.metadata.message = value;\n return RpcSerializedValue.create(value);\n }\n\n private async loadBinary(response: Response) {\n const value = new Uint8Array(await response.arrayBuffer());\n const objects = JSON.stringify(MarshalingBinaryMarker.createDefault());\n return RpcSerializedValue.create(objects, [value]);\n }\n\n private async loadMultipart(response: Response, contentType: string) {\n const data = await response.arrayBuffer();\n const value = new RpcMultipartParser(contentType, new Uint8Array(data)).parse();\n return value;\n }\n\n private async setupTransport(): Promise<void> {\n const parameters = (await this.protocol.serialize(this)).parameters;\n const transportType = WebAppRpcRequest.computeTransportType(parameters, this.parameters);\n\n if (transportType === RpcContentType.Binary) {\n this.setupBinaryTransport(parameters);\n } else if (transportType === RpcContentType.Multipart) {\n this.setupMultipartTransport(parameters);\n } else {\n this.setupTextTransport(parameters);\n }\n }\n\n private setupBinaryTransport(parameters: RpcSerializedValue) {\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.BINARY;\n this._request.method = \"post\";\n this._request.body = parameters.data[0];\n }\n\n private setupMultipartTransport(parameters: RpcSerializedValue) {\n // IMPORTANT: do not set a multipart Content-Type header value. The browser does this automatically!\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._request.method = \"post\";\n this._request.body = RpcMultipart.createForm(parameters);\n }\n\n private setupTextTransport(parameters: RpcSerializedValue) {\n if (this.operation.policy.allowResponseCaching(this)) {\n const encodedBody = btoa(parameters.objects);\n if (encodedBody.length <= WebAppRpcRequest.maxUrlComponentSize) {\n this._request.method = \"get\";\n this._request.body = undefined;\n delete this._headers[WEB_RPC_CONSTANTS.CONTENT];\n this._pathSuffix = encodedBody;\n return;\n }\n }\n\n this._pathSuffix = \"\";\n this._headers[WEB_RPC_CONSTANTS.CONTENT] = WEB_RPC_CONSTANTS.TEXT;\n this._request.method = \"post\";\n this._request.body = parameters.objects;\n }\n\n /** @internal */\n public static backend = {\n sendResponse: async (_protocol: WebAppRpcProtocol, _request: SerializedRpcRequest, _fulfillment: RpcRequestFulfillment, _req: HttpServerRequest, _res: HttpServerResponse): Promise<void> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n parseRequest: async (_protocol: WebAppRpcProtocol, _req: HttpServerRequest): Promise<SerializedRpcRequest> => {\n throw new IModelError(BentleyStatus.ERROR, \"Not bound.\");\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AnalysisStyle.d.ts","sourceRoot":"","sources":["../../src/AnalysisStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,yBAAyB;IACpC,8GAA8G;IAC9G,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC;;OA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AAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,sBAAsB,CAAC,EAAE,6BAA6B,CAAC;CACxD;AAgCD;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,SAAgB,YAAY,CAAC,EAAE,yBAAyB,CAAC;IACzD,SAAgB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjD,qHAAqH;IACrH,SAAgB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3C;;OAEG;WACW,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,GAAG,aAAa;IAWjE,OAAO;IASP,qDAAqD;IAC9C,MAAM,IAAI,kBAAkB;IAiBnC,2GAA2G;IACpG,KAAK,CAAC,YAAY,EAAE,kBAAkB,GAAG,aAAa;IAO7D,0DAA0D;IACnD,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAiB5C,gBAAuB,QAAQ,gBAAyB;CACzD"}
@@ -165,10 +165,12 @@ export class AnalysisStyle {
165
165
  return false;
166
166
  if ((undefined === this.displacement) !== (undefined === other.displacement))
167
167
  return false;
168
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
168
169
  else if (this.displacement && !this.displacement.equals(other.displacement))
169
170
  return false;
170
171
  if ((undefined === this.thematic) !== (undefined === other.thematic))
171
172
  return false;
173
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
172
174
  return undefined === this.thematic || this.thematic.equals(other.thematic);
173
175
  }
174
176
  static defaults = new AnalysisStyle({});
@@ -1 +1 @@
1
- {"version":3,"file":"AnalysisStyle.js","sourceRoot":"","sources":["../../src/AnalysisStyle.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAiC,MAAM,mBAAmB,CAA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AAS,KAAK,KAAK,CAAC,QAAQ,CAAC;YAClE,OAAO,KAAK,CAAC;QAEf,OAAO,SAAS,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC;IAC9E,CAAC;IAEM,MAAM,CAAU,QAAQ,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module DisplayStyles\n */\n\nimport { Range1d, Range1dProps } from \"@itwin/core-geometry\";\nimport { ThematicGradientSettings, ThematicGradientSettingsProps } from \"./ThematicDisplay\";\nimport { Gradient } from \"./Gradient\";\n\n/** JSON representation of an [[AnalysisStyleDisplacement]].\n * @see [[AnalysisStyleProps.displacement]].\n * @public\n * @extensions\n */\nexport interface AnalysisStyleDisplacementProps {\n /** See [[AnalysisStyleDisplacement.channelName]]. */\n channelName: string;\n /** See [[AnalysisStyleDisplacement.scale]].\n * Default value: 1.\n */\n scale?: number;\n}\n\n/** Describes how an [[AnalysisStyle]] deforms a [Polyface]($core-geometry) by applying translation to its vertices.\n * @see [[AnalysisStyle.displacement]].\n * @public\n */\nexport class AnalysisStyleDisplacement {\n /** The name of the [AuxChannel]($core-geometry) supplying the displacements to be applied to the vertices. */\n public readonly channelName: string;\n /** A scale applied to the displacements to adjust the magnitude of the effect.\n * Default value: 1.\n */\n public readonly scale: number;\n\n private constructor(channelName: string, scale = 1) {\n this.channelName = channelName;\n this.scale = scale;\n }\n\n /** Create from JSON representation. */\n public static fromJSON(props: AnalysisStyleDisplacementProps): AnalysisStyleDisplacement {\n return new this(props.channelName, props.scale);\n }\n\n /** Convert to JSON representation. */\n public toJSON(): AnalysisStyleDisplacementProps {\n const props: AnalysisStyleDisplacementProps = { channelName: this.channelName };\n if (this.scale !== 1)\n props.scale = this.scale;\n\n return props;\n }\n\n /** Return true if `this` is equivalent to `other`. */\n public equals(other: AnalysisStyleDisplacement): boolean {\n return this.channelName === other.channelName && this.scale === other.scale;\n }\n}\n\n/** JSON representation of an [[AnalysisStyleThematic]].\n * @see [[AnalysisStyleProps.scalar]].\n * @public\n * @extensions\n */\nexport interface AnalysisStyleThematicProps {\n /** See [[AnalysisStyleThematic.channelName]]. */\n channelName: string;\n /** See [[AnalysisStyleThematic.range]]. */\n range: Range1dProps;\n /** See [[AnalysisStyleThematic.thematicSettings]].\n * Default value: [[ThematicGradientSettings.defaults]].\n */\n thematicSettings?: ThematicGradientSettingsProps;\n}\n\n/** Describes how an [[AnalysisStyle]] recolors [Polyface]($core-geometry) vertices by mapping values of type\n * [AuxChannelDataType.Scalar]($core-geometry) or [AuxChannelDataType.Distance]($core-geometry) supplied\n * by an [AuxChannel]($core-geometry) to colors supplied by a [[Gradient]] image.\n * @see [[AnalysisStyle.thematic]].\n * @public\n */\nexport class AnalysisStyleThematic {\n /** The name of the [AuxChannel]($core-geometry) supplying the values from which the vertex colors are computed. */\n public readonly channelName: string;\n /** The minimum and maximum values that map to colors in the [[Gradient]] image. Vertices with values outside of\n * this range are displayed with the gradient's margin color.\n */\n public readonly range: Readonly<Range1d>;\n /** Settings used to produce the [[Gradient]] image. */\n public readonly thematicSettings: ThematicGradientSettings;\n private _gradient?: Gradient.Symb;\n\n private constructor(props: AnalysisStyleThematicProps) {\n this.channelName = props.channelName;\n this.range = Range1d.fromJSON(props.range);\n this.thematicSettings = ThematicGradientSettings.fromJSON(props.thematicSettings);\n }\n\n /** Create from JSON representation. */\n public static fromJSON(props: AnalysisStyleThematicProps): AnalysisStyleThematic {\n return new this(props);\n }\n\n /** Convert to JSON representation. */\n public toJSON(): AnalysisStyleThematicProps {\n const props: AnalysisStyleThematicProps = {\n channelName: this.channelName,\n range: this.range.toJSON(),\n };\n\n if (!this.thematicSettings.equals(ThematicGradientSettings.defaults))\n props.thematicSettings = this.thematicSettings.toJSON();\n\n return props;\n }\n\n /** The gradient computed from [[thematicSettings]]. */\n public get gradient(): Gradient.Symb {\n if (!this._gradient)\n this._gradient = Gradient.Symb.createThematic(this.thematicSettings);\n\n return this._gradient;\n }\n\n /** Return true if `this` is equivalent to `other`. */\n public equals(other: AnalysisStyleThematic): boolean {\n return this.channelName === other.channelName && this.range.isAlmostEqual(other.range) && this.thematicSettings.equals(other.thematicSettings);\n }\n}\n\n/** JSON representation of an [[AnalysisStyle]].\n * @public\n * @extensions\n */\nexport interface AnalysisStyleProps {\n /** See [[AnalysisStyle.displacement]]. */\n displacement?: AnalysisStyleDisplacementProps;\n /** JSON representation of [[AnalysisStyle.thematic]].\n * @note The name \"scalar\" is used instead of \"thematic\" for backwards compatibility.\n */\n scalar?: AnalysisStyleThematicProps;\n /** See [[AnalysisStyle.normalChannelName]]. */\n normalChannelName?: string;\n}\n\n/** At time of writing, the only iModel in existence that uses AnalysisStyle is the one created by the analysis-importer test app.\n * To avoid breaking existing saved views of that iModel, AnalysisStyle.fromJSON() continues to accept the old JSON representation -\n * but that representation is not part of the public API.\n * @internal exported strictly for tests.\n */\nexport interface LegacyAnalysisStyleProps {\n displacementChannelName?: string;\n scalarChannelName?: string;\n normalChannelName?: string;\n displacementScale?: number;\n scalarRange?: Range1dProps;\n scalarThematicSettings?: ThematicGradientSettingsProps;\n}\n\nfunction tryConvertLegacyProps(input: AnalysisStyleProps): AnalysisStyleProps {\n if (input.displacement || input.scalar)\n return input;\n\n const legacy = input as LegacyAnalysisStyleProps;\n if (undefined === legacy.displacementChannelName && undefined === legacy.scalarChannelName)\n return input;\n\n const output: AnalysisStyleProps = {\n normalChannelName: input.normalChannelName,\n };\n\n if (undefined !== legacy.displacementChannelName) {\n output.displacement = {\n channelName: legacy.displacementChannelName,\n scale: legacy.displacementScale,\n };\n }\n\n if (undefined !== legacy.scalarChannelName && undefined !== legacy.scalarRange) {\n output.scalar = {\n channelName: legacy.scalarChannelName,\n range: legacy.scalarRange,\n thematicSettings: legacy.scalarThematicSettings,\n };\n }\n\n return output;\n}\n\n/** As part of a [[DisplayStyleSettings]], describes how to animate meshes in the view that have been augmented with\n * [PolyfaceAuxData]($core-geometry). The style specifies which channels to use, and can deform the meshes by\n * translating vertices and/or recolor vertices using [[ThematicDisplay]].\n * @see [[DisplayStyleSettings.analysisStyle]] to define the analysis style for a [DisplayStyle]($backend).\n * @see [[DisplayStyleSettings.analysisFraction]] to control playback of the animation.\n * @public\n */\nexport class AnalysisStyle {\n public readonly displacement?: AnalysisStyleDisplacement;\n public readonly thematic?: AnalysisStyleThematic;\n /** If defined, the name of the [AuxChannel]($core-geometry) from which to obtain normal vectors for the vertices. */\n public readonly normalChannelName?: string;\n\n /** Create an analysis style from its JSON representation.\n * @note AnalysisStyle is an immutable type - use [[clone]] to produce a modified copy.\n */\n public static fromJSON(props?: AnalysisStyleProps): AnalysisStyle {\n if (!props)\n return this.defaults;\n\n props = tryConvertLegacyProps(props);\n if (!props.displacement && !props.scalar && undefined === props.normalChannelName)\n return this.defaults;\n\n return new AnalysisStyle(props);\n }\n\n private constructor(props: AnalysisStyleProps) {\n this.normalChannelName = props.normalChannelName;\n if (props.displacement)\n this.displacement = AnalysisStyleDisplacement.fromJSON(props.displacement);\n\n if (props.scalar)\n this.thematic = AnalysisStyleThematic.fromJSON(props.scalar);\n }\n\n /** Convert this style to its JSON representation. */\n public toJSON(): AnalysisStyleProps {\n const props: AnalysisStyleProps = {};\n if (this === AnalysisStyle.defaults)\n return props;\n\n if (this.displacement)\n props.displacement = this.displacement.toJSON();\n\n if (this.thematic)\n props.scalar = this.thematic.toJSON();\n\n if (undefined !== this.normalChannelName)\n props.normalChannelName = this.normalChannelName;\n\n return props;\n }\n\n /** Produce a copy of this style identical except for properties explicitly specified by `changedProps`. */\n public clone(changedProps: AnalysisStyleProps): AnalysisStyle {\n return AnalysisStyle.fromJSON({\n ...this.toJSON(),\n ...changedProps,\n });\n }\n\n /** Return true if this style is equivalent to `other`. */\n public equals(other: AnalysisStyle): boolean {\n if (this.normalChannelName !== other.normalChannelName)\n return false;\n\n if ((undefined === this.displacement) !== (undefined === other.displacement))\n return false;\n else if (this.displacement && !this.displacement.equals(other.displacement!))\n return false;\n\n if ((undefined === this.thematic) !== (undefined === other.thematic))\n return false;\n\n return undefined === this.thematic || this.thematic.equals(other.thematic!);\n }\n\n public static readonly defaults = new AnalysisStyle({});\n}\n"]}
1
+ {"version":3,"file":"AnalysisStyle.js","sourceRoot":"","sources":["../../src/AnalysisStyle.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAiC,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAgBtC;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IACpC,8GAA8G;IAC9F,WAAW,CAAS;IACpC;;OAEG;IACa,KAAK,CAAS;IAE9B,YAAoB,WAAmB,EAAE,KAAK,GAAG,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,uCAAuC;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAqC;QAC1D,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAED,sCAAsC;IAC/B,MAAM;QACX,MAAM,KAAK,GAAmC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAChF,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC;YAClB,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAE3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,sDAAsD;IAC/C,MAAM,CAAC,KAAgC;QAC5C,OAAO,IAAI,C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AChB,GAAG,YAAY;SAChB,CAAC,CAAC;IACL,CAAC;IAED,0DAA0D;IACnD,MAAM,CAAC,KAAoB;QAChC,IAAI,IAAI,CAAC,iBAAiB,KAAK,KAAK,CAAC,iBAAiB;YACpD,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,YAAY,CAAC;YAC1E,OAAO,KAAK,CAAC;QACf,oEAAoE;aAC/D,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,YAAa,CAAC;YAC1E,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,QAAQ,CAAC;YAClE,OAAO,KAAK,CAAC;QAEf,oEAAoE;QACpE,OAAO,SAAS,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC;IAC9E,CAAC;IAEM,MAAM,CAAU,QAAQ,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module DisplayStyles\n */\n\nimport { Range1d, Range1dProps } from \"@itwin/core-geometry\";\nimport { ThematicGradientSettings, ThematicGradientSettingsProps } from \"./ThematicDisplay\";\nimport { Gradient } from \"./Gradient\";\n\n/** JSON representation of an [[AnalysisStyleDisplacement]].\n * @see [[AnalysisStyleProps.displacement]].\n * @public\n * @extensions\n */\nexport interface AnalysisStyleDisplacementProps {\n /** See [[AnalysisStyleDisplacement.channelName]]. */\n channelName: string;\n /** See [[AnalysisStyleDisplacement.scale]].\n * Default value: 1.\n */\n scale?: number;\n}\n\n/** Describes how an [[AnalysisStyle]] deforms a [Polyface]($core-geometry) by applying translation to its vertices.\n * @see [[AnalysisStyle.displacement]].\n * @public\n */\nexport class AnalysisStyleDisplacement {\n /** The name of the [AuxChannel]($core-geometry) supplying the displacements to be applied to the vertices. */\n public readonly channelName: string;\n /** A scale applied to the displacements to adjust the magnitude of the effect.\n * Default value: 1.\n */\n public readonly scale: number;\n\n private constructor(channelName: string, scale = 1) {\n this.channelName = channelName;\n this.scale = scale;\n }\n\n /** Create from JSON representation. */\n public static fromJSON(props: AnalysisStyleDisplacementProps): AnalysisStyleDisplacement {\n return new this(props.channelName, props.scale);\n }\n\n /** Convert to JSON representation. */\n public toJSON(): AnalysisStyleDisplacementProps {\n const props: AnalysisStyleDisplacementProps = { channelName: this.channelName };\n if (this.scale !== 1)\n props.scale = this.scale;\n\n return props;\n }\n\n /** Return true if `this` is equivalent to `other`. */\n public equals(other: AnalysisStyleDisplacement): boolean {\n return this.channelName === other.channelName && this.scale === other.scale;\n }\n}\n\n/** JSON representation of an [[AnalysisStyleThematic]].\n * @see [[AnalysisStyleProps.scalar]].\n * @public\n * @extensions\n */\nexport interface AnalysisStyleThematicProps {\n /** See [[AnalysisStyleThematic.channelName]]. */\n channelName: string;\n /** See [[AnalysisStyleThematic.range]]. */\n range: Range1dProps;\n /** See [[AnalysisStyleThematic.thematicSettings]].\n * Default value: [[ThematicGradientSettings.defaults]].\n */\n thematicSettings?: ThematicGradientSettingsProps;\n}\n\n/** Describes how an [[AnalysisStyle]] recolors [Polyface]($core-geometry) vertices by mapping values of type\n * [AuxChannelDataType.Scalar]($core-geometry) or [AuxChannelDataType.Distance]($core-geometry) supplied\n * by an [AuxChannel]($core-geometry) to colors supplied by a [[Gradient]] image.\n * @see [[AnalysisStyle.thematic]].\n * @public\n */\nexport class AnalysisStyleThematic {\n /** The name of the [AuxChannel]($core-geometry) supplying the values from which the vertex colors are computed. */\n public readonly channelName: string;\n /** The minimum and maximum values that map to colors in the [[Gradient]] image. Vertices with values outside of\n * this range are displayed with the gradient's margin color.\n */\n public readonly range: Readonly<Range1d>;\n /** Settings used to produce the [[Gradient]] image. */\n public readonly thematicSettings: ThematicGradientSettings;\n private _gradient?: Gradient.Symb;\n\n private constructor(props: AnalysisStyleThematicProps) {\n this.channelName = props.channelName;\n this.range = Range1d.fromJSON(props.range);\n this.thematicSettings = ThematicGradientSettings.fromJSON(props.thematicSettings);\n }\n\n /** Create from JSON representation. */\n public static fromJSON(props: AnalysisStyleThematicProps): AnalysisStyleThematic {\n return new this(props);\n }\n\n /** Convert to JSON representation. */\n public toJSON(): AnalysisStyleThematicProps {\n const props: AnalysisStyleThematicProps = {\n channelName: this.channelName,\n range: this.range.toJSON(),\n };\n\n if (!this.thematicSettings.equals(ThematicGradientSettings.defaults))\n props.thematicSettings = this.thematicSettings.toJSON();\n\n return props;\n }\n\n /** The gradient computed from [[thematicSettings]]. */\n public get gradient(): Gradient.Symb {\n if (!this._gradient)\n this._gradient = Gradient.Symb.createThematic(this.thematicSettings);\n\n return this._gradient;\n }\n\n /** Return true if `this` is equivalent to `other`. */\n public equals(other: AnalysisStyleThematic): boolean {\n return this.channelName === other.channelName && this.range.isAlmostEqual(other.range) && this.thematicSettings.equals(other.thematicSettings);\n }\n}\n\n/** JSON representation of an [[AnalysisStyle]].\n * @public\n * @extensions\n */\nexport interface AnalysisStyleProps {\n /** See [[AnalysisStyle.displacement]]. */\n displacement?: AnalysisStyleDisplacementProps;\n /** JSON representation of [[AnalysisStyle.thematic]].\n * @note The name \"scalar\" is used instead of \"thematic\" for backwards compatibility.\n */\n scalar?: AnalysisStyleThematicProps;\n /** See [[AnalysisStyle.normalChannelName]]. */\n normalChannelName?: string;\n}\n\n/** At time of writing, the only iModel in existence that uses AnalysisStyle is the one created by the analysis-importer test app.\n * To avoid breaking existing saved views of that iModel, AnalysisStyle.fromJSON() continues to accept the old JSON representation -\n * but that representation is not part of the public API.\n * @internal exported strictly for tests.\n */\nexport interface LegacyAnalysisStyleProps {\n displacementChannelName?: string;\n scalarChannelName?: string;\n normalChannelName?: string;\n displacementScale?: number;\n scalarRange?: Range1dProps;\n scalarThematicSettings?: ThematicGradientSettingsProps;\n}\n\nfunction tryConvertLegacyProps(input: AnalysisStyleProps): AnalysisStyleProps {\n if (input.displacement || input.scalar)\n return input;\n\n const legacy = input as LegacyAnalysisStyleProps;\n if (undefined === legacy.displacementChannelName && undefined === legacy.scalarChannelName)\n return input;\n\n const output: AnalysisStyleProps = {\n normalChannelName: input.normalChannelName,\n };\n\n if (undefined !== legacy.displacementChannelName) {\n output.displacement = {\n channelName: legacy.displacementChannelName,\n scale: legacy.displacementScale,\n };\n }\n\n if (undefined !== legacy.scalarChannelName && undefined !== legacy.scalarRange) {\n output.scalar = {\n channelName: legacy.scalarChannelName,\n range: legacy.scalarRange,\n thematicSettings: legacy.scalarThematicSettings,\n };\n }\n\n return output;\n}\n\n/** As part of a [[DisplayStyleSettings]], describes how to animate meshes in the view that have been augmented with\n * [PolyfaceAuxData]($core-geometry). The style specifies which channels to use, and can deform the meshes by\n * translating vertices and/or recolor vertices using [[ThematicDisplay]].\n * @see [[DisplayStyleSettings.analysisStyle]] to define the analysis style for a [DisplayStyle]($backend).\n * @see [[DisplayStyleSettings.analysisFraction]] to control playback of the animation.\n * @public\n */\nexport class AnalysisStyle {\n public readonly displacement?: AnalysisStyleDisplacement;\n public readonly thematic?: AnalysisStyleThematic;\n /** If defined, the name of the [AuxChannel]($core-geometry) from which to obtain normal vectors for the vertices. */\n public readonly normalChannelName?: string;\n\n /** Create an analysis style from its JSON representation.\n * @note AnalysisStyle is an immutable type - use [[clone]] to produce a modified copy.\n */\n public static fromJSON(props?: AnalysisStyleProps): AnalysisStyle {\n if (!props)\n return this.defaults;\n\n props = tryConvertLegacyProps(props);\n if (!props.displacement && !props.scalar && undefined === props.normalChannelName)\n return this.defaults;\n\n return new AnalysisStyle(props);\n }\n\n private constructor(props: AnalysisStyleProps) {\n this.normalChannelName = props.normalChannelName;\n if (props.displacement)\n this.displacement = AnalysisStyleDisplacement.fromJSON(props.displacement);\n\n if (props.scalar)\n this.thematic = AnalysisStyleThematic.fromJSON(props.scalar);\n }\n\n /** Convert this style to its JSON representation. */\n public toJSON(): AnalysisStyleProps {\n const props: AnalysisStyleProps = {};\n if (this === AnalysisStyle.defaults)\n return props;\n\n if (this.displacement)\n props.displacement = this.displacement.toJSON();\n\n if (this.thematic)\n props.scalar = this.thematic.toJSON();\n\n if (undefined !== this.normalChannelName)\n props.normalChannelName = this.normalChannelName;\n\n return props;\n }\n\n /** Produce a copy of this style identical except for properties explicitly specified by `changedProps`. */\n public clone(changedProps: AnalysisStyleProps): AnalysisStyle {\n return AnalysisStyle.fromJSON({\n ...this.toJSON(),\n ...changedProps,\n });\n }\n\n /** Return true if this style is equivalent to `other`. */\n public equals(other: AnalysisStyle): boolean {\n if (this.normalChannelName !== other.normalChannelName)\n return false;\n\n if ((undefined === this.displacement) !== (undefined === other.displacement))\n return false;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n else if (this.displacement && !this.displacement.equals(other.displacement!))\n return false;\n\n if ((undefined === this.thematic) !== (undefined === other.thematic))\n return false;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return undefined === this.thematic || this.thematic.equals(other.thematic!);\n }\n\n public static readonly defaults = new AnalysisStyle({});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BlobReader.d.ts","sourceRoot":"","sources":["../../src/BlobReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,WAAW,EAAsB,SAAS,EAAE,aAAa,EAAE,cAAc,EAAgB,iBAAiB,EAC3G,MAAM,mBAAmB,CAAC;AAE3B,YAAY;AACZ,qBAAa,WAAY,YAAW,QAAQ,CAAC,UAAU,CAAC;IACtD,OAAO,CAAC,OAAO,CAAoB;IAC5B,MAAM,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AE,CAAC,GAAG,EAAE,MAAM;IACrB,IAAW,MAAM,WAAkC;IAC5C,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,SAAS,CAAC;IAGzD,OAAO,IAAI,UAAU;CAU7B;AACD,YAAY;AACZ,qBAAa,UAAU;IAIF,OAAO,CAAC,SAAS;aAClB,SAAS,EAAE,MAAM;aACjB,YAAY,EAAE,MAAM;aACpB,UAAU,EAAE,UAAU;IANxC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAyC;gBAC9B,SAAS,EAAE,iBAAiB,CAAC,aAAa,EAAE,cAAc,CAAC,EACpE,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,UAAU,EACtC,OAAO,CAAC,EAAE,WAAW;IAGhB,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW;IAOlC,IAAW,KAAK,IAAI,SAAS,CAA+C;IAC/D,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAuBxB,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC;IAI7C,IAAW,OAAO,IAAI,UAAU,CAK/B;IACD,IAAW,MAAM,IAAI,WAAW,CAAyB;CAC1D"}
@@ -1,3 +1,11 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module iModels
7
+ */
8
+ import { expectDefined } from "@itwin/core-bentley";
1
9
  import { BlobOptionsBuilder, DbQueryError, DbRequestKind, } from "./ConcurrentQuery";
2
10
  /** @beta */
3
11
  export class Uint8Chunks {
@@ -42,9 +50,9 @@ export class BlobReader {
42
50
  this._options = options;
43
51
  }
44
52
  this._chunks = new Uint8Chunks();
45
- this._lengthToRead = this.range.count;
53
+ this._lengthToRead = expectDefined(this.range.count);
46
54
  }
47
- get range() { return this._options.range; }
55
+ get range() { return expectDefined(this._options.range); }
48
56
  async step() {
49
57
  if (this._lengthToRead === this._chunks.length) {
50
58
  return false;