altium-to-circuit-json 0.0.45 → 0.0.47
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/README.md +18 -0
- package/dist/index.d.ts +84 -13
- package/dist/index.js +4765 -3469
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -39,6 +39,24 @@ The public conversion functions are:
|
|
|
39
39
|
- `convertAltiumPcbDocToCircuitJson(document, options)` for PCB documents.
|
|
40
40
|
- `convertAltiumSchDocToCircuitJson(document, options)` for schematic documents.
|
|
41
41
|
|
|
42
|
+
For callers that need progress visibility, debugging, or custom orchestration,
|
|
43
|
+
the same conversion is exposed as a staged converter:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { AltiumToCircuitJsonConverter } from "altium-to-circuit-json"
|
|
47
|
+
|
|
48
|
+
const converter = new AltiumToCircuitJsonConverter(bytes)
|
|
49
|
+
while (!converter.finished) {
|
|
50
|
+
console.log(converter.currentStage?.constructor.name)
|
|
51
|
+
converter.step()
|
|
52
|
+
}
|
|
53
|
+
const circuitJson = converter.getOutput()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Each stage has the standard converter contract: `step()`,
|
|
57
|
+
`runUntilFinished()`, `finished`, and `getOutput()`. The parser boundary stays
|
|
58
|
+
in `altiumts`; conversion stages consume typed Altium documents and records.
|
|
59
|
+
|
|
42
60
|
## Current coverage
|
|
43
61
|
|
|
44
62
|
PCB conversion currently emits:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AnyCircuitElement, SourceNet, SourceTrace } from 'circuit-json';
|
|
2
|
+
import { AltiumPcbDocument, AltiumRecord, AltiumSchDoc } from 'altiumts';
|
|
3
3
|
|
|
4
4
|
interface ConvertAltiumPcbDocOptions {
|
|
5
5
|
includeBoardOutline?: boolean;
|
|
6
6
|
includeComponents?: boolean;
|
|
7
7
|
includeCopperAreas?: boolean;
|
|
8
8
|
includeCourtyards?: boolean;
|
|
9
|
-
includeKeepouts?: boolean;
|
|
10
9
|
includeDimensions?: boolean;
|
|
10
|
+
includeKeepouts?: boolean;
|
|
11
11
|
includePads?: boolean;
|
|
12
12
|
includeSilkscreen?: boolean;
|
|
13
13
|
includeTraces?: boolean;
|
|
14
14
|
includeVias?: boolean;
|
|
15
15
|
}
|
|
16
|
+
interface PcbNetContext {
|
|
17
|
+
elements: Array<SourceNet | SourceTrace>;
|
|
18
|
+
getSourceNetId: (record: AltiumRecord) => string | undefined;
|
|
19
|
+
getSourceTraceId: (record: AltiumRecord) => string | undefined;
|
|
20
|
+
}
|
|
21
|
+
interface PcbConversionContext {
|
|
22
|
+
document: AltiumPcbDocument;
|
|
23
|
+
elements: AnyCircuitElement[];
|
|
24
|
+
netContext: PcbNetContext;
|
|
25
|
+
options: ConvertAltiumPcbDocOptions;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface SchematicConversionContext extends SchematicContext {
|
|
29
|
+
elements: AnyCircuitElement[];
|
|
30
|
+
handledRecords: Set<AltiumRecord>;
|
|
31
|
+
options: ConvertAltiumSchDocOptions;
|
|
32
|
+
sheetDimensions: SheetDimensions;
|
|
33
|
+
}
|
|
34
|
+
interface SheetDimensions {
|
|
35
|
+
height: number;
|
|
36
|
+
width: number;
|
|
37
|
+
}
|
|
38
|
+
interface SchematicContext {
|
|
39
|
+
document: AltiumSchDoc;
|
|
40
|
+
records: AltiumRecord[];
|
|
41
|
+
scale: number;
|
|
42
|
+
sheetRecord?: AltiumRecord;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type AltiumSource = ArrayBuffer | Uint8Array | string;
|
|
46
|
+
type AltiumSourceType = "auto" | "pcb" | "schematic";
|
|
47
|
+
type SupportedAltiumDocument = AltiumPcbDocument | AltiumSchDoc;
|
|
48
|
+
interface ConvertAltiumToCircuitJsonOptions {
|
|
49
|
+
pcb?: ConvertAltiumPcbDocOptions;
|
|
50
|
+
schematic?: ConvertAltiumSchDocOptions;
|
|
51
|
+
sourceType?: AltiumSourceType;
|
|
52
|
+
}
|
|
53
|
+
interface AltiumToCircuitJsonConverterContext {
|
|
54
|
+
document: SupportedAltiumDocument;
|
|
55
|
+
elements: AnyCircuitElement[];
|
|
56
|
+
options: ConvertAltiumToCircuitJsonOptions;
|
|
57
|
+
pcb?: PcbConversionContext;
|
|
58
|
+
schematic?: SchematicConversionContext;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
declare abstract class ConverterStage<Input, Output> {
|
|
62
|
+
readonly input: Input;
|
|
63
|
+
readonly context: AltiumToCircuitJsonConverterContext;
|
|
64
|
+
readonly maxIterations = 1000;
|
|
65
|
+
iteration: number;
|
|
66
|
+
finished: boolean;
|
|
67
|
+
constructor(input: Input, context: AltiumToCircuitJsonConverterContext);
|
|
68
|
+
step(): void;
|
|
69
|
+
abstract _step(): void;
|
|
70
|
+
runUntilFinished(): void;
|
|
71
|
+
abstract getOutput(): Output;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare class AltiumToCircuitJsonConverter {
|
|
75
|
+
readonly context: AltiumToCircuitJsonConverterContext;
|
|
76
|
+
readonly pipeline: ConverterStage<SupportedAltiumDocument, unknown>[];
|
|
77
|
+
currentStageIndex: number;
|
|
78
|
+
finished: boolean;
|
|
79
|
+
constructor(source: AltiumSource | SupportedAltiumDocument, options?: ConvertAltiumToCircuitJsonOptions);
|
|
80
|
+
get currentStage(): ConverterStage<SupportedAltiumDocument, unknown> | undefined;
|
|
81
|
+
step(): void;
|
|
82
|
+
runUntilFinished(): void;
|
|
83
|
+
getOutput(): AnyCircuitElement[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare function isSupportedAltiumDocument(source: unknown): source is SupportedAltiumDocument;
|
|
87
|
+
|
|
88
|
+
declare function parseAltiumSource(source: AltiumSource, sourceType: "auto" | "pcb" | "schematic"): SupportedAltiumDocument;
|
|
89
|
+
|
|
90
|
+
declare function toUint8Array(source: AltiumSource): Uint8Array;
|
|
91
|
+
|
|
92
|
+
declare function convertAltiumDocumentToCircuitJson(document: unknown, options?: ConvertAltiumToCircuitJsonOptions): AnyCircuitElement[];
|
|
93
|
+
|
|
16
94
|
declare function convertAltiumPcbDocToCircuitJson(document: AltiumPcbDocument, options?: ConvertAltiumPcbDocOptions): AnyCircuitElement[];
|
|
17
95
|
|
|
18
96
|
interface ConvertAltiumSchDocOptions {
|
|
@@ -23,16 +101,9 @@ interface ConvertAltiumSchDocOptions {
|
|
|
23
101
|
schematicUnitScale?: number;
|
|
24
102
|
sheetName?: string;
|
|
25
103
|
}
|
|
104
|
+
|
|
26
105
|
declare function convertAltiumSchDocToCircuitJson(document: AltiumSchDoc, options?: ConvertAltiumSchDocOptions): AnyCircuitElement[];
|
|
27
106
|
|
|
28
|
-
|
|
29
|
-
interface ConvertAltiumToCircuitJsonOptions {
|
|
30
|
-
pcb?: ConvertAltiumPcbDocOptions;
|
|
31
|
-
schematic?: ConvertAltiumSchDocOptions;
|
|
32
|
-
sourceType?: AltiumSourceType;
|
|
33
|
-
}
|
|
34
|
-
type SupportedAltiumDocument = AltiumPcbDocument | AltiumSchDoc;
|
|
35
|
-
declare function convertAltiumToCircuitJson(source: ArrayBuffer | Uint8Array | string, options?: ConvertAltiumToCircuitJsonOptions): AnyCircuitElement[];
|
|
36
|
-
declare function convertAltiumDocumentToCircuitJson(document: unknown, options?: ConvertAltiumToCircuitJsonOptions): AnyCircuitElement[];
|
|
107
|
+
declare function convertAltiumToCircuitJson(source: AltiumSource, options?: ConvertAltiumToCircuitJsonOptions): AnyCircuitElement[];
|
|
37
108
|
|
|
38
|
-
export { type AltiumSourceType, type ConvertAltiumPcbDocOptions, type ConvertAltiumSchDocOptions, type ConvertAltiumToCircuitJsonOptions, type SupportedAltiumDocument, convertAltiumDocumentToCircuitJson, convertAltiumPcbDocToCircuitJson, convertAltiumSchDocToCircuitJson, convertAltiumToCircuitJson };
|
|
109
|
+
export { type AltiumSource, type AltiumSourceType, AltiumToCircuitJsonConverter, type AltiumToCircuitJsonConverterContext, type ConvertAltiumPcbDocOptions, type ConvertAltiumSchDocOptions, type ConvertAltiumToCircuitJsonOptions, ConverterStage, type SupportedAltiumDocument, convertAltiumDocumentToCircuitJson, convertAltiumPcbDocToCircuitJson, convertAltiumSchDocToCircuitJson, convertAltiumToCircuitJson, isSupportedAltiumDocument, parseAltiumSource, toUint8Array };
|