@tscircuit/core 0.0.368 → 0.0.370
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 -1
- package/dist/index.js +79 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11431,6 +11431,14 @@ declare const applyEditEventsToManualEditsFile: ({ circuitJson, editEvents, manu
|
|
|
11431
11431
|
manualEditsFile: ManualEditsFile;
|
|
11432
11432
|
}) => ManualEditsFile;
|
|
11433
11433
|
|
|
11434
|
+
/**
|
|
11435
|
+
* Applies edit events directly to a CircuitJson object
|
|
11436
|
+
*/
|
|
11437
|
+
declare const applyEditEvents: ({ circuitJson, editEvents, }: {
|
|
11438
|
+
circuitJson: CircuitJson;
|
|
11439
|
+
editEvents: ManualEditEvent[];
|
|
11440
|
+
}) => CircuitJson;
|
|
11441
|
+
|
|
11434
11442
|
/**
|
|
11435
11443
|
* This function can only be called in the PcbTraceRender phase or later
|
|
11436
11444
|
*/
|
|
@@ -11613,4 +11621,4 @@ declare module "react/jsx-runtime" {
|
|
|
11613
11621
|
}
|
|
11614
11622
|
}
|
|
11615
11623
|
|
|
11616
|
-
export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, type Obstacle, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, Subcircuit, Switch, Trace, TraceHint, Transistor, Via, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
|
|
11624
|
+
export { type AsyncEffect, type AutorouterCompleteEvent, type AutorouterErrorEvent, type AutorouterEvent, type AutorouterProgressEvent, type AutoroutingEndEvent, type AutoroutingErrorEvent, type AutoroutingProgressEvent, type AutoroutingStartEvent, Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Crystal, Diode, FabricationNotePath, FabricationNoteText, Footprint, type GenericConnectionsAndSelectorsSel, type GenericLocalAutorouter, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Mosfet, Net, NetAlias, NormalComponent, type Obstacle, PinHeader, type PinLabelSpec, PlatedHole, Port, Potentiometer, PowerSource, PrimitiveComponent, Project, PushButton, type RenderPhase, type RenderPhaseFn, type RenderPhaseFunctions, type RenderPhaseStates, Renderable, Resistor, Resonator, RootCircuit, type RootCircuitEventName, type Sel, SilkscreenCircle, SilkscreenLine, SilkscreenPath, SilkscreenRect, SilkscreenText, type SimpleRouteConnection, type SimpleRouteJson, type SimplifiedPcbTrace, SmtPad, Subcircuit, Switch, Trace, TraceHint, Transistor, Via, applyEditEvents, applyEditEventsToManualEditsFile, applyPcbEditEventsToManualEditsFile, applySchematicEditEventsToManualEditsFile, createUseComponent, getPhaseTimingsFromRenderEvents, getSimpleRouteJsonFromCircuitJson, orderedRenderPhases, sel, useCapacitor, useChip, useDiode, useLed, useRenderedCircuit, useResistor };
|
package/dist/index.js
CHANGED
|
@@ -5514,9 +5514,81 @@ var applyEditEventsToManualEditsFile = ({
|
|
|
5514
5514
|
return updatedManualEditsFile;
|
|
5515
5515
|
};
|
|
5516
5516
|
|
|
5517
|
+
// lib/utils/edit-events/apply-edit-events-to-circuit-json.ts
|
|
5518
|
+
import { transformPCBElement } from "@tscircuit/soup-util";
|
|
5519
|
+
import { translate as translate3 } from "transformation-matrix";
|
|
5520
|
+
|
|
5521
|
+
// lib/utils/edit-events/apply-trace-hint-edit-event.ts
|
|
5522
|
+
import { su as su3 } from "@tscircuit/soup-util";
|
|
5523
|
+
var applyTraceHintEditEvent = (circuitJson, edit_event) => {
|
|
5524
|
+
const existingTraceHint = su3(circuitJson).pcb_trace_hint.get(
|
|
5525
|
+
edit_event.pcb_trace_hint_id
|
|
5526
|
+
);
|
|
5527
|
+
if (existingTraceHint) {
|
|
5528
|
+
circuitJson = circuitJson.map(
|
|
5529
|
+
(e) => e.pcb_trace_hint_id === edit_event.pcb_trace_hint_id ? {
|
|
5530
|
+
...e,
|
|
5531
|
+
route: edit_event.route
|
|
5532
|
+
} : e
|
|
5533
|
+
);
|
|
5534
|
+
} else {
|
|
5535
|
+
const pcbPort = su3(circuitJson).pcb_port.get(edit_event.pcb_port_id);
|
|
5536
|
+
circuitJson = circuitJson.filter(
|
|
5537
|
+
(e) => !(e.type === "pcb_trace_hint" && e.pcb_port_id === edit_event.pcb_port_id)
|
|
5538
|
+
).concat([
|
|
5539
|
+
{
|
|
5540
|
+
type: "pcb_trace_hint",
|
|
5541
|
+
pcb_trace_hint_id: edit_event.pcb_trace_hint_id,
|
|
5542
|
+
route: edit_event.route,
|
|
5543
|
+
pcb_port_id: edit_event.pcb_port_id,
|
|
5544
|
+
pcb_component_id: pcbPort?.pcb_component_id
|
|
5545
|
+
}
|
|
5546
|
+
]);
|
|
5547
|
+
}
|
|
5548
|
+
return circuitJson;
|
|
5549
|
+
};
|
|
5550
|
+
|
|
5551
|
+
// lib/utils/edit-events/apply-edit-events-to-circuit-json.ts
|
|
5552
|
+
var applyEditEvents = ({
|
|
5553
|
+
circuitJson,
|
|
5554
|
+
editEvents
|
|
5555
|
+
}) => {
|
|
5556
|
+
circuitJson = JSON.parse(JSON.stringify(circuitJson));
|
|
5557
|
+
for (const editEvent of editEvents) {
|
|
5558
|
+
if (editEvent.edit_event_type === "edit_pcb_component_location") {
|
|
5559
|
+
const component = circuitJson.find(
|
|
5560
|
+
(e) => e.type === "pcb_component" && e.pcb_component_id === editEvent.pcb_component_id
|
|
5561
|
+
);
|
|
5562
|
+
const needsMovement = !component || component.center.x !== editEvent.new_center.x || component.center.y !== editEvent.new_center.y;
|
|
5563
|
+
if (needsMovement && editEvent.original_center) {
|
|
5564
|
+
const mat = translate3(
|
|
5565
|
+
editEvent.new_center.x - editEvent.original_center.x,
|
|
5566
|
+
editEvent.new_center.y - editEvent.original_center.y
|
|
5567
|
+
);
|
|
5568
|
+
circuitJson = circuitJson.map(
|
|
5569
|
+
(e) => e.pcb_component_id !== editEvent.pcb_component_id ? e : transformPCBElement(e, mat)
|
|
5570
|
+
);
|
|
5571
|
+
}
|
|
5572
|
+
} else if (editEvent.edit_event_type === "edit_schematic_component_location") {
|
|
5573
|
+
circuitJson = circuitJson.map((e) => {
|
|
5574
|
+
if (e.type === "schematic_component" && e.schematic_component_id === editEvent.schematic_component_id) {
|
|
5575
|
+
return {
|
|
5576
|
+
...e,
|
|
5577
|
+
center: editEvent.new_center
|
|
5578
|
+
};
|
|
5579
|
+
}
|
|
5580
|
+
return e;
|
|
5581
|
+
});
|
|
5582
|
+
} else if (editEvent.edit_event_type === "edit_pcb_trace_hint") {
|
|
5583
|
+
circuitJson = applyTraceHintEditEvent(circuitJson, editEvent);
|
|
5584
|
+
}
|
|
5585
|
+
}
|
|
5586
|
+
return circuitJson;
|
|
5587
|
+
};
|
|
5588
|
+
|
|
5517
5589
|
// lib/utils/autorouting/getSimpleRouteJsonFromCircuitJson.ts
|
|
5518
5590
|
import { getObstaclesFromSoup as getObstaclesFromSoup2 } from "@tscircuit/infgrid-ijump-astar";
|
|
5519
|
-
import { su as
|
|
5591
|
+
import { su as su4 } from "@tscircuit/soup-util";
|
|
5520
5592
|
import {
|
|
5521
5593
|
getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson2
|
|
5522
5594
|
} from "circuit-json-to-connectivity-map";
|
|
@@ -5548,7 +5620,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
5548
5620
|
minTraceWidth = 0.1
|
|
5549
5621
|
}) => {
|
|
5550
5622
|
if (!db && circuitJson) {
|
|
5551
|
-
db =
|
|
5623
|
+
db = su4(circuitJson);
|
|
5552
5624
|
}
|
|
5553
5625
|
if (!db) {
|
|
5554
5626
|
throw new Error("db or circuitJson is required");
|
|
@@ -5567,7 +5639,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
|
|
|
5567
5639
|
(e) => !subcircuit_id || "subcircuit_id" in e && relevantSubcircuitIds.has(e.subcircuit_id)
|
|
5568
5640
|
);
|
|
5569
5641
|
const board = db.pcb_board.list()[0];
|
|
5570
|
-
db =
|
|
5642
|
+
db = su4(subcircuitElements);
|
|
5571
5643
|
const connMap = getFullConnectivityMapFromCircuitJson2(subcircuitElements);
|
|
5572
5644
|
const obstacles = getObstaclesFromSoup2(
|
|
5573
5645
|
[
|
|
@@ -7433,7 +7505,7 @@ var Switch = class extends NormalComponent {
|
|
|
7433
7505
|
};
|
|
7434
7506
|
|
|
7435
7507
|
// lib/RootCircuit.ts
|
|
7436
|
-
import { su as
|
|
7508
|
+
import { su as su5 } from "@tscircuit/soup-util";
|
|
7437
7509
|
import { isValidElement as isValidElement2 } from "react";
|
|
7438
7510
|
import { identity as identity4 } from "transformation-matrix";
|
|
7439
7511
|
|
|
@@ -7441,7 +7513,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
7441
7513
|
var package_default = {
|
|
7442
7514
|
name: "@tscircuit/core",
|
|
7443
7515
|
type: "module",
|
|
7444
|
-
version: "0.0.
|
|
7516
|
+
version: "0.0.369",
|
|
7445
7517
|
types: "dist/index.d.ts",
|
|
7446
7518
|
main: "dist/index.js",
|
|
7447
7519
|
module: "dist/index.js",
|
|
@@ -7533,7 +7605,7 @@ var RootCircuit = class {
|
|
|
7533
7605
|
_hasRenderedAtleastOnce = false;
|
|
7534
7606
|
constructor() {
|
|
7535
7607
|
this.children = [];
|
|
7536
|
-
this.db =
|
|
7608
|
+
this.db = su5([]);
|
|
7537
7609
|
this.root = this;
|
|
7538
7610
|
}
|
|
7539
7611
|
add(componentOrElm) {
|
|
@@ -7915,6 +7987,7 @@ export {
|
|
|
7915
7987
|
TraceHint,
|
|
7916
7988
|
Transistor,
|
|
7917
7989
|
Via,
|
|
7990
|
+
applyEditEvents,
|
|
7918
7991
|
applyEditEventsToManualEditsFile,
|
|
7919
7992
|
applyPcbEditEventsToManualEditsFile,
|
|
7920
7993
|
applySchematicEditEventsToManualEditsFile,
|