@mlightcad/cad-simple-viewer 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +296 -2
  2. package/dist/index.js +1348 -122
  3. package/dist/index.umd.cjs +2 -2
  4. package/lib/app/AcApContext.d.ts +45 -3
  5. package/lib/app/AcApContext.d.ts.map +1 -1
  6. package/lib/app/AcApContext.js +43 -3
  7. package/lib/app/AcApContext.js.map +1 -1
  8. package/lib/app/AcApDocCreator.d.ts +68 -2
  9. package/lib/app/AcApDocCreator.d.ts.map +1 -1
  10. package/lib/app/AcApDocCreator.js +67 -2
  11. package/lib/app/AcApDocCreator.js.map +1 -1
  12. package/lib/app/AcApDocManager.d.ts +227 -12
  13. package/lib/app/AcApDocManager.d.ts.map +1 -1
  14. package/lib/app/AcApDocManager.js +229 -17
  15. package/lib/app/AcApDocManager.js.map +1 -1
  16. package/lib/app/AcApDocument.d.ts +77 -3
  17. package/lib/app/AcApDocument.d.ts.map +1 -1
  18. package/lib/app/AcApDocument.js +75 -3
  19. package/lib/app/AcApDocument.js.map +1 -1
  20. package/lib/app/AcApFontLoader.d.ts +32 -0
  21. package/lib/app/AcApFontLoader.d.ts.map +1 -1
  22. package/lib/app/AcApFontLoader.js +30 -0
  23. package/lib/app/AcApFontLoader.js.map +1 -1
  24. package/lib/app/AcApSettingManager.d.ts +191 -3
  25. package/lib/app/AcApSettingManager.d.ts.map +1 -1
  26. package/lib/app/AcApSettingManager.js +161 -0
  27. package/lib/app/AcApSettingManager.js.map +1 -1
  28. package/lib/command/AcApConvertToSvgCmd.d.ts +26 -0
  29. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -1
  30. package/lib/command/AcApConvertToSvgCmd.js +26 -0
  31. package/lib/command/AcApConvertToSvgCmd.js.map +1 -1
  32. package/lib/command/AcApOpenCmd.d.ts +31 -0
  33. package/lib/command/AcApOpenCmd.d.ts.map +1 -1
  34. package/lib/command/AcApOpenCmd.js +31 -0
  35. package/lib/command/AcApOpenCmd.js.map +1 -1
  36. package/lib/command/AcApPanCmd.d.ts +25 -0
  37. package/lib/command/AcApPanCmd.d.ts.map +1 -1
  38. package/lib/command/AcApPanCmd.js +25 -0
  39. package/lib/command/AcApPanCmd.js.map +1 -1
  40. package/lib/command/AcApQNewCmd.d.ts +26 -0
  41. package/lib/command/AcApQNewCmd.d.ts.map +1 -1
  42. package/lib/command/AcApQNewCmd.js +26 -0
  43. package/lib/command/AcApQNewCmd.js.map +1 -1
  44. package/lib/command/AcApSelectCmd.d.ts +26 -0
  45. package/lib/command/AcApSelectCmd.d.ts.map +1 -1
  46. package/lib/command/AcApSelectCmd.js +26 -0
  47. package/lib/command/AcApSelectCmd.js.map +1 -1
  48. package/lib/command/AcApSvgConvertor.d.ts +48 -0
  49. package/lib/command/AcApSvgConvertor.d.ts.map +1 -1
  50. package/lib/command/AcApSvgConvertor.js +48 -0
  51. package/lib/command/AcApSvgConvertor.js.map +1 -1
  52. package/lib/command/AcApZoomCmd.d.ts +29 -0
  53. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  54. package/lib/command/AcApZoomCmd.js +29 -0
  55. package/lib/command/AcApZoomCmd.js.map +1 -1
  56. package/lib/command/AcApZoomToBoxCmd.d.ts +57 -0
  57. package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -1
  58. package/lib/command/AcApZoomToBoxCmd.js +57 -0
  59. package/lib/command/AcApZoomToBoxCmd.js.map +1 -1
  60. package/lib/editor/command/AcEdCommand.d.ts +118 -9
  61. package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
  62. package/lib/editor/command/AcEdCommand.js +113 -9
  63. package/lib/editor/command/AcEdCommand.js.map +1 -1
  64. package/lib/editor/command/AcEdCommandStack.d.ts +59 -5
  65. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
  66. package/lib/editor/command/AcEdCommandStack.js +48 -5
  67. package/lib/editor/command/AcEdCommandStack.js.map +1 -1
  68. package/lib/editor/global/eventBus.d.ts +76 -7
  69. package/lib/editor/global/eventBus.d.ts.map +1 -1
  70. package/lib/editor/global/eventBus.js +38 -0
  71. package/lib/editor/global/eventBus.js.map +1 -1
  72. package/lib/editor/input/AcEdBaseInput.d.ts +65 -1
  73. package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -1
  74. package/lib/editor/input/AcEdBaseInput.js +62 -1
  75. package/lib/editor/input/AcEdBaseInput.js.map +1 -1
  76. package/lib/editor/input/AcEdBoxSelector.d.ts +81 -0
  77. package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -1
  78. package/lib/editor/input/AcEdBoxSelector.js +80 -0
  79. package/lib/editor/input/AcEdBoxSelector.js.map +1 -1
  80. package/lib/editor/input/AcEdCursorManager.d.ts +95 -8
  81. package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -1
  82. package/lib/editor/input/AcEdCursorManager.js +95 -11
  83. package/lib/editor/input/AcEdCursorManager.js.map +1 -1
  84. package/lib/editor/input/AcEdInputPoint.d.ts +38 -1
  85. package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -1
  86. package/lib/editor/input/AcEdInputPoint.js +38 -1
  87. package/lib/editor/input/AcEdInputPoint.js.map +1 -1
  88. package/lib/editor/input/AcEdJig.d.ts +166 -0
  89. package/lib/editor/input/AcEdJig.d.ts.map +1 -1
  90. package/lib/editor/input/AcEdJig.js +164 -0
  91. package/lib/editor/input/AcEdJig.js.map +1 -1
  92. package/lib/editor/input/AcEdJigLoop.d.ts +49 -0
  93. package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -1
  94. package/lib/editor/input/AcEdJigLoop.js +48 -0
  95. package/lib/editor/input/AcEdJigLoop.js.map +1 -1
  96. package/lib/editor/input/AcEdSelectionSet.d.ts +122 -2
  97. package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -1
  98. package/lib/editor/input/AcEdSelectionSet.js +117 -1
  99. package/lib/editor/input/AcEdSelectionSet.js.map +1 -1
  100. package/lib/editor/input/AcEditor.d.ts +90 -6
  101. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  102. package/lib/editor/input/AcEditor.js +86 -6
  103. package/lib/editor/input/AcEditor.js.map +1 -1
  104. package/lib/editor/view/AcEdBaseView.d.ts +163 -16
  105. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  106. package/lib/editor/view/AcEdBaseView.js +94 -5
  107. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  108. package/lib/util/AcTrGeometryUtil.d.ts +65 -0
  109. package/lib/util/AcTrGeometryUtil.d.ts.map +1 -1
  110. package/lib/util/AcTrGeometryUtil.js +65 -0
  111. package/lib/util/AcTrGeometryUtil.js.map +1 -1
  112. package/lib/view/AcTrLayer.d.ts +40 -5
  113. package/lib/view/AcTrLayer.d.ts.map +1 -1
  114. package/lib/view/AcTrLayer.js +34 -5
  115. package/lib/view/AcTrLayer.js.map +1 -1
  116. package/lib/view/AcTrLayout.d.ts +122 -23
  117. package/lib/view/AcTrLayout.d.ts.map +1 -1
  118. package/lib/view/AcTrLayout.js +103 -23
  119. package/lib/view/AcTrLayout.js.map +1 -1
  120. package/lib/view/AcTrLayoutView.d.ts +74 -16
  121. package/lib/view/AcTrLayoutView.d.ts.map +1 -1
  122. package/lib/view/AcTrLayoutView.js +65 -16
  123. package/lib/view/AcTrLayoutView.js.map +1 -1
  124. package/lib/view/AcTrLayoutViewManager.d.ts +58 -12
  125. package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -1
  126. package/lib/view/AcTrLayoutViewManager.js +56 -12
  127. package/lib/view/AcTrLayoutViewManager.js.map +1 -1
  128. package/lib/view/AcTrScene.d.ts +48 -4
  129. package/lib/view/AcTrScene.d.ts.map +1 -1
  130. package/lib/view/AcTrScene.js +44 -4
  131. package/lib/view/AcTrScene.js.map +1 -1
  132. package/lib/view/AcTrView2d.d.ts +71 -0
  133. package/lib/view/AcTrView2d.d.ts.map +1 -1
  134. package/lib/view/AcTrView2d.js +65 -0
  135. package/lib/view/AcTrView2d.js.map +1 -1
  136. package/package.json +8 -4
@@ -42,10 +42,34 @@ import { AcApContext } from './AcApContext';
42
42
  import { AcApDocCreator } from './AcApDocCreator';
43
43
  import { AcApDocument } from './AcApDocument';
44
44
  import { AcApFontLoader } from './AcApFontLoader';
45
+ /**
46
+ * Document manager that handles CAD document lifecycle and provides the main entry point for the CAD viewer.
47
+ *
48
+ * This singleton class manages:
49
+ * - Document creation and opening (from URLs or file content)
50
+ * - View and context management
51
+ * - Command registration and execution
52
+ * - Font loading for text rendering
53
+ * - Event handling for document lifecycle
54
+ *
55
+ * The manager follows a singleton pattern to ensure only one instance manages the application state.
56
+ */
45
57
  var AcApDocManager = /** @class */ (function () {
58
+ /**
59
+ * Private constructor for singleton pattern.
60
+ *
61
+ * Creates an empty document with a 2D view and sets up the application context.
62
+ * Registers default commands and creates an example document.
63
+ *
64
+ * @param canvas - Optional HTML canvas element for rendering. If not provided, a new canvas will be created
65
+ * @private
66
+ */
46
67
  function AcApDocManager(canvas) {
68
+ /** Events fired during document lifecycle */
47
69
  this.events = {
70
+ /** Fired when a new document is created */
48
71
  documentCreated: new AcCmEventManager(),
72
+ /** Fired when a document becomes active */
49
73
  documentActivated: new AcCmEventManager()
50
74
  };
51
75
  // Create one empty drawing
@@ -54,6 +78,7 @@ var AcApDocManager = /** @class */ (function () {
54
78
  eventBus.emit('open-file-progress', {
55
79
  percentage: args.percentage,
56
80
  stage: args.stage,
81
+ subStage: args.subStage,
57
82
  stageStatus: args.stageStatus
58
83
  });
59
84
  });
@@ -68,8 +93,22 @@ var AcApDocManager = /** @class */ (function () {
68
93
  this._fontLoader = new AcApFontLoader(view.renderer);
69
94
  acdbHostApplicationServices().workingDatabase = doc.database;
70
95
  this.registerCommands();
71
- this.createExampleDoc();
72
96
  }
97
+ /**
98
+ * Creates the singleton instance with an optional canvas element.
99
+ *
100
+ * This method should be called before accessing the `instance` property
101
+ * if you want to provide a specific canvas element.
102
+ *
103
+ * @param canvas - Optional HTML canvas element for rendering
104
+ * @returns The singleton instance
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const canvas = document.getElementById('my-canvas') as HTMLCanvasElement;
109
+ * const docManager = AcApDocManager.createInstance(canvas);
110
+ * ```
111
+ */
73
112
  AcApDocManager.createInstance = function (canvas) {
74
113
  if (AcApDocManager._instance == null) {
75
114
  AcApDocManager._instance = new AcApDocManager(canvas);
@@ -77,6 +116,13 @@ var AcApDocManager = /** @class */ (function () {
77
116
  return this._instance;
78
117
  };
79
118
  Object.defineProperty(AcApDocManager, "instance", {
119
+ /**
120
+ * Gets the singleton instance of the document manager.
121
+ *
122
+ * Creates a new instance if one doesn't exist yet.
123
+ *
124
+ * @returns The singleton document manager instance
125
+ */
80
126
  get: function () {
81
127
  if (!AcApDocManager._instance) {
82
128
  AcApDocManager._instance = new AcApDocManager();
@@ -88,7 +134,11 @@ var AcApDocManager = /** @class */ (function () {
88
134
  });
89
135
  Object.defineProperty(AcApDocManager.prototype, "context", {
90
136
  /**
91
- * Current context
137
+ * Gets the current application context.
138
+ *
139
+ * The context binds the current document with its associated view.
140
+ *
141
+ * @returns The current application context
92
142
  */
93
143
  get: function () {
94
144
  return this._context;
@@ -98,7 +148,9 @@ var AcApDocManager = /** @class */ (function () {
98
148
  });
99
149
  Object.defineProperty(AcApDocManager.prototype, "curDocument", {
100
150
  /**
101
- * Current open drawing
151
+ * Gets the currently open CAD document.
152
+ *
153
+ * @returns The current document instance
102
154
  */
103
155
  get: function () {
104
156
  return this._context.doc;
@@ -108,7 +160,12 @@ var AcApDocManager = /** @class */ (function () {
108
160
  });
109
161
  Object.defineProperty(AcApDocManager.prototype, "mdiActiveDocument", {
110
162
  /**
111
- * For now, it is same as property `curDocument`.
163
+ * Gets the currently active document.
164
+ *
165
+ * For now, this is the same as `curDocument` since only one document
166
+ * can be active at a time.
167
+ *
168
+ * @returns The current active document
112
169
  */
113
170
  get: function () {
114
171
  return this._context.doc;
@@ -118,7 +175,9 @@ var AcApDocManager = /** @class */ (function () {
118
175
  });
119
176
  Object.defineProperty(AcApDocManager.prototype, "curView", {
120
177
  /**
121
- * Current view used to show current drawing
178
+ * Gets the current 2D view used to display the drawing.
179
+ *
180
+ * @returns The current 2D view instance
122
181
  */
123
182
  get: function () {
124
183
  return this._context.view;
@@ -127,6 +186,11 @@ var AcApDocManager = /** @class */ (function () {
127
186
  configurable: true
128
187
  });
129
188
  Object.defineProperty(AcApDocManager.prototype, "editor", {
189
+ /**
190
+ * Gets the editor instance for handling user input.
191
+ *
192
+ * @returns The current editor instance
193
+ */
130
194
  get: function () {
131
195
  return this._context.view.editor;
132
196
  },
@@ -135,8 +199,11 @@ var AcApDocManager = /** @class */ (function () {
135
199
  });
136
200
  Object.defineProperty(AcApDocManager.prototype, "avaiableFonts", {
137
201
  /**
138
- * Avaiable fonts to load. It means those fonts are avaiable to load. However, it
139
- * doesn't mean those fonts are already loaded and avaiable to use.
202
+ * Gets the list of available fonts that can be loaded.
203
+ *
204
+ * Note: These fonts are available for loading but may not be loaded yet.
205
+ *
206
+ * @returns Array of available font names
140
207
  */
141
208
  get: function () {
142
209
  return this._fontLoader.avaiableFonts;
@@ -145,8 +212,15 @@ var AcApDocManager = /** @class */ (function () {
145
212
  configurable: true
146
213
  });
147
214
  /**
148
- * Load the specified fonts
149
- * @param fonts Input one list of font names
215
+ * Loads the specified fonts for text rendering.
216
+ *
217
+ * @param fonts - Array of font names to load
218
+ * @returns Promise that resolves when fonts are loaded
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * await docManager.loadFonts(['Arial', 'Times New Roman']);
223
+ * ```
150
224
  */
151
225
  AcApDocManager.prototype.loadFonts = function (fonts) {
152
226
  return __awaiter(this, void 0, void 0, function () {
@@ -161,23 +235,60 @@ var AcApDocManager = /** @class */ (function () {
161
235
  });
162
236
  };
163
237
  /**
164
- * Load default fonts
238
+ * Loads default fonts for CAD text rendering.
239
+ *
240
+ * This method loads either the specified fonts or falls back to default Chinese fonts
241
+ * (specifically 'simkai') if no fonts are provided. The loaded fonts are used for
242
+ * rendering CAD text entities like MText and Text in the viewer.
243
+ *
244
+ * It is better to load default fonts when viewer is initialized so that the viewer can
245
+ * render text correctly if fonts used in the document are not available.
246
+ *
247
+ * @param fonts - Optional array of font names to load. If not provided or null,
248
+ * defaults to ['simkai'] for Chinese text support
249
+ * @returns Promise that resolves when all specified fonts are loaded
250
+ *
251
+ * @example
252
+ * ```typescript
253
+ * // Load default fonts (simkai)
254
+ * await docManager.loadDefaultFonts();
255
+ *
256
+ * // Load specific fonts
257
+ * await docManager.loadDefaultFonts(['Arial', 'SimSun']);
258
+ *
259
+ * // Load no fonts (empty array)
260
+ * await docManager.loadDefaultFonts([]);
261
+ * ```
262
+ *
263
+ * @see {@link AcApFontLoader.load} - The underlying font loading implementation
264
+ * @see {@link createExampleDoc} - Method that uses this for example document creation
165
265
  */
166
- AcApDocManager.prototype.loadDefaultFonts = function () {
266
+ AcApDocManager.prototype.loadDefaultFonts = function (fonts) {
167
267
  return __awaiter(this, void 0, void 0, function () {
168
- var fontFiles;
169
268
  return __generator(this, function (_a) {
170
269
  switch (_a.label) {
171
270
  case 0:
172
- fontFiles = ['simkai'];
173
- return [4 /*yield*/, this._fontLoader.load(fontFiles)];
271
+ if (!(fonts == null)) return [3 /*break*/, 2];
272
+ return [4 /*yield*/, this._fontLoader.load(['simkai'])];
174
273
  case 1:
175
274
  _a.sent();
176
- return [2 /*return*/];
275
+ return [3 /*break*/, 4];
276
+ case 2: return [4 /*yield*/, this._fontLoader.load(fonts)];
277
+ case 3:
278
+ _a.sent();
279
+ _a.label = 4;
280
+ case 4: return [2 /*return*/];
177
281
  }
178
282
  });
179
283
  });
180
284
  };
285
+ /**
286
+ * Creates an example CAD document with sample content.
287
+ *
288
+ * This method asynchronously loads default fonts, creates example drawing content,
289
+ * sets up layout information, and zooms the view to fit the content.
290
+ * The creation is performed after a short delay to ensure proper initialization.
291
+ */
181
292
  AcApDocManager.prototype.createExampleDoc = function () {
182
293
  var _this = this;
183
294
  setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
@@ -194,6 +305,24 @@ var AcApDocManager = /** @class */ (function () {
194
305
  });
195
306
  }); });
196
307
  };
308
+ /**
309
+ * Opens a CAD document from a URL.
310
+ *
311
+ * This method loads a document from the specified URL and replaces the current document.
312
+ * It handles the complete document lifecycle including before/after open events.
313
+ *
314
+ * @param url - The URL of the CAD file to open
315
+ * @param options - Optional database opening options. If not provided, default options with font loader will be used
316
+ * @returns Promise that resolves to true if the document was successfully opened, false otherwise
317
+ *
318
+ * @example
319
+ * ```typescript
320
+ * const success = await docManager.openUrl('https://example.com/drawing.dwg');
321
+ * if (success) {
322
+ * console.log('Document opened successfully');
323
+ * }
324
+ * ```
325
+ */
197
326
  AcApDocManager.prototype.openUrl = function (url, options) {
198
327
  return __awaiter(this, void 0, void 0, function () {
199
328
  var isSuccess;
@@ -206,11 +335,29 @@ var AcApDocManager = /** @class */ (function () {
206
335
  case 1:
207
336
  isSuccess = _a.sent();
208
337
  this.onAfterOpenDocument(isSuccess);
209
- return [2 /*return*/];
338
+ return [2 /*return*/, isSuccess];
210
339
  }
211
340
  });
212
341
  });
213
342
  };
343
+ /**
344
+ * Opens a CAD document from file content.
345
+ *
346
+ * This method loads a document from the provided file content (string or binary data)
347
+ * and replaces the current document. It handles the complete document lifecycle
348
+ * including before/after open events.
349
+ *
350
+ * @param fileName - The name of the file being opened (used for format detection)
351
+ * @param content - The file content as string or ArrayBuffer
352
+ * @param options - Database opening options including font loader settings
353
+ * @returns Promise that resolves to true if the document was successfully opened, false otherwise
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * const fileContent = await file.arrayBuffer();
358
+ * const success = await docManager.openDocument('drawing.dwg', fileContent, options);
359
+ * ```
360
+ */
214
361
  AcApDocManager.prototype.openDocument = function (fileName, content, options) {
215
362
  return __awaiter(this, void 0, void 0, function () {
216
363
  var isSuccess;
@@ -223,11 +370,25 @@ var AcApDocManager = /** @class */ (function () {
223
370
  case 1:
224
371
  isSuccess = _a.sent();
225
372
  this.onAfterOpenDocument(isSuccess);
226
- return [2 /*return*/];
373
+ return [2 /*return*/, isSuccess];
227
374
  }
228
375
  });
229
376
  });
230
377
  };
378
+ /**
379
+ * Registers all default commands available in the CAD viewer.
380
+ *
381
+ * This method sets up the command system by registering built-in commands including:
382
+ * - pan: Pan/move the view
383
+ * - select: Select entities
384
+ * - zoom: Zoom in/out
385
+ * - zoomw: Zoom to window/box
386
+ * - csvg: Convert to SVG
387
+ * - qnew: Quick new document
388
+ * - open: Open document
389
+ *
390
+ * All commands are registered under the system command group.
391
+ */
231
392
  AcApDocManager.prototype.registerCommands = function () {
232
393
  var register = AcEdCommandStack.instance;
233
394
  register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'pan', 'pan', new AcApPanCmd());
@@ -238,14 +399,46 @@ var AcApDocManager = /** @class */ (function () {
238
399
  register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'qnew', 'qnew', new AcApQNewCmd());
239
400
  register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'open', 'open', new AcApOpenCmd());
240
401
  };
402
+ /**
403
+ * Executes a command by its string name.
404
+ *
405
+ * This method looks up a registered command by name and executes it with the current context.
406
+ * If the command is not found, no action is taken.
407
+ *
408
+ * @param cmdStr - The command string to execute (e.g., 'pan', 'zoom', 'select')
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * docManager.sendStringToExecute('zoom');
413
+ * docManager.sendStringToExecute('pan');
414
+ * ```
415
+ */
241
416
  AcApDocManager.prototype.sendStringToExecute = function (cmdStr) {
242
417
  var register = AcEdCommandStack.instance;
243
418
  var cmd = register.lookupGlobalCmd(cmdStr);
244
419
  cmd === null || cmd === void 0 ? void 0 : cmd.execute(this.context);
245
420
  };
421
+ /**
422
+ * Performs cleanup operations before opening a new document.
423
+ *
424
+ * This protected method is called automatically before any document opening operation.
425
+ * It clears the current view to prepare for the new document content.
426
+ *
427
+ * @protected
428
+ */
246
429
  AcApDocManager.prototype.onBeforeOpenDocument = function () {
247
430
  this.curView.clear();
248
431
  };
432
+ /**
433
+ * Performs setup operations after a document opening attempt.
434
+ *
435
+ * This protected method is called automatically after any document opening operation.
436
+ * If the document was successfully opened, it dispatches the documentActivated event,
437
+ * sets up layout information, and zooms the view to fit the content.
438
+ *
439
+ * @param isSuccess - Whether the document was successfully opened
440
+ * @protected
441
+ */
249
442
  AcApDocManager.prototype.onAfterOpenDocument = function (isSuccess) {
250
443
  if (isSuccess) {
251
444
  this.events.documentActivated.dispatch({
@@ -255,6 +448,17 @@ var AcApDocManager = /** @class */ (function () {
255
448
  this.curView.zoomToFit();
256
449
  }
257
450
  };
451
+ /**
452
+ * Sets up or validates database opening options.
453
+ *
454
+ * This private method ensures that the options object has a font loader configured.
455
+ * If no options are provided, creates new options with the font loader.
456
+ * If options are provided but missing a font loader, adds the font loader.
457
+ *
458
+ * @param options - Optional database opening options to validate/modify
459
+ * @returns The validated options object with font loader configured
460
+ * @private
461
+ */
258
462
  AcApDocManager.prototype.setOptions = function (options) {
259
463
  if (options == null) {
260
464
  options = { fontLoader: this._fontLoader };
@@ -264,6 +468,14 @@ var AcApDocManager = /** @class */ (function () {
264
468
  }
265
469
  return options;
266
470
  };
471
+ /**
472
+ * Configures layout information for the current view.
473
+ *
474
+ * This private method sets up the active layout block table record ID and
475
+ * model space block table record ID based on the current document's space configuration.
476
+ *
477
+ * @private
478
+ */
267
479
  AcApDocManager.prototype.setLayoutInfo = function () {
268
480
  var currentView = this.curView;
269
481
  currentView.activeLayoutBtrId = this.curDocument.database.currentSpaceId;
@@ -1 +1 @@
1
- {"version":3,"file":"AcApDocManager.js","sourceRoot":"","sources":["../../src/app/AcApDocManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAE5B,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EACL,mBAA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AAE,CAAA;QAC5C,CAAC;aAAM,IAAI,OAAO,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YACtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAA;QACvC,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;;;;OAOG;IACK,sCAAa,GAArB;QACE,IAAM,WAAW,GAAG,IAAI,CAAC,OAAqB,CAAA;QAC9C,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAA;QACxE,WAAW,CAAC,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAA;IACxE,CAAC;IACH,qBAAC;AAAD,CAAC,AAraD,IAqaC"}
@@ -1,27 +1,101 @@
1
1
  import { AcDbDatabase, AcDbOpenDatabaseOptions } from '@mlightcad/data-model';
2
+ /**
3
+ * Represents a CAD document that manages a drawing database and associated metadata.
4
+ *
5
+ * This class handles:
6
+ * - Opening CAD files from URIs or file content (DWG/DXF formats)
7
+ * - Managing document properties (title, read-only state)
8
+ * - Providing access to the underlying database
9
+ * - Handling file loading errors through event emission
10
+ */
2
11
  export declare class AcApDocument {
12
+ /** The URI of the opened document, if opened from a URI */
3
13
  private _uri?;
14
+ /** The underlying CAD database containing all drawing data */
4
15
  private _database;
16
+ /** The file name of the document */
5
17
  private _fileName;
18
+ /** The display title of the document */
6
19
  private _docTitle;
20
+ /** Whether the document is opened in read-only mode */
7
21
  private _isReadOnly;
22
+ /**
23
+ * Creates a new document instance with an empty database.
24
+ *
25
+ * The document is initialized with an "Untitled" title and read-only mode enabled.
26
+ */
8
27
  constructor();
28
+ /**
29
+ * Opens a CAD document from a URI.
30
+ *
31
+ * @param uri - The URI of the CAD file to open
32
+ * @param options - Options for opening the database, including read-only mode
33
+ * @returns Promise resolving to true if successful, false if failed
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const success = await document.openUri('https://example.com/drawing.dwg', {
38
+ * readOnly: true
39
+ * });
40
+ * ```
41
+ */
9
42
  openUri(uri: string, options: AcDbOpenDatabaseOptions): Promise<boolean>;
43
+ /**
44
+ * Opens a CAD document from file content.
45
+ *
46
+ * @param fileName - The name of the file (used to determine file type from extension)
47
+ * @param content - The file content as string or ArrayBuffer
48
+ * @param options - Options for opening the database, including read-only mode
49
+ * @returns Promise resolving to true if successful, false if failed
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const fileContent = await fetch('drawing.dwg').then(r => r.arrayBuffer());
54
+ * const success = await document.openDocument('drawing.dwg', fileContent, {
55
+ * readOnly: false
56
+ * });
57
+ * ```
58
+ */
10
59
  openDocument(fileName: string, content: string | ArrayBuffer, options: AcDbOpenDatabaseOptions): Promise<boolean>;
60
+ /**
61
+ * Gets the URI of the document if opened from a URI.
62
+ *
63
+ * @returns The document URI, or undefined if not opened from URI
64
+ */
11
65
  get uri(): string | undefined;
12
66
  /**
13
- * The database object being used by this document instance.
67
+ * Gets the database object containing all drawing data.
68
+ *
69
+ * @returns The underlying CAD database instance
14
70
  */
15
71
  get database(): AcDbDatabase;
16
72
  /**
17
- * The window title of the document
73
+ * Gets the display title of the document.
74
+ *
75
+ * @returns The document title displayed in the window/tab
18
76
  */
19
77
  get docTitle(): string;
78
+ /**
79
+ * Sets the display title of the document.
80
+ *
81
+ * Also updates the browser tab title if running in a browser environment.
82
+ *
83
+ * @param value - The new document title
84
+ */
20
85
  set docTitle(value: string);
21
86
  /**
22
- * Return true if the document is read only; otherwise, returns false.
87
+ * Gets whether the document is opened in read-only mode.
88
+ *
89
+ * @returns True if the document is read-only, false if editable
23
90
  */
24
91
  get isReadOnly(): boolean;
92
+ /**
93
+ * Extracts the file name from a URI.
94
+ *
95
+ * @param uri - The URI to extract the file name from
96
+ * @returns The extracted file name, or empty string if extraction fails
97
+ * @private
98
+ */
25
99
  private getFileNameFromUri;
26
100
  }
27
101
  //# sourceMappingURL=AcApDocument.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AcApDocument.d.ts","sourceRoot":"","sources":["../../src/app/AcApDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAI9B,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAC,CAAQ;IACrB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,WAAW,CAAgB;;IAO7B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB;IAerD,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,WAAW,EAC7B,OAAO,EAAE,uBAAuB;IAoBlC,IAAI,GAAG,uBAEN;IAED;;OAEG;IACH,IAAI,QAAQ,iBAEX;IAED;;OAEG;IACH,IAAI,QAAQ,IAGQ,MAAM,CADzB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMzB;IAED;;OAEG;IACH,IAAI,UAAU,YAEb;IAED,OAAO,CAAC,kBAAkB;CAa3B"}
1
+ {"version":3,"file":"AcApDocument.d.ts","sourceRoot":"","sources":["../../src/app/AcApDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAI9B;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACvB,2DAA2D;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAQ;IACrB,8DAA8D;IAC9D,OAAO,CAAC,SAAS,CAAc;IAC/B,oCAAoC;IACpC,OAAO,CAAC,SAAS,CAAa;IAC9B,wCAAwC;IACxC,OAAO,CAAC,SAAS,CAAa;IAC9B,uDAAuD;IACvD,OAAO,CAAC,WAAW,CAAgB;IAEnC;;;;OAIG;;IAMH;;;;;;;;;;;;;OAaG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB;IAe3D;;;;;;;;;;;;;;;OAeG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,WAAW,EAC7B,OAAO,EAAE,uBAAuB;IAoBlC;;;;OAIG;IACH,IAAI,GAAG,uBAEN;IAED;;;;OAIG;IACH,IAAI,QAAQ,iBAEX;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAWQ,MAAM,CATzB;IAED;;;;;;OAMG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMzB;IAED;;;;OAIG;IACH,IAAI,UAAU,YAEb;IAED;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;CAa3B"}
@@ -36,14 +36,45 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import { AcDbDatabase, AcDbFileType } from '@mlightcad/data-model';
38
38
  import { eventBus } from '../editor';
39
+ /**
40
+ * Represents a CAD document that manages a drawing database and associated metadata.
41
+ *
42
+ * This class handles:
43
+ * - Opening CAD files from URIs or file content (DWG/DXF formats)
44
+ * - Managing document properties (title, read-only state)
45
+ * - Providing access to the underlying database
46
+ * - Handling file loading errors through event emission
47
+ */
39
48
  var AcApDocument = /** @class */ (function () {
49
+ /**
50
+ * Creates a new document instance with an empty database.
51
+ *
52
+ * The document is initialized with an "Untitled" title and read-only mode enabled.
53
+ */
40
54
  function AcApDocument() {
55
+ /** The file name of the document */
41
56
  this._fileName = '';
57
+ /** The display title of the document */
42
58
  this._docTitle = '';
59
+ /** Whether the document is opened in read-only mode */
43
60
  this._isReadOnly = true;
44
61
  this._database = new AcDbDatabase();
45
62
  this.docTitle = 'Untitled';
46
63
  }
64
+ /**
65
+ * Opens a CAD document from a URI.
66
+ *
67
+ * @param uri - The URI of the CAD file to open
68
+ * @param options - Options for opening the database, including read-only mode
69
+ * @returns Promise resolving to true if successful, false if failed
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const success = await document.openUri('https://example.com/drawing.dwg', {
74
+ * readOnly: true
75
+ * });
76
+ * ```
77
+ */
47
78
  AcApDocument.prototype.openUri = function (uri, options) {
48
79
  return __awaiter(this, void 0, void 0, function () {
49
80
  var isSuccess, _1;
@@ -72,6 +103,22 @@ var AcApDocument = /** @class */ (function () {
72
103
  });
73
104
  });
74
105
  };
106
+ /**
107
+ * Opens a CAD document from file content.
108
+ *
109
+ * @param fileName - The name of the file (used to determine file type from extension)
110
+ * @param content - The file content as string or ArrayBuffer
111
+ * @param options - Options for opening the database, including read-only mode
112
+ * @returns Promise resolving to true if successful, false if failed
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const fileContent = await fetch('drawing.dwg').then(r => r.arrayBuffer());
117
+ * const success = await document.openDocument('drawing.dwg', fileContent, {
118
+ * readOnly: false
119
+ * });
120
+ * ```
121
+ */
75
122
  AcApDocument.prototype.openDocument = function (fileName, content, options) {
76
123
  return __awaiter(this, void 0, void 0, function () {
77
124
  var isSuccess, fileExtension, e_1;
@@ -102,6 +149,11 @@ var AcApDocument = /** @class */ (function () {
102
149
  });
103
150
  };
104
151
  Object.defineProperty(AcApDocument.prototype, "uri", {
152
+ /**
153
+ * Gets the URI of the document if opened from a URI.
154
+ *
155
+ * @returns The document URI, or undefined if not opened from URI
156
+ */
105
157
  get: function () {
106
158
  return this._uri;
107
159
  },
@@ -110,7 +162,9 @@ var AcApDocument = /** @class */ (function () {
110
162
  });
111
163
  Object.defineProperty(AcApDocument.prototype, "database", {
112
164
  /**
113
- * The database object being used by this document instance.
165
+ * Gets the database object containing all drawing data.
166
+ *
167
+ * @returns The underlying CAD database instance
114
168
  */
115
169
  get: function () {
116
170
  return this._database;
@@ -120,11 +174,20 @@ var AcApDocument = /** @class */ (function () {
120
174
  });
121
175
  Object.defineProperty(AcApDocument.prototype, "docTitle", {
122
176
  /**
123
- * The window title of the document
177
+ * Gets the display title of the document.
178
+ *
179
+ * @returns The document title displayed in the window/tab
124
180
  */
125
181
  get: function () {
126
182
  return this._docTitle;
127
183
  },
184
+ /**
185
+ * Sets the display title of the document.
186
+ *
187
+ * Also updates the browser tab title if running in a browser environment.
188
+ *
189
+ * @param value - The new document title
190
+ */
128
191
  set: function (value) {
129
192
  this._docTitle = value;
130
193
  // Update browser title when document title changes
@@ -137,7 +200,9 @@ var AcApDocument = /** @class */ (function () {
137
200
  });
138
201
  Object.defineProperty(AcApDocument.prototype, "isReadOnly", {
139
202
  /**
140
- * Return true if the document is read only; otherwise, returns false.
203
+ * Gets whether the document is opened in read-only mode.
204
+ *
205
+ * @returns True if the document is read-only, false if editable
141
206
  */
142
207
  get: function () {
143
208
  return this._isReadOnly;
@@ -145,6 +210,13 @@ var AcApDocument = /** @class */ (function () {
145
210
  enumerable: false,
146
211
  configurable: true
147
212
  });
213
+ /**
214
+ * Extracts the file name from a URI.
215
+ *
216
+ * @param uri - The URI to extract the file name from
217
+ * @returns The extracted file name, or empty string if extraction fails
218
+ * @private
219
+ */
148
220
  AcApDocument.prototype.getFileNameFromUri = function (uri) {
149
221
  try {
150
222
  // Create a new URL object