@tscircuit/core 0.0.612 → 0.0.614

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 CHANGED
@@ -967,6 +967,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
967
967
  initPorts(opts?: {
968
968
  additionalAliases?: Record<`pin${number}`, string[]>;
969
969
  pinCount?: number;
970
+ ignoreSymbolPorts?: boolean;
970
971
  }): void;
971
972
  _getImpliedFootprintString(): string | null;
972
973
  _isFootprintUrl(s: string): boolean;
package/dist/index.js CHANGED
@@ -314,7 +314,24 @@ var InvalidProps = class extends Error {
314
314
  const propsWithError = Object.keys(formattedError).filter(
315
315
  (k) => k !== "_errors"
316
316
  );
317
+ const invalidPinLabelMessages = [];
318
+ const pinLabels = originalProps.pinLabels;
319
+ if (pinLabels) {
320
+ for (const [pin, labelOrLabels] of Object.entries(pinLabels)) {
321
+ const labels = Array.isArray(labelOrLabels) ? labelOrLabels : [labelOrLabels];
322
+ for (const label of labels) {
323
+ if (typeof label === "string" && (label.startsWith(" ") || label.endsWith(" "))) {
324
+ invalidPinLabelMessages.push(
325
+ `pinLabels.${pin} ("${label}" has leading or trailing spaces)`
326
+ );
327
+ }
328
+ }
329
+ }
330
+ }
317
331
  const propMessage = propsWithError.map((k) => {
332
+ if (k === "pinLabels" && invalidPinLabelMessages.length > 0) {
333
+ return invalidPinLabelMessages.join(", ");
334
+ }
318
335
  if (formattedError[k]._errors[0]) {
319
336
  return `${k} (${formattedError[k]._errors[0]})`;
320
337
  }
@@ -6175,7 +6192,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
6175
6192
  }
6176
6193
  }
6177
6194
  }
6178
- if (config.schematicSymbolName) {
6195
+ if (config.schematicSymbolName && !opts.ignoreSymbolPorts) {
6179
6196
  const sym = symbols2[this._getSchematicSymbolNameOrThrow()];
6180
6197
  if (!sym) return;
6181
6198
  for (const symPort of sym.ports) {
@@ -6211,9 +6228,18 @@ var NormalComponent = class extends PrimitiveComponent2 {
6211
6228
  }
6212
6229
  }
6213
6230
  }
6214
- for (let pn = 1; pn <= (opts.pinCount ?? this._getPinCount()); pn++) {
6215
- if (!schPortArrangement) continue;
6231
+ const requiredPinCount = opts.pinCount ?? this._getPinCount() ?? 0;
6232
+ for (let pn = 1; pn <= requiredPinCount; pn++) {
6216
6233
  if (portsToCreate.find((p) => p._parsedProps.pinNumber === pn)) continue;
6234
+ if (!schPortArrangement) {
6235
+ portsToCreate.push(
6236
+ new Port({
6237
+ pinNumber: pn,
6238
+ aliases: opts.additionalAliases?.[`pin${pn}`] ?? []
6239
+ })
6240
+ );
6241
+ continue;
6242
+ }
6217
6243
  let explicitlyListedPinNumbersInSchPortArrangement = [
6218
6244
  ...schPortArrangement.leftSide?.pins ?? [],
6219
6245
  ...schPortArrangement.rightSide?.pins ?? [],
@@ -10900,6 +10926,7 @@ var Potentiometer = class extends NormalComponent {
10900
10926
 
10901
10927
  // lib/components/normal-components/PushButton.ts
10902
10928
  import { pushButtonProps } from "@tscircuit/props";
10929
+ import { symbols as symbols3 } from "schematic-symbols";
10903
10930
  var PushButton = class extends NormalComponent {
10904
10931
  get config() {
10905
10932
  return {
@@ -10910,19 +10937,44 @@ var PushButton = class extends NormalComponent {
10910
10937
  };
10911
10938
  }
10912
10939
  get defaultInternallyConnectedPinNames() {
10913
- return [
10914
- ["pin1", "pin4"],
10915
- ["pin2", "pin3"]
10916
- ];
10940
+ return [];
10917
10941
  }
10918
10942
  initPorts() {
10919
10943
  super.initPorts({
10920
- pinCount: 4,
10921
- additionalAliases: {
10922
- pin1: ["side1"],
10923
- pin3: ["side2"]
10924
- }
10944
+ pinCount: 2,
10945
+ ignoreSymbolPorts: true
10925
10946
  });
10947
+ const symbol = symbols3[this._getSchematicSymbolNameOrThrow()];
10948
+ const symPort1 = symbol.ports.find((p) => p.labels.includes("1"));
10949
+ const symPort2 = symbol.ports.find((p) => p.labels.includes("2"));
10950
+ const ports = this.selectAll("port");
10951
+ const pin1Port = ports.find((p) => p.props.pinNumber === 1);
10952
+ const pin2Port = ports.find((p) => p.props.pinNumber === 2);
10953
+ const pin3Port = ports.find((p) => p.props.pinNumber === 3);
10954
+ const pin4Port = ports.find((p) => p.props.pinNumber === 4);
10955
+ const { internallyConnectedPins } = this._parsedProps;
10956
+ pin1Port.schematicSymbolPortDef = symPort1;
10957
+ if (!internallyConnectedPins || internallyConnectedPins.length === 0) {
10958
+ pin2Port.schematicSymbolPortDef = symPort2;
10959
+ }
10960
+ for (const [pn, port] of [
10961
+ [2, pin2Port],
10962
+ [3, pin3Port],
10963
+ [4, pin4Port]
10964
+ ]) {
10965
+ const internallyConnectedRow = internallyConnectedPins?.find(
10966
+ ([pin1, pin2]) => pin1 === `pin${pn}` || pin2 === `pin${pn}`
10967
+ );
10968
+ if (!internallyConnectedRow) {
10969
+ port.schematicSymbolPortDef = symPort2;
10970
+ break;
10971
+ }
10972
+ const internallyConnectedTo = internallyConnectedRow?.[0] === `pin${pn}` ? internallyConnectedRow[1] : internallyConnectedRow?.[0];
10973
+ if (internallyConnectedTo === "pin1") {
10974
+ continue;
10975
+ }
10976
+ port.schematicSymbolPortDef = symPort2;
10977
+ }
10926
10978
  }
10927
10979
  doInitialSourceRender() {
10928
10980
  const { db } = this.root;
@@ -11595,7 +11647,7 @@ import { identity as identity5 } from "transformation-matrix";
11595
11647
  var package_default = {
11596
11648
  name: "@tscircuit/core",
11597
11649
  type: "module",
11598
- version: "0.0.611",
11650
+ version: "0.0.613",
11599
11651
  types: "dist/index.d.ts",
11600
11652
  main: "dist/index.js",
11601
11653
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.612",
4
+ "version": "0.0.614",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",