@tscircuit/internal-dynamic-import 0.0.18 → 0.0.20
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 +278 -7
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/lib/supported-modules.ts +6 -0
- package/lib/type-bundles/circuit-json-to-kicad.d.ts +169 -6
- package/lib/type-bundles/jscad-to-parasolid.d.ts +59 -0
- package/lib/type-bundles/jscad-to-step.d.ts +24 -0
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,114 @@
|
|
|
1
|
+
import { JscadOperation } from 'jscad-planner';
|
|
1
2
|
import * as circuit_json_to_gltf from 'circuit-json-to-gltf';
|
|
2
|
-
import { AnyCircuitElement, SourceComponentBase, PcbComponent, CircuitJson, SchematicNetLabel, PCBTrace, PCBPort, LayerRef as LayerRef$1, Ring, NinePointAnchor, PcbRenderLayer, PcbBoard, PcbCopperPour, PcbCopperText, PcbCourtyardCircle, PcbCutout, PcbFabricationNoteDimension, PcbFabricationNotePath, PcbFabricationNoteRect, PcbFabricationNoteText, PcbHole, PCBKeepout, PcbNoteDimension, PcbNotePath, PcbNoteRect, PcbNoteText, PcbPanel, PcbPlatedHole, PcbSilkscreenCircle, PcbSilkscreenGraphic, PcbSilkscreenLine, PcbSilkscreenOval, PcbSilkscreenPath, PcbSilkscreenPill, PcbSilkscreenRect, PcbSilkscreenText, PcbSmtPad, PcbVia, PcbSolderPaste, PcbTrace, PCBVia, SimulationExperiment, SimulationTransientVoltageGraph, SimulationVoltageProbe, PcbPort, SchematicComponent } from 'circuit-json';
|
|
3
|
+
import { AnyCircuitElement, SourceComponentBase, PcbComponent, CircuitJson, SchematicNetLabel, PCBTrace, PCBPort, LayerRef as LayerRef$1, Point as Point$1, Ring, NinePointAnchor, PcbRenderLayer, PcbBoard, PcbCopperPour, PcbCopperText, PcbCourtyardCircle, PcbCutout, PcbFabricationNoteDimension, PcbFabricationNotePath, PcbFabricationNoteRect, PcbFabricationNoteText, PcbHole, PCBKeepout, PcbNoteDimension, PcbNotePath, PcbNoteRect, PcbNoteText, PcbPanel, PcbPlatedHole, PcbSilkscreenCircle, PcbSilkscreenGraphic, PcbSilkscreenLine, PcbSilkscreenOval, PcbSilkscreenPath, PcbSilkscreenPill, PcbSilkscreenRect, PcbSilkscreenText, PcbSmtPad, PcbVia, PcbSolderPaste, PcbTrace, PCBVia, SimulationExperiment, SimulationTransientVoltageGraph, SimulationVoltageProbe, PcbPort, SchematicComponent } from 'circuit-json';
|
|
3
4
|
import { BpcGraph } from 'bpc-graph';
|
|
4
5
|
import { RenderOptionsInput } from 'poppygl';
|
|
5
6
|
import { z, AnyZodObject } from 'zod';
|
|
6
|
-
import { CircuitJsonUtilObjects, cju } from '@tscircuit/circuit-json-util';
|
|
7
7
|
import { KicadSch, KicadPcb, SchematicSymbol, KicadSym } from 'kicadts';
|
|
8
|
+
import { CircuitJsonUtilObjects, cju } from '@tscircuit/circuit-json-util';
|
|
8
9
|
import { Matrix } from 'transformation-matrix';
|
|
9
10
|
import { LightBurnProject } from 'lbrnts';
|
|
10
11
|
import { Box } from '@tscircuit/simple-3d-svg';
|
|
11
12
|
import { INode } from 'svgson';
|
|
12
13
|
|
|
14
|
+
type StepColorInput = number[] | string;
|
|
15
|
+
|
|
16
|
+
interface Geom3Like$1 {
|
|
17
|
+
polygons: Array<{
|
|
18
|
+
vertices: any[];
|
|
19
|
+
}>;
|
|
20
|
+
transforms?: number[];
|
|
21
|
+
color?: StepColorInput;
|
|
22
|
+
}
|
|
23
|
+
interface RenderedModel$1 {
|
|
24
|
+
geometries: Array<{
|
|
25
|
+
geom: Geom3Like$1;
|
|
26
|
+
color?: StepColorInput;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
interface JscadToStepOptions {
|
|
30
|
+
/** Merge adjacent coplanar polygons into faces with inner bounds for holes. Default: true. */
|
|
31
|
+
mergeCoplanarFaces?: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare function jscadToStep(operation: JscadOperation | RenderedModel$1, options?: JscadToStepOptions): string;
|
|
34
|
+
|
|
35
|
+
type JscadToStepModule_JscadToStepOptions = JscadToStepOptions;
|
|
36
|
+
declare const JscadToStepModule_jscadToStep: typeof jscadToStep;
|
|
37
|
+
declare namespace JscadToStepModule {
|
|
38
|
+
export { type JscadToStepModule_JscadToStepOptions as JscadToStepOptions, JscadToStepModule_jscadToStep as jscadToStep };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type Point3$1 = readonly [number, number, number];
|
|
42
|
+
type ParasolidColorInput = string | readonly number[];
|
|
43
|
+
type ParasolidRgbColor = readonly [number, number, number];
|
|
44
|
+
/** Also accepts JSON-exported JSCAD vertices and typed coordinate arrays. */
|
|
45
|
+
type Geom3Vertex = ArrayLike<number> | {
|
|
46
|
+
readonly pos: ArrayLike<number>;
|
|
47
|
+
} | {
|
|
48
|
+
readonly position: ArrayLike<number>;
|
|
49
|
+
};
|
|
50
|
+
interface Geom3Like {
|
|
51
|
+
readonly polygons: readonly {
|
|
52
|
+
readonly vertices: readonly Geom3Vertex[];
|
|
53
|
+
readonly color?: ParasolidColorInput;
|
|
54
|
+
}[];
|
|
55
|
+
/** JSCAD's column-major, lazily applied affine matrix. */
|
|
56
|
+
readonly transforms?: ArrayLike<number>;
|
|
57
|
+
readonly color?: ParasolidColorInput;
|
|
58
|
+
}
|
|
59
|
+
type JscadGeometryInput = JscadOperation | Geom3Like;
|
|
60
|
+
/** The vanilla renderer can use either jscad-planner or @jscad/modeling. */
|
|
61
|
+
interface RenderedModel {
|
|
62
|
+
readonly geometries: readonly {
|
|
63
|
+
readonly geom: JscadGeometryInput;
|
|
64
|
+
readonly color?: ParasolidColorInput;
|
|
65
|
+
readonly name?: string;
|
|
66
|
+
}[];
|
|
67
|
+
}
|
|
68
|
+
type JscadToParasolidInput = JscadGeometryInput | readonly JscadGeometryInput[] | RenderedModel;
|
|
69
|
+
interface JscadToParasolidOptions {
|
|
70
|
+
/** Merge adjacent coplanar CAD faces. Default true; curves remain faceted. */
|
|
71
|
+
readonly mergeCoplanarFaces?: boolean;
|
|
72
|
+
/** Input length unit. X_T coordinates are always written in metres. */
|
|
73
|
+
readonly units?: "mm" | "m";
|
|
74
|
+
/** Reserved for future X_T name attributes; not transmitted yet. */
|
|
75
|
+
readonly name?: string;
|
|
76
|
+
}
|
|
77
|
+
interface ParasolidBodyInput {
|
|
78
|
+
readonly polygons: readonly (readonly Point3$1[])[];
|
|
79
|
+
readonly name?: string;
|
|
80
|
+
readonly color?: ParasolidRgbColor;
|
|
81
|
+
readonly faceColors?: readonly (ParasolidRgbColor | undefined)[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Resolve JSCAD geometry into world-coordinate polygon bodies, in input units.
|
|
86
|
+
* No caller-owned geometry or matrices are mutated. RGB colors are preserved;
|
|
87
|
+
* alpha is not represented by the supported native color attributes.
|
|
88
|
+
* The converter validates planarity and closed-manifold topology before serialization.
|
|
89
|
+
*/
|
|
90
|
+
declare function jscadToParasolidBodies(input: JscadToParasolidInput, options?: JscadToParasolidOptions): ParasolidBodyInput[];
|
|
91
|
+
/**
|
|
92
|
+
* Convert JSCAD/modelprinter geometry to native Parasolid text (.x_t).
|
|
93
|
+
* Curves remain JSCAD's planar facets; this does not reconstruct analytic curves.
|
|
94
|
+
*/
|
|
95
|
+
declare function jscadToParasolid(input: JscadToParasolidInput, options?: JscadToParasolidOptions): string;
|
|
96
|
+
|
|
97
|
+
type JscadToParasolidModule_Geom3Like = Geom3Like;
|
|
98
|
+
type JscadToParasolidModule_Geom3Vertex = Geom3Vertex;
|
|
99
|
+
type JscadToParasolidModule_JscadGeometryInput = JscadGeometryInput;
|
|
100
|
+
type JscadToParasolidModule_JscadToParasolidInput = JscadToParasolidInput;
|
|
101
|
+
type JscadToParasolidModule_JscadToParasolidOptions = JscadToParasolidOptions;
|
|
102
|
+
type JscadToParasolidModule_ParasolidBodyInput = ParasolidBodyInput;
|
|
103
|
+
type JscadToParasolidModule_ParasolidColorInput = ParasolidColorInput;
|
|
104
|
+
type JscadToParasolidModule_ParasolidRgbColor = ParasolidRgbColor;
|
|
105
|
+
type JscadToParasolidModule_RenderedModel = RenderedModel;
|
|
106
|
+
declare const JscadToParasolidModule_jscadToParasolid: typeof jscadToParasolid;
|
|
107
|
+
declare const JscadToParasolidModule_jscadToParasolidBodies: typeof jscadToParasolidBodies;
|
|
108
|
+
declare namespace JscadToParasolidModule {
|
|
109
|
+
export { type JscadToParasolidModule_Geom3Like as Geom3Like, type JscadToParasolidModule_Geom3Vertex as Geom3Vertex, type JscadToParasolidModule_JscadGeometryInput as JscadGeometryInput, type JscadToParasolidModule_JscadToParasolidInput as JscadToParasolidInput, type JscadToParasolidModule_JscadToParasolidOptions as JscadToParasolidOptions, type JscadToParasolidModule_ParasolidBodyInput as ParasolidBodyInput, type JscadToParasolidModule_ParasolidColorInput as ParasolidColorInput, type JscadToParasolidModule_ParasolidRgbColor as ParasolidRgbColor, type Point3$1 as Point3, type JscadToParasolidModule_RenderedModel as RenderedModel, JscadToParasolidModule_jscadToParasolid as jscadToParasolid, JscadToParasolidModule_jscadToParasolidBodies as jscadToParasolidBodies };
|
|
110
|
+
}
|
|
111
|
+
|
|
13
112
|
type CameraOptions = {
|
|
14
113
|
camPos: readonly [number, number, number];
|
|
15
114
|
lookAt: readonly [number, number, number];
|
|
@@ -1348,9 +1447,18 @@ declare namespace CircuitJsonToGltfModule {
|
|
|
1348
1447
|
|
|
1349
1448
|
type PaperSize = "A0" | "A1" | "A2" | "A3" | "A4" | "A5";
|
|
1350
1449
|
interface PaperDimensions {
|
|
1450
|
+
/** Effective page width after orientation, in millimeters. */
|
|
1351
1451
|
width: number;
|
|
1452
|
+
/** Effective page height after orientation, in millimeters. */
|
|
1352
1453
|
height: number;
|
|
1353
|
-
name: PaperSize;
|
|
1454
|
+
name: PaperSize | string;
|
|
1455
|
+
/** Raw custom dimensions written to KiCad's `(paper width height)` form. */
|
|
1456
|
+
customSize?: {
|
|
1457
|
+
width: number;
|
|
1458
|
+
height: number;
|
|
1459
|
+
};
|
|
1460
|
+
/** Whether KiCad writes the page with its `portrait` flag. */
|
|
1461
|
+
isPortrait?: boolean;
|
|
1354
1462
|
}
|
|
1355
1463
|
|
|
1356
1464
|
type SchematicPortId = string;
|
|
@@ -1400,6 +1508,25 @@ interface ConverterContext$1 {
|
|
|
1400
1508
|
c2kMatPcb?: Matrix;
|
|
1401
1509
|
/** Selected paper size for schematic */
|
|
1402
1510
|
schematicPaperSize?: PaperDimensions;
|
|
1511
|
+
/**
|
|
1512
|
+
* UUID written as this file's own top-level `(uuid ...)`. When set,
|
|
1513
|
+
* InitializeSchematicStage uses it instead of generating a random one so the
|
|
1514
|
+
* root uuid can be shared across the root file, child files, sheet nodes and
|
|
1515
|
+
* the `.kicad_pro`.
|
|
1516
|
+
*/
|
|
1517
|
+
schematicFileUuid?: string;
|
|
1518
|
+
/**
|
|
1519
|
+
* Prefix used for every symbol `(instances ... (path ...))` in this file.
|
|
1520
|
+
* Root/legacy files use `/<rootUuid>`; child sheet files use
|
|
1521
|
+
* `/<rootUuid>/<sheetNodeUuid>` (KiCad requires the root uuid first).
|
|
1522
|
+
*/
|
|
1523
|
+
symbolInstancePathPrefix?: string;
|
|
1524
|
+
/**
|
|
1525
|
+
* Lib id for each schematic component whose pin numbering differs from an
|
|
1526
|
+
* earlier instance of the same library symbol, keyed by
|
|
1527
|
+
* schematic_component_id. Set by AddLibrarySymbolsStage.
|
|
1528
|
+
*/
|
|
1529
|
+
schematicComponentLibraryIds?: Map<string, string>;
|
|
1403
1530
|
pinPositions?: Map<SchematicPortId, {
|
|
1404
1531
|
x: number;
|
|
1405
1532
|
y: number;
|
|
@@ -1411,6 +1538,7 @@ interface ConverterContext$1 {
|
|
|
1411
1538
|
}>;
|
|
1412
1539
|
pcbNetMap?: Map<string, PcbNetInfo>;
|
|
1413
1540
|
numLayers?: number;
|
|
1541
|
+
edgeCutsWidth?: number;
|
|
1414
1542
|
/** Project name used as the .3dshapes folder for user-provided 3D models */
|
|
1415
1543
|
projectName?: string;
|
|
1416
1544
|
/** CDN URLs of 3D models needed for this PCB (collected during footprint stage) */
|
|
@@ -1436,20 +1564,125 @@ declare abstract class ConverterStage$1<Input, Output> {
|
|
|
1436
1564
|
getOutput(): Output;
|
|
1437
1565
|
}
|
|
1438
1566
|
|
|
1567
|
+
/** Fields common to the root page and every child schematic file. */
|
|
1568
|
+
interface SchematicSheetPlanEntryBase {
|
|
1569
|
+
/** Value written to the KiCad `(property "Sheetname" ...)` */
|
|
1570
|
+
sheetName: string;
|
|
1571
|
+
/** Sanitized, unique file stem (no extension) used to derive `filename` */
|
|
1572
|
+
fileBaseName: string;
|
|
1573
|
+
/** File name for this sheet's `.kicad_sch` (root filename is overridden by the caller) */
|
|
1574
|
+
filename: string;
|
|
1575
|
+
/** KiCad page number ("1" for root, "2".. for children) */
|
|
1576
|
+
pageNumber: string;
|
|
1577
|
+
/** UUID written as this file's own top-level `(uuid ...)` */
|
|
1578
|
+
fileUuid: string;
|
|
1579
|
+
}
|
|
1580
|
+
/** The top-level root schematic (page "1"); it holds the `(sheet)` nodes. */
|
|
1581
|
+
interface RootSchematicSheetPlanEntry extends SchematicSheetPlanEntryBase {
|
|
1582
|
+
schematicSheetId: null;
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* One circuit-json `schematic_sheet`, emitted as a `(sheet)` node on the root
|
|
1586
|
+
* page plus its own child `.kicad_sch` file.
|
|
1587
|
+
*/
|
|
1588
|
+
interface ChildSchematicSheetPlanEntry extends SchematicSheetPlanEntryBase {
|
|
1589
|
+
/** circuit-json schematic_sheet_id this file represents */
|
|
1590
|
+
schematicSheetId: string;
|
|
1591
|
+
/**
|
|
1592
|
+
* UUID of the `(sheet)` node placed on the root page. It is the second segment
|
|
1593
|
+
* of the symbol instance path for symbols on this sheet (`/<rootUuid>/<sheetNodeUuid>`).
|
|
1594
|
+
*/
|
|
1595
|
+
sheetNodeUuid: string;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Blueprint of the KiCad schematic files to emit for one circuit-json input:
|
|
1599
|
+
* the root `.kicad_sch` plus one child `.kicad_sch` per `schematic_sheet`, each
|
|
1600
|
+
* with the UUIDs, filename, and page number KiCad needs. Computed up front (with
|
|
1601
|
+
* no file content) so the schematic converter and the `.kicad_pro` converter
|
|
1602
|
+
* agree on the same identifiers.
|
|
1603
|
+
*/
|
|
1604
|
+
interface SchematicSheetPlan {
|
|
1605
|
+
/**
|
|
1606
|
+
* UUID of the root schematic file. Every symbol instance path begins with
|
|
1607
|
+
* this uuid (KiCad requirement), so it is shared by the root file, the child
|
|
1608
|
+
* files, the `(sheet)` nodes, and the `.kicad_pro` sheets list.
|
|
1609
|
+
*/
|
|
1610
|
+
rootUuid: string;
|
|
1611
|
+
root: RootSchematicSheetPlanEntry;
|
|
1612
|
+
children: ChildSchematicSheetPlanEntry[];
|
|
1613
|
+
/** True when the design has `schematic_sheet`s and must be emitted as a hierarchy */
|
|
1614
|
+
isHierarchical: boolean;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
interface KicadSchematicTitleBlockMetadata {
|
|
1618
|
+
company?: string;
|
|
1619
|
+
comments?: Array<{
|
|
1620
|
+
index: number;
|
|
1621
|
+
text: string;
|
|
1622
|
+
}>;
|
|
1623
|
+
date?: string;
|
|
1624
|
+
revision?: string;
|
|
1625
|
+
title?: string;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
interface KicadSchFile {
|
|
1629
|
+
filename: string;
|
|
1630
|
+
content: string;
|
|
1631
|
+
}
|
|
1632
|
+
interface KicadSchFileOutputOptions {
|
|
1633
|
+
schematicFilename: string;
|
|
1634
|
+
}
|
|
1635
|
+
interface CircuitJsonToKicadSchConverterOptions {
|
|
1636
|
+
paperSize?: PaperDimensions;
|
|
1637
|
+
schematicSheets?: KicadSchematicSheetOptions[];
|
|
1638
|
+
titleBlock?: KicadSchematicTitleBlockMetadata;
|
|
1639
|
+
}
|
|
1640
|
+
interface KicadSchematicSheetOptions {
|
|
1641
|
+
/** Position of Circuit JSON (0, 0) on the KiCad page, in millimeters. */
|
|
1642
|
+
circuitOrigin: Point$1;
|
|
1643
|
+
/** Geometry of this child sheet's hierarchy node on the root page. */
|
|
1644
|
+
hierarchyNode?: {
|
|
1645
|
+
position: Point$1;
|
|
1646
|
+
size: {
|
|
1647
|
+
height: number;
|
|
1648
|
+
width: number;
|
|
1649
|
+
};
|
|
1650
|
+
};
|
|
1651
|
+
/** Omit for a standalone schematic or the root sheet. */
|
|
1652
|
+
schematicSheetId?: string;
|
|
1653
|
+
}
|
|
1439
1654
|
declare class CircuitJsonToKicadSchConverter {
|
|
1440
1655
|
ctx: ConverterContext$1;
|
|
1441
1656
|
pipeline: ConverterStage$1<CircuitJson, KicadSch>[];
|
|
1442
1657
|
currentStageIndex: number;
|
|
1443
1658
|
finished: boolean;
|
|
1659
|
+
circuitJson: CircuitJson;
|
|
1660
|
+
schematicSheetPlan: SchematicSheetPlan;
|
|
1661
|
+
private files;
|
|
1662
|
+
private built;
|
|
1663
|
+
private readonly options;
|
|
1444
1664
|
get currentStage(): ConverterStage$1<CircuitJson, KicadSch> | undefined;
|
|
1445
|
-
constructor(circuitJson: CircuitJson);
|
|
1665
|
+
constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadSchConverterOptions);
|
|
1446
1666
|
step(): void;
|
|
1447
1667
|
runUntilFinished(): void;
|
|
1448
1668
|
getOutput(): KicadSch;
|
|
1449
1669
|
/**
|
|
1450
|
-
* Get the
|
|
1670
|
+
* Get the (root) schematic as a string.
|
|
1451
1671
|
*/
|
|
1452
1672
|
getOutputString(): string;
|
|
1673
|
+
/**
|
|
1674
|
+
* Returns every KiCad schematic file produced by this converter.
|
|
1675
|
+
*
|
|
1676
|
+
* For a design with no `schematic_sheet` elements this is a single root file.
|
|
1677
|
+
* For a hierarchical design it is the root file (named by
|
|
1678
|
+
* `options.schematicFilename`) followed by one child `.kicad_sch` per sheet,
|
|
1679
|
+
* each named after its sheet and referenced by the root via `Sheetfile`.
|
|
1680
|
+
*/
|
|
1681
|
+
getOutputFiles(options: KicadSchFileOutputOptions): KicadSchFile[];
|
|
1682
|
+
/** Builds the root + child `.kicad_sch` files for a hierarchical design. */
|
|
1683
|
+
private buildAll;
|
|
1684
|
+
/** Builds one child/root `.kicad_sch` for a sheet, run to completion. */
|
|
1685
|
+
private buildSheetFile;
|
|
1453
1686
|
}
|
|
1454
1687
|
|
|
1455
1688
|
interface CircuitJsonToKicadPcbOptions {
|
|
@@ -1464,6 +1697,11 @@ interface CircuitJsonToKicadPcbOptions {
|
|
|
1464
1697
|
* e.g. "index" → "3dmodels/index.3dshapes/{filename}"
|
|
1465
1698
|
*/
|
|
1466
1699
|
projectName?: string;
|
|
1700
|
+
/**
|
|
1701
|
+
* Stroke width in millimetres for generated Edge.Cuts graphics.
|
|
1702
|
+
* Defaults to 0.1 mm when the source format does not provide one.
|
|
1703
|
+
*/
|
|
1704
|
+
edgeCutsWidth?: number;
|
|
1467
1705
|
}
|
|
1468
1706
|
declare class CircuitJsonToKicadPcbConverter {
|
|
1469
1707
|
ctx: ConverterContext$1;
|
|
@@ -1490,6 +1728,12 @@ interface CircuitJsonToKicadProOptions {
|
|
|
1490
1728
|
projectName?: string;
|
|
1491
1729
|
schematicFilename?: string;
|
|
1492
1730
|
pcbFilename?: string;
|
|
1731
|
+
/**
|
|
1732
|
+
* Sheet plan produced by CircuitJsonToKicadSchConverter. When provided, the
|
|
1733
|
+
* project's `sheets` list uses the same root/sheet-node UUIDs so the
|
|
1734
|
+
* `.kicad_pro` stays consistent with the generated `.kicad_sch` hierarchy.
|
|
1735
|
+
*/
|
|
1736
|
+
schematicSheetPlan?: SchematicSheetPlan;
|
|
1493
1737
|
}
|
|
1494
1738
|
interface KicadProNetClass {
|
|
1495
1739
|
bus_width?: number;
|
|
@@ -1604,6 +1848,24 @@ declare class CircuitJsonToKicadProConverter {
|
|
|
1604
1848
|
getOutputString(): string;
|
|
1605
1849
|
}
|
|
1606
1850
|
|
|
1851
|
+
interface CircuitJsonToKicadModOptions {
|
|
1852
|
+
libraryName?: string;
|
|
1853
|
+
footprintLibraryName?: string;
|
|
1854
|
+
footprintName?: string;
|
|
1855
|
+
}
|
|
1856
|
+
declare class CircuitJsonToKicadModConverter {
|
|
1857
|
+
private readonly libraryConverter;
|
|
1858
|
+
private readonly footprintName?;
|
|
1859
|
+
constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadModOptions);
|
|
1860
|
+
get finished(): boolean;
|
|
1861
|
+
get currentStage(): ConverterStage$1<CircuitJson, KicadLibraryOutput> | undefined;
|
|
1862
|
+
step(): void;
|
|
1863
|
+
runUntilFinished(): void;
|
|
1864
|
+
getOutput(): FootprintEntry;
|
|
1865
|
+
getOutputString(): string;
|
|
1866
|
+
getModel3dSourcePaths(): string[];
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1607
1869
|
type ModelFetchResponse = {
|
|
1608
1870
|
ok: boolean;
|
|
1609
1871
|
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
@@ -1734,12 +1996,16 @@ declare class KicadLibraryConverter {
|
|
|
1734
1996
|
|
|
1735
1997
|
type CircuitJsonToKicadModule_CircuitJsonToKicadLibraryConverter = CircuitJsonToKicadLibraryConverter;
|
|
1736
1998
|
declare const CircuitJsonToKicadModule_CircuitJsonToKicadLibraryConverter: typeof CircuitJsonToKicadLibraryConverter;
|
|
1999
|
+
type CircuitJsonToKicadModule_CircuitJsonToKicadModConverter = CircuitJsonToKicadModConverter;
|
|
2000
|
+
declare const CircuitJsonToKicadModule_CircuitJsonToKicadModConverter: typeof CircuitJsonToKicadModConverter;
|
|
1737
2001
|
type CircuitJsonToKicadModule_CircuitJsonToKicadPcbConverter = CircuitJsonToKicadPcbConverter;
|
|
1738
2002
|
declare const CircuitJsonToKicadModule_CircuitJsonToKicadPcbConverter: typeof CircuitJsonToKicadPcbConverter;
|
|
2003
|
+
type CircuitJsonToKicadModule_CircuitJsonToKicadPcbOptions = CircuitJsonToKicadPcbOptions;
|
|
1739
2004
|
type CircuitJsonToKicadModule_CircuitJsonToKicadProConverter = CircuitJsonToKicadProConverter;
|
|
1740
2005
|
declare const CircuitJsonToKicadModule_CircuitJsonToKicadProConverter: typeof CircuitJsonToKicadProConverter;
|
|
1741
2006
|
type CircuitJsonToKicadModule_CircuitJsonToKicadSchConverter = CircuitJsonToKicadSchConverter;
|
|
1742
2007
|
declare const CircuitJsonToKicadModule_CircuitJsonToKicadSchConverter: typeof CircuitJsonToKicadSchConverter;
|
|
2008
|
+
type CircuitJsonToKicadModule_CircuitJsonToKicadSchConverterOptions = CircuitJsonToKicadSchConverterOptions;
|
|
1743
2009
|
type CircuitJsonToKicadModule_FootprintEntry = FootprintEntry;
|
|
1744
2010
|
type CircuitJsonToKicadModule_Kicad3dModelLoadError = Kicad3dModelLoadError;
|
|
1745
2011
|
type CircuitJsonToKicadModule_KicadLibraryConverter = KicadLibraryConverter;
|
|
@@ -1747,12 +2013,15 @@ declare const CircuitJsonToKicadModule_KicadLibraryConverter: typeof KicadLibrar
|
|
|
1747
2013
|
type CircuitJsonToKicadModule_KicadLibraryConverterOptions = KicadLibraryConverterOptions;
|
|
1748
2014
|
type CircuitJsonToKicadModule_KicadLibraryConverterOutput = KicadLibraryConverterOutput;
|
|
1749
2015
|
type CircuitJsonToKicadModule_KicadLibraryOutput = KicadLibraryOutput;
|
|
2016
|
+
type CircuitJsonToKicadModule_KicadSchFile = KicadSchFile;
|
|
2017
|
+
type CircuitJsonToKicadModule_KicadSchFileOutputOptions = KicadSchFileOutputOptions;
|
|
2018
|
+
type CircuitJsonToKicadModule_KicadSchematicSheetOptions = KicadSchematicSheetOptions;
|
|
1750
2019
|
type CircuitJsonToKicadModule_LoadedKicad3dModelFile = LoadedKicad3dModelFile;
|
|
1751
2020
|
type CircuitJsonToKicadModule_ResolveAndLoadKicad3dModelFilesOptions = ResolveAndLoadKicad3dModelFilesOptions;
|
|
1752
2021
|
type CircuitJsonToKicadModule_SymbolEntry = SymbolEntry;
|
|
1753
2022
|
declare const CircuitJsonToKicadModule_resolveAndLoadKicad3dModelFiles: typeof resolveAndLoadKicad3dModelFiles;
|
|
1754
2023
|
declare namespace CircuitJsonToKicadModule {
|
|
1755
|
-
export { CircuitJsonToKicadModule_CircuitJsonToKicadLibraryConverter as CircuitJsonToKicadLibraryConverter, CircuitJsonToKicadModule_CircuitJsonToKicadPcbConverter as CircuitJsonToKicadPcbConverter, CircuitJsonToKicadModule_CircuitJsonToKicadProConverter as CircuitJsonToKicadProConverter, CircuitJsonToKicadModule_CircuitJsonToKicadSchConverter as CircuitJsonToKicadSchConverter, type CircuitJsonToKicadModule_FootprintEntry as FootprintEntry, type CircuitJsonToKicadModule_Kicad3dModelLoadError as Kicad3dModelLoadError, CircuitJsonToKicadModule_KicadLibraryConverter as KicadLibraryConverter, type CircuitJsonToKicadModule_KicadLibraryConverterOptions as KicadLibraryConverterOptions, type CircuitJsonToKicadModule_KicadLibraryConverterOutput as KicadLibraryConverterOutput, type CircuitJsonToKicadModule_KicadLibraryOutput as KicadLibraryOutput, type CircuitJsonToKicadModule_LoadedKicad3dModelFile as LoadedKicad3dModelFile, type CircuitJsonToKicadModule_ResolveAndLoadKicad3dModelFilesOptions as ResolveAndLoadKicad3dModelFilesOptions, type CircuitJsonToKicadModule_SymbolEntry as SymbolEntry, CircuitJsonToKicadModule_resolveAndLoadKicad3dModelFiles as resolveAndLoadKicad3dModelFiles };
|
|
2024
|
+
export { CircuitJsonToKicadModule_CircuitJsonToKicadLibraryConverter as CircuitJsonToKicadLibraryConverter, CircuitJsonToKicadModule_CircuitJsonToKicadModConverter as CircuitJsonToKicadModConverter, CircuitJsonToKicadModule_CircuitJsonToKicadPcbConverter as CircuitJsonToKicadPcbConverter, type CircuitJsonToKicadModule_CircuitJsonToKicadPcbOptions as CircuitJsonToKicadPcbOptions, CircuitJsonToKicadModule_CircuitJsonToKicadProConverter as CircuitJsonToKicadProConverter, CircuitJsonToKicadModule_CircuitJsonToKicadSchConverter as CircuitJsonToKicadSchConverter, type CircuitJsonToKicadModule_CircuitJsonToKicadSchConverterOptions as CircuitJsonToKicadSchConverterOptions, type CircuitJsonToKicadModule_FootprintEntry as FootprintEntry, type CircuitJsonToKicadModule_Kicad3dModelLoadError as Kicad3dModelLoadError, CircuitJsonToKicadModule_KicadLibraryConverter as KicadLibraryConverter, type CircuitJsonToKicadModule_KicadLibraryConverterOptions as KicadLibraryConverterOptions, type CircuitJsonToKicadModule_KicadLibraryConverterOutput as KicadLibraryConverterOutput, type CircuitJsonToKicadModule_KicadLibraryOutput as KicadLibraryOutput, type CircuitJsonToKicadModule_KicadSchFile as KicadSchFile, type CircuitJsonToKicadModule_KicadSchFileOutputOptions as KicadSchFileOutputOptions, type CircuitJsonToKicadModule_KicadSchematicSheetOptions as KicadSchematicSheetOptions, type CircuitJsonToKicadModule_LoadedKicad3dModelFile as LoadedKicad3dModelFile, type CircuitJsonToKicadModule_ResolveAndLoadKicad3dModelFilesOptions as ResolveAndLoadKicad3dModelFilesOptions, type CircuitJsonToKicadModule_SymbolEntry as SymbolEntry, CircuitJsonToKicadModule_resolveAndLoadKicad3dModelFiles as resolveAndLoadKicad3dModelFiles };
|
|
1756
2025
|
}
|
|
1757
2026
|
|
|
1758
2027
|
interface ConvertCircuitJsonToLbrnOptions {
|
|
@@ -4397,10 +4666,12 @@ declare namespace SchematicPlacementAnalysisModule {
|
|
|
4397
4666
|
export { SchematicPlacementAnalysisModule_SchematicPlacementAnalysis as SchematicPlacementAnalysis, type SchematicPlacementAnalysisModule_SchematicPlacementIssueArtifact as SchematicPlacementIssueArtifact, SchematicPlacementAnalysisModule_analyzeSchematicPlacement as analyzeSchematicPlacement, SchematicPlacementAnalysisModule_createSchematicPlacementIssueArtifacts as createSchematicPlacementIssueArtifacts };
|
|
4398
4667
|
}
|
|
4399
4668
|
|
|
4400
|
-
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-fdm-component-box", "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", "@tscircuit/circuit-json-schematic-placement-analysis"];
|
|
4669
|
+
declare const supportedModules: readonly ["jscad-to-step", "jscad-to-parasolid", "circuit-json-to-3d-png", "circuit-json-to-bom-csv", "circuit-json-to-bpc", "circuit-json-to-connectivity-map", "circuit-json-to-fdm-component-box", "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", "@tscircuit/circuit-json-schematic-placement-analysis"];
|
|
4401
4670
|
type SupportedModuleName = (typeof supportedModules)[number];
|
|
4402
4671
|
type SupportedModuleSpecifier = SupportedModuleName | `${SupportedModuleName}@${string}`;
|
|
4403
4672
|
interface SupportedModuleMap {
|
|
4673
|
+
"jscad-to-step": typeof JscadToStepModule;
|
|
4674
|
+
"jscad-to-parasolid": typeof JscadToParasolidModule;
|
|
4404
4675
|
"circuit-json-to-3d-png": typeof CircuitJsonTo3dPngModule;
|
|
4405
4676
|
"circuit-json-to-bom-csv": typeof CircuitJsonToBomCsvModule;
|
|
4406
4677
|
"circuit-json-to-bpc": typeof CircuitJsonToBpcModule;
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../lib/dynamic-module-registry.ts","../lib/supported-modules.ts","../lib/import-urls.ts","../lib/create-importer.ts","../lib/dynamic-import-resolver.ts","../lib/index.ts"],"names":["importer"],"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;;;AChBO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,kCAAA;AAAA,EACA,mCAAA;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,uBAAA;AAAA,EACA;AACF;AAsCO,IAAM,aAAA,GAAgB,CAAC,SAAA,KAA8B;AAE1D,EAAA,MAAM,wBAAwB,SAAA,CAAU,OAAA;AAAA,IACtC,GAAA;AAAA,IACA,SAAA,CAAU,UAAA,CAAW,GAAG,CAAA,GAAI,CAAA,GAAI;AAAA,GAClC;AACA,EAAA,OAAO,0BAA0B,EAAA,GAC7B,SAAA,GACA,SAAA,CAAU,KAAA,CAAM,GAAG,qBAAqB,CAAA;AAC9C;;;AC/EA,IAAM,cAAA,GAAiB,6BAAA;AAEvB,SAAS,oBAAA,GAA2C;AAClD,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA,GACrB,MAAA,CAAO,4BAA4B,M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AAA,CAAS,SAAS,CAAA;AACvC,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,SAAS,CAAA,CAAE,CAAA;AAAA,IAClE;AACA,IAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,SAAS,CAAA,EAAG;AAC3B,MAAA,MAAM,IAAA,GAAO,QAAQ,OAAA,EAAQ,CAC1B,KAAK,MAAM,CAAA,CACX,KAAA,CAAM,CAAC,KAAA,KAAU;AAChB,QAAA,OAAA,CAAQ,OAAO,SAAS,CAAA;AACxB,QAAA,MAAM,KAAA;AAAA,MACR,CAAC,CAAA;AACH,MAAA,OAAA,CAAQ,GAAA,CAAI,WAAW,IAAI,CAAA;AAAA,IAC7B;AACA,IAAA,OAAO,OAAA,CAAQ,IAAI,SAAS,CAAA;AAAA,EAC9B;AACA,EAAA,OAAOA,SAAAA;AACT;;;ACvBA,IAAM,aAAa,kCAAA,EAAmC;AAMtD,eAAe,SAAS,SAAA,EAAqC;AAC3D,EAAA,MAAM,WAAW,wBAAA,EAAyB;AAC1C,EAAA,OAAO,WAAW,QAAA,CAAS,SAAA,EAAW,UAAU,CAAA,GAAI,WAAW,SAAS,CAAA;AAC1E;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 CircuitJsonToFdmComponentBoxModule from \"./type-bundles/circuit-json-to-fdm-component-box\"\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\"\nimport type * as SchematicPlacementAnalysisModule from \"./type-bundles/@tscircuit/circuit-json-schematic-placement-analysis\"\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-fdm-component-box\",\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 \"@tscircuit/circuit-json-schematic-placement-analysis\",\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-fdm-component-box\": typeof CircuitJsonToFdmComponentBoxModule\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 \"@tscircuit/circuit-json-schematic-placement-analysis\": typeof SchematicPlacementAnalysisModule\n}\n\nexport type StripVersion<TSpecifier extends string> =\n TSpecifier extends SupportedModuleName\n ? TSpecifier\n : {\n [TName in SupportedModuleName]: TSpecifier extends `${TName}@${string}`\n ? TName\n : never\n }[SupportedModuleName]\n\nexport const getModuleName = (specifier: string): string => {\n // A scoped name's leading @ is part of the name, not a version separator.\n const versionSeparatorIndex = specifier.indexOf(\n \"@\",\n specifier.startsWith(\"@\") ? 1 : 0,\n )\n return versionSeparatorIndex === -1\n ? specifier\n : specifier.slice(0, versionSeparatorIndex)\n}\n","import { getModuleName, supportedModules } from \"./supported-modules\"\n\ndeclare global {\n interface Window {\n TSCIRCUIT_JSCDN_BASE_URL?: string\n }\n}\n\nconst defaultBaseUrl = \"https://jscdn.tscircuit.com\"\n\nfunction getConfiguredBaseUrl(): string | undefined {\n return typeof window !== \"undefined\"\n ? window.TSCIRCUIT_JSCDN_BASE_URL || undefined\n : undefined\n}\n\nconst supportedModuleSet = new Set<string>(supportedModules)\nconst browserEntrypoints = new Map<string, string>([\n [\"@tscircuit/circuit-json-schematic-placement-analysis\", \"dist/browser.js\"],\n])\n\nfunction assertSupportedModule(specifier: string) {\n if (!supportedModuleSet.has(getModuleName(specifier))) {\n throw new Error(`Unsupported module: ${specifier}`)\n }\n}\n\nexport const getImportUrl = (specifier: string): string => {\n assertSupportedModule(specifier)\n const moduleName = getModuleName(specifier)\n const version =\n specifier.length === moduleName.length\n ? \"latest\"\n : specifier.slice(moduleName.length + 1)\n const entrypoint = browserEntrypoints.get(moduleName) ?? \"+esm\"\n const configuredBaseUrl = getConfiguredBaseUrl()\n const baseUrl = (configuredBaseUrl ?? defaultBaseUrl).replace(/\\/+$/, \"\")\n const url = `${baseUrl}/${moduleName}/${version}/${entrypoint}`\n return configuredBaseUrl ? new URL(url, window.location.href).href : url\n}\n\nexport const getImportUrls = (specifier: string): string[] => {\n const url = getImportUrl(specifier)\n return getConfiguredBaseUrl() ? [url] : [url, `https://esm.run/${specifier}`]\n}\n","import { getDynamicModuleRegistry } from \"./dynamic-module-registry\"\nimport { getImportUrls } from \"./import-urls\"\n\n/** Internal dependency seam lets tests observe CDN attempts without a network. */\nexport function createDefaultDynamicImportResolver(\n importModule: (url: string) => Promise<unknown> = (url) =>\n import(/* @vite-ignore */ /* webpackIgnore: true */ url),\n) {\n return async (specifier: string): Promise<unknown> => {\n const modules = getDynamicModuleRegistry()\n if (Object.hasOwn(modules, specifier)) return modules[specifier]\n\n let lastError: unknown\n for (const importUrl of getImportUrls(specifier)) {\n try {\n const mod = await importModule(importUrl)\n // A versioned module never silently satisfies a different version or\n // an unversioned request for latest.\n modules[specifier] = mod\n return mod\n } catch (error) {\n lastError = error\n }\n }\n throw lastError\n }\n}\n","export type DynamicModuleResolver = (\n specifier: string,\n) => unknown | PromiseLike<unknown>\n\n/** A custom resolver can delegate to the default registry/CDN resolver. */\nexport type DynamicImportResolver = (\n specifier: string,\n defaultResolver: DynamicModuleResolver,\n) => unknown | PromiseLike<unknown>\n\ndeclare global {\n var tscircuitDynamicImportResolver: DynamicImportResolver | undefined\n}\n\nexport const getDynamicImportResolver = () =>\n globalThis.tscircuitDynamicImportResolver\n\n/** Configure before requesting modules, separately in each JavaScript realm. */\nexport function setDynamicImportResolver(\n resolver: DynamicImportResolver | undefined,\n): void {\n globalThis.tscircuitDynamicImportResolver = resolver\n}\n\n/**\n * Create an importer from exact specifier keys and lazy module loaders.\n * Missing keys reject unless a fallback is supplied; loader failures retry\n * through the same loader on the next request.\n */\nexport function createDynamicImporter<\n TLoaders extends Record<string, () => unknown | PromiseLike<unknown>>,\n>(loaders: TLoaders, fallback?: DynamicModuleResolver) {\n const entries = new Map(Object.entries(loaders))\n const pending = new Map<string, Promise<unknown>>()\n\n function importer<TSpecifier extends keyof TLoaders & string>(\n specifier: TSpecifier,\n ): Promise<Awaited<ReturnType<TLoaders[TSpecifier]>>>\n function importer(specifier: string): Promise<unknown>\n async function importer(specifier: string): Promise<unknown> {\n const loader = entries.get(specifier)\n if (!loader) {\n if (fallback) return fallback(specifier)\n throw new Error(`No bundled module registered for: ${specifier}`)\n }\n if (!pending.has(specifier)) {\n const load = Promise.resolve()\n .then(loader)\n .catch((error) => {\n pending.delete(specifier)\n throw error\n })\n pending.set(specifier, load)\n }\n return pending.get(specifier)!\n }\n return importer\n}\n","import { createDefaultDynamicImportResolver } from \"./create-importer\"\nimport { getDynamicImportResolver } from \"./dynamic-import-resolver\"\nimport {\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 setDynamicImportResolver,\n createDynamicImporter,\n} from \"./dynamic-import-resolver\"\nexport type {\n DynamicImportResolver,\n DynamicModuleResolver,\n} from \"./dynamic-import-resolver\"\nexport {\n getModuleName,\n supportedModules,\n} from \"./supported-modules\"\nexport type {\n StripVersion,\n SupportedModuleMap,\n SupportedModuleName,\n SupportedModuleSpecifier,\n} from \"./supported-modules\"\n\nexport { getImportUrl, getImportUrls } from \"./import-urls\"\n\nconst loadModule = createDefaultDynamicImportResolver()\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 const resolver = getDynamicImportResolver()\n return resolver ? resolver(specifier, loadModule) : loadModule(specifier)\n}\n\nexport default importer\n"]}
|
|
1
|
+
{"version":3,"sources":["../lib/dynamic-module-registry.ts","../lib/supported-modules.ts","../lib/import-urls.ts","../lib/create-importer.ts","../lib/dynamic-import-resolver.ts","../lib/index.ts"],"names":["importer"],"mappings":";AAYO,IAAM,2BAA2B,MAA6B;AACnE,EAAA,IAAI,WAAW,uBAAA,EAAyB;AACtC,IAAA,OAAO,UAAA,CA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AAA,CAAI,SAAS,CAAA,EAAG;AAC3B,MAAA,MAAM,IAAA,GAAO,QAAQ,OAAA,EAAQ,CAC1B,KAAK,MAAM,CAAA,CACX,KAAA,CAAM,CAAC,KAAA,KAAU;AAChB,QAAA,OAAA,CAAQ,OAAO,SAAS,CAAA;AACxB,QAAA,MAAM,KAAA;AAAA,MACR,CAAC,CAAA;AACH,MAAA,OAAA,CAAQ,GAAA,CAAI,WAAW,IAAI,CAAA;AAAA,IAC7B;AACA,IAAA,OAAO,OAAA,CAAQ,IAAI,SAAS,CAAA;AAAA,EAC9B;AACA,EAAA,OAAOA,SAAAA;AACT;;;ACvBA,IAAM,aAAa,kCAAA,EAAmC;AAMtD,eAAe,SAAS,SAAA,EAAqC;AAC3D,EAAA,MAAM,WAAW,wBAAA,EAAyB;AAC1C,EAAA,OAAO,WAAW,QAAA,CAAS,SAAA,EAAW,UAAU,CAAA,GAAI,WAAW,SAAS,CAAA;AAC1E;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 JscadToStepModule from \"./type-bundles/jscad-to-step\"\nimport type * as JscadToParasolidModule from \"./type-bundles/jscad-to-parasolid\"\nimport 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 CircuitJsonToFdmComponentBoxModule from \"./type-bundles/circuit-json-to-fdm-component-box\"\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\"\nimport type * as SchematicPlacementAnalysisModule from \"./type-bundles/@tscircuit/circuit-json-schematic-placement-analysis\"\n\nexport const supportedModules = [\n \"jscad-to-step\",\n \"jscad-to-parasolid\",\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-fdm-component-box\",\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 \"@tscircuit/circuit-json-schematic-placement-analysis\",\n] as const\n\nexport type SupportedModuleName = (typeof supportedModules)[number]\nexport type SupportedModuleSpecifier =\n | SupportedModuleName\n | `${SupportedModuleName}@${string}`\n\nexport interface SupportedModuleMap {\n \"jscad-to-step\": typeof JscadToStepModule\n \"jscad-to-parasolid\": typeof JscadToParasolidModule\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-fdm-component-box\": typeof CircuitJsonToFdmComponentBoxModule\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 \"@tscircuit/circuit-json-schematic-placement-analysis\": typeof SchematicPlacementAnalysisModule\n}\n\nexport type StripVersion<TSpecifier extends string> =\n TSpecifier extends SupportedModuleName\n ? TSpecifier\n : {\n [TName in SupportedModuleName]: TSpecifier extends `${TName}@${string}`\n ? TName\n : never\n }[SupportedModuleName]\n\nexport const getModuleName = (specifier: string): string => {\n // A scoped name's leading @ is part of the name, not a version separator.\n const versionSeparatorIndex = specifier.indexOf(\n \"@\",\n specifier.startsWith(\"@\") ? 1 : 0,\n )\n return versionSeparatorIndex === -1\n ? specifier\n : specifier.slice(0, versionSeparatorIndex)\n}\n","import { getModuleName, supportedModules } from \"./supported-modules\"\n\ndeclare global {\n interface Window {\n TSCIRCUIT_JSCDN_BASE_URL?: string\n }\n}\n\nconst defaultBaseUrl = \"https://jscdn.tscircuit.com\"\n\nfunction getConfiguredBaseUrl(): string | undefined {\n return typeof window !== \"undefined\"\n ? window.TSCIRCUIT_JSCDN_BASE_URL || undefined\n : undefined\n}\n\nconst supportedModuleSet = new Set<string>(supportedModules)\nconst browserEntrypoints = new Map<string, string>([\n [\"@tscircuit/circuit-json-schematic-placement-analysis\", \"dist/browser.js\"],\n])\n\nfunction assertSupportedModule(specifier: string) {\n if (!supportedModuleSet.has(getModuleName(specifier))) {\n throw new Error(`Unsupported module: ${specifier}`)\n }\n}\n\nexport const getImportUrl = (specifier: string): string => {\n assertSupportedModule(specifier)\n const moduleName = getModuleName(specifier)\n const version =\n specifier.length === moduleName.length\n ? \"latest\"\n : specifier.slice(moduleName.length + 1)\n const entrypoint = browserEntrypoints.get(moduleName) ?? \"+esm\"\n const configuredBaseUrl = getConfiguredBaseUrl()\n const baseUrl = (configuredBaseUrl ?? defaultBaseUrl).replace(/\\/+$/, \"\")\n const url = `${baseUrl}/${moduleName}/${version}/${entrypoint}`\n return configuredBaseUrl ? new URL(url, window.location.href).href : url\n}\n\nexport const getImportUrls = (specifier: string): string[] => {\n const url = getImportUrl(specifier)\n return getConfiguredBaseUrl() ? [url] : [url, `https://esm.run/${specifier}`]\n}\n","import { getDynamicModuleRegistry } from \"./dynamic-module-registry\"\nimport { getImportUrls } from \"./import-urls\"\n\n/** Internal dependency seam lets tests observe CDN attempts without a network. */\nexport function createDefaultDynamicImportResolver(\n importModule: (url: string) => Promise<unknown> = (url) =>\n import(/* @vite-ignore */ /* webpackIgnore: true */ url),\n) {\n return async (specifier: string): Promise<unknown> => {\n const modules = getDynamicModuleRegistry()\n if (Object.hasOwn(modules, specifier)) return modules[specifier]\n\n let lastError: unknown\n for (const importUrl of getImportUrls(specifier)) {\n try {\n const mod = await importModule(importUrl)\n // A versioned module never silently satisfies a different version or\n // an unversioned request for latest.\n modules[specifier] = mod\n return mod\n } catch (error) {\n lastError = error\n }\n }\n throw lastError\n }\n}\n","export type DynamicModuleResolver = (\n specifier: string,\n) => unknown | PromiseLike<unknown>\n\n/** A custom resolver can delegate to the default registry/CDN resolver. */\nexport type DynamicImportResolver = (\n specifier: string,\n defaultResolver: DynamicModuleResolver,\n) => unknown | PromiseLike<unknown>\n\ndeclare global {\n var tscircuitDynamicImportResolver: DynamicImportResolver | undefined\n}\n\nexport const getDynamicImportResolver = () =>\n globalThis.tscircuitDynamicImportResolver\n\n/** Configure before requesting modules, separately in each JavaScript realm. */\nexport function setDynamicImportResolver(\n resolver: DynamicImportResolver | undefined,\n): void {\n globalThis.tscircuitDynamicImportResolver = resolver\n}\n\n/**\n * Create an importer from exact specifier keys and lazy module loaders.\n * Missing keys reject unless a fallback is supplied; loader failures retry\n * through the same loader on the next request.\n */\nexport function createDynamicImporter<\n TLoaders extends Record<string, () => unknown | PromiseLike<unknown>>,\n>(loaders: TLoaders, fallback?: DynamicModuleResolver) {\n const entries = new Map(Object.entries(loaders))\n const pending = new Map<string, Promise<unknown>>()\n\n function importer<TSpecifier extends keyof TLoaders & string>(\n specifier: TSpecifier,\n ): Promise<Awaited<ReturnType<TLoaders[TSpecifier]>>>\n function importer(specifier: string): Promise<unknown>\n async function importer(specifier: string): Promise<unknown> {\n const loader = entries.get(specifier)\n if (!loader) {\n if (fallback) return fallback(specifier)\n throw new Error(`No bundled module registered for: ${specifier}`)\n }\n if (!pending.has(specifier)) {\n const load = Promise.resolve()\n .then(loader)\n .catch((error) => {\n pending.delete(specifier)\n throw error\n })\n pending.set(specifier, load)\n }\n return pending.get(specifier)!\n }\n return importer\n}\n","import { createDefaultDynamicImportResolver } from \"./create-importer\"\nimport { getDynamicImportResolver } from \"./dynamic-import-resolver\"\nimport {\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 setDynamicImportResolver,\n createDynamicImporter,\n} from \"./dynamic-import-resolver\"\nexport type {\n DynamicImportResolver,\n DynamicModuleResolver,\n} from \"./dynamic-import-resolver\"\nexport {\n getModuleName,\n supportedModules,\n} from \"./supported-modules\"\nexport type {\n StripVersion,\n SupportedModuleMap,\n SupportedModuleName,\n SupportedModuleSpecifier,\n} from \"./supported-modules\"\n\nexport { getImportUrl, getImportUrls } from \"./import-urls\"\n\nconst loadModule = createDefaultDynamicImportResolver()\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 const resolver = getDynamicImportResolver()\n return resolver ? resolver(specifier, loadModule) : loadModule(specifier)\n}\n\nexport default importer\n"]}
|
package/lib/supported-modules.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type * as JscadToStepModule from "./type-bundles/jscad-to-step"
|
|
2
|
+
import type * as JscadToParasolidModule from "./type-bundles/jscad-to-parasolid"
|
|
1
3
|
import type * as CircuitJsonTo3dPngModule from "./type-bundles/circuit-json-to-3d-png"
|
|
2
4
|
import type * as CircuitJsonToBomCsvModule from "./type-bundles/circuit-json-to-bom-csv"
|
|
3
5
|
import type * as CircuitJsonToBpcModule from "./type-bundles/circuit-json-to-bpc"
|
|
@@ -19,6 +21,8 @@ import type * as KicadToCircuitJsonModule from "./type-bundles/kicad-to-circuit-
|
|
|
19
21
|
import type * as SchematicPlacementAnalysisModule from "./type-bundles/@tscircuit/circuit-json-schematic-placement-analysis"
|
|
20
22
|
|
|
21
23
|
export const supportedModules = [
|
|
24
|
+
"jscad-to-step",
|
|
25
|
+
"jscad-to-parasolid",
|
|
22
26
|
"circuit-json-to-3d-png",
|
|
23
27
|
"circuit-json-to-bom-csv",
|
|
24
28
|
"circuit-json-to-bpc",
|
|
@@ -46,6 +50,8 @@ export type SupportedModuleSpecifier =
|
|
|
46
50
|
| `${SupportedModuleName}@${string}`
|
|
47
51
|
|
|
48
52
|
export interface SupportedModuleMap {
|
|
53
|
+
"jscad-to-step": typeof JscadToStepModule
|
|
54
|
+
"jscad-to-parasolid": typeof JscadToParasolidModule
|
|
49
55
|
"circuit-json-to-3d-png": typeof CircuitJsonTo3dPngModule
|
|
50
56
|
"circuit-json-to-bom-csv": typeof CircuitJsonToBomCsvModule
|
|
51
57
|
"circuit-json-to-bpc": typeof CircuitJsonToBpcModule
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import { CircuitJson } from 'circuit-json';
|
|
2
|
-
import { CircuitJsonUtilObjects, cju } from '@tscircuit/circuit-json-util';
|
|
1
|
+
import { CircuitJson, Point } from 'circuit-json';
|
|
3
2
|
import { KicadSch, KicadPcb, SchematicSymbol } from 'kicadts';
|
|
3
|
+
import { CircuitJsonUtilObjects, cju } from '@tscircuit/circuit-json-util';
|
|
4
4
|
import { Matrix } from 'transformation-matrix';
|
|
5
5
|
|
|
6
6
|
type PaperSize = "A0" | "A1" | "A2" | "A3" | "A4" | "A5";
|
|
7
7
|
interface PaperDimensions {
|
|
8
|
+
/** Effective page width after orientation, in millimeters. */
|
|
8
9
|
width: number;
|
|
10
|
+
/** Effective page height after orientation, in millimeters. */
|
|
9
11
|
height: number;
|
|
10
|
-
name: PaperSize;
|
|
12
|
+
name: PaperSize | string;
|
|
13
|
+
/** Raw custom dimensions written to KiCad's `(paper width height)` form. */
|
|
14
|
+
customSize?: {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
};
|
|
18
|
+
/** Whether KiCad writes the page with its `portrait` flag. */
|
|
19
|
+
isPortrait?: boolean;
|
|
11
20
|
}
|
|
12
21
|
|
|
13
22
|
type SchematicPortId = string;
|
|
@@ -57,6 +66,25 @@ interface ConverterContext {
|
|
|
57
66
|
c2kMatPcb?: Matrix;
|
|
58
67
|
/** Selected paper size for schematic */
|
|
59
68
|
schematicPaperSize?: PaperDimensions;
|
|
69
|
+
/**
|
|
70
|
+
* UUID written as this file's own top-level `(uuid ...)`. When set,
|
|
71
|
+
* InitializeSchematicStage uses it instead of generating a random one so the
|
|
72
|
+
* root uuid can be shared across the root file, child files, sheet nodes and
|
|
73
|
+
* the `.kicad_pro`.
|
|
74
|
+
*/
|
|
75
|
+
schematicFileUuid?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Prefix used for every symbol `(instances ... (path ...))` in this file.
|
|
78
|
+
* Root/legacy files use `/<rootUuid>`; child sheet files use
|
|
79
|
+
* `/<rootUuid>/<sheetNodeUuid>` (KiCad requires the root uuid first).
|
|
80
|
+
*/
|
|
81
|
+
symbolInstancePathPrefix?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Lib id for each schematic component whose pin numbering differs from an
|
|
84
|
+
* earlier instance of the same library symbol, keyed by
|
|
85
|
+
* schematic_component_id. Set by AddLibrarySymbolsStage.
|
|
86
|
+
*/
|
|
87
|
+
schematicComponentLibraryIds?: Map<string, string>;
|
|
60
88
|
pinPositions?: Map<SchematicPortId, {
|
|
61
89
|
x: number;
|
|
62
90
|
y: number;
|
|
@@ -68,6 +96,7 @@ interface ConverterContext {
|
|
|
68
96
|
}>;
|
|
69
97
|
pcbNetMap?: Map<string, PcbNetInfo>;
|
|
70
98
|
numLayers?: number;
|
|
99
|
+
edgeCutsWidth?: number;
|
|
71
100
|
/** Project name used as the .3dshapes folder for user-provided 3D models */
|
|
72
101
|
projectName?: string;
|
|
73
102
|
/** CDN URLs of 3D models needed for this PCB (collected during footprint stage) */
|
|
@@ -93,20 +122,125 @@ declare abstract class ConverterStage<Input, Output> {
|
|
|
93
122
|
getOutput(): Output;
|
|
94
123
|
}
|
|
95
124
|
|
|
125
|
+
/** Fields common to the root page and every child schematic file. */
|
|
126
|
+
interface SchematicSheetPlanEntryBase {
|
|
127
|
+
/** Value written to the KiCad `(property "Sheetname" ...)` */
|
|
128
|
+
sheetName: string;
|
|
129
|
+
/** Sanitized, unique file stem (no extension) used to derive `filename` */
|
|
130
|
+
fileBaseName: string;
|
|
131
|
+
/** File name for this sheet's `.kicad_sch` (root filename is overridden by the caller) */
|
|
132
|
+
filename: string;
|
|
133
|
+
/** KiCad page number ("1" for root, "2".. for children) */
|
|
134
|
+
pageNumber: string;
|
|
135
|
+
/** UUID written as this file's own top-level `(uuid ...)` */
|
|
136
|
+
fileUuid: string;
|
|
137
|
+
}
|
|
138
|
+
/** The top-level root schematic (page "1"); it holds the `(sheet)` nodes. */
|
|
139
|
+
interface RootSchematicSheetPlanEntry extends SchematicSheetPlanEntryBase {
|
|
140
|
+
schematicSheetId: null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* One circuit-json `schematic_sheet`, emitted as a `(sheet)` node on the root
|
|
144
|
+
* page plus its own child `.kicad_sch` file.
|
|
145
|
+
*/
|
|
146
|
+
interface ChildSchematicSheetPlanEntry extends SchematicSheetPlanEntryBase {
|
|
147
|
+
/** circuit-json schematic_sheet_id this file represents */
|
|
148
|
+
schematicSheetId: string;
|
|
149
|
+
/**
|
|
150
|
+
* UUID of the `(sheet)` node placed on the root page. It is the second segment
|
|
151
|
+
* of the symbol instance path for symbols on this sheet (`/<rootUuid>/<sheetNodeUuid>`).
|
|
152
|
+
*/
|
|
153
|
+
sheetNodeUuid: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Blueprint of the KiCad schematic files to emit for one circuit-json input:
|
|
157
|
+
* the root `.kicad_sch` plus one child `.kicad_sch` per `schematic_sheet`, each
|
|
158
|
+
* with the UUIDs, filename, and page number KiCad needs. Computed up front (with
|
|
159
|
+
* no file content) so the schematic converter and the `.kicad_pro` converter
|
|
160
|
+
* agree on the same identifiers.
|
|
161
|
+
*/
|
|
162
|
+
interface SchematicSheetPlan {
|
|
163
|
+
/**
|
|
164
|
+
* UUID of the root schematic file. Every symbol instance path begins with
|
|
165
|
+
* this uuid (KiCad requirement), so it is shared by the root file, the child
|
|
166
|
+
* files, the `(sheet)` nodes, and the `.kicad_pro` sheets list.
|
|
167
|
+
*/
|
|
168
|
+
rootUuid: string;
|
|
169
|
+
root: RootSchematicSheetPlanEntry;
|
|
170
|
+
children: ChildSchematicSheetPlanEntry[];
|
|
171
|
+
/** True when the design has `schematic_sheet`s and must be emitted as a hierarchy */
|
|
172
|
+
isHierarchical: boolean;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface KicadSchematicTitleBlockMetadata {
|
|
176
|
+
company?: string;
|
|
177
|
+
comments?: Array<{
|
|
178
|
+
index: number;
|
|
179
|
+
text: string;
|
|
180
|
+
}>;
|
|
181
|
+
date?: string;
|
|
182
|
+
revision?: string;
|
|
183
|
+
title?: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
interface KicadSchFile {
|
|
187
|
+
filename: string;
|
|
188
|
+
content: string;
|
|
189
|
+
}
|
|
190
|
+
interface KicadSchFileOutputOptions {
|
|
191
|
+
schematicFilename: string;
|
|
192
|
+
}
|
|
193
|
+
interface CircuitJsonToKicadSchConverterOptions {
|
|
194
|
+
paperSize?: PaperDimensions;
|
|
195
|
+
schematicSheets?: KicadSchematicSheetOptions[];
|
|
196
|
+
titleBlock?: KicadSchematicTitleBlockMetadata;
|
|
197
|
+
}
|
|
198
|
+
interface KicadSchematicSheetOptions {
|
|
199
|
+
/** Position of Circuit JSON (0, 0) on the KiCad page, in millimeters. */
|
|
200
|
+
circuitOrigin: Point;
|
|
201
|
+
/** Geometry of this child sheet's hierarchy node on the root page. */
|
|
202
|
+
hierarchyNode?: {
|
|
203
|
+
position: Point;
|
|
204
|
+
size: {
|
|
205
|
+
height: number;
|
|
206
|
+
width: number;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
/** Omit for a standalone schematic or the root sheet. */
|
|
210
|
+
schematicSheetId?: string;
|
|
211
|
+
}
|
|
96
212
|
declare class CircuitJsonToKicadSchConverter {
|
|
97
213
|
ctx: ConverterContext;
|
|
98
214
|
pipeline: ConverterStage<CircuitJson, KicadSch>[];
|
|
99
215
|
currentStageIndex: number;
|
|
100
216
|
finished: boolean;
|
|
217
|
+
circuitJson: CircuitJson;
|
|
218
|
+
schematicSheetPlan: SchematicSheetPlan;
|
|
219
|
+
private files;
|
|
220
|
+
private built;
|
|
221
|
+
private readonly options;
|
|
101
222
|
get currentStage(): ConverterStage<CircuitJson, KicadSch> | undefined;
|
|
102
|
-
constructor(circuitJson: CircuitJson);
|
|
223
|
+
constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadSchConverterOptions);
|
|
103
224
|
step(): void;
|
|
104
225
|
runUntilFinished(): void;
|
|
105
226
|
getOutput(): KicadSch;
|
|
106
227
|
/**
|
|
107
|
-
* Get the
|
|
228
|
+
* Get the (root) schematic as a string.
|
|
108
229
|
*/
|
|
109
230
|
getOutputString(): string;
|
|
231
|
+
/**
|
|
232
|
+
* Returns every KiCad schematic file produced by this converter.
|
|
233
|
+
*
|
|
234
|
+
* For a design with no `schematic_sheet` elements this is a single root file.
|
|
235
|
+
* For a hierarchical design it is the root file (named by
|
|
236
|
+
* `options.schematicFilename`) followed by one child `.kicad_sch` per sheet,
|
|
237
|
+
* each named after its sheet and referenced by the root via `Sheetfile`.
|
|
238
|
+
*/
|
|
239
|
+
getOutputFiles(options: KicadSchFileOutputOptions): KicadSchFile[];
|
|
240
|
+
/** Builds the root + child `.kicad_sch` files for a hierarchical design. */
|
|
241
|
+
private buildAll;
|
|
242
|
+
/** Builds one child/root `.kicad_sch` for a sheet, run to completion. */
|
|
243
|
+
private buildSheetFile;
|
|
110
244
|
}
|
|
111
245
|
|
|
112
246
|
interface CircuitJsonToKicadPcbOptions {
|
|
@@ -121,6 +255,11 @@ interface CircuitJsonToKicadPcbOptions {
|
|
|
121
255
|
* e.g. "index" → "3dmodels/index.3dshapes/{filename}"
|
|
122
256
|
*/
|
|
123
257
|
projectName?: string;
|
|
258
|
+
/**
|
|
259
|
+
* Stroke width in millimetres for generated Edge.Cuts graphics.
|
|
260
|
+
* Defaults to 0.1 mm when the source format does not provide one.
|
|
261
|
+
*/
|
|
262
|
+
edgeCutsWidth?: number;
|
|
124
263
|
}
|
|
125
264
|
declare class CircuitJsonToKicadPcbConverter {
|
|
126
265
|
ctx: ConverterContext;
|
|
@@ -147,6 +286,12 @@ interface CircuitJsonToKicadProOptions {
|
|
|
147
286
|
projectName?: string;
|
|
148
287
|
schematicFilename?: string;
|
|
149
288
|
pcbFilename?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Sheet plan produced by CircuitJsonToKicadSchConverter. When provided, the
|
|
291
|
+
* project's `sheets` list uses the same root/sheet-node UUIDs so the
|
|
292
|
+
* `.kicad_pro` stays consistent with the generated `.kicad_sch` hierarchy.
|
|
293
|
+
*/
|
|
294
|
+
schematicSheetPlan?: SchematicSheetPlan;
|
|
150
295
|
}
|
|
151
296
|
interface KicadProNetClass {
|
|
152
297
|
bus_width?: number;
|
|
@@ -261,6 +406,24 @@ declare class CircuitJsonToKicadProConverter {
|
|
|
261
406
|
getOutputString(): string;
|
|
262
407
|
}
|
|
263
408
|
|
|
409
|
+
interface CircuitJsonToKicadModOptions {
|
|
410
|
+
libraryName?: string;
|
|
411
|
+
footprintLibraryName?: string;
|
|
412
|
+
footprintName?: string;
|
|
413
|
+
}
|
|
414
|
+
declare class CircuitJsonToKicadModConverter {
|
|
415
|
+
private readonly libraryConverter;
|
|
416
|
+
private readonly footprintName?;
|
|
417
|
+
constructor(circuitJson: CircuitJson, options?: CircuitJsonToKicadModOptions);
|
|
418
|
+
get finished(): boolean;
|
|
419
|
+
get currentStage(): ConverterStage<CircuitJson, KicadLibraryOutput> | undefined;
|
|
420
|
+
step(): void;
|
|
421
|
+
runUntilFinished(): void;
|
|
422
|
+
getOutput(): FootprintEntry;
|
|
423
|
+
getOutputString(): string;
|
|
424
|
+
getModel3dSourcePaths(): string[];
|
|
425
|
+
}
|
|
426
|
+
|
|
264
427
|
type ModelFetchResponse = {
|
|
265
428
|
ok: boolean;
|
|
266
429
|
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
@@ -389,4 +552,4 @@ declare class KicadLibraryConverter {
|
|
|
389
552
|
getOutput(): KicadLibraryConverterOutput;
|
|
390
553
|
}
|
|
391
554
|
|
|
392
|
-
export { CircuitJsonToKicadLibraryConverter, CircuitJsonToKicadPcbConverter, CircuitJsonToKicadProConverter, CircuitJsonToKicadSchConverter, type FootprintEntry, type Kicad3dModelLoadError, KicadLibraryConverter, type KicadLibraryConverterOptions, type KicadLibraryConverterOutput, type KicadLibraryOutput, type LoadedKicad3dModelFile, type ResolveAndLoadKicad3dModelFilesOptions, type SymbolEntry, resolveAndLoadKicad3dModelFiles };
|
|
555
|
+
export { CircuitJsonToKicadLibraryConverter, CircuitJsonToKicadModConverter, CircuitJsonToKicadPcbConverter, type CircuitJsonToKicadPcbOptions, CircuitJsonToKicadProConverter, CircuitJsonToKicadSchConverter, type CircuitJsonToKicadSchConverterOptions, type FootprintEntry, type Kicad3dModelLoadError, KicadLibraryConverter, type KicadLibraryConverterOptions, type KicadLibraryConverterOutput, type KicadLibraryOutput, type KicadSchFile, type KicadSchFileOutputOptions, type KicadSchematicSheetOptions, type LoadedKicad3dModelFile, type ResolveAndLoadKicad3dModelFilesOptions, type SymbolEntry, resolveAndLoadKicad3dModelFiles };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { JscadOperation } from 'jscad-planner';
|
|
2
|
+
|
|
3
|
+
type Point3 = readonly [number, number, number];
|
|
4
|
+
type ParasolidColorInput = string | readonly number[];
|
|
5
|
+
type ParasolidRgbColor = readonly [number, number, number];
|
|
6
|
+
/** Also accepts JSON-exported JSCAD vertices and typed coordinate arrays. */
|
|
7
|
+
type Geom3Vertex = ArrayLike<number> | {
|
|
8
|
+
readonly pos: ArrayLike<number>;
|
|
9
|
+
} | {
|
|
10
|
+
readonly position: ArrayLike<number>;
|
|
11
|
+
};
|
|
12
|
+
interface Geom3Like {
|
|
13
|
+
readonly polygons: readonly {
|
|
14
|
+
readonly vertices: readonly Geom3Vertex[];
|
|
15
|
+
readonly color?: ParasolidColorInput;
|
|
16
|
+
}[];
|
|
17
|
+
/** JSCAD's column-major, lazily applied affine matrix. */
|
|
18
|
+
readonly transforms?: ArrayLike<number>;
|
|
19
|
+
readonly color?: ParasolidColorInput;
|
|
20
|
+
}
|
|
21
|
+
type JscadGeometryInput = JscadOperation | Geom3Like;
|
|
22
|
+
/** The vanilla renderer can use either jscad-planner or @jscad/modeling. */
|
|
23
|
+
interface RenderedModel {
|
|
24
|
+
readonly geometries: readonly {
|
|
25
|
+
readonly geom: JscadGeometryInput;
|
|
26
|
+
readonly color?: ParasolidColorInput;
|
|
27
|
+
readonly name?: string;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
30
|
+
type JscadToParasolidInput = JscadGeometryInput | readonly JscadGeometryInput[] | RenderedModel;
|
|
31
|
+
interface JscadToParasolidOptions {
|
|
32
|
+
/** Merge adjacent coplanar CAD faces. Default true; curves remain faceted. */
|
|
33
|
+
readonly mergeCoplanarFaces?: boolean;
|
|
34
|
+
/** Input length unit. X_T coordinates are always written in metres. */
|
|
35
|
+
readonly units?: "mm" | "m";
|
|
36
|
+
/** Reserved for future X_T name attributes; not transmitted yet. */
|
|
37
|
+
readonly name?: string;
|
|
38
|
+
}
|
|
39
|
+
interface ParasolidBodyInput {
|
|
40
|
+
readonly polygons: readonly (readonly Point3[])[];
|
|
41
|
+
readonly name?: string;
|
|
42
|
+
readonly color?: ParasolidRgbColor;
|
|
43
|
+
readonly faceColors?: readonly (ParasolidRgbColor | undefined)[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolve JSCAD geometry into world-coordinate polygon bodies, in input units.
|
|
48
|
+
* No caller-owned geometry or matrices are mutated. RGB colors are preserved;
|
|
49
|
+
* alpha is not represented by the supported native color attributes.
|
|
50
|
+
* The converter validates planarity and closed-manifold topology before serialization.
|
|
51
|
+
*/
|
|
52
|
+
declare function jscadToParasolidBodies(input: JscadToParasolidInput, options?: JscadToParasolidOptions): ParasolidBodyInput[];
|
|
53
|
+
/**
|
|
54
|
+
* Convert JSCAD/modelprinter geometry to native Parasolid text (.x_t).
|
|
55
|
+
* Curves remain JSCAD's planar facets; this does not reconstruct analytic curves.
|
|
56
|
+
*/
|
|
57
|
+
declare function jscadToParasolid(input: JscadToParasolidInput, options?: JscadToParasolidOptions): string;
|
|
58
|
+
|
|
59
|
+
export { type Geom3Like, type Geom3Vertex, type JscadGeometryInput, type JscadToParasolidInput, type JscadToParasolidOptions, type ParasolidBodyInput, type ParasolidColorInput, type ParasolidRgbColor, type Point3, type RenderedModel, jscadToParasolid, jscadToParasolidBodies };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JscadOperation } from 'jscad-planner';
|
|
2
|
+
|
|
3
|
+
type StepColorInput = number[] | string;
|
|
4
|
+
|
|
5
|
+
interface Geom3Like {
|
|
6
|
+
polygons: Array<{
|
|
7
|
+
vertices: any[];
|
|
8
|
+
}>;
|
|
9
|
+
transforms?: number[];
|
|
10
|
+
color?: StepColorInput;
|
|
11
|
+
}
|
|
12
|
+
interface RenderedModel {
|
|
13
|
+
geometries: Array<{
|
|
14
|
+
geom: Geom3Like;
|
|
15
|
+
color?: StepColorInput;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
interface JscadToStepOptions {
|
|
19
|
+
/** Merge adjacent coplanar polygons into faces with inner bounds for holes. Default: true. */
|
|
20
|
+
mergeCoplanarFaces?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare function jscadToStep(operation: JscadOperation | RenderedModel, options?: JscadToStepOptions): string;
|
|
23
|
+
|
|
24
|
+
export { type JscadToStepOptions, jscadToStep };
|
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.20",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tscircuit/internal-dynamic-import"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"circuit-json-to-fdm-component-box": "0.0.2",
|
|
46
46
|
"circuit-json-to-gerber": "0.0.84",
|
|
47
47
|
"circuit-json-to-gltf": "0.0.106",
|
|
48
|
-
"circuit-json-to-kicad": "0.0.
|
|
48
|
+
"circuit-json-to-kicad": "0.0.241",
|
|
49
49
|
"circuit-json-to-lbrn": "0.0.69",
|
|
50
50
|
"circuit-json-to-pnp-csv": "0.0.8",
|
|
51
51
|
"circuit-json-to-readable-netlist": "0.0.15",
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
"kicad-to-circuit-json": "0.0.98",
|
|
59
59
|
"tsup": "8.5.1",
|
|
60
60
|
"typescript": "5.9.3",
|
|
61
|
-
"@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.46.tgz"
|
|
61
|
+
"@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.46.tgz",
|
|
62
|
+
"jscad-to-step": "0.0.11",
|
|
63
|
+
"jscad-to-parasolid": "0.0.4"
|
|
62
64
|
}
|
|
63
65
|
}
|