@tscircuit/core 0.0.143 → 0.0.145
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 +14 -10
- package/dist/index.js +56 -49
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import * as zod from 'zod';
|
|
|
3
3
|
import { ZodType, z } from 'zod';
|
|
4
4
|
import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
|
|
5
5
|
import { PcbTraceError, PcbPlacementError, LayerRef, AnyCircuitElement, AnySourceComponent, RouteHintPoint } from 'circuit-json';
|
|
6
|
-
import { SoupUtilObjects } from '@tscircuit/soup-util';
|
|
7
6
|
import { Matrix } from 'transformation-matrix';
|
|
7
|
+
import { SoupUtilObjects } from '@tscircuit/soup-util';
|
|
8
8
|
import * as _tscircuit_props from '@tscircuit/props';
|
|
9
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, inductorProps, CapacitorProps, ChipProps, ResistorProps } from '@tscircuit/props';
|
|
10
|
+
import * as _tscircuit_layout from '@tscircuit/layout';
|
|
10
11
|
|
|
11
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"];
|
|
12
13
|
type RenderPhase = (typeof orderedRenderPhases)[number];
|
|
@@ -833,7 +834,8 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
833
834
|
}>, "many">>;
|
|
834
835
|
pcbX: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>>;
|
|
835
836
|
pcbY: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>>;
|
|
836
|
-
layout: z.ZodOptional<z.
|
|
837
|
+
layout: z.ZodOptional<z.ZodType<_tscircuit_layout.LayoutBuilder, z.ZodTypeDef, _tscircuit_layout.LayoutBuilder>>;
|
|
838
|
+
manualEdits: z.ZodOptional<z.ZodType<_tscircuit_layout.ManualEditFile, z.ZodTypeDef, _tscircuit_layout.ManualEditFile>>;
|
|
837
839
|
routingDisabled: z.ZodOptional<z.ZodBoolean>;
|
|
838
840
|
children: z.ZodAny;
|
|
839
841
|
defaultTraceWidth: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
@@ -844,28 +846,30 @@ declare class Board extends Group<typeof boardProps> {
|
|
|
844
846
|
children?: any;
|
|
845
847
|
width?: number | undefined;
|
|
846
848
|
height?: number | undefined;
|
|
847
|
-
layout?: any;
|
|
848
|
-
routingDisabled?: boolean | undefined;
|
|
849
|
-
defaultTraceWidth?: number | undefined;
|
|
850
|
-
schAutoLayoutEnabled?: boolean | undefined;
|
|
851
849
|
outline?: {
|
|
852
850
|
x: number;
|
|
853
851
|
y: number;
|
|
854
852
|
}[] | undefined;
|
|
853
|
+
layout?: _tscircuit_layout.LayoutBuilder | undefined;
|
|
854
|
+
manualEdits?: _tscircuit_layout.ManualEditFile | undefined;
|
|
855
|
+
routingDisabled?: boolean | undefined;
|
|
856
|
+
defaultTraceWidth?: number | undefined;
|
|
857
|
+
schAutoLayoutEnabled?: boolean | undefined;
|
|
855
858
|
}, {
|
|
856
859
|
pcbX?: string | number | undefined;
|
|
857
860
|
pcbY?: string | number | undefined;
|
|
858
861
|
children?: any;
|
|
859
862
|
width?: string | number | undefined;
|
|
860
863
|
height?: string | number | undefined;
|
|
861
|
-
layout?: any;
|
|
862
|
-
routingDisabled?: boolean | undefined;
|
|
863
|
-
defaultTraceWidth?: string | number | undefined;
|
|
864
|
-
schAutoLayoutEnabled?: boolean | undefined;
|
|
865
864
|
outline?: {
|
|
866
865
|
x: string | number;
|
|
867
866
|
y: string | number;
|
|
868
867
|
}[] | undefined;
|
|
868
|
+
layout?: _tscircuit_layout.LayoutBuilder | undefined;
|
|
869
|
+
manualEdits?: _tscircuit_layout.ManualEditFile | undefined;
|
|
870
|
+
routingDisabled?: boolean | undefined;
|
|
871
|
+
defaultTraceWidth?: string | number | undefined;
|
|
872
|
+
schAutoLayoutEnabled?: boolean | undefined;
|
|
869
873
|
}>;
|
|
870
874
|
};
|
|
871
875
|
get boardThickness(): number;
|
package/dist/index.js
CHANGED
|
@@ -354,18 +354,32 @@ var createInstanceFromReactElement = (reactElm) => {
|
|
|
354
354
|
return rootContainer.children[0];
|
|
355
355
|
};
|
|
356
356
|
|
|
357
|
-
// lib/
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
357
|
+
// lib/errors/InvalidProps.ts
|
|
358
|
+
var InvalidProps = class extends Error {
|
|
359
|
+
constructor(componentName, originalProps, formattedError) {
|
|
360
|
+
let message;
|
|
361
|
+
const propsWithError = Object.keys(formattedError).filter(
|
|
362
|
+
(k) => k !== "_errors"
|
|
363
|
+
);
|
|
364
|
+
const propMessage = propsWithError.map((k) => {
|
|
365
|
+
if (formattedError[k]._errors[0]) {
|
|
366
|
+
return `${k} (${formattedError[k]._errors[0]})`;
|
|
367
|
+
}
|
|
368
|
+
return `${k} (${JSON.stringify(formattedError[k])})`;
|
|
369
|
+
}).join(", ");
|
|
370
|
+
if ("name" in originalProps) {
|
|
371
|
+
message = `Invalid props for ${componentName} "${originalProps.name}": ${propMessage}`;
|
|
372
|
+
} else if ("footprint" in originalProps && typeof originalProps.footprint === "string") {
|
|
373
|
+
message = `Invalid props for ${componentName} (unnamed ${originalProps.footprint} component): ${propMessage}`;
|
|
374
|
+
} else {
|
|
375
|
+
message = `Invalid props for ${componentName} (unnamed): ${propMessage}`;
|
|
376
|
+
}
|
|
377
|
+
super(message);
|
|
378
|
+
this.componentName = componentName;
|
|
379
|
+
this.originalProps = originalProps;
|
|
380
|
+
this.formattedError = formattedError;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
369
383
|
|
|
370
384
|
// lib/utils/selector-matching/is-matching-selector.ts
|
|
371
385
|
function isMatchingSelector(component, selector) {
|
|
@@ -396,34 +410,17 @@ function isMatchingSelector(component, selector) {
|
|
|
396
410
|
});
|
|
397
411
|
}
|
|
398
412
|
|
|
399
|
-
// lib/errors/InvalidProps.ts
|
|
400
|
-
var InvalidProps = class extends Error {
|
|
401
|
-
constructor(componentName, originalProps, formattedError) {
|
|
402
|
-
let message;
|
|
403
|
-
const propsWithError = Object.keys(formattedError).filter(
|
|
404
|
-
(k) => k !== "_errors"
|
|
405
|
-
);
|
|
406
|
-
const propMessage = propsWithError.map((k) => {
|
|
407
|
-
if (formattedError[k]._errors[0]) {
|
|
408
|
-
return `${k} (${formattedError[k]._errors[0]})`;
|
|
409
|
-
}
|
|
410
|
-
return `${k} (${JSON.stringify(formattedError[k])})`;
|
|
411
|
-
}).join(", ");
|
|
412
|
-
if ("name" in originalProps) {
|
|
413
|
-
message = `Invalid props for ${componentName} "${originalProps.name}": ${propMessage}`;
|
|
414
|
-
} else if ("footprint" in originalProps && typeof originalProps.footprint === "string") {
|
|
415
|
-
message = `Invalid props for ${componentName} (unnamed ${originalProps.footprint} component): ${propMessage}`;
|
|
416
|
-
} else {
|
|
417
|
-
message = `Invalid props for ${componentName} (unnamed): ${propMessage}`;
|
|
418
|
-
}
|
|
419
|
-
super(message);
|
|
420
|
-
this.componentName = componentName;
|
|
421
|
-
this.originalProps = originalProps;
|
|
422
|
-
this.formattedError = formattedError;
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
|
|
426
413
|
// lib/components/base-components/PrimitiveComponent.ts
|
|
414
|
+
import { symbols } from "schematic-symbols";
|
|
415
|
+
import {
|
|
416
|
+
applyToPoint,
|
|
417
|
+
compose,
|
|
418
|
+
flipY,
|
|
419
|
+
identity as identity2,
|
|
420
|
+
rotate,
|
|
421
|
+
translate
|
|
422
|
+
} from "transformation-matrix";
|
|
423
|
+
import { z } from "zod";
|
|
427
424
|
var PrimitiveComponent = class extends Renderable {
|
|
428
425
|
parent = null;
|
|
429
426
|
children;
|
|
@@ -630,16 +627,17 @@ var PrimitiveComponent = class extends Renderable {
|
|
|
630
627
|
_getManualPlacementForComponent(component) {
|
|
631
628
|
if (!this.isSubcircuit) return null;
|
|
632
629
|
const layout = this.props.layout;
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
630
|
+
const manualEdits = this.props.manualEdits;
|
|
631
|
+
if (!layout && !manualEdits) return null;
|
|
632
|
+
const placementConfigPositions = layout?.manual_pcb_placement_config?.positions || manualEdits?.pcb_placements;
|
|
633
|
+
if (!placementConfigPositions) return null;
|
|
634
|
+
for (const position of placementConfigPositions) {
|
|
635
|
+
if (layout && isMatchingSelector(component, position.selector) || component.props.name === position.selector) {
|
|
638
636
|
const center = applyToPoint(
|
|
639
637
|
this._computePcbGlobalTransformBeforeLayout(),
|
|
640
638
|
position.center
|
|
641
639
|
);
|
|
642
|
-
return center;
|
|
640
|
+
return Array.isArray(center) ? { x: center[0], y: center[1] } : center;
|
|
643
641
|
}
|
|
644
642
|
}
|
|
645
643
|
return null;
|
|
@@ -1802,7 +1800,7 @@ function getPortFromHints(hints) {
|
|
|
1802
1800
|
|
|
1803
1801
|
// lib/components/base-components/NormalComponent.ts
|
|
1804
1802
|
import {
|
|
1805
|
-
isValidElement as
|
|
1803
|
+
isValidElement as isReactElement,
|
|
1806
1804
|
isValidElement
|
|
1807
1805
|
} from "react";
|
|
1808
1806
|
import { symbols as symbols2 } from "schematic-symbols";
|
|
@@ -2265,7 +2263,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2265
2263
|
this.initPorts();
|
|
2266
2264
|
}
|
|
2267
2265
|
doInitialReactSubtreesRender() {
|
|
2268
|
-
if (
|
|
2266
|
+
if (isReactElement(this.props.footprint)) {
|
|
2269
2267
|
if (this.reactSubtrees.some((rs) => rs.element === this.props.footprint))
|
|
2270
2268
|
return;
|
|
2271
2269
|
const subtree = this._renderReactSubtree(this.props.footprint);
|
|
@@ -2285,7 +2283,7 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2285
2283
|
}
|
|
2286
2284
|
add(componentOrElm) {
|
|
2287
2285
|
let component;
|
|
2288
|
-
if (
|
|
2286
|
+
if (isReactElement(componentOrElm)) {
|
|
2289
2287
|
const subtree = this._renderReactSubtree(componentOrElm);
|
|
2290
2288
|
this.reactSubtrees.push(subtree);
|
|
2291
2289
|
component = subtree.component;
|
|
@@ -2328,9 +2326,18 @@ var NormalComponent = class extends PrimitiveComponent {
|
|
|
2328
2326
|
}
|
|
2329
2327
|
if (!isValidElement(footprint) && footprint && footprint.componentName === "Footprint") {
|
|
2330
2328
|
const fp2 = footprint;
|
|
2329
|
+
let pinNumber = 1;
|
|
2331
2330
|
const newPorts2 = [];
|
|
2332
2331
|
for (const fpChild of fp2.children) {
|
|
2333
|
-
|
|
2332
|
+
let portHintsList = fpChild.props.portHints ?? [];
|
|
2333
|
+
const hasPinPrefix = portHintsList.some(
|
|
2334
|
+
(hint) => hint.startsWith("pin")
|
|
2335
|
+
);
|
|
2336
|
+
if (!hasPinPrefix) {
|
|
2337
|
+
portHintsList = [...portHintsList, `pin${pinNumber}`];
|
|
2338
|
+
}
|
|
2339
|
+
pinNumber++;
|
|
2340
|
+
const newPort = getPortFromHints(portHintsList);
|
|
2334
2341
|
if (!newPort) continue;
|
|
2335
2342
|
newPort.originDescription = `footprint:${footprint}`;
|
|
2336
2343
|
newPorts2.push(newPort);
|
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.145",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@tscircuit/footprinter": "^0.0.77",
|
|
41
41
|
"@tscircuit/infgrid-ijump-astar": "^0.0.24",
|
|
42
42
|
"@tscircuit/math-utils": "^0.0.4",
|
|
43
|
-
"@tscircuit/props": "^0.0.
|
|
43
|
+
"@tscircuit/props": "^0.0.78",
|
|
44
44
|
"@tscircuit/schematic-autolayout": "^0.0.5",
|
|
45
45
|
"@tscircuit/soup-util": "^0.0.33",
|
|
46
46
|
"circuit-json": "^0.0.91",
|