Skip to content

Commit

Permalink
Mount vue app after comfy app init (#167)
Browse files Browse the repository at this point in the history
* Mount vue app after comfy app

* Emit event when vue app loaded

* Dispatch event to window

* Fix test timeout

* Try observe variable

* Revert

* Update test expectations [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
huchenlei and github-actions authored Jul 19, 2024
1 parent 396e0c9 commit a2afdd7
Show file tree
Hide file tree
Showing 25 changed files with 24 additions and 21 deletions.
3 changes: 1 addition & 2 deletions browser_tests/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ export const comfyPageFixture = base.extend<{ comfyPage: ComfyPage }>({
font-family: 'Roboto Mono', 'Noto Color Emoji';
}`,
});

await page.waitForFunction(() => document.fonts.ready);
await page.waitForFunction(() => window["app"] != undefined);
await page.waitForFunction(() => window["app"] !== undefined);
await page.evaluate(() => {
window["app"]["canvas"].show_info = false;
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineConfig({
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
timeout: 3000,
timeout: 5000,
},

// {
Expand Down
7 changes: 5 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import { onMounted, onUnmounted, provide, ref } from "vue";
import NodeSearchboxPopover from "@/components/NodeSearchBoxPopover.vue";
import ProgressSpinner from "primevue/progressspinner";
import { api } from "@/scripts/api";
import {
NodeSearchService,
SYSTEM_NODE_DEFS,
} from "./services/nodeSearchService";
import { ColorPaletteLoadedEvent } from "./types/colorPalette";
import { LiteGraphNodeSearchSettingEvent } from "./scripts/ui";
import { app } from "./scripts/app";
const isLoading = ref(true);
const nodeSearchEnabled = ref(false);
Expand All @@ -37,7 +37,7 @@ const updateNodeSearchSetting = (e: LiteGraphNodeSearchSettingEvent) => {
};
const init = async () => {
const nodeDefs = Object.values(await api.getNodeDefs());
const nodeDefs = Object.values(app.nodeDefs);
nodeSearchService.value = new NodeSearchService([
...nodeDefs,
...SYSTEM_NODE_DEFS,
Expand All @@ -48,6 +48,9 @@ const init = async () => {
"comfy:setting:litegraph-node-search",
updateNodeSearchSetting
);
app.ui.settings.refreshSetting("Comfy.NodeSearchBoxImpl");
app.ui.settings.refreshSetting("Comfy.ColorPalette");
};
onMounted(async () => {
Expand Down
29 changes: 15 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ import App from "./App.vue";
import { app as comfyApp } from "@/scripts/app";

const app = createApp(App);
app
.use(PrimeVue, {
theme: {
preset: Aura,
options: {
prefix: "p",
cssLayer: false,
// This is a workaround for the issue with the dark mode selector
// https://github.com/primefaces/primevue/issues/5515
darkModeSelector: ".dark-theme, :root:has(.dark-theme)",
},
},
})
.mount("#vue-app");

comfyApp.setup().then(() => {
window["app"] = comfyApp;
window["graph"] = comfyApp.graph;

app
.use(PrimeVue, {
theme: {
preset: Aura,
options: {
prefix: "p",
cssLayer: false,
// This is a workaround for the issue with the dark mode selector
// https://github.com/primefaces/primevue/issues/5515
darkModeSelector: ".dark-theme, :root:has(.dark-theme)",
},
},
})
.mount("#vue-app");
});
4 changes: 2 additions & 2 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class ComfyApp {
bodyRight: HTMLElement;
bodyBottom: HTMLElement;
menu: ComfyAppMenu;
nodeDefs: Record<string, ComfyNodeDef>;

constructor() {
this.ui = new ComfyUI(this);
Expand Down Expand Up @@ -1871,7 +1872,6 @@ export class ComfyApp {
this.#addAfterConfigureHandler();

this.canvas = new LGraphCanvas(canvasEl, this.graph);
this.ui.settings.refreshSetting("Comfy.NodeSearchBoxImpl");
this.ctx = canvasEl.getContext("2d");

LiteGraph.release_link_on_empty_shows_menu = true;
Expand Down Expand Up @@ -1955,9 +1955,9 @@ export class ComfyApp {
* Registers nodes with the graph
*/
async registerNodes() {
const app = this;
// Load node definitions from the backend
const defs = await api.getNodeDefs();
this.nodeDefs = defs;
await this.registerNodesFromDefs(defs);
await this.#invokeExtensionsAsync("registerCustomNodes");
}
Expand Down

0 comments on commit a2afdd7

Please sign in to comment.