@pierre/diffs 1.1.0-beta.16 → 1.1.0-beta.18
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/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/AdvancedVirtualizedFileDiff.js +2 -7
- package/dist/components/AdvancedVirtualizedFileDiff.js.map +1 -1
- package/dist/components/File.d.ts +17 -7
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +98 -41
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +20 -9
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +119 -42
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/VirtualizedFile.js +4 -2
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +1 -0
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +10 -2
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.js +2 -1
- 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.js +12 -4
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/managers/InteractionManager.d.ts +140 -0
- package/dist/managers/InteractionManager.d.ts.map +1 -0
- package/dist/managers/InteractionManager.js +789 -0
- package/dist/managers/InteractionManager.js.map +1 -0
- package/dist/react/File.d.ts +2 -0
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +3 -1
- 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 +3 -1
- 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 +3 -1
- 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 +3 -1
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/constants.d.ts +2 -2
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/constants.js +2 -2
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +2 -2
- package/dist/react/types.d.ts +11 -2
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +5 -1
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +17 -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 +1 -2
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +1 -2
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +1 -0
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +10 -2
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.js +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 +2 -2
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +7 -1
- package/dist/types.d.ts.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/hast_utils.d.ts +1 -1
- package/dist/utils/hast_utils.d.ts.map +1 -1
- package/dist/utils/hast_utils.js.map +1 -1
- package/dist/worker/worker-portable.js +7 -0
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js.map +1 -1
- package/package.json +2 -1
- 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
|
@@ -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,
|
|
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,QAAQ;AACtB,OAAK,gBAAgB;;CAGvB,AAAQ,cAAc;EACpB,MAAM,EACJ,SAAS,EAAE,oBAAoB,SAC/B,UACA,SAAS,EAAE,kBAAkB,SAAS,q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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,mBAAmB;AACtB,QAAK,iBAAiB;AACtB,QAAK,eAAe;SACf;AACL,QAAK,iBAAiB;AACtB,QAAK,eAAe;;AAMtB,OAAK,MAAM,QAAQ,SAAS,O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,gBAAgB,KAAK,KAAK,gBAAgB,GAAG;AACpD,cAAU,sBAAsB;AAChC,QAAI,SAAS,KAAK,SAAS,MAAM,GAC/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"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { BaseCodeOptions, FileContents, LineAnnotation, PrePropertiesConfig, 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,6 +33,10 @@ interface FileOptions<LAnnotation> extends BaseCodeOptions, MouseEventManagerBas
|
|
|
29
33
|
*/
|
|
30
34
|
disableErrorHandling?: boolean;
|
|
31
35
|
renderAnnotation?(annotation: LineAnnotation<LAnnotation>): HTMLElement | undefined;
|
|
36
|
+
renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Use `renderGutterUtility` instead.
|
|
39
|
+
*/
|
|
32
40
|
renderHoverUtility?(getHoveredRow: () => GetHoveredLineResult<'file'> | undefined): HTMLElement | null;
|
|
33
41
|
}
|
|
34
42
|
interface AnnotationElementCache<LAnnotation> {
|
|
@@ -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;\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 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,eAJ0BS,EAITb,6BAJSa,CAAAA,MAAAA,CAAAA,CAAAA;EAAhBD,iBAAAA,CAAAA,EAAAA,OAAAA;EACzCE;;;EAGFG,kBAAW,CAAA,EAAAJ,OAAAA;EAMHL,kBAAAA,CAAAA,EA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AAAA,EAAAA,IAAAA;EAEQY,cAAAA,EAAAA,GAAAA,GAAAA;IAAjBE,UAAAA,EAAAA,MAAAA;EACaV,CAAAA,GAAAA,SAAAA;EACnBmB,kBAAAA,CAAAA,eAAAA,EAL2BlB,cAK3BkB,CAL0CX,WAK1CW,CAAAA,EAAAA,CAAAA,EAAAA,IAAAA;EAAMC,gBAAAA,CAAAA,KAAAA,EAJSxB,iBAITwB,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EAAeC,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAAaC,OAAAA,CAAAA,KAAAA,EAF5BZ,gBAE4BY,CAFXd,WAEWc,CAAAA,CAAAA,EAAAA,IAAAA;EAAkBC,oBAAAA,CAAAA,IAAAA,CAAAA,EADjCvB,YACiCuB,GAAAA,SAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAiBC,MAAAA,CAAAA;IAAAA,IAAAA;IAAAA,aAAAA;IAAAA,WAAAA;IAAAA,gBAAAA;IAAAA,eAAAA;IAAAA;EAAAA,CAAAA,EAAejB,eAAfiB,CAA+BhB,WAA/BgB,CAAAA,CAAAA,EAAAA,OAAAA;EAA+BhB,QAAAA,kBAAAA;EAAhBD,QAAAA,mBAAAA;EAiBtCE,QAAAA,kBAAAA;EAA0BA,iBAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;EAAcA,QAAAA,eAAAA;EAAW,QAAA,iBAAA;;;;;;;;;;;yDAAnDA,0BAA0BA,cAAcA"}
|
package/dist/components/File.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DEFAULT_THEMES, DIFFS_TAG_NAME, HEADER_METADATA_SLOT_ID, UNSAFE_CSS_ATTRIBUTE } from "../constants.js";
|
|
2
|
-
import {
|
|
3
|
-
import { MouseEventManager, pluckMouseEventOptions } from "../managers/MouseEventManager.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
|
+
import { InteractionManager, pluckInteractionOptions } from "../managers/InteractionManager.js";
|
|
4
3
|
import { ResizeManager } from "../managers/ResizeManager.js";
|
|
5
4
|
import { areRenderRangesEqual } from "../utils/areRenderRangesEqual.js";
|
|
6
5
|
import { getLineAnnotationName } from "../utils/getLineAnnotationName.js";
|
|
@@ -10,7 +9,7 @@ import { areFilesEqual } from "../utils/areFilesEqual.js";
|
|
|
10
9
|
import { areLineAnnotationsEqual } from "../utils/areLineAnnotationsEqual.js";
|
|
11
10
|
import { arePrePropertiesEqual } from "../utils/arePrePropertiesEqual.js";
|
|
12
11
|
import { createAnnotationWrapperNode } from "../utils/createAnnotationWrapperNode.js";
|
|
13
|
-
import {
|
|
12
|
+
import { createGutterUtilityContentNode } from "../utils/createGutterUtilityContentNode.js";
|
|
14
13
|
import { createUnsafeCSSStyleNode } from "../utils/createUnsafeCSSStyleNode.js";
|
|
15
14
|
import { wrapUnsafeCSS } from "../utils/cssWrappers.js";
|
|
16
15
|
import { getOrCreateCodeNode } from "../utils/getOrCreateCodeNode.js";
|
|
@@ -32,18 +31,18 @@ var File = class {
|
|
|
32
31
|
bufferBefore;
|
|
33
32
|
bufferAfter;
|
|
34
33
|
unsafeCSSStyle;
|
|
35
|
-
|
|
34
|
+
gutterUtilityContent;
|
|
36
35
|
errorWrapper;
|
|
37
36
|
placeHolder;
|
|
38
37
|
lastRenderedHeaderHTML;
|
|
39
38
|
appliedPreAttributes;
|
|
40
39
|
lastRowCount;
|
|
41
40
|
headerElement;
|
|
41
|
+
headerPrefix;
|
|
42
42
|
headerMetadata;
|
|
43
43
|
fileRenderer;
|
|
44
44
|
resizeManager;
|
|
45
|
-
|
|
46
|
-
lineSelectionManager;
|
|
45
|
+
interactionManager;
|
|
47
46
|
annotationCache = /* @__PURE__ */ new Map();
|
|
48
47
|
lineAnnotations = [];
|
|
49
48
|
file;
|
|
@@ -54,8 +53,7 @@ var File = class {
|
|
|
54
53
|
this.isContainerManaged = isContainerManaged;
|
|
55
54
|
this.fileRenderer = new FileRenderer(options, this.handleHighlightRender, this.workerManager);
|
|
56
55
|
this.resizeManager = new ResizeManager();
|
|
57
|
-
this.
|
|
58
|
-
this.lineSelectionManager = new LineSelectionManager(pluckLineSelectionOptions(options));
|
|
56
|
+
this.interactionManager = new InteractionManager("file", pluckInteractionOptions(options));
|
|
59
57
|
this.workerManager?.subscribeToThemeChanges(this);
|
|
60
58
|
}
|
|
61
59
|
handleHighlightRender = () => {
|
|
@@ -72,8 +70,7 @@ var File = class {
|
|
|
72
70
|
setOptions(options) {
|
|
73
71
|
if (options == null) return;
|
|
74
72
|
this.options = options;
|
|
75
|
-
this.
|
|
76
|
-
this.lineSelectionManager.setOptions(pluckLineSelectionOptions(options));
|
|
73
|
+
this.interactionManager.setOptions(pluckInteractionOptions(options));
|
|
77
74
|
}
|
|
78
75
|
mergeOptions(options) {
|
|
79
76
|
this.options = {
|
|
@@ -98,19 +95,18 @@ var File = class {
|
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
97
|
getHoveredLine = () => {
|
|
101
|
-
return this.
|
|
98
|
+
return this.interactionManager.getHoveredLine();
|
|
102
99
|
};
|
|
103
100
|
setLineAnnotations(lineAnnotations) {
|
|
104
101
|
this.lineAnnotations = lineAnnotations;
|
|
105
102
|
}
|
|
106
103
|
setSelectedLines(range) {
|
|
107
|
-
this.
|
|
104
|
+
this.interactionManager.setSelection(range);
|
|
108
105
|
}
|
|
109
106
|
cleanUp() {
|
|
110
107
|
this.fileRenderer.cleanUp();
|
|
111
108
|
this.resizeManager.cleanUp();
|
|
112
|
-
this.
|
|
113
|
-
this.lineSelectionManager.cleanUp();
|
|
109
|
+
this.interactionManager.cleanUp();
|
|
114
110
|
this.workerManager?.unsubscribeToThemeChanges(this);
|
|
115
111
|
this.workerManager = void 0;
|
|
116
112
|
this.renderRange = void 0;
|
|
@@ -124,6 +120,8 @@ var File = class {
|
|
|
124
120
|
this.appliedPreAttributes = void 0;
|
|
125
121
|
this.lastRowCount = void 0;
|
|
126
122
|
this.headerElement = void 0;
|
|
123
|
+
this.headerPrefix = void 0;
|
|
124
|
+
this.headerMetadata = void 0;
|
|
127
125
|
this.lastRenderedHeaderHTML = void 0;
|
|
128
126
|
this.errorWrapper = void 0;
|
|
129
127
|
this.unsafeCSSStyle = void 0;
|
|
@@ -163,10 +161,9 @@ var File = class {
|
|
|
163
161
|
this.file = file;
|
|
164
162
|
this.fileRenderer.hydrate(file);
|
|
165
163
|
this.renderAnnotations();
|
|
166
|
-
this.
|
|
164
|
+
this.renderGutterUtility();
|
|
167
165
|
this.injectUnsafeCSS();
|
|
168
|
-
this.
|
|
169
|
-
this.lineSelectionManager.setup(this.pre);
|
|
166
|
+
this.interactionManager.setup(this.pre);
|
|
170
167
|
this.resizeManager.setup(this.pre, overflow === "wrap");
|
|
171
168
|
}
|
|
172
169
|
}
|
|
@@ -174,11 +171,13 @@ var File = class {
|
|
|
174
171
|
return file != null ? this.fileRenderer.getOrCreateLineCache(file) : EMPTY_STRINGS;
|
|
175
172
|
}
|
|
176
173
|
render({ file, fileContainer, forceRender = false, containerWrapper, lineAnnotations, renderRange }) {
|
|
174
|
+
const { collapsed = false } = this.options;
|
|
175
|
+
const nextRenderRange = collapsed ? void 0 : renderRange;
|
|
177
176
|
const previousRenderRange = this.renderRange;
|
|
178
177
|
const annotationsChanged = lineAnnotations != null && (lineAnnotations.length > 0 || this.lineAnnotations.length > 0) ? lineAnnotations !== this.lineAnnotations : false;
|
|
179
178
|
const didFileChange = !areFilesEqual(this.file, file);
|
|
180
|
-
if (!forceRender && areRenderRangesEqual(
|
|
181
|
-
this.renderRange =
|
|
179
|
+
if (!collapsed && !forceRender && areRenderRangesEqual(nextRenderRange, this.renderRange) && !didFileChange && !annotationsChanged) return false;
|
|
180
|
+
this.renderRange = nextRenderRange;
|
|
182
181
|
this.file = file;
|
|
183
182
|
this.fileRenderer.setOptions(this.options);
|
|
184
183
|
if (lineAnnotations != null) this.setLineAnnotations(lineAnnotations);
|
|
@@ -190,12 +189,34 @@ var File = class {
|
|
|
190
189
|
this.headerElement = void 0;
|
|
191
190
|
this.lastRenderedHeaderHTML = void 0;
|
|
192
191
|
}
|
|
192
|
+
if (this.headerPrefix != null) {
|
|
193
|
+
this.headerPrefix.parentNode?.removeChild(this.headerPrefix);
|
|
194
|
+
this.headerPrefix = void 0;
|
|
195
|
+
}
|
|
196
|
+
if (this.headerMetadata != null) {
|
|
197
|
+
this.headerMetadata.parentNode?.removeChild(this.headerMetadata);
|
|
198
|
+
this.headerMetadata = void 0;
|
|
199
|
+
}
|
|
193
200
|
}
|
|
194
201
|
fileContainer = this.getOrCreateFileContainerNode(fileContainer, containerWrapper);
|
|
202
|
+
if (collapsed) {
|
|
203
|
+
this.removeRenderedCode();
|
|
204
|
+
this.clearAuxiliaryNodes();
|
|
205
|
+
try {
|
|
206
|
+
const fileResult = this.fileRenderer.renderFile(file, EMPTY_RENDER_RANGE);
|
|
207
|
+
if (fileResult?.headerAST != null) this.applyHeaderToDOM(fileResult.headerAST, fileContainer);
|
|
208
|
+
this.injectUnsafeCSS();
|
|
209
|
+
} catch (error) {
|
|
210
|
+
if (disableErrorHandling) throw error;
|
|
211
|
+
console.error(error);
|
|
212
|
+
if (error instanceof Error) this.applyErrorToDOM(error, fileContainer);
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
195
216
|
try {
|
|
196
217
|
const pre = this.getOrCreatePreNode(fileContainer);
|
|
197
|
-
if (!this.canPartiallyRender(forceRender, annotationsChanged, didFileChange) || !this.applyPartialRender(previousRenderRange,
|
|
198
|
-
const fileResult = this.fileRenderer.renderFile(file,
|
|
218
|
+
if (!this.canPartiallyRender(forceRender, annotationsChanged, didFileChange) || !this.applyPartialRender(previousRenderRange, nextRenderRange)) {
|
|
219
|
+
const fileResult = this.fileRenderer.renderFile(file, nextRenderRange);
|
|
199
220
|
if (fileResult == null) {
|
|
200
221
|
if (this.workerManager?.isInitialized() === false) this.workerManager.initialize().then(() => this.rerender());
|
|
201
222
|
return false;
|
|
@@ -203,13 +224,12 @@ var File = class {
|
|
|
203
224
|
if (fileResult.headerAST != null) this.applyHeaderToDOM(fileResult.headerAST, fileContainer);
|
|
204
225
|
this.applyFullRender(fileResult, pre);
|
|
205
226
|
}
|
|
206
|
-
this.applyBuffers(pre,
|
|
227
|
+
this.applyBuffers(pre, nextRenderRange);
|
|
207
228
|
this.injectUnsafeCSS();
|
|
208
|
-
this.
|
|
209
|
-
this.lineSelectionManager.setup(pre);
|
|
229
|
+
this.interactionManager.setup(pre);
|
|
210
230
|
this.resizeManager.setup(pre, overflow === "wrap");
|
|
211
231
|
this.renderAnnotations();
|
|
212
|
-
this.
|
|
232
|
+
this.renderGutterUtility();
|
|
213
233
|
} catch (error) {
|
|
214
234
|
if (disableErrorHandling) throw error;
|
|
215
235
|
console.error(error);
|
|
@@ -217,6 +237,26 @@ var File = class {
|
|
|
217
237
|
}
|
|
218
238
|
return true;
|
|
219
239
|
}
|
|
240
|
+
removeRenderedCode() {
|
|
241
|
+
this.resizeManager.cleanUp();
|
|
242
|
+
this.interactionManager.cleanUp();
|
|
243
|
+
this.bufferBefore?.remove();
|
|
244
|
+
this.bufferBefore = void 0;
|
|
245
|
+
this.bufferAfter?.remove();
|
|
246
|
+
this.bufferAfter = void 0;
|
|
247
|
+
this.code?.remove();
|
|
248
|
+
this.code = void 0;
|
|
249
|
+
this.pre?.remove();
|
|
250
|
+
this.pre = void 0;
|
|
251
|
+
this.appliedPreAttributes = void 0;
|
|
252
|
+
this.lastRowCount = void 0;
|
|
253
|
+
}
|
|
254
|
+
clearAuxiliaryNodes() {
|
|
255
|
+
for (const { element } of this.annotationCache.values()) element.parentNode?.removeChild(element);
|
|
256
|
+
this.annotationCache.clear();
|
|
257
|
+
this.gutterUtilityContent?.remove();
|
|
258
|
+
this.gutterUtilityContent = void 0;
|
|
259
|
+
}
|
|
220
260
|
canPartiallyRender(forceRender, annotationsChanged, didContentChange) {
|
|
221
261
|
if (forceRender || annotationsChanged || didContentChange) return false;
|
|
222
262
|
return true;
|
|
@@ -235,14 +275,15 @@ var File = class {
|
|
|
235
275
|
}
|
|
236
276
|
cleanChildNodes() {
|
|
237
277
|
this.resizeManager.cleanUp();
|
|
238
|
-
this.
|
|
239
|
-
this.lineSelectionManager.cleanUp();
|
|
278
|
+
this.interactionManager.cleanUp();
|
|
240
279
|
this.bufferAfter?.remove();
|
|
241
280
|
this.bufferBefore?.remove();
|
|
242
281
|
this.code?.remove();
|
|
243
282
|
this.errorWrapper?.remove();
|
|
244
283
|
this.headerElement?.remove();
|
|
245
|
-
this.
|
|
284
|
+
this.gutterUtilityContent?.remove();
|
|
285
|
+
this.headerPrefix?.remove();
|
|
286
|
+
this.headerMetadata?.remove();
|
|
246
287
|
this.pre?.remove();
|
|
247
288
|
this.spriteSVG?.remove();
|
|
248
289
|
this.unsafeCSSStyle?.remove();
|
|
@@ -251,7 +292,9 @@ var File = class {
|
|
|
251
292
|
this.code = void 0;
|
|
252
293
|
this.errorWrapper = void 0;
|
|
253
294
|
this.headerElement = void 0;
|
|
254
|
-
this.
|
|
295
|
+
this.gutterUtilityContent = void 0;
|
|
296
|
+
this.headerPrefix = void 0;
|
|
297
|
+
this.headerMetadata = void 0;
|
|
255
298
|
this.pre = void 0;
|
|
256
299
|
this.spriteSVG = void 0;
|
|
257
300
|
this.unsafeCSSStyle = void 0;
|
|
@@ -288,19 +331,24 @@ var File = class {
|
|
|
288
331
|
element.parentNode?.removeChild(element);
|
|
289
332
|
}
|
|
290
333
|
}
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
if (this.fileContainer == null ||
|
|
294
|
-
|
|
295
|
-
|
|
334
|
+
renderGutterUtility() {
|
|
335
|
+
const renderGutterUtility = this.options.renderGutterUtility ?? this.options.renderHoverUtility;
|
|
336
|
+
if (this.fileContainer == null || renderGutterUtility == null) {
|
|
337
|
+
this.gutterUtilityContent?.remove();
|
|
338
|
+
this.gutterUtilityContent = void 0;
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const element = renderGutterUtility(this.interactionManager.getHoveredLine);
|
|
342
|
+
if (element != null && this.gutterUtilityContent != null) return;
|
|
296
343
|
else if (element == null) {
|
|
297
|
-
this.
|
|
298
|
-
this.
|
|
344
|
+
this.gutterUtilityContent?.parentNode?.removeChild(this.gutterUtilityContent);
|
|
345
|
+
this.gutterUtilityContent = void 0;
|
|
299
346
|
return;
|
|
300
347
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this.fileContainer.appendChild(
|
|
348
|
+
const gutterUtilityContent = createGutterUtilityContentNode();
|
|
349
|
+
gutterUtilityContent.appendChild(element);
|
|
350
|
+
this.fileContainer.appendChild(gutterUtilityContent);
|
|
351
|
+
this.gutterUtilityContent = gutterUtilityContent;
|
|
304
352
|
}
|
|
305
353
|
injectUnsafeCSS() {
|
|
306
354
|
if (this.fileContainer?.shadowRoot == null) return;
|
|
@@ -474,9 +522,18 @@ var File = class {
|
|
|
474
522
|
this.lastRenderedHeaderHTML = headerHTML;
|
|
475
523
|
}
|
|
476
524
|
if (this.isContainerManaged) return;
|
|
477
|
-
const { renderCustomMetadata } = this.options;
|
|
525
|
+
const { renderHeaderPrefix, renderCustomMetadata } = this.options;
|
|
526
|
+
if (this.headerPrefix != null) this.headerPrefix.parentNode?.removeChild(this.headerPrefix);
|
|
478
527
|
if (this.headerMetadata != null) this.headerMetadata.parentNode?.removeChild(this.headerMetadata);
|
|
528
|
+
const prefix = renderHeaderPrefix?.(file) ?? void 0;
|
|
479
529
|
const content = renderCustomMetadata?.(file) ?? void 0;
|
|
530
|
+
if (prefix != null) {
|
|
531
|
+
this.headerPrefix = document.createElement("div");
|
|
532
|
+
this.headerPrefix.slot = HEADER_PREFIX_SLOT_ID;
|
|
533
|
+
if (prefix instanceof Element) this.headerPrefix.appendChild(prefix);
|
|
534
|
+
else this.headerPrefix.innerText = `${prefix}`;
|
|
535
|
+
container.appendChild(this.headerPrefix);
|
|
536
|
+
}
|
|
480
537
|
if (content != null) {
|
|
481
538
|
this.headerMetadata = document.createElement("div");
|
|
482
539
|
this.headerMetadata.slot = HEADER_METADATA_SLOT_ID;
|