@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,44 @@
1
+ import { AnyCircuitElement, PCBTrace, PCBPort } from 'circuit-json';
2
+
3
+ type NodeId = string;
4
+ declare function findConnectedNetworks(connections: Array<NodeId[]>): Record<string, string[]>;
5
+
6
+ declare class ConnectivityMap {
7
+ netMap: Record<string, string[]>;
8
+ idToNetMap: Record<string, string>;
9
+ constructor(netMap: Record<string, string[]>);
10
+ addConnections(connections: string[][]): void;
11
+ getIdsConnectedToNet(netId: string): string[];
12
+ getNetConnectedToId(id: string): string | undefined;
13
+ areIdsConnected(id1: string, id2: string): boolean;
14
+ areAllIdsConnected(ids: string[]): boolean;
15
+ }
16
+
17
+ declare const getSourcePortConnectivityMapFromCircuitJson: (circuitJson: AnyCircuitElement[]) => ConnectivityMap;
18
+
19
+ declare const getFullConnectivityMapFromCircuitJson: (circuitJson: AnyCircuitElement[]) => ConnectivityMap;
20
+
21
+ /**
22
+ * A PCB Connectivity Map is a connectivity map that has analyzed what traces and ports are actually connected on the
23
+ * PCB.
24
+ *
25
+ * This is useful for determining how to route a trace on the PCB. For example, you may want to determine where the
26
+ * nearest connected net point is to connect an unrouted pin.
27
+ */
28
+ declare class PcbConnectivityMap {
29
+ circuitJson: AnyCircuitElement[];
30
+ traceIdToElm: Map<string, PCBTrace>;
31
+ portIdToElm: Map<string, PCBPort>;
32
+ connMap: ConnectivityMap;
33
+ constructor(circuitJson?: AnyCircuitElement[]);
34
+ private _buildPortMap;
35
+ private _buildTraceMap;
36
+ private _buildTraceConnectivityMap;
37
+ addTrace(trace: PCBTrace): void;
38
+ _arePcbTracesConnected(trace1: PCBTrace, trace2: PCBTrace): boolean;
39
+ areTracesConnected(traceId1: string, traceId2: string): boolean;
40
+ getAllTracesConnectedToTrace(traceId: string): PCBTrace[];
41
+ getAllTracesConnectedToPort(portId: string): PCBTrace[];
42
+ }
43
+
44
+ export { ConnectivityMap, PcbConnectivityMap, findConnectedNetworks, getFullConnectivityMapFromCircuitJson, getSourcePortConnectivityMapFromCircuitJson };
@@ -0,0 +1,160 @@
1
+ import { CircuitJson } from 'circuit-json';
2
+ export { CircuitJson } from 'circuit-json';
3
+ import { RenderOptionsInput } from 'poppygl';
4
+
5
+ interface FdmComponentBoxOptions {
6
+ /** Number of compartments per row. Defaults to a near-square layout. */
7
+ columns?: number;
8
+ /** Clear X dimension of each compartment, in millimetres. */
9
+ compartmentWidth?: number;
10
+ /** Clear Y dimension of each compartment, in millimetres. */
11
+ compartmentDepth?: number;
12
+ /** Clear Z depth from the floor to the rim, in millimetres. */
13
+ compartmentHeight?: number;
14
+ /** Thickness of outside and divider walls, in millimetres. */
15
+ wallThickness?: number;
16
+ /** Thickness beneath each compartment, in millimetres. */
17
+ floorThickness?: number;
18
+ /** Solid Y-depth behind each compartment that carries its label. */
19
+ labelBandDepth?: number;
20
+ /** Height of the raised label above the box rim, in millimetres. */
21
+ labelThickness?: number;
22
+ /** Empty margin around each label, in millimetres. */
23
+ labelPadding?: number;
24
+ /** Smallest allowed text stroke, in millimetres. */
25
+ minimumLabelStrokeWidth?: number;
26
+ /** Include source components that do not have a pcb_component record. */
27
+ includeUnplacedComponents?: boolean;
28
+ /** Include test points, which are excluded from assembly compartments by default. */
29
+ includeTestPoints?: boolean;
30
+ /** Group confidently identical BOM parts into one compartment. Defaults to true. */
31
+ groupByComponent?: boolean;
32
+ /** Core 3MF display color for the box material, as #RRGGBB or #RRGGBBAA. */
33
+ boxColor?: string;
34
+ /** Core 3MF display color for the label material, as #RRGGBB or #RRGGBBAA. */
35
+ labelColor?: string;
36
+ /** Title stored in the 3MF model metadata. */
37
+ title?: string;
38
+ }
39
+ interface ComponentGroup {
40
+ /** Stable description of the BOM identity used for this group. */
41
+ componentKey: string;
42
+ /** Every refdes whose physical parts belong in this compartment. */
43
+ referenceDesignators: string[];
44
+ quantity: number;
45
+ componentType?: string;
46
+ manufacturerPartNumber?: string;
47
+ supplierPartNumbers?: Record<string, string[]>;
48
+ footprint?: string;
49
+ }
50
+ interface FdmComponentBoxDimensions {
51
+ /** Overall X dimension, in millimetres. */
52
+ width: number;
53
+ /** Overall Y dimension, in millimetres. */
54
+ depth: number;
55
+ /** Overall Z dimension excluding raised text, in millimetres. */
56
+ height: number;
57
+ columns: number;
58
+ rows: number;
59
+ }
60
+ interface CompartmentPlacement {
61
+ /** Primary refdes, retained for compatibility with one-component compartments. */
62
+ refdes: string;
63
+ /** All refdes values assigned to this compartment. */
64
+ referenceDesignators: string[];
65
+ /** Text physically embossed above the compartment. */
66
+ label: string;
67
+ componentKey: string;
68
+ quantity: number;
69
+ row: number;
70
+ column: number;
71
+ /** Cavity center in the box coordinate frame, in millimetres. */
72
+ center: {
73
+ x: number;
74
+ y: number;
75
+ };
76
+ /** Center of the solid label band behind this cavity, in millimetres. */
77
+ labelCenter: {
78
+ x: number;
79
+ y: number;
80
+ };
81
+ width: number;
82
+ depth: number;
83
+ }
84
+ interface FdmComponentBoxMeshStats {
85
+ boxTriangles: number;
86
+ labelTriangles: number;
87
+ totalTriangles: number;
88
+ }
89
+ interface FdmComponentBoxResult {
90
+ /** Ready-to-write 3MF package bytes. */
91
+ threeMf: Uint8Array;
92
+ /** Naturally sorted refdes values represented by all compartments. */
93
+ componentRefdes: string[];
94
+ /** BOM-aware groups, one per generated compartment. */
95
+ componentGroups: ComponentGroup[];
96
+ dimensions: FdmComponentBoxDimensions;
97
+ compartments: CompartmentPlacement[];
98
+ meshStats: FdmComponentBoxMeshStats;
99
+ }
100
+ interface ResolvedFdmComponentBoxOptions {
101
+ columns: number;
102
+ compartmentWidth: number;
103
+ compartmentDepth: number;
104
+ compartmentHeight: number;
105
+ wallThickness: number;
106
+ floorThickness: number;
107
+ labelBandDepth: number;
108
+ labelThickness: number;
109
+ labelPadding: number;
110
+ minimumLabelStrokeWidth: number;
111
+ includeUnplacedComponents: boolean;
112
+ includeTestPoints: boolean;
113
+ groupByComponent: boolean;
114
+ boxColor: string;
115
+ labelColor: string;
116
+ title: string;
117
+ }
118
+ declare const DEFAULT_FDM_COMPONENT_BOX_OPTIONS: {
119
+ readonly compartmentWidth: 26;
120
+ readonly compartmentDepth: 22;
121
+ readonly compartmentHeight: 12;
122
+ readonly wallThickness: 1.6;
123
+ readonly floorThickness: 1.6;
124
+ readonly labelBandDepth: 6.5;
125
+ readonly labelThickness: 0.6;
126
+ readonly labelPadding: 0.75;
127
+ readonly minimumLabelStrokeWidth: 0.45;
128
+ readonly includeUnplacedComponents: false;
129
+ readonly includeTestPoints: false;
130
+ readonly groupByComponent: true;
131
+ readonly boxColor: "#D9D9D9FF";
132
+ readonly labelColor: "#151515FF";
133
+ };
134
+
135
+ declare const createFdmComponentBox: (circuitJson: CircuitJson, options?: FdmComponentBoxOptions) => Promise<FdmComponentBoxResult>;
136
+ /** Convert Circuit JSON directly to a ready-to-write 3MF byte array. */
137
+ declare const circuitJsonToFdmComponentBox: (circuitJson: CircuitJson, options?: FdmComponentBoxOptions) => Promise<Uint8Array>;
138
+
139
+ interface ExtractComponentGroupsOptions {
140
+ includeUnplacedComponents?: boolean;
141
+ includeTestPoints?: boolean;
142
+ groupByComponent?: boolean;
143
+ }
144
+ declare const naturalRefdesCollator: Intl.Collator;
145
+ declare const extractComponentGroups: (circuitJson: CircuitJson, options?: ExtractComponentGroupsOptions) => ComponentGroup[];
146
+
147
+ /**
148
+ * Returns the physical component refdes values that should receive pockets.
149
+ *
150
+ * When the document contains pcb_component records, unplaced source components
151
+ * are omitted by default. Source-only Circuit JSON falls back to all source
152
+ * components so partially rendered documents remain useful.
153
+ */
154
+ declare const extractComponentRefdes: (circuitJson: CircuitJson, options?: Omit<ExtractComponentGroupsOptions, "groupByComponent">) => string[];
155
+
156
+ type FdmComponentBoxPngOptions = RenderOptionsInput;
157
+ /** Render a deterministic, pure-JavaScript PNG preview directly from Circuit JSON. */
158
+ declare const renderFdmComponentBoxPng: (circuitJson: CircuitJson, boxOptions?: FdmComponentBoxOptions, renderOptions?: FdmComponentBoxPngOptions) => Promise<Uint8Array>;
159
+
160
+ export { type CompartmentPlacement, type ComponentGroup, DEFAULT_FDM_COMPONENT_BOX_OPTIONS, type ExtractComponentGroupsOptions, type FdmComponentBoxDimensions, type FdmComponentBoxMeshStats, type FdmComponentBoxOptions, type FdmComponentBoxPngOptions, type FdmComponentBoxResult, type ResolvedFdmComponentBoxOptions, circuitJsonToFdmComponentBox, createFdmComponentBox, extractComponentGroups, extractComponentRefdes, naturalRefdesCollator, renderFdmComponentBoxPng };