lineadraw 0.14.0 → 0.15.0
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/dist/bridge.js +2 -3
- package/dist/{chunk-ZQLBHWCD.js → chunk-3QRYJAPZ.js} +111 -93
- package/dist/{chunk-FBZASM7T.js → chunk-BQHN5HQY.js} +106 -3764
- package/dist/chunk-L7VHB7FJ.js +3837 -0
- package/dist/{chunk-PZ5AY32C.js → chunk-MLKGABMK.js} +0 -1
- package/dist/{chunk-RNA2RDGL.js → chunk-WRJMBE3K.js} +0 -1
- package/dist/{chunk-L4FNH35X.js → chunk-ZC7H23FQ.js} +11 -1
- package/dist/embedded-G6SF2C34.js +14 -0
- package/dist/exportDxf-HQT4JPUQ.js +10 -0
- package/dist/helpers.js +4 -4
- package/dist/{node-PLO3I6OZ.js → node-FWKE5ULH.js} +1 -2
- package/dist/pkg/linea_dwg_bg.wasm +0 -0
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.js +14 -11
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +7 -7
- package/dist/{types.d-DMu4ZKhe.d.ts → types.d-B_nchcQx.d.ts} +14 -12
- package/lineadraw.d.ts +2 -2
- package/package.json +4 -2
- package/dist/bridge.js.map +0 -1
- package/dist/chunk-FBZASM7T.js.map +0 -1
- package/dist/chunk-L4FNH35X.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-RNA2RDGL.js.map +0 -1
- package/dist/chunk-ZQLBHWCD.js.map +0 -1
- package/dist/embedded-F5ZJYFHC.js +0 -10
- package/dist/embedded-F5ZJYFHC.js.map +0 -1
- package/dist/exportDxf-YBVM7KKS.js +0 -10
- package/dist/exportDxf-YBVM7KKS.js.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/node-PLO3I6OZ.js.map +0 -1
- package/dist/sdk.js.map +0 -1
- package/dist/tools.js.map +0 -1
package/dist/bridge.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
bridgeFilePath,
|
|
5
5
|
connectEditors,
|
|
6
6
|
createBridge
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-WRJMBE3K.js";
|
|
8
|
+
import "./chunk-MLKGABMK.js";
|
|
9
9
|
export {
|
|
10
10
|
BridgeError,
|
|
11
11
|
DEFAULT_BRIDGE_PORT,
|
|
@@ -13,4 +13,3 @@ export {
|
|
|
13
13
|
connectEditors,
|
|
14
14
|
createBridge
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=bridge.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ADVANCE_TABLES,
|
|
3
2
|
ANSI31_BASE_SPACING,
|
|
4
3
|
BlockChildSchema,
|
|
5
4
|
CURRENT_DOCUMENT_VERSION,
|
|
@@ -8,14 +7,10 @@ import {
|
|
|
8
7
|
DEFAULT_TEXT_STYLE,
|
|
9
8
|
DimStyleOverrideSchema,
|
|
10
9
|
DimStyleSchema,
|
|
11
|
-
EXTRACTED_EXTRAS,
|
|
12
|
-
EXTRACTED_RANGES,
|
|
13
|
-
FONTS,
|
|
14
10
|
HatchPatternSchema,
|
|
15
11
|
LineTypeSchema,
|
|
16
12
|
MAX_HATCH_SEGMENTS,
|
|
17
13
|
ModelObjectSchema,
|
|
18
|
-
REAL_FACES,
|
|
19
14
|
REFERENCE_FORMATS,
|
|
20
15
|
TextStyleOverrideSchema,
|
|
21
16
|
TextStyleSchema,
|
|
@@ -25,7 +20,6 @@ import {
|
|
|
25
20
|
add,
|
|
26
21
|
angle,
|
|
27
22
|
angleInArc,
|
|
28
|
-
approximateTextMeasurer,
|
|
29
23
|
arcEndPoint,
|
|
30
24
|
arcFrom3Points,
|
|
31
25
|
arcMidPoint,
|
|
@@ -72,8 +66,6 @@ import {
|
|
|
72
66
|
expandBlockChildren,
|
|
73
67
|
expandWithBlockDependents,
|
|
74
68
|
findBlockScript,
|
|
75
|
-
fontFace,
|
|
76
|
-
fontFromDxfStyle,
|
|
77
69
|
fromAngle,
|
|
78
70
|
getBlockError,
|
|
79
71
|
getBlockMeta,
|
|
@@ -118,16 +110,14 @@ import {
|
|
|
118
110
|
nurbsToBeziers,
|
|
119
111
|
paintArrowhead,
|
|
120
112
|
paramMismatch,
|
|
121
|
-
parseFontFace,
|
|
122
113
|
parseInputTable,
|
|
123
114
|
parseParamsExport,
|
|
124
115
|
perp,
|
|
125
116
|
pointOnArc,
|
|
126
|
-
|
|
117
|
+
printColorMapper,
|
|
127
118
|
remapBlockInputRefs,
|
|
128
119
|
renderDashes,
|
|
129
120
|
resolveDocumentObject,
|
|
130
|
-
resolveFont,
|
|
131
121
|
resolveHatchPattern,
|
|
132
122
|
resolveLineType,
|
|
133
123
|
rgbToHex,
|
|
@@ -155,7 +145,23 @@ import {
|
|
|
155
145
|
valueParams,
|
|
156
146
|
verticesToLoop,
|
|
157
147
|
withEmptyLists
|
|
158
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-BQHN5HQY.js";
|
|
149
|
+
import {
|
|
150
|
+
ADVANCE_TABLES,
|
|
151
|
+
EXTRACTED_EXTRAS,
|
|
152
|
+
EXTRACTED_RANGES,
|
|
153
|
+
FONTS,
|
|
154
|
+
REAL_FACES,
|
|
155
|
+
approximateTextMeasurer,
|
|
156
|
+
fontFace,
|
|
157
|
+
fontFromDxfStyle,
|
|
158
|
+
fontTextMeasurer,
|
|
159
|
+
hasFontFile,
|
|
160
|
+
measureFace,
|
|
161
|
+
parseFontFace,
|
|
162
|
+
realFace,
|
|
163
|
+
resolveFont
|
|
164
|
+
} from "./chunk-L7VHB7FJ.js";
|
|
159
165
|
|
|
160
166
|
// ../core/src/model/scale.ts
|
|
161
167
|
var parseScale = (scale2) => {
|
|
@@ -229,7 +235,7 @@ var SvgSink = class {
|
|
|
229
235
|
objectStart = null;
|
|
230
236
|
minStroke;
|
|
231
237
|
constructor(opts = {}) {
|
|
232
|
-
this.measurer = opts.measure ??
|
|
238
|
+
this.measurer = opts.measure ?? fontTextMeasurer;
|
|
233
239
|
this.minStroke = opts.minStrokeWidthMm ?? 0;
|
|
234
240
|
}
|
|
235
241
|
/** Transformed + Y-flipped point, as an "x y" token. */
|
|
@@ -336,7 +342,7 @@ var SvgSink = class {
|
|
|
336
342
|
const rot = transforms.length > 0 ? ` transform="${transforms.join(" ")}"` : "";
|
|
337
343
|
const alpha = t.opacity !== void 0 && t.opacity < 1 ? ` fill-opacity="${n(t.opacity)}"` : "";
|
|
338
344
|
this.els.push(
|
|
339
|
-
`<text x="${n(tp.x)}" y="${n(-tp.y)}" font-size="${n(t.heightMm / def.capHeight * scale2)}" font-family="${def.cssStack}"${face} fill="${t.color}"${alpha} text-anchor="${anchor}"${rot}>${escapeXml(t.text)}</text>`
|
|
345
|
+
`<text x="${n(tp.x)}" y="${n(-tp.y)}" font-size="${n(t.heightMm / def.capHeight * scale2)}" font-family="${def.cssStack}"${face} style="font-kerning:none" fill="${t.color}"${alpha} text-anchor="${anchor}"${rot}>${escapeXml(t.text)}</text>`
|
|
340
346
|
);
|
|
341
347
|
}
|
|
342
348
|
measureText(text, heightMm, font, widthFactor) {
|
|
@@ -636,12 +642,7 @@ var paintText = (obj, sink, env) => {
|
|
|
636
642
|
measureTextWidth: (text, heightMm) => sink.measureText(text, heightMm, font, widthFactor).width
|
|
637
643
|
};
|
|
638
644
|
const tabStopMeasure = {
|
|
639
|
-
measureTextWidth: (text, heightMm) =>
|
|
640
|
-
text,
|
|
641
|
-
heightMm,
|
|
642
|
-
font,
|
|
643
|
-
widthFactor
|
|
644
|
-
)
|
|
645
|
+
measureTextWidth: (text, heightMm) => fontTextMeasurer.measureTextWidth(text, heightMm, font, widthFactor)
|
|
645
646
|
};
|
|
646
647
|
const { color, widthMm, opacity } = env.style;
|
|
647
648
|
const arrowSize = textArrowSize(obj, env.textStyles);
|
|
@@ -840,7 +841,7 @@ var paintDimension = (obj, sink, env) => {
|
|
|
840
841
|
widthFactor: text.widthFactor ?? 1
|
|
841
842
|
},
|
|
842
843
|
sinkMeasurer(sink),
|
|
843
|
-
|
|
844
|
+
fontTextMeasurer
|
|
844
845
|
),
|
|
845
846
|
{
|
|
846
847
|
position: text.anchor,
|
|
@@ -2996,7 +2997,8 @@ var scanTags = (lines) => {
|
|
|
2996
2997
|
dimOverridesByHandle: /* @__PURE__ */ new Map(),
|
|
2997
2998
|
textHeightsByStyle: /* @__PURE__ */ new Map(),
|
|
2998
2999
|
splineWeightsByHandle: /* @__PURE__ */ new Map(),
|
|
2999
|
-
mtextLineSpacingByHandle: /* @__PURE__ */ new Map()
|
|
3000
|
+
mtextLineSpacingByHandle: /* @__PURE__ */ new Map(),
|
|
3001
|
+
mtextByHandle: /* @__PURE__ */ new Map()
|
|
3000
3002
|
};
|
|
3001
3003
|
const hex24 = (value) => {
|
|
3002
3004
|
const v = Number(value);
|
|
@@ -3128,6 +3130,11 @@ var scanTags = (lines) => {
|
|
|
3128
3130
|
} else if (code === "44" && type === "MTEXT") {
|
|
3129
3131
|
const v = Number(value);
|
|
3130
3132
|
if (v > 0) out.mtextLineSpacingByHandle.set(handle, v);
|
|
3133
|
+
} else if ((code === "3" || code === "1") && type === "MTEXT") {
|
|
3134
|
+
out.mtextByHandle.set(
|
|
3135
|
+
handle,
|
|
3136
|
+
(out.mtextByHandle.get(handle) ?? "") + lines[i + 1]
|
|
3137
|
+
);
|
|
3131
3138
|
}
|
|
3132
3139
|
}
|
|
3133
3140
|
}
|
|
@@ -3449,7 +3456,11 @@ var dimStyleOf = (e, ctx) => {
|
|
|
3449
3456
|
const id = name ? ctx.dimStyleIdByName.get(name.toLowerCase()) : void 0;
|
|
3450
3457
|
const style = id ? ctx.dimStyleById.get(id) : void 0;
|
|
3451
3458
|
if (id && style)
|
|
3452
|
-
return {
|
|
3459
|
+
return {
|
|
3460
|
+
id,
|
|
3461
|
+
style,
|
|
3462
|
+
scale: ctx.dimScaleByName.get(name.toLowerCase()) ?? 1
|
|
3463
|
+
};
|
|
3453
3464
|
return { style: ctx.defaultDimStyle, scale: ctx.dimScale };
|
|
3454
3465
|
};
|
|
3455
3466
|
var dimStyleRef = (e, ctx) => {
|
|
@@ -3544,7 +3555,10 @@ var convertMultiLeader = (e, ctx) => {
|
|
|
3544
3555
|
];
|
|
3545
3556
|
};
|
|
3546
3557
|
var legacyDim = (raw) => [
|
|
3547
|
-
|
|
3558
|
+
{
|
|
3559
|
+
labels: [],
|
|
3560
|
+
...dimensionRawToLabels(dimensionRawToOffset(raw))
|
|
3561
|
+
}
|
|
3548
3562
|
];
|
|
3549
3563
|
var convertDimension = (e, dxf, ctx) => {
|
|
3550
3564
|
const anyE = e;
|
|
@@ -3857,6 +3871,7 @@ var convertEntityInner = (e, dxf, ctx) => {
|
|
|
3857
3871
|
];
|
|
3858
3872
|
}
|
|
3859
3873
|
case "MTEXT": {
|
|
3874
|
+
const text = ctx.tags.mtextByHandle.get(String(anyE.handle)) ?? anyE.text ?? "";
|
|
3860
3875
|
const ap = anyE.attachmentPoint ?? 1;
|
|
3861
3876
|
const hAlign = ["left", "center", "right"][(ap - 1) % 3];
|
|
3862
3877
|
const vAlign = ap <= 3 ? "top" : ap <= 6 ? "center" : "bottom";
|
|
@@ -3864,10 +3879,7 @@ var convertEntityInner = (e, dxf, ctx) => {
|
|
|
3864
3879
|
const rotation = ocsAngle(
|
|
3865
3880
|
dv && (dv.x !== 0 || dv.y !== 0) ? Math.atan2(dv.y, dv.x) : (anyE.rotation ?? 0) * DEG2RAD
|
|
3866
3881
|
);
|
|
3867
|
-
const rich = cleanRichText(
|
|
3868
|
-
anyE.text ?? "",
|
|
3869
|
-
anyE.height > 0 ? anyE.height : 2.5
|
|
3870
|
-
);
|
|
3882
|
+
const rich = cleanRichText(text, anyE.height > 0 ? anyE.height : 2.5);
|
|
3871
3883
|
return [
|
|
3872
3884
|
{
|
|
3873
3885
|
type: "text",
|
|
@@ -3885,8 +3897,8 @@ var convertEntityInner = (e, dxf, ctx) => {
|
|
|
3885
3897
|
// (cleanText strips them) as overrides where they differ.
|
|
3886
3898
|
...textStyleRef(e, ctx, {
|
|
3887
3899
|
textHeight: (anyE.height > 0 ? anyE.height : 2.5) * f,
|
|
3888
|
-
widthFactor: mtextWidthFactor(
|
|
3889
|
-
...mtextFontFlags(
|
|
3900
|
+
widthFactor: mtextWidthFactor(text),
|
|
3901
|
+
...mtextFontFlags(text),
|
|
3890
3902
|
...mtextLineSpacing(e, ctx)
|
|
3891
3903
|
}),
|
|
3892
3904
|
...base
|
|
@@ -4520,22 +4532,33 @@ var dxfToModel = (text, input) => {
|
|
|
4520
4532
|
if (adopt && currentDim) usedDimStyles.add(currentDim.toLowerCase());
|
|
4521
4533
|
const incomingDim = [];
|
|
4522
4534
|
const dimScaleByName = /* @__PURE__ */ new Map();
|
|
4535
|
+
const dimRecord = (key) => [...tags.dimStyles.values()].find((r) => r.name.toLowerCase() === key);
|
|
4536
|
+
const dimAlias = /* @__PURE__ */ new Map();
|
|
4523
4537
|
for (const key of usedDimStyles) {
|
|
4524
|
-
const
|
|
4525
|
-
|
|
4526
|
-
);
|
|
4538
|
+
const baseKey = /^(.+)_\d+$/.exec(key)?.[1];
|
|
4539
|
+
const rec = dimRecord(key);
|
|
4540
|
+
const base = baseKey ? dimRecord(baseKey) : void 0;
|
|
4541
|
+
if (!rec || !base || !baseKey) continue;
|
|
4542
|
+
const a = dimStyleFromRecord(rec, headerDim, dimValueCtx);
|
|
4543
|
+
const b = dimStyleFromRecord(base, headerDim, dimValueCtx);
|
|
4544
|
+
if (sameDimStyle(a.values, b.values)) dimAlias.set(key, baseKey);
|
|
4545
|
+
}
|
|
4546
|
+
for (const base of dimAlias.values()) usedDimStyles.add(base);
|
|
4547
|
+
for (const key of usedDimStyles) {
|
|
4548
|
+
const rec = dimRecord(key);
|
|
4527
4549
|
if (!rec) continue;
|
|
4528
4550
|
const { values, scale: scale2 } = dimStyleFromRecord(rec, headerDim, dimValueCtx);
|
|
4529
|
-
incomingDim.push({ name: rec.name, values });
|
|
4551
|
+
if (!dimAlias.has(key)) incomingDim.push({ name: rec.name, values });
|
|
4530
4552
|
dimScaleByName.set(key, scale2);
|
|
4531
4553
|
}
|
|
4532
4554
|
const mergedDim = mergeStyles(existingDim, incomingDim, sameDimStyle, {
|
|
4533
4555
|
adopt,
|
|
4534
4556
|
current: currentDim
|
|
4535
4557
|
});
|
|
4536
|
-
const
|
|
4537
|
-
|
|
4538
|
-
|
|
4558
|
+
for (const [key, base] of dimAlias) {
|
|
4559
|
+
const id = mergedDim.idByName.get(base);
|
|
4560
|
+
if (id) mergedDim.idByName.set(key, id);
|
|
4561
|
+
}
|
|
4539
4562
|
const customLineTypes = {
|
|
4540
4563
|
customLineTypes: /* @__PURE__ */ new Map(),
|
|
4541
4564
|
usedLineTypes: /* @__PURE__ */ new Map()
|
|
@@ -4606,7 +4629,7 @@ var dxfToModel = (text, input) => {
|
|
|
4606
4629
|
dimStyleById: new Map(mergedDim.styles.map((s) => [s.id, s])),
|
|
4607
4630
|
textStyleIdByName: mergedText.idByName,
|
|
4608
4631
|
dimStyleIdByName: mergedDim.idByName,
|
|
4609
|
-
|
|
4632
|
+
dimScaleByName,
|
|
4610
4633
|
defaultTextStyle: mergedText.styles[0] ?? DEFAULT_TEXT_STYLE,
|
|
4611
4634
|
defaultDimStyle: mergedDim.styles[0] ?? DEFAULT_DIM_STYLE,
|
|
4612
4635
|
dimValuesFrom: (groups) => dimValuesFromGroups(groups, dimValueCtx),
|
|
@@ -5983,29 +6006,6 @@ var paintLayoutContent = (layout, sink, model, opts = {}) => {
|
|
|
5983
6006
|
paintLayoutAnnotations(layout, sink, model, opts);
|
|
5984
6007
|
};
|
|
5985
6008
|
|
|
5986
|
-
// ../core/src/paint/printPalette.ts
|
|
5987
|
-
var luminance = (r, g, b) => (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
|
5988
|
-
var grayHex = (level) => {
|
|
5989
|
-
const v = Math.round(Math.min(Math.max(level, 0), 1) * 255).toString(16).padStart(2, "0");
|
|
5990
|
-
return `#${v}${v}${v}`;
|
|
5991
|
-
};
|
|
5992
|
-
var printColorMapper = (palette) => (hex) => {
|
|
5993
|
-
const rgb = hexToRgb(hex);
|
|
5994
|
-
if (!rgb) return hex;
|
|
5995
|
-
const [r, g, b] = rgb;
|
|
5996
|
-
const lum = luminance(r, g, b);
|
|
5997
|
-
switch (palette) {
|
|
5998
|
-
case "color": {
|
|
5999
|
-
const saturation = (Math.max(r, g, b) - Math.min(r, g, b)) / 255;
|
|
6000
|
-
return lum > 0.75 && saturation < 0.25 ? "#000000" : hex;
|
|
6001
|
-
}
|
|
6002
|
-
case "grayscale":
|
|
6003
|
-
return grayHex(Math.min(1 - lum, 0.75));
|
|
6004
|
-
case "monochrome":
|
|
6005
|
-
return "#000000";
|
|
6006
|
-
}
|
|
6007
|
-
};
|
|
6008
|
-
|
|
6009
6009
|
// ../core/src/operations/diff.ts
|
|
6010
6010
|
var sameJson = (a, b) => a === b || JSON.stringify(a) === JSON.stringify(b);
|
|
6011
6011
|
var diffById = (prev, next) => {
|
|
@@ -6330,7 +6330,7 @@ var DWG_VERSIONS = [
|
|
|
6330
6330
|
"AC1032"
|
|
6331
6331
|
// AutoCAD 2018
|
|
6332
6332
|
];
|
|
6333
|
-
var loadDwg = () => import("./node-
|
|
6333
|
+
var loadDwg = () => import("./node-FWKE5ULH.js").then((m) => m.loadDwg());
|
|
6334
6334
|
var dwgToDxf = async (data) => {
|
|
6335
6335
|
const { dwg_to_dxf } = await loadDwg();
|
|
6336
6336
|
return dwg_to_dxf(data);
|
|
@@ -6612,6 +6612,15 @@ var PdfSink = class {
|
|
|
6612
6612
|
this.doc.restoreGraphicsState();
|
|
6613
6613
|
}
|
|
6614
6614
|
measureText(text, heightMm, font, widthFactor = 1) {
|
|
6615
|
+
if (hasFontFile(measureFace(font)))
|
|
6616
|
+
return {
|
|
6617
|
+
width: fontTextMeasurer.measureTextWidth(
|
|
6618
|
+
text,
|
|
6619
|
+
heightMm,
|
|
6620
|
+
font,
|
|
6621
|
+
widthFactor
|
|
6622
|
+
)
|
|
6623
|
+
};
|
|
6615
6624
|
const { def, name } = this.pdfFace(font, text);
|
|
6616
6625
|
this.doc.setFont(name, "normal");
|
|
6617
6626
|
this.doc.setFontSize(heightMm / def.capHeight * PT_PER_MM);
|
|
@@ -6736,7 +6745,7 @@ var stripNonPrintLayers = (layouts, model) => {
|
|
|
6736
6745
|
}))
|
|
6737
6746
|
};
|
|
6738
6747
|
};
|
|
6739
|
-
|
|
6748
|
+
function* paintPages(printLayouts, printModel, fonts) {
|
|
6740
6749
|
const { layouts, model } = stripNonPrintLayers(printLayouts, printModel);
|
|
6741
6750
|
const first = layouts[0];
|
|
6742
6751
|
const pdf = new jsPDF({
|
|
@@ -6749,7 +6758,8 @@ var renderLayoutsToPdf = (printLayouts, printModel, fonts = []) => {
|
|
|
6749
6758
|
pdf.addFileToVFS(`${font.id}.ttf`, font.ttfBase64);
|
|
6750
6759
|
pdf.addFont(`${font.id}.ttf`, font.id, "normal");
|
|
6751
6760
|
}
|
|
6752
|
-
layouts.
|
|
6761
|
+
for (const [index, layout] of layouts.entries()) {
|
|
6762
|
+
yield index;
|
|
6753
6763
|
if (index > 0) {
|
|
6754
6764
|
pdf.addPage(
|
|
6755
6765
|
[layout.sheet.width, layout.sheet.height],
|
|
@@ -6762,13 +6772,20 @@ var renderLayoutsToPdf = (printLayouts, printModel, fonts = []) => {
|
|
|
6762
6772
|
mapColor: printColorMapper(layout.printPalette)
|
|
6763
6773
|
});
|
|
6764
6774
|
});
|
|
6765
|
-
}
|
|
6775
|
+
}
|
|
6766
6776
|
return pdf;
|
|
6777
|
+
}
|
|
6778
|
+
var renderLayoutsToPdf = (printLayouts, printModel, fonts = []) => {
|
|
6779
|
+
const pages = paintPages(printLayouts, printModel, fonts);
|
|
6780
|
+
for (; ; ) {
|
|
6781
|
+
const next = pages.next();
|
|
6782
|
+
if (next.done) return next.value;
|
|
6783
|
+
}
|
|
6767
6784
|
};
|
|
6768
6785
|
|
|
6769
6786
|
// ../core/src/export/svg/renderSvg.ts
|
|
6770
6787
|
var renderModelToSvg = (model, opts = {}) => {
|
|
6771
|
-
const measure = opts.measure ??
|
|
6788
|
+
const measure = opts.measure ?? fontTextMeasurer;
|
|
6772
6789
|
const mapColor = opts.palette ? printColorMapper(opts.palette) : (c) => c;
|
|
6773
6790
|
const layerVisible = new Map(model.layers.map((l) => [l.id, l.visible]));
|
|
6774
6791
|
const layerName = new Map(model.layers.map((l) => [l.id, l.name]));
|
|
@@ -8409,8 +8426,8 @@ import { z as z7 } from "zod";
|
|
|
8409
8426
|
var DrawingError = class extends Error {
|
|
8410
8427
|
code;
|
|
8411
8428
|
issues;
|
|
8412
|
-
constructor(code, message, issues) {
|
|
8413
|
-
super(message);
|
|
8429
|
+
constructor(code, message, issues, options) {
|
|
8430
|
+
super(message, options);
|
|
8414
8431
|
this.code = code;
|
|
8415
8432
|
if (issues) this.issues = issues;
|
|
8416
8433
|
}
|
|
@@ -8619,7 +8636,6 @@ var wrapZod = (e, context) => {
|
|
|
8619
8636
|
e.issues
|
|
8620
8637
|
);
|
|
8621
8638
|
};
|
|
8622
|
-
var PDF_PAGE_GAP_MM = 50;
|
|
8623
8639
|
var selectPdfLayouts = (layouts, opts, fallback) => {
|
|
8624
8640
|
const byRef = (ref) => {
|
|
8625
8641
|
const l = layouts.find((x) => x.name === ref || x.id === ref);
|
|
@@ -8994,7 +9010,9 @@ var LocalDrawing = class {
|
|
|
8994
9010
|
} catch (e) {
|
|
8995
9011
|
throw new DrawingError(
|
|
8996
9012
|
"invalidDxf",
|
|
8997
|
-
`Not a readable DXF file: ${e instanceof Error ? e.message : String(e)}
|
|
9013
|
+
`Not a readable DXF file: ${e instanceof Error ? e.message : String(e)}`,
|
|
9014
|
+
void 0,
|
|
9015
|
+
{ cause: e }
|
|
8998
9016
|
);
|
|
8999
9017
|
}
|
|
9000
9018
|
const { ops, objects } = dxfImportOps(doc, result);
|
|
@@ -9022,43 +9040,44 @@ var LocalDrawing = class {
|
|
|
9022
9040
|
} catch (e) {
|
|
9023
9041
|
throw new DrawingError(
|
|
9024
9042
|
"invalidDwg",
|
|
9025
|
-
`Not a readable DWG file: ${e instanceof Error ? e.message : String(e)}
|
|
9043
|
+
`Not a readable DWG file: ${e instanceof Error ? e.message : String(e)}`,
|
|
9044
|
+
void 0,
|
|
9045
|
+
{ cause: e }
|
|
9026
9046
|
);
|
|
9027
9047
|
}
|
|
9028
9048
|
return this.importDxfText(dxf, opts);
|
|
9029
9049
|
}
|
|
9030
9050
|
/** Merge a PDF: its vector/text content onto the current layer, or
|
|
9031
|
-
* (`as: "image"`) embedded,
|
|
9032
|
-
* scale. */
|
|
9051
|
+
* (`as: "image"`) embedded, its first page a raster reference at true
|
|
9052
|
+
* page scale (`pdfPage` on the reference switches it). */
|
|
9033
9053
|
async importPdfData(data, opts = {}) {
|
|
9034
9054
|
if (opts.as === "image") {
|
|
9035
9055
|
if (!this.rasterizePdf)
|
|
9036
9056
|
throw new Error(
|
|
9037
9057
|
'PDF as image is not available on this host yet; import it with as: "vectors"'
|
|
9038
9058
|
);
|
|
9039
|
-
const
|
|
9059
|
+
const [first] = await this.rasterizePdf(data, 1);
|
|
9040
9060
|
const at = toVec(opts.origin ?? [0, 0]);
|
|
9041
|
-
const layerId2 = this.state.currentLayerId;
|
|
9042
9061
|
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
9043
9062
|
const assetId = this.addAsset(bytesToDataUrl(bytes, "application/pdf"));
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
const object = {
|
|
9063
|
+
const objectIds2 = this.add([
|
|
9064
|
+
{
|
|
9047
9065
|
type: "reference",
|
|
9048
|
-
layerId:
|
|
9066
|
+
layerId: this.state.currentLayerId,
|
|
9049
9067
|
format: "pdf",
|
|
9050
|
-
name:
|
|
9068
|
+
name: "PDF",
|
|
9051
9069
|
source: { kind: "asset", assetId },
|
|
9052
|
-
pdfPage: i + 1,
|
|
9053
9070
|
pdfMode: "raster",
|
|
9054
|
-
position:
|
|
9055
|
-
extent: {
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9071
|
+
position: at,
|
|
9072
|
+
extent: {
|
|
9073
|
+
minX: 0,
|
|
9074
|
+
minY: 0,
|
|
9075
|
+
maxX: first.widthMm,
|
|
9076
|
+
maxY: first.heightMm
|
|
9077
|
+
}
|
|
9078
|
+
}
|
|
9079
|
+
]);
|
|
9080
|
+
return { objects: 1, pageCount: first.pageCount, objectIds: objectIds2 };
|
|
9062
9081
|
}
|
|
9063
9082
|
const result = await this.convertPdf(data);
|
|
9064
9083
|
const layerId = this.state.currentLayerId;
|
|
@@ -9796,7 +9815,7 @@ var LocalDrawing = class {
|
|
|
9796
9815
|
}
|
|
9797
9816
|
// --- reads ---------------------------------------------------------------
|
|
9798
9817
|
get measurer() {
|
|
9799
|
-
return this.hooks.measure ??
|
|
9818
|
+
return this.hooks.measure ?? fontTextMeasurer;
|
|
9800
9819
|
}
|
|
9801
9820
|
resolveObject() {
|
|
9802
9821
|
return this.hooks.resolveObject ?? documentObjectResolver(this.state);
|
|
@@ -9980,7 +9999,7 @@ var LocalDrawing = class {
|
|
|
9980
9999
|
}
|
|
9981
10000
|
/** Export the document to a DXF string. */
|
|
9982
10001
|
async toDxf() {
|
|
9983
|
-
const { buildDxf } = await import("./exportDxf-
|
|
10002
|
+
const { buildDxf } = await import("./exportDxf-HQT4JPUQ.js");
|
|
9984
10003
|
return buildDxf(this.state, this.measurer).content;
|
|
9985
10004
|
}
|
|
9986
10005
|
/** Export the document to DWG bytes (the DXF content, wasm-transcoded).
|
|
@@ -9995,7 +10014,7 @@ var LocalDrawing = class {
|
|
|
9995
10014
|
"unknownDwgVersion",
|
|
9996
10015
|
`Unknown DWG version "${String(version)}" (one of ${DWG_VERSIONS.join(", ")})`
|
|
9997
10016
|
);
|
|
9998
|
-
const { buildDxf, DWG_DXF_OPTIONS } = await import("./exportDxf-
|
|
10017
|
+
const { buildDxf, DWG_DXF_OPTIONS } = await import("./exportDxf-HQT4JPUQ.js");
|
|
9999
10018
|
const dxf = buildDxf(this.state, this.measurer, DWG_DXF_OPTIONS).content;
|
|
10000
10019
|
return dxfToDwg(dxf, version);
|
|
10001
10020
|
}
|
|
@@ -10178,4 +10197,3 @@ export {
|
|
|
10178
10197
|
runCommandModule,
|
|
10179
10198
|
runDocumentCommand
|
|
10180
10199
|
};
|
|
10181
|
-
//# sourceMappingURL=chunk-ZQLBHWCD.js.map
|