@tscircuit/core 0.0.1131 → 0.0.1133

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
@@ -12,7 +12,7 @@ import { symbols, SchSymbol, BaseSymbolName } from 'schematic-symbols';
12
12
  import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
13
13
  import { Matrix } from 'transformation-matrix';
14
14
  import { PackSolver2 } from 'calculate-packing';
15
- import { AutoroutingPipelineSolver, AssignableAutoroutingPipeline2, AssignableAutoroutingPipeline3, AutoroutingPipeline1_OriginalUnravel, AutoroutingPipelineSolver3_HgPortPointPathing, AutoroutingPipelineSolver4 } from '@tscircuit/capacity-autorouter';
15
+ import { AutoroutingPipelineSolver, AssignableAutoroutingPipeline2, AssignableAutoroutingPipeline3, AutoroutingPipeline1_OriginalUnravel, AutoroutingPipelineSolver3_HgPortPointPathing } from '@tscircuit/capacity-autorouter';
16
16
  import { CopperPourPipelineSolver } from '@tscircuit/copper-pour-solver';
17
17
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
18
18
  import { GraphicsObject } from 'graphics-debug';
@@ -24,7 +24,7 @@ declare const SOLVERS: {
24
24
  AssignableAutoroutingPipeline3: typeof AssignableAutoroutingPipeline3;
25
25
  AutoroutingPipeline1_OriginalUnravel: typeof AutoroutingPipeline1_OriginalUnravel;
26
26
  AutoroutingPipelineSolver3_HgPortPointPathing: typeof AutoroutingPipelineSolver3_HgPortPointPathing;
27
- AutoroutingPipelineSolver4: typeof AutoroutingPipelineSolver4;
27
+ AutoroutingPipelineSolver4: typeof AutoroutingPipelineSolver;
28
28
  CopperPourPipelineSolver: typeof CopperPourPipelineSolver;
29
29
  };
30
30
  type SolverName = keyof typeof SOLVERS;
@@ -5575,7 +5575,7 @@ declare class Subpanel extends Group<typeof subpanelProps> {
5575
5575
  topMargin?: string | number | undefined;
5576
5576
  bottomMargin?: string | number | undefined;
5577
5577
  }>>>;
5578
- }, "width" | "children" | "height" | "layoutMode"> & {
5578
+ }, "width" | "height" | "children" | "layoutMode"> & {
5579
5579
  width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
5580
5580
  height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
5581
5581
  children: zod.ZodOptional<zod.ZodAny>;
@@ -6768,7 +6768,7 @@ declare class Panel extends Subpanel {
6768
6768
  topMargin?: string | number | undefined;
6769
6769
  bottomMargin?: string | number | undefined;
6770
6770
  }>>>;
6771
- }, "width" | "children" | "height" | "layoutMode"> & {
6771
+ }, "width" | "height" | "children" | "layoutMode"> & {
6772
6772
  width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
6773
6773
  height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
6774
6774
  children: zod.ZodOptional<zod.ZodAny>;
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({
@@ -18734,8 +18758,8 @@ var package_default = {
18734
18758
  "@biomejs/biome": "^1.8.3",
18735
18759
  "@resvg/resvg-js": "^2.6.2",
18736
18760
  "@tscircuit/alphabet": "0.0.25",
18761
+ "@tscircuit/capacity-autorouter": "^0.0.398",
18737
18762
  "@tscircuit/checks": "0.0.115",
18738
- "@tscircuit/capacity-autorouter": "^0.0.359",
18739
18763
  "@tscircuit/circuit-json-util": "^0.0.90",
18740
18764
  "@tscircuit/common": "^0.0.20",
18741
18765
  "@tscircuit/copper-pour-solver": "^0.0.20",
@@ -18773,7 +18797,7 @@ var package_default = {
18773
18797
  debug: "^4.3.6",
18774
18798
  "eecircuit-engine": "^1.5.6",
18775
18799
  flatbush: "^4.5.0",
18776
- "graphics-debug": "^0.0.60",
18800
+ "graphics-debug": "^0.0.89",
18777
18801
  howfat: "^0.3.8",
18778
18802
  "live-server": "^1.2.2",
18779
18803
  "looks-same": "^9.0.1",
@@ -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.1131",
4
+ "version": "0.0.1133",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -33,8 +33,8 @@
33
33
  "@biomejs/biome": "^1.8.3",
34
34
  "@resvg/resvg-js": "^2.6.2",
35
35
  "@tscircuit/alphabet": "0.0.25",
36
+ "@tscircuit/capacity-autorouter": "^0.0.398",
36
37
  "@tscircuit/checks": "0.0.115",
37
- "@tscircuit/capacity-autorouter": "^0.0.359",
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",
@@ -72,7 +72,7 @@
72
72
  "debug": "^4.3.6",
73
73
  "eecircuit-engine": "^1.5.6",
74
74
  "flatbush": "^4.5.0",
75
- "graphics-debug": "^0.0.60",
75
+ "graphics-debug": "^0.0.89",
76
76
  "howfat": "^0.3.8",
77
77
  "live-server": "^1.2.2",
78
78
  "looks-same": "^9.0.1",