@tscircuit/core 0.0.804 → 0.0.806

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
@@ -1858,6 +1858,15 @@ var SmtPad = class extends PrimitiveComponent2 {
1858
1858
  if (props.shape === "rect") {
1859
1859
  return { width: props.width, height: props.height };
1860
1860
  }
1861
+ if (props.shape === "rotated_rect") {
1862
+ const rotationDegrees = props.ccwRotation ?? 0;
1863
+ const angleRad = rotationDegrees * Math.PI / 180;
1864
+ const cosAngle = Math.cos(angleRad);
1865
+ const sinAngle = Math.sin(angleRad);
1866
+ const width = Math.abs(props.width * cosAngle) + Math.abs(props.height * sinAngle);
1867
+ const height = Math.abs(props.width * sinAngle) + Math.abs(props.height * cosAngle);
1868
+ return { width, height };
1869
+ }
1861
1870
  if (props.shape === "polygon") {
1862
1871
  const points = props.points;
1863
1872
  const xs = points.map((p) => p.x);
@@ -1908,6 +1917,7 @@ var SmtPad = class extends PrimitiveComponent2 {
1908
1917
  const isAxisAligned = Math.abs(normalizedRotationDegrees) < rotationTolerance || Math.abs(normalizedRotationDegrees - 180) < rotationTolerance || Math.abs(normalizedRotationDegrees - 360) < rotationTolerance;
1909
1918
  const isRotated90Degrees = Math.abs(normalizedRotationDegrees - 90) < rotationTolerance || Math.abs(normalizedRotationDegrees - 270) < rotationTolerance;
1910
1919
  let finalRotationDegrees = Math.abs(normalizedRotationDegrees - 360) < rotationTolerance ? 0 : normalizedRotationDegrees;
1920
+ const transformRotationBeforeFlip = finalRotationDegrees;
1911
1921
  const { maybeFlipLayer, isFlipped } = this._getPcbPrimitiveFlippedHelpers();
1912
1922
  if (isFlipped) {
1913
1923
  finalRotationDegrees = (360 - finalRotationDegrees + 360) % 360;
@@ -1992,12 +2002,46 @@ var SmtPad = class extends PrimitiveComponent2 {
1992
2002
  height: pcb_smtpad.height * 0.7,
1993
2003
  x: pcb_smtpad.x,
1994
2004
  y: pcb_smtpad.y,
1995
- ccw_rotation: finalRotationDegrees,
2005
+ ccw_rotation: pcb_smtpad.ccw_rotation,
1996
2006
  pcb_component_id: pcb_smtpad.pcb_component_id,
1997
2007
  pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
1998
2008
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
1999
2009
  pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
2000
2010
  });
2011
+ } else if (props.shape === "rotated_rect") {
2012
+ const baseRotation = props.ccwRotation ?? 0;
2013
+ const combinedRotationBeforeFlip = (transformRotationBeforeFlip + baseRotation + 360) % 360;
2014
+ const padRotation = isFlipped ? (360 - combinedRotationBeforeFlip + 360) % 360 : combinedRotationBeforeFlip;
2015
+ pcb_smtpad = db.pcb_smtpad.insert({
2016
+ pcb_component_id,
2017
+ pcb_port_id: this.matchedPort?.pcb_port_id,
2018
+ layer: maybeFlipLayer(props.layer ?? "top"),
2019
+ shape: "rotated_rect",
2020
+ width: props.width,
2021
+ height: props.height,
2022
+ corner_radius: props.cornerRadius ?? 0,
2023
+ x: position.x,
2024
+ y: position.y,
2025
+ ccw_rotation: padRotation,
2026
+ port_hints: props.portHints.map((ph) => ph.toString()),
2027
+ is_covered_with_solder_mask: isCoveredWithSolderMask,
2028
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
2029
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
2030
+ });
2031
+ if (shouldCreateSolderPaste)
2032
+ db.pcb_solder_paste.insert({
2033
+ layer: maybeFlipLayer(props.layer ?? "top"),
2034
+ shape: "rotated_rect",
2035
+ width: pcb_smtpad.width * 0.7,
2036
+ height: pcb_smtpad.height * 0.7,
2037
+ x: position.x,
2038
+ y: position.y,
2039
+ ccw_rotation: padRotation,
2040
+ pcb_component_id,
2041
+ pcb_smtpad_id: pcb_smtpad.pcb_smtpad_id,
2042
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
2043
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
2044
+ });
2001
2045
  } else if (props.shape === "polygon") {
2002
2046
  pcb_smtpad = db.pcb_smtpad.insert({
2003
2047
  pcb_component_id,
@@ -4437,7 +4481,8 @@ var CadModel = class extends PrimitiveComponent2 {
4437
4481
  const bounds = parent._getPcbCircuitJsonBounds();
4438
4482
  const pcb_component = db.pcb_component.get(parent.pcb_component_id);
4439
4483
  const props = this._parsedProps;
4440
- if (!props || typeof props.modelUrl !== "string") return;
4484
+ if (!props || typeof props.modelUrl !== "string" && typeof props.stepUrl !== "string")
4485
+ return;
4441
4486
  const parentTransform = parent._computePcbGlobalTransformBeforeLayout();
4442
4487
  const decomposedTransform = decomposeTSR4(parentTransform);
4443
4488
  const accumulatedRotation = decomposedTransform.rotation.angle * 180 / Math.PI;
@@ -4458,7 +4503,7 @@ var CadModel = class extends PrimitiveComponent2 {
4458
4503
  });
4459
4504
  const zOffsetFromSurface = props.zOffsetFromSurface !== void 0 ? distance.parse(props.zOffsetFromSurface) : 0;
4460
4505
  const layer = parent.props.layer === "bottom" ? "bottom" : "top";
4461
- const ext = getFileExtension(props.modelUrl);
4506
+ const ext = props.modelUrl ? getFileExtension(props.modelUrl) : void 0;
4462
4507
  const urlProps = {};
4463
4508
  if (ext === "stl")
4464
4509
  urlProps.model_stl_url = this._addCachebustToModelUrl(props.modelUrl);
@@ -4473,6 +4518,10 @@ var CadModel = class extends PrimitiveComponent2 {
4473
4518
  else if (ext === "wrl" || ext === "vrml")
4474
4519
  urlProps.model_wrl_url = this._addCachebustToModelUrl(props.modelUrl);
4475
4520
  else urlProps.model_stl_url = this._addCachebustToModelUrl(props.modelUrl);
4521
+ if (props.stepUrl) {
4522
+ const transformed = this._addCachebustToModelUrl(props.stepUrl);
4523
+ if (transformed) urlProps.model_step_url = transformed;
4524
+ }
4476
4525
  const cad = db.cad_component.insert({
4477
4526
  position: {
4478
4527
  x: bounds.center.x + Number(positionOffset.x),
@@ -17112,7 +17161,7 @@ import { identity as identity6 } from "transformation-matrix";
17112
17161
  var package_default = {
17113
17162
  name: "@tscircuit/core",
17114
17163
  type: "module",
17115
- version: "0.0.803",
17164
+ version: "0.0.805",
17116
17165
  types: "dist/index.d.ts",
17117
17166
  main: "dist/index.js",
17118
17167
  module: "dist/index.js",
@@ -17152,7 +17201,7 @@ var package_default = {
17152
17201
  "@tscircuit/matchpack": "^0.0.16",
17153
17202
  "@tscircuit/math-utils": "^0.0.29",
17154
17203
  "@tscircuit/miniflex": "^0.0.4",
17155
- "@tscircuit/props": "0.0.369",
17204
+ "@tscircuit/props": "0.0.371",
17156
17205
  "@tscircuit/schematic-autolayout": "^0.0.6",
17157
17206
  "@tscircuit/schematic-match-adapt": "^0.0.16",
17158
17207
  "@tscircuit/schematic-trace-solver": "^0.0.41",
@@ -17170,7 +17219,7 @@ var package_default = {
17170
17219
  "circuit-json-to-connectivity-map": "^0.0.22",
17171
17220
  "circuit-json-to-gltf": "^0.0.26",
17172
17221
  "circuit-json-to-simple-3d": "^0.0.9",
17173
- "circuit-to-svg": "^0.0.245",
17222
+ "circuit-to-svg": "^0.0.250",
17174
17223
  "circuit-json-to-spice": "^0.0.15",
17175
17224
  concurrently: "^9.1.2",
17176
17225
  "connectivity-map": "^1.0.0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.804",
4
+ "version": "0.0.806",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "@tscircuit/matchpack": "^0.0.16",
42
42
  "@tscircuit/math-utils": "^0.0.29",
43
43
  "@tscircuit/miniflex": "^0.0.4",
44
- "@tscircuit/props": "0.0.369",
44
+ "@tscircuit/props": "0.0.371",
45
45
  "@tscircuit/schematic-autolayout": "^0.0.6",
46
46
  "@tscircuit/schematic-match-adapt": "^0.0.16",
47
47
  "@tscircuit/schematic-trace-solver": "^0.0.41",
@@ -59,7 +59,7 @@
59
59
  "circuit-json-to-connectivity-map": "^0.0.22",
60
60
  "circuit-json-to-gltf": "^0.0.26",
61
61
  "circuit-json-to-simple-3d": "^0.0.9",
62
- "circuit-to-svg": "^0.0.245",
62
+ "circuit-to-svg": "^0.0.250",
63
63
  "circuit-json-to-spice": "^0.0.15",
64
64
  "concurrently": "^9.1.2",
65
65
  "connectivity-map": "^1.0.0",