@mlightcad/cad-pdf-plugin 1.5.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.
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/AcApPdfPlugin-CXWCd8bg.js +34 -0
- package/dist/html2canvas.esm-d2sM-0Wm.js +4870 -0
- package/dist/index-DNe5YnrC.js +30983 -0
- package/dist/index.es-DxTvd7sT.js +5645 -0
- package/dist/index.js +11 -0
- package/dist/index.umd.cjs +312 -0
- package/dist/purify.es-CxNDhYDZ.js +663 -0
- package/lib/AcApConvertToPdfCmd.d.ts +14 -0
- package/lib/AcApConvertToPdfCmd.d.ts.map +1 -0
- package/lib/AcApConvertToPdfCmd.js +86 -0
- package/lib/AcApConvertToPdfCmd.js.map +1 -0
- package/lib/AcApImportPdfCmd.d.ts +14 -0
- package/lib/AcApImportPdfCmd.d.ts.map +1 -0
- package/lib/AcApImportPdfCmd.js +81 -0
- package/lib/AcApImportPdfCmd.js.map +1 -0
- package/lib/AcApPdfConvertor.d.ts +17 -0
- package/lib/AcApPdfConvertor.d.ts.map +1 -0
- package/lib/AcApPdfConvertor.js +155 -0
- package/lib/AcApPdfConvertor.js.map +1 -0
- package/lib/AcApPdfImportConvertor.d.ts +23 -0
- package/lib/AcApPdfImportConvertor.d.ts.map +1 -0
- package/lib/AcApPdfImportConvertor.js +363 -0
- package/lib/AcApPdfImportConvertor.js.map +1 -0
- package/lib/AcApPdfPlugin.d.ts +32 -0
- package/lib/AcApPdfPlugin.d.ts.map +1 -0
- package/lib/AcApPdfPlugin.js +70 -0
- package/lib/AcApPdfPlugin.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/registerLazyPdfPlugin.d.ts +25 -0
- package/lib/registerLazyPdfPlugin.d.ts.map +1 -0
- package/lib/registerLazyPdfPlugin.js +103 -0
- package/lib/registerLazyPdfPlugin.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
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);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __values = (this && this.__values) || function(o) {
|
|
49
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
50
|
+
if (m) return m.call(o);
|
|
51
|
+
if (o && typeof o.length === "number") return {
|
|
52
|
+
next: function () {
|
|
53
|
+
if (o && i >= o.length) o = void 0;
|
|
54
|
+
return { value: o && o[i++], done: !o };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
58
|
+
};
|
|
59
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
60
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
61
|
+
if (!m) return o;
|
|
62
|
+
var i = m.call(o), r, ar = [], e;
|
|
63
|
+
try {
|
|
64
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
65
|
+
}
|
|
66
|
+
catch (error) { e = { error: error }; }
|
|
67
|
+
finally {
|
|
68
|
+
try {
|
|
69
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
70
|
+
}
|
|
71
|
+
finally { if (e) throw e.error; }
|
|
72
|
+
}
|
|
73
|
+
return ar;
|
|
74
|
+
};
|
|
75
|
+
import { AcDbLine, AcDbPolyline, AcGePoint2d, AcGePoint3d, log } from '@mlightcad/data-model';
|
|
76
|
+
import * as pdfjsLib from 'pdfjs-dist';
|
|
77
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = '';
|
|
78
|
+
/** 1 PDF point in mm (1 pt = 1/72 inch = 25.4/72 mm) */
|
|
79
|
+
var PT_TO_MM = 25.4 / 72;
|
|
80
|
+
/** Bezier approximation resolution (line segments per curve) */
|
|
81
|
+
var BEZIER_STEPS = 8;
|
|
82
|
+
/**
|
|
83
|
+
* Converts a PDF file into CAD entities appended to the current document's
|
|
84
|
+
* model space.
|
|
85
|
+
*/
|
|
86
|
+
var AcApPdfImportConvertor = /** @class */ (function () {
|
|
87
|
+
function AcApPdfImportConvertor() {
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Prompts the user to pick a PDF file and imports vector geometry.
|
|
91
|
+
*
|
|
92
|
+
* @param context - Application context for the target document
|
|
93
|
+
*/
|
|
94
|
+
AcApPdfImportConvertor.prototype.importFromFilePicker = function (context) {
|
|
95
|
+
var _this = this;
|
|
96
|
+
var input = document.createElement('input');
|
|
97
|
+
input.type = 'file';
|
|
98
|
+
input.accept = '.pdf';
|
|
99
|
+
input.style.display = 'none';
|
|
100
|
+
document.body.appendChild(input);
|
|
101
|
+
input.addEventListener('change', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
102
|
+
var file, buffer;
|
|
103
|
+
var _a;
|
|
104
|
+
return __generator(this, function (_b) {
|
|
105
|
+
switch (_b.label) {
|
|
106
|
+
case 0:
|
|
107
|
+
file = (_a = input.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
108
|
+
document.body.removeChild(input);
|
|
109
|
+
if (!file)
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
return [4 /*yield*/, file.arrayBuffer()];
|
|
112
|
+
case 1:
|
|
113
|
+
buffer = _b.sent();
|
|
114
|
+
return [4 /*yield*/, this.convert(context, buffer)];
|
|
115
|
+
case 2:
|
|
116
|
+
_b.sent();
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); });
|
|
121
|
+
input.click();
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Converts the first page of a PDF ArrayBuffer into CAD entities.
|
|
125
|
+
* @param context - Application context for the target document
|
|
126
|
+
* @param data - Raw PDF bytes
|
|
127
|
+
* @param pageNumber - 1-based page number (default: 1)
|
|
128
|
+
*/
|
|
129
|
+
AcApPdfImportConvertor.prototype.convert = function (context_1, data_1) {
|
|
130
|
+
return __awaiter(this, arguments, void 0, function (context, data, pageNumber) {
|
|
131
|
+
var pdf, page, viewport, pageHeight, operatorList, entities, modelSpace, entities_1, entities_1_1, entity, err_1;
|
|
132
|
+
var e_1, _a;
|
|
133
|
+
if (pageNumber === void 0) { pageNumber = 1; }
|
|
134
|
+
return __generator(this, function (_b) {
|
|
135
|
+
switch (_b.label) {
|
|
136
|
+
case 0:
|
|
137
|
+
_b.trys.push([0, 4, , 5]);
|
|
138
|
+
return [4 /*yield*/, pdfjsLib.getDocument({ data: data }).promise];
|
|
139
|
+
case 1:
|
|
140
|
+
pdf = _b.sent();
|
|
141
|
+
return [4 /*yield*/, pdf.getPage(pageNumber)];
|
|
142
|
+
case 2:
|
|
143
|
+
page = _b.sent();
|
|
144
|
+
viewport = page.getViewport({ scale: 1 });
|
|
145
|
+
pageHeight = viewport.height;
|
|
146
|
+
return [4 /*yield*/, page.getOperatorList()];
|
|
147
|
+
case 3:
|
|
148
|
+
operatorList = _b.sent();
|
|
149
|
+
entities = this.extractEntities(operatorList, pageHeight);
|
|
150
|
+
if (entities.length === 0) {
|
|
151
|
+
log.warn('[PdfImport] No vector paths found in PDF page.');
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
modelSpace = context.doc.database.tables.blockTable.modelSpace;
|
|
155
|
+
try {
|
|
156
|
+
for (entities_1 = __values(entities), entities_1_1 = entities_1.next(); !entities_1_1.done; entities_1_1 = entities_1.next()) {
|
|
157
|
+
entity = entities_1_1.value;
|
|
158
|
+
modelSpace.appendEntity(entity);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
162
|
+
finally {
|
|
163
|
+
try {
|
|
164
|
+
if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
|
|
165
|
+
}
|
|
166
|
+
finally { if (e_1) throw e_1.error; }
|
|
167
|
+
}
|
|
168
|
+
log.info("[PdfImport] Imported ".concat(entities.length, " entities from PDF."));
|
|
169
|
+
return [3 /*break*/, 5];
|
|
170
|
+
case 4:
|
|
171
|
+
err_1 = _b.sent();
|
|
172
|
+
log.error('[PdfImport] Failed to import PDF:', err_1);
|
|
173
|
+
return [3 /*break*/, 5];
|
|
174
|
+
case 5: return [2 /*return*/];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
AcApPdfImportConvertor.prototype.extractEntities = function (opList, pageHeight) {
|
|
180
|
+
var e_2, _a, e_3, _b, e_4, _c;
|
|
181
|
+
var _this = this;
|
|
182
|
+
var OPS = pdfjsLib.OPS;
|
|
183
|
+
var fnArray = opList.fnArray, argsArray = opList.argsArray;
|
|
184
|
+
var result = [];
|
|
185
|
+
var subpaths = [];
|
|
186
|
+
var current = [];
|
|
187
|
+
var curX = 0;
|
|
188
|
+
var curY = 0;
|
|
189
|
+
var flush = function () {
|
|
190
|
+
if (current.length > 1)
|
|
191
|
+
subpaths.push(current);
|
|
192
|
+
current = [];
|
|
193
|
+
};
|
|
194
|
+
var commit = function () {
|
|
195
|
+
var e_5, _a;
|
|
196
|
+
flush();
|
|
197
|
+
try {
|
|
198
|
+
for (var subpaths_1 = __values(subpaths), subpaths_1_1 = subpaths_1.next(); !subpaths_1_1.done; subpaths_1_1 = subpaths_1.next()) {
|
|
199
|
+
var sp = subpaths_1_1.value;
|
|
200
|
+
var entity = _this.subpathToEntity(sp);
|
|
201
|
+
if (entity)
|
|
202
|
+
result.push(entity);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
206
|
+
finally {
|
|
207
|
+
try {
|
|
208
|
+
if (subpaths_1_1 && !subpaths_1_1.done && (_a = subpaths_1.return)) _a.call(subpaths_1);
|
|
209
|
+
}
|
|
210
|
+
finally { if (e_5) throw e_5.error; }
|
|
211
|
+
}
|
|
212
|
+
subpaths = [];
|
|
213
|
+
};
|
|
214
|
+
var tx = function (x, _y) { return x * PT_TO_MM; };
|
|
215
|
+
var ty = function (_x, y) { return (pageHeight - y) * PT_TO_MM; };
|
|
216
|
+
for (var i = 0; i < fnArray.length; i++) {
|
|
217
|
+
var fn = fnArray[i];
|
|
218
|
+
var args = argsArray[i];
|
|
219
|
+
switch (fn) {
|
|
220
|
+
case OPS.moveTo: {
|
|
221
|
+
flush();
|
|
222
|
+
curX = args[0];
|
|
223
|
+
curY = args[1];
|
|
224
|
+
current = [{ x: tx(curX, curY), y: ty(curX, curY) }];
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case OPS.lineTo: {
|
|
228
|
+
curX = args[0];
|
|
229
|
+
curY = args[1];
|
|
230
|
+
current.push({ x: tx(curX, curY), y: ty(curX, curY) });
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
case OPS.curveTo: {
|
|
234
|
+
var _d = __read(args, 6), x1 = _d[0], y1 = _d[1], x2 = _d[2], y2 = _d[3], x3 = _d[4], y3 = _d[5];
|
|
235
|
+
var pts = cubicBezier({ x: curX, y: curY }, { x: x1, y: y1 }, { x: x2, y: y2 }, { x: x3, y: y3 }, BEZIER_STEPS);
|
|
236
|
+
try {
|
|
237
|
+
for (var pts_1 = (e_2 = void 0, __values(pts)), pts_1_1 = pts_1.next(); !pts_1_1.done; pts_1_1 = pts_1.next()) {
|
|
238
|
+
var p = pts_1_1.value;
|
|
239
|
+
current.push({ x: tx(p.x, p.y), y: ty(p.x, p.y) });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
243
|
+
finally {
|
|
244
|
+
try {
|
|
245
|
+
if (pts_1_1 && !pts_1_1.done && (_a = pts_1.return)) _a.call(pts_1);
|
|
246
|
+
}
|
|
247
|
+
finally { if (e_2) throw e_2.error; }
|
|
248
|
+
}
|
|
249
|
+
curX = x3;
|
|
250
|
+
curY = y3;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case OPS.curveTo2: {
|
|
254
|
+
var _e = __read(args, 4), x2 = _e[0], y2 = _e[1], x3 = _e[2], y3 = _e[3];
|
|
255
|
+
var pts = cubicBezier({ x: curX, y: curY }, { x: curX, y: curY }, { x: x2, y: y2 }, { x: x3, y: y3 }, BEZIER_STEPS);
|
|
256
|
+
try {
|
|
257
|
+
for (var pts_2 = (e_3 = void 0, __values(pts)), pts_2_1 = pts_2.next(); !pts_2_1.done; pts_2_1 = pts_2.next()) {
|
|
258
|
+
var p = pts_2_1.value;
|
|
259
|
+
current.push({ x: tx(p.x, p.y), y: ty(p.x, p.y) });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
263
|
+
finally {
|
|
264
|
+
try {
|
|
265
|
+
if (pts_2_1 && !pts_2_1.done && (_b = pts_2.return)) _b.call(pts_2);
|
|
266
|
+
}
|
|
267
|
+
finally { if (e_3) throw e_3.error; }
|
|
268
|
+
}
|
|
269
|
+
curX = x3;
|
|
270
|
+
curY = y3;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
case OPS.curveTo3: {
|
|
274
|
+
var _f = __read(args, 4), x1 = _f[0], y1 = _f[1], x3 = _f[2], y3 = _f[3];
|
|
275
|
+
var pts = cubicBezier({ x: curX, y: curY }, { x: x1, y: y1 }, { x: x3, y: y3 }, { x: x3, y: y3 }, BEZIER_STEPS);
|
|
276
|
+
try {
|
|
277
|
+
for (var pts_3 = (e_4 = void 0, __values(pts)), pts_3_1 = pts_3.next(); !pts_3_1.done; pts_3_1 = pts_3.next()) {
|
|
278
|
+
var p = pts_3_1.value;
|
|
279
|
+
current.push({ x: tx(p.x, p.y), y: ty(p.x, p.y) });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
283
|
+
finally {
|
|
284
|
+
try {
|
|
285
|
+
if (pts_3_1 && !pts_3_1.done && (_c = pts_3.return)) _c.call(pts_3);
|
|
286
|
+
}
|
|
287
|
+
finally { if (e_4) throw e_4.error; }
|
|
288
|
+
}
|
|
289
|
+
curX = x3;
|
|
290
|
+
curY = y3;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case OPS.closePath: {
|
|
294
|
+
if (current.length > 0 && subpaths.length === 0) {
|
|
295
|
+
current.push(__assign({}, current[0]));
|
|
296
|
+
}
|
|
297
|
+
flush();
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case OPS.stroke:
|
|
301
|
+
case OPS.fill:
|
|
302
|
+
case OPS.eoFill:
|
|
303
|
+
case OPS.fillStroke:
|
|
304
|
+
case OPS.eoFillStroke:
|
|
305
|
+
case OPS.endPath: {
|
|
306
|
+
commit();
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
commit();
|
|
312
|
+
return result;
|
|
313
|
+
};
|
|
314
|
+
AcApPdfImportConvertor.prototype.subpathToEntity = function (pts) {
|
|
315
|
+
if (pts.length < 2)
|
|
316
|
+
return null;
|
|
317
|
+
if (pts.length === 2) {
|
|
318
|
+
return new AcDbLine(new AcGePoint3d(pts[0].x, pts[0].y, 0), new AcGePoint3d(pts[1].x, pts[1].y, 0));
|
|
319
|
+
}
|
|
320
|
+
var poly = new AcDbPolyline();
|
|
321
|
+
for (var i = 0; i < pts.length; i++) {
|
|
322
|
+
poly.addVertexAt(i, new AcGePoint2d(pts[i].x, pts[i].y));
|
|
323
|
+
}
|
|
324
|
+
var first = pts[0];
|
|
325
|
+
var last = pts[pts.length - 1];
|
|
326
|
+
var dx = first.x - last.x;
|
|
327
|
+
var dy = first.y - last.y;
|
|
328
|
+
if (Math.sqrt(dx * dx + dy * dy) < 1e-6) {
|
|
329
|
+
poly.closed = true;
|
|
330
|
+
}
|
|
331
|
+
return poly;
|
|
332
|
+
};
|
|
333
|
+
return AcApPdfImportConvertor;
|
|
334
|
+
}());
|
|
335
|
+
export { AcApPdfImportConvertor };
|
|
336
|
+
/**
|
|
337
|
+
* Approximates a cubic Bézier curve as a polyline.
|
|
338
|
+
*
|
|
339
|
+
* @param p0 - Start point
|
|
340
|
+
* @param p1 - First control point
|
|
341
|
+
* @param p2 - Second control point
|
|
342
|
+
* @param p3 - End point
|
|
343
|
+
* @param steps - Number of line segments to generate
|
|
344
|
+
* @returns Sampled points along the curve (excluding `p0`)
|
|
345
|
+
*/
|
|
346
|
+
function cubicBezier(p0, p1, p2, p3, steps) {
|
|
347
|
+
var pts = [];
|
|
348
|
+
for (var i = 1; i <= steps; i++) {
|
|
349
|
+
var t = i / steps;
|
|
350
|
+
var mt = 1 - t;
|
|
351
|
+
var x = mt * mt * mt * p0.x +
|
|
352
|
+
3 * mt * mt * t * p1.x +
|
|
353
|
+
3 * mt * t * t * p2.x +
|
|
354
|
+
t * t * t * p3.x;
|
|
355
|
+
var y = mt * mt * mt * p0.y +
|
|
356
|
+
3 * mt * mt * t * p1.y +
|
|
357
|
+
3 * mt * t * t * p2.y +
|
|
358
|
+
t * t * t * p3.y;
|
|
359
|
+
pts.push({ x: x, y: y });
|
|
360
|
+
}
|
|
361
|
+
return pts;
|
|
362
|
+
}
|
|
363
|
+
//# sourceMappingURL=AcApPdfImportConvertor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfImportConvertor.js","sourceRoot":"","sources":["../src/AcApPdfImportConvertor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,WAAW,EACX,GAAG,EACJ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AAGtC,QAAQ,CAAC,mBAAmB,CAAC,SAAS,GAAG,EAAE,CAAA;AAE3C,wDAAwD;AACxD,IAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAA;AAE1B,gEAAgE;AAChE,IAAM,YAAY,GAAG,CAAC,CAAA;AAKtB;;;GAGG;AACH;IAAA;IAyMA,CAAC;IAxMC;;;;OAIG;IACH,qDAAoB,GAApB,UAAqB,OAAoB;QAAzC,iBAgBC;QAfC,IAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC7C,KAAK,CAAC,IAAI,GAAG,MAAM,CAAA;QACnB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;QACrB,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA;QAC5B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAEhC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE;;;;;;wBACzB,IAAI,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CAAC;YACrB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAClB,IAAM,CAAC,GACL,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;YACnB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACtB,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YACrB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAClB,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAA,EAAE,CAAC,GAAA,EAAE,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AcApContext, AcApPlugin, AcEdCommandStack } from '@mlightcad/cad-simple-viewer';
|
|
2
|
+
/**
|
|
3
|
+
* PDF export/import plugin for cad-simple-viewer.
|
|
4
|
+
*
|
|
5
|
+
* Registers `cpdf` and `ipdf` commands when loaded. Register this plugin
|
|
6
|
+
* lazily via {@link registerLazyPdfPlugin} so PDF libraries are fetched on demand.
|
|
7
|
+
*/
|
|
8
|
+
export declare class AcApPdfPlugin implements AcApPlugin {
|
|
9
|
+
/** @inheritdoc */
|
|
10
|
+
name: string;
|
|
11
|
+
/** @inheritdoc */
|
|
12
|
+
version: string;
|
|
13
|
+
/** @inheritdoc */
|
|
14
|
+
description: string;
|
|
15
|
+
/** Commands registered in {@link onLoad} for cleanup in {@link onUnload}. */
|
|
16
|
+
private registeredCommands;
|
|
17
|
+
/**
|
|
18
|
+
* Registers `cpdf` and `ipdf` system commands.
|
|
19
|
+
*
|
|
20
|
+
* @param _context - Application context (unused)
|
|
21
|
+
* @param commandManager - Command stack used to register PDF commands
|
|
22
|
+
*/
|
|
23
|
+
onLoad(_context: AcApContext, commandManager: AcEdCommandStack): void;
|
|
24
|
+
/**
|
|
25
|
+
* Removes commands registered in {@link onLoad}.
|
|
26
|
+
*
|
|
27
|
+
* @param _context - Application context (unused)
|
|
28
|
+
* @param commandManager - Command stack used to unregister PDF commands
|
|
29
|
+
*/
|
|
30
|
+
onUnload(_context: AcApContext, commandManager: AcEdCommandStack): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=AcApPdfPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfPlugin.d.ts","sourceRoot":"","sources":["../src/AcApPdfPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,MAAM,8BAA8B,CAAA;AAKrC;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,UAAU;IAC9C,kBAAkB;IAClB,IAAI,SAAc;IAClB,kBAAkB;IAClB,OAAO,SAAU;IACjB,kBAAkB;IAClB,WAAW,SAAiD;IAE5D,6EAA6E;IAC7E,OAAO,CAAC,kBAAkB,CAA6C;IAEvE;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,GAAG,IAAI;IAUrE;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,GAAG,IAAI;CAMxE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { AcEdCommandStack } from '@mlightcad/cad-simple-viewer';
|
|
13
|
+
import { AcApConvertToPdfCmd } from './AcApConvertToPdfCmd';
|
|
14
|
+
import { AcApImportPdfCmd } from './AcApImportPdfCmd';
|
|
15
|
+
/**
|
|
16
|
+
* PDF export/import plugin for cad-simple-viewer.
|
|
17
|
+
*
|
|
18
|
+
* Registers `cpdf` and `ipdf` commands when loaded. Register this plugin
|
|
19
|
+
* lazily via {@link registerLazyPdfPlugin} so PDF libraries are fetched on demand.
|
|
20
|
+
*/
|
|
21
|
+
var AcApPdfPlugin = /** @class */ (function () {
|
|
22
|
+
function AcApPdfPlugin() {
|
|
23
|
+
/** @inheritdoc */
|
|
24
|
+
this.name = 'PdfPlugin';
|
|
25
|
+
/** @inheritdoc */
|
|
26
|
+
this.version = '1.0.0';
|
|
27
|
+
/** @inheritdoc */
|
|
28
|
+
this.description = 'PDF export (cpdf) and import (ipdf) commands';
|
|
29
|
+
/** Commands registered in {@link onLoad} for cleanup in {@link onUnload}. */
|
|
30
|
+
this.registeredCommands = [];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Registers `cpdf` and `ipdf` system commands.
|
|
34
|
+
*
|
|
35
|
+
* @param _context - Application context (unused)
|
|
36
|
+
* @param commandManager - Command stack used to register PDF commands
|
|
37
|
+
*/
|
|
38
|
+
AcApPdfPlugin.prototype.onLoad = function (_context, commandManager) {
|
|
39
|
+
var group = AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME;
|
|
40
|
+
commandManager.addCommand(group, 'cpdf', 'cpdf', new AcApConvertToPdfCmd());
|
|
41
|
+
commandManager.addCommand(group, 'ipdf', 'ipdf', new AcApImportPdfCmd());
|
|
42
|
+
this.registeredCommands.push({ group: group, name: 'cpdf' }, { group: group, name: 'ipdf' });
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Removes commands registered in {@link onLoad}.
|
|
46
|
+
*
|
|
47
|
+
* @param _context - Application context (unused)
|
|
48
|
+
* @param commandManager - Command stack used to unregister PDF commands
|
|
49
|
+
*/
|
|
50
|
+
AcApPdfPlugin.prototype.onUnload = function (_context, commandManager) {
|
|
51
|
+
var e_1, _a;
|
|
52
|
+
try {
|
|
53
|
+
for (var _b = __values(this.registeredCommands), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
54
|
+
var cmd = _c.value;
|
|
55
|
+
commandManager.removeCmd(cmd.group, cmd.name);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
+
finally {
|
|
60
|
+
try {
|
|
61
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
62
|
+
}
|
|
63
|
+
finally { if (e_1) throw e_1.error; }
|
|
64
|
+
}
|
|
65
|
+
this.registeredCommands = [];
|
|
66
|
+
};
|
|
67
|
+
return AcApPdfPlugin;
|
|
68
|
+
}());
|
|
69
|
+
export { AcApPdfPlugin };
|
|
70
|
+
//# sourceMappingURL=AcApPdfPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfPlugin.js","sourceRoot":"","sources":["../src/AcApPdfPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAA;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;;;GAKG;AACH;IAAA;QACE,kBAAkB;QAClB,SAAI,GAAG,WAAW,CAAA;QAClB,kBAAkB;QAClB,YAAO,GAAG,OAAO,CAAA;QACjB,kBAAkB;QAClB,gBAAW,GAAG,8CAA8C,CAAA;QAE5D,6EAA6E;QACrE,uBAAkB,GAA2C,EAAE,CAAA;IA8BzE,CAAC;IA5BC;;;;;OAKG;IACH,8BAAM,GAAN,UAAO,QAAqB,EAAE,cAAgC;QAC5D,IAAM,KAAK,GAAG,gBAAgB,CAAC,0BAA0B,CAAA;QACzD,cAAc,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAA;QAC3E,cAAc,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA;QACxE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAC1B,EAAE,KAAK,OAAA,EAAE,IAAI,EAAE,MAAM,EAAE,EACvB,EAAE,KAAK,OAAA,EAAE,IAAI,EAAE,MAAM,EAAE,CACxB,CAAA;IACH,CAAC;IAED;;;;;OAKG;IACH,gCAAQ,GAAR,UAAS,QAAqB,EAAE,cAAgC;;;YAC9D,KAAkB,IAAA,KAAA,SAAA,IAAI,CAAC,kBAAkB,CAAA,gBAAA,4BAAE,CAAC;gBAAvC,IAAM,GAAG,WAAA;gBACZ,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;YAC/C,CAAC;;;;;;;;;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAA;IAC9B,CAAC;IACH,oBAAC;AAAD,CAAC,AAvCD,IAuCC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF export and import plugin for cad-simple-viewer.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { AcApConvertToPdfCmd } from './AcApConvertToPdfCmd';
|
|
7
|
+
export { AcApImportPdfCmd } from './AcApImportPdfCmd';
|
|
8
|
+
export { AcApPdfConvertor } from './AcApPdfConvertor';
|
|
9
|
+
export { AcApPdfImportConvertor } from './AcApPdfImportConvertor';
|
|
10
|
+
export { createPdfPlugin, PDF_PLUGIN_NAME, PDF_PLUGIN_TRIGGERS, registerLazyPdfPlugin } from './registerLazyPdfPlugin';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,yBAAyB,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDF export and import plugin for cad-simple-viewer.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { AcApConvertToPdfCmd } from './AcApConvertToPdfCmd';
|
|
7
|
+
export { AcApImportPdfCmd } from './AcApImportPdfCmd';
|
|
8
|
+
export { AcApPdfConvertor } from './AcApPdfConvertor';
|
|
9
|
+
export { AcApPdfImportConvertor } from './AcApPdfImportConvertor';
|
|
10
|
+
export { createPdfPlugin, PDF_PLUGIN_NAME, PDF_PLUGIN_TRIGGERS, registerLazyPdfPlugin } from './registerLazyPdfPlugin';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AcApPluginManager } from '@mlightcad/cad-simple-viewer';
|
|
2
|
+
/** Lazy plugin name for PDF export/import. */
|
|
3
|
+
export declare const PDF_PLUGIN_NAME = "PdfPlugin";
|
|
4
|
+
/**
|
|
5
|
+
* Trigger commands handled by {@link PDF_PLUGIN_NAME}.
|
|
6
|
+
*
|
|
7
|
+
* - `cpdf` — export drawing to PDF
|
|
8
|
+
* - `ipdf` — import vector geometry from PDF
|
|
9
|
+
*/
|
|
10
|
+
export declare const PDF_PLUGIN_TRIGGERS: readonly ["cpdf", "ipdf"];
|
|
11
|
+
/**
|
|
12
|
+
* Creates a PDF plugin instance after loading the plugin module chunk.
|
|
13
|
+
*
|
|
14
|
+
* @returns A loaded {@link AcApPdfPlugin} instance
|
|
15
|
+
*/
|
|
16
|
+
export declare function createPdfPlugin(): Promise<import("./AcApPdfPlugin").AcApPdfPlugin>;
|
|
17
|
+
/**
|
|
18
|
+
* Registers the PDF plugin for lazy loading.
|
|
19
|
+
*
|
|
20
|
+
* The plugin bundle is not fetched until one of its trigger commands runs.
|
|
21
|
+
*
|
|
22
|
+
* @param pluginManager - Plugin manager that receives the lazy registration
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerLazyPdfPlugin(pluginManager: AcApPluginManager): void;
|
|
25
|
+
//# sourceMappingURL=registerLazyPdfPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerLazyPdfPlugin.d.ts","sourceRoot":"","sources":["../src/registerLazyPdfPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAErE,8CAA8C;AAC9C,eAAO,MAAM,eAAe,cAAc,CAAA;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,2BAA4B,CAAA;AAE5D;;;;GAIG;AACH,wBAAsB,eAAe,qDAGpC;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,iBAAiB,GAAG,IAAI,CAM5E"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
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);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
+
if (!m) return o;
|
|
40
|
+
var i = m.call(o), r, ar = [], e;
|
|
41
|
+
try {
|
|
42
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
+
}
|
|
44
|
+
catch (error) { e = { error: error }; }
|
|
45
|
+
finally {
|
|
46
|
+
try {
|
|
47
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
+
}
|
|
49
|
+
finally { if (e) throw e.error; }
|
|
50
|
+
}
|
|
51
|
+
return ar;
|
|
52
|
+
};
|
|
53
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
+
if (ar || !(i in from)) {
|
|
56
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
+
ar[i] = from[i];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
+
};
|
|
62
|
+
/** Lazy plugin name for PDF export/import. */
|
|
63
|
+
export var PDF_PLUGIN_NAME = 'PdfPlugin';
|
|
64
|
+
/**
|
|
65
|
+
* Trigger commands handled by {@link PDF_PLUGIN_NAME}.
|
|
66
|
+
*
|
|
67
|
+
* - `cpdf` — export drawing to PDF
|
|
68
|
+
* - `ipdf` — import vector geometry from PDF
|
|
69
|
+
*/
|
|
70
|
+
export var PDF_PLUGIN_TRIGGERS = ['cpdf', 'ipdf'];
|
|
71
|
+
/**
|
|
72
|
+
* Creates a PDF plugin instance after loading the plugin module chunk.
|
|
73
|
+
*
|
|
74
|
+
* @returns A loaded {@link AcApPdfPlugin} instance
|
|
75
|
+
*/
|
|
76
|
+
export function createPdfPlugin() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var AcApPdfPlugin;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0: return [4 /*yield*/, import('./AcApPdfPlugin')];
|
|
82
|
+
case 1:
|
|
83
|
+
AcApPdfPlugin = (_a.sent()).AcApPdfPlugin;
|
|
84
|
+
return [2 /*return*/, new AcApPdfPlugin()];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Registers the PDF plugin for lazy loading.
|
|
91
|
+
*
|
|
92
|
+
* The plugin bundle is not fetched until one of its trigger commands runs.
|
|
93
|
+
*
|
|
94
|
+
* @param pluginManager - Plugin manager that receives the lazy registration
|
|
95
|
+
*/
|
|
96
|
+
export function registerLazyPdfPlugin(pluginManager) {
|
|
97
|
+
pluginManager.registerLazyPlugin({
|
|
98
|
+
name: PDF_PLUGIN_NAME,
|
|
99
|
+
triggers: __spreadArray([], __read(PDF_PLUGIN_TRIGGERS), false),
|
|
100
|
+
loader: createPdfPlugin
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=registerLazyPdfPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerLazyPdfPlugin.js","sourceRoot":"","sources":["../src/registerLazyPdfPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,8CAA8C;AAC9C,MAAM,CAAC,IAAM,eAAe,GAAG,WAAW,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAA;AAE5D;;;;GAIG;AACH,MAAM,UAAgB,eAAe;;;;;wBACT,qBAAM,MAAM,CAAC,iBAAiB,CAAC,EAAA;;oBAAjD,aAAa,GAAK,CAAA,SAA+B,CAAA,cAApC;oBACrB,sBAAO,IAAI,aAAa,EAAE,EAAA;;;;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAgC;IACpE,aAAa,CAAC,kBAAkB,CAAC;QAC/B,IAAI,EAAE,eAAe;QACrB,QAAQ,2BAAM,mBAAmB,SAAC;QAClC,MAAM,EAAE,eAAe;KACxB,CAAC,CAAA;AACJ,CAAC"}
|