@tscircuit/core 0.0.1475 → 0.0.1476

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
- import { PcbTraceError, PcbPlacementError, PcbManualEditConflictWarning, PcbViaClearanceError, LayerRef, AnyCircuitElement, Size, PcbTrace as PcbTrace$1, PcbVia as PcbVia$1, PcbTraceRoutePoint, AnySourceComponent, PcbComponent, SchematicPort, SchematicComponent, PcbSilkscreenGraphic, RouteHintPoint, CircuitJson } from 'circuit-json';
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, internalCircuitProps, 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, 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, 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, internalCircuitProps, 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';
5
5
  export { kicadFootprintStrings } from '@tscircuit/props';
6
6
  import * as react from 'react';
7
7
  import react__default, { ReactElement } from 'react';
@@ -11,10 +11,11 @@ import { z, ZodType } from 'zod';
11
11
  import { symbols, SchSymbol, BaseSymbolName } from 'schematic-symbols';
12
12
  import { CircuitJsonUtilObjects } from '@tscircuit/circuit-json-util';
13
13
  import { Matrix } from 'transformation-matrix';
14
- import { PackSolver2 } from 'calculate-packing';
15
14
  import { AutoroutingPipelineSolver, AssignableAutoroutingPipeline2, AssignableAutoroutingPipeline3, AutoroutingPipeline1_OriginalUnravel, AutoroutingPipelineSolver3_HgPortPointPathing, AutoroutingPipelineSolver4, AutoroutingPipelineSolver5, AutoroutingPipelineSolver8, SimplifiedPcbTrace as SimplifiedPcbTrace$1, SimpleRouteJson as SimpleRouteJson$1 } from '@tscircuit/capacity-autorouter';
16
15
  import { CopperPourPipelineSolver } from '@tscircuit/copper-pour-solver';
16
+ import { CreateFdmEnclosureSolver, EnclosureApertureInput } from '@tscircuit/create-fdm-enclosure';
17
17
  import { SchematicTracePipelineSolver } from '@tscircuit/schematic-trace-solver';
18
+ import { PackSolver2 } from 'calculate-packing';
18
19
  import { Bounds } from '@tscircuit/math-utils';
19
20
  import { ConnectivityMap } from 'circuit-json-to-connectivity-map';
20
21
  import { GraphicsObject } from 'graphics-debug';
@@ -31,6 +32,7 @@ declare const SOLVERS: {
31
32
  AutoroutingPipelineSolver7_MultiGraph: typeof AutoroutingPipelineSolver;
32
33
  AutoroutingPipelineSolver8: typeof AutoroutingPipelineSolver8;
33
34
  CopperPourPipelineSolver: typeof CopperPourPipelineSolver;
35
+ CreateFdmEnclosureSolver: typeof CreateFdmEnclosureSolver;
34
36
  SchematicTracePipelineSolver: typeof SchematicTracePipelineSolver;
35
37
  };
36
38
  type SolverName = keyof typeof SOLVERS;
@@ -6320,7 +6322,7 @@ declare class Subpanel extends Group<typeof subpanelProps> {
6320
6322
  topMargin?: string | number | undefined;
6321
6323
  bottomMargin?: string | number | undefined;
6322
6324
  }>>>;
6323
- }, "width" | "children" | "height" | "layoutMode"> & {
6325
+ }, "width" | "height" | "children" | "layoutMode"> & {
6324
6326
  width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
6325
6327
  height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
6326
6328
  children: zod.ZodOptional<zod.ZodAny>;
@@ -7524,7 +7526,7 @@ declare class Panel extends Subpanel {
7524
7526
  topMargin?: string | number | undefined;
7525
7527
  bottomMargin?: string | number | undefined;
7526
7528
  }>>>;
7527
- }, "width" | "children" | "height" | "layoutMode"> & {
7529
+ }, "width" | "height" | "children" | "layoutMode"> & {
7528
7530
  width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
7529
7531
  height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
7530
7532
  children: zod.ZodOptional<zod.ZodAny>;
@@ -90489,6 +90491,98 @@ declare class Cutout extends PrimitiveComponent<typeof cutoutProps> {
90489
90491
  }): void;
90490
90492
  }
90491
90493
 
90494
+ interface GetFdmEnclosureSolverInputParams {
90495
+ board: Board;
90496
+ pcbBoard: PcbBoard;
90497
+ floorThickness: number;
90498
+ }
90499
+
90500
+ /**
90501
+ * Metadata consumed by enclosure generators. The aperture itself does not emit
90502
+ * Circuit JSON; its nearest ancestor with a pcb_component determines where the
90503
+ * enclosure opening is placed.
90504
+ */
90505
+ declare class EnclosureCutoutAperture extends PrimitiveComponent<typeof enclosureCutoutApertureProps> {
90506
+ get config(): {
90507
+ componentName: string;
90508
+ zodProps: zod.ZodDiscriminatedUnion<"shape", [zod.ZodObject<{
90509
+ shape: zod.ZodLiteral<"pill">;
90510
+ width: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
90511
+ height: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
90512
+ } & {
90513
+ margin: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
90514
+ }, "strip", zod.ZodTypeAny, {
90515
+ shape: "pill";
90516
+ width: number;
90517
+ height: number;
90518
+ margin?: number | undefined;
90519
+ }, {
90520
+ shape: "pill";
90521
+ width: string | number;
90522
+ height: string | number;
90523
+ margin?: string | number | undefined;
90524
+ }>, zod.ZodObject<{
90525
+ shape: zod.ZodLiteral<"rect">;
90526
+ width: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
90527
+ height: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
90528
+ } & {
90529
+ margin: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
90530
+ }, "strip", zod.ZodTypeAny, {
90531
+ shape: "rect";
90532
+ width: number;
90533
+ height: number;
90534
+ margin?: number | undefined;
90535
+ }, {
90536
+ shape: "rect";
90537
+ width: string | number;
90538
+ height: string | number;
90539
+ margin?: string | number | undefined;
90540
+ }>, zod.ZodObject<{
90541
+ shape: zod.ZodLiteral<"circle">;
90542
+ radius: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
90543
+ } & {
90544
+ margin: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
90545
+ }, "strip", zod.ZodTypeAny, {
90546
+ shape: "circle";
90547
+ radius: number;
90548
+ margin?: number | undefined;
90549
+ }, {
90550
+ shape: "circle";
90551
+ radius: string | number;
90552
+ margin?: string | number | undefined;
90553
+ }>]>;
90554
+ };
90555
+ getFdmEnclosureSolverInput(params: GetFdmEnclosureSolverInputParams): EnclosureApertureInput;
90556
+ }
90557
+
90558
+ declare class EnclosureFdmBox extends PrimitiveComponent<typeof enclosureFdmBoxProps> {
90559
+ get config(): {
90560
+ componentName: string;
90561
+ zodProps: zod.ZodObject<{
90562
+ boardRef: zod.ZodString;
90563
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
90564
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
90565
+ depth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
90566
+ wallThickness: zod.ZodDefault<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
90567
+ }, "strip", zod.ZodTypeAny, {
90568
+ boardRef: string;
90569
+ wallThickness: number;
90570
+ width?: number | undefined;
90571
+ height?: number | undefined;
90572
+ depth?: number | undefined;
90573
+ }, {
90574
+ boardRef: string;
90575
+ width?: string | number | undefined;
90576
+ height?: string | number | undefined;
90577
+ depth?: string | number | undefined;
90578
+ wallThickness?: string | number | undefined;
90579
+ }>;
90580
+ };
90581
+ doInitialSourceRender(): void;
90582
+ doInitialPcbComponentRender(): void;
90583
+ doInitialCadModelRender(): void;
90584
+ }
90585
+
90492
90586
  declare class Battery extends NormalComponent<typeof batteryProps, PassivePorts> {
90493
90587
  get config(): {
90494
90588
  componentName: string;
@@ -158042,6 +158136,14 @@ declare class SpiceModel extends PrimitiveComponent<typeof spicemodelProps> {
158042
158136
  private _insertSpiceModelError;
158043
158137
  }
158044
158138
 
158139
+ declare const enclosure: {
158140
+ readonly cutoutaperture: react.FunctionComponent<EnclosureCutoutApertureProps>;
158141
+ readonly fdm: {
158142
+ readonly box: react.FunctionComponent<EnclosureFdmBoxProps>;
158143
+ readonly Box: react.FunctionComponent<EnclosureFdmBoxProps>;
158144
+ };
158145
+ };
158146
+
158045
158147
  declare function resolveStaticFileImport(path: string, platform?: PlatformConfig): Promise<string>;
158046
158148
 
158047
158149
  declare class RootCircuit extends IsolatedCircuit {
@@ -159574,4 +159676,4 @@ declare module "react/jsx-runtime" {
159574
159676
  }
159575
159677
  }
159576
159678
 
159577
- 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, 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, InternalCircuit, InternalCircuitMosfet, 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, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, normalizePinLabels, orderedRenderPhases, renderPhaseIndexMap, resolveStaticFileImport, sel, unrouteCircuitJson, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
159679
+ 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, InternalCircuit, InternalCircuitMosfet, 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 };
package/dist/index.js CHANGED
@@ -31,6 +31,8 @@ __export(components_exports, {
31
31
  DifferentialPair: () => DifferentialPair,
32
32
  Diode: () => Diode,
33
33
  DrcCheck: () => DrcCheck,
34
+ EnclosureCutoutAperture: () => EnclosureCutoutAperture,
35
+ EnclosureFdmBox: () => EnclosureFdmBox,
34
36
  FabricationNoteDimension: () => FabricationNoteDimension,
35
37
  FabricationNotePath: () => FabricationNotePath,
36
38
  FabricationNoteRect: () => FabricationNoteRect,
@@ -15750,12 +15752,11 @@ import Debug14 from "debug";
15750
15752
  import "@tscircuit/capacity-autorouter";
15751
15753
 
15752
15754
  // lib/solvers.ts
15753
- import { PackSolver2 } from "calculate-packing";
15754
15755
  import {
15755
- AutoroutingPipelineSolver,
15756
15756
  AssignableAutoroutingPipeline2,
15757
- AutoroutingPipeline1_OriginalUnravel,
15758
15757
  AssignableAutoroutingPipeline3,
15758
+ AutoroutingPipeline1_OriginalUnravel,
15759
+ AutoroutingPipelineSolver,
15759
15760
  AutoroutingPipelineSolver3_HgPortPointPathing,
15760
15761
  AutoroutingPipelineSolver4,
15761
15762
  AutoroutingPipelineSolver5,
@@ -15763,7 +15764,9 @@ import {
15763
15764
  AutoroutingPipelineSolver8
15764
15765
  } from "@tscircuit/capacity-autorouter";
15765
15766
  import { CopperPourPipelineSolver } from "@tscircuit/copper-pour-solver";
15767
+ import { CreateFdmEnclosureSolver } from "@tscircuit/create-fdm-enclosure";
15766
15768
  import { SchematicTracePipelineSolver } from "@tscircuit/schematic-trace-solver";
15769
+ import { PackSolver2 } from "calculate-packing";
15767
15770
  var SOLVERS = {
15768
15771
  PackSolver2,
15769
15772
  AutoroutingPipelineSolver,
@@ -15776,6 +15779,7 @@ var SOLVERS = {
15776
15779
  AutoroutingPipelineSolver7_MultiGraph,
15777
15780
  AutoroutingPipelineSolver8,
15778
15781
  CopperPourPipelineSolver,
15782
+ CreateFdmEnclosureSolver,
15779
15783
  SchematicTracePipelineSolver
15780
15784
  };
15781
15785
 
@@ -22911,7 +22915,7 @@ function Group_getRoutingPhasePlans(group) {
22911
22915
  var package_default = {
22912
22916
  name: "@tscircuit/core",
22913
22917
  type: "module",
22914
- version: "0.0.1474",
22918
+ version: "0.0.1475",
22915
22919
  types: "dist/index.d.ts",
22916
22920
  main: "dist/index.js",
22917
22921
  module: "dist/index.js",
@@ -22949,6 +22953,7 @@ var package_default = {
22949
22953
  "@tscircuit/circuit-json-util": "^0.0.97",
22950
22954
  "@tscircuit/common": "^0.0.20",
22951
22955
  "@tscircuit/copper-pour-solver": "0.0.39",
22956
+ "@tscircuit/create-fdm-enclosure": "0.0.2",
22952
22957
  "@tscircuit/footprinter": "^0.0.380",
22953
22958
  "@tscircuit/image-utils": "^0.0.8",
22954
22959
  "@tscircuit/infer-cable-insertion-point": "^0.0.2",
@@ -22977,7 +22982,7 @@ var package_default = {
22977
22982
  "circuit-json": "^0.0.450",
22978
22983
  "circuit-json-to-bpc": "^0.0.13",
22979
22984
  "circuit-json-to-connectivity-map": "^0.0.23",
22980
- "circuit-json-to-gltf": "^0.0.105",
22985
+ "circuit-json-to-gltf": "^0.0.107",
22981
22986
  "circuit-json-to-spice": "^0.0.43",
22982
22987
  "circuit-to-svg": "^0.0.391",
22983
22988
  concurrently: "^9.1.2",
@@ -23006,6 +23011,7 @@ var package_default = {
23006
23011
  "@tscircuit/capacity-autorouter": "*",
23007
23012
  "@tscircuit/checks": "*",
23008
23013
  "@tscircuit/circuit-json-util": "*",
23014
+ "@tscircuit/create-fdm-enclosure": "*",
23009
23015
  "@tscircuit/footprinter": "*",
23010
23016
  "@tscircuit/infgrid-ijump-astar": "*",
23011
23017
  "@tscircuit/math-utils": "*",
@@ -31653,6 +31659,228 @@ var CopperPour = class extends PrimitiveComponent2 {
31653
31659
  }
31654
31660
  };
31655
31661
 
31662
+ // lib/components/primitive-components/EnclosureCutoutAperture/EnclosureCutoutAperture.ts
31663
+ import { enclosureCutoutApertureProps } from "@tscircuit/props";
31664
+
31665
+ // lib/components/primitive-components/EnclosureCutoutAperture/get-aperture-height.ts
31666
+ var getApertureHeight = (aperture) => {
31667
+ const margin = aperture.margin ?? 0;
31668
+ return aperture.shape === "circle" ? 2 * (aperture.radius + margin) : aperture.height + margin * 2;
31669
+ };
31670
+
31671
+ // lib/components/primitive-components/EnclosureCutoutAperture/get-nearest-board-wall.ts
31672
+ var getNearestBoardWall = ({
31673
+ point: point6,
31674
+ board
31675
+ }) => {
31676
+ const halfWidth = (board.width ?? 0) / 2;
31677
+ const halfHeight = (board.height ?? 0) / 2;
31678
+ const distances = [
31679
+ ["left", Math.abs(point6.x - (board.center.x - halfWidth))],
31680
+ ["right", Math.abs(point6.x - (board.center.x + halfWidth))],
31681
+ ["front", Math.abs(point6.y - (board.center.y - halfHeight))],
31682
+ ["back", Math.abs(point6.y - (board.center.y + halfHeight))]
31683
+ ];
31684
+ distances.sort((a, b) => a[1] - b[1]);
31685
+ return distances[0][0];
31686
+ };
31687
+
31688
+ // lib/components/primitive-components/EnclosureCutoutAperture/get-solver-wall.ts
31689
+ var getSolverWall = (boardWall) => {
31690
+ if (boardWall === "front") return "back";
31691
+ if (boardWall === "back") return "front";
31692
+ return boardWall;
31693
+ };
31694
+
31695
+ // lib/components/primitive-components/EnclosureCutoutAperture/get-fdm-enclosure-solver-input.ts
31696
+ var getFdmEnclosureSolverInput = (apertureComponent, { board, pcbBoard, floorThickness }) => {
31697
+ let owner = apertureComponent.parent;
31698
+ while (owner && owner !== board && !owner.pcb_component_id) {
31699
+ owner = owner.parent;
31700
+ }
31701
+ const pcbComponent = owner?.pcb_component_id ? apertureComponent.root?.db.pcb_component.get(owner.pcb_component_id) : null;
31702
+ if (!pcbComponent) {
31703
+ throw new Error(
31704
+ "<enclosure.cutoutaperture /> must be nested inside a component with a PCB footprint"
31705
+ );
31706
+ }
31707
+ const point6 = pcbComponent.cable_insertion_center ?? pcbComponent.center;
31708
+ const boardWall = getNearestBoardWall({ point: point6, board: pcbBoard });
31709
+ const aperture = apertureComponent._parsedProps;
31710
+ const commonInput = {
31711
+ wall: getSolverWall(boardWall),
31712
+ offset: boardWall === "left" || boardWall === "right" ? -(point6.y - pcbBoard.center.y) : point6.x - pcbBoard.center.x,
31713
+ centerZ: floorThickness + (pcbBoard.thickness ?? board.boardThickness) + getApertureHeight(aperture) / 2,
31714
+ margin: aperture.margin
31715
+ };
31716
+ switch (aperture.shape) {
31717
+ case "pill":
31718
+ case "rect":
31719
+ return {
31720
+ ...commonInput,
31721
+ shape: aperture.shape,
31722
+ width: aperture.width,
31723
+ height: aperture.height
31724
+ };
31725
+ case "circle":
31726
+ return {
31727
+ ...commonInput,
31728
+ shape: "circle",
31729
+ radius: aperture.radius
31730
+ };
31731
+ }
31732
+ };
31733
+
31734
+ // lib/components/primitive-components/EnclosureCutoutAperture/EnclosureCutoutAperture.ts
31735
+ var EnclosureCutoutAperture = class extends PrimitiveComponent2 {
31736
+ get config() {
31737
+ return {
31738
+ componentName: "EnclosureCutoutAperture",
31739
+ zodProps: enclosureCutoutApertureProps
31740
+ };
31741
+ }
31742
+ getFdmEnclosureSolverInput(params) {
31743
+ return getFdmEnclosureSolverInput(this, params);
31744
+ }
31745
+ };
31746
+
31747
+ // lib/components/primitive-components/EnclosureFdmBox.ts
31748
+ import { enclosureFdmBoxProps } from "@tscircuit/props";
31749
+
31750
+ // lib/components/primitive-components/EnclosureFdmBox_doInitialCadModelRender.ts
31751
+ import {
31752
+ CreateFdmEnclosureSolver as CreateFdmEnclosureSolver2
31753
+ } from "@tscircuit/create-fdm-enclosure";
31754
+
31755
+ // lib/components/primitive-components/get-referenced-enclosure-board.ts
31756
+ import { selectOne as selectOne2 } from "css-select";
31757
+ var getReferencedEnclosureBoard = (component, boardRef) => {
31758
+ const rootComponent = component.root?.firstChild;
31759
+ const selectedComponent = rootComponent ? selectOne2(boardRef, rootComponent, {
31760
+ adapter: cssSelectPrimitiveComponentAdapter
31761
+ }) : null;
31762
+ const board = selectedComponent instanceof Board ? selectedComponent : [rootComponent, ...rootComponent?.getDescendants() ?? []].find(
31763
+ (descendant) => descendant instanceof Board && descendant.isMatchingNameOrAlias(boardRef)
31764
+ );
31765
+ if (!(board instanceof Board)) {
31766
+ throw new Error(
31767
+ `Could not find a <board /> matching enclosure boardRef "${boardRef}"`
31768
+ );
31769
+ }
31770
+ return board;
31771
+ };
31772
+
31773
+ // lib/components/primitive-components/EnclosureFdmBox_doInitialCadModelRender.ts
31774
+ var EnclosureFdmBox_doInitialCadModelRender = (component) => {
31775
+ const root = component.root;
31776
+ if (!root || root.pcbDisabled || !component.source_component_id || !component.pcb_component_id) {
31777
+ return;
31778
+ }
31779
+ const { db } = root;
31780
+ const props = component._parsedProps;
31781
+ const board = getReferencedEnclosureBoard(component, props.boardRef);
31782
+ const pcbBoard = board.pcb_board_id ? db.pcb_board.get(board.pcb_board_id) : null;
31783
+ if (!pcbBoard?.width || !pcbBoard.height) {
31784
+ throw new Error(
31785
+ `Could not resolve dimensions for boardRef "${props.boardRef}"`
31786
+ );
31787
+ }
31788
+ const boardThickness = pcbBoard.thickness ?? board.boardThickness;
31789
+ const inputProblem = {
31790
+ board: {
31791
+ width: pcbBoard.width,
31792
+ height: pcbBoard.height,
31793
+ thickness: boardThickness
31794
+ },
31795
+ width: props.width,
31796
+ height: props.height,
31797
+ depth: props.depth,
31798
+ wallThickness: props.wallThickness,
31799
+ apertures: board.getDescendants().filter(
31800
+ (descendant) => descendant instanceof EnclosureCutoutAperture
31801
+ ).map(
31802
+ (aperture) => aperture.getFdmEnclosureSolverInput({
31803
+ board,
31804
+ pcbBoard,
31805
+ floorThickness: props.wallThickness
31806
+ })
31807
+ )
31808
+ };
31809
+ const solver = new CreateFdmEnclosureSolver2(inputProblem);
31810
+ root.emit("solver:started", {
31811
+ type: "solver:started",
31812
+ solverName: "CreateFdmEnclosureSolver",
31813
+ solverParams: solver.getConstructorParams()[0],
31814
+ componentName: component.getString()
31815
+ });
31816
+ solver.solve();
31817
+ if (solver.failed) {
31818
+ throw new Error(solver.error ?? "Failed to create FDM enclosure");
31819
+ }
31820
+ const output = solver.getOutput();
31821
+ db.pcb_component.update(component.pcb_component_id, {
31822
+ center: pcbBoard.center,
31823
+ width: output.dimensions.width,
31824
+ height: output.dimensions.height
31825
+ });
31826
+ const cadComponent = db.cad_component.insert({
31827
+ position: {
31828
+ x: pcbBoard.center.x,
31829
+ y: pcbBoard.center.y,
31830
+ z: -boardThickness / 2 - output.dimensions.floorThickness
31831
+ },
31832
+ rotation: { x: 0, y: 0, z: 0 },
31833
+ pcb_component_id: component.pcb_component_id,
31834
+ source_component_id: component.source_component_id,
31835
+ model_jscad: output.jscadPlan,
31836
+ model_unit_to_mm_scale_factor: 1,
31837
+ model_object_fit: "contain_within_bounds",
31838
+ model_origin_alignment: "bottom_center_of_component",
31839
+ anchor_alignment: "center",
31840
+ show_as_translucent_model: false
31841
+ });
31842
+ component.cad_component_id = cadComponent.cad_component_id;
31843
+ };
31844
+
31845
+ // lib/components/primitive-components/EnclosureFdmBox.ts
31846
+ var EnclosureFdmBox = class extends PrimitiveComponent2 {
31847
+ get config() {
31848
+ return {
31849
+ componentName: "EnclosureFdmBox",
31850
+ zodProps: enclosureFdmBoxProps
31851
+ };
31852
+ }
31853
+ doInitialSourceRender() {
31854
+ const sourceComponent = this.root.db.source_component.insert({
31855
+ ftype: "simple_chip",
31856
+ name: this.name
31857
+ });
31858
+ this.source_component_id = sourceComponent.source_component_id;
31859
+ }
31860
+ doInitialPcbComponentRender() {
31861
+ const root = this.root;
31862
+ if (!root || root.pcbDisabled || !this.source_component_id) return;
31863
+ const board = getReferencedEnclosureBoard(this, this._parsedProps.boardRef);
31864
+ const pcbBoard = board.pcb_board_id ? root.db.pcb_board.get(board.pcb_board_id) : null;
31865
+ const center = pcbBoard?.center ?? board._getGlobalPcbPositionBeforeLayout();
31866
+ const pcbComponent = root.db.pcb_component.insert({
31867
+ center,
31868
+ width: 0,
31869
+ height: 0,
31870
+ layer: "top",
31871
+ rotation: 0,
31872
+ source_component_id: this.source_component_id,
31873
+ obstructs_within_bounds: false,
31874
+ do_not_place: true,
31875
+ is_allowed_to_be_off_board: true
31876
+ });
31877
+ this.pcb_component_id = pcbComponent.pcb_component_id;
31878
+ }
31879
+ doInitialCadModelRender() {
31880
+ EnclosureFdmBox_doInitialCadModelRender(this);
31881
+ }
31882
+ };
31883
+
31656
31884
  // lib/components/normal-components/Battery.ts
31657
31885
  import { batteryProps } from "@tscircuit/props";
31658
31886
  var Battery = class extends NormalComponent3 {
@@ -33706,6 +33934,26 @@ var SpiceModel = class extends PrimitiveComponent2 {
33706
33934
  }
33707
33935
  };
33708
33936
 
33937
+ // lib/namespaced-elements/create-namespaced-element.ts
33938
+ import { createElement } from "react";
33939
+ var createNamespacedElement = (hostType) => {
33940
+ const Component2 = (props) => createElement(hostType, props);
33941
+ Component2.displayName = hostType;
33942
+ return Component2;
33943
+ };
33944
+
33945
+ // lib/namespaced-elements/enclosure.ts
33946
+ var EnclosureFdmBoxElement = createNamespacedElement("enclosure.fdm.box");
33947
+ var enclosure = {
33948
+ cutoutaperture: createNamespacedElement(
33949
+ "enclosure.cutoutaperture"
33950
+ ),
33951
+ fdm: {
33952
+ box: EnclosureFdmBoxElement,
33953
+ Box: EnclosureFdmBoxElement
33954
+ }
33955
+ };
33956
+
33709
33957
  // lib/RootCircuit.ts
33710
33958
  var RootCircuit = class extends IsolatedCircuit {
33711
33959
  isRootCircuit = true;
@@ -33924,13 +34172,15 @@ var sel = new Proxy(
33924
34172
  );
33925
34173
 
33926
34174
  // lib/index.ts
33927
- import { createElement } from "react";
34175
+ import { createElement as createElement2 } from "react";
33928
34176
  import { kicadFootprintStrings } from "@tscircuit/props";
33929
34177
 
33930
34178
  // lib/register-catalogue.ts
33931
34179
  extendCatalogue(components_exports);
33932
34180
  extendCatalogue({
33933
34181
  Bug: Chip,
34182
+ "enclosure.cutoutaperture": EnclosureCutoutAperture,
34183
+ "enclosure.fdm.box": EnclosureFdmBox,
33934
34184
  Fanout: Breakout,
33935
34185
  FanoutPoint: BreakoutPoint
33936
34186
  });
@@ -33963,6 +34213,8 @@ export {
33963
34213
  DifferentialPair,
33964
34214
  Diode,
33965
34215
  DrcCheck,
34216
+ EnclosureCutoutAperture,
34217
+ EnclosureFdmBox,
33966
34218
  FabricationNoteDimension,
33967
34219
  FabricationNotePath,
33968
34220
  FabricationNoteRect,
@@ -34046,8 +34298,9 @@ export {
34046
34298
  applyEditEventsToManualEditsFile,
34047
34299
  applyPcbEditEventsToManualEditsFile,
34048
34300
  applySchematicEditEventsToManualEditsFile,
34049
- createElement,
34301
+ createElement2 as createElement,
34050
34302
  createUseComponent,
34303
+ enclosure,
34051
34304
  getPhaseTimingsFromRenderEvents,
34052
34305
  getSimpleRouteJsonFromCircuitJson,
34053
34306
  kicadFootprintStrings,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1475",
4
+ "version": "0.0.1476",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -39,6 +39,7 @@
39
39
  "@tscircuit/circuit-json-util": "^0.0.97",
40
40
  "@tscircuit/common": "^0.0.20",
41
41
  "@tscircuit/copper-pour-solver": "0.0.39",
42
+ "@tscircuit/create-fdm-enclosure": "0.0.2",
42
43
  "@tscircuit/footprinter": "^0.0.380",
43
44
  "@tscircuit/image-utils": "^0.0.8",
44
45
  "@tscircuit/infer-cable-insertion-point": "^0.0.2",
@@ -67,7 +68,7 @@
67
68
  "circuit-json": "^0.0.450",
68
69
  "circuit-json-to-bpc": "^0.0.13",
69
70
  "circuit-json-to-connectivity-map": "^0.0.23",
70
- "circuit-json-to-gltf": "^0.0.105",
71
+ "circuit-json-to-gltf": "^0.0.107",
71
72
  "circuit-json-to-spice": "^0.0.43",
72
73
  "circuit-to-svg": "^0.0.391",
73
74
  "concurrently": "^9.1.2",
@@ -96,6 +97,7 @@
96
97
  "@tscircuit/capacity-autorouter": "*",
97
98
  "@tscircuit/checks": "*",
98
99
  "@tscircuit/circuit-json-util": "*",
100
+ "@tscircuit/create-fdm-enclosure": "*",
99
101
  "@tscircuit/footprinter": "*",
100
102
  "@tscircuit/infgrid-ijump-astar": "*",
101
103
  "@tscircuit/math-utils": "*",