@tscircuit/core 0.0.1295 → 0.0.1296

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/index.js +84 -70
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6027,6 +6027,75 @@ var CourtyardRect = class extends PrimitiveComponent2 {
6027
6027
  }
6028
6028
  };
6029
6029
 
6030
+ // lib/utils/normalizeTextForCircuitJson.ts
6031
+ function normalizeTextForCircuitJson(text) {
6032
+ return text.replace(/\\n/g, "\n");
6033
+ }
6034
+
6035
+ // lib/components/primitive-components/CopperText.ts
6036
+ import { copperTextProps } from "@tscircuit/props";
6037
+ var CopperText = class extends PrimitiveComponent2 {
6038
+ isPcbPrimitive = true;
6039
+ pcb_copper_text_id = null;
6040
+ get config() {
6041
+ return {
6042
+ componentName: "CopperText",
6043
+ zodProps: copperTextProps
6044
+ };
6045
+ }
6046
+ doInitialPcbPrimitiveRender() {
6047
+ if (this.root?.pcbDisabled) return;
6048
+ const { db } = this.root;
6049
+ const { _parsedProps: props } = this;
6050
+ const container = this.getPrimitiveContainer();
6051
+ const position = this._getGlobalPcbPositionBeforeLayout();
6052
+ const subcircuit = this.getSubcircuit();
6053
+ const pcb_copper_text = db.pcb_copper_text.insert({
6054
+ anchor_alignment: props.anchorAlignment,
6055
+ anchor_position: {
6056
+ x: position.x,
6057
+ y: position.y
6058
+ },
6059
+ font: "tscircuit2024",
6060
+ font_size: props.fontSize,
6061
+ layer: props.layer ?? "top",
6062
+ text: normalizeTextForCircuitJson(props.text),
6063
+ ccw_rotation: props.pcbRotation,
6064
+ is_mirrored: props.mirrored,
6065
+ is_knockout: props.knockout,
6066
+ pcb_component_id: container.pcb_component_id,
6067
+ subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
6068
+ pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
6069
+ });
6070
+ this.pcb_copper_text_id = pcb_copper_text.pcb_copper_text_id;
6071
+ }
6072
+ getPcbSize() {
6073
+ const { _parsedProps: props } = this;
6074
+ const fontSize = props.fontSize ?? 1;
6075
+ const text = props.text ?? "";
6076
+ const textWidth = text.length * fontSize;
6077
+ const textHeight = fontSize;
6078
+ return { width: textWidth * fontSize, height: textHeight * fontSize };
6079
+ }
6080
+ _moveCircuitJsonElements({
6081
+ deltaX,
6082
+ deltaY
6083
+ }) {
6084
+ if (this.root?.pcbDisabled) return;
6085
+ const { db } = this.root;
6086
+ if (!this.pcb_copper_text_id) return;
6087
+ const text = db.pcb_copper_text.get(this.pcb_copper_text_id);
6088
+ if (text) {
6089
+ db.pcb_copper_text.update(this.pcb_copper_text_id, {
6090
+ anchor_position: {
6091
+ x: text.anchor_position.x + deltaX,
6092
+ y: text.anchor_position.y + deltaY
6093
+ }
6094
+ });
6095
+ }
6096
+ }
6097
+ };
6098
+
6030
6099
  // lib/components/primitive-components/Cutout.ts
6031
6100
  import { applyToPoint as applyToPoint4 } from "transformation-matrix";
6032
6101
  import { cutoutProps } from "@tscircuit/props";
@@ -6356,11 +6425,6 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
6356
6425
  // lib/components/primitive-components/FabricationNoteText.ts
6357
6426
  import { fabricationNoteTextProps } from "@tscircuit/props";
6358
6427
 
6359
- // lib/utils/normalizeTextForCircuitJson.ts
6360
- function normalizeTextForCircuitJson(text) {
6361
- return text.replace(/\\n/g, "\n");
6362
- }
6363
-
6364
6428
  // lib/utils/pcbSx/resolve-pcb-property.ts
6365
6429
  function parseSegment(seg) {
6366
6430
  const bracketIdx = seg.indexOf("[");
@@ -8665,6 +8729,20 @@ var createComponentsFromCircuitJson = ({
8665
8729
  strokeWidth: elm.stroke_width
8666
8730
  })
8667
8731
  );
8732
+ } else if (elm.type === "pcb_copper_text") {
8733
+ components.push(
8734
+ new CopperText({
8735
+ text: elm.text,
8736
+ pcbX: elm.anchor_position.x,
8737
+ pcbY: elm.anchor_position.y,
8738
+ pcbRotation: elm.ccw_rotation,
8739
+ anchorAlignment: elm.anchor_alignment,
8740
+ fontSize: elm.font_size,
8741
+ layer: elm.layer,
8742
+ mirrored: elm.is_mirrored,
8743
+ knockout: elm.is_knockout
8744
+ })
8745
+ );
8668
8746
  } else if (elm.type === "pcb_plated_hole") {
8669
8747
  if (elm.shape === "circle") {
8670
8748
  components.push(
@@ -22348,7 +22426,7 @@ import { identity as identity5 } from "transformation-matrix";
22348
22426
  var package_default = {
22349
22427
  name: "@tscircuit/core",
22350
22428
  type: "module",
22351
- version: "0.0.1294",
22429
+ version: "0.0.1295",
22352
22430
  types: "dist/index.d.ts",
22353
22431
  main: "dist/index.js",
22354
22432
  module: "dist/index.js",
@@ -27079,70 +27157,6 @@ var CopperPour = class extends PrimitiveComponent2 {
27079
27157
  }
27080
27158
  };
27081
27159
 
27082
- // lib/components/primitive-components/CopperText.ts
27083
- import { copperTextProps } from "@tscircuit/props";
27084
- var CopperText = class extends PrimitiveComponent2 {
27085
- isPcbPrimitive = true;
27086
- pcb_copper_text_id = null;
27087
- get config() {
27088
- return {
27089
- componentName: "CopperText",
27090
- zodProps: copperTextProps
27091
- };
27092
- }
27093
- doInitialPcbPrimitiveRender() {
27094
- if (this.root?.pcbDisabled) return;
27095
- const { db } = this.root;
27096
- const { _parsedProps: props } = this;
27097
- const container = this.getPrimitiveContainer();
27098
- const position = this._getGlobalPcbPositionBeforeLayout();
27099
- const subcircuit = this.getSubcircuit();
27100
- const pcb_copper_text = db.pcb_copper_text.insert({
27101
- anchor_alignment: props.anchorAlignment,
27102
- anchor_position: {
27103
- x: position.x,
27104
- y: position.y
27105
- },
27106
- font: "tscircuit2024",
27107
- font_size: props.fontSize,
27108
- layer: props.layer ?? "top",
27109
- text: normalizeTextForCircuitJson(props.text),
27110
- ccw_rotation: props.pcbRotation,
27111
- is_mirrored: props.mirrored,
27112
- is_knockout: props.knockout,
27113
- pcb_component_id: container.pcb_component_id,
27114
- subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
27115
- pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
27116
- });
27117
- this.pcb_copper_text_id = pcb_copper_text.pcb_copper_text_id;
27118
- }
27119
- getPcbSize() {
27120
- const { _parsedProps: props } = this;
27121
- const fontSize = props.fontSize ?? 1;
27122
- const text = props.text ?? "";
27123
- const textWidth = text.length * fontSize;
27124
- const textHeight = fontSize;
27125
- return { width: textWidth * fontSize, height: textHeight * fontSize };
27126
- }
27127
- _moveCircuitJsonElements({
27128
- deltaX,
27129
- deltaY
27130
- }) {
27131
- if (this.root?.pcbDisabled) return;
27132
- const { db } = this.root;
27133
- if (!this.pcb_copper_text_id) return;
27134
- const text = db.pcb_copper_text.get(this.pcb_copper_text_id);
27135
- if (text) {
27136
- db.pcb_copper_text.update(this.pcb_copper_text_id, {
27137
- anchor_position: {
27138
- x: text.anchor_position.x + deltaX,
27139
- y: text.anchor_position.y + deltaY
27140
- }
27141
- });
27142
- }
27143
- }
27144
- };
27145
-
27146
27160
  // lib/components/normal-components/Battery.ts
27147
27161
  import { batteryProps } from "@tscircuit/props";
27148
27162
  var Battery = class extends NormalComponent3 {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1295",
4
+ "version": "0.0.1296",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",