@tscircuit/cli 0.1.1172 → 0.1.1174

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.
@@ -11865,16 +11865,18 @@ var formatIgnoredDrcCounts = (counts) => [
11865
11865
  // cli/build/image-format-selection.ts
11866
11866
  var DEFAULT_IMAGE_FORMAT_SELECTION = {
11867
11867
  threeDPngs: true,
11868
+ pcbPngs: false,
11868
11869
  pcbSvgs: true,
11869
11870
  schematicSvgs: true
11870
11871
  };
11871
11872
  var EMPTY_IMAGE_FORMAT_SELECTION = {
11872
11873
  threeDPngs: false,
11874
+ pcbPngs: false,
11873
11875
  pcbSvgs: false,
11874
11876
  schematicSvgs: false
11875
11877
  };
11876
- var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbSvgs || selection.schematicSvgs;
11877
- var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.svgs || options?.pcbSvgs || options?.schematicSvgs);
11878
+ var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbPngs || selection.pcbSvgs || selection.schematicSvgs;
11879
+ var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.pcbPng || options?.svgs || options?.pcbSvgs || options?.schematicSvgs);
11878
11880
  var hasEstablishedOutputFlags = (options) => Boolean(options?.["3d"] || options?.pcbOnly || options?.schematicOnly);
11879
11881
  var resolveImageFormatSelection = (options) => {
11880
11882
  const hasNewFlags = hasNewOutputFlags(options);
@@ -11889,6 +11891,7 @@ var resolveImageFormatSelection = (options) => {
11889
11891
  if (!hasNewFlags && hasEstablishedFlags) {
11890
11892
  const selection2 = {
11891
11893
  threeDPngs: Boolean(options?.["3d"]),
11894
+ pcbPngs: false,
11892
11895
  pcbSvgs: true,
11893
11896
  schematicSvgs: true
11894
11897
  };
@@ -11910,6 +11913,9 @@ var resolveImageFormatSelection = (options) => {
11910
11913
  if (options?.pcbSvgs) {
11911
11914
  selection.pcbSvgs = true;
11912
11915
  }
11916
+ if (options?.pcbPng) {
11917
+ selection.pcbPngs = true;
11918
+ }
11913
11919
  if (options?.schematicSvgs) {
11914
11920
  selection.schematicSvgs = true;
11915
11921
  }
@@ -13489,6 +13495,17 @@ var normalizeToArrayBuffer = async (value) => {
13489
13495
  throw new Error("Expected ArrayBuffer, ArrayBufferView, or Buffer-compatible object");
13490
13496
  };
13491
13497
 
13498
+ // cli/build/svg-to-png.ts
13499
+ import { Resvg } from "@resvg/resvg-js";
13500
+ var convertSvgToPngBuffer = async (svg) => {
13501
+ const resvg = new Resvg(svg, {
13502
+ fitTo: {
13503
+ mode: "original"
13504
+ }
13505
+ });
13506
+ return resvg.render().asPng();
13507
+ };
13508
+
13492
13509
  // cli/build/worker-output-generators.ts
13493
13510
  var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
13494
13511
  const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
@@ -13504,6 +13521,10 @@ var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
13504
13521
  const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
13505
13522
  fs9.writeFileSync(path12.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
13506
13523
  }
13524
+ if (imageFormats.pcbPngs) {
13525
+ const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
13526
+ fs9.writeFileSync(path12.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
13527
+ }
13507
13528
  if (imageFormats.schematicSvgs) {
13508
13529
  const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
13509
13530
  fs9.writeFileSync(path12.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
package/dist/cli/main.js CHANGED
@@ -98409,7 +98409,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
98409
98409
  // lib/getVersion.ts
98410
98410
  import { createRequire as createRequire2 } from "node:module";
98411
98411
  // package.json
98412
- var version = "0.1.1171";
98412
+ var version = "0.1.1172";
98413
98413
  var package_default = {
98414
98414
  name: "@tscircuit/cli",
98415
98415
  version,
@@ -108079,6 +108079,19 @@ import {
108079
108079
  convertCircuitJsonToSchematicSvg
108080
108080
  } from "circuit-to-svg";
108081
108081
  import { renderGLTFToPNGBufferFromGLBBuffer } from "poppygl";
108082
+
108083
+ // cli/build/svg-to-png.ts
108084
+ import { Resvg } from "@resvg/resvg-js";
108085
+ var convertSvgToPngBuffer = async (svg) => {
108086
+ const resvg = new Resvg(svg, {
108087
+ fitTo: {
108088
+ mode: "original"
108089
+ }
108090
+ });
108091
+ return resvg.render().asPng();
108092
+ };
108093
+
108094
+ // cli/build/build-preview-images.ts
108082
108095
  var viewToArrayBuffer2 = (view) => {
108083
108096
  const copy = new Uint8Array(view.byteLength);
108084
108097
  copy.set(new Uint8Array(view.buffer, view.byteOffset, view.byteLength));
@@ -108139,6 +108152,16 @@ var generatePreviewAssets = async ({
108139
108152
  console.error(`${prefix}Failed to generate PCB SVG:`, error);
108140
108153
  }
108141
108154
  }
108155
+ if (imageFormats.pcbPngs) {
108156
+ try {
108157
+ console.log(`${prefix}Generating PCB PNG...`);
108158
+ const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson);
108159
+ fs30.writeFileSync(path32.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
108160
+ console.log(`${prefix}Written pcb.png`);
108161
+ } catch (error) {
108162
+ console.error(`${prefix}Failed to generate PCB PNG:`, error);
108163
+ }
108164
+ }
108142
108165
  if (imageFormats.schematicSvgs) {
108143
108166
  try {
108144
108167
  console.log(`${prefix}Generating schematic SVG...`);
@@ -108541,16 +108564,18 @@ async function getBuildEntrypoints({
108541
108564
  // cli/build/image-format-selection.ts
108542
108565
  var DEFAULT_IMAGE_FORMAT_SELECTION = {
108543
108566
  threeDPngs: true,
108567
+ pcbPngs: false,
108544
108568
  pcbSvgs: true,
108545
108569
  schematicSvgs: true
108546
108570
  };
108547
108571
  var EMPTY_IMAGE_FORMAT_SELECTION = {
108548
108572
  threeDPngs: false,
108573
+ pcbPngs: false,
108549
108574
  pcbSvgs: false,
108550
108575
  schematicSvgs: false
108551
108576
  };
108552
- var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbSvgs || selection.schematicSvgs;
108553
- var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.svgs || options?.pcbSvgs || options?.schematicSvgs);
108577
+ var hasAnyImageFormatSelected = (selection) => selection.threeDPngs || selection.pcbPngs || selection.pcbSvgs || selection.schematicSvgs;
108578
+ var hasNewOutputFlags = (options) => Boolean(options?.pngs || options?.pcbPng || options?.svgs || options?.pcbSvgs || options?.schematicSvgs);
108554
108579
  var hasEstablishedOutputFlags = (options) => Boolean(options?.["3d"] || options?.pcbOnly || options?.schematicOnly);
108555
108580
  var resolveImageFormatSelection = (options) => {
108556
108581
  const hasNewFlags = hasNewOutputFlags(options);
@@ -108565,6 +108590,7 @@ var resolveImageFormatSelection = (options) => {
108565
108590
  if (!hasNewFlags && hasEstablishedFlags) {
108566
108591
  const selection2 = {
108567
108592
  threeDPngs: Boolean(options?.["3d"]),
108593
+ pcbPngs: false,
108568
108594
  pcbSvgs: true,
108569
108595
  schematicSvgs: true
108570
108596
  };
@@ -108586,6 +108612,9 @@ var resolveImageFormatSelection = (options) => {
108586
108612
  if (options?.pcbSvgs) {
108587
108613
  selection.pcbSvgs = true;
108588
108614
  }
108615
+ if (options?.pcbPng) {
108616
+ selection.pcbPngs = true;
108617
+ }
108589
108618
  if (options?.schematicSvgs) {
108590
108619
  selection.schematicSvgs = true;
108591
108620
  }
@@ -109347,7 +109376,7 @@ var getOutputDirName = (relativePath) => {
109347
109376
  return relativePath.replace(/(\.board|\.circuit)?\.tsx$/, "").replace(/\.circuit\.json$/, "");
109348
109377
  };
109349
109378
  var registerBuild = (program2) => {
109350
- program2.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--ignore-netlist-drc", "Ignore netlist DRC errors/warnings").option("--ignore-pin-specification-drc", "Ignore pin-specification DRC errors/warnings").option("--ignore-placement-drc", "Ignore placement DRC errors/warnings").option("--ignore-routing-drc", "Ignore routing DRC errors/warnings").option("--ignore-config", "Ignore options from tscircuit.config.json").option("--disable-pcb", "Disable PCB outputs").option("--routing-disabled", "Disable routing during circuit generation").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--pngs", "Generate PNG outputs during build generation").option("--svgs", "Generate SVG outputs during build generation").option("--pcb-svgs", "Generate PCB SVG outputs during build generation").option("--schematic-svgs", "Generate schematic SVG outputs during build generation").option("--3d", "Generate 3D PNG outputs during build generation").option("--pcb-only", "Generate only PCB SVG outputs during build generation").option("--schematic-only", "Generate only schematic SVG outputs during build generation").option("--kicad-project", "Generate KiCad project directories for each successful build output").option("--kicad-project-zip", "Generate a zipped KiCad project for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--kicad-library-name <name>", "Specify the name of the KiCad library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--glbs", "Generate GLB 3D model files for every successful build").option("--profile", "Log per-circuit circuit.json generation time during build").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").option("--inject-props <json>", "Inject JSON props into the built file's default export").option("--inject-props-file <path>", "Inject JSON props from a file into the built file's default export").action(async (file, options) => {
109379
+ program2.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ci", "Run install and optional prebuild/build commands (or default CI build)").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--ignore-netlist-drc", "Ignore netlist DRC errors/warnings").option("--ignore-pin-specification-drc", "Ignore pin-specification DRC errors/warnings").option("--ignore-placement-drc", "Ignore placement DRC errors/warnings").option("--ignore-routing-drc", "Ignore routing DRC errors/warnings").option("--ignore-config", "Ignore options from tscircuit.config.json").option("--disable-pcb", "Disable PCB outputs").option("--routing-disabled", "Disable routing during circuit generation").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").option("--pngs", "Generate PNG outputs during build generation").option("--pcb-png", "Generate PCB PNG outputs during build generation").option("--svgs", "Generate SVG outputs during build generation").option("--pcb-svgs", "Generate PCB SVG outputs during build generation").option("--schematic-svgs", "Generate schematic SVG outputs during build generation").option("--3d", "Generate 3D PNG outputs during build generation").option("--pcb-only", "Generate only PCB SVG outputs during build generation").option("--schematic-only", "Generate only schematic SVG outputs during build generation").option("--kicad-project", "Generate KiCad project directories for each successful build output").option("--kicad-project-zip", "Generate a zipped KiCad project for each successful build output").option("--kicad-library", "Generate KiCad library in dist/kicad-library").option("--kicad-library-name <name>", "Specify the name of the KiCad library").option("--preview-gltf", "Generate a GLTF file from the preview entrypoint").option("--glbs", "Generate GLB 3D model files for every successful build").option("--profile", "Log per-circuit circuit.json generation time during build").option("--kicad-pcm", "Generate KiCad PCM (Plugin and Content Manager) assets in dist/pcm").option("--use-cdn-javascript", "Use CDN-hosted JavaScript instead of bundled standalone file for --site").option("--concurrency <number>", "Number of files to build in parallel (default: 1)", "1").option("--inject-props <json>", "Inject JSON props into the built file's default export").option("--inject-props-file <path>", "Inject JSON props from a file into the built file's default export").action(async (file, options) => {
109351
109380
  try {
109352
109381
  const transpileExplicitlyRequested = options?.transpile === true;
109353
109382
  const resolvedRoot = path39.resolve(process.cwd());
@@ -109797,6 +109826,7 @@ var registerBuild = (program2) => {
109797
109826
  resolvedOptions?.previewImages && "preview-images",
109798
109827
  resolvedOptions?.allImages && "all-images",
109799
109828
  resolvedOptions?.pngs && "pngs",
109829
+ resolvedOptions?.pcbPng && "pcb-png",
109800
109830
  resolvedOptions?.svgs && "svgs",
109801
109831
  resolvedOptions?.pcbSvgs && "pcb-svgs",
109802
109832
  resolvedOptions?.schematicSvgs && "schematic-svgs",
package/dist/lib/index.js CHANGED
@@ -60678,7 +60678,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
60678
60678
  }));
60679
60679
  };
60680
60680
  // package.json
60681
- var version = "0.1.1171";
60681
+ var version = "0.1.1172";
60682
60682
  var package_default = {
60683
60683
  name: "@tscircuit/cli",
60684
60684
  version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.1172",
3
+ "version": "0.1.1174",
4
4
  "main": "dist/cli/main.js",
5
5
  "exports": {
6
6
  ".": "./dist/cli/main.js",