@tscircuit/cli 0.1.183 → 0.1.185

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.
Files changed (2) hide show
  1. package/dist/main.js +323 -223
  2. package/package.json +10 -3
package/dist/main.js CHANGED
@@ -262643,7 +262643,7 @@ var init_dist6 = __esm(() => {
262643
262643
  package_default2 = {
262644
262644
  name: "circuit-to-svg",
262645
262645
  type: "module",
262646
- version: "0.0.172",
262646
+ version: "0.0.171",
262647
262647
  description: "Convert Circuit JSON to SVG",
262648
262648
  main: "dist/index.js",
262649
262649
  files: [
@@ -262686,7 +262686,7 @@ var init_dist6 = __esm(() => {
262686
262686
  "vite-tsconfig-paths": "^5.0.1",
262687
262687
  "@tscircuit/checks": "^0.0.44",
262688
262688
  "@tscircuit/circuit-json-util": "^0.0.47",
262689
- "@tscircuit/footprinter": "^0.0.204"
262689
+ "@tscircuit/footprinter": "^0.0.203"
262690
262690
  },
262691
262691
  peerDependencies: {
262692
262692
  "circuit-json": "*",
@@ -434909,7 +434909,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
434909
434909
  import { execSync as execSync2 } from "node:child_process";
434910
434910
  var import_semver2 = __toESM2(require_semver2(), 1);
434911
434911
  // package.json
434912
- var version = "0.1.182";
434912
+ var version = "0.1.184";
434913
434913
  var package_default = {
434914
434914
  name: "@tscircuit/cli",
434915
434915
  version,
@@ -434949,21 +434949,28 @@ var package_default = {
434949
434949
  "jwt-decode": "^4.0.0",
434950
434950
  kleur: "^4.1.5",
434951
434951
  ky: "^1.7.4",
434952
- "looks-same": "^9.0.1",
434953
434952
  "make-vfs": "^1.0.15",
434954
434953
  "perfect-cli": "^1.0.20",
434955
434954
  prompts: "^2.4.2",
434956
434955
  redaxios: "^0.5.1",
434957
434956
  semver: "^7.6.3",
434958
434957
  tempy: "^3.1.0",
434959
- tscircuit: "^0.0.553",
434958
+ tscircuit: "^0.0.555",
434960
434959
  tsx: "^4.7.1",
434961
434960
  "typed-ky": "^0.0.4",
434962
434961
  zod: "3"
434963
434962
  },
434963
+ dependencies: {
434964
+ "looks-same": "^9.0.1"
434965
+ },
434964
434966
  peerDependencies: {
434965
434967
  tscircuit: "*"
434966
434968
  },
434969
+ peerDependenciesMeta: {
434970
+ tscircuit: {
434971
+ optional: true
434972
+ }
434973
+ },
434967
434974
  bin: {
434968
434975
  tsci: "./cli/entrypoint.js"
434969
434976
  },
@@ -438460,59 +438467,128 @@ import * as path16 from "node:path";
438460
438467
  // lib/shared/get-entrypoint.ts
438461
438468
  import * as fs12 from "node:fs";
438462
438469
  import * as path13 from "node:path";
438470
+ var ALLOWED_ENTRYPOINT_NAMES = Object.freeze([
438471
+ "index.tsx",
438472
+ "index.ts",
438473
+ "index.circuit.tsx",
438474
+ "main.tsx",
438475
+ "main.circuit.tsx"
438476
+ ]);
438477
+ var MAX_SEARCH_DEPTH = 3;
438478
+ var MAX_RESULTS = 100;
438479
+ var isValidDirectory = (dirPath, projectDir) => {
438480
+ const resolvedDir = path13.resolve(dirPath);
438481
+ const resolvedProject = path13.resolve(projectDir);
438482
+ return resolvedDir.startsWith(resolvedProject) && !resolvedDir.includes("..");
438483
+ };
438484
+ var findEntrypointsRecursively = (dir, projectDir, maxDepth = MAX_SEARCH_DEPTH, fileNames = ALLOWED_ENTRYPOINT_NAMES) => {
438485
+ if (maxDepth <= 0 || !isValidDirectory(dir, projectDir)) {
438486
+ return [];
438487
+ }
438488
+ const results = [];
438489
+ try {
438490
+ const entries = fs12.readdirSync(dir, { withFileTypes: true });
438491
+ for (const entry of entries) {
438492
+ if (results.length >= MAX_RESULTS)
438493
+ break;
438494
+ if (entry.isFile() && fileNames.includes(entry.name)) {
438495
+ const filePath = path13.resolve(dir, entry.name);
438496
+ if (isValidDirectory(filePath, projectDir)) {
438497
+ results.push(filePath);
438498
+ }
438499
+ }
438500
+ }
438501
+ for (const entry of entries) {
438502
+ if (results.length >= MAX_RESULTS)
438503
+ break;
438504
+ if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
438505
+ const subdirPath = path13.resolve(dir, entry.name);
438506
+ if (isValidDirectory(subdirPath, projectDir)) {
438507
+ results.push(...findEntrypointsRecursively(subdirPath, projectDir, maxDepth - 1, fileNames));
438508
+ }
438509
+ }
438510
+ }
438511
+ } catch {
438512
+ return [];
438513
+ }
438514
+ return results;
438515
+ };
438516
+ var validateProjectDir = (projectDir) => {
438517
+ const resolvedDir = path13.resolve(projectDir);
438518
+ if (!fs12.existsSync(resolvedDir)) {
438519
+ throw new Error(`Project directory does not exist: ${projectDir}`);
438520
+ }
438521
+ return resolvedDir;
438522
+ };
438523
+ var validateFilePath = (filePath, projectDir) => {
438524
+ const absolutePath = path13.resolve(projectDir, filePath);
438525
+ if (!absolutePath.startsWith(path13.resolve(projectDir))) {
438526
+ return null;
438527
+ }
438528
+ if (absolutePath.includes("..")) {
438529
+ return null;
438530
+ }
438531
+ return fs12.existsSync(absolutePath) ? absolutePath : null;
438532
+ };
438463
438533
  var getEntrypoint = async ({
438464
438534
  filePath,
438465
438535
  projectDir = process.cwd(),
438466
438536
  onSuccess = (message) => console.log(message),
438467
438537
  onError = (message) => console.error(message)
438468
438538
  }) => {
438469
- if (filePath) {
438470
- const absolutePath = path13.resolve(projectDir, filePath);
438471
- if (fs12.existsSync(absolutePath)) {
438472
- onSuccess(`Using provided file: '${path13.relative(projectDir, absolutePath)}'`);
438473
- return absolutePath;
438539
+ try {
438540
+ const validatedProjectDir = validateProjectDir(projectDir);
438541
+ if (filePath) {
438542
+ const validatedPath = validateFilePath(filePath, validatedProjectDir);
438543
+ if (validatedPath) {
438544
+ const relativePath = path13.relative(validatedProjectDir, validatedPath);
438545
+ onSuccess(`Using provided file: '${relativePath}'`);
438546
+ return validatedPath;
438547
+ }
438548
+ onError(kleur_default.red(`File not found or invalid: '${filePath}'`));
438549
+ return null;
438474
438550
  }
438475
- onError(kleur_default.red(`File not found: '${filePath}'`));
438476
- return null;
438477
- }
438478
- const projectConfig = loadProjectConfig(projectDir);
438479
- if (projectConfig?.mainEntrypoint) {
438480
- const configEntrypoint = path13.resolve(projectDir, projectConfig.mainEntrypoint);
438481
- if (fs12.existsSync(configEntrypoint)) {
438482
- onSuccess(`Using entrypoint from tscircuit.config.json: '${path13.relative(projectDir, configEntrypoint)}'`);
438483
- return configEntrypoint;
438484
- }
438485
- }
438486
- const possibleEntrypoints = [
438487
- path13.resolve(projectDir, "index.tsx"),
438488
- path13.resolve(projectDir, "index.ts"),
438489
- path13.resolve(projectDir, "index.circuit.tsx"),
438490
- path13.resolve(projectDir, "main.tsx"),
438491
- path13.resolve(projectDir, "main.circuit.tsx"),
438492
- path13.resolve(projectDir, "lib/index.tsx"),
438493
- path13.resolve(projectDir, "lib/index.ts"),
438494
- path13.resolve(projectDir, "lib/index.circuit.tsx"),
438495
- path13.resolve(projectDir, "lib/main.tsx"),
438496
- path13.resolve(projectDir, "lib/main.circuit.tsx"),
438497
- path13.resolve(projectDir, "src/index.tsx"),
438498
- path13.resolve(projectDir, "src/index.ts"),
438499
- path13.resolve(projectDir, "src/index.circuit.tsx"),
438500
- path13.resolve(projectDir, "src/main.tsx"),
438501
- path13.resolve(projectDir, "src/main.circuit.tsx")
438502
- ];
438503
- let detectedEntrypoint = null;
438504
- for (const entrypoint of possibleEntrypoints) {
438505
- if (fs12.existsSync(entrypoint)) {
438506
- detectedEntrypoint = entrypoint;
438507
- const relativePath = path13.relative(projectDir, entrypoint);
438508
- onSuccess(`Detected entrypoint: '${relativePath}'`);
438509
- break;
438551
+ const projectConfig = loadProjectConfig(validatedProjectDir);
438552
+ if (projectConfig?.mainEntrypoint && typeof projectConfig.mainEntrypoint === "string") {
438553
+ const validatedConfigPath = validateFilePath(projectConfig.mainEntrypoint, validatedProjectDir);
438554
+ if (validatedConfigPath) {
438555
+ const relativePath = path13.relative(validatedProjectDir, validatedConfigPath);
438556
+ onSuccess(`Using entrypoint from tscircuit.config.json: '${relativePath}'`);
438557
+ return validatedConfigPath;
438558
+ }
438559
+ }
438560
+ const commonLocations = [
438561
+ "index.tsx",
438562
+ "index.ts",
438563
+ "index.circuit.tsx",
438564
+ "main.tsx",
438565
+ "main.circuit.tsx",
438566
+ "lib/index.tsx",
438567
+ "lib/index.ts",
438568
+ "lib/index.circuit.tsx",
438569
+ "lib/main.tsx",
438570
+ "lib/main.circuit.tsx",
438571
+ "src/index.tsx",
438572
+ "src/index.ts",
438573
+ "src/index.circuit.tsx",
438574
+ "src/main.tsx",
438575
+ "src/main.circuit.tsx"
438576
+ ].map((location) => path13.resolve(validatedProjectDir, location));
438577
+ const recursiveEntrypoints = findEntrypointsRecursively(validatedProjectDir, validatedProjectDir);
438578
+ const possibleEntrypoints = [...commonLocations, ...recursiveEntrypoints];
438579
+ for (const entrypoint of possibleEntrypoints) {
438580
+ if (fs12.existsSync(entrypoint) && isValidDirectory(entrypoint, validatedProjectDir)) {
438581
+ const relativePath = path13.relative(validatedProjectDir, entrypoint);
438582
+ onSuccess(`Detected entrypoint: '${relativePath}'`);
438583
+ return entrypoint;
438584
+ }
438510
438585
  }
438511
- }
438512
- if (!detectedEntrypoint) {
438513
438586
  onError(kleur_default.red("No entrypoint found. Run 'tsci init' to bootstrap a basic project or specify a file with 'tsci push <file>'"));
438587
+ return null;
438588
+ } catch (error) {
438589
+ onError(kleur_default.red(`Error detecting entrypoint: ${error instanceof Error ? error.message : "Unknown error"}`));
438590
+ return null;
438514
438591
  }
438515
- return detectedEntrypoint;
438516
438592
  };
438517
438593
 
438518
438594
  // lib/utils/get-unscoped-package-name.ts
@@ -439339,11 +439415,12 @@ class DevServer {
439339
439415
  typesHandler;
439340
439416
  constructor({
439341
439417
  port,
439342
- componentFilePath
439418
+ componentFilePath,
439419
+ projectDir
439343
439420
  }) {
439344
439421
  this.port = port;
439345
439422
  this.componentFilePath = componentFilePath;
439346
- this.projectDir = path18.dirname(componentFilePath);
439423
+ this.projectDir = projectDir ?? path18.dirname(componentFilePath);
439347
439424
  const projectConfig = loadProjectConfig(this.projectDir);
439348
439425
  this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
439349
439426
  this.fsKy = distribution_default.create({
@@ -439565,7 +439642,8 @@ var registerDev = (program3) => {
439565
439642
  }
439566
439643
  const server2 = new DevServer({
439567
439644
  port,
439568
- componentFilePath: absolutePath
439645
+ componentFilePath: absolutePath,
439646
+ projectDir: process.cwd()
439569
439647
  });
439570
439648
  await server2.start();
439571
439649
  const timeToStart = Date.now() - startTime;
@@ -451734,8 +451812,9 @@ init_zod();
451734
451812
  init_dist();
451735
451813
  var import_transformation_matrix72 = __toESM2(require_build_commonjs(), 1);
451736
451814
  var import_transformation_matrix73 = __toESM2(require_build_commonjs(), 1);
451737
- init_dist5();
451738
451815
  var import_transformation_matrix74 = __toESM2(require_build_commonjs(), 1);
451816
+ init_dist5();
451817
+ var import_transformation_matrix75 = __toESM2(require_build_commonjs(), 1);
451739
451818
  init_zod();
451740
451819
  var import_react2 = __toESM2(require_react(), 1);
451741
451820
  init_dist5();
@@ -453174,7 +453253,7 @@ var calculateElbow = (point1, point22, options = {}) => {
453174
453253
  // node_modules/@tscircuit/core/dist/index.js
453175
453254
  init_dist();
453176
453255
  init_dist4();
453177
- var import_transformation_matrix75 = __toESM2(require_build_commonjs(), 1);
453256
+ var import_transformation_matrix76 = __toESM2(require_build_commonjs(), 1);
453178
453257
 
453179
453258
  // node_modules/@tscircuit/capacity-autorouter/dist/index.js
453180
453259
  var import_object_hash = __toESM2(require_object_hash(), 1);
@@ -468761,11 +468840,11 @@ var package_default3 = {
468761
468840
  // node_modules/@tscircuit/core/dist/index.js
468762
468841
  init_dist();
468763
468842
  var import_debug21 = __toESM2(require_src2(), 1);
468764
- var import_transformation_matrix76 = __toESM2(require_build_commonjs(), 1);
468843
+ var import_transformation_matrix77 = __toESM2(require_build_commonjs(), 1);
468765
468844
  init_dist2();
468766
468845
  init_dist2();
468767
468846
  init_dist2();
468768
- var import_transformation_matrix77 = __toESM2(require_build_commonjs(), 1);
468847
+ var import_transformation_matrix78 = __toESM2(require_build_commonjs(), 1);
468769
468848
  init_dist2();
468770
468849
  init_dist2();
468771
468850
  init_dist4();
@@ -476798,7 +476877,7 @@ var layoutSchematicGraphVariants = (variants, {
476798
476877
  var import_debug22 = __toESM2(require_src2(), 1);
476799
476878
  init_dist2();
476800
476879
  init_dist4();
476801
- var import_transformation_matrix78 = __toESM2(require_build_commonjs(), 1);
476880
+ var import_transformation_matrix79 = __toESM2(require_build_commonjs(), 1);
476802
476881
  init_dist2();
476803
476882
 
476804
476883
  // node_modules/@tscircuit/checks/dist/index.js
@@ -477370,7 +477449,6 @@ function formatSiUnit(value2) {
477370
477449
  }
477371
477450
 
477372
477451
  // node_modules/@tscircuit/core/dist/index.js
477373
- var import_transformation_matrix79 = __toESM2(require_build_commonjs(), 1);
477374
477452
  var import_transformation_matrix80 = __toESM2(require_build_commonjs(), 1);
477375
477453
  var import_transformation_matrix81 = __toESM2(require_build_commonjs(), 1);
477376
477454
  init_dist2();
@@ -479479,6 +479557,157 @@ var SilkscreenText = class extends PrimitiveComponent2 {
479479
479557
  return { width: textWidth * fontSize, height: textHeight * fontSize };
479480
479558
  }
479481
479559
  };
479560
+ var Cutout = class extends PrimitiveComponent2 {
479561
+ pcb_cutout_id = null;
479562
+ isPcbPrimitive = true;
479563
+ get config() {
479564
+ return {
479565
+ componentName: "Cutout",
479566
+ zodProps: cutoutProps
479567
+ };
479568
+ }
479569
+ doInitialPcbPrimitiveRender() {
479570
+ if (this.root?.pcbDisabled)
479571
+ return;
479572
+ const { db } = this.root;
479573
+ const { _parsedProps: props } = this;
479574
+ const subcircuit = this.getSubcircuit();
479575
+ const pcb_group_id = this.getGroup()?.pcb_group_id ?? undefined;
479576
+ const globalPosition = this._getGlobalPcbPositionBeforeLayout();
479577
+ let inserted_pcb_cutout = undefined;
479578
+ if (props.shape === "rect") {
479579
+ const rectData = {
479580
+ shape: "rect",
479581
+ center: globalPosition,
479582
+ width: props.width,
479583
+ height: props.height,
479584
+ subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
479585
+ pcb_group_id
479586
+ };
479587
+ inserted_pcb_cutout = db.pcb_cutout.insert(rectData);
479588
+ } else if (props.shape === "circle") {
479589
+ const circleData = {
479590
+ shape: "circle",
479591
+ center: globalPosition,
479592
+ radius: props.radius,
479593
+ subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
479594
+ pcb_group_id
479595
+ };
479596
+ inserted_pcb_cutout = db.pcb_cutout.insert(circleData);
479597
+ } else if (props.shape === "polygon") {
479598
+ const transform2 = this._computePcbGlobalTransformBeforeLayout();
479599
+ const transformedPoints = props.points.map((p) => import_transformation_matrix74.applyToPoint(transform2, p));
479600
+ const polygonData = {
479601
+ shape: "polygon",
479602
+ points: transformedPoints,
479603
+ subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
479604
+ pcb_group_id
479605
+ };
479606
+ inserted_pcb_cutout = db.pcb_cutout.insert(polygonData);
479607
+ }
479608
+ if (inserted_pcb_cutout) {
479609
+ this.pcb_cutout_id = inserted_pcb_cutout.pcb_cutout_id;
479610
+ }
479611
+ }
479612
+ getPcbSize() {
479613
+ const { _parsedProps: props } = this;
479614
+ if (props.shape === "rect") {
479615
+ return { width: props.width, height: props.height };
479616
+ }
479617
+ if (props.shape === "circle") {
479618
+ return { width: props.radius * 2, height: props.radius * 2 };
479619
+ }
479620
+ if (props.shape === "polygon") {
479621
+ if (props.points.length === 0)
479622
+ return { width: 0, height: 0 };
479623
+ let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
479624
+ for (const point4 of props.points) {
479625
+ minX = Math.min(minX, point4.x);
479626
+ maxX = Math.max(maxX, point4.x);
479627
+ minY = Math.min(minY, point4.y);
479628
+ maxY = Math.max(maxY, point4.y);
479629
+ }
479630
+ return { width: maxX - minX, height: maxY - minY };
479631
+ }
479632
+ return { width: 0, height: 0 };
479633
+ }
479634
+ _getPcbCircuitJsonBounds() {
479635
+ if (!this.pcb_cutout_id)
479636
+ return super._getPcbCircuitJsonBounds();
479637
+ const { db } = this.root;
479638
+ const cutout = db.pcb_cutout.get(this.pcb_cutout_id);
479639
+ if (!cutout)
479640
+ return super._getPcbCircuitJsonBounds();
479641
+ if (cutout.shape === "rect") {
479642
+ return {
479643
+ center: cutout.center,
479644
+ bounds: {
479645
+ left: cutout.center.x - cutout.width / 2,
479646
+ top: cutout.center.y + cutout.height / 2,
479647
+ right: cutout.center.x + cutout.width / 2,
479648
+ bottom: cutout.center.y - cutout.height / 2
479649
+ },
479650
+ width: cutout.width,
479651
+ height: cutout.height
479652
+ };
479653
+ } else if (cutout.shape === "circle") {
479654
+ return {
479655
+ center: cutout.center,
479656
+ bounds: {
479657
+ left: cutout.center.x - cutout.radius,
479658
+ top: cutout.center.y + cutout.radius,
479659
+ right: cutout.center.x + cutout.radius,
479660
+ bottom: cutout.center.y - cutout.radius
479661
+ },
479662
+ width: cutout.radius * 2,
479663
+ height: cutout.radius * 2
479664
+ };
479665
+ } else if (cutout.shape === "polygon") {
479666
+ if (cutout.points.length === 0)
479667
+ return super._getPcbCircuitJsonBounds();
479668
+ let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
479669
+ for (const point4 of cutout.points) {
479670
+ minX = Math.min(minX, point4.x);
479671
+ maxX = Math.max(maxX, point4.x);
479672
+ minY = Math.min(minY, point4.y);
479673
+ maxY = Math.max(maxY, point4.y);
479674
+ }
479675
+ return {
479676
+ center: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
479677
+ bounds: { left: minX, top: maxY, right: maxX, bottom: minY },
479678
+ width: maxX - minX,
479679
+ height: maxY - minY
479680
+ };
479681
+ }
479682
+ return super._getPcbCircuitJsonBounds();
479683
+ }
479684
+ _setPositionFromLayout(newCenter) {
479685
+ if (!this.pcb_cutout_id)
479686
+ return;
479687
+ const { db } = this.root;
479688
+ const cutout = db.pcb_cutout.get(this.pcb_cutout_id);
479689
+ if (!cutout)
479690
+ return;
479691
+ if (cutout.shape === "rect" || cutout.shape === "circle") {
479692
+ db.pcb_cutout.update(this.pcb_cutout_id, {
479693
+ ...cutout,
479694
+ center: newCenter
479695
+ });
479696
+ } else if (cutout.shape === "polygon") {
479697
+ const oldCenter = this._getPcbCircuitJsonBounds().center;
479698
+ const dx = newCenter.x - oldCenter.x;
479699
+ const dy = newCenter.y - oldCenter.y;
479700
+ const newPoints = cutout.points.map((p) => ({
479701
+ x: p.x + dx,
479702
+ y: p.y + dy
479703
+ }));
479704
+ db.pcb_cutout.update(this.pcb_cutout_id, {
479705
+ ...cutout,
479706
+ points: newPoints
479707
+ });
479708
+ }
479709
+ }
479710
+ };
479482
479711
  var createPinrowSilkscreenText = ({
479483
479712
  elm,
479484
479713
  pinLabels,
@@ -479587,6 +479816,28 @@ var createComponentsFromCircuitJson = ({
479587
479816
  pcbY: elm.y,
479588
479817
  diameter: elm.hole_diameter
479589
479818
  }));
479819
+ } else if (elm.type === "pcb_cutout") {
479820
+ if (elm.shape === "rect") {
479821
+ components.push(new Cutout({
479822
+ pcbX: elm.center.x,
479823
+ pcbY: elm.center.y,
479824
+ shape: "rect",
479825
+ width: elm.width,
479826
+ height: elm.height
479827
+ }));
479828
+ } else if (elm.shape === "circle") {
479829
+ components.push(new Cutout({
479830
+ pcbX: elm.center.x,
479831
+ pcbY: elm.center.y,
479832
+ shape: "circle",
479833
+ radius: elm.radius
479834
+ }));
479835
+ } else if (elm.shape === "polygon") {
479836
+ components.push(new Cutout({
479837
+ shape: "polygon",
479838
+ points: elm.points
479839
+ }));
479840
+ }
479590
479841
  } else if (elm.type === "pcb_silkscreen_text") {
479591
479842
  const ccwRotation = calculateCcwRotation(componentRotation, elm.ccw_rotation);
479592
479843
  if (footprint.includes("pinrow") && elm.text.includes("PIN")) {
@@ -479602,7 +479853,7 @@ var createComponentsFromCircuitJson = ({
479602
479853
  anchorAlignment: elm.anchor_alignment || "center",
479603
479854
  text: componentName,
479604
479855
  fontSize: elm.font_size + 0.2,
479605
- pcbX: isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
479856
+ pcbX: Number.isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
479606
479857
  pcbY: elm.anchor_position.y,
479607
479858
  pcbRotation: ccwRotation ?? 0
479608
479859
  }));
@@ -479816,8 +480067,8 @@ var Port = class extends PrimitiveComponent2 {
479816
480067
  throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);
479817
480068
  }
479818
480069
  }
479819
- const transform2 = import_transformation_matrix74.compose(this.parent.computeSchematicGlobalTransform(), import_transformation_matrix74.translate(-symbol8.center.x, -symbol8.center.y));
479820
- return import_transformation_matrix74.applyToPoint(transform2, schematicSymbolPortDef);
480070
+ const transform2 = import_transformation_matrix75.compose(this.parent.computeSchematicGlobalTransform(), import_transformation_matrix75.translate(-symbol8.center.x, -symbol8.center.y));
480071
+ return import_transformation_matrix75.applyToPoint(transform2, schematicSymbolPortDef);
479821
480072
  }
479822
480073
  const parentBoxDim = this?.parent?._getSchematicBoxDimensions();
479823
480074
  if (parentBoxDim && this.props.pinNumber !== undefined) {
@@ -479825,7 +480076,7 @@ var Port = class extends PrimitiveComponent2 {
479825
480076
  if (!localPortPosition) {
479826
480077
  throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);
479827
480078
  }
479828
- return import_transformation_matrix74.applyToPoint(this.parent.computeSchematicGlobalTransform(), localPortPosition);
480079
+ return import_transformation_matrix75.applyToPoint(this.parent.computeSchematicGlobalTransform(), localPortPosition);
479829
480080
  }
479830
480081
  throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`);
479831
480082
  }
@@ -483315,7 +483566,7 @@ var TraceHint = class extends PrimitiveComponent2 {
483315
483566
  return [];
483316
483567
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
483317
483568
  return offsets.map((offset) => ({
483318
- ...import_transformation_matrix76.applyToPoint(globalTransform, offset),
483569
+ ...import_transformation_matrix77.applyToPoint(globalTransform, offset),
483319
483570
  via: offset.via,
483320
483571
  to_layer: offset.to_layer,
483321
483572
  trace_width: offset.trace_width
@@ -483947,7 +484198,7 @@ function Group_doInitialPcbLayoutGrid(group) {
483947
484198
  const newCenter = { x: targetCellCenterX, y: targetCellCenterY };
483948
484199
  const deltaX = newCenter.x - oldCenter.x;
483949
484200
  const deltaY = newCenter.y - oldCenter.y;
483950
- const mat = import_transformation_matrix78.translate(deltaX, deltaY);
484201
+ const mat = import_transformation_matrix79.translate(deltaX, deltaY);
483951
484202
  const related = db.toArray().filter((e) => e.pcb_component_id === child.pcb_component_id);
483952
484203
  const moved = transformPCBElements(related, mat);
483953
484204
  for (const elm of moved) {
@@ -483966,8 +484217,8 @@ function Group_doInitialPcbLayoutGrid(group) {
483966
484217
  }
483967
484218
  if (group.pcb_group_id) {
483968
484219
  db.pcb_group.update(group.pcb_group_id, {
483969
- width: totalGridWidth,
483970
- height: totalGridHeight,
484220
+ width: props.width ?? totalGridWidth,
484221
+ height: props.height ?? totalGridHeight,
483971
484222
  center: groupCenter
483972
484223
  });
483973
484224
  }
@@ -484106,8 +484357,8 @@ var Group = class extends NormalComponent {
484106
484357
  centerY += (padTop - padBottom) / 2;
484107
484358
  }
484108
484359
  db.pcb_group.update(this.pcb_group_id, {
484109
- width,
484110
- height,
484360
+ width: Number(props.width ?? width),
484361
+ height: Number(props.height ?? height),
484111
484362
  center: {
484112
484363
  x: centerX,
484113
484364
  y: centerY
@@ -484818,7 +485069,7 @@ var Board = class extends Group {
484818
485069
  this.pcb_board_id = null;
484819
485070
  }
484820
485071
  _computePcbGlobalTransformBeforeLayout() {
484821
- return import_transformation_matrix75.identity();
485072
+ return import_transformation_matrix76.identity();
484822
485073
  }
484823
485074
  doInitialPcbDesignRuleChecks() {
484824
485075
  if (this.root?.pcbDisabled)
@@ -485498,7 +485749,7 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
485498
485749
  layer,
485499
485750
  color: props.color,
485500
485751
  route: props.route.map((p) => {
485501
- const transformedPosition = import_transformation_matrix79.applyToPoint(transform2, {
485752
+ const transformedPosition = import_transformation_matrix80.applyToPoint(transform2, {
485502
485753
  x: p.x,
485503
485754
  y: p.y
485504
485755
  });
@@ -485716,8 +485967,8 @@ var NetLabel = class extends PrimitiveComponent2 {
485716
485967
  const connectedPorts = this._getConnectedPorts();
485717
485968
  if (connectedPorts.length > 0) {
485718
485969
  const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
485719
- const parentCenter = import_transformation_matrix80.applyToPoint(this.parent?.computeSchematicGlobalTransform?.() ?? import_transformation_matrix80.identity(), { x: 0, y: 0 });
485720
- return import_transformation_matrix80.translate(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
485970
+ const parentCenter = import_transformation_matrix81.applyToPoint(this.parent?.computeSchematicGlobalTransform?.() ?? import_transformation_matrix81.identity(), { x: 0, y: 0 });
485971
+ return import_transformation_matrix81.translate(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
485721
485972
  }
485722
485973
  }
485723
485974
  return super.computeSchematicPropsTransform();
@@ -485961,157 +486212,6 @@ var Via = class extends PrimitiveComponent2 {
485961
486212
  this.pcb_via_id = pcb_via2.pcb_via_id;
485962
486213
  }
485963
486214
  };
485964
- var Cutout = class extends PrimitiveComponent2 {
485965
- pcb_cutout_id = null;
485966
- isPcbPrimitive = true;
485967
- get config() {
485968
- return {
485969
- componentName: "Cutout",
485970
- zodProps: cutoutProps
485971
- };
485972
- }
485973
- doInitialPcbPrimitiveRender() {
485974
- if (this.root?.pcbDisabled)
485975
- return;
485976
- const { db } = this.root;
485977
- const { _parsedProps: props } = this;
485978
- const subcircuit = this.getSubcircuit();
485979
- const pcb_group_id = this.getGroup()?.pcb_group_id ?? undefined;
485980
- const globalPosition = this._getGlobalPcbPositionBeforeLayout();
485981
- let inserted_pcb_cutout = undefined;
485982
- if (props.shape === "rect") {
485983
- const rectData = {
485984
- shape: "rect",
485985
- center: globalPosition,
485986
- width: props.width,
485987
- height: props.height,
485988
- subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
485989
- pcb_group_id
485990
- };
485991
- inserted_pcb_cutout = db.pcb_cutout.insert(rectData);
485992
- } else if (props.shape === "circle") {
485993
- const circleData = {
485994
- shape: "circle",
485995
- center: globalPosition,
485996
- radius: props.radius,
485997
- subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
485998
- pcb_group_id
485999
- };
486000
- inserted_pcb_cutout = db.pcb_cutout.insert(circleData);
486001
- } else if (props.shape === "polygon") {
486002
- const transform2 = this._computePcbGlobalTransformBeforeLayout();
486003
- const transformedPoints = props.points.map((p) => import_transformation_matrix81.applyToPoint(transform2, p));
486004
- const polygonData = {
486005
- shape: "polygon",
486006
- points: transformedPoints,
486007
- subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
486008
- pcb_group_id
486009
- };
486010
- inserted_pcb_cutout = db.pcb_cutout.insert(polygonData);
486011
- }
486012
- if (inserted_pcb_cutout) {
486013
- this.pcb_cutout_id = inserted_pcb_cutout.pcb_cutout_id;
486014
- }
486015
- }
486016
- getPcbSize() {
486017
- const { _parsedProps: props } = this;
486018
- if (props.shape === "rect") {
486019
- return { width: props.width, height: props.height };
486020
- }
486021
- if (props.shape === "circle") {
486022
- return { width: props.radius * 2, height: props.radius * 2 };
486023
- }
486024
- if (props.shape === "polygon") {
486025
- if (props.points.length === 0)
486026
- return { width: 0, height: 0 };
486027
- let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
486028
- for (const point4 of props.points) {
486029
- minX = Math.min(minX, point4.x);
486030
- maxX = Math.max(maxX, point4.x);
486031
- minY = Math.min(minY, point4.y);
486032
- maxY = Math.max(maxY, point4.y);
486033
- }
486034
- return { width: maxX - minX, height: maxY - minY };
486035
- }
486036
- return { width: 0, height: 0 };
486037
- }
486038
- _getPcbCircuitJsonBounds() {
486039
- if (!this.pcb_cutout_id)
486040
- return super._getPcbCircuitJsonBounds();
486041
- const { db } = this.root;
486042
- const cutout = db.pcb_cutout.get(this.pcb_cutout_id);
486043
- if (!cutout)
486044
- return super._getPcbCircuitJsonBounds();
486045
- if (cutout.shape === "rect") {
486046
- return {
486047
- center: cutout.center,
486048
- bounds: {
486049
- left: cutout.center.x - cutout.width / 2,
486050
- top: cutout.center.y + cutout.height / 2,
486051
- right: cutout.center.x + cutout.width / 2,
486052
- bottom: cutout.center.y - cutout.height / 2
486053
- },
486054
- width: cutout.width,
486055
- height: cutout.height
486056
- };
486057
- } else if (cutout.shape === "circle") {
486058
- return {
486059
- center: cutout.center,
486060
- bounds: {
486061
- left: cutout.center.x - cutout.radius,
486062
- top: cutout.center.y + cutout.radius,
486063
- right: cutout.center.x + cutout.radius,
486064
- bottom: cutout.center.y - cutout.radius
486065
- },
486066
- width: cutout.radius * 2,
486067
- height: cutout.radius * 2
486068
- };
486069
- } else if (cutout.shape === "polygon") {
486070
- if (cutout.points.length === 0)
486071
- return super._getPcbCircuitJsonBounds();
486072
- let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
486073
- for (const point4 of cutout.points) {
486074
- minX = Math.min(minX, point4.x);
486075
- maxX = Math.max(maxX, point4.x);
486076
- minY = Math.min(minY, point4.y);
486077
- maxY = Math.max(maxY, point4.y);
486078
- }
486079
- return {
486080
- center: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
486081
- bounds: { left: minX, top: maxY, right: maxX, bottom: minY },
486082
- width: maxX - minX,
486083
- height: maxY - minY
486084
- };
486085
- }
486086
- return super._getPcbCircuitJsonBounds();
486087
- }
486088
- _setPositionFromLayout(newCenter) {
486089
- if (!this.pcb_cutout_id)
486090
- return;
486091
- const { db } = this.root;
486092
- const cutout = db.pcb_cutout.get(this.pcb_cutout_id);
486093
- if (!cutout)
486094
- return;
486095
- if (cutout.shape === "rect" || cutout.shape === "circle") {
486096
- db.pcb_cutout.update(this.pcb_cutout_id, {
486097
- ...cutout,
486098
- center: newCenter
486099
- });
486100
- } else if (cutout.shape === "polygon") {
486101
- const oldCenter = this._getPcbCircuitJsonBounds().center;
486102
- const dx = newCenter.x - oldCenter.x;
486103
- const dy = newCenter.y - oldCenter.y;
486104
- const newPoints = cutout.points.map((p) => ({
486105
- x: p.x + dx,
486106
- y: p.y + dy
486107
- }));
486108
- db.pcb_cutout.update(this.pcb_cutout_id, {
486109
- ...cutout,
486110
- points: newPoints
486111
- });
486112
- }
486113
- }
486114
- };
486115
486215
  var Battery = class extends NormalComponent {
486116
486216
  get config() {
486117
486217
  return {
@@ -486962,7 +487062,7 @@ var SchematicCell = class extends PrimitiveComponent2 {
486962
487062
  var package_default4 = {
486963
487063
  name: "@tscircuit/core",
486964
487064
  type: "module",
486965
- version: "0.0.573",
487065
+ version: "0.0.575",
486966
487066
  types: "dist/index.d.ts",
486967
487067
  main: "dist/index.js",
486968
487068
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.183",
3
+ "version": "0.1.185",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -37,21 +37,28 @@
37
37
  "jwt-decode": "^4.0.0",
38
38
  "kleur": "^4.1.5",
39
39
  "ky": "^1.7.4",
40
- "looks-same": "^9.0.1",
41
40
  "make-vfs": "^1.0.15",
42
41
  "perfect-cli": "^1.0.20",
43
42
  "prompts": "^2.4.2",
44
43
  "redaxios": "^0.5.1",
45
44
  "semver": "^7.6.3",
46
45
  "tempy": "^3.1.0",
47
- "tscircuit": "^0.0.553",
46
+ "tscircuit": "^0.0.555",
48
47
  "tsx": "^4.7.1",
49
48
  "typed-ky": "^0.0.4",
50
49
  "zod": "3"
51
50
  },
51
+ "dependencies": {
52
+ "looks-same": "^9.0.1"
53
+ },
52
54
  "peerDependencies": {
53
55
  "tscircuit": "*"
54
56
  },
57
+ "peerDependenciesMeta": {
58
+ "tscircuit": {
59
+ "optional": true
60
+ }
61
+ },
55
62
  "bin": {
56
63
  "tsci": "./cli/entrypoint.js"
57
64
  },