diff --git a/global.d.ts b/global.d.ts index 73019099a9..2134f9b492 100644 --- a/global.d.ts +++ b/global.d.ts @@ -5,6 +5,11 @@ declare const __ALGOLIA_APP_ID__: string declare const __ALGOLIA_API_KEY__: string declare const __USE_PROD_CONFIG__: boolean +type BuildFeatureFlags = { + REQUIRE_SUBSCRIPTION: boolean +} +declare const __BUILD_FLAGS__: BuildFeatureFlags + interface Navigator { /** * Used by the electron API. This is a WICG non-standard API, but is guaranteed to exist in Electron. diff --git a/src/components/actionbar/ComfyRunButton/index.ts b/src/components/actionbar/ComfyRunButton/index.ts index 917c25921d..4d15d44ee2 100644 --- a/src/components/actionbar/ComfyRunButton/index.ts +++ b/src/components/actionbar/ComfyRunButton/index.ts @@ -2,6 +2,6 @@ import { defineAsyncComponent } from 'vue' import { isCloud } from '@/platform/distribution/types' -export default isCloud +export default isCloud && __BUILD_FLAGS__.REQUIRE_SUBSCRIPTION ? defineAsyncComponent(() => import('./CloudRunButtonWrapper.vue')) : defineAsyncComponent(() => import('./ComfyQueueButton.vue')) diff --git a/src/extensions/core/index.ts b/src/extensions/core/index.ts index faf4bcaf72..31d73abee9 100644 --- a/src/extensions/core/index.ts +++ b/src/extensions/core/index.ts @@ -26,5 +26,8 @@ import './widgetInputs' if (isCloud) { import('./cloudBadge') - import('./cloudSubscription') + + if (__BUILD_FLAGS__.REQUIRE_SUBSCRIPTION) { + import('./cloudSubscription') + } } diff --git a/src/platform/cloud/subscription/composables/useSubscription.ts b/src/platform/cloud/subscription/composables/useSubscription.ts index 4d8e102ece..694cbe2397 100644 --- a/src/platform/cloud/subscription/composables/useSubscription.ts +++ b/src/platform/cloud/subscription/composables/useSubscription.ts @@ -26,7 +26,7 @@ interface CloudSubscriptionStatusResponse { const subscriptionStatus = ref(null) const isActiveSubscription = computed(() => { - if (!isCloud) return true + if (!isCloud || !__BUILD_FLAGS__.REQUIRE_SUBSCRIPTION) return true return subscriptionStatus.value?.is_active ?? false }) diff --git a/src/platform/settings/composables/useSettingUI.ts b/src/platform/settings/composables/useSettingUI.ts index c8e9be87a8..416df810ba 100644 --- a/src/platform/settings/composables/useSettingUI.ts +++ b/src/platform/settings/composables/useSettingUI.ts @@ -80,21 +80,22 @@ export function useSettingUI( ) } - const subscriptionPanel: SettingPanelItem | null = !isCloud - ? null - : { - node: { - key: 'subscription', - label: 'PlanCredits', - children: [] - }, - component: defineAsyncComponent( - () => - import( - '@/platform/cloud/subscription/components/SubscriptionPanel.vue' - ) - ) - } + const subscriptionPanel: SettingPanelItem | null = + !isCloud || !__BUILD_FLAGS__.REQUIRE_SUBSCRIPTION + ? null + : { + node: { + key: 'subscription', + label: 'PlanCredits', + children: [] + }, + component: defineAsyncComponent( + () => + import( + '@/platform/cloud/subscription/components/SubscriptionPanel.vue' + ) + ) + } const userPanel: SettingPanelItem = { node: { @@ -148,7 +149,9 @@ export function useSettingUI( keybindingPanel, extensionPanel, ...(isElectron() ? [serverConfigPanel] : []), - ...(isCloud && subscriptionPanel ? [subscriptionPanel] : []) + ...(isCloud && __BUILD_FLAGS__.REQUIRE_SUBSCRIPTION && subscriptionPanel + ? [subscriptionPanel] + : []) ].filter((panel) => panel.component) ) @@ -180,10 +183,16 @@ export function useSettingUI( label: 'Account', children: [ userPanel.node, - ...(isLoggedIn.value && isCloud && subscriptionPanel + ...(isLoggedIn.value && + isCloud && + __BUILD_FLAGS__.REQUIRE_SUBSCRIPTION && + subscriptionPanel ? [subscriptionPanel.node] : []), - ...(isLoggedIn.value && !isCloud ? [creditsPanel.node] : []) + ...(isLoggedIn.value && + !(isCloud && __BUILD_FLAGS__.REQUIRE_SUBSCRIPTION) + ? [creditsPanel.node] + : []) ].map(translateCategory) }, // Normal settings stored in the settingStore diff --git a/src/services/dialogService.ts b/src/services/dialogService.ts index 138f5be50b..ecd12766d7 100644 --- a/src/services/dialogService.ts +++ b/src/services/dialogService.ts @@ -488,7 +488,7 @@ export const useDialogService = () => { } function showSubscriptionRequiredDialog() { - if (!isCloud) { + if (!isCloud || !__BUILD_FLAGS__.REQUIRE_SUBSCRIPTION) { return } diff --git a/vite.config.mts b/vite.config.mts index 2a31570cf5..99c8d47aec 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -32,6 +32,10 @@ const DISTRIBUTION = (process.env.DISTRIBUTION || 'localhost') as | 'localhost' | 'cloud' +const BUILD_FLAGS = { + REQUIRE_SUBSCRIPTION: process.env.REQUIRE_SUBSCRIPTION === 'true' +} + export default defineConfig({ base: '', server: { @@ -267,7 +271,8 @@ export default defineConfig({ __ALGOLIA_APP_ID__: JSON.stringify(process.env.ALGOLIA_APP_ID || ''), __ALGOLIA_API_KEY__: JSON.stringify(process.env.ALGOLIA_API_KEY || ''), __USE_PROD_CONFIG__: process.env.USE_PROD_CONFIG === 'true', - __DISTRIBUTION__: JSON.stringify(DISTRIBUTION) + __DISTRIBUTION__: JSON.stringify(DISTRIBUTION), + __BUILD_FLAGS__: JSON.stringify(BUILD_FLAGS) }, resolve: { diff --git a/vitest.setup.ts b/vitest.setup.ts index 86e72cf521..8502a3de9d 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -9,6 +9,9 @@ globalThis.__ALGOLIA_APP_ID__ = '' globalThis.__ALGOLIA_API_KEY__ = '' globalThis.__USE_PROD_CONFIG__ = false globalThis.__DISTRIBUTION__ = 'localhost' +globalThis.__BUILD_FLAGS__ = { + REQUIRE_SUBSCRIPTION: true +} // Mock Worker for extendable-media-recorder globalThis.Worker = vi.fn().mockImplementation(() => ({