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,31 +1,6 @@
|
|
|
1
|
+
import * as UnitParsers from './CircuitJsonUnitParsers.mjs'
|
|
2
|
+
|
|
1
3
|
const MILS_PER_MM = 39.37007874015748
|
|
2
|
-
const LENGTH_FACTORS_TO_MM = new Map([
|
|
3
|
-
['mm', 1],
|
|
4
|
-
['millimeter', 1],
|
|
5
|
-
['millimeters', 1],
|
|
6
|
-
['cm', 10],
|
|
7
|
-
['centimeter', 10],
|
|
8
|
-
['centimeters', 10],
|
|
9
|
-
['m', 1000],
|
|
10
|
-
['meter', 1000],
|
|
11
|
-
['meters', 1000],
|
|
12
|
-
['in', 25.4],
|
|
13
|
-
['inch', 25.4],
|
|
14
|
-
['inches', 25.4],
|
|
15
|
-
['mil', 0.0254],
|
|
16
|
-
['mils', 0.0254],
|
|
17
|
-
['um', 0.001],
|
|
18
|
-
['micrometer', 0.001],
|
|
19
|
-
['micrometers', 0.001]
|
|
20
|
-
])
|
|
21
|
-
const ANGLE_FACTORS_TO_DEG = new Map([
|
|
22
|
-
['deg', 1],
|
|
23
|
-
['degree', 1],
|
|
24
|
-
['degrees', 1],
|
|
25
|
-
['rad', 180 / Math.PI],
|
|
26
|
-
['radian', 180 / Math.PI],
|
|
27
|
-
['radians', 180 / Math.PI]
|
|
28
|
-
])
|
|
29
4
|
|
|
30
5
|
/**
|
|
31
6
|
* Unit helpers for CircuitJSON's millimeter-based PCB dimensions.
|
|
@@ -38,10 +13,7 @@ export class CircuitJsonUnits {
|
|
|
38
13
|
* @returns {number}
|
|
39
14
|
*/
|
|
40
15
|
static length(value, fallback = 0) {
|
|
41
|
-
return (
|
|
42
|
-
CircuitJsonUnits.optionalLength(value) ??
|
|
43
|
-
CircuitJsonUnits.#round(fallback)
|
|
44
|
-
)
|
|
16
|
+
return UnitParsers.optionalLength(value) ?? UnitParsers.round(fallback)
|
|
45
17
|
}
|
|
46
18
|
|
|
47
19
|
/**
|
|
@@ -50,7 +22,7 @@ export class CircuitJsonUnits {
|
|
|
50
22
|
* @returns {number | null}
|
|
51
23
|
*/
|
|
52
24
|
static optionalLength(value) {
|
|
53
|
-
return
|
|
25
|
+
return UnitParsers.optionalLength(value)
|
|
54
26
|
}
|
|
55
27
|
|
|
56
28
|
/**
|
|
@@ -60,10 +32,7 @@ export class CircuitJsonUnits {
|
|
|
60
32
|
* @returns {number}
|
|
61
33
|
*/
|
|
62
34
|
static angle(value, fallback = 0) {
|
|
63
|
-
return (
|
|
64
|
-
CircuitJsonUnits.optionalAngle(value) ??
|
|
65
|
-
CircuitJsonUnits.#round(fallback)
|
|
66
|
-
)
|
|
35
|
+
return UnitParsers.optionalAngle(value) ?? UnitParsers.round(fallback)
|
|
67
36
|
}
|
|
68
37
|
|
|
69
38
|
/**
|
|
@@ -72,7 +41,7 @@ export class CircuitJsonUnits {
|
|
|
72
41
|
* @returns {number | null}
|
|
73
42
|
*/
|
|
74
43
|
static optionalAngle(value) {
|
|
75
|
-
return
|
|
44
|
+
return UnitParsers.optionalAngle(value)
|
|
76
45
|
}
|
|
77
46
|
|
|
78
47
|
/**
|
|
@@ -82,8 +51,8 @@ export class CircuitJsonUnits {
|
|
|
82
51
|
*/
|
|
83
52
|
static point(point) {
|
|
84
53
|
return {
|
|
85
|
-
x:
|
|
86
|
-
y:
|
|
54
|
+
x: UnitParsers.optionalLength(point?.x) ?? 0,
|
|
55
|
+
y: UnitParsers.optionalLength(point?.y) ?? 0
|
|
87
56
|
}
|
|
88
57
|
}
|
|
89
58
|
|
|
@@ -93,9 +62,7 @@ export class CircuitJsonUnits {
|
|
|
93
62
|
* @returns {{ x: number, y: number } | null}
|
|
94
63
|
*/
|
|
95
64
|
static optionalPoint(point) {
|
|
96
|
-
|
|
97
|
-
const y = CircuitJsonUnits.optionalLength(point?.y)
|
|
98
|
-
return x === null || y === null ? null : { x, y }
|
|
65
|
+
return UnitParsers.optionalPoint(point)
|
|
99
66
|
}
|
|
100
67
|
|
|
101
68
|
/**
|
|
@@ -104,9 +71,7 @@ export class CircuitJsonUnits {
|
|
|
104
71
|
* @returns {{ width: number, height: number } | null}
|
|
105
72
|
*/
|
|
106
73
|
static optionalSize(size) {
|
|
107
|
-
|
|
108
|
-
const height = CircuitJsonUnits.optionalLength(size?.height)
|
|
109
|
-
return width === null || height === null ? null : { width, height }
|
|
74
|
+
return UnitParsers.optionalSize(size)
|
|
110
75
|
}
|
|
111
76
|
|
|
112
77
|
/**
|
|
@@ -116,8 +81,9 @@ export class CircuitJsonUnits {
|
|
|
116
81
|
* @returns {number}
|
|
117
82
|
*/
|
|
118
83
|
static mmToMil(value, fallback = 0) {
|
|
119
|
-
return
|
|
120
|
-
|
|
84
|
+
return UnitParsers.round(
|
|
85
|
+
(UnitParsers.optionalLength(value) ?? UnitParsers.round(fallback)) *
|
|
86
|
+
MILS_PER_MM
|
|
121
87
|
)
|
|
122
88
|
}
|
|
123
89
|
|
|
@@ -132,44 +98,4 @@ export class CircuitJsonUnits {
|
|
|
132
98
|
y: CircuitJsonUnits.mmToMil(point?.y, 0)
|
|
133
99
|
}
|
|
134
100
|
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Parses one numeric value with an optional unit suffix.
|
|
138
|
-
* @param {unknown} value Value candidate.
|
|
139
|
-
* @param {Map<string, number>} unitFactors Unit factor lookup.
|
|
140
|
-
* @returns {number | null}
|
|
141
|
-
*/
|
|
142
|
-
static #parseUnitValue(value, unitFactors) {
|
|
143
|
-
if (typeof value === 'number') {
|
|
144
|
-
return Number.isFinite(value)
|
|
145
|
-
? CircuitJsonUnits.#round(value)
|
|
146
|
-
: null
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const text = String(value ?? '').trim()
|
|
150
|
-
if (!text) return null
|
|
151
|
-
|
|
152
|
-
const match = text.match(
|
|
153
|
-
/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*([a-z]+)?$/iu
|
|
154
|
-
)
|
|
155
|
-
if (!match) return null
|
|
156
|
-
|
|
157
|
-
const number = Number(match[1])
|
|
158
|
-
if (!Number.isFinite(number)) return null
|
|
159
|
-
|
|
160
|
-
const unit = String(match[2] || '').toLowerCase()
|
|
161
|
-
const factor = unit ? unitFactors.get(unit) : 1
|
|
162
|
-
if (!Number.isFinite(factor)) return null
|
|
163
|
-
|
|
164
|
-
return CircuitJsonUnits.#round(number * factor)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Rounds render-unit conversions to stable precision.
|
|
169
|
-
* @param {number} value Numeric value.
|
|
170
|
-
* @returns {number}
|
|
171
|
-
*/
|
|
172
|
-
static #round(value) {
|
|
173
|
-
return Math.round(value * 1_000_000) / 1_000_000
|
|
174
|
-
}
|
|
175
101
|
}
|