@tscircuit/pcb-viewer 1.3.13 → 1.4.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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +160 -48
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 tscircuit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { LayerRef
|
|
2
|
+
import { LayerRef } from '@tscircuit/builder';
|
|
3
|
+
import { AnySoupElement } from '@tscircuit/soup';
|
|
3
4
|
import { Matrix } from 'transformation-matrix';
|
|
4
5
|
|
|
5
6
|
type EditComponentLocationEvent = {
|
package/dist/index.js
CHANGED
|
@@ -976,6 +976,18 @@ var drawCircle = function(drawer, circle) {
|
|
|
976
976
|
});
|
|
977
977
|
drawer.circle(circle.x, circle.y, circle.r);
|
|
978
978
|
};
|
|
979
|
+
var drawOval = function(drawer, oval) {
|
|
980
|
+
drawer.equip({
|
|
981
|
+
color: oval.layer
|
|
982
|
+
});
|
|
983
|
+
drawer.oval(oval.x, oval.y, oval.rX, oval.rY);
|
|
984
|
+
};
|
|
985
|
+
var drawPill = function(drawer, pill) {
|
|
986
|
+
drawer.equip({
|
|
987
|
+
color: pill.layer
|
|
988
|
+
});
|
|
989
|
+
drawer.pill(pill.x, pill.y, pill.w, pill.h);
|
|
990
|
+
};
|
|
979
991
|
var drawPrimitive = function(drawer, primitive) {
|
|
980
992
|
switch(primitive.pcb_drawing_type){
|
|
981
993
|
case "line":
|
|
@@ -986,8 +998,11 @@ var drawPrimitive = function(drawer, primitive) {
|
|
|
986
998
|
return drawRect(drawer, primitive);
|
|
987
999
|
case "circle":
|
|
988
1000
|
return drawCircle(drawer, primitive);
|
|
1001
|
+
case "oval":
|
|
1002
|
+
return drawOval(drawer, primitive);
|
|
1003
|
+
case "pill":
|
|
1004
|
+
return drawPill(drawer, primitive);
|
|
989
1005
|
}
|
|
990
|
-
throw new Error("Unknown primitive type: ".concat(primitive.pcb_drawing_type));
|
|
991
1006
|
};
|
|
992
1007
|
var drawPrimitives = function(drawer, primitives) {
|
|
993
1008
|
primitives.sort(function(a, b) {
|
|
@@ -1372,6 +1387,44 @@ var Drawer = /*#__PURE__*/ function() {
|
|
|
1372
1387
|
ctx.closePath();
|
|
1373
1388
|
}
|
|
1374
1389
|
},
|
|
1390
|
+
{
|
|
1391
|
+
key: "oval",
|
|
1392
|
+
value: function oval(x, y, rx, ry) {
|
|
1393
|
+
var rx$ = scaleOnly(this.transform, rx);
|
|
1394
|
+
var ry$ = scaleOnly(this.transform, ry);
|
|
1395
|
+
var _ref = _sliced_to_array((0, import_transformation_matrix.applyToPoint)(this.transform, [
|
|
1396
|
+
x,
|
|
1397
|
+
y
|
|
1398
|
+
]), 2), x$ = _ref[0], y$ = _ref[1];
|
|
1399
|
+
this.applyAperture();
|
|
1400
|
+
var ctx = this.getLayerCtx();
|
|
1401
|
+
ctx.beginPath();
|
|
1402
|
+
ctx.ellipse(x$, y$, rx$, ry$, 0, 0, 2 * Math.PI);
|
|
1403
|
+
ctx.fill();
|
|
1404
|
+
ctx.closePath();
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
key: "pill",
|
|
1409
|
+
value: function pill(x, y, w, h) {
|
|
1410
|
+
var _ref = _sliced_to_array((0, import_transformation_matrix.applyToPoint)(this.transform, [
|
|
1411
|
+
x - w / 2,
|
|
1412
|
+
y + h / 2
|
|
1413
|
+
]), 2), x$ = _ref[0], y$ = _ref[1];
|
|
1414
|
+
var width$ = scaleOnly(this.transform, w);
|
|
1415
|
+
var height$ = scaleOnly(this.transform, h);
|
|
1416
|
+
var radius = Math.min(width$, height$) / 2;
|
|
1417
|
+
this.applyAperture();
|
|
1418
|
+
var ctx = this.getLayerCtx();
|
|
1419
|
+
ctx.beginPath();
|
|
1420
|
+
ctx.arc(x$ + radius, y$ + radius, radius, Math.PI, Math.PI * 1.5);
|
|
1421
|
+
ctx.arc(x$ + width$ - radius, y$ + radius, radius, Math.PI * 1.5, 0);
|
|
1422
|
+
ctx.arc(x$ + width$ - radius, y$ + height$ - radius, radius, 0, Math.PI * 0.5);
|
|
1423
|
+
ctx.arc(x$ + radius, y$ + height$ - radius, radius, Math.PI * 0.5, Math.PI);
|
|
1424
|
+
ctx.fill();
|
|
1425
|
+
ctx.closePath();
|
|
1426
|
+
}
|
|
1427
|
+
},
|
|
1375
1428
|
{
|
|
1376
1429
|
/* NOTE: This is not gerber compatible */ key: "debugText",
|
|
1377
1430
|
value: function debugText(text, x, y) {
|
|
@@ -1725,48 +1778,81 @@ var convertElementToPrimitives = function(element, allElements) {
|
|
|
1725
1778
|
}
|
|
1726
1779
|
];
|
|
1727
1780
|
}
|
|
1781
|
+
return [];
|
|
1728
1782
|
}
|
|
1729
1783
|
case "pcb_hole":
|
|
1730
1784
|
{
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1785
|
+
if (element.hole_shape === "round" || !element.hole_shape) {
|
|
1786
|
+
var x2 = element.x, y2 = element.y, hole_diameter = element.hole_diameter;
|
|
1787
|
+
return [
|
|
1788
|
+
{
|
|
1789
|
+
pcb_drawing_type: "circle",
|
|
1790
|
+
x: x2,
|
|
1791
|
+
y: y2,
|
|
1792
|
+
r: hole_diameter / 2,
|
|
1793
|
+
layer: "drill",
|
|
1794
|
+
_element: element,
|
|
1795
|
+
_parent_pcb_component: _parent_pcb_component,
|
|
1796
|
+
_parent_source_component: _parent_source_component
|
|
1797
|
+
}
|
|
1798
|
+
];
|
|
1799
|
+
}
|
|
1800
|
+
return [];
|
|
1744
1801
|
}
|
|
1745
1802
|
case "pcb_plated_hole":
|
|
1746
1803
|
{
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1804
|
+
if (element.shape === "circle") {
|
|
1805
|
+
var x3 = element.x, y3 = element.y, hole_diameter1 = element.hole_diameter, outer_diameter = element.outer_diameter;
|
|
1806
|
+
return [
|
|
1807
|
+
{
|
|
1808
|
+
pcb_drawing_type: "circle",
|
|
1809
|
+
x: x3,
|
|
1810
|
+
y: y3,
|
|
1811
|
+
r: outer_diameter / 2,
|
|
1812
|
+
// TODO support layer on pcb_plated_hole
|
|
1813
|
+
layer: "top",
|
|
1814
|
+
_element: element,
|
|
1815
|
+
_parent_pcb_component: _parent_pcb_component,
|
|
1816
|
+
_parent_source_component: _parent_source_component,
|
|
1817
|
+
_source_port: _source_port
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
pcb_drawing_type: "circle",
|
|
1821
|
+
x: x3,
|
|
1822
|
+
y: y3,
|
|
1823
|
+
r: hole_diameter1 / 2,
|
|
1824
|
+
// TODO support layer on pcb_plated_hole
|
|
1825
|
+
layer: "drill"
|
|
1826
|
+
}
|
|
1827
|
+
];
|
|
1828
|
+
} else if (element.shape === "oval") {
|
|
1829
|
+
var x4 = element.x, y4 = element.y, outer_height = element.outer_height, outer_width = element.outer_width, hole_height = element.hole_height, hole_width = element.hole_width, layers = element.layers;
|
|
1830
|
+
return [
|
|
1831
|
+
{
|
|
1832
|
+
pcb_drawing_type: "oval",
|
|
1833
|
+
x: x4,
|
|
1834
|
+
y: y4,
|
|
1835
|
+
rX: outer_width / 2,
|
|
1836
|
+
rY: outer_height / 2,
|
|
1837
|
+
layer: "top",
|
|
1838
|
+
// TODO: Confirm layer handling for oval plated holes
|
|
1839
|
+
_element: element,
|
|
1840
|
+
_parent_pcb_component: _parent_pcb_component,
|
|
1841
|
+
_parent_source_component: _parent_source_component,
|
|
1842
|
+
_source_port: _source_port
|
|
1843
|
+
},
|
|
1844
|
+
{
|
|
1845
|
+
pcb_drawing_type: "oval",
|
|
1846
|
+
x: x4,
|
|
1847
|
+
y: y4,
|
|
1848
|
+
rX: hole_width / 2,
|
|
1849
|
+
rY: hole_height / 2,
|
|
1850
|
+
layer: "drill"
|
|
1851
|
+
}
|
|
1852
|
+
];
|
|
1853
|
+
} else {
|
|
1854
|
+
return [];
|
|
1855
|
+
}
|
|
1770
1856
|
}
|
|
1771
1857
|
case "pcb_trace":
|
|
1772
1858
|
{
|
|
@@ -1812,12 +1898,12 @@ var convertElementToPrimitives = function(element, allElements) {
|
|
|
1812
1898
|
}
|
|
1813
1899
|
case "pcb_via":
|
|
1814
1900
|
{
|
|
1815
|
-
var
|
|
1901
|
+
var x5 = element.x, y5 = element.y, outer_diameter1 = element.outer_diameter, hole_diameter2 = element.hole_diameter, from_layer = element.from_layer, to_layer = element.to_layer;
|
|
1816
1902
|
return [
|
|
1817
1903
|
{
|
|
1818
1904
|
pcb_drawing_type: "circle",
|
|
1819
|
-
x:
|
|
1820
|
-
y:
|
|
1905
|
+
x: x5,
|
|
1906
|
+
y: y5,
|
|
1821
1907
|
r: outer_diameter1 / 2,
|
|
1822
1908
|
layer: from_layer,
|
|
1823
1909
|
_element: element,
|
|
@@ -1826,8 +1912,8 @@ var convertElementToPrimitives = function(element, allElements) {
|
|
|
1826
1912
|
},
|
|
1827
1913
|
{
|
|
1828
1914
|
pcb_drawing_type: "circle",
|
|
1829
|
-
x:
|
|
1830
|
-
y:
|
|
1915
|
+
x: x5,
|
|
1916
|
+
y: y5,
|
|
1831
1917
|
r: hole_diameter2 / 2,
|
|
1832
1918
|
layer: "drill",
|
|
1833
1919
|
_element: element,
|
|
@@ -1836,8 +1922,8 @@ var convertElementToPrimitives = function(element, allElements) {
|
|
|
1836
1922
|
},
|
|
1837
1923
|
{
|
|
1838
1924
|
pcb_drawing_type: "circle",
|
|
1839
|
-
x:
|
|
1840
|
-
y:
|
|
1925
|
+
x: x5,
|
|
1926
|
+
y: y5,
|
|
1841
1927
|
r: outer_diameter1 / 2,
|
|
1842
1928
|
layer: to_layer,
|
|
1843
1929
|
_element: element,
|
|
@@ -1871,6 +1957,32 @@ var convertElementToPrimitives = function(element, allElements) {
|
|
|
1871
1957
|
}
|
|
1872
1958
|
];
|
|
1873
1959
|
}
|
|
1960
|
+
case "pcb_silkscreen_oval":
|
|
1961
|
+
{
|
|
1962
|
+
return [
|
|
1963
|
+
{
|
|
1964
|
+
pcb_drawing_type: "oval",
|
|
1965
|
+
x: element.center.x,
|
|
1966
|
+
y: element.center.y,
|
|
1967
|
+
rX: element.radius_x / 2,
|
|
1968
|
+
rY: element.radius_y / 2,
|
|
1969
|
+
layer: element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen"
|
|
1970
|
+
}
|
|
1971
|
+
];
|
|
1972
|
+
}
|
|
1973
|
+
case "pcb_silkscreen_pill":
|
|
1974
|
+
{
|
|
1975
|
+
return [
|
|
1976
|
+
{
|
|
1977
|
+
pcb_drawing_type: "pill",
|
|
1978
|
+
x: element.center.x,
|
|
1979
|
+
y: element.center.y,
|
|
1980
|
+
w: element.width,
|
|
1981
|
+
h: element.height,
|
|
1982
|
+
layer: element.layer === "bottom" ? "bottom_silkscreen" : "top_silkscreen"
|
|
1983
|
+
}
|
|
1984
|
+
];
|
|
1985
|
+
}
|
|
1874
1986
|
case "pcb_silkscreen_line":
|
|
1875
1987
|
{
|
|
1876
1988
|
return [
|
|
@@ -2440,7 +2552,7 @@ var import_builder2 = require("@tscircuit/builder");
|
|
|
2440
2552
|
// package.json
|
|
2441
2553
|
var package_default = {
|
|
2442
2554
|
name: "@tscircuit/pcb-viewer",
|
|
2443
|
-
version: "1.3.
|
|
2555
|
+
version: "1.3.14",
|
|
2444
2556
|
main: "dist/index.js",
|
|
2445
2557
|
repository: "tscircuit/pcb-viewer",
|
|
2446
2558
|
license: "MIT",
|
|
@@ -2463,11 +2575,11 @@ var package_default = {
|
|
|
2463
2575
|
"@storybook/nextjs": "^8.0.6",
|
|
2464
2576
|
"@storybook/react": "^8.0.6",
|
|
2465
2577
|
"@swc/core": "^1.4.12",
|
|
2466
|
-
"@tscircuit/builder": "^1.5.
|
|
2578
|
+
"@tscircuit/builder": "^1.5.117",
|
|
2467
2579
|
"@tscircuit/eagle-xml-converter": "^0.0.6",
|
|
2468
2580
|
"@tscircuit/props": "^0.0.7",
|
|
2469
2581
|
"@tscircuit/react-fiber": "^1.1.25",
|
|
2470
|
-
"@tscircuit/soup": "^0.0.
|
|
2582
|
+
"@tscircuit/soup": "^0.0.33",
|
|
2471
2583
|
"@types/node": "18.7.23",
|
|
2472
2584
|
"@types/react": "^18.3.3",
|
|
2473
2585
|
next: "^14.1.4",
|
|
@@ -3527,7 +3639,7 @@ var PCBViewer = function(param) {
|
|
|
3527
3639
|
height: 1e-3
|
|
3528
3640
|
}, center = _ref.center, width = _ref.width, height2 = _ref.height;
|
|
3529
3641
|
var _elmBounds_width, _elmBounds_height;
|
|
3530
|
-
var scaleFactor = Math.min(((_elmBounds_width = elmBounds.width) !== null && _elmBounds_width !== void 0 ? _elmBounds_width : 0) / width, ((_elmBounds_height = elmBounds.height) !== null && _elmBounds_height !== void 0 ? _elmBounds_height : 0) / height2, 100);
|
|
3642
|
+
var scaleFactor = Math.min(((_elmBounds_width = elmBounds.width) !== null && _elmBounds_width !== void 0 ? _elmBounds_width : 0) / width, ((_elmBounds_height = elmBounds.height) !== null && _elmBounds_height !== void 0 ? _elmBounds_height : 0) / height2, 100) * 0.75;
|
|
3531
3643
|
var _elmBounds_width1, _elmBounds_height1;
|
|
3532
3644
|
setTransform((0, import_transformation_matrix8.compose)((0, import_transformation_matrix8.translate)(((_elmBounds_width1 = elmBounds.width) !== null && _elmBounds_width1 !== void 0 ? _elmBounds_width1 : 0) / 2, ((_elmBounds_height1 = elmBounds.height) !== null && _elmBounds_height1 !== void 0 ? _elmBounds_height1 : 0) / 2), // translate(100, 0),
|
|
3533
3645
|
(0, import_transformation_matrix8.scale)(scaleFactor, -scaleFactor, 0, 0), (0, import_transformation_matrix8.translate)(-center.x, -center.y)));
|