Skip to content

Open source CapCut alternative.

TypeScript

style(site): brace one-line ifs

David Lea6fe60c01cd5
diff --git a/site/scripts/eval-chatgpt-workflow.ts b/site/scripts/eval-chatgpt-workflow.ts
index 3ee2ed4a..6705a828 100644
--- a/site/scripts/eval-chatgpt-workflow.ts
+++ b/site/scripts/eval-chatgpt-workflow.ts
@@ -171,7 +171,9 @@ try {
await edit("trim_clip", { clipId, in: 0, out: Math.min(3, asset.duration) });
await edit("add_title", { text: "MADE IN CHATGPT", start: 0, end: 2 });
const frame = await settle(await call("capture_frame", { projectId, t: 0.5 }), "get_job_status", "capture");
- if (frame.images < 1) fail("capture_frame returned no image block");
+ if (frame.images < 1) {
+ fail("capture_frame returned no image block");
+ }
const titled = await doc(projectId);
if (!(titled.overlays ?? []).some((o) => o.text === "MADE IN CHATGPT")) fail("the title did not save");
if (!(titled.clips![0].out - titled.clips![0].in <= 3.001)) fail("the trim did not save");
diff --git a/site/src/clients/chatgpt/plugin.test.ts b/site/src/clients/chatgpt/plugin.test.ts
index 94f87763..712a88c6 100644
--- a/site/src/clients/chatgpt/plugin.test.ts
+++ b/site/src/clients/chatgpt/plugin.test.ts
@@ -45,7 +45,9 @@ test("every path the manifest names ships in the package, and no secret does", (
expect(paths.has(ref)).toBe(true);
}
for (const file of files) {
- if ("from" in file) expect(existsSync(path.resolve(process.cwd(), file.from))).toBe(true);
+ if ("from" in file) {
+ expect(existsSync(path.resolve(process.cwd(), file.from))).toBe(true);
+ }
}
const text = files.map((f) => ("text" in f ? f.text : "")).join("\n");
expect(text).not.toMatch(/clientSecret|test_credentials|reviewer_instructions|\.app\.json/);
@@ -56,7 +58,9 @@ test("each skill has the frontmatter ChatGPT reads to pick it", () => {
const skills = files.filter((f) => f.path.startsWith("skills/"));
expect(skills.length).toBeGreaterThan(10);
for (const skill of skills) {
- if (!("text" in skill)) throw new Error(skill.path);
+ if (!("text" in skill)) {
+ throw new Error(skill.path);
+ }
const name = skill.path.split("/")[1];
expect(skill.text.startsWith(`---\nname: ${name}\ndescription: "`)).toBe(true);
const description = JSON.parse(skill.text.split("\n")[2].slice("description: ".length));
diff --git a/site/src/clients/chatgpt/server/embed.ts b/site/src/clients/chatgpt/server/embed.ts
index 40ffcd0b..faf7d4ac 100644
--- a/site/src/clients/chatgpt/server/embed.ts
+++ b/site/src/clients/chatgpt/server/embed.ts
@@ -64,7 +64,9 @@ async function redeem(request: Request, refuse: Refuse) {
const params = new URL(request.url).searchParams;
const project = params.get("project");
- if (project !== null && !/^[A-Za-z0-9_-]{1,128}$/.test(project)) return refuse("badRequest", 400);
+ if (project !== null && !/^[A-Za-z0-9_-]{1,128}$/.test(project)) {
+ return refuse("badRequest", 400);
+ }
const redeemed = await redeemEditorCode(params.get("code") ?? "", config);
if (!redeemed) return refuse("expired", 403);
try {
diff --git a/site/src/clients/chatgpt/server/projects.ts b/site/src/clients/chatgpt/server/projects.ts
index dda8c4ca..337b1f0e 100644
--- a/site/src/clients/chatgpt/server/projects.ts
+++ b/site/src/clients/chatgpt/server/projects.ts
@@ -433,7 +433,9 @@ export function projectTools(
async withEditor(result: ProjectResult): Promise<ProjectResult> {
const projectId = result.view.project?.id;
const home = result.view.view === "projects";
- if (!canEdit || (!projectId && !home) || result.editor) return result;
+ if (!canEdit || (!projectId && !home) || result.editor) {
+ return result;
+ }
const code = await createEditorCode(identity.grantId, db);
const target = projectId ? `&project=${encodeURIComponent(projectId)}` : "";
const url = `${config.issuer}/api/chatgpt/embed?code=${code}${target}`;
diff --git a/site/src/clients/chatgpt/ui/useProjectApp.ts b/site/src/clients/chatgpt/ui/useProjectApp.ts
index 34dd6557..d6322be7 100644
--- a/site/src/clients/chatgpt/ui/useProjectApp.ts
+++ b/site/src/clients/chatgpt/ui/useProjectApp.ts
@@ -76,13 +76,17 @@ export function useProjectApp() {
const editable = parsed.data.canEdit ? parsed.data.project?.id ?? home : null;
const embed = editorSchema.safeParse(result._meta?.editor);
const link = embed.success && (origin !== "card" || embed.data.expiresAt > Date.now()) ? embed.data : null;
- if (origin === "call" && editable !== null && !link) throw new CardError("editorFailed");
+ if (origin === "call" && editable !== null && !link) {
+ throw new CardError("editorFailed");
+ }
const media = playbackSchema.safeParse(result._meta?.playback);
const interval = result._meta?.pollMs;
if (typeof interval === "number" && interval >= 1000 && interval <= 30000) setPollMs(interval);
setView(parsed.data);
setPlayback(media.success ? media.data : null);
- if (editable !== null && link) setEditor((current) => current ?? link);
+ if (editable !== null && link) {
+ setEditor((current) => current ?? link);
+ }
setEditorRequest(editable !== null && !link ? editable : null);
setError(null);
}, []);
@@ -173,7 +177,9 @@ export function useProjectApp() {
const framePage = useCallback((url: string, next: FramePage) => { setPage({ url, ...next }); }, []);
useEffect(() => {
const app = appRef.current;
- if (!app || !ready || !view || !app.getHostCapabilities()?.updateModelContext) return;
+ if (!app || !ready || !view || !app.getHostCapabilities()?.updateModelContext) {
+ return;
+ }
// The projects home clears what the card said, so the composer carries no
// chip until a project opens.
if (!shownId) {
@@ -217,7 +223,9 @@ export function useProjectApp() {
}, []);
useEffect(() => {
- if (!ready || editorRequest === null || editor || requested.current === editorRequest) return;
+ if (!ready || editorRequest === null || editor || requested.current === editorRequest) {
+ return;
+ }
requested.current = editorRequest;
void run("open_project", openArgs(editorRequest), false);
}, [ready, editorRequest, editor, run]);
@@ -225,7 +233,9 @@ export function useProjectApp() {
* on the page the frame was showing. */
const retryEditor = () => {
const target = reported ? reported.projectId ?? HOME : projectId ?? (view?.view === "projects" ? HOME : null);
- if (!ready || busy || reconnecting.current || target === null) return;
+ if (!ready || busy || reconnecting.current || target === null) {
+ return;
+ }
reconnecting.current = true;
requested.current = target;
setEditorRequest(null);
diff --git a/site/src/cut/components/Editor.tsx b/site/src/cut/components/Editor.tsx
index 0709168b..3c1b284b 100644
--- a/site/src/cut/components/Editor.tsx
+++ b/site/src/cut/components/Editor.tsx
@@ -335,7 +335,9 @@ export function Editor({
// the person while the tour is owed.
const play = () => {
const onboarding = queryClient.getQueryData<OnboardingState>(onboardingQueryKey);
- if (!chatgpt && onboardingStage(onboarding) === "tour") return;
+ if (!chatgpt && onboardingStage(onboarding) === "tour") {
+ return;
+ }
useEditor.getState().setPlaying(true);
};
if (!useOnboardingCover.getState().up) {
diff --git a/site/src/cut/components/RequireSession.tsx b/site/src/cut/components/RequireSession.tsx
index 8832a29e..2f88791c 100644
--- a/site/src/cut/components/RequireSession.tsx
+++ b/site/src/cut/components/RequireSession.tsx
@@ -68,7 +68,9 @@ export function RequireSession({ children }: { children: ReactNode }) {
// offer window.
const queryClient = useQueryClient();
useEffect(() => {
- if (!userId) return;
+ if (!userId) {
+ return;
+ }
void prefetchPricing(queryClient);
}, [userId, queryClient]);
diff --git a/site/src/cut/lib/environment.ts b/site/src/cut/lib/environment.ts
index 922c9cf5..7c894ad2 100644
--- a/site/src/cut/lib/environment.ts
+++ b/site/src/cut/lib/environment.ts
@@ -27,7 +27,9 @@ export function editorHost(): EditorHost {
function rememberCard() {
try {
- if (sessionStorage.getItem(CARD_KEY) !== "chatgpt") sessionStorage.setItem(CARD_KEY, "chatgpt");
+ if (sessionStorage.getItem(CARD_KEY) !== "chatgpt") {
+ sessionStorage.setItem(CARD_KEY, "chatgpt");
+ }
} catch {
// Storage blocked: the flag in the address is all the frame has.
}
diff --git a/site/src/cut/lib/hostBridge.ts b/site/src/cut/lib/hostBridge.ts
index 505e84a3..00ec50c4 100644
--- a/site/src/cut/lib/hostBridge.ts
+++ b/site/src/cut/lib/hostBridge.ts
@@ -30,13 +30,17 @@ export function useHostDisplayMode() {
}
export function requestHostFullscreen() {
- if (editorHost() !== "chatgpt") return;
+ if (editorHost() !== "chatgpt") {
+ return;
+ }
window.parent.postMessage({ type: "donkeycut:fullscreen" }, "*");
}
/** Renew the frame's partitioned session through the authenticated tool bridge. */
export function reconnectThroughHost() {
- if (editorHost() !== "chatgpt") return;
+ if (editorHost() !== "chatgpt") {
+ return;
+ }
window.parent.postMessage({ type: "donkeycut:reconnect" }, "*");
}
@@ -85,7 +89,9 @@ export function useHostReady(ready: boolean) {
/** Tell the card which project the frame shows, null on the projects home,
* so the model's context follows a project opened inside the frame. */
export function reportHostPage(projectId: string | null, name: string | null) {
- if (editorHost() !== "chatgpt") return;
+ if (editorHost() !== "chatgpt") {
+ return;
+ }
window.parent.postMessage({ type: "donkeycut:page", projectId, name }, "*");
}
@@ -105,7 +111,9 @@ export function projectPageUrl(): string {
export function useHostBridge() {
useEffect(() => {
- if (editorHost() !== "chatgpt") return;
+ if (editorHost() !== "chatgpt") {
+ return;
+ }
const onMessage = (event: MessageEvent) => {
if (event.source !== window.parent) return;
const data = event.data as { type?: unknown; insetBottom?: unknown; theme?: unknown; displayMode?: unknown } | null;
diff --git a/site/src/cut/lib/residency.ts b/site/src/cut/lib/residency.ts
index 5630c99d..3dcadf3e 100644
--- a/site/src/cut/lib/residency.ts
+++ b/site/src/cut/lib/residency.ts
@@ -53,7 +53,9 @@ export const RESIDENCY_LABEL: Record<Residency, string> = {
export function availableResidencies(): Residency[] {
// The card's tools reach cloud projects only, so the card lists and makes
// nothing else.
- if (editorHost() === "chatgpt") return ["cloud"];
+ if (editorHost() === "chatgpt") {
+ return ["cloud"];
+ }
const out: Residency[] = [];
if (servedFromEngine() || engineOrigin() !== "") out.push("local");
if (supportsBrowserStore()) out.push("browser");