@mlightcad/cad-simple-viewer 1.4.7 → 1.4.8
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.
- package/LICENSE +21 -21
- package/README.md +88 -88
- package/dist/index.js +6014 -5042
- package/dist/index.umd.cjs +22 -22
- package/lib/app/AcApAnnotation.d.ts +46 -0
- package/lib/app/AcApAnnotation.d.ts.map +1 -0
- package/lib/app/AcApAnnotation.js +134 -0
- package/lib/app/AcApAnnotation.js.map +1 -0
- package/lib/app/AcApDocManager.d.ts +118 -6
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +162 -6
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/app/AcApDocument.d.ts +16 -14
- package/lib/app/AcApDocument.d.ts.map +1 -1
- package/lib/app/AcApDocument.js +48 -31
- package/lib/app/AcApDocument.js.map +1 -1
- package/lib/app/AcDbOpenDatabaseOptions.d.ts +28 -0
- package/lib/app/AcDbOpenDatabaseOptions.d.ts.map +1 -0
- package/lib/app/AcDbOpenDatabaseOptions.js +2 -0
- package/lib/app/AcDbOpenDatabaseOptions.js.map +1 -0
- package/lib/app/index.d.ts +2 -0
- package/lib/app/index.d.ts.map +1 -1
- package/lib/app/index.js +2 -0
- package/lib/app/index.js.map +1 -1
- package/lib/command/AcApBaseRevCmd.d.ts +36 -0
- package/lib/command/AcApBaseRevCmd.d.ts.map +1 -0
- package/lib/command/AcApBaseRevCmd.js +68 -0
- package/lib/command/AcApBaseRevCmd.js.map +1 -0
- package/lib/command/AcApCircleCmd.d.ts +1 -0
- package/lib/command/AcApCircleCmd.d.ts.map +1 -1
- package/lib/command/AcApCircleCmd.js +4 -2
- package/lib/command/AcApCircleCmd.js.map +1 -1
- package/lib/command/AcApConvertToSvgCmd.d.ts +1 -1
- package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -1
- package/lib/command/AcApConvertToSvgCmd.js +44 -2
- package/lib/command/AcApConvertToSvgCmd.js.map +1 -1
- package/lib/command/AcApDimLinearCmd.d.ts +1 -0
- package/lib/command/AcApDimLinearCmd.d.ts.map +1 -1
- package/lib/command/AcApDimLinearCmd.js +4 -2
- package/lib/command/AcApDimLinearCmd.js.map +1 -1
- package/lib/command/AcApEraseCmd.d.ts +1 -0
- package/lib/command/AcApEraseCmd.d.ts.map +1 -1
- package/lib/command/AcApEraseCmd.js +14 -4
- package/lib/command/AcApEraseCmd.js.map +1 -1
- package/lib/command/AcApLineCmd.d.ts +1 -0
- package/lib/command/AcApLineCmd.d.ts.map +1 -1
- package/lib/command/AcApLineCmd.js +4 -2
- package/lib/command/AcApLineCmd.js.map +1 -1
- package/lib/command/AcApLogCmd.d.ts +1 -1
- package/lib/command/AcApLogCmd.d.ts.map +1 -1
- package/lib/command/AcApLogCmd.js +44 -3
- package/lib/command/AcApLogCmd.js.map +1 -1
- package/lib/command/AcApOpenCmd.d.ts +1 -1
- package/lib/command/AcApOpenCmd.d.ts.map +1 -1
- package/lib/command/AcApOpenCmd.js +42 -1
- package/lib/command/AcApOpenCmd.js.map +1 -1
- package/lib/command/AcApPanCmd.d.ts +1 -1
- package/lib/command/AcApPanCmd.d.ts.map +1 -1
- package/lib/command/AcApPanCmd.js +43 -2
- package/lib/command/AcApPanCmd.js.map +1 -1
- package/lib/command/AcApQNewCmd.d.ts +1 -1
- package/lib/command/AcApQNewCmd.d.ts.map +1 -1
- package/lib/command/AcApQNewCmd.js +44 -2
- package/lib/command/AcApQNewCmd.js.map +1 -1
- package/lib/command/AcApRectCmd.d.ts +23 -0
- package/lib/command/AcApRectCmd.d.ts.map +1 -0
- package/lib/command/AcApRectCmd.js +134 -0
- package/lib/command/AcApRectCmd.js.map +1 -0
- package/lib/command/AcApRegenCmd.d.ts +1 -1
- package/lib/command/AcApRegenCmd.d.ts.map +1 -1
- package/lib/command/AcApRegenCmd.js +42 -1
- package/lib/command/AcApRegenCmd.js.map +1 -1
- package/lib/command/AcApRevCircleCmd.d.ts +10 -0
- package/lib/command/AcApRevCircleCmd.d.ts.map +1 -0
- package/lib/command/AcApRevCircleCmd.js +83 -0
- package/lib/command/AcApRevCircleCmd.js.map +1 -0
- package/lib/command/AcApRevCloudCmd.d.ts +26 -0
- package/lib/command/AcApRevCloudCmd.d.ts.map +1 -0
- package/lib/command/AcApRevCloudCmd.js +234 -0
- package/lib/command/AcApRevCloudCmd.js.map +1 -0
- package/lib/command/AcApRevRectCmd.d.ts +10 -0
- package/lib/command/AcApRevRectCmd.d.ts.map +1 -0
- package/lib/command/AcApRevRectCmd.js +83 -0
- package/lib/command/AcApRevRectCmd.js.map +1 -0
- package/lib/command/AcApRevVisibilityCmd.d.ts +15 -0
- package/lib/command/AcApRevVisibilityCmd.d.ts.map +1 -0
- package/lib/command/AcApRevVisibilityCmd.js +90 -0
- package/lib/command/AcApRevVisibilityCmd.js.map +1 -0
- package/lib/command/AcApSelectCmd.d.ts +1 -1
- package/lib/command/AcApSelectCmd.d.ts.map +1 -1
- package/lib/command/AcApSelectCmd.js +43 -2
- package/lib/command/AcApSelectCmd.js.map +1 -1
- package/lib/command/AcApSketchCmd.d.ts +32 -0
- package/lib/command/AcApSketchCmd.d.ts.map +1 -0
- package/lib/command/AcApSketchCmd.js +171 -0
- package/lib/command/AcApSketchCmd.js.map +1 -0
- package/lib/command/AcApSwitchBgCmd.d.ts +15 -0
- package/lib/command/AcApSwitchBgCmd.d.ts.map +1 -0
- package/lib/command/AcApSwitchBgCmd.js +88 -0
- package/lib/command/AcApSwitchBgCmd.js.map +1 -0
- package/lib/command/AcApSysVarCmd.d.ts +2 -1
- package/lib/command/AcApSysVarCmd.d.ts.map +1 -1
- package/lib/command/AcApSysVarCmd.js +6 -5
- package/lib/command/AcApSysVarCmd.js.map +1 -1
- package/lib/command/AcApZoomCmd.d.ts +1 -1
- package/lib/command/AcApZoomCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomCmd.js +42 -1
- package/lib/command/AcApZoomCmd.js.map +1 -1
- package/lib/command/index.d.ts +8 -0
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +8 -0
- package/lib/command/index.js.map +1 -1
- package/lib/editor/command/AcEdCommand.d.ts +81 -22
- package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommand.js +157 -15
- package/lib/editor/command/AcEdCommand.js.map +1 -1
- package/lib/editor/command/AcEdCommandIterator.d.ts +1 -1
- package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommandStack.d.ts +31 -6
- package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommandStack.js +55 -11
- package/lib/editor/command/AcEdCommandStack.js.map +1 -1
- package/lib/editor/input/AcEditor.d.ts +14 -0
- package/lib/editor/input/AcEditor.d.ts.map +1 -1
- package/lib/editor/input/AcEditor.js +5 -1
- package/lib/editor/input/AcEditor.js.map +1 -1
- package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdCommandLine.js +2 -2
- package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
- package/lib/editor/view/AcEdOpenMode.d.ts +26 -0
- package/lib/editor/view/AcEdOpenMode.d.ts.map +1 -0
- package/lib/editor/view/AcEdOpenMode.js +27 -0
- package/lib/editor/view/AcEdOpenMode.js.map +1 -0
- package/lib/editor/view/index.d.ts +2 -0
- package/lib/editor/view/index.d.ts.map +1 -1
- package/lib/editor/view/index.js +2 -0
- package/lib/editor/view/index.js.map +1 -1
- package/lib/i18n/en/command.d.ts +18 -0
- package/lib/i18n/en/command.d.ts.map +1 -1
- package/lib/i18n/en/command.js +19 -1
- package/lib/i18n/en/command.js.map +1 -1
- package/lib/i18n/en/jig.d.ts +8 -0
- package/lib/i18n/en/jig.d.ts.map +1 -1
- package/lib/i18n/en/jig.js +8 -0
- package/lib/i18n/en/jig.js.map +1 -1
- package/lib/i18n/zh/command.d.ts +18 -0
- package/lib/i18n/zh/command.d.ts.map +1 -1
- package/lib/i18n/zh/command.js +18 -0
- package/lib/i18n/zh/command.js.map +1 -1
- package/lib/i18n/zh/jig.d.ts +8 -0
- package/lib/i18n/zh/jig.d.ts.map +1 -1
- package/lib/i18n/zh/jig.js +8 -0
- package/lib/i18n/zh/jig.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/plugin/AcApPlugin.d.ts +83 -0
- package/lib/plugin/AcApPlugin.d.ts.map +1 -0
- package/lib/plugin/AcApPlugin.js +2 -0
- package/lib/plugin/AcApPlugin.js.map +1 -0
- package/lib/plugin/AcApPluginExample.d.ts +23 -0
- package/lib/plugin/AcApPluginExample.d.ts.map +1 -0
- package/lib/plugin/AcApPluginExample.js +160 -0
- package/lib/plugin/AcApPluginExample.js.map +1 -0
- package/lib/plugin/AcApPluginManager.d.ts +206 -0
- package/lib/plugin/AcApPluginManager.d.ts.map +1 -0
- package/lib/plugin/AcApPluginManager.js +499 -0
- package/lib/plugin/AcApPluginManager.js.map +1 -0
- package/lib/plugin/index.d.ts +4 -0
- package/lib/plugin/index.d.ts.map +1 -0
- package/lib/plugin/index.js +4 -0
- package/lib/plugin/index.js.map +1 -0
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +8 -1
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AcCmColor, AcDbDatabase, AcDbObject, AcDbObjectId } from '@mlightcad/data-model';
|
|
2
|
+
export declare class AcApAnnotation {
|
|
3
|
+
/**
|
|
4
|
+
* Default annotation color is red
|
|
5
|
+
*/
|
|
6
|
+
static DEFAULT_ANNOTATION_COLOR: AcCmColor;
|
|
7
|
+
private _database;
|
|
8
|
+
constructor(db: AcDbDatabase);
|
|
9
|
+
/**
|
|
10
|
+
* Finds or creates a annotation layer identified by MLightCAD-specific XData.
|
|
11
|
+
*
|
|
12
|
+
* This method enforces the concept of a *singleton annotation layer* in a drawing.
|
|
13
|
+
* It first scans all existing layers and looks for one whose XData contains
|
|
14
|
+
* a description value of `"mlightcad"` under the registered application name
|
|
15
|
+
* `"mlightcad"`.
|
|
16
|
+
*
|
|
17
|
+
* Behavior:
|
|
18
|
+
* - If such a layer already exists, its name is returned and **no new layer
|
|
19
|
+
* is created**.
|
|
20
|
+
* - If no matching layer is found, a new layer is created with:
|
|
21
|
+
* - A unique name using the prefix `"$revision_"` followed by a numeric index
|
|
22
|
+
* (e.g. `$revision_1`, `$revision_2`, …)
|
|
23
|
+
* - Yellow color (ACI = 2)
|
|
24
|
+
* - Layer turned on and plottable
|
|
25
|
+
* - XData attached to mark it as an MLightCAD annotation layer
|
|
26
|
+
*
|
|
27
|
+
* XData layout:
|
|
28
|
+
* - RegApp name: `"mlightcad"`
|
|
29
|
+
* - Description (ASCII string): `"mlightcad"`
|
|
30
|
+
*
|
|
31
|
+
* The attached XData allows the annotation layer to be reliably identified even
|
|
32
|
+
* if the layer is renamed by the user.
|
|
33
|
+
*
|
|
34
|
+
* @returns The name of the existing or newly created annotation layer.
|
|
35
|
+
*/
|
|
36
|
+
getAnnotationLayer(): string;
|
|
37
|
+
filterAnnotationEntities(ids: AcDbObjectId[]): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Returns true if the specified object contains annotation xdata, which means
|
|
40
|
+
* it is only object created by annotation related commands.
|
|
41
|
+
* @param object - Object to check whether it contains annotation xdata.
|
|
42
|
+
* @returns Returns true if the specified object contains annotation xdata.
|
|
43
|
+
*/
|
|
44
|
+
hasAnnotationXData(object: AcDbObject): boolean;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=AcApAnnotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApAnnotation.d.ts","sourceRoot":"","sources":["../../src/app/AcApAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,YAAY,EAGZ,UAAU,EACV,YAAY,EAEb,MAAM,uBAAuB,CAAA;AAE9B,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,wBAAwB,YAA0C;IACzE,OAAO,CAAC,SAAS,CAAc;gBAEnB,EAAE,EAAE,YAAY;IAI5B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACI,kBAAkB,IAAI,MAAM;IAyCnC,wBAAwB,CAAC,GAAG,EAAE,YAAY,EAAE;IAQ5C;;;;;OAKG;IACI,kBAAkB,CAAC,MAAM,EAAE,UAAU;CAgB7C"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
12
|
+
import { AcCmColor, AcCmColorMethod, AcDbDatabase, AcDbLayerTableRecord, AcDbResultBuffer } from '@mlightcad/data-model';
|
|
13
|
+
var AcApAnnotation = /** @class */ (function () {
|
|
14
|
+
function AcApAnnotation(db) {
|
|
15
|
+
this._database = db;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Finds or creates a annotation layer identified by MLightCAD-specific XData.
|
|
19
|
+
*
|
|
20
|
+
* This method enforces the concept of a *singleton annotation layer* in a drawing.
|
|
21
|
+
* It first scans all existing layers and looks for one whose XData contains
|
|
22
|
+
* a description value of `"mlightcad"` under the registered application name
|
|
23
|
+
* `"mlightcad"`.
|
|
24
|
+
*
|
|
25
|
+
* Behavior:
|
|
26
|
+
* - If such a layer already exists, its name is returned and **no new layer
|
|
27
|
+
* is created**.
|
|
28
|
+
* - If no matching layer is found, a new layer is created with:
|
|
29
|
+
* - A unique name using the prefix `"$revision_"` followed by a numeric index
|
|
30
|
+
* (e.g. `$revision_1`, `$revision_2`, …)
|
|
31
|
+
* - Yellow color (ACI = 2)
|
|
32
|
+
* - Layer turned on and plottable
|
|
33
|
+
* - XData attached to mark it as an MLightCAD annotation layer
|
|
34
|
+
*
|
|
35
|
+
* XData layout:
|
|
36
|
+
* - RegApp name: `"mlightcad"`
|
|
37
|
+
* - Description (ASCII string): `"mlightcad"`
|
|
38
|
+
*
|
|
39
|
+
* The attached XData allows the annotation layer to be reliably identified even
|
|
40
|
+
* if the layer is renamed by the user.
|
|
41
|
+
*
|
|
42
|
+
* @returns The name of the existing or newly created annotation layer.
|
|
43
|
+
*/
|
|
44
|
+
AcApAnnotation.prototype.getAnnotationLayer = function () {
|
|
45
|
+
var e_1, _a;
|
|
46
|
+
var prefix = '$revision_';
|
|
47
|
+
var appId = AcDbDatabase.MLIGHTCAD_APPID;
|
|
48
|
+
var layerTable = this._database.tables.layerTable;
|
|
49
|
+
try {
|
|
50
|
+
// 1. Try to find an existing annotation layer by XData
|
|
51
|
+
for (var _b = __values(layerTable.newIterator()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
52
|
+
var layer = _c.value;
|
|
53
|
+
if (this.hasAnnotationXData(layer))
|
|
54
|
+
return layer.name;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
58
|
+
finally {
|
|
59
|
+
try {
|
|
60
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
61
|
+
}
|
|
62
|
+
finally { if (e_1) throw e_1.error; }
|
|
63
|
+
}
|
|
64
|
+
// 2. Generate a unique layer name
|
|
65
|
+
var index = 1;
|
|
66
|
+
var layerName = "".concat(prefix).concat(index);
|
|
67
|
+
while (layerTable.has(layerName)) {
|
|
68
|
+
index++;
|
|
69
|
+
layerName = "".concat(prefix).concat(index);
|
|
70
|
+
}
|
|
71
|
+
// 3. Create the layer
|
|
72
|
+
var record = new AcDbLayerTableRecord({
|
|
73
|
+
name: layerName,
|
|
74
|
+
isOff: false,
|
|
75
|
+
// Use red color as default color
|
|
76
|
+
color: new AcCmColor(AcCmColorMethod.ByACI, 1),
|
|
77
|
+
isPlottable: true
|
|
78
|
+
});
|
|
79
|
+
// 4. Attach XData
|
|
80
|
+
var xdata = new AcDbResultBuffer([
|
|
81
|
+
{ code: 1001 /* AcDbDxfCode.ExtendedDataRegAppName */, value: appId },
|
|
82
|
+
{ code: 1000 /* AcDbDxfCode.ExtendedDataAsciiString */, value: appId }
|
|
83
|
+
]);
|
|
84
|
+
record.setXData(xdata);
|
|
85
|
+
layerTable.add(record);
|
|
86
|
+
return layerName;
|
|
87
|
+
};
|
|
88
|
+
AcApAnnotation.prototype.filterAnnotationEntities = function (ids) {
|
|
89
|
+
var _this = this;
|
|
90
|
+
var layerName = this.getAnnotationLayer();
|
|
91
|
+
return ids.filter(function (id) {
|
|
92
|
+
var entity = _this._database.tables.blockTable.getEntityById(id);
|
|
93
|
+
return entity && entity.layer == layerName;
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Returns true if the specified object contains annotation xdata, which means
|
|
98
|
+
* it is only object created by annotation related commands.
|
|
99
|
+
* @param object - Object to check whether it contains annotation xdata.
|
|
100
|
+
* @returns Returns true if the specified object contains annotation xdata.
|
|
101
|
+
*/
|
|
102
|
+
AcApAnnotation.prototype.hasAnnotationXData = function (object) {
|
|
103
|
+
var e_2, _a;
|
|
104
|
+
var appId = AcDbDatabase.MLIGHTCAD_APPID;
|
|
105
|
+
var xdata = object.getXData(appId);
|
|
106
|
+
if (!xdata)
|
|
107
|
+
return false;
|
|
108
|
+
try {
|
|
109
|
+
// Look for Description string == 'mlightcad'
|
|
110
|
+
for (var xdata_1 = __values(xdata), xdata_1_1 = xdata_1.next(); !xdata_1_1.done; xdata_1_1 = xdata_1.next()) {
|
|
111
|
+
var tv = xdata_1_1.value;
|
|
112
|
+
if (tv.code === 1000 /* AcDbDxfCode.ExtendedDataAsciiString */ &&
|
|
113
|
+
tv.value === appId) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
119
|
+
finally {
|
|
120
|
+
try {
|
|
121
|
+
if (xdata_1_1 && !xdata_1_1.done && (_a = xdata_1.return)) _a.call(xdata_1);
|
|
122
|
+
}
|
|
123
|
+
finally { if (e_2) throw e_2.error; }
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Default annotation color is red
|
|
129
|
+
*/
|
|
130
|
+
AcApAnnotation.DEFAULT_ANNOTATION_COLOR = new AcCmColor(AcCmColorMethod.ByACI, 1);
|
|
131
|
+
return AcApAnnotation;
|
|
132
|
+
}());
|
|
133
|
+
export { AcApAnnotation };
|
|
134
|
+
//# sourceMappingURL=AcApAnnotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApAnnotation.js","sourceRoot":"","sources":["../../src/app/AcApAnnotation.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,YAAY,EAEZ,oBAAoB,EAGpB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;IAOE,wBAAY,EAAgB;QAC1B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;IACrB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACI,2CAAkB,GAAzB;;QACE,IAAM,MAAM,GAAG,YAAY,CAAA;QAC3B,IAAM,KAAK,GAAG,YAAY,CAAC,eAAe,CAAA;QAE1C,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAA;;YAEnD,uDAAuD;YACvD,KAAoB,IAAA,K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UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;YACjE,OAAO,MAAM,IAAI,MAAM,CAAC,KAAK,IAAI,SAAS,CAAA;QAC5C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACI,2CAAkB,GAAzB,UAA0B,MAAkB;;QAC1C,IAAM,KAAK,GAAG,YAAY,CAAC,eAAe,CAAA;QAC1C,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACpC,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAA;;YAExB,6CAA6C;YAC7C,KAAiB,IAAA,UAAA,SAAA,KAAK,CAAA,4BAAA,+CAAE,CAAC;gBAApB,IAAM,EAAE,kBAAA;gBACX,IACE,EAAE,CAAC,IAAI,mDAAwC;oBAC/C,EAAE,CAAC,KAAK,KAAK,KAAK,EAClB,CAAC;oBACD,OAAO,IAAI,CAAA;gBACb,CAAC;YACH,CAAC;;;;;;;;;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IA3GD;;OAEG;IACI,uCAAwB,GAAG,IAAI,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAyG3E,qBAAC;CAAA,AA7GD,IA6GC;SA7GY,cAAc"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { AcCmEventManager
|
|
1
|
+
import { AcCmEventManager } from '@mlightcad/data-model';
|
|
2
2
|
import { AcEdCommandStack } from '../command';
|
|
3
|
+
import { AcApPluginManager } from '../plugin/AcApPluginManager';
|
|
3
4
|
import { AcTrView2d } from '../view';
|
|
4
5
|
import { AcApContext } from './AcApContext';
|
|
5
6
|
import { AcApDocument } from './AcApDocument';
|
|
7
|
+
import { AcApOpenDatabaseOptions } from './AcDbOpenDatabaseOptions';
|
|
6
8
|
/**
|
|
7
9
|
* Event arguments for document-related events.
|
|
8
10
|
*/
|
|
@@ -80,6 +82,55 @@ export interface AcApDocManagerOptions {
|
|
|
80
82
|
* URLs for Web Worker JavaScript bundles used by the CAD viewer.
|
|
81
83
|
*/
|
|
82
84
|
webworkerFileUrls?: AcApWebworkerFiles;
|
|
85
|
+
/**
|
|
86
|
+
* Configuration for automatic plugin loading.
|
|
87
|
+
*
|
|
88
|
+
* Plugins can be loaded automatically during initialization from:
|
|
89
|
+
* - A configuration array of plugin instances or factory functions
|
|
90
|
+
* - A folder path with a list of plugin files to load
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Load plugins from configuration
|
|
95
|
+
* AcApDocManager.createInstance({
|
|
96
|
+
* plugins: {
|
|
97
|
+
* fromConfig: [
|
|
98
|
+
* new MyPlugin1(),
|
|
99
|
+
* () => new MyPlugin2()
|
|
100
|
+
* ]
|
|
101
|
+
* }
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* // Load plugins from folder
|
|
105
|
+
* AcApDocManager.createInstance({
|
|
106
|
+
* plugins: {
|
|
107
|
+
* fromFolder: {
|
|
108
|
+
* folderPath: './plugins',
|
|
109
|
+
* pluginList: ['Plugin1.js', 'Plugin2.js'],
|
|
110
|
+
* continueOnError: true
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
plugins?: {
|
|
117
|
+
/**
|
|
118
|
+
* Load plugins from a configuration array.
|
|
119
|
+
* Each item can be a plugin instance or a factory function that returns a plugin.
|
|
120
|
+
*/
|
|
121
|
+
fromConfig?: Array<import('../plugin/AcApPlugin').AcApPlugin | (() => import('../plugin/AcApPlugin').AcApPlugin)>;
|
|
122
|
+
/**
|
|
123
|
+
* Load plugins from a folder using dynamic imports.
|
|
124
|
+
*/
|
|
125
|
+
fromFolder?: {
|
|
126
|
+
/** Path to the folder containing plugin files */
|
|
127
|
+
folderPath: string;
|
|
128
|
+
/** List of plugin file names to load */
|
|
129
|
+
pluginList: string[];
|
|
130
|
+
/** Continue loading other plugins if one fails (default: false) */
|
|
131
|
+
continueOnError?: boolean;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
83
134
|
}
|
|
84
135
|
/**
|
|
85
136
|
* Document manager that handles CAD document lifecycle and provides the main entry point for the CAD viewer.
|
|
@@ -104,6 +155,8 @@ export declare class AcApDocManager {
|
|
|
104
155
|
private _progress;
|
|
105
156
|
/** Command manager */
|
|
106
157
|
private _commandManager;
|
|
158
|
+
/** Plugin manager */
|
|
159
|
+
private _pluginManager;
|
|
107
160
|
/** Singleton instance */
|
|
108
161
|
private static _instance?;
|
|
109
162
|
/** Events fired during document lifecycle */
|
|
@@ -142,9 +195,9 @@ export declare class AcApDocManager {
|
|
|
142
195
|
*/
|
|
143
196
|
static get instance(): AcApDocManager;
|
|
144
197
|
/**
|
|
145
|
-
* Destroy the view
|
|
198
|
+
* Destroy the view and unload all plugins
|
|
146
199
|
*/
|
|
147
|
-
destroy(): void
|
|
200
|
+
destroy(): Promise<void>;
|
|
148
201
|
/**
|
|
149
202
|
* Gets the current application context.
|
|
150
203
|
*
|
|
@@ -186,6 +239,12 @@ export declare class AcApDocManager {
|
|
|
186
239
|
* @returns The command manager
|
|
187
240
|
*/
|
|
188
241
|
get commandManager(): AcEdCommandStack;
|
|
242
|
+
/**
|
|
243
|
+
* Gets plugin manager to load and unload plugins
|
|
244
|
+
*
|
|
245
|
+
* @returns The plugin manager
|
|
246
|
+
*/
|
|
247
|
+
get pluginManager(): AcApPluginManager;
|
|
189
248
|
/**
|
|
190
249
|
* Base URL to load fonts
|
|
191
250
|
*/
|
|
@@ -258,7 +317,7 @@ export declare class AcApDocManager {
|
|
|
258
317
|
* }
|
|
259
318
|
* ```
|
|
260
319
|
*/
|
|
261
|
-
openUrl(url: string, options?:
|
|
320
|
+
openUrl(url: string, options?: AcApOpenDatabaseOptions): Promise<boolean>;
|
|
262
321
|
/**
|
|
263
322
|
* Opens a CAD document from file content.
|
|
264
323
|
*
|
|
@@ -277,12 +336,53 @@ export declare class AcApDocManager {
|
|
|
277
336
|
* const success = await docManager.openDocument('drawing.dwg', fileContent, options);
|
|
278
337
|
* ```
|
|
279
338
|
*/
|
|
280
|
-
openDocument(fileName: string, content: ArrayBuffer, options:
|
|
339
|
+
openDocument(fileName: string, content: ArrayBuffer, options: AcApOpenDatabaseOptions): Promise<boolean>;
|
|
281
340
|
/**
|
|
282
341
|
* Redraws the current view. Currently it is used once you modified font mapping
|
|
283
342
|
* for missed fonts so that the drawing can apply new fonts.
|
|
284
343
|
*/
|
|
285
344
|
regen(): void;
|
|
345
|
+
/**
|
|
346
|
+
* Search through all of the local and translated names in all of the command groups in the command stack
|
|
347
|
+
* starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched
|
|
348
|
+
* AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not
|
|
349
|
+
* be found. If more than one command of the same name is present in the command stack (that is, in
|
|
350
|
+
* separate command groups), then the first one found is used.
|
|
351
|
+
*
|
|
352
|
+
* The command which is compatible with the open mode of the current document is only returned
|
|
353
|
+
*
|
|
354
|
+
* @param cmdName - Input the command name to search for
|
|
355
|
+
* @returns Return the matched AcEdCommand object if a match is found and compatible with the open mode of
|
|
356
|
+
* the current document. Otherwise, return undefined.
|
|
357
|
+
*/
|
|
358
|
+
lookupLocalCmd(cmdName: string): import("../command").AcEdCommand<{}> | undefined;
|
|
359
|
+
/**
|
|
360
|
+
* Search through all of the global and untranslated names in all of the command groups in the command
|
|
361
|
+
* stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the
|
|
362
|
+
* matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command
|
|
363
|
+
* could not be found. If more than one command of the same name is present in the command stack (that
|
|
364
|
+
* is, in separate command groups), then the first one found is used.
|
|
365
|
+
*
|
|
366
|
+
* The command is only returned if it is compatible with that open mode of the current document.
|
|
367
|
+
* Higher value modes are compatible with lower value modes.
|
|
368
|
+
*
|
|
369
|
+
* @param cmdName - Input the command name to search for
|
|
370
|
+
* @returns Return the matched AcEdCommand object if a match is found and compatible with the open mode
|
|
371
|
+
* of the current document. Otherwise, return undefined.
|
|
372
|
+
*/
|
|
373
|
+
lookupGlobalCmd(cmdName: string): import("../command").AcEdCommand<{}> | undefined;
|
|
374
|
+
/**
|
|
375
|
+
* Fuzzy search for commands by prefix using the command iterator.
|
|
376
|
+
*
|
|
377
|
+
* This method iterates through all commands in all command groups and returns those
|
|
378
|
+
* whose global or local names start with the provided prefix. The search is case-insensitive.
|
|
379
|
+
* Only commands which are compatible with that open mode of the current document are returned.
|
|
380
|
+
* Higher value modes are compatible with lower value modes.
|
|
381
|
+
*
|
|
382
|
+
* @param prefix - The prefix string to search for. Case-insensitive.
|
|
383
|
+
* @returns An array of objects containing matched commands and their corresponding group names.
|
|
384
|
+
*/
|
|
385
|
+
searchCommandsByPrefix(prefix: string): import("../editor/command/AcEdCommandIterator").AcEdCommandIteratorItem[];
|
|
286
386
|
/**
|
|
287
387
|
* Registers all default commands available in the CAD viewer.
|
|
288
388
|
*
|
|
@@ -303,9 +403,11 @@ export declare class AcApDocManager {
|
|
|
303
403
|
* Executes a command by its string name.
|
|
304
404
|
*
|
|
305
405
|
* This method looks up a registered command by name and executes it with the current context.
|
|
306
|
-
*
|
|
406
|
+
* It checks if the command's required mode is compatible with the document's current mode.
|
|
407
|
+
* If the command is not found or not compatible, an error is thrown.
|
|
307
408
|
*
|
|
308
409
|
* @param cmdStr - The command string to execute (e.g., 'pan', 'zoom', 'select')
|
|
410
|
+
* @throws {Error} If the command is not found or if the command's mode is not compatible with the document's mode
|
|
309
411
|
*
|
|
310
412
|
* @example
|
|
311
413
|
* ```typescript
|
|
@@ -383,5 +485,15 @@ export declare class AcApDocManager {
|
|
|
383
485
|
* initialization are handled inside the respective registration routines.
|
|
384
486
|
*/
|
|
385
487
|
private registerWorkers;
|
|
488
|
+
/**
|
|
489
|
+
* Loads plugins automatically based on the provided configuration.
|
|
490
|
+
*
|
|
491
|
+
* This method is called during initialization if plugins are configured.
|
|
492
|
+
* It supports loading from both configuration arrays and folder paths.
|
|
493
|
+
*
|
|
494
|
+
* @param pluginsConfig - Plugin loading configuration
|
|
495
|
+
* @private
|
|
496
|
+
*/
|
|
497
|
+
private loadPlugins;
|
|
386
498
|
}
|
|
387
499
|
//# sourceMappingURL=AcApDocManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcApDocManager.d.ts","sourceRoot":"","sources":["../../src/app/AcApDocManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"AcApDocManager.d.ts","sourceRoot":"","sources":["../../src/app/AcApDocManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAQjB,MAAM,uBAAuB,CAAA;AAI9B,OAAO,EAsBL,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAInE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yCAAyC;IACzC,GAAG,EAAE,YAAY,CAAA;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;IAExB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;IAExB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAC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;IAMf;;;;;;;OAOG;IACH,SAAS,CAAC,oBAAoB;IAI9B;;;;;;;;;OASG;IACH,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO;IAgBhD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,UAAU;IASlB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAmBtB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,kBAAkB;IAsC1B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;;;OAQG;YACW,WAAW;CA8D1B"}
|
|
@@ -37,9 +37,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { AcCmEventManager, AcDbDatabaseConverterManager, AcDbDxfConverter, AcDbFileType, acdbHostApplicationServices, AcDbSysVarManager, AcGeBox2d } from '@mlightcad/data-model';
|
|
38
38
|
import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter';
|
|
39
39
|
import { AcTrMTextRenderer } from '@mlightcad/three-renderer';
|
|
40
|
-
import { AcApCircleCmd, AcApConvertToSvgCmd, AcApDimLinearCmd, AcApEraseCmd, AcApLineCmd, AcApLogCmd, AcApOpenCmd, AcApPanCmd, AcApQNewCmd, AcApRegenCmd, AcApSelectCmd, AcApSysVarCmd, AcApZoomCmd, AcApZoomToBoxCmd, AcEdCommandStack } from '../command';
|
|
41
|
-
import { eventBus } from '../editor';
|
|
40
|
+
import { AcApCircleCmd, AcApConvertToSvgCmd, AcApDimLinearCmd, AcApEraseCmd, AcApLineCmd, AcApLogCmd, AcApOpenCmd, AcApPanCmd, AcApQNewCmd, AcApRectCmd, AcApRegenCmd, AcApRevCircleCmd, AcApRevCloudCmd, AcApRevRectCmd, AcApRevVisibilityCmd, AcApSelectCmd, AcApSketchCmd, AcApSwitchBgCmd, AcApSysVarCmd, AcApZoomCmd, AcApZoomToBoxCmd, AcEdCommandStack } from '../command';
|
|
41
|
+
import { AcEdOpenMode, eventBus } from '../editor';
|
|
42
42
|
import { AcApI18n } from '../i18n';
|
|
43
|
+
import { AcApPluginManager } from '../plugin/AcApPluginManager';
|
|
43
44
|
import { AcTrView2d } from '../view';
|
|
44
45
|
import { AcApContext } from './AcApContext';
|
|
45
46
|
import { AcApDocument } from './AcApDocument';
|
|
@@ -136,12 +137,17 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
136
137
|
acdbHostApplicationServices().workingDatabase = doc.database;
|
|
137
138
|
this._commandManager = new AcEdCommandStack();
|
|
138
139
|
this.registerCommands();
|
|
140
|
+
this._pluginManager = new AcApPluginManager(this._context, this._commandManager);
|
|
139
141
|
this._progress = new AcApProgress();
|
|
140
142
|
this._progress.hide();
|
|
141
143
|
if (!options.notLoadDefaultFonts) {
|
|
142
144
|
this.loadDefaultFonts();
|
|
143
145
|
}
|
|
144
146
|
this.registerWorkers(options.webworkerFileUrls);
|
|
147
|
+
// Load plugins asynchronously (don't await to avoid blocking initialization)
|
|
148
|
+
this.loadPlugins(options.plugins).catch(function (error) {
|
|
149
|
+
console.error('[AcApDocManager] Error loading plugins:', error);
|
|
150
|
+
});
|
|
145
151
|
}
|
|
146
152
|
/**
|
|
147
153
|
* Creates the singleton instance with an optional canvas element.
|
|
@@ -177,10 +183,20 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
177
183
|
configurable: true
|
|
178
184
|
});
|
|
179
185
|
/**
|
|
180
|
-
* Destroy the view
|
|
186
|
+
* Destroy the view and unload all plugins
|
|
181
187
|
*/
|
|
182
188
|
AcApDocManager.prototype.destroy = function () {
|
|
183
|
-
|
|
189
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0: return [4 /*yield*/, this._pluginManager.unloadAllPlugins()];
|
|
193
|
+
case 1:
|
|
194
|
+
_a.sent();
|
|
195
|
+
AcApDocManager._instance = undefined;
|
|
196
|
+
return [2 /*return*/];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
184
200
|
};
|
|
185
201
|
Object.defineProperty(AcApDocManager.prototype, "context", {
|
|
186
202
|
/**
|
|
@@ -259,6 +275,18 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
259
275
|
enumerable: false,
|
|
260
276
|
configurable: true
|
|
261
277
|
});
|
|
278
|
+
Object.defineProperty(AcApDocManager.prototype, "pluginManager", {
|
|
279
|
+
/**
|
|
280
|
+
* Gets plugin manager to load and unload plugins
|
|
281
|
+
*
|
|
282
|
+
* @returns The plugin manager
|
|
283
|
+
*/
|
|
284
|
+
get: function () {
|
|
285
|
+
return this._pluginManager;
|
|
286
|
+
},
|
|
287
|
+
enumerable: false,
|
|
288
|
+
configurable: true
|
|
289
|
+
});
|
|
262
290
|
Object.defineProperty(AcApDocManager.prototype, "baseUrl", {
|
|
263
291
|
/**
|
|
264
292
|
* Base URL to load fonts
|
|
@@ -432,6 +460,53 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
432
460
|
this.curView.clear();
|
|
433
461
|
this.context.doc.database.regen();
|
|
434
462
|
};
|
|
463
|
+
/**
|
|
464
|
+
* Search through all of the local and translated names in all of the command groups in the command stack
|
|
465
|
+
* starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched
|
|
466
|
+
* AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not
|
|
467
|
+
* be found. If more than one command of the same name is present in the command stack (that is, in
|
|
468
|
+
* separate command groups), then the first one found is used.
|
|
469
|
+
*
|
|
470
|
+
* The command which is compatible with the open mode of the current document is only returned
|
|
471
|
+
*
|
|
472
|
+
* @param cmdName - Input the command name to search for
|
|
473
|
+
* @returns Return the matched AcEdCommand object if a match is found and compatible with the open mode of
|
|
474
|
+
* the current document. Otherwise, return undefined.
|
|
475
|
+
*/
|
|
476
|
+
AcApDocManager.prototype.lookupLocalCmd = function (cmdName) {
|
|
477
|
+
return this._commandManager.lookupLocalCmd(cmdName, this.curDocument.openMode);
|
|
478
|
+
};
|
|
479
|
+
/**
|
|
480
|
+
* Search through all of the global and untranslated names in all of the command groups in the command
|
|
481
|
+
* stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the
|
|
482
|
+
* matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command
|
|
483
|
+
* could not be found. If more than one command of the same name is present in the command stack (that
|
|
484
|
+
* is, in separate command groups), then the first one found is used.
|
|
485
|
+
*
|
|
486
|
+
* The command is only returned if it is compatible with that open mode of the current document.
|
|
487
|
+
* Higher value modes are compatible with lower value modes.
|
|
488
|
+
*
|
|
489
|
+
* @param cmdName - Input the command name to search for
|
|
490
|
+
* @returns Return the matched AcEdCommand object if a match is found and compatible with the open mode
|
|
491
|
+
* of the current document. Otherwise, return undefined.
|
|
492
|
+
*/
|
|
493
|
+
AcApDocManager.prototype.lookupGlobalCmd = function (cmdName) {
|
|
494
|
+
return this._commandManager.lookupGlobalCmd(cmdName, this.curDocument.openMode);
|
|
495
|
+
};
|
|
496
|
+
/**
|
|
497
|
+
* Fuzzy search for commands by prefix using the command iterator.
|
|
498
|
+
*
|
|
499
|
+
* This method iterates through all commands in all command groups and returns those
|
|
500
|
+
* whose global or local names start with the provided prefix. The search is case-insensitive.
|
|
501
|
+
* Only commands which are compatible with that open mode of the current document are returned.
|
|
502
|
+
* Higher value modes are compatible with lower value modes.
|
|
503
|
+
*
|
|
504
|
+
* @param prefix - The prefix string to search for. Case-insensitive.
|
|
505
|
+
* @returns An array of objects containing matched commands and their corresponding group names.
|
|
506
|
+
*/
|
|
507
|
+
AcApDocManager.prototype.searchCommandsByPrefix = function (prefix) {
|
|
508
|
+
return this._commandManager.searchCommandsByPrefix(prefix, this.curDocument.openMode);
|
|
509
|
+
};
|
|
435
510
|
/**
|
|
436
511
|
* Registers all default commands available in the CAD viewer.
|
|
437
512
|
*
|
|
@@ -458,8 +533,15 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
458
533
|
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'open', 'open', new AcApOpenCmd());
|
|
459
534
|
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'pan', 'pan', new AcApPanCmd());
|
|
460
535
|
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'qnew', 'qnew', new AcApQNewCmd());
|
|
536
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'rectangle', 'rectangle', new AcApRectCmd());
|
|
461
537
|
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'regen', 'regen', new AcApRegenCmd());
|
|
538
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'revcircle', 'revcircle', new AcApRevCircleCmd());
|
|
539
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'revcloud', 'revcloud', new AcApRevCloudCmd());
|
|
540
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'revrect', 'revrect', new AcApRevRectCmd());
|
|
541
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'revvis', 'revvis', new AcApRevVisibilityCmd());
|
|
462
542
|
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'select', 'select', new AcApSelectCmd());
|
|
543
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'sketch', 'sketch', new AcApSketchCmd());
|
|
544
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'switchbg', 'switchbg', new AcApSwitchBgCmd());
|
|
463
545
|
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'zoom', 'zoom', new AcApZoomCmd());
|
|
464
546
|
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'zoomw', 'zoomw', new AcApZoomToBoxCmd());
|
|
465
547
|
// Register system variables as commands
|
|
@@ -472,9 +554,11 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
472
554
|
* Executes a command by its string name.
|
|
473
555
|
*
|
|
474
556
|
* This method looks up a registered command by name and executes it with the current context.
|
|
475
|
-
*
|
|
557
|
+
* It checks if the command's required mode is compatible with the document's current mode.
|
|
558
|
+
* If the command is not found or not compatible, an error is thrown.
|
|
476
559
|
*
|
|
477
560
|
* @param cmdStr - The command string to execute (e.g., 'pan', 'zoom', 'select')
|
|
561
|
+
* @throws {Error} If the command is not found or if the command's mode is not compatible with the document's mode
|
|
478
562
|
*
|
|
479
563
|
* @example
|
|
480
564
|
* ```typescript
|
|
@@ -483,8 +567,16 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
483
567
|
* ```
|
|
484
568
|
*/
|
|
485
569
|
AcApDocManager.prototype.sendStringToExecute = function (cmdStr) {
|
|
570
|
+
var documentMode = this.context.doc.openMode;
|
|
486
571
|
var cmd = this._commandManager.lookupGlobalCmd(cmdStr);
|
|
487
|
-
|
|
572
|
+
if (!cmd) {
|
|
573
|
+
throw new Error("Command '".concat(cmdStr, "' not found"));
|
|
574
|
+
}
|
|
575
|
+
// Check mode compatibility: document mode must be >= command mode
|
|
576
|
+
if (documentMode < cmd.mode) {
|
|
577
|
+
throw new Error("Command '".concat(cmdStr, "' requires mode '").concat(AcEdOpenMode[cmd.mode], "' but document is in mode '").concat(AcEdOpenMode[documentMode], "'!"));
|
|
578
|
+
}
|
|
579
|
+
cmd.trigger(this.context);
|
|
488
580
|
};
|
|
489
581
|
/**
|
|
490
582
|
* Configures layout information for the current view.
|
|
@@ -634,6 +726,70 @@ var AcApDocManager = /** @class */ (function () {
|
|
|
634
726
|
? webworkerFileUrls.mtextRender
|
|
635
727
|
: './assets/mtext-renderer-worker.js');
|
|
636
728
|
};
|
|
729
|
+
/**
|
|
730
|
+
* Loads plugins automatically based on the provided configuration.
|
|
731
|
+
*
|
|
732
|
+
* This method is called during initialization if plugins are configured.
|
|
733
|
+
* It supports loading from both configuration arrays and folder paths.
|
|
734
|
+
*
|
|
735
|
+
* @param pluginsConfig - Plugin loading configuration
|
|
736
|
+
* @private
|
|
737
|
+
*/
|
|
738
|
+
AcApDocManager.prototype.loadPlugins = function (pluginsConfig) {
|
|
739
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
740
|
+
var result, error_1, result, error_2;
|
|
741
|
+
var _a;
|
|
742
|
+
return __generator(this, function (_b) {
|
|
743
|
+
switch (_b.label) {
|
|
744
|
+
case 0:
|
|
745
|
+
if (!pluginsConfig) {
|
|
746
|
+
return [2 /*return*/];
|
|
747
|
+
}
|
|
748
|
+
if (!(pluginsConfig.fromConfig && pluginsConfig.fromConfig.length > 0)) return [3 /*break*/, 4];
|
|
749
|
+
_b.label = 1;
|
|
750
|
+
case 1:
|
|
751
|
+
_b.trys.push([1, 3, , 4]);
|
|
752
|
+
return [4 /*yield*/, this._pluginManager.loadPluginsFromConfig(pluginsConfig.fromConfig, { continueOnError: true })];
|
|
753
|
+
case 2:
|
|
754
|
+
result = _b.sent();
|
|
755
|
+
if (result.loaded.length > 0) {
|
|
756
|
+
console.log("[AcApDocManager] Loaded ".concat(result.loaded.length, " plugin(s) from config:"), result.loaded);
|
|
757
|
+
}
|
|
758
|
+
if (result.failed.length > 0) {
|
|
759
|
+
console.warn("[AcApDocManager] Failed to load ".concat(result.failed.length, " plugin(s):"), result.failed.map(function (f) { return "".concat(f.name, ": ").concat(f.error.message); }));
|
|
760
|
+
}
|
|
761
|
+
return [3 /*break*/, 4];
|
|
762
|
+
case 3:
|
|
763
|
+
error_1 = _b.sent();
|
|
764
|
+
console.error('[AcApDocManager] Error loading plugins from config:', error_1);
|
|
765
|
+
return [3 /*break*/, 4];
|
|
766
|
+
case 4:
|
|
767
|
+
if (!pluginsConfig.fromFolder) return [3 /*break*/, 8];
|
|
768
|
+
_b.label = 5;
|
|
769
|
+
case 5:
|
|
770
|
+
_b.trys.push([5, 7, , 8]);
|
|
771
|
+
return [4 /*yield*/, this._pluginManager.loadPluginsFromFolder(pluginsConfig.fromFolder.folderPath, {
|
|
772
|
+
pluginList: pluginsConfig.fromFolder.pluginList,
|
|
773
|
+
continueOnError: (_a = pluginsConfig.fromFolder.continueOnError) !== null && _a !== void 0 ? _a : true
|
|
774
|
+
})];
|
|
775
|
+
case 6:
|
|
776
|
+
result = _b.sent();
|
|
777
|
+
if (result.loaded.length > 0) {
|
|
778
|
+
console.log("[AcApDocManager] Loaded ".concat(result.loaded.length, " plugin(s) from folder:"), result.loaded);
|
|
779
|
+
}
|
|
780
|
+
if (result.failed.length > 0) {
|
|
781
|
+
console.warn("[AcApDocManager] Failed to load ".concat(result.failed.length, " plugin(s) from folder:"), result.failed.map(function (f) { return "".concat(f.name, ": ").concat(f.error.message); }));
|
|
782
|
+
}
|
|
783
|
+
return [3 /*break*/, 8];
|
|
784
|
+
case 7:
|
|
785
|
+
error_2 = _b.sent();
|
|
786
|
+
console.error('[AcApDocManager] Error loading plugins from folder:', error_2);
|
|
787
|
+
return [3 /*break*/, 8];
|
|
788
|
+
case 8: return [2 /*return*/];
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
});
|
|
792
|
+
};
|
|
637
793
|
return AcApDocManager;
|
|
638
794
|
}());
|
|
639
795
|
export { AcApDocManager };
|