@tscircuit/core 0.0.320 → 0.0.322
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 +74 -51
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1823,8 +1823,55 @@ var Hole = class extends PrimitiveComponent {
|
|
|
1823
1823
|
}
|
|
1824
1824
|
};
|
|
1825
1825
|
|
|
1826
|
+
// lib/components/primitive-components/SilkscreenText.ts
|
|
1827
|
+
import { silkscreenTextProps } from "@tscircuit/props";
|
|
1828
|
+
var SilkscreenText = class extends PrimitiveComponent {
|
|
1829
|
+
isPcbPrimitive = true;
|
|
1830
|
+
get config() {
|
|
1831
|
+
return {
|
|
1832
|
+
componentName: "SilkscreenText",
|
|
1833
|
+
zodProps: silkscreenTextProps
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
doInitialPcbPrimitiveRender() {
|
|
1837
|
+
if (this.root?.pcbDisabled) return;
|
|
1838
|
+
const { db } = this.root;
|
|
1839
|
+
const { _parsedProps: props } = this;
|
|
1840
|
+
const container = this.getPrimitiveContainer();
|
|
1841
|
+
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1842
|
+
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
1843
|
+
const subcircuit = this.getSubcircuit();
|
|
1844
|
+
db.pcb_silkscreen_text.insert({
|
|
1845
|
+
anchor_alignment: props.anchorAlignment,
|
|
1846
|
+
anchor_position: {
|
|
1847
|
+
x: position.x,
|
|
1848
|
+
y: position.y
|
|
1849
|
+
},
|
|
1850
|
+
font: props.font ?? "tscircuit2024",
|
|
1851
|
+
font_size: props.fontSize ?? 1,
|
|
1852
|
+
layer: maybeFlipLayer(props.layer ?? "top"),
|
|
1853
|
+
text: props.text ?? "",
|
|
1854
|
+
ccw_rotation: props.pcbRotation,
|
|
1855
|
+
pcb_component_id: container.pcb_component_id,
|
|
1856
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1857
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
getPcbSize() {
|
|
1861
|
+
const { _parsedProps: props } = this;
|
|
1862
|
+
const fontSize = props.fontSize ?? 1;
|
|
1863
|
+
const text = props.text ?? "";
|
|
1864
|
+
const textWidth = text.length * fontSize;
|
|
1865
|
+
const textHeight = fontSize;
|
|
1866
|
+
return { width: textWidth * fontSize, height: textHeight * fontSize };
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
|
|
1826
1870
|
// lib/utils/createComponentsFromSoup.ts
|
|
1827
|
-
var createComponentsFromSoup = (
|
|
1871
|
+
var createComponentsFromSoup = ({
|
|
1872
|
+
componentName,
|
|
1873
|
+
componentRotation
|
|
1874
|
+
}, soup) => {
|
|
1828
1875
|
const components = [];
|
|
1829
1876
|
for (const elm of soup) {
|
|
1830
1877
|
if (elm.type === "pcb_smtpad" && elm.shape === "rect") {
|
|
@@ -1898,6 +1945,21 @@ var createComponentsFromSoup = (soup) => {
|
|
|
1898
1945
|
diameter: elm.hole_diameter
|
|
1899
1946
|
})
|
|
1900
1947
|
);
|
|
1948
|
+
} else if (elm.type === "pcb_silkscreen_text") {
|
|
1949
|
+
let readableRotation = componentRotation ? parseInt(componentRotation) : 0;
|
|
1950
|
+
const normalizedRotation = (readableRotation % 360 + 360) % 360;
|
|
1951
|
+
const isUpsideDown = normalizedRotation > 90 && normalizedRotation <= 270;
|
|
1952
|
+
readableRotation = isUpsideDown ? (normalizedRotation + 180) % 360 : normalizedRotation;
|
|
1953
|
+
components.push(
|
|
1954
|
+
new SilkscreenText({
|
|
1955
|
+
anchorAlignment: "center",
|
|
1956
|
+
text: componentName,
|
|
1957
|
+
fontSize: elm.font_size + 0.2,
|
|
1958
|
+
pcbX: isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
|
|
1959
|
+
pcbY: elm.anchor_position.y,
|
|
1960
|
+
pcbRotation: readableRotation ?? 0
|
|
1961
|
+
})
|
|
1962
|
+
);
|
|
1901
1963
|
}
|
|
1902
1964
|
}
|
|
1903
1965
|
return components;
|
|
@@ -1910,7 +1972,7 @@ function getBoundsOfPcbComponents(components) {
|
|
|
1910
1972
|
let maxX = -Infinity;
|
|
1911
1973
|
let maxY = -Infinity;
|
|
1912
1974
|
for (const child of components) {
|
|
1913
|
-
if (child.isPcbPrimitive) {
|
|
1975
|
+
if (child.isPcbPrimitive && child.componentName !== "SilkscreenText") {
|
|
1914
1976
|
const { x, y } = child._getGlobalPcbPositionBeforeLayout();
|
|
1915
1977
|
const { width: width2, height: height2 } = child.getPcbSize();
|
|
1916
1978
|
minX = Math.min(minX, x - width2 / 2);
|
|
@@ -3078,12 +3140,16 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3078
3140
|
return null;
|
|
3079
3141
|
}
|
|
3080
3142
|
_addChildrenFromStringFootprint() {
|
|
3143
|
+
const { name: componentName, pcbRotation: componentRotation } = this.props;
|
|
3081
3144
|
let { footprint } = this.props;
|
|
3082
3145
|
footprint ??= this._getImpliedFootprintString?.();
|
|
3083
3146
|
if (!footprint) return;
|
|
3084
3147
|
if (typeof footprint === "string") {
|
|
3085
3148
|
const fpSoup = fp.string(footprint).soup();
|
|
3086
|
-
const fpComponents = createComponentsFromSoup(
|
|
3149
|
+
const fpComponents = createComponentsFromSoup(
|
|
3150
|
+
{ componentName, componentRotation },
|
|
3151
|
+
fpSoup
|
|
3152
|
+
);
|
|
3087
3153
|
this.addAll(fpComponents);
|
|
3088
3154
|
}
|
|
3089
3155
|
}
|
|
@@ -6163,50 +6229,6 @@ var SilkscreenRect = class extends PrimitiveComponent {
|
|
|
6163
6229
|
}
|
|
6164
6230
|
};
|
|
6165
6231
|
|
|
6166
|
-
// lib/components/primitive-components/SilkscreenText.ts
|
|
6167
|
-
import { silkscreenTextProps } from "@tscircuit/props";
|
|
6168
|
-
var SilkscreenText = class extends PrimitiveComponent {
|
|
6169
|
-
isPcbPrimitive = true;
|
|
6170
|
-
get config() {
|
|
6171
|
-
return {
|
|
6172
|
-
componentName: "SilkscreenText",
|
|
6173
|
-
zodProps: silkscreenTextProps
|
|
6174
|
-
};
|
|
6175
|
-
}
|
|
6176
|
-
doInitialPcbPrimitiveRender() {
|
|
6177
|
-
if (this.root?.pcbDisabled) return;
|
|
6178
|
-
const { db } = this.root;
|
|
6179
|
-
const { _parsedProps: props } = this;
|
|
6180
|
-
const container = this.getPrimitiveContainer();
|
|
6181
|
-
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
6182
|
-
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
6183
|
-
const subcircuit = this.getSubcircuit();
|
|
6184
|
-
db.pcb_silkscreen_text.insert({
|
|
6185
|
-
anchor_alignment: props.anchorAlignment,
|
|
6186
|
-
anchor_position: {
|
|
6187
|
-
x: position.x,
|
|
6188
|
-
y: position.y
|
|
6189
|
-
},
|
|
6190
|
-
font: props.font ?? "tscircuit2024",
|
|
6191
|
-
font_size: props.fontSize ?? 1,
|
|
6192
|
-
layer: maybeFlipLayer(props.layer ?? "top"),
|
|
6193
|
-
text: props.text ?? "",
|
|
6194
|
-
ccw_rotation: props.pcbRotation,
|
|
6195
|
-
pcb_component_id: container.pcb_component_id,
|
|
6196
|
-
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6197
|
-
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
6198
|
-
});
|
|
6199
|
-
}
|
|
6200
|
-
getPcbSize() {
|
|
6201
|
-
const { _parsedProps: props } = this;
|
|
6202
|
-
const fontSize = props.fontSize ?? 1;
|
|
6203
|
-
const text = props.text ?? "";
|
|
6204
|
-
const textWidth = text.length * fontSize;
|
|
6205
|
-
const textHeight = fontSize;
|
|
6206
|
-
return { width: textWidth * fontSize, height: textHeight * fontSize };
|
|
6207
|
-
}
|
|
6208
|
-
};
|
|
6209
|
-
|
|
6210
6232
|
// lib/components/primitive-components/SilkscreenLine.ts
|
|
6211
6233
|
import { silkscreenLineProps } from "@tscircuit/props";
|
|
6212
6234
|
var SilkscreenLine = class extends PrimitiveComponent {
|
|
@@ -6660,11 +6682,12 @@ var Switch = class extends NormalComponent {
|
|
|
6660
6682
|
}
|
|
6661
6683
|
get config() {
|
|
6662
6684
|
const switchType = this._getSwitchType();
|
|
6685
|
+
const { isNormallyClosed } = this._parsedProps ?? {};
|
|
6663
6686
|
const baseSymbolNameMap = {
|
|
6664
|
-
spst: "SPST_switch",
|
|
6665
|
-
spdt: "SPDT_switch",
|
|
6666
|
-
dpst: "dpst_switch",
|
|
6667
|
-
dpdt: "dpdt_switch"
|
|
6687
|
+
spst: isNormallyClosed ? "spst_normally_closed_switch" : "SPST_switch",
|
|
6688
|
+
spdt: isNormallyClosed ? "spdt_normally_closed_switch" : "SPDT_switch",
|
|
6689
|
+
dpst: isNormallyClosed ? "dpst_normally_closed_switch" : "dpst_switch",
|
|
6690
|
+
dpdt: isNormallyClosed ? "dpdt_normally_closed_switch" : "dpdt_switch"
|
|
6668
6691
|
};
|
|
6669
6692
|
const symbolName = baseSymbolNameMap[switchType] ?? "SPST_switch";
|
|
6670
6693
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.322",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@lume/kiwi": "^0.4.3",
|
|
54
|
-
"@tscircuit/footprinter": "^0.0.
|
|
54
|
+
"@tscircuit/footprinter": "^0.0.128",
|
|
55
55
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
56
56
|
"@tscircuit/math-utils": "^0.0.9",
|
|
57
57
|
"@tscircuit/props": "^0.0.152",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"performance-now": "^2.1.0",
|
|
65
65
|
"react-reconciler": "^0.31.0",
|
|
66
66
|
"react-reconciler-18": "npm:react-reconciler@0.29.2",
|
|
67
|
-
"schematic-symbols": "^0.0.
|
|
67
|
+
"schematic-symbols": "^0.0.121",
|
|
68
68
|
"transformation-matrix": "^2.16.1",
|
|
69
69
|
"zod": "^3.23.8"
|
|
70
70
|
}
|