@pierre/diffs 1.1.5 → 1.1.7

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 (139) hide show
  1. package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
  2. package/dist/components/File.d.ts +21 -1
  3. package/dist/components/File.d.ts.map +1 -1
  4. package/dist/components/File.js +142 -70
  5. package/dist/components/File.js.map +1 -1
  6. package/dist/components/FileDiff.d.ts +26 -5
  7. package/dist/components/FileDiff.d.ts.map +1 -1
  8. package/dist/components/FileDiff.js +143 -89
  9. package/dist/components/FileDiff.js.map +1 -1
  10. package/dist/components/FileStream.d.ts +4 -1
  11. package/dist/components/FileStream.d.ts.map +1 -1
  12. package/dist/components/FileStream.js +27 -12
  13. package/dist/components/FileStream.js.map +1 -1
  14. package/dist/components/UnresolvedFile.js +6 -42
  15. package/dist/components/UnresolvedFile.js.map +1 -1
  16. package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
  17. package/dist/constants.d.ts +3 -1
  18. package/dist/constants.d.ts.map +1 -1
  19. package/dist/constants.js +3 -1
  20. package/dist/constants.js.map +1 -1
  21. package/dist/index.d.ts +6 -6
  22. package/dist/index.js +4 -4
  23. package/dist/react/File.d.ts +3 -1
  24. package/dist/react/File.d.ts.map +1 -1
  25. package/dist/react/File.js +5 -2
  26. package/dist/react/File.js.map +1 -1
  27. package/dist/react/FileDiff.d.ts +4 -1
  28. package/dist/react/FileDiff.d.ts.map +1 -1
  29. package/dist/react/FileDiff.js +5 -2
  30. package/dist/react/FileDiff.js.map +1 -1
  31. package/dist/react/MultiFileDiff.d.ts +4 -1
  32. package/dist/react/MultiFileDiff.d.ts.map +1 -1
  33. package/dist/react/MultiFileDiff.js +12 -6
  34. package/dist/react/MultiFileDiff.js.map +1 -1
  35. package/dist/react/PatchDiff.d.ts +4 -1
  36. package/dist/react/PatchDiff.d.ts.map +1 -1
  37. package/dist/react/PatchDiff.js +5 -2
  38. package/dist/react/PatchDiff.js.map +1 -1
  39. package/dist/react/UnresolvedFile.d.ts +4 -1
  40. package/dist/react/UnresolvedFile.d.ts.map +1 -1
  41. package/dist/react/UnresolvedFile.js +5 -2
  42. package/dist/react/UnresolvedFile.js.map +1 -1
  43. package/dist/react/WorkerPoolContext.js +7 -5
  44. package/dist/react/WorkerPoolContext.js.map +1 -1
  45. package/dist/react/index.d.ts +2 -2
  46. package/dist/react/jsx.d.ts.map +1 -1
  47. package/dist/react/types.d.ts +6 -3
  48. package/dist/react/types.d.ts.map +1 -1
  49. package/dist/react/utils/renderDiffChildren.d.ts +4 -6
  50. package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
  51. package/dist/react/utils/renderDiffChildren.js +12 -17
  52. package/dist/react/utils/renderDiffChildren.js.map +1 -1
  53. package/dist/react/utils/renderFileChildren.d.ts +2 -0
  54. package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
  55. package/dist/react/utils/renderFileChildren.js +9 -6
  56. package/dist/react/utils/renderFileChildren.js.map +1 -1
  57. package/dist/react/utils/useFileDiffInstance.d.ts +7 -7
  58. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  59. package/dist/react/utils/useFileDiffInstance.js +20 -11
  60. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  61. package/dist/react/utils/useFileInstance.d.ts +5 -1
  62. package/dist/react/utils/useFileInstance.d.ts.map +1 -1
  63. package/dist/react/utils/useFileInstance.js +20 -7
  64. package/dist/react/utils/useFileInstance.js.map +1 -1
  65. package/dist/react/utils/useUnresolvedFileInstance.d.ts +5 -1
  66. package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
  67. package/dist/react/utils/useUnresolvedFileInstance.js +17 -4
  68. package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
  69. package/dist/renderers/DiffHunksRenderer.d.ts +14 -9
  70. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  71. package/dist/renderers/DiffHunksRenderer.js +13 -21
  72. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  73. package/dist/renderers/FileRenderer.d.ts +5 -4
  74. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  75. package/dist/renderers/FileRenderer.js +11 -19
  76. package/dist/renderers/FileRenderer.js.map +1 -1
  77. package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +5 -5
  78. package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
  79. package/dist/renderers/UnresolvedFileHunksRenderer.js +2 -2
  80. package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
  81. package/dist/ssr/index.d.ts +2 -2
  82. package/dist/ssr/preloadDiffs.js +7 -4
  83. package/dist/ssr/preloadDiffs.js.map +1 -1
  84. package/dist/ssr/preloadFile.js +7 -2
  85. package/dist/ssr/preloadFile.js.map +1 -1
  86. package/dist/style.js +1 -1
  87. package/dist/style.js.map +1 -1
  88. package/dist/types.d.ts +11 -11
  89. package/dist/types.d.ts.map +1 -1
  90. package/dist/utils/arePrePropertiesEqual.js +1 -1
  91. package/dist/utils/arePrePropertiesEqual.js.map +1 -1
  92. package/dist/utils/createFileHeaderElement.d.ts +3 -5
  93. package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
  94. package/dist/utils/createFileHeaderElement.js +17 -10
  95. package/dist/utils/createFileHeaderElement.js.map +1 -1
  96. package/dist/utils/createPreElement.d.ts +0 -2
  97. package/dist/utils/createPreElement.d.ts.map +1 -1
  98. package/dist/utils/createPreElement.js +4 -7
  99. package/dist/utils/createPreElement.js.map +1 -1
  100. package/dist/utils/createStyleElement.d.ts +2 -1
  101. package/dist/utils/createStyleElement.d.ts.map +1 -1
  102. package/dist/utils/createStyleElement.js +9 -2
  103. package/dist/utils/createStyleElement.js.map +1 -1
  104. package/dist/utils/cssWrappers.d.ts +4 -1
  105. package/dist/utils/cssWrappers.d.ts.map +1 -1
  106. package/dist/utils/cssWrappers.js +11 -2
  107. package/dist/utils/cssWrappers.js.map +1 -1
  108. package/dist/utils/hast_utils.d.ts +1 -1
  109. package/dist/utils/hast_utils.d.ts.map +1 -1
  110. package/dist/utils/hast_utils.js.map +1 -1
  111. package/dist/utils/hostTheme.d.ts +15 -0
  112. package/dist/utils/hostTheme.d.ts.map +1 -0
  113. package/dist/utils/hostTheme.js +22 -0
  114. package/dist/utils/hostTheme.js.map +1 -0
  115. package/dist/utils/isDiffPlainText.d.ts +7 -0
  116. package/dist/utils/isDiffPlainText.d.ts.map +1 -0
  117. package/dist/utils/isDiffPlainText.js +12 -0
  118. package/dist/utils/isDiffPlainText.js.map +1 -0
  119. package/dist/utils/isFilePlainText.d.ts +7 -0
  120. package/dist/utils/isFilePlainText.d.ts.map +1 -0
  121. package/dist/utils/isFilePlainText.js +10 -0
  122. package/dist/utils/isFilePlainText.js.map +1 -0
  123. package/dist/utils/parsePatchFiles.js +1 -1
  124. package/dist/utils/parsePatchFiles.js.map +1 -1
  125. package/dist/utils/renderDiffWithHighlighter.js +1 -4
  126. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  127. package/dist/utils/renderFileWithHighlighter.js +1 -3
  128. package/dist/utils/renderFileWithHighlighter.js.map +1 -1
  129. package/dist/utils/setWrapperNodeProps.d.ts +0 -2
  130. package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
  131. package/dist/utils/setWrapperNodeProps.js +1 -4
  132. package/dist/utils/setWrapperNodeProps.js.map +1 -1
  133. package/dist/worker/WorkerPoolManager.js +4 -2
  134. package/dist/worker/WorkerPoolManager.js.map +1 -1
  135. package/dist/worker/worker-portable.js +4 -13
  136. package/dist/worker/worker-portable.js.map +1 -1
  137. package/dist/worker/worker.js +2 -7
  138. package/dist/worker/worker.js.map +1 -1
  139. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID } from "../../constants.js";
1
+ import { CUSTOM_HEADER_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID } from "../../constants.js";
2
2
  import { getLineAnnotationName } from "../../utils/getLineAnnotationName.js";
3
3
  import { getMergeConflictActionSlotName } from "../../utils/getMergeConflictActionSlotName.js";
4
4
  import { getMergeConflictActionAnchor } from "../../utils/parseMergeConflictDiffFromFile.js";
@@ -6,33 +6,28 @@ import { GutterUtilitySlotStyles, MergeConflictSlotStyles } from "../constants.j
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
 
8
8
  //#region src/react/utils/renderDiffChildren.tsx
9
- function renderDiffChildren({ fileDiff, actions, deletionFile, additionFile, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }) {
9
+ function renderDiffChildren({ fileDiff, actions, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility, lineAnnotations, getHoveredLine, getInstance }) {
10
10
  const gutterUtility = renderGutterUtility ?? renderHoverUtility;
11
- const prefix = renderHeaderPrefix?.({
12
- fileDiff,
13
- deletionFile,
14
- additionFile
15
- });
16
- const metadata = renderHeaderMetadata?.({
17
- fileDiff,
18
- deletionFile,
19
- additionFile
20
- });
11
+ const customHeader = renderCustomHeader?.(fileDiff);
12
+ const prefix = renderHeaderPrefix?.(fileDiff);
13
+ const metadata = renderHeaderMetadata?.(fileDiff);
21
14
  return /* @__PURE__ */ jsxs(Fragment, { children: [
22
- prefix != null && /* @__PURE__ */ jsx("div", {
15
+ customHeader != null ? /* @__PURE__ */ jsx("div", {
16
+ slot: CUSTOM_HEADER_SLOT_ID,
17
+ children: customHeader
18
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [prefix != null && /* @__PURE__ */ jsx("div", {
23
19
  slot: HEADER_PREFIX_SLOT_ID,
24
20
  children: prefix
25
- }),
26
- metadata != null && /* @__PURE__ */ jsx("div", {
21
+ }), metadata != null && /* @__PURE__ */ jsx("div", {
27
22
  slot: HEADER_METADATA_SLOT_ID,
28
23
  children: metadata
29
- }),
24
+ })] }),
30
25
  renderAnnotation != null && lineAnnotations?.map((annotation, index) => /* @__PURE__ */ jsx("div", {
31
26
  slot: getLineAnnotationName(annotation),
32
27
  children: renderAnnotation(annotation)
33
28
  }, index)),
34
29
  actions != null && renderMergeConflictUtility != null && getInstance != null && actions.map((action) => {
35
- if (action == null || fileDiff == null) return;
30
+ if (action == null) return;
36
31
  const slot = getSlotName(action, fileDiff);
37
32
  return /* @__PURE__ */ jsx("div", {
38
33
  slot,
@@ -1 +1 @@
1
- {"version":3,"file":"renderDiffChildren.js","names":[],"sources":["../../../src/react/utils/renderDiffChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents, FileDiffMetadata } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { getMergeConflictActionSlotName } from '../../utils/getMergeConflictActionSlotName';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { GutterUtilitySlotStyles, MergeConflictSlotStyles } from '../constants';\nimport type { DiffBasePropsReact } from '../types';\n\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff?: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n deletionFile?: FileContents;\n additionFile?: FileContents;\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => T | undefined\n ): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\n\nexport function renderDiffChildren<LAnnotation, T>({\n fileDiff,\n actions,\n deletionFile,\n additionFile,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n lineAnnotations,\n getHoveredLine,\n getInstance,\n}: RenderDiffChildrenProps<LAnnotation, T>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const prefix = renderHeaderPrefix?.({\n fileDiff,\n deletionFile,\n additionFile,\n });\n const metadata = renderHeaderMetadata?.({\n fileDiff,\n deletionFile,\n additionFile,\n });\n return (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {actions != null &&\n renderMergeConflictUtility != null &&\n getInstance != null &&\n actions.map((action) => {\n if (action == null || fileDiff == null) {\n return undefined;\n }\n const slot = getSlotName(action, fileDiff);\n return (\n <div key={slot} slot={slot} style={MergeConflictSlotStyles}>\n {renderMergeConflictUtility(action, getInstance)}\n </div>\n );\n })}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n\nfunction getSlotName(\n action: MergeConflictDiffAction,\n fileDiff: FileDiffMetadata\n): string | undefined {\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n return anchor != null\n ? getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex: action.conflictIndex,\n })\n : undefined;\n}\n"],"mappings":";;;;;;;;AAoCA,SAAgB,mBAAmC,EACjD,UACA,SACA,cACA,cACA,oBACA,sBACA,kBACA,qBACA,oBACA,4BACA,iBACA,gBACA,eACqD;CACrD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,SAAS,qBAAqB;EAClC;EACA;EACA;EACD,CAAC;CACF,MAAM,WAAW,uBAAuB;EACtC;EACA;EACA;EACD,CAAC;AACF,QACE;EACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa;EAClE,YAAY,QAAQ,oBAAC;GAAI,MAAM;aAA0B;IAAe;EACxE,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,WAAW,QACV,8BAA8B,QAC9B,eAAe,QACf,QAAQ,KAAK,WAAW;AACtB,OAAI,UAAU,QAAQ,YAAY,KAChC;GAEF,MAAM,OAAO,YAAY,QAAQ,SAAS;AAC1C,UACE,oBAAC;IAAqB;IAAM,OAAO;cAChC,2BAA2B,QAAQ,YAAY;MADxC,KAEJ;IAER;EACH,iBAAiB,QAChB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,cAAc,eAAe;IAC1B;KAEP;;AAIP,SAAS,YACP,QACA,UACoB;CACpB,MAAM,SAAS,6BAA6B,QAAQ,SAAS;AAC7D,QAAO,UAAU,OACb,+BAA+B;EAC7B,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,eAAe,OAAO;EACvB,CAAC,GACF"}
1
+ {"version":3,"file":"renderDiffChildren.js","names":[],"sources":["../../../src/react/utils/renderDiffChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileDiffMetadata } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { getMergeConflictActionSlotName } from '../../utils/getMergeConflictActionSlotName';\nimport {\n getMergeConflictActionAnchor,\n type MergeConflictDiffAction,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { GutterUtilitySlotStyles, MergeConflictSlotStyles } from '../constants';\nimport type { DiffBasePropsReact } from '../types';\n\ninterface RenderDiffChildrenProps<LAnnotation, T> {\n fileDiff: FileDiffMetadata;\n actions?: (MergeConflictDiffAction | undefined)[];\n renderCustomHeader: DiffBasePropsReact<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: DiffBasePropsReact<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: DiffBasePropsReact<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: DiffBasePropsReact<LAnnotation>['renderAnnotation'];\n renderGutterUtility: DiffBasePropsReact<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: DiffBasePropsReact<LAnnotation>['renderHoverUtility'];\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => T | undefined\n ): ReactNode;\n lineAnnotations: DiffBasePropsReact<LAnnotation>['lineAnnotations'];\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance?(): T | undefined;\n}\n\nexport function renderDiffChildren<LAnnotation, T>({\n fileDiff,\n actions,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n lineAnnotations,\n getHoveredLine,\n getInstance,\n}: RenderDiffChildrenProps<LAnnotation, T>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const customHeader = renderCustomHeader?.(fileDiff);\n const prefix = renderHeaderPrefix?.(fileDiff);\n const metadata = renderHeaderMetadata?.(fileDiff);\n return (\n <>\n {customHeader != null ? (\n <div slot={CUSTOM_HEADER_SLOT_ID}>{customHeader}</div>\n ) : (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && (\n <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>\n )}\n </>\n )}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {actions != null &&\n renderMergeConflictUtility != null &&\n getInstance != null &&\n actions.map((action) => {\n if (action == null) {\n return undefined;\n }\n const slot = getSlotName(action, fileDiff);\n return (\n <div key={slot} slot={slot} style={MergeConflictSlotStyles}>\n {renderMergeConflictUtility(action, getInstance)}\n </div>\n );\n })}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n\nfunction getSlotName(\n action: MergeConflictDiffAction,\n fileDiff: FileDiffMetadata\n): string | undefined {\n const anchor = getMergeConflictActionAnchor(action, fileDiff);\n return anchor != null\n ? getMergeConflictActionSlotName({\n hunkIndex: anchor.hunkIndex,\n lineIndex: anchor.lineIndex,\n conflictIndex: action.conflictIndex,\n })\n : undefined;\n}\n"],"mappings":";;;;;;;;AAoCA,SAAgB,mBAAmC,EACjD,UACA,SACA,oBACA,oBACA,sBACA,kBACA,qBACA,oBACA,4BACA,iBACA,gBACA,eACqD;CACrD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,eAAe,qBAAqB,SAAS;CACnD,MAAM,SAAS,qBAAqB,SAAS;CAC7C,MAAM,WAAW,uBAAuB,SAAS;AACjD,QACE;EACG,gBAAgB,OACf,oBAAC;GAAI,MAAM;aAAwB;IAAmB,GAEtD,4CACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa,EAClE,YAAY,QACX,oBAAC;GAAI,MAAM;aAA0B;IAAe,IAErD;EAEJ,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,WAAW,QACV,8BAA8B,QAC9B,eAAe,QACf,QAAQ,KAAK,WAAW;AACtB,OAAI,UAAU,KACZ;GAEF,MAAM,OAAO,YAAY,QAAQ,SAAS;AAC1C,UACE,oBAAC;IAAqB;IAAM,OAAO;cAChC,2BAA2B,QAAQ,YAAY;MADxC,KAEJ;IAER;EACH,iBAAiB,QAChB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,cAAc,eAAe;IAC1B;KAEP;;AAIP,SAAS,YACP,QACA,UACoB;CACpB,MAAM,SAAS,6BAA6B,QAAQ,SAAS;AAC7D,QAAO,UAAU,OACb,+BAA+B;EAC7B,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,eAAe,OAAO;EACvB,CAAC,GACF"}
@@ -6,6 +6,7 @@ import { ReactNode } from "react";
6
6
  //#region src/react/utils/renderFileChildren.d.ts
7
7
  interface RenderFileChildrenProps<LAnnotation> {
8
8
  file: FileContents;
9
+ renderCustomHeader: FileProps<LAnnotation>['renderCustomHeader'];
9
10
  renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];
10
11
  renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];
11
12
  renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];
@@ -16,6 +17,7 @@ interface RenderFileChildrenProps<LAnnotation> {
16
17
  }
17
18
  declare function renderFileChildren<LAnnotation>({
18
19
  file,
20
+ renderCustomHeader,
19
21
  renderHeaderPrefix,
20
22
  renderHeaderMetadata,
21
23
  renderAnnotation,
@@ -1 +1 @@
1
- {"version":3,"file":"renderFileChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileContents","FileProps","RenderFileChildrenProps","LAnnotation","renderFileChildren","file","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","lineAnnotations","renderGutterUtility","renderHoverUtility","getHoveredLine"],"sources":["../../../src/react/utils/renderFileChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport type { FileProps } from '../types';\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: FileProps<LAnnotation>['renderHoverUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function renderFileChildren<LAnnotation>({ file, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, renderHoverUtility, getHoveredLine }: RenderFileChildrenProps<LAnnotation>): ReactNode;\nexport {};\n//# sourceMappingURL=renderFileChildren.d.ts.map"],"mappings":";;;;;;UAIUI;QACAF;EADAE,kBAAAA,EAEcD,SAFS,CAECE,WAFDA,CAAAA,CAAAA,oBAAA,CAAA;EACvBH,oBAAAA,EAEgBC,SAFhBD,CAE0BG,WAF1BH,CAAAA,CAAAA,sBAAAA,CAAAA;EACwBG,gBAAAA,EAEZF,SAFYE,CAEFA,WAFEA,CAAAA,CAAAA,kBAAAA,CAAAA;EAAVF,eAAAA,EAGHA,SAHGA,CAGOE,WAHPF,CAAAA,CAAAA,iBAAAA,CAAAA;EACYE,mBAAAA,EAGXF,SAHWE,CAGDA,WAHCA,CAAAA,CAAAA,qBAAAA,CAAAA;EAAVF,kBAAAA,EAIFA,SAJEA,CAIQE,WAJRF,CAAAA,CAAAA,oBAAAA,CAAAA;EACME,cAAAA,EAAAA,EAIVJ,oBAJUI,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AACDA,iBAKPC,kBALOD,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,gBAAAA;EAAAA,eAAAA;EAAAA,mBAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAKyKD,uBALzKC,CAKiMA,WALjMA,CAAAA,CAAAA,EAKgNL,SALhNK"}
1
+ {"version":3,"file":"renderFileChildren.d.ts","names":["ReactNode","GetHoveredLineResult","FileContents","FileProps","RenderFileChildrenProps","LAnnotation","renderFileChildren","file","renderCustomHeader","renderHeaderPrefix","renderHeaderMetadata","renderAnnotation","lineAnnotations","renderGutterUtility","renderHoverUtility","getHoveredLine"],"sources":["../../../src/react/utils/renderFileChildren.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport type { FileProps } from '../types';\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderCustomHeader: FileProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: FileProps<LAnnotation>['renderHoverUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function renderFileChildren<LAnnotation>({ file, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, renderHoverUtility, getHoveredLine }: RenderFileChildrenProps<LAnnotation>): ReactNode;\nexport {};\n//# sourceMappingURL=renderFileChildren.d.ts.map"],"mappings":";;;;;;UAIUI;QACAF;EADAE,kBAAAA,EAEcD,SAFS,CAECE,WAFDA,CAAAA,CAAAA,oBAAA,CAAA;EACvBH,kBAAAA,EAEcC,SAFdD,CAEwBG,WAFxBH,CAAAA,CAAAA,oBAAAA,CAAAA;EACwBG,oBAAAA,EAERF,SAFQE,CAEEA,WAFFA,CAAAA,CAAAA,sBAAAA,CAAAA;EAAVF,gBAAAA,EAGFA,SAHEA,CAGQE,WAHRF,CAAAA,CAAAA,kBAAAA,CAAAA;EACUE,eAAAA,EAGbF,SAHaE,CAGHA,WAHGA,CAAAA,CAAAA,iBAAAA,CAAAA;EAAVF,mBAAAA,EAICA,SAJDA,CAIWE,WAJXF,CAAAA,CAAAA,qBAAAA,CAAAA;EACYE,kBAAAA,EAIZF,SAJYE,CAIFA,WAJEA,CAAAA,CAAAA,oBAAAA,CAAAA;EAAVF,cAAAA,EAAAA,EAKJF,oBALIE,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AACJA,iBAMEG,kBANFH,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,kBAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,gBAAAA;EAAAA,eAAAA;EAAAA,mBAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAMsMC,uBANtMD,CAM8NE,WAN9NF,CAAAA,CAAAA,EAM6OH,SAN7OG"}
@@ -1,22 +1,25 @@
1
- import { HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID } from "../../constants.js";
1
+ import { CUSTOM_HEADER_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID } from "../../constants.js";
2
2
  import { getLineAnnotationName } from "../../utils/getLineAnnotationName.js";
3
3
  import { GutterUtilitySlotStyles } from "../constants.js";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
 
6
6
  //#region src/react/utils/renderFileChildren.tsx
7
- function renderFileChildren({ file, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, renderHoverUtility, getHoveredLine }) {
7
+ function renderFileChildren({ file, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, renderHoverUtility, getHoveredLine }) {
8
8
  const gutterUtility = renderGutterUtility ?? renderHoverUtility;
9
+ const customHeader = renderCustomHeader?.(file);
9
10
  const prefix = renderHeaderPrefix?.(file);
10
11
  const metadata = renderHeaderMetadata?.(file);
11
12
  return /* @__PURE__ */ jsxs(Fragment, { children: [
12
- prefix != null && /* @__PURE__ */ jsx("div", {
13
+ customHeader != null ? /* @__PURE__ */ jsx("div", {
14
+ slot: CUSTOM_HEADER_SLOT_ID,
15
+ children: customHeader
16
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [prefix != null && /* @__PURE__ */ jsx("div", {
13
17
  slot: HEADER_PREFIX_SLOT_ID,
14
18
  children: prefix
15
- }),
16
- metadata != null && /* @__PURE__ */ jsx("div", {
19
+ }), metadata != null && /* @__PURE__ */ jsx("div", {
17
20
  slot: HEADER_METADATA_SLOT_ID,
18
21
  children: metadata
19
- }),
22
+ })] }),
20
23
  renderAnnotation != null && lineAnnotations?.map((annotation, index) => /* @__PURE__ */ jsx("div", {
21
24
  slot: getLineAnnotationName(annotation),
22
25
  children: renderAnnotation(annotation)
@@ -1 +1 @@
1
- {"version":3,"file":"renderFileChildren.js","names":[],"sources":["../../../src/react/utils/renderFileChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { GutterUtilitySlotStyles } from '../constants';\nimport type { FileProps } from '../types';\n\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: FileProps<LAnnotation>['renderHoverUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function renderFileChildren<LAnnotation>({\n file,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n renderHoverUtility,\n getHoveredLine,\n}: RenderFileChildrenProps<LAnnotation>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const prefix = renderHeaderPrefix?.(file);\n const metadata = renderHeaderMetadata?.(file);\n return (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,mBAAgC,EAC9C,MACA,oBACA,sBACA,kBACA,iBACA,qBACA,oBACA,kBACkD;CAClD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,SAAS,qBAAqB,KAAK;CACzC,MAAM,WAAW,uBAAuB,KAAK;AAC7C,QACE;EACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa;EAClE,YAAY,QAAQ,oBAAC;GAAI,MAAM;aAA0B;IAAe;EACxE,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,iBAAiB,QAChB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,cAAc,eAAe;IAC1B;KAEP"}
1
+ {"version":3,"file":"renderFileChildren.js","names":[],"sources":["../../../src/react/utils/renderFileChildren.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../../constants';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type { FileContents } from '../../types';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { GutterUtilitySlotStyles } from '../constants';\nimport type { FileProps } from '../types';\n\ninterface RenderFileChildrenProps<LAnnotation> {\n file: FileContents;\n renderCustomHeader: FileProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: FileProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: FileProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: FileProps<LAnnotation>['renderAnnotation'];\n lineAnnotations: FileProps<LAnnotation>['lineAnnotations'];\n renderGutterUtility: FileProps<LAnnotation>['renderGutterUtility'];\n renderHoverUtility: FileProps<LAnnotation>['renderHoverUtility'];\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function renderFileChildren<LAnnotation>({\n file,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n renderHoverUtility,\n getHoveredLine,\n}: RenderFileChildrenProps<LAnnotation>): ReactNode {\n const gutterUtility = renderGutterUtility ?? renderHoverUtility;\n const customHeader = renderCustomHeader?.(file);\n const prefix = renderHeaderPrefix?.(file);\n const metadata = renderHeaderMetadata?.(file);\n return (\n <>\n {customHeader != null ? (\n <div slot={CUSTOM_HEADER_SLOT_ID}>{customHeader}</div>\n ) : (\n <>\n {prefix != null && <div slot={HEADER_PREFIX_SLOT_ID}>{prefix}</div>}\n {metadata != null && (\n <div slot={HEADER_METADATA_SLOT_ID}>{metadata}</div>\n )}\n </>\n )}\n {renderAnnotation != null &&\n lineAnnotations?.map((annotation, index) => (\n <div key={index} slot={getLineAnnotationName(annotation)}>\n {renderAnnotation(annotation)}\n </div>\n ))}\n {gutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {gutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;AAyBA,SAAgB,mBAAgC,EAC9C,MACA,oBACA,oBACA,sBACA,kBACA,iBACA,qBACA,oBACA,kBACkD;CAClD,MAAM,gBAAgB,uBAAuB;CAC7C,MAAM,eAAe,qBAAqB,KAAK;CAC/C,MAAM,SAAS,qBAAqB,KAAK;CACzC,MAAM,WAAW,uBAAuB,KAAK;AAC7C,QACE;EACG,gBAAgB,OACf,oBAAC;GAAI,MAAM;aAAwB;IAAmB,GAEtD,4CACG,UAAU,QAAQ,oBAAC;GAAI,MAAM;aAAwB;IAAa,EAClE,YAAY,QACX,oBAAC;GAAI,MAAM;aAA0B;IAAe,IAErD;EAEJ,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC;GAAgB,MAAM,sBAAsB,WAAW;aACrD,iBAAiB,WAAW;KADrB,MAEJ,CACN;EACH,iBAAiB,QAChB,oBAAC;GAAI,MAAK;GAAsB,OAAO;aACpC,cAAc,eAAe;IAC1B;KAEP"}
@@ -1,33 +1,33 @@
1
- import { DiffLineAnnotation, FileContents, FileDiffMetadata, VirtualFileMetrics } from "../../types.js";
1
+ import { DiffLineAnnotation, FileDiffMetadata, VirtualFileMetrics } from "../../types.js";
2
2
  import { GetHoveredLineResult, SelectedLineRange } from "../../managers/InteractionManager.js";
3
3
  import { FileDiffOptions } from "../../components/FileDiff.js";
4
4
 
5
5
  //#region src/react/utils/useFileDiffInstance.d.ts
6
6
  interface UseFileDiffInstanceProps<LAnnotation> {
7
- oldFile?: FileContents;
8
- newFile?: FileContents;
9
- fileDiff?: FileDiffMetadata;
7
+ fileDiff: FileDiffMetadata;
10
8
  options: FileDiffOptions<LAnnotation> | undefined;
11
9
  lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;
12
10
  selectedLines: SelectedLineRange | null | undefined;
13
11
  prerenderedHTML: string | undefined;
14
12
  metrics?: VirtualFileMetrics;
15
13
  hasGutterRenderUtility: boolean;
14
+ hasCustomHeader: boolean;
15
+ disableWorkerPool: boolean;
16
16
  }
17
17
  interface UseFileDiffInstanceReturn {
18
18
  ref(node: HTMLElement | null): void;
19
19
  getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;
20
20
  }
21
21
  declare function useFileDiffInstance<LAnnotation>({
22
- oldFile,
23
- newFile,
24
22
  fileDiff,
25
23
  options,
26
24
  lineAnnotations,
27
25
  selectedLines,
28
26
  prerenderedHTML,
29
27
  metrics,
30
- hasGutterRenderUtility
28
+ hasGutterRenderUtility,
29
+ hasCustomHeader,
30
+ disableWorkerPool
31
31
  }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;
32
32
  //#endregion
33
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","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
+ {"version":3,"file":"useFileDiffInstance.d.ts","names":["FileDiffOptions","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileDiffMetadata","VirtualFileMetrics","UseFileDiffInstanceProps","LAnnotation","UseFileDiffInstanceReturn","HTMLElement","useFileDiffInstance","fileDiff","options","lineAnnotations","selectedLines","prerenderedHTML","metrics","hasGutterRenderUtility","hasCustomHeader","disableWorkerPool"],"sources":["../../../src/react/utils/useFileDiffInstance.d.ts"],"sourcesContent":["import { type FileDiffOptions } from '../../components/FileDiff';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileDiffMetadata, VirtualFileMetrics } from '../../types';\ninterface UseFileDiffInstanceProps<LAnnotation> {\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 hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\nexport declare function useFileDiffInstance<LAnnotation>({ fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileDiffInstance.d.ts.map"],"mappings":";;;;;UAGUM;YACIF;EADJE,OAAAA,EAEGN,eAFHM,CAEmBC,WAFKA,CAAAA,GAAAA,SAAAA;EACpBH,eAAAA,EAEOD,kBAFPC,CAE0BG,WAF1BH,CAAAA,EAAAA,GAAAA,SAAAA;EACeG,aAAAA,EAEVL,iBAFUK,GAAAA,IAAAA,GAAAA,SAAAA;EAAhBP,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC2BO,OAAAA,CAAAA,EAG1BF,kBAH0BE;EAAnBJ,sBAAAA,EAAAA,OAAAA;EACFD,eAAAA,EAAAA,OAAAA;EAELG,iBAAAA,EAAAA,OAAAA;;AAAkB,UAKtBG,yBAAAA,CAAyB;EAIXE,GAAAA,CAAAA,IAAAA,EAHVD,WAGUC,GAAmB,IAAA,CAAAH,EAAAA,IAAAA;EAAgBI,cAAAA,EAAAA,EAFrCV,oBAEqCU,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AAAmBE,iBAAtDH,mBAAsDG,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA,sBAAAA;EAAAA,eAAAA;EAAAA;AAAAA,CAAAA,EAAwHP,wBAAxHO,CAAiJN,WAAjJM,CAAAA,CAAAA,EAAgKL,yBAAhKK"}
@@ -9,19 +9,25 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "rea
9
9
 
10
10
  //#region src/react/utils/useFileDiffInstance.ts
11
11
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
12
- function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }) {
12
+ function useFileDiffInstance({ fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
13
13
  const simpleVirtualizer = useVirtualizer();
14
14
  const poolManager = useContext(WorkerPoolContext);
15
15
  const instanceRef = useRef(null);
16
16
  const ref = useStableCallback((fileContainer) => {
17
17
  if (fileContainer != null) {
18
18
  if (instanceRef.current != null) throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");
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);
19
+ if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFileDiff(mergeFileDiffOptions({
20
+ hasCustomHeader,
21
+ hasGutterRenderUtility,
22
+ options
23
+ }), simpleVirtualizer, metrics, !disableWorkerPool ? poolManager : void 0, true);
24
+ else instanceRef.current = new FileDiff(mergeFileDiffOptions({
25
+ hasCustomHeader,
26
+ hasGutterRenderUtility,
27
+ options
28
+ }), !disableWorkerPool ? poolManager : void 0, true);
21
29
  instanceRef.current.hydrate({
22
30
  fileDiff,
23
- oldFile,
24
- newFile,
25
31
  fileContainer,
26
32
  lineAnnotations,
27
33
  prerenderedHTML
@@ -35,14 +41,16 @@ function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotati
35
41
  useIsometricEffect(() => {
36
42
  const { current: instance } = instanceRef;
37
43
  if (instance == null) return;
38
- const newOptions = mergeFileDiffOptions(options, hasGutterRenderUtility);
44
+ const newOptions = mergeFileDiffOptions({
45
+ hasCustomHeader,
46
+ hasGutterRenderUtility,
47
+ options
48
+ });
39
49
  const forceRender = !areOptionsEqual(instance.options, newOptions);
40
50
  instance.setOptions(newOptions);
41
51
  instance.render({
42
52
  forceRender,
43
53
  fileDiff,
44
- oldFile,
45
- newFile,
46
54
  lineAnnotations
47
55
  });
48
56
  if (selectedLines !== void 0) instance.setSelectedLines(selectedLines);
@@ -54,10 +62,11 @@ function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotati
54
62
  }, [])
55
63
  };
56
64
  }
57
- function mergeFileDiffOptions(options, hasGutterRenderUtility) {
58
- if (hasGutterRenderUtility) return {
65
+ function mergeFileDiffOptions({ options, hasCustomHeader, hasGutterRenderUtility }) {
66
+ if (hasGutterRenderUtility || hasCustomHeader) return {
59
67
  ...options,
60
- renderGutterUtility: noopRender
68
+ renderCustomHeader: hasCustomHeader ? noopRender : void 0,
69
+ renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
61
70
  };
62
71
  return options;
63
72
  }
@@ -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 { 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"}
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 FileDiffMetadata,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender } 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 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 hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\n\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\n\nexport function useFileDiffInstance<LAnnotation>({\n fileDiff,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\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({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n simpleVirtualizer,\n metrics,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n } else {\n instanceRef.current = new FileDiff(\n mergeFileDiffOptions({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n }\n void instanceRef.current.hydrate({\n fileDiff,\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({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n });\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n forceRender,\n fileDiff,\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\ninterface MergeFileDiffOptionsProps<LAnnotation> {\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n if (hasGutterRenderUtility || hasCustomHeader) {\n return {\n ...options,\n renderCustomHeader: hasCustomHeader ? noopRender : undefined,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n }\n return options;\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,oBAAiC,EAC/C,UACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,qBACmE;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;IACnB;IACA;IACA;IACD,CAAC,EACF,mBACA,SACA,CAAC,oBAAoB,cAAc,QACnC,KACD;OAED,aAAY,UAAU,IAAI,SACxB,qBAAqB;IACnB;IACA;IACA;IACD,CAAC,EACF,CAAC,oBAAoB,cAAc,QACnC,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;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;GACtC;GACA;GACA;GACD,CAAC;EACF,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,WAAW;AAClE,WAAS,WAAW,WAAW;AAC/B,EAAK,SAAS,OAAO;GACnB;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;;AAShC,SAAS,qBAAkC,EACzC,SACA,iBACA,0BAGY;AACZ,KAAI,0BAA0B,gBAC5B,QAAO;EACL,GAAG;EACH,oBAAoB,kBAAkB,aAAa;EACnD,qBAAqB,yBAAyB,aAAa;EAC5D;AAEH,QAAO"}
@@ -11,6 +11,8 @@ interface UseFileInstanceProps<LAnnotation> {
11
11
  prerenderedHTML: string | undefined;
12
12
  metrics?: VirtualFileMetrics;
13
13
  hasGutterRenderUtility: boolean;
14
+ hasCustomHeader: boolean;
15
+ disableWorkerPool: boolean;
14
16
  }
15
17
  interface UseFileInstanceReturn {
16
18
  ref(node: HTMLElement | null): void;
@@ -23,7 +25,9 @@ declare function useFileInstance<LAnnotation>({
23
25
  selectedLines,
24
26
  prerenderedHTML,
25
27
  metrics,
26
- hasGutterRenderUtility
28
+ hasGutterRenderUtility,
29
+ hasCustomHeader,
30
+ disableWorkerPool
27
31
  }: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn;
28
32
  //#endregion
29
33
  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","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
+ {"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","hasCustomHeader","disableWorkerPool"],"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 hasCustomHeader: boolean;\n disableWorkerPool: 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, hasCustomHeader, disableWorkerPool }: 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;EACFF,eAAAA,EAAAA,OAAAA;EAELG,iBAAAA,EAAAA,OAAAA;;AAAkB,UAKtBG,qBAAAA,CAAqB;EAIPE,GAAAA,CAAAA,IAAAA,EAHVD,WAGyB,GAAA,IAAAF,CAAAA,EAAAA,IAAAA;EAAgBI,cAAAA,EAAAA,EAFjCV,oBAEiCU,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;;AAAeE,iBAA9CH,eAA8CG,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA,sBAAAA;EAAAA,eAAAA;EAAAA;AAAAA,CAAAA,EAAwHP,oBAAxHO,CAA6IN,WAA7IM,CAAAA,CAAAA,EAA4JL,qBAA5JK"}
@@ -9,15 +9,23 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "rea
9
9
 
10
10
  //#region src/react/utils/useFileInstance.ts
11
11
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
12
- function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }) {
12
+ function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
13
13
  const simpleVirtualizer = useVirtualizer();
14
14
  const poolManager = useContext(WorkerPoolContext);
15
15
  const instanceRef = useRef(null);
16
16
  const ref = useStableCallback((node) => {
17
17
  if (node != null) {
18
18
  if (instanceRef.current != null) throw new Error("File: An instance should not already exist when a node is created");
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);
19
+ if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFile(mergeFileOptions({
20
+ hasCustomHeader,
21
+ hasGutterRenderUtility,
22
+ options
23
+ }), simpleVirtualizer, metrics, !disableWorkerPool ? poolManager : void 0, true);
24
+ else instanceRef.current = new File(mergeFileOptions({
25
+ hasCustomHeader,
26
+ hasGutterRenderUtility,
27
+ options
28
+ }), !disableWorkerPool ? poolManager : void 0, true);
21
29
  instanceRef.current.hydrate({
22
30
  file,
23
31
  fileContainer: node,
@@ -32,7 +40,11 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
32
40
  });
33
41
  useIsometricEffect(() => {
34
42
  if (instanceRef.current == null) return;
35
- const newOptions = mergeFileOptions(options, hasGutterRenderUtility);
43
+ const newOptions = mergeFileOptions({
44
+ hasCustomHeader,
45
+ hasGutterRenderUtility,
46
+ options
47
+ });
36
48
  const forceRender = !areOptionsEqual(instanceRef.current.options, newOptions);
37
49
  instanceRef.current.setOptions(newOptions);
38
50
  instanceRef.current.render({
@@ -49,10 +61,11 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
49
61
  }, [])
50
62
  };
51
63
  }
52
- function mergeFileOptions(options, hasGutterRenderUtility) {
53
- if (hasGutterRenderUtility) return {
64
+ function mergeFileOptions({ options, hasCustomHeader, hasGutterRenderUtility }) {
65
+ if (hasGutterRenderUtility || hasCustomHeader) return {
54
66
  ...options,
55
- renderGutterUtility: noopRender
67
+ renderCustomHeader: hasCustomHeader ? noopRender : void 0,
68
+ renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
56
69
  };
57
70
  return options;
58
71
  }
@@ -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 { 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"}
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 } 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 hasCustomHeader: boolean;\n disableWorkerPool: 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 hasCustomHeader,\n disableWorkerPool,\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({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n simpleVirtualizer,\n metrics,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n } else {\n instanceRef.current = new File(\n mergeFileOptions({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\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({\n hasCustomHeader,\n hasGutterRenderUtility,\n options,\n });\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\ninterface MergeFileOptionsProps<LAnnotation> {\n options: FileOptions<LAnnotation> | undefined;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n}\n\nfunction mergeFileOptions<LAnnotation>({\n options,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileOptionsProps<LAnnotation>): FileOptions<LAnnotation> | undefined {\n if (hasGutterRenderUtility || hasCustomHeader) {\n return {\n ...options,\n renderCustomHeader: hasCustomHeader ? noopRender : undefined,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n }\n return options;\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,gBAA6B,EAC3C,MACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,qBAC2D;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;IACf;IACA;IACA;IACD,CAAC,EACF,mBACA,SACA,CAAC,oBAAoB,cAAc,QACnC,KACD;OAED,aAAY,UAAU,IAAI,KACxB,iBAAiB;IACf;IACA;IACA;IACD,CAAC,EACF,CAAC,oBAAoB,cAAc,QACnC,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;GAClC;GACA;GACA;GACD,CAAC;EACF,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;;AAShC,SAAS,iBAA8B,EACrC,SACA,iBACA,0BAC2E;AAC3E,KAAI,0BAA0B,gBAC5B,QAAO;EACL,GAAG;EACH,oBAAoB,kBAAkB,aAAa;EACnD,qBAAqB,yBAAyB,aAAa;EAC5D;AAEH,QAAO"}
@@ -13,6 +13,8 @@ interface UseUnresolvedFileInstanceProps<LAnnotation> {
13
13
  prerenderedHTML: string | undefined;
14
14
  hasConflictUtility: boolean;
15
15
  hasGutterRenderUtility: boolean;
16
+ hasCustomHeader: boolean;
17
+ disableWorkerPool: boolean;
16
18
  }
17
19
  interface UseUnresolvedFileInstanceReturn<LAnnotation> {
18
20
  fileDiff: FileDiffMetadata;
@@ -29,7 +31,9 @@ declare function useUnresolvedFileInstance<LAnnotation>({
29
31
  selectedLines,
30
32
  prerenderedHTML,
31
33
  hasConflictUtility,
32
- hasGutterRenderUtility
34
+ hasGutterRenderUtility,
35
+ hasCustomHeader,
36
+ disableWorkerPool
33
37
  }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;
34
38
  //#endregion
35
39
  export { useUnresolvedFileInstance };
@@ -1 +1 @@
1
- {"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictMarkerRow","MergeConflictDiffAction","UnresolvedFileReactOptions","UseUnresolvedFileInstanceProps","LAnnotation","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 { DiffLineAnnotation, FileContents, FileDiffMetadata, MergeConflictMarkerRow } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\nimport type { UnresolvedFileReactOptions } from '../UnresolvedFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUS;QACAL;EADAK,OAAAA,CAAAA,EAEID,0BAF0B,CAECE,WAFDA,CAAAA;EAC9BN,eAAAA,EAEWD,kBAFXC,CAE8BM,WAF9BN,CAAAA,EAAAA,GAAAA,SAAAA;EAC+BM,aAAAA,EAEtBR,iBAFsBQ,GAAAA,IAAAA,GAAAA,SAAAA;EAA3BF,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BE,kBAAAA,EAAAA,OAAAA;EAAnBP,sBAAAA,EAAAA,OAAAA;;UAMXQ,+BAL0B,CAAA,WAAA,CAAA,CAAA;EAK1BA,QAAAA,EACIN,gBADJM;EACIN,OAAAA,EAAAA,CACAE,uBADAF,GAAAA,SAAAA,CAAAA,EAAAA;EACAE,UAAAA,EACED,sBADFC,EAAAA;EACED,GAAAA,CAAAA,IAAAA,EACFM,WADEN,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACFM,cAAAA,EAAAA,EACQX,oBADRW,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACQX,WAAAA,EAAAA,EACHD,cADGC,CACYS,WADZT,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,EAE4JS,8BAF5JT,CAE2LU,WAF3LV,CAAAA,CAAAA,EAE0MW,+BAF1MX,CAE0OU,WAF1OV,CAAAA"}
1
+ {"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictMarkerRow","MergeConflictDiffAction","UnresolvedFileReactOptions","UseUnresolvedFileInstanceProps","LAnnotation","UseUnresolvedFileInstanceReturn","HTMLElement","useUnresolvedFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","hasConflictUtility","hasGutterRenderUtility","hasCustomHeader","disableWorkerPool"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.d.ts"],"sourcesContent":["import { UnresolvedFile } from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, MergeConflictMarkerRow } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\nimport type { UnresolvedFileReactOptions } from '../UnresolvedFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUS;QACAL;EADAK,OAAAA,CAAAA,EAEID,0BAF0B,CAECE,WAFDA,CAAAA;EAC9BN,eAAAA,EAEWD,kBAFXC,CAE8BM,WAF9BN,CAAAA,EAAAA,GAAAA,SAAAA;EAC+BM,aAAAA,EAEtBR,iBAFsBQ,GAAAA,IAAAA,GAAAA,SAAAA;EAA3BF,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BE,kBAAAA,EAAAA,OAAAA;EAAnBP,sBAAAA,EAAAA,OAAAA;EACFD,eAAAA,EAAAA,OAAAA;EAAiB,iBAAA,EAAA,OAAA;AAAA;UAO1BS,+BACIN,CAAAA,WAAAA,CAAAA,CAAAA;EACAE,QAAAA,EADAF,gBACAE;EACED,OAAAA,EAAAA,CADFC,uBACED,GAAAA,SAAAA,CAAAA,EAAAA;EACFM,UAAAA,EADEN,sBACFM,EAAAA;EACQX,GAAAA,CAAAA,IAAAA,EADRW,WACQX,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACYS,cAAAA,EAAAA,EADZT,oBACYS,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EAAfV,WAAAA,EAAAA,EAAAA,cAAAA,CAAeU,WAAfV,CAAAA,GAAAA,SAAAA;;AAEKa,iBAAAA,yBAAyBH,CAAAA,WAAA,CAAA,CAAA;EAAA,IAAA;EAAA,OAAA;EAAA,eAAA;EAAA,aAAA;EAAA,eAAA;EAAA,kBAAA;EAAA,sBAAA;EAAA,eAAA;EAAA;AAAA,CAAA,EAAkKD,8BAAlK,CAAiMC,WAAjM,CAAA,CAAA,EAAgNC,+BAAhN,CAAgPD,WAAhP,CAAA"}
@@ -8,7 +8,7 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState }
8
8
 
9
9
  //#region src/react/utils/useUnresolvedFileInstance.ts
10
10
  const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
11
- function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }) {
11
+ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
12
12
  const [{ fileDiff, actions, markerRows }, setState] = useState(() => {
13
13
  const { fileDiff: fileDiff$1, actions: actions$1, markerRows: markerRows$1 } = parseMergeConflictDiffFromFile(file, options?.maxContextLines);
14
14
  return {
@@ -33,7 +33,13 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
33
33
  const ref = useStableCallback((fileContainer) => {
34
34
  if (fileContainer != null) {
35
35
  if (instanceRef.current != null) throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");
36
- instanceRef.current = new UnresolvedFile(mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility), poolManager, true);
36
+ instanceRef.current = new UnresolvedFile(mergeUnresolvedOptions({
37
+ hasConflictUtility,
38
+ hasCustomHeader,
39
+ hasGutterRenderUtility,
40
+ onMergeConflictAction,
41
+ options
42
+ }), !disableWorkerPool ? poolManager : void 0, true);
37
43
  instanceRef.current.hydrate({
38
44
  fileDiff,
39
45
  actions,
@@ -51,7 +57,13 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
51
57
  useIsometricEffect(() => {
52
58
  if (instanceRef.current == null) return;
53
59
  const instance = instanceRef.current;
54
- const newOptions = mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility);
60
+ const newOptions = mergeUnresolvedOptions({
61
+ hasConflictUtility,
62
+ hasCustomHeader,
63
+ hasGutterRenderUtility,
64
+ onMergeConflictAction,
65
+ options
66
+ });
55
67
  const forceRender = !areOptionsEqual(instance.options, newOptions);
56
68
  instance.setOptions(newOptions);
57
69
  instance.render({
@@ -76,12 +88,13 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
76
88
  }, [])
77
89
  };
78
90
  }
79
- function mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility) {
91
+ function mergeUnresolvedOptions({ options, onMergeConflictAction, hasConflictUtility, hasCustomHeader, hasGutterRenderUtility }) {
80
92
  return {
81
93
  ...options,
82
94
  onMergeConflictAction,
83
95
  hunkSeparators: options?.hunkSeparators === "custom" ? noopRender : options?.hunkSeparators,
84
96
  mergeConflictActionsType: hasConflictUtility || options?.mergeConflictActionsType === "custom" ? noopRender : options?.mergeConflictActionsType,
97
+ renderCustomHeader: hasCustomHeader ? noopRender : void 0,
85
98
  renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
86
99
  };
87
100
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useUnresolvedFileInstance.js","names":["fileDiff","actions","markerRows","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 {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport {\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { noopRender } from '../constants';\nimport type { UnresolvedFileReactOptions } from '../UnresolvedFile';\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?: UnresolvedFileReactOptions<LAnnotation>;\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 | undefined)[];\n markerRows: MergeConflictMarkerRow[];\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, markerRows }, setState] = useState(() => {\n const { fileDiff, actions, markerRows } = parseMergeConflictDiffFromFile(\n file,\n options?.maxContextLines\n );\n return { fileDiff, actions, markerRows };\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 onMergeConflictAction = useStableCallback(\n (\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ) => {\n setState((prevState) => {\n const { fileDiff, actions, markerRows } =\n instance.resolveConflict(\n payload.conflict.conflictIndex,\n payload.resolution,\n prevState.fileDiff\n ) ?? {};\n if (fileDiff == null || actions == null || markerRows == null) {\n return prevState;\n } else {\n return { fileDiff, actions, markerRows };\n }\n });\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 markerRows,\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 markerRows,\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, markerRows, getInstance };\n}\n\nfunction mergeUnresolvedOptions<LAnnotation>(\n options: UnresolvedFileReactOptions<LAnnotation> | 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":";;;;;;;;;AAmCA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAqB9C,SAAgB,0BAAuC,EACrD,MACA,SACA,iBACA,eACA,iBACA,oBACA,0BAC4F;CAC5F,MAAM,CAAC,EAAE,UAAU,SAAS,cAAc,YAAY,eAAe;EACnE,MAAM,EAAE,sBAAU,oBAAS,6BAAe,+BACxC,MACA,SAAS,gBACV;AACD,SAAO;GAAE;GAAU;GAAS;GAAY;GACxC;CAIF,MAAM,wBAAwB,mBAE1B,SACA,aACG;AACH,YAAU,cAAc;GACtB,MAAM,EAAE,sBAAU,oBAAS,6BACzB,SAAS,gBACP,QAAQ,SAAS,eACjB,QAAQ,YACR,UAAU,SACX,IAAI,EAAE;AACT,OAAIA,cAAY,QAAQC,aAAW,QAAQC,gBAAc,KACvD,QAAO;OAEP,QAAO;IAAE;IAAU;IAAS;IAAY;IAE1C;GAEL;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,IAAIC,eACxB,uBACE,SACA,uBACA,oBACA,uBACD,EACD,aACA,KACD;AACD,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;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;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;EAAY,aAJzC,kBAAkB;AACpC,UAAO,YAAY,WAAW;KAC7B,EAAE,CAAC;EAEoE;;AAG5E,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
+ {"version":3,"file":"useUnresolvedFileInstance.js","names":["fileDiff","actions","markerRows","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 {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport {\n type MergeConflictDiffAction,\n parseMergeConflictDiffFromFile,\n} from '../../utils/parseMergeConflictDiffFromFile';\nimport { noopRender } from '../constants';\nimport type { UnresolvedFileReactOptions } from '../UnresolvedFile';\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?: UnresolvedFileReactOptions<LAnnotation>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n}\n\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: (MergeConflictDiffAction | undefined)[];\n markerRows: MergeConflictMarkerRow[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\n\nexport function useUnresolvedFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\n}: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation> {\n const [{ fileDiff, actions, markerRows }, setState] = useState(() => {\n const { fileDiff, actions, markerRows } = parseMergeConflictDiffFromFile(\n file,\n options?.maxContextLines\n );\n return { fileDiff, actions, markerRows };\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 onMergeConflictAction = useStableCallback(\n (\n payload: MergeConflictActionPayload,\n instance: UnresolvedFile<LAnnotation>\n ) => {\n setState((prevState) => {\n const { fileDiff, actions, markerRows } =\n instance.resolveConflict(\n payload.conflict.conflictIndex,\n payload.resolution,\n prevState.fileDiff\n ) ?? {};\n if (fileDiff == null || actions == null || markerRows == null) {\n return prevState;\n } else {\n return { fileDiff, actions, markerRows };\n }\n });\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 hasConflictUtility,\n hasCustomHeader,\n hasGutterRenderUtility,\n onMergeConflictAction,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n void instanceRef.current.hydrate({\n fileDiff,\n actions,\n markerRows,\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 hasConflictUtility,\n hasCustomHeader,\n hasGutterRenderUtility,\n onMergeConflictAction,\n options,\n });\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n fileDiff,\n actions,\n markerRows,\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, markerRows, getInstance };\n}\n\ninterface MergeUnresolvedOptionsProps<LAnnotation> {\n options: UnresolvedFileReactOptions<LAnnotation> | undefined;\n onMergeConflictAction: UnresolvedFileOptions<LAnnotation>['onMergeConflictAction'];\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n}\n\nfunction mergeUnresolvedOptions<LAnnotation>({\n options,\n onMergeConflictAction,\n hasConflictUtility,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeUnresolvedOptionsProps<LAnnotation>): 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 renderCustomHeader: hasCustomHeader ? noopRender : undefined,\n renderGutterUtility: hasGutterRenderUtility ? noopRender : undefined,\n };\n}\n"],"mappings":";;;;;;;;;AAmCA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAuB9C,SAAgB,0BAAuC,EACrD,MACA,SACA,iBACA,eACA,iBACA,oBACA,wBACA,iBACA,qBAC4F;CAC5F,MAAM,CAAC,EAAE,UAAU,SAAS,cAAc,YAAY,eAAe;EACnE,MAAM,EAAE,sBAAU,oBAAS,6BAAe,+BACxC,MACA,SAAS,gBACV;AACD,SAAO;GAAE;GAAU;GAAS;GAAY;GACxC;CAIF,MAAM,wBAAwB,mBAE1B,SACA,aACG;AACH,YAAU,cAAc;GACtB,MAAM,EAAE,sBAAU,oBAAS,6BACzB,SAAS,gBACP,QAAQ,SAAS,eACjB,QAAQ,YACR,UAAU,SACX,IAAI,EAAE;AACT,OAAIA,cAAY,QAAQC,aAAW,QAAQC,gBAAc,KACvD,QAAO;OAEP,QAAO;IAAE;IAAU;IAAS;IAAY;IAE1C;GAEL;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,IAAIC,eACxB,uBAAuB;IACrB;IACA;IACA;IACA;IACA;IACD,CAAC,EACF,CAAC,oBAAoB,cAAc,QACnC,KACD;AACD,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;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,uBAAuB;GACxC;GACA;GACA;GACA;GACA;GACD,CAAC;EACF,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;AAYF,QAAO;EAAE;EAAK,gBAVS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAMwB;EAAU;EAAS;EAAY,aAJzC,kBAAkB;AACpC,UAAO,YAAY,WAAW;KAC7B,EAAE,CAAC;EAEoE;;AAW5E,SAAS,uBAAoC,EAC3C,SACA,uBACA,oBACA,iBACA,0BAC+E;AAC/E,QAAO;EACL,GAAG;EACH;EACA,gBACE,SAAS,mBAAmB,WACxB,aACA,SAAS;EAEf,0BACE,sBAAsB,SAAS,6BAA6B,WACxD,aACA,SAAS;EACf,oBAAoB,kBAAkB,aAAa;EACnD,qBAAqB,yBAAyB,aAAa;EAC5D"}