@tscircuit/core 0.0.390 → 0.0.391
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 +54 -18
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2139,10 +2139,36 @@ var SilkscreenText = class extends PrimitiveComponent2 {
|
|
|
2139
2139
|
}
|
|
2140
2140
|
};
|
|
2141
2141
|
|
|
2142
|
-
// lib/utils/
|
|
2143
|
-
var
|
|
2142
|
+
// lib/utils/createPinrowSilkscreenText.ts
|
|
2143
|
+
var createPinrowSilkscreenText = ({
|
|
2144
|
+
elm,
|
|
2145
|
+
pinLabels,
|
|
2146
|
+
readableRotation
|
|
2147
|
+
}) => {
|
|
2148
|
+
const pinNum = elm.text.replace(/[{}]/g, "").toLowerCase();
|
|
2149
|
+
let label = pinNum;
|
|
2150
|
+
if (Array.isArray(pinLabels)) {
|
|
2151
|
+
const index = parseInt(pinNum.replace(/[^\d]/g, ""), 10) - 1;
|
|
2152
|
+
label = pinLabels[index] ?? pinNum;
|
|
2153
|
+
} else if (typeof pinLabels === "object") {
|
|
2154
|
+
label = pinLabels[pinNum]?.[0] ?? pinNum;
|
|
2155
|
+
}
|
|
2156
|
+
return new SilkscreenText({
|
|
2157
|
+
anchorAlignment: "center",
|
|
2158
|
+
text: label ?? pinNum,
|
|
2159
|
+
fontSize: elm.font_size + 0.2,
|
|
2160
|
+
pcbX: isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
|
|
2161
|
+
pcbY: elm.anchor_position.y,
|
|
2162
|
+
pcbRotation: readableRotation ?? 0
|
|
2163
|
+
});
|
|
2164
|
+
};
|
|
2165
|
+
|
|
2166
|
+
// lib/utils/createComponentsFromCircuitJson.ts
|
|
2167
|
+
var createComponentsFromCircuitJson = ({
|
|
2144
2168
|
componentName,
|
|
2145
|
-
componentRotation
|
|
2169
|
+
componentRotation,
|
|
2170
|
+
footprint,
|
|
2171
|
+
pinLabels
|
|
2146
2172
|
}, soup) => {
|
|
2147
2173
|
const components = [];
|
|
2148
2174
|
for (const elm of soup) {
|
|
@@ -2222,16 +2248,22 @@ var createComponentsFromSoup = ({
|
|
|
2222
2248
|
const normalizedRotation = (readableRotation % 360 + 360) % 360;
|
|
2223
2249
|
const isUpsideDown = normalizedRotation > 90 && normalizedRotation <= 270;
|
|
2224
2250
|
readableRotation = isUpsideDown ? (normalizedRotation + 180) % 360 : normalizedRotation;
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2251
|
+
if (footprint.includes("pinrow") && elm.text.includes("PIN") && pinLabels) {
|
|
2252
|
+
components.push(
|
|
2253
|
+
createPinrowSilkscreenText({ elm, pinLabels, readableRotation })
|
|
2254
|
+
);
|
|
2255
|
+
} else if (elm.text === "{REF}") {
|
|
2256
|
+
components.push(
|
|
2257
|
+
new SilkscreenText({
|
|
2258
|
+
anchorAlignment: "center",
|
|
2259
|
+
text: componentName,
|
|
2260
|
+
fontSize: elm.font_size + 0.2,
|
|
2261
|
+
pcbX: isNaN(elm.anchor_position.x) ? 0 : elm.anchor_position.x,
|
|
2262
|
+
pcbY: elm.anchor_position.y,
|
|
2263
|
+
pcbRotation: readableRotation ?? 0
|
|
2264
|
+
})
|
|
2265
|
+
);
|
|
2266
|
+
}
|
|
2235
2267
|
}
|
|
2236
2268
|
}
|
|
2237
2269
|
return components;
|
|
@@ -5009,14 +5041,18 @@ var NormalComponent = class extends PrimitiveComponent2 {
|
|
|
5009
5041
|
return null;
|
|
5010
5042
|
}
|
|
5011
5043
|
_addChildrenFromStringFootprint() {
|
|
5012
|
-
const {
|
|
5044
|
+
const {
|
|
5045
|
+
name: componentName,
|
|
5046
|
+
pcbRotation: componentRotation,
|
|
5047
|
+
pinLabels
|
|
5048
|
+
} = this.props;
|
|
5013
5049
|
let { footprint } = this.props;
|
|
5014
5050
|
footprint ??= this._getImpliedFootprintString?.();
|
|
5015
5051
|
if (!footprint) return;
|
|
5016
5052
|
if (typeof footprint === "string") {
|
|
5017
5053
|
const fpSoup = fp.string(footprint).soup();
|
|
5018
|
-
const fpComponents =
|
|
5019
|
-
{ componentName, componentRotation },
|
|
5054
|
+
const fpComponents = createComponentsFromCircuitJson(
|
|
5055
|
+
{ componentName, componentRotation, footprint, pinLabels },
|
|
5020
5056
|
fpSoup
|
|
5021
5057
|
);
|
|
5022
5058
|
this.addAll(fpComponents);
|
|
@@ -7972,7 +8008,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
7972
8008
|
var package_default = {
|
|
7973
8009
|
name: "@tscircuit/core",
|
|
7974
8010
|
type: "module",
|
|
7975
|
-
version: "0.0.
|
|
8011
|
+
version: "0.0.390",
|
|
7976
8012
|
types: "dist/index.d.ts",
|
|
7977
8013
|
main: "dist/index.js",
|
|
7978
8014
|
module: "dist/index.js",
|
|
@@ -7995,7 +8031,7 @@ var package_default = {
|
|
|
7995
8031
|
},
|
|
7996
8032
|
devDependencies: {
|
|
7997
8033
|
"@biomejs/biome": "^1.8.3",
|
|
7998
|
-
"@tscircuit/footprinter": "^0.0.
|
|
8034
|
+
"@tscircuit/footprinter": "^0.0.154",
|
|
7999
8035
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
8000
8036
|
"@tscircuit/layout": "^0.0.28",
|
|
8001
8037
|
"@tscircuit/log-soup": "^1.0.2",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.391",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@biomejs/biome": "^1.8.3",
|
|
27
|
-
"@tscircuit/footprinter": "^0.0.
|
|
27
|
+
"@tscircuit/footprinter": "^0.0.154",
|
|
28
28
|
"@tscircuit/import-snippet": "^0.0.4",
|
|
29
29
|
"@tscircuit/layout": "^0.0.28",
|
|
30
30
|
"@tscircuit/log-soup": "^1.0.2",
|