@mlightcad/cad-pdf-plugin 1.6.3 → 1.7.1

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 (42) hide show
  1. package/README.md +39 -23
  2. package/dist/cad-pdf-plugin-register.js +11 -10
  3. package/dist/cad-pdf-plugin-register.umd.cjs +1 -1
  4. package/dist/cad-pdf-plugin.js +17050 -41432
  5. package/dist/cad-pdf-plugin.umd.cjs +13 -270
  6. package/lib/AcApConvertToPdfCmd.d.ts +13 -2
  7. package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
  8. package/lib/AcApConvertToPdfCmd.js +153 -7
  9. package/lib/AcApConvertToPdfCmd.js.map +1 -1
  10. package/lib/AcApPdfConvertor.d.ts +18 -8
  11. package/lib/AcApPdfConvertor.d.ts.map +1 -1
  12. package/lib/AcApPdfConvertor.js +87 -94
  13. package/lib/AcApPdfConvertor.js.map +1 -1
  14. package/lib/AcApPdfExportOptions.d.ts +38 -0
  15. package/lib/AcApPdfExportOptions.d.ts.map +1 -0
  16. package/lib/AcApPdfExportOptions.js +12 -0
  17. package/lib/AcApPdfExportOptions.js.map +1 -0
  18. package/lib/AcApPdfFontResolver.d.ts +20 -0
  19. package/lib/AcApPdfFontResolver.d.ts.map +1 -0
  20. package/lib/AcApPdfFontResolver.js +105 -0
  21. package/lib/AcApPdfFontResolver.js.map +1 -0
  22. package/lib/AcApPdfGlyphProvider.d.ts +15 -0
  23. package/lib/AcApPdfGlyphProvider.d.ts.map +1 -0
  24. package/lib/AcApPdfGlyphProvider.js +277 -0
  25. package/lib/AcApPdfGlyphProvider.js.map +1 -0
  26. package/lib/AcApPdfPlugin.d.ts +13 -3
  27. package/lib/AcApPdfPlugin.d.ts.map +1 -1
  28. package/lib/AcApPdfPlugin.js +19 -7
  29. package/lib/AcApPdfPlugin.js.map +1 -1
  30. package/lib/createPdfPlugin.d.ts +3 -2
  31. package/lib/createPdfPlugin.d.ts.map +1 -1
  32. package/lib/createPdfPlugin.js +4 -2
  33. package/lib/createPdfPlugin.js.map +1 -1
  34. package/lib/index.d.ts +4 -0
  35. package/lib/index.d.ts.map +1 -1
  36. package/lib/index.js +3 -0
  37. package/lib/index.js.map +1 -1
  38. package/lib/register.d.ts +7 -3
  39. package/lib/register.d.ts.map +1 -1
  40. package/lib/register.js +12 -5
  41. package/lib/register.js.map +1 -1
  42. package/package.json +9 -9
@@ -0,0 +1,105 @@
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
+ import { AcApFontUtil } from '@mlightcad/cad-simple-viewer';
38
+ /**
39
+ * Resolves embeddable TTF/OTF/WOFF font programs for `textMode: 'text'` PDF
40
+ * exports from the viewer font catalog.
41
+ *
42
+ * Lookup mirrors on-screen text rendering: direct catalog hit first, then the
43
+ * font manager's replacement chain (`getReplacementFontName`) for style fonts
44
+ * the catalog does not list ("Standard", localized aliases like "标准", …).
45
+ * Only a catalog *miss* falls through to the replacement — a direct SHX hit
46
+ * stays SHX so those texts keep their vector-glyph appearance in the PDF.
47
+ *
48
+ * The catalog entry's `url` is fetched on demand; bytes are not kept between
49
+ * calls beyond pdf-lib's own embed cache, so a document using several CJK
50
+ * faces embeds each subset once regardless of how many texts reference it.
51
+ *
52
+ * SHX fonts have no embeddable program and resolve `undefined` — the renderer
53
+ * then paints those texts as vector glyphs, matching the on-screen fallback.
54
+ */
55
+ export var resolveViewerTextFont = function (fontName) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var info, res, bytes, _a, error_1;
57
+ return __generator(this, function (_b) {
58
+ switch (_b.label) {
59
+ case 0:
60
+ info = findEmbeddableInfo(fontName);
61
+ if (!info || info.type !== 'mesh' || !info.url) {
62
+ // Called at most once per unique font name (negative results are cached
63
+ // by the renderer's font manager), so this cannot flood the log.
64
+ console.warn("[cad-pdf-plugin] No embeddable font for \"".concat(fontName, "\" ") +
65
+ "(catalog=".concat(info ? info.type : 'miss', ", url=").concat((info === null || info === void 0 ? void 0 : info.url) ? 'yes' : 'no', "); ") +
66
+ 'texts using it are painted as vector glyphs');
67
+ return [2 /*return*/, undefined];
68
+ }
69
+ _b.label = 1;
70
+ case 1:
71
+ _b.trys.push([1, 4, , 5]);
72
+ return [4 /*yield*/, fetch(info.url)];
73
+ case 2:
74
+ res = _b.sent();
75
+ if (!res.ok) {
76
+ console.warn("[cad-pdf-plugin] Font \"".concat(fontName, "\" fetch failed (").concat(res.status, " ").concat(info.url, "); ") +
77
+ 'texts using it are painted as vector glyphs');
78
+ return [2 /*return*/, undefined];
79
+ }
80
+ _a = Uint8Array.bind;
81
+ return [4 /*yield*/, res.arrayBuffer()];
82
+ case 3:
83
+ bytes = new (_a.apply(Uint8Array, [void 0, _b.sent()]))();
84
+ return [2 /*return*/, bytes.byteLength > 0 ? bytes : undefined];
85
+ case 4:
86
+ error_1 = _b.sent();
87
+ console.warn("[cad-pdf-plugin] Font \"".concat(fontName, "\" fetch errored (").concat(info.url, "): ") +
88
+ "".concat(error_1 instanceof Error ? error_1.message : String(error_1), "; ") +
89
+ 'texts using it are painted as vector glyphs');
90
+ return [2 /*return*/, undefined];
91
+ case 5: return [2 /*return*/];
92
+ }
93
+ });
94
+ }); };
95
+ function findEmbeddableInfo(fontName) {
96
+ var direct = AcApFontUtil.findFontInfoByName(fontName);
97
+ if (direct) {
98
+ return direct;
99
+ }
100
+ var replacement = AcApFontUtil.getReplacementFontName(fontName);
101
+ return replacement && replacement !== fontName
102
+ ? AcApFontUtil.findFontInfoByName(replacement)
103
+ : undefined;
104
+ }
105
+ //# sourceMappingURL=AcApPdfFontResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfFontResolver.js","sourceRoot":"","sources":["../src/AcApPdfFontResolver.ts"],"names":[],"mapp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,CACV,kCAA0B,QAAQ,+BAAoB,IAAI,CAAC,GAAG,QAAK;oBACjE,UAAG,OAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAK,CAAC,OAAI;oBAC7D,6CAA6C,CAChD,CAAA;gBACD,sBAAO,SAAS,EAAA;;;;KAEnB,CAAA;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,IAAM,MAAM,GAAG,YAAY,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IACxD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAA;IACf,CAAC;IACD,IAAM,WAAW,GAAG,YAAY,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IACjE,OAAO,WAAW,IAAI,WAAW,KAAK,QAAQ;QAC5C,CAAC,CAAC,YAAY,CAAC,kBAAkB,CAAC,WAAW,CAAC;QAC9C,CAAC,CAAC,SAAS,CAAA;AACf,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { AcPdfGlyphProvider } from '@mlightcad/pdf-renderer';
2
+ /**
3
+ * Turns the viewer's already-initialized mtext renderer into PDF glyph
4
+ * geometry so TEXT/MTEXT are not dropped during export.
5
+ *
6
+ * Geometry is emitted as flat float32 buffers relative to the text's own
7
+ * insertion point. Large drawings carry tens of thousands of MTEXT instances;
8
+ * the previous per-triangle object graphs (`{x, y}` points inside
9
+ * per-primitive arrays) retained ~25 objects per triangle in the renderer's
10
+ * glyph cache and exhausted the tab's heap. Buffers are shared by reference
11
+ * across identical texts, so a drawing's unique text content costs ~24 bytes
12
+ * per triangle.
13
+ */
14
+ export declare function createViewerPdfGlyphProvider(): AcPdfGlyphProvider;
15
+ //# sourceMappingURL=AcApPdfGlyphProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfGlyphProvider.d.ts","sourceRoot":"","sources":["../src/AcApPdfGlyphProvider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,yBAAyB,CAAA;AA0BhC;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,IAAI,kBAAkB,CAgDjE"}
@@ -0,0 +1,277 @@
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 __values = (this && this.__values) || function(o) {
38
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
39
+ if (m) return m.call(o);
40
+ if (o && typeof o.length === "number") return {
41
+ next: function () {
42
+ if (o && i >= o.length) o = void 0;
43
+ return { value: o && o[i++], done: !o };
44
+ }
45
+ };
46
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
47
+ };
48
+ import { AcTrMTextRenderer } from '@mlightcad/three-renderer';
49
+ /**
50
+ * Turns the viewer's already-initialized mtext renderer into PDF glyph
51
+ * geometry so TEXT/MTEXT are not dropped during export.
52
+ *
53
+ * Geometry is emitted as flat float32 buffers relative to the text's own
54
+ * insertion point. Large drawings carry tens of thousands of MTEXT instances;
55
+ * the previous per-triangle object graphs (`{x, y}` points inside
56
+ * per-primitive arrays) retained ~25 objects per triangle in the renderer's
57
+ * glyph cache and exhausted the tab's heap. Buffers are shared by reference
58
+ * across identical texts, so a drawing's unique text content costs ~24 bytes
59
+ * per triangle.
60
+ */
61
+ export function createViewerPdfGlyphProvider() {
62
+ var empty = {
63
+ triangles: new Float32Array(0),
64
+ polylines: new Float32Array(0)
65
+ };
66
+ var emptyBox = { min: { x: 0, y: 0 }, max: { x: 0, y: 0 } };
67
+ return {
68
+ renderMText: function (data, style) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var renderer, object, contents, _a, primitives, box, _b;
71
+ var _c, _d, _e, _f, _g, _h;
72
+ return __generator(this, function (_j) {
73
+ switch (_j.label) {
74
+ case 0:
75
+ _j.trys.push([0, 2, , 3]);
76
+ renderer = AcTrMTextRenderer.getInstance();
77
+ return [4 /*yield*/, renderer.asyncRenderMText(
78
+ // AcGi and mtext-renderer attachment enums are structurally compatible
79
+ // at runtime but diverge in the TypeScript type graph.
80
+ data, style)];
81
+ case 1:
82
+ object = (_j.sent());
83
+ contents = (_d = (_c = data.contents) !== null && _c !== void 0 ? _c : data.text) !== null && _d !== void 0 ? _d : '';
84
+ _a = extractGlyphPrimitives(object, (_f = (_e = data.position) === null || _e === void 0 ? void 0 : _e.x) !== null && _f !== void 0 ? _f : 0, (_h = (_g = data.position) === null || _g === void 0 ? void 0 : _g.y) !== null && _h !== void 0 ? _h : 0), primitives = _a.primitives, box = _a.box;
85
+ return [2 /*return*/, { primitives: primitives, actualText: contents, box: box }];
86
+ case 2:
87
+ _b = _j.sent();
88
+ return [2 /*return*/, { primitives: empty, actualText: '', box: emptyBox }];
89
+ case 3: return [2 /*return*/];
90
+ }
91
+ });
92
+ });
93
+ },
94
+ renderShape: function (shape, style) {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var renderer, object, _a, primitives, box, _b;
97
+ var _c, _d, _e, _f;
98
+ return __generator(this, function (_g) {
99
+ switch (_g.label) {
100
+ case 0:
101
+ _g.trys.push([0, 2, , 3]);
102
+ renderer = AcTrMTextRenderer.getInstance();
103
+ return [4 /*yield*/, renderer.asyncRenderShape(shape, (style !== null && style !== void 0 ? style : {}))];
104
+ case 1:
105
+ object = (_g.sent());
106
+ _a = extractGlyphPrimitives(object, (_d = (_c = shape.position) === null || _c === void 0 ? void 0 : _c.x) !== null && _d !== void 0 ? _d : 0, (_f = (_e = shape.position) === null || _e === void 0 ? void 0 : _e.y) !== null && _f !== void 0 ? _f : 0), primitives = _a.primitives, box = _a.box;
107
+ return [2 /*return*/, { primitives: primitives, box: box }];
108
+ case 2:
109
+ _b = _g.sent();
110
+ return [2 /*return*/, { primitives: empty, box: emptyBox }];
111
+ case 3: return [2 /*return*/];
112
+ }
113
+ });
114
+ });
115
+ }
116
+ };
117
+ }
118
+ /**
119
+ * Builds flat triangle/polyline buffers from the rendered scene graph,
120
+ * baking each node's world matrix and translating the result so (0,0) is the
121
+ * text's insertion point.
122
+ */
123
+ function extractGlyphPrimitives(root, originX, originY) {
124
+ var e_1, _a;
125
+ var _b;
126
+ (_b = root.updateMatrixWorld) === null || _b === void 0 ? void 0 : _b.call(root, true);
127
+ var sources = [];
128
+ var triangleFloats = 0;
129
+ var lineFloats = 0;
130
+ root.traverse(function (node) {
131
+ var _a, _b;
132
+ var geom = node.geometry;
133
+ if (!geom) {
134
+ return;
135
+ }
136
+ var pos = geom.getAttribute('position');
137
+ if (!pos || pos.count < 1) {
138
+ return;
139
+ }
140
+ if (node.isMesh) {
141
+ var index = geom.getIndex();
142
+ var triCount = index ? index.count / 3 : Math.floor(pos.count / 3);
143
+ if (triCount < 1) {
144
+ return;
145
+ }
146
+ sources.push({
147
+ elements: (_a = node.matrixWorld) === null || _a === void 0 ? void 0 : _a.elements,
148
+ pos: pos,
149
+ index: index,
150
+ isMesh: true,
151
+ isSegments: false
152
+ });
153
+ triangleFloats += triCount * 6;
154
+ return;
155
+ }
156
+ if (node.isLine) {
157
+ // three.js: LineSegments extends Line, so `isLine` is true for both.
158
+ // Stroke-font glyphs (SHX) arrive as LineSegments where every vertex
159
+ // PAIR is an independent stroke — expanding them as one continuous
160
+ // polyline would connect glyph strokes end-to-end.
161
+ var segments = !!node.isLineSegments;
162
+ sources.push({
163
+ elements: (_b = node.matrixWorld) === null || _b === void 0 ? void 0 : _b.elements,
164
+ pos: pos,
165
+ index: null,
166
+ isMesh: false,
167
+ isSegments: segments
168
+ });
169
+ lineFloats += segments
170
+ ? Math.floor(pos.count / 2) * 5
171
+ : pos.count * 2 + 1;
172
+ }
173
+ });
174
+ var triangles = new Float32Array(triangleFloats);
175
+ var polylines = new Float32Array(lineFloats);
176
+ var minX = Infinity;
177
+ var minY = Infinity;
178
+ var maxX = -Infinity;
179
+ var maxY = -Infinity;
180
+ var expand = function (x, y) {
181
+ if (x < minX) {
182
+ minX = x;
183
+ }
184
+ if (y < minY) {
185
+ minY = y;
186
+ }
187
+ if (x > maxX) {
188
+ maxX = x;
189
+ }
190
+ if (y > maxY) {
191
+ maxY = y;
192
+ }
193
+ };
194
+ var triOffset = 0;
195
+ var lineOffset = 0;
196
+ var _loop_1 = function (source) {
197
+ var el = source.elements;
198
+ var pos = source.pos;
199
+ // Full 4x4 transform with perspective divide, matching the previous
200
+ // per-point `applyWorldMatrix` behavior.
201
+ var world = function (i) {
202
+ var x = pos.getX(i);
203
+ var y = pos.getY(i);
204
+ if (!el) {
205
+ return { x: x, y: y };
206
+ }
207
+ var z = pos.getZ(i);
208
+ var w = el[3] * x + el[7] * y + el[11] * z + el[15];
209
+ var invW = w === 0 ? 1 : 1 / w;
210
+ return {
211
+ x: (el[0] * x + el[4] * y + el[8] * z + el[12]) * invW,
212
+ y: (el[1] * x + el[5] * y + el[9] * z + el[13]) * invW
213
+ };
214
+ };
215
+ if (source.isMesh) {
216
+ var count = source.index
217
+ ? source.index.count / 3
218
+ : Math.floor(pos.count / 3);
219
+ for (var t = 0; t < count; t++) {
220
+ for (var k = 0; k < 3; k++) {
221
+ var vi = source.index ? source.index.getX(t * 3 + k) : t * 3 + k;
222
+ var p = world(vi);
223
+ var x = p.x - originX;
224
+ var y = p.y - originY;
225
+ triangles[triOffset++] = x;
226
+ triangles[triOffset++] = y;
227
+ expand(x, y);
228
+ }
229
+ }
230
+ }
231
+ else if (source.isSegments) {
232
+ // One polyline per vertex pair: each stroke stays independent.
233
+ var pairCount = Math.floor(pos.count / 2);
234
+ for (var s = 0; s < pairCount; s++) {
235
+ polylines[lineOffset++] = 2;
236
+ for (var k = 0; k < 2; k++) {
237
+ var p = world(s * 2 + k);
238
+ var x = p.x - originX;
239
+ var y = p.y - originY;
240
+ polylines[lineOffset++] = x;
241
+ polylines[lineOffset++] = y;
242
+ expand(x, y);
243
+ }
244
+ }
245
+ }
246
+ else {
247
+ polylines[lineOffset++] = pos.count;
248
+ for (var i = 0; i < pos.count; i++) {
249
+ var p = world(i);
250
+ var x = p.x - originX;
251
+ var y = p.y - originY;
252
+ polylines[lineOffset++] = x;
253
+ polylines[lineOffset++] = y;
254
+ expand(x, y);
255
+ }
256
+ }
257
+ };
258
+ try {
259
+ for (var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()) {
260
+ var source = sources_1_1.value;
261
+ _loop_1(source);
262
+ }
263
+ }
264
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
265
+ finally {
266
+ try {
267
+ if (sources_1_1 && !sources_1_1.done && (_a = sources_1.return)) _a.call(sources_1);
268
+ }
269
+ finally { if (e_1) throw e_1.error; }
270
+ }
271
+ var primitives = { triangles: triangles, polylines: polylines };
272
+ var box = Number.isFinite(minX)
273
+ ? { min: { x: minX, y: minY }, max: { x: maxX, y: maxY } }
274
+ : { min: { x: 0, y: 0 }, max: { x: 0, y: 0 } };
275
+ return { primitives: primitives, box: box };
276
+ }
277
+ //# sourceMappingURL=AcApPdfGlyphProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPdfGlyphProvider.js","sourceRoot":"","sources":["../src/AcApPdfGlyphProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAyB7D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,4BAA4B;IAC1C,IAAM,KAAK,GAAyB;QAClC,SAAS,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC;QAC9B,SAAS,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC;KAC/B,CAAA;IACD,IAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,C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,CAAC,CAAA;gBAC3B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACd,CAAC;QACH,CAAC;;;QA1DH,KAAqB,IAAA,YAAA,SAAA,OAAO,CAAA,gCAAA;YAAvB,IAAM,MAAM,oBAAA;oBAAN,MAAM;SA2DhB;;;;;;;;;IAED,IAAM,UAAU,GAAyB,EAAE,SAAS,WAAA,EAAE,SAAS,WAAA,EAAE,CAAA;IACjE,IAAM,GAAG,GAAkB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC9C,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QAC1D,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAA;IAChD,OAAO,EAAE,UAAU,YAAA,EAAE,GAAG,KAAA,EAAE,CAAA;AAC5B,CAAC"}
@@ -1,9 +1,16 @@
1
1
  import { AcApContext, AcApPlugin, AcEdCommandStack } from '@mlightcad/cad-simple-viewer';
2
+ export interface AcApPdfPluginOptions {
3
+ /**
4
+ * When true, only `ipdf` is registered. Defaults to false.
5
+ */
6
+ disableExport?: boolean;
7
+ }
2
8
  /**
3
9
  * PDF export/import plugin for cad-simple-viewer.
4
10
  *
5
- * Registers `cpdf` and `ipdf` commands when loaded. Register this plugin
6
- * lazily via {@link registerLazyPdfPlugin} so PDF libraries are fetched on demand.
11
+ * Registers `-cpdf` and `ipdf` when loaded. Also registers `cpdf` when no UI
12
+ * dialog command is already present. Register this plugin lazily via
13
+ * {@link registerLazyPdfPlugin} so the PDF renderer is fetched on demand.
7
14
  */
8
15
  export declare class AcApPdfPlugin implements AcApPlugin {
9
16
  /** @inheritdoc */
@@ -12,10 +19,13 @@ export declare class AcApPdfPlugin implements AcApPlugin {
12
19
  version: string;
13
20
  /** @inheritdoc */
14
21
  description: string;
22
+ private readonly _disableExport;
15
23
  /** Commands registered in {@link onLoad} for cleanup in {@link onUnload}. */
16
24
  private registeredCommands;
25
+ constructor(options?: AcApPdfPluginOptions);
17
26
  /**
18
- * Registers `cpdf` and `ipdf` system commands.
27
+ * Registers `-cpdf` (when export is enabled) and `ipdf` system commands.
28
+ * Registers `cpdf` only when a host UI has not already claimed that name.
19
29
  *
20
30
  * @param _context - Application context (unused)
21
31
  * @param commandManager - Command stack used to register PDF commands
@@ -1 +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;AAMrC;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,UAAU;IAC9C,kBAAkB;IAClB,IAAI,SAAc;IAClB,kBAAkB;IAClB,OAAO,SAAsB;IAC7B,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"}
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;AAMrC,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;;;GAMG;AACH,qBAAa,aAAc,YAAW,UAAU;IAC9C,kBAAkB;IAClB,IAAI,SAAc;IAClB,kBAAkB;IAClB,OAAO,SAAsB;IAC7B,kBAAkB;IAClB,WAAW,SAAyD;IAEpE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAExC,6EAA6E;IAC7E,OAAO,CAAC,kBAAkB,CAA6C;gBAE3D,OAAO,GAAE,oBAAyB;IAI9C;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,GAAG,IAAI;IAerE;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,GAAG,IAAI;CAMxE"}
@@ -16,31 +16,43 @@ import { AcApImportPdfCmd } from './AcApImportPdfCmd';
16
16
  /**
17
17
  * PDF export/import plugin for cad-simple-viewer.
18
18
  *
19
- * Registers `cpdf` and `ipdf` commands when loaded. Register this plugin
20
- * lazily via {@link registerLazyPdfPlugin} so PDF libraries are fetched on demand.
19
+ * Registers `-cpdf` and `ipdf` when loaded. Also registers `cpdf` when no UI
20
+ * dialog command is already present. Register this plugin lazily via
21
+ * {@link registerLazyPdfPlugin} so the PDF renderer is fetched on demand.
21
22
  */
22
23
  var AcApPdfPlugin = /** @class */ (function () {
23
- function AcApPdfPlugin() {
24
+ function AcApPdfPlugin(options) {
25
+ if (options === void 0) { options = {}; }
24
26
  /** @inheritdoc */
25
27
  this.name = 'PdfPlugin';
26
28
  /** @inheritdoc */
27
29
  this.version = packageJson.version;
28
30
  /** @inheritdoc */
29
- this.description = 'PDF export (cpdf) and import (ipdf) commands';
31
+ this.description = 'PDF export (-cpdf / cpdf) and import (ipdf) commands';
30
32
  /** Commands registered in {@link onLoad} for cleanup in {@link onUnload}. */
31
33
  this.registeredCommands = [];
34
+ this._disableExport = options.disableExport === true;
32
35
  }
33
36
  /**
34
- * Registers `cpdf` and `ipdf` system commands.
37
+ * Registers `-cpdf` (when export is enabled) and `ipdf` system commands.
38
+ * Registers `cpdf` only when a host UI has not already claimed that name.
35
39
  *
36
40
  * @param _context - Application context (unused)
37
41
  * @param commandManager - Command stack used to register PDF commands
38
42
  */
39
43
  AcApPdfPlugin.prototype.onLoad = function (_context, commandManager) {
40
44
  var group = AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME;
41
- commandManager.addCommand(group, 'cpdf', 'cpdf', new AcApConvertToPdfCmd());
45
+ if (!this._disableExport) {
46
+ var exportCmd = new AcApConvertToPdfCmd();
47
+ commandManager.addCommand(group, '-cpdf', '-cpdf', exportCmd);
48
+ this.registeredCommands.push({ group: group, name: '-cpdf' });
49
+ if (!commandManager.lookupGlobalCmd('cpdf')) {
50
+ commandManager.addCommand(group, 'cpdf', 'cpdf', exportCmd);
51
+ this.registeredCommands.push({ group: group, name: 'cpdf' });
52
+ }
53
+ }
42
54
  commandManager.addCommand(group, 'ipdf', 'ipdf', new AcApImportPdfCmd());
43
- this.registeredCommands.push({ group: group, name: 'cpdf' }, { group: group, name: 'ipdf' });
55
+ this.registeredCommands.push({ group: group, name: 'ipdf' });
44
56
  };
45
57
  /**
46
58
  * Removes commands registered in {@link onLoad}.
@@ -1 +1 @@
1
- {"version":3,"file":"AcApPdfPlugin.js","sourceRoot":"","sources":["../src/AcApPdfPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAA;AAErC,OAAO,WAAW,MAAM,iBAAiB,CAAA;AACzC,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,WAAW,CAAC,OAAO,CAAA;QAC7B,kBAAkB;QAClB,gBAAW,GAAG,8CAA8C,CAAA;QAE5D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AC;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,AAnDD,IAmDC"}
@@ -1,8 +1,9 @@
1
- import { AcApPdfPlugin } from './AcApPdfPlugin';
1
+ import { AcApPdfPlugin, type AcApPdfPluginOptions } from './AcApPdfPlugin';
2
2
  /**
3
3
  * Creates a PDF plugin instance.
4
4
  *
5
+ * @param options - Optional plugin options (e.g. whether to skip `cpdf`)
5
6
  * @returns A loaded {@link AcApPdfPlugin} instance
6
7
  */
7
- export declare function createPdfPlugin(): Promise<AcApPdfPlugin>;
8
+ export declare function createPdfPlugin(options?: AcApPdfPluginOptions): Promise<AcApPdfPlugin>;
8
9
  //# sourceMappingURL=createPdfPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createPdfPlugin.d.ts","sourceRoot":"","sources":["../src/createPdfPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;GAIG;AACH,wBAAsB,eAAe,2BAEpC"}
1
+ {"version":3,"file":"createPdfPlugin.d.ts","sourceRoot":"","sources":["../src/createPdfPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE1E;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAE,oBAAyB,0BAEvE"}
@@ -38,12 +38,14 @@ import { AcApPdfPlugin } from './AcApPdfPlugin';
38
38
  /**
39
39
  * Creates a PDF plugin instance.
40
40
  *
41
+ * @param options - Optional plugin options (e.g. whether to skip `cpdf`)
41
42
  * @returns A loaded {@link AcApPdfPlugin} instance
42
43
  */
43
44
  export function createPdfPlugin() {
44
- return __awaiter(this, void 0, void 0, function () {
45
+ return __awaiter(this, arguments, void 0, function (options) {
46
+ if (options === void 0) { options = {}; }
45
47
  return __generator(this, function (_a) {
46
- return [2 /*return*/, new AcApPdfPlugin()];
48
+ return [2 /*return*/, new AcApPdfPlugin(options)];
47
49
  });
48
50
  });
49
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createPdfPlugin.js","sourceRoot":"","sources":["../src/createPdfPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;GAIG;AACH,MAAM,UAAgB,eAAe;;;YACnC,sBAAO,IAAI,aAAa,EAAE,EAAA;;;CAC3B"}
1
+ {"version":3,"file":"createPdfPlugin.js","sourceRoot":"","sources":["../src/createPdfPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,iBAAiB,CAAA;AAE1E;;;;;GAKG;AACH,MAAM,UAAgB,eAAe;wDAAC,OAAkC;QAAlC,wBAAA,EAAA,YAAkC;;YACtE,sBAAO,IAAI,aAAa,CAAC,OAAO,CAAC,EAAA;;;CAClC"}
package/lib/index.d.ts CHANGED
@@ -6,7 +6,11 @@
6
6
  export { AcApConvertToPdfCmd } from './AcApConvertToPdfCmd';
7
7
  export { AcApImportPdfCmd } from './AcApImportPdfCmd';
8
8
  export { AcApPdfConvertor } from './AcApPdfConvertor';
9
+ export { resolveViewerTextFont } from './AcApPdfFontResolver';
10
+ export { type AcApPdfExportOptions, type AcApPdfModelSpaceFit, resolveAcApPdfExportOptions } from './AcApPdfExportOptions';
9
11
  export { AcApPdfImportConvertor } from './AcApPdfImportConvertor';
12
+ export type { AcApPdfPluginOptions } from './AcApPdfPlugin';
13
+ export { AcApPdfPlugin } from './AcApPdfPlugin';
10
14
  export { createPdfPlugin } from './createPdfPlugin';
11
15
  export { PDF_PLUGIN_NAME, PDF_PLUGIN_TRIGGERS } from './register';
12
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
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,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,2BAA2B,EAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
package/lib/index.js CHANGED
@@ -6,7 +6,10 @@
6
6
  export { AcApConvertToPdfCmd } from './AcApConvertToPdfCmd';
7
7
  export { AcApImportPdfCmd } from './AcApImportPdfCmd';
8
8
  export { AcApPdfConvertor } from './AcApPdfConvertor';
9
+ export { resolveViewerTextFont } from './AcApPdfFontResolver';
10
+ export { resolveAcApPdfExportOptions } from './AcApPdfExportOptions';
9
11
  export { AcApPdfImportConvertor } from './AcApPdfImportConvertor';
12
+ export { AcApPdfPlugin } from './AcApPdfPlugin';
10
13
  export { createPdfPlugin } from './createPdfPlugin';
11
14
  export { PDF_PLUGIN_NAME, PDF_PLUGIN_TRIGGERS } from './register';
12
15
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +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,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
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,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAGL,2BAA2B,EAC5B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
package/lib/register.d.ts CHANGED
@@ -4,10 +4,12 @@ export declare const PDF_PLUGIN_NAME = "PdfPlugin";
4
4
  /**
5
5
  * Trigger commands handled by {@link PDF_PLUGIN_NAME}.
6
6
  *
7
- * - `cpdf` — export drawing to PDF
7
+ * - `-cpdf` — export drawing to PDF via command-line prompts
8
+ * - `cpdf` — same as `-cpdf` when no UI dialog is registered; in cad-viewer,
9
+ * `cpdf` opens the export dialog and loads this plugin on confirm via `-cpdf`
8
10
  * - `ipdf` — import vector geometry from PDF
9
11
  */
10
- export declare const PDF_PLUGIN_TRIGGERS: readonly ["cpdf", "ipdf"];
12
+ export declare const PDF_PLUGIN_TRIGGERS: readonly ["-cpdf", "cpdf", "ipdf"];
11
13
  /**
12
14
  * Registers the PDF plugin for lazy loading.
13
15
  *
@@ -16,5 +18,7 @@ export declare const PDF_PLUGIN_TRIGGERS: readonly ["cpdf", "ipdf"];
16
18
  *
17
19
  * @param pluginManager - Plugin manager that receives the lazy registration
18
20
  */
19
- export declare function registerLazyPdfPlugin(pluginManager: AcApPluginManager): void;
21
+ export declare function registerLazyPdfPlugin(pluginManager: AcApPluginManager, options?: {
22
+ disableExport?: boolean;
23
+ }): void;
20
24
  //# sourceMappingURL=register.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.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;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,iBAAiB,GAAG,IAAI,CAS5E"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAErE,8CAA8C;AAC9C,eAAO,MAAM,eAAe,cAAc,CAAA;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,oCAAqC,CAAA;AAErE;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,iBAAiB,EAChC,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GACxC,IAAI,CAcN"}