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

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 +117 -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 +22 -16
  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,405 @@
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 Elements
7
+ */
8
+ import { BisCodeSpec, Code, ElementGeometry, Placement2d, Placement3d, TextAnnotation, TextStyleSettings } from "@itwin/core-common";
9
+ import { AnnotationElement2d, DefinitionElement, GraphicalElement3d } from "../Element";
10
+ import { assert } from "@itwin/core-bentley";
11
+ import { layoutTextBlock, TextStyleResolver } from "./TextBlockLayout";
12
+ import { appendTextAnnotationGeometry } from "./TextAnnotationGeometry";
13
+ import { ElementDrivesTextAnnotation } from "./ElementDrivesTextAnnotation";
14
+ function parseTextAnnotationData(json) {
15
+ if (!json)
16
+ return undefined;
17
+ try {
18
+ return JSON.parse(json);
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
24
+ function getElementGeometryBuilderParams(iModel, modelId, _placementProps, stringifiedAnnotationProps, categoryId, _subCategory) {
25
+ const annotationProps = parseTextAnnotationData(stringifiedAnnotationProps);
26
+ const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;
27
+ const textStyleResolver = new TextStyleResolver({ textBlock, iModel, modelId });
28
+ const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });
29
+ const builder = new ElementGeometry.Builder();
30
+ appendTextAnnotationGeometry({ layout, textStyleResolver, annotationProps: annotationProps ?? {}, builder, categoryId });
31
+ return { entryArray: builder.entries };
32
+ }
33
+ /** An element that displays textual content within a 2d model.
34
+ * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
35
+ * @see [[setAnnotation]] to change the textual content.
36
+ * @public @preview
37
+ */
38
+ export class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {
39
+ /** @internal */
40
+ static get className() { return "TextAnnotation2d"; }
41
+ /** Optional string containing the data associated with the text annotation. */
42
+ _textAnnotationData;
43
+ /** Extract the textual content, if present.
44
+ * @see [[setAnnotation]] to change it.
45
+ */
46
+ getAnnotation() {
47
+ const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);
48
+ return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;
49
+ }
50
+ /** Change the textual content of the `TextAnnotation2d`.
51
+ * @see [[getAnnotation]] to extract the current annotation.
52
+ * @param annotation The new annotation
53
+ */
54
+ setAnnotation(annotation) {
55
+ this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;
56
+ }
57
+ constructor(props, iModel) {
58
+ super(props, iModel);
59
+ this._textAnnotationData = props.textAnnotationData;
60
+ }
61
+ /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */
62
+ static fromJSON(props, iModel) {
63
+ return new TextAnnotation2d(props, iModel);
64
+ }
65
+ /**
66
+ * Converts the current `TextAnnotation2d` instance to its JSON representation.
67
+ * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
68
+
69
+ * @inheritdoc
70
+ */
71
+ toJSON() {
72
+ const props = super.toJSON();
73
+ props.textAnnotationData = this._textAnnotationData;
74
+ if (this._textAnnotationData) {
75
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
76
+ }
77
+ return props;
78
+ }
79
+ /** Creates a new `TextAnnotation2d` instance with the specified properties.
80
+ * @param iModelDb The iModel.
81
+ * @param category The category ID for the annotation.
82
+ * @param model The model ID where the annotation will be placed.
83
+ * @param placement The placement properties for the annotation.
84
+ * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided.
85
+ * @param code Optional code for the element.
86
+ */
87
+ static create(iModelDb, category, model, placement, textAnnotationData, code) {
88
+ const props = {
89
+ classFullName: this.classFullName,
90
+ textAnnotationData: JSON.stringify(textAnnotationData),
91
+ placement,
92
+ model,
93
+ category,
94
+ code: code ?? Code.createEmpty(),
95
+ };
96
+ return new this(props, iModelDb);
97
+ }
98
+ /**
99
+ * Updates the geometry of the TextAnnotation2d on insert.
100
+ * @inheritdoc
101
+ * @beta
102
+ */
103
+ static onInsert(arg) {
104
+ super.onInsert(arg);
105
+ this.updateGeometry(arg.iModel, arg.props);
106
+ }
107
+ /**
108
+ * Updates the geometry of the TextAnnotation2d on update.
109
+ * @inheritdoc
110
+ * @beta
111
+ */
112
+ static onUpdate(arg) {
113
+ super.onUpdate(arg);
114
+ this.updateGeometry(arg.iModel, arg.props);
115
+ }
116
+ /**
117
+ * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).
118
+ * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
119
+ */
120
+ static updateGeometry(iModelDb, props) {
121
+ if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
122
+ return;
123
+ }
124
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement2d.fromJSON(), props.textAnnotationData, props.category);
125
+ }
126
+ /**
127
+ * Collects reference IDs used by this `TextAnnotation2d`.
128
+ * @inheritdoc
129
+ */
130
+ collectReferenceIds(ids) {
131
+ super.collectReferenceIds(ids);
132
+ const annotation = this.getAnnotation();
133
+ if (!annotation) {
134
+ return;
135
+ }
136
+ if (annotation.textBlock.styleId)
137
+ ids.addElement(annotation.textBlock.styleId);
138
+ }
139
+ /** @internal */
140
+ getTextBlocks() {
141
+ return getTextBlocks(this);
142
+ }
143
+ /** @internal */
144
+ updateTextBlocks(textBlocks) {
145
+ return updateTextBlocks(this, textBlocks);
146
+ }
147
+ /** @internal */
148
+ static onInserted(arg) {
149
+ super.onInserted(arg);
150
+ ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
151
+ }
152
+ /** @internal */
153
+ static onUpdated(arg) {
154
+ super.onUpdated(arg);
155
+ ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
156
+ }
157
+ }
158
+ /** An element that displays textual content within a 3d model.
159
+ * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.
160
+ * @see [[setAnnotation]] to change the textual content.
161
+ * @public @preview
162
+ */
163
+ export class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {
164
+ /** @internal */
165
+ static get className() { return "TextAnnotation3d"; }
166
+ /** Optional string containing the data associated with the text annotation. */
167
+ _textAnnotationData;
168
+ /** Extract the textual content, if present.
169
+ * @see [[setAnnotation]] to change it.
170
+ */
171
+ getAnnotation() {
172
+ const textAnnotationProps = parseTextAnnotationData(this._textAnnotationData);
173
+ return textAnnotationProps ? TextAnnotation.fromJSON(textAnnotationProps) : undefined;
174
+ }
175
+ /** Change the textual content of the `TextAnnotation3d`.
176
+ * @see [[getAnnotation]] to extract the current annotation.
177
+ * @param annotation The new annotation
178
+ */
179
+ setAnnotation(annotation) {
180
+ this._textAnnotationData = annotation ? JSON.stringify(annotation.toJSON()) : undefined;
181
+ }
182
+ constructor(props, iModel) {
183
+ super(props, iModel);
184
+ this._textAnnotationData = props.textAnnotationData;
185
+ }
186
+ /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */
187
+ static fromJSON(props, iModel) {
188
+ return new TextAnnotation3d(props, iModel);
189
+ }
190
+ /**
191
+ * Converts the current `TextAnnotation3d` instance to its JSON representation.
192
+ * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.
193
+ * @inheritdoc
194
+ */
195
+ toJSON() {
196
+ const props = super.toJSON();
197
+ props.textAnnotationData = this._textAnnotationData;
198
+ if (this._textAnnotationData) {
199
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.placement, this._textAnnotationData, this.category);
200
+ }
201
+ return props;
202
+ }
203
+ /** Creates a new `TextAnnotation3d` instance with the specified properties.
204
+ * @param iModelDb The iModel.
205
+ * @param category The category ID for the annotation.
206
+ * @param model The model ID where the annotation will be placed.
207
+ * @param placement The placement properties for the annotation.
208
+ * @param textAnnotationData Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided.
209
+ * @param code Optional code for the element.
210
+ */
211
+ static create(iModelDb, category, model, placement, textAnnotationData, code) {
212
+ const props = {
213
+ classFullName: this.classFullName,
214
+ textAnnotationData: JSON.stringify(textAnnotationData),
215
+ placement,
216
+ model,
217
+ category,
218
+ code: code ?? Code.createEmpty(),
219
+ };
220
+ return new this(props, iModelDb);
221
+ }
222
+ /**
223
+ * Updates the geometry of the TextAnnotation3d on insert.
224
+ * @inheritdoc
225
+ * @beta
226
+ */
227
+ static onInsert(arg) {
228
+ super.onInsert(arg);
229
+ this.updateGeometry(arg.iModel, arg.props);
230
+ }
231
+ /**
232
+ * Updates the geometry of the TextAnnotation3d on update.
233
+ * @inheritdoc
234
+ * @beta
235
+ */
236
+ static onUpdate(arg) {
237
+ super.onUpdate(arg);
238
+ this.updateGeometry(arg.iModel, arg.props);
239
+ }
240
+ /**
241
+ * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).
242
+ * It only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.
243
+ */
244
+ static updateGeometry(iModelDb, props) {
245
+ if (props.elementGeometryBuilderParams || !props.textAnnotationData) {
246
+ return;
247
+ }
248
+ props.elementGeometryBuilderParams = getElementGeometryBuilderParams(iModelDb, props.model, props.placement ?? Placement3d.fromJSON(), props.textAnnotationData, props.category);
249
+ }
250
+ /**
251
+ * Collects reference IDs used by this `TextAnnotation3d`.
252
+ * @inheritdoc
253
+ */
254
+ collectReferenceIds(ids) {
255
+ super.collectReferenceIds(ids);
256
+ const annotation = this.getAnnotation();
257
+ if (!annotation) {
258
+ return;
259
+ }
260
+ if (annotation.textBlock.styleId)
261
+ ids.addElement(annotation.textBlock.styleId);
262
+ }
263
+ /** @internal */
264
+ getTextBlocks() {
265
+ return getTextBlocks(this);
266
+ }
267
+ /** @internal */
268
+ updateTextBlocks(textBlocks) {
269
+ return updateTextBlocks(this, textBlocks);
270
+ }
271
+ /** @internal */
272
+ static onInserted(arg) {
273
+ super.onInserted(arg);
274
+ ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
275
+ }
276
+ /** @internal */
277
+ static onUpdated(arg) {
278
+ super.onUpdated(arg);
279
+ ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);
280
+ }
281
+ }
282
+ function getTextBlocks(elem) {
283
+ const annotation = elem.getAnnotation();
284
+ return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];
285
+ }
286
+ function updateTextBlocks(elem, textBlocks) {
287
+ assert(textBlocks.length === 1);
288
+ assert(textBlocks[0].id === undefined);
289
+ const annotation = elem.getAnnotation();
290
+ if (!annotation) {
291
+ // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if
292
+ // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.
293
+ throw new Error("Text annotation element has no text");
294
+ }
295
+ annotation.textBlock = textBlocks[0].textBlock;
296
+ elem.setAnnotation(annotation);
297
+ elem.update();
298
+ }
299
+ /**
300
+ * The definition element that holds text style information.
301
+ * The style is stored as a [TextStyleSettings]($common).
302
+ * @beta
303
+ */
304
+ export class AnnotationTextStyle extends DefinitionElement {
305
+ /** @internal */
306
+ static get className() { return "AnnotationTextStyle"; }
307
+ /**
308
+ * Optional text describing the `AnnotationTextStyle`.
309
+ */
310
+ description;
311
+ /**
312
+ * The text style settings for the `AnnotationTextStyle`.
313
+ * @see [[TextStyleSettings]] for more information.
314
+ */
315
+ settings;
316
+ constructor(props, iModel) {
317
+ super(props, iModel);
318
+ this.description = props.description;
319
+ const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);
320
+ this.settings = TextStyleSettings.fromJSON(settingsProps);
321
+ }
322
+ /**
323
+ * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.
324
+ *
325
+ * @param iModel - The IModelDb.
326
+ * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.
327
+ * @param name - The AnnotationTextStyle name.
328
+ */
329
+ static createCode(iModel, definitionModelId, name) {
330
+ const codeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);
331
+ return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });
332
+ }
333
+ /**
334
+ * Creates a new instance of `AnnotationTextStyle` with the specified properties.
335
+ *
336
+ * @param iModelDb - The iModelDb.
337
+ * @param definitionModelId - The ID of the [[DefinitionModel]].
338
+ * @param name - The name to assign to the `AnnotationTextStyle`.
339
+ * @param settings - Optional text style settings used to create the `AnnotationTextStyle`. Default settings will be used if not provided.
340
+ * @param description - Optional description for the `AnnotationTextStyle`.
341
+ */
342
+ static create(iModelDb, definitionModelId, name, settings, description) {
343
+ const props = {
344
+ classFullName: this.classFullName,
345
+ model: definitionModelId,
346
+ code: this.createCode(iModelDb, definitionModelId, name).toJSON(),
347
+ description,
348
+ settings: JSON.stringify(settings),
349
+ };
350
+ return new this(props, iModelDb);
351
+ }
352
+ /**
353
+ * Converts the current `AnnotationTextStyle` instance to its JSON representation.
354
+ * @inheritdoc
355
+ */
356
+ toJSON() {
357
+ const props = super.toJSON();
358
+ props.description = this.description;
359
+ props.settings = JSON.stringify(this.settings.toJSON());
360
+ return props;
361
+ }
362
+ /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */
363
+ static fromJSON(props, iModel) {
364
+ return new AnnotationTextStyle(props, iModel);
365
+ }
366
+ /**
367
+ * Validates that the AnnotationTextStyle's settings are valid before insert.
368
+ * @inheritdoc
369
+ * @beta
370
+ */
371
+ static onInsert(arg) {
372
+ super.onInsert(arg);
373
+ this.validateSettings(arg.props);
374
+ }
375
+ /**
376
+ * Validates that the AnnotationTextStyle's settings are valid before update.
377
+ * @inheritdoc
378
+ * @beta
379
+ */
380
+ static onUpdate(arg) {
381
+ super.onUpdate(arg);
382
+ this.validateSettings(arg.props);
383
+ }
384
+ static validateSettings(props) {
385
+ const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);
386
+ if (!settingProps)
387
+ return;
388
+ const settings = TextStyleSettings.fromJSON(settingProps);
389
+ const errors = settings.getValidationErrors();
390
+ if (errors.length > 0) {
391
+ throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(", ")}`);
392
+ }
393
+ }
394
+ static parseTextStyleSettings(json) {
395
+ if (!json)
396
+ return undefined;
397
+ try {
398
+ return JSON.parse(json);
399
+ }
400
+ catch {
401
+ return undefined;
402
+ }
403
+ }
404
+ }
405
+ //# 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,OAAO,EAA4B,WAAW,EAAE,IAAI,EAAuC,eAAe,EAAoD,WAAW,EAAoB,WAAW,EAAoC,cAAc,EAAqE,iBAAiB,EAA0B,MAAM,oBAAoB,CAAC;AAErY,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAqC,MAAM,YAAY,CAAC;AAC3H,OAAO,EAAE,MAAM,EAAc,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAkB,MAAM,+BAA+B,CAAC;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,+BAA+B,CAAC,MAAgB,EAAE,OAAmB,EAAE,eAA+B,E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I,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAU,QAAQ,CAAC,GAAsB;QACvD,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAiC,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAU,QAAQ,CAAC,GAAsB;QACvD,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAiC,CAAC,CAAC;IAC/D,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,KAA+B;QAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChF,IAAI,CAAC,YAAY;YAAE,OAAO;QAC1B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QAC9C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,sBAAsB,CAAC,IAAwB;QAC5D,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF","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,134 @@
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 ElementGeometry
7
+ */
8
+ import { ColorDef, FillDisplay, GeometryParams, TextAnnotation } from "@itwin/core-common";
9
+ import { LineString3d, PointString3d, Range2d, Transform } from "@itwin/core-geometry";
10
+ import { Id64 } from "@itwin/core-bentley";
11
+ import { produceTextBlockGeometry } from "./TextBlockGeometry";
12
+ import { appendFrameToBuilder, computeIntervalPoints } from "./FrameGeometry";
13
+ import { appendLeadersToBuilder } from "./LeaderGeometry";
14
+ /** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.
15
+ * @returns true if the geometry was successfully appended.
16
+ * @beta
17
+ */
18
+ export function appendTextAnnotationGeometry(props) {
19
+ const annotation = TextAnnotation.fromJSON(props.annotationProps);
20
+ const transform = annotation.computeTransform(props.layout.range, props.textStyleResolver.scaleFactor);
21
+ let result = true;
22
+ // Construct the TextBlockGeometry
23
+ const params = new GeometryParams(props.categoryId, props.subCategoryId);
24
+ const entries = produceTextBlockGeometry(props.layout, transform.clone());
25
+ result = result && props.builder.appendTextBlock(entries, params);
26
+ // Construct the frame geometry
27
+ if (props.textStyleResolver.blockSettings.frame.shape !== "none") {
28
+ result = result && appendFrameToBuilder(props.builder, props.textStyleResolver.blockSettings.frame, props.layout.range, transform.clone(), params);
29
+ }
30
+ // Construct the leader geometry
31
+ if (annotation.leaders && annotation.leaders.length > 0) {
32
+ result = result && appendLeadersToBuilder(props.builder, annotation.leaders, props.layout, transform.clone(), params, props.textStyleResolver);
33
+ }
34
+ // Construct the debug geometry
35
+ if (props.wantDebugGeometry) {
36
+ result = result && debugAnchorPoint(props.builder, annotation, props.layout, transform.clone());
37
+ result = result && debugRunLayout(props.builder, props.layout, transform.clone());
38
+ if (props.textStyleResolver.blockSettings.frame.shape !== "none")
39
+ result = result && debugSnapPoints(props.builder, props.textStyleResolver.blockSettings, props.layout.range, transform.clone());
40
+ }
41
+ return result;
42
+ }
43
+ ;
44
+ /**
45
+ * Draws the anchor point and margins of the text annotation.
46
+ * The anchor point is the point around which the text rotates and is drawn as a blue x (1m by 1m).
47
+ * The margins are drawn as a blue box.
48
+ * The text range is drawn as a red box.
49
+ */
50
+ function debugAnchorPoint(builder, annotation, layout, transform) {
51
+ const range = Range2d.fromJSON(layout.range);
52
+ const debugAnchorPt = transform.multiplyPoint3d(annotation.computeAnchorPoint(range));
53
+ // Make it blue
54
+ const blueLineParams = new GeometryParams(Id64.invalid);
55
+ blueLineParams.lineColor = ColorDef.blue;
56
+ let result = builder.appendGeometryParamsChange(blueLineParams);
57
+ // Draw a blue box to show the element's margin
58
+ const marginCorners = range.corners3d(true);
59
+ transform.multiplyPoint3dArrayInPlace(marginCorners);
60
+ result = result && builder.appendGeometryQuery(LineString3d.create(marginCorners));
61
+ // Draw a blue x to show the anchor point - Rotation occurs around this point. The x will be 1 m by 1 m.
62
+ result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(-1, -1), debugAnchorPt.plusXYZ(1, 1)));
63
+ result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(1, -1), debugAnchorPt.plusXYZ(-1, 1)));
64
+ // Draw a red box to show the text range
65
+ const redLineParams = new GeometryParams(Id64.invalid);
66
+ redLineParams.lineColor = ColorDef.red;
67
+ result = result && builder.appendGeometryParamsChange(redLineParams);
68
+ const rangeCorners = layout.textRange.corners3d(true);
69
+ transform.multiplyPoint3dArrayInPlace(rangeCorners);
70
+ result = result && builder.appendGeometryQuery(LineString3d.create(rangeCorners));
71
+ return result;
72
+ }
73
+ /** Draws the interval points defined by calling [[computeIntervalPoints]]. The points are shown as black dots 5x larger than the borderWeight */
74
+ function debugSnapPoints(builder, style, range, transform) {
75
+ if (style.frame.shape === "none")
76
+ return false;
77
+ const points = computeIntervalPoints({ frame: style.frame.shape, range, transform, lineIntervalFactor: 0.5, arcIntervalFactor: 0.25 });
78
+ const params = new GeometryParams(Id64.invalid);
79
+ params.lineColor = ColorDef.black;
80
+ params.weight = style.frame.borderWeight * 5; // We want the dots to be bigger than the frame so we can see them.
81
+ params.fillDisplay = FillDisplay.Always;
82
+ const result = builder.appendGeometryParamsChange(params) && builder.appendGeometryQuery(PointString3d.create(points));
83
+ return result;
84
+ }
85
+ /**
86
+ * Draws debug geometry for each line and run in a TextBlockLayout.
87
+ *
88
+ * For each line and run, this function draws boxes to visualize their layout and boundaries.
89
+ * Different run types (e.g., text, linebreak, fraction, tab) are assigned distinct colors for clarity.
90
+ * This is useful for debugging text layout and alignment issues.
91
+ *
92
+ * @param builder - The geometry builder to append debug geometry to.
93
+ * @param layout - The text block layout containing lines and runs to visualize.
94
+ * @param documentTransform - The transform to apply to the entire document.
95
+ * @returns True if all debug geometry was successfully appended.
96
+ */
97
+ function debugRunLayout(builder, layout, documentTransform) {
98
+ let result = true; // Tracks if all geometry was appended successfully
99
+ let color = ColorDef.black; // Current color for the run type
100
+ let lastColor = color; // Last color used, to minimize param changes
101
+ // Map run types to debug colors
102
+ const colors = {
103
+ "text": ColorDef.fromString("orange"),
104
+ "linebreak": ColorDef.fromString("yellow"),
105
+ "fraction": ColorDef.fromString("green"),
106
+ "tab": ColorDef.fromString("aquamarine"),
107
+ "field": ColorDef.fromString("purple"),
108
+ };
109
+ layout.lines.forEach(line => {
110
+ // Apply the line's offset transform
111
+ const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);
112
+ documentTransform.multiplyTransformTransform(lineTrans, lineTrans);
113
+ line.runs.forEach(run => {
114
+ // Determine color for this run type
115
+ color = colors[run.source.type] ?? ColorDef.black;
116
+ // Only change geometry params if the color changes
117
+ if (!lastColor.equals(color)) {
118
+ const colorParams = new GeometryParams(Id64.invalid);
119
+ colorParams.lineColor = color;
120
+ result = result && builder.appendGeometryParamsChange(colorParams);
121
+ lastColor = color;
122
+ }
123
+ // Apply the line's offset to the run's offset
124
+ const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);
125
+ lineTrans.multiplyTransformTransform(runTrans, runTrans);
126
+ // Draw the enclosing range for the run
127
+ const runCorners = run.range.corners3d(true);
128
+ runTrans.multiplyPoint3dArrayInPlace(runCorners);
129
+ result = result && builder.appendGeometryQuery(LineString3d.create(runCorners));
130
+ });
131
+ });
132
+ return result;
133
+ }
134
+ //# sourceMappingURL=TextAnnotationGeometry.js.map