@pierre/diffs 1.1.20 → 1.2.0-beta.0
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/CodeView.d.ts +324 -0
- package/dist/components/CodeView.d.ts.map +1 -0
- package/dist/components/CodeView.js +1245 -0
- package/dist/components/CodeView.js.map +1 -0
- package/dist/components/File.d.ts +13 -12
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +68 -28
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +9 -10
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +57 -30
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.js +9 -3
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +28 -5
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +225 -45
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +28 -5
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +285 -49
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +6 -3
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +4 -6
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts +2 -2
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +11 -10
- package/dist/managers/InteractionManager.d.ts +11 -7
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +38 -25
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts +4 -4
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +89 -54
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts +2 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.js +13 -16
- package/dist/managers/UniversalRenderingManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +45 -0
- package/dist/react/CodeView.d.ts.map +1 -0
- package/dist/react/CodeView.js +241 -0
- package/dist/react/CodeView.js.map +1 -0
- package/dist/react/File.d.ts +0 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +2 -3
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +0 -1
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +3 -4
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +0 -1
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +3 -4
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +0 -1
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +3 -4
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +0 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +3 -4
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +5 -4
- package/dist/react/types.d.ts +0 -8
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +0 -2
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +3 -4
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +0 -2
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +3 -4
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +12 -7
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.js +12 -7
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +6 -2
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +2 -1
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +35 -20
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +2 -1
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +34 -20
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.js +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +98 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts +7 -0
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -0
- package/dist/utils/areManagedSnapshotsEqual.js +15 -0
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -0
- package/dist/utils/areOptionsEqual.d.ts +2 -1
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.js +1 -1
- package/dist/utils/areOptionsEqual.js.map +1 -1
- package/dist/utils/createFileHeaderElement.d.ts +3 -1
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createFileHeaderElement.js +3 -2
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.d.ts +3 -3
- package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.js +6 -6
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
- package/dist/utils/iterateOverDiff.d.ts +2 -1
- package/dist/utils/iterateOverDiff.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.js +135 -7
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +1 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts +4 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts.map +1 -1
- package/dist/utils/resolveVirtualFileMetrics.js +11 -1
- package/dist/utils/resolveVirtualFileMetrics.js.map +1 -1
- package/dist/utils/roundToDevicePixel.d.ts +14 -0
- package/dist/utils/roundToDevicePixel.d.ts.map +1 -0
- package/dist/utils/roundToDevicePixel.js +18 -0
- package/dist/utils/roundToDevicePixel.js.map +1 -0
- package/dist/worker/worker-portable.js +195 -14
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +146 -7
- package/dist/worker/worker.js.map +1 -1
- package/package.json +7 -1
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts +0 -40
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +0 -1
- package/dist/components/AdvancedVirtualizedFileDiff.js +0 -140
- package/dist/components/AdvancedVirtualizedFileDiff.js.map +0 -1
- package/dist/components/AdvancedVirtualizer.d.ts +0 -38
- package/dist/components/AdvancedVirtualizer.d.ts.map +0 -1
- package/dist/components/AdvancedVirtualizer.js +0 -201
- package/dist/components/AdvancedVirtualizer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictMarkerRow","MergeConflictResolution","MergeConflictDiffAction","WorkerPoolManager","FileDiff","FileDiffOptions","FileDiffRenderProps","RenderMergeConflictActions","LAnnotation","UnresolvedFile","HTMLElement","DocumentFragment","MergeConflictActionsTypeOption","UnresolvedFileOptions","Omit","UnresolvedFileRenderProps","UnresolvedFileHydrationProps","GetOrComputeDiffProps","ResolveConflictReturn","UnresolvedFileDataCache","HTMLPreElement","getUnresolvedDiffHunksRendererOptions"],"sources":["../../src/components/UnresolvedFile.d.ts"],"sourcesContent":["import type { HunksRenderResult } from '../renderers/DiffHunksRenderer';\nimport { UnresolvedFileHunksRenderer, type UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, FileDiffMetadata, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { WorkerPoolManager } from '../worker';\nimport { FileDiff, type FileDiffOptions, type FileDiffRenderProps } from './FileDiff';\nexport type RenderMergeConflictActions<LAnnotation> = (action: MergeConflictDiffAction, instance: UnresolvedFile<LAnnotation>) => HTMLElement | DocumentFragment | null | undefined;\nexport type MergeConflictActionsTypeOption<LAnnotation> = 'none' | 'default' | RenderMergeConflictActions<LAnnotation>;\nexport interface UnresolvedFileOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'diffStyle'> {\n onPostRender?(node: HTMLElement, instance: UnresolvedFile<LAnnotation>): unknown;\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(payload: MergeConflictActionPayload, instance: UnresolvedFile<LAnnotation>): void;\n onMergeConflictResolve?(file: FileContents, payload: MergeConflictActionPayload): void;\n maxContextLines?: number;\n}\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<FileDiffRenderProps<LAnnotation>, 'oldFile' | 'newFile'> {\n file?: FileContents;\n actions?: (MergeConflictDiffAction | undefined)[];\n markerRows?: MergeConflictMarkerRow[];\n}\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<UnresolvedFileRenderProps<LAnnotation>, 'file'> {\n file?: FileContents;\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: (MergeConflictDiffAction | undefined)[] | undefined;\n markerRows: MergeConflictMarkerRow[] | undefined;\n}\ninterface ResolveConflictReturn {\n file: FileContents;\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\ntype UnresolvedFileDataCache = GetOrComputeDiffProps;\nexport declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotation> {\n options: UnresolvedFileOptions<LAnnotation>;\n readonly __id: string;\n protected computedCache: UnresolvedFileDataCache;\n private conflictActions;\n private markerRows;\n private conflictActionCache;\n constructor(options?: UnresolvedFileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n setOptions(options: UnresolvedFileOptions<LAnnotation> | undefined): void;\n protected createHunksRenderer(options: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRenderer<LAnnotation>;\n protected getHunksRendererOptions(options: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRendererOptions;\n protected applyPreNodeAttributes(pre: HTMLPreElement, result: HunksRenderResult): void;\n cleanUp(): void;\n private getOrComputeDiff;\n hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void;\n rerender(): void;\n render(props?: UnresolvedFileRenderProps<LAnnotation>): boolean;\n resolveConflict(conflictIndex: number, resolution: MergeConflictResolution, fileDiff?: FileDiffMetadata | undefined): ResolveConflictReturn | undefined;\n private resolveConflictAndRender;\n private setActiveMergeConflictState;\n private handleMergeConflictActionClick;\n private renderMergeConflictActionSlots;\n private renderMergeConflictAction;\n private clearMergeConflictActionCache;\n}\nexport declare function getUnresolvedDiffHunksRendererOptions<LAnnotation>(options?: UnresolvedFileOptions<LAnnotation>, baseOptions?: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRendererOptions;\nexport {};\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":";;;;;;;;;KAMYa,mDAAmDL,mCAAmCO,eAAeD,iBAAiBE,cAAcC;KACpIC,mEAAmEL,2BAA2BC;UACzFK,2CAA2CC,KAAKT,gBAAgBG;EAFrED,YAAAA,EAAAA,IAAAA,EAGYG,WAHc,EAAA,QAAAF,EAGSC,cAHT,CAGwBD,WAHxB,CAAA,CAAA,EAAA,OAAA;EAAyBN,wBAAAA,CAAAA,EAIhCU,8BAJgCV,CAIDM,WAJCN,CAAAA;EAAkDM,qBAAAA,EAAAA,OAAAA,EAK7ET,0BAL6ES,EAAAA,QAAAA,EAKvCC,cALuCD,CAKxBA,WALwBA,CAAAA,CAAAA,EAAAA,IAAAA;EAAfC,sBAAAA,EAAAA,IAAAA,EAMhEZ,YANgEY,EAAAA,OAAAA,EAMzCV,0BANyCU,CAAAA,EAAAA,IAAAA;EAAgCC,eAAAA,CAAAA,EAAAA,MAAAA;;AAA8B,UAS/IK,yBAT+I,CAAA,WAAA,CAAA,SAShGD,IATgG,CAS3FR,mBAT2F,CASvEE,WATuE,CAAA,EAAA,SAAA,GAAA,SAAA,CAAA,CAAA;EACpJI,IAAAA,CAAAA,EASDf,YATCe;EACKC,OAAAA,CAAAA,EAAAA,CASFX,uBATuBM,GAAAA,
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictMarkerRow","MergeConflictResolution","MergeConflictDiffAction","WorkerPoolManager","FileDiff","FileDiffOptions","FileDiffRenderProps","RenderMergeConflictActions","LAnnotation","UnresolvedFile","HTMLElement","DocumentFragment","MergeConflictActionsTypeOption","UnresolvedFileOptions","Omit","UnresolvedFileRenderProps","UnresolvedFileHydrationProps","GetOrComputeDiffProps","ResolveConflictReturn","UnresolvedFileDataCache","HTMLPreElement","getUnresolvedDiffHunksRendererOptions"],"sources":["../../src/components/UnresolvedFile.d.ts"],"sourcesContent":["import type { HunksRenderResult } from '../renderers/DiffHunksRenderer';\nimport { UnresolvedFileHunksRenderer, type UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, FileDiffMetadata, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { WorkerPoolManager } from '../worker';\nimport { FileDiff, type FileDiffOptions, type FileDiffRenderProps } from './FileDiff';\nexport type RenderMergeConflictActions<LAnnotation> = (action: MergeConflictDiffAction, instance: UnresolvedFile<LAnnotation>) => HTMLElement | DocumentFragment | null | undefined;\nexport type MergeConflictActionsTypeOption<LAnnotation> = 'none' | 'default' | RenderMergeConflictActions<LAnnotation>;\nexport interface UnresolvedFileOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'diffStyle'> {\n onPostRender?(node: HTMLElement, instance: UnresolvedFile<LAnnotation>): unknown;\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(payload: MergeConflictActionPayload, instance: UnresolvedFile<LAnnotation>): void;\n onMergeConflictResolve?(file: FileContents, payload: MergeConflictActionPayload): void;\n maxContextLines?: number;\n}\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<FileDiffRenderProps<LAnnotation>, 'oldFile' | 'newFile'> {\n file?: FileContents;\n actions?: (MergeConflictDiffAction | undefined)[];\n markerRows?: MergeConflictMarkerRow[];\n}\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<UnresolvedFileRenderProps<LAnnotation>, 'file'> {\n file?: FileContents;\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: (MergeConflictDiffAction | undefined)[] | undefined;\n markerRows: MergeConflictMarkerRow[] | undefined;\n}\ninterface ResolveConflictReturn {\n file: FileContents;\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\ntype UnresolvedFileDataCache = GetOrComputeDiffProps;\nexport declare class UnresolvedFile<LAnnotation = undefined> extends FileDiff<LAnnotation> {\n options: UnresolvedFileOptions<LAnnotation>;\n readonly __id: string;\n protected computedCache: UnresolvedFileDataCache;\n private conflictActions;\n private markerRows;\n private conflictActionCache;\n constructor(options?: UnresolvedFileOptions<LAnnotation>, workerManager?: WorkerPoolManager | undefined, isContainerManaged?: boolean);\n setOptions(options: UnresolvedFileOptions<LAnnotation> | undefined): void;\n protected createHunksRenderer(options: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRenderer<LAnnotation>;\n protected getHunksRendererOptions(options: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRendererOptions;\n protected applyPreNodeAttributes(pre: HTMLPreElement, result: HunksRenderResult): void;\n cleanUp(): void;\n private getOrComputeDiff;\n hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void;\n rerender(): void;\n render(props?: UnresolvedFileRenderProps<LAnnotation>): boolean;\n resolveConflict(conflictIndex: number, resolution: MergeConflictResolution, fileDiff?: FileDiffMetadata | undefined): ResolveConflictReturn | undefined;\n private resolveConflictAndRender;\n private setActiveMergeConflictState;\n private handleMergeConflictActionClick;\n private renderMergeConflictActionSlots;\n private renderMergeConflictAction;\n private clearMergeConflictActionCache;\n}\nexport declare function getUnresolvedDiffHunksRendererOptions<LAnnotation>(options?: UnresolvedFileOptions<LAnnotation>, baseOptions?: UnresolvedFileOptions<LAnnotation>): UnresolvedFileHunksRendererOptions;\nexport {};\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":"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"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { VirtualFileMetrics } from "../types.js";
|
|
1
|
+
import { FileContents, NumericScrollLineAnchor, StickySpecs, VirtualFileMetrics } from "../types.js";
|
|
2
2
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
3
3
|
import "../worker/index.js";
|
|
4
4
|
import { File, FileOptions, FileRenderProps } from "./File.js";
|
|
5
5
|
import { Virtualizer } from "./Virtualizer.js";
|
|
6
|
+
import { CodeView } from "./CodeView.js";
|
|
6
7
|
|
|
7
8
|
//#region src/components/VirtualizedFile.d.ts
|
|
8
9
|
declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation> {
|
|
@@ -11,22 +12,44 @@ declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation>
|
|
|
11
12
|
readonly __id: string;
|
|
12
13
|
top: number | undefined;
|
|
13
14
|
height: number;
|
|
14
|
-
private
|
|
15
|
+
private cache;
|
|
15
16
|
private isVisible;
|
|
16
17
|
private isSetup;
|
|
17
|
-
|
|
18
|
+
private forceRenderOverride;
|
|
19
|
+
constructor(options: FileOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: VirtualFileMetrics, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);
|
|
20
|
+
setMetrics(metrics: VirtualFileMetrics, force?: boolean): void;
|
|
18
21
|
getLineHeight(lineIndex: number, hasMetadataLine?: boolean): number;
|
|
19
22
|
setOptions(options: FileOptions<LAnnotation> | undefined): void;
|
|
20
|
-
reconcileHeights():
|
|
23
|
+
reconcileHeights(): boolean;
|
|
21
24
|
onRender: (dirty: boolean) => boolean;
|
|
22
|
-
|
|
25
|
+
prepareVirtualizedItem(file: FileContents): number;
|
|
26
|
+
getLinePosition(lineNumber: number): {
|
|
27
|
+
top: number;
|
|
28
|
+
height: number;
|
|
29
|
+
} | undefined;
|
|
30
|
+
getNumericScrollAnchor(localViewportTop: number): NumericScrollLineAnchor | undefined;
|
|
31
|
+
getVirtualizedHeight(): number;
|
|
32
|
+
getAdvancedStickySpecs(): StickySpecs | undefined;
|
|
33
|
+
cleanUp(recycle?: boolean): void;
|
|
23
34
|
private computeApproximateSize;
|
|
24
35
|
setVisibility(visible: boolean): void;
|
|
36
|
+
rerender(): void;
|
|
25
37
|
render({
|
|
26
38
|
fileContainer,
|
|
27
39
|
file,
|
|
40
|
+
forceRender,
|
|
28
41
|
...props
|
|
29
42
|
}: FileRenderProps<LAnnotation>): boolean;
|
|
43
|
+
syncVirtualizedTop(): void;
|
|
44
|
+
protected shouldDisableVirtualizationBuffers(): boolean;
|
|
45
|
+
private isSimpleMode;
|
|
46
|
+
private isAdvancedMode;
|
|
47
|
+
private addLayoutCheckpoint;
|
|
48
|
+
private getLayoutCheckpointBeforeLineIndex;
|
|
49
|
+
private getLayoutCheckpointBeforeTop;
|
|
50
|
+
private getVirtualizedTop;
|
|
51
|
+
private getSimpleVirtualizer;
|
|
52
|
+
private isResizeDebuggingEnabled;
|
|
30
53
|
private computeRenderRangeFromWindow;
|
|
31
54
|
}
|
|
32
55
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualizedFile.d.ts","names":["VirtualFileMetrics","WorkerPoolManager","File","FileOptions","FileRenderProps","Virtualizer","VirtualizedFile","LAnnotation","fileContainer","file"],"sources":["../../src/components/VirtualizedFile.d.ts"],"sourcesContent":["import type { VirtualFileMetrics } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nimport { File, type FileOptions, type FileRenderProps } from './File';\nimport type { Virtualizer } from './Virtualizer';\nexport declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation> {\n private virtualizer;\n private metrics;\n readonly __id: string;\n top: number | undefined;\n height: number;\n private
|
|
1
|
+
{"version":3,"file":"VirtualizedFile.d.ts","names":["FileContents","NumericScrollLineAnchor","StickySpecs","VirtualFileMetrics","WorkerPoolManager","CodeView","File","FileOptions","FileRenderProps","Virtualizer","VirtualizedFile","LAnnotation","fileContainer","file","forceRender"],"sources":["../../src/components/VirtualizedFile.d.ts"],"sourcesContent":["import type { FileContents, NumericScrollLineAnchor, StickySpecs, VirtualFileMetrics } from '../types';\nimport type { WorkerPoolManager } from '../worker';\nimport type { CodeView } from './CodeView';\nimport { File, type FileOptions, type FileRenderProps } from './File';\nimport type { Virtualizer } from './Virtualizer';\nexport declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation> {\n private virtualizer;\n private metrics;\n readonly __id: string;\n top: number | undefined;\n height: number;\n private cache;\n private isVisible;\n private isSetup;\n private forceRenderOverride;\n constructor(options: FileOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: VirtualFileMetrics, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);\n setMetrics(metrics: VirtualFileMetrics, force?: boolean): void;\n getLineHeight(lineIndex: number, hasMetadataLine?: boolean): number;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n reconcileHeights(): boolean;\n onRender: (dirty: boolean) => boolean;\n prepareVirtualizedItem(file: FileContents): number;\n getLinePosition(lineNumber: number): {\n top: number;\n height: number;\n } | undefined;\n getNumericScrollAnchor(localViewportTop: number): NumericScrollLineAnchor | undefined;\n getVirtualizedHeight(): number;\n getAdvancedStickySpecs(): StickySpecs | undefined;\n cleanUp(recycle?: boolean): void;\n private computeApproximateSize;\n setVisibility(visible: boolean): void;\n rerender(): void;\n render({ fileContainer, file, forceRender, ...props }: FileRenderProps<LAnnotation>): boolean;\n syncVirtualizedTop(): void;\n protected shouldDisableVirtualizationBuffers(): boolean;\n private isSimpleMode;\n private isAdvancedMode;\n private addLayoutCheckpoint;\n private getLayoutCheckpointBeforeLineIndex;\n private getLayoutCheckpointBeforeTop;\n private getVirtualizedTop;\n private getSimpleVirtualizer;\n private isResizeDebuggingEnabled;\n private computeRenderRangeFromWindow;\n}\n//# sourceMappingURL=VirtualizedFile.d.ts.map"],"mappings":";;;;;;;;cAKqBU,iDAAiDJ,KAAKK;;;EAAtDD,SAAAA,IAAAA,EAAAA,MAAe;EAAuCC,GAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAUtCA,MAAAA,EAAAA,MAAAA;EAAZJ,QAAAA,KAAAA;EAAmDE,QAAAA,SAAAA;EAAuBE,QAAAA,OAAAA;EAATN,QAAAA,mBAAAA;EAAiCF,WAAAA,CAAAA,OAAAA,EAAlGI,WAAkGJ,CAAtFQ,WAAsFR,CAAAA,GAAAA,SAAAA,EAAAA,WAAAA,EAA/CM,WAA+CN,GAAjCE,QAAiCF,CAAxBQ,WAAwBR,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,kBAAAA,EAAAA,aAAAA,CAAAA,EAAoCC,iBAApCD,EAAAA,kBAAAA,CAAAA,EAAAA,OAAAA;EAAoCC,UAAAA,CAAAA,OAAAA,EACvID,kBADuIC,EAAAA,KAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EACvID,aAAAA,CAAAA,SAAAA,EAAAA,MAAAA,EAAAA,eAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,MAAAA;EAEYQ,UAAAA,CAAAA,OAAAA,EAAZJ,WAAYI,CAAAA,WAAAA,CAAAA,GAAAA,SAAAA,CAAAA,EAAAA,IAAAA;EAAZJ,gBAAAA,CAAAA,CAAAA,EAAAA,OAAAA;EAGSP,QAAAA,EAAAA,CAAAA,KAAAA,EAAAA,OAAAA,EAAAA,GAAAA,OAAAA;EAKqBC,sBAAAA,CAAAA,IAAAA,EALrBD,YAKqBC,CAAAA,EAAAA,MAAAA;EAExBC,eAAAA,CAAAA,UAAAA,EAAAA,MAAAA,CAAAA,EAAAA;IAKjBU,GAAAA,EAAAA,MAAAA;IAAeC,MAAAA,EAAAA,MAAAA;EAAMC,CAAAA,GAAAA,SAAAA;EAAyCH,sBAAAA,CAAAA,gBAAAA,EAAAA,MAAAA,CAAAA,EAPrBV,uBAOqBU,GAAAA,SAAAA;EAAhBH,oBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EA5BWF,sBAAAA,CAAAA,CAAAA,EAuBxCJ,WAvBwCI,GAAAA,SAAAA;EAAI,OAAA,CAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;;;;;;;;;KA4BfE,gBAAgBG"}
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import { DEFAULT_VIRTUAL_FILE_METRICS } from "../constants.js";
|
|
2
|
+
import { areObjectsEqual } from "../utils/areObjectsEqual.js";
|
|
2
3
|
import { iterateOverFile } from "../utils/iterateOverFile.js";
|
|
4
|
+
import { getVirtualFileHeaderRegion, getVirtualFilePaddingBottom } from "../utils/resolveVirtualFileMetrics.js";
|
|
3
5
|
import { File } from "./File.js";
|
|
4
6
|
|
|
5
7
|
//#region src/components/VirtualizedFile.ts
|
|
8
|
+
const LAYOUT_CHECKPOINT_INTERVAL = 5e3;
|
|
6
9
|
let instanceId = -1;
|
|
7
10
|
var VirtualizedFile = class extends File {
|
|
8
11
|
__id = `virtualized-file:${++instanceId}`;
|
|
9
12
|
top;
|
|
10
13
|
height = 0;
|
|
11
|
-
|
|
14
|
+
cache = {
|
|
15
|
+
heights: /* @__PURE__ */ new Map(),
|
|
16
|
+
checkpoints: []
|
|
17
|
+
};
|
|
12
18
|
isVisible = false;
|
|
13
19
|
isSetup = false;
|
|
20
|
+
forceRenderOverride;
|
|
14
21
|
constructor(options, virtualizer, metrics = DEFAULT_VIRTUAL_FILE_METRICS, workerManager, isContainerManaged = false) {
|
|
15
22
|
super(options, workerManager, isContainerManaged);
|
|
16
23
|
this.virtualizer = virtualizer;
|
|
17
24
|
this.metrics = metrics;
|
|
18
25
|
}
|
|
26
|
+
setMetrics(metrics, force = false) {
|
|
27
|
+
if (!force && areObjectsEqual(this.metrics, metrics)) return;
|
|
28
|
+
this.metrics = metrics;
|
|
29
|
+
this.cache.heights.clear();
|
|
30
|
+
this.cache.checkpoints = [];
|
|
31
|
+
this.renderRange = void 0;
|
|
32
|
+
}
|
|
19
33
|
getLineHeight(lineIndex, hasMetadataLine = false) {
|
|
20
|
-
const cached = this.
|
|
34
|
+
const cached = this.cache.heights.get(lineIndex);
|
|
21
35
|
if (cached != null) return cached;
|
|
22
36
|
const multiplier = hasMetadataLine ? 2 : 1;
|
|
23
37
|
return this.metrics.lineHeight * multiplier;
|
|
@@ -28,24 +42,26 @@ var VirtualizedFile = class extends File {
|
|
|
28
42
|
const previousCollapsed = this.options.collapsed;
|
|
29
43
|
super.setOptions(options);
|
|
30
44
|
if (previousOverflow !== this.options.overflow || previousCollapsed !== this.options.collapsed) {
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
45
|
+
this.cache.heights.clear();
|
|
46
|
+
this.cache.checkpoints = [];
|
|
47
|
+
if (this.isSimpleMode()) this.computeApproximateSize();
|
|
33
48
|
this.renderRange = void 0;
|
|
34
49
|
}
|
|
35
|
-
this.virtualizer.instanceChanged(this);
|
|
50
|
+
if (this.isSimpleMode()) this.virtualizer.instanceChanged(this, true);
|
|
36
51
|
}
|
|
37
52
|
reconcileHeights() {
|
|
53
|
+
let hasHeightChange = false;
|
|
38
54
|
if (this.fileContainer == null || this.file == null) {
|
|
55
|
+
if (this.height !== 0) hasHeightChange = true;
|
|
39
56
|
this.height = 0;
|
|
40
|
-
return;
|
|
57
|
+
return hasHeightChange;
|
|
41
58
|
}
|
|
42
59
|
const { overflow = "scroll" } = this.options;
|
|
43
|
-
this.top = this.
|
|
44
|
-
if (overflow === "scroll" && this.lineAnnotations.length === 0 && !this.
|
|
45
|
-
|
|
46
|
-
if (this.code == null) return;
|
|
60
|
+
this.top = this.getVirtualizedTop();
|
|
61
|
+
if (overflow === "scroll" && this.lineAnnotations.length === 0 && !this.isResizeDebuggingEnabled()) return hasHeightChange;
|
|
62
|
+
if (this.code == null) return hasHeightChange;
|
|
47
63
|
const content = this.code.children[1];
|
|
48
|
-
if (!(content instanceof HTMLElement)) return;
|
|
64
|
+
if (!(content instanceof HTMLElement)) return hasHeightChange;
|
|
49
65
|
for (const line of content.children) {
|
|
50
66
|
if (!(line instanceof HTMLElement)) continue;
|
|
51
67
|
const lineIndexAttr = line.dataset.lineIndex;
|
|
@@ -59,41 +75,120 @@ var VirtualizedFile = class extends File {
|
|
|
59
75
|
}
|
|
60
76
|
const expectedHeight = this.getLineHeight(lineIndex, hasMetadata);
|
|
61
77
|
if (measuredHeight === expectedHeight) continue;
|
|
62
|
-
|
|
63
|
-
if (measuredHeight === this.metrics.lineHeight * (hasMetadata ? 2 : 1)) this.
|
|
64
|
-
else this.
|
|
78
|
+
hasHeightChange = true;
|
|
79
|
+
if (measuredHeight === this.metrics.lineHeight * (hasMetadata ? 2 : 1)) this.cache.heights.delete(lineIndex);
|
|
80
|
+
else this.cache.heights.set(lineIndex, measuredHeight);
|
|
65
81
|
}
|
|
66
|
-
if (
|
|
82
|
+
if (hasHeightChange || this.isResizeDebuggingEnabled()) this.computeApproximateSize();
|
|
83
|
+
return hasHeightChange;
|
|
67
84
|
}
|
|
68
85
|
onRender = (dirty) => {
|
|
69
86
|
if (this.fileContainer == null || this.file == null) return false;
|
|
70
|
-
if (dirty) this.top = this.
|
|
87
|
+
if (dirty) this.top = this.getVirtualizedTop();
|
|
71
88
|
return this.render({ file: this.file });
|
|
72
89
|
};
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
prepareVirtualizedItem(file) {
|
|
91
|
+
this.file = file;
|
|
92
|
+
this.top = this.getVirtualizedTop();
|
|
93
|
+
this.computeApproximateSize();
|
|
94
|
+
return this.height;
|
|
95
|
+
}
|
|
96
|
+
getLinePosition(lineNumber) {
|
|
97
|
+
if (this.file == null) return;
|
|
98
|
+
const { disableFileHeader = false, collapsed = false } = this.options;
|
|
99
|
+
const lastLineIndex = getLastVisibleLineIndex(this.getOrCreateLineCache(this.file));
|
|
100
|
+
let top = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
101
|
+
if (collapsed || lastLineIndex < 0) return {
|
|
102
|
+
top,
|
|
103
|
+
height: 0
|
|
104
|
+
};
|
|
105
|
+
const clampedLineIndex = Math.min(Math.max(lineNumber - 1, 0), lastLineIndex);
|
|
106
|
+
const { overflow = "scroll" } = this.options;
|
|
107
|
+
const { lineHeight } = this.metrics;
|
|
108
|
+
if (overflow === "scroll" && this.lineAnnotations.length === 0) return {
|
|
109
|
+
top: top + clampedLineIndex * lineHeight,
|
|
110
|
+
height: lineHeight
|
|
111
|
+
};
|
|
112
|
+
const checkpoint = this.getLayoutCheckpointBeforeLineIndex(clampedLineIndex);
|
|
113
|
+
top = checkpoint?.top ?? top;
|
|
114
|
+
for (let lineIndex = checkpoint?.lineIndex ?? 0; lineIndex < clampedLineIndex; lineIndex++) top += this.getLineHeight(lineIndex, false);
|
|
115
|
+
return {
|
|
116
|
+
top,
|
|
117
|
+
height: this.getLineHeight(clampedLineIndex, false)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
getNumericScrollAnchor(localViewportTop) {
|
|
121
|
+
if (this.file == null || this.renderRange == null) return;
|
|
122
|
+
const { disableFileHeader = false, collapsed = false, overflow = "scroll" } = this.options;
|
|
123
|
+
if (collapsed || this.renderRange.totalLines <= 0) return;
|
|
124
|
+
const lastLineIndex = getLastVisibleLineIndex(this.getOrCreateLineCache(this.file));
|
|
125
|
+
if (lastLineIndex < 0) return;
|
|
126
|
+
const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
127
|
+
const firstRenderedLineIndex = Math.min(this.renderRange.startingLine, lastLineIndex);
|
|
128
|
+
const lastRenderedLineIndex = Math.min(firstRenderedLineIndex + this.renderRange.totalLines - 1, lastLineIndex);
|
|
129
|
+
if (lastRenderedLineIndex < firstRenderedLineIndex) return;
|
|
130
|
+
if (overflow === "scroll" && this.lineAnnotations.length === 0) {
|
|
131
|
+
const { lineHeight } = this.metrics;
|
|
132
|
+
const firstRenderedLineTop = headerRegion + this.renderRange.bufferBefore;
|
|
133
|
+
const lineIndex = firstRenderedLineIndex + Math.max(Math.ceil((localViewportTop - firstRenderedLineTop) / lineHeight), 0);
|
|
134
|
+
if (lineIndex > lastRenderedLineIndex) return;
|
|
135
|
+
return {
|
|
136
|
+
lineNumber: lineIndex + 1,
|
|
137
|
+
top: headerRegion + lineIndex * lineHeight
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
let top = headerRegion + this.renderRange.bufferBefore;
|
|
141
|
+
for (let lineIndex = firstRenderedLineIndex; lineIndex <= lastRenderedLineIndex; lineIndex++) {
|
|
142
|
+
if (top >= localViewportTop) return {
|
|
143
|
+
lineNumber: lineIndex + 1,
|
|
144
|
+
top
|
|
145
|
+
};
|
|
146
|
+
top += this.getLineHeight(lineIndex);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
getVirtualizedHeight() {
|
|
150
|
+
return this.height;
|
|
151
|
+
}
|
|
152
|
+
getAdvancedStickySpecs() {
|
|
153
|
+
if (this.top == null) return;
|
|
154
|
+
if (this.options.collapsed === true) return {
|
|
155
|
+
topOffset: this.top,
|
|
156
|
+
height: this.height
|
|
157
|
+
};
|
|
158
|
+
if (this.renderRange == null) return;
|
|
159
|
+
const { bufferBefore, bufferAfter, totalLines } = this.renderRange;
|
|
160
|
+
return {
|
|
161
|
+
topOffset: this.top + bufferBefore + (totalLines === 0 ? bufferAfter : 0),
|
|
162
|
+
height: this.height - (bufferBefore + bufferAfter)
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
cleanUp(recycle = false) {
|
|
166
|
+
if (this.fileContainer != null && this.isSimpleMode()) this.getSimpleVirtualizer()?.disconnect(this.fileContainer);
|
|
75
167
|
this.isSetup = false;
|
|
76
|
-
super.cleanUp();
|
|
168
|
+
super.cleanUp(recycle);
|
|
77
169
|
}
|
|
78
170
|
computeApproximateSize() {
|
|
79
171
|
const isFirstCompute = this.height === 0;
|
|
80
172
|
this.height = 0;
|
|
173
|
+
this.cache.checkpoints = [];
|
|
81
174
|
if (this.file == null) return;
|
|
82
175
|
const { disableFileHeader = false, collapsed = false, overflow = "scroll" } = this.options;
|
|
83
|
-
const {
|
|
176
|
+
const { lineHeight } = this.metrics;
|
|
84
177
|
const lines = this.getOrCreateLineCache(this.file);
|
|
85
|
-
|
|
86
|
-
|
|
178
|
+
const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
179
|
+
const paddingBottom = getVirtualFilePaddingBottom(this.metrics);
|
|
180
|
+
this.height += headerRegion;
|
|
87
181
|
if (collapsed) return;
|
|
88
182
|
if (overflow === "scroll" && this.lineAnnotations.length === 0) this.height += this.getOrCreateLineCache(this.file).length * lineHeight;
|
|
89
183
|
else iterateOverFile({
|
|
90
184
|
lines,
|
|
91
185
|
callback: ({ lineIndex }) => {
|
|
186
|
+
this.addLayoutCheckpoint(lineIndex, this.height);
|
|
92
187
|
this.height += this.getLineHeight(lineIndex, false);
|
|
93
188
|
}
|
|
94
189
|
});
|
|
95
|
-
if (lines.length > 0) this.height +=
|
|
96
|
-
if (this.fileContainer != null && this.
|
|
190
|
+
if (lines.length > 0) this.height += paddingBottom;
|
|
191
|
+
if (this.fileContainer != null && this.isResizeDebuggingEnabled() && !isFirstCompute) {
|
|
97
192
|
const rect = this.fileContainer.getBoundingClientRect();
|
|
98
193
|
if (rect.height !== this.height) console.log("VirtualizedFile.computeApproximateSize: computed height doesnt match", {
|
|
99
194
|
name: this.file.name,
|
|
@@ -104,17 +199,23 @@ var VirtualizedFile = class extends File {
|
|
|
104
199
|
}
|
|
105
200
|
}
|
|
106
201
|
setVisibility(visible) {
|
|
107
|
-
if (this.fileContainer == null) return;
|
|
202
|
+
if (this.isAdvancedMode() || this.fileContainer == null) return;
|
|
108
203
|
if (visible && !this.isVisible) {
|
|
109
|
-
this.top = this.
|
|
204
|
+
this.top = this.getVirtualizedTop();
|
|
110
205
|
this.isVisible = true;
|
|
111
206
|
} else if (!visible && this.isVisible) {
|
|
112
207
|
this.isVisible = false;
|
|
113
208
|
this.rerender();
|
|
114
209
|
}
|
|
115
210
|
}
|
|
116
|
-
|
|
117
|
-
|
|
211
|
+
rerender() {
|
|
212
|
+
if (!this.enabled || this.file == null) return;
|
|
213
|
+
this.forceRenderOverride = true;
|
|
214
|
+
this.virtualizer.instanceChanged(this, false);
|
|
215
|
+
}
|
|
216
|
+
render({ fileContainer, file, forceRender = false,...props }) {
|
|
217
|
+
const { forceRenderOverride, isSetup } = this;
|
|
218
|
+
this.forceRenderOverride = void 0;
|
|
118
219
|
this.file ??= file;
|
|
119
220
|
fileContainer = this.getOrCreateFileContainerNode(fileContainer);
|
|
120
221
|
if (this.file == null) {
|
|
@@ -123,33 +224,106 @@ var VirtualizedFile = class extends File {
|
|
|
123
224
|
}
|
|
124
225
|
if (!isSetup) {
|
|
125
226
|
this.computeApproximateSize();
|
|
126
|
-
this.
|
|
127
|
-
this.top ??= this.
|
|
128
|
-
|
|
227
|
+
const virtualizer = this.getSimpleVirtualizer();
|
|
228
|
+
this.top ??= this.getVirtualizedTop();
|
|
229
|
+
if (this.isAdvancedMode()) this.isVisible = true;
|
|
230
|
+
else {
|
|
231
|
+
if (virtualizer == null) throw new Error("VirtualizedFile.render: simple virtualizer is not available");
|
|
232
|
+
virtualizer.connect(fileContainer, this);
|
|
233
|
+
this.isVisible = virtualizer.isInstanceVisible(this.top ?? 0, this.height);
|
|
234
|
+
}
|
|
129
235
|
this.isSetup = true;
|
|
130
|
-
} else this.top ??= this.
|
|
131
|
-
if (!this.isVisible) return this.renderPlaceholder(this.height);
|
|
236
|
+
} else this.top ??= this.getVirtualizedTop();
|
|
237
|
+
if (!this.isVisible && this.isSimpleMode()) return this.renderPlaceholder(this.height);
|
|
132
238
|
const windowSpecs = this.virtualizer.getWindowSpecs();
|
|
133
|
-
const
|
|
239
|
+
const fileTop = this.top ?? 0;
|
|
240
|
+
const renderRange = this.computeRenderRangeFromWindow(this.file, fileTop, windowSpecs);
|
|
134
241
|
return super.render({
|
|
135
242
|
file: this.file,
|
|
136
243
|
fileContainer,
|
|
137
244
|
renderRange,
|
|
245
|
+
forceRender: forceRenderOverride ?? forceRender,
|
|
138
246
|
...props
|
|
139
247
|
});
|
|
140
248
|
}
|
|
249
|
+
syncVirtualizedTop() {
|
|
250
|
+
this.top = this.getVirtualizedTop();
|
|
251
|
+
}
|
|
252
|
+
shouldDisableVirtualizationBuffers() {
|
|
253
|
+
return this.isAdvancedMode() || super.shouldDisableVirtualizationBuffers();
|
|
254
|
+
}
|
|
255
|
+
isSimpleMode() {
|
|
256
|
+
return this.virtualizer.type === "simple";
|
|
257
|
+
}
|
|
258
|
+
isAdvancedMode() {
|
|
259
|
+
return this.virtualizer.type === "advanced";
|
|
260
|
+
}
|
|
261
|
+
addLayoutCheckpoint(lineIndex, top) {
|
|
262
|
+
if (lineIndex % LAYOUT_CHECKPOINT_INTERVAL !== 0) return;
|
|
263
|
+
this.cache.checkpoints.push({
|
|
264
|
+
lineIndex,
|
|
265
|
+
top
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
getLayoutCheckpointBeforeLineIndex(lineIndex) {
|
|
269
|
+
if (lineIndex <= 0 || this.cache.checkpoints.length === 0) return;
|
|
270
|
+
let low = 0;
|
|
271
|
+
let high = this.cache.checkpoints.length - 1;
|
|
272
|
+
let result;
|
|
273
|
+
while (low <= high) {
|
|
274
|
+
const mid = low + high >> 1;
|
|
275
|
+
const checkpoint = this.cache.checkpoints[mid];
|
|
276
|
+
if (checkpoint == null) throw new Error("VirtualizedFile: invalid checkpoint index");
|
|
277
|
+
if (checkpoint.lineIndex <= lineIndex) {
|
|
278
|
+
result = checkpoint;
|
|
279
|
+
low = mid + 1;
|
|
280
|
+
} else high = mid - 1;
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
getLayoutCheckpointBeforeTop(top, hunkLineCount) {
|
|
285
|
+
let low = 0;
|
|
286
|
+
let high = this.cache.checkpoints.length - 1;
|
|
287
|
+
let resultIndex = -1;
|
|
288
|
+
while (low <= high) {
|
|
289
|
+
const mid = low + high >> 1;
|
|
290
|
+
const checkpoint = this.cache.checkpoints[mid];
|
|
291
|
+
if (checkpoint == null) throw new Error("VirtualizedFile: invalid checkpoint index");
|
|
292
|
+
if (checkpoint.top <= top) {
|
|
293
|
+
resultIndex = mid;
|
|
294
|
+
low = mid + 1;
|
|
295
|
+
} else high = mid - 1;
|
|
296
|
+
}
|
|
297
|
+
if (hunkLineCount == null) return resultIndex >= 0 ? this.cache.checkpoints[resultIndex] : void 0;
|
|
298
|
+
for (let index = resultIndex; index >= 0; index--) {
|
|
299
|
+
const checkpoint = this.cache.checkpoints[index];
|
|
300
|
+
if (checkpoint == null) throw new Error("VirtualizedFile: invalid checkpoint index");
|
|
301
|
+
if (checkpoint.lineIndex % hunkLineCount === 0) return checkpoint;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
getVirtualizedTop() {
|
|
305
|
+
if (this.virtualizer.type === "advanced") return this.virtualizer.getTopForInstance(this);
|
|
306
|
+
return this.fileContainer != null ? this.virtualizer.getOffsetInScrollContainer(this.fileContainer) : 0;
|
|
307
|
+
}
|
|
308
|
+
getSimpleVirtualizer() {
|
|
309
|
+
return this.virtualizer.type === "simple" ? this.virtualizer : void 0;
|
|
310
|
+
}
|
|
311
|
+
isResizeDebuggingEnabled() {
|
|
312
|
+
return this.getSimpleVirtualizer()?.config.resizeDebugging ?? false;
|
|
313
|
+
}
|
|
141
314
|
computeRenderRangeFromWindow(file, fileTop, { top, bottom }) {
|
|
142
315
|
const { disableFileHeader = false, overflow = "scroll" } = this.options;
|
|
143
|
-
const {
|
|
316
|
+
const { hunkLineCount, lineHeight } = this.metrics;
|
|
144
317
|
const lines = this.getOrCreateLineCache(file);
|
|
145
318
|
const lineCount = lines.length;
|
|
146
319
|
const fileHeight = this.height;
|
|
147
|
-
const headerRegion = disableFileHeader
|
|
320
|
+
const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
321
|
+
const paddingBottom = lineCount > 0 ? getVirtualFilePaddingBottom(this.metrics) : 0;
|
|
148
322
|
if (fileTop < top - fileHeight || fileTop > bottom) return {
|
|
149
323
|
startingLine: 0,
|
|
150
324
|
totalLines: 0,
|
|
151
325
|
bufferBefore: 0,
|
|
152
|
-
bufferAfter: fileHeight - headerRegion -
|
|
326
|
+
bufferAfter: fileHeight - headerRegion - paddingBottom
|
|
153
327
|
};
|
|
154
328
|
if (lineCount <= hunkLineCount) return {
|
|
155
329
|
startingLine: 0,
|
|
@@ -178,24 +352,26 @@ var VirtualizedFile = class extends File {
|
|
|
178
352
|
}
|
|
179
353
|
const overflowHunks = totalHunks;
|
|
180
354
|
const hunkOffsets = [];
|
|
181
|
-
|
|
182
|
-
let
|
|
355
|
+
const checkpoint = this.getLayoutCheckpointBeforeTop(Math.max(0, top - fileTop - totalLines * lineHeight * 2), hunkLineCount);
|
|
356
|
+
let absoluteLineTop = fileTop + (checkpoint?.top ?? headerRegion);
|
|
357
|
+
let currentLine = checkpoint?.lineIndex ?? 0;
|
|
183
358
|
let firstVisibleHunk;
|
|
184
359
|
let centerHunk;
|
|
185
360
|
let overflowCounter;
|
|
186
361
|
iterateOverFile({
|
|
187
362
|
lines,
|
|
363
|
+
startingLine: checkpoint?.lineIndex ?? 0,
|
|
188
364
|
callback: ({ lineIndex }) => {
|
|
189
365
|
const isAtHunkBoundary = currentLine % hunkLineCount === 0;
|
|
366
|
+
const currentHunk = Math.floor(currentLine / hunkLineCount);
|
|
190
367
|
if (isAtHunkBoundary) {
|
|
191
|
-
hunkOffsets
|
|
368
|
+
hunkOffsets[currentHunk] = absoluteLineTop - (fileTop + headerRegion);
|
|
192
369
|
if (overflowCounter != null) {
|
|
193
370
|
if (overflowCounter <= 0) return true;
|
|
194
371
|
overflowCounter--;
|
|
195
372
|
}
|
|
196
373
|
}
|
|
197
374
|
const lineHeight$1 = this.getLineHeight(lineIndex, false);
|
|
198
|
-
const currentHunk = Math.floor(currentLine / hunkLineCount);
|
|
199
375
|
if (absoluteLineTop > top - lineHeight$1 && absoluteLineTop < bottom) firstVisibleHunk ??= currentHunk;
|
|
200
376
|
if (absoluteLineTop + lineHeight$1 > viewportCenter) centerHunk ??= currentHunk;
|
|
201
377
|
if (overflowCounter == null && absoluteLineTop >= bottom && isAtHunkBoundary) overflowCounter = overflowHunks;
|
|
@@ -208,12 +384,11 @@ var VirtualizedFile = class extends File {
|
|
|
208
384
|
startingLine: 0,
|
|
209
385
|
totalLines: 0,
|
|
210
386
|
bufferBefore: 0,
|
|
211
|
-
bufferAfter: fileHeight - headerRegion -
|
|
387
|
+
bufferAfter: fileHeight - headerRegion - paddingBottom
|
|
212
388
|
};
|
|
213
|
-
const collectedHunks = hunkOffsets.length;
|
|
214
389
|
centerHunk ??= firstVisibleHunk;
|
|
215
390
|
const idealStartHunk = Math.round(centerHunk - totalHunks / 2);
|
|
216
|
-
const maxStartHunk = Math.max(0,
|
|
391
|
+
const maxStartHunk = Math.max(0, Math.ceil(lineCount / hunkLineCount) - totalHunks);
|
|
217
392
|
const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));
|
|
218
393
|
const startingLine = startHunk * hunkLineCount;
|
|
219
394
|
const clampedTotalLines = idealStartHunk < 0 ? totalLines + idealStartHunk * hunkLineCount : totalLines;
|
|
@@ -223,10 +398,15 @@ var VirtualizedFile = class extends File {
|
|
|
223
398
|
startingLine,
|
|
224
399
|
totalLines: clampedTotalLines,
|
|
225
400
|
bufferBefore,
|
|
226
|
-
bufferAfter: finalHunkIndex < hunkOffsets.length ? fileHeight - headerRegion - hunkOffsets[finalHunkIndex] -
|
|
401
|
+
bufferAfter: finalHunkIndex < hunkOffsets.length ? fileHeight - headerRegion - hunkOffsets[finalHunkIndex] - paddingBottom : fileHeight - (absoluteLineTop - fileTop) - paddingBottom
|
|
227
402
|
};
|
|
228
403
|
}
|
|
229
404
|
};
|
|
405
|
+
function getLastVisibleLineIndex(lines) {
|
|
406
|
+
const lastLine = lines.at(-1);
|
|
407
|
+
if (lastLine == null || lastLine === "" || lastLine === "\n" || lastLine === "\r\n" || lastLine === "\r") return lines.length - 2;
|
|
408
|
+
return lines.length - 1;
|
|
409
|
+
}
|
|
230
410
|
|
|
231
411
|
//#endregion
|
|
232
412
|
export { VirtualizedFile };
|