@tscircuit/core 0.0.249 → 0.0.250
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 +9 -0
- package/dist/index.js +45 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -444,6 +444,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
444
444
|
} | undefined;
|
|
445
445
|
}>, "many">>;
|
|
446
446
|
schDisplayLabel: z.ZodOptional<z.ZodString>;
|
|
447
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
447
448
|
}, {
|
|
448
449
|
path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<{
|
|
449
450
|
getPortSelector: () => string;
|
|
@@ -468,6 +469,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
468
469
|
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
469
470
|
}[] | undefined;
|
|
470
471
|
schDisplayLabel?: string | undefined;
|
|
472
|
+
maxLength?: number | undefined;
|
|
471
473
|
}, {
|
|
472
474
|
path: (string | {
|
|
473
475
|
getPortSelector: () => string;
|
|
@@ -488,6 +490,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
488
490
|
} | undefined;
|
|
489
491
|
}[] | undefined;
|
|
490
492
|
schDisplayLabel?: string | undefined;
|
|
493
|
+
maxLength?: number | undefined;
|
|
491
494
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
492
495
|
key: z.ZodOptional<z.ZodString>;
|
|
493
496
|
thickness: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
@@ -531,6 +534,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
531
534
|
} | undefined;
|
|
532
535
|
}>, "many">>;
|
|
533
536
|
schDisplayLabel: z.ZodOptional<z.ZodString>;
|
|
537
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
534
538
|
}, {
|
|
535
539
|
from: z.ZodUnion<[z.ZodString, z.ZodType<{
|
|
536
540
|
getPortSelector: () => string;
|
|
@@ -563,6 +567,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
563
567
|
to_layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
564
568
|
}[] | undefined;
|
|
565
569
|
schDisplayLabel?: string | undefined;
|
|
570
|
+
maxLength?: number | undefined;
|
|
566
571
|
}, {
|
|
567
572
|
from: string | {
|
|
568
573
|
getPortSelector: () => string;
|
|
@@ -586,6 +591,7 @@ declare class Trace extends PrimitiveComponent<typeof traceProps> implements Tra
|
|
|
586
591
|
} | undefined;
|
|
587
592
|
}[] | undefined;
|
|
588
593
|
schDisplayLabel?: string | undefined;
|
|
594
|
+
maxLength?: number | undefined;
|
|
589
595
|
}>]>;
|
|
590
596
|
componentName: string;
|
|
591
597
|
};
|
|
@@ -1549,6 +1555,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
|
|
|
1549
1555
|
decouplingTo: zod.ZodOptional<zod.ZodString>;
|
|
1550
1556
|
bypassFor: zod.ZodOptional<zod.ZodString>;
|
|
1551
1557
|
bypassTo: zod.ZodOptional<zod.ZodString>;
|
|
1558
|
+
maxDecouplingTraceLength: zod.ZodOptional<zod.ZodNumber>;
|
|
1552
1559
|
}>, "strip", zod.ZodTypeAny, {
|
|
1553
1560
|
name: string;
|
|
1554
1561
|
capacitance: number;
|
|
@@ -1622,6 +1629,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
|
|
|
1622
1629
|
decouplingTo?: string | undefined;
|
|
1623
1630
|
bypassFor?: string | undefined;
|
|
1624
1631
|
bypassTo?: string | undefined;
|
|
1632
|
+
maxDecouplingTraceLength?: number | undefined;
|
|
1625
1633
|
}, {
|
|
1626
1634
|
name: string;
|
|
1627
1635
|
capacitance: string | number;
|
|
@@ -1697,6 +1705,7 @@ declare class Capacitor extends NormalComponent<typeof capacitorProps, PassivePo
|
|
|
1697
1705
|
decouplingTo?: string | undefined;
|
|
1698
1706
|
bypassFor?: string | undefined;
|
|
1699
1707
|
bypassTo?: string | undefined;
|
|
1708
|
+
maxDecouplingTraceLength?: number | undefined;
|
|
1700
1709
|
}>;
|
|
1701
1710
|
sourceFtype: "simple_capacitor";
|
|
1702
1711
|
};
|
package/dist/index.js
CHANGED
|
@@ -3917,6 +3917,25 @@ var mergeRoutes = (routes) => {
|
|
|
3917
3917
|
return merged;
|
|
3918
3918
|
};
|
|
3919
3919
|
|
|
3920
|
+
// lib/components/primitive-components/Trace/compute-trace-length.ts
|
|
3921
|
+
function getTraceLength(route) {
|
|
3922
|
+
let totalLength = 0;
|
|
3923
|
+
for (let i = 0; i < route.length; i++) {
|
|
3924
|
+
const point = route[i];
|
|
3925
|
+
if (point.route_type === "wire") {
|
|
3926
|
+
const nextPoint = route[i + 1];
|
|
3927
|
+
if (nextPoint) {
|
|
3928
|
+
const dx = nextPoint.x - point.x;
|
|
3929
|
+
const dy = nextPoint.y - point.y;
|
|
3930
|
+
totalLength += Math.sqrt(dx * dx + dy * dy);
|
|
3931
|
+
}
|
|
3932
|
+
} else if (point.route_type === "via") {
|
|
3933
|
+
totalLength += 1.6;
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
return totalLength;
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3920
3939
|
// lib/utils/getClosest.ts
|
|
3921
3940
|
var getDistance = (a, b) => {
|
|
3922
3941
|
const aPos = "_getGlobalPcbPositionBeforeLayout" in a ? a._getGlobalPcbPositionBeforeLayout() : a;
|
|
@@ -4327,6 +4346,23 @@ var createDownwardNetLabelGroundSymbol = ({
|
|
|
4327
4346
|
});
|
|
4328
4347
|
};
|
|
4329
4348
|
|
|
4349
|
+
// lib/components/primitive-components/Trace/get-max-length-from-conn ected-capacitors.ts
|
|
4350
|
+
var getMaxLengthFromConnectedCapacitors = (ports, { db }) => {
|
|
4351
|
+
const capacitorMaxLengths = ports.map((port) => {
|
|
4352
|
+
const sourcePort = db.source_port.get(port.source_port_id);
|
|
4353
|
+
if (!sourcePort?.source_component_id) return null;
|
|
4354
|
+
const sourceComponent = db.source_component.get(
|
|
4355
|
+
sourcePort.source_component_id
|
|
4356
|
+
);
|
|
4357
|
+
if (sourceComponent?.ftype === "simple_capacitor") {
|
|
4358
|
+
return sourceComponent.max_decoupling_trace_length;
|
|
4359
|
+
}
|
|
4360
|
+
return null;
|
|
4361
|
+
}).filter((length) => length !== null);
|
|
4362
|
+
if (capacitorMaxLengths.length === 0) return void 0;
|
|
4363
|
+
return Math.min(...capacitorMaxLengths);
|
|
4364
|
+
};
|
|
4365
|
+
|
|
4330
4366
|
// lib/components/primitive-components/Trace/Trace.ts
|
|
4331
4367
|
var portToObjective = (port) => {
|
|
4332
4368
|
const portPosition = port._getGlobalPcbPositionAfterLayout();
|
|
@@ -4472,7 +4508,11 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4472
4508
|
const nets = this._findConnectedNets().nets;
|
|
4473
4509
|
const trace = db.source_trace.insert({
|
|
4474
4510
|
connected_source_port_ids: ports.map((p) => p.port.source_port_id),
|
|
4475
|
-
connected_source_net_ids: nets.map((n) => n.source_net_id)
|
|
4511
|
+
connected_source_net_ids: nets.map((n) => n.source_net_id),
|
|
4512
|
+
max_length: getMaxLengthFromConnectedCapacitors(
|
|
4513
|
+
ports.map((p) => p.port),
|
|
4514
|
+
{ db }
|
|
4515
|
+
) ?? props.maxLength
|
|
4476
4516
|
});
|
|
4477
4517
|
this.source_trace_id = trace.source_trace_id;
|
|
4478
4518
|
}
|
|
@@ -4722,9 +4762,11 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
4722
4762
|
routes.push(trace.route);
|
|
4723
4763
|
}
|
|
4724
4764
|
const mergedRoute = mergeRoutes(routes);
|
|
4765
|
+
const traceLength = getTraceLength(mergedRoute);
|
|
4725
4766
|
const pcb_trace = db.pcb_trace.insert({
|
|
4726
4767
|
route: mergedRoute,
|
|
4727
|
-
source_trace_id: this.source_trace_id
|
|
4768
|
+
source_trace_id: this.source_trace_id,
|
|
4769
|
+
trace_length: traceLength
|
|
4728
4770
|
});
|
|
4729
4771
|
this._portsRoutedOnPcb = ports;
|
|
4730
4772
|
this.pcb_trace_id = pcb_trace.pcb_trace_id;
|
|
@@ -5064,6 +5106,7 @@ var Capacitor = class extends NormalComponent {
|
|
|
5064
5106
|
manufacturer_part_number: props.manufacturerPartNumber ?? props.mfn,
|
|
5065
5107
|
supplier_part_numbers: props.supplierPartNumbers,
|
|
5066
5108
|
capacitance: props.capacitance,
|
|
5109
|
+
max_decoupling_trace_length: props.maxDecouplingTraceLength,
|
|
5067
5110
|
display_capacitance: this._getSchematicSymbolDisplayValue()
|
|
5068
5111
|
});
|
|
5069
5112
|
this.source_component_id = source_component.source_component_id;
|
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.250",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"@tscircuit/footprinter": "^0.0.95",
|
|
44
44
|
"@tscircuit/infgrid-ijump-astar": "^0.0.26",
|
|
45
45
|
"@tscircuit/math-utils": "^0.0.5",
|
|
46
|
-
"@tscircuit/props": "^0.0.
|
|
46
|
+
"@tscircuit/props": "^0.0.124",
|
|
47
47
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
48
48
|
"@tscircuit/soup-util": "^0.0.41",
|
|
49
|
-
"circuit-json": "^0.0.
|
|
49
|
+
"circuit-json": "^0.0.126",
|
|
50
50
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
51
51
|
"format-si-unit": "^0.0.2",
|
|
52
52
|
"nanoid": "^5.0.7",
|