@tscircuit/internal-dynamic-import 0.0.7 → 0.0.9
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/dist/index.d.ts +485 -15
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,73 @@
|
|
|
1
|
+
import * as circuit_json_to_gltf from 'circuit-json-to-gltf';
|
|
1
2
|
import { AnyCircuitElement, SourceComponentBase, PcbComponent, CircuitJson, SchematicNetLabel, PCBTrace, PCBPort, LayerRef as LayerRef$1, NinePointAnchor, PcbRenderLayer, PcbBoard, PcbCopperPour, PcbCopperText, PcbCourtyardCircle, PcbCutout, PcbFabricationNoteDimension, PcbFabricationNotePath, PcbFabricationNoteRect, PcbFabricationNoteText, PcbHole, PCBKeepout, PcbNoteDimension, PcbNotePath, PcbNoteRect, PcbNoteText, PcbPanel, PcbPlatedHole, PcbSilkscreenCircle, PcbSilkscreenLine, PcbSilkscreenOval, PcbSilkscreenPath, PcbSilkscreenPill, PcbSilkscreenRect, PcbSilkscreenText, PcbSmtPad, PcbTrace, PcbVia, PCBVia, SimulationExperiment, SimulationTransientVoltageGraph, SimulationVoltageProbe, PcbPort, SchematicComponent } from 'circuit-json';
|
|
2
3
|
import { BpcGraph } from 'bpc-graph';
|
|
3
4
|
import { z, AnyZodObject } from 'zod';
|
|
4
5
|
import { CircuitJsonUtilObjects, cju } from '@tscircuit/circuit-json-util';
|
|
5
|
-
import { KicadSch, KicadPcb, SchematicSymbol } from 'kicadts';
|
|
6
|
+
import { KicadSch, KicadPcb, SchematicSymbol, KicadSym } from 'kicadts';
|
|
6
7
|
import { Matrix } from 'transformation-matrix';
|
|
7
8
|
import { LightBurnProject } from 'lbrnts';
|
|
8
9
|
import { Box } from '@tscircuit/simple-3d-svg';
|
|
9
10
|
import { INode } from 'svgson';
|
|
10
11
|
|
|
12
|
+
type CameraOptions = {
|
|
13
|
+
camPos: readonly [number, number, number];
|
|
14
|
+
lookAt: readonly [number, number, number];
|
|
15
|
+
fov: number;
|
|
16
|
+
};
|
|
17
|
+
declare const CAMERA_PRESETS: {
|
|
18
|
+
readonly "top-down": (cam: CameraOptions) => CameraOptions;
|
|
19
|
+
readonly "top-down-ortho": (cam: CameraOptions) => CameraOptions;
|
|
20
|
+
readonly "top-left-corner": (cam: CameraOptions) => CameraOptions;
|
|
21
|
+
readonly "top-left": (cam: CameraOptions) => CameraOptions;
|
|
22
|
+
readonly "top-right-corner": (cam: CameraOptions) => CameraOptions;
|
|
23
|
+
readonly "top-right": (cam: CameraOptions) => CameraOptions;
|
|
24
|
+
readonly "left-sideview": (cam: CameraOptions) => CameraOptions;
|
|
25
|
+
readonly "right-sideview": (cam: CameraOptions) => CameraOptions;
|
|
26
|
+
readonly front: (cam: CameraOptions) => CameraOptions;
|
|
27
|
+
readonly "top-center-angled": (cam: CameraOptions) => CameraOptions;
|
|
28
|
+
};
|
|
29
|
+
type CameraPreset = keyof typeof CAMERA_PRESETS;
|
|
30
|
+
declare const CAMERA_PRESET_NAMES: CameraPreset[];
|
|
31
|
+
declare function applyCameraPreset(preset: CameraPreset, cam: CameraOptions): CameraOptions;
|
|
32
|
+
|
|
33
|
+
type ConvertCircuitJsonTo3dGltfResult = Awaited<ReturnType<typeof circuit_json_to_gltf["convertCircuitJsonToGltf"]>>;
|
|
34
|
+
type CircuitJson3dBaseOptions = {
|
|
35
|
+
modelPathBaseDir?: string;
|
|
36
|
+
projectBaseUrl?: string;
|
|
37
|
+
authHeaders?: {
|
|
38
|
+
Authorization: string;
|
|
39
|
+
};
|
|
40
|
+
boardTextureResolution?: number;
|
|
41
|
+
};
|
|
42
|
+
type RenderCircuitJsonTo3dPngOptions = CircuitJson3dBaseOptions & {
|
|
43
|
+
camera?: CameraOptions;
|
|
44
|
+
cameraPreset?: CameraPreset;
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
47
|
+
backgroundColor?: string | readonly [number, number, number] | null;
|
|
48
|
+
showInfiniteGrid?: boolean;
|
|
49
|
+
supersampling?: number;
|
|
50
|
+
};
|
|
51
|
+
declare const getDefaultCameraForCircuitJson: (circuitJson: AnyCircuitElement[]) => Promise<CameraOptions>;
|
|
52
|
+
declare const convertCircuitJsonTo3dGltf: (circuitJson: AnyCircuitElement[], options?: CircuitJson3dBaseOptions) => Promise<ConvertCircuitJsonTo3dGltfResult>;
|
|
53
|
+
declare const convertCircuitJsonTo3dGlb: (circuitJson: AnyCircuitElement[], options?: CircuitJson3dBaseOptions) => Promise<Uint8Array>;
|
|
54
|
+
declare const renderCircuitJsonTo3dPng: (circuitJson: AnyCircuitElement[], options?: RenderCircuitJsonTo3dPngOptions) => Promise<Uint8Array>;
|
|
55
|
+
|
|
56
|
+
declare const CircuitJsonTo3dPngModule_CAMERA_PRESET_NAMES: typeof CAMERA_PRESET_NAMES;
|
|
57
|
+
type CircuitJsonTo3dPngModule_CameraOptions = CameraOptions;
|
|
58
|
+
type CircuitJsonTo3dPngModule_CameraPreset = CameraPreset;
|
|
59
|
+
type CircuitJsonTo3dPngModule_CircuitJson3dBaseOptions = CircuitJson3dBaseOptions;
|
|
60
|
+
type CircuitJsonTo3dPngModule_ConvertCircuitJsonTo3dGltfResult = ConvertCircuitJsonTo3dGltfResult;
|
|
61
|
+
type CircuitJsonTo3dPngModule_RenderCircuitJsonTo3dPngOptions = RenderCircuitJsonTo3dPngOptions;
|
|
62
|
+
declare const CircuitJsonTo3dPngModule_applyCameraPreset: typeof applyCameraPreset;
|
|
63
|
+
declare const CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGlb: typeof convertCircuitJsonTo3dGlb;
|
|
64
|
+
declare const CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGltf: typeof convertCircuitJsonTo3dGltf;
|
|
65
|
+
declare const CircuitJsonTo3dPngModule_getDefaultCameraForCircuitJson: typeof getDefaultCameraForCircuitJson;
|
|
66
|
+
declare const CircuitJsonTo3dPngModule_renderCircuitJsonTo3dPng: typeof renderCircuitJsonTo3dPng;
|
|
67
|
+
declare namespace CircuitJsonTo3dPngModule {
|
|
68
|
+
export { CircuitJsonTo3dPngModule_CAMERA_PRESET_NAMES as CAMERA_PRESET_NAMES, type CircuitJsonTo3dPngModule_CameraOptions as CameraOptions, type CircuitJsonTo3dPngModule_CameraPreset as CameraPreset, type CircuitJsonTo3dPngModule_CircuitJson3dBaseOptions as CircuitJson3dBaseOptions, type CircuitJsonTo3dPngModule_ConvertCircuitJsonTo3dGltfResult as ConvertCircuitJsonTo3dGltfResult, type CircuitJsonTo3dPngModule_RenderCircuitJsonTo3dPngOptions as RenderCircuitJsonTo3dPngOptions, CircuitJsonTo3dPngModule_applyCameraPreset as applyCameraPreset, CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGlb as convertCircuitJsonTo3dGlb, CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGltf as convertCircuitJsonTo3dGltf, CircuitJsonTo3dPngModule_getDefaultCameraForCircuitJson as getDefaultCameraForCircuitJson, CircuitJsonTo3dPngModule_renderCircuitJsonTo3dPng as renderCircuitJsonTo3dPng };
|
|
69
|
+
}
|
|
70
|
+
|
|
11
71
|
type SupplierPartNumberColumn = "JLCPCB Part #";
|
|
12
72
|
interface BomRow {
|
|
13
73
|
designator: string;
|
|
@@ -1116,7 +1176,7 @@ interface KicadLibraryOutput {
|
|
|
1116
1176
|
symLibTableString: string;
|
|
1117
1177
|
model3dSourcePaths: string[];
|
|
1118
1178
|
}
|
|
1119
|
-
interface ConverterContext {
|
|
1179
|
+
interface ConverterContext$1 {
|
|
1120
1180
|
db: CircuitJsonUtilObjects;
|
|
1121
1181
|
circuitJson: CircuitJson;
|
|
1122
1182
|
kicadSch?: KicadSch;
|
|
@@ -1152,13 +1212,13 @@ interface ConverterContext {
|
|
|
1152
1212
|
footprintEntries?: FootprintEntry[];
|
|
1153
1213
|
libraryOutput?: KicadLibraryOutput;
|
|
1154
1214
|
}
|
|
1155
|
-
declare abstract class ConverterStage<Input, Output> {
|
|
1215
|
+
declare abstract class ConverterStage$1<Input, Output> {
|
|
1156
1216
|
MAX_ITERATIONS: number;
|
|
1157
1217
|
iteration: number;
|
|
1158
1218
|
finished: boolean;
|
|
1159
1219
|
input: Input;
|
|
1160
|
-
ctx: ConverterContext;
|
|
1161
|
-
constructor(input: Input, ctx: ConverterContext);
|
|
1220
|
+
ctx: ConverterContext$1;
|
|
1221
|
+
constructor(input: Input, ctx: ConverterContext$1);
|
|
1162
1222
|
step(): void;
|
|
1163
1223
|
_step(): void;
|
|
1164
1224
|
runUntilFinished(): void;
|
|
@@ -1166,11 +1226,11 @@ declare abstract class ConverterStage<Input, Output> {
|
|
|
1166
1226
|
}
|
|
1167
1227
|
|
|
1168
1228
|
declare class CircuitJsonToKicadSchConverter {
|
|
1169
|
-
ctx: ConverterContext;
|
|
1170
|
-
pipeline: ConverterStage<CircuitJson, KicadSch>[];
|
|
1229
|
+
ctx: ConverterContext$1;
|
|
1230
|
+
pipeline: ConverterStage$1<CircuitJson, KicadSch>[];
|
|
1171
1231
|
currentStageIndex: number;
|
|
1172
1232
|
finished: boolean;
|
|
1173
|
-
get currentStage(): ConverterStage<CircuitJson, KicadSch> | undefined;
|
|
1233
|
+
get currentStage(): ConverterStage$1<CircuitJson, KicadSch> | undefined;
|
|
1174
1234
|
constructor(circuitJson: CircuitJson);
|
|
1175
1235
|
step(): void;
|
|
1176
1236
|
runUntilFinished(): void;
|
|
@@ -1195,11 +1255,11 @@ interface CircuitJsonToKicadPcbOptions {
|
|
|
1195
1255
|
projectName?: string;
|
|
1196
1256
|
}
|
|
1197
1257
|
declare class CircuitJsonToKicadPcbConverter {
|
|
1198
|
-
ctx: ConverterContext;
|
|
1199
|
-
pipeline: ConverterStage<CircuitJson, KicadPcb>[];
|
|
1258
|
+
ctx: ConverterContext$1;
|
|
1259
|
+
pipeline: ConverterStage$1<CircuitJson, KicadPcb>[];
|
|
1200
1260
|
currentStageIndex: number;
|
|
1201
1261
|
finished: boolean;
|
|
1202
|
-
get currentStage(): ConverterStage<CircuitJson, KicadPcb> | undefined;
|
|
1262
|
+
get currentStage(): ConverterStage$1<CircuitJson, KicadPcb> | undefined;
|
|
1203
1263
|
constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadPcbOptions);
|
|
1204
1264
|
step(): void;
|
|
1205
1265
|
runUntilFinished(): void;
|
|
@@ -1362,11 +1422,11 @@ interface CircuitJsonToKicadLibraryOptions {
|
|
|
1362
1422
|
}
|
|
1363
1423
|
|
|
1364
1424
|
declare class CircuitJsonToKicadLibraryConverter {
|
|
1365
|
-
ctx: ConverterContext;
|
|
1366
|
-
pipeline: ConverterStage<CircuitJson, KicadLibraryOutput>[];
|
|
1425
|
+
ctx: ConverterContext$1;
|
|
1426
|
+
pipeline: ConverterStage$1<CircuitJson, KicadLibraryOutput>[];
|
|
1367
1427
|
currentStageIndex: number;
|
|
1368
1428
|
finished: boolean;
|
|
1369
|
-
get currentStage(): ConverterStage<CircuitJson, KicadLibraryOutput> | undefined;
|
|
1429
|
+
get currentStage(): ConverterStage$1<CircuitJson, KicadLibraryOutput> | undefined;
|
|
1370
1430
|
constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadLibraryOptions);
|
|
1371
1431
|
step(): void;
|
|
1372
1432
|
runUntilFinished(): void;
|
|
@@ -3054,10 +3114,419 @@ declare namespace CircuitToSvgModule {
|
|
|
3054
3114
|
export { type CircuitToSvgModule_AssemblySvgContext as AssemblySvgContext, CircuitToSvgModule_CIRCUIT_TO_SVG_VERSION as CIRCUIT_TO_SVG_VERSION, type CircuitToSvgModule_CircuitJsonWithSimulation as CircuitJsonWithSimulation, type CircuitToSvgModule_ColorMap as ColorMap, type CircuitToSvgModule_ColorOverrides as ColorOverrides, type CircuitToSvgModule_PcbColorMap as PcbColorMap, type CircuitToSvgModule_PcbColorOverrides as PcbColorOverrides, type CircuitToSvgModule_PcbContext as PcbContext, type CircuitToSvgModule_PcbSvgOptions as PcbSvgOptions, type CircuitToSvgModule_PinoutLabel as PinoutLabel, type CircuitToSvgModule_PinoutSvgContext as PinoutSvgContext, CircuitToSvgModule_circuitJsonToPcbSvg as circuitJsonToPcbSvg, CircuitToSvgModule_circuitJsonToSchematicSvg as circuitJsonToSchematicSvg, CircuitToSvgModule_convertCircuitJsonToAssemblySvg as convertCircuitJsonToAssemblySvg, CircuitToSvgModule_convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg, CircuitToSvgModule_convertCircuitJsonToPinoutSvg as convertCircuitJsonToPinoutSvg, CircuitToSvgModule_convertCircuitJsonToSchematicSimulationSvg as convertCircuitJsonToSchematicSimulationSvg, CircuitToSvgModule_convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg, CircuitToSvgModule_convertCircuitJsonToSimulationGraphSvg as convertCircuitJsonToSimulationGraphSvg, CircuitToSvgModule_convertCircuitJsonToSolderPasteMask as convertCircuitJsonToSolderPasteMask, CircuitToSvgModule_createErrorTextOverlay as createErrorTextOverlay, CircuitToSvgModule_createSvgObjectsForSchComponentPortHovers as createSvgObjectsForSchComponentPortHovers, CircuitToSvgModule_getSoftwareUsedString as getSoftwareUsedString, CircuitToSvgModule_isSimulationExperiment as isSimulationExperiment, CircuitToSvgModule_isSimulationTransientVoltageGraph as isSimulationTransientVoltageGraph, CircuitToSvgModule_isSimulationVoltageProbe as isSimulationVoltageProbe };
|
|
3055
3115
|
}
|
|
3056
3116
|
|
|
3057
|
-
|
|
3117
|
+
interface ConverterContext {
|
|
3118
|
+
db: CircuitJsonUtilObjects;
|
|
3119
|
+
kicadPcb?: KicadPcb;
|
|
3120
|
+
kicadSch?: KicadSch;
|
|
3121
|
+
kicadSymbolLib?: KicadSym;
|
|
3122
|
+
k2cMatSch?: Matrix;
|
|
3123
|
+
k2cMatPcb?: Matrix;
|
|
3124
|
+
netNumToName?: Map<number, string>;
|
|
3125
|
+
netNumToSourceNetId?: Map<number, string>;
|
|
3126
|
+
netNumToSourcePortIds?: Map<number, string[]>;
|
|
3127
|
+
footprintUuidToComponentId?: Map<string, string>;
|
|
3128
|
+
footprintUuidToSourceComponentId?: Map<string, string>;
|
|
3129
|
+
symbolUuidToComponentId?: Map<string, string>;
|
|
3130
|
+
warnings?: string[];
|
|
3131
|
+
stats?: {
|
|
3132
|
+
components?: number;
|
|
3133
|
+
pads?: number;
|
|
3134
|
+
vias?: number;
|
|
3135
|
+
traces?: number;
|
|
3136
|
+
labels?: number;
|
|
3137
|
+
copper_pours?: number;
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3140
|
+
/**
|
|
3141
|
+
* Base class for converter stages that process KiCad data into Circuit JSON.
|
|
3142
|
+
* Each stage performs a specific transformation step and can run iteratively.
|
|
3143
|
+
*/
|
|
3144
|
+
declare abstract class ConverterStage {
|
|
3145
|
+
protected ctx: ConverterContext;
|
|
3146
|
+
protected MAX_ITERATIONS: number;
|
|
3147
|
+
protected iterationCount: number;
|
|
3148
|
+
finished: boolean;
|
|
3149
|
+
constructor(ctx: ConverterContext);
|
|
3150
|
+
/**
|
|
3151
|
+
* Perform one step of the conversion process.
|
|
3152
|
+
* Returns true if the stage has more work to do, false if finished.
|
|
3153
|
+
*/
|
|
3154
|
+
abstract step(): boolean;
|
|
3155
|
+
/**
|
|
3156
|
+
* Run this stage until completion or max iterations reached.
|
|
3157
|
+
*/
|
|
3158
|
+
runUntilFinished(): void;
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
declare class KicadFootprintToCircuitJsonConverter {
|
|
3162
|
+
fsMap: Record<string, string>;
|
|
3163
|
+
ctx?: ConverterContext;
|
|
3164
|
+
addFile(filePath: string, content: string): void;
|
|
3165
|
+
private _findFileWithExtension;
|
|
3166
|
+
private initializeContext;
|
|
3167
|
+
private ensureFootprintUuid;
|
|
3168
|
+
runUntilFinished(): void;
|
|
3169
|
+
getOutput(): AnyCircuitElement[];
|
|
3170
|
+
getOutputString(): string;
|
|
3171
|
+
getWarnings(): string[];
|
|
3172
|
+
getStats(): {
|
|
3173
|
+
components?: number;
|
|
3174
|
+
pads?: number;
|
|
3175
|
+
vias?: number;
|
|
3176
|
+
traces?: number;
|
|
3177
|
+
labels?: number;
|
|
3178
|
+
copper_pours?: number;
|
|
3179
|
+
};
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
declare class KicadSymbolToCircuitJsonConverter {
|
|
3183
|
+
fsMap: Record<string, string>;
|
|
3184
|
+
ctx?: ConverterContext;
|
|
3185
|
+
currentStageIndex: number;
|
|
3186
|
+
pipeline?: ConverterStage[];
|
|
3187
|
+
get currentStage(): ConverterStage | undefined;
|
|
3188
|
+
addFile(filePath: string, content: string): void;
|
|
3189
|
+
private _findFileWithExtension;
|
|
3190
|
+
initializePipeline(): void;
|
|
3191
|
+
step(): boolean;
|
|
3192
|
+
runUntilFinished(): void;
|
|
3193
|
+
getOutput(): AnyCircuitElement[];
|
|
3194
|
+
getOutputString(): string;
|
|
3195
|
+
getWarnings(): string[];
|
|
3196
|
+
getStats(): {
|
|
3197
|
+
components?: number;
|
|
3198
|
+
pads?: number;
|
|
3199
|
+
vias?: number;
|
|
3200
|
+
traces?: number;
|
|
3201
|
+
labels?: number;
|
|
3202
|
+
copper_pours?: number;
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
declare class KicadToCircuitJsonConverter {
|
|
3207
|
+
fsMap: Record<string, string>;
|
|
3208
|
+
ctx?: ConverterContext;
|
|
3209
|
+
currentStageIndex: number;
|
|
3210
|
+
pipeline?: ConverterStage[];
|
|
3211
|
+
get currentStage(): ConverterStage | undefined;
|
|
3212
|
+
addFile(filePath: string, content: string): void;
|
|
3213
|
+
_findFileWithExtension(extension: string): string | null;
|
|
3214
|
+
initializePipeline(): void;
|
|
3215
|
+
step(): boolean;
|
|
3216
|
+
runUntilFinished(): void;
|
|
3217
|
+
getOutput(): AnyCircuitElement[];
|
|
3218
|
+
getOutputString(): string;
|
|
3219
|
+
getWarnings(): string[];
|
|
3220
|
+
getStats(): {
|
|
3221
|
+
components?: number;
|
|
3222
|
+
pads?: number;
|
|
3223
|
+
vias?: number;
|
|
3224
|
+
traces?: number;
|
|
3225
|
+
labels?: number;
|
|
3226
|
+
copper_pours?: number;
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
/**
|
|
3231
|
+
* InitializeSchematicContextStage sets up the coordinate transformation
|
|
3232
|
+
* from KiCad schematic space to Circuit JSON space.
|
|
3233
|
+
*
|
|
3234
|
+
* KiCad→CJ schematic transform (inverse of CJ→KiCad):
|
|
3235
|
+
* - CJ→KiCad used: translate(KICAD_CENTER) ∘ scale(15, -15) ∘ translate(-center)
|
|
3236
|
+
* - KiCad→CJ uses: translate(center) ∘ scale(1/15, -1/15) ∘ translate(-KICAD_CENTER)
|
|
3237
|
+
*/
|
|
3238
|
+
declare class InitializeSchematicContextStage extends ConverterStage {
|
|
3239
|
+
step(): boolean;
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
/**
|
|
3243
|
+
* CollectLibrarySymbolsStage extracts KiCad schematic symbols and creates:
|
|
3244
|
+
* - source_component entries (with ftype inferred from library id)
|
|
3245
|
+
* - schematic_component entries with positions
|
|
3246
|
+
* - schematic_port entries for each pin
|
|
3247
|
+
*/
|
|
3248
|
+
declare class CollectLibrarySymbolsStage extends ConverterStage {
|
|
3249
|
+
private processedSymbols;
|
|
3250
|
+
step(): boolean;
|
|
3251
|
+
private processSymbol;
|
|
3252
|
+
private getProperty;
|
|
3253
|
+
private inferFtype;
|
|
3254
|
+
private estimateSize;
|
|
3255
|
+
private createPorts;
|
|
3256
|
+
private inferPinDirection;
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
/**
|
|
3260
|
+
* CollectSchematicTracesStage converts KiCad schematic wires and junctions
|
|
3261
|
+
* into Circuit JSON schematic_trace elements.
|
|
3262
|
+
*/
|
|
3263
|
+
declare class CollectSchematicTracesStage extends ConverterStage {
|
|
3264
|
+
step(): boolean;
|
|
3265
|
+
private processWire;
|
|
3266
|
+
private processJunction;
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
/**
|
|
3270
|
+
* InitializePcbContextStage sets up the coordinate transformation
|
|
3271
|
+
* from KiCad PCB space to Circuit JSON space.
|
|
3272
|
+
*
|
|
3273
|
+
* KiCad→CJ PCB transform (inverse of CJ→KiCad):
|
|
3274
|
+
* - CJ→KiCad used: translate(100, 100) ∘ scale(1, -1)
|
|
3275
|
+
* - KiCad→CJ uses: scale(1, -1) ∘ translate(-100, -100)
|
|
3276
|
+
*/
|
|
3277
|
+
declare class InitializePcbContextStage extends ConverterStage {
|
|
3278
|
+
step(): boolean;
|
|
3279
|
+
private calculateBoardCenter;
|
|
3280
|
+
private getGraphicRects;
|
|
3281
|
+
private getRectStartEnd;
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
/**
|
|
3285
|
+
* CollectNetsStage builds a mapping from KiCad net numbers to meaningful net names.
|
|
3286
|
+
* Prefers KiCad's actual net names, falls back to "Net-<n>" for unnamed nets.
|
|
3287
|
+
*/
|
|
3288
|
+
declare class CollectNetsStage extends ConverterStage {
|
|
3289
|
+
step(): boolean;
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
/**
|
|
3293
|
+
* CollectFootprintsStage converts KiCad footprints into Circuit JSON pcb_components,
|
|
3294
|
+
* along with their associated pads (SMT, plated holes, NPTH) and silkscreen text.
|
|
3295
|
+
*/
|
|
3296
|
+
declare class CollectFootprintsStage extends ConverterStage {
|
|
3297
|
+
private processedFootprints;
|
|
3298
|
+
step(): boolean;
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
/**
|
|
3302
|
+
* CollectTracesStage converts KiCad PCB segments (traces) into Circuit JSON pcb_trace elements.
|
|
3303
|
+
* Connected copper primitives are stitched into contiguous pcb_trace routes.
|
|
3304
|
+
*/
|
|
3305
|
+
declare class CollectTracesStage extends ConverterStage {
|
|
3306
|
+
private readonly PORT_MATCH_TOLERANCE;
|
|
3307
|
+
private readonly POINT_KEY_PRECISION;
|
|
3308
|
+
private readonly sourceTraceIdByNetTraceKey;
|
|
3309
|
+
step(): boolean;
|
|
3310
|
+
private getTracePrimitiveFromSegment;
|
|
3311
|
+
private getTracePrimitiveFromArc;
|
|
3312
|
+
private getTracePrimitiveFromVia;
|
|
3313
|
+
private createTracesFromPrimitives;
|
|
3314
|
+
private createTracesFromPrimitiveGroup;
|
|
3315
|
+
private createTraceGraph;
|
|
3316
|
+
private walkTracePath;
|
|
3317
|
+
private insertTracePath;
|
|
3318
|
+
private getPathRoutePoints;
|
|
3319
|
+
private isTerminalNode;
|
|
3320
|
+
private getPrimitiveGroupKey;
|
|
3321
|
+
private getPointKey;
|
|
3322
|
+
private getPointFromKey;
|
|
3323
|
+
private getTraceGraphNodeKey;
|
|
3324
|
+
private getTraceGraphNodeFromKey;
|
|
3325
|
+
private getOrientedTraceEdgeStartKey;
|
|
3326
|
+
private getOrientedTraceEdgeEndKey;
|
|
3327
|
+
private pointsMatch;
|
|
3328
|
+
private getPcbTraceNodeKey;
|
|
3329
|
+
private annotatePrimitivesWithConnectedSourcePorts;
|
|
3330
|
+
private getSegmentNet;
|
|
3331
|
+
private findPortAtPosition;
|
|
3332
|
+
private getConnectedSourcePortIds;
|
|
3333
|
+
private getSourcePortIdsForTrace;
|
|
3334
|
+
private getTraceConnectedSourcePortIds;
|
|
3335
|
+
private createSourceTraceForPath;
|
|
3336
|
+
private getNetTraceKey;
|
|
3337
|
+
}
|
|
3338
|
+
|
|
3339
|
+
/**
|
|
3340
|
+
* CollectViasStage converts KiCad vias into Circuit JSON pcb_via elements.
|
|
3341
|
+
*/
|
|
3342
|
+
declare class CollectViasStage extends ConverterStage {
|
|
3343
|
+
step(): boolean;
|
|
3344
|
+
private processVia;
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
/**
|
|
3348
|
+
* CollectZonesStage converts KiCad zones with filled copper into Circuit JSON pcb_copper_pour elements.
|
|
3349
|
+
* Zones define copper pours/planes that are typically used for ground and power nets.
|
|
3350
|
+
*/
|
|
3351
|
+
declare class CollectZonesStage extends ConverterStage {
|
|
3352
|
+
step(): boolean;
|
|
3353
|
+
private isZoneFilled;
|
|
3354
|
+
private createCopperPourFromZone;
|
|
3355
|
+
private getZonePolygonRecords;
|
|
3356
|
+
private createZonePolygonRecordsFromShape;
|
|
3357
|
+
private getPolygonLayers;
|
|
3358
|
+
private getZoneLayers;
|
|
3359
|
+
private getZoneLayerLabel;
|
|
3360
|
+
private extractPointsFromPts;
|
|
3361
|
+
}
|
|
3362
|
+
|
|
3363
|
+
/**
|
|
3364
|
+
* CollectGraphicsStage processes KiCad graphics elements:
|
|
3365
|
+
* - gr_line on Edge.Cuts → pcb_board.outline
|
|
3366
|
+
* - gr_text on silk/fab layers → matching silkscreen/fabrication output
|
|
3367
|
+
* - gr_line/gr_arc on silk/fab/courtyard layers → matching PCB output
|
|
3368
|
+
* - gr_rect on copper layers (filled) → pcb_smtpad
|
|
3369
|
+
* - gr_poly on copper layers (filled) → pcb_smtpad (polygon)
|
|
3370
|
+
*/
|
|
3371
|
+
declare class CollectGraphicsStage extends ConverterStage {
|
|
3372
|
+
step(): boolean;
|
|
3373
|
+
private createBoardOutline;
|
|
3374
|
+
private createBoardContours;
|
|
3375
|
+
private getFootprintEdgeCutPrimitives;
|
|
3376
|
+
private transformFootprintPrimitive;
|
|
3377
|
+
private transformFootprintPoint;
|
|
3378
|
+
private orderConnectedContours;
|
|
3379
|
+
private reverseBoardPrimitive;
|
|
3380
|
+
private getRectEdgeCutPrimitives;
|
|
3381
|
+
private getRectStartEnd;
|
|
3382
|
+
private getBoardContourPoints;
|
|
3383
|
+
private getPrimitivePoints;
|
|
3384
|
+
private createEdgeCutCutout;
|
|
3385
|
+
private createEdgeCutCircleHole;
|
|
3386
|
+
private calculatePolygonArea;
|
|
3387
|
+
private createGraphicPath;
|
|
3388
|
+
private createGraphicArc;
|
|
3389
|
+
private insertRouteGraphic;
|
|
3390
|
+
private processRectangle;
|
|
3391
|
+
private createGraphicText;
|
|
3392
|
+
private pointsEqual;
|
|
3393
|
+
private pointsEqualKicad;
|
|
3394
|
+
private calculateWidth;
|
|
3395
|
+
private calculateHeight;
|
|
3396
|
+
private processPolygon;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
/**
|
|
3400
|
+
* CollectSourceTracesStage extracts logical nets from KiCad PCB by analyzing net
|
|
3401
|
+
* assignments on pads and copper.
|
|
3402
|
+
*
|
|
3403
|
+
* This stage:
|
|
3404
|
+
* 1. Iterates through all footprints and their pads
|
|
3405
|
+
* 2. Builds a mapping of nets to connected pads
|
|
3406
|
+
* 3. Creates source_port elements for each pad
|
|
3407
|
+
* 4. Creates source_net elements for each net. Physical trace collection creates
|
|
3408
|
+
* smaller source_trace elements that point at these source nets.
|
|
3409
|
+
*/
|
|
3410
|
+
declare class CollectSourceTracesStage extends ConverterStage {
|
|
3411
|
+
private processedNets;
|
|
3412
|
+
step(): boolean;
|
|
3413
|
+
private collectNetsFromCopper;
|
|
3414
|
+
private getSegmentNet;
|
|
3415
|
+
private processFootprintPads;
|
|
3416
|
+
private getPadNet;
|
|
3417
|
+
private getOrCreateSourcePort;
|
|
3418
|
+
private getSourcePortName;
|
|
3419
|
+
private getSourcePortPinNumber;
|
|
3420
|
+
private createSourceNet;
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
/**
|
|
3424
|
+
* InitializeSymbolLibraryContextStage prepares shared state for .kicad_sym
|
|
3425
|
+
* conversion. Symbol libraries have no schematic placements, so this branch
|
|
3426
|
+
* emits source-level Circuit JSON only.
|
|
3427
|
+
*/
|
|
3428
|
+
declare class InitializeSymbolLibraryContextStage extends ConverterStage {
|
|
3429
|
+
step(): boolean;
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
/**
|
|
3433
|
+
* CollectSymbolLibrarySymbolsStage converts KiCad symbol-library definitions
|
|
3434
|
+
* into source-level Circuit JSON:
|
|
3435
|
+
* - source_component for each top-level library symbol
|
|
3436
|
+
* - source_port for each physical pin in the symbol definition
|
|
3437
|
+
* - schematic_component and schematic_port preview geometry for snapshots
|
|
3438
|
+
*/
|
|
3439
|
+
declare class CollectSymbolLibrarySymbolsStage extends ConverterStage {
|
|
3440
|
+
private processedSymbols;
|
|
3441
|
+
private previewIndex;
|
|
3442
|
+
step(): boolean;
|
|
3443
|
+
private processSymbol;
|
|
3444
|
+
private getKicadSymbolExportFileName;
|
|
3445
|
+
private getSymbolName;
|
|
3446
|
+
private getSymbolProperties;
|
|
3447
|
+
private collectPins;
|
|
3448
|
+
private collectPolylines;
|
|
3449
|
+
private collectRectangles;
|
|
3450
|
+
private collectCircles;
|
|
3451
|
+
private collectArcs;
|
|
3452
|
+
private collectTexts;
|
|
3453
|
+
private createSchematicPreview;
|
|
3454
|
+
private getPreviewCenter;
|
|
3455
|
+
private getPinBounds;
|
|
3456
|
+
private getPreviewScale;
|
|
3457
|
+
private createSchematicPrimitives;
|
|
3458
|
+
private createPropertyTextPrimitives;
|
|
3459
|
+
private shouldRenderProperty;
|
|
3460
|
+
private getTextAnchor;
|
|
3461
|
+
private createPolylinePrimitives;
|
|
3462
|
+
private toSchematicPoint;
|
|
3463
|
+
private toStrokeWidth;
|
|
3464
|
+
private isFilled;
|
|
3465
|
+
private getFillColor;
|
|
3466
|
+
private getFontSize;
|
|
3467
|
+
private getPolylinePoints;
|
|
3468
|
+
private getShapeChildren;
|
|
3469
|
+
private getShapeChild;
|
|
3470
|
+
private getShapePoint;
|
|
3471
|
+
private getShapeNumber;
|
|
3472
|
+
private getShapeStroke;
|
|
3473
|
+
private getShapeFillType;
|
|
3474
|
+
private getArcPoints;
|
|
3475
|
+
private getArcGeometry;
|
|
3476
|
+
private getAngleDegrees;
|
|
3477
|
+
private getManufacturerPartNumber;
|
|
3478
|
+
private createSourceComponentData;
|
|
3479
|
+
private inferFtype;
|
|
3480
|
+
private getPortName;
|
|
3481
|
+
private getSourcePortPinMetadata;
|
|
3482
|
+
private getSchematicPortPinMetadata;
|
|
3483
|
+
private pinAngleToSideOfComponent;
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
type KicadToCircuitJsonModule_CollectFootprintsStage = CollectFootprintsStage;
|
|
3487
|
+
declare const KicadToCircuitJsonModule_CollectFootprintsStage: typeof CollectFootprintsStage;
|
|
3488
|
+
type KicadToCircuitJsonModule_CollectGraphicsStage = CollectGraphicsStage;
|
|
3489
|
+
declare const KicadToCircuitJsonModule_CollectGraphicsStage: typeof CollectGraphicsStage;
|
|
3490
|
+
type KicadToCircuitJsonModule_CollectLibrarySymbolsStage = CollectLibrarySymbolsStage;
|
|
3491
|
+
declare const KicadToCircuitJsonModule_CollectLibrarySymbolsStage: typeof CollectLibrarySymbolsStage;
|
|
3492
|
+
type KicadToCircuitJsonModule_CollectNetsStage = CollectNetsStage;
|
|
3493
|
+
declare const KicadToCircuitJsonModule_CollectNetsStage: typeof CollectNetsStage;
|
|
3494
|
+
type KicadToCircuitJsonModule_CollectSchematicTracesStage = CollectSchematicTracesStage;
|
|
3495
|
+
declare const KicadToCircuitJsonModule_CollectSchematicTracesStage: typeof CollectSchematicTracesStage;
|
|
3496
|
+
type KicadToCircuitJsonModule_CollectSourceTracesStage = CollectSourceTracesStage;
|
|
3497
|
+
declare const KicadToCircuitJsonModule_CollectSourceTracesStage: typeof CollectSourceTracesStage;
|
|
3498
|
+
type KicadToCircuitJsonModule_CollectSymbolLibrarySymbolsStage = CollectSymbolLibrarySymbolsStage;
|
|
3499
|
+
declare const KicadToCircuitJsonModule_CollectSymbolLibrarySymbolsStage: typeof CollectSymbolLibrarySymbolsStage;
|
|
3500
|
+
type KicadToCircuitJsonModule_CollectTracesStage = CollectTracesStage;
|
|
3501
|
+
declare const KicadToCircuitJsonModule_CollectTracesStage: typeof CollectTracesStage;
|
|
3502
|
+
type KicadToCircuitJsonModule_CollectViasStage = CollectViasStage;
|
|
3503
|
+
declare const KicadToCircuitJsonModule_CollectViasStage: typeof CollectViasStage;
|
|
3504
|
+
type KicadToCircuitJsonModule_CollectZonesStage = CollectZonesStage;
|
|
3505
|
+
declare const KicadToCircuitJsonModule_CollectZonesStage: typeof CollectZonesStage;
|
|
3506
|
+
type KicadToCircuitJsonModule_ConverterContext = ConverterContext;
|
|
3507
|
+
type KicadToCircuitJsonModule_ConverterStage = ConverterStage;
|
|
3508
|
+
declare const KicadToCircuitJsonModule_ConverterStage: typeof ConverterStage;
|
|
3509
|
+
type KicadToCircuitJsonModule_InitializePcbContextStage = InitializePcbContextStage;
|
|
3510
|
+
declare const KicadToCircuitJsonModule_InitializePcbContextStage: typeof InitializePcbContextStage;
|
|
3511
|
+
type KicadToCircuitJsonModule_InitializeSchematicContextStage = InitializeSchematicContextStage;
|
|
3512
|
+
declare const KicadToCircuitJsonModule_InitializeSchematicContextStage: typeof InitializeSchematicContextStage;
|
|
3513
|
+
type KicadToCircuitJsonModule_InitializeSymbolLibraryContextStage = InitializeSymbolLibraryContextStage;
|
|
3514
|
+
declare const KicadToCircuitJsonModule_InitializeSymbolLibraryContextStage: typeof InitializeSymbolLibraryContextStage;
|
|
3515
|
+
type KicadToCircuitJsonModule_KicadFootprintToCircuitJsonConverter = KicadFootprintToCircuitJsonConverter;
|
|
3516
|
+
declare const KicadToCircuitJsonModule_KicadFootprintToCircuitJsonConverter: typeof KicadFootprintToCircuitJsonConverter;
|
|
3517
|
+
type KicadToCircuitJsonModule_KicadSymbolToCircuitJsonConverter = KicadSymbolToCircuitJsonConverter;
|
|
3518
|
+
declare const KicadToCircuitJsonModule_KicadSymbolToCircuitJsonConverter: typeof KicadSymbolToCircuitJsonConverter;
|
|
3519
|
+
type KicadToCircuitJsonModule_KicadToCircuitJsonConverter = KicadToCircuitJsonConverter;
|
|
3520
|
+
declare const KicadToCircuitJsonModule_KicadToCircuitJsonConverter: typeof KicadToCircuitJsonConverter;
|
|
3521
|
+
declare namespace KicadToCircuitJsonModule {
|
|
3522
|
+
export { KicadToCircuitJsonModule_CollectFootprintsStage as CollectFootprintsStage, KicadToCircuitJsonModule_CollectGraphicsStage as CollectGraphicsStage, KicadToCircuitJsonModule_CollectLibrarySymbolsStage as CollectLibrarySymbolsStage, KicadToCircuitJsonModule_CollectNetsStage as CollectNetsStage, KicadToCircuitJsonModule_CollectSchematicTracesStage as CollectSchematicTracesStage, KicadToCircuitJsonModule_CollectSourceTracesStage as CollectSourceTracesStage, KicadToCircuitJsonModule_CollectSymbolLibrarySymbolsStage as CollectSymbolLibrarySymbolsStage, KicadToCircuitJsonModule_CollectTracesStage as CollectTracesStage, KicadToCircuitJsonModule_CollectViasStage as CollectViasStage, KicadToCircuitJsonModule_CollectZonesStage as CollectZonesStage, type KicadToCircuitJsonModule_ConverterContext as ConverterContext, KicadToCircuitJsonModule_ConverterStage as ConverterStage, KicadToCircuitJsonModule_InitializePcbContextStage as InitializePcbContextStage, KicadToCircuitJsonModule_InitializeSchematicContextStage as InitializeSchematicContextStage, KicadToCircuitJsonModule_InitializeSymbolLibraryContextStage as InitializeSymbolLibraryContextStage, KicadToCircuitJsonModule_KicadFootprintToCircuitJsonConverter as KicadFootprintToCircuitJsonConverter, KicadToCircuitJsonModule_KicadSymbolToCircuitJsonConverter as KicadSymbolToCircuitJsonConverter, KicadToCircuitJsonModule_KicadToCircuitJsonConverter as KicadToCircuitJsonConverter };
|
|
3523
|
+
}
|
|
3524
|
+
|
|
3525
|
+
declare const supportedModules: readonly ["circuit-json-to-3d-png", "circuit-json-to-bom-csv", "circuit-json-to-bpc", "circuit-json-to-connectivity-map", "circuit-json-to-gerber", "circuit-json-to-gltf", "circuit-json-to-kicad", "circuit-json-to-lbrn", "circuit-json-to-pnp-csv", "circuit-json-to-readable-netlist", "circuit-json-to-simple-3d", "circuit-json-to-spice", "circuit-json-to-step", "circuit-json-to-tscircuit", "circuit-to-canvas", "circuit-to-svg", "kicad-to-circuit-json"];
|
|
3058
3526
|
type SupportedModuleName = (typeof supportedModules)[number];
|
|
3059
3527
|
type SupportedModuleSpecifier = SupportedModuleName | `${SupportedModuleName}@${string}`;
|
|
3060
3528
|
interface SupportedModuleMap {
|
|
3529
|
+
"circuit-json-to-3d-png": typeof CircuitJsonTo3dPngModule;
|
|
3061
3530
|
"circuit-json-to-bom-csv": typeof CircuitJsonToBomCsvModule;
|
|
3062
3531
|
"circuit-json-to-bpc": typeof CircuitJsonToBpcModule;
|
|
3063
3532
|
"circuit-json-to-connectivity-map": typeof CircuitJsonToConnectivityMapModule;
|
|
@@ -3073,6 +3542,7 @@ interface SupportedModuleMap {
|
|
|
3073
3542
|
"circuit-json-to-tscircuit": typeof CircuitJsonToTscircuitModule;
|
|
3074
3543
|
"circuit-to-canvas": typeof CircuitToCanvasModule;
|
|
3075
3544
|
"circuit-to-svg": typeof CircuitToSvgModule;
|
|
3545
|
+
"kicad-to-circuit-json": typeof KicadToCircuitJsonModule;
|
|
3076
3546
|
}
|
|
3077
3547
|
type StripVersion<TSpecifier extends string> = TSpecifier extends `${infer TBase}@${string}` ? TBase extends SupportedModuleName ? TBase : never : TSpecifier extends SupportedModuleName ? TSpecifier : never;
|
|
3078
3548
|
declare const getModuleName: (specifier: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ function registerDynamicModule(name, mod) {
|
|
|
14
14
|
|
|
15
15
|
// lib/supported-modules.ts
|
|
16
16
|
var supportedModules = [
|
|
17
|
+
"circuit-json-to-3d-png",
|
|
17
18
|
"circuit-json-to-bom-csv",
|
|
18
19
|
"circuit-json-to-bpc",
|
|
19
20
|
"circuit-json-to-connectivity-map",
|
|
@@ -28,7 +29,8 @@ var supportedModules = [
|
|
|
28
29
|
"circuit-json-to-step",
|
|
29
30
|
"circuit-json-to-tscircuit",
|
|
30
31
|
"circuit-to-canvas",
|
|
31
|
-
"circuit-to-svg"
|
|
32
|
+
"circuit-to-svg",
|
|
33
|
+
"kicad-to-circuit-json"
|
|
32
34
|
];
|
|
33
35
|
var getModuleName = (specifier) => {
|
|
34
36
|
const versionSeparatorIndex = specifier.indexOf("@");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/dynamic-module-registry.ts","../lib/supported-modules.ts","../lib/index.ts"],"names":[],"mappings":";AAYO,IAAM,2BAA2B,MAA6B;AACnE,EAAA,IAAI,WAAW,uBAAA,EAAyB;AACtC,IAAA,OAAO,UAAA,CAAW,uBAAA;AAAA,EACpB;AAEA,EAAA,MAAM,WAAkC,EAAC;AACzC,EAAA,UAAA,CAAW,uBAAA,GAA0B,QAAA;AACrC,EAAA,OAAO,QAAA;AACT;AAUO,SAAS,qBAAA,CACd,MACA,GAAA,EACS;AACT,EAAA,wBAAA,EAAyB,CAAE,IAAI,CAAA,GAAI,GAAA;AACnC,EAAA,OAAO,GAAA;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../lib/dynamic-module-registry.ts","../lib/supported-modules.ts","../lib/index.ts"],"names":[],"mappings":";AAYO,IAAM,2BAA2B,MAA6B;AACnE,EAAA,IAAI,WAAW,uBAAA,EAAyB;AACtC,IAAA,OAAO,UAAA,CAAW,uBAAA;AAAA,EACpB;AAEA,EAAA,MAAM,WAAkC,EAAC;AACzC,EAAA,UAAA,CAAW,uBAAA,GAA0B,QAAA;AACrC,EAAA,OAAO,QAAA;AACT;AAUO,SAAS,qBAAA,CACd,MACA,GAAA,EACS;AACT,EAAA,wBAAA,EAAyB,CAAE,IAAI,CAAA,GAAI,GAAA;AACnC,EAAA,OAAO,GAAA;AACT;;;AClBO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,kCAAA;AAAA,EACA,wBAAA;AAAA,EACA,sBAAA;AAAA,EACA,uBAAA;AAAA,EACA,sBAAA;AAAA,EACA,yBAAA;AAAA,EACA,kCAAA;AAAA,EACA,2BAAA;AAAA,EACA,uBAAA;AAAA,EACA,sBAAA;AAAA,EACA,2BAAA;AAAA,EACA,mBAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAoCO,IAAM,aAAA,GAAgB,CAAC,SAAA,KAA8B;AAC1D,EAAA,MAAM,qBAAA,GAAwB,SAAA,CAAU,OAAA,CAAQ,GAAG,CAAA;AACnD,EAAA,OAAO,0BAA0B,EAAA,GAC7B,SAAA,GACA,SAAA,CAAU,KAAA,CAAM,GAAG,qBAAqB,CAAA;AAC9C;;;ACpDA,IAAM,kBAAA,GAAqB,IAAI,GAAA,CAAY,gBAAgB,CAAA;AAEpD,IAAM,YAAA,GAAe,CAAC,SAAA,KAA8B;AACzD,EAAA,qBAAA,CAAsB,SAAS,CAAA;AAE/B,EAAA,OAAO,kBAAkB,SAAS,CAAA;AACpC;AAEO,IAAM,aAAA,GAAgB,CAAC,SAAA,KAAgC;AAC5D,EAAA,qBAAA,CAAsB,SAAS,CAAA;AAE/B,EAAA,OAAO,CAAC,iBAAA,CAAkB,SAAS,CAAA,EAAG,CAAA,gBAAA,EAAmB,SAAS,CAAA,CAAE,CAAA;AACtE;AAEA,SAAS,kBAAkB,SAAA,EAA2B;AACpD,EAAA,MAAM,UAAA,GAAa,cAAc,SAAS,CAAA;AAC1C,EAAA,MAAM,OAAA,GACJ,SAAA,CAAU,MAAA,KAAW,UAAA,CAAW,MAAA,GAC5B,WACA,SAAA,CAAU,KAAA,CAAM,UAAA,CAAW,MAAA,GAAS,CAAC,CAAA;AAE3C,EAAA,OAAO,CAAA,4BAAA,EAA+B,UAAU,CAAA,CAAA,EAAI,OAAO,CAAA,KAAA,CAAA;AAC7D;AAEA,SAAS,sBAAsB,SAAA,EAAmB;AAChD,EAAA,MAAM,UAAA,GAAa,cAAc,SAAS,CAAA;AAE1C,EAAA,IAAI,CAAC,kBAAA,CAAmB,GAAA,CAAI,UAAU,CAAA,EAAG;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,oBAAA,EAAuB,SAAS,CAAA,CAAE,CAAA;AAAA,EACpD;AACF;AAMA,eAAe,SAAS,SAAA,EAAqC;AAC3D,EAAA,IAAI,SAAA;AAEJ,EAAA,KAAA,MAAW,SAAA,IAAa,aAAA,CAAc,SAAS,CAAA,EAAG;AAChD,IAAA,IAAI;AACF,MAAA,MAAM,MAAM,MAAM;AAAA;AAAA,QAA0B;AAAA,OAAA;AAC5C,MAAA,OAAO,qBAAA,CAAsB,aAAA,CAAc,SAAS,CAAA,EAAG,GAAG,CAAA;AAAA,IAC5D,SAAS,KAAA,EAAO;AACd,MAAA,SAAA,GAAY,KAAA;AAAA,IACd;AAAA,EACF;AAEA,EAAA,MAAM,SAAA;AACR;AAEA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["import type {\n SupportedModuleMap,\n SupportedModuleName,\n} from \"./supported-modules\"\n\nexport type DynamicModuleRegistry = Partial<SupportedModuleMap> &\n Record<string, unknown>\n\ndeclare global {\n var tscircuitDynamicModules: DynamicModuleRegistry | undefined\n}\n\nexport const getDynamicModuleRegistry = (): DynamicModuleRegistry => {\n if (globalThis.tscircuitDynamicModules) {\n return globalThis.tscircuitDynamicModules\n }\n\n const registry: DynamicModuleRegistry = {}\n globalThis.tscircuitDynamicModules = registry\n return registry\n}\n\nexport function registerDynamicModule<TSpecifier extends SupportedModuleName>(\n name: TSpecifier,\n mod: SupportedModuleMap[TSpecifier],\n): SupportedModuleMap[TSpecifier]\nexport function registerDynamicModule<TModule>(\n name: string,\n mod: TModule,\n): TModule\nexport function registerDynamicModule<TModule>(\n name: string,\n mod: TModule,\n): TModule {\n getDynamicModuleRegistry()[name] = mod\n return mod\n}\n","import type * as CircuitJsonTo3dPngModule from \"./type-bundles/circuit-json-to-3d-png\"\nimport type * as CircuitJsonToBomCsvModule from \"./type-bundles/circuit-json-to-bom-csv\"\nimport type * as CircuitJsonToBpcModule from \"./type-bundles/circuit-json-to-bpc\"\nimport type * as CircuitJsonToConnectivityMapModule from \"./type-bundles/circuit-json-to-connectivity-map\"\nimport type * as CircuitJsonToGerberModule from \"./type-bundles/circuit-json-to-gerber\"\nimport type * as CircuitJsonToGltfModule from \"./type-bundles/circuit-json-to-gltf\"\nimport type * as CircuitJsonToKicadModule from \"./type-bundles/circuit-json-to-kicad\"\nimport type * as CircuitJsonToLbrnModule from \"./type-bundles/circuit-json-to-lbrn\"\nimport type * as CircuitJsonToPnpCsvModule from \"./type-bundles/circuit-json-to-pnp-csv\"\nimport type * as CircuitJsonToReadableNetlistModule from \"./type-bundles/circuit-json-to-readable-netlist\"\nimport type * as CircuitJsonToSimple3dModule from \"./type-bundles/circuit-json-to-simple-3d\"\nimport type * as CircuitJsonToSpiceModule from \"./type-bundles/circuit-json-to-spice\"\nimport type * as CircuitJsonToStepModule from \"./type-bundles/circuit-json-to-step\"\nimport type * as CircuitJsonToTscircuitModule from \"./type-bundles/circuit-json-to-tscircuit\"\nimport type * as CircuitToCanvasModule from \"./type-bundles/circuit-to-canvas\"\nimport type * as CircuitToSvgModule from \"./type-bundles/circuit-to-svg\"\nimport type * as KicadToCircuitJsonModule from \"./type-bundles/kicad-to-circuit-json\"\n\nexport const supportedModules = [\n \"circuit-json-to-3d-png\",\n \"circuit-json-to-bom-csv\",\n \"circuit-json-to-bpc\",\n \"circuit-json-to-connectivity-map\",\n \"circuit-json-to-gerber\",\n \"circuit-json-to-gltf\",\n \"circuit-json-to-kicad\",\n \"circuit-json-to-lbrn\",\n \"circuit-json-to-pnp-csv\",\n \"circuit-json-to-readable-netlist\",\n \"circuit-json-to-simple-3d\",\n \"circuit-json-to-spice\",\n \"circuit-json-to-step\",\n \"circuit-json-to-tscircuit\",\n \"circuit-to-canvas\",\n \"circuit-to-svg\",\n \"kicad-to-circuit-json\",\n] as const\n\nexport type SupportedModuleName = (typeof supportedModules)[number]\nexport type SupportedModuleSpecifier =\n | SupportedModuleName\n | `${SupportedModuleName}@${string}`\n\nexport interface SupportedModuleMap {\n \"circuit-json-to-3d-png\": typeof CircuitJsonTo3dPngModule\n \"circuit-json-to-bom-csv\": typeof CircuitJsonToBomCsvModule\n \"circuit-json-to-bpc\": typeof CircuitJsonToBpcModule\n \"circuit-json-to-connectivity-map\": typeof CircuitJsonToConnectivityMapModule\n \"circuit-json-to-gerber\": typeof CircuitJsonToGerberModule\n \"circuit-json-to-gltf\": typeof CircuitJsonToGltfModule\n \"circuit-json-to-kicad\": typeof CircuitJsonToKicadModule\n \"circuit-json-to-lbrn\": typeof CircuitJsonToLbrnModule\n \"circuit-json-to-pnp-csv\": typeof CircuitJsonToPnpCsvModule\n \"circuit-json-to-readable-netlist\": typeof CircuitJsonToReadableNetlistModule\n \"circuit-json-to-simple-3d\": typeof CircuitJsonToSimple3dModule\n \"circuit-json-to-spice\": typeof CircuitJsonToSpiceModule\n \"circuit-json-to-step\": typeof CircuitJsonToStepModule\n \"circuit-json-to-tscircuit\": typeof CircuitJsonToTscircuitModule\n \"circuit-to-canvas\": typeof CircuitToCanvasModule\n \"circuit-to-svg\": typeof CircuitToSvgModule\n \"kicad-to-circuit-json\": typeof KicadToCircuitJsonModule\n}\n\nexport type StripVersion<TSpecifier extends string> =\n TSpecifier extends `${infer TBase}@${string}`\n ? TBase extends SupportedModuleName\n ? TBase\n : never\n : TSpecifier extends SupportedModuleName\n ? TSpecifier\n : never\n\nexport const getModuleName = (specifier: string): string => {\n const versionSeparatorIndex = specifier.indexOf(\"@\")\n return versionSeparatorIndex === -1\n ? specifier\n : specifier.slice(0, versionSeparatorIndex)\n}\n","import { registerDynamicModule } from \"./dynamic-module-registry\"\nimport {\n getModuleName,\n supportedModules,\n type StripVersion,\n type SupportedModuleMap,\n type SupportedModuleSpecifier,\n} from \"./supported-modules\"\n\nexport {\n getDynamicModuleRegistry,\n registerDynamicModule,\n} from \"./dynamic-module-registry\"\nexport type { DynamicModuleRegistry } from \"./dynamic-module-registry\"\nexport {\n getModuleName,\n supportedModules,\n} from \"./supported-modules\"\nexport type {\n StripVersion,\n SupportedModuleMap,\n SupportedModuleName,\n SupportedModuleSpecifier,\n} from \"./supported-modules\"\n\nconst supportedModuleSet = new Set<string>(supportedModules)\n\nexport const getImportUrl = (specifier: string): string => {\n assertSupportedModule(specifier)\n\n return getJscdnImportUrl(specifier)\n}\n\nexport const getImportUrls = (specifier: string): string[] => {\n assertSupportedModule(specifier)\n\n return [getJscdnImportUrl(specifier), `https://esm.run/${specifier}`]\n}\n\nfunction getJscdnImportUrl(specifier: string): string {\n const moduleName = getModuleName(specifier)\n const version =\n specifier.length === moduleName.length\n ? \"latest\"\n : specifier.slice(moduleName.length + 1)\n\n return `https://jscdn.tscircuit.com/${moduleName}/${version}/+esm`\n}\n\nfunction assertSupportedModule(specifier: string) {\n const moduleName = getModuleName(specifier)\n\n if (!supportedModuleSet.has(moduleName)) {\n throw new Error(`Unsupported module: ${specifier}`)\n }\n}\n\nasync function importer<TSpecifier extends SupportedModuleSpecifier>(\n specifier: TSpecifier,\n): Promise<SupportedModuleMap[StripVersion<TSpecifier>]>\nasync function importer(specifier: string): Promise<unknown>\nasync function importer(specifier: string): Promise<unknown> {\n let lastError: unknown\n\n for (const importUrl of getImportUrls(specifier)) {\n try {\n const mod = await import(/* @vite-ignore */ importUrl)\n return registerDynamicModule(getModuleName(specifier), mod)\n } catch (error) {\n lastError = error\n }\n }\n\n throw lastError\n}\n\nexport default importer\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/internal-dynamic-import",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Type-safe dynamic imports for selected tscircuit packages via jscdn and fallback to jsDelivr",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@biomejs/biome": "^2.0.5",
|
|
30
30
|
"@types/bun": "latest",
|
|
31
|
+
"circuit-json-to-3d-png": "0.0.7",
|
|
31
32
|
"circuit-json-to-bom-csv": "0.0.8",
|
|
32
33
|
"circuit-json-to-bpc": "0.0.13",
|
|
33
34
|
"circuit-json-to-connectivity-map": "0.0.23",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"circuit-json-to-tscircuit": "0.0.14",
|
|
44
45
|
"circuit-to-canvas": "0.0.94",
|
|
45
46
|
"circuit-to-svg": "0.0.339",
|
|
47
|
+
"kicad-to-circuit-json": "0.0.98",
|
|
46
48
|
"tsup": "8.5.1",
|
|
47
49
|
"typescript": "5.9.3"
|
|
48
50
|
}
|