mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-07-17 09:18:26 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99674df73b | ||
|
|
cfaf89edea | ||
|
|
a154e6a311 | ||
|
|
46fec1d47d | ||
|
|
1052658a02 | ||
|
|
f524683f3c | ||
|
|
d1d55585f9 | ||
|
|
98c654df20 | ||
|
|
5bce9c4874 | ||
|
|
6ac9b653bb | ||
|
|
86bccf8d4c | ||
|
|
b52f6ce764 | ||
|
|
5da3e16f33 | ||
|
|
6d0bbd7d7c | ||
|
|
4341972be3 | ||
|
|
98700cfcc7 |
9
.fallowrc.json
Normal file
9
.fallowrc.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json",
|
||||
"entry": ["src/main.ts", "index.html"],
|
||||
"duplicates": {
|
||||
"minOccurrences": 3,
|
||||
"ignore": ["**/*.generated.*", "**/generatedManagerTypes.ts"]
|
||||
},
|
||||
"rules": {}
|
||||
}
|
||||
8
.github/workflows/ci-tests-e2e.yaml
vendored
8
.github/workflows/ci-tests-e2e.yaml
vendored
@@ -73,8 +73,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
|
||||
shardTotal: [8]
|
||||
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
|
||||
shardTotal: [16]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
@@ -93,7 +93,7 @@ jobs:
|
||||
# Run sharded tests (browsers pre-installed in container)
|
||||
- name: Run Playwright tests (Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
|
||||
id: playwright
|
||||
run: pnpm exec playwright test --project=chromium --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter=blob
|
||||
run: pnpm exec playwright test --project=chromium --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
||||
env:
|
||||
PLAYWRIGHT_BLOB_OUTPUT_DIR: ./blob-report
|
||||
COLLECT_COVERAGE: 'true'
|
||||
@@ -150,7 +150,7 @@ jobs:
|
||||
# Run tests (browsers pre-installed in container)
|
||||
- name: Run Playwright tests (${{ matrix.browser }})
|
||||
id: playwright
|
||||
run: pnpm exec playwright test --project=${{ matrix.browser }} --reporter=blob
|
||||
run: pnpm exec playwright test --project=${{ matrix.browser }}
|
||||
env:
|
||||
PLAYWRIGHT_BLOB_OUTPUT_DIR: ./blob-report
|
||||
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,6 +16,7 @@ yarn.lock
|
||||
.eslintcache
|
||||
.prettiercache
|
||||
.stylelintcache
|
||||
.fallow/
|
||||
|
||||
node_modules
|
||||
.pnpm-store
|
||||
|
||||
@@ -88,6 +88,11 @@ const config: StorybookConfig = {
|
||||
replacement:
|
||||
process.cwd() + '/src/storybook/mocks/useFeatureFlags.ts'
|
||||
},
|
||||
{
|
||||
find: '@/platform/workspace/composables/useWorkspaceUI',
|
||||
replacement:
|
||||
process.cwd() + '/src/storybook/mocks/useWorkspaceUI.ts'
|
||||
},
|
||||
{
|
||||
find: '@/platform/workspace/stores/teamWorkspaceStore',
|
||||
replacement:
|
||||
|
||||
@@ -10,11 +10,13 @@ const PAYMENT_STATUSES = ['success', 'failed'] as const
|
||||
const LOCALE_PREFIXES = LOCALES.map((locale) =>
|
||||
locale === DEFAULT_LOCALE ? '' : `/${locale}`
|
||||
)
|
||||
const SITEMAP_EXCLUDED_PATHNAMES = new Set(
|
||||
LOCALE_PREFIXES.flatMap((prefix) =>
|
||||
const SITEMAP_EXCLUDED_PATHNAMES = new Set([
|
||||
...LOCALE_PREFIXES.flatMap((prefix) =>
|
||||
PAYMENT_STATUSES.map((status) => `${prefix}/payment/${status}`)
|
||||
)
|
||||
)
|
||||
),
|
||||
...LOCALE_PREFIXES.map((prefix) => `${prefix}/individual-submission`),
|
||||
...LOCALE_PREFIXES.map((prefix) => `${prefix}/booking-confirmation`)
|
||||
])
|
||||
|
||||
function isExcludedFromSitemap(page: string): boolean {
|
||||
const pathname = new URL(page).pathname.replace(/\/$/, '')
|
||||
|
||||
51
apps/website/e2e/brand.spec.ts
Normal file
51
apps/website/e2e/brand.spec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { expect } from '@playwright/test'
|
||||
|
||||
import { BRAND_ASSETS_ZIP, BRAND_GUIDELINES_PDF } from '../src/data/brandAssets'
|
||||
import { test } from './fixtures/blockExternalMedia'
|
||||
|
||||
test.describe('Brand portal @smoke', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/brand')
|
||||
})
|
||||
|
||||
test('renders each brand guideline section', async ({ page }) => {
|
||||
await expect(
|
||||
page.getByRole('heading', { level: 1, name: 'Create with ComfyUI' })
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'One mark, many dimensions.' })
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Every color earns its place.' })
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Precise, never cute.' })
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Trademark guidelines.' })
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('shows all four marks', async ({ page }) => {
|
||||
const logos = page.locator('#logos')
|
||||
for (const name of [
|
||||
'Core Logo',
|
||||
'Logomark',
|
||||
'Icon',
|
||||
'Amplified Logomark'
|
||||
]) {
|
||||
await expect(logos.getByText(name, { exact: true })).toBeVisible()
|
||||
}
|
||||
})
|
||||
|
||||
test('the hero ctas open the gated guidelines and the logo bundle', async ({
|
||||
page
|
||||
}) => {
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'View brand guidelines' })
|
||||
).toHaveAttribute('href', BRAND_GUIDELINES_PDF)
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'Download logos' })
|
||||
).toHaveAttribute('href', BRAND_ASSETS_ZIP)
|
||||
})
|
||||
})
|
||||
112
apps/website/e2e/mcp.spec.ts
Normal file
112
apps/website/e2e/mcp.spec.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import { expect } from '@playwright/test'
|
||||
|
||||
import { test } from './fixtures/blockExternalMedia'
|
||||
|
||||
const MCP_ENDPOINT = 'https://cloud.comfy.org/mcp'
|
||||
|
||||
test.describe('MCP page @smoke', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/mcp')
|
||||
})
|
||||
|
||||
test('hero and how-it-works INSTALL MCP CTAs anchor to setup', async ({
|
||||
page
|
||||
}) => {
|
||||
const installLinks = page.getByRole('link', { name: 'INSTALL MCP' })
|
||||
await expect(installLinks).toHaveCount(2)
|
||||
for (const link of await installLinks.all()) {
|
||||
await expect(link).toHaveAttribute('href', '#setup')
|
||||
}
|
||||
})
|
||||
|
||||
test('setup section shows both install options', async ({ page }) => {
|
||||
const setup = page.locator('#setup')
|
||||
await setup.scrollIntoViewIfNeeded()
|
||||
await expect(
|
||||
setup.getByRole('heading', {
|
||||
name: 'Ask your agent to install Comfy MCP'
|
||||
})
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
setup.getByRole('heading', { name: 'Install manually' })
|
||||
).toBeVisible()
|
||||
await expect(setup.getByText(MCP_ENDPOINT, { exact: true })).toBeVisible()
|
||||
})
|
||||
|
||||
test('client tabs swap install instructions', async ({ page }) => {
|
||||
const setup = page.locator('#setup')
|
||||
await setup.scrollIntoViewIfNeeded()
|
||||
const activePanel = setup.locator('[role="tabpanel"][data-state="active"]')
|
||||
|
||||
// Claude Code is the default tab and carries the CLI command
|
||||
await expect(
|
||||
setup.getByRole('tab', { name: 'Claude Code' })
|
||||
).toHaveAttribute('data-state', 'active')
|
||||
await expect(activePanel).toContainText(
|
||||
`claude mcp add --transport http comfy-cloud ${MCP_ENDPOINT}`
|
||||
)
|
||||
|
||||
await setup.getByRole('tab', { name: 'Claude Desktop' }).click()
|
||||
await expect(activePanel).toContainText('Add custom connector')
|
||||
|
||||
await setup.getByRole('tab', { name: 'Cursor' }).click()
|
||||
await expect(activePanel).toContainText('X-API-Key')
|
||||
await expect(
|
||||
activePanel.getByRole('link', { name: 'platform.comfy.org' })
|
||||
).toHaveAttribute('href', 'https://platform.comfy.org/profile/api-keys')
|
||||
|
||||
await setup.getByRole('tab', { name: 'Codex' }).click()
|
||||
await expect(activePanel).toContainText(
|
||||
`codex mcp add comfy-cloud --url ${MCP_ENDPOINT}`
|
||||
)
|
||||
})
|
||||
|
||||
test('skills plugin link lives in the agent option card', async ({
|
||||
page
|
||||
}) => {
|
||||
const setup = page.locator('#setup')
|
||||
await setup.scrollIntoViewIfNeeded()
|
||||
await expect(
|
||||
setup.getByRole('link', { name: 'View on GitHub' })
|
||||
).toHaveAttribute('href', 'https://github.com/Comfy-Org/comfy-skills')
|
||||
})
|
||||
|
||||
test('capabilities section shows all six tool cards', async ({ page }) => {
|
||||
for (const title of [
|
||||
'Generate anything',
|
||||
'Search the ecosystem',
|
||||
'Run real workflows',
|
||||
'Direct any model',
|
||||
'Generate in batches',
|
||||
'Ship it as an app'
|
||||
]) {
|
||||
await expect(
|
||||
page.getByRole('heading', { name: title, exact: true })
|
||||
).toBeVisible()
|
||||
}
|
||||
})
|
||||
|
||||
test('FAQ lists nine questions and autolinks the server URL', async ({
|
||||
page
|
||||
}) => {
|
||||
const triggers = page.locator('[id^="faq-trigger-"]')
|
||||
await triggers.first().scrollIntoViewIfNeeded()
|
||||
await expect(triggers).toHaveCount(9)
|
||||
|
||||
await page.getByRole('button', { name: "What's the server URL?" }).click()
|
||||
await expect(
|
||||
page.getByRole('link', { name: MCP_ENDPOINT, exact: true })
|
||||
).toHaveAttribute('href', MCP_ENDPOINT)
|
||||
})
|
||||
})
|
||||
|
||||
test.describe('MCP page zh-CN @smoke', () => {
|
||||
test('setup section renders localized options', async ({ page }) => {
|
||||
await page.goto('/zh-CN/mcp')
|
||||
const setup = page.locator('#setup')
|
||||
await setup.scrollIntoViewIfNeeded()
|
||||
await expect(setup.getByText('方式一')).toBeVisible()
|
||||
await expect(setup.getByRole('heading', { name: '手动安装' })).toBeVisible()
|
||||
await expect(setup.getByText(MCP_ENDPOINT, { exact: true })).toBeVisible()
|
||||
})
|
||||
})
|
||||
4
apps/website/public/icons/comfyicon.svg
Normal file
4
apps/website/public/icons/comfyicon.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg width="275" height="275" viewBox="0 0 275 275" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="274.66" height="274.66" rx="63.5555" fill="#211927"/>
|
||||
<path d="M177.456 174.409C177.713 173.538 177.854 172.621 177.854 171.656C177.854 166.313 173.546 161.983 168.232 161.983H125.108C122.791 162.006 120.894 160.124 120.894 157.794C120.894 157.37 120.965 156.97 121.058 156.594L132.67 115.926C133.162 114.137 134.801 112.819 136.72 112.819L180.008 112.772C189.138 112.772 196.84 106.582 199.158 98.1335L205.666 75.4696C205.877 74.6695 205.994 73.7987 205.994 72.9279C205.994 67.6091 201.71 63.3022 196.419 63.3022H144.048C134.965 63.3022 127.286 69.4448 124.921 77.7996L120.52 93.2618C120.005 95.0269 118.389 96.3213 116.47 96.3213H103.898C94.8846 96.3213 87.276 102.346 84.8412 110.607L69.0152 166.172C68.7811 166.996 68.6641 167.89 68.6641 168.784C68.6641 174.127 72.9717 178.457 78.2861 178.457H90.6472C92.9649 178.457 94.8612 180.34 94.8612 182.693C94.8612 183.093 94.8144 183.494 94.6973 183.87L90.3194 199.191C90.1087 200.015 89.9683 200.862 89.9683 201.733C89.9683 207.052 94.2525 211.359 99.5434 211.359L151.938 211.312C161.045 211.312 168.724 205.145 171.065 196.744L177.432 174.433L177.456 174.409Z" fill="#F2FF59"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
import { reactive, watch } from 'vue'
|
||||
import { computed, reactive, watch } from 'vue'
|
||||
|
||||
type Faq = { id: string; question: string; answer: string }
|
||||
|
||||
@@ -9,6 +9,31 @@ const { faqs } = defineProps<{
|
||||
faqs: readonly Faq[]
|
||||
}>()
|
||||
|
||||
type AnswerPart = { type: 'text' | 'link'; value: string }
|
||||
|
||||
function parseAnswer(answer: string): AnswerPart[] {
|
||||
const urlPattern = /https?:\/\/[\w\-./?=&#%~:@+,;]+/g
|
||||
const parts: AnswerPart[] = []
|
||||
let lastIndex = 0
|
||||
for (const match of answer.matchAll(urlPattern)) {
|
||||
const start = match.index ?? 0
|
||||
const url = match[0].replace(/[.,;:]+$/, '')
|
||||
if (start > lastIndex) {
|
||||
parts.push({ type: 'text', value: answer.slice(lastIndex, start) })
|
||||
}
|
||||
parts.push({ type: 'link', value: url })
|
||||
lastIndex = start + url.length
|
||||
}
|
||||
if (lastIndex < answer.length) {
|
||||
parts.push({ type: 'text', value: answer.slice(lastIndex) })
|
||||
}
|
||||
return parts
|
||||
}
|
||||
|
||||
const parsedFaqs = computed(() =>
|
||||
faqs.map((faq) => ({ ...faq, answerParts: parseAnswer(faq.answer) }))
|
||||
)
|
||||
|
||||
const expanded = reactive<boolean[]>(faqs.map(() => false))
|
||||
|
||||
watch(
|
||||
@@ -40,7 +65,7 @@ function toggle(index: number) {
|
||||
<!-- Right FAQ list -->
|
||||
<div class="flex-1">
|
||||
<div
|
||||
v-for="(faq, index) in faqs"
|
||||
v-for="(faq, index) in parsedFaqs"
|
||||
:key="faq.id"
|
||||
class="border-b border-primary-comfy-canvas/20"
|
||||
>
|
||||
@@ -83,8 +108,23 @@ function toggle(index: number) {
|
||||
:aria-labelledby="`faq-trigger-${faq.id}`"
|
||||
class="pb-6"
|
||||
>
|
||||
<p class="text-sm whitespace-pre-line text-primary-comfy-canvas/70">
|
||||
{{ faq.answer }}
|
||||
<p
|
||||
class="text-sm wrap-break-word whitespace-pre-line text-primary-comfy-canvas/70"
|
||||
>
|
||||
<template
|
||||
v-for="(part, partIndex) in faq.answerParts"
|
||||
:key="partIndex"
|
||||
>
|
||||
<a
|
||||
v-if="part.type === 'link'"
|
||||
:href="part.value"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-primary-comfy-yellow focus-visible:ring-primary-comfy-yellow/50 rounded-sm underline underline-offset-2 transition-opacity hover:opacity-70 focus-visible:ring-2 focus-visible:outline-none"
|
||||
>{{ part.value }}</a
|
||||
>
|
||||
<template v-else>{{ part.value }}</template>
|
||||
</template>
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
|
||||
import type { Component } from 'vue'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import CopyableField from '@/components/ui/copyable-field/CopyableField.vue'
|
||||
|
||||
import SectionHeader from '../common/SectionHeader.vue'
|
||||
|
||||
type CardAction =
|
||||
| {
|
||||
type: 'link'
|
||||
label: string
|
||||
href: string
|
||||
target?: '_blank'
|
||||
icon?: Component
|
||||
variant?: 'default' | 'outline'
|
||||
}
|
||||
| { type: 'code'; value: string }
|
||||
|
||||
export interface FeatureCard {
|
||||
id: string
|
||||
label?: string
|
||||
title: string
|
||||
description: string
|
||||
action?: CardAction
|
||||
}
|
||||
|
||||
type ColumnCount = 2 | 3 | 4
|
||||
|
||||
const {
|
||||
cards,
|
||||
columns = 3,
|
||||
copiedLabel,
|
||||
copyLabel,
|
||||
eyebrow,
|
||||
heading,
|
||||
subtitle
|
||||
} = defineProps<{
|
||||
cards: readonly FeatureCard[]
|
||||
columns?: ColumnCount
|
||||
copiedLabel?: string
|
||||
copyLabel?: string
|
||||
eyebrow?: string
|
||||
heading: string
|
||||
subtitle?: string
|
||||
}>()
|
||||
|
||||
const columnClass: Record<ColumnCount, string> = {
|
||||
2: 'lg:grid-cols-2',
|
||||
3: 'lg:grid-cols-3',
|
||||
4: 'lg:grid-cols-4'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="max-w-9xl mx-auto px-6 py-16 lg:py-24">
|
||||
<SectionHeader max-width="xl" :label="eyebrow" align="start">
|
||||
{{ heading }}
|
||||
<template v-if="subtitle" #subtitle>
|
||||
<p class="mt-4 max-w-xl text-sm text-smoke-700 lg:text-base">
|
||||
{{ subtitle }}
|
||||
</p>
|
||||
</template>
|
||||
</SectionHeader>
|
||||
|
||||
<div :class="cn('mt-16 grid grid-cols-1 gap-6', columnClass[columns])">
|
||||
<div
|
||||
v-for="card in cards"
|
||||
:key="card.id"
|
||||
class="bg-transparency-white-t4 flex flex-col rounded-3xl p-6 lg:p-8"
|
||||
>
|
||||
<p
|
||||
v-if="card.label"
|
||||
class="text-primary-comfy-yellow text-xs font-bold tracking-widest uppercase"
|
||||
>
|
||||
{{ card.label }}
|
||||
</p>
|
||||
<h3
|
||||
:class="
|
||||
cn(
|
||||
'text-xl font-light text-primary-comfy-canvas lg:text-2xl',
|
||||
card.label && 'mt-3'
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ card.title }}
|
||||
</h3>
|
||||
<p class="mt-3 text-sm text-smoke-700">
|
||||
{{ card.description }}
|
||||
</p>
|
||||
|
||||
<div v-if="card.action" class="mt-6">
|
||||
<Button
|
||||
v-if="card.action.type === 'link'"
|
||||
as="a"
|
||||
:href="card.action.href"
|
||||
:target="card.action.target"
|
||||
:rel="
|
||||
card.action.target === '_blank'
|
||||
? 'noopener noreferrer'
|
||||
: undefined
|
||||
"
|
||||
:variant="card.action.variant ?? 'outline'"
|
||||
:append-icon="card.action.icon"
|
||||
>
|
||||
{{ card.action.label }}
|
||||
</Button>
|
||||
<CopyableField
|
||||
v-else
|
||||
:value="card.action.value"
|
||||
:copy-label="copyLabel"
|
||||
:copied-label="copiedLabel"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -8,7 +8,7 @@ import VideoPlayer from '../common/VideoPlayer.vue'
|
||||
import type { VideoTrack } from '../common/VideoPlayer.vue'
|
||||
|
||||
type RowMedia =
|
||||
| { type: 'image'; src: string; alt?: string }
|
||||
| { type: 'image'; src: string; alt?: string; fit?: 'cover' | 'contain' }
|
||||
| {
|
||||
type: 'video'
|
||||
src: string
|
||||
@@ -20,6 +20,7 @@ type RowMedia =
|
||||
loop?: boolean
|
||||
minimal?: boolean
|
||||
hideControls?: boolean
|
||||
fit?: 'cover' | 'contain'
|
||||
}
|
||||
|
||||
export interface FeatureRow {
|
||||
@@ -58,7 +59,7 @@ const {
|
||||
<div
|
||||
:class="
|
||||
cn(
|
||||
'order-2 flex flex-col justify-center gap-4 p-6 lg:w-1/2 lg:p-12',
|
||||
'order-2 flex flex-col justify-center gap-4 p-6 lg:flex-1 lg:p-12',
|
||||
i % 2 === 0 ? 'lg:order-1' : 'lg:order-2'
|
||||
)
|
||||
"
|
||||
@@ -72,10 +73,11 @@ const {
|
||||
</div>
|
||||
|
||||
<!-- Media: image or video -->
|
||||
<!-- 620/364 and w-155 (620px) match the card media asset dimensions -->
|
||||
<div
|
||||
:class="
|
||||
cn(
|
||||
'order-1 flex lg:w-1/2',
|
||||
'relative order-1 aspect-620/364 w-full lg:w-155 lg:shrink-0',
|
||||
i % 2 === 0 ? 'lg:order-2' : 'lg:order-1'
|
||||
)
|
||||
"
|
||||
@@ -86,7 +88,12 @@ const {
|
||||
:alt="row.media.alt ?? row.title"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
class="aspect-4/3 w-full rounded-4xl object-cover"
|
||||
:class="
|
||||
cn(
|
||||
'absolute inset-0 size-full rounded-4xl',
|
||||
row.media.fit === 'contain' ? 'object-contain' : 'object-cover'
|
||||
)
|
||||
"
|
||||
/>
|
||||
<VideoPlayer
|
||||
v-else
|
||||
@@ -99,7 +106,13 @@ const {
|
||||
:loop="row.media.loop"
|
||||
:minimal="row.media.minimal"
|
||||
:hide-controls="row.media.hideControls"
|
||||
class="w-full"
|
||||
:fit="row.media.fit"
|
||||
:class="
|
||||
cn(
|
||||
'absolute inset-0 size-full',
|
||||
row.media.fit === 'contain' && 'bg-transparent'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</GlassCard>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
const { resources } = defineProps<{
|
||||
resources: { label: string; href: string; display: string }[]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul class="flex flex-col gap-3 text-base font-light lg:text-lg">
|
||||
<li v-for="resource in resources" :key="resource.href">
|
||||
<span class="text-primary-comfy-canvas">{{ resource.label }}</span>
|
||||
<span class="text-primary-warm-gray"> — </span>
|
||||
<a
|
||||
:href="resource.href"
|
||||
class="text-primary-comfy-yellow underline underline-offset-4 hover:no-underline"
|
||||
>
|
||||
{{ resource.display }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
@@ -85,6 +85,7 @@ const companyColumn: { title: string; links: FooterLink[] } = {
|
||||
links: [
|
||||
{ label: t('footer.about', locale), href: routes.about },
|
||||
{ label: t('nav.careers', locale), href: routes.careers },
|
||||
{ label: t('nav.brand', locale), href: routes.brand },
|
||||
{ label: t('footer.termsOfService', locale), href: routes.termsOfService },
|
||||
{ label: t('footer.enterpriseMsa', locale), href: routes.enterpriseMsa },
|
||||
{ label: t('footer.privacyPolicy', locale), href: routes.privacyPolicy }
|
||||
@@ -175,10 +176,7 @@ const contactColumn: { title: string; links: FooterLink[] } = {
|
||||
</div>
|
||||
|
||||
<!-- Logo -->
|
||||
<canvas
|
||||
ref="canvasRef"
|
||||
class="pointer-events-none size-52 opacity-80 lg:mt-28"
|
||||
/>
|
||||
<canvas ref="canvasRef" class="pointer-events-none size-52 lg:mt-28" />
|
||||
</div>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
whenever
|
||||
} from '@vueuse/core'
|
||||
import { computed, shallowRef, useTemplateRef, watch } from 'vue'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
|
||||
import { t } from '../../i18n/translations'
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
@@ -30,7 +31,9 @@ const {
|
||||
autoplay = false,
|
||||
loop = false,
|
||||
minimal = false,
|
||||
hideControls = false
|
||||
hideControls = false,
|
||||
fit = 'cover',
|
||||
class: className
|
||||
} = defineProps<{
|
||||
locale?: Locale
|
||||
src?: string
|
||||
@@ -40,6 +43,8 @@ const {
|
||||
loop?: boolean
|
||||
minimal?: boolean
|
||||
hideControls?: boolean
|
||||
fit?: 'cover' | 'contain'
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
|
||||
const playerEl = useTemplateRef<HTMLDivElement>('playerEl')
|
||||
@@ -189,7 +194,12 @@ function toggleFullscreen() {
|
||||
<template>
|
||||
<div
|
||||
ref="playerEl"
|
||||
class="relative aspect-video overflow-hidden rounded-4xl border border-white/10 bg-black"
|
||||
:class="
|
||||
cn(
|
||||
'relative aspect-video overflow-hidden rounded-4xl border border-white/10 bg-black',
|
||||
className
|
||||
)
|
||||
"
|
||||
@pointermove="showControls"
|
||||
@pointerdown="showControls"
|
||||
@focusin="showControls"
|
||||
@@ -197,7 +207,9 @@ function toggleFullscreen() {
|
||||
<video
|
||||
v-if="src"
|
||||
ref="videoEl"
|
||||
class="size-full object-cover"
|
||||
:class="
|
||||
cn('size-full', fit === 'contain' ? 'object-contain' : 'object-cover')
|
||||
"
|
||||
:src
|
||||
:poster
|
||||
:preload="autoplay ? 'auto' : 'metadata'"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import Button from '../ui/button/Button.vue'
|
||||
|
||||
const { href, label } = defineProps<{
|
||||
href: string
|
||||
label: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mt-2 flex justify-center">
|
||||
<Button as="a" :href variant="default" size="lg">
|
||||
{{ label }}
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
const { title } = defineProps<{ title: string }>()
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
|
||||
const { title, class: className } = defineProps<{
|
||||
title: string
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="flex items-center justify-center px-6 pt-20 pb-16 lg:pt-32 lg:pb-24"
|
||||
>
|
||||
<h1 class="text-primary-comfy-canvas text-4xl font-light lg:text-6xl">
|
||||
<h1
|
||||
:class="
|
||||
cn(
|
||||
'text-4xl font-light text-primary-comfy-canvas lg:text-6xl',
|
||||
className
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ title }}
|
||||
</h1>
|
||||
</section>
|
||||
|
||||
@@ -20,6 +20,8 @@ export const buttonVariants = cva(
|
||||
link: "text-primary-comfy-yellow h-auto justify-start px-0 py-1 text-base uppercase hover:opacity-90 [&_svg:not([class*='size-'])]:size-6",
|
||||
underlineLink:
|
||||
"text-primary-comfy-yellow relative h-auto justify-start px-0 py-1 uppercase after:absolute after:bottom-0 after:left-0 after:h-0.5 after:w-full after:origin-left after:scale-x-0 after:bg-current after:transition-transform after:duration-200 hover:opacity-90 hover:after:scale-x-100 [&_svg:not([class*='size-'])]:size-6",
|
||||
inline:
|
||||
'text-primary-comfy-yellow inline h-auto rounded-none p-0 align-baseline text-sm font-normal tracking-normal whitespace-normal hover:opacity-90 [&>span]:top-0 [&>span]:underline',
|
||||
nav: 'text-primary-warm-white hover:text-primary-comfy-yellow h-auto justify-between px-0 py-1 text-start text-2xl font-medium',
|
||||
navMuted:
|
||||
'hover:text-primary-comfy-yellow h-auto w-full justify-between px-0 py-1 text-start text-2xl font-medium text-primary-comfy-canvas uppercase'
|
||||
|
||||
@@ -21,7 +21,8 @@ const baseRoutes = {
|
||||
affiliateTerms: '/affiliates/terms',
|
||||
contact: '/contact',
|
||||
models: '/p/supported-models',
|
||||
mcp: '/mcp'
|
||||
mcp: '/mcp',
|
||||
brand: '/brand'
|
||||
} as const
|
||||
|
||||
type Routes = typeof baseRoutes
|
||||
@@ -87,6 +88,7 @@ export const externalLinks = {
|
||||
githubInstall: 'https://github.com/Comfy-Org/ComfyUI#installing',
|
||||
instagram: 'https://www.instagram.com/comfyui/',
|
||||
linkedin: 'https://www.linkedin.com/company/comfyui',
|
||||
mcpEndpoint: 'https://cloud.comfy.org/mcp',
|
||||
mcpSkills: 'https://github.com/Comfy-Org/comfy-skills',
|
||||
platform: 'https://platform.comfy.org',
|
||||
platformUsage: 'https://platform.comfy.org/profile/usage',
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { LocalizedText } from '../i18n/translations'
|
||||
|
||||
import { BRAND_ASSETS_ZIP } from './brandAssets'
|
||||
|
||||
interface AffiliateBrandAsset {
|
||||
id: string
|
||||
title: LocalizedText
|
||||
@@ -7,9 +9,6 @@ interface AffiliateBrandAsset {
|
||||
preview: string
|
||||
}
|
||||
|
||||
const BRAND_ASSETS_ZIP =
|
||||
'https://media.comfy.org/website/comfy-org-brand-assets.zip'
|
||||
|
||||
export const affiliateBrandAssets: readonly AffiliateBrandAsset[] = [
|
||||
{
|
||||
id: 'core-logo',
|
||||
|
||||
9
apps/website/src/data/brandAssets.ts
Normal file
9
apps/website/src/data/brandAssets.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// Shared brand download URLs served from the media bucket, used by both the
|
||||
// affiliate page and the brand portal.
|
||||
export const BRAND_ASSETS_ZIP =
|
||||
'https://media.comfy.org/website/comfy-org-brand-assets.zip'
|
||||
|
||||
// Brand guidelines live in Google Drive, shared to Comfy Org only, so Google
|
||||
// enforces the comfy.org sign-in. Opened in a new tab rather than downloaded.
|
||||
export const BRAND_GUIDELINES_PDF =
|
||||
'https://drive.google.com/file/d/1EDt03JTfF_nbbY_H2n67aaUj6k11v3bS/view'
|
||||
91
apps/website/src/data/brandColors.ts
Normal file
91
apps/website/src/data/brandColors.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
interface BrandColor {
|
||||
name: string
|
||||
hex: string
|
||||
rgb: string
|
||||
hsl: string
|
||||
cmyk: string
|
||||
swatchClass: string
|
||||
textClass: string
|
||||
wide?: boolean
|
||||
border?: boolean
|
||||
}
|
||||
|
||||
export const brandColors: readonly BrandColor[] = [
|
||||
{
|
||||
name: 'Comfy Yellow',
|
||||
hex: '#F2FF59',
|
||||
rgb: '242, 255, 89',
|
||||
hsl: '65, 100, 67',
|
||||
cmyk: '5, 0, 65, 0',
|
||||
swatchClass: 'bg-primary-comfy-yellow',
|
||||
textClass: 'text-primary-comfy-ink',
|
||||
wide: true
|
||||
},
|
||||
{
|
||||
name: 'Comfy Ink',
|
||||
hex: '#211927',
|
||||
rgb: '33, 25, 39',
|
||||
hsl: '274, 22, 13',
|
||||
cmyk: '15, 36, 0, 85',
|
||||
swatchClass: 'bg-primary-comfy-ink',
|
||||
textClass: 'text-primary-warm-white',
|
||||
border: true
|
||||
},
|
||||
{
|
||||
name: 'Comfy Canvas',
|
||||
hex: '#C2BFB9',
|
||||
rgb: '194, 191, 185',
|
||||
hsl: '40, 7, 74',
|
||||
cmyk: '0, 2, 5, 24',
|
||||
swatchClass: 'bg-primary-comfy-canvas',
|
||||
textClass: 'text-primary-comfy-ink'
|
||||
},
|
||||
{
|
||||
name: 'Comfy Plum',
|
||||
hex: '#49378B',
|
||||
rgb: '73, 55, 139',
|
||||
hsl: '253, 43, 38',
|
||||
cmyk: '47, 60, 0, 45',
|
||||
swatchClass: 'bg-primary-comfy-plum',
|
||||
textClass: 'text-primary-comfy-canvas'
|
||||
},
|
||||
{
|
||||
name: 'Warm White',
|
||||
hex: '#F0EFED',
|
||||
rgb: '240, 239, 237',
|
||||
hsl: '40, 9, 94',
|
||||
cmyk: '0, 0, 1, 6',
|
||||
swatchClass: 'bg-primary-warm-white',
|
||||
textClass: 'text-primary-comfy-ink',
|
||||
wide: true
|
||||
},
|
||||
{
|
||||
name: 'Warm Gray',
|
||||
hex: '#7E7C78',
|
||||
rgb: '126, 124, 120',
|
||||
hsl: '40, 2, 48',
|
||||
cmyk: '0, 2, 5, 51',
|
||||
swatchClass: 'bg-primary-warm-gray',
|
||||
textClass: 'text-primary-warm-white',
|
||||
border: true
|
||||
},
|
||||
{
|
||||
name: 'Cool Gray',
|
||||
hex: '#3C3C3C',
|
||||
rgb: '60, 60, 60',
|
||||
hsl: '0, 0, 24',
|
||||
cmyk: '0, 0, 0, 76',
|
||||
swatchClass: 'bg-secondary-cool-gray',
|
||||
textClass: 'text-primary-warm-white',
|
||||
border: true
|
||||
},
|
||||
{
|
||||
name: 'Mauve',
|
||||
hex: '#4D3762',
|
||||
rgb: '77, 55, 98',
|
||||
hsl: '271, 28, 30',
|
||||
cmyk: '21, 44, 0, 62',
|
||||
swatchClass: 'bg-secondary-mauve',
|
||||
textClass: 'text-primary-warm-white'
|
||||
}
|
||||
] as const
|
||||
@@ -1864,10 +1864,26 @@ const translations = {
|
||||
'zh-CN':
|
||||
'Comfy MCP 通过模型上下文协议暴露完整的 ComfyUI 引擎——让你的助手能够接入生态系统、构建工作流,并生成图像、视频、音频或 3D 内容。'
|
||||
},
|
||||
'mcp.hero.demoPrompt': {
|
||||
'mcp.hero.demoPromptMoodboard': {
|
||||
en: 'turn the brief in this email into a 6-up moodboard',
|
||||
'zh-CN': '把这封邮件里的需求做成六宫格情绪板'
|
||||
},
|
||||
'mcp.hero.demoPromptConcepts': {
|
||||
en: 'sketch three concept frames for the launch page',
|
||||
'zh-CN': '为发布页画三张概念稿'
|
||||
},
|
||||
'mcp.hero.demoPromptKeyart': {
|
||||
en: "match this frame's palette, make the hero key art",
|
||||
'zh-CN': '匹配这一帧的配色,生成主视觉关键画面'
|
||||
},
|
||||
'mcp.hero.demoPromptPbr': {
|
||||
en: 'make a tileable asphalt PBR material, all 5 maps',
|
||||
'zh-CN': '生成可平铺的沥青 PBR 材质,共 5 张贴图'
|
||||
},
|
||||
'mcp.hero.demoPromptUpscale': {
|
||||
en: 'upscale the neon kaiju shot to 4K',
|
||||
'zh-CN': '把霓虹怪兽画面放大到 4K'
|
||||
},
|
||||
'mcp.hero.viewDocs': {
|
||||
en: 'VIEW DOCS',
|
||||
'zh-CN': '查看文档'
|
||||
@@ -1876,10 +1892,6 @@ const translations = {
|
||||
en: 'INSTALL MCP',
|
||||
'zh-CN': '安装 MCP'
|
||||
},
|
||||
'mcp.hero.runWorkflow': {
|
||||
en: 'RUN A WORKFLOW',
|
||||
'zh-CN': '运行工作流'
|
||||
},
|
||||
'mcp.hero.demoGenerate': {
|
||||
en: 'GENERATE',
|
||||
'zh-CN': '生成'
|
||||
@@ -1897,60 +1909,90 @@ const translations = {
|
||||
'zh-CN': '放大图像'
|
||||
},
|
||||
|
||||
// MCP – SetupStepsSection
|
||||
// MCP – SetupSection
|
||||
'mcp.setup.label': {
|
||||
en: 'GET STARTED',
|
||||
'zh-CN': '快速开始'
|
||||
},
|
||||
'mcp.setup.heading': {
|
||||
en: 'Set up Comfy MCP in three steps',
|
||||
'zh-CN': '三步完成 Comfy MCP 配置'
|
||||
en: 'Set up Comfy MCP',
|
||||
'zh-CN': '配置 Comfy MCP'
|
||||
},
|
||||
'mcp.setup.subtitle': {
|
||||
en: 'Add Comfy Cloud as a custom connector in Claude, Cursor, Codex, or any MCP-compatible client. Sign in once, and the full ComfyUI toolset is available right in your chat.',
|
||||
en: 'Two ways to connect: ask your agent to install it, or add the server yourself. Sign in once, and the full ComfyUI toolset is available right in your chat.',
|
||||
'zh-CN':
|
||||
'将 Comfy Cloud 添加为 Claude、Cursor、Codex 或任意兼容 MCP 客户端的自定义连接器。登录一次,ComfyUI 全套工具即可直接在对话中使用。'
|
||||
'两种接入方式:让你的智能体自动安装,或自行添加服务器。登录一次,ComfyUI 全套工具即可直接在对话中使用。'
|
||||
},
|
||||
'mcp.setup.step1.label': { en: 'STEP 1', 'zh-CN': '第 1 步' },
|
||||
'mcp.setup.step1.title': {
|
||||
'mcp.setup.option1.label': { en: 'OPTION 1', 'zh-CN': '方式一' },
|
||||
'mcp.setup.option1.title': {
|
||||
en: 'Ask your agent to install Comfy MCP',
|
||||
'zh-CN': '让你的智能体安装 Comfy MCP'
|
||||
},
|
||||
'mcp.setup.step1.command': {
|
||||
'mcp.setup.option1.command': {
|
||||
en: 'Help me install Comfy MCP.\nFollow the setup guide at {url}',
|
||||
'zh-CN': '帮我安装 Comfy MCP。\n请按照 {url} 上的设置指南操作。'
|
||||
},
|
||||
'mcp.setup.step1.description': {
|
||||
'mcp.setup.option1.description': {
|
||||
en: 'Paste this into Claude, Cursor, Codex, or any MCP-compatible agent. It reads the docs and adds the connector for you.',
|
||||
'zh-CN':
|
||||
'将它粘贴到 Claude、Cursor、Codex 或任意兼容 MCP 的智能体中。它会读取文档并为你添加连接器。'
|
||||
},
|
||||
'mcp.setup.step2.label': { en: 'STEP 2', 'zh-CN': '第 2 步' },
|
||||
'mcp.setup.step2.title': {
|
||||
en: 'Or add it by hand',
|
||||
'zh-CN': '或手动添加'
|
||||
'mcp.setup.option2.label': { en: 'OPTION 2', 'zh-CN': '方式二' },
|
||||
'mcp.setup.option2.title': {
|
||||
en: 'Install manually',
|
||||
'zh-CN': '手动安装'
|
||||
},
|
||||
'mcp.setup.step2.description': {
|
||||
en: 'Prefer manual setup? Add Comfy Cloud as a custom connector with the MCP URL. The docs cover every client.',
|
||||
'mcp.setup.option2.description': {
|
||||
en: 'Prefer manual setup? Add this URL as a custom connector or remote MCP server in your client, then sign in when prompted.',
|
||||
'zh-CN':
|
||||
'想手动配置?用 MCP URL 将 Comfy Cloud 添加为自定义连接器。文档涵盖各类客户端。'
|
||||
'想手动配置?将此 URL 添加为客户端的自定义连接器或远程 MCP 服务器,然后按提示登录。'
|
||||
},
|
||||
'mcp.setup.step2.cta': {
|
||||
en: 'COMFY CLOUD MCP DOCS',
|
||||
'zh-CN': 'COMFY CLOUD MCP 文档'
|
||||
'mcp.setup.option2.tabsLabel': {
|
||||
en: 'Pick your client',
|
||||
'zh-CN': '选择你的客户端'
|
||||
},
|
||||
'mcp.setup.step3.label': { en: 'STEP 3', 'zh-CN': '第 3 步' },
|
||||
'mcp.setup.step3.title': {
|
||||
en: 'Connect and sign in',
|
||||
'zh-CN': '连接并登录'
|
||||
'mcp.setup.clients.claudeCode.step': {
|
||||
en: 'Run this in your terminal, then use /mcp to pick comfy-cloud and authenticate.',
|
||||
'zh-CN': '在终端运行以下命令,然后通过 /mcp 选择 comfy-cloud 并完成认证。'
|
||||
},
|
||||
'mcp.setup.step3.description': {
|
||||
en: 'Click Connect, sign in, and every Comfy Cloud skill is ready in your client.',
|
||||
'zh-CN': '点击"连接"并登录,所有 Comfy Cloud 技能即可在你的客户端中使用。'
|
||||
'mcp.setup.clients.claudeDesktop.step': {
|
||||
en: 'Click Customize in the sidebar, open Connectors, choose Add custom connector, paste the URL above, and sign in.',
|
||||
'zh-CN':
|
||||
'点击侧边栏的 Customize,进入 Connectors,选择添加自定义连接器,粘贴上方 URL 并登录。'
|
||||
},
|
||||
'mcp.setup.step3.cta': {
|
||||
en: 'COMFY CLOUD SKILLS',
|
||||
'zh-CN': 'COMFY CLOUD 技能'
|
||||
'mcp.setup.clients.cursor.step': {
|
||||
en: 'Add the URL above to ~/.cursor/mcp.json with an X-API-Key header. Create your key at ',
|
||||
'zh-CN':
|
||||
'将上方 URL 添加到 ~/.cursor/mcp.json,并附带 X-API-Key 请求头。在此创建密钥:'
|
||||
},
|
||||
'mcp.setup.clients.cursor.linkLabel': {
|
||||
en: 'platform.comfy.org',
|
||||
'zh-CN': 'platform.comfy.org'
|
||||
},
|
||||
'mcp.setup.clients.codex.step': {
|
||||
en: 'Run this in your terminal, then codex mcp login comfy-cloud to sign in.',
|
||||
'zh-CN': '在终端运行以下命令,然后执行 codex mcp login comfy-cloud 登录。'
|
||||
},
|
||||
'mcp.setup.clients.other.name': {
|
||||
en: 'Other clients',
|
||||
'zh-CN': '其他客户端'
|
||||
},
|
||||
'mcp.setup.clients.other.step': {
|
||||
en: 'Add the URL above as a remote MCP server. No OAuth in your client? Use an X-API-Key header instead. Full walkthroughs live in the ',
|
||||
'zh-CN':
|
||||
'将上方 URL 添加为远程 MCP 服务器。客户端不支持 OAuth?改用 X-API-Key 请求头。完整教程见'
|
||||
},
|
||||
'mcp.setup.clients.other.linkLabel': {
|
||||
en: 'setup docs',
|
||||
'zh-CN': '设置文档'
|
||||
},
|
||||
'mcp.setup.skillsNote': {
|
||||
en: 'Using Claude Code? The Comfy skills plugin adds ready-made slash commands. ',
|
||||
'zh-CN': '在用 Claude Code?Comfy 技能插件提供现成的斜杠命令。'
|
||||
},
|
||||
'mcp.setup.skillsLink': {
|
||||
en: 'View on GitHub',
|
||||
'zh-CN': '在 GitHub 上查看'
|
||||
},
|
||||
|
||||
// MCP – WhyBuildSection
|
||||
@@ -1971,9 +2013,9 @@ const translations = {
|
||||
'zh-CN': '开放协议,\n任意客户端。'
|
||||
},
|
||||
'mcp.why.1.description': {
|
||||
en: 'MCP is an open standard, so any MCP-compatible client can connect. Today Comfy supports Claude Code and Claude Desktop, with more clients coming.',
|
||||
en: 'MCP is an open standard, so any MCP-compatible client can connect. Claude Code, Claude Desktop, and Codex sign in with OAuth; every other agent connects with an API key.',
|
||||
'zh-CN':
|
||||
'MCP 是开放标准,因此任何兼容 MCP 的客户端都能接入。目前 Comfy 支持 Claude Code 和 Claude Desktop,更多客户端即将推出。'
|
||||
'MCP 是开放标准,因此任何兼容 MCP 的客户端都能接入。Claude Code、Claude Desktop 和 Codex 通过 OAuth 登录,其他智能体使用 API 密钥连接。'
|
||||
},
|
||||
'mcp.why.2.title': {
|
||||
en: 'The full engine,\nnot a sandbox.',
|
||||
@@ -2037,14 +2079,53 @@ const translations = {
|
||||
'zh-CN': '运行真实工作流'
|
||||
},
|
||||
'mcp.tools.3.description': {
|
||||
en: 'Turn any ComfyUI workflow into a callable tool. The full power of the engine, driven by your agent.',
|
||||
en: 'Submit graphs, track jobs, and pull outputs back. Save and share workflows, reuse a saved one, or open any run on the ComfyUI canvas — the full engine, driven by tool calls.',
|
||||
'zh-CN':
|
||||
'将任何 ComfyUI 工作流转换为可调用的工具。由你的智能体驱动完整的引擎能力。'
|
||||
'提交计算图、跟踪任务并取回输出。保存和分享工作流,复用已保存的工作流,或在 ComfyUI 画布上打开任意运行——完整的引擎,由工具调用驱动。'
|
||||
},
|
||||
'mcp.tools.3.alt': {
|
||||
en: 'Comfy MCP running a ComfyUI workflow as a callable tool from a chat',
|
||||
'zh-CN': 'Comfy MCP 在对话中将 ComfyUI 工作流作为可调用工具运行'
|
||||
},
|
||||
'mcp.tools.4.title': {
|
||||
en: 'Direct any model',
|
||||
'zh-CN': '直接调用任意模型'
|
||||
},
|
||||
'mcp.tools.4.description': {
|
||||
en: 'Kling, Veo, Seedance, Flux, GPT-Image, Nano Banana, and ElevenLabs. Closed partner APIs and open-source models, reached through one set of tools.',
|
||||
'zh-CN':
|
||||
'Kling、Veo、Seedance、Flux、GPT-Image、Nano Banana 和 ElevenLabs。封闭的合作伙伴 API 与开源模型,通过同一套工具即可调用。'
|
||||
},
|
||||
'mcp.tools.4.alt': {
|
||||
en: 'Comfy MCP directing closed partner APIs and open-source models through one set of tools',
|
||||
'zh-CN': 'Comfy MCP 通过同一套工具调用封闭合作伙伴 API 和开源模型'
|
||||
},
|
||||
'mcp.tools.5.title': {
|
||||
en: 'Generate in batches',
|
||||
'zh-CN': '批量生成'
|
||||
},
|
||||
'mcp.tools.5.description': {
|
||||
en: 'Stack a batch on the Queue, track it, and pull back every output. Dozens of runs from a single call.',
|
||||
'zh-CN':
|
||||
'将一批任务加入队列,跟踪进度,并取回每一个输出。一次调用即可完成数十次运行。'
|
||||
},
|
||||
'mcp.tools.5.alt': {
|
||||
en: 'Comfy MCP stacking a batch on the Queue and pulling back every output',
|
||||
'zh-CN': 'Comfy MCP 将一批任务加入队列并取回每个输出'
|
||||
},
|
||||
'mcp.tools.6.title': {
|
||||
en: 'Ship it as an app',
|
||||
'zh-CN': '作为应用发布'
|
||||
},
|
||||
'mcp.tools.6.description': {
|
||||
en: 'Turn any workflow into an app with a shareable URL. Collaborators run it in the browser — only the inputs you expose, nothing to install.',
|
||||
'zh-CN':
|
||||
'将任意工作流变成带可分享链接的应用。协作者在浏览器中运行——只暴露你开放的输入,无需安装任何东西。'
|
||||
},
|
||||
'mcp.tools.6.alt': {
|
||||
en: 'Comfy MCP turning a workflow into a shareable browser app',
|
||||
'zh-CN': 'Comfy MCP 将工作流变成可在浏览器中分享的应用'
|
||||
},
|
||||
|
||||
// MCP – HowItWorksSection
|
||||
'mcp.howItWorks.heading': {
|
||||
@@ -2091,71 +2172,81 @@ const translations = {
|
||||
'zh-CN': '支持哪些客户端?'
|
||||
},
|
||||
'mcp.faq.1.a': {
|
||||
en: 'Claude Code and Claude Desktop today, both signing in with OAuth. Support for more clients is coming.',
|
||||
en: "For Claude Code, Claude Desktop, or Codex, add https://cloud.comfy.org/mcp as a custom connector or remote MCP server in any client, then sign in when prompted.\nFor clients that don't support OAuth, connect with a Comfy API key. Send the docs https://docs.comfy.org/agent-tools/cloud to your agent and it will figure out the installation for you.",
|
||||
'zh-CN':
|
||||
'目前支持 Claude Code 和 Claude Desktop,均通过 OAuth 登录。更多客户端的支持即将推出。'
|
||||
'对于 Claude Code、Claude Desktop 或 Codex,在任意客户端中将 https://cloud.comfy.org/mcp 添加为自定义连接器或远程 MCP 服务器,然后在提示时登录。\n对于不支持 OAuth 的客户端,请使用 Comfy API 密钥连接。将文档 https://docs.comfy.org/agent-tools/cloud 发送给你的智能体,它会为你完成安装。'
|
||||
},
|
||||
'mcp.faq.2.q': {
|
||||
en: "What's the server URL?",
|
||||
'zh-CN': '服务器 URL 是什么?'
|
||||
},
|
||||
'mcp.faq.2.a': {
|
||||
en: 'https://cloud.comfy.org/mcp — add it as a custom connector or remote MCP server in any client, then sign in when prompted.',
|
||||
'zh-CN':
|
||||
'https://cloud.comfy.org/mcp——在任意客户端中将它添加为自定义连接器或远程 MCP 服务器,然后在提示时登录。'
|
||||
},
|
||||
'mcp.faq.3.q': {
|
||||
en: 'Do I need an API key?',
|
||||
'zh-CN': '我需要 API 密钥吗?'
|
||||
},
|
||||
'mcp.faq.2.a': {
|
||||
en: 'Not for Claude Code or Claude Desktop. They use OAuth. An API key is only needed for headless or CI setups with no browser.',
|
||||
'zh-CN':
|
||||
'Claude Code 和 Claude Desktop 不需要,它们使用 OAuth。仅在没有浏览器的无头或 CI 环境中才需要 API 密钥。'
|
||||
},
|
||||
'mcp.faq.3.q': {
|
||||
en: 'Do the slash commands work in Claude Desktop?',
|
||||
'zh-CN': '斜杠命令在 Claude Desktop 中可以使用吗?'
|
||||
},
|
||||
'mcp.faq.3.a': {
|
||||
en: 'No. They ship in the Claude Code plugin. Desktop connects to the same MCP server, so the tools work; just ask in plain language.',
|
||||
en: 'Not for Claude Code, Claude Desktop, or Codex. You need a Comfy API key for Cursor, Hermes, and OpenClaw for now. Just copy https://docs.comfy.org/agent-tools/cloud and your agent will figure out the installation for you.',
|
||||
'zh-CN':
|
||||
'不可以。斜杠命令包含在 Claude Code 插件中。Claude Desktop 连接的是同一个 MCP 服务器,因此工具可以正常使用;直接用自然语言提问即可。'
|
||||
'Claude Code、Claude Desktop 和 Codex 不需要。Cursor、Hermes 和 OpenClaw 目前需要 Comfy API 密钥。只需复制 https://docs.comfy.org/agent-tools/cloud,你的智能体就会为你完成安装。'
|
||||
},
|
||||
'mcp.faq.4.q': {
|
||||
en: "The sign-in didn't open a browser.",
|
||||
'zh-CN': '登录时没有打开浏览器。'
|
||||
en: 'Does it cost anything?',
|
||||
'zh-CN': '需要付费吗?'
|
||||
},
|
||||
'mcp.faq.4.a': {
|
||||
en: 'In Claude Code, run /mcp, select comfy-cloud, and choose Authenticate. In Claude Desktop, reopen the connector from Customize → Connectors.',
|
||||
en: "Connecting is free with a Comfy account, and searching models, nodes, and templates doesn't cost credits. Running a generation uses Comfy Cloud credits and needs a subscription or credit balance. Your agent confirms with you before it spends.",
|
||||
'zh-CN':
|
||||
'在 Claude Code 中,运行 /mcp,选择 comfy-cloud,然后选择 Authenticate(授权)。在 Claude Desktop 中,从“自定义 → 连接器”重新打开该连接器。'
|
||||
'使用 Comfy 账户连接是免费的,搜索模型、节点和模板也不消耗积分。运行生成会使用 Comfy Cloud 积分,需要订阅或积分余额。智能体在消费前会先与你确认。'
|
||||
},
|
||||
'mcp.faq.5.q': {
|
||||
en: 'How do I connect in Claude Code?',
|
||||
'zh-CN': '如何在 Claude Code 中连接?'
|
||||
en: 'Can I use it with my local ComfyUI?',
|
||||
'zh-CN': '可以配合我的本地 ComfyUI 使用吗?'
|
||||
},
|
||||
'mcp.faq.5.a': {
|
||||
en: 'Add the marketplace and install the comfy-cloud plugin, then run /mcp → comfy-cloud → Authenticate. It adds the connection and slash commands in one step.',
|
||||
en: 'Coming soon. Today, to drive a local ComfyUI, you can use comfy-cli: https://github.com/Comfy-Org/comfy-cli',
|
||||
'zh-CN':
|
||||
'添加插件市场并安装 comfy-cloud 插件,然后运行 /mcp → comfy-cloud → Authenticate(授权)。一步即可添加连接和斜杠命令。'
|
||||
'即将推出。目前,若要操作本地 ComfyUI,你可以使用 comfy-cli:https://github.com/Comfy-Org/comfy-cli'
|
||||
},
|
||||
'mcp.faq.6.q': {
|
||||
en: "What's the server URL for Claude Desktop?",
|
||||
'zh-CN': 'Claude Desktop 的服务器 URL 是什么?'
|
||||
},
|
||||
'mcp.faq.6.a': {
|
||||
en: 'Add a custom connector in Customize → Connectors pointing to https://cloud.comfy.org/mcp, then sign in when prompted.',
|
||||
'zh-CN':
|
||||
'在“自定义 → 连接器”中添加一个指向 https://cloud.comfy.org/mcp 的自定义连接器,然后在提示时登录。'
|
||||
},
|
||||
'mcp.faq.7.q': {
|
||||
en: 'What can my agent do once connected?',
|
||||
'zh-CN': '连接后我的智能体能做什么?'
|
||||
},
|
||||
'mcp.faq.7.a': {
|
||||
en: 'Generate images, video, audio, and 3D; search models, nodes, and templates; and run ComfyUI workflows, all from a chat.',
|
||||
'mcp.faq.6.a': {
|
||||
en: "• Generate images, video, audio, and 3D — including all open-source workflows and partner models like Seedance, GPT-Image, Nano Banana, and Kling\n• Build, edit, and run workflows; save and re-run workflows\n• Run and read in large batches\n• Search models, nodes, and template workflows\n• Read and execute shared workflow URLs\n• Upload and download assets for you\n\nEverything is now in natural language. No nodes, no downloads, no GPU, no node graphs if you don't want them.",
|
||||
'zh-CN':
|
||||
'生成图像、视频、音频和 3D;搜索模型、节点和模板;并运行 ComfyUI 工作流——全部在对话中完成。'
|
||||
'• 生成图像、视频、音频和 3D——包括所有开源工作流以及 Seedance、GPT-Image、Nano Banana 和 Kling 等合作伙伴模型\n• 构建、编辑和运行工作流;保存并重新运行工作流\n• 大批量运行和读取\n• 搜索模型、节点和模板工作流\n• 读取并执行分享的工作流链接\n• 为你上传和下载资产\n\n现在一切都用自然语言完成。如果你愿意,无需节点、无需下载、无需 GPU、无需节点图。'
|
||||
},
|
||||
'mcp.faq.7.q': {
|
||||
en: 'Where do my outputs go?',
|
||||
'zh-CN': '我的输出会保存到哪里?'
|
||||
},
|
||||
'mcp.faq.7.a': {
|
||||
en: 'Into your Comfy Cloud asset library, so you can reuse, remix, and share them — and open any run on the canvas to keep editing. You can also ask your agent to download the assets locally for you.',
|
||||
'zh-CN':
|
||||
'保存到你的 Comfy Cloud 资产库,你可以复用、二次创作和分享——还能在画布上打开任意运行继续编辑。你也可以让智能体把资产下载到本地。'
|
||||
},
|
||||
'mcp.faq.8.q': {
|
||||
en: 'Do slash commands work in Claude Desktop?',
|
||||
'zh-CN': '斜杠命令在 Claude Desktop 中可以使用吗?'
|
||||
},
|
||||
'mcp.faq.8.a': {
|
||||
en: 'No. They ship with the Claude Code comfy-cloud plugin. Desktop connects to the same MCP server, so every tool works; just ask in plain language.',
|
||||
'zh-CN':
|
||||
'不可以。斜杠命令随 Claude Code 的 comfy-cloud 插件一起提供。Claude Desktop 连接的是同一个 MCP 服务器,因此所有工具都能使用;直接用自然语言提问即可。'
|
||||
},
|
||||
'mcp.faq.9.q': {
|
||||
en: 'Is it generally available?',
|
||||
'zh-CN': '现已正式发布了吗?'
|
||||
},
|
||||
'mcp.faq.8.a': {
|
||||
en: 'Comfy Cloud MCP is in open beta and available to everyone.',
|
||||
'zh-CN': 'Comfy Cloud MCP 目前处于公开测试阶段,所有人均可使用。'
|
||||
'mcp.faq.9.a': {
|
||||
en: 'Yes. Comfy Cloud MCP is in open beta and available to everyone with a Comfy account.',
|
||||
'zh-CN':
|
||||
'是的。Comfy Cloud MCP 目前处于公开测试阶段,任何拥有 Comfy 账户的人都可以使用。'
|
||||
},
|
||||
|
||||
// SiteNav
|
||||
@@ -2181,6 +2272,7 @@ const translations = {
|
||||
'nav.youtube': { en: 'YouTube', 'zh-CN': 'YouTube' },
|
||||
'nav.aboutUs': { en: 'About Us', 'zh-CN': '关于我们' },
|
||||
'nav.careers': { en: 'Careers', 'zh-CN': '招聘' },
|
||||
'nav.brand': { en: 'Brand', 'zh-CN': '品牌' },
|
||||
'nav.customerStories': { en: 'Customer Stories', 'zh-CN': '客户故事' },
|
||||
'nav.launches': { en: 'Launches', 'zh-CN': '发布' },
|
||||
'nav.downloadLocal': { en: 'DOWNLOAD DESKTOP', 'zh-CN': '下载桌面版' },
|
||||
@@ -4446,6 +4538,161 @@ const translations = {
|
||||
'launches.section.title': {
|
||||
en: 'Latest Launches',
|
||||
'zh-CN': '最新发布'
|
||||
},
|
||||
|
||||
// Brand Portal page (/brand)
|
||||
'brand.page.title': {
|
||||
en: 'Brand — Comfy',
|
||||
'zh-CN': '品牌 — Comfy'
|
||||
},
|
||||
'brand.page.description': {
|
||||
en: 'The Comfy brand portal: logos, color, typography, and voice. Everything you need to build something that looks and sounds like Comfy.',
|
||||
'zh-CN':
|
||||
'Comfy 品牌门户:标志、色彩、字体与语调。打造与 Comfy 观感一致、表达一致所需的一切。'
|
||||
},
|
||||
'brand.hero.label': {
|
||||
en: 'Brand Portal',
|
||||
'zh-CN': '品牌门户'
|
||||
},
|
||||
'brand.hero.heading': {
|
||||
en: 'Create with ComfyUI',
|
||||
'zh-CN': '用 ComfyUI 创作'
|
||||
},
|
||||
'brand.hero.subheading': {
|
||||
en: 'Logo, color, type, and voice. Everything you need to build something that looks and sounds like us.',
|
||||
'zh-CN': '标志、色彩、字体与语调。打造与我们观感一致、表达一致所需的一切。'
|
||||
},
|
||||
'brand.hero.viewGuidelines': {
|
||||
en: 'View brand guidelines',
|
||||
'zh-CN': '查看品牌规范'
|
||||
},
|
||||
'brand.hero.downloadLogos': {
|
||||
en: 'Download logos',
|
||||
'zh-CN': '下载标志'
|
||||
},
|
||||
'brand.logos.heading': {
|
||||
en: 'One mark, many dimensions.',
|
||||
'zh-CN': '一个标志,多种维度。'
|
||||
},
|
||||
'brand.logos.subheading': {
|
||||
en: 'Logos come in light and dark options. Use as provided. Do not distort, recolor, or outline. Make sure the logo is legible against its background.',
|
||||
'zh-CN':
|
||||
'标志提供浅色和深色两种版本。请按原样使用,不要变形、改色或描边。确保标志在其背景上清晰可辨。'
|
||||
},
|
||||
'brand.colors.heading': {
|
||||
en: 'Every color earns its place.',
|
||||
'zh-CN': '每种颜色都各得其所。'
|
||||
},
|
||||
'brand.colors.subheading': {
|
||||
en: 'Our color palette helps build brand recognition. When people think of Comfy, we want them to associate it with the following colors.',
|
||||
'zh-CN':
|
||||
'我们的调色板有助于建立品牌辨识度。当人们想到 Comfy 时,我们希望他们联想到以下这些颜色。'
|
||||
},
|
||||
'brand.colors.copy': {
|
||||
en: 'Copy',
|
||||
'zh-CN': '复制'
|
||||
},
|
||||
'brand.colors.copied': {
|
||||
en: 'Copied',
|
||||
'zh-CN': '已复制'
|
||||
},
|
||||
'brand.voice.heading': {
|
||||
en: 'Precise, never cute.',
|
||||
'zh-CN': '精准,绝不卖弄。'
|
||||
},
|
||||
'brand.voice.direct.title': {
|
||||
en: 'Direct',
|
||||
'zh-CN': '直接'
|
||||
},
|
||||
'brand.voice.direct.body': {
|
||||
en: 'We state things. We don’t hedge, qualify, or suggest. Short sentences. Active voice. One idea at a time.',
|
||||
'zh-CN':
|
||||
'我们直陈其事。不含糊、不设限、不暗示。短句。主动语态。一次只讲一个观点。'
|
||||
},
|
||||
'brand.voice.precise.title': {
|
||||
en: 'Precise',
|
||||
'zh-CN': '精准'
|
||||
},
|
||||
'brand.voice.precise.body': {
|
||||
en: 'We use the real names for things. Nodes, samplers, seeds, checkpoints. We don’t talk around the product or reach for metaphor when the technical term is already good.',
|
||||
'zh-CN':
|
||||
'我们直呼其名:nodes、samplers、seeds、checkpoints。当技术术语已经足够贴切时,我们不绕弯子,也不借用比喻。'
|
||||
},
|
||||
'brand.voice.human.title': {
|
||||
en: 'Human-first',
|
||||
'zh-CN': '以人为先'
|
||||
},
|
||||
'brand.voice.human.body': {
|
||||
en: 'The human creates. Comfy makes every step visible. We never write as though the AI is doing the work.',
|
||||
'zh-CN':
|
||||
'创作的是人。Comfy 让每一步都清晰可见。我们绝不把功劳写成是 AI 完成的。'
|
||||
},
|
||||
'brand.voice.antihype.title': {
|
||||
en: 'Anti-hype',
|
||||
'zh-CN': '拒绝浮夸'
|
||||
},
|
||||
'brand.voice.antihype.body': {
|
||||
en: 'We don’t write “stunning,” “revolutionary,” or “effortless.” We don’t promise magic. Our tagline says exactly what we mean: Method, not magic.',
|
||||
'zh-CN':
|
||||
'我们不写“惊艳”“革命性”或“毫不费力”。我们不承诺魔法。我们的口号恰如其分:方法,而非魔法。'
|
||||
},
|
||||
'brand.voice.doLabel': {
|
||||
en: 'Do',
|
||||
'zh-CN': '推荐'
|
||||
},
|
||||
'brand.voice.dontLabel': {
|
||||
en: 'Don’t',
|
||||
'zh-CN': '避免'
|
||||
},
|
||||
'brand.voice.do.0': {
|
||||
en: 'Route your prompt through a ControlNet. Wire the output to the VAE decode.',
|
||||
'zh-CN': '让你的 prompt 经过 ControlNet,再将输出连接到 VAE decode。'
|
||||
},
|
||||
'brand.voice.do.1': {
|
||||
en: 'Comfy runs on your hardware. Nothing leaves your machine.',
|
||||
'zh-CN': 'Comfy 在你自己的硬件上运行。任何数据都不会离开你的机器。'
|
||||
},
|
||||
'brand.voice.dont.0': {
|
||||
en: 'Simply connect your AI blocks and watch the magic happen!',
|
||||
'zh-CN': '只需连接你的 AI 模块,见证奇迹的发生!'
|
||||
},
|
||||
'brand.voice.dont.1': {
|
||||
en: 'Oops! Something went wrong. Please try again later.',
|
||||
'zh-CN': '哎呀!出了点问题,请稍后再试。'
|
||||
},
|
||||
'brand.trademark.heading': {
|
||||
en: 'Trademark guidelines.',
|
||||
'zh-CN': '商标使用规范。'
|
||||
},
|
||||
'brand.trademark.body1': {
|
||||
en: 'Comfy and ComfyUI are trademarks of Comfy Org. You’re welcome to reference them in content that accurately describes your work with our platform. Tutorials, reviews, integrations, and affiliate content all qualify.',
|
||||
'zh-CN':
|
||||
'Comfy 和 ComfyUI 是 Comfy Org 的商标。欢迎在准确描述你与我们平台相关工作的内容中引用它们。教程、评测、集成以及联盟内容均可。'
|
||||
},
|
||||
'brand.trademark.body2': {
|
||||
en: 'A few rules: don’t modify the logo, don’t use the Comfy name in your own product or company name, and don’t present your content in a way that implies official endorsement or partnership beyond what’s been agreed.',
|
||||
'zh-CN':
|
||||
'几条规则:不要修改标志,不要在你自己的产品或公司名称中使用 Comfy 这一名称,也不要以暗示官方认可或合作关系(超出双方已达成的约定)的方式呈现你的内容。'
|
||||
},
|
||||
'brand.trademark.body3': {
|
||||
en: 'For permissions outside these guidelines,',
|
||||
'zh-CN': '如需本规范之外的授权,请'
|
||||
},
|
||||
'brand.trademark.contact': {
|
||||
en: 'Contact Us',
|
||||
'zh-CN': '联系我们'
|
||||
},
|
||||
'brand.questions.heading': {
|
||||
en: 'Questions?',
|
||||
'zh-CN': '有疑问?'
|
||||
},
|
||||
'brand.questions.body': {
|
||||
en: 'For press, partnerships, or anything outside these guidelines,',
|
||||
'zh-CN': '如涉及媒体、合作,或本规范未涵盖的任何事宜,请'
|
||||
},
|
||||
'brand.questions.contact': {
|
||||
en: 'Contact Us',
|
||||
'zh-CN': '联系我们'
|
||||
}
|
||||
} as const satisfies Record<string, Record<Locale, string>>
|
||||
|
||||
|
||||
54
apps/website/src/pages/booking-confirmation.astro
Normal file
54
apps/website/src/pages/booking-confirmation.astro
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
import BaseLayout from '../layouts/BaseLayout.astro'
|
||||
import ResourceList from '../components/booking-confirmation/ResourceList.vue'
|
||||
import HeroSection from '../components/legal/HeroSection.vue'
|
||||
import { externalLinks, getRoutes } from '../config/routes'
|
||||
|
||||
const routes = getRoutes('en')
|
||||
|
||||
const resources = [
|
||||
{
|
||||
label: 'Learning Center',
|
||||
href: routes.learning,
|
||||
display: 'comfy.org/learning'
|
||||
},
|
||||
{
|
||||
label: 'Workflow templates',
|
||||
href: externalLinks.workflows,
|
||||
display: 'comfy.org/workflows'
|
||||
},
|
||||
{
|
||||
label: 'Customer stories',
|
||||
href: routes.customers,
|
||||
display: 'comfy.org/customers'
|
||||
},
|
||||
{
|
||||
label: 'Docs',
|
||||
href: externalLinks.docs,
|
||||
display: 'docs.comfy.org'
|
||||
}
|
||||
]
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title="You're booked - Comfy"
|
||||
description="Your meeting is booked. Check your email for the calendar invite and meeting link."
|
||||
noindex
|
||||
>
|
||||
<HeroSection title="You're booked." class="text-center" />
|
||||
|
||||
<section class="-mt-8 px-6 pb-24 lg:-mt-12 lg:pb-40">
|
||||
<div
|
||||
class="text-primary-comfy-canvas mx-auto flex max-w-2xl flex-col gap-10 text-center text-base font-light lg:text-lg"
|
||||
>
|
||||
<p>Check your email for the calendar invite and meeting link!</p>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<h2 class="text-primary-comfy-yellow text-xl font-semibold italic lg:text-2xl">
|
||||
Resources while you wait
|
||||
</h2>
|
||||
<ResourceList resources={resources} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
28
apps/website/src/pages/brand.astro
Normal file
28
apps/website/src/pages/brand.astro
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
import BaseLayout from '../layouts/BaseLayout.astro'
|
||||
import BrandBackground from '../templates/brand/BrandBackground.vue'
|
||||
import BrandHeroSection from '../templates/brand/BrandHeroSection.vue'
|
||||
import BrandLogosSection from '../templates/brand/BrandLogosSection.vue'
|
||||
import BrandColorSection from '../templates/brand/BrandColorSection.vue'
|
||||
import BrandVoiceSection from '../templates/brand/BrandVoiceSection.vue'
|
||||
import BrandTrademarkSection from '../templates/brand/BrandTrademarkSection.vue'
|
||||
import BrandQuestionsSection from '../templates/brand/BrandQuestionsSection.vue'
|
||||
import { t } from '../i18n/translations'
|
||||
|
||||
const locale = 'en' as const
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title={t('brand.page.title', locale)}
|
||||
description={t('brand.page.description', locale)}
|
||||
>
|
||||
<div class="relative">
|
||||
<BrandBackground client:idle />
|
||||
<BrandHeroSection />
|
||||
<BrandLogosSection />
|
||||
<BrandColorSection client:visible />
|
||||
<BrandVoiceSection />
|
||||
<BrandTrademarkSection />
|
||||
<BrandQuestionsSection />
|
||||
</div>
|
||||
</BaseLayout>
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
absoluteUrl,
|
||||
comfyUiApplicationNode,
|
||||
comfyUiSoftwareId,
|
||||
comfyUiSourceCodeNode,
|
||||
pageContext,
|
||||
} from '../utils/jsonLd'
|
||||
|
||||
@@ -30,7 +31,7 @@ const { siteUrl, locale } = pageContext(
|
||||
{ name: t('breadcrumb.home', locale), url: absoluteUrl(Astro.site, '/') },
|
||||
{ name: t('breadcrumb.download', locale) },
|
||||
]}
|
||||
extraJsonLd={[comfyUiApplicationNode(siteUrl)]}
|
||||
extraJsonLd={[comfyUiApplicationNode(siteUrl), comfyUiSourceCodeNode(siteUrl)]}
|
||||
keywords={['comfyui app', 'comfyui desktop app', 'comfyui desktop', 'comfy ui application', 'comfyui download', 'download comfyui', 'comfyui windows', 'comfyui mac', 'comfyui linux']}
|
||||
>
|
||||
<CloudBannerSection />
|
||||
|
||||
60
apps/website/src/pages/individual-submission.astro
Normal file
60
apps/website/src/pages/individual-submission.astro
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
import BaseLayout from '../layouts/BaseLayout.astro'
|
||||
import PlansPricingCta from '../components/individual-submission/PlansPricingCta.vue'
|
||||
import HeroSection from '../components/legal/HeroSection.vue'
|
||||
import { getRoutes } from '../config/routes'
|
||||
|
||||
const routes = getRoutes('en')
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title="Thanks for reaching out - Comfy"
|
||||
description="Thanks for reaching out. Based on what you shared, one of our self-serve plans is probably a better fit."
|
||||
noindex
|
||||
>
|
||||
<HeroSection title="Thanks for reaching out." class="text-center" />
|
||||
|
||||
<section class="-mt-8 px-6 pb-24 lg:-mt-12 lg:pb-40">
|
||||
<div
|
||||
class="text-primary-comfy-canvas mx-auto flex max-w-2xl flex-col gap-6 text-center text-base font-light lg:text-lg"
|
||||
>
|
||||
<p>
|
||||
Based on what you shared, one of our self-serve plans is probably a
|
||||
better fit.
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Standard</strong
|
||||
>,
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Creator</strong
|
||||
>, and
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Pro</strong
|
||||
> for individual creators, plus our new
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Teams</strong
|
||||
> plan for multiple users under shared billing.
|
||||
</p>
|
||||
|
||||
<PlansPricingCta
|
||||
href={routes.cloudPricing}
|
||||
label="See plans and pricing →"
|
||||
/>
|
||||
|
||||
<p class="text-primary-warm-gray mt-8 text-sm">
|
||||
Still think you have an enterprise need?<br /> We're happy to assist. Email: <a
|
||||
href="mailto:gtm-team@comfy.org"
|
||||
class="text-primary-comfy-yellow whitespace-nowrap underline underline-offset-4 hover:no-underline"
|
||||
>gtm-team@comfy.org</a
|
||||
>
|
||||
</p>
|
||||
|
||||
<p class="text-primary-warm-gray text-sm">
|
||||
Need help with something else? Email: <a
|
||||
href="mailto:support@comfy.org"
|
||||
class="text-primary-comfy-yellow whitespace-nowrap underline underline-offset-4 hover:no-underline"
|
||||
>support@comfy.org</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
54
apps/website/src/pages/zh-CN/booking-confirmation.astro
Normal file
54
apps/website/src/pages/zh-CN/booking-confirmation.astro
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro'
|
||||
import ResourceList from '../../components/booking-confirmation/ResourceList.vue'
|
||||
import HeroSection from '../../components/legal/HeroSection.vue'
|
||||
import { externalLinks, getRoutes } from '../../config/routes'
|
||||
|
||||
const routes = getRoutes('zh-CN')
|
||||
|
||||
const resources = [
|
||||
{
|
||||
label: '学习中心',
|
||||
href: routes.learning,
|
||||
display: 'comfy.org/learning'
|
||||
},
|
||||
{
|
||||
label: '工作流模板',
|
||||
href: externalLinks.workflows,
|
||||
display: 'comfy.org/workflows'
|
||||
},
|
||||
{
|
||||
label: '客户案例',
|
||||
href: routes.customers,
|
||||
display: 'comfy.org/customers'
|
||||
},
|
||||
{
|
||||
label: '文档',
|
||||
href: externalLinks.docs,
|
||||
display: 'docs.comfy.org'
|
||||
}
|
||||
]
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title="预约成功 - Comfy"
|
||||
description="您的会议已预约成功。请查收邮件中的日历邀请和会议链接。"
|
||||
noindex
|
||||
>
|
||||
<HeroSection title="预约成功。" class="text-center" />
|
||||
|
||||
<section class="-mt-8 px-6 pb-24 lg:-mt-12 lg:pb-40">
|
||||
<div
|
||||
class="text-primary-comfy-canvas mx-auto flex max-w-2xl flex-col gap-10 text-center text-base font-light lg:text-lg"
|
||||
>
|
||||
<p>请查收邮件中的日历邀请和会议链接!</p>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<h2 class="text-primary-comfy-yellow text-xl font-semibold italic lg:text-2xl">
|
||||
等待期间的资源
|
||||
</h2>
|
||||
<ResourceList resources={resources} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
26
apps/website/src/pages/zh-CN/brand.astro
Normal file
26
apps/website/src/pages/zh-CN/brand.astro
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro'
|
||||
import BrandBackground from '../../templates/brand/BrandBackground.vue'
|
||||
import BrandHeroSection from '../../templates/brand/BrandHeroSection.vue'
|
||||
import BrandLogosSection from '../../templates/brand/BrandLogosSection.vue'
|
||||
import BrandColorSection from '../../templates/brand/BrandColorSection.vue'
|
||||
import BrandVoiceSection from '../../templates/brand/BrandVoiceSection.vue'
|
||||
import BrandTrademarkSection from '../../templates/brand/BrandTrademarkSection.vue'
|
||||
import BrandQuestionsSection from '../../templates/brand/BrandQuestionsSection.vue'
|
||||
import { t } from '../../i18n/translations'
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title={t('brand.page.title', 'zh-CN')}
|
||||
description={t('brand.page.description', 'zh-CN')}
|
||||
>
|
||||
<div class="relative">
|
||||
<BrandBackground client:idle />
|
||||
<BrandHeroSection locale="zh-CN" />
|
||||
<BrandLogosSection locale="zh-CN" />
|
||||
<BrandColorSection client:visible locale="zh-CN" />
|
||||
<BrandVoiceSection locale="zh-CN" />
|
||||
<BrandTrademarkSection locale="zh-CN" />
|
||||
<BrandQuestionsSection locale="zh-CN" />
|
||||
</div>
|
||||
</BaseLayout>
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
absoluteUrl,
|
||||
comfyUiApplicationNode,
|
||||
comfyUiSoftwareId,
|
||||
comfyUiSourceCodeNode,
|
||||
pageContext,
|
||||
} from '../../utils/jsonLd'
|
||||
|
||||
@@ -33,7 +34,7 @@ const { siteUrl, locale } = pageContext(
|
||||
},
|
||||
{ name: t('breadcrumb.download', locale) },
|
||||
]}
|
||||
extraJsonLd={[comfyUiApplicationNode(siteUrl)]}
|
||||
extraJsonLd={[comfyUiApplicationNode(siteUrl), comfyUiSourceCodeNode(siteUrl)]}
|
||||
keywords={['comfyui app', 'comfyui desktop app', 'comfyui download', 'ComfyUI 下载', 'ComfyUI 桌面应用', 'ComfyUI 应用', 'ComfyUI Windows', 'ComfyUI macOS', 'ComfyUI Linux']}
|
||||
>
|
||||
<CloudBannerSection locale="zh-CN" />
|
||||
|
||||
57
apps/website/src/pages/zh-CN/individual-submission.astro
Normal file
57
apps/website/src/pages/zh-CN/individual-submission.astro
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro'
|
||||
import PlansPricingCta from '../../components/individual-submission/PlansPricingCta.vue'
|
||||
import HeroSection from '../../components/legal/HeroSection.vue'
|
||||
import { getRoutes } from '../../config/routes'
|
||||
|
||||
const routes = getRoutes('zh-CN')
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title="感谢您的联系 - Comfy"
|
||||
description="感谢您的联系。根据您提供的信息,我们的自助服务套餐之一可能更适合您。"
|
||||
noindex
|
||||
>
|
||||
<HeroSection title="感谢您的联系。" class="text-center" />
|
||||
|
||||
<section class="-mt-8 px-6 pb-24 lg:-mt-12 lg:pb-40">
|
||||
<div
|
||||
class="text-primary-comfy-canvas mx-auto flex max-w-2xl flex-col gap-6 text-center text-base font-light lg:text-lg"
|
||||
>
|
||||
<p>
|
||||
根据您提供的信息,我们的自助服务套餐之一可能更适合您。面向个人创作者的
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Standard</strong
|
||||
>、
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Creator</strong
|
||||
>
|
||||
和
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Pro</strong
|
||||
>,以及我们全新的
|
||||
<strong class="text-primary-comfy-yellow font-semibold italic">
|
||||
Teams</strong
|
||||
> 套餐,可让多位用户共享账单。
|
||||
</p>
|
||||
|
||||
<PlansPricingCta href={routes.cloudPricing} label="查看套餐与价格 →" />
|
||||
|
||||
<p class="text-primary-warm-gray mt-8 text-sm">
|
||||
仍然认为您有企业级需求?我们很乐意为您提供帮助。邮箱:<a
|
||||
href="mailto:gtm-team@comfy.org"
|
||||
class="text-primary-comfy-yellow whitespace-nowrap underline underline-offset-4 hover:no-underline"
|
||||
>gtm-team@comfy.org</a
|
||||
>
|
||||
</p>
|
||||
|
||||
<p class="text-primary-warm-gray text-sm">
|
||||
需要其他方面的帮助?邮箱:<a
|
||||
href="mailto:support@comfy.org"
|
||||
class="text-primary-comfy-yellow whitespace-nowrap underline underline-offset-4 hover:no-underline"
|
||||
>support@comfy.org</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
112
apps/website/src/templates/brand/BrandBackground.vue
Normal file
112
apps/website/src/templates/brand/BrandBackground.vue
Normal file
@@ -0,0 +1,112 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
useEventListener,
|
||||
useIntersectionObserver,
|
||||
useRafFn
|
||||
} from '@vueuse/core'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import { prefersReducedMotion } from '../../composables/useReducedMotion'
|
||||
|
||||
interface Node {
|
||||
x: number
|
||||
y: number
|
||||
vx: number
|
||||
vy: number
|
||||
}
|
||||
|
||||
const canvasEl = ref<HTMLCanvasElement | null>(null)
|
||||
|
||||
let dpr =
|
||||
typeof window !== 'undefined' ? Math.min(window.devicePixelRatio || 1, 2) : 1
|
||||
|
||||
const nodes: Node[] = Array.from({ length: 14 }, () => ({
|
||||
x: Math.random(),
|
||||
y: Math.random(),
|
||||
vx: (Math.random() - 0.5) * 0.0005,
|
||||
vy: (Math.random() - 0.5) * 0.0005
|
||||
}))
|
||||
|
||||
let ctx: CanvasRenderingContext2D | null = null
|
||||
|
||||
function draw() {
|
||||
const el = canvasEl.value
|
||||
if (!el || !ctx) return
|
||||
const w = el.width
|
||||
const h = el.height
|
||||
ctx.clearRect(0, 0, w, h)
|
||||
|
||||
for (const n of nodes) {
|
||||
n.x += n.vx
|
||||
n.y += n.vy
|
||||
if (n.x < 0 || n.x > 1) n.vx *= -1
|
||||
if (n.y < 0 || n.y > 1) n.vy *= -1
|
||||
}
|
||||
|
||||
ctx.strokeStyle = 'rgba(242, 255, 89, 0.18)'
|
||||
ctx.lineWidth = dpr
|
||||
const max = Math.min(w, h) * 0.22
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
for (let j = i + 1; j < nodes.length; j++) {
|
||||
const a = nodes[i]
|
||||
const b = nodes[j]
|
||||
const dx = (a.x - b.x) * w
|
||||
const dy = (a.y - b.y) * h
|
||||
const d = Math.hypot(dx, dy)
|
||||
if (d < max) {
|
||||
ctx.globalAlpha = 1 - d / max
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(a.x * w, a.y * h)
|
||||
const mx = ((a.x + b.x) / 2) * w
|
||||
ctx.bezierCurveTo(mx, a.y * h, mx, b.y * h, b.x * w, b.y * h)
|
||||
ctx.stroke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctx.globalAlpha = 1
|
||||
ctx.fillStyle = 'rgba(242, 255, 89, 0.9)'
|
||||
for (const n of nodes) {
|
||||
ctx.beginPath()
|
||||
ctx.arc(n.x * w, n.y * h, 2.5 * dpr, 0, Math.PI * 2)
|
||||
ctx.fill()
|
||||
}
|
||||
}
|
||||
|
||||
// Resizing clears the canvas bitmap, so repaint immediately afterwards to keep
|
||||
// the field visible even when the RAF loop is paused (off screen or
|
||||
// reduced-motion). Also refresh dpr in case the window moved to another display.
|
||||
function resize() {
|
||||
const el = canvasEl.value
|
||||
if (!el) return
|
||||
dpr = Math.min(window.devicePixelRatio || 1, 2)
|
||||
el.width = el.offsetWidth * dpr
|
||||
el.height = el.offsetHeight * dpr
|
||||
draw()
|
||||
}
|
||||
|
||||
const { pause, resume } = useRafFn(draw, { immediate: false })
|
||||
|
||||
// Only animate while the field is on screen, and honour reduced-motion by
|
||||
// painting a single static frame instead of looping.
|
||||
useIntersectionObserver(canvasEl, ([entry]) => {
|
||||
if (prefersReducedMotion()) return
|
||||
if (entry?.isIntersecting) resume()
|
||||
else pause()
|
||||
})
|
||||
|
||||
useEventListener('resize', resize)
|
||||
|
||||
onMounted(() => {
|
||||
ctx = canvasEl.value?.getContext('2d') ?? null
|
||||
resize()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<canvas
|
||||
ref="canvasEl"
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-x-0 top-0 -z-10 h-screen w-full"
|
||||
/>
|
||||
</template>
|
||||
93
apps/website/src/templates/brand/BrandColorSection.vue
Normal file
93
apps/website/src/templates/brand/BrandColorSection.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<script setup lang="ts">
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
import { useClipboard } from '@vueuse/core'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import SectionHeader from '../../components/common/SectionHeader.vue'
|
||||
import { brandColors } from '../../data/brandColors'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const specRows = ['hex', 'rgb', 'hsl', 'cmyk'] as const
|
||||
|
||||
const { copy, copied } = useClipboard({ copiedDuring: 1500 })
|
||||
const copiedHex = ref<string | null>(null)
|
||||
const copiedValue = ref('')
|
||||
|
||||
function copyValue(hex: string, value: string) {
|
||||
copiedHex.value = hex
|
||||
copiedValue.value = value
|
||||
void copy(value)
|
||||
}
|
||||
|
||||
function isCardCopied(hex: string) {
|
||||
return copied.value && copiedHex.value === hex
|
||||
}
|
||||
|
||||
const liveMessage = computed(() =>
|
||||
copied.value ? `${t('brand.colors.copied', locale)} ${copiedValue.value}` : ''
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="max-w-9xl mx-auto px-6 py-10 lg:px-20 lg:py-12">
|
||||
<SectionHeader align="start" max-width="xl">
|
||||
{{ t('brand.colors.heading', locale) }}
|
||||
<template #subtitle>
|
||||
<p class="text-primary-warm-gray mt-4 max-w-2xl text-sm leading-[1.45]">
|
||||
{{ t('brand.colors.subheading', locale) }}
|
||||
</p>
|
||||
</template>
|
||||
</SectionHeader>
|
||||
|
||||
<span class="sr-only" aria-live="polite">{{ liveMessage }}</span>
|
||||
|
||||
<ul class="mt-10 grid grid-cols-2 gap-4 lg:grid-cols-5">
|
||||
<li
|
||||
v-for="color in brandColors"
|
||||
:key="color.hex"
|
||||
:class="
|
||||
cn(
|
||||
'flex min-h-[123px] cursor-pointer flex-col rounded-[30px] p-6',
|
||||
color.swatchClass,
|
||||
color.textClass,
|
||||
color.wide && 'lg:col-span-2',
|
||||
color.border && 'border-primary-warm-gray border-[0.783px]'
|
||||
)
|
||||
"
|
||||
@click="copyValue(color.hex, color.hex)"
|
||||
>
|
||||
<div
|
||||
v-if="isCardCopied(color.hex)"
|
||||
class="flex flex-1 items-center justify-center text-center text-sm font-semibold"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{{ t('brand.colors.copied', locale) }} {{ copiedValue }}
|
||||
</div>
|
||||
<template v-else>
|
||||
<span class="text-xs font-semibold">{{ color.name }}</span>
|
||||
<dl
|
||||
class="mt-3 grid grid-cols-[auto_1fr] gap-x-4 gap-y-0.5 text-xs leading-[1.4]"
|
||||
>
|
||||
<template v-for="row in specRows" :key="row">
|
||||
<dt class="uppercase opacity-50">{{ row }}</dt>
|
||||
<dd>
|
||||
<button
|
||||
type="button"
|
||||
:aria-label="`${t('brand.colors.copy', locale)} ${row} ${color[row]}`"
|
||||
class="cursor-pointer text-left hover:underline"
|
||||
@click.stop="copyValue(color.hex, color[row])"
|
||||
>
|
||||
{{ color[row] }}
|
||||
</button>
|
||||
</dd>
|
||||
</template>
|
||||
</dl>
|
||||
</template>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</template>
|
||||
55
apps/website/src/templates/brand/BrandHeroSection.vue
Normal file
55
apps/website/src/templates/brand/BrandHeroSection.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import Button from '../../components/ui/button/Button.vue'
|
||||
import { BRAND_ASSETS_ZIP, BRAND_GUIDELINES_PDF } from '../../data/brandAssets'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="max-w-9xl mx-auto px-6 pt-4 pb-10 text-center lg:px-20 lg:pb-12"
|
||||
>
|
||||
<p
|
||||
class="text-primary-comfy-yellow text-sm font-extrabold tracking-[0.7px] uppercase"
|
||||
>
|
||||
{{ t('brand.hero.label', locale) }}
|
||||
</p>
|
||||
<h1
|
||||
class="lg:text-6.5xl mx-auto mt-6 max-w-4xl text-4xl leading-[1.3] font-light tracking-[-0.03em] text-primary-comfy-canvas md:text-5xl"
|
||||
>
|
||||
{{ t('brand.hero.heading', locale) }}
|
||||
</h1>
|
||||
<p
|
||||
class="mx-auto mt-6 max-w-2xl text-[17px] leading-[1.6] font-light text-primary-comfy-canvas/80"
|
||||
>
|
||||
{{ t('brand.hero.subheading', locale) }}
|
||||
</p>
|
||||
|
||||
<div
|
||||
class="mt-10 flex flex-col items-center justify-center gap-3 sm:flex-row"
|
||||
>
|
||||
<Button
|
||||
as="a"
|
||||
:href="BRAND_GUIDELINES_PDF"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
variant="default"
|
||||
class="h-12 w-full px-5 text-sm font-extrabold sm:w-auto"
|
||||
>
|
||||
{{ t('brand.hero.viewGuidelines', locale) }}
|
||||
</Button>
|
||||
<Button
|
||||
as="a"
|
||||
:href="BRAND_ASSETS_ZIP"
|
||||
download
|
||||
variant="outline"
|
||||
class="h-12 w-full px-5 text-sm font-extrabold sm:w-auto"
|
||||
>
|
||||
{{ t('brand.hero.downloadLogos', locale) }}
|
||||
</Button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
58
apps/website/src/templates/brand/BrandLogosSection.vue
Normal file
58
apps/website/src/templates/brand/BrandLogosSection.vue
Normal file
@@ -0,0 +1,58 @@
|
||||
<script setup lang="ts">
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import { cn } from '@comfyorg/tailwind-utils'
|
||||
|
||||
import SectionHeader from '../../components/common/SectionHeader.vue'
|
||||
import { affiliateBrandAssets } from '../../data/affiliateBrandAssets'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const assets = affiliateBrandAssets.map((asset) =>
|
||||
asset.id === 'icon' ? { ...asset, preview: '/icons/comfyicon.svg' } : asset
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="logos" class="max-w-9xl mx-auto px-6 py-10 lg:px-20 lg:py-12">
|
||||
<SectionHeader align="start" max-width="xl">
|
||||
{{ t('brand.logos.heading', locale) }}
|
||||
<template #subtitle>
|
||||
<p class="text-primary-warm-gray mt-4 max-w-2xl text-sm leading-[1.45]">
|
||||
{{ t('brand.logos.subheading', locale) }}
|
||||
</p>
|
||||
</template>
|
||||
</SectionHeader>
|
||||
|
||||
<ul class="mt-10 grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<li
|
||||
v-for="asset in assets"
|
||||
:key="asset.id"
|
||||
class="flex min-h-60 flex-col rounded-[30px] border-[1.5px] border-white/8 lg:min-h-[285px]"
|
||||
>
|
||||
<div class="flex flex-1 items-center justify-center p-8">
|
||||
<img
|
||||
:src="asset.preview"
|
||||
:alt="asset.title[locale]"
|
||||
:class="
|
||||
cn(
|
||||
'object-contain',
|
||||
asset.id === 'icon'
|
||||
? 'size-24 rounded-[23%] border border-white/10'
|
||||
: 'max-h-24 max-w-[75%]'
|
||||
)
|
||||
"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
class="pb-8 text-center text-[21px] font-medium tracking-[1.05px] text-primary-comfy-canvas"
|
||||
>
|
||||
{{ asset.title[locale] }}
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</template>
|
||||
33
apps/website/src/templates/brand/BrandQuestionsSection.vue
Normal file
33
apps/website/src/templates/brand/BrandQuestionsSection.vue
Normal file
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import SectionHeader from '../../components/common/SectionHeader.vue'
|
||||
import Button from '../../components/ui/button/Button.vue'
|
||||
import { externalLinks } from '../../config/routes.ts'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="max-w-9xl mx-auto px-6 pt-10 pb-24 lg:px-20 lg:pt-12 lg:pb-32"
|
||||
>
|
||||
<SectionHeader align="start" max-width="xl">
|
||||
{{ t('brand.questions.heading', locale) }}
|
||||
</SectionHeader>
|
||||
|
||||
<p class="text-primary-warm-gray mt-6 max-w-2xl text-sm leading-[1.6]">
|
||||
{{ t('brand.questions.body', locale) }}
|
||||
<Button
|
||||
as="a"
|
||||
variant="inline"
|
||||
:href="externalLinks.support"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{{ t('brand.questions.contact', locale) }}
|
||||
</Button>
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
37
apps/website/src/templates/brand/BrandTrademarkSection.vue
Normal file
37
apps/website/src/templates/brand/BrandTrademarkSection.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import SectionHeader from '../../components/common/SectionHeader.vue'
|
||||
import Button from '../../components/ui/button/Button.vue'
|
||||
import { externalLinks } from '../../config/routes.ts'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="max-w-9xl mx-auto px-6 py-10 lg:px-20 lg:py-12">
|
||||
<SectionHeader align="start" max-width="xl">
|
||||
{{ t('brand.trademark.heading', locale) }}
|
||||
</SectionHeader>
|
||||
|
||||
<div
|
||||
class="text-primary-warm-gray mt-6 flex max-w-4xl flex-col gap-4 text-sm leading-[1.6]"
|
||||
>
|
||||
<p>{{ t('brand.trademark.body1', locale) }}</p>
|
||||
<p>{{ t('brand.trademark.body2', locale) }}</p>
|
||||
<p>
|
||||
{{ t('brand.trademark.body3', locale) }}
|
||||
<Button
|
||||
as="a"
|
||||
variant="inline"
|
||||
:href="externalLinks.support"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{{ t('brand.trademark.contact', locale) }}
|
||||
</Button>
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
100
apps/website/src/templates/brand/BrandVoiceSection.vue
Normal file
100
apps/website/src/templates/brand/BrandVoiceSection.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<script setup lang="ts">
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
|
||||
import SectionHeader from '../../components/common/SectionHeader.vue'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const principles = [
|
||||
{
|
||||
title: t('brand.voice.direct.title', locale),
|
||||
body: t('brand.voice.direct.body', locale)
|
||||
},
|
||||
{
|
||||
title: t('brand.voice.precise.title', locale),
|
||||
body: t('brand.voice.precise.body', locale)
|
||||
},
|
||||
{
|
||||
title: t('brand.voice.human.title', locale),
|
||||
body: t('brand.voice.human.body', locale)
|
||||
},
|
||||
{
|
||||
title: t('brand.voice.antihype.title', locale),
|
||||
body: t('brand.voice.antihype.body', locale)
|
||||
}
|
||||
]
|
||||
|
||||
const doExamples = [
|
||||
t('brand.voice.do.0', locale),
|
||||
t('brand.voice.do.1', locale)
|
||||
]
|
||||
|
||||
const dontExamples = [
|
||||
t('brand.voice.dont.0', locale),
|
||||
t('brand.voice.dont.1', locale)
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="max-w-9xl mx-auto px-6 py-10 lg:px-20 lg:py-12">
|
||||
<SectionHeader align="start" max-width="xl">
|
||||
{{ t('brand.voice.heading', locale) }}
|
||||
</SectionHeader>
|
||||
|
||||
<dl class="mt-10 flex max-w-4xl flex-col gap-3.5 text-sm leading-[1.6]">
|
||||
<div v-for="principle in principles" :key="principle.title">
|
||||
<dt class="text-primary-comfy-yellow">{{ principle.title }}</dt>
|
||||
<dd class="text-primary-warm-gray">{{ principle.body }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<div class="mt-12 grid gap-4 md:grid-cols-2">
|
||||
<div class="bg-transparency-white-t4 flex flex-col gap-4 rounded-4xl p-8">
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="bg-primary-comfy-yellow size-2.5 rounded-full"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span
|
||||
class="text-sm font-bold tracking-wider text-primary-comfy-canvas uppercase"
|
||||
>
|
||||
{{ t('brand.voice.doLabel', locale) }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="example in doExamples"
|
||||
:key="example"
|
||||
class="bg-transparency-ink-t80 rounded-2xl p-5"
|
||||
>
|
||||
<p class="text-base/[1.45] text-primary-comfy-canvas">
|
||||
{{ example }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-transparency-white-t4 flex flex-col gap-4 rounded-4xl p-8">
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="bg-primary-warm-gray size-2.5 rounded-full"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span
|
||||
class="text-primary-warm-gray text-sm font-bold tracking-wider uppercase"
|
||||
>
|
||||
{{ t('brand.voice.dontLabel', locale) }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="example in dontExamples"
|
||||
:key="example"
|
||||
class="bg-transparency-ink-t80 rounded-2xl p-5"
|
||||
>
|
||||
<p class="text-primary-warm-gray text-base/[1.45] line-through">
|
||||
{{ example }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -7,35 +7,40 @@ import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const PROMPT = t('mcp.hero.demoPrompt', locale)
|
||||
const generateLabel = t('mcp.hero.demoGenerate', locale)
|
||||
|
||||
// Each cycle types the prompt that produces the card about to slide in.
|
||||
const cards = [
|
||||
{
|
||||
promptKey: 'mcp.hero.demoPromptMoodboard',
|
||||
actionKey: 'mcp.hero.demoActionGenerateImage',
|
||||
file: 'moodboard_v1.png · 6-up',
|
||||
tag: 'Gmail',
|
||||
thumb: '/images/mcp/mcp-thumb-moodboard.webp'
|
||||
},
|
||||
{
|
||||
promptKey: 'mcp.hero.demoPromptConcepts',
|
||||
actionKey: 'mcp.hero.demoActionGenerateImage',
|
||||
file: 'concepts_01–03.png',
|
||||
tag: 'Notion',
|
||||
thumb: '/images/mcp/mcp-thumb-concepts.webp'
|
||||
},
|
||||
{
|
||||
promptKey: 'mcp.hero.demoPromptKeyart',
|
||||
actionKey: 'mcp.hero.demoActionGenerateImage',
|
||||
file: 'hero_keyart.png',
|
||||
tag: 'Figma',
|
||||
thumb: '/images/mcp/mcp-thumb-keyart.webp'
|
||||
},
|
||||
{
|
||||
promptKey: 'mcp.hero.demoPromptPbr',
|
||||
actionKey: 'mcp.hero.demoActionGenerate3d',
|
||||
file: 'asphalt_pbr/ · 5 maps',
|
||||
tag: 'Blender',
|
||||
thumb: '/images/mcp/mcp-thumb-asphalt.webp'
|
||||
},
|
||||
{
|
||||
promptKey: 'mcp.hero.demoPromptUpscale',
|
||||
actionKey: 'mcp.hero.demoActionUpscale',
|
||||
file: 'kaiju_neon_4k.png · 4096',
|
||||
tag: null,
|
||||
@@ -65,15 +70,15 @@ function schedule(fn: () => void, ms: number) {
|
||||
}, ms)
|
||||
}
|
||||
|
||||
function typePrompt(onDone: () => void) {
|
||||
function typePrompt(prompt: string, onDone: () => void) {
|
||||
displayedPrompt.value = ''
|
||||
promptDone.value = false
|
||||
let i = 0
|
||||
|
||||
function step() {
|
||||
i++
|
||||
displayedPrompt.value = PROMPT.slice(0, i)
|
||||
if (i < PROMPT.length) {
|
||||
displayedPrompt.value = prompt.slice(0, i)
|
||||
if (i < prompt.length) {
|
||||
schedule(step, 35)
|
||||
} else {
|
||||
promptDone.value = true
|
||||
@@ -94,8 +99,8 @@ function revealNextCard() {
|
||||
return
|
||||
}
|
||||
|
||||
// Type the prompt, then slide in the next card
|
||||
typePrompt(() => {
|
||||
// Type the next card's prompt, then slide that card in
|
||||
typePrompt(t(cards[visibleCount.value].promptKey, locale), () => {
|
||||
visibleCount.value++
|
||||
schedule(revealNextCard, 400)
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const faqNumbers = [1, 2, 3, 4, 5, 6, 7, 8] as const
|
||||
const faqNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] as const
|
||||
|
||||
const faqs = faqNumbers.map((n) => ({
|
||||
id: String(n),
|
||||
|
||||
@@ -11,9 +11,10 @@ const ctas = mcpCtas(locale)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 5rem/6.75rem = HeaderMain's rendered height (py-5 / lg:py-8) so the hero fills the viewport below the sticky nav -->
|
||||
<HeroSplit01
|
||||
:locale="locale"
|
||||
class="min-h-screen"
|
||||
class="min-h-[calc(100svh-5rem)] lg:min-h-[calc(100svh-6.75rem)]"
|
||||
badge-text="MCP"
|
||||
:title="t('mcp.hero.heading', locale)"
|
||||
:subtitle="t('mcp.hero.subtitle', locale)"
|
||||
|
||||
@@ -23,7 +23,7 @@ const steps: FeatureStep[] = stepNumbers.map((n) => ({
|
||||
<FeatureGrid02
|
||||
:heading="t('mcp.howItWorks.heading', locale)"
|
||||
:steps="steps"
|
||||
:primary-cta="ctas.runWorkflow"
|
||||
:primary-cta="ctas.installMcp"
|
||||
:secondary-cta="ctas.docs"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -1,69 +1,180 @@
|
||||
<script setup lang="ts">
|
||||
import { ArrowUpRight } from '@lucide/vue'
|
||||
import { TabsContent, TabsList, TabsRoot, TabsTrigger } from 'reka-ui'
|
||||
|
||||
import FeatureGrid01 from '../../components/blocks/FeatureGrid01.vue'
|
||||
import type { FeatureCard } from '../../components/blocks/FeatureGrid01.vue'
|
||||
import SectionHeader from '../../components/common/SectionHeader.vue'
|
||||
import SectionLabel from '../../components/common/SectionLabel.vue'
|
||||
import CopyableField from '../../components/ui/copyable-field/CopyableField.vue'
|
||||
import { externalLinks } from '../../config/routes'
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
const cards: FeatureCard[] = [
|
||||
const agentCommand = t('mcp.setup.option1.command', locale).replace(
|
||||
'{url}',
|
||||
externalLinks.docsMcp
|
||||
)
|
||||
|
||||
interface McpClient {
|
||||
id: string
|
||||
name: string
|
||||
step: string
|
||||
command?: string
|
||||
link?: { label: string; href: string }
|
||||
}
|
||||
|
||||
const clients: McpClient[] = [
|
||||
{
|
||||
id: 'step1',
|
||||
label: t('mcp.setup.step1.label', locale),
|
||||
title: t('mcp.setup.step1.title', locale),
|
||||
description: t('mcp.setup.step1.description', locale),
|
||||
action: {
|
||||
type: 'code',
|
||||
value: t('mcp.setup.step1.command', locale).replace(
|
||||
'{url}',
|
||||
externalLinks.docsMcp
|
||||
)
|
||||
id: 'claude-code',
|
||||
name: 'Claude Code',
|
||||
step: t('mcp.setup.clients.claudeCode.step', locale),
|
||||
command: `claude mcp add --transport http comfy-cloud ${externalLinks.mcpEndpoint}`
|
||||
},
|
||||
{
|
||||
id: 'claude-desktop',
|
||||
name: 'Claude Desktop',
|
||||
step: t('mcp.setup.clients.claudeDesktop.step', locale)
|
||||
},
|
||||
{
|
||||
id: 'cursor',
|
||||
name: 'Cursor',
|
||||
step: t('mcp.setup.clients.cursor.step', locale),
|
||||
link: {
|
||||
label: t('mcp.setup.clients.cursor.linkLabel', locale),
|
||||
href: externalLinks.apiKeys
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'step2',
|
||||
label: t('mcp.setup.step2.label', locale),
|
||||
title: t('mcp.setup.step2.title', locale),
|
||||
description: t('mcp.setup.step2.description', locale),
|
||||
action: {
|
||||
type: 'link',
|
||||
label: t('mcp.setup.step2.cta', locale),
|
||||
href: externalLinks.docsMcp,
|
||||
target: '_blank',
|
||||
icon: ArrowUpRight,
|
||||
variant: 'default'
|
||||
}
|
||||
id: 'codex',
|
||||
name: 'Codex',
|
||||
step: t('mcp.setup.clients.codex.step', locale),
|
||||
command: `codex mcp add comfy-cloud --url ${externalLinks.mcpEndpoint}`
|
||||
},
|
||||
{
|
||||
id: 'step3',
|
||||
label: t('mcp.setup.step3.label', locale),
|
||||
title: t('mcp.setup.step3.title', locale),
|
||||
description: t('mcp.setup.step3.description', locale),
|
||||
action: {
|
||||
type: 'link',
|
||||
label: t('mcp.setup.step3.cta', locale),
|
||||
href: externalLinks.mcpSkills,
|
||||
target: '_blank',
|
||||
icon: ArrowUpRight,
|
||||
variant: 'default'
|
||||
id: 'other',
|
||||
name: t('mcp.setup.clients.other.name', locale),
|
||||
step: t('mcp.setup.clients.other.step', locale),
|
||||
link: {
|
||||
label: t('mcp.setup.clients.other.linkLabel', locale),
|
||||
href: externalLinks.docsMcp
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const copyLabel = t('ui.copy', locale)
|
||||
const copiedLabel = t('ui.copied', locale)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FeatureGrid01
|
||||
<section
|
||||
id="setup"
|
||||
class="scroll-mt-24 lg:scroll-mt-36"
|
||||
:eyebrow="t('mcp.setup.label', locale)"
|
||||
:heading="t('mcp.setup.heading', locale)"
|
||||
:subtitle="t('mcp.setup.subtitle', locale)"
|
||||
:columns="3"
|
||||
:cards="cards"
|
||||
:copy-label="t('ui.copy', locale)"
|
||||
:copied-label="t('ui.copied', locale)"
|
||||
/>
|
||||
class="max-w-9xl mx-auto scroll-mt-24 px-6 py-16 lg:scroll-mt-36 lg:py-24"
|
||||
>
|
||||
<SectionHeader
|
||||
max-width="xl"
|
||||
:label="t('mcp.setup.label', locale)"
|
||||
align="start"
|
||||
>
|
||||
{{ t('mcp.setup.heading', locale) }}
|
||||
<template #subtitle>
|
||||
<p class="mt-4 max-w-xl text-sm text-smoke-700 lg:text-base">
|
||||
{{ t('mcp.setup.subtitle', locale) }}
|
||||
</p>
|
||||
</template>
|
||||
</SectionHeader>
|
||||
|
||||
<div class="mt-16 grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<div
|
||||
class="bg-transparency-white-t4 flex flex-col rounded-3xl p-6 lg:p-8"
|
||||
>
|
||||
<SectionLabel>{{ t('mcp.setup.option1.label', locale) }}</SectionLabel>
|
||||
<h3
|
||||
class="mt-3 text-xl font-light text-primary-comfy-canvas lg:text-2xl"
|
||||
>
|
||||
{{ t('mcp.setup.option1.title', locale) }}
|
||||
</h3>
|
||||
<p class="mt-3 text-sm text-smoke-700">
|
||||
{{ t('mcp.setup.option1.description', locale) }}
|
||||
</p>
|
||||
<div class="mt-6">
|
||||
<CopyableField
|
||||
:value="agentCommand"
|
||||
:copy-label="copyLabel"
|
||||
:copied-label="copiedLabel"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-auto pt-6 text-sm text-smoke-700">
|
||||
{{ t('mcp.setup.skillsNote', locale)
|
||||
}}<a
|
||||
:href="externalLinks.mcpSkills"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="focus-visible:ring-primary-comfy-yellow/50 rounded-sm text-primary-comfy-canvas underline underline-offset-4 focus-visible:ring-2 focus-visible:outline-none"
|
||||
>{{ t('mcp.setup.skillsLink', locale) }}</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="bg-transparency-white-t4 flex flex-col rounded-3xl p-6 lg:p-8"
|
||||
>
|
||||
<SectionLabel>{{ t('mcp.setup.option2.label', locale) }}</SectionLabel>
|
||||
<h3
|
||||
class="mt-3 text-xl font-light text-primary-comfy-canvas lg:text-2xl"
|
||||
>
|
||||
{{ t('mcp.setup.option2.title', locale) }}
|
||||
</h3>
|
||||
<p class="mt-3 text-sm text-smoke-700">
|
||||
{{ t('mcp.setup.option2.description', locale) }}
|
||||
</p>
|
||||
<div class="mt-6">
|
||||
<CopyableField
|
||||
:value="externalLinks.mcpEndpoint"
|
||||
:copy-label="copyLabel"
|
||||
:copied-label="copiedLabel"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<TabsRoot default-value="claude-code" class="mt-6">
|
||||
<TabsList
|
||||
:aria-label="t('mcp.setup.option2.tabsLabel', locale)"
|
||||
class="flex flex-wrap gap-2"
|
||||
>
|
||||
<TabsTrigger
|
||||
v-for="client in clients"
|
||||
:key="client.id"
|
||||
:value="client.id"
|
||||
class="bg-transparency-white-t4 focus-visible:ring-primary-comfy-yellow/50 data-[state=active]:bg-primary-comfy-yellow cursor-pointer rounded-full px-4 py-2 text-xs font-bold tracking-wider text-smoke-700 uppercase transition-colors hover:text-primary-comfy-canvas focus-visible:ring-2 focus-visible:outline-none data-[state=active]:text-primary-comfy-ink"
|
||||
>
|
||||
{{ client.name }}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent
|
||||
v-for="client in clients"
|
||||
:key="client.id"
|
||||
:value="client.id"
|
||||
class="mt-4 flex min-h-24 flex-col gap-3"
|
||||
>
|
||||
<p class="text-sm text-smoke-700">
|
||||
{{ client.step
|
||||
}}<a
|
||||
v-if="client.link"
|
||||
:href="client.link.href"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="focus-visible:ring-primary-comfy-yellow/50 rounded-sm text-primary-comfy-canvas underline underline-offset-4 focus-visible:ring-2 focus-visible:outline-none"
|
||||
>{{ client.link.label }}</a
|
||||
>
|
||||
</p>
|
||||
<CopyableField
|
||||
v-if="client.command"
|
||||
:value="client.command"
|
||||
:copy-label="copyLabel"
|
||||
:copied-label="copiedLabel"
|
||||
/>
|
||||
</TabsContent>
|
||||
</TabsRoot>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -7,16 +7,21 @@ import { t } from '../../i18n/translations'
|
||||
const { locale = 'en' } = defineProps<{ locale?: Locale }>()
|
||||
|
||||
type ToolMedia =
|
||||
| { type: 'image'; src: string }
|
||||
| { type: 'image'; src: string; fit?: 'cover' | 'contain' }
|
||||
| {
|
||||
type: 'video'
|
||||
src: string
|
||||
autoplay?: boolean
|
||||
loop?: boolean
|
||||
hideControls?: boolean
|
||||
fit?: 'cover' | 'contain'
|
||||
}
|
||||
|
||||
const tools: { n: 1 | 2 | 3; media: ToolMedia; altKey?: TranslationKey }[] = [
|
||||
const tools: {
|
||||
n: 1 | 2 | 3 | 4 | 5 | 6
|
||||
media: ToolMedia
|
||||
altKey?: TranslationKey
|
||||
}[] = [
|
||||
{
|
||||
n: 1,
|
||||
media: {
|
||||
@@ -40,9 +45,38 @@ const tools: { n: 1 | 2 | 3; media: ToolMedia; altKey?: TranslationKey }[] = [
|
||||
src: 'https://media.comfy.org/website/mcp/run-real-workflows.mp4',
|
||||
autoplay: true,
|
||||
loop: true,
|
||||
hideControls: true
|
||||
hideControls: true,
|
||||
fit: 'contain'
|
||||
},
|
||||
altKey: 'mcp.tools.3.alt'
|
||||
},
|
||||
{
|
||||
n: 4,
|
||||
media: {
|
||||
type: 'image',
|
||||
src: 'https://media.comfy.org/website/mcp/direct-any-model.png'
|
||||
},
|
||||
altKey: 'mcp.tools.4.alt'
|
||||
},
|
||||
{
|
||||
n: 5,
|
||||
media: {
|
||||
type: 'image',
|
||||
src: 'https://media.comfy.org/website/mcp/generate-in-batches.png'
|
||||
},
|
||||
altKey: 'mcp.tools.5.alt'
|
||||
},
|
||||
{
|
||||
n: 6,
|
||||
media: {
|
||||
type: 'video',
|
||||
src: 'https://media.comfy.org/website/homepage/showcase/ui-overview.webm',
|
||||
autoplay: true,
|
||||
loop: true,
|
||||
hideControls: true,
|
||||
fit: 'contain'
|
||||
},
|
||||
altKey: 'mcp.tools.6.alt'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { externalLinks, getRoutes } from '../../config/routes'
|
||||
import { externalLinks } from '../../config/routes'
|
||||
import type { Locale } from '../../i18n/translations'
|
||||
import { t } from '../../i18n/translations'
|
||||
|
||||
@@ -9,14 +9,13 @@ export interface McpCta {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls-to-action for the MCP page: view the docs, jump to the on-page setup
|
||||
* steps, or run a workflow in the cloud. The hero leads with install + docs;
|
||||
* the "how it works" section pairs run-a-workflow with docs.
|
||||
* Calls-to-action for the MCP page: view the docs or jump to the on-page
|
||||
* setup options. Both the hero and the "how it works" section pair install
|
||||
* with docs.
|
||||
*/
|
||||
export function mcpCtas(locale: Locale): {
|
||||
docs: McpCta
|
||||
installMcp: McpCta
|
||||
runWorkflow: McpCta
|
||||
} {
|
||||
return {
|
||||
docs: {
|
||||
@@ -27,10 +26,6 @@ export function mcpCtas(locale: Locale): {
|
||||
installMcp: {
|
||||
label: t('mcp.hero.installMcp', locale),
|
||||
href: '#setup'
|
||||
},
|
||||
runWorkflow: {
|
||||
label: t('mcp.hero.runWorkflow', locale),
|
||||
href: getRoutes(locale).cloud
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +171,31 @@ describe('comfyUiSourceCodeNode', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('ComfyUI entity links', () => {
|
||||
it('names the home page as the canonical page for the application', () => {
|
||||
const node = comfyUiApplicationNode(siteUrl)
|
||||
expect(node.mainEntityOfPage).toBe(`${siteUrl}/`)
|
||||
})
|
||||
|
||||
it('links the application back to the source code emitted alongside it', () => {
|
||||
const app = comfyUiApplicationNode(siteUrl)
|
||||
const source = comfyUiSourceCodeNode(siteUrl)
|
||||
expect(app.isBasedOn).toEqual({ '@id': source['@id'] })
|
||||
})
|
||||
|
||||
it('claims no canonical page or source code for third-party software', () => {
|
||||
const node = softwareApplicationNode({
|
||||
siteUrl,
|
||||
id: 'https://comfy.org/p/supported-models/foo/#software',
|
||||
name: 'Foo Model',
|
||||
url: 'https://comfy.org/p/supported-models/foo/',
|
||||
applicationCategory: 'MultimediaApplication'
|
||||
})
|
||||
expect(node.mainEntityOfPage).toBeUndefined()
|
||||
expect(node.isBasedOn).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildPageGraph', () => {
|
||||
const url = 'https://comfy.org/cloud/pricing/'
|
||||
const graph = buildPageGraph(
|
||||
|
||||
@@ -194,6 +194,8 @@ export interface SoftwareAppInput {
|
||||
authorName?: string
|
||||
isFree?: boolean
|
||||
sameAs?: string[]
|
||||
mainEntityOfPage?: string
|
||||
isBasedOnId?: string
|
||||
}
|
||||
|
||||
export function softwareApplicationNode(input: SoftwareAppInput): JsonLdNode {
|
||||
@@ -219,6 +221,8 @@ export function softwareApplicationNode(input: SoftwareAppInput): JsonLdNode {
|
||||
author,
|
||||
publisher: input.firstParty ? orgRef : undefined,
|
||||
sameAs: input.sameAs,
|
||||
mainEntityOfPage: input.mainEntityOfPage,
|
||||
isBasedOn: input.isBasedOnId ? { '@id': input.isBasedOnId } : undefined,
|
||||
offers: input.isFree
|
||||
? {
|
||||
'@type': 'Offer',
|
||||
@@ -257,6 +261,10 @@ export function comfyUiSoftwareId(siteUrl: string): string {
|
||||
return `${siteUrl}/#software`
|
||||
}
|
||||
|
||||
function comfyUiSourceCodeId(siteUrl: string): string {
|
||||
return `${siteUrl}/#sourcecode`
|
||||
}
|
||||
|
||||
export function comfyUiApplicationNode(siteUrl: string): JsonLdNode {
|
||||
return softwareApplicationNode({
|
||||
siteUrl,
|
||||
@@ -267,14 +275,16 @@ export function comfyUiApplicationNode(siteUrl: string): JsonLdNode {
|
||||
applicationCategory: 'MultimediaApplication',
|
||||
operatingSystem: 'Windows, macOS, Linux',
|
||||
isFree: true,
|
||||
sameAs: comfyUiSameAs
|
||||
sameAs: comfyUiSameAs,
|
||||
mainEntityOfPage: `${siteUrl}/`,
|
||||
isBasedOnId: comfyUiSourceCodeId(siteUrl)
|
||||
})
|
||||
}
|
||||
|
||||
export function comfyUiSourceCodeNode(siteUrl: string): JsonLdNode {
|
||||
return softwareSourceCodeNode({
|
||||
siteUrl,
|
||||
id: `${siteUrl}/#sourcecode`,
|
||||
id: comfyUiSourceCodeId(siteUrl),
|
||||
name: 'ComfyUI',
|
||||
codeRepository: externalLinks.github,
|
||||
programmingLanguage: 'Python',
|
||||
|
||||
@@ -54,6 +54,11 @@
|
||||
"source": "/press",
|
||||
"destination": "/about",
|
||||
"permanent": true
|
||||
},
|
||||
{
|
||||
"source": "/login",
|
||||
"destination": "https://cloud.comfy.org/login",
|
||||
"permanent": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -322,6 +322,9 @@ export class AssetsSidebarTab extends SidebarTab {
|
||||
// --- Folder view ---
|
||||
public readonly backToAssetsButton: Locator
|
||||
|
||||
// --- Panel chrome ---
|
||||
public readonly panelHeader: Locator
|
||||
|
||||
// --- Loading ---
|
||||
public readonly skeletonLoaders: Locator
|
||||
|
||||
@@ -358,6 +361,7 @@ export class AssetsSidebarTab extends SidebarTab {
|
||||
this.deleteSelectedButton = page.getByTestId('assets-delete-selected')
|
||||
this.downloadSelectedButton = page.getByTestId('assets-download-selected')
|
||||
this.backToAssetsButton = page.getByText('Back to all assets')
|
||||
this.panelHeader = page.locator('.comfy-vue-side-bar-header')
|
||||
this.skeletonLoaders = page.locator(
|
||||
'.sidebar-content-container .animate-pulse'
|
||||
)
|
||||
|
||||
@@ -28,11 +28,11 @@ const APP_URL = process.env.PLAYWRIGHT_TEST_URL || 'http://localhost:8188'
|
||||
// matches it against the members self-row.
|
||||
const SELF_EMAIL = 'e2e@test.comfy.org'
|
||||
|
||||
// consolidated_billing_enabled routes personal workspaces to the unified
|
||||
// pricing table asserted here; without it they fall back to the legacy table.
|
||||
// billing_control_enabled routes personal workspaces to the unified pricing
|
||||
// table asserted here; without it they fall back to the legacy table.
|
||||
const BOOT_FEATURES = {
|
||||
team_workspaces_enabled: true,
|
||||
consolidated_billing_enabled: true
|
||||
billing_control_enabled: true
|
||||
} satisfies RemoteConfig
|
||||
// Disable the experimental Asset API: with it on (cloud default) the unmocked
|
||||
// asset endpoints 403 and workflow restore throws uncaught, aborting the
|
||||
|
||||
@@ -276,3 +276,255 @@ test.describe('FE-130 assets sidebar route mocks', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
test.describe('FE-910 marquee selection and select all', () => {
|
||||
test.beforeEach(async ({ jobsRoutes, page, comfyPage }) => {
|
||||
await jobsRoutes.mockJobsQueue([])
|
||||
await jobsRoutes.mockJobsHistory(generatedJobs)
|
||||
await mockInputFiles(page, ['imported.png'])
|
||||
await mockViewFiles(page, viewFiles)
|
||||
await comfyPage.setup()
|
||||
await comfyPage.menu.assetsTab.open()
|
||||
})
|
||||
|
||||
test('Ctrl/Cmd+A selects every asset while the panel is hovered', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
|
||||
await tab.getAssetCardByName('alpha').hover()
|
||||
await comfyPage.page.keyboard.press('ControlOrMeta+a')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(2)
|
||||
})
|
||||
|
||||
test('a marquee that begins in the panel header selects the cards', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const { page } = comfyPage
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
await expect(tab.selectedCards).toHaveCount(0)
|
||||
|
||||
const header = await tab.panelHeader.boundingBox()
|
||||
const beta = await tab.getAssetCardByName('beta').boundingBox()
|
||||
if (!header || !beta) {
|
||||
throw new Error('panel header or asset card has no layout box')
|
||||
}
|
||||
|
||||
// Begin the rubber-band in the header (above the grid), then drag down
|
||||
// across both cards.
|
||||
await page.mouse.move(header.x + 24, header.y + 20)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(beta.x + 8, beta.y + beta.height - 8, { steps: 14 })
|
||||
await page.mouse.up()
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(2)
|
||||
await expect(tab.selectionFooter).toBeVisible()
|
||||
})
|
||||
|
||||
test('Ctrl/Cmd+A leaves assets unselected while the canvas is hovered', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const { page } = comfyPage
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
|
||||
const viewport = page.viewportSize()
|
||||
if (!viewport) throw new Error('viewport size is unavailable')
|
||||
|
||||
// Hover the canvas (not the panel); Ctrl/Cmd+A must yield to the canvas.
|
||||
await page.mouse.move(viewport.width - 100, viewport.height / 2)
|
||||
await page.keyboard.press('ControlOrMeta+a')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('a modifier-held marquee adds to the existing selection', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const { page } = comfyPage
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
|
||||
await tab.getAssetCardByName('alpha').click()
|
||||
await expect(tab.selectedCards).toHaveCount(1)
|
||||
|
||||
const beta = await tab.getAssetCardByName('beta').boundingBox()
|
||||
if (!beta) throw new Error('beta card has no layout box')
|
||||
|
||||
// Hold a modifier so the marquee is additive, then rubber-band over beta.
|
||||
await page.keyboard.down('Control')
|
||||
await page.mouse.move(beta.x + 12, beta.y + 12)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(beta.x + beta.width - 12, beta.y + beta.height - 12, {
|
||||
steps: 12
|
||||
})
|
||||
await page.mouse.up()
|
||||
await page.keyboard.up('Control')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(2)
|
||||
})
|
||||
|
||||
test('a Ctrl/Cmd+Shift marquee removes the covered cards from the selection', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const { page } = comfyPage
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
|
||||
await tab.getAssetCardByName('alpha').hover()
|
||||
await page.keyboard.press('ControlOrMeta+a')
|
||||
await expect(tab.selectedCards).toHaveCount(2)
|
||||
|
||||
const beta = await tab.getAssetCardByName('beta').boundingBox()
|
||||
if (!beta) throw new Error('beta card has no layout box')
|
||||
|
||||
// Ctrl+Shift makes the marquee subtractive: rubber-band over beta only.
|
||||
await page.keyboard.down('Control')
|
||||
await page.keyboard.down('Shift')
|
||||
await page.mouse.move(beta.x + 12, beta.y + 12)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(beta.x + beta.width - 12, beta.y + beta.height - 12, {
|
||||
steps: 12
|
||||
})
|
||||
await page.mouse.up()
|
||||
await page.keyboard.up('Shift')
|
||||
await page.keyboard.up('Control')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(1)
|
||||
await expect(tab.getAssetCardByName('alpha')).toHaveAttribute(
|
||||
'data-selected',
|
||||
'true'
|
||||
)
|
||||
})
|
||||
|
||||
test('Ctrl/Cmd-dragging from an asset card starts a marquee selection', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const { page } = comfyPage
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
await expect(tab.selectedCards).toHaveCount(0)
|
||||
|
||||
const alpha = await tab.getAssetCardByName('alpha').boundingBox()
|
||||
const beta = await tab.getAssetCardByName('beta').boundingBox()
|
||||
if (!alpha || !beta) throw new Error('asset cards have no layout box')
|
||||
|
||||
// Ctrl bypasses card drag, so a press that begins on a card rubber-bands.
|
||||
await page.keyboard.down('Control')
|
||||
await page.mouse.move(alpha.x + alpha.width / 2, alpha.y + alpha.height / 2)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(beta.x + beta.width - 6, beta.y + beta.height - 6, {
|
||||
steps: 12
|
||||
})
|
||||
await page.mouse.up()
|
||||
await page.keyboard.up('Control')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(2)
|
||||
await expect(tab.selectionFooter).toBeVisible()
|
||||
})
|
||||
|
||||
test('Ctrl/Cmd-dragging within a single card selects only that card', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const { page } = comfyPage
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
|
||||
const alpha = tab.getAssetCardByName('alpha')
|
||||
const box = await alpha.boundingBox()
|
||||
if (!box) throw new Error('alpha card has no layout box')
|
||||
|
||||
const start = { x: box.x + box.width / 2, y: box.y + box.height / 2 }
|
||||
await page.keyboard.down('Control')
|
||||
await page.mouse.move(start.x, start.y)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(start.x + 12, start.y + 12, { steps: 4 })
|
||||
await page.mouse.up()
|
||||
await page.keyboard.up('Control')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(1)
|
||||
await expect(alpha).toHaveAttribute('data-selected', 'true')
|
||||
})
|
||||
|
||||
test('Ctrl/Cmd+A in the focused search input does not select assets', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const query = 'alpha'
|
||||
|
||||
await tab.searchInput.fill(query)
|
||||
await expect(tab.assetCards).toHaveCount(1)
|
||||
|
||||
await tab.searchInput.focus()
|
||||
await comfyPage.page.keyboard.press('ControlOrMeta+a')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(0)
|
||||
await expect
|
||||
.poll(() =>
|
||||
tab.searchInput.evaluate((el: HTMLInputElement) => {
|
||||
return { start: el.selectionStart, end: el.selectionEnd }
|
||||
})
|
||||
)
|
||||
.toEqual({ start: 0, end: query.length })
|
||||
})
|
||||
|
||||
test('a drag starting in the search input does not marquee-select assets', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
const { page } = comfyPage
|
||||
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
|
||||
const search = await tab.searchInput.boundingBox()
|
||||
const beta = await tab.getAssetCardByName('beta').boundingBox()
|
||||
if (!search || !beta)
|
||||
throw new Error('search box or card has no layout box')
|
||||
|
||||
await page.mouse.move(
|
||||
search.x + search.width / 2,
|
||||
search.y + search.height / 2
|
||||
)
|
||||
await page.mouse.down()
|
||||
await page.mouse.move(beta.x + beta.width / 2, beta.y + beta.height / 2, {
|
||||
steps: 12
|
||||
})
|
||||
await page.mouse.up()
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('Ctrl/Cmd+A does not select assets while an aria-modal dialog is open', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const tab = comfyPage.menu.assetsTab
|
||||
await expect(tab.assetCards).toHaveCount(2)
|
||||
|
||||
await comfyPage.page.evaluate(() => {
|
||||
const dialog = document.createElement('div')
|
||||
dialog.id = 'test-modal'
|
||||
dialog.setAttribute('role', 'dialog')
|
||||
dialog.setAttribute('aria-modal', 'true')
|
||||
document.body.appendChild(dialog)
|
||||
})
|
||||
|
||||
await tab.getAssetCardByName('alpha').hover()
|
||||
await comfyPage.page.keyboard.press('ControlOrMeta+a')
|
||||
|
||||
await expect(tab.selectedCards).toHaveCount(0)
|
||||
|
||||
await comfyPage.page.evaluate(() => {
|
||||
document.getElementById('test-modal')?.remove()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,6 +7,45 @@ import {
|
||||
import { TestIds } from '@e2e/fixtures/selectors'
|
||||
|
||||
test.describe('Vue Upload Widgets', { tag: '@vue-nodes' }, () => {
|
||||
test.describe('media selection', { tag: '@widget' }, () => {
|
||||
test.beforeEach(async ({ comfyPage }) => {
|
||||
await comfyPage.workflow.loadWorkflow('widgets/load_image_widget')
|
||||
})
|
||||
|
||||
test('keeps a selected image loaded when it is selected again', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
const loadImageNodes =
|
||||
await comfyPage.nodeOps.getNodeRefsByType('LoadImage')
|
||||
expect(loadImageNodes, 'Workflow has one Load Image node').toHaveLength(1)
|
||||
const [loadImageNode] = loadImageNodes
|
||||
|
||||
const imageWidget = await loadImageNode.getWidgetByName('image')
|
||||
await expect.poll(() => imageWidget.getValue()).toBe('example.png')
|
||||
|
||||
const node = comfyPage.vueNodes.getNodeByTitle('Load Image')
|
||||
const imageLoadError = node.getByTestId(TestIds.errors.imageLoadError)
|
||||
const selectedImageButton = node.getByRole('button', {
|
||||
name: 'example.png',
|
||||
exact: true
|
||||
})
|
||||
await expect(selectedImageButton).toBeVisible()
|
||||
await expect(imageLoadError).toBeHidden()
|
||||
|
||||
await selectedImageButton.click()
|
||||
|
||||
const menu = comfyPage.page.getByTestId('form-dropdown-menu')
|
||||
await expect(menu).toBeVisible()
|
||||
await menu.getByText('example.png', { exact: true }).click()
|
||||
await expect(menu).toBeHidden()
|
||||
|
||||
await expect(selectedImageButton).toBeFocused()
|
||||
await expect(selectedImageButton).toBeVisible()
|
||||
await expect.poll(() => imageWidget.getValue()).toBe('example.png')
|
||||
await expect(imageLoadError).toBeHidden()
|
||||
})
|
||||
})
|
||||
|
||||
test('should hide canvas-only upload buttons', async ({ comfyPage }) => {
|
||||
await comfyPage.workflow.loadWorkflow('widgets/all_load_widgets')
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
"dev:test": "cross-env VITE_USE_LEGACY_DEFAULT_GRAPH=true vite --config vite.config.mts",
|
||||
"dev": "vite --config vite.config.mts",
|
||||
"devtools:pycheck": "python3 -m compileall -q tools/devtools",
|
||||
"fallow": "fallow",
|
||||
"fallow:audit": "fallow audit",
|
||||
"format:check": "oxfmt --check",
|
||||
"format": "oxfmt --write",
|
||||
"json-schema": "tsx scripts/generate-json-schema.ts",
|
||||
@@ -172,6 +174,7 @@
|
||||
"eslint-plugin-testing-library": "catalog:",
|
||||
"eslint-plugin-unused-imports": "catalog:",
|
||||
"eslint-plugin-vue": "catalog:",
|
||||
"fallow": "catalog:",
|
||||
"fast-check": "catalog:",
|
||||
"fs-extra": "^11.2.0",
|
||||
"globals": "catalog:",
|
||||
|
||||
@@ -40,6 +40,11 @@ export type ComfyDesktop2TelemetryProperties = Record<
|
||||
ComfyDesktop2TelemetryValue | ComfyDesktop2TelemetryValue[]
|
||||
>
|
||||
|
||||
export type ComfyDesktop2FirebaseAuthState =
|
||||
| { status: 'pending' }
|
||||
| { status: 'signed_out' }
|
||||
| { status: 'signed_in'; userId: string }
|
||||
|
||||
export interface ComfyDesktop2TerminalBridge {
|
||||
subscribe(installationId?: string): Promise<TerminalRestore>
|
||||
unsubscribe(installationId?: string): Promise<void>
|
||||
@@ -60,6 +65,7 @@ export interface ComfyDesktop2LogsBridge {
|
||||
|
||||
export interface ComfyDesktop2TelemetryBridge {
|
||||
capture(event: string, properties?: ComfyDesktop2TelemetryProperties): void
|
||||
reportFirebaseAuthState?(state: ComfyDesktop2FirebaseAuthState): void
|
||||
}
|
||||
|
||||
export interface ComfyDesktop2Bridge {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@comfyorg/comfyui-desktop-bridge-types",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "TypeScript definitions for the Comfy Desktop hosted frontend bridge",
|
||||
"homepage": "https://comfy.org",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -3,7 +3,6 @@ import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
appendWorkflowJsonExt,
|
||||
ensureWorkflowSuffix,
|
||||
escapeVueI18nMessageSyntax,
|
||||
formatLocalizedMediumDate,
|
||||
formatLocalizedNumber,
|
||||
getFilePathSeparatorVariants,
|
||||
@@ -478,49 +477,4 @@ describe('formatUtil', () => {
|
||||
expect(formatLocalizedMediumDate('not a date', 'en')).toBe('—')
|
||||
})
|
||||
})
|
||||
|
||||
describe('escapeVueI18nMessageSyntax', () => {
|
||||
it('escapes a literal @ that would break linked-message compilation', () => {
|
||||
expect(
|
||||
escapeVueI18nMessageSyntax('clips (tagged @Audio1-3 in the prompt)')
|
||||
).toBe("clips (tagged {'@'}Audio1-3 in the prompt)")
|
||||
})
|
||||
|
||||
it('escapes @ in an email address', () => {
|
||||
expect(escapeVueI18nMessageSyntax('support@comfy.org')).toBe(
|
||||
"support{'@'}comfy.org"
|
||||
)
|
||||
})
|
||||
|
||||
it('escapes interpolation braces', () => {
|
||||
expect(escapeVueI18nMessageSyntax('size {w}x{h}')).toBe(
|
||||
"size {'{'}w{'}'}x{'{'}h{'}'}"
|
||||
)
|
||||
})
|
||||
|
||||
it('escapes the plural pipe separator', () => {
|
||||
expect(escapeVueI18nMessageSyntax('foreground | background')).toBe(
|
||||
"foreground {'|'} background"
|
||||
)
|
||||
})
|
||||
|
||||
it('escapes the modulo percent so it cannot re-form %{', () => {
|
||||
expect(escapeVueI18nMessageSyntax('50%{done}')).toBe(
|
||||
"50{'%'}{'{'}done{'}'}"
|
||||
)
|
||||
})
|
||||
|
||||
it('escapes every occurrence in a single pass', () => {
|
||||
expect(escapeVueI18nMessageSyntax('@a @b @c')).toBe(
|
||||
"{'@'}a {'@'}b {'@'}c"
|
||||
)
|
||||
})
|
||||
|
||||
it('leaves strings without syntax characters unchanged', () => {
|
||||
expect(escapeVueI18nMessageSyntax('no special chars here')).toBe(
|
||||
'no special chars here'
|
||||
)
|
||||
expect(escapeVueI18nMessageSyntax('')).toBe('')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -178,40 +178,6 @@ export function normalizeI18nKey(key: string) {
|
||||
return typeof key === 'string' ? key.replace(/\./g, '_') : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Characters that vue-i18n's message compiler treats as syntax in message text,
|
||||
* so plain text has to escape them to render verbatim through `t()`/`st()`:
|
||||
*
|
||||
* - `@` starts a linked-message reference (`@:key`); malformed usage throws
|
||||
* `Invalid linked format`.
|
||||
* - `{` / `}` delimit interpolation (`{name}`, `{'literal'}`); an unbalanced
|
||||
* brace throws `Unterminated/Unbalanced closing brace`.
|
||||
* - `|` separates plural branches, so `a | b` silently renders as one branch.
|
||||
* - `%` forms modulo interpolation when immediately followed by `{` (`%{name}`);
|
||||
* it must be escaped too, otherwise escaping a following `{` re-forms `%{`.
|
||||
*
|
||||
* The set is a build-inlined `const enum` (`TokenChars`) in
|
||||
* `@intlify/message-compiler` and is not exported, so it is hardcoded here.
|
||||
*
|
||||
* @see https://vue-i18n.intlify.dev/guide/essentials/syntax (Special Characters, Literal interpolation)
|
||||
* @see https://vue-i18n.intlify.dev/guide/essentials/pluralization
|
||||
*/
|
||||
const VUE_I18N_SYNTAX_CHARS = /[@{}|%]/g
|
||||
|
||||
/**
|
||||
* Escapes vue-i18n message-syntax characters as literal interpolations (`{'x'}`)
|
||||
* so arbitrary text renders verbatim instead of being parsed as syntax. This is
|
||||
* the only escape vue-i18n supports; see {@link VUE_I18N_SYNTAX_CHARS}.
|
||||
*
|
||||
* Only apply to values read through the compiler (`t()`/`st()`). Values read raw
|
||||
* via `tm()`/`stRaw()` (e.g. node tooltips) must be left untouched, or the
|
||||
* literal `{'x'}` would surface to users. Apply exactly once to raw text: the
|
||||
* escape output itself contains `{`/`}`, so it is not idempotent.
|
||||
*/
|
||||
export function escapeVueI18nMessageSyntax(text: string): string {
|
||||
return text.replace(VUE_I18N_SYNTAX_CHARS, (char) => `{'${char}'}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a dynamic prompt in the format {opt1|opt2|{optA|optB}|} and randomly replaces groups. Supports C style comments.
|
||||
* @param input The dynamic prompt to process
|
||||
|
||||
@@ -16,6 +16,7 @@ const maybeLocalOptions: PlaywrightTestConfig = process.env.PLAYWRIGHT_LOCAL
|
||||
}
|
||||
: {
|
||||
retries: process.env.CI ? 3 : 0,
|
||||
workers: process.env.CI ? 2 : undefined,
|
||||
use: {
|
||||
trace: 'on-first-retry'
|
||||
}
|
||||
@@ -25,7 +26,7 @@ export default defineConfig({
|
||||
testDir: './browser_tests',
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
reporter: 'html',
|
||||
reporter: process.env.PLAYWRIGHT_BLOB_OUTPUT_DIR ? 'blob' : 'html',
|
||||
...maybeLocalOptions,
|
||||
|
||||
globalSetup: './browser_tests/globalSetup.ts',
|
||||
|
||||
88
pnpm-lock.yaml
generated
88
pnpm-lock.yaml
generated
@@ -240,6 +240,9 @@ catalogs:
|
||||
eslint-plugin-vue:
|
||||
specifier: ^10.9.1
|
||||
version: 10.9.1
|
||||
fallow:
|
||||
specifier: ^2.102.0
|
||||
version: 2.102.0
|
||||
fast-check:
|
||||
specifier: ^4.5.3
|
||||
version: 4.5.3
|
||||
@@ -763,6 +766,9 @@ importers:
|
||||
eslint-plugin-vue:
|
||||
specifier: 'catalog:'
|
||||
version: 10.9.1(@typescript-eslint/parser@8.60.0(eslint@10.4.0(jiti@2.6.1))(typescript@5.9.3))(eslint@10.4.0(jiti@2.6.1))(vue-eslint-parser@10.4.0(eslint@10.4.0(jiti@2.6.1)))
|
||||
fallow:
|
||||
specifier: 'catalog:'
|
||||
version: 2.102.0
|
||||
fast-check:
|
||||
specifier: 'catalog:'
|
||||
version: 4.5.3
|
||||
@@ -1908,6 +1914,46 @@ packages:
|
||||
'@exodus/crypto':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/darwin-arm64@2.102.0':
|
||||
resolution: {integrity: sha512-B8wzfzJgoX6h5Gv2xQ9ZidO5Jb8/PWdssAxYbWs1pb5oJHZ6S5PLwXuUdINmNSIaRGQwTk4DC9/tIMFHFvd9uw==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@fallow-cli/darwin-x64@2.102.0':
|
||||
resolution: {integrity: sha512-aLbTWWzQnleKdi56obAPXMJm7YA3qAnkIX9T3eocRHiagYqp8nsf4cslM0rZKvu2WwK34NaBm8x886gl4cl+zg==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@fallow-cli/linux-arm64-gnu@2.102.0':
|
||||
resolution: {integrity: sha512-8nYeOSLSewqcKH/KUcKZaCq5QII5VTRX62l60B6UM1iKe/0jcmlQ2mOtx4rkHpeq3LL5emvT/ph4NNgGmWKSBg==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@fallow-cli/linux-arm64-musl@2.102.0':
|
||||
resolution: {integrity: sha512-2Zi33PXzZxD7HU5sPVwyElZGP7zyEdGo4hK0ewy6gMYgQ9BDfLnFhgaSSOzN1J4paIhYtBmVsLmqakyDKy22Jw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@fallow-cli/linux-x64-gnu@2.102.0':
|
||||
resolution: {integrity: sha512-7Hys4X6hKuR/lqUaGXwezRzDrwXwu9KfahUy85WTuiG1to+ZbzDCqdbZ04LtnI8kK8ufrPDcq+ZXdyt5ksOJHA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@fallow-cli/linux-x64-musl@2.102.0':
|
||||
resolution: {integrity: sha512-RuDY1jOEPgJOuHBgEpHVl6J7Xf2QLFklnNy6zO1nw8R1fLgWUAAKlFirn1Y93pb9bXzqpn5Gre3YlhgIZ3+LBA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@fallow-cli/win32-arm64-msvc@2.102.0':
|
||||
resolution: {integrity: sha512-wsvHjLzWFvsYmCqnQLm1doSEHb9Z038+sFp1RzMcffPUBC5tqS3vCr8J8nolcLlPk7o3QWHQMXAqb1xSJe+doA==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@fallow-cli/win32-x64-msvc@2.102.0':
|
||||
resolution: {integrity: sha512-rH1hd0PD0mm6pCxh1pw5jubpJsvV6f5rjixMoD5AZLzWa6NPJBpPPuzruLGtH/9CYy8B0y7zPrGGTKRO2PCGzg==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@firebase/analytics-compat@0.2.18':
|
||||
resolution: {integrity: sha512-Hw9mzsSMZaQu6wrTbi3kYYwGw9nBqOHr47pVLxfr5v8CalsdrG5gfs9XUlPOZjHRVISp3oQrh1j7d3E+ulHPjQ==}
|
||||
peerDependencies:
|
||||
@@ -5682,6 +5728,11 @@ packages:
|
||||
extendable-media-recorder@9.2.27:
|
||||
resolution: {integrity: sha512-2X+Ixi1cxLek0Cj9x9atmhQ+apG+LwJpP2p3ypP8Pxau0poDnicrg7FTfPVQV5PW/3DHFm/eQ16vbgo5Yk3HGQ==}
|
||||
|
||||
fallow@2.102.0:
|
||||
resolution: {integrity: sha512-bkOT58kPVCB12d2apQjIKBw/qSdsGRPQFrN5ff9Yl5WzXRqlDTbT/MVdMXld4sJD5JQW1ftw2bTxJWCINggh6g==}
|
||||
engines: {node: '>=16'}
|
||||
hasBin: true
|
||||
|
||||
fast-check@4.5.3:
|
||||
resolution: {integrity: sha512-IE9csY7lnhxBnA8g/WI5eg/hygA6MGWJMSNfFRrBlXUciADEhS1EDB0SIsMSvzubzIlOBbVITSsypCsW717poA==}
|
||||
engines: {node: '>=12.17.0'}
|
||||
@@ -10044,6 +10095,30 @@ snapshots:
|
||||
|
||||
'@exodus/bytes@1.7.0': {}
|
||||
|
||||
'@fallow-cli/darwin-arm64@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/darwin-x64@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/linux-arm64-gnu@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/linux-arm64-musl@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/linux-x64-gnu@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/linux-x64-musl@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/win32-arm64-msvc@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@fallow-cli/win32-x64-msvc@2.102.0':
|
||||
optional: true
|
||||
|
||||
'@firebase/analytics-compat@0.2.18(@firebase/app-compat@0.2.53)(@firebase/app@0.11.4)':
|
||||
dependencies:
|
||||
'@firebase/analytics': 0.10.12(@firebase/app@0.11.4)
|
||||
@@ -14095,6 +14170,19 @@ snapshots:
|
||||
subscribable-things: 2.1.53
|
||||
tslib: 2.8.1
|
||||
|
||||
fallow@2.102.0:
|
||||
dependencies:
|
||||
detect-libc: 2.1.2
|
||||
optionalDependencies:
|
||||
'@fallow-cli/darwin-arm64': 2.102.0
|
||||
'@fallow-cli/darwin-x64': 2.102.0
|
||||
'@fallow-cli/linux-arm64-gnu': 2.102.0
|
||||
'@fallow-cli/linux-arm64-musl': 2.102.0
|
||||
'@fallow-cli/linux-x64-gnu': 2.102.0
|
||||
'@fallow-cli/linux-x64-musl': 2.102.0
|
||||
'@fallow-cli/win32-arm64-msvc': 2.102.0
|
||||
'@fallow-cli/win32-x64-msvc': 2.102.0
|
||||
|
||||
fast-check@4.5.3:
|
||||
dependencies:
|
||||
pure-rand: 7.0.1
|
||||
|
||||
@@ -89,6 +89,7 @@ catalog:
|
||||
eslint-plugin-testing-library: ^7.16.1
|
||||
eslint-plugin-unused-imports: ^4.4.1
|
||||
eslint-plugin-vue: ^10.9.1
|
||||
fallow: ^2.102.0
|
||||
fast-check: ^4.5.3
|
||||
firebase: ^11.6.0
|
||||
glob: ^13.0.6
|
||||
|
||||
@@ -3,11 +3,9 @@ import * as fs from 'fs'
|
||||
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
||||
|
||||
import { comfyPageFixture as test } from '../browser_tests/fixtures/ComfyPage'
|
||||
import {
|
||||
escapeVueI18nMessageSyntax,
|
||||
normalizeI18nKey
|
||||
} from '@/utils/formatUtil'
|
||||
import type { ComfyNodeDefImpl } from '../src/stores/nodeDefStore'
|
||||
import type { WidgetLabels } from './nodeDefLocaleSerializer'
|
||||
import { serializeNodeDefLocales } from './nodeDefLocaleSerializer'
|
||||
|
||||
const localePath = './src/locales/en/main.json'
|
||||
const nodeDefsPath = './src/locales/en/nodeDefs.json'
|
||||
@@ -17,10 +15,6 @@ interface WidgetInfo {
|
||||
label?: string
|
||||
}
|
||||
|
||||
interface WidgetLabels {
|
||||
[key: string]: Record<string, { name: string }>
|
||||
}
|
||||
|
||||
test('collect-i18n-node-defs', async ({ comfyPage }) => {
|
||||
// Mock view route
|
||||
await comfyPage.page.route('**/view**', async (route) => {
|
||||
@@ -47,26 +41,6 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
|
||||
}
|
||||
)
|
||||
|
||||
const allDataTypesLocale = Object.fromEntries(
|
||||
nodeDefs
|
||||
.flatMap((nodeDef) => {
|
||||
const inputDataTypes = Object.values(nodeDef.inputs).map(
|
||||
(inputSpec) => inputSpec.type
|
||||
)
|
||||
const outputDataTypes = nodeDef.outputs.map(
|
||||
(outputSpec) => outputSpec.type
|
||||
)
|
||||
const allDataTypes = [...inputDataTypes, ...outputDataTypes].flatMap(
|
||||
(type: string) => type.split(',')
|
||||
)
|
||||
return allDataTypes.map((dataType) => [
|
||||
normalizeI18nKey(dataType),
|
||||
escapeVueI18nMessageSyntax(dataType)
|
||||
])
|
||||
})
|
||||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
)
|
||||
|
||||
async function extractWidgetLabels() {
|
||||
const nodeLabels: WidgetLabels = {}
|
||||
|
||||
@@ -95,14 +69,10 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
|
||||
[nodeDef.name, nodeDef.display_name, inputNames]
|
||||
)
|
||||
|
||||
// Format runtime widgets
|
||||
const runtimeWidgets = Object.fromEntries(
|
||||
Object.entries(widgetsMappings)
|
||||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
.map(([key, value]) => [
|
||||
normalizeI18nKey(key),
|
||||
{ name: value ? escapeVueI18nMessageSyntax(value) : value }
|
||||
])
|
||||
.map(([key, name]) => [key, { name }])
|
||||
)
|
||||
|
||||
if (Object.keys(runtimeWidgets).length > 0) {
|
||||
@@ -121,97 +91,8 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
|
||||
}
|
||||
|
||||
const nodeDefLabels = await extractWidgetLabels()
|
||||
|
||||
function extractInputs(nodeDef: ComfyNodeDefImpl) {
|
||||
const inputs = Object.fromEntries(
|
||||
Object.values(nodeDef.inputs).flatMap((input) => {
|
||||
const name =
|
||||
input.name === undefined
|
||||
? undefined
|
||||
: escapeVueI18nMessageSyntax(input.name)
|
||||
const tooltip = input.tooltip
|
||||
|
||||
if (name === undefined && tooltip === undefined) {
|
||||
return []
|
||||
}
|
||||
|
||||
return [
|
||||
[
|
||||
normalizeI18nKey(input.name),
|
||||
{
|
||||
name,
|
||||
tooltip
|
||||
}
|
||||
]
|
||||
]
|
||||
})
|
||||
)
|
||||
return Object.keys(inputs).length > 0 ? inputs : undefined
|
||||
}
|
||||
|
||||
function extractOutputs(nodeDef: ComfyNodeDefImpl) {
|
||||
const outputs = Object.fromEntries(
|
||||
nodeDef.outputs.flatMap((output, i) => {
|
||||
// Ignore data types if they are already translated in allDataTypesLocale.
|
||||
const name =
|
||||
output.name === undefined || output.name in allDataTypesLocale
|
||||
? undefined
|
||||
: escapeVueI18nMessageSyntax(output.name)
|
||||
const tooltip = output.tooltip
|
||||
|
||||
if (name === undefined && tooltip === undefined) {
|
||||
return []
|
||||
}
|
||||
|
||||
return [
|
||||
[
|
||||
i.toString(),
|
||||
{
|
||||
name,
|
||||
tooltip
|
||||
}
|
||||
]
|
||||
]
|
||||
})
|
||||
)
|
||||
return Object.keys(outputs).length > 0 ? outputs : undefined
|
||||
}
|
||||
|
||||
const allNodeDefsLocale = Object.fromEntries(
|
||||
nodeDefs
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((nodeDef) => {
|
||||
const inputs = {
|
||||
...extractInputs(nodeDef),
|
||||
...(nodeDefLabels[nodeDef.name] ?? {})
|
||||
}
|
||||
|
||||
return [
|
||||
normalizeI18nKey(nodeDef.name),
|
||||
{
|
||||
display_name: escapeVueI18nMessageSyntax(
|
||||
nodeDef.display_name ?? nodeDef.name
|
||||
),
|
||||
description: nodeDef.description
|
||||
? escapeVueI18nMessageSyntax(nodeDef.description)
|
||||
: undefined,
|
||||
inputs: Object.keys(inputs).length > 0 ? inputs : undefined,
|
||||
outputs: extractOutputs(nodeDef)
|
||||
}
|
||||
]
|
||||
})
|
||||
)
|
||||
|
||||
const allNodeCategoriesLocale = Object.fromEntries(
|
||||
nodeDefs.flatMap((nodeDef) =>
|
||||
nodeDef.category
|
||||
.split('/')
|
||||
.map((category) => [
|
||||
normalizeI18nKey(category),
|
||||
escapeVueI18nMessageSyntax(category)
|
||||
])
|
||||
)
|
||||
)
|
||||
const { dataTypes, nodeCategories, nodeDefinitions } =
|
||||
serializeNodeDefLocales(nodeDefs, nodeDefLabels)
|
||||
|
||||
const locale = JSON.parse(fs.readFileSync(localePath, 'utf-8'))
|
||||
fs.writeFileSync(
|
||||
@@ -219,13 +100,13 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
|
||||
JSON.stringify(
|
||||
{
|
||||
...locale,
|
||||
dataTypes: allDataTypesLocale,
|
||||
nodeCategories: allNodeCategoriesLocale
|
||||
dataTypes,
|
||||
nodeCategories
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
)
|
||||
|
||||
fs.writeFileSync(nodeDefsPath, JSON.stringify(allNodeDefsLocale, null, 2))
|
||||
fs.writeFileSync(nodeDefsPath, JSON.stringify(nodeDefinitions, null, 2))
|
||||
})
|
||||
|
||||
130
scripts/nodeDefLocaleSerializer.test.ts
Normal file
130
scripts/nodeDefLocaleSerializer.test.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { serializeNodeDefLocales } from './nodeDefLocaleSerializer'
|
||||
|
||||
function render(message: string): string {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'en',
|
||||
messages: { en: { value: message } }
|
||||
})
|
||||
return i18n.global.t('value')
|
||||
}
|
||||
|
||||
describe('serializeNodeDefLocales', () => {
|
||||
it('escapes compiled fields and preserves raw tooltips', () => {
|
||||
const syntax = '@ $ {value} | 50%{done}'
|
||||
const inputName = `Input ${syntax}`
|
||||
const outputName = `Output ${syntax}`
|
||||
const dataType = `TYPE ${syntax}`
|
||||
const category = `Category ${syntax}`
|
||||
const nodeDef = {
|
||||
name: 'Test.Node',
|
||||
display_name: `Display ${syntax}`,
|
||||
description: `Description ${syntax}`,
|
||||
category,
|
||||
inputs: {
|
||||
input: {
|
||||
name: inputName,
|
||||
type: dataType,
|
||||
tooltip: `Input tooltip ${syntax}`
|
||||
}
|
||||
},
|
||||
outputs: [
|
||||
{
|
||||
name: outputName,
|
||||
type: 'OTHER',
|
||||
tooltip: `Output tooltip ${syntax}`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const { dataTypes, nodeCategories, nodeDefinitions } =
|
||||
serializeNodeDefLocales([nodeDef], {
|
||||
'Test.Node': {
|
||||
'Runtime.Widget': { name: `Widget ${syntax}` }
|
||||
}
|
||||
})
|
||||
const serializedNode = nodeDefinitions.Test_Node
|
||||
const serializedInput =
|
||||
serializedNode.inputs['Input @ $ {value} | 50%{done}']
|
||||
const serializedOutput = serializedNode.outputs['0']
|
||||
|
||||
expect(render(serializedNode.display_name)).toBe(nodeDef.display_name)
|
||||
expect(render(serializedNode.description)).toBe(nodeDef.description)
|
||||
expect(render(serializedInput.name)).toBe(inputName)
|
||||
expect(render(serializedOutput.name)).toBe(outputName)
|
||||
expect(render(serializedNode.inputs.Runtime_Widget.name)).toBe(
|
||||
`Widget ${syntax}`
|
||||
)
|
||||
expect(render(dataTypes[dataType])).toBe(dataType)
|
||||
expect(render(nodeCategories[category])).toBe(category)
|
||||
expect(serializedInput.tooltip).toBe(nodeDef.inputs.input.tooltip)
|
||||
expect(serializedOutput.tooltip).toBe(nodeDef.outputs[0].tooltip)
|
||||
})
|
||||
|
||||
it('preserves locale shapes and ordering', () => {
|
||||
const { dataTypes, nodeCategories, nodeDefinitions } =
|
||||
serializeNodeDefLocales(
|
||||
[
|
||||
{
|
||||
name: 'Z.Node',
|
||||
description: '',
|
||||
category: 'group/sub.group',
|
||||
inputs: {
|
||||
omitted: { type: 'Z.TYPE' },
|
||||
tooltipOnly: { type: 'A_TYPE', tooltip: 'raw @ tooltip' }
|
||||
},
|
||||
outputs: [
|
||||
{ name: 'A_TYPE', type: 'A_TYPE' },
|
||||
{ name: 'Custom.Output', type: 'Z.TYPE' },
|
||||
{ tooltip: 'raw output @ tooltip', type: 'Z.TYPE' }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'A.Node',
|
||||
category: 'group',
|
||||
inputs: {},
|
||||
outputs: []
|
||||
}
|
||||
],
|
||||
{
|
||||
'Z.Node': {
|
||||
'Runtime.Widget': { name: 'Runtime.Label' }
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
expect(dataTypes).toEqual({
|
||||
A_TYPE: 'A_TYPE',
|
||||
Z_TYPE: 'Z.TYPE'
|
||||
})
|
||||
expect(nodeCategories).toEqual({
|
||||
group: 'group',
|
||||
sub_group: 'sub.group'
|
||||
})
|
||||
expect(nodeDefinitions).toEqual({
|
||||
A_Node: {
|
||||
display_name: 'A.Node',
|
||||
description: undefined,
|
||||
inputs: undefined,
|
||||
outputs: undefined
|
||||
},
|
||||
Z_Node: {
|
||||
display_name: 'Z.Node',
|
||||
description: undefined,
|
||||
inputs: {
|
||||
'': { name: undefined, tooltip: 'raw @ tooltip' },
|
||||
Runtime_Widget: { name: 'Runtime.Label' }
|
||||
},
|
||||
outputs: {
|
||||
1: { name: 'Custom.Output', tooltip: undefined },
|
||||
2: { name: undefined, tooltip: 'raw output @ tooltip' }
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(Object.keys(dataTypes)).toEqual(['A_TYPE', 'Z_TYPE'])
|
||||
expect(Object.keys(nodeDefinitions)).toEqual(['A_Node', 'Z_Node'])
|
||||
})
|
||||
})
|
||||
127
scripts/nodeDefLocaleSerializer.ts
Normal file
127
scripts/nodeDefLocaleSerializer.ts
Normal file
@@ -0,0 +1,127 @@
|
||||
import { normalizeI18nKey } from '@/utils/formatUtil'
|
||||
|
||||
interface LocalizableInput {
|
||||
type: string
|
||||
name?: string
|
||||
tooltip?: string
|
||||
}
|
||||
|
||||
interface LocalizableOutput {
|
||||
type: string
|
||||
name?: string
|
||||
tooltip?: string
|
||||
}
|
||||
|
||||
interface LocalizableNodeDef {
|
||||
category: string
|
||||
inputs: Record<string, LocalizableInput>
|
||||
name: string
|
||||
outputs: LocalizableOutput[]
|
||||
description?: string
|
||||
display_name?: string
|
||||
}
|
||||
|
||||
export type WidgetLabels = Record<
|
||||
string,
|
||||
Record<string, { name: string | undefined }>
|
||||
>
|
||||
|
||||
const VUE_I18N_SYNTAX_CHARS = /[@${}|%]/g
|
||||
|
||||
function escapeMessage(text: string): string {
|
||||
return text.replace(VUE_I18N_SYNTAX_CHARS, (char) => `{'${char}'}`)
|
||||
}
|
||||
|
||||
export function serializeNodeDefLocales(
|
||||
nodeDefs: readonly LocalizableNodeDef[],
|
||||
widgetLabels: WidgetLabels = {}
|
||||
) {
|
||||
const dataTypes = Object.fromEntries(
|
||||
nodeDefs
|
||||
.flatMap((nodeDef) => [
|
||||
...Object.values(nodeDef.inputs).map(({ type }) => type),
|
||||
...nodeDef.outputs.map(({ type }) => type)
|
||||
])
|
||||
.flatMap((type) => type.split(','))
|
||||
.map((dataType) => [normalizeI18nKey(dataType), escapeMessage(dataType)])
|
||||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
)
|
||||
|
||||
function serializeInputs(nodeDef: LocalizableNodeDef) {
|
||||
const inputs = Object.fromEntries(
|
||||
Object.values(nodeDef.inputs).flatMap(({ name, tooltip }) => {
|
||||
if (name === undefined && tooltip === undefined) return []
|
||||
|
||||
return [
|
||||
[
|
||||
normalizeI18nKey(name ?? ''),
|
||||
{
|
||||
name: name === undefined ? undefined : escapeMessage(name),
|
||||
tooltip
|
||||
}
|
||||
]
|
||||
]
|
||||
})
|
||||
)
|
||||
return Object.keys(inputs).length > 0 ? inputs : undefined
|
||||
}
|
||||
|
||||
function serializeOutputs(nodeDef: LocalizableNodeDef) {
|
||||
const outputs = Object.fromEntries(
|
||||
nodeDef.outputs.flatMap(({ name, tooltip }, index) => {
|
||||
const serializedName =
|
||||
name === undefined || name in dataTypes
|
||||
? undefined
|
||||
: escapeMessage(name)
|
||||
if (serializedName === undefined && tooltip === undefined) return []
|
||||
|
||||
return [[index.toString(), { name: serializedName, tooltip }]]
|
||||
})
|
||||
)
|
||||
return Object.keys(outputs).length > 0 ? outputs : undefined
|
||||
}
|
||||
|
||||
function serializeWidgetLabels(nodeName: string) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(widgetLabels[nodeName] ?? {}).map(([name, label]) => [
|
||||
normalizeI18nKey(name),
|
||||
{
|
||||
name: label.name === undefined ? undefined : escapeMessage(label.name)
|
||||
}
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
const nodeDefinitions = Object.fromEntries(
|
||||
[...nodeDefs]
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((nodeDef) => {
|
||||
const inputs = {
|
||||
...serializeInputs(nodeDef),
|
||||
...serializeWidgetLabels(nodeDef.name)
|
||||
}
|
||||
|
||||
return [
|
||||
normalizeI18nKey(nodeDef.name),
|
||||
{
|
||||
display_name: escapeMessage(nodeDef.display_name ?? nodeDef.name),
|
||||
description: nodeDef.description
|
||||
? escapeMessage(nodeDef.description)
|
||||
: undefined,
|
||||
inputs: Object.keys(inputs).length > 0 ? inputs : undefined,
|
||||
outputs: serializeOutputs(nodeDef)
|
||||
}
|
||||
]
|
||||
})
|
||||
)
|
||||
|
||||
const nodeCategories = Object.fromEntries(
|
||||
nodeDefs.flatMap(({ category }) =>
|
||||
category
|
||||
.split('/')
|
||||
.map((part) => [normalizeI18nKey(part), escapeMessage(part)])
|
||||
)
|
||||
)
|
||||
|
||||
return { dataTypes, nodeCategories, nodeDefinitions }
|
||||
}
|
||||
@@ -39,6 +39,10 @@
|
||||
<NodePropertiesPanel v-else />
|
||||
</template>
|
||||
<template #graph-canvas-panel>
|
||||
<div
|
||||
ref="canvasPanelBoundsRef"
|
||||
class="pointer-events-none absolute inset-0"
|
||||
/>
|
||||
<GraphCanvasMenu
|
||||
v-if="canvasMenuEnabled && !isBuilderMode"
|
||||
class="pointer-events-auto"
|
||||
@@ -89,7 +93,10 @@
|
||||
/>
|
||||
|
||||
<!-- Selection rectangle overlay - rendered in DOM layer to appear above DOM widgets -->
|
||||
<SelectionRectangle v-if="comfyAppReady" />
|
||||
<SelectionRectangle
|
||||
v-if="comfyAppReady"
|
||||
:panel-el="canvasPanelBoundsRef ?? undefined"
|
||||
/>
|
||||
|
||||
<NodeTooltip v-if="tooltipEnabled" />
|
||||
<NodeSearchboxPopover ref="nodeSearchboxPopoverRef" />
|
||||
@@ -116,6 +123,7 @@ import {
|
||||
onUnmounted,
|
||||
ref,
|
||||
shallowRef,
|
||||
useTemplateRef,
|
||||
watch,
|
||||
watchEffect
|
||||
} from 'vue'
|
||||
@@ -202,6 +210,7 @@ const emit = defineEmits<{
|
||||
ready: []
|
||||
}>()
|
||||
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
||||
const canvasPanelBoundsRef = useTemplateRef('canvasPanelBoundsRef')
|
||||
const nodeSearchboxPopoverRef = shallowRef<InstanceType<
|
||||
typeof NodeSearchboxPopover
|
||||
> | null>(null)
|
||||
|
||||
106
src/components/graph/SelectionRectangle.test.ts
Normal file
106
src/components/graph/SelectionRectangle.test.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import { fromPartial } from '@total-typescript/shoehorn'
|
||||
import { render, screen } from '@testing-library/vue'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { nextTick, ref } from 'vue'
|
||||
|
||||
import SelectionRectangle from './SelectionRectangle.vue'
|
||||
|
||||
const rafCallbacks: Array<() => void> = []
|
||||
vi.mock('@vueuse/core', () => ({
|
||||
useRafFn: (cb: () => void) => {
|
||||
rafCallbacks.push(cb)
|
||||
return { pause: vi.fn(), resume: vi.fn() }
|
||||
}
|
||||
}))
|
||||
|
||||
const mockCanvas = ref<unknown>(null)
|
||||
vi.mock('@/renderer/core/canvas/canvasStore', () => ({
|
||||
useCanvasStore: () => ({
|
||||
get canvas() {
|
||||
return mockCanvas.value
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
function createPanelEl() {
|
||||
const panel = document.createElement('div')
|
||||
vi.spyOn(panel, 'getBoundingClientRect').mockReturnValue(
|
||||
fromPartial<DOMRect>({ left: 300, top: 0, right: 1000, bottom: 800 })
|
||||
)
|
||||
return panel
|
||||
}
|
||||
|
||||
function dragRectangle(eDown: [number, number], eMove: [number, number]) {
|
||||
const canvasEl = document.createElement('canvas')
|
||||
vi.spyOn(canvasEl, 'getBoundingClientRect').mockReturnValue(
|
||||
fromPartial<DOMRect>({ left: 0, top: 0, right: 1000, bottom: 800 })
|
||||
)
|
||||
mockCanvas.value = {
|
||||
canvas: canvasEl,
|
||||
dragging_rectangle: true,
|
||||
pointer: {
|
||||
eDown: { safeOffsetX: eDown[0], safeOffsetY: eDown[1] },
|
||||
eMove: { safeOffsetX: eMove[0], safeOffsetY: eMove[1] }
|
||||
}
|
||||
}
|
||||
rafCallbacks[rafCallbacks.length - 1]()
|
||||
}
|
||||
|
||||
describe('SelectionRectangle', () => {
|
||||
afterEach(() => {
|
||||
rafCallbacks.length = 0
|
||||
mockCanvas.value = null
|
||||
document.body.replaceChildren()
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('clips the rectangle to the canvas panel when dragged over the sidebar', async () => {
|
||||
render(SelectionRectangle, { props: { panelEl: createPanelEl() } })
|
||||
|
||||
dragRectangle([100, 100], [800, 400])
|
||||
await nextTick()
|
||||
|
||||
const rect = screen.getByTestId('selection-rectangle')
|
||||
expect(rect.style.left).toBe('300px')
|
||||
expect(rect.style.top).toBe('100px')
|
||||
expect(rect.style.width).toBe('500px')
|
||||
expect(rect.style.height).toBe('300px')
|
||||
})
|
||||
|
||||
it('leaves a rectangle within the panel unchanged', async () => {
|
||||
render(SelectionRectangle, { props: { panelEl: createPanelEl() } })
|
||||
|
||||
dragRectangle([400, 100], [600, 300])
|
||||
await nextTick()
|
||||
|
||||
const rect = screen.getByTestId('selection-rectangle')
|
||||
expect(rect.style.left).toBe('400px')
|
||||
expect(rect.style.top).toBe('100px')
|
||||
expect(rect.style.width).toBe('200px')
|
||||
expect(rect.style.height).toBe('200px')
|
||||
})
|
||||
|
||||
it('normalizes and clips a rectangle dragged up-and-left', async () => {
|
||||
render(SelectionRectangle, { props: { panelEl: createPanelEl() } })
|
||||
|
||||
dragRectangle([800, 400], [100, 100])
|
||||
await nextTick()
|
||||
|
||||
const rect = screen.getByTestId('selection-rectangle')
|
||||
expect(rect.style.left).toBe('300px')
|
||||
expect(rect.style.top).toBe('100px')
|
||||
expect(rect.style.width).toBe('500px')
|
||||
expect(rect.style.height).toBe('300px')
|
||||
})
|
||||
|
||||
it('renders unclamped edges when the canvas panel is absent', async () => {
|
||||
render(SelectionRectangle)
|
||||
|
||||
dragRectangle([100, 100], [800, 400])
|
||||
await nextTick()
|
||||
|
||||
const rect = screen.getByTestId('selection-rectangle')
|
||||
expect(rect.style.left).toBe('100px')
|
||||
expect(rect.style.width).toBe('700px')
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div
|
||||
v-show="isVisible"
|
||||
data-testid="selection-rectangle"
|
||||
class="pointer-events-none absolute z-9999 border border-blue-400 bg-blue-500/20"
|
||||
:style="rectangleStyle"
|
||||
/>
|
||||
@@ -11,6 +12,13 @@ import { useRafFn } from '@vueuse/core'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import { clipRectToBounds } from '@/utils/mathUtil'
|
||||
import type { RectEdges } from '@/utils/mathUtil'
|
||||
|
||||
const { panelEl } = defineProps<{
|
||||
/** Clip surface owned by the caller; the rectangle renders unclipped when absent. */
|
||||
panelEl?: HTMLElement
|
||||
}>()
|
||||
|
||||
const canvasStore = useCanvasStore()
|
||||
|
||||
@@ -20,17 +28,18 @@ const selectionRect = ref<{
|
||||
w: number
|
||||
h: number
|
||||
} | null>(null)
|
||||
const panelBounds = ref<RectEdges>()
|
||||
|
||||
useRafFn(() => {
|
||||
const canvas = canvasStore.canvas
|
||||
if (!canvas) {
|
||||
selectionRect.value = null
|
||||
return
|
||||
}
|
||||
if (!canvas) return
|
||||
|
||||
const { pointer, dragging_rectangle } = canvas
|
||||
|
||||
if (dragging_rectangle && pointer.eDown && pointer.eMove) {
|
||||
if (!selectionRect.value) {
|
||||
panelBounds.value = getCanvasPanelBounds(canvas.canvas)
|
||||
}
|
||||
const x = pointer.eDown.safeOffsetX
|
||||
const y = pointer.eDown.safeOffsetY
|
||||
const w = pointer.eMove.safeOffsetX - x
|
||||
@@ -39,25 +48,47 @@ useRafFn(() => {
|
||||
selectionRect.value = { x, y, w, h }
|
||||
} else {
|
||||
selectionRect.value = null
|
||||
panelBounds.value = undefined
|
||||
}
|
||||
})
|
||||
|
||||
const isVisible = computed(() => selectionRect.value !== null)
|
||||
|
||||
function getCanvasPanelBounds(
|
||||
canvasEl: HTMLCanvasElement
|
||||
): RectEdges | undefined {
|
||||
if (!panelEl) return undefined
|
||||
|
||||
const panel = panelEl.getBoundingClientRect()
|
||||
const canvas = canvasEl.getBoundingClientRect()
|
||||
return {
|
||||
left: panel.left - canvas.left,
|
||||
top: panel.top - canvas.top,
|
||||
right: panel.right - canvas.left,
|
||||
bottom: panel.bottom - canvas.top
|
||||
}
|
||||
}
|
||||
|
||||
const rectangleStyle = computed(() => {
|
||||
const rect = selectionRect.value
|
||||
if (!rect) return {}
|
||||
|
||||
const left = rect.w >= 0 ? rect.x : rect.x + rect.w
|
||||
const top = rect.h >= 0 ? rect.y : rect.y + rect.h
|
||||
const width = Math.abs(rect.w)
|
||||
const height = Math.abs(rect.h)
|
||||
const edges: RectEdges = {
|
||||
left: rect.w >= 0 ? rect.x : rect.x + rect.w,
|
||||
top: rect.h >= 0 ? rect.y : rect.y + rect.h,
|
||||
right: rect.w >= 0 ? rect.x + rect.w : rect.x,
|
||||
bottom: rect.h >= 0 ? rect.y + rect.h : rect.y
|
||||
}
|
||||
const bounds = panelBounds.value
|
||||
const { left, top, right, bottom } = bounds
|
||||
? clipRectToBounds(edges, bounds)
|
||||
: edges
|
||||
|
||||
return {
|
||||
left: `${left}px`,
|
||||
top: `${top}px`,
|
||||
width: `${width}px`,
|
||||
height: `${height}px`
|
||||
width: `${right - left}px`,
|
||||
height: `${bottom - top}px`
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<SidebarTabTemplate
|
||||
ref="panelRef"
|
||||
:title="isInFolderView ? '' : $t('sideToolbar.mediaAssets.title')"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
@@ -100,18 +101,19 @@
|
||||
@context-menu="handleAssetContextMenu"
|
||||
@approach-end="handleApproachEnd"
|
||||
/>
|
||||
<AssetsSidebarGridView
|
||||
v-else
|
||||
:assets="displayAssets"
|
||||
:is-selected="isSelected"
|
||||
:show-output-count="shouldShowOutputCount"
|
||||
:get-output-count="getOutputCount"
|
||||
@select-asset="handleAssetSelect"
|
||||
@context-menu="handleAssetContextMenu"
|
||||
@approach-end="handleApproachEnd"
|
||||
@zoom="handleZoomClick"
|
||||
@output-count-click="enterFolderView"
|
||||
/>
|
||||
<div v-else class="size-full">
|
||||
<AssetsSidebarGridView
|
||||
:assets="displayAssets"
|
||||
:is-selected
|
||||
:show-output-count
|
||||
:get-output-count
|
||||
@select-asset="handleAssetSelect"
|
||||
@context-menu="handleAssetContextMenu"
|
||||
@approach-end="handleApproachEnd"
|
||||
@zoom="handleZoomClick"
|
||||
@output-count-click="enterFolderView"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
@@ -125,6 +127,13 @@
|
||||
/>
|
||||
</template>
|
||||
</SidebarTabTemplate>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="marqueeStyle"
|
||||
class="pointer-events-none fixed z-9999 border border-primary-background bg-primary-background/20"
|
||||
:style="marqueeStyle"
|
||||
/>
|
||||
</Teleport>
|
||||
<MediaLightbox
|
||||
v-model:active-index="galleryActiveIndex"
|
||||
:all-gallery-items="galleryItems"
|
||||
@@ -151,6 +160,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
unrefElement,
|
||||
useAsyncState,
|
||||
useDebounceFn,
|
||||
useStorage,
|
||||
@@ -164,6 +174,7 @@ import {
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
ref,
|
||||
useTemplateRef,
|
||||
watch
|
||||
} from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
@@ -182,6 +193,7 @@ import MediaAssetFilterBar from '@/platform/assets/components/MediaAssetFilterBa
|
||||
import MediaAssetSelectionBar from '@/platform/assets/components/MediaAssetSelectionBar.vue'
|
||||
import { getAssetType } from '@/platform/assets/composables/media/assetMappers'
|
||||
import { useAssetsApi } from '@/platform/assets/composables/media/useAssetsApi'
|
||||
import { useAssetGridSelection } from '@/platform/assets/composables/useAssetGridSelection'
|
||||
import { useAssetSelection } from '@/platform/assets/composables/useAssetSelection'
|
||||
import { useMediaAssetActions } from '@/platform/assets/composables/useMediaAssetActions'
|
||||
import { useMediaAssetFiltering } from '@/platform/assets/composables/useMediaAssetFiltering'
|
||||
@@ -239,7 +251,7 @@ const contextMenuFileKind = computed<MediaKind>(() =>
|
||||
getMediaTypeFromFilename(contextMenuAsset.value?.name ?? '')
|
||||
)
|
||||
|
||||
const shouldShowOutputCount = (item: AssetItem): boolean => {
|
||||
const showOutputCount = (item: AssetItem): boolean => {
|
||||
if (activeTab.value !== 'output' || isInFolderView.value) {
|
||||
return false
|
||||
}
|
||||
@@ -259,7 +271,10 @@ const outputAssets = useAssetsApi('output')
|
||||
// Asset selection
|
||||
const {
|
||||
isSelected,
|
||||
selectedIds,
|
||||
handleAssetClick,
|
||||
selectAll,
|
||||
setSelectedIds,
|
||||
hasSelection,
|
||||
clearSelection,
|
||||
getSelectedAssets,
|
||||
@@ -270,6 +285,12 @@ const {
|
||||
deactivate: deactivateSelection
|
||||
} = useAssetSelection()
|
||||
|
||||
const panelRef = useTemplateRef('panelRef')
|
||||
const marqueePanelRef = computed(() => {
|
||||
const el = unrefElement(panelRef)
|
||||
return el instanceof HTMLElement ? el : undefined
|
||||
})
|
||||
|
||||
const {
|
||||
downloadAssets,
|
||||
deleteAssets,
|
||||
@@ -337,6 +358,16 @@ const visibleAssets = computed(() => {
|
||||
return listViewSelectableAssets.value
|
||||
})
|
||||
|
||||
const { marqueeStyle } = useAssetGridSelection({
|
||||
marqueeContainerRef: marqueePanelRef,
|
||||
hoverTargetRef: marqueePanelRef,
|
||||
getAssets: () => visibleAssets.value,
|
||||
getSelectedIds: () => [...selectedIds.value],
|
||||
setSelectedIds,
|
||||
selectAll,
|
||||
isEnabled: () => !isListView.value
|
||||
})
|
||||
|
||||
const previewableVisibleAssets = computed(() =>
|
||||
visibleAssets.value.filter((asset) =>
|
||||
isPreviewableMediaType(getMediaTypeFromFilename(asset.name))
|
||||
@@ -575,7 +606,7 @@ const handleDeselectAll = () => {
|
||||
}
|
||||
|
||||
const handleEmptySpaceClick = () => {
|
||||
if (hasSelection) {
|
||||
if (hasSelection.value) {
|
||||
clearSelection()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,5 +112,12 @@ export interface BillingContext extends BillingState, BillingActions {
|
||||
* (legacy) per-member tier plan, which keeps the old team pricing table.
|
||||
*/
|
||||
isLegacyTeamPlan: ComputedRef<boolean>
|
||||
/**
|
||||
* True when the subscription is a team plan of either generation. Unlike
|
||||
* `isLegacyTeamPlan` this does not require an active subscription: the spend
|
||||
* gate folds billing_status into is_active, so a paused or payment-failed team
|
||||
* plan reports is_active=false and must still read as a team plan.
|
||||
*/
|
||||
isTeamPlan: ComputedRef<boolean>
|
||||
getMaxSeats: (tierKey: TierKey) => number
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ const DEFAULT_BILLING_STATUS: BillingStatusResponse = {
|
||||
|
||||
const {
|
||||
mockTeamWorkspacesEnabled,
|
||||
mockConsolidatedBillingEnabled,
|
||||
mockBillingControlEnabled,
|
||||
mockIsPersonal,
|
||||
mockPlans,
|
||||
mockPurchaseCredits,
|
||||
@@ -27,7 +27,7 @@ const {
|
||||
mockBillingStatus
|
||||
} = vi.hoisted(() => ({
|
||||
mockTeamWorkspacesEnabled: { value: false },
|
||||
mockConsolidatedBillingEnabled: { value: false },
|
||||
mockBillingControlEnabled: { value: false },
|
||||
mockIsPersonal: { value: true },
|
||||
mockPlans: { value: [] as Plan[] },
|
||||
mockPurchaseCredits: vi.fn(),
|
||||
@@ -59,13 +59,11 @@ vi.mock('@/composables/useFeatureFlags', async () => {
|
||||
teamWorkspacesEnabledRef.value = value
|
||||
}
|
||||
})
|
||||
const consolidatedBillingEnabledRef = ref(
|
||||
mockConsolidatedBillingEnabled.value
|
||||
)
|
||||
Object.defineProperty(mockConsolidatedBillingEnabled, 'value', {
|
||||
get: () => consolidatedBillingEnabledRef.value,
|
||||
const billingControlEnabledRef = ref(mockBillingControlEnabled.value)
|
||||
Object.defineProperty(mockBillingControlEnabled, 'value', {
|
||||
get: () => billingControlEnabledRef.value,
|
||||
set: (value: boolean) => {
|
||||
consolidatedBillingEnabledRef.value = value
|
||||
billingControlEnabledRef.value = value
|
||||
}
|
||||
})
|
||||
return {
|
||||
@@ -74,8 +72,8 @@ vi.mock('@/composables/useFeatureFlags', async () => {
|
||||
get teamWorkspacesEnabled() {
|
||||
return mockTeamWorkspacesEnabled.value
|
||||
},
|
||||
get consolidatedBillingEnabled() {
|
||||
return mockConsolidatedBillingEnabled.value
|
||||
get billingControlEnabled() {
|
||||
return mockBillingControlEnabled.value
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -165,7 +163,7 @@ describe('useBillingContext', () => {
|
||||
setActivePinia(createPinia())
|
||||
vi.clearAllMocks()
|
||||
mockTeamWorkspacesEnabled.value = false
|
||||
mockConsolidatedBillingEnabled.value = false
|
||||
mockBillingControlEnabled.value = false
|
||||
mockIsPersonal.value = true
|
||||
mockPlans.value = []
|
||||
mockBillingStatus.value = { ...DEFAULT_BILLING_STATUS }
|
||||
@@ -177,27 +175,27 @@ describe('useBillingContext', () => {
|
||||
expect(type.value).toBe('legacy')
|
||||
})
|
||||
|
||||
it('keeps personal on legacy when consolidated billing is disabled', () => {
|
||||
it('keeps personal on legacy when billing control is disabled', () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockConsolidatedBillingEnabled.value = false
|
||||
mockBillingControlEnabled.value = false
|
||||
mockIsPersonal.value = true
|
||||
|
||||
const { type } = useBillingContext()
|
||||
expect(type.value).toBe('legacy')
|
||||
})
|
||||
|
||||
it('selects workspace type for personal when consolidated billing is enabled', () => {
|
||||
it('selects workspace type for personal when billing control is enabled', () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockConsolidatedBillingEnabled.value = true
|
||||
mockBillingControlEnabled.value = true
|
||||
mockIsPersonal.value = true
|
||||
|
||||
const { type } = useBillingContext()
|
||||
expect(type.value).toBe('workspace')
|
||||
})
|
||||
|
||||
it('selects workspace type for team regardless of consolidated billing', () => {
|
||||
it('selects workspace type for team regardless of billing control', () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockConsolidatedBillingEnabled.value = false
|
||||
mockBillingControlEnabled.value = false
|
||||
mockIsPersonal.value = false
|
||||
|
||||
const { type } = useBillingContext()
|
||||
@@ -298,7 +296,7 @@ describe('useBillingContext', () => {
|
||||
expect(workspaceApi.getBillingStatus).not.toHaveBeenCalled()
|
||||
|
||||
// Authenticated remote config resolves the flag on for the same workspace
|
||||
mockConsolidatedBillingEnabled.value = true
|
||||
mockBillingControlEnabled.value = true
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
|
||||
await vi.waitFor(() => {
|
||||
@@ -307,16 +305,16 @@ describe('useBillingContext', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('moves a personal workspace to workspace billing when consolidated billing flips on', async () => {
|
||||
it('moves a personal workspace to workspace billing when billing control flips on', async () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockConsolidatedBillingEnabled.value = false
|
||||
mockBillingControlEnabled.value = false
|
||||
mockIsPersonal.value = true
|
||||
|
||||
const { type } = useBillingContext()
|
||||
await nextTick()
|
||||
expect(type.value).toBe('legacy')
|
||||
|
||||
mockConsolidatedBillingEnabled.value = true
|
||||
mockBillingControlEnabled.value = true
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(type.value).toBe('workspace')
|
||||
@@ -325,9 +323,9 @@ describe('useBillingContext', () => {
|
||||
})
|
||||
|
||||
describe('subscription mirror to workspace store', () => {
|
||||
it('mirrors subscription for personal workspaces on the consolidated billing flow', async () => {
|
||||
it('mirrors subscription for personal workspaces on the billing control flow', async () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockConsolidatedBillingEnabled.value = true
|
||||
mockBillingControlEnabled.value = true
|
||||
mockIsPersonal.value = true
|
||||
|
||||
const { initialize } = useBillingContext()
|
||||
@@ -555,4 +553,110 @@ describe('useBillingContext', () => {
|
||||
expect(isLegacyTeamPlan.value).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('isTeamPlan', () => {
|
||||
it('is false for a personal workspace', () => {
|
||||
const { isTeamPlan } = useBillingContext()
|
||||
expect(isTeamPlan.value).toBe(false)
|
||||
})
|
||||
|
||||
// subscription_tier is omitted throughout: the backend sends 'TEAM' here, but
|
||||
// the FE's SubscriptionTier resolves to the registry spec, which has no TEAM
|
||||
// (tierPricing.ts imports comfyRegistryTypes for what is an ingest field).
|
||||
// isTeamPlan reads the credit stop and the slug, never the tier — which is
|
||||
// what keeps it working despite that divergence.
|
||||
it('is true for a credit-slider team sub, which carries a credit stop', async () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockIsPersonal.value = false
|
||||
mockBillingStatus.value = {
|
||||
is_active: true,
|
||||
has_funds: true,
|
||||
plan_slug: 'team_per_credit_monthly',
|
||||
team_credit_stop: {
|
||||
id: 'team_700',
|
||||
credits_monthly: 700,
|
||||
stop_usd: 332
|
||||
}
|
||||
}
|
||||
|
||||
const { initialize, isTeamPlan } = useBillingContext()
|
||||
await initialize()
|
||||
|
||||
expect(isTeamPlan.value).toBe(true)
|
||||
})
|
||||
|
||||
it('is true for a legacy team sub, identified by slug rather than credit stop', async () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockIsPersonal.value = false
|
||||
mockBillingStatus.value = {
|
||||
is_active: true,
|
||||
has_funds: true,
|
||||
subscription_tier: 'STANDARD',
|
||||
plan_slug: 'team-standard-annual'
|
||||
}
|
||||
|
||||
const { initialize, isTeamPlan } = useBillingContext()
|
||||
await initialize()
|
||||
|
||||
expect(isTeamPlan.value).toBe(true)
|
||||
})
|
||||
|
||||
// The banner states that need isTeamPlan most — paused and payment_failed —
|
||||
// are exactly the ones the backend reports with is_active=false, because the
|
||||
// spend gate folds billing_status into it. Coupling isTeamPlan to an active
|
||||
// subscription would blank the banner precisely when it is needed.
|
||||
it('stays true for a paused team plan, which the backend reports inactive', async () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockIsPersonal.value = false
|
||||
mockBillingStatus.value = {
|
||||
is_active: false,
|
||||
has_funds: true,
|
||||
billing_status: 'paused',
|
||||
plan_slug: 'team_per_credit_monthly',
|
||||
team_credit_stop: {
|
||||
id: 'team_700',
|
||||
credits_monthly: 700,
|
||||
stop_usd: 332
|
||||
}
|
||||
}
|
||||
|
||||
const { initialize, isTeamPlan } = useBillingContext()
|
||||
await initialize()
|
||||
|
||||
expect(isTeamPlan.value).toBe(true)
|
||||
})
|
||||
|
||||
it('stays true for a legacy team plan whose payment failed', async () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockIsPersonal.value = false
|
||||
mockBillingStatus.value = {
|
||||
is_active: false,
|
||||
has_funds: true,
|
||||
billing_status: 'payment_failed',
|
||||
subscription_tier: 'STANDARD',
|
||||
plan_slug: 'team-standard-annual'
|
||||
}
|
||||
|
||||
const { initialize, isTeamPlan } = useBillingContext()
|
||||
await initialize()
|
||||
|
||||
expect(isTeamPlan.value).toBe(true)
|
||||
})
|
||||
|
||||
it('is false for a team workspace on a personal-tier plan', async () => {
|
||||
mockTeamWorkspacesEnabled.value = true
|
||||
mockIsPersonal.value = false
|
||||
mockBillingStatus.value = {
|
||||
is_active: true,
|
||||
has_funds: true,
|
||||
subscription_tier: 'PRO',
|
||||
plan_slug: 'pro-monthly'
|
||||
}
|
||||
|
||||
const { initialize, isTeamPlan } = useBillingContext()
|
||||
await initialize()
|
||||
|
||||
expect(isTeamPlan.value).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -35,8 +35,8 @@ const LEGACY_TEAM_PLAN_SLUG_PREFIX = 'team-'
|
||||
*
|
||||
* - Team workspaces disabled (OSS/Desktop): legacy billing via /customers/*
|
||||
* - Team workspaces enabled: workspace billing via /api/billing/* for team
|
||||
* workspaces, and for personal workspaces once consolidated billing is
|
||||
* enabled; personal workspaces otherwise stay on legacy billing
|
||||
* workspaces, and for personal workspaces once billing control is enabled;
|
||||
* personal workspaces otherwise stay on legacy billing
|
||||
*
|
||||
* The context automatically initializes when the workspace changes and provides
|
||||
* a unified interface for subscription status, balance, and billing actions.
|
||||
@@ -141,6 +141,21 @@ function useBillingContextInternal(): BillingContext {
|
||||
false)
|
||||
)
|
||||
|
||||
// Plan identity, independent of subscription health: the per-credit Team plan
|
||||
// carries a credit stop, the retired seat-based ones a `team-` slug. Kept off
|
||||
// isActiveSubscription on purpose — paused and payment_failed both force
|
||||
// is_active=false, which is exactly when callers still need to know this is a
|
||||
// team plan.
|
||||
const isTeamPlan = computed(
|
||||
() =>
|
||||
type.value === 'workspace' &&
|
||||
(currentTeamCreditStop.value !== null ||
|
||||
(currentPlanSlug.value
|
||||
?.toLowerCase()
|
||||
.startsWith(LEGACY_TEAM_PLAN_SLUG_PREFIX) ??
|
||||
false))
|
||||
)
|
||||
|
||||
const billingStatus = computed(() =>
|
||||
toValue(activeContext.value.billingStatus)
|
||||
)
|
||||
@@ -191,9 +206,9 @@ function useBillingContextInternal(): BillingContext {
|
||||
error.value = null
|
||||
}
|
||||
|
||||
// type flips when the team-workspaces or consolidated-billing flag resolves
|
||||
// from authenticated config, swapping the active backend. Reset then reinit
|
||||
// on every workspace-id or type change.
|
||||
// type flips when the team-workspaces or billing-control flag resolves from
|
||||
// authenticated config, swapping the active backend. Reset then reinit on
|
||||
// every workspace-id or type change.
|
||||
watch(
|
||||
[() => store.activeWorkspace?.id, () => type.value],
|
||||
async ([newWorkspaceId]) => {
|
||||
@@ -299,6 +314,7 @@ function useBillingContextInternal(): BillingContext {
|
||||
isActiveSubscription,
|
||||
isFreeTier,
|
||||
isLegacyTeamPlan,
|
||||
isTeamPlan,
|
||||
billingStatus,
|
||||
subscriptionStatus,
|
||||
tier,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useBillingRouting } from './useBillingRouting'
|
||||
const { mockFlags, mockActiveWorkspace } = vi.hoisted(() => ({
|
||||
mockFlags: {
|
||||
teamWorkspacesEnabled: false,
|
||||
consolidatedBillingEnabled: false
|
||||
billingControlEnabled: false
|
||||
},
|
||||
mockActiveWorkspace: {
|
||||
value: null as { id: string; type: 'personal' | 'team' } | null
|
||||
@@ -30,7 +30,7 @@ const team = { id: 'w-team', type: 'team' as const }
|
||||
describe('useBillingRouting', () => {
|
||||
beforeEach(() => {
|
||||
mockFlags.teamWorkspacesEnabled = false
|
||||
mockFlags.consolidatedBillingEnabled = false
|
||||
mockFlags.billingControlEnabled = false
|
||||
mockActiveWorkspace.value = personal
|
||||
})
|
||||
|
||||
@@ -44,9 +44,9 @@ describe('useBillingRouting', () => {
|
||||
expect(shouldUseWorkspaceBilling.value).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps personal on legacy when consolidated billing is disabled', () => {
|
||||
it('keeps personal on legacy when billing control is disabled', () => {
|
||||
mockFlags.teamWorkspacesEnabled = true
|
||||
mockFlags.consolidatedBillingEnabled = false
|
||||
mockFlags.billingControlEnabled = false
|
||||
mockActiveWorkspace.value = personal
|
||||
|
||||
const { type } = useBillingRouting()
|
||||
@@ -54,9 +54,9 @@ describe('useBillingRouting', () => {
|
||||
expect(type.value).toBe('legacy')
|
||||
})
|
||||
|
||||
it('moves personal to workspace billing when consolidated billing is enabled', () => {
|
||||
it('moves personal to workspace billing when billing control is enabled', () => {
|
||||
mockFlags.teamWorkspacesEnabled = true
|
||||
mockFlags.consolidatedBillingEnabled = true
|
||||
mockFlags.billingControlEnabled = true
|
||||
mockActiveWorkspace.value = personal
|
||||
|
||||
const { type, shouldUseWorkspaceBilling } = useBillingRouting()
|
||||
@@ -65,9 +65,9 @@ describe('useBillingRouting', () => {
|
||||
expect(shouldUseWorkspaceBilling.value).toBe(true)
|
||||
})
|
||||
|
||||
it('uses workspace billing for team workspaces regardless of consolidated billing', () => {
|
||||
it('uses workspace billing for team workspaces regardless of billing control', () => {
|
||||
mockFlags.teamWorkspacesEnabled = true
|
||||
mockFlags.consolidatedBillingEnabled = false
|
||||
mockFlags.billingControlEnabled = false
|
||||
mockActiveWorkspace.value = team
|
||||
|
||||
const { type, shouldUseWorkspaceBilling } = useBillingRouting()
|
||||
@@ -76,9 +76,9 @@ describe('useBillingRouting', () => {
|
||||
expect(shouldUseWorkspaceBilling.value).toBe(true)
|
||||
})
|
||||
|
||||
it('uses workspace billing for team workspaces with consolidated billing enabled', () => {
|
||||
it('uses workspace billing for team workspaces with billing control enabled', () => {
|
||||
mockFlags.teamWorkspacesEnabled = true
|
||||
mockFlags.consolidatedBillingEnabled = true
|
||||
mockFlags.billingControlEnabled = true
|
||||
mockActiveWorkspace.value = team
|
||||
|
||||
const { type, shouldUseWorkspaceBilling } = useBillingRouting()
|
||||
@@ -89,7 +89,7 @@ describe('useBillingRouting', () => {
|
||||
|
||||
it('defaults to legacy while the workspace has not loaded', () => {
|
||||
mockFlags.teamWorkspacesEnabled = true
|
||||
mockFlags.consolidatedBillingEnabled = true
|
||||
mockFlags.billingControlEnabled = true
|
||||
mockActiveWorkspace.value = null
|
||||
|
||||
const { type } = useBillingRouting()
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { BillingType } from './types'
|
||||
/**
|
||||
* Selects the billing backend for the active workspace: legacy user-scoped
|
||||
* (`/customers/*`) or workspace-scoped (`/api/billing/*`). Personal workspaces
|
||||
* stay legacy until `consolidatedBillingEnabled`; team workspaces are always
|
||||
* stay legacy until `billingControlEnabled`; team workspaces are always
|
||||
* workspace-scoped. The routing matrix is covered in useBillingRouting.test.ts.
|
||||
*/
|
||||
export function useBillingRouting() {
|
||||
@@ -23,7 +23,7 @@ export function useBillingRouting() {
|
||||
const workspaceType = workspaceStore.activeWorkspace?.type
|
||||
if (!workspaceType) return 'legacy'
|
||||
|
||||
if (workspaceType === 'personal' && !flags.consolidatedBillingEnabled) {
|
||||
if (workspaceType === 'personal' && !flags.billingControlEnabled) {
|
||||
return 'legacy'
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@/composables/useFeatureFlags'
|
||||
import * as distributionTypes from '@/platform/distribution/types'
|
||||
import {
|
||||
cachedConsolidatedBillingEnabled,
|
||||
cachedBillingControlEnabled,
|
||||
cachedTeamWorkspacesEnabled,
|
||||
remoteConfig,
|
||||
remoteConfigState
|
||||
@@ -226,19 +226,19 @@ describe('useFeatureFlags', () => {
|
||||
expect(flags.teamWorkspacesEnabled).toBe(true)
|
||||
})
|
||||
|
||||
it('consolidatedBillingEnabled override bypasses isCloud and isAuthenticatedConfigLoaded guards', () => {
|
||||
it('billingControlEnabled override bypasses isCloud and isAuthenticatedConfigLoaded guards', () => {
|
||||
vi.mocked(distributionTypes).isCloud = false
|
||||
localStorage.setItem('ff:consolidated_billing_enabled', 'true')
|
||||
localStorage.setItem('ff:billing_control_enabled', 'true')
|
||||
|
||||
const { flags } = useFeatureFlags()
|
||||
expect(flags.consolidatedBillingEnabled).toBe(true)
|
||||
expect(flags.billingControlEnabled).toBe(true)
|
||||
})
|
||||
|
||||
it('consolidatedBillingEnabled is false off-cloud even without an override', () => {
|
||||
it('billingControlEnabled is false off-cloud even without an override', () => {
|
||||
vi.mocked(distributionTypes).isCloud = false
|
||||
|
||||
const { flags } = useFeatureFlags()
|
||||
expect(flags.consolidatedBillingEnabled).toBe(false)
|
||||
expect(flags.billingControlEnabled).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -248,7 +248,7 @@ describe('useFeatureFlags', () => {
|
||||
remoteConfigState.value = 'unloaded'
|
||||
remoteConfig.value = {}
|
||||
cachedTeamWorkspacesEnabled.value = undefined
|
||||
cachedConsolidatedBillingEnabled.value = undefined
|
||||
cachedBillingControlEnabled.value = undefined
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
@@ -257,36 +257,36 @@ describe('useFeatureFlags', () => {
|
||||
remoteConfigState.value = 'unloaded'
|
||||
remoteConfig.value = {}
|
||||
cachedTeamWorkspacesEnabled.value = undefined
|
||||
cachedConsolidatedBillingEnabled.value = undefined
|
||||
cachedBillingControlEnabled.value = undefined
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
it('returns the cached session value during the auth window', () => {
|
||||
cachedTeamWorkspacesEnabled.value = false
|
||||
cachedConsolidatedBillingEnabled.value = true
|
||||
cachedBillingControlEnabled.value = true
|
||||
|
||||
const { flags } = useFeatureFlags()
|
||||
expect(flags.teamWorkspacesEnabled).toBe(false)
|
||||
expect(flags.consolidatedBillingEnabled).toBe(true)
|
||||
expect(flags.billingControlEnabled).toBe(true)
|
||||
})
|
||||
|
||||
it('defaults to false during the auth window when nothing is cached', () => {
|
||||
const { flags } = useFeatureFlags()
|
||||
expect(flags.teamWorkspacesEnabled).toBe(false)
|
||||
expect(flags.consolidatedBillingEnabled).toBe(false)
|
||||
expect(flags.billingControlEnabled).toBe(false)
|
||||
})
|
||||
|
||||
it('prefers authenticated remoteConfig over the server feature fallback', () => {
|
||||
remoteConfigState.value = 'authenticated'
|
||||
remoteConfig.value = {
|
||||
team_workspaces_enabled: true,
|
||||
consolidated_billing_enabled: true
|
||||
billing_control_enabled: true
|
||||
}
|
||||
vi.mocked(api.getServerFeature).mockReturnValue(false)
|
||||
|
||||
const { flags } = useFeatureFlags()
|
||||
expect(flags.teamWorkspacesEnabled).toBe(true)
|
||||
expect(flags.consolidatedBillingEnabled).toBe(true)
|
||||
expect(flags.billingControlEnabled).toBe(true)
|
||||
})
|
||||
|
||||
it('falls back to api.getServerFeature when authenticated config omits the flag', () => {
|
||||
@@ -295,15 +295,14 @@ describe('useFeatureFlags', () => {
|
||||
vi.mocked(api.getServerFeature).mockImplementation(
|
||||
(path, defaultValue) => {
|
||||
if (path === ServerFeatureFlag.TEAM_WORKSPACES_ENABLED) return true
|
||||
if (path === ServerFeatureFlag.CONSOLIDATED_BILLING_ENABLED)
|
||||
return true
|
||||
if (path === ServerFeatureFlag.BILLING_CONTROL_ENABLED) return true
|
||||
return defaultValue
|
||||
}
|
||||
)
|
||||
|
||||
const { flags } = useFeatureFlags()
|
||||
expect(flags.teamWorkspacesEnabled).toBe(true)
|
||||
expect(flags.consolidatedBillingEnabled).toBe(true)
|
||||
expect(flags.billingControlEnabled).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { Ref } from 'vue'
|
||||
|
||||
import { isCloud, isNightly } from '@/platform/distribution/types'
|
||||
import {
|
||||
cachedConsolidatedBillingEnabled,
|
||||
cachedBillingControlEnabled,
|
||||
cachedTeamWorkspacesEnabled,
|
||||
isAuthenticatedConfigLoaded,
|
||||
remoteConfig
|
||||
@@ -32,7 +32,7 @@ export enum ServerFeatureFlag {
|
||||
COMFYHUB_PROFILE_GATE_ENABLED = 'comfyhub_profile_gate_enabled',
|
||||
SHOW_SIGNIN_BUTTON = 'show_signin_button',
|
||||
UNIFIED_CLOUD_AUTH = 'unified_cloud_auth',
|
||||
CONSOLIDATED_BILLING_ENABLED = 'consolidated_billing_enabled',
|
||||
BILLING_CONTROL_ENABLED = 'billing_control_enabled',
|
||||
SIGNUP_TURNSTILE = 'signup_turnstile'
|
||||
}
|
||||
|
||||
@@ -191,15 +191,15 @@ export function useFeatureFlags() {
|
||||
)
|
||||
},
|
||||
/**
|
||||
* Whether personal workspaces use the consolidated (workspace-scoped)
|
||||
* billing flow. While false (default), personal workspaces stay on the
|
||||
* legacy per-user billing flow; team workspaces are unaffected.
|
||||
* Whether personal workspaces use the workspace-scoped billing flow. While
|
||||
* false (default), personal workspaces stay on the legacy per-user billing
|
||||
* flow; team workspaces are unaffected.
|
||||
*/
|
||||
get consolidatedBillingEnabled() {
|
||||
get billingControlEnabled() {
|
||||
return resolveAuthGatedFlag(
|
||||
ServerFeatureFlag.CONSOLIDATED_BILLING_ENABLED,
|
||||
remoteConfig.value.consolidated_billing_enabled,
|
||||
cachedConsolidatedBillingEnabled
|
||||
ServerFeatureFlag.BILLING_CONTROL_ENABLED,
|
||||
remoteConfig.value.billing_control_enabled,
|
||||
cachedBillingControlEnabled
|
||||
)
|
||||
},
|
||||
get signupTurnstileMode() {
|
||||
|
||||
@@ -2473,6 +2473,11 @@
|
||||
},
|
||||
"credits": {
|
||||
"activity": "Activity",
|
||||
"insufficient": {
|
||||
"memberTitle": "This workspace is out of credits",
|
||||
"memberDescription": "Your team has used all its credits. Your workspace admins need to add more credits to run workflows.",
|
||||
"memberCta": "Ok, got it"
|
||||
},
|
||||
"credits": "Credits",
|
||||
"yourCreditBalance": "Your credit balance",
|
||||
"purchaseCredits": "Purchase Credits",
|
||||
@@ -2882,6 +2887,32 @@
|
||||
"updatePassword": "Update Password"
|
||||
},
|
||||
"workspacePanel": {
|
||||
"billingStatus": {
|
||||
"warning": {
|
||||
"title": "Payment declined",
|
||||
"body": "Your last payment didn't go through. Your subscription will pause on {date} unless payment is updated.",
|
||||
"bodyNoDate": "Your last payment didn't go through. Update payment to avoid a pause."
|
||||
},
|
||||
"paused": {
|
||||
"title": "Subscription paused",
|
||||
"body": "This workspace's subscription is paused. Update payment to resume.",
|
||||
"memberBody": "This workspace's subscription is paused. Your workspace admins need to update the payment method."
|
||||
},
|
||||
"outOfCredits": {
|
||||
"title": "Out of credits",
|
||||
"body": "Your team has used all its credits. Add more credits to continue generating or wait until credits refill on {date}.",
|
||||
"bodyNoDate": "Your team has used all its credits. Add more credits to continue generating.",
|
||||
"memberBody": "Your team has used all its credits. Your workspace admins need to add more credits to continue generating.",
|
||||
"addCredits": "Add credits",
|
||||
"dismiss": "Dismiss"
|
||||
},
|
||||
"ending": {
|
||||
"title": "Your team plan ends on {date}",
|
||||
"body": "Members keep full access until then. Reactivate to keep your shared credits and seats.",
|
||||
"reactivate": "Reactivate plan"
|
||||
},
|
||||
"updatePayment": "Update payment"
|
||||
},
|
||||
"invite": "Invite",
|
||||
"inviteMember": "Invite member",
|
||||
"inviteLimitReached": "You've reached the maximum of {count} members",
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { escapeVueI18nMessageSyntax } from '@comfyorg/shared-frontend-utils/formatUtil'
|
||||
|
||||
/**
|
||||
* Node descriptions are compiled by vue-i18n via `t()`/`st()`, which parses
|
||||
* `@ { } | %` as message syntax — a literal `@` even crashes the compiler with
|
||||
* `Invalid linked format` (this broke the whole app after the 1.47.7 locale
|
||||
* sync). `collect-i18n-node-defs.ts` escapes such values with
|
||||
* `escapeVueI18nMessageSyntax` before writing them; this guards that the escaped
|
||||
* output actually compiles and renders the original literal text.
|
||||
*/
|
||||
describe('escapeVueI18nMessageSyntax output is compiled safely by vue-i18n', () => {
|
||||
const compile = (message: string) => {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'en',
|
||||
messages: { en: { value: message } }
|
||||
})
|
||||
return i18n.global.t('value')
|
||||
}
|
||||
|
||||
it.for([
|
||||
'clips (tagged @Audio1-3 in the prompt)',
|
||||
'support@comfy.org',
|
||||
'resolution {width}x{height}',
|
||||
'foreground | background',
|
||||
'50%{done}',
|
||||
'all of @ { } | % together',
|
||||
'no special chars here'
|
||||
])('renders %s as the original literal text', (raw) => {
|
||||
expect(compile(escapeVueI18nMessageSyntax(raw))).toBe(raw)
|
||||
})
|
||||
})
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
configValueOrDefault,
|
||||
remoteConfig
|
||||
} from '@/platform/remoteConfig/remoteConfig'
|
||||
import { syncHostUserIdWithFirebaseAuth } from '@/platform/telemetry/hostUserIdSync'
|
||||
import '@/lib/litegraph/public/css/litegraph.css'
|
||||
import router from '@/router'
|
||||
import { isDesktop, isNightly } from '@/platform/distribution/types'
|
||||
@@ -141,6 +142,10 @@ app
|
||||
modules: [VueFireAuth()]
|
||||
})
|
||||
|
||||
if (isCloud && hasHostTelemetryBridge) {
|
||||
syncHostUserIdWithFirebaseAuth()
|
||||
}
|
||||
|
||||
LGraph.proxyWidgetMigrationFlush = (hostNode, nodeData) =>
|
||||
flushProxyWidgetMigration({
|
||||
hostNode,
|
||||
|
||||
118
src/platform/assets/components/MediaAssetCard.test.ts
Normal file
118
src/platform/assets/components/MediaAssetCard.test.ts
Normal file
@@ -0,0 +1,118 @@
|
||||
import { createTestingPinia } from '@pinia/testing'
|
||||
import { render, screen } from '@testing-library/vue'
|
||||
import { setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
import MediaAssetCard from '@/platform/assets/components/MediaAssetCard.vue'
|
||||
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
|
||||
|
||||
vi.mock('@/stores/assetsStore', () => ({
|
||||
useAssetsStore: () => ({ isAssetDeleting: () => false })
|
||||
}))
|
||||
|
||||
vi.mock('../composables/useMediaAssetActions', () => ({
|
||||
useMediaAssetActions: () => ({ downloadAssets: vi.fn() })
|
||||
}))
|
||||
|
||||
vi.mock('@/platform/assets/schemas/assetMetadataSchema', () => ({
|
||||
getOutputAssetMetadata: () => ({
|
||||
allOutputs: [
|
||||
{
|
||||
filename: 'a.png',
|
||||
subfolder: '',
|
||||
type: 'output',
|
||||
display_name: 'Display A'
|
||||
}
|
||||
]
|
||||
})
|
||||
}))
|
||||
|
||||
const asset: AssetItem = {
|
||||
id: 'a',
|
||||
name: 'a.png',
|
||||
tags: [],
|
||||
preview_url: '/preview.png'
|
||||
}
|
||||
|
||||
function renderCard() {
|
||||
setActivePinia(createTestingPinia({ stubActions: false }))
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'en',
|
||||
messages: { en: {} },
|
||||
missingWarn: false,
|
||||
fallbackWarn: false
|
||||
})
|
||||
return render(MediaAssetCard, {
|
||||
props: { asset, loading: true },
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
stubs: {
|
||||
IconGroup: true,
|
||||
LoadingOverlay: true,
|
||||
Button: true,
|
||||
MediaTitle: true
|
||||
},
|
||||
directives: { tooltip: {} }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function dispatchDragStart(
|
||||
init: { ctrlKey?: boolean; metaKey?: boolean } = {}
|
||||
) {
|
||||
const dataTransfer = new DataTransfer()
|
||||
const add = vi.spyOn(dataTransfer.items, 'add').mockImplementation(() => null)
|
||||
const event = new DragEvent('dragstart', { bubbles: true, cancelable: true })
|
||||
// happy-dom's DragEvent ignores dataTransfer/modifier init, so set them here.
|
||||
Object.defineProperties(event, {
|
||||
dataTransfer: { value: dataTransfer, configurable: true },
|
||||
ctrlKey: { value: init.ctrlKey ?? false, configurable: true },
|
||||
metaKey: { value: init.metaKey ?? false, configurable: true }
|
||||
})
|
||||
screen.getByRole('button').dispatchEvent(event)
|
||||
return { event, add }
|
||||
}
|
||||
|
||||
describe('MediaAssetCard', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('dragStart', () => {
|
||||
it('cancels the native drag when Ctrl is held so a marquee can start over the card', () => {
|
||||
renderCard()
|
||||
|
||||
const { event, add } = dispatchDragStart({ ctrlKey: true })
|
||||
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
expect(add).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('cancels the native drag when Meta is held', () => {
|
||||
renderCard()
|
||||
|
||||
const { event } = dispatchDragStart({ metaKey: true })
|
||||
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
})
|
||||
|
||||
it('includes the asset metadata with display_name in the drag payload', () => {
|
||||
renderCard()
|
||||
|
||||
const { event, add } = dispatchDragStart()
|
||||
|
||||
expect(event.defaultPrevented).toBe(false)
|
||||
expect(add).toHaveBeenCalledWith(
|
||||
JSON.stringify({
|
||||
filename: 'a.png',
|
||||
subfolder: '',
|
||||
type: 'output',
|
||||
display_name: 'Display A'
|
||||
}),
|
||||
expect.any(String)
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -21,6 +21,7 @@
|
||||
)
|
||||
"
|
||||
:data-selected="selected"
|
||||
:data-asset-id="asset?.id"
|
||||
:draggable="true"
|
||||
@click.stop="$emit('click')"
|
||||
@contextmenu.prevent.stop="
|
||||
@@ -316,6 +317,11 @@ const handleOutputCountClick = () => {
|
||||
emit('output-count-click')
|
||||
}
|
||||
function dragStart(e: DragEvent) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault()
|
||||
return
|
||||
}
|
||||
|
||||
if (!asset?.preview_url) return
|
||||
|
||||
const { dataTransfer } = e
|
||||
|
||||
800
src/platform/assets/composables/useAssetGridSelection.test.ts
Normal file
800
src/platform/assets/composables/useAssetGridSelection.test.ts
Normal file
@@ -0,0 +1,800 @@
|
||||
import { render, screen } from '@testing-library/vue'
|
||||
import { fromPartial } from '@total-typescript/shoehorn'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { defineComponent, nextTick, ref } from 'vue'
|
||||
|
||||
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
|
||||
|
||||
import { useAssetGridSelection } from './useAssetGridSelection'
|
||||
|
||||
const assets: AssetItem[] = [
|
||||
{ id: 'a', name: 'a.png', tags: [] },
|
||||
{ id: 'b', name: 'b.png', tags: [] },
|
||||
{ id: 'c', name: 'c.png', tags: [] }
|
||||
]
|
||||
|
||||
const cardBoxes: Record<string, { left: number; right: number }> = {
|
||||
a: { left: 0, right: 50 },
|
||||
b: { left: 60, right: 110 },
|
||||
c: { left: 120, right: 170 }
|
||||
}
|
||||
|
||||
function pointer(type: string, init: PointerEventInit = {}) {
|
||||
return new PointerEvent(type, {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
button: 0,
|
||||
pointerId: 1,
|
||||
isPrimary: true,
|
||||
...init
|
||||
})
|
||||
}
|
||||
|
||||
function createCallbacks(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
getAssets: () => assets,
|
||||
getSelectedIds: vi.fn(() => [] as string[]),
|
||||
setSelectedIds: vi.fn(),
|
||||
selectAll: vi.fn(),
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
async function renderHarness(callbacks: ReturnType<typeof createCallbacks>) {
|
||||
const Harness = defineComponent({
|
||||
setup() {
|
||||
const gridContainerRef = ref<HTMLElement>()
|
||||
const hoverTargetRef = ref<HTMLElement>()
|
||||
const { marqueeStyle } = useAssetGridSelection({
|
||||
marqueeContainerRef: gridContainerRef,
|
||||
hoverTargetRef,
|
||||
getAssets: callbacks.getAssets,
|
||||
getSelectedIds: callbacks.getSelectedIds,
|
||||
setSelectedIds: callbacks.setSelectedIds,
|
||||
selectAll: callbacks.selectAll
|
||||
})
|
||||
return { gridContainerRef, hoverTargetRef, marqueeStyle }
|
||||
},
|
||||
template: `
|
||||
<div ref="hoverTargetRef" data-testid="panel">
|
||||
<input data-testid="search" />
|
||||
<textarea data-testid="textarea"></textarea>
|
||||
<div contenteditable="true" data-testid="editable"></div>
|
||||
<div ref="gridContainerRef" data-testid="grid">
|
||||
<button data-testid="grid-button">x</button>
|
||||
<div data-asset-id="a" data-testid="card-a"></div>
|
||||
<div data-asset-id="b" data-testid="card-b"></div>
|
||||
<div data-asset-id="c" data-testid="card-c"></div>
|
||||
</div>
|
||||
<div
|
||||
v-if="marqueeStyle"
|
||||
data-testid="marquee"
|
||||
:style="marqueeStyle"
|
||||
></div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
render(Harness)
|
||||
await nextTick()
|
||||
vi.spyOn(screen.getByTestId('grid'), 'getBoundingClientRect').mockReturnValue(
|
||||
fromPartial<DOMRect>({ left: 0, top: 0, right: 1000, bottom: 1000 })
|
||||
)
|
||||
for (const id of Object.keys(cardBoxes)) {
|
||||
vi.spyOn(
|
||||
screen.getByTestId(`card-${id}`),
|
||||
'getBoundingClientRect'
|
||||
).mockReturnValue(
|
||||
fromPartial<DOMRect>({
|
||||
left: cardBoxes[id].left,
|
||||
right: cardBoxes[id].right,
|
||||
top: 0,
|
||||
bottom: 50
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const grid = () => screen.getByTestId('grid')
|
||||
const panel = () => screen.getByTestId('panel')
|
||||
const card = (id: string) => screen.getByTestId(`card-${id}`)
|
||||
|
||||
describe('useAssetGridSelection', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('marquee', () => {
|
||||
it('selects intersecting cards when dragging from empty space', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 110, clientY: 50 })
|
||||
)
|
||||
|
||||
expect(callbacks.setSelectedIds).toHaveBeenLastCalledWith(
|
||||
['a', 'b'],
|
||||
assets
|
||||
)
|
||||
})
|
||||
|
||||
it('unions with the current selection when a modifier is held', async () => {
|
||||
const callbacks = createCallbacks({ getSelectedIds: vi.fn(() => ['c']) })
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 0, clientY: 0, shiftKey: true })
|
||||
)
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 55, clientY: 50 }))
|
||||
|
||||
expect(
|
||||
[...callbacks.setSelectedIds.mock.lastCall![0]].sort(
|
||||
(a: string, b: string) => a.localeCompare(b)
|
||||
)
|
||||
).toEqual(['a', 'c'])
|
||||
})
|
||||
|
||||
it('removes covered cards from the selection when Ctrl+Shift is held (subtractive)', async () => {
|
||||
const callbacks = createCallbacks({
|
||||
getSelectedIds: vi.fn(() => ['a', 'b'])
|
||||
})
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(
|
||||
pointer('pointerdown', {
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
ctrlKey: true,
|
||||
shiftKey: true
|
||||
})
|
||||
)
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 55, clientY: 50 }))
|
||||
|
||||
expect(callbacks.setSelectedIds.mock.lastCall![0]).toEqual(['b'])
|
||||
})
|
||||
|
||||
it('removes covered cards when Cmd+Shift is held (macOS subtractive)', async () => {
|
||||
const callbacks = createCallbacks({
|
||||
getSelectedIds: vi.fn(() => ['a', 'b'])
|
||||
})
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(
|
||||
pointer('pointerdown', {
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
metaKey: true,
|
||||
shiftKey: true
|
||||
})
|
||||
)
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 55, clientY: 50 }))
|
||||
|
||||
expect(callbacks.setSelectedIds.mock.lastCall![0]).toEqual(['b'])
|
||||
})
|
||||
|
||||
it('restores cards when the subtractive marquee shrinks back off them', async () => {
|
||||
const callbacks = createCallbacks({
|
||||
getSelectedIds: vi.fn(() => ['a', 'b'])
|
||||
})
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(
|
||||
pointer('pointerdown', {
|
||||
clientX: 55,
|
||||
clientY: 55,
|
||||
ctrlKey: true,
|
||||
shiftKey: true
|
||||
})
|
||||
)
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 5, clientY: 45 }))
|
||||
expect(callbacks.setSelectedIds.mock.lastCall![0]).toEqual(['b'])
|
||||
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 54, clientY: 54 }))
|
||||
expect(callbacks.setSelectedIds.mock.lastCall![0]).toEqual(['a', 'b'])
|
||||
})
|
||||
|
||||
it('ignores movement below the drag threshold', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 2, clientY: 2 }))
|
||||
|
||||
expect(callbacks.setSelectedIds).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not start a marquee on a plain pointer-down on a card', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
card('a').dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 5, clientY: 5 })
|
||||
)
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 80, clientY: 40 }))
|
||||
|
||||
expect(callbacks.setSelectedIds).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('starts a marquee on a card when Ctrl is held and blocks native drag', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
card('a').dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 5, clientY: 5, ctrlKey: true })
|
||||
)
|
||||
const dragEvent = new DragEvent('dragstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
card('a').dispatchEvent(dragEvent)
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 65, clientY: 40 }))
|
||||
|
||||
expect(dragEvent.defaultPrevented).toBe(true)
|
||||
expect(callbacks.setSelectedIds).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not block native drag when no marquee is tracking', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
const dragEvent = new DragEvent('dragstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
card('a').dispatchEvent(dragEvent)
|
||||
|
||||
expect(dragEvent.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('shows a marquee overlay while dragging and removes it on release', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 30, clientY: 40 }))
|
||||
await nextTick()
|
||||
|
||||
const overlay = screen.getByTestId('marquee')
|
||||
expect(overlay.style.width).toBe('30px')
|
||||
expect(overlay.style.height).toBe('40px')
|
||||
|
||||
window.dispatchEvent(pointer('pointerup', { clientX: 30, clientY: 40 }))
|
||||
await nextTick()
|
||||
expect(screen.queryByTestId('marquee')).toBeNull()
|
||||
})
|
||||
|
||||
it('clips the overlay to the grid container when dragging past its edge', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 10, clientY: 10 }))
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 2000, clientY: 2000 })
|
||||
)
|
||||
await nextTick()
|
||||
|
||||
const overlay = screen.getByTestId('marquee')
|
||||
expect(overlay.style.left).toBe('10px')
|
||||
expect(overlay.style.top).toBe('10px')
|
||||
expect(overlay.style.width).toBe('990px')
|
||||
expect(overlay.style.height).toBe('990px')
|
||||
})
|
||||
|
||||
it('clears the overlay on dragend when a native drag swallows pointerup', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 30, clientY: 40 }))
|
||||
await nextTick()
|
||||
expect(screen.getByTestId('marquee')).toBeTruthy()
|
||||
|
||||
window.dispatchEvent(new DragEvent('dragend', { bubbles: true }))
|
||||
await nextTick()
|
||||
expect(screen.queryByTestId('marquee')).toBeNull()
|
||||
})
|
||||
|
||||
it('suppresses the click that trails a drag, but not a plain click', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 80, clientY: 40 }))
|
||||
window.dispatchEvent(pointer('pointerup', { clientX: 80, clientY: 40 }))
|
||||
|
||||
const trailing = new MouseEvent('click', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
window.dispatchEvent(trailing)
|
||||
expect(trailing.defaultPrevented).toBe(true)
|
||||
|
||||
const next = new MouseEvent('click', { bubbles: true, cancelable: true })
|
||||
window.dispatchEvent(next)
|
||||
expect(next.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('does not start a marquee for a non-primary mouse button', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 0, clientY: 0, button: 2 })
|
||||
)
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 110, clientY: 50 })
|
||||
)
|
||||
|
||||
expect(callbacks.setSelectedIds).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not start a marquee when the press lands on an interactive control', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
screen
|
||||
.getByTestId('grid-button')
|
||||
.dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 110, clientY: 50 })
|
||||
)
|
||||
|
||||
expect(callbacks.setSelectedIds).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('starts a marquee on a card when Cmd/Meta is held', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
card('a').dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 5, clientY: 5, metaKey: true })
|
||||
)
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 65, clientY: 40 }))
|
||||
|
||||
expect(callbacks.setSelectedIds).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('clears the selection when a no-modifier marquee covers no card', async () => {
|
||||
const callbacks = createCallbacks({ getSelectedIds: vi.fn(() => ['a']) })
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 300, clientY: 300 })
|
||||
)
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 400, clientY: 400 })
|
||||
)
|
||||
|
||||
expect(callbacks.setSelectedIds).toHaveBeenLastCalledWith([], assets)
|
||||
})
|
||||
|
||||
it('prevents text selection during a marquee and releases it on pointercancel', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 30, clientY: 40 }))
|
||||
await nextTick()
|
||||
expect(screen.getByTestId('marquee')).toBeTruthy()
|
||||
|
||||
const duringDrag = new Event('selectstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
grid().dispatchEvent(duringDrag)
|
||||
expect(duringDrag.defaultPrevented).toBe(true)
|
||||
|
||||
window.dispatchEvent(
|
||||
pointer('pointercancel', { clientX: 30, clientY: 40 })
|
||||
)
|
||||
await nextTick()
|
||||
expect(screen.queryByTestId('marquee')).toBeNull()
|
||||
|
||||
const afterEnd = new Event('selectstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
grid().dispatchEvent(afterEnd)
|
||||
expect(afterEnd.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('auto-resets click suppression when a drag ends without a trailing click', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 80, clientY: 40 }))
|
||||
window.dispatchEvent(
|
||||
pointer('pointercancel', { clientX: 80, clientY: 40 })
|
||||
)
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve))
|
||||
|
||||
const laterClick = new MouseEvent('click', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
window.dispatchEvent(laterClick)
|
||||
expect(laterClick.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('only blocks text selection inside the grid container during a marquee', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 30, clientY: 40 }))
|
||||
await nextTick()
|
||||
|
||||
const insideGrid = new Event('selectstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
card('a').dispatchEvent(insideGrid)
|
||||
expect(insideGrid.defaultPrevented).toBe(true)
|
||||
|
||||
const outsideGrid = new Event('selectstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
screen.getByTestId('search').dispatchEvent(outsideGrid)
|
||||
expect(outsideGrid.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('stops blocking text selection after a normal marquee release', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 30, clientY: 40 }))
|
||||
|
||||
const duringDrag = new Event('selectstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
card('a').dispatchEvent(duringDrag)
|
||||
expect(duringDrag.defaultPrevented).toBe(true)
|
||||
|
||||
window.dispatchEvent(pointer('pointerup', { clientX: 30, clientY: 40 }))
|
||||
|
||||
const afterRelease = new Event('selectstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
card('a').dispatchEvent(afterRelease)
|
||||
expect(afterRelease.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('does not suppress the click after a sub-threshold press', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(pointer('pointermove', { clientX: 2, clientY: 2 }))
|
||||
window.dispatchEvent(pointer('pointerup', { clientX: 2, clientY: 2 }))
|
||||
|
||||
const click = new MouseEvent('click', { bubbles: true, cancelable: true })
|
||||
window.dispatchEvent(click)
|
||||
expect(click.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('does not marquee or clear selection when the container has no cards', async () => {
|
||||
const setSelectedIds = vi.fn()
|
||||
const Harness = defineComponent({
|
||||
setup() {
|
||||
const containerRef = ref<HTMLElement>()
|
||||
useAssetGridSelection({
|
||||
marqueeContainerRef: containerRef,
|
||||
hoverTargetRef: containerRef,
|
||||
getAssets: () => assets,
|
||||
getSelectedIds: () => ['a'],
|
||||
setSelectedIds,
|
||||
selectAll: vi.fn()
|
||||
})
|
||||
return { containerRef }
|
||||
},
|
||||
template: `
|
||||
<div ref="containerRef" data-testid="list">
|
||||
<div data-testid="row">a.png</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
render(Harness)
|
||||
await nextTick()
|
||||
|
||||
screen
|
||||
.getByTestId('list')
|
||||
.dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 110, clientY: 50 })
|
||||
)
|
||||
|
||||
expect(setSelectedIds).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not start a marquee when disabled (e.g. list view)', async () => {
|
||||
const setSelectedIds = vi.fn()
|
||||
const Harness = defineComponent({
|
||||
setup() {
|
||||
const containerRef = ref<HTMLElement>()
|
||||
useAssetGridSelection({
|
||||
marqueeContainerRef: containerRef,
|
||||
hoverTargetRef: containerRef,
|
||||
getAssets: () => assets,
|
||||
getSelectedIds: () => [],
|
||||
setSelectedIds,
|
||||
selectAll: vi.fn(),
|
||||
isEnabled: () => false
|
||||
})
|
||||
return { containerRef }
|
||||
},
|
||||
template: `
|
||||
<div ref="containerRef" data-testid="disabled-grid">
|
||||
<div data-asset-id="a"></div>
|
||||
<div data-asset-id="b"></div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
render(Harness)
|
||||
await nextTick()
|
||||
|
||||
screen
|
||||
.getByTestId('disabled-grid')
|
||||
.dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 110, clientY: 50 })
|
||||
)
|
||||
|
||||
expect(setSelectedIds).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('ignores a reentrant pointer-down and does not leave text selection blocked', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 5, clientY: 5 }))
|
||||
window.dispatchEvent(pointer('pointerup', { clientX: 5, clientY: 5 }))
|
||||
|
||||
const selection = new Event('selectstart', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
})
|
||||
grid().dispatchEvent(selection)
|
||||
expect(selection.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('captures the pointer once a marquee drag starts, not on press', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
const capture = vi.spyOn(grid(), 'setPointerCapture')
|
||||
|
||||
card('a').dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 5, clientY: 5 })
|
||||
)
|
||||
expect(capture).not.toHaveBeenCalled()
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
expect(capture).not.toHaveBeenCalled()
|
||||
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 110, clientY: 50 })
|
||||
)
|
||||
expect(capture).toHaveBeenCalledWith(1)
|
||||
})
|
||||
|
||||
it('does not capture the pointer on a Ctrl/Cmd-click of a card', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
const capture = vi.spyOn(grid(), 'setPointerCapture')
|
||||
|
||||
card('a').dispatchEvent(
|
||||
pointer('pointerdown', { clientX: 5, clientY: 5, ctrlKey: true })
|
||||
)
|
||||
window.dispatchEvent(pointer('pointerup', { clientX: 5, clientY: 5 }))
|
||||
|
||||
expect(capture).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('still tracks a marquee when setPointerCapture throws', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
vi.spyOn(grid(), 'setPointerCapture').mockImplementation(() => {
|
||||
throw new Error('stale pointer id')
|
||||
})
|
||||
|
||||
grid().dispatchEvent(pointer('pointerdown', { clientX: 0, clientY: 0 }))
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 110, clientY: 50 })
|
||||
)
|
||||
expect(callbacks.setSelectedIds).toHaveBeenLastCalledWith(
|
||||
['a', 'b'],
|
||||
assets
|
||||
)
|
||||
|
||||
window.dispatchEvent(pointer('pointerup', { clientX: 110, clientY: 50 }))
|
||||
await nextTick()
|
||||
expect(screen.queryByTestId('marquee')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ctrl/cmd + A', () => {
|
||||
function pressSelectAll(init: KeyboardEventInit = {}) {
|
||||
const event = new KeyboardEvent('keydown', {
|
||||
key: 'a',
|
||||
ctrlKey: true,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
...init
|
||||
})
|
||||
window.dispatchEvent(event)
|
||||
return event
|
||||
}
|
||||
|
||||
it('selects all visible assets and blocks the event when hovered', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
const event = pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).toHaveBeenCalledWith(assets)
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
})
|
||||
|
||||
it('selects all with the Cmd/Meta key while hovered', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
pressSelectAll({ ctrlKey: false, metaKey: true })
|
||||
|
||||
expect(callbacks.selectAll).toHaveBeenCalledWith(assets)
|
||||
})
|
||||
|
||||
it('does nothing when the panel is not hovered', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('still selects all when hover desyncs but the pointer stays inside the panel', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
vi.spyOn(panel(), 'getBoundingClientRect').mockReturnValue(
|
||||
fromPartial<DOMRect>({
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 500,
|
||||
bottom: 500,
|
||||
width: 500,
|
||||
height: 500
|
||||
})
|
||||
)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 100, clientY: 100 })
|
||||
)
|
||||
// The selection bar under the cursor unmounts on "deselect all", which
|
||||
// latches useElementHover false while the pointer is still inside.
|
||||
panel().dispatchEvent(new MouseEvent('mouseleave'))
|
||||
|
||||
const event = pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).toHaveBeenCalledWith(assets)
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
})
|
||||
|
||||
it('does not select all when the live pointer is outside the panel rect', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
vi.spyOn(panel(), 'getBoundingClientRect').mockReturnValue(
|
||||
fromPartial<DOMRect>({
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 500,
|
||||
bottom: 500,
|
||||
width: 500,
|
||||
height: 500
|
||||
})
|
||||
)
|
||||
|
||||
window.dispatchEvent(
|
||||
pointer('pointermove', { clientX: 900, clientY: 900 })
|
||||
)
|
||||
panel().dispatchEvent(new MouseEvent('mouseleave'))
|
||||
|
||||
const event = pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).not.toHaveBeenCalled()
|
||||
expect(event.defaultPrevented).toBe(false)
|
||||
})
|
||||
|
||||
it('ignores other keys and the unmodified A while hovered', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
pressSelectAll({ ctrlKey: false })
|
||||
pressSelectAll({ key: 'b' })
|
||||
|
||||
expect(callbacks.selectAll).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not hijack select-all while typing in a field', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
screen.getByTestId<HTMLInputElement>('search').focus()
|
||||
pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not hijack select-all while focused in a textarea', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
screen.getByTestId<HTMLTextAreaElement>('textarea').focus()
|
||||
pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not hijack select-all while focused in a contenteditable element', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
screen.getByTestId('editable').focus()
|
||||
pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not hijack select-all while an aria-modal dialog is open', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
const dialog = document.createElement('div')
|
||||
dialog.setAttribute('role', 'dialog')
|
||||
dialog.setAttribute('aria-modal', 'true')
|
||||
document.body.appendChild(dialog)
|
||||
|
||||
const event = pressSelectAll()
|
||||
|
||||
expect(callbacks.selectAll).not.toHaveBeenCalled()
|
||||
expect(event.defaultPrevented).toBe(false)
|
||||
|
||||
dialog.remove()
|
||||
})
|
||||
|
||||
it('stops the select-all keystroke from reaching other handlers when hovered', async () => {
|
||||
const callbacks = createCallbacks()
|
||||
await renderHarness(callbacks)
|
||||
const downstream = vi.fn()
|
||||
window.addEventListener('keydown', downstream)
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseenter'))
|
||||
pressSelectAll()
|
||||
expect(callbacks.selectAll).toHaveBeenCalledTimes(1)
|
||||
expect(downstream).not.toHaveBeenCalled()
|
||||
|
||||
panel().dispatchEvent(new MouseEvent('mouseleave'))
|
||||
pressSelectAll()
|
||||
expect(callbacks.selectAll).toHaveBeenCalledTimes(1)
|
||||
expect(downstream).toHaveBeenCalledTimes(1)
|
||||
|
||||
window.removeEventListener('keydown', downstream)
|
||||
})
|
||||
})
|
||||
})
|
||||
250
src/platform/assets/composables/useAssetGridSelection.ts
Normal file
250
src/platform/assets/composables/useAssetGridSelection.ts
Normal file
@@ -0,0 +1,250 @@
|
||||
import { useElementHover, useEventListener } from '@vueuse/core'
|
||||
import type { Ref } from 'vue'
|
||||
import { computed, onScopeDispose, ref } from 'vue'
|
||||
|
||||
import type { AssetItem } from '@/platform/assets/schemas/assetSchema'
|
||||
import {
|
||||
normalizeMarqueeRect,
|
||||
selectMarqueeIds
|
||||
} from '@/platform/assets/utils/marqueeSelectionUtil'
|
||||
import { clipRectToBounds } from '@/utils/mathUtil'
|
||||
import type { RectEdges } from '@/utils/mathUtil'
|
||||
|
||||
const DRAG_THRESHOLD_PX = 4
|
||||
const CARD_SELECTOR = '[data-asset-id]'
|
||||
const INTERACTIVE_SELECTOR =
|
||||
'button, input, textarea, select, a[href], [role="slider"], [role="tab"], [contenteditable]'
|
||||
|
||||
interface AssetGridSelectionOptions {
|
||||
marqueeContainerRef: Ref<HTMLElement | undefined>
|
||||
hoverTargetRef: Ref<HTMLElement | undefined>
|
||||
getAssets: () => AssetItem[]
|
||||
getSelectedIds: () => string[]
|
||||
setSelectedIds: (ids: string[], allAssets: AssetItem[]) => void
|
||||
selectAll: (assets: AssetItem[]) => void
|
||||
isEnabled?: () => boolean
|
||||
}
|
||||
|
||||
function isTextEntryTarget(element: Element | null): boolean {
|
||||
return (
|
||||
element instanceof HTMLInputElement ||
|
||||
element instanceof HTMLTextAreaElement ||
|
||||
(element instanceof HTMLElement && element.isContentEditable)
|
||||
)
|
||||
}
|
||||
|
||||
export function useAssetGridSelection(options: AssetGridSelectionOptions) {
|
||||
const {
|
||||
marqueeContainerRef,
|
||||
hoverTargetRef,
|
||||
getAssets,
|
||||
getSelectedIds,
|
||||
setSelectedIds,
|
||||
selectAll,
|
||||
isEnabled = () => true
|
||||
} = options
|
||||
|
||||
const marqueeRect = ref<RectEdges | null>(null)
|
||||
const isHoveringPanel = useElementHover(hoverTargetRef)
|
||||
|
||||
let startX = 0
|
||||
let startY = 0
|
||||
let pointerId = 0
|
||||
let baseIds: string[] = []
|
||||
let isSubtractive = false
|
||||
let isTracking = false
|
||||
let isDragging = false
|
||||
let suppressNextClick = false
|
||||
let suppressClickResetTimeout: ReturnType<typeof setTimeout> | null = null
|
||||
let dragCards: { id: string; rect: DOMRect }[] = []
|
||||
let dragBounds: DOMRect | null = null
|
||||
let pointerClientX = 0
|
||||
let pointerClientY = 0
|
||||
let hasPointerSample = false
|
||||
|
||||
function collectCards(container: HTMLElement) {
|
||||
return [...container.querySelectorAll<HTMLElement>(CARD_SELECTOR)].flatMap(
|
||||
(el) => {
|
||||
const id = el.dataset.assetId
|
||||
return id ? [{ id, rect: el.getBoundingClientRect() }] : []
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function snapshotDrag() {
|
||||
const container = marqueeContainerRef.value
|
||||
if (!container) return
|
||||
dragCards = collectCards(container)
|
||||
dragBounds = container.getBoundingClientRect()
|
||||
}
|
||||
|
||||
function applyMarquee(clientX: number, clientY: number) {
|
||||
if (!dragBounds) return
|
||||
const rect = clipRectToBounds(
|
||||
normalizeMarqueeRect(
|
||||
{ x: startX, y: startY },
|
||||
{ x: clientX, y: clientY }
|
||||
),
|
||||
dragBounds
|
||||
)
|
||||
marqueeRect.value = rect
|
||||
setSelectedIds(
|
||||
[...selectMarqueeIds(dragCards, rect, baseIds, isSubtractive)],
|
||||
getAssets()
|
||||
)
|
||||
}
|
||||
|
||||
function onPointerMove(e: PointerEvent) {
|
||||
pointerClientX = e.clientX
|
||||
pointerClientY = e.clientY
|
||||
hasPointerSample = true
|
||||
if (!isTracking) return
|
||||
if (
|
||||
!isDragging &&
|
||||
Math.hypot(e.clientX - startX, e.clientY - startY) < DRAG_THRESHOLD_PX
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (!isDragging) {
|
||||
isDragging = true
|
||||
snapshotDrag()
|
||||
capturePointer()
|
||||
}
|
||||
applyMarquee(e.clientX, e.clientY)
|
||||
}
|
||||
|
||||
function capturePointer() {
|
||||
try {
|
||||
marqueeContainerRef.value?.setPointerCapture(pointerId)
|
||||
} catch {
|
||||
// Stale/invalid pointerId: window listeners still end the drag.
|
||||
}
|
||||
}
|
||||
|
||||
function endDrag() {
|
||||
if (!isTracking) return
|
||||
isTracking = false
|
||||
marqueeRect.value = null
|
||||
dragCards = []
|
||||
dragBounds = null
|
||||
if (isDragging) scheduleSuppressNextClick()
|
||||
isDragging = false
|
||||
}
|
||||
|
||||
function scheduleSuppressNextClick() {
|
||||
suppressNextClick = true
|
||||
clearSuppressTimer()
|
||||
suppressClickResetTimeout = setTimeout(() => {
|
||||
suppressNextClick = false
|
||||
suppressClickResetTimeout = null
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function clearSuppressTimer() {
|
||||
if (suppressClickResetTimeout !== null) {
|
||||
clearTimeout(suppressClickResetTimeout)
|
||||
suppressClickResetTimeout = null
|
||||
}
|
||||
}
|
||||
|
||||
function preventDragStart(e: Event) {
|
||||
if (isTracking) e.preventDefault()
|
||||
}
|
||||
|
||||
function preventTextSelection(e: Event) {
|
||||
if (!isTracking) return
|
||||
const container = marqueeContainerRef.value
|
||||
if (container && e.target instanceof Node && container.contains(e.target)) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
function onPointerDown(e: PointerEvent) {
|
||||
if (e.button !== 0) return
|
||||
if (isTracking) return
|
||||
if (!isEnabled()) return
|
||||
suppressNextClick = false
|
||||
clearSuppressTimer()
|
||||
const container = marqueeContainerRef.value
|
||||
if (!container) return
|
||||
if (!container.querySelector(CARD_SELECTOR)) return
|
||||
const target = e.target
|
||||
if (!(target instanceof HTMLElement)) return
|
||||
if (target.closest(INTERACTIVE_SELECTOR)) return
|
||||
|
||||
const onCard = target.closest(CARD_SELECTOR)
|
||||
if (onCard && !e.ctrlKey && !e.metaKey) return
|
||||
|
||||
startX = e.clientX
|
||||
startY = e.clientY
|
||||
pointerId = e.pointerId
|
||||
baseIds = e.shiftKey || e.ctrlKey || e.metaKey ? getSelectedIds() : []
|
||||
isSubtractive = (e.ctrlKey || e.metaKey) && e.shiftKey
|
||||
isDragging = false
|
||||
isTracking = true
|
||||
}
|
||||
|
||||
function onClickCapture(e: MouseEvent) {
|
||||
if (!suppressNextClick) return
|
||||
suppressNextClick = false
|
||||
clearSuppressTimer()
|
||||
e.stopImmediatePropagation()
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
// useElementHover latches stale-false when an overlay under the cursor (the
|
||||
// selection bar) unmounts on "deselect all"; recheck the live pointer against
|
||||
// the panel rect so Ctrl/Cmd+A still resolves against the panel it is over.
|
||||
function isPointerInsidePanel(): boolean {
|
||||
const el = hoverTargetRef.value
|
||||
if (!el || !hasPointerSample) return false
|
||||
const { left, top, right, bottom } = el.getBoundingClientRect()
|
||||
return (
|
||||
pointerClientX >= left &&
|
||||
pointerClientX <= right &&
|
||||
pointerClientY >= top &&
|
||||
pointerClientY <= bottom
|
||||
)
|
||||
}
|
||||
|
||||
function onKeydown(e: KeyboardEvent) {
|
||||
if (!(e.ctrlKey || e.metaKey) || (e.key !== 'a' && e.key !== 'A')) return
|
||||
if (
|
||||
!(isHoveringPanel.value || isPointerInsidePanel()) ||
|
||||
isTextEntryTarget(document.activeElement) ||
|
||||
document.querySelector('[role="dialog"][aria-modal="true"]')
|
||||
) {
|
||||
return
|
||||
}
|
||||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
selectAll(getAssets())
|
||||
}
|
||||
|
||||
useEventListener(marqueeContainerRef, 'pointerdown', onPointerDown)
|
||||
useEventListener(marqueeContainerRef, 'dragstart', preventDragStart, {
|
||||
capture: true
|
||||
})
|
||||
useEventListener(window, 'pointermove', onPointerMove)
|
||||
useEventListener(window, ['pointerup', 'pointercancel', 'dragend'], endDrag)
|
||||
useEventListener(window, 'click', onClickCapture, { capture: true })
|
||||
useEventListener(window, 'keydown', onKeydown, { capture: true })
|
||||
useEventListener(window, 'selectstart', preventTextSelection, {
|
||||
capture: true
|
||||
})
|
||||
|
||||
onScopeDispose(clearSuppressTimer)
|
||||
|
||||
const marqueeStyle = computed(() => {
|
||||
const rect = marqueeRect.value
|
||||
if (!rect) return null
|
||||
return {
|
||||
left: `${rect.left}px`,
|
||||
top: `${rect.top}px`,
|
||||
width: `${rect.right - rect.left}px`,
|
||||
height: `${rect.bottom - rect.top}px`
|
||||
}
|
||||
})
|
||||
|
||||
return { marqueeStyle }
|
||||
}
|
||||
@@ -248,6 +248,36 @@ describe('useAssetSelection', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('setSelectedIds', () => {
|
||||
it('replaces selection and anchors on the last selected asset', () => {
|
||||
const selection = useAssetSelection()
|
||||
const store = useAssetSelectionStore()
|
||||
const assets = createMockAssets(5)
|
||||
|
||||
selection.setSelectedIds(['asset-1', 'asset-3'], assets)
|
||||
|
||||
expect(Array.from(store.selectedAssetIds).sort()).toEqual([
|
||||
'asset-1',
|
||||
'asset-3'
|
||||
])
|
||||
expect(store.lastSelectedIndex).toBe(3)
|
||||
expect(store.lastSelectedAssetId).toBe('asset-3')
|
||||
})
|
||||
|
||||
it('clears the anchor when the selection is empty', () => {
|
||||
const selection = useAssetSelection()
|
||||
const store = useAssetSelectionStore()
|
||||
const assets = createMockAssets(3)
|
||||
store.setLastSelectedIndex(2)
|
||||
store.setLastSelectedAssetId('asset-2')
|
||||
|
||||
selection.setSelectedIds([], assets)
|
||||
|
||||
expect(store.lastSelectedIndex).toBe(-1)
|
||||
expect(store.lastSelectedAssetId).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('clearSelection', () => {
|
||||
it('clears all selections', () => {
|
||||
const { handleAssetClick, clearSelection, selectedCount } =
|
||||
|
||||
@@ -101,6 +101,19 @@ export function useAssetSelection() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the selection (e.g. from a marquee) and keep the shift-range anchor
|
||||
* on the last selected asset, the same way selectAll maintains it.
|
||||
*/
|
||||
function setSelectedIds(ids: string[], allAssets: AssetItem[]) {
|
||||
selectionStore.setSelection(ids)
|
||||
const selected = new Set(ids)
|
||||
const anchorIndex = allAssets.findLastIndex((asset) =>
|
||||
selected.has(asset.id)
|
||||
)
|
||||
setAnchor(anchorIndex, anchorIndex >= 0 ? allAssets[anchorIndex].id : null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual asset objects for selected IDs
|
||||
*/
|
||||
@@ -182,6 +195,7 @@ export function useAssetSelection() {
|
||||
// Selection actions
|
||||
handleAssetClick,
|
||||
selectAll,
|
||||
setSelectedIds,
|
||||
clearSelection: () => selectionStore.clearSelection(),
|
||||
getSelectedAssets,
|
||||
reconcileSelection,
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import * as fc from 'fast-check'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { MarqueeCard } from './marqueeSelectionUtil'
|
||||
import { normalizeMarqueeRect, selectMarqueeIds } from './marqueeSelectionUtil'
|
||||
|
||||
const ID_POOL = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] as const
|
||||
|
||||
const arbPoint = fc.record({
|
||||
x: fc.integer({ min: -100, max: 100 }),
|
||||
y: fc.integer({ min: -100, max: 100 })
|
||||
})
|
||||
|
||||
const arbRect = fc
|
||||
.tuple(arbPoint, arbPoint)
|
||||
.map(([start, end]) => normalizeMarqueeRect(start, end))
|
||||
|
||||
const arbCards: fc.Arbitrary<MarqueeCard[]> = fc.uniqueArray(
|
||||
fc.record({ id: fc.constantFrom(...ID_POOL), rect: arbRect }),
|
||||
{ selector: (card) => card.id, maxLength: ID_POOL.length }
|
||||
)
|
||||
|
||||
const arbBaseIds = fc.uniqueArray(fc.constantFrom(...ID_POOL), {
|
||||
maxLength: ID_POOL.length
|
||||
})
|
||||
|
||||
describe('marqueeSelectionUtil properties', () => {
|
||||
it('additive result is the union of the base and the covered ids', () => {
|
||||
fc.assert(
|
||||
fc.property(arbCards, arbRect, arbBaseIds, (cards, marquee, base) => {
|
||||
const covered = selectMarqueeIds(cards, marquee)
|
||||
const result = selectMarqueeIds(cards, marquee, base)
|
||||
expect([...result].sort()).toEqual(
|
||||
[...new Set([...base, ...covered])].sort()
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it('subtractive result is the base minus the covered ids', () => {
|
||||
fc.assert(
|
||||
fc.property(arbCards, arbRect, arbBaseIds, (cards, marquee, base) => {
|
||||
const covered = selectMarqueeIds(cards, marquee)
|
||||
const result = selectMarqueeIds(cards, marquee, base, true)
|
||||
expect([...result].sort()).toEqual(
|
||||
base.filter((id) => !covered.has(id)).sort()
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it('subtractive mode preserves the base order of surviving ids', () => {
|
||||
fc.assert(
|
||||
fc.property(arbCards, arbRect, arbBaseIds, (cards, marquee, base) => {
|
||||
const covered = selectMarqueeIds(cards, marquee)
|
||||
const result = selectMarqueeIds(cards, marquee, base, true)
|
||||
expect([...result]).toEqual(base.filter((id) => !covered.has(id)))
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it('never mutates baseIds in either mode', () => {
|
||||
fc.assert(
|
||||
fc.property(
|
||||
arbCards,
|
||||
arbRect,
|
||||
arbBaseIds,
|
||||
fc.boolean(),
|
||||
(cards, marquee, base, subtract) => {
|
||||
const original = [...base]
|
||||
selectMarqueeIds(cards, marquee, base, subtract)
|
||||
expect(base).toEqual(original)
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('normalizeMarqueeRect always yields ordered edges containing both points', () => {
|
||||
fc.assert(
|
||||
fc.property(arbPoint, arbPoint, (start, end) => {
|
||||
const rect = normalizeMarqueeRect(start, end)
|
||||
expect(rect.left).toBeLessThanOrEqual(rect.right)
|
||||
expect(rect.top).toBeLessThanOrEqual(rect.bottom)
|
||||
for (const point of [start, end]) {
|
||||
expect(point.x).toBeGreaterThanOrEqual(rect.left)
|
||||
expect(point.x).toBeLessThanOrEqual(rect.right)
|
||||
expect(point.y).toBeGreaterThanOrEqual(rect.top)
|
||||
expect(point.y).toBeLessThanOrEqual(rect.bottom)
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
93
src/platform/assets/utils/marqueeSelectionUtil.test.ts
Normal file
93
src/platform/assets/utils/marqueeSelectionUtil.test.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { RectEdges } from '@/utils/mathUtil'
|
||||
|
||||
import type { MarqueeCard } from './marqueeSelectionUtil'
|
||||
import { normalizeMarqueeRect, selectMarqueeIds } from './marqueeSelectionUtil'
|
||||
|
||||
const box = (
|
||||
left: number,
|
||||
top: number,
|
||||
right: number,
|
||||
bottom: number
|
||||
): RectEdges => ({
|
||||
left,
|
||||
top,
|
||||
right,
|
||||
bottom
|
||||
})
|
||||
|
||||
describe('normalizeMarqueeRect', () => {
|
||||
it('orders corners when dragging down-right', () => {
|
||||
expect(normalizeMarqueeRect({ x: 10, y: 20 }, { x: 50, y: 80 })).toEqual(
|
||||
box(10, 20, 50, 80)
|
||||
)
|
||||
})
|
||||
|
||||
it('orders corners when dragging up-left', () => {
|
||||
expect(normalizeMarqueeRect({ x: 50, y: 80 }, { x: 10, y: 20 })).toEqual(
|
||||
box(10, 20, 50, 80)
|
||||
)
|
||||
})
|
||||
|
||||
it('orders corners when dragging across axes', () => {
|
||||
expect(normalizeMarqueeRect({ x: 50, y: 20 }, { x: 10, y: 80 })).toEqual(
|
||||
box(10, 20, 50, 80)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('selectMarqueeIds', () => {
|
||||
const cards: MarqueeCard[] = [
|
||||
{ id: 'a', rect: box(0, 0, 10, 10) },
|
||||
{ id: 'b', rect: box(20, 0, 30, 10) },
|
||||
{ id: 'c', rect: box(40, 0, 50, 10) }
|
||||
]
|
||||
|
||||
it('selects only intersecting cards when base is empty (replace)', () => {
|
||||
const result = selectMarqueeIds(cards, box(15, 0, 35, 10))
|
||||
expect([...result]).toEqual(['b'])
|
||||
})
|
||||
|
||||
it('unions intersecting cards with the base selection (additive)', () => {
|
||||
const result = selectMarqueeIds(cards, box(35, 0, 55, 10), ['a'])
|
||||
expect([...result].sort()).toEqual(['a', 'c'])
|
||||
})
|
||||
|
||||
it('removes intersecting cards from the base selection (subtractive)', () => {
|
||||
const result = selectMarqueeIds(cards, box(15, 0, 35, 10), ['a', 'b'], true)
|
||||
expect([...result]).toEqual(['a'])
|
||||
})
|
||||
|
||||
it('returns a copy of the base when nothing intersects', () => {
|
||||
const base = new Set(['a'])
|
||||
const result = selectMarqueeIds(cards, box(100, 100, 110, 110), base)
|
||||
expect([...result]).toEqual(['a'])
|
||||
expect(result).not.toBe(base)
|
||||
})
|
||||
|
||||
it('does not mutate the provided base set', () => {
|
||||
const base = new Set(['a'])
|
||||
selectMarqueeIds(cards, box(15, 0, 35, 10), base)
|
||||
expect([...base]).toEqual(['a'])
|
||||
})
|
||||
|
||||
it('includes a card whose edge merely touches the marquee', () => {
|
||||
const touching = [{ id: 'edge', rect: box(0, 0, 10, 10) }]
|
||||
expect([...selectMarqueeIds(touching, box(10, 0, 20, 10))]).toEqual([
|
||||
'edge'
|
||||
])
|
||||
})
|
||||
|
||||
it('includes a card that contains the marquee and vice versa', () => {
|
||||
const around = [{ id: 'around', rect: box(40, 40, 60, 60) }]
|
||||
expect([...selectMarqueeIds(around, box(0, 0, 100, 100))]).toEqual([
|
||||
'around'
|
||||
])
|
||||
})
|
||||
|
||||
it('excludes a card separated on a single axis', () => {
|
||||
const below = [{ id: 'below', rect: box(0, 20, 10, 30) }]
|
||||
expect([...selectMarqueeIds(below, box(0, 0, 10, 10))]).toEqual([])
|
||||
})
|
||||
})
|
||||
48
src/platform/assets/utils/marqueeSelectionUtil.ts
Normal file
48
src/platform/assets/utils/marqueeSelectionUtil.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { RectEdges } from '@/utils/mathUtil'
|
||||
|
||||
export interface MarqueeCard {
|
||||
id: string
|
||||
rect: RectEdges
|
||||
}
|
||||
|
||||
export function normalizeMarqueeRect(
|
||||
start: { x: number; y: number },
|
||||
end: { x: number; y: number }
|
||||
): RectEdges {
|
||||
return {
|
||||
left: Math.min(start.x, end.x),
|
||||
top: Math.min(start.y, end.y),
|
||||
right: Math.max(start.x, end.x),
|
||||
bottom: Math.max(start.y, end.y)
|
||||
}
|
||||
}
|
||||
|
||||
function rectsIntersect(a: RectEdges, b: RectEdges): boolean {
|
||||
return !(
|
||||
a.right < b.left ||
|
||||
a.left > b.right ||
|
||||
a.bottom < b.top ||
|
||||
a.top > b.bottom
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the asset ids a marquee covers, starting from `baseIds` (the selection
|
||||
* to preserve when a modifier makes the drag additive). With `subtract`, covered
|
||||
* ids are removed from `baseIds` instead of added. A fresh Set is returned;
|
||||
* `baseIds` is never mutated.
|
||||
*/
|
||||
export function selectMarqueeIds(
|
||||
cards: readonly MarqueeCard[],
|
||||
marquee: RectEdges,
|
||||
baseIds: Iterable<string> = [],
|
||||
subtract = false
|
||||
): Set<string> {
|
||||
const result = new Set(baseIds)
|
||||
for (const { id, rect } of cards) {
|
||||
if (!rectsIntersect(rect, marquee)) continue
|
||||
if (subtract) result.delete(id)
|
||||
else result.add(id)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -8,10 +8,19 @@ const mockDialogService = {
|
||||
showTopUpCreditsDialog: vi.fn()
|
||||
}
|
||||
|
||||
const mockBilling = {
|
||||
fetchStatus: vi.fn(),
|
||||
fetchBalance: vi.fn()
|
||||
}
|
||||
|
||||
vi.mock('@/services/dialogService', () => ({
|
||||
useDialogService: vi.fn(() => mockDialogService)
|
||||
}))
|
||||
|
||||
vi.mock('@/composables/billing/useBillingContext', () => ({
|
||||
useBillingContext: vi.fn(() => mockBilling)
|
||||
}))
|
||||
|
||||
describe('useAccountPreconditionDialog', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
@@ -55,4 +64,18 @@ describe('useAccountPreconditionDialog', () => {
|
||||
mockDialogService.showSubscriptionRequiredDialog
|
||||
).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('refreshes the billing snapshot on a credit precondition so exhausted-state surfaces converge', () => {
|
||||
useAccountPreconditionDialog().open('credits')
|
||||
|
||||
expect(mockBilling.fetchStatus).toHaveBeenCalledTimes(1)
|
||||
expect(mockBilling.fetchBalance).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('does not touch billing state for non-credit preconditions', () => {
|
||||
useAccountPreconditionDialog().open('subscription')
|
||||
|
||||
expect(mockBilling.fetchStatus).not.toHaveBeenCalled()
|
||||
expect(mockBilling.fetchBalance).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useBillingContext } from '@/composables/billing/useBillingContext'
|
||||
import type { AccountPrecondition } from '@/platform/errorCatalog/accountPreconditionRouting'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
|
||||
@@ -28,11 +29,19 @@ export function useAccountPreconditionDialog() {
|
||||
reason: 'subscription_required'
|
||||
})
|
||||
return
|
||||
case 'credits':
|
||||
case 'credits': {
|
||||
// The server just declared the balance exhausted; there is no push or
|
||||
// polling for billing state, so refresh it here to converge
|
||||
// hasFunds-keyed surfaces such as the credits-exhausted banner. The
|
||||
// refresh is best-effort: allSettled keeps a flaky billing API from
|
||||
// surfacing as unhandled rejections.
|
||||
const { fetchStatus, fetchBalance } = useBillingContext()
|
||||
void Promise.allSettled([fetchStatus(), fetchBalance()])
|
||||
void dialogService.showTopUpCreditsDialog({
|
||||
isInsufficientCredits: true
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,21 @@ describe('useSubscriptionDialog', () => {
|
||||
expect(mockTrackSubscription).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('shows the read-only member dialog for out-of-credits too, not the pricing table', () => {
|
||||
mockShouldUseWorkspaceBilling.value = true
|
||||
mockIsInPersonalWorkspace.value = false
|
||||
mockCanManageSubscription.value = false
|
||||
const { showPricingTable } = useSubscriptionDialog()
|
||||
|
||||
showPricingTable({ reason: 'out_of_credits' })
|
||||
|
||||
expect(mockShowLayoutDialog).toHaveBeenCalledTimes(1)
|
||||
const props = mockShowLayoutDialog.mock.calls[0][0].props
|
||||
expect(props).toHaveProperty('onClose')
|
||||
expect(props).not.toHaveProperty('reason')
|
||||
expect(props).not.toHaveProperty('initialPlanMode')
|
||||
})
|
||||
|
||||
it('does not track on non-cloud', () => {
|
||||
mockIsCloud.value = false
|
||||
const { showPricingTable } = useSubscriptionDialog()
|
||||
|
||||
@@ -55,12 +55,12 @@ export const useSubscriptionDialog = () => {
|
||||
|
||||
// Members can't manage the workspace subscription, so a blocked run shows a
|
||||
// small read-only "ask your owner to reactivate" modal instead of the
|
||||
// pricing table. Out-of-credits still routes everyone to the credits flow.
|
||||
// pricing table — including out-of-credits, whose member recovery path is
|
||||
// also owner-only (FE-1246).
|
||||
if (
|
||||
shouldUseWorkspaceBilling.value &&
|
||||
!workspaceStore.isInPersonalWorkspace &&
|
||||
!permissions.value.canManageSubscription &&
|
||||
options?.reason !== 'out_of_credits'
|
||||
!permissions.value.canManageSubscription
|
||||
) {
|
||||
dialogService.showLayoutDialog({
|
||||
key: DIALOG_KEY,
|
||||
@@ -88,9 +88,9 @@ export const useSubscriptionDialog = () => {
|
||||
} as const
|
||||
|
||||
// Jun-5 model: a single unified pricing table (personal/team plan toggle on
|
||||
// one workspace) for workspaces on the consolidated billing flow. Replaces
|
||||
// the old personal-vs-team workspace fork. Personal workspaces still on the
|
||||
// legacy flow (consolidated billing disabled) get the legacy table.
|
||||
// one workspace) for workspaces on the workspace-scoped billing flow.
|
||||
// Replaces the old personal-vs-team workspace fork. Personal workspaces
|
||||
// still on the legacy flow (billing control disabled) get the legacy table.
|
||||
if (shouldUseWorkspaceBilling.value) {
|
||||
// Existing per-member (legacy) team subscribers keep the old tier-based
|
||||
// team table; the unified credit-slider table is for everyone else.
|
||||
|
||||
@@ -73,6 +73,33 @@ describe('resolveAccountPrecondition', () => {
|
||||
).toBe('credits')
|
||||
})
|
||||
|
||||
it('classifies the submit-time 402 body by its insufficient_credits type regardless of message', () => {
|
||||
expect(
|
||||
resolveAccountPrecondition({
|
||||
exceptionType: 'insufficient_credits',
|
||||
exceptionMessage: 'Workspace balance exhausted'
|
||||
})
|
||||
).toBe('credits')
|
||||
})
|
||||
|
||||
it('classifies the team submit-time 429 (PAYMENT_REQUIRED / insufficient credits) as a credits precondition', () => {
|
||||
expect(
|
||||
resolveAccountPrecondition({
|
||||
exceptionType: 'PAYMENT_REQUIRED',
|
||||
exceptionMessage: 'Insufficient credits to queue workflows'
|
||||
})
|
||||
).toBe('credits')
|
||||
})
|
||||
|
||||
it('keeps the team submit-time 429 for an inactive subscription on the subscription precondition', () => {
|
||||
expect(
|
||||
resolveAccountPrecondition({
|
||||
exceptionType: 'PAYMENT_REQUIRED',
|
||||
exceptionMessage: 'Subscription required to queue workflows'
|
||||
})
|
||||
).toBe('subscription')
|
||||
})
|
||||
|
||||
it('returns undefined for an ordinary workflow error', () => {
|
||||
expect(
|
||||
resolveAccountPrecondition({
|
||||
|
||||
@@ -33,7 +33,13 @@ const INSUFFICIENT_CREDITS_MESSAGES = new Set([
|
||||
'Payment Required: Please add credits to your account to use this node.'
|
||||
])
|
||||
const WORKSPACE_INSUFFICIENT_CREDITS_MESSAGES = new Set([
|
||||
'Payment Required: Please add credits to your workspace to continue.'
|
||||
// Execution-time (pre-GPU) WebSocket failure for a queued team job.
|
||||
'Payment Required: Please add credits to your workspace to continue.',
|
||||
// Submit-time 429 rejection for a team workspace out of credits
|
||||
// (checkTeamWorkspaceSubscription). It shares the PAYMENT_REQUIRED error type
|
||||
// with the subscription-required rejection, so it can only be told apart by
|
||||
// message.
|
||||
'Insufficient credits to queue workflows'
|
||||
])
|
||||
const SUBSCRIPTION_REQUIRED_MESSAGES = new Set([
|
||||
'Workspace has no active subscription. Please subscribe to a plan to continue.',
|
||||
@@ -243,8 +249,12 @@ const RUNTIME_MATCH_RULES: RuntimeMatchRule[] = [
|
||||
resolve: () => catalogMatch(WORKSPACE_INSUFFICIENT_CREDITS_CATALOG_ID)
|
||||
},
|
||||
{
|
||||
// 'insufficient_credits' is the error.type BE-2866 will emit on the
|
||||
// personal submit-time 402; the team submit path is a 429 matched by
|
||||
// message in WORKSPACE_INSUFFICIENT_CREDITS_MESSAGES above.
|
||||
matches: (info, message) =>
|
||||
info.exceptionType === 'InsufficientFundsError' ||
|
||||
info.exceptionType === 'insufficient_credits' ||
|
||||
INSUFFICIENT_CREDITS_MESSAGES.has(message),
|
||||
resolve: () => catalogMatch(INSUFFICIENT_CREDITS_CATALOG_ID)
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
cachedConsolidatedBillingEnabled,
|
||||
cachedBillingControlEnabled,
|
||||
cachedTeamWorkspacesEnabled,
|
||||
remoteConfig,
|
||||
remoteConfigState
|
||||
@@ -60,8 +60,8 @@ export async function refreshRemoteConfig(
|
||||
cachedTeamWorkspacesEnabled.value = Boolean(
|
||||
config.team_workspaces_enabled
|
||||
)
|
||||
cachedConsolidatedBillingEnabled.value = Boolean(
|
||||
config.consolidated_billing_enabled
|
||||
cachedBillingControlEnabled.value = Boolean(
|
||||
config.billing_control_enabled
|
||||
)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -60,7 +60,7 @@ export const cachedTeamWorkspacesEnabled = useStorage<boolean | undefined>(
|
||||
undefined
|
||||
)
|
||||
|
||||
export const cachedConsolidatedBillingEnabled = useStorage<boolean | undefined>(
|
||||
'consolidated_billing_enabled' satisfies `${ServerFeatureFlag.CONSOLIDATED_BILLING_ENABLED}`,
|
||||
export const cachedBillingControlEnabled = useStorage<boolean | undefined>(
|
||||
'billing_control_enabled' satisfies `${ServerFeatureFlag.BILLING_CONTROL_ENABLED}`,
|
||||
undefined
|
||||
)
|
||||
|
||||
@@ -115,7 +115,7 @@ export type RemoteConfig = {
|
||||
comfyhub_upload_enabled?: boolean
|
||||
comfyhub_profile_gate_enabled?: boolean
|
||||
unified_cloud_auth?: boolean
|
||||
consolidated_billing_enabled?: boolean
|
||||
billing_control_enabled?: boolean
|
||||
sentry_dsn?: string
|
||||
turnstile_sitekey?: string
|
||||
// Raw, unvalidated wire value (a server typo like 'enfroce' is possible).
|
||||
|
||||
@@ -779,7 +779,7 @@ export const CORE_SETTINGS: SettingParams[] = [
|
||||
tooltip:
|
||||
'When enabled, nodes are selected/deselected in real-time as you drag the selection rectangle, similar to other design tools.',
|
||||
type: 'boolean',
|
||||
defaultValue: false,
|
||||
defaultValue: true,
|
||||
versionAdded: '1.36.1'
|
||||
},
|
||||
{
|
||||
|
||||
183
src/platform/telemetry/hostUserIdSync.test.ts
Normal file
183
src/platform/telemetry/hostUserIdSync.test.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type * as VueModule from 'vue'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
type MockAuthStore = {
|
||||
isInitialized: boolean
|
||||
currentUser: { uid: string } | null
|
||||
}
|
||||
|
||||
const hoisted = vi.hoisted(() => ({
|
||||
authStore: null as unknown as MockAuthStore
|
||||
}))
|
||||
|
||||
vi.mock('@/stores/authStore', async () => {
|
||||
const { reactive } = await vi.importActual<typeof VueModule>('vue')
|
||||
hoisted.authStore = reactive<MockAuthStore>({
|
||||
isInitialized: false,
|
||||
currentUser: null
|
||||
})
|
||||
return { useAuthStore: () => hoisted.authStore }
|
||||
})
|
||||
|
||||
import { syncHostUserIdWithFirebaseAuth } from './hostUserIdSync'
|
||||
|
||||
const stopHandles: Array<() => void> = []
|
||||
|
||||
function installTelemetryBridge() {
|
||||
const reportFirebaseAuthState = vi.fn()
|
||||
window.__comfyDesktop2 = {
|
||||
isRemote: () => false,
|
||||
Telemetry: {
|
||||
capture: vi.fn(),
|
||||
reportFirebaseAuthState
|
||||
}
|
||||
}
|
||||
return { reportFirebaseAuthState }
|
||||
}
|
||||
|
||||
function startSync(): void {
|
||||
const stop = syncHostUserIdWithFirebaseAuth()
|
||||
if (stop) stopHandles.push(stop)
|
||||
}
|
||||
|
||||
describe('host user ID sync', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
hoisted.authStore.isInitialized = false
|
||||
hoisted.authStore.currentUser = null
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
while (stopHandles.length) stopHandles.pop()?.()
|
||||
delete window.__comfyDesktop2
|
||||
})
|
||||
|
||||
it('waits for Firebase auth initialization before reporting a user', async () => {
|
||||
const { reportFirebaseAuthState } = installTelemetryBridge()
|
||||
startSync()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenCalledOnce()
|
||||
expect(reportFirebaseAuthState).toHaveBeenLastCalledWith({
|
||||
status: 'pending'
|
||||
})
|
||||
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-a' }
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenCalledOnce()
|
||||
|
||||
hoisted.authStore.isInitialized = true
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenLastCalledWith({
|
||||
status: 'signed_in',
|
||||
userId: 'firebase-user-a'
|
||||
})
|
||||
})
|
||||
|
||||
it('reports a restored Firebase session immediately', () => {
|
||||
const { reportFirebaseAuthState } = installTelemetryBridge()
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-a' }
|
||||
hoisted.authStore.isInitialized = true
|
||||
|
||||
startSync()
|
||||
|
||||
expect(reportFirebaseAuthState.mock.calls).toEqual([
|
||||
[{ status: 'pending' }],
|
||||
[{ status: 'signed_in', userId: 'firebase-user-a' }]
|
||||
])
|
||||
})
|
||||
|
||||
it('reports an initially signed-out Firebase session', () => {
|
||||
const { reportFirebaseAuthState } = installTelemetryBridge()
|
||||
hoisted.authStore.isInitialized = true
|
||||
|
||||
startSync()
|
||||
|
||||
expect(reportFirebaseAuthState.mock.calls).toEqual([
|
||||
[{ status: 'pending' }],
|
||||
[{ status: 'signed_out' }]
|
||||
])
|
||||
})
|
||||
|
||||
it('reports signed out when Firebase finishes initialization', async () => {
|
||||
const { reportFirebaseAuthState } = installTelemetryBridge()
|
||||
startSync()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenCalledOnce()
|
||||
|
||||
hoisted.authStore.isInitialized = true
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenLastCalledWith({
|
||||
status: 'signed_out'
|
||||
})
|
||||
})
|
||||
|
||||
it('reports account switches, logout, and subsequent login', async () => {
|
||||
const { reportFirebaseAuthState } = installTelemetryBridge()
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-a' }
|
||||
hoisted.authStore.isInitialized = true
|
||||
startSync()
|
||||
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-b' }
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenLastCalledWith({
|
||||
status: 'signed_in',
|
||||
userId: 'firebase-user-b'
|
||||
})
|
||||
|
||||
hoisted.authStore.currentUser = null
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenLastCalledWith({
|
||||
status: 'signed_out'
|
||||
})
|
||||
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-c' }
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState.mock.calls).toEqual([
|
||||
[{ status: 'pending' }],
|
||||
[{ status: 'signed_in', userId: 'firebase-user-a' }],
|
||||
[{ status: 'signed_in', userId: 'firebase-user-b' }],
|
||||
[{ status: 'signed_out' }],
|
||||
[{ status: 'signed_in', userId: 'firebase-user-c' }]
|
||||
])
|
||||
})
|
||||
|
||||
it('does not report again when Firebase replaces the user object with the same UID', async () => {
|
||||
const { reportFirebaseAuthState } = installTelemetryBridge()
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-a' }
|
||||
hoisted.authStore.isInitialized = true
|
||||
startSync()
|
||||
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-a' }
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState.mock.calls).toEqual([
|
||||
[{ status: 'pending' }],
|
||||
[{ status: 'signed_in', userId: 'firebase-user-a' }]
|
||||
])
|
||||
})
|
||||
|
||||
it('does not let a host reporting failure interrupt Firebase state sync', async () => {
|
||||
const { reportFirebaseAuthState } = installTelemetryBridge()
|
||||
reportFirebaseAuthState.mockImplementationOnce(() => {
|
||||
throw new Error('host unavailable')
|
||||
})
|
||||
|
||||
expect(() => startSync()).not.toThrow()
|
||||
|
||||
hoisted.authStore.currentUser = { uid: 'firebase-user-a' }
|
||||
hoisted.authStore.isInitialized = true
|
||||
await nextTick()
|
||||
|
||||
expect(reportFirebaseAuthState).toHaveBeenLastCalledWith({
|
||||
status: 'signed_in',
|
||||
userId: 'firebase-user-a'
|
||||
})
|
||||
})
|
||||
})
|
||||
49
src/platform/telemetry/hostUserIdSync.ts
Normal file
49
src/platform/telemetry/hostUserIdSync.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { watch } from 'vue'
|
||||
import type { WatchStopHandle } from 'vue'
|
||||
|
||||
import { useAuthStore } from '@/stores/authStore'
|
||||
|
||||
function safelyReportFirebaseAuthState(report: () => void): void {
|
||||
try {
|
||||
report()
|
||||
} catch {
|
||||
// A host bridge failure must not block renderer startup or Firebase auth.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep the Desktop main-process telemetry identity aligned with Firebase auth.
|
||||
* Must run after Pinia and VueFire are installed.
|
||||
*/
|
||||
export function syncHostUserIdWithFirebaseAuth(): WatchStopHandle | undefined {
|
||||
const telemetry = window.__comfyDesktop2?.Telemetry
|
||||
if (!telemetry) return
|
||||
|
||||
// Register this Cloud renderer before Firebase resolves. Desktop may host
|
||||
// multiple Cloud main frames whose isolated browser partitions have
|
||||
// different auth states, so main owns all cross-WebContents arbitration.
|
||||
safelyReportFirebaseAuthState(() =>
|
||||
telemetry.reportFirebaseAuthState?.({ status: 'pending' })
|
||||
)
|
||||
|
||||
const authStore = useAuthStore()
|
||||
|
||||
return watch(
|
||||
() =>
|
||||
authStore.isInitialized
|
||||
? (authStore.currentUser?.uid ?? null)
|
||||
: undefined,
|
||||
(userId) => {
|
||||
if (userId === undefined) return
|
||||
|
||||
safelyReportFirebaseAuthState(() =>
|
||||
telemetry.reportFirebaseAuthState?.(
|
||||
userId === null
|
||||
? { status: 'signed_out' }
|
||||
: { status: 'signed_in', userId }
|
||||
)
|
||||
)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
}
|
||||
@@ -1,26 +1,42 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const hoisted = vi.hoisted(() => {
|
||||
const analytics = {
|
||||
identify: vi.fn(),
|
||||
track: vi.fn(),
|
||||
identify: vi.fn().mockResolvedValue(undefined),
|
||||
page: vi.fn(),
|
||||
track: vi.fn().mockResolvedValue(undefined),
|
||||
reset: vi.fn(),
|
||||
register: vi.fn().mockResolvedValue(undefined)
|
||||
}
|
||||
let resolvedCb: ((user: { id: string }) => void) | undefined
|
||||
let logoutCb: (() => void) | undefined
|
||||
const resolvedUserInfo = { value: null as { id: string } | null }
|
||||
return {
|
||||
analytics,
|
||||
load: vi.fn(() => analytics),
|
||||
inAppPlugin: vi.fn(() => ({ name: 'Customer.io In-App Plugin' })),
|
||||
userEmail: { value: null as string | null },
|
||||
onUserResolved: vi.fn((cb: (user: { id: string }) => void) => {
|
||||
resolvedCb = cb
|
||||
if (resolvedUserInfo.value) cb(resolvedUserInfo.value)
|
||||
}),
|
||||
onUserLogout: vi.fn((cb: () => void) => {
|
||||
logoutCb = cb
|
||||
}),
|
||||
resolveUser: (id: string) => resolvedCb?.({ id }),
|
||||
logoutUser: () => logoutCb?.()
|
||||
resolvedUserInfo,
|
||||
resolveUser: (id: string) => {
|
||||
resolvedUserInfo.value = { id }
|
||||
resolvedCb?.({ id })
|
||||
},
|
||||
logoutUser: () => {
|
||||
resolvedUserInfo.value = null
|
||||
logoutCb?.()
|
||||
},
|
||||
resetCallbacks: () => {
|
||||
resolvedCb = undefined
|
||||
logoutCb = undefined
|
||||
resolvedUserInfo.value = null
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -31,6 +47,8 @@ vi.mock('@customerio/cdp-analytics-browser', () => ({
|
||||
|
||||
vi.mock('@/composables/auth/useCurrentUser', () => ({
|
||||
useCurrentUser: () => ({
|
||||
userEmail: hoisted.userEmail,
|
||||
resolvedUserInfo: hoisted.resolvedUserInfo,
|
||||
onUserResolved: hoisted.onUserResolved,
|
||||
onUserLogout: hoisted.onUserLogout
|
||||
})
|
||||
@@ -54,14 +72,32 @@ function createProvider(
|
||||
return new CustomerIoTelemetryProvider()
|
||||
}
|
||||
|
||||
function createDeferred() {
|
||||
let resolve = () => {}
|
||||
const promise = new Promise<void>((complete) => {
|
||||
resolve = complete
|
||||
})
|
||||
return { promise, resolve }
|
||||
}
|
||||
|
||||
describe('CustomerIoTelemetryProvider', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
hoisted.resetCallbacks()
|
||||
hoisted.load.mockReturnValue(hoisted.analytics)
|
||||
hoisted.analytics.identify.mockResolvedValue(undefined)
|
||||
hoisted.analytics.track.mockResolvedValue(undefined)
|
||||
hoisted.analytics.reset.mockReset().mockResolvedValue(undefined)
|
||||
hoisted.analytics.register.mockResolvedValue(undefined)
|
||||
hoisted.userEmail.value = null
|
||||
window.__CONFIG__ = {} as typeof window.__CONFIG__
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it('loads the client and registers the in-app plugin with the site id', async () => {
|
||||
createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
@@ -73,6 +109,89 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
expect(hoisted.analytics.register).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('reports the current page after registering the in-app plugin', async () => {
|
||||
const provider = createProvider()
|
||||
provider.trackPageView('workflow_editor', {
|
||||
path: 'https://cloud.comfy.org/'
|
||||
})
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
expect(hoisted.analytics.page).toHaveBeenCalledOnce()
|
||||
expect(hoisted.analytics.page).toHaveBeenCalledWith()
|
||||
expect(hoisted.analytics.register.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
hoisted.analytics.page.mock.invocationCallOrder[0]
|
||||
)
|
||||
})
|
||||
|
||||
it('queues page views until the in-app plugin is registered', async () => {
|
||||
let resolveRegistration: (() => void) | undefined
|
||||
const registration = new Promise<void>((resolve) => {
|
||||
resolveRegistration = resolve
|
||||
})
|
||||
hoisted.analytics.register.mockReturnValue(registration)
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackPageView('workflow_editor', {
|
||||
path: 'https://cloud.comfy.org/'
|
||||
})
|
||||
expect(hoisted.analytics.page).not.toHaveBeenCalled()
|
||||
|
||||
resolveRegistration?.()
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.page).toHaveBeenCalledOnce()
|
||||
)
|
||||
})
|
||||
|
||||
it('reports client-side route changes', async () => {
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
expect(hoisted.analytics.page).not.toHaveBeenCalled()
|
||||
|
||||
provider.trackPageView('workflow_editor', {
|
||||
path: 'https://cloud.comfy.org/'
|
||||
})
|
||||
|
||||
expect(hoisted.analytics.page).toHaveBeenCalledOnce()
|
||||
expect(hoisted.analytics.page).toHaveBeenCalledWith()
|
||||
})
|
||||
|
||||
it('continues tracking events and page views when the in-app plugin fails to register', async () => {
|
||||
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const registrationError = new Error('in-app setup failed')
|
||||
hoisted.analytics.register.mockRejectedValue(registrationError)
|
||||
const provider = createProvider()
|
||||
provider.trackWorkflowExecution()
|
||||
provider.trackPageView('workflow_editor', {
|
||||
path: 'https://cloud.comfy.org/'
|
||||
})
|
||||
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'execution_start',
|
||||
SOURCE
|
||||
)
|
||||
expect(hoisted.analytics.page).toHaveBeenCalledOnce()
|
||||
expect(consoleError).toHaveBeenCalledWith(
|
||||
'Failed to initialize Customer.io in-app plugin:',
|
||||
registrationError
|
||||
)
|
||||
|
||||
provider.trackAddApiCreditButtonClicked()
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'app:add_api_credit_button_clicked',
|
||||
SOURCE
|
||||
)
|
||||
)
|
||||
provider.trackPageView('settings', {
|
||||
path: 'https://cloud.comfy.org/settings'
|
||||
})
|
||||
expect(hoisted.analytics.page).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('does not initialize without a write key', async () => {
|
||||
const provider = createProvider({ customer_io: { site_id: SITE_ID } })
|
||||
await vi.dynamicImportSettled()
|
||||
@@ -89,13 +208,19 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
expect(hoisted.load).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('identifies the person by uid only on auth resolve', async () => {
|
||||
it('identifies the resolved user with uid and email traits', async () => {
|
||||
createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
hoisted.userEmail.value = 'user@example.com'
|
||||
hoisted.resolveUser('test-uid-7f3a9c')
|
||||
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledWith('test-uid-7f3a9c')
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledWith(
|
||||
'test-uid-7f3a9c',
|
||||
{ email: 'user@example.com' }
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('identifies with the configured user_id override without waiting for auth', async () => {
|
||||
@@ -108,8 +233,54 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
})
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledWith('forced-uid')
|
||||
expect(hoisted.onUserResolved).not.toHaveBeenCalled()
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledWith(
|
||||
'forced-uid',
|
||||
undefined
|
||||
)
|
||||
expect(hoisted.onUserResolved).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('identifies a restored session with the configured user id once', async () => {
|
||||
hoisted.userEmail.value = 'restored@example.com'
|
||||
hoisted.resolvedUserInfo.value = { id: 'resolved-uid' }
|
||||
|
||||
createProvider({
|
||||
customer_io: {
|
||||
write_key: WRITE_KEY,
|
||||
site_id: SITE_ID,
|
||||
user_id: 'forced-uid'
|
||||
}
|
||||
})
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledOnce()
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledWith('forced-uid', {
|
||||
email: 'restored@example.com'
|
||||
})
|
||||
})
|
||||
|
||||
it('re-identifies with the configured user id after logout and re-login', async () => {
|
||||
createProvider({
|
||||
customer_io: {
|
||||
write_key: WRITE_KEY,
|
||||
site_id: SITE_ID,
|
||||
user_id: 'forced-uid'
|
||||
}
|
||||
})
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
hoisted.logoutUser()
|
||||
hoisted.userEmail.value = 'returning@example.com'
|
||||
hoisted.resolveUser('resolved-uid')
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.identify).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'forced-uid',
|
||||
{ email: 'returning@example.com' }
|
||||
)
|
||||
)
|
||||
expect(hoisted.analytics.reset).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('identifies before flushing events buffered before the SDK loads', async () => {
|
||||
@@ -129,13 +300,99 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
expect(identifyOrder).toBeLessThan(trackOrder)
|
||||
})
|
||||
|
||||
it('restores the resolved user after flushing an older auth event', async () => {
|
||||
let activeUser: string | null = null
|
||||
const trackedUsers: Array<[string, string | null]> = []
|
||||
hoisted.analytics.identify.mockImplementation((userId: string) => {
|
||||
activeUser = userId
|
||||
return Promise.resolve()
|
||||
})
|
||||
hoisted.analytics.track.mockImplementation((event: string) => {
|
||||
trackedUsers.push([event, activeUser])
|
||||
return Promise.resolve()
|
||||
})
|
||||
hoisted.userEmail.value = 'current@example.com'
|
||||
hoisted.resolvedUserInfo.value = { id: 'current-uid' }
|
||||
const provider = createProvider()
|
||||
|
||||
provider.trackAuth({
|
||||
user_id: 'queued-uid',
|
||||
email: 'queued@example.com'
|
||||
})
|
||||
provider.trackWorkflowExecution()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.identify.mock.calls).toEqual([
|
||||
['current-uid', { email: 'current@example.com' }],
|
||||
['queued-uid', { email: 'queued@example.com' }],
|
||||
['current-uid', { email: 'current@example.com' }]
|
||||
])
|
||||
)
|
||||
expect(activeUser).toBe('current-uid')
|
||||
expect(trackedUsers).toEqual([
|
||||
['app:user_auth_completed', 'queued-uid'],
|
||||
['execution_start', 'current-uid']
|
||||
])
|
||||
})
|
||||
|
||||
it('resets identity after flushing auth for a signed-out user', async () => {
|
||||
let activeUser: string | null = null
|
||||
let trackedUser: string | null = null
|
||||
hoisted.analytics.identify.mockImplementation((userId: string) => {
|
||||
activeUser = userId
|
||||
return Promise.resolve()
|
||||
})
|
||||
hoisted.analytics.track.mockImplementation(() => {
|
||||
trackedUser = activeUser
|
||||
return Promise.resolve()
|
||||
})
|
||||
hoisted.analytics.reset.mockImplementation(() => {
|
||||
activeUser = null
|
||||
})
|
||||
const provider = createProvider()
|
||||
|
||||
provider.trackAuth({
|
||||
user_id: 'queued-uid',
|
||||
email: 'queued@example.com'
|
||||
})
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
await vi.waitFor(() => expect(hoisted.analytics.reset).toHaveBeenCalled())
|
||||
expect(trackedUser).toBe('queued-uid')
|
||||
expect(activeUser).toBeNull()
|
||||
})
|
||||
|
||||
it('resets on logout', async () => {
|
||||
createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
hoisted.logoutUser()
|
||||
|
||||
expect(hoisted.analytics.reset).toHaveBeenCalledOnce()
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.reset).toHaveBeenCalledOnce()
|
||||
)
|
||||
})
|
||||
|
||||
it('continues tracking after reset fails', async () => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
hoisted.analytics.reset.mockRejectedValueOnce(new Error('reset failed'))
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
hoisted.logoutUser()
|
||||
provider.trackWorkflowExecution()
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'execution_start',
|
||||
SOURCE
|
||||
)
|
||||
)
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'Failed to process Customer.io operation:',
|
||||
expect.any(Error)
|
||||
)
|
||||
})
|
||||
|
||||
const DIRECT_EVENTS: Array<{
|
||||
@@ -189,6 +446,7 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
invoke: (p) =>
|
||||
p.trackShareFlow({
|
||||
step: 'dialog_opened',
|
||||
share_id: 'share-1',
|
||||
view_mode: 'graph',
|
||||
is_app_mode: false
|
||||
}),
|
||||
@@ -209,10 +467,280 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
|
||||
invoke(provider)
|
||||
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(event, expected)
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(event, expected)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
it('awaits auth identification before tracking without raw identifiers', async () => {
|
||||
const identifyResult = createDeferred()
|
||||
hoisted.analytics.identify.mockReturnValueOnce(identifyResult.promise)
|
||||
const provider = createProvider()
|
||||
|
||||
provider.trackAuth({
|
||||
method: 'google',
|
||||
is_new_user: true,
|
||||
user_id: 'uid-1',
|
||||
email: 'person@example.com',
|
||||
share_id: 'share-1'
|
||||
})
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledWith('uid-1', {
|
||||
email: 'person@example.com'
|
||||
})
|
||||
expect(hoisted.analytics.track).not.toHaveBeenCalled()
|
||||
|
||||
identifyResult.resolve()
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'app:user_auth_completed',
|
||||
{
|
||||
...SOURCE,
|
||||
method: 'google',
|
||||
is_new_user: true,
|
||||
user_id: 'uid-1'
|
||||
}
|
||||
)
|
||||
)
|
||||
expect(hoisted.analytics.identify.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
hoisted.analytics.track.mock.invocationCallOrder[0]
|
||||
)
|
||||
})
|
||||
|
||||
it('reuses matching resolved-user identification for auth delivery', async () => {
|
||||
const identifyResult = createDeferred()
|
||||
hoisted.analytics.identify.mockReturnValueOnce(identifyResult.promise)
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
hoisted.userEmail.value = 'person@example.com'
|
||||
hoisted.resolveUser('uid-1')
|
||||
provider.trackAuth({
|
||||
user_id: 'uid-1',
|
||||
email: 'person@example.com'
|
||||
})
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledOnce()
|
||||
)
|
||||
expect(hoisted.analytics.track).not.toHaveBeenCalled()
|
||||
identifyResult.resolve()
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'app:user_auth_completed',
|
||||
{ ...SOURCE, user_id: 'uid-1' }
|
||||
)
|
||||
)
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('tracks auth before resetting identity on logout', async () => {
|
||||
const identifyResult = createDeferred()
|
||||
const trackResult = createDeferred()
|
||||
let activeUser: string | null = null
|
||||
let trackedUser: string | null = null
|
||||
hoisted.analytics.identify.mockImplementationOnce((userId: string) => {
|
||||
activeUser = userId
|
||||
return identifyResult.promise
|
||||
})
|
||||
hoisted.analytics.track.mockImplementationOnce(() => {
|
||||
trackedUser = activeUser
|
||||
return trackResult.promise
|
||||
})
|
||||
hoisted.analytics.reset.mockImplementationOnce(() => {
|
||||
activeUser = null
|
||||
})
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackAuth({
|
||||
user_id: 'uid-1',
|
||||
email: 'person@example.com'
|
||||
})
|
||||
hoisted.logoutUser()
|
||||
identifyResult.resolve()
|
||||
|
||||
await vi.waitFor(() => expect(hoisted.analytics.reset).toHaveBeenCalled())
|
||||
expect(trackedUser).toBe('uid-1')
|
||||
expect(hoisted.analytics.track.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
hoisted.analytics.reset.mock.invocationCallOrder[0]
|
||||
)
|
||||
trackResult.resolve()
|
||||
})
|
||||
|
||||
it('restores signed-out identity when auth delivery follows logout', async () => {
|
||||
let activeUser: string | null = null
|
||||
let trackedUser: string | null = null
|
||||
hoisted.analytics.identify.mockImplementation((userId: string) => {
|
||||
activeUser = userId
|
||||
return Promise.resolve()
|
||||
})
|
||||
hoisted.analytics.track.mockImplementation(() => {
|
||||
trackedUser = activeUser
|
||||
return Promise.resolve()
|
||||
})
|
||||
hoisted.analytics.reset.mockImplementation(() => {
|
||||
activeUser = null
|
||||
})
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
hoisted.userEmail.value = 'person@example.com'
|
||||
hoisted.resolveUser('uid-1')
|
||||
hoisted.logoutUser()
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.reset).toHaveBeenCalledOnce()
|
||||
)
|
||||
|
||||
provider.trackAuth({
|
||||
user_id: 'uid-1',
|
||||
email: 'person@example.com'
|
||||
})
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.reset).toHaveBeenCalledTimes(2)
|
||||
)
|
||||
expect(trackedUser).toBe('uid-1')
|
||||
expect(activeUser).toBeNull()
|
||||
expect(hoisted.analytics.track.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
hoisted.analytics.reset.mock.invocationCallOrder[1]
|
||||
)
|
||||
})
|
||||
|
||||
it('restores a configured identity after tracking auth with the Firebase uid', async () => {
|
||||
const provider = createProvider({
|
||||
customer_io: {
|
||||
write_key: WRITE_KEY,
|
||||
site_id: SITE_ID,
|
||||
user_id: 'forced-uid'
|
||||
}
|
||||
})
|
||||
await vi.dynamicImportSettled()
|
||||
hoisted.analytics.identify.mockClear()
|
||||
|
||||
provider.trackAuth({
|
||||
user_id: 'firebase-uid',
|
||||
email: 'person@example.com'
|
||||
})
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.identify.mock.calls).toEqual([
|
||||
['firebase-uid', { email: 'person@example.com' }],
|
||||
['forced-uid', undefined]
|
||||
])
|
||||
)
|
||||
expect(hoisted.analytics.track.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
hoisted.analytics.identify.mock.invocationCallOrder[1]
|
||||
)
|
||||
})
|
||||
|
||||
it('does not reset identity when login resolution follows auth tracking', async () => {
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackAuth({ user_id: 'uid-1', email: 'person@example.com' })
|
||||
hoisted.userEmail.value = 'person@example.com'
|
||||
hoisted.resolveUser('uid-1')
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'app:user_auth_completed',
|
||||
{ ...SOURCE, user_id: 'uid-1' }
|
||||
)
|
||||
)
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledOnce()
|
||||
expect(hoisted.analytics.reset).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not stall later events when identification never settles', async () => {
|
||||
vi.useFakeTimers()
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
hoisted.analytics.identify.mockReturnValueOnce(new Promise(() => {}))
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackAuth({ user_id: 'uid-1', email: 'person@example.com' })
|
||||
provider.trackWorkflowExecution()
|
||||
expect(hoisted.analytics.track).not.toHaveBeenCalled()
|
||||
|
||||
await vi.advanceTimersByTimeAsync(10_000)
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track.mock.calls).toEqual([
|
||||
['app:user_auth_completed', { ...SOURCE, user_id: 'uid-1' }],
|
||||
['execution_start', SOURCE]
|
||||
])
|
||||
)
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'Failed to identify Customer.io user:',
|
||||
expect.any(Error)
|
||||
)
|
||||
})
|
||||
|
||||
it('tracks auth after identifying a user without an email', async () => {
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackAuth({ user_id: 'uid-without-email' })
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.identify).toHaveBeenCalledWith(
|
||||
'uid-without-email',
|
||||
undefined
|
||||
)
|
||||
)
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'app:user_auth_completed',
|
||||
{ ...SOURCE, user_id: 'uid-without-email' }
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('tracks auth without identifying when user_id is absent', async () => {
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackAuth({ method: 'google', email: 'person@example.com' })
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'app:user_auth_completed',
|
||||
{ ...SOURCE, method: 'google' }
|
||||
)
|
||||
)
|
||||
expect(hoisted.analytics.identify).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('tracks auth after identification fails', async () => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
hoisted.analytics.identify.mockRejectedValueOnce(
|
||||
new Error('identify failed')
|
||||
)
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackAuth({
|
||||
user_id: 'uid-1',
|
||||
email: 'person@example.com'
|
||||
})
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledWith(
|
||||
'app:user_auth_completed',
|
||||
{ ...SOURCE, user_id: 'uid-1' }
|
||||
)
|
||||
)
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'Failed to identify Customer.io user:',
|
||||
expect.any(Error)
|
||||
)
|
||||
})
|
||||
|
||||
it('flushes events buffered before load once, in order', async () => {
|
||||
const provider = createProvider()
|
||||
provider.trackWorkflowExecution()
|
||||
@@ -227,6 +755,67 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('waits for queued auth identification before later events', async () => {
|
||||
const identifyResult = createDeferred()
|
||||
hoisted.analytics.identify.mockReturnValueOnce(identifyResult.promise)
|
||||
const provider = createProvider()
|
||||
provider.trackAuth({
|
||||
user_id: 'uid-1',
|
||||
email: 'person@example.com'
|
||||
})
|
||||
provider.trackWorkflowExecution()
|
||||
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
expect(hoisted.analytics.track).not.toHaveBeenCalled()
|
||||
identifyResult.resolve()
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track.mock.calls).toEqual([
|
||||
['app:user_auth_completed', { ...SOURCE, user_id: 'uid-1' }],
|
||||
['execution_start', SOURCE]
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it('does not wait for event delivery before handing off later events', async () => {
|
||||
const trackResult = createDeferred()
|
||||
hoisted.analytics.track.mockReturnValueOnce(trackResult.promise)
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackWorkflowExecution()
|
||||
provider.trackAddApiCreditButtonClicked()
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.track.mock.calls).toEqual([
|
||||
['execution_start', SOURCE],
|
||||
['app:add_api_credit_button_clicked', SOURCE]
|
||||
])
|
||||
)
|
||||
trackResult.resolve()
|
||||
})
|
||||
|
||||
it('snapshots resolved user email before queued identification', async () => {
|
||||
const identifyResult = createDeferred()
|
||||
hoisted.analytics.identify.mockReturnValueOnce(identifyResult.promise)
|
||||
const provider = createProvider()
|
||||
await vi.dynamicImportSettled()
|
||||
|
||||
provider.trackAuth({ user_id: 'blocking-uid' })
|
||||
hoisted.userEmail.value = 'first@example.com'
|
||||
hoisted.resolveUser('resolved-uid')
|
||||
hoisted.userEmail.value = 'second@example.com'
|
||||
identifyResult.resolve()
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(hoisted.analytics.identify).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'resolved-uid',
|
||||
{ email: 'first@example.com' }
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('disables tracking when the SDK fails to load', async () => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
hoisted.load.mockImplementation(() => {
|
||||
@@ -253,12 +842,12 @@ describe('CustomerIoTelemetryProvider', () => {
|
||||
provider.trackWorkflowExecution()
|
||||
provider.trackAddApiCreditButtonClicked()
|
||||
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledTimes(2)
|
||||
await vi.waitFor(() =>
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'Failed to track Customer.io event:',
|
||||
expect.any(Error)
|
||||
)
|
||||
expect(hoisted.analytics.track).toHaveBeenCalledTimes(2)
|
||||
)
|
||||
expect(console.error).toHaveBeenCalledWith(
|
||||
'Failed to track Customer.io event:',
|
||||
expect.any(Error)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import type { AnalyticsBrowser } from '@customerio/cdp-analytics-browser'
|
||||
import { omit, withTimeout } from 'es-toolkit'
|
||||
|
||||
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
|
||||
import type { AuthUserInfo } from '@/types/authTypes'
|
||||
|
||||
import { TelemetryEvents } from '../../types'
|
||||
import type {
|
||||
AuthMetadata,
|
||||
ExecutionSuccessMetadata,
|
||||
PageViewMetadata,
|
||||
ShareFlowMetadata,
|
||||
SubscriptionMetadata,
|
||||
TelemetryEventProperties,
|
||||
@@ -16,9 +19,17 @@ import type {
|
||||
|
||||
export const EVENT_SOURCE = 'web-sdk'
|
||||
|
||||
const SDK_OPERATION_TIMEOUT_MS = 10_000
|
||||
|
||||
interface QueuedEvent {
|
||||
event: string
|
||||
properties: Record<string, unknown>
|
||||
identity?: CustomerIoIdentity
|
||||
}
|
||||
|
||||
interface CustomerIoIdentity {
|
||||
userId: string
|
||||
email?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +42,12 @@ interface QueuedEvent {
|
||||
export class CustomerIoTelemetryProvider implements TelemetryProvider {
|
||||
private analytics: AnalyticsBrowser | null = null
|
||||
private isEnabled = true
|
||||
private isPageViewTrackingReady = false
|
||||
private eventQueue: QueuedEvent[] = []
|
||||
private pageViewQueued = false
|
||||
private identifiedUser: CustomerIoIdentity | null = null
|
||||
private sessionIdentity: CustomerIoIdentity | null = null
|
||||
private operationQueue: Promise<void> = Promise.resolve()
|
||||
|
||||
constructor() {
|
||||
const {
|
||||
@@ -39,6 +55,7 @@ export class CustomerIoTelemetryProvider implements TelemetryProvider {
|
||||
site_id: siteId,
|
||||
user_id: userIdOverride
|
||||
} = window.__CONFIG__?.customer_io ?? {}
|
||||
this.sessionIdentity = userIdOverride ? { userId: userIdOverride } : null
|
||||
if (!writeKey || !siteId) {
|
||||
this.isEnabled = false
|
||||
return
|
||||
@@ -47,7 +64,7 @@ export class CustomerIoTelemetryProvider implements TelemetryProvider {
|
||||
void import('@customerio/cdp-analytics-browser')
|
||||
.then(({ AnalyticsBrowser, InAppPlugin }) => {
|
||||
const analytics = AnalyticsBrowser.load({ writeKey })
|
||||
void analytics.register(
|
||||
const inAppRegistration = analytics.register(
|
||||
InAppPlugin({
|
||||
siteId,
|
||||
events: null,
|
||||
@@ -60,14 +77,40 @@ export class CustomerIoTelemetryProvider implements TelemetryProvider {
|
||||
this.analytics = analytics
|
||||
|
||||
const currentUser = useCurrentUser()
|
||||
if (userIdOverride) {
|
||||
void analytics.identify(userIdOverride)
|
||||
} else {
|
||||
currentUser.onUserResolved((user) => void analytics.identify(user.id))
|
||||
const identifyResolvedUser = (user: AuthUserInfo) => {
|
||||
const identity = {
|
||||
userId: userIdOverride || user.id,
|
||||
email: currentUser.userEmail.value || undefined
|
||||
}
|
||||
this.sessionIdentity = identity
|
||||
return this.enqueueOperation(() => this.identify(identity))
|
||||
}
|
||||
currentUser.onUserLogout(() => void analytics.reset())
|
||||
|
||||
this.flushQueue()
|
||||
if (userIdOverride && !currentUser.resolvedUserInfo.value) {
|
||||
void this.enqueueOperation(() =>
|
||||
this.identify({ userId: userIdOverride })
|
||||
)
|
||||
}
|
||||
currentUser.onUserResolved((user) => {
|
||||
void identifyResolvedUser(user)
|
||||
})
|
||||
currentUser.onUserLogout(() => {
|
||||
this.sessionIdentity = null
|
||||
void this.enqueueOperation(() => this.resetIdentity())
|
||||
})
|
||||
|
||||
void this.flushQueue()
|
||||
void inAppRegistration
|
||||
.catch((error) => {
|
||||
console.error(
|
||||
'Failed to initialize Customer.io in-app plugin:',
|
||||
error
|
||||
)
|
||||
})
|
||||
.finally(() => {
|
||||
this.isPageViewTrackingReady = true
|
||||
this.flushPageView()
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to load Customer.io:', error)
|
||||
@@ -76,32 +119,134 @@ export class CustomerIoTelemetryProvider implements TelemetryProvider {
|
||||
})
|
||||
}
|
||||
|
||||
private send(event: string, properties: Record<string, unknown>): void {
|
||||
void this.analytics?.track(event, properties)?.catch((error) => {
|
||||
console.error('Failed to track Customer.io event:', error)
|
||||
private enqueueOperation(
|
||||
operation: () => Promise<void> | void
|
||||
): Promise<void> {
|
||||
this.operationQueue = this.operationQueue.then(operation).catch((error) => {
|
||||
console.error('Failed to process Customer.io operation:', error)
|
||||
})
|
||||
return this.operationQueue
|
||||
}
|
||||
|
||||
private track(event: string, metadata?: TelemetryEventProperties): void {
|
||||
private async resetIdentity(): Promise<void> {
|
||||
this.identifiedUser = null
|
||||
const analytics = this.analytics
|
||||
if (!analytics) return
|
||||
await withTimeout(async () => {
|
||||
await analytics.reset()
|
||||
}, SDK_OPERATION_TIMEOUT_MS)
|
||||
}
|
||||
|
||||
private async restoreSessionIdentity(): Promise<void> {
|
||||
if (this.sessionIdentity) {
|
||||
await this.identify(this.sessionIdentity)
|
||||
} else {
|
||||
await this.resetIdentity()
|
||||
}
|
||||
}
|
||||
|
||||
private async identify(identity: CustomerIoIdentity): Promise<void> {
|
||||
const analytics = this.analytics
|
||||
if (!analytics) return
|
||||
|
||||
if (
|
||||
this.identifiedUser?.userId === identity.userId &&
|
||||
this.identifiedUser.email === identity.email
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
this.identifiedUser = identity
|
||||
try {
|
||||
await withTimeout(async () => {
|
||||
await analytics.identify(
|
||||
identity.userId,
|
||||
identity.email ? { email: identity.email } : undefined
|
||||
)
|
||||
}, SDK_OPERATION_TIMEOUT_MS)
|
||||
} catch (error) {
|
||||
this.identifiedUser = null
|
||||
console.error('Failed to identify Customer.io user:', error)
|
||||
}
|
||||
}
|
||||
|
||||
private async send(
|
||||
event: string,
|
||||
properties: Record<string, unknown>,
|
||||
identity?: CustomerIoIdentity
|
||||
): Promise<void> {
|
||||
const analytics = this.analytics
|
||||
if (!analytics) return
|
||||
|
||||
if (identity) await this.identify(identity)
|
||||
|
||||
void analytics.track(event, properties).catch((error) => {
|
||||
console.error('Failed to track Customer.io event:', error)
|
||||
})
|
||||
|
||||
if (identity) await this.restoreSessionIdentity()
|
||||
}
|
||||
|
||||
private track(
|
||||
event: string,
|
||||
metadata?: TelemetryEventProperties,
|
||||
identity?: CustomerIoIdentity
|
||||
): void {
|
||||
if (!this.isEnabled) return
|
||||
const properties = { ...metadata, event_source: EVENT_SOURCE }
|
||||
if (this.analytics) {
|
||||
this.send(event, properties)
|
||||
void this.enqueueOperation(() => this.send(event, properties, identity))
|
||||
} else {
|
||||
this.eventQueue.push({ event, properties })
|
||||
this.eventQueue.push({ event, properties, identity })
|
||||
}
|
||||
}
|
||||
|
||||
private flushQueue(): void {
|
||||
private async flushQueue(): Promise<void> {
|
||||
if (!this.analytics) return
|
||||
for (const { event, properties } of this.eventQueue) {
|
||||
this.send(event, properties)
|
||||
}
|
||||
const queue = this.eventQueue
|
||||
this.eventQueue = []
|
||||
await this.enqueueOperation(async () => {
|
||||
for (const { event, properties, identity } of queue) {
|
||||
await this.send(event, properties, identity)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private sendPageView(): void {
|
||||
void this.analytics?.page()?.catch((error) => {
|
||||
console.error('Failed to track Customer.io page view:', error)
|
||||
})
|
||||
}
|
||||
|
||||
private flushPageView(): void {
|
||||
if (!this.isPageViewTrackingReady || !this.pageViewQueued) {
|
||||
return
|
||||
}
|
||||
this.pageViewQueued = false
|
||||
this.sendPageView()
|
||||
}
|
||||
|
||||
trackPageView(_pageName: string, _properties?: PageViewMetadata): void {
|
||||
if (!this.isEnabled) return
|
||||
if (!this.isPageViewTrackingReady) {
|
||||
this.pageViewQueued = true
|
||||
return
|
||||
}
|
||||
this.sendPageView()
|
||||
}
|
||||
|
||||
trackAuth(metadata: AuthMetadata): void {
|
||||
this.track(TelemetryEvents.USER_AUTH_COMPLETED, metadata)
|
||||
const identity = metadata.user_id
|
||||
? {
|
||||
userId: metadata.user_id,
|
||||
email: metadata.email || undefined
|
||||
}
|
||||
: undefined
|
||||
this.track(
|
||||
TelemetryEvents.USER_AUTH_COMPLETED,
|
||||
omit(metadata, ['email', 'share_id']),
|
||||
identity
|
||||
)
|
||||
}
|
||||
|
||||
trackSubscription(
|
||||
@@ -137,6 +282,6 @@ export class CustomerIoTelemetryProvider implements TelemetryProvider {
|
||||
}
|
||||
|
||||
trackShareFlow(metadata: ShareFlowMetadata): void {
|
||||
this.track(TelemetryEvents.SHARE_FLOW, metadata)
|
||||
this.track(TelemetryEvents.SHARE_FLOW, omit(metadata, ['share_id']))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,6 +250,9 @@ export type BillingStatus =
|
||||
| 'pending_payment'
|
||||
| 'paid'
|
||||
| 'payment_failed'
|
||||
// A Stripe-paused subscription stays `active` on the activity axis; the pause
|
||||
// is a payment-lifecycle fact. Not emitted until cloud#5075 ships.
|
||||
| 'paused'
|
||||
| 'inactive'
|
||||
|
||||
export interface CurrentTeamCreditStop {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user