@pierre/diffs 1.3.5 → 1.4.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 +113 -68
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +153 -58
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +75 -15
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +223 -62
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +97 -21
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +400 -100
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +2 -2
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +2 -2
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +16 -7
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +140 -51
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +14 -8
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +183 -93
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/edit/index.d.ts +7 -4
- package/dist/edit/index.js +5 -1
- package/dist/editor/EditStateManager.d.ts +56 -0
- package/dist/editor/EditStateManager.d.ts.map +1 -0
- package/dist/editor/EditStateManager.js +135 -0
- package/dist/editor/EditStateManager.js.map +1 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.d.ts +7 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.d.ts.map +1 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.js +16 -0
- package/dist/editor/cloneRetainedDiffSessionSnapshot.js.map +1 -0
- package/dist/editor/editPrediction.d.ts +76 -0
- package/dist/editor/editPrediction.d.ts.map +1 -0
- package/dist/editor/editPrediction.js +365 -0
- package/dist/editor/editPrediction.js.map +1 -0
- package/dist/editor/editStack.d.ts +19 -40
- package/dist/editor/editStack.d.ts.map +1 -1
- package/dist/editor/editStack.js +67 -4
- package/dist/editor/editStack.js.map +1 -1
- package/dist/editor/editor.d.ts +118 -29
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +1196 -403
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/languages.d.ts +3 -3
- package/dist/editor/languages.d.ts.map +1 -1
- package/dist/editor/languages.js.map +1 -1
- package/dist/editor/lineAnnotations.d.ts +3 -3
- package/dist/editor/lineAnnotations.d.ts.map +1 -1
- package/dist/editor/lineAnnotations.js +16 -7
- package/dist/editor/lineAnnotations.js.map +1 -1
- package/dist/editor/marker.d.ts +2 -2
- package/dist/editor/marker.d.ts.map +1 -1
- package/dist/editor/marker.js.map +1 -1
- package/dist/editor/matchBrackets.d.ts +2 -2
- package/dist/editor/matchBrackets.d.ts.map +1 -1
- package/dist/editor/matchBrackets.js.map +1 -1
- package/dist/editor/pieceTable.d.ts +1 -1
- package/dist/editor/pieceTable.js.map +1 -1
- package/dist/editor/searchPanel.d.ts +2 -2
- package/dist/editor/searchPanel.d.ts.map +1 -1
- package/dist/editor/searchPanel.js +3 -2
- package/dist/editor/searchPanel.js.map +1 -1
- package/dist/editor/selection.d.ts +33 -23
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/selection.js +3 -3
- package/dist/editor/selection.js.map +1 -1
- package/dist/editor/selectionAction.d.ts +3 -3
- package/dist/editor/selectionAction.d.ts.map +1 -1
- package/dist/editor/selectionAction.js.map +1 -1
- package/dist/editor/textDocument.d.ts +11 -8
- package/dist/editor/textDocument.d.ts.map +1 -1
- package/dist/editor/textDocument.js +28 -5
- package/dist/editor/textDocument.js.map +1 -1
- package/dist/editor/textDocumentChangeTransaction.d.ts +15 -0
- package/dist/editor/textDocumentChangeTransaction.d.ts.map +1 -0
- package/dist/editor/textDocumentChangeTransaction.js +12 -0
- package/dist/editor/textDocumentChangeTransaction.js.map +1 -0
- package/dist/editor/textMeasure.d.ts +5 -0
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +10 -0
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/tokenizer.d.ts +1 -1
- package/dist/editor/tokenizer.d.ts.map +1 -1
- package/dist/editor/tokenizer.js +6 -3
- package/dist/editor/tokenizer.js.map +1 -1
- package/dist/editor/types.d.ts +267 -0
- package/dist/editor/types.d.ts.map +1 -0
- package/dist/editor/types.js +0 -0
- package/dist/editor/utils.d.ts +2 -1
- package/dist/editor/utils.d.ts.map +1 -1
- package/dist/editor/utils.js +4 -1
- package/dist/editor/utils.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +9 -8
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +7 -0
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +36 -25
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +15 -14
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/EditContext.d.ts +8 -11
- package/dist/react/EditContext.d.ts.map +1 -1
- package/dist/react/EditContext.js +2 -9
- package/dist/react/EditContext.js.map +1 -1
- package/dist/react/File.d.ts +10 -6
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +8 -4
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +10 -5
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +8 -4
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +8 -5
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +8 -12
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +7 -4
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +8 -4
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +3 -3
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +8 -5
- package/dist/react/types.d.ts +46 -9
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +14 -12
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +2 -2
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +14 -12
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +2 -2
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +22 -10
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +112 -22
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +15 -9
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +84 -25
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +30 -15
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +172 -108
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +27 -11
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +138 -64
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +2 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +2 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
- package/dist/shiki-stream/tokenizer.js +2 -1
- package/dist/shiki-stream/tokenizer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +21 -21
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +1 -1
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/ssr/preloadFile.d.ts +6 -6
- package/dist/ssr/preloadFile.d.ts.map +1 -1
- package/dist/ssr/preloadFile.js.map +1 -1
- package/dist/ssr/preloadPatchFile.d.ts +4 -4
- package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
- package/dist/ssr/preloadPatchFile.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/types.d.ts +13 -263
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/appendItems.d.ts +5 -0
- package/dist/utils/appendItems.d.ts.map +1 -0
- package/dist/utils/appendItems.js +8 -0
- package/dist/utils/appendItems.js.map +1 -0
- package/dist/utils/areDiffTargetsEqual.js +1 -1
- package/dist/utils/areDiffTargetsEqual.js.map +1 -1
- package/dist/utils/areFileTargetsEqual.d.ts +7 -0
- package/dist/utils/areFileTargetsEqual.d.ts.map +1 -0
- package/dist/utils/areFileTargetsEqual.js +8 -0
- package/dist/utils/areFileTargetsEqual.js.map +1 -0
- package/dist/utils/areManagedSnapshotsEqual.d.ts +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
- package/dist/utils/areOptionsEqual.d.ts +3 -3
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.js.map +1 -1
- package/dist/utils/cloneFileDiffMetadata.d.ts +3 -2
- package/dist/utils/cloneFileDiffMetadata.d.ts.map +1 -1
- package/dist/utils/cloneFileDiffMetadata.js +8 -5
- package/dist/utils/cloneFileDiffMetadata.js.map +1 -1
- package/dist/utils/composeCacheKey.d.ts +6 -0
- package/dist/utils/composeCacheKey.d.ts.map +1 -0
- package/dist/utils/composeCacheKey.js +10 -0
- package/dist/utils/composeCacheKey.js.map +1 -0
- package/dist/utils/editSessionAnnotations.d.ts +69 -0
- package/dist/utils/editSessionAnnotations.d.ts.map +1 -0
- package/dist/utils/editSessionAnnotations.js +64 -0
- package/dist/utils/editSessionAnnotations.js.map +1 -0
- package/dist/utils/editSessionHunks.d.ts +5 -3
- package/dist/utils/editSessionHunks.d.ts.map +1 -1
- package/dist/utils/editSessionHunks.js +7 -5
- package/dist/utils/editSessionHunks.js.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.d.ts +1 -1
- package/dist/utils/getDiffHunksRendererOptions.d.ts.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFileRendererOptions.d.ts +1 -1
- package/dist/utils/getFileRendererOptions.d.ts.map +1 -1
- package/dist/utils/getFileRendererOptions.js.map +1 -1
- package/dist/utils/hydratePartialDiff.d.ts.map +1 -1
- package/dist/utils/hydratePartialDiff.js +2 -1
- package/dist/utils/hydratePartialDiff.js.map +1 -1
- package/dist/utils/lineAnnotationIdentity.d.ts +16 -0
- package/dist/utils/lineAnnotationIdentity.d.ts.map +1 -0
- package/dist/utils/lineAnnotationIdentity.js +17 -0
- package/dist/utils/lineAnnotationIdentity.js.map +1 -0
- package/dist/utils/parseDiffFromFile.d.ts +2 -2
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +6 -6
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts +6 -3
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +34 -9
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +6 -5
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +7 -4
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/trimPatchContext.d.ts.map +1 -1
- package/dist/utils/trimPatchContext.js +3 -2
- package/dist/utils/trimPatchContext.js.map +1 -1
- package/dist/utils/updateDiffHunks.js +1 -1
- package/dist/utils/virtualDiffLayout.js +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +4 -3
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +33 -4
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/types.d.ts +5 -0
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +14 -6
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +14 -6
- package/dist/worker/worker.js.map +1 -1
- package/package.json +9 -1
- package/dist/editor/stateStorage.d.ts +0 -15
- package/dist/editor/stateStorage.d.ts.map +0 -1
- package/dist/editor/stateStorage.js +0 -65
- package/dist/editor/stateStorage.js.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Element, ElementContent } from "../node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.js";
|
|
2
|
-
import { BaseCodeOptions, DiffsHighlighter,
|
|
2
|
+
import { BaseCodeOptions, DiffsHighlighter, FileContents, FileHeaderRenderMode, HighlightedToken, LineAnnotation, RenderFileOptions, RenderRange, ThemedFileResult } from "../types.js";
|
|
3
|
+
import { TextDocument } from "../editor/textDocument.js";
|
|
3
4
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
4
5
|
//#region src/renderers/FileRenderer.d.ts
|
|
5
6
|
interface FileRenderResult {
|
|
7
|
+
file: FileContents;
|
|
6
8
|
gutterAST: ElementContent[];
|
|
7
9
|
contentAST: ElementContent[];
|
|
8
10
|
preAST: Element;
|
|
@@ -20,18 +22,22 @@ interface FileRendererOptions extends BaseCodeOptions {
|
|
|
20
22
|
}
|
|
21
23
|
declare class FileRenderer<LAnnotation = undefined> {
|
|
22
24
|
options: FileRendererOptions;
|
|
25
|
+
private annotationSlotName;
|
|
23
26
|
private onRenderUpdate?;
|
|
24
27
|
private workerManager?;
|
|
25
28
|
readonly __id: string;
|
|
26
29
|
private highlighter;
|
|
30
|
+
private file;
|
|
27
31
|
private renderCache;
|
|
32
|
+
private pendingHighlightResult;
|
|
28
33
|
private computedLang;
|
|
29
34
|
private lineAnnotations;
|
|
30
35
|
private lineCache;
|
|
31
36
|
private pendingStructuralRows;
|
|
32
37
|
private textDocumentCache;
|
|
33
38
|
private editSessionActive;
|
|
34
|
-
|
|
39
|
+
get fileCache(): FileContents | undefined;
|
|
40
|
+
constructor(options?: FileRendererOptions, annotationSlotName?: (annotation: LineAnnotation<LAnnotation>) => string, onRenderUpdate?: (() => unknown) | undefined, workerManager?: WorkerPoolManager | undefined);
|
|
35
41
|
setOptions(options: FileRendererOptions): void;
|
|
36
42
|
mergeOptions(options: Partial<FileRendererOptions>): void;
|
|
37
43
|
setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;
|
|
@@ -39,29 +45,38 @@ declare class FileRenderer<LAnnotation = undefined> {
|
|
|
39
45
|
/**
|
|
40
46
|
* Enter edit-session mode: rendering happens locally with the token
|
|
41
47
|
* transformer forced on, and worker-pool requests/results are suspended
|
|
42
|
-
* for this renderer. Called on
|
|
43
|
-
* after recycle.
|
|
48
|
+
* for this renderer. Called on initial editor association and whenever its
|
|
49
|
+
* rendering resumes after recycle.
|
|
44
50
|
*/
|
|
45
|
-
beginEditSession(): void;
|
|
46
|
-
/**
|
|
47
|
-
|
|
51
|
+
beginEditSession(file?: FileContents, externalFile?: FileContents): void;
|
|
52
|
+
/**
|
|
53
|
+
* Leave edit-session mode. Rendering returns to the pool when one works.
|
|
54
|
+
* When `settledFile` has the content the cache already shows, the cache
|
|
55
|
+
* adopts it as its identity so the next render treats it as current
|
|
56
|
+
* instead of a new file.
|
|
57
|
+
*/
|
|
58
|
+
endEditSession(settledFile?: FileContents): void;
|
|
48
59
|
/**
|
|
49
60
|
* Ensures that the DOM is compatible with editor render updates
|
|
50
61
|
*/
|
|
51
62
|
editorRenderReady(): boolean;
|
|
52
63
|
recycle(): void;
|
|
53
|
-
private syncEditedContentsToFile;
|
|
54
|
-
hasUnkeyedFileContentsChanged(file: FileContents): boolean;
|
|
55
|
-
private invalidateChangedUnkeyedFile;
|
|
56
64
|
clearRenderCache(): void;
|
|
57
65
|
hydrate(file: FileContents): void;
|
|
58
66
|
private getLocalHighlightTheme;
|
|
59
67
|
getEffectiveCodeOptions(): Pick<BaseCodeOptions, 'theme' | 'tokenizeMaxLineLength'>;
|
|
60
68
|
private getRenderOptions;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the file that the next synchronous render can commit without
|
|
71
|
+
* changing the current render cache. Virtualized layouts use this to stay
|
|
72
|
+
* aligned with the DOM while a replacement highlight is still pending.
|
|
73
|
+
*/
|
|
74
|
+
getFileForNextRender(file: FileContents): FileContents;
|
|
75
|
+
private canRenderFile;
|
|
61
76
|
getOrCreateLineCache(file: FileContents): string[];
|
|
62
77
|
getLineCount(file: FileContents): number;
|
|
63
78
|
updateRenderCache(dirtyLines: Map<number, Array<HighlightedToken>>, themeType: 'dark' | 'light', lineCountChangeInFlight?: boolean): void;
|
|
64
|
-
applyDocumentChange(textDocument:
|
|
79
|
+
applyDocumentChange(textDocument: TextDocument<'file', LAnnotation>): void;
|
|
65
80
|
renderFile(file?: FileContents | undefined, renderRange?: RenderRange): FileRenderResult | undefined;
|
|
66
81
|
asyncRender(file: FileContents, renderRange?: RenderRange): Promise<FileRenderResult>;
|
|
67
82
|
private asyncHighlight;
|
|
@@ -76,6 +91,7 @@ declare class FileRenderer<LAnnotation = undefined> {
|
|
|
76
91
|
onHighlightSuccess(file: FileContents, result: ThemedFileResult, options: RenderFileOptions, highlighted?: boolean): void;
|
|
77
92
|
private applyHighlightResult;
|
|
78
93
|
private getMatchingWorkerResultCache;
|
|
94
|
+
private getReadyRenderResult;
|
|
79
95
|
private hasHighlightedRenderCache;
|
|
80
96
|
onHighlightError(error: unknown): void;
|
|
81
97
|
private getTokenizeMaxLength;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileRenderer.d.ts","names":[],"sources":["../../src/renderers/FileRenderer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileRenderer.d.ts","names":[],"sources":["../../src/renderers/FileRenderer.ts"],"mappings":";;;;;UAiFiB,gBAAA;EACf,IAAA,EAAM,YAAA;EACN,SAAA,EAAW,cAAA;EACX,UAAA,EAAY,cAAA;EACZ,MAAA,EAAQ,OAAA;EACR,SAAA,EAAW,OAAA;EACX,GAAA;EACA,UAAA;EACA,WAAA;EACA,aAAA;EACA,QAAA;EACA,YAAA;EACA,WAAA;AAAA;AAAA,UAkBe,mBAAA,SAA4B,eAAe;EAC1D,gBAAA,GAAmB,oBAAA;AAAA;AAAA,cAKR,YAAA;EAmCF,OAAA,EAAS,mBAAA;EAAA,QACR,kBAAA;EAAA,QAGA,cAAA;EAAA,QACA,aAAA;EAAA,SAvCD,IAAA;EAAA,QAED,WAAA;EAAA,QAIA,IAAA;EAAA,QAEA,WAAA;EAAA,QAGA,sBAAA;EAAA,QAEA,YAAA;EAAA,QACA,eAAA;EAAA,QACA,SAAA;EAAA,QACA,qBAAA;EAAA,QACA,iBAAA;EAAA,QAUA,iBAAA;EAAA,IAEG,SAAA,IAAa,YAAA;EAIxB,WAAA,CACS,OAAA,GAAS,mBAAA,EACR,kBAAA,IACN,UAAA,EAAY,cAAA,CAAe,WAAA,cAErB,cAAA,gCACA,aAAA,GAAgB,iBAAA;EASnB,UAAA,CAAW,OAAA,EAAS,mBAAA;EAIpB,YAAA,CAAa,OAAA,EAAS,OAAA,CAAQ,mBAAA;EAI9B,kBAAA,CACL,eAAA,EAAiB,cAAA,CAAe,WAAA;EAU3B,OAAA;EAzEgC;AAAA;AAKzC;;;;EAgFS,gBAAA,CACL,IAAA,GAAO,YAAA,EACP,YAAA,GAAe,YAAA;EA/CC;;;;;;EAuHX,cAAA,CAAe,WAAA,GAAc,YAAA;EAhGF;;;EAkH3B,iBAAA;EAQA,OAAA;EAgBA,gBAAA;EAMA,OAAA,CAAQ,IAAA,EAAM,YAAA;EAAA,QAqCb,sBAAA;EAQD,uBAAA,IAA2B,IAAA,CAChC,eAAA;EAAA,QAeM,gBAAA;EAiG0B;;;;;EA1D3B,oBAAA,CAAqB,IAAA,EAAM,YAAA,GAAe,YAAA;EAAA,QAyBzC,aAAA;EAiCD,oBAAA,CAAqB,IAAA,EAAM,YAAA;EAgB3B,YAAA,CAAa,IAAA,EAAM,YAAA;EAKnB,iBAAA,CACL,UAAA,EAAY,GAAA,SAAY,KAAA,CAAM,gBAAA,IAC9B,SAAA,oBACA,uBAAA;EAiFK,mBAAA,CACL,YAAA,EAAc,YAAA,SAAqB,WAAA;EAsG9B,UAAA,CACL,IAAA,GAAM,YAAA,cACN,WAAA,GAAa,WAAA,GACZ,gBAAA;EAuIG,WAAA,CACJ,IAAA,EAAM,YAAA,EACN,WAAA,GAAa,WAAA,GACZ,OAAA,CAAQ,gBAAA;EAAA,QAMG,cAAA;EAAA,QA2BN,yBAAA;EAAA,QAYA,iBAAA;EAAA,QA+FA,YAAA;EASD,cAAA,CAAe,MAAA,EAAQ,gBAAA;EAIvB,aAAA,CACL,MAAA,EAAQ,gBAAA,EACR,QAAA,GAAU,cAAA,KACT,OAAA;EAWI,aAAA,CAAc,MAAA,EAAQ,gBAAA,GAAmB,cAAA;EAWzC,iBAAA,CACL,QAAA,EAAU,cAAA,IACV,eAAA;EAcW,qBAAA,IAAyB,OAAA,CAAQ,gBAAA;EAYvC,kBAAA,CACL,IAAA,EAAM,YAAA,EACN,MAAA,EAAQ,gBAAA,EACR,OAAA,EAAS,iBAAA,EACT,WAAA;EAAA,QAQM,oBAAA;EAAA,QAqCA,4BAAA;EAAA,QAgBA,oBAAA;EAAA,QAoBA,yBAAA;EAaD,gBAAA,CAAiB,KAAA;EAAA,QAIhB,oBAAA;EAAA,QAIA,gBAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_RENDER_RANGE, DEFAULT_THEMES } from "../constants.js";
|
|
2
|
-
import {
|
|
2
|
+
import { areFileTargetsEqual } from "../utils/areFileTargetsEqual.js";
|
|
3
3
|
import { getFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
|
|
4
4
|
import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
|
|
5
5
|
import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
|
|
@@ -18,6 +18,7 @@ import { createPreElement } from "../utils/createPreElement.js";
|
|
|
18
18
|
import { getFiletypeFromFileName } from "../utils/getFiletypeFromFileName.js";
|
|
19
19
|
import { getHighlighterOptions } from "../utils/getHighlighterOptions.js";
|
|
20
20
|
import { getLineAnnotationName } from "../utils/getLineAnnotationName.js";
|
|
21
|
+
import { isDefaultRenderRange } from "../utils/isDefaultRenderRange.js";
|
|
21
22
|
import { isFilePlainText } from "../utils/isFilePlainText.js";
|
|
22
23
|
import { renderFileWithHighlighter } from "../utils/renderFileWithHighlighter.js";
|
|
23
24
|
import { toHtml } from "hast-util-to-html";
|
|
@@ -28,19 +29,26 @@ function isLineCacheForFile(lineCache, file) {
|
|
|
28
29
|
let instanceId = -1;
|
|
29
30
|
var FileRenderer = class {
|
|
30
31
|
options;
|
|
32
|
+
annotationSlotName;
|
|
31
33
|
onRenderUpdate;
|
|
32
34
|
workerManager;
|
|
33
35
|
__id = `file-renderer:${++instanceId}`;
|
|
34
36
|
highlighter;
|
|
37
|
+
file;
|
|
35
38
|
renderCache;
|
|
39
|
+
pendingHighlightResult;
|
|
36
40
|
computedLang = "text";
|
|
37
41
|
lineAnnotations = {};
|
|
38
42
|
lineCache;
|
|
39
43
|
pendingStructuralRows;
|
|
40
44
|
textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
41
45
|
editSessionActive = false;
|
|
42
|
-
|
|
46
|
+
get fileCache() {
|
|
47
|
+
return this.renderCache?.file;
|
|
48
|
+
}
|
|
49
|
+
constructor(options = { theme: DEFAULT_THEMES }, annotationSlotName = getLineAnnotationName, onRenderUpdate, workerManager) {
|
|
43
50
|
this.options = options;
|
|
51
|
+
this.annotationSlotName = annotationSlotName;
|
|
44
52
|
this.onRenderUpdate = onRenderUpdate;
|
|
45
53
|
this.workerManager = workerManager;
|
|
46
54
|
if (workerManager?.isWorkingPool() !== true) this.highlighter = areThemesAttached(options.theme ?? DEFAULT_THEMES) ? getHighlighterIfLoaded() : void 0;
|
|
@@ -70,15 +78,57 @@ var FileRenderer = class {
|
|
|
70
78
|
/**
|
|
71
79
|
* Enter edit-session mode: rendering happens locally with the token
|
|
72
80
|
* transformer forced on, and worker-pool requests/results are suspended
|
|
73
|
-
* for this renderer. Called on
|
|
74
|
-
* after recycle.
|
|
81
|
+
* for this renderer. Called on initial editor association and whenever its
|
|
82
|
+
* rendering resumes after recycle.
|
|
75
83
|
*/
|
|
76
|
-
beginEditSession() {
|
|
84
|
+
beginEditSession(file, externalFile) {
|
|
85
|
+
const { editSessionActive: wasAlreadyActive, renderCache } = this;
|
|
77
86
|
this.editSessionActive = true;
|
|
87
|
+
if (!wasAlreadyActive) this.pendingHighlightResult = void 0;
|
|
88
|
+
if (file == null) return;
|
|
89
|
+
this.file = file;
|
|
90
|
+
if (renderCache == null) return;
|
|
91
|
+
if (wasAlreadyActive && renderCache.file === file) return;
|
|
92
|
+
const { options } = this.getRenderOptions(file);
|
|
93
|
+
const cacheBelongsToSession = renderCache.file === file;
|
|
94
|
+
const cacheBelongsToExternal = externalFile != null && areFileTargetsEqual(renderCache.file, externalFile);
|
|
95
|
+
const { result } = renderCache;
|
|
96
|
+
if (!renderCache.highlighted || result == null || !areFileRenderOptionsEqual(renderCache.options, options) || !cacheBelongsToSession && !cacheBelongsToExternal) {
|
|
97
|
+
this.clearRenderCache();
|
|
98
|
+
this.lineCache = void 0;
|
|
99
|
+
this.textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (cacheBelongsToSession) return;
|
|
103
|
+
this.renderCache = {
|
|
104
|
+
...renderCache,
|
|
105
|
+
file,
|
|
106
|
+
result: {
|
|
107
|
+
...result,
|
|
108
|
+
code: [...result.code]
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const { lineCache } = this;
|
|
112
|
+
if (lineCache != null && externalFile != null && isLineCacheForFile(lineCache, externalFile)) this.lineCache = {
|
|
113
|
+
cacheKey: void 0,
|
|
114
|
+
file,
|
|
115
|
+
sourceContents: file.contents,
|
|
116
|
+
lines: lineCache.lines
|
|
117
|
+
};
|
|
118
|
+
else this.lineCache = void 0;
|
|
78
119
|
}
|
|
79
|
-
/**
|
|
80
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Leave edit-session mode. Rendering returns to the pool when one works.
|
|
122
|
+
* When `settledFile` has the content the cache already shows, the cache
|
|
123
|
+
* adopts it as its identity so the next render treats it as current
|
|
124
|
+
* instead of a new file.
|
|
125
|
+
*/
|
|
126
|
+
endEditSession(settledFile) {
|
|
81
127
|
this.editSessionActive = false;
|
|
128
|
+
this.pendingHighlightResult = void 0;
|
|
129
|
+
const { renderCache } = this;
|
|
130
|
+
if (settledFile == null || renderCache == null || renderCache.file === settledFile || !areFileTargetsEqual(renderCache.file, settledFile)) return;
|
|
131
|
+
renderCache.file = settledFile;
|
|
82
132
|
}
|
|
83
133
|
/**
|
|
84
134
|
* Ensures that the DOM is compatible with editor render updates
|
|
@@ -91,39 +141,24 @@ var FileRenderer = class {
|
|
|
91
141
|
this.highlighter = void 0;
|
|
92
142
|
this.workerManager?.cleanUpTasks(this);
|
|
93
143
|
this.lineCache = void 0;
|
|
144
|
+
this.file = void 0;
|
|
94
145
|
this.endEditSession();
|
|
95
146
|
this.textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
96
147
|
}
|
|
97
|
-
syncEditedContentsToFile() {
|
|
98
|
-
const { renderCache, lineCache } = this;
|
|
99
|
-
if (renderCache?.isDirty !== true || lineCache == null || !isLineCacheForFile(lineCache, renderCache.file)) return;
|
|
100
|
-
renderCache.file.contents = lineCache.lines.join("");
|
|
101
|
-
}
|
|
102
|
-
hasUnkeyedFileContentsChanged(file) {
|
|
103
|
-
const { lineCache } = this;
|
|
104
|
-
return file.cacheKey == null && lineCache != null && lineCache.file === file && lineCache.sourceContents !== file.contents;
|
|
105
|
-
}
|
|
106
|
-
invalidateChangedUnkeyedFile(file) {
|
|
107
|
-
if (!this.hasUnkeyedFileContentsChanged(file)) return;
|
|
108
|
-
this.workerManager?.cleanUpTasks(this);
|
|
109
|
-
this.clearRenderCache();
|
|
110
|
-
this.lineCache = void 0;
|
|
111
|
-
this.textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
112
|
-
}
|
|
113
148
|
clearRenderCache() {
|
|
114
|
-
this.syncEditedContentsToFile();
|
|
115
149
|
this.pendingStructuralRows = void 0;
|
|
116
|
-
const renderCache = this.renderCache;
|
|
117
150
|
this.renderCache = void 0;
|
|
118
|
-
|
|
151
|
+
this.pendingHighlightResult = void 0;
|
|
119
152
|
}
|
|
120
153
|
hydrate(file) {
|
|
154
|
+
this.file = file;
|
|
121
155
|
const { options } = this.getRenderOptions(file);
|
|
122
156
|
const massiveFile = isFileMassive(this.getOrCreateLineCache(file).length, this.getTokenizeMaxLength());
|
|
123
157
|
let cache = this.workerManager?.getFileResultCache(file);
|
|
124
158
|
if (cache != null && !areFileRenderOptionsEqual(options, cache.options)) cache = void 0;
|
|
125
159
|
this.renderCache ??= {
|
|
126
160
|
file,
|
|
161
|
+
hydrated: true,
|
|
127
162
|
options,
|
|
128
163
|
highlighted: !massiveFile && !isFilePlainText(file),
|
|
129
164
|
result: massiveFile ? void 0 : cache?.result,
|
|
@@ -168,7 +203,7 @@ var FileRenderer = class {
|
|
|
168
203
|
options,
|
|
169
204
|
forceHighlight: true
|
|
170
205
|
};
|
|
171
|
-
if (!
|
|
206
|
+
if (!areFileTargetsEqual(file, renderCache.file) || !areFileRenderOptionsEqual(options, renderCache.options)) return {
|
|
172
207
|
options,
|
|
173
208
|
forceHighlight: true
|
|
174
209
|
};
|
|
@@ -177,8 +212,30 @@ var FileRenderer = class {
|
|
|
177
212
|
forceHighlight: false
|
|
178
213
|
};
|
|
179
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Returns the file that the next synchronous render can commit without
|
|
217
|
+
* changing the current render cache. Virtualized layouts use this to stay
|
|
218
|
+
* aligned with the DOM while a replacement highlight is still pending.
|
|
219
|
+
*/
|
|
220
|
+
getFileForNextRender(file) {
|
|
221
|
+
const { options } = this.getRenderOptions(file);
|
|
222
|
+
if (this.getReadyRenderResult(file, options) != null) return file;
|
|
223
|
+
const { renderCache } = this;
|
|
224
|
+
if (renderCache == null) return file;
|
|
225
|
+
if (areFileTargetsEqual(renderCache.file, file)) return renderCache.file;
|
|
226
|
+
const lines = linesFromFileContents(file.contents);
|
|
227
|
+
const forcePlainText = file.contents.length === 0 || isFilePlainText(file) || isFileMassive(lines.length, this.getTokenizeMaxLength());
|
|
228
|
+
return this.canRenderFile(file, options, forcePlainText) ? file : renderCache.file;
|
|
229
|
+
}
|
|
230
|
+
canRenderFile(file, options, forcePlainText) {
|
|
231
|
+
const { renderCache } = this;
|
|
232
|
+
if (renderCache == null || areFileTargetsEqual(renderCache.file, file)) return true;
|
|
233
|
+
if (forcePlainText) return renderCache.result == null && renderCache.hydrated !== true || this.workerManager?.isWorkingPool() === true || this.highlighter != null && areThemesAttached(options.theme);
|
|
234
|
+
if (renderCache.result == null && renderCache.hydrated !== true) return true;
|
|
235
|
+
if (!this.editSessionActive && this.workerManager?.isWorkingPool() === true) return !renderCache.highlighted;
|
|
236
|
+
return this.highlighter != null && areThemesAttached(options.theme);
|
|
237
|
+
}
|
|
180
238
|
getOrCreateLineCache(file) {
|
|
181
|
-
this.invalidateChangedUnkeyedFile(file);
|
|
182
239
|
let { lineCache } = this;
|
|
183
240
|
if (lineCache == null || !isLineCacheForFile(lineCache, file)) lineCache = {
|
|
184
241
|
cacheKey: file.cacheKey,
|
|
@@ -195,14 +252,15 @@ var FileRenderer = class {
|
|
|
195
252
|
}
|
|
196
253
|
updateRenderCache(dirtyLines, themeType, lineCountChangeInFlight = false) {
|
|
197
254
|
this.pendingStructuralRows = void 0;
|
|
198
|
-
|
|
199
|
-
|
|
255
|
+
const { renderCache } = this;
|
|
256
|
+
if (renderCache == null) return;
|
|
257
|
+
const { file, result } = renderCache;
|
|
200
258
|
if (result == null) return;
|
|
201
259
|
const pendingStructuralRows = lineCountChangeInFlight ? /* @__PURE__ */ new Map() : void 0;
|
|
202
260
|
this.pendingStructuralRows = pendingStructuralRows;
|
|
203
261
|
const lineCache = this.lineCache != null && isLineCacheForFile(this.lineCache, file) ? this.lineCache : void 0;
|
|
204
262
|
for (const [line, tokens] of dirtyLines) {
|
|
205
|
-
if (pendingStructuralRows
|
|
263
|
+
if (pendingStructuralRows == null && lineCache != null && line < lineCache.lines.length) {
|
|
206
264
|
const lineText = tokens.map((token) => token[2]).join("");
|
|
207
265
|
lineCache.lines[line] = applyLineTextWithNewline(lineCache.lines[line] ?? "", lineText);
|
|
208
266
|
}
|
|
@@ -241,17 +299,21 @@ var FileRenderer = class {
|
|
|
241
299
|
};
|
|
242
300
|
})
|
|
243
301
|
};
|
|
244
|
-
if (pendingStructuralRows
|
|
302
|
+
if (pendingStructuralRows != null) pendingStructuralRows.set(line, row);
|
|
245
303
|
else result.code[line] = row;
|
|
246
304
|
}
|
|
247
305
|
result.baseThemeType = themeType;
|
|
248
|
-
|
|
306
|
+
renderCache.isDirty = true;
|
|
307
|
+
if (pendingStructuralRows == null && lineCache != null) {
|
|
308
|
+
file.contents = lineCache.lines.join("");
|
|
309
|
+
lineCache.sourceContents = file.contents;
|
|
310
|
+
}
|
|
249
311
|
}
|
|
250
312
|
applyDocumentChange(textDocument) {
|
|
251
|
-
const pendingStructuralRows = this
|
|
313
|
+
const { pendingStructuralRows, renderCache } = this;
|
|
252
314
|
this.pendingStructuralRows = void 0;
|
|
253
|
-
if (
|
|
254
|
-
const { file, result } =
|
|
315
|
+
if (renderCache == null) return;
|
|
316
|
+
const { file, result } = renderCache;
|
|
255
317
|
if (result == null) return;
|
|
256
318
|
const previousLines = this.lineCache != null && isLineCacheForFile(this.lineCache, file) ? this.lineCache.lines : linesFromFileContents(file.contents);
|
|
257
319
|
const nextLines = linesFromFileContents(textDocument.getText());
|
|
@@ -293,7 +355,7 @@ var FileRenderer = class {
|
|
|
293
355
|
line.properties["data-line-index"] = i;
|
|
294
356
|
}
|
|
295
357
|
}
|
|
296
|
-
|
|
358
|
+
renderCache.isDirty = true;
|
|
297
359
|
}
|
|
298
360
|
this.lineCache = {
|
|
299
361
|
cacheKey: file.cacheKey,
|
|
@@ -302,24 +364,22 @@ var FileRenderer = class {
|
|
|
302
364
|
lines: nextLines
|
|
303
365
|
};
|
|
304
366
|
this.textDocumentCache.set(file, textDocument);
|
|
367
|
+
file.contents = textDocument.getText();
|
|
305
368
|
}
|
|
306
|
-
renderFile(file = this.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
this.lineCache = void 0;
|
|
312
|
-
this.textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
369
|
+
renderFile(file = this.file, renderRange = DEFAULT_RENDER_RANGE) {
|
|
370
|
+
this.file = file;
|
|
371
|
+
if (file == null) {
|
|
372
|
+
this.pendingHighlightResult = void 0;
|
|
373
|
+
return;
|
|
313
374
|
}
|
|
314
375
|
let { options, forceHighlight } = this.getRenderOptions(file);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (
|
|
376
|
+
const readyResult = this.getReadyRenderResult(file, options);
|
|
377
|
+
this.pendingHighlightResult = void 0;
|
|
378
|
+
if (readyResult != null) {
|
|
318
379
|
this.renderCache = {
|
|
380
|
+
...readyResult,
|
|
319
381
|
file,
|
|
320
|
-
|
|
321
|
-
renderRange: void 0,
|
|
322
|
-
...cache
|
|
382
|
+
renderRange: void 0
|
|
323
383
|
};
|
|
324
384
|
forceHighlight = false;
|
|
325
385
|
}
|
|
@@ -333,10 +393,12 @@ var FileRenderer = class {
|
|
|
333
393
|
const lines = this.getOrCreateLineCache(file);
|
|
334
394
|
const hasContent = file.contents.length > 0;
|
|
335
395
|
const forcePlainText = !hasContent || isFilePlainText(file) || isFileMassive(lines.length, this.getTokenizeMaxLength());
|
|
336
|
-
const
|
|
396
|
+
const canRenderFile = this.canRenderFile(file, options, forcePlainText);
|
|
397
|
+
const newContent = !areFileTargetsEqual(file, this.renderCache.file);
|
|
337
398
|
const newRenderRange = !areRenderRangesEqual(this.renderCache.renderRange, renderRange);
|
|
338
399
|
if (!this.editSessionActive && this.workerManager?.isWorkingPool() === true) {
|
|
339
|
-
|
|
400
|
+
const preserveHydratedContent = this.renderCache.result == null && this.renderCache.highlighted && !forcePlainText && !newContent && isDefaultRenderRange(renderRange);
|
|
401
|
+
if (canRenderFile && !preserveHydratedContent && (forcePlainText || this.renderCache.result == null || !this.renderCache.highlighted && (newContent || newRenderRange))) {
|
|
340
402
|
this.renderCache.file = file;
|
|
341
403
|
this.renderCache.options = options;
|
|
342
404
|
this.renderCache.highlighted = false;
|
|
@@ -349,7 +411,7 @@ var FileRenderer = class {
|
|
|
349
411
|
const hasThemes = this.highlighter != null && areThemesAttached(options.theme);
|
|
350
412
|
const hasLangs = this.highlighter != null && areLanguagesAttached(this.computedLang);
|
|
351
413
|
const canHighlight = !forcePlainText && hasLangs;
|
|
352
|
-
if (this.highlighter != null && hasThemes && (forceHighlight || forcePlainText || !this.renderCache.highlighted && canHighlight || this.renderCache.result == null)) {
|
|
414
|
+
if (canRenderFile && this.highlighter != null && hasThemes && (forceHighlight || forcePlainText || !this.renderCache.highlighted && canHighlight || this.renderCache.result == null)) {
|
|
353
415
|
const { result, options } = this.renderFileWithHighlighter(file, this.highlighter, forcePlainText || !hasLangs);
|
|
354
416
|
this.renderCache = {
|
|
355
417
|
file,
|
|
@@ -360,13 +422,13 @@ var FileRenderer = class {
|
|
|
360
422
|
};
|
|
361
423
|
}
|
|
362
424
|
if (!hasThemes || !forcePlainText && !hasLangs) this.asyncHighlight(file).then(({ result, options }) => {
|
|
363
|
-
if (this.renderCache != null) this.renderCache.highlighted = false;
|
|
364
425
|
this.applyHighlightResult(file, result, options, !forcePlainText);
|
|
365
426
|
});
|
|
366
427
|
}
|
|
367
428
|
return this.renderCache.result != null ? this.processFileResult(this.renderCache.file, renderRange, this.renderCache.result) : void 0;
|
|
368
429
|
}
|
|
369
430
|
async asyncRender(file, renderRange = DEFAULT_RENDER_RANGE) {
|
|
431
|
+
this.file = file;
|
|
370
432
|
const { result } = await this.asyncHighlight(file);
|
|
371
433
|
return this.processFileResult(file, renderRange, result);
|
|
372
434
|
}
|
|
@@ -399,7 +461,7 @@ var FileRenderer = class {
|
|
|
399
461
|
type: "annotation",
|
|
400
462
|
hunkIndex: -1,
|
|
401
463
|
lineIndex: -1,
|
|
402
|
-
annotations: fileLevelAnnotations.map((annotation) =>
|
|
464
|
+
annotations: fileLevelAnnotations.map((annotation) => this.annotationSlotName(annotation))
|
|
403
465
|
}));
|
|
404
466
|
rowCount++;
|
|
405
467
|
}
|
|
@@ -425,13 +487,14 @@ var FileRenderer = class {
|
|
|
425
487
|
type: "annotation",
|
|
426
488
|
hunkIndex: 0,
|
|
427
489
|
lineIndex: lineNumber,
|
|
428
|
-
annotations: annotations.map((annotation) =>
|
|
490
|
+
annotations: annotations.map((annotation) => this.annotationSlotName(annotation))
|
|
429
491
|
}));
|
|
430
492
|
rowCount++;
|
|
431
493
|
}
|
|
432
494
|
}
|
|
433
495
|
gutter.properties.style = `grid-row: span ${rowCount}`;
|
|
434
496
|
return {
|
|
497
|
+
file,
|
|
435
498
|
gutterAST: gutter.children ?? [],
|
|
436
499
|
contentAST: contentArray,
|
|
437
500
|
preAST: this.createPreElement(totalLines),
|
|
@@ -493,16 +556,16 @@ var FileRenderer = class {
|
|
|
493
556
|
this.applyHighlightResult(file, result, options, highlighted);
|
|
494
557
|
}
|
|
495
558
|
applyHighlightResult(file, result, options, highlighted = true) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
559
|
+
const { file: currentFile, renderCache } = this;
|
|
560
|
+
if (currentFile == null || renderCache == null || !areFileTargetsEqual(file, currentFile) || !areFileRenderOptionsEqual(options, this.getRenderOptions(currentFile).options)) return;
|
|
561
|
+
if (!(renderCache.result == null || !renderCache.highlighted || !areFileRenderOptionsEqual(renderCache.options, options) || !areFileTargetsEqual(renderCache.file, currentFile))) return;
|
|
562
|
+
this.pendingHighlightResult = {
|
|
563
|
+
file: currentFile,
|
|
500
564
|
options,
|
|
501
565
|
highlighted,
|
|
502
|
-
result
|
|
503
|
-
renderRange: void 0
|
|
566
|
+
result
|
|
504
567
|
};
|
|
505
|
-
|
|
568
|
+
this.onRenderUpdate?.();
|
|
506
569
|
}
|
|
507
570
|
getMatchingWorkerResultCache(file, options) {
|
|
508
571
|
if (this.editSessionActive) return;
|
|
@@ -510,9 +573,20 @@ var FileRenderer = class {
|
|
|
510
573
|
if (cache == null || !areFileRenderOptionsEqual(options, cache.options)) return;
|
|
511
574
|
return cache;
|
|
512
575
|
}
|
|
576
|
+
getReadyRenderResult(file, options) {
|
|
577
|
+
const { pendingHighlightResult } = this;
|
|
578
|
+
if (pendingHighlightResult != null && areFileTargetsEqual(pendingHighlightResult.file, file) && areFileRenderOptionsEqual(pendingHighlightResult.options, options)) return pendingHighlightResult;
|
|
579
|
+
const workerCache = this.getMatchingWorkerResultCache(file, options);
|
|
580
|
+
if (workerCache == null || this.hasHighlightedRenderCache(file, options)) return;
|
|
581
|
+
return {
|
|
582
|
+
file,
|
|
583
|
+
highlighted: true,
|
|
584
|
+
...workerCache
|
|
585
|
+
};
|
|
586
|
+
}
|
|
513
587
|
hasHighlightedRenderCache(file, options) {
|
|
514
588
|
const { renderCache } = this;
|
|
515
|
-
return renderCache?.result != null && renderCache.highlighted &&
|
|
589
|
+
return renderCache?.result != null && renderCache.highlighted && areFileTargetsEqual(file, renderCache.file) && areFileRenderOptionsEqual(options, renderCache.options);
|
|
516
590
|
}
|
|
517
591
|
onHighlightError(error) {
|
|
518
592
|
console.error(error);
|