@pierre/diffs 1.1.2 → 1.1.4
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/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/FileDiff.d.ts +4 -4
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +18 -9
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +199 -57
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +5 -4
- package/dist/react/UnresolvedFile.d.ts +3 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +6 -4
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +5 -4
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +15 -12
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +15 -7
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +9 -7
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +11 -16
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +68 -75
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +4 -3
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +41 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.d.ts +3 -2
- package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.js +24 -89
- package/dist/utils/diffAcceptRejectHunk.js.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.d.ts +4 -6
- package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.js +2 -2
- package/dist/utils/getMergeConflictActionSlotName.js.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.d.ts +1 -2
- package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.js +7 -12
- package/dist/utils/getMergeConflictLineTypes.js.map +1 -1
- package/dist/utils/normalizeDiffResolution.d.ts +7 -0
- package/dist/utils/normalizeDiffResolution.d.ts.map +1 -0
- package/dist/utils/normalizeDiffResolution.js +11 -0
- package/dist/utils/normalizeDiffResolution.js.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts +16 -12
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.js +474 -117
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/resolveConflict.d.ts +7 -0
- package/dist/utils/resolveConflict.d.ts.map +1 -0
- package/dist/utils/resolveConflict.js +23 -0
- package/dist/utils/resolveConflict.js.map +1 -0
- package/dist/utils/resolveRegion.d.ts +14 -0
- package/dist/utils/resolveRegion.d.ts.map +1 -0
- package/dist/utils/resolveRegion.js +215 -0
- package/dist/utils/resolveRegion.js.map +1 -0
- package/dist/utils/trimPatchContext.js +19 -20
- package/dist/utils/trimPatchContext.js.map +1 -1
- package/dist/worker/{wasm-BlUZCxHM.js → wasm-BaDzIkIn.js} +2 -2
- package/dist/worker/wasm-BaDzIkIn.js.map +1 -0
- package/dist/worker/worker-portable.js +4880 -4810
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js.map +1 -1
- package/package.json +2 -1
- package/dist/utils/resolveMergeConflict.d.ts +0 -7
- package/dist/utils/resolveMergeConflict.d.ts.map +0 -1
- package/dist/utils/resolveMergeConflict.js +0 -30
- package/dist/utils/resolveMergeConflict.js.map +0 -1
- package/dist/worker/wasm-BlUZCxHM.js.map +0 -1
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":["ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","RenderHeaderMetadataProps","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","SelectionPoint"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow' | 'themeType'>> {\n type: 'diff' | 'file';\n split: boolean;\n themeStyles: string;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport interface RenderHeaderMetadataProps {\n deletionFile?: FileContents;\n additionFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n}\nexport type RenderHeaderMetadataCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderHeaderPrefixCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderFileMetadata = (file: FileContents) => Element | null | undefined | string | number;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","RenderHeaderMetadataProps","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type MergeConflictMarkerRowType = 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end';\nexport interface MergeConflictMarkerRow {\n type: MergeConflictMarkerRowType;\n hunkIndex: number;\n /** Index into `hunk.hunkContent` for the structural block this row belongs to. */\n contentIndex: number;\n conflictIndex: number;\n lineText: string;\n /** Unified rendered-row index where this virtual row should be injected. */\n lineIndex: number;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow' | 'themeType'>> {\n type: 'diff' | 'file';\n split: boolean;\n themeStyles: string;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport interface RenderHeaderMetadataProps {\n deletionFile?: FileContents;\n additionFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n}\nexport type RenderHeaderMetadataCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderHeaderPrefixCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderFileMetadata = (file: FileContents) => Element | null | undefined | string | number;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\nexport type DiffAcceptRejectHunkType = 'accept' | 'reject' | 'both';\nexport type ConflictResolverTypes = 'current' | 'incoming' | 'both';\nexport interface DiffAcceptRejectHunkConfig {\n type: DiffAcceptRejectHunkType;\n changeIndex: number;\n}\n/**\n * Unresolved merge conflict indexes use three different coordinate spaces:\n * - source line indexes live on `conflict.*LineIndex`\n * - hunk-content indexes live on the fields below, with `startContentIndex`\n * serving as both the conflict-range start and the start-marker anchor\n * - rendered row indexes live on unresolved `markerRows`\n */\nexport interface ProcessFileConflictData {\n /** Index of the hunk that owns this unresolved conflict. */\n hunkIndex: number;\n /** First hunk-content entry that belongs to the conflict region. */\n startContentIndex: number;\n /** Last hunk-content entry that belongs to the conflict region. */\n endContentIndex: number;\n /** Hunk-content index for the current/ours change block. */\n currentContentIndex?: number;\n /** Hunk-content index for the optional base context block. */\n baseContentIndex?: number;\n /** Hunk-content index for the incoming/theirs change block. */\n incomingContentIndex?: number;\n /** Hunk-content index that anchors the end marker row. */\n endMarkerContentIndex: number;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;AAMA;AAgBA;AAEYa,UAlBKH,YAAAA,CAkBU;EACfI;AAQZ;EAAkDH,IAAAA,EAAAA,MAAAA;EAAoBE;EAAvCR,QAAAA,EAAAA,MAAAA;EAAkB;AASjD;EAKiBa,IAAAA,CAAAA,EAjCNP,kBAiCiB;EAYXS;EAoBAC,MAAAA,CAAAA,EAAAA,MAAAA;EAqBAC;AA0FjB;;EA8BUL,QAAAA,CAAAA,EAAAA,MAAAA;;AAGK,KAzMHL,gBAAAA,GAyMG,UAAA,GAAA,YAAA;AAwCEY,KA/OLX,eAAAA,GAAkBX,YAgPpBqB,GAAAA,aAAAA,GAAAA,cAA0B,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AASxBZ,KAxPAG,UAAAA,GAAaC,MAwPK,CAAA,MAAGd,GAAAA,OAAAA,EAxPiBY,eAwPF,CAAA;AAChD;AACA;AAIA;AACA;AACA;;;AAIgBa,KA5PJV,gBAAAA,GAAmBX,kBA4PfqB,CA5PkCf,kBA4PlCe,EA5PsDb,eA4PtDa,CAAAA;;;AAShB;;;;;AAWA;AAAwDI,KAvQ5Cb,WAAAA,GAuQ4Ca,QAAAA,GAAAA,aAAAA,GAAAA,gBAAAA,GAAAA,KAAAA,GAAAA,SAAAA;;;;AACxD;AACiBK,UApQAjB,WAAAA,CAoQmB;EAAuBY;;EAKpCI,aAAAA,CAAAA,EAAAA,MAAAA;EALsBD;EAAQ,KAAA,EA/P1Cd,gBA+P0C,EAAA;AAOrD;;;;;AAKA;AACYqB,UArQKpB,cAAAA,CAqQLoB;EACAC,IAAAA,EAAAA,SAAAA;EACAC;EACAC,KAAAA,EAAAA,MAAAA;EACAC;AAA0C;AAMtD;AAGA;EACUD,iBAAAA,EAAAA,MAAAA;EAEWG;;;AACrB;EACiBI,iBAAAA,EAAAA,MAAmB;AAWpC;AAIA;AAIA;AACA;AACA;AAMA;AAGiBI,UAjSAjC,aAAAA,CAiSc;EAMdqC,IAAAA,EAAAA,QAAAA;EAOAE;EAAoCF,SAAAA,EAAAA,MAAAA;EAEjCf;;;;EAGHkB,iBAAAA,EAAAA,MAAAA;EAGEF;EACJA,SAAAA,EAAAA,MAAAA;EAIIA;;;AAMnB;EAOYI,iBAAc,EAAA,MAAA;AAC1B;AAWA;;;;AAAmD,UA/TlCzC,IAAAA,CA+TkC;EACvC6C;AACZ;AAKA;AAIA;EAKiBI,eAAAA,EAAAA,MAAmB;EAInBC;AAOjB;AAMA;;EACsD3D,aAAAA,EAAAA,MAAAA;EAAzBE;;AAG7B;;;;;EAG+B,aAAA,EAAA,MAAA;EAEd8D;EAIAC,aAAAA,EAAAA,MAAgB;EAIhBC;;;;EAKAC,iBAAAA,EAAAA,MAAAA;EAAW;AAE5B;;;EAIYV,aAAAA,EAAAA,MAAAA;EACKU;;AAEjB;AAMA;AAIA;AAIA;AAOA;EAIYM,aAAAA,EAAAA,MAAAA;EACAC;EACKC,aAAAA,EAAAA,MAAAA;EAWAC;;;;;;;;;gBAnXCrE,iBAAiBC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAwClBF,gBAAAA;;;;;;;;;;;SAWNR;;;;;;;;;;;;;;;;;;;QAmBDM;;;SAGCK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCCC,0BAAAA;UACKC,sBAAAA;QACPD;;;;;;;;;KASEZ,kBAAAA,GAAqBV;KACrBwB,YAAAA;KACAC,UAAAA;;;;KAIAC,cAAAA;KACAC,aAAAA;UACKC,eAAAA;UACLhB,kBAAkBC;;;cAGdY;;;;yBAIWd;;;;;UAKVkB,eAAAA,SAAwBD;;;;mBAIpBF;;;iBAGFC;;;;KAIPG,2BAAAA,GAA8BE,SAASD,KAAKF;KAC5CI,mBAAAA,GAAsBnB;UACjBoB,mBAAAA,SAA4BF,SAASG,KAAKN;;;;;qBAKpCI;;UAENG,yBAAAA;iBACE3B;iBACAA;aACJS;;KAEHmB,4BAAAA,WAAuCD,8BAA8BE;KACrEC,0BAAAA,WAAqCH,8BAA8BE;KACnEE,kBAAAA,UAA4B/B,iBAAiB6B;KAC7CG,kBAAAA,GAAqB3B,eAAeJ;KACpCgC,cAAAA;KACAC,aAAAA;KACPC,sBAAsBC;;;YAGbA;;KAEFC;;IAERF,iBAAiBC;KACTE;QACFL;;IAENE,iBAAiBC;KACTG,uBAAAA;UACKC,mBAAAA;;;;;;;;;;;UAWAC,0BAAAA;cACDF;YACFC;;UAEGE,OAAAA;;;;KAILC,SAAAA,GAAYD,UAAUE;KACtBC,SAAAA;UACKC,QAAAA;QACPD;;;;;UAKOE,iBAAAA;aACFD,wDAAwDA;;UAEtDF,cAAAA;;;;;;UAMAI,kBAAAA;;;eAGAC;iBACEA;;;UAGFC,sBAAAA,SAA+B5B,KAAK0B;;kBAEjCf;YACNY;;UAEGM,uBAAAA;;;eAGEF;WACJA;;;;eAIIA;WACJA;;;;;UAKEG,iBAAAA;;eAEAH;iBACEA;;;;KAIPI,cAAAA;UACKC,QAAAA;;;;QAIPD;;;;;;;KAOEE,iCAAiClD,eAAeiC,mBAAmBkB;KACnEC,mBAAAA;UACKC,gBAAAA;QACPpE;;;;UAIOqE,qBAAAA;iBACErE;iBACAA;;UAEFsE,gBAAAA;QACPD;;;;UAIOE,mBAAAA;;;;UAIAC,yBAAAA;;;;kBAIGC,YAAYF;;;UAGfG,yBAAAA;;;;;;UAMAC,iBAAAA;SACN9D,kBAAkBE,yBAAyBF;;;UAGrC+D,iBAAAA;SACN/D,kBAAkBE,yBAAyBF;;gBAEpCe;;UAEDiD,gBAAAA;UACLT;WACCO;;UAEIG,gBAAAA;UACLR;WACCM;;UAEIG,oBAAAA;QACPrE;;WAEGiE;UACDP;eACKY;;UAEAC,oBAAAA;QACP9D;;WAEGyD;UACDN;eACKU;;UAEAA,WAAAA;;;;;;UAMAE,YAAAA;;;;UAIAC,kBAAAA;;;;UAIAC,kBAAAA;;;;;;;UAOAC,cAAAA;;QAEPzC;;KAEE0C,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/utils/areMergeConflictActionsEqual.ts
|
|
2
2
|
function areMergeConflictActionsEqual(a, b) {
|
|
3
|
-
return a.
|
|
3
|
+
return a.hunkIndex === b.hunkIndex && a.startContentIndex === b.startContentIndex && a.endContentIndex === b.endContentIndex && a.currentContentIndex === b.currentContentIndex && a.baseContentIndex === b.baseContentIndex && a.incomingContentIndex === b.incomingContentIndex && a.endMarkerContentIndex === b.endMarkerContentIndex && a.conflictIndex === b.conflictIndex && areConflictsEqual(a.conflict, b.conflict);
|
|
4
4
|
}
|
|
5
5
|
function areConflictsEqual(a, b) {
|
|
6
6
|
return a.conflictIndex === b.conflictIndex && a.startLineIndex === b.startLineIndex && a.startLineNumber === b.startLineNumber && a.separatorLineIndex === b.separatorLineIndex && a.separatorLineNumber === b.separatorLineNumber && a.endLineIndex === b.endLineIndex && a.endLineNumber === b.endLineNumber && a.baseMarkerLineIndex === b.baseMarkerLineIndex && a.baseMarkerLineNumber === b.baseMarkerLineNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"areMergeConflictActionsEqual.js","names":[],"sources":["../../src/utils/areMergeConflictActionsEqual.ts"],"sourcesContent":["import type { MergeConflictRegion } from '../types';\nimport type { MergeConflictDiffAction } from './parseMergeConflictDiffFromFile';\n\nexport function areMergeConflictActionsEqual(\n a: MergeConflictDiffAction,\n b: MergeConflictDiffAction\n): boolean {\n return (\n a.
|
|
1
|
+
{"version":3,"file":"areMergeConflictActionsEqual.js","names":[],"sources":["../../src/utils/areMergeConflictActionsEqual.ts"],"sourcesContent":["import type { MergeConflictRegion } from '../types';\nimport type { MergeConflictDiffAction } from './parseMergeConflictDiffFromFile';\n\nexport function areMergeConflictActionsEqual(\n a: MergeConflictDiffAction,\n b: MergeConflictDiffAction\n): boolean {\n return (\n a.hunkIndex === b.hunkIndex &&\n a.startContentIndex === b.startContentIndex &&\n a.endContentIndex === b.endContentIndex &&\n a.currentContentIndex === b.currentContentIndex &&\n a.baseContentIndex === b.baseContentIndex &&\n a.incomingContentIndex === b.incomingContentIndex &&\n a.endMarkerContentIndex === b.endMarkerContentIndex &&\n a.conflictIndex === b.conflictIndex &&\n areConflictsEqual(a.conflict, b.conflict)\n );\n}\n\nfunction areConflictsEqual(a: MergeConflictRegion, b: MergeConflictRegion) {\n return (\n a.conflictIndex === b.conflictIndex &&\n a.startLineIndex === b.startLineIndex &&\n a.startLineNumber === b.startLineNumber &&\n a.separatorLineIndex === b.separatorLineIndex &&\n a.separatorLineNumber === b.separatorLineNumber &&\n a.endLineIndex === b.endLineIndex &&\n a.endLineNumber === b.endLineNumber &&\n a.baseMarkerLineIndex === b.baseMarkerLineIndex &&\n a.baseMarkerLineNumber === b.baseMarkerLineNumber\n );\n}\n"],"mappings":";AAGA,SAAgB,6BACd,GACA,GACS;AACT,QACE,EAAE,cAAc,EAAE,aAClB,EAAE,sBAAsB,EAAE,qBAC1B,EAAE,oBAAoB,EAAE,mBACxB,EAAE,wBAAwB,EAAE,uBAC5B,EAAE,qBAAqB,EAAE,oBACzB,EAAE,yBAAyB,EAAE,wBAC7B,EAAE,0BAA0B,EAAE,yBAC9B,EAAE,kBAAkB,EAAE,iBACtB,kBAAkB,EAAE,UAAU,EAAE,SAAS;;AAI7C,SAAS,kBAAkB,GAAwB,GAAwB;AACzE,QACE,EAAE,kBAAkB,EAAE,iBACtB,EAAE,mBAAmB,EAAE,kBACvB,EAAE,oBAAoB,EAAE,mBACxB,EAAE,uBAAuB,EAAE,sBAC3B,EAAE,wBAAwB,EAAE,uBAC5B,EAAE,iBAAiB,EAAE,gBACrB,EAAE,kBAAkB,EAAE,iBACtB,EAAE,wBAAwB,EAAE,uBAC5B,EAAE,yBAAyB,EAAE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FileDiffMetadata } from "../types.js";
|
|
1
|
+
import { DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, FileDiffMetadata } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/diffAcceptRejectHunk.d.ts
|
|
4
|
-
|
|
4
|
+
type DiffAcceptRejectHunkOptions = DiffAcceptRejectHunkType | DiffAcceptRejectHunkConfig;
|
|
5
|
+
declare function diffAcceptRejectHunk(diff: FileDiffMetadata, hunkIndex: number, options: DiffAcceptRejectHunkOptions): FileDiffMetadata;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { diffAcceptRejectHunk };
|
|
7
8
|
//# sourceMappingURL=diffAcceptRejectHunk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diffAcceptRejectHunk.d.ts","names":["FileDiffMetadata","diffAcceptRejectHunk"],"sources":["../../src/utils/diffAcceptRejectHunk.d.ts"],"sourcesContent":["import type { FileDiffMetadata } from '../types';\nexport declare function diffAcceptRejectHunk(diff: FileDiffMetadata, hunkIndex: number,
|
|
1
|
+
{"version":3,"file":"diffAcceptRejectHunk.d.ts","names":["DiffAcceptRejectHunkConfig","DiffAcceptRejectHunkType","FileDiffMetadata","DiffAcceptRejectHunkOptions","diffAcceptRejectHunk"],"sources":["../../src/utils/diffAcceptRejectHunk.d.ts"],"sourcesContent":["import type { DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, FileDiffMetadata } from '../types';\ntype DiffAcceptRejectHunkOptions = DiffAcceptRejectHunkType | DiffAcceptRejectHunkConfig;\nexport declare function diffAcceptRejectHunk(diff: FileDiffMetadata, hunkIndex: number, options: DiffAcceptRejectHunkOptions): FileDiffMetadata;\nexport {};\n//# sourceMappingURL=diffAcceptRejectHunk.d.ts.map"],"mappings":";;;KACKG,2BAAAA,GAA8BF,2BAA2BD;iBACtCI,oBAAAA,OAA2BF,8CAA8CC,8BAA8BD"}
|
|
@@ -1,95 +1,30 @@
|
|
|
1
|
+
import { normalizeDiffResolution } from "./normalizeDiffResolution.js";
|
|
2
|
+
import { resolveRegion } from "./resolveRegion.js";
|
|
3
|
+
|
|
1
4
|
//#region src/utils/diffAcceptRejectHunk.ts
|
|
2
|
-
function diffAcceptRejectHunk(diff, hunkIndex,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const { additionLines, deletionLines } = diff;
|
|
11
|
-
if (additionLines != null && deletionLines != null) {
|
|
12
|
-
const hunk = diff.hunks[hunkIndex];
|
|
13
|
-
if (hunk == null) {
|
|
14
|
-
console.error({
|
|
15
|
-
diff,
|
|
16
|
-
hunkIndex
|
|
17
|
-
});
|
|
18
|
-
throw new Error(`diffResolveRejectHunk: Invalid hunk index: ${hunkIndex}`);
|
|
19
|
-
}
|
|
20
|
-
if (type === "reject") additionLines.splice(hunk.additionLineIndex, hunk.additionCount, ...deletionLines.slice(hunk.deletionLineIndex, hunk.deletionLineIndex + hunk.deletionCount));
|
|
21
|
-
else deletionLines.splice(hunk.deletionLineIndex, hunk.deletionCount, ...additionLines.slice(hunk.additionLineIndex, hunk.additionLineIndex + hunk.additionCount));
|
|
5
|
+
function diffAcceptRejectHunk(diff, hunkIndex, options) {
|
|
6
|
+
const hunk = diff.hunks[hunkIndex];
|
|
7
|
+
if (hunk == null) {
|
|
8
|
+
console.error({
|
|
9
|
+
hunkIndex,
|
|
10
|
+
diff
|
|
11
|
+
});
|
|
12
|
+
throw new Error("diffAcceptRejectHunk: Invalid hunk index");
|
|
22
13
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
console.error({
|
|
31
|
-
hunk,
|
|
32
|
-
i,
|
|
33
|
-
hunkIndex,
|
|
34
|
-
diff
|
|
35
|
-
});
|
|
36
|
-
throw new Error("diffResolveRejectHunk: iterating through hunks, hunk doesnt exist...");
|
|
37
|
-
}
|
|
38
|
-
const { noEOFCRAdditions, noEOFCRDeletions } = hunk;
|
|
39
|
-
diff.hunks[i] = hunk = { ...hunk };
|
|
40
|
-
if (i === hunkIndex) {
|
|
41
|
-
hunk.noEOFCRDeletions = false;
|
|
42
|
-
hunk.noEOFCRAdditions = false;
|
|
43
|
-
if (type === "accept" && noEOFCRAdditions || type === "reject" && noEOFCRDeletions) {
|
|
44
|
-
hunk.noEOFCRAdditions = true;
|
|
45
|
-
hunk.noEOFCRDeletions = true;
|
|
46
|
-
}
|
|
47
|
-
const newContent = {
|
|
48
|
-
type: "context",
|
|
49
|
-
lines: 0,
|
|
50
|
-
additionLineIndex: hunk.additionLineIndex,
|
|
51
|
-
deletionLineIndex: hunk.deletionLineIndex
|
|
14
|
+
return resolveRegion(diff, {
|
|
15
|
+
resolution: normalizeDiffResolution(options),
|
|
16
|
+
hunkIndex,
|
|
17
|
+
...(() => {
|
|
18
|
+
if (typeof options === "object") return {
|
|
19
|
+
startContentIndex: options.changeIndex,
|
|
20
|
+
endContentIndex: options.changeIndex
|
|
52
21
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
hunk.splitLineCount = lineCount;
|
|
60
|
-
unifiedOffset = lineCount - hunk.unifiedLineCount;
|
|
61
|
-
hunk.unifiedLineCount = lineCount;
|
|
62
|
-
deletionOffset = lineCount - hunk.deletionCount;
|
|
63
|
-
hunk.deletionCount = lineCount;
|
|
64
|
-
hunk.deletionLines = 0;
|
|
65
|
-
additionOffset = lineCount - hunk.additionCount;
|
|
66
|
-
hunk.additionCount = lineCount;
|
|
67
|
-
hunk.additionLines = 0;
|
|
68
|
-
diff.splitLineCount += splitOffset;
|
|
69
|
-
diff.unifiedLineCount += unifiedOffset;
|
|
70
|
-
if (splitOffset === 0 && unifiedOffset === 0 && additionOffset === 0 && deletionOffset === 0) break;
|
|
71
|
-
} else {
|
|
72
|
-
hunk.splitLineStart += splitOffset;
|
|
73
|
-
hunk.unifiedLineStart += unifiedOffset;
|
|
74
|
-
hunk.additionStart += additionOffset;
|
|
75
|
-
hunk.additionLineIndex += additionOffset;
|
|
76
|
-
hunk.deletionLineIndex += deletionOffset;
|
|
77
|
-
hunk.deletionStart += deletionOffset;
|
|
78
|
-
if (deletionOffset !== 0 || additionOffset !== 0) {
|
|
79
|
-
let i$1 = 0;
|
|
80
|
-
while (i$1 < hunk.hunkContent.length) {
|
|
81
|
-
const content = hunk.hunkContent[i$1];
|
|
82
|
-
hunk.hunkContent[i$1] = {
|
|
83
|
-
...content,
|
|
84
|
-
additionLineIndex: content.additionLineIndex + additionOffset,
|
|
85
|
-
deletionLineIndex: content.deletionLineIndex + deletionOffset
|
|
86
|
-
};
|
|
87
|
-
i$1++;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return diff;
|
|
22
|
+
return {
|
|
23
|
+
startContentIndex: 0,
|
|
24
|
+
endContentIndex: Math.max(0, (hunk.hunkContent.length ?? 1) - 1)
|
|
25
|
+
};
|
|
26
|
+
})()
|
|
27
|
+
});
|
|
93
28
|
}
|
|
94
29
|
|
|
95
30
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diffAcceptRejectHunk.js","names":[
|
|
1
|
+
{"version":3,"file":"diffAcceptRejectHunk.js","names":[],"sources":["../../src/utils/diffAcceptRejectHunk.ts"],"sourcesContent":["import type {\n DiffAcceptRejectHunkConfig,\n DiffAcceptRejectHunkType,\n FileDiffMetadata,\n} from '../types';\nimport { normalizeDiffResolution } from './normalizeDiffResolution';\nimport { resolveRegion } from './resolveRegion';\n\ntype DiffAcceptRejectHunkOptions =\n | DiffAcceptRejectHunkType\n | DiffAcceptRejectHunkConfig;\n\nexport function diffAcceptRejectHunk(\n diff: FileDiffMetadata,\n hunkIndex: number,\n options: DiffAcceptRejectHunkOptions\n): FileDiffMetadata {\n const hunk = diff.hunks[hunkIndex];\n if (hunk == null) {\n console.error({ hunkIndex, diff });\n throw new Error('diffAcceptRejectHunk: Invalid hunk index');\n }\n\n return resolveRegion(diff, {\n resolution: normalizeDiffResolution(options),\n hunkIndex,\n ...(() => {\n if (typeof options === 'object') {\n return {\n startContentIndex: options.changeIndex,\n endContentIndex: options.changeIndex,\n };\n }\n return {\n startContentIndex: 0,\n endContentIndex: Math.max(0, (hunk.hunkContent.length ?? 1) - 1),\n };\n })(),\n });\n}\n"],"mappings":";;;;AAYA,SAAgB,qBACd,MACA,WACA,SACkB;CAClB,MAAM,OAAO,KAAK,MAAM;AACxB,KAAI,QAAQ,MAAM;AAChB,UAAQ,MAAM;GAAE;GAAW;GAAM,CAAC;AAClC,QAAM,IAAI,MAAM,2CAA2C;;AAG7D,QAAO,cAAc,MAAM;EACzB,YAAY,wBAAwB,QAAQ;EAC5C;EACA,UAAU;AACR,OAAI,OAAO,YAAY,SACrB,QAAO;IACL,mBAAmB,QAAQ;IAC3B,iBAAiB,QAAQ;IAC1B;AAEH,UAAO;IACL,mBAAmB;IACnB,iBAAiB,KAAK,IAAI,IAAI,KAAK,YAAY,UAAU,KAAK,EAAE;IACjE;MACC;EACL,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { AnnotationSide } from "../types.js";
|
|
2
|
-
|
|
3
1
|
//#region src/utils/getMergeConflictActionSlotName.d.ts
|
|
4
2
|
interface MergeConflictActionSlotInput {
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
hunkIndex: number;
|
|
4
|
+
lineIndex: number;
|
|
7
5
|
conflictIndex: number;
|
|
8
6
|
}
|
|
9
7
|
declare function getMergeConflictActionSlotName({
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
hunkIndex,
|
|
9
|
+
lineIndex,
|
|
12
10
|
conflictIndex
|
|
13
11
|
}: MergeConflictActionSlotInput): string;
|
|
14
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMergeConflictActionSlotName.d.ts","names":["
|
|
1
|
+
{"version":3,"file":"getMergeConflictActionSlotName.d.ts","names":["MergeConflictActionSlotInput","getMergeConflictActionSlotName","hunkIndex","lineIndex","conflictIndex"],"sources":["../../src/utils/getMergeConflictActionSlotName.d.ts"],"sourcesContent":["interface MergeConflictActionSlotInput {\n hunkIndex: number;\n lineIndex: number;\n conflictIndex: number;\n}\nexport declare function getMergeConflictActionSlotName({ hunkIndex, lineIndex, conflictIndex }: MergeConflictActionSlotInput): string;\nexport {};\n//# sourceMappingURL=getMergeConflictActionSlotName.d.ts.map"],"mappings":";UAAUA,4BAAAA;EAAAA,SAAAA,EAAAA,MAAAA;EAKcC,SAAAA,EAAAA,MAAAA;EAAiCC,aAAAA,EAAAA,MAAAA;;AAAsBE,iBAAvDH,8BAAAA,CAAuDG;EAAAA,SAAAA;EAAAA,SAAAA;EAAAA;AAAAA,CAAAA,EAAiBJ,4BAAjBI,CAAAA,EAAAA,MAAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/utils/getMergeConflictActionSlotName.ts
|
|
2
|
-
function getMergeConflictActionSlotName({
|
|
3
|
-
return `merge-conflict-action-${
|
|
2
|
+
function getMergeConflictActionSlotName({ hunkIndex, lineIndex, conflictIndex }) {
|
|
3
|
+
return `merge-conflict-action-${hunkIndex}-${lineIndex}-${conflictIndex}`;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMergeConflictActionSlotName.js","names":[],"sources":["../../src/utils/getMergeConflictActionSlotName.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"getMergeConflictActionSlotName.js","names":[],"sources":["../../src/utils/getMergeConflictActionSlotName.ts"],"sourcesContent":["interface MergeConflictActionSlotInput {\n hunkIndex: number;\n lineIndex: number;\n conflictIndex: number;\n}\n\nexport function getMergeConflictActionSlotName({\n hunkIndex,\n lineIndex,\n conflictIndex,\n}: MergeConflictActionSlotInput): string {\n return `merge-conflict-action-${hunkIndex}-${lineIndex}-${conflictIndex}`;\n}\n"],"mappings":";AAMA,SAAgB,+BAA+B,EAC7C,WACA,WACA,iBACuC;AACvC,QAAO,yBAAyB,UAAU,GAAG,UAAU,GAAG"}
|
|
@@ -7,9 +7,8 @@ interface MergeConflictParseResult {
|
|
|
7
7
|
regions: MergeConflictRegion[];
|
|
8
8
|
}
|
|
9
9
|
declare function getMergeConflictLineTypes(lines: string[]): MergeConflictLineType[];
|
|
10
|
-
declare function getMergeConflictRegions(lines: string[]): MergeConflictRegion[];
|
|
11
10
|
declare function getMergeConflictParseResult(lines: string[]): MergeConflictParseResult;
|
|
12
11
|
declare function getMergeConflictActionLineNumber(conflict: MergeConflictRegion): number;
|
|
13
12
|
//#endregion
|
|
14
|
-
export { MergeConflictLineType, MergeConflictParseResult, getMergeConflictActionLineNumber, getMergeConflictLineTypes, getMergeConflictParseResult
|
|
13
|
+
export { MergeConflictLineType, MergeConflictParseResult, getMergeConflictActionLineNumber, getMergeConflictLineTypes, getMergeConflictParseResult };
|
|
15
14
|
//# sourceMappingURL=getMergeConflictLineTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMergeConflictLineTypes.d.ts","names":["MergeConflictRegion","MergeConflictLineType","MergeConflictParseResult","getMergeConflictLineTypes","
|
|
1
|
+
{"version":3,"file":"getMergeConflictLineTypes.d.ts","names":["MergeConflictRegion","MergeConflictLineType","MergeConflictParseResult","getMergeConflictLineTypes","getMergeConflictParseResult","getMergeConflictActionLineNumber"],"sources":["../../src/utils/getMergeConflictLineTypes.d.ts"],"sourcesContent":["import type { MergeConflictRegion } from '../types';\nexport type MergeConflictLineType = 'none' | 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end' | 'current' | 'base' | 'incoming';\nexport interface MergeConflictParseResult {\n lineTypes: MergeConflictLineType[];\n regions: MergeConflictRegion[];\n}\nexport declare function getMergeConflictLineTypes(lines: string[]): MergeConflictLineType[];\nexport declare function getMergeConflictParseResult(lines: string[]): MergeConflictParseResult;\nexport declare function getMergeConflictActionLineNumber(conflict: MergeConflictRegion): number;\n//# sourceMappingURL=getMergeConflictLineTypes.d.ts.map"],"mappings":";;;KACYC,qBAAAA;UACKC,wBAAAA;EADLD,SAAAA,EAEGA,qBAFkB,EAAA;EAChBC,OAAAA,EAEJF,mBAF4B,EAAA;AAIzC;AACwBI,iBADAD,yBAAAA,CAC8CD,KAAAA,EAAAA,MAAAA,EAAAA,CAAAA,EADFD,qBAC0B,EAAA;AACtEI,iBADAD,2BAAAA,CAC2CJ,KAAAA,EAAAA,MAAAA,EAAAA,CAAAA,EADGE,wBACgB;iBAA9DG,gCAAAA,WAA2CL"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
+
import { MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX } from "../constants.js";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/getMergeConflictLineTypes.ts
|
|
2
|
-
const START_MARKER = /^<{7,}(?:\s.*)?$/;
|
|
3
|
-
const BASE_MARKER = /^\|{7,}(?:\s.*)?$/;
|
|
4
|
-
const SEPARATOR_MARKER = /^={7,}(?:\s.*)?$/;
|
|
5
|
-
const END_MARKER = /^>{7,}(?:\s.*)?$/;
|
|
6
4
|
function trimLineEnding(line) {
|
|
7
5
|
return line.replace(/(?:\r\n|\n|\r)$/, "");
|
|
8
6
|
}
|
|
9
7
|
function getMergeConflictLineTypes(lines) {
|
|
10
8
|
return getMergeConflictParseResult(lines).lineTypes;
|
|
11
9
|
}
|
|
12
|
-
function getMergeConflictRegions(lines) {
|
|
13
|
-
return getMergeConflictParseResult(lines).regions;
|
|
14
|
-
}
|
|
15
10
|
function getMergeConflictParseResult(lines) {
|
|
16
11
|
return parseMergeConflicts(lines);
|
|
17
12
|
}
|
|
@@ -24,7 +19,7 @@ function parseMergeConflicts(lines) {
|
|
|
24
19
|
const regions = [];
|
|
25
20
|
for (let index = 0; index < lines.length; index++) {
|
|
26
21
|
const line = trimLineEnding(lines[index]);
|
|
27
|
-
if (
|
|
22
|
+
if (MERGE_CONFLICT_START_MARKER_REGEX.test(line)) {
|
|
28
23
|
stack.push({
|
|
29
24
|
stage: "current",
|
|
30
25
|
startLineIndex: index
|
|
@@ -37,19 +32,19 @@ function parseMergeConflicts(lines) {
|
|
|
37
32
|
lineTypes[index] = "none";
|
|
38
33
|
continue;
|
|
39
34
|
}
|
|
40
|
-
if (
|
|
35
|
+
if (MERGE_CONFLICT_BASE_MARKER_REGEX.test(line)) {
|
|
41
36
|
frame.stage = "base";
|
|
42
37
|
frame.baseMarkerLineIndex = index;
|
|
43
38
|
lineTypes[index] = "marker-base";
|
|
44
39
|
continue;
|
|
45
40
|
}
|
|
46
|
-
if (
|
|
41
|
+
if (MERGE_CONFLICT_SEPARATOR_MARKER_REGEX.test(line)) {
|
|
47
42
|
frame.stage = "incoming";
|
|
48
43
|
frame.separatorLineIndex = index;
|
|
49
44
|
lineTypes[index] = "marker-separator";
|
|
50
45
|
continue;
|
|
51
46
|
}
|
|
52
|
-
if (
|
|
47
|
+
if (MERGE_CONFLICT_END_MARKER_REGEX.test(line)) {
|
|
53
48
|
const completedFrame = stack.pop();
|
|
54
49
|
lineTypes[index] = "marker-end";
|
|
55
50
|
if (completedFrame?.separatorLineIndex != null) {
|
|
@@ -77,5 +72,5 @@ function parseMergeConflicts(lines) {
|
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
//#endregion
|
|
80
|
-
export { getMergeConflictActionLineNumber, getMergeConflictLineTypes, getMergeConflictParseResult
|
|
75
|
+
export { getMergeConflictActionLineNumber, getMergeConflictLineTypes, getMergeConflictParseResult };
|
|
81
76
|
//# sourceMappingURL=getMergeConflictLineTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMergeConflictLineTypes.js","names":["stack: MergeConflictFrame[]","regions: MergeConflictRegion[]"],"sources":["../../src/utils/getMergeConflictLineTypes.ts"],"sourcesContent":["import type { MergeConflictRegion } from '../types';\n\nexport type MergeConflictLineType =\n | 'none'\n | 'marker-start'\n | 'marker-base'\n | 'marker-separator'\n | 'marker-end'\n | 'current'\n | 'base'\n | 'incoming';\n\ntype MergeConflictStage = 'current' | 'base' | 'incoming';\n\ninterface MergeConflictFrame {\n stage: MergeConflictStage;\n startLineIndex: number;\n baseMarkerLineIndex?: number;\n separatorLineIndex?: number;\n}\n\nexport interface MergeConflictParseResult {\n lineTypes: MergeConflictLineType[];\n regions: MergeConflictRegion[];\n}\n\
|
|
1
|
+
{"version":3,"file":"getMergeConflictLineTypes.js","names":["stack: MergeConflictFrame[]","regions: MergeConflictRegion[]"],"sources":["../../src/utils/getMergeConflictLineTypes.ts"],"sourcesContent":["import {\n MERGE_CONFLICT_BASE_MARKER_REGEX,\n MERGE_CONFLICT_END_MARKER_REGEX,\n MERGE_CONFLICT_SEPARATOR_MARKER_REGEX,\n MERGE_CONFLICT_START_MARKER_REGEX,\n} from '../constants';\nimport type { MergeConflictRegion } from '../types';\n\nexport type MergeConflictLineType =\n | 'none'\n | 'marker-start'\n | 'marker-base'\n | 'marker-separator'\n | 'marker-end'\n | 'current'\n | 'base'\n | 'incoming';\n\ntype MergeConflictStage = 'current' | 'base' | 'incoming';\n\ninterface MergeConflictFrame {\n stage: MergeConflictStage;\n startLineIndex: number;\n baseMarkerLineIndex?: number;\n separatorLineIndex?: number;\n}\n\nexport interface MergeConflictParseResult {\n lineTypes: MergeConflictLineType[];\n regions: MergeConflictRegion[];\n}\n\nfunction trimLineEnding(line: string): string {\n return line.replace(/(?:\\r\\n|\\n|\\r)$/, '');\n}\n\nexport function getMergeConflictLineTypes(\n lines: string[]\n): MergeConflictLineType[] {\n return getMergeConflictParseResult(lines).lineTypes;\n}\n\nexport function getMergeConflictParseResult(\n lines: string[]\n): MergeConflictParseResult {\n return parseMergeConflicts(lines);\n}\n\nexport function getMergeConflictActionLineNumber(\n conflict: MergeConflictRegion\n): number {\n return Math.max(1, conflict.startLineNumber - 1);\n}\n\nfunction parseMergeConflicts(lines: string[]): MergeConflictParseResult {\n const lineTypes = new Array<MergeConflictLineType>(lines.length);\n const stack: MergeConflictFrame[] = [];\n const regions: MergeConflictRegion[] = [];\n\n for (let index = 0; index < lines.length; index++) {\n const line = trimLineEnding(lines[index]);\n\n if (MERGE_CONFLICT_START_MARKER_REGEX.test(line)) {\n stack.push({ stage: 'current', startLineIndex: index });\n lineTypes[index] = 'marker-start';\n continue;\n }\n\n const frame = stack.at(-1);\n if (frame == null) {\n lineTypes[index] = 'none';\n continue;\n }\n\n if (MERGE_CONFLICT_BASE_MARKER_REGEX.test(line)) {\n frame.stage = 'base';\n frame.baseMarkerLineIndex = index;\n lineTypes[index] = 'marker-base';\n continue;\n }\n\n if (MERGE_CONFLICT_SEPARATOR_MARKER_REGEX.test(line)) {\n frame.stage = 'incoming';\n frame.separatorLineIndex = index;\n lineTypes[index] = 'marker-separator';\n continue;\n }\n\n if (MERGE_CONFLICT_END_MARKER_REGEX.test(line)) {\n const completedFrame = stack.pop();\n lineTypes[index] = 'marker-end';\n if (completedFrame?.separatorLineIndex != null) {\n const conflictIndex = regions.length;\n regions.push({\n conflictIndex,\n startLineIndex: completedFrame.startLineIndex,\n startLineNumber: completedFrame.startLineIndex + 1,\n separatorLineIndex: completedFrame.separatorLineIndex,\n separatorLineNumber: completedFrame.separatorLineIndex + 1,\n endLineIndex: index,\n endLineNumber: index + 1,\n baseMarkerLineIndex: completedFrame.baseMarkerLineIndex,\n baseMarkerLineNumber:\n completedFrame.baseMarkerLineIndex != null\n ? completedFrame.baseMarkerLineIndex + 1\n : undefined,\n });\n }\n continue;\n }\n\n lineTypes[index] = frame.stage;\n }\n\n return { lineTypes, regions };\n}\n"],"mappings":";;;AAgCA,SAAS,eAAe,MAAsB;AAC5C,QAAO,KAAK,QAAQ,mBAAmB,GAAG;;AAG5C,SAAgB,0BACd,OACyB;AACzB,QAAO,4BAA4B,MAAM,CAAC;;AAG5C,SAAgB,4BACd,OAC0B;AAC1B,QAAO,oBAAoB,MAAM;;AAGnC,SAAgB,iCACd,UACQ;AACR,QAAO,KAAK,IAAI,GAAG,SAAS,kBAAkB,EAAE;;AAGlD,SAAS,oBAAoB,OAA2C;CACtE,MAAM,YAAY,IAAI,MAA6B,MAAM,OAAO;CAChE,MAAMA,QAA8B,EAAE;CACtC,MAAMC,UAAiC,EAAE;AAEzC,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,OAAO,eAAe,MAAM,OAAO;AAEzC,MAAI,kCAAkC,KAAK,KAAK,EAAE;AAChD,SAAM,KAAK;IAAE,OAAO;IAAW,gBAAgB;IAAO,CAAC;AACvD,aAAU,SAAS;AACnB;;EAGF,MAAM,QAAQ,MAAM,GAAG,GAAG;AAC1B,MAAI,SAAS,MAAM;AACjB,aAAU,SAAS;AACnB;;AAGF,MAAI,iCAAiC,KAAK,KAAK,EAAE;AAC/C,SAAM,QAAQ;AACd,SAAM,sBAAsB;AAC5B,aAAU,SAAS;AACnB;;AAGF,MAAI,sCAAsC,KAAK,KAAK,EAAE;AACpD,SAAM,QAAQ;AACd,SAAM,qBAAqB;AAC3B,aAAU,SAAS;AACnB;;AAGF,MAAI,gCAAgC,KAAK,KAAK,EAAE;GAC9C,MAAM,iBAAiB,MAAM,KAAK;AAClC,aAAU,SAAS;AACnB,OAAI,gBAAgB,sBAAsB,MAAM;IAC9C,MAAM,gBAAgB,QAAQ;AAC9B,YAAQ,KAAK;KACX;KACA,gBAAgB,eAAe;KAC/B,iBAAiB,eAAe,iBAAiB;KACjD,oBAAoB,eAAe;KACnC,qBAAqB,eAAe,qBAAqB;KACzD,cAAc;KACd,eAAe,QAAQ;KACvB,qBAAqB,eAAe;KACpC,sBACE,eAAe,uBAAuB,OAClC,eAAe,sBAAsB,IACrC;KACP,CAAC;;AAEJ;;AAGF,YAAU,SAAS,MAAM;;AAG3B,QAAO;EAAE;EAAW;EAAS"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConflictResolverTypes, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/normalizeDiffResolution.d.ts
|
|
4
|
+
declare function normalizeDiffResolution(options: DiffAcceptRejectHunkType | ConflictResolverTypes | DiffAcceptRejectHunkConfig): 'deletions' | 'additions' | 'both';
|
|
5
|
+
//#endregion
|
|
6
|
+
export { normalizeDiffResolution };
|
|
7
|
+
//# sourceMappingURL=normalizeDiffResolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeDiffResolution.d.ts","names":["ConflictResolverTypes","DiffAcceptRejectHunkConfig","DiffAcceptRejectHunkType","normalizeDiffResolution"],"sources":["../../src/utils/normalizeDiffResolution.d.ts"],"sourcesContent":["import type { ConflictResolverTypes, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType } from '../types';\nexport declare function normalizeDiffResolution(options: DiffAcceptRejectHunkType | ConflictResolverTypes | DiffAcceptRejectHunkConfig): 'deletions' | 'additions' | 'both';\n//# sourceMappingURL=normalizeDiffResolution.d.ts.map"],"mappings":";;;iBACwBG,uBAAAA,UAAiCD,2BAA2BF,wBAAwBC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/utils/normalizeDiffResolution.ts
|
|
2
|
+
function normalizeDiffResolution(options) {
|
|
3
|
+
const type = (() => {
|
|
4
|
+
return typeof options === "string" ? options : options.type;
|
|
5
|
+
})();
|
|
6
|
+
return type === "accept" || type === "incoming" ? "additions" : type === "reject" || type === "current" ? "deletions" : "both";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { normalizeDiffResolution };
|
|
11
|
+
//# sourceMappingURL=normalizeDiffResolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeDiffResolution.js","names":[],"sources":["../../src/utils/normalizeDiffResolution.ts"],"sourcesContent":["import type {\n ConflictResolverTypes,\n DiffAcceptRejectHunkConfig,\n DiffAcceptRejectHunkType,\n} from '../types';\n\n// Normalize shorthand and config-object inputs into one internal resolution\n// mode so the rest of the helper only handles the three concrete diff states.\nexport function normalizeDiffResolution(\n options:\n | DiffAcceptRejectHunkType\n | ConflictResolverTypes\n | DiffAcceptRejectHunkConfig\n): 'deletions' | 'additions' | 'both' {\n const type = (() => {\n return typeof options === 'string' ? options : options.type;\n })();\n\n return type === 'accept' || type === 'incoming'\n ? 'additions'\n : type === 'reject' || type === 'current'\n ? 'deletions'\n : 'both';\n}\n"],"mappings":";AAQA,SAAgB,wBACd,SAIoC;CACpC,MAAM,cAAc;AAClB,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ;KACrD;AAEJ,QAAO,SAAS,YAAY,SAAS,aACjC,cACA,SAAS,YAAY,SAAS,YAC5B,cACA"}
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { FileContents, FileDiffMetadata, MergeConflictRegion } from "../types.js";
|
|
1
|
+
import { FileContents, FileDiffMetadata, MergeConflictMarkerRow, MergeConflictRegion, ProcessFileConflictData } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/parseMergeConflictDiffFromFile.d.ts
|
|
4
4
|
interface ParseMergeConflictDiffFromFileResult {
|
|
5
5
|
fileDiff: FileDiffMetadata;
|
|
6
6
|
currentFile: FileContents;
|
|
7
7
|
incomingFile: FileContents;
|
|
8
|
-
actions: MergeConflictDiffAction[];
|
|
8
|
+
actions: (MergeConflictDiffAction | undefined)[];
|
|
9
|
+
markerRows: MergeConflictMarkerRow[];
|
|
9
10
|
}
|
|
10
|
-
interface MergeConflictDiffAction {
|
|
11
|
-
actionOriginalLineIndex: number;
|
|
12
|
-
actionOriginalLineNumber: number;
|
|
13
|
-
currentLineNumber: number | undefined;
|
|
14
|
-
incomingLineNumber: number | undefined;
|
|
11
|
+
interface MergeConflictDiffAction extends ProcessFileConflictData {
|
|
15
12
|
conflict: MergeConflictRegion;
|
|
16
13
|
conflictIndex: number;
|
|
14
|
+
markerLines: {
|
|
15
|
+
start: string;
|
|
16
|
+
base?: string;
|
|
17
|
+
separator: string;
|
|
18
|
+
end: string;
|
|
19
|
+
};
|
|
17
20
|
}
|
|
18
21
|
interface GetMergeConflictActionAnchorReturn {
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
hunkIndex: number;
|
|
23
|
+
lineIndex: number;
|
|
21
24
|
}
|
|
22
|
-
declare function getMergeConflictActionAnchor(action: MergeConflictDiffAction): GetMergeConflictActionAnchorReturn | undefined;
|
|
23
|
-
declare function parseMergeConflictDiffFromFile(file: FileContents): ParseMergeConflictDiffFromFileResult;
|
|
25
|
+
declare function getMergeConflictActionAnchor(action: MergeConflictDiffAction, fileDiff: FileDiffMetadata): GetMergeConflictActionAnchorReturn | undefined;
|
|
26
|
+
declare function parseMergeConflictDiffFromFile(file: FileContents, maxContextLines?: number): ParseMergeConflictDiffFromFileResult;
|
|
27
|
+
declare function buildMergeConflictMarkerRows(fileDiff: FileDiffMetadata, actions: (MergeConflictDiffAction | undefined)[]): MergeConflictMarkerRow[];
|
|
24
28
|
//#endregion
|
|
25
|
-
export { MergeConflictDiffAction, ParseMergeConflictDiffFromFileResult, getMergeConflictActionAnchor, parseMergeConflictDiffFromFile };
|
|
29
|
+
export { MergeConflictDiffAction, ParseMergeConflictDiffFromFileResult, buildMergeConflictMarkerRows, getMergeConflictActionAnchor, parseMergeConflictDiffFromFile };
|
|
26
30
|
//# sourceMappingURL=parseMergeConflictDiffFromFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseMergeConflictDiffFromFile.d.ts","names":["FileContents","FileDiffMetadata","MergeConflictRegion","ParseMergeConflictDiffFromFileResult","MergeConflictDiffAction","GetMergeConflictActionAnchorReturn","getMergeConflictActionAnchor","parseMergeConflictDiffFromFile"],"sources":["../../src/utils/parseMergeConflictDiffFromFile.d.ts"],"sourcesContent":["import type { FileContents, FileDiffMetadata, MergeConflictRegion } from '../types';\nexport interface ParseMergeConflictDiffFromFileResult {\n fileDiff: FileDiffMetadata;\n currentFile: FileContents;\n incomingFile: FileContents;\n actions: MergeConflictDiffAction[];\n}\nexport interface MergeConflictDiffAction {\n
|
|
1
|
+
{"version":3,"file":"parseMergeConflictDiffFromFile.d.ts","names":["FileContents","FileDiffMetadata","MergeConflictMarkerRow","MergeConflictRegion","ProcessFileConflictData","ParseMergeConflictDiffFromFileResult","MergeConflictDiffAction","GetMergeConflictActionAnchorReturn","getMergeConflictActionAnchor","parseMergeConflictDiffFromFile","buildMergeConflictMarkerRows"],"sources":["../../src/utils/parseMergeConflictDiffFromFile.d.ts"],"sourcesContent":["import type { FileContents, FileDiffMetadata, MergeConflictMarkerRow, MergeConflictRegion, ProcessFileConflictData } from '../types';\nexport interface ParseMergeConflictDiffFromFileResult {\n fileDiff: FileDiffMetadata;\n currentFile: FileContents;\n incomingFile: FileContents;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\nexport interface MergeConflictDiffAction extends ProcessFileConflictData {\n conflict: MergeConflictRegion;\n conflictIndex: number;\n markerLines: {\n start: string;\n base?: string;\n separator: string;\n end: string;\n };\n}\ninterface GetMergeConflictActionAnchorReturn {\n hunkIndex: number;\n lineIndex: number;\n}\nexport declare function getMergeConflictActionAnchor(action: MergeConflictDiffAction, fileDiff: FileDiffMetadata): GetMergeConflictActionAnchorReturn | undefined;\nexport declare function parseMergeConflictDiffFromFile(file: FileContents, maxContextLines?: number): ParseMergeConflictDiffFromFileResult;\nexport declare function buildMergeConflictMarkerRows(fileDiff: FileDiffMetadata, actions: (MergeConflictDiffAction | undefined)[]): MergeConflictMarkerRow[];\nexport {};\n//# sourceMappingURL=parseMergeConflictDiffFromFile.d.ts.map"],"mappings":";;;UACiBK,oCAAAA;YACHJ;EADGI,WAAAA,EAEAL,YAFAK;EACHJ,YAAAA,EAEID,YAFJC;EACGD,OAAAA,EAAAA,CAEHM,uBAFGN,GAAAA,SAAAA,CAAAA,EAAAA;EACCA,UAAAA,EAEFE,sBAFEF,EAAAA;;AAEFE,UAECI,uBAAAA,SAAgCF,uBAFjCF,CAAAA;EAAsB,QAAA,EAGxBC,mBAHwB;EAErBG,aAAAA,EAAAA,MAAAA;EAUPC,WAAAA,EAAAA;IAIcC,KAAAA,EAAAA,MAAAA;IAAqCF,IAAAA,CAAAA,EAAAA,MAAAA;IAAmCL,SAAAA,EAAAA,MAAAA;IAAmBM,GAAAA,EAAAA,MAAAA;EAAkC,CAAA;AACrJ;AACA,UANUA,kCAAAA,CAM0C;EAAWN,SAAAA,EAAAA,MAAAA;EAA4BK,SAAAA,EAAAA,MAAAA;;AAA+D,iBAFlIE,4BAAAA,CAEkI,MAAA,EAF7FF,uBAE6F,EAAA,QAAA,EAF1DL,gBAE0D,CAAA,EAFvCM,kCAEuC,GAAA,SAAA;iBADlIE,8BAAAA,OAAqCT,yCAAyCK;iBAC9EK,4BAAAA,WAAuCT,4BAA4BK,yCAAyCJ"}
|