@tscircuit/internal-dynamic-import 0.0.0
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/README.md +22 -0
- package/dist/index.d.ts +3007 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// lib/index.ts
|
|
2
|
+
var supportedModules = [
|
|
3
|
+
"circuit-json-to-bom-csv",
|
|
4
|
+
"circuit-json-to-bpc",
|
|
5
|
+
"circuit-json-to-connectivity-map",
|
|
6
|
+
"circuit-json-to-gerber",
|
|
7
|
+
"circuit-json-to-gltf",
|
|
8
|
+
"circuit-json-to-kicad",
|
|
9
|
+
"circuit-json-to-lbrn",
|
|
10
|
+
"circuit-json-to-pnp-csv",
|
|
11
|
+
"circuit-json-to-readable-netlist",
|
|
12
|
+
"circuit-json-to-simple-3d",
|
|
13
|
+
"circuit-json-to-spice",
|
|
14
|
+
"circuit-json-to-step",
|
|
15
|
+
"circuit-json-to-tscircuit",
|
|
16
|
+
"circuit-to-canvas",
|
|
17
|
+
"circuit-to-svg"
|
|
18
|
+
];
|
|
19
|
+
var supportedModuleSet = new Set(supportedModules);
|
|
20
|
+
var getModuleName = (specifier) => {
|
|
21
|
+
const versionSeparatorIndex = specifier.indexOf("@");
|
|
22
|
+
return versionSeparatorIndex === -1 ? specifier : specifier.slice(0, versionSeparatorIndex);
|
|
23
|
+
};
|
|
24
|
+
var getImportUrl = (specifier) => {
|
|
25
|
+
const moduleName = getModuleName(specifier);
|
|
26
|
+
if (!supportedModuleSet.has(moduleName)) {
|
|
27
|
+
throw new Error(`Unsupported module: ${specifier}`);
|
|
28
|
+
}
|
|
29
|
+
return `https://esm.run/${specifier}`;
|
|
30
|
+
};
|
|
31
|
+
async function importer(specifier) {
|
|
32
|
+
return import(
|
|
33
|
+
/* @vite-ignore */
|
|
34
|
+
getImportUrl(specifier)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
var index_default = importer;
|
|
38
|
+
|
|
39
|
+
export { index_default as default, getImportUrl, supportedModules };
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/index.ts"],"names":[],"mappings":";AAgBO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,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;AACF;AAkCA,IAAM,kBAAA,GAAqB,IAAI,GAAA,CAAY,gBAAgB,CAAA;AAE3D,IAAM,aAAA,GAAgB,CAAC,SAAA,KAA8B;AACnD,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,CAAA;AAEO,IAAM,YAAA,GAAe,CAAC,SAAA,KAA8B;AACzD,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;AAEA,EAAA,OAAO,mBAAmB,SAAS,CAAA,CAAA;AACrC;AAMA,eAAe,SAAS,SAAA,EAAqC;AAC3D,EAAA,OAAO;AAAA;AAAA,IAA0B,aAAa,SAAS;AAAA,GAAA;AACzD;AAEA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["import 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\"\n\nexport const supportedModules = [\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] 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-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}\n\ntype 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\nconst supportedModuleSet = new Set<string>(supportedModules)\n\nconst getModuleName = (specifier: string): string => {\n const versionSeparatorIndex = specifier.indexOf(\"@\")\n return versionSeparatorIndex === -1\n ? specifier\n : specifier.slice(0, versionSeparatorIndex)\n}\n\nexport const getImportUrl = (specifier: string): string => {\n const moduleName = getModuleName(specifier)\n\n if (!supportedModuleSet.has(moduleName)) {\n throw new Error(`Unsupported module: ${specifier}`)\n }\n\n return `https://esm.run/${specifier}`\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 return import(/* @vite-ignore */ getImportUrl(specifier))\n}\n\nexport default importer\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tscircuit/internal-dynamic-import",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Type-safe dynamic imports for selected tscircuit packages via jsDelivr",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "bun run sync:type-bundles && tsup",
|
|
22
|
+
"format": "biome format --write .",
|
|
23
|
+
"format:check": "biome format .",
|
|
24
|
+
"sync:type-bundles": "node scripts/sync-type-bundles.mjs",
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"typecheck": "bun run sync:type-bundles && tsc --noEmit"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@biomejs/biome": "^2.0.5",
|
|
30
|
+
"@types/bun": "latest",
|
|
31
|
+
"circuit-json-to-bom-csv": "0.0.8",
|
|
32
|
+
"circuit-json-to-bpc": "0.0.13",
|
|
33
|
+
"circuit-json-to-connectivity-map": "0.0.23",
|
|
34
|
+
"circuit-json-to-gerber": "0.0.48",
|
|
35
|
+
"circuit-json-to-gltf": "0.0.88",
|
|
36
|
+
"circuit-json-to-kicad": "0.0.91",
|
|
37
|
+
"circuit-json-to-lbrn": "0.0.69",
|
|
38
|
+
"circuit-json-to-pnp-csv": "0.0.7",
|
|
39
|
+
"circuit-json-to-readable-netlist": "0.0.15",
|
|
40
|
+
"circuit-json-to-simple-3d": "0.0.9",
|
|
41
|
+
"circuit-json-to-spice": "0.0.34",
|
|
42
|
+
"circuit-json-to-step": "0.0.19",
|
|
43
|
+
"circuit-json-to-tscircuit": "0.0.14",
|
|
44
|
+
"circuit-to-canvas": "0.0.94",
|
|
45
|
+
"circuit-to-svg": "0.0.339",
|
|
46
|
+
"tsup": "8.5.1",
|
|
47
|
+
"typescript": "5.9.3"
|
|
48
|
+
}
|
|
49
|
+
}
|