@pierre/diffs 1.1.7 → 1.1.9

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 (65) hide show
  1. package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
  2. package/dist/components/File.d.ts.map +1 -1
  3. package/dist/components/FileDiff.js +2 -2
  4. package/dist/components/FileDiff.js.map +1 -1
  5. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  6. package/dist/components/VirtualizedFileDiff.js +1 -1
  7. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  8. package/dist/index.d.ts +4 -3
  9. package/dist/index.js +2 -1
  10. package/dist/managers/InteractionManager.d.ts +15 -2
  11. package/dist/managers/InteractionManager.d.ts.map +1 -1
  12. package/dist/managers/InteractionManager.js +143 -40
  13. package/dist/managers/InteractionManager.js.map +1 -1
  14. package/dist/react/index.d.ts +2 -2
  15. package/dist/renderers/DiffHunksRenderer.js +11 -10
  16. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  17. package/dist/renderers/FileRenderer.js +3 -1
  18. package/dist/renderers/FileRenderer.js.map +1 -1
  19. package/dist/ssr/FileDiffReact.js +1 -1
  20. package/dist/ssr/index.d.ts +2 -2
  21. package/dist/ssr/preloadDiffs.js +1 -1
  22. package/dist/ssr/preloadDiffs.js.map +1 -1
  23. package/dist/style.js +1 -1
  24. package/dist/style.js.map +1 -1
  25. package/dist/types.d.ts +23 -2
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/utils/areDiffRenderOptionsEqual.d.ts +7 -0
  28. package/dist/utils/areDiffRenderOptionsEqual.d.ts.map +1 -0
  29. package/dist/utils/areDiffRenderOptionsEqual.js +10 -0
  30. package/dist/utils/areDiffRenderOptionsEqual.js.map +1 -0
  31. package/dist/utils/areOptionsEqual.d.ts +2 -1
  32. package/dist/utils/areOptionsEqual.d.ts.map +1 -1
  33. package/dist/utils/areOptionsEqual.js +8 -1
  34. package/dist/utils/areOptionsEqual.js.map +1 -1
  35. package/dist/utils/createTransformerWithState.d.ts +1 -1
  36. package/dist/utils/createTransformerWithState.d.ts.map +1 -1
  37. package/dist/utils/createTransformerWithState.js +27 -2
  38. package/dist/utils/createTransformerWithState.js.map +1 -1
  39. package/dist/utils/parseDiffFromFile.js +1 -0
  40. package/dist/utils/parseDiffFromFile.js.map +1 -1
  41. package/dist/utils/renderDiffWithHighlighter.js +6 -3
  42. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  43. package/dist/utils/renderFileWithHighlighter.d.ts +2 -1
  44. package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
  45. package/dist/utils/renderFileWithHighlighter.js +2 -2
  46. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  47. package/dist/utils/shouldUseTokenTransformer.d.ts +9 -0
  48. package/dist/utils/shouldUseTokenTransformer.d.ts.map +1 -0
  49. package/dist/utils/shouldUseTokenTransformer.js +8 -0
  50. package/dist/utils/shouldUseTokenTransformer.js.map +1 -0
  51. package/dist/utils/wrapTokenFragments.d.ts +10 -0
  52. package/dist/utils/wrapTokenFragments.d.ts.map +1 -0
  53. package/dist/utils/wrapTokenFragments.js +82 -0
  54. package/dist/utils/wrapTokenFragments.js.map +1 -0
  55. package/dist/worker/WorkerPoolManager.d.ts +4 -0
  56. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  57. package/dist/worker/WorkerPoolManager.js +11 -6
  58. package/dist/worker/WorkerPoolManager.js.map +1 -1
  59. package/dist/worker/types.d.ts +2 -0
  60. package/dist/worker/types.d.ts.map +1 -1
  61. package/dist/worker/worker-portable.js +142 -8
  62. package/dist/worker/worker-portable.js.map +1 -1
  63. package/dist/worker/worker.js +124 -8
  64. package/dist/worker/worker.js.map +1 -1
  65. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","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","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData","AppliedThemeStyleCache"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type MergeConflictMarkerRowType = 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end';\nexport interface MergeConflictMarkerRow {\n type: MergeConflictMarkerRowType;\n hunkIndex: number;\n /** Index into `hunk.hunkContent` for the structural block this row belongs to. */\n contentIndex: number;\n conflictIndex: number;\n lineText: string;\n /** Unified rendered-row index where this virtual row should be injected. */\n lineIndex: number;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow'>> {\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 MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\nexport type DiffAcceptRejectHunkType = 'accept' | 'reject' | 'both';\nexport type ConflictResolverTypes = 'current' | 'incoming' | 'both';\nexport interface DiffAcceptRejectHunkConfig {\n type: DiffAcceptRejectHunkType;\n changeIndex: number;\n}\n/**\n * Unresolved merge conflict indexes use three different coordinate spaces:\n * - source line indexes live on `conflict.*LineIndex`\n * - hunk-content indexes live on the fields below, with `startContentIndex`\n * serving as both the conflict-range start and the start-marker anchor\n * - rendered row indexes live on unresolved `markerRows`\n */\nexport interface ProcessFileConflictData {\n /** Index of the hunk that owns this unresolved conflict. */\n hunkIndex: number;\n /** First hunk-content entry that belongs to the conflict region. */\n startContentIndex: number;\n /** Last hunk-content entry that belongs to the conflict region. */\n endContentIndex: number;\n /** Hunk-content index for the current/ours change block. */\n currentContentIndex?: number;\n /** Hunk-content index for the optional base context block. */\n baseContentIndex?: number;\n /** Hunk-content index for the incoming/theirs change block. */\n incomingContentIndex?: number;\n /** Hunk-content index that anchors the end marker row. */\n endMarkerContentIndex: number;\n}\nexport interface AppliedThemeStyleCache {\n themeStyles: string;\n themeType: ThemeTypes;\n baseThemeType: 'light' | 'dark' | undefined;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;AAMA;AAgBA;AAEYa,UAlBKH,YAAAA,CAkBU;EACfI;AAQZ;EAAkDH,IAAAA,EAAAA,MAAAA;EAAoBE;EAAvCR,QAAAA,EAAAA,MAAAA;EAAkB;AASjD;EAKiBa,IAAAA,CAAAA,EAjCNP,kBAiCiB;EAYXS;EAoBAC,MAAAA,CAAAA,EAAAA,MAAAA;EAqBAC;AA0FjB;;EA8BUL,QAAAA,CAAAA,EAAAA,MAAAA;;AAGK,KAzMHL,gBAAAA,GAyMG,UAAA,GAAA,YAAA;AAwCEY,KA/OLX,eAA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;;UAEtDF,cAAAA;;;;;;UAMAI,kBAAAA;;;eAGAC;iBACEA;;;UAGFC,sBAAAA,SAA+B5B,KAAK0B;;kBAEjCf;YACNY;;UAEGM,uBAAAA;;;eAGEF;WACJA;;;;eAIIA;WACJA;;;;;UAKEG,iBAAAA;;eAEAH;iBACEA;;;;KAIPI,cAAAA;UACKC,QAAAA;;;;QAIPD;;;;;;;KAOEE,iCAAiClD,eAAeiC,mBAAmBkB;KACnEC,mBAAAA;UACKC,gBAAAA;QACPpE;;;;UAIOqE,qBAAAA;iBACErE;iBACAA;;UAEFsE,gBAAAA;QACPD;;;;UAIOE,mBAAAA;;;;UAIAC,yBAAAA;;;;kBAIGC,YAAYF;;;UAGfG,yBAAAA;;;;;;UAMAC,iBAAAA;SACN9D,kBAAkBE,yBAAyBF;;;UAGrC+D,iBAAAA;SACN/D,kBAAkBE,yBAAyBF;;gBAEpCe;;UAEDiD,gBAAAA;UACLT;WACCO;;UAEIG,gBAAAA;UACLR;WACCM;;UAEIG,oBAAAA;QACPrE;;WAEGiE;UACDP;eACKY;;UAEAC,oBAAAA;QACP9D;;WAEGyD;UACDN;eACKU;;UAEAA,WAAAA;;;;;;UAMAE,YAAAA;;;;UAIAC,kBAAAA;;;;UAIAC,kBAAAA;;;;;;;UAOAC,cAAAA;;QAEPzC;;KAEE0C,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;;aAEFhE"}
1
+ {"version":3,"file":"types.d.ts","names":["CreatePatchOptionsNonabortable","ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","FileHeaderRenderMode","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","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","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData","AppliedThemeStyleCache"],"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 };\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type MergeConflictMarkerRowType = 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end';\nexport interface MergeConflictMarkerRow {\n type: MergeConflictMarkerRowType;\n hunkIndex: number;\n /** Index into `hunk.hunkContent` for the structural block this row belongs to. */\n contentIndex: number;\n conflictIndex: number;\n lineText: string;\n /** Unified rendered-row index where this virtual row should be injected. */\n lineIndex: number;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n useTokenTransformer?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n /**\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 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 top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\nexport type DiffAcceptRejectHunkType = 'accept' | 'reject' | 'both';\nexport type ConflictResolverTypes = 'current' | 'incoming' | 'both';\nexport interface DiffAcceptRejectHunkConfig {\n type: DiffAcceptRejectHunkType;\n changeIndex: number;\n}\n/**\n * Unresolved merge conflict indexes use three different coordinate spaces:\n * - source line indexes live on `conflict.*LineIndex`\n * - hunk-content indexes live on the fields below, with `startContentIndex`\n * serving as both the conflict-range start and the start-marker anchor\n * - rendered row indexes live on unresolved `markerRows`\n */\nexport interface ProcessFileConflictData {\n /** Index of the hunk that owns this unresolved conflict. */\n hunkIndex: number;\n /** First hunk-content entry that belongs to the conflict region. */\n startContentIndex: number;\n /** Last hunk-content entry that belongs to the conflict region. */\n endContentIndex: number;\n /** Hunk-content index for the current/ours change block. */\n currentContentIndex?: number;\n /** Hunk-content index for the optional base context block. */\n baseContentIndex?: number;\n /** Hunk-content index for the incoming/theirs change block. */\n incomingContentIndex?: number;\n /** Hunk-content index that anchors the end marker row. */\n endMarkerContentIndex: number;\n}\nexport interface AppliedThemeStyleCache {\n themeStyles: string;\n themeType: ThemeTypes;\n baseThemeType: 'light' | 'dark' | undefined;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;AAQA;AAgBA;AAEA;AACYe,UAnBKJ,YAAAA,CAmBiCG;EAQtCG;;EAA0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ACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;;aAEFlE"}
@@ -0,0 +1,7 @@
1
+ import { RenderDiffOptions } from "../types.js";
2
+
3
+ //#region src/utils/areDiffRenderOptionsEqual.d.ts
4
+ declare function areDiffRenderOptionsEqual(optionsA: RenderDiffOptions, optionsB: RenderDiffOptions): boolean;
5
+ //#endregion
6
+ export { areDiffRenderOptionsEqual };
7
+ //# sourceMappingURL=areDiffRenderOptionsEqual.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areDiffRenderOptionsEqual.d.ts","names":["RenderDiffOptions","areDiffRenderOptionsEqual"],"sources":["../../src/utils/areDiffRenderOptionsEqual.d.ts"],"sourcesContent":["import type { RenderDiffOptions } from '../types';\nexport declare function areDiffRenderOptionsEqual(optionsA: RenderDiffOptions, optionsB: RenderDiffOptions): boolean;\n//# sourceMappingURL=areDiffRenderOptionsEqual.d.ts.map"],"mappings":";;;iBACwBC,yBAAAA,WAAoCD,6BAA6BA"}
@@ -0,0 +1,10 @@
1
+ import { areThemesEqual } from "./areThemesEqual.js";
2
+
3
+ //#region src/utils/areDiffRenderOptionsEqual.ts
4
+ function areDiffRenderOptionsEqual(optionsA, optionsB) {
5
+ return areThemesEqual(optionsA.theme, optionsB.theme) && optionsA.useTokenTransformer === optionsB.useTokenTransformer && optionsA.tokenizeMaxLineLength === optionsB.tokenizeMaxLineLength && optionsA.lineDiffType === optionsB.lineDiffType && optionsA.maxLineDiffLength === optionsB.maxLineDiffLength;
6
+ }
7
+
8
+ //#endregion
9
+ export { areDiffRenderOptionsEqual };
10
+ //# sourceMappingURL=areDiffRenderOptionsEqual.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"areDiffRenderOptionsEqual.js","names":[],"sources":["../../src/utils/areDiffRenderOptionsEqual.ts"],"sourcesContent":["import type { RenderDiffOptions } from '../types';\nimport { areThemesEqual } from './areThemesEqual';\n\nexport function areDiffRenderOptionsEqual(\n optionsA: RenderDiffOptions,\n optionsB: RenderDiffOptions\n): boolean {\n return (\n areThemesEqual(optionsA.theme, optionsB.theme) &&\n optionsA.useTokenTransformer === optionsB.useTokenTransformer &&\n optionsA.tokenizeMaxLineLength === optionsB.tokenizeMaxLineLength &&\n optionsA.lineDiffType === optionsB.lineDiffType &&\n optionsA.maxLineDiffLength === optionsB.maxLineDiffLength\n );\n}\n"],"mappings":";;;AAGA,SAAgB,0BACd,UACA,UACS;AACT,QACE,eAAe,SAAS,OAAO,SAAS,MAAM,IAC9C,SAAS,wBAAwB,SAAS,uBAC1C,SAAS,0BAA0B,SAAS,yBAC5C,SAAS,iBAAiB,SAAS,gBACnC,SAAS,sBAAsB,SAAS"}
@@ -3,7 +3,8 @@ import "../react/index.js";
3
3
  import { FileDiffOptions } from "../components/FileDiff.js";
4
4
 
5
5
  //#region src/utils/areOptionsEqual.d.ts
6
- declare function areOptionsEqual<LAnnotation>(optionsA: FileOptions<LAnnotation> | FileDiffOptions<LAnnotation> | undefined, optionsB: FileOptions<LAnnotation> | FileDiffOptions<LAnnotation> | undefined): boolean;
6
+ type AnyOptions<L> = FileOptions<L> | FileDiffOptions<L> | undefined;
7
+ declare function areOptionsEqual<LAnnotation>(optionsA: AnyOptions<LAnnotation>, optionsB: AnyOptions<LAnnotation>): boolean;
7
8
  //#endregion
8
9
  export { areOptionsEqual };
9
10
  //# sourceMappingURL=areOptionsEqual.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"areOptionsEqual.d.ts","names":["FileDiffOptions","FileOptions","areOptionsEqual","LAnnotation"],"sources":["../../src/utils/areOptionsEqual.d.ts"],"sourcesContent":["import type { FileDiffOptions } from '../components/FileDiff';\nimport type { FileOptions } from '../react';\nexport declare function areOptionsEqual<LAnnotation>(optionsA: FileOptions<LAnnotation> | FileDiffOptions<LAnnotation> | undefined, optionsB: FileOptions<LAnnotation> | FileDiffOptions<LAnnotation> | undefined): boolean;\n//# sourceMappingURL=areOptionsEqual.d.ts.map"],"mappings":";;;;;iBAEwBE,uCAAuCD,YAAYE,eAAeH,gBAAgBG,oCAAoCF,YAAYE,eAAeH,gBAAgBG"}
1
+ {"version":3,"file":"areOptionsEqual.d.ts","names":["FileDiffOptions","FileOptions","AnyOptions","L","areOptionsEqual","LAnnotation"],"sources":["../../src/utils/areOptionsEqual.d.ts"],"sourcesContent":["import type { FileDiffOptions } from '../components/FileDiff';\nimport type { FileOptions } from '../react';\ntype AnyOptions<L> = FileOptions<L> | FileDiffOptions<L> | undefined;\nexport declare function areOptionsEqual<LAnnotation>(optionsA: AnyOptions<LAnnotation>, optionsB: AnyOptions<LAnnotation>): boolean;\nexport {};\n//# sourceMappingURL=areOptionsEqual.d.ts.map"],"mappings":";;;;;KAEKE,gBAAgBD,YAAYE,KAAKH,gBAAgBG;iBAC9BC,uCAAuCF,WAAWG,wBAAwBH,WAAWG"}
@@ -4,7 +4,14 @@ import { areObjectsEqual } from "./areObjectsEqual.js";
4
4
 
5
5
  //#region src/utils/areOptionsEqual.ts
6
6
  function areOptionsEqual(optionsA, optionsB) {
7
- return areThemesEqual(optionsA?.theme ?? DEFAULT_THEMES, optionsB?.theme ?? DEFAULT_THEMES) && areObjectsEqual(optionsA, optionsB, ["theme"]);
7
+ const themeA = optionsA?.theme ?? DEFAULT_THEMES;
8
+ const themeB = optionsB?.theme ?? DEFAULT_THEMES;
9
+ const diffOptsA = getParseDiffOptions(optionsA);
10
+ const diffOptsB = getParseDiffOptions(optionsB);
11
+ return areThemesEqual(themeA, themeB) && areObjectsEqual(optionsA, optionsB, ["theme", "parseDiffOptions"]) && areObjectsEqual(diffOptsA, diffOptsB);
12
+ }
13
+ function getParseDiffOptions(options) {
14
+ if (options != null && "parseDiffOptions" in options) return options.parseDiffOptions;
8
15
  }
9
16
 
10
17
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"areOptionsEqual.js","names":[],"sources":["../../src/utils/areOptionsEqual.ts"],"sourcesContent":["import type { FileDiffOptions } from '../components/FileDiff';\nimport { DEFAULT_THEMES } from '../constants';\nimport type { FileOptions } from '../react';\nimport { areObjectsEqual } from './areObjectsEqual';\nimport { areThemesEqual } from './areThemesEqual';\n\nexport function areOptionsEqual<LAnnotation>(\n optionsA: FileOptions<LAnnotation> | FileDiffOptions<LAnnotation> | undefined,\n optionsB: FileOptions<LAnnotation> | FileDiffOptions<LAnnotation> | undefined\n): boolean {\n const themeA = optionsA?.theme ?? DEFAULT_THEMES;\n const themeB = optionsB?.theme ?? DEFAULT_THEMES;\n return (\n areThemesEqual(themeA, themeB) &&\n areObjectsEqual(optionsA, optionsB, ['theme'])\n );\n}\n"],"mappings":";;;;;AAMA,SAAgB,gBACd,UACA,UACS;AAGT,QACE,eAHa,UAAU,SAAS,gBACnB,UAAU,SAAS,eAEF,IAC9B,gBAAgB,UAAU,UAAU,CAAC,QAAQ,CAAC"}
1
+ {"version":3,"file":"areOptionsEqual.js","names":[],"sources":["../../src/utils/areOptionsEqual.ts"],"sourcesContent":["import type { CreatePatchOptionsNonabortable } from 'diff';\n\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport { DEFAULT_THEMES } from '../constants';\nimport type { FileOptions } from '../react';\nimport { areObjectsEqual } from './areObjectsEqual';\nimport { areThemesEqual } from './areThemesEqual';\n\ntype AnyOptions<L> = FileOptions<L> | FileDiffOptions<L> | undefined;\n\nexport function areOptionsEqual<LAnnotation>(\n optionsA: AnyOptions<LAnnotation>,\n optionsB: AnyOptions<LAnnotation>\n): boolean {\n const themeA = optionsA?.theme ?? DEFAULT_THEMES;\n const themeB = optionsB?.theme ?? DEFAULT_THEMES;\n const diffOptsA = getParseDiffOptions(optionsA);\n const diffOptsB = getParseDiffOptions(optionsB);\n return (\n areThemesEqual(themeA, themeB) &&\n areObjectsEqual(optionsA, optionsB, [\n 'theme',\n 'parseDiffOptions' as keyof typeof optionsA,\n ]) &&\n areObjectsEqual(diffOptsA, diffOptsB)\n );\n}\n\nfunction getParseDiffOptions<L>(\n options: AnyOptions<L>\n): CreatePatchOptionsNonabortable | undefined {\n if (options != null && 'parseDiffOptions' in options) {\n return options.parseDiffOptions;\n }\n return undefined;\n}\n"],"mappings":";;;;;AAUA,SAAgB,gBACd,UACA,UACS;CACT,MAAM,SAAS,UAAU,SAAS;CAClC,MAAM,SAAS,UAAU,SAAS;CAClC,MAAM,YAAY,oBAAoB,SAAS;CAC/C,MAAM,YAAY,oBAAoB,SAAS;AAC/C,QACE,eAAe,QAAQ,OAAO,IAC9B,gBAAgB,UAAU,UAAU,CAClC,SACA,mBACD,CAAC,IACF,gBAAgB,WAAW,UAAU;;AAIzC,SAAS,oBACP,SAC4C;AAC5C,KAAI,WAAW,QAAQ,sBAAsB,QAC3C,QAAO,QAAQ"}
@@ -7,7 +7,7 @@ interface CreateTransformerWithStateReturn {
7
7
  transformers: ShikiTransformer[];
8
8
  toClass: ShikiTransformerStyleToClass;
9
9
  }
10
- declare function createTransformerWithState(useCSSClasses?: boolean): CreateTransformerWithStateReturn;
10
+ declare function createTransformerWithState(useTokenTransformer?: boolean, useCSSClasses?: boolean): CreateTransformerWithStateReturn;
11
11
  //#endregion
12
12
  export { createTransformerWithState };
13
13
  //# sourceMappingURL=createTransformerWithState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTransformerWithState.d.ts","names":["ShikiTransformerStyleToClass","SharedRenderState","ShikiTransformer","CreateTransformerWithStateReturn","createTransformerWithState"],"sources":["../../src/utils/createTransformerWithState.d.ts"],"sourcesContent":["import { type ShikiTransformerStyleToClass } from '@shikijs/transformers';\nimport type { SharedRenderState, ShikiTransformer } from '../types';\ninterface CreateTransformerWithStateReturn {\n state: SharedRenderState;\n transformers: ShikiTransformer[];\n toClass: ShikiTransformerStyleToClass;\n}\nexport declare function createTransformerWithState(useCSSClasses?: boolean): CreateTransformerWithStateReturn;\nexport {};\n//# sourceMappingURL=createTransformerWithState.d.ts.map"],"mappings":";;;;UAEUG,gCAAAA;SACCF;EADDE,YAAAA,EAEQD,gBAFRC,EAAAA;EACCF,OAAAA,EAEED,4BAFFC;;AAEED,iBAEWI,0BAAAA,CAFXJ,aAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAEgEG,gCAFhEH"}
1
+ {"version":3,"file":"createTransformerWithState.d.ts","names":["ShikiTransformerStyleToClass","SharedRenderState","ShikiTransformer","CreateTransformerWithStateReturn","createTransformerWithState"],"sources":["../../src/utils/createTransformerWithState.d.ts"],"sourcesContent":["import { type ShikiTransformerStyleToClass } from '@shikijs/transformers';\nimport type { SharedRenderState, ShikiTransformer } from '../types';\ninterface CreateTransformerWithStateReturn {\n state: SharedRenderState;\n transformers: ShikiTransformer[];\n toClass: ShikiTransformerStyleToClass;\n}\nexport declare function createTransformerWithState(useTokenTransformer?: boolean, useCSSClasses?: boolean): CreateTransformerWithStateReturn;\nexport {};\n//# sourceMappingURL=createTransformerWithState.d.ts.map"],"mappings":";;;;UAEUG,gCAAAA;SACCF;EADDE,YAAAA,EAEQD,gBAFRC,EAAAA;EACCF,OAAAA,EAEED,4BAFFC;;AAEED,iBAEWI,0BAAAA,CAFXJ,mBAAAA,CAAAA,EAAAA,OAAAA,EAAAA,aAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAE+FG,gCAF/FH"}
@@ -1,9 +1,10 @@
1
1
  import { findCodeElement } from "./hast_utils.js";
2
2
  import { processLine } from "./processLine.js";
3
+ import { wrapTokenFragments } from "./wrapTokenFragments.js";
3
4
  import { transformerStyleToClass } from "@shikijs/transformers";
4
5
 
5
6
  //#region src/utils/createTransformerWithState.ts
6
- function createTransformerWithState(useCSSClasses = false) {
7
+ function createTransformerWithState(useTokenTransformer = false, useCSSClasses = false) {
7
8
  const state = { lineInfo: [] };
8
9
  const transformers = [{
9
10
  line(node) {
@@ -17,13 +18,37 @@ function createTransformerWithState(useCSSClasses = false) {
17
18
  let index = 1;
18
19
  for (const node of code.children) {
19
20
  if (node.type !== "element") continue;
21
+ if (useTokenTransformer) wrapTokenFragments(node);
20
22
  children.push(processLine(node, index, state));
21
23
  index++;
22
24
  }
23
25
  code.children = children;
24
26
  }
25
27
  return pre;
26
- }
28
+ },
29
+ ...useTokenTransformer ? {
30
+ tokens(lines) {
31
+ for (const line of lines) {
32
+ let col = 0;
33
+ for (const token of line) {
34
+ const tokenWithOriginalRange = token;
35
+ tokenWithOriginalRange.__lineChar ??= col;
36
+ col += token.content.length;
37
+ }
38
+ }
39
+ },
40
+ preprocess(_code, options) {
41
+ options.mergeWhitespaces = "never";
42
+ },
43
+ span(hast, _line, _char, _lineElement, token) {
44
+ if (token?.offset != null && token.content != null) {
45
+ const tokenChar = token.__lineChar;
46
+ if (tokenChar != null) hast.properties["data-char"] = tokenChar;
47
+ return hast;
48
+ }
49
+ return hast;
50
+ }
51
+ } : null
27
52
  }];
28
53
  if (useCSSClasses) transformers.push(tokenStyleNormalizer, toClass);
29
54
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"createTransformerWithState.js","names":["state: SharedRenderState","transformers: ShikiTransformer[]","children: ElementContent[]","tokenStyleNormalizer: ShikiTransformer","style: Record<string, string>"],"sources":["../../src/utils/createTransformerWithState.ts"],"sourcesContent":["import {\n type ShikiTransformerStyleToClass,\n transformerStyleToClass,\n} from '@shikijs/transformers';\nimport type { ElementContent } from 'hast';\n\nimport type { SharedRenderState, ShikiTransformer } from '../types';\nimport { findCodeElement } from './hast_utils';\nimport { processLine } from './processLine';\n\ninterface CreateTransformerWithStateReturn {\n state: SharedRenderState;\n transformers: ShikiTransformer[];\n toClass: ShikiTransformerStyleToClass;\n}\n\nexport function createTransformerWithState(\n useCSSClasses = false\n): CreateTransformerWithStateReturn {\n const state: SharedRenderState = { lineInfo: [] };\n const transformers: ShikiTransformer[] = [\n {\n line(node) {\n // Remove the default class\n delete node.properties.class;\n return node;\n },\n pre(pre) {\n const code = findCodeElement(pre);\n const children: ElementContent[] = [];\n if (code != null) {\n let index = 1;\n for (const node of code.children) {\n if (node.type !== 'element') continue;\n children.push(processLine(node, index, state));\n index++;\n }\n code.children = children;\n }\n return pre;\n },\n },\n ];\n if (useCSSClasses) {\n transformers.push(tokenStyleNormalizer, toClass);\n }\n return { state, transformers, toClass };\n}\n\nconst toClass = transformerStyleToClass({ classPrefix: 'hl-' });\n\n// Create a transformer that converts token color/fontStyle to htmlStyle\n// This needs to run BEFORE transformerStyleToClass\nconst tokenStyleNormalizer: ShikiTransformer = {\n name: 'token-style-normalizer',\n tokens(lines) {\n for (const line of lines) {\n for (const token of line) {\n // Skip if htmlStyle is already set\n if (token.htmlStyle != null) continue;\n\n const style: Record<string, string> = {};\n\n if (token.color != null) {\n style.color = token.color;\n }\n if (token.bgColor != null) {\n style['background-color'] = token.bgColor;\n }\n if (token.fontStyle != null && token.fontStyle !== 0) {\n // FontStyle is a bitmask: 1 = italic, 2 = bold, 4 = underline\n if ((token.fontStyle & 1) !== 0) {\n style['font-style'] = 'italic';\n }\n if ((token.fontStyle & 2) !== 0) {\n style['font-weight'] = 'bold';\n }\n if ((token.fontStyle & 4) !== 0) {\n style['text-decoration'] = 'underline';\n }\n }\n\n // Only set htmlStyle if we have any styles\n if (Object.keys(style).length > 0) {\n token.htmlStyle = style;\n }\n }\n }\n },\n};\n"],"mappings":";;;;;AAgBA,SAAgB,2BACd,gBAAgB,OACkB;CAClC,MAAMA,QAA2B,EAAE,UAAU,EAAE,EAAE;CACjD,MAAMC,eAAmC,CACvC;EACE,KAAK,MAAM;AAET,UAAO,KAAK,WAAW;AACvB,UAAO;;EAET,IAAI,KAAK;GACP,MAAM,OAAO,gBAAgB,IAAI;GACjC,MAAMC,WAA6B,EAAE;AACrC,OAAI,QAAQ,MAAM;IAChB,IAAI,QAAQ;AACZ,SAAK,MAAM,QAAQ,KAAK,UAAU;AAChC,SAAI,KAAK,SAAS,UAAW;AAC7B,cAAS,KAAK,YAAY,MAAM,OAAO,MAAM,CAAC;AAC9C;;AAEF,SAAK,WAAW;;AAElB,UAAO;;EAEV,CACF;AACD,KAAI,cACF,cAAa,KAAK,sBAAsB,QAAQ;AAElD,QAAO;EAAE;EAAO;EAAc;EAAS;;AAGzC,MAAM,UAAU,wBAAwB,EAAE,aAAa,OAAO,CAAC;AAI/D,MAAMC,uBAAyC;CAC7C,MAAM;CACN,OAAO,OAAO;AACZ,OAAK,MAAM,QAAQ,MACjB,MAAK,MAAM,SAAS,MAAM;AAExB,OAAI,MAAM,aAAa,KAAM;GAE7B,MAAMC,QAAgC,EAAE;AAExC,OAAI,MAAM,SAAS,KACjB,OAAM,QAAQ,MAAM;AAEtB,OAAI,MAAM,WAAW,KACnB,OAAM,sBAAsB,MAAM;AAEpC,OAAI,MAAM,aAAa,QAAQ,MAAM,cAAc,GAAG;AAEpD,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,gBAAgB;AAExB,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,iBAAiB;AAEzB,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,qBAAqB;;AAK/B,OAAI,OAAO,KAAK,MAAM,CAAC,SAAS,EAC9B,OAAM,YAAY;;;CAK3B"}
1
+ {"version":3,"file":"createTransformerWithState.js","names":["state: SharedRenderState","transformers: ShikiTransformer[]","children: ElementContent[]","tokenStyleNormalizer: ShikiTransformer","style: Record<string, string>"],"sources":["../../src/utils/createTransformerWithState.ts"],"sourcesContent":["import {\n type ShikiTransformerStyleToClass,\n transformerStyleToClass,\n} from '@shikijs/transformers';\nimport type { ElementContent } from 'hast';\nimport type { ThemedToken } from 'shiki';\n\nimport type { SharedRenderState, ShikiTransformer } from '../types';\nimport { findCodeElement } from './hast_utils';\nimport { processLine } from './processLine';\nimport { wrapTokenFragments } from './wrapTokenFragments';\n\ninterface CreateTransformerWithStateReturn {\n state: SharedRenderState;\n transformers: ShikiTransformer[];\n toClass: ShikiTransformerStyleToClass;\n}\n\ntype TokenWithLineChar = ThemedToken & {\n __lineChar?: number;\n};\n\nexport function createTransformerWithState(\n useTokenTransformer = false,\n useCSSClasses = false\n): CreateTransformerWithStateReturn {\n const state: SharedRenderState = { lineInfo: [] };\n const transformers: ShikiTransformer[] = [\n {\n line(node) {\n // Remove the default class\n delete node.properties.class;\n return node;\n },\n pre(pre) {\n const code = findCodeElement(pre);\n const children: ElementContent[] = [];\n if (code != null) {\n let index = 1;\n for (const node of code.children) {\n if (node.type !== 'element') continue;\n if (useTokenTransformer) {\n wrapTokenFragments(node);\n }\n children.push(processLine(node, index, state));\n index++;\n }\n code.children = children;\n }\n return pre;\n },\n ...(useTokenTransformer\n ? {\n tokens(lines) {\n for (const line of lines) {\n let col = 0;\n for (const token of line) {\n const tokenWithOriginalRange = token as TokenWithLineChar;\n tokenWithOriginalRange.__lineChar ??= col;\n col += token.content.length;\n }\n }\n },\n preprocess(_code, options) {\n options.mergeWhitespaces = 'never';\n },\n span(hast, _line, _char, _lineElement, token) {\n if (token?.offset != null && token.content != null) {\n const tokenWithOriginalRange = token as TokenWithLineChar;\n const tokenChar = tokenWithOriginalRange.__lineChar;\n if (tokenChar != null) {\n hast.properties['data-char'] = tokenChar;\n }\n return hast;\n }\n return hast;\n },\n }\n : null),\n },\n ];\n if (useCSSClasses) {\n transformers.push(tokenStyleNormalizer, toClass);\n }\n return { state, transformers, toClass };\n}\n\nconst toClass = transformerStyleToClass({ classPrefix: 'hl-' });\n\n// Create a transformer that converts token color/fontStyle to htmlStyle\n// This needs to run BEFORE transformerStyleToClass\nconst tokenStyleNormalizer: ShikiTransformer = {\n name: 'token-style-normalizer',\n tokens(lines) {\n for (const line of lines) {\n for (const token of line) {\n // Skip if htmlStyle is already set\n if (token.htmlStyle != null) continue;\n\n const style: Record<string, string> = {};\n\n if (token.color != null) {\n style.color = token.color;\n }\n if (token.bgColor != null) {\n style['background-color'] = token.bgColor;\n }\n if (token.fontStyle != null && token.fontStyle !== 0) {\n // FontStyle is a bitmask: 1 = italic, 2 = bold, 4 = underline\n if ((token.fontStyle & 1) !== 0) {\n style['font-style'] = 'italic';\n }\n if ((token.fontStyle & 2) !== 0) {\n style['font-weight'] = 'bold';\n }\n if ((token.fontStyle & 4) !== 0) {\n style['text-decoration'] = 'underline';\n }\n }\n\n // Only set htmlStyle if we have any styles\n if (Object.keys(style).length > 0) {\n token.htmlStyle = style;\n }\n }\n }\n },\n};\n"],"mappings":";;;;;;AAsBA,SAAgB,2BACd,sBAAsB,OACtB,gBAAgB,OACkB;CAClC,MAAMA,QAA2B,EAAE,UAAU,EAAE,EAAE;CACjD,MAAMC,eAAmC,CACvC;EACE,KAAK,MAAM;AAET,UAAO,KAAK,WAAW;AACvB,UAAO;;EAET,IAAI,KAAK;GACP,MAAM,OAAO,gBAAgB,IAAI;GACjC,MAAMC,WAA6B,EAAE;AACrC,OAAI,QAAQ,MAAM;IAChB,IAAI,QAAQ;AACZ,SAAK,MAAM,QAAQ,KAAK,UAAU;AAChC,SAAI,KAAK,SAAS,UAAW;AAC7B,SAAI,oBACF,oBAAmB,KAAK;AAE1B,cAAS,KAAK,YAAY,MAAM,OAAO,MAAM,CAAC;AAC9C;;AAEF,SAAK,WAAW;;AAElB,UAAO;;EAET,GAAI,sBACA;GACE,OAAO,OAAO;AACZ,SAAK,MAAM,QAAQ,OAAO;KACxB,IAAI,MAAM;AACV,UAAK,MAAM,SAAS,MAAM;MACxB,MAAM,yBAAyB;AAC/B,6BAAuB,eAAe;AACtC,aAAO,MAAM,QAAQ;;;;GAI3B,WAAW,OAAO,SAAS;AACzB,YAAQ,mBAAmB;;GAE7B,KAAK,MAAM,OAAO,OAAO,cAAc,OAAO;AAC5C,QAAI,OAAO,UAAU,QAAQ,MAAM,WAAW,MAAM;KAElD,MAAM,YADyB,MACU;AACzC,SAAI,aAAa,KACf,MAAK,WAAW,eAAe;AAEjC,YAAO;;AAET,WAAO;;GAEV,GACD;EACL,CACF;AACD,KAAI,cACF,cAAa,KAAK,sBAAsB,QAAQ;AAElD,QAAO;EAAE;EAAO;EAAc;EAAS;;AAGzC,MAAM,UAAU,wBAAwB,EAAE,aAAa,OAAO,CAAC;AAI/D,MAAMC,uBAAyC;CAC7C,MAAM;CACN,OAAO,OAAO;AACZ,OAAK,MAAM,QAAQ,MACjB,MAAK,MAAM,SAAS,MAAM;AAExB,OAAI,MAAM,aAAa,KAAM;GAE7B,MAAMC,QAAgC,EAAE;AAExC,OAAI,MAAM,SAAS,KACjB,OAAM,QAAQ,MAAM;AAEtB,OAAI,MAAM,WAAW,KACnB,OAAM,sBAAsB,MAAM;AAEpC,OAAI,MAAM,aAAa,QAAQ,MAAM,cAAc,GAAG;AAEpD,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,gBAAgB;AAExB,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,iBAAiB;AAEzB,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,qBAAqB;;AAK/B,OAAI,OAAO,KAAK,MAAM,CAAC,SAAS,EAC9B,OAAM,YAAY;;;CAK3B"}
@@ -18,6 +18,7 @@ function parseDiffFromFile(oldFile, newFile, options, throwOnError = false) {
18
18
  throwOnError
19
19
  });
20
20
  if (fileData == null) throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");
21
+ if (newFile.lang != null) fileData.lang = newFile.lang;
21
22
  return fileData;
22
23
  }
23
24
 
@@ -1 +1 @@
1
- {"version":3,"file":"parseDiffFromFile.js","names":[],"sources":["../../src/utils/parseDiffFromFile.ts"],"sourcesContent":["import { type CreatePatchOptionsNonabortable, createTwoFilesPatch } from 'diff';\n\nimport type { FileContents, FileDiffMetadata } from '../types';\nimport { processFile } from './parsePatchFiles';\n\n/**\n * Parses a diff from two file contents objects.\n *\n * If both `oldFile` and `newFile` have a `cacheKey`, the resulting diff will\n * automatically get a combined cache key in the format `oldKey:newKey`.\n */\nexport function parseDiffFromFile(\n // FIXME(amadeus): oldFile/newFile should be optional to simulate new/deleted\n // files\n oldFile: FileContents,\n newFile: FileContents,\n options?: CreatePatchOptionsNonabortable,\n throwOnError = false\n): FileDiffMetadata {\n const patch = createTwoFilesPatch(\n oldFile.name,\n newFile.name,\n oldFile.contents,\n newFile.contents,\n oldFile.header,\n newFile.header,\n options\n );\n\n const fileData = processFile(patch, {\n cacheKey: (() => {\n if (oldFile.cacheKey != null && newFile.cacheKey != null) {\n return `${oldFile.cacheKey}:${newFile.cacheKey}`;\n }\n return undefined;\n })(),\n oldFile,\n newFile,\n throwOnError,\n });\n if (fileData == null) {\n throw new Error(\n 'parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?'\n );\n }\n return fileData;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,kBAGd,SACA,SACA,SACA,eAAe,OACG;CAWlB,MAAM,WAAW,YAVH,oBACZ,QAAQ,MACR,QAAQ,MACR,QAAQ,UACR,QAAQ,UACR,QAAQ,QACR,QAAQ,QACR,QACD,EAEmC;EAClC,iBAAiB;AACf,OAAI,QAAQ,YAAY,QAAQ,QAAQ,YAAY,KAClD,QAAO,GAAG,QAAQ,SAAS,GAAG,QAAQ;MAGtC;EACJ;EACA;EACA;EACD,CAAC;AACF,KAAI,YAAY,KACd,OAAM,IAAI,MACR,wGACD;AAEH,QAAO"}
1
+ {"version":3,"file":"parseDiffFromFile.js","names":[],"sources":["../../src/utils/parseDiffFromFile.ts"],"sourcesContent":["import { type CreatePatchOptionsNonabortable, createTwoFilesPatch } from 'diff';\n\nimport type { FileContents, FileDiffMetadata } from '../types';\nimport { processFile } from './parsePatchFiles';\n\n/**\n * Parses a diff from two file contents objects.\n *\n * If both `oldFile` and `newFile` have a `cacheKey`, the resulting diff will\n * automatically get a combined cache key in the format `oldKey:newKey`.\n */\nexport function parseDiffFromFile(\n // FIXME(amadeus): oldFile/newFile should be optional to simulate new/deleted\n // files\n oldFile: FileContents,\n newFile: FileContents,\n options?: CreatePatchOptionsNonabortable,\n throwOnError = false\n): FileDiffMetadata {\n const patch = createTwoFilesPatch(\n oldFile.name,\n newFile.name,\n oldFile.contents,\n newFile.contents,\n oldFile.header,\n newFile.header,\n options\n );\n\n const fileData = processFile(patch, {\n cacheKey: (() => {\n if (oldFile.cacheKey != null && newFile.cacheKey != null) {\n return `${oldFile.cacheKey}:${newFile.cacheKey}`;\n }\n return undefined;\n })(),\n oldFile,\n newFile,\n throwOnError,\n });\n if (fileData == null) {\n throw new Error(\n 'parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?'\n );\n }\n // If we've been provided an override for language in the newFile, let’s pass\n // it through to FileDiffMetadata.\n if (newFile.lang != null) {\n fileData.lang = newFile.lang;\n }\n return fileData;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,kBAGd,SACA,SACA,SACA,eAAe,OACG;CAWlB,MAAM,WAAW,YAVH,oBACZ,QAAQ,MACR,QAAQ,MACR,QAAQ,UACR,QAAQ,UACR,QAAQ,QACR,QAAQ,QACR,QACD,EAEmC;EAClC,iBAAiB;AACf,OAAI,QAAQ,YAAY,QAAQ,QAAQ,YAAY,KAClD,QAAO,GAAG,QAAQ,SAAS,GAAG,QAAQ;MAGtC;EACJ;EACA;EACA;EACD,CAAC;AACF,KAAI,YAAY,KACd,OAAM,IAAI,MACR,wGACD;AAIH,KAAI,QAAQ,QAAQ,KAClB,UAAS,OAAO,QAAQ;AAE1B,QAAO"}
@@ -30,6 +30,7 @@ function renderDiffWithHighlighter(diff, highlighter, options, { forcePlainText,
30
30
  deletionLines: [],
31
31
  additionLines: []
32
32
  };
33
+ const { maxLineDiffLength } = options;
33
34
  const shouldGroupAll = !forcePlainText && !diff.isPartial;
34
35
  const expandedHunksForIteration = forcePlainText ? expandedHunks : void 0;
35
36
  const buckets = /* @__PURE__ */ new Map();
@@ -71,7 +72,8 @@ function renderDiffWithHighlighter(diff, highlighter, options, { forcePlainText,
71
72
  additionLineIndex: bucket.additionContent.length,
72
73
  deletionDecorations: bucket.deletionDecorations,
73
74
  additionDecorations: bucket.additionDecorations,
74
- lineDiffType
75
+ lineDiffType,
76
+ maxLineDiffLength
75
77
  });
76
78
  if (deletionLine != null) {
77
79
  appendContent(diff.deletionLines[deletionLine.lineIndex], deletionLine.lineIndex, bucket.deletionSegments, bucket.deletionContent);
@@ -130,10 +132,11 @@ function renderDiffWithHighlighter(diff, highlighter, options, { forcePlainText,
130
132
  baseThemeType
131
133
  };
132
134
  }
133
- function computeLineDiffDecorations({ deletionLine, additionLine, deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations, lineDiffType }) {
135
+ function computeLineDiffDecorations({ deletionLine, additionLine, deletionLineIndex, additionLineIndex, deletionDecorations, additionDecorations, lineDiffType, maxLineDiffLength }) {
134
136
  if (deletionLine == null || additionLine == null || lineDiffType === "none") return;
135
137
  deletionLine = cleanLastNewline(deletionLine);
136
138
  additionLine = cleanLastNewline(additionLine);
139
+ if (deletionLine.length > maxLineDiffLength || additionLine.length > maxLineDiffLength) return;
137
140
  const lineDiff = lineDiffType === "char" ? diffChars(deletionLine, additionLine) : diffWordsWithSpace(deletionLine, additionLine);
138
141
  const deletionSpans = [];
139
142
  const additionSpans = [];
@@ -217,7 +220,7 @@ function createBucket() {
217
220
  function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo, highlighter, deletionDecorations, additionDecorations, languageOverride, options: { theme: themeOrThemes = DEFAULT_THEMES,...options } }) {
218
221
  const deletionLang = languageOverride ?? getFiletypeFromFileName(deletionFile.name);
219
222
  const additionLang = languageOverride ?? getFiletypeFromFileName(additionFile.name);
220
- const { state, transformers } = createTransformerWithState();
223
+ const { state, transformers } = createTransformerWithState(options.useTokenTransformer);
221
224
  const hastConfig = (() => {
222
225
  return typeof themeOrThemes === "string" ? {
223
226
  ...options,
@@ -1 +1 @@
1
- {"version":3,"file":"renderDiffWithHighlighter.js","names":["DEFAULT_PLAIN_TEXT_OPTIONS: ForceDiffPlainTextOptions","code: RenderDiffFilesResult","deletionSpans: [0 | 1, string][]","additionSpans: [0 | 1, string][]","hastConfig: CodeToHastOptions<DiffsThemeNames>"],"sources":["../../src/utils/renderDiffWithHighlighter.ts"],"sourcesContent":["import { diffChars, diffWordsWithSpace } from 'diff';\n\nimport {\n DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n DEFAULT_THEMES,\n} from '../constants';\nimport type {\n CodeToHastOptions,\n DecorationItem,\n DiffsHighlighter,\n DiffsThemeNames,\n FileContents,\n FileDiffMetadata,\n ForceDiffPlainTextOptions,\n LineDiffTypes,\n LineInfo,\n RenderDiffFilesResult,\n RenderDiffOptions,\n SupportedLanguages,\n ThemedDiffResult,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { createTransformerWithState } from './createTransformerWithState';\nimport { formatCSSVariablePrefix } from './formatCSSVariablePrefix';\nimport { getFiletypeFromFileName } from './getFiletypeFromFileName';\nimport { getHighlighterThemeStyles } from './getHighlighterThemeStyles';\nimport { getLineNodes } from './getLineNodes';\nimport { iterateOverDiff } from './iterateOverDiff';\nimport {\n createDiffSpanDecoration,\n pushOrJoinSpan,\n} from './parseDiffDecorations';\n\nconst DEFAULT_PLAIN_TEXT_OPTIONS: ForceDiffPlainTextOptions = {\n forcePlainText: false,\n};\n\nexport function renderDiffWithHighlighter(\n diff: FileDiffMetadata,\n highlighter: DiffsHighlighter,\n options: RenderDiffOptions,\n {\n forcePlainText,\n startingLine,\n totalLines,\n expandedHunks,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n }: ForceDiffPlainTextOptions = DEFAULT_PLAIN_TEXT_OPTIONS\n): ThemedDiffResult {\n if (forcePlainText) {\n startingLine ??= 0;\n totalLines ??= Infinity;\n } else {\n // If we aren't forcing plain text, then we intentionally do not support\n // ranges for highlighting as that could break the syntax highlighting, we\n // we override any values that may have been passed in. Maybe one day we\n // warn about this?\n startingLine = 0;\n totalLines = Infinity;\n }\n const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;\n const baseThemeType =\n typeof options.theme === 'string'\n ? highlighter.getTheme(options.theme).type\n : undefined;\n const themeStyles = getHighlighterThemeStyles({\n theme: options.theme,\n highlighter,\n });\n\n // If we have a large file and we are rendering the WHOLE plain diff ast,\n // then we should remove the lineDiffType to make sure things render quickly.\n // For highlighted ASTs or windowed highlights, we should just inherit the\n // setting\n const lineDiffType =\n forcePlainText &&\n !isWindowedHighlight &&\n (diff.unifiedLineCount > 1000 || diff.splitLineCount > 1000)\n ? 'none'\n : options.lineDiffType;\n\n const code: RenderDiffFilesResult = {\n deletionLines: [],\n additionLines: [],\n };\n\n const shouldGroupAll = !forcePlainText && !diff.isPartial;\n const expandedHunksForIteration = forcePlainText ? expandedHunks : undefined;\n const buckets = new Map<number, RenderBucket>();\n function getBucketForHunk(hunkIndex: number) {\n const index = shouldGroupAll ? 0 : hunkIndex;\n const bucket = buckets.get(index) ?? createBucket();\n buckets.set(index, bucket);\n return bucket;\n }\n\n function appendContent(\n lineContent: string,\n lineIndex: number,\n segments: HighlightSegment[],\n contentWrapper: FakeArrayType\n ) {\n if (isWindowedHighlight) {\n let segment = segments.at(-1);\n if (\n segment == null ||\n segment.targetIndex + segment.count !== lineIndex\n ) {\n segment = {\n targetIndex: lineIndex,\n originalOffset: contentWrapper.length,\n count: 0,\n };\n segments.push(segment);\n }\n segment.count++;\n }\n contentWrapper.push(lineContent);\n }\n\n iterateOverDiff({\n diff,\n diffStyle: 'both',\n startingLine,\n totalLines,\n expandedHunks: isWindowedHighlight ? expandedHunksForIteration : true,\n collapsedContextThreshold,\n callback: ({ hunkIndex, additionLine, deletionLine, type }) => {\n const bucket = getBucketForHunk(hunkIndex);\n const splitLineIndex =\n additionLine != null\n ? additionLine.splitLineIndex\n : deletionLine.splitLineIndex;\n\n if (type === 'change' && additionLine != null && deletionLine != null) {\n computeLineDiffDecorations({\n additionLine: diff.additionLines[additionLine.lineIndex],\n deletionLine: diff.deletionLines[deletionLine.lineIndex],\n deletionLineIndex: bucket.deletionContent.length,\n additionLineIndex: bucket.additionContent.length,\n deletionDecorations: bucket.deletionDecorations,\n additionDecorations: bucket.additionDecorations,\n lineDiffType,\n });\n }\n\n if (deletionLine != null) {\n appendContent(\n diff.deletionLines[deletionLine.lineIndex],\n deletionLine.lineIndex,\n bucket.deletionSegments,\n bucket.deletionContent\n );\n bucket.deletionInfo.push({\n type: type === 'change' ? 'change-deletion' : type,\n lineNumber: deletionLine.lineNumber,\n altLineNumber:\n type === 'change'\n ? undefined\n : (additionLine.lineNumber ?? undefined),\n lineIndex: `${deletionLine.unifiedLineIndex},${splitLineIndex}`,\n });\n }\n\n if (additionLine != null) {\n appendContent(\n diff.additionLines[additionLine.lineIndex],\n additionLine.lineIndex,\n bucket.additionSegments,\n bucket.additionContent\n );\n bucket.additionInfo.push({\n type: type === 'change' ? 'change-addition' : type,\n lineNumber: additionLine.lineNumber,\n altLineNumber:\n type === 'change'\n ? undefined\n : (deletionLine.lineNumber ?? undefined),\n lineIndex: `${additionLine.unifiedLineIndex},${splitLineIndex}`,\n });\n }\n },\n });\n\n for (const bucket of buckets.values()) {\n if (\n bucket.deletionContent.length === 0 &&\n bucket.additionContent.length === 0\n ) {\n continue;\n }\n\n const deletionFile = {\n name: diff.prevName ?? diff.name,\n contents: bucket.deletionContent.value,\n };\n const additionFile = {\n name: diff.name,\n contents: bucket.additionContent.value,\n };\n const { deletionLines, additionLines } = renderTwoFiles({\n deletionFile,\n deletionInfo: bucket.deletionInfo,\n deletionDecorations: bucket.deletionDecorations,\n\n additionFile,\n additionInfo: bucket.additionInfo,\n additionDecorations: bucket.additionDecorations,\n\n highlighter,\n options,\n languageOverride: forcePlainText ? 'text' : diff.lang,\n });\n\n if (shouldGroupAll) {\n code.deletionLines = deletionLines;\n code.additionLines = additionLines;\n continue;\n }\n\n if (bucket.deletionSegments.length > 0) {\n for (const seg of bucket.deletionSegments) {\n for (let i = 0; i < seg.count; i++) {\n code.deletionLines[seg.targetIndex + i] =\n deletionLines[seg.originalOffset + i];\n }\n }\n } else {\n code.deletionLines.push(...deletionLines);\n }\n if (bucket.additionSegments.length > 0) {\n for (const seg of bucket.additionSegments) {\n for (let i = 0; i < seg.count; i++) {\n code.additionLines[seg.targetIndex + i] =\n additionLines[seg.originalOffset + i];\n }\n }\n } else {\n code.additionLines.push(...additionLines);\n }\n }\n\n return { code, themeStyles, baseThemeType };\n}\n\ninterface ProcessLineDiffProps {\n deletionLine: string | undefined;\n additionLine: string | undefined;\n deletionLineIndex: number;\n additionLineIndex: number;\n deletionDecorations: DecorationItem[];\n additionDecorations: DecorationItem[];\n lineDiffType: LineDiffTypes;\n}\n\nfunction computeLineDiffDecorations({\n deletionLine,\n additionLine,\n deletionLineIndex,\n additionLineIndex,\n deletionDecorations,\n additionDecorations,\n lineDiffType,\n}: ProcessLineDiffProps) {\n if (deletionLine == null || additionLine == null || lineDiffType === 'none') {\n return;\n }\n deletionLine = cleanLastNewline(deletionLine);\n additionLine = cleanLastNewline(additionLine);\n // NOTE(amadeus): Because we visually trim trailing newlines when rendering,\n // we also gotta make sure the diff parsing doesn't include the newline\n // character that could be there...\n const lineDiff =\n lineDiffType === 'char'\n ? diffChars(deletionLine, additionLine)\n : diffWordsWithSpace(deletionLine, additionLine);\n const deletionSpans: [0 | 1, string][] = [];\n const additionSpans: [0 | 1, string][] = [];\n const enableJoin = lineDiffType === 'word-alt';\n const lastItem = lineDiff.at(-1);\n for (const item of lineDiff) {\n const isLastItem = item === lastItem;\n if (!item.added && !item.removed) {\n pushOrJoinSpan({\n item,\n arr: deletionSpans,\n enableJoin,\n isNeutral: true,\n isLastItem,\n });\n pushOrJoinSpan({\n item,\n arr: additionSpans,\n enableJoin,\n isNeutral: true,\n isLastItem,\n });\n } else if (item.removed) {\n pushOrJoinSpan({ item, arr: deletionSpans, enableJoin, isLastItem });\n } else {\n pushOrJoinSpan({ item, arr: additionSpans, enableJoin, isLastItem });\n }\n }\n let spanIndex = 0;\n for (const span of deletionSpans) {\n if (span[0] === 1) {\n deletionDecorations.push(\n createDiffSpanDecoration({\n line: deletionLineIndex,\n spanStart: spanIndex,\n spanLength: span[1].length,\n })\n );\n }\n spanIndex += span[1].length;\n }\n spanIndex = 0;\n for (const span of additionSpans) {\n if (span[0] === 1) {\n additionDecorations.push(\n createDiffSpanDecoration({\n line: additionLineIndex,\n spanStart: spanIndex,\n spanLength: span[1].length,\n })\n );\n }\n spanIndex += span[1].length;\n }\n}\n\ninterface HighlightSegment {\n // The where the highlighted region starts\n originalOffset: number;\n // Where to place the highlighted line in RenderDiffFilesResult\n targetIndex: number;\n // Number of highlighted lines\n count: number;\n}\n\ninterface FakeArrayType {\n push(value: string): void;\n value: string;\n length: number;\n}\n\ninterface RenderBucket {\n deletionContent: FakeArrayType;\n additionContent: FakeArrayType;\n deletionInfo: (LineInfo | undefined)[];\n additionInfo: (LineInfo | undefined)[];\n deletionDecorations: DecorationItem[];\n additionDecorations: DecorationItem[];\n deletionSegments: HighlightSegment[];\n additionSegments: HighlightSegment[];\n}\n\nfunction createBucket(): RenderBucket {\n return {\n deletionContent: {\n push(value: string) {\n this.value += value;\n this.length++;\n },\n value: '',\n length: 0,\n },\n additionContent: {\n push(value: string) {\n this.value += value;\n this.length++;\n },\n value: '',\n length: 0,\n },\n deletionInfo: [],\n additionInfo: [],\n deletionDecorations: [],\n additionDecorations: [],\n deletionSegments: [],\n additionSegments: [],\n };\n}\n\ninterface RenderTwoFilesProps {\n deletionFile: FileContents;\n additionFile: FileContents;\n deletionInfo: (LineInfo | undefined)[];\n additionInfo: (LineInfo | undefined)[];\n deletionDecorations: DecorationItem[];\n additionDecorations: DecorationItem[];\n options: RenderDiffOptions;\n highlighter: DiffsHighlighter;\n languageOverride: SupportedLanguages | undefined;\n}\n\nfunction renderTwoFiles({\n deletionFile,\n additionFile,\n deletionInfo,\n additionInfo,\n highlighter,\n deletionDecorations,\n additionDecorations,\n languageOverride,\n options: { theme: themeOrThemes = DEFAULT_THEMES, ...options },\n}: RenderTwoFilesProps): RenderDiffFilesResult {\n const deletionLang =\n languageOverride ?? getFiletypeFromFileName(deletionFile.name);\n const additionLang =\n languageOverride ?? getFiletypeFromFileName(additionFile.name);\n const { state, transformers } = createTransformerWithState();\n const hastConfig: CodeToHastOptions<DiffsThemeNames> = (() => {\n return typeof themeOrThemes === 'string'\n ? {\n ...options,\n // language will be overwritten for each highlight\n lang: 'text',\n theme: themeOrThemes,\n transformers,\n decorations: undefined,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n }\n : {\n ...options,\n // language will be overwritten for each highlight\n lang: 'text',\n themes: themeOrThemes,\n transformers,\n decorations: undefined,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n };\n })();\n\n const deletionLines = (() => {\n if (deletionFile.contents === '') {\n return [];\n }\n hastConfig.lang = deletionLang;\n state.lineInfo = deletionInfo;\n hastConfig.decorations = deletionDecorations;\n return getLineNodes(\n highlighter.codeToHast(\n cleanLastNewline(deletionFile.contents),\n hastConfig\n )\n );\n })();\n const additionLines = (() => {\n if (additionFile.contents === '') {\n return [];\n }\n hastConfig.lang = additionLang;\n hastConfig.decorations = additionDecorations;\n state.lineInfo = additionInfo;\n return getLineNodes(\n highlighter.codeToHast(\n cleanLastNewline(additionFile.contents),\n hastConfig\n )\n );\n })();\n\n return { deletionLines, additionLines };\n}\n"],"mappings":";;;;;;;;;;;;AAiCA,MAAMA,6BAAwD,EAC5D,gBAAgB,OACjB;AAED,SAAgB,0BACd,MACA,aACA,SACA,EACE,gBACA,cACA,YACA,eACA,4BAA4B,wCACC,4BACb;AAClB,KAAI,gBAAgB;AAClB,mBAAiB;AACjB,iBAAe;QACV;AAKL,iBAAe;AACf,eAAa;;CAEf,MAAM,sBAAsB,eAAe,KAAK,aAAa;CAC7D,MAAM,gBACJ,OAAO,QAAQ,UAAU,WACrB,YAAY,SAAS,QAAQ,MAAM,CAAC,OACpC;CACN,MAAM,cAAc,0BAA0B;EAC5C,OAAO,QAAQ;EACf;EACD,CAAC;CAMF,MAAM,eACJ,kBACA,CAAC,wBACA,KAAK,mBAAmB,OAAQ,KAAK,iBAAiB,OACnD,SACA,QAAQ;CAEd,MAAMC,OAA8B;EAClC,eAAe,EAAE;EACjB,eAAe,EAAE;EAClB;CAED,MAAM,i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;GACP,QAAQ;GACT;EACD,iBAAiB;GACf,KAAK,OAAe;AAClB,SAAK,SAAS;AACd,SAAK;;GAEP,OAAO;GACP,QAAQ;GACT;EACD,cAAc,EAAE;EAChB,cAAc,EAAE;EAChB,qBAAqB,EAAE;EACvB,qBAAqB,EAAE;EACvB,kBAAkB,EAAE;EACpB,kBAAkB,EAAE;EACrB;;AAeH,SAAS,eAAe,EACtB,cACA,cACA,cACA,cACA,aACA,qBACA,qBACA,kBACA,SAAS,EAAE,OAAO,gBAAgB,eAAgB,GAAG,aACR;CAC7C,MAAM,eACJ,oBAAoB,wBAAwB,aAAa,KAAK;CAChE,MAAM,eACJ,oBAAoB,wBAAwB,aAAa,KAAK;CAChE,MAAM,EAAE,OAAO,iBAAiB,4BAA4B;CAC5D,MAAMC,oBAAwD;AAC5D,SAAO,OAAO,kBAAkB,WAC5B;GACE,GAAG;GAEH,MAAM;GACN,OAAO;GACP;GACA,aAAa;GACb,cAAc;GACd,mBAAmB,wBAAwB,QAAQ;GACpD,GACD;GACE,GAAG;GAEH,MAAM;GACN,QAAQ;GACR;GACA,aAAa;GACb,cAAc;GACd,mBAAmB,wBAAwB,QAAQ;GACpD;KACH;AA+BJ,QAAO;EAAE,sBA7BoB;AAC3B,OAAI,aAAa,aAAa,GAC5B,QAAO,EAAE;AAEX,cAAW,OAAO;AAClB,SAAM,WAAW;AACjB,cAAW,cAAc;AACzB,UAAO,aACL,YAAY,WACV,iBAAiB,aAAa,SAAS,EACvC,WACD,CACF;MACC;EAgBoB,sBAfK;AAC3B,OAAI,aAAa,aAAa,GAC5B,QAAO,EAAE;AAEX,cAAW,OAAO;AAClB,cAAW,cAAc;AACzB,SAAM,WAAW;AACjB,UAAO,aACL,YAAY,WACV,iBAAiB,aAAa,SAAS,EACvC,WACD,CACF;MACC;EAEmC"}
1
+ {"version":3,"file":"renderDiffWithHighlighter.js","names":["DEFAULT_PLAIN_TEXT_OPTIONS: ForceDiffPlainTextOptions","code: RenderDiffFilesResult","deletionSpans: [0 | 1, string][]","additionSpans: [0 | 1, string][]","hastConfig: CodeToHastOptions<DiffsThemeNames>"],"sources":["../../src/utils/renderDiffWithHighlighter.ts"],"sourcesContent":["import { diffChars, diffWordsWithSpace } from 'diff';\n\nimport {\n DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n DEFAULT_THEMES,\n} from '../constants';\nimport type {\n CodeToHastOptions,\n DecorationItem,\n DiffsHighlighter,\n DiffsThemeNames,\n FileContents,\n FileDiffMetadata,\n ForceDiffPlainTextOptions,\n LineDiffTypes,\n LineInfo,\n RenderDiffFilesResult,\n RenderDiffOptions,\n SupportedLanguages,\n ThemedDiffResult,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { createTransformerWithState } from './createTransformerWithState';\nimport { formatCSSVariablePrefix } from './formatCSSVariablePrefix';\nimport { getFiletypeFromFileName } from './getFiletypeFromFileName';\nimport { getHighlighterThemeStyles } from './getHighlighterThemeStyles';\nimport { getLineNodes } from './getLineNodes';\nimport { iterateOverDiff } from './iterateOverDiff';\nimport {\n createDiffSpanDecoration,\n pushOrJoinSpan,\n} from './parseDiffDecorations';\n\nconst DEFAULT_PLAIN_TEXT_OPTIONS: ForceDiffPlainTextOptions = {\n forcePlainText: false,\n};\n\nexport function renderDiffWithHighlighter(\n diff: FileDiffMetadata,\n highlighter: DiffsHighlighter,\n options: RenderDiffOptions,\n {\n forcePlainText,\n startingLine,\n totalLines,\n expandedHunks,\n collapsedContextThreshold = DEFAULT_COLLAPSED_CONTEXT_THRESHOLD,\n }: ForceDiffPlainTextOptions = DEFAULT_PLAIN_TEXT_OPTIONS\n): ThemedDiffResult {\n if (forcePlainText) {\n startingLine ??= 0;\n totalLines ??= Infinity;\n } else {\n // If we aren't forcing plain text, then we intentionally do not support\n // ranges for highlighting as that could break the syntax highlighting, we\n // we override any values that may have been passed in. Maybe one day we\n // warn about this?\n startingLine = 0;\n totalLines = Infinity;\n }\n const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;\n const baseThemeType =\n typeof options.theme === 'string'\n ? highlighter.getTheme(options.theme).type\n : undefined;\n const themeStyles = getHighlighterThemeStyles({\n theme: options.theme,\n highlighter,\n });\n\n // If we have a large file and we are rendering the WHOLE plain diff ast,\n // then we should remove the lineDiffType to make sure things render quickly.\n // For highlighted ASTs or windowed highlights, we should just inherit the\n // setting\n const lineDiffType =\n forcePlainText &&\n !isWindowedHighlight &&\n (diff.unifiedLineCount > 1000 || diff.splitLineCount > 1000)\n ? 'none'\n : options.lineDiffType;\n\n const code: RenderDiffFilesResult = {\n deletionLines: [],\n additionLines: [],\n };\n\n const { maxLineDiffLength } = options;\n const shouldGroupAll = !forcePlainText && !diff.isPartial;\n const expandedHunksForIteration = forcePlainText ? expandedHunks : undefined;\n const buckets = new Map<number, RenderBucket>();\n function getBucketForHunk(hunkIndex: number) {\n const index = shouldGroupAll ? 0 : hunkIndex;\n const bucket = buckets.get(index) ?? createBucket();\n buckets.set(index, bucket);\n return bucket;\n }\n\n function appendContent(\n lineContent: string,\n lineIndex: number,\n segments: HighlightSegment[],\n contentWrapper: FakeArrayType\n ) {\n if (isWindowedHighlight) {\n let segment = segments.at(-1);\n if (\n segment == null ||\n segment.targetIndex + segment.count !== lineIndex\n ) {\n segment = {\n targetIndex: lineIndex,\n originalOffset: contentWrapper.length,\n count: 0,\n };\n segments.push(segment);\n }\n segment.count++;\n }\n contentWrapper.push(lineContent);\n }\n\n iterateOverDiff({\n diff,\n diffStyle: 'both',\n startingLine,\n totalLines,\n expandedHunks: isWindowedHighlight ? expandedHunksForIteration : true,\n collapsedContextThreshold,\n callback: ({ hunkIndex, additionLine, deletionLine, type }) => {\n const bucket = getBucketForHunk(hunkIndex);\n const splitLineIndex =\n additionLine != null\n ? additionLine.splitLineIndex\n : deletionLine.splitLineIndex;\n\n if (type === 'change' && additionLine != null && deletionLine != null) {\n computeLineDiffDecorations({\n additionLine: diff.additionLines[additionLine.lineIndex],\n deletionLine: diff.deletionLines[deletionLine.lineIndex],\n deletionLineIndex: bucket.deletionContent.length,\n additionLineIndex: bucket.additionContent.length,\n deletionDecorations: bucket.deletionDecorations,\n additionDecorations: bucket.additionDecorations,\n lineDiffType,\n maxLineDiffLength,\n });\n }\n\n if (deletionLine != null) {\n appendContent(\n diff.deletionLines[deletionLine.lineIndex],\n deletionLine.lineIndex,\n bucket.deletionSegments,\n bucket.deletionContent\n );\n bucket.deletionInfo.push({\n type: type === 'change' ? 'change-deletion' : type,\n lineNumber: deletionLine.lineNumber,\n altLineNumber:\n type === 'change'\n ? undefined\n : (additionLine.lineNumber ?? undefined),\n lineIndex: `${deletionLine.unifiedLineIndex},${splitLineIndex}`,\n });\n }\n\n if (additionLine != null) {\n appendContent(\n diff.additionLines[additionLine.lineIndex],\n additionLine.lineIndex,\n bucket.additionSegments,\n bucket.additionContent\n );\n bucket.additionInfo.push({\n type: type === 'change' ? 'change-addition' : type,\n lineNumber: additionLine.lineNumber,\n altLineNumber:\n type === 'change'\n ? undefined\n : (deletionLine.lineNumber ?? undefined),\n lineIndex: `${additionLine.unifiedLineIndex},${splitLineIndex}`,\n });\n }\n },\n });\n\n for (const bucket of buckets.values()) {\n if (\n bucket.deletionContent.length === 0 &&\n bucket.additionContent.length === 0\n ) {\n continue;\n }\n\n const deletionFile = {\n name: diff.prevName ?? diff.name,\n contents: bucket.deletionContent.value,\n };\n const additionFile = {\n name: diff.name,\n contents: bucket.additionContent.value,\n };\n const { deletionLines, additionLines } = renderTwoFiles({\n deletionFile,\n deletionInfo: bucket.deletionInfo,\n deletionDecorations: bucket.deletionDecorations,\n\n additionFile,\n additionInfo: bucket.additionInfo,\n additionDecorations: bucket.additionDecorations,\n\n highlighter,\n options,\n languageOverride: forcePlainText ? 'text' : diff.lang,\n });\n\n if (shouldGroupAll) {\n code.deletionLines = deletionLines;\n code.additionLines = additionLines;\n continue;\n }\n\n if (bucket.deletionSegments.length > 0) {\n for (const seg of bucket.deletionSegments) {\n for (let i = 0; i < seg.count; i++) {\n code.deletionLines[seg.targetIndex + i] =\n deletionLines[seg.originalOffset + i];\n }\n }\n } else {\n code.deletionLines.push(...deletionLines);\n }\n if (bucket.additionSegments.length > 0) {\n for (const seg of bucket.additionSegments) {\n for (let i = 0; i < seg.count; i++) {\n code.additionLines[seg.targetIndex + i] =\n additionLines[seg.originalOffset + i];\n }\n }\n } else {\n code.additionLines.push(...additionLines);\n }\n }\n\n return { code, themeStyles, baseThemeType };\n}\n\ninterface ProcessLineDiffProps {\n deletionLine: string | undefined;\n additionLine: string | undefined;\n deletionLineIndex: number;\n additionLineIndex: number;\n deletionDecorations: DecorationItem[];\n additionDecorations: DecorationItem[];\n lineDiffType: LineDiffTypes;\n maxLineDiffLength: number;\n}\n\nfunction computeLineDiffDecorations({\n deletionLine,\n additionLine,\n deletionLineIndex,\n additionLineIndex,\n deletionDecorations,\n additionDecorations,\n lineDiffType,\n maxLineDiffLength,\n}: ProcessLineDiffProps) {\n if (deletionLine == null || additionLine == null || lineDiffType === 'none') {\n return;\n }\n deletionLine = cleanLastNewline(deletionLine);\n additionLine = cleanLastNewline(additionLine);\n // If we have really long lines, we probably shouldn't compute diffs on them.\n if (\n deletionLine.length > maxLineDiffLength ||\n additionLine.length > maxLineDiffLength\n ) {\n return;\n }\n // NOTE(amadeus): Because we visually trim trailing newlines when rendering,\n // we also gotta make sure the diff parsing doesn't include the newline\n // character that could be there...\n const lineDiff =\n lineDiffType === 'char'\n ? diffChars(deletionLine, additionLine)\n : diffWordsWithSpace(deletionLine, additionLine);\n const deletionSpans: [0 | 1, string][] = [];\n const additionSpans: [0 | 1, string][] = [];\n const enableJoin = lineDiffType === 'word-alt';\n const lastItem = lineDiff.at(-1);\n for (const item of lineDiff) {\n const isLastItem = item === lastItem;\n if (!item.added && !item.removed) {\n pushOrJoinSpan({\n item,\n arr: deletionSpans,\n enableJoin,\n isNeutral: true,\n isLastItem,\n });\n pushOrJoinSpan({\n item,\n arr: additionSpans,\n enableJoin,\n isNeutral: true,\n isLastItem,\n });\n } else if (item.removed) {\n pushOrJoinSpan({ item, arr: deletionSpans, enableJoin, isLastItem });\n } else {\n pushOrJoinSpan({ item, arr: additionSpans, enableJoin, isLastItem });\n }\n }\n let spanIndex = 0;\n for (const span of deletionSpans) {\n if (span[0] === 1) {\n deletionDecorations.push(\n createDiffSpanDecoration({\n line: deletionLineIndex,\n spanStart: spanIndex,\n spanLength: span[1].length,\n })\n );\n }\n spanIndex += span[1].length;\n }\n spanIndex = 0;\n for (const span of additionSpans) {\n if (span[0] === 1) {\n additionDecorations.push(\n createDiffSpanDecoration({\n line: additionLineIndex,\n spanStart: spanIndex,\n spanLength: span[1].length,\n })\n );\n }\n spanIndex += span[1].length;\n }\n}\n\ninterface HighlightSegment {\n // The where the highlighted region starts\n originalOffset: number;\n // Where to place the highlighted line in RenderDiffFilesResult\n targetIndex: number;\n // Number of highlighted lines\n count: number;\n}\n\ninterface FakeArrayType {\n push(value: string): void;\n value: string;\n length: number;\n}\n\ninterface RenderBucket {\n deletionContent: FakeArrayType;\n additionContent: FakeArrayType;\n deletionInfo: (LineInfo | undefined)[];\n additionInfo: (LineInfo | undefined)[];\n deletionDecorations: DecorationItem[];\n additionDecorations: DecorationItem[];\n deletionSegments: HighlightSegment[];\n additionSegments: HighlightSegment[];\n}\n\nfunction createBucket(): RenderBucket {\n return {\n deletionContent: {\n push(value: string) {\n this.value += value;\n this.length++;\n },\n value: '',\n length: 0,\n },\n additionContent: {\n push(value: string) {\n this.value += value;\n this.length++;\n },\n value: '',\n length: 0,\n },\n deletionInfo: [],\n additionInfo: [],\n deletionDecorations: [],\n additionDecorations: [],\n deletionSegments: [],\n additionSegments: [],\n };\n}\n\ninterface RenderTwoFilesProps {\n deletionFile: FileContents;\n additionFile: FileContents;\n deletionInfo: (LineInfo | undefined)[];\n additionInfo: (LineInfo | undefined)[];\n deletionDecorations: DecorationItem[];\n additionDecorations: DecorationItem[];\n options: RenderDiffOptions;\n highlighter: DiffsHighlighter;\n languageOverride: SupportedLanguages | undefined;\n}\n\nfunction renderTwoFiles({\n deletionFile,\n additionFile,\n deletionInfo,\n additionInfo,\n highlighter,\n deletionDecorations,\n additionDecorations,\n languageOverride,\n options: { theme: themeOrThemes = DEFAULT_THEMES, ...options },\n}: RenderTwoFilesProps): RenderDiffFilesResult {\n const deletionLang =\n languageOverride ?? getFiletypeFromFileName(deletionFile.name);\n const additionLang =\n languageOverride ?? getFiletypeFromFileName(additionFile.name);\n const { state, transformers } = createTransformerWithState(\n options.useTokenTransformer\n );\n const hastConfig: CodeToHastOptions<DiffsThemeNames> = (() => {\n return typeof themeOrThemes === 'string'\n ? {\n ...options,\n // language will be overwritten for each highlight\n lang: 'text',\n theme: themeOrThemes,\n transformers,\n decorations: undefined,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n }\n : {\n ...options,\n // language will be overwritten for each highlight\n lang: 'text',\n themes: themeOrThemes,\n transformers,\n decorations: undefined,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n };\n })();\n\n const deletionLines = (() => {\n if (deletionFile.contents === '') {\n return [];\n }\n hastConfig.lang = deletionLang;\n state.lineInfo = deletionInfo;\n hastConfig.decorations = deletionDecorations;\n return getLineNodes(\n highlighter.codeToHast(\n cleanLastNewline(deletionFile.contents),\n hastConfig\n )\n );\n })();\n const additionLines = (() => {\n if (additionFile.contents === '') {\n return [];\n }\n hastConfig.lang = additionLang;\n hastConfig.decorations = additionDecorations;\n state.lineInfo = additionInfo;\n return getLineNodes(\n highlighter.codeToHast(\n cleanLastNewline(additionFile.contents),\n hastConfig\n )\n );\n })();\n\n return { deletionLines, additionLines };\n}\n"],"mappings":";;;;;;;;;;;;AAiCA,MAAMA,6BAAwD,EAC5D,gBAAgB,OACjB;AAED,SAAgB,0BACd,MACA,aACA,SACA,EACE,gBACA,cACA,YACA,eACA,4BAA4B,wCACC,4BACb;AAClB,KAAI,gBAAgB;AAClB,mBAAiB;AACjB,iBAAe;QACV;AAKL,iBAAe;AACf,eAAa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a,aAAa,GAC5B,QAAO,EAAE;AAEX,cAAW,OAAO;AAClB,SAAM,WAAW;AACjB,cAAW,cAAc;AACzB,UAAO,aACL,YAAY,WACV,iBAAiB,aAAa,SAAS,EACvC,WACD,CACF;MACC;EAgBoB,sBAfK;AAC3B,OAAI,aAAa,aAAa,GAC5B,QAAO,EAAE;AAEX,cAAW,OAAO;AAClB,cAAW,cAAc;AACzB,SAAM,WAAW;AACjB,UAAO,aACL,YAAY,WACV,iBAAiB,aAAa,SAAS,EACvC,WACD,CACF;MACC;EAEmC"}
@@ -3,7 +3,8 @@ import { DiffsHighlighter, FileContents, ForceFilePlainTextOptions, RenderFileOp
3
3
  //#region src/utils/renderFileWithHighlighter.d.ts
4
4
  declare function renderFileWithHighlighter(file: FileContents, highlighter: DiffsHighlighter, {
5
5
  theme,
6
- tokenizeMaxLineLength
6
+ tokenizeMaxLineLength,
7
+ useTokenTransformer
7
8
  }: RenderFileOptions, {
8
9
  forcePlainText,
9
10
  startingLine,
@@ -1 +1 @@
1
- {"version":3,"file":"renderFileWithHighlighter.d.ts","names":["DiffsHighlighter","FileContents","ForceFilePlainTextOptions","RenderFileOptions","ThemedFileResult","renderFileWithHighlighter","theme","tokenizeMaxLineLength","forcePlainText","startingLine","totalLines","lines"],"sources":["../../src/utils/renderFileWithHighlighter.d.ts"],"sourcesContent":["import type { DiffsHighlighter, FileContents, ForceFilePlainTextOptions, RenderFileOptions, ThemedFileResult } from '../types';\nexport declare function renderFileWithHighlighter(file: FileContents, highlighter: DiffsHighlighter, { theme, tokenizeMaxLineLength }: RenderFileOptions, { forcePlainText, startingLine, totalLines, lines }?: ForceFilePlainTextOptions): ThemedFileResult;\n//# sourceMappingURL=renderFileWithHighlighter.d.ts.map"],"mappings":";;;iBACwBK,yBAAAA,OAAgCJ,2BAA2BD;;;GAAoDG;;;;;IAAyED,4BAA4BE"}
1
+ {"version":3,"file":"renderFileWithHighlighter.d.ts","names":["DiffsHighlighter","FileContents","ForceFilePlainTextOptions","RenderFileOptions","ThemedFileResult","renderFileWithHighlighter","theme","tokenizeMaxLineLength","useTokenTransformer","forcePlainText","startingLine","totalLines","lines"],"sources":["../../src/utils/renderFileWithHighlighter.d.ts"],"sourcesContent":["import type { DiffsHighlighter, FileContents, ForceFilePlainTextOptions, RenderFileOptions, ThemedFileResult } from '../types';\nexport declare function renderFileWithHighlighter(file: FileContents, highlighter: DiffsHighlighter, { theme, tokenizeMaxLineLength, useTokenTransformer }: RenderFileOptions, { forcePlainText, startingLine, totalLines, lines }?: ForceFilePlainTextOptions): ThemedFileResult;\n//# sourceMappingURL=renderFileWithHighlighter.d.ts.map"],"mappings":";;;iBACwBK,yBAAAA,OAAgCJ,2BAA2BD;;;;GAAyEG;;;;;IAAyED,4BAA4BE"}
@@ -10,7 +10,7 @@ import { splitFileContents } from "./splitFileContents.js";
10
10
 
11
11
  //#region src/utils/renderFileWithHighlighter.ts
12
12
  const DEFAULT_PLAIN_TEXT_OPTIONS = { forcePlainText: false };
13
- function renderFileWithHighlighter(file, highlighter, { theme = DEFAULT_THEMES, tokenizeMaxLineLength }, { forcePlainText, startingLine, totalLines, lines } = DEFAULT_PLAIN_TEXT_OPTIONS) {
13
+ function renderFileWithHighlighter(file, highlighter, { theme = DEFAULT_THEMES, tokenizeMaxLineLength, useTokenTransformer }, { forcePlainText, startingLine, totalLines, lines } = DEFAULT_PLAIN_TEXT_OPTIONS) {
14
14
  if (forcePlainText) {
15
15
  startingLine ??= 0;
16
16
  totalLines ??= Infinity;
@@ -19,7 +19,7 @@ function renderFileWithHighlighter(file, highlighter, { theme = DEFAULT_THEMES,
19
19
  totalLines = Infinity;
20
20
  }
21
21
  const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;
22
- const { state, transformers } = createTransformerWithState();
22
+ const { state, transformers } = createTransformerWithState(useTokenTransformer);
23
23
  const lang = forcePlainText ? "text" : file.lang ?? getFiletypeFromFileName(file.name);
24
24
  const baseThemeType = typeof theme === "string" ? highlighter.getTheme(theme).type : void 0;
25
25
  const themeStyles = getHighlighterThemeStyles({
@@ -1 +1 @@
1
- {"version":3,"file":"renderFileWithHighlighter.js","names":["DEFAULT_PLAIN_TEXT_OPTIONS: ForceFilePlainTextOptions","hastConfig: CodeToHastOptions<DiffsThemeNames>","windowContent: string"],"sources":["../../src/utils/renderFileWithHighlighter.ts"],"sourcesContent":["import { DEFAULT_THEMES } from '../constants';\nimport type {\n CodeToHastOptions,\n DiffsHighlighter,\n DiffsThemeNames,\n FileContents,\n ForceFilePlainTextOptions,\n RenderFileOptions,\n ThemedFileResult,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { createTransformerWithState } from './createTransformerWithState';\nimport { formatCSSVariablePrefix } from './formatCSSVariablePrefix';\nimport { getFiletypeFromFileName } from './getFiletypeFromFileName';\nimport { getHighlighterThemeStyles } from './getHighlighterThemeStyles';\nimport { getLineNodes } from './getLineNodes';\nimport { iterateOverFile } from './iterateOverFile';\nimport { splitFileContents } from './splitFileContents';\n\nconst DEFAULT_PLAIN_TEXT_OPTIONS: ForceFilePlainTextOptions = {\n forcePlainText: false,\n};\n\nexport function renderFileWithHighlighter(\n file: FileContents,\n highlighter: DiffsHighlighter,\n { theme = DEFAULT_THEMES, tokenizeMaxLineLength }: RenderFileOptions,\n {\n forcePlainText,\n startingLine,\n totalLines,\n lines,\n }: ForceFilePlainTextOptions = DEFAULT_PLAIN_TEXT_OPTIONS\n): ThemedFileResult {\n if (forcePlainText) {\n startingLine ??= 0;\n totalLines ??= Infinity;\n } else {\n // If we aren't forcing plain text, then we intentionally do not support\n // ranges for highlighting as that could break the syntax highlighting, we\n // we override any values that may have been passed in. Maybe one day we\n // warn about this?\n startingLine = 0;\n totalLines = Infinity;\n }\n const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;\n const { state, transformers } = createTransformerWithState();\n const lang = forcePlainText\n ? 'text'\n : (file.lang ?? getFiletypeFromFileName(file.name));\n const baseThemeType =\n typeof theme === 'string' ? highlighter.getTheme(theme).type : undefined;\n const themeStyles = getHighlighterThemeStyles({\n theme,\n highlighter,\n });\n state.lineInfo = (shikiLineNumber: number) => ({\n type: 'context',\n lineIndex: shikiLineNumber - 1 + startingLine,\n lineNumber: shikiLineNumber + startingLine,\n });\n const hastConfig: CodeToHastOptions<DiffsThemeNames> = (() => {\n if (typeof theme === 'string') {\n return {\n lang,\n theme,\n transformers,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n tokenizeMaxLineLength,\n };\n }\n return {\n lang,\n themes: theme,\n transformers,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n tokenizeMaxLineLength,\n };\n })();\n const highlightedLines = getLineNodes(\n highlighter.codeToHast(\n isWindowedHighlight\n ? extractWindowedFileContent(\n lines ?? splitFileContents(file.contents),\n startingLine,\n totalLines\n )\n : cleanLastNewline(file.contents),\n hastConfig\n )\n );\n\n // Create sparse array for windowed rendering\n const code = isWindowedHighlight ? new Array(startingLine) : highlightedLines;\n if (isWindowedHighlight) {\n code.push(...highlightedLines);\n }\n\n return { code, themeStyles, baseThemeType };\n}\n\nfunction extractWindowedFileContent(\n lines: string[],\n startingLine: number,\n totalLines: number\n): string {\n let windowContent: string = '';\n iterateOverFile({\n lines,\n startingLine,\n totalLines,\n callback({ content }) {\n windowContent += content;\n },\n });\n return windowContent;\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAMA,6BAAwD,EAC5D,gBAAgB,OACjB;AAED,SAAgB,0BACd,MACA,aACA,EAAE,QAAQ,gBAAgB,yBAC1B,EACE,gBACA,cACA,YACA,UAC6B,4BACb;AAClB,KAAI,gBAAgB;AAClB,mBAAiB;AACjB,iBAAe;QACV;AAKL,iBAAe;AACf,eAAa;;CAEf,MAAM,sBAAsB,eAAe,KAAK,aAAa;CAC7D,MAAM,EAAE,OAAO,iBAAiB,4BAA4B;CAC5D,MAAM,OAAO,iBACT,SACC,KAAK,QAAQ,wBAAwB,KAAK,KAAK;CACpD,MAAM,gBACJ,OAAO,UAAU,WAAW,YAAY,SAAS,MAAM,CAAC,OAAO;CACjE,MAAM,cAAc,0BAA0B;EAC5C;EACA;EACD,CAAC;AACF,OAAM,YAAY,qBAA6B;EAC7C,MAAM;EACN,WAAW,kBAAkB,IAAI;EACjC,YAAY,kBAAkB;EAC/B;CACD,MAAMC,oBAAwD;AAC5D,MAAI,OAAO,UAAU,SACnB,QAAO;GACL;GACA;GACA;GACA,cAAc;GACd,mBAAmB,wBAAwB,QAAQ;GACnD;GACD;AAEH,SAAO;GACL;GACA,QAAQ;GACR;GACA,cAAc;GACd,mBAAmB,wBAAwB,QAAQ;GACnD;GACD;KACC;CACJ,MAAM,mBAAmB,aACvB,YAAY,WACV,sBACI,2BACE,SAAS,kBAAkB,KAAK,SAAS,EACzC,cACA,WACD,GACD,iBAAiB,KAAK,SAAS,EACnC,WACD,CACF;CAGD,MAAM,OAAO,sBAAsB,IAAI,MAAM,aAAa,GAAG;AAC7D,KAAI,oBACF,MAAK,KAAK,GAAG,iBAAiB;AAGhC,QAAO;EAAE;EAAM;EAAa;EAAe;;AAG7C,SAAS,2BACP,OACA,cACA,YACQ;CACR,IAAIC,gBAAwB;AAC5B,iBAAgB;EACd;EACA;EACA;EACA,SAAS,EAAE,WAAW;AACpB,oBAAiB;;EAEpB,CAAC;AACF,QAAO"}
1
+ {"version":3,"file":"renderFileWithHighlighter.js","names":["DEFAULT_PLAIN_TEXT_OPTIONS: ForceFilePlainTextOptions","hastConfig: CodeToHastOptions<DiffsThemeNames>","windowContent: string"],"sources":["../../src/utils/renderFileWithHighlighter.ts"],"sourcesContent":["import { DEFAULT_THEMES } from '../constants';\nimport type {\n CodeToHastOptions,\n DiffsHighlighter,\n DiffsThemeNames,\n FileContents,\n ForceFilePlainTextOptions,\n RenderFileOptions,\n ThemedFileResult,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { createTransformerWithState } from './createTransformerWithState';\nimport { formatCSSVariablePrefix } from './formatCSSVariablePrefix';\nimport { getFiletypeFromFileName } from './getFiletypeFromFileName';\nimport { getHighlighterThemeStyles } from './getHighlighterThemeStyles';\nimport { getLineNodes } from './getLineNodes';\nimport { iterateOverFile } from './iterateOverFile';\nimport { splitFileContents } from './splitFileContents';\n\nconst DEFAULT_PLAIN_TEXT_OPTIONS: ForceFilePlainTextOptions = {\n forcePlainText: false,\n};\n\nexport function renderFileWithHighlighter(\n file: FileContents,\n highlighter: DiffsHighlighter,\n {\n theme = DEFAULT_THEMES,\n tokenizeMaxLineLength,\n useTokenTransformer,\n }: RenderFileOptions,\n {\n forcePlainText,\n startingLine,\n totalLines,\n lines,\n }: ForceFilePlainTextOptions = DEFAULT_PLAIN_TEXT_OPTIONS\n): ThemedFileResult {\n if (forcePlainText) {\n startingLine ??= 0;\n totalLines ??= Infinity;\n } else {\n // If we aren't forcing plain text, then we intentionally do not support\n // ranges for highlighting as that could break the syntax highlighting, we\n // we override any values that may have been passed in. Maybe one day we\n // warn about this?\n startingLine = 0;\n totalLines = Infinity;\n }\n const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;\n const { state, transformers } =\n createTransformerWithState(useTokenTransformer);\n const lang = forcePlainText\n ? 'text'\n : (file.lang ?? getFiletypeFromFileName(file.name));\n const baseThemeType =\n typeof theme === 'string' ? highlighter.getTheme(theme).type : undefined;\n const themeStyles = getHighlighterThemeStyles({\n theme,\n highlighter,\n });\n state.lineInfo = (shikiLineNumber: number) => ({\n type: 'context',\n lineIndex: shikiLineNumber - 1 + startingLine,\n lineNumber: shikiLineNumber + startingLine,\n });\n const hastConfig: CodeToHastOptions<DiffsThemeNames> = (() => {\n if (typeof theme === 'string') {\n return {\n lang,\n theme,\n transformers,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n tokenizeMaxLineLength,\n };\n }\n return {\n lang,\n themes: theme,\n transformers,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n tokenizeMaxLineLength,\n };\n })();\n const highlightedLines = getLineNodes(\n highlighter.codeToHast(\n isWindowedHighlight\n ? extractWindowedFileContent(\n lines ?? splitFileContents(file.contents),\n startingLine,\n totalLines\n )\n : cleanLastNewline(file.contents),\n hastConfig\n )\n );\n\n // Create sparse array for windowed rendering\n const code = isWindowedHighlight ? new Array(startingLine) : highlightedLines;\n if (isWindowedHighlight) {\n code.push(...highlightedLines);\n }\n\n return { code, themeStyles, baseThemeType };\n}\n\nfunction extractWindowedFileContent(\n lines: string[],\n startingLine: number,\n totalLines: number\n): string {\n let windowContent: string = '';\n iterateOverFile({\n lines,\n startingLine,\n totalLines,\n callback({ content }) {\n windowContent += content;\n },\n });\n return windowContent;\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAMA,6BAAwD,EAC5D,gBAAgB,OACjB;AAED,SAAgB,0BACd,MACA,aACA,EACE,QAAQ,gBACR,uBACA,uBAEF,EACE,gBACA,cACA,YACA,UAC6B,4BACb;AAClB,KAAI,gBAAgB;AAClB,mBAAiB;AACjB,iBAAe;QACV;AAKL,iBAAe;AACf,eAAa;;CAEf,MAAM,sBAAsB,eAAe,KAAK,aAAa;CAC7D,MAAM,EAAE,OAAO,iBACb,2BAA2B,oBAAoB;CACjD,MAAM,OAAO,iBACT,SACC,KAAK,QAAQ,wBAAwB,KAAK,KAAK;CACpD,MAAM,gBACJ,OAAO,UAAU,WAAW,YAAY,SAAS,MAAM,CAAC,OAAO;CACjE,MAAM,cAAc,0BAA0B;EAC5C;EACA;EACD,CAAC;AACF,OAAM,YAAY,qBAA6B;EAC7C,MAAM;EACN,WAAW,kBAAkB,IAAI;EACjC,YAAY,kBAAkB;EAC/B;CACD,MAAMC,oBAAwD;AAC5D,MAAI,OAAO,UAAU,SACnB,QAAO;GACL;GACA;GACA;GACA,cAAc;GACd,mBAAmB,wBAAwB,QAAQ;GACnD;GACD;AAEH,SAAO;GACL;GACA,QAAQ;GACR;GACA,cAAc;GACd,mBAAmB,wBAAwB,QAAQ;GACnD;GACD;KACC;CACJ,MAAM,mBAAmB,aACvB,YAAY,WACV,sBACI,2BACE,SAAS,kBAAkB,KAAK,SAAS,EACzC,cACA,WACD,GACD,iBAAiB,KAAK,SAAS,EACnC,WACD,CACF;CAGD,MAAM,OAAO,sBAAsB,IAAI,MAAM,aAAa,GAAG;AAC7D,KAAI,oBACF,MAAK,KAAK,GAAG,iBAAiB;AAGhC,QAAO;EAAE;EAAM;EAAa;EAAe;;AAG7C,SAAS,2BACP,OACA,cACA,YACQ;CACR,IAAIC,gBAAwB;AAC5B,iBAAgB;EACd;EACA;EACA;EACA,SAAS,EAAE,WAAW;AACpB,oBAAiB;;EAEpB,CAAC;AACF,QAAO"}
@@ -0,0 +1,9 @@
1
+ import { InteractionManagerBaseOptions } from "../managers/InteractionManager.js";
2
+
3
+ //#region src/utils/shouldUseTokenTransformer.d.ts
4
+ declare function shouldUseTokenTransformer<TMode extends 'file' | 'diff'>(options: InteractionManagerBaseOptions<TMode> & {
5
+ useTokenTransformer?: boolean;
6
+ }): boolean;
7
+ //#endregion
8
+ export { shouldUseTokenTransformer };
9
+ //# sourceMappingURL=shouldUseTokenTransformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shouldUseTokenTransformer.d.ts","names":["InteractionManagerBaseOptions","shouldUseTokenTransformer","TMode"],"sources":["../../src/utils/shouldUseTokenTransformer.d.ts"],"sourcesContent":["import type { InteractionManagerBaseOptions } from '../managers/InteractionManager';\nexport declare function shouldUseTokenTransformer<TMode extends 'file' | 'diff'>(options: InteractionManagerBaseOptions<TMode> & {\n useTokenTransformer?: boolean;\n}): boolean;\n//# sourceMappingURL=shouldUseTokenTransformer.d.ts.map"],"mappings":";;;iBACwBC,kEAAkED,8BAA8BE;;AAAxH,CAAA,CAAA,EAAwBD,OAAAA"}
@@ -0,0 +1,8 @@
1
+ //#region src/utils/shouldUseTokenTransformer.ts
2
+ function shouldUseTokenTransformer(options) {
3
+ return options.useTokenTransformer === true || options.onTokenClick != null || options.onTokenEnter != null || options.onTokenLeave != null;
4
+ }
5
+
6
+ //#endregion
7
+ export { shouldUseTokenTransformer };
8
+ //# sourceMappingURL=shouldUseTokenTransformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shouldUseTokenTransformer.js","names":[],"sources":["../../src/utils/shouldUseTokenTransformer.ts"],"sourcesContent":["import type { InteractionManagerBaseOptions } from '../managers/InteractionManager';\n\n// Token metadata is only needed when token-level interactions are enabled.\nexport function shouldUseTokenTransformer<TMode extends 'file' | 'diff'>(\n options: InteractionManagerBaseOptions<TMode> & {\n useTokenTransformer?: boolean;\n }\n): boolean {\n return (\n options.useTokenTransformer === true ||\n options.onTokenClick != null ||\n options.onTokenEnter != null ||\n options.onTokenLeave != null\n );\n}\n"],"mappings":";AAGA,SAAgB,0BACd,SAGS;AACT,QACE,QAAQ,wBAAwB,QAChC,QAAQ,gBAAgB,QACxB,QAAQ,gBAAgB,QACxB,QAAQ,gBAAgB"}
@@ -0,0 +1,10 @@
1
+ import { Element } from "hast";
2
+
3
+ //#region src/utils/wrapTokenFragments.d.ts
4
+ declare const NO_TOKEN: unique symbol;
5
+ declare const MULTIPLE_TOKENS: unique symbol;
6
+ type TokenFragmentState = number | typeof NO_TOKEN | typeof MULTIPLE_TOKENS;
7
+ declare function wrapTokenFragments(container: Element): TokenFragmentState;
8
+ //#endregion
9
+ export { wrapTokenFragments };
10
+ //# sourceMappingURL=wrapTokenFragments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapTokenFragments.d.ts","names":["Element","HASTElement","NO_TOKEN","MULTIPLE_TOKENS","TokenFragmentState","wrapTokenFragments"],"sources":["../../src/utils/wrapTokenFragments.d.ts"],"sourcesContent":["import type { Element as HASTElement } from 'hast';\ndeclare const NO_TOKEN: unique symbol;\ndeclare const MULTIPLE_TOKENS: unique symbol;\ntype TokenFragmentState = number | typeof NO_TOKEN | typeof MULTIPLE_TOKENS;\nexport declare function wrapTokenFragments(container: HASTElement): TokenFragmentState;\nexport {};\n//# sourceMappingURL=wrapTokenFragments.d.ts.map"],"mappings":";;;cACcE;cACAC;AAFqC,KAG9CC,kBAAAA,GAFgC,MAAA,GAAA,OAEKF,QAFL,GAAA,OAEuBC,eAFvB;AACvBA,iBAEUE,kBAAAA,CAFoB,SAAA,EAEUJ,OAFV,CAAA,EAEwBG,kBAFxB"}