@tscircuit/core 0.0.361 → 0.0.363

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
@@ -1036,6 +1036,7 @@ declare class Group<Props extends z.ZodType<any, any, any> = typeof groupProps>
1036
1036
  * or if using a "fullview" or "rip and replace" autorouting mode
1037
1037
  */
1038
1038
  _shouldUseTraceByTraceRouting(): boolean;
1039
+ doInitialPcbDesignRuleChecks(): void;
1039
1040
  }
1040
1041
 
1041
1042
  declare class Board extends Group<typeof boardProps> {
@@ -11429,6 +11430,12 @@ declare const applyPcbEditEventsToManualEditsFile: ({ circuitJson, editEvents, m
11429
11430
  manualEditsFile: z.infer<typeof manual_edits_file>;
11430
11431
  }) => z.infer<typeof manual_edits_file>;
11431
11432
 
11433
+ declare const applySchematicEditEventsToManualEditsFile: ({ circuitJson, editEvents, manualEditsFile, }: {
11434
+ circuitJson: CircuitJson;
11435
+ editEvents: ManualEditEvent[];
11436
+ manualEditsFile: z.infer<typeof manual_edits_file>;
11437
+ }) => z.infer<typeof manual_edits_file>;
11438
+
11432
11439
  interface TscircuitElements {
11433
11440
  resistor: _tscircuit_props.ResistorProps;
11434
11441
  capacitor: _tscircuit_props.CapacitorProps;
@@ -11494,4 +11501,4 @@ declare module "react/jsx-runtime" {
11494
11501
  }
11495
11502
  }
11496
11503
 
11497
- export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, type Obstacle, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, Subcircuit, Switch, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
11504
+ export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, type Obstacle, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, Subcircuit, Switch, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
package/dist/index.js CHANGED
@@ -5629,6 +5629,7 @@ var getPhaseTimingsFromRenderEvents = (renderEvents) => {
5629
5629
  };
5630
5630
 
5631
5631
  // lib/components/primitive-components/Group/Group.ts
5632
+ import "@tscircuit/checks";
5632
5633
  var Group = class extends NormalComponent {
5633
5634
  pcb_group_id = null;
5634
5635
  subcircuit_id = null;
@@ -6130,10 +6131,38 @@ var Group = class extends NormalComponent {
6130
6131
  const autorouter = this._getAutorouterConfig();
6131
6132
  return autorouter.groupMode === "sequential-trace";
6132
6133
  }
6134
+ doInitialPcbDesignRuleChecks() {
6135
+ if (this.root?.pcbDisabled) return;
6136
+ if (this.getInheritedProperty("routingDisabled")) return;
6137
+ const { db } = this.root;
6138
+ if (this.isSubcircuit) {
6139
+ const subcircuitComponentsByName = /* @__PURE__ */ new Map();
6140
+ for (const child of this.children) {
6141
+ if (child.isSubcircuit) continue;
6142
+ if (child._parsedProps.name) {
6143
+ const components = subcircuitComponentsByName.get(child._parsedProps.name) || [];
6144
+ components.push(child);
6145
+ subcircuitComponentsByName.set(child._parsedProps.name, components);
6146
+ }
6147
+ }
6148
+ for (const [name, components] of subcircuitComponentsByName.entries()) {
6149
+ if (components.length > 1) {
6150
+ db.pcb_trace_error.insert({
6151
+ error_type: "pcb_trace_error",
6152
+ message: `Multiple components found with name "${name}" in subcircuit "${this._parsedProps.name || "unnamed"}". Component names must be unique within a subcircuit.`,
6153
+ source_trace_id: "",
6154
+ pcb_trace_id: "",
6155
+ pcb_component_ids: components.map((c) => c.pcb_component_id).filter(Boolean),
6156
+ pcb_port_ids: []
6157
+ });
6158
+ }
6159
+ }
6160
+ }
6161
+ }
6133
6162
  };
6134
6163
 
6135
6164
  // lib/components/normal-components/Board.ts
6136
- import { checkEachPcbTraceNonOverlapping } from "@tscircuit/checks";
6165
+ import { checkEachPcbTraceNonOverlapping as checkEachPcbTraceNonOverlapping2 } from "@tscircuit/checks";
6137
6166
  var Board = class extends Group {
6138
6167
  pcb_board_id = null;
6139
6168
  get isSubcircuit() {
@@ -6234,7 +6263,8 @@ var Board = class extends Group {
6234
6263
  if (this.root?.pcbDisabled) return;
6235
6264
  if (this.getInheritedProperty("routingDisabled")) return;
6236
6265
  const { db } = this.root;
6237
- const errors = checkEachPcbTraceNonOverlapping(db.toArray());
6266
+ super.doInitialPcbDesignRuleChecks();
6267
+ const errors = checkEachPcbTraceNonOverlapping2(db.toArray());
6238
6268
  for (const error of errors) {
6239
6269
  db.pcb_trace_error.insert(error);
6240
6270
  }
@@ -7332,7 +7362,7 @@ import { identity as identity4 } from "transformation-matrix";
7332
7362
  var package_default = {
7333
7363
  name: "@tscircuit/core",
7334
7364
  type: "module",
7335
- version: "0.0.360",
7365
+ version: "0.0.362",
7336
7366
  types: "dist/index.d.ts",
7337
7367
  main: "dist/index.js",
7338
7368
  module: "dist/index.js",
@@ -7777,6 +7807,47 @@ var applyPcbEditEventsToManualEditsFile = ({
7777
7807
  return updatedManualEditsFile;
7778
7808
  };
7779
7809
 
7810
+ // lib/utils/edit-events/apply-schematic-edit-events-to-manual-edits-file.ts
7811
+ import { su as su5 } from "@tscircuit/soup-util";
7812
+ import "zod";
7813
+ var applySchematicEditEventsToManualEditsFile = ({
7814
+ circuitJson,
7815
+ editEvents,
7816
+ manualEditsFile
7817
+ }) => {
7818
+ const updatedManualEditsFile = {
7819
+ ...manualEditsFile,
7820
+ schematic_placements: [...manualEditsFile.schematic_placements ?? []]
7821
+ };
7822
+ for (const editEvent of editEvents) {
7823
+ if (editEvent.edit_event_type === "edit_schematic_component_location") {
7824
+ const { schematic_component_id, new_center } = editEvent;
7825
+ const schematic_component2 = su5(circuitJson).schematic_component.get(
7826
+ schematic_component_id
7827
+ );
7828
+ if (!schematic_component2) continue;
7829
+ const source_component = su5(circuitJson).source_component.get(
7830
+ schematic_component2.source_component_id
7831
+ );
7832
+ if (!source_component) continue;
7833
+ const existingPlacementIndex = updatedManualEditsFile.schematic_placements?.findIndex(
7834
+ (p) => p.selector === source_component.name
7835
+ );
7836
+ const newPlacement = {
7837
+ selector: source_component.name,
7838
+ center: new_center,
7839
+ relative_to: "group_center"
7840
+ };
7841
+ if (existingPlacementIndex >= 0) {
7842
+ updatedManualEditsFile.schematic_placements[existingPlacementIndex] = newPlacement;
7843
+ } else {
7844
+ updatedManualEditsFile.schematic_placements.push(newPlacement);
7845
+ }
7846
+ }
7847
+ }
7848
+ return updatedManualEditsFile;
7849
+ };
7850
+
7780
7851
  // lib/index.ts
7781
7852
  import { createElement } from "react";
7782
7853
 
@@ -7833,6 +7904,7 @@ export {
7833
7904
  Via,
7834
7905
  applyEditEventsToManualEditsFile,
7835
7906
  applyPcbEditEventsToManualEditsFile,
7907
+ applySchematicEditEventsToManualEditsFile,
7836
7908
  createElement,
7837
7909
  createUseComponent,
7838
7910
  getPhaseTimingsFromRenderEvents,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.361",
4
+ "version": "0.0.363",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",