circuit-json-to-kicad 0.0.8 → 0.0.10
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.js +13 -32
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ import {
|
|
|
75
75
|
} from "kicadts";
|
|
76
76
|
import { symbols } from "schematic-symbols";
|
|
77
77
|
|
|
78
|
-
// lib/schematic/
|
|
78
|
+
// lib/schematic/getLibraryId.ts
|
|
79
79
|
function getLibraryId(sourceComp, schematicComp) {
|
|
80
80
|
if (sourceComp.type !== "source_component") {
|
|
81
81
|
if (schematicComp.symbol_name) {
|
|
@@ -114,47 +114,28 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
const libSymbols = new LibSymbols();
|
|
117
|
-
const symbolsToCreate = /* @__PURE__ */ new Set();
|
|
118
|
-
for (const comp of schematicComponents) {
|
|
119
|
-
if (comp.symbol_name) {
|
|
120
|
-
symbolsToCreate.add(comp.symbol_name);
|
|
121
|
-
} else {
|
|
122
|
-
const sourceComp = comp.source_component_id ? db.source_component.get(comp.source_component_id) : null;
|
|
123
|
-
if (sourceComp?.ftype === "simple_chip") {
|
|
124
|
-
symbolsToCreate.add(`generic_chip_${comp.source_component_id}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
117
|
const librarySymbols = [];
|
|
129
|
-
for (const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
118
|
+
for (const schematicComponent of schematicComponents) {
|
|
119
|
+
const sourceComp = schematicComponent.source_component_id ? db.source_component.get(schematicComponent.source_component_id) : null;
|
|
120
|
+
if (!sourceComp) continue;
|
|
121
|
+
const symbolName = schematicComponent.symbol_name || (sourceComp.ftype === "simple_chip" ? `generic_chip_${schematicComponent.source_component_id}` : null);
|
|
122
|
+
if (!symbolName) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
let symbolData;
|
|
133
126
|
if (symbolName.startsWith("generic_chip_")) {
|
|
134
|
-
|
|
135
|
-
sourceComp = db.source_component.get(sourceCompId);
|
|
136
|
-
exampleComp = schematicComponents.find(
|
|
137
|
-
(c) => c.source_component_id === sourceCompId
|
|
138
|
-
);
|
|
139
|
-
if (exampleComp) {
|
|
140
|
-
symbolData = this.createGenericChipSymbolData(exampleComp, db);
|
|
141
|
-
}
|
|
127
|
+
symbolData = this.createGenericChipSymbolData(schematicComponent, db);
|
|
142
128
|
} else {
|
|
143
129
|
symbolData = symbols[symbolName];
|
|
144
130
|
if (!symbolData) {
|
|
145
|
-
console.warn(`Symbol ${symbolName} not found in schematic-symbols`);
|
|
146
131
|
continue;
|
|
147
132
|
}
|
|
148
|
-
exampleComp = schematicComponents.find(
|
|
149
|
-
(c) => c.symbol_name === symbolName
|
|
150
|
-
);
|
|
151
|
-
sourceComp = exampleComp && exampleComp.source_component_id ? db.source_component.get(exampleComp.source_component_id) : null;
|
|
152
133
|
}
|
|
153
134
|
const libSymbol = this.createLibrarySymbolFromSchematicSymbol(
|
|
154
135
|
symbolName,
|
|
155
136
|
symbolData,
|
|
156
137
|
sourceComp,
|
|
157
|
-
|
|
138
|
+
schematicComponent
|
|
158
139
|
);
|
|
159
140
|
librarySymbols.push(libSymbol);
|
|
160
141
|
}
|
|
@@ -364,7 +345,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
364
345
|
isChip
|
|
365
346
|
);
|
|
366
347
|
pin.at = [x, y, angle];
|
|
367
|
-
pin.length = isChip ?
|
|
348
|
+
pin.length = isChip ? 6 : 1.27;
|
|
368
349
|
const nameFont = new TextEffectsFont();
|
|
369
350
|
nameFont.size = { height: 1.27, width: 1.27 };
|
|
370
351
|
const nameEffects = new TextEffects({ font: nameFont });
|
|
@@ -392,7 +373,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
392
373
|
const dy = port.y - center.y;
|
|
393
374
|
let x = port.x * symbolScale;
|
|
394
375
|
let y = port.y * symbolScale;
|
|
395
|
-
const chipPinLength =
|
|
376
|
+
const chipPinLength = 6;
|
|
396
377
|
if (isChip && size) {
|
|
397
378
|
const halfWidth = size.width / 2 * symbolScale;
|
|
398
379
|
const halfHeight = size.height / 2 * symbolScale;
|