Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

clippy + formatting

Richie McIlroya9e909efec89
diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
index 5a05dce99..3cbfb0102 100644
--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx
+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
@@ -45,6 +45,8 @@ import type {
BackgroundBlurMode,
BackgroundSource,
CameraShape,
+ CameraXPosition,
+ CameraYPosition,
CaptionTrackSegment,
ClipOffsets,
CursorAnimationStyle,
@@ -211,6 +213,13 @@ const CAMERA_SHAPES = [
},
] satisfies Array<{ name: string; value: CameraShape }>;
+const CAMERA_X_POSITIONS = [
+ "left",
+ "center",
+ "right",
+] satisfies CameraXPosition[];
+const CAMERA_Y_POSITIONS = ["top", "bottom"] satisfies CameraYPosition[];
+
const CORNER_STYLE_OPTIONS = [
{ name: "Squircle", value: "squircle" },
{ name: "Rounded", value: "rounded" },
@@ -403,9 +412,8 @@ export function ConfigSidebar() {
{
id: TAB_IDS.cursor,
icon: IconCapCursor,
- disabled: !(
- meta().type === "multiple" && (meta() as any).segments[0].cursor
- ),
+ disabled:
+ meta().type !== "multiple" || !meta().segments[0]?.cursor,
},
{
id: TAB_IDS.keyboard,
@@ -674,7 +682,7 @@ export function ConfigSidebar() {
value={[cursorIdleDelay()]}
onChange={(v) => {
const rounded = clampIdleDelay(v[0]);
- setProject("cursor", "hideWhenIdleDelay" as any, rounded);
+ setProject("cursor", "hideWhenIdleDelay", rounded);
}}
minValue={0.5}
maxValue={5}
@@ -770,9 +778,9 @@ export function ConfigSidebar() {
icon={<IconLucideSparkles />}
value={
<Toggle
- checked={(project.cursor as any).useSvg ?? true}
+ checked={project.cursor.useSvg ?? true}
onChange={(value) => {
- setProject("cursor", "useSvg" as any, value);
+ setProject("cursor", "useSvg", value);
}}
/>
}
@@ -1235,59 +1243,68 @@ export function ConfigSidebar() {
segment: project.timeline?.sceneSegments?.[idx],
index: idx,
}))
- .filter((s) => s.segment !== undefined);
+ .filter(
+ (
+ s,
+ ): s is { segment: SceneSegment; index: number } =>
+ s.segment !== undefined,
+ );
if (segments.length === 0) return;
return { selection: sceneSelection, segments };
})()}
>
{(value) => (
- <Show
- when={value().segments.length > 1}
- fallback={
- <SceneSegmentConfig
- segment={value().segments[0].segment!}
- segmentIndex={value().segments[0].index}
- />
- }
- >
- <div class="space-y-4">
- <div class="flex flex-row justify-between items-center">
- <div class="flex gap-2 items-center">
- <EditorButton
- onClick={() =>
- setEditorState("timeline", "selection", null)
- }
- leftIcon={<IconLucideCheck />}
- >
- Done
- </EditorButton>
- <span class="text-sm text-gray-10">
- {value().segments.length} scene{" "}
- {value().segments.length === 1
- ? "segment"
- : "segments"}{" "}
- selected
- </span>
+ <Show when={value().segments[0]}>
+ {(firstSegment) => (
+ <Show
+ when={value().segments.length > 1}
+ fallback={
+ <SceneSegmentConfig
+ segment={firstSegment().segment}
+ segmentIndex={firstSegment().index}
+ />
+ }
+ >
+ <div class="space-y-4">
+ <div class="flex flex-row justify-between items-center">
+ <div class="flex gap-2 items-center">
+ <EditorButton
+ onClick={() =>
+ setEditorState("timeline", "selection", null)
+ }
+ leftIcon={<IconLucideCheck />}
+ >
+ Done
+ </EditorButton>
+ <span class="text-sm text-gray-10">
+ {value().segments.length} scene{" "}
+ {value().segments.length === 1
+ ? "segment"
+ : "segments"}{" "}
+ selected
+ </span>
+ </div>
+ <EditorButton
+ variant="danger"
+ onClick={() => {
+ const indices = value().selection.indices;
+
+ // Delete segments in reverse order to maintain indices
+ [...indices]
+ .sort((a, b) => b - a)
+ .forEach((idx) => {
+ projectActions.deleteSceneSegment(idx);
+ });
+ }}
+ leftIcon={<IconCapTrash />}
+ >
+ Delete
+ </EditorButton>
+ </div>
</div>
- <EditorButton
- variant="danger"
- onClick={() => {
- const indices = value().selection.indices;
-
- // Delete segments in reverse order to maintain indices
- [...indices]
- .sort((a, b) => b - a)
- .forEach((idx) => {
- projectActions.deleteSceneSegment(idx);
- });
- }}
- leftIcon={<IconCapTrash />}
- >
- Delete
- </EditorButton>
- </div>
- </div>
+ </Show>
+ )}
</Show>
)}
</Show>
@@ -1301,59 +1318,68 @@ export function ConfigSidebar() {
segment: project.timeline?.segments?.[idx],
index: idx,
}))
- .filter((s) => s.segment !== undefined);
+ .filter(
+ (
+ s,
+ ): s is { segment: TimelineSegment; index: number } =>
+ s.segment !== undefined,
+ );
if (segments.length === 0) return;
return { selection: clipSelection, segments };
})()}
>
{(value) => (
- <Show
- when={value().segments.length > 1}
- fallback={
- <ClipSegmentConfig
- segment={value().segments[0].segment!}
- segmentIndex={value().segments[0].index}
- />
- }
- >
- <div class="space-y-4">
- <div class="flex flex-row justify-between items-center">
- <div class="flex gap-2 items-center">
- <EditorButton
- onClick={() =>
- setEditorState("timeline", "selection", null)
- }
- leftIcon={<IconLucideCheck />}
- >
- Done
- </EditorButton>
- <span class="text-sm text-gray-10">
- {value().segments.length} clip{" "}
- {value().segments.length === 1
- ? "segment"
- : "segments"}{" "}
- selected
- </span>
+ <Show when={value().segments[0]}>
+ {(firstSegment) => (
+ <Show
+ when={value().segments.length > 1}
+ fallback={
+ <ClipSegmentConfig
+ segment={firstSegment().segment}
+ segmentIndex={firstSegment().index}
+ />
+ }
+ >
+ <div class="space-y-4">
+ <div class="flex flex-row justify-between items-center">
+ <div class="flex gap-2 items-center">
+ <EditorButton
+ onClick={() =>
+ setEditorState("timeline", "selection", null)
+ }
+ leftIcon={<IconLucideCheck />}
+ >
+ Done
+ </EditorButton>
+ <span class="text-sm text-gray-10">
+ {value().segments.length} clip{" "}
+ {value().segments.length === 1
+ ? "segment"
+ : "segments"}{" "}
+ selected
+ </span>
+ </div>
+ <EditorButton
+ variant="danger"
+ onClick={() => {
+ const indices = value().selection.indices;
+
+ // Delete segments in reverse order to maintain indices
+ [...indices]
+ .sort((a, b) => b - a)
+ .forEach((idx) => {
+ projectActions.deleteClipSegment(idx);
+ });
+ }}
+ leftIcon={<IconCapTrash />}
+ >
+ Delete
+ </EditorButton>
+ </div>
</div>
- <EditorButton
- variant="danger"
- onClick={() => {
- const indices = value().selection.indices;
-
- // Delete segments in reverse order to maintain indices
- [...indices]
- .sort((a, b) => b - a)
- .forEach((idx) => {
- projectActions.deleteClipSegment(idx);
- });
- }}
- leftIcon={<IconCapTrash />}
- >
- Delete
- </EditorButton>
- </div>
- </div>
+ </Show>
+ )}
</Show>
)}
</Show>
@@ -1387,11 +1413,11 @@ function BackgroundConfig(props: { scrollRef: HTMLDivElement }) {
const initialPaths = await Promise.all(visibleWallpaperPaths);
return initialPaths
- .filter((p) => p.path !== null)
+ .filter((p): p is { id: string; path: string } => p.path !== null)
.map(({ id, path }) => ({
id,
- url: convertFileSrc(path!),
- rawPath: path!,
+ url: convertFileSrc(path),
+ rawPath: path,
}));
});
@@ -1790,13 +1816,13 @@ function BackgroundConfig(props: { scrollRef: HTMLDivElement }) {
<For each={filteredWallpapers().slice(0, 21)}>
{(photo) => (
<KRadioGroup.Item
- value={photo.url!}
+ value={photo.url}
class="relative aspect-square group"
>
<KRadioGroup.ItemInput class="peer" />
<KRadioGroup.ItemControl class="overflow-hidden w-full h-full rounded-lg transition cursor-pointer ui-not-checked:ring-offset-1 ui-not-checked:ring-offset-gray-200 ui-not-checked:hover:ring-1 ui-not-checked:hover:ring-gray-400 ui-checked:ring-2 ui-checked:ring-gray-500 ui-checked:ring-offset-2 ui-checked:ring-offset-gray-200">
<img
- src={photo.url!}
+ src={photo.url}
loading="eager"
class="object-cover w-full h-full"
alt="Wallpaper option"
@@ -1811,13 +1837,13 @@ function BackgroundConfig(props: { scrollRef: HTMLDivElement }) {
<For each={filteredWallpapers()}>
{(photo) => (
<KRadioGroup.Item
- value={photo.url!}
+ value={photo.url}
class="relative aspect-square group"
>
<KRadioGroup.ItemInput class="peer" />
<KRadioGroup.ItemControl class="overflow-hidden w-full h-full rounded-lg border cursor-pointer border-gray-5 ui-checked:border-blue-9 ui-checked:ring-2 ui-checked:ring-blue-9 peer-focus-visible:border-2 peer-focus-visible:border-blue-9">
<img
- src={photo.url!}
+ src={photo.url}
alt="Wallpaper option"
class="object-cover w-full h-full"
loading="lazy"
@@ -2054,7 +2080,7 @@ function BackgroundConfig(props: { scrollRef: HTMLDivElement }) {
<Field name="Motion Blur" icon={<IconLucideWind class="size-4" />}>
<Slider
value={[project.cursor.motionBlur ?? DEFAULT_CURSOR_MOTION_BLUR]}
- onChange={(v) => setProject("cursor", "motionBlur" as any, v[0])}
+ onChange={(v) => setProject("cursor", "motionBlur", v[0])}
minValue={0}
maxValue={1}
step={0.01}
@@ -2161,7 +2187,7 @@ function BackgroundConfig(props: { scrollRef: HTMLDivElement }) {
</KCollapsible>
<Field name="Shadow" icon={<IconCapShadow class="size-4" />}>
<Slider
- value={[project.background.shadow!]}
+ value={[project.background.shadow ?? 0]}
onChange={(v) => {
batch(() => {
setProject("background", "shadow", v[0]);
@@ -2255,7 +2281,17 @@ function CameraConfig(props: { scrollRef: HTMLDivElement }) {
value={`${project.camera.position.x}:${project.camera.position.y}`}
onChange={(v) => {
const [x, y] = v.split(":");
- setProject("camera", "position", { x, y } as any);
+ const xPosition = CAMERA_X_POSITIONS.find(
+ (position) => position === x,
+ );
+ const yPosition = CAMERA_Y_POSITIONS.find(
+ (position) => position === y,
+ );
+ if (!xPosition || !yPosition) return;
+ setProject("camera", "position", {
+ x: xPosition,
+ y: yPosition,
+ });
}}
class="mt-[0.75rem] rounded-[0.5rem] border border-gray-3 bg-gray-2 w-full h-[7.5rem] relative"
>
@@ -2456,7 +2492,7 @@ function CameraConfig(props: { scrollRef: HTMLDivElement }) {
<Field name="Rounded Corners" icon={<IconCapCorners class="size-4" />}>
<div class="flex flex-col gap-3">
<Slider
- value={[project.camera.rounding!]}
+ value={[project.camera.rounding ?? 0]}
onChange={(v) => setProject("camera", "rounding", v[0])}
minValue={0}
maxValue={100}
@@ -2473,7 +2509,7 @@ function CameraConfig(props: { scrollRef: HTMLDivElement }) {
<Field name="Shadow" icon={<IconCapShadow class="size-4" />}>
<div class="space-y-8">
<Slider
- value={[project.camera.shadow!]}
+ value={[project.camera.shadow ?? 0]}
onChange={(v) => setProject("camera", "shadow", v[0])}
minValue={0}
maxValue={100}
@@ -2772,7 +2808,7 @@ function TextSegmentConfig(props: {
)}
>
<KSelect.Trigger class="flex w-full items-center justify-between rounded-md border border-gray-3 bg-gray-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:border-gray-4 hover:bg-gray-3 focus:border-blue-9 focus:outline-none focus:ring-1 focus:ring-blue-9">
- <KSelect.Value<any> class="truncate">
+ <KSelect.Value<{ label: string; value: number }> class="truncate">
{(state) => {
const selected = state.selectedOption();
if (selected) return selected.label;
@@ -3352,13 +3388,8 @@ function ZoomSegmentConfig(props: {
segment: ZoomSegment;
}) {
const generalSettings = generalSettingsStore.createQuery();
- const {
- project,
- setProject,
- editorInstance,
- setEditorState,
- projectHistory,
- } = useEditorContext();
+ const { project, setProject, editorInstance, projectHistory } =
+ useEditorContext();
const states = {
manual:
@@ -3521,8 +3552,8 @@ function ZoomSegmentConfig(props: {
croppedSize().y,
0,
0,
- canvasRef.width!,
- canvasRef.height!,
+ canvasRef.width,
+ canvasRef.height,
);
};
@@ -3566,7 +3597,7 @@ function ZoomSegmentConfig(props: {
};
const visualHeight = () =>
- (bounds.width! / croppedSize().x) * croppedSize().y;
+ ((bounds.width ?? 0) / croppedSize().x) * croppedSize().y;
return (
<div
@@ -3666,7 +3697,8 @@ function ClipSegmentConfig(props: {
setProject(
produce((proj) => {
- const clips = (proj.clips ??= []);
+ if (!proj.clips) proj.clips = [];
+ const clips = proj.clips;
let clip = clips.find(
(clip) => clip.index === (props.segment.recordingSegment ?? 0),
);
diff --git a/apps/desktop/src/routes/editor/TextOverlay.tsx b/apps/desktop/src/routes/editor/TextOverlay.tsx
index 3e2fa4922..c478e928e 100644
--- a/apps/desktop/src/routes/editor/TextOverlay.tsx
+++ b/apps/desktop/src/routes/editor/TextOverlay.tsx
@@ -314,7 +314,7 @@ function TextSegmentOverlay(props: {
startSize: { ...seg.size },
};
},
- (e, { startPos, startSize }, initialMouse) => {
+ (e, { startPos }, initialMouse) => {
const dx = (e.clientX - initialMouse.x) / props.size.width;
const dy = (e.clientY - initialMouse.y) / props.size.height;
diff --git a/apps/desktop/src/styles/theme.css b/apps/desktop/src/styles/theme.css
index f3cac8f33..65039625c 100644
--- a/apps/desktop/src/styles/theme.css
+++ b/apps/desktop/src/styles/theme.css
@@ -261,8 +261,6 @@
stroke-dasharray: 100;
stroke-dashoffset: 100;
}
- 50% {
- }
100% {
stroke-dashoffset: 0;
}
diff --git a/apps/media-server/src/routes/video.ts b/apps/media-server/src/routes/video.ts
index 91becb856..6bf5f2616 100644
--- a/apps/media-server/src/routes/video.ts
+++ b/apps/media-server/src/routes/video.ts
@@ -1027,7 +1027,7 @@ video.post("/mux-segments", async (c) => {
phase: "error",
error: err instanceof Error ? err.message : String(err),
});
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
}
});
@@ -1147,6 +1147,11 @@ async function downloadSegmentsBatchTracked(
return failed;
}
+function sendCurrentJobWebhook(jobId: string): void {
+ const job = getJob(jobId);
+ if (job) sendWebhook(job);
+}
+
async function muxSegmentsAsync(
jobId: string,
videoId: string,
@@ -1170,7 +1175,7 @@ async function muxSegmentsAsync(
try {
await ensureTempDir();
updateJob(jobId, { phase: "downloading", progress: 0 });
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
await mkdir(workDir, { recursive: true });
const videoDir = join(workDir, "video");
@@ -1180,7 +1185,7 @@ async function muxSegmentsAsync(
await downloadUrlToFile(videoInitUrl, join(videoDir, "init.mp4"));
updateJob(jobId, { phase: "downloading", progress: 5 });
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
const videoFailed = await downloadSegmentsBatchTracked(
videoSegmentUrls,
@@ -1202,36 +1207,38 @@ async function muxSegmentsAsync(
);
}
- let hasAudio =
+ let audioInput =
audioInitUrl !== null &&
audioSegmentUrls !== null &&
- audioSegmentUrls.length > 0;
- if (hasAudio) {
- await downloadUrlToFile(audioInitUrl!, join(audioDir, "init.mp4"));
+ audioSegmentUrls.length > 0
+ ? { initUrl: audioInitUrl, segmentUrls: audioSegmentUrls }
+ : null;
+ if (audioInput) {
+ await downloadUrlToFile(audioInput.initUrl, join(audioDir, "init.mp4"));
const audioFailed = await downloadSegmentsBatchTracked(
- audioSegmentUrls!,
+ audioInput.segmentUrls,
audioDir,
jobId,
50,
10,
);
if (audioFailed > 0) {
- const audioFailRatio = audioFailed / audioSegmentUrls!.length;
+ const audioFailRatio = audioFailed / audioInput.segmentUrls.length;
if (audioFailRatio >= 0.5) {
console.warn(
- `[mux-segments] ${audioFailed}/${audioSegmentUrls!.length} audio segments failed for ${videoId} (${Math.round(audioFailRatio * 100)}%), proceeding without audio`,
+ `[mux-segments] ${audioFailed}/${audioInput.segmentUrls.length} audio segments failed for ${videoId} (${Math.round(audioFailRatio * 100)}%), proceeding without audio`,
);
- hasAudio = false;
+ audioInput = null;
} else {
console.warn(
- `[mux-segments] ${audioFailed}/${audioSegmentUrls!.length} audio segments failed to download for ${videoId}`,
+ `[mux-segments] ${audioFailed}/${audioInput.segmentUrls.length} audio segments failed to download for ${videoId}`,
);
}
}
}
updateJob(jobId, { phase: "processing", progress: 60 });
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
const combinedVideoPath = join(workDir, "combined_video.mp4");
const videoInitPath = join(videoDir, "init.mp4");
@@ -1257,7 +1264,7 @@ async function muxSegmentsAsync(
let resultPath: string;
- if (hasAudio) {
+ if (audioInput) {
const combinedAudioPath = join(workDir, "combined_audio.mp4");
const audioInitPath = join(audioDir, "init.mp4");
const audioSegmentFiles = (await readdir(audioDir))
@@ -1298,7 +1305,7 @@ async function muxSegmentsAsync(
}
updateJob(jobId, { phase: "uploading", progress: 80 });
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
await uploadFileToS3(resultPath, outputPresignedUrl, "video/mp4");
@@ -1319,7 +1326,7 @@ async function muxSegmentsAsync(
progress: 90,
message: "Generating thumbnail...",
});
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
try {
const duration = metadata?.duration ?? 0;
@@ -1338,7 +1345,7 @@ async function muxSegmentsAsync(
progress: 100,
metadata,
});
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
setTimeout(() => deleteJob(jobId), 5 * 60 * 1000);
} catch (error: unknown) {
@@ -1347,7 +1354,7 @@ async function muxSegmentsAsync(
phase: "error",
error: error instanceof Error ? error.message : "Unknown error",
});
- sendWebhook(getJob(jobId)!);
+ sendCurrentJobWebhook(jobId);
} finally {
const { rm } = await import("node:fs/promises");
await rm(workDir, { recursive: true, force: true }).catch(() => {});
diff --git a/apps/web-cluster/src/cluster/container-metadata.ts b/apps/web-cluster/src/cluster/container-metadata.ts
index 7b79f95bd..11622861b 100644
--- a/apps/web-cluster/src/cluster/container-metadata.ts
+++ b/apps/web-cluster/src/cluster/container-metadata.ts
@@ -1,6 +1,8 @@
import { Config, Data, Effect, Option } from "effect";
-export class FetchIpError extends Data.TaggedError("FetchIpError")<{}> {}
+export class FetchIpError extends Data.TaggedError("FetchIpError")<
+ Record<never, never>
+> {}
class EcsContainerMetadata extends Effect.Service<EcsContainerMetadata>()(
"EcsContainerMetadata",
diff --git a/apps/web/__tests__/unit/async-video-code-reviews-page.test.ts b/apps/web/__tests__/unit/async-video-code-reviews-page.test.ts
index 33eb89ead..7c15b83d6 100644
--- a/apps/web/__tests__/unit/async-video-code-reviews-page.test.ts
+++ b/apps/web/__tests__/unit/async-video-code-reviews-page.test.ts
@@ -146,7 +146,7 @@ describe("AsyncVideoCodeReviewsPage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "What is an async video code review?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/avi-to-mp4-page.test.ts b/apps/web/__tests__/unit/avi-to-mp4-page.test.ts
index 9add737c2..b47dc75b0 100644
--- a/apps/web/__tests__/unit/avi-to-mp4-page.test.ts
+++ b/apps/web/__tests__/unit/avi-to-mp4-page.test.ts
@@ -114,7 +114,7 @@ describe("AVI to MP4 FAQ schema validity", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "How do I convert AVI to MP4 online?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/best-screen-recorder-page.test.ts b/apps/web/__tests__/unit/best-screen-recorder-page.test.ts
index 9a9057ecc..b5b71f2dd 100644
--- a/apps/web/__tests__/unit/best-screen-recorder-page.test.ts
+++ b/apps/web/__tests__/unit/best-screen-recorder-page.test.ts
@@ -138,7 +138,7 @@ describe("BestScreenRecorderPage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "What is the best screen recorder?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/breadcrumb-schema.test.ts b/apps/web/__tests__/unit/breadcrumb-schema.test.ts
index e37ccc1f3..609dd4d08 100644
--- a/apps/web/__tests__/unit/breadcrumb-schema.test.ts
+++ b/apps/web/__tests__/unit/breadcrumb-schema.test.ts
@@ -44,9 +44,11 @@ describe("createBreadcrumbSchema", () => {
{ name: "Home", url: "https://cap.so" },
{ name: "Current Page" },
]);
+ const currentPageItem = schema.itemListElement[1];
expect(schema.itemListElement[0]?.item).toBe("https://cap.so");
- expect("item" in schema.itemListElement[1]!).toBe(false);
+ expect(currentPageItem).toBeDefined();
+ expect(currentPageItem && "item" in currentPageItem).toBe(false);
});
it("handles single item breadcrumb", () => {
@@ -165,7 +167,7 @@ describe("Breadcrumb structured data in tools pages", () => {
const content = readPage("(site)/tools/convert/[conversionPath]/page.tsx");
expect(content).toContain("createBreadcrumbSchema");
expect(content).toContain(
- "`https://cap.so/tools/convert/${conversionPath}`",
+ "`https://cap.so/tools/convert/$" + "{conversionPath}`",
);
});
});
diff --git a/apps/web/__tests__/unit/developer-credit-math.test.ts b/apps/web/__tests__/unit/developer-credit-math.test.ts
index 06188dba5..4bcaefc1e 100644
--- a/apps/web/__tests__/unit/developer-credit-math.test.ts
+++ b/apps/web/__tests__/unit/developer-credit-math.test.ts
@@ -25,6 +25,10 @@ function balanceAfterCharge(balance: number, charge: number): number {
return Math.max(0, balance - charge);
}
+function isBelowMinimumPurchase(amountCents: number): boolean {
+ return amountCents < 500;
+}
+
describe("Purchase Credits Conversion", () => {
it("converts $5.00 (500 cents) to 500,000 micro-credits", () => {
expect(purchaseCreditsFormula(500)).toBe(500_000);
@@ -52,9 +56,9 @@ describe("Purchase Credits Conversion", () => {
});
it("rejects purchases below $5.00 minimum (amountCents < 500)", () => {
- expect(499 < 500).toBe(true);
- expect(500 < 500).toBe(false);
- expect(0 < 500).toBe(true);
+ expect(isBelowMinimumPurchase(499)).toBe(true);
+ expect(isBelowMinimumPurchase(500)).toBe(false);
+ expect(isBelowMinimumPurchase(0)).toBe(true);
});
});
diff --git a/apps/web/__tests__/unit/developer-cron-storage.test.ts b/apps/web/__tests__/unit/developer-cron-storage.test.ts
index 05348226a..71449c265 100644
--- a/apps/web/__tests__/unit/developer-cron-storage.test.ts
+++ b/apps/web/__tests__/unit/developer-cron-storage.test.ts
@@ -2,6 +2,25 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
const mockDb = vi.fn();
+type DbRow = Record<string, unknown>;
+type JsonBody = Record<string, unknown>;
+type TransactionValues = {
+ type?: string;
+ amountMicroCredits?: number;
+};
+type MockDbChain = {
+ select: ReturnType<typeof vi.fn>;
+ from: ReturnType<typeof vi.fn>;
+ where: ReturnType<typeof vi.fn>;
+ groupBy?: ReturnType<typeof vi.fn>;
+ limit: ReturnType<typeof vi.fn>;
+ insert: ReturnType<typeof vi.fn>;
+ values: ReturnType<typeof vi.fn>;
+ update: ReturnType<typeof vi.fn>;
+ set: ReturnType<typeof vi.fn>;
+ transaction?: ReturnType<typeof vi.fn>;
+};
+
vi.mock("@cap/database", () => ({
db: mockDb,
}));
@@ -32,19 +51,19 @@ vi.mock("@cap/database/schema", () => ({
}));
vi.mock("drizzle-orm", () => ({
- and: vi.fn((...args: any[]) => args),
- eq: vi.fn((a: any, b: any) => ({ eq: [a, b] })),
- inArray: vi.fn((a: any, b: any) => ({ inArray: [a, b] })),
- isNull: vi.fn((a: any) => ({ isNull: a })),
+ and: vi.fn((...args: unknown[]) => args),
+ eq: vi.fn((a: unknown, b: unknown) => ({ eq: [a, b] })),
+ inArray: vi.fn((a: unknown, b: unknown) => ({ inArray: [a, b] })),
+ isNull: vi.fn((a: unknown) => ({ isNull: a })),
sql: vi.fn(),
}));
-let capturedJsonBody: any = null;
+let capturedJsonBody: JsonBody | null = null;
let capturedStatus: number | undefined;
vi.mock("next/server", () => ({
NextResponse: {
- json: vi.fn((body: any, init?: any) => {
+ json: vi.fn((body: JsonBody, init?: ResponseInit) => {
capturedJsonBody = body;
capturedStatus = init?.status;
return { body, status: init?.status ?? 200 };
@@ -55,10 +74,11 @@ vi.mock("next/server", () => ({
const CRON_SECRET = "test-cron-secret";
function makeChain(
- result: any[],
- options?: { onTransaction?: (tx: any) => void },
+ result: DbRow[],
+ options?: { onTransaction?: (tx: MockDbChain) => void },
) {
- const chain: any = {
+ const chain = Promise.resolve(result) as Promise<DbRow[]> & MockDbChain;
+ Object.assign(chain, {
select: vi.fn(() => chain),
from: vi.fn(() => chain),
where: vi.fn(() => chain),
@@ -68,9 +88,9 @@ function makeChain(
values: vi.fn(() => Promise.resolve()),
update: vi.fn(() => chain),
set: vi.fn(() => chain),
- transaction: vi.fn(async (cb: any) => {
+ transaction: vi.fn(async (cb: (tx: MockDbChain) => Promise<unknown>) => {
let currentOperation: "select" | "update" | "insert" | null = null;
- const txChain: any = {
+ const txChain = {
select: vi.fn(() => {
currentOperation = "select";
return txChain;
@@ -99,23 +119,26 @@ function makeChain(
}
await cb(txChain);
}),
- };
- chain.then = (resolve: any) => resolve(result);
+ });
return chain;
}
function setupDbSequence(
- responses: any[][],
- txOptions?: { onTransaction?: (tx: any) => void },
+ responses: DbRow[][],
+ txOptions?: { onTransaction?: (tx: MockDbChain) => void },
) {
let callIndex = 0;
mockDb.mockImplementation(() => {
const idx = callIndex++;
- const result = idx < responses.length ? responses[idx]! : [];
+ const result = responses[idx] ?? [];
return makeChain(result, txOptions);
});
}
+function isTransactionValues(value: unknown): value is TransactionValues {
+ return typeof value === "object" && value !== null;
+}
+
beforeEach(() => {
vi.clearAllMocks();
capturedJsonBody = null;
@@ -234,7 +257,7 @@ describe("developer-storage cron job", () => {
describe("transaction behavior", () => {
it("creates negative transaction for storage_daily", async () => {
const GET = await importGET();
- let insertValues: any = null;
+ let insertValues: TransactionValues | null = null;
setupDbSequence(
[
@@ -246,8 +269,8 @@ describe("developer-storage cron job", () => {
],
{
onTransaction: (tx) => {
- tx.values.mockImplementation((vals: any) => {
- if (vals?.type === "storage_daily") {
+ tx.values.mockImplementation((vals: unknown) => {
+ if (isTransactionValues(vals) && vals.type === "storage_daily") {
insertValues = vals;
}
return Promise.resolve();
@@ -277,8 +300,8 @@ describe("developer-storage cron job", () => {
],
{
onTransaction: (tx) => {
- tx.values.mockImplementation((vals: any) => {
- if (vals?.type === "storage_daily") {
+ tx.values.mockImplementation((vals: unknown) => {
+ if (isTransactionValues(vals) && vals.type === "storage_daily") {
capturedAmount = vals.amountMicroCredits;
}
return Promise.resolve();
diff --git a/apps/web/__tests__/unit/developer-documentation-videos-page.test.ts b/apps/web/__tests__/unit/developer-documentation-videos-page.test.ts
index 772d5da75..17388c072 100644
--- a/apps/web/__tests__/unit/developer-documentation-videos-page.test.ts
+++ b/apps/web/__tests__/unit/developer-documentation-videos-page.test.ts
@@ -155,7 +155,7 @@ describe("DeveloperDocumentationVideosPage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "What is a developer documentation video?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/hipaa-compliant-screen-recording-page.test.ts b/apps/web/__tests__/unit/hipaa-compliant-screen-recording-page.test.ts
index c82a51f93..0296b994b 100644
--- a/apps/web/__tests__/unit/hipaa-compliant-screen-recording-page.test.ts
+++ b/apps/web/__tests__/unit/hipaa-compliant-screen-recording-page.test.ts
@@ -146,7 +146,7 @@ describe("HipaaCompliantScreenRecordingPage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "Can Cap be used for HIPAA-compliant screen recording?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/mac-screen-recording-with-audio-page.test.ts b/apps/web/__tests__/unit/mac-screen-recording-with-audio-page.test.ts
index 6a4075c77..83ade7f90 100644
--- a/apps/web/__tests__/unit/mac-screen-recording-with-audio-page.test.ts
+++ b/apps/web/__tests__/unit/mac-screen-recording-with-audio-page.test.ts
@@ -171,7 +171,7 @@ describe("MacScreenRecordingWithAudioPage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "Why doesn't macOS record internal audio by default?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/mov-to-mp4-page.test.ts b/apps/web/__tests__/unit/mov-to-mp4-page.test.ts
index 7be75ecd0..5b03243ab 100644
--- a/apps/web/__tests__/unit/mov-to-mp4-page.test.ts
+++ b/apps/web/__tests__/unit/mov-to-mp4-page.test.ts
@@ -109,7 +109,7 @@ describe("MOV to MP4 FAQ schema validity", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "How do I convert MOV to MP4 online?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/mp4-to-gif-page.test.ts b/apps/web/__tests__/unit/mp4-to-gif-page.test.ts
index a27066f31..1d87c3db1 100644
--- a/apps/web/__tests__/unit/mp4-to-gif-page.test.ts
+++ b/apps/web/__tests__/unit/mp4-to-gif-page.test.ts
@@ -109,7 +109,7 @@ describe("MP4 to GIF FAQ schema validity", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "How do I convert MP4 to GIF?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/obs-alternative-page.test.ts b/apps/web/__tests__/unit/obs-alternative-page.test.ts
index cee286d2c..9dfac6f30 100644
--- a/apps/web/__tests__/unit/obs-alternative-page.test.ts
+++ b/apps/web/__tests__/unit/obs-alternative-page.test.ts
@@ -148,7 +148,7 @@ describe("ObsAlternativePage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "Why would I use Cap instead of OBS Studio?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/open-source-screen-recorder-page.test.ts b/apps/web/__tests__/unit/open-source-screen-recorder-page.test.ts
index a1dde8388..00fab1333 100644
--- a/apps/web/__tests__/unit/open-source-screen-recorder-page.test.ts
+++ b/apps/web/__tests__/unit/open-source-screen-recorder-page.test.ts
@@ -144,7 +144,7 @@ describe("OpenSourceScreenRecorderPage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "Is Cap really open source?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/self-hosted-screen-recording-page.test.ts b/apps/web/__tests__/unit/self-hosted-screen-recording-page.test.ts
index e9db417fe..451334bb6 100644
--- a/apps/web/__tests__/unit/self-hosted-screen-recording-page.test.ts
+++ b/apps/web/__tests__/unit/self-hosted-screen-recording-page.test.ts
@@ -147,7 +147,7 @@ describe("SelfHostedScreenRecordingPage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "Can Cap be self-hosted?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/video-frame-thumbnail.test.ts b/apps/web/__tests__/unit/video-frame-thumbnail.test.ts
index 5925ac2db..9b0ff6b0c 100644
--- a/apps/web/__tests__/unit/video-frame-thumbnail.test.ts
+++ b/apps/web/__tests__/unit/video-frame-thumbnail.test.ts
@@ -1,8 +1,5 @@
import { describe, expect, it, vi } from "vitest";
-import {
- type CaptureVideoFrameDeps,
- captureVideoFrameDataUrl,
-} from "@/app/s/[videoId]/_components/video-frame-thumbnail";
+import { captureVideoFrameDataUrl } from "@/app/s/[videoId]/_components/video-frame-thumbnail";
function createMockCanvas(options?: {
contextReturnsNull?: boolean;
diff --git a/apps/web/__tests__/unit/video-recording-software-page.test.ts b/apps/web/__tests__/unit/video-recording-software-page.test.ts
index 697c8b318..b5a7d9fa4 100644
--- a/apps/web/__tests__/unit/video-recording-software-page.test.ts
+++ b/apps/web/__tests__/unit/video-recording-software-page.test.ts
@@ -143,7 +143,7 @@ describe("VideoRecordingSoftwarePage FAQ schema", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "What is video recording software?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/video-speed-controller-page.test.ts b/apps/web/__tests__/unit/video-speed-controller-page.test.ts
index d2765577b..68ddafb0e 100644
--- a/apps/web/__tests__/unit/video-speed-controller-page.test.ts
+++ b/apps/web/__tests__/unit/video-speed-controller-page.test.ts
@@ -109,7 +109,7 @@ describe("Video Speed Controller FAQ schema validity", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "How do I change the speed of a video online?",
acceptedAnswer: {
diff --git a/apps/web/__tests__/unit/webm-to-mp4-page.test.ts b/apps/web/__tests__/unit/webm-to-mp4-page.test.ts
index 8f30523dd..184aa5ed1 100644
--- a/apps/web/__tests__/unit/webm-to-mp4-page.test.ts
+++ b/apps/web/__tests__/unit/webm-to-mp4-page.test.ts
@@ -114,7 +114,7 @@ describe("WebM to MP4 FAQ schema validity", () => {
it("maps each FAQ to a Question entity with acceptedAnswer", () => {
const schema = createFAQSchema(faqs);
- expect(schema.mainEntity[0]!).toEqual({
+ expect(schema.mainEntity[0]).toEqual({
"@type": "Question",
name: "How do I convert WebM to MP4 online?",
acceptedAnswer: {
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/SpaceDialog.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/SpaceDialog.tsx
index b8bb2ae1b..a9b83e8ac 100644
--- a/apps/web/app/(org)/dashboard/_components/Navbar/SpaceDialog.tsx
+++ b/apps/web/app/(org)/dashboard/_components/Navbar/SpaceDialog.tsx
@@ -223,14 +223,19 @@ export const NewSpaceForm: React.FC<NewSpaceFormProps> = (props) => {
form.reset();
setSelectedFile(null);
props.onSpaceCreated();
- } catch (error: any) {
+ } catch (error) {
console.error(
edit ? "Error updating space:" : "Error creating space:",
error,
);
+ const message =
+ error instanceof Error
+ ? error.message
+ : edit
+ ? "Failed to update space"
+ : "Failed to create space";
toast.error(
- error?.message ||
- error?.error ||
+ message ||
(edit ? "Failed to update space" : "Failed to create space"),
);
} finally {
diff --git a/apps/web/app/(site)/(seo)/async-video-code-reviews/page.tsx b/apps/web/app/(site)/(seo)/async-video-code-reviews/page.tsx
index d13a9d2d9..c937dbcdc 100644
--- a/apps/web/app/(site)/(seo)/async-video-code-reviews/page.tsx
+++ b/apps/web/app/(site)/(seo)/async-video-code-reviews/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
AsyncVideoCodeReviewsPage,
asyncVideoCodeReviewsContent,
@@ -42,15 +41,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(asyncVideoCodeReviewsContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(asyncVideoCodeReviewsContent.faqs))}
+ </script>
<AsyncVideoCodeReviewsPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/best-screen-recorder/page.tsx b/apps/web/app/(site)/(seo)/best-screen-recorder/page.tsx
index 15d725dad..060585218 100644
--- a/apps/web/app/(site)/(seo)/best-screen-recorder/page.tsx
+++ b/apps/web/app/(site)/(seo)/best-screen-recorder/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
BestScreenRecorderPage,
bestScreenRecorderContent,
@@ -44,15 +43,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(bestScreenRecorderContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(bestScreenRecorderContent.faqs))}
+ </script>
<BestScreenRecorderPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/developer-documentation-videos/page.tsx b/apps/web/app/(site)/(seo)/developer-documentation-videos/page.tsx
index eccc0cdc2..a2a66bcc7 100644
--- a/apps/web/app/(site)/(seo)/developer-documentation-videos/page.tsx
+++ b/apps/web/app/(site)/(seo)/developer-documentation-videos/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
DeveloperDocumentationVideosPage,
developerDocumentationVideosContent,
@@ -45,15 +44,11 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(developerDocumentationVideosContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(
+ createFAQSchema(developerDocumentationVideosContent.faqs),
+ )}
+ </script>
<DeveloperDocumentationVideosPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/free-screen-recorder/page.tsx b/apps/web/app/(site)/(seo)/free-screen-recorder/page.tsx
index 594120f37..c5520a872 100644
--- a/apps/web/app/(site)/(seo)/free-screen-recorder/page.tsx
+++ b/apps/web/app/(site)/(seo)/free-screen-recorder/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
FreeScreenRecorderPage,
freeScreenRecorderContent,
@@ -42,15 +41,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(freeScreenRecorderContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(freeScreenRecorderContent.faqs))}
+ </script>
<FreeScreenRecorderPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/hipaa-compliant-screen-recording/page.tsx b/apps/web/app/(site)/(seo)/hipaa-compliant-screen-recording/page.tsx
index 0cd3368b9..c19b81c16 100644
--- a/apps/web/app/(site)/(seo)/hipaa-compliant-screen-recording/page.tsx
+++ b/apps/web/app/(site)/(seo)/hipaa-compliant-screen-recording/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
HipaaCompliantScreenRecordingPage,
hipaaCompliantScreenRecordingContent,
@@ -45,15 +44,11 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(hipaaCompliantScreenRecordingContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(
+ createFAQSchema(hipaaCompliantScreenRecordingContent.faqs),
+ )}
+ </script>
<HipaaCompliantScreenRecordingPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx b/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx
index 49a095f34..4a65baad3 100644
--- a/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx
+++ b/apps/web/app/(site)/(seo)/how-to-screen-record/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
HowToScreenRecordPage,
howToScreenRecordContent,
@@ -61,30 +60,20 @@ const howToSteps = [
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(howToScreenRecordContent.faqs),
- ),
- }}
- />
- <Script
- id="howto-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createHowToSchema({
- name: "How to Screen Record on Mac, Windows & Chrome",
- description:
- "Learn how to screen record with audio on Mac, Windows, or in your browser using Cap, the free open-source screen recorder.",
- totalTime: "PT2M",
- steps: howToSteps,
- }),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(howToScreenRecordContent.faqs))}
+ </script>
+ <script type="application/ld+json">
+ {JSON.stringify(
+ createHowToSchema({
+ name: "How to Screen Record on Mac, Windows & Chrome",
+ description:
+ "Learn how to screen record with audio on Mac, Windows, or in your browser using Cap, the free open-source screen recorder.",
+ totalTime: "PT2M",
+ steps: howToSteps,
+ }),
+ )}
+ </script>
<HowToScreenRecordPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/mac-screen-recording-with-audio/page.tsx b/apps/web/app/(site)/(seo)/mac-screen-recording-with-audio/page.tsx
index f88231660..bd566d145 100644
--- a/apps/web/app/(site)/(seo)/mac-screen-recording-with-audio/page.tsx
+++ b/apps/web/app/(site)/(seo)/mac-screen-recording-with-audio/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
MacScreenRecordingWithAudioPage,
macScreenRecordingWithAudioContent,
@@ -42,15 +41,11 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(macScreenRecordingWithAudioContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(
+ createFAQSchema(macScreenRecordingWithAudioContent.faqs),
+ )}
+ </script>
<MacScreenRecordingWithAudioPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/obs-alternative/page.tsx b/apps/web/app/(site)/(seo)/obs-alternative/page.tsx
index c2cc8608c..8469e069a 100644
--- a/apps/web/app/(site)/(seo)/obs-alternative/page.tsx
+++ b/apps/web/app/(site)/(seo)/obs-alternative/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
ObsAlternativePage,
obsAlternativeContent,
@@ -44,13 +43,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(createFAQSchema(obsAlternativeContent.faqs)),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(obsAlternativeContent.faqs))}
+ </script>
<ObsAlternativePage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx b/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx
index cd667f7bd..607dbc2b5 100644
--- a/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx
+++ b/apps/web/app/(site)/(seo)/open-source-screen-recorder/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
OpenSourceScreenRecorderPage,
openSourceScreenRecorderContent,
@@ -42,15 +41,11 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(openSourceScreenRecorderContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(
+ createFAQSchema(openSourceScreenRecorderContent.faqs),
+ )}
+ </script>
<OpenSourceScreenRecorderPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/record-screen/page.tsx b/apps/web/app/(site)/(seo)/record-screen/page.tsx
index 1fc7ee9d4..bab88de8f 100644
--- a/apps/web/app/(site)/(seo)/record-screen/page.tsx
+++ b/apps/web/app/(site)/(seo)/record-screen/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
RecordScreenPage,
recordScreenContent,
@@ -42,13 +41,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(createFAQSchema(recordScreenContent.faqs)),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(recordScreenContent.faqs))}
+ </script>
<RecordScreenPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/screen-recorder/page.tsx b/apps/web/app/(site)/(seo)/screen-recorder/page.tsx
index cb3f85b41..18afadadc 100644
--- a/apps/web/app/(site)/(seo)/screen-recorder/page.tsx
+++ b/apps/web/app/(site)/(seo)/screen-recorder/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
ScreenRecorderPage,
screenRecorderContent,
@@ -44,13 +43,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(createFAQSchema(screenRecorderContent.faqs)),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(screenRecorderContent.faqs))}
+ </script>
<ScreenRecorderPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/screen-recording/page.tsx b/apps/web/app/(site)/(seo)/screen-recording/page.tsx
index 8eb83e961..e6099f9f9 100644
--- a/apps/web/app/(site)/(seo)/screen-recording/page.tsx
+++ b/apps/web/app/(site)/(seo)/screen-recording/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
ScreenRecordingPage,
screenRecordingContent,
@@ -42,13 +41,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(createFAQSchema(screenRecordingContent.faqs)),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(screenRecordingContent.faqs))}
+ </script>
<ScreenRecordingPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx b/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx
index 4a0645bfb..cbc6cf621 100644
--- a/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx
+++ b/apps/web/app/(site)/(seo)/self-hosted-screen-recording/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
SelfHostedScreenRecordingPage,
selfHostedScreenRecordingContent,
@@ -45,15 +44,11 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(selfHostedScreenRecordingContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(
+ createFAQSchema(selfHostedScreenRecordingContent.faqs),
+ )}
+ </script>
<SelfHostedScreenRecordingPage />
</>
);
diff --git a/apps/web/app/(site)/(seo)/video-recording-software/page.tsx b/apps/web/app/(site)/(seo)/video-recording-software/page.tsx
index ae6c6cedc..3d816a679 100644
--- a/apps/web/app/(site)/(seo)/video-recording-software/page.tsx
+++ b/apps/web/app/(site)/(seo)/video-recording-software/page.tsx
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
-import Script from "next/script";
import {
VideoRecordingSoftwarePage,
videoRecordingSoftwareContent,
@@ -42,15 +41,9 @@ export const metadata: Metadata = {
export default function Page() {
return (
<>
- <Script
- id="faq-structured-data"
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(
- createFAQSchema(videoRecordingSoftwareContent.faqs),
- ),
- }}
- />
+ <script type="application/ld+json">
+ {JSON.stringify(createFAQSchema(videoRecordingSoftwareContent.faqs))}
+ </script>
<VideoRecordingSoftwarePage />
</>
);
diff --git a/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx b/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx
index 4988b9d23..7d0ca9d58 100644
--- a/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx
+++ b/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx
@@ -481,7 +481,7 @@ export function CapVideoPlayer({
const generateVideoFrameThumbnail = useCallback(
(_time: number): string | undefined =>
captureVideoFrameDataUrl({ video: videoRef.current }),
- [],
+ [videoRef.current],
);
const isUploadFailed = uploadProgress?.status === "failed";
diff --git a/biome.json b/biome.json
index 4b6e2f87f..e37af6e12 100644
--- a/biome.json
+++ b/biome.json
@@ -8,6 +8,8 @@
"files": {
"includes": [
"**",
+ "!**/tauri.ts",
+ "!**/queries.ts",
"!apps/desktop/src/utils/tauri.ts",
"!apps/desktop/src/global.d.ts",
"!apps/web/public/gif.worker.js",
diff --git a/crates/export/tests/export_benchmark.rs b/crates/export/tests/export_benchmark.rs
index ecdc8227e..984b486ef 100644
--- a/crates/export/tests/export_benchmark.rs
+++ b/crates/export/tests/export_benchmark.rs
@@ -137,7 +137,7 @@ pub fn list_recordings() -> Vec<PathBuf> {
})
.collect();
- recordings.sort_by(|a, b| b.0.cmp(&a.0));
+ recordings.sort_by_key(|entry| std::cmp::Reverse(entry.0));
recordings.into_iter().map(|(_, path)| path).collect()
}
diff --git a/packages/database/crypto.ts b/packages/database/crypto.ts
index ab54c4a50..d5db0c510 100644
--- a/packages/database/crypto.ts
+++ b/packages/database/crypto.ts
@@ -81,9 +81,9 @@ export async function encrypt(text: string): Promise<string> {
);
const result = Buffer.concat([
- Buffer.from(salt as any) as any,
- Buffer.from(iv as any) as any,
- Buffer.from(encrypted as any) as any,
+ Buffer.from(salt),
+ Buffer.from(iv),
+ Buffer.from(encrypted),
]);
return result.toString("base64");
@@ -107,7 +107,7 @@ export async function decrypt(encryptedText: string): Promise<string> {
const iv = encrypted.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
const content = encrypted.subarray(SALT_LENGTH + IV_LENGTH);
- const key = await deriveKey(salt as Uint8Array);
+ const key = await deriveKey(salt);
const decrypted = await crypto.subtle.decrypt(
{
@@ -156,10 +156,7 @@ export async function hashPassword(password: string): Promise<string> {
PASSWORD_KEY_LENGTH * 8,
);
- const result = Buffer.concat([
- Buffer.from(salt as any) as any,
- Buffer.from(derived as any) as any,
- ]);
+ const result = Buffer.concat([Buffer.from(salt), Buffer.from(derived)]);
return result.toString("base64");
}
diff --git a/packages/database/emails/config.ts b/packages/database/emails/config.ts
index 0f27b402b..20ad371ef 100644
--- a/packages/database/emails/config.ts
+++ b/packages/database/emails/config.ts
@@ -18,7 +18,7 @@ export const sendEmail = async ({
}: {
email: string;
subject: string;
- react: ReactElement<any, string | JSXElementConstructor<any>>;
+ react: ReactElement<unknown, string | JSXElementConstructor<unknown>>;
marketing?: boolean;
test?: boolean;
scheduledAt?: string;
@@ -32,7 +32,7 @@ export const sendEmail = async ({
}
if (marketing && !buildEnv.NEXT_PUBLIC_IS_CAP) return;
- let from;
+ let from: string;
if (fromOverride) from = fromOverride;
else if (marketing) from = "Richie from Cap <[email protected]>";
@@ -48,5 +48,5 @@ export const sendEmail = async ({
scheduledAt,
cc: test ? undefined : cc,
replyTo: replyTo,
- }) as any;
+ });
};
diff --git a/packages/env/build.ts b/packages/env/build.ts
index a46bfb278..f52ddc6b3 100644
--- a/packages/env/build.ts
+++ b/packages/env/build.ts
@@ -34,6 +34,6 @@ export const buildEnv = new Proxy({} as typeof _env, {
get(_, key) {
if (!_env) _env = create();
- return (_env as any)[key];
+ return _env[key as keyof typeof _env];
},
});
diff --git a/packages/web-backend/src/Auth.ts b/packages/web-backend/src/Auth.ts
index ae3a26442..f03f09fd7 100644
--- a/packages/web-backend/src/Auth.ts
+++ b/packages/web-backend/src/Auth.ts
@@ -23,7 +23,7 @@ export const getCurrentUser = Effect.gen(function* () {
db
.select()
.from(Db.users)
- .where(Dz.eq(Db.users.id, (session.user as any).id)),
+ .where(Dz.eq(Db.users.id, (session.user as { id: string }).id)),
);
return Option.fromNullable(currentUser);
@@ -60,7 +60,7 @@ export const HttpAuthMiddlewareLive = Layer.effect(
);
const authHeader = headers.authorization?.split(" ")[1];
- let user;
+ let user: Option.Option<typeof Db.users.$inferSelect>;
if (authHeader?.length === 36) {
user = yield* database
diff --git a/packages/web-domain/src/Policy.ts b/packages/web-domain/src/Policy.ts
index cd965ee13..d6cbe3e51 100644
--- a/packages/web-domain/src/Policy.ts
+++ b/packages/web-domain/src/Policy.ts
@@ -58,7 +58,9 @@ export const publicPolicy = <E, R>(
);
}) as PublicPolicy<E, R>;
-export class DenyAccess extends Data.TaggedError("DenyAccess")<{}> {}
+export class DenyAccess extends Data.TaggedError("DenyAccess")<
+ Record<never, never>
+> {}
/**
* Applies a policy as a pre-check to an effect.