diff --git a/js/common.js b/js/common.js
index 7090855f..666af62d 100644
--- a/js/common.js
+++ b/js/common.js
@@ -119,3 +119,93 @@ export async function free_models() {
show_message('Unloading of models failed.
Installed ComfyUI may be an outdated version.')
}
}
+
+export function md5(inputString) {
+ const hc = '0123456789abcdef';
+ const rh = n => {let j,s='';for(j=0;j<=3;j++) s+=hc.charAt((n>>(j*8+4))&0x0F)+hc.charAt((n>>(j*8))&0x0F);return s;}
+ const ad = (x,y) => {let l=(x&0xFFFF)+(y&0xFFFF);let m=(x>>16)+(y>>16)+(l>>16);return (m<<16)|(l&0xFFFF);}
+ const rl = (n,c) => (n<>>(32-c));
+ const cm = (q,a,b,x,s,t) => ad(rl(ad(ad(a,q),ad(x,t)),s),b);
+ const ff = (a,b,c,d,x,s,t) => cm((b&c)|((~b)&d),a,b,x,s,t);
+ const gg = (a,b,c,d,x,s,t) => cm((b&d)|(c&(~d)),a,b,x,s,t);
+ const hh = (a,b,c,d,x,s,t) => cm(b^c^d,a,b,x,s,t);
+ const ii = (a,b,c,d,x,s,t) => cm(c^(b|(~d)),a,b,x,s,t);
+ const sb = x => {
+ let i;const nblk=((x.length+8)>>6)+1;const blks=[];for(i=0;i>2]|=x.charCodeAt(i)<<((i%4)*8);}
+ blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=x.length*8;return blks;
+ }
+ let i,x=sb(inputString),a=1732584193,b=-271733879,c=-1732584194,d=271733878,olda,oldb,oldc,oldd;
+ for(i=0;i {
+ err = e;
+ });
+
+ if (!res) {
+ return {
+ status: 400,
+ error: new Error("Unknown Error")
+ }
+ }
+
+ const { status, statusText } = res;
+ if (err) {
+ return {
+ status,
+ error: err
+ }
+ }
+
+ if (status !== 200) {
+ return {
+ status,
+ error: new Error(statusText || "Unknown Error")
+ }
+ }
+
+ const data = await res.json();
+ if (!data) {
+ return {
+ status,
+ error: new Error(`Failed to load data: ${route}`)
+ }
+ }
+ return {
+ status,
+ data
+ }
+}
+
+export const icons = {
+ search: '',
+ extensions: '',
+ conflicts: ''
+}
\ No newline at end of file
diff --git a/js/custom-nodes-manager.js b/js/custom-nodes-manager.js
index fe56cb03..b85954b1 100644
--- a/js/custom-nodes-manager.js
+++ b/js/custom-nodes-manager.js
@@ -1,17 +1,14 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js"
import { $el } from "../../scripts/ui.js";
-import { manager_instance, rebootAPI, install_via_git_url } from "./common.js";
+import {
+ manager_instance, rebootAPI, install_via_git_url,
+ fetchData, md5, icons
+} from "./common.js";
// https://cenfun.github.io/turbogrid/api.html
import TG from "./turbogrid.esm.js";
-const icons = {
- search: '',
- extensions: '',
- conflicts: ''
-}
-
const pageCss = `
.cn-manager {
--grid-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
@@ -614,7 +611,7 @@ export class CustomNodesManager {
const grid = new TG.Grid(container);
this.grid = grid;
- let prevViewRowsLength = 0;
+ let prevViewRowsLength = -1;
grid.bind('onUpdated', (e, d) => {
const viewRows = grid.viewRows;
@@ -959,7 +956,7 @@ export class CustomNodesManager {
this.showStatus(`${label} ${item.title} ...`);
const data = item.originalData;
- const res = await this.fetchData(`/customnode/${mode}`, {
+ const res = await fetchData(`/customnode/${mode}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
@@ -1008,53 +1005,10 @@ export class CustomNodesManager {
// ===========================================================================================
- async fetchData(route, options) {
- let err;
- const res = await api.fetchApi(route, options).catch(e => {
- err = e;
- });
-
- if (!res) {
- return {
- status: 400,
- error: new Error("Unknown Error")
- }
- }
-
- const { status, statusText } = res;
- if (err) {
- return {
- status,
- error: err
- }
- }
-
- if (status !== 200) {
- return {
- status,
- error: new Error(statusText || "Unknown Error")
- }
- }
-
- const data = await res.json();
- if (!data) {
- return {
- status,
- error: new Error(`Failed to load data: ${route}`)
- }
- }
- return {
- status,
- data
- }
- }
-
- // ===========================================================================================
-
async getExtensionMappings() {
const mode = manager_instance.datasrc_combo.value;
this.showStatus(`Loading extension mappings (${mode}) ...`);
- const res = await this.fetchData(`/customnode/getmappings?mode=${mode}`);
+ const res = await fetchData(`/customnode/getmappings?mode=${mode}`);
if (res.error) {
console.log(res.error);
return {}
@@ -1108,7 +1062,7 @@ export class CustomNodesManager {
async getMissingNodes() {
const mode = manager_instance.datasrc_combo.value;
this.showStatus(`Loading missing nodes (${mode}) ...`);
- const res = await this.fetchData(`/customnode/getmappings?mode=${mode}`);
+ const res = await fetchData(`/customnode/getmappings?mode=${mode}`);
if (res.error) {
this.showError(`Failed to get custom node mappings: ${res.error}`);
return;
@@ -1178,7 +1132,7 @@ export class CustomNodesManager {
}
}
- const resUnresolved = await this.fetchData(`/component/get_unresolved`);
+ const resUnresolved = await fetchData(`/component/get_unresolved`);
const unresolved = resUnresolved.data;
if (unresolved && unresolved.nodes) {
unresolved.nodes.forEach(node_type => {
@@ -1202,7 +1156,7 @@ export class CustomNodesManager {
const mode = manager_instance.datasrc_combo.value;
this.showStatus(`Loading alternatives (${mode}) ...`);
- const res = await this.fetchData(`/customnode/alternatives?mode=${mode}`);
+ const res = await fetchData(`/customnode/alternatives?mode=${mode}`);
if (res.error) {
this.showError(`Failed to get alternatives: ${res.error}`);
return [];
@@ -1244,7 +1198,7 @@ export class CustomNodesManager {
this.showStatus(`Loading custom nodes (${mode}) ...`);
const skip_update = this.show_mode === ShowMode.UPDATE ? "" : "&skip_update=true";
- const res = await this.fetchData(`/customnode/getlist?mode=${mode}${skip_update}`);
+ const res = await fetchData(`/customnode/getlist?mode=${mode}${skip_update}`);
if (res.error) {
this.showError("Failed to get custom node list.");
this.hideLoading();
@@ -1261,7 +1215,8 @@ export class CustomNodesManager {
for (const item of custom_nodes) {
item.originalData = JSON.parse(JSON.stringify(item));
- item.hash = await calculateHash(item);
+ const message = item.title + item.files[0];
+ item.hash = md5(message);
}
const filterItem = this.getFilterItem(this.show_mode);
@@ -1430,54 +1385,4 @@ export class CustomNodesManager {
close() {
this.element.style.display = "none";
}
-}
-
-// ===========================================================================================
-
-async function calculateHash(item) {
- const message = item.title + item.files[0];
- return md5(message);
-}
-
-function md5(inputString) {
- const hc = '0123456789abcdef';
- const rh = n => {let j,s='';for(j=0;j<=3;j++) s+=hc.charAt((n>>(j*8+4))&0x0F)+hc.charAt((n>>(j*8))&0x0F);return s;}
- const ad = (x,y) => {let l=(x&0xFFFF)+(y&0xFFFF);let m=(x>>16)+(y>>16)+(l>>16);return (m<<16)|(l&0xFFFF);}
- const rl = (n,c) => (n<>>(32-c));
- const cm = (q,a,b,x,s,t) => ad(rl(ad(ad(a,q),ad(x,t)),s),b);
- const ff = (a,b,c,d,x,s,t) => cm((b&c)|((~b)&d),a,b,x,s,t);
- const gg = (a,b,c,d,x,s,t) => cm((b&d)|(c&(~d)),a,b,x,s,t);
- const hh = (a,b,c,d,x,s,t) => cm(b^c^d,a,b,x,s,t);
- const ii = (a,b,c,d,x,s,t) => cm(c^(b|(~d)),a,b,x,s,t);
- const sb = x => {
- let i;const nblk=((x.length+8)>>6)+1;const blks=[];for(i=0;i>2]|=x.charCodeAt(i)<<((i%4)*8);}
- blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=x.length*8;return blks;
- }
- let i,x=sb(inputString),a=1732584193,b=-271733879,c=-1732584194,d=271733878,olda,oldb,oldc,oldd;
- for(i=0;i