Files
MajoorWaldi-ComfyUI-Majoor-…/js/features/viewer/nodeStream/adapters/BaseAdapter.js
T
MajoorWaldi bd8b540160 feat(nodeStream): introduce Node Stream system with adapter registry
- Implement NodeStreamRegistry for managing adapters that handle ComfyUI node outputs.
- Create BaseAdapter interface for defining adapter structure and behavior.
- Add DefaultImageAdapter for standard image output handling.
- Implement KnownNodesAdapter for well-known ComfyUI nodes with specific output formats.
- Introduce VideoAdapter for handling video output from nodes.
- Establish NodeStream feature flag for controlled rollout.
- Add tests for NodeStreamController to ensure proper behavior when feature is disabled.
2026-03-17 22:30:56 +01:00

38 lines
1.2 KiB
JavaScript

/**
* BaseAdapter — interface contract for Node Stream adapters.
*
* Every adapter must implement:
* - name {string} Unique identifier
* - priority {number} Higher = matched first (default 0)
* - description {string} Human-readable label for UI
* - canHandle(classType, outputs) → boolean
* - extractMedia(classType, outputs, nodeId) → FileData[] | null
*
* FileData shape:
* { filename, subfolder, type, kind?, _nodeId?, _classType? }
*
* @typedef {{
* name: string,
* priority: number,
* description: string,
* canHandle: (classType: string, outputs: object) => boolean,
* extractMedia: (classType: string, outputs: object, nodeId: string) => Array<{filename:string, subfolder:string, type:string, kind?:string}> | null,
* }} NodeStreamAdapter
*/
/**
* Create an adapter from a plain config object.
* Fills in defaults for optional fields.
* @param {Partial<NodeStreamAdapter> & {name: string}} config
* @returns {NodeStreamAdapter}
*/
export function createAdapter(config) {
return {
priority: 0,
description: "",
canHandle: () => false,
extractMedia: () => null,
...config,
};
}