@tscircuit/core 0.0.146 → 0.0.147
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 +60 -39
- package/dist/index.js +749 -763
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as _tscircuit_props from '@tscircuit/props';
|
|
2
|
+
import { traceProps, SchematicPortArrangement, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, inductorProps, CapacitorProps, ChipProps, ResistorProps } from '@tscircuit/props';
|
|
1
3
|
import React, { ReactElement } from 'react';
|
|
2
4
|
import * as zod from 'zod';
|
|
3
5
|
import { ZodType, z } from 'zod';
|
|
@@ -5,8 +7,6 @@ import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
|
|
|
5
7
|
import { PcbTraceError, PcbPlacementError, LayerRef, AnyCircuitElement, AnySourceComponent, RouteHintPoint } from 'circuit-json';
|
|
6
8
|
import { Matrix } from 'transformation-matrix';
|
|
7
9
|
import { SoupUtilObjects } from '@tscircuit/soup-util';
|
|
8
|
-
import * as _tscircuit_props from '@tscircuit/props';
|
|
9
|
-
import { traceProps, groupProps, boardProps, capacitorProps, chipProps, diodeProps, jumperProps, ledProps, powerSourceProps, resistorProps, constraintProps, fabricationNotePathProps, fabricationNoteTextProps, footprintProps, holeProps, pcbKeepoutProps, netAliasProps, platedHoleProps, silkscreenCircleProps, silkscreenPathProps, silkscreenRectProps, silkscreenTextProps, smtPadProps, traceHintProps, viaProps, batteryProps, pinHeaderProps, inductorProps, CapacitorProps, ChipProps, ResistorProps } from '@tscircuit/props';
|
|
10
10
|
import * as _tscircuit_layout from '@tscircuit/layout';
|
|
11
11
|
|
|
12
12
|
declare const orderedRenderPhases: readonly ["ReactSubtreesRender", "InitializePortsFromChildren", "CreateNetsFromProps", "CreateTracesFromProps", "CreateTraceHintsFromProps", "SourceRender", "SourceParentAttachment", "PortDiscovery", "PortMatching", "SourceTraceRender", "SchematicComponentRender", "SchematicPortRender", "SchematicLayout", "SchematicTraceRender", "PcbComponentRender", "PcbPrimitiveRender", "PcbFootprintLayout", "PcbPortRender", "PcbPortAttachment", "PcbLayout", "PcbTraceRender", "PcbTraceHintRender", "PcbRouteNetIslands", "PcbComponentSizeCalculation", "CadModelRender"];
|
|
@@ -111,11 +111,43 @@ interface ISubcircuit extends PrimitiveComponent {
|
|
|
111
111
|
_shouldUseTraceByTraceRouting(): boolean;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
type SchematicBoxPortPositionWithMetadata = {
|
|
115
|
+
trueIndex: number;
|
|
116
|
+
pinNumber: number;
|
|
117
|
+
side: "left" | "right" | "top" | "bottom";
|
|
118
|
+
distanceFromEdge: number;
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Get the dimensions of a schematic box based on the provided parameters.
|
|
124
|
+
*
|
|
125
|
+
* A schematic box is a rectangular box with a set of pins on the sides.
|
|
126
|
+
*
|
|
127
|
+
* The user can customize the position of the pins and the spacing between them,
|
|
128
|
+
* this makes computing the box fairly complicated.
|
|
129
|
+
*
|
|
130
|
+
* A note on the internals:
|
|
131
|
+
* * A "true port" refers to a pin/port before it's remapped by the user to a
|
|
132
|
+
* different position. True Pin 1 is guaranteed to be in the top-left corner
|
|
133
|
+
* * We basically iterate over each side and compute how far we are from the
|
|
134
|
+
* edge for that side by adding margins together
|
|
135
|
+
*/
|
|
136
|
+
interface SchematicBoxDimensions {
|
|
137
|
+
pinCount: number;
|
|
138
|
+
getPortPositionByPinNumber(pinNumber: number): SchematicBoxPortPositionWithMetadata | null;
|
|
139
|
+
getSize(): {
|
|
140
|
+
width: number;
|
|
141
|
+
height: number;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
114
145
|
interface BaseComponentConfig {
|
|
115
146
|
componentName: string;
|
|
116
147
|
schematicSymbolName?: BaseSymbolName | null;
|
|
117
148
|
zodProps: ZodType;
|
|
118
149
|
sourceFtype?: AnySourceComponent["ftype"] | null;
|
|
150
|
+
shouldRenderAsSchematicBox?: boolean;
|
|
119
151
|
}
|
|
120
152
|
/**
|
|
121
153
|
* A PrimitiveComponent (SmtPad, Port etc.) doesn't have the ability to contain
|
|
@@ -271,6 +303,16 @@ declare abstract class PrimitiveComponent<ZodProps extends ZodType = any> extend
|
|
|
271
303
|
}): PrimitiveComponent | null;
|
|
272
304
|
getAvailablePcbLayers(): string[];
|
|
273
305
|
getDescendants(): PrimitiveComponent[];
|
|
306
|
+
/**
|
|
307
|
+
* Return the number of pins in this component, this is important for
|
|
308
|
+
* NormalComponents
|
|
309
|
+
*/
|
|
310
|
+
_getPinCount(): number;
|
|
311
|
+
/**
|
|
312
|
+
* If this component represents a SchematicBox (like a Chip), return the
|
|
313
|
+
* dimensions of the box, which allows computing the position of ports etc.
|
|
314
|
+
*/
|
|
315
|
+
_getSchematicBoxDimensions(): SchematicBoxDimensions | null;
|
|
274
316
|
renderError(message: Parameters<typeof Renderable.prototype.renderError>[0]): void;
|
|
275
317
|
getString(): string;
|
|
276
318
|
get [Symbol.toStringTag](): string;
|
|
@@ -696,11 +738,14 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
|
|
|
696
738
|
doInitialSourceRender(): void;
|
|
697
739
|
/**
|
|
698
740
|
* Render the schematic component for this NormalComponent using the
|
|
699
|
-
* config.schematicSymbolName if it exists
|
|
741
|
+
* config.schematicSymbolName if it exists, or create a generic box if
|
|
742
|
+
* no symbol is defined.
|
|
700
743
|
*
|
|
701
744
|
* You can override this method to do more complicated things.
|
|
702
745
|
*/
|
|
703
746
|
doInitialSchematicComponentRender(): void;
|
|
747
|
+
_doInitialSchematicComponentRenderWithSymbol(): void;
|
|
748
|
+
_doInitialSchematicComponentRenderWithSchematicBoxDimensions(): void;
|
|
704
749
|
doInitialPcbComponentRender(): void;
|
|
705
750
|
/**
|
|
706
751
|
* At this stage, the smtpads/pcb primitives are placed, so we can compute
|
|
@@ -739,6 +784,13 @@ declare class NormalComponent<ZodProps extends ZodType = any, PortNames extends
|
|
|
739
784
|
width: number;
|
|
740
785
|
height: number;
|
|
741
786
|
};
|
|
787
|
+
_getPinCount(): number;
|
|
788
|
+
/**
|
|
789
|
+
* Override the schematic port arrangement if you want to customize where pins
|
|
790
|
+
* appear on a schematic box, e.g. for a pin header
|
|
791
|
+
*/
|
|
792
|
+
_getSchematicPortArrangement(): SchematicPortArrangement | null;
|
|
793
|
+
_getSchematicBoxDimensions(): SchematicBoxDimensions | null;
|
|
742
794
|
doInitialCadModelRender(): void;
|
|
743
795
|
}
|
|
744
796
|
|
|
@@ -1310,39 +1362,8 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
|
|
|
1310
1362
|
doInitialSourceRender(): void;
|
|
1311
1363
|
}
|
|
1312
1364
|
|
|
1313
|
-
type PortInfo = {
|
|
1314
|
-
trueIndex: number;
|
|
1315
|
-
pinNumber: number;
|
|
1316
|
-
side: "left" | "right" | "top" | "bottom" | "center";
|
|
1317
|
-
distanceFromEdge: number;
|
|
1318
|
-
x: number;
|
|
1319
|
-
y: number;
|
|
1320
|
-
};
|
|
1321
|
-
/**
|
|
1322
|
-
* Get the dimensions of a schematic box based on the provided parameters.
|
|
1323
|
-
*
|
|
1324
|
-
* A schematic box is a rectangular box with a set of pins on the sides.
|
|
1325
|
-
*
|
|
1326
|
-
* The user can customize the position of the pins and the spacing between them,
|
|
1327
|
-
* this makes computing the box fairly complicated.
|
|
1328
|
-
*
|
|
1329
|
-
* A note on the internals:
|
|
1330
|
-
* * A "true port" refers to a pin/port before it's remapped by the user to a
|
|
1331
|
-
* different position. True Pin 1 is guaranteed to be in the top-left corner
|
|
1332
|
-
* * We basically iterate over each side and compute how far we are from the
|
|
1333
|
-
* edge for that side by adding margins together
|
|
1334
|
-
*/
|
|
1335
|
-
interface SchematicBoxDimensions {
|
|
1336
|
-
pinCount: number;
|
|
1337
|
-
getPortPositionByPinNumber(pinNumber: number): PortInfo;
|
|
1338
|
-
getSize(): {
|
|
1339
|
-
width: number;
|
|
1340
|
-
height: number;
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
1365
|
declare class Chip<PinLabels extends string = never> extends NormalComponent<typeof chipProps, PinLabels> {
|
|
1345
|
-
|
|
1366
|
+
schematicBoxDimensions: SchematicBoxDimensions | null;
|
|
1346
1367
|
get config(): {
|
|
1347
1368
|
componentName: string;
|
|
1348
1369
|
zodProps: zod.ZodObject<zod.objectUtil.extendShape<zod.objectUtil.extendShape<zod.objectUtil.extendShape<{
|
|
@@ -1934,9 +1955,9 @@ declare class Chip<PinLabels extends string = never> extends NormalComponent<typ
|
|
|
1934
1955
|
schWidth?: string | number | undefined;
|
|
1935
1956
|
schHeight?: string | number | undefined;
|
|
1936
1957
|
}>;
|
|
1958
|
+
shouldRenderAsSchematicBox: boolean;
|
|
1937
1959
|
};
|
|
1938
1960
|
doInitialSourceRender(): void;
|
|
1939
|
-
doInitialSchematicComponentRender(): void;
|
|
1940
1961
|
doInitialPcbComponentRender(): void;
|
|
1941
1962
|
}
|
|
1942
1963
|
|
|
@@ -2942,9 +2963,9 @@ declare class Jumper<PinLabels extends string = never> extends NormalComponent<t
|
|
|
2942
2963
|
schHeight?: string | number | undefined;
|
|
2943
2964
|
schDirection?: "left" | "right" | undefined;
|
|
2944
2965
|
}>;
|
|
2966
|
+
shouldRenderAsSchematicBox: boolean;
|
|
2945
2967
|
};
|
|
2946
2968
|
doInitialSourceRender(): void;
|
|
2947
|
-
doInitialSchematicComponentRender(): void;
|
|
2948
2969
|
doInitialPcbComponentRender(): void;
|
|
2949
2970
|
}
|
|
2950
2971
|
|
|
@@ -6234,12 +6255,12 @@ declare class PinHeader extends NormalComponent<typeof pinHeaderProps> {
|
|
|
6234
6255
|
doubleRow?: boolean | undefined;
|
|
6235
6256
|
platedDiameter?: string | number | undefined;
|
|
6236
6257
|
}>;
|
|
6237
|
-
|
|
6258
|
+
shouldRenderAsSchematicBox: boolean;
|
|
6238
6259
|
};
|
|
6239
6260
|
_getImpliedFootprintString(): string | null;
|
|
6240
6261
|
initPorts(): void;
|
|
6262
|
+
_getSchematicPortArrangement(): SchematicPortArrangement | null;
|
|
6241
6263
|
doInitialSourceRender(): void;
|
|
6242
|
-
doInitialSchematicComponentRender(): void;
|
|
6243
6264
|
}
|
|
6244
6265
|
|
|
6245
6266
|
declare class Inductor extends NormalComponent<typeof inductorProps, PassivePorts> {
|