Skip to content

Commit efb85e9

Browse files
committed
new approach: modify render
1 parent d2da37f commit efb85e9

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

lib/components/base-components/NormalComponent/NormalComponent_doInitialPcbFootprintStringRender.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export function NormalComponent_doInitialPcbFootprintStringRender(
5656
result.footprintCircuitJson,
5757
)
5858
component.addAll(fpComponents)
59-
component._markDirty("InitializePortsFromChildren")
6059
} catch (err) {
6160
const db = component.root?.db
6261
if (db && component.source_component_id && component.pcb_component_id) {
@@ -102,7 +101,6 @@ export function NormalComponent_doInitialPcbFootprintStringRender(
102101
soup as any,
103102
)
104103
component.addAll(fpComponents)
105-
component._markDirty("InitializePortsFromChildren")
106104
} catch (err) {
107105
const db = component.root?.db
108106
if (db && component.source_component_id && component.pcb_component_id) {
@@ -174,13 +172,6 @@ export function NormalComponent_doInitialPcbFootprintStringRender(
174172
if (!Array.isArray(result) && result.cadModel) {
175173
component._asyncFootprintCadModel = result.cadModel
176174
}
177-
// Ensure existing Ports re-run PcbPortRender now that pads exist
178-
for (const child of component.children) {
179-
if (child.componentName === "Port") {
180-
child._markDirty?.("PcbPortRender")
181-
}
182-
}
183-
component._markDirty("InitializePortsFromChildren")
184175
} catch (err) {
185176
const db = component.root?.db
186177
if (db && component.source_component_id && component.pcb_component_id) {

lib/components/base-components/Renderable.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,14 @@ export abstract class Renderable implements IRenderable {
307307
if (hasIncompleteEffects) return
308308
}
309309

310-
// Check declared async dependencies for this phase within subtree
311310
const deps = asyncPhaseDependencies[phase] || []
312311
for (const depPhase of deps) {
313-
if (this._hasIncompleteAsyncEffectsInSubtreeForPhase(depPhase)) return
312+
const root = (this as any).root
313+
const boardComponent = root?._getBoard?.() || root?.children?.[0] || this
314+
if (
315+
boardComponent._hasIncompleteAsyncEffectsInSubtreeForPhase?.(depPhase)
316+
)
317+
return
314318
}
315319

316320
this._emitRenderLifecycleEvent(phase, "start")
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { test, expect } from "bun:test"
2+
import { getTestFixture } from "tests/fixtures/get-test-fixture"
3+
import kicadModJson from "tests/fixtures/assets/R_0402_1005Metric.json" with {
4+
type: "json",
5+
}
6+
7+
test("trace pcbPath selectors work with kicad footprints", async () => {
8+
const { circuit } = getTestFixture()
9+
10+
circuit.platform = {
11+
footprintLibraryMap: {
12+
kicad: async (footprintName: string) => {
13+
return {
14+
footprintCircuitJson: kicadModJson,
15+
}
16+
},
17+
},
18+
}
19+
20+
circuit.add(
21+
<board width="10mm" height="10mm">
22+
<resistor
23+
name="R1"
24+
resistance="10k"
25+
footprint="kicad:Resistor_SMD/R_0402_1005Metric"
26+
pcbX={-3}
27+
pcbY={0}
28+
/>
29+
<resistor
30+
name="R2"
31+
resistance="10k"
32+
footprint="kicad:Resistor_SMD/R_0402_1005Metric"
33+
pcbX={3}
34+
pcbY={0}
35+
/>
36+
<trace
37+
from=".R1 > .pin2"
38+
to=".R2 > .pin1"
39+
pcbPathRelativeTo=".R1 > .pin2"
40+
pcbPath={["R1.pin2", { x: 0, y: 4 }, "R2.pin1"]}
41+
thickness="0.5mm"
42+
/>
43+
</board>,
44+
)
45+
46+
await circuit.renderUntilSettled()
47+
48+
const selectorErrors = circuit.db.pcb_trace_error
49+
.list()
50+
.filter((e) => e.message?.includes("Could not resolve pcbPath selector"))
51+
expect(selectorErrors.length).toBe(0)
52+
53+
const pcbTrace = circuit.db.pcb_trace.list()[0]
54+
expect(pcbTrace).toBeDefined()
55+
expect(pcbTrace.route.length).toBeGreaterThanOrEqual(3)
56+
57+
await expect(circuit).toMatchPcbSnapshot(import.meta.path)
58+
})

0 commit comments

Comments
 (0)