@pierre/diffs 1.3.0-beta.4 → 1.3.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +6 -6
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +1 -0
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +26 -12
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +1 -0
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +12 -11
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.js +4 -2
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +5 -1
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +82 -21
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +6 -1
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +77 -15
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/editor/command.d.ts +1 -1
- package/dist/editor/command.d.ts.map +1 -1
- package/dist/editor/command.js +3 -3
- package/dist/editor/command.js.map +1 -1
- package/dist/editor/editor.d.ts +31 -5
- package/dist/editor/editor.d.ts.map +1 -1
- package/dist/editor/editor.js +240 -178
- package/dist/editor/editor.js.map +1 -1
- package/dist/editor/editor2.js +1 -1
- package/dist/editor/editor2.js.map +1 -1
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/marker.d.ts +2 -2
- package/dist/editor/marker.d.ts.map +1 -1
- package/dist/editor/marker.js +2 -2
- package/dist/editor/marker.js.map +1 -1
- package/dist/editor/pieceTable.d.ts +6 -1
- package/dist/editor/pieceTable.d.ts.map +1 -1
- package/dist/editor/pieceTable.js +32 -1
- package/dist/editor/pieceTable.js.map +1 -1
- package/dist/editor/searchPanel.d.ts +12 -3
- package/dist/editor/searchPanel.d.ts.map +1 -1
- package/dist/editor/searchPanel.js +168 -54
- package/dist/editor/searchPanel.js.map +1 -1
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/sprite.d.ts +2 -2
- package/dist/editor/sprite.d.ts.map +1 -1
- package/dist/editor/sprite.js +10 -3
- package/dist/editor/sprite.js.map +1 -1
- package/dist/editor/textMeasure.d.ts +1 -0
- package/dist/editor/textMeasure.d.ts.map +1 -1
- package/dist/editor/textMeasure.js +6 -0
- package/dist/editor/textMeasure.js.map +1 -1
- package/dist/editor/tokenzier.js +9 -6
- package/dist/editor/tokenzier.js.map +1 -1
- package/dist/managers/InteractionManager.js +1 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.js +1 -1
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/react/CodeView.js +1 -1
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +3 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +49 -2
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.js +12 -0
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/FileDiffReact.js +1 -1
- package/dist/types.d.ts +17 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/includesFileAnnotations.d.ts +17 -0
- package/dist/utils/includesFileAnnotations.d.ts.map +1 -0
- package/dist/utils/includesFileAnnotations.js +19 -0
- package/dist/utils/includesFileAnnotations.js.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +4 -2
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +4 -2
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/worker/{wasm-BaDzIkIn.js → wasm-qE0LgnY3.js} +2 -2
- package/dist/worker/{wasm-BaDzIkIn.js.map → wasm-qE0LgnY3.js.map} +1 -1
- package/dist/worker/worker-portable.js +289 -253
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +8 -4
- package/dist/worker/worker.js.map +1 -1
- package/package.json +4 -10
|
@@ -102,14 +102,16 @@ var FileStream = class {
|
|
|
102
102
|
highlighter,
|
|
103
103
|
allowRecalls: true,
|
|
104
104
|
defaultColor: false,
|
|
105
|
-
cssVariablePrefix: formatCSSVariablePrefix("token")
|
|
105
|
+
cssVariablePrefix: formatCSSVariablePrefix("token"),
|
|
106
|
+
tokenizeTimeLimit: 0
|
|
106
107
|
}) : new CodeToTokenTransformStream({
|
|
107
108
|
...this.options,
|
|
108
109
|
themes: theme,
|
|
109
110
|
highlighter,
|
|
110
111
|
allowRecalls: true,
|
|
111
112
|
defaultColor: false,
|
|
112
|
-
cssVariablePrefix: formatCSSVariablePrefix("token")
|
|
113
|
+
cssVariablePrefix: formatCSSVariablePrefix("token"),
|
|
114
|
+
tokenizeTimeLimit: 0
|
|
113
115
|
})).pipeTo(new WritableStream({
|
|
114
116
|
start(controller) {
|
|
115
117
|
onStreamStart?.(controller);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileStream.js","names":["options: FileStreamOptions"],"sources":["../../src/components/FileStream.ts"],"sourcesContent":["import { DEFAULT_THEMES, DIFFS_TAG_NAME } from '../constants';\nimport { getSharedHighlighter } from '../highlighter/shared_highlighter';\nimport { queueRender } from '../managers/UniversalRenderingManager';\nimport { CodeToTokenTransformStream, type RecallToken } from '../shiki-stream';\nimport type {\n AppliedThemeStyleCache,\n BaseCodeOptions,\n DiffsHighlighter,\n SupportedLanguages,\n ThemedToken,\n ThemeTypes,\n} from '../types';\nimport { createSpanFromToken } from '../utils/createSpanNodeFromToken';\nimport { wrapThemeCSS } from '../utils/cssWrappers';\nimport { formatCSSVariablePrefix } from '../utils/formatCSSVariablePrefix';\nimport { getHighlighterOptions } from '../utils/getHighlighterOptions';\nimport { getHighlighterThemeStyles } from '../utils/getHighlighterThemeStyles';\nimport { getOrCreateCodeNode } from '../utils/getOrCreateCodeNode';\nimport { upsertHostThemeStyle } from '../utils/hostTheme';\nimport { getMeasuredScrollbarGutter } from '../utils/scrollbarGutter';\nimport { setPreNodeProperties } from '../utils/setWrapperNodeProps';\n\nexport interface FileStreamOptions extends BaseCodeOptions {\n lang?: SupportedLanguages;\n startingLineIndex?: number;\n\n onPreRender?(instance: FileStream): unknown;\n onPostRender?(instance: FileStream): unknown;\n\n onStreamStart?(controller: WritableStreamDefaultController): unknown;\n onStreamWrite?(token: ThemedToken | RecallToken): unknown;\n onStreamClose?(): unknown;\n onStreamAbort?(reason: unknown): unknown;\n}\n\nlet instanceId = -1;\n\nexport class FileStream {\n readonly __id: string = `file-stream:${++instanceId}`;\n\n private highlighter: DiffsHighlighter | undefined;\n private stream: ReadableStream<string> | undefined;\n private abortController: AbortController | undefined;\n private fileContainer: HTMLElement | undefined;\n private pre: HTMLPreElement | undefined;\n private code: HTMLElement | undefined;\n private gutterElement: HTMLElement | undefined;\n private contentElement: HTMLElement | undefined;\n private themeCSSStyle: HTMLStyleElement | undefined;\n private appliedThemeCSS: AppliedThemeStyleCache | undefined;\n private currentRowCount = 0;\n\n constructor(public options: FileStreamOptions = { theme: DEFAULT_THEMES }) {\n this.currentLineIndex = this.options.startingLineIndex ?? 1;\n }\n\n cleanUp(): void {\n this.abortController?.abort();\n this.abortController = undefined;\n }\n\n setThemeType(themeType: ThemeTypes): void {\n if ((this.options.themeType ?? 'system') === themeType) {\n return;\n }\n this.options = { ...this.options, themeType };\n if (\n typeof this.options.theme === 'string' ||\n this.fileContainer == null ||\n this.appliedThemeCSS == null\n ) {\n return;\n }\n this.applyThemeState(\n this.fileContainer,\n this.appliedThemeCSS.themeStyles,\n themeType,\n this.appliedThemeCSS.baseThemeType\n );\n }\n\n private async initializeHighlighter(): Promise<DiffsHighlighter> {\n this.highlighter = await getSharedHighlighter(\n getHighlighterOptions(this.options.lang, this.options)\n );\n return this.highlighter;\n }\n\n private queuedSetupArgs: [ReadableStream<string>, HTMLElement] | undefined;\n async setup(\n _source: ReadableStream<string>,\n _wrapper: HTMLElement\n ): Promise<void> {\n const isSettingUp = this.queuedSetupArgs != null;\n this.queuedSetupArgs = [_source, _wrapper];\n if (isSettingUp) {\n // TODO(amadeus): Make it so that this function can be properly\n // awaitable, maybe?\n return;\n }\n this.highlighter ??= await this.initializeHighlighter();\n\n const [source, wrapper] = this.queuedSetupArgs;\n this.queuedSetupArgs = undefined;\n\n const stream = source;\n\n this.setupStream(stream, wrapper, this.highlighter);\n }\n\n private setupStream(\n stream: ReadableStream<string>,\n wrapper: HTMLElement,\n highlighter: DiffsHighlighter\n ): void {\n const {\n disableLineNumbers = false,\n overflow = 'scroll',\n theme = DEFAULT_THEMES,\n themeType = 'system',\n } = this.options;\n const fileContainer = this.getOrCreateFileContainer();\n if (fileContainer.parentElement == null) {\n wrapper.appendChild(fileContainer);\n }\n this.pre ??= document.createElement('pre');\n if (this.pre.parentElement == null) {\n fileContainer.shadowRoot?.appendChild(this.pre);\n }\n const baseThemeType =\n typeof theme === 'string' ? highlighter.getTheme(theme).type : undefined;\n const themeStyles = getHighlighterThemeStyles({ theme, highlighter });\n this.applyThemeState(fileContainer, themeStyles, themeType, baseThemeType);\n const pre = setPreNodeProperties(this.pre, {\n type: 'file',\n diffIndicators: 'none',\n disableBackground: true,\n disableLineNumbers,\n overflow,\n split: false,\n totalLines: 0,\n });\n pre.textContent = '';\n\n this.pre = pre;\n this.code = getOrCreateCodeNode({ code: this.code, pre });\n this.gutterElement = undefined;\n this.contentElement = undefined;\n this.currentRowCount = 0;\n this.currentLineElement = undefined;\n this.currentLineIndex = this.options.startingLineIndex ?? 1;\n this.abortController?.abort();\n this.abortController = new AbortController();\n const { onStreamStart, onStreamClose, onStreamAbort } = this.options;\n // Cancel the prior source so upstream producers stop generating tokens.\n // Swallow AbortError / locked-stream rejections since we're tearing down.\n this.stream?.cancel().catch(() => {});\n this.stream = stream;\n this.stream\n .pipeThrough(\n typeof theme === 'string'\n ? new CodeToTokenTransformStream({\n ...this.options,\n theme,\n highlighter,\n allowRecalls: true,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n })\n : new CodeToTokenTransformStream({\n ...this.options,\n themes: theme,\n highlighter,\n allowRecalls: true,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n })\n )\n .pipeTo(\n new WritableStream({\n start(controller) {\n onStreamStart?.(controller);\n },\n close() {\n onStreamClose?.();\n },\n abort(reason) {\n onStreamAbort?.(reason);\n },\n write: this.handleWrite,\n }),\n { signal: this.abortController.signal }\n )\n .catch((error) => {\n // Ignore AbortError - it's expected when cleaning up\n if (error.name !== 'AbortError') {\n console.error('FileStream pipe error:', error);\n }\n });\n }\n\n private queuedTokens: (ThemedToken | RecallToken)[] = [];\n private handleWrite = (token: ThemedToken | RecallToken) => {\n // If we've recalled tokens we haven't rendered yet, we can just yeet them\n // and never apply them\n if ('recall' in token && this.queuedTokens.length >= token.recall) {\n this.queuedTokens.length = this.queuedTokens.length - token.recall;\n } else {\n this.queuedTokens.push(token);\n }\n queueRender(this.render);\n this.options.onStreamWrite?.(token);\n };\n\n private currentLineIndex: number;\n private currentLineElement: HTMLElement | undefined;\n private render = () => {\n this.options.onPreRender?.(this);\n const { gutter, content } = this.getOrCreateStreamColumns();\n const gutterFragment = document.createDocumentFragment();\n const contentFragment = document.createDocumentFragment();\n for (const token of this.queuedTokens) {\n if ('recall' in token) {\n if (this.currentLineElement == null) {\n throw new Error(\n 'FileStream.render: no current line element, shouldnt be possible to get here'\n );\n }\n if (token.recall > this.currentLineElement.childNodes.length) {\n throw new Error(\n `FileStream.render: Token recall exceed the current line, there's probably a bug...`\n );\n }\n for (let i = 0; i < token.recall; i++) {\n this.currentLineElement.lastChild?.remove();\n }\n } else {\n const span = createSpanFromToken(token);\n if (this.currentLineElement == null) {\n const { gutterLine, contentLine } = this.createLine();\n gutterFragment.appendChild(gutterLine);\n contentFragment.appendChild(contentLine);\n }\n this.currentLineElement?.appendChild(span);\n if (token.content === '\\n') {\n this.currentLineIndex++;\n const { gutterLine, contentLine } = this.createLine();\n gutterFragment.appendChild(gutterLine);\n contentFragment.appendChild(contentLine);\n }\n }\n }\n if (gutterFragment.childNodes.length > 0) {\n gutter.appendChild(gutterFragment);\n }\n if (contentFragment.childNodes.length > 0) {\n content.appendChild(contentFragment);\n }\n this.queuedTokens.length = 0;\n this.options.onPostRender?.(this);\n };\n\n private getOrCreateStreamColumns(): {\n gutter: HTMLElement;\n content: HTMLElement;\n } {\n if (this.code == null) {\n throw new Error('FileStream: expected code element to exist');\n }\n if (this.gutterElement != null && this.contentElement != null) {\n return { gutter: this.gutterElement, content: this.contentElement };\n }\n const gutter = document.createElement('div');\n gutter.dataset.gutter = '';\n const content = document.createElement('div');\n content.dataset.content = '';\n this.code.appendChild(gutter);\n this.code.appendChild(content);\n this.gutterElement = gutter;\n this.contentElement = content;\n return { gutter, content };\n }\n\n private updateRowSpan(): void {\n if (this.gutterElement != null) {\n this.gutterElement.style.gridRow = `span ${this.currentRowCount}`;\n }\n if (this.contentElement != null) {\n this.contentElement.style.gridRow = `span ${this.currentRowCount}`;\n }\n }\n\n private createLine(): { gutterLine: HTMLElement; contentLine: HTMLElement } {\n const lineNumber = this.currentLineIndex;\n const lineIndex = `${lineNumber - 1}`;\n const gutterLine = document.createElement('div');\n gutterLine.dataset.columnNumber = `${lineNumber}`;\n gutterLine.dataset.lineType = 'context';\n gutterLine.dataset.lineIndex = lineIndex;\n\n const numberContent = document.createElement('span');\n numberContent.dataset.lineNumberContent = '';\n numberContent.textContent = `${lineNumber}`;\n gutterLine.appendChild(numberContent);\n\n const contentLine = document.createElement('div');\n contentLine.dataset.line = `${lineNumber}`;\n contentLine.dataset.lineType = 'context';\n contentLine.dataset.lineIndex = lineIndex;\n\n this.currentRowCount += 1;\n this.updateRowSpan();\n this.currentLineElement = contentLine;\n return { gutterLine, contentLine };\n }\n\n private getOrCreateFileContainer(fileContainer?: HTMLElement): HTMLElement {\n if (\n (fileContainer != null && fileContainer === this.fileContainer) ||\n (fileContainer == null && this.fileContainer != null)\n ) {\n return this.fileContainer;\n }\n if (\n this.fileContainer != null &&\n fileContainer != null &&\n fileContainer !== this.fileContainer\n ) {\n this.themeCSSStyle = undefined;\n this.appliedThemeCSS = undefined;\n }\n this.fileContainer =\n fileContainer ?? document.createElement(DIFFS_TAG_NAME);\n return this.fileContainer;\n }\n\n private applyThemeState(\n container: HTMLElement,\n themeStyles: string,\n themeType: ThemeTypes,\n baseThemeType?: 'light' | 'dark'\n ): void {\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const effectiveThemeType = baseThemeType ?? themeType;\n const currentTheme = this.options.theme ?? DEFAULT_THEMES;\n const theme =\n typeof currentTheme === 'string' ? currentTheme : { ...currentTheme };\n const scrollbarGutter = getMeasuredScrollbarGutter(shadowRoot);\n if (\n this.themeCSSStyle?.parentNode === shadowRoot &&\n this.appliedThemeCSS?.themeStyles === themeStyles &&\n this.appliedThemeCSS.themeType === effectiveThemeType &&\n this.appliedThemeCSS.scrollbarGutter === scrollbarGutter\n ) {\n this.appliedThemeCSS.theme = theme;\n return;\n }\n this.themeCSSStyle = upsertHostThemeStyle({\n shadowRoot,\n currentNode: this.themeCSSStyle,\n themeCSS: wrapThemeCSS(themeStyles, effectiveThemeType, scrollbarGutter),\n });\n this.appliedThemeCSS =\n this.themeCSSStyle != null\n ? {\n theme,\n themeStyles,\n themeType: effectiveThemeType,\n baseThemeType,\n scrollbarGutter,\n }\n : undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmCA,IAAI,aAAa;AAEjB,IAAa,aAAb,MAAwB;CACtB,AAAS,O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,yBAAyB,eAA0C;AACzE,MACG,iBAAiB,QAAQ,kBAAkB,KAAK,iBAChD,iBAAiB,QAAQ,KAAK,iBAAiB,KAEhD,QAAO,KAAK;AAEd,MACE,KAAK,iBAAiB,QACtB,iBAAiB,QACjB,kBAAkB,KAAK,eACvB;AACA,QAAK,gBAAgB;AACrB,QAAK,kBAAkB;;AAEzB,OAAK,gBACH,iBAAiB,SAAS,cAAc,eAAe;AACzD,SAAO,KAAK;;CAGd,AAAQ,gBACN,WACA,aACA,WACA,eACM;EACN,MAAM,aACJ,UAAU,cAAc,UAAU,aAAa,EAAE,MAAM,QAAQ,CAAC;EAClE,MAAM,qBAAqB,iBAAiB;EAC5C,MAAM,eAAe,KAAK,QAAQ,SAAS;EAC3C,MAAM,QACJ,OAAO,iBAAiB,WAAW,eAAe,EAAE,GAAG,cAAc;EACvE,MAAM,kBAAkB,2BAA2B,WAAW;AAC9D,MACE,KAAK,eAAe,eAAe,cACnC,KAAK,iBAAiB,gBAAgB,eACtC,KAAK,gBAAgB,cAAc,sBACnC,KAAK,gBAAgB,oBAAoB,iBACzC;AACA,QAAK,gBAAgB,QAAQ;AAC7B;;AAEF,OAAK,gBAAgB,qBAAqB;GACxC;GACA,aAAa,KAAK;GAClB,UAAU,aAAa,aAAa,oBAAoB,gBAAgB;GACzE,CAAC;AACF,OAAK,kBACH,KAAK,iBAAiB,OAClB;GACE;GACA;GACA,WAAW;GACX;GACA;GACD,GACD"}
|
|
1
|
+
{"version":3,"file":"FileStream.js","names":["options: FileStreamOptions"],"sources":["../../src/components/FileStream.ts"],"sourcesContent":["import { DEFAULT_THEMES, DIFFS_TAG_NAME } from '../constants';\nimport { getSharedHighlighter } from '../highlighter/shared_highlighter';\nimport { queueRender } from '../managers/UniversalRenderingManager';\nimport { CodeToTokenTransformStream, type RecallToken } from '../shiki-stream';\nimport type {\n AppliedThemeStyleCache,\n BaseCodeOptions,\n DiffsHighlighter,\n SupportedLanguages,\n ThemedToken,\n ThemeTypes,\n} from '../types';\nimport { createSpanFromToken } from '../utils/createSpanNodeFromToken';\nimport { wrapThemeCSS } from '../utils/cssWrappers';\nimport { formatCSSVariablePrefix } from '../utils/formatCSSVariablePrefix';\nimport { getHighlighterOptions } from '../utils/getHighlighterOptions';\nimport { getHighlighterThemeStyles } from '../utils/getHighlighterThemeStyles';\nimport { getOrCreateCodeNode } from '../utils/getOrCreateCodeNode';\nimport { upsertHostThemeStyle } from '../utils/hostTheme';\nimport { getMeasuredScrollbarGutter } from '../utils/scrollbarGutter';\nimport { setPreNodeProperties } from '../utils/setWrapperNodeProps';\n\nexport interface FileStreamOptions extends BaseCodeOptions {\n lang?: SupportedLanguages;\n startingLineIndex?: number;\n\n onPreRender?(instance: FileStream): unknown;\n onPostRender?(instance: FileStream): unknown;\n\n onStreamStart?(controller: WritableStreamDefaultController): unknown;\n onStreamWrite?(token: ThemedToken | RecallToken): unknown;\n onStreamClose?(): unknown;\n onStreamAbort?(reason: unknown): unknown;\n}\n\nlet instanceId = -1;\n\nexport class FileStream {\n readonly __id: string = `file-stream:${++instanceId}`;\n\n private highlighter: DiffsHighlighter | undefined;\n private stream: ReadableStream<string> | undefined;\n private abortController: AbortController | undefined;\n private fileContainer: HTMLElement | undefined;\n private pre: HTMLPreElement | undefined;\n private code: HTMLElement | undefined;\n private gutterElement: HTMLElement | undefined;\n private contentElement: HTMLElement | undefined;\n private themeCSSStyle: HTMLStyleElement | undefined;\n private appliedThemeCSS: AppliedThemeStyleCache | undefined;\n private currentRowCount = 0;\n\n constructor(public options: FileStreamOptions = { theme: DEFAULT_THEMES }) {\n this.currentLineIndex = this.options.startingLineIndex ?? 1;\n }\n\n cleanUp(): void {\n this.abortController?.abort();\n this.abortController = undefined;\n }\n\n setThemeType(themeType: ThemeTypes): void {\n if ((this.options.themeType ?? 'system') === themeType) {\n return;\n }\n this.options = { ...this.options, themeType };\n if (\n typeof this.options.theme === 'string' ||\n this.fileContainer == null ||\n this.appliedThemeCSS == null\n ) {\n return;\n }\n this.applyThemeState(\n this.fileContainer,\n this.appliedThemeCSS.themeStyles,\n themeType,\n this.appliedThemeCSS.baseThemeType\n );\n }\n\n private async initializeHighlighter(): Promise<DiffsHighlighter> {\n this.highlighter = await getSharedHighlighter(\n getHighlighterOptions(this.options.lang, this.options)\n );\n return this.highlighter;\n }\n\n private queuedSetupArgs: [ReadableStream<string>, HTMLElement] | undefined;\n async setup(\n _source: ReadableStream<string>,\n _wrapper: HTMLElement\n ): Promise<void> {\n const isSettingUp = this.queuedSetupArgs != null;\n this.queuedSetupArgs = [_source, _wrapper];\n if (isSettingUp) {\n // TODO(amadeus): Make it so that this function can be properly\n // awaitable, maybe?\n return;\n }\n this.highlighter ??= await this.initializeHighlighter();\n\n const [source, wrapper] = this.queuedSetupArgs;\n this.queuedSetupArgs = undefined;\n\n const stream = source;\n\n this.setupStream(stream, wrapper, this.highlighter);\n }\n\n private setupStream(\n stream: ReadableStream<string>,\n wrapper: HTMLElement,\n highlighter: DiffsHighlighter\n ): void {\n const {\n disableLineNumbers = false,\n overflow = 'scroll',\n theme = DEFAULT_THEMES,\n themeType = 'system',\n } = this.options;\n const fileContainer = this.getOrCreateFileContainer();\n if (fileContainer.parentElement == null) {\n wrapper.appendChild(fileContainer);\n }\n this.pre ??= document.createElement('pre');\n if (this.pre.parentElement == null) {\n fileContainer.shadowRoot?.appendChild(this.pre);\n }\n const baseThemeType =\n typeof theme === 'string' ? highlighter.getTheme(theme).type : undefined;\n const themeStyles = getHighlighterThemeStyles({ theme, highlighter });\n this.applyThemeState(fileContainer, themeStyles, themeType, baseThemeType);\n const pre = setPreNodeProperties(this.pre, {\n type: 'file',\n diffIndicators: 'none',\n disableBackground: true,\n disableLineNumbers,\n overflow,\n split: false,\n totalLines: 0,\n });\n pre.textContent = '';\n\n this.pre = pre;\n this.code = getOrCreateCodeNode({ code: this.code, pre });\n this.gutterElement = undefined;\n this.contentElement = undefined;\n this.currentRowCount = 0;\n this.currentLineElement = undefined;\n this.currentLineIndex = this.options.startingLineIndex ?? 1;\n this.abortController?.abort();\n this.abortController = new AbortController();\n const { onStreamStart, onStreamClose, onStreamAbort } = this.options;\n // Cancel the prior source so upstream producers stop generating tokens.\n // Swallow AbortError / locked-stream rejections since we're tearing down.\n this.stream?.cancel().catch(() => {});\n this.stream = stream;\n this.stream\n // tokenizeTimeLimit: 0 — never trade silently-wrong token colors for\n // latency; see renderFileWithHighlighter for the full rationale.\n .pipeThrough(\n typeof theme === 'string'\n ? new CodeToTokenTransformStream({\n ...this.options,\n theme,\n highlighter,\n allowRecalls: true,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n tokenizeTimeLimit: 0,\n })\n : new CodeToTokenTransformStream({\n ...this.options,\n themes: theme,\n highlighter,\n allowRecalls: true,\n defaultColor: false,\n cssVariablePrefix: formatCSSVariablePrefix('token'),\n tokenizeTimeLimit: 0,\n })\n )\n .pipeTo(\n new WritableStream({\n start(controller) {\n onStreamStart?.(controller);\n },\n close() {\n onStreamClose?.();\n },\n abort(reason) {\n onStreamAbort?.(reason);\n },\n write: this.handleWrite,\n }),\n { signal: this.abortController.signal }\n )\n .catch((error) => {\n // Ignore AbortError - it's expected when cleaning up\n if (error.name !== 'AbortError') {\n console.error('FileStream pipe error:', error);\n }\n });\n }\n\n private queuedTokens: (ThemedToken | RecallToken)[] = [];\n private handleWrite = (token: ThemedToken | RecallToken) => {\n // If we've recalled tokens we haven't rendered yet, we can just yeet them\n // and never apply them\n if ('recall' in token && this.queuedTokens.length >= token.recall) {\n this.queuedTokens.length = this.queuedTokens.length - token.recall;\n } else {\n this.queuedTokens.push(token);\n }\n queueRender(this.render);\n this.options.onStreamWrite?.(token);\n };\n\n private currentLineIndex: number;\n private currentLineElement: HTMLElement | undefined;\n private render = () => {\n this.options.onPreRender?.(this);\n const { gutter, content } = this.getOrCreateStreamColumns();\n const gutterFragment = document.createDocumentFragment();\n const contentFragment = document.createDocumentFragment();\n for (const token of this.queuedTokens) {\n if ('recall' in token) {\n if (this.currentLineElement == null) {\n throw new Error(\n 'FileStream.render: no current line element, shouldnt be possible to get here'\n );\n }\n if (token.recall > this.currentLineElement.childNodes.length) {\n throw new Error(\n `FileStream.render: Token recall exceed the current line, there's probably a bug...`\n );\n }\n for (let i = 0; i < token.recall; i++) {\n this.currentLineElement.lastChild?.remove();\n }\n } else {\n const span = createSpanFromToken(token);\n if (this.currentLineElement == null) {\n const { gutterLine, contentLine } = this.createLine();\n gutterFragment.appendChild(gutterLine);\n contentFragment.appendChild(contentLine);\n }\n this.currentLineElement?.appendChild(span);\n if (token.content === '\\n') {\n this.currentLineIndex++;\n const { gutterLine, contentLine } = this.createLine();\n gutterFragment.appendChild(gutterLine);\n contentFragment.appendChild(contentLine);\n }\n }\n }\n if (gutterFragment.childNodes.length > 0) {\n gutter.appendChild(gutterFragment);\n }\n if (contentFragment.childNodes.length > 0) {\n content.appendChild(contentFragment);\n }\n this.queuedTokens.length = 0;\n this.options.onPostRender?.(this);\n };\n\n private getOrCreateStreamColumns(): {\n gutter: HTMLElement;\n content: HTMLElement;\n } {\n if (this.code == null) {\n throw new Error('FileStream: expected code element to exist');\n }\n if (this.gutterElement != null && this.contentElement != null) {\n return { gutter: this.gutterElement, content: this.contentElement };\n }\n const gutter = document.createElement('div');\n gutter.dataset.gutter = '';\n const content = document.createElement('div');\n content.dataset.content = '';\n this.code.appendChild(gutter);\n this.code.appendChild(content);\n this.gutterElement = gutter;\n this.contentElement = content;\n return { gutter, content };\n }\n\n private updateRowSpan(): void {\n if (this.gutterElement != null) {\n this.gutterElement.style.gridRow = `span ${this.currentRowCount}`;\n }\n if (this.contentElement != null) {\n this.contentElement.style.gridRow = `span ${this.currentRowCount}`;\n }\n }\n\n private createLine(): { gutterLine: HTMLElement; contentLine: HTMLElement } {\n const lineNumber = this.currentLineIndex;\n const lineIndex = `${lineNumber - 1}`;\n const gutterLine = document.createElement('div');\n gutterLine.dataset.columnNumber = `${lineNumber}`;\n gutterLine.dataset.lineType = 'context';\n gutterLine.dataset.lineIndex = lineIndex;\n\n const numberContent = document.createElement('span');\n numberContent.dataset.lineNumberContent = '';\n numberContent.textContent = `${lineNumber}`;\n gutterLine.appendChild(numberContent);\n\n const contentLine = document.createElement('div');\n contentLine.dataset.line = `${lineNumber}`;\n contentLine.dataset.lineType = 'context';\n contentLine.dataset.lineIndex = lineIndex;\n\n this.currentRowCount += 1;\n this.updateRowSpan();\n this.currentLineElement = contentLine;\n return { gutterLine, contentLine };\n }\n\n private getOrCreateFileContainer(fileContainer?: HTMLElement): HTMLElement {\n if (\n (fileContainer != null && fileContainer === this.fileContainer) ||\n (fileContainer == null && this.fileContainer != null)\n ) {\n return this.fileContainer;\n }\n if (\n this.fileContainer != null &&\n fileContainer != null &&\n fileContainer !== this.fileContainer\n ) {\n this.themeCSSStyle = undefined;\n this.appliedThemeCSS = undefined;\n }\n this.fileContainer =\n fileContainer ?? document.createElement(DIFFS_TAG_NAME);\n return this.fileContainer;\n }\n\n private applyThemeState(\n container: HTMLElement,\n themeStyles: string,\n themeType: ThemeTypes,\n baseThemeType?: 'light' | 'dark'\n ): void {\n const shadowRoot =\n container.shadowRoot ?? container.attachShadow({ mode: 'open' });\n const effectiveThemeType = baseThemeType ?? themeType;\n const currentTheme = this.options.theme ?? DEFAULT_THEMES;\n const theme =\n typeof currentTheme === 'string' ? currentTheme : { ...currentTheme };\n const scrollbarGutter = getMeasuredScrollbarGutter(shadowRoot);\n if (\n this.themeCSSStyle?.parentNode === shadowRoot &&\n this.appliedThemeCSS?.themeStyles === themeStyles &&\n this.appliedThemeCSS.themeType === effectiveThemeType &&\n this.appliedThemeCSS.scrollbarGutter === scrollbarGutter\n ) {\n this.appliedThemeCSS.theme = theme;\n return;\n }\n this.themeCSSStyle = upsertHostThemeStyle({\n shadowRoot,\n currentNode: this.themeCSSStyle,\n themeCSS: wrapThemeCSS(themeStyles, effectiveThemeType, scrollbarGutter),\n });\n this.appliedThemeCSS =\n this.themeCSSStyle != null\n ? {\n theme,\n themeStyles,\n them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AAQ,OAAO,GAAG;AAC9B,cAAY,QAAQ,WAAW;AAC/B,cAAY,QAAQ,YAAY;AAEhC,OAAK,mBAAmB;AACxB,OAAK,eAAe;AACpB,OAAK,qBAAqB;AAC1B,SAAO;GAAE;GAAY;GAAa;;CAGpC,AAAQ,yBAAyB,eAA0C;AACzE,MACG,iBAAiB,QAAQ,kBAAkB,KAAK,iBAChD,iBAAiB,QAAQ,KAAK,iBAAiB,KAEhD,QAAO,KAAK;AAEd,MACE,KAAK,iBAAiB,QACtB,iBAAiB,QACjB,kBAAkB,KAAK,eACvB;AACA,QAAK,gBAAgB;AACrB,QAAK,kBAAkB;;AAEzB,OAAK,gBACH,iBAAiB,SAAS,cAAc,eAAe;AACzD,SAAO,KAAK;;CAGd,AAAQ,gBACN,WACA,aACA,WACA,eACM;EACN,MAAM,aACJ,UAAU,cAAc,UAAU,aAAa,EAAE,MAAM,QAAQ,CAAC;EAClE,MAAM,qBAAqB,iBAAiB;EAC5C,MAAM,eAAe,KAAK,QAAQ,SAAS;EAC3C,MAAM,QACJ,OAAO,iBAAiB,WAAW,eAAe,EAAE,GAAG,cAAc;EACvE,MAAM,kBAAkB,2BAA2B,WAAW;AAC9D,MACE,KAAK,eAAe,eAAe,cACnC,KAAK,iBAAiB,gBAAgB,eACtC,KAAK,gBAAgB,cAAc,sBACnC,KAAK,gBAAgB,oBAAoB,iBACzC;AACA,QAAK,gBAAgB,QAAQ;AAC7B;;AAEF,OAAK,gBAAgB,qBAAqB;GACxC;GACA,aAAa,KAAK;GAClB,UAAU,aAAa,aAAa,oBAAoB,gBAAgB;GACzE,CAAC;AACF,OAAK,kBACH,KAAK,iBAAiB,OAClB;GACE;GACA;GACA,WAAW;GACX;GACA;GACD,GACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictMarkerRow","MergeConflictResolution","PostRenderPhase","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, PostRenderPhase } 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' | 'onPostRender'> {\n onPostRender?(node: HTMLElement, instance: UnresolvedFile<LAnnotation>, phase: PostRenderPhase): 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 readonly type = \"unresolved-file\";\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":";;;;;;;;;KAMYc,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,EAAA,KAAA,EAG6CP,eAH7C,CAAA,EAAA,OAAA;EAAyBC,wBAAAA,CAAAA,EAIhCU,8BAJgCV,CAIDM,WAJCN,CAAAA;EAAkDM,qBAAAA,EAAAA,OAAAA,EAK7EV,0BAL6EU,EAAAA,QAAAA,EAKvCC,cALuCD,CAKxBA,WALwBA,CAAAA,CAAAA,EAAAA,IAAAA;EAAfC,sBAAAA,EAAAA,IAAAA,EAMhEb,YANgEa,EAAAA,OAAAA,EAMzCX,0BANyCW,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,EASDhB,YATCgB;EACKC,OAAAA,CAAAA,EAAAA,CASFX,uBATuBM,GAAAA,
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.d.ts","names":["HunksRenderResult","UnresolvedFileHunksRenderer","UnresolvedFileHunksRendererOptions","FileContents","FileDiffMetadata","MergeConflictActionPayload","MergeConflictMarkerRow","MergeConflictResolution","PostRenderPhase","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, PostRenderPhase } 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' | 'onPostRender'> {\n onPostRender?(node: HTMLElement, instance: UnresolvedFile<LAnnotation>, phase: PostRenderPhase): 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 readonly type = \"unresolved-file\";\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>, baseOpt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A;EACrBZ,UAAAA,uBAAAA,CAAAA,OAAAA,EAuBqCiB,qBAvBrCjB,CAuB2DY,WAvB3DZ,CAAAA,CAAAA,EAuB0ED,kCAvB1EC;EACIC,UAAAA,sBAAAA,CAAAA,GAAAA,EAuB4BuB,cAvB5BvB,EAAAA,MAAAA,EAuBoDJ,iBAvBpDI,CAAAA,EAAAA,IAAAA;EACAK,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EACEH,QAAAA,gBAAAA;EAAsB,OAAA,CAAA,KAAA,EAwBnBiB,4BAxBmB,CAwBUR,WAxBV,CAAA,CAAA,EAAA,IAAA;EAE5BU,QAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EACAtB,MAAAA,CAAAA,KAAAA,CAAAA,EAuBSmB,yBAvBTnB,CAuBmCY,WAvBnCZ,CAAAA,CAAAA,EAAAA,OAAAA;EACIC,eAAAA,CAAAA,aAAAA,EAAAA,MAAAA,EAAAA,UAAAA,EAuByCG,uBAvBzCH,EAAAA,QAAAA,CAAAA,EAuB6EA,gBAvB7EA,GAAAA,SAAAA,CAAAA,EAuB4GqB,qBAvB5GrB,GAAAA,SAAAA;EACAK,QAAAA,wBAAAA;EACEH,QAAAA,2BAAAA;EAAsB,QAAA,8BAAA;EAEjCoB,QAAAA,8BAAuB;EACPV,QAAAA,yBAAcD;EAA2CA,QAAAA,6BAAAA;;AACjEK,iBAyBWQ,qCAzBXR,CAAAA,WAAAA,CAAAA,CAAAA,OAAAA,CAAAA,EAyBwEA,qBAzBxEA,CAyB8FL,WAzB9FK,CAAAA,EAAAA,WAAAA,CAAAA,EAyB0HA,qBAzB1HA,CAyBgJL,WAzBhJK,CAAAA,CAAAA,EAyB+JlB,kCAzB/JkB"}
|
|
@@ -20,13 +20,16 @@ declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation>
|
|
|
20
20
|
private currentCollapsed;
|
|
21
21
|
constructor(options: FileOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: VirtualFileMetrics, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);
|
|
22
22
|
setMetrics(metrics: VirtualFileMetrics, force?: boolean): void;
|
|
23
|
+
setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;
|
|
24
|
+
private syncLineAnnotations;
|
|
25
|
+
private hasLineAnnotations;
|
|
23
26
|
getLineHeight(lineIndex: number, hasMetadataLine?: boolean): number;
|
|
24
27
|
setOptions(options: FileOptions<LAnnotation> | undefined): void;
|
|
25
28
|
setThemeType(themeType: ThemeTypes): void;
|
|
26
29
|
private resetLayoutCache;
|
|
27
30
|
reconcileHeights(): boolean;
|
|
28
31
|
onRender: (dirty: boolean) => boolean;
|
|
29
|
-
prepareCodeViewItem(file: FileContents, top: number, reset?: PendingCodeViewLayoutReset): number;
|
|
32
|
+
prepareCodeViewItem(file: FileContents, top: number, reset?: PendingCodeViewLayoutReset, lineAnnotations?: LineAnnotation<LAnnotation>[]): number;
|
|
30
33
|
getLinePosition(lineNumber: number): {
|
|
31
34
|
top: number;
|
|
32
35
|
height: number;
|
|
@@ -43,6 +46,7 @@ declare class VirtualizedFile<LAnnotation = undefined> extends File<LAnnotation>
|
|
|
43
46
|
fileContainer,
|
|
44
47
|
file,
|
|
45
48
|
forceRender,
|
|
49
|
+
lineAnnotations,
|
|
46
50
|
...props
|
|
47
51
|
}: FileRenderProps<LAnnotation>): boolean;
|
|
48
52
|
syncVirtualizedTop(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualizedFile.d.ts","names":["DiffsTextDocument","FileContents","LineAnnotation","NumericScrollLineAnchor","PendingCodeViewLayoutReset","RenderWindow","StickySpecs","ThemeTypes","VirtualFileMetrics","WorkerPoolManager","CodeView","File","FileOptions","FileRenderProps","Virtualizer","VirtualizedFile","LAnnotation","fileContainer","file","forceRender"],"sources":["../../src/components/VirtualizedFile.d.ts"],"sourcesContent":["import type { DiffsTextDocument, FileContents, LineAnnotation, NumericScrollLineAnchor, PendingCodeViewLayoutReset, RenderWindow, StickySpecs, ThemeTypes, 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 layoutDirty;\n private forceRenderOverride;\n private currentCollapsed;\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 setThemeType(themeType: ThemeTypes): void;\n private resetLayoutCache;\n reconcileHeights(): boolean;\n onRender: (dirty: boolean) => boolean;\n prepareCodeViewItem(file: FileContents, top: number, reset?: PendingCodeViewLayoutReset): number;\n getLinePosition(lineNumber: number): {\n top: number;\n height: number;\n } | undefined;\n getNumericScrollAnchor(localViewportTop: number): NumericScrollLineAnchor | undefined;\n getVirtualizedHeight(): number;\n getAdvancedStickySpecs(windowSpecs?: RenderWindow): StickySpecs | undefined;\n cleanUp(recycle?: boolean): void;\n private computeApproximateSize;\n setVisibility(visible: boolean): void;\n rerender(): void;\n applyDocumentChange(textDocument: DiffsTextDocument, newLineAnnotations?: LineAnnotation<LAnnotation>[], shouldUpdateBuffer?: boolean): 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":";;;;;;;;cAKqBe,iDAAiDJ,KAAKK;;;EAAtDD,SAAAA,IAAAA,EAAAA,MAAe;EAAuCC,GAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAYtCA,MAAAA,EAAAA,MAAAA;EAAZJ,QAAAA,KAAAA;EAAmDE,QAAAA,SAAAA;EAAuBE,QAAAA,OAAAA;EAATN,QAAAA,WAAAA;EAAiCF,QAAAA,mBAAAA;EAAoCC,QAAAA,gBAAAA;EACvID,WAAAA,CAAAA,OAAAA,EADCI,WACDJ,CADaQ,WACbR,CAAAA,GAAAA,SAAAA,EAAAA,WAAAA,EADoDM,WACpDN,GADkEE,QAClEF,CAD2EQ,WAC3ER,CAAAA,EAAAA,OAAAA,CAAAA,EADmGA,kBACnGA,EAAAA,aAAAA,CAAAA,EADuIC,iBACvID,EAAAA,kBAAAA,CAAAA,EAAAA,OAAAA;
|
|
1
|
+
{"version":3,"file":"VirtualizedFile.d.ts","names":["DiffsTextDocument","FileContents","LineAnnotation","NumericScrollLineAnchor","PendingCodeViewLayoutReset","RenderWindow","StickySpecs","ThemeTypes","VirtualFileMetrics","WorkerPoolManager","CodeView","File","FileOptions","FileRenderProps","Virtualizer","VirtualizedFile","LAnnotation","fileContainer","file","forceRender","lineAnnotations"],"sources":["../../src/components/VirtualizedFile.d.ts"],"sourcesContent":["import type { DiffsTextDocument, FileContents, LineAnnotation, NumericScrollLineAnchor, PendingCodeViewLayoutReset, RenderWindow, StickySpecs, ThemeTypes, 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 layoutDirty;\n private forceRenderOverride;\n private currentCollapsed;\n constructor(options: FileOptions<LAnnotation> | undefined, virtualizer: Virtualizer | CodeView<LAnnotation>, metrics?: VirtualFileMetrics, workerManager?: WorkerPoolManager, isContainerManaged?: boolean);\n setMetrics(metrics: VirtualFileMetrics, force?: boolean): void;\n setLineAnnotations(lineAnnotations: LineAnnotation<LAnnotation>[]): void;\n private syncLineAnnotations;\n private hasLineAnnotations;\n getLineHeight(lineIndex: number, hasMetadataLine?: boolean): number;\n setOptions(options: FileOptions<LAnnotation> | undefined): void;\n setThemeType(themeType: ThemeTypes): void;\n private resetLayoutCache;\n reconcileHeights(): boolean;\n onRender: (dirty: boolean) => boolean;\n prepareCodeViewItem(file: FileContents, top: number, reset?: PendingCodeViewLayoutReset, lineAnnotations?: LineAnnotation<LAnnotation>[]): number;\n getLinePosition(lineNumber: number): {\n top: number;\n height: number;\n } | undefined;\n getNumericScrollAnchor(localViewportTop: number): NumericScrollLineAnchor | undefined;\n getVirtualizedHeight(): number;\n getAdvancedStickySpecs(windowSpecs?: RenderWindow): StickySpecs | undefined;\n cleanUp(recycle?: boolean): void;\n private computeApproximateSize;\n setVisibility(visible: boolean): void;\n rerender(): void;\n applyDocumentChange(textDocument: DiffsTextDocument, newLineAnnotations?: LineAnnotation<LAnnotation>[], shouldUpdateBuffer?: boolean): void;\n render({ fileContainer, file, forceRender, lineAnnotations, ...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":";;;;;;;;cAKqBe,iDAA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AAA,EAAAA,MAAAA,EAAAA,KAAAA,CAAAA,EAPwBD,0BAOxBC,EAAAA,eAAAA,CAAAA,EAPsEH,cAOtEG,CAPqFW,WAOrFX,CAAAA,EAAAA,CAAAA,EAAAA,MAAAA;EAAeC,eAAAA,CAAAA,UAAAA,EAAAA,MAAAA,CAAAA,EAAAA;IAKlBN,GAAAA,EAAAA,MAAAA;IAAuDgB,MAAAA,EAAAA,MAAAA;EAAfd,CAAAA,GAAAA,SAAAA;EACjEe,sBAAAA,CAAAA,gBAAAA,EAAAA,MAAAA,CAAAA,EARyCd,uBAQzCc,GAAAA,SAAAA;EAAeC,oBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAMC,sBAAAA,CAAAA,WAAAA,CAAAA,EANOd,YAMPc,CAAAA,EANsBb,WAMtBa,GAAAA,SAAAA;EAAaC,OAAAA,CAAAA,OAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EAA6CJ,QAAAA,sBAAAA;EAAhBH,aAAAA,CAAAA,OAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA;EApCNF,QAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAAI,mBAAA,CAAA,YAAA,EAmCpCX,iBAnCoC,EAAA,kBAAA,CAAA,EAmCIE,cAnCJ,CAmCmBc,WAnCnB,CAAA,EAAA,EAAA,kBAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;;;;;;;KAoCEH,gBAAgBG"}
|
|
@@ -3,6 +3,7 @@ import { areObjectsEqual } from "../utils/areObjectsEqual.js";
|
|
|
3
3
|
import { areOptionsEqual } from "../utils/areOptionsEqual.js";
|
|
4
4
|
import { areFilesEqual } from "../utils/areFilesEqual.js";
|
|
5
5
|
import { getVirtualFileHeaderRegion, getVirtualFilePaddingBottom } from "../utils/computeVirtualFileMetrics.js";
|
|
6
|
+
import { FILE_ANNOTATION_DOM_KEY, FILE_ANNOTATION_LINE_NUMBER, includesFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
|
|
6
7
|
import { File } from "./File.js";
|
|
7
8
|
|
|
8
9
|
//#region src/components/VirtualizedFile.ts
|
|
@@ -17,7 +18,8 @@ var VirtualizedFile = class extends File {
|
|
|
17
18
|
height = 0;
|
|
18
19
|
cache = {
|
|
19
20
|
heights: /* @__PURE__ */ new Map(),
|
|
20
|
-
checkpoints: []
|
|
21
|
+
checkpoints: [],
|
|
22
|
+
fileAnnotationHeight: 0
|
|
21
23
|
};
|
|
22
24
|
isVisible = false;
|
|
23
25
|
isSetup = false;
|
|
@@ -34,6 +36,18 @@ var VirtualizedFile = class extends File {
|
|
|
34
36
|
this.metrics = metrics;
|
|
35
37
|
this.resetLayoutCache();
|
|
36
38
|
}
|
|
39
|
+
setLineAnnotations(lineAnnotations) {
|
|
40
|
+
if (this.syncLineAnnotations(lineAnnotations)) this.resetLayoutCache();
|
|
41
|
+
}
|
|
42
|
+
syncLineAnnotations(lineAnnotations) {
|
|
43
|
+
if (lineAnnotations == null || lineAnnotations === this.lineAnnotations) return false;
|
|
44
|
+
if (lineAnnotations.length === 0 && this.lineAnnotations.length === 0) return false;
|
|
45
|
+
super.setLineAnnotations(lineAnnotations);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
hasLineAnnotations() {
|
|
49
|
+
return this.lineAnnotations.some((annotation) => annotation.lineNumber > FILE_ANNOTATION_LINE_NUMBER);
|
|
50
|
+
}
|
|
37
51
|
getLineHeight(lineIndex, hasMetadataLine = false) {
|
|
38
52
|
const cached = this.cache.heights.get(lineIndex);
|
|
39
53
|
if (cached != null) return cached;
|
|
@@ -57,6 +71,7 @@ var VirtualizedFile = class extends File {
|
|
|
57
71
|
}
|
|
58
72
|
resetLayoutCache(recompute = false) {
|
|
59
73
|
this.layoutDirty = true;
|
|
74
|
+
this.cache.fileAnnotationHeight = 0;
|
|
60
75
|
if (this.cache.heights.size > 0) this.cache.heights.clear();
|
|
61
76
|
if (this.cache.checkpoints.length > 0) this.cache.checkpoints.length = 0;
|
|
62
77
|
if (this.renderRange != null) this.renderRange = void 0;
|
|
@@ -75,6 +90,17 @@ var VirtualizedFile = class extends File {
|
|
|
75
90
|
if (this.code == null) return hasHeightChange;
|
|
76
91
|
const content = this.code.children[1];
|
|
77
92
|
if (!(content instanceof HTMLElement)) return hasHeightChange;
|
|
93
|
+
const hasFileAnnotations = includesFileAnnotations(this.lineAnnotations);
|
|
94
|
+
if (this.renderRange != null && hasFileAnnotations && shouldRenderFileAnnotations(this.renderRange)) {
|
|
95
|
+
const nextFileAnnotationHeight = measureFileAnnotationHeight(content) ?? 0;
|
|
96
|
+
if (nextFileAnnotationHeight !== this.cache.fileAnnotationHeight) {
|
|
97
|
+
this.cache.fileAnnotationHeight = nextFileAnnotationHeight;
|
|
98
|
+
hasHeightChange = true;
|
|
99
|
+
}
|
|
100
|
+
} else if (!hasFileAnnotations && this.cache.fileAnnotationHeight !== 0) {
|
|
101
|
+
this.cache.fileAnnotationHeight = 0;
|
|
102
|
+
hasHeightChange = true;
|
|
103
|
+
}
|
|
78
104
|
for (const line of content.children) {
|
|
79
105
|
if (!(line instanceof HTMLElement)) continue;
|
|
80
106
|
const lineIndexAttr = line.dataset.lineIndex;
|
|
@@ -100,8 +126,9 @@ var VirtualizedFile = class extends File {
|
|
|
100
126
|
if (dirty) this.top = this.getVirtualizedTop();
|
|
101
127
|
return this.render({ file: this.file });
|
|
102
128
|
};
|
|
103
|
-
prepareCodeViewItem(file, top, reset) {
|
|
104
|
-
|
|
129
|
+
prepareCodeViewItem(file, top, reset, lineAnnotations) {
|
|
130
|
+
const annotationsChanged = this.syncLineAnnotations(lineAnnotations);
|
|
131
|
+
let shouldResetLayoutCache = reset?.resetFileLayoutCache === true || annotationsChanged;
|
|
105
132
|
if (reset?.metrics != null) {
|
|
106
133
|
this.metrics = reset.metrics;
|
|
107
134
|
shouldResetLayoutCache = true;
|
|
@@ -119,7 +146,7 @@ var VirtualizedFile = class extends File {
|
|
|
119
146
|
return this.height;
|
|
120
147
|
}
|
|
121
148
|
getLinePosition(lineNumber) {
|
|
122
|
-
if (this.file == null) return;
|
|
149
|
+
if (this.file == null || lineNumber < 1) return;
|
|
123
150
|
const { disableFileHeader = false, collapsed = false } = this.options;
|
|
124
151
|
const lastLineIndex = this.fileRenderer.getLineCount(this.file) - 1;
|
|
125
152
|
let top = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
@@ -130,7 +157,8 @@ var VirtualizedFile = class extends File {
|
|
|
130
157
|
const clampedLineIndex = Math.min(Math.max(lineNumber - 1, 0), lastLineIndex);
|
|
131
158
|
const { overflow = "scroll" } = this.options;
|
|
132
159
|
const { lineHeight } = this.metrics;
|
|
133
|
-
|
|
160
|
+
top += this.cache.fileAnnotationHeight;
|
|
161
|
+
if (overflow === "scroll" && !this.hasLineAnnotations()) return {
|
|
134
162
|
top: top + clampedLineIndex * lineHeight,
|
|
135
163
|
height: lineHeight
|
|
136
164
|
};
|
|
@@ -152,17 +180,18 @@ var VirtualizedFile = class extends File {
|
|
|
152
180
|
const firstRenderedLineIndex = Math.min(this.renderRange.startingLine, lastLineIndex);
|
|
153
181
|
const lastRenderedLineIndex = Math.min(firstRenderedLineIndex + this.renderRange.totalLines - 1, lastLineIndex);
|
|
154
182
|
if (lastRenderedLineIndex < firstRenderedLineIndex) return;
|
|
155
|
-
|
|
183
|
+
const { fileAnnotationHeight } = this.cache;
|
|
184
|
+
if (overflow === "scroll" && !this.hasLineAnnotations()) {
|
|
156
185
|
const { lineHeight } = this.metrics;
|
|
157
|
-
const firstRenderedLineTop = headerRegion + this.renderRange.bufferBefore;
|
|
186
|
+
const firstRenderedLineTop = headerRegion + (firstRenderedLineIndex === 0 ? fileAnnotationHeight : this.renderRange.bufferBefore);
|
|
158
187
|
const lineIndex = firstRenderedLineIndex + Math.max(Math.ceil((localViewportTop - firstRenderedLineTop) / lineHeight), 0);
|
|
159
188
|
if (lineIndex > lastRenderedLineIndex) return;
|
|
160
189
|
return {
|
|
161
190
|
lineNumber: lineIndex + 1,
|
|
162
|
-
top: headerRegion + lineIndex * lineHeight
|
|
191
|
+
top: headerRegion + fileAnnotationHeight + lineIndex * lineHeight
|
|
163
192
|
};
|
|
164
193
|
}
|
|
165
|
-
let top = headerRegion + this.renderRange.bufferBefore;
|
|
194
|
+
let top = headerRegion + (firstRenderedLineIndex === 0 ? fileAnnotationHeight : this.renderRange.bufferBefore);
|
|
166
195
|
for (let lineIndex = firstRenderedLineIndex; lineIndex <= lastRenderedLineIndex; lineIndex++) {
|
|
167
196
|
if (top >= localViewportTop) return {
|
|
168
197
|
lineNumber: lineIndex + 1,
|
|
@@ -195,7 +224,7 @@ var VirtualizedFile = class extends File {
|
|
|
195
224
|
}
|
|
196
225
|
cleanUp(recycle = false) {
|
|
197
226
|
if (this.fileContainer != null && this.isSimpleMode()) this.getSimpleVirtualizer()?.disconnect(this.fileContainer);
|
|
198
|
-
if (!recycle) this.
|
|
227
|
+
if (!recycle) this.resetLayoutCache();
|
|
199
228
|
this.isSetup = false;
|
|
200
229
|
super.cleanUp(recycle);
|
|
201
230
|
}
|
|
@@ -219,7 +248,8 @@ var VirtualizedFile = class extends File {
|
|
|
219
248
|
this.layoutDirty = false;
|
|
220
249
|
return;
|
|
221
250
|
}
|
|
222
|
-
|
|
251
|
+
this.height += this.cache.fileAnnotationHeight;
|
|
252
|
+
if (overflow === "scroll" && !this.hasLineAnnotations()) this.height += lineCount * lineHeight;
|
|
223
253
|
else for (let lineIndex = 0; lineIndex < lineCount; lineIndex++) {
|
|
224
254
|
this.addLayoutCheckpoint(lineIndex, this.height);
|
|
225
255
|
this.height += this.getLineHeight(lineIndex, false);
|
|
@@ -266,10 +296,12 @@ var VirtualizedFile = class extends File {
|
|
|
266
296
|
if (renderRange.bufferAfter !== previousRenderRange.bufferAfter) this.updateBuffers(renderRange);
|
|
267
297
|
}
|
|
268
298
|
}
|
|
269
|
-
render({ fileContainer, file, forceRender = false,...props }) {
|
|
299
|
+
render({ fileContainer, file, forceRender = false, lineAnnotations,...props }) {
|
|
270
300
|
const didFileChange = this.file == null || !areFilesEqual(this.file, file);
|
|
271
301
|
const { forceRenderOverride, isSetup } = this;
|
|
272
302
|
this.forceRenderOverride = void 0;
|
|
303
|
+
const annotationsChanged = this.syncLineAnnotations(lineAnnotations);
|
|
304
|
+
if (annotationsChanged) this.resetLayoutCache();
|
|
273
305
|
this.file = file;
|
|
274
306
|
fileContainer = this.getOrCreateFileContainerNode(fileContainer);
|
|
275
307
|
if (this.file == null) {
|
|
@@ -302,7 +334,8 @@ var VirtualizedFile = class extends File {
|
|
|
302
334
|
file: this.file,
|
|
303
335
|
fileContainer,
|
|
304
336
|
renderRange,
|
|
305
|
-
|
|
337
|
+
lineAnnotations,
|
|
338
|
+
forceRender: (forceRenderOverride ?? forceRender) || annotationsChanged,
|
|
306
339
|
...props
|
|
307
340
|
});
|
|
308
341
|
}
|
|
@@ -378,6 +411,12 @@ var VirtualizedFile = class extends File {
|
|
|
378
411
|
const fileHeight = this.height;
|
|
379
412
|
const headerRegion = getVirtualFileHeaderRegion(this.metrics, disableFileHeader);
|
|
380
413
|
const paddingBottom = lineCount > 0 ? getVirtualFilePaddingBottom(this.metrics) : 0;
|
|
414
|
+
const { fileAnnotationHeight } = this.cache;
|
|
415
|
+
const codeRegionTop = headerRegion + fileAnnotationHeight;
|
|
416
|
+
const codeRowsHeight = Math.max(0, fileHeight - headerRegion - fileAnnotationHeight - paddingBottom);
|
|
417
|
+
const hasFileAnnotations = includesFileAnnotations(this.lineAnnotations);
|
|
418
|
+
const fileAnnotationTop = fileTop + headerRegion;
|
|
419
|
+
const measuredFileAnnotationVisible = fileAnnotationHeight > 0 && hasFileAnnotations && fileAnnotationTop < bottom && fileAnnotationTop + fileAnnotationHeight > top;
|
|
381
420
|
if (fileTop < top - fileHeight || fileTop > bottom) return {
|
|
382
421
|
startingLine: 0,
|
|
383
422
|
totalLines: 0,
|
|
@@ -394,13 +433,21 @@ var VirtualizedFile = class extends File {
|
|
|
394
433
|
const totalLines = Math.ceil(estimatedTargetLines / hunkLineCount) * hunkLineCount + hunkLineCount * 2;
|
|
395
434
|
const totalHunks = totalLines / hunkLineCount;
|
|
396
435
|
const viewportCenter = (top + bottom) / 2;
|
|
397
|
-
if (overflow === "scroll" && this.
|
|
398
|
-
const
|
|
436
|
+
if (overflow === "scroll" && !this.hasLineAnnotations()) {
|
|
437
|
+
const sourceRowsTop = fileTop + codeRegionTop;
|
|
438
|
+
const sourceRowsBottom = sourceRowsTop + codeRowsHeight;
|
|
439
|
+
if (!measuredFileAnnotationVisible && !(sourceRowsTop < bottom && sourceRowsBottom > top)) return {
|
|
440
|
+
startingLine: 0,
|
|
441
|
+
totalLines: 0,
|
|
442
|
+
bufferBefore: 0,
|
|
443
|
+
bufferAfter: fileHeight - headerRegion - paddingBottom
|
|
444
|
+
};
|
|
445
|
+
const centerLine = Math.floor(measuredFileAnnotationVisible && viewportCenter < fileTop + codeRegionTop ? 0 : (viewportCenter - (fileTop + codeRegionTop)) / lineHeight);
|
|
399
446
|
const idealStartHunk$1 = Math.floor(centerLine / hunkLineCount) - Math.floor(totalHunks / 2);
|
|
400
447
|
const totalHunksInFile = Math.ceil(lineCount / hunkLineCount);
|
|
401
448
|
const startingLine$1 = Math.max(0, Math.min(idealStartHunk$1, totalHunksInFile)) * hunkLineCount;
|
|
402
449
|
const clampedTotalLines$1 = idealStartHunk$1 < 0 ? totalLines + idealStartHunk$1 * hunkLineCount : totalLines;
|
|
403
|
-
const bufferBefore$1 = startingLine$1 * lineHeight;
|
|
450
|
+
const bufferBefore$1 = startingLine$1 === 0 ? 0 : fileAnnotationHeight + startingLine$1 * lineHeight;
|
|
404
451
|
const renderedLines = Math.min(clampedTotalLines$1, lineCount - startingLine$1);
|
|
405
452
|
return {
|
|
406
453
|
startingLine: startingLine$1,
|
|
@@ -412,7 +459,7 @@ var VirtualizedFile = class extends File {
|
|
|
412
459
|
const overflowHunks = totalHunks;
|
|
413
460
|
const hunkOffsets = [];
|
|
414
461
|
const checkpoint = this.getLayoutCheckpointBeforeTop(Math.max(0, top - fileTop - totalLines * lineHeight * 2), hunkLineCount);
|
|
415
|
-
let absoluteLineTop = fileTop + (checkpoint?.top ??
|
|
462
|
+
let absoluteLineTop = fileTop + (checkpoint?.top ?? codeRegionTop);
|
|
416
463
|
let currentLine = checkpoint?.lineIndex ?? 0;
|
|
417
464
|
let firstVisibleHunk;
|
|
418
465
|
let centerHunk;
|
|
@@ -422,7 +469,7 @@ var VirtualizedFile = class extends File {
|
|
|
422
469
|
const isAtHunkBoundary = currentLine % hunkLineCount === 0;
|
|
423
470
|
const currentHunk = Math.floor(currentLine / hunkLineCount);
|
|
424
471
|
if (isAtHunkBoundary) {
|
|
425
|
-
hunkOffsets[currentHunk] = absoluteLineTop - (fileTop +
|
|
472
|
+
hunkOffsets[currentHunk] = absoluteLineTop - (fileTop + codeRegionTop);
|
|
426
473
|
if (overflowCounter != null) {
|
|
427
474
|
if (overflowCounter <= 0) break;
|
|
428
475
|
overflowCounter--;
|
|
@@ -435,7 +482,10 @@ var VirtualizedFile = class extends File {
|
|
|
435
482
|
currentLine++;
|
|
436
483
|
absoluteLineTop += lineHeight$1;
|
|
437
484
|
}
|
|
438
|
-
if (firstVisibleHunk == null)
|
|
485
|
+
if (firstVisibleHunk == null) if (measuredFileAnnotationVisible) {
|
|
486
|
+
firstVisibleHunk = 0;
|
|
487
|
+
centerHunk = 0;
|
|
488
|
+
} else return {
|
|
439
489
|
startingLine: 0,
|
|
440
490
|
totalLines: 0,
|
|
441
491
|
bufferBefore: 0,
|
|
@@ -447,16 +497,27 @@ var VirtualizedFile = class extends File {
|
|
|
447
497
|
const startHunk = Math.max(0, Math.min(idealStartHunk, maxStartHunk));
|
|
448
498
|
const startingLine = startHunk * hunkLineCount;
|
|
449
499
|
const clampedTotalLines = idealStartHunk < 0 ? totalLines + idealStartHunk * hunkLineCount : totalLines;
|
|
450
|
-
const
|
|
500
|
+
const codeBufferBefore = hunkOffsets[startHunk] ?? 0;
|
|
501
|
+
const bufferBefore = startingLine === 0 ? 0 : fileAnnotationHeight + codeBufferBefore;
|
|
451
502
|
const finalHunkIndex = startHunk + clampedTotalLines / hunkLineCount;
|
|
503
|
+
const bufferAfter = finalHunkIndex < hunkOffsets.length ? codeRowsHeight - hunkOffsets[finalHunkIndex] : codeRowsHeight - (absoluteLineTop - fileTop - codeRegionTop);
|
|
452
504
|
return {
|
|
453
505
|
startingLine,
|
|
454
506
|
totalLines: clampedTotalLines,
|
|
455
507
|
bufferBefore,
|
|
456
|
-
bufferAfter:
|
|
508
|
+
bufferAfter: Math.max(0, bufferAfter)
|
|
457
509
|
};
|
|
458
510
|
}
|
|
459
511
|
};
|
|
512
|
+
function measureFileAnnotationHeight(content) {
|
|
513
|
+
let height;
|
|
514
|
+
for (const child of content.children) {
|
|
515
|
+
if (!(child instanceof HTMLElement)) continue;
|
|
516
|
+
if (child.dataset.lineAnnotation !== FILE_ANNOTATION_DOM_KEY) continue;
|
|
517
|
+
height = Math.max(height ?? 0, child.getBoundingClientRect().height);
|
|
518
|
+
}
|
|
519
|
+
return height;
|
|
520
|
+
}
|
|
460
521
|
|
|
461
522
|
//#endregion
|
|
462
523
|
export { VirtualizedFile };
|