@tscircuit/core 0.0.805 → 0.0.807
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.d.ts +1344 -373
- package/dist/index.js +103 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(components_exports, {
|
|
|
37
37
|
Net: () => Net,
|
|
38
38
|
NetLabel: () => NetLabel,
|
|
39
39
|
NormalComponent: () => NormalComponent3,
|
|
40
|
+
Panel: () => Panel,
|
|
40
41
|
PcbNoteDimension: () => PcbNoteDimension,
|
|
41
42
|
PcbNoteLine: () => PcbNoteLine,
|
|
42
43
|
PcbNotePath: () => PcbNotePath,
|
|
@@ -1028,6 +1029,9 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
1028
1029
|
if (this.lowercaseComponentName === "board" && component.lowercaseComponentName === "board") {
|
|
1029
1030
|
throw new Error("Nested boards are not supported");
|
|
1030
1031
|
}
|
|
1032
|
+
if (component.lowercaseComponentName === "panel") {
|
|
1033
|
+
throw new Error("<panel> must be a root-level element");
|
|
1034
|
+
}
|
|
1031
1035
|
if (!component.onAddToParent) {
|
|
1032
1036
|
throw new Error(
|
|
1033
1037
|
`Invalid JSX Element: Expected a React component but received "${JSON.stringify(
|
|
@@ -1858,6 +1862,15 @@ var SmtPad = class extends PrimitiveComponent2 {
|
|
|
1858
1862
|
if (props.shape === "rect") {
|
|
1859
1863
|
return { width: props.width, height: props.height };
|
|
1860
1864
|
}
|
|
1865
|
+
if (props.shape === "rotated_rect") {
|
|
1866
|
+
const rotationDegrees = props.ccwRotation ?? 0;
|
|
1867
|
+
const angleRad = rotationDegrees * Math.PI / 180;
|
|
1868
|
+
const cosAngle = Math.cos(angleRad);
|
|
1869
|
+
const sinAngle = Math.sin(angleRad);
|
|
1870
|
+
const width = Math.abs(props.width * cosAngle) + Math.abs(props.height * sinAngle);
|
|
1871
|
+
const height = Math.abs(props.width * sinAngle) + Math.abs(props.height * cosAngle);
|
|
1872
|
+
return { width, height };
|
|
1873
|
+
}
|
|
1861
1874
|
if (props.shape === "polygon") {
|
|
1862
1875
|
const points = props.points;
|
|
1863
1876
|
const xs = points.map((p) => p.x);
|
|
@@ -1908,6 +1921,7 @@ var SmtPad = class extends PrimitiveComponent2 {
|
|
|
1908
1921
|
const isAxisAligned = Math.abs(normalizedRotationDegrees) < rotationTolerance || Math.abs(normalizedRotationDegrees - 180) < rotationTolerance || Math.abs(normalizedRotationDegrees - 360) < rotationTolerance;
|
|
1909
1922
|
const isRotated90Degrees = Math.abs(normalizedRotationDegrees - 90) < rotationTolerance || Math.abs(normalizedRotationDegrees - 270) < rotationTolerance;
|
|
1910
1923
|
let finalRotationDegrees = Math.abs(normalizedRotationDegrees - 360) < rotationTolerance ? 0 : normalizedRotationDegrees;
|
|
1924
|
+
const transformRotationBeforeFlip = finalRotationDegrees;
|
|
1911
1925
|
const { maybeFlipLayer, isFlipped } = this._getPcbPrimitiveFlippedHelpers();
|
|
1912
1926
|
if (isFlipped) {
|
|
1913
1927
|
finalRotationDegrees = (360 - finalRotationDegrees + 360) % 360;
|
|
@@ -1992,12 +2006,46 @@ var SmtPad = class extends PrimitiveComponent2 {
|
|
|
1992
2006
|
height: pcb_smtpad.height * 0.7,
|
|
1993
2007
|
x: pcb_smtpad.x,
|
|
1994
2008
|
y: pcb_smtpad.y,
|
|
1995
|
-
ccw_rotation:
|
|
2009
|
+
ccw_rotation: pcb_smtpad.ccw_rotation,
|
|
1996
2010
|
pcb_component_id: pcb_smtpad.pcb_component_id,
|
|
1997
2011
|
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
|
|
1998
2012
|
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
1999
2013
|
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
2000
2014
|
});
|
|
2015
|
+
} else if (props.shape === "rotated_rect") {
|
|
2016
|
+
const baseRotation = props.ccwRotation ?? 0;
|
|
2017
|
+
const combinedRotationBeforeFlip = (transformRotationBeforeFlip + baseRotation + 360) % 360;
|
|
2018
|
+
const padRotation = isFlipped ? (360 - combinedRotationBeforeFlip + 360) % 360 : combinedRotationBeforeFlip;
|
|
2019
|
+
pcb_smtpad = db.pcb_smtpad.insert({
|
|
2020
|
+
pcb_component_id,
|
|
2021
|
+
pcb_port_id: this.matchedPort?.pcb_port_id,
|
|
2022
|
+
layer: maybeFlipLayer(props.layer ?? "top"),
|
|
2023
|
+
shape: "rotated_rect",
|
|
2024
|
+
width: props.width,
|
|
2025
|
+
height: props.height,
|
|
2026
|
+
corner_radius: props.cornerRadius ?? 0,
|
|
2027
|
+
x: position.x,
|
|
2028
|
+
y: position.y,
|
|
2029
|
+
ccw_rotation: padRotation,
|
|
2030
|
+
port_hints: props.portHints.map((ph) => ph.toString()),
|
|
2031
|
+
is_covered_with_solder_mask: isCoveredWithSolderMask,
|
|
2032
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
2033
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
2034
|
+
});
|
|
2035
|
+
if (shouldCreateSolderPaste)
|
|
2036
|
+
db.pcb_solder_paste.insert({
|
|
2037
|
+
layer: maybeFlipLayer(props.layer ?? "top"),
|
|
2038
|
+
shape: "rotated_rect",
|
|
2039
|
+
width: pcb_smtpad.width * 0.7,
|
|
2040
|
+
height: pcb_smtpad.height * 0.7,
|
|
2041
|
+
x: position.x,
|
|
2042
|
+
y: position.y,
|
|
2043
|
+
ccw_rotation: padRotation,
|
|
2044
|
+
pcb_component_id,
|
|
2045
|
+
pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
|
|
2046
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
2047
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
2048
|
+
});
|
|
2001
2049
|
} else if (props.shape === "polygon") {
|
|
2002
2050
|
pcb_smtpad = db.pcb_smtpad.insert({
|
|
2003
2051
|
pcb_component_id,
|
|
@@ -6666,7 +6714,14 @@ var Trace3 = class extends PrimitiveComponent2 {
|
|
|
6666
6714
|
const match = selector.match(/^net\.(.+)$/);
|
|
6667
6715
|
const netName = match ? match[1] : null;
|
|
6668
6716
|
if (!netName) return null;
|
|
6669
|
-
const
|
|
6717
|
+
const board = this.root?._getBoard();
|
|
6718
|
+
if (!board) {
|
|
6719
|
+
this.renderError(
|
|
6720
|
+
`Could not find a <board> ancestor for ${this}, so net "${selector}" cannot be resolved`
|
|
6721
|
+
);
|
|
6722
|
+
return null;
|
|
6723
|
+
}
|
|
6724
|
+
const allDescendants = board.getDescendants();
|
|
6670
6725
|
return allDescendants.find(
|
|
6671
6726
|
(d) => d.componentName === "Net" && d._parsedProps.name === netName
|
|
6672
6727
|
) || null;
|
|
@@ -13709,6 +13764,32 @@ var Board = class extends Group6 {
|
|
|
13709
13764
|
}
|
|
13710
13765
|
};
|
|
13711
13766
|
|
|
13767
|
+
// lib/components/normal-components/Panel.ts
|
|
13768
|
+
import { panelProps } from "@tscircuit/props";
|
|
13769
|
+
var Panel = class extends Group6 {
|
|
13770
|
+
get config() {
|
|
13771
|
+
return {
|
|
13772
|
+
componentName: "Panel",
|
|
13773
|
+
zodProps: panelProps
|
|
13774
|
+
};
|
|
13775
|
+
}
|
|
13776
|
+
get isGroup() {
|
|
13777
|
+
return true;
|
|
13778
|
+
}
|
|
13779
|
+
add(component) {
|
|
13780
|
+
if (component.lowercaseComponentName !== "board") {
|
|
13781
|
+
throw new Error("<panel> can only contain <board> elements");
|
|
13782
|
+
}
|
|
13783
|
+
super.add(component);
|
|
13784
|
+
}
|
|
13785
|
+
runRenderCycle() {
|
|
13786
|
+
if (!this.children.some((child) => child.componentName === "Board")) {
|
|
13787
|
+
throw new Error("<panel> must contain at least one <board>");
|
|
13788
|
+
}
|
|
13789
|
+
super.runRenderCycle();
|
|
13790
|
+
}
|
|
13791
|
+
};
|
|
13792
|
+
|
|
13712
13793
|
// lib/components/normal-components/Capacitor.ts
|
|
13713
13794
|
import { capacitorProps } from "@tscircuit/props";
|
|
13714
13795
|
|
|
@@ -17117,7 +17198,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
17117
17198
|
var package_default = {
|
|
17118
17199
|
name: "@tscircuit/core",
|
|
17119
17200
|
type: "module",
|
|
17120
|
-
version: "0.0.
|
|
17201
|
+
version: "0.0.806",
|
|
17121
17202
|
types: "dist/index.d.ts",
|
|
17122
17203
|
main: "dist/index.js",
|
|
17123
17204
|
module: "dist/index.js",
|
|
@@ -17277,9 +17358,11 @@ var RootCircuit = class {
|
|
|
17277
17358
|
* Get the main board for this Circuit.
|
|
17278
17359
|
*/
|
|
17279
17360
|
_getBoard() {
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17361
|
+
const directBoard = this.children.find((c) => c.componentName === "Board");
|
|
17362
|
+
if (directBoard) {
|
|
17363
|
+
return directBoard;
|
|
17364
|
+
}
|
|
17365
|
+
return void 0;
|
|
17283
17366
|
}
|
|
17284
17367
|
_guessRootComponent() {
|
|
17285
17368
|
if (this.firstChild) return;
|
|
@@ -17288,6 +17371,19 @@ var RootCircuit = class {
|
|
|
17288
17371
|
"Not able to guess root component: RootCircuit has no children (use circuit.add(...))"
|
|
17289
17372
|
);
|
|
17290
17373
|
}
|
|
17374
|
+
const panels = this.children.filter(
|
|
17375
|
+
(child) => child.lowercaseComponentName === "panel"
|
|
17376
|
+
);
|
|
17377
|
+
if (panels.length > 1) {
|
|
17378
|
+
throw new Error("Only one <panel> is allowed per circuit");
|
|
17379
|
+
}
|
|
17380
|
+
if (panels.length === 1) {
|
|
17381
|
+
if (this.children.length !== 1) {
|
|
17382
|
+
throw new Error("<panel> must be the root element of the circuit");
|
|
17383
|
+
}
|
|
17384
|
+
this.firstChild = panels[0];
|
|
17385
|
+
return;
|
|
17386
|
+
}
|
|
17291
17387
|
if (this.children.length === 1 && this.children[0].isGroup) {
|
|
17292
17388
|
this.firstChild = this.children[0];
|
|
17293
17389
|
return;
|
|
@@ -17655,6 +17751,7 @@ export {
|
|
|
17655
17751
|
Net,
|
|
17656
17752
|
NetLabel,
|
|
17657
17753
|
NormalComponent3 as NormalComponent,
|
|
17754
|
+
Panel,
|
|
17658
17755
|
PcbNoteDimension,
|
|
17659
17756
|
PcbNoteLine,
|
|
17660
17757
|
PcbNotePath,
|