@tscircuit/core 0.0.1130 → 0.0.1132

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 +110 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -356,6 +356,21 @@ var renderPhaseIndexMap = new Map(
356
356
  );
357
357
  var asyncPhaseDependencies = {
358
358
  InflateSubcircuitCircuitJson: ["RenderIsolatedSubcircuits"],
359
+ SchematicComponentRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
360
+ SchematicPortRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
361
+ SymbolContainerRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
362
+ SchematicPrimitiveRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
363
+ SchematicSymbolResize: ["PcbFootprintStringRender", "FetchPartFootprint"],
364
+ SchematicComponentSizeCalculation: [
365
+ "PcbFootprintStringRender",
366
+ "FetchPartFootprint"
367
+ ],
368
+ SchematicLayout: ["PcbFootprintStringRender", "FetchPartFootprint"],
369
+ SchematicTraceRender: ["PcbFootprintStringRender", "FetchPartFootprint"],
370
+ SchematicReplaceNetLabelsWithSymbols: [
371
+ "PcbFootprintStringRender",
372
+ "FetchPartFootprint"
373
+ ],
359
374
  PcbFootprintLayout: ["PcbFootprintStringRender", "FetchPartFootprint"],
360
375
  PcbComponentSizeCalculation: [
361
376
  "PcbFootprintStringRender",
@@ -7857,6 +7872,15 @@ var createComponentsFromCircuitJson = ({
7857
7872
  layer: elm.layer
7858
7873
  })
7859
7874
  );
7875
+ } else if (elm.type === "pcb_smtpad" && elm.shape === "polygon") {
7876
+ components.push(
7877
+ new SmtPad({
7878
+ shape: "polygon",
7879
+ points: elm.points,
7880
+ portHints: elm.port_hints,
7881
+ layer: elm.layer
7882
+ })
7883
+ );
7860
7884
  } else if (elm.type === "pcb_silkscreen_path") {
7861
7885
  components.push(
7862
7886
  new SilkscreenPath({
@@ -22497,6 +22521,89 @@ import {
22497
22521
  connectorProps
22498
22522
  } from "@tscircuit/props";
22499
22523
  import { unknown_error_finding_part as unknown_error_finding_part2 } from "circuit-json";
22524
+
22525
+ // lib/utils/connectors/rewriteToStandardUsbCPortHints.ts
22526
+ var PIN_HINT_RE = /^(?:pin)?(\d+)$/i;
22527
+ var USB_C_STANDARD_PORT_HINT_ALIASES = {
22528
+ GND1: [],
22529
+ VBUS1: [],
22530
+ SBU2: [],
22531
+ CC1: [],
22532
+ DM2: ["DN2"],
22533
+ DP1: [],
22534
+ DM1: ["DN1"],
22535
+ DP2: [],
22536
+ SBU1: [],
22537
+ CC2: [],
22538
+ VBUS2: [],
22539
+ GND2: [],
22540
+ SHELL1: [],
22541
+ SHELL2: [],
22542
+ SHELL3: [],
22543
+ SHELL4: []
22544
+ };
22545
+ var unique = (hints) => Array.from(new Set(hints));
22546
+ var rewriteToStandardUsbCPortHints = (circuitJson) => {
22547
+ const aliasToStandardHint = {};
22548
+ for (const [standardHint, aliases] of Object.entries(
22549
+ USB_C_STANDARD_PORT_HINT_ALIASES
22550
+ )) {
22551
+ aliasToStandardHint[standardHint] = standardHint;
22552
+ for (const alias of aliases) {
22553
+ aliasToStandardHint[alias] = standardHint;
22554
+ }
22555
+ }
22556
+ const sourceAliasesByPin = /* @__PURE__ */ new Map();
22557
+ for (const elm of circuitJson) {
22558
+ if (elm && typeof elm === "object" && elm.type === "source_port" && typeof elm.pin_number === "number") {
22559
+ const pin = elm.pin_number;
22560
+ const hints = Array.isArray(elm.port_hints) ? elm.port_hints.filter((h) => typeof h === "string").map((h) => h.trim()).filter((h) => h.length > 0 && !PIN_HINT_RE.test(h)) : [];
22561
+ if (hints.length > 0) sourceAliasesByPin.set(pin, unique(hints));
22562
+ }
22563
+ }
22564
+ if (sourceAliasesByPin.size === 0) return circuitJson;
22565
+ return circuitJson.map((elm) => {
22566
+ if (!elm || typeof elm !== "object" || !("port_hints" in elm)) return elm;
22567
+ if (!Array.isArray(elm.port_hints)) return elm;
22568
+ const originalHints = elm.port_hints.filter((h) => typeof h === "string").map((h) => h.trim()).filter((h) => h.length > 0);
22569
+ if (originalHints.length === 0) return elm;
22570
+ const pinNumbers = /* @__PURE__ */ new Set();
22571
+ if (elm.type === "source_port" && typeof elm.pin_number === "number") {
22572
+ pinNumbers.add(elm.pin_number);
22573
+ }
22574
+ for (const hint of originalHints) {
22575
+ const m = hint.match(PIN_HINT_RE);
22576
+ if (m) pinNumbers.add(Number.parseInt(m[1], 10));
22577
+ }
22578
+ const sourceAliases = [];
22579
+ for (const pin of pinNumbers) {
22580
+ sourceAliases.push(...sourceAliasesByPin.get(pin) ?? []);
22581
+ }
22582
+ const standardHints = /* @__PURE__ */ new Set();
22583
+ for (const hint of [...originalHints, ...sourceAliases]) {
22584
+ const standard = aliasToStandardHint[hint.toUpperCase()];
22585
+ if (standard) standardHints.add(standard);
22586
+ }
22587
+ const addedHints = [];
22588
+ for (const standardHint of standardHints) {
22589
+ addedHints.push(
22590
+ standardHint,
22591
+ ...USB_C_STANDARD_PORT_HINT_ALIASES[standardHint]
22592
+ );
22593
+ }
22594
+ const rewrittenPortHints = unique([
22595
+ ...originalHints,
22596
+ ...sourceAliases,
22597
+ ...addedHints
22598
+ ]);
22599
+ return {
22600
+ ...elm,
22601
+ port_hints: rewrittenPortHints
22602
+ };
22603
+ });
22604
+ };
22605
+
22606
+ // lib/components/normal-components/Connector.ts
22500
22607
  var Connector = class extends Chip {
22501
22608
  _getConnectorProps() {
22502
22609
  return this._parsedProps;
@@ -22555,6 +22662,7 @@ var Connector = class extends Chip {
22555
22662
  });
22556
22663
  }
22557
22664
  _addConnectorFootprintFromCircuitJson(standard, circuitJson) {
22665
+ const rewrittenCircuitJson = standard === "usb_c" ? rewriteToStandardUsbCPortHints(circuitJson) : circuitJson;
22558
22666
  const props = this._getConnectorProps();
22559
22667
  const fpComponents = createComponentsFromCircuitJson(
22560
22668
  {
@@ -22564,9 +22672,10 @@ var Connector = class extends Chip {
22564
22672
  pinLabels: props.pinLabels,
22565
22673
  pcbPinLabels: props.pcbPinLabels
22566
22674
  },
22567
- circuitJson
22675
+ rewrittenCircuitJson
22568
22676
  );
22569
22677
  this.addAll(fpComponents);
22678
+ this._markDirty("InitializePortsFromChildren");
22570
22679
  }
22571
22680
  get config() {
22572
22681
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1130",
4
+ "version": "0.0.1132",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",