Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiboSoftwareDev committed Dec 23, 2024
2 parents 7fc7168 + 4af6554 commit 5a10e32
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 9 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/sch/convert-circuit-json-to-schematic-svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function convertCircuitJsonToSchematicSvg(
schTraceSvgs.push(...createSchematicTrace(elm, transform))
} else if (elm.type === "schematic_net_label") {
schNetLabel.push(...createSvgObjectsForSchNetLabel(elm, transform))
} else if (elm.type === "schematic_text") {
} else if (elm.type === "schematic_text" && !elm.schematic_component_id) {
schText.push(createSvgSchText(elm, transform))
} else if (elm.type === "schematic_voltage_probe") {
voltageProbeSvgs.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { createSvgObjectsFromSchematicComponentWithSymbol } from "./create-svg-o
import { createSvgObjectsFromSchPortOnBox } from "./create-svg-objects-from-sch-port-on-box"
import { getSchStrokeSize } from "lib/utils/get-sch-stroke-size"
import { getSchScreenFontSize } from "lib/utils/get-sch-font-size"
import { createSvgSchText } from "./create-svg-objects-for-sch-text"

export const createSvgObjectsFromSchematicComponentWithBox = ({
component: schComponent,
Expand Down Expand Up @@ -72,6 +73,15 @@ export const createSvgObjectsFromSchematicComponentWithBox = ({
children: [],
})

const schTexts = su(circuitJson as any).schematic_text.list()

for (const schText of schTexts) {
if (
schText.schematic_component_id === schComponent.schematic_component_id
) {
svgObjects.push(createSvgSchText(schText, transform))
}
}
// // Process ports
const schematicPorts = su(circuitJson as any).schematic_port.list({
schematic_component_id: schComponent.schematic_component_id,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "circuit-to-svg",
"type": "module",
"version": "0.0.95",
"version": "0.0.96",
"description": "Convert Circuit JSON to SVG",
"main": "dist/index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion tests/sch/__snapshots__/kicad-theme-demo.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/sch/__snapshots__/rp2040.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion tests/sch/component-wrapper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ test("component wrapper has correct attributes", () => {

circuit.render()
const circuitJson = circuit.getCircuitJson()
const svg = convertCircuitJsonToSchematicSvg(circuitJson)
const svg = convertCircuitJsonToSchematicSvg(
circuitJson as SchematicComponent[],
)

expect(svg).toContain('data-circuit-json-type="schematic_component"')
expect(svg).toContain("data-schematic-component-id")
Expand Down
3 changes: 2 additions & 1 deletion tests/sch/resistor.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from "bun:test"
import type { AnyCircuitElement } from "circuit-json"
import { convertCircuitJsonToSchematicSvg } from "lib/index"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

Expand Down Expand Up @@ -30,7 +31,7 @@ test("schematic resistor", () => {
}
}
return elm
}),
}) as AnyCircuitElement[],
),
).toMatchSvgSnapshot(import.meta.path)
})
1 change: 1 addition & 0 deletions tests/sch/rotated-resistor.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from "bun:test"
import type { AnyCircuitElement } from "circuit-json"
import { convertCircuitJsonToSchematicSvg } from "lib"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

Expand Down
5 changes: 4 additions & 1 deletion tests/sch/trace-overlap.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from "bun:test"
import type { AnyCircuitElement } from "circuit-json"
import { convertCircuitJsonToSchematicSvg } from "lib"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

Expand Down Expand Up @@ -30,6 +31,8 @@ test("schematic trace overlap", () => {
)

expect(
convertCircuitJsonToSchematicSvg(circuit.getCircuitJson()),
convertCircuitJsonToSchematicSvg(
circuit.getCircuitJson() as AnyCircuitElement[],
),
).toMatchSvgSnapshot(import.meta.path)
})
1 change: 0 additions & 1 deletion tests/sch/transform-attribute.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ test("svg should have data-real-to-screen-transform attribute", () => {

// Extract the transform value and verify it's a valid matrix string
const match = svg.match(/data-real-to-screen-transform="([^"]+)"/)

// @ts-ignore
expect(match[1]).toMatchInlineSnapshot(
`"matrix(54.5454545455,0,0,-54.5454545455,600,300)"`,
Expand Down
3 changes: 2 additions & 1 deletion tests/sch/unknown-symbol.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from "bun:test"
import type { AnyCircuitElement } from "circuit-json"
import { convertCircuitJsonToSchematicSvg } from "lib"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

Expand Down Expand Up @@ -32,7 +33,7 @@ test("schematic rotated resistor", () => {
c.symbol_name = "INTENTIONALLY_NONEXISTENT_SYMBOL!!"
}
return c
}),
}) as AnyCircuitElement[],
),
).toMatchSvgSnapshot(import.meta.path)
})

0 comments on commit 5a10e32

Please sign in to comment.