@pierre/diffs 1.2.0-beta.2 → 1.2.0-beta.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.
Files changed (81) hide show
  1. package/dist/components/CodeView.d.ts +16 -6
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +129 -27
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +3 -2
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +14 -5
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +3 -2
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +14 -5
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/FileStream.js +6 -3
  14. package/dist/components/FileStream.js.map +1 -1
  15. package/dist/components/VirtualizedFile.d.ts +1 -0
  16. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  17. package/dist/components/VirtualizedFile.js +18 -13
  18. package/dist/components/VirtualizedFile.js.map +1 -1
  19. package/dist/components/VirtualizedFileDiff.d.ts +1 -0
  20. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  21. package/dist/components/VirtualizedFileDiff.js +19 -16
  22. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  23. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
  24. package/dist/components/web-components.js +4 -0
  25. package/dist/components/web-components.js.map +1 -1
  26. package/dist/constants.d.ts +6 -3
  27. package/dist/constants.d.ts.map +1 -1
  28. package/dist/constants.js +11 -2
  29. package/dist/constants.js.map +1 -1
  30. package/dist/index.d.ts +5 -5
  31. package/dist/index.js +5 -5
  32. package/dist/managers/InteractionManager.d.ts +2 -8
  33. package/dist/managers/InteractionManager.d.ts.map +1 -1
  34. package/dist/managers/InteractionManager.js.map +1 -1
  35. package/dist/react/CodeView.d.ts +5 -1
  36. package/dist/react/CodeView.d.ts.map +1 -1
  37. package/dist/react/CodeView.js +75 -16
  38. package/dist/react/CodeView.js.map +1 -1
  39. package/dist/react/index.d.ts +2 -2
  40. package/dist/react/types.d.ts +2 -2
  41. package/dist/react/types.d.ts.map +1 -1
  42. package/dist/react/utils/useFileDiffInstance.d.ts +2 -2
  43. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  44. package/dist/react/utils/useFileDiffInstance.js +1 -1
  45. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  46. package/dist/react/utils/useFileInstance.d.ts +2 -2
  47. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  48. package/dist/react/utils/useFileInstance.js +1 -1
  49. package/dist/react/utils/useFileInstance.js.map +1 -1
  50. package/dist/react/utils/useUnresolvedFileInstance.d.ts +2 -2
  51. package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
  52. package/dist/react/utils/useUnresolvedFileInstance.js +1 -1
  53. package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
  54. package/dist/renderers/FileRenderer.js +1 -1
  55. package/dist/ssr/index.d.ts +2 -2
  56. package/dist/style.js +1 -1
  57. package/dist/style.js.map +1 -1
  58. package/dist/types.d.ts +23 -7
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/utils/areSelectionsEqual.d.ts +1 -1
  61. package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
  62. package/dist/utils/areSelectionsEqual.js.map +1 -1
  63. package/dist/utils/cssWrappers.d.ts +3 -2
  64. package/dist/utils/cssWrappers.d.ts.map +1 -1
  65. package/dist/utils/cssWrappers.js +13 -2
  66. package/dist/utils/cssWrappers.js.map +1 -1
  67. package/dist/utils/getFiletypeFromFileName.js +16 -0
  68. package/dist/utils/getFiletypeFromFileName.js.map +1 -1
  69. package/dist/utils/parsePatchFiles.js +15 -0
  70. package/dist/utils/parsePatchFiles.js.map +1 -1
  71. package/dist/utils/scrollbarGutter.d.ts +6 -0
  72. package/dist/utils/scrollbarGutter.d.ts.map +1 -0
  73. package/dist/utils/scrollbarGutter.js +28 -0
  74. package/dist/utils/scrollbarGutter.js.map +1 -0
  75. package/dist/worker/WorkerPoolManager.js +1 -1
  76. package/dist/worker/WorkerPoolManager.js.map +1 -1
  77. package/dist/worker/worker-portable.js +26 -1
  78. package/dist/worker/worker-portable.js.map +1 -1
  79. package/dist/worker/worker.js +23 -0
  80. package/dist/worker/worker.js.map +1 -1
  81. package/package.json +1 -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","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","FileHeaderRenderMode","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","CodeViewItemVersion","CodeViewFileItem","CodeViewDiffItem","CodeViewItem","CodeViewPositionScrollTarget","CodeViewLineScrollTarget","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","CodeViewMetrics","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 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?: '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 /**\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';\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 CodeViewItemVersion = string | number;\nexport type CodeViewFileItem<T = undefined> = {\n id: string;\n type: 'file';\n file: FileContents;\n annotations?: LineAnnotation<T>[];\n version?: CodeViewItemVersion;\n collapsed?: boolean;\n};\nexport type CodeViewDiffItem<T = undefined> = {\n id: string;\n type: 'diff';\n fileDiff: FileDiffMetadata;\n annotations?: DiffLineAnnotation<T>[];\n version?: CodeViewItemVersion;\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 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 | 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 CodeViewMetrics {\n /** Top padding applied to the viewer's sticky container offset. */\n paddingTop: number;\n /** Bottom padding added after the final rendered item in the viewer. */\n paddingBottom: number;\n /** Vertical gap between virtualized items in the viewer. */\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}\nexport interface StickySpecs {\n topOffset: number;\n height: number;\n}\n//# sourceMappingURL=types.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BAAAA,SAAgCD;QACvC3B;;UAEO6B,uBAAAA;;;eAGEJ;WACJA;;;;eAIIA;WACJA;;;;;UAKEK,iBAAAA;;eAEAL;iBACEA;;;;KAIPM,cAAAA;UACKC,QAAAA;;;;QAIPD;;;;;;;KAOEE,iCAAiC7D,eAAeiC,mBAAmB6B;KACnEC,mBAAAA;UACKC,gBAAAA;QACPhF;;;;UAIOiF,qBAAAA;iBACEjF;iBACAA;;UAEFkF,gBAAAA;QACPD;;;;UAIOE,mBAAAA;;;;UAIAC,yBAAAA;;;;kBAIGC,YAAYF;;;UAGfG,yBAAAA;;;;;;UAMAC,iBAAAA;SACNzE,kBAAkBE,yBAAyBF;;;;UAIrC0E,iBAAAA;SACN1E,kBAAkBE,yBAAyBF;;;gBAGpCe;;;UAGD4D,gBAAAA;UACLT;WACCO;;UAEIG,gBAAAA;UACLR;WACCM;;UAEIG,oBAAAA;QACPhF;;WAEG4E;UACDP;eACKY;;UAEAC,oBAAAA;QACPzE;;WAEGoE;UACDN;eACKU;;UAEAA,WAAAA;;;;;;UAMAE,YAAAA;;;;UAIAC,kBAAAA;;;;;;UAMAC,kBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,eAAAA;;;;;;;;UAQAC,oBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,cAAAA;;QAEPtD;;KAEEuD,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;SACN1F,kBAAkBC;;aAEdY;;;UAGE8E,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","CodeViewItemVersion","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 CodeViewItemVersion = string | number;\nexport type CodeViewFileItem<T = undefined> = {\n id: string;\n type: 'file';\n file: FileContents;\n annotations?: LineAnnotation<T>[];\n version?: CodeViewItemVersion;\n collapsed?: boolean;\n};\nexport type CodeViewDiffItem<T = undefined> = {\n id: string;\n type: 'diff';\n fileDiff: FileDiffMetadata;\n annotations?: DiffLineAnnotation<T>[];\n version?: CodeViewItemVersion;\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;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AAAA;;eAEAL;iBACEA;;;;KAIPM,cAAAA;UACKC,QAAAA;;;;QAIPD;;;;;;;KAOEE,iCAAiChE,eAAemC,mBAAmB8B;KACnEC,mBAAAA;UACKC,gBAAAA;QACPnF;;;;UAIOoF,qBAAAA;iBACEpF;iBACAA;;UAEFqF,gBAAAA;QACPD;;;;UAIOE,mBAAAA;;;;UAIAC,yBAAAA;;;;kBAIGC,YAAYF;;;UAGfG,yBAAAA;;;;;;UAMAC,iBAAAA;SACN5E,kBAAkBE,yBAAyBF;;;;UAIrC6E,iBAAAA;SACN7E,kBAAkBE,yBAAyBF;;;gBAGpCe;;;UAGD+D,gBAAAA;UACLT;WACCO;;UAEIG,gBAAAA;UACLR;WACCM;;UAEIG,oBAAAA;QACPnF;;WAEG+E;UACDP;eACKY;;UAEAC,oBAAAA;QACP5E;;WAEGuE;UACDN;eACKU;;UAEAA,WAAAA;;;;;;UAMAE,YAAAA;;;;UAIAC,kBAAAA;;;;;;UAMAC,kBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,cAAAA;;;;;;;;UAQAC,oBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,cAAAA;;QAEPxD;;KAEEyD,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;SACN7F,kBAAkBC;;aAEdY;;;;UAIEiF,WAAAA"}
@@ -1,4 +1,4 @@
1
- import { SelectedLineRange } from "../managers/InteractionManager.js";
1
+ import { SelectedLineRange } from "../types.js";
2
2
 
3
3
  //#region src/utils/areSelectionsEqual.d.ts
4
4
  declare function areSelectionsEqual(selectionA: SelectedLineRange | undefined, selectionB: SelectedLineRange | undefined): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"areSelectionsEqual.d.ts","names":["SelectedLineRange","areSelectionsEqual"],"sources":["../../src/utils/areSelectionsEqual.d.ts"],"sourcesContent":["import type { SelectedLineRange } from '../managers/InteractionManager';\nexport declare function areSelectionsEqual(selectionA: SelectedLineRange | undefined, selectionB: SelectedLineRange | undefined): boolean;\n//# sourceMappingURL=areSelectionsEqual.d.ts.map"],"mappings":";;;iBACwBC,kBAAAA,aAA+BD,2CAA2CA"}
1
+ {"version":3,"file":"areSelectionsEqual.d.ts","names":["SelectedLineRange","areSelectionsEqual"],"sources":["../../src/utils/areSelectionsEqual.d.ts"],"sourcesContent":["import type { SelectedLineRange } from '../types';\nexport declare function areSelectionsEqual(selectionA: SelectedLineRange | undefined, selectionB: SelectedLineRange | undefined): boolean;\n//# sourceMappingURL=areSelectionsEqual.d.ts.map"],"mappings":";;;iBACwBC,kBAAAA,aAA+BD,2CAA2CA"}
@@ -1 +1 @@
1
- {"version":3,"file":"areSelectionsEqual.js","names":[],"sources":["../../src/utils/areSelectionsEqual.ts"],"sourcesContent":["import type { SelectedLineRange } from '../managers/InteractionManager';\n\nexport function areSelectionsEqual(\n selectionA: SelectedLineRange | undefined,\n selectionB: SelectedLineRange | undefined\n): boolean {\n return (\n selectionA?.start === selectionB?.start &&\n selectionA?.end === selectionB?.end &&\n selectionA?.side === selectionB?.side &&\n selectionA?.endSide === selectionB?.endSide\n );\n}\n"],"mappings":";AAEA,SAAgB,mBACd,YACA,YACS;AACT,QACE,YAAY,UAAU,YAAY,SAClC,YAAY,QAAQ,YAAY,OAChC,YAAY,SAAS,YAAY,QACjC,YAAY,YAAY,YAAY"}
1
+ {"version":3,"file":"areSelectionsEqual.js","names":[],"sources":["../../src/utils/areSelectionsEqual.ts"],"sourcesContent":["import type { SelectedLineRange } from '../types';\n\nexport function areSelectionsEqual(\n selectionA: SelectedLineRange | undefined,\n selectionB: SelectedLineRange | undefined\n): boolean {\n return (\n selectionA?.start === selectionB?.start &&\n selectionA?.end === selectionB?.end &&\n selectionA?.side === selectionB?.side &&\n selectionA?.endSide === selectionB?.endSide\n );\n}\n"],"mappings":";AAEA,SAAgB,mBACd,YACA,YACS;AACT,QACE,YAAY,UAAU,YAAY,SAClC,YAAY,QAAQ,YAAY,OAChC,YAAY,SAAS,YAAY,QACjC,YAAY,YAAY,YAAY"}
@@ -3,7 +3,8 @@ import { ThemeTypes } from "../types.js";
3
3
  //#region src/utils/cssWrappers.d.ts
4
4
  declare function wrapCoreCSS(mainCSS: string): string;
5
5
  declare function wrapUnsafeCSS(unsafeCSS: string): string;
6
- declare function wrapThemeCSS(themeCSS: string, themeType?: ThemeTypes): string;
6
+ declare function wrapThemeCSS(themeCSS: string, themeType?: ThemeTypes, scrollbarGutter?: number): string;
7
+ declare function patchScrollbarGutterSize(themeCSS: string, scrollbarGutter: number | undefined): string;
7
8
  //#endregion
8
- export { wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
9
+ export { patchScrollbarGutterSize, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
9
10
  //# sourceMappingURL=cssWrappers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cssWrappers.d.ts","names":["ThemeTypes","wrapCoreCSS","wrapUnsafeCSS","wrapThemeCSS"],"sources":["../../src/utils/cssWrappers.d.ts"],"sourcesContent":["import type { ThemeTypes } from '../types';\nexport declare function wrapCoreCSS(mainCSS: string): string;\nexport declare function wrapUnsafeCSS(unsafeCSS: string): string;\nexport declare function wrapThemeCSS(themeCSS: string, themeType?: ThemeTypes): string;\n//# sourceMappingURL=cssWrappers.d.ts.map"],"mappings":";;;iBACwBC,WAAAA;iBACAC,aAAAA;AADAD,iBAEAE,YAAAA,CAFW,QAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAEgCH,UAFhC,CAAA,EAAA,MAAA"}
1
+ {"version":3,"file":"cssWrappers.d.ts","names":["ThemeTypes","wrapCoreCSS","wrapUnsafeCSS","wrapThemeCSS","patchScrollbarGutterSize"],"sources":["../../src/utils/cssWrappers.d.ts"],"sourcesContent":["import type { ThemeTypes } from '../types';\nexport declare function wrapCoreCSS(mainCSS: string): string;\nexport declare function wrapUnsafeCSS(unsafeCSS: string): string;\nexport declare function wrapThemeCSS(themeCSS: string, themeType?: ThemeTypes, scrollbarGutter?: number): string;\nexport declare function patchScrollbarGutterSize(themeCSS: string, scrollbarGutter: number | undefined): string;\n//# sourceMappingURL=cssWrappers.d.ts.map"],"mappings":";;;iBACwBC,WAAAA;iBACAC,aAAAA;AADAD,iBAEAE,YAAAA,CAFW,QAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAEgCH,UAFhC,EAAA,eAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AACXE,iBAEAE,wBAAAA,CAFa,QAAA,EAAA,MAAA,EAAA,eAAA,EAAA,MAAA,GAAA,SAAA,CAAA,EAAA,MAAA"}
@@ -1,7 +1,10 @@
1
+ import { DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY } from "../constants.js";
1
2
  import style_default from "../style.js";
3
+ import { createMeasuredScrollbarGutterDeclaration } from "./scrollbarGutter.js";
2
4
 
3
5
  //#region src/utils/cssWrappers.ts
4
6
  const LAYER_ORDER = `@layer base, theme, rendered, unsafe;`;
7
+ const SCROLLBAR_GUTTER_DECLARATION_PATTERN = /* @__PURE__ */ new RegExp(`${escapeRegExp(DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY)}\\s*:\\s*[^;]+;`);
5
8
  function wrapCoreCSS(mainCSS) {
6
9
  return `${LAYER_ORDER}
7
10
  ${style_default}
@@ -15,16 +18,24 @@ function wrapUnsafeCSS(unsafeCSS) {
15
18
  ${unsafeCSS}
16
19
  }`;
17
20
  }
18
- function wrapThemeCSS(themeCSS, themeType = "system") {
21
+ function wrapThemeCSS(themeCSS, themeType = "system", scrollbarGutter) {
19
22
  return `${LAYER_ORDER}
20
23
  @layer rendered {
21
24
  :host {${themeType === "system" ? "" : `
22
25
  color-scheme: ${themeType};`}
26
+ ${createMeasuredScrollbarGutterDeclaration(scrollbarGutter)}
23
27
  ${themeCSS}
24
28
  }
25
29
  }`;
26
30
  }
31
+ function patchScrollbarGutterSize(themeCSS, scrollbarGutter) {
32
+ const scrollbarGutterRule = createMeasuredScrollbarGutterDeclaration(scrollbarGutter);
33
+ return themeCSS.replace(SCROLLBAR_GUTTER_DECLARATION_PATTERN, scrollbarGutterRule);
34
+ }
35
+ function escapeRegExp(value) {
36
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
37
+ }
27
38
 
28
39
  //#endregion
29
- export { wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
40
+ export { patchScrollbarGutterSize, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
30
41
  //# sourceMappingURL=cssWrappers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cssWrappers.js","names":["rawStyles"],"sources":["../../src/utils/cssWrappers.ts"],"sourcesContent":["import rawStyles from '../style.css';\nimport type { ThemeTypes } from '../types';\n\nconst LAYER_ORDER = `@layer base, theme, rendered, unsafe;`;\n\nexport function wrapCoreCSS(mainCSS: string) {\n return `${LAYER_ORDER}\n${rawStyles}\n@layer theme {\n ${mainCSS}\n}`;\n}\n\nexport function wrapUnsafeCSS(unsafeCSS: string) {\n return `${LAYER_ORDER}\n@layer unsafe {\n ${unsafeCSS}\n}`;\n}\n\nexport function wrapThemeCSS(\n themeCSS: string,\n themeType: ThemeTypes = 'system'\n) {\n const colorSchemeRule =\n themeType === 'system'\n ? ''\n : `\n color-scheme: ${themeType};`;\n\n return `${LAYER_ORDER}\n@layer rendered {\n :host {${colorSchemeRule}\n ${themeCSS}\n }\n}`;\n}\n"],"mappings":";;;AAGA,MAAM,cAAc;AAEpB,SAAgB,YAAY,SAAiB;AAC3C,QAAO,GAAG,YAAY;EACtBA,cAAU;;IAER,QAAQ;;;AAIZ,SAAgB,cAAc,WAAmB;AAC/C,QAAO,GAAG,YAAY;;IAEpB,UAAU;;;AAId,SAAgB,aACd,UACA,YAAwB,UACxB;AAOA,QAAO,GAAG,YAAY;;WALpB,cAAc,WACV,KACA;kBACU,UAAU,GAID;IACvB,SAAS"}
1
+ {"version":3,"file":"cssWrappers.js","names":["rawStyles"],"sources":["../../src/utils/cssWrappers.ts"],"sourcesContent":["import { DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY } from '../constants';\nimport rawStyles from '../style.css';\nimport type { ThemeTypes } from '../types';\nimport { createMeasuredScrollbarGutterDeclaration } from './scrollbarGutter';\n\nconst LAYER_ORDER = `@layer base, theme, rendered, unsafe;`;\nconst SCROLLBAR_GUTTER_DECLARATION_PATTERN = new RegExp(\n `${escapeRegExp(DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY)}\\\\s*:\\\\s*[^;]+;`\n);\n\nexport function wrapCoreCSS(mainCSS: string) {\n return `${LAYER_ORDER}\n${rawStyles}\n@layer theme {\n ${mainCSS}\n}`;\n}\n\nexport function wrapUnsafeCSS(unsafeCSS: string) {\n return `${LAYER_ORDER}\n@layer unsafe {\n ${unsafeCSS}\n}`;\n}\n\nexport function wrapThemeCSS(\n themeCSS: string,\n themeType: ThemeTypes = 'system',\n scrollbarGutter?: number\n) {\n const colorSchemeRule =\n themeType === 'system'\n ? ''\n : `\n color-scheme: ${themeType};`;\n const scrollbarGutterVar =\n createMeasuredScrollbarGutterDeclaration(scrollbarGutter);\n\n return `${LAYER_ORDER}\n@layer rendered {\n :host {${colorSchemeRule}\n ${scrollbarGutterVar}\n ${themeCSS}\n }\n}`;\n}\n\nexport function patchScrollbarGutterSize(\n themeCSS: string,\n scrollbarGutter: number | undefined\n): string {\n const scrollbarGutterRule =\n createMeasuredScrollbarGutterDeclaration(scrollbarGutter);\n return themeCSS.replace(\n SCROLLBAR_GUTTER_DECLARATION_PATTERN,\n scrollbarGutterRule\n );\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"mappings":";;;;;AAKA,MAAM,cAAc;AACpB,MAAM,uDAAuC,IAAI,OAC/C,GAAG,aAAa,yCAAyC,CAAC,iBAC3D;AAED,SAAgB,YAAY,SAAiB;AAC3C,QAAO,GAAG,YAAY;EACtBA,cAAU;;IAER,QAAQ;;;AAIZ,SAAgB,cAAc,WAAmB;AAC/C,QAAO,GAAG,YAAY;;IAEpB,UAAU;;;AAId,SAAgB,aACd,UACA,YAAwB,UACxB,iBACA;AASA,QAAO,GAAG,YAAY;;WAPpB,cAAc,WACV,KACA;kBACU,UAAU,GAMD;IAJvB,yCAAyC,gBAAgB,CAKtC;IACnB,SAAS;;;;AAKb,SAAgB,yBACd,UACA,iBACQ;CACR,MAAM,sBACJ,yCAAyC,gBAAgB;AAC3D,QAAO,SAAS,QACd,sCACA,oBACD;;AAGH,SAAS,aAAa,OAAuB;AAC3C,QAAO,MAAM,QAAQ,uBAAuB,OAAO"}
@@ -257,6 +257,22 @@ const EXTENSION_TO_FILE_FORMAT = {
257
257
  rst: "rst",
258
258
  rake: "ruby",
259
259
  gemspec: "ruby",
260
+ jbuilder: "ruby",
261
+ builder: "ruby",
262
+ rabl: "ruby",
263
+ arb: "ruby",
264
+ ru: "ruby",
265
+ podspec: "ruby",
266
+ Gemfile: "ruby",
267
+ Rakefile: "ruby",
268
+ Guardfile: "ruby",
269
+ Capfile: "ruby",
270
+ Berksfile: "ruby",
271
+ Brewfile: "ruby",
272
+ Vagrantfile: "ruby",
273
+ Thorfile: "ruby",
274
+ Appraisals: "ruby",
275
+ Dangerfile: "ruby",
260
276
  sas: "sas",
261
277
  sass: "sass",
262
278
  scala: "scala",
@@ -1 +1 @@
1
- {"version":3,"file":"getFiletypeFromFileName.js","names":["CUSTOM_EXTENSION_TO_FILE_FORMAT: Map<string, SupportedLanguages>","EXTENSION_TO_FILE_FORMAT: ExtensionFormatMap"],"sources":["../../src/utils/getFiletypeFromFileName.ts"],"sourcesContent":["import type { ExtensionFormatMap, SupportedLanguages } from '../types';\n\nconst CUSTOM_EXTENSION_TO_FILE_FORMAT: Map<string, SupportedLanguages> =\n new Map();\n\nlet customExtensionsVersion = 0;\n\nexport const EXTENSION_TO_FILE_FORMAT: ExtensionFormatMap = {\n '1c': '1c',\n abap: 'abap',\n as: 'actionscript-3',\n ada: 'ada',\n adb: 'ada',\n ads: 'ada',\n adoc: 'asciidoc',\n asciidoc: 'asciidoc',\n 'component.html': 'angular-html',\n 'component.ts': 'angular-ts',\n conf: 'nginx',\n htaccess: 'apache',\n cls: 'tex',\n trigger: 'apex',\n apl: 'apl',\n applescript: 'applescript',\n scpt: 'applescript',\n ara: 'ara',\n asm: 'asm',\n s: 'riscv',\n astro: 'astro',\n awk: 'awk',\n bal: 'ballerina',\n sh: 'zsh',\n bash: 'zsh',\n bat: 'cmd',\n cmd: 'cmd',\n be: 'berry',\n beancount: 'beancount',\n bib: 'bibtex',\n bicep: 'bicep',\n 'blade.php': 'blade',\n bsl: 'bsl',\n c: 'c',\n h: 'objective-cpp',\n cs: 'csharp',\n cpp: 'cpp',\n hpp: 'cpp',\n cc: 'cpp',\n cxx: 'cpp',\n hh: 'cpp',\n cdc: 'cdc',\n cairo: 'cairo',\n clar: 'clarity',\n clj: 'clojure',\n cljs: 'clojure',\n cljc: 'clojure',\n soy: 'soy',\n cmake: 'cmake',\n 'CMakeLists.txt': 'cmake',\n cob: 'cobol',\n cbl: 'cobol',\n cobol: 'cobol',\n CODEOWNERS: 'codeowners',\n ql: 'ql',\n coffee: 'coffeescript',\n lisp: 'lisp',\n cl: 'lisp',\n lsp: 'lisp',\n log: 'log',\n v: 'verilog',\n cql: 'cql',\n cr: 'crystal',\n css: 'css',\n csv: 'csv',\n cue: 'cue',\n cypher: 'cypher',\n cyp: 'cypher',\n d: 'd',\n dart: 'dart',\n dax: 'dax',\n desktop: 'desktop',\n diff: 'diff',\n patch: 'diff',\n Dockerfile: 'dockerfile',\n dockerfile: 'dockerfile',\n env: 'dotenv',\n dm: 'dream-maker',\n edge: 'edge',\n el: 'emacs-lisp',\n ex: 'elixir',\n exs: 'elixir',\n elm: 'elm',\n erb: 'erb',\n erl: 'erlang',\n hrl: 'erlang',\n f: 'fortran-fixed-form',\n for: 'fortran-fixed-form',\n fs: 'fsharp',\n fsi: 'fsharp',\n fsx: 'fsharp',\n f03: 'f03',\n f08: 'f08',\n f18: 'f18',\n f77: 'f77',\n f90: 'fortran-free-form',\n f95: 'fortran-free-form',\n fnl: 'fennel',\n fish: 'fish',\n ftl: 'ftl',\n tres: 'gdresource',\n res: 'gdresource',\n gd: 'gdscript',\n gdshader: 'gdshader',\n gs: 'genie',\n feature: 'gherkin',\n COMMIT_EDITMSG: 'git-commit',\n 'git-rebase-todo': 'git-rebase',\n gjs: 'glimmer-js',\n gleam: 'gleam',\n gts: 'glimmer-ts',\n glsl: 'glsl',\n vert: 'glsl',\n frag: 'glsl',\n shader: 'shaderlab',\n gp: 'gnuplot',\n plt: 'gnuplot',\n gnuplot: 'gnuplot',\n go: 'go',\n graphql: 'graphql',\n gql: 'graphql',\n groovy: 'groovy',\n gvy: 'groovy',\n hack: 'hack',\n haml: 'haml',\n hbs: 'handlebars',\n handlebars: 'handlebars',\n hs: 'haskell',\n lhs: 'haskell',\n hx: 'haxe',\n hcl: 'hcl',\n hjson: 'hjson',\n hlsl: 'hlsl',\n fx: 'hlsl',\n html: 'html',\n htm: 'html',\n http: 'http',\n rest: 'http',\n hxml: 'hxml',\n hy: 'hy',\n imba: 'imba',\n ini: 'ini',\n cfg: 'ini',\n jade: 'pug',\n pug: 'pug',\n java: 'java',\n js: 'javascript',\n mjs: 'javascript',\n cjs: 'javascript',\n jinja: 'jinja',\n jinja2: 'jinja',\n j2: 'jinja',\n jison: 'jison',\n jl: 'julia',\n json: 'json',\n json5: 'json5',\n jsonc: 'jsonc',\n jsonl: 'jsonl',\n jsonnet: 'jsonnet',\n libsonnet: 'jsonnet',\n jssm: 'jssm',\n jsx: 'jsx',\n kt: 'kotlin',\n kts: 'kts',\n kql: 'kusto',\n tex: 'tex',\n ltx: 'tex',\n lean: 'lean4',\n less: 'less',\n liquid: 'liquid',\n lit: 'lit',\n ll: 'llvm',\n logo: 'logo',\n lua: 'lua',\n luau: 'luau',\n Makefile: 'makefile',\n mk: 'makefile',\n makefile: 'makefile',\n md: 'markdown',\n markdown: 'markdown',\n marko: 'marko',\n m: 'wolfram',\n mat: 'matlab',\n mdc: 'mdc',\n mdx: 'mdx',\n wiki: 'wikitext',\n mediawiki: 'wikitext',\n mmd: 'mermaid',\n mermaid: 'mermaid',\n mips: 'mipsasm',\n mojo: 'mojo',\n '🔥': 'mojo',\n move: 'move',\n nar: 'narrat',\n nf: 'nextflow',\n nim: 'nim',\n nims: 'nim',\n nimble: 'nim',\n nix: 'nix',\n nu: 'nushell',\n mm: 'objective-cpp',\n ml: 'ocaml',\n mli: 'ocaml',\n mll: 'ocaml',\n mly: 'ocaml',\n pas: 'pascal',\n p: 'pascal',\n pl: 'prolog',\n pm: 'perl',\n t: 'perl',\n raku: 'raku',\n p6: 'raku',\n pl6: 'raku',\n php: 'php',\n phtml: 'php',\n pls: 'plsql',\n sql: 'sql',\n po: 'po',\n polar: 'polar',\n pcss: 'postcss',\n pot: 'pot',\n potx: 'potx',\n pq: 'powerquery',\n pqm: 'powerquery',\n ps1: 'powershell',\n psm1: 'powershell',\n psd1: 'powershell',\n prisma: 'prisma',\n pro: 'prolog',\n P: 'prolog',\n properties: 'properties',\n proto: 'protobuf',\n pp: 'puppet',\n purs: 'purescript',\n py: 'python',\n pyw: 'python',\n pyi: 'python',\n qml: 'qml',\n qmldir: 'qmldir',\n qss: 'qss',\n r: 'r',\n R: 'r',\n rkt: 'racket',\n rktl: 'racket',\n razor: 'razor',\n cshtml: 'razor',\n rb: 'ruby',\n rbw: 'ruby',\n reg: 'reg',\n regex: 'regexp',\n rel: 'rel',\n rs: 'rust',\n rst: 'rst',\n rake: 'ruby',\n gemspec: 'ruby',\n sas: 'sas',\n sass: 'sass',\n scala: 'scala',\n sc: 'scala',\n scm: 'scheme',\n ss: 'scheme',\n sld: 'scheme',\n scss: 'scss',\n sdbl: 'sdbl',\n shadergraph: 'shader',\n st: 'smalltalk',\n sol: 'solidity',\n sparql: 'sparql',\n rq: 'sparql',\n spl: 'splunk',\n config: 'ssh-config',\n do: 'stata',\n ado: 'stata',\n dta: 'stata',\n styl: 'stylus',\n stylus: 'stylus',\n svelte: 'svelte',\n swift: 'swift',\n sv: 'system-verilog',\n svh: 'system-verilog',\n service: 'systemd',\n socket: 'systemd',\n device: 'systemd',\n timer: 'systemd',\n talon: 'talonscript',\n tasl: 'tasl',\n tcl: 'tcl',\n templ: 'templ',\n tf: 'tf',\n tfvars: 'tfvars',\n toml: 'toml',\n ts: 'typescript',\n tsp: 'typespec',\n tsv: 'tsv',\n tsx: 'tsx',\n ttl: 'turtle',\n twig: 'twig',\n typ: 'typst',\n vv: 'v',\n vala: 'vala',\n vapi: 'vala',\n vb: 'vb',\n vbs: 'vb',\n bas: 'vb',\n vh: 'verilog',\n vhd: 'vhdl',\n vhdl: 'vhdl',\n vim: 'vimscript',\n vue: 'vue',\n 'vine.ts': 'vue-vine',\n vy: 'vyper',\n wasm: 'wasm',\n wat: 'wasm',\n wy: '文言',\n wgsl: 'wgsl',\n wit: 'wit',\n wl: 'wolfram',\n nb: 'wolfram',\n xml: 'xml',\n xsl: 'xsl',\n xslt: 'xsl',\n yaml: 'yaml',\n yml: 'yml',\n zs: 'zenscript',\n zig: 'zig',\n zsh: 'zsh',\n sty: 'tex',\n};\n\nexport function getFiletypeFromFileName(fileName: string): SupportedLanguages {\n if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(fileName)) {\n return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(fileName) ?? 'text';\n }\n // Handle special files without extensions first\n if (EXTENSION_TO_FILE_FORMAT[fileName] != null) {\n return EXTENSION_TO_FILE_FORMAT[fileName];\n }\n\n // Try compound extensions first (e.g., .blade.php, .component.ts)\n const compoundMatch = fileName.match(/\\.([^/\\\\]+\\.[^/\\\\]+)$/);\n if (compoundMatch != null) {\n if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(compoundMatch[1])) {\n return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(compoundMatch[1]) ?? 'text';\n }\n if (EXTENSION_TO_FILE_FORMAT[compoundMatch[1]] != null) {\n return EXTENSION_TO_FILE_FORMAT[compoundMatch[1]] ?? 'text';\n }\n }\n\n // Fall back to simple extension\n const simpleMatch = fileName.match(/\\.([^.]+)$/)?.[1] ?? '';\n if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(simpleMatch)) {\n return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(simpleMatch) ?? 'text';\n }\n return EXTENSION_TO_FILE_FORMAT[simpleMatch] ?? 'text';\n}\n\nexport function replaceCustomExtensions(\n version: number,\n map: ExtensionFormatMap\n): boolean {\n if (version <= customExtensionsVersion) {\n return false;\n }\n CUSTOM_EXTENSION_TO_FILE_FORMAT.clear();\n for (const key in map) {\n const lang = map[key];\n if (lang != null) {\n CUSTOM_EXTENSION_TO_FILE_FORMAT.set(key, lang);\n }\n }\n customExtensionsVersion = version;\n return true;\n}\n\nexport function getCustomExtensionsVersion(): number {\n return customExtensionsVersion;\n}\n\nexport function setCustomExtension(\n key: string,\n lang: SupportedLanguages\n): boolean {\n const existing = CUSTOM_EXTENSION_TO_FILE_FORMAT.get(key);\n if (existing === lang) {\n return false;\n }\n if (existing != null) {\n console.warn(\n `setCustomExtension: overriding custom mapping for \"${key}\" from \"${existing}\" to \"${lang}\"`\n );\n }\n CUSTOM_EXTENSION_TO_FILE_FORMAT.set(key, lang);\n customExtensionsVersion++;\n return true;\n}\n\nexport function getCustomExtensionsMap(): ExtensionFormatMap {\n return Object.fromEntries(\n CUSTOM_EXTENSION_TO_FILE_FORMAT\n ) as ExtensionFormatMap;\n}\n"],"mappings":";AAEA,MAAMA,kDACJ,IAAI,KAAK;AAEX,IAAI,0BAA0B;AAE9B,MAAaC,2BAA+C;CAC1D,MAAM;CACN,MAAM;CACN,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,UAAU;CACV,kBAAkB;CAClB,gBAAgB;CAChB,MAAM;CACN,UAAU;CACV,KAAK;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AwB;AAC7D,KAAI,iBAAiB,MAAM;AACzB,MAAI,gCAAgC,IAAI,cAAc,GAAG,CACvD,QAAO,gCAAgC,IAAI,cAAc,GAAG,IAAI;AAElE,MAAI,yBAAyB,cAAc,OAAO,KAChD,QAAO,yBAAyB,cAAc,OAAO;;CAKzD,MAAM,cAAc,SAAS,MAAM,aAAa,GAAG,MAAM;AACzD,KAAI,gCAAgC,IAAI,YAAY,CAClD,QAAO,gCAAgC,IAAI,YAAY,IAAI;AAE7D,QAAO,yBAAyB,gBAAgB;;AAGlD,SAAgB,wBACd,SACA,KACS;AACT,KAAI,WAAW,wBACb,QAAO;AAET,iCAAgC,OAAO;AACvC,MAAK,MAAM,OAAO,KAAK;EACrB,MAAM,OAAO,IAAI;AACjB,MAAI,QAAQ,KACV,iCAAgC,IAAI,KAAK,KAAK;;AAGlD,2BAA0B;AAC1B,QAAO;;AAGT,SAAgB,6BAAqC;AACnD,QAAO;;AAGT,SAAgB,mBACd,KACA,MACS;CACT,MAAM,WAAW,gCAAgC,IAAI,IAAI;AACzD,KAAI,aAAa,KACf,QAAO;AAET,KAAI,YAAY,KACd,SAAQ,KACN,sDAAsD,IAAI,UAAU,SAAS,QAAQ,KAAK,GAC3F;AAEH,iCAAgC,IAAI,KAAK,KAAK;AAC9C;AACA,QAAO;;AAGT,SAAgB,yBAA6C;AAC3D,QAAO,OAAO,YACZ,gCACD"}
1
+ {"version":3,"file":"getFiletypeFromFileName.js","names":["CUSTOM_EXTENSION_TO_FILE_FORMAT: Map<string, SupportedLanguages>","EXTENSION_TO_FILE_FORMAT: ExtensionFormatMap"],"sources":["../../src/utils/getFiletypeFromFileName.ts"],"sourcesContent":["import type { ExtensionFormatMap, SupportedLanguages } from '../types';\n\nconst CUSTOM_EXTENSION_TO_FILE_FORMAT: Map<string, SupportedLanguages> =\n new Map();\n\nlet customExtensionsVersion = 0;\n\nexport const EXTENSION_TO_FILE_FORMAT: ExtensionFormatMap = {\n '1c': '1c',\n abap: 'abap',\n as: 'actionscript-3',\n ada: 'ada',\n adb: 'ada',\n ads: 'ada',\n adoc: 'asciidoc',\n asciidoc: 'asciidoc',\n 'component.html': 'angular-html',\n 'component.ts': 'angular-ts',\n conf: 'nginx',\n htaccess: 'apache',\n cls: 'tex',\n trigger: 'apex',\n apl: 'apl',\n applescript: 'applescript',\n scpt: 'applescript',\n ara: 'ara',\n asm: 'asm',\n s: 'riscv',\n astro: 'astro',\n awk: 'awk',\n bal: 'ballerina',\n sh: 'zsh',\n bash: 'zsh',\n bat: 'cmd',\n cmd: 'cmd',\n be: 'berry',\n beancount: 'beancount',\n bib: 'bibtex',\n bicep: 'bicep',\n 'blade.php': 'blade',\n bsl: 'bsl',\n c: 'c',\n h: 'objective-cpp',\n cs: 'csharp',\n cpp: 'cpp',\n hpp: 'cpp',\n cc: 'cpp',\n cxx: 'cpp',\n hh: 'cpp',\n cdc: 'cdc',\n cairo: 'cairo',\n clar: 'clarity',\n clj: 'clojure',\n cljs: 'clojure',\n cljc: 'clojure',\n soy: 'soy',\n cmake: 'cmake',\n 'CMakeLists.txt': 'cmake',\n cob: 'cobol',\n cbl: 'cobol',\n cobol: 'cobol',\n CODEOWNERS: 'codeowners',\n ql: 'ql',\n coffee: 'coffeescript',\n lisp: 'lisp',\n cl: 'lisp',\n lsp: 'lisp',\n log: 'log',\n v: 'verilog',\n cql: 'cql',\n cr: 'crystal',\n css: 'css',\n csv: 'csv',\n cue: 'cue',\n cypher: 'cypher',\n cyp: 'cypher',\n d: 'd',\n dart: 'dart',\n dax: 'dax',\n desktop: 'desktop',\n diff: 'diff',\n patch: 'diff',\n Dockerfile: 'dockerfile',\n dockerfile: 'dockerfile',\n env: 'dotenv',\n dm: 'dream-maker',\n edge: 'edge',\n el: 'emacs-lisp',\n ex: 'elixir',\n exs: 'elixir',\n elm: 'elm',\n erb: 'erb',\n erl: 'erlang',\n hrl: 'erlang',\n f: 'fortran-fixed-form',\n for: 'fortran-fixed-form',\n fs: 'fsharp',\n fsi: 'fsharp',\n fsx: 'fsharp',\n f03: 'f03',\n f08: 'f08',\n f18: 'f18',\n f77: 'f77',\n f90: 'fortran-free-form',\n f95: 'fortran-free-form',\n fnl: 'fennel',\n fish: 'fish',\n ftl: 'ftl',\n tres: 'gdresource',\n res: 'gdresource',\n gd: 'gdscript',\n gdshader: 'gdshader',\n gs: 'genie',\n feature: 'gherkin',\n COMMIT_EDITMSG: 'git-commit',\n 'git-rebase-todo': 'git-rebase',\n gjs: 'glimmer-js',\n gleam: 'gleam',\n gts: 'glimmer-ts',\n glsl: 'glsl',\n vert: 'glsl',\n frag: 'glsl',\n shader: 'shaderlab',\n gp: 'gnuplot',\n plt: 'gnuplot',\n gnuplot: 'gnuplot',\n go: 'go',\n graphql: 'graphql',\n gql: 'graphql',\n groovy: 'groovy',\n gvy: 'groovy',\n hack: 'hack',\n haml: 'haml',\n hbs: 'handlebars',\n handlebars: 'handlebars',\n hs: 'haskell',\n lhs: 'haskell',\n hx: 'haxe',\n hcl: 'hcl',\n hjson: 'hjson',\n hlsl: 'hlsl',\n fx: 'hlsl',\n html: 'html',\n htm: 'html',\n http: 'http',\n rest: 'http',\n hxml: 'hxml',\n hy: 'hy',\n imba: 'imba',\n ini: 'ini',\n cfg: 'ini',\n jade: 'pug',\n pug: 'pug',\n java: 'java',\n js: 'javascript',\n mjs: 'javascript',\n cjs: 'javascript',\n jinja: 'jinja',\n jinja2: 'jinja',\n j2: 'jinja',\n jison: 'jison',\n jl: 'julia',\n json: 'json',\n json5: 'json5',\n jsonc: 'jsonc',\n jsonl: 'jsonl',\n jsonnet: 'jsonnet',\n libsonnet: 'jsonnet',\n jssm: 'jssm',\n jsx: 'jsx',\n kt: 'kotlin',\n kts: 'kts',\n kql: 'kusto',\n tex: 'tex',\n ltx: 'tex',\n lean: 'lean4',\n less: 'less',\n liquid: 'liquid',\n lit: 'lit',\n ll: 'llvm',\n logo: 'logo',\n lua: 'lua',\n luau: 'luau',\n Makefile: 'makefile',\n mk: 'makefile',\n makefile: 'makefile',\n md: 'markdown',\n markdown: 'markdown',\n marko: 'marko',\n m: 'wolfram',\n mat: 'matlab',\n mdc: 'mdc',\n mdx: 'mdx',\n wiki: 'wikitext',\n mediawiki: 'wikitext',\n mmd: 'mermaid',\n mermaid: 'mermaid',\n mips: 'mipsasm',\n mojo: 'mojo',\n '🔥': 'mojo',\n move: 'move',\n nar: 'narrat',\n nf: 'nextflow',\n nim: 'nim',\n nims: 'nim',\n nimble: 'nim',\n nix: 'nix',\n nu: 'nushell',\n mm: 'objective-cpp',\n ml: 'ocaml',\n mli: 'ocaml',\n mll: 'ocaml',\n mly: 'ocaml',\n pas: 'pascal',\n p: 'pascal',\n pl: 'prolog',\n pm: 'perl',\n t: 'perl',\n raku: 'raku',\n p6: 'raku',\n pl6: 'raku',\n php: 'php',\n phtml: 'php',\n pls: 'plsql',\n sql: 'sql',\n po: 'po',\n polar: 'polar',\n pcss: 'postcss',\n pot: 'pot',\n potx: 'potx',\n pq: 'powerquery',\n pqm: 'powerquery',\n ps1: 'powershell',\n psm1: 'powershell',\n psd1: 'powershell',\n prisma: 'prisma',\n pro: 'prolog',\n P: 'prolog',\n properties: 'properties',\n proto: 'protobuf',\n pp: 'puppet',\n purs: 'purescript',\n py: 'python',\n pyw: 'python',\n pyi: 'python',\n qml: 'qml',\n qmldir: 'qmldir',\n qss: 'qss',\n r: 'r',\n R: 'r',\n rkt: 'racket',\n rktl: 'racket',\n razor: 'razor',\n cshtml: 'razor',\n rb: 'ruby',\n rbw: 'ruby',\n reg: 'reg',\n regex: 'regexp',\n rel: 'rel',\n rs: 'rust',\n rst: 'rst',\n rake: 'ruby',\n gemspec: 'ruby',\n jbuilder: 'ruby',\n builder: 'ruby',\n rabl: 'ruby',\n arb: 'ruby',\n ru: 'ruby',\n podspec: 'ruby',\n Gemfile: 'ruby',\n Rakefile: 'ruby',\n Guardfile: 'ruby',\n Capfile: 'ruby',\n Berksfile: 'ruby',\n Brewfile: 'ruby',\n Vagrantfile: 'ruby',\n Thorfile: 'ruby',\n Appraisals: 'ruby',\n Dangerfile: 'ruby',\n sas: 'sas',\n sass: 'sass',\n scala: 'scala',\n sc: 'scala',\n scm: 'scheme',\n ss: 'scheme',\n sld: 'scheme',\n scss: 'scss',\n sdbl: 'sdbl',\n shadergraph: 'shader',\n st: 'smalltalk',\n sol: 'solidity',\n sparql: 'sparql',\n rq: 'sparql',\n spl: 'splunk',\n config: 'ssh-config',\n do: 'stata',\n ado: 'stata',\n dta: 'stata',\n styl: 'stylus',\n stylus: 'stylus',\n svelte: 'svelte',\n swift: 'swift',\n sv: 'system-verilog',\n svh: 'system-verilog',\n service: 'systemd',\n socket: 'systemd',\n device: 'systemd',\n timer: 'systemd',\n talon: 'talonscript',\n tasl: 'tasl',\n tcl: 'tcl',\n templ: 'templ',\n tf: 'tf',\n tfvars: 'tfvars',\n toml: 'toml',\n ts: 'typescript',\n tsp: 'typespec',\n tsv: 'tsv',\n tsx: 'tsx',\n ttl: 'turtle',\n twig: 'twig',\n typ: 'typst',\n vv: 'v',\n vala: 'vala',\n vapi: 'vala',\n vb: 'vb',\n vbs: 'vb',\n bas: 'vb',\n vh: 'verilog',\n vhd: 'vhdl',\n vhdl: 'vhdl',\n vim: 'vimscript',\n vue: 'vue',\n 'vine.ts': 'vue-vine',\n vy: 'vyper',\n wasm: 'wasm',\n wat: 'wasm',\n wy: '文言',\n wgsl: 'wgsl',\n wit: 'wit',\n wl: 'wolfram',\n nb: 'wolfram',\n xml: 'xml',\n xsl: 'xsl',\n xslt: 'xsl',\n yaml: 'yaml',\n yml: 'yml',\n zs: 'zenscript',\n zig: 'zig',\n zsh: 'zsh',\n sty: 'tex',\n};\n\nexport function getFiletypeFromFileName(fileName: string): SupportedLanguages {\n if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(fileName)) {\n return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(fileName) ?? 'text';\n }\n // Handle special files without extensions first\n if (EXTENSION_TO_FILE_FORMAT[fileName] != null) {\n return EXTENSION_TO_FILE_FORMAT[fileName];\n }\n\n // Try compound extensions first (e.g., .blade.php, .component.ts)\n const compoundMatch = fileName.match(/\\.([^/\\\\]+\\.[^/\\\\]+)$/);\n if (compoundMatch != null) {\n if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(compoundMatch[1])) {\n return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(compoundMatch[1]) ?? 'text';\n }\n if (EXTENSION_TO_FILE_FORMAT[compoundMatch[1]] != null) {\n return EXTENSION_TO_FILE_FORMAT[compoundMatch[1]] ?? 'text';\n }\n }\n\n // Fall back to simple extension\n const simpleMatch = fileName.match(/\\.([^.]+)$/)?.[1] ?? '';\n if (CUSTOM_EXTENSION_TO_FILE_FORMAT.has(simpleMatch)) {\n return CUSTOM_EXTENSION_TO_FILE_FORMAT.get(simpleMatch) ?? 'text';\n }\n return EXTENSION_TO_FILE_FORMAT[simpleMatch] ?? 'text';\n}\n\nexport function replaceCustomExtensions(\n version: number,\n map: ExtensionFormatMap\n): boolean {\n if (version <= customExtensionsVersion) {\n return false;\n }\n CUSTOM_EXTENSION_TO_FILE_FORMAT.clear();\n for (const key in map) {\n const lang = map[key];\n if (lang != null) {\n CUSTOM_EXTENSION_TO_FILE_FORMAT.set(key, lang);\n }\n }\n customExtensionsVersion = version;\n return true;\n}\n\nexport function getCustomExtensionsVersion(): number {\n return customExtensionsVersion;\n}\n\nexport function setCustomExtension(\n key: string,\n lang: SupportedLanguages\n): boolean {\n const existing = CUSTOM_EXTENSION_TO_FILE_FORMAT.get(key);\n if (existing === lang) {\n return false;\n }\n if (existing != null) {\n console.warn(\n `setCustomExtension: overriding custom mapping for \"${key}\" from \"${existing}\" to \"${lang}\"`\n );\n }\n CUSTOM_EXTENSION_TO_FILE_FORMAT.set(key, lang);\n customExtensionsVersion++;\n return true;\n}\n\nexport function getCustomExtensionsMap(): ExtensionFormatMap {\n return Object.fromEntries(\n CUSTOM_EXTENSION_TO_FILE_FORMAT\n ) as ExtensionFormatMap;\n}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SAAgB,yBAA6C;AAC3D,QAAO,OAAO,YACZ,gCACD"}
@@ -139,7 +139,15 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
139
139
  else console.error("parsePatchContent: invalid hunk metadata", hunkData);
140
140
  continue;
141
141
  }
142
+ let parsedAdditionLines = 0;
143
+ let parsedDeletionLines = 0;
142
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;
143
151
  const parsedLine = parseLineType(rawLine);
144
152
  if (parsedLine == null) {
145
153
  console.error("processFile: invalid rawLine:", rawLine);
@@ -152,6 +160,7 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
152
160
  hunkData.hunkContent.push(currentContent);
153
161
  }
154
162
  additionLineIndex++;
163
+ parsedAdditionLines++;
155
164
  if (isPartial) currentFile.additionLines.push(line);
156
165
  currentContent.additions++;
157
166
  additionLines++;
@@ -162,6 +171,7 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
162
171
  hunkData.hunkContent.push(currentContent);
163
172
  }
164
173
  deletionLineIndex++;
174
+ parsedDeletionLines++;
165
175
  if (isPartial) currentFile.deletionLines.push(line);
166
176
  currentContent.deletions++;
167
177
  deletionLines++;
@@ -173,6 +183,8 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
173
183
  }
174
184
  additionLineIndex++;
175
185
  deletionLineIndex++;
186
+ parsedAdditionLines++;
187
+ parsedDeletionLines++;
176
188
  if (isPartial) {
177
189
  currentFile.deletionLines.push(line);
178
190
  currentFile.additionLines.push(line);
@@ -230,6 +242,9 @@ function processFile(fileDiffString, { cacheKey, isGitDiff = GIT_DIFF_FILE_BREAK
230
242
  if (currentFile.type !== "rename-pure" && currentFile.type !== "rename-changed") currentFile.prevName = void 0;
231
243
  return currentFile;
232
244
  }
245
+ function isHunkBodyComplete({ additionCount, parsedAdditionLines, deletionCount, parsedDeletionLines }) {
246
+ return parsedAdditionLines >= additionCount && parsedDeletionLines >= deletionCount;
247
+ }
233
248
  /**
234
249
  * Parses a patch file string into an array of parsed patches.
235
250
  *
@@ -1 +1 @@
1
- {"version":3,"file":"parsePatchFiles.js","names":["patchMetadata: string | undefined","files: FileDiffMetadata[]","currentFile: FileDiffMetadata | undefined","currentContent: ContextContent | ChangeContent | undefined","lastLineType: 'context' | 'addition' | 'deletion' | undefined","hunkData: Hunk","lastHunkEnd","patches: ParsedPatch[]"],"sources":["../../src/utils/parsePatchFiles.ts"],"sourcesContent":["import {\n ALTERNATE_FILE_NAMES_GIT,\n COMMIT_METADATA_SPLIT,\n FILE_CONTEXT_BLOB,\n FILENAME_HEADER_REGEX,\n FILENAME_HEADER_REGEX_GIT,\n GIT_DIFF_FILE_BREAK_REGEX,\n HUNK_HEADER,\n INDEX_LINE_METADATA,\n SPLIT_WITH_NEWLINES,\n UNIFIED_DIFF_FILE_BREAK_REGEX,\n} from '../constants';\nimport type {\n ChangeContent,\n ContextContent,\n FileContents,\n FileDiffMetadata,\n Hunk,\n ParsedPatch,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { parseLineType } from './parseLineType';\n\nexport function processPatch(\n data: string,\n cacheKeyPrefix?: string,\n throwOnError = false\n): ParsedPatch {\n const isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(data);\n const rawFiles = data.split(\n isGitDiff ? GIT_DIFF_FILE_BREAK_REGEX : UNIFIED_DIFF_FILE_BREAK_REGEX\n );\n let patchMetadata: string | undefined;\n const files: FileDiffMetadata[] = [];\n for (const fileOrPatchMetadata of rawFiles) {\n if (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)) {\n if (patchMetadata == null) {\n patchMetadata = fileOrPatchMetadata;\n } else {\n if (throwOnError) {\n throw Error('parsePatchContent: unknown file blob');\n } else {\n console.error(\n 'parsePatchContent: unknown file blob:',\n fileOrPatchMetadata\n );\n }\n }\n // If we get in here, it's most likely the introductory metadata from the\n // patch, or something is fucked with the diff format\n continue;\n } else if (\n !isGitDiff &&\n !UNIFIED_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)\n ) {\n if (patchMetadata == null) {\n patchMetadata = fileOrPatchMetadata;\n } else {\n if (throwOnError) {\n throw Error('parsePatchContent: unknown file blob');\n } else {\n console.error(\n 'parsePatchContent: unknown file blob:',\n fileOrPatchMetadata\n );\n }\n }\n continue;\n }\n const currentFile = processFile(fileOrPatchMetadata, {\n cacheKey:\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${files.length}`\n : undefined,\n isGitDiff,\n throwOnError,\n });\n if (currentFile != null) {\n files.push(currentFile);\n }\n }\n return { patchMetadata, files };\n}\n\ninterface ProcessFileOptions {\n cacheKey?: string;\n isGitDiff?: boolean;\n oldFile?: FileContents;\n newFile?: FileContents;\n throwOnError?: boolean;\n}\n\nexport function processFile(\n fileDiffString: string,\n {\n cacheKey,\n isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(fileDiffString),\n oldFile,\n newFile,\n throwOnError = false,\n }: ProcessFileOptions = {}\n): FileDiffMetadata | undefined {\n let lastHunkEnd = 0;\n const hunks = fileDiffString.split(FILE_CONTEXT_BLOB);\n let currentFile: FileDiffMetadata | undefined;\n const isPartial = oldFile == null || newFile == null;\n let deletionLineIndex = 0;\n let additionLineIndex = 0;\n for (const hunk of hunks) {\n const lines = hunk.split(SPLIT_WITH_NEWLINES);\n const firstLine = lines.shift();\n if (firstLine == null) {\n if (throwOnError) {\n throw Error('parsePatchContent: invalid hunk');\n } else {\n console.error('parsePatchContent: invalid hunk', hunk);\n }\n continue;\n }\n const fileHeaderMatch = firstLine.match(HUNK_HEADER);\n let additionLines = 0;\n let deletionLines = 0;\n // Setup currentFile, this should be the first iteration of our hunks, and\n // technically not a hunk\n if (fileHeaderMatch == null || currentFile == null) {\n if (currentFile != null) {\n if (throwOnError) {\n throw Error('parsePatchContent: Invalid hunk');\n } else {\n console.error('parsePatchContent: Invalid hunk', hunk);\n }\n continue;\n }\n currentFile = {\n name: '',\n type: 'change',\n hunks: [],\n splitLineCount: 0,\n unifiedLineCount: 0,\n isPartial,\n additionLines:\n !isPartial && oldFile != null && newFile != null\n ? newFile.contents.split(SPLIT_WITH_NEWLINES)\n : [],\n deletionLines:\n !isPartial && oldFile != null && newFile != null\n ? oldFile.contents.split(SPLIT_WITH_NEWLINES)\n : [],\n cacheKey,\n };\n // If either file is technically empty, then we should empty the\n // arrays respectively\n if (currentFile.additionLines.length === 1 && newFile?.contents === '') {\n currentFile.additionLines.length = 0;\n }\n if (currentFile.deletionLines.length === 1 && oldFile?.contents === '') {\n currentFile.deletionLines.length = 0;\n }\n\n // Push that first line back into the group of lines so we can properly\n // parse it out\n lines.unshift(firstLine);\n for (const line of lines) {\n const filenameMatch = line.match(\n isGitDiff ? FILENAME_HEADER_REGEX_GIT : FILENAME_HEADER_REGEX\n );\n if (line.startsWith('diff --git')) {\n const [, , prevName, , name] =\n line.trim().match(ALTERNATE_FILE_NAMES_GIT) ?? [];\n currentFile.name = name.trim();\n if (prevName !== name) {\n currentFile.prevName = prevName.trim();\n }\n } else if (filenameMatch != null) {\n const [, type, fileName] = filenameMatch;\n if (type === '---' && fileName !== '/dev/null') {\n currentFile.prevName = fileName.trim();\n currentFile.name = fileName.trim();\n } else if (type === '+++' && fileName !== '/dev/null') {\n currentFile.name = fileName.trim();\n }\n }\n // Git diffs have a bunch of additional metadata we can pull from\n else if (isGitDiff) {\n if (line.startsWith('new mode ')) {\n currentFile.mode = line.replace('new mode', '').trim();\n }\n if (line.startsWith('old mode ')) {\n currentFile.prevMode = line.replace('old mode', '').trim();\n }\n if (line.startsWith('new file mode')) {\n currentFile.type = 'new';\n currentFile.mode = line.replace('new file mode', '').trim();\n }\n if (line.startsWith('deleted file mode')) {\n currentFile.type = 'deleted';\n currentFile.mode = line.replace('deleted file mode', '').trim();\n }\n if (line.startsWith('similarity index')) {\n if (line.startsWith('similarity index 100%')) {\n currentFile.type = 'rename-pure';\n } else {\n currentFile.type = 'rename-changed';\n }\n }\n if (line.startsWith('index ')) {\n const [, prevObjectId, newObjectId, mode] =\n line.trim().match(INDEX_LINE_METADATA) ?? [];\n if (prevObjectId != null) {\n currentFile.prevObjectId = prevObjectId;\n }\n if (newObjectId != null) {\n currentFile.newObjectId = newObjectId;\n }\n if (mode != null) {\n currentFile.mode = mode;\n }\n }\n // We have to handle these for pure renames because there won't be\n // --- and +++ lines\n if (line.startsWith('rename from ')) {\n currentFile.prevName = line.replace('rename from ', '').trim();\n }\n if (line.startsWith('rename to ')) {\n currentFile.name = line.replace('rename to ', '').trim();\n }\n }\n }\n continue;\n }\n\n // Otherwise, time to start parsing out the hunk\n let currentContent: ContextContent | ChangeContent | undefined;\n let lastLineType: 'context' | 'addition' | 'deletion' | undefined;\n\n // Strip trailing bare newlines (format-patch separators between commits)\n // if needed\n while (\n lines.length > 0 &&\n (lines[lines.length - 1] === '\\n' ||\n lines[lines.length - 1] === '\\r' ||\n lines[lines.length - 1] === '\\r\\n' ||\n lines[lines.length - 1] === '')\n ) {\n lines.pop();\n }\n\n const additionStart = parseInt(fileHeaderMatch[3]);\n const deletionStart = parseInt(fileHeaderMatch[1]);\n deletionLineIndex = isPartial ? deletionLineIndex : deletionStart - 1;\n additionLineIndex = isPartial ? additionLineIndex : additionStart - 1;\n\n const hunkData: Hunk = {\n collapsedBefore: 0,\n\n splitLineCount: 0,\n splitLineStart: 0,\n\n unifiedLineCount: 0,\n unifiedLineStart: 0,\n\n additionCount: parseInt(fileHeaderMatch[4] ?? '1'),\n additionStart,\n additionLines,\n\n deletionCount: parseInt(fileHeaderMatch[2] ?? '1'),\n deletionStart,\n deletionLines,\n\n deletionLineIndex,\n additionLineIndex,\n\n hunkContent: [],\n hunkContext: fileHeaderMatch[5],\n hunkSpecs: firstLine,\n\n noEOFCRAdditions: false,\n noEOFCRDeletions: false,\n };\n\n // Lets validate out hunkData to ensure there's no broken data from the\n // regex\n if (\n isNaN(hunkData.additionCount) ||\n isNaN(hunkData.deletionCount) ||\n isNaN(hunkData.additionStart) ||\n isNaN(hunkData.deletionStart)\n ) {\n if (throwOnError) {\n throw Error('parsePatchContent: invalid hunk metadata');\n } else {\n console.error('parsePatchContent: invalid hunk metadata', hunkData);\n }\n continue;\n }\n\n // Now we process each line of the hunk\n for (const rawLine of lines) {\n const parsedLine = parseLineType(rawLine);\n // If we can't properly process the line, well, lets just try to salvage\n // things and continue... It's possible an AI generated diff might have\n // some stray blank lines or something in there\n if (parsedLine == null) {\n console.error('processFile: invalid rawLine:', rawLine);\n continue;\n }\n\n const { type, line } = parsedLine;\n if (type === 'addition') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup(\n 'change',\n deletionLineIndex,\n additionLineIndex\n );\n hunkData.hunkContent.push(currentContent);\n }\n additionLineIndex++;\n if (isPartial) {\n currentFile.additionLines.push(line);\n }\n currentContent.additions++;\n additionLines++;\n lastLineType = 'addition';\n } else if (type === 'deletion') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup(\n 'change',\n deletionLineIndex,\n additionLineIndex\n );\n hunkData.hunkContent.push(currentContent);\n }\n deletionLineIndex++;\n if (isPartial) {\n currentFile.deletionLines.push(line);\n }\n currentContent.deletions++;\n deletionLines++;\n lastLineType = 'deletion';\n } else if (type === 'context') {\n if (currentContent == null || currentContent.type !== 'context') {\n currentContent = createContentGroup(\n 'context',\n deletionLineIndex,\n additionLineIndex\n );\n hunkData.hunkContent.push(currentContent);\n }\n additionLineIndex++;\n deletionLineIndex++;\n if (isPartial) {\n currentFile.deletionLines.push(line);\n currentFile.additionLines.push(line);\n }\n currentContent.lines++;\n lastLineType = 'context';\n } else if (type === 'metadata' && currentContent != null) {\n if (currentContent.type === 'context') {\n hunkData.noEOFCRAdditions = true;\n hunkData.noEOFCRDeletions = true;\n } else if (lastLineType === 'deletion') {\n hunkData.noEOFCRDeletions = true;\n } else if (lastLineType === 'addition') {\n hunkData.noEOFCRAdditions = true;\n }\n // If we're dealing with partial content from a diff, we need to strip\n // newlines manually from the content\n if (\n isPartial &&\n (lastLineType === 'addition' || lastLineType === 'context')\n ) {\n const lastIndex = currentFile.additionLines.length - 1;\n if (lastIndex >= 0) {\n currentFile.additionLines[lastIndex] = cleanLastNewline(\n currentFile.additionLines[lastIndex]\n );\n }\n }\n if (\n isPartial &&\n (lastLineType === 'deletion' || lastLineType === 'context')\n ) {\n const lastIndex = currentFile.deletionLines.length - 1;\n if (lastIndex >= 0) {\n currentFile.deletionLines[lastIndex] = cleanLastNewline(\n currentFile.deletionLines[lastIndex]\n );\n }\n }\n }\n }\n\n hunkData.additionLines = additionLines;\n hunkData.deletionLines = deletionLines;\n\n hunkData.collapsedBefore = Math.max(\n hunkData.additionStart - 1 - lastHunkEnd,\n 0\n );\n currentFile.hunks.push(hunkData);\n lastHunkEnd = hunkData.additionStart + hunkData.additionCount - 1;\n for (const content of hunkData.hunkContent) {\n if (content.type === 'context') {\n hunkData.splitLineCount += content.lines;\n hunkData.unifiedLineCount += content.lines;\n } else {\n hunkData.splitLineCount += Math.max(\n content.additions,\n content.deletions\n );\n hunkData.unifiedLineCount += content.deletions + content.additions;\n }\n }\n hunkData.splitLineStart =\n currentFile.splitLineCount + hunkData.collapsedBefore;\n hunkData.unifiedLineStart =\n currentFile.unifiedLineCount + hunkData.collapsedBefore;\n\n currentFile.splitLineCount +=\n hunkData.collapsedBefore + hunkData.splitLineCount;\n currentFile.unifiedLineCount +=\n hunkData.collapsedBefore + hunkData.unifiedLineCount;\n }\n if (currentFile == null) {\n return undefined;\n }\n\n // Account for collapsed lines after the final hunk and increment the\n // split/unified counts properly\n if (\n currentFile.hunks.length > 0 &&\n !isPartial &&\n currentFile.additionLines.length > 0 &&\n currentFile.deletionLines.length > 0\n ) {\n const lastHunk = currentFile.hunks[currentFile.hunks.length - 1];\n const lastHunkEnd = lastHunk.additionStart + lastHunk.additionCount - 1;\n const totalFileLines = currentFile.additionLines.length;\n const collapsedAfter = Math.max(totalFileLines - lastHunkEnd, 0);\n currentFile.splitLineCount += collapsedAfter;\n currentFile.unifiedLineCount += collapsedAfter;\n }\n\n // If this isn't a git diff style patch, then we'll need to sus out some\n // additional metadata manually\n if (!isGitDiff) {\n if (\n currentFile.prevName != null &&\n currentFile.name !== currentFile.prevName\n ) {\n if (currentFile.hunks.length > 0) {\n currentFile.type = 'rename-changed';\n } else {\n currentFile.type = 'rename-pure';\n }\n }\n // Sort of a hack for detecting deleted/added files...\n else if (\n (oldFile == null || oldFile.contents === '') &&\n newFile != null &&\n newFile.contents !== ''\n ) {\n currentFile.type = 'new';\n } else if (\n oldFile != null &&\n oldFile.contents !== '' &&\n (newFile == null || newFile.contents === '')\n ) {\n currentFile.type = 'deleted';\n }\n }\n if (\n currentFile.type !== 'rename-pure' &&\n currentFile.type !== 'rename-changed'\n ) {\n currentFile.prevName = undefined;\n }\n return currentFile;\n}\n\n/**\n * Parses a patch file string into an array of parsed patches.\n *\n * @param data - The raw patch file content (supports multi-commit patches)\n * @param cacheKeyPrefix - Optional prefix for generating cache keys. When provided,\n * each file in the patch will get a cache key in the format `prefix-patchIndex-fileIndex`.\n * This enables caching of rendered diff results in the worker pool.\n */\nexport function parsePatchFiles(\n data: string,\n cacheKeyPrefix?: string,\n throwOnError = false\n): ParsedPatch[] {\n // NOTE(amadeus): This function is pretty forgiving in that it can accept a\n // patch file that includes commit metdata, multiple commits, or not\n const patches: ParsedPatch[] = [];\n for (const patch of data.split(COMMIT_METADATA_SPLIT)) {\n try {\n patches.push(\n processPatch(\n patch,\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${patches.length}`\n : undefined,\n throwOnError\n )\n );\n } catch (error) {\n if (throwOnError) {\n throw error;\n } else {\n console.error(error);\n }\n }\n }\n return patches;\n}\n\nfunction createContentGroup(\n type: 'change',\n deletionLineIndex: number,\n additionLineIndex: number\n): ChangeContent;\nfunction createContentGroup(\n type: 'context',\n deletionLineIndex: number,\n additionLineIndex: number\n): ContextContent;\nfunction createContentGroup(\n type: 'change' | 'context',\n deletionLineIndex: number,\n additionLineIndex: number\n): ChangeContent | ContextContent {\n if (type === 'change') {\n return {\n type: 'change',\n additions: 0,\n deletions: 0,\n additionLineIndex,\n deletionLineIndex,\n };\n }\n return {\n type: 'context',\n lines: 0,\n additionLineIndex,\n deletionLineIndex,\n };\n}\n"],"mappings":";;;;;AAuBA,SAAgB,aACd,MACA,gBACA,eAAe,OACF;CACb,MAAM,YAAY,0BAA0B,KAAK,KAAK;CACtD,MAAM,WAAW,KAAK,MACpB,YAAY,4BAA4B,8BACzC;CACD,IAAIA;CACJ,MAAMC,QAA4B,EAAE;AACpC,MAAK,MAAM,uBAAuB,UAAU;AAC1C,MAAI,aAAa,CAAC,0BAA0B,KAAK,oBAAoB,EAAE;AACrE,OAAI,iBAAiB,KACnB,iBAAgB;YAEZ,aACF,OAAM,MAAM,uCAAuC;OAEnD,SAAQ,MACN,yCACA,oBACD;AAKL;aAEA,CAAC,aACD,CAAC,8BAA8B,KAAK,oBAAoB,EACxD;AACA,OAAI,iBAAiB,KACnB,iBAAgB;YAEZ,aACF,OAAM,MAAM,uCAAuC;OAEnD,SAAQ,MACN,yCACA,oBACD;AAGL;;EAEF,MAAM,cAAc,YAAY,qBAAqB;GACnD,UACE,kBAAkB,OACd,GAAG,eAAe,GAAG,MAAM,WAC3B;GACN;GACA;GACD,CAAC;AACF,MAAI,eAAe,KACjB,OAAM,KAAK,YAAY;;AAG3B,QAAO;EAAE;EAAe;EAAO;;AAWjC,SAAgB,YACd,gBACA,EACE,UACA,YAAY,0BAA0B,KAAK,eAAe,EAC1D,SACA,SACA,eAAe,UACO,EAAE,EACI;CAC9B,IAAI,cAAc;CAClB,MAAM,QAAQ,eAAe,MAAM,kBAAkB;CACrD,IAAIC;CACJ,MAAM,YAAY,W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M;EACN,WAAW;EACX,WAAW;EACX;EACA;EACD;AAEH,QAAO;EACL,MAAM;EACN,OAAO;EACP;EACA;EACD"}
1
+ {"version":3,"file":"parsePatchFiles.js","names":["patchMetadata: string | undefined","files: FileDiffMetadata[]","currentFile: FileDiffMetadata | undefined","currentContent: ContextContent | ChangeContent | undefined","lastLineType: 'context' | 'addition' | 'deletion' | undefined","hunkData: Hunk","lastHunkEnd","patches: ParsedPatch[]"],"sources":["../../src/utils/parsePatchFiles.ts"],"sourcesContent":["import {\n ALTERNATE_FILE_NAMES_GIT,\n COMMIT_METADATA_SPLIT,\n FILE_CONTEXT_BLOB,\n FILENAME_HEADER_REGEX,\n FILENAME_HEADER_REGEX_GIT,\n GIT_DIFF_FILE_BREAK_REGEX,\n HUNK_HEADER,\n INDEX_LINE_METADATA,\n SPLIT_WITH_NEWLINES,\n UNIFIED_DIFF_FILE_BREAK_REGEX,\n} from '../constants';\nimport type {\n ChangeContent,\n ContextContent,\n FileContents,\n FileDiffMetadata,\n Hunk,\n ParsedPatch,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { parseLineType } from './parseLineType';\n\nexport function processPatch(\n data: string,\n cacheKeyPrefix?: string,\n throwOnError = false\n): ParsedPatch {\n const isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(data);\n const rawFiles = data.split(\n isGitDiff ? GIT_DIFF_FILE_BREAK_REGEX : UNIFIED_DIFF_FILE_BREAK_REGEX\n );\n let patchMetadata: string | undefined;\n const files: FileDiffMetadata[] = [];\n for (const fileOrPatchMetadata of rawFiles) {\n if (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)) {\n if (patchMetadata == null) {\n patchMetadata = fileOrPatchMetadata;\n } else {\n if (throwOnError) {\n throw Error('parsePatchContent: unknown file blob');\n } else {\n console.error(\n 'parsePatchContent: unknown file blob:',\n fileOrPatchMetadata\n );\n }\n }\n // If we get in here, it's most likely the introductory metadata from the\n // patch, or something is fucked with the diff format\n continue;\n } else if (\n !isGitDiff &&\n !UNIFIED_DIFF_FILE_BREAK_REGEX.test(fileOrPatchMetadata)\n ) {\n if (patchMetadata == null) {\n patchMetadata = fileOrPatchMetadata;\n } else {\n if (throwOnError) {\n throw Error('parsePatchContent: unknown file blob');\n } else {\n console.error(\n 'parsePatchContent: unknown file blob:',\n fileOrPatchMetadata\n );\n }\n }\n continue;\n }\n const currentFile = processFile(fileOrPatchMetadata, {\n cacheKey:\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${files.length}`\n : undefined,\n isGitDiff,\n throwOnError,\n });\n if (currentFile != null) {\n files.push(currentFile);\n }\n }\n return { patchMetadata, files };\n}\n\ninterface ProcessFileOptions {\n cacheKey?: string;\n isGitDiff?: boolean;\n oldFile?: FileContents;\n newFile?: FileContents;\n throwOnError?: boolean;\n}\n\nexport function processFile(\n fileDiffString: string,\n {\n cacheKey,\n isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(fileDiffString),\n oldFile,\n newFile,\n throwOnError = false,\n }: ProcessFileOptions = {}\n): FileDiffMetadata | undefined {\n let lastHunkEnd = 0;\n const hunks = fileDiffString.split(FILE_CONTEXT_BLOB);\n let currentFile: FileDiffMetadata | undefined;\n const isPartial = oldFile == null || newFile == null;\n let deletionLineIndex = 0;\n let additionLineIndex = 0;\n for (const hunk of hunks) {\n const lines = hunk.split(SPLIT_WITH_NEWLINES);\n const firstLine = lines.shift();\n if (firstLine == null) {\n if (throwOnError) {\n throw Error('parsePatchContent: invalid hunk');\n } else {\n console.error('parsePatchContent: invalid hunk', hunk);\n }\n continue;\n }\n const fileHeaderMatch = firstLine.match(HUNK_HEADER);\n let additionLines = 0;\n let deletionLines = 0;\n // Setup currentFile, this should be the first iteration of our hunks, and\n // technically not a hunk\n if (fileHeaderMatch == null || currentFile == null) {\n if (currentFile != null) {\n if (throwOnError) {\n throw Error('parsePatchContent: Invalid hunk');\n } else {\n console.error('parsePatchContent: Invalid hunk', hunk);\n }\n continue;\n }\n currentFile = {\n name: '',\n type: 'change',\n hunks: [],\n splitLineCount: 0,\n unifiedLineCount: 0,\n isPartial,\n additionLines:\n !isPartial && oldFile != null && newFile != null\n ? newFile.contents.split(SPLIT_WITH_NEWLINES)\n : [],\n deletionLines:\n !isPartial && oldFile != null && newFile != null\n ? oldFile.contents.split(SPLIT_WITH_NEWLINES)\n : [],\n cacheKey,\n };\n // If either file is technically empty, then we should empty the\n // arrays respectively\n if (currentFile.additionLines.length === 1 && newFile?.contents === '') {\n currentFile.additionLines.length = 0;\n }\n if (currentFile.deletionLines.length === 1 && oldFile?.contents === '') {\n currentFile.deletionLines.length = 0;\n }\n\n // Push that first line back into the group of lines so we can properly\n // parse it out\n lines.unshift(firstLine);\n for (const line of lines) {\n const filenameMatch = line.match(\n isGitDiff ? FILENAME_HEADER_REGEX_GIT : FILENAME_HEADER_REGEX\n );\n if (line.startsWith('diff --git')) {\n const [, , prevName, , name] =\n line.trim().match(ALTERNATE_FILE_NAMES_GIT) ?? [];\n currentFile.name = name.trim();\n if (prevName !== name) {\n currentFile.prevName = prevName.trim();\n }\n } else if (filenameMatch != null) {\n const [, type, fileName] = filenameMatch;\n if (type === '---' && fileName !== '/dev/null') {\n currentFile.prevName = fileName.trim();\n currentFile.name = fileName.trim();\n } else if (type === '+++' && fileName !== '/dev/null') {\n currentFile.name = fileName.trim();\n }\n }\n // Git diffs have a bunch of additional metadata we can pull from\n else if (isGitDiff) {\n if (line.startsWith('new mode ')) {\n currentFile.mode = line.replace('new mode', '').trim();\n }\n if (line.startsWith('old mode ')) {\n currentFile.prevMode = line.replace('old mode', '').trim();\n }\n if (line.startsWith('new file mode')) {\n currentFile.type = 'new';\n currentFile.mode = line.replace('new file mode', '').trim();\n }\n if (line.startsWith('deleted file mode')) {\n currentFile.type = 'deleted';\n currentFile.mode = line.replace('deleted file mode', '').trim();\n }\n if (line.startsWith('similarity index')) {\n if (line.startsWith('similarity index 100%')) {\n currentFile.type = 'rename-pure';\n } else {\n currentFile.type = 'rename-changed';\n }\n }\n if (line.startsWith('index ')) {\n const [, prevObjectId, newObjectId, mode] =\n line.trim().match(INDEX_LINE_METADATA) ?? [];\n if (prevObjectId != null) {\n currentFile.prevObjectId = prevObjectId;\n }\n if (newObjectId != null) {\n currentFile.newObjectId = newObjectId;\n }\n if (mode != null) {\n currentFile.mode = mode;\n }\n }\n // We have to handle these for pure renames because there won't be\n // --- and +++ lines\n if (line.startsWith('rename from ')) {\n currentFile.prevName = line.replace('rename from ', '').trim();\n }\n if (line.startsWith('rename to ')) {\n currentFile.name = line.replace('rename to ', '').trim();\n }\n }\n }\n continue;\n }\n\n // Otherwise, time to start parsing out the hunk\n let currentContent: ContextContent | ChangeContent | undefined;\n let lastLineType: 'context' | 'addition' | 'deletion' | undefined;\n\n // Strip trailing bare newlines (format-patch separators between commits)\n // if needed\n while (\n lines.length > 0 &&\n (lines[lines.length - 1] === '\\n' ||\n lines[lines.length - 1] === '\\r' ||\n lines[lines.length - 1] === '\\r\\n' ||\n lines[lines.length - 1] === '')\n ) {\n lines.pop();\n }\n\n const additionStart = parseInt(fileHeaderMatch[3]);\n const deletionStart = parseInt(fileHeaderMatch[1]);\n deletionLineIndex = isPartial ? deletionLineIndex : deletionStart - 1;\n additionLineIndex = isPartial ? additionLineIndex : additionStart - 1;\n\n const hunkData: Hunk = {\n collapsedBefore: 0,\n\n splitLineCount: 0,\n splitLineStart: 0,\n\n unifiedLineCount: 0,\n unifiedLineStart: 0,\n\n additionCount: parseInt(fileHeaderMatch[4] ?? '1'),\n additionStart,\n additionLines,\n\n deletionCount: parseInt(fileHeaderMatch[2] ?? '1'),\n deletionStart,\n deletionLines,\n\n deletionLineIndex,\n additionLineIndex,\n\n hunkContent: [],\n hunkContext: fileHeaderMatch[5],\n hunkSpecs: firstLine,\n\n noEOFCRAdditions: false,\n noEOFCRDeletions: false,\n };\n\n // Lets validate out hunkData to ensure there's no broken data from the\n // regex\n if (\n isNaN(hunkData.additionCount) ||\n isNaN(hunkData.deletionCount) ||\n isNaN(hunkData.additionStart) ||\n isNaN(hunkData.deletionStart)\n ) {\n if (throwOnError) {\n throw Error('parsePatchContent: invalid hunk metadata');\n } else {\n console.error('parsePatchContent: invalid hunk metadata', hunkData);\n }\n continue;\n }\n\n // Now we process each line of the hunk\n let parsedAdditionLines = 0;\n let parsedDeletionLines = 0;\n for (const rawLine of lines) {\n if (\n isHunkBodyComplete({\n additionCount: hunkData.additionCount,\n parsedAdditionLines,\n deletionCount: hunkData.deletionCount,\n parsedDeletionLines,\n }) &&\n !rawLine.startsWith('\\\\')\n ) {\n break;\n }\n\n const parsedLine = parseLineType(rawLine);\n // If we can't properly process the line, well, lets just try to salvage\n // things and continue... It's possible an AI generated diff might have\n // some stray blank lines or something in there\n if (parsedLine == null) {\n console.error('processFile: invalid rawLine:', rawLine);\n continue;\n }\n\n const { type, line } = parsedLine;\n if (type === 'addition') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup(\n 'change',\n deletionLineIndex,\n additionLineIndex\n );\n hunkData.hunkContent.push(currentContent);\n }\n additionLineIndex++;\n parsedAdditionLines++;\n if (isPartial) {\n currentFile.additionLines.push(line);\n }\n currentContent.additions++;\n additionLines++;\n lastLineType = 'addition';\n } else if (type === 'deletion') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup(\n 'change',\n deletionLineIndex,\n additionLineIndex\n );\n hunkData.hunkContent.push(currentContent);\n }\n deletionLineIndex++;\n parsedDeletionLines++;\n if (isPartial) {\n currentFile.deletionLines.push(line);\n }\n currentContent.deletions++;\n deletionLines++;\n lastLineType = 'deletion';\n } else if (type === 'context') {\n if (currentContent == null || currentContent.type !== 'context') {\n currentContent = createContentGroup(\n 'context',\n deletionLineIndex,\n additionLineIndex\n );\n hunkData.hunkContent.push(currentContent);\n }\n additionLineIndex++;\n deletionLineIndex++;\n parsedAdditionLines++;\n parsedDeletionLines++;\n if (isPartial) {\n currentFile.deletionLines.push(line);\n currentFile.additionLines.push(line);\n }\n currentContent.lines++;\n lastLineType = 'context';\n } else if (type === 'metadata' && currentContent != null) {\n if (currentContent.type === 'context') {\n hunkData.noEOFCRAdditions = true;\n hunkData.noEOFCRDeletions = true;\n } else if (lastLineType === 'deletion') {\n hunkData.noEOFCRDeletions = true;\n } else if (lastLineType === 'addition') {\n hunkData.noEOFCRAdditions = true;\n }\n // If we're dealing with partial content from a diff, we need to strip\n // newlines manually from the content\n if (\n isPartial &&\n (lastLineType === 'addition' || lastLineType === 'context')\n ) {\n const lastIndex = currentFile.additionLines.length - 1;\n if (lastIndex >= 0) {\n currentFile.additionLines[lastIndex] = cleanLastNewline(\n currentFile.additionLines[lastIndex]\n );\n }\n }\n if (\n isPartial &&\n (lastLineType === 'deletion' || lastLineType === 'context')\n ) {\n const lastIndex = currentFile.deletionLines.length - 1;\n if (lastIndex >= 0) {\n currentFile.deletionLines[lastIndex] = cleanLastNewline(\n currentFile.deletionLines[lastIndex]\n );\n }\n }\n }\n }\n\n hunkData.additionLines = additionLines;\n hunkData.deletionLines = deletionLines;\n\n hunkData.collapsedBefore = Math.max(\n hunkData.additionStart - 1 - lastHunkEnd,\n 0\n );\n currentFile.hunks.push(hunkData);\n lastHunkEnd = hunkData.additionStart + hunkData.additionCount - 1;\n for (const content of hunkData.hunkContent) {\n if (content.type === 'context') {\n hunkData.splitLineCount += content.lines;\n hunkData.unifiedLineCount += content.lines;\n } else {\n hunkData.splitLineCount += Math.max(\n content.additions,\n content.deletions\n );\n hunkData.unifiedLineCount += content.deletions + content.additions;\n }\n }\n hunkData.splitLineStart =\n currentFile.splitLineCount + hunkData.collapsedBefore;\n hunkData.unifiedLineStart =\n currentFile.unifiedLineCount + hunkData.collapsedBefore;\n\n currentFile.splitLineCount +=\n hunkData.collapsedBefore + hunkData.splitLineCount;\n currentFile.unifiedLineCount +=\n hunkData.collapsedBefore + hunkData.unifiedLineCount;\n }\n if (currentFile == null) {\n return undefined;\n }\n\n // Account for collapsed lines after the final hunk and increment the\n // split/unified counts properly\n if (\n currentFile.hunks.length > 0 &&\n !isPartial &&\n currentFile.additionLines.length > 0 &&\n currentFile.deletionLines.length > 0\n ) {\n const lastHunk = currentFile.hunks[currentFile.hunks.length - 1];\n const lastHunkEnd = lastHunk.additionStart + lastHunk.additionCount - 1;\n const totalFileLines = currentFile.additionLines.length;\n const collapsedAfter = Math.max(totalFileLines - lastHunkEnd, 0);\n currentFile.splitLineCount += collapsedAfter;\n currentFile.unifiedLineCount += collapsedAfter;\n }\n\n // If this isn't a git diff style patch, then we'll need to sus out some\n // additional metadata manually\n if (!isGitDiff) {\n if (\n currentFile.prevName != null &&\n currentFile.name !== currentFile.prevName\n ) {\n if (currentFile.hunks.length > 0) {\n currentFile.type = 'rename-changed';\n } else {\n currentFile.type = 'rename-pure';\n }\n }\n // Sort of a hack for detecting deleted/added files...\n else if (\n (oldFile == null || oldFile.contents === '') &&\n newFile != null &&\n newFile.contents !== ''\n ) {\n currentFile.type = 'new';\n } else if (\n oldFile != null &&\n oldFile.contents !== '' &&\n (newFile == null || newFile.contents === '')\n ) {\n currentFile.type = 'deleted';\n }\n }\n if (\n currentFile.type !== 'rename-pure' &&\n currentFile.type !== 'rename-changed'\n ) {\n currentFile.prevName = undefined;\n }\n return currentFile;\n}\n\ninterface isHunkBodyCompleteProps {\n additionCount: number;\n parsedAdditionLines: number;\n deletionCount: number;\n parsedDeletionLines: number;\n}\n\n// Git format-patch trailers follow the final hunk without a new diff marker.\n// Once both header-declared line counts are satisfied, the next non-metadata\n// line belongs to the surrounding patch file rather than the hunk body.\nfunction isHunkBodyComplete({\n additionCount,\n parsedAdditionLines,\n deletionCount,\n parsedDeletionLines,\n}: isHunkBodyCompleteProps): boolean {\n return (\n parsedAdditionLines >= additionCount && parsedDeletionLines >= deletionCount\n );\n}\n\n/**\n * Parses a patch file string into an array of parsed patches.\n *\n * @param data - The raw patch file content (supports multi-commit patches)\n * @param cacheKeyPrefix - Optional prefix for generating cache keys. When provided,\n * each file in the patch will get a cache key in the format `prefix-patchIndex-fileIndex`.\n * This enables caching of rendered diff results in the worker pool.\n */\nexport function parsePatchFiles(\n data: string,\n cacheKeyPrefix?: string,\n throwOnError = false\n): ParsedPatch[] {\n // NOTE(amadeus): This function is pretty forgiving in that it can accept a\n // patch file that includes commit metdata, multiple commits, or not\n const patches: ParsedPatch[] = [];\n for (const patch of data.split(COMMIT_METADATA_SPLIT)) {\n try {\n patches.push(\n processPatch(\n patch,\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${patches.length}`\n : undefined,\n throwOnError\n )\n );\n } catch (error) {\n if (throwOnError) {\n throw error;\n } else {\n console.error(error);\n }\n }\n }\n return patches;\n}\n\nfunction createContentGroup(\n type: 'change',\n deletionLineIndex: number,\n additionLineIndex: number\n): ChangeContent;\nfunction createContentGroup(\n type: 'context',\n deletionLineIndex: number,\n additionLineIndex: number\n): ContextContent;\nfunction createContentGroup(\n type: 'change' | 'context',\n deletionLineIndex: number,\n additionLineIndex: number\n): ChangeContent | ContextContent {\n if (type === 'change') {\n return {\n type: 'change',\n additions: 0,\n deletions: 0,\n additionLineIndex,\n deletionLineIndex,\n };\n }\n return {\n type: 'context',\n lines: 0,\n additionLineIndex,\n deletionLineIndex,\n };\n}\n"],"mappings":";;;;;AAuBA,SAAgB,aACd,MACA,gBACA,eAAe,OACF;CACb,MAAM,YAAY,0BAA0B,KAAK,KAAK;CACtD,MAAM,WAAW,KAAK,MACpB,YAAY,4BAA4B,8BACzC;CACD,IAAIA;CACJ,MAAMC,QAA4B,EAAE;AACpC,MAAK,MAAM,uBAAuB,UAAU;AAC1C,MAAI,aAAa,CAAC,0BAA0B,KAAK,oBAAoB,EAAE;AACrE,OAAI,iBAAiB,KACnB,iBAAgB;YAEZ,aACF,OAAM,MAAM,uCAAuC;OAEnD,SAAQ,MACN,yCACA,oBACD;AAKL;aAEA,CAAC,aACD,CAAC,8BAA8B,KAAK,oBAAoB,EACxD;AACA,OAAI,iBAAiB,KACnB,iBAAgB;YAEZ,aACF,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AKpB,WAAW,QAAQ,QAAQ,aAAa,OACzC,WAAW,QACX,QAAQ,aAAa,GAErB,aAAY,OAAO;WAEnB,WAAW,QACX,QAAQ,aAAa,OACpB,WAAW,QAAQ,QAAQ,aAAa,IAEzC,aAAY,OAAO;;AAGvB,KACE,YAAY,SAAS,iBACrB,YAAY,SAAS,iBAErB,aAAY,WAAW;AAEzB,QAAO;;AAaT,SAAS,mBAAmB,EAC1B,eACA,qBACA,eACA,uBACmC;AACnC,QACE,uBAAuB,iBAAiB,uBAAuB;;;;;;;;;;AAYnE,SAAgB,gBACd,MACA,gBACA,eAAe,OACA;CAGf,MAAMC,UAAyB,EAAE;AACjC,MAAK,MAAM,SAAS,KAAK,MAAM,sBAAsB,CACnD,KAAI;AACF,UAAQ,KACN,aACE,OACA,kBAAkB,OACd,GAAG,eAAe,GAAG,QAAQ,WAC7B,QACJ,aACD,CACF;UACM,OAAO;AACd,MAAI,aACF,OAAM;MAEN,SAAQ,MAAM,MAAM;;AAI1B,QAAO;;AAaT,SAAS,mBACP,MACA,mBACA,mBACgC;AAChC,KAAI,SAAS,SACX,QAAO;EACL,MAAM;EACN,WAAW;EACX,WAAW;EACX;EACA;EACD;AAEH,QAAO;EACL,MAAM;EACN,OAAO;EACP;EACA;EACD"}
@@ -0,0 +1,6 @@
1
+ //#region src/utils/scrollbarGutter.d.ts
2
+ declare function getMeasuredScrollbarGutter(shadowRoot: ShadowRoot): number | undefined;
3
+ declare function createMeasuredScrollbarGutterDeclaration(scrollbarGutter: number | undefined): string;
4
+ //#endregion
5
+ export { createMeasuredScrollbarGutterDeclaration, getMeasuredScrollbarGutter };
6
+ //# sourceMappingURL=scrollbarGutter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollbarGutter.d.ts","names":["getMeasuredScrollbarGutter","ShadowRoot","createMeasuredScrollbarGutterDeclaration"],"sources":["../../src/utils/scrollbarGutter.d.ts"],"sourcesContent":["export declare function getMeasuredScrollbarGutter(shadowRoot: ShadowRoot): number | undefined;\nexport declare function createMeasuredScrollbarGutterDeclaration(scrollbarGutter: number | undefined): string;\n//# sourceMappingURL=scrollbarGutter.d.ts.map"],"mappings":";iBAAwBA,0BAAAA,aAAuCC;AAAvCD,iBACAE,wCAAAA,CADiD,eAAA,EAAA,MAAA,GAAA,SAAA,CAAA,EAAA,MAAA"}
@@ -0,0 +1,28 @@
1
+ import { DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE } from "../constants.js";
2
+
3
+ //#region src/utils/scrollbarGutter.ts
4
+ let measuredScrollbarGutter;
5
+ function getMeasuredScrollbarGutter(shadowRoot) {
6
+ if (measuredScrollbarGutter != null) return measuredScrollbarGutter;
7
+ const host = shadowRoot.host;
8
+ if (typeof HTMLElement !== "undefined" && host instanceof HTMLElement && !host.isConnected) return;
9
+ const wrapper = document.createElement("div");
10
+ wrapper.setAttribute("data-code", "");
11
+ wrapper.setAttribute(DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, "true");
12
+ const child = document.createElement("div");
13
+ child.style.position = "relative";
14
+ child.style.width = "200%";
15
+ child.style.height = "200%";
16
+ wrapper.appendChild(child);
17
+ shadowRoot.appendChild(wrapper);
18
+ measuredScrollbarGutter = Math.max(wrapper.offsetHeight - wrapper.clientHeight, 0);
19
+ wrapper.remove();
20
+ return measuredScrollbarGutter;
21
+ }
22
+ function createMeasuredScrollbarGutterDeclaration(scrollbarGutter) {
23
+ return `${DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY}: ${scrollbarGutter == null ? "var(--diffs-scrollbar-gutter-fallback)" : `${scrollbarGutter}px`};`;
24
+ }
25
+
26
+ //#endregion
27
+ export { createMeasuredScrollbarGutterDeclaration, getMeasuredScrollbarGutter };
28
+ //# sourceMappingURL=scrollbarGutter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollbarGutter.js","names":["measuredScrollbarGutter: number | undefined"],"sources":["../../src/utils/scrollbarGutter.ts"],"sourcesContent":["import {\n DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY,\n DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE,\n} from '../constants';\n\nlet measuredScrollbarGutter: number | undefined;\n\n// Measures the horizontal scrollbar used by `[data-code]` once per page. The\n// hidden probe opts into the same selector as real code panes so custom\n// scrollbar CSS is reflected in the measured value.\nexport function getMeasuredScrollbarGutter(\n shadowRoot: ShadowRoot\n): number | undefined {\n if (measuredScrollbarGutter != null) {\n return measuredScrollbarGutter;\n }\n\n const host = shadowRoot.host;\n if (\n typeof HTMLElement !== 'undefined' &&\n host instanceof HTMLElement &&\n !host.isConnected\n ) {\n return undefined;\n }\n\n const wrapper = document.createElement('div');\n wrapper.setAttribute('data-code', '');\n wrapper.setAttribute(DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, 'true');\n\n const child = document.createElement('div');\n child.style.position = 'relative';\n child.style.width = '200%';\n child.style.height = '200%';\n wrapper.appendChild(child);\n\n shadowRoot.appendChild(wrapper);\n measuredScrollbarGutter = Math.max(\n wrapper.offsetHeight - wrapper.clientHeight,\n 0\n );\n wrapper.remove();\n return measuredScrollbarGutter;\n}\n\nexport function createMeasuredScrollbarGutterDeclaration(\n scrollbarGutter: number | undefined\n): string {\n const value =\n scrollbarGutter == null\n ? 'var(--diffs-scrollbar-gutter-fallback)'\n : `${scrollbarGutter}px`;\n return `${DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY}: ${value};`;\n}\n"],"mappings":";;;AAKA,IAAIA;AAKJ,SAAgB,2BACd,YACoB;AACpB,KAAI,2BAA2B,KAC7B,QAAO;CAGT,MAAM,OAAO,WAAW;AACxB,KACE,OAAO,gBAAgB,eACvB,gBAAgB,eAChB,CAAC,KAAK,YAEN;CAGF,MAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,SAAQ,aAAa,aAAa,GAAG;AACrC,SAAQ,aAAa,mCAAmC,OAAO;CAE/D,MAAM,QAAQ,SAAS,cAAc,MAAM;AAC3C,OAAM,MAAM,WAAW;AACvB,OAAM,MAAM,QAAQ;AACpB,OAAM,MAAM,SAAS;AACrB,SAAQ,YAAY,MAAM;AAE1B,YAAW,YAAY,QAAQ;AAC/B,2BAA0B,KAAK,IAC7B,QAAQ,eAAe,QAAQ,cAC/B,EACD;AACD,SAAQ,QAAQ;AAChB,QAAO;;AAGT,SAAgB,yCACd,iBACQ;AAKR,QAAO,GAAG,yCAAyC,IAHjD,mBAAmB,OACf,2CACA,GAAG,gBAAgB,IACoC"}
@@ -1,9 +1,9 @@
1
1
  import { DEFAULT_THEMES } from "../constants.js";
2
+ import { areThemesEqual } from "../utils/areThemesEqual.js";
2
3
  import { attachResolvedThemes } from "../highlighter/themes/attachResolvedThemes.js";
3
4
  import { getSharedHighlighter } from "../highlighter/shared_highlighter.js";
4
5
  import { getThemes } from "../utils/getThemes.js";
5
6
  import { hasResolvedThemes } from "../highlighter/themes/hasResolvedThemes.js";
6
- import { areThemesEqual } from "../utils/areThemesEqual.js";
7
7
  import { getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName } from "../utils/getFiletypeFromFileName.js";
8
8
  import { isFilePlainText } from "../utils/isFilePlainText.js";
9
9
  import { renderFileWithHighlighter } from "../utils/renderFileWithHighlighter.js";