@tscircuit/core 0.0.135 → 0.0.137
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 +10 -3
- package/dist/index.js +13 -4
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactElement
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
import { ZodType, z } from 'zod';
|
|
4
4
|
import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
|
|
@@ -6220,7 +6220,14 @@ declare const useRenderedCircuit: (reactElements: React.ReactElement) => {
|
|
|
6220
6220
|
circuitJson?: AnyCircuitElement[];
|
|
6221
6221
|
};
|
|
6222
6222
|
|
|
6223
|
-
|
|
6223
|
+
type ComponentWithPins<Props, PinLabel extends string | never = never, PropsFromHook extends Omit<Props, "name"> | undefined = undefined> = React.ComponentType<(PropsFromHook extends undefined ? Omit<Props, "name"> : Omit<Partial<Props>, "name">) & {
|
|
6224
|
+
[key in PinLabel]?: string;
|
|
6225
|
+
}> & {
|
|
6226
|
+
[key in PinLabel]: string;
|
|
6227
|
+
};
|
|
6228
|
+
declare const createUseComponent: <Props, PinLabel extends string | never = never>(Component: React.ComponentType<Props>, pins: readonly PinLabel[] | readonly (readonly PinLabel[])[] | {
|
|
6229
|
+
[key: string]: readonly PinLabel[];
|
|
6230
|
+
}) => (<PropsFromHook extends Omit<Props, "name"> | undefined = undefined>(name: string, props?: PropsFromHook) => ComponentWithPins<Props, PinLabel, PropsFromHook>);
|
|
6224
6231
|
|
|
6225
6232
|
declare global {
|
|
6226
6233
|
namespace JSX {
|
|
@@ -6269,4 +6276,4 @@ declare global {
|
|
|
6269
6276
|
}
|
|
6270
6277
|
}
|
|
6271
6278
|
|
|
6272
|
-
export { Battery, Board, Capacitor, Chip, Circuit, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Net, NetAlias, NormalComponent, PlatedHole, Port, PowerSource, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenCircle, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Trace, TraceHint, Via, createUseComponent, useRenderedCircuit };
|
|
6279
|
+
export { Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Net, NetAlias, NormalComponent, PlatedHole, Port, PowerSource, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenCircle, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Trace, TraceHint, Via, createUseComponent, useRenderedCircuit };
|
package/dist/index.js
CHANGED
|
@@ -3406,7 +3406,8 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
3406
3406
|
}
|
|
3407
3407
|
const autorouter = new Autorouter({
|
|
3408
3408
|
input: simpleRouteJsonInput,
|
|
3409
|
-
OBSTACLE_MARGIN: 0.1
|
|
3409
|
+
OBSTACLE_MARGIN: 0.1,
|
|
3410
|
+
isRemovePathLoopsEnabled: true
|
|
3410
3411
|
});
|
|
3411
3412
|
const results = autorouter.solveAndMapToTraces();
|
|
3412
3413
|
if (results.length === 0) return;
|
|
@@ -3822,7 +3823,8 @@ var Chip = class extends NormalComponent {
|
|
|
3822
3823
|
doInitialSchematicComponentRender() {
|
|
3823
3824
|
const { db } = this.root;
|
|
3824
3825
|
const { _parsedProps: props } = this;
|
|
3825
|
-
const
|
|
3826
|
+
const pinCountFromSchArrangement = (props.schPortArrangement?.leftSize ?? 0) + (props.schPortArrangement?.rightSize ?? 0) + (props.schPortArrangement?.topSize ?? 0) + (props.schPortArrangement?.bottomSize ?? 0);
|
|
3827
|
+
const pinCount = pinCountFromSchArrangement || this.getPortsFromFootprint().length;
|
|
3826
3828
|
const pinSpacing = props.schPinSpacing ?? 0.2;
|
|
3827
3829
|
const dimensions = getAllDimensionsForSchematicBox({
|
|
3828
3830
|
schWidth: props.schWidth,
|
|
@@ -4659,10 +4661,17 @@ import "@tscircuit/props";
|
|
|
4659
4661
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4660
4662
|
var createUseComponent = (Component2, pins) => {
|
|
4661
4663
|
return (name, props) => {
|
|
4664
|
+
const pinLabelsFlatArray = [];
|
|
4665
|
+
if (Array.isArray(pins)) {
|
|
4666
|
+
pinLabelsFlatArray.push(...pins.flat());
|
|
4667
|
+
} else if (typeof pins === "object") {
|
|
4668
|
+
pinLabelsFlatArray.push(...Object.values(pins).flat());
|
|
4669
|
+
pinLabelsFlatArray.push(...Object.keys(pins));
|
|
4670
|
+
}
|
|
4662
4671
|
const R = (props2) => {
|
|
4663
4672
|
const combinedProps = { ...props, ...props2, name };
|
|
4664
4673
|
const tracesToCreate = [];
|
|
4665
|
-
for (const portLabel of
|
|
4674
|
+
for (const portLabel of pinLabelsFlatArray) {
|
|
4666
4675
|
if (combinedProps[portLabel]) {
|
|
4667
4676
|
const from = `.${name} > .${portLabel}`;
|
|
4668
4677
|
const to = combinedProps[portLabel];
|
|
@@ -4678,7 +4687,7 @@ var createUseComponent = (Component2, pins) => {
|
|
|
4678
4687
|
))
|
|
4679
4688
|
] });
|
|
4680
4689
|
};
|
|
4681
|
-
for (const port of
|
|
4690
|
+
for (const port of pinLabelsFlatArray) {
|
|
4682
4691
|
R[port] = `.${name} > .${port}`;
|
|
4683
4692
|
}
|
|
4684
4693
|
return R;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.137",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"debug": "^4.3.6",
|
|
30
30
|
"howfat": "^0.3.8",
|
|
31
31
|
"looks-same": "^9.0.1",
|
|
32
|
+
"ts-expect": "^1.3.0",
|
|
32
33
|
"tsup": "^8.2.4"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"@tscircuit/soup-util": "^0.0.33",
|
|
45
46
|
"circuit-json": "^0.0.91",
|
|
46
47
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
47
|
-
"circuit-to-svg": "^0.0.
|
|
48
|
+
"circuit-to-svg": "^0.0.56",
|
|
48
49
|
"nanoid": "^5.0.7",
|
|
49
50
|
"performance-now": "^2.1.0",
|
|
50
51
|
"react": "^18.3.1",
|