circuit-to-svg 0.0.461 → 0.0.463

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
@@ -9115,7 +9115,7 @@ var package_default = {
9115
9115
  engines: {
9116
9116
  node: "24.x"
9117
9117
  },
9118
- version: "0.0.460",
9118
+ version: "0.0.462",
9119
9119
  repository: {
9120
9120
  type: "git",
9121
9121
  url: "https://github.com/tscircuit/circuit-to-svg.git"
@@ -9141,14 +9141,14 @@ var package_default = {
9141
9141
  "@resvg/resvg-js": "^2.6.2",
9142
9142
  "@tscircuit/alphabet": "^0.0.27",
9143
9143
  "@tscircuit/checks-latest": "npm:@tscircuit/checks@0.0.179",
9144
- "@tscircuit/circuit-json-util": "^0.0.115",
9144
+ "@tscircuit/circuit-json-util": "^0.0.134",
9145
9145
  "@types/bun": "^1.2.8",
9146
9146
  "@types/color": "^4.2.1",
9147
9147
  "@types/debug": "^4.1.12",
9148
9148
  "@vitejs/plugin-react": "5.0.0",
9149
9149
  biome: "^0.3.3",
9150
9150
  "bun-match-svg": "^0.0.12",
9151
- "circuit-json": "^0.0.549",
9151
+ "circuit-json": "^0.0.560",
9152
9152
  "circuit-json-to-connectivity-map": "^0.0.23",
9153
9153
  esbuild: "^0.20.2",
9154
9154
  "format-si-unit": "^0.0.12",
@@ -9387,6 +9387,7 @@ function getComprehensivePcbBounds(circuitJson) {
9387
9387
  let boardMaxY = Number.NEGATIVE_INFINITY;
9388
9388
  let hasBoardBounds = false;
9389
9389
  for (const circuitJsonElm of circuitJson) {
9390
+ if (!circuitJsonElm.type.startsWith("pcb_")) continue;
9390
9391
  if (circuitJsonElm.type === "pcb_panel") {
9391
9392
  const panel = circuitJsonElm;
9392
9393
  const width = distance6.parse(panel.width);
@@ -14629,6 +14630,10 @@ function createSvgObjects3(elm, ctx, soup) {
14629
14630
  }
14630
14631
  }
14631
14632
 
14633
+ // lib/sch/convert-circuit-json-to-schematic-svg.ts
14634
+ import { convertSchematicLengthUnits } from "@tscircuit/circuit-json-util";
14635
+ import { LEGACY_SCHEMATIC_LENGTH_UNIT as LEGACY_SCHEMATIC_LENGTH_UNIT2 } from "circuit-json";
14636
+
14632
14637
  // lib/utils/get-sch-stroke-size.ts
14633
14638
  var getSchStrokeSize = (transform) => {
14634
14639
  return Math.abs(transform.a) * 0.02;
@@ -15471,17 +15476,15 @@ var getTableDimensions = (schematicTable, circuitJson) => {
15471
15476
  };
15472
15477
 
15473
15478
  // lib/sch/schematic-sheet-utils.ts
15474
- var KICAD_RESISTOR_PIN_SPAN_MM = 10.16;
15475
- var TSCIRCUIT_RESISTOR_PIN_SPAN = 1.1;
15476
- var SCHEMATIC_UNIT_TO_MM = KICAD_RESISTOR_PIN_SPAN_MM / TSCIRCUIT_RESISTOR_PIN_SPAN;
15477
- var DEFAULT_SCHEMATIC_SHEET_WIDTH = 297 / SCHEMATIC_UNIT_TO_MM;
15478
- var DEFAULT_SCHEMATIC_SHEET_HEIGHT = 210 / SCHEMATIC_UNIT_TO_MM;
15479
- var SCHEMATIC_SHEET_GAP = 20 / SCHEMATIC_UNIT_TO_MM;
15480
- var SCHEMATIC_SHEET_INNER_MARGIN = 5 / SCHEMATIC_UNIT_TO_MM;
15479
+ import { MM_PER_SCHEMATIC_UNIT } from "circuit-json";
15480
+ var DEFAULT_SCHEMATIC_SHEET_WIDTH = 297 / MM_PER_SCHEMATIC_UNIT;
15481
+ var DEFAULT_SCHEMATIC_SHEET_HEIGHT = 210 / MM_PER_SCHEMATIC_UNIT;
15482
+ var SCHEMATIC_SHEET_GAP = 20 / MM_PER_SCHEMATIC_UNIT;
15483
+ var SCHEMATIC_SHEET_INNER_MARGIN = 5 / MM_PER_SCHEMATIC_UNIT;
15481
15484
  function getSchematicSheetLayout(schematicSheet = {}) {
15482
15485
  const center = schematicSheet.center ?? { x: 0, y: 0 };
15483
- const width = schematicSheet.sheet_width === void 0 ? DEFAULT_SCHEMATIC_SHEET_WIDTH : schematicSheet.sheet_width / SCHEMATIC_UNIT_TO_MM;
15484
- const height = schematicSheet.sheet_height === void 0 ? DEFAULT_SCHEMATIC_SHEET_HEIGHT : schematicSheet.sheet_height / SCHEMATIC_UNIT_TO_MM;
15486
+ const width = schematicSheet.sheet_width === void 0 ? DEFAULT_SCHEMATIC_SHEET_WIDTH : schematicSheet.sheet_width / MM_PER_SCHEMATIC_UNIT;
15487
+ const height = schematicSheet.sheet_height === void 0 ? DEFAULT_SCHEMATIC_SHEET_HEIGHT : schematicSheet.sheet_height / MM_PER_SCHEMATIC_UNIT;
15485
15488
  const minX = center.x - width / 2;
15486
15489
  const maxX = center.x + width / 2;
15487
15490
  const minY = center.y - height / 2;
@@ -16279,14 +16282,22 @@ var createSvgObjectsForSchNetLabel = ({
16279
16282
  };
16280
16283
 
16281
16284
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
16282
- import { su as su7 } from "@tscircuit/circuit-json-util";
16285
+ import { LEGACY_SCHEMATIC_LENGTH_UNIT } from "circuit-json";
16286
+ import { getSchematicLengthUnitScale, su as su7 } from "@tscircuit/circuit-json-util";
16283
16287
  import { applyToPoint as applyToPoint76 } from "transformation-matrix";
16284
16288
  var PIN_CIRCLE_RADIUS_MM = 0.02;
16285
16289
  var createSvgObjectsForSchPortHover = ({
16286
16290
  schPort,
16287
16291
  transform
16288
16292
  }) => {
16289
- const screenSchPortPos = applyToPoint76(transform, schPort.center);
16293
+ const scale10 = getSchematicLengthUnitScale(
16294
+ schPort.schematic_length_unit ?? LEGACY_SCHEMATIC_LENGTH_UNIT,
16295
+ LEGACY_SCHEMATIC_LENGTH_UNIT
16296
+ );
16297
+ const screenSchPortPos = applyToPoint76(transform, {
16298
+ x: schPort.center.x * scale10,
16299
+ y: schPort.center.y * scale10
16300
+ });
16290
16301
  const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM * 2;
16291
16302
  return [
16292
16303
  {
@@ -17715,9 +17726,10 @@ function createSvgObjectsFromSchDebugObject({
17715
17726
  }
17716
17727
 
17717
17728
  // lib/sch/svg-object-fns/create-svg-objects-from-sch-sheet.ts
17729
+ import { MM_PER_SCHEMATIC_UNIT as MM_PER_SCHEMATIC_UNIT2 } from "circuit-json";
17718
17730
  import { applyToPoint as applyToPoint92 } from "transformation-matrix";
17719
- var SHEET_STROKE_WIDTH = 0.2 / SCHEMATIC_UNIT_TO_MM;
17720
- var SHEET_LABEL_FONT_SIZE = 3 / SCHEMATIC_UNIT_TO_MM;
17731
+ var SHEET_STROKE_WIDTH = 0.2 / MM_PER_SCHEMATIC_UNIT2;
17732
+ var SHEET_LABEL_FONT_SIZE = 3 / MM_PER_SCHEMATIC_UNIT2;
17721
17733
  var SHEET_COLUMNS = ["1", "2", "3", "4", "5", "6"];
17722
17734
  var SHEET_ROWS = ["A", "B", "C", "D"];
17723
17735
  function createSvgObjectsFromSchematicSheet({
@@ -19173,6 +19185,10 @@ function getSourcePortErrorReferences(error) {
19173
19185
 
19174
19186
  // lib/sch/convert-circuit-json-to-schematic-svg.ts
19175
19187
  function convertCircuitJsonToSchematicSvg(circuitJson, options) {
19188
+ circuitJson = convertSchematicLengthUnits(
19189
+ circuitJson,
19190
+ LEGACY_SCHEMATIC_LENGTH_UNIT2
19191
+ );
19176
19192
  const schematicSheets = circuitJson.filter(
19177
19193
  (elm) => elm.type === "schematic_sheet"
19178
19194
  );
@@ -19623,12 +19639,18 @@ function clampGraphicDimension(requestedPixels, availablePixels) {
19623
19639
  }
19624
19640
 
19625
19641
  // lib/sch/convert-circuit-json-to-stacked-schematic-sheets-svg.ts
19642
+ import { convertSchematicLengthUnits as convertSchematicLengthUnits2 } from "@tscircuit/circuit-json-util";
19643
+ import { LEGACY_SCHEMATIC_LENGTH_UNIT as LEGACY_SCHEMATIC_LENGTH_UNIT3 } from "circuit-json";
19626
19644
  import { parseSync as parseSync3 } from "svgson";
19627
19645
  import { applyToPoint as applyToPoint99, fromString } from "transformation-matrix";
19628
19646
  var DEFAULT_SHEET_WIDTH = 1e3;
19629
19647
  var DEFAULT_LABEL_HEIGHT = 28;
19630
19648
  var DEFAULT_GAP = 16;
19631
19649
  function convertCircuitJsonToStackedSchematicSheetsSvg(circuitJson, options) {
19650
+ circuitJson = convertSchematicLengthUnits2(
19651
+ circuitJson,
19652
+ LEGACY_SCHEMATIC_LENGTH_UNIT3
19653
+ );
19632
19654
  const sheets = circuitJson.filter((elm) => elm.type === "schematic_sheet").slice().sort((a, b) => (a.sheet_index ?? 0) - (b.sheet_index ?? 0));
19633
19655
  if (sheets.length <= 1) {
19634
19656
  return convertCircuitJsonToSchematicSvg(circuitJson, options);