circuitjson-toolkit 1.0.17 → 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/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
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { BinaryDataSnapshot } from './BinaryDataSnapshot.mjs'
|
|
2
|
+
|
|
3
|
+
const PROTECTED_BINARY_GETTERS = new WeakSet()
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Protects byte-backed values embedded in canonical extension containers.
|
|
7
|
+
*/
|
|
8
|
+
export class ProtectedExtensionBinaryBoundary {
|
|
9
|
+
/**
|
|
10
|
+
* Replaces owned binary data properties with defensive-copy getters.
|
|
11
|
+
* @param {unknown} root Owned extension graph.
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
static protect(root) {
|
|
15
|
+
if (BinaryDataSnapshot.describe(root)) {
|
|
16
|
+
throw new TypeError(
|
|
17
|
+
'Canonical extension root must be a plain data container.'
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
const seen = new Set()
|
|
21
|
+
const stack = [root]
|
|
22
|
+
while (stack.length) {
|
|
23
|
+
const current = stack.pop()
|
|
24
|
+
if (!ProtectedExtensionBinaryBoundary.#container(current)) continue
|
|
25
|
+
if (seen.has(current)) continue
|
|
26
|
+
seen.add(current)
|
|
27
|
+
|
|
28
|
+
let descriptors
|
|
29
|
+
try {
|
|
30
|
+
descriptors = Object.getOwnPropertyDescriptors(current)
|
|
31
|
+
} catch {
|
|
32
|
+
throw new TypeError(
|
|
33
|
+
'Canonical extension data could not be inspected safely.'
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
37
|
+
const descriptor = descriptors[key]
|
|
38
|
+
if (!Object.hasOwn(descriptor, 'value')) {
|
|
39
|
+
if (
|
|
40
|
+
ProtectedExtensionBinaryBoundary.isProtected(descriptor)
|
|
41
|
+
) {
|
|
42
|
+
continue
|
|
43
|
+
}
|
|
44
|
+
throw new TypeError(
|
|
45
|
+
'Canonical extension data may contain only data properties.'
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
const child = descriptor.value
|
|
49
|
+
if (!child || typeof child !== 'object') continue
|
|
50
|
+
if (ProtectedExtensionBinaryBoundary.#container(child)) {
|
|
51
|
+
stack.push(child)
|
|
52
|
+
continue
|
|
53
|
+
}
|
|
54
|
+
const binary = BinaryDataSnapshot.describe(child)
|
|
55
|
+
if (!binary) continue
|
|
56
|
+
const ownedBinary = child
|
|
57
|
+
/** @returns {ArrayBuffer | Uint8Array | DataView} A defensive binary copy. */
|
|
58
|
+
const readBinary = () =>
|
|
59
|
+
BinaryDataSnapshot.clone(ownedBinary, binary)
|
|
60
|
+
PROTECTED_BINARY_GETTERS.add(readBinary)
|
|
61
|
+
Object.defineProperty(current, key, {
|
|
62
|
+
configurable: false,
|
|
63
|
+
enumerable: descriptor.enumerable,
|
|
64
|
+
get: readBinary
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Reads only an internally-created defensive binary getter.
|
|
72
|
+
* @param {PropertyDescriptor | undefined} descriptor Binary descriptor.
|
|
73
|
+
* @returns {{ trusted: boolean, value: unknown }} Trusted read result.
|
|
74
|
+
*/
|
|
75
|
+
static read(descriptor) {
|
|
76
|
+
if (!ProtectedExtensionBinaryBoundary.isProtected(descriptor)) {
|
|
77
|
+
return { trusted: false, value: null }
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
trusted: true,
|
|
81
|
+
value: Reflect.apply(descriptor.get, undefined, [])
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns whether a descriptor belongs to this binary boundary.
|
|
87
|
+
* @param {PropertyDescriptor | undefined} descriptor Descriptor candidate.
|
|
88
|
+
* @returns {boolean} Whether the descriptor is a protected binary getter.
|
|
89
|
+
*/
|
|
90
|
+
static isProtected(descriptor) {
|
|
91
|
+
return Boolean(
|
|
92
|
+
descriptor &&
|
|
93
|
+
typeof descriptor.get === 'function' &&
|
|
94
|
+
descriptor.set === undefined &&
|
|
95
|
+
descriptor.enumerable === true &&
|
|
96
|
+
descriptor.configurable === false &&
|
|
97
|
+
PROTECTED_BINARY_GETTERS.has(descriptor.get)
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Returns true for plain extension containers.
|
|
103
|
+
* @param {unknown} value Candidate value.
|
|
104
|
+
* @returns {boolean} Whether the value is a supported container.
|
|
105
|
+
*/
|
|
106
|
+
static #container(value) {
|
|
107
|
+
if (!value || typeof value !== 'object') return false
|
|
108
|
+
try {
|
|
109
|
+
if (Array.isArray(value)) {
|
|
110
|
+
if (Object.getPrototypeOf(value) !== Array.prototype) {
|
|
111
|
+
throw new TypeError(
|
|
112
|
+
'Canonical extension arrays must use Array.prototype.'
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
return true
|
|
116
|
+
}
|
|
117
|
+
const prototype = Object.getPrototypeOf(value)
|
|
118
|
+
return prototype === Object.prototype || prototype === null
|
|
119
|
+
} catch {
|
|
120
|
+
throw new TypeError(
|
|
121
|
+
'Canonical extension data could not be inspected safely.'
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
Object.freeze(ProtectedExtensionBinaryBoundary.prototype)
|
|
128
|
+
Object.freeze(ProtectedExtensionBinaryBoundary)
|