circuit-to-svg 0.0.168 → 0.0.170

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 CHANGED
@@ -1,5 +1,6 @@
1
- import { AnyCircuitElement } from 'circuit-json';
1
+ import { AnyCircuitElement, SchematicComponent } from 'circuit-json';
2
2
  import { Matrix } from 'transformation-matrix';
3
+ import { INode } from 'svgson';
3
4
 
4
5
  interface PcbColorMap {
5
6
  copper: {
@@ -262,4 +263,10 @@ declare function getSoftwareUsedString(circuitJson: AnyCircuitElement[]): string
262
263
 
263
264
  declare const CIRCUIT_TO_SVG_VERSION: string;
264
265
 
265
- export { type AssemblySvgContext, CIRCUIT_TO_SVG_VERSION, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSolderPasteMask, getSoftwareUsedString };
266
+ declare const createSvgObjectsForSchComponentPortHovers: ({ component, transform, circuitJson, }: {
267
+ component: SchematicComponent;
268
+ transform: Matrix;
269
+ circuitJson: AnyCircuitElement[];
270
+ }) => INode[];
271
+
272
+ export { type AssemblySvgContext, CIRCUIT_TO_SVG_VERSION, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSolderPasteMask, createSvgObjectsForSchComponentPortHovers, getSoftwareUsedString };
package/dist/index.js CHANGED
@@ -1446,7 +1446,7 @@ function getSoftwareUsedString(circuitJson) {
1446
1446
  var package_default = {
1447
1447
  name: "circuit-to-svg",
1448
1448
  type: "module",
1449
- version: "0.0.167",
1449
+ version: "0.0.169",
1450
1450
  description: "Convert Circuit JSON to SVG",
1451
1451
  main: "dist/index.js",
1452
1452
  files: [
@@ -1489,7 +1489,7 @@ var package_default = {
1489
1489
  "vite-tsconfig-paths": "^5.0.1",
1490
1490
  "@tscircuit/checks": "^0.0.44",
1491
1491
  "@tscircuit/circuit-json-util": "^0.0.47",
1492
- "@tscircuit/footprinter": "^0.0.91"
1492
+ "@tscircuit/footprinter": "^0.0.203"
1493
1493
  },
1494
1494
  peerDependencies: {
1495
1495
  "circuit-json": "*",
@@ -5815,6 +5815,58 @@ var createSvgObjectsFromSchematicTable = ({
5815
5815
  ];
5816
5816
  };
5817
5817
 
5818
+ // lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
5819
+ import { su as su8 } from "@tscircuit/circuit-json-util";
5820
+ import { applyToPoint as applyToPoint43 } from "transformation-matrix";
5821
+ var PIN_CIRCLE_RADIUS_MM2 = 0.02;
5822
+ var createSvgObjectsForSchPortHover = ({
5823
+ schPort,
5824
+ transform
5825
+ }) => {
5826
+ const screenSchPortPos = applyToPoint43(transform, schPort.center);
5827
+ const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
5828
+ return [
5829
+ {
5830
+ name: "g",
5831
+ type: "element",
5832
+ value: "",
5833
+ attributes: {
5834
+ class: "schematic-port-hover",
5835
+ "data-schematic-port-id": schPort.source_port_id
5836
+ },
5837
+ children: [
5838
+ {
5839
+ name: "circle",
5840
+ type: "element",
5841
+ value: "",
5842
+ attributes: {
5843
+ cx: screenSchPortPos.x.toString(),
5844
+ cy: screenSchPortPos.y.toString(),
5845
+ r: pinRadiusPx.toString(),
5846
+ fill: "red",
5847
+ opacity: "0"
5848
+ },
5849
+ children: []
5850
+ }
5851
+ ]
5852
+ }
5853
+ ];
5854
+ };
5855
+ var createSvgObjectsForSchComponentPortHovers = ({
5856
+ component,
5857
+ transform,
5858
+ circuitJson
5859
+ }) => {
5860
+ const schematicPorts = su8(circuitJson).schematic_port.list({
5861
+ schematic_component_id: component.schematic_component_id
5862
+ });
5863
+ const svgs = [];
5864
+ for (const schPort of schematicPorts) {
5865
+ svgs.push(...createSvgObjectsForSchPortHover({ schPort, transform }));
5866
+ }
5867
+ return svgs;
5868
+ };
5869
+
5818
5870
  // lib/sch/convert-circuit-json-to-schematic-svg.ts
5819
5871
  function convertCircuitJsonToSchematicSvg(circuitJson, options) {
5820
5872
  const realBounds = getSchematicBoundsFromCircuitJson(circuitJson);
@@ -5886,6 +5938,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
5886
5938
  const voltageProbeSvgs = [];
5887
5939
  const schBoxSvgs = [];
5888
5940
  const schTableSvgs = [];
5941
+ const schPortHoverSvgs = [];
5889
5942
  for (const elm of circuitJson) {
5890
5943
  if (elm.type === "schematic_debug_object") {
5891
5944
  schDebugObjectSvgs.push(
@@ -5903,6 +5956,13 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
5903
5956
  colorMap: colorMap2
5904
5957
  })
5905
5958
  );
5959
+ schPortHoverSvgs.push(
5960
+ ...createSvgObjectsForSchComponentPortHovers({
5961
+ component: elm,
5962
+ transform,
5963
+ circuitJson
5964
+ })
5965
+ );
5906
5966
  } else if (elm.type === "schematic_box") {
5907
5967
  schBoxSvgs.push(
5908
5968
  ...createSvgObjectsFromSchematicBox({
@@ -5958,6 +6018,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
5958
6018
  ...schDebugObjectSvgs,
5959
6019
  ...schComponentSvgs,
5960
6020
  ...schTraceSvgs,
6021
+ ...schPortHoverSvgs,
5961
6022
  ...schNetLabel,
5962
6023
  ...schText,
5963
6024
  ...schBoxSvgs,
@@ -6039,18 +6100,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
6039
6100
  // lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
6040
6101
  import { stringify as stringify4 } from "svgson";
6041
6102
  import {
6042
- applyToPoint as applyToPoint45,
6103
+ applyToPoint as applyToPoint46,
6043
6104
  compose as compose11,
6044
6105
  scale as scale8,
6045
6106
  translate as translate11
6046
6107
  } from "transformation-matrix";
6047
6108
 
6048
6109
  // lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
6049
- import { applyToPoint as applyToPoint44 } from "transformation-matrix";
6110
+ import { applyToPoint as applyToPoint45 } from "transformation-matrix";
6050
6111
  function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
6051
6112
  const { transform, layer: layerFilter } = ctx;
6052
6113
  if (layerFilter && solderPaste.layer !== layerFilter) return [];
6053
- const [x, y] = applyToPoint44(transform, [solderPaste.x, solderPaste.y]);
6114
+ const [x, y] = applyToPoint45(transform, [solderPaste.x, solderPaste.y]);
6054
6115
  if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
6055
6116
  const width = solderPaste.width * Math.abs(transform.a);
6056
6117
  const height = solderPaste.height * Math.abs(transform.d);
@@ -6253,8 +6314,8 @@ function createSvgObjects3({ elm, ctx }) {
6253
6314
  }
6254
6315
  }
6255
6316
  function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
6256
- const [x1, y1] = applyToPoint45(transform, [minX, minY]);
6257
- const [x2, y2] = applyToPoint45(transform, [maxX, maxY]);
6317
+ const [x1, y1] = applyToPoint46(transform, [minX, minY]);
6318
+ const [x2, y2] = applyToPoint46(transform, [maxX, maxY]);
6258
6319
  const width = Math.abs(x2 - x1);
6259
6320
  const height = Math.abs(y2 - y1);
6260
6321
  const x = Math.min(x1, x2);
@@ -6284,6 +6345,7 @@ export {
6284
6345
  convertCircuitJsonToPcbSvg,
6285
6346
  convertCircuitJsonToSchematicSvg,
6286
6347
  convertCircuitJsonToSolderPasteMask,
6348
+ createSvgObjectsForSchComponentPortHovers,
6287
6349
  getSoftwareUsedString
6288
6350
  };
6289
6351
  //# sourceMappingURL=index.js.map