import type { RepoDiff, RepoDiffDeps, RepoDiffFile } from "$lib/api/repoDiff";
// every file below inlines `content` on both sides, so `fetchSides` never
// falls back to `deps.git`'s blob endpoint -- `deps` itself is never touched
export const deps = { ctx: {}, git: {} } as unknown as RepoDiffDeps;
const zeroOid = "0".repeat(40);
const changed: RepoDiffFile = {
key: "src/lib/components/repo/DiffView.svelte→src/lib/components/repo/DiffView.svelte",
name: "src/lib/components/repo/DiffView.svelte",
kind: "changed",
stat: { insertions: 2, deletions: 1 },
lines: 6,
sides: {
lhs: {
path: "src/lib/components/repo/DiffView.svelte",
oid: "1111111111111111111111111111111111111111",
isBinary: false,
isSubmodule: false,
size: 60,
content: "let treeOpen = true;\n"
},
rhs: {
path: "src/lib/components/repo/DiffView.svelte",
oid: "2222222222222222222222222222222222222222",
isBinary: false,
isSubmodule: false,
size: 100,
content: "let treeOpen = $state(true);\nlet allOpen = $state(true);\n"
}
}
};
const added: RepoDiffFile = {
key: "→src/lib/components/repo/pulls/PullFileTree.svelte",
name: "src/lib/components/repo/pulls/PullFileTree.svelte",
kind: "new",
stat: { insertions: 3, deletions: 0 },
lines: 4,
sides: {
lhs: { path: "", oid: zeroOid, isBinary: false, isSubmodule: false, size: 0 },
rhs: {
path: "src/lib/components/repo/pulls/PullFileTree.svelte",
oid: "3333333333333333333333333333333333333333",
isBinary: false,
isSubmodule: false,
size: 80,
content: "interface Props {\n\tfiles: { name: string }[];\n}\n"
}
}
};
const deleted: RepoDiffFile = {
key: "src/lib/components/repo/pulls/PullOldPanel.svelte→",
name: "src/lib/components/repo/pulls/PullOldPanel.svelte",
kind: "deleted",
stat: { insertions: 0, deletions: 4 },
lines: 4,
sides: {
lhs: {
path: "src/lib/components/repo/pulls/PullOldPanel.svelte",
oid: "4444444444444444444444444444444444444444",
isBinary: false,
isSubmodule: false,
size: 90,
content: "
\n\told panel, replaced by PullFileTree\n
\n"
},
rhs: { path: "", oid: zeroOid, isBinary: false, isSubmodule: false, size: 0 }
}
};
const renamed: RepoDiffFile = {
key: "src/lib/components/repo/PierreDiff.svelte→src/lib/components/repo/DiffFileCard.svelte",
name: "src/lib/components/repo/DiffFileCard.svelte",
oldName: "src/lib/components/repo/PierreDiff.svelte",
kind: "renamed",
stat: { insertions: 1, deletions: 1 },
lines: 4,
sides: {
lhs: {
path: "src/lib/components/repo/PierreDiff.svelte",
oid: "5555555555555555555555555555555555555555",
isBinary: false,
isSubmodule: false,
size: 70,
content: "let diffStyle = 'unified';\n"
},
rhs: {
path: "src/lib/components/repo/DiffFileCard.svelte",
oid: "6666666666666666666666666666666666666666",
isBinary: false,
isSubmodule: false,
size: 80,
content: "let diffStyle: DiffStyle = 'unified';\n"
}
}
};
const binary: RepoDiffFile = {
key: "assets/diff-icon.png→assets/diff-icon.png",
name: "assets/diff-icon.png",
kind: "changed",
stat: { insertions: 0, deletions: 0 },
lines: 0,
note: "This is a binary file and will not be displayed."
};
const submodule: RepoDiffFile = {
key: "vendor/pierre→vendor/pierre",
name: "vendor/pierre",
kind: "changed",
stat: { insertions: 0, deletions: 0 },
lines: 0,
note: "Submodule pointer, not shown."
};
const skelFile1: RepoDiffFile = {
key: "src/lib/components/timeline/TimelineView.svelte→src/lib/components/timeline/TimelineView.svelte",
name: "src/lib/components/timeline/TimelineView.svelte",
kind: "changed",
stat: { insertions: 14, deletions: 4 },
lines: 24,
sides: {
lhs: {
path: "src/lib/components/timeline/TimelineView.svelte",
oid: "1010101010101010101010101010101010101010",
isBinary: false,
isSubmodule: false,
size: 480,
content: `// Svelte component
import Timeline from "./Timeline.svelte";
import TimelineSkeleton from "./TimelineSkeleton.svelte";
import TrendingRepos from "./TrendingRepos.svelte";
let { feed = [], trending = [], loading = false } = $props();
// end script
{#if loading}
{:else}
{/if}
`
},
rhs: {
path: "src/lib/components/timeline/TimelineView.svelte",
oid: "2020202020202020202020202020202020202020",
isBinary: false,
isSubmodule: false,
size: 890,
content: `// Svelte component
import Bones from "$lib/components/ui/Bones.svelte";
import Pending from "$lib/components/ui/Pending.svelte";
import timelineFixture from "$lib/bones/timeline--skeleton-fixture.bones.json";
import Timeline from "./Timeline.svelte";
import TrendingRepos from "./TrendingRepos.svelte";
let { feed = [], trending = [], signedIn = false } = $props();
// end script
{#snippet skeleton()}
{/snippet}
{@const resolved = await feed}
`
}
}
};
const skelFile2: RepoDiffFile = {
key: "src/lib/api/timelineFeed.ts→src/lib/api/timelineFeed.ts",
name: "src/lib/api/timelineFeed.ts",
kind: "changed",
stat: { insertions: 8, deletions: 2 },
lines: 14,
sides: {
lhs: {
path: "src/lib/api/timelineFeed.ts",
oid: "3030303030303030303030303030303030303030",
isBinary: false,
isSubmodule: false,
size: 260,
content: `export const loadFeed = async (ctx: Client) => {
const res = await ctx.getTimeline({});
return res.feed;
};
`
},
rhs: {
path: "src/lib/api/timelineFeed.ts",
oid: "4040404040404040404040404040404040404040",
isBinary: false,
isSubmodule: false,
size: 520,
content: `import { browser } from "$app/environment";
export const loadFeed = async (ctx: Client) => {
if (!browser) return [];
try {
const res = await ctx.getTimeline({});
return res.feed;
} catch {
return [];
}
};
`
}
}
};
const skelFile3: RepoDiffFile = {
key: "src/lib/components/notifications/NotificationList.svelte→src/lib/components/notifications/NotificationList.svelte",
name: "src/lib/components/notifications/NotificationList.svelte",
kind: "changed",
stat: { insertions: 18, deletions: 6 },
lines: 32,
sides: {
lhs: {
path: "src/lib/components/notifications/NotificationList.svelte",
oid: "5050505050505050505050505050505050505050",
isBinary: false,
isSubmodule: false,
size: 680,
content: `// Svelte component
import NotificationItem from "./NotificationItem.svelte";
let { notifications = [] } = $props();
// end script
{#each notifications as n}
{/each}
`
},
rhs: {
path: "src/lib/components/notifications/NotificationList.svelte",
oid: "6060606060606060606060606060606060606060",
isBinary: false,
isSubmodule: false,
size: 1240,
content: `// Svelte component
import Bones from "$lib/components/ui/Bones.svelte";
import notifsFixture from "$lib/bones/notifs--skeleton-fixture.bones.json";
import NotificationItem from "./NotificationItem.svelte";
interface Props {
notifications?: NotificationSummary[];
loading?: boolean;
title?: string;
}
let { notifications = [], loading = false, title }: Props = $props();
// end script
{#if loading}
{:else}
{#if title}
{title}
{/if}
{#each notifications as n (n.uri)}
{/each}
{/if}
`
}
}
};
const skelFile4: RepoDiffFile = {
key: "src/routes/+page.svelte→src/routes/+page.svelte",
name: "src/routes/+page.svelte",
kind: "changed",
stat: { insertions: 5, deletions: 2 },
lines: 10,
sides: {
lhs: {
path: "src/routes/+page.svelte",
oid: "7070707070707070707070707070707070707070",
isBinary: false,
isSubmodule: false,
size: 200,
content: `
`
},
rhs: {
path: "src/routes/+page.svelte",
oid: "8080808080808080808080808080808080808080",
isBinary: false,
isSubmodule: false,
size: 340,
content: `
`
}
}
};
const skelFile5: RepoDiffFile = {
key: "src/lib/format.ts→src/lib/format.ts",
name: "src/lib/format.ts",
kind: "changed",
stat: { insertions: 10, deletions: 1 },
lines: 16,
sides: {
lhs: {
path: "src/lib/format.ts",
oid: "9090909090909090909090909090909090909090",
isBinary: false,
isSubmodule: false,
size: 280,
content: `export const formatCount = (n: number): string => {
if (n >= 1000) return (n / 1000).toFixed(1) + "k";
return String(n);
};
`
},
rhs: {
path: "src/lib/format.ts",
oid: "a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0",
isBinary: false,
isSubmodule: false,
size: 580,
content: `const formatter = new Intl.NumberFormat("en", { notation: "compact" });
export const formatCount = (n: number): string => {
if (n < 1000) return String(n);
return formatter.format(n);
};
export const formatPercent = (ratio: number): string => {
return (ratio * 100).toFixed(1) + "%";
};
`
}
}
};
const skeletonFixtureFiles = [skelFile1, skelFile2, skelFile3, skelFile4, skelFile5];
const stat = (files: RepoDiffFile[]) => ({
insertions: files.reduce((n, f) => n + f.stat.insertions, 0),
deletions: files.reduce((n, f) => n + f.stat.deletions, 0),
files_changed: files.length
});
export const skeletonDiff: RepoDiff = {
files: skeletonFixtureFiles,
stat: stat(skeletonFixtureFiles),
contents: { inlineOld: false, oldRef: "old-ref", newRef: "new-ref" }
};
const mixedFiles = [changed, added, deleted, renamed, binary, submodule];
export const diff: RepoDiff = {
files: mixedFiles,
stat: stat(mixedFiles),
contents: { inlineOld: false, oldRef: "old-ref", newRef: "new-ref" }
};
export const emptyDiff: RepoDiff = {
files: [],
stat: stat([]),
contents: { inlineOld: false, oldRef: "old-ref", newRef: "new-ref" }
};