@pierre/diffs 1.1.0-beta.9 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -18
- package/dist/components/AdvancedVirtualizedFileDiff.js +2 -7
- package/dist/components/AdvancedVirtualizedFileDiff.js.map +1 -1
- package/dist/components/AdvancedVirtualizer.js +1 -1
- package/dist/components/AdvancedVirtualizer.js.map +1 -1
- package/dist/components/File.d.ts +18 -8
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +111 -54
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +33 -15
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +156 -81
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +60 -0
- package/dist/components/UnresolvedFile.d.ts.map +1 -0
- package/dist/components/UnresolvedFile.js +280 -0
- package/dist/components/UnresolvedFile.js.map +1 -0
- package/dist/components/VirtualizedFile.js +8 -5
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +15 -11
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +3 -1
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +50 -24
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/constants.d.ts +3 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +8 -1
- package/dist/constants.js.map +1 -1
- package/dist/highlighter/shared_highlighter.d.ts +4 -2
- package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.js +15 -7
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +8 -6
- package/dist/managers/InteractionManager.d.ts +146 -0
- package/dist/managers/InteractionManager.d.ts.map +1 -0
- package/dist/managers/InteractionManager.js +813 -0
- package/dist/managers/InteractionManager.js.map +1 -0
- package/dist/managers/ResizeManager.d.ts +0 -2
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +43 -32
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/react/File.d.ts +2 -0
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +5 -2
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +2 -0
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +5 -2
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +2 -0
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +5 -2
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +2 -0
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +5 -2
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +36 -0
- package/dist/react/UnresolvedFile.d.ts.map +1 -0
- package/dist/react/UnresolvedFile.js +43 -0
- package/dist/react/UnresolvedFile.js.map +1 -0
- package/dist/react/constants.d.ts +4 -2
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/constants.js +6 -2
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.js +3 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/types.d.ts +11 -2
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +16 -5
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +34 -7
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +5 -1
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +13 -7
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +4 -3
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +16 -7
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +4 -3
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +14 -5
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +35 -0
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -0
- package/dist/react/utils/useUnresolvedFileInstance.js +88 -0
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -0
- package/dist/renderers/DiffHunksRenderer.d.ts +50 -6
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +145 -45
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.js +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +46 -0
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -0
- package/dist/renderers/UnresolvedFileHunksRenderer.js +207 -0
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -0
- package/dist/shiki-stream/stream.d.ts +1 -1
- package/dist/shiki-stream/stream.d.ts.map +1 -1
- package/dist/shiki-stream/stream.js.map +1 -1
- package/dist/shiki-stream/tokenizer.d.ts +1 -1
- package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
- package/dist/shiki-stream/tokenizer.js.map +1 -1
- package/dist/shiki-stream/types.d.ts +1 -1
- package/dist/shiki-stream/types.d.ts.map +1 -1
- package/dist/sprite.d.ts +2 -2
- package/dist/sprite.d.ts.map +1 -1
- package/dist/sprite.js +3 -0
- package/dist/sprite.js.map +1 -1
- package/dist/ssr/index.d.ts +3 -3
- package/dist/ssr/index.js +2 -2
- package/dist/ssr/preloadDiffs.d.ts +23 -14
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +40 -14
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +29 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.d.ts +7 -0
- package/dist/utils/areMergeConflictActionsEqual.d.ts.map +1 -0
- package/dist/utils/areMergeConflictActionsEqual.js +11 -0
- package/dist/utils/areMergeConflictActionsEqual.js.map +1 -0
- package/dist/utils/arePrePropertiesEqual.js +10 -1
- package/dist/utils/arePrePropertiesEqual.js.map +1 -1
- package/dist/utils/areSelectionPointsEqual.d.ts +7 -0
- package/dist/utils/areSelectionPointsEqual.d.ts.map +1 -0
- package/dist/utils/areSelectionPointsEqual.js +8 -0
- package/dist/utils/areSelectionPointsEqual.js.map +1 -0
- package/dist/utils/areSelectionsEqual.d.ts +1 -1
- package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
- package/dist/utils/areSelectionsEqual.js.map +1 -1
- package/dist/utils/createFileHeaderElement.js +5 -2
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createGutterUtilityContentNode.d.ts +5 -0
- package/dist/utils/createGutterUtilityContentNode.d.ts.map +1 -0
- package/dist/utils/createGutterUtilityContentNode.js +15 -0
- package/dist/utils/createGutterUtilityContentNode.js.map +1 -0
- package/dist/utils/createGutterUtilityElement.d.ts +7 -0
- package/dist/utils/createGutterUtilityElement.d.ts.map +1 -0
- package/dist/utils/createGutterUtilityElement.js +20 -0
- package/dist/utils/createGutterUtilityElement.js.map +1 -0
- package/dist/utils/createPreElement.d.ts +2 -1
- package/dist/utils/createPreElement.d.ts.map +1 -1
- package/dist/utils/createPreElement.js +2 -1
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/createSeparator.js +1 -1
- package/dist/utils/createSeparator.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.js +12 -11
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
- package/dist/utils/getHighlighterOptions.d.ts +7 -2
- package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
- package/dist/utils/getHighlighterOptions.js +3 -2
- package/dist/utils/getHighlighterOptions.js.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.d.ts +16 -0
- package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -0
- package/dist/utils/getMergeConflictActionSlotName.js +8 -0
- package/dist/utils/getMergeConflictActionSlotName.js.map +1 -0
- package/dist/utils/getMergeConflictLineTypes.d.ts +15 -0
- package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -0
- package/dist/utils/getMergeConflictLineTypes.js +81 -0
- package/dist/utils/getMergeConflictLineTypes.js.map +1 -0
- package/dist/utils/getOrCreateCodeNode.d.ts +3 -1
- package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -1
- package/dist/utils/getOrCreateCodeNode.js +5 -3
- package/dist/utils/getOrCreateCodeNode.js.map +1 -1
- package/dist/utils/hast_utils.d.ts +2 -2
- package/dist/utils/hast_utils.d.ts.map +1 -1
- package/dist/utils/hast_utils.js +3 -2
- package/dist/utils/hast_utils.js.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts +26 -0
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js +143 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -0
- package/dist/utils/resolveMergeConflict.d.ts +7 -0
- package/dist/utils/resolveMergeConflict.d.ts.map +1 -0
- package/dist/utils/resolveMergeConflict.js +30 -0
- package/dist/utils/resolveMergeConflict.js.map +1 -0
- package/dist/utils/resolveVirtualFileMetrics.js +1 -0
- package/dist/utils/resolveVirtualFileMetrics.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.d.ts +2 -1
- package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +5 -1
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +4 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +16 -9
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/types.d.ts +3 -1
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/wasm-BlUZCxHM.js +10 -0
- package/dist/worker/wasm-BlUZCxHM.js.map +1 -0
- package/dist/worker/worker-portable.js +10546 -10106
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +27 -19
- package/dist/worker/worker.js.map +1 -1
- package/package.json +3 -7
- package/dist/managers/LineSelectionManager.d.ts +0 -64
- package/dist/managers/LineSelectionManager.d.ts.map +0 -1
- package/dist/managers/LineSelectionManager.js +0 -270
- package/dist/managers/LineSelectionManager.js.map +0 -1
- package/dist/managers/MouseEventManager.d.ts +0 -71
- package/dist/managers/MouseEventManager.d.ts.map +0 -1
- package/dist/managers/MouseEventManager.js +0 -358
- package/dist/managers/MouseEventManager.js.map +0 -1
- package/dist/themes/pierre-dark.js +0 -1328
- package/dist/themes/pierre-dark.js.map +0 -1
- package/dist/themes/pierre-light.js +0 -1328
- package/dist/themes/pierre-light.js.map +0 -1
- package/dist/utils/createHoverContentNode.d.ts +0 -5
- package/dist/utils/createHoverContentNode.d.ts.map +0 -1
- package/dist/utils/createHoverContentNode.js +0 -15
- package/dist/utils/createHoverContentNode.js.map +0 -1
package/README.md
CHANGED
|
@@ -72,26 +72,15 @@ cd packages/diffs
|
|
|
72
72
|
bun publish
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
## Building
|
|
75
|
+
## Building the sprite
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
To build all our SVG icons from Figma there's a couple preparation steps that
|
|
80
|
-
you need to run first.
|
|
81
|
-
|
|
82
|
-
Perform a full export of all `Published Icons` the `Pierre Design` Figma file
|
|
83
|
-
|
|
84
|
-
Do this by selecting all the icons but not the art board and in the bottom right
|
|
85
|
-
click `Export XXX Layers` and make sure to point it to a `./svg` folder at the
|
|
86
|
-
root level of this project
|
|
87
|
-
|
|
88
|
-
Once that's done, simply run:
|
|
77
|
+
The diff UI uses an SVG sprite built from `@pierre/icons`. From the monorepo
|
|
78
|
+
root:
|
|
89
79
|
|
|
90
80
|
```bash
|
|
91
|
-
bun run icons:
|
|
81
|
+
bun run icons:sprite
|
|
92
82
|
```
|
|
93
83
|
|
|
94
|
-
This
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Then make sure to check in any changes needed
|
|
84
|
+
This reads SVGs from `node_modules/@pierre/icons/svg` and writes
|
|
85
|
+
`packages/diffs/src/sprite.ts`. Run after updating `@pierre/icons` or changing
|
|
86
|
+
`sprite.config.js`.
|
|
@@ -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,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,mBAAmB;AACtB,QAAK,iBAAiB;AACtB,QAAK,eAAe;SACf;AACL,QAA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Line: 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,mBAAmB;AACtB,QAAK,iBAAiB;AACtB,QAAK,eAAe;SACf;AACL,QAAK,iBAAiB;AACtB,QAAK,eAAe;;AAMtB,OAAK,MAAM,QAAQ,SAAS,OAAO;AACjC,QAAK,iBAAiB,KAAK,mBAAmB;AAC9C,QAAK,eAAe,KAAK,iBAAiB;;EAI5C,MAAM,YAAY,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AC/B,YAAW;AAEb,uBAAmB;;GAErB,MAAMC,kBACJ,cAAc,UAAU,KAAK,iBAAiB,KAAK;AACrD,QAAK,IAAI,IAAI,GAAG,IAAIA,iBAAe,KAAK;AACtC,QAAI,cAAcA,oBAAkB,EAClC,aAAY,KACV,mBAAmB,UAAU,gBAAgB,MAAM,IAAI,UAAU,IAClE;AAEH,QACE,gBAAgB,QAChB,kBAAkB,MAAM,cACxB,kBAAkB,QAClB;AACA,oBAAe;AACf,kBAAa,eAAe;eACnB,gBAAgB,QAAQ,kBAAkB,OACnD;AAEF;AACA,uBAAmB;;;AAIvB,MAAI,gBAAgB,KAClB,QAAO;GACL,cAAc;GACd,YAAY;GACZ,cAAc,aAAa;GAC3B,aAAa;GACd;AAGH,iBAAe,KAAK,MAAM,eAAe,cAAc,GAAG;EAC1D,MAAM,aACJ,KAAK,MAAM,aAAa,gBAAgB,cAAc,GAAG;EAE3D,MAAM,yBAAyB,eAAe,cAAc;EAC5D,MAAM,eAAe,YAAY,eAAe,kBAAkB;EAClE,MAAM,cACJ,wBAAwB,YAAY,SAChC,aACA,eACA,YAAY,yBACZ,UACA;AACN,SAAO;GAAE;GAAc;GAAY;GAAc;GAAa;;;AAIlE,SAAS,SACP,UACA,OAA4B,SAC5B;AACA,KAAI,SAAS,QACX,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"}
|
|
@@ -181,7 +181,7 @@ var AdvancedVirtualizer = class AdvancedVirtualizer {
|
|
|
181
181
|
};
|
|
182
182
|
function cleanupRenderedItem(item) {
|
|
183
183
|
item.instance.cleanUp(true);
|
|
184
|
-
item.element.
|
|
184
|
+
item.element.remove();
|
|
185
185
|
item.element.innerHTML = "";
|
|
186
186
|
if (item.element.shadowRoot != null) item.element.shadowRoot.innerHTML = "";
|
|
187
187
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdvancedVirtualizer.js","names":["container: HTMLElement","fileOptions: FileDiffOptions<LAnnotations>","metrics: VirtualFileMetrics","workerManager?: WorkerPoolManager | undefined","prevElement: HTMLElement | undefined","firstInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined","lastInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined"],"sources":["../../src/components/AdvancedVirtualizer.ts"],"sourcesContent":["import {\n DEFAULT_THEMES,\n DEFAULT_VIRTUAL_FILE_METRICS,\n DIFFS_TAG_NAME,\n} from '../constants';\nimport { queueRender } from '../managers/UniversalRenderingManager';\nimport type { VirtualFileMetrics } from '../types';\nimport type { ParsedPatch } from '../types';\nimport { createWindowFromScrollPosition } from '../utils/createWindowFromScrollPosition';\nimport type { WorkerPoolManager } from '../worker';\nimport { AdvancedVirtualizedFileDiff } from './AdvancedVirtualizedFileDiff';\nimport type { FileDiffOptions } from './FileDiff';\n\nconst ENABLE_RENDERING = true;\nconst OVERSCROLL_SIZE = 500;\n\ninterface RenderedItems<LAnnotations> {\n instance: AdvancedVirtualizedFileDiff<LAnnotations>;\n element: HTMLElement;\n}\n\nexport class AdvancedVirtualizer<LAnnotations = undefined> {\n static __STOP = false;\n static __lastScrollPosition = 0;\n\n public type = 'advanced';\n private files: AdvancedVirtualizedFileDiff<LAnnotations>[] = [];\n private totalHeightUnified = 0;\n private totalHeightSplit = 0;\n private rendered: Map<\n AdvancedVirtualizedFileDiff<LAnnotations>,\n RenderedItems<LAnnotations>\n > = new Map();\n\n private containerOffset = 0;\n private scrollTop: number = 0;\n private lastRenderedScrollY = -1;\n private height: number = 0;\n private scrollHeight: number = 0;\n private initialized = false;\n\n private stickyContainer: HTMLElement;\n private stickyOffset: HTMLElement;\n\n constructor(\n private container: HTMLElement,\n private fileOptions: FileDiffOptions<LAnnotations> = {\n theme: DEFAULT_THEMES,\n // FIXME(amadeus): Fix selected lines crashing when scroll out of the window\n enableLineSelection: true,\n disableVirtualizationBuffers: true,\n diffStyle: 'split',\n },\n private metrics: VirtualFileMetrics = DEFAULT_VIRTUAL_FILE_METRICS,\n private workerManager?: WorkerPoolManager | undefined\n ) {\n this.stickyOffset = document.createElement('div');\n this.stickyOffset.style.contain = 'layout size';\n this.stickyContainer = document.createElement('div');\n this.stickyContainer.style.contain = 'strict';\n this.stickyContainer.style.position = 'sticky';\n this.stickyContainer.style.width = '100%';\n this.stickyContainer.style.contain = 'strict';\n this.stickyContainer.style.isolation = 'isolate';\n this.container.appendChild(this.stickyOffset);\n this.container.appendChild(this.stickyContainer);\n this.handleScroll();\n this.handleResize();\n this.containerOffset =\n this.container.getBoundingClientRect().top + this.scrollTop;\n\n // FIXME(amadeus): Remove me before release\n window.__INSTANCE = this;\n window.__TOGGLE = () => {\n if (AdvancedVirtualizer.__STOP) {\n AdvancedVirtualizer.__STOP = false;\n window.scrollTo({ top: AdvancedVirtualizer.__lastScrollPosition });\n queueRender(this._render);\n } else {\n AdvancedVirtualizer.__lastScrollPosition = window.scrollY;\n AdvancedVirtualizer.__STOP = true;\n }\n };\n }\n\n reset(): void {\n this.files.length = 0;\n this.totalHeightSplit = 0;\n this.totalHeightUnified = 0;\n for (const [, item] of Array.from(this.rendered)) {\n cleanupRenderedItem(item);\n }\n this.rendered.clear();\n this.stickyContainer.innerHTML = '';\n this.stickyOffset.style.height = '';\n this.initialized = false;\n this.container.style.height = '';\n this.scrollHeight = 0;\n window.removeEventListener('scroll', this.handleScroll);\n window.removeEventListener('resize', this.handleResize);\n }\n\n addFiles(parsedPatches: ParsedPatch[]): void {\n for (const patch of parsedPatches) {\n for (const fileDiff of patch.files) {\n const vFileDiff = new AdvancedVirtualizedFileDiff<LAnnotations>(\n {\n unifiedTop: this.totalHeightUnified,\n splitTop: this.totalHeightSplit,\n fileDiff,\n },\n this.fileOptions,\n this.metrics,\n this.workerManager\n );\n\n // NOTE(amadeus): I hate this, lol... probably should figure out a way\n // to not immediately subscribe\n vFileDiff.cleanUp(true);\n this.files.push(vFileDiff);\n this.totalHeightUnified +=\n vFileDiff.unifiedHeight + this.metrics.fileGap;\n this.totalHeightSplit += vFileDiff.splitHeight + this.metrics.fileGap;\n }\n }\n }\n\n render(): void {\n this.setupContainer();\n if (!ENABLE_RENDERING) return;\n queueRender(this._render);\n }\n\n _render = (): void => {\n if (this.files.length === 0 || AdvancedVirtualizer.__STOP) {\n return;\n }\n const { diffStyle = 'split' } = this.fileOptions;\n const { scrollTop, height, scrollHeight, containerOffset } = this;\n const fitPerfectly =\n this.lastRenderedScrollY === -1 ||\n Math.abs(scrollTop - this.lastRenderedScrollY) >\n height + OVERSCROLL_SIZE * 2;\n const { top, bottom } = createWindowFromScrollPosition({\n scrollTop,\n height,\n scrollHeight,\n containerOffset,\n fitPerfectly,\n overscrollSize: OVERSCROLL_SIZE,\n });\n this.lastRenderedScrollY = scrollTop;\n for (const [renderedInstance, item] of Array.from(this.rendered)) {\n // If not visible, we should unmount it\n if (\n !(\n getInstanceSpecs(renderedInstance, diffStyle).top >\n top - getInstanceSpecs(renderedInstance, diffStyle).height &&\n getInstanceSpecs(renderedInstance, diffStyle).top <= bottom\n )\n ) {\n cleanupRenderedItem(item);\n this.rendered.delete(renderedInstance);\n }\n }\n let prevElement: HTMLElement | undefined;\n let firstInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined;\n let lastInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined;\n for (const instance of this.files) {\n // We can stop iterating when we get to elements after the window\n if (getInstanceSpecs(instance, diffStyle).top > bottom) {\n break;\n }\n if (\n getInstanceSpecs(instance, diffStyle).top <\n top - getInstanceSpecs(instance, diffStyle).height\n ) {\n continue;\n }\n const rendered = this.rendered.get(instance);\n if (rendered == null) {\n const fileContainer = document.createElement(DIFFS_TAG_NAME);\n // NOTE(amadeus): We gotta append first to ensure file ordering is\n // correct... but i guess maybe doesn't matter because we are positioning shit\n if (prevElement == null) {\n this.stickyContainer.prepend(fileContainer);\n } else if (prevElement.nextSibling !== fileContainer) {\n prevElement.after(fileContainer);\n }\n instance.virtualizedSetup();\n\n this.rendered.set(instance, {\n element: fileContainer,\n instance: instance,\n });\n instance.virtualizedRender({\n fileContainer,\n renderWindow: { top, bottom },\n });\n prevElement = fileContainer;\n } else {\n prevElement = rendered.element;\n rendered.instance.virtualizedRender({\n renderWindow: { top, bottom },\n });\n }\n firstInstance ??= instance;\n lastInstance = instance;\n }\n\n if (\n firstInstance?.renderedRange != null &&\n lastInstance?.renderedRange != null\n ) {\n const firstSpecs = getInstanceSpecs(firstInstance, diffStyle);\n const lastSpecs = getInstanceSpecs(lastInstance, diffStyle);\n const stickyTop = Math.max(\n Math.min(firstSpecs.top + firstInstance.renderedRange.bufferBefore),\n 0\n );\n const lastBuffer =\n lastInstance.renderedRange.totalLines === 0\n ? lastInstance.renderedRange.bufferBefore\n : lastInstance.renderedRange.bufferAfter;\n const stickyBottom = Math.max(\n 0,\n lastSpecs.top + lastSpecs.height - lastBuffer\n );\n const totalHeight = stickyBottom - stickyTop;\n this.stickyOffset.style.height = `${stickyTop}px`;\n this.stickyContainer.style.top = `${-totalHeight + height + this.metrics.fileGap}px`;\n this.stickyContainer.style.bottom = `${-totalHeight + height}px`;\n this.stickyContainer.style.height = `${totalHeight}px`;\n }\n\n if (fitPerfectly) {\n queueRender(this._render);\n }\n };\n\n private setupContainer() {\n const { diffStyle = 'split' } = this.fileOptions;\n this.container.style.height = `${diffStyle === 'split' ? this.totalHeightSplit : this.totalHeightUnified}px`;\n this.scrollHeight = document.documentElement.scrollHeight;\n if (!this.initialized) {\n window.addEventListener('scroll', this.handleScroll, { passive: true });\n window.addEventListener('resize', this.handleResize);\n this.initialized = true;\n }\n }\n\n handleScroll = (): void => {\n let { scrollY: scrollTop } = window;\n scrollTop = Math.max(scrollTop, 0);\n if (this.scrollTop === scrollTop) return;\n this.scrollTop = scrollTop;\n if (this.files.length === 0) return;\n queueRender(this._render);\n };\n\n handleResize = (): void => {\n const { innerHeight: height } = window;\n const { scrollHeight } = document.documentElement;\n if (this.height === height && this.scrollHeight === scrollHeight) {\n return;\n }\n this.height = height;\n this.scrollHeight = scrollHeight;\n if (this.files.length > 0) {\n queueRender(this._render);\n }\n };\n}\n\nfunction cleanupRenderedItem<LAnnotations>(item: RenderedItems<LAnnotations>) {\n item.instance.cleanUp(true);\n item.element.parentNode?.removeChild(item.element);\n item.element.innerHTML = '';\n if (item.element.shadowRoot != null) {\n item.element.shadowRoot.innerHTML = '';\n }\n}\n\nfunction getInstanceSpecs<LAnnotations>(\n instance: AdvancedVirtualizedFileDiff<LAnnotations>,\n diffStyle: 'split' | 'unified' = 'split'\n) {\n if (diffStyle === 'split') {\n return {\n top: instance.splitTop,\n height: instance.splitHeight,\n };\n }\n return {\n top: instance.unifiedTop,\n height: instance.unifiedHeight,\n };\n}\n"],"mappings":";;;;;;AAcA,MAAM,kBAAkB;AAOxB,IAAa,sBAAb,MAAa,oBAA8C;CACzD,OAAO,SAAS;CAChB,OAAO,uBAAuB;CAE9B,AAAO,OAAO;CACd,AAAQ,QAAqD,EAAE;CAC/D,AAAQ,qBAAqB;CAC7B,AAAQ,mBAAmB;CAC3B,AAAQ,2BAGJ,IAAI,KAAK;CAEb,AAAQ,kBAAkB;CAC1B,AAAQ,YAAoB;CAC5B,AAAQ,sBAAsB;CAC9B,AAAQ,SAAiB;CACzB,AAAQ,eAAuB;CAC/B,AAAQ,cAAc;CAEtB,AAAQ;CACR,AAAQ;CAER,YACE,AAAQA,WACR,AAAQC,cAA6C;EACnD,OAAO;EAEP,qBAAqB;EACrB,8BAA8B;EAC9B,WAAW;EACZ,EACD,AAAQC,UAA8B,8BACtC,AAAQC,eACR;EAVQ;EACA;EAOA;EACA;AAER,OAAK,eAAe,SAAS,cAAc,MAAM;AACjD,OAAK,aAAa,MAAM,UAAU;AAClC,OAAK,kBAAkB,SAAS,cAAc,MAAM;AACpD,OAAK,gBAAgB,MAAM,UAAU;AACrC,OAAK,gBAAgB,MAAM,WAAW;AACtC,OAA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cAAY,KAAK,QAAQ;;CAG3B,qBAA2B;EACzB,MAAM,EAAE,aAAa,WAAW;EAChC,MAAM,EAAE,iBAAiB,SAAS;AAClC,MAAI,KAAK,WAAW,UAAU,KAAK,iBAAiB,aAClD;AAEF,OAAK,SAAS;AACd,OAAK,eAAe;AACpB,MAAI,KAAK,MAAM,SAAS,EACtB,aAAY,KAAK,QAAQ;;;AAK/B,SAAS,oBAAkC,MAAmC;AAC5E,MAAK,SAAS,QAAQ,KAAK;AAC3B,MAAK,QAAQ,YAAY,YAAY,KAAK,QAAQ;AAClD,MAAK,QAAQ,YAAY;AACzB,KAAI,KAAK,QAAQ,cAAc,KAC7B,MAAK,QAAQ,WAAW,YAAY;;AAIxC,SAAS,iBACP,UACA,YAAiC,SACjC;AACA,KAAI,cAAc,QAChB,QAAO;EACL,KAAK,SAAS;EACd,QAAQ,SAAS;EAClB;AAEH,QAAO;EACL,KAAK,SAAS;EACd,QAAQ,SAAS;EAClB"}
|
|
1
|
+
{"version":3,"file":"AdvancedVirtualizer.js","names":["container: HTMLElement","fileOptions: FileDiffOptions<LAnnotations>","metrics: VirtualFileMetrics","workerManager?: WorkerPoolManager | undefined","prevElement: HTMLElement | undefined","firstInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined","lastInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined"],"sources":["../../src/components/AdvancedVirtualizer.ts"],"sourcesContent":["import {\n DEFAULT_THEMES,\n DEFAULT_VIRTUAL_FILE_METRICS,\n DIFFS_TAG_NAME,\n} from '../constants';\nimport { queueRender } from '../managers/UniversalRenderingManager';\nimport type { VirtualFileMetrics } from '../types';\nimport type { ParsedPatch } from '../types';\nimport { createWindowFromScrollPosition } from '../utils/createWindowFromScrollPosition';\nimport type { WorkerPoolManager } from '../worker';\nimport { AdvancedVirtualizedFileDiff } from './AdvancedVirtualizedFileDiff';\nimport type { FileDiffOptions } from './FileDiff';\n\nconst ENABLE_RENDERING = true;\nconst OVERSCROLL_SIZE = 500;\n\ninterface RenderedItems<LAnnotations> {\n instance: AdvancedVirtualizedFileDiff<LAnnotations>;\n element: HTMLElement;\n}\n\nexport class AdvancedVirtualizer<LAnnotations = undefined> {\n static __STOP = false;\n static __lastScrollPosition = 0;\n\n public type = 'advanced';\n private files: AdvancedVirtualizedFileDiff<LAnnotations>[] = [];\n private totalHeightUnified = 0;\n private totalHeightSplit = 0;\n private rendered: Map<\n AdvancedVirtualizedFileDiff<LAnnotations>,\n RenderedItems<LAnnotations>\n > = new Map();\n\n private containerOffset = 0;\n private scrollTop: number = 0;\n private lastRenderedScrollY = -1;\n private height: number = 0;\n private scrollHeight: number = 0;\n private initialized = false;\n\n private stickyContainer: HTMLElement;\n private stickyOffset: HTMLElement;\n\n constructor(\n private container: HTMLElement,\n private fileOptions: FileDiffOptions<LAnnotations> = {\n theme: DEFAULT_THEMES,\n // FIXME(amadeus): Fix selected lines crashing when scroll out of the window\n enableLineSelection: true,\n disableVirtualizationBuffers: true,\n diffStyle: 'split',\n },\n private metrics: VirtualFileMetrics = DEFAULT_VIRTUAL_FILE_METRICS,\n private workerManager?: WorkerPoolManager | undefined\n ) {\n this.stickyOffset = document.createElement('div');\n this.stickyOffset.style.contain = 'layout size';\n this.stickyContainer = document.createElement('div');\n this.stickyContainer.style.contain = 'strict';\n this.stickyContainer.style.position = 'sticky';\n this.stickyContainer.style.width = '100%';\n this.stickyContainer.style.contain = 'strict';\n this.stickyContainer.style.isolation = 'isolate';\n this.container.appendChild(this.stickyOffset);\n this.container.appendChild(this.stickyContainer);\n this.handleScroll();\n this.handleResize();\n this.containerOffset =\n this.container.getBoundingClientRect().top + this.scrollTop;\n\n // FIXME(amadeus): Remove me before release\n window.__INSTANCE = this;\n window.__TOGGLE = () => {\n if (AdvancedVirtualizer.__STOP) {\n AdvancedVirtualizer.__STOP = false;\n window.scrollTo({ top: AdvancedVirtualizer.__lastScrollPosition });\n queueRender(this._render);\n } else {\n AdvancedVirtualizer.__lastScrollPosition = window.scrollY;\n AdvancedVirtualizer.__STOP = true;\n }\n };\n }\n\n reset(): void {\n this.files.length = 0;\n this.totalHeightSplit = 0;\n this.totalHeightUnified = 0;\n for (const [, item] of Array.from(this.rendered)) {\n cleanupRenderedItem(item);\n }\n this.rendered.clear();\n this.stickyContainer.innerHTML = '';\n this.stickyOffset.style.height = '';\n this.initialized = false;\n this.container.style.height = '';\n this.scrollHeight = 0;\n window.removeEventListener('scroll', this.handleScroll);\n window.removeEventListener('resize', this.handleResize);\n }\n\n addFiles(parsedPatches: ParsedPatch[]): void {\n for (const patch of parsedPatches) {\n for (const fileDiff of patch.files) {\n const vFileDiff = new AdvancedVirtualizedFileDiff<LAnnotations>(\n {\n unifiedTop: this.totalHeightUnified,\n splitTop: this.totalHeightSplit,\n fileDiff,\n },\n this.fileOptions,\n this.metrics,\n this.workerManager\n );\n\n // NOTE(amadeus): I hate this, lol... probably should figure out a way\n // to not immediately subscribe\n vFileDiff.cleanUp(true);\n this.files.push(vFileDiff);\n this.totalHeightUnified +=\n vFileDiff.unifiedHeight + this.metrics.fileGap;\n this.totalHeightSplit += vFileDiff.splitHeight + this.metrics.fileGap;\n }\n }\n }\n\n render(): void {\n this.setupContainer();\n if (!ENABLE_RENDERING) return;\n queueRender(this._render);\n }\n\n _render = (): void => {\n if (this.files.length === 0 || AdvancedVirtualizer.__STOP) {\n return;\n }\n const { diffStyle = 'split' } = this.fileOptions;\n const { scrollTop, height, scrollHeight, containerOffset } = this;\n const fitPerfectly =\n this.lastRenderedScrollY === -1 ||\n Math.abs(scrollTop - this.lastRenderedScrollY) >\n height + OVERSCROLL_SIZE * 2;\n const { top, bottom } = createWindowFromScrollPosition({\n scrollTop,\n height,\n scrollHeight,\n containerOffset,\n fitPerfectly,\n overscrollSize: OVERSCROLL_SIZE,\n });\n this.lastRenderedScrollY = scrollTop;\n for (const [renderedInstance, item] of Array.from(this.rendered)) {\n // If not visible, we should unmount it\n if (\n !(\n getInstanceSpecs(renderedInstance, diffStyle).top >\n top - getInstanceSpecs(renderedInstance, diffStyle).height &&\n getInstanceSpecs(renderedInstance, diffStyle).top <= bottom\n )\n ) {\n cleanupRenderedItem(item);\n this.rendered.delete(renderedInstance);\n }\n }\n let prevElement: HTMLElement | undefined;\n let firstInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined;\n let lastInstance: AdvancedVirtualizedFileDiff<LAnnotations> | undefined;\n for (const instance of this.files) {\n // We can stop iterating when we get to elements after the window\n if (getInstanceSpecs(instance, diffStyle).top > bottom) {\n break;\n }\n if (\n getInstanceSpecs(instance, diffStyle).top <\n top - getInstanceSpecs(instance, diffStyle).height\n ) {\n continue;\n }\n const rendered = this.rendered.get(instance);\n if (rendered == null) {\n const fileContainer = document.createElement(DIFFS_TAG_NAME);\n // NOTE(amadeus): We gotta append first to ensure file ordering is\n // correct... but i guess maybe doesn't matter because we are positioning shit\n if (prevElement == null) {\n this.stickyContainer.prepend(fileContainer);\n } else if (prevElement.nextSibling !== fileContainer) {\n prevElement.after(fileContainer);\n }\n instance.virtualizedSetup();\n\n this.rendered.set(instance, {\n element: fileContainer,\n instance: instance,\n });\n instance.virtualizedRender({\n fileContainer,\n renderWindow: { top, bottom },\n });\n prevElement = fileContainer;\n } else {\n prevElement = rendered.element;\n rendered.instance.virtualizedRender({\n renderWindow: { top, bottom },\n });\n }\n firstInstance ??= instance;\n lastInstance = instance;\n }\n\n if (\n firstInstance?.renderedRange != null &&\n lastInstance?.renderedRange != null\n ) {\n const firstSpecs = getInstanceSpecs(firstInstance, diffStyle);\n const lastSpecs = getInstanceSpecs(lastInstance, diffStyle);\n const stickyTop = Math.max(\n Math.min(firstSpecs.top + firstInstance.renderedRange.bufferBefore),\n 0\n );\n const lastBuffer =\n lastInstance.renderedRange.totalLines === 0\n ? lastInstance.renderedRange.bufferBefore\n : lastInstance.renderedRange.bufferAfter;\n const stickyBottom = Math.max(\n 0,\n lastSpecs.top + lastSpecs.height - lastBuffer\n );\n const totalHeight = stickyBottom - stickyTop;\n this.stickyOffset.style.height = `${stickyTop}px`;\n this.stickyContainer.style.top = `${-totalHeight + height + this.metrics.fileGap}px`;\n this.stickyContainer.style.bottom = `${-totalHeight + height}px`;\n this.stickyContainer.style.height = `${totalHeight}px`;\n }\n\n if (fitPerfectly) {\n queueRender(this._render);\n }\n };\n\n private setupContainer() {\n const { diffStyle = 'split' } = this.fileOptions;\n this.container.style.height = `${diffStyle === 'split' ? this.totalHeightSplit : this.totalHeightUnified}px`;\n this.scrollHeight = document.documentElement.scrollHeight;\n if (!this.initialized) {\n window.addEventListener('scroll', this.handleScroll, { passive: true });\n window.addEventListener('resize', this.handleResize);\n this.initialized = true;\n }\n }\n\n handleScroll = (): void => {\n let { scrollY: scrollTop } = window;\n scrollTop = Math.max(scrollTop, 0);\n if (this.scrollTop === scrollTop) return;\n this.scrollTop = scrollTop;\n if (this.files.length === 0) return;\n queueRender(this._render);\n };\n\n handleResize = (): void => {\n const { innerHeight: height } = window;\n const { scrollHeight } = document.documentElement;\n if (this.height === height && this.scrollHeight === scrollHeight) {\n return;\n }\n this.height = height;\n this.scrollHeight = scrollHeight;\n if (this.files.length > 0) {\n queueRender(this._render);\n }\n };\n}\n\nfunction cleanupRenderedItem<LAnnotations>(item: RenderedItems<LAnnotations>) {\n item.instance.cleanUp(true);\n item.element.remove();\n item.element.innerHTML = '';\n if (item.element.shadowRoot != null) {\n item.element.shadowRoot.innerHTML = '';\n }\n}\n\nfunction getInstanceSpecs<LAnnotations>(\n instance: AdvancedVirtualizedFileDiff<LAnnotations>,\n diffStyle: 'split' | 'unified' = 'split'\n) {\n if (diffStyle === 'split') {\n return {\n top: instance.splitTop,\n height: instance.splitHeight,\n };\n }\n return {\n top: instance.unifiedTop,\n height: instance.unifiedHeight,\n };\n}\n"],"mappings":";;;;;;AAcA,MAAM,kBAAkB;AAOxB,IAAa,sBAAb,MAAa,oBAA8C;CACzD,OAAO,SAAS;CAChB,OAAO,uBAAuB;CAE9B,AAAO,OAAO;CACd,AAAQ,QAAqD,EAAE;C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fig, RenderFileMetadata, RenderRange, ThemeTypes } from "../types.js";
|
|
2
2
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
3
3
|
import "../worker/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import { GetHoveredLineResult, MouseEventManager, MouseEventManagerBaseOptions } from "../managers/MouseEventManager.js";
|
|
4
|
+
import { GetHoveredLineResult, InteractionManager, InteractionManagerBaseOptions, SelectedLineRange } from "../managers/InteractionManager.js";
|
|
6
5
|
import { ResizeManager } from "../managers/ResizeManager.js";
|
|
7
6
|
import { FileRenderer } from "../renderers/FileRenderer.js";
|
|
8
7
|
|
|
@@ -19,8 +18,13 @@ interface FileHyrdateProps<LAnnotation> extends Omit<FileRenderProps<LAnnotation
|
|
|
19
18
|
fileContainer: HTMLElement;
|
|
20
19
|
prerenderedHTML?: string;
|
|
21
20
|
}
|
|
22
|
-
interface FileOptions<LAnnotation> extends BaseCodeOptions,
|
|
21
|
+
interface FileOptions<LAnnotation> extends BaseCodeOptions, InteractionManagerBaseOptions<'file'> {
|
|
23
22
|
disableFileHeader?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use `enableGutterUtility` instead.
|
|
25
|
+
*/
|
|
26
|
+
enableHoverUtility?: boolean;
|
|
27
|
+
renderHeaderPrefix?: RenderFileMetadata;
|
|
24
28
|
renderCustomMetadata?: RenderFileMetadata;
|
|
25
29
|
/**
|
|
26
30
|
* When true, errors during rendering are rethrown instead of being caught
|
|
@@ -29,7 +33,11 @@ interface FileOptions<LAnnotation> extends BaseCodeOptions, MouseEventManagerBas
|
|
|
29
33
|
*/
|
|
30
34
|
disableErrorHandling?: boolean;
|
|
31
35
|
renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;
|
|
32
|
-
|
|
36
|
+
renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Use `renderGutterUtility` instead.
|
|
39
|
+
*/
|
|
40
|
+
renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;
|
|
33
41
|
}
|
|
34
42
|
interface AnnotationElementCache<LAnnotation> {
|
|
35
43
|
element: HTMLElement;
|
|
@@ -48,18 +56,18 @@ declare class File<LAnnotation = undefined> {
|
|
|
48
56
|
protected bufferBefore: HTMLElement | undefined;
|
|
49
57
|
protected bufferAfter: HTMLElement | undefined;
|
|
50
58
|
protected unsafeCSSStyle: HTMLStyleElement | undefined;
|
|
51
|
-
protected
|
|
59
|
+
protected gutterUtilityContent: HTMLElement | undefined;
|
|
52
60
|
protected errorWrapper: HTMLElement | undefined;
|
|
53
61
|
protected placeHolder: HTMLElement | undefined;
|
|
54
62
|
protected lastRenderedHeaderHTML: string | undefined;
|
|
55
63
|
protected appliedPreAttributes: PrePropertiesConfig | undefined;
|
|
56
64
|
protected lastRowCount: number | undefined;
|
|
57
65
|
protected headerElement: HTMLElement | undefined;
|
|
66
|
+
protected headerPrefix: HTMLElement | undefined;
|
|
58
67
|
protected headerMetadata: HTMLElement | undefined;
|
|
59
68
|
protected fileRenderer: FileRenderer<LAnnotation>;
|
|
60
69
|
protected resizeManager: ResizeManager;
|
|
61
|
-
protected
|
|
62
|
-
protected lineSelectionManager: LineSelectionManager;
|
|
70
|
+
protected interactionManager: InteractionManager<'file'>;
|
|
63
71
|
protected annotationCache: Map<string, AnnotationElementCache<LAnnotation>>;
|
|
64
72
|
protected lineAnnotations: LineAnnotation<LAnnotation>[];
|
|
65
73
|
protected file: FileContents | undefined;
|
|
@@ -86,11 +94,13 @@ declare class File<LAnnotation = undefined> {
|
|
|
86
94
|
lineAnnotations,
|
|
87
95
|
renderRange
|
|
88
96
|
}: FileRenderProps<LAnnotation>): boolean;
|
|
97
|
+
private removeRenderedCode;
|
|
98
|
+
private clearAuxiliaryNodes;
|
|
89
99
|
private canPartiallyRender;
|
|
90
100
|
renderPlaceholder(height: number): boolean;
|
|
91
101
|
private cleanChildNodes;
|
|
92
102
|
private renderAnnotations;
|
|
93
|
-
private
|
|
103
|
+
private renderGutterUtility;
|
|
94
104
|
private injectUnsafeCSS;
|
|
95
105
|
private applyFullRender;
|
|
96
106
|
private applyPartialRender;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","names":["
|
|
1
|
+
{"version":3,"file":"File.d.ts","names":["GetHoveredLineResult","InteractionManager","InteractionManagerBaseOptions","SelectedLineRange","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 { type GetHoveredLineResult, InteractionManager, type InteractionManagerBaseOptions, type SelectedLineRange } from '../managers/InteractionManager';\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, InteractionManagerBaseOptions<'file'> {\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 | undefined;\n /**\n * @deprecated Use `renderGutterUtility` instead.\n */\n renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null | undefined;\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 interactionManager: InteractionManager<'file'>;\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":";;;;;;;;UAKiBc;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,eAJ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