@pierre/diffs 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
  2. package/dist/components/File.d.ts +2 -2
  3. package/dist/components/File.d.ts.map +1 -1
  4. package/dist/components/File.js.map +1 -1
  5. package/dist/components/FileDiff.d.ts +3 -3
  6. package/dist/components/FileDiff.d.ts.map +1 -1
  7. package/dist/components/FileDiff.js.map +1 -1
  8. package/dist/components/UnresolvedFile.d.ts +1 -1
  9. package/dist/components/UnresolvedFile.d.ts.map +1 -1
  10. package/dist/components/UnresolvedFile.js.map +1 -1
  11. package/dist/managers/InteractionManager.d.ts +2 -2
  12. package/dist/managers/InteractionManager.d.ts.map +1 -1
  13. package/dist/managers/InteractionManager.js.map +1 -1
  14. package/dist/react/File.js +2 -1
  15. package/dist/react/File.js.map +1 -1
  16. package/dist/react/FileDiff.js +2 -1
  17. package/dist/react/FileDiff.js.map +1 -1
  18. package/dist/react/MultiFileDiff.js +2 -1
  19. package/dist/react/MultiFileDiff.js.map +1 -1
  20. package/dist/react/PatchDiff.js +2 -1
  21. package/dist/react/PatchDiff.js.map +1 -1
  22. package/dist/react/UnresolvedFile.js +2 -1
  23. package/dist/react/UnresolvedFile.js.map +1 -1
  24. package/dist/react/constants.d.ts +2 -1
  25. package/dist/react/constants.d.ts.map +1 -1
  26. package/dist/react/constants.js +4 -1
  27. package/dist/react/constants.js.map +1 -1
  28. package/dist/react/index.d.ts +2 -2
  29. package/dist/react/index.js +2 -2
  30. package/dist/react/jsx.d.ts.map +1 -1
  31. package/dist/react/utils/useFileDiffInstance.d.ts +3 -1
  32. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  33. package/dist/react/utils/useFileDiffInstance.js +14 -5
  34. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  35. package/dist/react/utils/useFileInstance.d.ts +3 -1
  36. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  37. package/dist/react/utils/useFileInstance.js +14 -5
  38. package/dist/react/utils/useFileInstance.js.map +1 -1
  39. package/dist/react/utils/useUnresolvedFileInstance.d.ts +3 -1
  40. package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
  41. package/dist/react/utils/useUnresolvedFileInstance.js +8 -7
  42. package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
  43. package/dist/types.d.ts.map +1 -1
  44. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","_1","HTMLElement","React","HTMLAttributes","DetailedHTMLProps","sideEffect"],"sources":["../../src/react/jsx.d.ts"],"sourcesContent":["import 'react';\nimport type { DIFFS_TAG_NAME } from '../constants';\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n [DIFFS_TAG_NAME]: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n >;\n }\n }\n}\n"],"mappings":";;;;;EACmD,UAAA,GAAA,CAAA;IAAA,UAAA,iBAAA,CAAA;OAK5CA,cAAAA,CAL4C,EAK3BG,KAAAA,CAAME,iBALqB,CAM3CF,KAAAA,CAAMC,cAAeF,CAAAA,WAAAA,CAAAA,EACrBA,WADME,CACNF;IAFgBC;EAAjBH"}
1
+ {"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","_0","HTMLElement","React","HTMLAttributes","DetailedHTMLProps","sideEffect"],"sources":["../../src/react/jsx.d.ts"],"sourcesContent":["import 'react';\nimport type { DIFFS_TAG_NAME } from '../constants';\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n [DIFFS_TAG_NAME]: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n >;\n }\n }\n}\n"],"mappings":";;;;;EACmD,UAAA,GAAA,CAAA;IAAA,UAAA,iBAAA,CAAA;OAK5CA,cAAAA,CAL4C,EAK3BG,KAAAA,CAAME,iBALqB,CAM3CF,KAAAA,CAAMC,cAAeF,CAAAA,WAAAA,CAAAA,EACrBA,WADME,CACNF;IAFgBC;EAAjBH"}
@@ -12,6 +12,7 @@ interface UseFileDiffInstanceProps<LAnnotation> {
12
12
  selectedLines: SelectedLineRange | null | undefined;
13
13
  prerenderedHTML: string | undefined;
14
14
  metrics?: VirtualFileMetrics;
15
+ hasGutterRenderUtility: boolean;
15
16
  }
16
17
  interface UseFileDiffInstanceReturn {
17
18
  ref(node: HTMLElement | null): void;
@@ -25,7 +26,8 @@ declare function useFileDiffInstance<LAnnotation>({
25
26
  lineAnnotations,
26
27
  selectedLines,
27
28
  prerenderedHTML,
28
- metrics
29
+ metrics,
30
+ hasGutterRenderUtility
29
31
  }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;
30
32
  //#endregion
31
33
  export { useFileDiffInstance };
@@ -1 +1 @@
1
- {"version":3,"file":"useFileDiffInstance.d.ts","names":["FileDiffOptions","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","VirtualFileMetrics","UseFileDiffInstanceProps","LAnnotation","UseFileDiffInstanceReturn","HTMLElement","useFileDiffInstance","oldFile","newFile","fileDiff","options","lineAnnotations","selectedLines","prerenderedHTML","metrics"],"sources":["../../../src/react/utils/useFileDiffInstance.d.ts"],"sourcesContent":["import { type FileDiffOptions } from '../../components/FileDiff';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, VirtualFileMetrics } from '../../types';\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\nexport declare function useFileDiffInstance<LAnnotation>({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileDiffInstance.d.ts.map"],"mappings":";;;;;UAGUO;YACIH;EADJG,OAAAA,CAAAA,EAEIH,YAFJG;EACIH,QAAAA,CAAAA,EAECC,gBAFDD;EACAA,OAAAA,EAEDJ,eAFCI,CAEeI,WAFfJ,CAAAA,GAAAA,SAAAA;EACCC,eAAAA,EAEMF,kBAFNE,CAEyBG,WAFzBH,CAAAA,EAAAA,GAAAA,SAAAA;EACcG,aAAAA,EAEVN,iBAFUM,GAAAA,IAAAA,GAAAA,SAAAA;EAAhBR,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC2BQ,OAAAA,CAAAA,EAG1BF,kBAH0BE;;UAK9BC,yBAAAA,CAJSP;EAELI,GAAAA,CAAAA,IAAAA,EAGAI,WAHAJ,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EAAkB,cAAA,EAAA,EAIVL,oBAJU,CAAA,MAAA,CAAA,GAAA,SAAA;AAAA;AAMRU,iBAAAA,mBAAmBH,CAAAA,WAAA,CAAA,CAAA;EAAA,OAAA;EAAA,OAAA;EAAA,QAAA;EAAA,OAAA;EAAA,eAAA;EAAA,aAAA;EAAA,eAAA;EAAA;AAAA,CAAA,EAAiHD,wBAAjH,CAA0IC,WAA1I,CAAA,CAAA,EAAyJC,yBAAzJ"}
1
+ {"version":3,"file":"useFileDiffInstance.d.ts","names":["FileDiffOptions","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","VirtualFileMetrics","UseFileDiffInstanceProps","LAnnotation","UseFileDiffInstanceReturn","HTMLElement","useFileDiffInstance","oldFile","newFile","fileDiff","options","lineAnnotations","selectedLines","prerenderedHTML","metrics","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useFileDiffInstance.d.ts"],"sourcesContent":["import { type FileDiffOptions } from '../../components/FileDiff';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, VirtualFileMetrics } from '../../types';\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\nexport declare function useFileDiffInstance<LAnnotation>({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileDiffInstance.d.ts.map"],"mappings":";;;;;UAGUO;YACIH;EADJG,OAAAA,CAAAA,EAEIH,YAFJG;EACIH,QAAAA,CAAAA,EAECC,gBAFDD;EACAA,OAAAA,EAEDJ,eAFCI,CAEeI,WAFfJ,CAAAA,GAAAA,SAAAA;EACCC,eAAAA,EAEMF,kBAFNE,CAEyBG,WAFzBH,CAAAA,EAAAA,GAAAA,SAAAA;EACcG,aAAAA,EAEVN,iBAFUM,GAAAA,IAAAA,GAAAA,SAAAA;EAAhBR,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC2BQ,OAAAA,CAAAA,EAG1BF,kBAH0BE;EAAnBL,sBAAAA,EAAAA,OAAAA;;UAMXM,yBAAAA,CAHIH;EAAkB,GAAA,CAAA,IAAA,EAIlBI,WAJkB,GAAA,IAAA,CAAA,EAAA,IAAA;EAGtBD,cAAAA,EAAAA,EAEYR,oBAFa,CAAA,MACrBS,CAAAA,GAAAA,SACQT;AAEtB;AAA2DW,iBAAnCD,mBAAmCC,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,OAAAA;EAAAA,OAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA;AAAAA,CAAAA,EAAyHL,wBAAzHK,CAAkJJ,WAAlJI,CAAAA,CAAAA,EAAiKH,yBAAjKG"}
@@ -1,6 +1,7 @@
1
1
  import { FileDiff } from "../../components/FileDiff.js";
2
2
  import { VirtualizedFileDiff } from "../../components/VirtualizedFileDiff.js";
3
3
  import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
+ import { noopRender } from "../constants.js";
4
5
  import { useVirtualizer } from "../Virtualizer.js";
5
6
  import { WorkerPoolContext } from "../WorkerPoolContext.js";
6
7
  import { useStableCallback } from "./useStableCallback.js";
@@ -8,15 +9,15 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "rea
8
9
 
9
10
  //#region src/react/utils/useFileDiffInstance.ts
10
11
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
11
- function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }) {
12
+ function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }) {
12
13
  const simpleVirtualizer = useVirtualizer();
13
14
  const poolManager = useContext(WorkerPoolContext);
14
15
  const instanceRef = useRef(null);
15
16
  const ref = useStableCallback((fileContainer) => {
16
17
  if (fileContainer != null) {
17
18
  if (instanceRef.current != null) throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");
18
- if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFileDiff(options, simpleVirtualizer, metrics, poolManager, true);
19
- else instanceRef.current = new FileDiff(options, poolManager, true);
19
+ if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFileDiff(mergeFileDiffOptions(options, hasGutterRenderUtility), simpleVirtualizer, metrics, poolManager, true);
20
+ else instanceRef.current = new FileDiff(mergeFileDiffOptions(options, hasGutterRenderUtility), poolManager, true);
20
21
  instanceRef.current.hydrate({
21
22
  fileDiff,
22
23
  oldFile,
@@ -34,8 +35,9 @@ function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotati
34
35
  useIsometricEffect(() => {
35
36
  const { current: instance } = instanceRef;
36
37
  if (instance == null) return;
37
- const forceRender = !areOptionsEqual(instance.options, options);
38
- instance.setOptions(options);
38
+ const newOptions = mergeFileDiffOptions(options, hasGutterRenderUtility);
39
+ const forceRender = !areOptionsEqual(instance.options, newOptions);
40
+ instance.setOptions(newOptions);
39
41
  instance.render({
40
42
  forceRender,
41
43
  fileDiff,
@@ -52,6 +54,13 @@ function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotati
52
54
  }, [])
53
55
  };
54
56
  }
57
+ function mergeFileDiffOptions(options, hasGutterRenderUtility) {
58
+ if (hasGutterRenderUtility) return {
59
+ ...options,
60
+ renderGutterUtility: noopRender
61
+ };
62
+ return options;
63
+ }
55
64
 
56
65
  //#endregion
57
66
  export { useFileDiffInstance };
@@ -1 +1 @@
1
- {"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\n\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\n\nexport function useFileDiffInstance<LAnnotation>({\n oldFile,\n newFile,\n fileDiff,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n FileDiff<LAnnotation> | VirtualizedFileDiff<LAnnotation> | null\n >(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n options,\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new FileDiff(options, poolManager, true);\n }\n void instanceRef.current.hydrate({\n fileDiff,\n oldFile,\n newFile,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useFileDiffInstance: A FileDiff instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n const { current: instance } = instanceRef;\n if (instance == null) return;\n const forceRender = !areOptionsEqual(instance.options, options);\n instance.setOptions(options);\n void instance.render({\n forceRender,\n fileDiff,\n oldFile,\n newFile,\n lineAnnotations,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n return { ref, getHoveredLine };\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAkB9C,SAAgB,oBAAiC,EAC/C,SACA,SACA,UACA,SACA,iBACA,eACA,iBACA,WACmE;CACnE,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,kBAAsC;AACnE,MAAI,iBAAiB,MAAM;AACzB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,mFACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,oBACxB,SACA,mBACA,SACA,aACA,KACD;OAED,aAAY,UAAU,IAAI,SAAS,SAAS,aAAa,KAAK;AAEhE,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,wEACD;AAEH,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;EACvB,MAAM,EAAE,SAAS,aAAa;AAC9B,MAAI,YAAY,KAAM;EACtB,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,QAAQ;AAC/D,WAAS,WAAW,QAAQ;AAC5B,EAAK,SAAS,OAAO;GACnB;GACA;GACA;GACA;GACA;GACD,CAAC;AACF,MAAI,kBAAkB,OACpB,UAAS,iBAAiB,cAAc;GAE1C;AAQF,QAAO;EAAE;EAAK,gBANS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAEwB"}
1
+ {"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender as renderGutterUtility } from '../constants';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\n\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\n\nexport function useFileDiffInstance<LAnnotation>({\n oldFile,\n newFile,\n fileDiff,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n FileDiff<LAnnotation> | VirtualizedFileDiff<LAnnotation> | null\n >(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n mergeFileDiffOptions(options, hasGutterRenderUtility),\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new FileDiff(\n mergeFileDiffOptions(options, hasGutterRenderUtility),\n poolManager,\n true\n );\n }\n void instanceRef.current.hydrate({\n fileDiff,\n oldFile,\n newFile,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useFileDiffInstance: A FileDiff instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n const { current: instance } = instanceRef;\n if (instance == null) return;\n const newOptions = mergeFileDiffOptions(options, hasGutterRenderUtility);\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n forceRender,\n fileDiff,\n oldFile,\n newFile,\n lineAnnotations,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n return { ref, getHoveredLine };\n}\n\nfunction mergeFileDiffOptions<LAnnotation>(\n options: FileDiffOptions<LAnnotation> | undefined,\n hasGutterRenderUtility: boolean\n): FileDiffOptions<LAnnotation> | undefined {\n if (hasGutterRenderUtility) {\n return { ...options, renderGutterUtility };\n }\n return options;\n}\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,oBAAiC,EAC/C,SACA,SACA,UACA,SACA,iBACA,eACA,iBACA,SACA,0BACmE;CACnE,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,kBAAsC;AACnE,MAAI,iBAAiB,MAAM;AACzB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,mFACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,oBACxB,qBAAqB,SAAS,uBAAuB,EACrD,mBACA,SACA,aACA,KACD;OAED,aAAY,UAAU,IAAI,SACxB,qBAAqB,SAAS,uBAAuB,EACrD,aACA,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,wEACD;AAEH,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;EACvB,MAAM,EAAE,SAAS,aAAa;AAC9B,MAAI,YAAY,KAAM;EACtB,MAAM,aAAa,qBAAqB,SAAS,uBAAuB;EACxE,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,WAAW;AAClE,WAAS,WAAW,WAAW;AAC/B,EAAK,SAAS,OAAO;GACnB;GACA;GACA;GACA;GACA;GACD,CAAC;AACF,MAAI,kBAAkB,OACpB,UAAS,iBAAiB,cAAc;GAE1C;AAQF,QAAO;EAAE;EAAK,gBANS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAEwB;;AAGhC,SAAS,qBACP,SACA,wBAC0C;AAC1C,KAAI,uBACF,QAAO;EAAE,GAAG;EAAS;EAAqB;AAE5C,QAAO"}
@@ -10,6 +10,7 @@ interface UseFileInstanceProps<LAnnotation> {
10
10
  selectedLines: SelectedLineRange | null | undefined;
11
11
  prerenderedHTML: string | undefined;
12
12
  metrics?: VirtualFileMetrics;
13
+ hasGutterRenderUtility: boolean;
13
14
  }
14
15
  interface UseFileInstanceReturn {
15
16
  ref(node: HTMLElement | null): void;
@@ -21,7 +22,8 @@ declare function useFileInstance<LAnnotation>({
21
22
  lineAnnotations,
22
23
  selectedLines,
23
24
  prerenderedHTML,
24
- metrics
25
+ metrics,
26
+ hasGutterRenderUtility
25
27
  }: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn;
26
28
  //#endregion
27
29
  export { useFileInstance };
@@ -1 +1 @@
1
- {"version":3,"file":"useFileInstance.d.ts","names":["FileOptions","GetHoveredLineResult","SelectedLineRange","FileContents","LineAnnotation","VirtualFileMetrics","UseFileInstanceProps","LAnnotation","UseFileInstanceReturn","HTMLElement","useFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","metrics"],"sources":["../../../src/react/utils/useFileInstance.d.ts"],"sourcesContent":["import { type FileOptions } from '../../components/File';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { FileContents, LineAnnotation, VirtualFileMetrics } from '../../types';\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function useFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileInstance.d.ts.map"],"mappings":";;;;;UAGUM;QACAH;EADAG,OAAAA,EAEGN,WAFHM,CAEeC,WAFKA,CAAAA,GAAAA,SAAAA;EACpBJ,eAAAA,EAEWC,cAFXD,CAE0BI,WAF1BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACeI,aAAAA,EAENL,iBAFMK,GAAAA,IAAAA,GAAAA,SAAAA;EAAZP,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EACuBO,OAAAA,CAAAA,EAGtBF,kBAHsBE;;UAK1BC,qBAAAA,CAJSN;EAELG,GAAAA,CAAAA,IAAAA,EAGAI,WAHAJ,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EAAkB,cAAA,EAAA,EAIVJ,oBAJU,CAAA,MAAA,CAAA,GAAA,SAAA;AAAA;AAMRS,iBAAAA,eAAeH,CAAAA,WAAA,CAAA,CAAA;EAAA,IAAA;EAAA,OAAA;EAAA,eAAA;EAAA,aAAA;EAAA,eAAA;EAAA;AAAA,CAAA,EAA2FD,oBAA3F,CAAgHC,WAAhH,CAAA,CAAA,EAA+HC,qBAA/H"}
1
+ {"version":3,"file":"useFileInstance.d.ts","names":["FileOptions","GetHoveredLineResult","SelectedLineRange","FileContents","LineAnnotation","VirtualFileMetrics","UseFileInstanceProps","LAnnotation","UseFileInstanceReturn","HTMLElement","useFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","metrics","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useFileInstance.d.ts"],"sourcesContent":["import { type FileOptions } from '../../components/File';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { FileContents, LineAnnotation, VirtualFileMetrics } from '../../types';\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function useFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileInstance.d.ts.map"],"mappings":";;;;;UAGUM;QACAH;EADAG,OAAAA,EAEGN,WAFHM,CAEeC,WAFKA,CAAAA,GAAAA,SAAAA;EACpBJ,eAAAA,EAEWC,cAFXD,CAE0BI,WAF1BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACeI,aAAAA,EAENL,iBAFMK,GAAAA,IAAAA,GAAAA,SAAAA;EAAZP,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EACuBO,OAAAA,CAAAA,EAGtBF,kBAHsBE;EAAfH,sBAAAA,EAAAA,OAAAA;;UAMXI,qBAAAA,CAHIH;EAAkB,GAAA,CAAA,IAAA,EAIlBI,WAJkB,GAAA,IAAA,CAAA,EAAA,IAAA;EAGtBD,cAAAA,EAAAA,EAEYP,oBADRQ,CAAAA,MAAAA,CAAAA,GAAAA,SACQR;AAEtB;AAAuDU,iBAA/BD,eAA+BC,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA;AAAAA,CAAAA,EAAmGL,oBAAnGK,CAAwHJ,WAAxHI,CAAAA,CAAAA,EAAuIH,qBAAvIG"}
@@ -1,6 +1,7 @@
1
1
  import { File } from "../../components/File.js";
2
2
  import { VirtualizedFile } from "../../components/VirtualizedFile.js";
3
3
  import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
+ import { noopRender } from "../constants.js";
4
5
  import { useVirtualizer } from "../Virtualizer.js";
5
6
  import { WorkerPoolContext } from "../WorkerPoolContext.js";
6
7
  import { useStableCallback } from "./useStableCallback.js";
@@ -8,15 +9,15 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "rea
8
9
 
9
10
  //#region src/react/utils/useFileInstance.ts
10
11
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
11
- function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }) {
12
+ function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }) {
12
13
  const simpleVirtualizer = useVirtualizer();
13
14
  const poolManager = useContext(WorkerPoolContext);
14
15
  const instanceRef = useRef(null);
15
16
  const ref = useStableCallback((node) => {
16
17
  if (node != null) {
17
18
  if (instanceRef.current != null) throw new Error("File: An instance should not already exist when a node is created");
18
- if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFile(options, simpleVirtualizer, metrics, poolManager, true);
19
- else instanceRef.current = new File(options, poolManager, true);
19
+ if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFile(mergeFileOptions(options, hasGutterRenderUtility), simpleVirtualizer, metrics, poolManager, true);
20
+ else instanceRef.current = new File(mergeFileOptions(options, hasGutterRenderUtility), poolManager, true);
20
21
  instanceRef.current.hydrate({
21
22
  file,
22
23
  fileContainer: node,
@@ -31,8 +32,9 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
31
32
  });
32
33
  useIsometricEffect(() => {
33
34
  if (instanceRef.current == null) return;
34
- const forceRender = !areOptionsEqual(instanceRef.current.options, options);
35
- instanceRef.current.setOptions(options);
35
+ const newOptions = mergeFileOptions(options, hasGutterRenderUtility);
36
+ const forceRender = !areOptionsEqual(instanceRef.current.options, newOptions);
37
+ instanceRef.current.setOptions(newOptions);
36
38
  instanceRef.current.render({
37
39
  file,
38
40
  lineAnnotations,
@@ -47,6 +49,13 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
47
49
  }, [])
48
50
  };
49
51
  }
52
+ function mergeFileOptions(options, hasGutterRenderUtility) {
53
+ if (hasGutterRenderUtility) return {
54
+ ...options,
55
+ renderGutterUtility: noopRender
56
+ };
57
+ return options;
58
+ }
50
59
 
51
60
  //#endregion
52
61
  export { useFileInstance };
@@ -1 +1 @@
1
- {"version":3,"file":"useFileInstance.js","names":[],"sources":["../../../src/react/utils/useFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { File, type FileOptions } from '../../components/File';\nimport { VirtualizedFile } from '../../components/VirtualizedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\n\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function useFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n}: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n File<LAnnotation> | VirtualizedFile<LAnnotation> | null\n >(null);\n const ref = useStableCallback((node: HTMLElement | null) => {\n if (node != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'File: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFile(\n options,\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new File(options, poolManager, true);\n }\n void instanceRef.current.hydrate({\n file,\n fileContainer: node,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error('File: A File instance should exist when unmounting');\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const forceRender = !areOptionsEqual(instanceRef.current.options, options);\n instanceRef.current.setOptions(options);\n void instanceRef.current.render({ file, lineAnnotations, forceRender });\n if (selectedLines !== undefined) {\n instanceRef.current.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'file'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n return { ref, getHoveredLine };\n}\n"],"mappings":";;;;;;;;;AAwBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAgB9C,SAAgB,gBAA6B,EAC3C,MACA,SACA,iBACA,eACA,iBACA,WAC2D;CAC3D,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,SAA6B;AAC1D,MAAI,QAAQ,MAAM;AAChB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,oEACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,gBACxB,SACA,mBACA,SACA,aACA,KACD;OAED,aAAY,UAAU,IAAI,KAAK,SAAS,aAAa,KAAK;AAE5D,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA,eAAe;IACf;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MAAM,qDAAqD;AAEvE,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;AACvB,MAAI,YAAY,WAAW,KAAM;EACjC,MAAM,cAAc,CAAC,gBAAgB,YAAY,QAAQ,SAAS,QAAQ;AAC1E,cAAY,QAAQ,WAAW,QAAQ;AACvC,EAAK,YAAY,QAAQ,OAAO;GAAE;GAAM;GAAiB;GAAa,CAAC;AACvE,MAAI,kBAAkB,OACpB,aAAY,QAAQ,iBAAiB,cAAc;GAErD;AAOF,QAAO;EAAE;EAAK,gBALS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EACwB"}
1
+ {"version":3,"file":"useFileInstance.js","names":[],"sources":["../../../src/react/utils/useFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { File, type FileOptions } from '../../components/File';\nimport { VirtualizedFile } from '../../components/VirtualizedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender as renderGutterUtility } from '../constants';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\n\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function useFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n}: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n File<LAnnotation> | VirtualizedFile<LAnnotation> | null\n >(null);\n const ref = useStableCallback((node: HTMLElement | null) => {\n if (node != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'File: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFile(\n mergeFileOptions(options, hasGutterRenderUtility),\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new File(\n mergeFileOptions(options, hasGutterRenderUtility),\n poolManager,\n true\n );\n }\n void instanceRef.current.hydrate({\n file,\n fileContainer: node,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error('File: A File instance should exist when unmounting');\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const newOptions = mergeFileOptions(options, hasGutterRenderUtility);\n const forceRender = !areOptionsEqual(\n instanceRef.current.options,\n newOptions\n );\n instanceRef.current.setOptions(newOptions);\n void instanceRef.current.render({ file, lineAnnotations, forceRender });\n if (selectedLines !== undefined) {\n instanceRef.current.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'file'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n return { ref, getHoveredLine };\n}\n\nfunction mergeFileOptions<LAnnotation>(\n options: FileOptions<LAnnotation> | undefined,\n hasGutterRenderUtility: boolean\n): FileOptions<LAnnotation> | undefined {\n if (hasGutterRenderUtility) {\n return { ...options, renderGutterUtility };\n }\n return options;\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAiB9C,SAAgB,gBAA6B,EAC3C,MACA,SACA,iBACA,eACA,iBACA,SACA,0BAC2D;CAC3D,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,SAA6B;AAC1D,MAAI,QAAQ,MAAM;AAChB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,oEACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,gBACxB,iBAAiB,SAAS,uBAAuB,EACjD,mBACA,SACA,aACA,KACD;OAED,aAAY,UAAU,IAAI,KACxB,iBAAiB,SAAS,uBAAuB,EACjD,aACA,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA,eAAe;IACf;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MAAM,qDAAqD;AAEvE,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;AACvB,MAAI,YAAY,WAAW,KAAM;EACjC,MAAM,aAAa,iBAAiB,SAAS,uBAAuB;EACpE,MAAM,cAAc,CAAC,gBACnB,YAAY,QAAQ,SACpB,WACD;AACD,cAAY,QAAQ,WAAW,WAAW;AAC1C,EAAK,YAAY,QAAQ,OAAO;GAAE;GAAM;GAAiB;GAAa,CAAC;AACvE,MAAI,kBAAkB,OACpB,aAAY,QAAQ,iBAAiB,cAAc;GAErD;AAOF,QAAO;EAAE;EAAK,gBALS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EACwB;;AAGhC,SAAS,iBACP,SACA,wBACsC;AACtC,KAAI,uBACF,QAAO;EAAE,GAAG;EAAS;EAAqB;AAE5C,QAAO"}
@@ -12,6 +12,7 @@ interface UseUnresolvedFileInstanceProps<LAnnotation> {
12
12
  selectedLines: SelectedLineRange | null | undefined;
13
13
  prerenderedHTML: string | undefined;
14
14
  hasConflictUtility: boolean;
15
+ hasGutterRenderUtility: boolean;
15
16
  }
16
17
  interface UseUnresolvedFileInstanceReturn<LAnnotation> {
17
18
  fileDiff: FileDiffMetadata;
@@ -26,7 +27,8 @@ declare function useUnresolvedFileInstance<LAnnotation>({
26
27
  lineAnnotations,
27
28
  selectedLines,
28
29
  prerenderedHTML,
29
- hasConflictUtility
30
+ hasConflictUtility,
31
+ hasGutterRenderUtility
30
32
  }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;
31
33
  //#endregion
32
34
  export { useUnresolvedFileInstance };
@@ -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"],"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}\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 }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUQ;QACAH;EADAG,OAAAA,CAAAA,EAEIE,IAFJF,CAESL,kCAFqBM,EAAAA,uBAAA,CAAA;EAC9BJ,eAAAA,EAEWD,kBAFXC,CAE8BI,WAF9BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACSF,aAAAA,EAEAD,iBAFAC,GAAAA,IAAAA,GAAAA,SAAAA;EAALO,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BD,kBAAAA,EAAAA,OAAAA;;UAK9BE,+BAJST,CAAAA,WAAAA,CAAAA,CAAAA;EAAiB,QAAA,EAKtBI,gBALsB;EAI1BK,OAAAA,EAEGJ,uBAFHI,EAA+B;EAC3BL,GAAAA,CAAAA,IAAAA,EAEAM,WAFAN,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACDC,cAAAA,EAAAA,EAESN,oBAFTM,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACCK,WAAAA,EAAAA,EAEKZ,cAFLY,CAEoBH,WAFpBG,CAAAA,GAAAA,SAAAA;;AAEoBH,iBAEVI,yBAFUJ,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA;AAAAA,CAAAA,EAEqHD,8BAFrHC,CAEoJA,WAFpJA,CAAAA,CAAAA,EAEmKE,+BAFnKF,CAEmMA,WAFnMA,CAAAA"}
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":";;;;;;;UAKUQ;QACAH;EADAG,OAAAA,CAAAA,EAEIE,IAFJF,CAESL,kCAFqBM,EAAAA,uBAAA,CAAA;EAC9BJ,eAAAA,EAEWD,kBAFXC,CAE8BI,WAF9BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACSF,aAAAA,EAEAD,iBAFAC,GAAAA,IAAAA,GAAAA,SAAAA;EAALO,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BD,kBAAAA,EAAAA,OAAAA;EAAnBL,sBAAAA,EAAAA,OAAAA;;UAMXO,+BAL0B,CAAA,WAAA,CAAA,CAAA;EAK1BA,QAAAA,EACIL,gBADJK;EACIL,OAAAA,EACDC,uBADCD,EAAAA;EACDC,GAAAA,CAAAA,IAAAA,EACCK,WADDL,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACCK,cAAAA,EAAAA,EACQX,oBADRW,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACQX,WAAAA,EAAAA,EACHD,cADGC,CACYQ,WADZR,CAAAA,GAAAA,SAAAA;;AACHD,iBAEKa,yBAFLb,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAE4JQ,8BAF5JR,CAE2LS,WAF3LT,CAAAA,CAAAA,EAE0MW,+BAF1MX,CAE0OS,WAF1OT,CAAAA"}
@@ -1,13 +1,14 @@
1
1
  import { parseMergeConflictDiffFromFile } from "../../utils/parseMergeConflictDiffFromFile.js";
2
2
  import { UnresolvedFile } from "../../components/UnresolvedFile.js";
3
3
  import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
+ import { noopRender } from "../constants.js";
4
5
  import { WorkerPoolContext } from "../WorkerPoolContext.js";
5
6
  import { useStableCallback } from "./useStableCallback.js";
6
7
  import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
7
8
 
8
9
  //#region src/react/utils/useUnresolvedFileInstance.ts
9
10
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
10
- function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility }) {
11
+ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }) {
11
12
  const [{ fileDiff, actions }, setState] = useState(() => {
12
13
  const { fileDiff: fileDiff$1, actions: actions$1 } = parseMergeConflictDiffFromFile(file);
13
14
  return {
@@ -32,7 +33,7 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
32
33
  const ref = useStableCallback((fileContainer) => {
33
34
  if (fileContainer != null) {
34
35
  if (instanceRef.current != null) throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");
35
- instanceRef.current = new UnresolvedFile(mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility), poolManager, true);
36
+ instanceRef.current = new UnresolvedFile(mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility), poolManager, true);
36
37
  instanceRef.current.hydrate({
37
38
  fileDiff,
38
39
  actions,
@@ -49,7 +50,7 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
49
50
  useIsometricEffect(() => {
50
51
  if (instanceRef.current == null) return;
51
52
  const instance = instanceRef.current;
52
- const newOptions = mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility);
53
+ const newOptions = mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility);
53
54
  const forceRender = !areOptionsEqual(instance.options, newOptions);
54
55
  instance.setOptions(newOptions);
55
56
  instance.render({
@@ -72,15 +73,15 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
72
73
  }, [])
73
74
  };
74
75
  }
75
- function mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility) {
76
+ function mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility) {
76
77
  return {
77
78
  ...options,
78
79
  onMergeConflictAction,
79
- hunkSeparators: options?.hunkSeparators === "custom" ? emptyRender : options?.hunkSeparators,
80
- mergeConflictActionsType: hasConflictUtility || options?.mergeConflictActionsType === "custom" ? emptyRender : options?.mergeConflictActionsType
80
+ hunkSeparators: options?.hunkSeparators === "custom" ? noopRender : options?.hunkSeparators,
81
+ mergeConflictActionsType: hasConflictUtility || options?.mergeConflictActionsType === "custom" ? noopRender : options?.mergeConflictActionsType,
82
+ renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
81
83
  };
82
84
  }
83
- function emptyRender() {}
84
85
 
85
86
  //#endregion
86
87
  export { useUnresolvedFileInstance };
@@ -1 +1 @@
1
- {"version":3,"file":"useUnresolvedFileInstance.js","names":["UnresolvedFileClass"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n UnresolvedFile,\n UnresolvedFile as UnresolvedFileClass,\n type UnresolvedFileOptions,\n} from '../../components/UnresolvedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport {\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\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}\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}\n\nexport function useUnresolvedFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility,\n}: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation> {\n const [{ fileDiff, actions }, setState] = useState(() => {\n const { fileDiff, actions } = parseMergeConflictDiffFromFile(file);\n return { fileDiff, actions };\n });\n // UnresolvedFile is intentionally uncontrolled in React. Keep an internal\n // source-of-truth file so sequential conflict actions apply to the latest\n // resolved contents rather than the initial prop value.\n const activeFileRef = useRef(file);\n const onMergeConflictAction = useStableCallback(\n (\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ) => {\n const activeFile = activeFileRef.current;\n const newFile = instance.resolveConflict(\n payload.conflict.conflictIndex,\n payload.resolution,\n activeFile\n );\n if (newFile == null) return;\n activeFileRef.current = newFile;\n const { fileDiff, actions } = parseMergeConflictDiffFromFile(newFile);\n setState({ fileDiff, actions });\n }\n );\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<UnresolvedFileClass<LAnnotation> | null>(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useUnresolvedFileInstance: An instance should not already exist when a node is created'\n );\n }\n instanceRef.current = new UnresolvedFileClass(\n mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility\n ),\n poolManager,\n true\n );\n void instanceRef.current.hydrate({\n fileDiff,\n actions,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const instance = instanceRef.current;\n const newOptions = mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility\n );\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n fileDiff,\n actions,\n lineAnnotations,\n forceRender,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n const getInstance = useCallback(() => {\n return instanceRef.current ?? undefined;\n }, []);\n\n return { ref, getHoveredLine, fileDiff, actions, getInstance };\n}\n\nfunction mergeUnresolvedOptions<LAnnotation>(\n options: UnresolvedFileHunksRendererOptions | undefined,\n onMergeConflictAction: UnresolvedFileOptions<LAnnotation>['onMergeConflictAction'],\n hasConflictUtility: boolean\n): UnresolvedFileOptions<LAnnotation> {\n return {\n ...options,\n onMergeConflictAction,\n hunkSeparators:\n options?.hunkSeparators === 'custom'\n ? emptyRender\n : options?.hunkSeparators,\n // Add a placeholder type for the custom render\n mergeConflictActionsType:\n hasConflictUtility || options?.mergeConflictActionsType === 'custom'\n ? emptyRender\n : options?.mergeConflictActionsType,\n };\n}\n\nfunction emptyRender() {\n return undefined;\n}\n"],"mappings":";;;;;;;;AAiCA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,0BAAuC,EACrD,MACA,SACA,iBACA,eACA,iBACA,sBAC4F;CAC5F,MAAM,CAAC,EAAE,UAAU,WAAW,YAAY,eAAe;EACvD,MAAM,EAAE,sBAAU,uBAAY,+BAA+B,KAAK;AAClE,SAAO;GAAE;GAAU;GAAS;GAC5B;CAIF,MAAM,gBAAgB,OAAO,KAAK;CAClC,MAAM,wBAAwB,mBAE1B,SACA,aACG;EACH,MAAM,aAAa,cAAc;EACjC,MAAM,UAAU,SAAS,gBACvB,QAAQ,SAAS,eACjB,QAAQ,YACR,WACD;AACD,MAAI,WAAW,KAAM;AACrB,gBAAc,UAAU;EACxB,MAAM,EAAE,sBAAU,uBAAY,+BAA+B,QAAQ;AACrE,WAAS;GAAE;GAAU;GAAS,CAAC;GAElC;CACD,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAAgD,KAAK;CACzE,MAAM,MAAM,mBAAmB,kBAAsC;AACnE,MAAI,iBAAiB,MAAM;AACzB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,yFACD;AAEH,eAAY,UAAU,IAAIA,eACxB,uBACE,SACA,uBACA,mBACD,EACD,aACA,KACD;AACD,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,oFACD;AAEH,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;AACvB,MAAI,YAAY,WAAW,KAAM;EACjC,MAAM,WAAW,YAAY;EAC7B,MAAM,aAAa,uBACjB,SACA,uBACA,mBACD;EACD,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,WAAW;AAClE,WAAS,WAAW,WAAW;AAC/B,EAAK,SAAS,OAAO;GACnB;GACA;GACA;GACA;GACD,CAAC;AACF,MAAI,kBAAkB,OACpB,UAAS,iBAAiB,cAAc;GAE1C;AAYF,QAAO;EAAE;EAAK,gBAVS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAMwB;EAAU;EAAS,aAJ7B,kBAAkB;AACpC,UAAO,YAAY,WAAW;KAC7B,EAAE,CAAC;EAEwD;;AAGhE,SAAS,uBACP,SACA,uBACA,oBACoC;AACpC,QAAO;EACL,GAAG;EACH;EACA,gBACE,SAAS,mBAAmB,WACxB,cACA,SAAS;EAEf,0BACE,sBAAsB,SAAS,6BAA6B,WACxD,cACA,SAAS;EAChB;;AAGH,SAAS,cAAc"}
1
+ {"version":3,"file":"useUnresolvedFileInstance.js","names":["UnresolvedFileClass"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n UnresolvedFile,\n UnresolvedFile as UnresolvedFileClass,\n type UnresolvedFileOptions,\n} from '../../components/UnresolvedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport {\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { noopRender } from '../constants';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\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}\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}\n\nexport function useUnresolvedFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility,\n hasGutterRenderUtility,\n}: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation> {\n const [{ fileDiff, actions }, setState] = useState(() => {\n const { fileDiff, actions } = parseMergeConflictDiffFromFile(file);\n return { fileDiff, actions };\n });\n // UnresolvedFile is intentionally uncontrolled in React. Keep an internal\n // source-of-truth file so sequential conflict actions apply to the latest\n // resolved contents rather than the initial prop value.\n const activeFileRef = useRef(file);\n const onMergeConflictAction = useStableCallback(\n (\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ) => {\n const activeFile = activeFileRef.current;\n const newFile = instance.resolveConflict(\n payload.conflict.conflictIndex,\n payload.resolution,\n activeFile\n );\n if (newFile == null) return;\n activeFileRef.current = newFile;\n const { fileDiff, actions } = parseMergeConflictDiffFromFile(newFile);\n setState({ fileDiff, actions });\n }\n );\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<UnresolvedFileClass<LAnnotation> | null>(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useUnresolvedFileInstance: An instance should not already exist when a node is created'\n );\n }\n instanceRef.current = new UnresolvedFileClass(\n mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility,\n hasGutterRenderUtility\n ),\n poolManager,\n true\n );\n void instanceRef.current.hydrate({\n fileDiff,\n actions,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useUnresolvedFileInstance: A UnresolvedFile instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const instance = instanceRef.current;\n const newOptions = mergeUnresolvedOptions(\n options,\n onMergeConflictAction,\n hasConflictUtility,\n hasGutterRenderUtility\n );\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n fileDiff,\n actions,\n lineAnnotations,\n forceRender,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n const getInstance = useCallback(() => {\n return instanceRef.current ?? undefined;\n }, []);\n\n return { ref, getHoveredLine, fileDiff, actions, getInstance };\n}\n\nfunction mergeUnresolvedOptions<LAnnotation>(\n options: UnresolvedFileHunksRendererOptions | undefined,\n onMergeConflictAction: UnresolvedFileOptions<LAnnotation>['onMergeConflictAction'],\n hasConflictUtility: boolean,\n hasGutterRenderUtility: boolean\n): UnresolvedFileOptions<LAnnotation> {\n return {\n ...options,\n onMergeConflictAction,\n hunkSeparators:\n options?.hunkSeparators === 'custom'\n ? noopRender\n : options?.hunkSeparators,\n // Add a placeholder type for the custom render\n mergeConflictActionsType:\n hasConflictUtility || options?.mergeConflictActionsType === 'custom'\n ? noopRender\n : options?.mergeConflictActionsType,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n}\n"],"mappings":";;;;;;;;;AAkCA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAoB9C,SAAgB,0BAAuC,EACrD,MACA,SACA,iBACA,eACA,iBACA,oBACA,0BAC4F;CAC5F,MAAM,CAAC,EAAE,UAAU,WAAW,YAAY,eAAe;EACvD,MAAM,EAAE,sBAAU,uBAAY,+BAA+B,KAAK;AAClE,SAAO;GAAE;GAAU;GAAS;GAC5B;CAIF,MAAM,gBAAgB,OAAO,KAAK;CAClC,MAAM,wBAAwB,mBAE1B,SACA,aACG;EACH,MAAM,aAAa,cAAc;EACjC,MAAM,UAAU,SAAS,gBACvB,QAAQ,SAAS,eACjB,QAAQ,YACR,WACD;AACD,MAAI,WAAW,KAAM;AACrB,gBAAc,UAAU;EACxB,MAAM,EAAE,sBAAU,uBAAY,+BAA+B,QAAQ;AACrE,WAAS;GAAE;GAAU;GAAS,CAAC;GAElC;CACD,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAAgD,KAAK;CACzE,MAAM,MAAM,mBAAmB,kBAAsC;AACnE,MAAI,iBAAiB,MAAM;AACzB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,yFACD;AAEH,eAAY,UAAU,IAAIA,eACxB,uBACE,SACA,uBACA,oBACA,uBACD,EACD,aACA,KACD;AACD,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,oFACD;AAEH,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;AACvB,MAAI,YAAY,WAAW,KAAM;EACjC,MAAM,WAAW,YAAY;EAC7B,MAAM,aAAa,uBACjB,SACA,uBACA,oBACA,uBACD;EACD,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,WAAW;AAClE,WAAS,WAAW,WAAW;AAC/B,EAAK,SAAS,OAAO;GACnB;GACA;GACA;GACA;GACD,CAAC;AACF,MAAI,kBAAkB,OACpB,UAAS,iBAAiB,cAAc;GAE1C;AAYF,QAAO;EAAE;EAAK,gBAVS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAMwB;EAAU;EAAS,aAJ7B,kBAAkB;AACpC,UAAO,YAAY,WAAW;KAC7B,EAAE,CAAC;EAEwD;;AAGhE,SAAS,uBACP,SACA,uBACA,oBACA,wBACoC;AACpC,QAAO;EACL,GAAG;EACH;EACA,gBACE,SAAS,mBAAmB,WACxB,aACA,SAAS;EAEf,0BACE,sBAAsB,SAAS,6BAA6B,WACxD,aACA,SAAS;EACf,qBAAqB,yBAAyB,aAAa;EAC5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","RenderHeaderMetadataProps","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","SelectionPoint"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow' | 'themeType'>> {\n type: 'diff' | 'file';\n split: boolean;\n themeStyles: string;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport interface RenderHeaderMetadataProps {\n deletionFile?: FileContents;\n additionFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n}\nexport type RenderHeaderMetadataCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderHeaderPrefixCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderFileMetadata = (file: FileContents) => Element | null | undefined | string | number;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":"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"}
1
+ {"version":3,"file":"types.d.ts","names":["ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","RenderHeaderMetadataProps","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","SelectionPoint"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow' | 'themeType'>> {\n type: 'diff' | 'file';\n split: boolean;\n themeStyles: string;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport interface RenderHeaderMetadataProps {\n deletionFile?: FileContents;\n additionFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n}\nexport type RenderHeaderMetadataCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderHeaderPrefixCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderFileMetadata = (file: FileContents) => Element | null | undefined | string | number;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pierre/diffs",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "license": "apache-2.0",
5
5
  "files": [
6
6
  "dist",