@itwin/core-backend 5.1.0-dev.9 → 5.2.0-dev.1

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 (441) hide show
  1. package/CHANGELOG.md +112 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +1 -1
  3. package/lib/cjs/BackendHubAccess.js +1 -1
  4. package/lib/cjs/BackendHubAccess.js.map +1 -1
  5. package/lib/cjs/BisCoreSchema.d.ts.map +1 -1
  6. package/lib/cjs/BisCoreSchema.js +4 -2
  7. package/lib/cjs/BisCoreSchema.js.map +1 -1
  8. package/lib/cjs/BriefcaseManager.d.ts +10 -2
  9. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  10. package/lib/cjs/BriefcaseManager.js +16 -0
  11. package/lib/cjs/BriefcaseManager.js.map +1 -1
  12. package/lib/cjs/Category.d.ts +4 -4
  13. package/lib/cjs/Category.js +4 -4
  14. package/lib/cjs/Category.js.map +1 -1
  15. package/lib/cjs/ChangesetECAdaptor.d.ts +67 -8
  16. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  17. package/lib/cjs/ChangesetECAdaptor.js +248 -33
  18. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  19. package/lib/cjs/ClassRegistry.d.ts +9 -1
  20. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  21. package/lib/cjs/ClassRegistry.js +9 -1
  22. package/lib/cjs/ClassRegistry.js.map +1 -1
  23. package/lib/cjs/CloudSqlite.js +1 -1
  24. package/lib/cjs/CloudSqlite.js.map +1 -1
  25. package/lib/cjs/CodeSpecs.d.ts +1 -1
  26. package/lib/cjs/CodeSpecs.js +1 -1
  27. package/lib/cjs/CodeSpecs.js.map +1 -1
  28. package/lib/cjs/DisplayStyle.d.ts +4 -4
  29. package/lib/cjs/DisplayStyle.js +3 -3
  30. package/lib/cjs/DisplayStyle.js.map +1 -1
  31. package/lib/cjs/ECDb.d.ts +4 -4
  32. package/lib/cjs/ECDb.d.ts.map +1 -1
  33. package/lib/cjs/ECDb.js +4 -4
  34. package/lib/cjs/ECDb.js.map +1 -1
  35. package/lib/cjs/ECSqlStatement.d.ts +15 -6
  36. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  37. package/lib/cjs/ECSqlStatement.js +19 -4
  38. package/lib/cjs/ECSqlStatement.js.map +1 -1
  39. package/lib/cjs/Element.d.ts +54 -51
  40. package/lib/cjs/Element.d.ts.map +1 -1
  41. package/lib/cjs/Element.js +67 -52
  42. package/lib/cjs/Element.js.map +1 -1
  43. package/lib/cjs/ElementAspect.d.ts +8 -8
  44. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  45. package/lib/cjs/ElementAspect.js +8 -8
  46. package/lib/cjs/ElementAspect.js.map +1 -1
  47. package/lib/cjs/Entity.d.ts +10 -7
  48. package/lib/cjs/Entity.d.ts.map +1 -1
  49. package/lib/cjs/Entity.js +35 -13
  50. package/lib/cjs/Entity.js.map +1 -1
  51. package/lib/cjs/ExportGraphics.d.ts +54 -8
  52. package/lib/cjs/ExportGraphics.d.ts.map +1 -1
  53. package/lib/cjs/ExportGraphics.js +158 -59
  54. package/lib/cjs/ExportGraphics.js.map +1 -1
  55. package/lib/cjs/GeographicCRSServices.d.ts +6 -2
  56. package/lib/cjs/GeographicCRSServices.d.ts.map +1 -1
  57. package/lib/cjs/GeographicCRSServices.js +1 -1
  58. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  59. package/lib/cjs/IModelDb.d.ts +37 -26
  60. package/lib/cjs/IModelDb.d.ts.map +1 -1
  61. package/lib/cjs/IModelDb.js +124 -47
  62. package/lib/cjs/IModelDb.js.map +1 -1
  63. package/lib/cjs/IModelElementCloneContext.d.ts +1 -1
  64. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  65. package/lib/cjs/IModelElementCloneContext.js +1 -1
  66. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  67. package/lib/cjs/IModelHost.d.ts +2 -3
  68. package/lib/cjs/IModelHost.d.ts.map +1 -1
  69. package/lib/cjs/IModelHost.js +2 -3
  70. package/lib/cjs/IModelHost.js.map +1 -1
  71. package/lib/cjs/IModelIncrementalSchemaLocater.d.ts +36 -0
  72. package/lib/cjs/IModelIncrementalSchemaLocater.d.ts.map +1 -0
  73. package/lib/cjs/IModelIncrementalSchemaLocater.js +69 -0
  74. package/lib/cjs/IModelIncrementalSchemaLocater.js.map +1 -0
  75. package/lib/cjs/LocalHub.d.ts.map +1 -1
  76. package/lib/cjs/LocalHub.js +6 -4
  77. package/lib/cjs/LocalHub.js.map +1 -1
  78. package/lib/cjs/Material.d.ts +4 -3
  79. package/lib/cjs/Material.d.ts.map +1 -1
  80. package/lib/cjs/Material.js +5 -5
  81. package/lib/cjs/Material.js.map +1 -1
  82. package/lib/cjs/Model.d.ts +22 -22
  83. package/lib/cjs/Model.js +22 -22
  84. package/lib/cjs/Model.js.map +1 -1
  85. package/lib/cjs/Relationship.d.ts +3 -0
  86. package/lib/cjs/Relationship.d.ts.map +1 -1
  87. package/lib/cjs/Relationship.js +15 -0
  88. package/lib/cjs/Relationship.js.map +1 -1
  89. package/lib/cjs/SQLiteDb.d.ts +1 -1
  90. package/lib/cjs/SQLiteDb.js +1 -1
  91. package/lib/cjs/SQLiteDb.js.map +1 -1
  92. package/lib/cjs/Schema.d.ts +25 -0
  93. package/lib/cjs/Schema.d.ts.map +1 -1
  94. package/lib/cjs/Schema.js +25 -0
  95. package/lib/cjs/Schema.js.map +1 -1
  96. package/lib/cjs/SqliteStatement.d.ts +1 -1
  97. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  98. package/lib/cjs/SqliteStatement.js +1 -1
  99. package/lib/cjs/SqliteStatement.js.map +1 -1
  100. package/lib/cjs/Texture.d.ts +1 -1
  101. package/lib/cjs/Texture.js +1 -1
  102. package/lib/cjs/Texture.js.map +1 -1
  103. package/lib/cjs/TxnManager.d.ts +4 -4
  104. package/lib/cjs/TxnManager.js +1 -1
  105. package/lib/cjs/TxnManager.js.map +1 -1
  106. package/lib/cjs/ViewDefinition.d.ts +40 -14
  107. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  108. package/lib/cjs/ViewDefinition.js +42 -14
  109. package/lib/cjs/ViewDefinition.js.map +1 -1
  110. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +61 -0
  111. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -0
  112. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +110 -0
  113. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -0
  114. package/lib/cjs/annotations/FrameGeometry.d.ts +51 -0
  115. package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -0
  116. package/lib/cjs/annotations/FrameGeometry.js +249 -0
  117. package/lib/cjs/annotations/FrameGeometry.js.map +1 -0
  118. package/lib/cjs/annotations/LeaderGeometry.d.ts +53 -0
  119. package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -0
  120. package/lib/cjs/annotations/LeaderGeometry.js +184 -0
  121. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -0
  122. package/lib/cjs/annotations/TextAnnotationElement.d.ts +204 -0
  123. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -0
  124. package/lib/cjs/annotations/TextAnnotationElement.js +411 -0
  125. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -0
  126. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts +33 -0
  127. package/lib/cjs/annotations/TextAnnotationGeometry.d.ts.map +1 -0
  128. package/lib/cjs/annotations/TextAnnotationGeometry.js +137 -0
  129. package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -0
  130. package/lib/cjs/annotations/TextBlockGeometry.d.ts +16 -0
  131. package/lib/cjs/annotations/TextBlockGeometry.d.ts.map +1 -0
  132. package/lib/cjs/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +28 -70
  133. package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -0
  134. package/lib/cjs/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +69 -22
  135. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -0
  136. package/lib/cjs/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +174 -49
  137. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -0
  138. package/lib/cjs/core-backend.d.ts +7 -3
  139. package/lib/cjs/core-backend.d.ts.map +1 -1
  140. package/lib/cjs/core-backend.js +27 -6
  141. package/lib/cjs/core-backend.js.map +1 -1
  142. package/lib/cjs/internal/ElementLRUCache.d.ts +23 -0
  143. package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -1
  144. package/lib/cjs/internal/ElementLRUCache.js +167 -3
  145. package/lib/cjs/internal/ElementLRUCache.js.map +1 -1
  146. package/lib/cjs/internal/Symbols.d.ts +1 -0
  147. package/lib/cjs/internal/Symbols.d.ts.map +1 -1
  148. package/lib/cjs/internal/Symbols.js +2 -1
  149. package/lib/cjs/internal/Symbols.js.map +1 -1
  150. package/lib/cjs/internal/annotations/fields.d.ts +22 -0
  151. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -0
  152. package/lib/cjs/internal/annotations/fields.js +237 -0
  153. package/lib/cjs/internal/annotations/fields.js.map +1 -0
  154. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  155. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -1
  156. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  157. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  158. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  159. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  160. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  161. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  162. package/lib/cjs/workspace/Workspace.d.ts +0 -1
  163. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  164. package/lib/cjs/workspace/Workspace.js.map +1 -1
  165. package/lib/esm/BackendHubAccess.d.ts +1 -1
  166. package/lib/esm/BackendHubAccess.js +1 -1
  167. package/lib/esm/BackendHubAccess.js.map +1 -1
  168. package/lib/esm/BisCoreSchema.d.ts.map +1 -1
  169. package/lib/esm/BisCoreSchema.js +4 -2
  170. package/lib/esm/BisCoreSchema.js.map +1 -1
  171. package/lib/esm/BriefcaseManager.d.ts +10 -2
  172. package/lib/esm/BriefcaseManager.d.ts.map +1 -1
  173. package/lib/esm/BriefcaseManager.js +17 -1
  174. package/lib/esm/BriefcaseManager.js.map +1 -1
  175. package/lib/esm/Category.d.ts +4 -4
  176. package/lib/esm/Category.js +4 -4
  177. package/lib/esm/Category.js.map +1 -1
  178. package/lib/esm/ChangesetECAdaptor.d.ts +67 -8
  179. package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
  180. package/lib/esm/ChangesetECAdaptor.js +248 -33
  181. package/lib/esm/ChangesetECAdaptor.js.map +1 -1
  182. package/lib/esm/ClassRegistry.d.ts +9 -1
  183. package/lib/esm/ClassRegistry.d.ts.map +1 -1
  184. package/lib/esm/ClassRegistry.js +9 -1
  185. package/lib/esm/ClassRegistry.js.map +1 -1
  186. package/lib/esm/CloudSqlite.js +1 -1
  187. package/lib/esm/CloudSqlite.js.map +1 -1
  188. package/lib/esm/CodeSpecs.d.ts +1 -1
  189. package/lib/esm/CodeSpecs.js +1 -1
  190. package/lib/esm/CodeSpecs.js.map +1 -1
  191. package/lib/esm/DisplayStyle.d.ts +4 -4
  192. package/lib/esm/DisplayStyle.js +3 -3
  193. package/lib/esm/DisplayStyle.js.map +1 -1
  194. package/lib/esm/ECDb.d.ts +4 -4
  195. package/lib/esm/ECDb.d.ts.map +1 -1
  196. package/lib/esm/ECDb.js +4 -4
  197. package/lib/esm/ECDb.js.map +1 -1
  198. package/lib/esm/ECSqlStatement.d.ts +15 -6
  199. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  200. package/lib/esm/ECSqlStatement.js +19 -4
  201. package/lib/esm/ECSqlStatement.js.map +1 -1
  202. package/lib/esm/Element.d.ts +54 -51
  203. package/lib/esm/Element.d.ts.map +1 -1
  204. package/lib/esm/Element.js +67 -52
  205. package/lib/esm/Element.js.map +1 -1
  206. package/lib/esm/ElementAspect.d.ts +8 -8
  207. package/lib/esm/ElementAspect.d.ts.map +1 -1
  208. package/lib/esm/ElementAspect.js +8 -8
  209. package/lib/esm/ElementAspect.js.map +1 -1
  210. package/lib/esm/Entity.d.ts +10 -7
  211. package/lib/esm/Entity.d.ts.map +1 -1
  212. package/lib/esm/Entity.js +36 -14
  213. package/lib/esm/Entity.js.map +1 -1
  214. package/lib/esm/ExportGraphics.d.ts +54 -8
  215. package/lib/esm/ExportGraphics.d.ts.map +1 -1
  216. package/lib/esm/ExportGraphics.js +156 -58
  217. package/lib/esm/ExportGraphics.js.map +1 -1
  218. package/lib/esm/GeographicCRSServices.d.ts +6 -2
  219. package/lib/esm/GeographicCRSServices.d.ts.map +1 -1
  220. package/lib/esm/GeographicCRSServices.js +1 -1
  221. package/lib/esm/GeographicCRSServices.js.map +1 -1
  222. package/lib/esm/IModelDb.d.ts +37 -26
  223. package/lib/esm/IModelDb.d.ts.map +1 -1
  224. package/lib/esm/IModelDb.js +128 -51
  225. package/lib/esm/IModelDb.js.map +1 -1
  226. package/lib/esm/IModelElementCloneContext.d.ts +1 -1
  227. package/lib/esm/IModelElementCloneContext.d.ts.map +1 -1
  228. package/lib/esm/IModelElementCloneContext.js +1 -1
  229. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  230. package/lib/esm/IModelHost.d.ts +2 -3
  231. package/lib/esm/IModelHost.d.ts.map +1 -1
  232. package/lib/esm/IModelHost.js +2 -3
  233. package/lib/esm/IModelHost.js.map +1 -1
  234. package/lib/esm/IModelIncrementalSchemaLocater.d.ts +36 -0
  235. package/lib/esm/IModelIncrementalSchemaLocater.d.ts.map +1 -0
  236. package/lib/esm/IModelIncrementalSchemaLocater.js +65 -0
  237. package/lib/esm/IModelIncrementalSchemaLocater.js.map +1 -0
  238. package/lib/esm/LocalHub.d.ts.map +1 -1
  239. package/lib/esm/LocalHub.js +6 -4
  240. package/lib/esm/LocalHub.js.map +1 -1
  241. package/lib/esm/Material.d.ts +4 -3
  242. package/lib/esm/Material.d.ts.map +1 -1
  243. package/lib/esm/Material.js +5 -5
  244. package/lib/esm/Material.js.map +1 -1
  245. package/lib/esm/Model.d.ts +22 -22
  246. package/lib/esm/Model.js +22 -22
  247. package/lib/esm/Model.js.map +1 -1
  248. package/lib/esm/Relationship.d.ts +3 -0
  249. package/lib/esm/Relationship.d.ts.map +1 -1
  250. package/lib/esm/Relationship.js +15 -0
  251. package/lib/esm/Relationship.js.map +1 -1
  252. package/lib/esm/SQLiteDb.d.ts +1 -1
  253. package/lib/esm/SQLiteDb.js +1 -1
  254. package/lib/esm/SQLiteDb.js.map +1 -1
  255. package/lib/esm/Schema.d.ts +25 -0
  256. package/lib/esm/Schema.d.ts.map +1 -1
  257. package/lib/esm/Schema.js +25 -0
  258. package/lib/esm/Schema.js.map +1 -1
  259. package/lib/esm/SqliteStatement.d.ts +1 -1
  260. package/lib/esm/SqliteStatement.d.ts.map +1 -1
  261. package/lib/esm/SqliteStatement.js +1 -1
  262. package/lib/esm/SqliteStatement.js.map +1 -1
  263. package/lib/esm/Texture.d.ts +1 -1
  264. package/lib/esm/Texture.js +1 -1
  265. package/lib/esm/Texture.js.map +1 -1
  266. package/lib/esm/TxnManager.d.ts +4 -4
  267. package/lib/esm/TxnManager.js +1 -1
  268. package/lib/esm/TxnManager.js.map +1 -1
  269. package/lib/esm/ViewDefinition.d.ts +40 -14
  270. package/lib/esm/ViewDefinition.d.ts.map +1 -1
  271. package/lib/esm/ViewDefinition.js +42 -14
  272. package/lib/esm/ViewDefinition.js.map +1 -1
  273. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +61 -0
  274. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -0
  275. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +105 -0
  276. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -0
  277. package/lib/esm/annotations/FrameGeometry.d.ts +51 -0
  278. package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -0
  279. package/lib/esm/annotations/FrameGeometry.js +244 -0
  280. package/lib/esm/annotations/FrameGeometry.js.map +1 -0
  281. package/lib/esm/annotations/LeaderGeometry.d.ts +53 -0
  282. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -0
  283. package/lib/esm/annotations/LeaderGeometry.js +179 -0
  284. package/lib/esm/annotations/LeaderGeometry.js.map +1 -0
  285. package/lib/esm/annotations/TextAnnotationElement.d.ts +204 -0
  286. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -0
  287. package/lib/esm/annotations/TextAnnotationElement.js +405 -0
  288. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -0
  289. package/lib/esm/annotations/TextAnnotationGeometry.d.ts +33 -0
  290. package/lib/esm/annotations/TextAnnotationGeometry.d.ts.map +1 -0
  291. package/lib/esm/annotations/TextAnnotationGeometry.js +134 -0
  292. package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -0
  293. package/lib/esm/annotations/TextBlockGeometry.d.ts +16 -0
  294. package/lib/esm/annotations/TextBlockGeometry.d.ts.map +1 -0
  295. package/lib/esm/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +28 -70
  296. package/lib/esm/annotations/TextBlockGeometry.js.map +1 -0
  297. package/lib/esm/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +69 -22
  298. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -0
  299. package/lib/esm/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +172 -48
  300. package/lib/esm/annotations/TextBlockLayout.js.map +1 -0
  301. package/lib/esm/core-backend.d.ts +7 -3
  302. package/lib/esm/core-backend.d.ts.map +1 -1
  303. package/lib/esm/core-backend.js +27 -3
  304. package/lib/esm/core-backend.js.map +1 -1
  305. package/lib/esm/internal/ElementLRUCache.d.ts +23 -0
  306. package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -1
  307. package/lib/esm/internal/ElementLRUCache.js +165 -2
  308. package/lib/esm/internal/ElementLRUCache.js.map +1 -1
  309. package/lib/esm/internal/Symbols.d.ts +1 -0
  310. package/lib/esm/internal/Symbols.d.ts.map +1 -1
  311. package/lib/esm/internal/Symbols.js +1 -0
  312. package/lib/esm/internal/Symbols.js.map +1 -1
  313. package/lib/esm/internal/annotations/fields.d.ts +22 -0
  314. package/lib/esm/internal/annotations/fields.d.ts.map +1 -0
  315. package/lib/esm/internal/annotations/fields.js +231 -0
  316. package/lib/esm/internal/annotations/fields.js.map +1 -0
  317. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  318. package/lib/esm/rpc-impl/IModelReadRpcImpl.js +1 -1
  319. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  320. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  321. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  322. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  323. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  324. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  325. package/lib/esm/test/AnnotationTestUtils.d.ts +15 -0
  326. package/lib/esm/test/AnnotationTestUtils.d.ts.map +1 -0
  327. package/lib/esm/test/AnnotationTestUtils.js +41 -0
  328. package/lib/esm/test/AnnotationTestUtils.js.map +1 -0
  329. package/lib/esm/test/ElementLRUCache.test.js +224 -1
  330. package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
  331. package/lib/esm/test/IModelTestUtils.d.ts.map +1 -1
  332. package/lib/esm/test/IModelTestUtils.js +1 -0
  333. package/lib/esm/test/IModelTestUtils.js.map +1 -1
  334. package/lib/esm/test/TestUtils.d.ts +1 -1
  335. package/lib/esm/test/TestUtils.d.ts.map +1 -1
  336. package/lib/esm/test/TestUtils.js +1 -1
  337. package/lib/esm/test/TestUtils.js.map +1 -1
  338. package/lib/esm/test/annotations/Fields.test.d.ts +2 -0
  339. package/lib/esm/test/annotations/Fields.test.d.ts.map +1 -0
  340. package/lib/esm/test/annotations/Fields.test.js +576 -0
  341. package/lib/esm/test/annotations/Fields.test.js.map +1 -0
  342. package/lib/esm/test/annotations/FrameGeometry.test.d.ts +2 -0
  343. package/lib/esm/test/annotations/FrameGeometry.test.d.ts.map +1 -0
  344. package/lib/esm/test/annotations/FrameGeometry.test.js +86 -0
  345. package/lib/esm/test/annotations/FrameGeometry.test.js.map +1 -0
  346. package/lib/esm/test/annotations/LeaderGeometry.test.d.ts +2 -0
  347. package/lib/esm/test/annotations/LeaderGeometry.test.d.ts.map +1 -0
  348. package/lib/esm/test/annotations/LeaderGeometry.test.js +256 -0
  349. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -0
  350. package/lib/esm/test/annotations/TextAnnotation.test.js +269 -1047
  351. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  352. package/lib/esm/test/annotations/TextBlock.test.d.ts +2 -0
  353. package/lib/esm/test/annotations/TextBlock.test.d.ts.map +1 -0
  354. package/lib/esm/test/annotations/TextBlock.test.js +1199 -0
  355. package/lib/esm/test/annotations/TextBlock.test.js.map +1 -0
  356. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.d.ts +60 -0
  357. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.d.ts.map +1 -0
  358. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js +69 -0
  359. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/old.config.js.map +1 -0
  360. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.d.ts +1442 -0
  361. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.d.ts.map +1 -0
  362. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js +817 -0
  363. package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -0
  364. package/lib/esm/test/ecdb/ConcurrentQuery.test.d.ts +2 -0
  365. package/lib/esm/test/ecdb/ConcurrentQuery.test.d.ts.map +1 -0
  366. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +164 -0
  367. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -0
  368. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +22 -32
  369. package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
  370. package/lib/esm/test/ecdb/ECDb.test.js +29 -8
  371. package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
  372. package/lib/esm/test/ecdb/ECSqlQuery.test.js +0 -55
  373. package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
  374. package/lib/esm/test/ecdb/ECSqlStatement.test.js +192 -0
  375. package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
  376. package/lib/esm/test/hubaccess/ApplyChangeset.test.d.ts +2 -0
  377. package/lib/esm/test/hubaccess/ApplyChangeset.test.d.ts.map +1 -0
  378. package/lib/esm/test/hubaccess/ApplyChangeset.test.js +86 -0
  379. package/lib/esm/test/hubaccess/ApplyChangeset.test.js.map +1 -0
  380. package/lib/esm/test/imodel/IModel.test.js +313 -5
  381. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  382. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.d.ts +2 -0
  383. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.d.ts.map +1 -0
  384. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js +343 -0
  385. package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -0
  386. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.d.ts +2 -0
  387. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.d.ts.map +1 -0
  388. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js +207 -0
  389. package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -0
  390. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts +11 -0
  391. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts.map +1 -0
  392. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js +36 -0
  393. package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +1 -0
  394. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts +17 -0
  395. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts.map +1 -0
  396. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js +116 -0
  397. package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +1 -0
  398. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts +9 -0
  399. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts.map +1 -0
  400. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js +20 -0
  401. package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +1 -0
  402. package/lib/esm/test/misc/GeoServices.test.js +36 -10
  403. package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
  404. package/lib/esm/test/schema/ClassRegistry.test.js +104 -2
  405. package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
  406. package/lib/esm/test/standalone/ChangesetReader.test.js +547 -136
  407. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  408. package/lib/esm/test/standalone/ExportGraphics.test.js +53 -1
  409. package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
  410. package/lib/esm/test/standalone/GeometryStream.test.js +49 -1
  411. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  412. package/lib/esm/test/standalone/IModelLimits.test.d.ts +2 -0
  413. package/lib/esm/test/standalone/IModelLimits.test.d.ts.map +1 -0
  414. package/lib/esm/test/standalone/IModelLimits.test.js +103 -0
  415. package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -0
  416. package/lib/esm/test/standalone/RenderMaterialElement.test.js +24 -1
  417. package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
  418. package/lib/esm/test/standalone/SnapshotDb.test.js +19 -1
  419. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  420. package/lib/esm/workspace/Workspace.d.ts +0 -1
  421. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  422. package/lib/esm/workspace/Workspace.js.map +1 -1
  423. package/package.json +21 -15
  424. package/lib/cjs/TextAnnotationElement.d.ts +0 -54
  425. package/lib/cjs/TextAnnotationElement.d.ts.map +0 -1
  426. package/lib/cjs/TextAnnotationElement.js +0 -94
  427. package/lib/cjs/TextAnnotationElement.js.map +0 -1
  428. package/lib/cjs/TextAnnotationGeometry.d.ts +0 -32
  429. package/lib/cjs/TextAnnotationGeometry.d.ts.map +0 -1
  430. package/lib/cjs/TextAnnotationGeometry.js.map +0 -1
  431. package/lib/cjs/TextAnnotationLayout.d.ts.map +0 -1
  432. package/lib/cjs/TextAnnotationLayout.js.map +0 -1
  433. package/lib/esm/TextAnnotationElement.d.ts +0 -54
  434. package/lib/esm/TextAnnotationElement.d.ts.map +0 -1
  435. package/lib/esm/TextAnnotationElement.js +0 -89
  436. package/lib/esm/TextAnnotationElement.js.map +0 -1
  437. package/lib/esm/TextAnnotationGeometry.d.ts +0 -32
  438. package/lib/esm/TextAnnotationGeometry.d.ts.map +0 -1
  439. package/lib/esm/TextAnnotationGeometry.js.map +0 -1
  440. package/lib/esm/TextAnnotationLayout.d.ts.map +0 -1
  441. package/lib/esm/TextAnnotationLayout.js.map +0 -1
@@ -0,0 +1,411 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Elements
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AnnotationTextStyle = exports.TextAnnotation3d = exports.TextAnnotation2d = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const Element_1 = require("../Element");
13
+ const core_bentley_1 = require("@itwin/core-bentley");
14
+ const TextBlockLayout_1 = require("./TextBlockLayout");
15
+ const TextAnnotationGeometry_1 = require("./TextAnnotationGeometry");
16
+ const ElementDrivesTextAnnotation_1 = require("./ElementDrivesTextAnnotation");
17
+ function parseTextAnnotationData(json) {
18
+ if (!json)
19
+ return undefined;
20
+ try {
21
+ return JSON.parse(json);
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ }
27
+ function getElementGeometryBuilderParams(iModel, modelId, _placementProps, stringifiedAnnotationProps, categoryId, _subCategory) {
28
+ const annotationProps = parseTextAnnotationData(stringifiedAnnotationProps);
29
+ const textBlock = core_common_1.TextAnnotation.fromJSON(annotationProps).textBlock;
30
+ const textStyleResolver = new TextBlockLayout_1.TextStyleResolver({ textBlock, iModel, modelId });
31
+ const layout = (0, TextBlockLayout_1.layoutTextBlock)({ iModel, textBlock, textStyleResolver });
32
+ const builder = new core_common_1.ElementGeometry.Builder();
33
+ (0, TextAnnotationGeometry_1.appendTextAnnotationGeometry)({ layout, textStyleResolver, annotationProps: annotationProps ?? {}, builder, categoryId });
34
+ return { entryArray: builder.entries };
35
+ }
36
+ /** An element that displays textual content within a 2d model.
37
+ * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
38
+ * @see [[setAnnotation]] to change the textual content.
39
+ * @public @preview
40
+ */
41
+ class TextAnnotation2d extends Element_1.AnnotationElement2d /* implements ITextAnnotation */ {
42
+ /** @internal */
43
+ static get className() { return "TextAnnotation2d"; }
44
+ /** Optional string containing the data associated with the text annotation. */
45
+ _textAnnotationData;
46
+ /** Extract the textual content, if present.
47
+ * @see [[setAnnotation]] to change it.
48
+ */
49
+ getAnnotation() {
50
+ const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);
51
+ return textAnnotationProps ? core_common_1.TextAnnotation.fromJSON(textAnnotationProps) : undefined;
52
+ }
53
+ /** Change the textual content of the `TextAnnotation2d`.
54
+ * @see [[getAnnotation]] to extract the current annotation.
55
+ * @param annotation The new annotation
56
+ */
57
+ setAnnotation(annotation) {
58
+ this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;
59
+ }
60
+ constructor(props, iModel) {
61
+ super(props, iModel);
62
+ this._textAnnotationData = props.textAnnotationData;
63
+ }
64
+ /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */
65
+ static fromJSON(props, iModel) {
66
+ return new TextAnnotation2d(props, iModel);
67
+ }
68
+ /**
69
+ * Converts the current `TextAnnotation2d` instance to its JSON representation.
70
+ * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
71
+
72
+ * @inheritdoc
73
+ */
74
+ toJSON() {
75
+ const props = super.toJSON();
76
+ props.textAnnotationData = this._textAnnotationData;
77
+ if (this._textAnnotationData) {
78
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
79
+ }
80
+ return props;
81
+ }
82
+ /** Creates a new `TextAnnotation2d` instance with the specified properties.
83
+ * @param iModelDb The iModel.
84
+ * @param category The category ID for the annotation.
85
+ * @param model The model ID where the annotation will be placed.
86
+ * @param placement The placement properties for the annotation.
87
+ * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.
88
+ * @param code Optional code for the element.
89
+ */
90
+ static create(iModelDb, category, model, placement, textAnnotationData, code) {
91
+ const props = {
92
+ classFullName: this.classFullName,
93
+ textAnnotationData: JSON.stringify(textAnnotationData),
94
+ placement,
95
+ model,
96
+ category,
97
+ code: code ?? core_common_1.Code.createEmpty(),
98
+ };
99
+ return new this(props, iModelDb);
100
+ }
101
+ /**
102
+ * Updates the geometry of the TextAnnotation2d on insert.
103
+ * @inheritdoc
104
+ * @beta
105
+ */
106
+ static onInsert(arg) {
107
+ super.onInsert(arg);
108
+ this.updateGeometry(arg.iModel, arg.props);
109
+ }
110
+ /**
111
+ * Updates the geometry of the TextAnnotation2d on update.
112
+ * @inheritdoc
113
+ * @beta
114
+ */
115
+ static onUpdate(arg) {
116
+ super.onUpdate(arg);
117
+ this.updateGeometry(arg.iModel, arg.props);
118
+ }
119
+ /**
120
+ * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).
121
+ * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
122
+ */
123
+ static updateGeometry(iModelDb, props) {
124
+ if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
125
+ return;
126
+ }
127
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? core_common_1.Placement2d.fromJSON(), props.textAnnotationData, props.category);
128
+ }
129
+ /**
130
+ * Collects reference IDs used by this `TextAnnotation2d`.
131
+ * @inheritdoc
132
+ */
133
+ collectReferenceIds(ids) {
134
+ super.collectReferenceIds(ids);
135
+ const annotation = this.getAnnotation();
136
+ if (!annotation) {
137
+ return;
138
+ }
139
+ if (annotation.textBlock.styleId)
140
+ ids.addElement(annotation.textBlock.styleId);
141
+ }
142
+ /** @internal */
143
+ getTextBlocks() {
144
+ return getTextBlocks(this);
145
+ }
146
+ /** @internal */
147
+ updateTextBlocks(textBlocks) {
148
+ return updateTextBlocks(this, textBlocks);
149
+ }
150
+ /** @internal */
151
+ static onInserted(arg) {
152
+ super.onInserted(arg);
153
+ ElementDrivesTextAnnotation_1.ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
154
+ }
155
+ /** @internal */
156
+ static onUpdated(arg) {
157
+ super.onUpdated(arg);
158
+ ElementDrivesTextAnnotation_1.ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
159
+ }
160
+ }
161
+ exports.TextAnnotation2d = TextAnnotation2d;
162
+ /** An element that displays textual content within a 3d model.
163
+ * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
164
+ * @see [[setAnnotation]] to change the textual content.
165
+ * @public @preview
166
+ */
167
+ class TextAnnotation3d extends Element_1.GraphicalElement3d /* implements ITextAnnotation */ {
168
+ /** @internal */
169
+ static get className() { return "TextAnnotation3d"; }
170
+ /** Optional string containing the data associated with the text annotation. */
171
+ _textAnnotationData;
172
+ /** Extract the textual content, if present.
173
+ * @see [[setAnnotation]] to change it.
174
+ */
175
+ getAnnotation() {
176
+ const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);
177
+ return textAnnotationProps ? core_common_1.TextAnnotation.fromJSON(textAnnotationProps) : undefined;
178
+ }
179
+ /** Change the textual content of the `TextAnnotation3d`.
180
+ * @see [[getAnnotation]] to extract the current annotation.
181
+ * @param annotation The new annotation
182
+ */
183
+ setAnnotation(annotation) {
184
+ this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;
185
+ }
186
+ constructor(props, iModel) {
187
+ super(props, iModel);
188
+ this._textAnnotationData = props.textAnnotationData;
189
+ }
190
+ /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */
191
+ static fromJSON(props, iModel) {
192
+ return new TextAnnotation3d(props, iModel);
193
+ }
194
+ /**
195
+ * Converts the current `TextAnnotation3d` instance to its JSON representation.
196
+ * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
197
+ * @inheritdoc
198
+ */
199
+ toJSON() {
200
+ const props = super.toJSON();
201
+ props.textAnnotationData = this._textAnnotationData;
202
+ if (this._textAnnotationData) {
203
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
204
+ }
205
+ return props;
206
+ }
207
+ /** Creates a new `TextAnnotation3d` instance with the specified properties.
208
+ * @param iModelDb The iModel.
209
+ * @param category The category ID for the annotation.
210
+ * @param model The model ID where the annotation will be placed.
211
+ * @param placement The placement properties for the annotation.
212
+ * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.
213
+ * @param code Optional code for the element.
214
+ */
215
+ static create(iModelDb, category, model, placement, textAnnotationData, code) {
216
+ const props = {
217
+ classFullName: this.classFullName,
218
+ textAnnotationData: JSON.stringify(textAnnotationData),
219
+ placement,
220
+ model,
221
+ category,
222
+ code: code ?? core_common_1.Code.createEmpty(),
223
+ };
224
+ return new this(props, iModelDb);
225
+ }
226
+ /**
227
+ * Updates the geometry of the TextAnnotation3d on insert.
228
+ * @inheritdoc
229
+ * @beta
230
+ */
231
+ static onInsert(arg) {
232
+ super.onInsert(arg);
233
+ this.updateGeometry(arg.iModel, arg.props);
234
+ }
235
+ /**
236
+ * Updates the geometry of the TextAnnotation3d on update.
237
+ * @inheritdoc
238
+ * @beta
239
+ */
240
+ static onUpdate(arg) {
241
+ super.onUpdate(arg);
242
+ this.updateGeometry(arg.iModel, arg.props);
243
+ }
244
+ /**
245
+ * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).
246
+ * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
247
+ */
248
+ static updateGeometry(iModelDb, props) {
249
+ if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
250
+ return;
251
+ }
252
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? core_common_1.Placement3d.fromJSON(), props.textAnnotationData, props.category);
253
+ }
254
+ /**
255
+ * Collects reference IDs used by this `TextAnnotation3d`.
256
+ * @inheritdoc
257
+ */
258
+ collectReferenceIds(ids) {
259
+ super.collectReferenceIds(ids);
260
+ const annotation = this.getAnnotation();
261
+ if (!annotation) {
262
+ return;
263
+ }
264
+ if (annotation.textBlock.styleId)
265
+ ids.addElement(annotation.textBlock.styleId);
266
+ }
267
+ /** @internal */
268
+ getTextBlocks() {
269
+ return getTextBlocks(this);
270
+ }
271
+ /** @internal */
272
+ updateTextBlocks(textBlocks) {
273
+ return updateTextBlocks(this, textBlocks);
274
+ }
275
+ /** @internal */
276
+ static onInserted(arg) {
277
+ super.onInserted(arg);
278
+ ElementDrivesTextAnnotation_1.ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
279
+ }
280
+ /** @internal */
281
+ static onUpdated(arg) {
282
+ super.onUpdated(arg);
283
+ ElementDrivesTextAnnotation_1.ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
284
+ }
285
+ }
286
+ exports.TextAnnotation3d = TextAnnotation3d;
287
+ function getTextBlocks(elem) {
288
+ const annotation = elem.getAnnotation();
289
+ return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];
290
+ }
291
+ function updateTextBlocks(elem, textBlocks) {
292
+ (0, core_bentley_1.assert)(textBlocks.length === 1);
293
+ (0, core_bentley_1.assert)(textBlocks[0].id === undefined);
294
+ const annotation = elem.getAnnotation();
295
+ if (!annotation) {
296
+ // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if
297
+ // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.
298
+ throw new Error("Text annotation element has no text");
299
+ }
300
+ annotation.textBlock = textBlocks[0].textBlock;
301
+ elem.setAnnotation(annotation);
302
+ elem.update();
303
+ }
304
+ /**
305
+ * The definition element that holds text style information.
306
+ * The style is stored as a [TextStyleSettings]($common).
307
+ * @beta
308
+ */
309
+ class AnnotationTextStyle extends Element_1.DefinitionElement {
310
+ /** @internal */
311
+ static get className() { return "AnnotationTextStyle"; }
312
+ /**
313
+ * Optional text describing the `AnnotationTextStyle`.
314
+ */
315
+ description;
316
+ /**
317
+ * The text style settings for the `AnnotationTextStyle`.
318
+ * @see [[TextStyleSettings]] for more information.
319
+ */
320
+ settings;
321
+ constructor(props, iModel) {
322
+ super(props, iModel);
323
+ this.description = props.description;
324
+ const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);
325
+ this.settings = core_common_1.TextStyleSettings.fromJSON(settingsProps);
326
+ }
327
+ /**
328
+ * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.
329
+ *
330
+ * @param iModel - The IModelDb.
331
+ * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.
332
+ * @param name - The AnnotationTextStyle name.
333
+ */
334
+ static createCode(iModel, definitionModelId, name) {
335
+ const codeSpec = iModel.codeSpecs.getByName(core_common_1.BisCodeSpec.annotationTextStyle);
336
+ return new core_common_1.Code({ spec: codeSpec.id, scope: definitionModelId, value: name });
337
+ }
338
+ /**
339
+ * Creates a new instance of `AnnotationTextStyle` with the specified properties.
340
+ *
341
+ * @param iModelDb - The iModelDb.
342
+ * @param definitionModelId - The ID of the [[DefinitionModel]].
343
+ * @param name - The name to assign to the `AnnotationTextStyle`.
344
+ * @param settings - Optional text style settings used to create the `AnnotationTextStyle`. Default settings will be used if not provided.
345
+ * @param description - Optional description for the `AnnotationTextStyle`.
346
+ */
347
+ static create(iModelDb, definitionModelId, name, settings, description) {
348
+ const props = {
349
+ classFullName: this.classFullName,
350
+ model: definitionModelId,
351
+ code: this.createCode(iModelDb, definitionModelId, name).toJSON(),
352
+ description,
353
+ settings: JSON.stringify(settings),
354
+ };
355
+ return new this(props, iModelDb);
356
+ }
357
+ /**
358
+ * Converts the current `AnnotationTextStyle` instance to its JSON representation.
359
+ * @inheritdoc
360
+ */
361
+ toJSON() {
362
+ const props = super.toJSON();
363
+ props.description = this.description;
364
+ props.settings = JSON.stringify(this.settings.toJSON());
365
+ return props;
366
+ }
367
+ /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */
368
+ static fromJSON(props, iModel) {
369
+ return new AnnotationTextStyle(props, iModel);
370
+ }
371
+ /**
372
+ * Validates that the AnnotationTextStyle's settings are valid before insert.
373
+ * @inheritdoc
374
+ * @beta
375
+ */
376
+ static onInsert(arg) {
377
+ super.onInsert(arg);
378
+ this.validateSettings(arg.props);
379
+ }
380
+ /**
381
+ * Validates that the AnnotationTextStyle's settings are valid before update.
382
+ * @inheritdoc
383
+ * @beta
384
+ */
385
+ static onUpdate(arg) {
386
+ super.onUpdate(arg);
387
+ this.validateSettings(arg.props);
388
+ }
389
+ static validateSettings(props) {
390
+ const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);
391
+ if (!settingProps)
392
+ return;
393
+ const settings = core_common_1.TextStyleSettings.fromJSON(settingProps);
394
+ const errors = settings.getValidationErrors();
395
+ if (errors.length > 0) {
396
+ throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(", ")}`);
397
+ }
398
+ }
399
+ static parseTextStyleSettings(json) {
400
+ if (!json)
401
+ return undefined;
402
+ try {
403
+ return JSON.parse(json);
404
+ }
405
+ catch {
406
+ return undefined;
407
+ }
408
+ }
409
+ }
410
+ exports.AnnotationTextStyle = AnnotationTextStyle;
411
+ //# sourceMappingURL=TextAnnotationElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAqY;AAErY,wCAA2H;AAC3H,sDAAyD;AACzD,uDAAuE;AACvE,qEAAwE;AACxE,+EAA4F;AAE5F,SAAS,uBAAuB,CAAC,IAAwB;IACvD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,+BA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","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 Elements\n */\n\nimport { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\n\nfunction parseTextAnnotationData(json: string | undefined): TextAnnotationProps | undefined {\n if (!json) return undefined;\n try {\n return JSON.parse(json);\n } catch {\n return undefined;\n }\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, _placementProps: PlacementProps, stringifiedAnnotationProps: string, categoryId: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const annotationProps = parseTextAnnotationData(stringifiedAnnotationProps);\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({textBlock, iModel, modelId});\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n appendTextAnnotationGeometry({ layout, textStyleResolver, annotationProps: annotationProps ?? {}, builder, categoryId })\n\n return { entryArray: builder.entries };\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /** Optional string containing the data associated with the text annotation. */\n private _textAnnotationData?: string;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);\n return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n this._textAnnotationData = props.textAnnotationData;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationData;\n if (this._textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param category The category ID for the annotation.\n * @param model The model ID where the annotation will be placed.\n * @param placement The placement properties for the annotation.\n * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.\n * @param code Optional code for the element.\n */\n public static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement2dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation2d {\n const props: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: JSON.stringify(textAnnotationData),\n placement,\n model,\n category,\n code: code ?? Code.createEmpty(),\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation2dProps);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation2dProps);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n */\n protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation2dProps): void {\n if (props.elementGeometryBuilderParams || !props.textAnnotationData) {\n return;\n }\n\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement2d.fromJSON(), props.textAnnotationData, props.category);\n }\n\n /**\n * Collects reference IDs used by this `TextAnnotation2d`.\n * @inheritdoc\n */\n protected override collectReferenceIds(ids: EntityReferenceSet): void {\n super.collectReferenceIds(ids);\n const annotation = this.getAnnotation();\n if (!annotation) {\n return;\n }\n if (annotation.textBlock.styleId)\n ids.addElement(annotation.textBlock.styleId);\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /** Optional string containing the data associated with the text annotation. */\n private _textAnnotationData?: string;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);\n return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n this._textAnnotationData = props.textAnnotationData;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationData;\n if (this._textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param category The category ID for the annotation.\n * @param model The model ID where the annotation will be placed.\n * @param placement The placement properties for the annotation.\n * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.\n * @param code Optional code for the element.\n */\n public static create(iModelDb: IModelDb, category: Id64String, model: Id64String, placement: Placement3dProps, textAnnotationData?: TextAnnotationProps, code?: CodeProps): TextAnnotation3d {\n const props: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: JSON.stringify(textAnnotationData),\n placement,\n model,\n category,\n code: code ?? Code.createEmpty(),\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation3dProps);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.updateGeometry(arg.iModel, arg.props as TextAnnotation3dProps);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n */\n protected static updateGeometry(iModelDb: IModelDb, props: TextAnnotation3dProps): void {\n if (props.elementGeometryBuilderParams || !props.textAnnotationData) {\n return;\n }\n\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement3d.fromJSON(), props.textAnnotationData, props.category);\n }\n\n /**\n * Collects reference IDs used by this `TextAnnotation3d`.\n * @inheritdoc\n */\n protected override collectReferenceIds(ids: EntityReferenceSet): void {\n super.collectReferenceIds(ids);\n const annotation = this.getAnnotation();\n if (!annotation) {\n return;\n }\n if (annotation.textBlock.styleId)\n ids.addElement(annotation.textBlock.styleId);\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n elem.update();\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param definitionModelId - The ID of the [[DefinitionModel]].\n * @param name - The name to assign to the `AnnotationTextStyle`.\n * @param settings - Optional text style settings used to create the `AnnotationTextStyle`. Default settings will be used if not provided.\n * @param description - Optional description for the `AnnotationTextStyle`.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, settings?: TextStyleSettingsProps, description?: string) {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name).toJSON(),\n description,\n settings: JSON.stringify(settings),\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify(this.settings.toJSON());\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n private static parseTextStyleSettings(json: string | undefined): TextStyleSettingsProps | undefined {\n if (!json) return undefined;\n try {\n return JSON.parse(json);\n } catch {\n return undefined;\n }\n }\n}\n\n\n"]}
@@ -0,0 +1,33 @@
1
+ /** @packageDocumentation
2
+ * @module ElementGeometry
3
+ */
4
+ import { ElementGeometry, TextAnnotationProps } from "@itwin/core-common";
5
+ import { TextBlockLayout, TextStyleResolver } from "./TextBlockLayout";
6
+ import { Id64String } from "@itwin/core-bentley";
7
+ /**
8
+ * Properties required to compute the geometry of a text annotation.
9
+ * @beta
10
+ * @see [[appendTextAnnotationGeometry]] to append the geometry to an [[ElementGeometry.Builder]].
11
+ */
12
+ export interface AppendTextAnnotationGeometryArgs {
13
+ /** The annotation to be drawn. Be sure to include a TextBlock with runs or no geometry will be produced. */
14
+ annotationProps: TextAnnotationProps;
15
+ /** Layout provided by calling [[layoutTextBlock]] */
16
+ layout: TextBlockLayout;
17
+ /** [[TextStyleResolver]] used to get styling and scale information for creating geometry. */
18
+ textStyleResolver: TextStyleResolver;
19
+ /** Builder that will be added to in place */
20
+ builder: ElementGeometry.Builder;
21
+ /** The category the element will belong to. This will passed into the [[GeometryParams]] */
22
+ categoryId: Id64String;
23
+ /** The optional sub-category the element will belong to. This will passed into the [[GeometryParams]] */
24
+ subCategoryId?: Id64String;
25
+ /** Whether or not to draw geometry for things like the snap points, range, and anchor point */
26
+ wantDebugGeometry?: boolean;
27
+ }
28
+ /** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.
29
+ * @returns true if the geometry was successfully appended.
30
+ * @beta
31
+ */
32
+ export declare function appendTextAnnotationGeometry(props: AppendTextAnnotationGeometryArgs): boolean;
33
+ //# sourceMappingURL=TextAnnotationGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,eAAe,EAA+C,mBAAmB,EAAqB,MAAM,oBAAoB,CAAC;AACpJ,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,4GAA4G;IAC5G,eAAe,EAAE,mBAAmB,CAAC;IACrC,qDAAqD;IACrD,MAAM,EAAE,eAAe,CAAC;IACxB,6FAA6F;IAC7F,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,6CAA6C;IAC7C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IACjC,4FAA4F;IAC5F,UAAU,EAAE,UAAU,CAAA;IACtB,yGAAyG;IACzG,aAAa,CAAC,EAAE,UAAU,CAAA;IAC1B,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,gCAAgC,GAAG,OAAO,CA8B7F"}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module ElementGeometry
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.appendTextAnnotationGeometry = appendTextAnnotationGeometry;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const core_geometry_1 = require("@itwin/core-geometry");
13
+ const core_bentley_1 = require("@itwin/core-bentley");
14
+ const TextBlockGeometry_1 = require("./TextBlockGeometry");
15
+ const FrameGeometry_1 = require("./FrameGeometry");
16
+ const LeaderGeometry_1 = require("./LeaderGeometry");
17
+ /** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.
18
+ * @returns true if the geometry was successfully appended.
19
+ * @beta
20
+ */
21
+ function appendTextAnnotationGeometry(props) {
22
+ const annotation = core_common_1.TextAnnotation.fromJSON(props.annotationProps);
23
+ const transform = annotation.computeTransform(props.layout.range, props.textStyleResolver.scaleFactor);
24
+ let result = true;
25
+ // Construct the TextBlockGeometry
26
+ const params = new core_common_1.GeometryParams(props.categoryId, props.subCategoryId);
27
+ const entries = (0, TextBlockGeometry_1.produceTextBlockGeometry)(props.layout, transform.clone());
28
+ result = result && props.builder.appendTextBlock(entries, params);
29
+ // Construct the frame geometry
30
+ if (props.textStyleResolver.blockSettings.frame.shape !== "none") {
31
+ result = result && (0, FrameGeometry_1.appendFrameToBuilder)(props.builder, props.textStyleResolver.blockSettings.frame, props.layout.range, transform.clone(), params);
32
+ }
33
+ // Construct the leader geometry
34
+ if (annotation.leaders && annotation.leaders.length > 0) {
35
+ result = result && (0, LeaderGeometry_1.appendLeadersToBuilder)(props.builder, annotation.leaders, props.layout, transform.clone(), params, props.textStyleResolver);
36
+ }
37
+ // Construct the debug geometry
38
+ if (props.wantDebugGeometry) {
39
+ result = result && debugAnchorPoint(props.builder, annotation, props.layout, transform.clone());
40
+ result = result && debugRunLayout(props.builder, props.layout, transform.clone());
41
+ if (props.textStyleResolver.blockSettings.frame.shape !== "none")
42
+ result = result && debugSnapPoints(props.builder, props.textStyleResolver.blockSettings, props.layout.range, transform.clone());
43
+ }
44
+ return result;
45
+ }
46
+ ;
47
+ /**
48
+ * Draws the anchor point and margins of the text annotation.
49
+ * The anchor point is the point around which the text rotates and is drawn as a blue x (1m by 1m).
50
+ * The margins are drawn as a blue box.
51
+ * The text range is drawn as a red box.
52
+ */
53
+ function debugAnchorPoint(builder, annotation, layout, transform) {
54
+ const range = core_geometry_1.Range2d.fromJSON(layout.range);
55
+ const debugAnchorPt = transform.multiplyPoint3d(annotation.computeAnchorPoint(range));
56
+ // Make it blue
57
+ const blueLineParams = new core_common_1.GeometryParams(core_bentley_1.Id64.invalid);
58
+ blueLineParams.lineColor = core_common_1.ColorDef.blue;
59
+ let result = builder.appendGeometryParamsChange(blueLineParams);
60
+ // Draw a blue box to show the element's margin
61
+ const marginCorners = range.corners3d(true);
62
+ transform.multiplyPoint3dArrayInPlace(marginCorners);
63
+ result = result && builder.appendGeometryQuery(core_geometry_1.LineString3d.create(marginCorners));
64
+ // Draw a blue x to show the anchor point - Rotation occurs around this point. The x will be 1 m by 1 m.
65
+ result = result && builder.appendGeometryQuery(core_geometry_1.LineString3d.create(debugAnchorPt.plusXYZ(-1, -1), debugAnchorPt.plusXYZ(1, 1)));
66
+ result = result && builder.appendGeometryQuery(core_geometry_1.LineString3d.create(debugAnchorPt.plusXYZ(1, -1), debugAnchorPt.plusXYZ(-1, 1)));
67
+ // Draw a red box to show the text range
68
+ const redLineParams = new core_common_1.GeometryParams(core_bentley_1.Id64.invalid);
69
+ redLineParams.lineColor = core_common_1.ColorDef.red;
70
+ result = result && builder.appendGeometryParamsChange(redLineParams);
71
+ const rangeCorners = layout.textRange.corners3d(true);
72
+ transform.multiplyPoint3dArrayInPlace(rangeCorners);
73
+ result = result && builder.appendGeometryQuery(core_geometry_1.LineString3d.create(rangeCorners));
74
+ return result;
75
+ }
76
+ /** Draws the interval points defined by calling [[computeIntervalPoints]]. The points are shown as black dots 5x larger than the borderWeight */
77
+ function debugSnapPoints(builder, style, range, transform) {
78
+ if (style.frame.shape === "none")
79
+ return false;
80
+ const points = (0, FrameGeometry_1.computeIntervalPoints)({ frame: style.frame.shape, range, transform, lineIntervalFactor: 0.5, arcIntervalFactor: 0.25 });
81
+ const params = new core_common_1.GeometryParams(core_bentley_1.Id64.invalid);
82
+ params.lineColor = core_common_1.ColorDef.black;
83
+ params.weight = style.frame.borderWeight * 5; // We want the dots to be bigger than the frame so we can see them.
84
+ params.fillDisplay = core_common_1.FillDisplay.Always;
85
+ const result = builder.appendGeometryParamsChange(params) && builder.appendGeometryQuery(core_geometry_1.PointString3d.create(points));
86
+ return result;
87
+ }
88
+ /**
89
+ * Draws debug geometry for each line and run in a TextBlockLayout.
90
+ *
91
+ * For each line and run, this function draws boxes to visualize their layout and boundaries.
92
+ * Different run types (e.g., text, linebreak, fraction, tab) are assigned distinct colors for clarity.
93
+ * This is useful for debugging text layout and alignment issues.
94
+ *
95
+ * @param builder - The geometry builder to append debug geometry to.
96
+ * @param layout - The text block layout containing lines and runs to visualize.
97
+ * @param documentTransform - The transform to apply to the entire document.
98
+ * @returns True if all debug geometry was successfully appended.
99
+ */
100
+ function debugRunLayout(builder, layout, documentTransform) {
101
+ let result = true; // Tracks if all geometry was appended successfully
102
+ let color = core_common_1.ColorDef.black; // Current color for the run type
103
+ let lastColor = color; // Last color used, to minimize param changes
104
+ // Map run types to debug colors
105
+ const colors = {
106
+ "text": core_common_1.ColorDef.fromString("orange"),
107
+ "linebreak": core_common_1.ColorDef.fromString("yellow"),
108
+ "fraction": core_common_1.ColorDef.fromString("green"),
109
+ "tab": core_common_1.ColorDef.fromString("aquamarine"),
110
+ "field": core_common_1.ColorDef.fromString("purple"),
111
+ };
112
+ layout.lines.forEach(line => {
113
+ // Apply the line's offset transform
114
+ const lineTrans = core_geometry_1.Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);
115
+ documentTransform.multiplyTransformTransform(lineTrans, lineTrans);
116
+ line.runs.forEach(run => {
117
+ // Determine color for this run type
118
+ color = colors[run.source.type] ?? core_common_1.ColorDef.black;
119
+ // Only change geometry params if the color changes
120
+ if (!lastColor.equals(color)) {
121
+ const colorParams = new core_common_1.GeometryParams(core_bentley_1.Id64.invalid);
122
+ colorParams.lineColor = color;
123
+ result = result && builder.appendGeometryParamsChange(colorParams);
124
+ lastColor = color;
125
+ }
126
+ // Apply the line's offset to the run's offset
127
+ const runTrans = core_geometry_1.Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);
128
+ lineTrans.multiplyTransformTransform(runTrans, runTrans);
129
+ // Draw the enclosing range for the run
130
+ const runCorners = run.range.corners3d(true);
131
+ runTrans.multiplyPoint3dArrayInPlace(runCorners);
132
+ result = result && builder.appendGeometryQuery(core_geometry_1.LineString3d.create(runCorners));
133
+ });
134
+ });
135
+ return result;
136
+ }
137
+ //# sourceMappingURL=TextAnnotationGeometry.js.map