@tscircuit/core 0.0.429 → 0.0.431

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 * as _tscircuit_layout from '@tscircuit/layout';
12
12
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
13
13
  import { GraphicsObject } from 'graphics-debug';
14
14
 
15
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPrimitiveRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbComponentSizeCalculation", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
15
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "PcbFootprintStringRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SchematicComponentRender", "SchematicPrimitiveRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbComponentSizeCalculation", "PcbBoardAutoSize", "PcbTraceHintRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbDesignRuleChecks", "CadModelRender", "PartsEngineRender"];
16
16
  type RenderPhase = (typeof orderedRenderPhases)[number];
17
17
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
18
18
  type RenderPhaseStates = Record<RenderPhase, {
@@ -919,6 +919,7 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
919
919
  isPrimitiveContainer: boolean;
920
920
  _asyncSupplierPartNumbers?: SupplierPartNumbers;
921
921
  pcb_missing_footprint_error_id?: string;
922
+ _hasStartedFootprintUrlLoad: boolean;
922
923
  /**
923
924
  * Override this property for component defaults
924
925
  */
@@ -944,6 +945,7 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
944
945
  pinCount?: number;
945
946
  }): void;
946
947
  _getImpliedFootprintString(): string | null;
948
+ _isFootprintUrl(s: string): boolean;
947
949
  _addChildrenFromStringFootprint(): void;
948
950
  get portMap(): PortMap<PortNames>;
949
951
  getInstanceForReactElement(element: ReactElement): NormalComponent | null;
@@ -969,6 +971,7 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
969
971
  _renderReactSubtree(element: ReactElement): ReactSubtree;
970
972
  doInitialInitializePortsFromChildren(): void;
971
973
  doInitialReactSubtreesRender(): void;
974
+ doInitialPcbFootprintStringRender(): void;
972
975
  _hasExistingPortExactly(port1: Port): boolean;
973
976
  add(componentOrElm: PrimitiveComponent | ReactElement): void;
974
977
  getPortsFromFootprint(opts?: {
package/dist/index.js CHANGED
@@ -76,6 +76,7 @@ import Debug from "debug";
76
76
  var debug = Debug("tscircuit:renderable");
77
77
  var orderedRenderPhases = [
78
78
  "ReactSubtreesRender",
79
+ "PcbFootprintStringRender",
79
80
  "InitializePortsFromChildren",
80
81
  "CreateNetsFromProps",
81
82
  "CreateTracesFromProps",
@@ -2350,7 +2351,7 @@ var createComponentsFromCircuitJson = ({
2350
2351
  strokeWidth: elm.stroke_width
2351
2352
  })
2352
2353
  );
2353
- } else if (elm.type === "pcb_plated_hole" && elm.shape === "circle") {
2354
+ } else if (elm.type === "pcb_plated_hole") {
2354
2355
  if (elm.shape === "circle") {
2355
2356
  components.push(
2356
2357
  new PlatedHole({
@@ -2362,6 +2363,18 @@ var createComponentsFromCircuitJson = ({
2362
2363
  portHints: elm.port_hints
2363
2364
  })
2364
2365
  );
2366
+ } else if (elm.shape === "circular_hole_with_rect_pad") {
2367
+ components.push(
2368
+ new PlatedHole({
2369
+ pcbX: elm.x,
2370
+ pcbY: elm.y,
2371
+ shape: "circular_hole_with_rect_pad",
2372
+ holeDiameter: elm.hole_diameter,
2373
+ rectPadHeight: elm.rect_pad_height,
2374
+ rectPadWidth: elm.rect_pad_width,
2375
+ portHints: elm.port_hints
2376
+ })
2377
+ );
2365
2378
  }
2366
2379
  } else if (elm.type === "pcb_keepout" && elm.shape === "circle") {
2367
2380
  components.push(
@@ -5023,6 +5036,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
5023
5036
  isPrimitiveContainer = true;
5024
5037
  _asyncSupplierPartNumbers;
5025
5038
  pcb_missing_footprint_error_id;
5039
+ _hasStartedFootprintUrlLoad = false;
5026
5040
  /**
5027
5041
  * Override this property for component defaults
5028
5042
  */
@@ -5212,6 +5226,9 @@ var NormalComponent = class extends PrimitiveComponent2 {
5212
5226
  _getImpliedFootprintString() {
5213
5227
  return null;
5214
5228
  }
5229
+ _isFootprintUrl(s) {
5230
+ return s.startsWith("http://") || s.startsWith("https://");
5231
+ }
5215
5232
  _addChildrenFromStringFootprint() {
5216
5233
  const {
5217
5234
  name: componentName,
@@ -5222,6 +5239,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
5222
5239
  footprint ??= this._getImpliedFootprintString?.();
5223
5240
  if (!footprint) return;
5224
5241
  if (typeof footprint === "string") {
5242
+ if (this._isFootprintUrl(footprint)) return;
5225
5243
  const fpSoup = fp.string(footprint).soup();
5226
5244
  const fpComponents = createComponentsFromCircuitJson(
5227
5245
  { componentName, componentRotation, footprint, pinLabels },
@@ -5464,12 +5482,41 @@ var NormalComponent = class extends PrimitiveComponent2 {
5464
5482
  this.initPorts();
5465
5483
  }
5466
5484
  doInitialReactSubtreesRender() {
5467
- if (isReactElement(this.props.footprint)) {
5468
- if (this.reactSubtrees.some((rs) => rs.element === this.props.footprint))
5469
- return;
5470
- const subtree = this._renderReactSubtree(this.props.footprint);
5485
+ }
5486
+ doInitialPcbFootprintStringRender() {
5487
+ let { footprint } = this.props;
5488
+ footprint ??= this._getImpliedFootprintString?.();
5489
+ if (!footprint) return;
5490
+ const {
5491
+ name: componentName,
5492
+ pcbRotation: componentRotation,
5493
+ pinLabels
5494
+ } = this.props;
5495
+ if (typeof footprint === "string" && this._isFootprintUrl(footprint)) {
5496
+ if (this._hasStartedFootprintUrlLoad) return;
5497
+ this._hasStartedFootprintUrlLoad = true;
5498
+ const url = footprint;
5499
+ this._queueAsyncEffect("load-footprint-url", async () => {
5500
+ const res = await fetch(url);
5501
+ const soup = await res.json();
5502
+ const fpComponents = createComponentsFromCircuitJson(
5503
+ { componentName, componentRotation, footprint: url, pinLabels },
5504
+ soup
5505
+ );
5506
+ this.addAll(fpComponents);
5507
+ this._markDirty("InitializePortsFromChildren");
5508
+ });
5509
+ return;
5510
+ }
5511
+ if (isReactElement(footprint)) {
5512
+ if (this.reactSubtrees.some((rs) => rs.element === footprint)) return;
5513
+ const subtree = this._renderReactSubtree(footprint);
5471
5514
  this.reactSubtrees.push(subtree);
5472
5515
  this.add(subtree.component);
5516
+ return;
5517
+ }
5518
+ if (!isValidElement(footprint) && footprint.componentName === "Footprint") {
5519
+ this.add(footprint);
5473
5520
  }
5474
5521
  }
5475
5522
  _hasExistingPortExactly(port1) {
@@ -5513,6 +5560,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
5513
5560
  footprint = this.children.find((c) => c.componentName === "Footprint");
5514
5561
  }
5515
5562
  if (typeof footprint === "string") {
5563
+ if (this._isFootprintUrl(footprint)) return [];
5516
5564
  const fpSoup = fp.string(footprint).soup();
5517
5565
  const newPorts2 = [];
5518
5566
  for (const elm of fpSoup) {
@@ -8644,7 +8692,7 @@ import { identity as identity4 } from "transformation-matrix";
8644
8692
  var package_default = {
8645
8693
  name: "@tscircuit/core",
8646
8694
  type: "module",
8647
- version: "0.0.428",
8695
+ version: "0.0.430",
8648
8696
  types: "dist/index.d.ts",
8649
8697
  main: "dist/index.js",
8650
8698
  module: "dist/index.js",
@@ -8670,13 +8718,13 @@ var package_default = {
8670
8718
  "@tscircuit/capacity-autorouter": "^0.0.67",
8671
8719
  "@tscircuit/checks": "^0.0.46",
8672
8720
  "@tscircuit/circuit-json-util": "^0.0.47",
8673
- "@tscircuit/footprinter": "^0.0.159",
8721
+ "@tscircuit/footprinter": "^0.0.169",
8674
8722
  "@tscircuit/import-snippet": "^0.0.4",
8675
8723
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
8676
8724
  "@tscircuit/layout": "^0.0.28",
8677
8725
  "@tscircuit/log-soup": "^1.0.2",
8678
8726
  "@tscircuit/math-utils": "^0.0.18",
8679
- "@tscircuit/props": "^0.0.193",
8727
+ "@tscircuit/props": "^0.0.195",
8680
8728
  "@tscircuit/schematic-autolayout": "^0.0.6",
8681
8729
  "@types/bun": "latest",
8682
8730
  "@types/debug": "^4.1.12",
@@ -8688,7 +8736,7 @@ var package_default = {
8688
8736
  "circuit-json": "^0.0.190",
8689
8737
  "circuit-json-to-connectivity-map": "^0.0.22",
8690
8738
  "circuit-json-to-simple-3d": "^0.0.2",
8691
- "circuit-to-svg": "^0.0.127",
8739
+ "circuit-to-svg": "^0.0.132",
8692
8740
  concurrently: "^9.1.2",
8693
8741
  debug: "^4.3.6",
8694
8742
  "graphics-debug": "^0.0.4",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.429",
4
+ "version": "0.0.431",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -27,13 +27,13 @@
27
27
  "@tscircuit/capacity-autorouter": "^0.0.67",
28
28
  "@tscircuit/checks": "^0.0.46",
29
29
  "@tscircuit/circuit-json-util": "^0.0.47",
30
- "@tscircuit/footprinter": "^0.0.159",
30
+ "@tscircuit/footprinter": "^0.0.169",
31
31
  "@tscircuit/import-snippet": "^0.0.4",
32
32
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
33
33
  "@tscircuit/layout": "^0.0.28",
34
34
  "@tscircuit/log-soup": "^1.0.2",
35
35
  "@tscircuit/math-utils": "^0.0.18",
36
- "@tscircuit/props": "^0.0.193",
36
+ "@tscircuit/props": "^0.0.195",
37
37
  "@tscircuit/schematic-autolayout": "^0.0.6",
38
38
  "@types/bun": "latest",
39
39
  "@types/debug": "^4.1.12",
@@ -45,7 +45,7 @@
45
45
  "circuit-json": "^0.0.190",
46
46
  "circuit-json-to-connectivity-map": "^0.0.22",
47
47
  "circuit-json-to-simple-3d": "^0.0.2",
48
- "circuit-to-svg": "^0.0.127",
48
+ "circuit-to-svg": "^0.0.132",
49
49
  "concurrently": "^9.1.2",
50
50
  "debug": "^4.3.6",
51
51
  "graphics-debug": "^0.0.4",