@tscircuit/core 0.0.784 → 0.0.786

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 (3) hide show
  1. package/dist/index.d.ts +1111 -2
  2. package/dist/index.js +147 -17
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ __export(components_exports, {
21
21
  Crystal: () => Crystal,
22
22
  Cutout: () => Cutout,
23
23
  Diode: () => Diode,
24
+ FabricationNoteDimension: () => FabricationNoteDimension,
24
25
  FabricationNotePath: () => FabricationNotePath,
25
26
  FabricationNoteRect: () => FabricationNoteRect,
26
27
  FabricationNoteText: () => FabricationNoteText,
@@ -76,6 +77,7 @@ __export(components_exports, {
76
77
  TraceHint: () => TraceHint,
77
78
  Transistor: () => Transistor,
78
79
  Via: () => Via,
80
+ VoltageProbe: () => VoltageProbe,
79
81
  VoltageSource: () => VoltageSource
80
82
  });
81
83
 
@@ -14371,9 +14373,84 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
14371
14373
  }
14372
14374
  };
14373
14375
 
14376
+ // lib/components/primitive-components/FabricationNoteDimension.ts
14377
+ import { fabricationNoteDimensionProps } from "@tscircuit/props";
14378
+ import { applyToPoint as applyToPoint10 } from "transformation-matrix";
14379
+ var FabricationNoteDimension = class extends PrimitiveComponent2 {
14380
+ fabrication_note_dimension_id = null;
14381
+ isPcbPrimitive = true;
14382
+ get config() {
14383
+ return {
14384
+ componentName: "FabricationNoteDimension",
14385
+ zodProps: fabricationNoteDimensionProps
14386
+ };
14387
+ }
14388
+ _resolvePoint(input, transform) {
14389
+ if (typeof input === "string") {
14390
+ const target = this.getSubcircuit().selectOne(
14391
+ input
14392
+ );
14393
+ if (!target) {
14394
+ this.renderError(
14395
+ `FabricationNoteDimension could not find selector "${input}"`
14396
+ );
14397
+ return applyToPoint10(transform, { x: 0, y: 0 });
14398
+ }
14399
+ return target._getGlobalPcbPositionBeforeLayout();
14400
+ }
14401
+ const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
14402
+ const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
14403
+ return applyToPoint10(transform, { x: numericX, y: numericY });
14404
+ }
14405
+ doInitialPcbPrimitiveRender() {
14406
+ if (this.root?.pcbDisabled) return;
14407
+ const { db } = this.root;
14408
+ const { _parsedProps: props } = this;
14409
+ const transform = this._computePcbGlobalTransformBeforeLayout();
14410
+ const from = this._resolvePoint(props.from, transform);
14411
+ const to = this._resolvePoint(props.to, transform);
14412
+ const subcircuit = this.getSubcircuit();
14413
+ const group = this.getGroup();
14414
+ const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
14415
+ const layer = maybeFlipLayer(props.layer ?? "top");
14416
+ if (layer !== "top" && layer !== "bottom") {
14417
+ throw new Error(
14418
+ `Invalid layer "${layer}" for FabricationNoteDimension. Must be "top" or "bottom".`
14419
+ );
14420
+ }
14421
+ const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
14422
+ const fabrication_note_dimension = db.pcb_fabrication_note_dimension.insert(
14423
+ {
14424
+ pcb_component_id,
14425
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
14426
+ pcb_group_id: group?.pcb_group_id ?? void 0,
14427
+ layer,
14428
+ from,
14429
+ to,
14430
+ text: props.text,
14431
+ offset: props.offset,
14432
+ font: props.font ?? "tscircuit2024",
14433
+ font_size: props.fontSize ?? 1,
14434
+ color: props.color,
14435
+ arrow_size: props.arrowSize ?? 1
14436
+ }
14437
+ );
14438
+ this.fabrication_note_dimension_id = fabrication_note_dimension.pcb_fabrication_note_dimension_id;
14439
+ }
14440
+ getPcbSize() {
14441
+ const transform = this._computePcbGlobalTransformBeforeLayout();
14442
+ const from = this._resolvePoint(this._parsedProps.from, transform);
14443
+ const to = this._resolvePoint(this._parsedProps.to, transform);
14444
+ return {
14445
+ width: Math.abs(to.x - from.x),
14446
+ height: Math.abs(to.y - from.y)
14447
+ };
14448
+ }
14449
+ };
14450
+
14374
14451
  // lib/components/primitive-components/PcbNoteLine.ts
14375
14452
  import { pcbNoteLineProps } from "@tscircuit/props";
14376
- import { applyToPoint as applyToPoint10 } from "transformation-matrix";
14453
+ import { applyToPoint as applyToPoint11 } from "transformation-matrix";
14377
14454
  var PcbNoteLine = class extends PrimitiveComponent2 {
14378
14455
  pcb_note_line_id = null;
14379
14456
  isPcbPrimitive = true;
@@ -14390,8 +14467,8 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
14390
14467
  const subcircuit = this.getSubcircuit();
14391
14468
  const group = this.getGroup();
14392
14469
  const transform = this._computePcbGlobalTransformBeforeLayout();
14393
- const start = applyToPoint10(transform, { x: props.x1, y: props.y1 });
14394
- const end = applyToPoint10(transform, { x: props.x2, y: props.y2 });
14470
+ const start = applyToPoint11(transform, { x: props.x1, y: props.y1 });
14471
+ const end = applyToPoint11(transform, { x: props.x2, y: props.y2 });
14395
14472
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
14396
14473
  const pcb_note_line = db.pcb_note_line.insert({
14397
14474
  pcb_component_id,
@@ -14418,7 +14495,7 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
14418
14495
 
14419
14496
  // lib/components/primitive-components/PcbNoteRect.ts
14420
14497
  import { pcbNoteRectProps } from "@tscircuit/props";
14421
- import { applyToPoint as applyToPoint11 } from "transformation-matrix";
14498
+ import { applyToPoint as applyToPoint12 } from "transformation-matrix";
14422
14499
  var PcbNoteRect = class extends PrimitiveComponent2 {
14423
14500
  pcb_note_rect_id = null;
14424
14501
  isPcbPrimitive = true;
@@ -14433,7 +14510,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
14433
14510
  const { db } = this.root;
14434
14511
  const { _parsedProps: props } = this;
14435
14512
  const transform = this._computePcbGlobalTransformBeforeLayout();
14436
- const center = applyToPoint11(transform, { x: 0, y: 0 });
14513
+ const center = applyToPoint12(transform, { x: 0, y: 0 });
14437
14514
  const subcircuit = this.getSubcircuit();
14438
14515
  const group = this.getGroup();
14439
14516
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
@@ -14462,7 +14539,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
14462
14539
 
14463
14540
  // lib/components/primitive-components/PcbNotePath.ts
14464
14541
  import { pcbNotePathProps } from "@tscircuit/props";
14465
- import { applyToPoint as applyToPoint12 } from "transformation-matrix";
14542
+ import { applyToPoint as applyToPoint13 } from "transformation-matrix";
14466
14543
  var PcbNotePath = class extends PrimitiveComponent2 {
14467
14544
  pcb_note_path_id = null;
14468
14545
  isPcbPrimitive = true;
@@ -14484,7 +14561,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
14484
14561
  const { x, y, ...rest } = point;
14485
14562
  const numericX = typeof x === "string" ? parseFloat(x) : x;
14486
14563
  const numericY = typeof y === "string" ? parseFloat(y) : y;
14487
- const transformed = applyToPoint12(transform, { x: numericX, y: numericY });
14564
+ const transformed = applyToPoint13(transform, { x: numericX, y: numericY });
14488
14565
  return { ...rest, x: transformed.x, y: transformed.y };
14489
14566
  });
14490
14567
  const pcb_note_path = db.pcb_note_path.insert({
@@ -14516,7 +14593,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
14516
14593
 
14517
14594
  // lib/components/primitive-components/PcbNoteDimension.ts
14518
14595
  import { pcbNoteDimensionProps } from "@tscircuit/props";
14519
- import { applyToPoint as applyToPoint13 } from "transformation-matrix";
14596
+ import { applyToPoint as applyToPoint14 } from "transformation-matrix";
14520
14597
  var PcbNoteDimension = class extends PrimitiveComponent2 {
14521
14598
  pcb_note_dimension_id = null;
14522
14599
  isPcbPrimitive = true;
@@ -14533,13 +14610,13 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
14533
14610
  );
14534
14611
  if (!target) {
14535
14612
  this.renderError(`PcbNoteDimension could not find selector "${input}"`);
14536
- return applyToPoint13(transform, { x: 0, y: 0 });
14613
+ return applyToPoint14(transform, { x: 0, y: 0 });
14537
14614
  }
14538
14615
  return target._getGlobalPcbPositionBeforeLayout();
14539
14616
  }
14540
14617
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
14541
14618
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
14542
- return applyToPoint13(transform, { x: numericX, y: numericY });
14619
+ return applyToPoint14(transform, { x: numericX, y: numericY });
14543
14620
  }
14544
14621
  doInitialPcbPrimitiveRender() {
14545
14622
  if (this.root?.pcbDisabled) return;
@@ -14700,7 +14777,7 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
14700
14777
  // lib/components/primitive-components/NetLabel.ts
14701
14778
  import { netLabelProps } from "@tscircuit/props";
14702
14779
  import {
14703
- applyToPoint as applyToPoint14,
14780
+ applyToPoint as applyToPoint15,
14704
14781
  identity as identity5,
14705
14782
  translate as translate6
14706
14783
  } from "transformation-matrix";
@@ -14751,7 +14828,7 @@ var NetLabel = class extends PrimitiveComponent2 {
14751
14828
  const connectedPorts = this._getConnectedPorts();
14752
14829
  if (connectedPorts.length > 0) {
14753
14830
  const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
14754
- const parentCenter = applyToPoint14(
14831
+ const parentCenter = applyToPoint15(
14755
14832
  this.parent?.computeSchematicGlobalTransform?.() ?? identity5(),
14756
14833
  { x: 0, y: 0 }
14757
14834
  );
@@ -16549,6 +16626,57 @@ var AnalogSimulation = class extends PrimitiveComponent2 {
16549
16626
  }
16550
16627
  };
16551
16628
 
16629
+ // lib/components/primitive-components/VoltageProbe.ts
16630
+ import { voltageProbeProps } from "@tscircuit/props";
16631
+ import "zod";
16632
+ var VoltageProbe = class extends PrimitiveComponent2 {
16633
+ simulation_voltage_probe_id = null;
16634
+ get config() {
16635
+ return {
16636
+ componentName: "VoltageProbe",
16637
+ zodProps: voltageProbeProps
16638
+ };
16639
+ }
16640
+ doInitialSimulationRender() {
16641
+ const { db } = this.root;
16642
+ const { connectsTo, name } = this._parsedProps;
16643
+ const subcircuit = this.getSubcircuit();
16644
+ if (!subcircuit) {
16645
+ this.renderError("VoltageProbe must be inside a subcircuit");
16646
+ return;
16647
+ }
16648
+ const targets = Array.isArray(connectsTo) ? connectsTo : [connectsTo];
16649
+ if (targets.length !== 1) {
16650
+ this.renderError("VoltageProbe must connect to exactly one port or net");
16651
+ return;
16652
+ }
16653
+ const targetSelector = targets[0];
16654
+ const port = subcircuit.selectOne(targetSelector, {
16655
+ type: "port"
16656
+ });
16657
+ const net = !port ? subcircuit.selectOne(targetSelector, { type: "net" }) : null;
16658
+ if (net && net.componentName !== "Net") {
16659
+ this.renderError(
16660
+ `VoltageProbe connection target "${targetSelector}" resolved to a non-net component "${net.componentName}".`
16661
+ );
16662
+ return;
16663
+ }
16664
+ if (!port && !net) {
16665
+ this.renderError(
16666
+ `VoltageProbe could not find connection target "${targetSelector}"`
16667
+ );
16668
+ return;
16669
+ }
16670
+ const { simulation_voltage_probe_id } = db.simulation_voltage_probe.insert({
16671
+ name: name ?? this.name,
16672
+ source_port_id: port?.source_port_id ?? void 0,
16673
+ source_net_id: net?.source_net_id ?? void 0,
16674
+ subcircuit_id: subcircuit.subcircuit_id || void 0
16675
+ });
16676
+ this.simulation_voltage_probe_id = simulation_voltage_probe_id;
16677
+ }
16678
+ };
16679
+
16552
16680
  // lib/RootCircuit.ts
16553
16681
  import { su as su5 } from "@tscircuit/circuit-json-util";
16554
16682
  import { isValidElement as isValidElement2 } from "react";
@@ -16558,7 +16686,7 @@ import { identity as identity6 } from "transformation-matrix";
16558
16686
  var package_default = {
16559
16687
  name: "@tscircuit/core",
16560
16688
  type: "module",
16561
- version: "0.0.783",
16689
+ version: "0.0.785",
16562
16690
  types: "dist/index.d.ts",
16563
16691
  main: "dist/index.js",
16564
16692
  module: "dist/index.js",
@@ -16611,13 +16739,13 @@ var package_default = {
16611
16739
  "bun-match-svg": "0.0.12",
16612
16740
  "calculate-elbow": "^0.0.12",
16613
16741
  "chokidar-cli": "^3.0.0",
16614
- "circuit-json": "^0.0.277",
16742
+ "circuit-json": "^0.0.278",
16615
16743
  "circuit-json-to-bpc": "^0.0.13",
16616
16744
  "circuit-json-to-connectivity-map": "^0.0.22",
16617
16745
  "circuit-json-to-gltf": "^0.0.7",
16618
16746
  "circuit-json-to-simple-3d": "^0.0.9",
16619
- "circuit-json-to-spice": "^0.0.13",
16620
- "circuit-to-svg": "^0.0.235",
16747
+ "circuit-to-svg": "^0.0.238",
16748
+ "circuit-json-to-spice": "^0.0.14",
16621
16749
  concurrently: "^9.1.2",
16622
16750
  "connectivity-map": "^1.0.0",
16623
16751
  debug: "^4.3.6",
@@ -16632,7 +16760,7 @@ var package_default = {
16632
16760
  react: "^19.1.0",
16633
16761
  "react-dom": "^19.1.0",
16634
16762
  "schematic-symbols": "^0.0.202",
16635
- spicey: "^0.0.4",
16763
+ spicey: "^0.0.8",
16636
16764
  "ts-expect": "^1.3.0",
16637
16765
  tsup: "^8.2.4"
16638
16766
  },
@@ -17080,6 +17208,7 @@ export {
17080
17208
  Crystal,
17081
17209
  Cutout,
17082
17210
  Diode,
17211
+ FabricationNoteDimension,
17083
17212
  FabricationNotePath,
17084
17213
  FabricationNoteRect,
17085
17214
  FabricationNoteText,
@@ -17137,6 +17266,7 @@ export {
17137
17266
  TraceHint,
17138
17267
  Transistor,
17139
17268
  Via,
17269
+ VoltageProbe,
17140
17270
  VoltageSource,
17141
17271
  applyEditEvents,
17142
17272
  applyEditEventsToManualEditsFile,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.784",
4
+ "version": "0.0.786",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -54,13 +54,13 @@
54
54
  "bun-match-svg": "0.0.12",
55
55
  "calculate-elbow": "^0.0.12",
56
56
  "chokidar-cli": "^3.0.0",
57
- "circuit-json": "^0.0.277",
57
+ "circuit-json": "^0.0.278",
58
58
  "circuit-json-to-bpc": "^0.0.13",
59
59
  "circuit-json-to-connectivity-map": "^0.0.22",
60
60
  "circuit-json-to-gltf": "^0.0.7",
61
61
  "circuit-json-to-simple-3d": "^0.0.9",
62
- "circuit-json-to-spice": "^0.0.13",
63
- "circuit-to-svg": "^0.0.235",
62
+ "circuit-to-svg": "^0.0.238",
63
+ "circuit-json-to-spice": "^0.0.14",
64
64
  "concurrently": "^9.1.2",
65
65
  "connectivity-map": "^1.0.0",
66
66
  "debug": "^4.3.6",
@@ -75,7 +75,7 @@
75
75
  "react": "^19.1.0",
76
76
  "react-dom": "^19.1.0",
77
77
  "schematic-symbols": "^0.0.202",
78
- "spicey": "^0.0.4",
78
+ "spicey": "^0.0.8",
79
79
  "ts-expect": "^1.3.0",
80
80
  "tsup": "^8.2.4"
81
81
  },