From af9978f1b0d6e971815c6caf5773bc2e04a7809a Mon Sep 17 00:00:00 2001 From: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue, 20 Oct 2026 20:42:13 +0800 Subject: [PATCH 001/754] perf(desktop): strip local symbols from the bundled macOS ONNX Runtime --- .github/workflows/ci.yml | 13 +++++++++++++ scripts/setup.js | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57810c00587..ebafe4afa24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,7 @@ jobs: - 'Cargo.lock' gpui: - '.gitattributes' + - 'scripts/setup.js' - 'apps/desktop-gpui/**' - 'apps/desktop/src/assets/**' - 'apps/desktop/src-tauri/src/recording_start_sound.rs' @@ -340,6 +341,18 @@ jobs: env: RUST_TARGET_TRIPLE: ${{ matrix.settings.target }} + # setup.js strips the local symbols from Microsoft's ONNX Runtime dylib + # before Cap bundles it; the C API ort loads through must still resolve + # and run a real inference. + - name: Test the prepared ONNX Runtime + if: ${{ runner.os == 'macOS' }} + shell: bash + run: | + set -euo pipefail + dylib=target/native-deps/onnxruntime/lib/libonnxruntime.dylib + nm -gU "$dylib" | grep -q OrtGetApiBase + cargo test --locked -p cap-camera-effects --lib segmentation::tests::inference_runs_from_a_caller_with_a_tiny_stack -- --ignored --exact + # The test build compiles every line the binary build does (the app has # no cfg(not(test)) code), so a separate binary build only repeated the # app crate's compile and link. Release builds still produce the binary. diff --git a/scripts/setup.js b/scripts/setup.js index d61d0898c32..278e30a588e 100644 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -434,6 +434,9 @@ async function setupMacOSOnnxRuntime() { const outputDir = path.join(targetDir, "native-deps", "onnxruntime", "lib"); const outputPath = path.join(outputDir, "libonnxruntime.dylib"); const markerPath = path.join(outputDir, "asset.txt"); + // Microsoft's dylib keeps ~12 MB of local symbols nothing in Cap reads; the + // marker changes with the preparation so a cached unstripped copy is redone. + const preparedMarker = `${asset.name}:stripped`; const marker = await fs .readFile(markerPath, "utf-8") .then((value) => value.trim()) @@ -448,7 +451,7 @@ async function setupMacOSOnnxRuntime() { console.log(`Downloaded ${asset.name}`); } else console.log(`Using cached ${asset.name}`); - if (!(await fileExists(outputPath)) || marker !== asset.name) { + if (!(await fileExists(outputPath)) || marker !== preparedMarker) { await fs.rm(extractDir, { recursive: true, force: true }).catch(() => {}); await execFile("tar", ["xf", archivePath, "-C", targetDir]); await fs.mkdir(outputDir, { recursive: true }); @@ -456,8 +459,11 @@ async function setupMacOSOnnxRuntime() { path.join(extractDir, "lib", "libonnxruntime.dylib"), outputPath, ); + // Local symbols only: the exported C API (OrtGetApiBase) that ort loads + // through is unchanged. + await execFile("strip", ["-x", outputPath]); await signMacOSDylib(outputPath); - await fs.writeFile(markerPath, asset.name); + await fs.writeFile(markerPath, preparedMarker); console.log("Prepared ONNX Runtime dylib"); } else { console.log("Using cached ONNX Runtime dylib"); From 1d4067138213c531a276f564c35edd0e3a222ce9 Mon Sep 17 00:00:00 2001 From: Reet Singh <183598724+Reet24-del@users.noreply.github.com> Date: Mon, 26 Oct 2026 12:25:43 +0530 Subject: [PATCH 002/754] perf(gpui): reuse one row of screenshot blur scratch --- apps/desktop-gpui/kernels/src/screenshot.rs | 37 ++++++++------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/apps/desktop-gpui/kernels/src/screenshot.rs b/apps/desktop-gpui/kernels/src/screenshot.rs index ef353a6625a..94e80a7b0f1 100644 --- a/apps/desktop-gpui/kernels/src/screenshot.rs +++ b/apps/desktop-gpui/kernels/src/screenshot.rs @@ -469,9 +469,11 @@ fn resize_triangle( let vertical_weights = triangle_axis(height, new_height); let horizontal_weights = triangle_axis(width, new_width); let row_bytes = width as usize * 4; - let mut vertical = vec![0f32; row_bytes * new_height as usize]; + let mut vertical = vec![0f32; row_bytes]; + let packed = (horizontal_weights.max_taps <= 3).then(|| pack_tap3(&horizontal_weights)); + let out_row = new_width as usize * 4; + let mut out = vec![0u8; out_row * new_height as usize]; for out_y in 0..new_height as usize { - let dst = &mut vertical[out_y * row_bytes..(out_y + 1) * row_bytes]; let tap_count = vertical_weights.count[out_y] as usize; let weight_at = vertical_weights.offset[out_y]; let src_y0 = vertical_weights.start[out_y]; @@ -479,29 +481,18 @@ fn resize_triangle( for (tap, &weight) in weights.iter().enumerate() { let src_y = src_y0 + tap as u32; let start = (y0 + src_y) as usize * stride + x0 as usize * 4; - accumulate_row(dst, &src[start..start + row_bytes], weight, tap == 0); - } - } - - let out_row = new_width as usize * 4; - let mut out = vec![0u8; out_row * new_height as usize]; - if horizontal_weights.max_taps <= 3 { - let packed = pack_tap3(&horizontal_weights); - for y in 0..new_height as usize { - sample_horizontal_tap3( - &vertical[y * row_bytes..(y + 1) * row_bytes], - &mut out[y * out_row..(y + 1) * out_row], - &packed, - width, + accumulate_row( + &mut vertical, + &src[start..start + row_bytes], + weight, + tap == 0, ); } - } else { - for y in 0..new_height as usize { - sample_horizontal_general( - &vertical[y * row_bytes..(y + 1) * row_bytes], - &mut out[y * out_row..(y + 1) * out_row], - &horizontal_weights, - ); + let dst = &mut out[out_y * out_row..(out_y + 1) * out_row]; + if let Some(packed) = &packed { + sample_horizontal_tap3(&vertical, dst, packed, width); + } else { + sample_horizontal_general(&vertical, dst, &horizontal_weights); } } out From 19340e2abdf5902b53476814836291ae58c3fe77 Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Nov 2026 14:23:22 -0500 Subject: [PATCH 003/754] fix(web): end Pro by email when a canceled customer's userId is stale --- .../unit/pro-checkout-webhook.test.ts | 25 +++++++ .../__tests__/unit/signed-baa-webhook.test.ts | 5 +- apps/web/app/api/webhooks/stripe/route.ts | 66 +++++++++---------- 3 files changed, 57 insertions(+), 39 deletions(-) diff --git a/apps/web/__tests__/unit/pro-checkout-webhook.test.ts b/apps/web/__tests__/unit/pro-checkout-webhook.test.ts index b7f4e7bb0e7..7aa34ccb28f 100644 --- a/apps/web/__tests__/unit/pro-checkout-webhook.test.ts +++ b/apps/web/__tests__/unit/pro-checkout-webhook.test.ts @@ -499,6 +499,31 @@ describe("Stripe webhook: Cap Pro checkout fulfilment", () => { }); }); + it("ends Pro by email when the customer's userId names a deleted account", async () => { + state.users = [{ ...owner(), stripeSubscriptionStatus: "past_due" }]; + const canceled = fakeSubscription("sub_own", "cus_own", 5, "canceled"); + stripeSubscriptions([canceled]); + mockStripe.customers.retrieve.mockResolvedValue({ + id: "cus_own", + email: "owner@example.com", + metadata: { userId: "user-gone" }, + }); + mockStripe.webhooks.constructEvent.mockReturnValue( + subscriptionEvent("customer.subscription.deleted", canceled), + ); + + expect((await POST(request())).status).toBe(200); + expect(state.users[0]).toMatchObject({ + id: "user-own", + stripeSubscriptionId: "sub_own", + stripeSubscriptionStatus: "canceled", + inviteQuota: 1, + }); + expect(mockStripe.customers.update).toHaveBeenCalledWith("cus_own", { + metadata: { userId: "user-own" }, + }); + }); + it("moves the account onto the customer's other live subscription when the tracked one is deleted", async () => { const canceled = fakeSubscription("sub_own", "cus_own", 5, "canceled"); stripeSubscriptions([ diff --git a/apps/web/__tests__/unit/signed-baa-webhook.test.ts b/apps/web/__tests__/unit/signed-baa-webhook.test.ts index 07a5ca85c76..bb718a40dd4 100644 --- a/apps/web/__tests__/unit/signed-baa-webhook.test.ts +++ b/apps/web/__tests__/unit/signed-baa-webhook.test.ts @@ -947,9 +947,8 @@ describe("Signed BAA Payment Link webhooks", () => { }); mockStripe.subscriptions.list.mockResolvedValue({ data: [pro] }); if (eventType.endsWith("deleted")) { - mockDbChain.limit.mockResolvedValueOnce([linkedRecord]); - mockDbChain.where - .mockReturnValueOnce(mockDbChain) + mockDbChain.limit + .mockResolvedValueOnce([linkedRecord]) .mockResolvedValueOnce([owner]); } else { mockDbChain.limit diff --git a/apps/web/app/api/webhooks/stripe/route.ts b/apps/web/app/api/webhooks/stripe/route.ts index 74a54f83c2d..f87c9a018ee 100644 --- a/apps/web/app/api/webhooks/stripe/route.ts +++ b/apps/web/app/api/webhooks/stripe/route.ts @@ -992,42 +992,36 @@ export const POST = async (req: Request) => { ? User.UserId.make(customer.metadata.userId) : undefined; } - if (!foundUserId) { - console.log("No user found in metadata, checking customer email"); - if ("email" in customer && customer.email) { - const userByEmail = await db() + + let [subscriptionUser] = foundUserId + ? await db() .select() .from(users) - .where(eq(users.email, customer.email)) - .limit(1); - - if (userByEmail && userByEmail.length > 0 && userByEmail[0]) { - foundUserId = userByEmail[0].id; - linkCustomerToUser = true; - console.log(`User found by email: ${foundUserId}`); - } else { - console.log("No user found by email"); - return new Response("No user found", { - status: 400, - }); - } - } else { - console.log("No email found for customer"); - return new Response("No user found", { - status: 400, - }); - } - } + .where(eq(users.id, foundUserId)) + .limit(1) + : []; - const userResult = await db() - .select() - .from(users) - .where(eq(users.id, foundUserId)); - - const [subscriptionUser] = userResult; + // Older customers carry a metadata userId for an account that no + // longer exists. Rejecting the event left the account on past_due, + // which keeps Pro forever, so match on email like the other events. if (!subscriptionUser) { - console.log("No user found in database"); - return new Response("No user found", { status: 400 }); + console.log("No user found from metadata, checking customer email"); + if (!("email" in customer) || !customer.email) { + console.log("No email found for customer"); + return new Response("No user found", { status: 400 }); + } + [subscriptionUser] = await db() + .select() + .from(users) + .where(eq(users.email, customer.email)) + .limit(1); + if (!subscriptionUser) { + console.log("No user found by email"); + return new Response("No user found", { status: 400 }); + } + foundUserId = subscriptionUser.id; + linkCustomerToUser = true; + console.log(`User found by email: ${foundUserId}`); } if ( @@ -1045,7 +1039,7 @@ export const POST = async (req: Request) => { if (linkCustomerToUser) { await stripe().customers.update(customer.id, { - metadata: { userId: foundUserId }, + metadata: { userId: subscriptionUser.id }, }); } @@ -1070,11 +1064,11 @@ export const POST = async (req: Request) => { await db() .update(users) .set(userUpdate) - .where(eq(users.id, foundUserId)); - await enqueueLoopsSync(db(), foundUserId); + .where(eq(users.id, subscriptionUser.id)); + await enqueueLoopsSync(db(), subscriptionUser.id); console.log("User updated successfully", { - foundUserId, + userId: subscriptionUser.id, ...userUpdate, }); } From d50be1357f73ddd67bb77265964c0f0d47b6bd6e Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Nov 2026 20:08:12 -0500 Subject: [PATCH 004/754] fix(web): keep a cap in its personal folder when it is removed from the organization --- .github/workflows/ci.yml | 1 + .../unit/remove-organization-videos.test.ts | 25 ++++++++++++++++--- .../actions/organizations/remove-videos.ts | 11 +++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b274a54e2c2..88add0178d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,6 +153,7 @@ jobs: __tests__/unit/pro-checkout-webhook.test.ts __tests__/unit/referral-checkout.test.ts __tests__/unit/remove-organization-member.test.ts + __tests__/unit/remove-organization-videos.test.ts __tests__/unit/reply-notification.test.ts __tests__/unit/seo-demo-videos.test.ts __tests__/unit/share-comments-rendering.test.ts diff --git a/apps/web/__tests__/unit/remove-organization-videos.test.ts b/apps/web/__tests__/unit/remove-organization-videos.test.ts index 0039691472a..547ebbec5ae 100644 --- a/apps/web/__tests__/unit/remove-organization-videos.test.ts +++ b/apps/web/__tests__/unit/remove-organization-videos.test.ts @@ -22,10 +22,12 @@ const colleagueVideo = Video.VideoId.make("video-colleague"); let memberRole: string | null; let sharedRows: { videoId: Video.VideoId; ownerId: string }[]; +let folderSql = ""; const writes: { table: string; params: unknown[] }[] = []; beforeEach(() => { writes.length = 0; + folderSql = ""; memberRole = "member"; sharedRows = [ { videoId: ownVideo, ownerId: "member-user" }, @@ -42,7 +44,10 @@ beforeEach(() => { return memberRole ? [{ id: "membership", role: memberRole }] : []; if (table === "shared_videos") return sharedRows.filter((row) => params.includes(row.videoId)); - if (table === "folders") return [{ id: "folder-1" }]; + if (table === "folders") + return folderSql.includes("spaceId") + ? [{ id: "org-folder" }] + : [{ id: "personal-folder" }, { id: "org-folder" }]; return []; }; const query = Object.assign( @@ -54,7 +59,9 @@ beforeEach(() => { }, leftJoin: () => query, where(filter: SQL) { - params = dialect.sqlToQuery(filter).params; + const compiled = dialect.sqlToQuery(filter); + params = compiled.params; + if (table === "folders") folderSql = compiled.sql; return query; }, limit: () => query, @@ -95,6 +102,16 @@ describe("removing videos from an organization", () => { expect(writes).toEqual([]); }); + it("only unfiles videos from the organization's folders, not personal ones", async () => { + await removeVideosFromOrganization(organizationId, [ownVideo]); + + expect(folderSql).toContain("spaceId"); + expect(writes).toContainEqual({ + table: "videos", + params: [ownVideo, "org-folder"], + }); + }); + it("only removes and unfiles the member's own videos from a mixed request", async () => { const result = await removeVideosFromOrganization(organizationId, [ ownVideo, @@ -104,7 +121,7 @@ describe("removing videos from an organization", () => { expect(result).toMatchObject({ success: true }); expect(writes).toEqual([ { table: "shared_videos", params: [organizationId, ownVideo] }, - { table: "videos", params: [ownVideo, "folder-1"] }, + { table: "videos", params: [ownVideo, "org-folder"] }, ]); }); @@ -122,7 +139,7 @@ describe("removing videos from an organization", () => { expect(result).toMatchObject({ success: true }); expect(writes).toEqual([ { table: "shared_videos", params: [organizationId, colleagueVideo] }, - { table: "videos", params: [colleagueVideo, "folder-1"] }, + { table: "videos", params: [colleagueVideo, "org-folder"] }, ]); }); diff --git a/apps/web/actions/organizations/remove-videos.ts b/apps/web/actions/organizations/remove-videos.ts index 71a08f71455..14e52fc8e1a 100644 --- a/apps/web/actions/organizations/remove-videos.ts +++ b/apps/web/actions/organizations/remove-videos.ts @@ -106,12 +106,17 @@ export async function removeVideosFromOrganization( ), ); - // Clear folderId for videos that are being removed from the organization and are currently in folders within that organization - // First, get all folder IDs that belong to this organization + // Clear folderId for videos that are being removed from the organization and are currently in the organization's own folders. + // Personal folders (spaceId null) also carry the organizationId, and a Cap's place in My Caps must survive unsharing it. const organizationFolders = await db() .select({ id: folders.id }) .from(folders) - .where(eq(folders.organizationId, organizationId)); + .where( + and( + eq(folders.organizationId, organizationId), + eq(folders.spaceId, organizationId), + ), + ); const organizationFolderIds = organizationFolders.map((f) => f.id); From 5ab2b25219cd30801db43a07e729a8c062446a24 Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Nov 2026 20:15:22 -0500 Subject: [PATCH 005/754] fix(web): keep unsaved sharing changes when inviting or removing a viewer --- .github/workflows/ci.yml | 3 ++ .../sharing-dialog-viewer-invites.test.ts | 32 +++++++++++++++++++ .../caps/components/SharingDialog.tsx | 13 ++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b274a54e2c2..cbb0ae90677 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -161,6 +161,9 @@ jobs: __tests__/unit/share-transcript-rendering.test.ts __tests__/unit/share-video-quota-loading.test.ts __tests__/unit/shared-cap-card-delete.test.ts + __tests__/unit/sharing-dialog-link-access.test.ts + __tests__/unit/sharing-dialog-share-url.test.ts + __tests__/unit/sharing-dialog-viewer-invites.test.ts __tests__/unit/sdk-recorder-hook.test.ts __tests__/unit/signed-baa-card.test.ts __tests__/unit/sonner-theme.test.ts diff --git a/apps/web/__tests__/unit/sharing-dialog-viewer-invites.test.ts b/apps/web/__tests__/unit/sharing-dialog-viewer-invites.test.ts index ac548350051..4d8de5d9343 100644 --- a/apps/web/__tests__/unit/sharing-dialog-viewer-invites.test.ts +++ b/apps/web/__tests__/unit/sharing-dialog-viewer-invites.test.ts @@ -237,4 +237,36 @@ describe("sharing dialog viewer invitations", () => { expect(mocks.toast.error).toHaveBeenCalledWith("Unable to invite viewer"); expectNoSuccessEffects(); }); + + it("keeps unsaved edits when the page refreshes, and resets on reopen", async () => { + const renderOpen = (isOpen: boolean) => + act(async () => { + root.render( + createElement( + QueryClientProvider, + { client: queryClient }, + createElement(SharingDialog, { + isOpen, + onClose: vi.fn(), + capId: Video.VideoId.make("video-id"), + capName: "Test video", + sharedSpaces: [], + onSharingUpdated: vi.fn(), + isPublic: false, + }), + ), + ); + }); + await render(); + await enterEmail("someone@example.com"); + + await renderOpen(true); + await flushUpdates(); + expect(emailInput().value).toBe("someone@example.com"); + + await renderOpen(false); + await renderOpen(true); + await flushUpdates(); + expect(emailInput().value).toBe(""); + }); }); diff --git a/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx b/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx index 7b525baa02e..986cc9aa663 100644 --- a/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx +++ b/apps/web/app/(org)/dashboard/caps/components/SharingDialog.tsx @@ -17,7 +17,7 @@ import clsx from "clsx"; import { Check, Globe2, Lock, Search } from "lucide-react"; import { motion } from "motion/react"; import { useRouter } from "next/navigation"; -import { useCallback, useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { toast } from "sonner"; import { shareCap } from "@/actions/caps/share"; import { @@ -324,8 +324,17 @@ export const SharingDialog: React.FC = ({ const sharedSpaceIds = new Set(sharedSpaces?.map((space) => space.id) || []); + // Reset to the saved settings once each time the dialog opens. Inviting or + // removing a viewer refreshes the page, which hands in a new sharedSpaces + // array; resetting on that would drop the edits the user has not saved. + const initializedForOpen = useRef(false); useEffect(() => { - if (isOpen && sharedSpaces) { + if (!isOpen) { + initializedForOpen.current = false; + return; + } + if (sharedSpaces && !initializedForOpen.current) { + initializedForOpen.current = true; const spaceIds = new Set(sharedSpaces.map((space) => space.id)); setSelectedSpaces(spaceIds); setInitialSelectedSpaces(spaceIds); From 6f4b2bb76b115a3083143d60da3e679c68b1056a Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Nov 2026 21:27:10 -0500 Subject: [PATCH 006/754] feat(web): add delivery and speech price constants --- apps/web/lib/developer-pricing.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/web/lib/developer-pricing.ts b/apps/web/lib/developer-pricing.ts index 8fde5060f77..d5fa484761c 100644 --- a/apps/web/lib/developer-pricing.ts +++ b/apps/web/lib/developer-pricing.ts @@ -7,6 +7,10 @@ export const STORAGE_DOLLARS_PER_1000_MINUTES_PER_MONTH = (STORAGE_MICRO_CREDITS_PER_MINUTE_PER_MONTH * 1000) / MICRO_CREDITS_PER_DOLLAR; +export const DELIVERY_DOLLARS_PER_1000_MINUTES = 0.5; + +export const SPEECH_DOLLARS_PER_HOUR = 0.1; + export function dailyStorageMicroCredits(totalMinutes: number) { return Math.floor( (totalMinutes * STORAGE_MICRO_CREDITS_PER_MINUTE_PER_MONTH) / From e1c851c0f76390a18bc6886a18c0c49f08362b4f Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Nov 2026 21:27:11 -0500 Subject: [PATCH 007/754] feat(web): add Cap Infra landing page components Hero, video, speech, player, pricing table with a usage calculator, FAQ and final call to action. Prices come from lib/developer-pricing. --- .../web/components/pages/infra/Calculator.tsx | 336 ++++++++++++++++++ apps/web/components/pages/infra/CodePanel.tsx | 152 ++++++++ apps/web/components/pages/infra/Faq.tsx | 49 +++ apps/web/components/pages/infra/FinalCta.tsx | 32 ++ apps/web/components/pages/infra/Footer.tsx | 64 ++++ apps/web/components/pages/infra/Header.tsx | 53 +++ apps/web/components/pages/infra/Hero.tsx | 46 +++ apps/web/components/pages/infra/InfraPage.tsx | 25 ++ apps/web/components/pages/infra/Player.tsx | 17 + apps/web/components/pages/infra/Pricing.tsx | 62 ++++ apps/web/components/pages/infra/Speech.tsx | 30 ++ apps/web/components/pages/infra/Video.tsx | 46 +++ apps/web/components/pages/infra/content.ts | 328 +++++++++++++++++ apps/web/components/pages/infra/highlight.tsx | 61 ++++ apps/web/components/pages/infra/shared.tsx | 83 +++++ 15 files changed, 1384 insertions(+) create mode 100644 apps/web/components/pages/infra/Calculator.tsx create mode 100644 apps/web/components/pages/infra/CodePanel.tsx create mode 100644 apps/web/components/pages/infra/Faq.tsx create mode 100644 apps/web/components/pages/infra/FinalCta.tsx create mode 100644 apps/web/components/pages/infra/Footer.tsx create mode 100644 apps/web/components/pages/infra/Header.tsx create mode 100644 apps/web/components/pages/infra/Hero.tsx create mode 100644 apps/web/components/pages/infra/InfraPage.tsx create mode 100644 apps/web/components/pages/infra/Player.tsx create mode 100644 apps/web/components/pages/infra/Pricing.tsx create mode 100644 apps/web/components/pages/infra/Speech.tsx create mode 100644 apps/web/components/pages/infra/Video.tsx create mode 100644 apps/web/components/pages/infra/content.ts create mode 100644 apps/web/components/pages/infra/highlight.tsx create mode 100644 apps/web/components/pages/infra/shared.tsx diff --git a/apps/web/components/pages/infra/Calculator.tsx b/apps/web/components/pages/infra/Calculator.tsx new file mode 100644 index 00000000000..a4a2e91e4fa --- /dev/null +++ b/apps/web/components/pages/infra/Calculator.tsx @@ -0,0 +1,336 @@ +"use client"; + +import { classNames } from "@cap/utils/helpers"; +import NumberFlow from "@number-flow/react"; +import { type CSSProperties, useId, useState } from "react"; +import { GRAIN } from "@/components/pages/HomeTwo/theme"; +import { PRICES, usd, usdWhole } from "./content"; + +const STEPS = 1000; + +type MeterKey = "stored" | "watched" | "audio"; + +type Meter = { + key: MeterKey; + label: string; + unit: string; + rate: string; + min: number; + max: number; + initial: number; + cost: (value: number) => number; +}; + +const METERS: readonly Meter[] = [ + { + key: "stored", + label: "Minutes stored", + unit: "min", + rate: `${usd(PRICES.storagePer1000Minutes)} per 1,000 minutes, per month`, + min: 100, + max: 10_000_000, + initial: 5_000, + cost: (value) => (value / 1000) * PRICES.storagePer1000Minutes, + }, + { + key: "watched", + label: "Minutes watched per month", + unit: "min", + rate: `${usd(PRICES.deliveryPer1000Minutes)} per 1,000 minutes`, + min: 100, + max: 100_000_000, + initial: 50_000, + cost: (value) => (value / 1000) * PRICES.deliveryPer1000Minutes, + }, + { + key: "audio", + label: "Hours transcribed per month", + unit: "hr", + rate: `${usd(PRICES.speechPerHour)} per hour of audio`, + min: 1, + max: 100_000, + initial: 100, + cost: (value) => value * PRICES.speechPerHour, + }, +]; + +const BREAKDOWN_LABEL: Record = { + stored: "Storage", + watched: "Delivery", + audio: "Speech to text", +}; + +const roundNice = (value: number) => { + if (value < 10) return Math.round(value); + const magnitude = 10 ** (Math.floor(Math.log10(value)) - 1); + return Math.round(value / magnitude) * magnitude; +}; + +const toValue = (meter: Meter, position: number) => { + if (position <= 0) return 0; + const lo = Math.log10(meter.min); + const hi = Math.log10(meter.max); + return Math.min( + meter.max, + roundNice(10 ** (lo + (position / STEPS) * (hi - lo))), + ); +}; + +const toPosition = (meter: Meter, value: number) => { + if (value <= 0) return 0; + if (value <= meter.min) return 1; + const lo = Math.log10(meter.min); + const hi = Math.log10(meter.max); + const position = ((Math.log10(value) - lo) / (hi - lo)) * STEPS; + return Math.min(STEPS, Math.max(1, Math.round(position))); +}; + +const ticksFor = (meter: Meter) => { + const ticks: number[] = []; + for ( + let value = meter.min * 10; + value <= meter.max; + value *= meter.max / meter.min > 1_000_000 ? 100 : 10 + ) { + ticks.push(value); + } + return ticks; +}; + +const compact = new Intl.NumberFormat("en-US", { + notation: "compact", + maximumFractionDigits: 1, +}); + +const grouped = new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }); + +const CURRENCY = { + style: "currency", + currency: "USD", + minimumFractionDigits: 2, + maximumFractionDigits: 2, +} as const; + +const SLIDER = [ + "relative block h-6 w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-none", + "[&::-webkit-slider-runnable-track]:h-[6px] [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:[background:var(--track)]", + "[&::-webkit-slider-thumb]:-mt-[8px] [&::-webkit-slider-thumb]:size-[22px] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:shadow-[0_0_0_1px_rgba(17,17,17,0.14),0_2px_6px_rgba(17,17,17,0.18)] [&::-webkit-slider-thumb]:transition-[box-shadow,transform] [&::-webkit-slider-thumb]:duration-150", + "active:[&::-webkit-slider-thumb]:scale-110 focus-visible:[&::-webkit-slider-thumb]:shadow-[0_0_0_1px_rgba(17,17,17,0.14),0_0_0_5px_rgba(61,119,194,0.28)]", + "[&::-moz-range-track]:h-[6px] [&::-moz-range-track]:rounded-full [&::-moz-range-track]:[background:var(--track)]", + "[&::-moz-range-thumb]:size-[22px] [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-white [&::-moz-range-thumb]:shadow-[0_0_0_1px_rgba(17,17,17,0.14),0_2px_6px_rgba(17,17,17,0.18)]", + "focus-visible:[&::-moz-range-thumb]:shadow-[0_0_0_1px_rgba(17,17,17,0.14),0_0_0_5px_rgba(61,119,194,0.28)]", +].join(" "); + +const MeterInput = ({ + meter, + value, + onChange, +}: { + meter: Meter; + value: number; + onChange: (value: number) => void; +}) => { + const id = useId(); + const [draft, setDraft] = useState(null); + const position = toPosition(meter, value); + const fill = (position / STEPS) * 100; + const trackStyle = { + "--track": `linear-gradient(to right, #3D77C2 0%, #6FA8E8 ${fill}%, #DCE4EC ${fill}%, #DCE4EC 100%)`, + } as CSSProperties; + + return ( +
+
+
+ +

+ {meter.rate} +

+
+
+ { + setDraft(String(value)); + event.currentTarget.select(); + }} + onBlur={() => setDraft(null)} + onChange={(event) => { + const digits = event.target.value.replace(/\D/g, ""); + setDraft(digits); + const next = digits === "" ? 0 : Number(digits); + onChange(Math.min(meter.max, next)); + }} + className="w-full min-w-0 bg-transparent text-right text-[16px] tabular-nums text-[#111111] outline-none" + /> + + {meter.unit} + +
+
+
+ + onChange(toValue(meter, Number(event.target.value))) + } + className={SLIDER} + style={trackStyle} + /> + +
+
+ ); +}; + +export const Calculator = () => { + const [values, setValues] = useState>(() => ({ + stored: METERS[0]?.initial ?? 0, + watched: METERS[1]?.initial ?? 0, + audio: METERS[2]?.initial ?? 0, + })); + const [pro, setPro] = useState(false); + const proId = useId(); + + const lines = METERS.map((meter) => ({ + key: meter.key, + label: BREAKDOWN_LABEL[meter.key], + cost: meter.cost(values[meter.key]), + })); + const subtotal = lines.reduce((sum, line) => sum + line.cost, 0); + const credit = pro ? Math.min(PRICES.proMonthlyCredit, subtotal) : 0; + const total = Math.max(0, subtotal - credit); + + return ( +
+
+ {METERS.map((meter) => ( + + setValues((current) => ({ ...current, [meter.key]: next })) + } + /> + ))} +
+
+

Your monthly estimate

+

+ +

+
+ {lines.map((line) => ( +
+
{line.label}
+
{usd(line.cost)}
+
+ ))} +
+
Encoding
+
Free
+
+
+
Player
+
Included
+
+ {pro ? ( +
+
Cap Pro credit
+
+ −{usd(credit)} +
+
+ ) : null} +
+
+ +

+ Prepaid credits with optional auto top-up. No minimums, no seats, no + plans. +

+
+
+
+ ); +}; diff --git a/apps/web/components/pages/infra/CodePanel.tsx b/apps/web/components/pages/infra/CodePanel.tsx new file mode 100644 index 00000000000..9a8783fcbbb --- /dev/null +++ b/apps/web/components/pages/infra/CodePanel.tsx @@ -0,0 +1,152 @@ +"use client"; + +import { classNames } from "@cap/utils/helpers"; +import { + type KeyboardEvent, + type ReactNode, + useId, + useRef, + useSyncExternalStore, +} from "react"; +import { CopyIconButton } from "@/components/pages/agents/copy"; +import { GRAIN, MONO } from "@/components/pages/HomeTwo/theme"; + +export type PanelTab = { + id: string; + label: string; + code: string; + content: ReactNode; +}; + +const listeners = new Set<() => void>(); +let preferred = "curl"; + +const subscribe = (listener: () => void) => { + listeners.add(listener); + return () => { + listeners.delete(listener); + }; +}; + +const setPreferred = (id: string) => { + preferred = id; + for (const listener of listeners) listener(); +}; + +const usePreferred = () => + useSyncExternalStore( + subscribe, + () => preferred, + () => "curl", + ); + +const PRE = `${MONO} m-0 overflow-x-auto px-5 py-4 text-[12px] leading-[1.75] [tab-size:2] sm:text-[13px]`; + +export const CodePanel = ({ + tabs, + response, + label, + className, +}: { + tabs: readonly PanelTab[]; + response?: ReactNode; + label: string; + className?: string; +}) => { + const preferredId = usePreferred(); + const baseId = useId(); + const tabRefs = useRef<(HTMLButtonElement | null)[]>([]); + const active = tabs.find((tab) => tab.id === preferredId) ?? tabs[0]; + if (!active) return null; + const activeIndex = tabs.indexOf(active); + const switchable = tabs.length > 1; + + const onKeyDown = (event: KeyboardEvent) => { + if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return; + event.preventDefault(); + const step = event.key === "ArrowRight" ? 1 : -1; + const next = (activeIndex + step + tabs.length) % tabs.length; + const tab = tabs[next]; + if (!tab) return; + setPreferred(tab.id); + tabRefs.current[next]?.focus(); + }; + + return ( +
+
+ {switchable ? ( +
+ {tabs.map((tab, i) => { + const selected = tab.id === active.id; + return ( + + ); + })} +
+ ) : ( +

+ {active.label} +

+ )} + +
+ {switchable ? ( +
+
+						{active.content}
+					
+
+ ) : ( +
+					{active.content}
+				
+ )} + {response ? ( +
+

+ Response +

+
+						{response}
+					
+
+ ) : null} +
+ ); +}; diff --git a/apps/web/components/pages/infra/Faq.tsx b/apps/web/components/pages/infra/Faq.tsx new file mode 100644 index 00000000000..0650095adcb --- /dev/null +++ b/apps/web/components/pages/infra/Faq.tsx @@ -0,0 +1,49 @@ +import Link from "next/link"; +import { BODY_TEXT } from "@/components/pages/HomeTwo/theme"; +import { ANCHORS, infraFaqs, LINKS } from "./content"; +import { Section, SectionHeading } from "./shared"; + +export const Faq = () => ( +
+
+
+ +

+ The full reference lives in the{" "} + + docs + + . +

+
+
+
+ {infraFaqs.map((item) => ( +
+ + {item.question} + +

+ {item.answer} +

+
+ ))} +
+
+
+); diff --git a/apps/web/components/pages/infra/FinalCta.tsx b/apps/web/components/pages/infra/FinalCta.tsx new file mode 100644 index 00000000000..1e47a94b6f2 --- /dev/null +++ b/apps/web/components/pages/infra/FinalCta.tsx @@ -0,0 +1,32 @@ +import Link from "next/link"; +import { + BODY_TEXT, + BTN_PRIMARY, + BTN_SECONDARY, + H_HERO, +} from "@/components/pages/HomeTwo/theme"; +import { LINKS } from "./content"; + +export const FinalCta = () => ( +
+
+

+ Your first video is one request away. +

+

+ Create an app, grab a key and upload your first video. Encoding is on + us. +

+
+ + Start building + + + Read the docs + +
+
+
+); diff --git a/apps/web/components/pages/infra/Footer.tsx b/apps/web/components/pages/infra/Footer.tsx new file mode 100644 index 00000000000..5f7b3b35ce6 --- /dev/null +++ b/apps/web/components/pages/infra/Footer.tsx @@ -0,0 +1,64 @@ +import { Logo } from "@cap/ui/logo"; +import Link from "next/link"; +import { ANCHORS, LINKS } from "./content"; + +const FOOTER_LINKS = [ + { label: "Cap.so", href: LINKS.home }, + { label: "Docs", href: LINKS.docs }, + { label: "Pricing", href: `#${ANCHORS.pricing}` }, + { label: "Privacy", href: LINKS.privacy }, + { label: "Terms", href: LINKS.terms }, + { label: "GitHub", href: LINKS.github }, +] as const; + +const LINK = + "rounded-[6px] text-[14px] text-[rgba(17,17,17,0.6)] transition-colors duration-200 hover:text-[#111111] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#111111]"; + +export const Footer = () => ( +
+
+
+ +
+ +
+

+ © Cap Software, Inc. {new Date().getFullYear()}. Cap is open source. +

+
+); diff --git a/apps/web/components/pages/infra/Header.tsx b/apps/web/components/pages/infra/Header.tsx new file mode 100644 index 00000000000..1b1a1631719 --- /dev/null +++ b/apps/web/components/pages/infra/Header.tsx @@ -0,0 +1,53 @@ +import { Logo } from "@cap/ui/logo"; +import Link from "next/link"; +import { LINKS, NAV_LINKS } from "./content"; + +const NAV_ITEM = + "rounded-[8px] px-3 py-2 text-[14.5px] text-[rgba(17,17,17,0.7)] transition-colors duration-200 hover:bg-[#EDF1F6] hover:text-[#111111] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#111111]"; + +export const Header = () => ( +
+
+
+ + +
+
+ + Sign in + + + Start building + +
+
+
+); diff --git a/apps/web/components/pages/infra/Hero.tsx b/apps/web/components/pages/infra/Hero.tsx new file mode 100644 index 00000000000..50599b4fe2d --- /dev/null +++ b/apps/web/components/pages/infra/Hero.tsx @@ -0,0 +1,46 @@ +import Link from "next/link"; +import { + BODY_TEXT, + BTN_PRIMARY, + BTN_SECONDARY, + H_HERO, +} from "@/components/pages/HomeTwo/theme"; +import { ANCHORS, CREATE_VIDEO, CREATE_VIDEO_RESPONSE, LINKS } from "./content"; +import { Code } from "./shared"; + +export const Hero = () => ( +
+
+
+

+ + Upload a video. + + + Get back a stream. + +

+

+ Cap Infra turns every upload into adaptive HLS, an MP4, a thumbnail + and a transcript, served from a CDN. It runs on the same GPUs that + process every Cap recording, and encoding is free. +

+
+ + Start building + + + See pricing + +
+
+ +
+
+); diff --git a/apps/web/components/pages/infra/InfraPage.tsx b/apps/web/components/pages/infra/InfraPage.tsx new file mode 100644 index 00000000000..551cdf94341 --- /dev/null +++ b/apps/web/components/pages/infra/InfraPage.tsx @@ -0,0 +1,25 @@ +import { CREAM, grainBg } from "@/components/pages/HomeTwo/theme"; +import { Faq } from "./Faq"; +import { FinalCta } from "./FinalCta"; +import { Hero } from "./Hero"; +import { Player } from "./Player"; +import { Pricing } from "./Pricing"; +import { Speech } from "./Speech"; +import { Video } from "./Video"; + +export const InfraPage = () => ( +
+
+ +
+
+); diff --git a/apps/web/components/pages/infra/Player.tsx b/apps/web/components/pages/infra/Player.tsx new file mode 100644 index 00000000000..ebbd9724441 --- /dev/null +++ b/apps/web/components/pages/infra/Player.tsx @@ -0,0 +1,17 @@ +import { ANCHORS, DIRECT, EMBED } from "./content"; +import { Code, Section, SectionHeading } from "./shared"; + +export const Player = () => ( +
+ +

+ Drop in the Cap player, a lightweight embed with nothing to build. Or + skip it and point any player you like at the HLS or MP4 URL. +

+
+
+ + +
+
+); diff --git a/apps/web/components/pages/infra/Pricing.tsx b/apps/web/components/pages/infra/Pricing.tsx new file mode 100644 index 00000000000..8b10f30feac --- /dev/null +++ b/apps/web/components/pages/infra/Pricing.tsx @@ -0,0 +1,62 @@ +import { Calculator } from "./Calculator"; +import { ANCHORS, PRICE_ROWS, PRICES, usdWhole } from "./content"; +import { Section, SectionHeading } from "./shared"; + +export const Pricing = () => ( +
+
+ +

+ Encoding is free. You pay for what you store, what your viewers watch + and what you transcribe. No minimums, no seats, no plans. +

+

+ Cap Pro subscribers get {usdWhole(PRICES.proMonthlyCredit)} of usage + every month. +

+
+ + + + + + + + + + {PRICE_ROWS.map((row) => ( + + + + + ))} + +
Cap Infra prices
MeterPrice
+ {row.meter} + + + {row.price} + + + {row.unit} + + {row.note ? ( + + {row.note} + + ) : null} +
+
+
+

+ Estimate your month +

+
+ +
+
+
+); diff --git a/apps/web/components/pages/infra/Speech.tsx b/apps/web/components/pages/infra/Speech.tsx new file mode 100644 index 00000000000..01fded0bd3c --- /dev/null +++ b/apps/web/components/pages/infra/Speech.tsx @@ -0,0 +1,30 @@ +import { ANCHORS, CREATE_TRANSCRIPT, PRICES, usd } from "./content"; +import { Code, Section, SectionHeading } from "./shared"; + +export const Speech = () => ( +
+
+
+ +
+
+ +

+ The speech API works on its own. Send audio or video from anywhere + and get a transcript back, without hosting the file on Cap. +

+

+ Already on a speech SDK? Change its base URL to Cap and keep your + code. +

+
+

+ + {usd(PRICES.speechPerHour)} per hour of audio. + {" "} + Free for videos hosted on Cap Infra. +

+
+
+
+); diff --git a/apps/web/components/pages/infra/Video.tsx b/apps/web/components/pages/infra/Video.tsx new file mode 100644 index 00000000000..00f73a2b67e --- /dev/null +++ b/apps/web/components/pages/infra/Video.tsx @@ -0,0 +1,46 @@ +import { + ANCHORS, + GET_VIDEO, + GET_VIDEO_RESPONSE, + UPLOAD_SOURCES, + VIDEO_OUTPUTS, +} from "./content"; +import { Code, Section, SectionHeading } from "./shared"; + +export const Video = () => ( +
+
+
+ +

+ Send a file from {UPLOAD_SOURCES[0]}, {UPLOAD_SOURCES[1]}, or{" "} + {UPLOAD_SOURCES[2]}. When it is ready, one request gives you every + way to play it. +

+
+
+ {VIDEO_OUTPUTS.map((item) => ( +
+
+ {item.name} +
+
+ {item.detail} +
+
+ ))} +
+
+
+ +
+
+
+); diff --git a/apps/web/components/pages/infra/content.ts b/apps/web/components/pages/infra/content.ts new file mode 100644 index 00000000000..d65d6b60a4e --- /dev/null +++ b/apps/web/components/pages/infra/content.ts @@ -0,0 +1,328 @@ +import { + DELIVERY_DOLLARS_PER_1000_MINUTES, + SPEECH_DOLLARS_PER_HOUR, + STORAGE_DOLLARS_PER_1000_MINUTES_PER_MONTH, +} from "@/lib/developer-pricing"; + +export const infraSeo = { + path: "/infra", + url: "https://cap.so/infra", + title: "Cap Infra: video and speech APIs", + description: + "Upload a video and get back adaptive HLS up to 4K, an MP4, a thumbnail and a transcript, served from a CDN. Speech to text for any file. Free encoding, usage-based pricing, no plans.", + keywords: [ + "video API", + "video hosting API", + "video encoding API", + "HLS streaming API", + "adaptive bitrate streaming", + "speech to text API", + "transcription API", + "video transcription API", + "embeddable video player", + "usage based video hosting", + ], +} as const; + +export const ANCHORS = { + video: "video", + speech: "speech", + player: "player", + pricing: "pricing", + faq: "faq", +} as const; + +export const NAV_LINKS = [ + { label: "Video", href: `#${ANCHORS.video}` }, + { label: "Speech", href: `#${ANCHORS.speech}` }, + { label: "Player", href: `#${ANCHORS.player}` }, + { label: "Pricing", href: `#${ANCHORS.pricing}` }, +] as const; + +export const LINKS = { + start: "/dashboard/infra", + docs: "/docs", + signIn: "/login", + home: "/", + privacy: "/privacy", + terms: "/terms", + github: "https://github.com/CapSoftware/Cap", +} as const; + +export const PRICES = { + storagePer1000Minutes: STORAGE_DOLLARS_PER_1000_MINUTES_PER_MONTH, + deliveryPer1000Minutes: DELIVERY_DOLLARS_PER_1000_MINUTES, + speechPerHour: SPEECH_DOLLARS_PER_HOUR, + proMonthlyCredit: 5, +} as const; + +export const usd = (value: number) => + new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", + minimumFractionDigits: 2, + }).format(value); + +export const usdWhole = (value: number) => + new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", + maximumFractionDigits: 0, + }).format(value); + +export type PriceRow = { + meter: string; + price: string; + unit: string; + note?: string; +}; + +export const PRICE_ROWS: readonly PriceRow[] = [ + { + meter: "Encoding", + price: "Free", + unit: "Every rendition, every upload", + }, + { + meter: "Storage", + price: usd(PRICES.storagePer1000Minutes), + unit: "per 1,000 minutes stored, per month", + }, + { + meter: "Delivery", + price: usd(PRICES.deliveryPer1000Minutes), + unit: "per 1,000 minutes watched", + }, + { + meter: "Speech to text", + price: usd(PRICES.speechPerHour), + unit: "per hour of audio", + note: "Free for videos hosted on Cap Infra", + }, + { + meter: "Player", + price: "Included", + unit: "Embed it anywhere", + }, +]; + +export const API_BASE = "https://cap.so/api/developer/v1"; + +export const SAMPLE_ID = "8k2m4x9q"; + +const MEDIA = `https://cdn.example.com/${SAMPLE_ID}`; + +export const PLAYBACK = { + hls: `${MEDIA}/master.m3u8`, + mp4: `${MEDIA}/1080p.mp4`, + thumbnail: `${MEDIA}/thumbnail.jpg`, + captions: `${MEDIA}/captions.vtt`, +} as const; + +export type CodeSample = { + id: "curl" | "ts" | "html"; + label: string; + code: string; +}; + +export const CREATE_VIDEO: readonly CodeSample[] = [ + { + id: "curl", + label: "curl", + code: `curl -X POST ${API_BASE}/videos \\ + -H "Authorization: Bearer csk_..." \\ + -H "Content-Type: application/json" \\ + -d '{ "url": "https://example.com/video.mp4" }'`, + }, + { + id: "ts", + label: "TypeScript", + code: `const res = await fetch("${API_BASE}/videos", { + method: "POST", + headers: { + Authorization: "Bearer csk_...", + "Content-Type": "application/json", + }, + body: JSON.stringify({ url: "https://example.com/video.mp4" }), +}); + +const { data } = await res.json();`, + }, +]; + +export const CREATE_VIDEO_RESPONSE = `{ + "data": { + "id": "${SAMPLE_ID}", + "status": "processing" + } +}`; + +export const GET_VIDEO: readonly CodeSample[] = [ + { + id: "curl", + label: "curl", + code: `curl ${API_BASE}/videos/${SAMPLE_ID} \\ + -H "Authorization: Bearer csk_..."`, + }, + { + id: "ts", + label: "TypeScript", + code: `const res = await fetch("${API_BASE}/videos/${SAMPLE_ID}", { + headers: { Authorization: "Bearer csk_..." }, +}); + +const { data } = await res.json();`, + }, +]; + +export const GET_VIDEO_RESPONSE = `{ + "data": { + "id": "${SAMPLE_ID}", + "status": "ready", + "duration": 184.2, + "playback": { + "hls": "${PLAYBACK.hls}", + "mp4": "${PLAYBACK.mp4}", + "thumbnail": "${PLAYBACK.thumbnail}", + "captions": "${PLAYBACK.captions}" + } + } +}`; + +export const CREATE_TRANSCRIPT: readonly CodeSample[] = [ + { + id: "curl", + label: "curl", + code: `curl -X POST ${API_BASE}/transcripts \\ + -H "Authorization: Bearer csk_..." \\ + -H "Content-Type: application/json" \\ + -d '{ "audio_url": "https://example.com/call.mp3" }'`, + }, + { + id: "ts", + label: "TypeScript", + code: `const res = await fetch("${API_BASE}/transcripts", { + method: "POST", + headers: { + Authorization: "Bearer csk_...", + "Content-Type": "application/json", + }, + body: JSON.stringify({ audio_url: "https://example.com/call.mp3" }), +}); + +const { data } = await res.json();`, + }, +]; + +export const EMBED: readonly CodeSample[] = [ + { + id: "html", + label: "Cap player", + code: ``, + }, +]; + +export const DIRECT: readonly CodeSample[] = [ + { + id: "html", + label: "Your own player", + code: ``, + }, +]; + +export const VIDEO_OUTPUTS = [ + { + name: "Adaptive HLS", + detail: "Renditions from 360p up to 4K, never above the source resolution.", + }, + { + name: "MP4", + detail: "A single file for downloads, previews and simple players.", + }, + { + name: "Thumbnail", + detail: "Ready for your poster frames and listings.", + }, + { + name: "Transcript and captions", + detail: "Generated automatically, with captions as WebVTT.", + }, + { + name: "Signed webhooks", + detail: "Know the moment a video is ready or a transcript completes.", + }, +] as const; + +export const UPLOAD_SOURCES = [ + "the dashboard", + "the REST API", + "a URL to import", +] as const; + +export type Faq = { question: string; answer: string }; + +export const infraFaqs: readonly Faq[] = [ + { + question: "What does encoding cost?", + answer: + "Nothing. Every upload is encoded into an adaptive HLS ladder and an MP4 at no charge. You pay for the minutes you store and the minutes your viewers watch.", + }, + { + question: "How do I pay?", + answer: `With prepaid credits, and you can turn on auto top-up so you never run dry. There are no minimums, no seats and no plans. Cap Pro subscribers get ${usdWhole(PRICES.proMonthlyCredit)} of usage every month.`, + }, + { + question: "Do I have to use the Cap player?", + answer: + "No. Every video comes with direct HLS and MP4 URLs that work in any player. The Cap player is there when you want a lightweight embed with nothing to build.", + }, + { + question: "Can I use the speech API without hosting my video on Cap?", + answer: `Yes. Send any audio or video file and get a transcript back, at ${usd(PRICES.speechPerHour)} per hour of audio. If you already use a speech SDK, change its base URL to Cap. Transcripts for videos hosted on Cap Infra are free.`, + }, + { + question: "How do I know when a video is ready?", + answer: + "Cap sends a signed webhook when a video is ready and when a transcript completes. You can also fetch the video at any time and check its status.", + }, + { + question: "How do API keys work?", + answer: + "Each app gets its own keys. Use the public key in browsers and the secret key on your servers.", + }, + { + question: "Is Cap Infra compliant for sensitive video?", + answer: + "Cap is SOC 2 Type II and HIPAA compliant, and a BAA is available. Cap Infra runs on Cap's own GPUs, the same pipeline that processes every Cap recording.", + }, +]; + +export const infraSoftwareSchema = { + "@context": "https://schema.org", + "@type": "SoftwareApplication", + "@id": "https://cap.so/infra#software", + name: "Cap Infra", + url: infraSeo.url, + description: + "Video and speech APIs from Cap. Upload, encode to adaptive HLS and MP4, generate thumbnails and transcripts, and serve from a CDN, priced by usage.", + applicationCategory: "DeveloperApplication", + operatingSystem: "Web", + offers: { + "@type": "Offer", + price: 0, + priceCurrency: "USD", + description: "Usage-based pricing with free encoding.", + }, + publisher: { + "@type": "Organization", + name: "Cap", + url: "https://cap.so", + }, +} as const; diff --git a/apps/web/components/pages/infra/highlight.tsx b/apps/web/components/pages/infra/highlight.tsx new file mode 100644 index 00000000000..1f03f1b42f1 --- /dev/null +++ b/apps/web/components/pages/infra/highlight.tsx @@ -0,0 +1,61 @@ +import type { ReactNode } from "react"; + +const TOKEN = + /("(?:[^"\\\n]|\\.)*"|'[^'\n]*'|<\/?[a-z]+|\/?>|\b[a-z]+(?==")|(?<=^|\s)-{1,2}[A-Za-z][\w-]*|\b(?:const|await|curl)\b|\b\d+(?:\.\d+)?\b)/g; + +const COLORS = { + key: "#C9B8F8", + string: "#9EE0C2", + number: "#F7C995", + keyword: "#9CC9F5", + plain: "#E8EDF3", + muted: "rgba(232,237,243,0.5)", +} as const; + +const colorOf = (token: string, rest: string) => { + if (token.startsWith('"') || token.startsWith("'")) { + return /^\s*:/.test(rest) ? COLORS.key : COLORS.string; + } + if (token.startsWith("<") || token.endsWith(">")) return COLORS.keyword; + if (token.startsWith("-") || /^[a-z]+$/.test(token)) { + return /^(?:const|await|curl)$/.test(token) || token.startsWith("-") + ? COLORS.keyword + : COLORS.key; + } + return COLORS.number; +}; + +export const highlight = (code: string): ReactNode[] => { + const out: ReactNode[] = []; + let cursor = 0; + for (const match of code.matchAll(TOKEN)) { + const start = match.index ?? 0; + const token = match[0]; + if (start > cursor) { + out.push( + + {code.slice(cursor, start)} + , + ); + } + out.push( + + {token} + , + ); + cursor = start + token.length; + } + if (cursor < code.length) { + out.push( + + {code.slice(cursor)} + , + ); + } + return out; +}; + +export const CODE_MUTED = COLORS.muted; diff --git a/apps/web/components/pages/infra/shared.tsx b/apps/web/components/pages/infra/shared.tsx new file mode 100644 index 00000000000..c7e6480262b --- /dev/null +++ b/apps/web/components/pages/infra/shared.tsx @@ -0,0 +1,83 @@ +import { classNames } from "@cap/utils/helpers"; +import { DM_Mono } from "next/font/google"; +import type { ReactNode } from "react"; +import { BODY_TEXT, H_SECTION } from "@/components/pages/HomeTwo/theme"; +import { CodePanel } from "./CodePanel"; +import type { CodeSample } from "./content"; +import { highlight } from "./highlight"; + +export const infraMono = DM_Mono({ + subsets: ["latin"], + weight: ["400"], + display: "swap", + variable: "--font-ht-mono", +}); + +export const Code = ({ + samples, + response, + label, + className, +}: { + samples: readonly CodeSample[]; + response?: string; + label: string; + className?: string; +}) => ( + ({ + id: sample.id, + label: sample.label, + code: sample.code, + content: highlight(sample.code), + }))} + response={response ? highlight(response) : undefined} + /> +); + +export const SectionHeading = ({ + id, + title, + children, + className, +}: { + id?: string; + title: string; + children?: ReactNode; + className?: string; +}) => ( +
+

+ {title} +

+ {children ? ( +
+ {children} +
+ ) : null} +
+); + +export const Section = ({ + id, + children, + className, +}: { + id?: string; + children: ReactNode; + className?: string; +}) => ( +
+
{children}
+
+); From 236b6b5a816d55e593211a752f36b9fe8b3fbc16 Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Nov 2026 21:27:11 -0500 Subject: [PATCH 008/754] feat(web): serve the Cap Infra landing page at /infra Own route group with a slim header and footer, so it does not inherit the main marketing shell. Metadata, breadcrumb, FAQPage and SoftwareApplication JSON-LD. --- apps/web/app/(infra)/infra/page.tsx | 56 +++++++++++++++++++++++++++++ apps/web/app/(infra)/layout.tsx | 21 +++++++++++ 2 files changed, 77 insertions(+) create mode 100644 apps/web/app/(infra)/infra/page.tsx create mode 100644 apps/web/app/(infra)/layout.tsx diff --git a/apps/web/app/(infra)/infra/page.tsx b/apps/web/app/(infra)/infra/page.tsx new file mode 100644 index 00000000000..6f971601c2d --- /dev/null +++ b/apps/web/app/(infra)/infra/page.tsx @@ -0,0 +1,56 @@ +import type { Metadata } from "next"; +import { + infraFaqs, + infraSeo, + infraSoftwareSchema, +} from "@/components/pages/infra/content"; +import { InfraPage } from "@/components/pages/infra/InfraPage"; +import { buildMarketingMetadata } from "@/lib/og/url"; +import { createBreadcrumbSchema, createFAQSchema } from "@/utils/web-schema"; + +export const metadata: Metadata = { + ...buildMarketingMetadata({ + title: infraSeo.title, + description: infraSeo.description, + path: infraSeo.path, + ogTitle: "Cap Infra", + ogDescription: + "Video and speech APIs on Cap's own GPUs. Free encoding, usage-based pricing.", + ogTag: "Infra", + }), + keywords: [...infraSeo.keywords], + robots: { + index: true, + follow: true, + googleBot: { + index: true, + follow: true, + "max-image-preview": "large", + "max-snippet": -1, + }, + }, +}; + +const schemas = [ + createBreadcrumbSchema([ + { name: "Home", url: "https://cap.so" }, + { name: "Cap Infra", url: infraSeo.url }, + ]), + createFAQSchema( + infraFaqs.map((faq) => ({ question: faq.question, answer: faq.answer })), + ), + infraSoftwareSchema, +]; + +export default function Page() { + return ( + <> + {schemas.map((schema) => ( + + ))} + + + ); +} diff --git a/apps/web/app/(infra)/layout.tsx b/apps/web/app/(infra)/layout.tsx new file mode 100644 index 00000000000..0f1bc33b70f --- /dev/null +++ b/apps/web/app/(infra)/layout.tsx @@ -0,0 +1,21 @@ +import { buildEnv } from "@cap/env"; +import "../(site)/tailwind-base.css"; +import type { PropsWithChildren } from "react"; +import { htSans, htSerif } from "@/components/pages/HomeTwo/fonts"; +import { Footer } from "@/components/pages/infra/Footer"; +import { Header } from "@/components/pages/infra/Header"; +import { infraMono } from "@/components/pages/infra/shared"; +import { DubAnalytics } from "@/components/referrals/DubAnalytics"; + +export default function InfraLayout(props: PropsWithChildren) { + return ( +
+
+ {props.children} +
+ {buildEnv.NEXT_PUBLIC_IS_CAP === "true" && } +
+ ); +} From 6b6587bd7a5bcc333b0fd7df6e1cdc9919e5de83 Mon Sep 17 00:00:00 2001 From: x Date: Tue, 10 Nov 2026 22:29:40 -0500 Subject: [PATCH 009/754] feat(web): add the plain scene for the Cap Infra page A pure CSS monolith on a perspective grid floor under a hazed sun, with a document-wide grain layer. No JavaScript. --- apps/web/components/pages/infra/Plain.tsx | 100 ++++++++ .../components/pages/infra/scene.module.css | 228 ++++++++++++++++++ apps/web/components/pages/infra/theme.ts | 37 +++ 3 files changed, 365 insertions(+) create mode 100644 apps/web/components/pages/infra/Plain.tsx create mode 100644 apps/web/components/pages/infra/scene.module.css create mode 100644 apps/web/components/pages/infra/theme.ts diff --git a/apps/web/components/pages/infra/Plain.tsx b/apps/web/components/pages/infra/Plain.tsx new file mode 100644 index 00000000000..0b1bcb38c90 --- /dev/null +++ b/apps/web/components/pages/infra/Plain.tsx @@ -0,0 +1,100 @@ +import { classNames } from "@cap/utils/helpers"; +import type { CSSProperties, ReactNode } from "react"; +import styles from "./scene.module.css"; + +const W = 1600; +const H = 400; +const VANISH_X = W / 2; + +const rays = Array.from({ length: 41 }, (_, i) => i - 20).map( + (step) => VANISH_X + step * 150, +); + +const rows = Array.from({ length: 15 }, (_, k) => H / (1 + k * 0.6)); + +const NOISE = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E")`; + +export const Grain = () => ( +