input halo sections, sparkle handling
This commit is contained in:
62
src/routes/api/InputHalo/appcast.xml.ts
Normal file
62
src/routes/api/InputHalo/appcast.xml.ts
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,12 +3,12 @@ import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
|
|||||||
import { env } from "~/env/server";
|
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
|
* This endpoint is used by Sparkle updater to download updates
|
||||||
*
|
*
|
||||||
* Handles:
|
* Handles:
|
||||||
* - Full DMG files: /api/downloads/Gaze-0.2.2.dmg
|
* - Full DMG files: /api/downloads/Gaze-0.2.2.dmg, /api/downloads/InputHalo-0.1.0.dmg
|
||||||
* - Delta updates: /api/downloads/Gaze3-2.delta
|
* - Delta updates: /api/downloads/Gaze3-2.delta, /api/downloads/InputHalo3-2.delta
|
||||||
*
|
*
|
||||||
* URL: https://freno.me/api/downloads/[filename]
|
* 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 (
|
if (
|
||||||
!filename.startsWith("Gaze") ||
|
!isValidPrefix ||
|
||||||
(!filename.endsWith(".dmg") && !filename.endsWith(".delta"))
|
(!filename.endsWith(".dmg") && !filename.endsWith(".delta"))
|
||||||
) {
|
) {
|
||||||
return new Response("Invalid file format", {
|
return new Response("Invalid file format", {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export default function DownloadsPage() {
|
|||||||
const [SwAText, setSwAText] = createSignal("Shapes with Abigail!");
|
const [SwAText, setSwAText] = createSignal("Shapes with Abigail!");
|
||||||
const [corkText, setCorkText] = createSignal("Cork");
|
const [corkText, setCorkText] = createSignal("Cork");
|
||||||
const [gazeText, setGazeText] = createSignal("Gaze");
|
const [gazeText, setGazeText] = createSignal("Gaze");
|
||||||
|
const [inputHaloText, setInputHaloText] = createSignal("InputHalo");
|
||||||
|
|
||||||
// Track loading states for each download button
|
// Track loading states for each download button
|
||||||
const [loadingState, setLoadingState] = createSignal<Record<string, boolean>>(
|
const [loadingState, setLoadingState] = createSignal<Record<string, boolean>>(
|
||||||
@@ -17,7 +18,8 @@ export default function DownloadsPage() {
|
|||||||
lineage: false,
|
lineage: false,
|
||||||
cork: false,
|
cork: false,
|
||||||
gaze: 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 swaInterval = glitchText(SwAText(), setSwAText);
|
||||||
const corkInterval = glitchText(corkText(), setCorkText);
|
const corkInterval = glitchText(corkText(), setCorkText);
|
||||||
const gazeInterval = glitchText(gazeText(), setGazeText);
|
const gazeInterval = glitchText(gazeText(), setGazeText);
|
||||||
|
const inputHaloInterval = glitchText(inputHaloText(), setInputHaloText);
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
clearInterval(lalInterval);
|
clearInterval(lalInterval);
|
||||||
clearInterval(swaInterval);
|
clearInterval(swaInterval);
|
||||||
clearInterval(corkInterval);
|
clearInterval(corkInterval);
|
||||||
clearInterval(gazeInterval);
|
clearInterval(gazeInterval);
|
||||||
|
clearInterval(inputHaloInterval);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,7 +70,7 @@ export default function DownloadsPage() {
|
|||||||
<>
|
<>
|
||||||
<PageHead
|
<PageHead
|
||||||
title="Downloads"
|
title="Downloads"
|
||||||
description="Download Life and Lineage, Shapes with Abigail, and Cork for macOS. Available on iOS, Android, and macOS."
|
description="Download InputHalo, Gaze, Life and Lineage, Shapes with Abigail, and Cork. Available on iOS, Android, and macOS."
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="bg-base relative min-h-screen overflow-hidden px-4 pt-[15vh] pb-12 md:px-8">
|
<div class="bg-base relative min-h-screen overflow-hidden px-4 pt-[15vh] pb-12 md:px-8">
|
||||||
@@ -86,6 +90,52 @@ export default function DownloadsPage() {
|
|||||||
Ordered by date of initial release
|
Ordered by date of initial release
|
||||||
</div>
|
</div>
|
||||||
<div class="mx-auto max-w-5xl space-y-16">
|
<div class="mx-auto max-w-5xl space-y-16">
|
||||||
|
{/* InputHalo */}
|
||||||
|
<div class="border-overlay0 rounded-lg border p-6 md:p-8">
|
||||||
|
<h2 class="text-text mb-6 font-mono text-2xl">
|
||||||
|
<span class="text-yellow">{">"}</span> {inputHaloText()}
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-8 lg:flex-row lg:justify-around">
|
||||||
|
<div class="flex flex-col items-center gap-3">
|
||||||
|
<span class="text-subtext0 font-mono text-sm">
|
||||||
|
platform: macOS (14.6+)
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="download"
|
||||||
|
size="lg"
|
||||||
|
loading={loadingState()["inputhalo"]}
|
||||||
|
onClick={() => download("inputhalo")}
|
||||||
|
>
|
||||||
|
download.dmg
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-col items-center gap-3">
|
||||||
|
<span class="text-subtext0 font-mono text-sm">
|
||||||
|
variant: paid (coming soon)
|
||||||
|
</span>
|
||||||
|
<A
|
||||||
|
class="transition-all duration-200 ease-out hover:scale-105 active:scale-95"
|
||||||
|
href="https://apps.apple.com/us/app/inputhalo/"
|
||||||
|
>
|
||||||
|
<DownloadOnAppStore size={50} />
|
||||||
|
</A>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col items-center gap-3">
|
||||||
|
<span class="text-subtext0 font-mono text-sm">
|
||||||
|
variant: free (coming soon)
|
||||||
|
</span>
|
||||||
|
<A
|
||||||
|
class="transition-all duration-200 ease-out hover:scale-105 active:scale-95"
|
||||||
|
href=""
|
||||||
|
>
|
||||||
|
<DownloadOnAppStore size={50} />
|
||||||
|
</A>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Gaze */}
|
{/* Gaze */}
|
||||||
<div class="border-overlay0 rounded-lg border p-6 md:p-8">
|
<div class="border-overlay0 rounded-lg border p-6 md:p-8">
|
||||||
<h2 class="text-text mb-6 font-mono text-2xl">
|
<h2 class="text-text mb-6 font-mono text-2xl">
|
||||||
|
|||||||
@@ -16,23 +16,24 @@ const assets: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,
|
client: S3Client,
|
||||||
bucket: string
|
bucket: string,
|
||||||
|
prefix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
try {
|
try {
|
||||||
const listCommand = new ListObjectsV2Command({
|
const listCommand = new ListObjectsV2Command({
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Prefix: "downloads/Gaze-",
|
Prefix: prefix,
|
||||||
MaxKeys: 100
|
MaxKeys: 100
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await client.send(listCommand);
|
const response = await client.send(listCommand);
|
||||||
|
|
||||||
if (!response.Contents || response.Contents.length === 0) {
|
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)
|
// Filter for .dmg files only and sort by LastModified (newest first)
|
||||||
@@ -45,18 +46,38 @@ async function getLatestGazeDMG(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (dmgFiles.length === 0) {
|
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!;
|
const latestFile = dmgFiles[0].Key!;
|
||||||
console.log(`Latest Gaze DMG: ${latestFile}`);
|
console.log(`Latest DMG: ${latestFile}`);
|
||||||
return latestFile;
|
return latestFile;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error finding latest Gaze DMG:", error);
|
console.error(`Error finding latest DMG for ${prefix}:`, error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest Gaze DMG from S3
|
||||||
|
*/
|
||||||
|
async function getLatestGazeDMG(
|
||||||
|
client: S3Client,
|
||||||
|
bucket: string
|
||||||
|
): Promise<string> {
|
||||||
|
return getLatestDMG(client, bucket, "downloads/Gaze-");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest InputHalo DMG from S3
|
||||||
|
*/
|
||||||
|
async function getLatestInputHaloDMG(
|
||||||
|
client: S3Client,
|
||||||
|
bucket: string
|
||||||
|
): Promise<string> {
|
||||||
|
return getLatestDMG(client, bucket, "downloads/InputHalo-");
|
||||||
|
}
|
||||||
|
|
||||||
export const downloadsRouter = createTRPCRouter({
|
export const downloadsRouter = createTRPCRouter({
|
||||||
getDownloadUrl: publicProcedure
|
getDownloadUrl: publicProcedure
|
||||||
.input(z.object({ asset_name: z.string() }))
|
.input(z.object({ asset_name: z.string() }))
|
||||||
@@ -76,9 +97,11 @@ export const downloadsRouter = createTRPCRouter({
|
|||||||
try {
|
try {
|
||||||
let fileKey: string;
|
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") {
|
if (input.asset_name === "gaze") {
|
||||||
fileKey = await getLatestGazeDMG(client, bucket);
|
fileKey = await getLatestGazeDMG(client, bucket);
|
||||||
|
} else if (input.asset_name === "inputhalo") {
|
||||||
|
fileKey = await getLatestInputHaloDMG(client, bucket);
|
||||||
} else {
|
} else {
|
||||||
// Use static mapping for other assets
|
// Use static mapping for other assets
|
||||||
fileKey = assets[input.asset_name];
|
fileKey = assets[input.asset_name];
|
||||||
|
|||||||
Reference in New Issue
Block a user