altium-toolkit 0.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.
Files changed (82) hide show
  1. package/AGENTS.md +67 -0
  2. package/COMMERCIAL-LICENSE.md +20 -0
  3. package/CONTRIBUTING.md +19 -0
  4. package/LICENSE +22 -0
  5. package/LICENSES/CC-BY-SA-4.0.txt +170 -0
  6. package/LICENSES/GPL-3.0-or-later.txt +232 -0
  7. package/NOTICE.md +32 -0
  8. package/README.md +116 -0
  9. package/docs/api.md +73 -0
  10. package/docs/model-format.md +36 -0
  11. package/docs/testing.md +25 -0
  12. package/examples/README.md +47 -0
  13. package/examples/arduino-uno/PcbThreeSceneRenderer.mjs +635 -0
  14. package/examples/arduino-uno/SvgViewportController.mjs +306 -0
  15. package/examples/arduino-uno/example.mjs +480 -0
  16. package/examples/arduino-uno/index.html +163 -0
  17. package/examples/arduino-uno/styles.css +552 -0
  18. package/examples/server.mjs +212 -0
  19. package/package.json +53 -0
  20. package/spec/library-scope.md +32 -0
  21. package/src/core/BinaryReader.mjs +127 -0
  22. package/src/core/altium/AltiumLayoutParser.mjs +485 -0
  23. package/src/core/altium/AltiumParser.mjs +1007 -0
  24. package/src/core/altium/AsciiRecordParser.mjs +151 -0
  25. package/src/core/altium/ParserUtils.mjs +173 -0
  26. package/src/core/altium/PcbBinaryPrimitiveParser.mjs +424 -0
  27. package/src/core/altium/PcbEmbeddedModelExtractor.mjs +505 -0
  28. package/src/core/altium/PcbModelParser.mjs +336 -0
  29. package/src/core/altium/PcbOutlineRasterizer.mjs +852 -0
  30. package/src/core/altium/PcbOutlineRecovery.mjs +957 -0
  31. package/src/core/altium/PcbStreamExtractor.mjs +210 -0
  32. package/src/core/altium/PrintableTextDecoder.mjs +156 -0
  33. package/src/core/altium/SchematicAnnotationParser.mjs +220 -0
  34. package/src/core/altium/SchematicBusEntryParser.mjs +48 -0
  35. package/src/core/altium/SchematicDirectiveParser.mjs +47 -0
  36. package/src/core/altium/SchematicImageParser.mjs +173 -0
  37. package/src/core/altium/SchematicJunctionParser.mjs +43 -0
  38. package/src/core/altium/SchematicMultipartOwnerMatcher.mjs +564 -0
  39. package/src/core/altium/SchematicNetlistBuilder.mjs +351 -0
  40. package/src/core/altium/SchematicPinParser.mjs +767 -0
  41. package/src/core/altium/SchematicPrimitiveParser.mjs +716 -0
  42. package/src/core/altium/SchematicSheetParser.mjs +241 -0
  43. package/src/core/altium/SchematicSheetStyleResolver.mjs +46 -0
  44. package/src/core/altium/SchematicStandaloneCalloutNormalizer.mjs +592 -0
  45. package/src/core/altium/SchematicTextParser.mjs +708 -0
  46. package/src/core/altium/SchematicTextPostProcessor.mjs +801 -0
  47. package/src/core/ole/OleCompoundDocument.mjs +439 -0
  48. package/src/core/ole/OleConstants.mjs +64 -0
  49. package/src/core/ole/OleDirectoryEntry.mjs +95 -0
  50. package/src/index.mjs +7 -0
  51. package/src/parser.mjs +21 -0
  52. package/src/renderers.mjs +15 -0
  53. package/src/scene3d.mjs +9 -0
  54. package/src/styles/altium-renderers.css +358 -0
  55. package/src/ui/BomTableRenderer.mjs +46 -0
  56. package/src/ui/PcbArcUtils.mjs +189 -0
  57. package/src/ui/PcbEdgeFacingGlyphNormalizer.mjs +808 -0
  58. package/src/ui/PcbFootprintPrimitiveSelector.mjs +128 -0
  59. package/src/ui/PcbScene3dBuilder.mjs +742 -0
  60. package/src/ui/PcbScene3dModelRegistry.mjs +309 -0
  61. package/src/ui/PcbScene3dPackages.mjs +137 -0
  62. package/src/ui/PcbScene3dScenePreparator.mjs +36 -0
  63. package/src/ui/PcbScene3dSummaryRenderer.mjs +65 -0
  64. package/src/ui/PcbSvgRenderer.mjs +906 -0
  65. package/src/ui/SchematicColorResolver.mjs +132 -0
  66. package/src/ui/SchematicContentLayout.mjs +661 -0
  67. package/src/ui/SchematicDirectiveRenderer.mjs +184 -0
  68. package/src/ui/SchematicImageRenderer.mjs +135 -0
  69. package/src/ui/SchematicJunctionRenderer.mjs +381 -0
  70. package/src/ui/SchematicNoteRenderer.mjs +427 -0
  71. package/src/ui/SchematicOwnerPinLabelLayout.mjs +173 -0
  72. package/src/ui/SchematicPinSvgRenderer.mjs +495 -0
  73. package/src/ui/SchematicPortRenderer.mjs +558 -0
  74. package/src/ui/SchematicPowerPortRenderer.mjs +574 -0
  75. package/src/ui/SchematicRegionRenderer.mjs +94 -0
  76. package/src/ui/SchematicShapeRenderer.mjs +398 -0
  77. package/src/ui/SchematicSheetChromeRenderer.mjs +1025 -0
  78. package/src/ui/SchematicSheetSymbolRenderer.mjs +228 -0
  79. package/src/ui/SchematicSvgRenderer.mjs +756 -0
  80. package/src/ui/SchematicSvgUtils.mjs +182 -0
  81. package/src/ui/SchematicTypography.mjs +204 -0
  82. package/src/workers/altium-parser.worker.mjs +29 -0
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2026 André Fiedler
3
+
4
+ SPDX-License-Identifier: CC-BY-SA-4.0
5
+ -->
6
+
7
+ # Altium Toolkit
8
+
9
+ Altium Toolkit is an ESM JavaScript library for parsing native Altium
10
+ schematic and PCB documents and rendering deterministic, non-interactive
11
+ outputs from the recovered model.
12
+
13
+ The package was extracted from ECAD Forge so parser behavior, normalized model
14
+ shape, and renderer output can be reused by other browser or Node-based tools.
15
+
16
+ ## Features
17
+
18
+ - Parse standalone native `.SchDoc` and `.PcbDoc` files from `ArrayBuffer`
19
+ - Recover schematic records, PCB outlines, placements, primitives, embedded
20
+ schematic images, and embedded PCB STEP payload metadata
21
+ - Render schematic SVG, PCB SVG, and grouped BOM HTML
22
+ - Build non-interactive PCB 3D scene-description data for host applications
23
+ - Render a static 3D board summary
24
+ - Run entirely with local input data; no network calls are made by the parser
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ npm install altium-toolkit
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```js
35
+ import {
36
+ AltiumParser,
37
+ SchematicSvgRenderer,
38
+ PcbSvgRenderer,
39
+ BomTableRenderer,
40
+ PcbScene3dBuilder
41
+ } from 'altium-toolkit'
42
+
43
+ const documentModel = AltiumParser.parseArrayBuffer(file.name, arrayBuffer)
44
+
45
+ const schematicMarkup = SchematicSvgRenderer.render(documentModel)
46
+ const pcbMarkup = PcbSvgRenderer.render(documentModel)
47
+ const bomMarkup = BomTableRenderer.render(documentModel.bom || [])
48
+ const sceneDescription = PcbScene3dBuilder.build(documentModel)
49
+ ```
50
+
51
+ Optional renderer CSS is available through:
52
+
53
+ ```js
54
+ import 'altium-toolkit/styles/altium-renderers.css'
55
+ ```
56
+
57
+ ## Documentation
58
+
59
+ - [API](docs/api.md)
60
+ - [Model Format](docs/model-format.md)
61
+ - [Testing](docs/testing.md)
62
+ - [Scope](spec/library-scope.md)
63
+
64
+ ## Examples
65
+
66
+ - [Arduino Uno Altium example](examples/arduino-uno/) based on Mehdi
67
+ KHALFALLAH's public
68
+ [My-Arduino-UNO-Design](https://github.com/Mehdi-KHALFALLAH/My-Arduino-UNO-Design)
69
+ project. The example fetches credited source documents from
70
+ `raw.githubusercontent.com` at runtime and does not redistribute them.
71
+
72
+ Run the local example server with:
73
+
74
+ ```bash
75
+ npm start
76
+ ```
77
+
78
+ ## Test
79
+
80
+ ```bash
81
+ npm test
82
+ ```
83
+
84
+ The test suite uses repo-owned, obfuscated fixture shards only. Do not add
85
+ native customer, vendor, or source project files to this repository.
86
+
87
+ ## License
88
+
89
+ This project is available under two licensing options.
90
+
91
+ ### 1. Open-source software license
92
+
93
+ GNU General Public License v3.0 or later (`GPL-3.0-or-later`).
94
+
95
+ You may use, modify, and distribute this project under the GPL. If you
96
+ distribute modified versions or larger works based on this project, they must
97
+ comply with the GPL, including source-code availability requirements.
98
+
99
+ ### 2. Commercial/proprietary license
100
+
101
+ For use in closed-source, proprietary, or otherwise GPL-incompatible products,
102
+ a separate paid commercial license is required.
103
+
104
+ Commercial licensing contact: https://github.com/SunboX
105
+
106
+ ### Documentation and notices
107
+
108
+ Documentation and non-code text are licensed under Creative Commons
109
+ Attribution-ShareAlike 4.0 (`CC-BY-SA-4.0`) unless otherwise marked.
110
+
111
+ Copyright (C) 2026 André Fiedler.
112
+
113
+ Copyright, license, attribution, and source-origin notices must be preserved as
114
+ required by the GPL, CC-BY-SA-4.0, and the notice files in this repository.
115
+ See [LICENSE](LICENSE), [COMMERCIAL-LICENSE.md](COMMERCIAL-LICENSE.md), and
116
+ [NOTICE.md](NOTICE.md).
package/docs/api.md ADDED
@@ -0,0 +1,73 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2026 André Fiedler
3
+
4
+ SPDX-License-Identifier: CC-BY-SA-4.0
5
+ -->
6
+
7
+ # API
8
+
9
+ ## Entrypoints
10
+
11
+ `altium-toolkit` exports the supported parser, renderer, and 3D
12
+ scene-description classes from one entrypoint.
13
+
14
+ Specialized entrypoints are also available:
15
+
16
+ - `altium-toolkit/parser`
17
+ - `altium-toolkit/renderers`
18
+ - `altium-toolkit/scene3d`
19
+ - `altium-toolkit/workers/altium-parser.worker.mjs`
20
+ - `altium-toolkit/styles/altium-renderers.css`
21
+
22
+ ## Parser
23
+
24
+ ```js
25
+ import { AltiumParser } from 'altium-toolkit/parser'
26
+
27
+ const documentModel = AltiumParser.parseArrayBuffer(fileName, arrayBuffer)
28
+ ```
29
+
30
+ `fileName` is used to infer schematic versus PCB parsing from the extension.
31
+ The parser accepts native `.SchDoc` and `.PcbDoc` document bytes as an
32
+ `ArrayBuffer` and returns the normalized model described in
33
+ [Model Format](model-format.md).
34
+
35
+ ## Renderers
36
+
37
+ ```js
38
+ import {
39
+ SchematicSvgRenderer,
40
+ PcbSvgRenderer,
41
+ BomTableRenderer
42
+ } from 'altium-toolkit/renderers'
43
+ ```
44
+
45
+ - `SchematicSvgRenderer.render(documentModel)` returns schematic SVG markup.
46
+ - `PcbSvgRenderer.render(documentModel)` returns PCB SVG markup.
47
+ - `BomTableRenderer.render(rows)` returns grouped BOM table markup.
48
+
49
+ Renderer output is deterministic string markup. The library does not attach DOM
50
+ events or mutate a host document.
51
+
52
+ ## 3D Scene Data
53
+
54
+ ```js
55
+ import {
56
+ PcbScene3dBuilder,
57
+ PcbScene3dModelRegistry,
58
+ PcbScene3dScenePreparator,
59
+ PcbScene3dSummaryRenderer
60
+ } from 'altium-toolkit/scene3d'
61
+ ```
62
+
63
+ - `PcbScene3dBuilder.build(documentModel, options)` returns procedural board,
64
+ placement, copper, silkscreen, and external-model scene-description data.
65
+ - `PcbScene3dModelRegistry` resolves embedded or session model candidates for
66
+ component placements.
67
+ - `PcbScene3dScenePreparator.prepare(documentModel, options)` prepares the same
68
+ scene-description data behind an async API suitable for host workers.
69
+ - `PcbScene3dSummaryRenderer.render(documentModel)` returns static 3D summary
70
+ HTML.
71
+
72
+ The library intentionally does not create Three.js objects, canvases, controls,
73
+ or event listeners.
@@ -0,0 +1,36 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2026 André Fiedler
3
+
4
+ SPDX-License-Identifier: CC-BY-SA-4.0
5
+ -->
6
+
7
+ # Model Format
8
+
9
+ The normalized model is intentionally stable with the ECAD Forge parser model.
10
+ The parser returns one object per parsed native document.
11
+
12
+ ## Common Fields
13
+
14
+ - `kind`: `schematic` or `pcb`
15
+ - `fileName`: original file name passed to the parser
16
+ - `diagnostics`: parser warnings and recovery notes
17
+ - `bom`: grouped component metadata where available
18
+
19
+ ## Schematic Fields
20
+
21
+ Schematic documents include recovered `schematic` data with sheet metadata,
22
+ primitives, wires, labels, power ports, sheet symbols, images, net metadata, and
23
+ component ownership hints. Coordinates remain in recovered document units until
24
+ the SVG renderer maps them into SVG space.
25
+
26
+ ## PCB Fields
27
+
28
+ PCB documents include recovered `pcb` data with board outline geometry,
29
+ component placements, layer metadata, primitive detail, copper, pads, vias,
30
+ fills, arcs, embedded model references, and model body placement metadata.
31
+
32
+ ## Compatibility Rule
33
+
34
+ Consumers should treat unknown fields as additive. Parser fixes may add detail,
35
+ but existing field names and shapes should stay compatible unless a major
36
+ version explicitly documents a model migration.
@@ -0,0 +1,25 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2026 André Fiedler
3
+
4
+ SPDX-License-Identifier: CC-BY-SA-4.0
5
+ -->
6
+
7
+ # Testing
8
+
9
+ Run the complete suite:
10
+
11
+ ```bash
12
+ npm test
13
+ ```
14
+
15
+ The tests cover:
16
+
17
+ - Binary and OLE helpers
18
+ - Printable and binary Altium parser recovery
19
+ - Obfuscated fake schematic and PCB fixture shards
20
+ - Schematic SVG, PCB SVG, BOM HTML, and static 3D summary renderers
21
+ - Non-interactive PCB 3D scene-description builders and model registry logic
22
+
23
+ Fixture data must remain repo-owned and obfuscated. Do not add native provided
24
+ Altium files, real customer identifiers, real vendor identifiers, or
25
+ source-descriptive fixture names.
@@ -0,0 +1,47 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2026 André Fiedler
3
+
4
+ SPDX-License-Identifier: CC-BY-SA-4.0
5
+ -->
6
+
7
+ # Examples
8
+
9
+ ## Arduino Uno
10
+
11
+ The `arduino-uno` example is a browser page for loading `.SchDoc` and
12
+ `.PcbDoc` files locally and rendering the recovered schematic, PCB, BOM,
13
+ interactive Three.js PCB view, and static 3D summary outputs. It automatically
14
+ fetches the credited source schematic and source PCB from GitHub at startup.
15
+
16
+ It is based on the public
17
+ [My-Arduino-UNO-Design](https://github.com/Mehdi-KHALFALLAH/My-Arduino-UNO-Design)
18
+ Altium project by Mehdi KHALFALLAH. Credit for that Arduino Uno Altium design
19
+ belongs to Mehdi KHALFALLAH.
20
+
21
+ The example does not redistribute Mehdi KHALFALLAH's Altium project files,
22
+ screenshots, datasheets, or manufacturing outputs. The browser fetches selected
23
+ source `.SchDoc` and `.PcbDoc` files from `raw.githubusercontent.com` at runtime.
24
+ You can also load local files downloaded from the original project.
25
+
26
+ From the repository root, start the local example server:
27
+
28
+ ```bash
29
+ npm start
30
+ ```
31
+
32
+ Then visit:
33
+
34
+ ```text
35
+ http://localhost:4173/examples/arduino-uno/
36
+ ```
37
+
38
+ The server binds to `127.0.0.1` by default. Override it with `HOST` or `PORT`
39
+ when needed:
40
+
41
+ ```bash
42
+ PORT=4174 npm start
43
+ ```
44
+
45
+ The parser and renderers remain local-first library code. This example page
46
+ explicitly makes outbound runtime requests to `raw.githubusercontent.com` only
47
+ for the credited source demo files.