circuitjson-toolkit 1.0.16 → 1.1.0
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 +15 -0
- package/NOTICE.md +31 -0
- package/README.md +267 -107
- package/docs/api.md +501 -96
- package/docs/capabilities.md +70 -0
- package/docs/migration/behaviors.md +45 -0
- package/docs/migration/parser.md +60 -0
- package/docs/migration/renderers.md +515 -0
- package/docs/migration/root.md +740 -0
- package/docs/migration.md +120 -0
- package/docs/model-format.md +175 -57
- package/docs/provenance.md +206 -0
- package/docs/release-notes-v1.1.0.md +154 -0
- package/docs/testing.md +117 -7
- package/package.json +31 -5
- package/spec/api-baseline-v1.0.17.json +1 -0
- package/spec/baseline-provenance-v1.0.17.json +7 -0
- package/spec/circuitjson-schema-snapshot.json +321 -0
- package/spec/circuitjson-schema-source.json +28 -0
- package/spec/feature-preservation.json +1 -0
- package/spec/library-scope.md +27 -20
- package/src/capabilities.mjs +1 -0
- package/src/core/ArchiveEntryPath.mjs +93 -0
- package/src/core/ArchiveLimits.mjs +31 -0
- package/src/core/ArchiveLimitsValidator.mjs +107 -0
- package/src/core/AsyncInputOwnership.mjs +56 -0
- package/src/core/AttachedValueLimits.mjs +67 -0
- package/src/core/CircuitJsonDiagnosticIndexer.mjs +184 -0
- package/src/core/CircuitJsonDocument.mjs +19 -61
- package/src/core/CircuitJsonElementTypes.mjs +10 -0
- package/src/core/CircuitJsonElementValidator.mjs +98 -847
- package/src/core/CircuitJsonIndexer.mjs +274 -194
- package/src/core/CircuitJsonManufacturingBuilder.mjs +167 -164
- package/src/core/CircuitJsonParser.mjs +75 -13
- package/src/core/CircuitJsonPcbClearanceDiagnostics.mjs +12 -6
- package/src/core/CircuitJsonPcbHolePrimitiveModel.mjs +108 -10
- package/src/core/CircuitJsonPcbPadPrimitiveModel.mjs +1 -1
- package/src/core/CircuitJsonPcbPrimitiveArtwork.mjs +44 -38
- package/src/core/CircuitJsonPcbPrimitiveBuilder.mjs +146 -28
- package/src/core/CircuitJsonPcbPrimitiveFields.mjs +70 -4
- package/src/core/CircuitJsonPcbPrimitiveIndex.mjs +18 -2
- package/src/core/CircuitJsonPcbPrimitiveOverlays.mjs +26 -9
- package/src/core/CircuitJsonPcbZonePrimitiveBuilder.mjs +7 -6
- package/src/core/CircuitJsonSerializedInputAudit.mjs +87 -0
- package/src/core/CircuitJsonSourceMetadata.mjs +5 -1
- package/src/core/CircuitJsonSupportMatrixBuilder.mjs +3 -1
- package/src/core/CircuitJsonToolkitElementSchema.mjs +218 -0
- package/src/core/CircuitJsonUnitParsers.mjs +101 -0
- package/src/core/CircuitJsonUnits.mjs +13 -87
- package/src/core/CircuitJsonUpstreamSchema.mjs +9 -0
- package/src/core/CircuitJsonUpstreamValidator.mjs +418 -0
- package/src/core/CircuitJsonValidationUnits.mjs +6 -0
- package/src/core/ManufacturingService.mjs +323 -0
- package/src/core/Parser.mjs +343 -0
- package/src/core/ParserOptions.mjs +333 -0
- package/src/core/PcbBoundsSelectionModel.mjs +55 -19
- package/src/core/PcbDiagnosticFocusModel.mjs +42 -11
- package/src/core/PcbInteractionIndex.mjs +368 -0
- package/src/core/PcbInteractionPrimitiveModel.mjs +393 -62
- package/src/core/ProjectAsyncInputOwner.mjs +70 -0
- package/src/core/ProjectLoader.mjs +975 -0
- package/src/core/SimulationService.mjs +790 -0
- package/src/core/ToolkitCapabilities.mjs +130 -0
- package/src/core/ZipArchiveInspector.mjs +649 -0
- package/src/core/context/BinaryDataSnapshot.mjs +217 -0
- package/src/core/context/CircuitJsonContextIndexes.mjs +96 -0
- package/src/core/context/CircuitJsonDerivedCache.mjs +114 -0
- package/src/core/context/CircuitJsonDocumentContext.mjs +353 -0
- package/src/core/context/CircuitJsonLegacyModel.mjs +147 -0
- package/src/core/context/CircuitJsonLegacyNormalizer.mjs +847 -0
- package/src/core/context/CircuitJsonMetadataBoundary.mjs +76 -0
- package/src/core/context/CircuitJsonModelFreezeTraversal.mjs +179 -0
- package/src/core/context/CircuitJsonReadOnlyDocument.mjs +920 -0
- package/src/core/context/CircuitJsonSchematicTableNormalizer.mjs +314 -0
- package/src/core/context/CircuitJsonValidationAuthority.mjs +39 -0
- package/src/core/context/CircuitJsonValidationProof.mjs +217 -0
- package/src/core/context/PcbPrimitivePreparation.mjs +198 -0
- package/src/core/context/PcbSpatialIndex.mjs +701 -0
- package/src/core/context/ProtectedExtensionBinaryBoundary.mjs +128 -0
- package/src/core/context/StructuredDataSnapshot.mjs +683 -0
- package/src/core/contracts/DocumentResult.mjs +198 -0
- package/src/core/contracts/ProjectResult.mjs +96 -0
- package/src/core/contracts/RuntimeProxyBoundary.mjs +48 -0
- package/src/core/contracts/ToolkitAsset.mjs +493 -0
- package/src/core/contracts/ToolkitDiagnostic.mjs +38 -0
- package/src/core/contracts/ToolkitError.mjs +176 -0
- package/src/core/contracts/ToolkitProgress.mjs +89 -0
- package/src/core/interaction/CanonicalInteractionOptions.mjs +246 -0
- package/src/core/interaction/PcbInteractionBounds.mjs +167 -0
- package/src/core/query/CircuitTraversal.mjs +343 -0
- package/src/core/query/ComponentGrouping.mjs +275 -0
- package/src/core/query/QueryNetlistBuilder.mjs +306 -0
- package/src/core/query/QueryService.mjs +435 -0
- package/src/core/query/RegexPattern.mjs +75 -0
- package/src/core/rendering/CanonicalBomOrder.mjs +81 -0
- package/src/core/rendering/CanonicalBomRows.mjs +92 -0
- package/src/core/rendering/CanonicalRenderOptions.mjs +498 -0
- package/src/core/rendering/CanonicalSvgDocument.mjs +102 -0
- package/src/core/rendering/PcbRenderPlan.mjs +429 -0
- package/src/core/rendering/SchematicSheetSelector.mjs +335 -0
- package/src/core/scene3d/PcbScene3dBuilder.mjs +906 -0
- package/src/core/scene3d/PcbScene3dPreparator.mjs +47 -0
- package/src/core/scene3d/Scene3dAssetIndex.mjs +284 -0
- package/src/core/scene3d/Scene3dBoardModel.mjs +596 -0
- package/src/core/scene3d/Scene3dDocumentMetadata.mjs +167 -0
- package/src/core/scene3d/Scene3dFreeze.mjs +37 -0
- package/src/core/scene3d/Scene3dIdRegistry.mjs +34 -0
- package/src/core/scene3d/Scene3dInputPreflight.mjs +193 -0
- package/src/core/scene3d/Scene3dMaterials.mjs +58 -0
- package/src/core/scene3d/Scene3dModelReference.mjs +134 -0
- package/src/core/scene3d/Scene3dOptions.mjs +363 -0
- package/src/core/scene3d/SceneAssetResolver.mjs +441 -0
- package/src/core/simulation/SimulationParameterCloner.mjs +543 -0
- package/src/core/worker/ParserWorkerClient.mjs +997 -0
- package/src/core/worker/ToolkitWorkerProtocol.mjs +412 -0
- package/src/core/worker/WorkerRequestData.mjs +623 -0
- package/src/core/worker/WorkerResponseData.mjs +905 -0
- package/src/extensions.mjs +37 -0
- package/src/index.mjs +14 -9
- package/src/interaction.mjs +2 -0
- package/src/manufacturing.mjs +1 -0
- package/src/parser.mjs +12 -2
- package/src/project.mjs +5 -0
- package/src/query.mjs +1 -0
- package/src/renderers.mjs +3 -29
- package/src/scene3d.mjs +3 -0
- package/src/simulation.mjs +1 -0
- package/src/styles/renderers.css +24 -0
- package/src/testing/ToolkitContractFixtures.mjs +124 -0
- package/src/testing/ToolkitLoopbackWorker.mjs +174 -0
- package/src/testing/runToolkitContract.mjs +705 -0
- package/src/testing.mjs +3 -0
- package/src/ui/BomTableRenderer.mjs +304 -0
- package/src/ui/CircuitJsonPcbBoardSvgRenderer.mjs +80 -0
- package/src/ui/CircuitJsonPcbPrimitiveAttributeRenderer.mjs +3 -5
- package/src/ui/CircuitJsonPcbSvgRenderer.mjs +63 -43
- package/src/ui/CircuitJsonPcbViaSvgRenderer.mjs +3 -5
- package/src/ui/CircuitJsonSchematicDebugRenderer.mjs +164 -0
- package/src/ui/CircuitJsonSchematicImageSvgRenderer.mjs +210 -0
- package/src/ui/CircuitJsonSchematicLineRenderer.mjs +86 -0
- package/src/ui/CircuitJsonSchematicSheetSymbolSvgRenderer.mjs +98 -0
- package/src/ui/CircuitJsonSchematicSvgArcPath.mjs +117 -17
- package/src/ui/CircuitJsonSchematicSvgPortMetadata.mjs +67 -20
- package/src/ui/CircuitJsonSchematicSvgPrimitiveAttributes.mjs +45 -9
- package/src/ui/CircuitJsonSchematicSvgRenderer.mjs +151 -148
- package/src/ui/CircuitJsonSchematicTableSvgRenderer.mjs +4 -292
- package/src/ui/PcbSvgRenderer.mjs +41 -0
- package/src/ui/SafeSvgPaint.mjs +26 -0
- package/src/ui/SafeXmlText.mjs +60 -0
- package/src/ui/SchematicGeometryBounds.mjs +540 -0
- package/src/ui/SchematicSvgRenderer.mjs +110 -0
- package/src/ui/SchematicTableGeometry.mjs +319 -0
- package/src/ui/SchematicTextAnchor.mjs +55 -0
- package/src/ui/SchematicTextBounds.mjs +98 -0
- package/src/workers/parser.worker.mjs +59 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CircuitJsonElementValidator } from './CircuitJsonElementValidator.mjs'
|
|
2
|
+
import { CircuitJsonLegacyModel } from './context/CircuitJsonLegacyModel.mjs'
|
|
3
|
+
import { CircuitJsonLegacyNormalizer } from './context/CircuitJsonLegacyNormalizer.mjs'
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Validates serialized CircuitJSON element arrays.
|
|
@@ -25,24 +27,36 @@ export class CircuitJsonDocument {
|
|
|
25
27
|
/**
|
|
26
28
|
* Returns validation errors for a candidate CircuitJSON element array.
|
|
27
29
|
* @param {unknown} value Candidate model.
|
|
30
|
+
* @param {{ freeze?: boolean }} [options] Validation options.
|
|
28
31
|
* @returns {string[]}
|
|
29
32
|
*/
|
|
30
|
-
static validateModel(value) {
|
|
31
|
-
return CircuitJsonElementValidator.validateModel(value)
|
|
33
|
+
static validateModel(value, options = {}) {
|
|
34
|
+
return CircuitJsonElementValidator.validateModel(value, options)
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
35
38
|
* Throws when a value is not a CircuitJSON element array.
|
|
36
39
|
* @param {unknown} value Candidate model.
|
|
40
|
+
* @param {{ freeze?: boolean }} [options] Validation options.
|
|
37
41
|
* @returns {void}
|
|
38
42
|
*/
|
|
39
|
-
static assertModel(value) {
|
|
40
|
-
const errors = CircuitJsonDocument.validateModel(value)
|
|
43
|
+
static assertModel(value, options = {}) {
|
|
44
|
+
const errors = CircuitJsonDocument.validateModel(value, options)
|
|
41
45
|
if (errors.length) {
|
|
42
46
|
throw new TypeError(errors[0])
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Projects supported pre-union aliases onto the current CircuitJSON model.
|
|
52
|
+
* @param {unknown} model CircuitJSON model candidate.
|
|
53
|
+
* @param {{ owned?: boolean }} [options] Ownership options.
|
|
54
|
+
* @returns {unknown} Original model or its canonical projection.
|
|
55
|
+
*/
|
|
56
|
+
static normalizeModel(model, options = {}) {
|
|
57
|
+
return CircuitJsonLegacyNormalizer.normalize(model, options)
|
|
58
|
+
}
|
|
59
|
+
|
|
46
60
|
/**
|
|
47
61
|
* Attaches non-serialized metadata to a CircuitJSON array.
|
|
48
62
|
* @template {object[]} T
|
|
@@ -52,62 +66,6 @@ export class CircuitJsonDocument {
|
|
|
52
66
|
*/
|
|
53
67
|
static attachMetadata(circuitJson, metadata = {}) {
|
|
54
68
|
CircuitJsonDocument.assertModel(circuitJson)
|
|
55
|
-
|
|
56
|
-
fileName: {
|
|
57
|
-
configurable: true,
|
|
58
|
-
enumerable: true,
|
|
59
|
-
value: String(metadata.fileName || ''),
|
|
60
|
-
writable: true
|
|
61
|
-
},
|
|
62
|
-
fileType: {
|
|
63
|
-
configurable: true,
|
|
64
|
-
enumerable: true,
|
|
65
|
-
value: String(metadata.fileType || 'circuitjson'),
|
|
66
|
-
writable: true
|
|
67
|
-
},
|
|
68
|
-
kind: {
|
|
69
|
-
configurable: true,
|
|
70
|
-
enumerable: true,
|
|
71
|
-
value: String(metadata.kind || 'pcb'),
|
|
72
|
-
writable: true
|
|
73
|
-
},
|
|
74
|
-
sourceFormat: {
|
|
75
|
-
configurable: true,
|
|
76
|
-
enumerable: true,
|
|
77
|
-
value: 'circuitjson',
|
|
78
|
-
writable: true
|
|
79
|
-
},
|
|
80
|
-
diagnostics: {
|
|
81
|
-
configurable: true,
|
|
82
|
-
enumerable: true,
|
|
83
|
-
value: Array.isArray(metadata.diagnostics)
|
|
84
|
-
? metadata.diagnostics
|
|
85
|
-
: [],
|
|
86
|
-
writable: true
|
|
87
|
-
},
|
|
88
|
-
bom: {
|
|
89
|
-
configurable: true,
|
|
90
|
-
enumerable: true,
|
|
91
|
-
value: Array.isArray(metadata.bom) ? metadata.bom : [],
|
|
92
|
-
writable: true
|
|
93
|
-
},
|
|
94
|
-
supportMatrix: {
|
|
95
|
-
configurable: true,
|
|
96
|
-
enumerable: true,
|
|
97
|
-
value: metadata.supportMatrix || null,
|
|
98
|
-
writable: true
|
|
99
|
-
},
|
|
100
|
-
manufacturing: {
|
|
101
|
-
configurable: true,
|
|
102
|
-
enumerable: true,
|
|
103
|
-
value: metadata.manufacturing || {
|
|
104
|
-
pickAndPlaceRows: [],
|
|
105
|
-
routingDsn: ''
|
|
106
|
-
},
|
|
107
|
-
writable: true
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
return circuitJson
|
|
69
|
+
return CircuitJsonLegacyModel.attachValidated(circuitJson, metadata)
|
|
112
70
|
}
|
|
113
71
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CIRCUIT_JSON_UPSTREAM_ELEMENT_TYPES } from './CircuitJsonUpstreamSchema.mjs'
|
|
2
|
+
import { CircuitJsonToolkitElementSchema } from './CircuitJsonToolkitElementSchema.mjs'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Frozen inventory of exact pinned upstream CircuitJSON element type names.
|
|
6
|
+
*/
|
|
7
|
+
export const CIRCUIT_JSON_ELEMENT_TYPES = new Set([
|
|
8
|
+
...CIRCUIT_JSON_UPSTREAM_ELEMENT_TYPES,
|
|
9
|
+
...CircuitJsonToolkitElementSchema.elementTypes()
|
|
10
|
+
])
|