From 16bc48f2c6a7b859190c1163a5aec7a77184f2df Mon Sep 17 00:00:00 2001 From: seveibar Date: Fri, 30 Aug 2024 17:43:29 -0700 Subject: [PATCH 1/8] wip --- bun.lockb | Bin 117323 -> 116537 bytes lib/Project.ts | 29 +++++++++++++++++++++ lib/fiber/intrinsic-jsx.ts | 1 + package.json | 3 ++- tests/examples/example1.test.tsx | 42 +++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 tests/examples/example1.test.tsx diff --git a/bun.lockb b/bun.lockb index 0161d3bcb1ddc8a2245827ddf5d8950d1cb43865..2abf1a68013cfb116f4477c50d6b90b7607a3799 100755 GIT binary patch delta 19164 zcmeHvd3=pm+wQZrY{?UX2qKBdV4foL4q9 zdG@Il_IsDuFZ1j0c1~RQ`OjYtA5;Bo(C|x^pu=r5vrn8H++@{*n~RMX4}7!jIFslK zTAt)p^j%k#NK#r(ZU#k9&q*gCJq4OdQt^FAXGjRi5waSx5oB(LEiE76=>|!v4=&e{ zBpGrtILQl0s|R@;@lKGAcB)K=Yyf_qco70#MoDskOhE)?s0ODB&S>%wWJB-|k?sx| zW3Lv_4U+QRgQR>NAxY0m<7XYz3im>iA*<0UGNcI74RRo?DQb*B4kD<+Luhdm$nB6+ zP&brHmgsyv;z_SLBo(w2W_v;Uz&vVLV@S#;LsGt6qlM zT2ZboFGCuGQmNueS-H0Sj67+=bW)R~zNm#P%g@Z1m^G$Q>Z0*5Nb1rA!w~9XGbGKD^BvTl2-XZ7mjgQ{@|kvyMHL;@PTvDb zot4u`wS70FGJ3hTGP(e ze-x6^w`+VgBzev(Ej|a5${(hsM?)ficyWjp;RQ(r)Q2R+pMq4Ey8+n*{0tYPN}m6KwfunQ68(a!jc$29`$UiCOKQsfeR)$jh|l!a*g^ zUg{{+fuwGG0!gElZ_Dj6CJ&<$q3TycqNw8F-b#5M#ckCQalv|E^8qo}zg8*eLfTV{1j0!13LvU({Zs5ac z&7Ezz8C`Pnq|qc{`L+S7e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kPPaP=;2C z;-eHyF>9hYox;u=-b@tBQrQmdQax~g9I5|W!J?v{E_9q%<#p6UTQN%eliN2l>Ol)? zC5e^8;Dr8*1#k9F{buhltrC}AGJH&v zneLrJLZqy|qE8xYW_qiyddqlROiRNiA0a+V!=+vSHG>1Qf9Y8J$Gj7UKR#;czh^M< z;qY_QU;EDAz-UxL%(NxPrDG$|f9POA%K>v5?~IG44_Bx$G&t(27z+coP|Qk46Fri} z;dE?H`cE1B?M9u5k|*6uolsyDEfq=su>+S!Vu`Qi!s?2Y0m-7~aCC?M^9ZGp+uI&G z|MTDqi~uAi@yzLE$A@^4smTb zYsD@IQwH<(?}i0W8_VfOBJQn{ydQ@^)1CHH^ZX5g8@$3YTtwFlR=-n!Y#nsxeluy} zI@<>gyoN#3$A&_Wq?*6i4*wzx8h?)C(L;J$$H!dl_qtmD_ERcXZ9Oi^(jY|i#3K)J zGJ^%|ev!eRRjU;loI5RzVW_Ieh%-ohDYaDAK8jNG^#t2FhFUGTa!Zwa|6kq4C hx)?|MD%L=}9M7tXR=LboxXxyNirl??99xn2{{UlG>;C`% diff --git a/lib/Project.ts b/lib/Project.ts index 3390705..1f3dd2c 100644 --- a/lib/Project.ts +++ b/lib/Project.ts @@ -11,6 +11,8 @@ export class Project { children: PrimitiveComponent[] db: SoupUtilObjects + _hasRenderedAtleastOnce = false + constructor() { this.children = [] this.db = su([]) @@ -64,9 +66,11 @@ export class Project { rootComponent.setProject(this) rootComponent.runRenderCycle() + this._hasRenderedAtleastOnce = true } getSoup(): AnySoupElement[] { + if (!this._hasRenderedAtleastOnce) this.render() return this.db.toArray() } @@ -74,6 +78,31 @@ export class Project { return this.getSoup() } + async getSvg(options: { view: "pcb"; layer?: string }): Promise { + const circuitToSvg = await import("circuit-to-svg").catch((e) => { + throw new Error( + `To use project.getSvg, you must install the "circuit-to-svg" package.\n\n"${e.message}"`, + ) + }) + + return circuitToSvg.pcbSoupToSvg(this.getSoup()) + } + + async preview( + previewNameOrOpts: + | string + | { + previewName: string + tscircuitApiKey?: string + }, + ) { + const previewOpts = + typeof previewNameOrOpts === "object" + ? previewNameOrOpts + : { previewName: previewNameOrOpts } + throw new Error("project.preview is not yet implemented") + } + computeGlobalSchematicTransform(): Matrix { return identity() } diff --git a/lib/fiber/intrinsic-jsx.ts b/lib/fiber/intrinsic-jsx.ts index bfce9b7..51b050a 100644 --- a/lib/fiber/intrinsic-jsx.ts +++ b/lib/fiber/intrinsic-jsx.ts @@ -9,6 +9,7 @@ declare global { diode: Props.DiodeProps led: Props.LedProps board: Props.BoardProps + jumper: Props.JumperProps bug: Props.ChipProps // TODO use ChipProps once it gets merged in @tscircuit/props chip: Props.ChipProps diff --git a/package.json b/package.json index 1fc72c0..538ac9c 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "devDependencies": { "@biomejs/biome": "^1.8.3", + "@tscircuit/layout": "^0.0.27", "@tscircuit/log-soup": "^1.0.2", "@types/bun": "latest", "@types/react": "^18.3.3", @@ -30,7 +31,7 @@ }, "dependencies": { "@tscircuit/infgrid-ijump-astar": "0.0.5", - "@tscircuit/props": "^0.0.46", + "@tscircuit/props": "^0.0.48", "@tscircuit/soup": "^0.0.58", "@tscircuit/soup-util": "0.0.18", "footprinter": "^0.0.44", diff --git a/tests/examples/example1.test.tsx b/tests/examples/example1.test.tsx new file mode 100644 index 0000000..731b6bc --- /dev/null +++ b/tests/examples/example1.test.tsx @@ -0,0 +1,42 @@ +import { test, expect } from "bun:test" +import { getTestFixture } from "tests/fixtures/get-test-fixture" + +test("example1", () => { + const { project } = getTestFixture() + project.add( + + + + + + + + + + + , + ) + + expect( + project.getSvg({ + view: "pcb", + layer: "top", + }), + ).toMatchSnapshot() +}) From 50e928e6b879514f9940fcb3eeb10904655a9733 Mon Sep 17 00:00:00 2001 From: seveibar Date: Fri, 30 Aug 2024 17:55:36 -0700 Subject: [PATCH 2/8] placeholder jumper --- bun.lockb | Bin 116537 -> 116952 bytes bunfig.toml | 2 + lib/components/index.ts | 1 + lib/components/normal-components/Chip.ts | 3 +- lib/components/normal-components/Jumper.ts | 121 +++++++++++++++++++++ package.json | 1 + tests/__snapshots__/example1.snap.svg | 1 + tests/examples/example1.test.tsx | 2 +- tests/fixtures/preload.ts | 1 + 9 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 bunfig.toml create mode 100644 lib/components/normal-components/Jumper.ts create mode 100644 tests/__snapshots__/example1.snap.svg create mode 100644 tests/fixtures/preload.ts diff --git a/bun.lockb b/bun.lockb index 2abf1a68013cfb116f4477c50d6b90b7607a3799..b6068eb2f701ef283475a6efa29f1dc7bbc02438 100755 GIT binary patch delta 15494 zcmeHOdt6n;_TO{lDBDMZBCmt;(p2RAIvf!;D5Cg6R0KpcKoANAIcT9KV05ia&Bp7L zX=$mI)y>qKm(frX3d(J zHEU+iIqcoEu+8DcZ5|8n{a$nDFLyV7loAxM<;C2H$8(N6IBo5Um*=iMy=&DILq;y0 zK6n>X=!#vO<6rlAq!bjTxU#y0)H5q55h(3Y&_z+|uYh+4lCCZA9MBC|T~b(F1Ad-G zQQAZHY^5kFa1La`lPGHk{0RCEKra`G(|~tCK0$IFm{6;tbOx3}K^4wHrUs50xCht~ z^1CSa1?IJp4$^^CuNg@7>_D;$HRNNivca7|8ps;-iU#s1&<8jUqp9lzW;PVm;2!kY z1Gp7Pj?&?kMqzXk2*5B zqOyqWyC58%kgY)K=s_UWf6u^s%gT$(U{~%exvvD6=Yja^Awzt~VO3#GS=c=#wO0@p zs@NXhsHaoPr595k^?uJtniN<4fc~A`MIAw^oBanA4u)&!hFDG{i{GURUg=h ziJ^jJP*9T0z_6%?Q!%lG+xg;FUUi!wQFp2q6D?rMmg$7museYD}`_{*Sp@w{c)c;av$&8YzHO>x@ zsbdq+Z3^g6ASS#1L~l9nR9@)fRrg_tjOq>`MPqg!Ikqg%lHHY9S??^6?Dqqye5)a^0a9ixGW4^7RIkh^9}7ggee3%h ziclaq@Bxyc3$P3DLX2$SD3Ho`8uBKd+B(8LJW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t(O+L|voyE5vGV;?^CFmUR53*;Bt|VPLN4o880H)i+3Vi&q;LJU7tLJQx^M_T zL9P_%?1*3R)ZnET25yG|rU$oI&S{db=B!^H9Pm^pGsRp4cBg!S{HHwZrAE8q2nO z23A|=NXdrTpUBKlo*4^!OpmyP-kNg=CA3%WWAD3O>W36F_!G3tYW56l3jdO4E!2b5 zmKh>PMa>k+DXt0DBi#O<{dq|6mBk2qXJ398DO}c extends NormalComponent< const { _parsedProps: props } = this if (props.pinLabels) { - for (const [pinNumber, label] of Object.entries(props.pinLabels)) { + for (let [pinNumber, label] of Object.entries(props.pinLabels)) { + pinNumber = pinNumber.replace("pin", "") const port = this.selectOne(`port[pinNumber='${pinNumber}']`) if (!port) { throw new Error( diff --git a/lib/components/normal-components/Jumper.ts b/lib/components/normal-components/Jumper.ts new file mode 100644 index 0000000..cff2579 --- /dev/null +++ b/lib/components/normal-components/Jumper.ts @@ -0,0 +1,121 @@ +import { NormalComponent } from "lib/components/base-components/NormalComponent" +import { jumperProps } from "@tscircuit/props" +import { Port } from "../primitive-components/Port" +import type { BaseSymbolName } from "lib/utils/constants" +import { + getAllDimensionsForSchematicBox, + type SchematicBoxDimensions, +} from "lib/utils/schematic/getAllDimensionsForSchematicBox" +import { underscorifyPortArrangement } from "lib/soup/underscorifyPortArrangement" +import { underscorifyPinStyles } from "lib/soup/underscorifyPinStyles" + +export class Jumper extends NormalComponent< + typeof jumperProps, + PinLabels +> { + schematicDimensions: SchematicBoxDimensions | null = null + + get config() { + return { + zodProps: jumperProps, + } + } + + initPorts() { + super.initPorts() + + const { _parsedProps: props } = this + + if (props.pinLabels) { + for (let [pinNumber, label] of Object.entries(props.pinLabels)) { + pinNumber = pinNumber.replace("pin", "") + const port = this.selectOne(`port[pinNumber='${pinNumber}']`) + if (!port) { + throw new Error( + `Could not find port for pin number ${pinNumber} in chip ${this.getString()}`, + ) + } + port.props.aliases.push(port.props.name) + port.props.name = label + } + } + } + + doInitialSourceRender(): void { + const { db } = this.project! + const { _parsedProps: props } = this + + const source_component = db.source_component.insert({ + ftype: "simple_chip", // TODO unknown or jumper + name: props.name, + manufacturer_part_number: props.manufacturerPartNumber, + supplier_part_numbers: props.supplierPartNumbers, + }) + + this.source_component_id = source_component.source_component_id! + } + + doInitialSchematicComponentRender() { + const { db } = this.project! + const { _parsedProps: props } = this + + const ports = this.children.filter((child) => child instanceof Port) + + const pinSpacing = props.schPinSpacing ?? 0.2 + + const dimensions = getAllDimensionsForSchematicBox({ + schWidth: props.schWidth, + schHeight: props.schHeight, + schPinSpacing: pinSpacing, + schPinStyle: props.schPinStyle, + + pinCount: ports.length, + + // @ts-ignore there's a subtley in the definition difference with + // leftSide/rightSide/topSide/bottomSide in how the direction is defined + // that doesn't really matter + schPortArrangement: { + // TODO use schematic direction or schPortArrangement + rightSize: ports.length, + }, + }) + this.schematicDimensions = dimensions + + const schematic_component = db.schematic_component.insert({ + center: { x: props.schX ?? 0, y: props.schY ?? 0 }, + rotation: props.schRotation ?? 0, + size: dimensions.getSize(), + + port_arrangement: underscorifyPortArrangement( + props.schPortArrangement as any, + ), + + pin_spacing: pinSpacing, + + // @ts-ignore soup needs to support distance for pin_styles + pin_styles: underscorifyPinStyles(props.schPinStyle), + + port_labels: props.pinLabels, + + source_component_id: this.source_component_id!, + }) + + this.schematic_component_id = schematic_component.schematic_component_id + } + + doInitialPcbComponentRender() { + const { db } = this.project! + const { _parsedProps: props } = this + + const pcb_component = db.pcb_component.insert({ + center: { x: props.pcbX ?? 0, y: props.pcbY ?? 0 }, + width: 2, // Default width, adjust as needed + height: 3, // Default height, adjust as needed + layer: props.layer ?? "top", + rotation: props.pcbRotation ?? 0, + source_component_id: this.source_component_id!, + }) + + this.pcb_component_id = pcb_component.pcb_component_id + } +} diff --git a/package.json b/package.json index 538ac9c..255685d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@types/bun": "latest", "@types/react": "^18.3.3", "@types/react-reconciler": "^0.28.8", + "bun-match-svg": "^0.0.1", "circuit-to-svg": "^0.0.3", "howfat": "^0.3.8", "looks-same": "^9.0.1", diff --git a/tests/__snapshots__/example1.snap.svg b/tests/__snapshots__/example1.snap.svg new file mode 100644 index 0000000..c4c2a10 --- /dev/null +++ b/tests/__snapshots__/example1.snap.svg @@ -0,0 +1 @@ +[object Promise] \ No newline at end of file diff --git a/tests/examples/example1.test.tsx b/tests/examples/example1.test.tsx index 731b6bc..a0e0d81 100644 --- a/tests/examples/example1.test.tsx +++ b/tests/examples/example1.test.tsx @@ -38,5 +38,5 @@ test("example1", () => { view: "pcb", layer: "top", }), - ).toMatchSnapshot() + ).toMatchSvgSnapshot(import.meta.dir, "example1") }) diff --git a/tests/fixtures/preload.ts b/tests/fixtures/preload.ts new file mode 100644 index 0000000..ee67a60 --- /dev/null +++ b/tests/fixtures/preload.ts @@ -0,0 +1 @@ +import "bun-match-svg" From dfd2caf62fe2284ba209923c15ed8441f46d9959 Mon Sep 17 00:00:00 2001 From: seveibar Date: Fri, 30 Aug 2024 18:22:47 -0700 Subject: [PATCH 3/8] fix chip pinLabel selectors not working --- .../base-components/PrimitiveComponent.ts | 19 ++++++++++++++++++ lib/components/normal-components/Chip.ts | 2 +- lib/components/primitive-components/Port.ts | 1 + .../chip-pin-selector.test.tsx | 20 +++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/components/normal-components/chip-pin-selector.test.tsx diff --git a/lib/components/base-components/PrimitiveComponent.ts b/lib/components/base-components/PrimitiveComponent.ts index 5436845..7bc1e14 100644 --- a/lib/components/base-components/PrimitiveComponent.ts +++ b/lib/components/base-components/PrimitiveComponent.ts @@ -46,6 +46,8 @@ export abstract class PrimitiveComponent< componentName = "" lowercaseComponentName = "" + externallyAddedAliases: string[] + source_group_id: string | null = null source_component_id: string | null = null schematic_component_id: string | null = null @@ -57,6 +59,7 @@ export abstract class PrimitiveComponent< this.children = [] this.childrenPendingRemoval = [] this.props = props ?? {} + this.externallyAddedAliases = [] this._parsedProps = this.config.zodProps.parse( props ?? {}, ) as z.infer @@ -226,9 +229,24 @@ export abstract class PrimitiveComponent< let onlyDirectChildren = false for (const part of parts) { + // console.log({ part, results }) if (part === ">") { onlyDirectChildren = true } else { + // console.log( + // "descendants", + // results + // .flatMap((component) => { + // return onlyDirectChildren + // ? component.children + // : component.getDescendants() + // }) + // .map((c) => ({ + // component: c.toString(), + + // isMatching: isMatchingSelector(c, part), + // })), + // ) results = results.flatMap((component) => { return ( onlyDirectChildren ? component.children : component.getDescendants() @@ -236,6 +254,7 @@ export abstract class PrimitiveComponent< }) onlyDirectChildren = false } + // console.log({ results }) } return results.filter((component) => component !== this) diff --git a/lib/components/normal-components/Chip.ts b/lib/components/normal-components/Chip.ts index c315b0d..af3111b 100644 --- a/lib/components/normal-components/Chip.ts +++ b/lib/components/normal-components/Chip.ts @@ -35,7 +35,7 @@ export class Chip extends NormalComponent< `Could not find port for pin number ${pinNumber} in chip ${this.getString()}`, ) } - port.props.aliases.push(port.props.name) + port.externallyAddedAliases.push(label) port.props.name = label } } diff --git a/lib/components/primitive-components/Port.ts b/lib/components/primitive-components/Port.ts index b59ea22..4ee513c 100644 --- a/lib/components/primitive-components/Port.ts +++ b/lib/components/primitive-components/Port.ts @@ -82,6 +82,7 @@ export class Port extends PrimitiveComponent { ...(typeof props.pinNumber === "number" ? [`pin${props.pinNumber}`, props.pinNumber.toString()] : []), + ...this.externallyAddedAliases, ]), ) as string[] } diff --git a/tests/components/normal-components/chip-pin-selector.test.tsx b/tests/components/normal-components/chip-pin-selector.test.tsx new file mode 100644 index 0000000..eb52949 --- /dev/null +++ b/tests/components/normal-components/chip-pin-selector.test.tsx @@ -0,0 +1,20 @@ +import { test, expect } from "bun:test" +import { getTestFixture } from "tests/fixtures/get-test-fixture" + +test("should be able to select a pin/port by label on a chip", () => { + const { project } = getTestFixture() + project.add( + + + , + ) + + project.render() + + const pwr = project.selectOne(".U1 .PWR") + expect(pwr).toBeTruthy() +}) From 338dc988d0e2a3421ff2b74934778445e304eb5c Mon Sep 17 00:00:00 2001 From: seveibar Date: Sat, 31 Aug 2024 09:51:39 -0700 Subject: [PATCH 4/8] add example render --- bun.lockb | Bin 116952 -> 120714 bytes lib/Project.ts | 2 +- package.json | 4 ++-- tests/__snapshots__/example1.snap.svg | 8 +++++++- tests/examples/example1.test.tsx | 10 ++++++---- .../extend-expect-circuit-snapshot.ts | 5 +++-- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/bun.lockb b/bun.lockb index b6068eb2f701ef283475a6efa29f1dc7bbc02438..3938d8a10addd903688dbfae5d143a7949c656b8 100755 GIT binary patch delta 4635 zcmeHK`CpSq6Mr@kNuYS(0g)R7K}{eDAzVg4LjQRKbif`%I6se97jG%Nb8q&GZ@(8RkVW`srGwiJ-6*?ITmG^QQKZP!Vb-i4yuQvo z!%=1CBxRo5BH+2X5Rz1h?C4s3j=aEx=BnHP~YP-~^Ud63TBC=9jMcg!_4vL1iq%+BuF-P_zR zNo?46^A~3Fmf#K(Uyi*6wWxf_nB*$6(Qbk4888fmnB$#&r z3(uP%5uFNdB5OwVjl^9Hby^+axKs2_zXv2&T*iG4 z`#&8#AmWzm1)B#)4F*xqlCnOMn7DxDdjzDr2h(WBWLxhQY)N;lITKEFy@%R9dS*pwuA2kJ>^i1__Iy(gWNM zNUU}M68%n6F-X{5j7*TQpE5E*V!s!V*zX4Tz)$N~M=jQqbNvCn8Phh^Q zw8mji&fy;3;CtB_&Qn4SYxESy=GHuJSyvcd+!RssWI>em=VKE3F309N2Hb7Bde1b# zB$QhkpxL_DBVGfVGTTM`>zB3Ms+qnptr-0KIp#FX=v|op_g#LED%dP3u>SfIhu{0} z%Y7bP=M^rBKkg{6_~h#F-hwNCg!oPi-|*T~x{s7sco5QQuXrpEa1$ z6U=Yx9uVJ3@tQb~8`o~zbF^mShOg?z88+r7ncaQrSGTrn?Xc>`C!zWdw|4KFFs)!n zbiAR_nFrN8=?gmNpueH4XleOx3p!F76}4a3IIX!5+wlDc*SQ%h|44npiQ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PJkfDr=Ma6^!7iZ(*gdcxnXXd@M^jBf*Fxj~*2O9SOqu{2{u zIkYW61+W#^25bj*0F}UG4449Z2Aii3o=O<7T=t8jtT)dbr2x-MtAJ1HFT~LeRKqg~ z&p|vdt(J>M(FVGwW`J3=v<`Ai~h=*m|@h`cU|_7fsWeN_@I4%9j?@AoI?)GTlM zszadD^O^-&`T#qiFzY(Ui#j;)beKGa4cG) zM4hPDlb307=Rz9duEveWuj`a_Ibso=Ab+=r=Jj{p?I+eg9q0M5=v#q?I97)*35%R! zquSxl%Y5hgvZC$Q=6r#EXcVJGy^bjN{<4zr%yofvaU;+Yff*x2<1UN54P%8F7Ws&c zMhNYh@~`mwJ1_DBEq$X;KY#n83)PE8F%mQOnkxG)#%#{3e^gkNo3&-&!#6#g9|sqQ z+ed%>{p0CxTBND+e2g_YKPQfr=W54qvNpWw;r!r8+YtZJq2$~CZ(4%#9T6gT^Ldu= zl&>tNqU^SWo^sb(U$?|J);BMqmNZqQxcJ?r^7!*KO!jS}-Rd7*pgN(nnYzgHo9IBf T%RcHWPim&F_4X$EW7od`*<(0S diff --git a/lib/Project.ts b/lib/Project.ts index 1f3dd2c..3ea90e9 100644 --- a/lib/Project.ts +++ b/lib/Project.ts @@ -85,7 +85,7 @@ export class Project { ) }) - return circuitToSvg.pcbSoupToSvg(this.getSoup()) + return circuitToSvg.circuitJsonToPcbSvg(this.getSoup()) } async preview( diff --git a/package.json b/package.json index 255685d..ccef5ff 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "@types/bun": "latest", "@types/react": "^18.3.3", "@types/react-reconciler": "^0.28.8", - "bun-match-svg": "^0.0.1", - "circuit-to-svg": "^0.0.3", + "bun-match-svg": "0.0.2", + "circuit-to-svg": "^0.0.13", "howfat": "^0.3.8", "looks-same": "^9.0.1", "tsup": "^8.2.4" diff --git a/tests/__snapshots__/example1.snap.svg b/tests/__snapshots__/example1.snap.svg index c4c2a10..5a55346 100644 --- a/tests/__snapshots__/example1.snap.svg +++ b/tests/__snapshots__/example1.snap.svg @@ -1 +1,7 @@ -[object Promise] \ No newline at end of file + \ No newline at end of file diff --git a/tests/examples/example1.test.tsx b/tests/examples/example1.test.tsx index a0e0d81..0c6451f 100644 --- a/tests/examples/example1.test.tsx +++ b/tests/examples/example1.test.tsx @@ -1,7 +1,7 @@ import { test, expect } from "bun:test" import { getTestFixture } from "tests/fixtures/get-test-fixture" -test("example1", () => { +test("example1", async () => { const { project } = getTestFixture() project.add( @@ -26,14 +26,16 @@ test("example1", () => { /> - + {/* - + */} , ) - expect( + project.render() + + await expect( project.getSvg({ view: "pcb", layer: "top", diff --git a/tests/fixtures/extend-expect-circuit-snapshot.ts b/tests/fixtures/extend-expect-circuit-snapshot.ts index f1c686a..3aaedbb 100644 --- a/tests/fixtures/extend-expect-circuit-snapshot.ts +++ b/tests/fixtures/extend-expect-circuit-snapshot.ts @@ -1,4 +1,4 @@ -import { pcbSoupToSvg, soupToSvg as schematicSoupToSvg } from "circuit-to-svg" +import { circuitJsonToPcbSvg, circuitJsonToSchematicSvg } from "circuit-to-svg" import { it, expect, type CustomMatcher, type MatcherResult } from "bun:test" import * as fs from "node:fs" import * as path from "node:path" @@ -22,7 +22,8 @@ async function saveSnapshotOfSoup({ const snapshotName = `${path.basename(testPath || "")}-${mode}.snap.svg` const filePath = path.join(snapshotDir, snapshotName) - const svg = mode === "pcb" ? pcbSoupToSvg(soup) : schematicSoupToSvg(soup) + const svg = + mode === "pcb" ? circuitJsonToPcbSvg(soup) : circuitJsonToSchematicSvg(soup) if (!fs.existsSync(snapshotDir)) { fs.mkdirSync(snapshotDir, { recursive: true }) From f4e2d2c6267eb1b127c6f3e254e7c53414240ce6 Mon Sep 17 00:00:00 2001 From: seveibar Date: Sat, 31 Aug 2024 12:38:47 -0700 Subject: [PATCH 5/8] remove log statements --- .../base-components/PrimitiveComponent.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/components/base-components/PrimitiveComponent.ts b/lib/components/base-components/PrimitiveComponent.ts index 7bc1e14..2f939a9 100644 --- a/lib/components/base-components/PrimitiveComponent.ts +++ b/lib/components/base-components/PrimitiveComponent.ts @@ -229,24 +229,9 @@ export abstract class PrimitiveComponent< let onlyDirectChildren = false for (const part of parts) { - // console.log({ part, results }) if (part === ">") { onlyDirectChildren = true } else { - // console.log( - // "descendants", - // results - // .flatMap((component) => { - // return onlyDirectChildren - // ? component.children - // : component.getDescendants() - // }) - // .map((c) => ({ - // component: c.toString(), - - // isMatching: isMatchingSelector(c, part), - // })), - // ) results = results.flatMap((component) => { return ( onlyDirectChildren ? component.children : component.getDescendants() @@ -254,7 +239,6 @@ export abstract class PrimitiveComponent< }) onlyDirectChildren = false } - // console.log({ results }) } return results.filter((component) => component !== this) From c4c636fc336955a60ef5b1660d002d497d14ef96 Mon Sep 17 00:00:00 2001 From: seveibar Date: Sat, 31 Aug 2024 13:45:17 -0700 Subject: [PATCH 6/8] draw silkscreen --- lib/components/index.ts | 1 + .../primitive-components/SilkscreenPath.ts | 35 ++++++++++ lib/utils/createComponentsFromSoup.ts | 59 +++------------- tests/__snapshots__/example1.snap.svg | 4 +- .../__snapshots__/trace-hint-pcb.snap.svg | 37 ++-------- .../trace-hint-schematic.snap.svg | 69 ++----------------- .../__snapshots__/trace-pcb.snap.svg | 37 ++-------- .../__snapshots__/trace-schematic.snap.svg | 69 ++----------------- .../circuit-snapshot-pcb.snap.svg | 28 ++------ 9 files changed, 82 insertions(+), 257 deletions(-) create mode 100644 lib/components/primitive-components/SilkscreenPath.ts diff --git a/lib/components/index.ts b/lib/components/index.ts index fd3e400..d3d556b 100644 --- a/lib/components/index.ts +++ b/lib/components/index.ts @@ -14,3 +14,4 @@ export { TraceHint } from "./primitive-components/TraceHint" export { Group } from "./primitive-components/Group" export { Chip } from "./normal-components/Chip" export { Jumper } from "./normal-components/Jumper" +export { SilkscreenPath } from "./primitive-components/SilkscreenPath" diff --git a/lib/components/primitive-components/SilkscreenPath.ts b/lib/components/primitive-components/SilkscreenPath.ts new file mode 100644 index 0000000..3f1e630 --- /dev/null +++ b/lib/components/primitive-components/SilkscreenPath.ts @@ -0,0 +1,35 @@ +import { silkscreenPathProps } from "@tscircuit/props" +import { PrimitiveComponent } from "../base-components/PrimitiveComponent" + +export class SilkscreenPath extends PrimitiveComponent< + typeof silkscreenPathProps +> { + pcb_silkscreen_path_id: string | null = null + + get config() { + return { + zodProps: silkscreenPathProps, + } + } + + doInitialPcbPrimitiveRender(): void { + const { db } = this.project! + const { _parsedProps: props } = this + + const layer = props.layer ?? "top" + if (layer !== "top" && layer !== "bottom") { + throw new Error( + `Invalid layer "${layer}" for SilkscreenPath. Must be "top" or "bottom".`, + ) + } + + const pcb_silkscreen_path = db.pcb_silkscreen_path.insert({ + pcb_component_id: this.parent?.pcb_component_id!, + layer, + route: props.route, + stroke_width: props.strokeWidth ?? 0.1, + }) + + this.pcb_silkscreen_path_id = pcb_silkscreen_path.pcb_silkscreen_path_id + } +} diff --git a/lib/utils/createComponentsFromSoup.ts b/lib/utils/createComponentsFromSoup.ts index dd345f9..b9b38d9 100644 --- a/lib/utils/createComponentsFromSoup.ts +++ b/lib/utils/createComponentsFromSoup.ts @@ -1,6 +1,7 @@ import type { AnySoupElement } from "@tscircuit/soup" import type { PrimitiveComponent } from "../components/base-components/PrimitiveComponent" import { SmtPad } from "lib/components/primitive-components/SmtPad" +import { SilkscreenPath } from "lib/components/primitive-components/SilkscreenPath" export const createComponentsFromSoup = ( soup: AnySoupElement[], @@ -30,57 +31,15 @@ export const createComponentsFromSoup = ( portHints: elm.port_hints, }), ) + } else if (elm.type === "pcb_silkscreen_path") { + components.push( + new SilkscreenPath({ + layer: elm.layer, + route: elm.route, + strokeWidth: elm.stroke_width, + }), + ) } } return components - // if (elm.type === "pcb_smtpad") { - // this.add("smtpad", (pb) => pb.setProps(elm)) - // } else if (elm.type === "pcb_plated_hole") { - // this.add("platedhole", (pb) => pb.setProps(elm)) - // } else if (elm.type === "pcb_hole") { - // this.add("hole", (pb) => pb.setProps(elm)) - // } else if (elm.type === "pcb_silkscreen_circle") { - // this.add("silkscreencircle", (pb) => - // pb.setProps({ - // ...elm, - // pcbX: elm.center.x, - // pcbY: elm.center.y, - // }) - // ) - // } else if (elm.type === "pcb_silkscreen_line") { - // this.add("silkscreenline", (pb) => - // pb.setProps({ - // ...elm, - // strokeWidth: elm.stroke_width, - // }) - // ) - // } else if (elm.type === "pcb_silkscreen_path") { - // this.add("silkscreenpath", (pb) => - // pb.setProps({ - // ...elm, - // strokeWidth: elm.stroke_width, - // }) - // ) - // } else if (elm.type === "pcb_silkscreen_rect") { - // this.add("silkscreenrect", (pb) => - // pb.setProps({ - // ...elm, - // pcbX: elm.center.x, - // pcbY: elm.center.y, - // // TODO silkscreen rect isFilled, isOutline etc. - // }) - // ) - // } else if (elm.type === "pcb_fabrication_note_path") { - // this.add("fabricationnotepath", (pb) => pb.setProps(elm)) - // } else if (elm.type === "pcb_fabrication_note_text") { - // this.add("fabricationnotetext", (pb) => - // pb.setProps({ - // ...elm, - // pcbX: elm.anchor_position.x, - // pcbY: elm.anchor_position.y, - // anchorAlignment: elm.anchor_alignment, - // fontSize: elm.font_size, - // }) - // ) - // } } diff --git a/tests/__snapshots__/example1.snap.svg b/tests/__snapshots__/example1.snap.svg index 5a55346..3d9ac17 100644 --- a/tests/__snapshots__/example1.snap.svg +++ b/tests/__snapshots__/example1.snap.svg @@ -3,5 +3,5 @@ .pcb-trace { stroke: #FF0000; stroke-width: 0.3; fill: none; } .pcb-hole { fill: #FF00FF; } .pcb-pad { fill: #FF0000; } - .pcb-boundary { fill: none; stroke: #f2eda1; stroke-width: 2.5; } - \ No newline at end of file + .pcb-boundary { fill: none; stroke: #f2eda1; stroke-width: 5; } + \ No newline at end of file diff --git a/tests/components/primitive-components/__snapshots__/trace-hint-pcb.snap.svg b/tests/components/primitive-components/__snapshots__/trace-hint-pcb.snap.svg index 3e91265..8a496c4 100644 --- a/tests/components/primitive-components/__snapshots__/trace-hint-pcb.snap.svg +++ b/tests/components/primitive-components/__snapshots__/trace-hint-pcb.snap.svg @@ -1,30 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/tests/components/primitive-components/__snapshots__/trace-hint-schematic.snap.svg b/tests/components/primitive-components/__snapshots__/trace-hint-schematic.snap.svg index 3fad545..c11e7b4 100644 --- a/tests/components/primitive-components/__snapshots__/trace-hint-schematic.snap.svg +++ b/tests/components/primitive-components/__snapshots__/trace-hint-schematic.snap.svg @@ -1,62 +1,7 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/tests/components/primitive-components/__snapshots__/trace-pcb.snap.svg b/tests/components/primitive-components/__snapshots__/trace-pcb.snap.svg index f3642e1..f92a18c 100644 --- a/tests/components/primitive-components/__snapshots__/trace-pcb.snap.svg +++ b/tests/components/primitive-components/__snapshots__/trace-pcb.snap.svg @@ -1,30 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/tests/components/primitive-components/__snapshots__/trace-schematic.snap.svg b/tests/components/primitive-components/__snapshots__/trace-schematic.snap.svg index 3fad545..c11e7b4 100644 --- a/tests/components/primitive-components/__snapshots__/trace-schematic.snap.svg +++ b/tests/components/primitive-components/__snapshots__/trace-schematic.snap.svg @@ -1,62 +1,7 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/tests/fixtures/__snapshots__/circuit-snapshot-pcb.snap.svg b/tests/fixtures/__snapshots__/circuit-snapshot-pcb.snap.svg index babdd01..99b70d5 100644 --- a/tests/fixtures/__snapshots__/circuit-snapshot-pcb.snap.svg +++ b/tests/fixtures/__snapshots__/circuit-snapshot-pcb.snap.svg @@ -1,21 +1,7 @@ - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file From c26c1c3e1d51281cd3313fb8d752eee6683ec15e Mon Sep 17 00:00:00 2001 From: seveibar Date: Sat, 31 Aug 2024 14:51:27 -0700 Subject: [PATCH 7/8] support pinLabels for things other than chips --- .../base-components/NormalComponent.ts | 16 +++++++++++++++ lib/components/normal-components/Chip.ts | 20 ------------------- lib/components/normal-components/Jumper.ts | 20 ------------------- 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/lib/components/base-components/NormalComponent.ts b/lib/components/base-components/NormalComponent.ts index 761af61..2f7e554 100644 --- a/lib/components/base-components/NormalComponent.ts +++ b/lib/components/base-components/NormalComponent.ts @@ -87,6 +87,22 @@ export class NormalComponent< const portsFromFootprint = this.getPortsFromFootprint() this.addAll(portsFromFootprint) + + const pinLabels: Record | undefined = + this._parsedProps.pinLabels + if (pinLabels) { + for (let [pinNumber, label] of Object.entries(pinLabels)) { + pinNumber = pinNumber.replace("pin", "") + const port = this.selectOne(`port[pinNumber='${pinNumber}']`) + if (!port) { + throw new Error( + `Could not find port for pin number ${pinNumber} in chip ${this.getString()}`, + ) + } + port.externallyAddedAliases.push(label) + port.props.name = label + } + } } _addChildrenFromStringFootprint() { diff --git a/lib/components/normal-components/Chip.ts b/lib/components/normal-components/Chip.ts index af3111b..10dd7a4 100644 --- a/lib/components/normal-components/Chip.ts +++ b/lib/components/normal-components/Chip.ts @@ -21,26 +21,6 @@ export class Chip extends NormalComponent< } } - initPorts() { - super.initPorts() - - const { _parsedProps: props } = this - - if (props.pinLabels) { - for (let [pinNumber, label] of Object.entries(props.pinLabels)) { - pinNumber = pinNumber.replace("pin", "") - const port = this.selectOne(`port[pinNumber='${pinNumber}']`) - if (!port) { - throw new Error( - `Could not find port for pin number ${pinNumber} in chip ${this.getString()}`, - ) - } - port.externallyAddedAliases.push(label) - port.props.name = label - } - } - } - doInitialSourceRender(): void { const { db } = this.project! const { _parsedProps: props } = this diff --git a/lib/components/normal-components/Jumper.ts b/lib/components/normal-components/Jumper.ts index cff2579..b2dea0f 100644 --- a/lib/components/normal-components/Jumper.ts +++ b/lib/components/normal-components/Jumper.ts @@ -21,26 +21,6 @@ export class Jumper extends NormalComponent< } } - initPorts() { - super.initPorts() - - const { _parsedProps: props } = this - - if (props.pinLabels) { - for (let [pinNumber, label] of Object.entries(props.pinLabels)) { - pinNumber = pinNumber.replace("pin", "") - const port = this.selectOne(`port[pinNumber='${pinNumber}']`) - if (!port) { - throw new Error( - `Could not find port for pin number ${pinNumber} in chip ${this.getString()}`, - ) - } - port.props.aliases.push(port.props.name) - port.props.name = label - } - } - } - doInitialSourceRender(): void { const { db } = this.project! const { _parsedProps: props } = this From 3757ecb905e555b94bb6cf326b5c5197db929e48 Mon Sep 17 00:00:00 2001 From: seveibar Date: Sat, 31 Aug 2024 21:26:15 -0700 Subject: [PATCH 8/8] update props to get schPortArrangement --- bun.lockb | Bin 120714 -> 120714 bytes package.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bun.lockb b/bun.lockb index 3938d8a10addd903688dbfae5d143a7949c656b8..7346269acdb91830acb60816f36ace9ea9ba492c 100755 GIT binary patch delta 154 zcmV;L0A>G*uLp{+2aqlxLNqveG%=gaQ=>w^4MhNIW8)o;Fc@n*^`L29U63hVu}&%- z0Wp(d6eqKw9hGK4O-W)iwH>bTUBDkRO0U7vDZ`!@6GxFf$#1rB@P;&FZ5GK$|0#$) zmyP6s-KVC8Nvvq{7#RvjyVRU74bO5(2N&yEr0Xdfe&;cs9 IU4j8ERiaQm5dZ)H delta 154 zcmV;L0A>G*uLp{+2aqlxC{0bpQ+XN3V;wQ$=uG&uyfI|~99W{E|COrVsl>jku}&%- z0Wgzc6eqKw9hGK4FtjO;;r5Ngz03x*1RZybdb(!Yc=C=yhB*kfxKU-qOHyYQHbc&Z zxE3Q;3ya3gEDVgJDvN_es82OWw4O}avvq{7#RvgjFfK4IG&r{_N&yEr0XUZd&;cs9 IU4j8ERq!W3`~Uy| diff --git a/package.json b/package.json index ccef5ff..51f70ae 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@tscircuit/infgrid-ijump-astar": "0.0.5", - "@tscircuit/props": "^0.0.48", + "@tscircuit/props": "^0.0.49", "@tscircuit/soup": "^0.0.58", "@tscircuit/soup-util": "0.0.18", "footprinter": "^0.0.44",