circuit-to-svg 0.0.178 → 0.0.180

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.js CHANGED
@@ -1495,7 +1495,7 @@ function getSoftwareUsedString(circuitJson) {
1495
1495
  var package_default = {
1496
1496
  name: "circuit-to-svg",
1497
1497
  type: "module",
1498
- version: "0.0.177",
1498
+ version: "0.0.179",
1499
1499
  description: "Convert Circuit JSON to SVG",
1500
1500
  main: "dist/index.js",
1501
1501
  files: [
@@ -1522,7 +1522,7 @@ var package_default = {
1522
1522
  react: "19.1.0",
1523
1523
  "react-cosmos": "7.0.0",
1524
1524
  "react-cosmos-plugin-vite": "7.0.0",
1525
- tscircuit: "^0.0.571",
1525
+ tscircuit: "^0.0.609",
1526
1526
  tsup: "^8.0.2",
1527
1527
  typescript: "^5.4.5",
1528
1528
  "vite-tsconfig-paths": "^5.0.1"
@@ -4570,6 +4570,29 @@ import "@tscircuit/circuit-json-util";
4570
4570
  import { applyToPoint as applyToPoint30 } from "transformation-matrix";
4571
4571
  import { su as su5 } from "@tscircuit/circuit-json-util";
4572
4572
  var PIN_CIRCLE_RADIUS_MM = 0.02;
4573
+ var createArrow = (tip, angle, size, color, strokeWidth) => {
4574
+ const arrowAngle = Math.PI / 6;
4575
+ const p1 = {
4576
+ x: tip.x - size * Math.cos(angle - arrowAngle),
4577
+ y: tip.y - size * Math.sin(angle - arrowAngle)
4578
+ };
4579
+ const p2 = {
4580
+ x: tip.x - size * Math.cos(angle + arrowAngle),
4581
+ y: tip.y - size * Math.sin(angle + arrowAngle)
4582
+ };
4583
+ return {
4584
+ name: "polygon",
4585
+ type: "element",
4586
+ attributes: {
4587
+ points: `${tip.x},${tip.y} ${p1.x},${p1.y} ${p2.x},${p2.y}`,
4588
+ fill: "white",
4589
+ stroke: color,
4590
+ "stroke-width": `${strokeWidth}px`
4591
+ },
4592
+ value: "",
4593
+ children: []
4594
+ };
4595
+ };
4573
4596
  var createSvgObjectsForSchPortBoxLine = ({
4574
4597
  schPort,
4575
4598
  schComponent,
@@ -4669,6 +4692,69 @@ var createSvgObjectsForSchPortBoxLine = ({
4669
4692
  },
4670
4693
  children: pinChildren
4671
4694
  });
4695
+ const { has_input_arrow, has_output_arrow } = schPort;
4696
+ if ((has_input_arrow || has_output_arrow) && schPort.side_of_component) {
4697
+ const arrowSize = Math.abs(transform.a) * 0.15;
4698
+ const arrowColor = colorMap.schematic.component_outline;
4699
+ const arrowAxialLength = arrowSize * Math.cos(Math.PI / 6);
4700
+ const strokeWidth = getSchStrokeSize(transform) / 2;
4701
+ let inputAngleRads = 0;
4702
+ let outputAngleRads = 0;
4703
+ if (schPort.side_of_component === "left") {
4704
+ inputAngleRads = 0;
4705
+ outputAngleRads = Math.PI;
4706
+ } else if (schPort.side_of_component === "right") {
4707
+ inputAngleRads = Math.PI;
4708
+ outputAngleRads = 0;
4709
+ } else if (schPort.side_of_component === "top") {
4710
+ inputAngleRads = Math.PI / 2;
4711
+ outputAngleRads = -Math.PI / 2;
4712
+ } else if (schPort.side_of_component === "bottom") {
4713
+ inputAngleRads = -Math.PI / 2;
4714
+ outputAngleRads = Math.PI / 2;
4715
+ }
4716
+ const both = has_input_arrow && has_output_arrow;
4717
+ let inputArrowTip = { ...screenRealEdgePos };
4718
+ let outputArrowBase = { ...screenRealEdgePos };
4719
+ if (both) {
4720
+ const offset = arrowAxialLength;
4721
+ if (schPort.side_of_component === "left") {
4722
+ outputArrowBase.x -= offset;
4723
+ } else if (schPort.side_of_component === "right") {
4724
+ outputArrowBase.x += offset;
4725
+ } else if (schPort.side_of_component === "top") {
4726
+ outputArrowBase.y -= offset;
4727
+ } else if (schPort.side_of_component === "bottom") {
4728
+ outputArrowBase.y += offset;
4729
+ }
4730
+ }
4731
+ if (has_input_arrow) {
4732
+ svgObjects.push(
4733
+ createArrow(
4734
+ inputArrowTip,
4735
+ inputAngleRads,
4736
+ arrowSize,
4737
+ arrowColor,
4738
+ strokeWidth
4739
+ )
4740
+ );
4741
+ }
4742
+ if (has_output_arrow) {
4743
+ const outputArrowTip = {
4744
+ x: outputArrowBase.x + arrowSize * Math.cos(outputAngleRads),
4745
+ y: outputArrowBase.y + arrowSize * Math.sin(outputAngleRads)
4746
+ };
4747
+ svgObjects.push(
4748
+ createArrow(
4749
+ outputArrowTip,
4750
+ outputAngleRads,
4751
+ arrowSize,
4752
+ arrowColor,
4753
+ strokeWidth
4754
+ )
4755
+ );
4756
+ }
4757
+ }
4672
4758
  return svgObjects;
4673
4759
  };
4674
4760