@tscircuit/core 0.0.389 → 0.0.391
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +117 -30
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3314,6 +3314,7 @@ declare class Diode extends NormalComponent<typeof diodeProps, PolarizedPassiveP
|
|
|
3314
3314
|
sourceFtype: Ftype;
|
|
3315
3315
|
};
|
|
3316
3316
|
initPorts(): void;
|
|
3317
|
+
doInitialSourceRender(): void;
|
|
3317
3318
|
pos: Port;
|
|
3318
3319
|
anode: Port;
|
|
3319
3320
|
neg: Port;
|
|
@@ -4346,6 +4347,7 @@ declare class Led extends NormalComponent<typeof ledProps, PolarizedPassivePorts
|
|
|
4346
4347
|
sourceFtype: Ftype;
|
|
4347
4348
|
};
|
|
4348
4349
|
initPorts(): void;
|
|
4350
|
+
doInitialSourceRender(): void;
|
|
4349
4351
|
pos: Port;
|
|
4350
4352
|
anode: Port;
|
|
4351
4353
|
neg: Port;
|
|
@@ -4756,6 +4758,7 @@ declare class PowerSource extends NormalComponent<typeof powerSourceProps, Polar
|
|
|
4756
4758
|
sourceFtype: Ftype;
|
|
4757
4759
|
};
|
|
4758
4760
|
initPorts(): void;
|
|
4761
|
+
doInitialSourceRender(): void;
|
|
4759
4762
|
pos: Port;
|
|
4760
4763
|
positive: Port;
|
|
4761
4764
|
neg: Port;
|
package/dist/index.js
CHANGED
|
@@ -2139,10 +2139,36 @@ var SilkscreenText = class extends PrimitiveComponent2 {
|
|
|
2139
2139
|
}
|
|
2140
2140
|
};
|
|
2141
2141
|
|
|
2142
|
-
// lib/utils/
|
|
2143
|
-
var
|
|
2142
|
+
// lib/utils/createPinrowSilkscreenText.ts
|
|
2143
|
+
var createPinrowSilkscreenText = ({
|
|
2144
|
+
elm,
|
|
2145
|
+
pinLabels,
|
|
2146
|
+
readableRotation
|
|
2147
|
+
}) => {
|
|
2148
|
+
const pinNum = elm.text.replace(/[{}]/g, "").toLowerCase();
|
|
2149
|
+
let label = pinNum;
|
|
2150
|
+
if (Array.isArray(pinLabels)) {
|
|
2151
|
+
const index = parseInt(pinNum.replace(/[^\d]/g, ""), 10) - 1;
|
|
2152
|
+
label = pinLabels[index] ?? pinNum;
|
|
2153
|
+
} else if (typeof pinLabels === "object") {
|
|
2154
|
+
label = pinLabels[pinNum]?.[0] ?? pinNum;
|
|
2155
|
+
}
|
|
2156
|
+
return new SilkscreenText({
|
|
2157
|
+
anchorAlignment: "center",
|
|
2158
|
+
text: label ?? pinNum,
|
|
2159
|
+
fontSize: elm.font_size + 0.2,
|
|
2160
|
+
pcbX: isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
|
|
2161
|
+
pcbY: elm.anchor_position.y,
|
|
2162
|
+
pcbRotation: readableRotation ?? 0
|
|
2163
|
+
});
|
|
2164
|
+
};
|
|
2165
|
+
|
|
2166
|
+
// lib/utils/createComponentsFromCircuitJson.ts
|
|
2167
|
+
var createComponentsFromCircuitJson = ({
|
|
2144
2168
|
componentName,
|
|
2145
|
-
componentRotation
|
|
2169
|
+
componentRotation,
|
|
2170
|
+
footprint,
|
|
2171
|
+
pinLabels
|
|
2146
2172
|
}, soup) => {
|
|
2147
2173
|
const components = [];
|
|
2148
2174
|
for (const elm of soup) {
|
|
@@ -2222,16 +2248,22 @@ var createComponentsFromSoup = ({
|
|
|
2222
2248
|
const normalizedRotation = (readableRotation % 360 + 360) % 360;
|
|
2223
2249
|
const isUpsideDown = normalizedRotation > 90 && normalizedRotation <= 270;
|
|
2224
2250
|
readableRotation = isUpsideDown ? (normalizedRotation + 180) % 360 : normalizedRotation;
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2251
|
+
if (footprint.includes("pinrow") && elm.text.includes("PIN") && pinLabels) {
|
|
2252
|
+
components.push(
|
|
2253
|
+
createPinrowSilkscreenText({ elm, pinLabels, readableRotation })
|
|
2254
|
+
);
|
|
2255
|
+
} else if (elm.text === "{REF}") {
|
|
2256
|
+
components.push(
|
|
2257
|
+
new SilkscreenText({
|
|
2258
|
+
anchorAlignment: "center",
|
|
2259
|
+
text: componentName,
|
|
2260
|
+
fontSize: elm.font_size + 0.2,
|
|
2261
|
+
pcbX: isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
|
|
2262
|
+
pcbY: elm.anchor_position.y,
|
|
2263
|
+
pcbRotation: readableRotation ?? 0
|
|
2264
|
+
})
|
|
2265
|
+
);
|
|
2266
|
+
}
|
|
2235
2267
|
}
|
|
2236
2268
|
}
|
|
2237
2269
|
return components;
|
|
@@ -5009,14 +5041,18 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
5009
5041
|
return null;
|
|
5010
5042
|
}
|
|
5011
5043
|
_addChildrenFromStringFootprint() {
|
|
5012
|
-
const {
|
|
5044
|
+
const {
|
|
5045
|
+
name: componentName,
|
|
5046
|
+
pcbRotation: componentRotation,
|
|
5047
|
+
pinLabels
|
|
5048
|
+
} = this.props;
|
|
5013
5049
|
let { footprint } = this.props;
|
|
5014
5050
|
footprint ??= this._getImpliedFootprintString?.();
|
|
5015
5051
|
if (!footprint) return;
|
|
5016
5052
|
if (typeof footprint === "string") {
|
|
5017
5053
|
const fpSoup = fp.string(footprint).soup();
|
|
5018
|
-
const fpComponents =
|
|
5019
|
-
{ componentName, componentRotation },
|
|
5054
|
+
const fpComponents = createComponentsFromCircuitJson(
|
|
5055
|
+
{ componentName, componentRotation, footprint, pinLabels },
|
|
5020
5056
|
fpSoup
|
|
5021
5057
|
);
|
|
5022
5058
|
this.addAll(fpComponents);
|
|
@@ -6898,7 +6934,8 @@ var Capacitor = class extends NormalComponent {
|
|
|
6898
6934
|
capacitance: props.capacitance,
|
|
6899
6935
|
max_voltage_rating: props.maxVoltageRating,
|
|
6900
6936
|
max_decoupling_trace_length: props.maxDecouplingTraceLength,
|
|
6901
|
-
display_capacitance: this._getSchematicSymbolDisplayValue()
|
|
6937
|
+
display_capacitance: this._getSchematicSymbolDisplayValue(),
|
|
6938
|
+
are_pins_interchangeable: !props.polarized
|
|
6902
6939
|
});
|
|
6903
6940
|
this.source_component_id = source_component.source_component_id;
|
|
6904
6941
|
}
|
|
@@ -6984,6 +7021,19 @@ var Diode = class extends NormalComponent {
|
|
|
6984
7021
|
}
|
|
6985
7022
|
});
|
|
6986
7023
|
}
|
|
7024
|
+
doInitialSourceRender() {
|
|
7025
|
+
const { db } = this.root;
|
|
7026
|
+
const { _parsedProps: props } = this;
|
|
7027
|
+
const source_component = db.source_component.insert({
|
|
7028
|
+
ftype: "simple_diode",
|
|
7029
|
+
name: props.name,
|
|
7030
|
+
// @ts-ignore
|
|
7031
|
+
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
7032
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
7033
|
+
are_pins_interchangeable: false
|
|
7034
|
+
});
|
|
7035
|
+
this.source_component_id = source_component.source_component_id;
|
|
7036
|
+
}
|
|
6987
7037
|
pos = this.portMap.pin1;
|
|
6988
7038
|
anode = this.portMap.pin1;
|
|
6989
7039
|
neg = this.portMap.pin2;
|
|
@@ -7009,7 +7059,8 @@ var Jumper = class extends NormalComponent {
|
|
|
7009
7059
|
// TODO unknown or jumper
|
|
7010
7060
|
name: props.name,
|
|
7011
7061
|
manufacturer_part_number: props.manufacturerPartNumber,
|
|
7012
|
-
supplier_part_numbers: props.supplierPartNumbers
|
|
7062
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
7063
|
+
are_pins_interchangeable: true
|
|
7013
7064
|
});
|
|
7014
7065
|
this.source_component_id = source_component.source_component_id;
|
|
7015
7066
|
}
|
|
@@ -7052,6 +7103,19 @@ var Led = class extends NormalComponent {
|
|
|
7052
7103
|
}
|
|
7053
7104
|
});
|
|
7054
7105
|
}
|
|
7106
|
+
doInitialSourceRender() {
|
|
7107
|
+
const { db } = this.root;
|
|
7108
|
+
const { _parsedProps: props } = this;
|
|
7109
|
+
const source_component = db.source_component.insert({
|
|
7110
|
+
ftype: "simple_diode",
|
|
7111
|
+
name: props.name,
|
|
7112
|
+
// @ts-ignore
|
|
7113
|
+
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
7114
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
7115
|
+
are_pins_interchangeable: false
|
|
7116
|
+
});
|
|
7117
|
+
this.source_component_id = source_component.source_component_id;
|
|
7118
|
+
}
|
|
7055
7119
|
pos = this.portMap.pin1;
|
|
7056
7120
|
anode = this.portMap.pin1;
|
|
7057
7121
|
neg = this.portMap.pin2;
|
|
@@ -7079,6 +7143,18 @@ var PowerSource = class extends NormalComponent {
|
|
|
7079
7143
|
new Port({ name: "pin2", pinNumber: 2, aliases: ["negative", "neg"] })
|
|
7080
7144
|
);
|
|
7081
7145
|
}
|
|
7146
|
+
doInitialSourceRender() {
|
|
7147
|
+
const { db } = this.root;
|
|
7148
|
+
const { _parsedProps: props } = this;
|
|
7149
|
+
const source_component = db.source_component.insert({
|
|
7150
|
+
ftype: "simple_power_source",
|
|
7151
|
+
name: props.name,
|
|
7152
|
+
voltage: props.voltage,
|
|
7153
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
7154
|
+
are_pins_interchangeable: false
|
|
7155
|
+
});
|
|
7156
|
+
this.source_component_id = source_component.source_component_id;
|
|
7157
|
+
}
|
|
7082
7158
|
pos = this.portMap.pin1;
|
|
7083
7159
|
positive = this.portMap.pin1;
|
|
7084
7160
|
neg = this.portMap.pin2;
|
|
@@ -7142,7 +7218,8 @@ var Resistor = class extends NormalComponent {
|
|
|
7142
7218
|
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
7143
7219
|
supplier_part_numbers: props.supplierPartNumbers,
|
|
7144
7220
|
resistance: props.resistance,
|
|
7145
|
-
display_resistance: this._getSchematicSymbolDisplayValue()
|
|
7221
|
+
display_resistance: this._getSchematicSymbolDisplayValue(),
|
|
7222
|
+
are_pins_interchangeable: true
|
|
7146
7223
|
});
|
|
7147
7224
|
this.source_component_id = source_component.source_component_id;
|
|
7148
7225
|
}
|
|
@@ -7549,7 +7626,8 @@ var Battery = class extends NormalComponent {
|
|
|
7549
7626
|
name: props.name,
|
|
7550
7627
|
ftype: "simple_power_source",
|
|
7551
7628
|
capacity: props.capacity,
|
|
7552
|
-
supplier_part_numbers: props.supplierPartNumbers
|
|
7629
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
7630
|
+
are_pins_interchangeable: false
|
|
7553
7631
|
});
|
|
7554
7632
|
this.source_component_id = source_component.source_component_id;
|
|
7555
7633
|
}
|
|
@@ -7608,7 +7686,8 @@ var PinHeader = class extends NormalComponent {
|
|
|
7608
7686
|
name: props.name,
|
|
7609
7687
|
supplier_part_numbers: props.supplierPartNumbers,
|
|
7610
7688
|
pin_count: props.pinCount,
|
|
7611
|
-
gender: props.gender
|
|
7689
|
+
gender: props.gender,
|
|
7690
|
+
are_pins_interchangeable: true
|
|
7612
7691
|
});
|
|
7613
7692
|
this.source_component_id = source_component.source_component_id;
|
|
7614
7693
|
}
|
|
@@ -7640,13 +7719,15 @@ var Resonator = class extends NormalComponent {
|
|
|
7640
7719
|
doInitialSourceRender() {
|
|
7641
7720
|
const { db } = this.root;
|
|
7642
7721
|
const { _parsedProps: props } = this;
|
|
7722
|
+
const pinVariant = props.pinVariant || "no_ground";
|
|
7643
7723
|
const source_component = db.source_component.insert({
|
|
7644
7724
|
ftype: "simple_resonator",
|
|
7645
7725
|
name: props.name,
|
|
7646
7726
|
frequency: props.frequency,
|
|
7647
7727
|
load_capacitance: props.loadCapacitance,
|
|
7648
7728
|
supplier_part_numbers: props.supplierPartNumbers,
|
|
7649
|
-
pin_variant:
|
|
7729
|
+
pin_variant: pinVariant,
|
|
7730
|
+
are_pins_interchangeable: pinVariant === "no_ground" || pinVariant === "ground_pin"
|
|
7650
7731
|
});
|
|
7651
7732
|
this.source_component_id = source_component.source_component_id;
|
|
7652
7733
|
}
|
|
@@ -7678,7 +7759,8 @@ var Inductor = class extends NormalComponent {
|
|
|
7678
7759
|
name: props.name,
|
|
7679
7760
|
ftype: FTYPE.simple_inductor,
|
|
7680
7761
|
inductance: props.inductance,
|
|
7681
|
-
supplier_part_numbers: props.supplierPartNumbers
|
|
7762
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
7763
|
+
are_pins_interchangeable: true
|
|
7682
7764
|
});
|
|
7683
7765
|
this.source_component_id = source_component.source_component_id;
|
|
7684
7766
|
}
|
|
@@ -7708,11 +7790,13 @@ var Potentiometer = class extends NormalComponent {
|
|
|
7708
7790
|
doInitialSourceRender() {
|
|
7709
7791
|
const { db } = this.root;
|
|
7710
7792
|
const { _parsedProps: props } = this;
|
|
7793
|
+
const pinVariant = props.pinVariant || "two_pin";
|
|
7711
7794
|
const source_component = db.source_component.insert({
|
|
7712
7795
|
ftype: "simple_potentiometer",
|
|
7713
7796
|
name: props.name,
|
|
7714
7797
|
max_resistance: props.maxResistance,
|
|
7715
|
-
pin_variant:
|
|
7798
|
+
pin_variant: pinVariant,
|
|
7799
|
+
are_pins_interchangeable: pinVariant === "two_pin"
|
|
7716
7800
|
});
|
|
7717
7801
|
this.source_component_id = source_component.source_component_id;
|
|
7718
7802
|
}
|
|
@@ -7750,7 +7834,8 @@ var PushButton = class extends NormalComponent {
|
|
|
7750
7834
|
const source_component = db.source_component.insert({
|
|
7751
7835
|
name: props.name,
|
|
7752
7836
|
ftype: FTYPE.simple_push_button,
|
|
7753
|
-
supplier_part_numbers: props.supplierPartNumbers
|
|
7837
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
7838
|
+
are_pins_interchangeable: true
|
|
7754
7839
|
});
|
|
7755
7840
|
this.source_component_id = source_component.source_component_id;
|
|
7756
7841
|
}
|
|
@@ -7795,7 +7880,8 @@ var Crystal = class extends NormalComponent {
|
|
|
7795
7880
|
ftype: "simple_crystal",
|
|
7796
7881
|
frequency: props.frequency,
|
|
7797
7882
|
load_capacitance: props.loadCapacitance,
|
|
7798
|
-
pin_variant: props.pinVariant || "two_pin"
|
|
7883
|
+
pin_variant: props.pinVariant || "two_pin",
|
|
7884
|
+
are_pins_interchangeable: (props.pinVariant || "two_pin") === "two_pin"
|
|
7799
7885
|
});
|
|
7800
7886
|
this.source_component_id = source_component.source_component_id;
|
|
7801
7887
|
}
|
|
@@ -7906,7 +7992,8 @@ var Switch = class extends NormalComponent {
|
|
|
7906
7992
|
ftype: "simple_switch",
|
|
7907
7993
|
name: props.name,
|
|
7908
7994
|
switch_type: props.type,
|
|
7909
|
-
is_normally_closed: props.isNormallyClosed ?? false
|
|
7995
|
+
is_normally_closed: props.isNormallyClosed ?? false,
|
|
7996
|
+
are_pins_interchangeable: this._getSwitchType() === "spst"
|
|
7910
7997
|
});
|
|
7911
7998
|
this.source_component_id = source_component.source_component_id;
|
|
7912
7999
|
}
|
|
@@ -7921,7 +8008,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
7921
8008
|
var package_default = {
|
|
7922
8009
|
name: "@tscircuit/core",
|
|
7923
8010
|
type: "module",
|
|
7924
|
-
version: "0.0.
|
|
8011
|
+
version: "0.0.390",
|
|
7925
8012
|
types: "dist/index.d.ts",
|
|
7926
8013
|
main: "dist/index.js",
|
|
7927
8014
|
module: "dist/index.js",
|
|
@@ -7944,7 +8031,7 @@ var package_default = {
|
|
|
7944
8031
|
},
|
|
7945
8032
|
devDependencies: {
|
|
7946
8033
|
"@biomejs/biome": "^1.8.3",
|
|
7947
|
-
"@tscircuit/footprinter": "^0.0.
|
|
8034
|
+
"@tscircuit/footprinter": "^0.0.154",
|
|
7948
8035
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
7949
8036
|
"@tscircuit/layout": "^0.0.28",
|
|
7950
8037
|
"@tscircuit/log-soup": "^1.0.2",
|
|
@@ -7981,7 +8068,7 @@ var package_default = {
|
|
|
7981
8068
|
"@tscircuit/math-utils": "^0.0.14",
|
|
7982
8069
|
"@tscircuit/props": "^0.0.172",
|
|
7983
8070
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
7984
|
-
"circuit-json": "0.0.
|
|
8071
|
+
"circuit-json": "0.0.164",
|
|
7985
8072
|
"circuit-json-to-connectivity-map": "^0.0.20",
|
|
7986
8073
|
"css-select": "^5.1.0",
|
|
7987
8074
|
"format-si-unit": "^0.0.3",
|
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.391",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@biomejs/biome": "^1.8.3",
|
|
27
|
-
"@tscircuit/footprinter": "^0.0.
|
|
27
|
+
"@tscircuit/footprinter": "^0.0.154",
|
|
28
28
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
29
29
|
"@tscircuit/layout": "^0.0.28",
|
|
30
30
|
"@tscircuit/log-soup": "^1.0.2",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@tscircuit/math-utils": "^0.0.14",
|
|
62
62
|
"@tscircuit/props": "^0.0.172",
|
|
63
63
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
64
|
-
"circuit-json": "0.0.
|
|
64
|
+
"circuit-json": "0.0.164",
|
|
65
65
|
"circuit-json-to-connectivity-map": "^0.0.20",
|
|
66
66
|
"css-select": "^5.1.0",
|
|
67
67
|
"format-si-unit": "^0.0.3",
|