@tscircuit/core 0.0.250 → 0.0.252

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
@@ -644,12 +644,12 @@ declare const portProps: z.ZodObject<{
644
644
  pinNumber: z.ZodOptional<z.ZodNumber>;
645
645
  aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
646
646
  }, "strip", z.ZodTypeAny, {
647
- name?: string | undefined;
648
647
  pinNumber?: number | undefined;
648
+ name?: string | undefined;
649
649
  aliases?: string[] | undefined;
650
650
  }, {
651
- name?: string | undefined;
652
651
  pinNumber?: number | undefined;
652
+ name?: string | undefined;
653
653
  aliases?: string[] | undefined;
654
654
  }>;
655
655
  declare class Port extends PrimitiveComponent<typeof portProps> {
@@ -667,12 +667,12 @@ declare class Port extends PrimitiveComponent<typeof portProps> {
667
667
  pinNumber: z.ZodOptional<z.ZodNumber>;
668
668
  aliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
669
669
  }, "strip", z.ZodTypeAny, {
670
- name?: string | undefined;
671
670
  pinNumber?: number | undefined;
671
+ name?: string | undefined;
672
672
  aliases?: string[] | undefined;
673
673
  }, {
674
- name?: string | undefined;
675
674
  pinNumber?: number | undefined;
675
+ name?: string | undefined;
676
676
  aliases?: string[] | undefined;
677
677
  }>;
678
678
  };
@@ -2098,6 +2098,7 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
2098
2098
  schPinSpacing: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
2099
2099
  schWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
2100
2100
  schHeight: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
2101
+ noSchematicRepresentation: zod.ZodOptional<zod.ZodBoolean>;
2101
2102
  }>, "strip", zod.ZodTypeAny, {
2102
2103
  name: string;
2103
2104
  pcbX?: number | undefined;
@@ -2202,6 +2203,7 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
2202
2203
  schPinSpacing?: number | undefined;
2203
2204
  schWidth?: number | undefined;
2204
2205
  schHeight?: number | undefined;
2206
+ noSchematicRepresentation?: boolean | undefined;
2205
2207
  }, {
2206
2208
  name: string;
2207
2209
  pcbX?: string | number | undefined;
@@ -2308,9 +2310,11 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
2308
2310
  schPinSpacing?: string | number | undefined;
2309
2311
  schWidth?: string | number | undefined;
2310
2312
  schHeight?: string | number | undefined;
2313
+ noSchematicRepresentation?: boolean | undefined;
2311
2314
  }>;
2312
2315
  shouldRenderAsSchematicBox: boolean;
2313
2316
  };
2317
+ doInitialSchematicComponentRender(): void;
2314
2318
  doInitialSourceRender(): void;
2315
2319
  doInitialPcbComponentRender(): void;
2316
2320
  }
package/dist/index.js CHANGED
@@ -410,11 +410,47 @@ var createInstanceFromReactElement = (reactElm) => {
410
410
  // lib/soup/underscorifyPinStyles.ts
411
411
  import "circuit-json";
412
412
  import "zod";
413
- var underscorifyPinStyles = (pinStyles) => {
413
+
414
+ // lib/utils/schematic/parsePinNumberFromLabelsOrThrow.ts
415
+ var parsePinNumberFromLabelsOrThrow = (pinNumberOrLabel, pinLabels) => {
416
+ if (typeof pinNumberOrLabel === "number") {
417
+ return pinNumberOrLabel;
418
+ }
419
+ if (pinNumberOrLabel.startsWith("pin")) {
420
+ const pinNumber = Number(pinNumberOrLabel.slice(3));
421
+ return pinNumber;
422
+ }
423
+ if (!pinLabels) {
424
+ throw new Error(
425
+ `No pin labels provided and pin number or label is not a number: "${pinNumberOrLabel}"`
426
+ );
427
+ }
428
+ for (const pinNumberKey in pinLabels) {
429
+ const aliases = Array.isArray(pinLabels[pinNumberKey]) ? pinLabels[pinNumberKey] : [pinLabels[pinNumberKey]];
430
+ if (aliases.includes(pinNumberOrLabel)) {
431
+ return Number(pinNumberKey.replace("pin", ""));
432
+ }
433
+ }
434
+ throw new Error(
435
+ `No pin labels provided and pin number or label is not a number: "${pinNumberOrLabel}"`
436
+ );
437
+ };
438
+
439
+ // lib/soup/underscorifyPinStyles.ts
440
+ var underscorifyPinStyles = (pinStyles, pinLabels) => {
414
441
  if (!pinStyles) return void 0;
415
442
  const underscorePinStyles = {};
416
- for (const [pinName, pinStyle] of Object.entries(pinStyles)) {
417
- underscorePinStyles[pinName] = {
443
+ const mergedStyles = {};
444
+ for (const [pinNameOrLabel, pinStyle] of Object.entries(pinStyles)) {
445
+ const pinNumber = parsePinNumberFromLabelsOrThrow(pinNameOrLabel, pinLabels);
446
+ mergedStyles[pinNumber] = {
447
+ ...mergedStyles[pinNumber],
448
+ ...pinStyle
449
+ };
450
+ }
451
+ for (const [pinNumber, pinStyle] of Object.entries(mergedStyles)) {
452
+ const pinKey = `pin${pinNumber}`;
453
+ underscorePinStyles[pinKey] = {
418
454
  bottom_margin: pinStyle.bottomMargin,
419
455
  left_margin: pinStyle.leftMargin,
420
456
  right_margin: pinStyle.rightMargin,
@@ -2130,31 +2166,6 @@ var getSizeOfSidesFromPortArrangement = (pa) => {
2130
2166
  return { leftSize, rightSize, topSize, bottomSize };
2131
2167
  };
2132
2168
 
2133
- // lib/utils/schematic/parsePinNumberFromLabelsOrThrow.ts
2134
- var parsePinNumberFromLabelsOrThrow = (pinNumberOrLabel, pinLabels) => {
2135
- if (typeof pinNumberOrLabel === "number") {
2136
- return pinNumberOrLabel;
2137
- }
2138
- if (pinNumberOrLabel.startsWith("pin")) {
2139
- const pinNumber = Number(pinNumberOrLabel.slice(3));
2140
- return pinNumber;
2141
- }
2142
- if (!pinLabels) {
2143
- throw new Error(
2144
- `No pin labels provided and pin number or label is not a number: "${pinNumberOrLabel}"`
2145
- );
2146
- }
2147
- for (const pinNumberKey in pinLabels) {
2148
- const aliases = Array.isArray(pinLabels[pinNumberKey]) ? pinLabels[pinNumberKey] : [pinLabels[pinNumberKey]];
2149
- if (aliases.includes(pinNumberOrLabel)) {
2150
- return Number(pinNumberKey.replace("pin", ""));
2151
- }
2152
- }
2153
- throw new Error(
2154
- `No pin labels provided and pin number or label is not a number: "${pinNumberOrLabel}"`
2155
- );
2156
- };
2157
-
2158
2169
  // lib/utils/schematic/getAllDimensionsForSchematicBox.ts
2159
2170
  function isExplicitPinMappingArrangement(arrangement) {
2160
2171
  return arrangement.leftSide !== void 0;
@@ -2227,7 +2238,7 @@ var getAllDimensionsForSchematicBox = (params) => {
2227
2238
  sideIndex,
2228
2239
  truePinIndex
2229
2240
  });
2230
- const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
2241
+ const pinStyle = params.numericSchPinStyle?.[`pin${pinNumber}`] ?? params.numericSchPinStyle?.[pinNumber];
2231
2242
  if (pinStyle?.topMargin) {
2232
2243
  currentDistanceFromEdge += pinStyle.topMargin;
2233
2244
  }
@@ -2255,7 +2266,7 @@ var getAllDimensionsForSchematicBox = (params) => {
2255
2266
  sideIndex,
2256
2267
  truePinIndex
2257
2268
  });
2258
- const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
2269
+ const pinStyle = params.numericSchPinStyle?.[`pin${pinNumber}`] ?? params.numericSchPinStyle?.[pinNumber];
2259
2270
  if (pinStyle?.leftMargin) {
2260
2271
  currentDistanceFromEdge += pinStyle.leftMargin;
2261
2272
  }
@@ -2283,7 +2294,7 @@ var getAllDimensionsForSchematicBox = (params) => {
2283
2294
  sideIndex,
2284
2295
  truePinIndex
2285
2296
  });
2286
- const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
2297
+ const pinStyle = params.numericSchPinStyle?.[`pin${pinNumber}`] ?? params.numericSchPinStyle?.[pinNumber];
2287
2298
  if (pinStyle?.bottomMargin) {
2288
2299
  currentDistanceFromEdge += pinStyle.bottomMargin;
2289
2300
  }
@@ -2311,7 +2322,7 @@ var getAllDimensionsForSchematicBox = (params) => {
2311
2322
  sideIndex,
2312
2323
  truePinIndex
2313
2324
  });
2314
- const pinStyle = params.schPinStyle?.[`pin${pinNumber}`] ?? params.schPinStyle?.[pinNumber];
2325
+ const pinStyle = params.numericSchPinStyle?.[`pin${pinNumber}`] ?? params.numericSchPinStyle?.[pinNumber];
2315
2326
  if (pinStyle?.rightMargin) {
2316
2327
  currentDistanceFromEdge += pinStyle.rightMargin;
2317
2328
  }
@@ -2627,6 +2638,20 @@ var Footprint = class extends PrimitiveComponent {
2627
2638
  }
2628
2639
  };
2629
2640
 
2641
+ // lib/utils/schematic/getNumericSchPinStyle.ts
2642
+ var getNumericSchPinStyle = (pinStyles, pinLabels) => {
2643
+ if (!pinStyles) return void 0;
2644
+ const numericPinStyles = {};
2645
+ for (const [pinNameOrLabel, pinStyle] of Object.entries(pinStyles)) {
2646
+ const pinNumber = parsePinNumberFromLabelsOrThrow(pinNameOrLabel, pinLabels);
2647
+ numericPinStyles[`pin${pinNumber}`] = {
2648
+ ...numericPinStyles[`pin${pinNumber}`],
2649
+ ...pinStyle
2650
+ };
2651
+ }
2652
+ return numericPinStyles;
2653
+ };
2654
+
2630
2655
  // lib/components/base-components/NormalComponent.ts
2631
2656
  var debug2 = Debug3("tscircuit:core");
2632
2657
  var rotation3 = z5.object({
@@ -2926,7 +2951,7 @@ var NormalComponent = class extends PrimitiveComponent {
2926
2951
  ),
2927
2952
  pin_spacing: props.schPinSpacing ?? 0.2,
2928
2953
  // @ts-ignore soup needs to support distance for pin_styles
2929
- pin_styles: underscorifyPinStyles(props.schPinStyle),
2954
+ pin_styles: underscorifyPinStyles(props.schPinStyle, props.pinLabels),
2930
2955
  port_labels: primaryPortLabels,
2931
2956
  source_component_id: this.source_component_id
2932
2957
  });
@@ -3217,7 +3242,10 @@ var NormalComponent = class extends PrimitiveComponent {
3217
3242
  schWidth: props.schWidth,
3218
3243
  schHeight: props.schHeight,
3219
3244
  schPinSpacing: pinSpacing,
3220
- schPinStyle: props.schPinStyle,
3245
+ numericSchPinStyle: getNumericSchPinStyle(
3246
+ props.schPinStyle,
3247
+ props.pinLabels
3248
+ ),
3221
3249
  pinCount,
3222
3250
  schPortArrangement: this._getSchematicPortArrangement(),
3223
3251
  pinLabels: props.pinLabels
@@ -5124,6 +5152,11 @@ var Chip = class extends NormalComponent {
5124
5152
  shouldRenderAsSchematicBox: true
5125
5153
  };
5126
5154
  }
5155
+ doInitialSchematicComponentRender() {
5156
+ const { _parsedProps: props } = this;
5157
+ if (props?.noSchematicRepresentation === true) return;
5158
+ super.doInitialSchematicComponentRender();
5159
+ }
5127
5160
  doInitialSourceRender() {
5128
5161
  const { db } = this.root;
5129
5162
  const { _parsedProps: props } = this;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.250",
4
+ "version": "0.0.252",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "@tscircuit/footprinter": "^0.0.95",
44
44
  "@tscircuit/infgrid-ijump-astar": "^0.0.26",
45
45
  "@tscircuit/math-utils": "^0.0.5",
46
- "@tscircuit/props": "^0.0.124",
46
+ "@tscircuit/props": "^0.0.125",
47
47
  "@tscircuit/schematic-autolayout": "^0.0.6",
48
48
  "@tscircuit/soup-util": "^0.0.41",
49
49
  "circuit-json": "^0.0.126",