@tscircuit/core 0.0.711 → 0.0.713

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
@@ -1,7 +1,7 @@
1
1
  import * as circuit_json from 'circuit-json';
2
2
  import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, LayerRef, AnyCircuitElement, Size, AnySourceComponent, PcbTraceRoutePoint, PcbTrace as PcbTrace$1, PcbVia, SchematicPort, SchematicComponent, RouteHintPoint, CircuitJson } from 'circuit-json';
3
3
  import * as _tscircuit_props from '@tscircuit/props';
4
- import { PlatformConfig, subcircuitGroupProps, AutorouterConfig, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, solderjumperProps, ledProps, powerSourceProps, CommonComponentProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, switchProps, testpointProps, schematicTextProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
4
+ import { PlatformConfig, subcircuitGroupProps, AutorouterConfig, traceProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, solderjumperProps, ledProps, powerSourceProps, CommonComponentProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, cutoutProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, switchProps, testpointProps, schematicTextProps, schematicBoxProps, schematicTableProps, schematicRowProps, schematicCellProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
5
5
  import React, { ReactElement, DetailedHTMLProps, SVGProps } from 'react';
6
6
  export { createElement } from 'react';
7
7
  import * as zod from 'zod';
@@ -1034,6 +1034,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
1034
1034
  _isnormalcomponent: string;
1035
1035
  };
1036
1036
  _asyncSupplierPartNumbers?: SupplierPartNumbers;
1037
+ _asyncFootprintCadModel?: CadModelProp;
1037
1038
  pcb_missing_footprint_error_id?: string;
1038
1039
  _hasStartedFootprintUrlLoad: boolean;
1039
1040
  private _invalidPinLabelMessages;
@@ -13863,19 +13864,6 @@ declare const voltageSourceProps: z.ZodObject<{
13863
13864
  schRotation?: number | undefined;
13864
13865
  schRelative?: boolean | undefined;
13865
13866
  pcbRelative?: boolean | undefined;
13866
- pinAttributes?: Record<string, {
13867
- providesPower?: boolean | undefined;
13868
- requiresPower?: boolean | undefined;
13869
- providesGround?: boolean | undefined;
13870
- requiresGround?: boolean | undefined;
13871
- providesVoltage?: string | number | undefined;
13872
- requiresVoltage?: string | number | undefined;
13873
- doNotConnect?: boolean | undefined;
13874
- }> | undefined;
13875
- peakToPeakVoltage?: number | undefined;
13876
- waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
13877
- dutyCycle?: number | undefined;
13878
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
13879
13867
  cadModel?: string | {
13880
13868
  stlUrl: string;
13881
13869
  rotationOffset?: number | {
@@ -13997,6 +13985,19 @@ declare const voltageSourceProps: z.ZodObject<{
13997
13985
  z: number;
13998
13986
  } | undefined;
13999
13987
  } | null | undefined;
13988
+ pinAttributes?: Record<string, {
13989
+ providesPower?: boolean | undefined;
13990
+ requiresPower?: boolean | undefined;
13991
+ providesGround?: boolean | undefined;
13992
+ requiresGround?: boolean | undefined;
13993
+ providesVoltage?: string | number | undefined;
13994
+ requiresVoltage?: string | number | undefined;
13995
+ doNotConnect?: boolean | undefined;
13996
+ }> | undefined;
13997
+ peakToPeakVoltage?: number | undefined;
13998
+ waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
13999
+ dutyCycle?: number | undefined;
14000
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
14000
14001
  symbolName?: string | undefined;
14001
14002
  doNotPlace?: boolean | undefined;
14002
14003
  }, {
@@ -14033,19 +14034,6 @@ declare const voltageSourceProps: z.ZodObject<{
14033
14034
  schRotation?: string | number | undefined;
14034
14035
  schRelative?: boolean | undefined;
14035
14036
  pcbRelative?: boolean | undefined;
14036
- pinAttributes?: Record<string, {
14037
- providesPower?: boolean | undefined;
14038
- requiresPower?: boolean | undefined;
14039
- providesGround?: boolean | undefined;
14040
- requiresGround?: boolean | undefined;
14041
- providesVoltage?: string | number | undefined;
14042
- requiresVoltage?: string | number | undefined;
14043
- doNotConnect?: boolean | undefined;
14044
- }> | undefined;
14045
- peakToPeakVoltage?: string | number | undefined;
14046
- waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
14047
- dutyCycle?: number | undefined;
14048
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
14049
14037
  cadModel?: string | {
14050
14038
  stlUrl: string;
14051
14039
  rotationOffset?: number | {
@@ -14167,6 +14155,19 @@ declare const voltageSourceProps: z.ZodObject<{
14167
14155
  z: string | number;
14168
14156
  } | undefined;
14169
14157
  } | null | undefined;
14158
+ pinAttributes?: Record<string, {
14159
+ providesPower?: boolean | undefined;
14160
+ requiresPower?: boolean | undefined;
14161
+ providesGround?: boolean | undefined;
14162
+ requiresGround?: boolean | undefined;
14163
+ providesVoltage?: string | number | undefined;
14164
+ requiresVoltage?: string | number | undefined;
14165
+ doNotConnect?: boolean | undefined;
14166
+ }> | undefined;
14167
+ peakToPeakVoltage?: string | number | undefined;
14168
+ waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
14169
+ dutyCycle?: number | undefined;
14170
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
14170
14171
  symbolName?: string | undefined;
14171
14172
  doNotPlace?: boolean | undefined;
14172
14173
  }>;
@@ -14816,19 +14817,6 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
14816
14817
  schRotation?: number | undefined;
14817
14818
  schRelative?: boolean | undefined;
14818
14819
  pcbRelative?: boolean | undefined;
14819
- pinAttributes?: Record<string, {
14820
- providesPower?: boolean | undefined;
14821
- requiresPower?: boolean | undefined;
14822
- providesGround?: boolean | undefined;
14823
- requiresGround?: boolean | undefined;
14824
- providesVoltage?: string | number | undefined;
14825
- requiresVoltage?: string | number | undefined;
14826
- doNotConnect?: boolean | undefined;
14827
- }> | undefined;
14828
- peakToPeakVoltage?: number | undefined;
14829
- waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
14830
- dutyCycle?: number | undefined;
14831
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
14832
14820
  cadModel?: string | {
14833
14821
  stlUrl: string;
14834
14822
  rotationOffset?: number | {
@@ -14950,6 +14938,19 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
14950
14938
  z: number;
14951
14939
  } | undefined;
14952
14940
  } | null | undefined;
14941
+ pinAttributes?: Record<string, {
14942
+ providesPower?: boolean | undefined;
14943
+ requiresPower?: boolean | undefined;
14944
+ providesGround?: boolean | undefined;
14945
+ requiresGround?: boolean | undefined;
14946
+ providesVoltage?: string | number | undefined;
14947
+ requiresVoltage?: string | number | undefined;
14948
+ doNotConnect?: boolean | undefined;
14949
+ }> | undefined;
14950
+ peakToPeakVoltage?: number | undefined;
14951
+ waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
14952
+ dutyCycle?: number | undefined;
14953
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
14953
14954
  symbolName?: string | undefined;
14954
14955
  doNotPlace?: boolean | undefined;
14955
14956
  }, {
@@ -14986,19 +14987,6 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
14986
14987
  schRotation?: string | number | undefined;
14987
14988
  schRelative?: boolean | undefined;
14988
14989
  pcbRelative?: boolean | undefined;
14989
- pinAttributes?: Record<string, {
14990
- providesPower?: boolean | undefined;
14991
- requiresPower?: boolean | undefined;
14992
- providesGround?: boolean | undefined;
14993
- requiresGround?: boolean | undefined;
14994
- providesVoltage?: string | number | undefined;
14995
- requiresVoltage?: string | number | undefined;
14996
- doNotConnect?: boolean | undefined;
14997
- }> | undefined;
14998
- peakToPeakVoltage?: string | number | undefined;
14999
- waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
15000
- dutyCycle?: number | undefined;
15001
- supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
15002
14990
  cadModel?: string | {
15003
14991
  stlUrl: string;
15004
14992
  rotationOffset?: number | {
@@ -15120,6 +15108,19 @@ declare class VoltageSource extends NormalComponent<typeof voltageSourceProps, "
15120
15108
  z: string | number;
15121
15109
  } | undefined;
15122
15110
  } | null | undefined;
15111
+ pinAttributes?: Record<string, {
15112
+ providesPower?: boolean | undefined;
15113
+ requiresPower?: boolean | undefined;
15114
+ providesGround?: boolean | undefined;
15115
+ requiresGround?: boolean | undefined;
15116
+ providesVoltage?: string | number | undefined;
15117
+ requiresVoltage?: string | number | undefined;
15118
+ doNotConnect?: boolean | undefined;
15119
+ }> | undefined;
15120
+ peakToPeakVoltage?: string | number | undefined;
15121
+ waveShape?: "square" | "sinewave" | "triangle" | "sawtooth" | undefined;
15122
+ dutyCycle?: number | undefined;
15123
+ supplierPartNumbers?: Partial<Record<"jlcpcb" | "macrofab" | "pcbway" | "digikey" | "mouser" | "lcsc", string[]>> | undefined;
15123
15124
  symbolName?: string | undefined;
15124
15125
  doNotPlace?: boolean | undefined;
15125
15126
  }>;
package/dist/index.js CHANGED
@@ -127,7 +127,8 @@ var orderedRenderPhases = [
127
127
  "PartsEngineRender"
128
128
  ];
129
129
  var asyncPhaseDependencies = {
130
- PcbTraceRender: ["PcbFootprintStringRender"]
130
+ PcbTraceRender: ["PcbFootprintStringRender"],
131
+ CadModelRender: ["PcbFootprintStringRender"]
131
132
  };
132
133
  var globalRenderCounter = 0;
133
134
  var Renderable = class {
@@ -6587,6 +6588,7 @@ var parseLibraryFootprintRef = (s) => {
6587
6588
  };
6588
6589
 
6589
6590
  // lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
6591
+ import { external_footprint_load_error } from "circuit-json";
6590
6592
  function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
6591
6593
  let { footprint } = component.props;
6592
6594
  footprint ??= component._getImpliedFootprintString?.();
@@ -6597,20 +6599,42 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
6597
6599
  component._hasStartedFootprintUrlLoad = true;
6598
6600
  const url = footprint;
6599
6601
  queueAsyncEffect("load-footprint-url", async () => {
6600
- const res = await fetch(url);
6601
- const soup = await res.json();
6602
- const fpComponents = createComponentsFromCircuitJson(
6603
- {
6604
- componentName: component.name,
6605
- componentRotation: pcbRotation,
6606
- footprint: url,
6607
- pinLabels,
6608
- pcbPinLabels
6609
- },
6610
- soup
6611
- );
6612
- component.addAll(fpComponents);
6613
- component._markDirty("InitializePortsFromChildren");
6602
+ try {
6603
+ const res = await fetch(url);
6604
+ if (!res.ok) {
6605
+ throw new Error(`Failed to fetch footprint: ${res.status}`);
6606
+ }
6607
+ const soup = await res.json();
6608
+ const fpComponents = createComponentsFromCircuitJson(
6609
+ {
6610
+ componentName: component.name,
6611
+ componentRotation: pcbRotation,
6612
+ footprint: url,
6613
+ pinLabels,
6614
+ pcbPinLabels
6615
+ },
6616
+ soup
6617
+ );
6618
+ component.addAll(fpComponents);
6619
+ component._markDirty("InitializePortsFromChildren");
6620
+ } catch (err) {
6621
+ const db = component.root?.db;
6622
+ if (db && component.source_component_id && component.pcb_component_id) {
6623
+ const subcircuit = component.getSubcircuit();
6624
+ const errorMsg = `${component.getString()} failed to load external footprint "${url}": ` + (err instanceof Error ? err.message : String(err));
6625
+ const errorObj = external_footprint_load_error.parse({
6626
+ type: "external_footprint_load_error",
6627
+ message: errorMsg,
6628
+ pcb_component_id: component.pcb_component_id,
6629
+ source_component_id: component.source_component_id,
6630
+ subcircuit_id: subcircuit.subcircuit_id ?? void 0,
6631
+ pcb_group_id: component.getGroup()?.pcb_group_id ?? void 0,
6632
+ footprinter_string: url
6633
+ });
6634
+ db.external_footprint_load_error.insert(errorObj);
6635
+ }
6636
+ throw err;
6637
+ }
6614
6638
  });
6615
6639
  return;
6616
6640
  }
@@ -6627,26 +6651,53 @@ function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsync
6627
6651
  }
6628
6652
  if (!resolverFn) return;
6629
6653
  queueAsyncEffect("load-lib-footprint", async () => {
6630
- const result = await resolverFn(libRef.footprintName);
6631
- const circuitJson = Array.isArray(result) ? result : Array.isArray(result?.footprintCircuitJson) ? result.footprintCircuitJson : null;
6632
- if (!circuitJson) return;
6633
- const fpComponents = createComponentsFromCircuitJson(
6634
- {
6635
- componentName: component.name,
6636
- componentRotation: pcbRotation,
6637
- footprint,
6638
- pinLabels,
6639
- pcbPinLabels
6640
- },
6641
- circuitJson
6642
- );
6643
- component.addAll(fpComponents);
6644
- for (const child of component.children) {
6645
- if (child.componentName === "Port") {
6646
- child._markDirty?.("PcbPortRender");
6654
+ try {
6655
+ const result = await resolverFn(libRef.footprintName);
6656
+ let circuitJson = null;
6657
+ if (Array.isArray(result)) {
6658
+ circuitJson = result;
6659
+ } else if (Array.isArray(result.footprintCircuitJson)) {
6660
+ circuitJson = result.footprintCircuitJson;
6647
6661
  }
6662
+ if (!circuitJson) return;
6663
+ const fpComponents = createComponentsFromCircuitJson(
6664
+ {
6665
+ componentName: component.name,
6666
+ componentRotation: pcbRotation,
6667
+ footprint,
6668
+ pinLabels,
6669
+ pcbPinLabels
6670
+ },
6671
+ circuitJson
6672
+ );
6673
+ component.addAll(fpComponents);
6674
+ if (!Array.isArray(result) && result.cadModel) {
6675
+ component._asyncFootprintCadModel = result.cadModel;
6676
+ }
6677
+ for (const child of component.children) {
6678
+ if (child.componentName === "Port") {
6679
+ child._markDirty?.("PcbPortRender");
6680
+ }
6681
+ }
6682
+ component._markDirty("InitializePortsFromChildren");
6683
+ } catch (err) {
6684
+ const db = component.root?.db;
6685
+ if (db && component.source_component_id && component.pcb_component_id) {
6686
+ const subcircuit = component.getSubcircuit();
6687
+ const errorMsg = `${component.getString()} failed to load external footprint "${footprint}": ` + (err instanceof Error ? err.message : String(err));
6688
+ const errorObj = external_footprint_load_error.parse({
6689
+ type: "external_footprint_load_error",
6690
+ message: errorMsg,
6691
+ pcb_component_id: component.pcb_component_id,
6692
+ source_component_id: component.source_component_id,
6693
+ subcircuit_id: subcircuit.subcircuit_id ?? void 0,
6694
+ pcb_group_id: component.getGroup()?.pcb_group_id ?? void 0,
6695
+ footprinter_string: footprint
6696
+ });
6697
+ db.external_footprint_load_error.insert(errorObj);
6698
+ }
6699
+ throw err;
6648
6700
  }
6649
- component._markDirty("InitializePortsFromChildren");
6650
6701
  });
6651
6702
  return;
6652
6703
  }
@@ -6681,6 +6732,7 @@ var NormalComponent2 = class extends PrimitiveComponent2 {
6681
6732
  _isnormalcomponent: "_isNormalComponent"
6682
6733
  };
6683
6734
  _asyncSupplierPartNumbers;
6735
+ _asyncFootprintCadModel;
6684
6736
  pcb_missing_footprint_error_id;
6685
6737
  _hasStartedFootprintUrlLoad = false;
6686
6738
  _invalidPinLabelMessages = [];
@@ -7416,7 +7468,8 @@ var NormalComponent2 = class extends PrimitiveComponent2 {
7416
7468
  doInitialCadModelRender() {
7417
7469
  const { db } = this.root;
7418
7470
  const { boardThickness = 0 } = this.root?._getBoard() ?? {};
7419
- const cadModel = this._parsedProps.cadModel;
7471
+ const cadModelProp = this._parsedProps.cadModel;
7472
+ const cadModel = cadModelProp === void 0 ? this._asyncFootprintCadModel : cadModelProp;
7420
7473
  const footprint = this.props.footprint ?? this._getImpliedFootprintString();
7421
7474
  if (!this.pcb_component_id) return;
7422
7475
  if (!cadModel && !footprint) return;
@@ -7455,10 +7508,15 @@ var NormalComponent2 = class extends PrimitiveComponent2 {
7455
7508
  source_component_id: this.source_component_id,
7456
7509
  model_stl_url: "stlUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.stlUrl) : void 0,
7457
7510
  model_obj_url: "objUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.objUrl) : void 0,
7511
+ model_mtl_url: "mtlUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.mtlUrl) : void 0,
7458
7512
  model_gltf_url: "gltfUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.gltfUrl) : void 0,
7513
+ model_glb_url: "glbUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.glbUrl) : void 0,
7514
+ model_step_url: "stepUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.stepUrl) : void 0,
7515
+ model_wrl_url: "wrlUrl" in (cadModel ?? {}) ? this._addCachebustToModelUrl(cadModel.wrlUrl) : void 0,
7459
7516
  model_jscad: "jscad" in (cadModel ?? {}) ? cadModel.jscad : void 0,
7460
7517
  footprinter_string: typeof footprint === "string" && !cadModel ? footprint : void 0
7461
7518
  });
7519
+ this.cad_component_id = cad_model.cad_component_id;
7462
7520
  }
7463
7521
  _addCachebustToModelUrl(url) {
7464
7522
  if (!url || !url.includes("modelcdn.tscircuit.com")) return url;
@@ -14642,7 +14700,7 @@ import { identity as identity6 } from "transformation-matrix";
14642
14700
  var package_default = {
14643
14701
  name: "@tscircuit/core",
14644
14702
  type: "module",
14645
- version: "0.0.710",
14703
+ version: "0.0.712",
14646
14704
  types: "dist/index.d.ts",
14647
14705
  main: "dist/index.js",
14648
14706
  module: "dist/index.js",
@@ -14695,7 +14753,7 @@ var package_default = {
14695
14753
  "bun-match-svg": "0.0.12",
14696
14754
  "calculate-elbow": "^0.0.12",
14697
14755
  "chokidar-cli": "^3.0.0",
14698
- "circuit-json": "^0.0.245",
14756
+ "circuit-json": "^0.0.247",
14699
14757
  "circuit-json-to-bpc": "^0.0.13",
14700
14758
  "circuit-json-to-connectivity-map": "^0.0.22",
14701
14759
  "circuit-json-to-simple-3d": "^0.0.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.711",
4
+ "version": "0.0.713",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -54,7 +54,7 @@
54
54
  "bun-match-svg": "0.0.12",
55
55
  "calculate-elbow": "^0.0.12",
56
56
  "chokidar-cli": "^3.0.0",
57
- "circuit-json": "^0.0.245",
57
+ "circuit-json": "^0.0.247",
58
58
  "circuit-json-to-bpc": "^0.0.13",
59
59
  "circuit-json-to-connectivity-map": "^0.0.22",
60
60
  "circuit-json-to-simple-3d": "^0.0.6",