@tscircuit/core 0.0.279 → 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 +42 -13
- package/dist/index.js +52 -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
|
|
@@ -9933,6 +9927,41 @@ type RenderEvent = {
|
|
|
9933
9927
|
*/
|
|
9934
9928
|
declare const getPhaseTimingsFromRenderEvents: (renderEvents: RenderEvent[]) => Record<string, number>;
|
|
9935
9929
|
|
|
9930
|
+
type Nums16 = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16";
|
|
9931
|
+
type Nums40 = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13" | "14" | "15" | "16" | "17" | "18" | "19" | "20" | "21" | "22" | "23" | "24" | "25" | "26" | "27" | "28" | "29" | "30" | "31" | "32" | "33" | "34" | "35" | "36" | "37" | "38" | "39" | "40";
|
|
9932
|
+
type PinNumbers100 = "pin1" | "pin2" | "pin3" | "pin4" | "pin5" | "pin6" | "pin7" | "pin8" | "pin9" | "pin10" | "pin11" | "pin12" | "pin13" | "pin14" | "pin15" | "pin16" | "pin17" | "pin18" | "pin19" | "pin20" | "pin21" | "pin22" | "pin23" | "pin24" | "pin25" | "pin26" | "pin27" | "pin28" | "pin29" | "pin30" | "pin31" | "pin32" | "pin33" | "pin34" | "pin35" | "pin36" | "pin37" | "pin38" | "pin39" | "pin40" | "pin41" | "pin42" | "pin43" | "pin44" | "pin45" | "pin46" | "pin47" | "pin48" | "pin49" | "pin50" | "pin51" | "pin52" | "pin53" | "pin54" | "pin55" | "pin56" | "pin57" | "pin58" | "pin59" | "pin60" | "pin61" | "pin62" | "pin63" | "pin64" | "pin65" | "pin66" | "pin67" | "pin68" | "pin69" | "pin70" | "pin71" | "pin72" | "pin73" | "pin74" | "pin75" | "pin76" | "pin77" | "pin78" | "pin79" | "pin80" | "pin81" | "pin82" | "pin83" | "pin84" | "pin85" | "pin86" | "pin87" | "pin88" | "pin89" | "pin90" | "pin91" | "pin92" | "pin93" | "pin94" | "pin95" | "pin96" | "pin97" | "pin98" | "pin99" | "pin100";
|
|
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;
|
|
9934
|
+
type TransistorPinNames = "base" | "collector" | "emitter";
|
|
9935
|
+
|
|
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
|
+
pin1: string;
|
|
9944
|
+
pin2: string;
|
|
9945
|
+
pos: string;
|
|
9946
|
+
neg: string;
|
|
9947
|
+
side1: string;
|
|
9948
|
+
side2: string;
|
|
9949
|
+
}>;
|
|
9950
|
+
type PolarizedSel = Record<`C${Nums40}` | `L${Nums40}` | `LED${Nums40}` | `D${Nums40}` | `Y${Nums40}` | `B${Nums16}`, {
|
|
9951
|
+
pin1: string;
|
|
9952
|
+
pin2: string;
|
|
9953
|
+
anode: string;
|
|
9954
|
+
cathode: string;
|
|
9955
|
+
pos: string;
|
|
9956
|
+
neg: string;
|
|
9957
|
+
}>;
|
|
9958
|
+
type TransistorSel = Record<`Q${Nums40}`, Record<TransistorPinNames, string>>;
|
|
9959
|
+
type JumperSel = Record<`J${Nums40}`, Record<PinNumbers100, string>>;
|
|
9960
|
+
type ChipSel = Record<`U${Nums40}`, Record<CommonPinNames, string>>;
|
|
9961
|
+
type NetSel = Record<"net", Record<"VCC" | "GND" | "VDD", string>>;
|
|
9962
|
+
type Sel = NonPolarizedSel & PolarizedSel & TransistorSel & JumperSel & ChipSel & SwSel & NetSel;
|
|
9963
|
+
declare const sel: Sel;
|
|
9964
|
+
|
|
9936
9965
|
interface TscircuitElements {
|
|
9937
9966
|
resistor: _tscircuit_props.ResistorProps;
|
|
9938
9967
|
capacitor: _tscircuit_props.CapacitorProps;
|
|
@@ -9995,4 +10024,4 @@ declare module "react/jsx-runtime" {
|
|
|
9995
10024
|
}
|
|
9996
10025
|
}
|
|
9997
10026
|
|
|
9998
|
-
export { type AsyncEffect, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Subcircuit, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
|
|
10027
|
+
export { type AsyncEffect, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Subcircuit, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
|
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"]
|
|
@@ -6842,6 +6817,26 @@ var getPhaseTimingsFromRenderEvents = (renderEvents) => {
|
|
|
6842
6817
|
return phaseTimings;
|
|
6843
6818
|
};
|
|
6844
6819
|
|
|
6820
|
+
// lib/sel/sel.ts
|
|
6821
|
+
var sel = new Proxy(
|
|
6822
|
+
{},
|
|
6823
|
+
{
|
|
6824
|
+
get: (_, prop1) => {
|
|
6825
|
+
return new Proxy(
|
|
6826
|
+
{},
|
|
6827
|
+
{
|
|
6828
|
+
get: (_2, prop2) => {
|
|
6829
|
+
if (prop1 === "net") {
|
|
6830
|
+
return `net.${prop2}`;
|
|
6831
|
+
}
|
|
6832
|
+
return `.${prop1} > .${prop2}`;
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
);
|
|
6836
|
+
}
|
|
6837
|
+
}
|
|
6838
|
+
);
|
|
6839
|
+
|
|
6845
6840
|
// lib/index.ts
|
|
6846
6841
|
import { createElement } from "react";
|
|
6847
6842
|
|
|
@@ -6901,6 +6896,7 @@ export {
|
|
|
6901
6896
|
getPhaseTimingsFromRenderEvents,
|
|
6902
6897
|
getSimpleRouteJsonFromCircuitJson,
|
|
6903
6898
|
orderedRenderPhases,
|
|
6899
|
+
sel,
|
|
6904
6900
|
useCapacitor,
|
|
6905
6901
|
useChip,
|
|
6906
6902
|
useDiode,
|