From a96e028bb564582a027a65ad672ae10f362d84fa Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Fri, 2 Jan 2026 09:35:04 -0800 Subject: [PATCH 1/6] include fees with lightning payments --- package-lock.json | 44 +++++++++++++++++------ src/components/AIProviderConfigDialog.tsx | 6 +++- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index b3eb7183..eb308bfe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -195,6 +195,7 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1830,6 +1831,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" }, @@ -1853,6 +1855,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -1874,6 +1877,7 @@ "resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz", "integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==", "license": "MIT", + "peer": true, "dependencies": { "@dnd-kit/accessibility": "^3.1.1", "@dnd-kit/utilities": "^3.2.2", @@ -5442,8 +5446,7 @@ "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/chrome": { "version": "0.0.74", @@ -5655,6 +5658,7 @@ "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.20.tgz", "integrity": "sha512-IPaCZN7PShZK/3t6Q87pfTkRm6oLTd4vztyoj+cbHUF1g3FfVb2tFIL79uCRKEfv16AhqDMBywP2VW3KIZUvcg==", "license": "MIT", + "peer": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -5666,6 +5670,7 @@ "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==", "devOptional": true, "license": "MIT", + "peer": true, "peerDependencies": { "@types/react": "^18.0.0" } @@ -5749,6 +5754,7 @@ "integrity": "sha512-oU/OtYVydhXnumd0BobL9rkJg7wFJ9bFFPmSmB/bf/XWN85hlViji59ko6bSKBXyseT9V8l+CN1nwmlbiN0G7Q==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.31.1", "@typescript-eslint/types": "8.31.1", @@ -6108,6 +6114,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -6622,6 +6629,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.19", "caniuse-lite": "^1.0.30001751", @@ -6851,6 +6859,7 @@ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "license": "MIT", + "peer": true, "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -7610,8 +7619,7 @@ "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/dom-helpers": { "version": "5.2.1", @@ -7676,7 +7684,8 @@ "version": "8.6.0", "resolved": "https://registry.npmjs.org/embla-carousel/-/embla-carousel-8.6.0.tgz", "integrity": "sha512-SjWyZBHJPbqxHOzckOfo8lHisEaJWmwd23XppYFYVh10bU66/Pn5tkVkbkCMZVdbUE5eTCI2nD8OyIP4Z+uwkA==", - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/embla-carousel-react": { "version": "8.6.0", @@ -7962,6 +7971,7 @@ "integrity": "sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", @@ -8227,6 +8237,7 @@ "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", "license": "MIT", + "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.0", @@ -9324,6 +9335,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "@babel/runtime": "^7.27.6" }, @@ -10117,6 +10129,7 @@ "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "cssstyle": "^4.2.1", "data-urls": "^5.0.0", @@ -10501,7 +10514,6 @@ "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", "dev": true, "license": "MIT", - "peer": true, "bin": { "lz-string": "bin/bin.js" } @@ -12255,6 +12267,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.8", "picocolors": "^1.1.1", @@ -12422,7 +12435,6 @@ "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", @@ -12438,7 +12450,6 @@ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -12449,7 +12460,6 @@ "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -12462,8 +12472,7 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/prismjs": { "version": "1.30.0", @@ -12637,6 +12646,7 @@ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -12663,6 +12673,7 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" @@ -12688,6 +12699,7 @@ "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.1.tgz", "integrity": "sha512-qWAVokhSpshhcEuQDSANHx3jiAEFzu2HAaaQIzi/r9FNPm1ioAvuJSD4EuZzWd7Al7nTRKcKPnBKO7sRn+zavQ==", "license": "MIT", + "peer": true, "engines": { "node": ">=18.0.0" }, @@ -12736,6 +12748,7 @@ "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz", "integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==", "license": "MIT", + "peer": true, "dependencies": { "@types/hast": "^3.0.0", "@types/mdast": "^4.0.0", @@ -13278,6 +13291,7 @@ "integrity": "sha512-C5VvvgCCyfyotVITIAv+4efVytl5F7wt+/I2i9q9GZcEXW9BP52YYOXC58igUi+LFZVHukErIIqQSWwv/M3WRw==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "@types/estree": "1.0.7" }, @@ -14332,6 +14346,7 @@ "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.17.tgz", "integrity": "sha512-w33E2aCvSDP0tW9RZuNXadXlkHXqFzSkQew/aIa2i/Sj8fThxwovwlXHSPXTbAHwEIhBFXAedUhP2tueAKP8Og==", "license": "MIT", + "peer": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", @@ -14535,6 +14550,7 @@ "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -14830,6 +14846,7 @@ "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -15357,6 +15374,7 @@ "integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", @@ -15501,6 +15519,7 @@ "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -15972,6 +15991,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -16048,6 +16068,7 @@ "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "dev": true, "license": "MIT", + "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -16496,6 +16517,7 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/src/components/AIProviderConfigDialog.tsx b/src/components/AIProviderConfigDialog.tsx index c98d4d89..818a59c2 100644 --- a/src/components/AIProviderConfigDialog.tsx +++ b/src/components/AIProviderConfigDialog.tsx @@ -355,6 +355,7 @@ export function AIProviderConfigDialog({ const [paymentMethod, setPaymentMethod] = useState<'stripe' | 'lightning'>('stripe'); const [lightningInvoice, setLightningInvoice] = useState(null); const [lightningPaymentId, setLightningPaymentId] = useState(null); + const [lightningTotal, setLightningTotal] = useState(10); const [refreshingPayments, setRefreshingPayments] = useState>(new Set()); const [giftcardAmount, setGiftcardAmount] = useState(10); const [giftcardQuantity, setGiftcardQuantity] = useState(1); @@ -452,6 +453,7 @@ export function AIProviderConfigDialog({ } else if (payment.method === 'lightning') { setLightningInvoice(payment.url); setLightningPaymentId(payment.id); + setLightningTotal(payment.total); } queryClient.invalidateQueries({ @@ -632,6 +634,7 @@ export function AIProviderConfigDialog({ } else if (paymentPreview.method === 'lightning') { setLightningInvoice(paymentPreview.url); setLightningPaymentId(paymentPreview.id); + setLightningTotal(paymentPreview.total); } queryClient.invalidateQueries({ @@ -1238,6 +1241,7 @@ export function AIProviderConfigDialog({ if (payment.method === 'lightning') { setLightningInvoice(payment.url); setLightningPaymentId(payment.id); + setLightningTotal(payment.total); } else { window.open(payment.url, '_blank'); } @@ -1512,7 +1516,7 @@ export function AIProviderConfigDialog({
{ From 87de7c79ffcee87d2373e84a0a66c7dece54db4e Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Fri, 2 Jan 2026 09:45:39 -0800 Subject: [PATCH 2/6] add debouncing on typed input --- src/components/AIProviderConfigDialog.tsx | 27 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/AIProviderConfigDialog.tsx b/src/components/AIProviderConfigDialog.tsx index 818a59c2..3259da58 100644 --- a/src/components/AIProviderConfigDialog.tsx +++ b/src/components/AIProviderConfigDialog.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, useCallback } from 'react'; +import { useState, useEffect, useCallback, useRef } from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import QRCode from 'qrcode'; import { Trash2, Bot, CreditCard, Zap, ExternalLink, RefreshCw, Check, X, Clock, AlertCircle, Copy, RotateCcw, ArrowLeft, Gift, Plus, History, DollarSign, Printer, Download } from 'lucide-react'; @@ -352,11 +352,13 @@ export function AIProviderConfigDialog({ // Credits state const [amount, setAmount] = useState(10); + const [debouncedAmount, setDebouncedAmount] = useState(10); const [paymentMethod, setPaymentMethod] = useState<'stripe' | 'lightning'>('stripe'); const [lightningInvoice, setLightningInvoice] = useState(null); const [lightningPaymentId, setLightningPaymentId] = useState(null); const [lightningTotal, setLightningTotal] = useState(10); const [refreshingPayments, setRefreshingPayments] = useState>(new Set()); + const amountDebounceTimer = useRef(null); const [giftcardAmount, setGiftcardAmount] = useState(10); const [giftcardQuantity, setGiftcardQuantity] = useState(1); const [redeemCode, setRedeemCode] = useState(''); @@ -384,13 +386,30 @@ export function AIProviderConfigDialog({ } }, [open, supportsCredits, isLoadingCredits]); + // Debounce amount changes to avoid excessive API calls + useEffect(() => { + if (amountDebounceTimer.current) { + clearTimeout(amountDebounceTimer.current); + } + + amountDebounceTimer.current = setTimeout(() => { + setDebouncedAmount(amount); + }, 500); // Wait 500ms after user stops typing + + return () => { + if (amountDebounceTimer.current) { + clearTimeout(amountDebounceTimer.current); + } + }; + }, [amount]); + // Query for payment preview (to get fee information) const { data: paymentPreview, isLoading: isLoadingPreview } = useQuery({ - queryKey: ['ai-payment-preview', provider.nostr ? user?.pubkey ?? '' : '', provider.id, amount, paymentMethod], + queryKey: ['ai-payment-preview', provider.nostr ? user?.pubkey ?? '' : '', provider.id, debouncedAmount, paymentMethod], queryFn: async (): Promise => { const ai = createAIClient(provider, user, config.corsProxy); const request: AddCreditsRequest = { - amount, + amount: debouncedAmount, method: paymentMethod, }; @@ -402,7 +421,7 @@ export function AIProviderConfigDialog({ body: request, }) as Payment; }, - enabled: open && supportsCredits && amount > 0, + enabled: open && supportsCredits && debouncedAmount > 0, retry: false, refetchOnWindowFocus: false, staleTime: Infinity, From 4cbce6be632a3ba2250507f8487e9133ddfa3e84 Mon Sep 17 00:00:00 2001 From: lemonknowsall Date: Fri, 2 Jan 2026 09:53:02 -0800 Subject: [PATCH 3/6] show placeholder when clearing field --- src/components/AIProviderConfigDialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AIProviderConfigDialog.tsx b/src/components/AIProviderConfigDialog.tsx index 3259da58..1809caf7 100644 --- a/src/components/AIProviderConfigDialog.tsx +++ b/src/components/AIProviderConfigDialog.tsx @@ -1116,8 +1116,8 @@ export function AIProviderConfigDialog({ id="amount" type="number" step="0.01" - value={amount} - onChange={(e) => setAmount(Number(e.target.value))} + value={amount || ''} + onChange={(e) => setAmount(Number(e.target.value) || 0)} placeholder={t('enterAmount')} className="text-center text-lg font-medium" /> From 1915e6044fd30540914a334bbbe36ff3fab24ec7 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 3 Jan 2026 18:49:54 -0600 Subject: [PATCH 4/6] Deployment providers refactoring --- src/components/AddProviderDialog.tsx | 67 ++------- src/components/ExternalFavicon.tsx | 3 +- src/components/ProviderConfigDialog.tsx | 86 ++--------- src/components/deploy/DeploySteps.tsx | 94 +++++------- src/lib/deploy/types.ts | 16 ++ src/lib/deployProviderPresets.ts | 63 ++++++++ src/pages/DeploySettings.tsx | 187 +++--------------------- 7 files changed, 168 insertions(+), 348 deletions(-) create mode 100644 src/lib/deployProviderPresets.ts diff --git a/src/components/AddProviderDialog.tsx b/src/components/AddProviderDialog.tsx index 59e78bb8..b4507566 100644 --- a/src/components/AddProviderDialog.tsx +++ b/src/components/AddProviderDialog.tsx @@ -19,21 +19,7 @@ import { } from '@/components/ui/dropdown-menu'; import { ExternalFavicon } from '@/components/ExternalFavicon'; import { Link } from 'react-router-dom'; - -interface PresetProvider { - id: string; - type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno'; - name: string; - description: string; - requiresNostr?: boolean; - apiKeyLabel?: string; - apiKeyURL?: string; - accountIdLabel?: string; - accountIdURL?: string; - organizationIdLabel?: string; - organizationIdURL?: string; - proxy?: boolean; -} +import type { PresetDeployProvider } from '@/lib/deploy/types'; interface OAuthHook { isOAuthConfigured: boolean; @@ -45,7 +31,7 @@ interface OAuthHook { interface AddProviderDialogProps { open: boolean; onOpenChange: (open: boolean) => void; - preset: PresetProvider; + preset: PresetDeployProvider; isLoggedIntoNostr: boolean; oauthHook: OAuthHook | null; forceManualEntry: boolean; @@ -53,25 +39,6 @@ interface AddProviderDialogProps { onAdd: (apiKey: string, accountId?: string, organizationId?: string) => void; } -function getProviderUrl(preset: PresetProvider): string | null { - switch (preset.type) { - case 'shakespeare': - return 'https://shakespeare.diy'; - case 'netlify': - return 'https://netlify.com'; - case 'vercel': - return 'https://vercel.com'; - case 'cloudflare': - return 'https://cloudflare.com'; - case 'deno': - return 'https://deno.com'; - case 'nsite': - return null; - default: - return null; - } -} - export function AddProviderDialog({ open, onOpenChange, @@ -100,22 +67,16 @@ export function AddProviderDialog({ onOpenChange(false); }; - const url = getProviderUrl(preset); - return (
- {url ? ( - } - /> - ) : ( - - )} + } + /> {preset.name}
@@ -152,15 +113,11 @@ export function AddProviderDialog({ ) : ( <> - {url ? ( - } - /> - ) : ( - - )} + } + /> Connect to {preset.name} diff --git a/src/components/ExternalFavicon.tsx b/src/components/ExternalFavicon.tsx index 38868387..4e903c1f 100644 --- a/src/components/ExternalFavicon.tsx +++ b/src/components/ExternalFavicon.tsx @@ -5,7 +5,7 @@ import { ReactNode, useMemo } from 'react'; interface ExternalFaviconProps { /** The URL to fetch the favicon for */ - url: string | URL; + url: string | URL | undefined; /** Size of the favicon in pixels */ size?: number; /** Fallback element to display if favicon fails to load */ @@ -28,6 +28,7 @@ export function ExternalFavicon({ // Generate the favicon URL using the configured template const faviconSrc = useMemo(() => { + if (!url) return; try { // Normalize the URL to ensure it has a protocol return faviconUrl(config.faviconUrl, url); diff --git a/src/components/ProviderConfigDialog.tsx b/src/components/ProviderConfigDialog.tsx index a8031779..69843b98 100644 --- a/src/components/ProviderConfigDialog.tsx +++ b/src/components/ProviderConfigDialog.tsx @@ -15,28 +15,14 @@ import { DialogFooter, } from '@/components/ui/dialog'; import type { DeployProvider } from '@/contexts/DeploySettingsContext'; +import type { PresetDeployProvider } from '@/lib/deploy/types'; import { ExternalFavicon } from '@/components/ExternalFavicon'; -interface PresetProvider { - id: string; - type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno'; - name: string; - description: string; - requiresNostr?: boolean; - apiKeyLabel?: string; - apiKeyURL?: string; - accountIdLabel?: string; - accountIdURL?: string; - organizationIdLabel?: string; - organizationIdURL?: string; - proxy?: boolean; -} - interface ProviderConfigDialogProps { open: boolean; onOpenChange: (open: boolean) => void; provider: DeployProvider; - preset?: PresetProvider; + preset?: PresetDeployProvider; onUpdate: (provider: DeployProvider) => void; onRemove: () => void; } @@ -56,52 +42,6 @@ function normalizeUrl(url: string): string { return `https://${url}`; } -function getProviderUrl(provider: DeployProvider | PresetProvider): string | null { - switch (provider.type) { - case 'shakespeare': - // For Shakespeare providers, check for custom host first, then use default - if ('host' in provider && provider.host) { - return normalizeUrl(provider.host); - } - return 'https://shakespeare.diy'; - - case 'netlify': - // For Netlify providers, check for custom baseURL first, then use default - if ('baseURL' in provider && provider.baseURL) { - return provider.baseURL; - } - return 'https://netlify.com'; - - case 'vercel': - // For Vercel providers, check for custom baseURL first, then use default - if ('baseURL' in provider && provider.baseURL) { - return provider.baseURL; - } - return 'https://vercel.com'; - - case 'cloudflare': - // For Cloudflare providers, check for custom baseURL first, then use default - if ('baseURL' in provider && provider.baseURL) { - return provider.baseURL; - } - return 'https://cloudflare.com'; - - case 'deno': - // For Deno Deploy providers, check for custom baseURL first, then use default - if ('baseURL' in provider && provider.baseURL) { - return provider.baseURL; - } - return 'https://deno.com'; - - case 'nsite': - // nsite uses Rocket icon fallback - return null; - - default: - return null; - } -} - export function ProviderConfigDialog({ open, onOpenChange, @@ -130,22 +70,24 @@ export function ProviderConfigDialog({ onOpenChange(false); }; - const url = getProviderUrl(localProvider); + // Use baseURL from configured provider, falling back to preset baseURL + const baseURL = ('baseURL' in localProvider && localProvider.baseURL) || preset?.baseURL; + + // For Shakespeare, special handling for host field + const shakespeareUrl = localProvider.type === 'shakespeare' && 'host' in localProvider && localProvider.host + ? normalizeUrl(localProvider.host) + : undefined; return (
- {url ? ( - } - /> - ) : ( - - )} + } + /> {localProvider.name}
diff --git a/src/components/deploy/DeploySteps.tsx b/src/components/deploy/DeploySteps.tsx index 9bffde50..7563dad7 100644 --- a/src/components/deploy/DeploySteps.tsx +++ b/src/components/deploy/DeploySteps.tsx @@ -15,6 +15,8 @@ import { useAppContext } from '@/hooks/useAppContext'; import { useNostr } from '@nostrify/react'; import { Link } from 'react-router-dom'; import type { DeployProvider } from '@/contexts/DeploySettingsContext'; +import type { PresetDeployProvider } from '@/lib/deploy/types'; +import { PRESET_DEPLOY_PROVIDERS } from '@/lib/deployProviderPresets'; import { ShakespeareDeployForm } from '@/components/deploy/ShakespeareDeployForm'; import { NetlifyDeployForm } from '@/components/deploy/NetlifyDeployForm'; import { VercelDeployForm } from '@/components/deploy/VercelDeployForm'; @@ -31,53 +33,28 @@ import { CloudflareAdapter } from '@/lib/deploy/CloudflareAdapter'; import { DenoDeployAdapter } from '@/lib/deploy/DenoDeployAdapter'; /** - * Helper function to get provider URL for favicon + * Normalize a URL string to ensure it has a protocol */ -function getProviderUrl(provider: DeployProvider): string | null { - switch (provider.type) { - case 'shakespeare': - if (provider.host) { - return `https://${provider.host}`; - } - return 'https://shakespeare.diy'; - - case 'netlify': - if (provider.baseURL) { - return provider.baseURL; - } - return 'https://netlify.com'; - - case 'vercel': - if (provider.baseURL) { - return provider.baseURL; - } - return 'https://vercel.com'; - - case 'cloudflare': - if (provider.baseURL) { - return provider.baseURL; - } - return 'https://cloudflare.com'; - - case 'deno': - if (provider.baseURL) { - return provider.baseURL; - } - return 'https://deno.com'; - - case 'nsite': - return null; - - default: - return null; +function normalizeUrl(url: string): string { + if (/^https?:\/\//i.test(url)) { + return url; } + return `https://${url}`; } /** * Render provider icon using favicon or fallback */ -function renderProviderIcon(provider: DeployProvider, size = 14) { - const url = getProviderUrl(provider); +function renderProviderIcon(provider: DeployProvider, preset: PresetDeployProvider | undefined, size = 14) { + // Use baseURL from configured provider, falling back to preset baseURL + const baseURL = ('baseURL' in provider && provider.baseURL) || preset?.baseURL; + + // For Shakespeare, special handling for host field + const shakespeareUrl = provider.type === 'shakespeare' && 'host' in provider && provider.host + ? normalizeUrl(provider.host) + : undefined; + + const url = shakespeareUrl || baseURL; if (url) { return ( @@ -589,23 +566,26 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
- {settings.providers.map((provider) => ( - - ))} + {settings.providers.map((provider) => { + const preset = PRESET_DEPLOY_PROVIDERS.find(p => p.type === provider.type); + return ( + + ); + })}
diff --git a/src/lib/deploy/types.ts b/src/lib/deploy/types.ts index 60222a5d..6c9df61a 100644 --- a/src/lib/deploy/types.ts +++ b/src/lib/deploy/types.ts @@ -74,3 +74,19 @@ export interface DenoDeployConfig { projectName?: string; corsProxy?: string; } + +export interface PresetDeployProvider { + id: string; + type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno'; + name: string; + description: string; + baseURL?: string; + requiresNostr?: boolean; + apiKeyLabel?: string; + apiKeyURL?: string; + accountIdLabel?: string; + accountIdURL?: string; + organizationIdLabel?: string; + organizationIdURL?: string; + proxy?: boolean; +} diff --git a/src/lib/deployProviderPresets.ts b/src/lib/deployProviderPresets.ts new file mode 100644 index 00000000..5bf6d8a4 --- /dev/null +++ b/src/lib/deployProviderPresets.ts @@ -0,0 +1,63 @@ +import type { PresetDeployProvider } from './deploy/types'; + +export const PRESET_DEPLOY_PROVIDERS: PresetDeployProvider[] = [ + { + id: 'shakespeare', + type: 'shakespeare', + name: 'Shakespeare Deploy', + description: 'Deploy to Shakespeare hosting with Nostr authentication', + baseURL: 'https://shakespeare.diy', + requiresNostr: true, + }, + { + id: 'nsite', + type: 'nsite', + name: 'nsite', + description: 'Deploy to Nostr as a static website', + // No baseURL for nsite - uses Rocket icon fallback + }, + { + id: 'netlify', + type: 'netlify', + name: 'Netlify', + description: 'Deploy to Netlify', + baseURL: 'https://api.netlify.com/api/v1', + apiKeyLabel: 'Personal Access Token', + apiKeyURL: 'https://app.netlify.com/user/applications#personal-access-tokens', + proxy: true, + }, + { + id: 'vercel', + type: 'vercel', + name: 'Vercel', + description: 'Deploy to Vercel', + baseURL: 'https://api.vercel.com', + apiKeyLabel: 'Access Token', + apiKeyURL: 'https://vercel.com/account/tokens', + proxy: true, + }, + { + id: 'cloudflare', + type: 'cloudflare', + name: 'Cloudflare', + description: 'Deploy to Cloudflare Workers', + baseURL: 'https://api.cloudflare.com/client/v4', + apiKeyLabel: 'API Token', + apiKeyURL: 'https://dash.cloudflare.com/profile/api-tokens', + accountIdLabel: 'Account ID', + accountIdURL: 'https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/', + proxy: true, + }, + { + id: 'deno', + type: 'deno', + name: 'Deno Deploy', + description: 'Deploy to Deno Deploy', + baseURL: 'https://api.deno.com/v1', + apiKeyLabel: 'Access Token', + apiKeyURL: 'https://dash.deno.com/account#access-tokens', + organizationIdLabel: 'Organization ID', + organizationIdURL: 'https://dash.deno.com/orgs', + proxy: true, + }, +]; diff --git a/src/pages/DeploySettings.tsx b/src/pages/DeploySettings.tsx index e25fe797..2f458271 100644 --- a/src/pages/DeploySettings.tsx +++ b/src/pages/DeploySettings.tsx @@ -8,6 +8,8 @@ import { useNetlifyOAuth } from '@/hooks/useNetlifyOAuth'; import { useVercelOAuth } from '@/hooks/useVercelOAuth'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import type { DeployProvider } from '@/contexts/DeploySettingsContext'; +import type { PresetDeployProvider } from '@/lib/deploy/types'; +import { PRESET_DEPLOY_PROVIDERS } from '@/lib/deployProviderPresets'; import { ExternalFavicon } from '@/components/ExternalFavicon'; import { ProviderConfigDialog } from '@/components/ProviderConfigDialog'; import { AddProviderDialog } from '@/components/AddProviderDialog'; @@ -30,30 +32,17 @@ import { } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; -interface PresetProvider { - id: string; - type: 'shakespeare' | 'netlify' | 'vercel' | 'nsite' | 'cloudflare' | 'deno'; - name: string; - description: string; - requiresNostr?: boolean; - apiKeyLabel?: string; - apiKeyURL?: string; - accountIdLabel?: string; - accountIdURL?: string; - organizationIdLabel?: string; - organizationIdURL?: string; - proxy?: boolean; -} - interface ProviderTileProps { provider: DeployProvider; - preset?: PresetProvider; + preset?: PresetDeployProvider; onClick: () => void; id: string; } -function ProviderTile({ provider, onClick, id }: ProviderTileProps) { - const url = getProviderUrl(provider); +function ProviderTile({ provider, preset, onClick, id }: ProviderTileProps) { + // Use baseURL from configured provider, falling back to preset baseURL + const baseURL = ('baseURL' in provider && provider.baseURL) || preset?.baseURL; + const { attributes, listeners, @@ -75,15 +64,11 @@ function ProviderTile({ provider, onClick, id }: ProviderTileProps) { onClick={onClick} className="flex flex-col items-center justify-center gap-2 p-4 rounded-lg border bg-card hover:bg-muted transition-colors text-center h-[120px] w-full" > - {url ? ( - } - /> - ) : ( - - )} + } + /> {provider.name} @@ -119,27 +104,21 @@ function AddProviderTile({ onClick }: AddProviderTileProps) { } interface PresetProviderTileProps { - preset: PresetProvider; + preset: PresetDeployProvider; onClick: () => void; } function PresetProviderTile({ preset, onClick }: PresetProviderTileProps) { - const url = getProviderUrl(preset); - return (