circuitjson-toolkit 1.0.3 → 1.0.16
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/AGENTS.md +5 -3
- package/README.md +21 -2
- package/docs/api.md +50 -4
- package/docs/model-format.md +21 -3
- package/package.json +3 -2
- package/spec/library-scope.md +4 -1
- package/src/core/CircuitJsonBomBuilder.mjs +143 -0
- package/src/core/CircuitJsonDocument.mjs +46 -13
- package/src/core/CircuitJsonElementValidator.mjs +990 -0
- package/src/core/CircuitJsonIndexer.mjs +773 -4
- package/src/core/CircuitJsonManufacturingBuilder.mjs +898 -0
- package/src/core/CircuitJsonManufacturingDownloadBuilder.mjs +196 -0
- package/src/core/CircuitJsonParser.mjs +22 -6
- package/src/core/CircuitJsonPcbClearanceDiagnostics.mjs +329 -0
- package/src/core/CircuitJsonPcbCopperGeometry.mjs +503 -0
- package/src/core/CircuitJsonPcbDrawingStyle.mjs +88 -0
- package/src/core/CircuitJsonPcbHolePrimitiveModel.mjs +172 -0
- package/src/core/CircuitJsonPcbNetMetadata.mjs +247 -0
- package/src/core/CircuitJsonPcbPadPrimitiveModel.mjs +70 -0
- package/src/core/CircuitJsonPcbPrimitiveArtwork.mjs +992 -0
- package/src/core/CircuitJsonPcbPrimitiveBuilder.mjs +872 -0
- package/src/core/CircuitJsonPcbPrimitiveFields.mjs +233 -0
- package/src/core/CircuitJsonPcbPrimitiveGeometry.mjs +142 -0
- package/src/core/CircuitJsonPcbPrimitiveGroups.mjs +305 -0
- package/src/core/CircuitJsonPcbPrimitiveIndex.mjs +65 -0
- package/src/core/CircuitJsonPcbPrimitiveOverlays.mjs +895 -0
- package/src/core/CircuitJsonPcbTraceLengthModel.mjs +257 -0
- package/src/core/CircuitJsonPcbZonePrimitiveBuilder.mjs +683 -0
- package/src/core/CircuitJsonSourceMetadata.mjs +233 -0
- package/src/core/CircuitJsonSupportMatrixBuilder.mjs +481 -0
- package/src/core/CircuitJsonUnits.mjs +133 -8
- package/src/core/PcbBoundsSelectionModel.mjs +250 -0
- package/src/core/PcbCandidateSelectionModel.mjs +77 -0
- package/src/core/PcbDiagnosticFocusModel.mjs +423 -0
- package/src/core/PcbInteractionPrimitiveModel.mjs +560 -0
- package/src/core/SelectedPartCircuitJsonExportAdapter.mjs +335 -0
- package/src/core/spice/SpiceCompatibilityPreprocessor.mjs +139 -0
- package/src/core/spice/SpiceDirectiveParser.mjs +231 -0
- package/src/core/spice/SpiceFallbackSimulationEngine.mjs +168 -0
- package/src/core/spice/SpiceSimulationDiagnostics.mjs +234 -0
- package/src/core/spice/SpiceSimulationGraphBuilder.mjs +421 -0
- package/src/core/spice/SpiceSimulationGraphSummary.mjs +90 -0
- package/src/core/spice/SpiceSimulationService.mjs +92 -0
- package/src/core/spice/SpiceTimeSeriesNormalizer.mjs +132 -0
- package/src/index.mjs +8 -0
- package/src/renderers.mjs +29 -0
- package/src/ui/CircuitJsonPcbPrimitiveAttributeRenderer.mjs +128 -0
- package/src/ui/CircuitJsonPcbSvgRenderer.mjs +964 -0
- package/src/ui/CircuitJsonPcbViaSvgRenderer.mjs +168 -0
- package/src/ui/CircuitJsonSchematicSvgArcPath.mjs +138 -0
- package/src/ui/CircuitJsonSchematicSvgPortMetadata.mjs +114 -0
- package/src/ui/CircuitJsonSchematicSvgPrimitiveAttributes.mjs +130 -0
- package/src/ui/CircuitJsonSchematicSvgRenderer.mjs +994 -0
- package/src/ui/CircuitJsonSchematicTableSvgRenderer.mjs +439 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CircuitJsonIndexer } from './CircuitJsonIndexer.mjs'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builds PCB primitive element indexes with a tolerant local fallback.
|
|
5
|
+
*/
|
|
6
|
+
export class CircuitJsonPcbPrimitiveIndex {
|
|
7
|
+
/**
|
|
8
|
+
* Builds an element index while tolerating newer drawable row types.
|
|
9
|
+
* @param {object[]} elements CircuitJSON elements.
|
|
10
|
+
* @returns {{ elements: object[], elementsByType: Map<string, object[]>, sourceComponentById: Map<string, object>, pcbComponentById: Map<string, object> }}
|
|
11
|
+
*/
|
|
12
|
+
static build(elements) {
|
|
13
|
+
try {
|
|
14
|
+
return CircuitJsonIndexer.index(elements)
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (!CircuitJsonPcbPrimitiveIndex.#isUnknownTypeError(error)) {
|
|
17
|
+
throw error
|
|
18
|
+
}
|
|
19
|
+
return CircuitJsonPcbPrimitiveIndex.#localIndex(elements)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns true when a validator error is limited to a newer type name.
|
|
25
|
+
* @param {unknown} error Candidate error.
|
|
26
|
+
* @returns {boolean}
|
|
27
|
+
*/
|
|
28
|
+
static #isUnknownTypeError(error) {
|
|
29
|
+
return /Unsupported CircuitJSON element type:/u.test(
|
|
30
|
+
String(error?.message || '')
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Builds the subset of index data required by PCB primitive projection.
|
|
36
|
+
* @param {object[]} elements CircuitJSON elements.
|
|
37
|
+
* @returns {{ elements: object[], elementsByType: Map<string, object[]>, sourceComponentById: Map<string, object>, pcbComponentById: Map<string, object> }}
|
|
38
|
+
*/
|
|
39
|
+
static #localIndex(elements) {
|
|
40
|
+
const index = {
|
|
41
|
+
elements,
|
|
42
|
+
elementsByType: new Map(),
|
|
43
|
+
sourceComponentById: new Map(),
|
|
44
|
+
pcbComponentById: new Map()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
for (const element of elements) {
|
|
48
|
+
const type = String(element?.type || '')
|
|
49
|
+
if (!index.elementsByType.has(type)) {
|
|
50
|
+
index.elementsByType.set(type, [])
|
|
51
|
+
}
|
|
52
|
+
index.elementsByType.get(type).push(element)
|
|
53
|
+
|
|
54
|
+
const id = CircuitJsonIndexer.getElementId(element)
|
|
55
|
+
if (type === 'source_component' && id) {
|
|
56
|
+
index.sourceComponentById.set(id, element)
|
|
57
|
+
}
|
|
58
|
+
if (type === 'pcb_component' && id) {
|
|
59
|
+
index.pcbComponentById.set(id, element)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return index
|
|
64
|
+
}
|
|
65
|
+
}
|