@tscircuit/core 0.0.363 → 0.0.365

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,5 +1,5 @@
1
1
  import * as _tscircuit_props from '@tscircuit/props';
2
- import { subcircuitGroupProps, AutorouterConfig, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, switchProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, manual_edits_file, ChipConnections } from '@tscircuit/props';
2
+ import { subcircuitGroupProps, AutorouterConfig, traceProps, SupplierPartNumbers, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, subcircuitProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, transistorProps, mosfetProps, switchProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
3
3
  import React, { ReactElement, DetailedHTMLProps, SVGProps } from 'react';
4
4
  export { createElement } from 'react';
5
5
  import * as zod from 'zod';
@@ -5649,15 +5649,15 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
5649
5649
  shape: zod.ZodLiteral<"oval">;
5650
5650
  outerWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5651
5651
  outerHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5652
- innerWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5653
- innerHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5652
+ holeWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5653
+ holeHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5654
5654
  portHints: zod.ZodOptional<zod.ZodArray<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, "many">>;
5655
5655
  }>, "strip", zod.ZodTypeAny, {
5656
5656
  shape: "oval";
5657
5657
  outerWidth: number;
5658
5658
  outerHeight: number;
5659
- innerWidth: number;
5660
- innerHeight: number;
5659
+ holeWidth: number;
5660
+ holeHeight: number;
5661
5661
  pcbX?: number | undefined;
5662
5662
  pcbY?: number | undefined;
5663
5663
  name?: string | undefined;
@@ -5666,8 +5666,8 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
5666
5666
  shape: "oval";
5667
5667
  outerWidth: string | number;
5668
5668
  outerHeight: string | number;
5669
- innerWidth: string | number;
5670
- innerHeight: string | number;
5669
+ holeWidth: string | number;
5670
+ holeHeight: string | number;
5671
5671
  pcbX?: string | number | undefined;
5672
5672
  pcbY?: string | number | undefined;
5673
5673
  name?: string | undefined;
@@ -5690,15 +5690,15 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
5690
5690
  shape: zod.ZodLiteral<"pill">;
5691
5691
  outerWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5692
5692
  outerHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5693
- innerWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5694
- innerHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5693
+ holeWidth: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5694
+ holeHeight: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
5695
5695
  portHints: zod.ZodOptional<zod.ZodArray<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, "many">>;
5696
5696
  }>, "strip", zod.ZodTypeAny, {
5697
5697
  shape: "pill";
5698
5698
  outerWidth: number;
5699
5699
  outerHeight: number;
5700
- innerWidth: number;
5701
- innerHeight: number;
5700
+ holeWidth: number;
5701
+ holeHeight: number;
5702
5702
  pcbX?: number | undefined;
5703
5703
  pcbY?: number | undefined;
5704
5704
  name?: string | undefined;
@@ -5707,8 +5707,8 @@ declare class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
5707
5707
  shape: "pill";
5708
5708
  outerWidth: string | number;
5709
5709
  outerHeight: string | number;
5710
- innerWidth: string | number;
5711
- innerHeight: string | number;
5710
+ holeWidth: string | number;
5711
+ holeHeight: string | number;
5712
5712
  pcbX?: string | number | undefined;
5713
5713
  pcbY?: string | number | undefined;
5714
5714
  name?: string | undefined;
@@ -11322,8 +11322,8 @@ declare const useResistor: <PropsFromHook extends Omit<ResistorProps, "name"> |
11322
11322
  declare const applyEditEventsToManualEditsFile: ({ circuitJson, editEvents, manualEditsFile, }: {
11323
11323
  circuitJson: CircuitJson;
11324
11324
  editEvents: ManualEditEvent[];
11325
- manualEditsFile: z.infer<typeof manual_edits_file>;
11326
- }) => z.infer<typeof manual_edits_file>;
11325
+ manualEditsFile: ManualEditsFile;
11326
+ }) => ManualEditsFile;
11327
11327
 
11328
11328
  /**
11329
11329
  * This function can only be called in the PcbTraceRender phase or later
package/dist/index.js CHANGED
@@ -1723,8 +1723,8 @@ var PlatedHole = class extends PrimitiveComponent {
1723
1723
  pcb_port_id: this.matchedPort?.pcb_port_id,
1724
1724
  outer_width: props.outerWidth,
1725
1725
  outer_height: props.outerHeight,
1726
- hole_width: props.innerWidth,
1727
- hole_height: props.innerHeight,
1726
+ hole_width: props.holeWidth,
1727
+ hole_height: props.holeHeight,
1728
1728
  shape: props.shape,
1729
1729
  port_hints: this.getNameAndAliases(),
1730
1730
  x: position.x,
@@ -5404,10 +5404,49 @@ var TraceHint = class extends PrimitiveComponent {
5404
5404
  }
5405
5405
  };
5406
5406
 
5407
- // lib/utils/edit-events/apply-edit-events-to-manual-edits-file.ts
5407
+ // lib/utils/edit-events/apply-pcb-edit-events-to-manual-edits-file.ts
5408
5408
  import "zod";
5409
5409
  import { su } from "@tscircuit/soup-util";
5410
- var applyEditEventsToManualEditsFile = ({
5410
+ var applyPcbEditEventsToManualEditsFile = ({
5411
+ circuitJson,
5412
+ editEvents,
5413
+ manualEditsFile
5414
+ }) => {
5415
+ const updatedManualEditsFile = {
5416
+ ...manualEditsFile,
5417
+ pcb_placements: [...manualEditsFile.pcb_placements ?? []]
5418
+ };
5419
+ for (const editEvent of editEvents) {
5420
+ if (editEvent.edit_event_type === "edit_pcb_component_location") {
5421
+ const { pcb_component_id, new_center } = editEvent;
5422
+ const pcb_component = su(circuitJson).pcb_component.get(pcb_component_id);
5423
+ if (!pcb_component) continue;
5424
+ const source_component = su(circuitJson).source_component.get(
5425
+ pcb_component.source_component_id
5426
+ );
5427
+ if (!source_component) continue;
5428
+ const existingPlacementIndex = updatedManualEditsFile.pcb_placements?.findIndex(
5429
+ (p) => p.selector === source_component.name
5430
+ );
5431
+ const newPlacement = {
5432
+ selector: source_component.name,
5433
+ center: new_center,
5434
+ relative_to: "group_center"
5435
+ };
5436
+ if (existingPlacementIndex >= 0) {
5437
+ updatedManualEditsFile.pcb_placements[existingPlacementIndex] = newPlacement;
5438
+ } else {
5439
+ updatedManualEditsFile.pcb_placements.push(newPlacement);
5440
+ }
5441
+ }
5442
+ }
5443
+ return updatedManualEditsFile;
5444
+ };
5445
+
5446
+ // lib/utils/edit-events/apply-schematic-edit-events-to-manual-edits-file.ts
5447
+ import { su as su2 } from "@tscircuit/soup-util";
5448
+ import "zod";
5449
+ var applySchematicEditEventsToManualEditsFile = ({
5411
5450
  circuitJson,
5412
5451
  editEvents,
5413
5452
  manualEditsFile
@@ -5419,11 +5458,11 @@ var applyEditEventsToManualEditsFile = ({
5419
5458
  for (const editEvent of editEvents) {
5420
5459
  if (editEvent.edit_event_type === "edit_schematic_component_location") {
5421
5460
  const { schematic_component_id, new_center } = editEvent;
5422
- const schematic_component2 = su(circuitJson).schematic_component.get(
5461
+ const schematic_component2 = su2(circuitJson).schematic_component.get(
5423
5462
  schematic_component_id
5424
5463
  );
5425
5464
  if (!schematic_component2) continue;
5426
- const source_component = su(circuitJson).source_component.get(
5465
+ const source_component = su2(circuitJson).source_component.get(
5427
5466
  schematic_component2.source_component_id
5428
5467
  );
5429
5468
  if (!source_component) continue;
@@ -5445,9 +5484,39 @@ var applyEditEventsToManualEditsFile = ({
5445
5484
  return updatedManualEditsFile;
5446
5485
  };
5447
5486
 
5487
+ // lib/utils/edit-events/apply-edit-events-to-manual-edits-file.ts
5488
+ var applyEditEventsToManualEditsFile = ({
5489
+ circuitJson,
5490
+ editEvents,
5491
+ manualEditsFile
5492
+ }) => {
5493
+ const schematicEditEvents = editEvents.filter(
5494
+ (event) => event.edit_event_type === "edit_schematic_component_location"
5495
+ );
5496
+ const pcbEditEvents = editEvents.filter(
5497
+ (event) => event.edit_event_type === "edit_pcb_component_location"
5498
+ );
5499
+ let updatedManualEditsFile = manualEditsFile;
5500
+ if (schematicEditEvents.length > 0) {
5501
+ updatedManualEditsFile = applySchematicEditEventsToManualEditsFile({
5502
+ circuitJson,
5503
+ editEvents: schematicEditEvents,
5504
+ manualEditsFile: updatedManualEditsFile
5505
+ });
5506
+ }
5507
+ if (pcbEditEvents.length > 0) {
5508
+ updatedManualEditsFile = applyPcbEditEventsToManualEditsFile({
5509
+ circuitJson,
5510
+ editEvents: pcbEditEvents,
5511
+ manualEditsFile: updatedManualEditsFile
5512
+ });
5513
+ }
5514
+ return updatedManualEditsFile;
5515
+ };
5516
+
5448
5517
  // lib/utils/autorouting/getSimpleRouteJsonFromCircuitJson.ts
5449
5518
  import { getObstaclesFromSoup as getObstaclesFromSoup2 } from "@tscircuit/infgrid-ijump-astar";
5450
- import { su as su2 } from "@tscircuit/soup-util";
5519
+ import { su as su3 } from "@tscircuit/soup-util";
5451
5520
  import {
5452
5521
  getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson2
5453
5522
  } from "circuit-json-to-connectivity-map";
@@ -5479,7 +5548,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
5479
5548
  minTraceWidth = 0.1
5480
5549
  }) => {
5481
5550
  if (!db && circuitJson) {
5482
- db = su2(circuitJson);
5551
+ db = su3(circuitJson);
5483
5552
  }
5484
5553
  if (!db) {
5485
5554
  throw new Error("db or circuitJson is required");
@@ -5498,7 +5567,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
5498
5567
  (e) => !subcircuit_id || "subcircuit_id" in e && relevantSubcircuitIds.has(e.subcircuit_id)
5499
5568
  );
5500
5569
  const board = db.pcb_board.list()[0];
5501
- db = su2(subcircuitElements);
5570
+ db = su3(subcircuitElements);
5502
5571
  const connMap = getFullConnectivityMapFromCircuitJson2(subcircuitElements);
5503
5572
  const obstacles = getObstaclesFromSoup2(
5504
5573
  [
@@ -7354,7 +7423,7 @@ var Switch = class extends NormalComponent {
7354
7423
  };
7355
7424
 
7356
7425
  // lib/RootCircuit.ts
7357
- import { su as su3 } from "@tscircuit/soup-util";
7426
+ import { su as su4 } from "@tscircuit/soup-util";
7358
7427
  import { isValidElement as isValidElement2 } from "react";
7359
7428
  import { identity as identity4 } from "transformation-matrix";
7360
7429
 
@@ -7362,7 +7431,7 @@ import { identity as identity4 } from "transformation-matrix";
7362
7431
  var package_default = {
7363
7432
  name: "@tscircuit/core",
7364
7433
  type: "module",
7365
- version: "0.0.362",
7434
+ version: "0.0.364",
7366
7435
  types: "dist/index.d.ts",
7367
7436
  main: "dist/index.js",
7368
7437
  module: "dist/index.js",
@@ -7419,7 +7488,7 @@ var package_default = {
7419
7488
  "@tscircuit/circuit-json-util": "^0.0.45",
7420
7489
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
7421
7490
  "@tscircuit/math-utils": "^0.0.12",
7422
- "@tscircuit/props": "^0.0.165",
7491
+ "@tscircuit/props": "^0.0.167",
7423
7492
  "@tscircuit/schematic-autolayout": "^0.0.6",
7424
7493
  "@tscircuit/soup-util": "^0.0.41",
7425
7494
  "circuit-json": "^0.0.153",
@@ -7454,7 +7523,7 @@ var RootCircuit = class {
7454
7523
  _hasRenderedAtleastOnce = false;
7455
7524
  constructor() {
7456
7525
  this.children = [];
7457
- this.db = su3([]);
7526
+ this.db = su4([]);
7458
7527
  this.root = this;
7459
7528
  }
7460
7529
  add(componentOrElm) {
@@ -7768,86 +7837,6 @@ var sel = new Proxy(
7768
7837
  }
7769
7838
  );
7770
7839
 
7771
- // lib/utils/edit-events/apply-pcb-edit-events-to-manual-edits-file.ts
7772
- import "zod";
7773
- import { su as su4 } from "@tscircuit/soup-util";
7774
- var applyPcbEditEventsToManualEditsFile = ({
7775
- circuitJson,
7776
- editEvents,
7777
- manualEditsFile
7778
- }) => {
7779
- const updatedManualEditsFile = {
7780
- ...manualEditsFile,
7781
- pcb_placements: [...manualEditsFile.pcb_placements ?? []]
7782
- };
7783
- for (const editEvent of editEvents) {
7784
- if (editEvent.edit_event_type === "edit_pcb_component_location") {
7785
- const { pcb_component_id, new_center } = editEvent;
7786
- const pcb_component = su4(circuitJson).pcb_component.get(pcb_component_id);
7787
- if (!pcb_component) continue;
7788
- const source_component = su4(circuitJson).source_component.get(
7789
- pcb_component.source_component_id
7790
- );
7791
- if (!source_component) continue;
7792
- const existingPlacementIndex = updatedManualEditsFile.pcb_placements?.findIndex(
7793
- (p) => p.selector === source_component.name
7794
- );
7795
- const newPlacement = {
7796
- selector: source_component.name,
7797
- center: new_center,
7798
- relative_to: "group_center"
7799
- };
7800
- if (existingPlacementIndex >= 0) {
7801
- updatedManualEditsFile.pcb_placements[existingPlacementIndex] = newPlacement;
7802
- } else {
7803
- updatedManualEditsFile.pcb_placements.push(newPlacement);
7804
- }
7805
- }
7806
- }
7807
- return updatedManualEditsFile;
7808
- };
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
-
7851
7840
  // lib/index.ts
7852
7841
  import { createElement } from "react";
7853
7842
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.363",
4
+ "version": "0.0.365",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -58,7 +58,7 @@
58
58
  "@tscircuit/circuit-json-util": "^0.0.45",
59
59
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
60
60
  "@tscircuit/math-utils": "^0.0.12",
61
- "@tscircuit/props": "^0.0.165",
61
+ "@tscircuit/props": "^0.0.167",
62
62
  "@tscircuit/schematic-autolayout": "^0.0.6",
63
63
  "@tscircuit/soup-util": "^0.0.41",
64
64
  "circuit-json": "^0.0.153",