@mlightcad/cad-simple-viewer 1.6.1 → 1.6.3

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 (281) hide show
  1. package/dist/cad-simple-viewer.js +12123 -8535
  2. package/dist/cad-simple-viewer.umd.cjs +180 -29
  3. package/icons.ts +7 -0
  4. package/lib/app/AcApBusyIndicator.d.ts +6 -0
  5. package/lib/app/AcApBusyIndicator.d.ts.map +1 -1
  6. package/lib/app/AcApBusyIndicator.js +8 -0
  7. package/lib/app/AcApBusyIndicator.js.map +1 -1
  8. package/lib/app/AcApContext.d.ts +24 -0
  9. package/lib/app/AcApContext.d.ts.map +1 -1
  10. package/lib/app/AcApContext.js +103 -18
  11. package/lib/app/AcApContext.js.map +1 -1
  12. package/lib/app/AcApDocManager.d.ts +221 -21
  13. package/lib/app/AcApDocManager.d.ts.map +1 -1
  14. package/lib/app/AcApDocManager.js +820 -134
  15. package/lib/app/AcApDocManager.js.map +1 -1
  16. package/lib/app/AcApDocSession.d.ts +41 -0
  17. package/lib/app/AcApDocSession.d.ts.map +1 -0
  18. package/lib/app/AcApDocSession.js +29 -0
  19. package/lib/app/AcApDocSession.js.map +1 -0
  20. package/lib/app/AcApDocument.d.ts +5 -0
  21. package/lib/app/AcApDocument.d.ts.map +1 -1
  22. package/lib/app/AcApDocument.js +21 -0
  23. package/lib/app/AcApDocument.js.map +1 -1
  24. package/lib/app/AcApOpenFileProgressController.d.ts +14 -0
  25. package/lib/app/AcApOpenFileProgressController.d.ts.map +1 -1
  26. package/lib/app/AcApOpenFileProgressController.js +18 -0
  27. package/lib/app/AcApOpenFileProgressController.js.map +1 -1
  28. package/lib/app/AcApProgress.d.ts +6 -0
  29. package/lib/app/AcApProgress.d.ts.map +1 -1
  30. package/lib/app/AcApProgress.js +17 -0
  31. package/lib/app/AcApProgress.js.map +1 -1
  32. package/lib/app/AcApSettingManager.d.ts.map +1 -1
  33. package/lib/app/AcApSettingManager.js +1 -0
  34. package/lib/app/AcApSettingManager.js.map +1 -1
  35. package/lib/app/index.d.ts +1 -0
  36. package/lib/app/index.d.ts.map +1 -1
  37. package/lib/app/index.js +1 -0
  38. package/lib/app/index.js.map +1 -1
  39. package/lib/command/AcApCloseCmd.d.ts +15 -0
  40. package/lib/command/AcApCloseCmd.d.ts.map +1 -0
  41. package/lib/command/AcApCloseCmd.js +83 -0
  42. package/lib/command/AcApCloseCmd.js.map +1 -0
  43. package/lib/command/draw/AcApArcCmd.d.ts.map +1 -1
  44. package/lib/command/draw/AcApArcCmd.js +28 -312
  45. package/lib/command/draw/AcApArcCmd.js.map +1 -1
  46. package/lib/command/draw/AcApCircleCmd.d.ts.map +1 -1
  47. package/lib/command/draw/AcApCircleCmd.js +10 -42
  48. package/lib/command/draw/AcApCircleCmd.js.map +1 -1
  49. package/lib/command/index.d.ts +1 -0
  50. package/lib/command/index.d.ts.map +1 -1
  51. package/lib/command/index.js +1 -0
  52. package/lib/command/index.js.map +1 -1
  53. package/lib/command/markup/AcApMarkupCalloutCmd.d.ts.map +1 -1
  54. package/lib/command/markup/AcApMarkupCalloutCmd.js +29 -10
  55. package/lib/command/markup/AcApMarkupCalloutCmd.js.map +1 -1
  56. package/lib/command/markup/AcApMarkupGeometry.d.ts +20 -1
  57. package/lib/command/markup/AcApMarkupGeometry.d.ts.map +1 -1
  58. package/lib/command/markup/AcApMarkupGeometry.js +84 -24
  59. package/lib/command/markup/AcApMarkupGeometry.js.map +1 -1
  60. package/lib/command/markup/AcApMarkupHistory.d.ts +1 -1
  61. package/lib/command/markup/AcApMarkupHistory.d.ts.map +1 -1
  62. package/lib/command/markup/AcApMarkupHistory.js +4 -11
  63. package/lib/command/markup/AcApMarkupHistory.js.map +1 -1
  64. package/lib/command/markup/AcApMarkupPresenter.d.ts +8 -2
  65. package/lib/command/markup/AcApMarkupPresenter.d.ts.map +1 -1
  66. package/lib/command/markup/AcApMarkupPresenter.js +35 -5
  67. package/lib/command/markup/AcApMarkupPresenter.js.map +1 -1
  68. package/lib/command/markup/AcApMarkupSession.d.ts +54 -0
  69. package/lib/command/markup/AcApMarkupSession.d.ts.map +1 -0
  70. package/lib/command/markup/AcApMarkupSession.js +85 -0
  71. package/lib/command/markup/AcApMarkupSession.js.map +1 -0
  72. package/lib/command/markup/AcApMarkupSessionBootstrap.d.ts +2 -0
  73. package/lib/command/markup/AcApMarkupSessionBootstrap.d.ts.map +1 -0
  74. package/lib/command/markup/AcApMarkupSessionBootstrap.js +12 -0
  75. package/lib/command/markup/AcApMarkupSessionBootstrap.js.map +1 -0
  76. package/lib/command/markup/AcApMarkupShapeCallout.d.ts +21 -1
  77. package/lib/command/markup/AcApMarkupShapeCallout.d.ts.map +1 -1
  78. package/lib/command/markup/AcApMarkupShapeCallout.js +29 -22
  79. package/lib/command/markup/AcApMarkupShapeCallout.js.map +1 -1
  80. package/lib/command/markup/AcApMarkupStore.d.ts +1 -1
  81. package/lib/command/markup/AcApMarkupStore.d.ts.map +1 -1
  82. package/lib/command/markup/AcApMarkupStore.js +3 -6
  83. package/lib/command/markup/AcApMarkupStore.js.map +1 -1
  84. package/lib/command/markup/AcApMarkupTextCmd.d.ts.map +1 -1
  85. package/lib/command/markup/AcApMarkupTextCmd.js +8 -2
  86. package/lib/command/markup/AcApMarkupTextCmd.js.map +1 -1
  87. package/lib/command/markup/AcApMarkupTextEdit.d.ts.map +1 -1
  88. package/lib/command/markup/AcApMarkupTextEdit.js +3 -1
  89. package/lib/command/markup/AcApMarkupTextEdit.js.map +1 -1
  90. package/lib/command/markup/AcApMarkupUtil.d.ts.map +1 -1
  91. package/lib/command/markup/AcApMarkupUtil.js +3 -2
  92. package/lib/command/markup/AcApMarkupUtil.js.map +1 -1
  93. package/lib/command/markup/index.d.ts +2 -0
  94. package/lib/command/markup/index.d.ts.map +1 -1
  95. package/lib/command/markup/index.js +3 -0
  96. package/lib/command/markup/index.js.map +1 -1
  97. package/lib/command/measure/AcApMeasureArcCmd.d.ts +22 -25
  98. package/lib/command/measure/AcApMeasureArcCmd.d.ts.map +1 -1
  99. package/lib/command/measure/AcApMeasureArcCmd.js +480 -256
  100. package/lib/command/measure/AcApMeasureArcCmd.js.map +1 -1
  101. package/lib/command/measure/AcApMeasureArcLock.d.ts +40 -0
  102. package/lib/command/measure/AcApMeasureArcLock.d.ts.map +1 -0
  103. package/lib/command/measure/AcApMeasureArcLock.js +226 -0
  104. package/lib/command/measure/AcApMeasureArcLock.js.map +1 -0
  105. package/lib/command/measure/AcApMeasurementGeometry.d.ts.map +1 -1
  106. package/lib/command/measure/AcApMeasurementGeometry.js +9 -9
  107. package/lib/command/measure/AcApMeasurementGeometry.js.map +1 -1
  108. package/lib/command/measure/AcApMeasurementSidecar.d.ts.map +1 -1
  109. package/lib/command/measure/AcApMeasurementSidecar.js +12 -7
  110. package/lib/command/measure/AcApMeasurementSidecar.js.map +1 -1
  111. package/lib/command/measure/AcApMeasurementStore.d.ts +2 -0
  112. package/lib/command/measure/AcApMeasurementStore.d.ts.map +1 -1
  113. package/lib/command/measure/AcApMeasurementStore.js +4 -0
  114. package/lib/command/measure/AcApMeasurementStore.js.map +1 -1
  115. package/lib/command/measure/AcApMeasurementTypes.d.ts +6 -0
  116. package/lib/command/measure/AcApMeasurementTypes.d.ts.map +1 -1
  117. package/lib/command/measure/entity/AcApMeasureArcEntity.d.ts +24 -22
  118. package/lib/command/measure/entity/AcApMeasureArcEntity.d.ts.map +1 -1
  119. package/lib/command/measure/entity/AcApMeasureArcEntity.js +104 -41
  120. package/lib/command/measure/entity/AcApMeasureArcEntity.js.map +1 -1
  121. package/lib/command/measure/entity/AcApMeasureDrawUtil.d.ts +35 -38
  122. package/lib/command/measure/entity/AcApMeasureDrawUtil.d.ts.map +1 -1
  123. package/lib/command/measure/entity/AcApMeasureDrawUtil.js +42 -53
  124. package/lib/command/measure/entity/AcApMeasureDrawUtil.js.map +1 -1
  125. package/lib/command/measure/entity/AcApMeasureEntityFactory.d.ts.map +1 -1
  126. package/lib/command/measure/entity/AcApMeasureEntityFactory.js +1 -1
  127. package/lib/command/measure/entity/AcApMeasureEntityFactory.js.map +1 -1
  128. package/lib/command/modify/AcApEraseCmd.d.ts +1 -0
  129. package/lib/command/modify/AcApEraseCmd.d.ts.map +1 -1
  130. package/lib/command/modify/AcApEraseCmd.js +4 -2
  131. package/lib/command/modify/AcApEraseCmd.js.map +1 -1
  132. package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -1
  133. package/lib/editor/grip/AcEdGripEditSession.js +2 -0
  134. package/lib/editor/grip/AcEdGripEditSession.js.map +1 -1
  135. package/lib/editor/input/AcEdOsnapCenterMarks.d.ts +23 -0
  136. package/lib/editor/input/AcEdOsnapCenterMarks.d.ts.map +1 -0
  137. package/lib/editor/input/AcEdOsnapCenterMarks.js +240 -0
  138. package/lib/editor/input/AcEdOsnapCenterMarks.js.map +1 -0
  139. package/lib/editor/input/AcEdOsnapResolver.d.ts +18 -0
  140. package/lib/editor/input/AcEdOsnapResolver.d.ts.map +1 -1
  141. package/lib/editor/input/AcEdOsnapResolver.js +159 -10
  142. package/lib/editor/input/AcEdOsnapResolver.js.map +1 -1
  143. package/lib/editor/input/marker/AcEdMarker.d.ts +1 -1
  144. package/lib/editor/input/marker/AcEdMarker.d.ts.map +1 -1
  145. package/lib/editor/input/marker/AcEdMarker.js +11 -1
  146. package/lib/editor/input/marker/AcEdMarker.js.map +1 -1
  147. package/lib/editor/input/marker/AcEdOSnapMarkerManager.d.ts +17 -1
  148. package/lib/editor/input/marker/AcEdOSnapMarkerManager.d.ts.map +1 -1
  149. package/lib/editor/input/marker/AcEdOSnapMarkerManager.js +71 -10
  150. package/lib/editor/input/marker/AcEdOSnapMarkerManager.js.map +1 -1
  151. package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
  152. package/lib/editor/input/ui/AcEdFloatingInput.js +4 -0
  153. package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
  154. package/lib/editor/view/AcEdBaseView.d.ts +12 -0
  155. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  156. package/lib/editor/view/AcEdBaseView.js +29 -1
  157. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  158. package/lib/i18n/AcApI18n.d.ts +1 -1
  159. package/lib/i18n/AcApI18n.d.ts.map +1 -1
  160. package/lib/i18n/AcApI18n.js +2 -1
  161. package/lib/i18n/AcApI18n.js.map +1 -1
  162. package/lib/i18n/ar/command.d.ts +456 -0
  163. package/lib/i18n/ar/command.d.ts.map +1 -0
  164. package/lib/i18n/ar/command.js +14 -0
  165. package/lib/i18n/ar/command.js.map +1 -0
  166. package/lib/i18n/ar/jig.d.ts +1231 -0
  167. package/lib/i18n/ar/jig.d.ts.map +1 -0
  168. package/lib/i18n/ar/jig.js +594 -0
  169. package/lib/i18n/ar/jig.js.map +1 -0
  170. package/lib/i18n/ar/main.d.ts +64 -0
  171. package/lib/i18n/ar/main.d.ts.map +1 -0
  172. package/lib/i18n/ar/main.js +63 -0
  173. package/lib/i18n/ar/main.js.map +1 -0
  174. package/lib/i18n/cs/command.d.ts +3 -0
  175. package/lib/i18n/cs/command.d.ts.map +1 -1
  176. package/lib/i18n/cs/command.js +3 -0
  177. package/lib/i18n/cs/command.js.map +1 -1
  178. package/lib/i18n/cs/jig.d.ts +3 -0
  179. package/lib/i18n/cs/jig.d.ts.map +1 -1
  180. package/lib/i18n/cs/jig.js +7 -4
  181. package/lib/i18n/cs/jig.js.map +1 -1
  182. package/lib/i18n/en/command.d.ts +3 -0
  183. package/lib/i18n/en/command.d.ts.map +1 -1
  184. package/lib/i18n/en/command.js +3 -0
  185. package/lib/i18n/en/command.js.map +1 -1
  186. package/lib/i18n/en/jig.d.ts +3 -0
  187. package/lib/i18n/en/jig.d.ts.map +1 -1
  188. package/lib/i18n/en/jig.js +7 -4
  189. package/lib/i18n/en/jig.js.map +1 -1
  190. package/lib/i18n/index.d.ts.map +1 -1
  191. package/lib/i18n/index.js +8 -0
  192. package/lib/i18n/index.js.map +1 -1
  193. package/lib/i18n/tr/command.d.ts +3 -0
  194. package/lib/i18n/tr/command.d.ts.map +1 -1
  195. package/lib/i18n/tr/command.js +3 -0
  196. package/lib/i18n/tr/command.js.map +1 -1
  197. package/lib/i18n/tr/jig.d.ts +3 -0
  198. package/lib/i18n/tr/jig.d.ts.map +1 -1
  199. package/lib/i18n/tr/jig.js +7 -4
  200. package/lib/i18n/tr/jig.js.map +1 -1
  201. package/lib/i18n/zh/command.d.ts +3 -0
  202. package/lib/i18n/zh/command.d.ts.map +1 -1
  203. package/lib/i18n/zh/command.js +3 -0
  204. package/lib/i18n/zh/command.js.map +1 -1
  205. package/lib/i18n/zh/jig.d.ts +3 -0
  206. package/lib/i18n/zh/jig.d.ts.map +1 -1
  207. package/lib/i18n/zh/jig.js +7 -4
  208. package/lib/i18n/zh/jig.js.map +1 -1
  209. package/lib/plugin/AcApPluginManager.d.ts +10 -0
  210. package/lib/plugin/AcApPluginManager.d.ts.map +1 -1
  211. package/lib/plugin/AcApPluginManager.js +18 -0
  212. package/lib/plugin/AcApPluginManager.js.map +1 -1
  213. package/lib/service/AcApEntityService.d.ts +4 -2
  214. package/lib/service/AcApEntityService.d.ts.map +1 -1
  215. package/lib/service/AcApEntityService.js +14 -10
  216. package/lib/service/AcApEntityService.js.map +1 -1
  217. package/lib/ui/AcApDrawStyle.d.ts +19 -1
  218. package/lib/ui/AcApDrawStyle.d.ts.map +1 -1
  219. package/lib/ui/AcApDrawStyle.js +22 -1
  220. package/lib/ui/AcApDrawStyle.js.map +1 -1
  221. package/lib/ui/AcApDrawStyleToolbar.d.ts +12 -7
  222. package/lib/ui/AcApDrawStyleToolbar.d.ts.map +1 -1
  223. package/lib/ui/AcApDrawStyleToolbar.js +173 -52
  224. package/lib/ui/AcApDrawStyleToolbar.js.map +1 -1
  225. package/lib/ui/icons.d.ts +148 -0
  226. package/lib/ui/icons.d.ts.map +1 -0
  227. package/lib/ui/icons.js +173 -0
  228. package/lib/ui/icons.js.map +1 -0
  229. package/lib/ui/index.d.ts +1 -0
  230. package/lib/ui/index.d.ts.map +1 -1
  231. package/lib/ui/index.js +1 -0
  232. package/lib/ui/index.js.map +1 -1
  233. package/lib/util/AcApCssColor.d.ts +8 -0
  234. package/lib/util/AcApCssColor.d.ts.map +1 -0
  235. package/lib/util/AcApCssColor.js +20 -0
  236. package/lib/util/AcApCssColor.js.map +1 -0
  237. package/lib/util/AcApMeasurementUtil.d.ts.map +1 -1
  238. package/lib/util/AcApMeasurementUtil.js +3 -2
  239. package/lib/util/AcApMeasurementUtil.js.map +1 -1
  240. package/lib/util/AcApScreenHitTest.d.ts +5 -1
  241. package/lib/util/AcApScreenHitTest.d.ts.map +1 -1
  242. package/lib/util/AcApScreenHitTest.js +9 -3
  243. package/lib/util/AcApScreenHitTest.js.map +1 -1
  244. package/lib/util/index.d.ts +1 -0
  245. package/lib/util/index.d.ts.map +1 -1
  246. package/lib/util/index.js +1 -0
  247. package/lib/util/index.js.map +1 -1
  248. package/lib/view/AcApCompareDisplay.d.ts +37 -0
  249. package/lib/view/AcApCompareDisplay.d.ts.map +1 -0
  250. package/lib/view/AcApCompareDisplay.js +8 -0
  251. package/lib/view/AcApCompareDisplay.js.map +1 -0
  252. package/lib/view/AcEdReviewOverlayPick.d.ts +9 -0
  253. package/lib/view/AcEdReviewOverlayPick.d.ts.map +1 -1
  254. package/lib/view/AcEdReviewOverlayPick.js +30 -1
  255. package/lib/view/AcEdReviewOverlayPick.js.map +1 -1
  256. package/lib/view/AcTrLayer.d.ts +6 -0
  257. package/lib/view/AcTrLayer.d.ts.map +1 -1
  258. package/lib/view/AcTrLayer.js +8 -0
  259. package/lib/view/AcTrLayer.js.map +1 -1
  260. package/lib/view/AcTrLayout.d.ts +12 -0
  261. package/lib/view/AcTrLayout.d.ts.map +1 -1
  262. package/lib/view/AcTrLayout.js +12 -0
  263. package/lib/view/AcTrLayout.js.map +1 -1
  264. package/lib/view/AcTrScene.d.ts +7 -0
  265. package/lib/view/AcTrScene.d.ts.map +1 -1
  266. package/lib/view/AcTrScene.js +13 -0
  267. package/lib/view/AcTrScene.js.map +1 -1
  268. package/lib/view/AcTrView2d.d.ts +50 -2
  269. package/lib/view/AcTrView2d.d.ts.map +1 -1
  270. package/lib/view/AcTrView2d.js +210 -37
  271. package/lib/view/AcTrView2d.js.map +1 -1
  272. package/lib/view/AcTrViewSessionState.d.ts +26 -0
  273. package/lib/view/AcTrViewSessionState.d.ts.map +1 -0
  274. package/lib/view/AcTrViewSessionState.js +2 -0
  275. package/lib/view/AcTrViewSessionState.js.map +1 -0
  276. package/lib/view/index.d.ts +2 -0
  277. package/lib/view/index.d.ts.map +1 -1
  278. package/lib/view/index.js +2 -0
  279. package/lib/view/index.js.map +1 -1
  280. package/package.json +12 -5
  281. package/src/ui/icons.ts +293 -0
@@ -45,6 +45,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
48
59
  var __read = (this && this.__read) || function (o, n) {
49
60
  var m = typeof Symbol === "function" && o[Symbol.iterator];
50
61
  if (!m) return o;
@@ -84,7 +95,7 @@ var __values = (this && this.__values) || function(o) {
84
95
  import { AcCmEventManager, AcDbDatabase, AcDbFileType, acdbHostApplicationServices, AcDbSysVarManager, AcGeBox2d, log } from '@mlightcad/data-model';
85
96
  import { FontManager } from '@mlightcad/mtext-renderer';
86
97
  import { AcTrMTextRenderer } from '@mlightcad/three-renderer';
87
- import { AcApAboutCmd, AcApArcCmd, AcApCacheFontCmd, AcApCircleCmd, AcApClearMarkupsCmd, AcApClearMeasurementsCmd, AcApConvertToDxfCmd, AcApConvertToPngCmd, AcApCopyCmd, AcApDimLinearCmd, AcApEllipseCmd, AcApEntityPreviewCmd, AcApEraseCmd, AcApHatchCmd, AcApHideObjectsCmd, AcApImageAttachCmd, AcApInsertCmd, AcApLayerCloseCmd, AcApLayerCmd, AcApLayerCurCmd, AcApLayerDelCmd, AcApLayerFreezeCmd, AcApLayerIsoCmd, AcApLayerLockCmd, AcApLayerOnCmd, AcApLayerPCmd, AcApLayerThawCmd, AcApLayerUnisoCmd, AcApLayerUnlockCmd, AcApLayoffCmd, AcApLineCmd, AcApLogCmd, AcApMarkupArrowCmd, AcApMarkupCalloutCmd, AcApMarkupCircleCmd, AcApMarkupCloudCmd, AcApMarkupExportCmd, AcApMarkupHighlightCmd, AcApMarkupImportCmd, AcApMarkupLineCmd, AcApMarkupRectCmd, AcApMarkupStampCmd, AcApMarkupTextCmd, AcApMarkupVisibilityCmd, AcApMeasureAngleCmd, AcApMeasureArcCmd, AcApMeasureAreaCmd, AcApMeasureDistanceCmd, AcApMeasurementExportCmd, AcApMeasurementImportCmd, AcApMeasurementVisibilityCmd, AcApMeasurePointCmd, AcApMLineCmd, AcApMoveCmd, AcApMTextCmd, AcApOffsetCmd, AcApOpenCmd, AcApPanCmd, AcApPointCmd, AcApPolygonCmd, AcApPolylineCmd, AcApQNewCmd, AcApRayCmd, AcApRectCmd, AcApRedoCmd, AcApRegenCmd, AcApRevCloudCmd, AcApRotateCmd, AcApSelectCmd, AcApSketchCmd, AcApSplineCmd, AcApSwitchBgCmd, AcApSysVarCmd, AcApUndoCmd, AcApUnisolateObjectsCmd, AcApXAttachCmd, AcApXLineCmd, AcApZoomCmd, resetMarkupSession, resetMeasurementSession } from '../command';
98
+ import { AcApAboutCmd, AcApArcCmd, acapBindMarkupSession, AcApCacheFontCmd, AcApCircleCmd, AcApClearMarkupsCmd, AcApClearMeasurementsCmd, AcApCloseCmd, AcApConvertToDxfCmd, AcApConvertToPngCmd, AcApCopyCmd, AcApDimLinearCmd, acapDisposeMarkupSession, AcApEllipseCmd, AcApEntityPreviewCmd, AcApEraseCmd, AcApHatchCmd, AcApHideObjectsCmd, AcApImageAttachCmd, AcApInsertCmd, AcApLayerCloseCmd, AcApLayerCmd, AcApLayerCurCmd, AcApLayerDelCmd, AcApLayerFreezeCmd, AcApLayerIsoCmd, AcApLayerLockCmd, AcApLayerOnCmd, AcApLayerPCmd, AcApLayerThawCmd, AcApLayerUnisoCmd, AcApLayerUnlockCmd, AcApLayoffCmd, AcApLineCmd, AcApLogCmd, AcApMarkupArrowCmd, AcApMarkupCalloutCmd, AcApMarkupCircleCmd, AcApMarkupCloudCmd, AcApMarkupExportCmd, AcApMarkupHighlightCmd, AcApMarkupImportCmd, AcApMarkupLineCmd, AcApMarkupRectCmd, AcApMarkupStampCmd, AcApMarkupTextCmd, AcApMarkupVisibilityCmd, AcApMeasureAngleCmd, AcApMeasureArcCmd, AcApMeasureAreaCmd, AcApMeasureDistanceCmd, AcApMeasurementExportCmd, AcApMeasurementImportCmd, AcApMeasurementVisibilityCmd, AcApMeasurePointCmd, AcApMLineCmd, AcApMoveCmd, AcApMTextCmd, AcApOffsetCmd, AcApOpenCmd, AcApPanCmd, AcApPointCmd, AcApPolygonCmd, AcApPolylineCmd, AcApQNewCmd, AcApRayCmd, AcApRectCmd, AcApRedoCmd, AcApRegenCmd, AcApRevCloudCmd, AcApRotateCmd, AcApSelectCmd, AcApSketchCmd, AcApSplineCmd, AcApSwitchBgCmd, AcApSysVarCmd, AcApUndoCmd, AcApUnisolateObjectsCmd, AcApXAttachCmd, AcApXLineCmd, AcApZoomCmd, resetMarkupSession, resetMeasurementSession } from '../command';
88
99
  import { AcEdCommandStack, AcEdOpenMode } from '../editor';
89
100
  import { AcApPluginManager } from '../plugin/AcApPluginManager';
90
101
  import { AcApDrawStyleToolbar } from '../ui/AcApDrawStyleToolbar';
@@ -94,6 +105,7 @@ import { AcTrView2d } from '../view';
94
105
  import { AcApBusyIndicator } from './AcApBusyIndicator';
95
106
  import { acapBindCommandServices } from './AcApCommandServices';
96
107
  import { AcApContext } from './AcApContext';
108
+ import { AcApDocSession } from './AcApDocSession';
97
109
  import { AcApDocument } from './AcApDocument';
98
110
  import { AcApFontLoader } from './AcApFontLoader';
99
111
  import { acapInstallOpenFileDialog, acapUninstallOpenFileDialog, acapUpdateOpenFileDialogOptions } from './AcApOpenFileDialog';
@@ -183,12 +195,14 @@ var AcApDocManager = /** @class */ (function () {
183
195
  if (options === void 0) { options = {}; }
184
196
  var _this = this;
185
197
  var _a, _b, _c, _d;
198
+ /** Open document sessions (MDI). The shared view shows {@link _activeSession}. */
199
+ this._sessions = [];
200
+ /** Monotonic id suffix for {@link AcApDocSession.id}. */
201
+ this._nextSessionId = 1;
186
202
  /** Optional OPENPROF session profiler (console stage timings) */
187
203
  this._openFileProfiler = new AcApOpenFileProfiler();
188
204
  /** Cached worker readiness; null until checked, then true or false */
189
205
  this._workersReady = null;
190
- /** Loaded overlay (reference/base drawing) state, keyed by overlay id */
191
- this._overlays = new Map();
192
206
  /** Monotonically increasing counter used to generate overlay ids */
193
207
  this._nextOverlayId = 1;
194
208
  /** Events fired during document lifecycle */
@@ -199,6 +213,12 @@ var AcApDocManager = /** @class */ (function () {
199
213
  documentCreated: new AcCmEventManager(),
200
214
  /** Fired when a document becomes active */
201
215
  documentActivated: new AcCmEventManager(),
216
+ /** Fired before a document is activated */
217
+ documentToBeActivated: new AcCmEventManager(),
218
+ /** Fired before a document is closed and destroyed */
219
+ documentToBeDestroyed: new AcCmEventManager(),
220
+ /** Fired after a document has been closed */
221
+ documentDestroyed: new AcCmEventManager(),
202
222
  /** Fired when a worker readiness check completes */
203
223
  workersReady: new AcCmEventManager()
204
224
  };
@@ -249,7 +269,11 @@ var AcApDocManager = /** @class */ (function () {
249
269
  container: options.container,
250
270
  calculateSizeCallback: callback
251
271
  });
252
- this._context = new AcApContext(view, doc);
272
+ this._mainView = view;
273
+ var context = new AcApContext(view, doc);
274
+ this._activeSession = new AcApDocSession("doc-".concat(this._nextSessionId++), context);
275
+ this._sessions = [this._activeSession];
276
+ acapBindMarkupSession(this._activeSession.id);
253
277
  this._drawStyleToolbar = new AcApDrawStyleToolbar(view);
254
278
  this._fontLoader = new AcApFontLoader();
255
279
  var fontsUrl = this.resolveFontsBaseUrl();
@@ -259,10 +283,12 @@ var AcApDocManager = /** @class */ (function () {
259
283
  acdbHostApplicationServices().workingDatabase = doc.database;
260
284
  this._commandManager = new AcEdCommandStack();
261
285
  this.registerCommands();
262
- this._pluginManager = new AcApPluginManager(this._context, this._commandManager);
286
+ this._pluginManager = new AcApPluginManager(this.context, this._commandManager);
263
287
  var busyHost = (_d = options.busyIndicatorHost) !== null && _d !== void 0 ? _d : view.container;
288
+ this._busyIndicatorHost = busyHost;
264
289
  this._openFileProgress = new AcApOpenFileProgressController(busyHost);
265
- this._openFileProgress.setSceneBusyGate(function () { return _this.curView.isProcessingEntities; });
290
+ this._openFileProgress.setSceneBusyGate(function () { return _this.openProgressView.isProcessingEntities; });
291
+ this._openFileProgress.setOnHidden(function () { return _this.onOpenProgressHidden(); });
266
292
  this._busyIndicator = new AcApBusyIndicator(busyHost);
267
293
  acapBindCommandServices({
268
294
  showMessage: function (message, type, msgKey) {
@@ -277,22 +303,10 @@ var AcApDocManager = /** @class */ (function () {
277
303
  this.events.documentToBeOpened.addEventListener(function () {
278
304
  _this._openFileProgress.reset();
279
305
  });
280
- doc.database.events.openProgress.addEventListener(function (args) {
281
- _this._openFileProgress.handle({
282
- database: doc.database,
283
- percentage: args.percentage,
284
- stage: args.stage,
285
- subStage: args.subStage,
286
- subStageStatus: args.subStageStatus,
287
- data: args.data
288
- });
289
- // After doc header is loaded, need to set global ltscale and celtscale
290
- // It's too late when subStage is 'END'
291
- if (args.subStage === 'HEADER') {
292
- _this.curView.ltscale = doc.database.ltscale;
293
- _this.curView.celtscale = doc.database.celtscale;
294
- _this.curView.renderer.showLineWeight = doc.database.lwdisplay;
295
- }
306
+ this.bindOpenProgress(doc);
307
+ this.events.documentCreated.dispatch({
308
+ doc: doc,
309
+ mode: doc.openMode
296
310
  });
297
311
  if (options.preloadDefaultFonts) {
298
312
  void this.loadDefaultFonts();
@@ -355,12 +369,34 @@ var AcApDocManager = /** @class */ (function () {
355
369
  */
356
370
  AcApDocManager.prototype.destroy = function () {
357
371
  return __awaiter(this, void 0, void 0, function () {
358
- return __generator(this, function (_a) {
359
- switch (_a.label) {
372
+ var _a, _b, session;
373
+ var e_1, _c;
374
+ var _d;
375
+ return __generator(this, function (_e) {
376
+ switch (_e.label) {
360
377
  case 0: return [4 /*yield*/, this._pluginManager.unloadAllPlugins()];
361
378
  case 1:
362
- _a.sent();
363
- this.context.doc.destroy();
379
+ _e.sent();
380
+ (_d = this._splitView) === null || _d === void 0 ? void 0 : _d.stopAnimationLoop();
381
+ this._splitView = undefined;
382
+ try {
383
+ for (_a = __values(__spreadArray([], __read(this._sessions), false)), _b = _a.next(); !_b.done; _b = _a.next()) {
384
+ session = _b.value;
385
+ session.context.dispose();
386
+ session.doc.destroy();
387
+ if (session.viewState) {
388
+ this.curView.disposeSessionState(session.viewState);
389
+ }
390
+ }
391
+ }
392
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
393
+ finally {
394
+ try {
395
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
396
+ }
397
+ finally { if (e_1) throw e_1.error; }
398
+ }
399
+ this._sessions = [];
364
400
  acapUninstallOpenFileDialog();
365
401
  AcTrMTextRenderer.resetInstance();
366
402
  resetWebworkerReadinessCache();
@@ -419,19 +455,68 @@ var AcApDocManager = /** @class */ (function () {
419
455
  * @returns The current application context
420
456
  */
421
457
  get: function () {
422
- return this._context;
458
+ return this._activeSession.context;
459
+ },
460
+ enumerable: false,
461
+ configurable: true
462
+ });
463
+ Object.defineProperty(AcApDocManager.prototype, "documents", {
464
+ /**
465
+ * Open document sessions in tab order.
466
+ */
467
+ get: function () {
468
+ return this._sessions.map(function (session) { return session.doc; });
469
+ },
470
+ enumerable: false,
471
+ configurable: true
472
+ });
473
+ Object.defineProperty(AcApDocManager.prototype, "documentCount", {
474
+ /**
475
+ * Number of open documents.
476
+ */
477
+ get: function () {
478
+ return this._sessions.length;
423
479
  },
424
480
  enumerable: false,
425
481
  configurable: true
426
482
  });
483
+ Object.defineProperty(AcApDocManager.prototype, "activeSessionId", {
484
+ /**
485
+ * Session id of the active document, for host UI tabs.
486
+ */
487
+ get: function () {
488
+ return this._activeSession.id;
489
+ },
490
+ enumerable: false,
491
+ configurable: true
492
+ });
493
+ /**
494
+ * Returns the document at `index`, or undefined when out of range.
495
+ *
496
+ * @param index - Zero-based tab order.
497
+ */
498
+ AcApDocManager.prototype.document = function (index) {
499
+ var _a;
500
+ return (_a = this._sessions[index]) === null || _a === void 0 ? void 0 : _a.doc;
501
+ };
502
+ /**
503
+ * Finds the session that owns `doc`.
504
+ *
505
+ * @param doc - Document to look up.
506
+ */
507
+ AcApDocManager.prototype.sessionFor = function (doc) {
508
+ return this._sessions.find(function (session) { return session.doc === doc; });
509
+ };
427
510
  Object.defineProperty(AcApDocManager.prototype, "curDocument", {
428
511
  /**
429
512
  * Gets the currently open CAD document.
430
513
  *
514
+ * Same as {@link mdiActiveDocument} — the document bound to the shared view.
515
+ *
431
516
  * @returns The current document instance
432
517
  */
433
518
  get: function () {
434
- return this._context.doc;
519
+ return this.context.doc;
435
520
  },
436
521
  enumerable: false,
437
522
  configurable: true
@@ -440,17 +525,232 @@ var AcApDocManager = /** @class */ (function () {
440
525
  /**
441
526
  * Gets the currently active document.
442
527
  *
443
- * For now, this is the same as `curDocument` since only one document
444
- * can be active at a time.
445
- *
446
528
  * @returns The current active document
447
529
  */
448
530
  get: function () {
449
- return this._context.doc;
531
+ return this._activeSession.doc;
532
+ },
533
+ enumerable: false,
534
+ configurable: true
535
+ });
536
+ /**
537
+ * Makes `doc` the command target.
538
+ *
539
+ * When both documents already have their own canvas (split view), scenes
540
+ * stay in place. When they share one canvas (tab MDI), the current scene is
541
+ * parked and the target is restored.
542
+ *
543
+ * @param doc - Document to activate.
544
+ * @returns `false` when `doc` is not an open session.
545
+ */
546
+ AcApDocManager.prototype.activateDocument = function (doc) {
547
+ return __awaiter(this, void 0, void 0, function () {
548
+ var session, targetView, currentView;
549
+ return __generator(this, function (_a) {
550
+ switch (_a.label) {
551
+ case 0:
552
+ session = this.sessionFor(doc);
553
+ if (!session) {
554
+ return [2 /*return*/, false];
555
+ }
556
+ if (session === this._activeSession) {
557
+ return [2 /*return*/, true];
558
+ }
559
+ targetView = session.context.view;
560
+ currentView = this._activeSession.context.view;
561
+ if (this._openingSession && targetView === currentView) {
562
+ return [2 /*return*/, false];
563
+ }
564
+ return [4 /*yield*/, this._commandManager.cancelActive()];
565
+ case 1:
566
+ _a.sent();
567
+ this.events.documentToBeActivated.dispatch({
568
+ doc: doc,
569
+ mode: doc.openMode
570
+ });
571
+ if (targetView === currentView) {
572
+ this.parkActiveSession();
573
+ this._activeSession = session;
574
+ session.context.resume();
575
+ if (session.viewState) {
576
+ this.curView.restoreSessionState(session.viewState);
577
+ session.viewState = undefined;
578
+ }
579
+ }
580
+ else {
581
+ if (this._activeSession !== this._openingSession) {
582
+ this._activeSession.context.suspend();
583
+ }
584
+ this._activeSession = session;
585
+ session.context.resume();
586
+ }
587
+ acapBindMarkupSession(session.id);
588
+ acdbHostApplicationServices().workingDatabase = doc.database;
589
+ this._pluginManager.setContext(session.context);
590
+ this.curView.bindDrawDatabase(doc.database);
591
+ this.events.documentActivated.dispatch({
592
+ doc: doc,
593
+ mode: doc.openMode
594
+ });
595
+ this.setActiveLayout();
596
+ this.curView.syncDisplaySysVars(doc.database);
597
+ if (!this._openingSession) {
598
+ this.syncProgressOverlayHost();
599
+ }
600
+ return [2 /*return*/, true];
601
+ }
602
+ });
603
+ });
604
+ };
605
+ Object.defineProperty(AcApDocManager.prototype, "mainView", {
606
+ /**
607
+ * Canvas created with {@link createInstance} (left pane in a split layout).
608
+ */
609
+ get: function () {
610
+ return this._mainView;
450
611
  },
451
612
  enumerable: false,
452
613
  configurable: true
453
614
  });
615
+ Object.defineProperty(AcApDocManager.prototype, "splitView", {
616
+ /**
617
+ * Second canvas created by {@link ensureSplitView}, if any.
618
+ */
619
+ get: function () {
620
+ return this._splitView;
621
+ },
622
+ enumerable: false,
623
+ configurable: true
624
+ });
625
+ /**
626
+ * Creates a second WebGL view in `container` for side-by-side comparison.
627
+ *
628
+ * Each document is converted into one view and stays there. Use
629
+ * {@link openDocument}'s `view` argument to open a file into this canvas,
630
+ * and {@link activateDocument} to choose which side receives commands.
631
+ *
632
+ * @param container - Host element for the second canvas.
633
+ */
634
+ AcApDocManager.prototype.ensureSplitView = function (container) {
635
+ if (!this._splitView) {
636
+ this._splitView = new AcTrView2d({
637
+ container: container,
638
+ calculateSizeCallback: function () { return ({
639
+ width: Math.max(1, container.clientWidth),
640
+ height: Math.max(1, container.clientHeight)
641
+ }); }
642
+ });
643
+ }
644
+ else if (this._splitView.container !== container) {
645
+ container.appendChild(this._splitView.container);
646
+ }
647
+ return this._splitView;
648
+ };
649
+ /**
650
+ * @deprecated Use {@link ensureSplitView} and open each file into its own view.
651
+ *
652
+ * @param container - Host element for the second canvas.
653
+ */
654
+ AcApDocManager.prototype.attachSatelliteView = function (container, _doc) {
655
+ this.ensureSplitView(container);
656
+ return true;
657
+ };
658
+ /**
659
+ * @deprecated Split canvases keep rendering; there is nothing to detach.
660
+ */
661
+ AcApDocManager.prototype.detachSatelliteView = function () {
662
+ return;
663
+ };
664
+ Object.defineProperty(AcApDocManager.prototype, "satelliteDocument", {
665
+ /**
666
+ * Document currently shown on the split canvas, if a session is bound to it.
667
+ */
668
+ get: function () {
669
+ var _this = this;
670
+ var _a;
671
+ if (!this._splitView) {
672
+ return undefined;
673
+ }
674
+ return (_a = this._sessions.find(function (session) { return session.context.view === _this._splitView; })) === null || _a === void 0 ? void 0 : _a.doc;
675
+ },
676
+ enumerable: false,
677
+ configurable: true
678
+ });
679
+ /**
680
+ * Closes `doc`, or the active document when omitted.
681
+ *
682
+ * Closing the last document replaces it with a new untitled drawing.
683
+ *
684
+ * @param doc - Document to close; defaults to {@link curDocument}.
685
+ * @returns `false` when `doc` is not an open session.
686
+ */
687
+ AcApDocManager.prototype.closeDocument = function (doc) {
688
+ return __awaiter(this, void 0, void 0, function () {
689
+ var target, session, wasActive, index, closedView, next;
690
+ return __generator(this, function (_a) {
691
+ switch (_a.label) {
692
+ case 0:
693
+ target = doc !== null && doc !== void 0 ? doc : this.curDocument;
694
+ session = this.sessionFor(target);
695
+ if (!session) {
696
+ return [2 /*return*/, false];
697
+ }
698
+ return [4 /*yield*/, this._commandManager.cancelActive()];
699
+ case 1:
700
+ _a.sent();
701
+ this.events.documentToBeDestroyed.dispatch({
702
+ doc: target,
703
+ mode: target.openMode
704
+ });
705
+ wasActive = session === this._activeSession;
706
+ index = this._sessions.indexOf(session);
707
+ if (this._sessions.length === 1) {
708
+ this.resetActiveSessionToUntitled(session);
709
+ this.events.documentDestroyed.dispatch({
710
+ doc: target,
711
+ mode: target.openMode
712
+ });
713
+ this.events.documentCreated.dispatch({
714
+ doc: this.curDocument,
715
+ mode: this.curDocument.openMode
716
+ });
717
+ this.events.documentActivated.dispatch({
718
+ doc: this.curDocument,
719
+ mode: this.curDocument.openMode
720
+ });
721
+ return [2 /*return*/, true];
722
+ }
723
+ if (wasActive) {
724
+ this.parkActiveSession();
725
+ }
726
+ session.context.dispose();
727
+ target.destroy();
728
+ this.clearSessionOverlays(session);
729
+ acapDisposeMarkupSession(session.id);
730
+ closedView = session.context.view;
731
+ if (session.viewState) {
732
+ closedView.disposeSessionState(session.viewState);
733
+ session.viewState = undefined;
734
+ }
735
+ else {
736
+ closedView.clear();
737
+ }
738
+ this._sessions.splice(index, 1);
739
+ this.events.documentDestroyed.dispatch({
740
+ doc: target,
741
+ mode: target.openMode
742
+ });
743
+ if (!wasActive) return [3 /*break*/, 3];
744
+ next = this._sessions[Math.min(index, this._sessions.length - 1)];
745
+ return [4 /*yield*/, this.activateDocument(next.doc)];
746
+ case 2:
747
+ _a.sent();
748
+ _a.label = 3;
749
+ case 3: return [2 /*return*/, true];
750
+ }
751
+ });
752
+ });
753
+ };
454
754
  Object.defineProperty(AcApDocManager.prototype, "curView", {
455
755
  /**
456
756
  * Gets the current 2D view used to display the drawing.
@@ -458,7 +758,7 @@ var AcApDocManager = /** @class */ (function () {
458
758
  * @returns The current 2D view instance
459
759
  */
460
760
  get: function () {
461
- return this._context.view;
761
+ return this.context.view;
462
762
  },
463
763
  enumerable: false,
464
764
  configurable: true
@@ -470,7 +770,7 @@ var AcApDocManager = /** @class */ (function () {
470
770
  * @returns The current editor instance
471
771
  */
472
772
  get: function () {
473
- return this._context.view.editor;
773
+ return this.context.view.editor;
474
774
  },
475
775
  enumerable: false,
476
776
  configurable: true
@@ -652,8 +952,9 @@ var AcApDocManager = /** @class */ (function () {
652
952
  /**
653
953
  * Opens a CAD document from a URL.
654
954
  *
655
- * This method loads a document from the specified URL and replaces the current document.
656
- * It handles the complete document lifecycle including before/after open events.
955
+ * This method loads a document from the specified URL. When the current
956
+ * drawing is a reusable Untitled, it is replaced; otherwise a new document
957
+ * session is created and activated.
657
958
  *
658
959
  * @param url - The URL of the CAD file to open
659
960
  * @param options - Optional database opening options. If not provided, default options with font loader will be used
@@ -669,30 +970,42 @@ var AcApDocManager = /** @class */ (function () {
669
970
  */
670
971
  AcApDocManager.prototype.openUrl = function (url, options) {
671
972
  return __awaiter(this, void 0, void 0, function () {
672
- var isSuccess, error_1;
973
+ var created, isSuccess, error_1;
673
974
  return __generator(this, function (_a) {
674
975
  switch (_a.label) {
675
976
  case 0:
676
977
  options = this.setOptions(options);
677
- this.onBeforeOpenDocument(options);
678
- _a.label = 1;
978
+ return [4 /*yield*/, this.ensureOpenSession()];
679
979
  case 1:
680
- _a.trys.push([1, 4, , 5]);
681
- return [4 /*yield*/, this._openFileProgress.beginOpen(this.context.doc.database)
682
- // TODO: The correct way is to create one new context instead of using old context and document
683
- ];
980
+ created = _a.sent();
981
+ this.beginOpenProgress();
982
+ this.onBeforeOpenDocument(options, !created);
983
+ _a.label = 2;
684
984
  case 2:
985
+ _a.trys.push([2, 7, , 10]);
986
+ return [4 /*yield*/, this._openFileProgress.beginOpen(this.context.doc.database)];
987
+ case 3:
685
988
  _a.sent();
686
989
  return [4 /*yield*/, this.context.doc.openUri(url, options)];
687
- case 3:
990
+ case 4:
688
991
  isSuccess = _a.sent();
689
992
  this.onAfterOpenDocument(isSuccess, options);
690
- return [2 /*return*/, isSuccess];
691
- case 4:
993
+ if (!(!isSuccess && created)) return [3 /*break*/, 6];
994
+ return [4 /*yield*/, this.closeFailedOpenSession()];
995
+ case 5:
996
+ _a.sent();
997
+ _a.label = 6;
998
+ case 6: return [2 /*return*/, isSuccess];
999
+ case 7:
692
1000
  error_1 = _a.sent();
693
1001
  this._openFileProfiler.cancel();
694
- throw error_1;
695
- case 5: return [2 /*return*/];
1002
+ if (!created) return [3 /*break*/, 9];
1003
+ return [4 /*yield*/, this.closeFailedOpenSession()];
1004
+ case 8:
1005
+ _a.sent();
1006
+ _a.label = 9;
1007
+ case 9: throw error_1;
1008
+ case 10: return [2 /*return*/];
696
1009
  }
697
1010
  });
698
1011
  });
@@ -700,13 +1013,14 @@ var AcApDocManager = /** @class */ (function () {
700
1013
  /**
701
1014
  * Opens a CAD document from file content.
702
1015
  *
703
- * This method loads a document from the provided file content (binary data)
704
- * and replaces the current document. It handles the complete document lifecycle
705
- * including before/after open events.
1016
+ * This method loads a document from the provided file content (binary data).
1017
+ * When the current drawing is a reusable Untitled, it is replaced; otherwise
1018
+ * a new document session is created and activated.
706
1019
  *
707
1020
  * @param fileName - The name of the file being opened (used for format detection)
708
1021
  * @param content - The file content
709
1022
  * @param options - Database opening options including font loader settings
1023
+ * @param view - Optional canvas to convert into (split view). Defaults to the active view.
710
1024
  * @returns Promise that resolves to true if the document was successfully opened, false otherwise
711
1025
  *
712
1026
  * @example
@@ -715,32 +1029,44 @@ var AcApDocManager = /** @class */ (function () {
715
1029
  * const success = await docManager.openDocument('drawing.dwg', fileContent, options);
716
1030
  * ```
717
1031
  */
718
- AcApDocManager.prototype.openDocument = function (fileName, content, options) {
1032
+ AcApDocManager.prototype.openDocument = function (fileName, content, options, view) {
719
1033
  return __awaiter(this, void 0, void 0, function () {
720
- var isSuccess, error_2;
1034
+ var created, isSuccess, error_2;
721
1035
  return __generator(this, function (_a) {
722
1036
  switch (_a.label) {
723
1037
  case 0:
724
1038
  options = this.setOptions(options);
725
- this.onBeforeOpenDocument(options);
726
- _a.label = 1;
1039
+ return [4 /*yield*/, this.ensureOpenSession(view)];
727
1040
  case 1:
728
- _a.trys.push([1, 4, , 5]);
729
- return [4 /*yield*/, this._openFileProgress.beginOpen(this.context.doc.database)
730
- // TODO: The correct way is to create one new context instead of using old context and document
731
- ];
1041
+ created = _a.sent();
1042
+ this.beginOpenProgress();
1043
+ this.onBeforeOpenDocument(options, !created);
1044
+ _a.label = 2;
732
1045
  case 2:
1046
+ _a.trys.push([2, 7, , 10]);
1047
+ return [4 /*yield*/, this._openFileProgress.beginOpen(this.context.doc.database)];
1048
+ case 3:
733
1049
  _a.sent();
734
1050
  return [4 /*yield*/, this.context.doc.openDocument(fileName, content, options)];
735
- case 3:
1051
+ case 4:
736
1052
  isSuccess = _a.sent();
737
1053
  this.onAfterOpenDocument(isSuccess, options);
738
- return [2 /*return*/, isSuccess];
739
- case 4:
1054
+ if (!(!isSuccess && created)) return [3 /*break*/, 6];
1055
+ return [4 /*yield*/, this.closeFailedOpenSession()];
1056
+ case 5:
1057
+ _a.sent();
1058
+ _a.label = 6;
1059
+ case 6: return [2 /*return*/, isSuccess];
1060
+ case 7:
740
1061
  error_2 = _a.sent();
741
1062
  this._openFileProfiler.cancel();
742
- throw error_2;
743
- case 5: return [2 /*return*/];
1063
+ if (!created) return [3 /*break*/, 9];
1064
+ return [4 /*yield*/, this.closeFailedOpenSession()];
1065
+ case 8:
1066
+ _a.sent();
1067
+ _a.label = 9;
1068
+ case 9: throw error_2;
1069
+ case 10: return [2 /*return*/];
744
1070
  }
745
1071
  });
746
1072
  });
@@ -773,19 +1099,20 @@ var AcApDocManager = /** @class */ (function () {
773
1099
  */
774
1100
  AcApDocManager.prototype.loadOverlay = function (fileName_1, content_1) {
775
1101
  return __awaiter(this, arguments, void 0, function (fileName, content, options) {
776
- var db, fileExtension;
1102
+ var targetView, dbOptions, db, fileExtension;
777
1103
  var _this = this;
778
1104
  var _a;
779
1105
  if (options === void 0) { options = {}; }
780
1106
  return __generator(this, function (_b) {
781
1107
  switch (_b.label) {
782
1108
  case 0:
1109
+ targetView = options.targetView, dbOptions = __rest(options, ["targetView"]);
783
1110
  db = new AcDbDatabase();
784
1111
  fileExtension = (_a = fileName.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase();
785
1112
  return [4 /*yield*/, acapWithSecondaryDatabase(db, function () { return __awaiter(_this, void 0, void 0, function () {
786
1113
  return __generator(this, function (_a) {
787
1114
  switch (_a.label) {
788
- case 0: return [4 /*yield*/, db.read(content, __assign({ readOnly: true }, options), fileExtension === 'dwg' ? AcDbFileType.DWG : AcDbFileType.DXF)];
1115
+ case 0: return [4 /*yield*/, db.read(content, __assign({ readOnly: true }, dbOptions), fileExtension === 'dwg' ? AcDbFileType.DWG : AcDbFileType.DXF)];
789
1116
  case 1:
790
1117
  _a.sent();
791
1118
  return [2 /*return*/];
@@ -794,7 +1121,7 @@ var AcApDocManager = /** @class */ (function () {
794
1121
  }); })];
795
1122
  case 1:
796
1123
  _b.sent();
797
- return [2 /*return*/, this.registerOverlayDatabase(db)];
1124
+ return [2 /*return*/, this.registerOverlayDatabase(db, { targetView: targetView })];
798
1125
  }
799
1126
  });
800
1127
  });
@@ -804,19 +1131,25 @@ var AcApDocManager = /** @class */ (function () {
804
1131
  *
805
1132
  * Prefer this when the caller already loaded the secondary database (e.g.
806
1133
  * XATTACH extents preview) to avoid reading the same file twice.
1134
+ *
1135
+ * @param db - Secondary database to draw into the target view.
1136
+ * @param options.targetView - Canvas that receives the overlay (defaults to
1137
+ * the active view). Used by side-by-side → overlay compare without moving scenes.
807
1138
  */
808
- AcApDocManager.prototype.registerOverlayDatabase = function (db) {
1139
+ AcApDocManager.prototype.registerOverlayDatabase = function (db, options) {
809
1140
  return __awaiter(this, void 0, void 0, function () {
810
- var view, layout, overlayId;
811
- return __generator(this, function (_a) {
812
- switch (_a.label) {
1141
+ var view, layout, overlayId, session;
1142
+ var _a, _b;
1143
+ return __generator(this, function (_c) {
1144
+ switch (_c.label) {
813
1145
  case 0:
814
- view = this.curView;
1146
+ view = (_a = options === null || options === void 0 ? void 0 : options.targetView) !== null && _a !== void 0 ? _a : this.curView;
815
1147
  return [4 /*yield*/, view.addOverlayEntities(db)];
816
1148
  case 1:
817
- layout = _a.sent();
1149
+ layout = _c.sent();
818
1150
  overlayId = "overlay-".concat(this._nextOverlayId++);
819
- this._overlays.set(overlayId, { db: db, layout: layout });
1151
+ session = (_b = this._sessions.find(function (s) { return s.context.view === view; })) !== null && _b !== void 0 ? _b : this._activeSession;
1152
+ session.overlays.set(overlayId, { db: db, layout: layout });
820
1153
  view.isDirty = true;
821
1154
  return [2 /*return*/, overlayId];
822
1155
  }
@@ -830,15 +1163,32 @@ var AcApDocManager = /** @class */ (function () {
830
1163
  * @returns True when an overlay with the given id was found and removed.
831
1164
  */
832
1165
  AcApDocManager.prototype.removeOverlay = function (overlayId) {
833
- var overlay = this._overlays.get(overlayId);
834
- if (!overlay)
835
- return false;
836
- var view = this.curView;
837
- view.cadScene.internalScene.remove(overlay.layout.internalObject);
838
- overlay.layout.clear();
839
- this._overlays.delete(overlayId);
840
- view.isDirty = true;
841
- return true;
1166
+ var e_2, _a;
1167
+ try {
1168
+ for (var _b = __values(this._sessions), _c = _b.next(); !_c.done; _c = _b.next()) {
1169
+ var session = _c.value;
1170
+ var overlay = session.overlays.get(overlayId);
1171
+ if (!overlay)
1172
+ continue;
1173
+ var scene = this.sessionCadScene(session);
1174
+ scene.internalScene.remove(overlay.layout.internalObject);
1175
+ overlay.layout.clear();
1176
+ session.overlays.delete(overlayId);
1177
+ if (!session.viewState) {
1178
+ ;
1179
+ session.context.view.isDirty = true;
1180
+ }
1181
+ return true;
1182
+ }
1183
+ }
1184
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1185
+ finally {
1186
+ try {
1187
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1188
+ }
1189
+ finally { if (e_2) throw e_2.error; }
1190
+ }
1191
+ return false;
842
1192
  };
843
1193
  /**
844
1194
  * Shows or hides a previously loaded overlay without removing it.
@@ -848,42 +1198,126 @@ var AcApDocManager = /** @class */ (function () {
848
1198
  * @returns True when an overlay with the given id was found.
849
1199
  */
850
1200
  AcApDocManager.prototype.setOverlayVisible = function (overlayId, visible) {
851
- var overlay = this._overlays.get(overlayId);
852
- if (!overlay)
853
- return false;
854
- overlay.layout.visible = visible;
855
- this.curView.isDirty = true;
856
- return true;
1201
+ var e_3, _a;
1202
+ try {
1203
+ for (var _b = __values(this._sessions), _c = _b.next(); !_c.done; _c = _b.next()) {
1204
+ var session = _c.value;
1205
+ var overlay = session.overlays.get(overlayId);
1206
+ if (!overlay)
1207
+ continue;
1208
+ overlay.layout.visible = visible;
1209
+ session.context.view.isDirty = true;
1210
+ return true;
1211
+ }
1212
+ }
1213
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1214
+ finally {
1215
+ try {
1216
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1217
+ }
1218
+ finally { if (e_3) throw e_3.error; }
1219
+ }
1220
+ return false;
857
1221
  };
858
1222
  /**
859
1223
  * Removes all loaded overlays and disposes their geometry.
1224
+ *
1225
+ * @param view - When set, only overlays on sessions bound to this canvas are cleared.
860
1226
  */
861
- AcApDocManager.prototype.clearOverlays = function () {
862
- var e_1, _a;
1227
+ AcApDocManager.prototype.clearOverlays = function (view) {
1228
+ var e_4, _a, e_5, _b;
1229
+ var sessions = view
1230
+ ? this._sessions.filter(function (s) { return s.context.view === view; })
1231
+ : this._sessions;
863
1232
  try {
864
- for (var _b = __values(__spreadArray([], __read(this._overlays.keys()), false)), _c = _b.next(); !_c.done; _c = _b.next()) {
865
- var overlayId = _c.value;
866
- this.removeOverlay(overlayId);
1233
+ for (var sessions_1 = __values(sessions), sessions_1_1 = sessions_1.next(); !sessions_1_1.done; sessions_1_1 = sessions_1.next()) {
1234
+ var session = sessions_1_1.value;
1235
+ try {
1236
+ for (var _c = (e_5 = void 0, __values(__spreadArray([], __read(session.overlays.keys()), false))), _d = _c.next(); !_d.done; _d = _c.next()) {
1237
+ var overlayId = _d.value;
1238
+ this.removeOverlay(overlayId);
1239
+ }
1240
+ }
1241
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1242
+ finally {
1243
+ try {
1244
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
1245
+ }
1246
+ finally { if (e_5) throw e_5.error; }
1247
+ }
867
1248
  }
868
1249
  }
869
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1250
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
870
1251
  finally {
871
1252
  try {
872
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1253
+ if (sessions_1_1 && !sessions_1_1.done && (_a = sessions_1.return)) _a.call(sessions_1);
873
1254
  }
874
- finally { if (e_1) throw e_1.error; }
1255
+ finally { if (e_4) throw e_4.error; }
1256
+ }
1257
+ };
1258
+ /**
1259
+ * Ids of all currently loaded overlays on the active session (or a view).
1260
+ *
1261
+ * @param view - Optional canvas whose session overlays are listed.
1262
+ */
1263
+ AcApDocManager.prototype.getOverlayIds = function (view) {
1264
+ if (!view) {
1265
+ return Array.from(this._activeSession.overlays.keys());
875
1266
  }
1267
+ var session = this._sessions.find(function (s) { return s.context.view === view; });
1268
+ return session ? Array.from(session.overlays.keys()) : [];
876
1269
  };
877
1270
  Object.defineProperty(AcApDocManager.prototype, "overlayIds", {
878
- /**
879
- * Ids of all currently loaded overlays.
880
- */
1271
+ /** @deprecated Prefer {@link getOverlayIds}. */
881
1272
  get: function () {
882
- return Array.from(this._overlays.keys());
1273
+ return this.getOverlayIds();
883
1274
  },
884
1275
  enumerable: false,
885
1276
  configurable: true
886
1277
  });
1278
+ /**
1279
+ * Enables compare-display mode on a view (default: current view).
1280
+ * Does not automatically color overlay layouts — use
1281
+ * {@link setOverlayCompareDisplay} for those.
1282
+ *
1283
+ * @param options - Compare colors and per-entity role overrides.
1284
+ * @param view - Target canvas; defaults to {@link curView}.
1285
+ */
1286
+ AcApDocManager.prototype.setCompareDisplay = function (options, view) {
1287
+ var target = view !== null && view !== void 0 ? view : this.curView;
1288
+ target.setCompareDisplay(options);
1289
+ };
1290
+ /**
1291
+ * Applies compare-display coloring to one overlay layout.
1292
+ *
1293
+ * @param overlayId - Id returned by {@link loadOverlay} / {@link registerOverlayDatabase}.
1294
+ * @param options - Compare colors and per-entity role overrides.
1295
+ * @param view - Canvas that owns the overlay; omitted to search all sessions.
1296
+ * @returns `true` when the overlay id was found.
1297
+ */
1298
+ AcApDocManager.prototype.setOverlayCompareDisplay = function (overlayId, options, view) {
1299
+ var e_6, _a;
1300
+ var _b;
1301
+ try {
1302
+ for (var _c = __values(this._sessions), _d = _c.next(); !_d.done; _d = _c.next()) {
1303
+ var session = _d.value;
1304
+ var overlay = session.overlays.get(overlayId);
1305
+ if (!overlay)
1306
+ continue;
1307
+ var target = (_b = view !== null && view !== void 0 ? view : session.context.view) !== null && _b !== void 0 ? _b : this.curView;
1308
+ target.setCompareDisplay(options, overlay.layout);
1309
+ return true;
1310
+ }
1311
+ }
1312
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1313
+ finally {
1314
+ try {
1315
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1316
+ }
1317
+ finally { if (e_6) throw e_6.error; }
1318
+ }
1319
+ return false;
1320
+ };
887
1321
  /**
888
1322
  * Returns the rendered layout for a loaded overlay, if any.
889
1323
  *
@@ -891,14 +1325,29 @@ var AcApDocManager = /** @class */ (function () {
891
1325
  * geometry without registering the layout in {@link AcTrScene}.
892
1326
  */
893
1327
  AcApDocManager.prototype.getOverlayLayout = function (overlayId) {
894
- var _a;
895
- return (_a = this._overlays.get(overlayId)) === null || _a === void 0 ? void 0 : _a.layout;
1328
+ var e_7, _a;
1329
+ try {
1330
+ for (var _b = __values(this._sessions), _c = _b.next(); !_c.done; _c = _b.next()) {
1331
+ var session = _c.value;
1332
+ var overlay = session.overlays.get(overlayId);
1333
+ if (overlay)
1334
+ return overlay.layout;
1335
+ }
1336
+ }
1337
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1338
+ finally {
1339
+ try {
1340
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1341
+ }
1342
+ finally { if (e_7) throw e_7.error; }
1343
+ }
1344
+ return undefined;
896
1345
  };
897
1346
  /**
898
1347
  * Creates a new CAD document from the default ISO drawing template.
899
1348
  *
900
- * This method loads the predefined template (`acadiso.dxf`) from {@link baseUrl}
901
- * and replaces the current document in write mode with default open options.
1349
+ * Loads `acadiso.dxf` into a new document session (or reuses the current
1350
+ * unused Untitled). The new drawing is presented as unsaved.
902
1351
  *
903
1352
  * @param options - Optional database opening options merged with write mode
904
1353
  * @returns Promise that resolves to true if the document was successfully created
@@ -910,7 +1359,7 @@ var AcApDocManager = /** @class */ (function () {
910
1359
  */
911
1360
  AcApDocManager.prototype.newDocument = function (options) {
912
1361
  return __awaiter(this, void 0, void 0, function () {
913
- var baseUrl, templateUrl, openOptions, isSuccess;
1362
+ var baseUrl, templateUrl, openOptions, created, isSuccess;
914
1363
  return __generator(this, function (_a) {
915
1364
  switch (_a.label) {
916
1365
  case 0:
@@ -919,18 +1368,27 @@ var AcApDocManager = /** @class */ (function () {
919
1368
  : "".concat(this.baseUrl, "/");
920
1369
  templateUrl = "".concat(baseUrl).concat(DEFAULT_NEW_DRAWING_TEMPLATE);
921
1370
  openOptions = this.setOptions(__assign(__assign({}, options), { mode: AcEdOpenMode.Write }));
922
- this.onBeforeOpenDocument(openOptions);
923
- return [4 /*yield*/, this._openFileProgress.beginOpen(this.context.doc.database)];
1371
+ return [4 /*yield*/, this.ensureOpenSession()];
924
1372
  case 1:
1373
+ created = _a.sent();
1374
+ this.beginOpenProgress();
1375
+ this.onBeforeOpenDocument(openOptions, !created);
1376
+ return [4 /*yield*/, this._openFileProgress.beginOpen(this.context.doc.database)];
1377
+ case 2:
925
1378
  _a.sent();
926
1379
  return [4 /*yield*/, this.context.doc.openUri(templateUrl, openOptions)];
927
- case 2:
1380
+ case 3:
928
1381
  isSuccess = _a.sent();
929
1382
  if (isSuccess) {
930
1383
  this.context.doc.resetNewDocumentIdentity();
931
1384
  }
932
1385
  this.onAfterOpenDocument(isSuccess, openOptions);
933
- return [2 /*return*/, isSuccess];
1386
+ if (!(!isSuccess && created)) return [3 /*break*/, 5];
1387
+ return [4 /*yield*/, this.closeFailedOpenSession()];
1388
+ case 4:
1389
+ _a.sent();
1390
+ _a.label = 5;
1391
+ case 5: return [2 /*return*/, isSuccess];
934
1392
  }
935
1393
  });
936
1394
  });
@@ -1062,6 +1520,7 @@ var AcApDocManager = /** @class */ (function () {
1062
1520
  addSystemCommand('arc', 'arc', new AcApArcCmd());
1063
1521
  addSystemCommand('cachefont', 'cachefont', new AcApCacheFontCmd());
1064
1522
  addSystemCommand('circle', 'circle', new AcApCircleCmd());
1523
+ addSystemCommand('close', 'close', new AcApCloseCmd());
1065
1524
  addSystemCommand('cdxf', 'cdxf', new AcApConvertToDxfCmd());
1066
1525
  addSystemCommand('pngout', 'pngout', new AcApConvertToPngCmd());
1067
1526
  addSystemCommand('entout', 'entout', new AcApEntityPreviewCmd());
@@ -1407,9 +1866,9 @@ var AcApDocManager = /** @class */ (function () {
1407
1866
  * Sets up the active layout block table record ID and model space block table
1408
1867
  * record ID based on the current document's space configuration.
1409
1868
  */
1410
- AcApDocManager.prototype.setActiveLayout = function () {
1411
- var currentView = this.curView;
1412
- var db = this.curDocument.database;
1869
+ AcApDocManager.prototype.setActiveLayout = function (view, database) {
1870
+ var currentView = view !== null && view !== void 0 ? view : this.curView;
1871
+ var db = database !== null && database !== void 0 ? database : this.curDocument.database;
1413
1872
  currentView.activeLayoutBtrId = db.currentSpaceId;
1414
1873
  currentView.modelSpaceBtrId = db.tables.blockTable.modelSpace.objectId;
1415
1874
  };
@@ -1421,23 +1880,29 @@ var AcApDocManager = /** @class */ (function () {
1421
1880
  *
1422
1881
  * @protected
1423
1882
  */
1424
- AcApDocManager.prototype.onBeforeOpenDocument = function (options) {
1883
+ AcApDocManager.prototype.onBeforeOpenDocument = function (options, replaceCurrent) {
1425
1884
  var _a, _b;
1885
+ if (replaceCurrent === void 0) { replaceCurrent = true; }
1426
1886
  this.events.documentToBeOpened.dispatch({
1427
1887
  doc: this.context.doc,
1428
1888
  mode: this.getDocumentEventMode(options)
1429
1889
  });
1430
- // Drop xref sessions first so their overlay ids are removed via unload.
1431
- AcApXrefManager.instance.clearAll();
1432
- this.clearOverlays();
1433
- this.curView.bindDrawDatabase(this.context.doc.database);
1434
- this.curView.progressiveRendering =
1890
+ if (replaceCurrent) {
1891
+ // Drop xref sessions first so their overlay ids are removed via unload.
1892
+ AcApXrefManager.instance.clearAll();
1893
+ this.clearOverlays();
1894
+ // Drop overlay / markup history before view.clear() disposes HTML.
1895
+ resetMeasurementSession();
1896
+ resetMarkupSession();
1897
+ this.openProgressView.clear();
1898
+ }
1899
+ this.openProgressView.bindDrawDatabase(this.context.doc.database);
1900
+ // Progressive convert/paint is gated by this flag (time-sliced yields in
1901
+ // batchConvert). Camera auto-fit is started separately in onAfter when the
1902
+ // open view mode uses zoom-to-fit — not for restored VPORT/saved views.
1903
+ this.openProgressView.progressiveRendering =
1435
1904
  (_a = options === null || options === void 0 ? void 0 : options.progressiveRendering) !== null && _a !== void 0 ? _a : false;
1436
1905
  this._openFileProgress.setSeeThroughOverlay((_b = options === null || options === void 0 ? void 0 : options.progressiveRendering) !== null && _b !== void 0 ? _b : false);
1437
- // Drop overlay / markup history before view.clear() disposes HTML.
1438
- resetMeasurementSession();
1439
- resetMarkupSession();
1440
- this.curView.clear();
1441
1906
  // OPENPROF: start stage timings before db.read / entity flush.
1442
1907
  this._openFileProfiler.begin(this.context.doc.database);
1443
1908
  };
@@ -1459,17 +1924,19 @@ var AcApDocManager = /** @class */ (function () {
1459
1924
  * @protected
1460
1925
  */
1461
1926
  AcApDocManager.prototype.onAfterOpenDocument = function (isSuccess, options) {
1462
- var _a;
1927
+ var _a, _b;
1463
1928
  var recoveredPartialContent = !isSuccess && this.hasRecoverablePartialContent();
1464
1929
  if (isSuccess || recoveredPartialContent) {
1465
- this.context.doc.destroy();
1466
- var doc = this.context.doc;
1930
+ var session = (_a = this._openingSession) !== null && _a !== void 0 ? _a : this._activeSession;
1931
+ var view = session.context.view;
1932
+ session.doc.destroy();
1933
+ var doc = session.doc;
1467
1934
  this.events.documentActivated.dispatch({
1468
1935
  doc: doc,
1469
1936
  mode: this.getDocumentEventMode(options)
1470
1937
  });
1471
- this.setActiveLayout();
1472
- this.curView.syncDisplaySysVars(doc.database);
1938
+ this.setActiveLayout(view, doc.database);
1939
+ view.syncDisplaySysVars(doc.database);
1473
1940
  var db = doc.database;
1474
1941
  // View framing at document open time (see `openViewMode`):
1475
1942
  //
@@ -1502,8 +1969,7 @@ var AcApDocManager = /** @class */ (function () {
1502
1969
  var activeLayout = acdbHostApplicationServices().layoutManager.getActiveLayout(db);
1503
1970
  var layoutLimits = activeLayout === null || activeLayout === void 0 ? void 0 : activeLayout.limits;
1504
1971
  var openViewMode = this.resolveOpenViewMode(options);
1505
- var view = this.curView;
1506
- var progressiveRendering = (_a = options === null || options === void 0 ? void 0 : options.progressiveRendering) !== null && _a !== void 0 ? _a : false;
1972
+ var progressiveRendering = (_b = options === null || options === void 0 ? void 0 : options.progressiveRendering) !== null && _b !== void 0 ? _b : false;
1507
1973
  if (isPaperSpaceActive && layoutLimits && !layoutLimits.isEmpty()) {
1508
1974
  view.zoomTo(layoutLimits);
1509
1975
  }
@@ -1545,14 +2011,13 @@ var AcApDocManager = /** @class */ (function () {
1545
2011
  // state on this layout. Cast is intentional: `setActiveLayout`
1546
2012
  // above relies on `curView` being an `AcTrView2d`, and the
1547
2013
  // markLayoutAsInitialized method is part of that contract.
1548
- ;
1549
- this.curView.markLayoutAsInitialized(db.currentSpaceId);
2014
+ view.markLayoutAsInitialized(db.currentSpaceId);
1550
2015
  // OPENPROF: db.read is done; wait for batchConvert to drain, then print.
1551
2016
  this._openFileProfiler.markReadCompleteAndScheduleReport(view);
1552
2017
  }
1553
2018
  else {
1554
2019
  this._openFileProfiler.cancel();
1555
- this.curView.endProgressiveOpenFit();
2020
+ this.openProgressView.endProgressiveOpenFit();
1556
2021
  this.regen();
1557
2022
  }
1558
2023
  };
@@ -1591,7 +2056,8 @@ var AcApDocManager = /** @class */ (function () {
1591
2056
  * @protected
1592
2057
  */
1593
2058
  AcApDocManager.prototype.hasRecoverablePartialContent = function () {
1594
- var db = this.context.doc.database;
2059
+ var _a;
2060
+ var db = ((_a = this._openingSession) !== null && _a !== void 0 ? _a : this._activeSession).doc.database;
1595
2061
  // `db.extents` comes from the DWG/DXF header, and some DXF files omit it
1596
2062
  // entirely, leaving it empty even when entities parsed successfully. Check
1597
2063
  // for actual entities in model space first, and only fall back to the
@@ -1685,6 +2151,60 @@ var AcApDocManager = /** @class */ (function () {
1685
2151
  AcApDocManager.prototype.showBusyIndicator = function (message) {
1686
2152
  this._busyIndicator.show(message);
1687
2153
  };
2154
+ /**
2155
+ * Moves busy/open-file overlays onto `host`.
2156
+ *
2157
+ * In split view the host is overridden to the canvas being opened or focused.
2158
+ *
2159
+ * @param host - Default overlay parent when not in split view.
2160
+ */
2161
+ AcApDocManager.prototype.setBusyIndicatorHost = function (host) {
2162
+ this._busyIndicatorHost = host;
2163
+ this.syncProgressOverlayHost();
2164
+ };
2165
+ Object.defineProperty(AcApDocManager.prototype, "openProgressView", {
2166
+ /**
2167
+ * Pins progress overlays to the canvas being opened, or the active canvas
2168
+ * when a split view exists.
2169
+ */
2170
+ get: function () {
2171
+ var _a, _b;
2172
+ return (_b = (_a = this._openingSession) === null || _a === void 0 ? void 0 : _a.context.view) !== null && _b !== void 0 ? _b : this.curView;
2173
+ },
2174
+ enumerable: false,
2175
+ configurable: true
2176
+ });
2177
+ /**
2178
+ * Pins the open-file overlay to the session that is currently reading a file.
2179
+ */
2180
+ AcApDocManager.prototype.beginOpenProgress = function () {
2181
+ this._openingSession = this._activeSession;
2182
+ this.syncProgressOverlayHost();
2183
+ };
2184
+ /**
2185
+ * Releases the open-file overlay pin after the spinner hides.
2186
+ */
2187
+ AcApDocManager.prototype.onOpenProgressHidden = function () {
2188
+ var opening = this._openingSession;
2189
+ this._openingSession = undefined;
2190
+ if (opening &&
2191
+ this._sessions.includes(opening) &&
2192
+ opening !== this._activeSession) {
2193
+ opening.context.suspend();
2194
+ }
2195
+ this.syncProgressOverlayHost();
2196
+ };
2197
+ /**
2198
+ * Pins progress overlays to the canvas being opened when a split view exists.
2199
+ *
2200
+ * @param view - Canvas whose container receives the overlay.
2201
+ */
2202
+ AcApDocManager.prototype.syncProgressOverlayHost = function (view) {
2203
+ if (view === void 0) { view = this.openProgressView; }
2204
+ var host = this._splitView ? view.container : this._busyIndicatorHost;
2205
+ this._openFileProgress.setHost(host);
2206
+ this._busyIndicator.setHost(host);
2207
+ };
1688
2208
  /**
1689
2209
  * Hides the spinner overlay shown by {@link showBusyIndicator}.
1690
2210
  *
@@ -1793,6 +2313,172 @@ var AcApDocManager = /** @class */ (function () {
1793
2313
  });
1794
2314
  });
1795
2315
  };
2316
+ /**
2317
+ * Forwards database open-progress events to the overlay and header sysvars.
2318
+ *
2319
+ * @param doc - Document whose `openProgress` events should drive the overlay.
2320
+ */
2321
+ AcApDocManager.prototype.bindOpenProgress = function (doc) {
2322
+ var _this = this;
2323
+ doc.database.events.openProgress.addEventListener(function (args) {
2324
+ var _a;
2325
+ _this._openFileProgress.handle({
2326
+ database: doc.database,
2327
+ percentage: args.percentage,
2328
+ stage: args.stage,
2329
+ subStage: args.subStage,
2330
+ subStageStatus: args.subStageStatus,
2331
+ data: args.data
2332
+ });
2333
+ if (args.subStage !== 'HEADER') {
2334
+ return;
2335
+ }
2336
+ var session = _this._sessions.find(function (item) { return item.doc === doc; });
2337
+ var view = (_a = session === null || session === void 0 ? void 0 : session.context.view) !== null && _a !== void 0 ? _a : _this.curView;
2338
+ view.ltscale = doc.database.ltscale;
2339
+ view.celtscale = doc.database.celtscale;
2340
+ view.renderer.showLineWeight = doc.database.lwdisplay;
2341
+ });
2342
+ };
2343
+ /**
2344
+ * Parks the live view onto the active session so another document can take the canvas.
2345
+ */
2346
+ AcApDocManager.prototype.parkActiveSession = function () {
2347
+ this._activeSession.context.suspend();
2348
+ this._activeSession.viewState = this.curView.captureSessionState();
2349
+ };
2350
+ /**
2351
+ * Reuses an Untitled on `targetView` when it has no file identity and no
2352
+ * entities; otherwise creates a new session on that view.
2353
+ *
2354
+ * When `targetView` is a different canvas (split comparison), the current
2355
+ * view keeps rendering — GPU scenes are never moved between renderers.
2356
+ *
2357
+ * @param targetView - Canvas that will receive the open; defaults to {@link curView}.
2358
+ * @returns True when a new session was created.
2359
+ */
2360
+ AcApDocManager.prototype.ensureOpenSession = function (targetView) {
2361
+ return __awaiter(this, void 0, void 0, function () {
2362
+ var view, occupant, doc, context, session;
2363
+ return __generator(this, function (_a) {
2364
+ switch (_a.label) {
2365
+ case 0:
2366
+ view = targetView !== null && targetView !== void 0 ? targetView : this.curView;
2367
+ if (view === this.curView && this.curDocument.isReusableUntitled) {
2368
+ return [2 /*return*/, false];
2369
+ }
2370
+ occupant = this._sessions.find(function (session) { return session.context.view === view; });
2371
+ if (!(occupant === null || occupant === void 0 ? void 0 : occupant.doc.isReusableUntitled)) return [3 /*break*/, 3];
2372
+ if (!(occupant !== this._activeSession)) return [3 /*break*/, 2];
2373
+ return [4 /*yield*/, this.activateDocument(occupant.doc)];
2374
+ case 1:
2375
+ _a.sent();
2376
+ _a.label = 2;
2377
+ case 2: return [2 /*return*/, false];
2378
+ case 3: return [4 /*yield*/, this._commandManager.cancelActive()];
2379
+ case 4:
2380
+ _a.sent();
2381
+ this._activeSession.context.suspend();
2382
+ if (view === this.curView) {
2383
+ this._activeSession.viewState = this.curView.beginNewSession();
2384
+ }
2385
+ doc = new AcApDocument();
2386
+ context = new AcApContext(view, doc);
2387
+ session = new AcApDocSession("doc-".concat(this._nextSessionId++), context);
2388
+ this._sessions.push(session);
2389
+ this._activeSession = session;
2390
+ acapBindMarkupSession(session.id);
2391
+ acdbHostApplicationServices().workingDatabase = doc.database;
2392
+ this._pluginManager.setContext(context);
2393
+ this.bindOpenProgress(doc);
2394
+ this.events.documentCreated.dispatch({
2395
+ doc: doc,
2396
+ mode: doc.openMode
2397
+ });
2398
+ return [2 /*return*/, true];
2399
+ }
2400
+ });
2401
+ });
2402
+ };
2403
+ /**
2404
+ * Drops a session created for an open that failed before activation completed.
2405
+ */
2406
+ AcApDocManager.prototype.closeFailedOpenSession = function () {
2407
+ return __awaiter(this, void 0, void 0, function () {
2408
+ return __generator(this, function (_a) {
2409
+ switch (_a.label) {
2410
+ case 0:
2411
+ if (this._sessions.length <= 1) {
2412
+ return [2 /*return*/];
2413
+ }
2414
+ return [4 /*yield*/, this.closeDocument(this.curDocument)];
2415
+ case 1:
2416
+ _a.sent();
2417
+ return [2 /*return*/];
2418
+ }
2419
+ });
2420
+ });
2421
+ };
2422
+ /**
2423
+ * Replaces the last remaining session with a fresh Untitled drawing.
2424
+ *
2425
+ * @param session - The only remaining session to recycle.
2426
+ */
2427
+ AcApDocManager.prototype.resetActiveSessionToUntitled = function (session) {
2428
+ var oldDoc = session.doc;
2429
+ var oldId = session.id;
2430
+ AcApXrefManager.instance.clearAll();
2431
+ this.clearOverlays();
2432
+ resetMeasurementSession();
2433
+ resetMarkupSession();
2434
+ this.curView.clear();
2435
+ session.context.dispose();
2436
+ oldDoc.destroy();
2437
+ acapDisposeMarkupSession(oldId);
2438
+ var doc = new AcApDocument();
2439
+ var context = new AcApContext(this.curView, doc);
2440
+ var replacement = new AcApDocSession("doc-".concat(this._nextSessionId++), context);
2441
+ this._sessions = [replacement];
2442
+ this._activeSession = replacement;
2443
+ acapBindMarkupSession(replacement.id);
2444
+ acdbHostApplicationServices().workingDatabase = doc.database;
2445
+ this._pluginManager.setContext(context);
2446
+ this.bindOpenProgress(doc);
2447
+ this.curView.bindDrawDatabase(doc.database);
2448
+ };
2449
+ /**
2450
+ * Removes overlay layouts belonging to a session being closed.
2451
+ *
2452
+ * @param session - Session whose overlays should be disposed.
2453
+ */
2454
+ AcApDocManager.prototype.clearSessionOverlays = function (session) {
2455
+ var e_8, _a;
2456
+ var scene = this.sessionCadScene(session);
2457
+ try {
2458
+ for (var _b = __values(session.overlays.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
2459
+ var overlay = _c.value;
2460
+ scene.internalScene.remove(overlay.layout.internalObject);
2461
+ overlay.layout.clear();
2462
+ }
2463
+ }
2464
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
2465
+ finally {
2466
+ try {
2467
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2468
+ }
2469
+ finally { if (e_8) throw e_8.error; }
2470
+ }
2471
+ session.overlays.clear();
2472
+ };
2473
+ /**
2474
+ * Scene that currently owns `session`'s overlay layouts.
2475
+ * Parked sessions keep overlays on {@link AcApDocSession.viewState}; live
2476
+ * split-view sessions keep them on their own canvas, not {@link curView}.
2477
+ */
2478
+ AcApDocManager.prototype.sessionCadScene = function (session) {
2479
+ var _a, _b;
2480
+ return ((_b = (_a = session.viewState) === null || _a === void 0 ? void 0 : _a.scene) !== null && _b !== void 0 ? _b : session.context.view.cadScene);
2481
+ };
1796
2482
  return AcApDocManager;
1797
2483
  }());
1798
2484
  export { AcApDocManager };