@tscircuit/pcb-viewer 1.11.277 → 1.11.278
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 +170 -148
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7075,6 +7075,166 @@ 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
|
+
...element.shape === "rotated_pill" && element.ccw_rotation !== void 0 ? { ccw_rotation: element.ccw_rotation } : {}
|
|
7213
|
+
}
|
|
7214
|
+
];
|
|
7215
|
+
if (element.is_covered_with_solder_mask) {
|
|
7216
|
+
const maskLayer = layer === "bottom" ? "soldermask_with_copper_bottom" : "soldermask_with_copper_top";
|
|
7217
|
+
const maskPrimitive = {
|
|
7218
|
+
_pcb_drawing_object_id: getNewPcbDrawingObjectId("pill"),
|
|
7219
|
+
pcb_drawing_type: "pill",
|
|
7220
|
+
x,
|
|
7221
|
+
y,
|
|
7222
|
+
w: width,
|
|
7223
|
+
h: height,
|
|
7224
|
+
layer: maskLayer,
|
|
7225
|
+
_element: element,
|
|
7226
|
+
_parent_pcb_component: metadata._parent_pcb_component,
|
|
7227
|
+
_parent_source_component: metadata._parent_source_component,
|
|
7228
|
+
_source_port: metadata._source_port,
|
|
7229
|
+
...element.shape === "rotated_pill" && element.ccw_rotation !== void 0 ? { ccw_rotation: element.ccw_rotation } : {},
|
|
7230
|
+
..."solder_mask_color" in element && element.solder_mask_color ? { color: element.solder_mask_color } : {}
|
|
7231
|
+
};
|
|
7232
|
+
primitives.push(maskPrimitive);
|
|
7233
|
+
}
|
|
7234
|
+
return primitives;
|
|
7235
|
+
};
|
|
7236
|
+
|
|
7237
|
+
// src/lib/convert-element-to-primitive.ts
|
|
7078
7238
|
var globalPcbDrawingObjectCount = 0;
|
|
7079
7239
|
var getNewPcbDrawingObjectId = (prefix) => `${prefix}_${globalPcbDrawingObjectCount++}`;
|
|
7080
7240
|
var normalizePolygonPoints = (points) => (points ?? []).map((point) => ({
|
|
@@ -7267,157 +7427,19 @@ var convertElementToPrimitives = (element, allElements) => {
|
|
|
7267
7427
|
return primitives;
|
|
7268
7428
|
}
|
|
7269
7429
|
case "pcb_smtpad": {
|
|
7430
|
+
const metadata = {
|
|
7431
|
+
_parent_pcb_component,
|
|
7432
|
+
_parent_source_component,
|
|
7433
|
+
_source_port
|
|
7434
|
+
};
|
|
7270
7435
|
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;
|
|
7436
|
+
return convertSmtpadRect(element, metadata);
|
|
7313
7437
|
} 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;
|
|
7438
|
+
return convertSmtpadCircle(element, metadata);
|
|
7349
7439
|
} else if (element.shape === "polygon") {
|
|
7350
|
-
|
|
7351
|
-
const primitives = [
|
|
7352
|
-
{
|
|
7353
|
-
_pcb_drawing_object_id: `polygon_${globalPcbDrawingObjectCount++}`,
|
|
7354
|
-
pcb_drawing_type: "polygon",
|
|
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;
|
|
7440
|
+
return convertSmtpadPolygon(element, metadata);
|
|
7381
7441
|
} else if (element.shape === "pill" || element.shape === "rotated_pill") {
|
|
7382
|
-
|
|
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;
|
|
7442
|
+
return convertSmtpadPill(element, metadata);
|
|
7421
7443
|
}
|
|
7422
7444
|
return [];
|
|
7423
7445
|
}
|
|
@@ -13311,7 +13333,7 @@ import { css as css3 } from "@emotion/css";
|
|
|
13311
13333
|
// package.json
|
|
13312
13334
|
var package_default = {
|
|
13313
13335
|
name: "@tscircuit/pcb-viewer",
|
|
13314
|
-
version: "1.11.
|
|
13336
|
+
version: "1.11.277",
|
|
13315
13337
|
main: "dist/index.js",
|
|
13316
13338
|
type: "module",
|
|
13317
13339
|
repository: "tscircuit/pcb-viewer",
|