circuit-to-svg 0.0.286 → 0.0.287
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/index.js +44 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3791,7 +3791,9 @@ function createAnchorOffsetIndicators(params) {
|
|
|
3791
3791
|
componentPosition,
|
|
3792
3792
|
transform,
|
|
3793
3793
|
componentWidth = 0,
|
|
3794
|
-
componentHeight = 0
|
|
3794
|
+
componentHeight = 0,
|
|
3795
|
+
displayXOffset,
|
|
3796
|
+
displayYOffset
|
|
3795
3797
|
} = params;
|
|
3796
3798
|
const objects = [];
|
|
3797
3799
|
const [screenGroupAnchorX, screenGroupAnchorY] = applyToPoint22(transform, [
|
|
@@ -3857,7 +3859,8 @@ function createAnchorOffsetIndicators(params) {
|
|
|
3857
3859
|
endX: screenComponentX,
|
|
3858
3860
|
y: horizontalLineY,
|
|
3859
3861
|
offsetMm: offsetX,
|
|
3860
|
-
offsetY
|
|
3862
|
+
offsetY,
|
|
3863
|
+
displayOffset: displayXOffset
|
|
3861
3864
|
})
|
|
3862
3865
|
);
|
|
3863
3866
|
}
|
|
@@ -3868,7 +3871,8 @@ function createAnchorOffsetIndicators(params) {
|
|
|
3868
3871
|
startY: screenGroupAnchorY,
|
|
3869
3872
|
endY: screenComponentY,
|
|
3870
3873
|
offsetMm: offsetY,
|
|
3871
|
-
offsetX
|
|
3874
|
+
offsetX,
|
|
3875
|
+
displayOffset: displayYOffset
|
|
3872
3876
|
})
|
|
3873
3877
|
);
|
|
3874
3878
|
}
|
|
@@ -3922,7 +3926,8 @@ function createHorizontalDimension({
|
|
|
3922
3926
|
endX,
|
|
3923
3927
|
y,
|
|
3924
3928
|
offsetMm,
|
|
3925
|
-
offsetY
|
|
3929
|
+
offsetY,
|
|
3930
|
+
displayOffset
|
|
3926
3931
|
}) {
|
|
3927
3932
|
const objects = [];
|
|
3928
3933
|
objects.push({
|
|
@@ -3986,7 +3991,7 @@ function createHorizontalDimension({
|
|
|
3986
3991
|
children: [
|
|
3987
3992
|
{
|
|
3988
3993
|
type: "text",
|
|
3989
|
-
value:
|
|
3994
|
+
value: formatOffsetLabel("X", offsetMm, displayOffset),
|
|
3990
3995
|
name: "",
|
|
3991
3996
|
attributes: {},
|
|
3992
3997
|
children: []
|
|
@@ -4001,7 +4006,8 @@ function createVerticalDimension({
|
|
|
4001
4006
|
startY,
|
|
4002
4007
|
endY,
|
|
4003
4008
|
offsetMm,
|
|
4004
|
-
offsetX
|
|
4009
|
+
offsetX,
|
|
4010
|
+
displayOffset
|
|
4005
4011
|
}) {
|
|
4006
4012
|
const objects = [];
|
|
4007
4013
|
objects.push({
|
|
@@ -4065,7 +4071,7 @@ function createVerticalDimension({
|
|
|
4065
4071
|
children: [
|
|
4066
4072
|
{
|
|
4067
4073
|
type: "text",
|
|
4068
|
-
value:
|
|
4074
|
+
value: formatOffsetLabel("Y", offsetMm, displayOffset),
|
|
4069
4075
|
name: "",
|
|
4070
4076
|
attributes: {},
|
|
4071
4077
|
children: []
|
|
@@ -4075,6 +4081,13 @@ function createVerticalDimension({
|
|
|
4075
4081
|
});
|
|
4076
4082
|
return objects;
|
|
4077
4083
|
}
|
|
4084
|
+
function formatOffsetLabel(axis, offsetMm, displayOffset) {
|
|
4085
|
+
const baseValue = displayOffset ?? offsetMm.toFixed(2);
|
|
4086
|
+
const valueStr = typeof baseValue === "number" ? baseValue.toString() : baseValue;
|
|
4087
|
+
const hasUnit = typeof valueStr === "string" && valueStr.trim().endsWith("mm");
|
|
4088
|
+
const unitSuffix = hasUnit ? "" : "mm";
|
|
4089
|
+
return `${axis}: ${valueStr}${unitSuffix}`;
|
|
4090
|
+
}
|
|
4078
4091
|
|
|
4079
4092
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
4080
4093
|
function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
@@ -5363,18 +5376,18 @@ function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
|
5363
5376
|
const scaledHeight = height * Math.abs(transform.d);
|
|
5364
5377
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
5365
5378
|
const svgObjects = [];
|
|
5366
|
-
if (ctx.showAnchorOffsets && component.
|
|
5367
|
-
const
|
|
5368
|
-
|
|
5369
|
-
);
|
|
5370
|
-
if (pcbGroup?.center) {
|
|
5379
|
+
if (ctx.showAnchorOffsets && component.position_mode === "relative" && circuitJson) {
|
|
5380
|
+
const anchorPosition = getAnchorPosition(component, circuitJson);
|
|
5381
|
+
if (anchorPosition) {
|
|
5371
5382
|
svgObjects.push(
|
|
5372
5383
|
...createAnchorOffsetIndicators({
|
|
5373
|
-
groupAnchorPosition:
|
|
5384
|
+
groupAnchorPosition: anchorPosition,
|
|
5374
5385
|
componentPosition: center,
|
|
5375
5386
|
transform,
|
|
5376
5387
|
componentWidth: width,
|
|
5377
|
-
componentHeight: height
|
|
5388
|
+
componentHeight: height,
|
|
5389
|
+
displayXOffset: component.display_x_offset,
|
|
5390
|
+
displayYOffset: component.display_y_offset
|
|
5378
5391
|
})
|
|
5379
5392
|
);
|
|
5380
5393
|
}
|
|
@@ -5411,6 +5424,21 @@ function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
|
5411
5424
|
});
|
|
5412
5425
|
return svgObjects;
|
|
5413
5426
|
}
|
|
5427
|
+
function getAnchorPosition(component, circuitJson) {
|
|
5428
|
+
if (component.positioned_relative_to_pcb_group_id) {
|
|
5429
|
+
const pcbGroup = circuitJson.find(
|
|
5430
|
+
(elm) => elm.type === "pcb_group" && elm.pcb_group_id === component.positioned_relative_to_pcb_group_id
|
|
5431
|
+
);
|
|
5432
|
+
if (pcbGroup?.center) return pcbGroup.center;
|
|
5433
|
+
}
|
|
5434
|
+
if (component.positioned_relative_to_pcb_board_id) {
|
|
5435
|
+
const pcbBoard = circuitJson.find(
|
|
5436
|
+
(elm) => elm.type === "pcb_board" && elm.pcb_board_id === component.positioned_relative_to_pcb_board_id
|
|
5437
|
+
);
|
|
5438
|
+
if (pcbBoard?.center) return pcbBoard.center;
|
|
5439
|
+
}
|
|
5440
|
+
return void 0;
|
|
5441
|
+
}
|
|
5414
5442
|
|
|
5415
5443
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-group.ts
|
|
5416
5444
|
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
@@ -5502,7 +5530,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
5502
5530
|
var package_default = {
|
|
5503
5531
|
name: "circuit-to-svg",
|
|
5504
5532
|
type: "module",
|
|
5505
|
-
version: "0.0.
|
|
5533
|
+
version: "0.0.286",
|
|
5506
5534
|
description: "Convert Circuit JSON to SVG",
|
|
5507
5535
|
main: "dist/index.js",
|
|
5508
5536
|
files: [
|
|
@@ -5525,7 +5553,7 @@ var package_default = {
|
|
|
5525
5553
|
"@vitejs/plugin-react": "5.0.0",
|
|
5526
5554
|
biome: "^0.3.3",
|
|
5527
5555
|
"bun-match-svg": "^0.0.12",
|
|
5528
|
-
"circuit-json": "^0.0.
|
|
5556
|
+
"circuit-json": "^0.0.331",
|
|
5529
5557
|
esbuild: "^0.20.2",
|
|
5530
5558
|
"performance-now": "^2.1.0",
|
|
5531
5559
|
react: "19.1.0",
|