From 8b6551330fce7ab10bf3c6045247f802360af405 Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Thu, 30 Apr 2026 06:38:54 -0400 Subject: [PATCH] input halo sections, sparkle handling --- src/routes/api/InputHalo/appcast.xml.ts | 62 +++++++++++++++++++++++++ src/routes/api/downloads/[filename].ts | 12 +++-- src/routes/downloads.tsx | 54 ++++++++++++++++++++- src/server/api/routers/downloads.ts | 41 ++++++++++++---- 4 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 src/routes/api/InputHalo/appcast.xml.ts diff --git a/src/routes/api/InputHalo/appcast.xml.ts b/src/routes/api/InputHalo/appcast.xml.ts new file mode 100644 index 0000000..a8d9e1c --- /dev/null +++ b/src/routes/api/InputHalo/appcast.xml.ts @@ -0,0 +1,62 @@ +import type { APIEvent } from "@solidjs/start/server"; +import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"; +import { env } from "~/env/server"; + +/** + * Serves the InputHalo appcast.xml file from S3 + * This endpoint is used by Sparkle updater to check for new versions + * + * URL: https://freno.me/api/InputHalo/appcast.xml + */ +export async function GET(event: APIEvent) { + const bucket = env.VITE_DOWNLOAD_BUCKET_STRING; + const key = "api/InputHalo/appcast.xml"; + + const credentials = { + accessKeyId: env.MY_AWS_ACCESS_KEY, + secretAccessKey: env.MY_AWS_SECRET_KEY + }; + + try { + const client = new S3Client({ + region: env.AWS_REGION, + credentials: credentials + }); + + const command = new GetObjectCommand({ + Bucket: bucket, + Key: key + }); + + const response = await client.send(command); + + if (!response.Body) { + return new Response("Appcast not found", { + status: 404, + headers: { + "Content-Type": "text/plain" + } + }); + } + + // Stream the XML content from S3 + const body = await response.Body.transformToString(); + + return new Response(body, { + status: 200, + headers: { + "Content-Type": "application/xml; charset=utf-8", + "Cache-Control": "public, max-age=300", // Cache for 5 minutes + "Access-Control-Allow-Origin": "*" // Allow CORS for appcast + } + }); + } catch (error) { + console.error("Failed to fetch appcast:", error); + return new Response("Internal Server Error", { + status: 500, + headers: { + "Content-Type": "text/plain" + } + }); + } +} diff --git a/src/routes/api/downloads/[filename].ts b/src/routes/api/downloads/[filename].ts index ea4df57..69d51b7 100644 --- a/src/routes/api/downloads/[filename].ts +++ b/src/routes/api/downloads/[filename].ts @@ -3,12 +3,12 @@ import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"; import { env } from "~/env/server"; /** - * Serves Gaze DMG files and delta updates from S3 + * Serves macOS app DMG files and delta updates from S3 * This endpoint is used by Sparkle updater to download updates * * Handles: - * - Full DMG files: /api/downloads/Gaze-0.2.2.dmg - * - Delta updates: /api/downloads/Gaze3-2.delta + * - Full DMG files: /api/downloads/Gaze-0.2.2.dmg, /api/downloads/InputHalo-0.1.0.dmg + * - Delta updates: /api/downloads/Gaze3-2.delta, /api/downloads/InputHalo3-2.delta * * URL: https://freno.me/api/downloads/[filename] */ @@ -24,9 +24,11 @@ export async function GET(event: APIEvent) { }); } - // Validate filename format (only allow Gaze files) + // Validate filename format (only allow Gaze or InputHalo files) + const validPrefixes = ["Gaze", "InputHalo"]; + const isValidPrefix = validPrefixes.some((prefix) => filename.startsWith(prefix)); if ( - !filename.startsWith("Gaze") || + !isValidPrefix || (!filename.endsWith(".dmg") && !filename.endsWith(".delta")) ) { return new Response("Invalid file format", { diff --git a/src/routes/downloads.tsx b/src/routes/downloads.tsx index 1ebd1b0..71bbb6d 100644 --- a/src/routes/downloads.tsx +++ b/src/routes/downloads.tsx @@ -10,6 +10,7 @@ export default function DownloadsPage() { const [SwAText, setSwAText] = createSignal("Shapes with Abigail!"); const [corkText, setCorkText] = createSignal("Cork"); const [gazeText, setGazeText] = createSignal("Gaze"); + const [inputHaloText, setInputHaloText] = createSignal("InputHalo"); // Track loading states for each download button const [loadingState, setLoadingState] = createSignal>( @@ -17,7 +18,8 @@ export default function DownloadsPage() { lineage: false, cork: false, gaze: false, - "shapes-with-abigail": false + "shapes-with-abigail": false, + inputhalo: false } ); @@ -53,12 +55,14 @@ export default function DownloadsPage() { const swaInterval = glitchText(SwAText(), setSwAText); const corkInterval = glitchText(corkText(), setCorkText); const gazeInterval = glitchText(gazeText(), setGazeText); + const inputHaloInterval = glitchText(inputHaloText(), setInputHaloText); onCleanup(() => { clearInterval(lalInterval); clearInterval(swaInterval); clearInterval(corkInterval); clearInterval(gazeInterval); + clearInterval(inputHaloInterval); }); }); @@ -66,7 +70,7 @@ export default function DownloadsPage() { <>
@@ -86,6 +90,52 @@ export default function DownloadsPage() { Ordered by date of initial release
+ {/* InputHalo */} +
+

+ {">"} {inputHaloText()} +

+ +
+
+ + platform: macOS (14.6+) + + +
+ +
+ + variant: paid (coming soon) + + + + +
+
+ + variant: free (coming soon) + + + + +
+
+
+ {/* Gaze */}

diff --git a/src/server/api/routers/downloads.ts b/src/server/api/routers/downloads.ts index ed35762..9137ea4 100644 --- a/src/server/api/routers/downloads.ts +++ b/src/server/api/routers/downloads.ts @@ -16,23 +16,24 @@ const assets: Record = { }; /** - * Get the latest Gaze DMG from S3 by finding the most recent file in downloads/ folder + * Get the latest DMG from S3 by finding the most recent file with the given prefix */ -async function getLatestGazeDMG( +async function getLatestDMG( client: S3Client, - bucket: string + bucket: string, + prefix: string ): Promise { try { const listCommand = new ListObjectsV2Command({ Bucket: bucket, - Prefix: "downloads/Gaze-", + Prefix: prefix, MaxKeys: 100 }); const response = await client.send(listCommand); if (!response.Contents || response.Contents.length === 0) { - throw new Error("No Gaze DMG files found in S3"); + throw new Error(`No DMG files found in S3 with prefix ${prefix}`); } // Filter for .dmg files only and sort by LastModified (newest first) @@ -45,18 +46,38 @@ async function getLatestGazeDMG( }); if (dmgFiles.length === 0) { - throw new Error("No .dmg files found in downloads/Gaze-* prefix"); + throw new Error(`No .dmg files found in ${prefix} prefix`); } const latestFile = dmgFiles[0].Key!; - console.log(`Latest Gaze DMG: ${latestFile}`); + console.log(`Latest DMG: ${latestFile}`); return latestFile; } catch (error) { - console.error("Error finding latest Gaze DMG:", error); + console.error(`Error finding latest DMG for ${prefix}:`, error); throw error; } } +/** + * Get the latest Gaze DMG from S3 + */ +async function getLatestGazeDMG( + client: S3Client, + bucket: string +): Promise { + return getLatestDMG(client, bucket, "downloads/Gaze-"); +} + +/** + * Get the latest InputHalo DMG from S3 + */ +async function getLatestInputHaloDMG( + client: S3Client, + bucket: string +): Promise { + return getLatestDMG(client, bucket, "downloads/InputHalo-"); +} + export const downloadsRouter = createTRPCRouter({ getDownloadUrl: publicProcedure .input(z.object({ asset_name: z.string() })) @@ -76,9 +97,11 @@ export const downloadsRouter = createTRPCRouter({ try { let fileKey: string; - // Special handling for Gaze - find latest version automatically + // Special handling for macOS apps - find latest version automatically if (input.asset_name === "gaze") { fileKey = await getLatestGazeDMG(client, bucket); + } else if (input.asset_name === "inputhalo") { + fileKey = await getLatestInputHaloDMG(client, bucket); } else { // Use static mapping for other assets fileKey = assets[input.asset_name];