@tscircuit/internal-dynamic-import 0.0.15 → 0.0.17

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 (30) hide show
  1. package/README.md +112 -14
  2. package/dist/index.d.ts +624 -3
  3. package/dist/index.js +72 -28
  4. package/dist/index.js.map +1 -1
  5. package/lib/create-importer.ts +27 -0
  6. package/lib/dynamic-import-resolver.ts +58 -0
  7. package/lib/dynamic-module-registry.ts +37 -0
  8. package/lib/import-urls.ts +27 -0
  9. package/lib/index.ts +46 -0
  10. package/lib/supported-modules.ts +88 -0
  11. package/lib/type-bundles/@tscircuit/circuit-json-schematic-placement-analysis.d.ts +593 -0
  12. package/lib/type-bundles/circuit-json-to-3d-png.d.ts +48 -0
  13. package/lib/type-bundles/circuit-json-to-bom-csv.d.ts +36 -0
  14. package/lib/type-bundles/circuit-json-to-bpc.d.ts +15 -0
  15. package/lib/type-bundles/circuit-json-to-connectivity-map.d.ts +44 -0
  16. package/lib/type-bundles/circuit-json-to-fdm-component-box.d.ts +160 -0
  17. package/lib/type-bundles/circuit-json-to-gerber.d.ts +672 -0
  18. package/lib/type-bundles/circuit-json-to-gltf.d.ts +273 -0
  19. package/lib/type-bundles/circuit-json-to-kicad.d.ts +392 -0
  20. package/lib/type-bundles/circuit-json-to-lbrn.d.ts +54 -0
  21. package/lib/type-bundles/circuit-json-to-pnp-csv.d.ts +15 -0
  22. package/lib/type-bundles/circuit-json-to-readable-netlist.d.ts +5 -0
  23. package/lib/type-bundles/circuit-json-to-simple-3d.d.ts +41 -0
  24. package/lib/type-bundles/circuit-json-to-spice.d.ts +242 -0
  25. package/lib/type-bundles/circuit-json-to-step.d.ts +28 -0
  26. package/lib/type-bundles/circuit-json-to-tscircuit.d.ts +14 -0
  27. package/lib/type-bundles/circuit-to-canvas.d.ts +646 -0
  28. package/lib/type-bundles/circuit-to-svg.d.ts +399 -0
  29. package/lib/type-bundles/kicad-to-circuit-json.d.ts +375 -0
  30. package/package.json +14 -3
@@ -0,0 +1,273 @@
1
+ import { CircuitJson } from 'circuit-json';
2
+
3
+ interface AuthHeaders extends Record<string, string> {
4
+ Authorization: string;
5
+ }
6
+ interface ConversionOptions {
7
+ format?: "gltf" | "glb";
8
+ boardTextureResolution?: number;
9
+ showPcbNotes?: boolean;
10
+ boardDrillQuality?: "high" | "fast";
11
+ drawFauxBoard?: boolean;
12
+ includeModels?: boolean;
13
+ modelCache?: Map<string, STLMesh | OBJMesh>;
14
+ backgroundColor?: string;
15
+ showBoundingBoxes?: boolean;
16
+ coordinateTransform?: CoordinateTransformConfig;
17
+ projectBaseUrl?: string;
18
+ authHeaders?: AuthHeaders;
19
+ }
20
+ interface CoordinateTransformConfig {
21
+ flipX?: number;
22
+ flipY?: number;
23
+ flipZ?: number;
24
+ axisMapping?: {
25
+ x?: "x" | "y" | "z" | "-x" | "-y" | "-z";
26
+ y?: "x" | "y" | "z" | "-x" | "-y" | "-z";
27
+ z?: "x" | "y" | "z" | "-x" | "-y" | "-z";
28
+ };
29
+ rotation?: {
30
+ x?: number;
31
+ y?: number;
32
+ z?: number;
33
+ };
34
+ }
35
+ interface Point3 {
36
+ x: number;
37
+ y: number;
38
+ z: number;
39
+ }
40
+ interface Size3 {
41
+ x: number;
42
+ y: number;
43
+ z: number;
44
+ }
45
+ interface Triangle {
46
+ vertices: [Point3, Point3, Point3];
47
+ normal: Point3;
48
+ color?: Color;
49
+ materialIndex?: number;
50
+ }
51
+ interface BoundingBox {
52
+ min: Point3;
53
+ max: Point3;
54
+ }
55
+ interface STLMesh {
56
+ triangles: Triangle[];
57
+ boundingBox: BoundingBox;
58
+ }
59
+ interface OBJMesh extends STLMesh {
60
+ materials?: Map<string, OBJMaterial>;
61
+ materialIndexMap?: Map<string, number>;
62
+ }
63
+ interface OBJMaterial {
64
+ name: string;
65
+ color?: Color;
66
+ ambient?: Color;
67
+ specular?: Color;
68
+ shininess?: number;
69
+ dissolve?: number;
70
+ }
71
+ type Color = string | [number, number, number, number];
72
+ interface Box3D {
73
+ center: Point3;
74
+ size: Size3;
75
+ rotation?: Point3;
76
+ color?: Color;
77
+ texture?: {
78
+ top?: string;
79
+ bottom?: string;
80
+ front?: string;
81
+ back?: string;
82
+ left?: string;
83
+ right?: string;
84
+ };
85
+ mesh?: STLMesh | OBJMesh;
86
+ meshUrl?: string;
87
+ meshType?: "stl" | "obj" | "glb" | "step";
88
+ label?: string;
89
+ labelColor?: Color;
90
+ isTranslucent?: boolean;
91
+ }
92
+ interface Scene3D {
93
+ boxes: Box3D[];
94
+ camera?: Camera3D;
95
+ lights?: Light3D[];
96
+ }
97
+ interface Camera3D {
98
+ position: Point3;
99
+ target: Point3;
100
+ up?: Point3;
101
+ fov?: number;
102
+ near?: number;
103
+ far?: number;
104
+ }
105
+ interface Light3D {
106
+ type: "ambient" | "directional" | "point";
107
+ color?: Color;
108
+ intensity?: number;
109
+ position?: Point3;
110
+ direction?: Point3;
111
+ }
112
+ interface GLTFExportOptions {
113
+ binary?: boolean;
114
+ trs?: boolean;
115
+ onlyVisible?: boolean;
116
+ truncateDrawRange?: boolean;
117
+ embedImages?: boolean;
118
+ animations?: any[];
119
+ forceIndices?: boolean;
120
+ includeCustomExtensions?: boolean;
121
+ }
122
+ interface CircuitTo3DOptions {
123
+ pcbColor?: Color;
124
+ componentColor?: Color;
125
+ copperColor?: Color;
126
+ boardThickness?: number;
127
+ boardDrillQuality?: "high" | "fast";
128
+ drawFauxBoard?: boolean;
129
+ defaultComponentHeight?: number;
130
+ renderBoardTextures?: boolean;
131
+ textureResolution?: number;
132
+ showPcbNotes?: boolean;
133
+ coordinateTransform?: CoordinateTransformConfig;
134
+ showBoundingBoxes?: boolean;
135
+ projectBaseUrl?: string;
136
+ authHeaders?: AuthHeaders;
137
+ }
138
+ interface BoardRenderOptions {
139
+ layer: "top" | "bottom";
140
+ resolution?: number;
141
+ backgroundColor?: string;
142
+ copperColor?: string;
143
+ silkscreenColor?: string;
144
+ padColor?: string;
145
+ drillColor?: string;
146
+ showPcbNotes?: boolean;
147
+ }
148
+
149
+ declare function renderBoardLayer(circuitJson: CircuitJson, options: BoardRenderOptions): Promise<string>;
150
+ declare function renderBoardTextures(circuitJson: CircuitJson, { resolution, showPcbNotes }: {
151
+ resolution?: number | undefined;
152
+ showPcbNotes?: boolean | undefined;
153
+ }): Promise<{
154
+ top: string;
155
+ bottom: string;
156
+ }>;
157
+
158
+ declare function convertCircuitJsonTo3D(circuitJson: CircuitJson, options?: CircuitTo3DOptions): Promise<Scene3D>;
159
+
160
+ declare function convertSceneToGLTF(scene: Scene3D, options?: GLTFExportOptions): Promise<ArrayBuffer | object>;
161
+
162
+ declare function loadGLB({ url, transform, projectBaseUrl, authHeaders, }: {
163
+ url: string;
164
+ transform?: CoordinateTransformConfig;
165
+ projectBaseUrl?: string;
166
+ authHeaders?: AuthHeaders;
167
+ }): Promise<STLMesh | OBJMesh>;
168
+ declare function clearGLBCache(): void;
169
+
170
+ declare function loadOBJ({ url, transform, projectBaseUrl, authHeaders, }: {
171
+ url: string;
172
+ transform?: CoordinateTransformConfig;
173
+ projectBaseUrl?: string;
174
+ authHeaders?: AuthHeaders;
175
+ }): Promise<OBJMesh>;
176
+ declare function clearOBJCache(): void;
177
+
178
+ declare function loadSTL({ url, transform, projectBaseUrl, authHeaders, }: {
179
+ url: string;
180
+ transform?: CoordinateTransformConfig;
181
+ projectBaseUrl?: string;
182
+ authHeaders?: AuthHeaders;
183
+ }): Promise<STLMesh>;
184
+ declare function clearSTLCache(): void;
185
+
186
+ declare const CAMERA_PRESET_DIRECTIONS: {
187
+ readonly isometric: readonly [-0.7, 1.2, -0.8];
188
+ readonly top_down: readonly [0, 1, 0.001];
189
+ readonly bottom_up: readonly [0, -1, 0.001];
190
+ readonly left_side: readonly [-1, 0, 0];
191
+ readonly right_side: readonly [1, 0, 0];
192
+ readonly front: readonly [0, 0, 1];
193
+ readonly back: readonly [0, 0, -1];
194
+ };
195
+ type CameraPreset = keyof typeof CAMERA_PRESET_DIRECTIONS;
196
+ interface CameraFitOptions {
197
+ /**
198
+ * Named preset view. Useful for stable top/bottom/side snapshots.
199
+ *
200
+ * `top_down`/`bottom_up` use a tiny hidden tilt because the downstream
201
+ * renderer currently assumes a fixed up-vector and collapses on a perfectly
202
+ * vertical view.
203
+ */
204
+ preset?: CameraPreset;
205
+ /**
206
+ * Approximate an orthographic view using a very narrow perspective FOV.
207
+ *
208
+ * This is a compatibility hack for renderers that only expose perspective
209
+ * cameras. It is not a true orthographic projection.
210
+ */
211
+ ortho?: boolean;
212
+ /**
213
+ * Target-to-camera direction vector used for solved camera position.
214
+ */
215
+ direction?: readonly [number, number, number];
216
+ /**
217
+ * Vertical field of view in degrees.
218
+ */
219
+ fov?: number;
220
+ /**
221
+ * Aspect ratio (width / height) used for horizontal fit calculations.
222
+ */
223
+ aspectRatio?: number;
224
+ /**
225
+ * Focal length in millimeters. If provided with sensorHeight,
226
+ * it is used instead of fov.
227
+ */
228
+ focalLength?: number;
229
+ /**
230
+ * Sensor height in millimeters for focalLength->fov conversion.
231
+ */
232
+ sensorHeight?: number;
233
+ }
234
+ declare function getBestCameraPosition(circuitJson: CircuitJson, opts?: CameraFitOptions): {
235
+ camPos: readonly [number, number, number];
236
+ lookAt: readonly [number, number, number];
237
+ fov: number;
238
+ };
239
+
240
+ declare function applyCoordinateTransform(point: Point3, config: CoordinateTransformConfig): Point3;
241
+ declare function transformTriangles(triangles: Triangle[], config: CoordinateTransformConfig): Triangle[];
242
+ declare const COORDINATE_TRANSFORMS: {
243
+ readonly Z_UP_TO_Y_UP: CoordinateTransformConfig;
244
+ readonly Z_OUT_OF_TOP: CoordinateTransformConfig;
245
+ readonly STEP_INVERTED: CoordinateTransformConfig;
246
+ readonly USB_PORT_FIX: CoordinateTransformConfig;
247
+ readonly Z_UP_TO_Y_UP_USB_FIX: CoordinateTransformConfig;
248
+ readonly IDENTITY: CoordinateTransformConfig;
249
+ readonly TEST_ROTATE_X_90: CoordinateTransformConfig;
250
+ readonly TEST_ROTATE_X_270: CoordinateTransformConfig;
251
+ readonly TEST_ROTATE_Y_90: CoordinateTransformConfig;
252
+ readonly TEST_ROTATE_Y_270: CoordinateTransformConfig;
253
+ readonly TEST_ROTATE_Z_90: CoordinateTransformConfig;
254
+ readonly TEST_ROTATE_Z_270: CoordinateTransformConfig;
255
+ readonly TEST_FLIP_X: CoordinateTransformConfig;
256
+ readonly TEST_FLIP_Z: CoordinateTransformConfig;
257
+ readonly FOOTPRINTER_MODEL_TRANSFORM: CoordinateTransformConfig;
258
+ readonly OBJ_Z_UP_TO_Y_UP: CoordinateTransformConfig;
259
+ };
260
+
261
+ declare function convertCircuitJsonToGltf(circuitJson: CircuitJson, options?: ConversionOptions): Promise<ArrayBuffer | object>;
262
+
263
+ interface Point {
264
+ x: number;
265
+ y: number;
266
+ }
267
+ type LayerRef = string | number;
268
+ interface BRepShape {
269
+ polygons: Point[][];
270
+ is_negative?: boolean;
271
+ }
272
+
273
+ export { type BRepShape, type BoardRenderOptions, type BoundingBox, type Box3D, CAMERA_PRESET_DIRECTIONS, COORDINATE_TRANSFORMS, type Camera3D, type CameraFitOptions, type CameraPreset, type CircuitTo3DOptions, type Color, type ConversionOptions, type CoordinateTransformConfig, type GLTFExportOptions, type LayerRef, type Light3D, type OBJMaterial, type OBJMesh, type Point, type Point3, type STLMesh, type Scene3D, type Size3, type Triangle, applyCoordinateTransform, clearGLBCache, clearOBJCache, clearSTLCache, convertCircuitJsonTo3D, convertCircuitJsonToGltf, convertSceneToGLTF, getBestCameraPosition, loadGLB, loadOBJ, loadSTL, renderBoardLayer, renderBoardTextures, transformTriangles };
@@ -0,0 +1,392 @@
1
+ import { CircuitJson } from 'circuit-json';
2
+ import { CircuitJsonUtilObjects, cju } from '@tscircuit/circuit-json-util';
3
+ import { KicadSch, KicadPcb, SchematicSymbol } from 'kicadts';
4
+ import { Matrix } from 'transformation-matrix';
5
+
6
+ type PaperSize = "A0" | "A1" | "A2" | "A3" | "A4" | "A5";
7
+ interface PaperDimensions {
8
+ width: number;
9
+ height: number;
10
+ name: PaperSize;
11
+ }
12
+
13
+ type SchematicPortId = string;
14
+ type SchematicTraceId = string;
15
+ type PcbPortId = string;
16
+ interface PcbNetInfo {
17
+ id: number;
18
+ name: string;
19
+ }
20
+ interface SymbolEntry {
21
+ symbolName: string;
22
+ symbol: SchematicSymbol;
23
+ /**
24
+ * Whether this symbol is from a standard library footprint (has footprinter_string).
25
+ * If true, this is a builtin/standard symbol. If false, it's a custom/inline symbol.
26
+ */
27
+ isBuiltin?: boolean;
28
+ }
29
+ interface FootprintEntry {
30
+ footprintName: string;
31
+ kicadModString: string;
32
+ model3dSourcePaths: string[];
33
+ /**
34
+ * Whether this footprint is from a standard library footprint (has footprinter_string).
35
+ * If true, this is a builtin/standard footprint. If false, it's a custom/inline footprint.
36
+ */
37
+ isBuiltin?: boolean;
38
+ }
39
+ interface KicadLibraryOutput {
40
+ kicadSymString: string;
41
+ symbols: SymbolEntry[];
42
+ footprints: FootprintEntry[];
43
+ fpLibTableString: string;
44
+ symLibTableString: string;
45
+ model3dSourcePaths: string[];
46
+ }
47
+ interface ConverterContext {
48
+ db: CircuitJsonUtilObjects;
49
+ circuitJson: CircuitJson;
50
+ kicadSch?: KicadSch;
51
+ kicadPcb?: KicadPcb;
52
+ /** Scale factor used to convert circuit-json schematic units into KiCad mm */
53
+ kicadSchematicScaleFactor?: number;
54
+ /** Circuit JSON to KiCad schematic transformation matrix */
55
+ c2kMatSch?: Matrix;
56
+ /** Circuit JSON to KiCad PCB transformation matrix */
57
+ c2kMatPcb?: Matrix;
58
+ /** Selected paper size for schematic */
59
+ schematicPaperSize?: PaperDimensions;
60
+ pinPositions?: Map<SchematicPortId, {
61
+ x: number;
62
+ y: number;
63
+ }>;
64
+ wireConnections?: Map<SchematicTraceId, SchematicPortId[]>;
65
+ pcbPadPositions?: Map<PcbPortId, {
66
+ x: number;
67
+ y: number;
68
+ }>;
69
+ pcbNetMap?: Map<string, PcbNetInfo>;
70
+ numLayers?: number;
71
+ /** Project name used as the .3dshapes folder for user-provided 3D models */
72
+ projectName?: string;
73
+ /** CDN URLs of 3D models needed for this PCB (collected during footprint stage) */
74
+ pcbModel3dSourcePaths?: string[];
75
+ libraryName?: string;
76
+ fpLibraryName?: string;
77
+ kicadSchString?: string;
78
+ kicadPcbString?: string;
79
+ symbolEntries?: SymbolEntry[];
80
+ footprintEntries?: FootprintEntry[];
81
+ libraryOutput?: KicadLibraryOutput;
82
+ }
83
+ declare abstract class ConverterStage<Input, Output> {
84
+ MAX_ITERATIONS: number;
85
+ iteration: number;
86
+ finished: boolean;
87
+ input: Input;
88
+ ctx: ConverterContext;
89
+ constructor(input: Input, ctx: ConverterContext);
90
+ step(): void;
91
+ _step(): void;
92
+ runUntilFinished(): void;
93
+ getOutput(): Output;
94
+ }
95
+
96
+ declare class CircuitJsonToKicadSchConverter {
97
+ ctx: ConverterContext;
98
+ pipeline: ConverterStage<CircuitJson, KicadSch>[];
99
+ currentStageIndex: number;
100
+ finished: boolean;
101
+ get currentStage(): ConverterStage<CircuitJson, KicadSch> | undefined;
102
+ constructor(circuitJson: CircuitJson);
103
+ step(): void;
104
+ runUntilFinished(): void;
105
+ getOutput(): KicadSch;
106
+ /**
107
+ * Get the output as a string
108
+ */
109
+ getOutputString(): string;
110
+ }
111
+
112
+ interface CircuitJsonToKicadPcbOptions {
113
+ /**
114
+ * Set to true to embed "${KIPRJMOD}/3dmodels" 3D model references for
115
+ * builtin footprints. Enable this in the CLI zip export.
116
+ * Defaults to false.
117
+ */
118
+ includeBuiltin3dModels?: boolean;
119
+ /**
120
+ * Project name used as the .3dshapes folder for user-provided models.
121
+ * e.g. "index" → "3dmodels/index.3dshapes/{filename}"
122
+ */
123
+ projectName?: string;
124
+ }
125
+ declare class CircuitJsonToKicadPcbConverter {
126
+ ctx: ConverterContext;
127
+ pipeline: ConverterStage<CircuitJson, KicadPcb>[];
128
+ currentStageIndex: number;
129
+ finished: boolean;
130
+ get currentStage(): ConverterStage<CircuitJson, KicadPcb> | undefined;
131
+ constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadPcbOptions);
132
+ step(): void;
133
+ runUntilFinished(): void;
134
+ getOutput(): KicadPcb;
135
+ /**
136
+ * Get the output as a string
137
+ */
138
+ getOutputString(): string;
139
+ /**
140
+ * Returns CDN URLs for 3D model files needed by builtin footprints in this PCB.
141
+ * The CLI can use these to download and include the models in the project zip.
142
+ */
143
+ getModel3dSourcePaths(): string[];
144
+ }
145
+
146
+ interface CircuitJsonToKicadProOptions {
147
+ projectName?: string;
148
+ schematicFilename?: string;
149
+ pcbFilename?: string;
150
+ }
151
+ interface KicadProNetClass {
152
+ bus_width?: number;
153
+ clearance?: number;
154
+ diff_pair_gap?: number;
155
+ diff_pair_via_gap?: number;
156
+ diff_pair_width?: number;
157
+ line_style?: number;
158
+ microvia_diameter?: number;
159
+ microvia_drill?: number;
160
+ name?: string;
161
+ pcb_color?: string;
162
+ priority?: number;
163
+ schematic_color?: string;
164
+ track_width?: number;
165
+ via_diameter?: number;
166
+ via_drill?: number;
167
+ wire_width?: number;
168
+ }
169
+ interface KicadProProject {
170
+ version: number;
171
+ head: {
172
+ generator: string;
173
+ generator_version: string;
174
+ project_name: string;
175
+ created: string;
176
+ modified: string;
177
+ };
178
+ meta: {
179
+ version: number;
180
+ };
181
+ text_variables: Record<string, string>;
182
+ libraries: {
183
+ pinned_symbol_libs: string[];
184
+ pinned_footprint_libs: string[];
185
+ };
186
+ boards: string[];
187
+ cvpcb: {
188
+ meta: {
189
+ version: number;
190
+ };
191
+ };
192
+ erc: {
193
+ meta: {
194
+ version: number;
195
+ };
196
+ erc_exclusions: unknown[];
197
+ };
198
+ net_settings: {
199
+ meta: {
200
+ version: number;
201
+ };
202
+ last_net_id: number;
203
+ classes: KicadProNetClass[];
204
+ };
205
+ pcbnew: {
206
+ page_layout_descr_file: string;
207
+ last_paths: Record<string, string>;
208
+ };
209
+ schematic: {
210
+ meta: {
211
+ version: number;
212
+ };
213
+ page_layout_descr_file: string;
214
+ last_opened_files: string[];
215
+ };
216
+ board: {
217
+ meta: {
218
+ version: number;
219
+ };
220
+ design_settings: {
221
+ rules: {
222
+ allow_blind_buried_vias?: boolean;
223
+ allow_microvias?: boolean;
224
+ max_error?: number;
225
+ min_clearance?: number;
226
+ min_connection?: number;
227
+ min_copper_edge_clearance?: number;
228
+ min_groove_width?: number;
229
+ min_hole_clearance?: number;
230
+ min_hole_to_hole?: number;
231
+ min_microvia_diameter?: number;
232
+ min_microvia_drill?: number;
233
+ min_resolved_spokes?: number;
234
+ min_silk_clearance?: number;
235
+ min_text_height?: number;
236
+ min_text_thickness?: number;
237
+ min_through_hole_diameter?: number;
238
+ min_track_width?: number;
239
+ min_via_annular_width?: number;
240
+ min_via_diameter?: number;
241
+ solder_mask_clearance?: number;
242
+ solder_mask_min_width?: number;
243
+ solder_mask_to_copper_clearance?: number;
244
+ use_height_for_length_calcs?: boolean;
245
+ };
246
+ };
247
+ last_opened_board: string;
248
+ };
249
+ sheets: [string, string][];
250
+ }
251
+ declare class CircuitJsonToKicadProConverter {
252
+ ctx: {
253
+ db: ReturnType<typeof cju>;
254
+ circuitJson: CircuitJson;
255
+ };
256
+ private project;
257
+ private createBaseNetClass;
258
+ constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadProOptions);
259
+ runUntilFinished(): void;
260
+ getOutput(): KicadProProject;
261
+ getOutputString(): string;
262
+ }
263
+
264
+ type ModelFetchResponse = {
265
+ ok: boolean;
266
+ arrayBuffer: () => Promise<ArrayBuffer>;
267
+ };
268
+ interface LoadedKicad3dModelFile {
269
+ sourcePath: string;
270
+ outputPath: string;
271
+ content: Uint8Array;
272
+ }
273
+ interface Kicad3dModelLoadError {
274
+ sourcePath: string;
275
+ error: unknown;
276
+ }
277
+ interface ResolveAndLoadKicad3dModelFilesOptions {
278
+ model3dSourcePaths: string[];
279
+ projectName: string;
280
+ fetch: (modelPath: string) => Promise<ModelFetchResponse>;
281
+ readFile?: (modelPath: string) => Promise<ArrayBuffer | Uint8Array>;
282
+ onModelFile: (file: LoadedKicad3dModelFile) => void | Promise<void>;
283
+ onError?: (error: Kicad3dModelLoadError) => void | Promise<void>;
284
+ }
285
+ declare const resolveAndLoadKicad3dModelFiles: ({ model3dSourcePaths, projectName, fetch, readFile, onModelFile, onError, }: ResolveAndLoadKicad3dModelFilesOptions) => Promise<void>;
286
+
287
+ interface CircuitJsonToKicadLibraryOptions {
288
+ libraryName?: string;
289
+ footprintLibraryName?: string;
290
+ }
291
+
292
+ declare class CircuitJsonToKicadLibraryConverter {
293
+ ctx: ConverterContext;
294
+ pipeline: ConverterStage<CircuitJson, KicadLibraryOutput>[];
295
+ currentStageIndex: number;
296
+ finished: boolean;
297
+ get currentStage(): ConverterStage<CircuitJson, KicadLibraryOutput> | undefined;
298
+ constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadLibraryOptions);
299
+ step(): void;
300
+ runUntilFinished(): void;
301
+ getOutput(): KicadLibraryOutput;
302
+ getSymbolLibraryString(): string;
303
+ getFootprints(): FootprintEntry[];
304
+ getFpLibTableString(): string;
305
+ getSymLibTableString(): string;
306
+ getModel3dSourcePaths(): string[];
307
+ }
308
+
309
+ interface KicadLibraryConverterOptions {
310
+ /**
311
+ * Name for the generated KiCad library (e.g., "my-library").
312
+ * This will be used for the user library files.
313
+ */
314
+ kicadLibraryName?: string;
315
+ /**
316
+ * The main entry point file for the library (e.g., "lib/my-library.ts").
317
+ * This file's exports define the public API of the library.
318
+ */
319
+ entrypoint: string;
320
+ /**
321
+ * Callback to build circuit JSON from a file path and export name.
322
+ * Should handle both board components and symbol components:
323
+ * - For board components: render inside a <board> element
324
+ * - For symbol components: render inside a <chip> with the symbol prop
325
+ * (Note: tscircuit symbols cannot render standalone - they must be
326
+ * used as a prop on a <chip> component)
327
+ * Return null if the export cannot be rendered.
328
+ */
329
+ buildFileToCircuitJson: (filePath: string, componentName: string) => Promise<CircuitJson | null>;
330
+ /**
331
+ * Callback to get all exports from a TSX/TS file.
332
+ * Must evaluate the file (not just parse) to handle `export * from` patterns.
333
+ */
334
+ getExportsFromTsxFile: (filePath: string) => Promise<string[]>;
335
+ /**
336
+ * Callback to resolve an export name to its file path.
337
+ * Returns the file path where the component is defined, or null if not resolvable.
338
+ */
339
+ resolveExportPath?: (entrypoint: string, exportName: string) => Promise<string | null>;
340
+ /**
341
+ * Whether to include builtin footprints/symbols (like 0402, soic8).
342
+ * Default: true
343
+ */
344
+ includeBuiltins?: boolean;
345
+ /**
346
+ * Whether to generate files for KiCad PCM (Plugin and Content Manager).
347
+ * When true:
348
+ * - Footprint references in symbols will be prefixed with "PCM_"
349
+ * - 3D model paths will use ${KICAD_3RD_PARTY} variable instead of relative paths
350
+ * Default: false
351
+ */
352
+ isPcm?: boolean;
353
+ /**
354
+ * The KiCad PCM package identifier (e.g., "com_tscircuit_author_package-name").
355
+ * Required when useKicadPcmPaths is true.
356
+ * Used to construct 3D model paths like:
357
+ * ${KICAD9_3RD_PARTY}/3dmodels/<kicadPcmPackageId>/<library>.3dshapes/<model>.step
358
+ */
359
+ kicadPcmPackageId?: string;
360
+ }
361
+ interface KicadLibraryConverterOutput {
362
+ /**
363
+ * Map of file paths to file contents for the generated KiCad library.
364
+ */
365
+ kicadProjectFsMap: Record<string, string | Buffer>;
366
+ /**
367
+ * Source paths to 3D model files that need to be copied.
368
+ */
369
+ model3dSourcePaths: string[];
370
+ }
371
+
372
+ /**
373
+ * Converts tscircuit component files to a KiCad library.
374
+ */
375
+ declare class KicadLibraryConverter {
376
+ private options;
377
+ private output;
378
+ private ctx;
379
+ constructor(options: KicadLibraryConverterOptions);
380
+ run(): Promise<void>;
381
+ /**
382
+ * Builds tscircuit components to circuit-json.
383
+ */
384
+ private buildTscircuitComponents;
385
+ /**
386
+ * Extracts KiCad footprints and symbols from built tscircuit components.
387
+ */
388
+ private extractKicadComponents;
389
+ getOutput(): KicadLibraryConverterOutput;
390
+ }
391
+
392
+ export { CircuitJsonToKicadLibraryConverter, CircuitJsonToKicadPcbConverter, CircuitJsonToKicadProConverter, CircuitJsonToKicadSchConverter, type FootprintEntry, type Kicad3dModelLoadError, KicadLibraryConverter, type KicadLibraryConverterOptions, type KicadLibraryConverterOutput, type KicadLibraryOutput, type LoadedKicad3dModelFile, type ResolveAndLoadKicad3dModelFilesOptions, type SymbolEntry, resolveAndLoadKicad3dModelFiles };