mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-16 16:32:34 +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="text/javascript" src="./lib/litegraph.extensions.js" defer></script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import { app } from "./scripts/app.js";
|
import { app } from "./scripts/app.js";
|
||||||
|
app.apiBase = "https://undertake-greek-possibly-mil.trycloudflare.com"
|
||||||
await app.setup();
|
await app.setup();
|
||||||
|
|
||||||
window.app = app;
|
window.app = app;
|
||||||
window.graph = app.graph;
|
window.graph = app.graph;
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1283,10 +1283,43 @@ export class ComfyApp {
|
|||||||
async #loadExtensions() {
|
async #loadExtensions() {
|
||||||
const extensions = await api.getExtensions();
|
const extensions = await api.getExtensions();
|
||||||
this.logging.addEntry("Comfy.App", "debug", { Extensions: extensions });
|
this.logging.addEntry("Comfy.App", "debug", { Extensions: extensions });
|
||||||
|
|
||||||
const extensionPromises = extensions.map(async ext => {
|
const extensionPromises = extensions.map(async ext => {
|
||||||
try {
|
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) {
|
} catch (error) {
|
||||||
console.error("Error loading extension", ext, error);
|
console.error("Error loading extension", ext, error);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user