@tscircuit/core 0.0.1137 → 0.0.1139
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.js +106 -67
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18320,6 +18320,107 @@ function inflateSourcePort(sourcePort, inflatorContext) {
|
|
|
18320
18320
|
}
|
|
18321
18321
|
}
|
|
18322
18322
|
|
|
18323
|
+
// lib/components/normal-components/PushButton.ts
|
|
18324
|
+
import { pushButtonProps } from "@tscircuit/props";
|
|
18325
|
+
import { symbols as symbols3 } from "schematic-symbols";
|
|
18326
|
+
var PushButton = class extends NormalComponent3 {
|
|
18327
|
+
get config() {
|
|
18328
|
+
return {
|
|
18329
|
+
componentName: "PushButton",
|
|
18330
|
+
schematicSymbolName: this.props.symbolName ?? "push_button_normally_open_momentary",
|
|
18331
|
+
zodProps: pushButtonProps,
|
|
18332
|
+
sourceFtype: FTYPE.simple_push_button
|
|
18333
|
+
};
|
|
18334
|
+
}
|
|
18335
|
+
get defaultInternallyConnectedPinNames() {
|
|
18336
|
+
return [];
|
|
18337
|
+
}
|
|
18338
|
+
initPorts() {
|
|
18339
|
+
super.initPorts({
|
|
18340
|
+
pinCount: 2,
|
|
18341
|
+
ignoreSymbolPorts: true
|
|
18342
|
+
});
|
|
18343
|
+
const symbol = symbols3[this._getSchematicSymbolNameOrThrow()];
|
|
18344
|
+
const symPort1 = symbol.ports.find((p) => p.labels.includes("1"));
|
|
18345
|
+
const symPort2 = symbol.ports.find((p) => p.labels.includes("2"));
|
|
18346
|
+
const ports = this.selectAll("port");
|
|
18347
|
+
const pin1Port = ports.find((p) => p.props.pinNumber === 1);
|
|
18348
|
+
const pin2Port = ports.find((p) => p.props.pinNumber === 2);
|
|
18349
|
+
const pin3Port = ports.find((p) => p.props.pinNumber === 3);
|
|
18350
|
+
const pin4Port = ports.find((p) => p.props.pinNumber === 4);
|
|
18351
|
+
const { internallyConnectedPins } = this._parsedProps;
|
|
18352
|
+
pin1Port.schematicSymbolPortDef = symPort1;
|
|
18353
|
+
if (!internallyConnectedPins || internallyConnectedPins.length === 0) {
|
|
18354
|
+
pin2Port.schematicSymbolPortDef = symPort2;
|
|
18355
|
+
}
|
|
18356
|
+
for (const [pn, port] of [
|
|
18357
|
+
[2, pin2Port],
|
|
18358
|
+
[3, pin3Port],
|
|
18359
|
+
[4, pin4Port]
|
|
18360
|
+
]) {
|
|
18361
|
+
const internallyConnectedRow = internallyConnectedPins?.find(
|
|
18362
|
+
([pin1, pin2]) => pin1 === `pin${pn}` || pin2 === `pin${pn}`
|
|
18363
|
+
);
|
|
18364
|
+
if (!internallyConnectedRow) {
|
|
18365
|
+
port.schematicSymbolPortDef = symPort2;
|
|
18366
|
+
break;
|
|
18367
|
+
}
|
|
18368
|
+
const internallyConnectedTo = internallyConnectedRow?.[0] === `pin${pn}` ? internallyConnectedRow[1] : internallyConnectedRow?.[0];
|
|
18369
|
+
if (internallyConnectedTo === "pin1") {
|
|
18370
|
+
continue;
|
|
18371
|
+
}
|
|
18372
|
+
port.schematicSymbolPortDef = symPort2;
|
|
18373
|
+
}
|
|
18374
|
+
}
|
|
18375
|
+
doInitialSourceRender() {
|
|
18376
|
+
const { db } = this.root;
|
|
18377
|
+
const { _parsedProps: props } = this;
|
|
18378
|
+
const source_component = db.source_component.insert({
|
|
18379
|
+
name: this.name,
|
|
18380
|
+
ftype: FTYPE.simple_push_button,
|
|
18381
|
+
supplier_part_numbers: props.supplierPartNumbers,
|
|
18382
|
+
are_pins_interchangeable: true,
|
|
18383
|
+
display_name: props.displayName
|
|
18384
|
+
});
|
|
18385
|
+
this.source_component_id = source_component.source_component_id;
|
|
18386
|
+
}
|
|
18387
|
+
};
|
|
18388
|
+
|
|
18389
|
+
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourcePushButton.ts
|
|
18390
|
+
function inflateSourcePushButton(sourceElm, inflatorContext) {
|
|
18391
|
+
const { injectionDb, subcircuit, groupsMap } = inflatorContext;
|
|
18392
|
+
const pcbElm = injectionDb.pcb_component.getWhere({
|
|
18393
|
+
source_component_id: sourceElm.source_component_id
|
|
18394
|
+
});
|
|
18395
|
+
const cadElm = injectionDb.cad_component.getWhere({
|
|
18396
|
+
source_component_id: sourceElm.source_component_id
|
|
18397
|
+
});
|
|
18398
|
+
const pushButton = new PushButton({
|
|
18399
|
+
name: sourceElm.name,
|
|
18400
|
+
layer: pcbElm?.layer,
|
|
18401
|
+
pcbX: pcbElm?.center?.x,
|
|
18402
|
+
pcbY: pcbElm?.center?.y,
|
|
18403
|
+
pcbRotation: pcbElm?.rotation,
|
|
18404
|
+
doNotPlace: pcbElm?.do_not_place,
|
|
18405
|
+
obstructsWithinBounds: pcbElm?.obstructs_within_bounds
|
|
18406
|
+
});
|
|
18407
|
+
if (pcbElm) {
|
|
18408
|
+
const footprint = inflateFootprintComponent(pcbElm, {
|
|
18409
|
+
...inflatorContext,
|
|
18410
|
+
normalComponent: pushButton
|
|
18411
|
+
});
|
|
18412
|
+
if (footprint) {
|
|
18413
|
+
pushButton.add(footprint);
|
|
18414
|
+
}
|
|
18415
|
+
}
|
|
18416
|
+
if (sourceElm.source_group_id && groupsMap?.has(sourceElm.source_group_id)) {
|
|
18417
|
+
const group = groupsMap.get(sourceElm.source_group_id);
|
|
18418
|
+
group.add(pushButton);
|
|
18419
|
+
} else {
|
|
18420
|
+
subcircuit.add(pushButton);
|
|
18421
|
+
}
|
|
18422
|
+
}
|
|
18423
|
+
|
|
18323
18424
|
// lib/components/normal-components/Resistor.ts
|
|
18324
18425
|
import { resistorProps } from "@tscircuit/props";
|
|
18325
18426
|
import { formatSiUnit as formatSiUnit3 } from "format-si-unit";
|
|
@@ -18718,6 +18819,9 @@ var inflateCircuitJson = (target, circuitJson, children) => {
|
|
|
18718
18819
|
case "simple_transistor":
|
|
18719
18820
|
inflateSourceTransistor(sourceComponent, inflationCtx);
|
|
18720
18821
|
break;
|
|
18822
|
+
case "simple_push_button":
|
|
18823
|
+
inflateSourcePushButton(sourceComponent, inflationCtx);
|
|
18824
|
+
break;
|
|
18721
18825
|
default:
|
|
18722
18826
|
throw new Error(
|
|
18723
18827
|
`No inflator implemented for source component ftype: "${sourceComponent.ftype}"`
|
|
@@ -18745,7 +18849,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
18745
18849
|
var package_default = {
|
|
18746
18850
|
name: "@tscircuit/core",
|
|
18747
18851
|
type: "module",
|
|
18748
|
-
version: "0.0.
|
|
18852
|
+
version: "0.0.1138",
|
|
18749
18853
|
types: "dist/index.d.ts",
|
|
18750
18854
|
main: "dist/index.js",
|
|
18751
18855
|
module: "dist/index.js",
|
|
@@ -22739,6 +22843,7 @@ var Connector = class extends Chip {
|
|
|
22739
22843
|
if (!fetchPartCircuitJson) return;
|
|
22740
22844
|
this._hasStartedFootprintUrlLoad = true;
|
|
22741
22845
|
const sourceComponentForQuery = {
|
|
22846
|
+
type: "source_component",
|
|
22742
22847
|
ftype: "simple_connector",
|
|
22743
22848
|
name: this.name,
|
|
22744
22849
|
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
@@ -23007,72 +23112,6 @@ var Potentiometer = class extends NormalComponent3 {
|
|
|
23007
23112
|
}
|
|
23008
23113
|
};
|
|
23009
23114
|
|
|
23010
|
-
// lib/components/normal-components/PushButton.ts
|
|
23011
|
-
import { pushButtonProps } from "@tscircuit/props";
|
|
23012
|
-
import { symbols as symbols3 } from "schematic-symbols";
|
|
23013
|
-
var PushButton = class extends NormalComponent3 {
|
|
23014
|
-
get config() {
|
|
23015
|
-
return {
|
|
23016
|
-
componentName: "PushButton",
|
|
23017
|
-
schematicSymbolName: this.props.symbolName ?? "push_button_normally_open_momentary",
|
|
23018
|
-
zodProps: pushButtonProps,
|
|
23019
|
-
sourceFtype: FTYPE.simple_push_button
|
|
23020
|
-
};
|
|
23021
|
-
}
|
|
23022
|
-
get defaultInternallyConnectedPinNames() {
|
|
23023
|
-
return [];
|
|
23024
|
-
}
|
|
23025
|
-
initPorts() {
|
|
23026
|
-
super.initPorts({
|
|
23027
|
-
pinCount: 2,
|
|
23028
|
-
ignoreSymbolPorts: true
|
|
23029
|
-
});
|
|
23030
|
-
const symbol = symbols3[this._getSchematicSymbolNameOrThrow()];
|
|
23031
|
-
const symPort1 = symbol.ports.find((p) => p.labels.includes("1"));
|
|
23032
|
-
const symPort2 = symbol.ports.find((p) => p.labels.includes("2"));
|
|
23033
|
-
const ports = this.selectAll("port");
|
|
23034
|
-
const pin1Port = ports.find((p) => p.props.pinNumber === 1);
|
|
23035
|
-
const pin2Port = ports.find((p) => p.props.pinNumber === 2);
|
|
23036
|
-
const pin3Port = ports.find((p) => p.props.pinNumber === 3);
|
|
23037
|
-
const pin4Port = ports.find((p) => p.props.pinNumber === 4);
|
|
23038
|
-
const { internallyConnectedPins } = this._parsedProps;
|
|
23039
|
-
pin1Port.schematicSymbolPortDef = symPort1;
|
|
23040
|
-
if (!internallyConnectedPins || internallyConnectedPins.length === 0) {
|
|
23041
|
-
pin2Port.schematicSymbolPortDef = symPort2;
|
|
23042
|
-
}
|
|
23043
|
-
for (const [pn, port] of [
|
|
23044
|
-
[2, pin2Port],
|
|
23045
|
-
[3, pin3Port],
|
|
23046
|
-
[4, pin4Port]
|
|
23047
|
-
]) {
|
|
23048
|
-
const internallyConnectedRow = internallyConnectedPins?.find(
|
|
23049
|
-
([pin1, pin2]) => pin1 === `pin${pn}` || pin2 === `pin${pn}`
|
|
23050
|
-
);
|
|
23051
|
-
if (!internallyConnectedRow) {
|
|
23052
|
-
port.schematicSymbolPortDef = symPort2;
|
|
23053
|
-
break;
|
|
23054
|
-
}
|
|
23055
|
-
const internallyConnectedTo = internallyConnectedRow?.[0] === `pin${pn}` ? internallyConnectedRow[1] : internallyConnectedRow?.[0];
|
|
23056
|
-
if (internallyConnectedTo === "pin1") {
|
|
23057
|
-
continue;
|
|
23058
|
-
}
|
|
23059
|
-
port.schematicSymbolPortDef = symPort2;
|
|
23060
|
-
}
|
|
23061
|
-
}
|
|
23062
|
-
doInitialSourceRender() {
|
|
23063
|
-
const { db } = this.root;
|
|
23064
|
-
const { _parsedProps: props } = this;
|
|
23065
|
-
const source_component = db.source_component.insert({
|
|
23066
|
-
name: this.name,
|
|
23067
|
-
ftype: FTYPE.simple_push_button,
|
|
23068
|
-
supplier_part_numbers: props.supplierPartNumbers,
|
|
23069
|
-
are_pins_interchangeable: true,
|
|
23070
|
-
display_name: props.displayName
|
|
23071
|
-
});
|
|
23072
|
-
this.source_component_id = source_component.source_component_id;
|
|
23073
|
-
}
|
|
23074
|
-
};
|
|
23075
|
-
|
|
23076
23115
|
// lib/components/normal-components/Crystal.ts
|
|
23077
23116
|
import { crystalProps } from "@tscircuit/props";
|
|
23078
23117
|
import { formatSiUnit as formatSiUnit9 } from "format-si-unit";
|