@pierre/diffs 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/File.d.ts +9 -5
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +12 -3
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +7 -3
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +12 -3
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +2 -1
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +8 -4
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/managers/InteractionManager.d.ts +2 -2
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/react/File.js +2 -1
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.js +2 -1
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.js +2 -1
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.js +2 -1
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +6 -2
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +2 -1
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/constants.d.ts +2 -1
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/constants.js +4 -1
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +2 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +3 -1
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +14 -5
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +3 -1
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +14 -5
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +3 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +8 -7
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/package.json +1 -1
package/dist/react/FileDiff.js
CHANGED
|
@@ -15,7 +15,8 @@ function FileDiff({ fileDiff, options, metrics, lineAnnotations, selectedLines,
|
|
|
15
15
|
metrics,
|
|
16
16
|
lineAnnotations,
|
|
17
17
|
selectedLines,
|
|
18
|
-
prerenderedHTML
|
|
18
|
+
prerenderedHTML,
|
|
19
|
+
hasGutterRenderUtility: renderGutterUtility != null || renderHoverUtility != null
|
|
19
20
|
});
|
|
20
21
|
return /* @__PURE__ */ jsx(DIFFS_TAG_NAME, {
|
|
21
22
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDiff.js","names":[],"sources":["../../src/react/FileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileDiffMetadata };\n\nexport interface FileDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n fileDiff: FileDiffMetadata;\n}\n\nexport function FileDiff<LAnnotation = undefined>({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n}: FileDiffProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileDiffInstance({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n lineAnnotations,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,SAAkC,EAChD,UACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,sBACgD;CAChD,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;
|
|
1
|
+
{"version":3,"file":"FileDiff.js","names":[],"sources":["../../src/react/FileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileDiffMetadata };\n\nexport interface FileDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n fileDiff: FileDiffMetadata;\n}\n\nexport function FileDiff<LAnnotation = undefined>({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n}: FileDiffProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileDiffInstance({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasGutterRenderUtility:\n renderGutterUtility != null || renderHoverUtility != null,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n lineAnnotations,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,SAAkC,EAChD,UACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,sBACgD;CAChD,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;EACA,wBACE,uBAAuB,QAAQ,sBAAsB;EACxD,CAAC;AAWF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAZY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
|
@@ -16,7 +16,8 @@ function MultiFileDiff({ oldFile, newFile, options, metrics, lineAnnotations, se
|
|
|
16
16
|
metrics,
|
|
17
17
|
lineAnnotations,
|
|
18
18
|
selectedLines,
|
|
19
|
-
prerenderedHTML
|
|
19
|
+
prerenderedHTML,
|
|
20
|
+
hasGutterRenderUtility: renderGutterUtility != null || renderHoverUtility != null
|
|
20
21
|
});
|
|
21
22
|
return /* @__PURE__ */ jsx(DIFFS_TAG_NAME, {
|
|
22
23
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiFileDiff.js","names":[],"sources":["../../src/react/MultiFileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileContents } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileContents };\n\nexport interface MultiFileDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n oldFile: FileContents;\n newFile: FileContents;\n}\n\nexport function MultiFileDiff<LAnnotation = undefined>({\n oldFile,\n newFile,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n}: MultiFileDiffProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileDiffInstance({\n oldFile,\n newFile,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderDiffChildren({\n deletionFile: oldFile,\n additionFile: newFile,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAgB,cAAuC,EACrD,SACA,SACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,sBACqD;CACrD,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;EACA;
|
|
1
|
+
{"version":3,"file":"MultiFileDiff.js","names":[],"sources":["../../src/react/MultiFileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileContents } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileContents };\n\nexport interface MultiFileDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n oldFile: FileContents;\n newFile: FileContents;\n}\n\nexport function MultiFileDiff<LAnnotation = undefined>({\n oldFile,\n newFile,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n}: MultiFileDiffProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileDiffInstance({\n oldFile,\n newFile,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasGutterRenderUtility:\n renderGutterUtility != null || renderHoverUtility != null,\n });\n const children = renderDiffChildren({\n deletionFile: oldFile,\n additionFile: newFile,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAgB,cAAuC,EACrD,SACA,SACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,sBACqD;CACrD,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;EACA;EACA,wBACE,uBAAuB,QAAQ,sBAAsB;EACxD,CAAC;AAYF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAbY,mBAAmB;GAClC,cAAc;GACd,cAAc;GACd;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
package/dist/react/PatchDiff.js
CHANGED
|
@@ -18,7 +18,8 @@ function PatchDiff({ patch, options, metrics, lineAnnotations, selectedLines, cl
|
|
|
18
18
|
metrics,
|
|
19
19
|
lineAnnotations,
|
|
20
20
|
selectedLines,
|
|
21
|
-
prerenderedHTML
|
|
21
|
+
prerenderedHTML,
|
|
22
|
+
hasGutterRenderUtility: renderGutterUtility != null || renderHoverUtility != null
|
|
22
23
|
});
|
|
23
24
|
return /* @__PURE__ */ jsx(DIFFS_TAG_NAME, {
|
|
24
25
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PatchDiff.js","names":[],"sources":["../../src/react/PatchDiff.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport { getSingularPatch } from '../utils/getSingularPatch';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport interface PatchDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n patch: string;\n}\n\nexport function PatchDiff<LAnnotation = undefined>({\n patch,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n}: PatchDiffProps<LAnnotation>): React.JSX.Element {\n const fileDiff = usePatch(patch);\n const { ref, getHoveredLine } = useFileDiffInstance({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n\nfunction usePatch(patch: string): FileDiffMetadata {\n return useMemo<FileDiffMetadata>(() => getSingularPatch(patch), [patch]);\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,UAAmC,EACjD,OACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,sBACiD;CACjD,MAAM,WAAW,SAAS,MAAM;CAChC,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;
|
|
1
|
+
{"version":3,"file":"PatchDiff.js","names":[],"sources":["../../src/react/PatchDiff.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport { getSingularPatch } from '../utils/getSingularPatch';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport interface PatchDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n patch: string;\n}\n\nexport function PatchDiff<LAnnotation = undefined>({\n patch,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n}: PatchDiffProps<LAnnotation>): React.JSX.Element {\n const fileDiff = usePatch(patch);\n const { ref, getHoveredLine } = useFileDiffInstance({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasGutterRenderUtility:\n renderGutterUtility != null || renderHoverUtility != null,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderGutterUtility,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n\nfunction usePatch(patch: string): FileDiffMetadata {\n return useMemo<FileDiffMetadata>(() => getSingularPatch(patch), [patch]);\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,UAAmC,EACjD,OACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,sBACiD;CACjD,MAAM,WAAW,SAAS,MAAM;CAChC,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;EACA,wBACE,uBAAuB,QAAQ,sBAAsB;EACxD,CAAC;AAWF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAZY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B;;AAIrB,SAAS,SAAS,OAAiC;AACjD,QAAO,cAAgC,iBAAiB,MAAM,EAAE,CAAC,MAAM,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { MergeConflictDiffAction } from "../utils/parseMergeConflictDiffFromFile
|
|
|
3
3
|
import { UnresolvedFileHunksRendererOptions } from "../renderers/UnresolvedFileHunksRenderer.js";
|
|
4
4
|
import { UnresolvedFile as UnresolvedFile$1 } from "../components/UnresolvedFile.js";
|
|
5
5
|
import { FileDiffProps } from "./FileDiff.js";
|
|
6
|
+
import { FileDiffOptions } from "../components/FileDiff.js";
|
|
6
7
|
import { ReactNode } from "react";
|
|
7
8
|
|
|
8
9
|
//#region src/react/UnresolvedFile.d.ts
|
|
@@ -11,9 +12,12 @@ interface RenderMergeConflictActionContext {
|
|
|
11
12
|
}
|
|
12
13
|
type RenderMergeConflictActions = (action: MergeConflictDiffAction, context: RenderMergeConflictActionContext) => ReactNode;
|
|
13
14
|
type MergeConflictActionsTypeOption = 'none' | 'default' | RenderMergeConflictActions;
|
|
15
|
+
interface UnresolvedFileReactOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'>, UnresolvedFileHunksRendererOptions {
|
|
16
|
+
onPostRender?(node: HTMLElement, instance: UnresolvedFile$1<LAnnotation>): unknown;
|
|
17
|
+
}
|
|
14
18
|
interface UnresolvedFileProps<LAnnotation> extends Omit<FileDiffProps<LAnnotation>, 'fileDiff' | 'options'> {
|
|
15
19
|
file: FileContents;
|
|
16
|
-
options?:
|
|
20
|
+
options?: UnresolvedFileReactOptions<LAnnotation>;
|
|
17
21
|
renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => UnresolvedFile$1<LAnnotation> | undefined): ReactNode;
|
|
18
22
|
}
|
|
19
23
|
declare function UnresolvedFile<LAnnotation = undefined>({
|
|
@@ -32,5 +36,5 @@ declare function UnresolvedFile<LAnnotation = undefined>({
|
|
|
32
36
|
renderMergeConflictUtility
|
|
33
37
|
}: UnresolvedFileProps<LAnnotation>): React.JSX.Element;
|
|
34
38
|
//#endregion
|
|
35
|
-
export { MergeConflictActionsTypeOption, RenderMergeConflictActionContext, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileProps };
|
|
39
|
+
export { MergeConflictActionsTypeOption, RenderMergeConflictActionContext, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions };
|
|
36
40
|
//# sourceMappingURL=UnresolvedFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.d.ts","names":["ReactNode","UnresolvedFile","UnresolvedFileClass","UnresolvedFileHunksRendererOptions","FileContents","MergeConflictResolution","MergeConflictDiffAction","FileDiffProps","RenderMergeConflictActionContext","RenderMergeConflictActions","MergeConflictActionsTypeOption","
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.d.ts","names":["ReactNode","FileDiffOptions","UnresolvedFile","UnresolvedFileClass","UnresolvedFileHunksRendererOptions","FileContents","MergeConflictResolution","MergeConflictDiffAction","FileDiffProps","RenderMergeConflictActionContext","RenderMergeConflictActions","MergeConflictActionsTypeOption","UnresolvedFileReactOptions","LAnnotation","HTMLElement","Omit","UnresolvedFileProps","file","options","lineAnnotations","selectedLines","className","style","prerenderedHTML","renderAnnotation","renderHeaderPrefix","renderHeaderMetadata","renderGutterUtility","renderHoverUtility","renderMergeConflictUtility","React","JSX","Element"],"sources":["../../src/react/UnresolvedFile.d.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\nexport type RenderMergeConflictActions = (action: MergeConflictDiffAction, context: RenderMergeConflictActionContext) => ReactNode;\nexport type MergeConflictActionsTypeOption = 'none' | 'default' | RenderMergeConflictActions;\nexport interface UnresolvedFileReactOptions<LAnnotation> extends Omit<FileDiffOptions<LAnnotation>, 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'>, UnresolvedFileHunksRendererOptions {\n onPostRender?(node: HTMLElement, instance: UnresolvedFileClass<LAnnotation>): unknown;\n}\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<FileDiffProps<LAnnotation>, 'fileDiff' | 'options'> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n renderMergeConflictUtility?(action: MergeConflictDiffAction, getInstance: () => UnresolvedFileClass<LAnnotation> | undefined): ReactNode;\n}\nexport declare function UnresolvedFile<LAnnotation = undefined>({ file, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderPrefix, renderHeaderMetadata, renderGutterUtility, renderHoverUtility, renderMergeConflictUtility }: UnresolvedFileProps<LAnnotation>): React.JSX.Element;\n//# sourceMappingURL=UnresolvedFile.d.ts.map"],"mappings":";;;;;;;;;UAOiBS,gCAAAA;8BACeH;AADhC;AAGYI,KAAAA,0BAAAA,GAA0B,CAAA,MAAA,EAAYH,uBAAZ,EAAA,OAAA,EAA8CE,gCAA9C,EAAA,GAAmFT,SAAnF;AAAYO,KACtCI,8BAAAA,GADsCJ,MAAAA,GAAAA,SAAAA,GACgBG,0BADhBH;AAAkCE,UAEnEG,0BAFmEH,CAAAA,WAAAA,CAAAA,SAEnBM,IAFmBN,CAEdR,eAFcQ,CAEEI,WAFFJ,CAAAA,EAAAA,gBAAAA,GAAAA,WAAAA,GAAAA,uBAAAA,GAAAA,cAAAA,CAAAA,EAE4FL,kCAF5FK,CAAAA;EAAqCT,YAAAA,EAAAA,IAAAA,EAGjGc,WAHiGd,EAAAA,QAAAA,EAG1EG,gBAH0EH,CAGtDa,WAHsDb,CAAAA,CAAAA,EAAAA,OAAAA;;AAC7GW,UAIKK,mBAJLL,CAA8B,WAAA,CAAA,SAIgBI,IAJQL,CAIHF,aAJGE,CAIWG,WAJe,CAAA,EAAA,UAAA,GAAA,SAAA,CAAA,CAAA;EAC3ED,IAAAA,EAIPP,YAJOO;EAAqEC,OAAAA,CAAAA,EAKxED,0BALwEC,CAK7CA,WAL6CA,CAAAA;EAAhBZ,0BAAAA,EAAAA,MAAAA,EAM9BM,uBAN8BN,EAAAA,WAAAA,EAAAA,GAAAA,GAMcE,gBANdF,CAMkCY,WANlCZ,CAAAA,GAAAA,SAAAA,CAAAA,EAM6DD,SAN7DC;;AACHY,iBAO3CX,cAP2CW,CAAAA,cAAAA,SAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,SAAAA;EAAAA,KAAAA;EAAAA,eAAAA;EAAAA,gBAAAA;EAAAA,kBAAAA;EAAAA,oBAAAA;EAAAA,mBAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAOoNG,mBAPpNH,CAOwOA,WAPxOA,CAAAA,CAAAA,EAOuPiB,KAAAA,CAAMC,GAAAA,CAAIC,OAPjQnB"}
|
|
@@ -15,7 +15,8 @@ function UnresolvedFile({ file, options, lineAnnotations, selectedLines, classNa
|
|
|
15
15
|
lineAnnotations,
|
|
16
16
|
selectedLines,
|
|
17
17
|
prerenderedHTML,
|
|
18
|
-
hasConflictUtility: renderMergeConflictUtility != null
|
|
18
|
+
hasConflictUtility: renderMergeConflictUtility != null,
|
|
19
|
+
hasGutterRenderUtility: renderGutterUtility != null || renderHoverUtility != null
|
|
19
20
|
});
|
|
20
21
|
return /* @__PURE__ */ jsx(DIFFS_TAG_NAME, {
|
|
21
22
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnresolvedFile.js","names":[],"sources":["../../src/react/UnresolvedFile.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\n\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useUnresolvedFileInstance } from './utils/useUnresolvedFileInstance';\n\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\n\nexport type RenderMergeConflictActions = (\n action: MergeConflictDiffAction,\n context: RenderMergeConflictActionContext\n) => ReactNode;\n\nexport type MergeConflictActionsTypeOption =\n | 'none'\n | 'default'\n | RenderMergeConflictActions;\n\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<\n FileDiffProps<LAnnotation>,\n 'fileDiff' | 'options'\n> {\n file: FileContents;\n options?:
|
|
1
|
+
{"version":3,"file":"UnresolvedFile.js","names":[],"sources":["../../src/react/UnresolvedFile.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\n\nimport type { FileDiffOptions } from '../components/FileDiff';\nimport type { UnresolvedFile as UnresolvedFileClass } from '../components/UnresolvedFile';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { UnresolvedFileHunksRendererOptions } from '../renderers/UnresolvedFileHunksRenderer';\nimport type { FileContents, MergeConflictResolution } from '../types';\nimport { type MergeConflictDiffAction } from '../utils/parseMergeConflictDiffFromFile';\nimport type { FileDiffProps } from './FileDiff';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useUnresolvedFileInstance } from './utils/useUnresolvedFileInstance';\n\nexport interface RenderMergeConflictActionContext {\n resolveConflict(resolution: MergeConflictResolution): void;\n}\n\nexport type RenderMergeConflictActions = (\n action: MergeConflictDiffAction,\n context: RenderMergeConflictActionContext\n) => ReactNode;\n\nexport type MergeConflictActionsTypeOption =\n | 'none'\n | 'default'\n | RenderMergeConflictActions;\n\nexport interface UnresolvedFileReactOptions<LAnnotation>\n extends\n Omit<\n FileDiffOptions<LAnnotation>,\n 'hunkSeparators' | 'diffStyle' | 'onMergeConflictAction' | 'onPostRender'\n >,\n UnresolvedFileHunksRendererOptions {\n onPostRender?(\n node: HTMLElement,\n instance: UnresolvedFileClass<LAnnotation>\n ): unknown;\n}\n\nexport interface UnresolvedFileProps<LAnnotation> extends Omit<\n FileDiffProps<LAnnotation>,\n 'fileDiff' | 'options'\n> {\n file: FileContents;\n options?: UnresolvedFileReactOptions<LAnnotation>;\n renderMergeConflictUtility?(\n action: MergeConflictDiffAction,\n getInstance: () => UnresolvedFileClass<LAnnotation> | undefined\n ): ReactNode;\n}\n\nexport function UnresolvedFile<LAnnotation = undefined>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderGutterUtility,\n renderHoverUtility,\n renderMergeConflictUtility,\n}: UnresolvedFileProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine, fileDiff, actions, getInstance } =\n useUnresolvedFileInstance({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n hasConflictUtility: renderMergeConflictUtility != null,\n hasGutterRenderUtility:\n renderGutterUtility != null || renderHoverUtility != null,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n renderHoverUtility,\n lineAnnotations,\n getHoveredLine,\n actions,\n renderMergeConflictUtility,\n getInstance,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAsDA,SAAgB,eAAwC,EACtD,MACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,oBACA,sBACA,qBACA,oBACA,8BACsD;CACtD,MAAM,EAAE,KAAK,gBAAgB,UAAU,SAAS,gBAC9C,0BAA0B;EACxB;EACA;EACA;EACA;EACA;EACA,oBAAoB,8BAA8B;EAClD,wBACE,uBAAuB,QAAQ,sBAAsB;EACxD,CAAC;AAcJ,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAfY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
|
@@ -3,6 +3,7 @@ import { CSSProperties } from "react";
|
|
|
3
3
|
//#region src/react/constants.d.ts
|
|
4
4
|
declare const GutterUtilitySlotStyles: CSSProperties;
|
|
5
5
|
declare const MergeConflictSlotStyles: CSSProperties;
|
|
6
|
+
declare function noopRender(): null;
|
|
6
7
|
//#endregion
|
|
7
|
-
export { GutterUtilitySlotStyles, MergeConflictSlotStyles };
|
|
8
|
+
export { GutterUtilitySlotStyles, MergeConflictSlotStyles, noopRender };
|
|
8
9
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":["CSSProperties","GutterUtilitySlotStyles","MergeConflictSlotStyles"],"sources":["../../src/react/constants.d.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nexport declare const GutterUtilitySlotStyles: CSSProperties;\nexport declare const MergeConflictSlotStyles: CSSProperties;\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;;cACqBC,yBAAyBD;cACzBE,yBAAyBF"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":["CSSProperties","GutterUtilitySlotStyles","MergeConflictSlotStyles","noopRender"],"sources":["../../src/react/constants.d.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nexport declare const GutterUtilitySlotStyles: CSSProperties;\nexport declare const MergeConflictSlotStyles: CSSProperties;\nexport declare function noopRender(): null;\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;;cACqBC,yBAAyBD;cACzBE,yBAAyBF;AADzBC,iBAEGE,UAAAA,CAAAA,CAFmC,EAAA,IAAA"}
|
package/dist/react/constants.js
CHANGED
|
@@ -6,7 +6,10 @@ const GutterUtilitySlotStyles = {
|
|
|
6
6
|
textAlign: "center"
|
|
7
7
|
};
|
|
8
8
|
const MergeConflictSlotStyles = { display: "contents" };
|
|
9
|
+
function noopRender() {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
9
12
|
|
|
10
13
|
//#endregion
|
|
11
|
-
export { GutterUtilitySlotStyles, MergeConflictSlotStyles };
|
|
14
|
+
export { GutterUtilitySlotStyles, MergeConflictSlotStyles, noopRender };
|
|
12
15
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["GutterUtilitySlotStyles: CSSProperties","MergeConflictSlotStyles: CSSProperties"],"sources":["../../src/react/constants.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport const GutterUtilitySlotStyles: CSSProperties = {\n position: 'absolute',\n top: 0,\n bottom: 0,\n textAlign: 'center',\n};\n\nexport const MergeConflictSlotStyles: CSSProperties = {\n display: 'contents',\n};\n"],"mappings":";AAEA,MAAaA,0BAAyC;CACpD,UAAU;CACV,KAAK;CACL,QAAQ;CACR,WAAW;CACZ;AAED,MAAaC,0BAAyC,EACpD,SAAS,YACV"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":["GutterUtilitySlotStyles: CSSProperties","MergeConflictSlotStyles: CSSProperties"],"sources":["../../src/react/constants.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport const GutterUtilitySlotStyles: CSSProperties = {\n position: 'absolute',\n top: 0,\n bottom: 0,\n textAlign: 'center',\n};\n\nexport const MergeConflictSlotStyles: CSSProperties = {\n display: 'contents',\n};\n\nexport function noopRender() {\n return null;\n}\n"],"mappings":";AAEA,MAAaA,0BAAyC;CACpD,UAAU;CACV,KAAK;CACL,QAAQ;CACR,WAAW;CACZ;AAED,MAAaC,0BAAyC,EACpD,SAAS,YACV;AAED,SAAgB,aAAa;AAC3B,QAAO"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -4,16 +4,16 @@ import { FileOptions } from "../components/File.js";
|
|
|
4
4
|
import { DiffBasePropsReact, FileProps } from "./types.js";
|
|
5
5
|
import { File } from "./File.js";
|
|
6
6
|
import { FileDiff, FileDiffProps } from "./FileDiff.js";
|
|
7
|
-
import { MergeConflictActionsTypeOption, RenderMergeConflictActionContext, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileProps } from "./UnresolvedFile.js";
|
|
7
|
+
import { MergeConflictActionsTypeOption, RenderMergeConflictActionContext, RenderMergeConflictActions, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions } from "./UnresolvedFile.js";
|
|
8
8
|
import { MultiFileDiff, MultiFileDiffProps } from "./MultiFileDiff.js";
|
|
9
9
|
import { PatchDiff, PatchDiffProps } from "./PatchDiff.js";
|
|
10
10
|
import { Virtualizer, VirtualizerContext, useVirtualizer } from "./Virtualizer.js";
|
|
11
11
|
import { WorkerPoolContext, WorkerPoolContextProvider, useWorkerPool } from "./WorkerPoolContext.js";
|
|
12
|
-
import { GutterUtilitySlotStyles, MergeConflictSlotStyles } from "./constants.js";
|
|
12
|
+
import { GutterUtilitySlotStyles, MergeConflictSlotStyles, noopRender } from "./constants.js";
|
|
13
13
|
import { renderDiffChildren } from "./utils/renderDiffChildren.js";
|
|
14
14
|
import { renderFileChildren } from "./utils/renderFileChildren.js";
|
|
15
15
|
import { templateRender } from "./utils/templateRender.js";
|
|
16
16
|
import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
|
|
17
17
|
import { useFileInstance } from "./utils/useFileInstance.js";
|
|
18
18
|
import { useStableCallback } from "./utils/useStableCallback.js";
|
|
19
|
-
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ContextContent, CustomPreProperties, DecorationItem, DiffBasePropsReact, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, UnresolvedFile, UnresolvedFileProps, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
|
|
19
|
+
export { AnnotationLineMap, AnnotationSide, AnnotationSpan, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, ContextContent, CustomPreProperties, DecorationItem, DiffBasePropsReact, DiffLineAnnotation, DiffLineEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderMetadataProps, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
|
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GutterUtilitySlotStyles, MergeConflictSlotStyles } from "./constants.js";
|
|
1
|
+
import { GutterUtilitySlotStyles, MergeConflictSlotStyles, noopRender } from "./constants.js";
|
|
2
2
|
import { renderFileChildren } from "./utils/renderFileChildren.js";
|
|
3
3
|
import { templateRender } from "./utils/templateRender.js";
|
|
4
4
|
import { Virtualizer, VirtualizerContext, useVirtualizer } from "./Virtualizer.js";
|
|
@@ -13,4 +13,4 @@ import { MultiFileDiff } from "./MultiFileDiff.js";
|
|
|
13
13
|
import { PatchDiff } from "./PatchDiff.js";
|
|
14
14
|
import { UnresolvedFile } from "./UnresolvedFile.js";
|
|
15
15
|
|
|
16
|
-
export { File, FileDiff, GutterUtilitySlotStyles, MergeConflictSlotStyles, MultiFileDiff, PatchDiff, UnresolvedFile, Virtualizer, VirtualizerContext, WorkerPoolContext, WorkerPoolContextProvider, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
|
|
16
|
+
export { File, FileDiff, GutterUtilitySlotStyles, MergeConflictSlotStyles, MultiFileDiff, PatchDiff, UnresolvedFile, Virtualizer, VirtualizerContext, WorkerPoolContext, WorkerPoolContextProvider, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
|
package/dist/react/jsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","names":["DIFFS_TAG_NAME","_0","HTMLElement","React","HTMLAttributes","DetailedHTMLProps","sideEffect"],"sources":["../../src/react/jsx.d.ts"],"sourcesContent":["import 'react';\nimport type { DIFFS_TAG_NAME } from '../constants';\n\ndeclare module 'react' {\n namespace JSX {\n interface IntrinsicElements {\n [DIFFS_TAG_NAME]: React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n >;\n }\n }\n}\n"],"mappings":";;;;;EACmD,UAAA,GAAA,CAAA;IAAA,UAAA,iBAAA,CAAA;OAK5CA,cAAAA,CAL4C,EAK3BG,KAAAA,CAAME,iBALqB,CAM3CF,KAAAA,CAAMC,cAAeF,CAAAA,WAAAA,CAAAA,EACrBA,WADME,CACNF;IAFgBC;EAAjBH"}
|
|
@@ -12,6 +12,7 @@ interface UseFileDiffInstanceProps<LAnnotation> {
|
|
|
12
12
|
selectedLines: SelectedLineRange | null | undefined;
|
|
13
13
|
prerenderedHTML: string | undefined;
|
|
14
14
|
metrics?: VirtualFileMetrics;
|
|
15
|
+
hasGutterRenderUtility: boolean;
|
|
15
16
|
}
|
|
16
17
|
interface UseFileDiffInstanceReturn {
|
|
17
18
|
ref(node: HTMLElement | null): void;
|
|
@@ -25,7 +26,8 @@ declare function useFileDiffInstance<LAnnotation>({
|
|
|
25
26
|
lineAnnotations,
|
|
26
27
|
selectedLines,
|
|
27
28
|
prerenderedHTML,
|
|
28
|
-
metrics
|
|
29
|
+
metrics,
|
|
30
|
+
hasGutterRenderUtility
|
|
29
31
|
}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;
|
|
30
32
|
//#endregion
|
|
31
33
|
export { useFileDiffInstance };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileDiffInstance.d.ts","names":["FileDiffOptions","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","VirtualFileMetrics","UseFileDiffInstanceProps","LAnnotation","UseFileDiffInstanceReturn","HTMLElement","useFileDiffInstance","oldFile","newFile","fileDiff","options","lineAnnotations","selectedLines","prerenderedHTML","metrics"],"sources":["../../../src/react/utils/useFileDiffInstance.d.ts"],"sourcesContent":["import { type FileDiffOptions } from '../../components/FileDiff';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, VirtualFileMetrics } from '../../types';\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\nexport declare function useFileDiffInstance<LAnnotation>({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileDiffInstance.d.ts.map"],"mappings":";;;;;UAGUO;YACIH;EADJG,OAAAA,CAAAA,EAEIH,YAFJG;EACIH,QAAAA,CAAAA,EAECC,gBAFDD;EACAA,OAAAA,EAEDJ,eAFCI,CAEeI,WAFfJ,CAAAA,GAAAA,SAAAA;EACCC,eAAAA,EAEMF,kBAFNE,CAEyBG,WAFzBH,CAAAA,EAAAA,GAAAA,SAAAA;EACcG,aAAAA,EAEVN,iBAFUM,GAAAA,IAAAA,GAAAA,SAAAA;EAAhBR,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC2BQ,OAAAA,CAAAA,EAG1BF,kBAH0BE;;
|
|
1
|
+
{"version":3,"file":"useFileDiffInstance.d.ts","names":["FileDiffOptions","GetHoveredLineResult","SelectedLineRange","DiffLineAnnotation","FileContents","FileDiffMetadata","VirtualFileMetrics","UseFileDiffInstanceProps","LAnnotation","UseFileDiffInstanceReturn","HTMLElement","useFileDiffInstance","oldFile","newFile","fileDiff","options","lineAnnotations","selectedLines","prerenderedHTML","metrics","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useFileDiffInstance.d.ts"],"sourcesContent":["import { type FileDiffOptions } from '../../components/FileDiff';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata, VirtualFileMetrics } from '../../types';\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\nexport declare function useFileDiffInstance<LAnnotation>({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileDiffInstance.d.ts.map"],"mappings":";;;;;UAGUO;YACIH;EADJG,OAAAA,CAAAA,EAEIH,YAFJG;EACIH,QAAAA,CAAAA,EAECC,gBAFDD;EACAA,OAAAA,EAEDJ,eAFCI,CAEeI,WAFfJ,CAAAA,GAAAA,SAAAA;EACCC,eAAAA,EAEMF,kBAFNE,CAEyBG,WAFzBH,CAAAA,EAAAA,GAAAA,SAAAA;EACcG,aAAAA,EAEVN,iBAFUM,GAAAA,IAAAA,GAAAA,SAAAA;EAAhBR,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC2BQ,OAAAA,CAAAA,EAG1BF,kBAH0BE;EAAnBL,sBAAAA,EAAAA,OAAAA;;UAMXM,yBAAAA,CAHIH;EAAkB,GAAA,CAAA,IAAA,EAIlBI,WAJkB,GAAA,IAAA,CAAA,EAAA,IAAA;EAGtBD,cAAAA,EAAAA,EAEYR,oBAFa,CAAA,MACrBS,CAAAA,GAAAA,SACQT;AAEtB;AAA2DW,iBAAnCD,mBAAmCC,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,OAAAA;EAAAA,OAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA;AAAAA,CAAAA,EAAyHL,wBAAzHK,CAAkJJ,WAAlJI,CAAAA,CAAAA,EAAiKH,yBAAjKG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FileDiff } from "../../components/FileDiff.js";
|
|
2
2
|
import { VirtualizedFileDiff } from "../../components/VirtualizedFileDiff.js";
|
|
3
3
|
import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
|
|
4
|
+
import { noopRender } from "../constants.js";
|
|
4
5
|
import { useVirtualizer } from "../Virtualizer.js";
|
|
5
6
|
import { WorkerPoolContext } from "../WorkerPoolContext.js";
|
|
6
7
|
import { useStableCallback } from "./useStableCallback.js";
|
|
@@ -8,15 +9,15 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "rea
|
|
|
8
9
|
|
|
9
10
|
//#region src/react/utils/useFileDiffInstance.ts
|
|
10
11
|
const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
11
|
-
function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }) {
|
|
12
|
+
function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }) {
|
|
12
13
|
const simpleVirtualizer = useVirtualizer();
|
|
13
14
|
const poolManager = useContext(WorkerPoolContext);
|
|
14
15
|
const instanceRef = useRef(null);
|
|
15
16
|
const ref = useStableCallback((fileContainer) => {
|
|
16
17
|
if (fileContainer != null) {
|
|
17
18
|
if (instanceRef.current != null) throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");
|
|
18
|
-
if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFileDiff(options, simpleVirtualizer, metrics, poolManager, true);
|
|
19
|
-
else instanceRef.current = new FileDiff(options, poolManager, true);
|
|
19
|
+
if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFileDiff(mergeFileDiffOptions(options, hasGutterRenderUtility), simpleVirtualizer, metrics, poolManager, true);
|
|
20
|
+
else instanceRef.current = new FileDiff(mergeFileDiffOptions(options, hasGutterRenderUtility), poolManager, true);
|
|
20
21
|
instanceRef.current.hydrate({
|
|
21
22
|
fileDiff,
|
|
22
23
|
oldFile,
|
|
@@ -34,8 +35,9 @@ function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotati
|
|
|
34
35
|
useIsometricEffect(() => {
|
|
35
36
|
const { current: instance } = instanceRef;
|
|
36
37
|
if (instance == null) return;
|
|
37
|
-
const
|
|
38
|
-
instance.
|
|
38
|
+
const newOptions = mergeFileDiffOptions(options, hasGutterRenderUtility);
|
|
39
|
+
const forceRender = !areOptionsEqual(instance.options, newOptions);
|
|
40
|
+
instance.setOptions(newOptions);
|
|
39
41
|
instance.render({
|
|
40
42
|
forceRender,
|
|
41
43
|
fileDiff,
|
|
@@ -52,6 +54,13 @@ function useFileDiffInstance({ oldFile, newFile, fileDiff, options, lineAnnotati
|
|
|
52
54
|
}, [])
|
|
53
55
|
};
|
|
54
56
|
}
|
|
57
|
+
function mergeFileDiffOptions(options, hasGutterRenderUtility) {
|
|
58
|
+
if (hasGutterRenderUtility) return {
|
|
59
|
+
...options,
|
|
60
|
+
renderGutterUtility: noopRender
|
|
61
|
+
};
|
|
62
|
+
return options;
|
|
63
|
+
}
|
|
55
64
|
|
|
56
65
|
//#endregion
|
|
57
66
|
export { useFileDiffInstance };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\n\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\n\nexport function useFileDiffInstance<LAnnotation>({\n oldFile,\n newFile,\n fileDiff,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n FileDiff<LAnnotation> | VirtualizedFileDiff<LAnnotation> | null\n >(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n options,\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new FileDiff(options, poolManager
|
|
1
|
+
{"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { FileDiff, type FileDiffOptions } from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender as renderGutterUtility } from '../constants';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileDiffInstanceProps<LAnnotation> {\n oldFile?: FileContents;\n newFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n options: FileDiffOptions<LAnnotation> | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\n\ninterface UseFileDiffInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n}\n\nexport function useFileDiffInstance<LAnnotation>({\n oldFile,\n newFile,\n fileDiff,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n}: UseFileDiffInstanceProps<LAnnotation>): UseFileDiffInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n FileDiff<LAnnotation> | VirtualizedFileDiff<LAnnotation> | null\n >(null);\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n mergeFileDiffOptions(options, hasGutterRenderUtility),\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new FileDiff(\n mergeFileDiffOptions(options, hasGutterRenderUtility),\n poolManager,\n true\n );\n }\n void instanceRef.current.hydrate({\n fileDiff,\n oldFile,\n newFile,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useFileDiffInstance: A FileDiff instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n const { current: instance } = instanceRef;\n if (instance == null) return;\n const newOptions = mergeFileDiffOptions(options, hasGutterRenderUtility);\n const forceRender = !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n void instance.render({\n forceRender,\n fileDiff,\n oldFile,\n newFile,\n lineAnnotations,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n\n return { ref, getHoveredLine };\n}\n\nfunction mergeFileDiffOptions<LAnnotation>(\n options: FileDiffOptions<LAnnotation> | undefined,\n hasGutterRenderUtility: boolean\n): FileDiffOptions<LAnnotation> | undefined {\n if (hasGutterRenderUtility) {\n return { ...options, renderGutterUtility };\n }\n return options;\n}\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,oBAAiC,EAC/C,SACA,SACA,UACA,SACA,iBACA,eACA,iBACA,SACA,0BACmE;CACnE,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,kBAAsC;AACnE,MAAI,iBAAiB,MAAM;AACzB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,mFACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,oBACxB,qBAAqB,SAAS,uBAAuB,EACrD,mBACA,SACA,aACA,KACD;OAED,aAAY,UAAU,IAAI,SACxB,qBAAqB,SAAS,uBAAuB,EACrD,aACA,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,wEACD;AAEH,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;EACvB,MAAM,EAAE,SAAS,aAAa;AAC9B,MAAI,YAAY,KAAM;EACtB,MAAM,aAAa,qBAAqB,SAAS,uBAAuB;EACxE,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,WAAW;AAClE,WAAS,WAAW,WAAW;AAC/B,EAAK,SAAS,OAAO;GACnB;GACA;GACA;GACA;GACA;GACD,CAAC;AACF,MAAI,kBAAkB,OACpB,UAAS,iBAAiB,cAAc;GAE1C;AAQF,QAAO;EAAE;EAAK,gBANS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EAEwB;;AAGhC,SAAS,qBACP,SACA,wBAC0C;AAC1C,KAAI,uBACF,QAAO;EAAE,GAAG;EAAS;EAAqB;AAE5C,QAAO"}
|
|
@@ -10,6 +10,7 @@ interface UseFileInstanceProps<LAnnotation> {
|
|
|
10
10
|
selectedLines: SelectedLineRange | null | undefined;
|
|
11
11
|
prerenderedHTML: string | undefined;
|
|
12
12
|
metrics?: VirtualFileMetrics;
|
|
13
|
+
hasGutterRenderUtility: boolean;
|
|
13
14
|
}
|
|
14
15
|
interface UseFileInstanceReturn {
|
|
15
16
|
ref(node: HTMLElement | null): void;
|
|
@@ -21,7 +22,8 @@ declare function useFileInstance<LAnnotation>({
|
|
|
21
22
|
lineAnnotations,
|
|
22
23
|
selectedLines,
|
|
23
24
|
prerenderedHTML,
|
|
24
|
-
metrics
|
|
25
|
+
metrics,
|
|
26
|
+
hasGutterRenderUtility
|
|
25
27
|
}: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn;
|
|
26
28
|
//#endregion
|
|
27
29
|
export { useFileInstance };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileInstance.d.ts","names":["FileOptions","GetHoveredLineResult","SelectedLineRange","FileContents","LineAnnotation","VirtualFileMetrics","UseFileInstanceProps","LAnnotation","UseFileInstanceReturn","HTMLElement","useFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","metrics"],"sources":["../../../src/react/utils/useFileInstance.d.ts"],"sourcesContent":["import { type FileOptions } from '../../components/File';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { FileContents, LineAnnotation, VirtualFileMetrics } from '../../types';\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function useFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileInstance.d.ts.map"],"mappings":";;;;;UAGUM;QACAH;EADAG,OAAAA,EAEGN,WAFHM,CAEeC,WAFKA,CAAAA,GAAAA,SAAAA;EACpBJ,eAAAA,EAEWC,cAFXD,CAE0BI,WAF1BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACeI,aAAAA,EAENL,iBAFMK,GAAAA,IAAAA,GAAAA,SAAAA;EAAZP,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EACuBO,OAAAA,CAAAA,EAGtBF,kBAHsBE;;
|
|
1
|
+
{"version":3,"file":"useFileInstance.d.ts","names":["FileOptions","GetHoveredLineResult","SelectedLineRange","FileContents","LineAnnotation","VirtualFileMetrics","UseFileInstanceProps","LAnnotation","UseFileInstanceReturn","HTMLElement","useFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","metrics","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useFileInstance.d.ts"],"sourcesContent":["import { type FileOptions } from '../../components/File';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { FileContents, LineAnnotation, VirtualFileMetrics } from '../../types';\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\nexport declare function useFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn;\nexport {};\n//# sourceMappingURL=useFileInstance.d.ts.map"],"mappings":";;;;;UAGUM;QACAH;EADAG,OAAAA,EAEGN,WAFHM,CAEeC,WAFKA,CAAAA,GAAAA,SAAAA;EACpBJ,eAAAA,EAEWC,cAFXD,CAE0BI,WAF1BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACeI,aAAAA,EAENL,iBAFMK,GAAAA,IAAAA,GAAAA,SAAAA;EAAZP,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EACuBO,OAAAA,CAAAA,EAGtBF,kBAHsBE;EAAfH,sBAAAA,EAAAA,OAAAA;;UAMXI,qBAAAA,CAHIH;EAAkB,GAAA,CAAA,IAAA,EAIlBI,WAJkB,GAAA,IAAA,CAAA,EAAA,IAAA;EAGtBD,cAAAA,EAAAA,EAEYP,oBADRQ,CAAAA,MAAAA,CAAAA,GAAAA,SACQR;AAEtB;AAAuDU,iBAA/BD,eAA+BC,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,OAAAA;EAAAA;AAAAA,CAAAA,EAAmGL,oBAAnGK,CAAwHJ,WAAxHI,CAAAA,CAAAA,EAAuIH,qBAAvIG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { File } from "../../components/File.js";
|
|
2
2
|
import { VirtualizedFile } from "../../components/VirtualizedFile.js";
|
|
3
3
|
import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
|
|
4
|
+
import { noopRender } from "../constants.js";
|
|
4
5
|
import { useVirtualizer } from "../Virtualizer.js";
|
|
5
6
|
import { WorkerPoolContext } from "../WorkerPoolContext.js";
|
|
6
7
|
import { useStableCallback } from "./useStableCallback.js";
|
|
@@ -8,15 +9,15 @@ import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "rea
|
|
|
8
9
|
|
|
9
10
|
//#region src/react/utils/useFileInstance.ts
|
|
10
11
|
const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
11
|
-
function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics }) {
|
|
12
|
+
function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility }) {
|
|
12
13
|
const simpleVirtualizer = useVirtualizer();
|
|
13
14
|
const poolManager = useContext(WorkerPoolContext);
|
|
14
15
|
const instanceRef = useRef(null);
|
|
15
16
|
const ref = useStableCallback((node) => {
|
|
16
17
|
if (node != null) {
|
|
17
18
|
if (instanceRef.current != null) throw new Error("File: An instance should not already exist when a node is created");
|
|
18
|
-
if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFile(options, simpleVirtualizer, metrics, poolManager, true);
|
|
19
|
-
else instanceRef.current = new File(options, poolManager, true);
|
|
19
|
+
if (simpleVirtualizer != null) instanceRef.current = new VirtualizedFile(mergeFileOptions(options, hasGutterRenderUtility), simpleVirtualizer, metrics, poolManager, true);
|
|
20
|
+
else instanceRef.current = new File(mergeFileOptions(options, hasGutterRenderUtility), poolManager, true);
|
|
20
21
|
instanceRef.current.hydrate({
|
|
21
22
|
file,
|
|
22
23
|
fileContainer: node,
|
|
@@ -31,8 +32,9 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
|
|
|
31
32
|
});
|
|
32
33
|
useIsometricEffect(() => {
|
|
33
34
|
if (instanceRef.current == null) return;
|
|
34
|
-
const
|
|
35
|
-
instanceRef.current.
|
|
35
|
+
const newOptions = mergeFileOptions(options, hasGutterRenderUtility);
|
|
36
|
+
const forceRender = !areOptionsEqual(instanceRef.current.options, newOptions);
|
|
37
|
+
instanceRef.current.setOptions(newOptions);
|
|
36
38
|
instanceRef.current.render({
|
|
37
39
|
file,
|
|
38
40
|
lineAnnotations,
|
|
@@ -47,6 +49,13 @@ function useFileInstance({ file, options, lineAnnotations, selectedLines, preren
|
|
|
47
49
|
}, [])
|
|
48
50
|
};
|
|
49
51
|
}
|
|
52
|
+
function mergeFileOptions(options, hasGutterRenderUtility) {
|
|
53
|
+
if (hasGutterRenderUtility) return {
|
|
54
|
+
...options,
|
|
55
|
+
renderGutterUtility: noopRender
|
|
56
|
+
};
|
|
57
|
+
return options;
|
|
58
|
+
}
|
|
50
59
|
|
|
51
60
|
//#endregion
|
|
52
61
|
export { useFileInstance };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileInstance.js","names":[],"sources":["../../../src/react/utils/useFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { File, type FileOptions } from '../../components/File';\nimport { VirtualizedFile } from '../../components/VirtualizedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n}\n\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function useFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n}: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n File<LAnnotation> | VirtualizedFile<LAnnotation> | null\n >(null);\n const ref = useStableCallback((node: HTMLElement | null) => {\n if (node != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'File: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFile(\n options,\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new File(options, poolManager
|
|
1
|
+
{"version":3,"file":"useFileInstance.js","names":[],"sources":["../../../src/react/utils/useFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n} from 'react';\n\nimport { File, type FileOptions } from '../../components/File';\nimport { VirtualizedFile } from '../../components/VirtualizedFile';\nimport type {\n GetHoveredLineResult,\n SelectedLineRange,\n} from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\n VirtualFileMetrics,\n} from '../../types';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { noopRender as renderGutterUtility } from '../constants';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface UseFileInstanceProps<LAnnotation> {\n file: FileContents;\n options: FileOptions<LAnnotation> | undefined;\n lineAnnotations: LineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n}\n\ninterface UseFileInstanceReturn {\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'file'> | undefined;\n}\n\nexport function useFileInstance<LAnnotation>({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n}: UseFileInstanceProps<LAnnotation>): UseFileInstanceReturn {\n const simpleVirtualizer = useVirtualizer();\n const poolManager = useContext(WorkerPoolContext);\n const instanceRef = useRef<\n File<LAnnotation> | VirtualizedFile<LAnnotation> | null\n >(null);\n const ref = useStableCallback((node: HTMLElement | null) => {\n if (node != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'File: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFile(\n mergeFileOptions(options, hasGutterRenderUtility),\n simpleVirtualizer,\n metrics,\n poolManager,\n true\n );\n } else {\n instanceRef.current = new File(\n mergeFileOptions(options, hasGutterRenderUtility),\n poolManager,\n true\n );\n }\n void instanceRef.current.hydrate({\n file,\n fileContainer: node,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error('File: A File instance should exist when unmounting');\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n }\n });\n\n useIsometricEffect(() => {\n if (instanceRef.current == null) return;\n const newOptions = mergeFileOptions(options, hasGutterRenderUtility);\n const forceRender = !areOptionsEqual(\n instanceRef.current.options,\n newOptions\n );\n instanceRef.current.setOptions(newOptions);\n void instanceRef.current.render({ file, lineAnnotations, forceRender });\n if (selectedLines !== undefined) {\n instanceRef.current.setSelectedLines(selectedLines);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'file'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n return { ref, getHoveredLine };\n}\n\nfunction mergeFileOptions<LAnnotation>(\n options: FileOptions<LAnnotation> | undefined,\n hasGutterRenderUtility: boolean\n): FileOptions<LAnnotation> | undefined {\n if (hasGutterRenderUtility) {\n return { ...options, renderGutterUtility };\n }\n return options;\n}\n"],"mappings":";;;;;;;;;;AAyBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAiB9C,SAAgB,gBAA6B,EAC3C,MACA,SACA,iBACA,eACA,iBACA,SACA,0BAC2D;CAC3D,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,cAAc,OAElB,KAAK;CACP,MAAM,MAAM,mBAAmB,SAA6B;AAC1D,MAAI,QAAQ,MAAM;AAChB,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MACR,oEACD;AAEH,OAAI,qBAAqB,KACvB,aAAY,UAAU,IAAI,gBACxB,iBAAiB,SAAS,uBAAuB,EACjD,mBACA,SACA,aACA,KACD;OAED,aAAY,UAAU,IAAI,KACxB,iBAAiB,SAAS,uBAAuB,EACjD,aACA,KACD;AAEH,GAAK,YAAY,QAAQ,QAAQ;IAC/B;IACA,eAAe;IACf;IACA;IACD,CAAC;SACG;AACL,OAAI,YAAY,WAAW,KACzB,OAAM,IAAI,MAAM,qDAAqD;AAEvE,eAAY,QAAQ,SAAS;AAC7B,eAAY,UAAU;;GAExB;AAEF,0BAAyB;AACvB,MAAI,YAAY,WAAW,KAAM;EACjC,MAAM,aAAa,iBAAiB,SAAS,uBAAuB;EACpE,MAAM,cAAc,CAAC,gBACnB,YAAY,QAAQ,SACpB,WACD;AACD,cAAY,QAAQ,WAAW,WAAW;AAC1C,EAAK,YAAY,QAAQ,OAAO;GAAE;GAAM;GAAiB;GAAa,CAAC;AACvE,MAAI,kBAAkB,OACpB,aAAY,QAAQ,iBAAiB,cAAc;GAErD;AAOF,QAAO;EAAE;EAAK,gBALS,kBAEN;AACf,UAAO,YAAY,SAAS,gBAAgB;KAC3C,EAAE,CAAC;EACwB;;AAGhC,SAAS,iBACP,SACA,wBACsC;AACtC,KAAI,uBACF,QAAO;EAAE,GAAG;EAAS;EAAqB;AAE5C,QAAO"}
|
|
@@ -12,6 +12,7 @@ interface UseUnresolvedFileInstanceProps<LAnnotation> {
|
|
|
12
12
|
selectedLines: SelectedLineRange | null | undefined;
|
|
13
13
|
prerenderedHTML: string | undefined;
|
|
14
14
|
hasConflictUtility: boolean;
|
|
15
|
+
hasGutterRenderUtility: boolean;
|
|
15
16
|
}
|
|
16
17
|
interface UseUnresolvedFileInstanceReturn<LAnnotation> {
|
|
17
18
|
fileDiff: FileDiffMetadata;
|
|
@@ -26,7 +27,8 @@ declare function useUnresolvedFileInstance<LAnnotation>({
|
|
|
26
27
|
lineAnnotations,
|
|
27
28
|
selectedLines,
|
|
28
29
|
prerenderedHTML,
|
|
29
|
-
hasConflictUtility
|
|
30
|
+
hasConflictUtility,
|
|
31
|
+
hasGutterRenderUtility
|
|
30
32
|
}: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;
|
|
31
33
|
//#endregion
|
|
32
34
|
export { useUnresolvedFileInstance };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","UnresolvedFileHunksRendererOptions","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictDiffAction","UseUnresolvedFileInstanceProps","LAnnotation","Omit","UseUnresolvedFileInstanceReturn","HTMLElement","useUnresolvedFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","hasConflictUtility"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.d.ts"],"sourcesContent":["import { UnresolvedFile } from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: Omit<UnresolvedFileHunksRendererOptions, 'onMergeConflictAction'>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: MergeConflictDiffAction[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUQ;QACAH;EADAG,OAAAA,CAAAA,EAEIE,IAFJF,CAESL,kCAFqBM,EAAAA,uBAAA,CAAA;EAC9BJ,eAAAA,EAEWD,kBAFXC,CAE8BI,WAF9BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACSF,aAAAA,EAEAD,iBAFAC,GAAAA,IAAAA,GAAAA,SAAAA;EAALO,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BD,kBAAAA,EAAAA,OAAAA;;
|
|
1
|
+
{"version":3,"file":"useUnresolvedFileInstance.d.ts","names":["UnresolvedFile","GetHoveredLineResult","SelectedLineRange","UnresolvedFileHunksRendererOptions","DiffLineAnnotation","FileContents","FileDiffMetadata","MergeConflictDiffAction","UseUnresolvedFileInstanceProps","LAnnotation","Omit","UseUnresolvedFileInstanceReturn","HTMLElement","useUnresolvedFileInstance","file","options","lineAnnotations","selectedLines","prerenderedHTML","hasConflictUtility","hasGutterRenderUtility"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.d.ts"],"sourcesContent":["import { UnresolvedFile } from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult, SelectedLineRange } from '../../managers/InteractionManager';\nimport type { UnresolvedFileHunksRendererOptions } from '../../renderers/UnresolvedFileHunksRenderer';\nimport type { DiffLineAnnotation, FileContents, FileDiffMetadata } from '../../types';\nimport { type MergeConflictDiffAction } from '../../utils/parseMergeConflictDiffFromFile';\ninterface UseUnresolvedFileInstanceProps<LAnnotation> {\n file: FileContents;\n options?: Omit<UnresolvedFileHunksRendererOptions, 'onMergeConflictAction'>;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n}\ninterface UseUnresolvedFileInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n actions: MergeConflictDiffAction[];\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getInstance(): UnresolvedFile<LAnnotation> | undefined;\n}\nexport declare function useUnresolvedFileInstance<LAnnotation>({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }: UseUnresolvedFileInstanceProps<LAnnotation>): UseUnresolvedFileInstanceReturn<LAnnotation>;\nexport {};\n//# sourceMappingURL=useUnresolvedFileInstance.d.ts.map"],"mappings":";;;;;;;UAKUQ;QACAH;EADAG,OAAAA,CAAAA,EAEIE,IAFJF,CAESL,kCAFqBM,EAAAA,uBAAA,CAAA;EAC9BJ,eAAAA,EAEWD,kBAFXC,CAE8BI,WAF9BJ,CAAAA,EAAAA,GAAAA,SAAAA;EACSF,aAAAA,EAEAD,iBAFAC,GAAAA,IAAAA,GAAAA,SAAAA;EAALO,eAAAA,EAAAA,MAAAA,GAAAA,SAAAA;EAC0BD,kBAAAA,EAAAA,OAAAA;EAAnBL,sBAAAA,EAAAA,OAAAA;;UAMXO,+BAL0B,CAAA,WAAA,CAAA,CAAA;EAK1BA,QAAAA,EACIL,gBADJK;EACIL,OAAAA,EACDC,uBADCD,EAAAA;EACDC,GAAAA,CAAAA,IAAAA,EACCK,WADDL,GAAAA,IAAAA,CAAAA,EAAAA,IAAAA;EACCK,cAAAA,EAAAA,EACQX,oBADRW,CAAAA,MAAAA,CAAAA,GAAAA,SAAAA;EACQX,WAAAA,EAAAA,EACHD,cADGC,CACYQ,WADZR,CAAAA,GAAAA,SAAAA;;AACHD,iBAEKa,yBAFLb,CAAAA,WAAAA,CAAAA,CAAAA;EAAAA,IAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,eAAAA;EAAAA,kBAAAA;EAAAA;AAAAA,CAAAA,EAE4JQ,8BAF5JR,CAE2LS,WAF3LT,CAAAA,CAAAA,EAE0MW,+BAF1MX,CAE0OS,WAF1OT,CAAAA"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { parseMergeConflictDiffFromFile } from "../../utils/parseMergeConflictDiffFromFile.js";
|
|
2
2
|
import { UnresolvedFile } from "../../components/UnresolvedFile.js";
|
|
3
3
|
import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
|
|
4
|
+
import { noopRender } from "../constants.js";
|
|
4
5
|
import { WorkerPoolContext } from "../WorkerPoolContext.js";
|
|
5
6
|
import { useStableCallback } from "./useStableCallback.js";
|
|
6
7
|
import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
7
8
|
|
|
8
9
|
//#region src/react/utils/useUnresolvedFileInstance.ts
|
|
9
10
|
const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
10
|
-
function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility }) {
|
|
11
|
+
function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility }) {
|
|
11
12
|
const [{ fileDiff, actions }, setState] = useState(() => {
|
|
12
13
|
const { fileDiff: fileDiff$1, actions: actions$1 } = parseMergeConflictDiffFromFile(file);
|
|
13
14
|
return {
|
|
@@ -32,7 +33,7 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
|
|
|
32
33
|
const ref = useStableCallback((fileContainer) => {
|
|
33
34
|
if (fileContainer != null) {
|
|
34
35
|
if (instanceRef.current != null) throw new Error("useUnresolvedFileInstance: An instance should not already exist when a node is created");
|
|
35
|
-
instanceRef.current = new UnresolvedFile(mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility), poolManager, true);
|
|
36
|
+
instanceRef.current = new UnresolvedFile(mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility), poolManager, true);
|
|
36
37
|
instanceRef.current.hydrate({
|
|
37
38
|
fileDiff,
|
|
38
39
|
actions,
|
|
@@ -49,7 +50,7 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
|
|
|
49
50
|
useIsometricEffect(() => {
|
|
50
51
|
if (instanceRef.current == null) return;
|
|
51
52
|
const instance = instanceRef.current;
|
|
52
|
-
const newOptions = mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility);
|
|
53
|
+
const newOptions = mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility);
|
|
53
54
|
const forceRender = !areOptionsEqual(instance.options, newOptions);
|
|
54
55
|
instance.setOptions(newOptions);
|
|
55
56
|
instance.render({
|
|
@@ -72,15 +73,15 @@ function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLin
|
|
|
72
73
|
}, [])
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
|
-
function mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility) {
|
|
76
|
+
function mergeUnresolvedOptions(options, onMergeConflictAction, hasConflictUtility, hasGutterRenderUtility) {
|
|
76
77
|
return {
|
|
77
78
|
...options,
|
|
78
79
|
onMergeConflictAction,
|
|
79
|
-
hunkSeparators: options?.hunkSeparators === "custom" ?
|
|
80
|
-
mergeConflictActionsType: hasConflictUtility || options?.mergeConflictActionsType === "custom" ?
|
|
80
|
+
hunkSeparators: options?.hunkSeparators === "custom" ? noopRender : options?.hunkSeparators,
|
|
81
|
+
mergeConflictActionsType: hasConflictUtility || options?.mergeConflictActionsType === "custom" ? noopRender : options?.mergeConflictActionsType,
|
|
82
|
+
renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
|
-
function emptyRender() {}
|
|
84
85
|
|
|
85
86
|
//#endregion
|
|
86
87
|
export { useUnresolvedFileInstance };
|