@pierre/diffs 1.1.2 → 1.1.3
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/File.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +18 -9
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +155 -52
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +5 -4
- package/dist/react/UnresolvedFile.d.ts +3 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/utils/renderDiffChildren.d.ts +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +6 -4
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +3 -2
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +15 -12
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +15 -7
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +9 -7
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +11 -16
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +68 -75
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +4 -3
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +41 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.d.ts +3 -2
- package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.js +24 -89
- package/dist/utils/diffAcceptRejectHunk.js.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.d.ts +4 -6
- package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.js +2 -2
- package/dist/utils/getMergeConflictActionSlotName.js.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.d.ts +1 -2
- package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.js +7 -12
- package/dist/utils/getMergeConflictLineTypes.js.map +1 -1
- package/dist/utils/normalizeDiffResolution.d.ts +7 -0
- package/dist/utils/normalizeDiffResolution.d.ts.map +1 -0
- package/dist/utils/normalizeDiffResolution.js +11 -0
- package/dist/utils/normalizeDiffResolution.js.map +1 -0
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts +16 -12
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.js +474 -117
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/resolveConflict.d.ts +7 -0
- package/dist/utils/resolveConflict.d.ts.map +1 -0
- package/dist/utils/resolveConflict.js +23 -0
- package/dist/utils/resolveConflict.js.map +1 -0
- package/dist/utils/resolveRegion.d.ts +14 -0
- package/dist/utils/resolveRegion.d.ts.map +1 -0
- package/dist/utils/resolveRegion.js +215 -0
- package/dist/utils/resolveRegion.js.map +1 -0
- package/dist/utils/trimPatchContext.js +19 -20
- package/dist/utils/trimPatchContext.js.map +1 -1
- package/dist/worker/worker-portable.js +4 -0
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js.map +1 -1
- package/package.json +2 -1
- package/dist/utils/resolveMergeConflict.d.ts +0 -7
- package/dist/utils/resolveMergeConflict.d.ts.map +0 -1
- package/dist/utils/resolveMergeConflict.js +0 -30
- package/dist/utils/resolveMergeConflict.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.js","names":["options: UnresolvedFileOptions<LAnnotation>","payload: MergeConflictActionPayload"],"sources":["../../src/components/UnresolvedFile.ts"],"sourcesContent":["import { DEFAULT_THEMES } from '../constants';\nimport type { MergeConflictActionTarget } from '../managers/InteractionManager';\nimport { pluckInteractionOptions } from '../managers/InteractionManager';\nimport type { HunksRenderResult } from '../renderers/DiffHunksRenderer';\nimport {\n UnresolvedFileHunksRenderer,\n type UnresolvedFileHunksRendererOptions,\n} from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictResolution,\n} from '../types';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areMergeConflictActionsEqual } from '../utils/areMergeConflictActionsEqual';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { getMergeConflictActionSlotName } from '../utils/getMergeConflictActionSlotName';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport { resolveMergeConflict } from '../utils/resolveMergeConflict';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderProps,\n} from './FileDiff';\n\nexport type RenderMergeConflictActions<LAnnotation> = (\n action: MergeConflictDiffAction,\n instance: UnresolvedFile<LAnnotation>\n) => HTMLElement | DocumentFragment | null | undefined;\n\nexport type MergeConflictActionsTypeOption<LAnnotation> =\n | 'none'\n | 'default'\n | RenderMergeConflictActions<LAnnotation>;\n\nexport interface UnresolvedFileOptions<\n LAnnotation,\n> extends FileDiffOptions<LAnnotation> {\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFile<LAnnotation>\n ): unknown;\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ): void;\n onMergeConflictResolve?(\n file: FileContents,\n payload: MergeConflictActionPayload\n ): void;\n}\n\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'oldFile' | 'newFile'\n> {\n file?: FileContents;\n actions?: MergeConflictDiffAction[];\n}\n\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<\n UnresolvedFileRenderProps<LAnnotation>,\n 'file'\n> {\n file?: FileContents;\n fileDiff?: FileDiffMetadata;\n actions?: MergeConflictDiffAction[];\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\n\ninterface MergeConflictActionElementCache {\n element: HTMLElement;\n action: MergeConflictDiffAction;\n}\n\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: MergeConflictDiffAction[] | undefined;\n}\n\ninterface GetOrComputeDiffResult {\n fileDiff: FileDiffMetadata;\n actions: MergeConflictDiffAction[];\n}\n\ntype UnresolvedFileDataCache = GetOrComputeDiffProps;\n\nlet instanceId = -1;\n\nexport class UnresolvedFile<\n LAnnotation = undefined,\n> extends FileDiff<LAnnotation> {\n override readonly __id: string = `unresolved-file:${++instanceId}`;\n protected computedCache: UnresolvedFileDataCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n };\n private conflictActions: MergeConflictDiffAction[] = [];\n private conflictActionCache: Map<string, MergeConflictActionElementCache> =\n new Map();\n\n constructor(\n public override options: UnresolvedFileOptions<LAnnotation> = {\n theme: DEFAULT_THEMES,\n },\n workerManager?: WorkerPoolManager | undefined,\n isContainerManaged = false\n ) {\n super(undefined, workerManager, isContainerManaged);\n this.setOptions(options);\n }\n\n override setOptions(\n options: UnresolvedFileOptions<LAnnotation> | undefined\n ): void {\n if (options == null) {\n return;\n }\n\n if (\n options.onMergeConflictAction != null &&\n options.onMergeConflictResolve != null\n ) {\n throw new Error(\n 'UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.'\n );\n }\n\n this.options = options;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n\n const hunkSeparators = this.options.hunkSeparators ?? 'line-info';\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof hunkSeparators === 'function' ||\n hunkSeparators === 'line-info' ||\n hunkSeparators === 'line-info-basic'\n ? this.expandHunk\n : undefined,\n this.getLineIndex,\n this.handleMergeConflictActionClick\n )\n );\n }\n\n protected override createHunksRenderer(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRenderer<LAnnotation> {\n const renderer = new UnresolvedFileHunksRenderer<LAnnotation>(\n this.getHunksRendererOptions(options),\n this.handleHighlightRender,\n this.workerManager\n );\n return renderer;\n }\n\n protected override getHunksRendererOptions(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRendererOptions {\n return {\n ...this.options,\n hunkSeparators:\n typeof options.hunkSeparators === 'function'\n ? 'custom'\n : options.hunkSeparators,\n mergeConflictActionsType:\n typeof options.mergeConflictActionsType === 'function'\n ? 'custom'\n : options.mergeConflictActionsType,\n };\n }\n\n protected override applyPreNodeAttributes(\n pre: HTMLPreElement,\n result: HunksRenderResult\n ): void {\n super.applyPreNodeAttributes(pre, result, {\n 'data-has-merge-conflict': '',\n });\n }\n\n override cleanUp(): void {\n this.clearMergeConflictActionCache();\n this.computedCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n };\n this.conflictActions = [];\n super.cleanUp();\n }\n\n private getOrComputeDiff({\n file,\n fileDiff,\n actions,\n }: GetOrComputeDiffProps): GetOrComputeDiffResult | undefined {\n wrapper: {\n // We are dealing with a controlled component\n if (this.options.onMergeConflictAction != null) {\n const hasFileDiff = fileDiff != null;\n const hasActions = actions != null;\n if (hasFileDiff !== hasActions) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff and actions must be passed together'\n );\n }\n // If we were provided a new fileDiff and actions, we are a FULLY\n // controlled component, which means we will not do any computation\n if (fileDiff != null && actions != null) {\n this.computedCache = {\n file: file ?? this.computedCache.file,\n fileDiff,\n actions,\n };\n break wrapper;\n }\n // If we were provided a new file, we should attempt to parse out a new\n // diff/actions if we haven't computed it before\n else if (file != null || this.computedCache.file != null) {\n file ??= this.computedCache.file;\n if (file == null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: file is null, should be impossible'\n );\n }\n if (\n !areFilesEqual(file, this.computedCache.file) ||\n this.computedCache.fileDiff == null ||\n this.computedCache.actions == null\n ) {\n const computed = parseMergeConflictDiffFromFile(file);\n this.computedCache = {\n file,\n fileDiff: computed.fileDiff,\n actions: computed.actions,\n };\n }\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n break wrapper;\n }\n // Otherwise we should fall through and try to use the cache if it exists\n else {\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n break wrapper;\n }\n }\n // If we are uncontrolled we only rely on the file and only use the first\n // version, otherwise utilize the cached version\n else {\n if (fileDiff != null || actions != null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff and actions are only usable in controlled mode, you must pass in `onMergeConflictAction`'\n );\n }\n this.computedCache.file ??= file;\n if (\n this.computedCache.fileDiff == null &&\n this.computedCache.file != null\n ) {\n const computed = parseMergeConflictDiffFromFile(\n this.computedCache.file\n );\n this.computedCache.fileDiff = computed.fileDiff;\n this.computedCache.actions = computed.actions;\n }\n // Because we are uncontrolled, the source of truth is the\n // computedCache\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n break wrapper;\n }\n }\n if (fileDiff == null || actions == null) {\n return undefined;\n }\n return { fileDiff, actions };\n }\n\n override hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void {\n const {\n file,\n fileDiff,\n actions,\n lineAnnotations,\n preventEmit = false,\n ...rest\n } = props;\n const source = this.getOrComputeDiff({ file, fileDiff, actions });\n if (source == null) {\n return;\n }\n this.setActiveMergeConflictActions(source.actions);\n super.hydrate({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n preventEmit: true,\n });\n this.renderMergeConflictActionSlots();\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n\n override rerender(): void {\n if (!this.enabled || this.fileDiff == null) {\n return;\n }\n this.render({ forceRender: true, renderRange: this.renderRange });\n }\n\n override render(props: UnresolvedFileRenderProps<LAnnotation> = {}): boolean {\n let {\n file,\n fileDiff,\n actions,\n lineAnnotations,\n preventEmit = false,\n ...rest\n } = props;\n const source = this.getOrComputeDiff({ file, fileDiff, actions });\n if (source == null) {\n return false;\n }\n this.setActiveMergeConflictActions(source.actions);\n const didRender = super.render({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n preventEmit: true,\n });\n this.renderMergeConflictActionSlots();\n if (didRender && !preventEmit) {\n this.emitPostRender();\n }\n return didRender;\n }\n\n public resolveConflict(\n conflictIndex: number,\n resolution: MergeConflictResolution,\n file: FileContents | undefined = this.computedCache.file\n ): FileContents | undefined {\n const action = this.conflictActions[conflictIndex];\n if (file == null || action == null) {\n return undefined;\n }\n\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match\"\n );\n }\n\n const contents = resolveMergeConflict(file.contents, {\n resolution,\n conflict: action.conflict,\n });\n if (contents === file.contents) {\n return undefined;\n }\n\n return {\n ...file,\n contents,\n cacheKey:\n file.cacheKey != null\n ? `${file.cacheKey}:mc-${conflictIndex}-${resolution}`\n : undefined,\n };\n }\n\n private resolveConflictAndRender(\n conflictIndex: number,\n resolution: MergeConflictResolution\n ): FileContents | undefined {\n const action = this.conflictActions[conflictIndex];\n if (action == null) {\n return undefined;\n }\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution,\n conflict: action.conflict,\n };\n const nextFile = this.resolveConflict(conflictIndex, resolution);\n if (nextFile == null) {\n return undefined;\n }\n\n this.computedCache.file = nextFile;\n // Clear out the diff cache to force a new compute next render\n this.computedCache.fileDiff = undefined;\n this.computedCache.actions = undefined;\n this.render();\n this.options.onMergeConflictResolve?.(nextFile, payload);\n return nextFile;\n }\n\n private setActiveMergeConflictActions(\n actions: MergeConflictDiffAction[]\n ): void {\n this.conflictActions = actions;\n if (this.hunksRenderer instanceof UnresolvedFileHunksRenderer) {\n this.hunksRenderer.setConflictActions(\n this.options.mergeConflictActionsType === 'none' ? [] : actions\n );\n }\n }\n\n private handleMergeConflictActionClick = (\n target: MergeConflictActionTarget\n ): void => {\n const action = this.conflictActions[target.conflictIndex];\n if (action == null) {\n return;\n }\n if (action.conflictIndex !== target.conflictIndex) {\n console.error({ conflictIndex: target.conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution: target.resolution,\n conflict: action.conflict,\n };\n if (this.options.onMergeConflictAction != null) {\n this.options.onMergeConflictAction(payload, this);\n return;\n }\n this.resolveConflictAndRender(target.conflictIndex, target.resolution);\n };\n\n private renderMergeConflictActionSlots(): void {\n if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof this.options.mergeConflictActionsType !== 'function' ||\n this.conflictActions.length === 0\n ) {\n this.clearMergeConflictActionCache();\n return;\n }\n const staleActions = new Map(this.conflictActionCache);\n for (\n let actionIndex = 0;\n actionIndex < this.conflictActions.length;\n actionIndex++\n ) {\n const action = this.conflictActions[actionIndex];\n if (action == null) {\n continue;\n }\n if (action.conflictIndex !== actionIndex) {\n console.error({ conflictIndex: actionIndex, action });\n throw new Error(\n \"UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match\"\n );\n }\n const anchor = getMergeConflictActionAnchor(action);\n if (anchor == null) {\n continue;\n }\n const conflictIndex = action.conflictIndex;\n const slotName = getMergeConflictActionSlotName({\n side: anchor.side,\n lineNumber: anchor.lineNumber,\n conflictIndex,\n });\n const id = `${actionIndex}-${slotName}`;\n let cache = this.conflictActionCache.get(id);\n if (\n cache == null ||\n !areMergeConflictActionsEqual(cache.action, action)\n ) {\n cache?.element.remove();\n const rendered = this.renderMergeConflictAction(action);\n if (rendered == null) {\n continue;\n }\n const element = createAnnotationWrapperNode(slotName);\n element.appendChild(rendered);\n this.fileContainer.appendChild(element);\n cache = { element, action };\n this.conflictActionCache.set(id, cache);\n }\n staleActions.delete(id);\n }\n for (const [id, { element }] of staleActions.entries()) {\n this.conflictActionCache.delete(id);\n element.remove();\n }\n }\n\n private renderMergeConflictAction(\n action: MergeConflictDiffAction\n ): HTMLElement | undefined {\n if (typeof this.options.mergeConflictActionsType !== 'function') {\n return undefined;\n }\n const rendered = this.options.mergeConflictActionsType(action, this);\n if (rendered == null) {\n return undefined;\n }\n if (rendered instanceof HTMLElement) {\n return rendered;\n }\n if (\n typeof DocumentFragment !== 'undefined' &&\n rendered instanceof DocumentFragment\n ) {\n const wrapper = document.createElement('div');\n wrapper.style.display = 'contents';\n wrapper.appendChild(rendered);\n return wrapper;\n }\n return undefined;\n }\n\n private clearMergeConflictActionCache(): void {\n for (const { element } of this.conflictActionCache.values()) {\n element.remove();\n }\n this.conflictActionCache.clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgGA,IAAI,aAAa;AAEjB,IAAa,iBAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,mBAAmB,EA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3,"file":"UnresolvedFile.js","names":["options: UnresolvedFileOptions<LAnnotation>","resolveConflictDiff","payload: MergeConflictActionPayload"],"sources":["../../src/components/UnresolvedFile.ts"],"sourcesContent":["import { DEFAULT_THEMES } from '../constants';\nimport type { MergeConflictActionTarget } from '../managers/InteractionManager';\nimport { pluckInteractionOptions } from '../managers/InteractionManager';\nimport type { HunksRenderResult } from '../renderers/DiffHunksRenderer';\nimport {\n UnresolvedFileHunksRenderer,\n type UnresolvedFileHunksRendererOptions,\n} from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n MergeConflictRegion,\n MergeConflictResolution,\n} from '../types';\nimport { areFilesEqual } from '../utils/areFilesEqual';\nimport { areMergeConflictActionsEqual } from '../utils/areMergeConflictActionsEqual';\nimport { createAnnotationWrapperNode } from '../utils/createAnnotationWrapperNode';\nimport { getMergeConflictActionSlotName } from '../utils/getMergeConflictActionSlotName';\nimport {\n buildMergeConflictMarkerRows,\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../utils/parseMergeConflictDiffFromFile';\nimport { resolveConflict as resolveConflictDiff } from '../utils/resolveConflict';\nimport { splitFileContents } from '../utils/splitFileContents';\nimport type { WorkerPoolManager } from '../worker';\nimport {\n FileDiff,\n type FileDiffOptions,\n type FileDiffRenderProps,\n} from './FileDiff';\n\nexport type RenderMergeConflictActions<LAnnotation> = (\n action: MergeConflictDiffAction,\n instance: UnresolvedFile<LAnnotation>\n) => HTMLElement | DocumentFragment | null | undefined;\n\nexport type MergeConflictActionsTypeOption<LAnnotation> =\n | 'none'\n | 'default'\n | RenderMergeConflictActions<LAnnotation>;\n\nexport interface UnresolvedFileOptions<LAnnotation> extends Omit<\n FileDiffOptions<LAnnotation>,\n 'diffStyle'\n> {\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFile<LAnnotation>\n ): unknown;\n mergeConflictActionsType?: MergeConflictActionsTypeOption<LAnnotation>;\n onMergeConflictAction?(\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ): void;\n onMergeConflictResolve?(\n file: FileContents,\n payload: MergeConflictActionPayload\n ): void;\n maxContextLines?: number;\n}\n\nexport interface UnresolvedFileRenderProps<LAnnotation> extends Omit<\n FileDiffRenderProps<LAnnotation>,\n 'oldFile' | 'newFile'\n> {\n file?: FileContents;\n actions?: (MergeConflictDiffAction | undefined)[];\n markerRows?: MergeConflictMarkerRow[];\n}\n\nexport interface UnresolvedFileHydrationProps<LAnnotation> extends Omit<\n UnresolvedFileRenderProps<LAnnotation>,\n 'file'\n> {\n file?: FileContents;\n fileContainer: HTMLElement;\n prerenderedHTML?: string;\n}\n\ninterface MergeConflictActionElementCache {\n element: HTMLElement;\n action: MergeConflictDiffAction;\n}\n\ninterface GetOrComputeDiffProps {\n file: FileContents | undefined;\n fileDiff: FileDiffMetadata | undefined;\n actions: (MergeConflictDiffAction | undefined)[] | undefined;\n markerRows: MergeConflictMarkerRow[] | undefined;\n}\n\ninterface GetOrComputeDiffResult {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\n\ninterface ResolveConflictReturn {\n file: FileContents;\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n}\n\ntype UnresolvedFileDataCache = GetOrComputeDiffProps;\n\nlet instanceId = -1;\n\nexport class UnresolvedFile<\n LAnnotation = undefined,\n> extends FileDiff<LAnnotation> {\n override readonly __id: string = `unresolved-file:${++instanceId}`;\n protected computedCache: UnresolvedFileDataCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n markerRows: undefined,\n };\n private conflictActions: (MergeConflictDiffAction | undefined)[] = [];\n private markerRows: MergeConflictMarkerRow[] = [];\n private conflictActionCache: Map<string, MergeConflictActionElementCache> =\n new Map();\n\n constructor(\n public override options: UnresolvedFileOptions<LAnnotation> = {\n theme: DEFAULT_THEMES,\n },\n workerManager?: WorkerPoolManager | undefined,\n isContainerManaged = false\n ) {\n super(undefined, workerManager, isContainerManaged);\n this.setOptions(options);\n }\n\n override setOptions(\n options: UnresolvedFileOptions<LAnnotation> | undefined\n ): void {\n if (options == null) {\n return;\n }\n\n if (\n options.onMergeConflictAction != null &&\n options.onMergeConflictResolve != null\n ) {\n throw new Error(\n 'UnresolvedFile: onMergeConflictAction and onMergeConflictResolve are mutually exclusive. Use only one callback.'\n );\n }\n\n this.options = options;\n this.hunksRenderer.setOptions(this.getHunksRendererOptions(options));\n\n const hunkSeparators = this.options.hunkSeparators ?? 'line-info';\n this.interactionManager.setOptions(\n pluckInteractionOptions(\n this.options,\n typeof hunkSeparators === 'function' ||\n hunkSeparators === 'line-info' ||\n hunkSeparators === 'line-info-basic'\n ? this.expandHunk\n : undefined,\n this.getLineIndex,\n this.handleMergeConflictActionClick\n )\n );\n }\n\n protected override createHunksRenderer(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRenderer<LAnnotation> {\n const renderer = new UnresolvedFileHunksRenderer<LAnnotation>(\n this.getHunksRendererOptions(options),\n this.handleHighlightRender,\n this.workerManager\n );\n return renderer;\n }\n\n protected override getHunksRendererOptions(\n options: UnresolvedFileOptions<LAnnotation>\n ): UnresolvedFileHunksRendererOptions {\n return getUnresolvedDiffHunksRendererOptions(options, this.options);\n }\n\n protected override applyPreNodeAttributes(\n pre: HTMLPreElement,\n result: HunksRenderResult\n ): void {\n super.applyPreNodeAttributes(pre, result, {\n 'data-has-merge-conflict': '',\n });\n }\n\n override cleanUp(): void {\n this.clearMergeConflictActionCache();\n this.computedCache = {\n file: undefined,\n fileDiff: undefined,\n actions: undefined,\n markerRows: undefined,\n };\n this.conflictActions = [];\n super.cleanUp();\n }\n\n private getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n }: GetOrComputeDiffProps): GetOrComputeDiffResult | undefined {\n const { maxContextLines, onMergeConflictAction } = this.options;\n wrapper: {\n // We are dealing with a controlled component\n if (onMergeConflictAction != null) {\n const hasFileDiff = fileDiff != null;\n const hasActions = actions != null;\n const hasMarkerRows = markerRows != null;\n if (hasFileDiff !== hasActions || hasFileDiff !== hasMarkerRows) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows must be passed together'\n );\n }\n // If we were provided a new fileDiff/actions/markerRows, we are a FULLY\n // controlled component, which means we will not do any computation\n if (fileDiff != null && actions != null && markerRows != null) {\n this.computedCache = {\n file: file ?? this.computedCache.file,\n fileDiff,\n actions,\n markerRows,\n };\n break wrapper;\n }\n // If we were provided a new file, we should attempt to parse out a new\n // diff/actions if we haven't computed it before. Once we initialize from\n // a file, later updates must flow through fileDiff/actions instead of\n // reparsing from a new file input.\n else if (file != null || this.computedCache.file != null) {\n if (\n file != null &&\n this.computedCache.file != null &&\n !areFilesEqual(file, this.computedCache.file) &&\n this.computedCache.fileDiff != null &&\n this.computedCache.actions != null\n ) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: file can only be used to initialize unresolved state once. Pass fileDiff and actions for subsequent updates.'\n );\n }\n file ??= this.computedCache.file;\n if (file == null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: file is null, should be impossible'\n );\n }\n if (\n !areFilesEqual(file, this.computedCache.file) ||\n this.computedCache.fileDiff == null ||\n this.computedCache.actions == null\n ) {\n const computed = parseMergeConflictDiffFromFile(\n file,\n maxContextLines\n );\n this.computedCache = {\n file,\n fileDiff: computed.fileDiff,\n actions: computed.actions,\n markerRows: computed.markerRows,\n };\n }\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n // Otherwise we should fall through and try to use the cache if it exists\n else {\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n }\n // If we are uncontrolled we only rely on the file and only use the first\n // version. After that, the cached diff/action pair is the source of\n // truth and we should not accept a new file input.\n else {\n if (fileDiff != null || actions != null || markerRows != null) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: fileDiff, actions, and markerRows are only usable in controlled mode, you must pass in `onMergeConflictAction`'\n );\n }\n if (\n file != null &&\n this.computedCache.file != null &&\n !areFilesEqual(file, this.computedCache.file)\n ) {\n throw new Error(\n 'UnresolvedFile.getOrComputeDiff: uncontrolled unresolved files parse the file only once. Later updates must come from the cached diff state.'\n );\n }\n this.computedCache.file ??= file;\n if (\n this.computedCache.fileDiff == null &&\n this.computedCache.file != null\n ) {\n const computed = parseMergeConflictDiffFromFile(\n this.computedCache.file,\n maxContextLines\n );\n this.computedCache.fileDiff = computed.fileDiff;\n this.computedCache.actions = computed.actions;\n this.computedCache.markerRows = computed.markerRows;\n }\n // Because we are uncontrolled, the source of truth is the\n // computedCache\n fileDiff = this.computedCache.fileDiff;\n actions = this.computedCache.actions;\n markerRows = this.computedCache.markerRows;\n break wrapper;\n }\n }\n if (fileDiff == null || actions == null || markerRows == null) {\n return undefined;\n }\n return { fileDiff, actions, markerRows };\n }\n\n override hydrate(props: UnresolvedFileHydrationProps<LAnnotation>): void {\n const {\n file,\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n preventEmit = false,\n ...rest\n } = props;\n const source = this.getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n });\n if (source == null) {\n return;\n }\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n super.hydrate({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n preventEmit: true,\n });\n this.renderMergeConflictActionSlots();\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n\n override rerender(): void {\n if (!this.enabled || this.fileDiff == null) {\n return;\n }\n this.render({ forceRender: true, renderRange: this.renderRange });\n }\n\n override render(props: UnresolvedFileRenderProps<LAnnotation> = {}): boolean {\n let {\n file,\n fileDiff,\n actions,\n markerRows,\n lineAnnotations,\n preventEmit = false,\n ...rest\n } = props;\n const source = this.getOrComputeDiff({\n file,\n fileDiff,\n actions,\n markerRows,\n });\n if (source == null) {\n return false;\n }\n this.setActiveMergeConflictState(source.actions, source.markerRows);\n const didRender = super.render({\n ...rest,\n fileDiff: source.fileDiff,\n lineAnnotations,\n preventEmit: true,\n });\n if (didRender) {\n this.renderMergeConflictActionSlots();\n if (!preventEmit) {\n this.emitPostRender();\n }\n }\n return didRender;\n }\n\n public resolveConflict(\n conflictIndex: number,\n resolution: MergeConflictResolution,\n fileDiff: FileDiffMetadata | undefined = this.computedCache.fileDiff\n ): ResolveConflictReturn | undefined {\n const action = this.conflictActions[conflictIndex];\n if (fileDiff == null || action == null) {\n return undefined;\n }\n\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflict: conflictIndex and conflictAction don't match\"\n );\n }\n\n const newFileDiff = resolveConflictDiff(fileDiff, action, resolution);\n const previousFile = this.computedCache.file;\n const { file, actions, markerRows } = rebuildFileAndActions({\n fileDiff: newFileDiff,\n previousActions: this.conflictActions,\n resolvedConflictIndex: conflictIndex,\n previousFile,\n resolution,\n });\n\n return {\n file,\n fileDiff: newFileDiff,\n actions,\n markerRows,\n };\n }\n\n private resolveConflictAndRender(\n conflictIndex: number,\n resolution: MergeConflictResolution\n ): void {\n const action = this.conflictActions[conflictIndex];\n if (action == null) {\n return undefined;\n }\n if (action.conflictIndex !== conflictIndex) {\n console.error({ conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.resolveConflictAndRender: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution,\n conflict: action.conflict,\n };\n const { file, fileDiff, actions, markerRows } =\n this.resolveConflict(conflictIndex, resolution) ?? {};\n if (\n file == null ||\n fileDiff == null ||\n actions == null ||\n markerRows == null\n ) {\n return undefined;\n }\n\n this.computedCache = { file, fileDiff, actions, markerRows };\n this.setActiveMergeConflictState(actions, markerRows);\n // NOTE(amadeus): This is a bit jank, but helps to ensure we don't see a\n // bunch of jittery re-renders as things resolve out. In a more perfect\n // world we would have a more elegant way to kick off a render to the\n // highlighter and then resolve actions in a cleaner way, but time is short\n // right now. Can't let perfect be the enemy of good\n if (this.workerManager != null) {\n // Because we are using a workerManager, if we fire off the renderDiff\n // call, it will eventually get back to us in a callback which will\n // trigger a re-render\n this.hunksRenderer.renderDiff(fileDiff);\n } else {\n this.render({ forceRender: true });\n }\n this.options.onMergeConflictResolve?.(file, payload);\n }\n\n private setActiveMergeConflictState(\n actions: (MergeConflictDiffAction | undefined)[] = this.conflictActions,\n markerRows: MergeConflictMarkerRow[] = this.markerRows\n ): void {\n this.conflictActions = actions;\n this.markerRows = markerRows;\n if (\n this.computedCache.fileDiff != null &&\n this.hunksRenderer instanceof UnresolvedFileHunksRenderer\n ) {\n this.hunksRenderer.setConflictState(\n this.options.mergeConflictActionsType === 'none' ? [] : actions,\n markerRows,\n this.computedCache.fileDiff\n );\n }\n }\n\n private handleMergeConflictActionClick = (\n target: MergeConflictActionTarget\n ): void => {\n const action = this.conflictActions[target.conflictIndex];\n if (action == null) {\n return;\n }\n if (action.conflictIndex !== target.conflictIndex) {\n console.error({ conflictIndex: target.conflictIndex, action });\n throw new Error(\n \"UnresolvedFile.handleMergeConflictActionClick: conflictIndex and conflictAction don't match\"\n );\n }\n const payload: MergeConflictActionPayload = {\n resolution: target.resolution,\n conflict: action.conflict,\n };\n if (this.options.onMergeConflictAction != null) {\n this.options.onMergeConflictAction(payload, this);\n return;\n }\n this.resolveConflictAndRender(target.conflictIndex, target.resolution);\n };\n\n private renderMergeConflictActionSlots(): void {\n const { fileDiff } = this.computedCache;\n if (\n this.isContainerManaged ||\n this.fileContainer == null ||\n typeof this.options.mergeConflictActionsType !== 'function' ||\n this.conflictActions.length === 0 ||\n fileDiff == null\n ) {\n this.clearMergeConflictActionCache();\n return;\n }\n const staleActions = new Map(this.conflictActionCache);\n for (\n let actionIndex = 0;\n actionIndex < this.conflictActions.length;\n actionIndex++\n ) {\n const action = this.conflictActions[actionIndex];\n if (action == null) {\n continue;\n }\n if (action.conflictIndex !== actionIndex) {\n console.error({ conflictIndex: actionIndex, action });\n throw new Error(\n \"UnresolvedFile.renderMergeConflictActionSlots: conflictIndex and conflictAction don't match\"\n );\n }\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n if (anchor == null) {\n continue;\n }\n const conflictIndex = action.conflictIndex;\n const slotName = getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex,\n });\n const id = `${actionIndex}-${slotName}`;\n let cache = this.conflictActionCache.get(id);\n if (\n cache == null ||\n !areMergeConflictActionsEqual(cache.action, action)\n ) {\n cache?.element.remove();\n const rendered = this.renderMergeConflictAction(action);\n if (rendered == null) {\n continue;\n }\n const element = createAnnotationWrapperNode(slotName);\n element.appendChild(rendered);\n this.fileContainer.appendChild(element);\n cache = { element, action };\n this.conflictActionCache.set(id, cache);\n }\n staleActions.delete(id);\n }\n for (const [id, { element }] of staleActions.entries()) {\n this.conflictActionCache.delete(id);\n element.remove();\n }\n }\n\n private renderMergeConflictAction(\n action: MergeConflictDiffAction\n ): HTMLElement | undefined {\n if (typeof this.options.mergeConflictActionsType !== 'function') {\n return undefined;\n }\n const rendered = this.options.mergeConflictActionsType(action, this);\n if (rendered == null) {\n return undefined;\n }\n if (rendered instanceof HTMLElement) {\n return rendered;\n }\n if (\n typeof DocumentFragment !== 'undefined' &&\n rendered instanceof DocumentFragment\n ) {\n const wrapper = document.createElement('div');\n wrapper.style.display = 'contents';\n wrapper.appendChild(rendered);\n return wrapper;\n }\n return undefined;\n }\n\n private clearMergeConflictActionCache(): void {\n for (const { element } of this.conflictActionCache.values()) {\n element.remove();\n }\n this.conflictActionCache.clear();\n }\n}\n\ninterface RebuildFileAndActionsProps {\n fileDiff: FileDiffMetadata;\n previousActions: (MergeConflictDiffAction | undefined)[];\n resolvedConflictIndex: number;\n // FIXME: Probably should remove this...\n // additionOffset: number;\n // deletionOffset: number;\n previousFile: FileContents | undefined;\n resolution: MergeConflictResolution;\n}\n\n// Rebuild the emitted unresolved file contents and remaining action anchors in\n// one pass over the post-resolution diff state.\nfunction rebuildFileAndActions({\n fileDiff,\n previousActions,\n resolvedConflictIndex,\n previousFile,\n resolution,\n}: RebuildFileAndActionsProps): Pick<\n ResolveConflictReturn,\n 'file' | 'actions' | 'markerRows'\n> {\n const resolvedAction = previousActions[resolvedConflictIndex];\n if (resolvedAction == null) {\n throw new Error(\n 'rebuildFileAndActions: missing resolved action for unresolved file rebuild'\n );\n }\n\n const actions = updateConflictActionsAfterResolution(\n previousActions,\n resolvedConflictIndex,\n resolvedAction,\n resolution\n );\n const markerRows = buildMergeConflictMarkerRows(fileDiff, actions);\n\n const file = rebuildUnresolvedFile({\n fileDiff,\n resolvedAction,\n resolvedConflictIndex,\n previousFile,\n resolution,\n });\n\n return {\n file,\n actions,\n markerRows,\n };\n}\n\ninterface RebuildUnresolvedFileProps {\n fileDiff: FileDiffMetadata;\n resolvedAction: MergeConflictDiffAction;\n resolvedConflictIndex: number;\n previousFile: FileContents | undefined;\n resolution: MergeConflictResolution;\n}\n\n// Rebuild the unresolved file text from the previous unresolved source so we\n// preserve remaining marker blocks exactly while the diff state stays in-place.\nfunction rebuildUnresolvedFile({\n resolvedAction,\n resolvedConflictIndex,\n previousFile,\n fileDiff,\n resolution,\n}: RebuildUnresolvedFileProps): FileContents {\n const previousContents = previousFile?.contents ?? '';\n const lines = splitFileContents(previousContents);\n const { conflict } = resolvedAction;\n const replacementLines = getResolvedConflictReplacementLines(\n lines,\n conflict,\n resolution\n );\n const contents = [\n ...lines.slice(0, conflict.startLineIndex),\n ...replacementLines,\n ...lines.slice(conflict.endLineIndex + 1),\n ].join('');\n\n return {\n name: previousFile?.name ?? fileDiff.name,\n contents,\n cacheKey:\n previousFile?.cacheKey != null\n ? `${previousFile.cacheKey}:mc-${resolvedConflictIndex}-${resolution}`\n : undefined,\n };\n}\n\nfunction getResolvedConflictReplacementLines(\n lines: string[],\n conflict: MergeConflictDiffAction['conflict'],\n resolution: MergeConflictResolution\n): string[] {\n const currentLines = lines.slice(\n conflict.startLineIndex + 1,\n conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex\n );\n const incomingLines = lines.slice(\n conflict.separatorLineIndex + 1,\n conflict.endLineIndex\n );\n\n if (resolution === 'current') {\n return currentLines;\n }\n if (resolution === 'incoming') {\n return incomingLines;\n }\n return [...currentLines, ...incomingLines];\n}\n\n// The diff resolver keeps hunk/content group indexes stable, so the only\n// follow-up update we need here is shifting unresolved source-region line\n// numbers for later conflicts in the rebuilt file text.\nfunction updateConflictActionsAfterResolution(\n previousActions: (MergeConflictDiffAction | undefined)[],\n resolvedConflictIndex: number,\n resolvedAction: MergeConflictDiffAction,\n resolution: MergeConflictResolution\n): (MergeConflictDiffAction | undefined)[] {\n const lineDelta = getResolvedConflictLineDelta(\n resolvedAction.conflict,\n resolution\n );\n\n return previousActions.map((action, index) => {\n if (index === resolvedConflictIndex) {\n return undefined;\n }\n if (action == null) {\n return undefined;\n }\n if (action.conflict.startLineIndex > resolvedAction.conflict.endLineIndex) {\n return {\n ...action,\n conflict: shiftMergeConflictRegion(action.conflict, lineDelta),\n };\n }\n return action;\n });\n}\n\nfunction getResolvedConflictLineDelta(\n conflict: MergeConflictRegion,\n resolution: MergeConflictResolution\n): number {\n const currentLineCount =\n (conflict.baseMarkerLineIndex ?? conflict.separatorLineIndex) -\n conflict.startLineIndex -\n 1;\n const incomingLineCount =\n conflict.endLineIndex - conflict.separatorLineIndex - 1;\n const replacementLineCount =\n resolution === 'current'\n ? currentLineCount\n : resolution === 'incoming'\n ? incomingLineCount\n : currentLineCount + incomingLineCount;\n const conflictLineCount = conflict.endLineIndex - conflict.startLineIndex + 1;\n return replacementLineCount - conflictLineCount;\n}\n\nfunction shiftMergeConflictRegion(\n conflict: MergeConflictRegion,\n lineDelta: number\n): MergeConflictRegion {\n return {\n ...conflict,\n startLineIndex: conflict.startLineIndex + lineDelta,\n startLineNumber: conflict.startLineNumber + lineDelta,\n separatorLineIndex: conflict.separatorLineIndex + lineDelta,\n separatorLineNumber: conflict.separatorLineNumber + lineDelta,\n endLineIndex: conflict.endLineIndex + lineDelta,\n endLineNumber: conflict.endLineNumber + lineDelta,\n baseMarkerLineIndex:\n conflict.baseMarkerLineIndex != null\n ? conflict.baseMarkerLineIndex + lineDelta\n : undefined,\n baseMarkerLineNumber:\n conflict.baseMarkerLineNumber != null\n ? conflict.baseMarkerLineNumber + lineDelta\n : undefined,\n };\n}\n\n// NOTE(amadeus): Should probably pull this out into a util, and make variants\n// for all component types\nexport function getUnresolvedDiffHunksRendererOptions<LAnnotation>(\n options?: UnresolvedFileOptions<LAnnotation>,\n baseOptions?: UnresolvedFileOptions<LAnnotation>\n): UnresolvedFileHunksRendererOptions {\n return {\n ...baseOptions,\n ...options,\n hunkSeparators:\n typeof options?.hunkSeparators === 'function'\n ? 'custom'\n : options?.hunkSeparators,\n mergeConflictActionsType:\n typeof options?.mergeConflictActionsType === 'function'\n ? 'custom'\n : options?.mergeConflictActionsType,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AA8GA,IAAI,aAAa;AAEjB,IAAa,iBAAb,cAEU,SAAsB;CAC9B,AAAkB,OAAe,mBAAmB,EAAE;CACtD,AAAU,gBAAyC;EACjD,MAAM;EACN,UAAU;EACV,SAAS;EACT,YAAY;EACb;CACD,AAAQ,kBAA2D,EAAE;CACrE,AAAQ,aAAuC,EAAE;CACjD,AAAQ,sCACN,IAAI,KAAK;CAEX,YACE,AAAgBA,UAA8C,EAC5D,OAAO,gBACR,EACD,eACA,qBAAqB,OACrB;AACA,QAAM,QAAW,eAAe,mBAAmB;EANnC;AAOhB,OAAK,WAAW,QAAQ;;CAG1B,AAAS,WACP,SACM;AACN,MAAI,WAAW,KACb;AAGF,MACE,QAAQ,yBAAyB,QACjC,QAAQ,0BAA0B,KAElC,OAAM,IAAI,MACR,kHACD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}
|
package/dist/constants.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ declare const FILENAME_HEADER_REGEX: RegExp;
|
|
|
12
12
|
declare const FILENAME_HEADER_REGEX_GIT: RegExp;
|
|
13
13
|
declare const ALTERNATE_FILE_NAMES_GIT: RegExp;
|
|
14
14
|
declare const INDEX_LINE_METADATA: RegExp;
|
|
15
|
+
declare const MERGE_CONFLICT_START_MARKER_REGEX: RegExp;
|
|
16
|
+
declare const MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp;
|
|
17
|
+
declare const MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp;
|
|
18
|
+
declare const MERGE_CONFLICT_END_MARKER_REGEX: RegExp;
|
|
15
19
|
declare const HEADER_PREFIX_SLOT_ID = "header-prefix";
|
|
16
20
|
declare const HEADER_METADATA_SLOT_ID = "header-metadata";
|
|
17
21
|
declare const DEFAULT_THEMES: ThemesType;
|
|
@@ -23,5 +27,5 @@ declare const DEFAULT_EXPANDED_REGION: HunkExpansionRegion;
|
|
|
23
27
|
declare const DEFAULT_RENDER_RANGE: RenderRange;
|
|
24
28
|
declare const EMPTY_RENDER_RANGE: RenderRange;
|
|
25
29
|
//#endregion
|
|
26
|
-
export { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE };
|
|
30
|
+
export { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE };
|
|
27
31
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":["HunkExpansionRegion","RenderRange","ThemesType","VirtualFileMetrics","DIFFS_TAG_NAME","COMMIT_METADATA_SPLIT","RegExp","GIT_DIFF_FILE_BREAK_REGEX","UNIFIED_DIFF_FILE_BREAK_REGEX","FILE_CONTEXT_BLOB","HUNK_HEADER","SPLIT_WITH_NEWLINES","FILENAME_HEADER_REGEX","FILENAME_HEADER_REGEX_GIT","ALTERNATE_FILE_NAMES_GIT","INDEX_LINE_METADATA","HEADER_PREFIX_SLOT_ID","HEADER_METADATA_SLOT_ID","DEFAULT_THEMES","UNSAFE_CSS_ATTRIBUTE","CORE_CSS_ATTRIBUTE","DEFAULT_COLLAPSED_CONTEXT_THRESHOLD","DEFAULT_VIRTUAL_FILE_METRICS","DEFAULT_EXPANDED_REGION","DEFAULT_RENDER_RANGE","EMPTY_RENDER_RANGE"],"sources":["../src/constants.d.ts"],"sourcesContent":["import type { HunkExpansionRegion, RenderRange, ThemesType, VirtualFileMetrics } from './types';\nexport declare const DIFFS_TAG_NAME: \"diffs-container\";\nexport declare const COMMIT_METADATA_SPLIT: RegExp;\nexport declare const GIT_DIFF_FILE_BREAK_REGEX: RegExp;\nexport declare const UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp;\nexport declare const FILE_CONTEXT_BLOB: RegExp;\nexport declare const HUNK_HEADER: RegExp;\nexport declare const SPLIT_WITH_NEWLINES: RegExp;\nexport declare const FILENAME_HEADER_REGEX: RegExp;\nexport declare const FILENAME_HEADER_REGEX_GIT: RegExp;\nexport declare const ALTERNATE_FILE_NAMES_GIT: RegExp;\nexport declare const INDEX_LINE_METADATA: RegExp;\nexport declare const HEADER_PREFIX_SLOT_ID = \"header-prefix\";\nexport declare const HEADER_METADATA_SLOT_ID = \"header-metadata\";\nexport declare const DEFAULT_THEMES: ThemesType;\nexport declare const UNSAFE_CSS_ATTRIBUTE = \"data-unsafe-css\";\nexport declare const CORE_CSS_ATTRIBUTE = \"data-core-css\";\nexport declare const DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nexport declare const DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics;\nexport declare const DEFAULT_EXPANDED_REGION: HunkExpansionRegion;\nexport declare const DEFAULT_RENDER_RANGE: RenderRange;\nexport declare const EMPTY_RENDER_RANGE: RenderRange;\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;;cACqBI;cACAC,uBAAuBC;AADvBF,cAEAG,yBAFiC,EAEND,MAFM;AACjCD,cAEAG,6BAF6B,EAEEF,MAFF;AAC7BC,cAEAE,iBAFiC,EAEdH,MAFQA;AAC3BE,cAEAE,WAFAF,EAEaF,MAFwB;AACrCG,cAEAE,mBAFmBL,EAEEA,MAFI;AACzBI,cAEAE,qBAFmB,EAEIN,MAFJ;AACnBK,cAEAE,yBAF2B,EAEAP,MAFA;AAC3BM,cAEAE,wBAFuBR,EAEGA,MAFG;AAC7BO,cAEAE,mBAFiC,EAEZT,MAFMA;AAC3BQ,cAEAE,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":["HunkExpansionRegion","RenderRange","ThemesType","VirtualFileMetrics","DIFFS_TAG_NAME","COMMIT_METADATA_SPLIT","RegExp","GIT_DIFF_FILE_BREAK_REGEX","UNIFIED_DIFF_FILE_BREAK_REGEX","FILE_CONTEXT_BLOB","HUNK_HEADER","SPLIT_WITH_NEWLINES","FILENAME_HEADER_REGEX","FILENAME_HEADER_REGEX_GIT","ALTERNATE_FILE_NAMES_GIT","INDEX_LINE_METADATA","MERGE_CONFLICT_START_MARKER_REGEX","MERGE_CONFLICT_BASE_MARKER_REGEX","MERGE_CONFLICT_SEPARATOR_MARKER_REGEX","MERGE_CONFLICT_END_MARKER_REGEX","HEADER_PREFIX_SLOT_ID","HEADER_METADATA_SLOT_ID","DEFAULT_THEMES","UNSAFE_CSS_ATTRIBUTE","CORE_CSS_ATTRIBUTE","DEFAULT_COLLAPSED_CONTEXT_THRESHOLD","DEFAULT_VIRTUAL_FILE_METRICS","DEFAULT_EXPANDED_REGION","DEFAULT_RENDER_RANGE","EMPTY_RENDER_RANGE"],"sources":["../src/constants.d.ts"],"sourcesContent":["import type { HunkExpansionRegion, RenderRange, ThemesType, VirtualFileMetrics } from './types';\nexport declare const DIFFS_TAG_NAME: \"diffs-container\";\nexport declare const COMMIT_METADATA_SPLIT: RegExp;\nexport declare const GIT_DIFF_FILE_BREAK_REGEX: RegExp;\nexport declare const UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp;\nexport declare const FILE_CONTEXT_BLOB: RegExp;\nexport declare const HUNK_HEADER: RegExp;\nexport declare const SPLIT_WITH_NEWLINES: RegExp;\nexport declare const FILENAME_HEADER_REGEX: RegExp;\nexport declare const FILENAME_HEADER_REGEX_GIT: RegExp;\nexport declare const ALTERNATE_FILE_NAMES_GIT: RegExp;\nexport declare const INDEX_LINE_METADATA: RegExp;\nexport declare const MERGE_CONFLICT_START_MARKER_REGEX: RegExp;\nexport declare const MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp;\nexport declare const MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp;\nexport declare const MERGE_CONFLICT_END_MARKER_REGEX: RegExp;\nexport declare const HEADER_PREFIX_SLOT_ID = \"header-prefix\";\nexport declare const HEADER_METADATA_SLOT_ID = \"header-metadata\";\nexport declare const DEFAULT_THEMES: ThemesType;\nexport declare const UNSAFE_CSS_ATTRIBUTE = \"data-unsafe-css\";\nexport declare const CORE_CSS_ATTRIBUTE = \"data-core-css\";\nexport declare const DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nexport declare const DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics;\nexport declare const DEFAULT_EXPANDED_REGION: HunkExpansionRegion;\nexport declare const DEFAULT_RENDER_RANGE: RenderRange;\nexport declare const EMPTY_RENDER_RANGE: RenderRange;\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;;cACqBI;cACAC,uBAAuBC;AADvBF,cAEAG,yBAFiC,EAEND,MAFM;AACjCD,cAEAG,6BAF6B,EAEEF,MAFF;AAC7BC,cAEAE,iBAFiC,EAEdH,MAFQA;AAC3BE,cAEAE,WAFAF,EAEaF,MAFwB;AACrCG,cAEAE,mBAFmBL,EAEEA,MAFI;AACzBI,cAEAE,qBAFmB,EAEIN,MAFJ;AACnBK,cAEAE,yBAF2B,EAEAP,MAFA;AAC3BM,cAEAE,wBAFuBR,EAEGA,MAFG;AAC7BO,cAEAE,mBAFiC,EAEZT,MAFMA;AAC3BQ,cAEAE,iCAFgC,EAEGV,MAFH;AAChCS,cAEAE,gCAF2B,EAEOX,MAFP;AAC3BU,cAEAE,qCAFmCZ,EAEIA,MAFE;AACzCW,cAEAE,+BAFkCb,EAEDA,MAFO;AACxCY,cAEAE,qBAAAA,GAF6C,eAANd;AACvCa,cAEAE,uBAAAA,GAFuC,iBAAA;AACvCD,cAEAE,cAFqB,EAELpB,UAFK;AACrBmB,cAEAE,oBAAAA,GAFuB,iBAAA;AACvBD,cAEAE,kBAAAA,GAFgBtB,eAAU;AAC1BqB,cAEAE,mCAAAA,GAFoB,CAAA;AACpBD,cAEAE,4BAFkB,EAEYvB,kBAFZ;AAClBsB,cAEAE,uBAFmC,EAEV3B,mBAFU;AACnC0B,cAEAE,oBAFgD,EAE1B3B,WAFQE;AAC9BwB,cAEAE,kBAF4C,EAExB5B,WAFKD"}
|
package/dist/constants.js
CHANGED
|
@@ -10,6 +10,10 @@ const FILENAME_HEADER_REGEX = /^(---|\+\+\+)\s+([^\t\r\n]+)/;
|
|
|
10
10
|
const FILENAME_HEADER_REGEX_GIT = /^(---|\+\+\+)\s+[ab]\/([^\t\r\n]+)/;
|
|
11
11
|
const ALTERNATE_FILE_NAMES_GIT = /^diff --git (?:"a\/(.+?)"|a\/(.+?)) (?:"b\/(.+?)"|b\/(.+?))$/;
|
|
12
12
|
const INDEX_LINE_METADATA = /^index ([0-9a-f]+)\.\.([0-9a-f]+)(?: (\d+))?$/i;
|
|
13
|
+
const MERGE_CONFLICT_START_MARKER_REGEX = /^<{7,}(?:\s.*)?$/;
|
|
14
|
+
const MERGE_CONFLICT_BASE_MARKER_REGEX = /^\|{7,}(?:\s.*)?$/;
|
|
15
|
+
const MERGE_CONFLICT_SEPARATOR_MARKER_REGEX = /^={7,}$/;
|
|
16
|
+
const MERGE_CONFLICT_END_MARKER_REGEX = /^>{7,}(?:\s.*)?$/;
|
|
13
17
|
const HEADER_PREFIX_SLOT_ID = "header-prefix";
|
|
14
18
|
const HEADER_METADATA_SLOT_ID = "header-metadata";
|
|
15
19
|
const DEFAULT_THEMES = {
|
|
@@ -44,5 +48,5 @@ const EMPTY_RENDER_RANGE = {
|
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
//#endregion
|
|
47
|
-
export { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE };
|
|
51
|
+
export { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE };
|
|
48
52
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["COMMIT_METADATA_SPLIT: RegExp","GIT_DIFF_FILE_BREAK_REGEX: RegExp","UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp","FILE_CONTEXT_BLOB: RegExp","HUNK_HEADER: RegExp","SPLIT_WITH_NEWLINES: RegExp","FILENAME_HEADER_REGEX: RegExp","FILENAME_HEADER_REGEX_GIT: RegExp","ALTERNATE_FILE_NAMES_GIT: RegExp","INDEX_LINE_METADATA: RegExp","DEFAULT_THEMES: ThemesType","DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics","DEFAULT_EXPANDED_REGION: HunkExpansionRegion","DEFAULT_RENDER_RANGE: RenderRange","EMPTY_RENDER_RANGE: RenderRange"],"sources":["../src/constants.ts"],"sourcesContent":["import type {\n HunkExpansionRegion,\n RenderRange,\n ThemesType,\n VirtualFileMetrics,\n} from './types';\n\nexport const DIFFS_TAG_NAME = 'diffs-container' as const;\n\n// Misc patch/content parsing regexes\nexport const COMMIT_METADATA_SPLIT: RegExp = /(?=^From [a-f0-9]+ .+$)/m;\nexport const GIT_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^diff --git)/gm;\nexport const UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^---\\s+\\S)/gm;\nexport const FILE_CONTEXT_BLOB: RegExp = /(?=^@@ )/gm;\nexport const HUNK_HEADER: RegExp =\n /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(?: (.*))?/m;\nexport const SPLIT_WITH_NEWLINES: RegExp = /(?<=\\n)/;\nexport const FILENAME_HEADER_REGEX: RegExp = /^(---|\\+\\+\\+)\\s+([^\\t\\r\\n]+)/;\nexport const FILENAME_HEADER_REGEX_GIT: RegExp =\n /^(---|\\+\\+\\+)\\s+[ab]\\/([^\\t\\r\\n]+)/;\nexport const ALTERNATE_FILE_NAMES_GIT: RegExp =\n /^diff --git (?:\"a\\/(.+?)\"|a\\/(.+?)) (?:\"b\\/(.+?)\"|b\\/(.+?))$/;\nexport const INDEX_LINE_METADATA: RegExp =\n /^index ([0-9a-f]+)\\.\\.([0-9a-f]+)(?: (\\d+))?$/i;\n\nexport const HEADER_PREFIX_SLOT_ID = 'header-prefix';\nexport const HEADER_METADATA_SLOT_ID = 'header-metadata';\n\nexport const DEFAULT_THEMES: ThemesType = {\n dark: 'pierre-dark',\n light: 'pierre-light',\n};\n\nexport const UNSAFE_CSS_ATTRIBUTE = 'data-unsafe-css';\nexport const CORE_CSS_ATTRIBUTE = 'data-core-css';\n\nexport const DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nexport const DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics = {\n hunkLineCount: 50,\n lineHeight: 20,\n diffHeaderHeight: 44,\n hunkSeparatorHeight: 32,\n fileGap: 8,\n};\n\nexport const DEFAULT_EXPANDED_REGION: HunkExpansionRegion = Object.freeze({\n fromStart: 0,\n fromEnd: 0,\n});\n\nexport const DEFAULT_RENDER_RANGE: RenderRange = {\n startingLine: 0,\n totalLines: Infinity,\n bufferBefore: 0,\n bufferAfter: 0,\n};\n\nexport const EMPTY_RENDER_RANGE: RenderRange = {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: 0,\n};\n"],"mappings":";AAOA,MAAa,iBAAiB;AAG9B,MAAaA,wBAAgC;AAC7C,MAAaC,4BAAoC;AACjD,MAAaC,gCAAwC;AACrD,MAAaC,oBAA4B;AACzC,MAAaC,cACX;AACF,MAAaC,sBAA8B;AAC3C,MAAaC,wBAAgC;AAC7C,MAAaC,4BACX;AACF,MAAaC,2BACX;AACF,MAAaC,sBACX;AAEF,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AAEvC,MAAaC,iBAA6B;CACxC,MAAM;CACN,OAAO;CACR;AAED,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;AAElC,MAAa,sCAAsC;AACnD,MAAaC,+BAAmD;CAC9D,eAAe;CACf,YAAY;CACZ,kBAAkB;CAClB,qBAAqB;CACrB,SAAS;CACV;AAED,MAAaC,0BAA+C,OAAO,OAAO;CACxE,WAAW;CACX,SAAS;CACV,CAAC;AAEF,MAAaC,uBAAoC;CAC/C,cAAc;CACd,YAAY;CACZ,cAAc;CACd,aAAa;CACd;AAED,MAAaC,qBAAkC;CAC7C,cAAc;CACd,YAAY;CACZ,cAAc;CACd,aAAa;CACd"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":["COMMIT_METADATA_SPLIT: RegExp","GIT_DIFF_FILE_BREAK_REGEX: RegExp","UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp","FILE_CONTEXT_BLOB: RegExp","HUNK_HEADER: RegExp","SPLIT_WITH_NEWLINES: RegExp","FILENAME_HEADER_REGEX: RegExp","FILENAME_HEADER_REGEX_GIT: RegExp","ALTERNATE_FILE_NAMES_GIT: RegExp","INDEX_LINE_METADATA: RegExp","MERGE_CONFLICT_START_MARKER_REGEX: RegExp","MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp","MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp","MERGE_CONFLICT_END_MARKER_REGEX: RegExp","DEFAULT_THEMES: ThemesType","DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics","DEFAULT_EXPANDED_REGION: HunkExpansionRegion","DEFAULT_RENDER_RANGE: RenderRange","EMPTY_RENDER_RANGE: RenderRange"],"sources":["../src/constants.ts"],"sourcesContent":["import type {\n HunkExpansionRegion,\n RenderRange,\n ThemesType,\n VirtualFileMetrics,\n} from './types';\n\nexport const DIFFS_TAG_NAME = 'diffs-container' as const;\n\n// Misc patch/content parsing regexes\nexport const COMMIT_METADATA_SPLIT: RegExp = /(?=^From [a-f0-9]+ .+$)/m;\nexport const GIT_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^diff --git)/gm;\nexport const UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^---\\s+\\S)/gm;\nexport const FILE_CONTEXT_BLOB: RegExp = /(?=^@@ )/gm;\nexport const HUNK_HEADER: RegExp =\n /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(?: (.*))?/m;\nexport const SPLIT_WITH_NEWLINES: RegExp = /(?<=\\n)/;\nexport const FILENAME_HEADER_REGEX: RegExp = /^(---|\\+\\+\\+)\\s+([^\\t\\r\\n]+)/;\nexport const FILENAME_HEADER_REGEX_GIT: RegExp =\n /^(---|\\+\\+\\+)\\s+[ab]\\/([^\\t\\r\\n]+)/;\nexport const ALTERNATE_FILE_NAMES_GIT: RegExp =\n /^diff --git (?:\"a\\/(.+?)\"|a\\/(.+?)) (?:\"b\\/(.+?)\"|b\\/(.+?))$/;\nexport const INDEX_LINE_METADATA: RegExp =\n /^index ([0-9a-f]+)\\.\\.([0-9a-f]+)(?: (\\d+))?$/i;\n\nexport const MERGE_CONFLICT_START_MARKER_REGEX: RegExp = /^<{7,}(?:\\s.*)?$/;\nexport const MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp = /^\\|{7,}(?:\\s.*)?$/;\nexport const MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp = /^={7,}$/;\nexport const MERGE_CONFLICT_END_MARKER_REGEX: RegExp = /^>{7,}(?:\\s.*)?$/;\n\nexport const HEADER_PREFIX_SLOT_ID = 'header-prefix';\nexport const HEADER_METADATA_SLOT_ID = 'header-metadata';\n\nexport const DEFAULT_THEMES: ThemesType = {\n dark: 'pierre-dark',\n light: 'pierre-light',\n};\n\nexport const UNSAFE_CSS_ATTRIBUTE = 'data-unsafe-css';\nexport const CORE_CSS_ATTRIBUTE = 'data-core-css';\n\nexport const DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nexport const DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics = {\n hunkLineCount: 50,\n lineHeight: 20,\n diffHeaderHeight: 44,\n hunkSeparatorHeight: 32,\n fileGap: 8,\n};\n\nexport const DEFAULT_EXPANDED_REGION: HunkExpansionRegion = Object.freeze({\n fromStart: 0,\n fromEnd: 0,\n});\n\nexport const DEFAULT_RENDER_RANGE: RenderRange = {\n startingLine: 0,\n totalLines: Infinity,\n bufferBefore: 0,\n bufferAfter: 0,\n};\n\nexport const EMPTY_RENDER_RANGE: RenderRange = {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: 0,\n};\n"],"mappings":";AAOA,MAAa,iBAAiB;AAG9B,MAAaA,wBAAgC;AAC7C,MAAaC,4BAAoC;AACjD,MAAaC,gCAAwC;AACrD,MAAaC,oBAA4B;AACzC,MAAaC,cACX;AACF,MAAaC,sBAA8B;AAC3C,MAAaC,wBAAgC;AAC7C,MAAaC,4BACX;AACF,MAAaC,2BACX;AACF,MAAaC,sBACX;AAEF,MAAaC,oCAA4C;AACzD,MAAaC,mCAA2C;AACxD,MAAaC,wCAAgD;AAC7D,MAAaC,kCAA0C;AAEvD,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AAEvC,MAAaC,iBAA6B;CACxC,MAAM;CACN,OAAO;CACR;AAED,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;AAElC,MAAa,sCAAsC;AACnD,MAAaC,+BAAmD;CAC9D,eAAe;CACf,YAAY;CACZ,kBAAkB;CAClB,qBAAqB;CACrB,SAAS;CACV;AAED,MAAaC,0BAA+C,OAAO,OAAO;CACxE,WAAW;CACX,SAAS;CACV,CAAC;AAEF,MAAaC,uBAAoC;CAC/C,cAAc;CACd,YAAY;CACZ,cAAc;CACd,aAAa;CACd;AAED,MAAaC,qBAAkC;CAC7C,cAAc;CACd,YAAY;CACZ,cAAc;CACd,aAAa;CACd"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ContextContent, CustomPreProperties, DecorationItem, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictRegion, MergeConflictResolution, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, VirtualFileMetrics, VirtualWindowSpecs } from "./types.js";
|
|
1
|
+
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ConflictResolverTypes, ContextContent, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, VirtualFileMetrics, VirtualWindowSpecs } from "./types.js";
|
|
2
2
|
import { GetHoveredLineResult, GetLineIndexUtility, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LogTypes, MergeConflictActionTarget, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, SelectedLineRange, pluckInteractionOptions } from "./managers/InteractionManager.js";
|
|
3
3
|
import { ResizeManager } from "./managers/ResizeManager.js";
|
|
4
4
|
import { FileRenderResult, FileRenderer, FileRendererOptions } from "./renderers/FileRenderer.js";
|
|
@@ -7,12 +7,12 @@ import { CodeToTokenTransformStreamOptions, RecallToken, ShikiStreamTokenizerEnq
|
|
|
7
7
|
import { ShikiStreamTokenizer } from "./shiki-stream/tokenizer.js";
|
|
8
8
|
import { CodeToTokenTransformStream } from "./shiki-stream/stream.js";
|
|
9
9
|
import { FileStream, FileStreamOptions } from "./components/FileStream.js";
|
|
10
|
-
import { DiffHunksRenderer, HunksRenderResult,
|
|
11
|
-
import { MergeConflictActionsTypeOption, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps } from "./components/UnresolvedFile.js";
|
|
10
|
+
import { DiffHunksRenderer, HunksRenderResult, InjectedRow, LineDecoration, RenderedLineContext, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps } from "./renderers/DiffHunksRenderer.js";
|
|
11
|
+
import { MergeConflictActionsTypeOption, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, getUnresolvedDiffHunksRendererOptions } from "./components/UnresolvedFile.js";
|
|
12
12
|
import { Virtualizer, VirtualizerConfig } from "./components/Virtualizer.js";
|
|
13
13
|
import { VirtualizedFile } from "./components/VirtualizedFile.js";
|
|
14
14
|
import { VirtualizedFileDiff } from "./components/VirtualizedFileDiff.js";
|
|
15
|
-
import { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
|
|
15
|
+
import { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
|
|
16
16
|
import { areLanguagesAttached } from "./highlighter/languages/areLanguagesAttached.js";
|
|
17
17
|
import { attachResolvedLanguages } from "./highlighter/languages/attachResolvedLanguages.js";
|
|
18
18
|
import { cleanUpResolvedLanguages } from "./highlighter/languages/cleanUpResolvedLanguages.js";
|
|
@@ -92,10 +92,11 @@ import { prerenderHTMLIfNecessary } from "./utils/prerenderHTMLIfNecessary.js";
|
|
|
92
92
|
import { processLine } from "./utils/processLine.js";
|
|
93
93
|
import { renderDiffWithHighlighter } from "./utils/renderDiffWithHighlighter.js";
|
|
94
94
|
import { renderFileWithHighlighter } from "./utils/renderFileWithHighlighter.js";
|
|
95
|
-
import {
|
|
95
|
+
import { resolveConflict } from "./utils/resolveConflict.js";
|
|
96
|
+
import { resolveRegion } from "./utils/resolveRegion.js";
|
|
96
97
|
import { setLanguageOverride } from "./utils/setLanguageOverride.js";
|
|
97
98
|
import { setPreNodeProperties } from "./utils/setWrapperNodeProps.js";
|
|
98
99
|
import { trimPatchContext } from "./utils/trimPatchContext.js";
|
|
99
100
|
import { FileDiff, FileDiffHydrationProps, FileDiffOptions, FileDiffRenderProps } from "./components/FileDiff.js";
|
|
100
101
|
import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
|
|
101
|
-
export { ALTERNATE_FILE_NAMES_GIT, AnnotationLineMap, AnnotationSide, AnnotationSpan, AttachedLanguages, AttachedThemes, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, ContextContent, CreateFileHeaderElementProps, CustomPreProperties, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DecorationItem, DiffHunksRenderer, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, ExpansionDirections, ExtensionFormatMap, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileContents, FileDiff, FileDiffHydrationProps, FileDiffMetadata, FileDiffOptions, FileDiffRenderProps, FileHydrateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA,
|
|
102
|
+
export { ALTERNATE_FILE_NAMES_GIT, AnnotationLineMap, AnnotationSide, AnnotationSpan, AttachedLanguages, AttachedThemes, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, ConflictResolverTypes, ContextContent, CreateFileHeaderElementProps, CustomPreProperties, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffHunksRenderer, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, ExpansionDirections, ExtensionFormatMap, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileContents, FileDiff, FileDiffHydrationProps, FileDiffMetadata, FileDiffOptions, FileDiffRenderProps, FileHydrateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, InjectedRow, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LanguageRegistration, LineAnnotation, LineDecoration, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, LogTypes, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, MergeConflictActionPayload, MergeConflictActionTarget, MergeConflictActionsTypeOption, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, ObservedAnnotationNodes, ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, ParsedLine, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RecallToken, RegisteredCustomLanguages, RegisteredCustomThemes, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, RenderedLineContext, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiStreamTokenizer, ShikiStreamTokenizerEnqueueResult, ShikiStreamTokenizerOptions, ShikiTransformer, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, VirtualFileMetrics, VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, areDiffLineAnnotationsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, diffAcceptRejectHunk, disposeHighlighter, extendFileFormatMap, findCodeElement, formatCSSVariablePrefix, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, pluckInteractionOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapUnsafeCSS };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
|
|
1
|
+
import { ALTERNATE_FILE_NAMES_GIT, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
|
|
2
2
|
import { areSelectionsEqual } from "./utils/areSelectionsEqual.js";
|
|
3
3
|
import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement, createIconElement, createTextNodeElement, findCodeElement } from "./utils/hast_utils.js";
|
|
4
4
|
import { createGutterUtilityElement } from "./utils/createGutterUtilityElement.js";
|
|
@@ -71,8 +71,9 @@ import { ShikiStreamTokenizer } from "./shiki-stream/tokenizer.js";
|
|
|
71
71
|
import { CodeToTokenTransformStream } from "./shiki-stream/stream.js";
|
|
72
72
|
import { createSpanFromToken } from "./utils/createSpanNodeFromToken.js";
|
|
73
73
|
import { FileStream } from "./components/FileStream.js";
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
74
|
+
import { resolveRegion } from "./utils/resolveRegion.js";
|
|
75
|
+
import { resolveConflict } from "./utils/resolveConflict.js";
|
|
76
|
+
import { UnresolvedFile, getUnresolvedDiffHunksRendererOptions } from "./components/UnresolvedFile.js";
|
|
76
77
|
import { VirtualizedFile } from "./components/VirtualizedFile.js";
|
|
77
78
|
import { VirtualizedFileDiff } from "./components/VirtualizedFileDiff.js";
|
|
78
79
|
import { areVirtualWindowSpecsEqual } from "./utils/areVirtualWindowSpecsEqual.js";
|
|
@@ -97,4 +98,4 @@ import { setLanguageOverride } from "./utils/setLanguageOverride.js";
|
|
|
97
98
|
import { trimPatchContext } from "./utils/trimPatchContext.js";
|
|
98
99
|
import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
|
|
99
100
|
|
|
100
|
-
export { ALTERNATE_FILE_NAMES_GIT, AttachedLanguages, AttachedThemes, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, CodeToTokenTransformStream, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, InteractionManager, RegisteredCustomLanguages, RegisteredCustomThemes, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, ShikiStreamTokenizer, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnresolvedFile, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, diffAcceptRejectHunk, disposeHighlighter, extendFileFormatMap, findCodeElement, formatCSSVariablePrefix, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, pluckInteractionOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, resolveLanguage, resolveLanguages,
|
|
101
|
+
export { ALTERNATE_FILE_NAMES_GIT, AttachedLanguages, AttachedThemes, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_EXTENSION_TO_FILE_FORMAT, CodeToTokenTransformStream, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, InteractionManager, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, RegisteredCustomLanguages, RegisteredCustomThemes, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, ShikiStreamTokenizer, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnresolvedFile, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, diffAcceptRejectHunk, disposeHighlighter, extendFileFormatMap, findCodeElement, formatCSSVariablePrefix, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, pluckInteractionOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapUnsafeCSS };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileContents, MergeConflictResolution } from "../types.js";
|
|
1
|
+
import { FileContents, HunkSeparators, MergeConflictResolution } from "../types.js";
|
|
2
2
|
import { MergeConflictDiffAction } from "../utils/parseMergeConflictDiffFromFile.js";
|
|
3
3
|
import { UnresolvedFileHunksRendererOptions } from "../renderers/UnresolvedFileHunksRenderer.js";
|
|
4
4
|
import { UnresolvedFile as UnresolvedFile$1 } from "../components/UnresolvedFile.js";
|
|
@@ -13,7 +13,9 @@ interface RenderMergeConflictActionContext {
|
|
|
13
13
|
type RenderMergeConflictActions = (action: MergeConflictDiffAction, context: RenderMergeConflictActionContext) => ReactNode;
|
|
14
14
|
type MergeConflictActionsTypeOption = 'none' | 'default' | RenderMergeConflictActions;
|
|
15
15
|
interface UnresolvedFileReactOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'>, UnresolvedFileHunksRendererOptions {
|
|
16
|
+
hunkSeparators?: HunkSeparators;
|
|
16
17
|
onPostRender?(node: HTMLElement, instance: UnresolvedFile$1<LAnnotation>): unknown;
|
|
18
|
+
maxContextLines?: number;
|
|
17
19
|
}
|
|
18
20
|
interface UnresolvedFileProps<LAnnotation> extends Omit<FileDiffProps<LAnnotation>, 'fileDiff' | 'options'> {
|
|
19
21
|
file: FileContents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.d.ts","names":["ReactNode","FileDiffOptions","UnresolvedFile","UnresolvedFileClass","UnresolvedFileHunksRendererOptions","FileContents","MergeConflictResolution","MergeConflictDiffAction","FileDiffProps","RenderMergeConflictActionContext","RenderMergeConflictActions","MergeConflictActionsTypeOption","UnresolvedFileReactOptions","LAnnotation","HTMLElement","Omit","UnresolvedFileProps","file","options","lineAnnotations","selectedLines","className","style","prerenderedHTML","renderAnnotation","renderHeaderPrefix","renderHeaderMetadata","renderGutterUtility","renderHoverUtility","renderMergeConflictUtility","React","JSX","Element"],"sources":["../../src/react/UnresolvedFile.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\nexport type RenderMergeConflictActions = (action: MergeConflictDiffAction, context: RenderMergeConflictActionContext) => ReactNode;\nexport type MergeConflictActionsTypeOption = 'none' | 'default' | RenderMergeConflictActions;\nexport interface UnresolvedFileReactOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'>, UnresolvedFileHunksRendererOptions {\n onPostRender?(node: HTMLElement, instance: UnresolvedFileClass<LAnnotation>): unknown;\n}\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<FileDiffProps<LAnnotation>, 'fileDiff' | 'options'> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => UnresolvedFileClass<LAnnotation> | undefined): ReactNode;\n}\nexport declare function UnresolvedFile<LAnnotation = undefined>({ file, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderPrefix, renderHeaderMetadata, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility }: UnresolvedFileProps<LAnnotation>): React.JSX.Element;\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.d.ts","names":["ReactNode","FileDiffOptions","UnresolvedFile","UnresolvedFileClass","UnresolvedFileHunksRendererOptions","FileContents","HunkSeparators","MergeConflictResolution","MergeConflictDiffAction","FileDiffProps","RenderMergeConflictActionContext","RenderMergeConflictActions","MergeConflictActionsTypeOption","UnresolvedFileReactOptions","LAnnotation","HTMLElement","Omit","UnresolvedFileProps","file","options","lineAnnotations","selectedLines","className","style","prerenderedHTML","renderAnnotation","renderHeaderPrefix","renderHeaderMetadata","renderGutterUtility","renderHoverUtility","renderMergeConflictUtility","React","JSX","Element"],"sources":["../../src/react/UnresolvedFile.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, HunkSeparators, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\nexport type RenderMergeConflictActions = (action: MergeConflictDiffAction, context: RenderMergeConflictActionContext) => ReactNode;\nexport type MergeConflictActionsTypeOption = 'none' | 'default' | RenderMergeConflictActions;\nexport interface UnresolvedFileReactOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'>, UnresolvedFileHunksRendererOptions {\n hunkSeparators?: HunkSeparators;\n onPostRender?(node: HTMLElement, instance: UnresolvedFileClass<LAnnotation>): unknown;\n maxContextLines?: number;\n}\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<FileDiffProps<LAnnotation>, 'fileDiff' | 'options'> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => UnresolvedFileClass<LAnnotation> | undefined): ReactNode;\n}\nexport declare function UnresolvedFile<LAnnotation = undefined>({ file, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderPrefix, renderHeaderMetadata, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility }: UnresolvedFileProps<LAnnotation>): React.JSX.Element;\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":";;;;;;;;;UAOiBU,gCAAAA;8BACeH;AADhC;AAGYI,KAAAA,0BAAAA,GAA0B,CAAA,MAAA,EAAYH,uBAAZ,EAAA,OAAA,EAA8CE,gCAA9C,EAAA,GAAmFV,SAAnF;AAAYQ,KACtCI,8BAAAA,GADsCJ,MAAAA,GAAAA,SAAAA,GACgBG,0BADhBH;AAAkCE,UAEnEG,0BAFmEH,CAAAA,WAAAA,CAAAA,SAEnBM,IAFmBN,CAEdT,eAFcS,CAEEI,WAFFJ,CAAAA,EAAAA,gBAAAA,GAAAA,WAAAA,GAAAA,uBAAAA,GAAAA,cAAAA,CAAAA,EAE4FN,kCAF5FM,CAAAA;EAAqCV,cAAAA,CAAAA,EAGpGM,cAHoGN;EAAS,YAAA,EAAA,IAAA,EAI1Ge,WAJ0G,EAAA,QAAA,EAInFZ,gBAJmF,CAI/DW,WAJ+D,CAAA,CAAA,EAAA,OAAA;EACtHF,eAAAA,CAAAA,EAAAA,MAAAA;AACZ;AAAsFE,UAKrEG,mBALqEH,CAAAA,WAAAA,CAAAA,SAK5BE,IAL4BF,CAKvBL,aALuBK,CAKTA,WALSA,CAAAA,EAAAA,UAAAA,GAAAA,SAAAA,CAAAA,CAAAA;EAAhBb,IAAAA,EAM5DI,YAN4DJ;EACjDK,OAAAA,CAAAA,EAMPO,0BANOP,CAMoBQ,WANpBR,CAAAA;EACGS,0BAAAA,EAAAA,MAAAA,EAMgBP,uBANhBO,EAAAA,WAAAA,EAAAA,GAAAA,GAM4DZ,gBAN5DY,CAMgFD,WANhFC,CAAAA,GAAAA,SAAAA,CAAAA,EAM2Gf,SAN3Ge;;AAAuBZ,iBAQvBD,cARuBC,CAAAA,cAAAA,SAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,SAAAA;EAAAA,KAAAA;EAAAA,eAAAA;EAAAA,gBAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,mBAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAQwOc,mBARxOd,CAQ4PW,WAR5PX,CAAAA,CAAAA,EAQ2Q4B,KAAAA,CAAMC,GAAAA,CAAIC,OARrR9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.js","names":[],"sources":["../../src/react/UnresolvedFile.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\n\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type {
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.js","names":[],"sources":["../../src/react/UnresolvedFile.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\n\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type {\n FileContents,\n HunkSeparators,\n MergeConflictResolution,\n} from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useUnresolvedFileInstance } from './utils/useUnresolvedFileInstance';\n\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\n\nexport type RenderMergeConflictActions = (\n action: MergeConflictDiffAction,\n context: RenderMergeConflictActionContext\n) => ReactNode;\n\nexport type MergeConflictActionsTypeOption =\n | 'none'\n | 'default'\n | RenderMergeConflictActions;\n\nexport interface UnresolvedFileReactOptions<LAnnotation>\n extends\n Omit<\n FileDiffOptions<LAnnotation>,\n 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'\n >,\n UnresolvedFileHunksRendererOptions {\n hunkSeparators?: HunkSeparators;\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFileClass<LAnnotation>\n ): unknown;\n maxContextLines?: number;\n}\n\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<\n FileDiffProps<LAnnotation>,\n 'fileDiff' | 'options'\n> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => UnresolvedFileClass<LAnnotation> | undefined\n ): ReactNode;\n}\n\nexport function UnresolvedFile<LAnnotation = undefined>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n}: UnresolvedFileProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine, fileDiff, actions, getInstance } =\n useUnresolvedFileInstance({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility: renderMergeConflictUtility != null,\n hasGutterRenderUtility:\n renderGutterUtility != null || renderHoverUtility != null,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n lineAnnotations,\n getHoveredLine,\n actions,\n renderMergeConflictUtility,\n getInstance,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AA4DA,SAAgB,eAAwC,EACtD,MACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,oBACA,8BACsD;CACtD,MAAM,EAAE,KAAK,gBAAgB,UAAU,SAAS,gBAC9C,0BAA0B;EACxB;EACA;EACA;EACA;EACA;EACA,oBAAoB,8BAA8B;EAClD,wBACE,uBAAuB,QAAQ,sBAAsB;EACxD,CAAC;AAcJ,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAfY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ContextContent, CustomPreProperties, DecorationItem, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictRegion, MergeConflictResolution, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
|
|
1
|
+
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ConflictResolverTypes, ContextContent, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
|
|
2
2
|
import { WorkerInitializationRenderOptions, WorkerPoolOptions } from "../worker/types.js";
|
|
3
3
|
import { FileOptions } from "../components/File.js";
|
|
4
4
|
import { DiffBasePropsReact, FileProps } from "./types.js";
|
|
@@ -16,4 +16,4 @@ import { templateRender } from "./utils/templateRender.js";
|
|
|
16
16
|
import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
|
|
17
17
|
import { useFileInstance } from "./utils/useFileInstance.js";
|
|
18
18
|
import { useStableCallback } from "./utils/useStableCallback.js";
|
|
19
|
-
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ContextContent, CustomPreProperties, DecorationItem, DiffBasePropsReact, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
|
|
19
|
+
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ConflictResolverTypes, ContextContent, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
|
|
@@ -7,7 +7,7 @@ import { ReactNode } from "react";
|
|
|
7
7
|
//#region src/react/utils/renderDiffChildren.d.ts
|
|
8
8
|
interface RenderDiffChildrenProps<LAnnotation, T> {
|
|
9
9
|
fileDiff?: FileDiffMetadata;
|
|
10
|
-
actions?: MergeConflictDiffAction[];
|
|
10
|
+
actions?: (MergeConflictDiffAction | undefined)[];
|
|
11
11
|
deletionFile?: FileContents;
|
|
12
12
|
additionFile?: FileContents;
|
|
13
13
|
renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDiffChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileContents","FileDiffMetadata","MergeConflictDiffAction","DiffBasePropsReact","RenderDiffChildrenProps","LAnnotation","T","renderDiffChildren","fileDiff","actions","deletionFile","additionFile","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","renderHoverUtility","renderMergeConflictUtility","lineAnnotations","getHoveredLine","getInstance"],"sources":["../../../src/react/utils/renderDiffChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents, FileDiffMetadata } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\nimport type { DiffBasePropsReact } from '../types';\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff?: FileDiffMetadata;\n actions?: MergeConflictDiffAction[];\n deletionFile?: FileContents;\n additionFile?: FileContents;\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => T | undefined): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\nexport declare function renderDiffChildren<LAnnotation, T>({ fileDiff, actions, deletionFile, additionFile, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }: RenderDiffChildrenProps<LAnnotation, T>): ReactNode;\nexport {};\n//# sourceMappingURL=renderDiffChildren.d.ts.map"],"mappings":";;;;;;;UAKUM;aACKH;EADLG,OAAAA,CAAAA,
|
|
1
|
+
{"version":3,"file":"renderDiffChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileContents","FileDiffMetadata","MergeConflictDiffAction","DiffBasePropsReact","RenderDiffChildrenProps","LAnnotation","T","renderDiffChildren","fileDiff","actions","deletionFile","additionFile","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","renderGutterUtility","renderHoverUtility","renderMergeConflictUtility","lineAnnotations","getHoveredLine","getInstance"],"sources":["../../../src/react/utils/renderDiffChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents, FileDiffMetadata } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\nimport type { DiffBasePropsReact } from '../types';\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff?: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n deletionFile?: FileContents;\n additionFile?: FileContents;\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => T | undefined): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\nexport declare function renderDiffChildren<LAnnotation, T>({ fileDiff, actions, deletionFile, additionFile, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }: RenderDiffChildrenProps<LAnnotation, T>): ReactNode;\nexport {};\n//# sourceMappingURL=renderDiffChildren.d.ts.map"],"mappings":";;;;;;;UAKUM;aACKH;EADLG,OAAAA,CAAAA,EAAAA,CAEKF,uBAFkBG,GAAAA,SAAAC,CAAAA,EAAAA;EAClBL,YAAAA,CAAAA,EAEID,YAFJC;EACAC,YAAAA,CAAAA,EAEIF,YAFJE;EACIF,kBAAAA,EAEKG,kBAFLH,CAEwBK,WAFxBL,CAAAA,CAAAA,oBAAAA,CAAAA;EACAA,oBAAAA,EAEOG,kBAFPH,CAE0BK,WAF1BL,CAAAA,CAAAA,sBAAAA,CAAAA;EACwBK,gBAAAA,EAErBF,kBAFqBE,CAEFA,WAFEA,CAAAA,CAAAA,kBAAAA,CAAAA;EAAnBF,mBAAAA,EAGCA,kBAHDA,CAGoBE,WAHpBF,CAAAA,CAAAA,qBAAAA,CAAAA;EACqBE,kBAAAA,EAGrBF,kBAHqBE,CAGFA,WAHEA,CAAAA,CAAAA,oBAAAA,CAAAA;EAAnBF,0BAAAA,EAAAA,MAAAA,EAIcD,uBAJdC,EAAAA,WAAAA,EAAAA,GAAAA,GAI0DG,CAJ1DH,GAAAA,SAAAA,CAAAA,EAI0EL,SAJ1EK;EACeE,eAAAA,EAIpBF,kBAJoBE,CAIDA,WAJCA,CAAAA,CAAAA,iBAAAA,CAAAA;EAAnBF,cAAAA,EAAAA,EAKAJ,oBALAI,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACsBE,WAAAA,GAAAA,EAKxBC,CALwBD,GAAAA,SAAAA;;AACDA,iBAMnBE,kBANmBF,CAAAA,WAAAA,EAAAA,CAAAA,CAAAA,CAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,YAAAA;EAAAA,YAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,gBAAAA;EAAAA,mBAAAA;EAAAA,kBAAAA;EAAAA,0BAAAA;EAAAA,eAAAA;EAAAA,cAAAA;EAAAA;AAAAA,CAAAA,EAMkPD,uBANlPC,CAM0QA,WAN1QA,EAMuRC,CANvRD,CAAAA,CAAAA,EAM4RP,SAN5RO"}
|
|
@@ -32,7 +32,8 @@ function renderDiffChildren({ fileDiff, actions, deletionFile, additionFile, ren
|
|
|
32
32
|
children: renderAnnotation(annotation)
|
|
33
33
|
}, index)),
|
|
34
34
|
actions != null && renderMergeConflictUtility != null && getInstance != null && actions.map((action) => {
|
|
35
|
-
|
|
35
|
+
if (action == null || fileDiff == null) return;
|
|
36
|
+
const slot = getSlotName(action, fileDiff);
|
|
36
37
|
return /* @__PURE__ */ jsx("div", {
|
|
37
38
|
slot,
|
|
38
39
|
style: MergeConflictSlotStyles,
|
|
@@ -46,10 +47,11 @@ function renderDiffChildren({ fileDiff, actions, deletionFile, additionFile, ren
|
|
|
46
47
|
})
|
|
47
48
|
] });
|
|
48
49
|
}
|
|
49
|
-
function getSlotName(action) {
|
|
50
|
-
const anchor = getMergeConflictActionAnchor(action);
|
|
50
|
+
function getSlotName(action, fileDiff) {
|
|
51
|
+
const anchor = getMergeConflictActionAnchor(action, fileDiff);
|
|
51
52
|
return anchor != null ? getMergeConflictActionSlotName({
|
|
52
|
-
|
|
53
|
+
hunkIndex: anchor.hunkIndex,
|
|
54
|
+
lineIndex: anchor.lineIndex,
|
|
53
55
|
conflictIndex: action.conflictIndex
|
|
54
56
|
}) : void 0;
|
|
55
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderDiffChildren.js","names":[],"sources":["../../../src/react/utils/renderDiffChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents, FileDiffMetadata } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { getMergeConflictActionSlotName } from '../../utils/getMergeConflictActionSlotName';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { GutterUtilitySlotStyles, MergeConflictSlotStyles } from '../constants';\nimport type { DiffBasePropsReact } from '../types';\n\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff?: FileDiffMetadata;\n actions?: MergeConflictDiffAction[];\n deletionFile?: FileContents;\n additionFile?: FileContents;\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => T | undefined\n ): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\n\nexport function renderDiffChildren<LAnnotation, T>({\n fileDiff,\n actions,\n deletionFile,\n additionFile,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n lineAnnotations,\n getHoveredLine,\n getInstance,\n}: RenderDiffChildrenProps<LAnnotation, T>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const prefix = renderHeaderPrefix?.({\n fileDiff,\n deletionFile,\n additionFile,\n });\n const metadata = renderHeaderMetadata?.({\n fileDiff,\n deletionFile,\n additionFile,\n });\n return (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {actions != null &&\n renderMergeConflictUtility != null &&\n getInstance != null &&\n actions.map((action) => {\n const slot = getSlotName(action);\n return (\n <div key={slot} slot={slot} style={MergeConflictSlotStyles}>\n {renderMergeConflictUtility(action, getInstance)}\n </div>\n );\n })}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n\nfunction getSlotName(action: MergeConflictDiffAction): string | undefined {\n const anchor = getMergeConflictActionAnchor(action);\n return anchor != null\n ? getMergeConflictActionSlotName({\n
|
|
1
|
+
{"version":3,"file":"renderDiffChildren.js","names":[],"sources":["../../../src/react/utils/renderDiffChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents, FileDiffMetadata } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { getMergeConflictActionSlotName } from '../../utils/getMergeConflictActionSlotName';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { GutterUtilitySlotStyles, MergeConflictSlotStyles } from '../constants';\nimport type { DiffBasePropsReact } from '../types';\n\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff?: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n deletionFile?: FileContents;\n additionFile?: FileContents;\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => T | undefined\n ): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\n\nexport function renderDiffChildren<LAnnotation, T>({\n fileDiff,\n actions,\n deletionFile,\n additionFile,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n lineAnnotations,\n getHoveredLine,\n getInstance,\n}: RenderDiffChildrenProps<LAnnotation, T>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const prefix = renderHeaderPrefix?.({\n fileDiff,\n deletionFile,\n additionFile,\n });\n const metadata = renderHeaderMetadata?.({\n fileDiff,\n deletionFile,\n additionFile,\n });\n return (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {actions != null &&\n renderMergeConflictUtility != null &&\n getInstance != null &&\n actions.map((action) => {\n if (action == null || fileDiff == null) {\n return undefined;\n }\n const slot = getSlotName(action, fileDiff);\n return (\n <div key={slot} slot={slot} style={MergeConflictSlotStyles}>\n {renderMergeConflictUtility(action, getInstance)}\n </div>\n );\n })}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n\nfunction getSlotName(\n action: MergeConflictDiffAction,\n fileDiff: FileDiffMetadata\n): string | undefined {\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n return anchor != null\n ? getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex: action.conflictIndex,\n })\n : undefined;\n}\n"],"mappings":";;;;;;;;AAoCA,SAAgB,mBAAmC,EACjD,UACA,SACA,cACA,cACA,oBACA,sBACA,kBACA,qBACA,oBACA,4BACA,iBACA,gBACA,eACqD;CACrD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,SAAS,qBAAqB;EAClC;EACA;EACA;EACD,CAAC;CACF,MAAM,WAAW,uBAAuB;EACtC;EACA;EACA;EACD,CAAC;AACF,QACE;EACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa;EAClE,YAAY,QAAQ,oBAAC;GAAI,MAAM;aAA0B;IAAe;EACxE,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,WAAW,QACV,8BAA8B,QAC9B,eAAe,QACf,QAAQ,KAAK,WAAW;AACtB,OAAI,UAAU,QAAQ,YAAY,KAChC;GAEF,MAAM,OAAO,YAAY,QAAQ,SAAS;AAC1C,UACE,oBAAC;IAAqB;IAAM,OAAO;cAChC,2BAA2B,QAAQ,YAAY;MADxC,KAEJ;IAER;EACH,iBAAiB,QAChB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,cAAc,eAAe;IAC1B;KAEP;;AAIP,SAAS,YACP,QACA,UACoB;CACpB,MAAM,SAAS,6BAA6B,QAAQ,SAAS;AAC7D,QAAO,UAAU,OACb,+BAA+B;EAC7B,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,eAAe,OAAO;EACvB,CAAC,GACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiffLineAnnotation, FileContents, FileDiffMetadata } from "../../types.js";
|
|
1
|
+
import { DiffLineAnnotation, FileContents, FileDiffMetadata, MergeConflictMarkerRow } from "../../types.js";
|
|
2
2
|
import { GetHoveredLineResult, SelectedLineRange } from "../../managers/InteractionManager.js";
|
|
3
3
|
import { MergeConflictDiffAction } from "../../utils/parseMergeConflictDiffFromFile.js";
|
|
4
4
|
import { UnresolvedFileHunksRendererOptions } from "../../renderers/UnresolvedFileHunksRenderer.js";
|
|
@@ -16,7 +16,8 @@ interface UseUnresolvedFileInstanceProps<LAnnotation> {
|
|
|
16
16
|
}
|
|
17
17
|
interface UseUnresolvedFileInstanceReturn<LAnnotation> {
|
|
18
18
|
fileDiff: FileDiffMetadata;
|
|
19
|
-
actions: MergeConflictDiffAction[];
|
|
19
|
+
actions: (MergeConflictDiffAction | undefined)[];
|
|
20
|
+
markerRows: MergeConflictMarkerRow[];
|
|
20
21
|
ref(node: HTMLElement | null): void;
|
|
21
22
|
getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;
|
|
22
23
|
getInstance(): UnresolvedFile<LAnnotation> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","UnresolvedFileHunksRendererOptions","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictDiffAction","UseUnresolvedFileInstanceProps","LAnnotation","Omit","UseUnresolvedFileInstanceReturn","HTMLElement","useUnresolvedFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","hasConflictUtility","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.d.ts"],"sourcesContent":["import { UnresolvedFile } from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: Omit<UnresolvedFileHunksRendererOptions, 'onMergeConflictAction'>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: MergeConflictDiffAction[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","UnresolvedFileHunksRendererOptions","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictMarkerRow","MergeConflictDiffAction","UseUnresolvedFileInstanceProps","LAnnotation","Omit","UseUnresolvedFileInstanceReturn","HTMLElement","useUnresolvedFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","hasConflictUtility","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.d.ts"],"sourcesContent":["import { UnresolvedFile } from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, MergeConflictMarkerRow } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: Omit<UnresolvedFileHunksRendererOptions, 'onMergeConflictAction'>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUS;QACAJ;EADAI,OAAAA,CAAAA,EAEIE,IAFJF,CAESN,kCAFqBO,EAAAA,uBAAA,CAAA;EAC9BL,eAAAA,EAEWD,kBAFXC,CAE8BK,WAF9BL,CAAAA,EAAAA,GAAAA,SAAAA;EACSF,aAAAA,EAEAD,iBAFAC,GAAAA,IAAAA,GAAAA,SAAAA;EAALQ,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BD,kBAAAA,EAAAA,OAAAA;EAAnBN,sBAAAA,EAAAA,OAAAA;;UAMXQ,+BAL0B,CAAA,WAAA,CAAA,CAAA;EAK1BA,QAAAA,EACIN,gBADJM;EACIN,OAAAA,EAAAA,CACAE,uBADAF,GAAAA,SAAAA,CAAAA,EAAAA;EACAE,UAAAA,EACED,sBADFC,EAAAA;EACED,GAAAA,CAAAA,IAAAA,EACFM,WADEN,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACFM,cAAAA,EAAAA,EACQZ,oBADRY,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACQZ,WAAAA,EAAAA,EACHD,cADGC,CACYS,WADZT,CAAAA,GAAAA,SAAAA;;AACHD,iBAEKc,yBAFLd,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAE4JS,8BAF5JT,CAE2LU,WAF3LV,CAAAA,CAAAA,EAE0MY,+BAF1MZ,CAE0OU,WAF1OV,CAAAA"}
|