@mlightcad/cad-simple-viewer 1.4.12 → 1.4.13

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 (160) hide show
  1. package/dist/index.js +15901 -10590
  2. package/dist/index.umd.cjs +55 -48
  3. package/dist/libredwg-parser-worker.js +4724 -4762
  4. package/lib/app/AcApDocManager.d.ts +60 -4
  5. package/lib/app/AcApDocManager.d.ts.map +1 -1
  6. package/lib/app/AcApDocManager.js +160 -33
  7. package/lib/app/AcApDocManager.js.map +1 -1
  8. package/lib/command/AcApArcCmd.d.ts.map +1 -1
  9. package/lib/command/AcApArcCmd.js +1 -1
  10. package/lib/command/AcApArcCmd.js.map +1 -1
  11. package/lib/command/AcApCircleCmd.d.ts +59 -0
  12. package/lib/command/AcApCircleCmd.d.ts.map +1 -1
  13. package/lib/command/AcApCircleCmd.js +489 -18
  14. package/lib/command/AcApCircleCmd.js.map +1 -1
  15. package/lib/command/AcApConvertToPngCmd.d.ts +35 -0
  16. package/lib/command/AcApConvertToPngCmd.d.ts.map +1 -0
  17. package/lib/command/{AcApZoomToBoxCmd.js → AcApConvertToPngCmd.js} +50 -26
  18. package/lib/command/AcApConvertToPngCmd.js.map +1 -0
  19. package/lib/command/AcApEllipseCmd.d.ts +87 -0
  20. package/lib/command/AcApEllipseCmd.d.ts.map +1 -0
  21. package/lib/command/AcApEllipseCmd.js +583 -0
  22. package/lib/command/AcApEllipseCmd.js.map +1 -0
  23. package/lib/command/AcApHatchCmd.d.ts +210 -0
  24. package/lib/command/AcApHatchCmd.d.ts.map +1 -0
  25. package/lib/command/AcApHatchCmd.js +808 -0
  26. package/lib/command/AcApHatchCmd.js.map +1 -0
  27. package/lib/command/AcApLayerCmd.d.ts +217 -0
  28. package/lib/command/AcApLayerCmd.d.ts.map +1 -0
  29. package/lib/command/AcApLayerCmd.js +768 -0
  30. package/lib/command/AcApLayerCmd.js.map +1 -0
  31. package/lib/command/AcApLineCmd.d.ts +36 -1
  32. package/lib/command/AcApLineCmd.d.ts.map +1 -1
  33. package/lib/command/AcApLineCmd.js +157 -20
  34. package/lib/command/AcApLineCmd.js.map +1 -1
  35. package/lib/command/AcApMeasureAreaCmd.d.ts.map +1 -1
  36. package/lib/command/AcApMeasureAreaCmd.js +3 -0
  37. package/lib/command/AcApMeasureAreaCmd.js.map +1 -1
  38. package/lib/command/AcApMoveCmd.d.ts +16 -0
  39. package/lib/command/AcApMoveCmd.d.ts.map +1 -0
  40. package/lib/command/AcApMoveCmd.js +278 -0
  41. package/lib/command/AcApMoveCmd.js.map +1 -0
  42. package/lib/command/AcApPngConvertor.d.ts +95 -0
  43. package/lib/command/AcApPngConvertor.d.ts.map +1 -0
  44. package/lib/command/AcApPngConvertor.js +205 -0
  45. package/lib/command/AcApPngConvertor.js.map +1 -0
  46. package/lib/command/AcApPolygonCmd.d.ts +69 -0
  47. package/lib/command/AcApPolygonCmd.d.ts.map +1 -0
  48. package/lib/command/AcApPolygonCmd.js +422 -0
  49. package/lib/command/AcApPolygonCmd.js.map +1 -0
  50. package/lib/command/AcApRectCmd.d.ts +149 -4
  51. package/lib/command/AcApRectCmd.d.ts.map +1 -1
  52. package/lib/command/AcApRectCmd.js +716 -34
  53. package/lib/command/AcApRectCmd.js.map +1 -1
  54. package/lib/command/AcApRevCircleCmd.d.ts +8 -0
  55. package/lib/command/AcApRevCircleCmd.d.ts.map +1 -1
  56. package/lib/command/AcApRevCircleCmd.js +30 -6
  57. package/lib/command/AcApRevCircleCmd.js.map +1 -1
  58. package/lib/command/AcApRevRectCmd.d.ts +8 -0
  59. package/lib/command/AcApRevRectCmd.d.ts.map +1 -1
  60. package/lib/command/AcApRevRectCmd.js +78 -6
  61. package/lib/command/AcApRevRectCmd.js.map +1 -1
  62. package/lib/command/AcApSplineCmd.d.ts +66 -1
  63. package/lib/command/AcApSplineCmd.d.ts.map +1 -1
  64. package/lib/command/AcApSplineCmd.js +466 -59
  65. package/lib/command/AcApSplineCmd.js.map +1 -1
  66. package/lib/command/AcApZoomCmd.d.ts +91 -20
  67. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  68. package/lib/command/AcApZoomCmd.js +288 -23
  69. package/lib/command/AcApZoomCmd.js.map +1 -1
  70. package/lib/command/index.d.ts +7 -1
  71. package/lib/command/index.d.ts.map +1 -1
  72. package/lib/command/index.js +7 -1
  73. package/lib/command/index.js.map +1 -1
  74. package/lib/editor/command/AcEdCommandStack.d.ts +54 -1
  75. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
  76. package/lib/editor/command/AcEdCommandStack.js +207 -25
  77. package/lib/editor/command/AcEdCommandStack.js.map +1 -1
  78. package/lib/editor/input/AcEdSelectionFilter.d.ts +79 -0
  79. package/lib/editor/input/AcEdSelectionFilter.d.ts.map +1 -0
  80. package/lib/editor/input/AcEdSelectionFilter.js +231 -0
  81. package/lib/editor/input/AcEdSelectionFilter.js.map +1 -0
  82. package/lib/editor/input/AcEditor.d.ts +20 -2
  83. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  84. package/lib/editor/input/AcEditor.js +66 -0
  85. package/lib/editor/input/AcEditor.js.map +1 -1
  86. package/lib/editor/input/index.d.ts +1 -0
  87. package/lib/editor/input/index.d.ts.map +1 -1
  88. package/lib/editor/input/index.js +1 -0
  89. package/lib/editor/input/index.js.map +1 -1
  90. package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts +47 -0
  91. package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts.map +1 -1
  92. package/lib/editor/input/prompt/AcEdKeywordCollection.js +19 -0
  93. package/lib/editor/input/prompt/AcEdKeywordCollection.js.map +1 -1
  94. package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts +7 -0
  95. package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts.map +1 -1
  96. package/lib/editor/input/prompt/AcEdPromptAngleOptions.js +17 -0
  97. package/lib/editor/input/prompt/AcEdPromptAngleOptions.js.map +1 -1
  98. package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts +17 -0
  99. package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts.map +1 -1
  100. package/lib/editor/input/prompt/AcEdPromptEntityOptions.js +30 -3
  101. package/lib/editor/input/prompt/AcEdPromptEntityOptions.js.map +1 -1
  102. package/lib/editor/input/prompt/AcEdPromptOptions.d.ts +6 -1
  103. package/lib/editor/input/prompt/AcEdPromptOptions.d.ts.map +1 -1
  104. package/lib/editor/input/prompt/AcEdPromptOptions.js +7 -0
  105. package/lib/editor/input/prompt/AcEdPromptOptions.js.map +1 -1
  106. package/lib/editor/input/session/AcEdKeywordSession.d.ts +65 -0
  107. package/lib/editor/input/session/AcEdKeywordSession.d.ts.map +1 -1
  108. package/lib/editor/input/session/AcEdKeywordSession.js +71 -0
  109. package/lib/editor/input/session/AcEdKeywordSession.js.map +1 -1
  110. package/lib/editor/input/ui/AcEdCommandLine.d.ts +23 -0
  111. package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
  112. package/lib/editor/input/ui/AcEdCommandLine.js +42 -6
  113. package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
  114. package/lib/editor/input/ui/AcEdFloatingInput.d.ts +1 -0
  115. package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
  116. package/lib/editor/input/ui/AcEdFloatingInput.js +8 -2
  117. package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
  118. package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts +23 -1
  119. package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts.map +1 -1
  120. package/lib/editor/input/ui/AcEdFloatingInputBoxes.js +32 -9
  121. package/lib/editor/input/ui/AcEdFloatingInputBoxes.js.map +1 -1
  122. package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts +28 -0
  123. package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts.map +1 -1
  124. package/lib/editor/input/ui/AcEdInputManager.d.ts +356 -16
  125. package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
  126. package/lib/editor/input/ui/AcEdInputManager.js +964 -529
  127. package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
  128. package/lib/editor/input/ui/AcEdRubberBand.d.ts +15 -1
  129. package/lib/editor/input/ui/AcEdRubberBand.d.ts.map +1 -1
  130. package/lib/editor/input/ui/AcEdRubberBand.js +42 -10
  131. package/lib/editor/input/ui/AcEdRubberBand.js.map +1 -1
  132. package/lib/i18n/en/command.d.ts +21 -3
  133. package/lib/i18n/en/command.d.ts.map +1 -1
  134. package/lib/i18n/en/command.js +21 -3
  135. package/lib/i18n/en/command.js.map +1 -1
  136. package/lib/i18n/en/jig.d.ts +443 -0
  137. package/lib/i18n/en/jig.d.ts.map +1 -1
  138. package/lib/i18n/en/jig.js +452 -9
  139. package/lib/i18n/en/jig.js.map +1 -1
  140. package/lib/i18n/zh/command.d.ts +21 -3
  141. package/lib/i18n/zh/command.d.ts.map +1 -1
  142. package/lib/i18n/zh/command.js +21 -3
  143. package/lib/i18n/zh/command.js.map +1 -1
  144. package/lib/i18n/zh/jig.d.ts +443 -0
  145. package/lib/i18n/zh/jig.d.ts.map +1 -1
  146. package/lib/i18n/zh/jig.js +452 -9
  147. package/lib/i18n/zh/jig.js.map +1 -1
  148. package/lib/plugin/AcApPluginManager.d.ts.map +1 -1
  149. package/lib/plugin/AcApPluginManager.js.map +1 -1
  150. package/lib/view/AcTrLayer.d.ts.map +1 -1
  151. package/lib/view/AcTrLayer.js +5 -3
  152. package/lib/view/AcTrLayer.js.map +1 -1
  153. package/lib/view/AcTrView2d.d.ts +0 -1
  154. package/lib/view/AcTrView2d.d.ts.map +1 -1
  155. package/lib/view/AcTrView2d.js +17 -4
  156. package/lib/view/AcTrView2d.js.map +1 -1
  157. package/package.json +11 -9
  158. package/lib/command/AcApZoomToBoxCmd.d.ts +0 -29
  159. package/lib/command/AcApZoomToBoxCmd.d.ts.map +0 -1
  160. package/lib/command/AcApZoomToBoxCmd.js.map +0 -1
@@ -0,0 +1,768 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ var __read = (this && this.__read) || function (o, n) {
53
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
54
+ if (!m) return o;
55
+ var i = m.call(o), r, ar = [], e;
56
+ try {
57
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
58
+ }
59
+ catch (error) { e = { error: error }; }
60
+ finally {
61
+ try {
62
+ if (r && !r.done && (m = i["return"])) m.call(i);
63
+ }
64
+ finally { if (e) throw e.error; }
65
+ }
66
+ return ar;
67
+ };
68
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
69
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
70
+ if (ar || !(i in from)) {
71
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
72
+ ar[i] = from[i];
73
+ }
74
+ }
75
+ return to.concat(ar || Array.prototype.slice.call(from));
76
+ };
77
+ import { AcCmColor, AcCmColorMethod, AcDbLayerTableRecord } from '@mlightcad/data-model';
78
+ import { AcApDocManager } from '../app';
79
+ import { AcEdCommand, AcEdOpenMode, AcEdPromptKeywordOptions, AcEdPromptStatus, AcEdPromptStringOptions } from '../editor';
80
+ import { eventBus } from '../editor/global/eventBus';
81
+ import { AcApI18n } from '../i18n';
82
+ /**
83
+ * AutoCAD-style command-line layer command (`-LAYER`).
84
+ *
85
+ * This command intentionally avoids any dialog UI and keeps all interactions
86
+ * in command line prompts.
87
+ */
88
+ var AcApLayerCmd = /** @class */ (function (_super) {
89
+ __extends(AcApLayerCmd, _super);
90
+ /**
91
+ * Creates a command-line `-LAYER` command instance.
92
+ *
93
+ * The command is registered as a write-mode command because layer operations
94
+ * can modify database state (current layer, visibility, lock state, color,
95
+ * descriptions, and table records).
96
+ */
97
+ function AcApLayerCmd() {
98
+ var _this = _super.call(this) || this;
99
+ _this.mode = AcEdOpenMode.Write;
100
+ return _this;
101
+ }
102
+ /**
103
+ * Runs the interactive `-LAYER` loop.
104
+ *
105
+ * The command keeps prompting for top-level options until the user cancels
106
+ * or confirms an empty input. Each selected keyword dispatches to one
107
+ * dedicated branch handler.
108
+ *
109
+ * @param context - Active application context containing view and document.
110
+ * @returns Resolves when the command exits.
111
+ */
112
+ AcApLayerCmd.prototype.execute = function (context) {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var action, _a;
115
+ return __generator(this, function (_b) {
116
+ switch (_b.label) {
117
+ case 0:
118
+ if (!true) return [3 /*break*/, 26];
119
+ return [4 /*yield*/, this.promptMainKeyword()];
120
+ case 1:
121
+ action = _b.sent();
122
+ if (!action)
123
+ return [2 /*return*/];
124
+ _a = action;
125
+ switch (_a) {
126
+ case '?': return [3 /*break*/, 2];
127
+ case 'Make': return [3 /*break*/, 3];
128
+ case 'Set': return [3 /*break*/, 5];
129
+ case 'New': return [3 /*break*/, 7];
130
+ case 'On': return [3 /*break*/, 9];
131
+ case 'Off': return [3 /*break*/, 11];
132
+ case 'Color': return [3 /*break*/, 13];
133
+ case 'Freeze': return [3 /*break*/, 15];
134
+ case 'Thaw': return [3 /*break*/, 17];
135
+ case 'Lock': return [3 /*break*/, 19];
136
+ case 'Unlock': return [3 /*break*/, 21];
137
+ case 'Description': return [3 /*break*/, 23];
138
+ }
139
+ return [3 /*break*/, 25];
140
+ case 2:
141
+ this.listLayers(context);
142
+ return [3 /*break*/, 25];
143
+ case 3: return [4 /*yield*/, this.runMake(context)];
144
+ case 4:
145
+ _b.sent();
146
+ return [3 /*break*/, 25];
147
+ case 5: return [4 /*yield*/, this.runSet(context)];
148
+ case 6:
149
+ _b.sent();
150
+ return [3 /*break*/, 25];
151
+ case 7: return [4 /*yield*/, this.runNew(context)];
152
+ case 8:
153
+ _b.sent();
154
+ return [3 /*break*/, 25];
155
+ case 9: return [4 /*yield*/, this.runOnOff(context, false)];
156
+ case 10:
157
+ _b.sent();
158
+ return [3 /*break*/, 25];
159
+ case 11: return [4 /*yield*/, this.runOnOff(context, true)];
160
+ case 12:
161
+ _b.sent();
162
+ return [3 /*break*/, 25];
163
+ case 13: return [4 /*yield*/, this.runColor(context)];
164
+ case 14:
165
+ _b.sent();
166
+ return [3 /*break*/, 25];
167
+ case 15: return [4 /*yield*/, this.runFreeze(context, true)];
168
+ case 16:
169
+ _b.sent();
170
+ return [3 /*break*/, 25];
171
+ case 17: return [4 /*yield*/, this.runFreeze(context, false)];
172
+ case 18:
173
+ _b.sent();
174
+ return [3 /*break*/, 25];
175
+ case 19: return [4 /*yield*/, this.runLock(context, true)];
176
+ case 20:
177
+ _b.sent();
178
+ return [3 /*break*/, 25];
179
+ case 21: return [4 /*yield*/, this.runLock(context, false)];
180
+ case 22:
181
+ _b.sent();
182
+ return [3 /*break*/, 25];
183
+ case 23: return [4 /*yield*/, this.runDescription(context)];
184
+ case 24:
185
+ _b.sent();
186
+ return [3 /*break*/, 25];
187
+ case 25: return [3 /*break*/, 0];
188
+ case 26: return [2 /*return*/];
189
+ }
190
+ });
191
+ });
192
+ };
193
+ /**
194
+ * Prompts for one top-level `-LAYER` action keyword.
195
+ *
196
+ * The prompt is keyword-only and supports empty-enter termination (`allowNone`).
197
+ *
198
+ * @returns Selected top-level keyword, or `undefined` when canceled/finished.
199
+ */
200
+ AcApLayerCmd.prototype.promptMainKeyword = function () {
201
+ return __awaiter(this, void 0, void 0, function () {
202
+ var prompt, result, keyword;
203
+ return __generator(this, function (_a) {
204
+ switch (_a.label) {
205
+ case 0:
206
+ prompt = new AcEdPromptKeywordOptions(AcApI18n.t('jig.layer.main'));
207
+ prompt.allowNone = true;
208
+ this.addKeyword(prompt, 'list');
209
+ this.addKeyword(prompt, 'make');
210
+ this.addKeyword(prompt, 'set');
211
+ this.addKeyword(prompt, 'new');
212
+ this.addKeyword(prompt, 'on');
213
+ this.addKeyword(prompt, 'off');
214
+ this.addKeyword(prompt, 'color');
215
+ this.addKeyword(prompt, 'freeze');
216
+ this.addKeyword(prompt, 'thaw');
217
+ this.addKeyword(prompt, 'lock');
218
+ this.addKeyword(prompt, 'unlock');
219
+ this.addKeyword(prompt, 'description');
220
+ return [4 /*yield*/, AcApDocManager.instance.editor.getKeywords(prompt)];
221
+ case 1:
222
+ result = _a.sent();
223
+ if (result.status !== AcEdPromptStatus.OK)
224
+ return [2 /*return*/, undefined];
225
+ keyword = result.stringResult;
226
+ return [2 /*return*/, keyword];
227
+ }
228
+ });
229
+ });
230
+ };
231
+ /**
232
+ * Adds one localized keyword entry to the main `-LAYER` prompt.
233
+ *
234
+ * @param prompt - Target keyword prompt to receive the keyword option.
235
+ * @param keyword - Translation-key suffix for `jig.layer.keywords.*`.
236
+ */
237
+ AcApLayerCmd.prototype.addKeyword = function (prompt, keyword) {
238
+ prompt.keywords.add(AcApI18n.t("jig.layer.keywords.".concat(keyword, ".display")), AcApI18n.t("jig.layer.keywords.".concat(keyword, ".global")), AcApI18n.t("jig.layer.keywords.".concat(keyword, ".local")));
239
+ };
240
+ /**
241
+ * Emits one user-facing message through the global event bus.
242
+ *
243
+ * This keeps command logic decoupled from concrete UI rendering.
244
+ *
245
+ * @param message - Message text to display.
246
+ * @param type - Message severity category.
247
+ */
248
+ AcApLayerCmd.prototype.notify = function (message, type) {
249
+ if (type === void 0) { type = 'info'; }
250
+ eventBus.emit('message', { message: message, type: type });
251
+ };
252
+ /**
253
+ * Prints all layer states to browser console and reports summary in UI.
254
+ *
255
+ * The list contains the current-layer marker and common status columns
256
+ * (on/off, frozen, locked, color).
257
+ *
258
+ * @param context - Active command context used to resolve the layer table.
259
+ */
260
+ AcApLayerCmd.prototype.listLayers = function (context) {
261
+ var db = context.doc.database;
262
+ var layers = __spreadArray([], __read(db.tables.layerTable.newIterator()), false);
263
+ var rows = layers.map(function (layer) { return ({
264
+ name: layer.name,
265
+ current: db.clayer === layer.name ? '*' : '',
266
+ on: layer.isOff ? 'No' : 'Yes',
267
+ frozen: layer.isFrozen ? 'Yes' : 'No',
268
+ locked: layer.isLocked ? 'Yes' : 'No',
269
+ color: layer.color.toString()
270
+ }); });
271
+ console.table(rows);
272
+ this.notify("".concat(AcApI18n.t('jig.layer.listSummary'), " (").concat(rows.length, ")"), 'info');
273
+ };
274
+ /**
275
+ * Parses a raw layer-name input string into a distinct name list.
276
+ *
277
+ * Supported forms:
278
+ * - `*` to target all existing layer names.
279
+ * - Comma-separated names (e.g. `A,B,C`).
280
+ *
281
+ * @param input - Raw user input from command line.
282
+ * @param allNames - All existing layer names, used for wildcard expansion.
283
+ * @returns Deduplicated list of requested layer names.
284
+ */
285
+ AcApLayerCmd.prototype.parseLayerNameInput = function (input, allNames) {
286
+ var raw = input.trim();
287
+ if (!raw)
288
+ return [];
289
+ if (raw === '*')
290
+ return __spreadArray([], __read(allNames), false);
291
+ var names = raw
292
+ .split(',')
293
+ .map(function (v) { return v.trim(); })
294
+ .filter(Boolean);
295
+ return __spreadArray([], __read(new Set(names)), false);
296
+ };
297
+ /**
298
+ * Resolves layer records by name and separates missing names.
299
+ *
300
+ * @param context - Active command context with access to layer table.
301
+ * @param names - Layer names to resolve.
302
+ * @returns Object containing matched records and unresolved names.
303
+ */
304
+ AcApLayerCmd.prototype.resolveLayers = function (context, names) {
305
+ var table = context.doc.database.tables.layerTable;
306
+ var layers = [];
307
+ var missing = [];
308
+ names.forEach(function (name) {
309
+ var layer = table.getAt(name);
310
+ if (layer)
311
+ layers.push(layer);
312
+ else
313
+ missing.push(name);
314
+ });
315
+ return { layers: layers, missing: missing };
316
+ };
317
+ /**
318
+ * Sets or clears the frozen bit in `standardFlags`.
319
+ *
320
+ * The explicit bit operation is used to ensure both freeze and thaw are
321
+ * applied deterministically.
322
+ *
323
+ * @param layer - Target layer table record.
324
+ * @param frozen - `true` to freeze, `false` to thaw.
325
+ */
326
+ AcApLayerCmd.prototype.setLayerFrozen = function (layer, frozen) {
327
+ var _a;
328
+ var flags = (_a = layer.standardFlags) !== null && _a !== void 0 ? _a : 0;
329
+ layer.standardFlags = frozen ? flags | 0x01 : flags & ~0x01;
330
+ };
331
+ /**
332
+ * Sets or clears the locked bit in `standardFlags`.
333
+ *
334
+ * The explicit bit operation is used to ensure both lock and unlock are
335
+ * applied deterministically.
336
+ *
337
+ * @param layer - Target layer table record.
338
+ * @param locked - `true` to lock, `false` to unlock.
339
+ */
340
+ AcApLayerCmd.prototype.setLayerLocked = function (layer, locked) {
341
+ var _a;
342
+ var flags = (_a = layer.standardFlags) !== null && _a !== void 0 ? _a : 0;
343
+ layer.standardFlags = locked ? flags | 0x04 : flags & ~0x04;
344
+ };
345
+ /**
346
+ * Prompts for one or more layer names and parses them into a list.
347
+ *
348
+ * This helper powers batch operations such as on/off/freeze/thaw/lock/unlock
349
+ * and supports wildcard `*` plus comma-separated names.
350
+ *
351
+ * @param message - Prompt message shown in command line.
352
+ * @param context - Active command context used for wildcard expansion.
353
+ * @returns Parsed layer names, or `undefined` when canceled/invalid.
354
+ */
355
+ AcApLayerCmd.prototype.promptLayerNames = function (message, context) {
356
+ return __awaiter(this, void 0, void 0, function () {
357
+ var prompt, result, allNames, names;
358
+ var _a;
359
+ return __generator(this, function (_b) {
360
+ switch (_b.label) {
361
+ case 0:
362
+ prompt = new AcEdPromptStringOptions(message);
363
+ prompt.allowSpaces = false;
364
+ return [4 /*yield*/, AcApDocManager.instance.editor.getString(prompt)];
365
+ case 1:
366
+ result = _b.sent();
367
+ if (result.status !== AcEdPromptStatus.OK)
368
+ return [2 /*return*/, undefined];
369
+ allNames = __spreadArray([], __read(context.doc.database.tables.layerTable.newIterator()), false).map(function (layer) { return layer.name; });
370
+ names = this.parseLayerNameInput((_a = result.stringResult) !== null && _a !== void 0 ? _a : '', allNames);
371
+ if (!names.length) {
372
+ this.notify(AcApI18n.t('jig.layer.emptyInput'), 'warning');
373
+ return [2 /*return*/, undefined];
374
+ }
375
+ return [2 /*return*/, names];
376
+ }
377
+ });
378
+ });
379
+ };
380
+ /**
381
+ * Prompts for a single layer name.
382
+ *
383
+ * @param message - Prompt message shown in command line.
384
+ * @returns Trimmed layer name, or `undefined` when canceled/empty.
385
+ */
386
+ AcApLayerCmd.prototype.promptSingleLayerName = function (message) {
387
+ return __awaiter(this, void 0, void 0, function () {
388
+ var prompt, result, name;
389
+ var _a;
390
+ return __generator(this, function (_b) {
391
+ switch (_b.label) {
392
+ case 0:
393
+ prompt = new AcEdPromptStringOptions(message);
394
+ prompt.allowSpaces = true;
395
+ return [4 /*yield*/, AcApDocManager.instance.editor.getString(prompt)];
396
+ case 1:
397
+ result = _b.sent();
398
+ if (result.status !== AcEdPromptStatus.OK)
399
+ return [2 /*return*/, undefined];
400
+ name = ((_a = result.stringResult) !== null && _a !== void 0 ? _a : '').trim();
401
+ return [2 /*return*/, name || undefined];
402
+ }
403
+ });
404
+ });
405
+ };
406
+ /**
407
+ * Handles the `New` branch.
408
+ *
409
+ * Creates one or more missing layers while keeping existing ones unchanged.
410
+ * The method reports creation count and duplicate names separately.
411
+ *
412
+ * @param context - Active command context used to access the layer table.
413
+ * @returns Resolves when branch execution completes.
414
+ */
415
+ AcApLayerCmd.prototype.runNew = function (context) {
416
+ return __awaiter(this, void 0, void 0, function () {
417
+ var names, table, created, existed;
418
+ return __generator(this, function (_a) {
419
+ switch (_a.label) {
420
+ case 0: return [4 /*yield*/, this.promptLayerNames(AcApI18n.t('jig.layer.newPrompt'), context)];
421
+ case 1:
422
+ names = _a.sent();
423
+ if (!names)
424
+ return [2 /*return*/];
425
+ table = context.doc.database.tables.layerTable;
426
+ created = 0;
427
+ existed = [];
428
+ names.forEach(function (name) {
429
+ if (table.has(name)) {
430
+ existed.push(name);
431
+ return;
432
+ }
433
+ table.add(new AcDbLayerTableRecord({
434
+ name: name,
435
+ isOff: false,
436
+ isPlottable: true,
437
+ color: new AcCmColor(AcCmColorMethod.ByACI, 7),
438
+ linetype: 'Continuous'
439
+ }));
440
+ created++;
441
+ });
442
+ if (created > 0) {
443
+ this.notify("".concat(AcApI18n.t('jig.layer.created'), ": ").concat(created), 'success');
444
+ }
445
+ if (existed.length > 0) {
446
+ this.notify("".concat(AcApI18n.t('jig.layer.alreadyExists'), ": ").concat(existed.join(', ')), 'warning');
447
+ }
448
+ return [2 /*return*/];
449
+ }
450
+ });
451
+ });
452
+ };
453
+ /**
454
+ * Handles the `Set` branch.
455
+ *
456
+ * Sets one existing layer as current (`CLAYER`) and ensures the target is
457
+ * visible/unfrozen before assignment.
458
+ *
459
+ * @param context - Active command context.
460
+ * @returns Resolves when branch execution completes.
461
+ */
462
+ AcApLayerCmd.prototype.runSet = function (context) {
463
+ return __awaiter(this, void 0, void 0, function () {
464
+ var name, layer;
465
+ return __generator(this, function (_a) {
466
+ switch (_a.label) {
467
+ case 0: return [4 /*yield*/, this.promptSingleLayerName(AcApI18n.t('jig.layer.setPrompt'))];
468
+ case 1:
469
+ name = _a.sent();
470
+ if (!name)
471
+ return [2 /*return*/];
472
+ layer = context.doc.database.tables.layerTable.getAt(name);
473
+ if (!layer) {
474
+ this.notify("".concat(AcApI18n.t('jig.layer.notFound'), ": ").concat(name), 'warning');
475
+ return [2 /*return*/];
476
+ }
477
+ layer.isOff = false;
478
+ this.setLayerFrozen(layer, false);
479
+ context.doc.database.clayer = layer.name;
480
+ return [2 /*return*/];
481
+ }
482
+ });
483
+ });
484
+ };
485
+ /**
486
+ * Handles the `Make` branch.
487
+ *
488
+ * Creates the layer if missing, then makes it current. The resulting current
489
+ * layer is turned on and thawed.
490
+ *
491
+ * @param context - Active command context.
492
+ * @returns Resolves when branch execution completes.
493
+ */
494
+ AcApLayerCmd.prototype.runMake = function (context) {
495
+ return __awaiter(this, void 0, void 0, function () {
496
+ var name, table, layer;
497
+ return __generator(this, function (_a) {
498
+ switch (_a.label) {
499
+ case 0: return [4 /*yield*/, this.promptSingleLayerName(AcApI18n.t('jig.layer.makePrompt'))];
500
+ case 1:
501
+ name = _a.sent();
502
+ if (!name)
503
+ return [2 /*return*/];
504
+ table = context.doc.database.tables.layerTable;
505
+ layer = table.getAt(name);
506
+ if (!layer) {
507
+ layer = new AcDbLayerTableRecord({
508
+ name: name,
509
+ isOff: false,
510
+ isPlottable: true,
511
+ color: new AcCmColor(AcCmColorMethod.ByACI, 7),
512
+ linetype: 'Continuous'
513
+ });
514
+ table.add(layer);
515
+ }
516
+ layer.isOff = false;
517
+ this.setLayerFrozen(layer, false);
518
+ context.doc.database.clayer = layer.name;
519
+ return [2 /*return*/];
520
+ }
521
+ });
522
+ });
523
+ };
524
+ /**
525
+ * Handles `On` and `Off` branches.
526
+ *
527
+ * Batch toggles visibility for selected layers. Turning off the current layer
528
+ * is skipped and reported as warning.
529
+ *
530
+ * @param context - Active command context.
531
+ * @param off - `true` for `Off`, `false` for `On`.
532
+ * @returns Resolves when branch execution completes.
533
+ */
534
+ AcApLayerCmd.prototype.runOnOff = function (context, off) {
535
+ return __awaiter(this, void 0, void 0, function () {
536
+ var names, db, _a, layers, missing, skippedCurrent;
537
+ return __generator(this, function (_b) {
538
+ switch (_b.label) {
539
+ case 0: return [4 /*yield*/, this.promptLayerNames(off
540
+ ? AcApI18n.t('jig.layer.offPrompt')
541
+ : AcApI18n.t('jig.layer.onPrompt'), context)];
542
+ case 1:
543
+ names = _b.sent();
544
+ if (!names)
545
+ return [2 /*return*/];
546
+ db = context.doc.database;
547
+ _a = this.resolveLayers(context, names), layers = _a.layers, missing = _a.missing;
548
+ if (missing.length > 0) {
549
+ this.notify("".concat(AcApI18n.t('jig.layer.notFound'), ": ").concat(missing.join(', ')), 'warning');
550
+ }
551
+ skippedCurrent = [];
552
+ layers.forEach(function (layer) {
553
+ if (off && layer.name === db.clayer) {
554
+ skippedCurrent.push(layer.name);
555
+ return;
556
+ }
557
+ layer.isOff = off;
558
+ });
559
+ if (skippedCurrent.length > 0) {
560
+ this.notify(AcApI18n.t('jig.layer.cannotChangeCurrent'), 'warning');
561
+ }
562
+ return [2 /*return*/];
563
+ }
564
+ });
565
+ });
566
+ };
567
+ /**
568
+ * Handles `Freeze` and `Thaw` branches.
569
+ *
570
+ * Batch toggles frozen state using explicit bit operations. Freezing the
571
+ * current layer is skipped and reported as warning.
572
+ *
573
+ * @param context - Active command context.
574
+ * @param freeze - `true` for `Freeze`, `false` for `Thaw`.
575
+ * @returns Resolves when branch execution completes.
576
+ */
577
+ AcApLayerCmd.prototype.runFreeze = function (context, freeze) {
578
+ return __awaiter(this, void 0, void 0, function () {
579
+ var names, db, _a, layers, missing, skippedCurrent;
580
+ var _this = this;
581
+ return __generator(this, function (_b) {
582
+ switch (_b.label) {
583
+ case 0: return [4 /*yield*/, this.promptLayerNames(freeze
584
+ ? AcApI18n.t('jig.layer.freezePrompt')
585
+ : AcApI18n.t('jig.layer.thawPrompt'), context)];
586
+ case 1:
587
+ names = _b.sent();
588
+ if (!names)
589
+ return [2 /*return*/];
590
+ db = context.doc.database;
591
+ _a = this.resolveLayers(context, names), layers = _a.layers, missing = _a.missing;
592
+ if (missing.length > 0) {
593
+ this.notify("".concat(AcApI18n.t('jig.layer.notFound'), ": ").concat(missing.join(', ')), 'warning');
594
+ }
595
+ skippedCurrent = [];
596
+ layers.forEach(function (layer) {
597
+ if (freeze && layer.name === db.clayer) {
598
+ skippedCurrent.push(layer.name);
599
+ return;
600
+ }
601
+ _this.setLayerFrozen(layer, freeze);
602
+ });
603
+ if (skippedCurrent.length > 0) {
604
+ this.notify(AcApI18n.t('jig.layer.cannotChangeCurrent'), 'warning');
605
+ }
606
+ return [2 /*return*/];
607
+ }
608
+ });
609
+ });
610
+ };
611
+ /**
612
+ * Handles `Lock` and `Unlock` branches.
613
+ *
614
+ * Batch toggles lock state using explicit bit operations.
615
+ *
616
+ * @param context - Active command context.
617
+ * @param lock - `true` for `Lock`, `false` for `Unlock`.
618
+ * @returns Resolves when branch execution completes.
619
+ */
620
+ AcApLayerCmd.prototype.runLock = function (context, lock) {
621
+ return __awaiter(this, void 0, void 0, function () {
622
+ var names, _a, layers, missing;
623
+ var _this = this;
624
+ return __generator(this, function (_b) {
625
+ switch (_b.label) {
626
+ case 0: return [4 /*yield*/, this.promptLayerNames(lock
627
+ ? AcApI18n.t('jig.layer.lockPrompt')
628
+ : AcApI18n.t('jig.layer.unlockPrompt'), context)];
629
+ case 1:
630
+ names = _b.sent();
631
+ if (!names)
632
+ return [2 /*return*/];
633
+ _a = this.resolveLayers(context, names), layers = _a.layers, missing = _a.missing;
634
+ if (missing.length > 0) {
635
+ this.notify("".concat(AcApI18n.t('jig.layer.notFound'), ": ").concat(missing.join(', ')), 'warning');
636
+ }
637
+ layers.forEach(function (layer) { return _this.setLayerLocked(layer, lock); });
638
+ return [2 /*return*/];
639
+ }
640
+ });
641
+ });
642
+ };
643
+ /**
644
+ * Parses one color input token into `AcCmColor`.
645
+ *
646
+ * Supported formats:
647
+ * - ACI index (`1..255`)
648
+ * - RGB string accepted by `AcCmColor.fromString`
649
+ * - CSS color names accepted by `AcCmColor.fromString`
650
+ *
651
+ * `ByLayer` and `ByBlock` are rejected for explicit layer color assignment.
652
+ *
653
+ * @param input - Raw color input string.
654
+ * @returns Parsed color object, or `undefined` when invalid/unsupported.
655
+ */
656
+ AcApLayerCmd.prototype.parseColorInput = function (input) {
657
+ var value = input.trim();
658
+ if (!value)
659
+ return undefined;
660
+ if (/^\d+$/.test(value)) {
661
+ var index = Number(value);
662
+ if (index >= 1 && index <= 255) {
663
+ return new AcCmColor(AcCmColorMethod.ByACI, index);
664
+ }
665
+ return undefined;
666
+ }
667
+ var color = AcCmColor.fromString(value);
668
+ if (!color)
669
+ return undefined;
670
+ if (color.isByACI) {
671
+ var index = color.colorIndex;
672
+ if (index == null || index < 1 || index > 255) {
673
+ return undefined;
674
+ }
675
+ }
676
+ if (color.isByLayer || color.isByBlock)
677
+ return undefined;
678
+ return color;
679
+ };
680
+ /**
681
+ * Handles the `Color` branch.
682
+ *
683
+ * Prompts target layers first, then prompts color value and applies a cloned
684
+ * color instance to each resolved layer.
685
+ *
686
+ * @param context - Active command context.
687
+ * @returns Resolves when branch execution completes.
688
+ */
689
+ AcApLayerCmd.prototype.runColor = function (context) {
690
+ return __awaiter(this, void 0, void 0, function () {
691
+ var names, _a, layers, missing, colorPrompt, colorResult, color;
692
+ var _b;
693
+ return __generator(this, function (_c) {
694
+ switch (_c.label) {
695
+ case 0: return [4 /*yield*/, this.promptLayerNames(AcApI18n.t('jig.layer.colorLayerPrompt'), context)];
696
+ case 1:
697
+ names = _c.sent();
698
+ if (!names)
699
+ return [2 /*return*/];
700
+ _a = this.resolveLayers(context, names), layers = _a.layers, missing = _a.missing;
701
+ if (missing.length > 0) {
702
+ this.notify("".concat(AcApI18n.t('jig.layer.notFound'), ": ").concat(missing.join(', ')), 'warning');
703
+ }
704
+ if (layers.length === 0)
705
+ return [2 /*return*/];
706
+ colorPrompt = new AcEdPromptStringOptions(AcApI18n.t('jig.layer.colorValuePrompt'));
707
+ colorPrompt.allowSpaces = false;
708
+ return [4 /*yield*/, AcApDocManager.instance.editor.getString(colorPrompt)];
709
+ case 2:
710
+ colorResult = _c.sent();
711
+ if (colorResult.status !== AcEdPromptStatus.OK)
712
+ return [2 /*return*/];
713
+ color = this.parseColorInput((_b = colorResult.stringResult) !== null && _b !== void 0 ? _b : '');
714
+ if (!color) {
715
+ this.notify(AcApI18n.t('jig.layer.invalidColor'), 'warning');
716
+ return [2 /*return*/];
717
+ }
718
+ layers.forEach(function (layer) {
719
+ layer.color = color.clone();
720
+ });
721
+ return [2 /*return*/];
722
+ }
723
+ });
724
+ });
725
+ };
726
+ /**
727
+ * Handles the `Description` branch.
728
+ *
729
+ * Updates the description text of one specified layer. Empty description is
730
+ * allowed and treated as clear.
731
+ *
732
+ * @param context - Active command context.
733
+ * @returns Resolves when branch execution completes.
734
+ */
735
+ AcApLayerCmd.prototype.runDescription = function (context) {
736
+ return __awaiter(this, void 0, void 0, function () {
737
+ var name, layer, descPrompt, result;
738
+ var _a;
739
+ return __generator(this, function (_b) {
740
+ switch (_b.label) {
741
+ case 0: return [4 /*yield*/, this.promptSingleLayerName(AcApI18n.t('jig.layer.descriptionLayerPrompt'))];
742
+ case 1:
743
+ name = _b.sent();
744
+ if (!name)
745
+ return [2 /*return*/];
746
+ layer = context.doc.database.tables.layerTable.getAt(name);
747
+ if (!layer) {
748
+ this.notify("".concat(AcApI18n.t('jig.layer.notFound'), ": ").concat(name), 'warning');
749
+ return [2 /*return*/];
750
+ }
751
+ descPrompt = new AcEdPromptStringOptions(AcApI18n.t('jig.layer.descriptionValuePrompt'));
752
+ descPrompt.allowSpaces = true;
753
+ descPrompt.allowEmpty = true;
754
+ return [4 /*yield*/, AcApDocManager.instance.editor.getString(descPrompt)];
755
+ case 2:
756
+ result = _b.sent();
757
+ if (result.status !== AcEdPromptStatus.OK)
758
+ return [2 /*return*/];
759
+ layer.description = (_a = result.stringResult) !== null && _a !== void 0 ? _a : '';
760
+ return [2 /*return*/];
761
+ }
762
+ });
763
+ });
764
+ };
765
+ return AcApLayerCmd;
766
+ }(AcEdCommand));
767
+ export { AcApLayerCmd };
768
+ //# sourceMappingURL=AcApLayerCmd.js.map