@tscircuit/core 0.0.1447 → 0.0.1449
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 +21 -7
- package/dist/index.js +326 -76
- package/package.json +1 -1
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, 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, 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, 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';
|
|
5
5
|
export { kicadFootprintStrings } from '@tscircuit/props';
|
|
6
6
|
import * as react from 'react';
|
|
7
7
|
import react__default, { ReactElement } from 'react';
|
|
@@ -99,8 +99,10 @@ type Obstacle = {
|
|
|
99
99
|
netIsAssignable?: boolean;
|
|
100
100
|
offBoardConnectsTo?: string[];
|
|
101
101
|
};
|
|
102
|
+
/** A connection identifier in Simple Route JSON. */
|
|
103
|
+
type SrjConnectionName = string;
|
|
102
104
|
type SimpleRouteConnection = {
|
|
103
|
-
name:
|
|
105
|
+
name: SrjConnectionName;
|
|
104
106
|
source_trace_id?: string;
|
|
105
107
|
rootConnectionName?: string;
|
|
106
108
|
mergedConnectionNames?: string[];
|
|
@@ -124,7 +126,12 @@ type SimpleRouteConnection = {
|
|
|
124
126
|
/** @deprecated DO NOT USE **/
|
|
125
127
|
externallyConnectedPointIds?: string[][];
|
|
126
128
|
};
|
|
127
|
-
|
|
129
|
+
/** Length-matching constraints for two connections in Simple Route JSON. */
|
|
130
|
+
type SimpleRouteDifferentialPair = {
|
|
131
|
+
connectionNames: [SrjConnectionName, SrjConnectionName];
|
|
132
|
+
lengthTolerance: number;
|
|
133
|
+
};
|
|
134
|
+
type SimpleRouteJson = Omit<SimpleRouteJson$1, "connections" | "traces" | "obstacles" | "bounds" | "outline" | "allowJumpers" | "availableJumperTypes" | "differentialPairs"> & {
|
|
128
135
|
layerCount: number;
|
|
129
136
|
minTraceWidth: number;
|
|
130
137
|
nominalTraceWidth?: number;
|
|
@@ -167,6 +174,7 @@ type SimpleRouteJson = Omit<SimpleRouteJson$1, "connections" | "traces" | "obsta
|
|
|
167
174
|
}>;
|
|
168
175
|
allowJumpers?: boolean;
|
|
169
176
|
availableJumperTypes?: Array<"1206x4" | "0603">;
|
|
177
|
+
differentialPairs?: SimpleRouteDifferentialPair[];
|
|
170
178
|
};
|
|
171
179
|
|
|
172
180
|
type RootCircuitEventName = "asyncEffect:start" | "asyncEffect:end" | "renderable:renderLifecycle:anyEvent" | `renderable:renderLifecycle:${RenderPhase}:start` | `renderable:renderLifecycle:${RenderPhase}:end` | `board:renderPhaseStarted` | "external:evalError" | "autorouting:start" | "autorouting:end" | "autorouting:error" | "autorouting:progress" | "packing:start" | "packing:end" | "packing:error" | "solver:started" | "renderComplete" | "debug:logOutput";
|
|
@@ -88198,6 +88206,13 @@ declare class Fiducial extends PrimitiveComponent<typeof fiducialProps> {
|
|
|
88198
88206
|
}): void;
|
|
88199
88207
|
}
|
|
88200
88208
|
|
|
88209
|
+
/**
|
|
88210
|
+
* Declares the routing constraints for a positive and negative trace pair.
|
|
88211
|
+
*/
|
|
88212
|
+
declare class DifferentialPair extends PrimitiveComponent<typeof differentialPairProps> {
|
|
88213
|
+
get config(): BaseComponentConfig;
|
|
88214
|
+
}
|
|
88215
|
+
|
|
88201
88216
|
declare const pcbTraceProps: z.ZodObject<{
|
|
88202
88217
|
route: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
88203
88218
|
route_type: z.ZodLiteral<"wire">;
|
|
@@ -158928,9 +158943,7 @@ declare const getSimpleRouteJsonFromCircuitJson: ({ db, circuitJson, subcircuit_
|
|
|
158928
158943
|
minBoardEdgeClearance?: number;
|
|
158929
158944
|
minViaHoleDiameter?: number;
|
|
158930
158945
|
minViaPadDiameter?: number;
|
|
158931
|
-
subcircuitComponent?:
|
|
158932
|
-
selectAll(selector: string): unknown[];
|
|
158933
|
-
};
|
|
158946
|
+
subcircuitComponent?: Pick<ISubcircuit, "selectAll">;
|
|
158934
158947
|
/**
|
|
158935
158948
|
* Excludes existing root-level PCB route state from a fresh routing problem.
|
|
158936
158949
|
* Routed child-subcircuit traces and vias remain fixed routing geometry.
|
|
@@ -159138,6 +159151,7 @@ interface TscircuitElements {
|
|
|
159138
159151
|
cadassembly: _tscircuit_props.CadAssemblyProps;
|
|
159139
159152
|
net: _tscircuit_props.NetProps;
|
|
159140
159153
|
trace: _tscircuit_props.TraceProps;
|
|
159154
|
+
differentialpair: _tscircuit_props.DifferentialPairProps;
|
|
159141
159155
|
breakout: _tscircuit_props.BreakoutProps;
|
|
159142
159156
|
breakoutpoint: _tscircuit_props.BreakoutPointProps;
|
|
159143
159157
|
fanout: _tscircuit_props.BreakoutProps;
|
|
@@ -159210,4 +159224,4 @@ declare module "react/jsx-runtime" {
|
|
|
159210
159224
|
}
|
|
159211
159225
|
}
|
|
159212
159226
|
|
|
159213
|
-
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, 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, 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 SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, SolderJumper, type SolverName, type SolverStartedEvent, SpiceModel, 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 };
|
|
159227
|
+
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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(components_exports, {
|
|
|
28
28
|
Crystal: () => Crystal,
|
|
29
29
|
CurrentSource: () => CurrentSource,
|
|
30
30
|
Cutout: () => Cutout,
|
|
31
|
+
DifferentialPair: () => DifferentialPair,
|
|
31
32
|
Diode: () => Diode,
|
|
32
33
|
DrcCheck: () => DrcCheck,
|
|
33
34
|
FabricationNoteDimension: () => FabricationNoteDimension,
|
|
@@ -16258,6 +16259,153 @@ import {
|
|
|
16258
16259
|
getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson3
|
|
16259
16260
|
} from "circuit-json-to-connectivity-map";
|
|
16260
16261
|
|
|
16262
|
+
// lib/components/primitive-components/DifferentialPair.ts
|
|
16263
|
+
import { differentialPairProps } from "@tscircuit/props";
|
|
16264
|
+
var DifferentialPair = class extends PrimitiveComponent2 {
|
|
16265
|
+
get config() {
|
|
16266
|
+
return {
|
|
16267
|
+
componentName: "DifferentialPair",
|
|
16268
|
+
zodProps: differentialPairProps
|
|
16269
|
+
};
|
|
16270
|
+
}
|
|
16271
|
+
};
|
|
16272
|
+
|
|
16273
|
+
// lib/utils/autorouting/getDifferentialPairsForSimpleRouteJson.ts
|
|
16274
|
+
var getDifferentialPairSourceTracesByTraceName = (differentialPairSourceTraces, traceName) => differentialPairSourceTraces.filter(
|
|
16275
|
+
(sourceTrace) => sourceTrace.name === traceName
|
|
16276
|
+
);
|
|
16277
|
+
var getDifferentialPairSourceTracesByPortId = (differentialPairSourceTraces, sourcePortId) => differentialPairSourceTraces.filter(
|
|
16278
|
+
(sourceTrace) => sourceTrace.connected_source_port_ids.includes(sourcePortId)
|
|
16279
|
+
);
|
|
16280
|
+
var getDifferentialPairTraceSubcircuitConnectivityMapKeyOrThrow = ({
|
|
16281
|
+
differentialPair,
|
|
16282
|
+
differentialPairSourceTraces,
|
|
16283
|
+
traceNameOrPortSelector
|
|
16284
|
+
}) => {
|
|
16285
|
+
const differentialPairSubcircuit = differentialPair.getSubcircuit();
|
|
16286
|
+
const sourceTracesWithMatchingName = getDifferentialPairSourceTracesByTraceName(
|
|
16287
|
+
differentialPairSourceTraces,
|
|
16288
|
+
traceNameOrPortSelector
|
|
16289
|
+
);
|
|
16290
|
+
const selectedPort = sourceTracesWithMatchingName.length === 0 ? differentialPairSubcircuit.selectOne(traceNameOrPortSelector, {
|
|
16291
|
+
type: "port"
|
|
16292
|
+
}) : null;
|
|
16293
|
+
const selectedSourcePortId = selectedPort?.source_port_id ?? void 0;
|
|
16294
|
+
const matchingSourceTraces = selectedSourcePortId ? getDifferentialPairSourceTracesByPortId(
|
|
16295
|
+
differentialPairSourceTraces,
|
|
16296
|
+
selectedSourcePortId
|
|
16297
|
+
) : sourceTracesWithMatchingName;
|
|
16298
|
+
if (matchingSourceTraces.length === 0) {
|
|
16299
|
+
throw new Error(
|
|
16300
|
+
`Could not find source trace for trace name or port selector "${traceNameOrPortSelector}" in differential pair "${differentialPair.name}"`
|
|
16301
|
+
);
|
|
16302
|
+
}
|
|
16303
|
+
if (matchingSourceTraces.length > 1) {
|
|
16304
|
+
throw new Error(
|
|
16305
|
+
`Trace name or port selector "${traceNameOrPortSelector}" matches multiple source traces for differential pair "${differentialPair.name}"`
|
|
16306
|
+
);
|
|
16307
|
+
}
|
|
16308
|
+
const sourceTrace = matchingSourceTraces[0];
|
|
16309
|
+
if (!sourceTrace) {
|
|
16310
|
+
throw new Error(
|
|
16311
|
+
`Expected one source trace for trace name or port selector "${traceNameOrPortSelector}" in differential pair "${differentialPair.name}"`
|
|
16312
|
+
);
|
|
16313
|
+
}
|
|
16314
|
+
const subcircuitConnectivityMapKey = sourceTrace.subcircuit_connectivity_map_key;
|
|
16315
|
+
if (!subcircuitConnectivityMapKey) {
|
|
16316
|
+
throw new Error(
|
|
16317
|
+
`Source trace "${sourceTrace.source_trace_id}" does not have a subcircuit connectivity map key for differential pair "${differentialPair.name}"`
|
|
16318
|
+
);
|
|
16319
|
+
}
|
|
16320
|
+
return subcircuitConnectivityMapKey;
|
|
16321
|
+
};
|
|
16322
|
+
var getDifferentialPairSrjConnectionNameOrThrow = ({
|
|
16323
|
+
srjConnections,
|
|
16324
|
+
differentialPairName,
|
|
16325
|
+
differentialPairSourceTraces,
|
|
16326
|
+
traceSubcircuitConnectivityMapKey,
|
|
16327
|
+
traceNameOrPortSelector
|
|
16328
|
+
}) => {
|
|
16329
|
+
const differentialPairSourceTraceIds = [];
|
|
16330
|
+
for (const sourceTrace of differentialPairSourceTraces) {
|
|
16331
|
+
if (sourceTrace.subcircuit_connectivity_map_key === traceSubcircuitConnectivityMapKey) {
|
|
16332
|
+
differentialPairSourceTraceIds.push(sourceTrace.source_trace_id);
|
|
16333
|
+
}
|
|
16334
|
+
}
|
|
16335
|
+
const matchingSrjConnections = [];
|
|
16336
|
+
for (const srjConnection2 of srjConnections) {
|
|
16337
|
+
if (srjConnection2.source_trace_id && differentialPairSourceTraceIds.includes(srjConnection2.source_trace_id)) {
|
|
16338
|
+
matchingSrjConnections.push(srjConnection2);
|
|
16339
|
+
}
|
|
16340
|
+
}
|
|
16341
|
+
if (matchingSrjConnections.length === 0) {
|
|
16342
|
+
throw new Error(
|
|
16343
|
+
`Could not find an SRJ connection for trace name or port selector "${traceNameOrPortSelector}" in differential pair "${differentialPairName}"`
|
|
16344
|
+
);
|
|
16345
|
+
}
|
|
16346
|
+
if (matchingSrjConnections.length > 1) {
|
|
16347
|
+
throw new Error(
|
|
16348
|
+
`Subcircuit connectivity map key "${traceSubcircuitConnectivityMapKey}" matches multiple SRJ connections for differential pair "${differentialPairName}"`
|
|
16349
|
+
);
|
|
16350
|
+
}
|
|
16351
|
+
const srjConnection = matchingSrjConnections[0];
|
|
16352
|
+
if (!srjConnection) {
|
|
16353
|
+
throw new Error(
|
|
16354
|
+
`Expected one SRJ connection for subcircuit connectivity map key "${traceSubcircuitConnectivityMapKey}"`
|
|
16355
|
+
);
|
|
16356
|
+
}
|
|
16357
|
+
return srjConnection.name;
|
|
16358
|
+
};
|
|
16359
|
+
var getDifferentialPairsForSimpleRouteJson = ({
|
|
16360
|
+
srjConnections,
|
|
16361
|
+
differentialPairs,
|
|
16362
|
+
sourceTraces,
|
|
16363
|
+
subcircuitId
|
|
16364
|
+
}) => {
|
|
16365
|
+
const srjDifferentialPairs = [];
|
|
16366
|
+
for (const differentialPair of differentialPairs) {
|
|
16367
|
+
const differentialPairSubcircuitId = differentialPair.getSubcircuit().subcircuit_id;
|
|
16368
|
+
if (subcircuitId && differentialPairSubcircuitId !== subcircuitId) {
|
|
16369
|
+
continue;
|
|
16370
|
+
}
|
|
16371
|
+
const differentialPairSourceTraces = sourceTraces.filter(
|
|
16372
|
+
(sourceTrace) => sourceTrace.subcircuit_id === differentialPairSubcircuitId
|
|
16373
|
+
);
|
|
16374
|
+
const positiveTraceNameOrPortSelector = differentialPair._parsedProps.positiveConnection;
|
|
16375
|
+
const negativeTraceNameOrPortSelector = differentialPair._parsedProps.negativeConnection;
|
|
16376
|
+
const positiveSubcircuitConnectivityMapKey = getDifferentialPairTraceSubcircuitConnectivityMapKeyOrThrow({
|
|
16377
|
+
differentialPair,
|
|
16378
|
+
differentialPairSourceTraces,
|
|
16379
|
+
traceNameOrPortSelector: positiveTraceNameOrPortSelector
|
|
16380
|
+
});
|
|
16381
|
+
const negativeSubcircuitConnectivityMapKey = getDifferentialPairTraceSubcircuitConnectivityMapKeyOrThrow({
|
|
16382
|
+
differentialPair,
|
|
16383
|
+
differentialPairSourceTraces,
|
|
16384
|
+
traceNameOrPortSelector: negativeTraceNameOrPortSelector
|
|
16385
|
+
});
|
|
16386
|
+
const positiveSrjConnectionName = getDifferentialPairSrjConnectionNameOrThrow({
|
|
16387
|
+
srjConnections,
|
|
16388
|
+
differentialPairName: differentialPair.name,
|
|
16389
|
+
differentialPairSourceTraces,
|
|
16390
|
+
traceSubcircuitConnectivityMapKey: positiveSubcircuitConnectivityMapKey,
|
|
16391
|
+
traceNameOrPortSelector: positiveTraceNameOrPortSelector
|
|
16392
|
+
});
|
|
16393
|
+
const negativeSrjConnectionName = getDifferentialPairSrjConnectionNameOrThrow({
|
|
16394
|
+
srjConnections,
|
|
16395
|
+
differentialPairName: differentialPair.name,
|
|
16396
|
+
differentialPairSourceTraces,
|
|
16397
|
+
traceSubcircuitConnectivityMapKey: negativeSubcircuitConnectivityMapKey,
|
|
16398
|
+
traceNameOrPortSelector: negativeTraceNameOrPortSelector
|
|
16399
|
+
});
|
|
16400
|
+
const lengthTolerance = differentialPair._parsedProps.maxLengthSkew ?? 0.1;
|
|
16401
|
+
srjDifferentialPairs.push({
|
|
16402
|
+
connectionNames: [positiveSrjConnectionName, negativeSrjConnectionName],
|
|
16403
|
+
lengthTolerance
|
|
16404
|
+
});
|
|
16405
|
+
}
|
|
16406
|
+
return srjDifferentialPairs.length > 0 ? srjDifferentialPairs : void 0;
|
|
16407
|
+
};
|
|
16408
|
+
|
|
16261
16409
|
// lib/utils/autorouting/getPreservedRoutedSubcircuitTraces.ts
|
|
16262
16410
|
var getPreservedTraceConnectionName = (trace) => trace.source_trace_id ?? trace.connection_name ?? trace.pcb_trace_id;
|
|
16263
16411
|
var getConnectedToIdsForPreservedTrace = ({
|
|
@@ -16833,6 +16981,13 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
16833
16981
|
conn.nominalTraceWidth ??= defaultTraceWidth;
|
|
16834
16982
|
conn.width ??= defaultTraceWidth;
|
|
16835
16983
|
}
|
|
16984
|
+
const differentialPairs = subcircuitComponent?.selectAll("differentialpair") ?? [];
|
|
16985
|
+
const srjDifferentialPairs = getDifferentialPairsForSimpleRouteJson({
|
|
16986
|
+
srjConnections: allConns,
|
|
16987
|
+
differentialPairs,
|
|
16988
|
+
sourceTraces: db.source_trace.list(),
|
|
16989
|
+
subcircuitId: subcircuit_id
|
|
16990
|
+
});
|
|
16836
16991
|
if (subcircuit_id) {
|
|
16837
16992
|
const pointIdToConn = /* @__PURE__ */ new Map();
|
|
16838
16993
|
for (const conn of allConns) {
|
|
@@ -16874,6 +17029,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
16874
17029
|
bounds,
|
|
16875
17030
|
obstacles,
|
|
16876
17031
|
connections: allConns,
|
|
17032
|
+
differentialPairs: srjDifferentialPairs,
|
|
16877
17033
|
traces: preservedRoutedSubcircuitTraces.length > 0 ? preservedRoutedSubcircuitTraces : void 0,
|
|
16878
17034
|
layerCount: board?.num_layers ?? 2,
|
|
16879
17035
|
minTraceWidth: Math.min(
|
|
@@ -22654,7 +22810,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
22654
22810
|
var package_default = {
|
|
22655
22811
|
name: "@tscircuit/core",
|
|
22656
22812
|
type: "module",
|
|
22657
|
-
version: "0.0.
|
|
22813
|
+
version: "0.0.1448",
|
|
22658
22814
|
types: "dist/index.d.ts",
|
|
22659
22815
|
main: "dist/index.js",
|
|
22660
22816
|
module: "dist/index.js",
|
|
@@ -22958,9 +23114,29 @@ function Group_filterSimpleRouteJsonForPhase(simpleRouteJson, phasePlan) {
|
|
|
22958
23114
|
connections.push(connection);
|
|
22959
23115
|
}
|
|
22960
23116
|
}
|
|
23117
|
+
const includedConnectionNames = /* @__PURE__ */ new Set();
|
|
23118
|
+
for (const connection of connections) {
|
|
23119
|
+
includedConnectionNames.add(connection.name);
|
|
23120
|
+
}
|
|
23121
|
+
const differentialPairs = [];
|
|
23122
|
+
for (const differentialPair of simpleRouteJson.differentialPairs ?? []) {
|
|
23123
|
+
const positiveConnectionIncluded = includedConnectionNames.has(
|
|
23124
|
+
differentialPair.connectionNames[0]
|
|
23125
|
+
);
|
|
23126
|
+
const negativeConnectionIncluded = includedConnectionNames.has(
|
|
23127
|
+
differentialPair.connectionNames[1]
|
|
23128
|
+
);
|
|
23129
|
+
if (positiveConnectionIncluded !== negativeConnectionIncluded) {
|
|
23130
|
+
throw new Error(
|
|
23131
|
+
`Differential pair "${differentialPair.connectionNames.join("/")}" cannot be split across autorouting phases`
|
|
23132
|
+
);
|
|
23133
|
+
}
|
|
23134
|
+
if (positiveConnectionIncluded) differentialPairs.push(differentialPair);
|
|
23135
|
+
}
|
|
22961
23136
|
return {
|
|
22962
23137
|
...simpleRouteJson,
|
|
22963
|
-
connections
|
|
23138
|
+
connections,
|
|
23139
|
+
differentialPairs: differentialPairs.length > 0 ? differentialPairs : void 0
|
|
22964
23140
|
};
|
|
22965
23141
|
}
|
|
22966
23142
|
function hasDrcTolerances(drcTolerances) {
|
|
@@ -25565,6 +25741,150 @@ function inflateSourceResistor(sourceElm, inflatorContext) {
|
|
|
25565
25741
|
}
|
|
25566
25742
|
}
|
|
25567
25743
|
|
|
25744
|
+
// lib/components/normal-components/Switch.ts
|
|
25745
|
+
import { switchProps } from "@tscircuit/props";
|
|
25746
|
+
import { frequency, ms } from "circuit-json";
|
|
25747
|
+
function hasSimProps(props) {
|
|
25748
|
+
return props.simSwitchFrequency !== void 0 || props.simCloseAt !== void 0 || props.simOpenAt !== void 0 || props.simStartClosed !== void 0 || props.simStartOpen !== void 0;
|
|
25749
|
+
}
|
|
25750
|
+
var Switch = class extends NormalComponent3 {
|
|
25751
|
+
_getSwitchType() {
|
|
25752
|
+
const props = this._parsedProps;
|
|
25753
|
+
if (!props) return "spst";
|
|
25754
|
+
if (props.dpdt) return "dpdt";
|
|
25755
|
+
if (props.spst) return "spst";
|
|
25756
|
+
if (props.spdt) return "spdt";
|
|
25757
|
+
if (props.dpst) return "dpst";
|
|
25758
|
+
return props.type ?? "spst";
|
|
25759
|
+
}
|
|
25760
|
+
get config() {
|
|
25761
|
+
const switchType = this._getSwitchType();
|
|
25762
|
+
const isNormallyClosed = this._parsedProps?.isNormallyClosed ?? false;
|
|
25763
|
+
const symbolMap = {
|
|
25764
|
+
spst: isNormallyClosed ? "spst_normally_closed_switch" : "spst_switch",
|
|
25765
|
+
spdt: isNormallyClosed ? "spdt_normally_closed_switch" : "spdt_switch",
|
|
25766
|
+
dpst: isNormallyClosed ? "dpst_normally_closed_switch" : "dpst_switch",
|
|
25767
|
+
dpdt: isNormallyClosed ? "dpdt_normally_closed_switch" : "dpdt_switch"
|
|
25768
|
+
};
|
|
25769
|
+
return {
|
|
25770
|
+
componentName: "Switch",
|
|
25771
|
+
schematicSymbolName: this.props.symbolName ?? symbolMap[switchType],
|
|
25772
|
+
zodProps: switchProps,
|
|
25773
|
+
shouldRenderAsSchematicBox: false
|
|
25774
|
+
};
|
|
25775
|
+
}
|
|
25776
|
+
doInitialSourceRender() {
|
|
25777
|
+
const { db } = this.root;
|
|
25778
|
+
const props = this._parsedProps ?? {};
|
|
25779
|
+
const source_component = db.source_component.insert({
|
|
25780
|
+
ftype: "simple_switch",
|
|
25781
|
+
name: this.name,
|
|
25782
|
+
are_pins_interchangeable: this._getSwitchType() === "spst",
|
|
25783
|
+
display_name: props?.displayName
|
|
25784
|
+
});
|
|
25785
|
+
this.source_component_id = source_component.source_component_id;
|
|
25786
|
+
}
|
|
25787
|
+
doInitialSimulationRender() {
|
|
25788
|
+
const { _parsedProps: props } = this;
|
|
25789
|
+
if (!hasSimProps(props)) {
|
|
25790
|
+
return;
|
|
25791
|
+
}
|
|
25792
|
+
const { db } = this.root;
|
|
25793
|
+
const simulationSwitch = {
|
|
25794
|
+
type: "simulation_switch",
|
|
25795
|
+
source_component_id: this.source_component_id || ""
|
|
25796
|
+
};
|
|
25797
|
+
if (props.simSwitchFrequency !== void 0) {
|
|
25798
|
+
simulationSwitch.switching_frequency = frequency.parse(
|
|
25799
|
+
props.simSwitchFrequency
|
|
25800
|
+
);
|
|
25801
|
+
}
|
|
25802
|
+
if (props.simCloseAt !== void 0) {
|
|
25803
|
+
simulationSwitch.closes_at = ms.parse(props.simCloseAt);
|
|
25804
|
+
}
|
|
25805
|
+
if (props.simOpenAt !== void 0) {
|
|
25806
|
+
simulationSwitch.opens_at = ms.parse(props.simOpenAt);
|
|
25807
|
+
}
|
|
25808
|
+
if (props.simStartOpen !== void 0) {
|
|
25809
|
+
simulationSwitch.starts_closed = !props.simStartOpen;
|
|
25810
|
+
}
|
|
25811
|
+
if (props.simStartClosed !== void 0) {
|
|
25812
|
+
simulationSwitch.starts_closed = props.simStartClosed;
|
|
25813
|
+
}
|
|
25814
|
+
db.simulation_switch.insert(simulationSwitch);
|
|
25815
|
+
}
|
|
25816
|
+
};
|
|
25817
|
+
|
|
25818
|
+
// lib/components/primitive-components/Group/Subcircuit/inflators/inflateSourceSwitch.ts
|
|
25819
|
+
var getImportedSwitchProps = (sourceElm, inflatorContext) => {
|
|
25820
|
+
const sourcePorts = inflatorContext.injectionDb.source_port.list().filter(
|
|
25821
|
+
(port) => port.source_component_id === sourceElm.source_component_id
|
|
25822
|
+
);
|
|
25823
|
+
const pinLabels = {};
|
|
25824
|
+
let highestPinNumber = 0;
|
|
25825
|
+
for (const sourcePort of sourcePorts) {
|
|
25826
|
+
const pinNumber = sourcePort.pin_number;
|
|
25827
|
+
if (pinNumber === void 0 || pinNumber === null) continue;
|
|
25828
|
+
highestPinNumber = Math.max(highestPinNumber, pinNumber);
|
|
25829
|
+
const labels = Array.from(
|
|
25830
|
+
new Set(
|
|
25831
|
+
[sourcePort.name, ...sourcePort.port_hints ?? []].filter(
|
|
25832
|
+
(label) => typeof label === "string" && label.length > 0
|
|
25833
|
+
)
|
|
25834
|
+
)
|
|
25835
|
+
);
|
|
25836
|
+
if (labels.length > 0) {
|
|
25837
|
+
pinLabels[`pin${pinNumber}`] = labels;
|
|
25838
|
+
}
|
|
25839
|
+
}
|
|
25840
|
+
let type = "spst";
|
|
25841
|
+
if (highestPinNumber >= 5) type = "dpdt";
|
|
25842
|
+
else if (highestPinNumber === 4) type = "dpst";
|
|
25843
|
+
else if (highestPinNumber === 3) type = "spdt";
|
|
25844
|
+
return {
|
|
25845
|
+
type,
|
|
25846
|
+
pinLabels: Object.keys(pinLabels).length > 0 ? pinLabels : void 0
|
|
25847
|
+
};
|
|
25848
|
+
};
|
|
25849
|
+
function inflateSourceSwitch(sourceElm, inflatorContext) {
|
|
25850
|
+
const { injectionDb, subcircuit, groupsMap } = inflatorContext;
|
|
25851
|
+
const pcbElm = injectionDb.pcb_component.getWhere({
|
|
25852
|
+
source_component_id: sourceElm.source_component_id
|
|
25853
|
+
});
|
|
25854
|
+
const { pcbX, pcbY } = getInflatedPcbPlacement({
|
|
25855
|
+
pcbComponent: pcbElm,
|
|
25856
|
+
sourceGroupId: sourceElm.source_group_id,
|
|
25857
|
+
inflatorContext
|
|
25858
|
+
});
|
|
25859
|
+
const importedSwitchProps = getImportedSwitchProps(sourceElm, inflatorContext);
|
|
25860
|
+
const switchComponent = new Switch({
|
|
25861
|
+
name: sourceElm.name,
|
|
25862
|
+
displayName: sourceElm.display_name,
|
|
25863
|
+
...importedSwitchProps,
|
|
25864
|
+
layer: pcbElm?.layer,
|
|
25865
|
+
pcbX,
|
|
25866
|
+
pcbY,
|
|
25867
|
+
pcbRotation: pcbElm?.rotation,
|
|
25868
|
+
doNotPlace: pcbElm?.do_not_place,
|
|
25869
|
+
obstructsWithinBounds: pcbElm?.obstructs_within_bounds
|
|
25870
|
+
});
|
|
25871
|
+
if (pcbElm) {
|
|
25872
|
+
const footprint = inflateFootprintComponent(pcbElm, {
|
|
25873
|
+
...inflatorContext,
|
|
25874
|
+
normalComponent: switchComponent
|
|
25875
|
+
});
|
|
25876
|
+
if (footprint) {
|
|
25877
|
+
switchComponent.add(footprint);
|
|
25878
|
+
}
|
|
25879
|
+
}
|
|
25880
|
+
if (sourceElm.source_group_id && groupsMap?.has(sourceElm.source_group_id)) {
|
|
25881
|
+
const group = groupsMap.get(sourceElm.source_group_id);
|
|
25882
|
+
group.add(switchComponent);
|
|
25883
|
+
} else {
|
|
25884
|
+
subcircuit.add(switchComponent);
|
|
25885
|
+
}
|
|
25886
|
+
}
|
|
25887
|
+
|
|
25568
25888
|
// lib/utils/pcbTraceRouteToPcbPath.ts
|
|
25569
25889
|
function pcbTraceRouteToPcbPath(route) {
|
|
25570
25890
|
if (route.length <= 2) {
|
|
@@ -25877,6 +26197,9 @@ var inflateCircuitJson = (target, circuitJson, children) => {
|
|
|
25877
26197
|
case "simple_push_button":
|
|
25878
26198
|
inflateSourcePushButton(sourceComponent, inflationCtx);
|
|
25879
26199
|
break;
|
|
26200
|
+
case "simple_switch":
|
|
26201
|
+
inflateSourceSwitch(sourceComponent, inflationCtx);
|
|
26202
|
+
break;
|
|
25880
26203
|
default:
|
|
25881
26204
|
throw new Error(
|
|
25882
26205
|
`No inflator implemented for source component ftype: "${sourceComponent.ftype}"`
|
|
@@ -32210,80 +32533,6 @@ var OpAmp = class extends NormalComponent3 {
|
|
|
32210
32533
|
negative_supply = this.portMap.negative_supply;
|
|
32211
32534
|
};
|
|
32212
32535
|
|
|
32213
|
-
// lib/components/normal-components/Switch.ts
|
|
32214
|
-
import { switchProps } from "@tscircuit/props";
|
|
32215
|
-
import { frequency, ms } from "circuit-json";
|
|
32216
|
-
function hasSimProps(props) {
|
|
32217
|
-
return props.simSwitchFrequency !== void 0 || props.simCloseAt !== void 0 || props.simOpenAt !== void 0 || props.simStartClosed !== void 0 || props.simStartOpen !== void 0;
|
|
32218
|
-
}
|
|
32219
|
-
var Switch = class extends NormalComponent3 {
|
|
32220
|
-
_getSwitchType() {
|
|
32221
|
-
const props = this._parsedProps;
|
|
32222
|
-
if (!props) return "spst";
|
|
32223
|
-
if (props.dpdt) return "dpdt";
|
|
32224
|
-
if (props.spst) return "spst";
|
|
32225
|
-
if (props.spdt) return "spdt";
|
|
32226
|
-
if (props.dpst) return "dpst";
|
|
32227
|
-
return props.type ?? "spst";
|
|
32228
|
-
}
|
|
32229
|
-
get config() {
|
|
32230
|
-
const switchType = this._getSwitchType();
|
|
32231
|
-
const isNormallyClosed = this._parsedProps?.isNormallyClosed ?? false;
|
|
32232
|
-
const symbolMap = {
|
|
32233
|
-
spst: isNormallyClosed ? "spst_normally_closed_switch" : "spst_switch",
|
|
32234
|
-
spdt: isNormallyClosed ? "spdt_normally_closed_switch" : "spdt_switch",
|
|
32235
|
-
dpst: isNormallyClosed ? "dpst_normally_closed_switch" : "dpst_switch",
|
|
32236
|
-
dpdt: isNormallyClosed ? "dpdt_normally_closed_switch" : "dpdt_switch"
|
|
32237
|
-
};
|
|
32238
|
-
return {
|
|
32239
|
-
componentName: "Switch",
|
|
32240
|
-
schematicSymbolName: this.props.symbolName ?? symbolMap[switchType],
|
|
32241
|
-
zodProps: switchProps,
|
|
32242
|
-
shouldRenderAsSchematicBox: false
|
|
32243
|
-
};
|
|
32244
|
-
}
|
|
32245
|
-
doInitialSourceRender() {
|
|
32246
|
-
const { db } = this.root;
|
|
32247
|
-
const props = this._parsedProps ?? {};
|
|
32248
|
-
const source_component = db.source_component.insert({
|
|
32249
|
-
ftype: "simple_switch",
|
|
32250
|
-
name: this.name,
|
|
32251
|
-
are_pins_interchangeable: this._getSwitchType() === "spst",
|
|
32252
|
-
display_name: props?.displayName
|
|
32253
|
-
});
|
|
32254
|
-
this.source_component_id = source_component.source_component_id;
|
|
32255
|
-
}
|
|
32256
|
-
doInitialSimulationRender() {
|
|
32257
|
-
const { _parsedProps: props } = this;
|
|
32258
|
-
if (!hasSimProps(props)) {
|
|
32259
|
-
return;
|
|
32260
|
-
}
|
|
32261
|
-
const { db } = this.root;
|
|
32262
|
-
const simulationSwitch = {
|
|
32263
|
-
type: "simulation_switch",
|
|
32264
|
-
source_component_id: this.source_component_id || ""
|
|
32265
|
-
};
|
|
32266
|
-
if (props.simSwitchFrequency !== void 0) {
|
|
32267
|
-
simulationSwitch.switching_frequency = frequency.parse(
|
|
32268
|
-
props.simSwitchFrequency
|
|
32269
|
-
);
|
|
32270
|
-
}
|
|
32271
|
-
if (props.simCloseAt !== void 0) {
|
|
32272
|
-
simulationSwitch.closes_at = ms.parse(props.simCloseAt);
|
|
32273
|
-
}
|
|
32274
|
-
if (props.simOpenAt !== void 0) {
|
|
32275
|
-
simulationSwitch.opens_at = ms.parse(props.simOpenAt);
|
|
32276
|
-
}
|
|
32277
|
-
if (props.simStartOpen !== void 0) {
|
|
32278
|
-
simulationSwitch.starts_closed = !props.simStartOpen;
|
|
32279
|
-
}
|
|
32280
|
-
if (props.simStartClosed !== void 0) {
|
|
32281
|
-
simulationSwitch.starts_closed = props.simStartClosed;
|
|
32282
|
-
}
|
|
32283
|
-
db.simulation_switch.insert(simulationSwitch);
|
|
32284
|
-
}
|
|
32285
|
-
};
|
|
32286
|
-
|
|
32287
32536
|
// lib/components/normal-components/TestPoint.ts
|
|
32288
32537
|
import { testpointProps } from "@tscircuit/props";
|
|
32289
32538
|
var TESTPOINT_DEFAULTS = {
|
|
@@ -33579,6 +33828,7 @@ export {
|
|
|
33579
33828
|
Crystal,
|
|
33580
33829
|
CurrentSource,
|
|
33581
33830
|
Cutout,
|
|
33831
|
+
DifferentialPair,
|
|
33582
33832
|
Diode,
|
|
33583
33833
|
DrcCheck,
|
|
33584
33834
|
FabricationNoteDimension,
|