@tscircuit/core 0.0.280 → 0.0.281
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 +16 -14
- package/dist/index.js +31 -56
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { Matrix } from 'transformation-matrix';
|
|
|
10
10
|
import { SoupUtilObjects } from '@tscircuit/soup-util';
|
|
11
11
|
import * as _tscircuit_layout from '@tscircuit/layout';
|
|
12
12
|
|
|
13
|
-
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "
|
|
13
|
+
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortMatching", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbComponentSizeCalculation", "PcbTraceRender", "PcbTraceHintRender", "PcbRouteNetIslands", "CadModelRender", "PartsEngineRender"];
|
|
14
14
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
15
15
|
type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
|
|
16
16
|
type RenderPhaseStates = Record<RenderPhase, {
|
|
@@ -808,6 +808,7 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
|
|
|
808
808
|
*/
|
|
809
809
|
initPorts(opts?: {
|
|
810
810
|
additionalAliases?: Record<`pin${number}`, string[]>;
|
|
811
|
+
pinCount?: number;
|
|
811
812
|
}): void;
|
|
812
813
|
_getImpliedFootprintString(): string | null;
|
|
813
814
|
_addChildrenFromStringFootprint(): void;
|
|
@@ -836,19 +837,11 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
|
|
|
836
837
|
doInitialReactSubtreesRender(): void;
|
|
837
838
|
_hasExistingPortExactly(port1: Port): boolean;
|
|
838
839
|
add(componentOrElm: PrimitiveComponent | ReactElement): void;
|
|
839
|
-
getPortsFromFootprint(
|
|
840
|
+
getPortsFromFootprint(opts?: {
|
|
841
|
+
additionalAliases?: Record<string, string[]>;
|
|
842
|
+
}): Port[];
|
|
840
843
|
getPortsFromSchematicSymbol(): Port[];
|
|
841
844
|
_createNetsFromProps(propsWithConnections: (string | undefined | null)[]): void;
|
|
842
|
-
/**
|
|
843
|
-
* Use data from our props to create ports for this component.
|
|
844
|
-
*
|
|
845
|
-
* Generally, this is done by looking at the schematic and the footprint,
|
|
846
|
-
* reading the pins, making sure there aren't duplicates.
|
|
847
|
-
*
|
|
848
|
-
* Can probably be removed in favor of initPorts()
|
|
849
|
-
*
|
|
850
|
-
*/
|
|
851
|
-
doInitialPortDiscovery(): void;
|
|
852
845
|
_getPcbCircuitJsonBounds(): {
|
|
853
846
|
center: {
|
|
854
847
|
x: number;
|
|
@@ -863,6 +856,7 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
|
|
|
863
856
|
width: number;
|
|
864
857
|
height: number;
|
|
865
858
|
};
|
|
859
|
+
_getPinCountFromSchematicPortArrangement(): number;
|
|
866
860
|
_getPinCount(): number;
|
|
867
861
|
/**
|
|
868
862
|
* Override the schematic port arrangement if you want to customize where pins
|
|
@@ -9939,11 +9933,19 @@ type PinNumbers100 = "pin1" | "pin2" | "pin3" | "pin4" | "pin5" | "pin6" | "pin7
|
|
|
9939
9933
|
type CommonPinNames = "pos" | "neg" | "V5" | "V3_3" | "VCC" | "VDD" | "GND" | `D${Nums40}` | `GP${Nums40}` | `GPIO${Nums40}` | "DP" | "DN" | "VIN" | "VOUT" | "VREF" | "VIN" | "VOUT" | "VREF" | "VIN" | "VOUT" | "VREF" | `A${Nums40}` | `B${Nums40}` | PinNumbers100;
|
|
9940
9934
|
type TransistorPinNames = "base" | "collector" | "emitter";
|
|
9941
9935
|
|
|
9942
|
-
type NonPolarizedSel = Record<`R${Nums40}
|
|
9936
|
+
type NonPolarizedSel = Record<`R${Nums40}`, {
|
|
9937
|
+
pin1: string;
|
|
9938
|
+
pin2: string;
|
|
9939
|
+
pos: string;
|
|
9940
|
+
neg: string;
|
|
9941
|
+
}>;
|
|
9942
|
+
type SwSel = Record<`SW${Nums40}`, {
|
|
9943
9943
|
pin1: string;
|
|
9944
9944
|
pin2: string;
|
|
9945
9945
|
pos: string;
|
|
9946
9946
|
neg: string;
|
|
9947
|
+
side1: string;
|
|
9948
|
+
side2: string;
|
|
9947
9949
|
}>;
|
|
9948
9950
|
type PolarizedSel = Record<`C${Nums40}` | `L${Nums40}` | `LED${Nums40}` | `D${Nums40}` | `Y${Nums40}` | `B${Nums16}`, {
|
|
9949
9951
|
pin1: string;
|
|
@@ -9957,7 +9959,7 @@ type TransistorSel = Record<`Q${Nums40}`, Record<TransistorPinNames, string>>;
|
|
|
9957
9959
|
type JumperSel = Record<`J${Nums40}`, Record<PinNumbers100, string>>;
|
|
9958
9960
|
type ChipSel = Record<`U${Nums40}`, Record<CommonPinNames, string>>;
|
|
9959
9961
|
type NetSel = Record<"net", Record<"VCC" | "GND" | "VDD", string>>;
|
|
9960
|
-
type Sel = NonPolarizedSel & PolarizedSel & TransistorSel & JumperSel & ChipSel & NetSel;
|
|
9962
|
+
type Sel = NonPolarizedSel & PolarizedSel & TransistorSel & JumperSel & ChipSel & SwSel & NetSel;
|
|
9961
9963
|
declare const sel: Sel;
|
|
9962
9964
|
|
|
9963
9965
|
interface TscircuitElements {
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,6 @@ var orderedRenderPhases = [
|
|
|
72
72
|
"CreateTraceHintsFromProps",
|
|
73
73
|
"SourceRender",
|
|
74
74
|
"SourceParentAttachment",
|
|
75
|
-
"PortDiscovery",
|
|
76
75
|
"PortMatching",
|
|
77
76
|
"SourceTraceRender",
|
|
78
77
|
"SourceAddConnectivityMapKey",
|
|
@@ -2267,14 +2266,19 @@ var getPinNumberFromLabels = (labels) => {
|
|
|
2267
2266
|
if (!pinNumber) return null;
|
|
2268
2267
|
return Number.parseInt(pinNumber.replace(/^pin/, ""));
|
|
2269
2268
|
};
|
|
2270
|
-
function getPortFromHints(hints) {
|
|
2269
|
+
function getPortFromHints(hints, opts) {
|
|
2271
2270
|
const pinNumber = getPinNumberFromLabels(hints);
|
|
2272
2271
|
if (!pinNumber) return null;
|
|
2272
|
+
const aliasesFromHints = hints.filter(
|
|
2273
|
+
(p) => p.toString() !== pinNumber.toString() && p !== `pin${pinNumber}`
|
|
2274
|
+
);
|
|
2275
|
+
const aliases = [
|
|
2276
|
+
...aliasesFromHints,
|
|
2277
|
+
...opts?.additionalAliases?.[`pin${pinNumber}`] ?? []
|
|
2278
|
+
];
|
|
2273
2279
|
return new Port({
|
|
2274
2280
|
pinNumber,
|
|
2275
|
-
aliases
|
|
2276
|
-
(p) => p.toString() !== pinNumber.toString() && p !== `pin${pinNumber}`
|
|
2277
|
-
)
|
|
2281
|
+
aliases
|
|
2278
2282
|
});
|
|
2279
2283
|
}
|
|
2280
2284
|
|
|
@@ -2926,10 +2930,9 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2926
2930
|
}
|
|
2927
2931
|
}
|
|
2928
2932
|
this.addAll(portsToCreate);
|
|
2929
|
-
return;
|
|
2930
2933
|
}
|
|
2931
2934
|
if (!this._parsedProps.schPortArrangement) {
|
|
2932
|
-
const portsFromFootprint = this.getPortsFromFootprint();
|
|
2935
|
+
const portsFromFootprint = this.getPortsFromFootprint(opts);
|
|
2933
2936
|
for (const port of portsFromFootprint) {
|
|
2934
2937
|
if (!portsToCreate.some(
|
|
2935
2938
|
(p) => p.isMatchingAnyOf(port.getNameAndAliases())
|
|
@@ -2938,7 +2941,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2938
2941
|
}
|
|
2939
2942
|
}
|
|
2940
2943
|
}
|
|
2941
|
-
for (let pn = 1; pn <= this._getPinCount(); pn++) {
|
|
2944
|
+
for (let pn = 1; pn <= (opts.pinCount ?? this._getPinCount()); pn++) {
|
|
2942
2945
|
if (!this._parsedProps.schPortArrangement) continue;
|
|
2943
2946
|
if (portsToCreate.find((p) => p._parsedProps.pinNumber === pn)) continue;
|
|
2944
2947
|
let explicitlyListedPinNumbersInSchPortArrangement = [
|
|
@@ -3241,7 +3244,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3241
3244
|
}
|
|
3242
3245
|
super.add(component);
|
|
3243
3246
|
}
|
|
3244
|
-
getPortsFromFootprint() {
|
|
3247
|
+
getPortsFromFootprint(opts) {
|
|
3245
3248
|
let { footprint } = this.props;
|
|
3246
3249
|
if (!footprint || isValidElement(footprint)) {
|
|
3247
3250
|
footprint = this.children.find((c) => c.componentName === "Footprint");
|
|
@@ -3251,7 +3254,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3251
3254
|
const newPorts2 = [];
|
|
3252
3255
|
for (const elm of fpSoup) {
|
|
3253
3256
|
if ("port_hints" in elm && elm.port_hints) {
|
|
3254
|
-
const newPort = getPortFromHints(elm.port_hints);
|
|
3257
|
+
const newPort = getPortFromHints(elm.port_hints, opts);
|
|
3255
3258
|
if (!newPort) continue;
|
|
3256
3259
|
newPort.originDescription = `footprint:string:${footprint}:port_hints[0]:${elm.port_hints[0]}`;
|
|
3257
3260
|
newPorts2.push(newPort);
|
|
@@ -3310,41 +3313,6 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3310
3313
|
_createNetsFromProps(propsWithConnections) {
|
|
3311
3314
|
createNetsFromProps(this, propsWithConnections);
|
|
3312
3315
|
}
|
|
3313
|
-
/**
|
|
3314
|
-
* Use data from our props to create ports for this component.
|
|
3315
|
-
*
|
|
3316
|
-
* Generally, this is done by looking at the schematic and the footprint,
|
|
3317
|
-
* reading the pins, making sure there aren't duplicates.
|
|
3318
|
-
*
|
|
3319
|
-
* Can probably be removed in favor of initPorts()
|
|
3320
|
-
*
|
|
3321
|
-
*/
|
|
3322
|
-
doInitialPortDiscovery() {
|
|
3323
|
-
const { _parsedProps: props } = this;
|
|
3324
|
-
let newPorts = [];
|
|
3325
|
-
if (!props.schPortArrangement) {
|
|
3326
|
-
newPorts = [
|
|
3327
|
-
...this.getPortsFromFootprint(),
|
|
3328
|
-
...this.getPortsFromSchematicSymbol()
|
|
3329
|
-
];
|
|
3330
|
-
}
|
|
3331
|
-
const existingPorts = this.children.filter(
|
|
3332
|
-
(c) => c.componentName === "Port"
|
|
3333
|
-
);
|
|
3334
|
-
for (const newPort of newPorts) {
|
|
3335
|
-
const existingPort = existingPorts.find(
|
|
3336
|
-
(p) => p.isMatchingAnyOf(newPort.getNameAndAliases())
|
|
3337
|
-
);
|
|
3338
|
-
if (existingPort) {
|
|
3339
|
-
if (!existingPort.schematicSymbolPortDef && newPort.schematicSymbolPortDef) {
|
|
3340
|
-
existingPort.schematicSymbolPortDef = newPort.schematicSymbolPortDef;
|
|
3341
|
-
}
|
|
3342
|
-
continue;
|
|
3343
|
-
}
|
|
3344
|
-
existingPorts.push(newPort);
|
|
3345
|
-
this.add(newPort);
|
|
3346
|
-
}
|
|
3347
|
-
}
|
|
3348
3316
|
_getPcbCircuitJsonBounds() {
|
|
3349
3317
|
const { db } = this.root;
|
|
3350
3318
|
if (!this.pcb_component_id) return super._getPcbCircuitJsonBounds();
|
|
@@ -3361,20 +3329,26 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
3361
3329
|
height: pcb_component.height
|
|
3362
3330
|
};
|
|
3363
3331
|
}
|
|
3332
|
+
_getPinCountFromSchematicPortArrangement() {
|
|
3333
|
+
const schPortArrangement = this._getSchematicPortArrangement();
|
|
3334
|
+
if (!schPortArrangement) return 0;
|
|
3335
|
+
const isExplicitPinMapping = isExplicitPinMappingArrangement(schPortArrangement);
|
|
3336
|
+
if (!isExplicitPinMapping) {
|
|
3337
|
+
return (schPortArrangement.leftSize ?? schPortArrangement.leftPinCount ?? 0) + (schPortArrangement.rightSize ?? schPortArrangement.rightPinCount ?? 0) + (schPortArrangement.topSize ?? schPortArrangement.topPinCount ?? 0) + (schPortArrangement.bottomSize ?? schPortArrangement.bottomPinCount ?? 0);
|
|
3338
|
+
}
|
|
3339
|
+
const { leftSide, rightSide, topSide, bottomSide } = schPortArrangement;
|
|
3340
|
+
return Math.max(
|
|
3341
|
+
...leftSide?.pins ?? [],
|
|
3342
|
+
...rightSide?.pins ?? [],
|
|
3343
|
+
...topSide?.pins ?? [],
|
|
3344
|
+
...bottomSide?.pins ?? []
|
|
3345
|
+
);
|
|
3346
|
+
}
|
|
3364
3347
|
_getPinCount() {
|
|
3365
3348
|
const schPortArrangement = this._getSchematicPortArrangement();
|
|
3366
3349
|
if (schPortArrangement) {
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3369
|
-
return (schPortArrangement.leftSize ?? schPortArrangement.leftPinCount ?? 0) + (schPortArrangement.rightSize ?? schPortArrangement.rightPinCount ?? 0) + (schPortArrangement.topSize ?? schPortArrangement.topPinCount ?? 0) + (schPortArrangement.bottomSize ?? schPortArrangement.bottomPinCount ?? 0);
|
|
3370
|
-
}
|
|
3371
|
-
const { leftSide, rightSide, topSide, bottomSide } = schPortArrangement;
|
|
3372
|
-
return Math.max(
|
|
3373
|
-
...leftSide?.pins ?? [],
|
|
3374
|
-
...rightSide?.pins ?? [],
|
|
3375
|
-
...topSide?.pins ?? [],
|
|
3376
|
-
...bottomSide?.pins ?? []
|
|
3377
|
-
);
|
|
3350
|
+
const pinCountFromSchematicPortArrangement = this._getPinCountFromSchematicPortArrangement();
|
|
3351
|
+
return pinCountFromSchematicPortArrangement;
|
|
3378
3352
|
}
|
|
3379
3353
|
return this.getPortsFromFootprint().length;
|
|
3380
3354
|
}
|
|
@@ -6339,6 +6313,7 @@ var PushButton = class extends NormalComponent {
|
|
|
6339
6313
|
}
|
|
6340
6314
|
initPorts() {
|
|
6341
6315
|
super.initPorts({
|
|
6316
|
+
pinCount: 4,
|
|
6342
6317
|
additionalAliases: {
|
|
6343
6318
|
pin1: ["side1"],
|
|
6344
6319
|
pin3: ["side2"]
|