@pierre/diffs 1.1.0-beta.16 → 1.1.0-beta.17

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 (98) hide show
  1. package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
  2. package/dist/components/AdvancedVirtualizedFileDiff.js +2 -7
  3. package/dist/components/AdvancedVirtualizedFileDiff.js.map +1 -1
  4. package/dist/components/File.d.ts +14 -2
  5. package/dist/components/File.d.ts.map +1 -1
  6. package/dist/components/File.js +89 -23
  7. package/dist/components/File.js.map +1 -1
  8. package/dist/components/FileDiff.d.ts +15 -3
  9. package/dist/components/FileDiff.d.ts.map +1 -1
  10. package/dist/components/FileDiff.js +101 -23
  11. package/dist/components/FileDiff.js.map +1 -1
  12. package/dist/components/VirtualizedFile.js +4 -2
  13. package/dist/components/VirtualizedFile.js.map +1 -1
  14. package/dist/components/VirtualizedFileDiff.js +4 -2
  15. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  16. package/dist/components/Virtualizer.js +2 -1
  17. package/dist/components/Virtualizer.js.map +1 -1
  18. package/dist/constants.d.ts +3 -1
  19. package/dist/constants.d.ts.map +1 -1
  20. package/dist/constants.js +8 -1
  21. package/dist/constants.js.map +1 -1
  22. package/dist/highlighter/shared_highlighter.js +12 -4
  23. package/dist/highlighter/shared_highlighter.js.map +1 -1
  24. package/dist/index.d.ts +5 -4
  25. package/dist/index.js +5 -4
  26. package/dist/managers/MouseEventManager.d.ts +20 -5
  27. package/dist/managers/MouseEventManager.d.ts.map +1 -1
  28. package/dist/managers/MouseEventManager.js +91 -25
  29. package/dist/managers/MouseEventManager.js.map +1 -1
  30. package/dist/react/File.d.ts +2 -0
  31. package/dist/react/File.d.ts.map +1 -1
  32. package/dist/react/File.js +3 -1
  33. package/dist/react/File.js.map +1 -1
  34. package/dist/react/FileDiff.d.ts +2 -0
  35. package/dist/react/FileDiff.d.ts.map +1 -1
  36. package/dist/react/FileDiff.js +3 -1
  37. package/dist/react/FileDiff.js.map +1 -1
  38. package/dist/react/MultiFileDiff.d.ts +2 -0
  39. package/dist/react/MultiFileDiff.d.ts.map +1 -1
  40. package/dist/react/MultiFileDiff.js +3 -1
  41. package/dist/react/MultiFileDiff.js.map +1 -1
  42. package/dist/react/PatchDiff.d.ts +2 -0
  43. package/dist/react/PatchDiff.d.ts.map +1 -1
  44. package/dist/react/PatchDiff.js +3 -1
  45. package/dist/react/PatchDiff.js.map +1 -1
  46. package/dist/react/constants.d.ts +2 -2
  47. package/dist/react/constants.d.ts.map +1 -1
  48. package/dist/react/constants.js +2 -2
  49. package/dist/react/constants.js.map +1 -1
  50. package/dist/react/index.d.ts +3 -3
  51. package/dist/react/index.js +2 -2
  52. package/dist/react/types.d.ts +10 -0
  53. package/dist/react/types.d.ts.map +1 -1
  54. package/dist/react/utils/renderDiffChildren.d.ts +4 -0
  55. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  56. package/dist/react/utils/renderDiffChildren.js +17 -7
  57. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  58. package/dist/react/utils/renderFileChildren.d.ts +4 -0
  59. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  60. package/dist/react/utils/renderFileChildren.js +13 -7
  61. package/dist/react/utils/renderFileChildren.js.map +1 -1
  62. package/dist/renderers/DiffHunksRenderer.js +3 -2
  63. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  64. package/dist/renderers/FileRenderer.js +1 -1
  65. package/dist/sprite.d.ts +2 -2
  66. package/dist/sprite.d.ts.map +1 -1
  67. package/dist/sprite.js +3 -0
  68. package/dist/sprite.js.map +1 -1
  69. package/dist/ssr/index.d.ts +2 -2
  70. package/dist/style.js +1 -1
  71. package/dist/style.js.map +1 -1
  72. package/dist/types.d.ts +3 -1
  73. package/dist/types.d.ts.map +1 -1
  74. package/dist/utils/createFileHeaderElement.js +5 -2
  75. package/dist/utils/createFileHeaderElement.js.map +1 -1
  76. package/dist/utils/createGutterUtilityContentNode.d.ts +5 -0
  77. package/dist/utils/createGutterUtilityContentNode.d.ts.map +1 -0
  78. package/dist/utils/createGutterUtilityContentNode.js +15 -0
  79. package/dist/utils/createGutterUtilityContentNode.js.map +1 -0
  80. package/dist/utils/createGutterUtilityElement.d.ts +7 -0
  81. package/dist/utils/createGutterUtilityElement.d.ts.map +1 -0
  82. package/dist/utils/createGutterUtilityElement.js +20 -0
  83. package/dist/utils/createGutterUtilityElement.js.map +1 -0
  84. package/dist/utils/hast_utils.d.ts +1 -1
  85. package/dist/utils/hast_utils.d.ts.map +1 -1
  86. package/dist/utils/hast_utils.js.map +1 -1
  87. package/dist/worker/worker-portable.js +7 -0
  88. package/dist/worker/worker-portable.js.map +1 -1
  89. package/dist/worker/worker.js.map +1 -1
  90. package/package.json +2 -1
  91. package/dist/themes/pierre-dark.js +0 -1328
  92. package/dist/themes/pierre-dark.js.map +0 -1
  93. package/dist/themes/pierre-light.js +0 -1328
  94. package/dist/themes/pierre-light.js.map +0 -1
  95. package/dist/utils/createHoverContentNode.d.ts +0 -5
  96. package/dist/utils/createHoverContentNode.d.ts.map +0 -1
  97. package/dist/utils/createHoverContentNode.js +0 -15
  98. package/dist/utils/createHoverContentNode.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AdvancedVirtualizedFileDiff.d.ts","names":["FileDiffMetadata","RenderRange","RenderWindow","VirtualFileMetrics","WorkerPoolManager","FileDiff","FileDiffOptions","RenderProps","HTMLElement","PositionProps","AdvancedVirtualizedFileDiff","LAnnotation","unifiedTop","splitTop","fileDiff","Partial","renderWindow","fileContainer"],"sources":["../../src/components/AdvancedVirtualizedFileDiff.d.ts"],"sourcesContent":["import type { FileDiffMetadata, RenderRange, RenderWindow, VirtualFileMetrics } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nimport { FileDiff, type FileDiffOptions } from './FileDiff';\nexport type { FileDiffOptions };\ninterface RenderProps {\n fileContainer?: HTMLElement;\n renderWindow: RenderWindow;\n}\ninterface PositionProps {\n unifiedTop: number;\n splitTop: number;\n fileDiff: FileDiffMetadata;\n}\nexport declare class AdvancedVirtualizedFileDiff<LAnnotation = undefined> extends FileDiff<LAnnotation> {\n readonly __id: string;\n unifiedTop: number;\n splitTop: number;\n unifiedHeight: number;\n splitHeight: number;\n private metrics;\n fileDiff: FileDiffMetadata;\n renderedRange: RenderRange | undefined;\n constructor({ unifiedTop, splitTop, fileDiff }: PositionProps, options?: FileDiffOptions<LAnnotation>, metrics?: Partial<VirtualFileMetrics>, workerManager?: WorkerPoolManager | undefined);\n cleanUp(recycle?: boolean): void;\n private computeSize;\n virtualizedRender({ renderWindow, fileContainer }: RenderProps): void;\n private computeRenderRangeFromWindow;\n}\n//# sourceMappingURL=AdvancedVirtualizedFileDiff.d.ts.map"],"mappings":";;;;;;UAIUO,WAAAA;kBACUC;EADVD,YAAAA,EAEQL,YADEM;AACU;AAO9B,UALUC,aAAAA,CAKWC;EAAsEC,UAAAA,EAAAA,MAAAA;EAO7EX,QAAAA,EAAAA,MAAAA;EACKC,QAAAA,EAVLD,gBAUKC;;AACWY,cATTH,2BASSG,CAAAA,cAAAA,SAAAA,CAAAA,SAToDR,QASpDQ,CAT6DF,WAS7DE,CAAAA,CAAAA;EAAUC,SAAAA,IAAAA,EAAAA,MAAAA;EAAYL,UAAAA,EAAAA,MAAAA;EAAyCE,QAAAA,EAAAA,MAAAA;EAAhBL,aAAAA,EAAAA,MAAAA;EAAgDH,WAAAA,EAAAA,MAAAA;EAARY,QAAAA,OAAAA;EAA6CX,QAAAA,EAFpJJ,gBAEoJI;EAG1IY,aAAAA,EAJLf,WAIKe,GAAAA,SAAAA;EAAcC,WAAAA,CAAAA;IAAAA,UAAAA;IAAAA,QAAAA;IAAAA;EAAAA,CAAAA,EAHcR,aAGdQ,EAAAA,OAAAA,CAAAA,EAHuCX,eAGvCW,CAHuDN,WAGvDM,CAAAA,EAAAA,OAAAA,CAAAA,EAH+EF,OAG/EE,CAHuFd,kBAGvFc,CAAAA,EAAAA,aAAAA,CAAAA,EAH4Hb,iBAG5Ha,GAAAA,SAAAA;EAAiBV,OAAAA,CAAAA,OAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EAZ2BF,QAAAA,WAAAA;EAAQ,iBAAA,CAAA;IAAA,YAAA;IAAA;EAAA,CAAA,EAYnCE,WAZmC,CAAA,EAAA,IAAA"}
1
+ {"version":3,"file":"AdvancedVirtualizedFileDiff.d.ts","names":["FileDiffMetadata","RenderRange","RenderWindow","VirtualFileMetrics","WorkerPoolManager","FileDiff","FileDiffOptions","RenderProps","HTMLElement","PositionProps","AdvancedVirtualizedFileDiff","LAnnotation","unifiedTop","splitTop","fileDiff","Partial","renderWindow","fileContainer"],"sources":["../../src/components/AdvancedVirtualizedFileDiff.d.ts"],"sourcesContent":["import type { FileDiffMetadata, RenderRange, RenderWindow, VirtualFileMetrics } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nimport { FileDiff, type FileDiffOptions } from './FileDiff';\nexport type { FileDiffOptions };\ninterface RenderProps {\n fileContainer?: HTMLElement;\n renderWindow: RenderWindow;\n}\ninterface PositionProps {\n unifiedTop: number;\n splitTop: number;\n fileDiff: FileDiffMetadata;\n}\nexport declare class AdvancedVirtualizedFileDiff<LAnnotation = undefined> extends FileDiff<LAnnotation> {\n readonly __id: string;\n unifiedTop: number;\n splitTop: number;\n unifiedHeight: number;\n splitHeight: number;\n private metrics;\n fileDiff: FileDiffMetadata;\n renderedRange: RenderRange | undefined;\n constructor({ unifiedTop, splitTop, fileDiff }: PositionProps, options?: FileDiffOptions<LAnnotation>, metrics?: Partial<VirtualFileMetrics>, workerManager?: WorkerPoolManager | undefined);\n cleanUp(recycle?: boolean): void;\n private computeSize;\n virtualizedRender({ renderWindow, fileContainer }: RenderProps): void;\n private computeRenderRangeFromWindow;\n}\n//# sourceMappingURL=AdvancedVirtualizedFileDiff.d.ts.map"],"mappings":";;;;;;UAIUO,WAAAA;kBACUC;EADVD,YAAAA,EAEQL,YAFG;AAES;AAO9B,UALUO,aAAAA,CAKWC;EAAsEC,UAAAA,EAAAA,MAAAA;EAO7EX,QAAAA,EAAAA,MAAAA;EACKC,QAAAA,EAVLD,gBAUKC;;AACWY,cATTH,2BASSG,CAAAA,cAAAA,SAAAA,CAAAA,SAToDR,QASpDQ,CAT6DF,WAS7DE,CAAAA,CAAAA;EAAUC,SAAAA,IAAAA,EAAAA,MAAAA;EAAYL,UAAAA,EAAAA,MAAAA;EAAyCE,QAAAA,EAAAA,MAAAA;EAAhBL,aAAAA,EAAAA,MAAAA;EAAgDH,WAAAA,EAAAA,MAAAA;EAARY,QAAAA,OAAAA;EAA6CX,QAAAA,EAFpJJ,gBAEoJI;EAG1IY,aAAAA,EAJLf,WAIKe,GAAAA,SAAAA;EAAcC,WAAAA,CAAAA;IAAAA,UAAAA;IAAAA,QAAAA;IAAAA;EAAAA,CAAAA,EAHcR,aAGdQ,EAAAA,OAAAA,CAAAA,EAHuCX,eAGvCW,CAHuDN,WAGvDM,CAAAA,EAAAA,OAAAA,CAAAA,EAH+EF,OAG/EE,CAHuFd,kBAGvFc,CAAAA,EAAAA,aAAAA,CAAAA,EAH4Hb,iBAG5Ha,GAAAA,SAAAA;EAAiBV,OAAAA,CAAAA,OAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EAZ2BF,QAAAA,WAAAA;EAAQ,iBAAA,CAAA;IAAA,YAAA;IAAA;EAAA,CAAA,EAYnCE,WAZmC,CAAA,EAAA,IAAA"}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_THEMES } from "../constants.js";
1
+ import { DEFAULT_THEMES, EMPTY_RENDER_RANGE } from "../constants.js";
2
2
  import { areRenderRangesEqual } from "../utils/areRenderRangesEqual.js";
3
3
  import { FileDiff } from "./FileDiff.js";
4
4
  import { resolveVirtualFileMetrics } from "../utils/resolveVirtualFileMetrics.js";
@@ -71,12 +71,7 @@ var AdvancedVirtualizedFileDiff = class extends FileDiff {
71
71
  const { lineCount, fileTop, fileHeight } = getSpecs(this, diffStyle);
72
72
  if (fileTop < top - fileHeight || fileTop > bottom) {
73
73
  console.error("VirtulizedFileDiff.computeRenderRangeFromWindow: invalid render", this.fileDiff.name);
74
- return {
75
- startingLine: 0,
76
- totalLines: 0,
77
- bufferBefore: 0,
78
- bufferAfter: 0
79
- };
74
+ return EMPTY_RENDER_RANGE;
80
75
  }
81
76
  if (lineCount <= hunkLineCount) return {
82
77
  startingLine: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"AdvancedVirtualizedFileDiff.js","names":["hunkOffsets: number[]","startingLine: number | undefined","hunkLineCount"],"sources":["../../src/components/AdvancedVirtualizedFileDiff.ts"],"sourcesContent":["import { DEFAULT_THEMES } from '../constants';\nimport type {\n FileDiffMetadata,\n RenderRange,\n RenderWindow,\n VirtualFileMetrics,\n} from '../types';\nimport { areRenderRangesEqual } from '../utils/areRenderRangesEqual';\nimport { resolveVirtualFileMetrics } from '../utils/resolveVirtualFileMetrics';\nimport type { WorkerPoolManager } from '../worker';\nimport { FileDiff, type FileDiffOptions } from './FileDiff';\n\nexport type { FileDiffOptions };\n\ninterface RenderProps {\n fileContainer?: HTMLElement;\n renderWindow: RenderWindow;\n}\n\ninterface PositionProps {\n unifiedTop: number;\n splitTop: number;\n fileDiff: FileDiffMetadata;\n}\n\nlet instanceId = -1;\n\nexport class AdvancedVirtualizedFileDiff<\n LAnnotation = undefined,\n> extends FileDiff<LAnnotation> {\n override readonly __id: string = `virtualized-file-diff:${++instanceId}`;\n\n public unifiedTop: number;\n public splitTop: number;\n public unifiedHeight: number = 0;\n public splitHeight: number = 0;\n private metrics: VirtualFileMetrics;\n\n override fileDiff: FileDiffMetadata;\n public renderedRange: RenderRange | undefined;\n\n constructor(\n { unifiedTop, splitTop, fileDiff }: PositionProps,\n options: FileDiffOptions<LAnnotation> = { theme: DEFAULT_THEMES },\n metrics?: Partial<VirtualFileMetrics>,\n workerManager?: WorkerPoolManager | undefined\n ) {\n super(options, workerManager, true);\n this.fileDiff = fileDiff;\n this.unifiedTop = unifiedTop;\n this.splitTop = splitTop;\n const { hunkSeparators = 'line-info' } = this.options;\n this.metrics = resolveVirtualFileMetrics(\n typeof hunkSeparators === 'function' ? 'custom' : hunkSeparators,\n metrics\n );\n this.computeSize();\n }\n\n override cleanUp(recycle = false): void {\n super.cleanUp(recycle);\n this.renderedRange = undefined;\n }\n\n private computeSize() {\n const {\n options: { disableFileHeader = false },\n fileDiff,\n metrics: { diffHeaderHeight, fileGap, hunkSeparatorHeight, lineHeight },\n } = this;\n\n // Add header height\n if (!disableFileHeader) {\n this.unifiedHeight += diffHeaderHeight;\n this.splitHeight += diffHeaderHeight;\n } else {\n this.unifiedHeight += fileGap;\n this.splitHeight += fileGap;\n }\n\n // NOTE(amadeus): I wonder if it's worth shortcutting this? It might help\n // to measure these values though and see if it's at all an issue on the\n // big bois\n for (const hunk of fileDiff.hunks) {\n this.unifiedHeight += hunk.unifiedLineCount * lineHeight;\n this.splitHeight += hunk.splitLineCount * lineHeight;\n }\n\n // Add hunk separators height\n const hunkCount = fileDiff.hunks.length;\n const [firstHunk] = fileDiff.hunks;\n if (firstHunk != null) {\n let hunkSize = (hunkSeparatorHeight + fileGap * 2) * (hunkCount - 1);\n if (firstHunk.additionStart > 1 || firstHunk.deletionStart > 1) {\n hunkSize += hunkSeparatorHeight + fileGap;\n }\n this.unifiedHeight += hunkSize;\n this.splitHeight += hunkSize;\n }\n\n // If there are hunks of code, then we gotta render some bottom padding\n if (hunkCount > 0) {\n this.unifiedHeight += fileGap;\n this.splitHeight += fileGap;\n }\n }\n\n virtualizedRender({ renderWindow, fileContainer }: RenderProps): void {\n const { fileDiff } = this;\n const renderRange = this.computeRenderRangeFromWindow(renderWindow);\n if (\n this.fileContainer != null &&\n areRenderRangesEqual(renderRange, this.renderedRange)\n ) {\n return;\n }\n this.renderedRange = renderRange;\n fileContainer = this.getOrCreateFileContainer(fileContainer);\n this.render({ fileDiff, fileContainer, renderRange });\n }\n\n private computeRenderRangeFromWindow({\n top,\n bottom,\n }: RenderWindow): RenderRange {\n const { diffStyle = 'split', disableFileHeader = false } = this.options;\n const {\n diffHeaderHeight,\n fileGap,\n hunkLineCount,\n hunkSeparatorHeight,\n lineHeight,\n } = this.metrics;\n const { lineCount, fileTop, fileHeight } = getSpecs(this, diffStyle);\n\n // We should never hit this theoretically, but if so, gtfo and yell loudly,\n // so we can fix\n if (fileTop < top - fileHeight || fileTop > bottom) {\n console.error(\n 'VirtulizedFileDiff.computeRenderRangeFromWindow: invalid render',\n this.fileDiff.name\n );\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: 0,\n };\n }\n\n // Whole file is under HUNK_LINE_COUNT, just render it all\n if (lineCount <= hunkLineCount) {\n return {\n startingLine: 0,\n totalLines: Infinity,\n bufferBefore: 0,\n bufferAfter: 0,\n };\n }\n\n const headerRegion = disableFileHeader ? fileGap : diffHeaderHeight;\n let absoluteLineTop = fileTop + headerRegion;\n let currentLine = 0;\n const hunkOffsets: number[] = [];\n let startingLine: number | undefined;\n let endingLine = 0;\n for (const hunk of this.fileDiff.hunks) {\n let hunkGap = 0;\n if (hunk.additionStart > 1 || hunk.deletionStart > 1) {\n hunkGap = hunkSeparatorHeight + fileGap;\n if (hunk !== this.fileDiff.hunks[0]) {\n hunkGap += fileGap;\n }\n absoluteLineTop += hunkGap;\n }\n const hunkLineCount =\n diffStyle === 'split' ? hunk.splitLineCount : hunk.unifiedLineCount;\n for (let l = 0; l < hunkLineCount; l++) {\n if (currentLine % hunkLineCount === 0) {\n hunkOffsets.push(\n absoluteLineTop - (fileTop + headerRegion + (l === 0 ? hunkGap : 0))\n );\n }\n if (\n startingLine == null &&\n absoluteLineTop > top - lineHeight &&\n absoluteLineTop < bottom\n ) {\n startingLine = currentLine;\n endingLine = startingLine + 1;\n } else if (startingLine != null && absoluteLineTop < bottom) {\n endingLine++;\n }\n currentLine++;\n absoluteLineTop += lineHeight;\n }\n }\n\n if (startingLine == null) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: fileHeight - headerRegion,\n bufferAfter: 0,\n };\n }\n\n startingLine = Math.floor(startingLine / hunkLineCount) * hunkLineCount;\n const totalLines =\n Math.ceil((endingLine - startingLine) / hunkLineCount) * hunkLineCount;\n\n const finalHunkBufferOffset = (startingLine + totalLines) / hunkLineCount;\n const bufferBefore = hunkOffsets[startingLine / hunkLineCount] ?? 0;\n const bufferAfter =\n finalHunkBufferOffset < hunkOffsets.length\n ? fileHeight -\n headerRegion -\n hunkOffsets[finalHunkBufferOffset] -\n fileGap // this is to account for bottom padding of the code container\n : 0;\n return { startingLine, totalLines, bufferBefore, bufferAfter };\n }\n}\n\nfunction getSpecs<LAnnotation>(\n instance: AdvancedVirtualizedFileDiff<LAnnotation>,\n type: 'split' | 'unified' = 'split'\n) {\n if (type === 'split') {\n return {\n lineCount: instance.fileDiff.splitLineCount,\n fileTop: instance.splitTop,\n fileHeight: instance.splitHeight,\n };\n }\n return {\n lineCount: instance.fileDiff.unifiedLineCount,\n fileTop: instance.unifiedTop,\n fileHeight: instance.unifiedHeight,\n };\n}\n"],"mappings":";;;;;;AAyBA,IAAI,aAAa;AAEjB,IAAa,8BAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,yBAAyB,EAAE;CAE5D,AAAO;CACP,AAAO;CACP,AAAO,gBAAwB;CAC/B,AAAO,cAAsB;CAC7B,AAAQ;CAER,AAAS;CACT,AAAO;CAEP,YACE,EAAE,YAAY,UAAU,YACxB,UAAwC,EAAE,OAAO,gBAAgB,EACjE,SACA,eACA;AACA,QAAM,SAAS,eAAe,KAAK;AACnC,OAAK,WAAW;AAChB,OAAK,aAAa;AAClB,OAAK,WAAW;EAChB,MAAM,EAAE,iBAAiB,gBAAgB,KAAK;AAC9C,OAAK,UAAU,0BACb,OAAO,mBAAmB,aAAa,WAAW,gBAClD,QACD;AACD,OAAK,aAAa;;CAGpB,AAAS,QAAQ,UAAU,OAAa;AACtC,QAAM,QAAQ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ACX,QAAO;EACL,WAAW,SAAS,SAAS;EAC7B,SAAS,SAAS;EAClB,YAAY,SAAS;EACtB;AAEH,QAAO;EACL,WAAW,SAAS,SAAS;EAC7B,SAAS,SAAS;EAClB,YAAY,SAAS;EACtB"}
1
+ {"version":3,"file":"AdvancedVirtualizedFileDiff.js","names":["hunkOffsets: number[]","startingLine: number | undefined","hunkLineCount"],"sources":["../../src/components/AdvancedVirtualizedFileDiff.ts"],"sourcesContent":["import { DEFAULT_THEMES, EMPTY_RENDER_RANGE } from '../constants';\nimport type {\n FileDiffMetadata,\n RenderRange,\n RenderWindow,\n VirtualFileMetrics,\n} from '../types';\nimport { areRenderRangesEqual } from '../utils/areRenderRangesEqual';\nimport { resolveVirtualFileMetrics } from '../utils/resolveVirtualFileMetrics';\nimport type { WorkerPoolManager } from '../worker';\nimport { FileDiff, type FileDiffOptions } from './FileDiff';\n\nexport type { FileDiffOptions };\n\ninterface RenderProps {\n fileContainer?: HTMLElement;\n renderWindow: RenderWindow;\n}\n\ninterface PositionProps {\n unifiedTop: number;\n splitTop: number;\n fileDiff: FileDiffMetadata;\n}\n\nlet instanceId = -1;\n\nexport class AdvancedVirtualizedFileDiff<\n LAnnotation = undefined,\n> extends FileDiff<LAnnotation> {\n override readonly __id: string = `virtualized-file-diff:${++instanceId}`;\n\n public unifiedTop: number;\n public splitTop: number;\n public unifiedHeight: number = 0;\n public splitHeight: number = 0;\n private metrics: VirtualFileMetrics;\n\n override fileDiff: FileDiffMetadata;\n public renderedRange: RenderRange | undefined;\n\n constructor(\n { unifiedTop, splitTop, fileDiff }: PositionProps,\n options: FileDiffOptions<LAnnotation> = { theme: DEFAULT_THEMES },\n metrics?: Partial<VirtualFileMetrics>,\n workerManager?: WorkerPoolManager | undefined\n ) {\n super(options, workerManager, true);\n this.fileDiff = fileDiff;\n this.unifiedTop = unifiedTop;\n this.splitTop = splitTop;\n const { hunkSeparators = 'line-info' } = this.options;\n this.metrics = resolveVirtualFileMetrics(\n typeof hunkSeparators === 'function' ? 'custom' : hunkSeparators,\n metrics\n );\n this.computeSize();\n }\n\n override cleanUp(recycle = false): void {\n super.cleanUp(recycle);\n this.renderedRange = undefined;\n }\n\n private computeSize() {\n const {\n options: { disableFileHeader = false },\n fileDiff,\n metrics: { diffHeaderHeight, fileGap, hunkSeparatorHeight, lineHeight },\n } = this;\n\n // Add header height\n if (!disableFileHeader) {\n this.unifiedHeight += diffHeaderHeight;\n this.splitHeight += diffHeaderHeight;\n } else {\n this.unifiedHeight += fileGap;\n this.splitHeight += fileGap;\n }\n\n // NOTE(amadeus): I wonder if it's worth shortcutting this? It might help\n // to measure these values though and see if it's at all an issue on the\n // big bois\n for (const hunk of fileDiff.hunks) {\n this.unifiedHeight += hunk.unifiedLineCount * lineHeight;\n this.splitHeight += hunk.splitLineCount * lineHeight;\n }\n\n // Add hunk separators height\n const hunkCount = fileDiff.hunks.length;\n const [firstHunk] = fileDiff.hunks;\n if (firstHunk != null) {\n let hunkSize = (hunkSeparatorHeight + fileGap * 2) * (hunkCount - 1);\n if (firstHunk.additionStart > 1 || firstHunk.deletionStart > 1) {\n hunkSize += hunkSeparatorHeight + fileGap;\n }\n this.unifiedHeight += hunkSize;\n this.splitHeight += hunkSize;\n }\n\n // If there are hunks of code, then we gotta render some bottom padding\n if (hunkCount > 0) {\n this.unifiedHeight += fileGap;\n this.splitHeight += fileGap;\n }\n }\n\n virtualizedRender({ renderWindow, fileContainer }: RenderProps): void {\n const { fileDiff } = this;\n const renderRange = this.computeRenderRangeFromWindow(renderWindow);\n if (\n this.fileContainer != null &&\n areRenderRangesEqual(renderRange, this.renderedRange)\n ) {\n return;\n }\n this.renderedRange = renderRange;\n fileContainer = this.getOrCreateFileContainer(fileContainer);\n this.render({ fileDiff, fileContainer, renderRange });\n }\n\n private computeRenderRangeFromWindow({\n top,\n bottom,\n }: RenderWindow): RenderRange {\n const { diffStyle = 'split', disableFileHeader = false } = this.options;\n const {\n diffHeaderHeight,\n fileGap,\n hunkLineCount,\n hunkSeparatorHeight,\n lineHeight,\n } = this.metrics;\n const { lineCount, fileTop, fileHeight } = getSpecs(this, diffStyle);\n\n // We should never hit this theoretically, but if so, gtfo and yell loudly,\n // so we can fix\n if (fileTop < top - fileHeight || fileTop > bottom) {\n console.error(\n 'VirtulizedFileDiff.computeRenderRangeFromWindow: invalid render',\n this.fileDiff.name\n );\n return EMPTY_RENDER_RANGE;\n }\n\n // Whole file is under HUNK_LINE_COUNT, just render it all\n if (lineCount <= hunkLineCount) {\n return {\n startingLine: 0,\n totalLines: Infinity,\n bufferBefore: 0,\n bufferAfter: 0,\n };\n }\n\n const headerRegion = disableFileHeader ? fileGap : diffHeaderHeight;\n let absoluteLineTop = fileTop + headerRegion;\n let currentLine = 0;\n const hunkOffsets: number[] = [];\n let startingLine: number | undefined;\n let endingLine = 0;\n for (const hunk of this.fileDiff.hunks) {\n let hunkGap = 0;\n if (hunk.additionStart > 1 || hunk.deletionStart > 1) {\n hunkGap = hunkSeparatorHeight + fileGap;\n if (hunk !== this.fileDiff.hunks[0]) {\n hunkGap += fileGap;\n }\n absoluteLineTop += hunkGap;\n }\n const hunkLineCount =\n diffStyle === 'split' ? hunk.splitLineCount : hunk.unifiedLineCount;\n for (let l = 0; l < hunkLineCount; l++) {\n if (currentLine % hunkLineCount === 0) {\n hunkOffsets.push(\n absoluteLineTop - (fileTop + headerRegion + (l === 0 ? hunkGap : 0))\n );\n }\n if (\n startingLine == null &&\n absoluteLineTop > top - lineHeight &&\n absoluteLineTop < bottom\n ) {\n startingLine = currentLine;\n endingLine = startingLine + 1;\n } else if (startingLine != null && absoluteLineTop < bottom) {\n endingLine++;\n }\n currentLine++;\n absoluteLineTop += lineHeight;\n }\n }\n\n if (startingLine == null) {\n return {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: fileHeight - headerRegion,\n bufferAfter: 0,\n };\n }\n\n startingLine = Math.floor(startingLine / hunkLineCount) * hunkLineCount;\n const totalLines =\n Math.ceil((endingLine - startingLine) / hunkLineCount) * hunkLineCount;\n\n const finalHunkBufferOffset = (startingLine + totalLines) / hunkLineCount;\n const bufferBefore = hunkOffsets[startingLine / hunkLineCount] ?? 0;\n const bufferAfter =\n finalHunkBufferOffset < hunkOffsets.length\n ? fileHeight -\n headerRegion -\n hunkOffsets[finalHunkBufferOffset] -\n fileGap // this is to account for bottom padding of the code container\n : 0;\n return { startingLine, totalLines, bufferBefore, bufferAfter };\n }\n}\n\nfunction getSpecs<LAnnotation>(\n instance: AdvancedVirtualizedFileDiff<LAnnotation>,\n type: 'split' | 'unified' = 'split'\n) {\n if (type === 'split') {\n return {\n lineCount: instance.fileDiff.splitLineCount,\n fileTop: instance.splitTop,\n fileHeight: instance.splitHeight,\n };\n }\n return {\n lineCount: instance.fileDiff.unifiedLineCount,\n fileTop: instance.unifiedTop,\n fileHeight: instance.unifiedHeight,\n };\n}\n"],"mappings":";;;;;;AAyBA,IAAI,aAAa;AAEjB,IAAa,8BAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,yBAAyB,EAAE;CAE5D,AAAO;CACP,AAAO;CACP,AAAO,gBAAwB;CAC/B,AAAO,cAAsB;CAC7B,AAAQ;CAER,AAAS;CACT,AAAO;CAEP,YACE,EAAE,YAAY,UAAU,YACxB,UAAwC,EAAE,OAAO,gBAAgB,EACjE,SACA,eACA;AACA,QAAM,SAAS,eAAe,KAAK;AACnC,OAAK,WAAW;AAChB,OAAK,aAAa;AAClB,OAAK,WAAW;EAChB,MAAM,EAAE,iBAAiB,gBAAgB,KAAK;AAC9C,OAAK,UAAU,0BACb,OAAO,mBAAmB,aAAa,WAAW,gBAClD,QACD;AACD,OAAK,aAAa;;CAGpB,AAAS,QAAQ,UAAU,OAAa;AACtC,QAAM,QAAQ,QAAQ;AACtB,OAAK,gBAAgB;;CAGvB,AAAQ,cAAc;EACpB,MAAM,EACJ,SAAS,EAAE,oBAAoB,SAC/B,UACA,SAAS,EAAE,kBAAkB,SAAS,qBAAqB,iBACzD;AAGJ,MAAI,CAAC,m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<LAnnotation
21
21
  }
22
22
  interface FileOptions<LAnnotation> extends BaseCodeOptions, MouseEventManagerBaseOptions<'file'>, LineSelectionOptions {
23
23
  disableFileHeader?: boolean;
24
+ /**
25
+ * @deprecated Use `enableGutterUtility` instead.
26
+ */
27
+ enableHoverUtility?: boolean;
28
+ renderHeaderPrefix?: RenderFileMetadata;
24
29
  renderCustomMetadata?: RenderFileMetadata;
25
30
  /**
26
31
  * When true, errors during rendering are rethrown instead of being caught
@@ -29,6 +34,10 @@ interface FileOptions<LAnnotation> extends BaseCodeOptions, MouseEventManagerBas
29
34
  */
30
35
  disableErrorHandling?: boolean;
31
36
  renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;
37
+ renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null;
38
+ /**
39
+ * @deprecated Use `renderGutterUtility` instead.
40
+ */
32
41
  renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null;
33
42
  }
34
43
  interface AnnotationElementCache<LAnnotation> {
@@ -48,13 +57,14 @@ declare class File<LAnnotation = undefined> {
48
57
  protected bufferBefore: HTMLElement | undefined;
49
58
  protected bufferAfter: HTMLElement | undefined;
50
59
  protected unsafeCSSStyle: HTMLStyleElement | undefined;
51
- protected hoverContent: HTMLElement | undefined;
60
+ protected gutterUtilityContent: HTMLElement | undefined;
52
61
  protected errorWrapper: HTMLElement | undefined;
53
62
  protected placeHolder: HTMLElement | undefined;
54
63
  protected lastRenderedHeaderHTML: string | undefined;
55
64
  protected appliedPreAttributes: PrePropertiesConfig | undefined;
56
65
  protected lastRowCount: number | undefined;
57
66
  protected headerElement: HTMLElement | undefined;
67
+ protected headerPrefix: HTMLElement | undefined;
58
68
  protected headerMetadata: HTMLElement | undefined;
59
69
  protected fileRenderer: FileRenderer<LAnnotation>;
60
70
  protected resizeManager: ResizeManager;
@@ -86,11 +96,13 @@ declare class File<LAnnotation = undefined> {
86
96
  lineAnnotations,
87
97
  renderRange
88
98
  }: FileRenderProps<LAnnotation>): boolean;
99
+ private removeRenderedCode;
100
+ private clearAuxiliaryNodes;
89
101
  private canPartiallyRender;
90
102
  renderPlaceholder(height: number): boolean;
91
103
  private cleanChildNodes;
92
104
  private renderAnnotations;
93
- private renderHoverUtility;
105
+ private renderGutterUtility;
94
106
  private injectUnsafeCSS;
95
107
  private applyFullRender;
96
108
  private applyPartialRender;
@@ -1 +1 @@
1
- {"version":3,"file":"File.d.ts","names":["LineSelectionManager","LineSelectionOptions","SelectedLineRange","GetHoveredLineResult","MouseEventManager","MouseEventManagerBaseOptions","ResizeManager","FileRenderer","BaseCodeOptions","FileContents","LineAnnotation","PrePropertiesConfig","RenderFileMetadata","RenderRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHyrdateProps","Omit","FileOptions","AnnotationElementCache","File","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","fileContainer","forceRender","containerWrapper","lineAnnotations","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { LineSelectionManager, type LineSelectionOptions, type SelectedLineRange } from '../managers/LineSelectionManager';\nimport { type GetHoveredLineResult, MouseEventManager, type MouseEventManagerBaseOptions } from '../managers/MouseEventManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n forceRender?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHyrdateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, MouseEventManagerBaseOptions<'file'>, LineSelectionOptions {\n disableFileHeader?: boolean;\n renderCustomMetadata?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected hoverContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n protected headerElement: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected mouseEventManager: MouseEventManager<'file'>;\n protected lineSelectionManager: LineSelectionManager;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null): void;\n cleanUp(): void;\n hydrate(props: FileHyrdateProps<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, containerWrapper, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n private cleanChildNodes;\n private renderAnnotations;\n private renderHoverUtility;\n private injectUnsafeCSS;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n private applyHeaderToDOM;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private getOrCreatePreNode;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":";;;;;;;;;UAMiBgB;QACPP;kBACUS;EAFHF,gBAAAA,CAAAA,EAGME,WAHSD;EACtBR,WAAAA,CAAAA,EAAAA,OAAAA;EACUS,eAAAA,CAAAA,EAGER,cAHFQ,CAGiBD,WAHjBC,CAAAA,EAAAA;EACGA,WAAAA,CAAAA,EAGLL,WAHKK;;AAEDR,UAGLS,gBAHKT,CAAAA,WAAAA,CAAAA,SAGiCU,IAHjCV,CAGsCM,eAHtCN,CAGsDO,WAHtDP,CAAAA,EAAAA,eAAAA,CAAAA,CAAAA;EACJG,aAAAA,EAGCK,WAHDL;EAAW,eAAA,CAAA,EAAA,MAAA;AAE7B;AAA4EI,UAI3DI,WAJ2DJ,CAAAA,WAAAA,CAAAA,SAI1BT,eAJ0BS,EAITZ,4BAJSY,CAAAA,MAAAA,CAAAA,EAI6BhB,oBAJ7BgB,CAAAA;EAAh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AAA,eAAAA,EAIYJ,cAJZI,CAI2BG,WAJ3BH,CAAAA,EAAAA,CAAAA,EAAAA,IAAAA;EAI2BG,gBAAAA,CAAAA,KAAAA,EAC3Bf,iBAD2Be,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EAAfP,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EACZR,OAAAA,CAAAA,KAAAA,EAETiB,gBAFSjB,CAEQe,WAFRf,CAAAA,CAAAA,EAAAA,IAAAA;EAEQe,oBAAAA,CAAAA,IAAAA,CAAAA,EACJR,YADIQ,GAAAA,SAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAjBE,MAAAA,CAAAA;IAAAA,IAAAA;IAAAA,aAAAA;IAAAA,WAAAA;IAAAA,gBAAAA;IAAAA,eAAAA;IAAAA;EAAAA,CAAAA,EAE8EH,eAF9EG,CAE8FF,WAF9FE,CAAAA,CAAAA,EAAAA,OAAAA;EACaV,QAAAA,kBAAAA;EACnBmB,iBAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;EAAMC,QAAAA,eAAAA;EAAeC,QAAAA,iBAAAA;EAAaC,QAAAA,kBAAAA;EAAkBC,QAAAA,eAAAA;EAAiBC,QAAAA,eAAAA;EAA+BhB,QAAAA,kBAAAA;EAAhBD,QAAAA,UAAAA;EAetCE,QAAAA,gBAAAA;EAA0BA,QAAAA,qBAAAA;EAAcA,QAAAA,uBAAAA;EAAW,QAAA,YAAA;;yDAAnDA,0BAA0BA,cAAcA"}
1
+ {"version":3,"file":"File.d.ts","names":["LineSelectionManager","LineSelectionOptions","SelectedLineRange","GetHoveredLineResult","MouseEventManager","MouseEventManagerBaseOptions","ResizeManager","FileRenderer","BaseCodeOptions","FileContents","LineAnnotation","PrePropertiesConfig","RenderFileMetadata","RenderRange","ThemeTypes","WorkerPoolManager","FileRenderProps","LAnnotation","HTMLElement","FileHyrdateProps","Omit","FileOptions","AnnotationElementCache","File","SVGElement","HTMLPreElement","HTMLStyleElement","Map","file","fileContainer","forceRender","containerWrapper","lineAnnotations","renderRange"],"sources":["../../src/components/File.d.ts"],"sourcesContent":["import { LineSelectionManager, type LineSelectionOptions, type SelectedLineRange } from '../managers/LineSelectionManager';\nimport { type GetHoveredLineResult, MouseEventManager, type MouseEventManagerBaseOptions } from '../managers/MouseEventManager';\nimport { ResizeManager } from '../managers/ResizeManager';\nimport { FileRenderer } from '../renderers/FileRenderer';\nimport type { BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, RenderFileMetadata, RenderRange, ThemeTypes } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nexport interface FileRenderProps<LAnnotation> {\n file: FileContents;\n fileContainer?: HTMLElement;\n containerWrapper?: HTMLElement;\n forceRender?: boolean;\n lineAnnotations?: LineAnnotation<LAnnotation>[];\n renderRange?: RenderRange;\n}\nexport interface FileHyrdateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation>, 'fileContainer'> {\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\nexport interface FileOptions<LAnnotation> extends BaseCodeOptions, MouseEventManagerBaseOptions<'file'>, LineSelectionOptions {\n disableFileHeader?: boolean;\n /**\n * @deprecated Use `enableGutterUtility` instead.\n */\n enableHoverUtility?: boolean;\n renderHeaderPrefix?: RenderFileMetadata;\n renderCustomMetadata?: RenderFileMetadata;\n /**\n * When true, errors during rendering are rethrown instead of being caught\n * and displayed in the DOM. Useful for testing or when you want to handle\n * errors yourself.\n */\n disableErrorHandling?: boolean;\n renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null;\n /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null;\n}\ninterface AnnotationElementCache<LAnnotation> {\n element: HTMLElement;\n annotation: LineAnnotation<LAnnotation>;\n}\nexport declare class File<LAnnotation = undefined> {\n options: FileOptions<LAnnotation>;\n private workerManager?;\n private isContainerManaged;\n static LoadedCustomComponent: boolean;\n readonly __id: string;\n protected fileContainer: HTMLElement | undefined;\n protected spriteSVG: SVGElement | undefined;\n protected pre: HTMLPreElement | undefined;\n protected code: HTMLElement | undefined;\n protected bufferBefore: HTMLElement | undefined;\n protected bufferAfter: HTMLElement | undefined;\n protected unsafeCSSStyle: HTMLStyleElement | undefined;\n protected gutterUtilityContent: HTMLElement | undefined;\n protected errorWrapper: HTMLElement | undefined;\n protected placeHolder: HTMLElement | undefined;\n protected lastRenderedHeaderHTML: string | undefined;\n protected appliedPreAttributes: PrePropertiesConfig | undefined;\n protected lastRowCount: number | undefined;\n protected headerElement: HTMLElement | undefined;\n protected headerPrefix: HTMLElement | undefined;\n protected headerMetadata: HTMLElement | undefined;\n protected fileRenderer: FileRenderer<LAnnotation>;\n protected resizeManager: ResizeManager;\n protected mouseEventManager: MouseEventManager<'file'>;\n protected lineSelectionManager: LineSelectionManager;\n protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;\n protected lineAnnotations: LineAnnotation<LAnnotation>[];\n protected file: FileContents | undefined;\n protected renderRange: RenderRange | undefined;\n constructor(options?: FileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n private handleHighlightRender;\n rerender(): void;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n private mergeOptions;\n setThemeType(themeType: ThemeTypes): void;\n getHoveredLine: () => {\n lineNumber: number;\n } | undefined;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n setSelectedLines(range: SelectedLineRange | null): void;\n cleanUp(): void;\n hydrate(props: FileHyrdateProps<LAnnotation>): void;\n getOrCreateLineCache(file?: FileContents | undefined): string[];\n render({ file, fileContainer, forceRender, containerWrapper, lineAnnotations, renderRange }: FileRenderProps<LAnnotation>): boolean;\n private removeRenderedCode;\n private clearAuxiliaryNodes;\n private canPartiallyRender;\n renderPlaceholder(height: number): boolean;\n private cleanChildNodes;\n private renderAnnotations;\n private renderGutterUtility;\n private injectUnsafeCSS;\n private applyFullRender;\n private applyPartialRender;\n private getColumns;\n private trimDOMToOverlap;\n private getDOMBoundaryIndices;\n private getLineIndexFromDOMNode;\n private applyBuffers;\n private applyHeaderToDOM;\n protected getOrCreateFileContainerNode(fileContainer?: HTMLElement, parentNode?: HTMLElement): HTMLElement;\n private getOrCreatePreNode;\n private applyPreNodeAttributes;\n private applyErrorToDOM;\n private cleanupErrorWrapper;\n}\nexport {};\n//# sourceMappingURL=File.d.ts.map"],"mappings":";;;;;;;;;UAMiBgB;QACPP;kBACUS;EAFHF,gBAAAA,CAAAA,EAGME,WAHSD;EACtBR,WAAAA,CAAAA,EAAAA,OAAAA;EACUS,eAAAA,CAAAA,EAGER,cAHFQ,CAGiBD,WAHjBC,CAAAA,EAAAA;EACGA,WAAAA,CAAAA,EAGLL,WAHKK;;AAEDR,UAGLS,gBAHKT,CAAAA,WAAAA,CAAAA,SAGiCU,IAHjCV,CAGsCM,eAHtCN,CAGsDO,WAHtDP,CAAAA,EAAAA,eAAAA,CAAAA,CAAAA;EACJG,aAAAA,EAGCK,WAHDL;EAAW,eAAA,CAAA,EAAA,MAAA;AAE7B;AAA4EI,UAI3DI,WAJ2DJ,CAAAA,WAAAA,CAAAA,SAI1BT,eAJ0BS,EAITZ,4BAJSY,CAAAA,MAAAA,CAAAA,EAI6BhB,oBAJ7BgB,CAAAA;EAAhBD,iBAAAA,CAAAA,EAAAA,OAAAA;EACzCE;;;EAGFG,kBAAW,CAAA,EAAAJ,OAAAA;EAMHL,kBAAAA,CAAAA,EAAAA,kBAAAA;EACEA,oBAAAA,CAAAA,EAAAA,kBAAAA;EAOsBK;;;;;EAKJd,oBAAAA,CAAAA,EAAAA,OAAAA;EAA2Ce,gBAAAA,EAAAA,UAAAA,EALtDR,cAKsDQ,CALvCD,WAKuCC,CAAAA,CAAAA,EALxBA,WAKwBA,GAAAA,SAAAA;EAnBtCV,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AAAA,CAAAA,EAAAA,IAAAA;EACnBmB,gBAAAA,CAAAA,KAAAA,EAJe1B,iBAIf0B,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EAAMC,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAAeC,OAAAA,CAAAA,KAAAA,EAFfX,gBAEeW,CAFEb,WAEFa,CAAAA,CAAAA,EAAAA,IAAAA;EAAaC,oBAAAA,CAAAA,IAAAA,CAAAA,EADftB,YACesB,GAAAA,SAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAkBC,MAAAA,CAAAA;IAAAA,IAAAA;IAAAA,aAAAA;IAAAA,WAAAA;IAAAA,gBAAAA;IAAAA,eAAAA;IAAAA;EAAAA,CAAAA,EAAgChB,eAAhCgB,CAAgDf,WAAhDe,CAAAA,CAAAA,EAAAA,OAAAA;EAAiBC,QAAAA,kBAAAA;EAA+BhB,QAAAA,mBAAAA;EAAhBD,QAAAA,kBAAAA;EAiBtCE,iBAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;EAA0BA,QAAAA,eAAAA;EAAcA,QAAAA,iBAAAA;EAAW,QAAA,mBAAA;;;;;;;;;;yDAAnDA,0BAA0BA,cAAcA"}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_THEMES, DIFFS_TAG_NAME, HEADER_METADATA_SLOT_ID, UNSAFE_CSS_ATTRIBUTE } from "../constants.js";
1
+ import { DEFAULT_THEMES, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, UNSAFE_CSS_ATTRIBUTE } from "../constants.js";
2
2
  import { LineSelectionManager, pluckLineSelectionOptions } from "../managers/LineSelectionManager.js";
3
3
  import { MouseEventManager, pluckMouseEventOptions } from "../managers/MouseEventManager.js";
4
4
  import { ResizeManager } from "../managers/ResizeManager.js";
@@ -10,7 +10,7 @@ import { areFilesEqual } from "../utils/areFilesEqual.js";
10
10
  import { areLineAnnotationsEqual } from "../utils/areLineAnnotationsEqual.js";
11
11
  import { arePrePropertiesEqual } from "../utils/arePrePropertiesEqual.js";
12
12
  import { createAnnotationWrapperNode } from "../utils/createAnnotationWrapperNode.js";
13
- import { createHoverContentNode } from "../utils/createHoverContentNode.js";
13
+ import { createGutterUtilityContentNode } from "../utils/createGutterUtilityContentNode.js";
14
14
  import { createUnsafeCSSStyleNode } from "../utils/createUnsafeCSSStyleNode.js";
15
15
  import { wrapUnsafeCSS } from "../utils/cssWrappers.js";
16
16
  import { getOrCreateCodeNode } from "../utils/getOrCreateCodeNode.js";
@@ -32,13 +32,14 @@ var File = class {
32
32
  bufferBefore;
33
33
  bufferAfter;
34
34
  unsafeCSSStyle;
35
- hoverContent;
35
+ gutterUtilityContent;
36
36
  errorWrapper;
37
37
  placeHolder;
38
38
  lastRenderedHeaderHTML;
39
39
  appliedPreAttributes;
40
40
  lastRowCount;
41
41
  headerElement;
42
+ headerPrefix;
42
43
  headerMetadata;
43
44
  fileRenderer;
44
45
  resizeManager;
@@ -124,6 +125,8 @@ var File = class {
124
125
  this.appliedPreAttributes = void 0;
125
126
  this.lastRowCount = void 0;
126
127
  this.headerElement = void 0;
128
+ this.headerPrefix = void 0;
129
+ this.headerMetadata = void 0;
127
130
  this.lastRenderedHeaderHTML = void 0;
128
131
  this.errorWrapper = void 0;
129
132
  this.unsafeCSSStyle = void 0;
@@ -163,7 +166,7 @@ var File = class {
163
166
  this.file = file;
164
167
  this.fileRenderer.hydrate(file);
165
168
  this.renderAnnotations();
166
- this.renderHoverUtility();
169
+ this.renderGutterUtility();
167
170
  this.injectUnsafeCSS();
168
171
  this.mouseEventManager.setup(this.pre);
169
172
  this.lineSelectionManager.setup(this.pre);
@@ -174,11 +177,13 @@ var File = class {
174
177
  return file != null ? this.fileRenderer.getOrCreateLineCache(file) : EMPTY_STRINGS;
175
178
  }
176
179
  render({ file, fileContainer, forceRender = false, containerWrapper, lineAnnotations, renderRange }) {
180
+ const { collapsed = false } = this.options;
181
+ const nextRenderRange = collapsed ? void 0 : renderRange;
177
182
  const previousRenderRange = this.renderRange;
178
183
  const annotationsChanged = lineAnnotations != null && (lineAnnotations.length > 0 || this.lineAnnotations.length > 0) ? lineAnnotations !== this.lineAnnotations : false;
179
184
  const didFileChange = !areFilesEqual(this.file, file);
180
- if (!forceRender && areRenderRangesEqual(renderRange, this.renderRange) && !didFileChange && !annotationsChanged) return false;
181
- this.renderRange = renderRange;
185
+ if (!collapsed && !forceRender && areRenderRangesEqual(nextRenderRange, this.renderRange) && !didFileChange && !annotationsChanged) return false;
186
+ this.renderRange = nextRenderRange;
182
187
  this.file = file;
183
188
  this.fileRenderer.setOptions(this.options);
184
189
  if (lineAnnotations != null) this.setLineAnnotations(lineAnnotations);
@@ -190,12 +195,34 @@ var File = class {
190
195
  this.headerElement = void 0;
191
196
  this.lastRenderedHeaderHTML = void 0;
192
197
  }
198
+ if (this.headerPrefix != null) {
199
+ this.headerPrefix.parentNode?.removeChild(this.headerPrefix);
200
+ this.headerPrefix = void 0;
201
+ }
202
+ if (this.headerMetadata != null) {
203
+ this.headerMetadata.parentNode?.removeChild(this.headerMetadata);
204
+ this.headerMetadata = void 0;
205
+ }
193
206
  }
194
207
  fileContainer = this.getOrCreateFileContainerNode(fileContainer, containerWrapper);
208
+ if (collapsed) {
209
+ this.removeRenderedCode();
210
+ this.clearAuxiliaryNodes();
211
+ try {
212
+ const fileResult = this.fileRenderer.renderFile(file, EMPTY_RENDER_RANGE);
213
+ if (fileResult?.headerAST != null) this.applyHeaderToDOM(fileResult.headerAST, fileContainer);
214
+ this.injectUnsafeCSS();
215
+ } catch (error) {
216
+ if (disableErrorHandling) throw error;
217
+ console.error(error);
218
+ if (error instanceof Error) this.applyErrorToDOM(error, fileContainer);
219
+ }
220
+ return true;
221
+ }
195
222
  try {
196
223
  const pre = this.getOrCreatePreNode(fileContainer);
197
- if (!this.canPartiallyRender(forceRender, annotationsChanged, didFileChange) || !this.applyPartialRender(previousRenderRange, renderRange)) {
198
- const fileResult = this.fileRenderer.renderFile(file, renderRange);
224
+ if (!this.canPartiallyRender(forceRender, annotationsChanged, didFileChange) || !this.applyPartialRender(previousRenderRange, nextRenderRange)) {
225
+ const fileResult = this.fileRenderer.renderFile(file, nextRenderRange);
199
226
  if (fileResult == null) {
200
227
  if (this.workerManager?.isInitialized() === false) this.workerManager.initialize().then(() => this.rerender());
201
228
  return false;
@@ -203,13 +230,13 @@ var File = class {
203
230
  if (fileResult.headerAST != null) this.applyHeaderToDOM(fileResult.headerAST, fileContainer);
204
231
  this.applyFullRender(fileResult, pre);
205
232
  }
206
- this.applyBuffers(pre, renderRange);
233
+ this.applyBuffers(pre, nextRenderRange);
207
234
  this.injectUnsafeCSS();
208
235
  this.mouseEventManager.setup(pre);
209
236
  this.lineSelectionManager.setup(pre);
210
237
  this.resizeManager.setup(pre, overflow === "wrap");
211
238
  this.renderAnnotations();
212
- this.renderHoverUtility();
239
+ this.renderGutterUtility();
213
240
  } catch (error) {
214
241
  if (disableErrorHandling) throw error;
215
242
  console.error(error);
@@ -217,6 +244,27 @@ var File = class {
217
244
  }
218
245
  return true;
219
246
  }
247
+ removeRenderedCode() {
248
+ this.resizeManager.cleanUp();
249
+ this.mouseEventManager.cleanUp();
250
+ this.lineSelectionManager.cleanUp();
251
+ this.bufferBefore?.remove();
252
+ this.bufferBefore = void 0;
253
+ this.bufferAfter?.remove();
254
+ this.bufferAfter = void 0;
255
+ this.code?.remove();
256
+ this.code = void 0;
257
+ this.pre?.remove();
258
+ this.pre = void 0;
259
+ this.appliedPreAttributes = void 0;
260
+ this.lastRowCount = void 0;
261
+ }
262
+ clearAuxiliaryNodes() {
263
+ for (const { element } of this.annotationCache.values()) element.parentNode?.removeChild(element);
264
+ this.annotationCache.clear();
265
+ this.gutterUtilityContent?.remove();
266
+ this.gutterUtilityContent = void 0;
267
+ }
220
268
  canPartiallyRender(forceRender, annotationsChanged, didContentChange) {
221
269
  if (forceRender || annotationsChanged || didContentChange) return false;
222
270
  return true;
@@ -242,7 +290,9 @@ var File = class {
242
290
  this.code?.remove();
243
291
  this.errorWrapper?.remove();
244
292
  this.headerElement?.remove();
245
- this.hoverContent?.remove();
293
+ this.gutterUtilityContent?.remove();
294
+ this.headerPrefix?.remove();
295
+ this.headerMetadata?.remove();
246
296
  this.pre?.remove();
247
297
  this.spriteSVG?.remove();
248
298
  this.unsafeCSSStyle?.remove();
@@ -251,7 +301,9 @@ var File = class {
251
301
  this.code = void 0;
252
302
  this.errorWrapper = void 0;
253
303
  this.headerElement = void 0;
254
- this.hoverContent = void 0;
304
+ this.gutterUtilityContent = void 0;
305
+ this.headerPrefix = void 0;
306
+ this.headerMetadata = void 0;
255
307
  this.pre = void 0;
256
308
  this.spriteSVG = void 0;
257
309
  this.unsafeCSSStyle = void 0;
@@ -288,19 +340,24 @@ var File = class {
288
340
  element.parentNode?.removeChild(element);
289
341
  }
290
342
  }
291
- renderHoverUtility() {
292
- const { renderHoverUtility } = this.options;
293
- if (this.fileContainer == null || renderHoverUtility == null) return;
294
- const element = renderHoverUtility(this.mouseEventManager.getHoveredLine);
295
- if (element != null && this.hoverContent != null) return;
343
+ renderGutterUtility() {
344
+ const renderGutterUtility = this.options.renderGutterUtility ?? this.options.renderHoverUtility;
345
+ if (this.fileContainer == null || renderGutterUtility == null) {
346
+ this.gutterUtilityContent?.remove();
347
+ this.gutterUtilityContent = void 0;
348
+ return;
349
+ }
350
+ const element = renderGutterUtility(this.mouseEventManager.getHoveredLine);
351
+ if (element != null && this.gutterUtilityContent != null) return;
296
352
  else if (element == null) {
297
- this.hoverContent?.parentNode?.removeChild(this.hoverContent);
298
- this.hoverContent = void 0;
353
+ this.gutterUtilityContent?.parentNode?.removeChild(this.gutterUtilityContent);
354
+ this.gutterUtilityContent = void 0;
299
355
  return;
300
356
  }
301
- this.hoverContent = createHoverContentNode();
302
- this.hoverContent.appendChild(element);
303
- this.fileContainer.appendChild(this.hoverContent);
357
+ const gutterUtilityContent = createGutterUtilityContentNode();
358
+ gutterUtilityContent.appendChild(element);
359
+ this.fileContainer.appendChild(gutterUtilityContent);
360
+ this.gutterUtilityContent = gutterUtilityContent;
304
361
  }
305
362
  injectUnsafeCSS() {
306
363
  if (this.fileContainer?.shadowRoot == null) return;
@@ -474,9 +531,18 @@ var File = class {
474
531
  this.lastRenderedHeaderHTML = headerHTML;
475
532
  }
476
533
  if (this.isContainerManaged) return;
477
- const { renderCustomMetadata } = this.options;
534
+ const { renderHeaderPrefix, renderCustomMetadata } = this.options;
535
+ if (this.headerPrefix != null) this.headerPrefix.parentNode?.removeChild(this.headerPrefix);
478
536
  if (this.headerMetadata != null) this.headerMetadata.parentNode?.removeChild(this.headerMetadata);
537
+ const prefix = renderHeaderPrefix?.(file) ?? void 0;
479
538
  const content = renderCustomMetadata?.(file) ?? void 0;
539
+ if (prefix != null) {
540
+ this.headerPrefix = document.createElement("div");
541
+ this.headerPrefix.slot = HEADER_PREFIX_SLOT_ID;
542
+ if (prefix instanceof Element) this.headerPrefix.appendChild(prefix);
543
+ else this.headerPrefix.innerText = `${prefix}`;
544
+ container.appendChild(this.headerPrefix);
545
+ }
480
546
  if (content != null) {
481
547
  this.headerMetadata = document.createElement("div");
482
548
  this.headerMetadata.slot = HEADER_METADATA_SLOT_ID;