mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-17 00:43:48 +08:00
WIP idea of loading the files oddly
This commit is contained in:
parent
4a7a32a051
commit
86bcd911a4
@ -11,7 +11,9 @@
|
||||
<script type="text/javascript" src="./lib/litegraph.extensions.js" defer></script>
|
||||
<script type="module">
|
||||
import { app } from "./scripts/app.js";
|
||||
app.apiBase = "https://undertake-greek-possibly-mil.trycloudflare.com"
|
||||
await app.setup();
|
||||
|
||||
window.app = app;
|
||||
window.graph = app.graph;
|
||||
</script>
|
||||
|
||||
@ -1283,10 +1283,43 @@ export class ComfyApp {
|
||||
async #loadExtensions() {
|
||||
const extensions = await api.getExtensions();
|
||||
this.logging.addEntry("Comfy.App", "debug", { Extensions: extensions });
|
||||
|
||||
const extensionPromises = extensions.map(async ext => {
|
||||
try {
|
||||
await import(api.apiURL(ext));
|
||||
// Fetch the file as text
|
||||
const response = await fetch(api.apiURL(ext));
|
||||
let text = await response.text();
|
||||
const lines = text.split('\n');
|
||||
for (const line of lines) {
|
||||
// Process each line here
|
||||
if (line.startsWith("import")) {
|
||||
const match = line.match(/from "(.*)"/);
|
||||
if (match) {
|
||||
const importPath = match[1];
|
||||
if (importPath.startsWith("./")) {
|
||||
let file = importPath.substring(2);
|
||||
ext = ext.replace(/[^/]*$/, file)
|
||||
text = text.replace(line, line.replace(importPath, `${api.apiURL(ext)}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// text = text.replace(/import { app } from "..\/..\/scripts\/app.js"/, '');
|
||||
// text = text.replace(/import { app } from "..\/..\/scripts\/api.js"/, '');
|
||||
|
||||
// Act on the text here...
|
||||
|
||||
// Create a blob from the text
|
||||
const blob = new Blob([text], { type: 'text/javascript' });
|
||||
|
||||
// Create a URL for the blob
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
// Import the module from the blob URL
|
||||
await import(url);
|
||||
|
||||
|
||||
// await import(api.apiURL(ext));
|
||||
} catch (error) {
|
||||
console.error("Error loading extension", ext, error);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user