Files
olivv-cs-ComfyUI-FunPack/app/shell/mounts.js
T
digital-garbage 5b59043fc8 core, app: a prompt you can type, on the main window
The prompt was a slot input on a CLIPTextEncode, reachable only by opening
the pipeline window and finding the node. A slot can now say that one of
its inputs belongs on the app's surface -- a place and a label -- and the
shell offers a region with that name or does not, exactly as a module's
panel works. Core validates that a role is names and nothing else.

Values for those inputs travel addressed by slot rather than as a whole
pipeline, so the window that owns the structure and a box that owns one
value cannot disagree about the slots between them. An address that is
not there is refused: a prompt typed into a box for a removed slot has
gone nowhere, and a run that starts anyway is not the run that was asked
for.

Region stand-ins are empty states now, taken down once something mounts --
'modules appear here' left above the modules that appeared explained
nothing to nobody.
2026-08-30 20:27:44 +03:00

52 lines
1.8 KiB
JavaScript

// Mount points are ANNOUNCED by the regions that offer them.
//
// A fixed list in core would be a global list -- the one thing the architecture
// avoids -- and it would have to be edited every time the shell grows a region.
// Instead a region says what it can host, and a module naming something no
// region offers is simply absent. That is "hide, don't warn" one level up.
const regions = new Map(); // mount point -> { host, standIn }
/**
* offer(mount, host, standIn?)
*
* `standIn` is what the region shows while nothing has mounted into it -- an
* empty state, not a label. It is taken down by settle() once something is
* there, because a region that says "modules appear here" ABOVE the modules
* that appeared is a region explaining itself to nobody.
*/
export function offer(mount, host, standIn = null) {
if (regions.has(mount)) {
throw new Error(`Mount point "${mount}" is already offered by another region.`);
}
regions.set(mount, { host, standIn });
return () => regions.delete(mount);
}
export const hostFor = (mount) => {
const region = regions.get(mount);
return region ? region.host : null;
};
export const offered = () => [...regions.keys()].sort();
export const claimed = (mount) => regions.has(mount);
/**
* Take down the stand-in of every region something mounted into.
*
* Called once, after everything that mounts has had its turn. Doing it as each
* one mounts would work too and would be wrong the moment two regions share a
* host: the one that mounted first would take down a stand-in belonging to
* both.
*/
export function settle() {
for (const { host, standIn } of regions.values()) {
if (!standIn || !standIn.parentNode) continue;
const others = [...host.children].filter((child) => child !== standIn);
if (others.length) standIn.remove();
}
}
export function _reset() {
regions.clear();
}