diff --git a/knip.jsonc b/knip.jsonc index e3cbcadc4..c78706f4c 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -21,9 +21,6 @@ "src/chat/preferences.functions.ts", "src/components/Logo.tsx", "src/components/OptimizedImage.tsx", - "src/components/application-starter/CustomTemplateDialog.tsx", - "src/components/application-starter/FeaturePicker.tsx", - "src/components/application-starter/index.ts", "src/components/game/engine/entities/index.ts", "src/components/icons/BaseballCapIcon.tsx", "src/components/npm-stats/index.ts", diff --git a/src/components/application-starter/CustomTemplateDialog.tsx b/src/components/application-starter/CustomTemplateDialog.tsx deleted file mode 100644 index 946974091..000000000 --- a/src/components/application-starter/CustomTemplateDialog.tsx +++ /dev/null @@ -1,351 +0,0 @@ -/** - * Custom Template Dialog - * - * Allows importing project templates from external URLs. - */ - -import { useState } from 'react' -import { Link } from '@tanstack/react-router' -import { twMerge } from 'tailwind-merge' -import { - CircleNotchIcon, - WarningCircleIcon, - LinkIcon, - XIcon, - QuestionIcon, -} from '@phosphor-icons/react' -import { useApplicationStarterStore, useCustomTemplate } from './store' -import type { CustomTemplateCompiled } from '~/application-starter/api' - -interface CustomTemplateDialogProps { - onClose?: () => void -} - -export function CustomTemplateDialog({ onClose }: CustomTemplateDialogProps) { - const [url, setUrl] = useState('') - const [isLoading, setIsLoading] = useState(false) - const [error, setError] = useState(null) - const [preview, setPreview] = useState(null) - - const setCustomTemplate = useApplicationStarterStore( - (s) => s.setCustomTemplate, - ) - - const handleLoad = async () => { - if (!url.trim()) { - setError('Please enter a URL') - return - } - - setIsLoading(true) - setError(null) - setPreview(null) - - try { - const response = await fetch( - `/api/application-starter/load-remote-template?url=${encodeURIComponent(url)}`, - ) - const data = await response.json() - - if (data.error) { - setError(data.error) - } else if (data.template) { - setPreview(data.template) - } - } catch { - setError('Failed to load template') - } finally { - setIsLoading(false) - } - } - - const handleApply = () => { - if (!preview) return - setCustomTemplate(preview) - onClose?.() - } - - const handleKeyDown = (e: React.KeyboardEvent) => { - if (e.key === 'Enter' && !isLoading) { - if (preview) { - handleApply() - } else { - handleLoad() - } - } - } - - return ( -
- {/* URL Input */} -
- -
- { - setUrl(e.target.value) - setError(null) - setPreview(null) - }} - onKeyDown={handleKeyDown} - placeholder="https://example.com/my-template.json" - className="flex-1 px-3 py-2 text-sm bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-cyan-500" - disabled={isLoading} - /> - -
-

- Enter the URL to a template JSON file -

-
- - {/* Error */} - {error && ( -
- - {error} -
- )} - - {/* Preview */} - {preview && ( -
-
-

- {preview.name} -

-

- {preview.description} -

-
- - {/* Metadata */} -
- {preview.tailwind && ( - - Tailwind - - )} - {preview.typescript && ( - - TypeScript - - )} - {preview.dependsOn && preview.dependsOn.length > 0 && ( - - {preview.dependsOn.length} add-ons - - )} -
- - {/* Apply button */} - -
- )} -
- ) -} - -/** - * Display and manage custom template selection - */ -export function CustomTemplateSection() { - const [isOpen, setIsOpen] = useState(false) - const customTemplate = useCustomTemplate() - const setCustomTemplate = useApplicationStarterStore( - (s) => s.setCustomTemplate, - ) - - if (customTemplate) { - return ( -
-
-
- -
- - {customTemplate.name} - - - Custom Template - -
-
- -
-
- ) - } - - return ( -
- - - {isOpen && ( -
- setIsOpen(false)} /> -
- )} -
- ) -} - -/** - * Custom template item for use in template grid - */ -export function CustomTemplateItem({ - isExpanded, - onToggle, -}: { - isExpanded: boolean - onToggle: () => void -}) { - const customTemplate = useCustomTemplate() - const setCustomTemplate = useApplicationStarterStore( - (s) => s.setCustomTemplate, - ) - - if (customTemplate) { - return ( -
-
-
-
-
- -
-
- - {customTemplate.name} - - - Custom Template - -
-
- -
-
-
- ) - } - - return ( - <> - - {isExpanded && ( -
- -
- )} - - ) -} diff --git a/src/components/application-starter/FeaturePicker.tsx b/src/components/application-starter/FeaturePicker.tsx deleted file mode 100644 index 542dc6c2f..000000000 --- a/src/components/application-starter/FeaturePicker.tsx +++ /dev/null @@ -1,649 +0,0 @@ -/** - * Feature Picker (v2) - * - * Component for selecting features in the application starter. - * Shows Framework (locked) -> Styling (Tailwind toggle) -> Add-ons hierarchy. - * Grouped by category with conflict/dependency handling. - * Features partner badges, external links, and collapsible sections. - * Partner features use the shared partner placement policy within categories. - */ - -import { useState, useMemo } from 'react' -import { twMerge } from 'tailwind-merge' -import { - StarIcon, - ArrowSquareOutIcon, - CaretDownIcon, - SparkleIcon, - XIcon, -} from '@phosphor-icons/react' -import { matchSorter } from 'match-sorter' -import { - useApplicationStarterStore, - useFeatureState, - useAvailableFeatures, - useAvailableExamples, - useSelectedExample, - useIntegrationSearch, -} from './store' -import { partners, type Partner } from '~/utils/partners' -import { - getPartnerPlacementContext, - getPartnersForPlacement, -} from '~/utils/partner-placement' -import { Tooltip } from '~/ui/Tooltip' -import { Panel, PanelTrigger, PanelContent } from '~/components/Panel' -import type { FeatureId, FeatureInfo } from '~/application-starter/api' - -type FeatureCategory = - | 'tanstack' - | 'database' - | 'orm' - | 'auth' - | 'deploy' - | 'tooling' - | 'monitoring' - | 'api' - | 'i18n' - | 'cms' - | 'ecommerce' - | 'other' - -const applicationStarterFeaturePlacementContext = getPartnerPlacementContext({ - orderStrategy: 'contextual-recommendation', - surface: 'application_starter_feature_picker', -}) - -const partnersById = new Map( - partners - .filter((partner) => partner.status === 'active') - .map((partner) => [partner.id, partner]), -) - -const CATEGORY_INFO: Record< - FeatureCategory, - { label: string; description: string; color: string } -> = { - tanstack: { - label: 'TanStack', - description: 'Official TanStack libraries', - color: '#00D1B2', // TanStack cyan/teal - }, - database: { - label: 'Database', - description: 'Database providers and real-time backends', - color: '#3B82F6', // Blue - }, - orm: { - label: 'ORM', - description: 'Object-relational mapping and query builders', - color: '#6366F1', // Indigo - }, - auth: { - label: 'Authentication', - description: 'User authentication and authorization', - color: '#8B5CF6', // Purple - }, - deploy: { - label: 'Deployment', - description: 'Hosting and deployment platforms', - color: '#EC4899', // Pink - }, - monitoring: { - label: 'Monitoring', - description: 'Observability, error tracking, and performance monitoring', - color: '#F59E0B', // Amber - }, - cms: { - label: 'CMS', - description: 'Content management systems', - color: '#10B981', // Emerald - }, - ecommerce: { - label: 'Ecommerce', - description: 'Storefronts, checkout, and product catalogs', - color: '#5A31F4', // Shopify purple - }, - tooling: { - label: 'Tooling', - description: 'Development tools, linting, and utilities', - color: '#F472B6', // Pink-400 - }, - api: { - label: 'API', - description: 'Type-safe APIs and RPC frameworks', - color: '#EF4444', // Red - }, - i18n: { - label: 'i18n', - description: 'Internationalization and localization', - color: '#14B8A6', // Teal - }, - other: { - label: 'Other', - description: 'Additional tools and integrations', - color: '#A78BFA', // Violet-400 - }, -} - -const CATEGORY_ORDER: Array = [ - 'tanstack', - 'deploy', - 'database', - 'orm', - 'auth', - 'monitoring', - 'api', - 'i18n', - 'cms', - 'ecommerce', - 'tooling', - 'other', -] - -// Custom addon color used in store.ts addCustomAddon -const CUSTOM_ADDON_COLOR = '#8B5CF6' - -function getFeaturePartner(feature: FeatureInfo) { - if (!feature.partnerId) { - return undefined - } - - return partnersById.get(feature.partnerId) -} - -function getFeaturePartnerPlacementRank( - feature: FeatureInfo, - partnerRankById: Map, -) { - if (!feature.partnerId) { - return undefined - } - - return partnerRankById.get(feature.partnerId) -} - -function getPartnerPlacementRankById(features: Array) { - const featurePartners = Array() - const featurePartnerIds = new Set() - - for (const feature of features) { - const partner = getFeaturePartner(feature) - - if (!partner || featurePartnerIds.has(partner.id)) { - continue - } - - featurePartnerIds.add(partner.id) - featurePartners.push(partner) - } - - return new Map( - getPartnersForPlacement( - featurePartners, - applicationStarterFeaturePlacementContext, - ).map((partner, index) => [partner.id, index]), - ) -} - -// Sort features: partners first by shared placement policy, then non-partners, custom addons last -function sortFeaturesByPartnerPlacement( - features: Array, -): Array { - const partnerRankById = getPartnerPlacementRankById(features) - - return features - .map((feature, index) => ({ feature, index })) - .sort((left, right) => { - // Custom addons always last - const leftIsCustom = left.feature.color === CUSTOM_ADDON_COLOR - const rightIsCustom = right.feature.color === CUSTOM_ADDON_COLOR - - if (leftIsCustom && !rightIsCustom) return 1 - if (!leftIsCustom && rightIsCustom) return -1 - - const leftPartnerRank = getFeaturePartnerPlacementRank( - left.feature, - partnerRankById, - ) - const rightPartnerRank = getFeaturePartnerPlacementRank( - right.feature, - partnerRankById, - ) - - if (leftPartnerRank !== undefined && rightPartnerRank !== undefined) { - const partnerComparison = leftPartnerRank - rightPartnerRank - - if (partnerComparison !== 0) { - return partnerComparison - } - - return left.index - right.index - } - - if (leftPartnerRank !== undefined) return -1 - if (rightPartnerRank !== undefined) return 1 - - return left.index - right.index - }) - .map(({ feature }) => feature) -} - -export function FeaturePicker() { - const availableFeatures = useAvailableFeatures() - const search = useIntegrationSearch() - - // Filter features by search - const filteredFeatures = useMemo(() => { - if (!search.trim()) return availableFeatures - return matchSorter(availableFeatures, search, { - keys: ['name', 'description', 'category'], - }) - }, [availableFeatures, search]) - - // Separate partner features for "Featured" section, sorted by placement policy - const partnerFeatures = useMemo( - () => - sortFeaturesByPartnerPlacement( - filteredFeatures.filter((f) => f.partnerId), - ), - [filteredFeatures], - ) - - // Group features by category, with partners sorted first by placement policy - const featuresByCategory = useMemo(() => { - return CATEGORY_ORDER.reduce( - (acc, category) => { - const categoryFeatures = filteredFeatures.filter( - (f) => f.category === category, - ) - acc[category] = sortFeaturesByPartnerPlacement(categoryFeatures) - return acc - }, - {} as Record>, - ) - }, [filteredFeatures]) - - const isSearching = search.trim().length > 0 - - return ( -
- {/* Example Picker */} - {!isSearching && } - - {/* Featured section */} - {partnerFeatures.length > 0 && !isSearching && ( - - )} - - {/* Category sections */} - {CATEGORY_ORDER.map((category) => { - const features = featuresByCategory[category] - if (!features || features.length === 0) return null - - const info = CATEGORY_INFO[category] - return ( - - ) - })} - - {/* No results */} - {isSearching && filteredFeatures.length === 0 && ( -
- No add-ons found for "{search}" -
- )} -
- ) -} - -interface FeatureSectionProps { - title: string - description: string - features: Array - categoryColor: string - defaultOpen?: boolean - forceOpen?: boolean -} - -function FeatureSection({ - title, - description, - features, - categoryColor, - defaultOpen = false, - forceOpen = false, -}: FeatureSectionProps) { - const [isOpen, setIsOpen] = useState(defaultOpen) - const effectiveOpen = forceOpen || isOpen - - return ( - - -
-

- {title} -

-

- {description} -

-
- -
- - -
- {features.map((feature) => ( - - ))} -
-
-
- ) -} - -interface FeatureCardProps { - feature: FeatureInfo - categoryColor: string -} - -function FeatureCard({ feature, categoryColor }: FeatureCardProps) { - const toggleFeature = useApplicationStarterStore((s) => s.toggleFeature) - const getFeatureInfo = useApplicationStarterStore((s) => s.getFeatureInfo) - const { selected, enabled, disabledReason, exclusiveConflict, requiredBy } = - useFeatureState(feature.id) - - const handleClick = () => { - if (enabled && !requiredBy) { - toggleFeature(feature.id) - } - } - - const handleLinkClick = (e: React.MouseEvent) => { - e.stopPropagation() - } - - const isPartner = Boolean(feature.partnerId) - const isDisabled = !enabled || !!requiredBy - - // Build tooltip content - const tooltipContent = disabledReason - ? disabledReason - : exclusiveConflict - ? `Replaces ${getFeatureInfo(exclusiveConflict)?.name ?? exclusiveConflict}` - : null - - // Use feature color for the dot and selected state - const featureColor = feature.color ?? categoryColor - - const cardContent = ( - - ) - - if (tooltipContent) { - return ( - -
{cardContent}
-
- ) - } - - return cardContent -} - -// Feature options panel -interface FeatureOptionsProps { - featureId: FeatureId -} - -export function FeatureOptions({ featureId }: FeatureOptionsProps) { - const feature = useApplicationStarterStore((s) => s.getFeatureInfo(featureId)) - const featureOptions = useApplicationStarterStore((s) => s.featureOptions) - const setFeatureOption = useApplicationStarterStore((s) => s.setFeatureOption) - - if (!feature || !feature.options || feature.options.length === 0) { - return null - } - - const currentOptions = featureOptions[featureId] || {} - - return ( -
- {feature.options.map((option) => ( -
- - {option.type === 'select' && option.choices && ( - - )} - {option.type === 'boolean' && ( - - )} - {option.type === 'string' && ( - - setFeatureOption(featureId, option.key, e.target.value) - } - className="w-full bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-cyan-500" - /> - )} - {option.description && ( -

- {option.description} -

- )} -
- ))} -
- ) -} - -/** - * Example Picker - Single-select section for full demo apps - */ -function ExamplePicker() { - const examples = useAvailableExamples() - const selectedExample = useSelectedExample() - const selectExample = useApplicationStarterStore((s) => s.selectExample) - const [isOpen, setIsOpen] = useState(true) - - if (examples.length === 0) return null - - return ( - - -
-

- Examples -

-

- Start with a complete demo app -

-
- -
- - -
- {examples.map((example) => { - const isSelected = selectedExample === example.id - - return ( - - ) - })} -
-
-
- ) -} diff --git a/src/components/application-starter/index.ts b/src/components/application-starter/index.ts deleted file mode 100644 index bd80aad0d..000000000 --- a/src/components/application-starter/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * ApplicationStarter v2 Components - * - * New applicationStarter implementation using the internal applicationStarter engine API. - */ - -export { ApplicationStarterProvider } from './ApplicationStarterProvider' -export { FeaturePicker, FeatureOptions } from './FeaturePicker' -export { - useApplicationStarterStore, - useProjectName, - useFeatures, - useAvailableFeatures, - useFeaturesLoaded, - useFeatureState, -} from './store' -export { - useApplicationStarterUrl, - useCliCommand, -} from './useApplicationStarterUrl'