@pierre/diffs 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -1
- package/dist/components/File.d.ts +21 -1
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +142 -70
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +26 -5
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +143 -89
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts +4 -1
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +27 -12
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/UnresolvedFile.js +6 -42
- package/dist/components/UnresolvedFile.js.map +1 -1
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -4
- package/dist/react/File.d.ts +3 -1
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +5 -2
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +4 -1
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +5 -2
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +4 -1
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +12 -6
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +4 -1
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +5 -2
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/UnresolvedFile.d.ts +4 -1
- package/dist/react/UnresolvedFile.d.ts.map +1 -1
- package/dist/react/UnresolvedFile.js +5 -2
- package/dist/react/UnresolvedFile.js.map +1 -1
- package/dist/react/WorkerPoolContext.js +7 -5
- package/dist/react/WorkerPoolContext.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/types.d.ts +6 -3
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +4 -6
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +12 -17
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +2 -0
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.js +9 -6
- package/dist/react/utils/renderFileChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +7 -7
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +20 -11
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +5 -1
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +20 -7
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts +5 -1
- package/dist/react/utils/useUnresolvedFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useUnresolvedFileInstance.js +17 -4
- package/dist/react/utils/useUnresolvedFileInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +14 -9
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +13 -21
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +5 -4
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +11 -19
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts +5 -5
- package/dist/renderers/UnresolvedFileHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/UnresolvedFileHunksRenderer.js +2 -2
- package/dist/renderers/UnresolvedFileHunksRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.js +7 -4
- package/dist/ssr/preloadDiffs.js.map +1 -1
- package/dist/ssr/preloadFile.js +7 -2
- package/dist/ssr/preloadFile.js.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +11 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/arePrePropertiesEqual.js +1 -1
- package/dist/utils/arePrePropertiesEqual.js.map +1 -1
- package/dist/utils/createFileHeaderElement.d.ts +3 -5
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createFileHeaderElement.js +17 -10
- package/dist/utils/createFileHeaderElement.js.map +1 -1
- package/dist/utils/createPreElement.d.ts +0 -2
- package/dist/utils/createPreElement.d.ts.map +1 -1
- package/dist/utils/createPreElement.js +4 -7
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/createStyleElement.d.ts +2 -1
- package/dist/utils/createStyleElement.d.ts.map +1 -1
- package/dist/utils/createStyleElement.js +9 -2
- package/dist/utils/createStyleElement.js.map +1 -1
- package/dist/utils/cssWrappers.d.ts +4 -1
- package/dist/utils/cssWrappers.d.ts.map +1 -1
- package/dist/utils/cssWrappers.js +11 -2
- package/dist/utils/cssWrappers.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.map +1 -1
- package/dist/utils/hostTheme.d.ts +15 -0
- package/dist/utils/hostTheme.d.ts.map +1 -0
- package/dist/utils/hostTheme.js +22 -0
- package/dist/utils/hostTheme.js.map +1 -0
- package/dist/utils/isDiffPlainText.d.ts +7 -0
- package/dist/utils/isDiffPlainText.d.ts.map +1 -0
- package/dist/utils/isDiffPlainText.js +12 -0
- package/dist/utils/isDiffPlainText.js.map +1 -0
- package/dist/utils/isFilePlainText.d.ts +7 -0
- package/dist/utils/isFilePlainText.d.ts.map +1 -0
- package/dist/utils/isFilePlainText.js +10 -0
- package/dist/utils/isFilePlainText.js.map +1 -0
- package/dist/utils/parsePatchFiles.js +1 -1
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +1 -4
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +1 -3
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.d.ts +0 -2
- package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +1 -4
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/worker/WorkerPoolManager.js +4 -2
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/worker-portable.js +4 -13
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +2 -7
- package/dist/worker/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":["ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","RenderHeaderMetadataProps","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type MergeConflictMarkerRowType = 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end';\nexport interface MergeConflictMarkerRow {\n type: MergeConflictMarkerRowType;\n hunkIndex: number;\n /** Index into `hunk.hunkContent` for the structural block this row belongs to. */\n contentIndex: number;\n conflictIndex: number;\n lineText: string;\n /** Unified rendered-row index where this virtual row should be injected. */\n lineIndex: number;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow' | 'themeType'>> {\n type: 'diff' | 'file';\n split: boolean;\n themeStyles: string;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport interface RenderHeaderMetadataProps {\n deletionFile?: FileContents;\n additionFile?: FileContents;\n fileDiff?: FileDiffMetadata;\n}\nexport type RenderHeaderMetadataCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderHeaderPrefixCallback = (props: RenderHeaderMetadataProps) => Element | null | undefined | string | number;\nexport type RenderFileMetadata = (file: FileContents) => Element | null | undefined | string | number;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\nexport type DiffAcceptRejectHunkType = 'accept' | 'reject' | 'both';\nexport type ConflictResolverTypes = 'current' | 'incoming' | 'both';\nexport interface DiffAcceptRejectHunkConfig {\n type: DiffAcceptRejectHunkType;\n changeIndex: number;\n}\n/**\n * Unresolved merge conflict indexes use three different coordinate spaces:\n * - source line indexes live on `conflict.*LineIndex`\n * - hunk-content indexes live on the fields below, with `startContentIndex`\n * serving as both the conflict-range start and the start-marker anchor\n * - rendered row indexes live on unresolved `markerRows`\n */\nexport interface ProcessFileConflictData {\n /** Index of the hunk that owns this unresolved conflict. */\n hunkIndex: number;\n /** First hunk-content entry that belongs to the conflict region. */\n startContentIndex: number;\n /** Last hunk-content entry that belongs to the conflict region. */\n endContentIndex: number;\n /** Hunk-content index for the current/ours change block. */\n currentContentIndex?: number;\n /** Hunk-content index for the optional base context block. */\n baseContentIndex?: number;\n /** Hunk-content index for the incoming/theirs change block. */\n incomingContentIndex?: number;\n /** Hunk-content index that anchors the end marker row. */\n endMarkerContentIndex: number;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;AAMA;AAgBA;AAEYa,UAlBKH,YAAAA,CAkBU;EACfI;AAQZ;EAAkDH,IAAAA,EAAAA,MAAAA;EAAoBE;EAAvCR,QAAAA,EAAAA,MAAAA;EAAkB;AASjD;EAKiBa,IAAAA,CAAAA,EAjCNP,kBAiCiB;EAYXS;EAoBAC,MAAAA,CAAAA,EAAAA,MAAAA;EAqBAC;AA0FjB;;EA8BUL,QAAAA,CAAAA,EAAAA,MAAAA;;AAGK,KAzMHL,gBAAAA,GAyMG,UAAA,GAAA,YAAA;AAwCEY,KA/OLX,eAAAA,GAAkBX,YAgPpBqB,GAAAA,aAAAA,GAAAA,cAA0B,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AASxBZ,KAxPAG,UAAAA,GAAaC,MAwPK,CAAA,MAAGd,GAAAA,OAAAA,EAxPiBY,eAwPF,CAAA;AAChD;AACA;AAIA;AACA;AACA;;;AAIgBa,KA5PJV,gBAAAA,GAAmBX,kBA4PfqB,CA5PkCf,kBA4PlCe,EA5PsDb,eA4PtDa,CAAAA;;;AAShB;;;;;AAWA;AAAwDI,KAvQ5Cb,WAAAA,GAuQ4Ca,QAAAA,GAAAA,a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BACAA;;UAEFsE,gBAAAA;QACPD;;;;UAIOE,mBAAAA;;;;UAIAC,yBAAAA;;;;kBAIGC,YAAYF;;;UAGfG,yBAAAA;;;;;;UAMAC,iBAAAA;SACN9D,kBAAkBE,yBAAyBF;;;UAGrC+D,iBAAAA;SACN/D,kBAAkBE,yBAAyBF;;gBAEpCe;;UAEDiD,gBAAAA;UACLT;WACCO;;UAEIG,gBAAAA;UACLR;WACCM;;UAEIG,oBAAAA;QACPrE;;WAEGiE;UACDP;eACKY;;UAEAC,oBAAAA;QACP9D;;WAEGyD;UACDN;eACKU;;UAEAA,WAAAA;;;;;;UAMAE,YAAAA;;;;UAIAC,kBAAAA;;;;UAIAC,kBAAAA;;;;;;;UAOAC,cAAAA;;QAEPzC;;KAEE0C,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":["ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","FileHeaderRenderMode","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData","AppliedThemeStyleCache"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type MergeConflictMarkerRowType = 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end';\nexport interface MergeConflictMarkerRow {\n type: MergeConflictMarkerRowType;\n hunkIndex: number;\n /** Index into `hunk.hunkContent` for the structural block this row belongs to. */\n contentIndex: number;\n conflictIndex: number;\n lineText: string;\n /** Unified rendered-row index where this virtual row should be injected. */\n lineIndex: number;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n tokenizeMaxLineLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow'>> {\n type: 'diff' | 'file';\n split: boolean;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport type FileHeaderRenderMode = 'default' | 'custom';\nexport type RenderHeaderMetadataCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderHeaderPrefixCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderFileMetadata = (file: FileContents) => Element | string | number | null | undefined;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n top: number;\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n hunkLineCount: number;\n lineHeight: number;\n diffHeaderHeight: number;\n hunkSeparatorHeight: number;\n fileGap: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\nexport type DiffAcceptRejectHunkType = 'accept' | 'reject' | 'both';\nexport type ConflictResolverTypes = 'current' | 'incoming' | 'both';\nexport interface DiffAcceptRejectHunkConfig {\n type: DiffAcceptRejectHunkType;\n changeIndex: number;\n}\n/**\n * Unresolved merge conflict indexes use three different coordinate spaces:\n * - source line indexes live on `conflict.*LineIndex`\n * - hunk-content indexes live on the fields below, with `startContentIndex`\n * serving as both the conflict-range start and the start-marker anchor\n * - rendered row indexes live on unresolved `markerRows`\n */\nexport interface ProcessFileConflictData {\n /** Index of the hunk that owns this unresolved conflict. */\n hunkIndex: number;\n /** First hunk-content entry that belongs to the conflict region. */\n startContentIndex: number;\n /** Last hunk-content entry that belongs to the conflict region. */\n endContentIndex: number;\n /** Hunk-content index for the current/ours change block. */\n currentContentIndex?: number;\n /** Hunk-content index for the optional base context block. */\n baseContentIndex?: number;\n /** Hunk-content index for the incoming/theirs change block. */\n incomingContentIndex?: number;\n /** Hunk-content index that anchors the end marker row. */\n endMarkerContentIndex: number;\n}\nexport interface AppliedThemeStyleCache {\n themeStyles: string;\n themeType: ThemeTypes;\n baseThemeType: 'light' | 'dark' | undefined;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;;;AAMA;AAgBA;AAEYa,UAlBKH,YAAAA,CAkBU;EACfI;AAQZ;EAAkDH,IAAAA,EAAAA,MAAAA;EAAoBE;EAAvCR,QAAAA,EAAAA,MAAAA;EAAkB;AASjD;EAKiBa,IAAAA,CAAAA,EAjCNP,kBAiCiB;EAYXS;EAoBAC,MAAAA,CAAAA,EAAAA,MAAAA;EAqBAC;AA0FjB;;EA8BUL,QAAAA,CAAAA,EAAAA,MAAAA;;AAGK,KAzMHL,gBAAAA,GAyMG,UAAA,GAAA,YAAA;AAwCEY,KA/OLX,eAAAA,GAAkBX,YAgPpBqB,GAAAA,aAAAA,GAAAA,cAA0B,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AASxBZ,KAxPAG,UAAAA,GAAaC,MAwPK,CAAA,MAAGd,GAAAA,OAAAA,EAxPiBY,eAwPF,CAAA;AAChD;AACA;AAIA;AACA;AACA;;;AAIgBa,KA5PJV,gBAAAA,GAAmBX,kBA4PfqB,CA5PkCf,kBA4PlCe,EA5PsDb,eA4PtDa,CAAAA;;;AAShB;;;;;AAWA;AAAwDI,KAvQ5Cb,WAAAA,GAuQ4Ca,QAAAA,GAAAA,aAAAA,GAAAA,gBAAAA,GAAAA,KAAAA,GAAAA,SAAAA;;;;AACxD;AACiBK,UApQAjB,WAAAA,CAoQmB;EAAuBY;;EAIpCI,aAAAA,CAAAA,EAAAA,MAAAA;EAJsBD;EAAQ,KAAA,EA/P1Cd,gBA+P0C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;;UAEDiD,gBAAAA;UACLT;WACCO;;UAEIG,gBAAAA;UACLR;WACCM;;UAEIG,oBAAAA;QACPrE;;WAEGiE;UACDP;eACKY;;UAEAC,oBAAAA;QACP9D;;WAEGyD;UACDN;eACKU;;UAEAA,WAAAA;;;;;;UAMAE,YAAAA;;;;UAIAC,kBAAAA;;;;UAIAC,kBAAAA;;;;;;;UAOAC,cAAAA;;QAEPzC;;KAEE0C,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;;aAEFhE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/utils/arePrePropertiesEqual.ts
|
|
2
2
|
function arePrePropertiesEqual(propsA, propsB) {
|
|
3
3
|
if (propsA == null || propsB == null) return propsA === propsB;
|
|
4
|
-
return areCustomPropertiesEqual(propsA.customProperties, propsB.customProperties) && propsA.type === propsB.type && propsA.diffIndicators === propsB.diffIndicators && propsA.disableBackground === propsB.disableBackground && propsA.disableLineNumbers === propsB.disableLineNumbers && propsA.overflow === propsB.overflow && propsA.split === propsB.split && propsA.
|
|
4
|
+
return areCustomPropertiesEqual(propsA.customProperties, propsB.customProperties) && propsA.type === propsB.type && propsA.diffIndicators === propsB.diffIndicators && propsA.disableBackground === propsB.disableBackground && propsA.disableLineNumbers === propsB.disableLineNumbers && propsA.overflow === propsB.overflow && propsA.split === propsB.split && propsA.totalLines === propsB.totalLines;
|
|
5
5
|
}
|
|
6
6
|
const EMPTY_CUSTOM_PROPERTIES = {};
|
|
7
7
|
function areCustomPropertiesEqual(customPropertiesA = EMPTY_CUSTOM_PROPERTIES, customPropertiesB = EMPTY_CUSTOM_PROPERTIES) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arePrePropertiesEqual.js","names":["EMPTY_CUSTOM_PROPERTIES: CustomPreProperties"],"sources":["../../src/utils/arePrePropertiesEqual.ts"],"sourcesContent":["import type { CustomPreProperties, PrePropertiesConfig } from '../types';\n\nexport function arePrePropertiesEqual(\n propsA: PrePropertiesConfig | undefined,\n propsB: PrePropertiesConfig | undefined\n): boolean {\n if (propsA == null || propsB == null) {\n return propsA === propsB;\n }\n return (\n areCustomPropertiesEqual(\n propsA.customProperties,\n propsB.customProperties\n ) &&\n propsA.type === propsB.type &&\n propsA.diffIndicators === propsB.diffIndicators &&\n propsA.disableBackground === propsB.disableBackground &&\n propsA.disableLineNumbers === propsB.disableLineNumbers &&\n propsA.overflow === propsB.overflow &&\n propsA.split === propsB.split &&\n propsA.
|
|
1
|
+
{"version":3,"file":"arePrePropertiesEqual.js","names":["EMPTY_CUSTOM_PROPERTIES: CustomPreProperties"],"sources":["../../src/utils/arePrePropertiesEqual.ts"],"sourcesContent":["import type { CustomPreProperties, PrePropertiesConfig } from '../types';\n\nexport function arePrePropertiesEqual(\n propsA: PrePropertiesConfig | undefined,\n propsB: PrePropertiesConfig | undefined\n): boolean {\n if (propsA == null || propsB == null) {\n return propsA === propsB;\n }\n return (\n areCustomPropertiesEqual(\n propsA.customProperties,\n propsB.customProperties\n ) &&\n propsA.type === propsB.type &&\n propsA.diffIndicators === propsB.diffIndicators &&\n propsA.disableBackground === propsB.disableBackground &&\n propsA.disableLineNumbers === propsB.disableLineNumbers &&\n propsA.overflow === propsB.overflow &&\n propsA.split === propsB.split &&\n propsA.totalLines === propsB.totalLines\n );\n}\n\nconst EMPTY_CUSTOM_PROPERTIES: CustomPreProperties = {};\n\nfunction areCustomPropertiesEqual(\n customPropertiesA: CustomPreProperties = EMPTY_CUSTOM_PROPERTIES,\n customPropertiesB: CustomPreProperties = EMPTY_CUSTOM_PROPERTIES\n): boolean {\n if (customPropertiesA === customPropertiesB) {\n return true;\n }\n const keysA = Object.keys(customPropertiesA);\n const keysB = Object.keys(customPropertiesB);\n if (keysA.length !== keysB.length) {\n return false;\n }\n for (const key of keysA) {\n if (customPropertiesA[key] !== customPropertiesB[key]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";AAEA,SAAgB,sBACd,QACA,QACS;AACT,KAAI,UAAU,QAAQ,UAAU,KAC9B,QAAO,WAAW;AAEpB,QACE,yBACE,OAAO,kBACP,OAAO,iBACR,IACD,OAAO,SAAS,OAAO,QACvB,OAAO,mBAAmB,OAAO,kBACjC,OAAO,sBAAsB,OAAO,qBACpC,OAAO,uBAAuB,OAAO,sBACrC,OAAO,aAAa,OAAO,YAC3B,OAAO,UAAU,OAAO,SACxB,OAAO,eAAe,OAAO;;AAIjC,MAAMA,0BAA+C,EAAE;AAEvD,SAAS,yBACP,oBAAyC,yBACzC,oBAAyC,yBAChC;AACT,KAAI,sBAAsB,kBACxB,QAAO;CAET,MAAM,QAAQ,OAAO,KAAK,kBAAkB;CAC5C,MAAM,QAAQ,OAAO,KAAK,kBAAkB;AAC5C,KAAI,MAAM,WAAW,MAAM,OACzB,QAAO;AAET,MAAK,MAAM,OAAO,MAChB,KAAI,kBAAkB,SAAS,kBAAkB,KAC/C,QAAO;AAGX,QAAO"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { FileContents, FileDiffMetadata,
|
|
1
|
+
import { FileContents, FileDiffMetadata, FileHeaderRenderMode } from "../types.js";
|
|
2
2
|
import { Element } from "hast";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/createFileHeaderElement.d.ts
|
|
5
5
|
interface CreateFileHeaderElementProps {
|
|
6
6
|
fileOrDiff: FileDiffMetadata | FileContents;
|
|
7
|
-
|
|
8
|
-
themeType: ThemeTypes;
|
|
7
|
+
mode: FileHeaderRenderMode;
|
|
9
8
|
}
|
|
10
9
|
declare function createFileHeaderElement({
|
|
11
10
|
fileOrDiff,
|
|
12
|
-
|
|
13
|
-
themeType
|
|
11
|
+
mode
|
|
14
12
|
}: CreateFileHeaderElementProps): Element;
|
|
15
13
|
//#endregion
|
|
16
14
|
export { CreateFileHeaderElementProps, createFileHeaderElement };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFileHeaderElement.d.ts","names":["Element","HASTElement","FileContents","FileDiffMetadata","
|
|
1
|
+
{"version":3,"file":"createFileHeaderElement.d.ts","names":["Element","HASTElement","FileContents","FileDiffMetadata","FileHeaderRenderMode","CreateFileHeaderElementProps","createFileHeaderElement","fileOrDiff","mode"],"sources":["../../src/utils/createFileHeaderElement.d.ts"],"sourcesContent":["import type { Element as HASTElement } from 'hast';\nimport type { FileContents, FileDiffMetadata, FileHeaderRenderMode } from '../types';\nexport interface CreateFileHeaderElementProps {\n fileOrDiff: FileDiffMetadata | FileContents;\n mode: FileHeaderRenderMode;\n}\nexport declare function createFileHeaderElement({ fileOrDiff, mode }: CreateFileHeaderElementProps): HASTElement;\n//# sourceMappingURL=createFileHeaderElement.d.ts.map"],"mappings":";;;;UAEiBK,4BAAAA;cACDF,mBAAmBD;EADlBG,IAAAA,EAEPD,oBAFOC;;AACkBH,iBAGXI,uBAAAA,CAHWJ;EAAAA,UAAAA;EAAAA;AAAAA,CAAAA,EAGmCG,4BAHnCH,CAAAA,EAGkED,OAHlEC"}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID } from "../constants.js";
|
|
1
|
+
import { CUSTOM_HEADER_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID } from "../constants.js";
|
|
2
2
|
import { createHastElement, createIconElement, createTextNodeElement } from "./hast_utils.js";
|
|
3
3
|
import { getIconForType } from "./getIconForType.js";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/createFileHeaderElement.ts
|
|
6
|
-
function createFileHeaderElement({ fileOrDiff,
|
|
6
|
+
function createFileHeaderElement({ fileOrDiff, mode }) {
|
|
7
7
|
const fileDiff = "type" in fileOrDiff ? fileOrDiff : void 0;
|
|
8
8
|
const properties = {
|
|
9
|
-
"data-diffs-header":
|
|
10
|
-
"data-change-type": fileDiff?.type
|
|
11
|
-
"data-theme-type": themeType !== "system" ? themeType : void 0,
|
|
12
|
-
style: themeStyles
|
|
9
|
+
"data-diffs-header": mode,
|
|
10
|
+
"data-change-type": fileDiff?.type
|
|
13
11
|
};
|
|
14
12
|
return createHastElement({
|
|
15
13
|
tagName: "div",
|
|
16
|
-
children: [
|
|
14
|
+
children: [mode === "custom" ? createHastElement({
|
|
15
|
+
tagName: "slot",
|
|
16
|
+
properties: { name: CUSTOM_HEADER_SLOT_ID }
|
|
17
|
+
}) : createHeaderElement({
|
|
17
18
|
name: fileOrDiff.name,
|
|
18
19
|
prevName: "prevName" in fileOrDiff ? fileOrDiff.prevName : void 0,
|
|
19
20
|
iconType: fileDiff?.type ?? "file"
|
|
20
|
-
}), createMetadataElement(fileDiff)],
|
|
21
|
+
}), ...mode === "custom" ? [] : [createMetadataElement(fileDiff)]],
|
|
21
22
|
properties
|
|
22
23
|
});
|
|
23
24
|
}
|
|
@@ -32,7 +33,10 @@ function createHeaderElement({ name, prevName, iconType }) {
|
|
|
32
33
|
if (prevName != null) {
|
|
33
34
|
children.push(createHastElement({
|
|
34
35
|
tagName: "div",
|
|
35
|
-
children: [
|
|
36
|
+
children: [createHastElement({
|
|
37
|
+
tagName: "bdi",
|
|
38
|
+
children: [createTextNodeElement(prevName)]
|
|
39
|
+
})],
|
|
36
40
|
properties: { "data-prev-name": "" }
|
|
37
41
|
}));
|
|
38
42
|
children.push(createIconElement({
|
|
@@ -42,7 +46,10 @@ function createHeaderElement({ name, prevName, iconType }) {
|
|
|
42
46
|
}
|
|
43
47
|
children.push(createHastElement({
|
|
44
48
|
tagName: "div",
|
|
45
|
-
children: [
|
|
49
|
+
children: [createHastElement({
|
|
50
|
+
tagName: "bdi",
|
|
51
|
+
children: [createTextNodeElement(name)]
|
|
52
|
+
})],
|
|
46
53
|
properties: { "data-title": "" }
|
|
47
54
|
}));
|
|
48
55
|
return createHastElement({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFileHeaderElement.js","names":["properties: Properties","children: ElementContent[]"],"sources":["../../src/utils/createFileHeaderElement.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement, Properties } from 'hast';\n\nimport {
|
|
1
|
+
{"version":3,"file":"createFileHeaderElement.js","names":["properties: Properties","children: ElementContent[]"],"sources":["../../src/utils/createFileHeaderElement.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement, Properties } from 'hast';\n\nimport {\n CUSTOM_HEADER_SLOT_ID,\n HEADER_METADATA_SLOT_ID,\n HEADER_PREFIX_SLOT_ID,\n} from '../constants';\nimport type {\n ChangeTypes,\n FileContents,\n FileDiffMetadata,\n FileHeaderRenderMode,\n} from '../types';\nimport { getIconForType } from './getIconForType';\nimport {\n createHastElement,\n createIconElement,\n createTextNodeElement,\n} from './hast_utils';\n\nexport interface CreateFileHeaderElementProps {\n fileOrDiff: FileDiffMetadata | FileContents;\n mode: FileHeaderRenderMode;\n}\n\nexport function createFileHeaderElement({\n fileOrDiff,\n mode,\n}: CreateFileHeaderElementProps): HASTElement {\n const fileDiff = 'type' in fileOrDiff ? fileOrDiff : undefined;\n const properties: Properties = {\n 'data-diffs-header': mode,\n 'data-change-type': fileDiff?.type,\n };\n\n return createHastElement({\n tagName: 'div',\n children: [\n mode === 'custom'\n ? createHastElement({\n tagName: 'slot',\n properties: { name: CUSTOM_HEADER_SLOT_ID },\n })\n : createHeaderElement({\n name: fileOrDiff.name,\n prevName:\n 'prevName' in fileOrDiff ? fileOrDiff.prevName : undefined,\n iconType: fileDiff?.type ?? 'file',\n }),\n ...(mode === 'custom' ? [] : [createMetadataElement(fileDiff)]),\n ],\n properties,\n });\n}\n\ninterface CreateHeaderElementOptions {\n name: string;\n prevName?: string;\n iconType: ChangeTypes | 'file';\n}\n\nfunction createHeaderElement({\n name,\n prevName,\n iconType,\n}: CreateHeaderElementOptions): HASTElement {\n const children: ElementContent[] = [\n createHastElement({\n tagName: 'slot',\n properties: { name: HEADER_PREFIX_SLOT_ID },\n }),\n createIconElement({\n name: getIconForType(iconType),\n properties: { 'data-change-icon': iconType },\n }),\n ];\n if (prevName != null) {\n children.push(\n createHastElement({\n tagName: 'div',\n children: [\n createHastElement({\n tagName: 'bdi',\n children: [createTextNodeElement(prevName)],\n }),\n ],\n properties: {\n 'data-prev-name': '',\n },\n })\n );\n children.push(\n createIconElement({\n name: 'diffs-icon-arrow-right-short',\n properties: {\n 'data-rename-icon': '',\n },\n })\n );\n }\n children.push(\n createHastElement({\n tagName: 'div',\n children: [\n createHastElement({\n tagName: 'bdi',\n children: [createTextNodeElement(name)],\n }),\n ],\n properties: { 'data-title': '' },\n })\n );\n return createHastElement({\n tagName: 'div',\n children,\n properties: { 'data-header-content': '' },\n });\n}\n\nfunction createMetadataElement(\n fileDiff: FileDiffMetadata | undefined\n): HASTElement {\n const children: ElementContent[] = [];\n if (fileDiff != null) {\n let additions = 0;\n let deletions = 0;\n for (const hunk of fileDiff.hunks) {\n additions += hunk.additionLines;\n deletions += hunk.deletionLines;\n }\n if (deletions > 0 || additions === 0) {\n children.push(\n createHastElement({\n tagName: 'span',\n children: [createTextNodeElement(`-${deletions}`)],\n properties: { 'data-deletions-count': '' },\n })\n );\n }\n if (additions > 0 || deletions === 0) {\n children.push(\n createHastElement({\n tagName: 'span',\n children: [createTextNodeElement(`+${additions}`)],\n properties: { 'data-additions-count': '' },\n })\n );\n }\n }\n children.push(\n createHastElement({\n tagName: 'slot',\n properties: { name: HEADER_METADATA_SLOT_ID },\n })\n );\n return createHastElement({\n tagName: 'div',\n children,\n properties: { 'data-metadata': '' },\n });\n}\n"],"mappings":";;;;;AAyBA,SAAgB,wBAAwB,EACtC,YACA,QAC4C;CAC5C,MAAM,WAAW,UAAU,aAAa,aAAa;CACrD,MAAMA,aAAyB;EAC7B,qBAAqB;EACrB,oBAAoB,UAAU;EAC/B;AAED,QAAO,kBAAkB;EACvB,SAAS;EACT,UAAU,CACR,SAAS,WACL,kBAAkB;GAChB,SAAS;GACT,YAAY,EAAE,MAAM,uBAAuB;GAC5C,CAAC,GACF,oBAAoB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CAAC;GAClD,YAAY,EAAE,wBAAwB,IAAI;GAC3C,CAAC,CACH;AAEH,MAAI,YAAY,KAAK,cAAc,EACjC,UAAS,KACP,kBAAkB;GAChB,SAAS;GACT,UAAU,CAAC,sBAAsB,IAAI,YAAY,CAAC;GAClD,YAAY,EAAE,wBAAwB,IAAI;GAC3C,CAAC,CACH;;AAGL,UAAS,KACP,kBAAkB;EAChB,SAAS;EACT,YAAY,EAAE,MAAM,yBAAyB;EAC9C,CAAC,CACH;AACD,QAAO,kBAAkB;EACvB,SAAS;EACT;EACA,YAAY,EAAE,iBAAiB,IAAI;EACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPreElement.d.ts","names":["Element","HASTElement","Properties","PrePropertiesConfig","createPreElement","createPreWrapperProperties","diffIndicators","disableBackground","disableLineNumbers","overflow","split","
|
|
1
|
+
{"version":3,"file":"createPreElement.d.ts","names":["Element","HASTElement","Properties","PrePropertiesConfig","createPreElement","createPreWrapperProperties","diffIndicators","disableBackground","disableLineNumbers","overflow","split","totalLines","type","customProperties"],"sources":["../../src/utils/createPreElement.d.ts"],"sourcesContent":["import type { Element as HASTElement, Properties } from 'hast';\nimport type { PrePropertiesConfig } from '../types';\nexport declare function createPreElement(options: PrePropertiesConfig): HASTElement;\nexport declare function createPreWrapperProperties({ diffIndicators, disableBackground, disableLineNumbers, overflow, split, totalLines, type, customProperties }: PrePropertiesConfig): Properties;\n//# sourceMappingURL=createPreElement.d.ts.map"],"mappings":";;;;iBAEwBI,gBAAAA,UAA0BD,sBAAsBF;iBAChDI,0BAAAA;;;;;;;;;GAA2IF,sBAAsBD"}
|
|
@@ -7,8 +7,8 @@ function createPreElement(options) {
|
|
|
7
7
|
properties: createPreWrapperProperties(options)
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
function createPreWrapperProperties({ diffIndicators, disableBackground, disableLineNumbers, overflow, split,
|
|
11
|
-
|
|
10
|
+
function createPreWrapperProperties({ diffIndicators, disableBackground, disableLineNumbers, overflow, split, totalLines, type, customProperties }) {
|
|
11
|
+
return {
|
|
12
12
|
...customProperties,
|
|
13
13
|
"data-diff": type === "diff" ? "" : void 0,
|
|
14
14
|
"data-file": type === "file" ? "" : void 0,
|
|
@@ -17,12 +17,9 @@ function createPreWrapperProperties({ diffIndicators, disableBackground, disable
|
|
|
17
17
|
"data-disable-line-numbers": disableLineNumbers ? "" : void 0,
|
|
18
18
|
"data-background": !disableBackground ? "" : void 0,
|
|
19
19
|
"data-indicators": diffIndicators === "bars" || diffIndicators === "classic" ? diffIndicators : void 0,
|
|
20
|
-
|
|
21
|
-
style:
|
|
22
|
-
tabIndex: 0
|
|
20
|
+
tabIndex: 0,
|
|
21
|
+
style: `--diffs-min-number-column-width-default:${`${totalLines}`.length}ch;`
|
|
23
22
|
};
|
|
24
|
-
properties.style += `--diffs-min-number-column-width-default:${`${totalLines}`.length}ch;`;
|
|
25
|
-
return properties;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPreElement.js","names":[
|
|
1
|
+
{"version":3,"file":"createPreElement.js","names":[],"sources":["../../src/utils/createPreElement.ts"],"sourcesContent":["import type { Element as HASTElement, Properties } from 'hast';\n\nimport type { PrePropertiesConfig } from '../types';\nimport { createHastElement } from './hast_utils';\n\nexport function createPreElement(options: PrePropertiesConfig): HASTElement {\n return createHastElement({\n tagName: 'pre',\n properties: createPreWrapperProperties(options),\n });\n}\n\nexport function createPreWrapperProperties({\n diffIndicators,\n disableBackground,\n disableLineNumbers,\n overflow,\n split,\n totalLines,\n type,\n customProperties,\n}: PrePropertiesConfig): Properties {\n const properties: Properties = {\n // NOTE: We always apply custom properties first so the important\n // properties cannot be overridden\n ...customProperties,\n 'data-diff': type === 'diff' ? '' : undefined,\n 'data-file': type === 'file' ? '' : undefined,\n 'data-diff-type':\n type === 'diff' ? (split ? 'split' : 'single') : undefined,\n 'data-overflow': overflow,\n 'data-disable-line-numbers': disableLineNumbers ? '' : undefined,\n 'data-background': !disableBackground ? '' : undefined,\n 'data-indicators':\n diffIndicators === 'bars' || diffIndicators === 'classic'\n ? diffIndicators\n : undefined,\n tabIndex: 0,\n style: `--diffs-min-number-column-width-default:${`${totalLines}`.length}ch;`,\n };\n\n return properties;\n}\n"],"mappings":";;;AAKA,SAAgB,iBAAiB,SAA2C;AAC1E,QAAO,kBAAkB;EACvB,SAAS;EACT,YAAY,2BAA2B,QAAQ;EAChD,CAAC;;AAGJ,SAAgB,2BAA2B,EACzC,gBACA,mBACA,oBACA,UACA,OACA,YACA,MACA,oBACkC;AAoBlC,QAnB+B;EAG7B,GAAG;EACH,aAAa,SAAS,SAAS,KAAK;EACpC,aAAa,SAAS,SAAS,KAAK;EACpC,kBACE,SAAS,SAAU,QAAQ,UAAU,WAAY;EACnD,iBAAiB;EACjB,6BAA6B,qBAAqB,KAAK;EACvD,mBAAmB,CAAC,oBAAoB,KAAK;EAC7C,mBACE,mBAAmB,UAAU,mBAAmB,YAC5C,iBACA;EACN,UAAU;EACV,OAAO,2CAA2C,GAAG,aAAa,OAAO;EAC1E"}
|
|
@@ -2,6 +2,7 @@ import { Element } from "hast";
|
|
|
2
2
|
|
|
3
3
|
//#region src/utils/createStyleElement.d.ts
|
|
4
4
|
declare function createStyleElement(content: string, isCoreCSS?: boolean): Element;
|
|
5
|
+
declare function createThemeStyleElement(content: string): Element;
|
|
5
6
|
//#endregion
|
|
6
|
-
export { createStyleElement };
|
|
7
|
+
export { createStyleElement, createThemeStyleElement };
|
|
7
8
|
//# sourceMappingURL=createStyleElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStyleElement.d.ts","names":["Element","HASTElement","createStyleElement"],"sources":["../../src/utils/createStyleElement.d.ts"],"sourcesContent":["import type { Element as HASTElement } from 'hast';\nexport declare function createStyleElement(content: string, isCoreCSS?: boolean): HASTElement;\n//# sourceMappingURL=createStyleElement.d.ts.map"],"mappings":";;;iBACwBE,kBAAAA,wCAA0DD"}
|
|
1
|
+
{"version":3,"file":"createStyleElement.d.ts","names":["Element","HASTElement","createStyleElement","createThemeStyleElement"],"sources":["../../src/utils/createStyleElement.d.ts"],"sourcesContent":["import type { Element as HASTElement } from 'hast';\nexport declare function createStyleElement(content: string, isCoreCSS?: boolean): HASTElement;\nexport declare function createThemeStyleElement(content: string): HASTElement;\n//# sourceMappingURL=createStyleElement.d.ts.map"],"mappings":";;;iBACwBE,kBAAAA,wCAA0DD;iBAC1DE,uBAAAA,mBAA0CF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CORE_CSS_ATTRIBUTE, UNSAFE_CSS_ATTRIBUTE } from "../constants.js";
|
|
1
|
+
import { CORE_CSS_ATTRIBUTE, THEME_CSS_ATTRIBUTE, UNSAFE_CSS_ATTRIBUTE } from "../constants.js";
|
|
2
2
|
import { createHastElement, createTextNodeElement } from "./hast_utils.js";
|
|
3
3
|
import { wrapCoreCSS, wrapUnsafeCSS } from "./cssWrappers.js";
|
|
4
4
|
|
|
@@ -13,7 +13,14 @@ function createStyleElement(content, isCoreCSS = false) {
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
+
function createThemeStyleElement(content) {
|
|
17
|
+
return createHastElement({
|
|
18
|
+
tagName: "style",
|
|
19
|
+
children: [createTextNodeElement(content)],
|
|
20
|
+
properties: { [THEME_CSS_ATTRIBUTE]: "" }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
16
23
|
|
|
17
24
|
//#endregion
|
|
18
|
-
export { createStyleElement };
|
|
25
|
+
export { createStyleElement, createThemeStyleElement };
|
|
19
26
|
//# sourceMappingURL=createStyleElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStyleElement.js","names":[],"sources":["../../src/utils/createStyleElement.ts"],"sourcesContent":["import type { Element as HASTElement } from 'hast';\n\nimport {
|
|
1
|
+
{"version":3,"file":"createStyleElement.js","names":[],"sources":["../../src/utils/createStyleElement.ts"],"sourcesContent":["import type { Element as HASTElement } from 'hast';\n\nimport {\n CORE_CSS_ATTRIBUTE,\n THEME_CSS_ATTRIBUTE,\n UNSAFE_CSS_ATTRIBUTE,\n} from '../constants';\nimport { wrapCoreCSS, wrapUnsafeCSS } from './cssWrappers';\nimport { createHastElement, createTextNodeElement } from './hast_utils';\n\nexport function createStyleElement(\n content: string,\n isCoreCSS: boolean = false\n): HASTElement {\n return createHastElement({\n tagName: 'style',\n children: [\n createTextNodeElement(\n isCoreCSS ? wrapCoreCSS(content) : wrapUnsafeCSS(content)\n ),\n ],\n properties: {\n [CORE_CSS_ATTRIBUTE]: isCoreCSS ? '' : undefined,\n [UNSAFE_CSS_ATTRIBUTE]: !isCoreCSS ? '' : undefined,\n },\n });\n}\n\nexport function createThemeStyleElement(content: string): HASTElement {\n return createHastElement({\n tagName: 'style',\n children: [createTextNodeElement(content)],\n properties: {\n [THEME_CSS_ATTRIBUTE]: '',\n },\n });\n}\n"],"mappings":";;;;;AAUA,SAAgB,mBACd,SACA,YAAqB,OACR;AACb,QAAO,kBAAkB;EACvB,SAAS;EACT,UAAU,CACR,sBACE,YAAY,YAAY,QAAQ,GAAG,cAAc,QAAQ,CAC1D,CACF;EACD,YAAY;IACT,qBAAqB,YAAY,KAAK;IACtC,uBAAuB,CAAC,YAAY,KAAK;GAC3C;EACF,CAAC;;AAGJ,SAAgB,wBAAwB,SAA8B;AACpE,QAAO,kBAAkB;EACvB,SAAS;EACT,UAAU,CAAC,sBAAsB,QAAQ,CAAC;EAC1C,YAAY,GACT,sBAAsB,IACxB;EACF,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { ThemeTypes } from "../types.js";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/cssWrappers.d.ts
|
|
2
4
|
declare function wrapCoreCSS(mainCSS: string): string;
|
|
3
5
|
declare function wrapUnsafeCSS(unsafeCSS: string): string;
|
|
6
|
+
declare function wrapThemeCSS(themeCSS: string, themeType?: ThemeTypes): string;
|
|
4
7
|
//#endregion
|
|
5
|
-
export { wrapCoreCSS, wrapUnsafeCSS };
|
|
8
|
+
export { wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
|
|
6
9
|
//# sourceMappingURL=cssWrappers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssWrappers.d.ts","names":["wrapCoreCSS","wrapUnsafeCSS"],"sources":["../../src/utils/cssWrappers.d.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"cssWrappers.d.ts","names":["ThemeTypes","wrapCoreCSS","wrapUnsafeCSS","wrapThemeCSS"],"sources":["../../src/utils/cssWrappers.d.ts"],"sourcesContent":["import type { ThemeTypes } from '../types';\nexport declare function wrapCoreCSS(mainCSS: string): string;\nexport declare function wrapUnsafeCSS(unsafeCSS: string): string;\nexport declare function wrapThemeCSS(themeCSS: string, themeType?: ThemeTypes): string;\n//# sourceMappingURL=cssWrappers.d.ts.map"],"mappings":";;;iBACwBC,WAAAA;iBACAC,aAAAA;AADAD,iBAEAE,YAAAA,CAFW,QAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAEgCH,UAFhC,CAAA,EAAA,MAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import style_default from "../style.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/cssWrappers.ts
|
|
4
|
-
const LAYER_ORDER = `@layer base, theme, unsafe;`;
|
|
4
|
+
const LAYER_ORDER = `@layer base, theme, rendered, unsafe;`;
|
|
5
5
|
function wrapCoreCSS(mainCSS) {
|
|
6
6
|
return `${LAYER_ORDER}
|
|
7
7
|
${style_default}
|
|
@@ -15,7 +15,16 @@ function wrapUnsafeCSS(unsafeCSS) {
|
|
|
15
15
|
${unsafeCSS}
|
|
16
16
|
}`;
|
|
17
17
|
}
|
|
18
|
+
function wrapThemeCSS(themeCSS, themeType = "system") {
|
|
19
|
+
return `${LAYER_ORDER}
|
|
20
|
+
@layer rendered {
|
|
21
|
+
:host {${themeType === "system" ? "" : `
|
|
22
|
+
color-scheme: ${themeType};`}
|
|
23
|
+
${themeCSS}
|
|
24
|
+
}
|
|
25
|
+
}`;
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
//#endregion
|
|
20
|
-
export { wrapCoreCSS, wrapUnsafeCSS };
|
|
29
|
+
export { wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
|
|
21
30
|
//# sourceMappingURL=cssWrappers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssWrappers.js","names":["rawStyles"],"sources":["../../src/utils/cssWrappers.ts"],"sourcesContent":["import rawStyles from '../style.css';\n\nconst LAYER_ORDER = `@layer base, theme, unsafe;`;\n\nexport function wrapCoreCSS(mainCSS: string) {\n return `${LAYER_ORDER}\n${rawStyles}\n@layer theme {\n ${mainCSS}\n}`;\n}\n\nexport function wrapUnsafeCSS(unsafeCSS: string) {\n return `${LAYER_ORDER}\n@layer unsafe {\n ${unsafeCSS}\n}`;\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cssWrappers.js","names":["rawStyles"],"sources":["../../src/utils/cssWrappers.ts"],"sourcesContent":["import rawStyles from '../style.css';\nimport type { ThemeTypes } from '../types';\n\nconst LAYER_ORDER = `@layer base, theme, rendered, unsafe;`;\n\nexport function wrapCoreCSS(mainCSS: string) {\n return `${LAYER_ORDER}\n${rawStyles}\n@layer theme {\n ${mainCSS}\n}`;\n}\n\nexport function wrapUnsafeCSS(unsafeCSS: string) {\n return `${LAYER_ORDER}\n@layer unsafe {\n ${unsafeCSS}\n}`;\n}\n\nexport function wrapThemeCSS(\n themeCSS: string,\n themeType: ThemeTypes = 'system'\n) {\n const colorSchemeRule =\n themeType === 'system'\n ? ''\n : `\n color-scheme: ${themeType};`;\n\n return `${LAYER_ORDER}\n@layer rendered {\n :host {${colorSchemeRule}\n ${themeCSS}\n }\n}`;\n}\n"],"mappings":";;;AAGA,MAAM,cAAc;AAEpB,SAAgB,YAAY,SAAiB;AAC3C,QAAO,GAAG,YAAY;EACtBA,cAAU;;IAER,QAAQ;;;AAIZ,SAAgB,cAAc,WAAmB;AAC/C,QAAO,GAAG,YAAY;;IAEpB,UAAU;;;AAId,SAAgB,aACd,UACA,YAAwB,UACxB;AAOA,QAAO,GAAG,YAAY;;WALpB,cAAc,WACV,KACA;kBACU,UAAU,GAID;IACvB,SAAS"}
|
|
@@ -5,7 +5,7 @@ import { Element, ElementContent, Properties, Root, Text } from "hast";
|
|
|
5
5
|
//#region src/utils/hast_utils.d.ts
|
|
6
6
|
declare function createTextNodeElement(value: string): Text;
|
|
7
7
|
interface CreateHastElementProps {
|
|
8
|
-
tagName: 'span' | 'div' | 'button' | 'code' | 'pre' | 'slot' | 'svg' | 'use' | 'style' | 'template';
|
|
8
|
+
tagName: 'span' | 'div' | 'button' | 'code' | 'pre' | 'slot' | 'svg' | 'use' | 'style' | 'template' | 'bdi';
|
|
9
9
|
children?: ElementContent[];
|
|
10
10
|
properties?: Properties;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hast_utils.d.ts","names":["ElementContent","Element","HASTElement","Properties","Root","Text","SVGSpriteNames","LineTypes","createTextNodeElement","CreateHastElementProps","createHastElement","tagName","children","properties","CreateIconProps","createIconElement","name","width","height","findCodeElement","createGutterWrapper","createGutterItem","createGutterGap"],"sources":["../../src/utils/hast_utils.d.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement, Properties, Root, Text } from 'hast';\nimport type { SVGSpriteNames } from '../sprite';\nimport type { LineTypes } from '../types';\nexport declare function createTextNodeElement(value: string): Text;\ninterface CreateHastElementProps {\n tagName: 'span' | 'div' | 'button' | 'code' | 'pre' | 'slot' | 'svg' | 'use' | 'style' | 'template';\n children?: ElementContent[];\n properties?: Properties;\n}\nexport declare function createHastElement({ tagName, children, properties }: CreateHastElementProps): HASTElement;\ninterface CreateIconProps {\n name: SVGSpriteNames;\n width?: number;\n height?: number;\n properties?: Properties;\n}\nexport declare function createIconElement({ name, width, height, properties }: CreateIconProps): HASTElement;\nexport declare function findCodeElement(nodes: Root | HASTElement): HASTElement | undefined;\nexport declare function createGutterWrapper(children?: ElementContent[]): HASTElement;\nexport declare function createGutterItem(lineType: LineTypes | 'buffer' | 'separator' | 'annotation', lineNumber: number, lineIndex: string, properties?: Properties): HASTElement;\nexport declare function createGutterGap(type: LineTypes | undefined, bufferType: 'annotation' | 'buffer' | 'metadata', size: number): HASTElement;\nexport {};\n//# sourceMappingURL=hast_utils.d.ts.map"],"mappings":";;;;;iBAGwBQ,qBAAAA,iBAAsCH;UACpDI,sBAAAA;EADcD,OAAAA,EAAAA,MAAAA,GAAAA,KAAAA,GAAqB,QAAA,GAAiBH,MAAI,GAAA,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,KAAA,GAAA,OAAA,GAAA,UAAA;EACxDI,QAAAA,CAAAA,EAEKT,cAFiB,EAAA;EAKRU,UAAAA,CAAAA,EAFPP,UAEwB;;AAAYS,iBAA7BF,iBAAAA,CAA6BE;EAAAA,OAAAA;EAAAA,QAAAA;EAAAA;AAAAA,CAAAA,EAAwBH,sBAAxBG,CAAAA,EAAiDV,OAAjDU;UAC3CE,eAAAA,CADqDD;EAAcJ,IAAAA,EAEnEH,cAFmEG;EAAyBP,KAAAA,CAAAA,EAAAA,MAAAA;EAAW,MAAA,CAAA,EAAA,MAAA;EACvGY,UAAAA,CAAAA,EAIOX,UAJQ;AAMzB;AAA4Ca,iBAApBD,iBAAAA,CAAoBC;EAAAA,IAAAA;EAAAA,KAAAA;EAAAA,MAAAA;EAAAA;AAAAA,CAAAA,EAAmCF,eAAnCE,CAAAA,EAAqDd,OAArDc;AAAMC,iBAC1BE,eAAAA,CAD0BF,KAAAA,EACHb,IADGa,GACIf,OADJe,CAAAA,EACkBf,OADlBe,GAAAA,SAAAA;AAAOC,iBAEjCE,mBAAAA,CAFiCF,QAAAA,CAAAA,EAEFlB,cAFEkB,EAAAA,CAAAA,EAEiBhB,OAFjBgB;AAAQL,iBAGzCQ,gBAAAA,CAHyCR,QAAAA,EAGdN,SAHcM,GAAAA,QAAAA,GAAAA,WAAAA,GAAAA,YAAAA,EAAAA,UAAAA,EAAAA,MAAAA,EAAAA,SAAAA,EAAAA,MAAAA,EAAAA,UAAAA,CAAAA,EAGyFV,UAHzFU,CAAAA,EAGsGX,OAHtGW;AAAcC,iBAIvDQ,eAAAA,CAJuDR,IAAAA,EAIjCP,SAJiCO,GAAAA,SAAAA,EAAAA,UAAAA,EAAAA,YAAAA,GAAAA,QAAAA,GAAAA,UAAAA,EAAAA,IAAAA,EAAAA,MAAAA,CAAAA,EAIuDZ,OAJvDY"}
|
|
1
|
+
{"version":3,"file":"hast_utils.d.ts","names":["ElementContent","Element","HASTElement","Properties","Root","Text","SVGSpriteNames","LineTypes","createTextNodeElement","CreateHastElementProps","createHastElement","tagName","children","properties","CreateIconProps","createIconElement","name","width","height","findCodeElement","createGutterWrapper","createGutterItem","createGutterGap"],"sources":["../../src/utils/hast_utils.d.ts"],"sourcesContent":["import type { ElementContent, Element as HASTElement, Properties, Root, Text } from 'hast';\nimport type { SVGSpriteNames } from '../sprite';\nimport type { LineTypes } from '../types';\nexport declare function createTextNodeElement(value: string): Text;\ninterface CreateHastElementProps {\n tagName: 'span' | 'div' | 'button' | 'code' | 'pre' | 'slot' | 'svg' | 'use' | 'style' | 'template' | 'bdi';\n children?: ElementContent[];\n properties?: Properties;\n}\nexport declare function createHastElement({ tagName, children, properties }: CreateHastElementProps): HASTElement;\ninterface CreateIconProps {\n name: SVGSpriteNames;\n width?: number;\n height?: number;\n properties?: Properties;\n}\nexport declare function createIconElement({ name, width, height, properties }: CreateIconProps): HASTElement;\nexport declare function findCodeElement(nodes: Root | HASTElement): HASTElement | undefined;\nexport declare function createGutterWrapper(children?: ElementContent[]): HASTElement;\nexport declare function createGutterItem(lineType: LineTypes | 'buffer' | 'separator' | 'annotation', lineNumber: number, lineIndex: string, properties?: Properties): HASTElement;\nexport declare function createGutterGap(type: LineTypes | undefined, bufferType: 'annotation' | 'buffer' | 'metadata', size: number): HASTElement;\nexport {};\n//# sourceMappingURL=hast_utils.d.ts.map"],"mappings":";;;;;iBAGwBQ,qBAAAA,iBAAsCH;UACpDI,sBAAAA;EADcD,OAAAA,EAAAA,MAAAA,GAAAA,KAAAA,GAAqB,QAAA,GAAiBH,MAAI,GAAA,KAAA,GAAA,MAAA,GAAA,KAAA,GAAA,KAAA,GAAA,OAAA,GAAA,UAAA,GAAA,KAAA;EACxDI,QAAAA,CAAAA,EAEKT,cAFiB,EAAA;EAKRU,UAAAA,CAAAA,EAFPP,UAEwB;;AAAYS,iBAA7BF,iBAAAA,CAA6BE;EAAAA,OAAAA;EAAAA,QAAAA;EAAAA;AAAAA,CAAAA,EAAwBH,sBAAxBG,CAAAA,EAAiDV,OAAjDU;UAC3CE,eAAAA,CADqDD;EAAcJ,IAAAA,EAEnEH,cAFmEG;EAAyBP,KAAAA,CAAAA,EAAAA,MAAAA;EAAW,MAAA,CAAA,EAAA,MAAA;EACvGY,UAAAA,CAAAA,EAIOX,UAJQ;AAMzB;AAA4Ca,iBAApBD,iBAAAA,CAAoBC;EAAAA,IAAAA;EAAAA,KAAAA;EAAAA,MAAAA;EAAAA;AAAAA,CAAAA,EAAmCF,eAAnCE,CAAAA,EAAqDd,OAArDc;AAAMC,iBAC1BE,eAAAA,CAD0BF,KAAAA,EACHb,IADGa,GACIf,OADJe,CAAAA,EACkBf,OADlBe,GAAAA,SAAAA;AAAOC,iBAEjCE,mBAAAA,CAFiCF,QAAAA,CAAAA,EAEFlB,cAFEkB,EAAAA,CAAAA,EAEiBhB,OAFjBgB;AAAQL,iBAGzCQ,gBAAAA,CAHyCR,QAAAA,EAGdN,SAHcM,GAAAA,QAAAA,GAAAA,WAAAA,GAAAA,YAAAA,EAAAA,UAAAA,EAAAA,MAAAA,EAAAA,SAAAA,EAAAA,MAAAA,EAAAA,UAAAA,CAAAA,EAGyFV,UAHzFU,CAAAA,EAGsGX,OAHtGW;AAAcC,iBAIvDQ,eAAAA,CAJuDR,IAAAA,EAIjCP,SAJiCO,GAAAA,SAAAA,EAAAA,UAAAA,EAAAA,YAAAA,GAAAA,QAAAA,GAAAA,UAAAA,EAAAA,IAAAA,EAAAA,MAAAA,CAAAA,EAIuDZ,OAJvDY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hast_utils.js","names":["firstChild: RootContent | HASTElement | Root | null"],"sources":["../../src/utils/hast_utils.ts"],"sourcesContent":["import type {\n ElementContent,\n Element as HASTElement,\n Properties,\n Root,\n RootContent,\n Text,\n} from 'hast';\n\nimport type { SVGSpriteNames } from '../sprite';\nimport type { LineTypes } from '../types';\n\nexport function createTextNodeElement(value: string): Text {\n return { type: 'text', value };\n}\n\ninterface CreateHastElementProps {\n tagName:\n | 'span'\n | 'div'\n | 'button'\n | 'code'\n | 'pre'\n | 'slot'\n | 'svg'\n | 'use'\n | 'style'\n | 'template';\n children?: ElementContent[];\n properties?: Properties;\n}\n\nexport function createHastElement({\n tagName,\n children = [],\n properties = {},\n}: CreateHastElementProps): HASTElement {\n return {\n type: 'element',\n tagName,\n properties,\n children,\n };\n}\n\ninterface CreateIconProps {\n name: SVGSpriteNames;\n width?: number;\n height?: number;\n properties?: Properties;\n}\n\nexport function createIconElement({\n name,\n width = 16,\n height = 16,\n properties,\n}: CreateIconProps): HASTElement {\n return createHastElement({\n tagName: 'svg',\n properties: { width, height, viewBox: '0 0 16 16', ...properties },\n children: [\n createHastElement({\n tagName: 'use',\n properties: { href: `#${name.replace(/^#/, '')}` },\n }),\n ],\n });\n}\n\nexport function findCodeElement(\n nodes: Root | HASTElement\n): HASTElement | undefined {\n let firstChild: RootContent | HASTElement | Root | null = nodes.children[0];\n while (firstChild != null) {\n if (firstChild.type === 'element' && firstChild.tagName === 'code') {\n return firstChild;\n }\n if ('children' in firstChild) {\n firstChild = firstChild.children[0];\n } else {\n firstChild = null;\n }\n }\n return undefined;\n}\n\nexport function createGutterWrapper(children?: ElementContent[]): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: { 'data-gutter': '' },\n children,\n });\n}\n\nexport function createGutterItem(\n lineType: LineTypes | 'buffer' | 'separator' | 'annotation',\n lineNumber: number,\n lineIndex: string,\n properties: Properties = {}\n): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-line-type': lineType,\n 'data-column-number': lineNumber,\n 'data-line-index': lineIndex,\n ...properties,\n },\n children:\n lineNumber != null\n ? [\n createHastElement({\n tagName: 'span',\n properties: { 'data-line-number-content': '' },\n children: [createTextNodeElement(`${lineNumber}`)],\n }),\n ]\n : undefined,\n });\n}\n\nexport function createGutterGap(\n type: LineTypes | undefined,\n bufferType: 'annotation' | 'buffer' | 'metadata',\n size: number\n): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-gutter-buffer': bufferType,\n 'data-buffer-size': size,\n 'data-line-type': bufferType === 'annotation' ? undefined : type,\n style:\n bufferType === 'annotation'\n ? `grid-row: span ${size};`\n : `grid-row: span ${size};min-height:calc(${size} * 1lh);`,\n },\n });\n}\n"],"mappings":";AAYA,SAAgB,sBAAsB,OAAqB;AACzD,QAAO;EAAE,MAAM;EAAQ;EAAO;;
|
|
1
|
+
{"version":3,"file":"hast_utils.js","names":["firstChild: RootContent | HASTElement | Root | null"],"sources":["../../src/utils/hast_utils.ts"],"sourcesContent":["import type {\n ElementContent,\n Element as HASTElement,\n Properties,\n Root,\n RootContent,\n Text,\n} from 'hast';\n\nimport type { SVGSpriteNames } from '../sprite';\nimport type { LineTypes } from '../types';\n\nexport function createTextNodeElement(value: string): Text {\n return { type: 'text', value };\n}\n\ninterface CreateHastElementProps {\n tagName:\n | 'span'\n | 'div'\n | 'button'\n | 'code'\n | 'pre'\n | 'slot'\n | 'svg'\n | 'use'\n | 'style'\n | 'template'\n | 'bdi';\n children?: ElementContent[];\n properties?: Properties;\n}\n\nexport function createHastElement({\n tagName,\n children = [],\n properties = {},\n}: CreateHastElementProps): HASTElement {\n return {\n type: 'element',\n tagName,\n properties,\n children,\n };\n}\n\ninterface CreateIconProps {\n name: SVGSpriteNames;\n width?: number;\n height?: number;\n properties?: Properties;\n}\n\nexport function createIconElement({\n name,\n width = 16,\n height = 16,\n properties,\n}: CreateIconProps): HASTElement {\n return createHastElement({\n tagName: 'svg',\n properties: { width, height, viewBox: '0 0 16 16', ...properties },\n children: [\n createHastElement({\n tagName: 'use',\n properties: { href: `#${name.replace(/^#/, '')}` },\n }),\n ],\n });\n}\n\nexport function findCodeElement(\n nodes: Root | HASTElement\n): HASTElement | undefined {\n let firstChild: RootContent | HASTElement | Root | null = nodes.children[0];\n while (firstChild != null) {\n if (firstChild.type === 'element' && firstChild.tagName === 'code') {\n return firstChild;\n }\n if ('children' in firstChild) {\n firstChild = firstChild.children[0];\n } else {\n firstChild = null;\n }\n }\n return undefined;\n}\n\nexport function createGutterWrapper(children?: ElementContent[]): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: { 'data-gutter': '' },\n children,\n });\n}\n\nexport function createGutterItem(\n lineType: LineTypes | 'buffer' | 'separator' | 'annotation',\n lineNumber: number,\n lineIndex: string,\n properties: Properties = {}\n): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-line-type': lineType,\n 'data-column-number': lineNumber,\n 'data-line-index': lineIndex,\n ...properties,\n },\n children:\n lineNumber != null\n ? [\n createHastElement({\n tagName: 'span',\n properties: { 'data-line-number-content': '' },\n children: [createTextNodeElement(`${lineNumber}`)],\n }),\n ]\n : undefined,\n });\n}\n\nexport function createGutterGap(\n type: LineTypes | undefined,\n bufferType: 'annotation' | 'buffer' | 'metadata',\n size: number\n): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-gutter-buffer': bufferType,\n 'data-buffer-size': size,\n 'data-line-type': bufferType === 'annotation' ? undefined : type,\n style:\n bufferType === 'annotation'\n ? `grid-row: span ${size};`\n :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AoB;GACpB,kBAAkB,eAAe,eAAe,SAAY;GAC5D,OACE,eAAe,eACX,kBAAkB,KAAK,KACvB,kBAAkB,KAAK,mBAAmB,KAAK;GACtD;EACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/utils/hostTheme.d.ts
|
|
2
|
+
interface UpsertHostThemeStyleProps {
|
|
3
|
+
shadowRoot: ShadowRoot;
|
|
4
|
+
currentNode: HTMLStyleElement | undefined;
|
|
5
|
+
themeCSS: string;
|
|
6
|
+
}
|
|
7
|
+
declare function upsertHostThemeStyle({
|
|
8
|
+
shadowRoot,
|
|
9
|
+
currentNode,
|
|
10
|
+
themeCSS
|
|
11
|
+
}: UpsertHostThemeStyleProps): HTMLStyleElement | undefined;
|
|
12
|
+
declare function createHostThemeStyleNode(): HTMLStyleElement;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createHostThemeStyleNode, upsertHostThemeStyle };
|
|
15
|
+
//# sourceMappingURL=hostTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostTheme.d.ts","names":["UpsertHostThemeStyleProps","ShadowRoot","HTMLStyleElement","upsertHostThemeStyle","shadowRoot","currentNode","themeCSS","createHostThemeStyleNode"],"sources":["../../src/utils/hostTheme.d.ts"],"sourcesContent":["interface UpsertHostThemeStyleProps {\n shadowRoot: ShadowRoot;\n currentNode: HTMLStyleElement | undefined;\n themeCSS: string;\n}\nexport declare function upsertHostThemeStyle({ shadowRoot, currentNode, themeCSS }: UpsertHostThemeStyleProps): HTMLStyleElement | undefined;\nexport declare function createHostThemeStyleNode(): HTMLStyleElement;\nexport {};\n//# sourceMappingURL=hostTheme.d.ts.map"],"mappings":";UAAUA,yBAAAA;EAAAA,UAAAA,EACMC,UADND;EAKcG,WAAAA,EAHPD,gBAG2B,GAAA,SAAA;EAAGE,QAAAA,EAAAA,MAAAA;;AAAyBE,iBAAhDH,oBAAAA,CAAgDG;EAAAA,UAAAA;EAAAA,WAAAA;EAAAA;AAAAA,CAAAA,EAAYN,yBAAZM,CAAAA,EAAwCJ,gBAAxCI,GAAAA,SAAAA;AAAYN,iBAC5DO,wBAAAA,CAAAA,CAD4DP,EAChCE,gBADgCF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { THEME_CSS_ATTRIBUTE } from "../constants.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/hostTheme.ts
|
|
4
|
+
function upsertHostThemeStyle({ shadowRoot, currentNode, themeCSS }) {
|
|
5
|
+
if (themeCSS.trim() === "") {
|
|
6
|
+
currentNode?.remove();
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
currentNode ??= createHostThemeStyleNode();
|
|
10
|
+
currentNode.textContent = themeCSS;
|
|
11
|
+
if (currentNode.parentNode !== shadowRoot) shadowRoot.appendChild(currentNode);
|
|
12
|
+
return currentNode;
|
|
13
|
+
}
|
|
14
|
+
function createHostThemeStyleNode() {
|
|
15
|
+
const node = document.createElement("style");
|
|
16
|
+
node.setAttribute(THEME_CSS_ATTRIBUTE, "");
|
|
17
|
+
return node;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createHostThemeStyleNode, upsertHostThemeStyle };
|
|
22
|
+
//# sourceMappingURL=hostTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostTheme.js","names":[],"sources":["../../src/utils/hostTheme.ts"],"sourcesContent":["import { THEME_CSS_ATTRIBUTE } from '../constants';\n\ninterface UpsertHostThemeStyleProps {\n shadowRoot: ShadowRoot;\n currentNode: HTMLStyleElement | undefined;\n themeCSS: string;\n}\n\n// Keep the host theme style stable so renderers can update the host-scoped theme\n// CSS without rebuilding the rest of the shadow DOM.\nexport function upsertHostThemeStyle({\n shadowRoot,\n currentNode,\n themeCSS,\n}: UpsertHostThemeStyleProps): HTMLStyleElement | undefined {\n if (themeCSS.trim() === '') {\n currentNode?.remove();\n return undefined;\n }\n\n currentNode ??= createHostThemeStyleNode();\n currentNode.textContent = themeCSS;\n if (currentNode.parentNode !== shadowRoot) {\n shadowRoot.appendChild(currentNode);\n }\n return currentNode;\n}\n\nexport function createHostThemeStyleNode(): HTMLStyleElement {\n const node = document.createElement('style');\n node.setAttribute(THEME_CSS_ATTRIBUTE, '');\n return node;\n}\n"],"mappings":";;;AAUA,SAAgB,qBAAqB,EACnC,YACA,aACA,YAC0D;AAC1D,KAAI,SAAS,MAAM,KAAK,IAAI;AAC1B,eAAa,QAAQ;AACrB;;AAGF,iBAAgB,0BAA0B;AAC1C,aAAY,cAAc;AAC1B,KAAI,YAAY,eAAe,WAC7B,YAAW,YAAY,YAAY;AAErC,QAAO;;AAGT,SAAgB,2BAA6C;CAC3D,MAAM,OAAO,SAAS,cAAc,QAAQ;AAC5C,MAAK,aAAa,qBAAqB,GAAG;AAC1C,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDiffPlainText.d.ts","names":["FileDiffMetadata","isDiffPlainText"],"sources":["../../src/utils/isDiffPlainText.d.ts"],"sourcesContent":["import type { FileDiffMetadata } from '../types';\nexport declare function isDiffPlainText(diff: FileDiffMetadata): boolean;\n//# sourceMappingURL=isDiffPlainText.d.ts.map"],"mappings":";;;iBACwBC,eAAAA,OAAsBD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getFiletypeFromFileName } from "./getFiletypeFromFileName.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/isDiffPlainText.ts
|
|
4
|
+
function isDiffPlainText(diff) {
|
|
5
|
+
const computedLang = diff.lang ?? getFiletypeFromFileName(diff.name);
|
|
6
|
+
const computedPreviousLang = diff.lang ?? (diff.prevName != null ? getFiletypeFromFileName(diff.prevName) : "text");
|
|
7
|
+
return computedLang === "text" && computedPreviousLang === "text";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isDiffPlainText };
|
|
12
|
+
//# sourceMappingURL=isDiffPlainText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDiffPlainText.js","names":[],"sources":["../../src/utils/isDiffPlainText.ts"],"sourcesContent":["import type { FileDiffMetadata } from '../types';\nimport { getFiletypeFromFileName } from './getFiletypeFromFileName';\n\nexport function isDiffPlainText(diff: FileDiffMetadata): boolean {\n const computedLang = diff.lang ?? getFiletypeFromFileName(diff.name);\n const computedPreviousLang =\n diff.lang ??\n (diff.prevName != null ? getFiletypeFromFileName(diff.prevName) : 'text');\n return computedLang === 'text' && computedPreviousLang === 'text';\n}\n"],"mappings":";;;AAGA,SAAgB,gBAAgB,MAAiC;CAC/D,MAAM,eAAe,KAAK,QAAQ,wBAAwB,KAAK,KAAK;CACpE,MAAM,uBACJ,KAAK,SACJ,KAAK,YAAY,OAAO,wBAAwB,KAAK,SAAS,GAAG;AACpE,QAAO,iBAAiB,UAAU,yBAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFilePlainText.d.ts","names":["FileContents","isFilePlainText"],"sources":["../../src/utils/isFilePlainText.d.ts"],"sourcesContent":["import type { FileContents } from '../types';\nexport declare function isFilePlainText(file: FileContents): boolean;\n//# sourceMappingURL=isFilePlainText.d.ts.map"],"mappings":";;;iBACwBC,eAAAA,OAAsBD"}
|