@tscircuit/core 0.0.1295 → 0.0.1297
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 +92 -74
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2234,6 +2234,10 @@ function pairs(arr) {
|
|
|
2234
2234
|
return result;
|
|
2235
2235
|
}
|
|
2236
2236
|
|
|
2237
|
+
// lib/utils/gnd-power-net-regex.ts
|
|
2238
|
+
var GROUND_NET_REGEX = /^(GND|AGND|DGND|PGND|VSS)/i;
|
|
2239
|
+
var POWER_NET_REGEX = /^V(?!SS)|^\d+(?:[_.]\d+)?[Vv]/i;
|
|
2240
|
+
|
|
2237
2241
|
// lib/components/primitive-components/Net.ts
|
|
2238
2242
|
import { autoroute } from "@tscircuit/infgrid-ijump-astar";
|
|
2239
2243
|
var Net = class extends PrimitiveComponent2 {
|
|
@@ -2251,8 +2255,8 @@ var Net = class extends PrimitiveComponent2 {
|
|
|
2251
2255
|
doInitialSourceRender() {
|
|
2252
2256
|
const { db } = this.root;
|
|
2253
2257
|
const { _parsedProps: props } = this;
|
|
2254
|
-
const isGround = props.isGroundNet ?? props.name
|
|
2255
|
-
const isPositiveVoltageSource = props.isPowerNet ?? props.name
|
|
2258
|
+
const isGround = props.isGroundNet ?? GROUND_NET_REGEX.test(props.name);
|
|
2259
|
+
const isPositiveVoltageSource = props.isPowerNet ?? POWER_NET_REGEX.test(props.name);
|
|
2256
2260
|
const net = db.source_net.insert({
|
|
2257
2261
|
name: props.name,
|
|
2258
2262
|
member_source_group_ids: [],
|
|
@@ -6027,6 +6031,75 @@ var CourtyardRect = class extends PrimitiveComponent2 {
|
|
|
6027
6031
|
}
|
|
6028
6032
|
};
|
|
6029
6033
|
|
|
6034
|
+
// lib/utils/normalizeTextForCircuitJson.ts
|
|
6035
|
+
function normalizeTextForCircuitJson(text) {
|
|
6036
|
+
return text.replace(/\\n/g, "\n");
|
|
6037
|
+
}
|
|
6038
|
+
|
|
6039
|
+
// lib/components/primitive-components/CopperText.ts
|
|
6040
|
+
import { copperTextProps } from "@tscircuit/props";
|
|
6041
|
+
var CopperText = class extends PrimitiveComponent2 {
|
|
6042
|
+
isPcbPrimitive = true;
|
|
6043
|
+
pcb_copper_text_id = null;
|
|
6044
|
+
get config() {
|
|
6045
|
+
return {
|
|
6046
|
+
componentName: "CopperText",
|
|
6047
|
+
zodProps: copperTextProps
|
|
6048
|
+
};
|
|
6049
|
+
}
|
|
6050
|
+
doInitialPcbPrimitiveRender() {
|
|
6051
|
+
if (this.root?.pcbDisabled) return;
|
|
6052
|
+
const { db } = this.root;
|
|
6053
|
+
const { _parsedProps: props } = this;
|
|
6054
|
+
const container = this.getPrimitiveContainer();
|
|
6055
|
+
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
6056
|
+
const subcircuit = this.getSubcircuit();
|
|
6057
|
+
const pcb_copper_text = db.pcb_copper_text.insert({
|
|
6058
|
+
anchor_alignment: props.anchorAlignment,
|
|
6059
|
+
anchor_position: {
|
|
6060
|
+
x: position.x,
|
|
6061
|
+
y: position.y
|
|
6062
|
+
},
|
|
6063
|
+
font: "tscircuit2024",
|
|
6064
|
+
font_size: props.fontSize,
|
|
6065
|
+
layer: props.layer ?? "top",
|
|
6066
|
+
text: normalizeTextForCircuitJson(props.text),
|
|
6067
|
+
ccw_rotation: props.pcbRotation,
|
|
6068
|
+
is_mirrored: props.mirrored,
|
|
6069
|
+
is_knockout: props.knockout,
|
|
6070
|
+
pcb_component_id: container.pcb_component_id,
|
|
6071
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
6072
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
6073
|
+
});
|
|
6074
|
+
this.pcb_copper_text_id = pcb_copper_text.pcb_copper_text_id;
|
|
6075
|
+
}
|
|
6076
|
+
getPcbSize() {
|
|
6077
|
+
const { _parsedProps: props } = this;
|
|
6078
|
+
const fontSize = props.fontSize ?? 1;
|
|
6079
|
+
const text = props.text ?? "";
|
|
6080
|
+
const textWidth = text.length * fontSize;
|
|
6081
|
+
const textHeight = fontSize;
|
|
6082
|
+
return { width: textWidth * fontSize, height: textHeight * fontSize };
|
|
6083
|
+
}
|
|
6084
|
+
_moveCircuitJsonElements({
|
|
6085
|
+
deltaX,
|
|
6086
|
+
deltaY
|
|
6087
|
+
}) {
|
|
6088
|
+
if (this.root?.pcbDisabled) return;
|
|
6089
|
+
const { db } = this.root;
|
|
6090
|
+
if (!this.pcb_copper_text_id) return;
|
|
6091
|
+
const text = db.pcb_copper_text.get(this.pcb_copper_text_id);
|
|
6092
|
+
if (text) {
|
|
6093
|
+
db.pcb_copper_text.update(this.pcb_copper_text_id, {
|
|
6094
|
+
anchor_position: {
|
|
6095
|
+
x: text.anchor_position.x + deltaX,
|
|
6096
|
+
y: text.anchor_position.y + deltaY
|
|
6097
|
+
}
|
|
6098
|
+
});
|
|
6099
|
+
}
|
|
6100
|
+
}
|
|
6101
|
+
};
|
|
6102
|
+
|
|
6030
6103
|
// lib/components/primitive-components/Cutout.ts
|
|
6031
6104
|
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
6032
6105
|
import { cutoutProps } from "@tscircuit/props";
|
|
@@ -6356,11 +6429,6 @@ var FabricationNoteRect = class extends PrimitiveComponent2 {
|
|
|
6356
6429
|
// lib/components/primitive-components/FabricationNoteText.ts
|
|
6357
6430
|
import { fabricationNoteTextProps } from "@tscircuit/props";
|
|
6358
6431
|
|
|
6359
|
-
// lib/utils/normalizeTextForCircuitJson.ts
|
|
6360
|
-
function normalizeTextForCircuitJson(text) {
|
|
6361
|
-
return text.replace(/\\n/g, "\n");
|
|
6362
|
-
}
|
|
6363
|
-
|
|
6364
6432
|
// lib/utils/pcbSx/resolve-pcb-property.ts
|
|
6365
6433
|
function parseSegment(seg) {
|
|
6366
6434
|
const bracketIdx = seg.indexOf("[");
|
|
@@ -8665,6 +8733,20 @@ var createComponentsFromCircuitJson = ({
|
|
|
8665
8733
|
strokeWidth: elm.stroke_width
|
|
8666
8734
|
})
|
|
8667
8735
|
);
|
|
8736
|
+
} else if (elm.type === "pcb_copper_text") {
|
|
8737
|
+
components.push(
|
|
8738
|
+
new CopperText({
|
|
8739
|
+
text: elm.text,
|
|
8740
|
+
pcbX: elm.anchor_position.x,
|
|
8741
|
+
pcbY: elm.anchor_position.y,
|
|
8742
|
+
pcbRotation: elm.ccw_rotation,
|
|
8743
|
+
anchorAlignment: elm.anchor_alignment,
|
|
8744
|
+
fontSize: elm.font_size,
|
|
8745
|
+
layer: elm.layer,
|
|
8746
|
+
mirrored: elm.is_mirrored,
|
|
8747
|
+
knockout: elm.is_knockout
|
|
8748
|
+
})
|
|
8749
|
+
);
|
|
8668
8750
|
} else if (elm.type === "pcb_plated_hole") {
|
|
8669
8751
|
if (elm.shape === "circle") {
|
|
8670
8752
|
components.push(
|
|
@@ -21348,13 +21430,13 @@ var Group5 = class extends NormalComponent3 {
|
|
|
21348
21430
|
for (const nl of subtree.schematic_net_label.list()) {
|
|
21349
21431
|
const net = subtree.source_net.get(nl.source_net_id);
|
|
21350
21432
|
const text = nl.text || net?.name || "";
|
|
21351
|
-
if (nl.anchor_side === "top" &&
|
|
21433
|
+
if (nl.anchor_side === "top" && GROUND_NET_REGEX.test(text)) {
|
|
21352
21434
|
subtree.schematic_net_label.update(nl.schematic_net_label_id, {
|
|
21353
21435
|
symbol_name: "rail_down"
|
|
21354
21436
|
});
|
|
21355
21437
|
continue;
|
|
21356
21438
|
}
|
|
21357
|
-
if (nl.anchor_side === "bottom" &&
|
|
21439
|
+
if (nl.anchor_side === "bottom" && POWER_NET_REGEX.test(text)) {
|
|
21358
21440
|
subtree.schematic_net_label.update(nl.schematic_net_label_id, {
|
|
21359
21441
|
symbol_name: "rail_up"
|
|
21360
21442
|
});
|
|
@@ -22348,7 +22430,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
22348
22430
|
var package_default = {
|
|
22349
22431
|
name: "@tscircuit/core",
|
|
22350
22432
|
type: "module",
|
|
22351
|
-
version: "0.0.
|
|
22433
|
+
version: "0.0.1296",
|
|
22352
22434
|
types: "dist/index.d.ts",
|
|
22353
22435
|
main: "dist/index.js",
|
|
22354
22436
|
module: "dist/index.js",
|
|
@@ -27079,70 +27161,6 @@ var CopperPour = class extends PrimitiveComponent2 {
|
|
|
27079
27161
|
}
|
|
27080
27162
|
};
|
|
27081
27163
|
|
|
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
27164
|
// lib/components/normal-components/Battery.ts
|
|
27147
27165
|
import { batteryProps } from "@tscircuit/props";
|
|
27148
27166
|
var Battery = class extends NormalComponent3 {
|