@pierre/diffs 1.2.0-beta.5 → 1.2.0-beta.6

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.
Files changed (48) hide show
  1. package/dist/components/CodeView.d.ts +3 -0
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +40 -1
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts.map +1 -1
  6. package/dist/components/FileDiff.d.ts.map +1 -1
  7. package/dist/components/VirtualizedFile.d.ts +1 -0
  8. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  9. package/dist/components/VirtualizedFile.js +19 -6
  10. package/dist/components/VirtualizedFile.js.map +1 -1
  11. package/dist/components/VirtualizedFileDiff.d.ts +6 -0
  12. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  13. package/dist/components/VirtualizedFileDiff.js +75 -35
  14. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  15. package/dist/constants.d.ts.map +1 -1
  16. package/dist/constants.js +0 -1
  17. package/dist/constants.js.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/managers/InteractionManager.d.ts.map +1 -1
  20. package/dist/managers/ResizeManager.d.ts +7 -2
  21. package/dist/managers/ResizeManager.d.ts.map +1 -1
  22. package/dist/managers/ResizeManager.js +52 -16
  23. package/dist/managers/ResizeManager.js.map +1 -1
  24. package/dist/react/CodeView.d.ts +1 -0
  25. package/dist/react/CodeView.d.ts.map +1 -1
  26. package/dist/react/CodeView.js +9 -0
  27. package/dist/react/CodeView.js.map +1 -1
  28. package/dist/react/constants.d.ts.map +1 -1
  29. package/dist/types.d.ts +3 -2
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/utils/computeVirtualFileMetrics.d.ts +11 -0
  32. package/dist/utils/computeVirtualFileMetrics.d.ts.map +1 -0
  33. package/dist/utils/{resolveVirtualFileMetrics.js → computeVirtualFileMetrics.js} +7 -10
  34. package/dist/utils/computeVirtualFileMetrics.js.map +1 -0
  35. package/dist/utils/detachString.d.ts +5 -0
  36. package/dist/utils/detachString.d.ts.map +1 -0
  37. package/dist/utils/detachString.js +19 -0
  38. package/dist/utils/detachString.js.map +1 -0
  39. package/dist/utils/parsePatchFiles.js +163 -56
  40. package/dist/utils/parsePatchFiles.js.map +1 -1
  41. package/dist/worker/worker-portable.js +0 -1
  42. package/dist/worker/worker-portable.js.map +1 -1
  43. package/dist/worker/worker.js +0 -1
  44. package/dist/worker/worker.js.map +1 -1
  45. package/package.json +1 -1
  46. package/dist/utils/resolveVirtualFileMetrics.d.ts +0 -10
  47. package/dist/utils/resolveVirtualFileMetrics.d.ts.map +0 -1
  48. package/dist/utils/resolveVirtualFileMetrics.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["CreatePatchOptionsNonabortable","ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","CodeViewScrollBehavior","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","DiffIndicators","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","FileHeaderRenderMode","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","SelectedLineRange","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","CodeViewFileItem","CodeViewDiffItem","CodeViewItem","CodeViewPositionScrollTarget","CodeViewLineScrollTarget","CodeViewRangeScrollTarget","NumericScrollLineAnchor","CodeViewItemScrollTarget","CodeViewScrollTarget","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","TokenEventBase","DiffTokenEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","CodeViewLayout","SmoothScrollSettings","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData","AppliedThemeStyleCache","StickySpecs"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { CreatePatchOptionsNonabortable } from 'diff';\nimport type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\nexport type { CreatePatchOptionsNonabortable };\nexport type CodeViewScrollBehavior = 'instant' | 'smooth' | 'smooth-auto';\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 type DiffIndicators = 'classic' | 'bars' | '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 stickyHeader?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n useTokenTransformer?: boolean;\n tokenizeMaxLineLength?: number;\n tokenizeMaxLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: DiffIndicators;\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n /**\n * Options forwarded to the underlying diff algorithm when computing diffs\n * from file contents (oldFile/newFile). Has no effect on pre-parsed patches.\n */\n parseDiffOptions?: CreatePatchOptionsNonabortable;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter' | 'parseDiffOptions'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow'>> {\n type: 'diff' | 'file';\n split: boolean;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport type FileHeaderRenderMode = 'default' | 'custom';\nexport type RenderHeaderMetadataCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderHeaderPrefixCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderFileMetadata = (file: FileContents) => Element | string | number | null | undefined;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\nexport interface SelectedLineRange {\n start: number;\n side?: SelectionSide;\n end: number;\n endSide?: SelectionSide;\n}\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 CodeViewFileItem<T = undefined> = {\n id: string;\n type: 'file';\n file: FileContents;\n annotations?: LineAnnotation<T>[];\n version?: number;\n collapsed?: boolean;\n};\nexport type CodeViewDiffItem<T = undefined> = {\n id: string;\n type: 'diff';\n fileDiff: FileDiffMetadata;\n annotations?: DiffLineAnnotation<T>[];\n version?: number;\n collapsed?: boolean;\n};\nexport type CodeViewItem<T = undefined> = CodeViewFileItem<T> | CodeViewDiffItem<T>;\nexport interface CodeViewPositionScrollTarget {\n type: 'position';\n position: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface CodeViewLineScrollTarget {\n type: 'line';\n id: string;\n lineNumber: number;\n side?: SelectionSide;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface CodeViewRangeScrollTarget {\n type: 'range';\n id: string;\n range: SelectedLineRange;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface NumericScrollLineAnchor {\n lineNumber: number;\n top: number;\n side?: SelectionSide;\n}\nexport interface CodeViewItemScrollTarget {\n type: 'item';\n id: string;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport type CodeViewScrollTarget = CodeViewPositionScrollTarget | CodeViewLineScrollTarget | CodeViewRangeScrollTarget | CodeViewItemScrollTarget;\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 TokenEventBase {\n type: 'token';\n lineNumber: number;\n lineCharStart: number;\n lineCharEnd: number;\n tokenText: string;\n tokenElement: HTMLElement;\n}\nexport interface DiffTokenEventBaseProps extends TokenEventBase {\n side: AnnotationSide;\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 useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n maxLineDiffLength: number;\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 /** Absolute top edge of the active virtual window in scroll-space pixels. */\n top: number;\n /** Absolute bottom edge of the active virtual window in scroll-space pixels. */\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n /** Number of rendered lines per hunk chunk when virtualization batches line rendering. */\n hunkLineCount: number;\n /** Estimated single-line row height used before a line is measured. */\n lineHeight: number;\n /** Height reserved for the file or diff header region. */\n diffHeaderHeight: number;\n /** Height reserved for each collapsed-context separator row. */\n hunkSeparatorHeight: number;\n /** Vertical spacing used around hunks and file-level padding. You should not\n * change this from the default if you aren't applying custom CSS */\n spacing: number;\n /** Optional top padding applied after the file header, or before content\n * when the header is disabled. Defaults to 0 with a header, otherwise\n * defaults to spacing if header is disabled */\n paddingTop?: number;\n /** Optional bottom padding applied after file content, and only if there is\n * code for the diff. Defaults to spacing if none provided */\n paddingBottom?: number;\n}\nexport interface CodeViewLayout {\n /** Top padding applied to the CodeView sticky container offset. */\n paddingTop: number;\n /** Bottom padding added after the final rendered item in CodeView. */\n paddingBottom: number;\n /** Vertical gap between virtualized CodeView items. */\n gap: number;\n}\nexport interface SmoothScrollSettings {\n /**\n * Natural frequency of the critically-damped spring, in rad/ms. 99% settle\n * takes roughly `6.6 / omega`; 0.015 gives ~440ms. Raise for a snappier\n * animation; lower for a longer glide.\n */\n omega: number;\n /**\n * Distance from destination (in CSS pixels) below which the spring is\n * considered settled. Must also clear `velocityEpsilon` before the\n * animation actually stops and snaps to destination.\n */\n positionEpsilon: number;\n /**\n * Velocity magnitude (in CSS pixels per millisecond) below which the\n * spring is considered effectively stationary. Pairs with\n * `positionEpsilon` to gate the settle transition.\n */\n velocityEpsilon: 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}\nexport interface AppliedThemeStyleCache {\n theme: DiffsThemeNames | ThemesType;\n themeStyles: string;\n themeType: ThemeTypes;\n baseThemeType: 'light' | 'dark' | undefined;\n scrollbarGutter: number | undefined;\n}\nexport interface StickySpecs {\n topOffset: number;\n height: number;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;KAIYW,sBAAAA;AAAZ;AAKA;AAgBA;AAEA;AACYK,UAnBKJ,YAAAA,CAmBiCG;EAQtCG;;EAA0DH,IAAAA,EAAAA,MAAAA;EAAvCT;EAAkB,QAAA,EAAA,MAAA;EASrCa;AAKZ;EAYiBG,IAAAA,CAAAA,EA7CNT,kBA6CoB;EAoBdU;EAqBAC,MAAAA,CAAI,EAAA,MAAA;EA0FJH;;;EAiCNG,QAAAA,CAAAA,EAAAA,MAAAA;;AAuCCC,KAhPAX,gBAAAA,GAgPAW,UAA0B,GAAA,YAAA;AAW1BZ,KAzPAE,eAAAA,GAAkBZ,YAyPGD,GAAAA,aAAe,GAAA,cAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACpCyB,KAzPAX,UAAAA,GAAaC,MAyPD,CAAA,MAAA,GAAA,OAAA,EAzP0BF,eAyP1B,CAAA;AACxB;AAIA;AACA;AACA;AACA;;;AAIgBa,KA7PJV,gBAAAA,GAAmBZ,kBA6PfsB,CA7PkCf,kBA6PlCe,EA7PsDb,eA6PtDa,CAAAA;;;AAYhB;;;;;;AAAwD,KAhQ5CT,WAAAA,GAgQ4C,QAAA,GAAA,aAAA,GAAA,gBAAA,GAAA,KAAA,GAAA,SA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E,YAAAA;;;;UAIAC,kBAAAA;;;;;;UAMAC,kBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,cAAAA;;;;;;;;UAQAC,oBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,cAAAA;;QAEPvD;;KAEEwD,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;SACN5F,kBAAkBC;;aAEdY;;;;UAIEgF,WAAAA"}
1
+ {"version":3,"file":"types.d.ts","names":["CreatePatchOptionsNonabortable","ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","CodeViewScrollBehavior","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","DiffIndicators","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","FileHeaderRenderMode","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","SelectedLineRange","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","CodeViewFileItem","CodeViewDiffItem","CodeViewItem","CodeViewPositionScrollTarget","CodeViewLineScrollTarget","CodeViewRangeScrollTarget","NumericScrollLineAnchor","CodeViewItemScrollTarget","CodeViewScrollTarget","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","TokenEventBase","DiffTokenEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","CodeViewLayout","SmoothScrollSettings","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData","AppliedThemeStyleCache","StickySpecs"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { CreatePatchOptionsNonabortable } from 'diff';\nimport type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\nexport type { CreatePatchOptionsNonabortable };\nexport type CodeViewScrollBehavior = 'instant' | 'smooth' | 'smooth-auto';\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 type DiffIndicators = 'classic' | 'bars' | '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 stickyHeader?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n useTokenTransformer?: boolean;\n tokenizeMaxLineLength?: number;\n tokenizeMaxLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: DiffIndicators;\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n /**\n * Options forwarded to the underlying diff algorithm when computing diffs\n * from file contents (oldFile/newFile). Has no effect on pre-parsed patches.\n */\n parseDiffOptions?: CreatePatchOptionsNonabortable;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter' | 'parseDiffOptions'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow'>> {\n type: 'diff' | 'file';\n split: boolean;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport type FileHeaderRenderMode = 'default' | 'custom';\nexport type RenderHeaderMetadataCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderHeaderPrefixCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderFileMetadata = (file: FileContents) => Element | string | number | null | undefined;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\nexport interface SelectedLineRange {\n start: number;\n side?: SelectionSide;\n end: number;\n endSide?: SelectionSide;\n}\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 CodeViewFileItem<T = undefined> = {\n id: string;\n type: 'file';\n file: FileContents;\n annotations?: LineAnnotation<T>[];\n version?: number;\n collapsed?: boolean;\n};\nexport type CodeViewDiffItem<T = undefined> = {\n id: string;\n type: 'diff';\n fileDiff: FileDiffMetadata;\n annotations?: DiffLineAnnotation<T>[];\n version?: number;\n collapsed?: boolean;\n};\nexport type CodeViewItem<T = undefined> = CodeViewFileItem<T> | CodeViewDiffItem<T>;\nexport interface CodeViewPositionScrollTarget {\n type: 'position';\n position: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface CodeViewLineScrollTarget {\n type: 'line';\n id: string;\n lineNumber: number;\n side?: SelectionSide;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface CodeViewRangeScrollTarget {\n type: 'range';\n id: string;\n range: SelectedLineRange;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface NumericScrollLineAnchor {\n lineNumber: number;\n top: number;\n side?: SelectionSide;\n}\nexport interface CodeViewItemScrollTarget {\n type: 'item';\n id: string;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport type CodeViewScrollTarget = CodeViewPositionScrollTarget | CodeViewLineScrollTarget | CodeViewRangeScrollTarget | CodeViewItemScrollTarget;\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 TokenEventBase {\n type: 'token';\n lineNumber: number;\n lineCharStart: number;\n lineCharEnd: number;\n tokenText: string;\n tokenElement: HTMLElement;\n}\nexport interface DiffTokenEventBaseProps extends TokenEventBase {\n side: AnnotationSide;\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 useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n maxLineDiffLength: number;\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 /** Absolute top edge of the active virtual window in scroll-space pixels. */\n top: number;\n /** Absolute bottom edge of the active virtual window in scroll-space pixels. */\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n /** Number of rendered lines per hunk chunk when virtualization batches line rendering. */\n hunkLineCount: number;\n /** Estimated single-line row height used before a line is measured. */\n lineHeight: number;\n /** Height reserved for the file or diff header region. */\n diffHeaderHeight: number;\n /** Height reserved for each collapsed-context separator row. Only set this\n * if you customized the size of hunk separators via unsafeCSS */\n hunkSeparatorHeight?: number;\n /** Vertical spacing used around hunks and file-level padding. You should not\n * change this from the default if you aren't applying custom CSS */\n spacing: number;\n /** Optional top padding applied after the file header, or before content\n * when the header is disabled. Defaults to 0 with a header, otherwise\n * defaults to spacing if header is disabled */\n paddingTop?: number;\n /** Optional bottom padding applied after file content, and only if there is\n * code for the diff. Defaults to spacing if none provided */\n paddingBottom?: number;\n}\nexport interface CodeViewLayout {\n /** Top padding applied to the CodeView sticky container offset. */\n paddingTop: number;\n /** Bottom padding added after the final rendered item in CodeView. */\n paddingBottom: number;\n /** Vertical gap between virtualized CodeView items. */\n gap: number;\n}\nexport interface SmoothScrollSettings {\n /**\n * Natural frequency of the critically-damped spring, in rad/ms. 99% settle\n * takes roughly `6.6 / omega`; 0.015 gives ~440ms. Raise for a snappier\n * animation; lower for a longer glide.\n */\n omega: number;\n /**\n * Distance from destination (in CSS pixels) below which the spring is\n * considered settled. Must also clear `velocityEpsilon` before the\n * animation actually stops and snaps to destination.\n */\n positionEpsilon: number;\n /**\n * Velocity magnitude (in CSS pixels per millisecond) below which the\n * spring is considered effectively stationary. Pairs with\n * `positionEpsilon` to gate the settle transition.\n */\n velocityEpsilon: 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}\nexport interface AppliedThemeStyleCache {\n theme: DiffsThemeNames | ThemesType;\n themeStyles: string;\n themeType: ThemeTypes;\n baseThemeType: 'light' | 'dark' | undefined;\n scrollbarGutter: number | undefined;\n}\nexport interface StickySpecs {\n topOffset: number;\n height: number;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;KAIYW,sBAAAA;AAAZ;AAKA;AAgBA;AAEA;AACYK,UAnBKJ,YAAAA,CAmBiCG;EAQtCG;;EAA0DH,IAAAA,EAAAA,MAAAA;EAAvCT;EAAkB,QAAA,EAAA,MAAA;EASrCa;AAKZ;EAYiBG,IAAAA,CAAAA,EA7CNT,kBA6CoB;EAoBdU;EAqBAC,MAAAA,CAAI,EAAA,MAAA;EA0FJH;;;EAiCNG,QAAAA,CAAAA,EAAAA,MAAAA;;AAuCCC,KAhPAX,gBAAAA,GAgPAW,UAA0B,GAAA,YAAA;AAW1BZ,KAzPAE,eAAAA,GAAkBZ,YAyPGD,GAAAA,aAAe,GAAA,cAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACpCyB,KAzPAX,UAAAA,GAAaC,MAyPD,CAAA,MAAA,GAAA,OAAA,EAzP0BF,eAyP1B,CAAA;AACxB;AAIA;AACA;AACA;AACA;;;AAIgBa,KA7PJV,gBAAAA,GAAmBZ,kBA6PfsB,CA7PkCf,kBA6PlCe,EA7PsDb,eA6PtDa,CAAAA;;;AAYhB;;;;;;AAAwD,KAhQ5CT,WAAAA,GAgQ4C,QAAA,GAAA,aAAA,GAAA,gBAAA,GAAA,KAAA,GAAA,SAAA;AAgBxD;;;;AAAkD,UA3QjCC,WAAAA,CA2QiC;EACtCiB;AACZ;EAA2DJ,aAAAA,CAAAA,EAAAA,MAAAA;EAALM;EAI/BF,K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;;;;;;;;;;;;;;;;;UAoBAC,cAAAA;;QAEPvD;;KAEEwD,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;SACN5F,kBAAkBC;;aAEdY;;;;UAIEgF,WAAAA"}
@@ -0,0 +1,11 @@
1
+ import { HunkSeparators, VirtualFileMetrics } from "../types.js";
2
+
3
+ //#region src/utils/computeVirtualFileMetrics.d.ts
4
+ declare function computeVirtualFileMetrics(metrics?: Partial<VirtualFileMetrics>): VirtualFileMetrics;
5
+ declare function getVirtualFileHeaderRegion(metrics: VirtualFileMetrics, disableFileHeader: boolean): number;
6
+ declare function getVirtualFilePaddingTop(metrics: VirtualFileMetrics, disableFileHeader: boolean): number;
7
+ declare function getVirtualFilePaddingBottom(metrics: VirtualFileMetrics): number;
8
+ declare function getDefaultHunkSeparatorHeight(type: HunkSeparators): number;
9
+ //#endregion
10
+ export { computeVirtualFileMetrics, getDefaultHunkSeparatorHeight, getVirtualFileHeaderRegion, getVirtualFilePaddingBottom, getVirtualFilePaddingTop };
11
+ //# sourceMappingURL=computeVirtualFileMetrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeVirtualFileMetrics.d.ts","names":["HunkSeparators","VirtualFileMetrics","computeVirtualFileMetrics","Partial","getVirtualFileHeaderRegion","getVirtualFilePaddingTop","getVirtualFilePaddingBottom","getDefaultHunkSeparatorHeight"],"sources":["../../src/utils/computeVirtualFileMetrics.d.ts"],"sourcesContent":["import type { HunkSeparators, VirtualFileMetrics } from '../types';\nexport declare function computeVirtualFileMetrics(metrics?: Partial<VirtualFileMetrics>): VirtualFileMetrics;\nexport declare function getVirtualFileHeaderRegion(metrics: VirtualFileMetrics, disableFileHeader: boolean): number;\nexport declare function getVirtualFilePaddingTop(metrics: VirtualFileMetrics, disableFileHeader: boolean): number;\nexport declare function getVirtualFilePaddingBottom(metrics: VirtualFileMetrics): number;\nexport declare function getDefaultHunkSeparatorHeight(type: HunkSeparators): number;\n//# sourceMappingURL=computeVirtualFileMetrics.d.ts.map"],"mappings":";;;iBACwBE,yBAAAA,WAAoCC,QAAQF,sBAAsBA;iBAClEG,0BAAAA,UAAoCH;AADpCC,iBAEAG,wBAAAA,CAFyB,OAAA,EAESJ,kBAFT,EAAA,iBAAA,EAAA,OAAA,CAAA,EAAA,MAAA;AAAmBA,iBAG5CK,2BAAAA,CAH4CL,OAAAA,EAGPA,kBAHOA,CAAAA,EAAAA,MAAAA;AAARE,iBAIpCI,6BAAAA,CAJoCJ,IAAAA,EAIAH,cAJAG,CAAAA,EAAAA,MAAAA"}
@@ -1,13 +1,11 @@
1
1
  import { DEFAULT_VIRTUAL_FILE_METRICS } from "../constants.js";
2
2
 
3
- //#region src/utils/resolveVirtualFileMetrics.ts
4
- function resolveVirtualFileMetrics(hunkSeparators, metricsOverride) {
5
- const metrics = {
3
+ //#region src/utils/computeVirtualFileMetrics.ts
4
+ function computeVirtualFileMetrics(metrics) {
5
+ return {
6
6
  ...DEFAULT_VIRTUAL_FILE_METRICS,
7
- ...metricsOverride
7
+ ...metrics
8
8
  };
9
- metrics.hunkSeparatorHeight = getHunkSeparatorHeight(hunkSeparators, metricsOverride?.hunkSeparatorHeight);
10
- return metrics;
11
9
  }
12
10
  function getVirtualFileHeaderRegion(metrics, disableFileHeader) {
13
11
  const paddingTop = getVirtualFilePaddingTop(metrics, disableFileHeader);
@@ -19,8 +17,7 @@ function getVirtualFilePaddingTop(metrics, disableFileHeader) {
19
17
  function getVirtualFilePaddingBottom(metrics) {
20
18
  return metrics.paddingBottom ?? metrics.spacing;
21
19
  }
22
- function getHunkSeparatorHeight(type, customHeight) {
23
- if (customHeight != null) return customHeight;
20
+ function getDefaultHunkSeparatorHeight(type) {
24
21
  switch (type) {
25
22
  case "simple": return 4;
26
23
  case "metadata":
@@ -31,5 +28,5 @@ function getHunkSeparatorHeight(type, customHeight) {
31
28
  }
32
29
 
33
30
  //#endregion
34
- export { getVirtualFileHeaderRegion, getVirtualFilePaddingBottom, getVirtualFilePaddingTop, resolveVirtualFileMetrics };
35
- //# sourceMappingURL=resolveVirtualFileMetrics.js.map
31
+ export { computeVirtualFileMetrics, getDefaultHunkSeparatorHeight, getVirtualFileHeaderRegion, getVirtualFilePaddingBottom, getVirtualFilePaddingTop };
32
+ //# sourceMappingURL=computeVirtualFileMetrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeVirtualFileMetrics.js","names":[],"sources":["../../src/utils/computeVirtualFileMetrics.ts"],"sourcesContent":["import { DEFAULT_VIRTUAL_FILE_METRICS } from '../constants';\nimport type { HunkSeparators, VirtualFileMetrics } from '../types';\n\nexport function computeVirtualFileMetrics(\n metrics?: Partial<VirtualFileMetrics>\n): VirtualFileMetrics {\n return {\n ...DEFAULT_VIRTUAL_FILE_METRICS,\n ...metrics,\n };\n}\n\nexport function getVirtualFileHeaderRegion(\n metrics: VirtualFileMetrics,\n disableFileHeader: boolean\n): number {\n const paddingTop = getVirtualFilePaddingTop(metrics, disableFileHeader);\n return disableFileHeader ? paddingTop : metrics.diffHeaderHeight + paddingTop;\n}\n\nexport function getVirtualFilePaddingTop(\n metrics: VirtualFileMetrics,\n disableFileHeader: boolean\n): number {\n return metrics.paddingTop ?? (disableFileHeader ? metrics.spacing : 0);\n}\n\nexport function getVirtualFilePaddingBottom(\n metrics: VirtualFileMetrics\n): number {\n return metrics.paddingBottom ?? metrics.spacing;\n}\n\nexport function getDefaultHunkSeparatorHeight(type: HunkSeparators): number {\n switch (type) {\n case 'simple':\n return 4;\n case 'metadata':\n case 'line-info':\n case 'line-info-basic':\n case 'custom':\n return 32;\n }\n}\n"],"mappings":";;;AAGA,SAAgB,0BACd,SACoB;AACpB,QAAO;EACL,GAAG;EACH,GAAG;EACJ;;AAGH,SAAgB,2BACd,SACA,mBACQ;CACR,MAAM,aAAa,yBAAyB,SAAS,kBAAkB;AACvE,QAAO,oBAAoB,aAAa,QAAQ,mBAAmB;;AAGrE,SAAgB,yBACd,SACA,mBACQ;AACR,QAAO,QAAQ,eAAe,oBAAoB,QAAQ,UAAU;;AAGtE,SAAgB,4BACd,SACQ;AACR,QAAO,QAAQ,iBAAiB,QAAQ;;AAG1C,SAAgB,8BAA8B,MAA8B;AAC1E,SAAQ,MAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,SACH,QAAO"}
@@ -0,0 +1,5 @@
1
+ //#region src/utils/detachString.d.ts
2
+ declare function detachString(value: string): string;
3
+ //#endregion
4
+ export { detachString };
5
+ //# sourceMappingURL=detachString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachString.d.ts","names":["detachString"],"sources":["../../src/utils/detachString.d.ts"],"sourcesContent":["export declare function detachString(value: string): string;\n//# sourceMappingURL=detachString.d.ts.map"],"mappings":";iBAAwBA,YAAAA"}
@@ -0,0 +1,19 @@
1
+ //#region src/utils/detachString.ts
2
+ const stringDetachEncoder = new TextEncoder();
3
+ const stringDetachDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
4
+ function detachString(value) {
5
+ if (value.length === 0) return value;
6
+ if (!hasSurrogateCodeUnit(value)) return stringDetachDecoder.decode(stringDetachEncoder.encode(value));
7
+ return JSON.parse(JSON.stringify(value));
8
+ }
9
+ function hasSurrogateCodeUnit(value) {
10
+ for (let index = 0; index < value.length; index++) {
11
+ const code = value.charCodeAt(index);
12
+ if (code >= 55296 && code <= 57343) return true;
13
+ }
14
+ return false;
15
+ }
16
+
17
+ //#endregion
18
+ export { detachString };
19
+ //# sourceMappingURL=detachString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detachString.js","names":[],"sources":["../../src/utils/detachString.ts"],"sourcesContent":["const stringDetachEncoder = new TextEncoder();\nconst stringDetachDecoder = new TextDecoder('utf-8', { ignoreBOM: true });\n\n// Forces a fresh backing string so a retained substring does not keep the\n// original raw patch/file text alive.\nexport function detachString(value: string): string {\n if (value.length === 0) {\n return value;\n }\n\n if (!hasSurrogateCodeUnit(value)) {\n return stringDetachDecoder.decode(stringDetachEncoder.encode(value));\n }\n\n return JSON.parse(JSON.stringify(value)) as string;\n}\n\nfunction hasSurrogateCodeUnit(value: string): boolean {\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index);\n if (code >= 0xd800 && code <= 0xdfff) {\n return true;\n }\n }\n return false;\n}\n"],"mappings":";AAAA,MAAM,sBAAsB,IAAI,aAAa;AAC7C,MAAM,sBAAsB,IAAI,YAAY,SAAS,EAAE,WAAW,MAAM,CAAC;AAIzE,SAAgB,aAAa,OAAuB;AAClD,KAAI,MAAM,WAAW,EACnB,QAAO;AAGT,KAAI,CAAC,qBAAqB,MAAM,CAC9B,QAAO,oBAAoB,OAAO,oBAAoB,OAAO,MAAM,CAAC;AAGtE,QAAO,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC;;AAG1C,SAAS,qBAAqB,OAAwB;AACpD,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,OAAO,MAAM,WAAW,MAAM;AACpC,MAAI,QAAQ,SAAU,QAAQ,MAC5B,QAAO;;AAGX,QAAO"}
@@ -1,21 +1,21 @@
1
- import { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HUNK_HEADER, INDEX_LINE_METADATA, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX } from "../constants.js";
1
+ import { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, GIT_DIFF_FILE_BREAK_REGEX, INDEX_LINE_METADATA, UNIFIED_DIFF_FILE_BREAK_REGEX } from "../constants.js";
2
2
  import { cleanLastNewline } from "./cleanLastNewline.js";
3
- import { parseLineType } from "./parseLineType.js";
3
+ import { detachString } from "./detachString.js";
4
4
 
5
5
  //#region src/utils/parsePatchFiles.ts
6
6
  function processPatch(data, cacheKeyPrefix, throwOnError = false) {
7
- const isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(data);
8
- const rawFiles = data.split(isGitDiff ? GIT_DIFF_FILE_BREAK_REGEX : UNIFIED_DIFF_FILE_BREAK_REGEX);
7
+ const isGitDiff = isGitDiffPatch(data);
8
+ const rawFiles = isGitDiff ? splitAtLinePrefix(data, "diff --git") : data.split(UNIFIED_DIFF_FILE_BREAK_REGEX);
9
9
  let patchMetadata;
10
10
  const files = [];
11
11
  for (const fileOrPatchMetadata of rawFiles) {
12
12
  if (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)) {
13
- if (patchMetadata == null) patchMetadata = fileOrPatchMetadata;
13
+ if (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);
14
14
  else if (throwOnError) throw Error("parsePatchContent: unknown file blob");
15
15
  else console.error("parsePatchContent: unknown file blob:", fileOrPatchMetadata);
16
16
  continue;
17
17
  } else if (!isGitDiff && !UNIFIED_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)) {
18
- if (patchMetadata == null) patchMetadata = fileOrPatchMetadata;
18
+ if (patchMetadata == null) patchMetadata = detachString(fileOrPatchMetadata);
19
19
  else if (throwOnError) throw Error("parsePatchContent: unknown file blob");
20
20
  else console.error("parsePatchContent: unknown file blob:", fileOrPatchMetadata);
21
21
  continue;
@@ -34,23 +34,23 @@ function processPatch(data, cacheKeyPrefix, throwOnError = false) {
34
34
  }
35
35
  function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(fileDiffString), oldFile, newFile, throwOnError = false } = {}) {
36
36
  let lastHunkEnd = 0;
37
- const hunks = fileDiffString.split(FILE_CONTEXT_BLOB);
37
+ const hunks = splitAtLinePrefix(fileDiffString, "@@ ");
38
38
  let currentFile;
39
39
  const isPartial = oldFile == null || newFile == null;
40
40
  let deletionLineIndex = 0;
41
41
  let additionLineIndex = 0;
42
42
  for (const hunk of hunks) {
43
- const lines = hunk.split(SPLIT_WITH_NEWLINES);
44
- const firstLine = lines.shift();
43
+ const lines = splitWithNewlines(hunk);
44
+ const firstLine = lines[0];
45
45
  if (firstLine == null) {
46
46
  if (throwOnError) throw Error("parsePatchContent: invalid hunk");
47
47
  else console.error("parsePatchContent: invalid hunk", hunk);
48
48
  continue;
49
49
  }
50
- const fileHeaderMatch = firstLine.match(HUNK_HEADER);
50
+ const fileHeader = parseHunkHeader(firstLine);
51
51
  let additionLines = 0;
52
52
  let deletionLines = 0;
53
- if (fileHeaderMatch == null || currentFile == null) {
53
+ if (fileHeader == null || currentFile == null) {
54
54
  if (currentFile != null) {
55
55
  if (throwOnError) throw Error("parsePatchContent: Invalid hunk");
56
56
  else console.error("parsePatchContent: Invalid hunk", hunk);
@@ -63,46 +63,48 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
63
63
  splitLineCount: 0,
64
64
  unifiedLineCount: 0,
65
65
  isPartial,
66
- additionLines: !isPartial && oldFile != null && newFile != null ? newFile.contents.split(SPLIT_WITH_NEWLINES) : [],
67
- deletionLines: !isPartial && oldFile != null && newFile != null ? oldFile.contents.split(SPLIT_WITH_NEWLINES) : [],
68
- cacheKey
66
+ additionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(newFile.contents) : [],
67
+ deletionLines: !isPartial && oldFile != null && newFile != null ? splitFileContents(oldFile.contents) : [],
68
+ cacheKey: maybeDetachOptionalString(cacheKey)
69
69
  };
70
70
  if (currentFile.additionLines.length === 1 && newFile?.contents === "") currentFile.additionLines.length = 0;
71
71
  if (currentFile.deletionLines.length === 1 && oldFile?.contents === "") currentFile.deletionLines.length = 0;
72
- lines.unshift(firstLine);
73
72
  for (const line of lines) {
74
- const filenameMatch = line.match(isGitDiff ? FILENAME_HEADER_REGEX_GIT : FILENAME_HEADER_REGEX);
75
73
  if (line.startsWith("diff --git")) {
76
74
  const [, , prevName, , name] = line.trim().match(ALTERNATE_FILE_NAMES_GIT) ?? [];
77
- currentFile.name = name.trim();
78
- if (prevName !== name) currentFile.prevName = prevName.trim();
79
- } else if (filenameMatch != null) {
75
+ currentFile.name = detachString(name.trim());
76
+ if (prevName !== name) currentFile.prevName = detachString(prevName.trim());
77
+ continue;
78
+ }
79
+ const filenameMatch = line.startsWith("---") || line.startsWith("+++") ? line.match(isGitDiff ? FILENAME_HEADER_REGEX_GIT : FILENAME_HEADER_REGEX) : null;
80
+ if (filenameMatch != null) {
80
81
  const [, type, fileName] = filenameMatch;
81
82
  if (type === "---" && fileName !== "/dev/null") {
82
- currentFile.prevName = fileName.trim();
83
- currentFile.name = fileName.trim();
84
- } else if (type === "+++" && fileName !== "/dev/null") currentFile.name = fileName.trim();
83
+ const detachedFileName = detachString(fileName.trim());
84
+ currentFile.prevName = detachedFileName;
85
+ currentFile.name = detachedFileName;
86
+ } else if (type === "+++" && fileName !== "/dev/null") currentFile.name = detachString(fileName.trim());
85
87
  } else if (isGitDiff) {
86
- if (line.startsWith("new mode ")) currentFile.mode = line.replace("new mode", "").trim();
87
- if (line.startsWith("old mode ")) currentFile.prevMode = line.replace("old mode", "").trim();
88
+ if (line.startsWith("new mode ")) currentFile.mode = detachString(line.slice(8).trim());
89
+ if (line.startsWith("old mode ")) currentFile.prevMode = detachString(line.slice(8).trim());
88
90
  if (line.startsWith("new file mode")) {
89
91
  currentFile.type = "new";
90
- currentFile.mode = line.replace("new file mode", "").trim();
92
+ currentFile.mode = detachString(line.slice(13).trim());
91
93
  }
92
94
  if (line.startsWith("deleted file mode")) {
93
95
  currentFile.type = "deleted";
94
- currentFile.mode = line.replace("deleted file mode", "").trim();
96
+ currentFile.mode = detachString(line.slice(17).trim());
95
97
  }
96
98
  if (line.startsWith("similarity index")) if (line.startsWith("similarity index 100%")) currentFile.type = "rename-pure";
97
99
  else currentFile.type = "rename-changed";
98
100
  if (line.startsWith("index ")) {
99
101
  const [, prevObjectId, newObjectId, mode] = line.trim().match(INDEX_LINE_METADATA) ?? [];
100
- if (prevObjectId != null) currentFile.prevObjectId = prevObjectId;
101
- if (newObjectId != null) currentFile.newObjectId = newObjectId;
102
- if (mode != null) currentFile.mode = mode;
102
+ if (prevObjectId != null) currentFile.prevObjectId = detachString(prevObjectId);
103
+ if (newObjectId != null) currentFile.newObjectId = detachString(newObjectId);
104
+ if (mode != null) currentFile.mode = detachString(mode);
103
105
  }
104
- if (line.startsWith("rename from ")) currentFile.prevName = line.replace("rename from ", "").trim();
105
- if (line.startsWith("rename to ")) currentFile.name = line.replace("rename to ", "").trim();
106
+ if (line.startsWith("rename from ")) currentFile.prevName = detachString(line.slice(12).trim());
107
+ if (line.startsWith("rename to ")) currentFile.name = detachString(line.slice(10).trim());
106
108
  }
107
109
  }
108
110
  continue;
@@ -110,8 +112,7 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
110
112
  let currentContent;
111
113
  let lastLineType;
112
114
  while (lines.length > 0 && (lines[lines.length - 1] === "\n" || lines[lines.length - 1] === "\r" || lines[lines.length - 1] === "\r\n" || lines[lines.length - 1] === "")) lines.pop();
113
- const additionStart = parseInt(fileHeaderMatch[3]);
114
- const deletionStart = parseInt(fileHeaderMatch[1]);
115
+ const { additionStart, deletionStart } = fileHeader;
115
116
  deletionLineIndex = isPartial ? deletionLineIndex : deletionStart - 1;
116
117
  additionLineIndex = isPartial ? additionLineIndex : additionStart - 1;
117
118
  const hunkData = {
@@ -120,41 +121,34 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
120
121
  splitLineStart: 0,
121
122
  unifiedLineCount: 0,
122
123
  unifiedLineStart: 0,
123
- additionCount: parseInt(fileHeaderMatch[4] ?? "1"),
124
+ additionCount: fileHeader.additionCount,
124
125
  additionStart,
125
126
  additionLines,
126
- deletionCount: parseInt(fileHeaderMatch[2] ?? "1"),
127
+ deletionCount: fileHeader.deletionCount,
127
128
  deletionStart,
128
129
  deletionLines,
129
130
  deletionLineIndex,
130
131
  additionLineIndex,
131
132
  hunkContent: [],
132
- hunkContext: fileHeaderMatch[5],
133
- hunkSpecs: firstLine,
133
+ hunkContext: maybeDetachOptionalString(fileHeader.hunkContext),
134
+ hunkSpecs: detachString(firstLine),
134
135
  noEOFCRAdditions: false,
135
136
  noEOFCRDeletions: false
136
137
  };
137
- if (isNaN(hunkData.additionCount) || isNaN(hunkData.deletionCount) || isNaN(hunkData.additionStart) || isNaN(hunkData.deletionStart)) {
138
- if (throwOnError) throw Error("parsePatchContent: invalid hunk metadata");
139
- else console.error("parsePatchContent: invalid hunk metadata", hunkData);
140
- continue;
141
- }
142
138
  let parsedAdditionLines = 0;
143
139
  let parsedDeletionLines = 0;
144
- for (const rawLine of lines) {
145
- if (isHunkBodyComplete({
146
- additionCount: hunkData.additionCount,
147
- parsedAdditionLines,
148
- deletionCount: hunkData.deletionCount,
149
- parsedDeletionLines
150
- }) && !rawLine.startsWith("\\")) break;
151
- const parsedLine = parseLineType(rawLine);
152
- if (parsedLine == null) {
140
+ for (let lineIndex = 1; lineIndex < lines.length; lineIndex++) {
141
+ const rawLine = lines[lineIndex];
142
+ if (parsedAdditionLines >= hunkData.additionCount && parsedDeletionLines >= hunkData.deletionCount && !rawLine.startsWith("\\")) break;
143
+ const firstChar = rawLine[0];
144
+ if (firstChar !== "+" && firstChar !== "-" && firstChar !== " " && firstChar !== "\\") {
145
+ console.error(`parseLineType: Invalid firstChar: "${firstChar}", full line: "${rawLine}"`);
153
146
  console.error("processFile: invalid rawLine:", rawLine);
154
147
  continue;
155
148
  }
156
- const { type, line } = parsedLine;
149
+ const type = parseRawLineType(firstChar);
157
150
  if (type === "addition") {
151
+ const line = getParsedLineContent(rawLine);
158
152
  if (currentContent == null || currentContent.type !== "change") {
159
153
  currentContent = createContentGroup("change", deletionLineIndex, additionLineIndex);
160
154
  hunkData.hunkContent.push(currentContent);
@@ -166,6 +160,7 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
166
160
  additionLines++;
167
161
  lastLineType = "addition";
168
162
  } else if (type === "deletion") {
163
+ const line = getParsedLineContent(rawLine);
169
164
  if (currentContent == null || currentContent.type !== "change") {
170
165
  currentContent = createContentGroup("change", deletionLineIndex, additionLineIndex);
171
166
  hunkData.hunkContent.push(currentContent);
@@ -177,6 +172,7 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
177
172
  deletionLines++;
178
173
  lastLineType = "deletion";
179
174
  } else if (type === "context") {
175
+ const line = getParsedLineContent(rawLine);
180
176
  if (currentContent == null || currentContent.type !== "context") {
181
177
  currentContent = createContentGroup("context", deletionLineIndex, additionLineIndex);
182
178
  hunkData.hunkContent.push(currentContent);
@@ -242,9 +238,6 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
242
238
  if (currentFile.type !== "rename-pure" && currentFile.type !== "rename-changed") currentFile.prevName = void 0;
243
239
  return currentFile;
244
240
  }
245
- function isHunkBodyComplete({ additionCount, parsedAdditionLines, deletionCount, parsedDeletionLines }) {
246
- return parsedAdditionLines >= additionCount && parsedDeletionLines >= deletionCount;
247
- }
248
241
  /**
249
242
  * Parses a patch file string into an array of parsed patches.
250
243
  *
@@ -255,7 +248,8 @@ function isHunkBodyComplete({ additionCount, parsedAdditionLines, deletionCount,
255
248
  */
256
249
  function parsePatchFiles(data, cacheKeyPrefix, throwOnError = false) {
257
250
  const patches = [];
258
- for (const patch of data.split(COMMIT_METADATA_SPLIT)) try {
251
+ const rawPatches = hasCommitMetadataBoundary(data) ? data.split(COMMIT_METADATA_SPLIT) : [data];
252
+ for (const patch of rawPatches) try {
259
253
  patches.push(processPatch(patch, cacheKeyPrefix != null ? `${cacheKeyPrefix}-${patches.length}` : void 0, throwOnError));
260
254
  } catch (error) {
261
255
  if (throwOnError) throw error;
@@ -263,6 +257,119 @@ function parsePatchFiles(data, cacheKeyPrefix, throwOnError = false) {
263
257
  }
264
258
  return patches;
265
259
  }
260
+ function hasCommitMetadataBoundary(data) {
261
+ return data.startsWith("From ") || data.includes("\nFrom ");
262
+ }
263
+ function splitFileContents(contents) {
264
+ const lines = splitWithNewlines(contents);
265
+ for (let index = 0; index < lines.length; index++) lines[index] = detachString(lines[index]);
266
+ return lines;
267
+ }
268
+ function splitWithNewlines(contents) {
269
+ if (contents.length === 0) return [""];
270
+ const lines = [];
271
+ let startIndex = 0;
272
+ for (;;) {
273
+ const newlineIndex = contents.indexOf("\n", startIndex);
274
+ if (newlineIndex === -1) break;
275
+ lines.push(contents.slice(startIndex, newlineIndex + 1));
276
+ startIndex = newlineIndex + 1;
277
+ }
278
+ if (startIndex < contents.length) lines.push(contents.slice(startIndex));
279
+ return lines;
280
+ }
281
+ function parseHunkHeader(line) {
282
+ if (!line.startsWith("@@ -")) return;
283
+ let index = 4;
284
+ const deletionStartResult = readPositiveInteger(line, index);
285
+ if (deletionStartResult == null) return;
286
+ const deletionStart = deletionStartResult.value;
287
+ index = deletionStartResult.endIndex;
288
+ let deletionCount = 1;
289
+ if (line[index] === ",") {
290
+ const deletionCountResult = readPositiveInteger(line, index + 1);
291
+ if (deletionCountResult == null) return;
292
+ deletionCount = deletionCountResult.value;
293
+ index = deletionCountResult.endIndex;
294
+ }
295
+ if (line[index] !== " " || line[index + 1] !== "+") return;
296
+ index += 2;
297
+ const additionStartResult = readPositiveInteger(line, index);
298
+ if (additionStartResult == null) return;
299
+ const additionStart = additionStartResult.value;
300
+ index = additionStartResult.endIndex;
301
+ let additionCount = 1;
302
+ if (line[index] === ",") {
303
+ const additionCountResult = readPositiveInteger(line, index + 1);
304
+ if (additionCountResult == null) return;
305
+ additionCount = additionCountResult.value;
306
+ index = additionCountResult.endIndex;
307
+ }
308
+ if (line[index] !== " " || line[index + 1] !== "@" || line[index + 2] !== "@") return;
309
+ let hunkContext;
310
+ const contextStartIndex = index + 3;
311
+ if (line[contextStartIndex] === " ") hunkContext = trimLineEnd(line.slice(contextStartIndex + 1));
312
+ return {
313
+ additionCount,
314
+ additionStart,
315
+ deletionCount,
316
+ deletionStart,
317
+ hunkContext
318
+ };
319
+ }
320
+ function readPositiveInteger(value, startIndex) {
321
+ let index = startIndex;
322
+ let parsedValue = 0;
323
+ for (; index < value.length; index++) {
324
+ const digit = value.charCodeAt(index) - 48;
325
+ if (digit < 0 || digit > 9) break;
326
+ parsedValue = parsedValue * 10 + digit;
327
+ }
328
+ if (index === startIndex) return;
329
+ return {
330
+ value: parsedValue,
331
+ endIndex: index
332
+ };
333
+ }
334
+ function trimLineEnd(value) {
335
+ if (value.endsWith("\r\n")) return value.slice(0, -2);
336
+ if (value.endsWith("\n")) return value.slice(0, -1);
337
+ return value;
338
+ }
339
+ function isGitDiffPatch(data) {
340
+ return data.startsWith("diff --git") || data.includes("\ndiff --git");
341
+ }
342
+ function splitAtLinePrefix(contents, prefix) {
343
+ if (contents.length === 0) return [""];
344
+ const newlinePrefix = `\n${prefix}`;
345
+ const firstBoundaryIndex = contents.startsWith(prefix) ? 0 : findLinePrefixIndex(contents, newlinePrefix, 0);
346
+ if (firstBoundaryIndex === -1) return [contents];
347
+ const parts = [];
348
+ if (firstBoundaryIndex > 0) parts.push(contents.slice(0, firstBoundaryIndex));
349
+ let startIndex = firstBoundaryIndex;
350
+ for (;;) {
351
+ const nextBoundaryIndex = findLinePrefixIndex(contents, newlinePrefix, startIndex + 1);
352
+ if (nextBoundaryIndex === -1) break;
353
+ parts.push(contents.slice(startIndex, nextBoundaryIndex));
354
+ startIndex = nextBoundaryIndex;
355
+ }
356
+ parts.push(contents.slice(startIndex));
357
+ return parts;
358
+ }
359
+ function findLinePrefixIndex(contents, newlinePrefix, fromIndex) {
360
+ const index = contents.indexOf(newlinePrefix, fromIndex);
361
+ return index === -1 ? -1 : index + 1;
362
+ }
363
+ function maybeDetachOptionalString(value) {
364
+ return value == null ? value : detachString(value);
365
+ }
366
+ function parseRawLineType(firstChar) {
367
+ return firstChar === " " ? "context" : firstChar === "\\" ? "metadata" : firstChar === "+" ? "addition" : "deletion";
368
+ }
369
+ function getParsedLineContent(rawLine) {
370
+ const processedLine = rawLine.slice(1);
371
+ return detachString(processedLine === "" ? "\n" : processedLine);
372
+ }
266
373
  function createContentGroup(type, deletionLineIndex, additionLineIndex) {
267
374
  if (type === "change") return {
268
375
  type: "change",