@tscircuit/core 0.0.369 → 0.0.371
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 +8 -8
- package/dist/index.js +79 -79
- package/package.json +2 -2
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
|
*/
|
|
@@ -11548,14 +11556,6 @@ declare const applySchematicEditEventsToManualEditsFile: ({ circuitJson, editEve
|
|
|
11548
11556
|
manualEditsFile: z.infer<typeof manual_edits_file>;
|
|
11549
11557
|
}) => z.infer<typeof manual_edits_file>;
|
|
11550
11558
|
|
|
11551
|
-
/**
|
|
11552
|
-
* Applies edit events directly to a CircuitJson object
|
|
11553
|
-
*/
|
|
11554
|
-
declare const applyEditEvents: ({ circuitJson, editEvents, }: {
|
|
11555
|
-
circuitJson: CircuitJson;
|
|
11556
|
-
editEvents: ManualEditEvent[];
|
|
11557
|
-
}) => CircuitJson;
|
|
11558
|
-
|
|
11559
11559
|
interface TscircuitElements {
|
|
11560
11560
|
resistor: _tscircuit_props.ResistorProps;
|
|
11561
11561
|
capacitor: _tscircuit_props.CapacitorProps;
|
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.370",
|
|
7445
7517
|
types: "dist/index.d.ts",
|
|
7446
7518
|
main: "dist/index.js",
|
|
7447
7519
|
module: "dist/index.js",
|
|
@@ -7493,7 +7565,7 @@ var package_default = {
|
|
|
7493
7565
|
},
|
|
7494
7566
|
dependencies: {
|
|
7495
7567
|
"@lume/kiwi": "^0.4.3",
|
|
7496
|
-
"@tscircuit/capacity-autorouter": "^0.0.
|
|
7568
|
+
"@tscircuit/capacity-autorouter": "^0.0.52",
|
|
7497
7569
|
"@tscircuit/checks": "^0.0.30",
|
|
7498
7570
|
"@tscircuit/circuit-json-util": "^0.0.45",
|
|
7499
7571
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|
|
@@ -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) {
|
|
@@ -7861,78 +7933,6 @@ var sel = new Proxy(
|
|
|
7861
7933
|
}
|
|
7862
7934
|
);
|
|
7863
7935
|
|
|
7864
|
-
// lib/utils/edit-events/apply-edit-events-to-circuit-json.ts
|
|
7865
|
-
import { transformPCBElement } from "@tscircuit/soup-util";
|
|
7866
|
-
import { translate as translate3 } from "transformation-matrix";
|
|
7867
|
-
|
|
7868
|
-
// lib/utils/edit-events/apply-trace-hint-edit-event.ts
|
|
7869
|
-
import { su as su5 } from "@tscircuit/soup-util";
|
|
7870
|
-
var applyTraceHintEditEvent = (circuitJson, edit_event) => {
|
|
7871
|
-
const existingTraceHint = su5(circuitJson).pcb_trace_hint.get(
|
|
7872
|
-
edit_event.pcb_trace_hint_id
|
|
7873
|
-
);
|
|
7874
|
-
if (existingTraceHint) {
|
|
7875
|
-
circuitJson = circuitJson.map(
|
|
7876
|
-
(e) => e.pcb_trace_hint_id === edit_event.pcb_trace_hint_id ? {
|
|
7877
|
-
...e,
|
|
7878
|
-
route: edit_event.route
|
|
7879
|
-
} : e
|
|
7880
|
-
);
|
|
7881
|
-
} else {
|
|
7882
|
-
const pcbPort = su5(circuitJson).pcb_port.get(edit_event.pcb_port_id);
|
|
7883
|
-
circuitJson = circuitJson.filter(
|
|
7884
|
-
(e) => !(e.type === "pcb_trace_hint" && e.pcb_port_id === edit_event.pcb_port_id)
|
|
7885
|
-
).concat([
|
|
7886
|
-
{
|
|
7887
|
-
type: "pcb_trace_hint",
|
|
7888
|
-
pcb_trace_hint_id: edit_event.pcb_trace_hint_id,
|
|
7889
|
-
route: edit_event.route,
|
|
7890
|
-
pcb_port_id: edit_event.pcb_port_id,
|
|
7891
|
-
pcb_component_id: pcbPort?.pcb_component_id
|
|
7892
|
-
}
|
|
7893
|
-
]);
|
|
7894
|
-
}
|
|
7895
|
-
return circuitJson;
|
|
7896
|
-
};
|
|
7897
|
-
|
|
7898
|
-
// lib/utils/edit-events/apply-edit-events-to-circuit-json.ts
|
|
7899
|
-
var applyEditEvents = ({
|
|
7900
|
-
circuitJson,
|
|
7901
|
-
editEvents
|
|
7902
|
-
}) => {
|
|
7903
|
-
circuitJson = JSON.parse(JSON.stringify(circuitJson));
|
|
7904
|
-
for (const editEvent of editEvents) {
|
|
7905
|
-
if (editEvent.edit_event_type === "edit_pcb_component_location") {
|
|
7906
|
-
const component = circuitJson.find(
|
|
7907
|
-
(e) => e.type === "pcb_component" && e.pcb_component_id === editEvent.pcb_component_id
|
|
7908
|
-
);
|
|
7909
|
-
const needsMovement = !component || component.center.x !== editEvent.new_center.x || component.center.y !== editEvent.new_center.y;
|
|
7910
|
-
if (needsMovement && editEvent.original_center) {
|
|
7911
|
-
const mat = translate3(
|
|
7912
|
-
editEvent.new_center.x - editEvent.original_center.x,
|
|
7913
|
-
editEvent.new_center.y - editEvent.original_center.y
|
|
7914
|
-
);
|
|
7915
|
-
circuitJson = circuitJson.map(
|
|
7916
|
-
(e) => e.pcb_component_id !== editEvent.pcb_component_id ? e : transformPCBElement(e, mat)
|
|
7917
|
-
);
|
|
7918
|
-
}
|
|
7919
|
-
} else if (editEvent.edit_event_type === "edit_schematic_component_location") {
|
|
7920
|
-
circuitJson = circuitJson.map((e) => {
|
|
7921
|
-
if (e.type === "schematic_component" && e.schematic_component_id === editEvent.schematic_component_id) {
|
|
7922
|
-
return {
|
|
7923
|
-
...e,
|
|
7924
|
-
center: editEvent.new_center
|
|
7925
|
-
};
|
|
7926
|
-
}
|
|
7927
|
-
return e;
|
|
7928
|
-
});
|
|
7929
|
-
} else if (editEvent.edit_event_type === "edit_pcb_trace_hint") {
|
|
7930
|
-
circuitJson = applyTraceHintEditEvent(circuitJson, editEvent);
|
|
7931
|
-
}
|
|
7932
|
-
}
|
|
7933
|
-
return circuitJson;
|
|
7934
|
-
};
|
|
7935
|
-
|
|
7936
7936
|
// lib/index.ts
|
|
7937
7937
|
import { createElement } from "react";
|
|
7938
7938
|
|
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.371",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@lume/kiwi": "^0.4.3",
|
|
56
|
-
"@tscircuit/capacity-autorouter": "^0.0.
|
|
56
|
+
"@tscircuit/capacity-autorouter": "^0.0.52",
|
|
57
57
|
"@tscircuit/checks": "^0.0.30",
|
|
58
58
|
"@tscircuit/circuit-json-util": "^0.0.45",
|
|
59
59
|
"@tscircuit/infgrid-ijump-astar": "^0.0.33",
|