@tscircuit/pcb-viewer 1.11.277 → 1.11.279
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 +210 -149
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7075,6 +7075,203 @@ function getExpandedStroke(strokeInput, defaultWidth) {
|
|
|
7075
7075
|
|
|
7076
7076
|
// src/lib/convert-element-to-primitive.ts
|
|
7077
7077
|
import { distance } from "circuit-json";
|
|
7078
|
+
|
|
7079
|
+
// src/lib/element-to-primitive-converters/convert-smtpad-rect.ts
|
|
7080
|
+
var convertSmtpadRect = (element, metadata) => {
|
|
7081
|
+
const { x, y, width, height, layer, rect_border_radius } = element;
|
|
7082
|
+
const corner_radius = element.corner_radius ?? rect_border_radius ?? 0;
|
|
7083
|
+
const primitives = [
|
|
7084
|
+
{
|
|
7085
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("rect"),
|
|
7086
|
+
pcb_drawing_type: "rect",
|
|
7087
|
+
x,
|
|
7088
|
+
y,
|
|
7089
|
+
w: width,
|
|
7090
|
+
h: height,
|
|
7091
|
+
layer: layer || "top",
|
|
7092
|
+
_element: element,
|
|
7093
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7094
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7095
|
+
_source_port: metadata._source_port,
|
|
7096
|
+
roundness: corner_radius,
|
|
7097
|
+
...element.shape === "rotated_rect" && element.ccw_rotation !== void 0 ? { ccw_rotation: element.ccw_rotation } : {}
|
|
7098
|
+
}
|
|
7099
|
+
];
|
|
7100
|
+
if (element.is_covered_with_solder_mask) {
|
|
7101
|
+
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7102
|
+
const maskPrimitiveBase = {
|
|
7103
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("rect"),
|
|
7104
|
+
pcb_drawing_type: "rect",
|
|
7105
|
+
x,
|
|
7106
|
+
y,
|
|
7107
|
+
w: width,
|
|
7108
|
+
h: height,
|
|
7109
|
+
layer: maskLayer,
|
|
7110
|
+
_element: element,
|
|
7111
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7112
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7113
|
+
_source_port: metadata._source_port,
|
|
7114
|
+
roundness: corner_radius,
|
|
7115
|
+
...element.shape === "rotated_rect" && element.ccw_rotation !== void 0 ? { ccw_rotation: element.ccw_rotation } : {}
|
|
7116
|
+
};
|
|
7117
|
+
const maskPrimitive = {
|
|
7118
|
+
...maskPrimitiveBase,
|
|
7119
|
+
..."solder_mask_color" in element && element.solder_mask_color ? { color: element.solder_mask_color } : {}
|
|
7120
|
+
};
|
|
7121
|
+
primitives.push(maskPrimitive);
|
|
7122
|
+
}
|
|
7123
|
+
return primitives;
|
|
7124
|
+
};
|
|
7125
|
+
|
|
7126
|
+
// src/lib/element-to-primitive-converters/convert-smtpad-circle.ts
|
|
7127
|
+
var convertSmtpadCircle = (element, metadata) => {
|
|
7128
|
+
const { x, y, radius, layer } = element;
|
|
7129
|
+
const primitives = [
|
|
7130
|
+
{
|
|
7131
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("circle"),
|
|
7132
|
+
pcb_drawing_type: "circle",
|
|
7133
|
+
x,
|
|
7134
|
+
y,
|
|
7135
|
+
r: radius,
|
|
7136
|
+
layer: layer || "top",
|
|
7137
|
+
_element: element,
|
|
7138
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7139
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7140
|
+
_source_port: metadata._source_port
|
|
7141
|
+
}
|
|
7142
|
+
];
|
|
7143
|
+
if (element.is_covered_with_solder_mask) {
|
|
7144
|
+
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7145
|
+
const maskPrimitive = {
|
|
7146
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("circle"),
|
|
7147
|
+
pcb_drawing_type: "circle",
|
|
7148
|
+
x,
|
|
7149
|
+
y,
|
|
7150
|
+
r: radius,
|
|
7151
|
+
layer: maskLayer,
|
|
7152
|
+
_element: element,
|
|
7153
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7154
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7155
|
+
_source_port: metadata._source_port,
|
|
7156
|
+
..."solder_mask_color" in element && element.solder_mask_color ? { color: element.solder_mask_color } : {}
|
|
7157
|
+
};
|
|
7158
|
+
primitives.push(maskPrimitive);
|
|
7159
|
+
}
|
|
7160
|
+
return primitives;
|
|
7161
|
+
};
|
|
7162
|
+
|
|
7163
|
+
// src/lib/element-to-primitive-converters/convert-smtpad-polygon.ts
|
|
7164
|
+
var convertSmtpadPolygon = (element, metadata) => {
|
|
7165
|
+
const { layer, points } = element;
|
|
7166
|
+
const primitives = [
|
|
7167
|
+
{
|
|
7168
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("polygon"),
|
|
7169
|
+
pcb_drawing_type: "polygon",
|
|
7170
|
+
points: normalizePolygonPoints(points),
|
|
7171
|
+
layer: layer || "top",
|
|
7172
|
+
_element: element,
|
|
7173
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7174
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7175
|
+
_source_port: metadata._source_port
|
|
7176
|
+
}
|
|
7177
|
+
];
|
|
7178
|
+
if (element.is_covered_with_solder_mask) {
|
|
7179
|
+
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7180
|
+
const maskPrimitive = {
|
|
7181
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("polygon"),
|
|
7182
|
+
pcb_drawing_type: "polygon",
|
|
7183
|
+
points: normalizePolygonPoints(points),
|
|
7184
|
+
layer: maskLayer,
|
|
7185
|
+
_element: element,
|
|
7186
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7187
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7188
|
+
_source_port: metadata._source_port,
|
|
7189
|
+
..."solder_mask_color" in element && element.solder_mask_color ? { color: element.solder_mask_color } : {}
|
|
7190
|
+
};
|
|
7191
|
+
primitives.push(maskPrimitive);
|
|
7192
|
+
}
|
|
7193
|
+
return primitives;
|
|
7194
|
+
};
|
|
7195
|
+
|
|
7196
|
+
// src/lib/element-to-primitive-converters/convert-smtpad-pill.ts
|
|
7197
|
+
var convertSmtpadPill = (element, metadata) => {
|
|
7198
|
+
const { x, y, width, height, layer } = element;
|
|
7199
|
+
const primitives = [
|
|
7200
|
+
{
|
|
7201
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pill"),
|
|
7202
|
+
pcb_drawing_type: "pill",
|
|
7203
|
+
x,
|
|
7204
|
+
y,
|
|
7205
|
+
w: width,
|
|
7206
|
+
h: height,
|
|
7207
|
+
layer: layer || "top",
|
|
7208
|
+
_element: element,
|
|
7209
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7210
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7211
|
+
_source_port: metadata._source_port
|
|
7212
|
+
}
|
|
7213
|
+
];
|
|
7214
|
+
if (element.is_covered_with_solder_mask) {
|
|
7215
|
+
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7216
|
+
const maskPrimitive = {
|
|
7217
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pill"),
|
|
7218
|
+
pcb_drawing_type: "pill",
|
|
7219
|
+
x,
|
|
7220
|
+
y,
|
|
7221
|
+
w: width,
|
|
7222
|
+
h: height,
|
|
7223
|
+
layer: maskLayer,
|
|
7224
|
+
_element: element,
|
|
7225
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7226
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7227
|
+
_source_port: metadata._source_port,
|
|
7228
|
+
..."solder_mask_color" in element && element.solder_mask_color ? { color: element.solder_mask_color } : {}
|
|
7229
|
+
};
|
|
7230
|
+
primitives.push(maskPrimitive);
|
|
7231
|
+
}
|
|
7232
|
+
return primitives;
|
|
7233
|
+
};
|
|
7234
|
+
var convertSmtpadRotatedPill = (element, metadata) => {
|
|
7235
|
+
const { x, y, width, height, layer, ccw_rotation } = element;
|
|
7236
|
+
const primitives = [
|
|
7237
|
+
{
|
|
7238
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pill"),
|
|
7239
|
+
pcb_drawing_type: "pill",
|
|
7240
|
+
x,
|
|
7241
|
+
y,
|
|
7242
|
+
w: width,
|
|
7243
|
+
h: height,
|
|
7244
|
+
layer: layer || "top",
|
|
7245
|
+
_element: element,
|
|
7246
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7247
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7248
|
+
_source_port: metadata._source_port,
|
|
7249
|
+
ccw_rotation
|
|
7250
|
+
}
|
|
7251
|
+
];
|
|
7252
|
+
if (element.is_covered_with_solder_mask) {
|
|
7253
|
+
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7254
|
+
const maskPrimitive = {
|
|
7255
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pill"),
|
|
7256
|
+
pcb_drawing_type: "pill",
|
|
7257
|
+
x,
|
|
7258
|
+
y,
|
|
7259
|
+
w: width,
|
|
7260
|
+
h: height,
|
|
7261
|
+
layer: maskLayer,
|
|
7262
|
+
_element: element,
|
|
7263
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7264
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7265
|
+
_source_port: metadata._source_port,
|
|
7266
|
+
ccw_rotation,
|
|
7267
|
+
..."solder_mask_color" in element && element.solder_mask_color ? { color: element.solder_mask_color } : {}
|
|
7268
|
+
};
|
|
7269
|
+
primitives.push(maskPrimitive);
|
|
7270
|
+
}
|
|
7271
|
+
return primitives;
|
|
7272
|
+
};
|
|
7273
|
+
|
|
7274
|
+
// src/lib/convert-element-to-primitive.ts
|
|
7078
7275
|
var globalPcbDrawingObjectCount = 0;
|
|
7079
7276
|
var getNewPcbDrawingObjectId = (prefix) => `${prefix}_${globalPcbDrawingObjectCount++}`;
|
|
7080
7277
|
var normalizePolygonPoints = (points) => (points ?? []).map((point) => ({
|
|
@@ -7267,157 +7464,21 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7267
7464
|
return primitives;
|
|
7268
7465
|
}
|
|
7269
7466
|
case "pcb_smtpad": {
|
|
7467
|
+
const metadata = {
|
|
7468
|
+
_parent_pcb_component,
|
|
7469
|
+
_parent_source_component,
|
|
7470
|
+
_source_port
|
|
7471
|
+
};
|
|
7270
7472
|
if (element.shape === "rect" || element.shape === "rotated_rect") {
|
|
7271
|
-
|
|
7272
|
-
const corner_radius = element.corner_radius ?? rect_border_radius ?? 0;
|
|
7273
|
-
const primitives = [
|
|
7274
|
-
{
|
|
7275
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7276
|
-
pcb_drawing_type: "rect",
|
|
7277
|
-
x,
|
|
7278
|
-
y,
|
|
7279
|
-
w: width,
|
|
7280
|
-
h: height,
|
|
7281
|
-
layer: layer || "top",
|
|
7282
|
-
_element: element,
|
|
7283
|
-
_parent_pcb_component,
|
|
7284
|
-
_parent_source_component,
|
|
7285
|
-
_source_port,
|
|
7286
|
-
ccw_rotation: element.ccw_rotation,
|
|
7287
|
-
roundness: corner_radius
|
|
7288
|
-
}
|
|
7289
|
-
];
|
|
7290
|
-
if (element.is_covered_with_solder_mask) {
|
|
7291
|
-
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7292
|
-
const maskPrimitive = {
|
|
7293
|
-
_pcb_drawing_object_id: `rect_${globalPcbDrawingObjectCount++}`,
|
|
7294
|
-
pcb_drawing_type: "rect",
|
|
7295
|
-
x,
|
|
7296
|
-
y,
|
|
7297
|
-
w: width,
|
|
7298
|
-
h: height,
|
|
7299
|
-
layer: maskLayer,
|
|
7300
|
-
_element: element,
|
|
7301
|
-
_parent_pcb_component,
|
|
7302
|
-
_parent_source_component,
|
|
7303
|
-
_source_port,
|
|
7304
|
-
ccw_rotation: element.ccw_rotation,
|
|
7305
|
-
roundness: corner_radius
|
|
7306
|
-
};
|
|
7307
|
-
if (element.solder_mask_color) {
|
|
7308
|
-
maskPrimitive.color = element.solder_mask_color;
|
|
7309
|
-
}
|
|
7310
|
-
primitives.push(maskPrimitive);
|
|
7311
|
-
}
|
|
7312
|
-
return primitives;
|
|
7473
|
+
return convertSmtpadRect(element, metadata);
|
|
7313
7474
|
} else if (element.shape === "circle") {
|
|
7314
|
-
|
|
7315
|
-
const primitives = [
|
|
7316
|
-
{
|
|
7317
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7318
|
-
pcb_drawing_type: "circle",
|
|
7319
|
-
x,
|
|
7320
|
-
y,
|
|
7321
|
-
r: radius,
|
|
7322
|
-
layer: layer || "top",
|
|
7323
|
-
_element: element,
|
|
7324
|
-
_parent_pcb_component,
|
|
7325
|
-
_parent_source_component,
|
|
7326
|
-
_source_port
|
|
7327
|
-
}
|
|
7328
|
-
];
|
|
7329
|
-
if (element.is_covered_with_solder_mask) {
|
|
7330
|
-
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7331
|
-
const maskPrimitive = {
|
|
7332
|
-
_pcb_drawing_object_id: `circle_${globalPcbDrawingObjectCount++}`,
|
|
7333
|
-
pcb_drawing_type: "circle",
|
|
7334
|
-
x,
|
|
7335
|
-
y,
|
|
7336
|
-
r: radius,
|
|
7337
|
-
layer: maskLayer,
|
|
7338
|
-
_element: element,
|
|
7339
|
-
_parent_pcb_component,
|
|
7340
|
-
_parent_source_component,
|
|
7341
|
-
_source_port
|
|
7342
|
-
};
|
|
7343
|
-
if (element.solder_mask_color) {
|
|
7344
|
-
maskPrimitive.color = element.solder_mask_color;
|
|
7345
|
-
}
|
|
7346
|
-
primitives.push(maskPrimitive);
|
|
7347
|
-
}
|
|
7348
|
-
return primitives;
|
|
7475
|
+
return convertSmtpadCircle(element, metadata);
|
|
7349
7476
|
} else if (element.shape === "polygon") {
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
points: normalizePolygonPoints(points),
|
|
7356
|
-
layer: layer || "top",
|
|
7357
|
-
_element: element,
|
|
7358
|
-
_parent_pcb_component,
|
|
7359
|
-
_parent_source_component,
|
|
7360
|
-
_source_port
|
|
7361
|
-
}
|
|
7362
|
-
];
|
|
7363
|
-
if (element.is_covered_with_solder_mask) {
|
|
7364
|
-
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7365
|
-
const maskPrimitive = {
|
|
7366
|
-
_pcb_drawing_object_id: `polygon_${globalPcbDrawingObjectCount++}`,
|
|
7367
|
-
pcb_drawing_type: "polygon",
|
|
7368
|
-
points: normalizePolygonPoints(points),
|
|
7369
|
-
layer: maskLayer,
|
|
7370
|
-
_element: element,
|
|
7371
|
-
_parent_pcb_component,
|
|
7372
|
-
_parent_source_component,
|
|
7373
|
-
_source_port
|
|
7374
|
-
};
|
|
7375
|
-
if (element.solder_mask_color) {
|
|
7376
|
-
maskPrimitive.color = element.solder_mask_color;
|
|
7377
|
-
}
|
|
7378
|
-
primitives.push(maskPrimitive);
|
|
7379
|
-
}
|
|
7380
|
-
return primitives;
|
|
7381
|
-
} else if (element.shape === "pill" || element.shape === "rotated_pill") {
|
|
7382
|
-
const { x, y, width, height, layer } = element;
|
|
7383
|
-
const primitives = [
|
|
7384
|
-
{
|
|
7385
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7386
|
-
pcb_drawing_type: "pill",
|
|
7387
|
-
x,
|
|
7388
|
-
y,
|
|
7389
|
-
w: width,
|
|
7390
|
-
h: height,
|
|
7391
|
-
layer: layer || "top",
|
|
7392
|
-
_element: element,
|
|
7393
|
-
_parent_pcb_component,
|
|
7394
|
-
_parent_source_component,
|
|
7395
|
-
_source_port,
|
|
7396
|
-
ccw_rotation: element.ccw_rotation
|
|
7397
|
-
}
|
|
7398
|
-
];
|
|
7399
|
-
if (element.is_covered_with_solder_mask) {
|
|
7400
|
-
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7401
|
-
const maskPrimitive = {
|
|
7402
|
-
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
|
|
7403
|
-
pcb_drawing_type: "pill",
|
|
7404
|
-
x,
|
|
7405
|
-
y,
|
|
7406
|
-
w: width,
|
|
7407
|
-
h: height,
|
|
7408
|
-
layer: maskLayer,
|
|
7409
|
-
_element: element,
|
|
7410
|
-
_parent_pcb_component,
|
|
7411
|
-
_parent_source_component,
|
|
7412
|
-
_source_port,
|
|
7413
|
-
ccw_rotation: element.ccw_rotation
|
|
7414
|
-
};
|
|
7415
|
-
if (element.solder_mask_color) {
|
|
7416
|
-
maskPrimitive.color = element.solder_mask_color;
|
|
7417
|
-
}
|
|
7418
|
-
primitives.push(maskPrimitive);
|
|
7419
|
-
}
|
|
7420
|
-
return primitives;
|
|
7477
|
+
return convertSmtpadPolygon(element, metadata);
|
|
7478
|
+
} else if (element.shape === "pill") {
|
|
7479
|
+
return convertSmtpadPill(element, metadata);
|
|
7480
|
+
} else if (element.shape === "rotated_pill") {
|
|
7481
|
+
return convertSmtpadRotatedPill(element, metadata);
|
|
7421
7482
|
}
|
|
7422
7483
|
return [];
|
|
7423
7484
|
}
|
|
@@ -13311,7 +13372,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13311
13372
|
// package.json
|
|
13312
13373
|
var package_default = {
|
|
13313
13374
|
name: "@tscircuit/pcb-viewer",
|
|
13314
|
-
version: "1.11.
|
|
13375
|
+
version: "1.11.278",
|
|
13315
13376
|
main: "dist/index.js",
|
|
13316
13377
|
type: "module",
|
|
13317
13378
|
repository: "tscircuit/pcb-viewer",
|