File size: 1,240 Bytes
7312c42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
interface CompareVideoWidget {
  name?: string
}

interface CompareVideoNodeInstance {
  hideOutputImages?: boolean
  onDrawBackground?: (context: CanvasRenderingContext2D) => void
  widgets?: CompareVideoWidget[]
  removeWidget?: (widget: CompareVideoWidget) => void
  videoContainer?: HTMLElement
  imgs?: unknown[]
}

interface CompareVideoNodeType {
  prototype: object
}

interface CompareVideoNodeDefinition {
  name?: string
}

export function suppressCompareVideoDefaultPreview(
  nodeType: CompareVideoNodeType,
  nodeData: CompareVideoNodeDefinition,
): void {
  if (nodeData.name !== 'easy compareVideos') return
  const prototype = nodeType.prototype as CompareVideoNodeInstance
  prototype.hideOutputImages = true
  prototype.onDrawBackground = function hideCompareVideoOutputPreview() {
    const defaultPreview = this.widgets?.find((widget) => widget.name === 'video-preview')
    if (defaultPreview && this.removeWidget) {
      try {
        this.removeWidget(defaultPreview)
      } catch (error) {
        console.error('[CompareVideoWidget] failed to remove the default video preview:', error)
      }
    }

    this.videoContainer?.replaceChildren()
    this.videoContainer = undefined
    this.imgs = undefined
  }
}