@tscircuit/core 0.0.894 → 0.0.896

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 +27 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3133,6 +3133,13 @@ var Hole = class extends PrimitiveComponent2 {
3133
3133
  // lib/components/primitive-components/SilkscreenText.ts
3134
3134
  import { silkscreenTextProps } from "@tscircuit/props";
3135
3135
  import { decomposeTSR as decomposeTSR3 } from "transformation-matrix";
3136
+
3137
+ // lib/utils/normalizeTextForCircuitJson.ts
3138
+ function normalizeTextForCircuitJson(text) {
3139
+ return text.replace(/\\n/g, "\n");
3140
+ }
3141
+
3142
+ // lib/components/primitive-components/SilkscreenText.ts
3136
3143
  var SilkscreenText = class extends PrimitiveComponent2 {
3137
3144
  isPcbPrimitive = true;
3138
3145
  get config() {
@@ -3174,7 +3181,7 @@ var SilkscreenText = class extends PrimitiveComponent2 {
3174
3181
  font: props.font ?? "tscircuit2024",
3175
3182
  font_size: fontSize,
3176
3183
  layer: maybeFlipLayer(layer),
3177
- text: props.text ?? "",
3184
+ text: normalizeTextForCircuitJson(props.text ?? ""),
3178
3185
  ccw_rotation: rotation4,
3179
3186
  pcb_component_id: container.pcb_component_id,
3180
3187
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
@@ -14598,13 +14605,17 @@ var inflatePcbComponent = (pcbElm, inflatorContext) => {
14598
14605
  const relativeElements = injectionDb.toArray().filter(
14599
14606
  (elm) => "pcb_component_id" in elm && elm.pcb_component_id === pcbElm.pcb_component_id
14600
14607
  );
14601
- transformPCBElements2(relativeElements, absoluteToComponentRelativeTransform);
14608
+ const clonedRelativeElements = structuredClone(relativeElements);
14609
+ transformPCBElements2(
14610
+ clonedRelativeElements,
14611
+ absoluteToComponentRelativeTransform
14612
+ );
14602
14613
  const components = createComponentsFromCircuitJson(
14603
14614
  {
14604
14615
  componentName: normalComponent.name,
14605
14616
  componentRotation: "0deg"
14606
14617
  },
14607
- relativeElements
14618
+ clonedRelativeElements
14608
14619
  );
14609
14620
  normalComponent.addAll(components);
14610
14621
  };
@@ -15534,7 +15545,9 @@ var Board = class extends Group6 {
15534
15545
  const pcbY = this._resolvePcbCoordinate(props.pcbY, "pcbY", {
15535
15546
  allowBoardVariables: false
15536
15547
  });
15537
- if (props.width && props.height || props.outline) return;
15548
+ const pcbBoard = db.pcb_board.get(this.pcb_board_id);
15549
+ if (pcbBoard?.width && pcbBoard?.height || pcbBoard?.outline && pcbBoard.outline.length > 0)
15550
+ return;
15538
15551
  let minX = Infinity;
15539
15552
  let minY = Infinity;
15540
15553
  let maxX = -Infinity;
@@ -15661,8 +15674,12 @@ var Board = class extends Group6 {
15661
15674
  if (this.root?.pcbDisabled) return;
15662
15675
  const { db } = this.root;
15663
15676
  const { _parsedProps: props } = this;
15664
- let computedWidth = props.width ?? 0;
15665
- let computedHeight = props.height ?? 0;
15677
+ const circuitJsonElements = props.circuitJson;
15678
+ const pcbBoardFromCircuitJson = circuitJsonElements?.find(
15679
+ (elm) => elm.type === "pcb_board"
15680
+ );
15681
+ let computedWidth = props.width ?? pcbBoardFromCircuitJson?.width ?? 0;
15682
+ let computedHeight = props.height ?? pcbBoardFromCircuitJson?.height ?? 0;
15666
15683
  const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
15667
15684
  let center = {
15668
15685
  x: pcbX + (props.outlineOffsetX ?? 0),
@@ -16908,7 +16925,7 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
16908
16925
  font_size: props.fontSize ?? 1,
16909
16926
  layer: "top",
16910
16927
  color: props.color,
16911
- text: props.text ?? "",
16928
+ text: normalizeTextForCircuitJson(props.text ?? ""),
16912
16929
  pcb_component_id: container.pcb_component_id,
16913
16930
  subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
16914
16931
  pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
@@ -17127,7 +17144,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
17127
17144
  pcb_group_id: group?.pcb_group_id ?? void 0,
17128
17145
  font: props.font ?? "tscircuit2024",
17129
17146
  font_size: props.fontSize ?? 1,
17130
- text: props.text,
17147
+ text: normalizeTextForCircuitJson(props.text),
17131
17148
  anchor_position: anchorPosition,
17132
17149
  anchor_alignment: props.anchorAlignment ?? "center",
17133
17150
  color: props.color
@@ -18528,7 +18545,7 @@ var SchematicText = class extends PrimitiveComponent2 {
18528
18545
  const globalPos = this._getGlobalSchematicPositionBeforeLayout();
18529
18546
  db.schematic_text.insert({
18530
18547
  anchor: props.anchor ?? "center",
18531
- text: props.text,
18548
+ text: normalizeTextForCircuitJson(props.text),
18532
18549
  font_size: props.fontSize,
18533
18550
  color: props.color || "#000000",
18534
18551
  position: {
@@ -19214,7 +19231,7 @@ import { identity as identity6 } from "transformation-matrix";
19214
19231
  var package_default = {
19215
19232
  name: "@tscircuit/core",
19216
19233
  type: "module",
19217
- version: "0.0.893",
19234
+ version: "0.0.895",
19218
19235
  types: "dist/index.d.ts",
19219
19236
  main: "dist/index.js",
19220
19237
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.894",
4
+ "version": "0.0.896",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",