@tscircuit/core 0.0.1138 → 0.0.1140

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.
Files changed (2) hide show
  1. package/dist/index.js +106 -68
  2. package/package.json +2 -2
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.1137",
18852
+ version: "0.0.1139",
18749
18853
  types: "dist/index.d.ts",
18750
18854
  main: "dist/index.js",
18751
18855
  module: "dist/index.js",
@@ -18782,7 +18886,7 @@ var package_default = {
18782
18886
  "@tscircuit/circuit-json-util": "^0.0.90",
18783
18887
  "@tscircuit/common": "^0.0.20",
18784
18888
  "@tscircuit/copper-pour-solver": "^0.0.20",
18785
- "@tscircuit/footprinter": "^0.0.333",
18889
+ "@tscircuit/footprinter": "^0.0.336",
18786
18890
  "@tscircuit/infer-cable-insertion-point": "^0.0.2",
18787
18891
  "@tscircuit/infgrid-ijump-astar": "^0.0.35",
18788
18892
  "@tscircuit/log-soup": "^1.0.2",
@@ -23008,72 +23112,6 @@ var Potentiometer = class extends NormalComponent3 {
23008
23112
  }
23009
23113
  };
23010
23114
 
23011
- // lib/components/normal-components/PushButton.ts
23012
- import { pushButtonProps } from "@tscircuit/props";
23013
- import { symbols as symbols3 } from "schematic-symbols";
23014
- var PushButton = class extends NormalComponent3 {
23015
- get config() {
23016
- return {
23017
- componentName: "PushButton",
23018
- schematicSymbolName: this.props.symbolName ?? "push_button_normally_open_momentary",
23019
- zodProps: pushButtonProps,
23020
- sourceFtype: FTYPE.simple_push_button
23021
- };
23022
- }
23023
- get defaultInternallyConnectedPinNames() {
23024
- return [];
23025
- }
23026
- initPorts() {
23027
- super.initPorts({
23028
- pinCount: 2,
23029
- ignoreSymbolPorts: true
23030
- });
23031
- const symbol = symbols3[this._getSchematicSymbolNameOrThrow()];
23032
- const symPort1 = symbol.ports.find((p) => p.labels.includes("1"));
23033
- const symPort2 = symbol.ports.find((p) => p.labels.includes("2"));
23034
- const ports = this.selectAll("port");
23035
- const pin1Port = ports.find((p) => p.props.pinNumber === 1);
23036
- const pin2Port = ports.find((p) => p.props.pinNumber === 2);
23037
- const pin3Port = ports.find((p) => p.props.pinNumber === 3);
23038
- const pin4Port = ports.find((p) => p.props.pinNumber === 4);
23039
- const { internallyConnectedPins } = this._parsedProps;
23040
- pin1Port.schematicSymbolPortDef = symPort1;
23041
- if (!internallyConnectedPins || internallyConnectedPins.length === 0) {
23042
- pin2Port.schematicSymbolPortDef = symPort2;
23043
- }
23044
- for (const [pn, port] of [
23045
- [2, pin2Port],
23046
- [3, pin3Port],
23047
- [4, pin4Port]
23048
- ]) {
23049
- const internallyConnectedRow = internallyConnectedPins?.find(
23050
- ([pin1, pin2]) => pin1 === `pin${pn}` || pin2 === `pin${pn}`
23051
- );
23052
- if (!internallyConnectedRow) {
23053
- port.schematicSymbolPortDef = symPort2;
23054
- break;
23055
- }
23056
- const internallyConnectedTo = internallyConnectedRow?.[0] === `pin${pn}` ? internallyConnectedRow[1] : internallyConnectedRow?.[0];
23057
- if (internallyConnectedTo === "pin1") {
23058
- continue;
23059
- }
23060
- port.schematicSymbolPortDef = symPort2;
23061
- }
23062
- }
23063
- doInitialSourceRender() {
23064
- const { db } = this.root;
23065
- const { _parsedProps: props } = this;
23066
- const source_component = db.source_component.insert({
23067
- name: this.name,
23068
- ftype: FTYPE.simple_push_button,
23069
- supplier_part_numbers: props.supplierPartNumbers,
23070
- are_pins_interchangeable: true,
23071
- display_name: props.displayName
23072
- });
23073
- this.source_component_id = source_component.source_component_id;
23074
- }
23075
- };
23076
-
23077
23115
  // lib/components/normal-components/Crystal.ts
23078
23116
  import { crystalProps } from "@tscircuit/props";
23079
23117
  import { formatSiUnit as formatSiUnit9 } from "format-si-unit";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1138",
4
+ "version": "0.0.1140",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -38,7 +38,7 @@
38
38
  "@tscircuit/circuit-json-util": "^0.0.90",
39
39
  "@tscircuit/common": "^0.0.20",
40
40
  "@tscircuit/copper-pour-solver": "^0.0.20",
41
- "@tscircuit/footprinter": "^0.0.333",
41
+ "@tscircuit/footprinter": "^0.0.336",
42
42
  "@tscircuit/infer-cable-insertion-point": "^0.0.2",
43
43
  "@tscircuit/infgrid-ijump-astar": "^0.0.35",
44
44
  "@tscircuit/log-soup": "^1.0.2",