The gyre
API is accessible via globalThis.gyre
and provides various parameters, functions, and APIs to interact with the current open document, handle layers, manage dialogs, and more in a ComfyUI/Gyre installation.
layers: An array of all layers in the current open document.
createLayerInstance: Create layer instance defined by layer type. Such an instance can be used to add a layer via layerManager API (see below). An optional data object can be provided to fill layer properties.
gyre.createLayerInstance(
/** @type {string} */ name,
/** @type {string} */ type,
/** @type {object} */ layerFrom)
openDialog: Opens a dialog from any workflow in a ComfyUI/Gyre installation. These are usually dialogs added to a workflow used in a plugin. It has got the workflow name as the first parameter.
gyre.ComfyUI.openDialog(
/** @type {string} */ workflowName,
/** @type {object} */ formData,
/** @type {string} */ title = '',
/** @type {function} */newformdatacallback)
openDialogById: Same as openDialog
but it has got the workflow-id as the first parameter.
x
,y
).copy (callbackFunctions['copy']
):
Provide your own callback function to be executed when the user selects the menu entry or shortcut for the copy-to-clipboard operation. This allows an activated tool to put something from its own context into the clipboard. Make sure to delete this callback if the tool is destroyed.
paste (callbackFunctions['paste']
):
Provide your own callback function to be executed when the user selects the menu entry or shortcut for the paste-from-clipboard operation. This allows an activated tool to copy something from the clipboard into its own context. Make sure to delete this callback if the tool is destroyed.
onKeyDown (callbackFunctions['onKeyDown']
): Please use this callback if your plugin wants to support own shortcuts. It has got the HTML event object as only parameter. Typing in INPUT, TEXTARE or SELECT elements somewhere in the UI will be ignored so we highly recommend to use this callback instead your own keyboard handler. Make sure to delete this callback if the tool is destroyed.
The system provides an undo_redo_add
function that allows you to register actions for undo and redo, with custom callbacks to handle state restoration.
;
gyre.ComfyUI.executeWorkflow(
/** @type {string} */ workflowName,
/** @type {function} */ callback_finished,
/** @type {function} */ callBack_files,
/** @type {object} */ data,
/** @type {function} */ callback_error
)
gyre.ComfyUI.executeWorkflowById(
/** @type {string} */ workflowID
/** @type {function} */ callback_finished,
/** @type {function} */ callBack_files,
/** @type {object} */ data,
/** @type {function} */ callback_error
)
If you use the executeWorkflow
function please make sure that a unique name is used like one which is connected to plugin tag name (e.g. fds-image-editor-sam points
). So the end-user would be able to deactivate the default workflow and make a new one with same name (but with another ID) which will be used from the plugin. openDialog
or openDialogById
function to simple key-value structure which is used by executeWorkflow
and executeWorkflowById
.
data=gyre.ComfyUI.convertFormData(
/** @type {object} */ formData
)
width
, height
, scrollX
and scrollY
.
// Accessing the gyre API
const layers = globalThis..;
const tools = globalThis..;
// Using the layerManager API
globalThis...;
// Opening a dialog
globalThis..;
// Executing a workflow in ComfyUI
globalThis...;
// Canvas helper functions
const position = globalThis...;
const coords = globalThis...;