- Remove export from drawGoldenEyeball (internal function only) Makes it a private implementation detail in golden_eyeball.ts - Remove unused CACHE properties in video_comparer.ts: - titleCanvas, titleCtx, lastWidth, lastHeight, collapsed - Now only keeps frameCount, frameSkip, lastTime needed by AnimationCache - Remove dead cleanup code in onRemoved - Extract shared imageDataToUrl utility: - Create new comfy_utils.ts module - Update advanced_comparer.ts to import shared function - Update video_comparer.ts to import shared function - Eliminates duplicated URL building logic All 85 tests pass.
24 lines
1003 B
JavaScript
24 lines
1003 B
JavaScript
/**
|
|
* comfy_utils.ts
|
|
* Shared ComfyUI utility functions used across widgets
|
|
*/
|
|
// @ts-ignore - Runtime ComfyUI import
|
|
import { app } from "../../../scripts/app.js";
|
|
// @ts-ignore - Runtime ComfyUI import
|
|
import { api } from "../../../scripts/api.js";
|
|
/**
|
|
* Converts image data to a ComfyUI API URL
|
|
* @param data - Image data containing filename, type, and subfolder
|
|
* @returns API URL for the image, or empty string if data is invalid
|
|
*/
|
|
export function imageDataToUrl(data) {
|
|
if (!data || !data.filename) {
|
|
return "";
|
|
}
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const apiObj = api;
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const appObj = app;
|
|
return apiObj.apiURL(`/view?filename=${encodeURIComponent(data.filename)}&type=${encodeURIComponent(data.type || "")}&subfolder=${encodeURIComponent(data.subfolder || "")}${appObj.getPreviewFormatParam()}${appObj.getRandParam()}`);
|
|
}
|
|
//# sourceMappingURL=comfy_utils.js.map
|