AI-native design editor. Open-source Figma alternative.
feat: ask for donations to support OpenPencil (#1725)
Danila Poyarkov27262677c6f3
diff --git a/.github/FUNDING.yml b/.github/FUNDING.ymlnew file mode 100644index 000000000..3425aac46--- /dev/null+++ b/.github/FUNDING.yml@@ -0,0 +1 @@+ko_fi: dannotediff --git a/README.md b/README.mdindex f6763ead9..26e35f89b 100644--- a/README.md+++ b/README.md@@ -4,6 +4,7 @@[](https://www.npmjs.com/package/@open-pencil/cli)[](https://discord.gg/4wXc9fuZfm)[](https://github.com/open-pencil/open-pencil/discussions)+[](https://ko-fi.com/dannote)Open-source design editor. Opens `.fig` and `.pen` design files, includes built-in AI, and ships as a programmable toolkit with a headless Vue SDK for building custom editors.@@ -212,6 +213,10 @@ See the [roadmap](https://openpencil.dev/development/roadmap) for product direct- **[GitHub Discussions](https://github.com/open-pencil/open-pencil/discussions)** — [Q&A](https://github.com/open-pencil/open-pencil/discussions/categories/q-a) for help, [Ideas](https://github.com/open-pencil/open-pencil/discussions/categories/ideas) for feature proposals, [Show and tell](https://github.com/open-pencil/open-pencil/discussions/categories/show-and-tell) for what you built; maintainers post [Announcements](https://github.com/open-pencil/open-pencil/discussions/categories/announcements) there- **[Issues](https://github.com/open-pencil/open-pencil/issues)** — reproducible bugs; report security problems through a [private advisory](https://github.com/open-pencil/open-pencil/security/advisories/new)+## Support++OpenPencil is free and open source. Donations help speed up its development and cover the servers and services it runs on. You can [donate on Ko-fi](https://ko-fi.com/dannote).+## Contributing```shdiff --git a/changes/1725/added.md b/changes/1725/added.mdnew file mode 100644index 000000000..456108f76--- /dev/null+++ b/changes/1725/added.md@@ -0,0 +1 @@+- Release builds occasionally ask whether you would like to donate toward OpenPencil's development and infrastructure, and File → Support OpenPencil… and Settings → General link to the donation page.diff --git a/desktop/generated/menu.json b/desktop/generated/menu.jsonindex 4f76f3f33..b4bf014b6 100644--- a/desktop/generated/menu.json+++ b/desktop/generated/menu.json@@ -34,6 +34,11 @@"label": "Report a Problem…","feature": "reports"},+ {+ "id": "support-openpencil",+ "label": "Support OpenPencil…",+ "feature": "donation"+ },{"type": "separator"},diff --git a/packages/feedback/src/contract/describe.ts b/packages/feedback/src/contract/describe.tsindex 9cb920863..8cc2fd565 100644--- a/packages/feedback/src/contract/describe.ts+++ b/packages/feedback/src/contract/describe.ts@@ -50,6 +50,10 @@ const EVENT_DESCRIPTIONS: {properties: {source: 'Where: right after the first-run welcome, on a later launch, or in Settings.'}+ },+ donate_clicked: {+ description: 'The donation page was opened; whether a donation followed is not known.',+ properties: { source: 'Where: the question the app asks, the File menu, or Settings.' }}}diff --git a/packages/feedback/src/contract/schema.ts b/packages/feedback/src/contract/schema.tsindex 967a897aa..7ec393a67 100644--- a/packages/feedback/src/contract/schema.ts+++ b/packages/feedback/src/contract/schema.ts@@ -60,6 +60,10 @@ export type UsageStatsAnswer = (typeof USAGE_STATS_ANSWERS)[number]export const CONSENT_SOURCES = ['welcome', 'prompt', 'settings'] as constexport type ConsentSource = (typeof CONSENT_SOURCES)[number]+/** Where a person chose to donate: the question the app asks, the File menu, or Settings. */+export const DONATION_SOURCES = ['prompt', 'menu', 'settings'] as const+export type DonationSource = (typeof DONATION_SOURCES)[number]+const appVersionSchema = v.pipe(v.string(),v.maxLength(32),@@ -119,6 +123,11 @@ export const usageEventSchema = v.variant('name', [name: v.literal('usage_stats_enabled'),timestamp: timestampSchema,source: v.picklist(CONSENT_SOURCES)+ }),+ v.strictObject({+ name: v.literal('donate_clicked'),+ timestamp: timestampSchema,+ source: v.picklist(DONATION_SOURCES)})])export type UsageEvent = v.InferOutput<typeof usageEventSchema>diff --git a/packages/feedback/tests/contract.test.ts b/packages/feedback/tests/contract.test.tsindex ee42454c8..6866cbca8 100644--- a/packages/feedback/tests/contract.test.ts+++ b/packages/feedback/tests/contract.test.ts@@ -17,7 +17,8 @@ describe('contract descriptions', () => {'document_opened','document_exported','ai_reply_finished',- 'usage_stats_enabled'+ 'usage_stats_enabled',+ 'donate_clicked'])for (const event of events) {expect(event.description).not.toBe('')diff --git a/packages/vue/src/i18n/locales/de/diagnostics.json b/packages/vue/src/i18n/locales/de/diagnostics.jsonindex 202f31f1c..de86bcf65 100644--- a/packages/vue/src/i18n/locales/de/diagnostics.json+++ b/packages/vue/src/i18n/locales/de/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "Statistik teilen","sharingQuestionAccepted": "Danke. Du kannst das in den Datenschutz-Einstellungen ändern.","sharingQuestionDeclined": "Die Nutzungsstatistik bleibt aus. Du kannst das in den Datenschutz-Einstellungen ändern.",+ "supportTitle": "OpenPencil unterstützen",+ "supportDescription": "Gefällt dir OpenPencil? Es ist kostenlos und quelloffen, und eine Spende beschleunigt die Entwicklung und deckt die Server und Dienste, auf denen es läuft.",+ "supportNotNow": "Nicht jetzt",+ "supportDonate": "Spenden","sharingLocalData": "Nutzung und Diagnose speichern ihre Daten auf diesem Gerät. Diagnosedaten verlassen es nur in einem Bericht, den du selbst sendest.","reportError": "Melden…","reportErrorTitle": "Diesen Fehler melden",diff --git a/packages/vue/src/i18n/locales/de/menu.json b/packages/vue/src/i18n/locales/de/menu.jsonindex e50bd6e21..dc7e3c5de 100644--- a/packages/vue/src/i18n/locales/de/menu.json+++ b/packages/vue/src/i18n/locales/de/menu.json@@ -88,5 +88,6 @@"saveTo": "Speichern in…","showVersionHistory": "Versionsverlauf anzeigen","saveToVersionHistory": "Im Versionsverlauf speichern…",- "reportProblem": "Problem melden…"+ "reportProblem": "Problem melden…",+ "supportOpenPencil": "OpenPencil unterstützen…"}diff --git a/packages/vue/src/i18n/locales/es/diagnostics.json b/packages/vue/src/i18n/locales/es/diagnostics.jsonindex a84cea97d..9c07322fd 100644--- a/packages/vue/src/i18n/locales/es/diagnostics.json+++ b/packages/vue/src/i18n/locales/es/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "Compartir estadísticas","sharingQuestionAccepted": "Gracias. Puedes cambiarlo en los ajustes de Privacidad.","sharingQuestionDeclined": "Las estadísticas de uso seguirán desactivadas. Puedes cambiarlo en los ajustes de Privacidad.",+ "supportTitle": "Apoyar OpenPencil",+ "supportDescription": "¿Te gusta OpenPencil? Es gratuito y de código abierto, y una donación ayuda a acelerar su desarrollo y cubre los servidores y servicios en los que funciona.",+ "supportNotNow": "Ahora no",+ "supportDonate": "Donar","sharingLocalData": "Uso y Diagnóstico guardan sus registros en este dispositivo. Los diagnósticos solo salen de él en un informe que tú decidas enviar.","reportError": "Informar…","reportErrorTitle": "Informar de este error",diff --git a/packages/vue/src/i18n/locales/es/menu.json b/packages/vue/src/i18n/locales/es/menu.jsonindex b64176828..2bada40d1 100644--- a/packages/vue/src/i18n/locales/es/menu.json+++ b/packages/vue/src/i18n/locales/es/menu.json@@ -88,5 +88,6 @@"saveTo": "Guardar en…","showVersionHistory": "Mostrar historial de versiones","saveToVersionHistory": "Guardar en el historial de versiones…",- "reportProblem": "Informar de un problema…"+ "reportProblem": "Informar de un problema…",+ "supportOpenPencil": "Apoyar OpenPencil…"}diff --git a/packages/vue/src/i18n/locales/fr/diagnostics.json b/packages/vue/src/i18n/locales/fr/diagnostics.jsonindex 7202c6dee..926987571 100644--- a/packages/vue/src/i18n/locales/fr/diagnostics.json+++ b/packages/vue/src/i18n/locales/fr/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "Partager les statistiques","sharingQuestionAccepted": "Merci. Vous pouvez modifier ce choix dans les réglages Confidentialité.","sharingQuestionDeclined": "Les statistiques d'utilisation restent désactivées. Vous pouvez modifier ce choix dans les réglages Confidentialité.",+ "supportTitle": "Soutenir OpenPencil",+ "supportDescription": "Vous aimez OpenPencil ? Il est gratuit et open source, et un don aide à accélérer son développement et couvre les serveurs et services sur lesquels il fonctionne.",+ "supportNotNow": "Plus tard",+ "supportDonate": "Faire un don","sharingLocalData": "Utilisation et Diagnostics conservent leurs données sur cet appareil. Les diagnostics n’en sortent que dans un rapport que vous choisissez d’envoyer.","reportError": "Signaler…","reportErrorTitle": "Signaler cette erreur",diff --git a/packages/vue/src/i18n/locales/fr/menu.json b/packages/vue/src/i18n/locales/fr/menu.jsonindex d840b8018..6bf8992ab 100644--- a/packages/vue/src/i18n/locales/fr/menu.json+++ b/packages/vue/src/i18n/locales/fr/menu.json@@ -88,5 +88,6 @@"saveTo": "Enregistrer dans…","showVersionHistory": "Afficher l’historique des versions","saveToVersionHistory": "Enregistrer dans l’historique des versions…",- "reportProblem": "Signaler un problème…"+ "reportProblem": "Signaler un problème…",+ "supportOpenPencil": "Soutenir OpenPencil…"}diff --git a/packages/vue/src/i18n/locales/it/diagnostics.json b/packages/vue/src/i18n/locales/it/diagnostics.jsonindex aab7285b0..c0ef499b9 100644--- a/packages/vue/src/i18n/locales/it/diagnostics.json+++ b/packages/vue/src/i18n/locales/it/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "Condividi statistiche","sharingQuestionAccepted": "Grazie. Puoi cambiare questa scelta nelle impostazioni Privacy.","sharingQuestionDeclined": "Le statistiche di utilizzo restano disattivate. Puoi cambiare questa scelta nelle impostazioni Privacy.",+ "supportTitle": "Sostieni OpenPencil",+ "supportDescription": "Ti piace OpenPencil? È gratuito e open source, e una donazione aiuta ad accelerarne lo sviluppo e copre i server e i servizi su cui funziona.",+ "supportNotNow": "Non ora",+ "supportDonate": "Dona","sharingLocalData": "Utilizzo e Diagnostica conservano i loro dati su questo dispositivo. I dati diagnostici lo lasciano solo in una segnalazione che scegli di inviare.","reportError": "Segnala…","reportErrorTitle": "Segnala questo errore",diff --git a/packages/vue/src/i18n/locales/it/menu.json b/packages/vue/src/i18n/locales/it/menu.jsonindex 8f7e2e990..ebd2a4418 100644--- a/packages/vue/src/i18n/locales/it/menu.json+++ b/packages/vue/src/i18n/locales/it/menu.json@@ -88,5 +88,6 @@"saveTo": "Salva in…","showVersionHistory": "Mostra cronologia versioni","saveToVersionHistory": "Salva nella cronologia versioni…",- "reportProblem": "Segnala un problema…"+ "reportProblem": "Segnala un problema…",+ "supportOpenPencil": "Sostieni OpenPencil…"}diff --git a/packages/vue/src/i18n/locales/ja/diagnostics.json b/packages/vue/src/i18n/locales/ja/diagnostics.jsonindex 4a7c81963..8858dcb53 100644--- a/packages/vue/src/i18n/locales/ja/diagnostics.json+++ b/packages/vue/src/i18n/locales/ja/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "統計を共有","sharingQuestionAccepted": "ありがとうございます。プライバシーの設定でいつでも変更できます。","sharingQuestionDeclined": "利用統計はオフのままです。プライバシーの設定でいつでも変更できます。",+ "supportTitle": "OpenPencil を支援",+ "supportDescription": "OpenPencil を気に入っていただけましたか?無料のオープンソースです。寄付は開発のスピードアップと、動作に必要なサーバーやサービスの費用に役立ちます。",+ "supportNotNow": "今はしない",+ "supportDonate": "寄付する","sharingLocalData": "使用状況と診断の記録はこのデバイスに保存されます。診断が外部に送られるのは、あなたが送信を選んだレポートの中だけです。","reportError": "報告…","reportErrorTitle": "このエラーを報告",diff --git a/packages/vue/src/i18n/locales/ja/menu.json b/packages/vue/src/i18n/locales/ja/menu.jsonindex 60438b135..b79ad8f16 100644--- a/packages/vue/src/i18n/locales/ja/menu.json+++ b/packages/vue/src/i18n/locales/ja/menu.json@@ -88,5 +88,6 @@"saveTo": "保存先を選んで保存…","showVersionHistory": "バージョン履歴を表示","saveToVersionHistory": "バージョン履歴に保存…",- "reportProblem": "問題を報告…"+ "reportProblem": "問題を報告…",+ "supportOpenPencil": "OpenPencil を支援…"}diff --git a/packages/vue/src/i18n/locales/pl/diagnostics.json b/packages/vue/src/i18n/locales/pl/diagnostics.jsonindex 98128a89e..da6e490a4 100644--- a/packages/vue/src/i18n/locales/pl/diagnostics.json+++ b/packages/vue/src/i18n/locales/pl/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "Udostępniaj statystyki","sharingQuestionAccepted": "Dziękujemy. Możesz to zmienić w ustawieniach prywatności.","sharingQuestionDeclined": "Statystyki użycia pozostaną wyłączone. Możesz to zmienić w ustawieniach prywatności.",+ "supportTitle": "Wesprzyj OpenPencil",+ "supportDescription": "Podoba ci się OpenPencil? Jest darmowy i otwartoźródłowy, a darowizna pomaga przyspieszyć jego rozwój i pokrywa koszty serwerów oraz usług, na których działa.",+ "supportNotNow": "Nie teraz",+ "supportDonate": "Wesprzyj","sharingLocalData": "Użycie i Diagnostyka przechowują swoje dane na tym urządzeniu. Dane diagnostyczne opuszczają je tylko w zgłoszeniu, które sam zdecydujesz się wysłać.","reportError": "Zgłoś…","reportErrorTitle": "Zgłoś ten błąd",diff --git a/packages/vue/src/i18n/locales/pl/menu.json b/packages/vue/src/i18n/locales/pl/menu.jsonindex a7f251da4..c530fe8f1 100644--- a/packages/vue/src/i18n/locales/pl/menu.json+++ b/packages/vue/src/i18n/locales/pl/menu.json@@ -88,5 +88,6 @@"saveTo": "Zapisz w…","showVersionHistory": "Pokaż historię wersji","saveToVersionHistory": "Zapisz w historii wersji…",- "reportProblem": "Zgłoś problem…"+ "reportProblem": "Zgłoś problem…",+ "supportOpenPencil": "Wesprzyj OpenPencil…"}diff --git a/packages/vue/src/i18n/locales/ru/diagnostics.json b/packages/vue/src/i18n/locales/ru/diagnostics.jsonindex 81a1c25f3..050ec984a 100644--- a/packages/vue/src/i18n/locales/ru/diagnostics.json+++ b/packages/vue/src/i18n/locales/ru/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "Делиться статистикой","sharingQuestionAccepted": "Спасибо. Это можно изменить в настройках конфиденциальности.","sharingQuestionDeclined": "Статистика использования останется выключенной. Это можно изменить в настройках конфиденциальности.",+ "supportTitle": "Поддержать OpenPencil",+ "supportDescription": "Нравится OpenPencil? Он бесплатный и с открытым исходным кодом, а пожертвование помогает ускорить разработку и покрывает серверы и сервисы, на которых он работает.",+ "supportNotNow": "Не сейчас",+ "supportDonate": "Поддержать","sharingLocalData": "Использование и Диагностика хранят записи на этом устройстве. Данные диагностики покидают его только в отчёте, который вы сами решите отправить.","reportError": "Сообщить…","reportErrorTitle": "Сообщить об этой ошибке",diff --git a/packages/vue/src/i18n/locales/ru/menu.json b/packages/vue/src/i18n/locales/ru/menu.jsonindex eea03fa08..14dbd7de3 100644--- a/packages/vue/src/i18n/locales/ru/menu.json+++ b/packages/vue/src/i18n/locales/ru/menu.json@@ -88,5 +88,6 @@"saveTo": "Сохранить в…","showVersionHistory": "Показать историю версий","saveToVersionHistory": "Сохранить в историю версий…",- "reportProblem": "Сообщить о проблеме…"+ "reportProblem": "Сообщить о проблеме…",+ "supportOpenPencil": "Поддержать OpenPencil…"}diff --git a/packages/vue/src/i18n/locales/zh-cn/diagnostics.json b/packages/vue/src/i18n/locales/zh-cn/diagnostics.jsonindex f111b2486..82155b2d4 100644--- a/packages/vue/src/i18n/locales/zh-cn/diagnostics.json+++ b/packages/vue/src/i18n/locales/zh-cn/diagnostics.json@@ -84,6 +84,10 @@"sharingQuestionAccept": "共享统计","sharingQuestionAccepted": "谢谢。你可以在隐私设置中更改此选项。","sharingQuestionDeclined": "使用统计将保持关闭。你可以在隐私设置中更改此选项。",+ "supportTitle": "支持 OpenPencil",+ "supportDescription": "喜欢 OpenPencil 吗?它免费且开源,捐赠有助于加快开发,并支付其运行所需的服务器和服务费用。",+ "supportNotNow": "以后再说",+ "supportDonate": "捐赠","sharingLocalData": "使用情况和诊断的记录保存在此设备上。诊断数据只会随你选择发送的报告离开此设备。","reportError": "报告…","reportErrorTitle": "报告此错误",diff --git a/packages/vue/src/i18n/locales/zh-cn/menu.json b/packages/vue/src/i18n/locales/zh-cn/menu.jsonindex f71dfb977..9712a1e19 100644--- a/packages/vue/src/i18n/locales/zh-cn/menu.json+++ b/packages/vue/src/i18n/locales/zh-cn/menu.json@@ -88,5 +88,6 @@"saveTo": "保存到…","showVersionHistory": "显示版本历史","saveToVersionHistory": "保存到版本历史…",- "reportProblem": "报告问题…"+ "reportProblem": "报告问题…",+ "supportOpenPencil": "支持 OpenPencil…"}diff --git a/packages/vue/src/i18n/messages/diagnostics.ts b/packages/vue/src/i18n/messages/diagnostics.tsindex 218162ace..de2333aec 100644--- a/packages/vue/src/i18n/messages/diagnostics.ts+++ b/packages/vue/src/i18n/messages/diagnostics.ts@@ -95,6 +95,11 @@ export const diagnosticsMessageDefaults = {sharingQuestionAccept: 'Share stats',sharingQuestionAccepted: 'Thank you. You can change this in Privacy settings.',sharingQuestionDeclined: 'Usage stats stay off. You can change this in Privacy settings.',+ supportTitle: 'Support OpenPencil',+ supportDescription:+ 'Enjoying OpenPencil? It’s free and open source, and a donation helps speed up its development and covers the servers and services it runs on.',+ supportNotNow: 'Not now',+ supportDonate: 'Donate',sharingLocalData:'Usage and Diagnostics keep their records on this device. Diagnostics leave it only in a report you choose to send.',reportError: 'Report…',diff --git a/packages/vue/src/i18n/messages/menu.ts b/packages/vue/src/i18n/messages/menu.tsindex 7820bad51..64a19e9e0 100644--- a/packages/vue/src/i18n/messages/menu.ts+++ b/packages/vue/src/i18n/messages/menu.ts@@ -14,6 +14,7 @@ export const menuMessageDefaults = {openTour: 'Open the Tour',diagnostics: 'Diagnostics…',reportProblem: 'Report a problem…',+ supportOpenPencil: 'Support OpenPencil…',save: 'Save',saveAs: 'Save as…',saveTo: 'Save to…',diff --git a/src/App.vue b/src/App.vueindex dfe69fe32..015eda571 100644--- a/src/App.vue+++ b/src/App.vue@@ -24,6 +24,7 @@ import { kickSyncEngine } from '@/app/storage/sync'import { prepareForReload } from '@/app/tabs'import { CloudHosts } from '@/components/cloud/integration'import UnsavedChangesDialog from '@/components/document/UnsavedChangesDialog.vue'+import DonationPrompt from '@/components/donation/DonationPrompt.vue'import PublishLibraryDialog from '@/components/libraries/PublishLibraryDialog.vue'import LibraryUpdateReviewDialog from '@/components/libraries/review/LibraryUpdateReviewDialog.vue'import ReportDialogHost from '@/components/reports/ReportDialogHost.vue'@@ -86,6 +87,7 @@ onMounted(() => {<PublishLibraryDialog /><LibraryUpdateReviewDialog /><UsageStatsPrompt />+ <DonationPrompt /><ReportDialogHost /><AppToaster /><VoiceCallAudio />diff --git a/src/app/donation/funding.ts b/src/app/donation/funding.tsnew file mode 100644index 000000000..776cb535e--- /dev/null+++ b/src/app/donation/funding.ts@@ -0,0 +1,45 @@+import * as v from 'valibot'+import { parse } from 'yaml'++const handleSchema = v.pipe(v.string(), v.regex(/^[\w.-]{1,100}$/))+const httpsURLSchema = v.pipe(v.string(), v.url(), v.startsWith('https://'))++/** The platforms `FUNDING.yml` names, as GitHub links each one; others are skipped. */+const PLATFORMS = {+ github: { value: handleSchema, url: (id: string) => `https://github.com/sponsors/${id}` },+ ko_fi: { value: handleSchema, url: (id: string) => `https://ko-fi.com/${id}` },+ open_collective: { value: handleSchema, url: (id: string) => `https://opencollective.com/${id}` },+ liberapay: { value: handleSchema, url: (id: string) => `https://liberapay.com/${id}` },+ patreon: { value: handleSchema, url: (id: string) => `https://www.patreon.com/${id}` },+ polar: { value: handleSchema, url: (id: string) => `https://polar.sh/${id}` },+ buy_me_a_coffee: { value: handleSchema, url: (id: string) => `https://buymeacoffee.com/${id}` },+ custom: { value: httpsURLSchema, url: (url: string) => url }+} as const++const fundingSchema = v.nullable(+ v.pipe(+ v.custom<object>((value) => typeof value === 'object' && !Array.isArray(value)),+ v.record(v.string(), v.nullable(v.union([v.string(), v.array(v.string())])))+ )+)++function isPlatform(name: string): name is keyof typeof PLATFORMS {+ return Object.hasOwn(PLATFORMS, name)+}++/**+ * The donation page a repository's `FUNDING.yml` names first, or `null` when it names none this+ * app can link to. A file that is not a mapping of platforms to names throws, so the build fails+ * rather than dropping the link.+ */+export function fundingURL(text: string): string | null {+ const funding = v.parse(fundingSchema, parse(text)) ?? {}+ for (const [name, entry] of Object.entries(funding)) {+ if (!isPlatform(name)) continue+ const platform = PLATFORMS[name]+ const first = Array.isArray(entry) ? entry[0] : entry+ const value = v.safeParse(platform.value, first)+ if (value.success) return platform.url(value.output)+ }+ return null+}diff --git a/src/app/donation/index.ts b/src/app/donation/index.tsnew file mode 100644index 000000000..c988899d8--- /dev/null+++ b/src/app/donation/index.ts@@ -0,0 +1,62 @@+import { ref } from 'vue'++import type { DonationSource } from '@open-pencil/feedback/contract'++import { appPreferences, updateDonationPreferences } from '@/app/settings/preferences/store'+import { openExternalLink } from '@/app/shell/ui'+import { trackUsage } from '@/app/telemetry'++const DAY = 24 * 60 * 60 * 1000+/** How long after the first launch the question first shows. */+export const FIRST_ASK_DELAY = 3 * DAY+/** How long Not now keeps it away. */+export const NOT_NOW_DELAY = 14 * DAY+/** How long it stays away once the person went to donate, which the app cannot confirm. */+export const DONATED_DELAY = 365 * DAY++/** The donation page `.github/FUNDING.yml` names; without one the app never asks or links. */+export const DONATION_URL: string | null =+ typeof __OPENPENCIL_DONATION_URL__ === 'string' ? __OPENPENCIL_DONATION_URL__ : null++/** Whether the donation question shows. */+export const donationPrompt = ref(false)++/**+ * Shows the question once it is due. The first time the app asks, it only starts the clock, so+ * the question waits `FIRST_ASK_DELAY` from the first launch.+ */+export function offerDonationPrompt(now = Date.now(), url = DONATION_URL): void {+ if (!url) return+ const { promptAfter } = appPreferences.value.donation+ if (promptAfter === null) {+ startDonationClock(now)+ return+ }+ if (now >= promptAfter) donationPrompt.value = true+}++/** Starts the clock on a launch that asks something else, such as the first-run welcome. */+export function startDonationClock(now = Date.now()): void {+ if (appPreferences.value.donation.promptAfter !== null) return+ updateDonationPreferences({ promptAfter: now + FIRST_ASK_DELAY })+}++/** Not now: asks again after `NOT_NOW_DELAY`. */+export function postponeDonation(now = Date.now()): void {+ updateDonationPreferences({ promptAfter: now + NOT_NOW_DELAY })+ donationPrompt.value = false+}++/** Records a choice to donate: the question stays away for a year, and shared stats count it. */+export function recordDonation(source: DonationSource, now = Date.now()): void {+ updateDonationPreferences({ promptAfter: now + DONATED_DELAY })+ donationPrompt.value = false+ trackUsage({ name: 'donate_clicked', source })+}++/** Opens the donation page in the browser. */+export function donate(source: DonationSource): void {+ if (!DONATION_URL) return+ recordDonation(source)+ void openExternalLink(DONATION_URL)+}diff --git a/src/app/settings/preferences/store.ts b/src/app/settings/preferences/store.tsindex 15cda6b8e..e6d2d28df 100644--- a/src/app/settings/preferences/store.ts+++ b/src/app/settings/preferences/store.ts@@ -75,6 +75,11 @@ export interface SharingPreferences {export const AI_SETUP_STATES = ['pending', 'done'] as constexport type AISetupState = (typeof AI_SETUP_STATES)[number]+/** When the donation question may show again, as a time in milliseconds; `null` before it was ever due. */+export interface DonationPreferences {+ promptAfter: number | null+}+/** Which events send a system notification while OpenPencil is out of view. */export interface NotificationPreferences {/** An agent waits on a permission request. */@@ -119,6 +124,7 @@ export interface AppPreferences {aiSetup: AISetupState}sharing: SharingPreferences+ donation: DonationPreferencesnotifications: NotificationPreferences}@@ -150,6 +156,7 @@ export const DEFAULT_APP_PREFERENCES: Readonly<AppPreferences> = {toolbar: structuredClone(DEFAULT_TOOLBAR_LAYOUT),onboarding: { aiSetup: 'pending' },sharing: { dailyPing: true, usageStats: 'unset' },+ donation: { promptAfter: null },notifications: { agentNeedsInput: true, agentFinished: false, agentFailed: false }}@@ -237,6 +244,12 @@ const appPreferencesSchema = section({dailyPing: v.fallback(v.boolean(), defaults.sharing.dailyPing),usageStats: v.fallback(v.picklist(USAGE_STATS_CONSENTS), defaults.sharing.usageStats)}),+ donation: section({+ promptAfter: v.fallback(+ v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0))),+ defaults.donation.promptAfter+ )+ }),notifications: section({agentNeedsInput: v.fallback(v.boolean(), defaults.notifications.agentNeedsInput),agentFinished: v.fallback(v.boolean(), defaults.notifications.agentFinished),@@ -286,6 +299,13 @@ export function updateSharingPreferences(changes: Partial<SharingPreferences>):}}+export function updateDonationPreferences(changes: Partial<DonationPreferences>): void {+ appPreferences.value = {+ ...appPreferences.value,+ donation: { ...appPreferences.value.donation, ...changes }+ }+}+export function updateNotificationPreferences(changes: Partial<NotificationPreferences>): void {appPreferences.value = {...appPreferences.value,diff --git a/src/app/shell/menu/app-menu.ts b/src/app/shell/menu/app-menu.tsindex f8de35273..0b34f929a 100644--- a/src/app/shell/menu/app-menu.ts+++ b/src/app/shell/menu/app-menu.ts@@ -25,6 +25,7 @@ import type {} from '@open-pencil/vue/primitives/CommandPalette'import { openTour } from '@/app/demo/document'+import { donate } from '@/app/donation'import { useEditorStore } from '@/app/editor/active-store'import { openReportDialog } from '@/app/reports/state'import { openSettingsDialog } from '@/app/settings/dialog'@@ -112,6 +113,7 @@ export function useAppMenu() {'open-tour': 'openTour',diagnostics: 'diagnostics','report-problem': 'reportProblem',+ 'support-openpencil': 'supportOpenPencil',save: 'save','save-as': 'saveAs','save-to': 'saveTo',@@ -196,6 +198,7 @@ export function useAppMenu() {settings: openSettingsDialog,diagnostics: () => openSettingsDialog('diagnostics'),'report-problem': () => openReportDialog(),+ 'support-openpencil': () => donate('menu'),'export-png': () => exportSelection('png'),'export-svg': () => exportSelection('svg'),'export-pptx': () => exportSelection('pptx'),diff --git a/src/app/shell/menu/features.ts b/src/app/shell/menu/features.tsindex aa9308678..b06eeba5f 100644--- a/src/app/shell/menu/features.ts+++ b/src/app/shell/menu/features.ts@@ -2,6 +2,7 @@ import { invoke } from '@tauri-apps/api/core'import { computed, watch } from 'vue'import { isCloudBinding } from '@/app/cloud/integration'+import { DONATION_URL } from '@/app/donation'import { useEditorStore } from '@/app/editor/active-store'import { REPORTS_ENABLED } from '@/app/reports/state'import { showsDocument } from '@/app/tabs'@@ -18,7 +19,8 @@ const available: Record<AppMenuFeature, () => boolean> = {'local-file': () => store.hasWritableSource() && !store.getStorageBinding(),// Version history lives on the Cloud server that keeps the document.'cloud-document': () => isCloudBinding(store.getStorageBinding()),- reports: () => REPORTS_ENABLED+ reports: () => REPORTS_ENABLED,+ donation: () => DONATION_URL !== null}/** Whether a menu item that waits for a feature shows; items without one always do. */diff --git a/src/app/shell/menu/schema/index.ts b/src/app/shell/menu/schema/index.tsindex a028abf76..bd5f23d9c 100644--- a/src/app/shell/menu/schema/index.ts+++ b/src/app/shell/menu/schema/index.ts@@ -44,6 +44,13 @@ export const APP_MENU_SCHEMA = [handler: 'shell',palette: { keywords: ['bug', 'issue', 'feedback', 'crash', 'support'] }},+ {+ id: 'support-openpencil',+ feature: 'donation',+ label: 'Support OpenPencil…',+ handler: 'shell',+ palette: { keywords: ['donate', 'donation', 'sponsor', 'fund', 'tip'] }+ },{ type: 'separator' },{ id: 'save', feature: 'document', label: 'Save', shortcut: 'MOD+S' },{ id: 'save-as', feature: 'document', label: 'Save As…', shortcut: 'MOD+SHIFT+S' },diff --git a/src/app/shell/menu/schema/types.ts b/src/app/shell/menu/schema/types.tsindex 041e8152b..cbb1fb821 100644--- a/src/app/shell/menu/schema/types.ts+++ b/src/app/shell/menu/schema/types.ts@@ -38,9 +38,10 @@ export type AppMenuHandler = 'editor' | 'shell'* A feature an item or a whole menu waits for: it shows only while the feature is available* (`./features`). `document`: the tab in front holds a document, not Home or a New file tab;* `local-file`: that document is backed by a file on disk; `cloud-document`: it is kept by a- * Cloud server; `reports`: the build sends problem reports, which only official releases do.+ * Cloud server; `reports`: the build sends problem reports, which only official releases do;+ * `donation`: the build names a donation page, from the repository's `.github/FUNDING.yml`.*/-export type AppMenuFeature = 'document' | 'local-file' | 'cloud-document' | 'reports'+export type AppMenuFeature = 'document' | 'local-file' | 'cloud-document' | 'reports' | 'donation'export interface AppMenuActionItem {type?: 'item'diff --git a/src/app/shell/menu/shell.ts b/src/app/shell/menu/shell.tsindex 577a2fea4..bf9300928 100644--- a/src/app/shell/menu/shell.ts+++ b/src/app/shell/menu/shell.ts@@ -2,6 +2,7 @@ import { useI18n } from '@open-pencil/vue/i18n'import { openTour } from '@/app/demo/document'import { requestAppExit } from '@/app/document/close/exit'+import { donate } from '@/app/donation'import { useActiveEditorStoreRef } from '@/app/editor/active-store'import { openReportDialog } from '@/app/reports/state'import { openSettingsDialog } from '@/app/settings/dialog'@@ -63,6 +64,7 @@ export function useShellMenu() {settings: openSettingsDialog,diagnostics: () => openSettingsDialog('diagnostics'),'report-problem': () => openReportDialog(),+ 'support-openpencil': () => donate('menu'),'snap-geometry': () => {const current = appPreferences.value.editing.snapping.geometrysetSnappingPreference('geometry', !current)diff --git a/src/components/donation/DonationPrompt.stories.ts b/src/components/donation/DonationPrompt.stories.tsnew file mode 100644index 000000000..fb9d51056--- /dev/null+++ b/src/components/donation/DonationPrompt.stories.ts@@ -0,0 +1,35 @@+import type { Meta, StoryObj } from '@storybook/vue3-vite'+import { expect, userEvent, within } from 'storybook/test'++import { donationPrompt } from '@/app/donation'+import { appPreferences } from '@/app/settings/preferences/store'++import DonationPrompt from './DonationPrompt.vue'++const meta = {+ title: 'App/Shell/Donation Prompt',+ component: DonationPrompt,+ render: () => ({+ components: { DonationPrompt },+ setup() {+ donationPrompt.value = true+ return {}+ },+ template: '<div class="h-60"><DonationPrompt /></div>'+ })+} satisfies Meta<typeof DonationPrompt>++export default meta+type Story = StoryObj<typeof meta>++export const Asking: Story = {}++/** Not now closes the card and asks again later. */+export const NotNow: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement)+ await userEvent.click(canvas.getByRole('button', { name: 'Not now' }))+ await expect(canvas.queryByRole('complementary')).toBeNull()+ await expect(appPreferences.value.donation.promptAfter).toBeGreaterThan(Date.now())+ }+}diff --git a/src/components/donation/DonationPrompt.vue b/src/components/donation/DonationPrompt.vuenew file mode 100644index 000000000..a3b95794b--- /dev/null+++ b/src/components/donation/DonationPrompt.vue@@ -0,0 +1,44 @@+<script setup lang="ts">+import { tv } from 'tailwind-variants'+import { useId } from 'vue'++import { useI18n } from '@open-pencil/vue/i18n'++import { donate, donationPrompt, postponeDonation } from '@/app/donation'+import AppButton from '@/components/ui/button/AppButton.vue'+import donationTheme from '@/theme/donation'+import promptTheme from '@/theme/sharing/prompt'+import questionTheme from '@/theme/sharing/question'++/** The donation question, in the corner the usage stats question uses, on launches it is due. */+const { diagnostics } = useI18n()+const prompt = tv(promptTheme)()+const styles = tv(questionTheme)()+const donation = tv(donationTheme)()+const headingId = useId()+</script>++<template>+ <aside+ v-if="donationPrompt"+ :class="prompt.root()"+ :aria-labelledby="headingId"+ data-test-id="donation-prompt"+ >+ <section :class="styles.root()">+ <h3 :id="headingId" :class="donation.heading()">+ <icon-lucide-heart :class="donation.heart()" aria-hidden="true" />+ {{ diagnostics.supportTitle }}+ </h3>+ <p :class="styles.text()">{{ diagnostics.supportDescription }}</p>+ <div :class="styles.actions()">+ <AppButton variant="outline" @click="postponeDonation()">+ {{ diagnostics.supportNotNow }}+ </AppButton>+ <AppButton color="primary" variant="solid" @click="donate('prompt')">+ {{ diagnostics.supportDonate }}+ </AppButton>+ </div>+ </section>+ </aside>+</template>diff --git a/src/components/settings/general/GeneralSettingsPanel.vue b/src/components/settings/general/GeneralSettingsPanel.vueindex b6fd7d09e..359539ee2 100644--- a/src/components/settings/general/GeneralSettingsPanel.vue+++ b/src/components/settings/general/GeneralSettingsPanel.vue@@ -22,6 +22,7 @@ import { useAppTheme } from '@/app/shell/theme'import CredentialSettingsSection from '@/components/settings/credentials/CredentialSettingsSection.vue'import AccentColorPicker from '@/components/settings/general/AccentColorPicker.vue'import CollaborationNameSection from '@/components/settings/general/CollaborationNameSection.vue'+import SupportSettingsSection from '@/components/settings/general/SupportSettingsSection.vue'import SettingsGroup from '@/components/settings/layout/SettingsGroup.vue'import SettingsRow from '@/components/settings/layout/SettingsRow.vue'import SettingsSection from '@/components/settings/layout/SettingsSection.vue'@@ -193,5 +194,7 @@ const interfaceScaleOptions = computed(() => {</SettingsSection><CredentialSettingsSection />++ <SupportSettingsSection /></section></template>diff --git a/src/components/settings/general/SupportSettingsSection.vue b/src/components/settings/general/SupportSettingsSection.vuenew file mode 100644index 000000000..c12f7d397--- /dev/null+++ b/src/components/settings/general/SupportSettingsSection.vue@@ -0,0 +1,22 @@+<script setup lang="ts">+import { useI18n } from '@open-pencil/vue/i18n'++import { donate, DONATION_URL } from '@/app/donation'+import SettingsSection from '@/components/settings/layout/SettingsSection.vue'+import AppButton from '@/components/ui/button/AppButton.vue'++/** Donating from Settings, for builds whose repository names a donation page. */+const { diagnostics } = useI18n()+</script>++<template>+ <SettingsSection v-if="DONATION_URL" data-test-id="settings-support">+ <template #title>{{ diagnostics.supportTitle }}</template>+ <template #description>{{ diagnostics.supportDescription }}</template>+ <template #actions>+ <AppButton size="sm" color="primary" variant="solid" @click="donate('settings')">+ {{ diagnostics.supportDonate }}+ </AppButton>+ </template>+ </SettingsSection>+</template>diff --git a/src/env.d.ts b/src/env.d.tsindex 3c35e67aa..0a9d187f1 100644--- a/src/env.d.ts+++ b/src/env.d.ts@@ -12,6 +12,8 @@ declare const __OPENPENCIL_APP_VERSION__: stringdeclare const __OPENPENCIL_CLOUD_SITE__: boolean/** `VITE_OPENPENCIL_OFFICIAL_CLOUD_URL`: the official Cloud server an official deployment's build names. */declare const __OPENPENCIL_OFFICIAL_CLOUD_URL__: string | null+/** The donation page `.github/FUNDING.yml` names first, or `null` when the build has none. */+declare const __OPENPENCIL_DONATION_URL__: string | nulldeclare const __OPENPENCIL_LOCAL_AUTOMATION_TOKEN__: string | nulldeclare const __OPENPENCIL_LOCAL_AUTOMATION_URL__: stringdeclare const __OPENPENCIL_LOCAL_AUTOMATION_HTTP_URL__: stringdiff --git a/src/theme/donation.ts b/src/theme/donation.tsnew file mode 100644index 000000000..3710a86cf--- /dev/null+++ b/src/theme/donation.ts@@ -0,0 +1,7 @@+/** The donation request: a warm heading with a heart, over the usage stats question's layout. */+export default {+ slots: {+ heading: 'flex items-center gap-1.5 text-sm font-semibold text-surface',+ heart: 'size-4 shrink-0 text-heart *:fill-current'+ }+} as constdiff --git a/src/theme/tokens.css b/src/theme/tokens.cssindex c066b8a98..ce8171985 100644--- a/src/theme/tokens.css+++ b/src/theme/tokens.css@@ -80,6 +80,8 @@--color-input: #1e1e1e;--color-component: #bb8cff;--color-slot: #f45cc4;+ /* The heart beside a request for donations. */+ --color-heart: #fb7185;/* A FigJam board's mark in file lists, after FigJam's own purple. */--color-board: #b38cff;/*@@ -138,6 +140,7 @@ html[data-theme='light'] {--color-input: #ffffff;--color-component: #7c3aed;--color-slot: #db2777;+ --color-heart: #e11d48;--color-board: #8b5cf6;--color-warning: #8f5500;--color-warning-bg: rgb(245 158 11 / 0.14);diff --git a/src/views/WorkspaceView.vue b/src/views/WorkspaceView.vueindex 13ed9f102..887007033 100644--- a/src/views/WorkspaceView.vue+++ b/src/views/WorkspaceView.vue@@ -24,6 +24,7 @@ import { openDemoDocument } from '@/app/demo/document'import type { PendingOpenFile } from '@/app/document/io/pending-open'import { openPendingFiles } from '@/app/document/io/pending-open'import { openWebLinkFromLocation, withoutWebLinkParams } from '@/app/document/io/web-link'+import { offerDonationPrompt, startDonationClock } from '@/app/donation'import { setActiveEditorStore } from '@/app/editor/active-store'import { focusNodesByName } from '@/app/editor/selection/focus'import { notificationMessages } from '@/app/i18n/notifications'@@ -45,7 +46,7 @@ import {} from '@/app/tabs'import { syncTabAddress } from '@/app/tabs/address'import { isTauri } from '@/app/tauri/env'-import { offerUsageStatsPrompt, startSharing } from '@/app/telemetry'+import { offerUsageStatsPrompt, startSharing, usageStatsPrompt } from '@/app/telemetry'import ColorSpaceBanner from '@/components/canvas/ColorSpaceBanner.vue'import { CloudVersionDialog } from '@/components/cloud/integration'import CommandPalette from '@/components/commands/CommandPalette.vue'@@ -139,8 +140,12 @@ const welcomeShown =? offerAISetupOnFirstRun({ inTour: route.meta.demo === true }): falseconst sharingStarted = startSharing()-// One question per surface: a first run is asked about usage stats once the welcome closes.+// Release builds ask for donations; development and test runs would only be interrupted.+const asksForDonations = import.meta.env.PROD && !appRuntimeConfig.test+// One question per launch: a first run is asked about usage stats once the welcome closes, and+// a later launch about usage stats if still unanswered, otherwise about a donation once it is due.if (welcomeShown) {+ startDonationClock()whenever(() => !aiSetupDialogOpen.value,async () => {@@ -156,6 +161,7 @@ if (welcomeShown) {async () => {await sharingStartedofferUsageStatsPrompt('prompt')+ if (asksForDonations && !usageStatsPrompt.value) offerDonationPrompt()},{ once: true, immediate: true })diff --git a/tests/app/donation/funding.test.ts b/tests/app/donation/funding.test.tsnew file mode 100644index 000000000..110f34b32--- /dev/null+++ b/tests/app/donation/funding.test.ts@@ -0,0 +1,24 @@+import { expect, test } from 'bun:test'++import { fundingURL } from '@/app/donation/funding'++test('links the first platform the file names, as GitHub does', () => {+ expect(fundingURL('ko_fi: dannote\n')).toBe('https://ko-fi.com/dannote')+ expect(fundingURL('github: [octocat, hubot]\nko_fi: other\n')).toBe(+ 'https://github.com/sponsors/octocat'+ )+ expect(fundingURL('custom: ["https://example.org/donate"]\n')).toBe('https://example.org/donate')+})++test('skips platforms it cannot link and entries left empty', () => {+ expect(fundingURL('tidelift: npm/open-pencil\npatreon:\nliberapay: openpencil\n')).toBe(+ 'https://liberapay.com/openpencil'+ )+ expect(fundingURL('custom: ["http://example.org"]\n')).toBeNull()+ expect(fundingURL('ko_fi: "../evil"\n')).toBeNull()+ expect(fundingURL('# nothing yet\n')).toBeNull()+})++test('fails on a file that is not a mapping of platforms', () => {+ expect(() => fundingURL('- ko_fi\n')).toThrow()+})diff --git a/tests/app/donation/prompt.test.ts b/tests/app/donation/prompt.test.tsnew file mode 100644index 000000000..0be0cc4f3--- /dev/null+++ b/tests/app/donation/prompt.test.ts@@ -0,0 +1,54 @@+import { beforeEach, expect, test } from 'bun:test'++import {+ DONATED_DELAY,+ donationPrompt,+ FIRST_ASK_DELAY,+ NOT_NOW_DELAY,+ offerDonationPrompt,+ postponeDonation,+ recordDonation,+ startDonationClock+} from '@/app/donation'+import { appPreferences, DEFAULT_APP_PREFERENCES } from '@/app/settings/preferences/store'++const URL = 'https://ko-fi.com/openpencil'+const NOW = Date.UTC(2026, 10, 3)++beforeEach(() => {+ appPreferences.value = structuredClone(DEFAULT_APP_PREFERENCES)+ donationPrompt.value = false+})++test('the first launch starts the clock, and the question shows once it runs out', () => {+ offerDonationPrompt(NOW, URL)+ expect(donationPrompt.value).toBe(false)+ expect(appPreferences.value.donation.promptAfter).toBe(NOW + FIRST_ASK_DELAY)++ offerDonationPrompt(NOW + FIRST_ASK_DELAY - 1, URL)+ expect(donationPrompt.value).toBe(false)+ offerDonationPrompt(NOW + FIRST_ASK_DELAY, URL)+ expect(donationPrompt.value).toBe(true)+})++test('a launch that asks something else still starts the clock, once', () => {+ startDonationClock(NOW)+ startDonationClock(NOW + 1000)+ expect(appPreferences.value.donation.promptAfter).toBe(NOW + FIRST_ASK_DELAY)+})++test('Not now and donating keep the question away for their own times', () => {+ donationPrompt.value = true+ postponeDonation(NOW)+ expect(donationPrompt.value).toBe(false)+ expect(appPreferences.value.donation.promptAfter).toBe(NOW + NOT_NOW_DELAY)++ recordDonation('menu', NOW)+ expect(appPreferences.value.donation.promptAfter).toBe(NOW + DONATED_DELAY)+})++test('a build without a donation page never asks', () => {+ appPreferences.value.donation.promptAfter = 0+ offerDonationPrompt(NOW, null)+ expect(donationPrompt.value).toBe(false)+})diff --git a/tests/engine/app/shell/menu/schema.test.ts b/tests/engine/app/shell/menu/schema.test.tsindex f7fd18a34..f98ab4be6 100644--- a/tests/engine/app/shell/menu/schema.test.ts+++ b/tests/engine/app/shell/menu/schema.test.ts@@ -52,6 +52,7 @@ describe('APP_MENU_SCHEMA', () => {'open-tour','diagnostics','report-problem',+ 'support-openpencil','settings','view-design-issues','theme-light',diff --git a/tools/checks/i18n/mixed-script-baseline.txt b/tools/checks/i18n/mixed-script-baseline.txtindex 590c9a3af..749b6cea6 100644--- a/tools/checks/i18n/mixed-script-baseline.txt+++ b/tools/checks/i18n/mixed-script-baseline.txt@@ -190,6 +190,7 @@ ja:menu.exportSelectionAsPNGja:menu.exportSelectionAsDrawIOja:menu.exportSelectionAsPPTXja:menu.exportSelectionAsSVG+ja:menu.supportOpenPencilja:menu.toggleUIja:panels.behaviourAddVariantsja:panels.colorHintHsb@@ -412,6 +413,7 @@ zh-cn:menu.exportSelectionAsPNGzh-cn:menu.exportSelectionAsDrawIOzh-cn:menu.exportSelectionAsPPTXzh-cn:menu.exportSelectionAsSVG+zh-cn:menu.supportOpenPencilzh-cn:panels.behaviourAddVariantszh-cn:panels.colorHintHsbzh-cn:panels.colorHintHsl@@ -605,6 +607,8 @@ ja:diagnostics.reportErrorDescriptionja:diagnostics.reportPanicja:diagnostics.reportProblemDescriptionja:diagnostics.reportUnexpectedError+ja:diagnostics.supportDescription+ja:diagnostics.supportTitlezh-cn:ai.skillsDescriptionzh-cn:ai.notificationsHintzh-cn:ai.notificationsAllowHint@@ -617,3 +621,5 @@ zh-cn:diagnostics.reportErrorDescriptionzh-cn:diagnostics.reportPaniczh-cn:diagnostics.reportProblemDescriptionzh-cn:diagnostics.reportUnexpectedError+zh-cn:diagnostics.supportDescription+zh-cn:diagnostics.supportTitlediff --git a/vite.config.ts b/vite.config.tsindex b98e0a5bb..6d91eed20 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -22,6 +22,7 @@ import {} from './vite/automation'import { bootSplashPlugin } from './vite/boot-splash'import { cloudSitePlugin } from './vite/cloud-site'+import { donationDefine } from './vite/funding'import { aiIconCollection } from './vite/icons'import { inlineScriptPlugin } from './vite/inline-script'import { metricsBrandPlugin } from './vite/metrics'@@ -52,6 +53,7 @@ export default defineConfig(async ({ command, mode }) => {define: {__OPENPENCIL_APP_VERSION__: JSON.stringify(packageJson.version),__OPENPENCIL_CLOUD_SITE__: JSON.stringify(cloudSite),+ ...donationDefine(__dirname),__OPENPENCIL_OFFICIAL_CLOUD_URL__: JSON.stringify(env.VITE_OPENPENCIL_OFFICIAL_CLOUD_URL ?? null),diff --git a/vite/app-source.ts b/vite/app-source.tsindex 54760115f..e80d55c41 100644--- a/vite/app-source.ts+++ b/vite/app-source.ts@@ -10,6 +10,7 @@ import { openPencil } from '@open-pencil/core/node/vite'import rootManifest from '../package.json' with { type: 'json' }import { createOpenPencilAliases } from './aliases.ts'+import { donationDefine } from './funding.ts'import { inlineScriptPlugin } from './inline-script.ts'const REPO_ROOT = fileURLToPath(new URL('..', import.meta.url))@@ -69,6 +70,7 @@ export function appSourceConfig(): AppSourceConfig {],define: {__OPENPENCIL_APP_VERSION__: JSON.stringify(rootManifest.version),+ ...donationDefine(REPO_ROOT),__OPENPENCIL_LOCAL_AUTOMATION_TOKEN__: JSON.stringify(''),__OPENPENCIL_LOCAL_AUTOMATION_URL__: JSON.stringify(''),__OPENPENCIL_LOCAL_AUTOMATION_HTTP_URL__: JSON.stringify('')diff --git a/vite/funding.ts b/vite/funding.tsnew file mode 100644index 000000000..d7384ad76--- /dev/null+++ b/vite/funding.ts@@ -0,0 +1,14 @@+import { existsSync, readFileSync } from 'node:fs'+import { join } from 'node:path'++import { fundingURL } from '../src/app/donation/funding.ts'++/**+ * `__OPENPENCIL_DONATION_URL__`: the donation page the repository's `.github/FUNDING.yml` names,+ * or `null` without one, as in a fork that has none, so its build asks for no donations.+ */+export function donationDefine(root: string): Record<string, string> {+ const path = join(root, '.github', 'FUNDING.yml')+ const url = existsSync(path) ? fundingURL(readFileSync(path, 'utf8')) : null+ return { __OPENPENCIL_DONATION_URL__: JSON.stringify(url) }+}