Skip to content

Commit da93e3c

Browse files
authored
Fix repl/importmap.js (#64)
1 parent c56affc commit da93e3c

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

repl/importmap.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
1+
/**
2+
* @param {string} content - The content.
3+
* @returns {string} data:text string
4+
*/
15
function importFile(content) {
26
return "data:text/javascript;base64," + btoa(content);
37
}
48
let rti = "../";
59
if (location.host === 'runtimetypeinspector.org') {
6-
rti = '/node_modules/runtime-type-inspector/';
10+
rti = '/node_modules/runtime-type-inspector/';
711
}
812
const imports = {
13+
"@runtime-type-inspector/runtime": rti + 'src-runtime/index.mjs',
914
"runtime-type-inspector/": rti,
1015
//"@babel/core": "./babel-core.mjs",
1116
"@babel/parser": "./babel-parser.mjs",
1217
//"@babel/helper-plugin-utils": "./babel-helper-plugin-utils.mjs",
1318
//"@babel/plugin-syntax-typescript": "./babel-plugin-syntax-typescript.mjs",
1419
"fs": importFile("export default {};"),
1520
"typescript": importFile("export default ts;"), // UMD import
16-
/*
17-
"path": importFile("export default {};"),
18-
"stream/web": importFile("export default {};"),
19-
"sharp": importFile("export default {};"),
20-
"onnxruntime-node": importFile("export default {};"),
21-
"onnxruntime-web": importFile(`
22-
//await import("https://cdnjs.cloudflare.com/ajax/libs/onnxruntime-web/1.15.0/ort.es6.min.js");
23-
await import("https://cdnjs.cloudflare.com/ajax/libs/onnxruntime-web/1.14.0/ort.es6.min.js");
24-
//http://127.0.0.1/transformer/onnxruntime/js/common/dist/
25-
//await import("http://127.0.0.1/transformer/onnxruntime/js/common/dist/ort-common.js");
26-
//await import("http://127.0.0.1/transformer/onnxruntime/js/web/dist/ort-webgl.js");
27-
//await import("https://cdnjs.cloudflare.com/ajax/libs/onnxruntime-web/1.14.0/ort.es6.min.js");
28-
let ONNX = globalThis.ort;
29-
export default ONNX;
30-
export {
31-
ONNX
32-
};
33-
`),
34-
*/
21+
// "path": importFile("export default {};"),
22+
// "stream/web": importFile("export default {};"),
23+
// "sharp": importFile("export default {};"),
24+
// "onnxruntime-node": importFile("export default {};"),
25+
// "onnxruntime-web": importFile(`
26+
// //await import("https://cdnjs.cloudflare.com/ajax/libs/onnxruntime-web/1.15.0/ort.es6.min.js");
27+
// await import("https://cdnjs.cloudflare.com/ajax/libs/onnxruntime-web/1.14.0/ort.es6.min.js");
28+
// //http://127.0.0.1/transformer/onnxruntime/js/common/dist/
29+
// //await import("http://127.0.0.1/transformer/onnxruntime/js/common/dist/ort-common.js");
30+
// //await import("http://127.0.0.1/transformer/onnxruntime/js/web/dist/ort-webgl.js");
31+
// //await import("https://cdnjs.cloudflare.com/ajax/libs/onnxruntime-web/1.14.0/ort.es6.min.js");
32+
// let ONNX = globalThis.ort;
33+
// export default ONNX;
34+
// export {
35+
// ONNX
36+
// };
37+
// `),
3538
};
3639
const importmap = document.createElement("script");
3740
importmap.type = "importmap";
3841
importmap.textContent = JSON.stringify({imports});
39-
const parent = document.body || document.head;
40-
if (!parent) {
41-
throw "neither <body> nor <head> available to append importmap";
42+
const dom = document.body || document.head;
43+
if (!dom) {
44+
throw new Error("neither <body> nor <head> available to append importmap");
4245
}
43-
parent.append(importmap);
46+
dom.append(importmap);

0 commit comments

Comments
 (0)