@tscircuit/core 0.0.1143 → 0.0.1145

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
@@ -177,9 +177,9 @@ interface IIsolatedCircuit {
177
177
  interface IRootCircuit extends IIsolatedCircuit {
178
178
  }
179
179
 
180
- declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
180
+ declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "RenderIsolatedSubcircuits", "InflateSubcircuitCircuitJson", "SourceNameDuplicateComponentRemoval", "PcbFootprintStringRender", "FetchPartFootprint", "InitializePortsFromChildren", "CreateNetsFromProps", "AssignFallbackProps", "CreateTracesFromProps", "CreateTracesFromNetLabels", "CreateTraceHintsFromProps", "SourceGroupRender", "AssignNameToUnnamedComponents", "SourceRender", "SourceComponentPropertyValidation", "SourceParentAttachment", "PortMatching", "OptimizeSelectorCache", "SourceTraceRender", "SourceAddConnectivityMapKey", "SourceDesignRuleChecks", "SimulationRender", "SchematicComponentRender", "SchematicPortRender", "SymbolContainerRender", "SchematicPrimitiveRender", "SchematicSymbolResize", "SchematicComponentSizeCalculation", "SchematicLayout", "SchematicTraceRender", "SchematicReplaceNetLabelsWithSymbols", "PanelBoardLayout", "ValidatePcbCoordinates", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbComponentSizeCalculation", "PcbComponentAnchorAlignment", "PcbCalcPlacementResolution", "PcbLayout", "PcbBoardAutoSize", "PanelLayout", "PcbTraceHintRender", "PcbManualTraceRender", "PcbTraceRender", "PcbRouteNetIslands", "PcbCopperPourRender", "PcbDesignRuleChecks", "SilkscreenOverlapAdjustment", "CadModelRender", "PartsEngineRender", "SimulationSpiceEngineRender"];
181
181
  type RenderPhase = (typeof orderedRenderPhases)[number];
182
- declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicTraceRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SimulationSpiceEngineRender", number>;
182
+ declare const renderPhaseIndexMap: Map<"ReactSubtreesRender" | "RenderIsolatedSubcircuits" | "InflateSubcircuitCircuitJson" | "SourceNameDuplicateComponentRemoval" | "PcbFootprintStringRender" | "FetchPartFootprint" | "InitializePortsFromChildren" | "CreateNetsFromProps" | "AssignFallbackProps" | "CreateTracesFromProps" | "CreateTracesFromNetLabels" | "CreateTraceHintsFromProps" | "SourceGroupRender" | "AssignNameToUnnamedComponents" | "SourceRender" | "SourceComponentPropertyValidation" | "SourceParentAttachment" | "PortMatching" | "OptimizeSelectorCache" | "SourceTraceRender" | "SourceAddConnectivityMapKey" | "SourceDesignRuleChecks" | "SimulationRender" | "SchematicComponentRender" | "SchematicPortRender" | "SymbolContainerRender" | "SchematicPrimitiveRender" | "SchematicSymbolResize" | "SchematicComponentSizeCalculation" | "SchematicLayout" | "SchematicTraceRender" | "SchematicReplaceNetLabelsWithSymbols" | "PanelBoardLayout" | "ValidatePcbCoordinates" | "PcbComponentRender" | "PcbPrimitiveRender" | "PcbFootprintLayout" | "PcbPortRender" | "PcbPortAttachment" | "PcbComponentSizeCalculation" | "PcbComponentAnchorAlignment" | "PcbCalcPlacementResolution" | "PcbLayout" | "PcbBoardAutoSize" | "PanelLayout" | "PcbTraceHintRender" | "PcbManualTraceRender" | "PcbTraceRender" | "PcbRouteNetIslands" | "PcbCopperPourRender" | "PcbDesignRuleChecks" | "SilkscreenOverlapAdjustment" | "CadModelRender" | "PartsEngineRender" | "SimulationSpiceEngineRender", number>;
183
183
  type RenderPhaseFn<K extends RenderPhase = RenderPhase> = `doInitial${K}` | `update${K}` | `remove${K}`;
184
184
  type RenderPhaseStates = Record<RenderPhase, {
185
185
  initialized: boolean;
@@ -720,6 +720,7 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
720
720
  _getSchematicBoxComponentDimensions(): SchematicBoxComponentDimensions | null;
721
721
  renderError(message: Parameters<typeof Renderable.prototype.renderError>[0]): void;
722
722
  getString(): string;
723
+ getDisplayName(): string;
723
724
  get [Symbol.toStringTag](): string;
724
725
  }
725
726
 
@@ -1581,6 +1582,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
1581
1582
  _isCadModelChild?: boolean;
1582
1583
  pcb_missing_footprint_error_id?: string;
1583
1584
  _hasStartedFootprintUrlLoad: boolean;
1585
+ private _invalidFootprintPropMessages;
1584
1586
  private _invalidPinLabelMessages;
1585
1587
  /**
1586
1588
  * Set to true to enable automatic silkscreen text adjustment when it overlaps with other components
@@ -1672,6 +1674,8 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
1672
1674
  getPortsFromFootprint(opts?: {
1673
1675
  additionalAliases?: Record<string, string[]>;
1674
1676
  }): Port[];
1677
+ private _queueInvalidFootprintPropMessage;
1678
+ private _insertInvalidFootprintPropErrors;
1675
1679
  getPortsFromSchematicSymbol(): Port[];
1676
1680
  doInitialCreateNetsFromProps(): void;
1677
1681
  _getNetsFromConnectionsProp(): string[];
@@ -1713,6 +1717,7 @@ declare class NormalComponent<ZodProps extends z.ZodType = any, PortNames extend
1713
1717
  doInitialCreateTracesFromProps(): void;
1714
1718
  _createTracesFromConnectionsProp(): void;
1715
1719
  doInitialSourceDesignRuleChecks(): void;
1720
+ doInitialSourceComponentPropertyValidation(): void;
1716
1721
  doInitialValidatePcbCoordinates(): void;
1717
1722
  doInitialPcbLayout(): void;
1718
1723
  /**
package/dist/index.js CHANGED
@@ -311,6 +311,7 @@ var orderedRenderPhases = [
311
311
  "SourceGroupRender",
312
312
  "AssignNameToUnnamedComponents",
313
313
  "SourceRender",
314
+ "SourceComponentPropertyValidation",
314
315
  "SourceParentAttachment",
315
316
  "PortMatching",
316
317
  "OptimizeSelectorCache",
@@ -2098,6 +2099,12 @@ var PrimitiveComponent2 = class extends Renderable {
2098
2099
  }
2099
2100
  return `<${cname}#${this._renderId} />`;
2100
2101
  }
2102
+ getDisplayName() {
2103
+ if (this.name) {
2104
+ return `${this.lowercaseComponentName} "${this.name}"`;
2105
+ }
2106
+ return `${this.lowercaseComponentName} (unnamed)`;
2107
+ }
2101
2108
  get [Symbol.toStringTag]() {
2102
2109
  return this.getString();
2103
2110
  }
@@ -10442,6 +10449,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
10442
10449
  _isCadModelChild;
10443
10450
  pcb_missing_footprint_error_id;
10444
10451
  _hasStartedFootprintUrlLoad = false;
10452
+ _invalidFootprintPropMessages = [];
10445
10453
  _invalidPinLabelMessages = [];
10446
10454
  /**
10447
10455
  * Set to true to enable automatic silkscreen text adjustment when it overlaps with other components
@@ -10728,7 +10736,13 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
10728
10736
  if (isHttpUrl(footprint)) return;
10729
10737
  if (isStaticAssetPath(footprint)) return;
10730
10738
  if (parseLibraryFootprintRef(footprint)) return;
10731
- const fpSoup = fp.string(footprint).soup();
10739
+ let fpCircuitJson;
10740
+ try {
10741
+ fpCircuitJson = fp.string(footprint).soup();
10742
+ } catch (error) {
10743
+ this._queueInvalidFootprintPropMessage(footprint, error);
10744
+ return;
10745
+ }
10732
10746
  const fpComponents = createComponentsFromCircuitJson(
10733
10747
  {
10734
10748
  componentName: this.name ?? this.componentName,
@@ -10737,7 +10751,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
10737
10751
  pinLabels,
10738
10752
  pcbPinLabels
10739
10753
  },
10740
- fpSoup
10754
+ fpCircuitJson
10741
10755
  );
10742
10756
  this.addAll(fpComponents);
10743
10757
  }
@@ -11251,9 +11265,15 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
11251
11265
  if (isHttpUrl(footprint)) return [];
11252
11266
  if (isStaticAssetPath(footprint)) return [];
11253
11267
  if (parseLibraryFootprintRef(footprint)) return [];
11254
- const fpSoup = fp.string(footprint).soup();
11268
+ let fpCircuitJson;
11269
+ try {
11270
+ fpCircuitJson = fp.string(footprint).soup();
11271
+ } catch (error) {
11272
+ this._queueInvalidFootprintPropMessage(footprint, error);
11273
+ return [];
11274
+ }
11255
11275
  const newPorts2 = [];
11256
- for (const elm of fpSoup) {
11276
+ for (const elm of fpCircuitJson) {
11257
11277
  if ("port_hints" in elm && elm.port_hints) {
11258
11278
  const newPort = getPortFromHints(elm.port_hints, opts);
11259
11279
  if (!newPort) continue;
@@ -11299,6 +11319,26 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
11299
11319
  }
11300
11320
  return newPorts;
11301
11321
  }
11322
+ _queueInvalidFootprintPropMessage(footprint, error) {
11323
+ const rawErrorMessage = error instanceof Error ? error.message : String(error);
11324
+ const isLikelyMissingLibraryPrefix = footprint.includes("/") && !footprint.includes(":");
11325
+ const helpfulHint = isLikelyMissingLibraryPrefix ? ` If this is a KiCad footprint, use "kicad:${footprint}".` : "";
11326
+ const message = `Invalid footprint prop on ${this.getDisplayName()}: "${footprint}".${helpfulHint} Parser details: ${rawErrorMessage}`;
11327
+ if (!this._invalidFootprintPropMessages.includes(message)) {
11328
+ this._invalidFootprintPropMessages.push(message);
11329
+ }
11330
+ }
11331
+ _insertInvalidFootprintPropErrors() {
11332
+ for (const message of this._invalidFootprintPropMessages) {
11333
+ this.root.db.source_invalid_component_property_error.insert({
11334
+ source_component_id: this.source_component_id || "",
11335
+ property_name: "footprint",
11336
+ message,
11337
+ error_type: "source_invalid_component_property_error"
11338
+ });
11339
+ }
11340
+ this._invalidFootprintPropMessages = [];
11341
+ }
11302
11342
  getPortsFromSchematicSymbol() {
11303
11343
  if (this.root?.schematicDisabled) return [];
11304
11344
  const { config } = this;
@@ -11663,6 +11703,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
11663
11703
  doInitialSourceDesignRuleChecks() {
11664
11704
  NormalComponent_doInitialSourceDesignRuleChecks(this);
11665
11705
  }
11706
+ doInitialSourceComponentPropertyValidation() {
11707
+ this._insertInvalidFootprintPropErrors();
11708
+ }
11666
11709
  doInitialValidatePcbCoordinates() {
11667
11710
  super.doInitialValidatePcbCoordinates();
11668
11711
  if (this.root?.pcbDisabled) return;
@@ -19037,7 +19080,7 @@ import { identity as identity5 } from "transformation-matrix";
19037
19080
  var package_default = {
19038
19081
  name: "@tscircuit/core",
19039
19082
  type: "module",
19040
- version: "0.0.1142",
19083
+ version: "0.0.1144",
19041
19084
  types: "dist/index.d.ts",
19042
19085
  main: "dist/index.js",
19043
19086
  module: "dist/index.js",
@@ -19102,7 +19145,7 @@ var package_default = {
19102
19145
  "circuit-json-to-gltf": "^0.0.91",
19103
19146
  "circuit-json-to-simple-3d": "^0.0.9",
19104
19147
  "circuit-json-to-spice": "^0.0.34",
19105
- "circuit-to-svg": "^0.0.337",
19148
+ "circuit-to-svg": "^0.0.342",
19106
19149
  concurrently: "^9.1.2",
19107
19150
  "connectivity-map": "^1.0.0",
19108
19151
  debug: "^4.3.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1143",
4
+ "version": "0.0.1145",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -66,7 +66,7 @@
66
66
  "circuit-json-to-gltf": "^0.0.91",
67
67
  "circuit-json-to-simple-3d": "^0.0.9",
68
68
  "circuit-json-to-spice": "^0.0.34",
69
- "circuit-to-svg": "^0.0.337",
69
+ "circuit-to-svg": "^0.0.342",
70
70
  "concurrently": "^9.1.2",
71
71
  "connectivity-map": "^1.0.0",
72
72
  "debug": "^4.3.6",