@tscircuit/core 0.0.1109 → 0.0.1111
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.d.ts +40 -0
- package/dist/index.js +456 -301
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -77220,6 +77220,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77220
77220
|
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77221
77221
|
y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77222
77222
|
width: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77223
|
+
copper_pour_id: z.ZodOptional<z.ZodString>;
|
|
77224
|
+
is_inside_copper_pour: z.ZodOptional<z.ZodBoolean>;
|
|
77223
77225
|
start_pcb_port_id: z.ZodOptional<z.ZodString>;
|
|
77224
77226
|
end_pcb_port_id: z.ZodOptional<z.ZodString>;
|
|
77225
77227
|
layer: z.ZodEffects<z.ZodUnion<[z.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>, z.ZodObject<{
|
|
@@ -77237,6 +77239,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77237
77239
|
width: number;
|
|
77238
77240
|
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77239
77241
|
route_type: "wire";
|
|
77242
|
+
copper_pour_id?: string | undefined;
|
|
77243
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77240
77244
|
start_pcb_port_id?: string | undefined;
|
|
77241
77245
|
end_pcb_port_id?: string | undefined;
|
|
77242
77246
|
}, {
|
|
@@ -77247,12 +77251,16 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77247
77251
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77248
77252
|
};
|
|
77249
77253
|
route_type: "wire";
|
|
77254
|
+
copper_pour_id?: string | undefined;
|
|
77255
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77250
77256
|
start_pcb_port_id?: string | undefined;
|
|
77251
77257
|
end_pcb_port_id?: string | undefined;
|
|
77252
77258
|
}>, z.ZodObject<{
|
|
77253
77259
|
route_type: z.ZodLiteral<"via">;
|
|
77254
77260
|
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77255
77261
|
y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77262
|
+
copper_pour_id: z.ZodOptional<z.ZodString>;
|
|
77263
|
+
is_inside_copper_pour: z.ZodOptional<z.ZodBoolean>;
|
|
77256
77264
|
hole_diameter: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
77257
77265
|
outer_diameter: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
77258
77266
|
from_layer: z.ZodString;
|
|
@@ -77265,6 +77273,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77265
77273
|
from_layer: string;
|
|
77266
77274
|
hole_diameter?: number | undefined;
|
|
77267
77275
|
outer_diameter?: number | undefined;
|
|
77276
|
+
copper_pour_id?: string | undefined;
|
|
77277
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77268
77278
|
}, {
|
|
77269
77279
|
x: string | number;
|
|
77270
77280
|
y: string | number;
|
|
@@ -77273,6 +77283,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77273
77283
|
from_layer: string;
|
|
77274
77284
|
hole_diameter?: string | number | undefined;
|
|
77275
77285
|
outer_diameter?: string | number | undefined;
|
|
77286
|
+
copper_pour_id?: string | undefined;
|
|
77287
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77276
77288
|
}>]>, "many">;
|
|
77277
77289
|
source_trace_id: z.ZodOptional<z.ZodString>;
|
|
77278
77290
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -77282,6 +77294,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77282
77294
|
width: number;
|
|
77283
77295
|
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77284
77296
|
route_type: "wire";
|
|
77297
|
+
copper_pour_id?: string | undefined;
|
|
77298
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77285
77299
|
start_pcb_port_id?: string | undefined;
|
|
77286
77300
|
end_pcb_port_id?: string | undefined;
|
|
77287
77301
|
} | {
|
|
@@ -77292,6 +77306,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77292
77306
|
from_layer: string;
|
|
77293
77307
|
hole_diameter?: number | undefined;
|
|
77294
77308
|
outer_diameter?: number | undefined;
|
|
77309
|
+
copper_pour_id?: string | undefined;
|
|
77310
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77295
77311
|
})[];
|
|
77296
77312
|
source_trace_id?: string | undefined;
|
|
77297
77313
|
}, {
|
|
@@ -77303,6 +77319,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77303
77319
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77304
77320
|
};
|
|
77305
77321
|
route_type: "wire";
|
|
77322
|
+
copper_pour_id?: string | undefined;
|
|
77323
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77306
77324
|
start_pcb_port_id?: string | undefined;
|
|
77307
77325
|
end_pcb_port_id?: string | undefined;
|
|
77308
77326
|
} | {
|
|
@@ -77313,6 +77331,8 @@ declare const pcbTraceProps: z.ZodObject<{
|
|
|
77313
77331
|
from_layer: string;
|
|
77314
77332
|
hole_diameter?: string | number | undefined;
|
|
77315
77333
|
outer_diameter?: string | number | undefined;
|
|
77334
|
+
copper_pour_id?: string | undefined;
|
|
77335
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77316
77336
|
})[];
|
|
77317
77337
|
source_trace_id?: string | undefined;
|
|
77318
77338
|
}>;
|
|
@@ -77327,6 +77347,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77327
77347
|
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77328
77348
|
y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77329
77349
|
width: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77350
|
+
copper_pour_id: z.ZodOptional<z.ZodString>;
|
|
77351
|
+
is_inside_copper_pour: z.ZodOptional<z.ZodBoolean>;
|
|
77330
77352
|
start_pcb_port_id: z.ZodOptional<z.ZodString>;
|
|
77331
77353
|
end_pcb_port_id: z.ZodOptional<z.ZodString>;
|
|
77332
77354
|
layer: z.ZodEffects<z.ZodUnion<[z.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>, z.ZodObject<{
|
|
@@ -77344,6 +77366,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77344
77366
|
width: number;
|
|
77345
77367
|
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77346
77368
|
route_type: "wire";
|
|
77369
|
+
copper_pour_id?: string | undefined;
|
|
77370
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77347
77371
|
start_pcb_port_id?: string | undefined;
|
|
77348
77372
|
end_pcb_port_id?: string | undefined;
|
|
77349
77373
|
}, {
|
|
@@ -77354,12 +77378,16 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77354
77378
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77355
77379
|
};
|
|
77356
77380
|
route_type: "wire";
|
|
77381
|
+
copper_pour_id?: string | undefined;
|
|
77382
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77357
77383
|
start_pcb_port_id?: string | undefined;
|
|
77358
77384
|
end_pcb_port_id?: string | undefined;
|
|
77359
77385
|
}>, z.ZodObject<{
|
|
77360
77386
|
route_type: z.ZodLiteral<"via">;
|
|
77361
77387
|
x: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77362
77388
|
y: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
77389
|
+
copper_pour_id: z.ZodOptional<z.ZodString>;
|
|
77390
|
+
is_inside_copper_pour: z.ZodOptional<z.ZodBoolean>;
|
|
77363
77391
|
hole_diameter: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
77364
77392
|
outer_diameter: z.ZodOptional<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>>;
|
|
77365
77393
|
from_layer: z.ZodString;
|
|
@@ -77372,6 +77400,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77372
77400
|
from_layer: string;
|
|
77373
77401
|
hole_diameter?: number | undefined;
|
|
77374
77402
|
outer_diameter?: number | undefined;
|
|
77403
|
+
copper_pour_id?: string | undefined;
|
|
77404
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77375
77405
|
}, {
|
|
77376
77406
|
x: string | number;
|
|
77377
77407
|
y: string | number;
|
|
@@ -77380,6 +77410,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77380
77410
|
from_layer: string;
|
|
77381
77411
|
hole_diameter?: string | number | undefined;
|
|
77382
77412
|
outer_diameter?: string | number | undefined;
|
|
77413
|
+
copper_pour_id?: string | undefined;
|
|
77414
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77383
77415
|
}>]>, "many">;
|
|
77384
77416
|
source_trace_id: z.ZodOptional<z.ZodString>;
|
|
77385
77417
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -77389,6 +77421,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77389
77421
|
width: number;
|
|
77390
77422
|
layer: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77391
77423
|
route_type: "wire";
|
|
77424
|
+
copper_pour_id?: string | undefined;
|
|
77425
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77392
77426
|
start_pcb_port_id?: string | undefined;
|
|
77393
77427
|
end_pcb_port_id?: string | undefined;
|
|
77394
77428
|
} | {
|
|
@@ -77399,6 +77433,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77399
77433
|
from_layer: string;
|
|
77400
77434
|
hole_diameter?: number | undefined;
|
|
77401
77435
|
outer_diameter?: number | undefined;
|
|
77436
|
+
copper_pour_id?: string | undefined;
|
|
77437
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77402
77438
|
})[];
|
|
77403
77439
|
source_trace_id?: string | undefined;
|
|
77404
77440
|
}, {
|
|
@@ -77410,6 +77446,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77410
77446
|
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
77411
77447
|
};
|
|
77412
77448
|
route_type: "wire";
|
|
77449
|
+
copper_pour_id?: string | undefined;
|
|
77450
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77413
77451
|
start_pcb_port_id?: string | undefined;
|
|
77414
77452
|
end_pcb_port_id?: string | undefined;
|
|
77415
77453
|
} | {
|
|
@@ -77420,6 +77458,8 @@ declare class PcbTrace extends PrimitiveComponent<typeof pcbTraceProps> {
|
|
|
77420
77458
|
from_layer: string;
|
|
77421
77459
|
hole_diameter?: string | number | undefined;
|
|
77422
77460
|
outer_diameter?: string | number | undefined;
|
|
77461
|
+
copper_pour_id?: string | undefined;
|
|
77462
|
+
is_inside_copper_pour?: boolean | undefined;
|
|
77423
77463
|
})[];
|
|
77424
77464
|
source_trace_id?: string | undefined;
|
|
77425
77465
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -5293,8 +5293,234 @@ var underscorifyPortArrangement = (portArrangement) => {
|
|
|
5293
5293
|
return void 0;
|
|
5294
5294
|
};
|
|
5295
5295
|
|
|
5296
|
-
// lib/components/primitive-components/
|
|
5296
|
+
// lib/components/primitive-components/CourtyardCircle.ts
|
|
5297
|
+
import { courtyardCircleProps } from "@tscircuit/props";
|
|
5298
|
+
var CourtyardCircle = class extends PrimitiveComponent2 {
|
|
5299
|
+
pcb_courtyard_circle_id = null;
|
|
5300
|
+
isPcbPrimitive = true;
|
|
5301
|
+
get config() {
|
|
5302
|
+
return {
|
|
5303
|
+
componentName: "CourtyardCircle",
|
|
5304
|
+
zodProps: courtyardCircleProps
|
|
5305
|
+
};
|
|
5306
|
+
}
|
|
5307
|
+
doInitialPcbPrimitiveRender() {
|
|
5308
|
+
if (this.root?.pcbDisabled) return;
|
|
5309
|
+
const { db } = this.root;
|
|
5310
|
+
const { _parsedProps: props } = this;
|
|
5311
|
+
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
5312
|
+
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
5313
|
+
const layer = maybeFlipLayer(props.layer ?? "top");
|
|
5314
|
+
if (layer !== "top" && layer !== "bottom") {
|
|
5315
|
+
throw new Error(
|
|
5316
|
+
`Invalid layer "${layer}" for CourtyardCircle. Must be "top" or "bottom".`
|
|
5317
|
+
);
|
|
5318
|
+
}
|
|
5319
|
+
const subcircuit = this.getSubcircuit();
|
|
5320
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
5321
|
+
const pcb_courtyard_circle = db.pcb_courtyard_circle.insert({
|
|
5322
|
+
pcb_component_id,
|
|
5323
|
+
layer,
|
|
5324
|
+
center: {
|
|
5325
|
+
x: position.x,
|
|
5326
|
+
y: position.y
|
|
5327
|
+
},
|
|
5328
|
+
radius: props.radius,
|
|
5329
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5330
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5331
|
+
});
|
|
5332
|
+
this.pcb_courtyard_circle_id = pcb_courtyard_circle.pcb_courtyard_circle_id;
|
|
5333
|
+
}
|
|
5334
|
+
getPcbSize() {
|
|
5335
|
+
const { _parsedProps: props } = this;
|
|
5336
|
+
const diameter = props.radius * 2;
|
|
5337
|
+
return { width: diameter, height: diameter };
|
|
5338
|
+
}
|
|
5339
|
+
_moveCircuitJsonElements({
|
|
5340
|
+
deltaX,
|
|
5341
|
+
deltaY
|
|
5342
|
+
}) {
|
|
5343
|
+
if (this.root?.pcbDisabled) return;
|
|
5344
|
+
const { db } = this.root;
|
|
5345
|
+
if (!this.pcb_courtyard_circle_id) return;
|
|
5346
|
+
const circle = db.pcb_courtyard_circle.get(this.pcb_courtyard_circle_id);
|
|
5347
|
+
if (circle) {
|
|
5348
|
+
db.pcb_courtyard_circle.update(this.pcb_courtyard_circle_id, {
|
|
5349
|
+
center: {
|
|
5350
|
+
x: circle.center.x + deltaX,
|
|
5351
|
+
y: circle.center.y + deltaY
|
|
5352
|
+
}
|
|
5353
|
+
});
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
};
|
|
5357
|
+
|
|
5358
|
+
// lib/components/primitive-components/CourtyardOutline.ts
|
|
5359
|
+
import { courtyardOutlineProps } from "@tscircuit/props";
|
|
5360
|
+
import { getBoundsFromPoints } from "@tscircuit/math-utils";
|
|
5297
5361
|
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
5362
|
+
var CourtyardOutline = class extends PrimitiveComponent2 {
|
|
5363
|
+
pcb_courtyard_outline_id = null;
|
|
5364
|
+
isPcbPrimitive = true;
|
|
5365
|
+
get config() {
|
|
5366
|
+
return {
|
|
5367
|
+
componentName: "CourtyardOutline",
|
|
5368
|
+
zodProps: courtyardOutlineProps
|
|
5369
|
+
};
|
|
5370
|
+
}
|
|
5371
|
+
doInitialPcbPrimitiveRender() {
|
|
5372
|
+
if (this.root?.pcbDisabled) return;
|
|
5373
|
+
const { db } = this.root;
|
|
5374
|
+
const { _parsedProps: props } = this;
|
|
5375
|
+
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
5376
|
+
const layer = maybeFlipLayer(props.layer ?? "top");
|
|
5377
|
+
if (layer !== "top" && layer !== "bottom") {
|
|
5378
|
+
throw new Error(
|
|
5379
|
+
`Invalid layer "${layer}" for CourtyardOutline. Must be "top" or "bottom".`
|
|
5380
|
+
);
|
|
5381
|
+
}
|
|
5382
|
+
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
5383
|
+
const subcircuit = this.getSubcircuit();
|
|
5384
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
5385
|
+
const pcb_courtyard_outline = db.pcb_courtyard_outline.insert({
|
|
5386
|
+
pcb_component_id,
|
|
5387
|
+
layer,
|
|
5388
|
+
outline: props.outline.map((p) => {
|
|
5389
|
+
const transformedPosition = applyToPoint3(transform, {
|
|
5390
|
+
x: p.x,
|
|
5391
|
+
y: p.y
|
|
5392
|
+
});
|
|
5393
|
+
return {
|
|
5394
|
+
x: transformedPosition.x,
|
|
5395
|
+
y: transformedPosition.y
|
|
5396
|
+
};
|
|
5397
|
+
}),
|
|
5398
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5399
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5400
|
+
});
|
|
5401
|
+
this.pcb_courtyard_outline_id = pcb_courtyard_outline.pcb_courtyard_outline_id;
|
|
5402
|
+
}
|
|
5403
|
+
_setPositionFromLayout(newCenter) {
|
|
5404
|
+
const { db } = this.root;
|
|
5405
|
+
const currentOutline = db.pcb_courtyard_outline.get(
|
|
5406
|
+
this.pcb_courtyard_outline_id
|
|
5407
|
+
);
|
|
5408
|
+
if (!currentOutline) return;
|
|
5409
|
+
let currentCenterX = 0;
|
|
5410
|
+
let currentCenterY = 0;
|
|
5411
|
+
for (const point6 of currentOutline.outline) {
|
|
5412
|
+
currentCenterX += point6.x;
|
|
5413
|
+
currentCenterY += point6.y;
|
|
5414
|
+
}
|
|
5415
|
+
currentCenterX /= currentOutline.outline.length;
|
|
5416
|
+
currentCenterY /= currentOutline.outline.length;
|
|
5417
|
+
const offsetX = newCenter.x - currentCenterX;
|
|
5418
|
+
const offsetY = newCenter.y - currentCenterY;
|
|
5419
|
+
const newOutline = currentOutline.outline.map((point6) => ({
|
|
5420
|
+
x: point6.x + offsetX,
|
|
5421
|
+
y: point6.y + offsetY
|
|
5422
|
+
}));
|
|
5423
|
+
db.pcb_courtyard_outline.update(this.pcb_courtyard_outline_id, {
|
|
5424
|
+
outline: newOutline
|
|
5425
|
+
});
|
|
5426
|
+
}
|
|
5427
|
+
_moveCircuitJsonElements({
|
|
5428
|
+
deltaX,
|
|
5429
|
+
deltaY
|
|
5430
|
+
}) {
|
|
5431
|
+
if (this.root?.pcbDisabled) return;
|
|
5432
|
+
const { db } = this.root;
|
|
5433
|
+
if (!this.pcb_courtyard_outline_id) return;
|
|
5434
|
+
const outline = db.pcb_courtyard_outline.get(this.pcb_courtyard_outline_id);
|
|
5435
|
+
if (outline) {
|
|
5436
|
+
db.pcb_courtyard_outline.update(this.pcb_courtyard_outline_id, {
|
|
5437
|
+
outline: outline.outline.map((p) => ({
|
|
5438
|
+
x: p.x + deltaX,
|
|
5439
|
+
y: p.y + deltaY
|
|
5440
|
+
}))
|
|
5441
|
+
});
|
|
5442
|
+
}
|
|
5443
|
+
}
|
|
5444
|
+
getPcbSize() {
|
|
5445
|
+
const { _parsedProps: props } = this;
|
|
5446
|
+
if (!props.outline || props.outline.length === 0) {
|
|
5447
|
+
return { width: 0, height: 0 };
|
|
5448
|
+
}
|
|
5449
|
+
const bounds = getBoundsFromPoints(props.outline);
|
|
5450
|
+
if (!bounds) {
|
|
5451
|
+
return { width: 0, height: 0 };
|
|
5452
|
+
}
|
|
5453
|
+
return {
|
|
5454
|
+
width: bounds.maxX - bounds.minX,
|
|
5455
|
+
height: bounds.maxY - bounds.minY
|
|
5456
|
+
};
|
|
5457
|
+
}
|
|
5458
|
+
};
|
|
5459
|
+
|
|
5460
|
+
// lib/components/primitive-components/CourtyardRect.ts
|
|
5461
|
+
import { courtyardRectProps } from "@tscircuit/props";
|
|
5462
|
+
var CourtyardRect = class extends PrimitiveComponent2 {
|
|
5463
|
+
pcb_courtyard_rect_id = null;
|
|
5464
|
+
isPcbPrimitive = true;
|
|
5465
|
+
get config() {
|
|
5466
|
+
return {
|
|
5467
|
+
componentName: "CourtyardRect",
|
|
5468
|
+
zodProps: courtyardRectProps
|
|
5469
|
+
};
|
|
5470
|
+
}
|
|
5471
|
+
doInitialPcbPrimitiveRender() {
|
|
5472
|
+
if (this.root?.pcbDisabled) return;
|
|
5473
|
+
const { db } = this.root;
|
|
5474
|
+
const { _parsedProps: props } = this;
|
|
5475
|
+
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
5476
|
+
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
5477
|
+
const layer = maybeFlipLayer(props.layer ?? "top");
|
|
5478
|
+
if (layer !== "top" && layer !== "bottom") {
|
|
5479
|
+
throw new Error(
|
|
5480
|
+
`Invalid layer "${layer}" for CourtyardRect. Must be "top" or "bottom".`
|
|
5481
|
+
);
|
|
5482
|
+
}
|
|
5483
|
+
const subcircuit = this.getSubcircuit();
|
|
5484
|
+
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
5485
|
+
const pcb_courtyard_rect = db.pcb_courtyard_rect.insert({
|
|
5486
|
+
pcb_component_id,
|
|
5487
|
+
layer,
|
|
5488
|
+
center: {
|
|
5489
|
+
x: position.x,
|
|
5490
|
+
y: position.y
|
|
5491
|
+
},
|
|
5492
|
+
width: props.width,
|
|
5493
|
+
height: props.height,
|
|
5494
|
+
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
5495
|
+
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
5496
|
+
});
|
|
5497
|
+
this.pcb_courtyard_rect_id = pcb_courtyard_rect.pcb_courtyard_rect_id;
|
|
5498
|
+
}
|
|
5499
|
+
getPcbSize() {
|
|
5500
|
+
const { _parsedProps: props } = this;
|
|
5501
|
+
return { width: props.width, height: props.height };
|
|
5502
|
+
}
|
|
5503
|
+
_moveCircuitJsonElements({
|
|
5504
|
+
deltaX,
|
|
5505
|
+
deltaY
|
|
5506
|
+
}) {
|
|
5507
|
+
if (this.root?.pcbDisabled) return;
|
|
5508
|
+
const { db } = this.root;
|
|
5509
|
+
if (!this.pcb_courtyard_rect_id) return;
|
|
5510
|
+
const rect = db.pcb_courtyard_rect.get(this.pcb_courtyard_rect_id);
|
|
5511
|
+
if (rect) {
|
|
5512
|
+
db.pcb_courtyard_rect.update(this.pcb_courtyard_rect_id, {
|
|
5513
|
+
center: {
|
|
5514
|
+
x: rect.center.x + deltaX,
|
|
5515
|
+
y: rect.center.y + deltaY
|
|
5516
|
+
}
|
|
5517
|
+
});
|
|
5518
|
+
}
|
|
5519
|
+
}
|
|
5520
|
+
};
|
|
5521
|
+
|
|
5522
|
+
// lib/components/primitive-components/Cutout.ts
|
|
5523
|
+
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
5298
5524
|
import { cutoutProps } from "@tscircuit/props";
|
|
5299
5525
|
var Cutout = class extends PrimitiveComponent2 {
|
|
5300
5526
|
pcb_cutout_id = null;
|
|
@@ -5339,7 +5565,7 @@ var Cutout = class extends PrimitiveComponent2 {
|
|
|
5339
5565
|
} else if (props.shape === "polygon") {
|
|
5340
5566
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
5341
5567
|
const transformedPoints = props.points.map(
|
|
5342
|
-
(p) =>
|
|
5568
|
+
(p) => applyToPoint4(transform, p)
|
|
5343
5569
|
);
|
|
5344
5570
|
const polygonData = {
|
|
5345
5571
|
shape: "polygon",
|
|
@@ -5471,7 +5697,7 @@ var Cutout = class extends PrimitiveComponent2 {
|
|
|
5471
5697
|
|
|
5472
5698
|
// lib/components/primitive-components/FabricationNotePath.ts
|
|
5473
5699
|
import { fabricationNotePathProps } from "@tscircuit/props";
|
|
5474
|
-
import { applyToPoint as
|
|
5700
|
+
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
5475
5701
|
var FabricationNotePath = class extends PrimitiveComponent2 {
|
|
5476
5702
|
fabrication_note_path_id = null;
|
|
5477
5703
|
isPcbPrimitive = true;
|
|
@@ -5499,7 +5725,7 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
|
|
|
5499
5725
|
layer,
|
|
5500
5726
|
color: props.color,
|
|
5501
5727
|
route: props.route.map((p) => {
|
|
5502
|
-
const transformedPosition =
|
|
5728
|
+
const transformedPosition = applyToPoint5(transform, {
|
|
5503
5729
|
x: p.x,
|
|
5504
5730
|
y: p.y
|
|
5505
5731
|
});
|
|
@@ -5988,7 +6214,7 @@ var Keepout = class extends PrimitiveComponent2 {
|
|
|
5988
6214
|
|
|
5989
6215
|
// lib/components/primitive-components/PcbNoteLine.ts
|
|
5990
6216
|
import { pcbNoteLineProps } from "@tscircuit/props";
|
|
5991
|
-
import { applyToPoint as
|
|
6217
|
+
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
5992
6218
|
var PcbNoteLine = class extends PrimitiveComponent2 {
|
|
5993
6219
|
pcb_note_line_id = null;
|
|
5994
6220
|
isPcbPrimitive = true;
|
|
@@ -6005,8 +6231,8 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
|
|
|
6005
6231
|
const subcircuit = this.getSubcircuit();
|
|
6006
6232
|
const group = this.getGroup();
|
|
6007
6233
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
6008
|
-
const start =
|
|
6009
|
-
const end =
|
|
6234
|
+
const start = applyToPoint7(transform, { x: props.x1, y: props.y1 });
|
|
6235
|
+
const end = applyToPoint7(transform, { x: props.x2, y: props.y2 });
|
|
6010
6236
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
|
|
6011
6237
|
const pcb_note_line = db.pcb_note_line.insert({
|
|
6012
6238
|
pcb_component_id,
|
|
@@ -6050,7 +6276,7 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
|
|
|
6050
6276
|
|
|
6051
6277
|
// lib/components/primitive-components/PcbNotePath.ts
|
|
6052
6278
|
import { pcbNotePathProps } from "@tscircuit/props";
|
|
6053
|
-
import { applyToPoint as
|
|
6279
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
6054
6280
|
var PcbNotePath = class extends PrimitiveComponent2 {
|
|
6055
6281
|
pcb_note_path_id = null;
|
|
6056
6282
|
isPcbPrimitive = true;
|
|
@@ -6072,7 +6298,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
|
|
|
6072
6298
|
const { x, y, ...rest } = point6;
|
|
6073
6299
|
const numericX = typeof x === "string" ? parseFloat(x) : x;
|
|
6074
6300
|
const numericY = typeof y === "string" ? parseFloat(y) : y;
|
|
6075
|
-
const transformed =
|
|
6301
|
+
const transformed = applyToPoint8(transform, { x: numericX, y: numericY });
|
|
6076
6302
|
return { ...rest, x: transformed.x, y: transformed.y };
|
|
6077
6303
|
});
|
|
6078
6304
|
const pcb_note_path = db.pcb_note_path.insert({
|
|
@@ -6122,7 +6348,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
|
|
|
6122
6348
|
|
|
6123
6349
|
// lib/components/primitive-components/PcbNoteRect.ts
|
|
6124
6350
|
import { pcbNoteRectProps } from "@tscircuit/props";
|
|
6125
|
-
import { applyToPoint as
|
|
6351
|
+
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
6126
6352
|
var PcbNoteRect = class extends PrimitiveComponent2 {
|
|
6127
6353
|
pcb_note_rect_id = null;
|
|
6128
6354
|
isPcbPrimitive = true;
|
|
@@ -6137,7 +6363,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
|
|
|
6137
6363
|
const { db } = this.root;
|
|
6138
6364
|
const { _parsedProps: props } = this;
|
|
6139
6365
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
6140
|
-
const center =
|
|
6366
|
+
const center = applyToPoint9(transform, { x: 0, y: 0 });
|
|
6141
6367
|
const subcircuit = this.getSubcircuit();
|
|
6142
6368
|
const group = this.getGroup();
|
|
6143
6369
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
|
|
@@ -6184,7 +6410,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
|
|
|
6184
6410
|
|
|
6185
6411
|
// lib/components/primitive-components/PcbNoteText.ts
|
|
6186
6412
|
import { pcbNoteTextProps } from "@tscircuit/props";
|
|
6187
|
-
import { applyToPoint as
|
|
6413
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
6188
6414
|
var PcbNoteText = class extends PrimitiveComponent2 {
|
|
6189
6415
|
pcb_note_text_id = null;
|
|
6190
6416
|
isPcbPrimitive = true;
|
|
@@ -6199,7 +6425,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
|
|
|
6199
6425
|
const { db } = this.root;
|
|
6200
6426
|
const { _parsedProps: props } = this;
|
|
6201
6427
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
6202
|
-
const anchorPosition =
|
|
6428
|
+
const anchorPosition = applyToPoint10(transform, { x: 0, y: 0 });
|
|
6203
6429
|
const subcircuit = this.getSubcircuit();
|
|
6204
6430
|
const group = this.getGroup();
|
|
6205
6431
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? void 0;
|
|
@@ -6246,7 +6472,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
|
|
|
6246
6472
|
// lib/components/primitive-components/PcbTrace.ts
|
|
6247
6473
|
import { z as z6 } from "zod";
|
|
6248
6474
|
import { pcb_trace_route_point } from "circuit-json";
|
|
6249
|
-
import { applyToPoint as
|
|
6475
|
+
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
6250
6476
|
var pcbTraceProps = z6.object({
|
|
6251
6477
|
route: z6.array(pcb_trace_route_point),
|
|
6252
6478
|
// If this primitive PcbTrace needs to be associated with a source_trace_id
|
|
@@ -6272,7 +6498,7 @@ var PcbTrace = class extends PrimitiveComponent2 {
|
|
|
6272
6498
|
const parentTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
6273
6499
|
const transformedRoute = props.route.map((point6) => {
|
|
6274
6500
|
const { x, y, ...restOfPoint } = point6;
|
|
6275
|
-
const transformedPoint =
|
|
6501
|
+
const transformedPoint = applyToPoint11(parentTransform, { x, y });
|
|
6276
6502
|
if (point6.route_type === "wire" && point6.layer) {
|
|
6277
6503
|
return {
|
|
6278
6504
|
...transformedPoint,
|
|
@@ -6702,7 +6928,7 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
|
|
|
6702
6928
|
|
|
6703
6929
|
// lib/components/primitive-components/SilkscreenLine.ts
|
|
6704
6930
|
import { silkscreenLineProps } from "@tscircuit/props";
|
|
6705
|
-
import { applyToPoint as
|
|
6931
|
+
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
6706
6932
|
var SilkscreenLine = class extends PrimitiveComponent2 {
|
|
6707
6933
|
pcb_silkscreen_line_id = null;
|
|
6708
6934
|
isPcbPrimitive = true;
|
|
@@ -6725,8 +6951,8 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
|
|
|
6725
6951
|
}
|
|
6726
6952
|
const subcircuit = this.getSubcircuit();
|
|
6727
6953
|
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
6728
|
-
const p1 =
|
|
6729
|
-
const p2 =
|
|
6954
|
+
const p1 = applyToPoint12(transform, { x: props.x1, y: props.y1 });
|
|
6955
|
+
const p2 = applyToPoint12(transform, { x: props.x2, y: props.y2 });
|
|
6730
6956
|
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
6731
6957
|
const pcb_silkscreen_line = db.pcb_silkscreen_line.insert({
|
|
6732
6958
|
pcb_component_id,
|
|
@@ -6768,7 +6994,7 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
|
|
|
6768
6994
|
|
|
6769
6995
|
// lib/components/primitive-components/SilkscreenPath.ts
|
|
6770
6996
|
import { silkscreenPathProps } from "@tscircuit/props";
|
|
6771
|
-
import { applyToPoint as
|
|
6997
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
6772
6998
|
var SilkscreenPath = class extends PrimitiveComponent2 {
|
|
6773
6999
|
pcb_silkscreen_path_id = null;
|
|
6774
7000
|
isPcbPrimitive = true;
|
|
@@ -6796,7 +7022,7 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
|
|
|
6796
7022
|
pcb_component_id,
|
|
6797
7023
|
layer,
|
|
6798
7024
|
route: props.route.map((p) => {
|
|
6799
|
-
const transformedPosition =
|
|
7025
|
+
const transformedPosition = applyToPoint13(transform, {
|
|
6800
7026
|
x: p.x,
|
|
6801
7027
|
y: p.y
|
|
6802
7028
|
});
|
|
@@ -6961,7 +7187,7 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
|
|
|
6961
7187
|
// lib/components/primitive-components/SilkscreenText.ts
|
|
6962
7188
|
import { silkscreenTextProps } from "@tscircuit/props";
|
|
6963
7189
|
import {
|
|
6964
|
-
applyToPoint as
|
|
7190
|
+
applyToPoint as applyToPoint14,
|
|
6965
7191
|
compose as compose3,
|
|
6966
7192
|
decomposeTSR as decomposeTSR4,
|
|
6967
7193
|
flipY as flipY2,
|
|
@@ -7018,7 +7244,7 @@ var SilkscreenText = class extends PrimitiveComponent2 {
|
|
|
7018
7244
|
});
|
|
7019
7245
|
const fontSize = props.fontSize ?? resolvedPcbSxFontSize ?? this.getInheritedProperty("pcbStyle")?.silkscreenFontSize ?? this._footprinterFontSize ?? 1;
|
|
7020
7246
|
const hasResolvedPcbSxPosition = resolvedPcbSxPcbX !== void 0 || resolvedPcbSxPcbY !== void 0;
|
|
7021
|
-
const position = hasResolvedPcbSxPosition && this._footprinterFontSize !== void 0 ?
|
|
7247
|
+
const position = hasResolvedPcbSxPosition && this._footprinterFontSize !== void 0 ? applyToPoint14(
|
|
7022
7248
|
compose3(
|
|
7023
7249
|
this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity4(),
|
|
7024
7250
|
isFlipped ? flipY2() : identity4()
|
|
@@ -7104,7 +7330,7 @@ import { smtPadProps } from "@tscircuit/props";
|
|
|
7104
7330
|
import {
|
|
7105
7331
|
distance as distance5
|
|
7106
7332
|
} from "circuit-json";
|
|
7107
|
-
import { applyToPoint as
|
|
7333
|
+
import { applyToPoint as applyToPoint15, decomposeTSR as decomposeTSR5 } from "transformation-matrix";
|
|
7108
7334
|
var SmtPad = class extends PrimitiveComponent2 {
|
|
7109
7335
|
pcb_smtpad_id = null;
|
|
7110
7336
|
matchedPort = null;
|
|
@@ -7324,7 +7550,7 @@ var SmtPad = class extends PrimitiveComponent2 {
|
|
|
7324
7550
|
});
|
|
7325
7551
|
} else if (props.shape === "polygon") {
|
|
7326
7552
|
const transformedPoints = props.points.map((point6) => {
|
|
7327
|
-
const transformed =
|
|
7553
|
+
const transformed = applyToPoint15(globalTransform, {
|
|
7328
7554
|
x: distance5.parse(point6.x),
|
|
7329
7555
|
y: distance5.parse(point6.y)
|
|
7330
7556
|
});
|
|
@@ -7909,23 +8135,49 @@ var createComponentsFromCircuitJson = ({
|
|
|
7909
8135
|
isDashed: elm.is_dashed
|
|
7910
8136
|
})
|
|
7911
8137
|
);
|
|
7912
|
-
}
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
8138
|
+
} else if (elm.type === "pcb_courtyard_rect") {
|
|
8139
|
+
components.push(
|
|
8140
|
+
new CourtyardRect({
|
|
8141
|
+
pcbX: elm.center.x,
|
|
8142
|
+
pcbY: elm.center.y,
|
|
8143
|
+
width: elm.width,
|
|
8144
|
+
height: elm.height,
|
|
8145
|
+
layer: elm.layer
|
|
8146
|
+
})
|
|
8147
|
+
);
|
|
8148
|
+
} else if (elm.type === "pcb_courtyard_circle") {
|
|
8149
|
+
components.push(
|
|
8150
|
+
new CourtyardCircle({
|
|
8151
|
+
pcbX: elm.center.x,
|
|
8152
|
+
pcbY: elm.center.y,
|
|
8153
|
+
radius: elm.radius,
|
|
8154
|
+
layer: elm.layer
|
|
8155
|
+
})
|
|
8156
|
+
);
|
|
8157
|
+
} else if (elm.type === "pcb_courtyard_outline") {
|
|
8158
|
+
components.push(
|
|
8159
|
+
new CourtyardOutline({
|
|
8160
|
+
outline: elm.outline,
|
|
8161
|
+
layer: elm.layer
|
|
8162
|
+
})
|
|
8163
|
+
);
|
|
8164
|
+
}
|
|
8165
|
+
}
|
|
8166
|
+
return components;
|
|
8167
|
+
};
|
|
8168
|
+
|
|
8169
|
+
// lib/utils/filterPinLabels.ts
|
|
8170
|
+
import { chipProps } from "@tscircuit/props";
|
|
8171
|
+
function filterPinLabels(pinLabels) {
|
|
8172
|
+
if (!pinLabels)
|
|
8173
|
+
return {
|
|
8174
|
+
validPinLabels: pinLabels,
|
|
8175
|
+
invalidPinLabelsMessages: []
|
|
8176
|
+
};
|
|
8177
|
+
const validPinLabels = {};
|
|
8178
|
+
const invalidPinLabelsMessages = [];
|
|
8179
|
+
for (const [pin, labelOrLabels] of Object.entries(pinLabels)) {
|
|
8180
|
+
const labels = Array.isArray(labelOrLabels) ? labelOrLabels.slice() : [labelOrLabels];
|
|
7929
8181
|
const validLabels = [];
|
|
7930
8182
|
for (const label of labels) {
|
|
7931
8183
|
if (isValidPinLabel(pin, label)) {
|
|
@@ -8041,7 +8293,7 @@ var SCHEMATIC_COMPONENT_OUTLINE_STROKE_WIDTH = 0.12;
|
|
|
8041
8293
|
|
|
8042
8294
|
// lib/components/primitive-components/Port/Port.ts
|
|
8043
8295
|
import "schematic-symbols";
|
|
8044
|
-
import { applyToPoint as
|
|
8296
|
+
import { applyToPoint as applyToPoint16, compose as compose4, translate as translate3 } from "transformation-matrix";
|
|
8045
8297
|
import { z as z7 } from "zod";
|
|
8046
8298
|
|
|
8047
8299
|
// lib/components/primitive-components/Port/areAllPcbPrimitivesOverlapping.ts
|
|
@@ -8265,7 +8517,7 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
8265
8517
|
parentNormalComponent.computeSchematicGlobalTransform(),
|
|
8266
8518
|
translate3(-symbol.center.x, -symbol.center.y)
|
|
8267
8519
|
);
|
|
8268
|
-
return
|
|
8520
|
+
return applyToPoint16(transform, schematicSymbolPortDef);
|
|
8269
8521
|
}
|
|
8270
8522
|
const parentBoxDim = parentNormalComponent?._getSchematicBoxDimensions();
|
|
8271
8523
|
if (parentBoxDim && this.props.pinNumber !== void 0) {
|
|
@@ -8277,7 +8529,7 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
8277
8529
|
`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`
|
|
8278
8530
|
);
|
|
8279
8531
|
}
|
|
8280
|
-
return
|
|
8532
|
+
return applyToPoint16(
|
|
8281
8533
|
parentNormalComponent.computeSchematicGlobalTransform(),
|
|
8282
8534
|
localPortPosition
|
|
8283
8535
|
);
|
|
@@ -8656,15 +8908,15 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
8656
8908
|
const { db } = this.root;
|
|
8657
8909
|
const schPort = db.schematic_port.get(this.schematic_port_id);
|
|
8658
8910
|
if (schPort) {
|
|
8659
|
-
const newCenter =
|
|
8911
|
+
const newCenter = applyToPoint16(transform, schPort.center);
|
|
8660
8912
|
db.schematic_port.update(this.schematic_port_id, {
|
|
8661
8913
|
center: newCenter
|
|
8662
8914
|
});
|
|
8663
8915
|
if (this.schematic_stem_line_id) {
|
|
8664
8916
|
const line = db.schematic_line.get(this.schematic_stem_line_id);
|
|
8665
8917
|
if (line) {
|
|
8666
|
-
const p1 =
|
|
8667
|
-
const p2 =
|
|
8918
|
+
const p1 = applyToPoint16(transform, { x: line.x1, y: line.y1 });
|
|
8919
|
+
const p2 = applyToPoint16(transform, { x: line.x2, y: line.y2 });
|
|
8668
8920
|
db.schematic_line.update(this.schematic_stem_line_id, {
|
|
8669
8921
|
x1: p1.x,
|
|
8670
8922
|
y1: p1.y,
|
|
@@ -9444,7 +9696,7 @@ var Footprint = class extends PrimitiveComponent2 {
|
|
|
9444
9696
|
};
|
|
9445
9697
|
|
|
9446
9698
|
// lib/components/base-components/NormalComponent/NormalComponent__getMinimumFlexContainerSize.ts
|
|
9447
|
-
import { getBoundsFromPoints } from "@tscircuit/math-utils";
|
|
9699
|
+
import { getBoundsFromPoints as getBoundsFromPoints2 } from "@tscircuit/math-utils";
|
|
9448
9700
|
var NormalComponent__getMinimumFlexContainerSize = (component) => {
|
|
9449
9701
|
const { db } = component.root;
|
|
9450
9702
|
if (component.pcb_component_id) {
|
|
@@ -9461,7 +9713,7 @@ var NormalComponent__getMinimumFlexContainerSize = (component) => {
|
|
|
9461
9713
|
);
|
|
9462
9714
|
if (!pcbGroup) return null;
|
|
9463
9715
|
if (pcbGroup.outline && pcbGroup.outline.length > 0) {
|
|
9464
|
-
const bounds =
|
|
9716
|
+
const bounds = getBoundsFromPoints2(pcbGroup.outline);
|
|
9465
9717
|
if (!bounds) return null;
|
|
9466
9718
|
return {
|
|
9467
9719
|
width: bounds.maxX - bounds.minX,
|
|
@@ -11336,7 +11588,7 @@ import {
|
|
|
11336
11588
|
runAllPlacementChecks,
|
|
11337
11589
|
runAllRoutingChecks
|
|
11338
11590
|
} from "@tscircuit/checks";
|
|
11339
|
-
import { getBoundsFromPoints as
|
|
11591
|
+
import { getBoundsFromPoints as getBoundsFromPoints5 } from "@tscircuit/math-utils";
|
|
11340
11592
|
import { boardProps } from "@tscircuit/props";
|
|
11341
11593
|
import { compose as compose7, translate as translate7 } from "transformation-matrix";
|
|
11342
11594
|
|
|
@@ -11932,7 +12184,7 @@ function inflateSourceDiode(sourceElm, inflatorContext) {
|
|
|
11932
12184
|
|
|
11933
12185
|
// lib/components/primitive-components/Group/Group.ts
|
|
11934
12186
|
import { convertSrjToGraphicsObject } from "@tscircuit/capacity-autorouter";
|
|
11935
|
-
import { getBoundsFromPoints as
|
|
12187
|
+
import { getBoundsFromPoints as getBoundsFromPoints4 } from "@tscircuit/math-utils";
|
|
11936
12188
|
import {
|
|
11937
12189
|
groupProps
|
|
11938
12190
|
} from "@tscircuit/props";
|
|
@@ -12951,7 +13203,7 @@ import "zod";
|
|
|
12951
13203
|
|
|
12952
13204
|
// lib/components/primitive-components/TraceHint.ts
|
|
12953
13205
|
import { traceHintProps } from "@tscircuit/props";
|
|
12954
|
-
import { applyToPoint as
|
|
13206
|
+
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
12955
13207
|
var TraceHint = class extends PrimitiveComponent2 {
|
|
12956
13208
|
matchedPort = null;
|
|
12957
13209
|
get config() {
|
|
@@ -12991,7 +13243,7 @@ var TraceHint = class extends PrimitiveComponent2 {
|
|
|
12991
13243
|
const globalTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
12992
13244
|
return offsets.map(
|
|
12993
13245
|
(offset) => ({
|
|
12994
|
-
...
|
|
13246
|
+
...applyToPoint17(globalTransform, offset),
|
|
12995
13247
|
via: offset.via,
|
|
12996
13248
|
to_layer: offset.to_layer,
|
|
12997
13249
|
trace_width: offset.trace_width
|
|
@@ -13351,7 +13603,7 @@ function collectPadElementsByReference(component) {
|
|
|
13351
13603
|
}
|
|
13352
13604
|
|
|
13353
13605
|
// lib/components/primitive-components/Group/Group_doInitialPcbComponentAnchorAlignment.ts
|
|
13354
|
-
import { getBoundsFromPoints as
|
|
13606
|
+
import { getBoundsFromPoints as getBoundsFromPoints3 } from "@tscircuit/math-utils";
|
|
13355
13607
|
function Group_doInitialPcbComponentAnchorAlignment(group) {
|
|
13356
13608
|
if (group.root?.pcbDisabled) return;
|
|
13357
13609
|
if (!group.pcb_group_id) return;
|
|
@@ -13367,7 +13619,7 @@ function Group_doInitialPcbComponentAnchorAlignment(group) {
|
|
|
13367
13619
|
let height = pcbGroup.height;
|
|
13368
13620
|
const { center } = pcbGroup;
|
|
13369
13621
|
if (pcbGroup.outline && pcbGroup.outline.length > 0) {
|
|
13370
|
-
const bounds2 =
|
|
13622
|
+
const bounds2 = getBoundsFromPoints3(pcbGroup.outline);
|
|
13371
13623
|
if (bounds2) {
|
|
13372
13624
|
width = bounds2.maxX - bounds2.minX;
|
|
13373
13625
|
height = bounds2.maxY - bounds2.minY;
|
|
@@ -17008,7 +17260,7 @@ var Group6 = class extends NormalComponent3 {
|
|
|
17008
17260
|
x: distance8.parse(point6.x),
|
|
17009
17261
|
y: distance8.parse(point6.y)
|
|
17010
17262
|
}));
|
|
17011
|
-
const outlineBounds =
|
|
17263
|
+
const outlineBounds = getBoundsFromPoints4(numericOutline);
|
|
17012
17264
|
if (!outlineBounds) return;
|
|
17013
17265
|
const centerX2 = (outlineBounds.minX + outlineBounds.maxX) / 2;
|
|
17014
17266
|
const centerY2 = (outlineBounds.minY + outlineBounds.maxY) / 2;
|
|
@@ -18390,7 +18642,7 @@ import { identity as identity5 } from "transformation-matrix";
|
|
|
18390
18642
|
var package_default = {
|
|
18391
18643
|
name: "@tscircuit/core",
|
|
18392
18644
|
type: "module",
|
|
18393
|
-
version: "0.0.
|
|
18645
|
+
version: "0.0.1110",
|
|
18394
18646
|
types: "dist/index.d.ts",
|
|
18395
18647
|
main: "dist/index.js",
|
|
18396
18648
|
module: "dist/index.js",
|
|
@@ -18432,7 +18684,7 @@ var package_default = {
|
|
|
18432
18684
|
"@tscircuit/infgrid-ijump-astar": "^0.0.35",
|
|
18433
18685
|
"@tscircuit/log-soup": "^1.0.2",
|
|
18434
18686
|
"@tscircuit/matchpack": "^0.0.16",
|
|
18435
|
-
"@tscircuit/math-utils": "^0.0.
|
|
18687
|
+
"@tscircuit/math-utils": "^0.0.36",
|
|
18436
18688
|
"@tscircuit/miniflex": "^0.0.4",
|
|
18437
18689
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
18438
18690
|
"@tscircuit/props": "^0.0.495",
|
|
@@ -18449,13 +18701,13 @@ var package_default = {
|
|
|
18449
18701
|
"bun-match-svg": "0.0.12",
|
|
18450
18702
|
"calculate-elbow": "^0.0.12",
|
|
18451
18703
|
"chokidar-cli": "^3.0.0",
|
|
18452
|
-
"circuit-json": "^0.0.
|
|
18704
|
+
"circuit-json": "^0.0.402",
|
|
18453
18705
|
"circuit-json-to-bpc": "^0.0.13",
|
|
18454
18706
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
18455
18707
|
"circuit-json-to-gltf": "^0.0.73",
|
|
18456
18708
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
18457
18709
|
"circuit-json-to-spice": "^0.0.34",
|
|
18458
|
-
"circuit-to-svg": "^0.0.
|
|
18710
|
+
"circuit-to-svg": "^0.0.336",
|
|
18459
18711
|
concurrently: "^9.1.2",
|
|
18460
18712
|
"connectivity-map": "^1.0.0",
|
|
18461
18713
|
debug: "^4.3.6",
|
|
@@ -19040,7 +19292,7 @@ var Board = class extends Group6 {
|
|
|
19040
19292
|
let width = dbBoard?.width ?? props.width;
|
|
19041
19293
|
let height = dbBoard?.height ?? props.height;
|
|
19042
19294
|
if ((width == null || height == null) && props.outline?.length) {
|
|
19043
|
-
const outlineBounds =
|
|
19295
|
+
const outlineBounds = getBoundsFromPoints5(props.outline);
|
|
19044
19296
|
if (outlineBounds) {
|
|
19045
19297
|
width ??= outlineBounds.maxX - outlineBounds.minX;
|
|
19046
19298
|
height ??= outlineBounds.maxY - outlineBounds.minY;
|
|
@@ -19097,7 +19349,7 @@ var Board = class extends Group6 {
|
|
|
19097
19349
|
let width = pcbGroup.width ?? 0;
|
|
19098
19350
|
let height = pcbGroup.height ?? 0;
|
|
19099
19351
|
if (pcbGroup.outline && pcbGroup.outline.length > 0) {
|
|
19100
|
-
const bounds =
|
|
19352
|
+
const bounds = getBoundsFromPoints5(pcbGroup.outline);
|
|
19101
19353
|
if (bounds) {
|
|
19102
19354
|
width = bounds.maxX - bounds.minX;
|
|
19103
19355
|
height = bounds.maxY - bounds.minY;
|
|
@@ -19269,7 +19521,7 @@ var Board = class extends Group6 {
|
|
|
19269
19521
|
}
|
|
19270
19522
|
let outlineTranslation = { x: 0, y: 0 };
|
|
19271
19523
|
if (outline && outline.length > 0 && (this.parent?.lowercaseComponentName === "panel" || this.parent?.lowercaseComponentName === "subpanel")) {
|
|
19272
|
-
const outlineBounds =
|
|
19524
|
+
const outlineBounds = getBoundsFromPoints5(outline);
|
|
19273
19525
|
if (outlineBounds) {
|
|
19274
19526
|
const outlineCenterX = (outlineBounds.minX + outlineBounds.maxX) / 2;
|
|
19275
19527
|
const outlineCenterY = (outlineBounds.minY + outlineBounds.maxY) / 2;
|
|
@@ -19391,7 +19643,7 @@ var Board = class extends Group6 {
|
|
|
19391
19643
|
if (this.pcb_board_id) {
|
|
19392
19644
|
db.pcb_board.update(this.pcb_board_id, { center: position });
|
|
19393
19645
|
if (pcbBoard?.outline) {
|
|
19394
|
-
const outlineBounds =
|
|
19646
|
+
const outlineBounds = getBoundsFromPoints5(pcbBoard.outline);
|
|
19395
19647
|
if (outlineBounds) {
|
|
19396
19648
|
const oldOutlineCenter = {
|
|
19397
19649
|
x: (outlineBounds.minX + outlineBounds.maxX) / 2,
|
|
@@ -19750,14 +20002,14 @@ function generatePanelTabsAndMouseBites(boards, options) {
|
|
|
19750
20002
|
import { distance as distance10 } from "circuit-json";
|
|
19751
20003
|
|
|
19752
20004
|
// lib/utils/panels/get-board-dimensions-from-props.ts
|
|
19753
|
-
import { getBoundsFromPoints as
|
|
20005
|
+
import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
|
|
19754
20006
|
import { distance as distance9 } from "circuit-json";
|
|
19755
20007
|
var getBoardDimensionsFromProps = (board) => {
|
|
19756
20008
|
const props = board._parsedProps;
|
|
19757
20009
|
let width = props.width != null ? distance9.parse(props.width) : void 0;
|
|
19758
20010
|
let height = props.height != null ? distance9.parse(props.height) : void 0;
|
|
19759
20011
|
if ((width === void 0 || height === void 0) && props.outline?.length) {
|
|
19760
|
-
const outlineBounds =
|
|
20012
|
+
const outlineBounds = getBoundsFromPoints6(props.outline);
|
|
19761
20013
|
if (outlineBounds) {
|
|
19762
20014
|
width ??= outlineBounds.maxX - outlineBounds.minX;
|
|
19763
20015
|
height ??= outlineBounds.maxY - outlineBounds.minY;
|
|
@@ -21071,7 +21323,7 @@ var Constraint3 = class extends PrimitiveComponent2 {
|
|
|
21071
21323
|
|
|
21072
21324
|
// lib/components/primitive-components/FabricationNoteDimension.ts
|
|
21073
21325
|
import { fabricationNoteDimensionProps } from "@tscircuit/props";
|
|
21074
|
-
import { applyToPoint as
|
|
21326
|
+
import { applyToPoint as applyToPoint18 } from "transformation-matrix";
|
|
21075
21327
|
var FabricationNoteDimension = class extends PrimitiveComponent2 {
|
|
21076
21328
|
fabrication_note_dimension_id = null;
|
|
21077
21329
|
isPcbPrimitive = true;
|
|
@@ -21090,13 +21342,13 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
|
|
|
21090
21342
|
this.renderError(
|
|
21091
21343
|
`FabricationNoteDimension could not find selector "${input}"`
|
|
21092
21344
|
);
|
|
21093
|
-
return
|
|
21345
|
+
return applyToPoint18(transform, { x: 0, y: 0 });
|
|
21094
21346
|
}
|
|
21095
21347
|
return target._getGlobalPcbPositionBeforeLayout();
|
|
21096
21348
|
}
|
|
21097
21349
|
const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
|
|
21098
21350
|
const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
|
|
21099
|
-
return
|
|
21351
|
+
return applyToPoint18(transform, { x: numericX, y: numericY });
|
|
21100
21352
|
}
|
|
21101
21353
|
doInitialPcbPrimitiveRender() {
|
|
21102
21354
|
if (this.root?.pcbDisabled) return;
|
|
@@ -21191,7 +21443,7 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
|
|
|
21191
21443
|
|
|
21192
21444
|
// lib/components/primitive-components/PcbNoteDimension.ts
|
|
21193
21445
|
import { pcbNoteDimensionProps } from "@tscircuit/props";
|
|
21194
|
-
import { applyToPoint as
|
|
21446
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
21195
21447
|
var PcbNoteDimension = class extends PrimitiveComponent2 {
|
|
21196
21448
|
pcb_note_dimension_id = null;
|
|
21197
21449
|
isPcbPrimitive = true;
|
|
@@ -21208,7 +21460,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
|
|
|
21208
21460
|
);
|
|
21209
21461
|
if (!target) {
|
|
21210
21462
|
this.renderError(`PcbNoteDimension could not find selector "${input}"`);
|
|
21211
|
-
return
|
|
21463
|
+
return applyToPoint19(transform, { x: 0, y: 0 });
|
|
21212
21464
|
}
|
|
21213
21465
|
const targetPcbComponentId = target.pcb_component_id;
|
|
21214
21466
|
const root = this.root;
|
|
@@ -21225,7 +21477,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
|
|
|
21225
21477
|
}
|
|
21226
21478
|
const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
|
|
21227
21479
|
const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
|
|
21228
|
-
return
|
|
21480
|
+
return applyToPoint19(transform, { x: numericX, y: numericY });
|
|
21229
21481
|
}
|
|
21230
21482
|
doInitialPcbPrimitiveRender() {
|
|
21231
21483
|
if (this.root?.pcbDisabled) return;
|
|
@@ -21448,7 +21700,7 @@ var BreakoutPoint = class extends PrimitiveComponent2 {
|
|
|
21448
21700
|
// lib/components/primitive-components/NetLabel.ts
|
|
21449
21701
|
import { netLabelProps } from "@tscircuit/props";
|
|
21450
21702
|
import {
|
|
21451
|
-
applyToPoint as
|
|
21703
|
+
applyToPoint as applyToPoint20,
|
|
21452
21704
|
identity as identity7,
|
|
21453
21705
|
translate as translate9
|
|
21454
21706
|
} from "transformation-matrix";
|
|
@@ -21499,7 +21751,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
21499
21751
|
const connectedPorts = this._getConnectedPorts();
|
|
21500
21752
|
if (connectedPorts.length > 0) {
|
|
21501
21753
|
const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
|
|
21502
|
-
const parentCenter =
|
|
21754
|
+
const parentCenter = applyToPoint20(
|
|
21503
21755
|
this.parent?.computeSchematicGlobalTransform?.() ?? identity7(),
|
|
21504
21756
|
{ x: 0, y: 0 }
|
|
21505
21757
|
);
|
|
@@ -21644,232 +21896,6 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
21644
21896
|
}
|
|
21645
21897
|
};
|
|
21646
21898
|
|
|
21647
|
-
// lib/components/primitive-components/CourtyardCircle.ts
|
|
21648
|
-
import { courtyardCircleProps } from "@tscircuit/props";
|
|
21649
|
-
var CourtyardCircle = class extends PrimitiveComponent2 {
|
|
21650
|
-
pcb_courtyard_circle_id = null;
|
|
21651
|
-
isPcbPrimitive = true;
|
|
21652
|
-
get config() {
|
|
21653
|
-
return {
|
|
21654
|
-
componentName: "CourtyardCircle",
|
|
21655
|
-
zodProps: courtyardCircleProps
|
|
21656
|
-
};
|
|
21657
|
-
}
|
|
21658
|
-
doInitialPcbPrimitiveRender() {
|
|
21659
|
-
if (this.root?.pcbDisabled) return;
|
|
21660
|
-
const { db } = this.root;
|
|
21661
|
-
const { _parsedProps: props } = this;
|
|
21662
|
-
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
21663
|
-
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
21664
|
-
const layer = maybeFlipLayer(props.layer ?? "top");
|
|
21665
|
-
if (layer !== "top" && layer !== "bottom") {
|
|
21666
|
-
throw new Error(
|
|
21667
|
-
`Invalid layer "${layer}" for CourtyardCircle. Must be "top" or "bottom".`
|
|
21668
|
-
);
|
|
21669
|
-
}
|
|
21670
|
-
const subcircuit = this.getSubcircuit();
|
|
21671
|
-
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
21672
|
-
const pcb_courtyard_circle = db.pcb_courtyard_circle.insert({
|
|
21673
|
-
pcb_component_id,
|
|
21674
|
-
layer,
|
|
21675
|
-
center: {
|
|
21676
|
-
x: position.x,
|
|
21677
|
-
y: position.y
|
|
21678
|
-
},
|
|
21679
|
-
radius: props.radius,
|
|
21680
|
-
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
21681
|
-
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
21682
|
-
});
|
|
21683
|
-
this.pcb_courtyard_circle_id = pcb_courtyard_circle.pcb_courtyard_circle_id;
|
|
21684
|
-
}
|
|
21685
|
-
getPcbSize() {
|
|
21686
|
-
const { _parsedProps: props } = this;
|
|
21687
|
-
const diameter = props.radius * 2;
|
|
21688
|
-
return { width: diameter, height: diameter };
|
|
21689
|
-
}
|
|
21690
|
-
_moveCircuitJsonElements({
|
|
21691
|
-
deltaX,
|
|
21692
|
-
deltaY
|
|
21693
|
-
}) {
|
|
21694
|
-
if (this.root?.pcbDisabled) return;
|
|
21695
|
-
const { db } = this.root;
|
|
21696
|
-
if (!this.pcb_courtyard_circle_id) return;
|
|
21697
|
-
const circle = db.pcb_courtyard_circle.get(this.pcb_courtyard_circle_id);
|
|
21698
|
-
if (circle) {
|
|
21699
|
-
db.pcb_courtyard_circle.update(this.pcb_courtyard_circle_id, {
|
|
21700
|
-
center: {
|
|
21701
|
-
x: circle.center.x + deltaX,
|
|
21702
|
-
y: circle.center.y + deltaY
|
|
21703
|
-
}
|
|
21704
|
-
});
|
|
21705
|
-
}
|
|
21706
|
-
}
|
|
21707
|
-
};
|
|
21708
|
-
|
|
21709
|
-
// lib/components/primitive-components/CourtyardOutline.ts
|
|
21710
|
-
import { courtyardOutlineProps } from "@tscircuit/props";
|
|
21711
|
-
import { getBoundsFromPoints as getBoundsFromPoints6 } from "@tscircuit/math-utils";
|
|
21712
|
-
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
21713
|
-
var CourtyardOutline = class extends PrimitiveComponent2 {
|
|
21714
|
-
pcb_courtyard_outline_id = null;
|
|
21715
|
-
isPcbPrimitive = true;
|
|
21716
|
-
get config() {
|
|
21717
|
-
return {
|
|
21718
|
-
componentName: "CourtyardOutline",
|
|
21719
|
-
zodProps: courtyardOutlineProps
|
|
21720
|
-
};
|
|
21721
|
-
}
|
|
21722
|
-
doInitialPcbPrimitiveRender() {
|
|
21723
|
-
if (this.root?.pcbDisabled) return;
|
|
21724
|
-
const { db } = this.root;
|
|
21725
|
-
const { _parsedProps: props } = this;
|
|
21726
|
-
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
21727
|
-
const layer = maybeFlipLayer(props.layer ?? "top");
|
|
21728
|
-
if (layer !== "top" && layer !== "bottom") {
|
|
21729
|
-
throw new Error(
|
|
21730
|
-
`Invalid layer "${layer}" for CourtyardOutline. Must be "top" or "bottom".`
|
|
21731
|
-
);
|
|
21732
|
-
}
|
|
21733
|
-
const transform = this._computePcbGlobalTransformBeforeLayout();
|
|
21734
|
-
const subcircuit = this.getSubcircuit();
|
|
21735
|
-
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
21736
|
-
const pcb_courtyard_outline = db.pcb_courtyard_outline.insert({
|
|
21737
|
-
pcb_component_id,
|
|
21738
|
-
layer,
|
|
21739
|
-
outline: props.outline.map((p) => {
|
|
21740
|
-
const transformedPosition = applyToPoint20(transform, {
|
|
21741
|
-
x: p.x,
|
|
21742
|
-
y: p.y
|
|
21743
|
-
});
|
|
21744
|
-
return {
|
|
21745
|
-
x: transformedPosition.x,
|
|
21746
|
-
y: transformedPosition.y
|
|
21747
|
-
};
|
|
21748
|
-
}),
|
|
21749
|
-
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
21750
|
-
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
21751
|
-
});
|
|
21752
|
-
this.pcb_courtyard_outline_id = pcb_courtyard_outline.pcb_courtyard_outline_id;
|
|
21753
|
-
}
|
|
21754
|
-
_setPositionFromLayout(newCenter) {
|
|
21755
|
-
const { db } = this.root;
|
|
21756
|
-
const currentOutline = db.pcb_courtyard_outline.get(
|
|
21757
|
-
this.pcb_courtyard_outline_id
|
|
21758
|
-
);
|
|
21759
|
-
if (!currentOutline) return;
|
|
21760
|
-
let currentCenterX = 0;
|
|
21761
|
-
let currentCenterY = 0;
|
|
21762
|
-
for (const point6 of currentOutline.outline) {
|
|
21763
|
-
currentCenterX += point6.x;
|
|
21764
|
-
currentCenterY += point6.y;
|
|
21765
|
-
}
|
|
21766
|
-
currentCenterX /= currentOutline.outline.length;
|
|
21767
|
-
currentCenterY /= currentOutline.outline.length;
|
|
21768
|
-
const offsetX = newCenter.x - currentCenterX;
|
|
21769
|
-
const offsetY = newCenter.y - currentCenterY;
|
|
21770
|
-
const newOutline = currentOutline.outline.map((point6) => ({
|
|
21771
|
-
x: point6.x + offsetX,
|
|
21772
|
-
y: point6.y + offsetY
|
|
21773
|
-
}));
|
|
21774
|
-
db.pcb_courtyard_outline.update(this.pcb_courtyard_outline_id, {
|
|
21775
|
-
outline: newOutline
|
|
21776
|
-
});
|
|
21777
|
-
}
|
|
21778
|
-
_moveCircuitJsonElements({
|
|
21779
|
-
deltaX,
|
|
21780
|
-
deltaY
|
|
21781
|
-
}) {
|
|
21782
|
-
if (this.root?.pcbDisabled) return;
|
|
21783
|
-
const { db } = this.root;
|
|
21784
|
-
if (!this.pcb_courtyard_outline_id) return;
|
|
21785
|
-
const outline = db.pcb_courtyard_outline.get(this.pcb_courtyard_outline_id);
|
|
21786
|
-
if (outline) {
|
|
21787
|
-
db.pcb_courtyard_outline.update(this.pcb_courtyard_outline_id, {
|
|
21788
|
-
outline: outline.outline.map((p) => ({
|
|
21789
|
-
x: p.x + deltaX,
|
|
21790
|
-
y: p.y + deltaY
|
|
21791
|
-
}))
|
|
21792
|
-
});
|
|
21793
|
-
}
|
|
21794
|
-
}
|
|
21795
|
-
getPcbSize() {
|
|
21796
|
-
const { _parsedProps: props } = this;
|
|
21797
|
-
if (!props.outline || props.outline.length === 0) {
|
|
21798
|
-
return { width: 0, height: 0 };
|
|
21799
|
-
}
|
|
21800
|
-
const bounds = getBoundsFromPoints6(props.outline);
|
|
21801
|
-
if (!bounds) {
|
|
21802
|
-
return { width: 0, height: 0 };
|
|
21803
|
-
}
|
|
21804
|
-
return {
|
|
21805
|
-
width: bounds.maxX - bounds.minX,
|
|
21806
|
-
height: bounds.maxY - bounds.minY
|
|
21807
|
-
};
|
|
21808
|
-
}
|
|
21809
|
-
};
|
|
21810
|
-
|
|
21811
|
-
// lib/components/primitive-components/CourtyardRect.ts
|
|
21812
|
-
import { courtyardRectProps } from "@tscircuit/props";
|
|
21813
|
-
var CourtyardRect = class extends PrimitiveComponent2 {
|
|
21814
|
-
pcb_courtyard_rect_id = null;
|
|
21815
|
-
isPcbPrimitive = true;
|
|
21816
|
-
get config() {
|
|
21817
|
-
return {
|
|
21818
|
-
componentName: "CourtyardRect",
|
|
21819
|
-
zodProps: courtyardRectProps
|
|
21820
|
-
};
|
|
21821
|
-
}
|
|
21822
|
-
doInitialPcbPrimitiveRender() {
|
|
21823
|
-
if (this.root?.pcbDisabled) return;
|
|
21824
|
-
const { db } = this.root;
|
|
21825
|
-
const { _parsedProps: props } = this;
|
|
21826
|
-
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
21827
|
-
const { maybeFlipLayer } = this._getPcbPrimitiveFlippedHelpers();
|
|
21828
|
-
const layer = maybeFlipLayer(props.layer ?? "top");
|
|
21829
|
-
if (layer !== "top" && layer !== "bottom") {
|
|
21830
|
-
throw new Error(
|
|
21831
|
-
`Invalid layer "${layer}" for CourtyardRect. Must be "top" or "bottom".`
|
|
21832
|
-
);
|
|
21833
|
-
}
|
|
21834
|
-
const subcircuit = this.getSubcircuit();
|
|
21835
|
-
const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
|
|
21836
|
-
const pcb_courtyard_rect = db.pcb_courtyard_rect.insert({
|
|
21837
|
-
pcb_component_id,
|
|
21838
|
-
layer,
|
|
21839
|
-
center: {
|
|
21840
|
-
x: position.x,
|
|
21841
|
-
y: position.y
|
|
21842
|
-
},
|
|
21843
|
-
width: props.width,
|
|
21844
|
-
height: props.height,
|
|
21845
|
-
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
21846
|
-
pcb_group_id: this.getGroup()?.pcb_group_id ?? void 0
|
|
21847
|
-
});
|
|
21848
|
-
this.pcb_courtyard_rect_id = pcb_courtyard_rect.pcb_courtyard_rect_id;
|
|
21849
|
-
}
|
|
21850
|
-
getPcbSize() {
|
|
21851
|
-
const { _parsedProps: props } = this;
|
|
21852
|
-
return { width: props.width, height: props.height };
|
|
21853
|
-
}
|
|
21854
|
-
_moveCircuitJsonElements({
|
|
21855
|
-
deltaX,
|
|
21856
|
-
deltaY
|
|
21857
|
-
}) {
|
|
21858
|
-
if (this.root?.pcbDisabled) return;
|
|
21859
|
-
const { db } = this.root;
|
|
21860
|
-
if (!this.pcb_courtyard_rect_id) return;
|
|
21861
|
-
const rect = db.pcb_courtyard_rect.get(this.pcb_courtyard_rect_id);
|
|
21862
|
-
if (rect) {
|
|
21863
|
-
db.pcb_courtyard_rect.update(this.pcb_courtyard_rect_id, {
|
|
21864
|
-
center: {
|
|
21865
|
-
x: rect.center.x + deltaX,
|
|
21866
|
-
y: rect.center.y + deltaY
|
|
21867
|
-
}
|
|
21868
|
-
});
|
|
21869
|
-
}
|
|
21870
|
-
}
|
|
21871
|
-
};
|
|
21872
|
-
|
|
21873
21899
|
// lib/components/primitive-components/Fiducial.ts
|
|
21874
21900
|
import "zod";
|
|
21875
21901
|
import { distance as distance13 } from "circuit-json";
|
|
@@ -22101,6 +22127,131 @@ import {
|
|
|
22101
22127
|
convertCircuitJsonToInputProblem
|
|
22102
22128
|
} from "@tscircuit/copper-pour-solver";
|
|
22103
22129
|
import { getFullConnectivityMapFromCircuitJson as getFullConnectivityMapFromCircuitJson4 } from "circuit-json-to-connectivity-map";
|
|
22130
|
+
|
|
22131
|
+
// lib/components/primitive-components/CopperPour/utils/mark-trace-segments-inside-copper-pour.ts
|
|
22132
|
+
var EPSILON = 1e-9;
|
|
22133
|
+
var isWireRoutePoint = (routePoint) => routePoint.route_type === "wire";
|
|
22134
|
+
var isPointOnSegment = (p, a, b) => {
|
|
22135
|
+
const cross2 = (p.y - a.y) * (b.x - a.x) - (p.x - a.x) * (b.y - a.y);
|
|
22136
|
+
if (Math.abs(cross2) > EPSILON) return false;
|
|
22137
|
+
const dot = (p.x - a.x) * (b.x - a.x) + (p.y - a.y) * (b.y - a.y);
|
|
22138
|
+
if (dot < -EPSILON) return false;
|
|
22139
|
+
const squaredLength = (b.x - a.x) ** 2 + (b.y - a.y) ** 2;
|
|
22140
|
+
if (dot - squaredLength > EPSILON) return false;
|
|
22141
|
+
return true;
|
|
22142
|
+
};
|
|
22143
|
+
var isPointInRing = (point6, ring) => {
|
|
22144
|
+
if (ring.length < 3) return false;
|
|
22145
|
+
let inside = false;
|
|
22146
|
+
let previous = ring[ring.length - 1];
|
|
22147
|
+
for (const current of ring) {
|
|
22148
|
+
if (isPointOnSegment(point6, previous, current)) return true;
|
|
22149
|
+
const intersects = current.y > point6.y !== previous.y > point6.y && point6.x < (previous.x - current.x) * (point6.y - current.y) / (previous.y - current.y) + current.x;
|
|
22150
|
+
if (intersects) inside = !inside;
|
|
22151
|
+
previous = current;
|
|
22152
|
+
}
|
|
22153
|
+
return inside;
|
|
22154
|
+
};
|
|
22155
|
+
var isPointInRectPour = (p, pour) => {
|
|
22156
|
+
const { center, width, height } = pour;
|
|
22157
|
+
const rotationRad = (pour.rotation ?? 0) * Math.PI / 180;
|
|
22158
|
+
const cosR = Math.cos(-rotationRad);
|
|
22159
|
+
const sinR = Math.sin(-rotationRad);
|
|
22160
|
+
const dx = p.x - center.x;
|
|
22161
|
+
const dy = p.y - center.y;
|
|
22162
|
+
const localX = dx * cosR - dy * sinR;
|
|
22163
|
+
const localY = dx * sinR + dy * cosR;
|
|
22164
|
+
return Math.abs(localX) <= width / 2 + EPSILON && Math.abs(localY) <= height / 2 + EPSILON;
|
|
22165
|
+
};
|
|
22166
|
+
var isPointInBrepPour = (p, pour) => {
|
|
22167
|
+
const outerRing = pour.brep_shape.outer_ring.vertices.map((v) => ({
|
|
22168
|
+
x: v.x,
|
|
22169
|
+
y: v.y
|
|
22170
|
+
}));
|
|
22171
|
+
if (!isPointInRing(p, outerRing)) return false;
|
|
22172
|
+
for (const innerRing of pour.brep_shape.inner_rings) {
|
|
22173
|
+
const points = innerRing.vertices.map((v) => ({ x: v.x, y: v.y }));
|
|
22174
|
+
if (isPointInRing(p, points)) return false;
|
|
22175
|
+
}
|
|
22176
|
+
return true;
|
|
22177
|
+
};
|
|
22178
|
+
var isPointInCopperPour = (point6, pour) => {
|
|
22179
|
+
if (pour.shape === "rect") {
|
|
22180
|
+
return isPointInRectPour(point6, pour);
|
|
22181
|
+
}
|
|
22182
|
+
if (pour.shape === "brep") {
|
|
22183
|
+
return isPointInBrepPour(point6, pour);
|
|
22184
|
+
}
|
|
22185
|
+
return false;
|
|
22186
|
+
};
|
|
22187
|
+
var isTraceConnectedToSourceNet = (trace, sourceNetId, sourceTraceById) => {
|
|
22188
|
+
if (trace.source_trace_id === sourceNetId) return true;
|
|
22189
|
+
if (!trace.source_trace_id) return false;
|
|
22190
|
+
const sourceTrace = sourceTraceById.get(trace.source_trace_id);
|
|
22191
|
+
if (!sourceTrace) return false;
|
|
22192
|
+
return sourceTrace.connected_source_net_ids.includes(sourceNetId);
|
|
22193
|
+
};
|
|
22194
|
+
var isSegmentFullyInsideCopperPour = (start, end, pour) => {
|
|
22195
|
+
const dx = end.x - start.x;
|
|
22196
|
+
const dy = end.y - start.y;
|
|
22197
|
+
const length7 = Math.hypot(dx, dy);
|
|
22198
|
+
if (length7 <= EPSILON) return false;
|
|
22199
|
+
const samples = [0, 0.25, 0.5, 0.75, 1];
|
|
22200
|
+
return samples.every(
|
|
22201
|
+
(t) => isPointInCopperPour(
|
|
22202
|
+
{
|
|
22203
|
+
x: start.x + dx * t,
|
|
22204
|
+
y: start.y + dy * t
|
|
22205
|
+
},
|
|
22206
|
+
pour
|
|
22207
|
+
)
|
|
22208
|
+
);
|
|
22209
|
+
};
|
|
22210
|
+
var markTraceSegmentsInsideCopperPour = ({
|
|
22211
|
+
db,
|
|
22212
|
+
copperPour
|
|
22213
|
+
}) => {
|
|
22214
|
+
if (!copperPour.source_net_id) return;
|
|
22215
|
+
const sourceTraceById = new Map(
|
|
22216
|
+
db.source_trace.list().map((sourceTrace) => [sourceTrace.source_trace_id, sourceTrace])
|
|
22217
|
+
);
|
|
22218
|
+
for (const trace of db.pcb_trace.list()) {
|
|
22219
|
+
if (!isTraceConnectedToSourceNet(
|
|
22220
|
+
trace,
|
|
22221
|
+
copperPour.source_net_id,
|
|
22222
|
+
sourceTraceById
|
|
22223
|
+
)) {
|
|
22224
|
+
continue;
|
|
22225
|
+
}
|
|
22226
|
+
let routeChanged = false;
|
|
22227
|
+
const nextRoute = trace.route.map((routePoint) => ({ ...routePoint }));
|
|
22228
|
+
for (let i = 0; i < nextRoute.length - 1; i++) {
|
|
22229
|
+
const fromRoutePoint = nextRoute[i];
|
|
22230
|
+
const toRoutePoint = nextRoute[i + 1];
|
|
22231
|
+
if (!fromRoutePoint || !toRoutePoint) continue;
|
|
22232
|
+
if (!isWireRoutePoint(fromRoutePoint) || !isWireRoutePoint(toRoutePoint))
|
|
22233
|
+
continue;
|
|
22234
|
+
if (fromRoutePoint.layer !== copperPour.layer || toRoutePoint.layer !== copperPour.layer)
|
|
22235
|
+
continue;
|
|
22236
|
+
if (isSegmentFullyInsideCopperPour(
|
|
22237
|
+
{ x: fromRoutePoint.x, y: fromRoutePoint.y },
|
|
22238
|
+
{ x: toRoutePoint.x, y: toRoutePoint.y },
|
|
22239
|
+
copperPour
|
|
22240
|
+
)) {
|
|
22241
|
+
fromRoutePoint.is_inside_copper_pour = true;
|
|
22242
|
+
fromRoutePoint.copper_pour_id = copperPour.pcb_copper_pour_id;
|
|
22243
|
+
toRoutePoint.is_inside_copper_pour = true;
|
|
22244
|
+
toRoutePoint.copper_pour_id = copperPour.pcb_copper_pour_id;
|
|
22245
|
+
routeChanged = true;
|
|
22246
|
+
}
|
|
22247
|
+
}
|
|
22248
|
+
if (routeChanged) {
|
|
22249
|
+
db.pcb_trace.update(trace.pcb_trace_id, { route: nextRoute });
|
|
22250
|
+
}
|
|
22251
|
+
}
|
|
22252
|
+
};
|
|
22253
|
+
|
|
22254
|
+
// lib/components/primitive-components/CopperPour/CopperPour.ts
|
|
22104
22255
|
var CopperPour = class extends PrimitiveComponent2 {
|
|
22105
22256
|
isPcbPrimitive = true;
|
|
22106
22257
|
get config() {
|
|
@@ -22153,7 +22304,7 @@ var CopperPour = class extends PrimitiveComponent2 {
|
|
|
22153
22304
|
const { brep_shapes } = solver.getOutput();
|
|
22154
22305
|
const coveredWithSolderMask = props.coveredWithSolderMask ?? false;
|
|
22155
22306
|
for (const brep_shape of brep_shapes) {
|
|
22156
|
-
db.pcb_copper_pour.insert({
|
|
22307
|
+
const insertedPour = db.pcb_copper_pour.insert({
|
|
22157
22308
|
shape: "brep",
|
|
22158
22309
|
layer: props.layer,
|
|
22159
22310
|
brep_shape,
|
|
@@ -22161,6 +22312,10 @@ var CopperPour = class extends PrimitiveComponent2 {
|
|
|
22161
22312
|
subcircuit_id: subcircuit?.subcircuit_id ?? void 0,
|
|
22162
22313
|
covered_with_solder_mask: coveredWithSolderMask
|
|
22163
22314
|
});
|
|
22315
|
+
markTraceSegmentsInsideCopperPour({
|
|
22316
|
+
db,
|
|
22317
|
+
copperPour: insertedPour
|
|
22318
|
+
});
|
|
22164
22319
|
}
|
|
22165
22320
|
});
|
|
22166
22321
|
}
|
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.1111",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@tscircuit/infgrid-ijump-astar": "^0.0.35",
|
|
44
44
|
"@tscircuit/log-soup": "^1.0.2",
|
|
45
45
|
"@tscircuit/matchpack": "^0.0.16",
|
|
46
|
-
"@tscircuit/math-utils": "^0.0.
|
|
46
|
+
"@tscircuit/math-utils": "^0.0.36",
|
|
47
47
|
"@tscircuit/miniflex": "^0.0.4",
|
|
48
48
|
"@tscircuit/ngspice-spice-engine": "^0.0.8",
|
|
49
49
|
"@tscircuit/props": "^0.0.495",
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"bun-match-svg": "0.0.12",
|
|
61
61
|
"calculate-elbow": "^0.0.12",
|
|
62
62
|
"chokidar-cli": "^3.0.0",
|
|
63
|
-
"circuit-json": "^0.0.
|
|
63
|
+
"circuit-json": "^0.0.402",
|
|
64
64
|
"circuit-json-to-bpc": "^0.0.13",
|
|
65
65
|
"circuit-json-to-connectivity-map": "^0.0.23",
|
|
66
66
|
"circuit-json-to-gltf": "^0.0.73",
|
|
67
67
|
"circuit-json-to-simple-3d": "^0.0.9",
|
|
68
68
|
"circuit-json-to-spice": "^0.0.34",
|
|
69
|
-
"circuit-to-svg": "^0.0.
|
|
69
|
+
"circuit-to-svg": "^0.0.336",
|
|
70
70
|
"concurrently": "^9.1.2",
|
|
71
71
|
"connectivity-map": "^1.0.0",
|
|
72
72
|
"debug": "^4.3.6",
|