@pierre/diffs 1.3.6 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeView.d.ts +115 -68
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +189 -59
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +79 -15
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +244 -66
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +101 -21
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +432 -102
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.js +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 +17 -7
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +142 -53
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +15 -8
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +186 -96
- 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 +1108 -384
- 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.js +1 -1
- package/dist/editor/searchPanel.js.map +1 -1
- package/dist/editor/selection.d.ts +32 -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.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/highlighter/shared_highlighter.d.ts +6 -2
- package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.js +7 -3
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/highlighter/themes/areThemesAttached.js +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +22 -21
- 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 -109
- 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 +141 -67
- 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 +44 -6
- 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,EAAM,YAAA,EACN,YAAA,GAAe,YAAA;EA/CC;;;;;;EAoHX,cAAA,CAAe,WAAA,GAAc,YAAA;EA7FF;;;EA+G3B,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;EAwIG,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,11 +1,11 @@
|
|
|
1
1
|
import { DEFAULT_RENDER_RANGE, DEFAULT_THEMES } from "../constants.js";
|
|
2
|
-
import { areFilesEqual } from "../utils/areFilesEqual.js";
|
|
3
|
-
import { getFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
|
|
4
|
-
import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
|
|
5
2
|
import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
|
|
6
|
-
import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
|
|
7
3
|
import { getThemes } from "../utils/getThemes.js";
|
|
8
4
|
import { areThemesAttached } from "../highlighter/themes/areThemesAttached.js";
|
|
5
|
+
import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
|
|
6
|
+
import { areFileTargetsEqual } from "../utils/areFileTargetsEqual.js";
|
|
7
|
+
import { getFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
|
|
8
|
+
import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
|
|
9
9
|
import { hasResolvedThemes } from "../highlighter/themes/hasResolvedThemes.js";
|
|
10
10
|
import { applyLineTextWithNewline } from "../utils/applyLineTextWithNewline.js";
|
|
11
11
|
import { areFileRenderOptionsEqual } from "../utils/areFileRenderOptionsEqual.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,56 @@ 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
|
+
this.file = file;
|
|
89
|
+
if (renderCache == null) return;
|
|
90
|
+
if (wasAlreadyActive && renderCache.file === file) return;
|
|
91
|
+
const { options } = this.getRenderOptions(file);
|
|
92
|
+
const cacheBelongsToSession = renderCache.file === file;
|
|
93
|
+
const cacheBelongsToExternal = externalFile != null && areFileTargetsEqual(renderCache.file, externalFile);
|
|
94
|
+
const { result } = renderCache;
|
|
95
|
+
if (!renderCache.highlighted || result == null || !areFileRenderOptionsEqual(renderCache.options, options) || !cacheBelongsToSession && !cacheBelongsToExternal) {
|
|
96
|
+
this.clearRenderCache();
|
|
97
|
+
this.lineCache = void 0;
|
|
98
|
+
this.textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (cacheBelongsToSession) return;
|
|
102
|
+
this.renderCache = {
|
|
103
|
+
...renderCache,
|
|
104
|
+
file,
|
|
105
|
+
result: {
|
|
106
|
+
...result,
|
|
107
|
+
code: [...result.code]
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const { lineCache } = this;
|
|
111
|
+
if (lineCache != null && externalFile != null && isLineCacheForFile(lineCache, externalFile)) this.lineCache = {
|
|
112
|
+
cacheKey: void 0,
|
|
113
|
+
file,
|
|
114
|
+
sourceContents: file.contents,
|
|
115
|
+
lines: lineCache.lines
|
|
116
|
+
};
|
|
117
|
+
else this.lineCache = void 0;
|
|
78
118
|
}
|
|
79
|
-
/**
|
|
80
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Leave edit-session mode. Rendering returns to the pool when one works.
|
|
121
|
+
* When `settledFile` has the content the cache already shows, the cache
|
|
122
|
+
* adopts it as its identity so the next render treats it as current
|
|
123
|
+
* instead of a new file.
|
|
124
|
+
*/
|
|
125
|
+
endEditSession(settledFile) {
|
|
81
126
|
this.editSessionActive = false;
|
|
127
|
+
this.pendingHighlightResult = void 0;
|
|
128
|
+
const { renderCache } = this;
|
|
129
|
+
if (settledFile == null || renderCache == null || renderCache.file === settledFile || !areFileTargetsEqual(renderCache.file, settledFile)) return;
|
|
130
|
+
renderCache.file = settledFile;
|
|
82
131
|
}
|
|
83
132
|
/**
|
|
84
133
|
* Ensures that the DOM is compatible with editor render updates
|
|
@@ -91,39 +140,24 @@ var FileRenderer = class {
|
|
|
91
140
|
this.highlighter = void 0;
|
|
92
141
|
this.workerManager?.cleanUpTasks(this);
|
|
93
142
|
this.lineCache = void 0;
|
|
143
|
+
this.file = void 0;
|
|
94
144
|
this.endEditSession();
|
|
95
145
|
this.textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
96
146
|
}
|
|
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
147
|
clearRenderCache() {
|
|
114
|
-
this.syncEditedContentsToFile();
|
|
115
148
|
this.pendingStructuralRows = void 0;
|
|
116
|
-
const renderCache = this.renderCache;
|
|
117
149
|
this.renderCache = void 0;
|
|
118
|
-
|
|
150
|
+
this.pendingHighlightResult = void 0;
|
|
119
151
|
}
|
|
120
152
|
hydrate(file) {
|
|
153
|
+
this.file = file;
|
|
121
154
|
const { options } = this.getRenderOptions(file);
|
|
122
155
|
const massiveFile = isFileMassive(this.getOrCreateLineCache(file).length, this.getTokenizeMaxLength());
|
|
123
156
|
let cache = this.workerManager?.getFileResultCache(file);
|
|
124
157
|
if (cache != null && !areFileRenderOptionsEqual(options, cache.options)) cache = void 0;
|
|
125
158
|
this.renderCache ??= {
|
|
126
159
|
file,
|
|
160
|
+
hydrated: true,
|
|
127
161
|
options,
|
|
128
162
|
highlighted: !massiveFile && !isFilePlainText(file),
|
|
129
163
|
result: massiveFile ? void 0 : cache?.result,
|
|
@@ -168,7 +202,7 @@ var FileRenderer = class {
|
|
|
168
202
|
options,
|
|
169
203
|
forceHighlight: true
|
|
170
204
|
};
|
|
171
|
-
if (!
|
|
205
|
+
if (!areFileTargetsEqual(file, renderCache.file) || !areFileRenderOptionsEqual(options, renderCache.options)) return {
|
|
172
206
|
options,
|
|
173
207
|
forceHighlight: true
|
|
174
208
|
};
|
|
@@ -177,8 +211,30 @@ var FileRenderer = class {
|
|
|
177
211
|
forceHighlight: false
|
|
178
212
|
};
|
|
179
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Returns the file that the next synchronous render can commit without
|
|
216
|
+
* changing the current render cache. Virtualized layouts use this to stay
|
|
217
|
+
* aligned with the DOM while a replacement highlight is still pending.
|
|
218
|
+
*/
|
|
219
|
+
getFileForNextRender(file) {
|
|
220
|
+
const { options } = this.getRenderOptions(file);
|
|
221
|
+
if (this.getReadyRenderResult(file, options) != null) return file;
|
|
222
|
+
const { renderCache } = this;
|
|
223
|
+
if (renderCache == null) return file;
|
|
224
|
+
if (areFileTargetsEqual(renderCache.file, file)) return renderCache.file;
|
|
225
|
+
const lines = linesFromFileContents(file.contents);
|
|
226
|
+
const forcePlainText = file.contents.length === 0 || isFilePlainText(file) || isFileMassive(lines.length, this.getTokenizeMaxLength());
|
|
227
|
+
return this.canRenderFile(file, options, forcePlainText) ? file : renderCache.file;
|
|
228
|
+
}
|
|
229
|
+
canRenderFile(file, options, forcePlainText) {
|
|
230
|
+
const { renderCache } = this;
|
|
231
|
+
if (renderCache == null || areFileTargetsEqual(renderCache.file, file)) return true;
|
|
232
|
+
if (forcePlainText) return renderCache.result == null && renderCache.hydrated !== true || this.workerManager?.isWorkingPool() === true || this.highlighter != null && areThemesAttached(options.theme);
|
|
233
|
+
if (renderCache.result == null && renderCache.hydrated !== true) return true;
|
|
234
|
+
if (!this.editSessionActive && this.workerManager?.isWorkingPool() === true) return !renderCache.highlighted;
|
|
235
|
+
return this.highlighter != null && areThemesAttached(options.theme);
|
|
236
|
+
}
|
|
180
237
|
getOrCreateLineCache(file) {
|
|
181
|
-
this.invalidateChangedUnkeyedFile(file);
|
|
182
238
|
let { lineCache } = this;
|
|
183
239
|
if (lineCache == null || !isLineCacheForFile(lineCache, file)) lineCache = {
|
|
184
240
|
cacheKey: file.cacheKey,
|
|
@@ -195,14 +251,15 @@ var FileRenderer = class {
|
|
|
195
251
|
}
|
|
196
252
|
updateRenderCache(dirtyLines, themeType, lineCountChangeInFlight = false) {
|
|
197
253
|
this.pendingStructuralRows = void 0;
|
|
198
|
-
|
|
199
|
-
|
|
254
|
+
const { renderCache } = this;
|
|
255
|
+
if (renderCache == null) return;
|
|
256
|
+
const { file, result } = renderCache;
|
|
200
257
|
if (result == null) return;
|
|
201
258
|
const pendingStructuralRows = lineCountChangeInFlight ? /* @__PURE__ */ new Map() : void 0;
|
|
202
259
|
this.pendingStructuralRows = pendingStructuralRows;
|
|
203
260
|
const lineCache = this.lineCache != null && isLineCacheForFile(this.lineCache, file) ? this.lineCache : void 0;
|
|
204
261
|
for (const [line, tokens] of dirtyLines) {
|
|
205
|
-
if (pendingStructuralRows
|
|
262
|
+
if (pendingStructuralRows == null && lineCache != null && line < lineCache.lines.length) {
|
|
206
263
|
const lineText = tokens.map((token) => token[2]).join("");
|
|
207
264
|
lineCache.lines[line] = applyLineTextWithNewline(lineCache.lines[line] ?? "", lineText);
|
|
208
265
|
}
|
|
@@ -241,17 +298,21 @@ var FileRenderer = class {
|
|
|
241
298
|
};
|
|
242
299
|
})
|
|
243
300
|
};
|
|
244
|
-
if (pendingStructuralRows
|
|
301
|
+
if (pendingStructuralRows != null) pendingStructuralRows.set(line, row);
|
|
245
302
|
else result.code[line] = row;
|
|
246
303
|
}
|
|
247
304
|
result.baseThemeType = themeType;
|
|
248
|
-
|
|
305
|
+
renderCache.isDirty = true;
|
|
306
|
+
if (pendingStructuralRows == null && lineCache != null) {
|
|
307
|
+
file.contents = lineCache.lines.join("");
|
|
308
|
+
lineCache.sourceContents = file.contents;
|
|
309
|
+
}
|
|
249
310
|
}
|
|
250
311
|
applyDocumentChange(textDocument) {
|
|
251
|
-
const pendingStructuralRows = this
|
|
312
|
+
const { pendingStructuralRows, renderCache } = this;
|
|
252
313
|
this.pendingStructuralRows = void 0;
|
|
253
|
-
if (
|
|
254
|
-
const { file, result } =
|
|
314
|
+
if (renderCache == null) return;
|
|
315
|
+
const { file, result } = renderCache;
|
|
255
316
|
if (result == null) return;
|
|
256
317
|
const previousLines = this.lineCache != null && isLineCacheForFile(this.lineCache, file) ? this.lineCache.lines : linesFromFileContents(file.contents);
|
|
257
318
|
const nextLines = linesFromFileContents(textDocument.getText());
|
|
@@ -293,7 +354,7 @@ var FileRenderer = class {
|
|
|
293
354
|
line.properties["data-line-index"] = i;
|
|
294
355
|
}
|
|
295
356
|
}
|
|
296
|
-
|
|
357
|
+
renderCache.isDirty = true;
|
|
297
358
|
}
|
|
298
359
|
this.lineCache = {
|
|
299
360
|
cacheKey: file.cacheKey,
|
|
@@ -302,24 +363,22 @@ var FileRenderer = class {
|
|
|
302
363
|
lines: nextLines
|
|
303
364
|
};
|
|
304
365
|
this.textDocumentCache.set(file, textDocument);
|
|
366
|
+
file.contents = textDocument.getText();
|
|
305
367
|
}
|
|
306
|
-
renderFile(file = this.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
this.lineCache = void 0;
|
|
312
|
-
this.textDocumentCache = /* @__PURE__ */ new WeakMap();
|
|
368
|
+
renderFile(file = this.file, renderRange = DEFAULT_RENDER_RANGE) {
|
|
369
|
+
this.file = file;
|
|
370
|
+
if (file == null) {
|
|
371
|
+
this.pendingHighlightResult = void 0;
|
|
372
|
+
return;
|
|
313
373
|
}
|
|
314
374
|
let { options, forceHighlight } = this.getRenderOptions(file);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (
|
|
375
|
+
const readyResult = this.getReadyRenderResult(file, options);
|
|
376
|
+
this.pendingHighlightResult = void 0;
|
|
377
|
+
if (readyResult != null) {
|
|
318
378
|
this.renderCache = {
|
|
379
|
+
...readyResult,
|
|
319
380
|
file,
|
|
320
|
-
|
|
321
|
-
renderRange: void 0,
|
|
322
|
-
...cache
|
|
381
|
+
renderRange: void 0
|
|
323
382
|
};
|
|
324
383
|
forceHighlight = false;
|
|
325
384
|
}
|
|
@@ -333,10 +392,12 @@ var FileRenderer = class {
|
|
|
333
392
|
const lines = this.getOrCreateLineCache(file);
|
|
334
393
|
const hasContent = file.contents.length > 0;
|
|
335
394
|
const forcePlainText = !hasContent || isFilePlainText(file) || isFileMassive(lines.length, this.getTokenizeMaxLength());
|
|
336
|
-
const
|
|
395
|
+
const canRenderFile = this.canRenderFile(file, options, forcePlainText);
|
|
396
|
+
const newContent = !areFileTargetsEqual(file, this.renderCache.file);
|
|
337
397
|
const newRenderRange = !areRenderRangesEqual(this.renderCache.renderRange, renderRange);
|
|
338
398
|
if (!this.editSessionActive && this.workerManager?.isWorkingPool() === true) {
|
|
339
|
-
|
|
399
|
+
const preserveHydratedContent = this.renderCache.result == null && this.renderCache.highlighted && !forcePlainText && !newContent && isDefaultRenderRange(renderRange);
|
|
400
|
+
if (canRenderFile && !preserveHydratedContent && (forcePlainText || this.renderCache.result == null || !this.renderCache.highlighted && (newContent || newRenderRange))) {
|
|
340
401
|
this.renderCache.file = file;
|
|
341
402
|
this.renderCache.options = options;
|
|
342
403
|
this.renderCache.highlighted = false;
|
|
@@ -346,10 +407,11 @@ var FileRenderer = class {
|
|
|
346
407
|
if (!forcePlainText && hasContent && (!this.renderCache.highlighted || forceHighlight)) this.workerManager.highlightFileAST(this, file);
|
|
347
408
|
} else {
|
|
348
409
|
this.computedLang = file.lang ?? getFiletypeFromFileName(file.name);
|
|
410
|
+
this.highlighter ??= getHighlighterIfLoaded();
|
|
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);
|