Use npm package @ComfyOrg/litegraph (#89)

* Use npm to manage litegraph

* Fix merge issues caused by BetaUI change

* Switch to @comfyorg/litegraph

* Fix various import

* Fix css apply order bug

* Fix package lock

* Update litegraph

* Update litegraph

* Update browsertest expectations

* Update test expectations [skip ci]

* Fix default view screenshot

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-07-05 20:53:47 -04:00
committed by GitHub
parent 27c5bc1581
commit d6b2d5fb4f
63 changed files with 472 additions and 17982 deletions

View File

@@ -1,4 +1,10 @@
import { app } from "../../scripts/app";
import {
LGraphCanvas,
LGraphNode,
LGraphGroup,
LiteGraph,
} from "@comfyorg/litegraph";
// Shift + drag/resize to snap to grid
@@ -77,12 +83,14 @@ app.registerExtension({
let w, h;
if (node.flags.collapsed) {
// @ts-ignore
w = node._collapsed_width;
h = LiteGraph.NODE_TITLE_HEIGHT;
shiftY -= LiteGraph.NODE_TITLE_HEIGHT;
} else {
w = node.size[0];
h = node.size[1];
// @ts-ignore
let titleMode = node.constructor.title_mode;
if (
titleMode !== LiteGraph.TRANSPARENT_TITLE &&
@@ -105,7 +113,7 @@ app.registerExtension({
* The currently moving, selected group only. Set after the `selected_group` has actually started
* moving.
*/
let selectedAndMovingGroup = null;
let selectedAndMovingGroup: LGraphGroup | null = null;
/**
* Handles moving a group; tracking when a group has been moved (to show the ghost in `drawGroups`
@@ -154,13 +162,16 @@ app.registerExtension({
LGraphCanvas.prototype.drawGroups = function (canvas, ctx) {
if (this.selected_group && app.shiftDown) {
if (this.selected_group_resizing) {
// @ts-ignore
roundVectorToGrid(this.selected_group.size);
} else if (selectedAndMovingGroup) {
// @ts-ignore
const [x, y] = roundVectorToGrid([...selectedAndMovingGroup.pos]);
const f = ctx.fillStyle;
const s = ctx.strokeStyle;
ctx.fillStyle = "rgba(100, 100, 100, 0.33)";
ctx.strokeStyle = "rgba(100, 100, 100, 0.66)";
// @ts-ignore
ctx.rect(x, y, ...selectedAndMovingGroup.size);
ctx.fill();
ctx.stroke();