LCOV - code coverage report
Current view: top level - src/platform/billing - localBillingWebEnabled.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 14 14
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { readonly, ref } from 'vue'
       2              : 
       3              : import { canDesktopHostIssueBillingHandoff } from '@/platform/auth/desktopHost/desktopHostSession'
       4              : import { isCloud, isDesktop } from '@/platform/distribution/types'
       5              : 
       6         2356 : const enabled = ref(false)
       7         2356 : const cloudBillingNewUx = ref(false)
       8              : 
       9          188 : export function localSurface(): 'desktop' | 'local_web' {
      10          188 :   return isDesktop || window.__comfyDesktop2 !== undefined
      11              :     ? 'desktop'
      12              :     : 'local_web'
      13              : }
      14              : 
      15              : /** Cloud's `local_billing_web` as the local flag store last read it; false until a read succeeds. */
      16         2356 : export const localBillingWebEnabled = readonly(enabled)
      17              : 
      18         2390 : export function setLocalBillingWebEnabled(value: boolean): void {
      19         2390 :   enabled.value = value
      20              : }
      21              : 
      22         2390 : export function setLocalBillingNewUxEnabled(value: boolean): void {
      23         2390 :   cloudBillingNewUx.value = value
      24              : }
      25              : 
      26         8332 : export function opensLocalBillingHandoff(): boolean {
      27         8332 :   if (isCloud || !enabled.value) return false
      28         8332 :   return localSurface() === 'local_web' || canDesktopHostIssueBillingHandoff()
      29              : }
      30              : 
      31              : /** Cloud's `billing_new_ux_enabled` for the signed-in local account, counted only while the handoff its Platform and checkout links need is open. */
      32         8144 : export function showsCloudBillingNewUxOnLocal(): boolean {
      33         8144 :   return opensLocalBillingHandoff() && cloudBillingNewUx.value
      34              : }
        

Generated by: LCOV version 2.0-1