@pierre/diffs 1.3.0-beta.6 → 1.3.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeView.d.ts +4 -1
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +45 -6
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +5 -2
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +36 -23
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +126 -58
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +3 -2
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +4 -2
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +3 -7
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +10 -4
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +178 -49
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/editor/editor.d.ts +2 -2
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +163 -106
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/selection.d.ts +1 -1
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +87 -37
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +25 -7
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/tokenzier.d.ts +2 -0
- package/dist/editor/tokenzier.d.ts.map +1 -1
- package/dist/editor/tokenzier.js +11 -3
- package/dist/editor/tokenzier.js.map +1 -1
- package/dist/editor/utils.d.ts +3 -1
- package/dist/editor/utils.d.ts.map +1 -1
- package/dist/editor/utils.js +14 -1
- package/dist/editor/utils.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -1
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +0 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/react/EditorContext.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +3 -4
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/utils/useFileDiffInstance.js +14 -15
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +2 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +29 -16
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +11 -10
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +14 -6
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/types.d.ts +59 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areHunkDataEqual.js +1 -1
- package/dist/utils/areHunkDataEqual.js.map +1 -1
- package/dist/utils/awaitWithTimeout.d.ts +5 -0
- package/dist/utils/awaitWithTimeout.d.ts.map +1 -0
- package/dist/utils/awaitWithTimeout.js +15 -0
- package/dist/utils/awaitWithTimeout.js.map +1 -0
- package/dist/utils/cloneFileDiffMetadata.d.ts +7 -0
- package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -0
- package/dist/utils/cloneFileDiffMetadata.js +16 -0
- package/dist/utils/cloneFileDiffMetadata.js.map +1 -0
- package/dist/utils/computeEstimatedDiffHeights.d.ts +3 -1
- package/dist/utils/computeEstimatedDiffHeights.d.ts.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.js +8 -1
- package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
- package/dist/utils/createPreElement.js +0 -1
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/getDiffFileInput.d.ts +14 -0
- package/dist/utils/getDiffFileInput.d.ts.map +1 -0
- package/dist/utils/getDiffFileInput.js +24 -0
- package/dist/utils/getDiffFileInput.js.map +1 -0
- package/dist/utils/getDiffHunksRendererOptions.js +1 -0
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
- package/dist/utils/getFiletypeFromFileName.js +2 -0
- package/dist/utils/getFiletypeFromFileName.js.map +1 -1
- package/dist/utils/hydratePartialDiff.d.ts +10 -0
- package/dist/utils/hydratePartialDiff.d.ts.map +1 -0
- package/dist/utils/hydratePartialDiff.js +140 -0
- package/dist/utils/hydratePartialDiff.js.map +1 -0
- package/dist/utils/iterateOverDiff.js +3 -3
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/parseDiffFromFile.d.ts +1 -1
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +26 -5
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +0 -1
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/utils/updateDiffHunks.d.ts +5 -1
- package/dist/utils/updateDiffHunks.d.ts.map +1 -1
- package/dist/utils/updateDiffHunks.js +26 -4
- package/dist/utils/updateDiffHunks.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +7 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +78 -15
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/index.d.ts +2 -2
- package/dist/worker/types.d.ts +7 -1
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +5 -3
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +5 -3
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/ssr/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistration, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
|
|
1
|
+
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistration, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
|
|
2
2
|
import { PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, preloadDiffHTML, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadUnresolvedFile, preloadUnresolvedFileHTML } from "./preloadDiffs.js";
|
|
3
3
|
import { PreloadFileOptions, PreloadedFileResult, preloadFile } from "./preloadFile.js";
|
|
4
4
|
import { PreloadPatchFileOptions, preloadPatchFile } from "./preloadPatchFile.js";
|
|
5
5
|
import { renderHTML } from "./renderHTML.js";
|
|
6
|
-
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadFileOptions, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadPatchFileOptions, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, PreloadedFileResult, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, type ThemeRegistration, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs, preloadDiffHTML, preloadFile, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadPatchFile, preloadUnresolvedFile, preloadUnresolvedFileHTML, renderHTML };
|
|
6
|
+
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadFileOptions, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadPatchFileOptions, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, PreloadedFileResult, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, type ThemeRegistration, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs, preloadDiffHTML, preloadFile, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadPatchFile, preloadUnresolvedFile, preloadUnresolvedFileHTML, renderHTML };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { DiffLineAnnotation, FileContents, FileDiffMetadata } from "../types.js";
|
|
1
|
+
import { DiffFileInput, DiffLineAnnotation, FileContents, FileDiffMetadata, MaybeDiffFileInput } from "../types.js";
|
|
2
2
|
import { FileDiffOptions } from "../components/FileDiff.js";
|
|
3
3
|
import { UnresolvedFileOptions } from "../components/UnresolvedFile.js";
|
|
4
4
|
|
|
5
5
|
//#region src/ssr/preloadDiffs.d.ts
|
|
6
|
-
interface
|
|
7
|
-
fileDiff?: FileDiffMetadata;
|
|
8
|
-
oldFile?: FileContents;
|
|
9
|
-
newFile?: FileContents;
|
|
6
|
+
interface PreloadDiffBaseOptions<LAnnotation> {
|
|
10
7
|
options?: FileDiffOptions<LAnnotation>;
|
|
11
8
|
annotations?: DiffLineAnnotation<LAnnotation>[];
|
|
12
9
|
}
|
|
10
|
+
type PreloadDiffOptions<LAnnotation> = PreloadDiffBaseOptions<LAnnotation> & (({
|
|
11
|
+
fileDiff: FileDiffMetadata;
|
|
12
|
+
} & MaybeDiffFileInput) | ({
|
|
13
|
+
fileDiff?: undefined;
|
|
14
|
+
} & DiffFileInput));
|
|
13
15
|
declare function preloadDiffHTML<LAnnotation = undefined>({
|
|
14
16
|
fileDiff,
|
|
15
17
|
oldFile,
|
|
@@ -22,15 +24,14 @@ declare function preloadUnresolvedFileHTML<LAnnotation = undefined>({
|
|
|
22
24
|
options,
|
|
23
25
|
annotations
|
|
24
26
|
}: PreloadUnresolvedFileOptions<LAnnotation>): Promise<string>;
|
|
25
|
-
interface
|
|
26
|
-
oldFile: FileContents;
|
|
27
|
-
newFile: FileContents;
|
|
27
|
+
interface PreloadMultiFileDiffBaseOptions<LAnnotation> {
|
|
28
28
|
options?: FileDiffOptions<LAnnotation>;
|
|
29
29
|
annotations?: DiffLineAnnotation<LAnnotation>[];
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
type PreloadMultiFileDiffOptions<LAnnotation> = PreloadMultiFileDiffBaseOptions<LAnnotation> & DiffFileInput;
|
|
32
|
+
type PreloadMultiFileDiffResult<LAnnotation> = PreloadMultiFileDiffOptions<LAnnotation> & {
|
|
32
33
|
prerenderedHTML: string;
|
|
33
|
-
}
|
|
34
|
+
};
|
|
34
35
|
declare function preloadMultiFileDiff<LAnnotation = undefined>({
|
|
35
36
|
oldFile,
|
|
36
37
|
newFile,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preloadDiffs.d.ts","names":[],"sources":["../../src/ssr/preloadDiffs.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"preloadDiffs.d.ts","names":[],"sources":["../../src/ssr/preloadDiffs.ts"],"mappings":";;;;;UA6BU,sBAAA;EACR,OAAA,GAAU,eAAA,CAAgB,WAAA;EAC1B,WAAA,GAAc,kBAAA,CAAmB,WAAA;AAAA;AAAA,KAGvB,kBAAA,gBACV,sBAAA,CAAuB,WAAA;EAEd,QAAA,EAAU,gBAAA;AAAA,IAAqB,kBAAA;EAC/B,QAAA;AAAA,IAAyB,aAAA;AAAA,iBAGd,eAAA;EACpB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gB,WAAA;EAC1B,WAAA,GAAc,kBAAA,CAAmB,WAAA;AAAA;AAAA,UAGlB,sBAAA,sBAEP,uBAAuB,CAAC,WAAA;EAChC,eAAA;AAAA;AAAA,iBAGoB,gBAAA;EACpB,KAAA;EACA,OAAA;EACA;AAAA,GACC,uBAAA,CAAwB,WAAA,IAAe,OAAA,CACxC,sBAAA,CAAuB,WAAA"}
|
package/dist/ssr/preloadDiffs.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { wrapThemeCSS } from "../utils/cssWrappers.js";
|
|
2
|
+
import { getDiffFileInput } from "../utils/getDiffFileInput.js";
|
|
2
3
|
import { parseDiffFromFile } from "../utils/parseDiffFromFile.js";
|
|
3
4
|
import { DiffHunksRenderer } from "../renderers/DiffHunksRenderer.js";
|
|
4
5
|
import { parseMergeConflictDiffFromFile } from "../utils/parseMergeConflictDiffFromFile.js";
|
|
@@ -9,8 +10,12 @@ import { getSingularPatch } from "../utils/getSingularPatch.js";
|
|
|
9
10
|
import { renderHTML } from "./renderHTML.js";
|
|
10
11
|
//#region src/ssr/preloadDiffs.ts
|
|
11
12
|
async function preloadDiffHTML({ fileDiff, oldFile, newFile, options, annotations }) {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const fileInput = getDiffFileInput({
|
|
14
|
+
oldFile,
|
|
15
|
+
newFile
|
|
16
|
+
}, "preloadDiffHTML");
|
|
17
|
+
if (fileDiff == null && fileInput != null) fileDiff = parseDiffFromFile(fileInput.oldFile, fileInput.newFile, options?.parseDiffOptions);
|
|
18
|
+
if (fileDiff == null) throw new Error("preloadFileDiff: You must pass at least a fileDiff, oldFile, or newFile prop");
|
|
14
19
|
const renderer = new DiffHunksRenderer(getHunksRendererOptions(options));
|
|
15
20
|
if (annotations != null && annotations.length > 0) renderer.setLineAnnotations(annotations);
|
|
16
21
|
return renderHTML(processHunkResult(await renderer.asyncRender(fileDiff), renderer, options?.unsafeCSS, options?.themeType ?? "system"));
|
|
@@ -23,14 +28,17 @@ async function preloadUnresolvedFileHTML({ file, options, annotations }) {
|
|
|
23
28
|
return renderHTML(processHunkResult(await renderer.asyncRender(fileDiff), renderer, options?.unsafeCSS, options?.themeType ?? "system"));
|
|
24
29
|
}
|
|
25
30
|
async function preloadMultiFileDiff({ oldFile, newFile, options, annotations }) {
|
|
26
|
-
|
|
27
|
-
newFile,
|
|
31
|
+
const fileInput = getDiffFileInput({
|
|
28
32
|
oldFile,
|
|
33
|
+
newFile
|
|
34
|
+
}, "preloadMultiFileDiff");
|
|
35
|
+
if (fileInput == null) throw new Error("preloadMultiFileDiff: You must pass oldFile, newFile, or both");
|
|
36
|
+
return {
|
|
37
|
+
...fileInput,
|
|
29
38
|
options,
|
|
30
39
|
annotations,
|
|
31
40
|
prerenderedHTML: await preloadDiffHTML({
|
|
32
|
-
|
|
33
|
-
newFile,
|
|
41
|
+
...fileInput,
|
|
34
42
|
options,
|
|
35
43
|
annotations
|
|
36
44
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preloadDiffs.js","names":[],"sources":["../../src/ssr/preloadDiffs.ts"],"sourcesContent":["import type { FileDiffOptions } from '../components/FileDiff';\nimport {\n getUnresolvedDiffHunksRendererOptions,\n type UnresolvedFileOptions,\n} from '../components/UnresolvedFile';\nimport {\n DiffHunksRenderer,\n type DiffHunksRendererOptions,\n type HunksRenderResult,\n} from '../renderers/DiffHunksRenderer';\nimport { UnresolvedFileHunksRenderer } from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n} from '../types';\nimport {\n createStyleElement,\n createThemeStyleElement,\n} from '../utils/createStyleElement';\nimport { wrapThemeCSS } from '../utils/cssWrappers';\nimport { getSingularPatch } from '../utils/getSingularPatch';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { parseMergeConflictDiffFromFile } from '../utils/parseMergeConflictDiffFromFile';\nimport { renderHTML } from './renderHTML';\n\
|
|
1
|
+
{"version":3,"file":"preloadDiffs.js","names":[],"sources":["../../src/ssr/preloadDiffs.ts"],"sourcesContent":["import type { FileDiffOptions } from '../components/FileDiff';\nimport {\n getUnresolvedDiffHunksRendererOptions,\n type UnresolvedFileOptions,\n} from '../components/UnresolvedFile';\nimport {\n DiffHunksRenderer,\n type DiffHunksRendererOptions,\n type HunksRenderResult,\n} from '../renderers/DiffHunksRenderer';\nimport { UnresolvedFileHunksRenderer } from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n DiffFileInput,\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MaybeDiffFileInput,\n} from '../types';\nimport {\n createStyleElement,\n createThemeStyleElement,\n} from '../utils/createStyleElement';\nimport { wrapThemeCSS } from '../utils/cssWrappers';\nimport { getDiffFileInput } from '../utils/getDiffFileInput';\nimport { getSingularPatch } from '../utils/getSingularPatch';\nimport { parseDiffFromFile } from '../utils/parseDiffFromFile';\nimport { parseMergeConflictDiffFromFile } from '../utils/parseMergeConflictDiffFromFile';\nimport { renderHTML } from './renderHTML';\n\ninterface PreloadDiffBaseOptions<LAnnotation> {\n options?: FileDiffOptions<LAnnotation>;\n annotations?: DiffLineAnnotation<LAnnotation>[];\n}\n\nexport type PreloadDiffOptions<LAnnotation> =\n PreloadDiffBaseOptions<LAnnotation> &\n (\n | ({ fileDiff: FileDiffMetadata } & MaybeDiffFileInput)\n | ({ fileDiff?: undefined } & DiffFileInput)\n );\n\nexport async function preloadDiffHTML<LAnnotation = undefined>({\n fileDiff,\n oldFile,\n newFile,\n options,\n annotations,\n}: PreloadDiffOptions<LAnnotation>): Promise<string> {\n const fileInput = getDiffFileInput({ oldFile, newFile }, 'preloadDiffHTML');\n if (fileDiff == null && fileInput != null) {\n fileDiff = parseDiffFromFile(\n fileInput.oldFile,\n fileInput.newFile,\n options?.parseDiffOptions\n );\n }\n if (fileDiff == null) {\n throw new Error(\n 'preloadFileDiff: You must pass at least a fileDiff, oldFile, or newFile prop'\n );\n }\n const renderer = new DiffHunksRenderer<LAnnotation>(\n getHunksRendererOptions(options)\n );\n if (annotations != null && annotations.length > 0) {\n renderer.setLineAnnotations(annotations);\n }\n return renderHTML(\n processHunkResult(\n await renderer.asyncRender(fileDiff),\n renderer,\n options?.unsafeCSS,\n options?.themeType ?? 'system'\n )\n );\n}\n\nexport async function preloadUnresolvedFileHTML<LAnnotation = undefined>({\n file,\n options,\n annotations,\n}: PreloadUnresolvedFileOptions<LAnnotation>): Promise<string> {\n const { fileDiff, actions, markerRows } = parseMergeConflictDiffFromFile(\n file,\n options?.maxContextLines\n );\n const renderer = new UnresolvedFileHunksRenderer<LAnnotation>(\n getUnresolvedDiffHunksRendererOptions(options)\n );\n if (annotations != null && annotations.length > 0) {\n renderer.setLineAnnotations(annotations);\n }\n renderer.setConflictState(actions, markerRows, fileDiff);\n return renderHTML(\n processHunkResult(\n await renderer.asyncRender(fileDiff),\n renderer,\n options?.unsafeCSS,\n options?.themeType ?? 'system'\n )\n );\n}\n\ninterface PreloadMultiFileDiffBaseOptions<LAnnotation> {\n options?: FileDiffOptions<LAnnotation>;\n annotations?: DiffLineAnnotation<LAnnotation>[];\n}\n\nexport type PreloadMultiFileDiffOptions<LAnnotation> =\n PreloadMultiFileDiffBaseOptions<LAnnotation> & DiffFileInput;\n\nexport type PreloadMultiFileDiffResult<LAnnotation> =\n PreloadMultiFileDiffOptions<LAnnotation> & {\n prerenderedHTML: string;\n };\n\nexport async function preloadMultiFileDiff<LAnnotation = undefined>({\n oldFile,\n newFile,\n options,\n annotations,\n}: PreloadMultiFileDiffOptions<LAnnotation>): Promise<\n PreloadMultiFileDiffResult<LAnnotation>\n> {\n const fileInput = getDiffFileInput(\n { oldFile, newFile },\n 'preloadMultiFileDiff'\n );\n if (fileInput == null) {\n throw new Error(\n 'preloadMultiFileDiff: You must pass oldFile, newFile, or both'\n );\n }\n return {\n ...fileInput,\n options,\n annotations,\n prerenderedHTML: await preloadDiffHTML({\n ...fileInput,\n options,\n annotations,\n }),\n };\n}\n\nexport interface PreloadFileDiffOptions<LAnnotation> {\n fileDiff: FileDiffMetadata;\n options?: FileDiffOptions<LAnnotation>;\n annotations?: DiffLineAnnotation<LAnnotation>[];\n}\n\nexport interface PreloadFileDiffResult<\n LAnnotation,\n> extends PreloadFileDiffOptions<LAnnotation> {\n prerenderedHTML: string;\n}\n\nexport async function preloadFileDiff<LAnnotation = undefined>({\n fileDiff,\n options,\n annotations,\n}: PreloadFileDiffOptions<LAnnotation>): Promise<\n PreloadFileDiffResult<LAnnotation>\n> {\n return {\n fileDiff,\n options,\n annotations,\n prerenderedHTML: await preloadDiffHTML({\n fileDiff,\n options,\n annotations,\n }),\n };\n}\n\nexport interface PreloadUnresolvedFileOptions<LAnnotation> {\n file: FileContents;\n options?: Omit<\n UnresolvedFileOptions<LAnnotation>,\n 'onMergeConflictAction' | 'onMergeConflictResolve' | 'onPostRender'\n >;\n annotations?: DiffLineAnnotation<LAnnotation>[];\n}\n\nexport interface PreloadUnresolvedFileResult<\n LAnnotation,\n> extends PreloadUnresolvedFileOptions<LAnnotation> {\n prerenderedHTML: string;\n}\n\nexport async function preloadUnresolvedFile<LAnnotation = undefined>({\n file,\n options,\n annotations,\n}: PreloadUnresolvedFileOptions<LAnnotation>): Promise<\n PreloadUnresolvedFileResult<LAnnotation>\n> {\n return {\n file,\n options,\n annotations,\n prerenderedHTML: await preloadUnresolvedFileHTML({\n file,\n options,\n annotations,\n }),\n };\n}\n\nexport interface PreloadPatchDiffOptions<LAnnotation> {\n patch: string;\n options?: FileDiffOptions<LAnnotation>;\n annotations?: DiffLineAnnotation<LAnnotation>[];\n}\n\nexport interface PreloadPatchDiffResult<\n LAnnotation,\n> extends PreloadPatchDiffOptions<LAnnotation> {\n prerenderedHTML: string;\n}\n\nexport async function preloadPatchDiff<LAnnotation = undefined>({\n patch,\n options,\n annotations,\n}: PreloadPatchDiffOptions<LAnnotation>): Promise<\n PreloadPatchDiffResult<LAnnotation>\n> {\n const fileDiff = getSingularPatch(patch);\n return {\n patch,\n options,\n annotations,\n prerenderedHTML: await preloadDiffHTML({\n fileDiff,\n options,\n annotations,\n }),\n };\n}\n\nfunction processHunkResult<LAnnotation>(\n hunkResult: HunksRenderResult,\n renderer:\n | DiffHunksRenderer<LAnnotation>\n | UnresolvedFileHunksRenderer<LAnnotation>,\n unsafeCSS: string | undefined,\n themeType: 'system' | 'light' | 'dark'\n) {\n const children = [createStyleElement(hunkResult.css, true)];\n children.push(\n createThemeStyleElement(\n wrapThemeCSS(\n hunkResult.themeStyles,\n hunkResult.baseThemeType ?? themeType\n )\n )\n );\n if (unsafeCSS != null) {\n children.push(createStyleElement(unsafeCSS));\n }\n if (hunkResult.headerElement != null) {\n children.push(hunkResult.headerElement);\n }\n const code = renderer.renderFullAST(hunkResult);\n code.properties['data-dehydrated'] = '';\n children.push(code);\n return children;\n}\n\nfunction getHunksRendererOptions<LAnnotation>(\n options: FileDiffOptions<LAnnotation> | undefined\n): DiffHunksRendererOptions {\n return {\n ...options,\n headerRenderMode:\n options?.renderCustomHeader != null ? 'custom' : 'default',\n hunkSeparators:\n typeof options?.hunkSeparators === 'function'\n ? 'custom'\n : options?.hunkSeparators,\n };\n}\n"],"mappings":";;;;;;;;;;;AAyCA,eAAsB,gBAAyC,EAC7D,UACA,SACA,SACA,SACA,eACmD;CACnD,MAAM,YAAY,iBAAiB;EAAE;EAAS;CAAQ,GAAG,iBAAiB;CAC1E,IAAI,YAAY,QAAQ,aAAa,MACnC,WAAW,kBACT,UAAU,SACV,UAAU,SACV,SAAS,gBACX;CAEF,IAAI,YAAY,MACd,MAAM,IAAI,MACR,8EACF;CAEF,MAAM,WAAW,IAAI,kBACnB,wBAAwB,OAAO,CACjC;CACA,IAAI,eAAe,QAAQ,YAAY,SAAS,GAC9C,SAAS,mBAAmB,WAAW;CAEzC,OAAO,WACL,kBACE,MAAM,SAAS,YAAY,QAAQ,GACnC,UACA,SAAS,WACT,SAAS,aAAa,QACxB,CACF;AACF;AAEA,eAAsB,0BAAmD,EAC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C,IAAI,WAAW,iBAAiB,MAC9B,SAAS,KAAK,WAAW,aAAa;CAExC,MAAM,OAAO,SAAS,cAAc,UAAU;CAC9C,KAAK,WAAW,qBAAqB;CACrC,SAAS,KAAK,IAAI;CAClB,OAAO;AACT;AAEA,SAAS,wBACP,SAC0B;CAC1B,OAAO;EACL,GAAG;EACH,kBACE,SAAS,sBAAsB,OAAO,WAAW;EACnD,gBACE,OAAO,SAAS,mBAAmB,aAC/B,WACA,SAAS;CACjB;AACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -24,6 +24,30 @@ interface FileContents {
|
|
|
24
24
|
* `contents` or `name`, you must update the `cacheKey`. */
|
|
25
25
|
cacheKey?: string;
|
|
26
26
|
}
|
|
27
|
+
interface FileDiffLoadedChangedFiles {
|
|
28
|
+
oldFile: FileContents;
|
|
29
|
+
newFile: FileContents;
|
|
30
|
+
}
|
|
31
|
+
interface FileDiffLoadedPureRenamedFile {
|
|
32
|
+
oldFile: null;
|
|
33
|
+
newFile: FileContents;
|
|
34
|
+
}
|
|
35
|
+
type FileDiffLoadedFiles = FileDiffLoadedChangedFiles | FileDiffLoadedPureRenamedFile;
|
|
36
|
+
type DiffFileInput = {
|
|
37
|
+
oldFile: FileContents;
|
|
38
|
+
newFile: FileContents;
|
|
39
|
+
} | {
|
|
40
|
+
oldFile: null;
|
|
41
|
+
newFile: FileContents;
|
|
42
|
+
} | {
|
|
43
|
+
oldFile: FileContents;
|
|
44
|
+
newFile: null;
|
|
45
|
+
};
|
|
46
|
+
type MaybeDiffFileInput = DiffFileInput | {
|
|
47
|
+
oldFile?: undefined;
|
|
48
|
+
newFile?: undefined;
|
|
49
|
+
};
|
|
50
|
+
type FileDiffContentsLoader = (fileDiff: FileDiffMetadata) => Promise<FileDiffLoadedFiles>;
|
|
27
51
|
type HighlighterTypes = 'shiki-js' | 'shiki-wasm';
|
|
28
52
|
type HighlightedToken = [char: number, fg: string, text: string];
|
|
29
53
|
type DiffsThemeNames = BundledTheme | (string & {});
|
|
@@ -191,6 +215,10 @@ interface Hunk {
|
|
|
191
215
|
/**
|
|
192
216
|
* Metadata and content for a single file's diff. Think of this as a JSON
|
|
193
217
|
* compatible representation of a diff for a single file.
|
|
218
|
+
*
|
|
219
|
+
* When a renderer uses `loadDiffFiles` to hydrate a partial diff, it upgrades
|
|
220
|
+
* this metadata object in place. Keep the same object identity stable when
|
|
221
|
+
* callers want that hydrated state to persist across later renders.
|
|
194
222
|
*/
|
|
195
223
|
interface FileDiffMetadata {
|
|
196
224
|
/** The file's name and path. */
|
|
@@ -238,6 +266,10 @@ interface FileDiffMetadata {
|
|
|
238
266
|
* in the patch and hunk expansion is unavailable.
|
|
239
267
|
*
|
|
240
268
|
* When false, they contain the complete file contents.
|
|
269
|
+
*
|
|
270
|
+
* A hydrating renderer mutates a partial metadata object to flip this to
|
|
271
|
+
* false after `loadDiffFiles` resolves. Passing a freshly parsed partial
|
|
272
|
+
* object later is treated as a new partial render model.
|
|
241
273
|
*/
|
|
242
274
|
isPartial: boolean;
|
|
243
275
|
/**
|
|
@@ -261,6 +293,11 @@ interface FileDiffMetadata {
|
|
|
261
293
|
* to highlight if we've already highlighted the diff. Please note that if
|
|
262
294
|
* you modify the contents of the diff in any way, you will need to update
|
|
263
295
|
* the `cacheKey`.
|
|
296
|
+
*
|
|
297
|
+
* When `loadDiffFiles` hydrates a partial diff, Diffs uses loaded file cache
|
|
298
|
+
* keys when they are available so full-file highlights can be reused. If the
|
|
299
|
+
* loaded files are unkeyed and this partial key exists, Diffs appends a
|
|
300
|
+
* hydration segment as a fallback.
|
|
264
301
|
*/
|
|
265
302
|
cacheKey?: string;
|
|
266
303
|
}
|
|
@@ -307,6 +344,13 @@ interface BaseDiffOptions extends BaseCodeOptions {
|
|
|
307
344
|
disableBackground?: boolean;
|
|
308
345
|
hunkSeparators?: HunkSeparators;
|
|
309
346
|
expandUnchanged?: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Fetches full file contents for partial changed/renamed diffs parsed from
|
|
349
|
+
* patches. Return both sides for changed diffs and `oldFile: null` for pure
|
|
350
|
+
* renames. Added/deleted diffs already include their available side and thus
|
|
351
|
+
* this function serves no purpose in those contexts
|
|
352
|
+
*/
|
|
353
|
+
loadDiffFiles?: FileDiffContentsLoader;
|
|
310
354
|
collapsedContextThreshold?: number;
|
|
311
355
|
lineDiffType?: LineDiffTypes;
|
|
312
356
|
maxLineDiffLength?: number;
|
|
@@ -317,7 +361,7 @@ interface BaseDiffOptions extends BaseCodeOptions {
|
|
|
317
361
|
*/
|
|
318
362
|
parseDiffOptions?: CreatePatchOptionsNonabortable;
|
|
319
363
|
}
|
|
320
|
-
type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter' | 'parseDiffOptions'>>;
|
|
364
|
+
type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter' | 'parseDiffOptions' | 'loadDiffFiles'>>;
|
|
321
365
|
type CustomPreProperties = Record<string, string | number | undefined>;
|
|
322
366
|
interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow'>> {
|
|
323
367
|
type: 'diff' | 'file';
|
|
@@ -497,6 +541,7 @@ interface HunkData {
|
|
|
497
541
|
slotName: string;
|
|
498
542
|
hunkIndex: number;
|
|
499
543
|
lines: number;
|
|
544
|
+
lineCountKnown: boolean;
|
|
500
545
|
type: CodeColumnType;
|
|
501
546
|
expandable?: {
|
|
502
547
|
chunked: boolean;
|
|
@@ -718,13 +763,22 @@ interface DiffsBaseComponent {
|
|
|
718
763
|
cleanUp(): void;
|
|
719
764
|
}
|
|
720
765
|
interface DiffsEditableComponent<LAnnotation> extends DiffsBaseComponent {
|
|
766
|
+
/**
|
|
767
|
+
* Return the position and height of a one-based line relative to this component.
|
|
768
|
+
* The host uses it to scroll to virtualized lines before their DOM nodes exist.
|
|
769
|
+
* A zero height means the line is not currently renderable.
|
|
770
|
+
* In a file diff, `lineNumber` is the line number in the new file.
|
|
771
|
+
*/
|
|
772
|
+
getLinePosition?: (lineNumber: number) => {
|
|
773
|
+
top: number;
|
|
774
|
+
height: number;
|
|
775
|
+
} | undefined;
|
|
721
776
|
attachEditor: (editor: DiffsEditor<LAnnotation>) => () => void;
|
|
722
777
|
applyDocumentChange: (textDocument: DiffsTextDocument, newLineAnnotations?: DiffLineAnnotation<LAnnotation>[], shouldUpdateBuffer?: boolean) => void;
|
|
723
|
-
updateRenderCache: (lines: Map<number, Array<HighlightedToken>>, themeType: 'dark' | 'light', shouldRefreshView
|
|
724
|
-
rerenderFromDocument?: (textDocument: DiffsTextDocument) => void;
|
|
778
|
+
updateRenderCache: (lines: Map<number, Array<HighlightedToken>>, themeType: 'dark' | 'light', shouldRefreshView: boolean) => void;
|
|
725
779
|
}
|
|
726
780
|
interface DiffsEditor<LAnnotation> {
|
|
727
|
-
|
|
781
|
+
__postponeBgTokenizeToNextFrame(): void;
|
|
728
782
|
__syncRenderView(highlighter: DiffsHighlighter, fileContainer: HTMLElement, fileOrDiff: FileContents | FileDiffMetadata, lineAnnotations: LineAnnotation<LAnnotation>[] | DiffLineAnnotation<LAnnotation>[] | undefined, renderRange: RenderRange | undefined): void;
|
|
729
783
|
cleanUp(): void;
|
|
730
784
|
}
|
|
@@ -745,5 +799,5 @@ interface DiffsTextDocument {
|
|
|
745
799
|
getText: () => string;
|
|
746
800
|
}
|
|
747
801
|
//#endregion
|
|
748
|
-
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, type ThemeRegistration, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs };
|
|
802
|
+
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffFileInput, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsBaseComponent, DiffsComponentOptions, DiffsEditableComponent, DiffsEditor, DiffsEditorSelection, DiffsHighlighter, DiffsTextDocument, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffContentsLoader, FileDiffLoadedChangedFiles, FileDiffLoadedFiles, FileDiffLoadedPureRenamedFile, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlightedToken, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MaybeDiffFileInput, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PendingCodeViewLayoutReset, PostRenderPhase, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderFilenameSuffixCallback, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, type ThemeRegistration, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs };
|
|
749
803
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;KAiBY,sBAAA;AAAZ;;;;AAAA,UAMiB,YAAA;EAAA;;EAGf,IAAA;EAKyB;EAHzB,QAAA;EAAA;;EAGA,IAAA,GAAO,kBAAkB;EAEzB;EAAA,MAAA;EAIQ;AAAA;AAGV;EAHE,QAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;KAiBY,sBAAA;AAAZ;;;;AAAA,UAMiB,YAAA;EAAA;;EAGf,IAAA;EAKyB;EAHzB,QAAA;EAAA;;EAGA,IAAA,GAAO,kBAAkB;EAEzB;EAAA,MAAA;EAIQ;AAAA;AAGV;EAHE,QAAA;AAAA;AAAA,UAGe,0BAAA;EACf,OAAA,EAAS,YAAA;EACT,OAAA,EAAS,YAAY;AAAA;AAAA,UAGN,6BAAA;EACf,OAAA;EACA,OAAA,EAAS,YAAY;AAAA;AAAA,KAGX,mBAAA,GACR,0BAAA,GACA,6BAA6B;AAAA,KAErB,aAAA;EACN,OAAA,EAAS,YAAA;EAAc,OAAA,EAAS,YAAA;AAAA;EAChC,OAAA;EAAe,OAAA,EAAS,YAAA;AAAA;EACxB,OAAA,EAAS,YAAA;EAAc,OAAA;AAAA;AAAA,KAEjB,kBAAA,GACR,aAAa;EACX,OAAA;EAAqB,OAAA;AAAA;AAAA,KAEf,sBAAA,IACV,QAAA,EAAU,gBAAA,KACP,OAAA,CAAQ,mBAAA;AAAA,KAED,gBAAA;AAAA,KAEA,gBAAA,IAAoB,IAAA,UAAc,EAAA,UAAY,IAAA;AAAA,KAe9C,eAAA,GAAkB,YAAY;AAAA,KAE9B,UAAA,GAAa,MAAM,mBAAmB,eAAA;;;;;;;;KAStC,gBAAA,GAAmB,kBAAA,CAC7B,kBAAA,EACA,eA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AAA,EAC3B,eAAA,EACI,cAAA,CAAe,WAAA,MACf,kBAAA,CAAmB,WAAA,iBAEvB,WAAA,EAAa,WAAA;EAEf,OAAA;AAAA;AAAA,UAGe,oBAAA;EACf,KAAA;IACE,IAAA;IACA,SAAA;EAAA;EAEF,GAAA;IACE,IAAA;IACA,SAAA;EAAA;EAEF,SAAA;AAAA;AAAA,UAGe,iBAAA;EAAA,SACN,SAAA;EACT,WAAA,GAAc,UAAA,UAAoB,gBAAA;EAClC,OAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/utils/areHunkDataEqual.ts
|
|
2
2
|
function areHunkDataEqual(hunkA, hunkB) {
|
|
3
|
-
return hunkA.slotName === hunkB.slotName && hunkA.hunkIndex === hunkB.hunkIndex && hunkA.lines === hunkB.lines && hunkA.type === hunkB.type && hunkA.expandable?.chunked === hunkB.expandable?.chunked && hunkA.expandable?.up === hunkB.expandable?.up && hunkA.expandable?.down === hunkB.expandable?.down;
|
|
3
|
+
return hunkA.slotName === hunkB.slotName && hunkA.hunkIndex === hunkB.hunkIndex && hunkA.lines === hunkB.lines && hunkA.lineCountKnown === hunkB.lineCountKnown && hunkA.type === hunkB.type && hunkA.expandable?.chunked === hunkB.expandable?.chunked && hunkA.expandable?.up === hunkB.expandable?.up && hunkA.expandable?.down === hunkB.expandable?.down;
|
|
4
4
|
}
|
|
5
5
|
//#endregion
|
|
6
6
|
export { areHunkDataEqual };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"areHunkDataEqual.js","names":[],"sources":["../../src/utils/areHunkDataEqual.ts"],"sourcesContent":["import type { HunkData } from '../types';\n\nexport function areHunkDataEqual(hunkA: HunkData, hunkB: HunkData): boolean {\n return (\n hunkA.slotName === hunkB.slotName &&\n hunkA.hunkIndex === hunkB.hunkIndex &&\n hunkA.lines === hunkB.lines &&\n hunkA.type === hunkB.type &&\n hunkA.expandable?.chunked === hunkB.expandable?.chunked &&\n hunkA.expandable?.up === hunkB.expandable?.up &&\n hunkA.expandable?.down === hunkB.expandable?.down\n );\n}\n"],"mappings":";AAEA,SAAgB,iBAAiB,OAAiB,OAA0B;CAC1E,OACE,MAAM,aAAa,MAAM,YACzB,MAAM,cAAc,MAAM,aAC1B,MAAM,UAAU,MAAM,SACtB,MAAM,SAAS,MAAM,QACrB,MAAM,YAAY,YAAY,MAAM,YAAY,WAChD,MAAM,YAAY,OAAO,MAAM,YAAY,MAC3C,MAAM,YAAY,SAAS,MAAM,YAAY;AAEjD"}
|
|
1
|
+
{"version":3,"file":"areHunkDataEqual.js","names":[],"sources":["../../src/utils/areHunkDataEqual.ts"],"sourcesContent":["import type { HunkData } from '../types';\n\nexport function areHunkDataEqual(hunkA: HunkData, hunkB: HunkData): boolean {\n return (\n hunkA.slotName === hunkB.slotName &&\n hunkA.hunkIndex === hunkB.hunkIndex &&\n hunkA.lines === hunkB.lines &&\n hunkA.lineCountKnown === hunkB.lineCountKnown &&\n hunkA.type === hunkB.type &&\n hunkA.expandable?.chunked === hunkB.expandable?.chunked &&\n hunkA.expandable?.up === hunkB.expandable?.up &&\n hunkA.expandable?.down === hunkB.expandable?.down\n );\n}\n"],"mappings":";AAEA,SAAgB,iBAAiB,OAAiB,OAA0B;CAC1E,OACE,MAAM,aAAa,MAAM,YACzB,MAAM,cAAc,MAAM,aAC1B,MAAM,UAAU,MAAM,SACtB,MAAM,mBAAmB,MAAM,kBAC/B,MAAM,SAAS,MAAM,QACrB,MAAM,YAAY,YAAY,MAAM,YAAY,WAChD,MAAM,YAAY,OAAO,MAAM,YAAY,MAC3C,MAAM,YAAY,SAAS,MAAM,YAAY;AAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awaitWithTimeout.d.ts","names":[],"sources":["../../src/utils/awaitWithTimeout.ts"],"mappings":";iBAAsB,gBAAA,CACpB,QAAA,QAAgB,OAAA,WAChB,OAAA,YACC,OAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/utils/awaitWithTimeout.ts
|
|
2
|
+
async function awaitWithTimeout(callback, timeout = 300) {
|
|
3
|
+
let timeoutId;
|
|
4
|
+
try {
|
|
5
|
+
await Promise.race([callback(), new Promise((resolve) => {
|
|
6
|
+
timeoutId = setTimeout(resolve, timeout);
|
|
7
|
+
})]);
|
|
8
|
+
} finally {
|
|
9
|
+
if (timeoutId != null) clearTimeout(timeoutId);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { awaitWithTimeout };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=awaitWithTimeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"awaitWithTimeout.js","names":[],"sources":["../../src/utils/awaitWithTimeout.ts"],"sourcesContent":["export async function awaitWithTimeout(\n callback: () => Promise<unknown>,\n timeout: number = 300\n): Promise<void> {\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n try {\n await Promise.race([\n callback(),\n new Promise<void>((resolve) => {\n timeoutId = setTimeout(resolve, timeout);\n }),\n ]);\n } finally {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n }\n}\n"],"mappings":";AAAA,eAAsB,iBACpB,UACA,UAAkB,KACH;CACf,IAAI;CACJ,IAAI;EACF,MAAM,QAAQ,KAAK,CACjB,SAAS,GACT,IAAI,SAAe,YAAY;GAC7B,YAAY,WAAW,SAAS,OAAO;EACzC,CAAC,CACH,CAAC;CACH,UAAU;EACR,IAAI,aAAa,MACf,aAAa,SAAS;CAE1B;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FileDiffMetadata } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/cloneFileDiffMetadata.d.ts
|
|
4
|
+
declare function cloneFileDiffMetadata(fileDiff: FileDiffMetadata): FileDiffMetadata;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { cloneFileDiffMetadata };
|
|
7
|
+
//# sourceMappingURL=cloneFileDiffMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloneFileDiffMetadata.d.ts","names":[],"sources":["../../src/utils/cloneFileDiffMetadata.ts"],"mappings":";;;iBAEgB,qBAAA,CACd,QAAA,EAAU,gBAAA,GACT,gBAAgB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/utils/cloneFileDiffMetadata.ts
|
|
2
|
+
function cloneFileDiffMetadata(fileDiff) {
|
|
3
|
+
return {
|
|
4
|
+
...fileDiff,
|
|
5
|
+
hunks: fileDiff.hunks.map((hunk) => ({
|
|
6
|
+
...hunk,
|
|
7
|
+
hunkContent: hunk.hunkContent.map((content) => ({ ...content }))
|
|
8
|
+
})),
|
|
9
|
+
deletionLines: [...fileDiff.deletionLines],
|
|
10
|
+
additionLines: [...fileDiff.additionLines]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { cloneFileDiffMetadata };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=cloneFileDiffMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloneFileDiffMetadata.js","names":[],"sources":["../../src/utils/cloneFileDiffMetadata.ts"],"sourcesContent":["import type { FileDiffMetadata } from '../types';\n\nexport function cloneFileDiffMetadata(\n fileDiff: FileDiffMetadata\n): FileDiffMetadata {\n return {\n ...fileDiff,\n hunks: fileDiff.hunks.map((hunk) => ({\n ...hunk,\n hunkContent: hunk.hunkContent.map((content) => ({ ...content })),\n })),\n deletionLines: [...fileDiff.deletionLines],\n additionLines: [...fileDiff.additionLines],\n };\n}\n"],"mappings":";AAEA,SAAgB,sBACd,UACkB;CAClB,OAAO;EACL,GAAG;EACH,OAAO,SAAS,MAAM,KAAK,UAAU;GACnC,GAAG;GACH,aAAa,KAAK,YAAY,KAAK,aAAa,EAAE,GAAG,QAAQ,EAAE;EACjE,EAAE;EACF,eAAe,CAAC,GAAG,SAAS,aAAa;EACzC,eAAe,CAAC,GAAG,SAAS,aAAa;CAC3C;AACF"}
|
|
@@ -9,6 +9,7 @@ interface ComputeEstimatedDiffHeightsOptions {
|
|
|
9
9
|
expandUnchanged: boolean;
|
|
10
10
|
expandedHunks: Map<number, HunkExpansionRegion> | true | undefined;
|
|
11
11
|
collapsedContextThreshold: number;
|
|
12
|
+
canHydratePartialDiff: boolean;
|
|
12
13
|
}
|
|
13
14
|
interface EstimatedDiffHeights {
|
|
14
15
|
splitHeight: number;
|
|
@@ -21,7 +22,8 @@ declare function computeEstimatedDiffHeights({
|
|
|
21
22
|
hunkSeparators,
|
|
22
23
|
expandUnchanged,
|
|
23
24
|
expandedHunks: configuredExpandedHunks,
|
|
24
|
-
collapsedContextThreshold
|
|
25
|
+
collapsedContextThreshold,
|
|
26
|
+
canHydratePartialDiff
|
|
25
27
|
}: ComputeEstimatedDiffHeightsOptions): EstimatedDiffHeights;
|
|
26
28
|
//#endregion
|
|
27
29
|
export { ComputeEstimatedDiffHeightsOptions, EstimatedDiffHeights, computeEstimatedDiffHeights };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeEstimatedDiffHeights.d.ts","names":[],"sources":["../../src/utils/computeEstimatedDiffHeights.ts"],"mappings":";;;UAmBiB,kCAAA;EACf,QAAA,EAAU,gBAAA;EACV,OAAA,EAAS,kBAAA;EACT,iBAAA;EACA,cAAA,EAAgB,cAAA;EAChB,eAAA;EACA,aAAA,EAAe,GAAA,SAAY,mBAAA;EAC3B,yBAAA;AAAA;AAAA,UAGe,oBAAA;EACf,WAAA;EACA,aAAa;AAAA;AAAA,iBAKC,2BAAA;EACd,QAAA;EACA,OAAA;EACA,iBAAA;EACA,cAAA;EACA,eAAA;EACA,aAAA,EAAe,uBAAA;EACf;AAAA,GACC,kCAAA,GAAqC,oBAAA"}
|
|
1
|
+
{"version":3,"file":"computeEstimatedDiffHeights.d.ts","names":[],"sources":["../../src/utils/computeEstimatedDiffHeights.ts"],"mappings":";;;UAmBiB,kCAAA;EACf,QAAA,EAAU,gBAAA;EACV,OAAA,EAAS,kBAAA;EACT,iBAAA;EACA,cAAA,EAAgB,cAAA;EAChB,eAAA;EACA,aAAA,EAAe,GAAA,SAAY,mBAAA;EAC3B,yBAAA;EACA,qBAAA;AAAA;AAAA,UAGe,oBAAA;EACf,WAAA;EACA,aAAa;AAAA;AAAA,iBAKC,2BAAA;EACd,QAAA;EACA,OAAA;EACA,iBAAA;EACA,cAAA;EACA,eAAA;EACA,aAAA,EAAe,uBAAA;EACf,yBAAA;EACA;AAAA,GACC,kCAAA,GAAqC,oBAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getVirtualFileHeaderRegion, getVirtualFilePaddingBottom } from "./computeVirtualFileMetrics.js";
|
|
2
2
|
import { getExpandedRegion, getLeadingHunkSeparatorLayout, getTrailingExpandedRegion, getTrailingHunkSeparatorLayout } from "./virtualDiffLayout.js";
|
|
3
3
|
//#region src/utils/computeEstimatedDiffHeights.ts
|
|
4
|
-
function computeEstimatedDiffHeights({ fileDiff, metrics, disableFileHeader, hunkSeparators, expandUnchanged, expandedHunks: configuredExpandedHunks, collapsedContextThreshold }) {
|
|
4
|
+
function computeEstimatedDiffHeights({ fileDiff, metrics, disableFileHeader, hunkSeparators, expandUnchanged, expandedHunks: configuredExpandedHunks, collapsedContextThreshold, canHydratePartialDiff }) {
|
|
5
5
|
let splitHeight = getVirtualFileHeaderRegion(metrics, disableFileHeader);
|
|
6
6
|
let unifiedHeight = splitHeight;
|
|
7
7
|
const expandedHunks = expandUnchanged ? true : configuredExpandedHunks;
|
|
@@ -53,6 +53,13 @@ function computeEstimatedDiffHeights({ fileDiff, metrics, disableFileHeader, hun
|
|
|
53
53
|
splitHeight += separatorHeight;
|
|
54
54
|
unifiedHeight += separatorHeight;
|
|
55
55
|
}
|
|
56
|
+
} else if (hunkIndex === finalHunkIndex && fileDiff.isPartial && canHydratePartialDiff) {
|
|
57
|
+
const separatorHeight = getTrailingHunkSeparatorLayout({
|
|
58
|
+
type: hunkSeparators,
|
|
59
|
+
metrics
|
|
60
|
+
})?.totalHeight ?? 0;
|
|
61
|
+
splitHeight += separatorHeight;
|
|
62
|
+
unifiedHeight += separatorHeight;
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
if (fileDiff.hunks.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeEstimatedDiffHeights.js","names":[],"sources":["../../src/utils/computeEstimatedDiffHeights.ts"],"sourcesContent":["import type {\n ChangeContent,\n FileDiffMetadata,\n Hunk,\n HunkExpansionRegion,\n HunkSeparators,\n VirtualFileMetrics,\n} from '../types';\nimport {\n getVirtualFileHeaderRegion,\n getVirtualFilePaddingBottom,\n} from './computeVirtualFileMetrics';\nimport {\n getExpandedRegion,\n getLeadingHunkSeparatorLayout,\n getTrailingExpandedRegion,\n getTrailingHunkSeparatorLayout,\n} from './virtualDiffLayout';\n\nexport interface ComputeEstimatedDiffHeightsOptions {\n fileDiff: FileDiffMetadata;\n metrics: VirtualFileMetrics;\n disableFileHeader: boolean;\n hunkSeparators: HunkSeparators;\n expandUnchanged: boolean;\n expandedHunks: Map<number, HunkExpansionRegion> | true | undefined;\n collapsedContextThreshold: number;\n}\n\nexport interface EstimatedDiffHeights {\n splitHeight: number;\n unifiedHeight: number;\n}\n\n// Computes both split and unified baseline heights from hunk-level metadata so\n// callers can avoid replaying the detailed rendered-line iterator.\nexport function computeEstimatedDiffHeights({\n fileDiff,\n metrics,\n disableFileHeader,\n hunkSeparators,\n expandUnchanged,\n expandedHunks: configuredExpandedHunks,\n collapsedContextThreshold,\n}: ComputeEstimatedDiffHeightsOptions): EstimatedDiffHeights {\n let splitHeight = getVirtualFileHeaderRegion(metrics, disableFileHeader);\n let unifiedHeight = splitHeight;\n const expandedHunks = expandUnchanged ? true : configuredExpandedHunks;\n const finalHunkIndex = fileDiff.hunks.length - 1;\n\n for (let hunkIndex = 0; hunkIndex < fileDiff.hunks.length; hunkIndex++) {\n const hunk = fileDiff.hunks[hunkIndex];\n if (hunk == null) {\n throw new Error('computeEstimatedDiffHeights: invalid hunk index');\n }\n\n const leadingRegion = getExpandedRegion({\n isPartial: fileDiff.isPartial,\n rangeSize: hunk.collapsedBefore,\n expandedHunks,\n hunkIndex,\n collapsedContextThreshold,\n });\n const leadingExpandedHeight =\n (leadingRegion.fromStart + leadingRegion.fromEnd) * metrics.lineHeight;\n splitHeight += leadingExpandedHeight;\n unifiedHeight += leadingExpandedHeight;\n\n if (leadingRegion.collapsedLines > 0) {\n const separatorHeight =\n getLeadingHunkSeparatorLayout({\n type: hunkSeparators,\n metrics,\n hunkIndex,\n hunkSpecs: hunk.hunkSpecs,\n })?.totalHeight ?? 0;\n splitHeight += separatorHeight;\n unifiedHeight += separatorHeight;\n }\n\n splitHeight += hunk.splitLineCount * metrics.lineHeight;\n unifiedHeight += hunk.unifiedLineCount * metrics.lineHeight;\n\n const metadataLineCounts = getNoNewlineMetadataLineCounts(hunk);\n splitHeight += metadataLineCounts.split * metrics.lineHeight;\n unifiedHeight += metadataLineCounts.unified * metrics.lineHeight;\n\n const trailingRegion =\n hunkIndex === finalHunkIndex\n ? getTrailingExpandedRegion({\n fileDiff,\n hunkIndex,\n expandedHunks,\n collapsedContextThreshold,\n errorPrefix: 'computeEstimatedDiffHeights',\n })\n : undefined;\n if (trailingRegion != null) {\n const trailingExpandedHeight =\n (trailingRegion.fromStart + trailingRegion.fromEnd) *\n metrics.lineHeight;\n splitHeight += trailingExpandedHeight;\n unifiedHeight += trailingExpandedHeight;\n\n if (trailingRegion.collapsedLines > 0) {\n const separatorHeight =\n getTrailingHunkSeparatorLayout({\n type: hunkSeparators,\n metrics,\n })?.totalHeight ?? 0;\n splitHeight += separatorHeight;\n unifiedHeight += separatorHeight;\n }\n }\n }\n\n if (fileDiff.hunks.length > 0) {\n const paddingBottom = getVirtualFilePaddingBottom(metrics);\n splitHeight += paddingBottom;\n unifiedHeight += paddingBottom;\n }\n\n return { splitHeight, unifiedHeight };\n}\n\nfunction getNoNewlineMetadataLineCounts(hunk: Hunk): {\n split: number;\n unified: number;\n} {\n if (!hunk.noEOFCRAdditions && !hunk.noEOFCRDeletions) {\n return { split: 0, unified: 0 };\n }\n\n const lastContent = hunk.hunkContent.at(-1);\n if (lastContent == null) {\n return { split: 0, unified: 0 };\n }\n\n if (lastContent.type === 'context') {\n const metadataRows = lastContent.lines > 0 ? 1 : 0;\n return { split: metadataRows, unified: metadataRows };\n }\n\n return getChangeNoNewlineMetadataLineCounts(hunk, lastContent);\n}\nfunction getChangeNoNewlineMetadataLineCounts(\n hunk: Hunk,\n content: ChangeContent\n): { split: number; unified: number } {\n const unified =\n (content.deletions > 0 && hunk.noEOFCRDeletions ? 1 : 0) +\n (content.additions > 0 && hunk.noEOFCRAdditions ? 1 : 0);\n const splitDeletionHasMetadata =\n content.deletions > 0 && hunk.noEOFCRDeletions;\n const splitAdditionHasMetadata =\n content.additions > 0 && hunk.noEOFCRAdditions;\n const split = splitDeletionHasMetadata || splitAdditionHasMetadata ? 1 : 0;\n\n return { split, unified };\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"computeEstimatedDiffHeights.js","names":[],"sources":["../../src/utils/computeEstimatedDiffHeights.ts"],"sourcesContent":["import type {\n ChangeContent,\n FileDiffMetadata,\n Hunk,\n HunkExpansionRegion,\n HunkSeparators,\n VirtualFileMetrics,\n} from '../types';\nimport {\n getVirtualFileHeaderRegion,\n getVirtualFilePaddingBottom,\n} from './computeVirtualFileMetrics';\nimport {\n getExpandedRegion,\n getLeadingHunkSeparatorLayout,\n getTrailingExpandedRegion,\n getTrailingHunkSeparatorLayout,\n} from './virtualDiffLayout';\n\nexport interface ComputeEstimatedDiffHeightsOptions {\n fileDiff: FileDiffMetadata;\n metrics: VirtualFileMetrics;\n disableFileHeader: boolean;\n hunkSeparators: HunkSeparators;\n expandUnchanged: boolean;\n expandedHunks: Map<number, HunkExpansionRegion> | true | undefined;\n collapsedContextThreshold: number;\n canHydratePartialDiff: boolean;\n}\n\nexport interface EstimatedDiffHeights {\n splitHeight: number;\n unifiedHeight: number;\n}\n\n// Computes both split and unified baseline heights from hunk-level metadata so\n// callers can avoid replaying the detailed rendered-line iterator.\nexport function computeEstimatedDiffHeights({\n fileDiff,\n metrics,\n disableFileHeader,\n hunkSeparators,\n expandUnchanged,\n expandedHunks: configuredExpandedHunks,\n collapsedContextThreshold,\n canHydratePartialDiff,\n}: ComputeEstimatedDiffHeightsOptions): EstimatedDiffHeights {\n let splitHeight = getVirtualFileHeaderRegion(metrics, disableFileHeader);\n let unifiedHeight = splitHeight;\n const expandedHunks = expandUnchanged ? true : configuredExpandedHunks;\n const finalHunkIndex = fileDiff.hunks.length - 1;\n\n for (let hunkIndex = 0; hunkIndex < fileDiff.hunks.length; hunkIndex++) {\n const hunk = fileDiff.hunks[hunkIndex];\n if (hunk == null) {\n throw new Error('computeEstimatedDiffHeights: invalid hunk index');\n }\n\n const leadingRegion = getExpandedRegion({\n isPartial: fileDiff.isPartial,\n rangeSize: hunk.collapsedBefore,\n expandedHunks,\n hunkIndex,\n collapsedContextThreshold,\n });\n const leadingExpandedHeight =\n (leadingRegion.fromStart + leadingRegion.fromEnd) * metrics.lineHeight;\n splitHeight += leadingExpandedHeight;\n unifiedHeight += leadingExpandedHeight;\n\n if (leadingRegion.collapsedLines > 0) {\n const separatorHeight =\n getLeadingHunkSeparatorLayout({\n type: hunkSeparators,\n metrics,\n hunkIndex,\n hunkSpecs: hunk.hunkSpecs,\n })?.totalHeight ?? 0;\n splitHeight += separatorHeight;\n unifiedHeight += separatorHeight;\n }\n\n splitHeight += hunk.splitLineCount * metrics.lineHeight;\n unifiedHeight += hunk.unifiedLineCount * metrics.lineHeight;\n\n const metadataLineCounts = getNoNewlineMetadataLineCounts(hunk);\n splitHeight += metadataLineCounts.split * metrics.lineHeight;\n unifiedHeight += metadataLineCounts.unified * metrics.lineHeight;\n\n const trailingRegion =\n hunkIndex === finalHunkIndex\n ? getTrailingExpandedRegion({\n fileDiff,\n hunkIndex,\n expandedHunks,\n collapsedContextThreshold,\n errorPrefix: 'computeEstimatedDiffHeights',\n })\n : undefined;\n if (trailingRegion != null) {\n const trailingExpandedHeight =\n (trailingRegion.fromStart + trailingRegion.fromEnd) *\n metrics.lineHeight;\n splitHeight += trailingExpandedHeight;\n unifiedHeight += trailingExpandedHeight;\n\n if (trailingRegion.collapsedLines > 0) {\n const separatorHeight =\n getTrailingHunkSeparatorLayout({\n type: hunkSeparators,\n metrics,\n })?.totalHeight ?? 0;\n splitHeight += separatorHeight;\n unifiedHeight += separatorHeight;\n }\n } else if (\n hunkIndex === finalHunkIndex &&\n fileDiff.isPartial &&\n canHydratePartialDiff\n ) {\n const separatorHeight =\n getTrailingHunkSeparatorLayout({\n type: hunkSeparators,\n metrics,\n })?.totalHeight ?? 0;\n splitHeight += separatorHeight;\n unifiedHeight += separatorHeight;\n }\n }\n\n if (fileDiff.hunks.length > 0) {\n const paddingBottom = getVirtualFilePaddingBottom(metrics);\n splitHeight += paddingBottom;\n unifiedHeight += paddingBottom;\n }\n\n return { splitHeight, unifiedHeight };\n}\n\nfunction getNoNewlineMetadataLineCounts(hunk: Hunk): {\n split: number;\n unified: number;\n} {\n if (!hunk.noEOFCRAdditions && !hunk.noEOFCRDeletions) {\n return { split: 0, unified: 0 };\n }\n\n const lastContent = hunk.hunkContent.at(-1);\n if (lastContent == null) {\n return { split: 0, unified: 0 };\n }\n\n if (lastContent.type === 'context') {\n const metadataRows = lastContent.lines > 0 ? 1 : 0;\n return { split: metadataRows, unified: metadataRows };\n }\n\n return getChangeNoNewlineMetadataLineCounts(hunk, lastContent);\n}\nfunction getChangeNoNewlineMetadataLineCounts(\n hunk: Hunk,\n content: ChangeContent\n): { split: number; unified: number } {\n const unified =\n (content.deletions > 0 && hunk.noEOFCRDeletions ? 1 : 0) +\n (content.additions > 0 && hunk.noEOFCRAdditions ? 1 : 0);\n const splitDeletionHasMetadata =\n content.deletions > 0 && hunk.noEOFCRDeletions;\n const splitAdditionHasMetadata =\n content.additions > 0 && hunk.noEOFCRAdditions;\n const split = splitDeletionHasMetadata || splitAdditionHasMetadata ? 1 : 0;\n\n return { split, unified };\n}\n"],"mappings":";;;AAqCA,SAAgB,4BAA4B,EAC1C,UACA,SACA,mBACA,gBACA,iBACA,eAAe,yBACf,2BACA,yBAC2D;CAC3D,IAAI,cAAc,2BAA2B,SAAS,iBAAiB;CACvE,IAAI,gBAAgB;CACpB,MAAM,gBAAgB,kBAAkB,OAAO;CAC/C,MAAM,iBAAiB,SAAS,MAAM,SAAS;CAE/C,KAAK,IAAI,YAAY,GAAG,YAAY,SAAS,MAAM,QAAQ,aAAa;EACtE,MAAM,OAAO,SAAS,MAAM;EAC5B,IAAI,QAAQ,MACV,MAAM,IAAI,MAAM,iDAAiD;EAGnE,MAAM,gBAAgB,kBAAkB;GACtC,WAAW,SAAS;GACpB,WAAW,KAAK;GAChB;GACA;GACA;EACF,CAAC;EACD,MAAM,yBACH,cAAc,YAAY,cAAc,WAAW,QAAQ;EAC9D,eAAe;EACf,iBAAiB;EAEjB,IAAI,cAAc,iBAAiB,GAAG;GACpC,MAAM,kBACJ,8BAA8B;IAC5B,MAAM;IACN;IACA;IACA,WAAW,KAAK;GAClB,CAAC,CAAC,EAAE,eAAe;GACrB,eAAe;GACf,iBAAiB;EACnB;EAEA,eAAe,KAAK,iBAAiB,QAAQ;EAC7C,iBAAiB,KAAK,mBAAmB,QAAQ;EAEjD,MAAM,qBAAqB,+BAA+B,IAAI;EAC9D,eAAe,mBAAmB,QAAQ,QAAQ;EAClD,iBAAiB,mBAAmB,UAAU,QAAQ;EAEtD,MAAM,iBACJ,cAAc,iBACV,0BAA0B;GACxB;GACA;GACA;GACA;GACA,aAAa;EACf,CAAC,IACD,KAAA;EACN,IAAI,kBAAkB,MAAM;GAC1B,MAAM,0BACH,eAAe,YAAY,eAAe,WAC3C,QAAQ;GACV,eAAe;GACf,iBAAiB;GAEjB,IAAI,eAAe,iBAAiB,GAAG;IACrC,MAAM,kBACJ,+BAA+B;KAC7B,MAAM;KACN;IACF,CAAC,CAAC,EAAE,eAAe;IACrB,eAAe;IACf,iBAAiB;GACnB;EACF,OAAO,IACL,cAAc,kBACd,SAAS,aACT,uBACA;GACA,MAAM,kBACJ,+BAA+B;IAC7B,MAAM;IACN;GACF,CAAC,CAAC,EAAE,eAAe;GACrB,eAAe;GACf,iBAAiB;EACnB;CACF;CAEA,IAAI,SAAS,MAAM,SAAS,GAAG;EAC7B,MAAM,gBAAgB,4BAA4B,OAAO;EACzD,eAAe;EACf,iBAAiB;CACnB;CAEA,OAAO;EAAE;EAAa;CAAc;AACtC;AAEA,SAAS,+BAA+B,MAGtC;CACA,IAAI,CAAC,KAAK,oBAAoB,CAAC,KAAK,kBAClC,OAAO;EAAE,OAAO;EAAG,SAAS;CAAE;CAGhC,MAAM,cAAc,KAAK,YAAY,GAAG,EAAE;CAC1C,IAAI,eAAe,MACjB,OAAO;EAAE,OAAO;EAAG,SAAS;CAAE;CAGhC,IAAI,YAAY,SAAS,WAAW;EAClC,MAAM,eAAe,YAAY,QAAQ,IAAI,IAAI;EACjD,OAAO;GAAE,OAAO;GAAc,SAAS;EAAa;CACtD;CAEA,OAAO,qCAAqC,MAAM,WAAW;AAC/D;AACA,SAAS,qCACP,MACA,SACoC;CACpC,MAAM,WACH,QAAQ,YAAY,KAAK,KAAK,mBAAmB,IAAI,MACrD,QAAQ,YAAY,KAAK,KAAK,mBAAmB,IAAI;CACxD,MAAM,2BACJ,QAAQ,YAAY,KAAK,KAAK;CAChC,MAAM,2BACJ,QAAQ,YAAY,KAAK,KAAK;CAGhC,OAAO;EAAE,OAFK,4BAA4B,2BAA2B,IAAI;EAEzD;CAAQ;AAC1B"}
|
|
@@ -16,7 +16,6 @@ function createPreWrapperProperties({ diffIndicators, disableBackground, disable
|
|
|
16
16
|
"data-disable-line-numbers": disableLineNumbers ? "" : void 0,
|
|
17
17
|
"data-background": !disableBackground ? "" : void 0,
|
|
18
18
|
"data-indicators": diffIndicators === "bars" || diffIndicators === "classic" ? diffIndicators : void 0,
|
|
19
|
-
tabIndex: 0,
|
|
20
19
|
style: `--diffs-min-number-column-width-default:${`${totalLines}`.length}ch;`
|
|
21
20
|
};
|
|
22
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPreElement.js","names":[],"sources":["../../src/utils/createPreElement.ts"],"sourcesContent":["import type { Element as HASTElement, Properties } from 'hast';\n\nimport type { PrePropertiesConfig } from '../types';\nimport { createHastElement } from './hast_utils';\n\nexport function createPreElement(options: PrePropertiesConfig): HASTElement {\n return createHastElement({\n tagName: 'pre',\n properties: createPreWrapperProperties(options),\n });\n}\n\nexport function createPreWrapperProperties({\n diffIndicators,\n disableBackground,\n disableLineNumbers,\n overflow,\n split,\n totalLines,\n type,\n customProperties,\n}: PrePropertiesConfig): Properties {\n const properties: Properties = {\n // NOTE: We always apply custom properties first so the important\n // properties cannot be overridden\n ...customProperties,\n 'data-diff': type === 'diff' ? '' : undefined,\n 'data-file': type === 'file' ? '' : undefined,\n 'data-diff-type':\n type === 'diff' ? (split ? 'split' : 'single') : undefined,\n 'data-overflow': overflow,\n 'data-disable-line-numbers': disableLineNumbers ? '' : undefined,\n 'data-background': !disableBackground ? '' : undefined,\n 'data-indicators':\n diffIndicators === 'bars' || diffIndicators === 'classic'\n ? diffIndicators\n : undefined,\n
|
|
1
|
+
{"version":3,"file":"createPreElement.js","names":[],"sources":["../../src/utils/createPreElement.ts"],"sourcesContent":["import type { Element as HASTElement, Properties } from 'hast';\n\nimport type { PrePropertiesConfig } from '../types';\nimport { createHastElement } from './hast_utils';\n\nexport function createPreElement(options: PrePropertiesConfig): HASTElement {\n return createHastElement({\n tagName: 'pre',\n properties: createPreWrapperProperties(options),\n });\n}\n\nexport function createPreWrapperProperties({\n diffIndicators,\n disableBackground,\n disableLineNumbers,\n overflow,\n split,\n totalLines,\n type,\n customProperties,\n}: PrePropertiesConfig): Properties {\n const properties: Properties = {\n // NOTE: We always apply custom properties first so the important\n // properties cannot be overridden\n ...customProperties,\n 'data-diff': type === 'diff' ? '' : undefined,\n 'data-file': type === 'file' ? '' : undefined,\n 'data-diff-type':\n type === 'diff' ? (split ? 'split' : 'single') : undefined,\n 'data-overflow': overflow,\n 'data-disable-line-numbers': disableLineNumbers ? '' : undefined,\n 'data-background': !disableBackground ? '' : undefined,\n 'data-indicators':\n diffIndicators === 'bars' || diffIndicators === 'classic'\n ? diffIndicators\n : undefined,\n // The pre is intentionally not focusable. It is not the scroll container\n // (`[data-code]` inside it is) and has no keyboard behavior of its own, so\n // a tabindex would only add a tab stop per diff and steal focus from a host\n // wrapper that wants to own keyboard navigation of the selection.\n style: `--diffs-min-number-column-width-default:${`${totalLines}`.length}ch;`,\n };\n\n return properties;\n}\n"],"mappings":";;AAKA,SAAgB,iBAAiB,SAA2C;CAC1E,OAAO,kBAAkB;EACvB,SAAS;EACT,YAAY,2BAA2B,OAAO;CAChD,CAAC;AACH;AAEA,SAAgB,2BAA2B,EACzC,gBACA,mBACA,oBACA,UACA,OACA,YACA,MACA,oBACkC;CAuBlC,OAAO;EAnBL,GAAG;EACH,aAAa,SAAS,SAAS,KAAK,KAAA;EACpC,aAAa,SAAS,SAAS,KAAK,KAAA;EACpC,kBACE,SAAS,SAAU,QAAQ,UAAU,WAAY,KAAA;EACnD,iBAAiB;EACjB,6BAA6B,qBAAqB,KAAK,KAAA;EACvD,mBAAmB,CAAC,oBAAoB,KAAK,KAAA;EAC7C,mBACE,mBAAmB,UAAU,mBAAmB,YAC5C,iBACA,KAAA;EAKN,OAAO,2CAA2C,GAAG,aAAa,OAAO;CAG3D;AAClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DiffFileInput, FileContents } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/getDiffFileInput.d.ts
|
|
4
|
+
interface GetDiffFileInputProps {
|
|
5
|
+
oldFile?: FileContents | null;
|
|
6
|
+
newFile?: FileContents | null;
|
|
7
|
+
}
|
|
8
|
+
declare function getDiffFileInput({
|
|
9
|
+
oldFile,
|
|
10
|
+
newFile
|
|
11
|
+
}: GetDiffFileInputProps, context: string): DiffFileInput | undefined;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getDiffFileInput };
|
|
14
|
+
//# sourceMappingURL=getDiffFileInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDiffFileInput.d.ts","names":[],"sources":["../../src/utils/getDiffFileInput.ts"],"mappings":";;;UAEU,qBAAA;EACR,OAAA,GAAU,YAAA;EACV,OAAA,GAAU,YAAY;AAAA;AAAA,iBAGR,gBAAA;EACZ,OAAA;EAAS;AAAA,GAAW,qBAAA,EACtB,OAAA,WACC,aAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/utils/getDiffFileInput.ts
|
|
2
|
+
function getDiffFileInput({ oldFile, newFile }, context) {
|
|
3
|
+
if (oldFile === void 0 && newFile === void 0) return;
|
|
4
|
+
if (oldFile === void 0 || newFile === void 0) throw new Error(`${context}: Pass null for an intentionally missing oldFile or newFile side`);
|
|
5
|
+
if (oldFile === null) {
|
|
6
|
+
if (newFile === null) throw new Error(`${context}: You must pass oldFile, newFile, or both`);
|
|
7
|
+
return {
|
|
8
|
+
oldFile,
|
|
9
|
+
newFile
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (newFile === null) return {
|
|
13
|
+
oldFile,
|
|
14
|
+
newFile
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
oldFile,
|
|
18
|
+
newFile
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getDiffFileInput };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=getDiffFileInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDiffFileInput.js","names":[],"sources":["../../src/utils/getDiffFileInput.ts"],"sourcesContent":["import type { DiffFileInput, FileContents } from '../types';\n\ninterface GetDiffFileInputProps {\n oldFile?: FileContents | null;\n newFile?: FileContents | null;\n}\n\nexport function getDiffFileInput(\n { oldFile, newFile }: GetDiffFileInputProps,\n context: string\n): DiffFileInput | undefined {\n if (oldFile === undefined && newFile === undefined) {\n return undefined;\n }\n if (oldFile === undefined || newFile === undefined) {\n throw new Error(\n `${context}: Pass null for an intentionally missing oldFile or newFile side`\n );\n }\n if (oldFile === null) {\n if (newFile === null) {\n throw new Error(`${context}: You must pass oldFile, newFile, or both`);\n }\n return { oldFile, newFile };\n }\n if (newFile === null) {\n return { oldFile, newFile };\n }\n return { oldFile, newFile };\n}\n"],"mappings":";AAOA,SAAgB,iBACd,EAAE,SAAS,WACX,SAC2B;CAC3B,IAAI,YAAY,KAAA,KAAa,YAAY,KAAA,GACvC;CAEF,IAAI,YAAY,KAAA,KAAa,YAAY,KAAA,GACvC,MAAM,IAAI,MACR,GAAG,QAAQ,iEACb;CAEF,IAAI,YAAY,MAAM;EACpB,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,QAAQ,0CAA0C;EAEvE,OAAO;GAAE;GAAS;EAAQ;CAC5B;CACA,IAAI,YAAY,MACd,OAAO;EAAE;EAAS;CAAQ;CAE5B,OAAO;EAAE;EAAS;CAAQ;AAC5B"}
|
|
@@ -18,6 +18,7 @@ function getDiffHunksRendererOptions(options) {
|
|
|
18
18
|
disableBackground: options?.disableBackground,
|
|
19
19
|
hunkSeparators: typeof options?.hunkSeparators === "function" ? "custom" : options?.hunkSeparators,
|
|
20
20
|
expandUnchanged: options?.expandUnchanged,
|
|
21
|
+
loadDiffFiles: options?.loadDiffFiles,
|
|
21
22
|
collapsedContextThreshold: options?.collapsedContextThreshold,
|
|
22
23
|
lineDiffType: options?.lineDiffType,
|
|
23
24
|
maxLineDiffLength: options?.maxLineDiffLength,
|