@tscircuit/core 0.0.1499 → 0.0.1501

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, PcbViaClearanceError, LayerRef, AnyCircuitElement, Size, PcbTrace as PcbTrace$1, PcbVia as PcbVia$1, PcbTraceRoutePoint, AnySourceComponent, PcbComponent, SchematicPort, SchematicComponent, PcbSilkscreenGraphic, RouteHintPoint, PcbBoard, CircuitJson } from 'circuit-json';
3
3
  import * as _tscircuit_props from '@tscircuit/props';
4
- import { PlatformConfig, traceProps, netProps, AutorouterProp, AutoroutingPhaseProps, subcircuitGroupProps, AutorouterConfig, PcbSx, portProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, ammeterProps, resistorProps, constraintProps, drcCheckProps, autoroutingPhaseProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, silkscreenGraphicProps, smtPadProps, fiducialProps, differentialPairProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, enclosureCutoutApertureProps, enclosureFdmBoxProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, CrystalPinLabels, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicSectionProps, schematicSheetProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, spicemodelProps, EnclosureCutoutApertureProps, EnclosureFdmBoxProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
4
+ import { PlatformConfig, traceProps, netProps, AutorouterProp, AutoroutingPhaseProps, subcircuitGroupProps, AutorouterConfig, PcbSx, portProps, SupplierPartNumbers, CadModelProp, SchematicPortArrangement, groupProps, boardProps, subcircuitProps, subpanelProps, capacitorProps, chipProps, pinoutProps, diodeProps, fuseProps, jumperProps, interconnectProps, solderjumperProps, ledProps, powerSourceProps, voltageSourceProps, currentSourceProps, ammeterProps, resistorProps, constraintProps, drcCheckProps, autoroutingPhaseProps, fabricationNoteRectProps, fabricationNotePathProps, fabricationNoteTextProps, fabricationNoteDimensionProps, pcbNoteLineProps, pcbNoteRectProps, pcbNoteTextProps, pcbNotePathProps, pcbNoteDimensionProps, footprintProps, breakoutProps, breakoutPointProps, holeProps, pcbKeepoutProps, netLabelProps, cadmodelProps, cadassemblyProps, platedHoleProps, courtyardCircleProps, courtyardOutlineProps, courtyardRectProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, silkscreenLineProps, silkscreenGraphicProps, smtPadProps, fiducialProps, differentialPairProps, traceHintProps, viaProps, copperPourProps, copperTextProps, cutoutProps, enclosureCutoutApertureProps, enclosureFdmBoxProps, batteryProps, pinHeaderProps, resonatorProps, inductorProps, potentiometerProps, pushButtonProps, crystalProps, CrystalPinLabels, transistorProps, mosfetProps, opampProps, OpAmpPinLabels, switchProps, SwitchProps, testpointProps, schematicTextProps, schematicLineProps, schematicRectProps, schematicArcProps, schematicCircleProps, schematicPathProps, schematicBoxProps, schematicSymbolProps, schematicSectionProps, schematicSheetProps, schematicTableProps, schematicRowProps, schematicCellProps, symbolProps, analogSimulationProps, voltageProbeProps, spicemodelProps, EnclosureCutoutApertureProps, EnclosureFdmBoxProps, CapacitorProps, ChipProps, DiodeProps, ResistorProps, ManualEditEvent, ManualEditsFile, ChipConnections, manual_edits_file } from '@tscircuit/props';
5
5
  export { kicadFootprintStrings } from '@tscircuit/props';
6
6
  import * as react from 'react';
7
7
  import react__default, { ReactElement } from 'react';
@@ -153017,6 +153017,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153017
153017
  }>>;
153018
153018
  schX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
153019
153019
  schY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
153020
+ schSectionName: zod.ZodOptional<zod.ZodString>;
153020
153021
  schSheetName: zod.ZodOptional<zod.ZodString>;
153021
153022
  width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
153022
153023
  height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
@@ -153041,6 +153042,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153041
153042
  name?: string | undefined;
153042
153043
  schX?: number | undefined;
153043
153044
  schY?: number | undefined;
153045
+ schSectionName?: string | undefined;
153044
153046
  schSheetName?: string | undefined;
153045
153047
  padding?: number | undefined;
153046
153048
  paddingLeft?: number | undefined;
@@ -153085,6 +153087,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153085
153087
  name?: string | undefined;
153086
153088
  schX?: string | number | undefined;
153087
153089
  schY?: string | number | undefined;
153090
+ schSectionName?: string | undefined;
153088
153091
  schSheetName?: string | undefined;
153089
153092
  padding?: string | number | undefined;
153090
153093
  paddingLeft?: string | number | undefined;
@@ -153135,6 +153138,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153135
153138
  name?: string | undefined;
153136
153139
  schX?: number | undefined;
153137
153140
  schY?: number | undefined;
153141
+ schSectionName?: string | undefined;
153138
153142
  schSheetName?: string | undefined;
153139
153143
  padding?: number | undefined;
153140
153144
  paddingLeft?: number | undefined;
@@ -153179,6 +153183,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153179
153183
  name?: string | undefined;
153180
153184
  schX?: string | number | undefined;
153181
153185
  schY?: string | number | undefined;
153186
+ schSectionName?: string | undefined;
153182
153187
  schSheetName?: string | undefined;
153183
153188
  padding?: string | number | undefined;
153184
153189
  paddingLeft?: string | number | undefined;
@@ -153229,6 +153234,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153229
153234
  name?: string | undefined;
153230
153235
  schX?: number | undefined;
153231
153236
  schY?: number | undefined;
153237
+ schSectionName?: string | undefined;
153232
153238
  schSheetName?: string | undefined;
153233
153239
  padding?: number | undefined;
153234
153240
  paddingLeft?: number | undefined;
@@ -153273,6 +153279,7 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153273
153279
  name?: string | undefined;
153274
153280
  schX?: string | number | undefined;
153275
153281
  schY?: string | number | undefined;
153282
+ schSectionName?: string | undefined;
153276
153283
  schSheetName?: string | undefined;
153277
153284
  padding?: string | number | undefined;
153278
153285
  paddingLeft?: string | number | undefined;
@@ -153321,6 +153328,50 @@ declare class SchematicBox extends PrimitiveComponent<typeof schematicBoxProps>
153321
153328
  doInitialSchematicPrimitiveRender(): void;
153322
153329
  }
153323
153330
 
153331
+ declare class SchematicSymbol extends PrimitiveComponent<typeof schematicSymbolProps> {
153332
+ isSchematicPrimitive: boolean;
153333
+ get config(): {
153334
+ componentName: string;
153335
+ schematicSymbolName: string;
153336
+ zodProps: zod.ZodObject<{
153337
+ name: zod.ZodString;
153338
+ displayName: zod.ZodOptional<zod.ZodString>;
153339
+ chipRef: zod.ZodOptional<zod.ZodString>;
153340
+ symbolName: zod.ZodString;
153341
+ connections: zod.ZodOptional<zod.ZodEffects<zod.ZodPipeline<zod.ZodType<Partial<Record<string, string | string[] | readonly string[]>>, zod.ZodTypeDef, Partial<Record<string, string | string[] | readonly string[]>>>, zod.ZodRecord<zod.ZodString, zod.ZodUnion<[zod.ZodUnion<[zod.ZodString, zod.ZodReadonly<zod.ZodArray<zod.ZodString, "many">>]>, zod.ZodArray<zod.ZodString, "many">]>>>, Record<string, string | readonly string[] | string[]>, Partial<Record<string, string | string[] | readonly string[]>>>>;
153342
+ schX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
153343
+ schY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
153344
+ schRotation: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
153345
+ schSectionName: zod.ZodOptional<zod.ZodString>;
153346
+ schSheetName: zod.ZodOptional<zod.ZodString>;
153347
+ }, "strip", zod.ZodTypeAny, {
153348
+ name: string;
153349
+ symbolName: string;
153350
+ schX?: number | undefined;
153351
+ schY?: number | undefined;
153352
+ schRotation?: number | undefined;
153353
+ displayName?: string | undefined;
153354
+ schSectionName?: string | undefined;
153355
+ schSheetName?: string | undefined;
153356
+ connections?: Record<string, string | readonly string[] | string[]> | undefined;
153357
+ chipRef?: string | undefined;
153358
+ }, {
153359
+ name: string;
153360
+ symbolName: string;
153361
+ schX?: string | number | undefined;
153362
+ schY?: string | number | undefined;
153363
+ schRotation?: string | number | undefined;
153364
+ displayName?: string | undefined;
153365
+ schSectionName?: string | undefined;
153366
+ schSheetName?: string | undefined;
153367
+ connections?: Partial<Record<string, string | string[] | readonly string[]>> | undefined;
153368
+ chipRef?: string | undefined;
153369
+ }>;
153370
+ };
153371
+ doInitialSourceRender(): void;
153372
+ doInitialSchematicComponentRender(): void;
153373
+ }
153374
+
153324
153375
  declare class SchematicSection extends PrimitiveComponent<typeof schematicSectionProps> {
153325
153376
  isSchematicPrimitive: boolean;
153326
153377
  get config(): {
@@ -159569,6 +159620,7 @@ interface TscircuitElements {
159569
159620
  schematicsheet: _tscircuit_props.SchematicSheetProps;
159570
159621
  via: _tscircuit_props.ViaProps;
159571
159622
  schematicbox: _tscircuit_props.SchematicBoxProps;
159623
+ schematicsymbol: _tscircuit_props.SchematicSymbolProps;
159572
159624
  schematicline: _tscircuit_props.SchematicLineProps;
159573
159625
  schematicrect: _tscircuit_props.SchematicRectProps;
159574
159626
  schematicarc: _tscircuit_props.SchematicArcProps;
@@ -159663,4 +159715,4 @@ declare module "react/jsx-runtime" {
159663
159715
  }
159664
159716
  }
159665
159717
 
159666
- export { Ammeter, AnalogSimulation, type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, AutoroutingPhase, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Breakout, BreakoutPoint, CadAssembly, CadModel, Capacitor, Chip, Circuit, type ComponentWithPins, Connector, Constraint, CopperPour, CopperText, CourtyardCircle, CourtyardOutline, CourtyardRect, Crystal, CurrentSource, Cutout, type DebugLogOutputEvent, DifferentialPair, Diode, DrcCheck, EnclosureCutoutAperture, EnclosureFdmBox, FabricationNoteDimension, FabricationNotePath, FabricationNoteRect, FabricationNoteText, Breakout as Fanout, BreakoutPoint as FanoutPoint, Fiducial, Footprint, Fuse, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IIsolatedCircuit, type IRenderable, type IRootCircuit, Inductor, Interconnect, IsolatedCircuit, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, MountedBoard, Net, NetLabel, NormalComponent, type Obstacle, OpAmp, type PackingEndEvent, type PackingErrorEvent, type PackingStartEvent, Panel, PcbNoteDimension, PcbNoteLine, PcbNotePath, PcbNoteRect, PcbNoteText, PcbTrace, PcbVia, PinHeader, type PinLabelSpec, Pinout, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SOLVERS, SchematicArc, SchematicBox, SchematicCell, SchematicCircle, SchematicLine, SchematicPath, SchematicRect, SchematicRow, SchematicSection, SchematicSheet, SchematicTable, SchematicText, type Sel, SilkscreenCircle, SilkscreenGraphic, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteDifferentialPair, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, SolderJumper, type SolverName, type SolverStartedEvent, SpiceModel, type SrjConnectionName, Subcircuit, Subpanel, Switch, SymbolComponent as Symbol, TestPoint, Trace, TraceHint, Transistor, Via, VoltageProbe, VoltageSource, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, enclosure, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, renderPhaseIndexMap, resolveStaticFileImport, sel, unrouteCircuitJson, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
159718
+ export { Ammeter, AnalogSimulation, type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, AutoroutingPhase, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Breakout, BreakoutPoint, CadAssembly, CadModel, Capacitor, Chip, Circuit, type ComponentWithPins, Connector, Constraint, CopperPour, CopperText, CourtyardCircle, CourtyardOutline, CourtyardRect, Crystal, CurrentSource, Cutout, type DebugLogOutputEvent, DifferentialPair, Diode, DrcCheck, EnclosureCutoutAperture, EnclosureFdmBox, FabricationNoteDimension, FabricationNotePath, FabricationNoteRect, FabricationNoteText, Breakout as Fanout, BreakoutPoint as FanoutPoint, Fiducial, Footprint, Fuse, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IIsolatedCircuit, type IRenderable, type IRootCircuit, Inductor, Interconnect, IsolatedCircuit, Jumper, Keepout, Led, type LocalCacheEngine, Mosfet, MountedBoard, Net, NetLabel, NormalComponent, type Obstacle, OpAmp, type PackingEndEvent, type PackingErrorEvent, type PackingStartEvent, Panel, PcbNoteDimension, PcbNoteLine, PcbNotePath, PcbNoteRect, PcbNoteText, PcbTrace, PcbVia, PinHeader, type PinLabelSpec, Pinout, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, SOLVERS, SchematicArc, SchematicBox, SchematicCell, SchematicCircle, SchematicLine, SchematicPath, SchematicRect, SchematicRow, SchematicSection, SchematicSheet, SchematicSymbol, SchematicTable, SchematicText, type Sel, SilkscreenCircle, SilkscreenGraphic, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteDifferentialPair, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, SolderJumper, type SolverName, type SolverStartedEvent, SpiceModel, type SrjConnectionName, Subcircuit, Subpanel, Switch, SymbolComponent as Symbol, TestPoint, Trace, TraceHint, Transistor, Via, VoltageProbe, VoltageSource, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, enclosure, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, renderPhaseIndexMap, resolveStaticFileImport, sel, unrouteCircuitJson, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
package/dist/index.js CHANGED
@@ -84,6 +84,7 @@ __export(components_exports, {
84
84
  SchematicRow: () => SchematicRow,
85
85
  SchematicSection: () => SchematicSection,
86
86
  SchematicSheet: () => SchematicSheet,
87
+ SchematicSymbol: () => SchematicSymbol,
87
88
  SchematicTable: () => SchematicTable,
88
89
  SchematicText: () => SchematicText,
89
90
  SilkscreenCircle: () => SilkscreenCircle,
@@ -1048,6 +1049,45 @@ function getResolvedPcbSx({
1048
1049
  return result;
1049
1050
  }
1050
1051
 
1052
+ // lib/utils/schematic/getRotatedSymbolName.ts
1053
+ function rotateDirection(direction, ccwRotationDegrees) {
1054
+ const directions = ["right", "up", "left", "down"];
1055
+ const currentIndex = directions.indexOf(direction);
1056
+ if (currentIndex === -1) return direction;
1057
+ const steps = Math.round(ccwRotationDegrees / 90);
1058
+ const newIndex = (currentIndex + steps) % 4;
1059
+ return directions[newIndex < 0 ? newIndex + 4 : newIndex];
1060
+ }
1061
+ function getRotatedSymbolName(symbolName, ccwRotationDegrees) {
1062
+ if (!symbolName) return symbolName;
1063
+ let rotatedSymbolName = symbolName;
1064
+ const schematicSymbolDirection = rotatedSymbolName.match(
1065
+ /_(right|left|up|down)$/
1066
+ );
1067
+ if (schematicSymbolDirection) {
1068
+ rotatedSymbolName = rotatedSymbolName.replace(
1069
+ schematicSymbolDirection[0],
1070
+ `_${rotateDirection(schematicSymbolDirection[1], ccwRotationDegrees)}`
1071
+ );
1072
+ }
1073
+ const schematicSymbolOrientation = rotatedSymbolName.match(/_(horz|vert)$/);
1074
+ if (schematicSymbolOrientation && shouldSwapOrientation(ccwRotationDegrees)) {
1075
+ rotatedSymbolName = rotatedSymbolName.replace(
1076
+ schematicSymbolOrientation[0],
1077
+ schematicSymbolOrientation[1] === "horz" ? "_vert" : "_horz"
1078
+ );
1079
+ }
1080
+ return rotatedSymbolName;
1081
+ }
1082
+ function shouldSwapOrientation(ccwRotationDegrees) {
1083
+ const normalizedRotation = (Math.round(ccwRotationDegrees) % 360 + 360) % 360;
1084
+ return normalizedRotation === 90 || normalizedRotation === 270;
1085
+ }
1086
+ function getRotatedSize(size, ccwRotationDegrees) {
1087
+ if (!shouldSwapOrientation(ccwRotationDegrees)) return size;
1088
+ return { width: size.height, height: size.width };
1089
+ }
1090
+
1051
1091
  // lib/utils/selector-matching/is-matching-selector.ts
1052
1092
  function isMatchingSelector(component, selector) {
1053
1093
  const idMatch = selector.match(/^#(\w+)/);
@@ -1804,6 +1844,17 @@ var PrimitiveComponent2 = class extends Renderable {
1804
1844
  `Schematic rotation ${props.schRotation} is not supported for ${this.componentName}`
1805
1845
  );
1806
1846
  }
1847
+ const hasOrientationOrDirectionSuffix = /_(horz|vert|up|down|left|right)$/.test(base_symbol_name);
1848
+ if (hasOrientationOrDirectionSuffix && base_symbol_name in symbols) {
1849
+ const rotatedSymbolName = getRotatedSymbolName(
1850
+ base_symbol_name,
1851
+ normalizedRotation
1852
+ );
1853
+ if (rotatedSymbolName && rotatedSymbolName in symbols) {
1854
+ return rotatedSymbolName;
1855
+ }
1856
+ return base_symbol_name;
1857
+ }
1807
1858
  const symbol_name_horz = `${base_symbol_name}_horz`;
1808
1859
  const symbol_name_vert = `${base_symbol_name}_vert`;
1809
1860
  const symbol_name_up = `${base_symbol_name}_up`;
@@ -4568,9 +4619,24 @@ function Trace_doInitialPcbTraceRender(trace) {
4568
4619
 
4569
4620
  // lib/components/primitive-components/Trace/Trace_doInitialSchematicTraceRender.ts
4570
4621
  import { MultilayerIjump as MultilayerIjump2 } from "@tscircuit/infgrid-ijump-astar";
4571
- import "circuit-json";
4572
- import { calculateElbow } from "calculate-elbow";
4573
4622
  import { doesLineIntersectLine as doesLineIntersectLine3 } from "@tscircuit/math-utils";
4623
+ import { calculateElbow } from "calculate-elbow";
4624
+ import "circuit-json";
4625
+
4626
+ // lib/utils/schematic/convertFacingDirectionToElbowDirection.ts
4627
+ var convertFacingDirectionToElbowDirection = (facingDirection) => {
4628
+ switch (facingDirection) {
4629
+ case "up":
4630
+ return "y+";
4631
+ case "down":
4632
+ return "y-";
4633
+ case "left":
4634
+ return "x-";
4635
+ case "right":
4636
+ return "x+";
4637
+ default:
4638
+ }
4639
+ };
4574
4640
 
4575
4641
  // lib/components/primitive-components/Trace/trace-utils/create-schematic-trace-crossing-segments.ts
4576
4642
  import { distance as distance2, doesLineIntersectLine } from "@tscircuit/math-utils";
@@ -5065,21 +5131,6 @@ var pushEdgesOfSchematicTraceToPreventOverlap = ({
5065
5131
  }
5066
5132
  };
5067
5133
 
5068
- // lib/utils/schematic/convertFacingDirectionToElbowDirection.ts
5069
- var convertFacingDirectionToElbowDirection = (facingDirection) => {
5070
- switch (facingDirection) {
5071
- case "up":
5072
- return "y+";
5073
- case "down":
5074
- return "y-";
5075
- case "left":
5076
- return "x-";
5077
- case "right":
5078
- return "x+";
5079
- default:
5080
- }
5081
- };
5082
-
5083
5134
  // lib/components/primitive-components/Trace/Trace_doInitialSchematicTraceRender.ts
5084
5135
  var Trace_doInitialSchematicTraceRender = (trace) => {
5085
5136
  if (trace.root?._featureMspSchematicTraceRouting) return;
@@ -5117,8 +5168,16 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
5117
5168
  });
5118
5169
  if (sheetSchematicPort) return sheetSchematicPort;
5119
5170
  }
5120
- if (!port.schematic_port_id) return null;
5121
- return db.schematic_port.get(port.schematic_port_id) ?? null;
5171
+ if (port.schematic_port_id) {
5172
+ return db.schematic_port.get(port.schematic_port_id) ?? null;
5173
+ }
5174
+ if (!schematicSheetId && port.source_port_id) {
5175
+ const unassignedSchematicPorts = db.schematic_port.list({ source_port_id: port.source_port_id }).filter((schematicPort) => !schematicPort.schematic_sheet_id);
5176
+ if (unassignedSchematicPorts.length === 1) {
5177
+ return unassignedSchematicPorts[0];
5178
+ }
5179
+ }
5180
+ return null;
5122
5181
  };
5123
5182
  const portsWithPosition = connectedPorts.flatMap(({ port }) => {
5124
5183
  const schematicPort = resolveSchematicPortForSheet(port);
@@ -19700,45 +19759,6 @@ import { LayoutPipelineSolver } from "@tscircuit/matchpack";
19700
19759
  import { getBoundFromCenteredRect as getBoundFromCenteredRect2 } from "@tscircuit/math-utils";
19701
19760
  import Debug8 from "debug";
19702
19761
 
19703
- // lib/utils/schematic/getRotatedSymbolName.ts
19704
- function rotateDirection(direction, ccwRotationDegrees) {
19705
- const directions = ["right", "up", "left", "down"];
19706
- const currentIndex = directions.indexOf(direction);
19707
- if (currentIndex === -1) return direction;
19708
- const steps = Math.round(ccwRotationDegrees / 90);
19709
- const newIndex = (currentIndex + steps) % 4;
19710
- return directions[newIndex < 0 ? newIndex + 4 : newIndex];
19711
- }
19712
- function getRotatedSymbolName(symbolName, ccwRotationDegrees) {
19713
- if (!symbolName) return symbolName;
19714
- let rotatedSymbolName = symbolName;
19715
- const schematicSymbolDirection = rotatedSymbolName.match(
19716
- /_(right|left|up|down)$/
19717
- );
19718
- if (schematicSymbolDirection) {
19719
- rotatedSymbolName = rotatedSymbolName.replace(
19720
- schematicSymbolDirection[0],
19721
- `_${rotateDirection(schematicSymbolDirection[1], ccwRotationDegrees)}`
19722
- );
19723
- }
19724
- const schematicSymbolOrientation = rotatedSymbolName.match(/_(horz|vert)$/);
19725
- if (schematicSymbolOrientation && shouldSwapOrientation(ccwRotationDegrees)) {
19726
- rotatedSymbolName = rotatedSymbolName.replace(
19727
- schematicSymbolOrientation[0],
19728
- schematicSymbolOrientation[1] === "horz" ? "_vert" : "_horz"
19729
- );
19730
- }
19731
- return rotatedSymbolName;
19732
- }
19733
- function shouldSwapOrientation(ccwRotationDegrees) {
19734
- const normalizedRotation = (Math.round(ccwRotationDegrees) % 360 + 360) % 360;
19735
- return normalizedRotation === 90 || normalizedRotation === 270;
19736
- }
19737
- function getRotatedSize(size, ccwRotationDegrees) {
19738
- if (!shouldSwapOrientation(ccwRotationDegrees)) return size;
19739
- return { width: size.height, height: size.width };
19740
- }
19741
-
19742
19762
  // lib/utils/schematic/getSchematicComponentWithTextBounds.ts
19743
19763
  import { getBoundFromCenteredRect } from "@tscircuit/math-utils";
19744
19764
  import { symbols as symbols3 } from "schematic-symbols";
@@ -23402,7 +23422,7 @@ function Group_getRoutingPhasePlans(group) {
23402
23422
  var package_default = {
23403
23423
  name: "@tscircuit/core",
23404
23424
  type: "module",
23405
- version: "0.0.1498",
23425
+ version: "0.0.1500",
23406
23426
  types: "dist/index.d.ts",
23407
23427
  main: "dist/index.js",
23408
23428
  module: "dist/index.js",
@@ -23442,7 +23462,7 @@ var package_default = {
23442
23462
  "@tscircuit/common": "^0.0.20",
23443
23463
  "@tscircuit/copper-pour-solver": "0.0.39",
23444
23464
  "@tscircuit/create-fdm-enclosure": "0.0.3",
23445
- "@tscircuit/footprinter": "^0.0.380",
23465
+ "@tscircuit/footprinter": "^0.0.386",
23446
23466
  "@tscircuit/image-utils": "^0.0.8",
23447
23467
  "@tscircuit/infer-cable-insertion-point": "^0.0.2",
23448
23468
  "@tscircuit/infgrid-ijump-astar": "^0.0.35",
@@ -23453,7 +23473,7 @@ var package_default = {
23453
23473
  "@tscircuit/math-utils": "^0.0.36",
23454
23474
  "@tscircuit/miniflex": "^0.0.4",
23455
23475
  "@tscircuit/ngspice-spice-engine": "^0.0.19",
23456
- "@tscircuit/props": "^0.0.589",
23476
+ "@tscircuit/props": "^0.0.591",
23457
23477
  "@tscircuit/schematic-match-adapt": "^0.0.18",
23458
23478
  "@tscircuit/schematic-trace-solver": "^0.0.108",
23459
23479
  "@tscircuit/solver-utils": "^0.0.16",
@@ -33491,6 +33511,185 @@ var TestPoint = class extends NormalComponent3 {
33491
33511
  }
33492
33512
  };
33493
33513
 
33514
+ // lib/components/primitive-components/SchematicSymbol/SchematicSymbol.ts
33515
+ import { schematicSymbolProps } from "@tscircuit/props";
33516
+
33517
+ // lib/components/primitive-components/SchematicSymbol/SchematicSymbol_doInitialSchematicComponentRender.ts
33518
+ import { symbols as symbols7 } from "schematic-symbols";
33519
+ var getDisplayPinLabel = (labels) => labels.find((label) => !/^(pin)?\d+$/.test(label));
33520
+ var getConnectionNamesForSymbolPort = (labels) => {
33521
+ const connectionNames = new Set(labels);
33522
+ const pinNumber = getPinNumberFromLabels(labels);
33523
+ if (pinNumber) connectionNames.add(`pin${pinNumber}`);
33524
+ return [...connectionNames];
33525
+ };
33526
+ var getSingleConnectionTarget = (connectionName, target) => {
33527
+ const targets = Array.isArray(target) ? target : [target];
33528
+ if (targets.length !== 1) {
33529
+ throw new Error(
33530
+ `SchematicSymbol connection "${connectionName}" must select exactly one physical port`
33531
+ );
33532
+ }
33533
+ return targets[0];
33534
+ };
33535
+ var SchematicSymbol_doInitialSchematicComponentRender = (schematicSymbol) => {
33536
+ if (schematicSymbol.root?.schematicDisabled) return;
33537
+ if (schematicSymbol.getCollapsedSchematicBoxAncestor()) return;
33538
+ const { db } = schematicSymbol.root;
33539
+ const symbolName = schematicSymbol._getSchematicSymbolNameOrThrow();
33540
+ const symbol = symbols7[symbolName];
33541
+ if (!symbol) {
33542
+ throw new Error(`No schematic symbol found for "${symbolName}"`);
33543
+ }
33544
+ const { chipRef, connections } = schematicSymbol._parsedProps;
33545
+ if (chipRef && !connections) {
33546
+ db.source_property_ignored_warning.insert({
33547
+ source_component_id: schematicSymbol.source_component_id,
33548
+ property_name: "chipRef",
33549
+ message: `${schematicSymbol.getString()} has chipRef "${chipRef}" without connections. chipRef will be ignored.`,
33550
+ error_type: "source_property_ignored_warning",
33551
+ subcircuit_id: schematicSymbol.getSubcircuit().subcircuit_id ?? void 0
33552
+ });
33553
+ }
33554
+ if (connections && !chipRef) {
33555
+ db.source_property_ignored_warning.insert({
33556
+ source_component_id: schematicSymbol.source_component_id,
33557
+ property_name: "connections",
33558
+ message: `${schematicSymbol.getString()} has connections without chipRef. connections will be ignored.`,
33559
+ error_type: "source_property_ignored_warning",
33560
+ subcircuit_id: schematicSymbol.getSubcircuit().subcircuit_id ?? void 0
33561
+ });
33562
+ }
33563
+ const effectiveChipRef = connections ? chipRef : void 0;
33564
+ const effectiveConnections = chipRef ? connections : void 0;
33565
+ const referencedChip = effectiveChipRef ? schematicSymbol.getSubcircuit().selectOne(effectiveChipRef) : null;
33566
+ if (effectiveChipRef && !referencedChip?.source_component_id) {
33567
+ throw new Error(
33568
+ `Could not resolve chipRef "${effectiveChipRef}" for ${schematicSymbol.getString()}`
33569
+ );
33570
+ }
33571
+ const usedConnectionNames = /* @__PURE__ */ new Set();
33572
+ const referencedSourcePortIds = /* @__PURE__ */ new Map();
33573
+ if (effectiveConnections && referencedChip?.source_component_id) {
33574
+ for (const symbolPort of symbol.ports) {
33575
+ const connectionNames = getConnectionNamesForSymbolPort(symbolPort.labels);
33576
+ const matchingConnections = Object.entries(effectiveConnections).filter(
33577
+ ([connectionName2]) => connectionNames.includes(connectionName2)
33578
+ );
33579
+ if (matchingConnections.length === 0) {
33580
+ throw new Error(
33581
+ `${schematicSymbol.getString()} is missing an explicit connection for symbol port "${symbolPort.labels.join("/")}"`
33582
+ );
33583
+ }
33584
+ if (matchingConnections.length > 1) {
33585
+ throw new Error(
33586
+ `${schematicSymbol.getString()} has multiple connections for symbol port "${symbolPort.labels.join("/")}"`
33587
+ );
33588
+ }
33589
+ const [connectionName, connectionTarget] = matchingConnections[0];
33590
+ usedConnectionNames.add(connectionName);
33591
+ const targetSelector = getSingleConnectionTarget(
33592
+ connectionName,
33593
+ connectionTarget
33594
+ );
33595
+ const referencedPort = schematicSymbol.getSubcircuit().selectOne(targetSelector, { type: "port" });
33596
+ if (!referencedPort?.source_port_id) {
33597
+ throw new Error(
33598
+ `Could not resolve connection "${connectionName}" target "${targetSelector}" for ${schematicSymbol.getString()}`
33599
+ );
33600
+ }
33601
+ const referencedSourcePort = db.source_port.get(
33602
+ referencedPort.source_port_id
33603
+ );
33604
+ if (referencedSourcePort?.source_component_id !== referencedChip.source_component_id) {
33605
+ throw new Error(
33606
+ `Connection "${connectionName}" target "${targetSelector}" does not belong to chipRef "${effectiveChipRef}"`
33607
+ );
33608
+ }
33609
+ referencedSourcePortIds.set(symbolPort, referencedPort.source_port_id);
33610
+ }
33611
+ const unusedConnectionNames = Object.keys(effectiveConnections).filter(
33612
+ (connectionName) => !usedConnectionNames.has(connectionName)
33613
+ );
33614
+ if (unusedConnectionNames.length > 0) {
33615
+ throw new Error(
33616
+ `${schematicSymbol.getString()} has connections that do not match symbol ports: ${unusedConnectionNames.join(", ")}`
33617
+ );
33618
+ }
33619
+ }
33620
+ const center = schematicSymbol._getGlobalSchematicPositionBeforeLayout();
33621
+ const schematicSheetId = schematicSymbol._resolveSchematicSheetId();
33622
+ const subcircuitId = schematicSymbol.getSubcircuit().subcircuit_id ?? void 0;
33623
+ const schematicComponent = db.schematic_component.insert({
33624
+ center,
33625
+ size: { ...symbol.size },
33626
+ is_box_with_pins: true,
33627
+ symbol_name: symbolName,
33628
+ source_component_id: schematicSymbol.source_component_id ?? void 0,
33629
+ schematic_sheet_id: schematicSheetId
33630
+ });
33631
+ schematicSymbol.schematic_component_id = schematicComponent.schematic_component_id;
33632
+ for (const symbolPort of symbol.ports) {
33633
+ const pinNumber = getPinNumberFromLabels(symbolPort.labels);
33634
+ const portName = getDisplayPinLabel(symbolPort.labels) ?? (pinNumber ? `pin${pinNumber}` : symbolPort.labels[0]);
33635
+ if (!portName) continue;
33636
+ const referencedSourcePortId = referencedSourcePortIds.get(symbolPort);
33637
+ const sourcePortId = referencedSourcePortId ?? db.source_port.insert({
33638
+ name: portName,
33639
+ pin_number: pinNumber ? Number(pinNumber) : void 0,
33640
+ port_hints: [...symbolPort.labels],
33641
+ source_component_id: schematicSymbol.source_component_id ?? void 0,
33642
+ subcircuit_id: subcircuitId
33643
+ }).source_port_id;
33644
+ const portCenter = {
33645
+ x: center.x + symbolPort.x - symbol.center.x,
33646
+ y: center.y + symbolPort.y - symbol.center.y
33647
+ };
33648
+ db.schematic_port.insert({
33649
+ schematic_component_id: schematicComponent.schematic_component_id,
33650
+ center: portCenter,
33651
+ source_port_id: sourcePortId,
33652
+ facing_direction: getRelativeDirection(
33653
+ center,
33654
+ portCenter
33655
+ ),
33656
+ distance_from_component_edge: 0.4,
33657
+ pin_number: pinNumber ? Number(pinNumber) : void 0,
33658
+ display_pin_label: getDisplayPinLabel(symbolPort.labels),
33659
+ is_connected: false,
33660
+ schematic_sheet_id: schematicSheetId,
33661
+ subcircuit_id: subcircuitId
33662
+ });
33663
+ }
33664
+ };
33665
+
33666
+ // lib/components/primitive-components/SchematicSymbol/SchematicSymbol.ts
33667
+ var SchematicSymbol = class extends PrimitiveComponent2 {
33668
+ isSchematicPrimitive = true;
33669
+ get config() {
33670
+ return {
33671
+ componentName: "SchematicSymbol",
33672
+ schematicSymbolName: this.props.symbolName,
33673
+ zodProps: schematicSymbolProps
33674
+ };
33675
+ }
33676
+ doInitialSourceRender() {
33677
+ const sourceComponent = this.root.db.source_component.insert({
33678
+ ftype: "simple_chip",
33679
+ name: this.name,
33680
+ are_pins_interchangeable: false
33681
+ });
33682
+ this.source_component_id = sourceComponent.source_component_id;
33683
+ }
33684
+ doInitialSchematicComponentRender() {
33685
+ SchematicSymbol_doInitialSchematicComponentRender(this);
33686
+ }
33687
+ /*
33688
+ * displayName cannot be supported until schematic_component has its own
33689
+ * display_name field. Avoid special-casing schematic rendering for it.
33690
+ */
33691
+ };
33692
+
33494
33693
  // lib/components/primitive-components/SchematicSection.ts
33495
33694
  import {
33496
33695
  calculateCellBoundaries,
@@ -34633,6 +34832,7 @@ export {
34633
34832
  SchematicRow,
34634
34833
  SchematicSection,
34635
34834
  SchematicSheet,
34835
+ SchematicSymbol,
34636
34836
  SchematicTable,
34637
34837
  SchematicText,
34638
34838
  SilkscreenCircle,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1499",
4
+ "version": "0.0.1501",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "@tscircuit/common": "^0.0.20",
42
42
  "@tscircuit/copper-pour-solver": "0.0.39",
43
43
  "@tscircuit/create-fdm-enclosure": "0.0.3",
44
- "@tscircuit/footprinter": "^0.0.380",
44
+ "@tscircuit/footprinter": "^0.0.386",
45
45
  "@tscircuit/image-utils": "^0.0.8",
46
46
  "@tscircuit/infer-cable-insertion-point": "^0.0.2",
47
47
  "@tscircuit/infgrid-ijump-astar": "^0.0.35",
@@ -52,7 +52,7 @@
52
52
  "@tscircuit/math-utils": "^0.0.36",
53
53
  "@tscircuit/miniflex": "^0.0.4",
54
54
  "@tscircuit/ngspice-spice-engine": "^0.0.19",
55
- "@tscircuit/props": "^0.0.589",
55
+ "@tscircuit/props": "^0.0.591",
56
56
  "@tscircuit/schematic-match-adapt": "^0.0.18",
57
57
  "@tscircuit/schematic-trace-solver": "^0.0.108",
58
58
  "@tscircuit/solver-utils": "^0.0.16",