circuit-to-svg 0.0.445 → 0.0.447
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/README.md +61 -0
- package/dist/index.d.ts +30 -2
- package/dist/index.js +6722 -6223
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -135,6 +135,67 @@ const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, {
|
|
|
135
135
|
- `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
|
|
136
136
|
the root `<svg>`.
|
|
137
137
|
|
|
138
|
+
## PCB return-current simulation overlays
|
|
139
|
+
|
|
140
|
+
Requires `circuit-json` 0.0.522 or later for the return-current schemas.
|
|
141
|
+
|
|
142
|
+
Pass `simulationResultId` to render one completed
|
|
143
|
+
`simulation_pcb_return_current_result` alongside the actual PCB. Other simulation
|
|
144
|
+
results remain hidden. The selected excitation traces appear in cyan on top and
|
|
145
|
+
orange on bottom; referenced signal/return pads and vias retain their actual PCB
|
|
146
|
+
positions. Return contacts are magenta. Ordinary PCB rendering remains unchanged
|
|
147
|
+
when this option is omitted.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { convertCircuitJsonToPcbSimulationSvg } from 'circuit-to-svg'
|
|
151
|
+
|
|
152
|
+
const svg = await convertCircuitJsonToPcbSimulationSvg(circuitJson, {
|
|
153
|
+
simulationResultId: 'simulation_pcb_return_current_result_0',
|
|
154
|
+
layer: 'inner1',
|
|
155
|
+
returnCurrent: { opacity: 0.65, showVectors: true },
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The asynchronous API loads embedded plain JSON or gzip field Assets, validates
|
|
160
|
+
decoded arrays with the official Circuit JSON schema, and then calls
|
|
161
|
+
`convertCircuitJsonToPcbSvg`. Supply `resolveAsset(asset)` to read external assets
|
|
162
|
+
explicitly; the library never performs network or filesystem requests itself.
|
|
163
|
+
Only the selected result/layer's assets are loaded.
|
|
164
|
+
|
|
165
|
+
The existing synchronous `convertCircuitJsonToPcbSvg` supports the same
|
|
166
|
+
`simulationResultId` and `returnCurrent` options. It displays stored heatmap image
|
|
167
|
+
URLs directly. To render fields or current arrows synchronously, supply decoded
|
|
168
|
+
grids as `returnCurrent.fieldData`, indexed by
|
|
169
|
+
`simulation_pcb_return_current_field_id`. Missing results, missing references,
|
|
170
|
+
unsupported layers, and field-only results without decoded data fail explicitly.
|
|
171
|
+
|
|
172
|
+
`returnCurrent` accepts:
|
|
173
|
+
|
|
174
|
+
- `opacity` (0–1, default 0.65) and `showLegend` (default true).
|
|
175
|
+
- `showVectors` (default false). Arrows show current direction when the
|
|
176
|
+
excitation current reaches its positive peak, with a fixed display length.
|
|
177
|
+
For complex fields this uses the in-phase real component. Producers should
|
|
178
|
+
normalize the complex source-current reference to its positive peak before
|
|
179
|
+
exporting results. Arrows do not represent measured via-transfer currents.
|
|
180
|
+
- `densityRange: { min, max }` for a common linear color scale of the average
|
|
181
|
+
current density through the copper thickness, in A/mm². With
|
|
182
|
+
decoded fields this replaces stored images, whose color scale is baked in.
|
|
183
|
+
Without a range, sampled fields use their maximum and stored images retain
|
|
184
|
+
their producer's colors.
|
|
185
|
+
- `fieldData` for already decoded field grids.
|
|
186
|
+
|
|
187
|
+
Sampled sheet-current magnitudes in A/mm are divided by `copper_thickness` in
|
|
188
|
+
millimeters to produce the magnitude of the current-density vector averaged
|
|
189
|
+
through the foil thickness, in A/mm². This does not give the local maximum
|
|
190
|
+
density within the skin layer. Complex magnitudes use the Euclidean phasor norm
|
|
191
|
+
and include both real and imaginary components. Rows start at the PCB bottom-left;
|
|
192
|
+
image top-left maps to `(min_x, max_y)`. Null cells remain empty; zero-current
|
|
193
|
+
copper remains visible. No solver runs or frequency approximations are performed
|
|
194
|
+
by the renderer. Its legend reports the frequency stored in the result, or says
|
|
195
|
+
when frequency was not specified.
|
|
196
|
+
|
|
197
|
+

|
|
198
|
+
|
|
138
199
|
## convertCircuitJsonToAssemblySvg
|
|
139
200
|
|
|
140
201
|
Converts circuit JSON into an assembly view of the board and components.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
import { LayerRef, AnyCircuitElement, PcbBoard, PcbPort, SimulationAnalysisResult, SimulationCurrentProbe, SimulationExperiment, SimulationOscilloscopeTrace, SimulationTransientCurrentGraph, SimulationTransientVoltageGraph, SimulationVoltageProbe, SchematicComponent } from 'circuit-json';
|
|
1
|
+
import { Asset, SimulationReturnCurrentGridJson, LayerRef, AnyCircuitElement, PcbBoard, PcbPort, SimulationAnalysisResult, SimulationCurrentProbe, SimulationExperiment, SimulationOscilloscopeTrace, SimulationTransientCurrentGraph, SimulationTransientVoltageGraph, SimulationVoltageProbe, SchematicComponent } from 'circuit-json';
|
|
2
2
|
export { SimulationAnalysisResult } from 'circuit-json';
|
|
3
3
|
import { Matrix } from 'transformation-matrix';
|
|
4
4
|
import { INode } from 'svgson';
|
|
5
5
|
|
|
6
|
+
interface PcbReturnCurrentOptions {
|
|
7
|
+
/** Opacity of the heatmap. Defaults to 0.65. */
|
|
8
|
+
opacity?: number;
|
|
9
|
+
/** Show current directions at the excitation's positive-current peak. */
|
|
10
|
+
showVectors?: boolean;
|
|
11
|
+
/** Decoded field assets, indexed by simulation_pcb_return_current_field_id. */
|
|
12
|
+
fieldData?: Readonly<Record<string, SimulationReturnCurrentGridJson>>;
|
|
13
|
+
/** Common linear scale for through-thickness average density in A/mm². Defaults to the field maximum. */
|
|
14
|
+
densityRange?: {
|
|
15
|
+
min: number;
|
|
16
|
+
max: number;
|
|
17
|
+
};
|
|
18
|
+
/** Show the result frequency, layer, units, and color legend. Defaults to true. */
|
|
19
|
+
showLegend?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface PcbReturnCurrentAssetOptions {
|
|
22
|
+
/** Resolve external assets explicitly; no network requests occur by default. */
|
|
23
|
+
resolveAsset?: (asset: Asset) => Promise<Uint8Array | string>;
|
|
24
|
+
}
|
|
25
|
+
|
|
6
26
|
interface PcbGridOptions {
|
|
7
27
|
cellSize: number;
|
|
8
28
|
lineColor?: string;
|
|
@@ -62,6 +82,9 @@ interface PcbColorOverrides {
|
|
|
62
82
|
type AnyCircuitJsonId = string;
|
|
63
83
|
|
|
64
84
|
interface PcbSvgOptions {
|
|
85
|
+
/** Overlay one completed PCB return-current result. Rendering remains opt-in. */
|
|
86
|
+
simulationResultId?: string;
|
|
87
|
+
returnCurrent?: PcbReturnCurrentOptions;
|
|
65
88
|
/** Resolved PCB element IDs to inspect together. Empty or omitted disables X-Ray. */
|
|
66
89
|
xRayElementIds?: readonly string[];
|
|
67
90
|
/** Opacity of other copper during X-Ray, between 0 and 1. Defaults to 0.2. */
|
|
@@ -144,6 +167,11 @@ declare function convertCircuitJsonToPcbSvg(circuitJson: AnyCircuitElement[], op
|
|
|
144
167
|
*/
|
|
145
168
|
declare const circuitJsonToPcbSvg: typeof convertCircuitJsonToPcbSvg;
|
|
146
169
|
|
|
170
|
+
/** Load only the selected result/layer's assets. No implicit network or filesystem access. */
|
|
171
|
+
declare function convertCircuitJsonToPcbSimulationSvg(circuitJson: AnyCircuitElement[], options: PcbSvgOptions & PcbReturnCurrentAssetOptions & {
|
|
172
|
+
simulationResultId: string;
|
|
173
|
+
}): Promise<string>;
|
|
174
|
+
|
|
147
175
|
interface Options$3 {
|
|
148
176
|
width?: number;
|
|
149
177
|
height?: number;
|
|
@@ -476,4 +504,4 @@ declare const createSvgObjectsForSchComponentPortHovers: ({ component, transform
|
|
|
476
504
|
|
|
477
505
|
declare function createErrorTextOverlay(circuitJson: AnyCircuitElement[], dataType?: string): INode | null;
|
|
478
506
|
|
|
479
|
-
export { type AcSweepView, type AssemblySvgContext, CIRCUIT_TO_SVG_VERSION, type CircuitJsonWithSimulation, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, type PcbSvgOptions, type PinoutLabel, type PinoutSvgContext, type StackedSchematicSheetsSvgOptions, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, colorMap, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToPinoutSvg, convertCircuitJsonToSchematicSimulationSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSimulationGraphSvg, convertCircuitJsonToSolderPasteMask, convertCircuitJsonToStackedSchematicSheetsSvg, createErrorTextOverlay, createSvgObjectsForSchComponentPortHovers, getSoftwareUsedString, isSimulationAnalysisResult, isSimulationCurrentProbe, isSimulationExperiment, isSimulationOscilloscopeTrace, isSimulationTransientCurrentGraph, isSimulationTransientVoltageGraph, isSimulationVoltageProbe };
|
|
507
|
+
export { type AcSweepView, type AssemblySvgContext, CIRCUIT_TO_SVG_VERSION, type CircuitJsonWithSimulation, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, type PcbReturnCurrentAssetOptions, type PcbReturnCurrentOptions, type PcbSvgOptions, type PinoutLabel, type PinoutSvgContext, type StackedSchematicSheetsSvgOptions, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, colorMap, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSimulationSvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToPinoutSvg, convertCircuitJsonToSchematicSimulationSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSimulationGraphSvg, convertCircuitJsonToSolderPasteMask, convertCircuitJsonToStackedSchematicSheetsSvg, createErrorTextOverlay, createSvgObjectsForSchComponentPortHovers, getSoftwareUsedString, isSimulationAnalysisResult, isSimulationCurrentProbe, isSimulationExperiment, isSimulationOscilloscopeTrace, isSimulationTransientCurrentGraph, isSimulationTransientVoltageGraph, isSimulationVoltageProbe };
|