altium-toolkit 1.1.3 → 1.1.22

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 (39) hide show
  1. package/docs/api.md +37 -0
  2. package/docs/model-format.md +18 -0
  3. package/docs/schemas/altium_toolkit/normalized_model_a1.schema.json +2 -2
  4. package/docs/testing.md +5 -0
  5. package/package.json +1 -1
  6. package/spec/library-scope.md +5 -0
  7. package/src/core/altium/AltiumLibraryBatchExporter.mjs +206 -0
  8. package/src/core/altium/AltiumLibraryRecordBuilder.mjs +293 -0
  9. package/src/core/altium/AltiumParser.mjs +5 -2
  10. package/src/core/altium/AltiumPcbLibExporter.mjs +101 -0
  11. package/src/core/altium/AltiumSchLibExporter.mjs +57 -0
  12. package/src/core/altium/AsciiRecordParser.mjs +43 -11
  13. package/src/core/altium/PcbComponentKindPolicy.mjs +9 -9
  14. package/src/core/altium/PcbEmbeddedModelExtractor.mjs +22 -3
  15. package/src/core/altium/PcbOutlineRecovery.mjs +94 -0
  16. package/src/core/altium/SchematicDirectiveParser.mjs +5 -17
  17. package/src/core/altium/SchematicNoErcSymbolResolver.mjs +36 -0
  18. package/src/core/altium/SchematicPinParser.mjs +87 -20
  19. package/src/core/altium/SchematicPrimitiveParser.mjs +116 -8
  20. package/src/core/altium/SchematicStreamExtractor.mjs +62 -15
  21. package/src/core/altium/SourceBundleExporter.mjs +156 -0
  22. package/src/core/altium/SourceComponentBundleNormalizer.mjs +295 -0
  23. package/src/core/altium/SourceComponentClient.mjs +239 -0
  24. package/src/core/ole/OleCompoundDocumentWriter.mjs +449 -0
  25. package/src/parser.mjs +8 -0
  26. package/src/styles/altium-renderers.css +6 -6
  27. package/src/ui/PcbArcUtils.mjs +19 -2
  28. package/src/ui/PcbScene3dBuilder.mjs +202 -20
  29. package/src/ui/PcbScene3dModelRegistry.mjs +28 -18
  30. package/src/ui/PcbScene3dPlacementSideResolver.mjs +48 -6
  31. package/src/ui/SchematicColorResolver.mjs +185 -0
  32. package/src/ui/SchematicDirectiveRenderer.mjs +133 -22
  33. package/src/ui/SchematicLineColorResolver.mjs +88 -0
  34. package/src/ui/SchematicNoteRenderer.mjs +5 -1
  35. package/src/ui/SchematicOwnerPinLabelLayout.mjs +269 -8
  36. package/src/ui/SchematicOwnerPinMarkerLineThemer.mjs +155 -0
  37. package/src/ui/SchematicPinSvgRenderer.mjs +229 -62
  38. package/src/ui/SchematicShapeRenderer.mjs +37 -11
  39. package/src/ui/SchematicSvgRenderer.mjs +944 -51
package/docs/api.md CHANGED
@@ -111,6 +111,43 @@ helpers. `PcbStatisticsBuilder` emits board QA summaries used by `.PcbDoc`
111
111
  models. `SchematicProjectParameterResolver` resolves dot-prefixed and
112
112
  equals-prefixed schematic special strings for parser and SVG integrations.
113
113
 
114
+ ## Library Exporters
115
+
116
+ ```js
117
+ import {
118
+ SourceComponentClient,
119
+ SourceComponentBundleNormalizer,
120
+ SourceBundleExporter,
121
+ AltiumSchLibExporter,
122
+ AltiumPcbLibExporter,
123
+ AltiumLibraryBatchExporter
124
+ } from 'altium-toolkit/parser'
125
+ ```
126
+
127
+ The exporter surface is local-first and host-controlled:
128
+
129
+ - `SourceComponentClient` performs component search, component fetch, model
130
+ asset fetch, retry, and response validation through an injected `fetcher`.
131
+ It does not use global `fetch` implicitly.
132
+ - `SourceComponentBundleNormalizer.normalize(raw)` converts provider-specific
133
+ component responses into a deterministic bundle with `symbol`, `footprint`,
134
+ `models`, `metadata`, `sourceJson`, and diagnostics fields.
135
+ - `SourceBundleExporter.export(bundle)` emits deterministic raw source bundle
136
+ entries: `manifest.json`, `source/source.json`, and optional `models/*`
137
+ assets.
138
+ - `AltiumSchLibExporter.export(bundles)` and
139
+ `AltiumPcbLibExporter.export(bundles)` write compact OLE-backed `.SchLib`
140
+ and `.PcbLib` byte arrays. The `.PcbLib` writer includes generated library
141
+ streams plus STEP/WRL model payload streams when the normalized bundle
142
+ contains model assets.
143
+ - `AltiumLibraryBatchExporter` orchestrates id lists, search-and-export,
144
+ per-component source/SchLib/PcbLib outputs, merged library outputs,
145
+ append/skip manifests, progress events, continue-on-error diagnostics, and
146
+ checkpoint state.
147
+
148
+ Hosts are responsible for choosing and configuring any outbound component
149
+ source. Tests use repo-owned fake responses only.
150
+
114
151
  ## Netlist Query
115
152
 
116
153
  ```js
@@ -34,6 +34,24 @@ Circuit JSON array. `JSON.stringify(result)` serializes only the Circuit JSON
34
34
  elements, including custom `altium_toolkit_*` sidecar elements; compatibility
35
35
  fields are intentionally omitted from serialized JSON.
36
36
 
37
+ ## Source Export Bundle
38
+
39
+ `SourceComponentBundleNormalizer` produces the exporter input contract used by
40
+ the source bundle, `.SchLib`, and `.PcbLib` writers:
41
+
42
+ - `id` and `name`: stable component identity
43
+ - `metadata`: provider metadata copied into deterministic plain-object form
44
+ - `symbol`: schematic symbol name, pins, primitives, and raw source object
45
+ - `footprint`: PCB footprint name, primitive families, and raw source object
46
+ - `models`: model id, file name, format, bytes/text, and optional source URL
47
+ - `sourceJson`: the original raw response retained for reproducible exports
48
+ - `diagnostics`: warnings for incomplete source data
49
+
50
+ `SourceBundleExporter.export()` serializes the original source response and a
51
+ manifest that lists included model assets. It does not fetch network resources;
52
+ callers provide already-normalized model bytes or use `SourceComponentClient`
53
+ before exporting.
54
+
37
55
  ## Renderer Compatibility Fields
38
56
 
39
57
  For compatibility, `AltiumParser.parseArrayBuffer()` attaches the previous
@@ -1548,7 +1548,7 @@
1548
1548
  "displayName",
1549
1549
  "includeInBom",
1550
1550
  "includeInNetlist",
1551
- "includeInPnp"
1551
+ "includeInPlacement"
1552
1552
  ],
1553
1553
  "properties": {
1554
1554
  "value": {
@@ -1566,7 +1566,7 @@
1566
1566
  "includeInNetlist": {
1567
1567
  "type": "boolean"
1568
1568
  },
1569
- "includeInPnp": {
1569
+ "includeInPlacement": {
1570
1570
  "type": "boolean"
1571
1571
  }
1572
1572
  },
package/docs/testing.md CHANGED
@@ -6,6 +6,11 @@ SPDX-License-Identifier: CC-BY-SA-4.0
6
6
 
7
7
  # Testing
8
8
 
9
+ Exporter tests use only synthetic component responses and generated OLE
10
+ streams. Do not add native customer files or provider-derived raw fixtures.
11
+ When exercising source lookup, inject a fake fetcher/client and assert emitted
12
+ entries, progress events, checkpoints, diagnostics, and OLE round trips.
13
+
9
14
  Run the complete suite:
10
15
 
11
16
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "altium-toolkit",
3
- "version": "1.1.3",
3
+ "version": "1.1.22",
4
4
  "description": "Altium document parsing and non-interactive rendering utilities",
5
5
  "keywords": [
6
6
  "altium",
@@ -31,6 +31,9 @@ rendering primitives.
31
31
  - Optional renderer CSS
32
32
  - Versioned normalized model schema identifiers and machine-readable schema
33
33
  contracts
34
+ - Source component client, source bundle exporter, generated `.SchLib` and
35
+ `.PcbLib` byte exporters, and batch export orchestration with progress,
36
+ checkpoint, append-skip, merged output, and retry-friendly client hooks
34
37
 
35
38
  ## Out Of Scope
36
39
 
@@ -40,6 +43,8 @@ rendering primitives.
40
43
  - Three.js runtime, OrbitControls, canvas mounting, and picking
41
44
  - STEP mesh loading and browser script injection
42
45
  - Model ZIP export UI and download orchestration
46
+ - Choosing a hosted component-source provider for applications; hosts inject
47
+ fetch and endpoint configuration explicitly
43
48
  - Server, deployment, and app metadata endpoints
44
49
  - Native document authoring, round-trip writing, GUI automation, and compiled
45
50
  multi-sheet project netlist generation
@@ -0,0 +1,206 @@
1
+ // SPDX-FileCopyrightText: 2026 André Fiedler
2
+ //
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+
5
+ import { AltiumPcbLibExporter } from './AltiumPcbLibExporter.mjs'
6
+ import { AltiumSchLibExporter } from './AltiumSchLibExporter.mjs'
7
+ import { SourceBundleExporter } from './SourceBundleExporter.mjs'
8
+
9
+ /**
10
+ * Orchestrates source lookup and local library export.
11
+ */
12
+ export class AltiumLibraryBatchExporter {
13
+ #client
14
+
15
+ /**
16
+ * @param {{ client?: { fetchComponentBundle?: Function, searchComponents?: Function } }} [options] Batch options.
17
+ */
18
+ constructor(options = {}) {
19
+ this.#client = options.client || null
20
+ }
21
+
22
+ /**
23
+ * Searches components and exports the matching ids.
24
+ * @param {string} query Search query.
25
+ * @param {object} [options] Export options.
26
+ * @returns {Promise<object>}
27
+ */
28
+ async searchAndExport(query, options = {}) {
29
+ const rows = await this.#requireClient().searchComponents(
30
+ query,
31
+ options
32
+ )
33
+ return this.exportIds(
34
+ rows.map((row) => row.id).filter(Boolean),
35
+ options
36
+ )
37
+ }
38
+
39
+ /**
40
+ * Exports one list of provider ids.
41
+ * @param {string[]} ids Component ids.
42
+ * @param {{ appendManifest?: { completedIds?: string[] }, includeSourceBundle?: boolean, includeSchLib?: boolean, includePcbLib?: boolean, merged?: boolean, continueOnError?: boolean, onProgress?: Function }} [options] Export options.
43
+ * @returns {Promise<{ entries: object[], bundles: object[], diagnostics: object[], checkpoint: { completedIds: string[] } }>}
44
+ */
45
+ async exportIds(ids, options = {}) {
46
+ const completedIds = [
47
+ ...new Set(options.appendManifest?.completedIds || [])
48
+ ]
49
+ const completedSet = new Set(completedIds)
50
+ const entries = []
51
+ const bundles = []
52
+ const diagnostics = []
53
+
54
+ for (const id of ids
55
+ .map((value) => String(value || ''))
56
+ .filter(Boolean)) {
57
+ if (completedSet.has(id)) {
58
+ AltiumLibraryBatchExporter.#emitProgress(options, {
59
+ id,
60
+ status: 'skipped'
61
+ })
62
+ continue
63
+ }
64
+
65
+ try {
66
+ const bundle =
67
+ await this.#requireClient().fetchComponentBundle(id)
68
+ bundles.push(bundle)
69
+ entries.push(
70
+ ...AltiumLibraryBatchExporter.#buildPerComponentEntries(
71
+ id,
72
+ bundle,
73
+ options
74
+ )
75
+ )
76
+ completedSet.add(id)
77
+ completedIds.push(id)
78
+ AltiumLibraryBatchExporter.#emitProgress(options, {
79
+ id,
80
+ status: 'exported'
81
+ })
82
+ } catch (error) {
83
+ diagnostics.push({
84
+ id,
85
+ severity: 'error',
86
+ message: String(error?.message || error)
87
+ })
88
+ AltiumLibraryBatchExporter.#emitProgress(options, {
89
+ id,
90
+ status: 'failed'
91
+ })
92
+ if (!options.continueOnError) {
93
+ throw error
94
+ }
95
+ }
96
+ }
97
+
98
+ if (options.merged && bundles.length) {
99
+ entries.push(
100
+ ...AltiumLibraryBatchExporter.#buildMergedEntries(bundles)
101
+ )
102
+ }
103
+
104
+ return {
105
+ entries,
106
+ bundles,
107
+ diagnostics,
108
+ checkpoint: { completedIds }
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Builds per-component export entries.
114
+ * @param {string} id Component id.
115
+ * @param {object} bundle Normalized bundle.
116
+ * @param {object} options Export options.
117
+ * @returns {object[]}
118
+ */
119
+ static #buildPerComponentEntries(id, bundle, options) {
120
+ const prefix = AltiumLibraryBatchExporter.#safePathSegment(id) + '/'
121
+ const entries = []
122
+
123
+ if (options.includeSourceBundle) {
124
+ entries.push(
125
+ ...SourceBundleExporter.export(bundle).entries.map((entry) => ({
126
+ ...entry,
127
+ path: prefix + entry.path
128
+ }))
129
+ )
130
+ }
131
+
132
+ if (options.includeSchLib) {
133
+ entries.push({
134
+ path: prefix + 'library.SchLib',
135
+ bytes: AltiumSchLibExporter.export([bundle]),
136
+ contentType: 'application/octet-stream'
137
+ })
138
+ }
139
+
140
+ if (options.includePcbLib) {
141
+ entries.push({
142
+ path: prefix + 'library.PcbLib',
143
+ bytes: AltiumPcbLibExporter.export([bundle]),
144
+ contentType: 'application/octet-stream'
145
+ })
146
+ }
147
+
148
+ return entries
149
+ }
150
+
151
+ /**
152
+ * Builds merged library output entries.
153
+ * @param {object[]} bundles Normalized bundles.
154
+ * @returns {object[]}
155
+ */
156
+ static #buildMergedEntries(bundles) {
157
+ return [
158
+ {
159
+ path: 'merged/library.SchLib',
160
+ bytes: AltiumSchLibExporter.export(bundles),
161
+ contentType: 'application/octet-stream'
162
+ },
163
+ {
164
+ path: 'merged/library.PcbLib',
165
+ bytes: AltiumPcbLibExporter.export(bundles),
166
+ contentType: 'application/octet-stream'
167
+ }
168
+ ]
169
+ }
170
+
171
+ /**
172
+ * Emits progress.
173
+ * @param {object} options Export options.
174
+ * @param {object} event Progress event.
175
+ * @returns {void}
176
+ */
177
+ static #emitProgress(options, event) {
178
+ if (typeof options.onProgress === 'function') {
179
+ options.onProgress(event)
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Sanitizes one path segment.
185
+ * @param {string} value Raw value.
186
+ * @returns {string}
187
+ */
188
+ static #safePathSegment(value) {
189
+ return String(value || 'component').replace(
190
+ /[\\/:\u0000-\u001f]/gu,
191
+ '_'
192
+ )
193
+ }
194
+
195
+ /**
196
+ * Returns the configured client or throws.
197
+ * @returns {{ fetchComponentBundle?: Function, searchComponents?: Function }}
198
+ */
199
+ #requireClient() {
200
+ if (!this.#client) {
201
+ throw new Error('AltiumLibraryBatchExporter client is required.')
202
+ }
203
+
204
+ return this.#client
205
+ }
206
+ }
@@ -0,0 +1,293 @@
1
+ // SPDX-FileCopyrightText: 2026 André Fiedler
2
+ //
3
+ // SPDX-License-Identifier: GPL-3.0-or-later
4
+
5
+ /**
6
+ * Builds deterministic textual and byte records for generated Altium libraries.
7
+ */
8
+ export class AltiumLibraryRecordBuilder {
9
+ /**
10
+ * Builds a schematic component record.
11
+ * @param {object} bundle Normalized component bundle.
12
+ * @returns {string}
13
+ */
14
+ static buildSchematicComponentRecord(bundle) {
15
+ return AltiumLibraryRecordBuilder.#pipeRecord({
16
+ RECORD: 'Component',
17
+ Name: bundle.symbol.name,
18
+ SourceId: bundle.id,
19
+ DisplayName: bundle.name,
20
+ PinCount: String(bundle.symbol.pins.length),
21
+ PrimitiveCount: String(bundle.symbol.primitives.length)
22
+ })
23
+ }
24
+
25
+ /**
26
+ * Builds a PCB footprint record.
27
+ * @param {object} bundle Normalized component bundle.
28
+ * @returns {string}
29
+ */
30
+ static buildPcbFootprintRecord(bundle) {
31
+ return AltiumLibraryRecordBuilder.#pipeRecord({
32
+ RECORD: 'Footprint',
33
+ Name: bundle.footprint.name,
34
+ SourceId: bundle.id,
35
+ DisplayName: bundle.name,
36
+ PadCount: String(bundle.footprint.pads.length),
37
+ TrackCount: String(bundle.footprint.tracks.length),
38
+ ModelCount: String(bundle.models.length)
39
+ })
40
+ }
41
+
42
+ /**
43
+ * Builds a PcbLib Library/Data stream.
44
+ * @param {object[]} bundles Normalized component bundles.
45
+ * @returns {Uint8Array}
46
+ */
47
+ static buildPcbLibraryData(bundles) {
48
+ const countBytes = AltiumLibraryRecordBuilder.createCountHeader(
49
+ bundles.length
50
+ )
51
+
52
+ return AltiumLibraryRecordBuilder.concatBytes([
53
+ AltiumLibraryRecordBuilder.createProperties({
54
+ HEADER: 'PCB 6.0 Binary Library File',
55
+ WEIGHT: '0',
56
+ GENERATEDBY: 'ECAD Forge'
57
+ }),
58
+ countBytes,
59
+ ...bundles.map((bundle) =>
60
+ AltiumLibraryRecordBuilder.createStringBlock(
61
+ bundle.footprint.name
62
+ )
63
+ )
64
+ ])
65
+ }
66
+
67
+ /**
68
+ * Builds a PcbLib component parameters table.
69
+ * @param {object[]} bundles Normalized component bundles.
70
+ * @returns {Uint8Array}
71
+ */
72
+ static buildComponentParamsToc(bundles) {
73
+ return AltiumLibraryRecordBuilder.concatBytes(
74
+ bundles.map((bundle) =>
75
+ AltiumLibraryRecordBuilder.createLengthPrefixedAscii(
76
+ AltiumLibraryRecordBuilder.#pipeRecord({
77
+ Name: bundle.footprint.name,
78
+ 'Pad Count': String(bundle.footprint.pads.length),
79
+ Height: String(bundle.metadata.height || ''),
80
+ Description: String(bundle.metadata.description || '')
81
+ }) + '\r\n\u0000'
82
+ )
83
+ )
84
+ )
85
+ }
86
+
87
+ /**
88
+ * Builds a SectionKeys stream.
89
+ * @param {object[]} bundles Normalized component bundles.
90
+ * @returns {Uint8Array}
91
+ */
92
+ static buildSectionKeys(bundles) {
93
+ const entries = bundles.map((bundle) => ({
94
+ fullName: bundle.footprint.name,
95
+ storageName: AltiumLibraryRecordBuilder.sanitizeStorageName(
96
+ bundle.footprint.name
97
+ )
98
+ }))
99
+
100
+ return AltiumLibraryRecordBuilder.concatBytes([
101
+ AltiumLibraryRecordBuilder.createCountHeader(entries.length),
102
+ ...entries.flatMap((entry) => [
103
+ AltiumLibraryRecordBuilder.createStringBlock(entry.fullName),
104
+ AltiumLibraryRecordBuilder.createStringBlock(entry.storageName)
105
+ ])
106
+ ])
107
+ }
108
+
109
+ /**
110
+ * Builds a footprint Data stream.
111
+ * @param {object} bundle Normalized component bundle.
112
+ * @returns {Uint8Array}
113
+ */
114
+ static buildFootprintData(bundle) {
115
+ return AltiumLibraryRecordBuilder.concatBytes([
116
+ AltiumLibraryRecordBuilder.createStringBlock(bundle.footprint.name)
117
+ ])
118
+ }
119
+
120
+ /**
121
+ * Builds a footprint Parameters stream.
122
+ * @param {object} bundle Normalized component bundle.
123
+ * @returns {Uint8Array}
124
+ */
125
+ static buildFootprintParameters(bundle) {
126
+ return AltiumLibraryRecordBuilder.createProperties({
127
+ PATTERN: bundle.footprint.name,
128
+ DESCRIPTION: String(bundle.metadata.description || ''),
129
+ HEIGHT: String(bundle.metadata.height || ''),
130
+ ITEMGUID: AltiumLibraryRecordBuilder.#guidFromText(bundle.id)
131
+ })
132
+ }
133
+
134
+ /**
135
+ * Builds model metadata entries.
136
+ * @param {{ model: object, id: string, checksum: number }[]} models Model rows.
137
+ * @returns {Uint8Array}
138
+ */
139
+ static buildModelsData(models) {
140
+ return AltiumLibraryRecordBuilder.concatBytes(
141
+ models.map((row) =>
142
+ AltiumLibraryRecordBuilder.createLengthPrefixedAscii(
143
+ AltiumLibraryRecordBuilder.#pipeRecord({
144
+ ID: row.id,
145
+ NAME: row.model.name,
146
+ CHECKSUM: String(row.checksum),
147
+ FORMAT: row.model.format
148
+ }) + '\u0000'
149
+ )
150
+ )
151
+ )
152
+ }
153
+
154
+ /**
155
+ * Creates a little-endian count header.
156
+ * @param {number} count Count value.
157
+ * @returns {Uint8Array}
158
+ */
159
+ static createCountHeader(count) {
160
+ const bytes = new Uint8Array(4)
161
+ new DataView(bytes.buffer).setUint32(0, Number(count || 0), true)
162
+ return bytes
163
+ }
164
+
165
+ /**
166
+ * Creates a PcbLib property stream.
167
+ * @param {Record<string, string>} properties Properties.
168
+ * @returns {Uint8Array}
169
+ */
170
+ static createProperties(properties) {
171
+ return AltiumLibraryRecordBuilder.createLengthPrefixedAscii(
172
+ AltiumLibraryRecordBuilder.#pipeRecord(properties) + '\u0000'
173
+ )
174
+ }
175
+
176
+ /**
177
+ * Creates a Pascal-style string block.
178
+ * @param {string} text Text value.
179
+ * @returns {Uint8Array}
180
+ */
181
+ static createStringBlock(text) {
182
+ const encoded = new TextEncoder().encode(String(text || ''))
183
+ const bytes = new Uint8Array(4 + 1 + encoded.byteLength)
184
+ const view = new DataView(bytes.buffer)
185
+
186
+ view.setUint32(0, 1 + encoded.byteLength, true)
187
+ bytes[4] = encoded.byteLength
188
+ bytes.set(encoded, 5)
189
+
190
+ return bytes
191
+ }
192
+
193
+ /**
194
+ * Creates a length-prefixed ASCII/UTF-8 byte block.
195
+ * @param {string} text Text body.
196
+ * @returns {Uint8Array}
197
+ */
198
+ static createLengthPrefixedAscii(text) {
199
+ const encoded = new TextEncoder().encode(String(text || ''))
200
+ const bytes = new Uint8Array(4 + encoded.byteLength)
201
+
202
+ new DataView(bytes.buffer).setUint32(0, encoded.byteLength, true)
203
+ bytes.set(encoded, 4)
204
+
205
+ return bytes
206
+ }
207
+
208
+ /**
209
+ * Concatenates byte chunks.
210
+ * @param {Uint8Array[]} chunks Byte chunks.
211
+ * @returns {Uint8Array}
212
+ */
213
+ static concatBytes(chunks) {
214
+ const byteLength = chunks.reduce(
215
+ (sum, chunk) => sum + chunk.byteLength,
216
+ 0
217
+ )
218
+ const bytes = new Uint8Array(byteLength)
219
+ let offset = 0
220
+
221
+ for (const chunk of chunks) {
222
+ bytes.set(chunk, offset)
223
+ offset += chunk.byteLength
224
+ }
225
+
226
+ return bytes
227
+ }
228
+
229
+ /**
230
+ * Sanitizes one OLE storage name.
231
+ * @param {string} name Storage name.
232
+ * @returns {string}
233
+ */
234
+ static sanitizeStorageName(name) {
235
+ return String(name || 'Component')
236
+ .replace(/[\\/:\u0000-\u001f]/gu, '_')
237
+ .slice(0, 31)
238
+ }
239
+
240
+ /**
241
+ * Computes a simple deterministic checksum for generated model metadata.
242
+ * @param {Uint8Array} bytes Model bytes.
243
+ * @returns {number}
244
+ */
245
+ static checksumBytes(bytes) {
246
+ return [...bytes].reduce(
247
+ (checksum, value) => (checksum + value) >>> 0,
248
+ 0
249
+ )
250
+ }
251
+
252
+ /**
253
+ * Builds one pipe-delimited record.
254
+ * @param {Record<string, string>} fields Record fields.
255
+ * @returns {string}
256
+ */
257
+ static #pipeRecord(fields) {
258
+ return (
259
+ '|' +
260
+ Object.entries(fields)
261
+ .filter(([, value]) => String(value ?? '') !== '')
262
+ .map(([key, value]) => key + '=' + String(value))
263
+ .join('|')
264
+ )
265
+ }
266
+
267
+ /**
268
+ * Builds a deterministic GUID-like id from text.
269
+ * @param {string} text Source text.
270
+ * @returns {string}
271
+ */
272
+ static #guidFromText(text) {
273
+ const hex = [...new TextEncoder().encode(String(text || ''))]
274
+ .map((value) => value.toString(16).padStart(2, '0'))
275
+ .join('')
276
+ .padEnd(32, '0')
277
+ .slice(0, 32)
278
+
279
+ return (
280
+ '{' +
281
+ hex.slice(0, 8) +
282
+ '-' +
283
+ hex.slice(8, 12) +
284
+ '-' +
285
+ hex.slice(12, 16) +
286
+ '-' +
287
+ hex.slice(16, 20) +
288
+ '-' +
289
+ hex.slice(20) +
290
+ '}'
291
+ )
292
+ }
293
+ }
@@ -238,8 +238,11 @@ export class AltiumParser {
238
238
  const rectangleRecords = drawableRecords.filter(
239
239
  (record) =>
240
240
  SchematicPrimitiveParser.isRectangleRecord(record.fields) &&
241
- AltiumParser.#hasCoordinatePair(record.fields, 'Location') &&
242
- AltiumParser.#hasCoordinatePair(record.fields, 'Corner')
241
+ ((AltiumParser.#hasCoordinatePair(record.fields, 'Location') &&
242
+ AltiumParser.#hasCoordinatePair(record.fields, 'Corner')) ||
243
+ SchematicPrimitiveParser.isPointListedRectangleRecord(
244
+ record.fields
245
+ ))
243
246
  )
244
247
  const roundedRectangleRecords = drawableRecords.filter(
245
248
  (record) =>