@pierre/diffs 1.2.0-beta.4 → 1.2.0-beta.6
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/CodeView.d.ts +10 -6
- package/dist/components/CodeView.d.ts.map +1 -1
- package/dist/components/CodeView.js +58 -8
- package/dist/components/CodeView.js.map +1 -1
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +1 -0
- package/dist/components/VirtualizedFile.d.ts.map +1 -1
- package/dist/components/VirtualizedFile.js +19 -6
- package/dist/components/VirtualizedFile.js.map +1 -1
- package/dist/components/VirtualizedFileDiff.d.ts +6 -0
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/VirtualizedFileDiff.js +75 -35
- package/dist/components/VirtualizedFileDiff.js.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/managers/InteractionManager.d.ts +20 -2
- package/dist/managers/InteractionManager.d.ts.map +1 -1
- package/dist/managers/InteractionManager.js +223 -28
- package/dist/managers/InteractionManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts +7 -2
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +52 -16
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/react/CodeView.d.ts +1 -0
- package/dist/react/CodeView.d.ts.map +1 -1
- package/dist/react/CodeView.js +9 -0
- package/dist/react/CodeView.js.map +1 -1
- package/dist/react/constants.js +3 -1
- package/dist/react/constants.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +6 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/computeVirtualFileMetrics.d.ts +11 -0
- package/dist/utils/computeVirtualFileMetrics.d.ts.map +1 -0
- package/dist/utils/{resolveVirtualFileMetrics.js → computeVirtualFileMetrics.js} +7 -10
- package/dist/utils/computeVirtualFileMetrics.js.map +1 -0
- package/dist/utils/createGutterUtilityContentNode.js +1 -0
- package/dist/utils/createGutterUtilityContentNode.js.map +1 -1
- package/dist/utils/detachString.d.ts +5 -0
- package/dist/utils/detachString.d.ts.map +1 -0
- package/dist/utils/detachString.js +19 -0
- package/dist/utils/detachString.js.map +1 -0
- package/dist/utils/parsePatchFiles.js +163 -56
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/worker/worker-portable.js +0 -1
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +0 -1
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts +0 -10
- package/dist/utils/resolveVirtualFileMetrics.d.ts.map +0 -1
- package/dist/utils/resolveVirtualFileMetrics.js.map +0 -1
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["DIFFS_DEVELOPMENT_BUILD: boolean","COMMIT_METADATA_SPLIT: RegExp","GIT_DIFF_FILE_BREAK_REGEX: RegExp","UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp","FILE_CONTEXT_BLOB: RegExp","HUNK_HEADER: RegExp","SPLIT_WITH_NEWLINES: RegExp","FILENAME_HEADER_REGEX: RegExp","FILENAME_HEADER_REGEX_GIT: RegExp","ALTERNATE_FILE_NAMES_GIT: RegExp","INDEX_LINE_METADATA: RegExp","MERGE_CONFLICT_START_MARKER_REGEX: RegExp","MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp","MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp","MERGE_CONFLICT_END_MARKER_REGEX: RegExp","DEFAULT_THEMES: ThemesType","DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics","DEFAULT_CODE_VIEW_FILE_METRICS: VirtualFileMetrics","DEFAULT_CODE_VIEW_LAYOUT: CodeViewLayout","DEFAULT_SMOOTH_SCROLL_SETTINGS: SmoothScrollSettings","DEFAULT_EXPANDED_REGION: HunkExpansionRegion","DEFAULT_RENDER_RANGE: RenderRange","EMPTY_RENDER_RANGE: RenderRange"],"sources":["../src/constants.ts"],"sourcesContent":["import type {\n CodeViewLayout,\n HunkExpansionRegion,\n RenderRange,\n SmoothScrollSettings,\n ThemesType,\n VirtualFileMetrics,\n} from './types';\n\nexport const DIFFS_TAG_NAME = 'diffs-container' as const;\n\n// Keep this as a NODE_ENV read so app builds can hard-disable development-only\n// checks unless they are explicitly built for development.\nexport const DIFFS_DEVELOPMENT_BUILD: boolean = (() => {\n try {\n return process.env.NODE_ENV === 'development';\n } catch {\n return false;\n }\n})();\n\n// Misc patch/content parsing regexes\nexport const COMMIT_METADATA_SPLIT: RegExp = /(?=^From [a-f0-9]+ .+$)/m;\nexport const GIT_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^diff --git)/gm;\nexport const UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^---\\s+\\S)/gm;\nexport const FILE_CONTEXT_BLOB: RegExp = /(?=^@@ )/gm;\nexport const HUNK_HEADER: RegExp =\n /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(?: (.*))?/m;\nexport const SPLIT_WITH_NEWLINES: RegExp = /(?<=\\n)/;\nexport const FILENAME_HEADER_REGEX: RegExp = /^(---|\\+\\+\\+)\\s+([^\\t\\r\\n]+)/;\nexport const FILENAME_HEADER_REGEX_GIT: RegExp =\n /^(---|\\+\\+\\+)\\s+[ab]\\/([^\\t\\r\\n]+)/;\nexport const ALTERNATE_FILE_NAMES_GIT: RegExp =\n /^diff --git (?:\"a\\/(.+?)\"|a\\/(.+?)) (?:\"b\\/(.+?)\"|b\\/(.+?))$/;\nexport const INDEX_LINE_METADATA: RegExp =\n /^index ([0-9a-f]+)\\.\\.([0-9a-f]+)(?: (\\d+))?$/i;\n\nexport const MERGE_CONFLICT_START_MARKER_REGEX: RegExp = /^<{7,}(?:\\s.*)?$/;\nexport const MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp = /^\\|{7,}(?:\\s.*)?$/;\nexport const MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp = /^={7,}$/;\nexport const MERGE_CONFLICT_END_MARKER_REGEX: RegExp = /^>{7,}(?:\\s.*)?$/;\n\nexport const HEADER_PREFIX_SLOT_ID = 'header-prefix';\nexport const HEADER_METADATA_SLOT_ID = 'header-metadata';\nexport const CUSTOM_HEADER_SLOT_ID = 'header-custom';\n\nexport const DEFAULT_THEMES: ThemesType = {\n dark: 'pierre-dark',\n light: 'pierre-light',\n};\n\nexport const THEME_CSS_ATTRIBUTE = 'data-theme-css';\nexport const UNSAFE_CSS_ATTRIBUTE = 'data-unsafe-css';\nexport const CORE_CSS_ATTRIBUTE = 'data-core-css';\nexport const DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE = 'data-diffs-scrollbar-measure';\nexport const DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY =\n '--diffs-scrollbar-gutter-measured';\n\nexport const DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nexport const DEFAULT_TOKENIZE_MAX_LENGTH = 100_000;\nexport const DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics = {\n hunkLineCount: 50,\n lineHeight: 20,\n diffHeaderHeight: 44,\n
|
|
1
|
+
{"version":3,"file":"constants.js","names":["DIFFS_DEVELOPMENT_BUILD: boolean","COMMIT_METADATA_SPLIT: RegExp","GIT_DIFF_FILE_BREAK_REGEX: RegExp","UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp","FILE_CONTEXT_BLOB: RegExp","HUNK_HEADER: RegExp","SPLIT_WITH_NEWLINES: RegExp","FILENAME_HEADER_REGEX: RegExp","FILENAME_HEADER_REGEX_GIT: RegExp","ALTERNATE_FILE_NAMES_GIT: RegExp","INDEX_LINE_METADATA: RegExp","MERGE_CONFLICT_START_MARKER_REGEX: RegExp","MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp","MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp","MERGE_CONFLICT_END_MARKER_REGEX: RegExp","DEFAULT_THEMES: ThemesType","DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics","DEFAULT_CODE_VIEW_FILE_METRICS: VirtualFileMetrics","DEFAULT_CODE_VIEW_LAYOUT: CodeViewLayout","DEFAULT_SMOOTH_SCROLL_SETTINGS: SmoothScrollSettings","DEFAULT_EXPANDED_REGION: HunkExpansionRegion","DEFAULT_RENDER_RANGE: RenderRange","EMPTY_RENDER_RANGE: RenderRange"],"sources":["../src/constants.ts"],"sourcesContent":["import type {\n CodeViewLayout,\n HunkExpansionRegion,\n RenderRange,\n SmoothScrollSettings,\n ThemesType,\n VirtualFileMetrics,\n} from './types';\n\nexport const DIFFS_TAG_NAME = 'diffs-container' as const;\n\n// Keep this as a NODE_ENV read so app builds can hard-disable development-only\n// checks unless they are explicitly built for development.\nexport const DIFFS_DEVELOPMENT_BUILD: boolean = (() => {\n try {\n return process.env.NODE_ENV === 'development';\n } catch {\n return false;\n }\n})();\n\n// Misc patch/content parsing regexes\nexport const COMMIT_METADATA_SPLIT: RegExp = /(?=^From [a-f0-9]+ .+$)/m;\nexport const GIT_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^diff --git)/gm;\nexport const UNIFIED_DIFF_FILE_BREAK_REGEX: RegExp = /(?=^---\\s+\\S)/gm;\nexport const FILE_CONTEXT_BLOB: RegExp = /(?=^@@ )/gm;\nexport const HUNK_HEADER: RegExp =\n /^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(?: (.*))?/m;\nexport const SPLIT_WITH_NEWLINES: RegExp = /(?<=\\n)/;\nexport const FILENAME_HEADER_REGEX: RegExp = /^(---|\\+\\+\\+)\\s+([^\\t\\r\\n]+)/;\nexport const FILENAME_HEADER_REGEX_GIT: RegExp =\n /^(---|\\+\\+\\+)\\s+[ab]\\/([^\\t\\r\\n]+)/;\nexport const ALTERNATE_FILE_NAMES_GIT: RegExp =\n /^diff --git (?:\"a\\/(.+?)\"|a\\/(.+?)) (?:\"b\\/(.+?)\"|b\\/(.+?))$/;\nexport const INDEX_LINE_METADATA: RegExp =\n /^index ([0-9a-f]+)\\.\\.([0-9a-f]+)(?: (\\d+))?$/i;\n\nexport const MERGE_CONFLICT_START_MARKER_REGEX: RegExp = /^<{7,}(?:\\s.*)?$/;\nexport const MERGE_CONFLICT_BASE_MARKER_REGEX: RegExp = /^\\|{7,}(?:\\s.*)?$/;\nexport const MERGE_CONFLICT_SEPARATOR_MARKER_REGEX: RegExp = /^={7,}$/;\nexport const MERGE_CONFLICT_END_MARKER_REGEX: RegExp = /^>{7,}(?:\\s.*)?$/;\n\nexport const HEADER_PREFIX_SLOT_ID = 'header-prefix';\nexport const HEADER_METADATA_SLOT_ID = 'header-metadata';\nexport const CUSTOM_HEADER_SLOT_ID = 'header-custom';\n\nexport const DEFAULT_THEMES: ThemesType = {\n dark: 'pierre-dark',\n light: 'pierre-light',\n};\n\nexport const THEME_CSS_ATTRIBUTE = 'data-theme-css';\nexport const UNSAFE_CSS_ATTRIBUTE = 'data-unsafe-css';\nexport const CORE_CSS_ATTRIBUTE = 'data-core-css';\nexport const DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE = 'data-diffs-scrollbar-measure';\nexport const DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY =\n '--diffs-scrollbar-gutter-measured';\n\nexport const DEFAULT_COLLAPSED_CONTEXT_THRESHOLD = 1;\nexport const DEFAULT_TOKENIZE_MAX_LENGTH = 100_000;\nexport const DEFAULT_VIRTUAL_FILE_METRICS: VirtualFileMetrics = {\n hunkLineCount: 50,\n lineHeight: 20,\n diffHeaderHeight: 44,\n spacing: 8,\n};\n\nexport const DEFAULT_CODE_VIEW_FILE_METRICS: VirtualFileMetrics = {\n ...DEFAULT_VIRTUAL_FILE_METRICS,\n hunkLineCount: 1,\n};\n\nexport const DEFAULT_CODE_VIEW_LAYOUT: CodeViewLayout = {\n paddingTop: 8,\n paddingBottom: 8,\n gap: 8,\n};\n\nexport const DEFAULT_SMOOTH_SCROLL_SETTINGS: SmoothScrollSettings = {\n omega: 0.015,\n positionEpsilon: 0.5,\n velocityEpsilon: 0.05,\n};\n\nexport const DEFAULT_EXPANDED_REGION: HunkExpansionRegion = Object.freeze({\n fromStart: 0,\n fromEnd: 0,\n});\n\nexport const DEFAULT_RENDER_RANGE: RenderRange = {\n startingLine: 0,\n totalLines: Infinity,\n bufferBefore: 0,\n bufferAfter: 0,\n};\n\nexport const EMPTY_RENDER_RANGE: RenderRange = {\n startingLine: 0,\n totalLines: 0,\n bufferBefore: 0,\n bufferAfter: 0,\n};\n"],"mappings":";AASA,MAAa,iBAAiB;AAI9B,MAAaA,iCAA0C;AACrD,KAAI;AACF,SAAO,QAAQ,IAAI,aAAa;SAC1B;AACN,SAAO;;IAEP;AAGJ,MAAaC,wBAAgC;AAC7C,MAAaC,4BAAoC;AACjD,MAAaC,gCAAwC;AACrD,MAAaC,oBAA4B;AACzC,MAAaC,cACX;AACF,MAAaC,sBAA8B;AAC3C,MAAaC,wBAAgC;AAC7C,MAAaC,4BACX;AACF,MAAaC,2BACX;AACF,MAAaC,sBACX;AAEF,MAAaC,oCAA4C;AACzD,MAAaC,mCAA2C;AACxD,MAAaC,wCAAgD;AAC7D,MAAaC,kCAA0C;AAEvD,MAAa,wBAAwB;AACrC,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AAErC,MAAaC,iBAA6B;CACxC,MAAM;CACN,OAAO;CACR;AAED,MAAa,sBAAsB;AACnC,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;AAClC,MAAa,oCAAoC;AACjD,MAAa,2CACX;AAEF,MAAa,sCAAsC;AACnD,MAAa,8BAA8B;AAC3C,MAAaC,+BAAmD;CAC9D,eAAe;CACf,YAAY;CACZ,kBAAkB;CAClB,SAAS;CACV;AAED,MAAaC,iCAAqD;CAChE,GAAG;CACH,eAAe;CAChB;AAED,MAAaC,2BAA2C;CACtD,YAAY;CACZ,eAAe;CACf,KAAK;CACN;AAED,MAAaC,iCAAuD;CAClE,OAAO;CACP,iBAAiB;CACjB,iBAAiB;CAClB;AAED,MAAaC,0BAA+C,OAAO,OAAO;CACxE,WAAW;CACX,SAAS;CACV,CAAC;AAEF,MAAaC,uBAAoC;CAC/C,cAAc;CACd,YAAY;CACZ,cAAc;CACd,aAAa;CACd;AAED,MAAaC,qBAAkC;CAC7C,cAAc;CACd,YAAY;CACZ,cAAc;CACd,aAAa;CACd"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget,
|
|
1
|
+
import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectedLineRange, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "./types.js";
|
|
2
2
|
import { GetHoveredLineResult, GetLineIndexUtility, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LogTypes, MergeConflictActionTarget, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, OnTokenEventProps, SelectionWriteOptions, pluckInteractionOptions } from "./managers/InteractionManager.js";
|
|
3
3
|
import { ResizeManager } from "./managers/ResizeManager.js";
|
|
4
4
|
import { FileRenderResult, FileRenderer, FileRendererOptions } from "./renderers/FileRenderer.js";
|
|
@@ -101,4 +101,4 @@ import { trimPatchContext } from "./utils/trimPatchContext.js";
|
|
|
101
101
|
import { FileDiff, FileDiffHydrationProps, FileDiffOptions, FileDiffRenderProps } from "./components/FileDiff.js";
|
|
102
102
|
import { CodeView, CodeViewCoordinator, CodeViewLineSelection, CodeViewOptions, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, CodeViewScrollListener } from "./components/CodeView.js";
|
|
103
103
|
import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
|
|
104
|
-
export { ALTERNATE_FILE_NAMES_GIT, AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, AttachedLanguages, AttachedThemes, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, CodeView, CodeViewCoordinator, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget,
|
|
104
|
+
export { ALTERNATE_FILE_NAMES_GIT, AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, AttachedLanguages, AttachedThemes, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, CodeView, CodeViewCoordinator, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewLayout, CodeViewLineScrollTarget, CodeViewLineSelection, CodeViewOptions, CodeViewPositionScrollTarget, CodeViewRangeScrollTarget, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, CodeViewScrollBehavior, CodeViewScrollListener, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreateFileHeaderElementProps, CreatePatchOptionsNonabortable, CustomPreProperties, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffHunksRenderer, DiffHunksRendererOptions, DiffHunksRendererOptionsWithDefaults, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, ExpansionDirections, ExtensionFormatMap, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileContents, FileDiff, FileDiffHydrationProps, FileDiffMetadata, FileDiffOptions, FileDiffRenderProps, FileHeaderRenderMode, FileHydrateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, InjectedRow, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, LanguageRegistration, LineAnnotation, LineDecoration, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, LogTypes, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, MergeConflictActionPayload, MergeConflictActionTarget, MergeConflictActionsTypeOption, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, OnTokenEventProps, ParsedLine, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RecallToken, RegisteredCustomLanguages, RegisteredCustomThemes, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, RenderedLineContext, ResizeManager, ResolvedLanguages, ResolvedThemes, ResolvingLanguages, ResolvingThemes, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, SelectedLineRange, SelectionPoint, SelectionSide, SelectionWriteOptions, SharedRenderState, ShikiStreamTokenizer, ShikiStreamTokenizerEnqueueResult, ShikiStreamTokenizerOptions, ShikiTransformer, SmoothScrollSettings, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, StickySpecs, SupportedLanguages, THEME_CSS_ATTRIBUTE, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, VirtualFileMetrics, VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, isDefaultRenderRange, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, renderDiffWithHighlighter, renderFileWithHighlighter, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
|
package/dist/index.js
CHANGED
|
@@ -55,7 +55,6 @@ import { prerenderHTMLIfNecessary } from "./utils/prerenderHTMLIfNecessary.js";
|
|
|
55
55
|
import { setPreNodeProperties } from "./utils/setWrapperNodeProps.js";
|
|
56
56
|
import { File } from "./components/File.js";
|
|
57
57
|
import { VirtualizedFile } from "./components/VirtualizedFile.js";
|
|
58
|
-
import { parseLineType } from "./utils/parseLineType.js";
|
|
59
58
|
import { parsePatchFiles, processFile, processPatch } from "./utils/parsePatchFiles.js";
|
|
60
59
|
import { parseDiffFromFile } from "./utils/parseDiffFromFile.js";
|
|
61
60
|
import { ScrollSyncManager } from "./managers/ScrollSyncManager.js";
|
|
@@ -96,6 +95,7 @@ import { createStyleElement, createThemeStyleElement } from "./utils/createStyle
|
|
|
96
95
|
import { diffAcceptRejectHunk } from "./utils/diffAcceptRejectHunk.js";
|
|
97
96
|
import { getLineEndingType } from "./utils/getLineEndingType.js";
|
|
98
97
|
import { getSingularPatch } from "./utils/getSingularPatch.js";
|
|
98
|
+
import { parseLineType } from "./utils/parseLineType.js";
|
|
99
99
|
import { setLanguageOverride } from "./utils/setLanguageOverride.js";
|
|
100
100
|
import { trimPatchContext } from "./utils/trimPatchContext.js";
|
|
101
101
|
import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
|
|
@@ -65,6 +65,7 @@ declare class InteractionManager<TMode extends InteractionManagerMode> {
|
|
|
65
65
|
private hoveredLine;
|
|
66
66
|
private hoveredToken;
|
|
67
67
|
private pre;
|
|
68
|
+
private gutterUtilityLine;
|
|
68
69
|
private gutterUtilityContainer;
|
|
69
70
|
private gutterUtilityButton;
|
|
70
71
|
private gutterUtilitySlot;
|
|
@@ -104,12 +105,29 @@ declare class InteractionManager<TMode extends InteractionManagerMode> {
|
|
|
104
105
|
private clearHoveredToken;
|
|
105
106
|
private setHoveredToken;
|
|
106
107
|
private ensureGutterUtilityNode;
|
|
108
|
+
private revealUtilityFromGutterPath;
|
|
109
|
+
private placeUtility;
|
|
110
|
+
private placeUtilityFromSelection;
|
|
111
|
+
private showUtilityOnLine;
|
|
112
|
+
private hideUtility;
|
|
113
|
+
private currentSelectionEnds;
|
|
114
|
+
private selectionEnds;
|
|
115
|
+
private selectionPointRowIndex;
|
|
116
|
+
private targetForSelectionPoint;
|
|
107
117
|
private attachDocumentPointerListeners;
|
|
108
118
|
private detachDocumentPointerListeners;
|
|
109
119
|
private clearPointerSession;
|
|
110
120
|
private clearPendingSingleLineState;
|
|
111
|
-
private
|
|
112
|
-
private
|
|
121
|
+
private selectionInfoFromPath;
|
|
122
|
+
private resolveSelectionInfo;
|
|
123
|
+
private selectionPointFromPath;
|
|
124
|
+
private resolveSelectionPoint;
|
|
125
|
+
private resolveSelectionPath;
|
|
126
|
+
private pathFromCoordinates;
|
|
127
|
+
private pathFromEventPath;
|
|
128
|
+
private pathFromElement;
|
|
129
|
+
private pathFromAnnotationSlot;
|
|
130
|
+
private hitTest;
|
|
113
131
|
private getLineIndex;
|
|
114
132
|
private getCurrentSelectionRange;
|
|
115
133
|
private clearProposedSelection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionManager.d.ts","names":["AnnotationSide","DiffLineEventBaseProps","DiffTokenEventBaseProps","ExpansionDirections","LineEventBaseProps","MergeConflictResolution","SelectedLineRange","SelectionSide","TokenEventBase","LogTypes","InteractionManagerMode","OnLineClickProps","PointerEvent","OnLineEnterLeaveProps","OnDiffLineClickProps","OnDiffLineEnterLeaveProps","SelectionWriteOptions","GetLineIndexUtility","EventClickProps","TMode","PointerEventEnterLeaveProps","OnTokenEventProps","GetHoveredLineResult","MergeConflictActionTarget","InteractionManagerBaseOptions","MouseEvent","InteractionManagerOptions","InteractionManager","HTMLPreElement","InteractionPluckOptions","HTMLElement","pluckInteractionOptions","enableTokenInteractionsOnWhitespace","enableGutterUtility","lineHoverHighlight","onGutterUtilityClick","onLineClick","onLineEnter","onLineLeave","onLineNumberClick","onTokenClick","onTokenEnter","onTokenLeave","renderGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],"sources":["../../src/managers/InteractionManager.d.ts"],"sourcesContent":["import type { AnnotationSide, DiffLineEventBaseProps, DiffTokenEventBaseProps, ExpansionDirections, LineEventBaseProps, MergeConflictResolution, SelectedLineRange, SelectionSide, TokenEventBase } from '../types';\nexport type LogTypes = 'click' | 'move' | 'both' | 'none';\nexport type InteractionManagerMode = 'file' | 'diff';\nexport interface OnLineClickProps extends LineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnLineEnterLeaveProps extends LineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnDiffLineClickProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnDiffLineEnterLeaveProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\nexport interface SelectionWriteOptions {\n notify?: boolean;\n}\nexport type GetLineIndexUtility = (lineNumber: number, side?: SelectionSide) => [number, number] | undefined;\ntype EventClickProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineClickProps : OnDiffLineClickProps;\ntype PointerEventEnterLeaveProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineEnterLeaveProps : OnDiffLineEnterLeaveProps;\nexport type OnTokenEventProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? TokenEventBase : DiffTokenEventBaseProps;\nexport type GetHoveredLineResult<TMode extends InteractionManagerMode> = TMode extends 'file' ? {\n lineNumber: number;\n} : {\n lineNumber: number;\n side: AnnotationSide;\n};\nexport interface MergeConflictActionTarget {\n kind: 'merge-conflict-action';\n resolution: MergeConflictResolution;\n conflictIndex: number;\n}\nexport interface InteractionManagerBaseOptions<TMode extends InteractionManagerMode> {\n lineHoverHighlight?: 'disabled' | 'both' | 'number' | 'line';\n enableTokenInteractionsOnWhitespace?: boolean;\n enableGutterUtility?: boolean;\n onGutterUtilityClick?(range: SelectedLineRange): unknown;\n onLineClick?(props: EventClickProps<TMode>): unknown;\n onLineNumberClick?(props: EventClickProps<TMode>): unknown;\n onLineEnter?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onLineLeave?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onTokenClick?(props: OnTokenEventProps<TMode>, event: MouseEvent): unknown;\n onTokenEnter?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n onTokenLeave?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n __debugPointerEvents?: LogTypes;\n enableLineSelection?: boolean;\n controlledSelection?: boolean;\n onLineSelected?: (range: SelectedLineRange | null) => void;\n onLineSelectionStart?: (range: SelectedLineRange | null) => void;\n onLineSelectionChange?: (range: SelectedLineRange | null) => void;\n onLineSelectionEnd?: (range: SelectedLineRange | null) => void;\n getLineIndex?: GetLineIndexUtility;\n}\nexport interface InteractionManagerOptions<TMode extends InteractionManagerMode> extends InteractionManagerBaseOptions<TMode> {\n usesCustomGutterUtility?: boolean;\n onHunkExpand?(hunkIndex: number, direction: ExpansionDirections, expansionLineCountOverride?: number): unknown;\n onMergeConflictActionClick?(target: MergeConflictActionTarget): void;\n}\nexport declare class InteractionManager<TMode extends InteractionManagerMode> {\n private mode;\n private options;\n private hoveredLine;\n private hoveredToken;\n private pre;\n private gutterUtilityContainer;\n private gutterUtilityButton;\n private gutterUtilitySlot;\n private interactiveLinesAttr;\n private interactiveLineNumbersAttr;\n private hasPointerListeners;\n private hasDocumentPointerListeners;\n private selectedRange;\n private proposedSelectedRange;\n private renderedSelectionRange;\n private selectionAnchor;\n private queuedSelectionRender;\n private pointerSession;\n constructor(mode: TMode, options: InteractionManagerOptions<TMode>);\n setOptions(options: InteractionManagerOptions<TMode>): void;\n cleanUp(): void;\n setup(pre: HTMLPreElement): void;\n setSelectionDirty(): void;\n isSelectionDirty(): boolean;\n setSelection(range: SelectedLineRange | null, options?: SelectionWriteOptions): void;\n getSelection(): SelectedLineRange | null;\n getHoveredLine: () => GetHoveredLineResult<TMode> | undefined;\n handlePointerClick: (event: MouseEvent) => void;\n handlePointerMove: (event: PointerEvent) => void;\n handlePointerLeave: (event: PointerEvent) => void;\n private handlePointerEvent;\n private syncPointerListeners;\n private updateInteractiveLineAttributes;\n private handlePointerDown;\n private startLineSelectionFromPointerDown;\n private startGutterSelectionFromPointerDown;\n private handleDocumentPointerMove;\n private handleDocumentPointerUp;\n private handleDocumentPointerCancel;\n private clearHoveredLine;\n private setHoveredLine;\n private clearHoveredToken;\n private setHoveredToken;\n private ensureGutterUtilityNode;\n private attachDocumentPointerListeners;\n private detachDocumentPointerListeners;\n private clearPointerSession;\n private clearPendingSingleLineState;\n private getSelectionPointerInfo;\n private getSelectionPointFromPath;\n private getLineIndex;\n private getCurrentSelectionRange;\n private clearProposedSelection;\n private updateSelection;\n private getIndexesFromSelection;\n private renderSelection;\n private notifySelectionCommitted;\n private notifySelectionChangeDelta;\n private notifySelectionStart;\n private notifySelectionEnd;\n private toEventBaseProps;\n private toTokenEventBaseProps;\n private buildSelectedLineRange;\n private buildSelectionRange;\n private resolvePointerTarget;\n private isSplitDiff;\n private parseLineIndex;\n}\ntype InteractionPluckOptions<TMode extends InteractionManagerMode> = InteractionManagerBaseOptions<TMode> & {\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null | undefined;\n};\nexport declare function pluckInteractionOptions<TMode extends InteractionManagerMode>({ enableTokenInteractionsOnWhitespace, enableGutterUtility, lineHoverHighlight, onGutterUtilityClick, onLineClick, onLineEnter, onLineLeave, onLineNumberClick, onTokenClick, onTokenEnter, onTokenLeave, renderGutterUtility, __debugPointerEvents, enableLineSelection, controlledSelection, onLineSelected, onLineSelectionStart, onLineSelectionChange, onLineSelectionEnd }: InteractionPluckOptions<TMode>, onHunkExpand?: (hunkIndex: number, direction: ExpansionDirections, expansionLineCountOverride?: number) => unknown, getLineIndex?: GetLineIndexUtility, onMergeConflictActionClick?: (target: MergeConflictActionTarget) => void): InteractionManagerOptions<TMode>;\nexport {};\n//# sourceMappingURL=InteractionManager.d.ts.map"],"mappings":";;;KACYS,QAAAA;KACAC,sBAAAA;AADAD,UAEK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qBC,QAAAA,YAAAA;EAAqBC,QAAAA,wBAAAA;EAAgBC,QAAAA,sBAAAA;EAAsBC,QAAAA,eAAAA;EAAuBC,QAAAA,uBAAAA;EAA8C/B,QAAAA,eAAAA;EAAxBU,QAAAA,wBAAAA;EAA8E1B,QAAAA,0BAAAA;EAAqFc,QAAAA,oBAAAA;EAA2DM,QAAAA,kBAAAA;EAA+DJ,QAAAA,gBAAAA;EAA1BO,QAAAA,qBAAAA;EAAyB,QAAA,sBAAA;;;;;;KAH/tBG,sCAAsCnB,0BAA0Bc,8BAA8BL;4CACrDG,qBAAqBH,qBAAqBW;;iBAEhEC,sCAAsCrB;;;;;;;;;;;;;;;;;;;;GAA0YmB,wBAAwBV,sDAAsDhB,qFAAqFc,2DAA2DM,qCAAqCG,0BAA0BP"}
|
|
1
|
+
{"version":3,"file":"InteractionManager.d.ts","names":["AnnotationSide","DiffLineEventBaseProps","DiffTokenEventBaseProps","ExpansionDirections","LineEventBaseProps","MergeConflictResolution","SelectedLineRange","SelectionSide","TokenEventBase","LogTypes","InteractionManagerMode","OnLineClickProps","PointerEvent","OnLineEnterLeaveProps","OnDiffLineClickProps","OnDiffLineEnterLeaveProps","SelectionWriteOptions","GetLineIndexUtility","EventClickProps","TMode","PointerEventEnterLeaveProps","OnTokenEventProps","GetHoveredLineResult","MergeConflictActionTarget","InteractionManagerBaseOptions","MouseEvent","InteractionManagerOptions","InteractionManager","HTMLPreElement","InteractionPluckOptions","HTMLElement","pluckInteractionOptions","enableTokenInteractionsOnWhitespace","enableGutterUtility","lineHoverHighlight","onGutterUtilityClick","onLineClick","onLineEnter","onLineLeave","onLineNumberClick","onTokenClick","onTokenEnter","onTokenLeave","renderGutterUtility","__debugPointerEvents","enableLineSelection","controlledSelection","onLineSelected","onLineSelectionStart","onLineSelectionChange","onLineSelectionEnd"],"sources":["../../src/managers/InteractionManager.d.ts"],"sourcesContent":["import type { AnnotationSide, DiffLineEventBaseProps, DiffTokenEventBaseProps, ExpansionDirections, LineEventBaseProps, MergeConflictResolution, SelectedLineRange, SelectionSide, TokenEventBase } from '../types';\nexport type LogTypes = 'click' | 'move' | 'both' | 'none';\nexport type InteractionManagerMode = 'file' | 'diff';\nexport interface OnLineClickProps extends LineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnLineEnterLeaveProps extends LineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnDiffLineClickProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\nexport interface OnDiffLineEnterLeaveProps extends DiffLineEventBaseProps {\n event: PointerEvent;\n}\nexport interface SelectionWriteOptions {\n notify?: boolean;\n}\nexport type GetLineIndexUtility = (lineNumber: number, side?: SelectionSide) => [number, number] | undefined;\ntype EventClickProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineClickProps : OnDiffLineClickProps;\ntype PointerEventEnterLeaveProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? OnLineEnterLeaveProps : OnDiffLineEnterLeaveProps;\nexport type OnTokenEventProps<TMode extends InteractionManagerMode> = TMode extends 'file' ? TokenEventBase : DiffTokenEventBaseProps;\nexport type GetHoveredLineResult<TMode extends InteractionManagerMode> = TMode extends 'file' ? {\n lineNumber: number;\n} : {\n lineNumber: number;\n side: AnnotationSide;\n};\nexport interface MergeConflictActionTarget {\n kind: 'merge-conflict-action';\n resolution: MergeConflictResolution;\n conflictIndex: number;\n}\nexport interface InteractionManagerBaseOptions<TMode extends InteractionManagerMode> {\n lineHoverHighlight?: 'disabled' | 'both' | 'number' | 'line';\n enableTokenInteractionsOnWhitespace?: boolean;\n enableGutterUtility?: boolean;\n onGutterUtilityClick?(range: SelectedLineRange): unknown;\n onLineClick?(props: EventClickProps<TMode>): unknown;\n onLineNumberClick?(props: EventClickProps<TMode>): unknown;\n onLineEnter?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onLineLeave?(props: PointerEventEnterLeaveProps<TMode>): unknown;\n onTokenClick?(props: OnTokenEventProps<TMode>, event: MouseEvent): unknown;\n onTokenEnter?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n onTokenLeave?(props: OnTokenEventProps<TMode>, event: PointerEvent): unknown;\n __debugPointerEvents?: LogTypes;\n enableLineSelection?: boolean;\n controlledSelection?: boolean;\n onLineSelected?: (range: SelectedLineRange | null) => void;\n onLineSelectionStart?: (range: SelectedLineRange | null) => void;\n onLineSelectionChange?: (range: SelectedLineRange | null) => void;\n onLineSelectionEnd?: (range: SelectedLineRange | null) => void;\n getLineIndex?: GetLineIndexUtility;\n}\nexport interface InteractionManagerOptions<TMode extends InteractionManagerMode> extends InteractionManagerBaseOptions<TMode> {\n usesCustomGutterUtility?: boolean;\n onHunkExpand?(hunkIndex: number, direction: ExpansionDirections, expansionLineCountOverride?: number): unknown;\n onMergeConflictActionClick?(target: MergeConflictActionTarget): void;\n}\nexport declare class InteractionManager<TMode extends InteractionManagerMode> {\n private mode;\n private options;\n private hoveredLine;\n private hoveredToken;\n private pre;\n private gutterUtilityLine;\n private gutterUtilityContainer;\n private gutterUtilityButton;\n private gutterUtilitySlot;\n private interactiveLinesAttr;\n private interactiveLineNumbersAttr;\n private hasPointerListeners;\n private hasDocumentPointerListeners;\n private selectedRange;\n private proposedSelectedRange;\n private renderedSelectionRange;\n private selectionAnchor;\n private queuedSelectionRender;\n private pointerSession;\n constructor(mode: TMode, options: InteractionManagerOptions<TMode>);\n setOptions(options: InteractionManagerOptions<TMode>): void;\n cleanUp(): void;\n setup(pre: HTMLPreElement): void;\n setSelectionDirty(): void;\n isSelectionDirty(): boolean;\n setSelection(range: SelectedLineRange | null, options?: SelectionWriteOptions): void;\n getSelection(): SelectedLineRange | null;\n getHoveredLine: () => GetHoveredLineResult<TMode> | undefined;\n handlePointerClick: (event: MouseEvent) => void;\n handlePointerMove: (event: PointerEvent) => void;\n handlePointerLeave: (event: PointerEvent) => void;\n private handlePointerEvent;\n private syncPointerListeners;\n private updateInteractiveLineAttributes;\n private handlePointerDown;\n private startLineSelectionFromPointerDown;\n private startGutterSelectionFromPointerDown;\n private handleDocumentPointerMove;\n private handleDocumentPointerUp;\n private handleDocumentPointerCancel;\n private clearHoveredLine;\n private setHoveredLine;\n private clearHoveredToken;\n private setHoveredToken;\n private ensureGutterUtilityNode;\n private revealUtilityFromGutterPath;\n private placeUtility;\n private placeUtilityFromSelection;\n private showUtilityOnLine;\n private hideUtility;\n private currentSelectionEnds;\n private selectionEnds;\n private selectionPointRowIndex;\n private targetForSelectionPoint;\n private attachDocumentPointerListeners;\n private detachDocumentPointerListeners;\n private clearPointerSession;\n private clearPendingSingleLineState;\n private selectionInfoFromPath;\n private resolveSelectionInfo;\n private selectionPointFromPath;\n private resolveSelectionPoint;\n private resolveSelectionPath;\n private pathFromCoordinates;\n private pathFromEventPath;\n private pathFromElement;\n private pathFromAnnotationSlot;\n private hitTest;\n private getLineIndex;\n private getCurrentSelectionRange;\n private clearProposedSelection;\n private updateSelection;\n private getIndexesFromSelection;\n private renderSelection;\n private notifySelectionCommitted;\n private notifySelectionChangeDelta;\n private notifySelectionStart;\n private notifySelectionEnd;\n private toEventBaseProps;\n private toTokenEventBaseProps;\n private buildSelectedLineRange;\n private buildSelectionRange;\n private resolvePointerTarget;\n private isSplitDiff;\n private parseLineIndex;\n}\ntype InteractionPluckOptions<TMode extends InteractionManagerMode> = InteractionManagerBaseOptions<TMode> & {\n renderGutterUtility?(getHoveredRow: () => GetHoveredLineResult<TMode> | undefined): HTMLElement | null | undefined;\n};\nexport declare function pluckInteractionOptions<TMode extends InteractionManagerMode>({ enableTokenInteractionsOnWhitespace, enableGutterUtility, lineHoverHighlight, onGutterUtilityClick, onLineClick, onLineEnter, onLineLeave, onLineNumberClick, onTokenClick, onTokenEnter, onTokenLeave, renderGutterUtility, __debugPointerEvents, enableLineSelection, controlledSelection, onLineSelected, onLineSelectionStart, onLineSelectionChange, onLineSelectionEnd }: InteractionPluckOptions<TMode>, onHunkExpand?: (hunkIndex: number, direction: ExpansionDirections, expansionLineCountOverride?: number) => unknown, getLineIndex?: GetLineIndexUtility, onMergeConflictActionClick?: (target: MergeConflictActionTarget) => void): InteractionManagerOptions<TMode>;\nexport {};\n//# sourceMappingURL=InteractionManager.d.ts.map"],"mappings":";;;KACYS,QAAAA;KACAC,sBAAAA;AADAD,UAEKE,gBAAAA,SAAyBP,kBAFtB,CAAA;EACRM,KAAAA,EAEDE,YAFCF;AACZ;AAGiBG,UAAAA,qBAAAA,SAA8BT,kBAAAA,CAAAA;EAG9BU,KAAAA,EAFNF,YAEME;AAGjB;AAGiBE,UANAF,oBAAAA,SAA6Bb,sBAMR,CAAA;EAG1BgB,KAAAA,EARDL,YAQCK;AAAiG;AAC1EP,UAPlBK,yBAAAA,SAAkCd,sBAOhBS,CAAAA;EAA0BS,KAAAA,EANlDP,YAMkDO;;AAA0CL,UAJtFE,qBAAAA,CAIsFF;EAAoB,MAAA,CAAA,EAAA,OAAA;AAAA;AAC5EJ,KAFnCO,mBAAAA,GAEmCP,CAAAA,UAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EAFeH,aAEfG,EAAAA,GAAAA,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA,GAAAA,SAAAA;KAD1CQ,eACoEC,CAAAA,cADtCT,sBACsCS,CAAAA,GADZA,KACYA,SAAAA,MAAAA,GADWR,gBACXQ,GAD8BL,oBAC9BK;KAApEC,2BAA2FP,CAAAA,cAAjDH,sBAAiDG,CAAAA,GAAvBM,KAAuBN,SAAAA,MAAAA,GAAAA,qBAAAA,GAAwBE,yBAAxBF;AAAwBE,KAC5GM,iBAD4GN,CAAAA,cAC5EL,sBAD4EK,CAAAA,GAClDI,KADkDJ,SAAAA,MAAAA,GAC3BP,cAD2BO,GACVb,uBADUa;AAAyB,KAErIO,oBAFqI,CAAA,cAElGZ,sBAFkG,CAAA,GAExES,KAFwE,SAAA,MAAA,GAAA;EACrIE,UAAAA,EAAAA,MAAAA;CAAgCX,GAAAA;EAA0BS,UAAAA,EAAAA,MAAAA;EAAuBX,IAAAA,EAKnFR,c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C,QAAAA,eAAAA;EAAmBC,QAAAA,uBAAAA;EAAcC,QAAAA,2BAAAA;EAAcC,QAAAA,YAAAA;EAAcC,QAAAA,yBAAAA;EAAqBC,QAAAA,iBAAAA;EAAsBC,QAAAA,WAAAA;EAAqBC,QAAAA,oBAAAA;EAAqBC,QAAAA,aAAAA;EAAgBC,QAAAA,sBAAAA;EAAsBC,QAAAA,uBAAAA;EAAuBC,QAAAA,8BAAAA;EAA8C/B,QAAAA,8BAAAA;EAAxBU,QAAAA,mBAAAA;EAA8E1B,QAAAA,2BAAAA;EAAqFc,QAAAA,qBAAAA;EAA2DM,QAAAA,oBAAAA;EAA+DJ,QAAAA,sBAAAA;EAA1BO,QAAAA,qBAAAA;EAAyB,QAAA,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;KAH/tBG,sCAAsCnB,0BAA0Bc,8BAA8BL;4CACrDG,qBAAqBH,qBAAqBW;;iBAEhEC,sCAAsCrB;;;;;;;;;;;;;;;;;;;;GAA0YmB,wBAAwBV,sDAAsDhB,qFAAqFc,2DAA2DM,qCAAqCG,0BAA0BP"}
|
|
@@ -8,6 +8,7 @@ var InteractionManager = class {
|
|
|
8
8
|
hoveredLine;
|
|
9
9
|
hoveredToken;
|
|
10
10
|
pre;
|
|
11
|
+
gutterUtilityLine;
|
|
11
12
|
gutterUtilityContainer;
|
|
12
13
|
gutterUtilityButton;
|
|
13
14
|
gutterUtilitySlot;
|
|
@@ -37,6 +38,7 @@ var InteractionManager = class {
|
|
|
37
38
|
this.pre?.removeAttribute("data-interactive-line-numbers");
|
|
38
39
|
this.pre = void 0;
|
|
39
40
|
this.gutterUtilityContainer?.remove();
|
|
41
|
+
this.gutterUtilityLine = void 0;
|
|
40
42
|
this.gutterUtilityContainer = void 0;
|
|
41
43
|
this.gutterUtilityButton = void 0;
|
|
42
44
|
this.gutterUtilitySlot = void 0;
|
|
@@ -62,6 +64,7 @@ var InteractionManager = class {
|
|
|
62
64
|
if (enableGutterUtility) this.ensureGutterUtilityNode(usesCustomGutterUtility);
|
|
63
65
|
else if (this.gutterUtilityContainer != null) {
|
|
64
66
|
this.gutterUtilityContainer.remove();
|
|
67
|
+
this.gutterUtilityLine = void 0;
|
|
65
68
|
this.gutterUtilityContainer = void 0;
|
|
66
69
|
this.gutterUtilityButton = void 0;
|
|
67
70
|
this.gutterUtilitySlot = void 0;
|
|
@@ -73,6 +76,7 @@ var InteractionManager = class {
|
|
|
73
76
|
this.syncPointerListeners(pre);
|
|
74
77
|
this.updateInteractiveLineAttributes();
|
|
75
78
|
this.renderSelection();
|
|
79
|
+
this.placeUtility();
|
|
76
80
|
}
|
|
77
81
|
setSelectionDirty() {
|
|
78
82
|
this.renderedSelectionRange = void 0;
|
|
@@ -86,24 +90,26 @@ var InteractionManager = class {
|
|
|
86
90
|
this.proposedSelectedRange = void 0;
|
|
87
91
|
this.selectedRange = range;
|
|
88
92
|
this.renderSelection();
|
|
93
|
+
this.placeUtility();
|
|
89
94
|
if (isRangeChange && options?.notify !== false) this.notifySelectionCommitted();
|
|
90
95
|
}
|
|
91
96
|
getSelection() {
|
|
92
97
|
return this.selectedRange;
|
|
93
98
|
}
|
|
94
99
|
getHoveredLine = () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
const gutterUtilityLine = this.gutterUtilityLine ?? this.hoveredLine;
|
|
101
|
+
if (gutterUtilityLine != null) {
|
|
102
|
+
if (this.mode === "diff" && gutterUtilityLine.type === "diff-line") return {
|
|
103
|
+
lineNumber: gutterUtilityLine.lineNumber,
|
|
104
|
+
side: gutterUtilityLine.annotationSide
|
|
99
105
|
};
|
|
100
|
-
if (this.mode === "file" &&
|
|
106
|
+
if (this.mode === "file" && gutterUtilityLine.type === "line") return { lineNumber: gutterUtilityLine.lineNumber };
|
|
101
107
|
}
|
|
102
108
|
};
|
|
103
109
|
handlePointerClick = (event) => {
|
|
104
110
|
const { onHunkExpand, onLineClick, onLineNumberClick, onTokenClick, onMergeConflictActionClick } = this.options;
|
|
105
111
|
if (onHunkExpand == null && onLineClick == null && onLineNumberClick == null && onMergeConflictActionClick == null && onTokenClick == null) return;
|
|
106
|
-
if (this.options.onGutterUtilityClick != null &&
|
|
112
|
+
if (this.options.onGutterUtilityClick != null && isGutterUtilityPath(event.composedPath())) return;
|
|
107
113
|
debugLogIfEnabled(this.options.__debugPointerEvents, "click", "FileDiff.DEBUG.handlePointerClick:", event);
|
|
108
114
|
this.handlePointerEvent({
|
|
109
115
|
eventType: "click",
|
|
@@ -111,6 +117,7 @@ var InteractionManager = class {
|
|
|
111
117
|
});
|
|
112
118
|
};
|
|
113
119
|
handlePointerMove = (event) => {
|
|
120
|
+
if (event.pointerType !== "mouse") return;
|
|
114
121
|
const { lineHoverHighlight = "disabled", onLineEnter, onLineLeave, onTokenEnter, onTokenLeave, enableGutterUtility = false } = this.options;
|
|
115
122
|
if (lineHoverHighlight === "disabled" && !enableGutterUtility && onLineEnter == null && onLineLeave == null && onTokenEnter == null && onTokenLeave == null) return;
|
|
116
123
|
debugLogIfEnabled(this.options.__debugPointerEvents, "move", "FileDiff.DEBUG.handlePointerMove:", event);
|
|
@@ -126,7 +133,6 @@ var InteractionManager = class {
|
|
|
126
133
|
debugLogIfEnabled(__debugPointerEvents, "move", "FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");
|
|
127
134
|
return;
|
|
128
135
|
}
|
|
129
|
-
this.gutterUtilityContainer?.remove();
|
|
130
136
|
if (this.hoveredToken != null) {
|
|
131
137
|
this.options.onTokenLeave?.(this.hoveredToken, event);
|
|
132
138
|
this.clearHoveredToken();
|
|
@@ -138,6 +144,7 @@ var InteractionManager = class {
|
|
|
138
144
|
});
|
|
139
145
|
this.clearHoveredLine();
|
|
140
146
|
}
|
|
147
|
+
this.placeUtility();
|
|
141
148
|
};
|
|
142
149
|
handlePointerEvent({ eventType, event }) {
|
|
143
150
|
const { __debugPointerEvents } = this.options;
|
|
@@ -164,7 +171,6 @@ var InteractionManager = class {
|
|
|
164
171
|
}
|
|
165
172
|
if (!sameLine) {
|
|
166
173
|
if (this.hoveredLine != null) {
|
|
167
|
-
this.gutterUtilityContainer?.remove();
|
|
168
174
|
onLineLeave?.({
|
|
169
175
|
...this.hoveredLine,
|
|
170
176
|
event
|
|
@@ -173,12 +179,12 @@ var InteractionManager = class {
|
|
|
173
179
|
}
|
|
174
180
|
if (isHoverableLinePointerTarget(target)) {
|
|
175
181
|
this.setHoveredLine(this.toEventBaseProps(target));
|
|
176
|
-
|
|
182
|
+
this.placeUtility();
|
|
177
183
|
onLineEnter?.({
|
|
178
184
|
...this.hoveredLine,
|
|
179
185
|
event
|
|
180
186
|
});
|
|
181
|
-
}
|
|
187
|
+
} else this.placeUtility();
|
|
182
188
|
}
|
|
183
189
|
break;
|
|
184
190
|
}
|
|
@@ -268,13 +274,19 @@ var InteractionManager = class {
|
|
|
268
274
|
handlePointerDown = (event) => {
|
|
269
275
|
if (event.pointerType === "mouse" && event.button !== 0 || this.pre == null || this.pointerSession.mode !== "idle") return;
|
|
270
276
|
const path = event.composedPath();
|
|
271
|
-
if (
|
|
272
|
-
else
|
|
277
|
+
if (isGutterUtilityPath(path) && this.options.onGutterUtilityClick != null) this.startGutterSelectionFromPointerDown(event);
|
|
278
|
+
else {
|
|
279
|
+
if (event.pointerType !== "mouse") this.revealUtilityFromGutterPath(path);
|
|
280
|
+
this.startLineSelectionFromPointerDown(event);
|
|
281
|
+
}
|
|
273
282
|
};
|
|
274
|
-
startLineSelectionFromPointerDown(event
|
|
283
|
+
startLineSelectionFromPointerDown(event) {
|
|
275
284
|
const { enableLineSelection = false } = this.options;
|
|
276
285
|
if (!enableLineSelection) return;
|
|
277
|
-
const pointerInfo = this.
|
|
286
|
+
const pointerInfo = this.resolveSelectionInfo(event, {
|
|
287
|
+
source: "event-path",
|
|
288
|
+
requireNumberColumn: true
|
|
289
|
+
});
|
|
278
290
|
if (pointerInfo == null) return;
|
|
279
291
|
const { pre } = this;
|
|
280
292
|
if (pre == null) return;
|
|
@@ -314,6 +326,7 @@ var InteractionManager = class {
|
|
|
314
326
|
}
|
|
315
327
|
if (this.options.controlledSelection === true) this.proposedSelectedRange = null;
|
|
316
328
|
else this.selectedRange = null;
|
|
329
|
+
this.placeUtility();
|
|
317
330
|
this.selectionAnchor = {
|
|
318
331
|
lineNumber,
|
|
319
332
|
side: eventSide
|
|
@@ -326,23 +339,28 @@ var InteractionManager = class {
|
|
|
326
339
|
};
|
|
327
340
|
this.attachDocumentPointerListeners();
|
|
328
341
|
}
|
|
329
|
-
startGutterSelectionFromPointerDown(event
|
|
342
|
+
startGutterSelectionFromPointerDown(event) {
|
|
330
343
|
const { enableLineSelection = false, onGutterUtilityClick } = this.options;
|
|
331
344
|
if (onGutterUtilityClick == null) return;
|
|
332
|
-
const
|
|
333
|
-
|
|
345
|
+
const selectedEndpoints = this.currentSelectionEnds();
|
|
346
|
+
const point = selectedEndpoints?.bottom ?? this.resolveSelectionPoint(event, {
|
|
347
|
+
source: "event-path",
|
|
348
|
+
excludeUtility: false
|
|
349
|
+
});
|
|
350
|
+
const anchor = selectedEndpoints?.top ?? point;
|
|
351
|
+
if (point == null || anchor == null) return;
|
|
334
352
|
event.preventDefault();
|
|
335
353
|
event.stopPropagation();
|
|
336
354
|
this.pointerSession = {
|
|
337
355
|
mode: "gutterSelecting",
|
|
338
356
|
pointerId: event.pointerId,
|
|
339
|
-
anchor
|
|
357
|
+
anchor,
|
|
340
358
|
current: point
|
|
341
359
|
};
|
|
342
360
|
if (enableLineSelection) {
|
|
343
361
|
this.selectionAnchor = {
|
|
344
|
-
lineNumber:
|
|
345
|
-
side:
|
|
362
|
+
lineNumber: anchor.lineNumber,
|
|
363
|
+
side: anchor.side
|
|
346
364
|
};
|
|
347
365
|
this.updateSelection(point.lineNumber, point.side, false);
|
|
348
366
|
this.notifySelectionStart(this.getCurrentSelectionRange());
|
|
@@ -355,7 +373,8 @@ var InteractionManager = class {
|
|
|
355
373
|
case "idle": return;
|
|
356
374
|
case "gutterSelecting": {
|
|
357
375
|
if (event.pointerId !== this.pointerSession.pointerId) return;
|
|
358
|
-
|
|
376
|
+
event.preventDefault();
|
|
377
|
+
const point = this.resolveSelectionPoint(event, { source: "coordinates-first" });
|
|
359
378
|
if (point == null) return;
|
|
360
379
|
this.pointerSession.current = point;
|
|
361
380
|
if (enableLineSelection === true) this.updateSelection(point.lineNumber, point.side);
|
|
@@ -363,14 +382,22 @@ var InteractionManager = class {
|
|
|
363
382
|
}
|
|
364
383
|
case "selecting": {
|
|
365
384
|
if (event.pointerId !== this.pointerSession.pointerId) return;
|
|
366
|
-
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
const pointerInfo = this.resolveSelectionInfo(event, {
|
|
387
|
+
source: "coordinates-first",
|
|
388
|
+
requireNumberColumn: false
|
|
389
|
+
});
|
|
367
390
|
if (pointerInfo == null || this.selectionAnchor == null) return;
|
|
368
391
|
this.updateSelection(pointerInfo.lineNumber, pointerInfo.eventSide);
|
|
369
392
|
return;
|
|
370
393
|
}
|
|
371
394
|
case "pendingSingleLineUnselect": {
|
|
372
395
|
if (event.pointerId !== this.pointerSession.pointerId) return;
|
|
373
|
-
|
|
396
|
+
event.preventDefault();
|
|
397
|
+
const pointerInfo = this.resolveSelectionInfo(event, {
|
|
398
|
+
source: "coordinates-first",
|
|
399
|
+
requireNumberColumn: false
|
|
400
|
+
});
|
|
374
401
|
if (pointerInfo == null || this.selectionAnchor == null) return;
|
|
375
402
|
const point = {
|
|
376
403
|
lineNumber: pointerInfo.lineNumber,
|
|
@@ -394,7 +421,8 @@ var InteractionManager = class {
|
|
|
394
421
|
case "idle": return;
|
|
395
422
|
case "gutterSelecting": {
|
|
396
423
|
if (event.pointerId !== this.pointerSession.pointerId) return;
|
|
397
|
-
|
|
424
|
+
event.preventDefault();
|
|
425
|
+
const point = this.resolveSelectionPoint(event, { source: "coordinates-first" });
|
|
398
426
|
if (point != null) {
|
|
399
427
|
this.pointerSession.current = point;
|
|
400
428
|
if (enableLineSelection) this.updateSelection(point.lineNumber, point.side);
|
|
@@ -412,6 +440,7 @@ var InteractionManager = class {
|
|
|
412
440
|
}
|
|
413
441
|
case "pendingSingleLineUnselect":
|
|
414
442
|
if (event.pointerId !== this.pointerSession.pointerId) return;
|
|
443
|
+
event.preventDefault();
|
|
415
444
|
this.updateSelection(null, void 0, false);
|
|
416
445
|
this.selectionAnchor = void 0;
|
|
417
446
|
this.clearPendingSingleLineState();
|
|
@@ -422,6 +451,7 @@ var InteractionManager = class {
|
|
|
422
451
|
return;
|
|
423
452
|
case "selecting":
|
|
424
453
|
if (event.pointerId !== this.pointerSession.pointerId) return;
|
|
454
|
+
event.preventDefault();
|
|
425
455
|
this.selectionAnchor = void 0;
|
|
426
456
|
this.detachDocumentPointerListeners();
|
|
427
457
|
this.clearPointerSession();
|
|
@@ -498,6 +528,79 @@ var InteractionManager = class {
|
|
|
498
528
|
if (this.gutterUtilityButton.parentNode !== this.gutterUtilityContainer) this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton);
|
|
499
529
|
}
|
|
500
530
|
}
|
|
531
|
+
revealUtilityFromGutterPath(path) {
|
|
532
|
+
if (this.placeUtilityFromSelection()) return;
|
|
533
|
+
const target = this.resolvePointerTarget(path);
|
|
534
|
+
if (isLinePointerTarget(target) && target.numberColumn) this.showUtilityOnLine(this.toEventBaseProps(target));
|
|
535
|
+
}
|
|
536
|
+
placeUtility() {
|
|
537
|
+
if (this.placeUtilityFromSelection()) return;
|
|
538
|
+
if (this.hoveredLine != null) {
|
|
539
|
+
this.showUtilityOnLine(this.hoveredLine);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
this.hideUtility();
|
|
543
|
+
}
|
|
544
|
+
placeUtilityFromSelection() {
|
|
545
|
+
const endpoints = this.currentSelectionEnds();
|
|
546
|
+
if (endpoints == null) return false;
|
|
547
|
+
const target = this.targetForSelectionPoint(endpoints.bottom);
|
|
548
|
+
if (target == null) this.hideUtility();
|
|
549
|
+
else this.showUtilityOnLine(this.toEventBaseProps(target));
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
showUtilityOnLine(line) {
|
|
553
|
+
if (this.gutterUtilityContainer == null) return;
|
|
554
|
+
this.gutterUtilityLine = line;
|
|
555
|
+
line.numberElement.appendChild(this.gutterUtilityContainer);
|
|
556
|
+
}
|
|
557
|
+
hideUtility() {
|
|
558
|
+
this.gutterUtilityContainer?.remove();
|
|
559
|
+
this.gutterUtilityLine = void 0;
|
|
560
|
+
}
|
|
561
|
+
currentSelectionEnds() {
|
|
562
|
+
const range = this.getCurrentSelectionRange();
|
|
563
|
+
return range == null ? void 0 : this.selectionEnds(range);
|
|
564
|
+
}
|
|
565
|
+
selectionEnds(range) {
|
|
566
|
+
const start = {
|
|
567
|
+
lineNumber: range.start,
|
|
568
|
+
side: range.side
|
|
569
|
+
};
|
|
570
|
+
const end = {
|
|
571
|
+
lineNumber: range.end,
|
|
572
|
+
side: range.endSide ?? range.side
|
|
573
|
+
};
|
|
574
|
+
const startIndex = this.selectionPointRowIndex(start);
|
|
575
|
+
const endIndex = this.selectionPointRowIndex(end);
|
|
576
|
+
if (startIndex == null || endIndex == null) return;
|
|
577
|
+
return startIndex > endIndex ? {
|
|
578
|
+
top: end,
|
|
579
|
+
bottom: start
|
|
580
|
+
} : {
|
|
581
|
+
top: start,
|
|
582
|
+
bottom: end
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
selectionPointRowIndex(point) {
|
|
586
|
+
const indexes = this.getLineIndex(point.lineNumber, point.side);
|
|
587
|
+
if (indexes == null) return;
|
|
588
|
+
return this.isSplitDiff() ? indexes[1] : indexes[0];
|
|
589
|
+
}
|
|
590
|
+
targetForSelectionPoint(point) {
|
|
591
|
+
if (this.pre == null) return;
|
|
592
|
+
const indexes = this.getLineIndex(point.lineNumber, point.side);
|
|
593
|
+
if (indexes == null) return;
|
|
594
|
+
const lineIndex = this.mode === "diff" ? `${indexes[0]},${indexes[1]}` : `${indexes[0]}`;
|
|
595
|
+
const candidates = this.pre.querySelectorAll(`[data-column-number="${point.lineNumber}"][data-line-index="${lineIndex}"]`);
|
|
596
|
+
for (const element of candidates) {
|
|
597
|
+
if (!(element instanceof HTMLElement)) continue;
|
|
598
|
+
const target = this.resolvePointerTarget(getElementPath(element));
|
|
599
|
+
if (!isLinePointerTarget(target)) continue;
|
|
600
|
+
if (this.mode === "diff" && point.side != null && target.side !== point.side) continue;
|
|
601
|
+
return target;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
501
604
|
attachDocumentPointerListeners() {
|
|
502
605
|
if (this.hasDocumentPointerListeners) return;
|
|
503
606
|
document.addEventListener("pointermove", this.handleDocumentPointerMove);
|
|
@@ -518,7 +621,7 @@ var InteractionManager = class {
|
|
|
518
621
|
clearPendingSingleLineState() {
|
|
519
622
|
if (this.pointerSession.mode === "pendingSingleLineUnselect") this.pointerSession = { mode: "idle" };
|
|
520
623
|
}
|
|
521
|
-
|
|
624
|
+
selectionInfoFromPath(path, requireNumberColumn) {
|
|
522
625
|
const target = this.resolvePointerTarget(path);
|
|
523
626
|
if (!isLinePointerTarget(target)) return;
|
|
524
627
|
if (requireNumberColumn && !target.numberColumn) return;
|
|
@@ -529,7 +632,11 @@ var InteractionManager = class {
|
|
|
529
632
|
eventSide: this.mode === "diff" ? target.side : void 0
|
|
530
633
|
};
|
|
531
634
|
}
|
|
532
|
-
|
|
635
|
+
resolveSelectionInfo(event, options) {
|
|
636
|
+
const path = this.resolveSelectionPath(event, options);
|
|
637
|
+
return path != null ? this.selectionInfoFromPath(path, options.requireNumberColumn) : void 0;
|
|
638
|
+
}
|
|
639
|
+
selectionPointFromPath(path) {
|
|
533
640
|
const target = this.resolvePointerTarget(path);
|
|
534
641
|
if (!isLinePointerTarget(target)) return;
|
|
535
642
|
return {
|
|
@@ -537,6 +644,51 @@ var InteractionManager = class {
|
|
|
537
644
|
side: this.mode === "diff" ? target.side : void 0
|
|
538
645
|
};
|
|
539
646
|
}
|
|
647
|
+
resolveSelectionPoint(event, options) {
|
|
648
|
+
const path = this.resolveSelectionPath(event, options);
|
|
649
|
+
return path != null ? this.selectionPointFromPath(path) : void 0;
|
|
650
|
+
}
|
|
651
|
+
resolveSelectionPath(event, options) {
|
|
652
|
+
const excludeUtility = options.excludeUtility !== false;
|
|
653
|
+
switch (options.source) {
|
|
654
|
+
case "event-path": return this.pathFromEventPath(event.composedPath(), excludeUtility);
|
|
655
|
+
case "coordinates-first": {
|
|
656
|
+
const coordinatePath = this.pathFromCoordinates(event, excludeUtility);
|
|
657
|
+
if (coordinatePath !== void 0) return coordinatePath ?? void 0;
|
|
658
|
+
return this.pathFromEventPath(event.composedPath(), excludeUtility);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
pathFromCoordinates(event, excludeUtility) {
|
|
663
|
+
const coordinateTarget = this.hitTest(event);
|
|
664
|
+
if (coordinateTarget === void 0) return;
|
|
665
|
+
if (coordinateTarget === null) return null;
|
|
666
|
+
return this.pathFromElement(coordinateTarget, excludeUtility) ?? null;
|
|
667
|
+
}
|
|
668
|
+
pathFromEventPath(path, excludeUtility) {
|
|
669
|
+
if (excludeUtility && isGutterUtilityPath(path)) return;
|
|
670
|
+
for (const element of path) if (element instanceof Element) return this.pathFromElement(element, excludeUtility);
|
|
671
|
+
}
|
|
672
|
+
pathFromElement(element, excludeUtility) {
|
|
673
|
+
const path = getElementPath(element);
|
|
674
|
+
if (excludeUtility && isGutterUtilityPath(path)) return;
|
|
675
|
+
const row = closestSelectableRow(element);
|
|
676
|
+
if (row != null) return getElementPath(row);
|
|
677
|
+
return this.pathFromAnnotationSlot(element);
|
|
678
|
+
}
|
|
679
|
+
pathFromAnnotationSlot(element) {
|
|
680
|
+
const point = selectionPointFromAnnotationSlotName(getAnnotationSlotName(element));
|
|
681
|
+
if (point == null) return;
|
|
682
|
+
const target = this.targetForSelectionPoint(point);
|
|
683
|
+
return target != null ? getElementPath(target.lineElement) : void 0;
|
|
684
|
+
}
|
|
685
|
+
hitTest(event) {
|
|
686
|
+
if (!Number.isFinite(event.clientX) || !Number.isFinite(event.clientY)) return;
|
|
687
|
+
const root = this.pre?.getRootNode();
|
|
688
|
+
const elementFromPointRoot = hasElementFromPoint(root) ? root : hasElementFromPoint(document) ? document : void 0;
|
|
689
|
+
if (elementFromPointRoot == null) return;
|
|
690
|
+
return elementFromPointRoot.elementFromPoint(event.clientX, event.clientY);
|
|
691
|
+
}
|
|
540
692
|
getLineIndex(lineNumber, side) {
|
|
541
693
|
const { getLineIndex } = this.options;
|
|
542
694
|
return getLineIndex != null ? getLineIndex(lineNumber, side) : [lineNumber - 1, lineNumber - 1];
|
|
@@ -562,6 +714,7 @@ var InteractionManager = class {
|
|
|
562
714
|
this.selectedRange = nextRange;
|
|
563
715
|
this.queuedSelectionRender ??= requestAnimationFrame(this.renderSelection);
|
|
564
716
|
}
|
|
717
|
+
this.placeUtility();
|
|
565
718
|
if (emitChange) this.notifySelectionChangeDelta();
|
|
566
719
|
}
|
|
567
720
|
getIndexesFromSelection(selectedRange, split) {
|
|
@@ -890,6 +1043,45 @@ function queryHTMLElement(parent, query) {
|
|
|
890
1043
|
const element = parent?.querySelector(query);
|
|
891
1044
|
return element instanceof HTMLElement ? element : void 0;
|
|
892
1045
|
}
|
|
1046
|
+
function getElementPath(element) {
|
|
1047
|
+
const path = [];
|
|
1048
|
+
let current = element;
|
|
1049
|
+
while (current != null) {
|
|
1050
|
+
path.push(current);
|
|
1051
|
+
current = current.parentNode;
|
|
1052
|
+
}
|
|
1053
|
+
return path;
|
|
1054
|
+
}
|
|
1055
|
+
function closestSelectableRow(element) {
|
|
1056
|
+
const row = element.closest("[data-line], [data-column-number]");
|
|
1057
|
+
if (row instanceof HTMLElement) return row;
|
|
1058
|
+
const annotationRow = element.closest("[data-line-annotation], [data-gutter-buffer=\"annotation\"]");
|
|
1059
|
+
if (!(annotationRow instanceof HTMLElement)) return;
|
|
1060
|
+
const previousRow = annotationRow.previousElementSibling;
|
|
1061
|
+
return previousRow instanceof HTMLElement && (previousRow.hasAttribute("data-line") || previousRow.hasAttribute("data-column-number")) ? previousRow : void 0;
|
|
1062
|
+
}
|
|
1063
|
+
function getAnnotationSlotName(element) {
|
|
1064
|
+
const slottedElement = element.closest("[slot^=\"annotation-\"]");
|
|
1065
|
+
if (slottedElement instanceof HTMLElement) return slottedElement.getAttribute("slot") ?? void 0;
|
|
1066
|
+
if (element instanceof HTMLElement) {
|
|
1067
|
+
const slotName = element.getAttribute("name") ?? void 0;
|
|
1068
|
+
return slotName != null && slotName.startsWith("annotation-") ? slotName : void 0;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
function selectionPointFromAnnotationSlotName(slotName) {
|
|
1072
|
+
if (slotName == null) return;
|
|
1073
|
+
const match = /^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(slotName);
|
|
1074
|
+
if (match == null) return;
|
|
1075
|
+
const lineNumber = Number.parseInt(match[2], 10);
|
|
1076
|
+
if (!Number.isFinite(lineNumber)) return;
|
|
1077
|
+
return {
|
|
1078
|
+
lineNumber,
|
|
1079
|
+
side: match[1]
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
function hasElementFromPoint(value) {
|
|
1083
|
+
return value != null && typeof value.elementFromPoint === "function";
|
|
1084
|
+
}
|
|
893
1085
|
function getAnnotationSide(lineType, codeElement) {
|
|
894
1086
|
switch (lineType) {
|
|
895
1087
|
case "change-deletion": return "deletions";
|
|
@@ -908,8 +1100,11 @@ function getLineTypeFromElement(element) {
|
|
|
908
1100
|
default: return;
|
|
909
1101
|
}
|
|
910
1102
|
}
|
|
911
|
-
function
|
|
912
|
-
for (const element of path)
|
|
1103
|
+
function isGutterUtilityPath(path) {
|
|
1104
|
+
for (const element of path) {
|
|
1105
|
+
if (!(element instanceof HTMLElement)) continue;
|
|
1106
|
+
if (element.hasAttribute("data-utility-button") || element.hasAttribute("data-gutter-utility-slot") || element.getAttribute("slot") === "gutter-utility-slot" || element.getAttribute("name") === "gutter-utility-slot") return true;
|
|
1107
|
+
}
|
|
913
1108
|
return false;
|
|
914
1109
|
}
|
|
915
1110
|
function debugLogIfEnabled(debugLogType = "none", logIfType, ...args) {
|