Files
MajoorWaldi-ComfyUI-Majoor-…/js/features/stacks/executionAssetBuffer.js
T
MajoorWaldi 71ef418bdd feat: Implement sibling asset hiding logic for PNG files
- Added functions to manage sibling asset states and determine if PNG siblings should be hidden based on their context (video, audio, model3D).
- Refactored asset appending logic to utilize the new sibling hiding functionality.
- Updated the backend to prioritize image assets over video assets in the same stack group.
- Introduced a new execution asset buffer to manage job-related assets efficiently.
- Created tests for sibling hiding logic and execution asset buffer functionality.
2026-03-28 17:58:23 +01:00

57 lines
1.7 KiB
JavaScript

function _normalizeJobId(jobId) {
return String(jobId || "").trim();
}
function _assetBufferKey(file) {
const filename = String(file?.filename || "").trim();
const subfolder = String(file?.subfolder || "").trim();
const type = String(file?.type || "output")
.trim()
.toLowerCase();
const rootId = String(file?.root_id || file?.custom_root_id || "").trim();
return `${type}|${rootId}|${subfolder}|${filename}`;
}
export function createExecutionAssetBuffer() {
const jobs = new Map();
function add(jobId, files) {
const normalizedJobId = _normalizeJobId(jobId);
if (!normalizedJobId) return [];
const list = Array.isArray(files) ? files : [];
if (!list.length) return [];
let bucket = jobs.get(normalizedJobId);
if (!bucket) {
bucket = new Map();
jobs.set(normalizedJobId, bucket);
}
for (const file of list) {
const key = _assetBufferKey(file);
if (!key) continue;
bucket.set(key, { ...(bucket.get(key) || {}), ...(file || {}) });
}
return Array.from(bucket.values());
}
function take(jobId) {
const normalizedJobId = _normalizeJobId(jobId);
if (!normalizedJobId) return [];
const bucket = jobs.get(normalizedJobId);
jobs.delete(normalizedJobId);
return Array.from(bucket?.values?.() || []);
}
function clear(jobId) {
const normalizedJobId = _normalizeJobId(jobId);
if (!normalizedJobId) return;
jobs.delete(normalizedJobId);
}
return {
add,
take,
clear,
_jobs: jobs,
};
}