From b952889300ba74d039553a86c61ed3b2c990b30e Mon Sep 17 00:00:00 2001 From: Martin Donadieu Date: Tue, 14 Apr 2026 12:15:41 +0200 Subject: [PATCH 1/3] fix astro deprecation warnings --- apps/docs/src/components/doc/CopyPage.astro | 27 ++++--------------- apps/web/src/content.config.ts | 8 +++--- .../pages/tools/ios-udid-finder/result.astro | 19 +++---------- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/apps/docs/src/components/doc/CopyPage.astro b/apps/docs/src/components/doc/CopyPage.astro index ad343c435..e580df7e1 100644 --- a/apps/docs/src/components/doc/CopyPage.astro +++ b/apps/docs/src/components/doc/CopyPage.astro @@ -205,30 +205,13 @@ const translations = { throw new Error('Failed to fetch markdown from any source') } - // Copy to clipboard using the most reliable method - try { - await navigator.clipboard.writeText(content) - console.log('Copied to clipboard successfully') - } catch (clipboardError) { - console.error('Clipboard API failed, trying fallback:', clipboardError) - - // Fallback method using textarea - const textarea = document.createElement('textarea') - textarea.value = content - textarea.style.position = 'fixed' - textarea.style.opacity = '0' - document.body.appendChild(textarea) - textarea.focus() - textarea.select() - // @ts-expect-error execCommand is deprecated but used as fallback for older browsers - const success = document.execCommand('copy') - document.body.removeChild(textarea) - - if (!success) { - throw new Error('Fallback copy method also failed') - } + if (!navigator.clipboard?.writeText) { + throw new Error('Clipboard API unavailable') } + await navigator.clipboard.writeText(content) + console.log('Copied to clipboard successfully') + // Show success feedback if (title) { title.textContent = translations.copied diff --git a/apps/web/src/content.config.ts b/apps/web/src/content.config.ts index 644bc26be..0658dc136 100644 --- a/apps/web/src/content.config.ts +++ b/apps/web/src/content.config.ts @@ -1,11 +1,9 @@ import { glob } from 'astro/loaders' -import { defineCollection, z } from 'astro:content' +import { z } from 'astro/zod' +import { defineCollection } from 'astro:content' import { locales, type Locales } from './services/locale' -const localeSchema = z.custom( - (value) => typeof value === 'string' && locales.includes(value as Locales), - { message: 'Invalid locale' }, -) +const localeSchema = z.custom((value) => typeof value === 'string' && locales.includes(value as Locales), { message: 'Invalid locale' }) const blog = defineCollection({ loader: glob({ pattern: '**/*.md', base: 'src/content/blog', generateId: ({ entry }) => entry }), diff --git a/apps/web/src/pages/tools/ios-udid-finder/result.astro b/apps/web/src/pages/tools/ios-udid-finder/result.astro index a65fd2f63..39f45f8f0 100644 --- a/apps/web/src/pages/tools/ios-udid-finder/result.astro +++ b/apps/web/src/pages/tools/ios-udid-finder/result.astro @@ -142,22 +142,11 @@ const signingDocsHref = getRelativeLocaleUrl(Astro.locals.locale, 'docs/cli/clou } async function copyText(value: string): Promise { - try { - await navigator.clipboard.writeText(value) - } catch { - const helper = document.createElement('textarea') - helper.value = value - helper.setAttribute('readonly', 'true') - helper.style.position = 'absolute' - helper.style.opacity = '0' - document.body.append(helper) - helper.select() - const copied = document.execCommand('copy') - helper.remove() - if (!copied) { - throw new Error('Copy failed') - } + if (!navigator.clipboard?.writeText) { + throw new Error('Clipboard API unavailable') } + + await navigator.clipboard.writeText(value) } function bindCopyButtons(): void { From d8b478d184ce1794a9bc080c997f8e60072c18fe Mon Sep 17 00:00:00 2001 From: Martin Donadieu Date: Tue, 14 Apr 2026 12:33:17 +0200 Subject: [PATCH 2/3] restore clipboard fallback paths --- apps/docs/src/components/doc/CopyPage.astro | 61 ++++++++++++++----- .../pages/tools/ios-udid-finder/result.astro | 27 +++++++- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/apps/docs/src/components/doc/CopyPage.astro b/apps/docs/src/components/doc/CopyPage.astro index e580df7e1..45bac3e56 100644 --- a/apps/docs/src/components/doc/CopyPage.astro +++ b/apps/docs/src/components/doc/CopyPage.astro @@ -127,7 +127,7 @@ const translations = { - +