@mlightcad/cad-simple-viewer 1.7.6-preview.0 → 1.7.7-preview.0

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 (157) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -190
  3. package/dist/cad-simple-viewer.js +7925 -7381
  4. package/dist/cad-simple-viewer.umd.cjs +116 -116
  5. package/dist/mtext-renderer-worker.js +14124 -8730
  6. package/find.ts +7 -7
  7. package/icons.ts +7 -7
  8. package/lib/app/AcApDocManager.d.ts.map +1 -1
  9. package/lib/app/AcApDocManager.js +67 -72
  10. package/lib/app/AcApDocManager.js.map +1 -1
  11. package/lib/app/AcApOpenDatabaseOptions.d.ts +8 -2
  12. package/lib/app/AcApOpenDatabaseOptions.d.ts.map +1 -1
  13. package/lib/command/convert/AcApEntityPreviewCmd.d.ts.map +1 -1
  14. package/lib/command/convert/AcApEntityPreviewCmd.js +1 -0
  15. package/lib/command/convert/AcApEntityPreviewCmd.js.map +1 -1
  16. package/lib/command/convert/AcApRasterImageConvertor.d.ts +17 -8
  17. package/lib/command/convert/AcApRasterImageConvertor.d.ts.map +1 -1
  18. package/lib/command/convert/AcApRasterImageConvertor.js +50 -12
  19. package/lib/command/convert/AcApRasterImageConvertor.js.map +1 -1
  20. package/lib/command/draw/AcApHatchCmd.d.ts.map +1 -1
  21. package/lib/command/draw/AcApHatchCmd.js +1 -0
  22. package/lib/command/draw/AcApHatchCmd.js.map +1 -1
  23. package/lib/command/layer/AcApLayerIsoCmd.d.ts.map +1 -1
  24. package/lib/command/layer/AcApLayerIsoCmd.js +1 -0
  25. package/lib/command/layer/AcApLayerIsoCmd.js.map +1 -1
  26. package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -1
  27. package/lib/editor/grip/AcEdGripEditSession.js +6 -1
  28. package/lib/editor/grip/AcEdGripEditSession.js.map +1 -1
  29. package/lib/editor/grip/AcEdGripManager.d.ts.map +1 -1
  30. package/lib/editor/grip/AcEdGripManager.js +2 -1
  31. package/lib/editor/grip/AcEdGripManager.js.map +1 -1
  32. package/lib/editor/input/AcEdOsnapCenterMarks.d.ts +15 -2
  33. package/lib/editor/input/AcEdOsnapCenterMarks.d.ts.map +1 -1
  34. package/lib/editor/input/AcEdOsnapCenterMarks.js +63 -13
  35. package/lib/editor/input/AcEdOsnapCenterMarks.js.map +1 -1
  36. package/lib/editor/input/AcEdOsnapResolver.d.ts +14 -0
  37. package/lib/editor/input/AcEdOsnapResolver.d.ts.map +1 -1
  38. package/lib/editor/input/AcEdOsnapResolver.js +246 -32
  39. package/lib/editor/input/AcEdOsnapResolver.js.map +1 -1
  40. package/lib/editor/input/AcEdSelectionFilter.d.ts +6 -0
  41. package/lib/editor/input/AcEdSelectionFilter.d.ts.map +1 -1
  42. package/lib/editor/input/AcEdSelectionFilter.js +19 -2
  43. package/lib/editor/input/AcEdSelectionFilter.js.map +1 -1
  44. package/lib/editor/input/AcEditor.d.ts +6 -0
  45. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  46. package/lib/editor/input/AcEditor.js +9 -0
  47. package/lib/editor/input/AcEditor.js.map +1 -1
  48. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts +8 -0
  49. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts.map +1 -1
  50. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js +16 -0
  51. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js.map +1 -1
  52. package/lib/editor/input/ui/AcEdCommandLine.d.ts +12 -0
  53. package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
  54. package/lib/editor/input/ui/AcEdCommandLine.js +54 -16
  55. package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
  56. package/lib/editor/input/ui/AcEdInputManager.d.ts +15 -0
  57. package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
  58. package/lib/editor/input/ui/AcEdInputManager.js +47 -16
  59. package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
  60. package/lib/editor/view/AcEdBaseView.d.ts +50 -0
  61. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  62. package/lib/editor/view/AcEdBaseView.js +73 -44
  63. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  64. package/lib/editor/view/AcEdSpatialQueryResult.d.ts +7 -0
  65. package/lib/editor/view/AcEdSpatialQueryResult.d.ts.map +1 -1
  66. package/lib/editor/view/AcEdSpatialQueryResult.js.map +1 -1
  67. package/lib/find/findText.d.ts.map +1 -1
  68. package/lib/find/findText.js +49 -15
  69. package/lib/find/findText.js.map +1 -1
  70. package/lib/i18n/ar/jig.d.ts +2 -0
  71. package/lib/i18n/ar/jig.d.ts.map +1 -1
  72. package/lib/i18n/ar/jig.js +1 -1
  73. package/lib/i18n/ar/jig.js.map +1 -1
  74. package/lib/i18n/ar/main.d.ts +1 -0
  75. package/lib/i18n/ar/main.d.ts.map +1 -1
  76. package/lib/i18n/ar/main.js +1 -0
  77. package/lib/i18n/ar/main.js.map +1 -1
  78. package/lib/i18n/cs/jig.d.ts +2 -0
  79. package/lib/i18n/cs/jig.d.ts.map +1 -1
  80. package/lib/i18n/cs/jig.js +2 -0
  81. package/lib/i18n/cs/jig.js.map +1 -1
  82. package/lib/i18n/cs/main.d.ts +1 -0
  83. package/lib/i18n/cs/main.d.ts.map +1 -1
  84. package/lib/i18n/cs/main.js +1 -0
  85. package/lib/i18n/cs/main.js.map +1 -1
  86. package/lib/i18n/en/jig.d.ts +2 -0
  87. package/lib/i18n/en/jig.d.ts.map +1 -1
  88. package/lib/i18n/en/jig.js +2 -0
  89. package/lib/i18n/en/jig.js.map +1 -1
  90. package/lib/i18n/en/main.d.ts +1 -0
  91. package/lib/i18n/en/main.d.ts.map +1 -1
  92. package/lib/i18n/en/main.js +1 -0
  93. package/lib/i18n/en/main.js.map +1 -1
  94. package/lib/i18n/tr/jig.d.ts +2 -0
  95. package/lib/i18n/tr/jig.d.ts.map +1 -1
  96. package/lib/i18n/tr/jig.js +2 -0
  97. package/lib/i18n/tr/jig.js.map +1 -1
  98. package/lib/i18n/tr/main.d.ts +1 -0
  99. package/lib/i18n/tr/main.d.ts.map +1 -1
  100. package/lib/i18n/tr/main.js +1 -0
  101. package/lib/i18n/tr/main.js.map +1 -1
  102. package/lib/i18n/zh/jig.d.ts +2 -0
  103. package/lib/i18n/zh/jig.d.ts.map +1 -1
  104. package/lib/i18n/zh/jig.js +2 -0
  105. package/lib/i18n/zh/jig.js.map +1 -1
  106. package/lib/i18n/zh/main.d.ts +1 -0
  107. package/lib/i18n/zh/main.d.ts.map +1 -1
  108. package/lib/i18n/zh/main.js +1 -0
  109. package/lib/i18n/zh/main.js.map +1 -1
  110. package/lib/service/AcApEntitySelection.d.ts.map +1 -1
  111. package/lib/service/AcApEntitySelection.js +34 -4
  112. package/lib/service/AcApEntitySelection.js.map +1 -1
  113. package/lib/service/AcApEntityService.d.ts.map +1 -1
  114. package/lib/service/AcApEntityService.js +11 -0
  115. package/lib/service/AcApEntityService.js.map +1 -1
  116. package/lib/service/AcApLayerService.d.ts +8 -1
  117. package/lib/service/AcApLayerService.d.ts.map +1 -1
  118. package/lib/service/AcApLayerService.js +10 -0
  119. package/lib/service/AcApLayerService.js.map +1 -1
  120. package/lib/service/AcApLockedLayer.d.ts +23 -0
  121. package/lib/service/AcApLockedLayer.d.ts.map +1 -0
  122. package/lib/service/AcApLockedLayer.js +94 -0
  123. package/lib/service/AcApLockedLayer.js.map +1 -0
  124. package/lib/service/index.d.ts +1 -0
  125. package/lib/service/index.d.ts.map +1 -1
  126. package/lib/service/index.js +1 -0
  127. package/lib/service/index.js.map +1 -1
  128. package/lib/ui/icons.d.ts +5 -2
  129. package/lib/ui/icons.d.ts.map +1 -1
  130. package/lib/ui/icons.js +5 -2
  131. package/lib/ui/icons.js.map +1 -1
  132. package/lib/util/AcApLayoutViewFraming.d.ts +68 -0
  133. package/lib/util/AcApLayoutViewFraming.d.ts.map +1 -0
  134. package/lib/util/AcApLayoutViewFraming.js +146 -0
  135. package/lib/util/AcApLayoutViewFraming.js.map +1 -0
  136. package/lib/util/index.d.ts +1 -0
  137. package/lib/util/index.d.ts.map +1 -1
  138. package/lib/util/index.js +1 -0
  139. package/lib/util/index.js.map +1 -1
  140. package/lib/view/AcTrDirectBatch.d.ts +4 -14
  141. package/lib/view/AcTrDirectBatch.d.ts.map +1 -1
  142. package/lib/view/AcTrDirectBatch.js +4 -120
  143. package/lib/view/AcTrDirectBatch.js.map +1 -1
  144. package/lib/view/AcTrScene.d.ts +1 -1
  145. package/lib/view/AcTrScene.d.ts.map +1 -1
  146. package/lib/view/AcTrView2d.d.ts +75 -38
  147. package/lib/view/AcTrView2d.d.ts.map +1 -1
  148. package/lib/view/AcTrView2d.js +313 -141
  149. package/lib/view/AcTrView2d.js.map +1 -1
  150. package/lib/view/AcTrViewSessionState.d.ts +7 -0
  151. package/lib/view/AcTrViewSessionState.d.ts.map +1 -1
  152. package/package.json +11 -11
  153. package/src/find/AcApFindNavigator.ts +190 -190
  154. package/src/find/findDrawing.ts +211 -211
  155. package/src/find/findText.ts +624 -595
  156. package/src/find/index.ts +2 -2
  157. package/src/ui/icons.ts +411 -408
@@ -105,6 +105,7 @@ import * as THREE from 'three';
105
105
  import Stats from 'three/examples/jsm/libs/stats.module';
106
106
  import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
107
107
  import { AcApDocManager, AcApSettingManager } from '../app';
108
+ import { AcApOpenViewMode } from '../app/AcApOpenDatabaseOptions';
108
109
  import { AcApZoomCmd } from '../command/AcApZoomCmd';
109
110
  import { isMarkupHtmlTextEditing } from '../command/markup/AcApMarkupTextEdit';
110
111
  import { notifyMeasurementLayoutChanged } from '../command/measure/AcApMeasurementStore';
@@ -115,6 +116,7 @@ import { acedEntityIntersectsSelectionBox, acedNeedsCrossingGeometryRefine } fro
115
116
  import { isEffectiveSpatialQueryHit } from '../editor/view/AcEdSpatialQueryResult';
116
117
  import { AcTrGeometryUtil } from '../util';
117
118
  import { acapRunDatabaseEdit } from '../util/AcApDatabaseEdit';
119
+ import { acapResolveLayoutFrameBox } from '../util/AcApLayoutViewFraming';
118
120
  import { collectTextStyleFontNames, planTextStyleFontPreload } from '../util/AcApTextStyleFontPreload';
119
121
  import { ACAP_READING_MODE_BACKGROUND, AcApReadingModeState } from './AcApReadingMode';
120
122
  import { trySelectReviewOverlay, trySelectReviewOverlaysByBox } from './AcEdReviewOverlayPick';
@@ -180,6 +182,11 @@ var AcTrView2d = /** @class */ (function (_super) {
180
182
  var container = (_a = mergedOptions.container) !== null && _a !== void 0 ? _a : document.createElement('div');
181
183
  mergedOptions.container = container;
182
184
  container.style.overflow = 'hidden';
185
+ // Allow focusing the container after canvas clicks so document-level
186
+ // shortcuts stay scoped to this viewer without stealing host-page focus.
187
+ if (!container.hasAttribute('tabindex')) {
188
+ container.tabIndex = -1;
189
+ }
183
190
  var renderer = new THREE.WebGLRenderer({
184
191
  antialias: true,
185
192
  alpha: true
@@ -242,6 +249,12 @@ var AcTrView2d = /** @class */ (function (_super) {
242
249
  * race during document open.
243
250
  */
244
251
  _this._externallyFramedLayouts = new Set();
252
+ /**
253
+ * Open options → Initial view (`Extents` / `Saved`) for this document.
254
+ * Applied at document open for the startup layout, and again on the
255
+ * **first visit** to every other layout the user has not framed yet.
256
+ */
257
+ _this._openViewMode = AcApOpenViewMode.Extents;
245
258
  /**
246
259
  * Layer names with an in-flight {@link convertMissingEntitiesOnLayer} pass.
247
260
  *
@@ -359,6 +372,12 @@ var AcTrView2d = /** @class */ (function (_super) {
359
372
  * ENTITY parse and linework convert; glyph jobs await this before draw.
360
373
  */
361
374
  _this._textStyleFontPreloadPromise = null;
375
+ /**
376
+ * Aborts canvas / document DOM listeners registered on this view.
377
+ * Custom singleton listeners are removed explicitly in {@link dispose}.
378
+ */
379
+ _this._viewDomAbort = new AbortController();
380
+ _this._viewDisposed = false;
362
381
  /** Transient reading mode forces black linework on a white canvas. */
363
382
  _this._readingMode = new AcApReadingModeState({
364
383
  getCurrentBackgroundColor: function () { return _this._renderer.currentBackgroundColor; },
@@ -442,16 +461,27 @@ var AcTrView2d = /** @class */ (function (_super) {
442
461
  };
443
462
  _this._disposeCanvasTouchCallout = disposeCanvasTouchCallout;
444
463
  var onProgressiveInput = function () { return _this.noteProgressiveUserInput(); };
445
- renderer.domElement.addEventListener('pointerdown', onProgressiveInput, {
464
+ // Pointer and wheel both claim shortcut focus so undo/erase still work
465
+ // after zooming without a prior click, without stealing focus from host
466
+ // inputs/textareas/contenteditable fields.
467
+ var onCanvasPointerDown = function () {
468
+ onProgressiveInput();
469
+ _this.focusViewerForShortcuts();
470
+ };
471
+ var onCanvasWheel = function () {
472
+ onProgressiveInput();
473
+ _this.focusViewerForShortcuts();
474
+ };
475
+ renderer.domElement.addEventListener('pointerdown', onCanvasPointerDown, {
446
476
  capture: true
447
477
  });
448
- renderer.domElement.addEventListener('wheel', onProgressiveInput, {
478
+ renderer.domElement.addEventListener('wheel', onCanvasWheel, {
449
479
  capture: true,
450
480
  passive: true
451
481
  });
452
482
  _this._disposeProgressiveInputWatch = function () {
453
- renderer.domElement.removeEventListener('pointerdown', onProgressiveInput, { capture: true });
454
- renderer.domElement.removeEventListener('wheel', onProgressiveInput, {
483
+ renderer.domElement.removeEventListener('pointerdown', onCanvasPointerDown, { capture: true });
484
+ renderer.domElement.removeEventListener('wheel', onCanvasWheel, {
455
485
  capture: true
456
486
  });
457
487
  };
@@ -468,27 +498,32 @@ var AcTrView2d = /** @class */ (function (_super) {
468
498
  setAcTrDrawOrderZAllocator(function () { return _this._renderer.allocateDrawOrderZ(); });
469
499
  var fontMapping = AcApSettingManager.instance.fontMapping;
470
500
  _this._renderer.setFontMapping(fontMapping);
471
- _this._renderer.events.fontNotFound.addEventListener(function (args) {
501
+ _this._onFontNotFound = function (args) {
472
502
  var _a;
473
503
  eventBus.emit('font-not-found', {
474
504
  fontName: args.fontName,
475
505
  count: (_a = args.count) !== null && _a !== void 0 ? _a : 0
476
506
  });
477
- });
478
- _this._renderer.events.fontLoaded.addEventListener(function (args) {
507
+ };
508
+ _this._onFontLoaded = function (args) {
479
509
  // Lazy load success clears FontManager.missedFonts; refresh status-bar state.
480
510
  eventBus.emit('missed-data-changed', {});
481
511
  // On-demand faces (e.g. style `malgun`) may finish after the first glyph
482
512
  // bake. Rebuild text so Hangul is not left as permanent '?'.
483
513
  _this.scheduleGlyphRedrawAfterFontLoad(args === null || args === void 0 ? void 0 : args.fontName);
484
- });
514
+ };
515
+ _this._renderer.events.fontNotFound.addEventListener(_this._onFontNotFound);
516
+ _this._renderer.events.fontLoaded.addEventListener(_this._onFontLoaded);
485
517
  _this._scene = _this.createScene();
486
518
  _this._layerAppearance = new AcTrLayerAppearanceController(_this._scene, _this._renderer);
487
519
  _this._inheritedLayerMaterialMapper = new AcTrInheritedLayerMaterialMapper(function (layerName) { return _this._layerAppearance.getEffectiveLayerTraits(layerName); }, _this._renderer);
488
520
  // Initialize background color through setter to keep renderer/cursor in sync.
489
521
  _this.backgroundColor =
490
522
  (_b = mergedOptions.background) !== null && _b !== void 0 ? _b : ACGI_MODEL_SPACE_BACKGROUND;
491
- _this._stats = _this.createStats(AcApSettingManager.instance.isShowStats && _this.isActiveManagedView());
523
+ // During main-view construction the manager singleton is not published yet,
524
+ // so treat a missing manager as "this is the primary canvas".
525
+ _this._stats = _this.createStats(AcApSettingManager.instance.isShowStats &&
526
+ (AcApDocManager.tryGetInstance() == null || _this.isActiveManagedView()));
492
527
  // Layout background sysvars drive the canvas clear colour and ACI-7
493
528
  // inversion (`MODELBKCOLOR` for model space, `PAPERBKCOLOR` for the
494
529
  // active layout). `COLORTHEME` only affects UI chrome — see
@@ -496,23 +531,28 @@ var AcTrView2d = /** @class */ (function (_super) {
496
531
  var sysVarManager = AcDbSysVarManager.instance();
497
532
  var modelBkVar = AcDbSystemVariables.MODELBKCOLOR.toLowerCase();
498
533
  var paperBkVar = AcDbSystemVariables.PAPERBKCOLOR.toLowerCase();
499
- sysVarManager.events.sysVarChanged.addEventListener(function (args) {
534
+ _this._onSysVarChanged = function (args) {
500
535
  var nameLower = args.name.toLowerCase();
501
536
  if (nameLower === modelBkVar || nameLower === paperBkVar) {
502
- var isModelSpace = _this.isModelSpaceLayout(args.database);
537
+ var database = args.database;
538
+ if (!database)
539
+ return;
540
+ var isModelSpace = _this.isModelSpaceLayout(database);
503
541
  var applies = (nameLower === modelBkVar && isModelSpace) ||
504
542
  (nameLower === paperBkVar && !isModelSpace);
505
543
  if (!applies) {
506
544
  return;
507
545
  }
508
- _this.applyCanvasBackground(readLayoutBackgroundColor(args.database, isModelSpace));
546
+ _this.applyCanvasBackground(readLayoutBackgroundColor(database, isModelSpace));
509
547
  }
510
- });
511
- AcApSettingManager.instance.events.modified.addEventListener(function (args) {
548
+ };
549
+ sysVarManager.events.sysVarChanged.addEventListener(_this._onSysVarChanged);
550
+ _this._onSettingsModified = function (args) {
512
551
  if (args.key == 'isShowStats') {
513
552
  _this.toggleStatsVisibility(_this._stats, args.value);
514
553
  }
515
- });
554
+ };
555
+ AcApSettingManager.instance.events.modified.addEventListener(_this._onSettingsModified);
516
556
  var selectionStartWcs = null;
517
557
  var selectionStartCanvas = null;
518
558
  var selectionPreviewEl = null;
@@ -618,6 +658,7 @@ var AcTrView2d = /** @class */ (function (_super) {
618
658
  selectionStartWcs = null;
619
659
  selectionStartCanvas = null;
620
660
  };
661
+ var viewDomSignal = _this._viewDomAbort.signal;
621
662
  _this.canvas.addEventListener('mousedown', function (e) {
622
663
  if (e.button !== 0)
623
664
  return;
@@ -627,7 +668,7 @@ var AcTrView2d = /** @class */ (function (_super) {
627
668
  return;
628
669
  }
629
670
  beginSelectionPreview(e.clientX, e.clientY);
630
- });
671
+ }, { signal: viewDomSignal });
631
672
  _this.canvas.addEventListener('mousemove', function (e) {
632
673
  if (!selectionStartWcs || !selectionPreviewEl || !selectionStartCanvas) {
633
674
  return;
@@ -636,7 +677,7 @@ var AcTrView2d = /** @class */ (function (_super) {
636
677
  return;
637
678
  }
638
679
  updateSelectionPreview(e.clientX, e.clientY, _this.getPointerSelectionAction(e));
639
- });
680
+ }, { signal: viewDomSignal });
640
681
  _this.canvas.addEventListener('mouseup', function (e) {
641
682
  if (_this._gripManager.isDragging) {
642
683
  resetSelectionDrag();
@@ -653,8 +694,8 @@ var AcTrView2d = /** @class */ (function (_super) {
653
694
  });
654
695
  var action = _this.getPointerSelectionAction(e);
655
696
  finishSelection(e.clientX, e.clientY, action, _this.isSelectionClick(selectionStartCanvas, endCanvas));
656
- });
657
- acedAttachMobileBoxGesture({
697
+ }, { signal: viewDomSignal });
698
+ _this._disposeMobileBoxGesture = acedAttachMobileBoxGesture({
658
699
  element: _this.canvas,
659
700
  shouldStart: function () { return canHandleMobileBoxGesture(); },
660
701
  setNavigationEnabled: function (enabled) {
@@ -693,16 +734,19 @@ var AcTrView2d = /** @class */ (function (_super) {
693
734
  return;
694
735
  }
695
736
  void _this.openPickedEntityEditor(e);
696
- });
737
+ }, { signal: viewDomSignal });
697
738
  // When using OrbitControls in THREE.js, it attaches its own event listeners to the DOM elements,
698
739
  // such as the canvas or the entire document. This can interfere with other event listeners you
699
- // add, including the keydown event.
740
+ // add, including the keydown event. Scope to this view's container so host-page shortcuts
741
+ // (and post-destroy key presses) are not captured.
700
742
  document.addEventListener('keydown', function (e) {
701
743
  if (!_this.isActiveManagedView())
702
744
  return;
745
+ if (!_this.isShortcutEventInsideViewer(e))
746
+ return;
703
747
  _this._keyHandler.handleKeyDown(e);
704
- });
705
- acdbHostApplicationServices().layoutManager.events.layoutSwitched.addEventListener(function (args) {
748
+ }, { signal: viewDomSignal });
749
+ _this._onLayoutSwitched = function (args) {
706
750
  var _a, _b;
707
751
  if (!_this.isActiveManagedView())
708
752
  return;
@@ -742,7 +786,8 @@ var AcTrView2d = /** @class */ (function (_super) {
742
786
  if (isFirstVisit) {
743
787
  _this.applyInitialZoom(btrId, args.layout);
744
788
  }
745
- });
789
+ };
790
+ acdbHostApplicationServices().layoutManager.events.layoutSwitched.addEventListener(_this._onLayoutSwitched);
746
791
  _this._css2dRenderer = new CSS2DRenderer();
747
792
  _this._css2dRenderer.setSize(_this.width, _this.height);
748
793
  _this._css2dRenderer.domElement.style.position = 'absolute';
@@ -841,12 +886,14 @@ var AcTrView2d = /** @class */ (function (_super) {
841
886
  // This method is called after camera and render are created.
842
887
  // Children class can override this method to add its own logic
843
888
  this.setCursor(AcEdCorsorType.Crosshair);
844
- this.editor.events.commandWillStart.addEventListener(function () {
889
+ this._onCommandWillStartHitTest = function () {
845
890
  _this.htmlTransientManager.setHitTestEnabled(false);
846
- });
847
- this.editor.events.commandEnded.addEventListener(function () {
891
+ };
892
+ this._onCommandEndedHitTest = function () {
848
893
  _this.htmlTransientManager.setHitTestEnabled(true);
849
- });
894
+ };
895
+ this.editor.events.commandWillStart.addEventListener(this._onCommandWillStartHitTest);
896
+ this.editor.events.commandEnded.addEventListener(this._onCommandEndedHitTest);
850
897
  };
851
898
  Object.defineProperty(AcTrView2d.prototype, "mode", {
852
899
  /**
@@ -2191,6 +2238,37 @@ var AcTrView2d = /** @class */ (function (_super) {
2191
2238
  var sortedResults = sortPickResults(results, point);
2192
2239
  return pickOneOnly ? sortedResults.slice(0, 1) : sortedResults;
2193
2240
  };
2241
+ /**
2242
+ * @inheritdoc
2243
+ */
2244
+ AcTrView2d.prototype.getViewportCoordinateMapper = function (viewportId) {
2245
+ var e_7, _a;
2246
+ var _b, _c;
2247
+ var vpView;
2248
+ try {
2249
+ for (var _d = __values((_c = (_b = this.activeLayoutView) === null || _b === void 0 ? void 0 : _b.viewportViews) !== null && _c !== void 0 ? _c : []), _e = _d.next(); !_e.done; _e = _d.next()) {
2250
+ var candidate = _e.value;
2251
+ if (candidate.viewport.id === viewportId) {
2252
+ vpView = candidate;
2253
+ break;
2254
+ }
2255
+ }
2256
+ }
2257
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
2258
+ finally {
2259
+ try {
2260
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2261
+ }
2262
+ finally { if (e_7) throw e_7.error; }
2263
+ }
2264
+ if (!vpView)
2265
+ return undefined;
2266
+ return {
2267
+ paperToModel: function (point) { return vpView.paperPointToModel(point); },
2268
+ modelToPaper: function (point) { return vpView.modelPointToPaper(point); },
2269
+ containsPaperPoint: function (point) { return vpView.containsPaperPoint(point); }
2270
+ };
2271
+ };
2194
2272
  /**
2195
2273
  * Resolves hits against the model-space layout for each viewport the
2196
2274
  * click drills through. Appends the matches into `results` (caller
@@ -2208,7 +2286,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2208
2286
  * paper-space pick.
2209
2287
  */
2210
2288
  AcTrView2d.prototype.pickThroughViewports = function (paperPoint, paperBox, viewports, results) {
2211
- var e_7, _a;
2289
+ var e_8, _a;
2212
2290
  var modelLayout = this._scene.modelSpaceLayout;
2213
2291
  if (!modelLayout)
2214
2292
  return;
@@ -2233,7 +2311,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2233
2311
  if (!isEffectiveSpatialQueryHit(item))
2234
2312
  return;
2235
2313
  if (modelLayout.isIntersectWith(item.id, vpRaycaster)) {
2236
- results.push(item);
2314
+ results.push(__assign(__assign({}, item), { viewportId: vpView.viewport.id }));
2237
2315
  }
2238
2316
  });
2239
2317
  };
@@ -2243,12 +2321,12 @@ var AcTrView2d = /** @class */ (function (_super) {
2243
2321
  _loop_1(vpView);
2244
2322
  }
2245
2323
  }
2246
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
2324
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
2247
2325
  finally {
2248
2326
  try {
2249
2327
  if (viewports_1_1 && !viewports_1_1.done && (_a = viewports_1.return)) _a.call(viewports_1);
2250
2328
  }
2251
- finally { if (e_7) throw e_7.error; }
2329
+ finally { if (e_8) throw e_8.error; }
2252
2330
  }
2253
2331
  };
2254
2332
  /**
@@ -2264,8 +2342,9 @@ var AcTrView2d = /** @class */ (function (_super) {
2264
2342
  var idsAdded = [];
2265
2343
  var results = this.pick(point);
2266
2344
  results.forEach(function (item) { return idsAdded.push(item.id); });
2267
- if (idsAdded.length > 0)
2268
- this.selectionSet.add(idsAdded);
2345
+ var selectable = this.selectableIds(idsAdded, 'add');
2346
+ if (selectable.length > 0)
2347
+ this.selectionSet.add(selectable);
2269
2348
  };
2270
2349
  /**
2271
2350
  * @inheritdoc
@@ -2281,7 +2360,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2281
2360
  * that interior also selects those polylines and can stall highlight work.
2282
2361
  */
2283
2362
  AcTrView2d.prototype.refineCrossingSelectionHits = function (box, results) {
2284
- var e_8, _a;
2363
+ var e_9, _a;
2285
2364
  var _b;
2286
2365
  var database = (_b = AcApDocManager.instance.curDocument) === null || _b === void 0 ? void 0 : _b.database;
2287
2366
  if (!database) {
@@ -2306,12 +2385,12 @@ var AcTrView2d = /** @class */ (function (_super) {
2306
2385
  }
2307
2386
  }
2308
2387
  }
2309
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
2388
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
2310
2389
  finally {
2311
2390
  try {
2312
2391
  if (results_1_1 && !results_1_1.done && (_a = results_1.return)) _a.call(results_1);
2313
2392
  }
2314
- finally { if (e_8) throw e_8.error; }
2393
+ finally { if (e_9) throw e_9.error; }
2315
2394
  }
2316
2395
  return ids;
2317
2396
  };
@@ -2327,7 +2406,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2327
2406
  * @inheritdoc
2328
2407
  */
2329
2408
  AcTrView2d.prototype.updateLayer = function (layer, changes) {
2330
- var e_9, _a;
2409
+ var e_10, _a;
2331
2410
  var touchedObjectIds = this._scene.updateLayer(this.toLayerInfo(layer)).touchedObjectIds;
2332
2411
  if (this._layerAppearance.layerStyleMayHaveChanged(changes)) {
2333
2412
  this._layerAppearance.syncFromLiveRecord(layer);
@@ -2349,12 +2428,12 @@ var AcTrView2d = /** @class */ (function (_super) {
2349
2428
  this.applySessionHiddenObjectState(objectId);
2350
2429
  }
2351
2430
  }
2352
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
2431
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
2353
2432
  finally {
2354
2433
  try {
2355
2434
  if (touchedObjectIds_1_1 && !touchedObjectIds_1_1.done && (_a = touchedObjectIds_1.return)) _a.call(touchedObjectIds_1);
2356
2435
  }
2357
- finally { if (e_9) throw e_9.error; }
2436
+ finally { if (e_10) throw e_10.error; }
2358
2437
  }
2359
2438
  this._isDirty = true;
2360
2439
  };
@@ -2628,7 +2707,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2628
2707
  * drawable entity that must be rebuilt (for example ATTRIB → INSERT).
2629
2708
  */
2630
2709
  AcTrView2d.prototype.resolveSceneUpdateEntities = function (entities) {
2631
- var e_10, _a;
2710
+ var e_11, _a;
2632
2711
  var _b;
2633
2712
  var db = (_b = AcApDocManager.instance.curDocument) === null || _b === void 0 ? void 0 : _b.database;
2634
2713
  var resolved = [];
@@ -2650,12 +2729,12 @@ var AcTrView2d = /** @class */ (function (_super) {
2650
2729
  resolved.push(target);
2651
2730
  }
2652
2731
  }
2653
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
2732
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
2654
2733
  finally {
2655
2734
  try {
2656
2735
  if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
2657
2736
  }
2658
- finally { if (e_10) throw e_10.error; }
2737
+ finally { if (e_11) throw e_11.error; }
2659
2738
  }
2660
2739
  return resolved;
2661
2740
  };
@@ -2684,6 +2763,15 @@ var AcTrView2d = /** @class */ (function (_super) {
2684
2763
  this._initializedLayouts.add(layoutBtrId);
2685
2764
  this._externallyFramedLayouts.add(layoutBtrId);
2686
2765
  };
2766
+ /**
2767
+ * Records the Open options → Initial view choice for this document.
2768
+ *
2769
+ * Used by {@link applyInitialZoom} on the first visit to any layout that
2770
+ * was not already framed at open time.
2771
+ */
2772
+ AcTrView2d.prototype.setOpenViewMode = function (mode) {
2773
+ this._openViewMode = mode;
2774
+ };
2687
2775
  /**
2688
2776
  * Whether the layout has already been visited (or framed by the
2689
2777
  * application layer), i.e. a switch to it will not run the first-visit
@@ -2711,41 +2799,18 @@ var AcTrView2d = /** @class */ (function (_super) {
2711
2799
  return undefined;
2712
2800
  };
2713
2801
  /**
2714
- * Applies the initial zoom-to-fit for a layout the user just switched
2715
- * into for the first time. Picks the best available "what should the
2716
- * camera frame?" signal in this order:
2717
- *
2718
- * 1. **`AcDbLayout.limits`** (LIMMIN/LIMMAX) — only when it actually
2719
- * contains the layout's viewports. Many real DWGs ship with garbage
2720
- * limits (e.g. `(0,0)-(12,9)` from a legacy template setup) that
2721
- * don't reflect the actual paper sheet. We reject those by
2722
- * checking containment against `viewportsBoundingBox`.
2723
- *
2724
- * 2. **`AcTrLayoutView.viewportsBoundingBox`** — bounding box of all
2725
- * real user viewports in the layout. In production sheets viewports
2726
- * typically span 70-90% of the paper, so this is a great proxy for
2727
- * the printable area and (crucially) ignores outliers like title
2728
- * blocks authored in a different unit/scale.
2729
- *
2730
- * 3. **`AcDbLayout.extents`** — the layout's own EXTMIN/EXTMAX, if
2731
- * populated. Many parsers leave this empty (we've seen `(0,0)-(0,0)`),
2732
- * so it sits below the viewport-based heuristic.
2802
+ * Applies Open options → Initial view for a layout the user just switched
2803
+ * into for the **first** time ({@link setOpenViewMode}).
2733
2804
  *
2734
- * 4. **`getDrawingExtents`** (entity extents from batch geometry) —
2735
- * last-resort fallback for layouts with no viewports and no
2736
- * sensible limits/extents (e.g. a freshly created empty paper).
2737
- * Vulnerable to scale-mismatch outliers, but better than no zoom.
2805
+ * - **Saved + model**: VPORT `*ACTIVE`, else geometry fallback.
2806
+ * - **Saved + paper**: {@link acapResolveLayoutFrameBox} with limits
2807
+ * trusted only when they contain real viewports (rejects template
2808
+ * `(0,0)-(12,9)`), then viewports → layout extents → entity box.
2809
+ * - **Extents**: frame converted geometry (and paper viewports as a
2810
+ * content proxy). Does not prefer LIMMIN/LIMMAX over drawable bounds.
2738
2811
  *
2739
- * **Critically, this runs through `AcEdConditionWaiter`**: at the
2740
- * moment `layoutSwitched` fires, the layout's entities (including its
2741
- * `AcDbViewport`s) have not yet been batch-converted into the scene
2742
- * — `loadLayoutEntitiesIfNeeded` chunked-converts via the progressive
2743
- * convert queue (or direct `batchConvert`).
2744
- * Without the waiter, `viewportsBoundingBox` returns undefined and
2745
- * the strategy degrades into (1) zooming to garbage `limits`, or
2746
- * (4) zooming to an empty scene box. The waiter polls
2747
- * {@link isProcessingEntities} (convert queue + deferred glyph jobs)
2748
- * and only fires the heuristic once conversion and text geometry finish.
2812
+ * Runs through {@link AcEdConditionWaiter} so viewport / entity convert
2813
+ * finishes before framing.
2749
2814
  */
2750
2815
  AcTrView2d.prototype.applyInitialZoom = function (btrId, layout) {
2751
2816
  var _this = this;
@@ -2753,34 +2818,9 @@ var AcTrView2d = /** @class */ (function (_super) {
2753
2818
  if (_this._externallyFramedLayouts.delete(btrId)) {
2754
2819
  return;
2755
2820
  }
2756
- var limits = layout.limits;
2757
- var layoutView = _this._layoutViewManager.getAt(btrId);
2758
- var vpsBox = layoutView === null || layoutView === void 0 ? void 0 : layoutView.viewportsBoundingBox;
2759
- var limitsContainsViewports = (function () {
2760
- if (!limits || limits.isEmpty())
2761
- return false;
2762
- if (!vpsBox)
2763
- return true;
2764
- return (limits.min.x <= vpsBox.min.x &&
2765
- limits.min.y <= vpsBox.min.y &&
2766
- limits.max.x >= vpsBox.max.x &&
2767
- limits.max.y >= vpsBox.max.y);
2768
- })();
2769
- if (limits && !limits.isEmpty() && limitsContainsViewports) {
2770
- _this.zoomTo(limits);
2771
- }
2772
- else if (vpsBox) {
2773
- _this.zoomTo(vpsBox);
2774
- }
2775
- else if (layout.extents && !layout.extents.isEmpty()) {
2776
- var extents = layout.extents;
2777
- _this.zoomTo(new AcGeBox2d({ x: extents.min.x, y: extents.min.y }, { x: extents.max.x, y: extents.max.y }));
2778
- }
2779
- else {
2780
- var box = _this.getDrawingExtents();
2781
- if (box) {
2782
- _this.zoomTo(box);
2783
- }
2821
+ var box = _this.resolveFirstVisitFrameBox(btrId, layout);
2822
+ if (box) {
2823
+ _this.zoomTo(box);
2784
2824
  }
2785
2825
  _this._isDirty = true;
2786
2826
  AcApZoomCmd.rememberOriginalView(_this, btrId);
@@ -2788,9 +2828,56 @@ var AcTrView2d = /** @class */ (function (_super) {
2788
2828
  waiter.start();
2789
2829
  };
2790
2830
  /**
2791
- * @inheritdoc
2831
+ * Resolves the camera box for a layout's first visit from
2832
+ * {@link _openViewMode}.
2792
2833
  */
2793
- AcTrView2d.prototype.clear = function () {
2834
+ AcTrView2d.prototype.resolveFirstVisitFrameBox = function (btrId, layout) {
2835
+ var _a, _b;
2836
+ var isModelSpace = btrId === this.modelSpaceBtrId;
2837
+ var wantSaved = this._openViewMode === AcApOpenViewMode.Saved;
2838
+ if (wantSaved && isModelSpace) {
2839
+ var db = AcApDocManager.instance.curDocument.database;
2840
+ var aspect = this.width / Math.max(this.height, 1);
2841
+ var savedBox = db.tables.viewportTable.getActiveVportBox(aspect);
2842
+ if (savedBox)
2843
+ return savedBox;
2844
+ }
2845
+ var layoutView = this._layoutViewManager.getAt(btrId);
2846
+ var extents = layout.extents;
2847
+ var layoutExtents = extents && !extents.isEmpty()
2848
+ ? {
2849
+ min: { x: extents.min.x, y: extents.min.y },
2850
+ max: { x: extents.max.x, y: extents.max.y }
2851
+ }
2852
+ : undefined;
2853
+ var entityBox = this.getDrawingExtents();
2854
+ var viewportsBox = layoutView === null || layoutView === void 0 ? void 0 : layoutView.viewportsBoundingBox;
2855
+ if (wantSaved && !isModelSpace) {
2856
+ // Paper Saved: trust LIMMIN/LIMMAX only when they contain viewports.
2857
+ return (_a = acapResolveLayoutFrameBox({
2858
+ limits: layout.limits,
2859
+ viewportsBox: viewportsBox,
2860
+ layoutExtents: layoutExtents,
2861
+ entityBox: entityBox
2862
+ })) === null || _a === void 0 ? void 0 : _a.box;
2863
+ }
2864
+ // Extents (any layout), or Saved model fallback without *ACTIVE:
2865
+ // prefer drawable content; never lead with template model/paper limits.
2866
+ return (_b = acapResolveLayoutFrameBox({
2867
+ limits: undefined,
2868
+ viewportsBox: isModelSpace ? undefined : viewportsBox,
2869
+ layoutExtents: layoutExtents,
2870
+ entityBox: entityBox
2871
+ })) === null || _b === void 0 ? void 0 : _b.box;
2872
+ };
2873
+ /**
2874
+ * Invalidates in-flight progressive convert and empties convert / deferred
2875
+ * queues without tearing down the renderer or DOM.
2876
+ *
2877
+ * Call before {@link AcApDocManager.destroy} tears down documents so
2878
+ * in-flight commits do not keep reading the manager singleton.
2879
+ */
2880
+ AcTrView2d.prototype.abortConversion = function () {
2794
2881
  // Invalidate any in-flight progressive convert so it neither paints into
2795
2882
  // the cleared scene nor double-decrements the processing counter.
2796
2883
  this._convertEpoch++;
@@ -2803,12 +2890,19 @@ var AcTrView2d = /** @class */ (function (_super) {
2803
2890
  this.cancelOpenLineworkFrame();
2804
2891
  this.resetDeferredGeometryQueue();
2805
2892
  this._entityProcessingIdleAt = 0;
2893
+ };
2894
+ /**
2895
+ * @inheritdoc
2896
+ */
2897
+ AcTrView2d.prototype.clear = function () {
2898
+ this.abortConversion();
2806
2899
  this._scene.clear();
2807
2900
  this._renderer.resetDrawOrderZ();
2808
2901
  this._isDirty = true;
2809
2902
  this._missedImages.clear();
2810
2903
  this._initializedLayouts.clear();
2811
2904
  this._externallyFramedLayouts.clear();
2905
+ this._openViewMode = AcApOpenViewMode.Extents;
2812
2906
  this._loadingLayouts.clear();
2813
2907
  this._renderer.dispose();
2814
2908
  // Drop block templates when the scene is torn down (next open / close).
@@ -2826,6 +2920,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2826
2920
  layoutViewManager: this._layoutViewManager,
2827
2921
  initializedLayouts: this._initializedLayouts,
2828
2922
  externallyFramedLayouts: this._externallyFramedLayouts,
2923
+ openViewMode: this._openViewMode,
2829
2924
  loadingLayouts: this._loadingLayouts,
2830
2925
  missedImages: this._missedImages,
2831
2926
  missedFonts: this._renderer.snapshotMissedFonts(),
@@ -2838,7 +2933,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2838
2933
  * @param state - Snapshot previously returned by {@link captureSessionState} or {@link beginNewSession}.
2839
2934
  */
2840
2935
  AcTrView2d.prototype.restoreSessionState = function (state) {
2841
- var _a;
2936
+ var _a, _b;
2842
2937
  this._convertEpoch++;
2843
2938
  this.clearFontLoadedRedrawTimer();
2844
2939
  this.cancelOpenLineworkFrame();
@@ -2853,9 +2948,10 @@ var AcTrView2d = /** @class */ (function (_super) {
2853
2948
  this._layoutViewManager = state.layoutViewManager;
2854
2949
  this._initializedLayouts = state.initializedLayouts;
2855
2950
  this._externallyFramedLayouts = state.externallyFramedLayouts;
2951
+ this._openViewMode = (_a = state.openViewMode) !== null && _a !== void 0 ? _a : AcApOpenViewMode.Extents;
2856
2952
  this._loadingLayouts = state.loadingLayouts;
2857
2953
  this._missedImages = state.missedImages;
2858
- this._renderer.replaceMissedFonts((_a = state.missedFonts) !== null && _a !== void 0 ? _a : {});
2954
+ this._renderer.replaceMissedFonts((_b = state.missedFonts) !== null && _b !== void 0 ? _b : {});
2859
2955
  this.rebindLayerAppearance();
2860
2956
  this._layoutViewManager.resize(this.width, this.height);
2861
2957
  this.selectionSet.clear();
@@ -2886,6 +2982,7 @@ var AcTrView2d = /** @class */ (function (_super) {
2886
2982
  this._layoutViewManager = new AcTrLayoutViewManager();
2887
2983
  this._initializedLayouts = new Set();
2888
2984
  this._externallyFramedLayouts = new Set();
2985
+ this._openViewMode = AcApOpenViewMode.Extents;
2889
2986
  this._loadingLayouts = new Set();
2890
2987
  this._missedImages = new Map();
2891
2988
  this._renderer.clearMissedFonts();
@@ -2919,12 +3016,44 @@ var AcTrView2d = /** @class */ (function (_super) {
2919
3016
  /**
2920
3017
  * True when this view is the document manager's live canvas.
2921
3018
  * Satellite/preview views must ignore global shortcuts and layout switches.
3019
+ * Returns false when no manager exists so post-destroy key handlers do not
3020
+ * reach {@link AcApDocManager.instance}.
2922
3021
  */
2923
3022
  AcTrView2d.prototype.isActiveManagedView = function () {
2924
3023
  var _a;
2925
3024
  var singleton = AcApDocManager;
2926
3025
  var current = (_a = singleton._instance) === null || _a === void 0 ? void 0 : _a.curView;
2927
- return current == null || current === this;
3026
+ return current != null && current === this;
3027
+ };
3028
+ /**
3029
+ * Moves keyboard focus into the viewer container after canvas interaction so
3030
+ * document-level shortcuts stay scoped to this view.
3031
+ *
3032
+ * Skips host editable fields so wheel-over-canvas does not interrupt typing.
3033
+ */
3034
+ AcTrView2d.prototype.focusViewerForShortcuts = function () {
3035
+ var active = document.activeElement;
3036
+ if (active instanceof Node && this.container.contains(active)) {
3037
+ return;
3038
+ }
3039
+ if (active instanceof HTMLElement &&
3040
+ (active.tagName === 'INPUT' ||
3041
+ active.tagName === 'TEXTAREA' ||
3042
+ active.isContentEditable)) {
3043
+ return;
3044
+ }
3045
+ this.container.focus({ preventScroll: true });
3046
+ };
3047
+ /**
3048
+ * True when the key event originated from (or is focused within) this view.
3049
+ */
3050
+ AcTrView2d.prototype.isShortcutEventInsideViewer = function (e) {
3051
+ var target = e.target;
3052
+ if (target instanceof Node && this.container.contains(target)) {
3053
+ return true;
3054
+ }
3055
+ var active = document.activeElement;
3056
+ return active instanceof Node && this.container.contains(active);
2928
3057
  };
2929
3058
  /**
2930
3059
  * Drains the convert queue on a single serial worker so ENTITY flush chunks
@@ -3223,20 +3352,63 @@ var AcTrView2d = /** @class */ (function (_super) {
3223
3352
  }
3224
3353
  };
3225
3354
  /**
3226
- * Releases canvas DOM listeners and stops the animation loop.
3355
+ * Releases canvas DOM, WebGL context, convert work, and listeners.
3227
3356
  *
3228
3357
  * Call when this view will no longer be used (manager destroy / split
3229
3358
  * view teardown). Safe to call more than once.
3230
3359
  */
3231
3360
  AcTrView2d.prototype.dispose = function () {
3232
- var _a, _b;
3361
+ var _a, _b, _c;
3362
+ if (this._viewDisposed)
3363
+ return;
3364
+ this._viewDisposed = true;
3365
+ // Stop convert before tearing down documents/singletons that commit paths read.
3366
+ this.abortConversion();
3233
3367
  (_a = this._disposeCanvasTouchCallout) === null || _a === void 0 ? void 0 : _a.call(this);
3234
3368
  this._disposeCanvasTouchCallout = undefined;
3235
3369
  (_b = this._disposeProgressiveInputWatch) === null || _b === void 0 ? void 0 : _b.call(this);
3236
3370
  this._disposeProgressiveInputWatch = undefined;
3371
+ (_c = this._disposeMobileBoxGesture) === null || _c === void 0 ? void 0 : _c.call(this);
3372
+ this._disposeMobileBoxGesture = undefined;
3373
+ this._viewDomAbort.abort();
3374
+ if (this._onFontNotFound) {
3375
+ this._renderer.events.fontNotFound.removeEventListener(this._onFontNotFound);
3376
+ }
3377
+ if (this._onFontLoaded) {
3378
+ this._renderer.events.fontLoaded.removeEventListener(this._onFontLoaded);
3379
+ }
3380
+ if (this._onSysVarChanged) {
3381
+ AcDbSysVarManager.instance().events.sysVarChanged.removeEventListener(this._onSysVarChanged);
3382
+ }
3383
+ if (this._onSettingsModified) {
3384
+ AcApSettingManager.instance.events.modified.removeEventListener(this._onSettingsModified);
3385
+ }
3386
+ if (this._onLayoutSwitched) {
3387
+ acdbHostApplicationServices().layoutManager.events.layoutSwitched.removeEventListener(this._onLayoutSwitched);
3388
+ }
3389
+ if (this._onCommandWillStartHitTest) {
3390
+ this.editor.events.commandWillStart.removeEventListener(this._onCommandWillStartHitTest);
3391
+ }
3392
+ if (this._onCommandEndedHitTest) {
3393
+ this.editor.events.commandEnded.removeEventListener(this._onCommandEndedHitTest);
3394
+ }
3395
+ this._gripManager.dispose();
3237
3396
  this.clearFontLoadedRedrawTimer();
3238
3397
  this.cancelOpenLineworkFrame();
3239
3398
  this.stopAnimationLoop();
3399
+ this.selectionSet.clear();
3400
+ this.htmlTransientManager.dispose();
3401
+ this._scene.clear();
3402
+ this._renderer.dispose();
3403
+ AcDbRenderingCache.instance.clear();
3404
+ var webgl = this._renderer.internalRenderer;
3405
+ webgl.dispose();
3406
+ webgl.forceContextLoss();
3407
+ this.canvas.remove();
3408
+ this._css2dRenderer.domElement.remove();
3409
+ this._stats.dom.remove();
3410
+ // Editor / command line / ResizeObserver (after canvas/CSS2D removed).
3411
+ _super.prototype.dispose.call(this);
3240
3412
  };
3241
3413
  /**
3242
3414
  * @inheritdoc
@@ -3338,7 +3510,7 @@ var AcTrView2d = /** @class */ (function (_super) {
3338
3510
  * @param layoutBtrId Input the block table record id of the layout
3339
3511
  */
3340
3512
  AcTrView2d.prototype.loadLayoutEntitiesIfNeeded = function (layoutBtrId) {
3341
- var e_11, _a;
3513
+ var e_12, _a;
3342
3514
  var _this = this;
3343
3515
  try {
3344
3516
  var db = AcApDocManager.instance.curDocument.database;
@@ -3402,12 +3574,12 @@ var AcTrView2d = /** @class */ (function (_super) {
3402
3574
  entities_2.push(entity);
3403
3575
  }
3404
3576
  }
3405
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
3577
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
3406
3578
  finally {
3407
3579
  try {
3408
3580
  if (iterator_1_1 && !iterator_1_1.done && (_a = iterator_1.return)) _a.call(iterator_1);
3409
3581
  }
3410
- finally { if (e_11) throw e_11.error; }
3582
+ finally { if (e_12) throw e_12.error; }
3411
3583
  }
3412
3584
  if (entities_2.length === 0) {
3413
3585
  // Empty layout (e.g. a freshly-created paper space tab). Mark as
@@ -3731,8 +3903,8 @@ var AcTrView2d = /** @class */ (function (_super) {
3731
3903
  */
3732
3904
  AcTrView2d.prototype.redrawGlyphEntitiesAfterFontLoad = function (epoch, fontName) {
3733
3905
  return __awaiter(this, void 0, void 0, function () {
3734
- var redrawEpoch, glyphs, _a, _b, layout, glyphs_1, glyphs_1_1, glyph, e_12_1, defaults, normalized_1, msSinceIdle, db;
3735
- var e_13, _c, e_12, _d;
3906
+ var redrawEpoch, glyphs, _a, _b, layout, glyphs_1, glyphs_1_1, glyph, e_13_1, defaults, normalized_1, msSinceIdle, db;
3907
+ var e_14, _c, e_13, _d;
3736
3908
  var _e, _f;
3737
3909
  return __generator(this, function (_g) {
3738
3910
  switch (_g.label) {
@@ -3754,12 +3926,12 @@ var AcTrView2d = /** @class */ (function (_super) {
3754
3926
  });
3755
3927
  }
3756
3928
  }
3757
- catch (e_13_1) { e_13 = { error: e_13_1 }; }
3929
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
3758
3930
  finally {
3759
3931
  try {
3760
3932
  if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
3761
3933
  }
3762
- finally { if (e_13) throw e_13.error; }
3934
+ finally { if (e_14) throw e_14.error; }
3763
3935
  }
3764
3936
  _g.label = 1;
3765
3937
  case 1:
@@ -3782,14 +3954,14 @@ var AcTrView2d = /** @class */ (function (_super) {
3782
3954
  return [3 /*break*/, 2];
3783
3955
  case 5: return [3 /*break*/, 8];
3784
3956
  case 6:
3785
- e_12_1 = _g.sent();
3786
- e_12 = { error: e_12_1 };
3957
+ e_13_1 = _g.sent();
3958
+ e_13 = { error: e_13_1 };
3787
3959
  return [3 /*break*/, 8];
3788
3960
  case 7:
3789
3961
  try {
3790
3962
  if (glyphs_1_1 && !glyphs_1_1.done && (_d = glyphs_1.return)) _d.call(glyphs_1);
3791
3963
  }
3792
- finally { if (e_12) throw e_12.error; }
3964
+ finally { if (e_13) throw e_13.error; }
3793
3965
  return [7 /*endfinally*/];
3794
3966
  case 8:
3795
3967
  if (glyphs.length > 0) {
@@ -3840,7 +4012,7 @@ var AcTrView2d = /** @class */ (function (_super) {
3840
4012
  });
3841
4013
  };
3842
4014
  AcTrView2d.prototype.groupHasPendingGlyphGeometry = function (group) {
3843
- var e_14, _a;
4015
+ var e_15, _a;
3844
4016
  try {
3845
4017
  // Prefer O(block-def shells). A full THREE.traverse over a mega-block
3846
4018
  // (100k+ flattened mesh leaves) was dominating scene-convert wall time.
@@ -3851,12 +4023,12 @@ var AcTrView2d = /** @class */ (function (_super) {
3851
4023
  }
3852
4024
  }
3853
4025
  }
3854
- catch (e_14_1) { e_14 = { error: e_14_1 }; }
4026
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
3855
4027
  finally {
3856
4028
  try {
3857
4029
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3858
4030
  }
3859
- finally { if (e_14) throw e_14.error; }
4031
+ finally { if (e_15) throw e_15.error; }
3860
4032
  }
3861
4033
  return AcTrView2d.directChildrenHavePendingGlyphs(group);
3862
4034
  };
@@ -3867,7 +4039,7 @@ var AcTrView2d = /** @class */ (function (_super) {
3867
4039
  * a whole-floor INSERT is O(glyph shells), not O(all drawable leaves).
3868
4040
  */
3869
4041
  AcTrView2d.directChildrenHavePendingGlyphs = function (root) {
3870
- var e_15, _a;
4042
+ var e_16, _a;
3871
4043
  var children = root.children;
3872
4044
  for (var i = 0; i < children.length; i++) {
3873
4045
  var child = children[i];
@@ -3879,7 +4051,7 @@ var AcTrView2d = /** @class */ (function (_super) {
3879
4051
  }
3880
4052
  if (child instanceof AcTrGroup) {
3881
4053
  try {
3882
- for (var _b = (e_15 = void 0, __values(child.getSourceEntities())), _c = _b.next(); !_c.done; _c = _b.next()) {
4054
+ for (var _b = (e_16 = void 0, __values(child.getSourceEntities())), _c = _b.next(); !_c.done; _c = _b.next()) {
3883
4055
  var entity = _c.value;
3884
4056
  if (entity instanceof AcTrGlyphEntity &&
3885
4057
  !entity.hasDrawableGeometry()) {
@@ -3887,12 +4059,12 @@ var AcTrView2d = /** @class */ (function (_super) {
3887
4059
  }
3888
4060
  }
3889
4061
  }
3890
- catch (e_15_1) { e_15 = { error: e_15_1 }; }
4062
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
3891
4063
  finally {
3892
4064
  try {
3893
4065
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3894
4066
  }
3895
- finally { if (e_15) throw e_15.error; }
4067
+ finally { if (e_16) throw e_16.error; }
3896
4068
  }
3897
4069
  if (AcTrView2d.directChildrenHavePendingGlyphs(child)) {
3898
4070
  return true;
@@ -4050,7 +4222,7 @@ var AcTrView2d = /** @class */ (function (_super) {
4050
4222
  * paper layouts.
4051
4223
  */
4052
4224
  AcTrView2d.prototype.ensureViewportViews = function (blockTableRecord, layoutView) {
4053
- var e_16, _a;
4225
+ var e_17, _a;
4054
4226
  var iterator = blockTableRecord.newIterator();
4055
4227
  try {
4056
4228
  for (var iterator_2 = __values(iterator), iterator_2_1 = iterator_2.next(); !iterator_2_1.done; iterator_2_1 = iterator_2.next()) {
@@ -4063,12 +4235,12 @@ var AcTrView2d = /** @class */ (function (_super) {
4063
4235
  layoutView.addViewport(viewportView);
4064
4236
  }
4065
4237
  }
4066
- catch (e_16_1) { e_16 = { error: e_16_1 }; }
4238
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
4067
4239
  finally {
4068
4240
  try {
4069
4241
  if (iterator_2_1 && !iterator_2_1.done && (_a = iterator_2.return)) _a.call(iterator_2);
4070
4242
  }
4071
- finally { if (e_16) throw e_16.error; }
4243
+ finally { if (e_17) throw e_17.error; }
4072
4244
  }
4073
4245
  };
4074
4246
  /**
@@ -4077,7 +4249,7 @@ var AcTrView2d = /** @class */ (function (_super) {
4077
4249
  * {@link AcDbViewport.frozenLayerIds} but omit them from `toGiViewport()`.
4078
4250
  */
4079
4251
  AcTrView2d.prototype.toGiViewportWithFrozenLayers = function (entity) {
4080
- var e_17, _a;
4252
+ var e_18, _a;
4081
4253
  var _b;
4082
4254
  var gi = entity.toGiViewport();
4083
4255
  if (gi.frozenLayers && gi.frozenLayers.length > 0) {
@@ -4097,12 +4269,12 @@ var AcTrView2d = /** @class */ (function (_super) {
4097
4269
  names.push(layer.name);
4098
4270
  }
4099
4271
  }
4100
- catch (e_17_1) { e_17 = { error: e_17_1 }; }
4272
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
4101
4273
  finally {
4102
4274
  try {
4103
4275
  if (ids_1_1 && !ids_1_1.done && (_a = ids_1.return)) _a.call(ids_1);
4104
4276
  }
4105
- finally { if (e_17) throw e_17.error; }
4277
+ finally { if (e_18) throw e_18.error; }
4106
4278
  }
4107
4279
  }
4108
4280
  gi.frozenLayerIds = __spreadArray([], __read(ids), false);
@@ -4422,8 +4594,8 @@ var AcTrView2d = /** @class */ (function (_super) {
4422
4594
  };
4423
4595
  AcTrView2d.prototype.handleGroup = function (group_1, progressive_1) {
4424
4596
  return __awaiter(this, arguments, void 0, function (group, progressive, epoch, convertGen) {
4425
- var t0, objectId, children, objectsGroupByLayer_2, children_1, children_1_1, child, renderContext, groupObjectId, groupLayerName, lazyChildren, groupChildBoxes, aggregateSpatialBbox, registeredChildIndex, yieldToEventLoop, lastGroupYieldAt, _loop_5, this_4, objectsGroupByLayer_1, objectsGroupByLayer_1_1, _a, layerName, objects, e_18_1;
4426
- var e_19, _b, e_18, _c;
4597
+ var t0, objectId, children, objectsGroupByLayer_2, children_1, children_1_1, child, renderContext, groupObjectId, groupLayerName, lazyChildren, groupChildBoxes, aggregateSpatialBbox, registeredChildIndex, yieldToEventLoop, lastGroupYieldAt, _loop_5, this_4, objectsGroupByLayer_1, objectsGroupByLayer_1_1, _a, layerName, objects, e_19_1;
4598
+ var e_20, _b, e_19, _c;
4427
4599
  var _this = this;
4428
4600
  var _d, _e;
4429
4601
  if (epoch === void 0) { epoch = this._convertEpoch; }
@@ -4478,12 +4650,12 @@ var AcTrView2d = /** @class */ (function (_super) {
4478
4650
  child.parent = null;
4479
4651
  }
4480
4652
  }
4481
- catch (e_19_1) { e_19 = { error: e_19_1 }; }
4653
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
4482
4654
  finally {
4483
4655
  try {
4484
4656
  if (children_1_1 && !children_1_1.done && (_b = children_1.return)) _b.call(children_1);
4485
4657
  }
4486
- finally { if (e_19) throw e_19.error; }
4658
+ finally { if (e_20) throw e_20.error; }
4487
4659
  }
4488
4660
  renderContext = group.renderContext;
4489
4661
  groupObjectId = group.objectId;
@@ -4598,14 +4770,14 @@ var AcTrView2d = /** @class */ (function (_super) {
4598
4770
  return [3 /*break*/, 4];
4599
4771
  case 7: return [3 /*break*/, 10];
4600
4772
  case 8:
4601
- e_18_1 = _f.sent();
4602
- e_18 = { error: e_18_1 };
4773
+ e_19_1 = _f.sent();
4774
+ e_19 = { error: e_19_1 };
4603
4775
  return [3 /*break*/, 10];
4604
4776
  case 9:
4605
4777
  try {
4606
4778
  if (objectsGroupByLayer_1_1 && !objectsGroupByLayer_1_1.done && (_c = objectsGroupByLayer_1.return)) _c.call(objectsGroupByLayer_1);
4607
4779
  }
4608
- finally { if (e_18) throw e_18.error; }
4780
+ finally { if (e_19) throw e_19.error; }
4609
4781
  return [7 /*endfinally*/];
4610
4782
  case 10:
4611
4783
  group.dispose();