@tscircuit/core 0.0.1484 → 0.0.1486
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 +9 -1
- package/dist/index.js +625 -530
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -95131,7 +95131,8 @@ declare class Connector<PinLabels extends string = never> extends Chip<PinLabels
|
|
|
95131
95131
|
private _getConnectorProps;
|
|
95132
95132
|
private _hasExplicitFootprint;
|
|
95133
95133
|
private _shouldUseStandardPartsEngineCircuitJsonFlow;
|
|
95134
|
-
private
|
|
95134
|
+
private _addUsbCCanonicalFallbackPorts;
|
|
95135
|
+
private _handleStandardConnectorCircuitJsonFailure;
|
|
95135
95136
|
private _getSupplierPartNumbersToTry;
|
|
95136
95137
|
private _tryFetchPartCircuitJson;
|
|
95137
95138
|
private _fetchStandardConnectorCircuitJson;
|
|
@@ -153037,6 +153038,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
|
|
|
153037
153038
|
}>>;
|
|
153038
153039
|
schX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
153039
153040
|
schY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
153041
|
+
schSheetName: zod.ZodOptional<zod.ZodString>;
|
|
153040
153042
|
width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
153041
153043
|
height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
153042
153044
|
overlay: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
@@ -153060,6 +153062,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
|
|
|
153060
153062
|
name?: string | undefined;
|
|
153061
153063
|
schX?: number | undefined;
|
|
153062
153064
|
schY?: number | undefined;
|
|
153065
|
+
schSheetName?: string | undefined;
|
|
153063
153066
|
padding?: number | undefined;
|
|
153064
153067
|
paddingLeft?: number | undefined;
|
|
153065
153068
|
paddingRight?: number | undefined;
|
|
@@ -153103,6 +153106,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
|
|
|
153103
153106
|
name?: string | undefined;
|
|
153104
153107
|
schX?: string | number | undefined;
|
|
153105
153108
|
schY?: string | number | undefined;
|
|
153109
|
+
schSheetName?: string | undefined;
|
|
153106
153110
|
padding?: string | number | undefined;
|
|
153107
153111
|
paddingLeft?: string | number | undefined;
|
|
153108
153112
|
paddingRight?: string | number | undefined;
|
|
@@ -153152,6 +153156,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
|
|
|
153152
153156
|
name?: string | undefined;
|
|
153153
153157
|
schX?: number | undefined;
|
|
153154
153158
|
schY?: number | undefined;
|
|
153159
|
+
schSheetName?: string | undefined;
|
|
153155
153160
|
padding?: number | undefined;
|
|
153156
153161
|
paddingLeft?: number | undefined;
|
|
153157
153162
|
paddingRight?: number | undefined;
|
|
@@ -153195,6 +153200,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
|
|
|
153195
153200
|
name?: string | undefined;
|
|
153196
153201
|
schX?: string | number | undefined;
|
|
153197
153202
|
schY?: string | number | undefined;
|
|
153203
|
+
schSheetName?: string | undefined;
|
|
153198
153204
|
padding?: string | number | undefined;
|
|
153199
153205
|
paddingLeft?: string | number | undefined;
|
|
153200
153206
|
paddingRight?: string | number | undefined;
|
|
@@ -153244,6 +153250,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
|
|
|
153244
153250
|
name?: string | undefined;
|
|
153245
153251
|
schX?: number | undefined;
|
|
153246
153252
|
schY?: number | undefined;
|
|
153253
|
+
schSheetName?: string | undefined;
|
|
153247
153254
|
padding?: number | undefined;
|
|
153248
153255
|
paddingLeft?: number | undefined;
|
|
153249
153256
|
paddingRight?: number | undefined;
|
|
@@ -153287,6 +153294,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
|
|
|
153287
153294
|
name?: string | undefined;
|
|
153288
153295
|
schX?: string | number | undefined;
|
|
153289
153296
|
schY?: string | number | undefined;
|
|
153297
|
+
schSheetName?: string | undefined;
|
|
153290
153298
|
padding?: string | number | undefined;
|
|
153291
153299
|
paddingLeft?: string | number | undefined;
|
|
153292
153300
|
paddingRight?: string | number | undefined;
|
package/dist/index.js
CHANGED
|
@@ -17213,8 +17213,8 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
17213
17213
|
];
|
|
17214
17214
|
const defaultTraceWidth = minTraceWidth ?? board?.min_trace_width ?? 0.1;
|
|
17215
17215
|
for (const conn of allConns) {
|
|
17216
|
-
conn.nominalTraceWidth ??= defaultTraceWidth;
|
|
17217
|
-
conn.width ??= defaultTraceWidth;
|
|
17216
|
+
conn.nominalTraceWidth ??= nominalTraceWidth ?? defaultTraceWidth;
|
|
17217
|
+
conn.width ??= nominalTraceWidth ?? defaultTraceWidth;
|
|
17218
17218
|
}
|
|
17219
17219
|
const differentialPairs = subcircuitComponent?.selectAll("differentialpair") ?? [];
|
|
17220
17220
|
const srjDifferentialPairs = getDifferentialPairsForSimpleRouteJson({
|
|
@@ -17463,6 +17463,409 @@ var TraceHint = class extends PrimitiveComponent2 {
|
|
|
17463
17463
|
}
|
|
17464
17464
|
};
|
|
17465
17465
|
|
|
17466
|
+
// lib/components/primitive-components/SchematicBox/SchematicBox.ts
|
|
17467
|
+
import { schematicBoxProps } from "@tscircuit/props";
|
|
17468
|
+
|
|
17469
|
+
// lib/components/primitive-components/getTitleAnchorAndPosition.ts
|
|
17470
|
+
function getTitleAnchorAndPosition({
|
|
17471
|
+
anchor,
|
|
17472
|
+
x,
|
|
17473
|
+
y,
|
|
17474
|
+
width,
|
|
17475
|
+
height,
|
|
17476
|
+
isInside
|
|
17477
|
+
}) {
|
|
17478
|
+
switch (anchor) {
|
|
17479
|
+
case "top_left":
|
|
17480
|
+
return {
|
|
17481
|
+
x,
|
|
17482
|
+
y: y + height,
|
|
17483
|
+
textAnchor: isInside ? "top_left" : "bottom_left"
|
|
17484
|
+
};
|
|
17485
|
+
case "top_center":
|
|
17486
|
+
return {
|
|
17487
|
+
x: x + width / 2,
|
|
17488
|
+
y: y + height,
|
|
17489
|
+
textAnchor: isInside ? "top_center" : "bottom_center"
|
|
17490
|
+
};
|
|
17491
|
+
case "top_right":
|
|
17492
|
+
return {
|
|
17493
|
+
x: x + width,
|
|
17494
|
+
y: y + height,
|
|
17495
|
+
textAnchor: isInside ? "top_right" : "bottom_right"
|
|
17496
|
+
};
|
|
17497
|
+
case "center_left":
|
|
17498
|
+
return {
|
|
17499
|
+
x,
|
|
17500
|
+
y: y + height / 2,
|
|
17501
|
+
textAnchor: isInside ? "center_left" : "center_right"
|
|
17502
|
+
};
|
|
17503
|
+
case "center":
|
|
17504
|
+
return {
|
|
17505
|
+
x: x + width / 2,
|
|
17506
|
+
y: y + height / 2,
|
|
17507
|
+
textAnchor: "center"
|
|
17508
|
+
};
|
|
17509
|
+
case "center_right":
|
|
17510
|
+
return {
|
|
17511
|
+
x: x + width,
|
|
17512
|
+
y: y + height / 2,
|
|
17513
|
+
textAnchor: isInside ? "center_right" : "center_left"
|
|
17514
|
+
};
|
|
17515
|
+
case "bottom_left":
|
|
17516
|
+
return {
|
|
17517
|
+
x,
|
|
17518
|
+
y,
|
|
17519
|
+
textAnchor: isInside ? "bottom_left" : "top_left"
|
|
17520
|
+
};
|
|
17521
|
+
case "bottom_center":
|
|
17522
|
+
return {
|
|
17523
|
+
x: x + width / 2,
|
|
17524
|
+
y,
|
|
17525
|
+
textAnchor: isInside ? "bottom_center" : "top_center"
|
|
17526
|
+
};
|
|
17527
|
+
case "bottom_right":
|
|
17528
|
+
return {
|
|
17529
|
+
x: x + width,
|
|
17530
|
+
y,
|
|
17531
|
+
textAnchor: isInside ? "bottom_right" : "top_right"
|
|
17532
|
+
};
|
|
17533
|
+
default:
|
|
17534
|
+
return {
|
|
17535
|
+
x: x + width / 2,
|
|
17536
|
+
y: y + height,
|
|
17537
|
+
textAnchor: "center"
|
|
17538
|
+
};
|
|
17539
|
+
}
|
|
17540
|
+
}
|
|
17541
|
+
|
|
17542
|
+
// lib/components/primitive-components/SchematicBox/SchematicBox_doInitialSchematicComponentRender.ts
|
|
17543
|
+
var getSchematicBoxPinLabels = (pinLabels) => {
|
|
17544
|
+
if (!pinLabels) return [];
|
|
17545
|
+
return Object.entries(pinLabels).map(([pinKey, pinLabel]) => {
|
|
17546
|
+
const pinNumber = getPinNumberFromPinLabelsKey(pinKey);
|
|
17547
|
+
if (pinNumber === null) {
|
|
17548
|
+
throw new Error(
|
|
17549
|
+
`Invalid schematicbox pinLabels key "${pinKey}". Expected pin<number>.`
|
|
17550
|
+
);
|
|
17551
|
+
}
|
|
17552
|
+
const pinAliases = typeof pinLabel === "string" ? [pinLabel] : [...pinLabel];
|
|
17553
|
+
return {
|
|
17554
|
+
pinNumber,
|
|
17555
|
+
displayPinLabel: pinAliases[0] ?? pinKey,
|
|
17556
|
+
pinAliases
|
|
17557
|
+
};
|
|
17558
|
+
});
|
|
17559
|
+
};
|
|
17560
|
+
var SchematicBox_doInitialSchematicComponentRender = (schematicBox) => {
|
|
17561
|
+
if (schematicBox.root?.schematicDisabled) return;
|
|
17562
|
+
const { db } = schematicBox.root;
|
|
17563
|
+
const props = schematicBox._parsedProps;
|
|
17564
|
+
if (!props.chipRef) return;
|
|
17565
|
+
const referencedChip = schematicBox.getSubcircuit().selectOne(props.chipRef);
|
|
17566
|
+
if (!referencedChip?.source_component_id) {
|
|
17567
|
+
throw new Error(
|
|
17568
|
+
`Could not resolve chipRef "${props.chipRef}" for ${schematicBox.getString()}`
|
|
17569
|
+
);
|
|
17570
|
+
}
|
|
17571
|
+
const schematicBoxPinLabels = getSchematicBoxPinLabels(props.pinLabels);
|
|
17572
|
+
const pinLabelsByPinKey = Object.fromEntries(
|
|
17573
|
+
schematicBoxPinLabels.map(({ pinNumber, displayPinLabel }) => [
|
|
17574
|
+
`pin${pinNumber}`,
|
|
17575
|
+
displayPinLabel
|
|
17576
|
+
])
|
|
17577
|
+
);
|
|
17578
|
+
const sourcePorts = db.source_port.list({
|
|
17579
|
+
source_component_id: referencedChip.source_component_id
|
|
17580
|
+
});
|
|
17581
|
+
const dimensions = getAllDimensionsForSchematicBox({
|
|
17582
|
+
schWidth: props.width,
|
|
17583
|
+
schHeight: props.height,
|
|
17584
|
+
schPinSpacing: 0.2,
|
|
17585
|
+
pinCount: schematicBoxPinLabels.length,
|
|
17586
|
+
schPortArrangement: props.schPinArrangement,
|
|
17587
|
+
pinLabels: pinLabelsByPinKey
|
|
17588
|
+
});
|
|
17589
|
+
const center = schematicBox._getGlobalSchematicPositionBeforeLayout();
|
|
17590
|
+
const size = dimensions.getSize();
|
|
17591
|
+
const schematicSheetId = schematicBox._resolveSchematicSheetId();
|
|
17592
|
+
const portLabels = Object.fromEntries(
|
|
17593
|
+
schematicBoxPinLabels.map(({ pinNumber, displayPinLabel }) => [
|
|
17594
|
+
String(pinNumber),
|
|
17595
|
+
displayPinLabel
|
|
17596
|
+
])
|
|
17597
|
+
);
|
|
17598
|
+
const schematicComponent = db.schematic_component.insert({
|
|
17599
|
+
center,
|
|
17600
|
+
size,
|
|
17601
|
+
source_component_id: referencedChip.source_component_id,
|
|
17602
|
+
is_box_with_pins: true,
|
|
17603
|
+
port_arrangement: underscorifyPortArrangement(props.schPinArrangement),
|
|
17604
|
+
port_labels: portLabels,
|
|
17605
|
+
pin_spacing: 0.2,
|
|
17606
|
+
schematic_sheet_id: schematicSheetId
|
|
17607
|
+
});
|
|
17608
|
+
schematicBox.schematic_component_id = schematicComponent.schematic_component_id;
|
|
17609
|
+
for (const {
|
|
17610
|
+
pinNumber,
|
|
17611
|
+
displayPinLabel,
|
|
17612
|
+
pinAliases
|
|
17613
|
+
} of schematicBoxPinLabels) {
|
|
17614
|
+
const referencedSourcePort = sourcePorts.find(
|
|
17615
|
+
(sourcePort) => pinAliases.some(
|
|
17616
|
+
(pinAlias) => sourcePort.name === pinAlias || sourcePort.port_hints?.includes(pinAlias)
|
|
17617
|
+
)
|
|
17618
|
+
);
|
|
17619
|
+
if (!referencedSourcePort) {
|
|
17620
|
+
throw new Error(
|
|
17621
|
+
`Could not find pin "${displayPinLabel}" on chipRef "${props.chipRef}"`
|
|
17622
|
+
);
|
|
17623
|
+
}
|
|
17624
|
+
const portPosition = dimensions.getPortPositionByPinNumber(pinNumber);
|
|
17625
|
+
if (!portPosition) {
|
|
17626
|
+
throw new Error(
|
|
17627
|
+
`Could not determine schematic position for ${schematicBox.getString()} pin${pinNumber}`
|
|
17628
|
+
);
|
|
17629
|
+
}
|
|
17630
|
+
const facingDirection = {
|
|
17631
|
+
left: "left",
|
|
17632
|
+
right: "right",
|
|
17633
|
+
top: "up",
|
|
17634
|
+
bottom: "down"
|
|
17635
|
+
}[portPosition.side];
|
|
17636
|
+
db.schematic_port.insert({
|
|
17637
|
+
schematic_component_id: schematicComponent.schematic_component_id,
|
|
17638
|
+
center: {
|
|
17639
|
+
x: center.x + portPosition.x,
|
|
17640
|
+
y: center.y + portPosition.y
|
|
17641
|
+
},
|
|
17642
|
+
source_port_id: referencedSourcePort.source_port_id,
|
|
17643
|
+
facing_direction: facingDirection,
|
|
17644
|
+
distance_from_component_edge: 0.4,
|
|
17645
|
+
side_of_component: portPosition.side,
|
|
17646
|
+
pin_number: pinNumber,
|
|
17647
|
+
true_ccw_index: portPosition.trueIndex,
|
|
17648
|
+
display_pin_label: displayPinLabel,
|
|
17649
|
+
is_connected: false,
|
|
17650
|
+
schematic_sheet_id: schematicSheetId
|
|
17651
|
+
});
|
|
17652
|
+
}
|
|
17653
|
+
const sectionName = props.name ?? props.chipRef;
|
|
17654
|
+
db.schematic_text.insert({
|
|
17655
|
+
text: sectionName,
|
|
17656
|
+
schematic_component_id: schematicComponent.schematic_component_id,
|
|
17657
|
+
anchor: "left",
|
|
17658
|
+
rotation: 0,
|
|
17659
|
+
position: {
|
|
17660
|
+
x: center.x - size.width / 2,
|
|
17661
|
+
y: center.y + size.height / 2 + 0.13
|
|
17662
|
+
},
|
|
17663
|
+
color: "#006464",
|
|
17664
|
+
font_size: 0.18,
|
|
17665
|
+
schematic_sheet_id: schematicSheetId
|
|
17666
|
+
});
|
|
17667
|
+
};
|
|
17668
|
+
|
|
17669
|
+
// lib/components/primitive-components/SchematicBox/SchematicBox.ts
|
|
17670
|
+
var SchematicBox = class extends PrimitiveComponent2 {
|
|
17671
|
+
isSchematicPrimitive = true;
|
|
17672
|
+
get config() {
|
|
17673
|
+
return {
|
|
17674
|
+
componentName: "SchematicBox",
|
|
17675
|
+
zodProps: schematicBoxProps,
|
|
17676
|
+
shouldRenderAsSchematicBox: true
|
|
17677
|
+
};
|
|
17678
|
+
}
|
|
17679
|
+
doInitialSchematicComponentRender() {
|
|
17680
|
+
SchematicBox_doInitialSchematicComponentRender(this);
|
|
17681
|
+
}
|
|
17682
|
+
doInitialSchematicPrimitiveRender() {
|
|
17683
|
+
if (this.root?.schematicDisabled) return;
|
|
17684
|
+
if (this.getCollapsedSchematicBoxAncestor()) return;
|
|
17685
|
+
const { db } = this.root;
|
|
17686
|
+
const { _parsedProps: props } = this;
|
|
17687
|
+
if (props.chipRef) return;
|
|
17688
|
+
const basePadding = 0.6;
|
|
17689
|
+
const generalPadding = typeof props.padding === "number" ? props.padding : 0;
|
|
17690
|
+
const paddingTop = typeof props.paddingTop === "number" ? props.paddingTop : generalPadding;
|
|
17691
|
+
const paddingBottom = typeof props.paddingBottom === "number" ? props.paddingBottom : generalPadding;
|
|
17692
|
+
const paddingLeft = typeof props.paddingLeft === "number" ? props.paddingLeft : generalPadding;
|
|
17693
|
+
const paddingRight = typeof props.paddingRight === "number" ? props.paddingRight : generalPadding;
|
|
17694
|
+
const hasOverlay = props.overlay && props.overlay.length > 0;
|
|
17695
|
+
const hasFixedSize = typeof props.width === "number" && typeof props.height === "number";
|
|
17696
|
+
let width;
|
|
17697
|
+
let height;
|
|
17698
|
+
let x;
|
|
17699
|
+
let y;
|
|
17700
|
+
let centerX;
|
|
17701
|
+
let centerY;
|
|
17702
|
+
if (hasOverlay) {
|
|
17703
|
+
const portsWithSelectors = props.overlay.map((selector) => ({
|
|
17704
|
+
selector,
|
|
17705
|
+
port: this.getSubcircuit().selectOne(selector, {
|
|
17706
|
+
type: "port"
|
|
17707
|
+
})
|
|
17708
|
+
})).filter(({ port }) => port != null);
|
|
17709
|
+
const portsWithPosition = portsWithSelectors.map(({ port }) => ({
|
|
17710
|
+
position: port._getGlobalSchematicPositionAfterLayout()
|
|
17711
|
+
}));
|
|
17712
|
+
if (portsWithPosition.length === 0) return;
|
|
17713
|
+
const xs = portsWithPosition.map((p) => p.position.x);
|
|
17714
|
+
const ys = portsWithPosition.map((p) => p.position.y);
|
|
17715
|
+
const minX = Math.min(...xs);
|
|
17716
|
+
const maxX = Math.max(...xs);
|
|
17717
|
+
const minY = Math.min(...ys);
|
|
17718
|
+
const maxY = Math.max(...ys);
|
|
17719
|
+
const rawWidth = maxX - minX;
|
|
17720
|
+
const rawHeight = maxY - minY;
|
|
17721
|
+
const defaultHorizontalPadding = rawWidth === 0 ? basePadding : 0;
|
|
17722
|
+
const defaultVerticalPadding = rawHeight === 0 ? basePadding : 0;
|
|
17723
|
+
const finalPaddingLeft = paddingLeft + defaultHorizontalPadding / 2;
|
|
17724
|
+
const finalPaddingRight = paddingRight + defaultHorizontalPadding / 2;
|
|
17725
|
+
const finalPaddingTop = paddingTop + defaultVerticalPadding / 2;
|
|
17726
|
+
const finalPaddingBottom = paddingBottom + defaultVerticalPadding / 2;
|
|
17727
|
+
const left = minX - finalPaddingLeft;
|
|
17728
|
+
const right = maxX + finalPaddingRight;
|
|
17729
|
+
const top = minY - finalPaddingBottom;
|
|
17730
|
+
const bottom = maxY + finalPaddingTop;
|
|
17731
|
+
width = right - left;
|
|
17732
|
+
height = bottom - top;
|
|
17733
|
+
x = left + (props.schX ?? 0);
|
|
17734
|
+
y = top + (props.schY ?? 0);
|
|
17735
|
+
centerX = x + width / 2;
|
|
17736
|
+
centerY = y + height / 2;
|
|
17737
|
+
} else if (hasFixedSize) {
|
|
17738
|
+
width = props.width;
|
|
17739
|
+
height = props.height;
|
|
17740
|
+
const center = this._getGlobalSchematicPositionBeforeLayout();
|
|
17741
|
+
centerX = center.x;
|
|
17742
|
+
centerY = center.y;
|
|
17743
|
+
x = centerX - width / 2;
|
|
17744
|
+
y = centerY - height / 2;
|
|
17745
|
+
} else {
|
|
17746
|
+
return;
|
|
17747
|
+
}
|
|
17748
|
+
db.schematic_box.insert({
|
|
17749
|
+
height,
|
|
17750
|
+
width,
|
|
17751
|
+
x,
|
|
17752
|
+
y,
|
|
17753
|
+
is_dashed: props.strokeStyle === "dashed",
|
|
17754
|
+
schematic_sheet_id: this._resolveSchematicSheetId()
|
|
17755
|
+
});
|
|
17756
|
+
if (props.title) {
|
|
17757
|
+
const isInside = props.titleInside;
|
|
17758
|
+
const TITLE_PADDING = 0.1;
|
|
17759
|
+
const anchor = props.titleAlignment;
|
|
17760
|
+
const anchorPos = getTitleAnchorAndPosition({
|
|
17761
|
+
anchor,
|
|
17762
|
+
x,
|
|
17763
|
+
y,
|
|
17764
|
+
width,
|
|
17765
|
+
height,
|
|
17766
|
+
isInside
|
|
17767
|
+
});
|
|
17768
|
+
let titleOffsetY;
|
|
17769
|
+
let titleOffsetX;
|
|
17770
|
+
const textAnchor = anchorPos.textAnchor;
|
|
17771
|
+
if (isInside) {
|
|
17772
|
+
titleOffsetY = anchor.includes("top") ? -TITLE_PADDING : anchor.includes("bottom") ? TITLE_PADDING : 0;
|
|
17773
|
+
titleOffsetX = anchor.includes("left") ? TITLE_PADDING : anchor.includes("right") ? -TITLE_PADDING : 0;
|
|
17774
|
+
} else {
|
|
17775
|
+
titleOffsetY = anchor.includes("top") ? TITLE_PADDING : anchor.includes("bottom") ? -TITLE_PADDING : 0;
|
|
17776
|
+
titleOffsetX = anchor.includes("center_left") ? -TITLE_PADDING : anchor.includes("center_right") ? TITLE_PADDING : 0;
|
|
17777
|
+
}
|
|
17778
|
+
const titleX = anchorPos.x + titleOffsetX;
|
|
17779
|
+
const titleY = anchorPos.y + titleOffsetY;
|
|
17780
|
+
db.schematic_text.insert({
|
|
17781
|
+
anchor: textAnchor,
|
|
17782
|
+
text: props.title,
|
|
17783
|
+
font_size: props.titleFontSize ?? 0.18,
|
|
17784
|
+
color: props.titleColor ?? "#000000",
|
|
17785
|
+
position: {
|
|
17786
|
+
x: titleX,
|
|
17787
|
+
y: titleY
|
|
17788
|
+
},
|
|
17789
|
+
rotation: 0,
|
|
17790
|
+
schematic_sheet_id: this._resolveSchematicSheetId()
|
|
17791
|
+
});
|
|
17792
|
+
}
|
|
17793
|
+
}
|
|
17794
|
+
};
|
|
17795
|
+
|
|
17796
|
+
// lib/components/primitive-components/Group/Group_doInitialAssignSchematicSheetToConnectedComponents.ts
|
|
17797
|
+
var Group_doInitialAssignSchematicSheetToConnectedComponents = (group) => {
|
|
17798
|
+
if (!group.isSubcircuit || group.root?.schematicDisabled) return;
|
|
17799
|
+
const { db } = group.root;
|
|
17800
|
+
const schematicSheetIdsBySubcircuitConnectivityMapKey = /* @__PURE__ */ new Map();
|
|
17801
|
+
const schematicBoxReferencedSourceComponentIds = /* @__PURE__ */ new Set();
|
|
17802
|
+
const schematicBoxes = group.getDescendants().filter(
|
|
17803
|
+
(component) => component instanceof SchematicBox && component.getSubcircuit() === group
|
|
17804
|
+
);
|
|
17805
|
+
for (const schematicBox of schematicBoxes) {
|
|
17806
|
+
const { chipRef, pinLabels } = schematicBox._parsedProps;
|
|
17807
|
+
const schematicSheetId = schematicBox._resolveSchematicSheetId();
|
|
17808
|
+
if (!chipRef || !schematicSheetId) continue;
|
|
17809
|
+
const referencedComponent = schematicBox.getSubcircuit().selectOne(chipRef);
|
|
17810
|
+
if (!(referencedComponent instanceof NormalComponent3)) continue;
|
|
17811
|
+
if (!referencedComponent.source_component_id) continue;
|
|
17812
|
+
schematicBoxReferencedSourceComponentIds.add(
|
|
17813
|
+
referencedComponent.source_component_id
|
|
17814
|
+
);
|
|
17815
|
+
const referencedSourcePorts = db.source_port.list({
|
|
17816
|
+
source_component_id: referencedComponent.source_component_id
|
|
17817
|
+
});
|
|
17818
|
+
for (const { pinAliases } of getSchematicBoxPinLabels(pinLabels)) {
|
|
17819
|
+
const referencedSourcePort = referencedSourcePorts.find(
|
|
17820
|
+
(sourcePort) => pinAliases.some(
|
|
17821
|
+
(pinAlias) => sourcePort.name === pinAlias || sourcePort.port_hints?.includes(pinAlias)
|
|
17822
|
+
)
|
|
17823
|
+
);
|
|
17824
|
+
const subcircuitConnectivityMapKey = referencedSourcePort?.subcircuit_connectivity_map_key;
|
|
17825
|
+
if (!subcircuitConnectivityMapKey) continue;
|
|
17826
|
+
const schematicSheetIds = schematicSheetIdsBySubcircuitConnectivityMapKey.get(
|
|
17827
|
+
subcircuitConnectivityMapKey
|
|
17828
|
+
) ?? /* @__PURE__ */ new Set();
|
|
17829
|
+
schematicSheetIds.add(schematicSheetId);
|
|
17830
|
+
schematicSheetIdsBySubcircuitConnectivityMapKey.set(
|
|
17831
|
+
subcircuitConnectivityMapKey,
|
|
17832
|
+
schematicSheetIds
|
|
17833
|
+
);
|
|
17834
|
+
}
|
|
17835
|
+
}
|
|
17836
|
+
const normalComponents = group.getDescendants().filter(
|
|
17837
|
+
(component) => component instanceof NormalComponent3 && component.getSubcircuit() === group
|
|
17838
|
+
);
|
|
17839
|
+
for (const normalComponent of normalComponents) {
|
|
17840
|
+
if (!normalComponent.source_component_id) continue;
|
|
17841
|
+
if (schematicBoxReferencedSourceComponentIds.has(
|
|
17842
|
+
normalComponent.source_component_id
|
|
17843
|
+
)) {
|
|
17844
|
+
continue;
|
|
17845
|
+
}
|
|
17846
|
+
if (normalComponent._resolveSchematicSheetId()) continue;
|
|
17847
|
+
const connectedSchematicSheetIds = /* @__PURE__ */ new Set();
|
|
17848
|
+
const sourcePorts = db.source_port.list({
|
|
17849
|
+
source_component_id: normalComponent.source_component_id
|
|
17850
|
+
});
|
|
17851
|
+
for (const sourcePort of sourcePorts) {
|
|
17852
|
+
const subcircuitConnectivityMapKey = sourcePort.subcircuit_connectivity_map_key;
|
|
17853
|
+
if (!subcircuitConnectivityMapKey) continue;
|
|
17854
|
+
const schematicSheetIds = schematicSheetIdsBySubcircuitConnectivityMapKey.get(
|
|
17855
|
+
subcircuitConnectivityMapKey
|
|
17856
|
+
);
|
|
17857
|
+
if (!schematicSheetIds) continue;
|
|
17858
|
+
for (const schematicSheetId of schematicSheetIds) {
|
|
17859
|
+
connectedSchematicSheetIds.add(schematicSheetId);
|
|
17860
|
+
}
|
|
17861
|
+
}
|
|
17862
|
+
if (connectedSchematicSheetIds.size !== 1) continue;
|
|
17863
|
+
const [inferredSchematicSheetId] = connectedSchematicSheetIds;
|
|
17864
|
+
if (!inferredSchematicSheetId) continue;
|
|
17865
|
+
normalComponent.schematic_sheet_id = inferredSchematicSheetId;
|
|
17866
|
+
}
|
|
17867
|
+
};
|
|
17868
|
+
|
|
17466
17869
|
// lib/components/primitive-components/Group/Group_doInitialPcbCalcPlacementResolution.ts
|
|
17467
17870
|
import { getBoundsOfPcbElements as getBoundsOfPcbElements2 } from "@tscircuit/circuit-json-util";
|
|
17468
17871
|
var SUPPORTED_COMPONENT_FIELDS = /* @__PURE__ */ new Set([
|
|
@@ -23129,7 +23532,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
23129
23532
|
var package_default = {
|
|
23130
23533
|
name: "@tscircuit/core",
|
|
23131
23534
|
type: "module",
|
|
23132
|
-
version: "0.0.
|
|
23535
|
+
version: "0.0.1485",
|
|
23133
23536
|
types: "dist/index.d.ts",
|
|
23134
23537
|
main: "dist/index.js",
|
|
23135
23538
|
module: "dist/index.js",
|
|
@@ -23179,7 +23582,7 @@ var package_default = {
|
|
|
23179
23582
|
"@tscircuit/math-utils": "^0.0.36",
|
|
23180
23583
|
"@tscircuit/miniflex": "^0.0.4",
|
|
23181
23584
|
"@tscircuit/ngspice-spice-engine": "^0.0.19",
|
|
23182
|
-
"@tscircuit/props": "^0.0.
|
|
23585
|
+
"@tscircuit/props": "^0.0.589",
|
|
23183
23586
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
23184
23587
|
"@tscircuit/schematic-trace-solver": "^0.0.104",
|
|
23185
23588
|
"@tscircuit/solver-utils": "^0.0.16",
|
|
@@ -24516,6 +24919,7 @@ var Group = class extends NormalComponent3 {
|
|
|
24516
24919
|
}
|
|
24517
24920
|
doInitialSourceAddConnectivityMapKey() {
|
|
24518
24921
|
Group_doInitialSourceAddConnectivityMapKey(this);
|
|
24922
|
+
Group_doInitialAssignSchematicSheetToConnectedComponents(this);
|
|
24519
24923
|
}
|
|
24520
24924
|
_areChildSubcircuitsRouted() {
|
|
24521
24925
|
const subcircuitChildren = this._findDirectChildSubcircuits();
|
|
@@ -24601,6 +25005,7 @@ var Group = class extends NormalComponent3 {
|
|
|
24601
25005
|
);
|
|
24602
25006
|
if (serverMode === "solve-endpoint") {
|
|
24603
25007
|
if (this.props.autorouter?.inputFormat === "simplified") {
|
|
25008
|
+
const preferredTraceWidth = props.defaultTraceWidth ?? props.nominalTraceWidth;
|
|
24604
25009
|
const { autorouting_result: autorouting_result2 } = await fetchWithDebug(
|
|
24605
25010
|
`${serverUrl}/autorouting/solve`,
|
|
24606
25011
|
{
|
|
@@ -24609,7 +25014,7 @@ var Group = class extends NormalComponent3 {
|
|
|
24609
25014
|
input_simple_route_json: getSimpleRouteJsonFromCircuitJson({
|
|
24610
25015
|
db,
|
|
24611
25016
|
minTraceWidth: Number(props.minTraceWidth ?? 0.15),
|
|
24612
|
-
nominalTraceWidth:
|
|
25017
|
+
nominalTraceWidth: preferredTraceWidth != null ? Number(preferredTraceWidth) : void 0,
|
|
24613
25018
|
subcircuit_id: this.subcircuit_id,
|
|
24614
25019
|
subcircuitComponent: this
|
|
24615
25020
|
}).simpleRouteJson,
|
|
@@ -24713,7 +25118,9 @@ var Group = class extends NormalComponent3 {
|
|
|
24713
25118
|
const isAutoJumperPreset = this._isAutoJumperAutorouter(autorouterConfig);
|
|
24714
25119
|
const isSingleLayerBoard = this._getSubcircuitLayerCount() === 1;
|
|
24715
25120
|
const minTraceWidth = Number(props.minTraceWidth ?? 0.15);
|
|
24716
|
-
const nominalTraceWidth = Number(
|
|
25121
|
+
const nominalTraceWidth = Number(
|
|
25122
|
+
props.defaultTraceWidth ?? props.nominalTraceWidth ?? minTraceWidth
|
|
25123
|
+
);
|
|
24717
25124
|
const { simpleRouteJson: baseSimpleRouteJson } = getSimpleRouteJsonFromCircuitJson({
|
|
24718
25125
|
db,
|
|
24719
25126
|
minTraceWidth,
|
|
@@ -32138,7 +32545,7 @@ import {
|
|
|
32138
32545
|
} from "@tscircuit/props";
|
|
32139
32546
|
import { source_part_not_found_warning as source_part_not_found_warning3 } from "circuit-json";
|
|
32140
32547
|
|
|
32141
|
-
// lib/utils/connectors/
|
|
32548
|
+
// lib/utils/connectors/usb-c-canonical-pin-definitions.ts
|
|
32142
32549
|
var STANDARD_USB_C_PIN_LABELS = [
|
|
32143
32550
|
{ label: "GND1", aliases: [] },
|
|
32144
32551
|
{ label: "VBUS1", aliases: [] },
|
|
@@ -32157,6 +32564,8 @@ var STANDARD_USB_C_PIN_LABELS = [
|
|
|
32157
32564
|
{ label: "SHELL3", aliases: ["MH3", "EH3", "MOUNT3"] },
|
|
32158
32565
|
{ label: "SHELL4", aliases: ["MH4", "EH4", "MOUNT4"] }
|
|
32159
32566
|
];
|
|
32567
|
+
|
|
32568
|
+
// lib/utils/connectors/convertCircuitJsonToUsbCStandardCircuitJson.ts
|
|
32160
32569
|
var PIN_NUMBER_HINT_PATTERN = /^(?:pin)?(\d+)$/i;
|
|
32161
32570
|
var dedupeHintsPreservingOrder = (hints) => Array.from(new Set(hints));
|
|
32162
32571
|
var convertCircuitJsonToUsbCStandardCircuitJson = (partCircuitJson) => {
|
|
@@ -32353,7 +32762,20 @@ var Connector = class extends Chip {
|
|
|
32353
32762
|
if (this.getInheritedProperty("partsEngineDisabled")) return false;
|
|
32354
32763
|
return true;
|
|
32355
32764
|
}
|
|
32356
|
-
|
|
32765
|
+
_addUsbCCanonicalFallbackPorts() {
|
|
32766
|
+
if (this.selectAll("port").length > 0) return;
|
|
32767
|
+
this.addAll(
|
|
32768
|
+
STANDARD_USB_C_PIN_LABELS.map(
|
|
32769
|
+
({ label, aliases }, pinIndex) => new Port({
|
|
32770
|
+
pinNumber: pinIndex + 1,
|
|
32771
|
+
name: label,
|
|
32772
|
+
aliases: [...aliases]
|
|
32773
|
+
})
|
|
32774
|
+
)
|
|
32775
|
+
);
|
|
32776
|
+
this._markDirty("InitializePortsFromChildren");
|
|
32777
|
+
}
|
|
32778
|
+
_handleStandardConnectorCircuitJsonFailure(standard, message) {
|
|
32357
32779
|
const { db } = this.root;
|
|
32358
32780
|
const warning = source_part_not_found_warning3.parse({
|
|
32359
32781
|
type: "source_part_not_found_warning",
|
|
@@ -32364,6 +32786,9 @@ var Connector = class extends Chip {
|
|
|
32364
32786
|
part_name: this.name
|
|
32365
32787
|
});
|
|
32366
32788
|
db.source_part_not_found_warning.insert(warning);
|
|
32789
|
+
if (standard === "usb_c") {
|
|
32790
|
+
this._addUsbCCanonicalFallbackPorts();
|
|
32791
|
+
}
|
|
32367
32792
|
}
|
|
32368
32793
|
_getSupplierPartNumbersToTry(supplierPartNumbers) {
|
|
32369
32794
|
const partNumbers = [];
|
|
@@ -32549,7 +32974,7 @@ var Connector = class extends Chip {
|
|
|
32549
32974
|
if (this._hasStartedFootprintUrlLoad) return;
|
|
32550
32975
|
const partsEngine = this.getInheritedProperty("partsEngine");
|
|
32551
32976
|
if (partsEngine && !partsEngine.fetchPartCircuitJson) {
|
|
32552
|
-
this.
|
|
32977
|
+
this._handleStandardConnectorCircuitJsonFailure(
|
|
32553
32978
|
standard,
|
|
32554
32979
|
"partsEngine.fetchPartCircuitJson is not configured"
|
|
32555
32980
|
);
|
|
@@ -32584,7 +33009,7 @@ var Connector = class extends Chip {
|
|
|
32584
33009
|
sourceComponentForQuery.manufacturer_part_number
|
|
32585
33010
|
);
|
|
32586
33011
|
if (!circuitJson) {
|
|
32587
|
-
this.
|
|
33012
|
+
this._handleStandardConnectorCircuitJsonFailure(
|
|
32588
33013
|
standard,
|
|
32589
33014
|
"part circuit JSON was not found"
|
|
32590
33015
|
);
|
|
@@ -32597,7 +33022,7 @@ var Connector = class extends Chip {
|
|
|
32597
33022
|
supplier_part_numbers: {}
|
|
32598
33023
|
});
|
|
32599
33024
|
}
|
|
32600
|
-
this.
|
|
33025
|
+
this._handleStandardConnectorCircuitJsonFailure(standard, error.message);
|
|
32601
33026
|
}
|
|
32602
33027
|
});
|
|
32603
33028
|
}
|
|
@@ -32982,558 +33407,228 @@ var getMosfetSchematicSymbolName = (props) => {
|
|
|
32982
33407
|
const { gate, drain } = getRequestedOrientation(props);
|
|
32983
33408
|
return `${baseSymbolName}_gate_${gate}_drain_${drain}`;
|
|
32984
33409
|
};
|
|
32985
|
-
|
|
32986
|
-
// lib/components/normal-components/Mosfet.ts
|
|
32987
|
-
var Mosfet = class extends NormalComponent3 {
|
|
32988
|
-
get config() {
|
|
32989
|
-
return {
|
|
32990
|
-
componentName: "Mosfet",
|
|
32991
|
-
schematicSymbolName: this.props.symbolName ?? getMosfetSchematicSymbolName(this.props),
|
|
32992
|
-
zodProps: mosfetProps,
|
|
32993
|
-
shouldRenderAsSchematicBox: false
|
|
32994
|
-
};
|
|
32995
|
-
}
|
|
32996
|
-
doInitialSourceRender() {
|
|
32997
|
-
const { db } = this.root;
|
|
32998
|
-
const { _parsedProps: props } = this;
|
|
32999
|
-
const source_component = db.source_component.insert({
|
|
33000
|
-
ftype: "simple_mosfet",
|
|
33001
|
-
name: this.name,
|
|
33002
|
-
mosfet_mode: props.mosfetMode,
|
|
33003
|
-
channel_type: props.channelType,
|
|
33004
|
-
display_name: props.displayName
|
|
33005
|
-
});
|
|
33006
|
-
this.source_component_id = source_component.source_component_id;
|
|
33007
|
-
}
|
|
33008
|
-
};
|
|
33009
|
-
|
|
33010
|
-
// lib/components/normal-components/InternalCircuitMosfet.ts
|
|
33011
|
-
import { isValidElement as isValidElement3 } from "react";
|
|
33012
|
-
var InternalCircuitMosfet = class extends Mosfet {
|
|
33013
|
-
resolveFootprint() {
|
|
33014
|
-
return void 0;
|
|
33015
|
-
}
|
|
33016
|
-
doInitialPcbComponentRender() {
|
|
33017
|
-
}
|
|
33018
|
-
doInitialReactSubtreesRender() {
|
|
33019
|
-
const symbol = this.props.symbol;
|
|
33020
|
-
if (isValidElement3(symbol) && !this.children.some((child) => child.componentName === "Symbol")) {
|
|
33021
|
-
this.add(symbol);
|
|
33022
|
-
}
|
|
33023
|
-
}
|
|
33024
|
-
};
|
|
33025
|
-
|
|
33026
|
-
// lib/components/normal-components/OpAmp.ts
|
|
33027
|
-
import { opampProps } from "@tscircuit/props";
|
|
33028
|
-
var OpAmp = class extends NormalComponent3 {
|
|
33029
|
-
getSchematicSymbolName() {
|
|
33030
|
-
if (this.props.symbolName) {
|
|
33031
|
-
return this.props.symbolName;
|
|
33032
|
-
}
|
|
33033
|
-
const hasPowerConnections = this.props.connections?.positive_supply || this.props.connections?.negative_supply;
|
|
33034
|
-
if (hasPowerConnections) {
|
|
33035
|
-
return "opamp_with_power";
|
|
33036
|
-
}
|
|
33037
|
-
return "opamp_no_power";
|
|
33038
|
-
}
|
|
33039
|
-
get config() {
|
|
33040
|
-
return {
|
|
33041
|
-
componentName: "OpAmp",
|
|
33042
|
-
schematicSymbolName: this.getSchematicSymbolName(),
|
|
33043
|
-
zodProps: opampProps,
|
|
33044
|
-
sourceFtype: "simple_op_amp"
|
|
33045
|
-
};
|
|
33046
|
-
}
|
|
33047
|
-
initPorts() {
|
|
33048
|
-
const additionalAliases = {
|
|
33049
|
-
pin1: ["non_inverting_input"],
|
|
33050
|
-
pin2: ["inverting_input"]
|
|
33051
|
-
};
|
|
33052
|
-
const hasPowerSymbol = this.getSchematicSymbolName() === "opamp_with_power";
|
|
33053
|
-
if (hasPowerSymbol) {
|
|
33054
|
-
Object.assign(additionalAliases, {
|
|
33055
|
-
pin4: ["output"],
|
|
33056
|
-
pin5: ["positive_supply", "vcc", "vdd"],
|
|
33057
|
-
pin3: ["negative_supply", "vee", "vss", "gnd"]
|
|
33058
|
-
});
|
|
33059
|
-
} else {
|
|
33060
|
-
Object.assign(additionalAliases, {
|
|
33061
|
-
pin3: ["output"],
|
|
33062
|
-
pin4: ["positive_supply", "vcc", "vdd"],
|
|
33063
|
-
pin5: ["negative_supply", "vee", "vss", "gnd"]
|
|
33064
|
-
});
|
|
33065
|
-
}
|
|
33066
|
-
super.initPorts({
|
|
33067
|
-
pinCount: 5,
|
|
33068
|
-
additionalAliases
|
|
33069
|
-
});
|
|
33070
|
-
}
|
|
33071
|
-
doInitialSourceRender() {
|
|
33072
|
-
const { db } = this.root;
|
|
33073
|
-
const { _parsedProps: props } = this;
|
|
33074
|
-
const source_component = db.source_component.insert({
|
|
33075
|
-
ftype: "simple_op_amp",
|
|
33076
|
-
name: this.name,
|
|
33077
|
-
supplier_part_numbers: props.supplierPartNumbers,
|
|
33078
|
-
display_name: props.displayName
|
|
33079
|
-
});
|
|
33080
|
-
this.source_component_id = source_component.source_component_id;
|
|
33081
|
-
}
|
|
33082
|
-
doInitialSimulationRender() {
|
|
33083
|
-
const { db } = this.root;
|
|
33084
|
-
const invertingInputPort = this.portMap.inverting_input;
|
|
33085
|
-
const nonInvertingInputPort = this.portMap.non_inverting_input;
|
|
33086
|
-
const outputPort = this.portMap.output;
|
|
33087
|
-
const positiveSupplyPort = this.portMap.positive_supply;
|
|
33088
|
-
const negativeSupplyPort = this.portMap.negative_supply;
|
|
33089
|
-
if (!invertingInputPort?.source_port_id || !nonInvertingInputPort?.source_port_id || !outputPort?.source_port_id || !positiveSupplyPort?.source_port_id || !negativeSupplyPort?.source_port_id) {
|
|
33090
|
-
return;
|
|
33091
|
-
}
|
|
33092
|
-
db.simulation_op_amp.insert({
|
|
33093
|
-
type: "simulation_op_amp",
|
|
33094
|
-
source_component_id: this.source_component_id,
|
|
33095
|
-
inverting_input_source_port_id: invertingInputPort.source_port_id,
|
|
33096
|
-
non_inverting_input_source_port_id: nonInvertingInputPort.source_port_id,
|
|
33097
|
-
output_source_port_id: outputPort.source_port_id,
|
|
33098
|
-
positive_supply_source_port_id: positiveSupplyPort.source_port_id,
|
|
33099
|
-
negative_supply_source_port_id: negativeSupplyPort.source_port_id
|
|
33100
|
-
});
|
|
33101
|
-
}
|
|
33102
|
-
inverting_input = this.portMap.inverting_input;
|
|
33103
|
-
non_inverting_input = this.portMap.non_inverting_input;
|
|
33104
|
-
output = this.portMap.output;
|
|
33105
|
-
positive_supply = this.portMap.positive_supply;
|
|
33106
|
-
negative_supply = this.portMap.negative_supply;
|
|
33107
|
-
};
|
|
33108
|
-
|
|
33109
|
-
// lib/components/normal-components/TestPoint.ts
|
|
33110
|
-
import { testpointProps } from "@tscircuit/props";
|
|
33111
|
-
var TESTPOINT_DEFAULTS = {
|
|
33112
|
-
HOLE_DIAMETER: 0.5,
|
|
33113
|
-
SMT_CIRCLE_DIAMETER: 1.2,
|
|
33114
|
-
SMT_RECT_SIZE: 2
|
|
33115
|
-
};
|
|
33116
|
-
var TestPoint = class extends NormalComponent3 {
|
|
33117
|
-
get config() {
|
|
33118
|
-
return {
|
|
33119
|
-
componentName: "TestPoint",
|
|
33120
|
-
schematicSymbolName: this.props.symbolName ?? "testpoint",
|
|
33121
|
-
zodProps: testpointProps,
|
|
33122
|
-
sourceFtype: FTYPE.simple_test_point
|
|
33123
|
-
};
|
|
33124
|
-
}
|
|
33125
|
-
_getPropsWithDefaults() {
|
|
33126
|
-
let {
|
|
33127
|
-
padShape,
|
|
33128
|
-
holeDiameter,
|
|
33129
|
-
footprintVariant,
|
|
33130
|
-
padDiameter,
|
|
33131
|
-
width,
|
|
33132
|
-
height
|
|
33133
|
-
} = this._parsedProps;
|
|
33134
|
-
if (!footprintVariant && holeDiameter) {
|
|
33135
|
-
footprintVariant = "through_hole";
|
|
33136
|
-
}
|
|
33137
|
-
footprintVariant ??= "through_hole";
|
|
33138
|
-
padShape ??= "circle";
|
|
33139
|
-
if (footprintVariant === "pad") {
|
|
33140
|
-
if (padShape === "circle") {
|
|
33141
|
-
padDiameter ??= TESTPOINT_DEFAULTS.SMT_CIRCLE_DIAMETER;
|
|
33142
|
-
} else if (padShape === "rect") {
|
|
33143
|
-
width ??= TESTPOINT_DEFAULTS.SMT_RECT_SIZE;
|
|
33144
|
-
height ??= width;
|
|
33145
|
-
}
|
|
33146
|
-
} else if (footprintVariant === "through_hole") {
|
|
33147
|
-
holeDiameter ??= TESTPOINT_DEFAULTS.HOLE_DIAMETER;
|
|
33148
|
-
}
|
|
33149
|
-
return {
|
|
33150
|
-
padShape,
|
|
33151
|
-
holeDiameter,
|
|
33152
|
-
footprintVariant,
|
|
33153
|
-
padDiameter,
|
|
33154
|
-
width,
|
|
33155
|
-
height
|
|
33156
|
-
};
|
|
33157
|
-
}
|
|
33158
|
-
_getImpliedFootprintString() {
|
|
33159
|
-
const {
|
|
33160
|
-
padShape,
|
|
33161
|
-
holeDiameter,
|
|
33162
|
-
footprintVariant,
|
|
33163
|
-
padDiameter,
|
|
33164
|
-
width,
|
|
33165
|
-
height
|
|
33166
|
-
} = this._getPropsWithDefaults();
|
|
33167
|
-
if (footprintVariant === "through_hole") {
|
|
33168
|
-
return `platedhole_d${holeDiameter}`;
|
|
33169
|
-
}
|
|
33170
|
-
if (footprintVariant === "pad") {
|
|
33171
|
-
if (padShape === "circle") {
|
|
33172
|
-
return `smtpad_circle_d${padDiameter}`;
|
|
33173
|
-
}
|
|
33174
|
-
if (padShape === "rect") {
|
|
33175
|
-
return `smtpad_rect_w${width}_h${height}`;
|
|
33176
|
-
}
|
|
33177
|
-
}
|
|
33178
|
-
throw new Error(
|
|
33179
|
-
`Footprint variant "${footprintVariant}" with pad shape "${padShape}" not implemented`
|
|
33180
|
-
);
|
|
33410
|
+
|
|
33411
|
+
// lib/components/normal-components/Mosfet.ts
|
|
33412
|
+
var Mosfet = class extends NormalComponent3 {
|
|
33413
|
+
get config() {
|
|
33414
|
+
return {
|
|
33415
|
+
componentName: "Mosfet",
|
|
33416
|
+
schematicSymbolName: this.props.symbolName ?? getMosfetSchematicSymbolName(this.props),
|
|
33417
|
+
zodProps: mosfetProps,
|
|
33418
|
+
shouldRenderAsSchematicBox: false
|
|
33419
|
+
};
|
|
33181
33420
|
}
|
|
33182
33421
|
doInitialSourceRender() {
|
|
33183
33422
|
const { db } = this.root;
|
|
33184
33423
|
const { _parsedProps: props } = this;
|
|
33185
|
-
const {
|
|
33186
|
-
padShape,
|
|
33187
|
-
holeDiameter,
|
|
33188
|
-
footprintVariant,
|
|
33189
|
-
padDiameter,
|
|
33190
|
-
width,
|
|
33191
|
-
height
|
|
33192
|
-
} = this._getPropsWithDefaults();
|
|
33193
33424
|
const source_component = db.source_component.insert({
|
|
33194
|
-
ftype:
|
|
33425
|
+
ftype: "simple_mosfet",
|
|
33195
33426
|
name: this.name,
|
|
33196
|
-
|
|
33197
|
-
|
|
33198
|
-
pad_shape: padShape,
|
|
33199
|
-
pad_diameter: padDiameter,
|
|
33200
|
-
hole_diameter: holeDiameter,
|
|
33201
|
-
width,
|
|
33202
|
-
height,
|
|
33203
|
-
are_pins_interchangeable: true,
|
|
33427
|
+
mosfet_mode: props.mosfetMode,
|
|
33428
|
+
channel_type: props.channelType,
|
|
33204
33429
|
display_name: props.displayName
|
|
33205
33430
|
});
|
|
33206
33431
|
this.source_component_id = source_component.source_component_id;
|
|
33207
33432
|
}
|
|
33208
33433
|
};
|
|
33209
33434
|
|
|
33210
|
-
// lib/components/
|
|
33211
|
-
import {
|
|
33212
|
-
|
|
33213
|
-
|
|
33214
|
-
|
|
33215
|
-
anchor,
|
|
33216
|
-
x,
|
|
33217
|
-
y,
|
|
33218
|
-
width,
|
|
33219
|
-
height,
|
|
33220
|
-
isInside
|
|
33221
|
-
}) {
|
|
33222
|
-
switch (anchor) {
|
|
33223
|
-
case "top_left":
|
|
33224
|
-
return {
|
|
33225
|
-
x,
|
|
33226
|
-
y: y + height,
|
|
33227
|
-
textAnchor: isInside ? "top_left" : "bottom_left"
|
|
33228
|
-
};
|
|
33229
|
-
case "top_center":
|
|
33230
|
-
return {
|
|
33231
|
-
x: x + width / 2,
|
|
33232
|
-
y: y + height,
|
|
33233
|
-
textAnchor: isInside ? "top_center" : "bottom_center"
|
|
33234
|
-
};
|
|
33235
|
-
case "top_right":
|
|
33236
|
-
return {
|
|
33237
|
-
x: x + width,
|
|
33238
|
-
y: y + height,
|
|
33239
|
-
textAnchor: isInside ? "top_right" : "bottom_right"
|
|
33240
|
-
};
|
|
33241
|
-
case "center_left":
|
|
33242
|
-
return {
|
|
33243
|
-
x,
|
|
33244
|
-
y: y + height / 2,
|
|
33245
|
-
textAnchor: isInside ? "center_left" : "center_right"
|
|
33246
|
-
};
|
|
33247
|
-
case "center":
|
|
33248
|
-
return {
|
|
33249
|
-
x: x + width / 2,
|
|
33250
|
-
y: y + height / 2,
|
|
33251
|
-
textAnchor: "center"
|
|
33252
|
-
};
|
|
33253
|
-
case "center_right":
|
|
33254
|
-
return {
|
|
33255
|
-
x: x + width,
|
|
33256
|
-
y: y + height / 2,
|
|
33257
|
-
textAnchor: isInside ? "center_right" : "center_left"
|
|
33258
|
-
};
|
|
33259
|
-
case "bottom_left":
|
|
33260
|
-
return {
|
|
33261
|
-
x,
|
|
33262
|
-
y,
|
|
33263
|
-
textAnchor: isInside ? "bottom_left" : "top_left"
|
|
33264
|
-
};
|
|
33265
|
-
case "bottom_center":
|
|
33266
|
-
return {
|
|
33267
|
-
x: x + width / 2,
|
|
33268
|
-
y,
|
|
33269
|
-
textAnchor: isInside ? "bottom_center" : "top_center"
|
|
33270
|
-
};
|
|
33271
|
-
case "bottom_right":
|
|
33272
|
-
return {
|
|
33273
|
-
x: x + width,
|
|
33274
|
-
y,
|
|
33275
|
-
textAnchor: isInside ? "bottom_right" : "top_right"
|
|
33276
|
-
};
|
|
33277
|
-
default:
|
|
33278
|
-
return {
|
|
33279
|
-
x: x + width / 2,
|
|
33280
|
-
y: y + height,
|
|
33281
|
-
textAnchor: "center"
|
|
33282
|
-
};
|
|
33435
|
+
// lib/components/normal-components/InternalCircuitMosfet.ts
|
|
33436
|
+
import { isValidElement as isValidElement3 } from "react";
|
|
33437
|
+
var InternalCircuitMosfet = class extends Mosfet {
|
|
33438
|
+
resolveFootprint() {
|
|
33439
|
+
return void 0;
|
|
33283
33440
|
}
|
|
33284
|
-
|
|
33441
|
+
doInitialPcbComponentRender() {
|
|
33442
|
+
}
|
|
33443
|
+
doInitialReactSubtreesRender() {
|
|
33444
|
+
const symbol = this.props.symbol;
|
|
33445
|
+
if (isValidElement3(symbol) && !this.children.some((child) => child.componentName === "Symbol")) {
|
|
33446
|
+
this.add(symbol);
|
|
33447
|
+
}
|
|
33448
|
+
}
|
|
33449
|
+
};
|
|
33285
33450
|
|
|
33286
|
-
// lib/components/
|
|
33287
|
-
|
|
33288
|
-
|
|
33289
|
-
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
throw new Error(
|
|
33293
|
-
`Invalid schematicbox pinLabels key "${pinKey}". Expected pin<number>.`
|
|
33294
|
-
);
|
|
33451
|
+
// lib/components/normal-components/OpAmp.ts
|
|
33452
|
+
import { opampProps } from "@tscircuit/props";
|
|
33453
|
+
var OpAmp = class extends NormalComponent3 {
|
|
33454
|
+
getSchematicSymbolName() {
|
|
33455
|
+
if (this.props.symbolName) {
|
|
33456
|
+
return this.props.symbolName;
|
|
33295
33457
|
}
|
|
33296
|
-
const
|
|
33458
|
+
const hasPowerConnections = this.props.connections?.positive_supply || this.props.connections?.negative_supply;
|
|
33459
|
+
if (hasPowerConnections) {
|
|
33460
|
+
return "opamp_with_power";
|
|
33461
|
+
}
|
|
33462
|
+
return "opamp_no_power";
|
|
33463
|
+
}
|
|
33464
|
+
get config() {
|
|
33297
33465
|
return {
|
|
33298
|
-
|
|
33299
|
-
|
|
33300
|
-
|
|
33466
|
+
componentName: "OpAmp",
|
|
33467
|
+
schematicSymbolName: this.getSchematicSymbolName(),
|
|
33468
|
+
zodProps: opampProps,
|
|
33469
|
+
sourceFtype: "simple_op_amp"
|
|
33301
33470
|
};
|
|
33302
|
-
});
|
|
33303
|
-
};
|
|
33304
|
-
var SchematicBox_doInitialSchematicComponentRender = (schematicBox) => {
|
|
33305
|
-
if (schematicBox.root?.schematicDisabled) return;
|
|
33306
|
-
const { db } = schematicBox.root;
|
|
33307
|
-
const props = schematicBox._parsedProps;
|
|
33308
|
-
if (!props.chipRef) return;
|
|
33309
|
-
const referencedChip = schematicBox.getSubcircuit().selectOne(props.chipRef);
|
|
33310
|
-
if (!referencedChip?.source_component_id) {
|
|
33311
|
-
throw new Error(
|
|
33312
|
-
`Could not resolve chipRef "${props.chipRef}" for ${schematicBox.getString()}`
|
|
33313
|
-
);
|
|
33314
33471
|
}
|
|
33315
|
-
|
|
33316
|
-
|
|
33317
|
-
|
|
33318
|
-
|
|
33319
|
-
|
|
33320
|
-
|
|
33321
|
-
|
|
33322
|
-
|
|
33323
|
-
|
|
33324
|
-
|
|
33325
|
-
|
|
33326
|
-
|
|
33327
|
-
|
|
33328
|
-
|
|
33329
|
-
|
|
33330
|
-
|
|
33331
|
-
|
|
33332
|
-
|
|
33333
|
-
const center = schematicBox._getGlobalSchematicPositionBeforeLayout();
|
|
33334
|
-
const size = dimensions.getSize();
|
|
33335
|
-
const schematicSheetId = schematicBox._resolveSchematicSheetId();
|
|
33336
|
-
const portLabels = Object.fromEntries(
|
|
33337
|
-
schematicBoxPinLabels.map(({ pinNumber, displayPinLabel }) => [
|
|
33338
|
-
String(pinNumber),
|
|
33339
|
-
displayPinLabel
|
|
33340
|
-
])
|
|
33341
|
-
);
|
|
33342
|
-
const schematicComponent = db.schematic_component.insert({
|
|
33343
|
-
center,
|
|
33344
|
-
size,
|
|
33345
|
-
source_component_id: referencedChip.source_component_id,
|
|
33346
|
-
is_box_with_pins: true,
|
|
33347
|
-
port_arrangement: underscorifyPortArrangement(props.schPinArrangement),
|
|
33348
|
-
port_labels: portLabels,
|
|
33349
|
-
pin_spacing: 0.2,
|
|
33350
|
-
schematic_sheet_id: schematicSheetId
|
|
33351
|
-
});
|
|
33352
|
-
schematicBox.schematic_component_id = schematicComponent.schematic_component_id;
|
|
33353
|
-
for (const {
|
|
33354
|
-
pinNumber,
|
|
33355
|
-
displayPinLabel,
|
|
33356
|
-
pinAliases
|
|
33357
|
-
} of schematicBoxPinLabels) {
|
|
33358
|
-
const referencedSourcePort = sourcePorts.find(
|
|
33359
|
-
(sourcePort) => pinAliases.some(
|
|
33360
|
-
(pinAlias) => sourcePort.name === pinAlias || sourcePort.port_hints?.includes(pinAlias)
|
|
33361
|
-
)
|
|
33362
|
-
);
|
|
33363
|
-
if (!referencedSourcePort) {
|
|
33364
|
-
throw new Error(
|
|
33365
|
-
`Could not find pin "${displayPinLabel}" on chipRef "${props.chipRef}"`
|
|
33366
|
-
);
|
|
33472
|
+
initPorts() {
|
|
33473
|
+
const additionalAliases = {
|
|
33474
|
+
pin1: ["non_inverting_input"],
|
|
33475
|
+
pin2: ["inverting_input"]
|
|
33476
|
+
};
|
|
33477
|
+
const hasPowerSymbol = this.getSchematicSymbolName() === "opamp_with_power";
|
|
33478
|
+
if (hasPowerSymbol) {
|
|
33479
|
+
Object.assign(additionalAliases, {
|
|
33480
|
+
pin4: ["output"],
|
|
33481
|
+
pin5: ["positive_supply", "vcc", "vdd"],
|
|
33482
|
+
pin3: ["negative_supply", "vee", "vss", "gnd"]
|
|
33483
|
+
});
|
|
33484
|
+
} else {
|
|
33485
|
+
Object.assign(additionalAliases, {
|
|
33486
|
+
pin3: ["output"],
|
|
33487
|
+
pin4: ["positive_supply", "vcc", "vdd"],
|
|
33488
|
+
pin5: ["negative_supply", "vee", "vss", "gnd"]
|
|
33489
|
+
});
|
|
33367
33490
|
}
|
|
33368
|
-
|
|
33369
|
-
|
|
33370
|
-
|
|
33371
|
-
|
|
33372
|
-
|
|
33491
|
+
super.initPorts({
|
|
33492
|
+
pinCount: 5,
|
|
33493
|
+
additionalAliases
|
|
33494
|
+
});
|
|
33495
|
+
}
|
|
33496
|
+
doInitialSourceRender() {
|
|
33497
|
+
const { db } = this.root;
|
|
33498
|
+
const { _parsedProps: props } = this;
|
|
33499
|
+
const source_component = db.source_component.insert({
|
|
33500
|
+
ftype: "simple_op_amp",
|
|
33501
|
+
name: this.name,
|
|
33502
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
33503
|
+
display_name: props.displayName
|
|
33504
|
+
});
|
|
33505
|
+
this.source_component_id = source_component.source_component_id;
|
|
33506
|
+
}
|
|
33507
|
+
doInitialSimulationRender() {
|
|
33508
|
+
const { db } = this.root;
|
|
33509
|
+
const invertingInputPort = this.portMap.inverting_input;
|
|
33510
|
+
const nonInvertingInputPort = this.portMap.non_inverting_input;
|
|
33511
|
+
const outputPort = this.portMap.output;
|
|
33512
|
+
const positiveSupplyPort = this.portMap.positive_supply;
|
|
33513
|
+
const negativeSupplyPort = this.portMap.negative_supply;
|
|
33514
|
+
if (!invertingInputPort?.source_port_id || !nonInvertingInputPort?.source_port_id || !outputPort?.source_port_id || !positiveSupplyPort?.source_port_id || !negativeSupplyPort?.source_port_id) {
|
|
33515
|
+
return;
|
|
33373
33516
|
}
|
|
33374
|
-
|
|
33375
|
-
|
|
33376
|
-
|
|
33377
|
-
|
|
33378
|
-
|
|
33379
|
-
|
|
33380
|
-
|
|
33381
|
-
|
|
33382
|
-
center: {
|
|
33383
|
-
x: center.x + portPosition.x,
|
|
33384
|
-
y: center.y + portPosition.y
|
|
33385
|
-
},
|
|
33386
|
-
source_port_id: referencedSourcePort.source_port_id,
|
|
33387
|
-
facing_direction: facingDirection,
|
|
33388
|
-
distance_from_component_edge: 0.4,
|
|
33389
|
-
side_of_component: portPosition.side,
|
|
33390
|
-
pin_number: pinNumber,
|
|
33391
|
-
true_ccw_index: portPosition.trueIndex,
|
|
33392
|
-
display_pin_label: displayPinLabel,
|
|
33393
|
-
is_connected: false,
|
|
33394
|
-
schematic_sheet_id: schematicSheetId
|
|
33517
|
+
db.simulation_op_amp.insert({
|
|
33518
|
+
type: "simulation_op_amp",
|
|
33519
|
+
source_component_id: this.source_component_id,
|
|
33520
|
+
inverting_input_source_port_id: invertingInputPort.source_port_id,
|
|
33521
|
+
non_inverting_input_source_port_id: nonInvertingInputPort.source_port_id,
|
|
33522
|
+
output_source_port_id: outputPort.source_port_id,
|
|
33523
|
+
positive_supply_source_port_id: positiveSupplyPort.source_port_id,
|
|
33524
|
+
negative_supply_source_port_id: negativeSupplyPort.source_port_id
|
|
33395
33525
|
});
|
|
33396
33526
|
}
|
|
33397
|
-
|
|
33398
|
-
|
|
33399
|
-
|
|
33400
|
-
|
|
33401
|
-
|
|
33402
|
-
rotation: 0,
|
|
33403
|
-
position: {
|
|
33404
|
-
x: center.x - size.width / 2,
|
|
33405
|
-
y: center.y + size.height / 2 + 0.13
|
|
33406
|
-
},
|
|
33407
|
-
color: "#006464",
|
|
33408
|
-
font_size: 0.18,
|
|
33409
|
-
schematic_sheet_id: schematicSheetId
|
|
33410
|
-
});
|
|
33527
|
+
inverting_input = this.portMap.inverting_input;
|
|
33528
|
+
non_inverting_input = this.portMap.non_inverting_input;
|
|
33529
|
+
output = this.portMap.output;
|
|
33530
|
+
positive_supply = this.portMap.positive_supply;
|
|
33531
|
+
negative_supply = this.portMap.negative_supply;
|
|
33411
33532
|
};
|
|
33412
33533
|
|
|
33413
|
-
// lib/components/
|
|
33414
|
-
|
|
33415
|
-
|
|
33534
|
+
// lib/components/normal-components/TestPoint.ts
|
|
33535
|
+
import { testpointProps } from "@tscircuit/props";
|
|
33536
|
+
var TESTPOINT_DEFAULTS = {
|
|
33537
|
+
HOLE_DIAMETER: 0.5,
|
|
33538
|
+
SMT_CIRCLE_DIAMETER: 1.2,
|
|
33539
|
+
SMT_RECT_SIZE: 2
|
|
33540
|
+
};
|
|
33541
|
+
var TestPoint = class extends NormalComponent3 {
|
|
33416
33542
|
get config() {
|
|
33417
33543
|
return {
|
|
33418
|
-
componentName: "
|
|
33419
|
-
|
|
33420
|
-
|
|
33544
|
+
componentName: "TestPoint",
|
|
33545
|
+
schematicSymbolName: this.props.symbolName ?? "testpoint",
|
|
33546
|
+
zodProps: testpointProps,
|
|
33547
|
+
sourceFtype: FTYPE.simple_test_point
|
|
33421
33548
|
};
|
|
33422
33549
|
}
|
|
33423
|
-
|
|
33424
|
-
|
|
33550
|
+
_getPropsWithDefaults() {
|
|
33551
|
+
let {
|
|
33552
|
+
padShape,
|
|
33553
|
+
holeDiameter,
|
|
33554
|
+
footprintVariant,
|
|
33555
|
+
padDiameter,
|
|
33556
|
+
width,
|
|
33557
|
+
height
|
|
33558
|
+
} = this._parsedProps;
|
|
33559
|
+
if (!footprintVariant && holeDiameter) {
|
|
33560
|
+
footprintVariant = "through_hole";
|
|
33561
|
+
}
|
|
33562
|
+
footprintVariant ??= "through_hole";
|
|
33563
|
+
padShape ??= "circle";
|
|
33564
|
+
if (footprintVariant === "pad") {
|
|
33565
|
+
if (padShape === "circle") {
|
|
33566
|
+
padDiameter ??= TESTPOINT_DEFAULTS.SMT_CIRCLE_DIAMETER;
|
|
33567
|
+
} else if (padShape === "rect") {
|
|
33568
|
+
width ??= TESTPOINT_DEFAULTS.SMT_RECT_SIZE;
|
|
33569
|
+
height ??= width;
|
|
33570
|
+
}
|
|
33571
|
+
} else if (footprintVariant === "through_hole") {
|
|
33572
|
+
holeDiameter ??= TESTPOINT_DEFAULTS.HOLE_DIAMETER;
|
|
33573
|
+
}
|
|
33574
|
+
return {
|
|
33575
|
+
padShape,
|
|
33576
|
+
holeDiameter,
|
|
33577
|
+
footprintVariant,
|
|
33578
|
+
padDiameter,
|
|
33579
|
+
width,
|
|
33580
|
+
height
|
|
33581
|
+
};
|
|
33425
33582
|
}
|
|
33426
|
-
|
|
33427
|
-
|
|
33428
|
-
|
|
33583
|
+
_getImpliedFootprintString() {
|
|
33584
|
+
const {
|
|
33585
|
+
padShape,
|
|
33586
|
+
holeDiameter,
|
|
33587
|
+
footprintVariant,
|
|
33588
|
+
padDiameter,
|
|
33589
|
+
width,
|
|
33590
|
+
height
|
|
33591
|
+
} = this._getPropsWithDefaults();
|
|
33592
|
+
if (footprintVariant === "through_hole") {
|
|
33593
|
+
return `platedhole_d${holeDiameter}`;
|
|
33594
|
+
}
|
|
33595
|
+
if (footprintVariant === "pad") {
|
|
33596
|
+
if (padShape === "circle") {
|
|
33597
|
+
return `smtpad_circle_d${padDiameter}`;
|
|
33598
|
+
}
|
|
33599
|
+
if (padShape === "rect") {
|
|
33600
|
+
return `smtpad_rect_w${width}_h${height}`;
|
|
33601
|
+
}
|
|
33602
|
+
}
|
|
33603
|
+
throw new Error(
|
|
33604
|
+
`Footprint variant "${footprintVariant}" with pad shape "${padShape}" not implemented`
|
|
33605
|
+
);
|
|
33606
|
+
}
|
|
33607
|
+
doInitialSourceRender() {
|
|
33429
33608
|
const { db } = this.root;
|
|
33430
33609
|
const { _parsedProps: props } = this;
|
|
33431
|
-
|
|
33432
|
-
|
|
33433
|
-
|
|
33434
|
-
|
|
33435
|
-
|
|
33436
|
-
const paddingLeft = typeof props.paddingLeft === "number" ? props.paddingLeft : generalPadding;
|
|
33437
|
-
const paddingRight = typeof props.paddingRight === "number" ? props.paddingRight : generalPadding;
|
|
33438
|
-
const hasOverlay = props.overlay && props.overlay.length > 0;
|
|
33439
|
-
const hasFixedSize = typeof props.width === "number" && typeof props.height === "number";
|
|
33440
|
-
let width;
|
|
33441
|
-
let height;
|
|
33442
|
-
let x;
|
|
33443
|
-
let y;
|
|
33444
|
-
let centerX;
|
|
33445
|
-
let centerY;
|
|
33446
|
-
if (hasOverlay) {
|
|
33447
|
-
const portsWithSelectors = props.overlay.map((selector) => ({
|
|
33448
|
-
selector,
|
|
33449
|
-
port: this.getSubcircuit().selectOne(selector, {
|
|
33450
|
-
type: "port"
|
|
33451
|
-
})
|
|
33452
|
-
})).filter(({ port }) => port != null);
|
|
33453
|
-
const portsWithPosition = portsWithSelectors.map(({ port }) => ({
|
|
33454
|
-
position: port._getGlobalSchematicPositionAfterLayout()
|
|
33455
|
-
}));
|
|
33456
|
-
if (portsWithPosition.length === 0) return;
|
|
33457
|
-
const xs = portsWithPosition.map((p) => p.position.x);
|
|
33458
|
-
const ys = portsWithPosition.map((p) => p.position.y);
|
|
33459
|
-
const minX = Math.min(...xs);
|
|
33460
|
-
const maxX = Math.max(...xs);
|
|
33461
|
-
const minY = Math.min(...ys);
|
|
33462
|
-
const maxY = Math.max(...ys);
|
|
33463
|
-
const rawWidth = maxX - minX;
|
|
33464
|
-
const rawHeight = maxY - minY;
|
|
33465
|
-
const defaultHorizontalPadding = rawWidth === 0 ? basePadding : 0;
|
|
33466
|
-
const defaultVerticalPadding = rawHeight === 0 ? basePadding : 0;
|
|
33467
|
-
const finalPaddingLeft = paddingLeft + defaultHorizontalPadding / 2;
|
|
33468
|
-
const finalPaddingRight = paddingRight + defaultHorizontalPadding / 2;
|
|
33469
|
-
const finalPaddingTop = paddingTop + defaultVerticalPadding / 2;
|
|
33470
|
-
const finalPaddingBottom = paddingBottom + defaultVerticalPadding / 2;
|
|
33471
|
-
const left = minX - finalPaddingLeft;
|
|
33472
|
-
const right = maxX + finalPaddingRight;
|
|
33473
|
-
const top = minY - finalPaddingBottom;
|
|
33474
|
-
const bottom = maxY + finalPaddingTop;
|
|
33475
|
-
width = right - left;
|
|
33476
|
-
height = bottom - top;
|
|
33477
|
-
x = left + (props.schX ?? 0);
|
|
33478
|
-
y = top + (props.schY ?? 0);
|
|
33479
|
-
centerX = x + width / 2;
|
|
33480
|
-
centerY = y + height / 2;
|
|
33481
|
-
} else if (hasFixedSize) {
|
|
33482
|
-
width = props.width;
|
|
33483
|
-
height = props.height;
|
|
33484
|
-
const center = this._getGlobalSchematicPositionBeforeLayout();
|
|
33485
|
-
centerX = center.x;
|
|
33486
|
-
centerY = center.y;
|
|
33487
|
-
x = centerX - width / 2;
|
|
33488
|
-
y = centerY - height / 2;
|
|
33489
|
-
} else {
|
|
33490
|
-
return;
|
|
33491
|
-
}
|
|
33492
|
-
db.schematic_box.insert({
|
|
33493
|
-
height,
|
|
33610
|
+
const {
|
|
33611
|
+
padShape,
|
|
33612
|
+
holeDiameter,
|
|
33613
|
+
footprintVariant,
|
|
33614
|
+
padDiameter,
|
|
33494
33615
|
width,
|
|
33495
|
-
|
|
33496
|
-
|
|
33497
|
-
|
|
33498
|
-
|
|
33616
|
+
height
|
|
33617
|
+
} = this._getPropsWithDefaults();
|
|
33618
|
+
const source_component = db.source_component.insert({
|
|
33619
|
+
ftype: FTYPE.simple_test_point,
|
|
33620
|
+
name: this.name,
|
|
33621
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
33622
|
+
footprint_variant: footprintVariant,
|
|
33623
|
+
pad_shape: padShape,
|
|
33624
|
+
pad_diameter: padDiameter,
|
|
33625
|
+
hole_diameter: holeDiameter,
|
|
33626
|
+
width,
|
|
33627
|
+
height,
|
|
33628
|
+
are_pins_interchangeable: true,
|
|
33629
|
+
display_name: props.displayName
|
|
33499
33630
|
});
|
|
33500
|
-
|
|
33501
|
-
const isInside = props.titleInside;
|
|
33502
|
-
const TITLE_PADDING = 0.1;
|
|
33503
|
-
const anchor = props.titleAlignment;
|
|
33504
|
-
const anchorPos = getTitleAnchorAndPosition({
|
|
33505
|
-
anchor,
|
|
33506
|
-
x,
|
|
33507
|
-
y,
|
|
33508
|
-
width,
|
|
33509
|
-
height,
|
|
33510
|
-
isInside
|
|
33511
|
-
});
|
|
33512
|
-
let titleOffsetY;
|
|
33513
|
-
let titleOffsetX;
|
|
33514
|
-
const textAnchor = anchorPos.textAnchor;
|
|
33515
|
-
if (isInside) {
|
|
33516
|
-
titleOffsetY = anchor.includes("top") ? -TITLE_PADDING : anchor.includes("bottom") ? TITLE_PADDING : 0;
|
|
33517
|
-
titleOffsetX = anchor.includes("left") ? TITLE_PADDING : anchor.includes("right") ? -TITLE_PADDING : 0;
|
|
33518
|
-
} else {
|
|
33519
|
-
titleOffsetY = anchor.includes("top") ? TITLE_PADDING : anchor.includes("bottom") ? -TITLE_PADDING : 0;
|
|
33520
|
-
titleOffsetX = anchor.includes("center_left") ? -TITLE_PADDING : anchor.includes("center_right") ? TITLE_PADDING : 0;
|
|
33521
|
-
}
|
|
33522
|
-
const titleX = anchorPos.x + titleOffsetX;
|
|
33523
|
-
const titleY = anchorPos.y + titleOffsetY;
|
|
33524
|
-
db.schematic_text.insert({
|
|
33525
|
-
anchor: textAnchor,
|
|
33526
|
-
text: props.title,
|
|
33527
|
-
font_size: props.titleFontSize ?? 0.18,
|
|
33528
|
-
color: props.titleColor ?? "#000000",
|
|
33529
|
-
position: {
|
|
33530
|
-
x: titleX,
|
|
33531
|
-
y: titleY
|
|
33532
|
-
},
|
|
33533
|
-
rotation: 0,
|
|
33534
|
-
schematic_sheet_id: this._resolveSchematicSheetId()
|
|
33535
|
-
});
|
|
33536
|
-
}
|
|
33631
|
+
this.source_component_id = source_component.source_component_id;
|
|
33537
33632
|
}
|
|
33538
33633
|
};
|
|
33539
33634
|
|
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.1486",
|
|
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
|
"@tscircuit/math-utils": "^0.0.36",
|
|
52
52
|
"@tscircuit/miniflex": "^0.0.4",
|
|
53
53
|
"@tscircuit/ngspice-spice-engine": "^0.0.19",
|
|
54
|
-
"@tscircuit/props": "^0.0.
|
|
54
|
+
"@tscircuit/props": "^0.0.589",
|
|
55
55
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
56
56
|
"@tscircuit/schematic-trace-solver": "^0.0.104",
|
|
57
57
|
"@tscircuit/solver-utils": "^0.0.16",
|