@tscircuit/core 0.0.788 → 0.0.790

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
@@ -84,6 +84,7 @@ __export(components_exports, {
84
84
  // lib/components/base-components/NormalComponent/NormalComponent.ts
85
85
  import { fp } from "@tscircuit/footprinter";
86
86
  import {
87
+ distance as distance4,
87
88
  pcb_manual_edit_conflict_warning,
88
89
  point3 as point32,
89
90
  rotation as rotation2,
@@ -4372,6 +4373,7 @@ var Footprint = class extends PrimitiveComponent2 {
4372
4373
  // lib/components/primitive-components/CadModel.ts
4373
4374
  import { cadmodelProps, point3 } from "@tscircuit/props";
4374
4375
  import { z as z7 } from "zod";
4376
+ import { distance } from "circuit-json";
4375
4377
  import { decomposeTSR as decomposeTSR4 } from "transformation-matrix";
4376
4378
 
4377
4379
  // lib/components/base-components/NormalComponent/utils/getFileExtension.ts
@@ -4385,6 +4387,30 @@ var getFileExtension = (filename) => {
4385
4387
  return extension?.toLowerCase() ?? null;
4386
4388
  };
4387
4389
 
4390
+ // lib/utils/constructAssetUrl.ts
4391
+ var joinUrlPath = (base, path) => {
4392
+ const trimmedBase = base.replace(/\/+$/, "");
4393
+ const trimmedPath = path.replace(/^\/+/, "");
4394
+ return `${trimmedBase}/${trimmedPath}`;
4395
+ };
4396
+ var constructAssetUrl = (targetUrl, baseUrl) => {
4397
+ if (!baseUrl) {
4398
+ return targetUrl;
4399
+ }
4400
+ if (!targetUrl.startsWith("/")) {
4401
+ return targetUrl;
4402
+ }
4403
+ try {
4404
+ const baseUrlObj = new URL(baseUrl);
4405
+ if (baseUrlObj.pathname !== "/" && targetUrl.startsWith(baseUrlObj.pathname)) {
4406
+ return new URL(targetUrl, baseUrlObj.origin).toString();
4407
+ }
4408
+ return joinUrlPath(baseUrl, targetUrl);
4409
+ } catch (error) {
4410
+ return targetUrl;
4411
+ }
4412
+ };
4413
+
4388
4414
  // lib/components/primitive-components/CadModel.ts
4389
4415
  var rotation = z7.union([z7.number(), z7.string()]);
4390
4416
  var rotation3 = z7.object({ x: rotation, y: rotation, z: rotation });
@@ -4423,6 +4449,7 @@ var CadModel = class extends PrimitiveComponent2 {
4423
4449
  z: props.pcbZ ?? 0,
4424
4450
  ...typeof props.positionOffset === "object" ? props.positionOffset : {}
4425
4451
  });
4452
+ const zOffsetFromSurface = props.zOffsetFromSurface !== void 0 ? distance.parse(props.zOffsetFromSurface) : 0;
4426
4453
  const layer = parent.props.layer === "bottom" ? "bottom" : "top";
4427
4454
  const ext = getFileExtension(props.modelUrl);
4428
4455
  const urlProps = {};
@@ -4443,7 +4470,7 @@ var CadModel = class extends PrimitiveComponent2 {
4443
4470
  position: {
4444
4471
  x: bounds.center.x + Number(positionOffset.x),
4445
4472
  y: bounds.center.y + Number(positionOffset.y),
4446
- z: (layer === "bottom" ? -boardThickness / 2 : boardThickness / 2) + Number(positionOffset.z)
4473
+ z: (layer === "bottom" ? -boardThickness / 2 : boardThickness / 2) + (layer === "bottom" ? -zOffsetFromSurface : zOffsetFromSurface) + Number(positionOffset.z)
4447
4474
  },
4448
4475
  rotation: {
4449
4476
  x: Number(rotationOffset.x),
@@ -4463,9 +4490,13 @@ var CadModel = class extends PrimitiveComponent2 {
4463
4490
  return p;
4464
4491
  }
4465
4492
  _addCachebustToModelUrl(url) {
4466
- if (!url || !url.includes("modelcdn.tscircuit.com")) return url;
4493
+ if (!url) return url;
4494
+ const baseUrl = this.root?.platform?.projectBaseUrl;
4495
+ const transformedUrl = constructAssetUrl(url, baseUrl);
4496
+ if (!transformedUrl.includes("modelcdn.tscircuit.com"))
4497
+ return transformedUrl;
4467
4498
  const origin = this.root?.getClientOrigin() ?? "";
4468
- return `${url}${url.includes("?") ? "&" : "?"}cachebust_origin=${encodeURIComponent(origin)}`;
4499
+ return `${transformedUrl}${transformedUrl.includes("?") ? "&" : "?"}cachebust_origin=${encodeURIComponent(origin)}`;
4469
4500
  }
4470
4501
  };
4471
4502
 
@@ -4727,7 +4758,7 @@ var getEnteringEdgeFromDirection = (direction) => {
4727
4758
  };
4728
4759
 
4729
4760
  // lib/utils/schematic/getStubEdges.ts
4730
- import { distance } from "@tscircuit/math-utils";
4761
+ import { distance as distance2 } from "@tscircuit/math-utils";
4731
4762
  var getStubEdges = ({
4732
4763
  firstEdge,
4733
4764
  firstEdgePort,
@@ -4774,7 +4805,7 @@ var getStubEdges = ({
4774
4805
  });
4775
4806
  }
4776
4807
  }
4777
- edges = edges.filter((e) => distance(e.from, e.to) > 0.01);
4808
+ edges = edges.filter((e) => distance2(e.from, e.to) > 0.01);
4778
4809
  return edges;
4779
4810
  };
4780
4811
 
@@ -5277,7 +5308,7 @@ import { calculateElbow } from "calculate-elbow";
5277
5308
  import { doesLineIntersectLine as doesLineIntersectLine3 } from "@tscircuit/math-utils";
5278
5309
 
5279
5310
  // lib/components/primitive-components/Trace/trace-utils/create-schematic-trace-crossing-segments.ts
5280
- import { distance as distance2, doesLineIntersectLine } from "@tscircuit/math-utils";
5311
+ import { distance as distance3, doesLineIntersectLine } from "@tscircuit/math-utils";
5281
5312
 
5282
5313
  // lib/components/primitive-components/Trace/trace-utils/get-other-schematic-traces.ts
5283
5314
  var getOtherSchematicTraces = ({
@@ -5344,7 +5375,7 @@ var createSchematicTraceCrossingSegments = ({
5344
5375
  otherEdgesIntersections.push({
5345
5376
  otherEdge,
5346
5377
  crossingPoint: crossingPoint2,
5347
- distanceFromEdgeFrom: distance2(edge.from, crossingPoint2)
5378
+ distanceFromEdgeFrom: distance3(edge.from, crossingPoint2)
5348
5379
  });
5349
5380
  }
5350
5381
  }
@@ -5369,7 +5400,7 @@ var createSchematicTraceCrossingSegments = ({
5369
5400
  x: crossingPoint.x + crossingUnitVec.x * crossingSegmentLength / 2,
5370
5401
  y: crossingPoint.y + crossingUnitVec.y * crossingSegmentLength / 2
5371
5402
  };
5372
- const overshot = distance2(afterCrossing, edge.to) < crossingSegmentLength;
5403
+ const overshot = distance3(afterCrossing, edge.to) < crossingSegmentLength;
5373
5404
  const newEdges = [
5374
5405
  { from: edge.from, to: beforeCrossing },
5375
5406
  { from: beforeCrossing, to: afterCrossing, is_crossing: true },
@@ -7068,25 +7099,6 @@ import {
7068
7099
  circuit_json_footprint_load_error,
7069
7100
  external_footprint_load_error
7070
7101
  } from "circuit-json";
7071
-
7072
- // lib/utils/constructAssetUrl.ts
7073
- var constructAssetUrl = (targetUrl, baseUrl) => {
7074
- if (!baseUrl) {
7075
- return targetUrl;
7076
- }
7077
- if (!targetUrl.startsWith("/")) {
7078
- return targetUrl;
7079
- }
7080
- try {
7081
- const base = new URL(baseUrl);
7082
- const resolved = new URL(targetUrl, base.origin);
7083
- return resolved.toString();
7084
- } catch (error) {
7085
- return targetUrl;
7086
- }
7087
- };
7088
-
7089
- // lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts
7090
7102
  function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
7091
7103
  let { footprint } = component.props;
7092
7104
  footprint ??= component._getImpliedFootprintString?.();
@@ -8272,6 +8284,9 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8272
8284
  z: 0,
8273
8285
  ...typeof cadModel?.positionOffset === "object" ? cadModel.positionOffset : {}
8274
8286
  });
8287
+ const zOffsetFromSurface = cadModel && typeof cadModel === "object" && "zOffsetFromSurface" in cadModel ? cadModel.zOffsetFromSurface !== void 0 ? distance4.parse(
8288
+ cadModel.zOffsetFromSurface
8289
+ ) : 0 : 0;
8275
8290
  const computedLayer = this.props.layer === "bottom" ? "bottom" : "top";
8276
8291
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
8277
8292
  const decomposedTransform = decomposeTSR5(globalTransform);
@@ -8281,7 +8296,7 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
8281
8296
  position: {
8282
8297
  x: bounds.center.x + positionOffset.x,
8283
8298
  y: bounds.center.y + positionOffset.y,
8284
- z: (computedLayer === "bottom" ? -boardThickness / 2 : boardThickness / 2) + positionOffset.z
8299
+ z: (computedLayer === "bottom" ? -boardThickness / 2 : boardThickness / 2) + (computedLayer === "bottom" ? -zOffsetFromSurface : zOffsetFromSurface) + positionOffset.z
8285
8300
  },
8286
8301
  rotation: {
8287
8302
  x: rotationOffset.x,
@@ -13077,7 +13092,7 @@ var Board = class extends Group6 {
13077
13092
  }
13078
13093
  get boardThickness() {
13079
13094
  const { _parsedProps: props } = this;
13080
- return 1.4;
13095
+ return props.thickness ?? 1.4;
13081
13096
  }
13082
13097
  /**
13083
13098
  * Get all available layers for the board
@@ -16690,7 +16705,7 @@ import { identity as identity6 } from "transformation-matrix";
16690
16705
  var package_default = {
16691
16706
  name: "@tscircuit/core",
16692
16707
  type: "module",
16693
- version: "0.0.787",
16708
+ version: "0.0.789",
16694
16709
  types: "dist/index.d.ts",
16695
16710
  main: "dist/index.js",
16696
16711
  module: "dist/index.js",
@@ -16730,7 +16745,7 @@ var package_default = {
16730
16745
  "@tscircuit/matchpack": "^0.0.16",
16731
16746
  "@tscircuit/math-utils": "^0.0.21",
16732
16747
  "@tscircuit/miniflex": "^0.0.4",
16733
- "@tscircuit/props": "0.0.361",
16748
+ "@tscircuit/props": "0.0.363",
16734
16749
  "@tscircuit/schematic-autolayout": "^0.0.6",
16735
16750
  "@tscircuit/schematic-match-adapt": "^0.0.16",
16736
16751
  "@tscircuit/schematic-trace-solver": "^0.0.41",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.788",
4
+ "version": "0.0.790",
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.21",
43
43
  "@tscircuit/miniflex": "^0.0.4",
44
- "@tscircuit/props": "0.0.361",
44
+ "@tscircuit/props": "0.0.363",
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",