@tscircuit/internal-dynamic-import 0.0.8 → 0.0.10
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 +90 -6
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as circuit_json_to_gltf from 'circuit-json-to-gltf';
|
|
1
2
|
import { AnyCircuitElement, SourceComponentBase, PcbComponent, CircuitJson, SchematicNetLabel, PCBTrace, PCBPort, LayerRef as LayerRef$1, NinePointAnchor, PcbRenderLayer, PcbBoard, PcbCopperPour, PcbCopperText, PcbCourtyardCircle, PcbCutout, PcbFabricationNoteDimension, PcbFabricationNotePath, PcbFabricationNoteRect, PcbFabricationNoteText, PcbHole, PCBKeepout, PcbNoteDimension, PcbNotePath, PcbNoteRect, PcbNoteText, PcbPanel, PcbPlatedHole, PcbSilkscreenCircle, PcbSilkscreenLine, PcbSilkscreenOval, PcbSilkscreenPath, PcbSilkscreenPill, PcbSilkscreenRect, PcbSilkscreenText, PcbSmtPad, PcbTrace, PcbVia, PCBVia, SimulationExperiment, SimulationTransientVoltageGraph, SimulationVoltageProbe, PcbPort, SchematicComponent } from 'circuit-json';
|
|
2
3
|
import { BpcGraph } from 'bpc-graph';
|
|
3
4
|
import { z, AnyZodObject } from 'zod';
|
|
@@ -8,6 +9,64 @@ import { LightBurnProject } from 'lbrnts';
|
|
|
8
9
|
import { Box } from '@tscircuit/simple-3d-svg';
|
|
9
10
|
import { INode } from 'svgson';
|
|
10
11
|
|
|
12
|
+
type CameraOptions = {
|
|
13
|
+
camPos: readonly [number, number, number];
|
|
14
|
+
lookAt: readonly [number, number, number];
|
|
15
|
+
fov: number;
|
|
16
|
+
};
|
|
17
|
+
declare const CAMERA_PRESETS: {
|
|
18
|
+
readonly "top-down": (cam: CameraOptions) => CameraOptions;
|
|
19
|
+
readonly "top-down-ortho": (cam: CameraOptions) => CameraOptions;
|
|
20
|
+
readonly "top-left-corner": (cam: CameraOptions) => CameraOptions;
|
|
21
|
+
readonly "top-left": (cam: CameraOptions) => CameraOptions;
|
|
22
|
+
readonly "top-right-corner": (cam: CameraOptions) => CameraOptions;
|
|
23
|
+
readonly "top-right": (cam: CameraOptions) => CameraOptions;
|
|
24
|
+
readonly "left-sideview": (cam: CameraOptions) => CameraOptions;
|
|
25
|
+
readonly "right-sideview": (cam: CameraOptions) => CameraOptions;
|
|
26
|
+
readonly front: (cam: CameraOptions) => CameraOptions;
|
|
27
|
+
readonly "top-center-angled": (cam: CameraOptions) => CameraOptions;
|
|
28
|
+
};
|
|
29
|
+
type CameraPreset$1 = keyof typeof CAMERA_PRESETS;
|
|
30
|
+
declare const CAMERA_PRESET_NAMES: CameraPreset$1[];
|
|
31
|
+
declare function applyCameraPreset(preset: CameraPreset$1, cam: CameraOptions): CameraOptions;
|
|
32
|
+
|
|
33
|
+
type ConvertCircuitJsonTo3dGltfResult = Awaited<ReturnType<typeof circuit_json_to_gltf["convertCircuitJsonToGltf"]>>;
|
|
34
|
+
type CircuitJson3dBaseOptions = {
|
|
35
|
+
modelPathBaseDir?: string;
|
|
36
|
+
projectBaseUrl?: string;
|
|
37
|
+
authHeaders?: {
|
|
38
|
+
Authorization: string;
|
|
39
|
+
};
|
|
40
|
+
boardTextureResolution?: number;
|
|
41
|
+
};
|
|
42
|
+
type RenderCircuitJsonTo3dPngOptions = CircuitJson3dBaseOptions & {
|
|
43
|
+
camera?: CameraOptions;
|
|
44
|
+
cameraPreset?: CameraPreset$1;
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
47
|
+
backgroundColor?: string | readonly [number, number, number] | null;
|
|
48
|
+
showInfiniteGrid?: boolean;
|
|
49
|
+
supersampling?: number;
|
|
50
|
+
};
|
|
51
|
+
declare const getDefaultCameraForCircuitJson: (circuitJson: AnyCircuitElement[]) => Promise<CameraOptions>;
|
|
52
|
+
declare const convertCircuitJsonTo3dGltf: (circuitJson: AnyCircuitElement[], options?: CircuitJson3dBaseOptions) => Promise<ConvertCircuitJsonTo3dGltfResult>;
|
|
53
|
+
declare const convertCircuitJsonTo3dGlb: (circuitJson: AnyCircuitElement[], options?: CircuitJson3dBaseOptions) => Promise<Uint8Array>;
|
|
54
|
+
declare const renderCircuitJsonTo3dPng: (circuitJson: AnyCircuitElement[], options?: RenderCircuitJsonTo3dPngOptions) => Promise<Uint8Array>;
|
|
55
|
+
|
|
56
|
+
declare const CircuitJsonTo3dPngModule_CAMERA_PRESET_NAMES: typeof CAMERA_PRESET_NAMES;
|
|
57
|
+
type CircuitJsonTo3dPngModule_CameraOptions = CameraOptions;
|
|
58
|
+
type CircuitJsonTo3dPngModule_CircuitJson3dBaseOptions = CircuitJson3dBaseOptions;
|
|
59
|
+
type CircuitJsonTo3dPngModule_ConvertCircuitJsonTo3dGltfResult = ConvertCircuitJsonTo3dGltfResult;
|
|
60
|
+
type CircuitJsonTo3dPngModule_RenderCircuitJsonTo3dPngOptions = RenderCircuitJsonTo3dPngOptions;
|
|
61
|
+
declare const CircuitJsonTo3dPngModule_applyCameraPreset: typeof applyCameraPreset;
|
|
62
|
+
declare const CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGlb: typeof convertCircuitJsonTo3dGlb;
|
|
63
|
+
declare const CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGltf: typeof convertCircuitJsonTo3dGltf;
|
|
64
|
+
declare const CircuitJsonTo3dPngModule_getDefaultCameraForCircuitJson: typeof getDefaultCameraForCircuitJson;
|
|
65
|
+
declare const CircuitJsonTo3dPngModule_renderCircuitJsonTo3dPng: typeof renderCircuitJsonTo3dPng;
|
|
66
|
+
declare namespace CircuitJsonTo3dPngModule {
|
|
67
|
+
export { CircuitJsonTo3dPngModule_CAMERA_PRESET_NAMES as CAMERA_PRESET_NAMES, type CircuitJsonTo3dPngModule_CameraOptions as CameraOptions, type CameraPreset$1 as CameraPreset, type CircuitJsonTo3dPngModule_CircuitJson3dBaseOptions as CircuitJson3dBaseOptions, type CircuitJsonTo3dPngModule_ConvertCircuitJsonTo3dGltfResult as ConvertCircuitJsonTo3dGltfResult, type CircuitJsonTo3dPngModule_RenderCircuitJsonTo3dPngOptions as RenderCircuitJsonTo3dPngOptions, CircuitJsonTo3dPngModule_applyCameraPreset as applyCameraPreset, CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGlb as convertCircuitJsonTo3dGlb, CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGltf as convertCircuitJsonTo3dGltf, CircuitJsonTo3dPngModule_getDefaultCameraForCircuitJson as getDefaultCameraForCircuitJson, CircuitJsonTo3dPngModule_renderCircuitJsonTo3dPng as renderCircuitJsonTo3dPng };
|
|
68
|
+
}
|
|
69
|
+
|
|
11
70
|
type SupplierPartNumberColumn = "JLCPCB Part #";
|
|
12
71
|
interface BomRow {
|
|
13
72
|
designator: string;
|
|
@@ -970,7 +1029,32 @@ declare function loadSTL({ url, transform, projectBaseUrl, authHeaders, }: {
|
|
|
970
1029
|
}): Promise<STLMesh>;
|
|
971
1030
|
declare function clearSTLCache(): void;
|
|
972
1031
|
|
|
1032
|
+
declare const CAMERA_PRESET_DIRECTIONS: {
|
|
1033
|
+
readonly isometric: readonly [-0.7, 1.2, -0.8];
|
|
1034
|
+
readonly top_down: readonly [0, 1, 0.001];
|
|
1035
|
+
readonly bottom_up: readonly [0, -1, 0.001];
|
|
1036
|
+
readonly left_side: readonly [-1, 0, 0];
|
|
1037
|
+
readonly right_side: readonly [1, 0, 0];
|
|
1038
|
+
readonly front: readonly [0, 0, 1];
|
|
1039
|
+
readonly back: readonly [0, 0, -1];
|
|
1040
|
+
};
|
|
1041
|
+
type CameraPreset = keyof typeof CAMERA_PRESET_DIRECTIONS;
|
|
973
1042
|
interface CameraFitOptions {
|
|
1043
|
+
/**
|
|
1044
|
+
* Named preset view. Useful for stable top/bottom/side snapshots.
|
|
1045
|
+
*
|
|
1046
|
+
* `top_down`/`bottom_up` use a tiny hidden tilt because the downstream
|
|
1047
|
+
* renderer currently assumes a fixed up-vector and collapses on a perfectly
|
|
1048
|
+
* vertical view.
|
|
1049
|
+
*/
|
|
1050
|
+
preset?: CameraPreset;
|
|
1051
|
+
/**
|
|
1052
|
+
* Approximate an orthographic view using a very narrow perspective FOV.
|
|
1053
|
+
*
|
|
1054
|
+
* This is a compatibility hack for renderers that only expose perspective
|
|
1055
|
+
* cameras. It is not a true orthographic projection.
|
|
1056
|
+
*/
|
|
1057
|
+
ortho?: boolean;
|
|
974
1058
|
/**
|
|
975
1059
|
* Target-to-camera direction vector used for solved camera position.
|
|
976
1060
|
*/
|
|
@@ -993,10 +1077,7 @@ interface CameraFitOptions {
|
|
|
993
1077
|
*/
|
|
994
1078
|
sensorHeight?: number;
|
|
995
1079
|
}
|
|
996
|
-
|
|
997
|
-
* Calculate optimal camera position for PCB viewing based on circuit dimensions
|
|
998
|
-
*/
|
|
999
|
-
declare function getBestCameraPosition(circuitJson: CircuitJson): {
|
|
1080
|
+
declare function getBestCameraPosition(circuitJson: CircuitJson, opts?: CameraFitOptions): {
|
|
1000
1081
|
camPos: readonly [number, number, number];
|
|
1001
1082
|
lookAt: readonly [number, number, number];
|
|
1002
1083
|
fov: number;
|
|
@@ -1039,9 +1120,11 @@ type CircuitJsonToGltfModule_BRepShape = BRepShape;
|
|
|
1039
1120
|
type CircuitJsonToGltfModule_BoardRenderOptions = BoardRenderOptions;
|
|
1040
1121
|
type CircuitJsonToGltfModule_BoundingBox = BoundingBox;
|
|
1041
1122
|
type CircuitJsonToGltfModule_Box3D = Box3D;
|
|
1123
|
+
declare const CircuitJsonToGltfModule_CAMERA_PRESET_DIRECTIONS: typeof CAMERA_PRESET_DIRECTIONS;
|
|
1042
1124
|
declare const CircuitJsonToGltfModule_COORDINATE_TRANSFORMS: typeof COORDINATE_TRANSFORMS;
|
|
1043
1125
|
type CircuitJsonToGltfModule_Camera3D = Camera3D;
|
|
1044
1126
|
type CircuitJsonToGltfModule_CameraFitOptions = CameraFitOptions;
|
|
1127
|
+
type CircuitJsonToGltfModule_CameraPreset = CameraPreset;
|
|
1045
1128
|
type CircuitJsonToGltfModule_CircuitTo3DOptions = CircuitTo3DOptions;
|
|
1046
1129
|
type CircuitJsonToGltfModule_Color = Color;
|
|
1047
1130
|
type CircuitJsonToGltfModule_ConversionOptions = ConversionOptions;
|
|
@@ -1072,7 +1155,7 @@ declare const CircuitJsonToGltfModule_renderBoardLayer: typeof renderBoardLayer;
|
|
|
1072
1155
|
declare const CircuitJsonToGltfModule_renderBoardTextures: typeof renderBoardTextures;
|
|
1073
1156
|
declare const CircuitJsonToGltfModule_transformTriangles: typeof transformTriangles;
|
|
1074
1157
|
declare namespace CircuitJsonToGltfModule {
|
|
1075
|
-
export { type CircuitJsonToGltfModule_BRepShape as BRepShape, type CircuitJsonToGltfModule_BoardRenderOptions as BoardRenderOptions, type CircuitJsonToGltfModule_BoundingBox as BoundingBox, type CircuitJsonToGltfModule_Box3D as Box3D, CircuitJsonToGltfModule_COORDINATE_TRANSFORMS as COORDINATE_TRANSFORMS, type CircuitJsonToGltfModule_Camera3D as Camera3D, type CircuitJsonToGltfModule_CameraFitOptions as CameraFitOptions, type CircuitJsonToGltfModule_CircuitTo3DOptions as CircuitTo3DOptions, type CircuitJsonToGltfModule_Color as Color, type CircuitJsonToGltfModule_ConversionOptions as ConversionOptions, type CircuitJsonToGltfModule_CoordinateTransformConfig as CoordinateTransformConfig, type CircuitJsonToGltfModule_GLTFExportOptions as GLTFExportOptions, type CircuitJsonToGltfModule_LayerRef as LayerRef, type CircuitJsonToGltfModule_Light3D as Light3D, type CircuitJsonToGltfModule_OBJMaterial as OBJMaterial, type CircuitJsonToGltfModule_OBJMesh as OBJMesh, type CircuitJsonToGltfModule_Point as Point, type CircuitJsonToGltfModule_Point3 as Point3, type CircuitJsonToGltfModule_STLMesh as STLMesh, type CircuitJsonToGltfModule_Scene3D as Scene3D, type CircuitJsonToGltfModule_Size3 as Size3, type CircuitJsonToGltfModule_Triangle as Triangle, CircuitJsonToGltfModule_applyCoordinateTransform as applyCoordinateTransform, CircuitJsonToGltfModule_clearGLBCache as clearGLBCache, CircuitJsonToGltfModule_clearOBJCache as clearOBJCache, CircuitJsonToGltfModule_clearSTLCache as clearSTLCache, CircuitJsonToGltfModule_convertCircuitJsonTo3D as convertCircuitJsonTo3D, CircuitJsonToGltfModule_convertCircuitJsonToGltf as convertCircuitJsonToGltf, CircuitJsonToGltfModule_convertSceneToGLTF as convertSceneToGLTF, CircuitJsonToGltfModule_getBestCameraPosition as getBestCameraPosition, CircuitJsonToGltfModule_loadGLB as loadGLB, CircuitJsonToGltfModule_loadOBJ as loadOBJ, CircuitJsonToGltfModule_loadSTL as loadSTL, CircuitJsonToGltfModule_renderBoardLayer as renderBoardLayer, CircuitJsonToGltfModule_renderBoardTextures as renderBoardTextures, CircuitJsonToGltfModule_transformTriangles as transformTriangles };
|
|
1158
|
+
export { type CircuitJsonToGltfModule_BRepShape as BRepShape, type CircuitJsonToGltfModule_BoardRenderOptions as BoardRenderOptions, type CircuitJsonToGltfModule_BoundingBox as BoundingBox, type CircuitJsonToGltfModule_Box3D as Box3D, CircuitJsonToGltfModule_CAMERA_PRESET_DIRECTIONS as CAMERA_PRESET_DIRECTIONS, CircuitJsonToGltfModule_COORDINATE_TRANSFORMS as COORDINATE_TRANSFORMS, type CircuitJsonToGltfModule_Camera3D as Camera3D, type CircuitJsonToGltfModule_CameraFitOptions as CameraFitOptions, type CircuitJsonToGltfModule_CameraPreset as CameraPreset, type CircuitJsonToGltfModule_CircuitTo3DOptions as CircuitTo3DOptions, type CircuitJsonToGltfModule_Color as Color, type CircuitJsonToGltfModule_ConversionOptions as ConversionOptions, type CircuitJsonToGltfModule_CoordinateTransformConfig as CoordinateTransformConfig, type CircuitJsonToGltfModule_GLTFExportOptions as GLTFExportOptions, type CircuitJsonToGltfModule_LayerRef as LayerRef, type CircuitJsonToGltfModule_Light3D as Light3D, type CircuitJsonToGltfModule_OBJMaterial as OBJMaterial, type CircuitJsonToGltfModule_OBJMesh as OBJMesh, type CircuitJsonToGltfModule_Point as Point, type CircuitJsonToGltfModule_Point3 as Point3, type CircuitJsonToGltfModule_STLMesh as STLMesh, type CircuitJsonToGltfModule_Scene3D as Scene3D, type CircuitJsonToGltfModule_Size3 as Size3, type CircuitJsonToGltfModule_Triangle as Triangle, CircuitJsonToGltfModule_applyCoordinateTransform as applyCoordinateTransform, CircuitJsonToGltfModule_clearGLBCache as clearGLBCache, CircuitJsonToGltfModule_clearOBJCache as clearOBJCache, CircuitJsonToGltfModule_clearSTLCache as clearSTLCache, CircuitJsonToGltfModule_convertCircuitJsonTo3D as convertCircuitJsonTo3D, CircuitJsonToGltfModule_convertCircuitJsonToGltf as convertCircuitJsonToGltf, CircuitJsonToGltfModule_convertSceneToGLTF as convertSceneToGLTF, CircuitJsonToGltfModule_getBestCameraPosition as getBestCameraPosition, CircuitJsonToGltfModule_loadGLB as loadGLB, CircuitJsonToGltfModule_loadOBJ as loadOBJ, CircuitJsonToGltfModule_loadSTL as loadSTL, CircuitJsonToGltfModule_renderBoardLayer as renderBoardLayer, CircuitJsonToGltfModule_renderBoardTextures as renderBoardTextures, CircuitJsonToGltfModule_transformTriangles as transformTriangles };
|
|
1076
1159
|
}
|
|
1077
1160
|
|
|
1078
1161
|
type PaperSize = "A0" | "A1" | "A2" | "A3" | "A4" | "A5";
|
|
@@ -3462,10 +3545,11 @@ declare namespace KicadToCircuitJsonModule {
|
|
|
3462
3545
|
export { KicadToCircuitJsonModule_CollectFootprintsStage as CollectFootprintsStage, KicadToCircuitJsonModule_CollectGraphicsStage as CollectGraphicsStage, KicadToCircuitJsonModule_CollectLibrarySymbolsStage as CollectLibrarySymbolsStage, KicadToCircuitJsonModule_CollectNetsStage as CollectNetsStage, KicadToCircuitJsonModule_CollectSchematicTracesStage as CollectSchematicTracesStage, KicadToCircuitJsonModule_CollectSourceTracesStage as CollectSourceTracesStage, KicadToCircuitJsonModule_CollectSymbolLibrarySymbolsStage as CollectSymbolLibrarySymbolsStage, KicadToCircuitJsonModule_CollectTracesStage as CollectTracesStage, KicadToCircuitJsonModule_CollectViasStage as CollectViasStage, KicadToCircuitJsonModule_CollectZonesStage as CollectZonesStage, type KicadToCircuitJsonModule_ConverterContext as ConverterContext, KicadToCircuitJsonModule_ConverterStage as ConverterStage, KicadToCircuitJsonModule_InitializePcbContextStage as InitializePcbContextStage, KicadToCircuitJsonModule_InitializeSchematicContextStage as InitializeSchematicContextStage, KicadToCircuitJsonModule_InitializeSymbolLibraryContextStage as InitializeSymbolLibraryContextStage, KicadToCircuitJsonModule_KicadFootprintToCircuitJsonConverter as KicadFootprintToCircuitJsonConverter, KicadToCircuitJsonModule_KicadSymbolToCircuitJsonConverter as KicadSymbolToCircuitJsonConverter, KicadToCircuitJsonModule_KicadToCircuitJsonConverter as KicadToCircuitJsonConverter };
|
|
3463
3546
|
}
|
|
3464
3547
|
|
|
3465
|
-
declare const supportedModules: readonly ["circuit-json-to-bom-csv", "circuit-json-to-bpc", "circuit-json-to-connectivity-map", "circuit-json-to-gerber", "circuit-json-to-gltf", "circuit-json-to-kicad", "circuit-json-to-lbrn", "circuit-json-to-pnp-csv", "circuit-json-to-readable-netlist", "circuit-json-to-simple-3d", "circuit-json-to-spice", "circuit-json-to-step", "circuit-json-to-tscircuit", "circuit-to-canvas", "circuit-to-svg", "kicad-to-circuit-json"];
|
|
3548
|
+
declare const supportedModules: readonly ["circuit-json-to-3d-png", "circuit-json-to-bom-csv", "circuit-json-to-bpc", "circuit-json-to-connectivity-map", "circuit-json-to-gerber", "circuit-json-to-gltf", "circuit-json-to-kicad", "circuit-json-to-lbrn", "circuit-json-to-pnp-csv", "circuit-json-to-readable-netlist", "circuit-json-to-simple-3d", "circuit-json-to-spice", "circuit-json-to-step", "circuit-json-to-tscircuit", "circuit-to-canvas", "circuit-to-svg", "kicad-to-circuit-json"];
|
|
3466
3549
|
type SupportedModuleName = (typeof supportedModules)[number];
|
|
3467
3550
|
type SupportedModuleSpecifier = SupportedModuleName | `${SupportedModuleName}@${string}`;
|
|
3468
3551
|
interface SupportedModuleMap {
|
|
3552
|
+
"circuit-json-to-3d-png": typeof CircuitJsonTo3dPngModule;
|
|
3469
3553
|
"circuit-json-to-bom-csv": typeof CircuitJsonToBomCsvModule;
|
|
3470
3554
|
"circuit-json-to-bpc": typeof CircuitJsonToBpcModule;
|
|
3471
3555
|
"circuit-json-to-connectivity-map": typeof CircuitJsonToConnectivityMapModule;
|
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/index.ts"],"names":[],"mappings":";AAYO,IAAM,2BAA2B,MAA6B;AACnE,EAAA,IAAI,WAAW,uBAAA,EAAyB;AACtC,IAAA,OAAO,UAAA,CAAW,uBAAA;AAAA,EACpB;AAEA,EAAA,MAAM,WAAkC,EAAC;AACzC,EAAA,UAAA,CAAW,uBAAA,GAA0B,QAAA;AACrC,EAAA,OAAO,QAAA;AACT;AAUO,SAAS,qBAAA,CACd,MACA,GAAA,EACS;AACT,EAAA,wBAAA,EAAyB,CAAE,IAAI,CAAA,GAAI,GAAA;AACnC,EAAA,OAAO,GAAA;AACT;;;
|
|
1
|
+
{"version":3,"sources":["../lib/dynamic-module-registry.ts","../lib/supported-modules.ts","../lib/index.ts"],"names":[],"mappings":";AAYO,IAAM,2BAA2B,MAA6B;AACnE,EAAA,IAAI,WAAW,uBAAA,EAAyB;AACtC,IAAA,OAAO,UAAA,CAAW,uBAAA;AAAA,EACpB;AAEA,EAAA,MAAM,WAAkC,EAAC;AACzC,EAAA,UAAA,CAAW,uBAAA,GAA0B,QAAA;AACrC,EAAA,OAAO,QAAA;AACT;AAUO,SAAS,qBAAA,CACd,MACA,GAAA,EACS;AACT,EAAA,wBAAA,EAAyB,CAAE,IAAI,CAAA,GAAI,GAAA;AACnC,EAAA,OAAO,GAAA;AACT;;;AClBO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,wBAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,kCAAA;AAAA,EACA,wBAAA;AAAA,EACA,sBAAA;AAAA,EACA,uBAAA;AAAA,EACA,sBAAA;AAAA,EACA,yBAAA;AAAA,EACA,kCAAA;AAAA,EACA,2BAAA;AAAA,EACA,uBAAA;AAAA,EACA,sBAAA;AAAA,EACA,2BAAA;AAAA,EACA,mBAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF;AAoCO,IAAM,aAAA,GAAgB,CAAC,SAAA,KAA8B;AAC1D,EAAA,MAAM,qBAAA,GAAwB,SAAA,CAAU,OAAA,CAAQ,GAAG,CAAA;AACnD,EAAA,OAAO,0BAA0B,EAAA,GAC7B,SAAA,GACA,SAAA,CAAU,KAAA,CAAM,GAAG,qBAAqB,CAAA;AAC9C;;;ACpDA,IAAM,kBAAA,GAAqB,IAAI,GAAA,CAAY,gBAAgB,CAAA;AAEpD,IAAM,YAAA,GAAe,CAAC,SAAA,KAA8B;AACzD,EAAA,qBAAA,CAAsB,SAAS,CAAA;AAE/B,EAAA,OAAO,kBAAkB,SAAS,CAAA;AACpC;AAEO,IAAM,aAAA,GAAgB,CAAC,SAAA,KAAgC;AAC5D,EAAA,qBAAA,CAAsB,SAAS,CAAA;AAE/B,EAAA,OAAO,CAAC,iBAAA,CAAkB,SAAS,CAAA,EAAG,CAAA,gBAAA,EAAmB,SAAS,CAAA,CAAE,CAAA;AACtE;AAEA,SAAS,kBAAkB,SAAA,EAA2B;AACpD,EAAA,MAAM,UAAA,GAAa,cAAc,SAAS,CAAA;AAC1C,EAAA,MAAM,OAAA,GACJ,SAAA,CAAU,MAAA,KAAW,UAAA,CAAW,MAAA,GAC5B,WACA,SAAA,CAAU,KAAA,CAAM,UAAA,CAAW,MAAA,GAAS,CAAC,CAAA;AAE3C,EAAA,OAAO,CAAA,4BAAA,EAA+B,UAAU,CAAA,CAAA,EAAI,OAAO,CAAA,KAAA,CAAA;AAC7D;AAEA,SAAS,sBAAsB,SAAA,EAAmB;AAChD,EAAA,MAAM,UAAA,GAAa,cAAc,SAAS,CAAA;AAE1C,EAAA,IAAI,CAAC,kBAAA,CAAmB,GAAA,CAAI,UAAU,CAAA,EAAG;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,oBAAA,EAAuB,SAAS,CAAA,CAAE,CAAA;AAAA,EACpD;AACF;AAMA,eAAe,SAAS,SAAA,EAAqC;AAC3D,EAAA,IAAI,SAAA;AAEJ,EAAA,KAAA,MAAW,SAAA,IAAa,aAAA,CAAc,SAAS,CAAA,EAAG;AAChD,IAAA,IAAI;AACF,MAAA,MAAM,MAAM,MAAM;AAAA;AAAA,QAA0B;AAAA,OAAA;AAC5C,MAAA,OAAO,qBAAA,CAAsB,aAAA,CAAc,SAAS,CAAA,EAAG,GAAG,CAAA;AAAA,IAC5D,SAAS,KAAA,EAAO;AACd,MAAA,SAAA,GAAY,KAAA;AAAA,IACd;AAAA,EACF;AAEA,EAAA,MAAM,SAAA;AACR;AAEA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["import type {\n SupportedModuleMap,\n SupportedModuleName,\n} from \"./supported-modules\"\n\nexport type DynamicModuleRegistry = Partial<SupportedModuleMap> &\n Record<string, unknown>\n\ndeclare global {\n var tscircuitDynamicModules: DynamicModuleRegistry | undefined\n}\n\nexport const getDynamicModuleRegistry = (): DynamicModuleRegistry => {\n if (globalThis.tscircuitDynamicModules) {\n return globalThis.tscircuitDynamicModules\n }\n\n const registry: DynamicModuleRegistry = {}\n globalThis.tscircuitDynamicModules = registry\n return registry\n}\n\nexport function registerDynamicModule<TSpecifier extends SupportedModuleName>(\n name: TSpecifier,\n mod: SupportedModuleMap[TSpecifier],\n): SupportedModuleMap[TSpecifier]\nexport function registerDynamicModule<TModule>(\n name: string,\n mod: TModule,\n): TModule\nexport function registerDynamicModule<TModule>(\n name: string,\n mod: TModule,\n): TModule {\n getDynamicModuleRegistry()[name] = mod\n return mod\n}\n","import type * as CircuitJsonTo3dPngModule from \"./type-bundles/circuit-json-to-3d-png\"\nimport type * as CircuitJsonToBomCsvModule from \"./type-bundles/circuit-json-to-bom-csv\"\nimport type * as CircuitJsonToBpcModule from \"./type-bundles/circuit-json-to-bpc\"\nimport type * as CircuitJsonToConnectivityMapModule from \"./type-bundles/circuit-json-to-connectivity-map\"\nimport type * as CircuitJsonToGerberModule from \"./type-bundles/circuit-json-to-gerber\"\nimport type * as CircuitJsonToGltfModule from \"./type-bundles/circuit-json-to-gltf\"\nimport type * as CircuitJsonToKicadModule from \"./type-bundles/circuit-json-to-kicad\"\nimport type * as CircuitJsonToLbrnModule from \"./type-bundles/circuit-json-to-lbrn\"\nimport type * as CircuitJsonToPnpCsvModule from \"./type-bundles/circuit-json-to-pnp-csv\"\nimport type * as CircuitJsonToReadableNetlistModule from \"./type-bundles/circuit-json-to-readable-netlist\"\nimport type * as CircuitJsonToSimple3dModule from \"./type-bundles/circuit-json-to-simple-3d\"\nimport type * as CircuitJsonToSpiceModule from \"./type-bundles/circuit-json-to-spice\"\nimport type * as CircuitJsonToStepModule from \"./type-bundles/circuit-json-to-step\"\nimport type * as CircuitJsonToTscircuitModule from \"./type-bundles/circuit-json-to-tscircuit\"\nimport type * as CircuitToCanvasModule from \"./type-bundles/circuit-to-canvas\"\nimport type * as CircuitToSvgModule from \"./type-bundles/circuit-to-svg\"\nimport type * as KicadToCircuitJsonModule from \"./type-bundles/kicad-to-circuit-json\"\n\nexport const supportedModules = [\n \"circuit-json-to-3d-png\",\n \"circuit-json-to-bom-csv\",\n \"circuit-json-to-bpc\",\n \"circuit-json-to-connectivity-map\",\n \"circuit-json-to-gerber\",\n \"circuit-json-to-gltf\",\n \"circuit-json-to-kicad\",\n \"circuit-json-to-lbrn\",\n \"circuit-json-to-pnp-csv\",\n \"circuit-json-to-readable-netlist\",\n \"circuit-json-to-simple-3d\",\n \"circuit-json-to-spice\",\n \"circuit-json-to-step\",\n \"circuit-json-to-tscircuit\",\n \"circuit-to-canvas\",\n \"circuit-to-svg\",\n \"kicad-to-circuit-json\",\n] as const\n\nexport type SupportedModuleName = (typeof supportedModules)[number]\nexport type SupportedModuleSpecifier =\n | SupportedModuleName\n | `${SupportedModuleName}@${string}`\n\nexport interface SupportedModuleMap {\n \"circuit-json-to-3d-png\": typeof CircuitJsonTo3dPngModule\n \"circuit-json-to-bom-csv\": typeof CircuitJsonToBomCsvModule\n \"circuit-json-to-bpc\": typeof CircuitJsonToBpcModule\n \"circuit-json-to-connectivity-map\": typeof CircuitJsonToConnectivityMapModule\n \"circuit-json-to-gerber\": typeof CircuitJsonToGerberModule\n \"circuit-json-to-gltf\": typeof CircuitJsonToGltfModule\n \"circuit-json-to-kicad\": typeof CircuitJsonToKicadModule\n \"circuit-json-to-lbrn\": typeof CircuitJsonToLbrnModule\n \"circuit-json-to-pnp-csv\": typeof CircuitJsonToPnpCsvModule\n \"circuit-json-to-readable-netlist\": typeof CircuitJsonToReadableNetlistModule\n \"circuit-json-to-simple-3d\": typeof CircuitJsonToSimple3dModule\n \"circuit-json-to-spice\": typeof CircuitJsonToSpiceModule\n \"circuit-json-to-step\": typeof CircuitJsonToStepModule\n \"circuit-json-to-tscircuit\": typeof CircuitJsonToTscircuitModule\n \"circuit-to-canvas\": typeof CircuitToCanvasModule\n \"circuit-to-svg\": typeof CircuitToSvgModule\n \"kicad-to-circuit-json\": typeof KicadToCircuitJsonModule\n}\n\nexport type StripVersion<TSpecifier extends string> =\n TSpecifier extends `${infer TBase}@${string}`\n ? TBase extends SupportedModuleName\n ? TBase\n : never\n : TSpecifier extends SupportedModuleName\n ? TSpecifier\n : never\n\nexport const getModuleName = (specifier: string): string => {\n const versionSeparatorIndex = specifier.indexOf(\"@\")\n return versionSeparatorIndex === -1\n ? specifier\n : specifier.slice(0, versionSeparatorIndex)\n}\n","import { registerDynamicModule } from \"./dynamic-module-registry\"\nimport {\n getModuleName,\n supportedModules,\n type StripVersion,\n type SupportedModuleMap,\n type SupportedModuleSpecifier,\n} from \"./supported-modules\"\n\nexport {\n getDynamicModuleRegistry,\n registerDynamicModule,\n} from \"./dynamic-module-registry\"\nexport type { DynamicModuleRegistry } from \"./dynamic-module-registry\"\nexport {\n getModuleName,\n supportedModules,\n} from \"./supported-modules\"\nexport type {\n StripVersion,\n SupportedModuleMap,\n SupportedModuleName,\n SupportedModuleSpecifier,\n} from \"./supported-modules\"\n\nconst supportedModuleSet = new Set<string>(supportedModules)\n\nexport const getImportUrl = (specifier: string): string => {\n assertSupportedModule(specifier)\n\n return getJscdnImportUrl(specifier)\n}\n\nexport const getImportUrls = (specifier: string): string[] => {\n assertSupportedModule(specifier)\n\n return [getJscdnImportUrl(specifier), `https://esm.run/${specifier}`]\n}\n\nfunction getJscdnImportUrl(specifier: string): string {\n const moduleName = getModuleName(specifier)\n const version =\n specifier.length === moduleName.length\n ? \"latest\"\n : specifier.slice(moduleName.length + 1)\n\n return `https://jscdn.tscircuit.com/${moduleName}/${version}/+esm`\n}\n\nfunction assertSupportedModule(specifier: string) {\n const moduleName = getModuleName(specifier)\n\n if (!supportedModuleSet.has(moduleName)) {\n throw new Error(`Unsupported module: ${specifier}`)\n }\n}\n\nasync function importer<TSpecifier extends SupportedModuleSpecifier>(\n specifier: TSpecifier,\n): Promise<SupportedModuleMap[StripVersion<TSpecifier>]>\nasync function importer(specifier: string): Promise<unknown>\nasync function importer(specifier: string): Promise<unknown> {\n let lastError: unknown\n\n for (const importUrl of getImportUrls(specifier)) {\n try {\n const mod = await import(/* @vite-ignore */ importUrl)\n return registerDynamicModule(getModuleName(specifier), mod)\n } catch (error) {\n lastError = error\n }\n }\n\n throw lastError\n}\n\nexport default importer\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/internal-dynamic-import",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Type-safe dynamic imports for selected tscircuit packages via jscdn and fallback to jsDelivr",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@biomejs/biome": "^2.0.5",
|
|
30
30
|
"@types/bun": "latest",
|
|
31
|
+
"circuit-json-to-3d-png": "0.0.7",
|
|
31
32
|
"circuit-json-to-bom-csv": "0.0.8",
|
|
32
33
|
"circuit-json-to-bpc": "0.0.13",
|
|
33
34
|
"circuit-json-to-connectivity-map": "0.0.23",
|
|
34
35
|
"circuit-json-to-gerber": "0.0.51",
|
|
35
|
-
"circuit-json-to-gltf": "0.0.
|
|
36
|
+
"circuit-json-to-gltf": "0.0.106",
|
|
36
37
|
"circuit-json-to-kicad": "0.0.137",
|
|
37
38
|
"circuit-json-to-lbrn": "0.0.69",
|
|
38
39
|
"circuit-json-to-pnp-csv": "0.0.7",
|