|
1 | 1 | <script lang="ts"> |
2 | | - import ConciseDiffView from "$lib/components/diff/ConciseDiffView.svelte"; |
3 | 2 | import { VList } from "virtua/svelte"; |
4 | | - import { MultiFileDiffViewerState, requireEitherImage } from "$lib/diff-viewer.svelte"; |
5 | | - import Spinner from "$lib/components/Spinner.svelte"; |
6 | | - import ImageDiff from "$lib/components/diff/ImageDiff.svelte"; |
7 | | - import AddedOrRemovedImage from "$lib/components/diff/AddedOrRemovedImage.svelte"; |
| 3 | + import { MultiFileDiffViewerState } from "$lib/diff-viewer.svelte"; |
8 | 4 | import DiffStats from "$lib/components/diff/DiffStats.svelte"; |
9 | 5 | import DiffSearch from "./DiffSearch.svelte"; |
10 | 6 | import FileHeader from "./FileHeader.svelte"; |
|
17 | 13 | import MenuBar from "$lib/components/menu-bar/MenuBar.svelte"; |
18 | 14 | import SettingsDialog from "$lib/components/settings/SettingsDialog.svelte"; |
19 | 15 | import Sidebar from "./Sidebar.svelte"; |
| 16 | + import DiffWrapper from "./DiffWrapper.svelte"; |
20 | 17 |
|
21 | 18 | let { data }: PageProps = $props(); |
22 | | - const globalOptions = GlobalOptions.init(data.globalOptions); |
| 19 | + GlobalOptions.init(data.globalOptions); |
23 | 20 | const viewer = MultiFileDiffViewerState.init(); |
24 | 21 |
|
25 | 22 | function getPageTitle() { |
|
76 | 73 | {#snippet children(value, index)} |
77 | 74 | <div id={`file-${index}`}> |
78 | 75 | <FileHeader {index} {value} /> |
79 | | - {#if !viewer.fileStates[index].collapsed && value.type === "image"} |
80 | | - {@const image = value.image} |
81 | | - <div class="mb border-b text-sm"> |
82 | | - {#if image.load} |
83 | | - {#if image.fileA !== null && image.fileB !== null} |
84 | | - {#await Promise.all([image.fileA.getValue(), image.fileB.getValue()])} |
85 | | - <div class="flex items-center justify-center bg-neutral-2 p-4"><Spinner /></div> |
86 | | - {:then images} |
87 | | - <ImageDiff fileA={images[0]} fileB={images[1]} /> |
88 | | - {/await} |
89 | | - {:else} |
90 | | - {#await requireEitherImage(image).getValue()} |
91 | | - <div class="flex items-center justify-center bg-neutral-2 p-4"><Spinner /></div> |
92 | | - {:then file} |
93 | | - <AddedOrRemovedImage {file} mode={image.fileA === null ? "add" : "remove"} /> |
94 | | - {/await} |
95 | | - {/if} |
96 | | - {:else} |
97 | | - <div class="flex justify-center bg-neutral-2 p-4"> |
98 | | - <button |
99 | | - type="button" |
100 | | - class=" flex flex-row items-center justify-center gap-1 rounded-md btn-primary px-2 py-1" |
101 | | - onclick={() => (image.load = true)} |
102 | | - > |
103 | | - <span class="iconify size-4 shrink-0 octicon--image-16"></span><span>Load image diff</span> |
104 | | - </button> |
105 | | - </div> |
106 | | - {/if} |
107 | | - </div> |
108 | | - {/if} |
109 | | - {#if !viewer.fileStates[index].collapsed && value.type === "text" && (!value.patchHeaderDiffOnly || !globalOptions.omitPatchHeaderOnlyHunks)} |
110 | | - <div class="border-b"> |
111 | | - <ConciseDiffView |
112 | | - patch={value.structuredPatch} |
113 | | - syntaxHighlighting={globalOptions.syntaxHighlighting} |
114 | | - syntaxHighlightingTheme={globalOptions.syntaxHighlightingTheme} |
115 | | - omitPatchHeaderOnlyHunks={globalOptions.omitPatchHeaderOnlyHunks} |
116 | | - wordDiffs={globalOptions.wordDiffs} |
117 | | - lineWrap={globalOptions.lineWrap} |
118 | | - searchQuery={viewer.searchQueryDebounced.current} |
119 | | - searchMatchingLines={() => viewer.searchResults.then((r) => r.lines.get(value))} |
120 | | - activeSearchResult={viewer.activeSearchResult && viewer.activeSearchResult.file === value |
121 | | - ? viewer.activeSearchResult.idx |
122 | | - : undefined} |
123 | | - cache={viewer.diffViewCache} |
124 | | - cacheKey={value} |
125 | | - /> |
126 | | - </div> |
127 | | - {/if} |
| 76 | + <DiffWrapper {index} {value} /> |
128 | 77 | </div> |
129 | 78 | {/snippet} |
130 | 79 | </VList> |
|
0 commit comments