circuit-to-svg 0.0.260 → 0.0.261
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 +10 -2
- package/dist/index.js +176 -90
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ interface Options$4 {
|
|
|
46
46
|
width?: number;
|
|
47
47
|
height?: number;
|
|
48
48
|
shouldDrawErrors?: boolean;
|
|
49
|
+
showErrorsInTextOverlay?: boolean;
|
|
49
50
|
shouldDrawRatsNest?: boolean;
|
|
50
51
|
showCourtyards?: boolean;
|
|
51
52
|
showPcbGroups?: boolean;
|
|
@@ -77,6 +78,7 @@ interface Options$3 {
|
|
|
77
78
|
width?: number;
|
|
78
79
|
height?: number;
|
|
79
80
|
includeVersion?: boolean;
|
|
81
|
+
showErrorsInTextOverlay?: boolean;
|
|
80
82
|
}
|
|
81
83
|
interface AssemblySvgContext {
|
|
82
84
|
transform: Matrix;
|
|
@@ -101,6 +103,7 @@ interface Options$2 {
|
|
|
101
103
|
width?: number;
|
|
102
104
|
height?: number;
|
|
103
105
|
includeVersion?: boolean;
|
|
106
|
+
showErrorsInTextOverlay?: boolean;
|
|
104
107
|
}
|
|
105
108
|
interface PinoutLabel {
|
|
106
109
|
pcb_port: PcbPort;
|
|
@@ -301,6 +304,7 @@ interface Options$1 {
|
|
|
301
304
|
label: string;
|
|
302
305
|
}>;
|
|
303
306
|
includeVersion?: boolean;
|
|
307
|
+
showErrorsInTextOverlay?: boolean;
|
|
304
308
|
}
|
|
305
309
|
declare function convertCircuitJsonToSchematicSvg(circuitJson: AnyCircuitElement[], options?: Options$1): string;
|
|
306
310
|
/**
|
|
@@ -322,14 +326,16 @@ interface ConvertSchematicSimulationParams {
|
|
|
322
326
|
schematicHeightRatio?: number;
|
|
323
327
|
schematicOptions?: Omit<Parameters<typeof convertCircuitJsonToSchematicSvg>[1], "width" | "height" | "includeVersion">;
|
|
324
328
|
includeVersion?: boolean;
|
|
329
|
+
showErrorsInTextOverlay?: boolean;
|
|
325
330
|
}
|
|
326
|
-
declare function convertCircuitJsonToSchematicSimulationSvg({ circuitJson, simulation_experiment_id, simulation_transient_voltage_graph_ids, width, height, schematicHeightRatio, schematicOptions, includeVersion, }: ConvertSchematicSimulationParams): string;
|
|
331
|
+
declare function convertCircuitJsonToSchematicSimulationSvg({ circuitJson, simulation_experiment_id, simulation_transient_voltage_graph_ids, width, height, schematicHeightRatio, schematicOptions, includeVersion, showErrorsInTextOverlay, }: ConvertSchematicSimulationParams): string;
|
|
327
332
|
|
|
328
333
|
interface Options {
|
|
329
334
|
layer: "top" | "bottom";
|
|
330
335
|
width?: number;
|
|
331
336
|
height?: number;
|
|
332
337
|
includeVersion?: boolean;
|
|
338
|
+
showErrorsInTextOverlay?: boolean;
|
|
333
339
|
}
|
|
334
340
|
declare function convertCircuitJsonToSolderPasteMask(circuitJson: AnyCircuitElement[], options: Options): string;
|
|
335
341
|
|
|
@@ -353,4 +359,6 @@ declare const createSvgObjectsForSchComponentPortHovers: ({ component, transform
|
|
|
353
359
|
circuitJson: AnyCircuitElement[];
|
|
354
360
|
}) => INode[];
|
|
355
361
|
|
|
356
|
-
|
|
362
|
+
declare function createErrorTextOverlay(circuitJson: AnyCircuitElement[], dataType?: string): INode | null;
|
|
363
|
+
|
|
364
|
+
export { type AssemblySvgContext, CIRCUIT_TO_SVG_VERSION, type CircuitJsonWithSimulation, type ColorMap, type ColorOverrides, type PcbColorMap, type PcbColorOverrides, type PcbContext, type PinoutLabel, type PinoutSvgContext, circuitJsonToPcbSvg, circuitJsonToSchematicSvg, convertCircuitJsonToAssemblySvg, convertCircuitJsonToPcbSvg, convertCircuitJsonToPinoutSvg, convertCircuitJsonToSchematicSimulationSvg, convertCircuitJsonToSchematicSvg, convertCircuitJsonToSimulationGraphSvg, convertCircuitJsonToSolderPasteMask, createErrorTextOverlay, createSvgObjectsForSchComponentPortHovers, getSoftwareUsedString, isSimulationExperiment, isSimulationTransientVoltageGraph, isSimulationVoltageProbe };
|
package/dist/index.js
CHANGED
|
@@ -3502,7 +3502,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
3502
3502
|
var package_default = {
|
|
3503
3503
|
name: "circuit-to-svg",
|
|
3504
3504
|
type: "module",
|
|
3505
|
-
version: "0.0.
|
|
3505
|
+
version: "0.0.260",
|
|
3506
3506
|
description: "Convert Circuit JSON to SVG",
|
|
3507
3507
|
main: "dist/index.js",
|
|
3508
3508
|
files: [
|
|
@@ -3625,6 +3625,53 @@ function getTypePriority(type) {
|
|
|
3625
3625
|
return TYPE_PRIORITY[type] ?? DEFAULT_TYPE_PRIORITY;
|
|
3626
3626
|
}
|
|
3627
3627
|
|
|
3628
|
+
// lib/utils/create-error-text-overlay.ts
|
|
3629
|
+
function createErrorTextOverlay(circuitJson, dataType = "error_text_overlay") {
|
|
3630
|
+
const errorElms = circuitJson.filter(
|
|
3631
|
+
(elm) => elm.type.endsWith("_error")
|
|
3632
|
+
);
|
|
3633
|
+
if (errorElms.length === 0) {
|
|
3634
|
+
return null;
|
|
3635
|
+
}
|
|
3636
|
+
const errorMessages = errorElms.map((e) => e.message).filter((m) => !!m);
|
|
3637
|
+
if (errorMessages.length === 0) {
|
|
3638
|
+
return null;
|
|
3639
|
+
}
|
|
3640
|
+
const textBlock = {
|
|
3641
|
+
name: "text",
|
|
3642
|
+
type: "element",
|
|
3643
|
+
value: "",
|
|
3644
|
+
attributes: {
|
|
3645
|
+
x: "10",
|
|
3646
|
+
y: "20",
|
|
3647
|
+
fill: "red",
|
|
3648
|
+
"font-family": "monospace",
|
|
3649
|
+
"font-size": "12px",
|
|
3650
|
+
"data-type": dataType,
|
|
3651
|
+
"data-layer": "global"
|
|
3652
|
+
},
|
|
3653
|
+
children: errorMessages.map((msg, i) => ({
|
|
3654
|
+
name: "tspan",
|
|
3655
|
+
type: "element",
|
|
3656
|
+
value: "",
|
|
3657
|
+
attributes: {
|
|
3658
|
+
x: "10",
|
|
3659
|
+
dy: i === 0 ? "0" : "1.2em"
|
|
3660
|
+
},
|
|
3661
|
+
children: [
|
|
3662
|
+
{
|
|
3663
|
+
type: "text",
|
|
3664
|
+
value: msg,
|
|
3665
|
+
name: "",
|
|
3666
|
+
attributes: {},
|
|
3667
|
+
children: []
|
|
3668
|
+
}
|
|
3669
|
+
]
|
|
3670
|
+
}))
|
|
3671
|
+
};
|
|
3672
|
+
return textBlock;
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3628
3675
|
// lib/pcb/convert-circuit-json-to-pcb-svg.ts
|
|
3629
3676
|
function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
3630
3677
|
const drawPaddingOutsideBoard = options?.drawPaddingOutsideBoard ?? true;
|
|
@@ -3859,6 +3906,15 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
3859
3906
|
if (gridObjects.rect) {
|
|
3860
3907
|
children.push(gridObjects.rect);
|
|
3861
3908
|
}
|
|
3909
|
+
if (options?.showErrorsInTextOverlay) {
|
|
3910
|
+
const errorOverlay = createErrorTextOverlay(
|
|
3911
|
+
circuitJson,
|
|
3912
|
+
"pcb_error_text_overlay"
|
|
3913
|
+
);
|
|
3914
|
+
if (errorOverlay) {
|
|
3915
|
+
children.push(errorOverlay);
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3862
3918
|
const softwareUsedString = getSoftwareUsedString(circuitJson);
|
|
3863
3919
|
const version = CIRCUIT_TO_SVG_VERSION;
|
|
3864
3920
|
const svgObject = {
|
|
@@ -4865,29 +4921,14 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
4865
4921
|
).flatMap((item) => createSvgObjects2(item, ctx, soup));
|
|
4866
4922
|
const softwareUsedString = getSoftwareUsedString(soup);
|
|
4867
4923
|
const version = CIRCUIT_TO_SVG_VERSION;
|
|
4868
|
-
const
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
"data-software-used-string": softwareUsedString
|
|
4877
|
-
},
|
|
4878
|
-
...options?.includeVersion && {
|
|
4879
|
-
"data-circuit-to-svg-version": version
|
|
4880
|
-
}
|
|
4881
|
-
},
|
|
4882
|
-
value: "",
|
|
4883
|
-
children: [
|
|
4884
|
-
{
|
|
4885
|
-
name: "style",
|
|
4886
|
-
type: "element",
|
|
4887
|
-
children: [
|
|
4888
|
-
{
|
|
4889
|
-
type: "text",
|
|
4890
|
-
value: `
|
|
4924
|
+
const children = [
|
|
4925
|
+
{
|
|
4926
|
+
name: "style",
|
|
4927
|
+
type: "element",
|
|
4928
|
+
children: [
|
|
4929
|
+
{
|
|
4930
|
+
type: "text",
|
|
4931
|
+
value: `
|
|
4891
4932
|
.assembly-component {
|
|
4892
4933
|
fill: none;
|
|
4893
4934
|
stroke: #000;
|
|
@@ -4910,30 +4951,52 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
4910
4951
|
stroke-width: 0.2;
|
|
4911
4952
|
}
|
|
4912
4953
|
`,
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4954
|
+
name: "",
|
|
4955
|
+
attributes: {},
|
|
4956
|
+
children: []
|
|
4957
|
+
}
|
|
4958
|
+
],
|
|
4959
|
+
value: "",
|
|
4960
|
+
attributes: {}
|
|
4961
|
+
},
|
|
4962
|
+
{
|
|
4963
|
+
name: "rect",
|
|
4964
|
+
type: "element",
|
|
4965
|
+
attributes: {
|
|
4966
|
+
fill: "#fff",
|
|
4967
|
+
x: "0",
|
|
4968
|
+
y: "0",
|
|
4969
|
+
width: svgWidth.toString(),
|
|
4970
|
+
height: svgHeight.toString()
|
|
4920
4971
|
},
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4972
|
+
value: "",
|
|
4973
|
+
children: []
|
|
4974
|
+
},
|
|
4975
|
+
createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY),
|
|
4976
|
+
...svgObjects
|
|
4977
|
+
].filter((child) => child !== null);
|
|
4978
|
+
if (options?.showErrorsInTextOverlay) {
|
|
4979
|
+
const errorOverlay = createErrorTextOverlay(soup);
|
|
4980
|
+
if (errorOverlay) {
|
|
4981
|
+
children.push(errorOverlay);
|
|
4982
|
+
}
|
|
4983
|
+
}
|
|
4984
|
+
const svgObject = {
|
|
4985
|
+
name: "svg",
|
|
4986
|
+
type: "element",
|
|
4987
|
+
attributes: {
|
|
4988
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4989
|
+
width: svgWidth.toString(),
|
|
4990
|
+
height: svgHeight.toString(),
|
|
4991
|
+
...softwareUsedString && {
|
|
4992
|
+
"data-software-used-string": softwareUsedString
|
|
4933
4993
|
},
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4994
|
+
...options?.includeVersion && {
|
|
4995
|
+
"data-circuit-to-svg-version": version
|
|
4996
|
+
}
|
|
4997
|
+
},
|
|
4998
|
+
value: "",
|
|
4999
|
+
children
|
|
4937
5000
|
};
|
|
4938
5001
|
return stringify2(svgObject);
|
|
4939
5002
|
}
|
|
@@ -6230,6 +6293,28 @@ function convertCircuitJsonToPinoutSvg(soup, options) {
|
|
|
6230
6293
|
).flatMap((item) => createSvgObjects3(item, ctx, soup));
|
|
6231
6294
|
const softwareUsedString = getSoftwareUsedString(soup);
|
|
6232
6295
|
const version = CIRCUIT_TO_SVG_VERSION;
|
|
6296
|
+
const children = [
|
|
6297
|
+
{
|
|
6298
|
+
name: "rect",
|
|
6299
|
+
type: "element",
|
|
6300
|
+
attributes: {
|
|
6301
|
+
fill: "rgb(255, 255, 255)",
|
|
6302
|
+
x: "0",
|
|
6303
|
+
y: "0",
|
|
6304
|
+
width: svgWidth.toString(),
|
|
6305
|
+
height: svgHeight.toString()
|
|
6306
|
+
},
|
|
6307
|
+
value: "",
|
|
6308
|
+
children: []
|
|
6309
|
+
},
|
|
6310
|
+
...svgObjects
|
|
6311
|
+
].filter((child) => child !== null);
|
|
6312
|
+
if (options?.showErrorsInTextOverlay) {
|
|
6313
|
+
const errorOverlay = createErrorTextOverlay(soup);
|
|
6314
|
+
if (errorOverlay) {
|
|
6315
|
+
children.push(errorOverlay);
|
|
6316
|
+
}
|
|
6317
|
+
}
|
|
6233
6318
|
const svgObject = {
|
|
6234
6319
|
name: "svg",
|
|
6235
6320
|
type: "element",
|
|
@@ -6245,22 +6330,7 @@ function convertCircuitJsonToPinoutSvg(soup, options) {
|
|
|
6245
6330
|
}
|
|
6246
6331
|
},
|
|
6247
6332
|
value: "",
|
|
6248
|
-
children
|
|
6249
|
-
{
|
|
6250
|
-
name: "rect",
|
|
6251
|
-
type: "element",
|
|
6252
|
-
attributes: {
|
|
6253
|
-
fill: "rgb(255, 255, 255)",
|
|
6254
|
-
x: "0",
|
|
6255
|
-
y: "0",
|
|
6256
|
-
width: svgWidth.toString(),
|
|
6257
|
-
height: svgHeight.toString()
|
|
6258
|
-
},
|
|
6259
|
-
value: "",
|
|
6260
|
-
children: []
|
|
6261
|
-
},
|
|
6262
|
-
...svgObjects
|
|
6263
|
-
].filter((child) => child !== null)
|
|
6333
|
+
children
|
|
6264
6334
|
};
|
|
6265
6335
|
return stringify3(svgObject);
|
|
6266
6336
|
}
|
|
@@ -9781,6 +9851,12 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
|
|
|
9781
9851
|
}
|
|
9782
9852
|
const softwareUsedString = getSoftwareUsedString(circuitJson);
|
|
9783
9853
|
const version = CIRCUIT_TO_SVG_VERSION;
|
|
9854
|
+
if (options?.showErrorsInTextOverlay) {
|
|
9855
|
+
const errorOverlay = createErrorTextOverlay(circuitJson);
|
|
9856
|
+
if (errorOverlay) {
|
|
9857
|
+
svgChildren.push(errorOverlay);
|
|
9858
|
+
}
|
|
9859
|
+
}
|
|
9784
9860
|
const svgObject = {
|
|
9785
9861
|
name: "svg",
|
|
9786
9862
|
type: "element",
|
|
@@ -10476,7 +10552,8 @@ function convertCircuitJsonToSchematicSimulationSvg({
|
|
|
10476
10552
|
height = DEFAULT_HEIGHT2,
|
|
10477
10553
|
schematicHeightRatio = DEFAULT_SCHEMATIC_RATIO,
|
|
10478
10554
|
schematicOptions,
|
|
10479
|
-
includeVersion
|
|
10555
|
+
includeVersion,
|
|
10556
|
+
showErrorsInTextOverlay
|
|
10480
10557
|
}) {
|
|
10481
10558
|
const schematicElements = circuitJson.filter(
|
|
10482
10559
|
(element) => !isSimulationExperiment(element) && !isSimulationTransientVoltageGraph(element)
|
|
@@ -10492,7 +10569,8 @@ function convertCircuitJsonToSchematicSimulationSvg({
|
|
|
10492
10569
|
...schematicOptions,
|
|
10493
10570
|
width,
|
|
10494
10571
|
height: schematicHeight,
|
|
10495
|
-
includeVersion: false
|
|
10572
|
+
includeVersion: false,
|
|
10573
|
+
showErrorsInTextOverlay
|
|
10496
10574
|
});
|
|
10497
10575
|
const simulationSvg = convertCircuitJsonToSimulationGraphSvg({
|
|
10498
10576
|
circuitJson,
|
|
@@ -10733,6 +10811,38 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
10733
10811
|
).flatMap((item) => createSvgObjects4({ elm: item, ctx }));
|
|
10734
10812
|
const softwareUsedString = getSoftwareUsedString(circuitJson);
|
|
10735
10813
|
const version = CIRCUIT_TO_SVG_VERSION;
|
|
10814
|
+
const children = [
|
|
10815
|
+
{
|
|
10816
|
+
name: "style",
|
|
10817
|
+
type: "element",
|
|
10818
|
+
children: [
|
|
10819
|
+
{
|
|
10820
|
+
type: "text",
|
|
10821
|
+
value: ""
|
|
10822
|
+
}
|
|
10823
|
+
]
|
|
10824
|
+
},
|
|
10825
|
+
{
|
|
10826
|
+
name: "rect",
|
|
10827
|
+
type: "element",
|
|
10828
|
+
attributes: {
|
|
10829
|
+
class: "boundary",
|
|
10830
|
+
x: "0",
|
|
10831
|
+
y: "0",
|
|
10832
|
+
fill: "#000",
|
|
10833
|
+
width: svgWidth.toString(),
|
|
10834
|
+
height: svgHeight.toString()
|
|
10835
|
+
}
|
|
10836
|
+
},
|
|
10837
|
+
createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY),
|
|
10838
|
+
...svgObjects
|
|
10839
|
+
].filter((child) => child !== null);
|
|
10840
|
+
if (options?.showErrorsInTextOverlay) {
|
|
10841
|
+
const errorOverlay = createErrorTextOverlay(circuitJson);
|
|
10842
|
+
if (errorOverlay) {
|
|
10843
|
+
children.push(errorOverlay);
|
|
10844
|
+
}
|
|
10845
|
+
}
|
|
10736
10846
|
const svgObject = {
|
|
10737
10847
|
name: "svg",
|
|
10738
10848
|
type: "element",
|
|
@@ -10748,32 +10858,7 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
10748
10858
|
}
|
|
10749
10859
|
},
|
|
10750
10860
|
value: "",
|
|
10751
|
-
children
|
|
10752
|
-
{
|
|
10753
|
-
name: "style",
|
|
10754
|
-
type: "element",
|
|
10755
|
-
children: [
|
|
10756
|
-
{
|
|
10757
|
-
type: "text",
|
|
10758
|
-
value: ""
|
|
10759
|
-
}
|
|
10760
|
-
]
|
|
10761
|
-
},
|
|
10762
|
-
{
|
|
10763
|
-
name: "rect",
|
|
10764
|
-
type: "element",
|
|
10765
|
-
attributes: {
|
|
10766
|
-
class: "boundary",
|
|
10767
|
-
x: "0",
|
|
10768
|
-
y: "0",
|
|
10769
|
-
fill: "#000",
|
|
10770
|
-
width: svgWidth.toString(),
|
|
10771
|
-
height: svgHeight.toString()
|
|
10772
|
-
}
|
|
10773
|
-
},
|
|
10774
|
-
createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY),
|
|
10775
|
-
...svgObjects
|
|
10776
|
-
].filter((child) => child !== null)
|
|
10861
|
+
children
|
|
10777
10862
|
};
|
|
10778
10863
|
try {
|
|
10779
10864
|
return stringify7(svgObject);
|
|
@@ -10844,6 +10929,7 @@ export {
|
|
|
10844
10929
|
convertCircuitJsonToSchematicSvg,
|
|
10845
10930
|
convertCircuitJsonToSimulationGraphSvg,
|
|
10846
10931
|
convertCircuitJsonToSolderPasteMask,
|
|
10932
|
+
createErrorTextOverlay,
|
|
10847
10933
|
createSvgObjectsForSchComponentPortHovers,
|
|
10848
10934
|
getSoftwareUsedString,
|
|
10849
10935
|
isSimulationExperiment,
|