LCOV - code coverage report
Current view: top level - src/composables - useWorkspaceInset.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 76.5 % 17 13
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { onScopeDispose, watchEffect } from 'vue'
       2              : 
       3              : /**
       4              :  * Width consumed by docked surfaces on the right of the workspace.
       5              :  *
       6              :  * Body-portaled overlays center on the raw viewport, which diverges from the
       7              :  * visible workspace once a docked surface takes layout width. They read this
       8              :  * variable to offset themselves; docked surfaces declare it.
       9              :  */
      10            1 : export const WORKSPACE_INSET_RIGHT = '--workspace-inset-right'
      11              : 
      12            1 : const insetPublishers = new Map<symbol, number>()
      13              : 
      14            1 : function publishCurrentInset(): void {
      15            1 :   const widths = [...insetPublishers.values()]
      16            1 :   if (widths.length === 0) {
      17            0 :     document.documentElement.style.removeProperty(WORKSPACE_INSET_RIGHT)
      18            0 :     return
      19              :   }
      20            1 :   const width = Math.max(...widths)
      21            1 :   document.documentElement.style.setProperty(
      22              :     WORKSPACE_INSET_RIGHT,
      23              :     `${width}px`
      24              :   )
      25              : }
      26              : 
      27            1 : export function useWorkspaceInsetRight(widthPx: () => number): void {
      28            1 :   const publisher = Symbol()
      29            1 :   watchEffect(() => {
      30            1 :     insetPublishers.set(publisher, widthPx())
      31            1 :     publishCurrentInset()
      32              :   })
      33            1 :   onScopeDispose(() => {
      34            0 :     insetPublishers.delete(publisher)
      35            0 :     publishCurrentInset()
      36              :   })
      37              : }
        

Generated by: LCOV version 2.0-1