@tscircuit/core 0.0.1404 → 0.0.1406

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
@@ -319,6 +319,14 @@ type ReactSubtree = {
319
319
  component: NormalComponent;
320
320
  };
321
321
 
322
+ type VerticalPortSideConfiguration = {
323
+ direction?: "top-to-bottom" | "bottom-to-top";
324
+ pins: number[];
325
+ };
326
+ type HorizontalPortSideConfiguration = {
327
+ direction?: "left-to-right" | "right-to-left";
328
+ pins: number[];
329
+ };
322
330
  type SchematicBoxPortPositionWithMetadata = {
323
331
  trueIndex: number;
324
332
  pinNumber: number;
@@ -327,6 +335,26 @@ type SchematicBoxPortPositionWithMetadata = {
327
335
  x: number;
328
336
  y: number;
329
337
  };
338
+ type ExplicitPinMappingArrangement = {
339
+ leftSide?: VerticalPortSideConfiguration;
340
+ rightSide?: VerticalPortSideConfiguration;
341
+ topSide?: HorizontalPortSideConfiguration;
342
+ bottomSide?: HorizontalPortSideConfiguration;
343
+ };
344
+ /** @deprecated prefer SidePinCounts */
345
+ interface SideSizes {
346
+ leftSize?: number;
347
+ rightSize?: number;
348
+ topSize?: number;
349
+ bottomSize?: number;
350
+ }
351
+ interface SidePinCounts {
352
+ leftPinCount?: number;
353
+ rightPinCount?: number;
354
+ topPinCount?: number;
355
+ bottomPinCount?: number;
356
+ }
357
+ type PortArrangement = SideSizes | SidePinCounts | ExplicitPinMappingArrangement;
330
358
  interface SchematicBoxDimensions {
331
359
  pinCount: number;
332
360
  getPortPositionByPinNumber(pinNumber: number): SchematicBoxPortPositionWithMetadata | null;
@@ -2310,6 +2338,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
2310
2338
  * Extract pin labels from ports using existing Port logic
2311
2339
  */
2312
2340
  _getPinLabelsFromPorts(): Record<string, string>;
2341
+ _getImplicitSparseSchematicPortArrangement(pinCount: number): PortArrangement | undefined;
2313
2342
  _getSchematicBoxDimensions(): SchematicBoxDimensions | null;
2314
2343
  getFootprinterString(): string | null;
2315
2344
  doInitialCadModelRender(): void;
package/dist/index.js CHANGED
@@ -10980,7 +10980,6 @@ var createComponentsFromCircuitJson = ({
10980
10980
  };
10981
10981
 
10982
10982
  // lib/utils/filterPinLabels.ts
10983
- import { chipProps } from "@tscircuit/props";
10984
10983
  function filterPinLabels(pinLabels) {
10985
10984
  if (!pinLabels)
10986
10985
  return {
@@ -11010,18 +11009,8 @@ function filterPinLabels(pinLabels) {
11010
11009
  invalidPinLabelsMessages
11011
11010
  };
11012
11011
  }
11013
- function isValidPinLabel(pin, label) {
11014
- try {
11015
- const testProps = {
11016
- name: "test",
11017
- footprint: "test",
11018
- pinLabels: { [pin]: label }
11019
- };
11020
- const result = chipProps.safeParse(testProps);
11021
- return result.success;
11022
- } catch (error) {
11023
- return false;
11024
- }
11012
+ function isValidPinLabel(_pin, label) {
11013
+ return /^[A-Za-z0-9_]+$/.test(label);
11025
11014
  }
11026
11015
 
11027
11016
  // lib/utils/get-bounds-of-pcb-components.ts
@@ -11229,7 +11218,7 @@ var getAllDimensionsForSchematicBox = (params) => {
11229
11218
  currentDistanceFromEdge += pinStyle.topMargin;
11230
11219
  }
11231
11220
  orderedTruePorts.push({
11232
- trueIndex: truePinIndex,
11221
+ trueIndex: pinNumber - 1,
11233
11222
  pinNumber,
11234
11223
  side: "left",
11235
11224
  distanceFromOrthogonalEdge: currentDistanceFromEdge
@@ -11257,7 +11246,7 @@ var getAllDimensionsForSchematicBox = (params) => {
11257
11246
  currentDistanceFromEdge += pinStyle.leftMargin;
11258
11247
  }
11259
11248
  orderedTruePorts.push({
11260
- trueIndex: truePinIndex,
11249
+ trueIndex: pinNumber - 1,
11261
11250
  pinNumber,
11262
11251
  side: "bottom",
11263
11252
  distanceFromOrthogonalEdge: currentDistanceFromEdge
@@ -11285,7 +11274,7 @@ var getAllDimensionsForSchematicBox = (params) => {
11285
11274
  currentDistanceFromEdge += pinStyle.bottomMargin;
11286
11275
  }
11287
11276
  orderedTruePorts.push({
11288
- trueIndex: truePinIndex,
11277
+ trueIndex: pinNumber - 1,
11289
11278
  pinNumber,
11290
11279
  side: "right",
11291
11280
  distanceFromOrthogonalEdge: currentDistanceFromEdge
@@ -11313,7 +11302,7 @@ var getAllDimensionsForSchematicBox = (params) => {
11313
11302
  currentDistanceFromEdge += pinStyle.rightMargin;
11314
11303
  }
11315
11304
  orderedTruePorts.push({
11316
- trueIndex: truePinIndex,
11305
+ trueIndex: pinNumber - 1,
11317
11306
  pinNumber,
11318
11307
  side: "top",
11319
11308
  distanceFromOrthogonalEdge: currentDistanceFromEdge
@@ -13292,6 +13281,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
13292
13281
  const requiredPinCount = opts.pinCount ?? this._getPrimaryPinCount() ?? 0;
13293
13282
  for (let pn = 1; pn <= requiredPinCount; pn++) {
13294
13283
  if (portsToCreate.find((p) => p._parsedProps.pinNumber === pn)) continue;
13284
+ if (!schPortArrangement && pinLabelsFromProps && !Array.isArray(propsPinLabels) && !pinLabelsFromProps[`pin${pn}`]) {
13285
+ continue;
13286
+ }
13295
13287
  if (!schPortArrangement) {
13296
13288
  portsToCreate.push(
13297
13289
  new Port({
@@ -14150,6 +14142,24 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
14150
14142
  }
14151
14143
  return pinLabels;
14152
14144
  }
14145
+ _getImplicitSparseSchematicPortArrangement(pinCount) {
14146
+ const pinNumbers = Array.from(
14147
+ new Set(
14148
+ this._getAllPortsFromChildren().filter((port) => port._isPrimaryPort).map((port) => port._parsedProps.pinNumber).filter((pinNumber) => pinNumber !== void 0)
14149
+ )
14150
+ ).sort((a, b) => a - b);
14151
+ if (pinNumbers.length !== pinCount) return void 0;
14152
+ const hasSparsePinNumbers = pinNumbers.some(
14153
+ (pinNumber, index) => pinNumber !== index + 1
14154
+ );
14155
+ if (!hasSparsePinNumbers) return void 0;
14156
+ const rightSize = Math.floor(pinCount / 2);
14157
+ const leftSize = pinCount - rightSize;
14158
+ return {
14159
+ leftSide: { pins: pinNumbers.slice(0, leftSize) },
14160
+ rightSide: { pins: pinNumbers.slice(leftSize) }
14161
+ };
14162
+ }
14153
14163
  _getSchematicBoxDimensions() {
14154
14164
  if (this.getSchematicSymbol()) return null;
14155
14165
  if (!this.config.shouldRenderAsSchematicBox && !this._parsedProps?.showAsSchematicBox) {
@@ -14163,6 +14173,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
14163
14173
  ...pinLabelsFromPorts,
14164
14174
  ...props.pinLabels
14165
14175
  };
14176
+ const schPortArrangement = this._getSchematicPortArrangement() ?? this._getImplicitSparseSchematicPortArrangement(pinCount);
14166
14177
  const dimensions = getAllDimensionsForSchematicBox({
14167
14178
  schWidth: props.schWidth,
14168
14179
  schHeight: props.schHeight,
@@ -14172,7 +14183,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
14172
14183
  allPinLabels
14173
14184
  ),
14174
14185
  pinCount,
14175
- schPortArrangement: this._getSchematicPortArrangement(),
14186
+ schPortArrangement,
14176
14187
  pinLabels: allPinLabels
14177
14188
  });
14178
14189
  return dimensions;
@@ -14858,7 +14869,7 @@ function inflateSourceCapacitor(sourceElm, inflatorContext) {
14858
14869
  }
14859
14870
 
14860
14871
  // lib/components/normal-components/Chip.ts
14861
- import { chipProps as chipProps2 } from "@tscircuit/props";
14872
+ import { chipProps } from "@tscircuit/props";
14862
14873
  import { pcb_component_invalid_layer_error as pcb_component_invalid_layer_error2 } from "circuit-json";
14863
14874
  var Chip = class extends NormalComponent3 {
14864
14875
  schematicBoxDimensions = null;
@@ -14868,7 +14879,7 @@ var Chip = class extends NormalComponent3 {
14868
14879
  get config() {
14869
14880
  return {
14870
14881
  componentName: "Chip",
14871
- zodProps: chipProps2,
14882
+ zodProps: chipProps,
14872
14883
  shouldRenderAsSchematicBox: true
14873
14884
  };
14874
14885
  }
@@ -19983,7 +19994,16 @@ function createSchematicTraceSolverInputProblem(group) {
19983
19994
  pins.push({
19984
19995
  pinId,
19985
19996
  x: schematicPort.center.x,
19986
- y: schematicPort.center.y
19997
+ y: schematicPort.center.y,
19998
+ // Pass the port's true facing direction (known from the schematic
19999
+ // symbol). The chip box handed to the solver is text-inclusive, so for
20000
+ // small parts with a large reference designator the pins sit inside the
20001
+ // box. The solver snaps such pins to the box edge along this facing
20002
+ // direction (rather than guessing from geometry, which would pick the
20003
+ // wrong edge for a resistor whose ref text widened the box).
20004
+ _facingDirection: convertFacingDirectionToElbowDirection(
20005
+ schematicPort.facing_direction ?? null
20006
+ )
19987
20007
  });
19988
20008
  }
19989
20009
  let sectionId;
@@ -25318,7 +25338,7 @@ import { identity as identity5 } from "transformation-matrix";
25318
25338
  var package_default = {
25319
25339
  name: "@tscircuit/core",
25320
25340
  type: "module",
25321
- version: "0.0.1403",
25341
+ version: "0.0.1405",
25322
25342
  types: "dist/index.d.ts",
25323
25343
  main: "dist/index.js",
25324
25344
  module: "dist/index.js",
@@ -25369,7 +25389,7 @@ var package_default = {
25369
25389
  "@tscircuit/ngspice-spice-engine": "^0.0.18",
25370
25390
  "@tscircuit/props": "^0.0.567",
25371
25391
  "@tscircuit/schematic-match-adapt": "^0.0.18",
25372
- "@tscircuit/schematic-trace-solver": "^0.0.87",
25392
+ "@tscircuit/schematic-trace-solver": "^0.0.91",
25373
25393
  "@tscircuit/solver-utils": "^0.0.16",
25374
25394
  "@tscircuit/soup-util": "^0.0.41",
25375
25395
  "@types/bun": "^1.2.16",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1404",
4
+ "version": "0.0.1406",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  "@tscircuit/ngspice-spice-engine": "^0.0.18",
53
53
  "@tscircuit/props": "^0.0.567",
54
54
  "@tscircuit/schematic-match-adapt": "^0.0.18",
55
- "@tscircuit/schematic-trace-solver": "^0.0.87",
55
+ "@tscircuit/schematic-trace-solver": "^0.0.91",
56
56
  "@tscircuit/solver-utils": "^0.0.16",
57
57
  "@tscircuit/soup-util": "^0.0.41",
58
58
  "@types/bun": "^1.2.16",