@pierre/diffs 1.2.11 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/components/CodeView.d.ts +10 -11
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +7 -8
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts +1 -4
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +13 -11
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +11 -14
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +15 -13
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts +0 -1
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +4 -4
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.d.ts +2 -2
- package/dist/components/UnresolvedFile.d.ts.map +1 -1
- package/dist/components/UnresolvedFile.js +7 -5
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +0 -1
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +19 -18
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +2 -3
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +17 -18
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/components/Virtualizer.d.ts +1 -1
- package/dist/components/Virtualizer.d.ts.map +1 -1
- package/dist/components/Virtualizer.js +23 -24
- package/dist/components/Virtualizer.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/components/web-components.d.ts.map +1 -1
- package/dist/components/web-components.js +2 -3
- package/dist/components/web-components.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/highlighter/languages/areLanguagesAttached.d.ts.map +1 -1
- package/dist/highlighter/languages/areLanguagesAttached.js +1 -2
- package/dist/highlighter/languages/areLanguagesAttached.js.map +1 -1
- package/dist/highlighter/languages/attachResolvedLanguages.d.ts +0 -2
- package/dist/highlighter/languages/attachResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/attachResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/attachResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/cleanUpResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/cleanUpResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/cleanUpResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/constants.d.ts +0 -1
- package/dist/highlighter/languages/constants.d.ts.map +1 -1
- package/dist/highlighter/languages/constants.js +1 -1
- package/dist/highlighter/languages/constants.js.map +1 -1
- package/dist/highlighter/languages/getResolvedLanguages.d.ts +0 -2
- package/dist/highlighter/languages/getResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/getResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/getResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts +0 -2
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.js +1 -2
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.js.map +1 -1
- package/dist/highlighter/languages/hasResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/hasResolvedLanguages.js +1 -2
- package/dist/highlighter/languages/hasResolvedLanguages.js.map +1 -1
- package/dist/highlighter/languages/registerCustomLanguage.d.ts +0 -1
- package/dist/highlighter/languages/registerCustomLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/registerCustomLanguage.js +1 -2
- package/dist/highlighter/languages/registerCustomLanguage.js.map +1 -1
- package/dist/highlighter/languages/resolveLanguage.d.ts +0 -2
- package/dist/highlighter/languages/resolveLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/resolveLanguage.js +4 -5
- package/dist/highlighter/languages/resolveLanguage.js.map +1 -1
- package/dist/highlighter/languages/resolveLanguages.d.ts +0 -2
- package/dist/highlighter/languages/resolveLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/resolveLanguages.js +1 -2
- package/dist/highlighter/languages/resolveLanguages.js.map +1 -1
- package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.js +3 -4
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/highlighter/themes/areThemesAttached.d.ts.map +1 -1
- package/dist/highlighter/themes/areThemesAttached.js +1 -2
- package/dist/highlighter/themes/areThemesAttached.js.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.js +1 -2
- package/dist/highlighter/themes/attachResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.js +1 -2
- package/dist/highlighter/themes/cleanUpResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/constants.d.ts.map +1 -1
- package/dist/highlighter/themes/constants.js +1 -1
- package/dist/highlighter/themes/constants.js.map +1 -1
- package/dist/highlighter/themes/getResolvedOrResolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js +1 -2
- package/dist/highlighter/themes/getResolvedOrResolveTheme.js.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.js +1 -2
- package/dist/highlighter/themes/getResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.js +1 -2
- package/dist/highlighter/themes/hasResolvedThemes.js.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.js +1 -2
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.js.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.js +1 -2
- package/dist/highlighter/themes/registerCustomTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveTheme.js +1 -2
- package/dist/highlighter/themes/resolveTheme.js.map +1 -1
- package/dist/highlighter/themes/resolveThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveThemes.js +1 -2
- package/dist/highlighter/themes/resolveThemes.js.map +1 -1
- package/dist/highlighter/themes/themeResolution.d.ts.map +1 -1
- package/dist/highlighter/themes/themeResolution.js +1 -2
- package/dist/highlighter/themes/themeResolution.js.map +1 -1
- package/dist/highlighter/themes/themeResolver.d.ts +2 -2
- package/dist/highlighter/themes/themeResolver.d.ts.map +1 -1
- package/dist/highlighter/themes/themeResolver.js +1 -2
- package/dist/highlighter/themes/themeResolver.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -2
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +3 -3
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +1 -1
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/managers/ScrollSyncManager.d.ts.map +1 -1
- package/dist/managers/ScrollSyncManager.js +1 -1
- package/dist/managers/ScrollSyncManager.js.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.js +2 -2
- package/dist/managers/UniversalRenderingManager.js.map +1 -1
- package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts +228 -0
- package/dist/node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +84 -0
- package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts.map +1 -0
- package/dist/react/CodeView.d.ts +0 -1
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +9 -12
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +2 -5
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +2 -5
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +2 -5
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +2 -5
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +1 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +2 -5
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/Virtualizer.d.ts.map +1 -1
- package/dist/react/Virtualizer.js +2 -5
- package/dist/react/Virtualizer.js.map +1 -1
- package/dist/react/WorkerPoolContext.d.ts +0 -1
- package/dist/react/WorkerPoolContext.d.ts.map +1 -1
- package/dist/react/WorkerPoolContext.js +2 -5
- package/dist/react/WorkerPoolContext.js.map +1 -1
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/constants.js +1 -1
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -2
- package/dist/react/jsx.d.ts +0 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +4 -5
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +4 -5
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/templateRender.d.ts.map +1 -1
- package/dist/react/utils/templateRender.js +1 -2
- package/dist/react/utils/templateRender.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +1 -2
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +1 -2
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useStableCallback.d.ts.map +1 -1
- package/dist/react/utils/useStableCallback.js +1 -2
- package/dist/react/utils/useStableCallback.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +10 -11
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +1 -2
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +23 -20
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +1 -3
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +13 -11
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +1 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +1 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/shiki-stream/index.js +1 -2
- package/dist/shiki-stream/stream.d.ts +0 -1
- package/dist/shiki-stream/stream.d.ts.map +1 -1
- package/dist/shiki-stream/stream.js +1 -2
- package/dist/shiki-stream/stream.js.map +1 -1
- package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
- package/dist/shiki-stream/tokenizer.js +1 -1
- package/dist/shiki-stream/tokenizer.js.map +1 -1
- package/dist/shiki-stream/types.d.ts +0 -1
- package/dist/shiki-stream/types.d.ts.map +1 -1
- package/dist/sprite.d.ts.map +1 -1
- package/dist/sprite.js +1 -1
- package/dist/ssr/FileDiffReact.d.ts.map +1 -1
- package/dist/ssr/FileDiffReact.js +4 -7
- package/dist/ssr/FileDiffReact.js.map +1 -1
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.js +1 -2
- package/dist/ssr/preloadDiffs.d.ts +1 -1
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadDiffs.js +1 -2
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/ssr/preloadFile.d.ts.map +1 -1
- package/dist/ssr/preloadFile.js +1 -2
- package/dist/ssr/preloadFile.js.map +1 -1
- package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
- package/dist/ssr/preloadPatchFile.js +2 -3
- package/dist/ssr/preloadPatchFile.js.map +1 -1
- package/dist/ssr/renderHTML.d.ts +1 -1
- package/dist/ssr/renderHTML.d.ts.map +1 -1
- package/dist/ssr/renderHTML.js +1 -2
- package/dist/ssr/renderHTML.js.map +1 -1
- package/dist/string-import.d.ts +4 -0
- package/dist/string-import.d.ts.map +1 -1
- package/dist/style.js +3 -3
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.d.ts.map +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.js +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.js.map +1 -1
- package/dist/utils/areDiffRenderOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areDiffRenderOptionsEqual.js +1 -2
- package/dist/utils/areDiffRenderOptionsEqual.js.map +1 -1
- package/dist/utils/areDiffTargetsEqual.d.ts.map +1 -1
- package/dist/utils/areDiffTargetsEqual.js +1 -1
- package/dist/utils/areDiffTargetsEqual.js.map +1 -1
- package/dist/utils/areFileRenderOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areFileRenderOptionsEqual.js +1 -2
- package/dist/utils/areFileRenderOptionsEqual.js.map +1 -1
- package/dist/utils/areFilesEqual.d.ts.map +1 -1
- package/dist/utils/areFilesEqual.js +1 -1
- package/dist/utils/areFilesEqual.js.map +1 -1
- package/dist/utils/areHunkDataEqual.d.ts.map +1 -1
- package/dist/utils/areHunkDataEqual.js +1 -1
- package/dist/utils/areHunkDataEqual.js.map +1 -1
- package/dist/utils/areLineAnnotationsEqual.d.ts.map +1 -1
- package/dist/utils/areLineAnnotationsEqual.js +1 -1
- package/dist/utils/areLineAnnotationsEqual.js.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.d.ts.map +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js +1 -1
- package/dist/utils/areManagedSnapshotsEqual.js.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.d.ts.map +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js +1 -1
- package/dist/utils/areMergeConflictActionsEqual.js.map +1 -1
- package/dist/utils/areObjectsEqual.d.ts.map +1 -1
- package/dist/utils/areObjectsEqual.js +1 -1
- package/dist/utils/areObjectsEqual.js.map +1 -1
- package/dist/utils/areOptionsEqual.d.ts +0 -2
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.js +1 -2
- package/dist/utils/areOptionsEqual.js.map +1 -1
- package/dist/utils/arePrePropertiesEqual.d.ts.map +1 -1
- package/dist/utils/arePrePropertiesEqual.js +1 -1
- package/dist/utils/arePrePropertiesEqual.js.map +1 -1
- package/dist/utils/areRenderRangesEqual.d.ts.map +1 -1
- package/dist/utils/areRenderRangesEqual.js +1 -1
- package/dist/utils/areRenderRangesEqual.js.map +1 -1
- package/dist/utils/areSelectionPointsEqual.d.ts.map +1 -1
- package/dist/utils/areSelectionPointsEqual.js +1 -1
- package/dist/utils/areSelectionPointsEqual.js.map +1 -1
- package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
- package/dist/utils/areSelectionsEqual.js +1 -1
- package/dist/utils/areSelectionsEqual.js.map +1 -1
- package/dist/utils/areThemesEqual.d.ts.map +1 -1
- package/dist/utils/areThemesEqual.js +1 -1
- package/dist/utils/areThemesEqual.js.map +1 -1
- package/dist/utils/areVirtualWindowSpecsEqual.d.ts.map +1 -1
- package/dist/utils/areVirtualWindowSpecsEqual.js +1 -1
- package/dist/utils/areVirtualWindowSpecsEqual.js.map +1 -1
- package/dist/utils/areWorkerStatsEqual.d.ts +0 -2
- package/dist/utils/areWorkerStatsEqual.d.ts.map +1 -1
- package/dist/utils/areWorkerStatsEqual.js +1 -1
- package/dist/utils/areWorkerStatsEqual.js.map +1 -1
- package/dist/utils/cleanLastNewline.d.ts.map +1 -1
- package/dist/utils/cleanLastNewline.js +1 -1
- package/dist/utils/cleanLastNewline.js.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.d.ts.map +1 -1
- package/dist/utils/computeEstimatedDiffHeights.js +1 -2
- package/dist/utils/computeEstimatedDiffHeights.js.map +1 -1
- package/dist/utils/computeVirtualFileMetrics.d.ts.map +1 -1
- package/dist/utils/computeVirtualFileMetrics.js +1 -2
- package/dist/utils/computeVirtualFileMetrics.js.map +1 -1
- package/dist/utils/createAnnotationElement.d.ts +1 -1
- package/dist/utils/createAnnotationElement.d.ts.map +1 -1
- package/dist/utils/createAnnotationElement.js +1 -2
- package/dist/utils/createAnnotationElement.js.map +1 -1
- package/dist/utils/createAnnotationWrapperNode.d.ts.map +1 -1
- package/dist/utils/createAnnotationWrapperNode.js +1 -1
- package/dist/utils/createAnnotationWrapperNode.js.map +1 -1
- package/dist/utils/createContentColumn.d.ts +1 -1
- package/dist/utils/createContentColumn.d.ts.map +1 -1
- package/dist/utils/createContentColumn.js +1 -2
- package/dist/utils/createContentColumn.js.map +1 -1
- package/dist/utils/createEmptyRowBuffer.d.ts +1 -1
- package/dist/utils/createEmptyRowBuffer.d.ts.map +1 -1
- package/dist/utils/createEmptyRowBuffer.js +1 -2
- package/dist/utils/createEmptyRowBuffer.js.map +1 -1
- package/dist/utils/createFileHeaderElement.d.ts +1 -1
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createFileHeaderElement.js +1 -2
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createGutterUtilityContentNode.d.ts.map +1 -1
- package/dist/utils/createGutterUtilityContentNode.js +1 -1
- package/dist/utils/createGutterUtilityContentNode.js.map +1 -1
- package/dist/utils/createGutterUtilityElement.d.ts +1 -1
- package/dist/utils/createGutterUtilityElement.d.ts.map +1 -1
- package/dist/utils/createGutterUtilityElement.js +1 -2
- package/dist/utils/createGutterUtilityElement.js.map +1 -1
- package/dist/utils/createNoNewlineElement.d.ts +1 -1
- package/dist/utils/createNoNewlineElement.d.ts.map +1 -1
- package/dist/utils/createNoNewlineElement.js +1 -2
- package/dist/utils/createNoNewlineElement.js.map +1 -1
- package/dist/utils/createPreElement.d.ts +1 -1
- package/dist/utils/createPreElement.d.ts.map +1 -1
- package/dist/utils/createPreElement.js +1 -3
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/createRowNodes.d.ts.map +1 -1
- package/dist/utils/createRowNodes.js +1 -1
- package/dist/utils/createRowNodes.js.map +1 -1
- package/dist/utils/createSeparator.d.ts +1 -1
- package/dist/utils/createSeparator.d.ts.map +1 -1
- package/dist/utils/createSeparator.js +1 -2
- package/dist/utils/createSeparator.js.map +1 -1
- package/dist/utils/createSpanNodeFromToken.d.ts.map +1 -1
- package/dist/utils/createSpanNodeFromToken.js +1 -2
- package/dist/utils/createSpanNodeFromToken.js.map +1 -1
- package/dist/utils/createStyleElement.d.ts +1 -1
- package/dist/utils/createStyleElement.d.ts.map +1 -1
- package/dist/utils/createStyleElement.js +1 -2
- package/dist/utils/createStyleElement.js.map +1 -1
- package/dist/utils/createTransformerWithState.d.ts.map +1 -1
- package/dist/utils/createTransformerWithState.js +1 -2
- package/dist/utils/createTransformerWithState.js.map +1 -1
- package/dist/utils/createUnsafeCSSStyleNode.d.ts.map +1 -1
- package/dist/utils/createUnsafeCSSStyleNode.js +1 -2
- package/dist/utils/createUnsafeCSSStyleNode.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.js +5 -5
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -1
- package/dist/utils/cssWrappers.d.ts.map +1 -1
- package/dist/utils/cssWrappers.js +2 -3
- package/dist/utils/cssWrappers.js.map +1 -1
- package/dist/utils/detachString.d.ts.map +1 -1
- package/dist/utils/detachString.js +1 -1
- package/dist/utils/detachString.js.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.js +1 -2
- package/dist/utils/diffAcceptRejectHunk.js.map +1 -1
- package/dist/utils/formatCSSVariablePrefix.d.ts.map +1 -1
- package/dist/utils/formatCSSVariablePrefix.js +1 -1
- package/dist/utils/formatCSSVariablePrefix.js.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.d.ts.map +1 -1
- package/dist/utils/getDiffHunksRendererOptions.js +1 -1
- package/dist/utils/getDiffHunksRendererOptions.js.map +1 -1
- package/dist/utils/getFileRendererOptions.d.ts.map +1 -1
- package/dist/utils/getFileRendererOptions.js +1 -1
- package/dist/utils/getFileRendererOptions.js.map +1 -1
- package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
- package/dist/utils/getFiletypeFromFileName.js +1 -1
- package/dist/utils/getFiletypeFromFileName.js.map +1 -1
- package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
- package/dist/utils/getHighlighterOptions.js +1 -2
- package/dist/utils/getHighlighterOptions.js.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.d.ts.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.js +1 -2
- package/dist/utils/getHighlighterThemeStyles.js.map +1 -1
- package/dist/utils/getHunkSeparatorSlotName.d.ts.map +1 -1
- package/dist/utils/getHunkSeparatorSlotName.js +1 -1
- package/dist/utils/getHunkSeparatorSlotName.js.map +1 -1
- package/dist/utils/getIconForType.d.ts.map +1 -1
- package/dist/utils/getIconForType.js +1 -1
- package/dist/utils/getIconForType.js.map +1 -1
- package/dist/utils/getLineAnnotationName.d.ts.map +1 -1
- package/dist/utils/getLineAnnotationName.js +1 -1
- package/dist/utils/getLineAnnotationName.js.map +1 -1
- package/dist/utils/getLineEndingType.d.ts.map +1 -1
- package/dist/utils/getLineEndingType.js +1 -1
- package/dist/utils/getLineEndingType.js.map +1 -1
- package/dist/utils/getLineNodes.d.ts +1 -1
- package/dist/utils/getLineNodes.d.ts.map +1 -1
- package/dist/utils/getLineNodes.js +1 -1
- package/dist/utils/getLineNodes.js.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.d.ts.map +1 -1
- package/dist/utils/getMergeConflictActionSlotName.js +1 -1
- package/dist/utils/getMergeConflictActionSlotName.js.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.d.ts.map +1 -1
- package/dist/utils/getMergeConflictLineTypes.js +1 -2
- package/dist/utils/getMergeConflictLineTypes.js.map +1 -1
- package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -1
- package/dist/utils/getOrCreateCodeNode.js +1 -1
- package/dist/utils/getOrCreateCodeNode.js.map +1 -1
- package/dist/utils/getSingularPatch.d.ts.map +1 -1
- package/dist/utils/getSingularPatch.js +1 -2
- package/dist/utils/getSingularPatch.js.map +1 -1
- package/dist/utils/getThemes.d.ts.map +1 -1
- package/dist/utils/getThemes.js +1 -2
- package/dist/utils/getThemes.js.map +1 -1
- package/dist/utils/getTotalLineCountFromHunks.d.ts.map +1 -1
- package/dist/utils/getTotalLineCountFromHunks.js +1 -1
- package/dist/utils/getTotalLineCountFromHunks.js.map +1 -1
- package/dist/utils/hast_utils.d.ts +1 -1
- package/dist/utils/hast_utils.d.ts.map +1 -1
- package/dist/utils/hast_utils.js +1 -1
- package/dist/utils/hast_utils.js.map +1 -1
- package/dist/utils/hostTheme.d.ts.map +1 -1
- package/dist/utils/hostTheme.js +1 -2
- package/dist/utils/hostTheme.js.map +1 -1
- package/dist/utils/includesFileAnnotations.d.ts.map +1 -1
- package/dist/utils/includesFileAnnotations.js +5 -5
- package/dist/utils/includesFileAnnotations.js.map +1 -1
- package/dist/utils/isDefaultRenderRange.d.ts.map +1 -1
- package/dist/utils/isDefaultRenderRange.js +1 -1
- package/dist/utils/isDefaultRenderRange.js.map +1 -1
- package/dist/utils/isDiffPlainText.d.ts.map +1 -1
- package/dist/utils/isDiffPlainText.js +1 -2
- package/dist/utils/isDiffPlainText.js.map +1 -1
- package/dist/utils/isFilePlainText.d.ts.map +1 -1
- package/dist/utils/isFilePlainText.js +1 -2
- package/dist/utils/isFilePlainText.js.map +1 -1
- package/dist/utils/isStyleNode.d.ts.map +1 -1
- package/dist/utils/isStyleNode.js +1 -1
- package/dist/utils/isStyleNode.js.map +1 -1
- package/dist/utils/isWorkerContext.d.ts.map +1 -1
- package/dist/utils/isWorkerContext.js +1 -1
- package/dist/utils/isWorkerContext.js.map +1 -1
- package/dist/utils/iterateOverDiff.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.js +44 -45
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/iterateOverFile.d.ts.map +1 -1
- package/dist/utils/iterateOverFile.js +1 -1
- package/dist/utils/iterateOverFile.js.map +1 -1
- package/dist/utils/normalizeDiffResolution.d.ts.map +1 -1
- package/dist/utils/normalizeDiffResolution.js +1 -1
- package/dist/utils/normalizeDiffResolution.js.map +1 -1
- package/dist/utils/parseDiffDecorations.d.ts.map +1 -1
- package/dist/utils/parseDiffDecorations.js +1 -2
- package/dist/utils/parseDiffDecorations.js.map +1 -1
- package/dist/utils/parseDiffFromFile.d.ts +0 -1
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +1 -2
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/parseLineType.d.ts.map +1 -1
- package/dist/utils/parseLineType.js +1 -1
- package/dist/utils/parseLineType.js.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseMergeConflictDiffFromFile.js +5 -5
- package/dist/utils/parseMergeConflictDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +6 -7
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/prefersReducedMotion.d.ts.map +1 -1
- package/dist/utils/prefersReducedMotion.js +1 -1
- package/dist/utils/prefersReducedMotion.js.map +1 -1
- package/dist/utils/prerenderHTMLIfNecessary.d.ts.map +1 -1
- package/dist/utils/prerenderHTMLIfNecessary.js +1 -1
- package/dist/utils/prerenderHTMLIfNecessary.js.map +1 -1
- package/dist/utils/processLine.d.ts +1 -1
- package/dist/utils/processLine.d.ts.map +1 -1
- package/dist/utils/processLine.js +1 -2
- package/dist/utils/processLine.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +4 -5
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +1 -2
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/resolveConflict.d.ts.map +1 -1
- package/dist/utils/resolveConflict.js +1 -2
- package/dist/utils/resolveConflict.js.map +1 -1
- package/dist/utils/resolveRegion.d.ts.map +1 -1
- package/dist/utils/resolveRegion.js +1 -1
- package/dist/utils/resolveRegion.js.map +1 -1
- package/dist/utils/roundToDevicePixel.d.ts.map +1 -1
- package/dist/utils/roundToDevicePixel.js +1 -1
- package/dist/utils/roundToDevicePixel.js.map +1 -1
- package/dist/utils/scrollbarGutter.d.ts.map +1 -1
- package/dist/utils/scrollbarGutter.js +1 -2
- package/dist/utils/scrollbarGutter.js.map +1 -1
- package/dist/utils/setLanguageOverride.d.ts.map +1 -1
- package/dist/utils/setLanguageOverride.js +1 -1
- package/dist/utils/setLanguageOverride.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +1 -2
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/utils/shouldUseTokenTransformer.d.ts.map +1 -1
- package/dist/utils/shouldUseTokenTransformer.js +1 -1
- package/dist/utils/shouldUseTokenTransformer.js.map +1 -1
- package/dist/utils/splitFileContents.d.ts.map +1 -1
- package/dist/utils/splitFileContents.js +1 -2
- package/dist/utils/splitFileContents.js.map +1 -1
- package/dist/utils/trimPatchContext.d.ts.map +1 -1
- package/dist/utils/trimPatchContext.js +1 -2
- package/dist/utils/trimPatchContext.js.map +1 -1
- package/dist/utils/virtualDiffLayout.d.ts.map +1 -1
- package/dist/utils/virtualDiffLayout.js +1 -2
- package/dist/utils/virtualDiffLayout.js.map +1 -1
- package/dist/utils/wrapTokenFragments.d.ts +1 -1
- package/dist/utils/wrapTokenFragments.d.ts.map +1 -1
- package/dist/utils/wrapTokenFragments.js +1 -2
- package/dist/utils/wrapTokenFragments.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +5 -5
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/getOrCreateWorkerPoolSingleton.d.ts.map +1 -1
- package/dist/worker/getOrCreateWorkerPoolSingleton.js +1 -2
- package/dist/worker/getOrCreateWorkerPoolSingleton.js.map +1 -1
- package/dist/worker/index.js +1 -2
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/wasm-B9ZqxnKj.js +8 -0
- package/dist/worker/wasm-B9ZqxnKj.js.map +1 -0
- package/dist/worker/worker-portable.js +2763 -6368
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +89 -124
- package/dist/worker/worker.js.map +1 -1
- package/package.json +15 -13
- package/dist/worker/wasm-qE0LgnY3.js +0 -10
- package/dist/worker/wasm-qE0LgnY3.js.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { CUSTOM_HEADER_SLOT_ID
|
|
1
|
+
import { CUSTOM_HEADER_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
|
-
|
|
6
5
|
//#region src/react/utils/renderFileChildren.tsx
|
|
7
6
|
function renderFileChildren({ file, renderCustomHeader, renderHeaderPrefix, renderHeaderMetadata, renderAnnotation, lineAnnotations, renderGutterUtility, getHoveredLine }) {
|
|
8
7
|
const customHeader = renderCustomHeader?.(file);
|
|
@@ -13,10 +12,10 @@ function renderFileChildren({ file, renderCustomHeader, renderHeaderPrefix, rend
|
|
|
13
12
|
slot: CUSTOM_HEADER_SLOT_ID,
|
|
14
13
|
children: customHeader
|
|
15
14
|
}) : /* @__PURE__ */ jsxs(Fragment, { children: [prefix != null && /* @__PURE__ */ jsx("div", {
|
|
16
|
-
slot:
|
|
15
|
+
slot: "header-prefix",
|
|
17
16
|
children: prefix
|
|
18
17
|
}), metadata != null && /* @__PURE__ */ jsx("div", {
|
|
19
|
-
slot:
|
|
18
|
+
slot: "header-metadata",
|
|
20
19
|
children: metadata
|
|
21
20
|
})] }),
|
|
22
21
|
renderAnnotation != null && lineAnnotations?.map((annotation, index) => /* @__PURE__ */ jsx("div", {
|
|
@@ -30,7 +29,7 @@ function renderFileChildren({ file, renderCustomHeader, renderHeaderPrefix, rend
|
|
|
30
29
|
})
|
|
31
30
|
] });
|
|
32
31
|
}
|
|
33
|
-
|
|
34
32
|
//#endregion
|
|
35
33
|
export { renderFileChildren };
|
|
34
|
+
|
|
36
35
|
//# sourceMappingURL=renderFileChildren.js.map
|
|
@@ -1 +1 @@
|
|
|
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 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 getHoveredLine,\n}: RenderFileChildrenProps<LAnnotation>): ReactNode {\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 {renderGutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {renderGutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n"],"mappings":"
|
|
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 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 getHoveredLine,\n}: RenderFileChildrenProps<LAnnotation>): ReactNode {\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 {renderGutterUtility != null && (\n <div slot=\"gutter-utility-slot\" style={GutterUtilitySlotStyles}>\n {renderGutterUtility(getHoveredLine)}\n </div>\n )}\n </>\n );\n}\n"],"mappings":";;;;;AAwBA,SAAgB,mBAAgC,EAC9C,MACA,oBACA,oBACA,sBACA,kBACA,iBACA,qBACA,kBACkD;CAClD,MAAM,eAAe,qBAAqB,IAAI;CAC9C,MAAM,SAAS,qBAAqB,IAAI;CACxC,MAAM,WAAW,uBAAuB,IAAI;CAC5C,OACE,qBAAA,UAAA,EAAA,UAAA;EACG,gBAAgB,OACf,oBAAC,OAAD;GAAK,MAAM;aAAwB;EAAkB,CAAA,IAErD,qBAAA,UAAA,EAAA,UAAA,CACG,UAAU,QAAQ,oBAAC,OAAD;GAAK,MAAA;aAA8B;EAAY,CAAA,GACjE,YAAY,QACX,oBAAC,OAAD;GAAK,MAAA;aAAgC;EAAc,CAAA,CAErD,EAAA,CAAA;EAEH,oBAAoB,QACnB,iBAAiB,KAAK,YAAY,UAChC,oBAAC,OAAD;GAAiB,MAAM,sBAAsB,UAAU;aACpD,iBAAiB,UAAU;EACzB,GAFK,KAEL,CACN;EACF,uBAAuB,QACtB,oBAAC,OAAD;GAAK,MAAK;GAAsB,OAAO;aACpC,oBAAoB,cAAc;EAChC,CAAA;CAEP,EAAA,CAAA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateRender.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"templateRender.d.ts","names":[],"sources":["../../../src/react/utils/templateRender.tsx"],"mappings":";;;iBAEgB,cAAA,CACd,QAAA,EAAU,SAAA,EACV,MAAA,uBACC,SAAS"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
2
|
//#region src/react/utils/templateRender.tsx
|
|
4
3
|
function templateRender(children, __html) {
|
|
5
4
|
if (typeof window === "undefined" && __html != null) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("template", {
|
|
@@ -8,7 +7,7 @@ function templateRender(children, __html) {
|
|
|
8
7
|
}), children] });
|
|
9
8
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
//#endregion
|
|
13
11
|
export { templateRender };
|
|
12
|
+
|
|
14
13
|
//# sourceMappingURL=templateRender.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateRender.js","names":[],"sources":["../../../src/react/utils/templateRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nexport function templateRender(\n children: ReactNode,\n __html: string | undefined\n): ReactNode {\n if (typeof window === 'undefined' && __html != null) {\n return (\n <>\n <template\n // @ts-expect-error unclear how to fix this\n shadowrootmode=\"open\"\n dangerouslySetInnerHTML={{ __html }}\n />\n {children}\n </>\n );\n }\n return <>{children}</>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"templateRender.js","names":[],"sources":["../../../src/react/utils/templateRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nexport function templateRender(\n children: ReactNode,\n __html: string | undefined\n): ReactNode {\n if (typeof window === 'undefined' && __html != null) {\n return (\n <>\n <template\n // @ts-expect-error unclear how to fix this\n shadowrootmode=\"open\"\n dangerouslySetInnerHTML={{ __html }}\n />\n {children}\n </>\n );\n }\n return <>{children}</>;\n}\n"],"mappings":";;AAEA,SAAgB,eACd,UACA,QACW;CACX,IAAI,OAAO,WAAW,eAAe,UAAU,MAC7C,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,YAAD;EAEE,gBAAe;EACf,yBAAyB,EAAE,OAAO;CACnC,CAAA,GACA,QACD,EAAA,CAAA;CAGN,OAAO,oBAAA,UAAA,EAAG,SAAW,CAAA;AACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileDiffInstance.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"useFileDiffInstance.d.ts","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"mappings":";;;;;UA0BU,wBAAA;EACR,QAAA,EAAU,gBAAA;EACV,OAAA,EAAS,eAAA,CAAgB,WAAA;EACzB,eAAA,EAAiB,kBAAA,CAAmB,WAAA;EACpC,aAAA,EAAe,iBAAA;EACf,eAAA;EACA,OAAA,GAAU,kBAAA;EACV,sBAAA;EACA,eAAA;EACA,iBAAA;AAAA;AAAA,UAGQ,yBAAA;EACR,GAAA,CAAI,IAAA,EAAM,WAAA;EACV,cAAA,IAAkB,oBAAoB;AAAA;AAAA,iBAGxB,mBAAA;EACd,QAAA;EACA,OAAA;EACA,eAAA;EACA,aAAA;EACA,eAAA;EACA,OAAA;EACA,sBAAA;EACA,eAAA;EACA;AAAA,GACC,wBAAA,CAAyB,WAAA,IAAe,yBAAA"}
|
|
@@ -6,7 +6,6 @@ import { useStableCallback } from "./useStableCallback.js";
|
|
|
6
6
|
import { WorkerPoolContext } from "../WorkerPoolContext.js";
|
|
7
7
|
import { useVirtualizer } from "../Virtualizer.js";
|
|
8
8
|
import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
9
|
-
|
|
10
9
|
//#region src/react/utils/useFileDiffInstance.ts
|
|
11
10
|
const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
12
11
|
function useFileDiffInstance({ fileDiff, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
|
|
@@ -75,7 +74,7 @@ function mergeFileDiffOptions({ options, controlledSelection, hasCustomHeader, h
|
|
|
75
74
|
renderGutterUtility: hasGutterRenderUtility ? noopRender : options?.renderGutterUtility
|
|
76
75
|
};
|
|
77
76
|
}
|
|
78
|
-
|
|
79
77
|
//#endregion
|
|
80
78
|
export { useFileDiffInstance };
|
|
79
|
+
|
|
81
80
|
//# sourceMappingURL=useFileDiffInstance.js.map
|
|
@@ -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 { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileDiffMetadata,\n SelectedLineRange,\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 controlledSelection = selectedLines !== undefined;\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 controlledSelection,\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 controlledSelection,\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 controlledSelection,\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 controlledSelection: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) {\n return options;\n }\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n };\n}\n"],"mappings":"
|
|
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 { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileDiffMetadata,\n SelectedLineRange,\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 controlledSelection = selectedLines !== undefined;\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 controlledSelection,\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 controlledSelection,\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 controlledSelection,\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 controlledSelection: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n options: FileDiffOptions<LAnnotation> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileDiffOptionsProps<LAnnotation>):\n | FileDiffOptions<LAnnotation>\n | undefined {\n if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) {\n return options;\n }\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n };\n}\n"],"mappings":";;;;;;;;;AAuBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,oBAAiC,EAC/C,UACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,qBACmE;CACnE,MAAM,oBAAoB,eAAe;CACzC,MAAM,sBAAsB,kBAAkB,KAAA;CAC9C,MAAM,cAAc,WAAW,iBAAiB;CAChD,MAAM,cAAc,OAElB,IAAI;CACN,MAAM,MAAM,mBAAmB,kBAAsC;EACnE,IAAI,iBAAiB,MAAM;GACzB,IAAI,YAAY,WAAW,MACzB,MAAM,IAAI,MACR,kFACF;GAEF,IAAI,qBAAqB,MACvB,YAAY,UAAU,IAAI,oBACxB,qBAAqB;IACnB;IACA;IACA;IACA;GACF,CAAC,GACD,mBACA,SACA,CAAC,oBAAoB,cAAc,KAAA,GACnC,IACF;QAEA,YAAY,UAAU,IAAI,SACxB,qBAAqB;IACnB;IACA;IACA;IACA;GACF,CAAC,GACD,CAAC,oBAAoB,cAAc,KAAA,GACnC,IACF;GAEF,YAAiB,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;GACF,CAAC;EACH,OAAO;GACL,IAAI,YAAY,WAAW,MACzB,MAAM,IAAI,MACR,uEACF;GAEF,YAAY,QAAQ,QAAQ;GAC5B,YAAY,UAAU;EACxB;CACF,CAAC;CAED,yBAAyB;EACvB,MAAM,EAAE,SAAS,aAAa;EAC9B,IAAI,YAAY,MAAM;EACtB,MAAM,aAAa,qBAAqB;GACtC;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,UAAU;EACjE,SAAS,WAAW,UAAU;EAC9B,SAAc,OAAO;GACnB;GACA;GACA;EACF,CAAC;EACD,IAAI,kBAAkB,KAAA,GACpB,SAAS,iBAAiB,aAAa;CAE3C,CAAC;CAQD,OAAO;EAAE;EAAK,gBANS,kBAEN;GACf,OAAO,YAAY,SAAS,eAAe;EAC7C,GAAG,CAAC,CAEuB;CAAE;AAC/B;AASA,SAAS,qBAAkC,EACzC,SACA,qBACA,iBACA,0BAGY;CACZ,IAAI,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,iBACtD,OAAO;CAET,OAAO;EACL,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;CACf;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileInstance.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"useFileInstance.d.ts","names":[],"sources":["../../../src/react/utils/useFileInstance.ts"],"mappings":";;;;;UA0BU,oBAAA;EACR,IAAA,EAAM,YAAA;EACN,OAAA,EAAS,WAAA,CAAY,WAAA;EACrB,eAAA,EAAiB,cAAA,CAAe,WAAA;EAChC,aAAA,EAAe,iBAAA;EACf,eAAA;EACA,OAAA,GAAU,kBAAA;EACV,sBAAA;EACA,eAAA;EACA,iBAAA;AAAA;AAAA,UAGQ,qBAAA;EACR,GAAA,CAAI,IAAA,EAAM,WAAA;EACV,cAAA,IAAkB,oBAAoB;AAAA;AAAA,iBAGxB,eAAA;EACd,IAAA;EACA,OAAA;EACA,eAAA;EACA,aAAA;EACA,eAAA;EACA,OAAA;EACA,sBAAA;EACA,eAAA;EACA;AAAA,GACC,oBAAA,CAAqB,WAAA,IAAe,qBAAA"}
|
|
@@ -6,7 +6,6 @@ import { useStableCallback } from "./useStableCallback.js";
|
|
|
6
6
|
import { WorkerPoolContext } from "../WorkerPoolContext.js";
|
|
7
7
|
import { useVirtualizer } from "../Virtualizer.js";
|
|
8
8
|
import { useCallback, useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
9
|
-
|
|
10
9
|
//#region src/react/utils/useFileInstance.ts
|
|
11
10
|
const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
12
11
|
function useFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
|
|
@@ -74,7 +73,7 @@ function mergeFileOptions({ options, controlledSelection, hasCustomHeader, hasGu
|
|
|
74
73
|
renderGutterUtility: hasGutterRenderUtility ? noopRender : options?.renderGutterUtility
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
|
-
|
|
78
76
|
//#endregion
|
|
79
77
|
export { useFileInstance };
|
|
78
|
+
|
|
80
79
|
//# sourceMappingURL=useFileInstance.js.map
|
|
@@ -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 { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\n SelectedLineRange,\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 controlledSelection = selectedLines !== undefined;\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 controlledSelection,\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 controlledSelection,\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 controlledSelection,\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 controlledSelection: boolean;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n}\n\nfunction mergeFileOptions<LAnnotation>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileOptionsProps<LAnnotation>): FileOptions<LAnnotation> | undefined {\n if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) {\n return options;\n }\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n };\n}\n"],"mappings":"
|
|
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 { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n FileContents,\n LineAnnotation,\n SelectedLineRange,\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 controlledSelection = selectedLines !== undefined;\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 controlledSelection,\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 controlledSelection,\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 controlledSelection,\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 controlledSelection: boolean;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n}\n\nfunction mergeFileOptions<LAnnotation>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeFileOptionsProps<LAnnotation>): FileOptions<LAnnotation> | undefined {\n if (!controlledSelection && !hasGutterRenderUtility && !hasCustomHeader) {\n return options;\n }\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n };\n}\n"],"mappings":";;;;;;;;;AAuBA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAmB9C,SAAgB,gBAA6B,EAC3C,MACA,SACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,qBAC2D;CAC3D,MAAM,oBAAoB,eAAe;CACzC,MAAM,sBAAsB,kBAAkB,KAAA;CAC9C,MAAM,cAAc,WAAW,iBAAiB;CAChD,MAAM,cAAc,OAElB,IAAI;CACN,MAAM,MAAM,mBAAmB,SAA6B;EAC1D,IAAI,QAAQ,MAAM;GAChB,IAAI,YAAY,WAAW,MACzB,MAAM,IAAI,MACR,mEACF;GAEF,IAAI,qBAAqB,MACvB,YAAY,UAAU,IAAI,gBACxB,iBAAiB;IACf;IACA;IACA;IACA;GACF,CAAC,GACD,mBACA,SACA,CAAC,oBAAoB,cAAc,KAAA,GACnC,IACF;QAEA,YAAY,UAAU,IAAI,KACxB,iBAAiB;IACf;IACA;IACA;IACA;GACF,CAAC,GACD,CAAC,oBAAoB,cAAc,KAAA,GACnC,IACF;GAEF,YAAiB,QAAQ,QAAQ;IAC/B;IACA,eAAe;IACf;IACA;GACF,CAAC;EACH,OAAO;GACL,IAAI,YAAY,WAAW,MACzB,MAAM,IAAI,MAAM,oDAAoD;GAEtE,YAAY,QAAQ,QAAQ;GAC5B,YAAY,UAAU;EACxB;CACF,CAAC;CAED,yBAAyB;EACvB,IAAI,YAAY,WAAW,MAAM;EACjC,MAAM,aAAa,iBAAiB;GAClC;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM,cAAc,CAAC,gBACnB,YAAY,QAAQ,SACpB,UACF;EACA,YAAY,QAAQ,WAAW,UAAU;EACzC,YAAiB,QAAQ,OAAO;GAAE;GAAM;GAAiB;EAAY,CAAC;EACtE,IAAI,kBAAkB,KAAA,GACpB,YAAY,QAAQ,iBAAiB,aAAa;CAEtD,CAAC;CAOD,OAAO;EAAE;EAAK,gBALS,kBAEN;GACf,OAAO,YAAY,SAAS,eAAe;EAC7C,GAAG,CAAC,CACuB;CAAE;AAC/B;AASA,SAAS,iBAA8B,EACrC,SACA,qBACA,iBACA,0BAC2E;CAC3E,IAAI,CAAC,uBAAuB,CAAC,0BAA0B,CAAC,iBACtD,OAAO;CAET,OAAO;EACL,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;CACf;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStableCallback.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"useStableCallback.d.ts","names":[],"sources":["../../../src/react/utils/useStableCallback.ts"],"mappings":";iBAGgB,iBAAA,eAAgC,IAAA,iBAC9C,QAAA,EAAU,CAAA,GACT,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useCallback, useInsertionEffect, useRef } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/react/utils/useStableCallback.ts
|
|
4
3
|
function useStableCallback(callback) {
|
|
5
4
|
const callbackRef = useRef(callback);
|
|
@@ -8,7 +7,7 @@ function useStableCallback(callback) {
|
|
|
8
7
|
return callbackRef.current(...args);
|
|
9
8
|
}, []);
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
//#endregion
|
|
13
11
|
export { useStableCallback };
|
|
12
|
+
|
|
14
13
|
//# sourceMappingURL=useStableCallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStableCallback.js","names":[],"sources":["../../../src/react/utils/useStableCallback.ts"],"sourcesContent":["import { useCallback, useInsertionEffect, useRef } from 'react';\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport function useStableCallback<T extends (...args: any[]) => any>(\n callback: T\n): T {\n const callbackRef = useRef(callback);\n useInsertionEffect(() => void (callbackRef.current = callback));\n return useCallback((...args: Parameters<T>): ReturnType<T> => {\n // oxlint-disable-next-line typescript/no-unsafe-return\n return callbackRef.current(...args);\n }, []) as T;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStableCallback.js","names":[],"sources":["../../../src/react/utils/useStableCallback.ts"],"sourcesContent":["import { useCallback, useInsertionEffect, useRef } from 'react';\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport function useStableCallback<T extends (...args: any[]) => any>(\n callback: T\n): T {\n const callbackRef = useRef(callback);\n useInsertionEffect(() => void (callbackRef.current = callback));\n return useCallback((...args: Parameters<T>): ReturnType<T> => {\n // oxlint-disable-next-line typescript/no-unsafe-return\n return callbackRef.current(...args);\n }, []) as T;\n}\n"],"mappings":";;AAGA,SAAgB,kBACd,UACG;CACH,MAAM,cAAc,OAAO,QAAQ;CACnC,yBAAyB,MAAM,YAAY,UAAU,SAAS;CAC9D,OAAO,aAAa,GAAG,SAAuC;EAE5D,OAAO,YAAY,QAAQ,GAAG,IAAI;CACpC,GAAG,CAAC,CAAC;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnresolvedFileInstance.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"useUnresolvedFileInstance.d.ts","names":[],"sources":["../../../src/react/utils/useUnresolvedFileInstance.ts"],"mappings":";;;;;;;UAoCU,8BAAA;EACR,IAAA,EAAM,YAAA;EACN,OAAA,GAAU,0BAAA,CAA2B,WAAA;EACrC,eAAA,EAAiB,kBAAA,CAAmB,WAAA;EACpC,aAAA,EAAe,iBAAA;EACf,eAAA;EACA,kBAAA;EACA,sBAAA;EACA,eAAA;EACA,iBAAA;AAAA;AAAA,UAGQ,+BAAA;EACR,QAAA,EAAU,gBAAA;EACV,OAAA,GAAU,uBAAA;EACV,UAAA,EAAY,sBAAA;EACZ,GAAA,CAAI,IAAA,EAAM,WAAA;EACV,cAAA,IAAkB,oBAAA;EAClB,WAAA,IAAe,cAAA,CAAe,WAAA;AAAA;AAAA,iBAGhB,yBAAA;EACd,IAAA;EACA,OAAA;EACA,eAAA;EACA,aAAA;EACA,eAAA;EACA,kBAAA;EACA,sBAAA;EACA,eAAA;EACA;AAAA,GACC,8BAAA,CAA+B,WAAA,IAAe,+BAAA,CAAgC,WAAA"}
|
|
@@ -5,26 +5,25 @@ import { noopRender } from "../constants.js";
|
|
|
5
5
|
import { useStableCallback } from "./useStableCallback.js";
|
|
6
6
|
import { WorkerPoolContext } from "../WorkerPoolContext.js";
|
|
7
7
|
import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
8
|
-
|
|
9
8
|
//#region src/react/utils/useUnresolvedFileInstance.ts
|
|
10
9
|
const useIsometricEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
11
10
|
function useUnresolvedFileInstance({ file, options, lineAnnotations, selectedLines, prerenderedHTML, hasConflictUtility, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool }) {
|
|
12
11
|
const [{ fileDiff, actions, markerRows }, setState] = useState(() => {
|
|
13
|
-
const { fileDiff
|
|
12
|
+
const { fileDiff, actions, markerRows } = parseMergeConflictDiffFromFile(file, options?.maxContextLines);
|
|
14
13
|
return {
|
|
15
|
-
fileDiff
|
|
16
|
-
actions
|
|
17
|
-
markerRows
|
|
14
|
+
fileDiff,
|
|
15
|
+
actions,
|
|
16
|
+
markerRows
|
|
18
17
|
};
|
|
19
18
|
});
|
|
20
19
|
const onMergeConflictAction = useStableCallback((payload, instance) => {
|
|
21
20
|
setState((prevState) => {
|
|
22
|
-
const { fileDiff
|
|
23
|
-
if (fileDiff
|
|
21
|
+
const { fileDiff, actions, markerRows } = instance.resolveConflict(payload.conflict.conflictIndex, payload.resolution, prevState.fileDiff) ?? {};
|
|
22
|
+
if (fileDiff == null || actions == null || markerRows == null) return prevState;
|
|
24
23
|
else return {
|
|
25
|
-
fileDiff
|
|
26
|
-
actions
|
|
27
|
-
markerRows
|
|
24
|
+
fileDiff,
|
|
25
|
+
actions,
|
|
26
|
+
markerRows
|
|
28
27
|
};
|
|
29
28
|
});
|
|
30
29
|
});
|
|
@@ -102,7 +101,7 @@ function mergeUnresolvedOptions({ options, controlledSelection, onMergeConflictA
|
|
|
102
101
|
renderGutterUtility: hasGutterRenderUtility ? noopRender : void 0
|
|
103
102
|
};
|
|
104
103
|
}
|
|
105
|
-
|
|
106
104
|
//#endregion
|
|
107
105
|
export { useUnresolvedFileInstance };
|
|
106
|
+
|
|
108
107
|
//# sourceMappingURL=useUnresolvedFileInstance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnresolvedFileInstance.js","names":["
|
|
1
|
+
{"version":3,"file":"useUnresolvedFileInstance.js","names":["UnresolvedFileClass"],"sources":["../../../src/react/utils/useUnresolvedFileInstance.ts"],"sourcesContent":["import {\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n UnresolvedFile,\n UnresolvedFile as UnresolvedFileClass,\n type UnresolvedFileOptions,\n} from '../../components/UnresolvedFile';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n MergeConflictActionPayload,\n MergeConflictMarkerRow,\n SelectedLineRange,\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 controlledSelection = selectedLines !== undefined;\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 controlledSelection,\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 controlledSelection,\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 controlledSelection: boolean;\n onMergeConflictAction: UnresolvedFileOptions<LAnnotation>['onMergeConflictAction'];\n hasConflictUtility: boolean;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n}\n\nfunction mergeUnresolvedOptions<LAnnotation>({\n options,\n controlledSelection,\n onMergeConflictAction,\n hasConflictUtility,\n hasCustomHeader,\n hasGutterRenderUtility,\n}: MergeUnresolvedOptionsProps<LAnnotation>): UnresolvedFileOptions<LAnnotation> {\n return {\n ...options,\n controlledSelection,\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":";;;;;;;;AAiCA,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,UAAU,SAAS,eAAe,+BACxC,MACA,SAAS,eACX;EACA,OAAO;GAAE;GAAU;GAAS;EAAW;CACzC,CAAC;CAID,MAAM,wBAAwB,mBAE1B,SACA,aACG;EACH,UAAU,cAAc;GACtB,MAAM,EAAE,UAAU,SAAS,eACzB,SAAS,gBACP,QAAQ,SAAS,eACjB,QAAQ,YACR,UAAU,QACZ,KAAK,CAAC;GACR,IAAI,YAAY,QAAQ,WAAW,QAAQ,cAAc,MACvD,OAAO;QAEP,OAAO;IAAE;IAAU;IAAS;GAAW;EAE3C,CAAC;CACH,CACF;CACA,MAAM,sBAAsB,kBAAkB,KAAA;CAC9C,MAAM,cAAc,WAAW,iBAAiB;CAChD,MAAM,cAAc,OAAgD,IAAI;CACxE,MAAM,MAAM,mBAAmB,kBAAsC;EACnE,IAAI,iBAAiB,MAAM;GACzB,IAAI,YAAY,WAAW,MACzB,MAAM,IAAI,MACR,wFACF;GAEF,YAAY,UAAU,IAAIA,eACxB,uBAAuB;IACrB;IACA;IACA;IACA;IACA;IACA;GACF,CAAC,GACD,CAAC,oBAAoB,cAAc,KAAA,GACnC,IACF;GACA,YAAiB,QAAQ,QAAQ;IAC/B;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACH,OAAO;GACL,IAAI,YAAY,WAAW,MACzB,MAAM,IAAI,MACR,mFACF;GAEF,YAAY,QAAQ,QAAQ;GAC5B,YAAY,UAAU;EACxB;CACF,CAAC;CAED,yBAAyB;EACvB,IAAI,YAAY,WAAW,MAAM;EACjC,MAAM,WAAW,YAAY;EAC7B,MAAM,aAAa,uBAAuB;GACxC;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM,cAAc,CAAC,gBAAgB,SAAS,SAAS,UAAU;EACjE,SAAS,WAAW,UAAU;EAC9B,SAAc,OAAO;GACnB;GACA;GACA;GACA;GACA;EACF,CAAC;EACD,IAAI,kBAAkB,KAAA,GACpB,SAAS,iBAAiB,aAAa;CAE3C,CAAC;CAYD,OAAO;EAAE;EAAK,gBAVS,kBAEN;GACf,OAAO,YAAY,SAAS,eAAe;EAC7C,GAAG,CAAC,CAMuB;EAAG;EAAU;EAAS;EAAY,aAJzC,kBAAkB;GACpC,OAAO,YAAY,WAAW,KAAA;EAChC,GAAG,CAAC,CAEmE;CAAE;AAC3E;AAWA,SAAS,uBAAoC,EAC3C,SACA,qBACA,uBACA,oBACA,iBACA,0BAC+E;CAC/E,OAAO;EACL,GAAG;EACH;EACA;EACA,gBACE,SAAS,mBAAmB,WACxB,aACA,SAAS;EAEf,0BACE,sBAAsB,SAAS,6BAA6B,WACxD,aACA,SAAS;EACf,oBAAoB,kBAAkB,aAAa,KAAA;EACnD,qBAAqB,yBAAyB,aAAa,KAAA;CAC7D;AACF"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { Element, ElementContent, Properties } from "../node_modules/.pnpm/@types_hast@3.0.4/node_modules/@types/hast/index.js";
|
|
1
2
|
import { BaseDiffOptions, BaseDiffOptionsWithDefaults, CustomPreProperties, DiffLineAnnotation, ExpansionDirections, FileDiffMetadata, FileHeaderRenderMode, HunkData, HunkExpansionRegion, LineTypes, RenderDiffOptions, RenderRange, ThemedDiffResult } from "../types.js";
|
|
2
3
|
import { WorkerPoolManager } from "../worker/WorkerPoolManager.js";
|
|
3
|
-
import "../worker/index.js";
|
|
4
4
|
import { DiffLineMetadata } from "../utils/iterateOverDiff.js";
|
|
5
|
-
import { Element, ElementContent, Properties } from "hast";
|
|
6
5
|
|
|
7
6
|
//#region src/renderers/DiffHunksRenderer.d.ts
|
|
8
7
|
interface DiffHunksRendererOptions extends BaseDiffOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiffHunksRenderer.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"DiffHunksRenderer.d.ts","names":[],"sources":["../../src/renderers/DiffHunksRenderer.ts"],"mappings":";;;;;;UAwHiB,wBAAA,SAAiC,eAAe;EAC/D,gBAAA,GAAmB,oBAAA;AAAA;AAAA,UAGJ,oCAAA,SAA6C,IAAA,CAC5D,2BAAA;EAGA,gBAAA,EAAkB,oBAAA;AAAA;AAAA,UAGH,0BAAA;EACf,IAAA;EACA,QAAA,EAAU,SAAS;EACnB,iBAAA;EACA,iBAAA;AAAA;AAAA,UAGe,wBAAA;EACf,IAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,UAGe,cAAA;EACf,cAAA,EAAgB,SAAA;EAChB,gBAAA,GAAmB,UAAA;EACnB,iBAAA,GAAoB,UAAA;AAAA;AAAA,UAUL,mBAAA;EACf,IAAA;EACA,SAAA;EACA,SAAA;EACA,gBAAA;EACA,cAAA;EACA,YAAA,GAAe,gBAAA;EACf,YAAA,GAAe,gBAAgB;AAAA;AAAA,UAGhB,WAAA;EACf,OAAA,EAAS,OAAA;EACT,MAAA,EAAQ,OAAW;AAAA;AAAA,UAGJ,gBAAA;EACf,QAAA,EAAU,WAAA;EACV,QAAA,EAAU,WAAW;AAAA;AAAA,UAGN,2BAAA;EACf,MAAA,GAAS,WAAA;EACT,KAAA,GAAQ,WAAW;AAAA;AAAA,UAGJ,yBAAA;EACf,MAAA,GAAS,gBAAA;EACT,KAAA,GAAQ,gBAAgB;AAAA;AAAA,UAGT,iBAAA;EACf,gBAAA,EAAkB,cAAA;EAClB,iBAAA,EAAmB,cAAA;EACnB,kBAAA,EAAoB,cAAA;EACpB,mBAAA,EAAqB,cAAA;EACrB,kBAAA,EAAoB,cAAA;EACpB,mBAAA,EAAqB,cAAA;EACrB,QAAA,EAAU,QAAA;EACV,GAAA;EACA,OAAA,EAAS,OAAA;EACT,aAAA,EAAe,OAAA;EACf,UAAA;EACA,WAAA;EACA,aAAA;EACA,QAAA;EACA,YAAA;EACA,WAAA;AAAA;AAAA,cAKW,iBAAA;EAeF,OAAA,EAAS,wBAAA;EAAA,QACR,cAAA;EAAA,QACA,aAAA;EAAA,SAhBD,IAAA;EAAA,QAED,WAAA;EAAA,QACA,IAAA;EAAA,QAEA,aAAA;EAAA,QAEA,mBAAA;EAAA,QACA,mBAAA;EAAA,QAEA,YAAA;EAAA,QACA,WAAA;EAER,WAAA,CACS,OAAA,GAAS,wBAAA,EACR,cAAA,gCACA,aAAA,GAAgB,iBAAA;EASnB,OAAA;EAOA,OAAA;EASA,gBAAA;EAIA,UAAA,CAAW,OAAA,EAAS,wBAAA;EAIpB,YAAA,CAAa,OAAA,EAAS,OAAA,CAAQ,wBAAA;EAI9B,UAAA,CACL,KAAA,UACA,SAAA,EAAW,mBAAA,EACX,kBAAA;EAuBK,eAAA,CAAgB,SAAA,WAAoB,mBAAA;EAIpC,mBAAA,IAAuB,GAAA,SAAY,mBAAA;EAInC,kBAAA,CACL,eAAA,EAAiB,kBAAA,CAAmB,WAAA;EAAA,UAmB5B,wBAAA;IACR;EAAA,GACC,0BAAA,GAA6B,cAAA;EAAA,UAItB,sBAAA;IACR,IAAA;IACA;EAAA,GACC,wBAAA,GAA2B,cAAA;EAAA,QAUtB,uBAAA;EAAA,UAKU,6BAAA,IAChB,GAAA,EAAK,mBAAA,KACF,2BAAA;EAAA,UAGa,2BAAA,IAChB,GAAA,EAAK,mBAAA,KACF,yBAAA;EAAA,UAEK,sBAAA,IAA0B,oCAAA;EAAA,QAiDtB,qBAAA;EAOP,OAAA,CAAQ,IAAA,EAAM,gBAAA;EAAA,QA+Bb,gBAAA;EA6BD,UAAA,CACL,IAAA,GAAM,gBAAA,cACN,WAAA,GAAa,WAAA,GACZ,iBAAA;EAoIU,WAAA,CACX,IAAA,EAAM,gBAAA,EACN,WAAA,GAAa,WAAA,GACZ,OAAA,CAAQ,iBAAA;EAAA,UAKD,gBAAA,CACR,KAAA,WACA,UAAA,UACA,gBAAA,GAAmB,mBAAA,GAClB,OAAA;EAAA,QAeW,cAAA;EAAA,QAyBN,yBAAA;EAeD,kBAAA,CACL,IAAA,EAAM,gBAAA,EACN,MAAA,EAAQ,gBAAA,EACR,OAAA,EAAS,iBAAA,EACT,WAAA;EAAA,QA0BM,4BAAA;EAAA,QAWA,yBAAA;EAaD,gBAAA,CAAiB,KAAA;EAAA,QAIhB,oBAAA;EAAA,QAIA,iBAAA;EAmgBD,aAAA,CACL,IAAA,yCACA,MAAA,EAAQ,iBAAA,GACP,cAAA;EAyBI,aAAA,CACL,MAAA,EAAQ,iBAAA,EACR,QAAA,GAAU,cAAA,KACT,OAAA;EAkDI,cAAA,CACL,MAAA,EAAQ,iBAAA,EACR,YAAA,GAAc,cAAA;EAKT,iBAAA,CACL,QAAA,EAAU,cAAA,IACV,UAAA;EAAA,QAqBM,wBAAA;EAAA,QAiEA,cAAA;EAAA,QA+DA,YAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH } from "../constants.js";
|
|
2
|
+
import { getFileAnnotations, shouldRenderFileAnnotations } from "../utils/includesFileAnnotations.js";
|
|
3
3
|
import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
|
|
4
4
|
import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
|
|
5
5
|
import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
|
|
@@ -26,10 +26,12 @@ import { isDefaultRenderRange } from "../utils/isDefaultRenderRange.js";
|
|
|
26
26
|
import { isDiffPlainText } from "../utils/isDiffPlainText.js";
|
|
27
27
|
import { renderDiffWithHighlighter } from "../utils/renderDiffWithHighlighter.js";
|
|
28
28
|
import { toHtml } from "hast-util-to-html";
|
|
29
|
-
|
|
30
29
|
//#region src/renderers/DiffHunksRenderer.ts
|
|
31
30
|
let instanceId = -1;
|
|
32
31
|
var DiffHunksRenderer = class {
|
|
32
|
+
options;
|
|
33
|
+
onRenderUpdate;
|
|
34
|
+
workerManager;
|
|
33
35
|
__id = `diff-hunks-renderer:${++instanceId}`;
|
|
34
36
|
highlighter;
|
|
35
37
|
diff;
|
|
@@ -112,7 +114,7 @@ var DiffHunksRenderer = class {
|
|
|
112
114
|
return createAnnotationElement(span);
|
|
113
115
|
};
|
|
114
116
|
getOptionsWithDefaults() {
|
|
115
|
-
const { diffIndicators = "bars", diffStyle = "split", disableBackground = false, disableFileHeader = false, disableLineNumbers = false, disableVirtualizationBuffers = false, collapsed = false, expandUnchanged = false, collapsedContextThreshold =
|
|
117
|
+
const { diffIndicators = "bars", diffStyle = "split", disableBackground = false, disableFileHeader = false, disableLineNumbers = false, disableVirtualizationBuffers = false, collapsed = false, expandUnchanged = false, collapsedContextThreshold = 1, expansionLineCount = 100, hunkSeparators = "line-info", lineDiffType = "word-alt", maxLineDiffLength = 1e3, overflow = "scroll", stickyHeader = false, theme = DEFAULT_THEMES, headerRenderMode = "default", tokenizeMaxLineLength = 1e3, tokenizeMaxLength = DEFAULT_TOKENIZE_MAX_LENGTH, useTokenTransformer = false, useCSSClasses = false } = this.options;
|
|
116
118
|
return {
|
|
117
119
|
diffIndicators,
|
|
118
120
|
diffStyle,
|
|
@@ -229,18 +231,18 @@ var DiffHunksRenderer = class {
|
|
|
229
231
|
const hasLangs = this.highlighter != null && areLanguagesAttached(this.computedLang);
|
|
230
232
|
const canHighlight = !forcePlainText && hasLangs;
|
|
231
233
|
if (this.highlighter != null && hasThemes && (forceHighlight || forcePlainText || !this.renderCache.highlighted && canHighlight || this.renderCache.result == null)) {
|
|
232
|
-
const { result, options
|
|
234
|
+
const { result, options } = this.renderDiffWithHighlighter(diff, this.highlighter, forcePlainText || !hasLangs);
|
|
233
235
|
this.renderCache = {
|
|
234
236
|
diff,
|
|
235
|
-
options
|
|
237
|
+
options,
|
|
236
238
|
highlighted: canHighlight,
|
|
237
239
|
result,
|
|
238
240
|
renderRange: void 0
|
|
239
241
|
};
|
|
240
242
|
}
|
|
241
|
-
if (!hasThemes || !forcePlainText && !hasLangs) this.asyncHighlight(diff).then(({ result, options
|
|
243
|
+
if (!hasThemes || !forcePlainText && !hasLangs) this.asyncHighlight(diff).then(({ result, options }) => {
|
|
242
244
|
if (this.renderCache != null) this.renderCache.highlighted = false;
|
|
243
|
-
this.onHighlightSuccess(diff, result, options
|
|
245
|
+
this.onHighlightSuccess(diff, result, options, !forcePlainText);
|
|
244
246
|
});
|
|
245
247
|
}
|
|
246
248
|
return this.renderCache.result != null ? this.processDiffResult(this.renderCache.diff, renderRange, this.renderCache.result) : void 0;
|
|
@@ -307,7 +309,7 @@ var DiffHunksRenderer = class {
|
|
|
307
309
|
console.error(error);
|
|
308
310
|
}
|
|
309
311
|
getTokenizeMaxLength() {
|
|
310
|
-
return this.options.tokenizeMaxLength ??
|
|
312
|
+
return this.options.tokenizeMaxLength ?? 1e5;
|
|
311
313
|
}
|
|
312
314
|
processDiffResult(fileDiff, renderRange, { code, themeStyles, baseThemeType }) {
|
|
313
315
|
const { diffStyle, disableFileHeader, expandUnchanged, expansionLineCount, collapsedContextThreshold, hunkSeparators } = this.getOptionsWithDefaults();
|
|
@@ -649,9 +651,9 @@ var DiffHunksRenderer = class {
|
|
|
649
651
|
const deletionAnnotationNames = fileDiff.type !== "new" ? getAnnotationNames(getFileAnnotations(this.deletionAnnotations)) : [];
|
|
650
652
|
const additionAnnotationNames = fileDiff.type !== "deleted" ? getAnnotationNames(getFileAnnotations(this.additionAnnotations)) : [];
|
|
651
653
|
if (deletionAnnotationNames.length === 0 && additionAnnotationNames.length === 0) return;
|
|
652
|
-
const hunkIndex =
|
|
653
|
-
const lineIndex =
|
|
654
|
-
const { createAnnotationElement
|
|
654
|
+
const hunkIndex = -1;
|
|
655
|
+
const lineIndex = -1;
|
|
656
|
+
const { createAnnotationElement } = this;
|
|
655
657
|
if (diffStyle === "unified") {
|
|
656
658
|
pushLineWithAnnotation({
|
|
657
659
|
diffStyle,
|
|
@@ -662,7 +664,7 @@ var DiffHunksRenderer = class {
|
|
|
662
664
|
lineIndex,
|
|
663
665
|
annotations: deletionAnnotationNames.concat(additionAnnotationNames)
|
|
664
666
|
},
|
|
665
|
-
createAnnotationElement
|
|
667
|
+
createAnnotationElement,
|
|
666
668
|
context
|
|
667
669
|
});
|
|
668
670
|
return;
|
|
@@ -682,7 +684,7 @@ var DiffHunksRenderer = class {
|
|
|
682
684
|
lineIndex,
|
|
683
685
|
annotations: additionAnnotationNames
|
|
684
686
|
},
|
|
685
|
-
createAnnotationElement
|
|
687
|
+
createAnnotationElement,
|
|
686
688
|
context
|
|
687
689
|
});
|
|
688
690
|
}
|
|
@@ -723,8 +725,9 @@ var DiffHunksRenderer = class {
|
|
|
723
725
|
function getAnnotationNames(annotations) {
|
|
724
726
|
return annotations?.map((annotation) => getLineAnnotationName(annotation)) ?? [];
|
|
725
727
|
}
|
|
728
|
+
const EN_PLURAL_RULES = new Intl.PluralRules("en-US");
|
|
726
729
|
function getModifiedLinesString(lines) {
|
|
727
|
-
return `${lines} unmodified line${lines
|
|
730
|
+
return `${lines} unmodified line${EN_PLURAL_RULES.select(lines) === "one" ? "" : "s"}`;
|
|
728
731
|
}
|
|
729
732
|
function pushUnifiedInjectedRows(rows, context) {
|
|
730
733
|
for (const row of rows) {
|
|
@@ -753,14 +756,14 @@ function pushSplitInjectedRows(rows, context, pendingSplitContext) {
|
|
|
753
756
|
context.incrementRowCount(1);
|
|
754
757
|
}
|
|
755
758
|
}
|
|
756
|
-
function pushLineWithAnnotation({ diffStyle, type, deletionLine, additionLine, unifiedSpan, deletionSpan, additionSpan, createAnnotationElement
|
|
759
|
+
function pushLineWithAnnotation({ diffStyle, type, deletionLine, additionLine, unifiedSpan, deletionSpan, additionSpan, createAnnotationElement, context }) {
|
|
757
760
|
let hasAnnotationRow = false;
|
|
758
761
|
if (diffStyle === "unified") {
|
|
759
762
|
if (additionLine != null) context.unifiedContentAST.push(additionLine);
|
|
760
763
|
else if (deletionLine != null) context.unifiedContentAST.push(deletionLine);
|
|
761
764
|
if (unifiedSpan != null) {
|
|
762
765
|
const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "change-addition" : type;
|
|
763
|
-
context.unifiedContentAST.push(createAnnotationElement
|
|
766
|
+
context.unifiedContentAST.push(createAnnotationElement(unifiedSpan));
|
|
764
767
|
context.pushToGutter("unified", createGutterGap(lineType, "annotation", 1));
|
|
765
768
|
hasAnnotationRow = true;
|
|
766
769
|
}
|
|
@@ -769,13 +772,13 @@ function pushLineWithAnnotation({ diffStyle, type, deletionLine, additionLine, u
|
|
|
769
772
|
if (additionLine != null) context.additionsContentAST.push(additionLine);
|
|
770
773
|
if (deletionSpan != null) {
|
|
771
774
|
const lineType = type === "change" ? deletionLine != null ? "change-deletion" : "context" : type;
|
|
772
|
-
context.deletionsContentAST.push(createAnnotationElement
|
|
775
|
+
context.deletionsContentAST.push(createAnnotationElement(deletionSpan));
|
|
773
776
|
context.pushToGutter("deletions", createGutterGap(lineType, "annotation", 1));
|
|
774
777
|
hasAnnotationRow = true;
|
|
775
778
|
}
|
|
776
779
|
if (additionSpan != null) {
|
|
777
780
|
const lineType = type === "change" ? additionLine != null ? "change-addition" : "context" : type;
|
|
778
|
-
context.additionsContentAST.push(createAnnotationElement
|
|
781
|
+
context.additionsContentAST.push(createAnnotationElement(additionSpan));
|
|
779
782
|
context.pushToGutter("additions", createGutterGap(lineType, "annotation", 1));
|
|
780
783
|
hasAnnotationRow = true;
|
|
781
784
|
}
|
|
@@ -866,7 +869,7 @@ function withContentProperties(lineNode, contentProperties) {
|
|
|
866
869
|
function isDiffMassive(diff, tokenizeMaxLength) {
|
|
867
870
|
return Math.max(diff.additionLines.length, diff.deletionLines.length) > tokenizeMaxLength;
|
|
868
871
|
}
|
|
869
|
-
|
|
870
872
|
//#endregion
|
|
871
873
|
export { DiffHunksRenderer };
|
|
874
|
+
|
|
872
875
|
//# sourceMappingURL=DiffHunksRenderer.js.map
|