circuitjson-toolkit 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/README.md +100 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,27 +6,41 @@ SPDX-License-Identifier: CC-BY-SA-4.0
6
6
 
7
7
  # CircuitJSON Toolkit
8
8
 
9
- CircuitJSON Toolkit is an ESM JavaScript library for validating, parsing,
9
+ CircuitJSON Toolkit is an ESM JavaScript library for parsing, validating,
10
10
  indexing, and inspecting serialized CircuitJSON element arrays.
11
11
 
12
12
  The package was extracted from [ECAD Forge](https://ecadforge.app/), where it
13
13
  is used as the shared CircuitJSON runtime utility layer between ECAD parsers,
14
- viewer adapters, and browser-based import flows. It is intentionally separate
15
- from `pcb-scene3d-viewer`, which owns Three.js rendering.
14
+ viewer adapters, and browser-based import flows. Its parser-style API,
15
+ metadata conventions, and local-first behavior are designed to line up with
16
+ packages such as `altium-toolkit` and `kicad-toolkit`, while remaining
17
+ independent of any source ECAD format.
18
+
19
+ This package is intentionally separate from
20
+ [`pcb-scene3d-viewer`](https://www.npmjs.com/package/pcb-scene3d-viewer).
21
+ `circuitjson-toolkit` owns CircuitJSON parsing, validation, indexing, and unit
22
+ helpers. `pcb-scene3d-viewer` owns Three.js runtime rendering and consumes this
23
+ package as a normal npm dependency.
16
24
 
17
25
  ## Features
18
26
 
19
- - Parse standalone CircuitJSON JSON text and bytes
20
- - Validate serialized CircuitJSON element arrays
27
+ - Parse standalone CircuitJSON `.json` text from strings, `ArrayBuffer`, or
28
+ `Uint8Array` input
29
+ - Validate serialized CircuitJSON element arrays with a small, stable document
30
+ API
21
31
  - Attach parser-style metadata such as `fileName`, `fileType`, `kind`, and
22
- `sourceFormat`
32
+ `sourceFormat`, matching the conventions used by the ECAD toolkit packages
23
33
  - Build lookup indexes by element type and stable CircuitJSON identifiers
24
- - Resolve source component and PCB component maps for viewer or reporting
25
- integrations
26
- - Convert CircuitJSON millimeter dimensions and points into mils for renderer
27
- adapters
34
+ - Resolve source component and PCB component maps for viewer, QA, export, or
35
+ reporting integrations
36
+ - Preserve unknown element types instead of imposing renderer-specific
37
+ semantics
38
+ - Convert CircuitJSON millimeter dimensions and points into mils for render
39
+ adapters that use PCB imperial units internally
40
+ - Provide root and parser-focused ESM entrypoints
28
41
  - Run in browser and Node ESM environments
29
- - Stay dependency-free at runtime and local-first by default
42
+ - Run entirely with local input data; no network calls are made by the parser
43
+ - Stay dependency-free at runtime
30
44
 
31
45
  ## Install
32
46
 
@@ -39,6 +53,8 @@ npm install circuitjson-toolkit
39
53
 
40
54
  ## Usage
41
55
 
56
+ Parse a standalone CircuitJSON file or string:
57
+
42
58
  ```js
43
59
  import {
44
60
  CircuitJsonDocument,
@@ -53,12 +69,59 @@ const index = CircuitJsonIndexer.index(circuitJson)
53
69
  console.log(index.elementsByType.get('pcb_board'))
54
70
  ```
55
71
 
56
- Parser-focused imports are also available through the `parser` subpath:
72
+ The parser also accepts bytes, mirroring the parser style used by the source
73
+ ECAD toolkits:
74
+
75
+ ```js
76
+ import { CircuitJsonParser } from 'circuitjson-toolkit'
77
+
78
+ const documentModel = CircuitJsonParser.parseBytes(arrayBuffer, {
79
+ fileName: file.name
80
+ })
81
+ ```
82
+
83
+ Parser-focused imports are available through the `parser` subpath:
57
84
 
58
85
  ```js
59
86
  import { CircuitJsonParser } from 'circuitjson-toolkit/parser'
60
87
  ```
61
88
 
89
+ Build an index for renderer or reporting integrations:
90
+
91
+ ```js
92
+ import { CircuitJsonIndexer } from 'circuitjson-toolkit'
93
+
94
+ const index = CircuitJsonIndexer.index(documentModel)
95
+ const board = index.elementsByType.get('pcb_board')?.[0]
96
+ const components = index.elementsByType.get('pcb_component') || []
97
+ const source = index.sourceComponentById.get('source_component_1')
98
+ ```
99
+
100
+ Convert CircuitJSON millimeter coordinates for renderer adapters:
101
+
102
+ ```js
103
+ import { CircuitJsonUnits } from 'circuitjson-toolkit'
104
+
105
+ const centerMil = CircuitJsonUnits.pointMmToMil(board.center)
106
+ const widthMil = CircuitJsonUnits.mmToMil(board.width)
107
+ ```
108
+
109
+ Pass CircuitJSON to the 3D renderer as a separate step:
110
+
111
+ ```js
112
+ import { CircuitJsonParser } from 'circuitjson-toolkit'
113
+ import { PcbScene3dController } from 'pcb-scene3d-viewer'
114
+
115
+ const circuitJson = CircuitJsonParser.parseText(fileText, {
116
+ fileName: 'board.circuitjson'
117
+ })
118
+
119
+ const controller = new PcbScene3dController(viewportNode, circuitJson)
120
+ ```
121
+
122
+ `circuitjson-toolkit` does not render, fetch, or load external model assets.
123
+ That behavior belongs in host applications or renderer packages.
124
+
62
125
  ## Documentation
63
126
 
64
127
  - [API](docs/api.md)
@@ -66,6 +129,19 @@ import { CircuitJsonParser } from 'circuitjson-toolkit/parser'
66
129
  - [Testing](docs/testing.md)
67
130
  - [Scope](spec/library-scope.md)
68
131
 
132
+ ## Package Scope
133
+
134
+ This package owns reusable CircuitJSON utility behavior only:
135
+
136
+ - parser-style document ingestion for serialized CircuitJSON;
137
+ - validation and diagnostics for element-array inputs;
138
+ - indexing and lookup maps for common CircuitJSON IDs;
139
+ - small unit conversion helpers for downstream renderer adapters.
140
+
141
+ It does not include native Altium or KiCad parsing, schematic/PCB SVG
142
+ rendering, Three.js rendering, browser UI controls, network fetching, or
143
+ format-specific scene-description builders.
144
+
69
145
  ## Test
70
146
 
71
147
  ```bash
@@ -88,6 +164,10 @@ distribute modified versions, run modified versions as a network service, or
88
164
  create larger works based on this project, they must comply with the AGPL,
89
165
  including source-code availability requirements.
90
166
 
167
+ The full AGPL license text is included in
168
+ [LICENSES/AGPL-3.0-or-later.txt](LICENSES/AGPL-3.0-or-later.txt). The root
169
+ [LICENSE](LICENSE) file summarizes the package's public software license.
170
+
91
171
  ### 2. Commercial/proprietary license
92
172
 
93
173
  For use in closed-source, proprietary, or otherwise AGPL-incompatible products,
@@ -95,14 +175,22 @@ a separate paid commercial license is required.
95
175
 
96
176
  Commercial licensing contact: https://github.com/SunboX
97
177
 
178
+ See [COMMERCIAL-LICENSE.md](COMMERCIAL-LICENSE.md). That file is a licensing
179
+ notice, not a commercial license grant.
180
+
98
181
  ### Documentation and notices
99
182
 
100
183
  Documentation and non-code text are licensed under Creative Commons
101
184
  Attribution-ShareAlike 4.0 (`CC-BY-SA-4.0`) unless otherwise marked.
102
185
 
186
+ The full CC-BY-SA license text is included in
187
+ [LICENSES/CC-BY-SA-4.0.txt](LICENSES/CC-BY-SA-4.0.txt).
188
+
103
189
  Copyright (C) 2026 André Fiedler.
104
190
 
105
191
  Copyright, license, attribution, and source-origin notices must be preserved as
106
192
  required by the AGPL, CC-BY-SA-4.0, and the notice files in this repository.
107
193
  See [LICENSE](LICENSE), [COMMERCIAL-LICENSE.md](COMMERCIAL-LICENSE.md), and
108
194
  [NOTICE.md](NOTICE.md).
195
+
196
+ Package-manager dependencies retain their own license terms and notices.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "circuitjson-toolkit",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Dependency-free CircuitJSON parsing, validation, indexing, and utility helpers",
5
5
  "keywords": [
6
6
  "circuitjson",