@tscircuit/core 0.0.430 → 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",
@@ -5035,6 +5036,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
5035
5036
  isPrimitiveContainer = true;
5036
5037
  _asyncSupplierPartNumbers;
5037
5038
  pcb_missing_footprint_error_id;
5039
+ _hasStartedFootprintUrlLoad = false;
5038
5040
  /**
5039
5041
  * Override this property for component defaults
5040
5042
  */
@@ -5224,6 +5226,9 @@ var NormalComponent = class extends PrimitiveComponent2 {
5224
5226
  _getImpliedFootprintString() {
5225
5227
  return null;
5226
5228
  }
5229
+ _isFootprintUrl(s) {
5230
+ return s.startsWith("http://") || s.startsWith("https://");
5231
+ }
5227
5232
  _addChildrenFromStringFootprint() {
5228
5233
  const {
5229
5234
  name: componentName,
@@ -5234,6 +5239,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
5234
5239
  footprint ??= this._getImpliedFootprintString?.();
5235
5240
  if (!footprint) return;
5236
5241
  if (typeof footprint === "string") {
5242
+ if (this._isFootprintUrl(footprint)) return;
5237
5243
  const fpSoup = fp.string(footprint).soup();
5238
5244
  const fpComponents = createComponentsFromCircuitJson(
5239
5245
  { componentName, componentRotation, footprint, pinLabels },
@@ -5476,12 +5482,41 @@ var NormalComponent = class extends PrimitiveComponent2 {
5476
5482
  this.initPorts();
5477
5483
  }
5478
5484
  doInitialReactSubtreesRender() {
5479
- if (isReactElement(this.props.footprint)) {
5480
- if (this.reactSubtrees.some((rs) => rs.element === this.props.footprint))
5481
- return;
5482
- 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);
5483
5514
  this.reactSubtrees.push(subtree);
5484
5515
  this.add(subtree.component);
5516
+ return;
5517
+ }
5518
+ if (!isValidElement(footprint) && footprint.componentName === "Footprint") {
5519
+ this.add(footprint);
5485
5520
  }
5486
5521
  }
5487
5522
  _hasExistingPortExactly(port1) {
@@ -5525,6 +5560,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
5525
5560
  footprint = this.children.find((c) => c.componentName === "Footprint");
5526
5561
  }
5527
5562
  if (typeof footprint === "string") {
5563
+ if (this._isFootprintUrl(footprint)) return [];
5528
5564
  const fpSoup = fp.string(footprint).soup();
5529
5565
  const newPorts2 = [];
5530
5566
  for (const elm of fpSoup) {
@@ -8656,7 +8692,7 @@ import { identity as identity4 } from "transformation-matrix";
8656
8692
  var package_default = {
8657
8693
  name: "@tscircuit/core",
8658
8694
  type: "module",
8659
- version: "0.0.429",
8695
+ version: "0.0.430",
8660
8696
  types: "dist/index.d.ts",
8661
8697
  main: "dist/index.js",
8662
8698
  module: "dist/index.js",
@@ -8688,7 +8724,7 @@ var package_default = {
8688
8724
  "@tscircuit/layout": "^0.0.28",
8689
8725
  "@tscircuit/log-soup": "^1.0.2",
8690
8726
  "@tscircuit/math-utils": "^0.0.18",
8691
- "@tscircuit/props": "^0.0.193",
8727
+ "@tscircuit/props": "^0.0.195",
8692
8728
  "@tscircuit/schematic-autolayout": "^0.0.6",
8693
8729
  "@types/bun": "latest",
8694
8730
  "@types/debug": "^4.1.12",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.430",
4
+ "version": "0.0.431",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -33,7 +33,7 @@
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",