@tscircuit/core 0.0.1349 → 0.0.1351

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.d.ts CHANGED
@@ -81470,7 +81470,7 @@ declare class CourtyardRect extends PrimitiveComponent<typeof courtyardRectProps
81470
81470
  isPcbPrimitive: boolean;
81471
81471
  get config(): {
81472
81472
  componentName: string;
81473
- zodProps: zod.ZodObject<Omit<{
81473
+ zodProps: zod.ZodObject<{
81474
81474
  pcbX: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>]>>;
81475
81475
  pcbY: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>]>>;
81476
81476
  pcbLeftEdgeX: zod.ZodOptional<zod.ZodUnion<[zod.ZodString, zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>]>>;
@@ -81535,7 +81535,7 @@ declare class CourtyardRect extends PrimitiveComponent<typeof courtyardRectProps
81535
81535
  pcbSx: zod.ZodOptional<zod.ZodType<_tscircuit_props.PcbSx, zod.ZodTypeDef, _tscircuit_props.PcbSx>>;
81536
81536
  pcbRelative: zod.ZodOptional<zod.ZodBoolean>;
81537
81537
  relative: zod.ZodOptional<zod.ZodBoolean>;
81538
- }, "pcbRotation"> & {
81538
+ } & {
81539
81539
  width: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
81540
81540
  height: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
81541
81541
  strokeWidth: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
@@ -81555,6 +81555,7 @@ declare class CourtyardRect extends PrimitiveComponent<typeof courtyardRectProps
81555
81555
  pcbBottomEdgeY?: string | number | undefined;
81556
81556
  pcbOffsetX?: number | undefined;
81557
81557
  pcbOffsetY?: number | undefined;
81558
+ pcbRotation?: number | undefined;
81558
81559
  pcbPositionAnchor?: string | undefined;
81559
81560
  pcbPositionMode?: "relative_to_group_anchor" | "auto" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
81560
81561
  shouldBeOnEdgeOfBoard?: boolean | undefined;
@@ -81596,6 +81597,7 @@ declare class CourtyardRect extends PrimitiveComponent<typeof courtyardRectProps
81596
81597
  pcbBottomEdgeY?: string | number | undefined;
81597
81598
  pcbOffsetX?: string | number | undefined;
81598
81599
  pcbOffsetY?: string | number | undefined;
81600
+ pcbRotation?: string | number | undefined;
81599
81601
  pcbPositionAnchor?: string | undefined;
81600
81602
  pcbPositionMode?: "relative_to_group_anchor" | "auto" | "relative_to_board_anchor" | "relative_to_component_anchor" | undefined;
81601
81603
  shouldBeOnEdgeOfBoard?: boolean | undefined;
@@ -152814,6 +152816,7 @@ declare class AnalogSimulation extends PrimitiveComponent<typeof analogSimulatio
152814
152816
  get config(): {
152815
152817
  componentName: string;
152816
152818
  zodProps: zod.ZodObject<{
152819
+ name: zod.ZodOptional<zod.ZodString>;
152817
152820
  simulationType: zod.ZodDefault<zod.ZodLiteral<"spice_transient_analysis">>;
152818
152821
  duration: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
152819
152822
  startTime: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
@@ -152837,6 +152840,7 @@ declare class AnalogSimulation extends PrimitiveComponent<typeof analogSimulatio
152837
152840
  }>>;
152838
152841
  }, "strip", zod.ZodTypeAny, {
152839
152842
  simulationType: "spice_transient_analysis";
152843
+ name?: string | undefined;
152840
152844
  duration?: number | undefined;
152841
152845
  startTime?: number | undefined;
152842
152846
  timePerStep?: number | undefined;
@@ -152848,6 +152852,7 @@ declare class AnalogSimulation extends PrimitiveComponent<typeof analogSimulatio
152848
152852
  vntol?: string | number | undefined;
152849
152853
  } | undefined;
152850
152854
  }, {
152855
+ name?: string | undefined;
152851
152856
  duration?: string | number | undefined;
152852
152857
  simulationType?: "spice_transient_analysis" | undefined;
152853
152858
  startTime?: string | number | undefined;
package/dist/index.js CHANGED
@@ -10632,6 +10632,7 @@ var createComponentsFromCircuitJson = ({
10632
10632
  pcbY: elm.center.y,
10633
10633
  width: elm.width,
10634
10634
  height: elm.height,
10635
+ pcbRotation: elm.ccw_rotation,
10635
10636
  layer: elm.layer
10636
10637
  })
10637
10638
  );
@@ -19795,6 +19796,111 @@ function computeJunctions(traces, opts = {}) {
19795
19796
  return result;
19796
19797
  }
19797
19798
 
19799
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/remove-overlapping-same-net-crossing-segments.ts
19800
+ var TOL3 = 1e-6;
19801
+ function isCollinear(a, b, tol = TOL3) {
19802
+ const adx = a.to.x - a.from.x;
19803
+ const ady = a.to.y - a.from.y;
19804
+ const bdx = b.to.x - b.from.x;
19805
+ const bdy = b.to.y - b.from.y;
19806
+ const aLen = Math.hypot(adx, ady);
19807
+ const bLen = Math.hypot(bdx, bdy);
19808
+ if (aLen <= tol || bLen <= tol) return false;
19809
+ const directionCross = adx * bdy - ady * bdx;
19810
+ if (Math.abs(directionCross) > tol * aLen * bLen) return false;
19811
+ const offsetCross = adx * (b.from.y - a.from.y) - ady * (b.from.x - a.from.x);
19812
+ return Math.abs(offsetCross) <= tol * aLen;
19813
+ }
19814
+ function splitEdgeAroundIntervals(edge, intervals) {
19815
+ const merged = mergeIntervals(intervals);
19816
+ if (merged.length === 0) return [edge];
19817
+ const edgeLength = length6(edge.from, edge.to);
19818
+ if (edgeLength <= TOL3) return [edge];
19819
+ const result = [];
19820
+ let cursor = 0;
19821
+ for (const interval of merged) {
19822
+ if (interval.start - cursor > TOL3) {
19823
+ result.push({
19824
+ from: pointAt(edge.from, edge.to, cursor / edgeLength),
19825
+ to: pointAt(edge.from, edge.to, interval.start / edgeLength)
19826
+ });
19827
+ }
19828
+ if (interval.end - interval.start > TOL3) {
19829
+ result.push({
19830
+ from: pointAt(edge.from, edge.to, interval.start / edgeLength),
19831
+ to: pointAt(edge.from, edge.to, interval.end / edgeLength),
19832
+ is_crossing: true
19833
+ });
19834
+ }
19835
+ cursor = Math.max(cursor, interval.end);
19836
+ }
19837
+ if (edgeLength - cursor > TOL3) {
19838
+ result.push({
19839
+ from: pointAt(edge.from, edge.to, cursor / edgeLength),
19840
+ to: edge.to
19841
+ });
19842
+ }
19843
+ return result;
19844
+ }
19845
+ function removeOverlappingSameNetCrossingSegments(traces) {
19846
+ const intervalsToRemove = /* @__PURE__ */ new Map();
19847
+ for (let crossingTraceIndex = 0; crossingTraceIndex < traces.length; crossingTraceIndex++) {
19848
+ const crossingTrace = traces[crossingTraceIndex];
19849
+ if (!crossingTrace.connectivity_key) continue;
19850
+ for (const crossingEdge of crossingTrace.edges) {
19851
+ if (!crossingEdge.is_crossing || length6(crossingEdge.from, crossingEdge.to) <= TOL3)
19852
+ continue;
19853
+ for (let traceIndex = 0; traceIndex < traces.length; traceIndex++) {
19854
+ const candidateTrace = traces[traceIndex];
19855
+ if (traceIndex === crossingTraceIndex || candidateTrace.connectivity_key !== crossingTrace.connectivity_key) {
19856
+ continue;
19857
+ }
19858
+ for (let edgeIndex = 0; edgeIndex < candidateTrace.edges.length; edgeIndex++) {
19859
+ const candidateEdge = candidateTrace.edges[edgeIndex];
19860
+ const candidateLength = length6(candidateEdge.from, candidateEdge.to);
19861
+ if (candidateEdge.is_crossing || candidateLength <= TOL3) continue;
19862
+ if (!isCollinear(candidateEdge, crossingEdge)) continue;
19863
+ const start = Math.max(
19864
+ 0,
19865
+ Math.min(
19866
+ paramAlong(
19867
+ candidateEdge.from,
19868
+ candidateEdge.to,
19869
+ crossingEdge.from
19870
+ ),
19871
+ paramAlong(candidateEdge.from, candidateEdge.to, crossingEdge.to)
19872
+ )
19873
+ );
19874
+ const end = Math.min(
19875
+ candidateLength,
19876
+ Math.max(
19877
+ paramAlong(
19878
+ candidateEdge.from,
19879
+ candidateEdge.to,
19880
+ crossingEdge.from
19881
+ ),
19882
+ paramAlong(candidateEdge.from, candidateEdge.to, crossingEdge.to)
19883
+ )
19884
+ );
19885
+ if (end - start <= TOL3) continue;
19886
+ const key = `${traceIndex}:${edgeIndex}`;
19887
+ const intervals = intervalsToRemove.get(key) ?? [];
19888
+ intervals.push({ start, end });
19889
+ intervalsToRemove.set(key, intervals);
19890
+ }
19891
+ }
19892
+ }
19893
+ }
19894
+ if (intervalsToRemove.size === 0) return traces;
19895
+ return traces.map((trace, traceIndex) => ({
19896
+ ...trace,
19897
+ edges: trace.edges.flatMap((edge, edgeIndex) => {
19898
+ const intervals = intervalsToRemove.get(`${traceIndex}:${edgeIndex}`);
19899
+ return intervals ? splitEdgeAroundIntervals(edge, intervals) : [edge];
19900
+ })
19901
+ }));
19902
+ }
19903
+
19798
19904
  // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts
19799
19905
  import Debug10 from "debug";
19800
19906
  var debug8 = Debug10("Group_doInitialSchematicTraceRender");
@@ -19949,19 +20055,37 @@ function applyTracesFromSolverOutput(args) {
19949
20055
  );
19950
20056
  const existingTracesForJunctions = [];
19951
20057
  for (const t of db.schematic_trace.list()) {
19952
- if (!t.source_trace_id || t.edges.length === 0) continue;
19953
- const sourceTrace = db.source_trace.get(t.source_trace_id);
20058
+ if (t.edges.length === 0) continue;
20059
+ const sourceTrace = t.source_trace_id ? db.source_trace.get(t.source_trace_id) : void 0;
19954
20060
  existingTracesForJunctions.push({
19955
- source_trace_id: t.source_trace_id,
20061
+ schematic_trace_id: t.schematic_trace_id,
20062
+ source_trace_id: t.source_trace_id ?? t.schematic_trace_id,
19956
20063
  edges: t.edges,
19957
20064
  connectivity_key: t.subcircuit_connectivity_map_key ?? sourceTrace?.subcircuit_connectivity_map_key
19958
20065
  });
19959
20066
  }
19960
- const junctionsById = computeJunctions([
20067
+ const tracesWithTrimmedCrossingOverlaps = removeOverlappingSameNetCrossingSegments([
19961
20068
  ...withCrossings,
19962
20069
  ...existingTracesForJunctions
19963
20070
  ]);
19964
- for (const t of withCrossings) {
20071
+ const visibleTraces = tracesWithTrimmedCrossingOverlaps.slice(
20072
+ 0,
20073
+ withCrossings.length
20074
+ );
20075
+ const visibleExistingTraces = tracesWithTrimmedCrossingOverlaps.slice(
20076
+ withCrossings.length
20077
+ );
20078
+ for (const trace of visibleExistingTraces) {
20079
+ if (!trace.schematic_trace_id) continue;
20080
+ db.schematic_trace.update(trace.schematic_trace_id, {
20081
+ edges: trace.edges
20082
+ });
20083
+ }
20084
+ const junctionsById = computeJunctions([
20085
+ ...visibleTraces,
20086
+ ...visibleExistingTraces
20087
+ ]);
20088
+ for (const t of visibleTraces) {
19965
20089
  db.schematic_trace.insert({
19966
20090
  source_trace_id: t.source_trace_id,
19967
20091
  edges: t.edges,
@@ -24064,7 +24188,7 @@ import { identity as identity5 } from "transformation-matrix";
24064
24188
  var package_default = {
24065
24189
  name: "@tscircuit/core",
24066
24190
  type: "module",
24067
- version: "0.0.1348",
24191
+ version: "0.0.1350",
24068
24192
  types: "dist/index.d.ts",
24069
24193
  main: "dist/index.js",
24070
24194
  module: "dist/index.js",
@@ -24112,7 +24236,7 @@ var package_default = {
24112
24236
  "@tscircuit/matchpack": "",
24113
24237
  "@tscircuit/math-utils": "^0.0.36",
24114
24238
  "@tscircuit/miniflex": "^0.0.4",
24115
- "@tscircuit/props": "^0.0.551",
24239
+ "@tscircuit/props": "^0.0.553",
24116
24240
  "@tscircuit/ngspice-spice-engine": "^0.0.18",
24117
24241
  "@tscircuit/schematic-match-adapt": "^0.0.18",
24118
24242
  "@tscircuit/solver-utils": "^0.0.16",
@@ -30329,7 +30453,7 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
30329
30453
  const PADDING = 0.5;
30330
30454
  const LABEL_PADDING = 0.2;
30331
30455
  const STROKE_WIDTH = 0.02;
30332
- const TOL3 = 1e-3;
30456
+ const TOL4 = 1e-3;
30333
30457
  const namedSectionsWithBounds = allSections.map((section) => {
30334
30458
  const bounds = section._computeSectionBounds(
30335
30459
  board,
@@ -30386,10 +30510,10 @@ var SchematicSection = class _SchematicSection extends PrimitiveComponent2 {
30386
30510
  });
30387
30511
  }
30388
30512
  const hDividers = dividers.filter(
30389
- (l) => Math.abs(l.start.y - l.end.y) < TOL3
30513
+ (l) => Math.abs(l.start.y - l.end.y) < TOL4
30390
30514
  );
30391
30515
  const vDividers = dividers.filter(
30392
- (l) => Math.abs(l.start.x - l.end.x) < TOL3
30516
+ (l) => Math.abs(l.start.x - l.end.x) < TOL4
30393
30517
  );
30394
30518
  for (const {
30395
30519
  displayName,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1349",
4
+ "version": "0.0.1351",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "@tscircuit/matchpack": "",
50
50
  "@tscircuit/math-utils": "^0.0.36",
51
51
  "@tscircuit/miniflex": "^0.0.4",
52
- "@tscircuit/props": "^0.0.551",
52
+ "@tscircuit/props": "^0.0.553",
53
53
  "@tscircuit/ngspice-spice-engine": "^0.0.18",
54
54
  "@tscircuit/schematic-match-adapt": "^0.0.18",
55
55
  "@tscircuit/solver-utils": "^0.0.16",