@tscircuit/core 0.0.1289 → 0.0.1291
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 +5 -0
- package/dist/index.js +67 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2167,6 +2167,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
|
|
|
2167
2167
|
ignoreSymbolPorts?: boolean;
|
|
2168
2168
|
}): void;
|
|
2169
2169
|
_getImpliedFootprintString(): string | null;
|
|
2170
|
+
resolveFootprint(): any;
|
|
2170
2171
|
_addChildrenFromStringFootprint(): void;
|
|
2171
2172
|
get portMap(): PortMap<PortNames>;
|
|
2172
2173
|
getInstanceForReactElement(element: ReactElement): NormalComponent | null;
|
|
@@ -43470,6 +43471,10 @@ declare class Interconnect extends NormalComponent<typeof interconnectProps> {
|
|
|
43470
43471
|
|
|
43471
43472
|
declare class SolderJumper<PinLabels extends string = never> extends NormalComponent<typeof solderjumperProps, PinLabels> {
|
|
43472
43473
|
schematicDimensions: SchematicBoxDimensions | null;
|
|
43474
|
+
private _getPinCountFromFootprintString;
|
|
43475
|
+
private _getPinNumberFromBridgedPinsProp;
|
|
43476
|
+
private _getBridgedPinNumbersForFootprint;
|
|
43477
|
+
resolveFootprint(): any;
|
|
43473
43478
|
_getPinNumberFromBridgedPinName(pinName: string): number | null;
|
|
43474
43479
|
get defaultInternallyConnectedPinNames(): string[][];
|
|
43475
43480
|
get config(): {
|
package/dist/index.js
CHANGED
|
@@ -10853,8 +10853,7 @@ var extractCadModelFromCircuitJson = (circuitJson) => {
|
|
|
10853
10853
|
|
|
10854
10854
|
// lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
|
|
10855
10855
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
10856
|
-
|
|
10857
|
-
footprint ??= component._getImpliedFootprintString?.();
|
|
10856
|
+
const footprint = component.resolveFootprint();
|
|
10858
10857
|
if (!footprint) return;
|
|
10859
10858
|
const { pcbRotation, pinLabels, pcbPinLabels } = component.props;
|
|
10860
10859
|
const fileExtension = getFileExtension(String(footprint));
|
|
@@ -11817,10 +11816,13 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
11817
11816
|
_getImpliedFootprintString() {
|
|
11818
11817
|
return null;
|
|
11819
11818
|
}
|
|
11819
|
+
// Override to choose the effective footprint without rewriting user props.
|
|
11820
|
+
resolveFootprint() {
|
|
11821
|
+
return this._parsedProps.footprint ?? this.props.footprint ?? this._getImpliedFootprintString?.();
|
|
11822
|
+
}
|
|
11820
11823
|
_addChildrenFromStringFootprint() {
|
|
11821
11824
|
const { pcbRotation, pinLabels, pcbPinLabels } = this.props;
|
|
11822
|
-
|
|
11823
|
-
footprint ??= this._getImpliedFootprintString?.();
|
|
11825
|
+
const footprint = this.resolveFootprint();
|
|
11824
11826
|
if (!footprint) return;
|
|
11825
11827
|
if (typeof footprint === "string") {
|
|
11826
11828
|
if (isHttpUrl(footprint)) return;
|
|
@@ -12115,7 +12117,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12115
12117
|
obstructs_within_bounds: props.obstructsWithinBounds ?? true,
|
|
12116
12118
|
metadata: props.kicadFootprintMetadata ? { kicad_footprint: props.kicadFootprintMetadata } : void 0
|
|
12117
12119
|
});
|
|
12118
|
-
const footprint =
|
|
12120
|
+
const footprint = this.resolveFootprint();
|
|
12119
12121
|
const hasFootprintChild = this.children.some(
|
|
12120
12122
|
(c) => c.componentName === "Footprint"
|
|
12121
12123
|
);
|
|
@@ -12654,8 +12656,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12654
12656
|
return dimensions;
|
|
12655
12657
|
}
|
|
12656
12658
|
getFootprinterString() {
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
+
const footprint = this.resolveFootprint();
|
|
12660
|
+
if (typeof footprint === "string") {
|
|
12661
|
+
return footprint;
|
|
12659
12662
|
}
|
|
12660
12663
|
return null;
|
|
12661
12664
|
}
|
|
@@ -12666,11 +12669,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12666
12669
|
const { boardThickness = 0 } = this._getBoard() ?? {};
|
|
12667
12670
|
const cadModelProp2 = this._parsedProps.cadModel;
|
|
12668
12671
|
const cadModel = cadModelProp2 === void 0 ? this._asyncFootprintCadModel : cadModelProp2;
|
|
12669
|
-
const
|
|
12670
|
-
let footprintString;
|
|
12671
|
-
if (typeof footprint === "string") {
|
|
12672
|
-
footprintString = footprint;
|
|
12673
|
-
}
|
|
12672
|
+
const footprintString = this.getFootprinterString() ?? void 0;
|
|
12674
12673
|
let footprintIsFootprinterString = false;
|
|
12675
12674
|
if (footprintString) {
|
|
12676
12675
|
footprintIsFootprinterString = !parseLibraryFootprintRef(footprintString) && !isHttpUrl(footprintString) && !isStaticAssetPath(footprintString);
|
|
@@ -12837,10 +12836,8 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
12837
12836
|
const source_component = db.source_component.get(this.source_component_id);
|
|
12838
12837
|
if (!source_component) return;
|
|
12839
12838
|
if (source_component.supplier_part_numbers) return;
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
footprinterString = this.props.footprint;
|
|
12843
|
-
}
|
|
12839
|
+
const footprint = this.props.footprint ?? this._getImpliedFootprintString();
|
|
12840
|
+
const footprinterString = typeof footprint === "string" ? footprint : void 0;
|
|
12844
12841
|
const supplierPartNumbersMaybePromise = this._getSupplierPartNumbers(
|
|
12845
12842
|
partsEngine,
|
|
12846
12843
|
source_component,
|
|
@@ -22240,7 +22237,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
22240
22237
|
var package_default = {
|
|
22241
22238
|
name: "@tscircuit/core",
|
|
22242
22239
|
type: "module",
|
|
22243
|
-
version: "0.0.
|
|
22240
|
+
version: "0.0.1290",
|
|
22244
22241
|
types: "dist/index.d.ts",
|
|
22245
22242
|
main: "dist/index.js",
|
|
22246
22243
|
module: "dist/index.js",
|
|
@@ -24459,6 +24456,59 @@ var Interconnect = class extends NormalComponent3 {
|
|
|
24459
24456
|
import { solderjumperProps } from "@tscircuit/props";
|
|
24460
24457
|
var SolderJumper = class extends NormalComponent3 {
|
|
24461
24458
|
schematicDimensions = null;
|
|
24459
|
+
_getPinCountFromFootprintString(footprint) {
|
|
24460
|
+
const match = footprint.match(/^solderjumper([23])(?:_|$)/);
|
|
24461
|
+
if (!match) return null;
|
|
24462
|
+
return Number(match[1]);
|
|
24463
|
+
}
|
|
24464
|
+
// Used during footprint resolution before ports can be selected.
|
|
24465
|
+
_getPinNumberFromBridgedPinsProp(pinName) {
|
|
24466
|
+
const numericPinMatch = pinName.match(/^(?:pin)?(\d+)$/i);
|
|
24467
|
+
if (numericPinMatch) return Number(numericPinMatch[1]);
|
|
24468
|
+
const pinLabels = this._parsedProps.pinLabels ?? this.props.pinLabels;
|
|
24469
|
+
if (Array.isArray(pinLabels)) {
|
|
24470
|
+
const labelIndex = pinLabels.findIndex((label) => label === pinName);
|
|
24471
|
+
return labelIndex >= 0 ? labelIndex + 1 : null;
|
|
24472
|
+
}
|
|
24473
|
+
if (pinLabels && typeof pinLabels === "object") {
|
|
24474
|
+
for (const [pinKey, labelOrLabels] of Object.entries(pinLabels)) {
|
|
24475
|
+
const labels = Array.isArray(labelOrLabels) ? labelOrLabels : [labelOrLabels];
|
|
24476
|
+
if (!labels.includes(pinName)) continue;
|
|
24477
|
+
const pinNumberMatch = pinKey.match(/^(?:pin)?(\d+)$/i);
|
|
24478
|
+
return pinNumberMatch ? Number(pinNumberMatch[1]) : null;
|
|
24479
|
+
}
|
|
24480
|
+
}
|
|
24481
|
+
return null;
|
|
24482
|
+
}
|
|
24483
|
+
_getBridgedPinNumbersForFootprint(pinCount) {
|
|
24484
|
+
const props = this._parsedProps ?? this.props;
|
|
24485
|
+
if (Array.isArray(props.bridgedPins) && props.bridgedPins.length > 0) {
|
|
24486
|
+
return Array.from(
|
|
24487
|
+
new Set(
|
|
24488
|
+
props.bridgedPins.flat().map(
|
|
24489
|
+
(pinName) => this._getPinNumberFromBridgedPinsProp(pinName)
|
|
24490
|
+
).filter(
|
|
24491
|
+
(pinNumber) => pinNumber !== null && pinNumber >= 1 && pinNumber <= pinCount
|
|
24492
|
+
)
|
|
24493
|
+
)
|
|
24494
|
+
).sort((a, b) => a - b);
|
|
24495
|
+
}
|
|
24496
|
+
if (!props.bridged) return [];
|
|
24497
|
+
return Array.from({ length: pinCount }, (_, index) => index + 1);
|
|
24498
|
+
}
|
|
24499
|
+
resolveFootprint() {
|
|
24500
|
+
const footprint = super.resolveFootprint();
|
|
24501
|
+
if (typeof footprint !== "string") return footprint;
|
|
24502
|
+
const pinCount = this._getPinCountFromFootprintString(footprint);
|
|
24503
|
+
if (!pinCount) return footprint;
|
|
24504
|
+
if (/_bridged\d+/.test(footprint)) return footprint;
|
|
24505
|
+
const bridgedPinNumbers = this._getBridgedPinNumbersForFootprint(pinCount);
|
|
24506
|
+
if (bridgedPinNumbers.length === 0) return footprint;
|
|
24507
|
+
return footprint.replace(
|
|
24508
|
+
/^solderjumper[23]/,
|
|
24509
|
+
`solderjumper${pinCount}_bridged${bridgedPinNumbers.join("")}`
|
|
24510
|
+
);
|
|
24511
|
+
}
|
|
24462
24512
|
_getPinNumberFromBridgedPinName(pinName) {
|
|
24463
24513
|
const port = this.selectOne(`port.${pinName}`, {
|
|
24464
24514
|
type: "port"
|