Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
Add version numbers next to key integrations that are often not up-to-date with the GitHub version (#3553)
Andrew Dunbar0e417b894a6d
diff --git a/packages/web/src/lib/marketing/data.ts b/packages/web/src/lib/marketing/data.tsindex d7b0016d8..8f3f7c580 100644--- a/packages/web/src/lib/marketing/data.ts+++ b/packages/web/src/lib/marketing/data.ts@@ -17,6 +17,7 @@ export type Integration = {categoryLabel: string;tag?: string;platform?: string;+ version?: string;cta: 'install' | 'docs';color?: string;fg?: string;@@ -106,7 +107,7 @@ export const integrationCategories: IntegrationCategory[] = [items: [{id: 'vscode',- name: 'Visual Studio Code',+ name: 'VS Code',desc: 'Marketplace extension.',href: marketingLinks.vscode,platform: 'VS Code, Cursor',diff --git a/packages/web/src/lib/marketing/versions.ts b/packages/web/src/lib/marketing/versions.tsnew file mode 100644index 000000000..8ff11b9a4--- /dev/null+++ b/packages/web/src/lib/marketing/versions.ts@@ -0,0 +1,130 @@+import { writable } from 'svelte/store';++export const liveVersions = writable<Record<string, string>>({+ harper: '',+ firefox: '',+ js: '',+ rust: '',+ vscode: '',+});++function isValidVersion(version: string): boolean {+ return /^\d+\.\d+\.\d+$/.test(version);+}++export function isUpToDate(harperVersion: string, integrationVersion: string): boolean | null {+ // 1. Structural/syntax invalidity+ if (!isValidVersion(harperVersion) || !isValidVersion(integrationVersion)) {+ return null;+ }++ const [hMaj, hMin, hPatch] = harperVersion.split('.').map(Number);+ const [iMaj, iMin, iPatch] = integrationVersion.split('.').map(Number);++ // 2. Logic invalidity: Integration is ahead of Harper ("Too New")+ if (iMaj > hMaj) return null;+ if (iMaj === hMaj && iMin > hMin) return null;+ if (iMaj === hMaj && iMin === hMin && iPatch > hPatch) return null;++ // 3. Exact match: Up-to-date+ if (iMaj === hMaj && iMin === hMin && iPatch === hPatch) return true;++ // 4. Fallthrough: Integration must be older+ return false;+}++export async function loadLiveVersions() {+ // 0. Harper+ (async () => {+ try {+ const ver = (await (await fetch('https://writewithharper.com/latestversion')).text()).replace(+ /^v/,+ '',+ );++ if (isValidVersion(ver)) {+ liveVersions.update((v) => ({ ...v, harper: ver }));+ }+ } catch {}+ })();++ // 1. Firefox Addon+ (async () => {+ try {+ const ver = (+ await (+ await fetch(+ 'https://addons.mozilla.org/api/v5/addons/addon/private-grammar-checker-harper/',+ )+ ).json()+ ).current_version.version;++ if (isValidVersion(ver)) {+ liveVersions.update((v) => ({ ...v, firefox: ver }));+ }+ } catch {}+ })();++ // 2. JS Package+ (async () => {+ try {+ const ver = (await (await fetch('https://registry.npmjs.org/harper.js')).json())['dist-tags']+ .latest;++ if (isValidVersion(ver)) {+ liveVersions.update((v) => ({ ...v, js: ver }));+ }+ } catch {}+ })();++ // 3. Rust Crate+ (async () => {+ try {+ const lines = (await (await fetch('https://index.crates.io/ha/rp/harper-core')).text()).split(+ '\n',+ );+ const ver = JSON.parse(lines[lines.length - 2]).vers;++ if (isValidVersion(ver)) {+ liveVersions.update((v) => ({ ...v, rust: ver }));+ }+ } catch {}+ })();++ // 4. VS Code Extension+ (async () => {+ try {+ const res = await fetch(+ 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery',+ {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json',+ Accept: 'application/json;api-version=3.0-preview.1',+ },+ body: JSON.stringify({+ filters: [+ {+ criteria: [+ { filterType: 8, value: 'Microsoft.VisualStudio.Code' },+ { filterType: 7, value: 'elijah-potter.harper' },+ ],+ pageNumber: 1,+ pageSize: 1,+ sortBy: 0,+ sortOrder: 0,+ },+ ],+ assetTypes: [],+ flags: 194,+ }),+ },+ );+ const ver = (await res.json()).results[0].extensions[0].versions[0].version;++ if (isValidVersion(ver)) {+ liveVersions.update((v) => ({ ...v, vscode: ver }));+ }+ } catch {}+ })();+}diff --git a/packages/web/src/routes/+page.svelte b/packages/web/src/routes/+page.svelteindex d6f50f474..9a3d86683 100644--- a/packages/web/src/routes/+page.svelte+++ b/packages/web/src/routes/+page.svelte@@ -19,12 +19,16 @@ import PrivacySpeedCards from '$lib/marketing/PrivacySpeedCards.svelte';import { featuredIntegrationIds, integrations, marketingLinks } from '$lib/marketing/data';import { LazyEditor } from 'harper-editor';import type { Linter } from 'harper.js';+import { isUpToDate, loadLiveVersions, liveVersions } from '$lib/marketing/versions';import { onMount } from 'svelte';import demoText from '../../../../demo.md?raw';const editorContent = demoText.trim();let linter: Linter | null = null;+const VERSION_UPTODATE = 'Up-to-date';+const VERSION_BEHIND = 'This version is slightly behind the core engine due to a delay';+const testimonials = [{authorName: 'Rich Edmonds',@@ -142,10 +146,17 @@ const faqs = [},];+let liveFxVer = '';+let liveJsVer = '';+let liveRustVer = '';+let liveVscodeVer = '';+onMount(() => {void (async () => {linter = await createEditorLinter();})();++ void loadLiveVersions();});</script>@@ -241,14 +252,30 @@ onMount(() => {{#each featuredIntegrationIds as id}{@const integration = integrations.find((item) => item.id === id)}{#if integration}+ {@const upToDate = isUpToDate($liveVersions.harper, $liveVersions[integration.id])}+ {@const titleText = upToDate ? VERSION_UPTODATE : upToDate === false ? VERSION_BEHIND : null}<aclass="flex items-center gap-3 rounded-[0.65rem] px-3 py-[0.65rem] !text-[#1c1a16] no-underline hover:bg-black/[0.04] hover:no-underline dark:!text-white dark:hover:bg-white/10"href={integration.href}><IntegrationTile {integration} size={32} /><span class="flex min-w-0 flex-col">- <strong class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.84rem]">{integration.name}</strong>- <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.72rem] text-[#807a6e] dark:text-white/55">{integration.desc}</small>+ <div class="flex items-center gap-1.5 overflow-hidden">+ <strong class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.84rem]">{integration.name}</strong>+ {#if $liveVersions[integration.id]}+ {#if upToDate != null}+ <span+ class="inline-flex items-center rounded-full bg-[#f4f1ea] dark:bg-white/10 px-1.5 py-0.5 text-[0.65rem] font-mono font-medium text-[#6b6455] dark:text-white/80 border border-[#e4dfd3] dark:border-white/10 select-none"+ title={titleText}+ >+ {$liveVersions[integration.id]}+ </span>+ {/if}+ {/if}+ </div>+ <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.72rem] text-[#807a6e] dark:text-white/55">+ {integration.desc}+ </small></span></a>{/if}diff --git a/packages/web/src/routes/get/+page.svelte b/packages/web/src/routes/get/+page.svelteindex 20c98b718..9431ead52 100644--- a/packages/web/src/routes/get/+page.svelte+++ b/packages/web/src/routes/get/+page.svelte@@ -1,4 +1,5 @@<script lang="ts">+import { onMount } from 'svelte';import {type Integration,integrationCategories,@@ -8,10 +9,18 @@ import {import IntegrationTile from '$lib/marketing/IntegrationTile.svelte';import MarketingFooter from '$lib/marketing/MarketingFooter.svelte';import MarketingHeader from '$lib/marketing/MarketingHeader.svelte';+import { isUpToDate, liveVersions, loadLiveVersions } from '$lib/marketing/versions';let activeCategory = 'all';let query = '';+const VERSION_UPTODATE = 'Up-to-date';+const VERSION_BEHIND = 'This version is slightly behind the core engine due to a delay';++onMount(() => {+ void loadLiveVersions();+});+$: filtered = integrations.filter((integration) => {if (activeCategory === 'community' && !integration.community) {return false;@@ -71,14 +80,30 @@ function clearFilters() {{#each ['desktop', 'chrome'] as id}{@const integration = integrations.find((item) => item.id === id)}{#if integration}+ {@const upToDate = isUpToDate($liveVersions.harper, $liveVersions[integration.id])}+ {@const titleText = upToDate ? VERSION_UPTODATE : upToDate === false ? VERSION_BEHIND : null}<aclass="grid grid-cols-[2.5rem_1fr_auto] items-center gap-[0.9rem] rounded-xl border-[0.5px] border-[rgba(28,26,22,0.1)] bg-white px-[1.1rem] py-[0.9rem] !text-[#1c1a16] no-underline transition-[transform,box-shadow,border-color] duration-150 hover:-translate-y-px hover:border-[#b06a1b] hover:shadow-[0_10px_24px_-16px_rgba(28,26,22,0.16)] hover:no-underline dark:border-white/10 dark:bg-white/5 dark:!text-white dark:hover:border-primary-300 max-[640px]:grid-cols-[2.5rem_1fr] [&_em]:max-[640px]:col-start-2"href={integration.href}><IntegrationTile {integration} size={40} /><span class="flex min-w-0 flex-col">- <strong class="text-[0.94rem] leading-[1.25]">{integration.name}</strong>- <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.8rem] leading-[1.4] text-[#807a6e] dark:text-white/55">{integration.desc}</small>+ <div class="flex items-center gap-1.5">+ <strong class="text-[0.94rem] leading-[1.25]">{integration.name}</strong>+ {#if $liveVersions[integration.id]}+ {#if upToDate != null}+ <span+ class="inline-flex items-center rounded-full bg-[#f4f1ea] dark:bg-white/10 px-1.5 py-0.5 text-[0.68rem] font-mono font-medium text-[#6b6455] dark:text-white/80 border border-[#e4dfd3] dark:border-white/10 select-none"+ title={titleText}+ >+ {$liveVersions[integration.id]}+ </span>+ {/if}+ {/if}+ </div>+ <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.8rem] leading-[1.4] text-[#807a6e] dark:text-white/55">+ {integration.desc}+ </small></span><em class="whitespace-nowrap text-[0.78rem] font-extrabold text-[#b06a1b] not-italic dark:text-primary-300">{ctaLabel(integration)} →</em></a>@@ -164,16 +189,32 @@ function clearFilters() {</div>{:else}{#each filtered as integration}+ {@const upToDate = isUpToDate($liveVersions.harper, $liveVersions[integration.id])}+ {@const titleText = upToDate ? VERSION_UPTODATE : upToDate === false ? VERSION_BEHIND : null}<aclass="grid grid-cols-[2.5rem_1fr_auto] items-center gap-[0.9rem] rounded-xl border-[0.5px] border-[rgba(28,26,22,0.1)] bg-white px-[1.1rem] py-[0.9rem] !text-[#1c1a16] no-underline transition-[transform,box-shadow,border-color] duration-150 hover:-translate-y-px hover:border-[#b06a1b] hover:shadow-[0_10px_24px_-16px_rgba(28,26,22,0.16)] hover:no-underline dark:border-white/10 dark:bg-white/5 dark:!text-white dark:hover:border-primary-300 max-[640px]:grid-cols-[2.5rem_1fr] [&_em]:max-[640px]:col-start-2"href={integration.href}>- <IntegrationTile {integration} size={40} />- <span class="flex min-w-0 flex-col">+ <IntegrationTile {integration} size={40} />+ <span class="flex min-w-0 flex-col">+ <div class="flex items-center gap-1.5"><strong class="text-[0.94rem] leading-[1.25]">{integration.name}</strong>- <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.8rem] leading-[1.4] text-[#807a6e] dark:text-white/55">{integration.platform}</small>- </span>- <em class="whitespace-nowrap text-[0.78rem] font-extrabold text-[#b06a1b] not-italic dark:text-primary-300">{ctaLabel(integration)} →</em>+ {#if $liveVersions[integration.id]}+ {#if upToDate != null}+ <span+ class="inline-flex items-center rounded-full bg-[#f4f1ea] dark:bg-white/10 px-1.5 py-0.5 text-[0.68rem] font-mono font-medium text-[#6b6455] dark:text-white/80 border border-[#e4dfd3] dark:border-white/10 select-none"+ title={titleText}+ >+ {$liveVersions[integration.id]}+ </span>+ {/if}+ {/if}+ </div>+ <small class="overflow-hidden text-ellipsis whitespace-nowrap text-[0.8rem] leading-[1.4] text-[#807a6e] dark:text-white/55">+ {integration.platform}+ </small>+ </span>+ <em class="whitespace-nowrap text-[0.78rem] font-extrabold text-[#b06a1b] not-italic dark:text-primary-300">{ctaLabel(integration)} →</em></a>{/each}{/if}