@tscircuit/core 0.0.1159 → 0.0.1161
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 -0
- package/dist/index.js +255 -100
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -88167,6 +88167,9 @@ declare class Connector<PinLabels extends string = never> extends Chip<PinLabels
|
|
|
88167
88167
|
private _tryFetchPartCircuitJson;
|
|
88168
88168
|
private _fetchStandardConnectorCircuitJson;
|
|
88169
88169
|
private _addConnectorFootprintFromCircuitJson;
|
|
88170
|
+
private _getUsbCCanonicalLabelToPinNumberMap;
|
|
88171
|
+
_getSchematicPortArrangement(): SchematicPortArrangement | null;
|
|
88172
|
+
_getSchematicBoxDimensions(): SchematicBoxDimensions | null;
|
|
88170
88173
|
get config(): {
|
|
88171
88174
|
componentName: string;
|
|
88172
88175
|
zodProps: zod.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ __export(components_exports, {
|
|
|
99
99
|
import { fp } from "@tscircuit/footprinter";
|
|
100
100
|
import { normalizeDegrees } from "@tscircuit/math-utils";
|
|
101
101
|
import {
|
|
102
|
-
distance as
|
|
102
|
+
distance as distance8,
|
|
103
103
|
pcb_component_invalid_layer_error,
|
|
104
104
|
pcb_manual_edit_conflict_warning,
|
|
105
105
|
point3 as point32,
|
|
@@ -9540,21 +9540,28 @@ var getAllDimensionsForSchematicBox = (params) => {
|
|
|
9540
9540
|
};
|
|
9541
9541
|
|
|
9542
9542
|
// lib/utils/schematic/getNumericSchPinStyle.ts
|
|
9543
|
+
import { distance as distance6 } from "circuit-json";
|
|
9543
9544
|
var getNumericSchPinStyle = (pinStyles, pinLabels) => {
|
|
9544
9545
|
if (!pinStyles) return void 0;
|
|
9545
9546
|
const numericPinStyles = {};
|
|
9546
9547
|
for (const [pinNameOrLabel, pinStyle] of Object.entries(pinStyles)) {
|
|
9547
9548
|
const pinNumber = parsePinNumberFromLabelsOrThrow(pinNameOrLabel, pinLabels);
|
|
9548
|
-
const
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
};
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9549
|
+
const leftMargin = pinStyle.marginLeft ?? pinStyle.leftMargin;
|
|
9550
|
+
const rightMargin = pinStyle.marginRight ?? pinStyle.rightMargin;
|
|
9551
|
+
const topMargin = pinStyle.marginTop ?? pinStyle.topMargin;
|
|
9552
|
+
const bottomMargin = pinStyle.marginBottom ?? pinStyle.bottomMargin;
|
|
9553
|
+
const existingStyle = numericPinStyles[`pin${pinNumber}`] ?? {};
|
|
9554
|
+
const nextStyle = { ...existingStyle };
|
|
9555
|
+
if (leftMargin !== void 0)
|
|
9556
|
+
nextStyle.leftMargin = distance6.parse(leftMargin);
|
|
9557
|
+
if (rightMargin !== void 0) {
|
|
9558
|
+
nextStyle.rightMargin = distance6.parse(rightMargin);
|
|
9559
|
+
}
|
|
9560
|
+
if (topMargin !== void 0) nextStyle.topMargin = distance6.parse(topMargin);
|
|
9561
|
+
if (bottomMargin !== void 0) {
|
|
9562
|
+
nextStyle.bottomMargin = distance6.parse(bottomMargin);
|
|
9563
|
+
}
|
|
9564
|
+
numericPinStyles[`pin${pinNumber}`] = nextStyle;
|
|
9558
9565
|
}
|
|
9559
9566
|
return numericPinStyles;
|
|
9560
9567
|
};
|
|
@@ -9583,7 +9590,7 @@ var CadAssembly = class extends PrimitiveComponent2 {
|
|
|
9583
9590
|
// lib/components/primitive-components/CadModel.ts
|
|
9584
9591
|
import { cadmodelProps, point3 } from "@tscircuit/props";
|
|
9585
9592
|
import { z as z8 } from "zod";
|
|
9586
|
-
import { distance as
|
|
9593
|
+
import { distance as distance7 } from "circuit-json";
|
|
9587
9594
|
import { decomposeTSR as decomposeTSR7 } from "transformation-matrix";
|
|
9588
9595
|
|
|
9589
9596
|
// lib/components/base-components/NormalComponent/utils/getFileExtension.ts
|
|
@@ -9664,7 +9671,7 @@ var CadModel = class extends PrimitiveComponent2 {
|
|
|
9664
9671
|
z: props.pcbZ ?? 0,
|
|
9665
9672
|
...typeof props.positionOffset === "object" ? props.positionOffset : {}
|
|
9666
9673
|
});
|
|
9667
|
-
const zOffsetFromSurface = props.zOffsetFromSurface !== void 0 ?
|
|
9674
|
+
const zOffsetFromSurface = props.zOffsetFromSurface !== void 0 ? distance7.parse(props.zOffsetFromSurface) : 0;
|
|
9668
9675
|
const layer = parent.props.layer === "bottom" ? "bottom" : "top";
|
|
9669
9676
|
const ext = props.modelUrl ? getFileExtension(props.modelUrl) : void 0;
|
|
9670
9677
|
const modelUrlWithoutExtFragment = props.modelUrl?.replace(/#ext=\w+$/, "");
|
|
@@ -10517,6 +10524,39 @@ var shouldCheckPortForMissingTrace = (component, port) => {
|
|
|
10517
10524
|
return true;
|
|
10518
10525
|
};
|
|
10519
10526
|
|
|
10527
|
+
// lib/components/base-components/NormalComponent/utils/getLogicalPortsFromPortHintGroups.ts
|
|
10528
|
+
function getLogicalPortsFromPortHintGroups(portHintGroups, opts) {
|
|
10529
|
+
let implicitPinNumber = 1;
|
|
10530
|
+
const portsByPinNumber = /* @__PURE__ */ new Map();
|
|
10531
|
+
for (const portHintGroup of portHintGroups) {
|
|
10532
|
+
const filteredPortHints = portHintGroup.hints.filter(
|
|
10533
|
+
(hint) => hint && hint.trim() !== ""
|
|
10534
|
+
);
|
|
10535
|
+
if (filteredPortHints.length === 0) continue;
|
|
10536
|
+
let portHintsList = filteredPortHints;
|
|
10537
|
+
const hasPinIdentifier = portHintsList.some(
|
|
10538
|
+
(hint) => hint.startsWith("pin") || /^(?:pin)?\d+$/.test(hint)
|
|
10539
|
+
);
|
|
10540
|
+
if (!hasPinIdentifier) {
|
|
10541
|
+
portHintsList = [...portHintsList, `pin${implicitPinNumber}`];
|
|
10542
|
+
}
|
|
10543
|
+
implicitPinNumber++;
|
|
10544
|
+
const newPort = getPortFromHints(portHintsList, opts);
|
|
10545
|
+
if (!newPort) continue;
|
|
10546
|
+
newPort.originDescription = portHintGroup.originDescription;
|
|
10547
|
+
const pinNumber = newPort._parsedProps.pinNumber;
|
|
10548
|
+
if (pinNumber === void 0) continue;
|
|
10549
|
+
const existingPort = portsByPinNumber.get(pinNumber);
|
|
10550
|
+
if (!existingPort) {
|
|
10551
|
+
portsByPinNumber.set(pinNumber, newPort);
|
|
10552
|
+
continue;
|
|
10553
|
+
}
|
|
10554
|
+
const mergedAliases = newPort.getNameAndAliases().filter((alias) => !existingPort.getNameAndAliases().includes(alias));
|
|
10555
|
+
existingPort.externallyAddedAliases.push(...mergedAliases);
|
|
10556
|
+
}
|
|
10557
|
+
return Array.from(portsByPinNumber.values());
|
|
10558
|
+
}
|
|
10559
|
+
|
|
10520
10560
|
// lib/components/base-components/NormalComponent/NormalComponent.ts
|
|
10521
10561
|
var debug3 = Debug5("tscircuit:core");
|
|
10522
10562
|
var rotation32 = z9.object({
|
|
@@ -11365,41 +11405,31 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
11365
11405
|
this._queueInvalidFootprintPropMessage(footprint, error);
|
|
11366
11406
|
return [];
|
|
11367
11407
|
}
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11408
|
+
return getLogicalPortsFromPortHintGroups(
|
|
11409
|
+
fpCircuitJson.flatMap(
|
|
11410
|
+
(elm) => "port_hints" in elm && elm.port_hints ? [
|
|
11411
|
+
{
|
|
11412
|
+
hints: elm.port_hints,
|
|
11413
|
+
originDescription: `footprint:string:${footprint}:port_hints[0]:${elm.port_hints[0]}`
|
|
11414
|
+
}
|
|
11415
|
+
] : []
|
|
11416
|
+
),
|
|
11417
|
+
opts
|
|
11418
|
+
);
|
|
11378
11419
|
}
|
|
11379
11420
|
if (!isValidElement(footprint) && footprint && footprint.componentName === "Footprint") {
|
|
11380
11421
|
const fp2 = footprint;
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
);
|
|
11393
|
-
if (!hasPinIdentifier) {
|
|
11394
|
-
portHintsList = [...portHintsList, `pin${pinNumber}`];
|
|
11395
|
-
}
|
|
11396
|
-
pinNumber++;
|
|
11397
|
-
const newPort = getPortFromHints(portHintsList);
|
|
11398
|
-
if (!newPort) continue;
|
|
11399
|
-
newPort.originDescription = `footprint:${footprint}`;
|
|
11400
|
-
newPorts2.push(newPort);
|
|
11401
|
-
}
|
|
11402
|
-
return newPorts2;
|
|
11422
|
+
return getLogicalPortsFromPortHintGroups(
|
|
11423
|
+
fp2.children.flatMap(
|
|
11424
|
+
(fpChild) => fpChild.props.portHints ? [
|
|
11425
|
+
{
|
|
11426
|
+
hints: fpChild.props.portHints,
|
|
11427
|
+
originDescription: `footprint:${footprint}`
|
|
11428
|
+
}
|
|
11429
|
+
] : []
|
|
11430
|
+
),
|
|
11431
|
+
opts
|
|
11432
|
+
);
|
|
11403
11433
|
}
|
|
11404
11434
|
const newPorts = [];
|
|
11405
11435
|
if (!footprint) {
|
|
@@ -11604,7 +11634,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
11604
11634
|
z: 0,
|
|
11605
11635
|
...typeof cadModel?.positionOffset === "object" ? cadModel.positionOffset : {}
|
|
11606
11636
|
});
|
|
11607
|
-
const zOffsetFromSurface = cadModel && typeof cadModel === "object" && "zOffsetFromSurface" in cadModel ? cadModel.zOffsetFromSurface !== void 0 ?
|
|
11637
|
+
const zOffsetFromSurface = cadModel && typeof cadModel === "object" && "zOffsetFromSurface" in cadModel ? cadModel.zOffsetFromSurface !== void 0 ? distance8.parse(
|
|
11608
11638
|
cadModel.zOffsetFromSurface
|
|
11609
11639
|
) : 0 : 0;
|
|
11610
11640
|
const computedLayer = this.props.layer === "bottom" ? "bottom" : "top";
|
|
@@ -12559,7 +12589,7 @@ import {
|
|
|
12559
12589
|
groupProps
|
|
12560
12590
|
} from "@tscircuit/props";
|
|
12561
12591
|
import {
|
|
12562
|
-
distance as
|
|
12592
|
+
distance as distance9
|
|
12563
12593
|
} from "circuit-json";
|
|
12564
12594
|
import Debug13 from "debug";
|
|
12565
12595
|
|
|
@@ -17736,8 +17766,8 @@ var Group6 = class extends NormalComponent3 {
|
|
|
17736
17766
|
const groupProps2 = props;
|
|
17737
17767
|
const hasOutline = groupProps2.outline && groupProps2.outline.length > 0;
|
|
17738
17768
|
const numericOutline = hasOutline ? groupProps2.outline.map((point6) => ({
|
|
17739
|
-
x:
|
|
17740
|
-
y:
|
|
17769
|
+
x: distance9.parse(point6.x),
|
|
17770
|
+
y: distance9.parse(point6.y)
|
|
17741
17771
|
})) : void 0;
|
|
17742
17772
|
const ctx = this.props;
|
|
17743
17773
|
const anchorPosition = this._getGlobalPcbPositionBeforeLayout();
|
|
@@ -17775,8 +17805,8 @@ var Group6 = class extends NormalComponent3 {
|
|
|
17775
17805
|
const hasExplicitPositioning = this._parsedProps.pcbX !== void 0 || this._parsedProps.pcbY !== void 0;
|
|
17776
17806
|
if (hasOutline) {
|
|
17777
17807
|
const numericOutline = props.outline.map((point6) => ({
|
|
17778
|
-
x:
|
|
17779
|
-
y:
|
|
17808
|
+
x: distance9.parse(point6.x),
|
|
17809
|
+
y: distance9.parse(point6.y)
|
|
17780
17810
|
}));
|
|
17781
17811
|
const outlineBounds = getBoundsFromPoints4(numericOutline);
|
|
17782
17812
|
if (!outlineBounds) return;
|
|
@@ -19315,7 +19345,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
19315
19345
|
var package_default = {
|
|
19316
19346
|
name: "@tscircuit/core",
|
|
19317
19347
|
type: "module",
|
|
19318
|
-
version: "0.0.
|
|
19348
|
+
version: "0.0.1160",
|
|
19319
19349
|
types: "dist/index.d.ts",
|
|
19320
19350
|
main: "dist/index.js",
|
|
19321
19351
|
module: "dist/index.js",
|
|
@@ -20467,11 +20497,11 @@ var MountedBoard = class extends Subcircuit {
|
|
|
20467
20497
|
|
|
20468
20498
|
// lib/components/normal-components/Panel.ts
|
|
20469
20499
|
import { panelProps } from "@tscircuit/props";
|
|
20470
|
-
import { distance as
|
|
20500
|
+
import { distance as distance13 } from "circuit-json";
|
|
20471
20501
|
|
|
20472
20502
|
// lib/components/normal-components/Subpanel.ts
|
|
20473
20503
|
import { subpanelProps } from "@tscircuit/props";
|
|
20474
|
-
import { distance as
|
|
20504
|
+
import { distance as distance12 } from "circuit-json";
|
|
20475
20505
|
import { compose as compose8, identity as identity6, translate as translate8 } from "transformation-matrix";
|
|
20476
20506
|
|
|
20477
20507
|
// lib/utils/panels/generate-panel-tabs-and-mouse-bites.ts
|
|
@@ -20684,15 +20714,15 @@ function generatePanelTabsAndMouseBites(boards, options) {
|
|
|
20684
20714
|
}
|
|
20685
20715
|
|
|
20686
20716
|
// lib/utils/panels/pack-into-grid.ts
|
|
20687
|
-
import { distance as
|
|
20717
|
+
import { distance as distance11 } from "circuit-json";
|
|
20688
20718
|
|
|
20689
20719
|
// lib/utils/panels/get-board-dimensions-from-props.ts
|
|
20690
20720
|
import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
|
|
20691
|
-
import { distance as
|
|
20721
|
+
import { distance as distance10 } from "circuit-json";
|
|
20692
20722
|
var getBoardDimensionsFromProps = (board) => {
|
|
20693
20723
|
const props = board._parsedProps;
|
|
20694
|
-
let width = props.width != null ?
|
|
20695
|
-
let height = props.height != null ?
|
|
20724
|
+
let width = props.width != null ? distance10.parse(props.width) : void 0;
|
|
20725
|
+
let height = props.height != null ? distance10.parse(props.height) : void 0;
|
|
20696
20726
|
if ((width === void 0 || height === void 0) && props.outline?.length) {
|
|
20697
20727
|
const outlineBounds = getBoundsFromPoints6(props.outline);
|
|
20698
20728
|
if (outlineBounds) {
|
|
@@ -20736,8 +20766,8 @@ function packIntoGrid({
|
|
|
20736
20766
|
}
|
|
20737
20767
|
let cols;
|
|
20738
20768
|
let rows;
|
|
20739
|
-
const minCellWidth = cellWidth ?
|
|
20740
|
-
const minCellHeight = cellHeight ?
|
|
20769
|
+
const minCellWidth = cellWidth ? distance11.parse(cellWidth) : 0;
|
|
20770
|
+
const minCellHeight = cellHeight ? distance11.parse(cellHeight) : 0;
|
|
20741
20771
|
if (col !== void 0) {
|
|
20742
20772
|
cols = col;
|
|
20743
20773
|
rows = row ?? Math.ceil(itemsWithDims.length / cols);
|
|
@@ -20836,8 +20866,8 @@ function getItemDimensions(item, db) {
|
|
|
20836
20866
|
const props = subpanel._parsedProps;
|
|
20837
20867
|
if (props.width !== void 0 && props.height !== void 0) {
|
|
20838
20868
|
return {
|
|
20839
|
-
width:
|
|
20840
|
-
height:
|
|
20869
|
+
width: distance11.parse(props.width),
|
|
20870
|
+
height: distance11.parse(props.height)
|
|
20841
20871
|
};
|
|
20842
20872
|
}
|
|
20843
20873
|
const directBoards = subpanel._getDirectBoardChildren();
|
|
@@ -20864,7 +20894,7 @@ function getItemDimensions(item, db) {
|
|
|
20864
20894
|
return getBoardDimensionsFromProps(directBoards[0]);
|
|
20865
20895
|
}
|
|
20866
20896
|
if (subpanel._cachedGridWidth > 0 && subpanel._cachedGridHeight > 0) {
|
|
20867
|
-
const edgePadding =
|
|
20897
|
+
const edgePadding = distance11.parse(props.edgePadding ?? 5);
|
|
20868
20898
|
return {
|
|
20869
20899
|
width: subpanel._cachedGridWidth + edgePadding * 2,
|
|
20870
20900
|
height: subpanel._cachedGridHeight + edgePadding * 2
|
|
@@ -21011,17 +21041,17 @@ var Subpanel = class _Subpanel extends Group6 {
|
|
|
21011
21041
|
edgePaddingTop: edgePaddingTopProp,
|
|
21012
21042
|
edgePaddingBottom: edgePaddingBottomProp
|
|
21013
21043
|
} = this._parsedProps;
|
|
21014
|
-
const edgePadding =
|
|
21015
|
-
const edgePaddingLeft =
|
|
21016
|
-
const edgePaddingRight =
|
|
21044
|
+
const edgePadding = distance12.parse(edgePaddingProp ?? 5);
|
|
21045
|
+
const edgePaddingLeft = distance12.parse(edgePaddingLeftProp ?? edgePadding);
|
|
21046
|
+
const edgePaddingRight = distance12.parse(
|
|
21017
21047
|
edgePaddingRightProp ?? edgePadding
|
|
21018
21048
|
);
|
|
21019
|
-
const edgePaddingTop =
|
|
21020
|
-
const edgePaddingBottom =
|
|
21049
|
+
const edgePaddingTop = distance12.parse(edgePaddingTopProp ?? edgePadding);
|
|
21050
|
+
const edgePaddingBottom = distance12.parse(
|
|
21021
21051
|
edgePaddingBottomProp ?? edgePadding
|
|
21022
21052
|
);
|
|
21023
|
-
const panelWidth =
|
|
21024
|
-
const panelHeight =
|
|
21053
|
+
const panelWidth = distance12.parse(this._parsedProps.width);
|
|
21054
|
+
const panelHeight = distance12.parse(this._parsedProps.height);
|
|
21025
21055
|
availablePanelWidth = panelWidth - edgePaddingLeft - edgePaddingRight;
|
|
21026
21056
|
availablePanelHeight = panelHeight - edgePaddingTop - edgePaddingBottom;
|
|
21027
21057
|
}
|
|
@@ -21096,8 +21126,8 @@ var Subpanel = class _Subpanel extends Group6 {
|
|
|
21096
21126
|
if (!this.pcb_group_id) return;
|
|
21097
21127
|
if (hasExplicitWidth && hasExplicitHeight) {
|
|
21098
21128
|
db.pcb_group.update(this.pcb_group_id, {
|
|
21099
|
-
width:
|
|
21100
|
-
height:
|
|
21129
|
+
width: distance12.parse(this._parsedProps.width),
|
|
21130
|
+
height: distance12.parse(this._parsedProps.height)
|
|
21101
21131
|
});
|
|
21102
21132
|
} else if (gridWidth > 0 || gridHeight > 0) {
|
|
21103
21133
|
const {
|
|
@@ -21107,18 +21137,18 @@ var Subpanel = class _Subpanel extends Group6 {
|
|
|
21107
21137
|
edgePaddingTop: edgePaddingTopProp,
|
|
21108
21138
|
edgePaddingBottom: edgePaddingBottomProp
|
|
21109
21139
|
} = this._parsedProps;
|
|
21110
|
-
const edgePadding =
|
|
21111
|
-
const edgePaddingLeft =
|
|
21112
|
-
const edgePaddingRight =
|
|
21140
|
+
const edgePadding = distance12.parse(edgePaddingProp ?? 5);
|
|
21141
|
+
const edgePaddingLeft = distance12.parse(edgePaddingLeftProp ?? edgePadding);
|
|
21142
|
+
const edgePaddingRight = distance12.parse(
|
|
21113
21143
|
edgePaddingRightProp ?? edgePadding
|
|
21114
21144
|
);
|
|
21115
|
-
const edgePaddingTop =
|
|
21116
|
-
const edgePaddingBottom =
|
|
21145
|
+
const edgePaddingTop = distance12.parse(edgePaddingTopProp ?? edgePadding);
|
|
21146
|
+
const edgePaddingBottom = distance12.parse(
|
|
21117
21147
|
edgePaddingBottomProp ?? edgePadding
|
|
21118
21148
|
);
|
|
21119
21149
|
db.pcb_group.update(this.pcb_group_id, {
|
|
21120
|
-
width: hasExplicitWidth ?
|
|
21121
|
-
height: hasExplicitHeight ?
|
|
21150
|
+
width: hasExplicitWidth ? distance12.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
|
|
21151
|
+
height: hasExplicitHeight ? distance12.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
|
|
21122
21152
|
});
|
|
21123
21153
|
}
|
|
21124
21154
|
}
|
|
@@ -21192,8 +21222,8 @@ var Panel = class extends Subpanel {
|
|
|
21192
21222
|
const { db } = this.root;
|
|
21193
21223
|
const props = this._parsedProps;
|
|
21194
21224
|
const inserted = db.pcb_panel.insert({
|
|
21195
|
-
width: props.width !== void 0 ?
|
|
21196
|
-
height: props.height !== void 0 ?
|
|
21225
|
+
width: props.width !== void 0 ? distance13.parse(props.width) : 0,
|
|
21226
|
+
height: props.height !== void 0 ? distance13.parse(props.height) : 0,
|
|
21197
21227
|
thickness: 1.6,
|
|
21198
21228
|
center: this._getGlobalPcbPositionBeforeLayout(),
|
|
21199
21229
|
covered_with_solder_mask: !(props.noSolderMask ?? false)
|
|
@@ -21212,8 +21242,8 @@ var Panel = class extends Subpanel {
|
|
|
21212
21242
|
if (!this.pcb_panel_id) return;
|
|
21213
21243
|
if (hasExplicitWidth && hasExplicitHeight) {
|
|
21214
21244
|
db.pcb_panel.update(this.pcb_panel_id, {
|
|
21215
|
-
width:
|
|
21216
|
-
height:
|
|
21245
|
+
width: distance13.parse(this._parsedProps.width),
|
|
21246
|
+
height: distance13.parse(this._parsedProps.height)
|
|
21217
21247
|
});
|
|
21218
21248
|
} else if (gridWidth > 0 || gridHeight > 0) {
|
|
21219
21249
|
const {
|
|
@@ -21223,18 +21253,18 @@ var Panel = class extends Subpanel {
|
|
|
21223
21253
|
edgePaddingTop: edgePaddingTopProp,
|
|
21224
21254
|
edgePaddingBottom: edgePaddingBottomProp
|
|
21225
21255
|
} = this._parsedProps;
|
|
21226
|
-
const edgePadding =
|
|
21227
|
-
const edgePaddingLeft =
|
|
21228
|
-
const edgePaddingRight =
|
|
21256
|
+
const edgePadding = distance13.parse(edgePaddingProp ?? 5);
|
|
21257
|
+
const edgePaddingLeft = distance13.parse(edgePaddingLeftProp ?? edgePadding);
|
|
21258
|
+
const edgePaddingRight = distance13.parse(
|
|
21229
21259
|
edgePaddingRightProp ?? edgePadding
|
|
21230
21260
|
);
|
|
21231
|
-
const edgePaddingTop =
|
|
21232
|
-
const edgePaddingBottom =
|
|
21261
|
+
const edgePaddingTop = distance13.parse(edgePaddingTopProp ?? edgePadding);
|
|
21262
|
+
const edgePaddingBottom = distance13.parse(
|
|
21233
21263
|
edgePaddingBottomProp ?? edgePadding
|
|
21234
21264
|
);
|
|
21235
21265
|
db.pcb_panel.update(this.pcb_panel_id, {
|
|
21236
|
-
width: hasExplicitWidth ?
|
|
21237
|
-
height: hasExplicitHeight ?
|
|
21266
|
+
width: hasExplicitWidth ? distance13.parse(this._parsedProps.width) : gridWidth + edgePaddingLeft + edgePaddingRight,
|
|
21267
|
+
height: hasExplicitHeight ? distance13.parse(this._parsedProps.height) : gridHeight + edgePaddingTop + edgePaddingBottom
|
|
21238
21268
|
});
|
|
21239
21269
|
}
|
|
21240
21270
|
}
|
|
@@ -21245,8 +21275,8 @@ var Panel = class extends Subpanel {
|
|
|
21245
21275
|
const props = this._parsedProps;
|
|
21246
21276
|
const currentPanel = db.pcb_panel.get(this.pcb_panel_id);
|
|
21247
21277
|
db.pcb_panel.update(this.pcb_panel_id, {
|
|
21248
|
-
width: props.width !== void 0 ?
|
|
21249
|
-
height: props.height !== void 0 ?
|
|
21278
|
+
width: props.width !== void 0 ? distance13.parse(props.width) : currentPanel?.width,
|
|
21279
|
+
height: props.height !== void 0 ? distance13.parse(props.height) : currentPanel?.height,
|
|
21250
21280
|
center: this._getGlobalPcbPositionBeforeLayout(),
|
|
21251
21281
|
covered_with_solder_mask: !(props.noSolderMask ?? false)
|
|
21252
21282
|
});
|
|
@@ -22585,7 +22615,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
22585
22615
|
|
|
22586
22616
|
// lib/components/primitive-components/Fiducial.ts
|
|
22587
22617
|
import "zod";
|
|
22588
|
-
import { distance as
|
|
22618
|
+
import { distance as distance14 } from "circuit-json";
|
|
22589
22619
|
import { fiducialProps } from "@tscircuit/props";
|
|
22590
22620
|
var Fiducial = class extends PrimitiveComponent2 {
|
|
22591
22621
|
pcb_smtpad_id = null;
|
|
@@ -22610,15 +22640,15 @@ var Fiducial = class extends PrimitiveComponent2 {
|
|
|
22610
22640
|
shape: "circle",
|
|
22611
22641
|
x: position.x,
|
|
22612
22642
|
y: position.y,
|
|
22613
|
-
radius:
|
|
22614
|
-
soldermask_margin: props.soldermaskPullback ?
|
|
22643
|
+
radius: distance14.parse(props.padDiameter) / 2,
|
|
22644
|
+
soldermask_margin: props.soldermaskPullback ? distance14.parse(props.soldermaskPullback) : distance14.parse(props.padDiameter) / 2,
|
|
22615
22645
|
is_covered_with_solder_mask: true
|
|
22616
22646
|
});
|
|
22617
22647
|
this.pcb_smtpad_id = pcb_smtpad.pcb_smtpad_id;
|
|
22618
22648
|
}
|
|
22619
22649
|
getPcbSize() {
|
|
22620
22650
|
const { _parsedProps: props } = this;
|
|
22621
|
-
const d =
|
|
22651
|
+
const d = distance14.parse(props.padDiameter);
|
|
22622
22652
|
return { width: d, height: d };
|
|
22623
22653
|
}
|
|
22624
22654
|
_setPositionFromLayout(newCenter) {
|
|
@@ -23224,6 +23254,8 @@ var extractCadModelFromCircuitJson = (circuitJson) => {
|
|
|
23224
23254
|
import { symbols as symbols4 } from "schematic-symbols";
|
|
23225
23255
|
|
|
23226
23256
|
// lib/components/normal-components/Connector_insertInnerSymbolInSchematicBox.ts
|
|
23257
|
+
var INNER_SYMBOL_SCALE_FACTOR = 0.5;
|
|
23258
|
+
var INNER_SYMBOL_LEFT_SHIFT_FACTOR = 0.15;
|
|
23227
23259
|
function insertInnerSymbolInSchematicBox(connector, symbol) {
|
|
23228
23260
|
if (!connector.schematic_component_id || !connector.root) return;
|
|
23229
23261
|
const { db } = connector.root;
|
|
@@ -23232,9 +23264,8 @@ function insertInnerSymbolInSchematicBox(connector, symbol) {
|
|
|
23232
23264
|
);
|
|
23233
23265
|
if (!schematicComponent) return;
|
|
23234
23266
|
if (schematicComponent.symbol_name) return;
|
|
23235
|
-
const
|
|
23236
|
-
const
|
|
23237
|
-
const targetHeight = schematicComponent.size.height * innerScaleFactor;
|
|
23267
|
+
const targetWidth = schematicComponent.size.width * INNER_SYMBOL_SCALE_FACTOR;
|
|
23268
|
+
const targetHeight = schematicComponent.size.height * INNER_SYMBOL_SCALE_FACTOR;
|
|
23238
23269
|
const scaleFactor = Math.min(
|
|
23239
23270
|
targetWidth / symbol.size.width,
|
|
23240
23271
|
targetHeight / symbol.size.height
|
|
@@ -23243,8 +23274,9 @@ function insertInnerSymbolInSchematicBox(connector, symbol) {
|
|
|
23243
23274
|
const subcircuit_id = connector.getSubcircuit()?.subcircuit_id ?? void 0;
|
|
23244
23275
|
const center = schematicComponent.center;
|
|
23245
23276
|
const symbolCenter = symbol.center;
|
|
23277
|
+
const centerOffsetX = -schematicComponent.size.width * INNER_SYMBOL_LEFT_SHIFT_FACTOR;
|
|
23246
23278
|
const transformPoint = (point6) => ({
|
|
23247
|
-
x: center.x + (point6.x - symbolCenter.x) * scaleFactor,
|
|
23279
|
+
x: center.x + centerOffsetX + (point6.x - symbolCenter.x) * scaleFactor,
|
|
23248
23280
|
y: center.y + (point6.y - symbolCenter.y) * scaleFactor
|
|
23249
23281
|
});
|
|
23250
23282
|
for (const primitive of symbol.primitives) {
|
|
@@ -23303,6 +23335,42 @@ function insertInnerSymbolInSchematicBox(connector, symbol) {
|
|
|
23303
23335
|
}
|
|
23304
23336
|
|
|
23305
23337
|
// lib/components/normal-components/Connector.ts
|
|
23338
|
+
var USB_C_SIGNAL_LABELS_IN_ORDER = [
|
|
23339
|
+
"VBUS1",
|
|
23340
|
+
"VBUS2",
|
|
23341
|
+
"CC1",
|
|
23342
|
+
"CC2",
|
|
23343
|
+
"DP1",
|
|
23344
|
+
"DP2",
|
|
23345
|
+
"DM1",
|
|
23346
|
+
"DM2",
|
|
23347
|
+
"SBU1",
|
|
23348
|
+
"SBU2",
|
|
23349
|
+
"GND1",
|
|
23350
|
+
"GND2"
|
|
23351
|
+
];
|
|
23352
|
+
var USB_C_SHELL_LABELS_IN_ORDER = [
|
|
23353
|
+
"SHELL1",
|
|
23354
|
+
"SHELL2",
|
|
23355
|
+
"SHELL3",
|
|
23356
|
+
"SHELL4"
|
|
23357
|
+
];
|
|
23358
|
+
var USB_C_CANONICAL_LABELS_IN_ORDER = [
|
|
23359
|
+
...USB_C_SIGNAL_LABELS_IN_ORDER,
|
|
23360
|
+
...USB_C_SHELL_LABELS_IN_ORDER
|
|
23361
|
+
];
|
|
23362
|
+
var USB_C_CANONICAL_LABELS = /* @__PURE__ */ new Set([
|
|
23363
|
+
...USB_C_CANONICAL_LABELS_IN_ORDER
|
|
23364
|
+
]);
|
|
23365
|
+
var USB_C_DEFAULT_SCH_PIN_STYLE_BY_LABEL = [
|
|
23366
|
+
// Group spacing on right side
|
|
23367
|
+
["CC1", { marginTop: 0.15 }],
|
|
23368
|
+
["DP1", { marginTop: 0.15 }],
|
|
23369
|
+
["SBU1", { marginTop: 0.15 }],
|
|
23370
|
+
["GND1", { marginTop: 0.15 }],
|
|
23371
|
+
// Bottom-side label spacing uses horizontal margins.
|
|
23372
|
+
["SHELL4", { marginRight: 0.15 }]
|
|
23373
|
+
];
|
|
23306
23374
|
var Connector = class extends Chip {
|
|
23307
23375
|
_getConnectorProps() {
|
|
23308
23376
|
return this._parsedProps;
|
|
@@ -23382,6 +23450,93 @@ var Connector = class extends Chip {
|
|
|
23382
23450
|
this.addAll(fpComponents);
|
|
23383
23451
|
this._markDirty("InitializePortsFromChildren");
|
|
23384
23452
|
}
|
|
23453
|
+
_getUsbCCanonicalLabelToPinNumberMap() {
|
|
23454
|
+
const labelToPinNumber = /* @__PURE__ */ new Map();
|
|
23455
|
+
const ports = this.selectAll("port");
|
|
23456
|
+
for (const port of ports) {
|
|
23457
|
+
const pinNumber = port.props.pinNumber;
|
|
23458
|
+
if (typeof pinNumber !== "number") continue;
|
|
23459
|
+
for (const alias of port.getNameAndAliases()) {
|
|
23460
|
+
const normalizedAlias = alias.trim().toUpperCase();
|
|
23461
|
+
if (!USB_C_CANONICAL_LABELS.has(normalizedAlias)) continue;
|
|
23462
|
+
const label = normalizedAlias;
|
|
23463
|
+
if (!labelToPinNumber.has(label)) {
|
|
23464
|
+
labelToPinNumber.set(label, pinNumber);
|
|
23465
|
+
}
|
|
23466
|
+
}
|
|
23467
|
+
}
|
|
23468
|
+
return labelToPinNumber;
|
|
23469
|
+
}
|
|
23470
|
+
_getSchematicPortArrangement() {
|
|
23471
|
+
const arrangement = super._getSchematicPortArrangement();
|
|
23472
|
+
if (arrangement && Object.keys(arrangement).length > 0) return arrangement;
|
|
23473
|
+
if (this._getConnectorProps().standard !== "usb_c") return arrangement;
|
|
23474
|
+
const labelToPinNumber = this._getUsbCCanonicalLabelToPinNumberMap();
|
|
23475
|
+
const rightPins = USB_C_SIGNAL_LABELS_IN_ORDER.map(
|
|
23476
|
+
(label) => labelToPinNumber.get(label)
|
|
23477
|
+
).filter((pin) => typeof pin === "number");
|
|
23478
|
+
const bottomPins = USB_C_SHELL_LABELS_IN_ORDER.map(
|
|
23479
|
+
(label) => labelToPinNumber.get(label)
|
|
23480
|
+
).filter((pin) => typeof pin === "number");
|
|
23481
|
+
if (rightPins.length === 0 && bottomPins.length === 0) return arrangement;
|
|
23482
|
+
const canonicalArrangement = {};
|
|
23483
|
+
if (rightPins.length > 0) {
|
|
23484
|
+
canonicalArrangement.rightSide = {
|
|
23485
|
+
pins: rightPins,
|
|
23486
|
+
direction: "top-to-bottom"
|
|
23487
|
+
};
|
|
23488
|
+
}
|
|
23489
|
+
if (bottomPins.length > 0) {
|
|
23490
|
+
canonicalArrangement.bottomSide = {
|
|
23491
|
+
pins: bottomPins,
|
|
23492
|
+
direction: "left-to-right"
|
|
23493
|
+
};
|
|
23494
|
+
}
|
|
23495
|
+
return canonicalArrangement;
|
|
23496
|
+
}
|
|
23497
|
+
_getSchematicBoxDimensions() {
|
|
23498
|
+
if (this._getConnectorProps().standard !== "usb_c") {
|
|
23499
|
+
return super._getSchematicBoxDimensions();
|
|
23500
|
+
}
|
|
23501
|
+
if (this.getSchematicSymbol()) return null;
|
|
23502
|
+
if (!this.config.shouldRenderAsSchematicBox) return null;
|
|
23503
|
+
const { _parsedProps: props } = this;
|
|
23504
|
+
const pinCount = this._getPinCount();
|
|
23505
|
+
const pinSpacing = props.schPinSpacing ?? 0.2;
|
|
23506
|
+
const pinLabelsFromPorts = this._getPinLabelsFromPorts();
|
|
23507
|
+
const allPinLabels = {
|
|
23508
|
+
...pinLabelsFromPorts
|
|
23509
|
+
};
|
|
23510
|
+
if (props.pinLabels) {
|
|
23511
|
+
for (const [k, v] of Object.entries(props.pinLabels)) {
|
|
23512
|
+
if (typeof v === "string") allPinLabels[k] = v;
|
|
23513
|
+
}
|
|
23514
|
+
}
|
|
23515
|
+
const labelToPinNumber = this._getUsbCCanonicalLabelToPinNumberMap();
|
|
23516
|
+
const resolvedDefaultSchPinStyle = {};
|
|
23517
|
+
for (const [label, style] of USB_C_DEFAULT_SCH_PIN_STYLE_BY_LABEL) {
|
|
23518
|
+
const pinNumber = labelToPinNumber.get(label);
|
|
23519
|
+
if (typeof pinNumber !== "number") continue;
|
|
23520
|
+
resolvedDefaultSchPinStyle[`pin${pinNumber}`] = style;
|
|
23521
|
+
}
|
|
23522
|
+
const mergedSchPinStyle = {
|
|
23523
|
+
...resolvedDefaultSchPinStyle,
|
|
23524
|
+
...props.schPinStyle ?? {}
|
|
23525
|
+
};
|
|
23526
|
+
const schPortArrangement = this._getSchematicPortArrangement();
|
|
23527
|
+
return getAllDimensionsForSchematicBox({
|
|
23528
|
+
schWidth: props.schWidth,
|
|
23529
|
+
schHeight: props.schHeight,
|
|
23530
|
+
schPinSpacing: pinSpacing,
|
|
23531
|
+
numericSchPinStyle: getNumericSchPinStyle(
|
|
23532
|
+
mergedSchPinStyle,
|
|
23533
|
+
allPinLabels
|
|
23534
|
+
),
|
|
23535
|
+
pinCount,
|
|
23536
|
+
schPortArrangement: schPortArrangement ?? void 0,
|
|
23537
|
+
pinLabels: allPinLabels
|
|
23538
|
+
});
|
|
23539
|
+
}
|
|
23385
23540
|
get config() {
|
|
23386
23541
|
return {
|
|
23387
23542
|
componentName: "Connector",
|