@tscircuit/core 0.0.1274 → 0.0.1275
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 +3 -2
- package/dist/index.js +122 -2
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -236,9 +236,9 @@ interface IIsolatedCircuit {
|
|
|
236
236
|
interface IRootCircuit extends IIsolatedCircuit {
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "CreateAutoplacedBreakoutPoints", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceComponentPropertyValidation", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicSectionRender", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SupplierFootprintMismatchWarning", "SimulationSpiceEngineRender"];
|
|
239
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "CreateAutoplacedBreakoutPoints", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceComponentPropertyValidation", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicSectionRender", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbAutoplaceBreakoutPoints", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SupplierFootprintMismatchWarning", "SimulationSpiceEngineRender"];
|
|
240
240
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
241
|
-
declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "CreateAutoplacedBreakoutPoints" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceComponentPropertyValidation" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicSectionRender" | "SchematicTraceRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SupplierFootprintMismatchWarning" | "SimulationSpiceEngineRender", number>;
|
|
241
|
+
declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "CreateAutoplacedBreakoutPoints" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceComponentPropertyValidation" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicSectionRender" | "SchematicTraceRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbAutoplaceBreakoutPoints" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SupplierFootprintMismatchWarning" | "SimulationSpiceEngineRender", number>;
|
|
242
242
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
243
243
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
244
244
|
initialized: boolean;
|
|
@@ -73062,6 +73062,7 @@ declare class Breakout extends Group<typeof breakoutProps> {
|
|
|
73062
73062
|
* after PcbLayout.
|
|
73063
73063
|
*/
|
|
73064
73064
|
doInitialCreateAutoplacedBreakoutPoints(): void;
|
|
73065
|
+
doInitialPcbAutoplaceBreakoutPoints(): void;
|
|
73065
73066
|
doInitialPcbPrimitiveRender(): void;
|
|
73066
73067
|
}
|
|
73067
73068
|
|
package/dist/index.js
CHANGED
|
@@ -364,6 +364,7 @@ var orderedRenderPhases = [
|
|
|
364
364
|
"PcbLayout",
|
|
365
365
|
"PcbBoardAutoSize",
|
|
366
366
|
"PanelLayout",
|
|
367
|
+
"PcbAutoplaceBreakoutPoints",
|
|
367
368
|
"PcbTraceHintRender",
|
|
368
369
|
"PcbManualTraceRender",
|
|
369
370
|
"PcbTraceRender",
|
|
@@ -21806,7 +21807,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
21806
21807
|
var package_default = {
|
|
21807
21808
|
name: "@tscircuit/core",
|
|
21808
21809
|
type: "module",
|
|
21809
|
-
version: "0.0.
|
|
21810
|
+
version: "0.0.1274",
|
|
21810
21811
|
types: "dist/index.d.ts",
|
|
21811
21812
|
main: "dist/index.js",
|
|
21812
21813
|
module: "dist/index.js",
|
|
@@ -21838,6 +21839,7 @@ var package_default = {
|
|
|
21838
21839
|
"@biomejs/biome": "^1.8.3",
|
|
21839
21840
|
"@resvg/resvg-js": "^2.6.2",
|
|
21840
21841
|
"@tscircuit/alphabet": "0.0.25",
|
|
21842
|
+
"@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
|
|
21841
21843
|
"@tscircuit/capacity-autorouter": "^0.0.529",
|
|
21842
21844
|
"@tscircuit/checks": "0.0.133",
|
|
21843
21845
|
"@tscircuit/circuit-json-util": "^0.0.94",
|
|
@@ -21879,7 +21881,7 @@ var package_default = {
|
|
|
21879
21881
|
debug: "^4.3.6",
|
|
21880
21882
|
"eecircuit-engine": "^1.5.6",
|
|
21881
21883
|
flatbush: "^4.5.0",
|
|
21882
|
-
"graphics-debug": "^0.0.
|
|
21884
|
+
"graphics-debug": "^0.0.95",
|
|
21883
21885
|
howfat: "^0.3.8",
|
|
21884
21886
|
"kicad-to-circuit-json": "^0.0.60",
|
|
21885
21887
|
kicadts: "^0.0.35",
|
|
@@ -24803,6 +24805,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
|
|
|
24803
24805
|
|
|
24804
24806
|
// lib/components/primitive-components/Breakout/Breakout.ts
|
|
24805
24807
|
import "@tscircuit/props";
|
|
24808
|
+
import { BreakoutPointSolver } from "@tscircuit/breakout-point-solver";
|
|
24806
24809
|
|
|
24807
24810
|
// lib/components/primitive-components/BaseBreakoutPoint.ts
|
|
24808
24811
|
import { pcbLayoutProps } from "@tscircuit/props";
|
|
@@ -24929,6 +24932,101 @@ var BreakoutPoint = class extends BaseBreakoutPoint {
|
|
|
24929
24932
|
}
|
|
24930
24933
|
};
|
|
24931
24934
|
|
|
24935
|
+
// lib/components/primitive-components/Breakout/createBreakoutPointSolverInput.ts
|
|
24936
|
+
import {
|
|
24937
|
+
findBoundsAndCenter
|
|
24938
|
+
} from "@tscircuit/circuit-json-util";
|
|
24939
|
+
var getPortLabel = (db, sourcePortId) => {
|
|
24940
|
+
if (!sourcePortId) return void 0;
|
|
24941
|
+
const sourcePort = db.source_port.get(sourcePortId);
|
|
24942
|
+
const sourceComponent = sourcePort?.source_component_id ? db.source_component.get(sourcePort.source_component_id) : void 0;
|
|
24943
|
+
if (!sourcePort) return void 0;
|
|
24944
|
+
return sourceComponent?.name ? `${sourceComponent.name}.${sourcePort.name}` : sourcePort.name;
|
|
24945
|
+
};
|
|
24946
|
+
var getPadElement = (db, pcbPortId) => {
|
|
24947
|
+
return db.pcb_smtpad.getWhere({ pcb_port_id: pcbPortId }) ?? db.pcb_plated_hole.getWhere({ pcb_port_id: pcbPortId });
|
|
24948
|
+
};
|
|
24949
|
+
var toBreakoutPort = (db, pcbPort) => {
|
|
24950
|
+
const pad = getPadElement(db, pcbPort.pcb_port_id);
|
|
24951
|
+
const padBounds = pad ? findBoundsAndCenter([pad]) : null;
|
|
24952
|
+
return {
|
|
24953
|
+
sourcePortId: pcbPort.source_port_id,
|
|
24954
|
+
position: { x: pcbPort.x, y: pcbPort.y },
|
|
24955
|
+
...padBounds ? { width: padBounds.width, height: padBounds.height } : {},
|
|
24956
|
+
layer: pcbPort.layers?.[0] ?? "top",
|
|
24957
|
+
label: getPortLabel(db, pcbPort.source_port_id)
|
|
24958
|
+
};
|
|
24959
|
+
};
|
|
24960
|
+
var createBreakoutPointSolverInput = (breakout) => {
|
|
24961
|
+
if (!breakout.root || !breakout.pcb_group_id) return null;
|
|
24962
|
+
const { db } = breakout.root;
|
|
24963
|
+
const pcbGroup = db.pcb_group.get(breakout.pcb_group_id);
|
|
24964
|
+
if (!pcbGroup || !pcbGroup.width || !pcbGroup.height) return null;
|
|
24965
|
+
const sourcePortIdToPcbPort = /* @__PURE__ */ new Map();
|
|
24966
|
+
for (const pcbPort of db.pcb_port.list()) {
|
|
24967
|
+
if (!pcbPort.source_port_id) continue;
|
|
24968
|
+
sourcePortIdToPcbPort.set(pcbPort.source_port_id, pcbPort);
|
|
24969
|
+
}
|
|
24970
|
+
const boundsMinX = pcbGroup.center.x - pcbGroup.width / 2;
|
|
24971
|
+
const boundsMaxX = pcbGroup.center.x + pcbGroup.width / 2;
|
|
24972
|
+
const boundsMinY = pcbGroup.center.y - pcbGroup.height / 2;
|
|
24973
|
+
const boundsMaxY = pcbGroup.center.y + pcbGroup.height / 2;
|
|
24974
|
+
const traces = [];
|
|
24975
|
+
for (const sourceTrace of db.source_trace.list()) {
|
|
24976
|
+
const pcbPorts = sourceTrace.connected_source_port_ids.map((sourcePortId) => sourcePortIdToPcbPort.get(sourcePortId)).filter((port) => Boolean(port));
|
|
24977
|
+
const insidePorts = pcbPorts.filter(
|
|
24978
|
+
(port) => port.pcb_group_id === breakout.pcb_group_id
|
|
24979
|
+
);
|
|
24980
|
+
const outsidePorts = pcbPorts.filter(
|
|
24981
|
+
(port) => port.pcb_group_id !== breakout.pcb_group_id && !(port.x >= boundsMinX && port.x <= boundsMaxX && port.y >= boundsMinY && port.y <= boundsMaxY)
|
|
24982
|
+
);
|
|
24983
|
+
if (insidePorts.length === 0 || outsidePorts.length === 0) continue;
|
|
24984
|
+
traces.push({
|
|
24985
|
+
sourceTraceId: sourceTrace.source_trace_id,
|
|
24986
|
+
insidePorts: insidePorts.map((port) => toBreakoutPort(db, port)),
|
|
24987
|
+
outsidePorts: outsidePorts.map((port) => toBreakoutPort(db, port))
|
|
24988
|
+
});
|
|
24989
|
+
}
|
|
24990
|
+
if (traces.length === 0) return null;
|
|
24991
|
+
const allPadElements = [...db.pcb_smtpad.list(), ...db.pcb_plated_hole.list()];
|
|
24992
|
+
const pads = [];
|
|
24993
|
+
for (const pad of allPadElements) {
|
|
24994
|
+
const padBounds = findBoundsAndCenter([pad]);
|
|
24995
|
+
if (!padBounds.width || !padBounds.height) continue;
|
|
24996
|
+
const pcbPort = pad.pcb_port_id ? db.pcb_port.get(pad.pcb_port_id) : null;
|
|
24997
|
+
pads.push({
|
|
24998
|
+
center: padBounds.center,
|
|
24999
|
+
width: padBounds.width,
|
|
25000
|
+
height: padBounds.height,
|
|
25001
|
+
layer: pad.layer ?? "top",
|
|
25002
|
+
sourcePortIds: pcbPort?.source_port_id ? [pcbPort.source_port_id] : [],
|
|
25003
|
+
label: getPortLabel(db, pcbPort?.source_port_id)
|
|
25004
|
+
});
|
|
25005
|
+
}
|
|
25006
|
+
const components = db.pcb_component.list().filter((component) => component.width && component.height).map((component) => ({
|
|
25007
|
+
center: component.center,
|
|
25008
|
+
width: component.width,
|
|
25009
|
+
height: component.height,
|
|
25010
|
+
ccwRotationDegrees: component.rotation,
|
|
25011
|
+
layer: component.layer,
|
|
25012
|
+
label: component.pcb_component_id
|
|
25013
|
+
}));
|
|
25014
|
+
const usedBoundaryPoints = db.pcb_breakout_point.list().filter((point6) => point6.pcb_group_id === breakout.pcb_group_id).map((point6) => ({ x: point6.x, y: point6.y }));
|
|
25015
|
+
return {
|
|
25016
|
+
bounds: {
|
|
25017
|
+
minX: boundsMinX,
|
|
25018
|
+
maxX: boundsMaxX,
|
|
25019
|
+
minY: boundsMinY,
|
|
25020
|
+
maxY: boundsMaxY
|
|
25021
|
+
},
|
|
25022
|
+
boundaryPointSpacing: 0.5,
|
|
25023
|
+
traces,
|
|
25024
|
+
pads,
|
|
25025
|
+
components,
|
|
25026
|
+
usedBoundaryPoints
|
|
25027
|
+
};
|
|
25028
|
+
};
|
|
25029
|
+
|
|
24932
25030
|
// lib/components/primitive-components/Breakout/Breakout.ts
|
|
24933
25031
|
var Breakout = class extends Group5 {
|
|
24934
25032
|
constructor(props) {
|
|
@@ -24978,6 +25076,28 @@ var Breakout = class extends Group5 {
|
|
|
24978
25076
|
}
|
|
24979
25077
|
}
|
|
24980
25078
|
}
|
|
25079
|
+
doInitialPcbAutoplaceBreakoutPoints() {
|
|
25080
|
+
if (this.root?.pcbDisabled) return;
|
|
25081
|
+
const solverInput = createBreakoutPointSolverInput(this);
|
|
25082
|
+
if (!solverInput) return;
|
|
25083
|
+
const solver = new BreakoutPointSolver(solverInput);
|
|
25084
|
+
solver.solve();
|
|
25085
|
+
const output = solver.getOutput();
|
|
25086
|
+
const autoBreakoutPoints = this.children.filter(
|
|
25087
|
+
(c) => c instanceof AutoplacedBreakoutPoint
|
|
25088
|
+
);
|
|
25089
|
+
for (const solvedPoint of output.breakoutPoints) {
|
|
25090
|
+
const matchingBreakoutPoint = autoBreakoutPoints.find(
|
|
25091
|
+
(child) => child.matchedPort?.source_port_id === solvedPoint.sourcePortId
|
|
25092
|
+
);
|
|
25093
|
+
if (matchingBreakoutPoint) {
|
|
25094
|
+
matchingBreakoutPoint._setPositionFromLayout({
|
|
25095
|
+
x: solvedPoint.x,
|
|
25096
|
+
y: solvedPoint.y
|
|
25097
|
+
});
|
|
25098
|
+
}
|
|
25099
|
+
}
|
|
25100
|
+
}
|
|
24981
25101
|
doInitialPcbPrimitiveRender() {
|
|
24982
25102
|
super.doInitialPcbPrimitiveRender();
|
|
24983
25103
|
if (this.root?.pcbDisabled) 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.1275",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@biomejs/biome": "^1.8.3",
|
|
34
34
|
"@resvg/resvg-js": "^2.6.2",
|
|
35
35
|
"@tscircuit/alphabet": "0.0.25",
|
|
36
|
+
"@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
|
|
36
37
|
"@tscircuit/capacity-autorouter": "^0.0.529",
|
|
37
38
|
"@tscircuit/checks": "0.0.133",
|
|
38
39
|
"@tscircuit/circuit-json-util": "^0.0.94",
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"debug": "^4.3.6",
|
|
75
76
|
"eecircuit-engine": "^1.5.6",
|
|
76
77
|
"flatbush": "^4.5.0",
|
|
77
|
-
"graphics-debug": "^0.0.
|
|
78
|
+
"graphics-debug": "^0.0.95",
|
|
78
79
|
"howfat": "^0.3.8",
|
|
79
80
|
"kicad-to-circuit-json": "^0.0.60",
|
|
80
81
|
"kicadts": "^0.0.35",
|