@tscircuit/internal-dynamic-import 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +62 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
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,65 @@ import { LightBurnProject } from 'lbrnts';
|
|
|
8
9
|
import { Box } from '@tscircuit/simple-3d-svg';
|
|
9
10
|
import { INode } from 'svgson';
|
|
10
11
|
|
|
12
|
+
type CameraOptions = {
|
|
13
|
+
camPos: readonly [number, number, number];
|
|
14
|
+
lookAt: readonly [number, number, number];
|
|
15
|
+
fov: number;
|
|
16
|
+
};
|
|
17
|
+
declare const CAMERA_PRESETS: {
|
|
18
|
+
readonly "top-down": (cam: CameraOptions) => CameraOptions;
|
|
19
|
+
readonly "top-down-ortho": (cam: CameraOptions) => CameraOptions;
|
|
20
|
+
readonly "top-left-corner": (cam: CameraOptions) => CameraOptions;
|
|
21
|
+
readonly "top-left": (cam: CameraOptions) => CameraOptions;
|
|
22
|
+
readonly "top-right-corner": (cam: CameraOptions) => CameraOptions;
|
|
23
|
+
readonly "top-right": (cam: CameraOptions) => CameraOptions;
|
|
24
|
+
readonly "left-sideview": (cam: CameraOptions) => CameraOptions;
|
|
25
|
+
readonly "right-sideview": (cam: CameraOptions) => CameraOptions;
|
|
26
|
+
readonly front: (cam: CameraOptions) => CameraOptions;
|
|
27
|
+
readonly "top-center-angled": (cam: CameraOptions) => CameraOptions;
|
|
28
|
+
};
|
|
29
|
+
type CameraPreset = keyof typeof CAMERA_PRESETS;
|
|
30
|
+
declare const CAMERA_PRESET_NAMES: CameraPreset[];
|
|
31
|
+
declare function applyCameraPreset(preset: CameraPreset, cam: CameraOptions): CameraOptions;
|
|
32
|
+
|
|
33
|
+
type ConvertCircuitJsonTo3dGltfResult = Awaited<ReturnType<typeof circuit_json_to_gltf["convertCircuitJsonToGltf"]>>;
|
|
34
|
+
type CircuitJson3dBaseOptions = {
|
|
35
|
+
modelPathBaseDir?: string;
|
|
36
|
+
projectBaseUrl?: string;
|
|
37
|
+
authHeaders?: {
|
|
38
|
+
Authorization: string;
|
|
39
|
+
};
|
|
40
|
+
boardTextureResolution?: number;
|
|
41
|
+
};
|
|
42
|
+
type RenderCircuitJsonTo3dPngOptions = CircuitJson3dBaseOptions & {
|
|
43
|
+
camera?: CameraOptions;
|
|
44
|
+
cameraPreset?: CameraPreset;
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
47
|
+
backgroundColor?: string | readonly [number, number, number] | null;
|
|
48
|
+
showInfiniteGrid?: boolean;
|
|
49
|
+
supersampling?: number;
|
|
50
|
+
};
|
|
51
|
+
declare const getDefaultCameraForCircuitJson: (circuitJson: AnyCircuitElement[]) => Promise<CameraOptions>;
|
|
52
|
+
declare const convertCircuitJsonTo3dGltf: (circuitJson: AnyCircuitElement[], options?: CircuitJson3dBaseOptions) => Promise<ConvertCircuitJsonTo3dGltfResult>;
|
|
53
|
+
declare const convertCircuitJsonTo3dGlb: (circuitJson: AnyCircuitElement[], options?: CircuitJson3dBaseOptions) => Promise<Uint8Array>;
|
|
54
|
+
declare const renderCircuitJsonTo3dPng: (circuitJson: AnyCircuitElement[], options?: RenderCircuitJsonTo3dPngOptions) => Promise<Uint8Array>;
|
|
55
|
+
|
|
56
|
+
declare const CircuitJsonTo3dPngModule_CAMERA_PRESET_NAMES: typeof CAMERA_PRESET_NAMES;
|
|
57
|
+
type CircuitJsonTo3dPngModule_CameraOptions = CameraOptions;
|
|
58
|
+
type CircuitJsonTo3dPngModule_CameraPreset = CameraPreset;
|
|
59
|
+
type CircuitJsonTo3dPngModule_CircuitJson3dBaseOptions = CircuitJson3dBaseOptions;
|
|
60
|
+
type CircuitJsonTo3dPngModule_ConvertCircuitJsonTo3dGltfResult = ConvertCircuitJsonTo3dGltfResult;
|
|
61
|
+
type CircuitJsonTo3dPngModule_RenderCircuitJsonTo3dPngOptions = RenderCircuitJsonTo3dPngOptions;
|
|
62
|
+
declare const CircuitJsonTo3dPngModule_applyCameraPreset: typeof applyCameraPreset;
|
|
63
|
+
declare const CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGlb: typeof convertCircuitJsonTo3dGlb;
|
|
64
|
+
declare const CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGltf: typeof convertCircuitJsonTo3dGltf;
|
|
65
|
+
declare const CircuitJsonTo3dPngModule_getDefaultCameraForCircuitJson: typeof getDefaultCameraForCircuitJson;
|
|
66
|
+
declare const CircuitJsonTo3dPngModule_renderCircuitJsonTo3dPng: typeof renderCircuitJsonTo3dPng;
|
|
67
|
+
declare namespace CircuitJsonTo3dPngModule {
|
|
68
|
+
export { CircuitJsonTo3dPngModule_CAMERA_PRESET_NAMES as CAMERA_PRESET_NAMES, type CircuitJsonTo3dPngModule_CameraOptions as CameraOptions, type CircuitJsonTo3dPngModule_CameraPreset as CameraPreset, type CircuitJsonTo3dPngModule_CircuitJson3dBaseOptions as CircuitJson3dBaseOptions, type CircuitJsonTo3dPngModule_ConvertCircuitJsonTo3dGltfResult as ConvertCircuitJsonTo3dGltfResult, type CircuitJsonTo3dPngModule_RenderCircuitJsonTo3dPngOptions as RenderCircuitJsonTo3dPngOptions, CircuitJsonTo3dPngModule_applyCameraPreset as applyCameraPreset, CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGlb as convertCircuitJsonTo3dGlb, CircuitJsonTo3dPngModule_convertCircuitJsonTo3dGltf as convertCircuitJsonTo3dGltf, CircuitJsonTo3dPngModule_getDefaultCameraForCircuitJson as getDefaultCameraForCircuitJson, CircuitJsonTo3dPngModule_renderCircuitJsonTo3dPng as renderCircuitJsonTo3dPng };
|
|
69
|
+
}
|
|
70
|
+
|
|
11
71
|
type SupplierPartNumberColumn = "JLCPCB Part #";
|
|
12
72
|
interface BomRow {
|
|
13
73
|
designator: string;
|
|
@@ -3462,10 +3522,11 @@ declare namespace KicadToCircuitJsonModule {
|
|
|
3462
3522
|
export { KicadToCircuitJsonModule_CollectFootprintsStage as CollectFootprintsStage, KicadToCircuitJsonModule_CollectGraphicsStage as CollectGraphicsStage, KicadToCircuitJsonModule_CollectLibrarySymbolsStage as CollectLibrarySymbolsStage, KicadToCircuitJsonModule_CollectNetsStage as CollectNetsStage, KicadToCircuitJsonModule_CollectSchematicTracesStage as CollectSchematicTracesStage, KicadToCircuitJsonModule_CollectSourceTracesStage as CollectSourceTracesStage, KicadToCircuitJsonModule_CollectSymbolLibrarySymbolsStage as CollectSymbolLibrarySymbolsStage, KicadToCircuitJsonModule_CollectTracesStage as CollectTracesStage, KicadToCircuitJsonModule_CollectViasStage as CollectViasStage, KicadToCircuitJsonModule_CollectZonesStage as CollectZonesStage, type KicadToCircuitJsonModule_ConverterContext as ConverterContext, KicadToCircuitJsonModule_ConverterStage as ConverterStage, KicadToCircuitJsonModule_InitializePcbContextStage as InitializePcbContextStage, KicadToCircuitJsonModule_InitializeSchematicContextStage as InitializeSchematicContextStage, KicadToCircuitJsonModule_InitializeSymbolLibraryContextStage as InitializeSymbolLibraryContextStage, KicadToCircuitJsonModule_KicadFootprintToCircuitJsonConverter as KicadFootprintToCircuitJsonConverter, KicadToCircuitJsonModule_KicadSymbolToCircuitJsonConverter as KicadSymbolToCircuitJsonConverter, KicadToCircuitJsonModule_KicadToCircuitJsonConverter as KicadToCircuitJsonConverter };
|
|
3463
3523
|
}
|
|
3464
3524
|
|
|
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"];
|
|
3525
|
+
declare const supportedModules: readonly ["circuit-json-to-3d-png", "circuit-json-to-bom-csv", "circuit-json-to-bpc", "circuit-json-to-connectivity-map", "circuit-json-to-gerber", "circuit-json-to-gltf", "circuit-json-to-kicad", "circuit-json-to-lbrn", "circuit-json-to-pnp-csv", "circuit-json-to-readable-netlist", "circuit-json-to-simple-3d", "circuit-json-to-spice", "circuit-json-to-step", "circuit-json-to-tscircuit", "circuit-to-canvas", "circuit-to-svg", "kicad-to-circuit-json"];
|
|
3466
3526
|
type SupportedModuleName = (typeof supportedModules)[number];
|
|
3467
3527
|
type SupportedModuleSpecifier = SupportedModuleName | `${SupportedModuleName}@${string}`;
|
|
3468
3528
|
interface SupportedModuleMap {
|
|
3529
|
+
"circuit-json-to-3d-png": typeof CircuitJsonTo3dPngModule;
|
|
3469
3530
|
"circuit-json-to-bom-csv": typeof CircuitJsonToBomCsvModule;
|
|
3470
3531
|
"circuit-json-to-bpc": typeof CircuitJsonToBpcModule;
|
|
3471
3532
|
"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.9",
|
|
4
4
|
"description": "Type-safe dynamic imports for selected tscircuit packages via jscdn and fallback to jsDelivr",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@biomejs/biome": "^2.0.5",
|
|
30
30
|
"@types/bun": "latest",
|
|
31
|
+
"circuit-json-to-3d-png": "0.0.7",
|
|
31
32
|
"circuit-json-to-bom-csv": "0.0.8",
|
|
32
33
|
"circuit-json-to-bpc": "0.0.13",
|
|
33
34
|
"circuit-json-to-connectivity-map": "0.0.23",
|