o
    i`                     @  sr  U d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ ddlmZmZmZmZmZ dd	lmZmZ dd
lmZmZmZmZmZmZ ddlmZ ddlm Z! d dl"m#Z# d dl$m%Z%m&Z& d dl'm(Z( d dl)m*Z* d dl+Z,G dd deZ-G dd deZ.G dd dZ/G dd dZ0G dd dZ1e-j2Z2e-Z3erd dl4Z5de6d< ee-Z7eZ8e!Z9g dZ:dS )    )annotations)ABCabstractmethod)TYPE_CHECKING)ComfyAPIBase)ProxiedSingleton)create_sync_class   )
ImageInput
AudioInput	MaskInputLatentInput
VideoInput)VideoFromFileVideoFromComponents)
VideoCodecVideoContainerVideoComponentsMESHVOXELFile3D)
_io_public)
_ui_public)get_executing_context)get_progress_statePreviewImageTuple)Image)argsNc                      sT   e Zd ZdZdZ fddZG dd deZG dd deZG d	d
 d
eZ	  Z
S )ComfyAPI_latestlatestFc                   s,   t    |  | _|  | _|  | _d S )N)super__init__NodeReplacementnode_replacement	Execution	executionCachingcachingself	__class__ 7/mnt/c/Users/fbmor/ComfyUI/comfy_api/latest/__init__.pyr!      s   


zComfyAPI_latest.__init__c                   @  s   e Zd ZdddZdS )	zComfyAPI_latest.NodeReplacementnode_replaceio.NodeReplacereturnNonec                   s    ddl m} |jj| dS )z$Register a node replacement mapping.r   )PromptServerN)serverr2   instancenode_replace_managerregister)r)   r.   r2   r,   r,   r-   r6      s   z(ComfyAPI_latest.NodeReplacement.registerN)r.   r/   r0   r1   )__name__
__module____qualname__r6   r,   r,   r,   r-   r"      s    r"   c                   @  s   e Zd Z			ddddZdS )zComfyAPI_latest.ExecutionNFvaluefloat	max_valuenode_id
str | Nonepreview_imageImage.Image | ImageInput | Noneignore_size_limitboolr0   r1   c                   s   t  }|du r|dur|j}|du rtd|}|durZt|tr@|}t|jdkr/|d }|  d 	t
j}	t|	}t|tjrZ|jrL|jnd}
|rRdntj}|
||f}t j||||d dS )aM  
            Update the progress bar displayed in the ComfyUI interface.

            This function allows custom nodes and API calls to report their progress
            back to the user interface, providing visual feedback during long operations.

            Migration from previous API: comfy.utils.PROGRESS_BAR_HOOK
            Nz4node_id must be provided if not in executing context   r      JPEG)r=   r:   r<   image)r   r=   
ValueError
isinstancer
   lenshapecpunumpyastypenpuint8r   	fromarrayformatr   preview_sizer   update_progress)r)   r:   r<   r=   r?   rA   executing_context
to_displaytensorimage_npimage_formatrR   r,   r,   r-   set_progress%   s0   



z&ComfyAPI_latest.Execution.set_progress)NNF)r:   r;   r<   r;   r=   r>   r?   r@   rA   rB   r0   r1   )r7   r8   r9   rY   r,   r,   r,   r-   r$   $   s
    r$   c                   @  s8   e Zd ZdZddlmZmZmZ ddd	Zdd
dZ	dS )zComfyAPI_latest.Cachinga  
        External cache provider API for sharing cached node outputs
        across ComfyUI instances.

        Example::

            from comfy_api.latest import Caching

            class MyCacheProvider(Caching.CacheProvider):
                async def on_lookup(self, context):
                    ...  # check external storage

                async def on_store(self, context, value):
                    ...  # store to external storage

            Caching.register_provider(MyCacheProvider())
        r	   )CacheProviderCacheContext
CacheValueprovider''ComfyAPI_latest.Caching.CacheProvider'r0   r1   c                      ddl m} || dS )zPRegister an external cache provider. Providers are called in registration order.r   )register_cache_providerN)comfy_execution.cache_providerr`   )r)   r]   r`   r,   r,   r-   register_providerl      z)ComfyAPI_latest.Caching.register_providerc                   r_   )z2Unregister a previously registered cache provider.r   )unregister_cache_providerN)ra   rd   )r)   r]   rd   r,   r,   r-   unregister_providerq   rc   z+ComfyAPI_latest.Caching.unregister_providerN)r]   r^   r0   r1   )
r7   r8   r9   __doc___cachingrZ   r[   r\   rb   re   r,   r,   r,   r-   r&   X   s
    
r&   )r7   r8   r9   VERSIONSTABLEr!   r   r"   r$   r&   __classcell__r,   r,   r*   r-   r      s    4r   c                   @  s$   e Zd Zd	ddZed
ddZdS )ComfyExtensionr0   r1   c                      dS )z
        Called when an extension is loaded.
        This should be used to initialize any global resources needed by the extension.
        Nr,   r(   r,   r,   r-   on_loadw       zComfyExtension.on_loadlist[type[io.ComfyNode]]c                   rl   )zG
        Returns a list of nodes that this extension provides.
        Nr,   r(   r,   r,   r-   get_node_list}   rn   zComfyExtension.get_node_listN)r0   r1   )r0   ro   )r7   r8   r9   rm   r   rp   r,   r,   r,   r-   rk   v   s    
rk   c                   @  s    e Zd ZeZeZeZe	Z
eZdS )InputN)r7   r8   r9   r
   r   r   Audior   Maskr   Latentr   Videor,   r,   r,   r-   rq      s    rq   c                   @  s   e Zd ZeZeZdS )	InputImplN)r7   r8   r9   r   r   r,   r,   r,   r-   rv      s    rv   c                   @  s$   e Zd ZeZeZeZeZeZeZdS )TypesN)	r7   r8   r9   r   r   r   r   r   r   r,   r,   r,   r-   rw      s    rw   zBtype[comfy_api.latest.generated.ComfyAPISyncStub.ComfyAPISyncStub]ComfyAPISync)ComfyAPIrx   rq   rv   rw   r&   rk   ioIOuiUI);
__future__r   abcr   r   typingr   comfy_api.internalr   comfy_api.internal.singletonr    comfy_api.internal.async_to_syncr   _inputr
   r   r   r   r   _input_implr   r   _utilr   r   r   r   r   r    r   rz   r   r|   comfy_execution.utilsr   comfy_execution.progressr   r   PILr   comfy.cli_argsr   rL   rN   r   rk   rq   rv   rw   r&   ry   +comfy_api.latest.generated.ComfyAPISyncStub	comfy_api__annotations__rx   r{   r}   __all__r,   r,   r,   r-   <module>   s<     b	