@tscircuit/core 0.0.44 → 0.0.45
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 +77 -2
- package/dist/index.js +71 -1
- package/lib/components/index.ts +1 -0
- package/lib/components/primitive-components/Keepout.ts +58 -0
- package/lib/components/primitive-components/Trace.ts +2 -1
- package/lib/fiber/intrinsic-jsx.ts +1 -0
- package/lib/utils/createComponentsFromSoup.ts +20 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ReactElement } from 'react';
|
|
|
6
6
|
import { Matrix } from 'transformation-matrix';
|
|
7
7
|
import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
|
|
8
8
|
import * as Props from '@tscircuit/props';
|
|
9
|
-
import { traceProps, groupProps, boardProps, footprintProps, smtPadProps, resistorProps, ledProps, diodeProps, capacitorProps, traceHintProps, chipProps, jumperProps, silkscreenPathProps, platedHoleProps, constraintProps, holeProps, silkscreenTextProps } from '@tscircuit/props';
|
|
9
|
+
import { traceProps, groupProps, boardProps, footprintProps, smtPadProps, resistorProps, ledProps, diodeProps, capacitorProps, traceHintProps, chipProps, jumperProps, silkscreenPathProps, platedHoleProps, constraintProps, holeProps, silkscreenTextProps, pcbKeepoutProps } from '@tscircuit/props';
|
|
10
10
|
|
|
11
11
|
declare class Circuit {
|
|
12
12
|
firstChild: PrimitiveComponent | null;
|
|
@@ -4029,6 +4029,80 @@ declare class SilkscreenText extends PrimitiveComponent<typeof silkscreenTextPro
|
|
|
4029
4029
|
doInitialPcbPrimitiveRender(): void;
|
|
4030
4030
|
}
|
|
4031
4031
|
|
|
4032
|
+
declare class Keepout extends PrimitiveComponent<typeof pcbKeepoutProps> {
|
|
4033
|
+
pcb_keepout_id: string | null;
|
|
4034
|
+
isPcbPrimitive: boolean;
|
|
4035
|
+
get config(): {
|
|
4036
|
+
zodProps: zod.ZodUnion<[zod.ZodObject<zod.objectUtil.extendShape<Omit<{
|
|
4037
|
+
pcbX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
4038
|
+
pcbY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
4039
|
+
pcbRotation: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
4040
|
+
layer: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>, zod.ZodObject<{
|
|
4041
|
+
name: zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>;
|
|
4042
|
+
}, "strip", zod.ZodTypeAny, {
|
|
4043
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4044
|
+
}, {
|
|
4045
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4046
|
+
}>]>, "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6", "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
4047
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4048
|
+
}>>;
|
|
4049
|
+
}, "pcbRotation">, {
|
|
4050
|
+
shape: zod.ZodLiteral<"circle">;
|
|
4051
|
+
radius: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
|
|
4052
|
+
}>, "strip", zod.ZodTypeAny, {
|
|
4053
|
+
shape: "circle";
|
|
4054
|
+
radius: number;
|
|
4055
|
+
pcbX?: number | undefined;
|
|
4056
|
+
pcbY?: number | undefined;
|
|
4057
|
+
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
4058
|
+
}, {
|
|
4059
|
+
shape: "circle";
|
|
4060
|
+
radius: string | number;
|
|
4061
|
+
pcbX?: string | number | undefined;
|
|
4062
|
+
pcbY?: string | number | undefined;
|
|
4063
|
+
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
4064
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4065
|
+
} | undefined;
|
|
4066
|
+
}>, zod.ZodObject<zod.objectUtil.extendShape<{
|
|
4067
|
+
pcbX: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
4068
|
+
pcbY: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
4069
|
+
pcbRotation: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>>;
|
|
4070
|
+
layer: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>, zod.ZodObject<{
|
|
4071
|
+
name: zod.ZodEnum<["top", "bottom", "inner1", "inner2", "inner3", "inner4", "inner5", "inner6"]>;
|
|
4072
|
+
}, "strip", zod.ZodTypeAny, {
|
|
4073
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4074
|
+
}, {
|
|
4075
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4076
|
+
}>]>, "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6", "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
4077
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4078
|
+
}>>;
|
|
4079
|
+
}, {
|
|
4080
|
+
shape: zod.ZodLiteral<"rect">;
|
|
4081
|
+
width: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
|
|
4082
|
+
height: zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodNumber]>, number, string | number>;
|
|
4083
|
+
}>, "strip", zod.ZodTypeAny, {
|
|
4084
|
+
shape: "rect";
|
|
4085
|
+
width: number;
|
|
4086
|
+
height: number;
|
|
4087
|
+
pcbX?: number | undefined;
|
|
4088
|
+
pcbY?: number | undefined;
|
|
4089
|
+
pcbRotation?: number | undefined;
|
|
4090
|
+
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | undefined;
|
|
4091
|
+
}, {
|
|
4092
|
+
shape: "rect";
|
|
4093
|
+
width: string | number;
|
|
4094
|
+
height: string | number;
|
|
4095
|
+
pcbX?: string | number | undefined;
|
|
4096
|
+
pcbY?: string | number | undefined;
|
|
4097
|
+
pcbRotation?: string | number | undefined;
|
|
4098
|
+
layer?: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6" | {
|
|
4099
|
+
name: "top" | "bottom" | "inner1" | "inner2" | "inner3" | "inner4" | "inner5" | "inner6";
|
|
4100
|
+
} | undefined;
|
|
4101
|
+
}>]>;
|
|
4102
|
+
};
|
|
4103
|
+
doInitialPcbPrimitiveRender(): void;
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4032
4106
|
declare global {
|
|
4033
4107
|
namespace JSX {
|
|
4034
4108
|
interface IntrinsicElements {
|
|
@@ -4049,6 +4123,7 @@ declare global {
|
|
|
4049
4123
|
schematictext: Props.SchematicTextProps;
|
|
4050
4124
|
smtpad: Props.SmtPadProps;
|
|
4051
4125
|
platedhole: Props.PlatedHoleProps;
|
|
4126
|
+
keepout: Props.PcbKeepoutProps;
|
|
4052
4127
|
hole: Props.HoleProps;
|
|
4053
4128
|
port: Props.PortProps;
|
|
4054
4129
|
group: Props.GroupProps;
|
|
@@ -4074,4 +4149,4 @@ declare global {
|
|
|
4074
4149
|
}
|
|
4075
4150
|
}
|
|
4076
4151
|
|
|
4077
|
-
export { Board, Capacitor, Chip, Circuit, Constraint, Diode, Footprint, Group, Hole, type IRenderable, Jumper, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SilkscreenText, SmtPad, Trace, TraceHint };
|
|
4152
|
+
export { Board, Capacitor, Chip, Circuit, Constraint, Diode, Footprint, Group, Hole, type IRenderable, Jumper, Keepout, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SilkscreenText, SmtPad, Trace, TraceHint };
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ __export(components_exports, {
|
|
|
16
16
|
Group: () => Group,
|
|
17
17
|
Hole: () => Hole,
|
|
18
18
|
Jumper: () => Jumper,
|
|
19
|
+
Keepout: () => Keepout,
|
|
19
20
|
Led: () => Led,
|
|
20
21
|
Net: () => Net,
|
|
21
22
|
NormalComponent: () => NormalComponent,
|
|
@@ -1347,6 +1348,55 @@ var PlatedHole = class extends PrimitiveComponent {
|
|
|
1347
1348
|
}
|
|
1348
1349
|
};
|
|
1349
1350
|
|
|
1351
|
+
// lib/components/primitive-components/Keepout.ts
|
|
1352
|
+
import { pcbKeepoutProps } from "@tscircuit/props";
|
|
1353
|
+
import { decomposeTSR as decomposeTSR2 } from "transformation-matrix";
|
|
1354
|
+
var Keepout = class extends PrimitiveComponent {
|
|
1355
|
+
pcb_keepout_id = null;
|
|
1356
|
+
isPcbPrimitive = true;
|
|
1357
|
+
get config() {
|
|
1358
|
+
return {
|
|
1359
|
+
zodProps: pcbKeepoutProps
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
doInitialPcbPrimitiveRender() {
|
|
1363
|
+
const { db } = this.root;
|
|
1364
|
+
const { _parsedProps: props } = this;
|
|
1365
|
+
const position = this._getGlobalPcbPositionBeforeLayout();
|
|
1366
|
+
const decomposedMat = decomposeTSR2(
|
|
1367
|
+
this._computePcbGlobalTransformBeforeLayout()
|
|
1368
|
+
);
|
|
1369
|
+
const isRotated90 = Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01;
|
|
1370
|
+
let pcb_keepout = null;
|
|
1371
|
+
if (props.shape === "circle") {
|
|
1372
|
+
pcb_keepout = db.pcb_keepout.insert({
|
|
1373
|
+
layers: ["top"],
|
|
1374
|
+
shape: "circle",
|
|
1375
|
+
// @ts-ignore: no idea why this is triggering
|
|
1376
|
+
radius: props.radius,
|
|
1377
|
+
center: {
|
|
1378
|
+
x: position.x,
|
|
1379
|
+
y: position.y
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
} else if (props.shape === "rect") {
|
|
1383
|
+
pcb_keepout = db.pcb_keepout.insert({
|
|
1384
|
+
layers: ["top"],
|
|
1385
|
+
shape: "rect",
|
|
1386
|
+
...isRotated90 ? { width: props.height, height: props.width } : { width: props.width, height: props.height },
|
|
1387
|
+
// @ts-ignore: no idea why this is triggering
|
|
1388
|
+
center: {
|
|
1389
|
+
x: position.x,
|
|
1390
|
+
y: position.y
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
if (pcb_keepout) {
|
|
1395
|
+
this.pcb_keepout_id = pcb_keepout.pcb_keepout_id;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
|
|
1350
1400
|
// lib/utils/createComponentsFromSoup.ts
|
|
1351
1401
|
var createComponentsFromSoup = (soup) => {
|
|
1352
1402
|
const components = [];
|
|
@@ -1395,6 +1445,25 @@ var createComponentsFromSoup = (soup) => {
|
|
|
1395
1445
|
})
|
|
1396
1446
|
);
|
|
1397
1447
|
}
|
|
1448
|
+
} else if (elm.type === "pcb_keepout" && elm.shape === "circle") {
|
|
1449
|
+
components.push(
|
|
1450
|
+
new Keepout({
|
|
1451
|
+
pcbX: elm.center.x,
|
|
1452
|
+
pcbY: elm.center.y,
|
|
1453
|
+
shape: "circle",
|
|
1454
|
+
radius: elm.radius
|
|
1455
|
+
})
|
|
1456
|
+
);
|
|
1457
|
+
} else if (elm.type === "pcb_keepout" && elm.shape === "rect") {
|
|
1458
|
+
components.push(
|
|
1459
|
+
new Keepout({
|
|
1460
|
+
pcbX: elm.center.x,
|
|
1461
|
+
pcbY: elm.center.y,
|
|
1462
|
+
shape: "rect",
|
|
1463
|
+
width: elm.width,
|
|
1464
|
+
height: elm.height
|
|
1465
|
+
})
|
|
1466
|
+
);
|
|
1398
1467
|
}
|
|
1399
1468
|
}
|
|
1400
1469
|
return components;
|
|
@@ -2260,7 +2329,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
2260
2329
|
return;
|
|
2261
2330
|
}
|
|
2262
2331
|
const pcbElements = db.toArray().filter(
|
|
2263
|
-
(elm) => elm.type === "pcb_smtpad" || elm.type === "pcb_trace" || elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "source_port" || elm.type === "pcb_port" || elm.type === "source_trace"
|
|
2332
|
+
(elm) => elm.type === "pcb_smtpad" || elm.type === "pcb_trace" || elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "source_port" || elm.type === "pcb_port" || elm.type === "source_trace" || elm.type === "pcb_keepout"
|
|
2264
2333
|
);
|
|
2265
2334
|
const source_trace = db.source_trace.get(this.source_trace_id);
|
|
2266
2335
|
const hints = ports.flatMap(
|
|
@@ -3299,6 +3368,7 @@ export {
|
|
|
3299
3368
|
Group,
|
|
3300
3369
|
Hole,
|
|
3301
3370
|
Jumper,
|
|
3371
|
+
Keepout,
|
|
3302
3372
|
Led,
|
|
3303
3373
|
Net,
|
|
3304
3374
|
NormalComponent,
|
package/lib/components/index.ts
CHANGED
|
@@ -20,3 +20,4 @@ export { PlatedHole } from "./primitive-components/PlatedHole"
|
|
|
20
20
|
export { Constraint } from "./primitive-components/Constraint"
|
|
21
21
|
export { Hole } from "./primitive-components/Hole"
|
|
22
22
|
export { SilkscreenText } from "./primitive-components/SilkscreenText"
|
|
23
|
+
export { Keepout } from "./primitive-components/Keepout"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { PrimitiveComponent } from "../base-components/PrimitiveComponent"
|
|
2
|
+
import { pcbKeepoutProps } from "@tscircuit/props"
|
|
3
|
+
import type { RenderPhaseFn } from "../base-components/Renderable"
|
|
4
|
+
import type { PCBKeepout } from "@tscircuit/soup"
|
|
5
|
+
import { decomposeTSR } from "transformation-matrix"
|
|
6
|
+
|
|
7
|
+
export class Keepout extends PrimitiveComponent<typeof pcbKeepoutProps> {
|
|
8
|
+
pcb_keepout_id: string | null = null
|
|
9
|
+
|
|
10
|
+
isPcbPrimitive = true
|
|
11
|
+
|
|
12
|
+
get config() {
|
|
13
|
+
return {
|
|
14
|
+
zodProps: pcbKeepoutProps,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
doInitialPcbPrimitiveRender(): void {
|
|
19
|
+
const { db } = this.root!
|
|
20
|
+
const { _parsedProps: props } = this
|
|
21
|
+
const position = this._getGlobalPcbPositionBeforeLayout()
|
|
22
|
+
const decomposedMat = decomposeTSR(
|
|
23
|
+
this._computePcbGlobalTransformBeforeLayout(),
|
|
24
|
+
)
|
|
25
|
+
const isRotated90 =
|
|
26
|
+
Math.abs(decomposedMat.rotation.angle * (180 / Math.PI) - 90) < 0.01
|
|
27
|
+
|
|
28
|
+
let pcb_keepout: PCBKeepout | null = null
|
|
29
|
+
if (props.shape === "circle") {
|
|
30
|
+
pcb_keepout = db.pcb_keepout.insert({
|
|
31
|
+
layers: ["top"],
|
|
32
|
+
shape: "circle",
|
|
33
|
+
// @ts-ignore: no idea why this is triggering
|
|
34
|
+
radius: props.radius,
|
|
35
|
+
center: {
|
|
36
|
+
x: position.x,
|
|
37
|
+
y: position.y,
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
} else if (props.shape === "rect") {
|
|
41
|
+
pcb_keepout = db.pcb_keepout.insert({
|
|
42
|
+
layers: ["top"],
|
|
43
|
+
shape: "rect",
|
|
44
|
+
...(isRotated90
|
|
45
|
+
? { width: props.height, height: props.width }
|
|
46
|
+
: { width: props.width, height: props.height }),
|
|
47
|
+
// @ts-ignore: no idea why this is triggering
|
|
48
|
+
center: {
|
|
49
|
+
x: position.x,
|
|
50
|
+
y: position.y,
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
if (pcb_keepout) {
|
|
55
|
+
this.pcb_keepout_id = pcb_keepout.pcb_keepout_id
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -294,7 +294,8 @@ export class Trace extends PrimitiveComponent<typeof traceProps> {
|
|
|
294
294
|
elm.type === "pcb_hole" ||
|
|
295
295
|
elm.type === "source_port" ||
|
|
296
296
|
elm.type === "pcb_port" ||
|
|
297
|
-
elm.type === "source_trace"
|
|
297
|
+
elm.type === "source_trace" ||
|
|
298
|
+
elm.type === "pcb_keepout",
|
|
298
299
|
)
|
|
299
300
|
|
|
300
301
|
const source_trace = db.source_trace.get(this.source_trace_id!)!
|
|
@@ -3,6 +3,7 @@ import type { PrimitiveComponent } from "../components/base-components/Primitive
|
|
|
3
3
|
import { SmtPad } from "lib/components/primitive-components/SmtPad"
|
|
4
4
|
import { SilkscreenPath } from "lib/components/primitive-components/SilkscreenPath"
|
|
5
5
|
import { PlatedHole } from "lib/components/primitive-components/PlatedHole"
|
|
6
|
+
import { Keepout } from "lib/components/primitive-components/Keepout"
|
|
6
7
|
|
|
7
8
|
export const createComponentsFromSoup = (
|
|
8
9
|
soup: AnySoupElement[],
|
|
@@ -53,6 +54,25 @@ export const createComponentsFromSoup = (
|
|
|
53
54
|
}),
|
|
54
55
|
)
|
|
55
56
|
}
|
|
57
|
+
} else if (elm.type === "pcb_keepout" && elm.shape === "circle") {
|
|
58
|
+
components.push(
|
|
59
|
+
new Keepout({
|
|
60
|
+
pcbX: elm.center.x,
|
|
61
|
+
pcbY: elm.center.y,
|
|
62
|
+
shape: "circle",
|
|
63
|
+
radius: elm.radius,
|
|
64
|
+
}),
|
|
65
|
+
)
|
|
66
|
+
} else if (elm.type === "pcb_keepout" && elm.shape === "rect") {
|
|
67
|
+
components.push(
|
|
68
|
+
new Keepout({
|
|
69
|
+
pcbX: elm.center.x,
|
|
70
|
+
pcbY: elm.center.y,
|
|
71
|
+
shape: "rect",
|
|
72
|
+
width: elm.width,
|
|
73
|
+
height: elm.height,
|
|
74
|
+
}),
|
|
75
|
+
)
|
|
56
76
|
}
|
|
57
77
|
}
|
|
58
78
|
return components
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"module": "index.ts",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.45",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@lume/kiwi": "^0.4.3",
|
|
37
37
|
"@tscircuit/infgrid-ijump-astar": "^0.0.9",
|
|
38
38
|
"@tscircuit/props": "^0.0.62",
|
|
39
|
-
"@tscircuit/soup": "^0.0.
|
|
40
|
-
"@tscircuit/soup-util": "0.0.
|
|
39
|
+
"@tscircuit/soup": "^0.0.67",
|
|
40
|
+
"@tscircuit/soup-util": "^0.0.23",
|
|
41
41
|
"footprinter": "^0.0.44",
|
|
42
42
|
"react": "^18.3.1",
|
|
43
43
|
"react-reconciler": "^0.29.2",
|